Scripts/Commands: fixed possible client crash with .go command

This commit is contained in:
joschiwald
2014-06-28 00:57:44 +02:00
parent c28345e279
commit d20a5f3df0
3 changed files with 24 additions and 14 deletions

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;
}