* added: auto-query player name on UPDATETYPE_CREATE_OBJECT

* added Object::_name to store object names faster & easier accessable. only players & items are added yet.
* added a small check for headers < 4 bytes (this can MAYBE fix some problems/errors with crypt)
This commit is contained in:
False.Genesis 2007-02-28 21:17:01 +00:00
parent 0d5e55fc67
commit bc74818daa
5 changed files with 29 additions and 5 deletions

View File

@ -96,10 +96,13 @@ public:
inline float GetY(void) { return _y; } inline float GetY(void) { return _y; }
inline float GetZ(void) { return _z; } inline float GetZ(void) { return _z; }
inline float GetO(void) { return _o; } inline float GetO(void) { return _o; }
inline void SetName(std::string name) { _name = name; }
inline std::string GetName(void) { return _name; }
protected: protected:
WorldObject(); WorldObject();
float _x,_y,_z,_o; // coords, orientation float _x,_y,_z,_o; // coords, orientation
uint16 _m; // map uint16 _m; // map
std::string _name;
}; };

View File

@ -134,7 +134,7 @@ void WorldSession::_HandleUpdateObjectOpcode(WorldPacket& recvPacket)
this->_MovementUpdate(objtypeid, uguid, recvPacket); this->_MovementUpdate(objtypeid, uguid, recvPacket);
this->_ValuesUpdate(uguid, recvPacket); this->_ValuesUpdate(uguid, recvPacket);
_QueryObjectProto(uguid); _QueryObjectInfo(uguid);
} }
break; break;
@ -282,7 +282,7 @@ void WorldSession::_ValuesUpdate(uint64 uguid, WorldPacket& recvPacket)
} }
void WorldSession::_QueryObjectProto(uint64 guid) void WorldSession::_QueryObjectInfo(uint64 guid)
{ {
Object *obj = objmgr.GetObj(guid); Object *obj = objmgr.GetObj(guid);
if(obj) if(obj)
@ -299,7 +299,19 @@ void WorldSession::_QueryObjectProto(uint64 guid)
SendQueryItem(obj->GetEntry(),obj->GetGUID()); // not sure if sending GUID is correct SendQueryItem(obj->GetEntry(),obj->GetGUID()); // not sure if sending GUID is correct
} }
} }
// case ... case TYPEID_PLAYER:
{
std::string name = plrNameCache.GetName(guid);
if(name.empty())
{
SendQueryPlayerName(guid);
}
else
{
((WorldObject*)obj)->SetName(name);
}
}
//case...
} }
} }
} }

View File

@ -546,6 +546,9 @@ void WorldSession::_HandleNameQueryResponseOpcode(WorldPacket& recvPacket)
if(GetInstance()->GetConf()->debug > 1) if(GetInstance()->GetConf()->debug > 1)
SendChatMessage(CHAT_MSG_SAY,0,"Player "+pname+" added to cache.",""); SendChatMessage(CHAT_MSG_SAY,0,"Player "+pname+" added to cache.","");
} }
WorldObject *wo = (WorldObject*)objmgr.GetObj(pguid);
if(wo)
wo->SetName(pname);
} }
void WorldSession::_HandlePongOpcode(WorldPacket& recvPacket) void WorldSession::_HandlePongOpcode(WorldPacket& recvPacket)

View File

@ -95,7 +95,7 @@ private:
void _MovementUpdate(uint8 objtypeid, uint64 guid, WorldPacket& recvPacket); // Helper for _HandleUpdateObjectOpcode void _MovementUpdate(uint8 objtypeid, uint64 guid, WorldPacket& recvPacket); // Helper for _HandleUpdateObjectOpcode
void _ValuesUpdate(uint64 uguid, WorldPacket& recvPacket); // ... void _ValuesUpdate(uint64 uguid, WorldPacket& recvPacket); // ...
void _QueryObjectProto(uint64 guid); void _QueryObjectInfo(uint64 guid);
PseuInstance *_instance; PseuInstance *_instance;
WorldSocket *_socket; WorldSocket *_socket;

View File

@ -42,6 +42,12 @@ void WorldSocket::OnRead()
this->CloseAndDelete(); this->CloseAndDelete();
return; return;
} }
// a valid header needs to have at least 4 bytes
if(len < 4 && (!_gothdr))
{
logerror("WorldSocket::OnRead(): Got %u bytes (header too small) - waiting for more data",len);
return;
}
uint8 *buf=new uint8[len]; uint8 *buf=new uint8[len];
ibuf.Read((char*)buf,len); ibuf.Read((char*)buf,len);
@ -76,7 +82,7 @@ void WorldSocket::OnRead()
// if the crypt gets messy its hardly possible to recover it, especially if we dont know // if the crypt gets messy its hardly possible to recover it, especially if we dont know
// the lentgh of the following data part // the lentgh of the following data part
// TODO: invent some way how to recover the crypt (reconnect?) // TODO: invent some way how to recover the crypt (reconnect?)
delete [] buf; // drop the current queue content delete buf; // drop the current queue content
return; return;
} }