mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[10106] More modes for .go commands
* Now '.go' command can be used with creature_entry/gameobject_entry shift links (output of .lookup creature/object commands) * Now '.go object' command sipport id-mode and name part mode similar .go creature case: .go object id #gameobject_id or .go object $namepart. * HandleGoHelper use in more commands also.
This commit is contained in:
parent
e203a235ba
commit
a504b4d200
13 changed files with 439 additions and 235 deletions
|
|
@ -1928,38 +1928,6 @@ char* ChatHandler::extractKeyFromLink(char* text, char const* const* linkTypes,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
char const *fmtstring( char const *format, ... )
|
||||
{
|
||||
va_list argptr;
|
||||
#define MAX_FMT_STRING 32000
|
||||
static char temp_buffer[MAX_FMT_STRING];
|
||||
static char string[MAX_FMT_STRING];
|
||||
static int index = 0;
|
||||
char *buf;
|
||||
int len;
|
||||
|
||||
va_start(argptr, format);
|
||||
vsnprintf(temp_buffer,MAX_FMT_STRING, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
len = strlen(temp_buffer);
|
||||
|
||||
if( len >= MAX_FMT_STRING )
|
||||
return "ERROR";
|
||||
|
||||
if (len + index >= MAX_FMT_STRING-1)
|
||||
{
|
||||
index = 0;
|
||||
}
|
||||
|
||||
buf = &string[index];
|
||||
memcpy( buf, temp_buffer, len+1 );
|
||||
|
||||
index += len + 1;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid,uint32 entry)
|
||||
{
|
||||
if(!m_session)
|
||||
|
|
@ -2135,11 +2103,13 @@ uint64 ChatHandler::extractGuidFromLink(char* text)
|
|||
|
||||
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
|
||||
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,
|
||||
LOCATION_LINK_CREATURE_ENTRY = 5,
|
||||
LOCATION_LINK_GAMEOBJECT_ENTRY = 6
|
||||
};
|
||||
|
||||
static char const* const locationKeys[] =
|
||||
|
|
@ -2149,6 +2119,8 @@ static char const* const locationKeys[] =
|
|||
"Hplayer",
|
||||
"Hcreature",
|
||||
"Hgameobject",
|
||||
"Hcreature_entry",
|
||||
"Hgameobject_entry",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
@ -2161,6 +2133,8 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
|||
// |color|Htaxinode:id|h[name]|h|r
|
||||
// |color|Hcreature:creature_guid|h[name]|h|r
|
||||
// |color|Hgameobject:go_guid|h[name]|h|r
|
||||
// |color|Hcreature_entry:creature_id|h[name]|h|r
|
||||
// |color|Hgameobject_entry:go_id|h[name]|h|r
|
||||
char* idS = extractKeyFromLink(text,locationKeys,&type);
|
||||
if(!idS)
|
||||
return false;
|
||||
|
|
@ -2251,6 +2225,54 @@ bool ChatHandler::extractLocationFromLink(char* text, uint32& mapid, float& x, f
|
|||
else
|
||||
return false;
|
||||
}
|
||||
case LOCATION_LINK_CREATURE_ENTRY:
|
||||
{
|
||||
uint32 id = (uint32)atol(idS);
|
||||
|
||||
if (sObjectMgr.GetCreatureTemplate(id))
|
||||
{
|
||||
FindCreatureData worker(id, m_session ? m_session->GetPlayer() : NULL);
|
||||
|
||||
sObjectMgr.DoCreatureData(worker);
|
||||
|
||||
if (CreatureDataPair const* dataPair = worker.GetResult())
|
||||
{
|
||||
mapid = dataPair->second.mapid;
|
||||
x = dataPair->second.posX;
|
||||
y = dataPair->second.posY;
|
||||
z = dataPair->second.posZ;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
case LOCATION_LINK_GAMEOBJECT_ENTRY:
|
||||
{
|
||||
uint32 id = (uint32)atol(idS);
|
||||
|
||||
if (sObjectMgr.GetGameObjectInfo(id))
|
||||
{
|
||||
FindGOData worker(id, m_session ? m_session->GetPlayer() : NULL);
|
||||
|
||||
sObjectMgr.DoGOData(worker);
|
||||
|
||||
if (GameObjectDataPair const* dataPair = worker.GetResult())
|
||||
{
|
||||
mapid = dataPair->second.mapid;
|
||||
x = dataPair->second.posX;
|
||||
y = dataPair->second.posY;
|
||||
z = dataPair->second.posZ;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// unknown type?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue