* Added reading items from chat messages and querying them if they are unknown

This commit is contained in:
False.Genesis 2007-02-04 01:12:16 +00:00
parent d6b6960c29
commit 931435b751
3 changed files with 27 additions and 0 deletions

View File

@ -5,4 +5,6 @@
#define GUID_LOPART(x) (*((uint32*)&(x)))
#define MAKE_GUID(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) )
#define CHAT_ITEM_BEGIN_STRING "|Hitem:"
#endif

View File

@ -70,6 +70,7 @@ void WorldSession::SendQueryItem(uint32 id, uint64 guid) // is it a guid? not su
logdebug("Skipped query of item %u (was marked as nonexistent before)",id);
return;
}
logdebug("Sending Item query, id=%u",id);
WorldPacket packet;
packet << id << guid;
packet.SetOpcode(CMSG_ITEM_QUERY_SINGLE);

View File

@ -461,6 +461,30 @@ void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket)
GetInstance()->GetScripts()->variables.Set("@thiswhisper_lang",toString((uint64)lang));
GetInstance()->GetScripts()->RunScript("_onwhisper",NULL);
}
// the following block searches for items in chat and queries them if they are unknown
if(!isCmd && target_guid!=_myGUID && msg.length()>strlen(CHAT_ITEM_BEGIN_STRING))
{
for(uint32 pos=0;pos<msg.length()-strlen(CHAT_ITEM_BEGIN_STRING);pos++)
{
if(!memcmp(msg.c_str()+pos,CHAT_ITEM_BEGIN_STRING,strlen(CHAT_ITEM_BEGIN_STRING)))
{
std::string itemid;
uint32 id;
while(msg[pos] != ':')
{
itemid += msg[pos+strlen(CHAT_ITEM_BEGIN_STRING)];
pos++;
}
id = atoi(itemid.c_str());
logdebug("Found Item in chat message: %u",id);
if(objmgr.GetItemProto(id)==NULL)
SendQueryItem(id,0);
}
}
}
}
void WorldSession::_HandleNameQueryResponseOpcode(WorldPacket& recvPacket)
{