diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-09-22 12:49:14 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-09-22 12:49:14 +0200 |
commit | 8e029bf217c852a37d47bf82fe26e6f521e3a93c (patch) | |
tree | c63c30ed245ab3ea4d19c3c2be5d6cba29d6d556 | |
parent | e1ec951b43884711d808cf46389357571c874fc5 (diff) | |
parent | 49762e3472fd4098fb3ae1a18f751024056e40df (diff) | |
download | manaserv-8e029bf217c852a37d47bf82fe26e6f521e3a93c.tar.gz manaserv-8e029bf217c852a37d47bf82fe26e6f521e3a93c.tar.bz2 manaserv-8e029bf217c852a37d47bf82fe26e6f521e3a93c.tar.xz manaserv-8e029bf217c852a37d47bf82fe26e6f521e3a93c.zip |
Merge branch 'master' into lpc2012
-rw-r--r-- | .travis.yml | 8 | ||||
-rw-r--r-- | src/game-server/mapcomposite.cpp | 57 | ||||
-rw-r--r-- | src/game-server/mapcomposite.h | 4 |
3 files changed, 49 insertions, 20 deletions
diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..bbebefd2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: cpp +compiler: + - gcc + - clang +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq sqlite3 cmake make gcc libxml2-dev liblua5.1-0-dev libphysfs-dev libsqlite3-dev libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-pango-dev libsdl-ttf2.0-dev libsdl1.2-dev libguichan-dev libphysfs-dev libenet1a libcurl4-openssl-dev libcurl3 zlib1g-dev libmysqlclient-dev +script: cmake . -DWITH_MYSQL=ON && make diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp index d684fd70..cdea12a8 100644 --- a/src/game-server/mapcomposite.cpp +++ b/src/game-server/mapcomposite.cpp @@ -500,6 +500,8 @@ bool MapComposite::activate() else mPvPRules = PVP_NONE; + mActive = true; + if (!mInitializeCallback.isValid()) { LOG_WARN("No callback for map initialization found"); @@ -512,8 +514,6 @@ bool MapComposite::activate() s->execute(); } - mActive = true; - return true; } @@ -729,6 +729,28 @@ void MapComposite::callWorldVariableCallback(const std::string &key, } /** + * Finds a map object by its name and type. + * Name and type are case insensitive. + */ +const MapObject *MapComposite::findMapObject(const std::string &name, + const std::string &type) const +{ + const std::vector<MapObject *> &destObjects = mMap->getObjects(); + std::vector<MapObject *>::const_iterator it, it_end; + for (it = destObjects.begin(), it_end = destObjects.end(); + it != it_end; ++it) + { + const MapObject *obj = *it; + if (utils::compareStrI(obj->getType(), type) == 0 && + utils::compareStrI(obj->getName(), name) == 0) + { + return obj; + } + } + return 0; // nothing found +} + +/** * Initializes the map content. This creates the warps, spawn areas, npcs and * other scripts. */ @@ -754,24 +776,19 @@ void MapComposite::initializeContent() if (destMap && !destMapObjectName.empty()) { - const std::vector<MapObject *> &destObjects = - destMap->getMap()->getObjects(); - - std::vector<MapObject *>::const_iterator it, it_end; - for (it = destObjects.begin(), it_end = destObjects.end(); - it != it_end; ++it) + const MapObject *obj = + destMap->findMapObject(destMapObjectName, "WARP"); + if (obj) + { + const Rectangle &rect = obj->getBounds(); + destX = rect.x + rect.w / 2; + destY = rect.y + rect.h / 2; + } + else { - const MapObject *destObject = *it; - if (utils::compareStrI(destObject->getType(), - "WARP_DEST") == 0 && - utils::compareStrI(destObject->getName(), - destMapObjectName) == 0) - { - const Rectangle &rect = destObject->getBounds(); - destX = rect.x + rect.w / 2; - destY = rect.y + rect.h / 2; - break; - } + LOG_ERROR("Warp target \"" << destMapObjectName << "\" " + << "was not found on the map " + << destMap->getName()); } } else @@ -789,7 +806,7 @@ void MapComposite::initializeContent() } else { - LOG_WARN("Unrecognized warp format"); + LOG_WARN("Unrecognized warp format on map " << mName); } } else if (utils::compareStrI(type, "SPAWN") == 0) diff --git a/src/game-server/mapcomposite.h b/src/game-server/mapcomposite.h index d61f8ce6..ba76ddc8 100644 --- a/src/game-server/mapcomposite.h +++ b/src/game-server/mapcomposite.h @@ -27,6 +27,7 @@ #include <map> #include "scripting/script.h" +#include "game-server/map.h" class Actor; class Being; @@ -361,6 +362,9 @@ class MapComposite static void setUpdateCallback(Script *script) { script->assignCallback(mUpdateCallback); } + const MapObject *findMapObject(const std::string &name, + const std::string &type) const; + private: MapComposite(const MapComposite &); |