* fixed bbread DefScript func in strnz mode
* optimized player name querying when recieving channel list (now all at once, not one by one) * cleanup: replaced valid player name lengths by #defines instead of hardcoded numbers
This commit is contained in:
parent
482669961d
commit
19cb07cfef
@ -88,7 +88,8 @@ DefReturnResult DefScriptPackage::func_bbread(CmdSet& Set)
|
||||
if(bytes)
|
||||
{
|
||||
std::string g;
|
||||
char *buf = new char[bytes];
|
||||
char *buf = new char[bytes+1]; // +1 for \0
|
||||
buf[bytes] = 0;
|
||||
bb->read((uint8*)buf,bytes);
|
||||
g = buf;
|
||||
delete [] buf;
|
||||
|
||||
@ -123,8 +123,9 @@ bool PlayerNameCache::ReadFromFile(void)
|
||||
PlayerNameCacheItem *cacheItem=new PlayerNameCacheItem;
|
||||
fh.read((char*)&(cacheItem->_guid),sizeof(uint64));
|
||||
fh.read((char*)&len,sizeof(uint8));
|
||||
if(len>12 || len<2){
|
||||
logerror("PlayerNameCache data seem corrupt [namelength=%d, should be <=12]",len);
|
||||
if(len > MAX_PLAYERNAME_LENGTH || len < MIN_PLAYERNAME_LENGTH)
|
||||
{
|
||||
logerror("PlayerNameCache data seem corrupt [namelength=%d, should be <=%u]",len,MAX_PLAYERNAME_LENGTH);
|
||||
log("-> Clearing cache, creating new.");
|
||||
_cache.clear();
|
||||
success=false;
|
||||
|
||||
@ -222,6 +222,8 @@ void Channel::HandleListRequest(WorldPacket& recvPacket)
|
||||
uint64 guid;
|
||||
uint8 mode, flags; // mode: player flags; flags: channel flags
|
||||
std::string name;
|
||||
bool must_delay = false;
|
||||
|
||||
recvPacket >> unk >> name >> flags >> size;
|
||||
|
||||
for(uint32 i = 0; i < size; i++)
|
||||
@ -231,10 +233,12 @@ void Channel::HandleListRequest(WorldPacket& recvPacket)
|
||||
if(_worldSession->GetOrRequestPlayerName(guid).empty())
|
||||
{
|
||||
_worldSession->_DelayWorldPacket(recvPacket, _worldSession->GetLagMS() * 1.2f);
|
||||
return;
|
||||
must_delay = true;
|
||||
}
|
||||
cpl[guid] = mode;
|
||||
}
|
||||
if(must_delay)
|
||||
return;
|
||||
|
||||
// store list of GUIDs in: @ChannelList - see below
|
||||
DefList *l = _worldSession->GetInstance()->GetScripts()->lists.Get("@ChannelList");
|
||||
@ -253,7 +257,7 @@ void Channel::HandleListRequest(WorldPacket& recvPacket)
|
||||
muted = mode & MEMBER_FLAG_MUTED;
|
||||
mod = mode & MEMBER_FLAG_MODERATOR;
|
||||
|
||||
while(pname.length()<12)
|
||||
while(pname.length() < MAX_PLAYERNAME_LENGTH)
|
||||
pname += " "; // for better formatting
|
||||
|
||||
logcustom(0,WHITE,"%s ["I64FMT"] %s %s",pname.c_str(),i->first,muted?"(muted)":"",mod?"(moderator)":"");
|
||||
|
||||
@ -1371,4 +1371,7 @@ enum SpellCastTargetFlags
|
||||
TARGET_FLAG_STRING = 0x2000
|
||||
};
|
||||
|
||||
#define MAX_PLAYERNAME_LENGTH 12
|
||||
#define MIN_PLAYERNAME_LENGTH 2
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user