mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[10086] Implement use .go command with shiftlinks or player name.
* Now if for .go command provided no X Y Z args command will not teleport player to nowhere. * Instead command allow used with player name and work as simplifed .goname (teleport to player _point_ in user instance binding, not to player instance) * Also command can be used with diferent point coordinates provided shift-links: - player (result for example .lookup player account) - creature (result .list creature command) - gameobject (result .list object command) - tele (result .lookup tele) - taxinode (result .lookup taxinode)
This commit is contained in:
parent
f28bc74e66
commit
619f01e150
8 changed files with 239 additions and 113 deletions
|
|
@ -216,7 +216,7 @@ ChatCommand * ChatHandler::getCommandTable()
|
|||
{ "zonexy", SEC_MODERATOR, false, &ChatHandler::HandleGoZoneXYCommand, "", NULL },
|
||||
{ "xy", SEC_MODERATOR, false, &ChatHandler::HandleGoXYCommand, "", NULL },
|
||||
{ "xyz", SEC_MODERATOR, false, &ChatHandler::HandleGoXYZCommand, "", NULL },
|
||||
{ "", SEC_MODERATOR, false, &ChatHandler::HandleGoXYZCommand, "", NULL },
|
||||
{ "", SEC_MODERATOR, false, &ChatHandler::HandleGoCommand, "", NULL },
|
||||
{ NULL, 0, false, NULL, "", NULL }
|
||||
};
|
||||
|
||||
|
|
@ -2133,6 +2133,130 @@ uint64 ChatHandler::extractGuidFromLink(char* text)
|
|||
return 0;
|
||||
}
|
||||
|
||||
enum LocationLinkType
|
||||
{
|
||||
LOCATION_LINK_PLAYER = 0, // must be first for selection in not link case
|
||||
LOCATION_LINK_TELE = 1,
|
||||
LOCATION_LINK_TAXINODE = 2,
|
||||
LOCATION_LINK_CREATURE = 3,
|
||||
LOCATION_LINK_GAMEOBJECT = 4
|
||||
};
|
||||
|
||||
static char const* const locationKeys[] =
|
||||
{
|
||||
"Htele",
|
||||
"Htaxinode",
|
||||
"Hplayer",
|
||||
"Hcreature",
|
||||
"Hgameobject",
|
||||
NULL
|
||||
};
|
||||
|
||||
bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, float& y, float& z)
|
||||
{
|
||||
int type = 0;
|
||||
|
||||
// |color|Hplayer:name|h[name]|h|r
|
||||
// |color|Htele:id|h[name]|h|r
|
||||
// |color|Htaxinode:id|h[name]|h|r
|
||||
// |color|Hcreature:creature_guid|h[name]|h|r
|
||||
// |color|Hgameobject:go_guid|h[name]|h|r
|
||||
char* idS = extractKeyFromLink(text,locationKeys,&type);
|
||||
if(!idS)
|
||||
return false;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
// it also fail case
|
||||
case LOCATION_LINK_PLAYER:
|
||||
{
|
||||
// not link and not name, possible coordinates/etc
|
||||
if (isNumeric(idS[0]))
|
||||
return false;
|
||||
|
||||
std::string name = idS;
|
||||
if(!normalizePlayerName(name))
|
||||
return false;
|
||||
|
||||
if(Player* player = sObjectMgr.GetPlayer(name.c_str()))
|
||||
{
|
||||
mapid = player->GetMapId();
|
||||
x = player->GetPositionX();
|
||||
y = player->GetPositionY();
|
||||
z = player->GetPositionZ();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(uint64 guid = sObjectMgr.GetPlayerGUIDByName(name))
|
||||
{
|
||||
// to point where player stay (if loaded)
|
||||
float o;
|
||||
bool in_flight;
|
||||
return Player::LoadPositionFromDB(mapid, x, y, z, o, in_flight, guid);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
case LOCATION_LINK_TELE:
|
||||
{
|
||||
uint32 id = (uint32)atol(idS);
|
||||
GameTele const* tele = sObjectMgr.GetGameTele(id);
|
||||
if (!tele)
|
||||
return false;
|
||||
mapid = tele->mapId;
|
||||
x = tele->position_x;
|
||||
y = tele->position_y;
|
||||
z = tele->position_z;
|
||||
return true;
|
||||
}
|
||||
case LOCATION_LINK_TAXINODE:
|
||||
{
|
||||
uint32 id = (uint32)atol(idS);
|
||||
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
|
||||
if (!node)
|
||||
return false;
|
||||
mapid = node->map_id;
|
||||
x = node->x;
|
||||
y = node->y;
|
||||
z = node->z;
|
||||
return true;
|
||||
}
|
||||
case LOCATION_LINK_CREATURE:
|
||||
{
|
||||
uint32 lowguid = (uint32)atol(idS);
|
||||
|
||||
if(CreatureData const* data = sObjectMgr.GetCreatureData(lowguid) )
|
||||
{
|
||||
mapid = data->mapid;
|
||||
x = data->posX;
|
||||
y = data->posY;
|
||||
z = data->posZ;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
case LOCATION_LINK_GAMEOBJECT:
|
||||
{
|
||||
uint32 lowguid = (uint32)atol(idS);
|
||||
|
||||
if(GameObjectData const* data = sObjectMgr.GetGOData(lowguid) )
|
||||
{
|
||||
mapid = data->mapid;
|
||||
x = data->posX;
|
||||
y = data->posY;
|
||||
z = data->posZ;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// unknown type?
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string ChatHandler::extractPlayerNameFromLink(char* text)
|
||||
{
|
||||
// |color|Hplayer:name|h[name]|h|r
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue