aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjoschiwald <joschiwald.trinity@gmail.com>2014-06-28 00:57:44 +0200
committerjoschiwald <joschiwald.trinity@gmail.com>2014-06-28 00:57:44 +0200
commitd20a5f3df080ce44d547ee98bca875e01598cd64 (patch)
treee61269cbeebb9e5b85c5dba0f0b84fddfb2129ad /src
parentc28345e279f31af2fa32df2411325ccfabe06fc8 (diff)
Scripts/Commands: fixed possible client crash with .go command
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp4
-rw-r--r--src/server/game/Globals/ObjectMgr.h2
-rw-r--r--src/server/scripts/Commands/cs_go.cpp32
3 files changed, 24 insertions, 14 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 72ea1b16864..9eb7d5ec1bf 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1668,7 +1668,7 @@ void ObjectMgr::LoadCreatures()
}
// Skip spawnMask check for transport maps
- if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
+ if (!IsTransportMap(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u).", guid, data.spawnMask, data.mapid);
bool ok = true;
@@ -2003,7 +2003,7 @@ void ObjectMgr::LoadGameobjects()
data.spawnMask = fields[14].GetUInt8();
- if (!_transportMaps.count(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
+ if (!IsTransportMap(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: %u Entry: %u) that has wrong spawn mask %u including not supported difficulty modes for map (Id: %u), skip", guid, data.id, data.spawnMask, data.mapid);
data.phaseMask = fields[15].GetUInt32();
diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h
index ba5940d7e12..e5e55b847d3 100644
--- a/src/server/game/Globals/ObjectMgr.h
+++ b/src/server/game/Globals/ObjectMgr.h
@@ -1293,6 +1293,8 @@ class ObjectMgr
void LoadFactionChangeSpells();
void LoadFactionChangeTitles();
+ bool IsTransportMap(uint32 mapId) const { return _transportMaps.count(mapId); }
+
private:
// first free id for selected id type
uint32 _auctionId;
diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp
index 3c1fa973cd8..44ebb1ea4e0 100644
--- a/src/server/scripts/Commands/cs_go.cpp
+++ b/src/server/scripts/Commands/cs_go.cpp
@@ -29,6 +29,7 @@ EndScriptData */
#include "Chat.h"
#include "Language.h"
#include "Player.h"
+#include "Transport.h"
class go_commandscript : public CommandScript
{
@@ -132,21 +133,24 @@ public:
float x = fields[0].GetFloat();
float y = fields[1].GetFloat();
float z = fields[2].GetFloat();
- float ort = fields[3].GetFloat();
- int mapId = fields[4].GetUInt16();
+ float o = fields[3].GetFloat();
+ uint32 mapId = fields[4].GetUInt16();
uint32 guid = fields[5].GetUInt32();
uint32 id = fields[6].GetUInt32();
- // if creature is in same map with caster go at its current location
- if (Creature* creature = sObjectAccessor->GetCreature(*player, MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT)))
+ Transport* transport = NULL;
+
+ if (Creature* creature = ObjectAccessor::GetObjectInWorld(MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT), (Creature*)NULL))
{
x = creature->GetPositionX();
y = creature->GetPositionY();
z = creature->GetPositionZ();
- ort = creature->GetOrientation();
+ o = creature->GetOrientation();
+ mapId = creature->GetMapId();
+ transport = creature->GetTransport();
}
- if (!MapManager::IsValidMapCoord(mapId, x, y, z, ort))
+ if (!MapManager::IsValidMapCoord(mapId, x, y, z, o) || sObjectMgr->IsTransportMap(mapId))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
handler->SetSentErrorMessage(true);
@@ -163,7 +167,11 @@ public:
else
player->SaveRecallPosition();
- player->TeleportTo(mapId, x, y, z, ort);
+ if (player->TeleportTo(mapId, x, y, z, o))
+ {
+ if (transport)
+ transport->AddPassenger(player);
+ }
return true;
}
@@ -274,8 +282,8 @@ public:
if (!guid)
return false;
- float x, y, z, ort;
- int mapId;
+ float x, y, z, o;
+ uint32 mapId;
// by DB guid
if (GameObjectData const* goData = sObjectMgr->GetGOData(guid))
@@ -283,7 +291,7 @@ public:
x = goData->posX;
y = goData->posY;
z = goData->posZ;
- ort = goData->orientation;
+ o = goData->orientation;
mapId = goData->mapid;
}
else
@@ -293,7 +301,7 @@ public:
return false;
}
- if (!MapManager::IsValidMapCoord(mapId, x, y, z, ort))
+ if (!MapManager::IsValidMapCoord(mapId, x, y, z, o) || sObjectMgr->IsTransportMap(mapId))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
handler->SetSentErrorMessage(true);
@@ -310,7 +318,7 @@ public:
else
player->SaveRecallPosition();
- player->TeleportTo(mapId, x, y, z, ort);
+ player->TeleportTo(mapId, x, y, z, o);
return true;
}