summaryrefslogtreecommitdiffstats
path: root/src/game-server/mapcomposite.cpp
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2012-09-06 21:00:16 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2012-09-22 12:48:50 +0200
commit86c407e390c4a390119174554330ec01dd8b236a (patch)
tree1b2eb468d238aedf90c857311b55f39fbe877b43 /src/game-server/mapcomposite.cpp
parent7022f62efc52599324cb6fbe16a7cf777bb3fad6 (diff)
downloadmanaserv-86c407e390c4a390119174554330ec01dd8b236a.tar.gz
manaserv-86c407e390c4a390119174554330ec01dd8b236a.tar.xz
manaserv-86c407e390c4a390119174554330ec01dd8b236a.zip
Fixed marking map as activated
The patch that allowed to use map objects as warp targets broke this. During run of map initalize mActive was still false. This broke creating objects (npc, triggers) in atinit. Reviewed-by: bjorn.
Diffstat (limited to 'src/game-server/mapcomposite.cpp')
-rw-r--r--src/game-server/mapcomposite.cpp55
1 files changed, 36 insertions, 19 deletions
diff --git a/src/game-server/mapcomposite.cpp b/src/game-server/mapcomposite.cpp
index d684fd7..962dbee 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