mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-18 06:00:10 -04:00
Script/Commands: Codestyle and cleanups
This commit is contained in:
@@ -57,6 +57,7 @@ public:
|
||||
};
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
/** \brief Teleport the GM to the specified creature
|
||||
*
|
||||
* .gocreature <GUID> --> TP using creature.guid
|
||||
@@ -68,59 +69,52 @@ public:
|
||||
* you will be teleported to the first one that is found.
|
||||
*/
|
||||
//teleport to creature
|
||||
static bool HandleGoCreatureCommand(ChatHandler* handler, const char* args)
|
||||
static bool HandleGoCreatureCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
Player* _player = handler->GetSession()->GetPlayer();
|
||||
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
// "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
|
||||
char* pParam1 = handler->extractKeyFromLink((char*)args, "Hcreature");
|
||||
if (!pParam1)
|
||||
char* param1 = handler->extractKeyFromLink((char*)args, "Hcreature");
|
||||
if (!param1)
|
||||
return false;
|
||||
|
||||
std::ostringstream whereClause;
|
||||
|
||||
// User wants to teleport to the NPC's template entry
|
||||
if (strcmp(pParam1, "id") == 0)
|
||||
if (strcmp(param1, "id") == 0)
|
||||
{
|
||||
//sLog->outError("DEBUG: ID found");
|
||||
|
||||
// Get the "creature_template.entry"
|
||||
// number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
|
||||
char* tail = strtok(NULL, "");
|
||||
if (!tail)
|
||||
return false;
|
||||
char* cId = handler->extractKeyFromLink(tail, "Hcreature_entry");
|
||||
if (!cId)
|
||||
char* id = handler->extractKeyFromLink(tail, "Hcreature_entry");
|
||||
if (!id)
|
||||
return false;
|
||||
|
||||
int32 tEntry = atoi(cId);
|
||||
//sLog->outError("DEBUG: ID value: %d", tEntry);
|
||||
if (!tEntry)
|
||||
int32 entry = atoi(id);
|
||||
if (!entry)
|
||||
return false;
|
||||
|
||||
whereClause << "WHERE id = '" << tEntry << '\'';
|
||||
whereClause << "WHERE id = '" << entry << '\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
//sLog->outError("DEBUG: ID *not found*");
|
||||
|
||||
int32 guid = atoi(pParam1);
|
||||
int32 guid = atoi(param1);
|
||||
|
||||
// Number is invalid - maybe the user specified the mob's name
|
||||
if (!guid)
|
||||
{
|
||||
std::string name = pParam1;
|
||||
std::string name = param1;
|
||||
WorldDatabase.EscapeString(name);
|
||||
whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name "_LIKE_" '" << name << '\'';
|
||||
}
|
||||
else
|
||||
{
|
||||
whereClause << "WHERE guid = '" << guid << '\'';
|
||||
}
|
||||
}
|
||||
//sLog->outError("DEBUG: %s", whereClause.c_str());
|
||||
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map, guid, id FROM creature %s", whereClause.str().c_str());
|
||||
if (!result)
|
||||
@@ -137,12 +131,12 @@ public:
|
||||
float y = fields[1].GetFloat();
|
||||
float z = fields[2].GetFloat();
|
||||
float ort = fields[3].GetFloat();
|
||||
int mapid = fields[4].GetUInt16();
|
||||
int 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)))
|
||||
if (Creature* creature = sObjectAccessor->GetCreature(*player, MAKE_NEW_GUID(guid, id, HIGHGUID_UNIT)))
|
||||
{
|
||||
x = creature->GetPositionX();
|
||||
y = creature->GetPositionY();
|
||||
@@ -150,46 +144,47 @@ public:
|
||||
ort = creature->GetOrientation();
|
||||
}
|
||||
|
||||
if (!MapManager::IsValidMapCoord(mapid, x, y, z, ort))
|
||||
if (!MapManager::IsValidMapCoord(mapId, x, y, z, ort))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid);
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
if (player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
player->GetMotionMaster()->MovementExpired();
|
||||
player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
player->SaveRecallPosition();
|
||||
|
||||
_player->TeleportTo(mapid, x, y, z, ort);
|
||||
player->TeleportTo(mapId, x, y, z, ort);
|
||||
return true;
|
||||
}
|
||||
static bool HandleGoGraveyardCommand(ChatHandler* handler, const char* args)
|
||||
|
||||
static bool HandleGoGraveyardCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
Player* _player = handler->GetSession()->GetPlayer();
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char *gyId = strtok((char*)args, " ");
|
||||
char* gyId = strtok((char*)args, " ");
|
||||
if (!gyId)
|
||||
return false;
|
||||
|
||||
int32 i_gyId = atoi(gyId);
|
||||
int32 graveyardId = atoi(gyId);
|
||||
|
||||
if (!i_gyId)
|
||||
if (!graveyardId)
|
||||
return false;
|
||||
|
||||
WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(i_gyId);
|
||||
WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(graveyardId);
|
||||
if (!gy)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, i_gyId);
|
||||
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, graveyardId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
@@ -202,93 +197,92 @@ public:
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
if (player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
player->GetMotionMaster()->MovementExpired();
|
||||
player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
player->SaveRecallPosition();
|
||||
|
||||
_player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, _player->GetOrientation());
|
||||
player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, player->GetOrientation());
|
||||
return true;
|
||||
}
|
||||
|
||||
//teleport to grid
|
||||
static bool HandleGoGridCommand(ChatHandler* handler, const char* args)
|
||||
static bool HandleGoGridCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args) return false;
|
||||
Player* _player = handler->GetSession()->GetPlayer();
|
||||
|
||||
char* px = strtok((char*)args, " ");
|
||||
char* py = strtok(NULL, " ");
|
||||
char* pmapid = strtok(NULL, " ");
|
||||
|
||||
if (!px || !py)
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
float grid_x = (float)atof(px);
|
||||
float grid_y = (float)atof(py);
|
||||
uint32 mapid;
|
||||
if (pmapid)
|
||||
mapid = (uint32)atoi(pmapid);
|
||||
else mapid = _player->GetMapId();
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
char* gridX = strtok((char*)args, " ");
|
||||
char* gridY = strtok(NULL, " ");
|
||||
char* id = strtok(NULL, " ");
|
||||
|
||||
if (!gridX || !gridY)
|
||||
return false;
|
||||
|
||||
uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId();
|
||||
|
||||
// center of grid
|
||||
float x = (grid_x-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS;
|
||||
float y = (grid_y-CENTER_GRID_ID+0.5f)*SIZE_OF_GRIDS;
|
||||
float x = ((float)atof(gridX) - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
|
||||
float y = ((float)atof(gridY) - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
|
||||
|
||||
if (!MapManager::IsValidMapCoord(mapid, x, y))
|
||||
if (!MapManager::IsValidMapCoord(mapId, x, y))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid);
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
if (player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
player->GetMotionMaster()->MovementExpired();
|
||||
player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
player->SaveRecallPosition();
|
||||
|
||||
Map const* map = sMapMgr->CreateBaseMap(mapid);
|
||||
Map const* map = sMapMgr->CreateBaseMap(mapId);
|
||||
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
|
||||
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
|
||||
|
||||
player->TeleportTo(mapId, x, y, z, player->GetOrientation());
|
||||
return true;
|
||||
}
|
||||
|
||||
//teleport to gameobject
|
||||
static bool HandleGoObjectCommand(ChatHandler* handler, const char* args)
|
||||
static bool HandleGoObjectCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* _player = handler->GetSession()->GetPlayer();
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
// number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
|
||||
char* cId = handler->extractKeyFromLink((char*)args, "Hgameobject");
|
||||
if (!cId)
|
||||
char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
|
||||
if (!id)
|
||||
return false;
|
||||
|
||||
int32 guid = atoi(cId);
|
||||
int32 guid = atoi(id);
|
||||
if (!guid)
|
||||
return false;
|
||||
|
||||
float x, y, z, ort;
|
||||
int mapid;
|
||||
int mapId;
|
||||
|
||||
// by DB guid
|
||||
if (GameObjectData const* go_data = sObjectMgr->GetGOData(guid))
|
||||
if (GameObjectData const* goData = sObjectMgr->GetGOData(guid))
|
||||
{
|
||||
x = go_data->posX;
|
||||
y = go_data->posY;
|
||||
z = go_data->posZ;
|
||||
ort = go_data->orientation;
|
||||
mapid = go_data->mapid;
|
||||
x = goData->posX;
|
||||
y = goData->posY;
|
||||
z = goData->posZ;
|
||||
ort = goData->orientation;
|
||||
mapId = goData->mapid;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -297,45 +291,46 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!MapManager::IsValidMapCoord(mapid, x, y, z, ort))
|
||||
if (!MapManager::IsValidMapCoord(mapId, x, y, z, ort))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid);
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
if (player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
player->GetMotionMaster()->MovementExpired();
|
||||
player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
player->SaveRecallPosition();
|
||||
|
||||
_player->TeleportTo(mapid, x, y, z, ort);
|
||||
player->TeleportTo(mapId, x, y, z, ort);
|
||||
return true;
|
||||
}
|
||||
static bool HandleGoTaxinodeCommand(ChatHandler* handler, const char* args)
|
||||
|
||||
static bool HandleGoTaxinodeCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
Player* _player = handler->GetSession()->GetPlayer();
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char* cNodeId = handler->extractKeyFromLink((char*)args, "Htaxinode");
|
||||
if (!cNodeId)
|
||||
char* id = handler->extractKeyFromLink((char*)args, "Htaxinode");
|
||||
if (!id)
|
||||
return false;
|
||||
|
||||
int32 i_nodeId = atoi(cNodeId);
|
||||
if (!i_nodeId)
|
||||
int32 nodeId = atoi(id);
|
||||
if (!nodeId)
|
||||
return false;
|
||||
|
||||
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i_nodeId);
|
||||
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(nodeId);
|
||||
if (!node)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND, i_nodeId);
|
||||
handler->PSendSysMessage(LANG_COMMAND_GOTAXINODENOTFOUND, nodeId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
@@ -349,38 +344,39 @@ public:
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
if (player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
player->GetMotionMaster()->MovementExpired();
|
||||
player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
player->SaveRecallPosition();
|
||||
|
||||
_player->TeleportTo(node->map_id, node->x, node->y, node->z, _player->GetOrientation());
|
||||
player->TeleportTo(node->map_id, node->x, node->y, node->z, player->GetOrientation());
|
||||
return true;
|
||||
}
|
||||
static bool HandleGoTriggerCommand(ChatHandler* handler, const char* args)
|
||||
|
||||
static bool HandleGoTriggerCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
Player* _player = handler->GetSession()->GetPlayer();
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char *atId = strtok((char*)args, " ");
|
||||
if (!atId)
|
||||
char* id = strtok((char*)args, " ");
|
||||
if (!id)
|
||||
return false;
|
||||
|
||||
int32 i_atId = atoi(atId);
|
||||
int32 areaTriggerId = atoi(id);
|
||||
|
||||
if (!i_atId)
|
||||
if (!areaTriggerId)
|
||||
return false;
|
||||
|
||||
AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(i_atId);
|
||||
AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(areaTriggerId);
|
||||
if (!at)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, i_atId);
|
||||
handler->PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, areaTriggerId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
@@ -393,49 +389,50 @@ public:
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
if (player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
player->GetMotionMaster()->MovementExpired();
|
||||
player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
player->SaveRecallPosition();
|
||||
|
||||
_player->TeleportTo(at->mapid, at->x, at->y, at->z, _player->GetOrientation());
|
||||
player->TeleportTo(at->mapid, at->x, at->y, at->z, player->GetOrientation());
|
||||
return true;
|
||||
}
|
||||
|
||||
//teleport at coordinates
|
||||
static bool HandleGoZoneXYCommand(ChatHandler* handler, const char* args)
|
||||
static bool HandleGoZoneXYCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* _player = handler->GetSession()->GetPlayer();
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
char* px = strtok((char*)args, " ");
|
||||
char* py = strtok(NULL, " ");
|
||||
char* zoneX = strtok((char*)args, " ");
|
||||
char* zoneY = strtok(NULL, " ");
|
||||
char* tail = strtok(NULL, "");
|
||||
|
||||
char* cAreaId = handler->extractKeyFromLink(tail, "Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r
|
||||
char* id = handler->extractKeyFromLink(tail, "Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r
|
||||
|
||||
if (!px || !py)
|
||||
if (!zoneX || !zoneY)
|
||||
return false;
|
||||
|
||||
float x = (float)atof(px);
|
||||
float y = (float)atof(py);
|
||||
float x = (float)atof(zoneX);
|
||||
float y = (float)atof(zoneY);
|
||||
|
||||
// prevent accept wrong numeric args
|
||||
if ((x == 0.0f && *px != '0') || (y == 0.0f && *py != '0'))
|
||||
if ((x == 0.0f && *zoneX != '0') || (y == 0.0f && *zoneY != '0'))
|
||||
return false;
|
||||
|
||||
uint32 areaid = cAreaId ? (uint32)atoi(cAreaId) : _player->GetZoneId();
|
||||
uint32 areaId = id ? (uint32)atoi(id) : player->GetZoneId();
|
||||
|
||||
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaid);
|
||||
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId);
|
||||
|
||||
if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_ZONE_COORD, x, y, areaid);
|
||||
handler->PSendSysMessage(LANG_INVALID_ZONE_COORD, x, y, areaId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
@@ -462,99 +459,90 @@ public:
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
if (player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
player->GetMotionMaster()->MovementExpired();
|
||||
player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
player->SaveRecallPosition();
|
||||
|
||||
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
|
||||
_player->TeleportTo(zoneEntry->mapid, x, y, z, _player->GetOrientation());
|
||||
|
||||
player->TeleportTo(zoneEntry->mapid, x, y, z, player->GetOrientation());
|
||||
return true;
|
||||
}
|
||||
|
||||
//teleport at coordinates, including Z and orientation
|
||||
static bool HandleGoXYZCommand(ChatHandler* handler, const char* args)
|
||||
static bool HandleGoXYZCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
Player* _player = handler->GetSession()->GetPlayer();
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
char* px = strtok((char*)args, " ");
|
||||
char* py = strtok(NULL, " ");
|
||||
char* pz = strtok(NULL, " ");
|
||||
char* pmapid = strtok(NULL, " ");
|
||||
char* goX = strtok((char*)args, " ");
|
||||
char* goY = strtok(NULL, " ");
|
||||
char* goZ = strtok(NULL, " ");
|
||||
char* id = strtok(NULL, " ");
|
||||
char* port = strtok(NULL, " ");
|
||||
|
||||
if (!px || !py)
|
||||
if (!goX || !goY)
|
||||
return false;
|
||||
|
||||
float x = (float)atof(px);
|
||||
float y = (float)atof(py);
|
||||
float x = (float)atof(goX);
|
||||
float y = (float)atof(goY);
|
||||
float z;
|
||||
float ort;
|
||||
uint32 mapid;
|
||||
|
||||
if (pmapid)
|
||||
mapid = (uint32)atoi(pmapid);
|
||||
else
|
||||
mapid = _player->GetMapId();
|
||||
|
||||
if ( port )
|
||||
ort = (float)atof(port);
|
||||
else
|
||||
ort = _player->GetOrientation();
|
||||
|
||||
if ( pz )
|
||||
float ort = port ? (float)atof(port) : player->GetOrientation();
|
||||
uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId();
|
||||
|
||||
if (goZ)
|
||||
{
|
||||
z = (float)atof(pz);
|
||||
if (!MapManager::IsValidMapCoord(mapid, x, y, z))
|
||||
z = (float)atof(goZ);
|
||||
if (!MapManager::IsValidMapCoord(mapId, x, y, z))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid);
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!MapManager::IsValidMapCoord(mapid, x, y))
|
||||
if (!MapManager::IsValidMapCoord(mapId, x, y))
|
||||
{
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapid);
|
||||
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
}
|
||||
Map const* map = sMapMgr->CreateBaseMap(mapid);
|
||||
Map const* map = sMapMgr->CreateBaseMap(mapId);
|
||||
z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if (_player->isInFlight())
|
||||
if (player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
player->GetMotionMaster()->MovementExpired();
|
||||
player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
// save only in non-flight case
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
|
||||
_player->TeleportTo(mapid, x, y, z, ort);
|
||||
player->SaveRecallPosition();
|
||||
|
||||
player->TeleportTo(mapId, x, y, z, ort);
|
||||
return true;
|
||||
}
|
||||
static bool HandleGoTicketCommand(ChatHandler* handler, const char* args)
|
||||
|
||||
static bool HandleGoTicketCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
char *sTicketId = strtok((char*)args, " ");
|
||||
if (!sTicketId)
|
||||
char* id = strtok((char*)args, " ");
|
||||
if (!id)
|
||||
return false;
|
||||
|
||||
uint32 ticketId = atoi(sTicketId);
|
||||
uint32 ticketId = atoi(id);
|
||||
if (!ticketId)
|
||||
return false;
|
||||
|
||||
@@ -565,16 +553,16 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
Player* _player = handler->GetSession()->GetPlayer();
|
||||
if (_player->isInFlight())
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
if (player->isInFlight())
|
||||
{
|
||||
_player->GetMotionMaster()->MovementExpired();
|
||||
_player->CleanupAfterTaxiFlight();
|
||||
player->GetMotionMaster()->MovementExpired();
|
||||
player->CleanupAfterTaxiFlight();
|
||||
}
|
||||
else
|
||||
_player->SaveRecallPosition();
|
||||
player->SaveRecallPosition();
|
||||
|
||||
ticket->TeleportTo(_player);
|
||||
ticket->TeleportTo(player);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user