* fixed WorldSocket. this fixed crypt errors hopefully.

* fixed problem with not sent packets that appeared [85]
* fixed infinite spam-loop when whispering to self with enabled autoreply
* fixed a bug (asking for playername although object is an item)
This commit is contained in:
False.Genesis 2007-03-07 17:09:39 +00:00
parent 10e6b70c4d
commit d044ef7138
5 changed files with 29 additions and 38 deletions

View File

@ -82,7 +82,7 @@ notifyping=1
showmyopcodes=0 showmyopcodes=0
// disable the check for learned spells. // disable the check for learned spells.
// if you disable it, you can cast spells you do not have in our spellbook! // if you disable it, you can cast spells you do not have in your spellbook!
// WARNING: most servers will consider this as CHEATING! // WARNING: most servers will consider this as CHEATING!
// DO NOT put 1 here! // DO NOT put 1 here!
disablespellcheck=0 disablespellcheck=0

View File

@ -4,11 +4,8 @@
LOG * World entered, executing appropriate script... LOG * World entered, executing appropriate script...
// not yet implemented
// CASTSPELL 836
// MaNGOS: make PseuWoW invincible // MaNGOS: make PseuWoW invincible
SAY .gmon // SAY .gmon
// you can also teleport on every startup to a certain player... // you can also teleport on every startup to a certain player...
// simple: use the .goname command as usual. // simple: use the .goname command as usual.
@ -29,6 +26,9 @@ JOINCHANNEL help
JOINCHANNEL tradee JOINCHANNEL tradee
// ... // ...
// Spell 836 = LoginEffect
CASTSPELL 836
// uncomment the following line to enable the autobroadcast script (first broadcast will happen after the timer (check the script) has expired) // uncomment the following line to enable the autobroadcast script (first broadcast will happen after the timer (check the script) has expired)
// LOADDEF autobroadcast // LOADDEF autobroadcast

View File

@ -337,6 +337,7 @@ void WorldSession::_QueryObjectInfo(uint64 guid)
logdebug("Found unknown item: GUID="I64FMT" entry=%u",obj->GetGUID(),obj->GetEntry()); logdebug("Found unknown item: GUID="I64FMT" entry=%u",obj->GetGUID(),obj->GetEntry());
SendQueryItem(obj->GetEntry(),obj->GetGUID()); // not sure if sending GUID is correct SendQueryItem(obj->GetEntry(),obj->GetGUID()); // not sure if sending GUID is correct
} }
break;
} }
case TYPEID_PLAYER: case TYPEID_PLAYER:
{ {
@ -349,6 +350,7 @@ void WorldSession::_QueryObjectInfo(uint64 guid)
{ {
((WorldObject*)obj)->SetName(name); ((WorldObject*)obj)->SetName(name);
} }
break;
} }
//case... //case...
} }

View File

@ -459,7 +459,7 @@ void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket)
logcustom(0,WHITE,"UNK CHAT TYPE (%u): %s [%s]: %s",type,plrname.c_str(),LookupName(lang,langNames),msg.c_str()); logcustom(0,WHITE,"UNK CHAT TYPE (%u): %s [%s]: %s",type,plrname.c_str(),LookupName(lang,langNames),msg.c_str());
} }
if(target_guid!=_myGUID && msg.length()>1 && msg.at(0)=='-' && GetInstance()->GetConf()->allowgamecmd) if(target_guid!=GetGuid() && msg.length()>1 && msg.at(0)=='-' && GetInstance()->GetConf()->allowgamecmd)
isCmd=true; isCmd=true;
// some fun code :P // some fun code :P
@ -500,7 +500,7 @@ void WorldSession::_HandleMessageChatOpcode(WorldPacket& recvPacket)
} }
} }
if(type==CHAT_MSG_WHISPER && !isCmd) if(type==CHAT_MSG_WHISPER && (!isCmd) && target_guid!=GetGuid())
{ {
GetInstance()->GetScripts()->variables.Set("@thiswhisper_name",plrname); GetInstance()->GetScripts()->variables.Set("@thiswhisper_name",plrname);
GetInstance()->GetScripts()->variables.Set("@thiswhisper",toString(target_guid)); GetInstance()->GetScripts()->variables.Set("@thiswhisper",toString(target_guid));

View File

@ -35,43 +35,38 @@ void WorldSocket::OnException()
void WorldSocket::OnRead() void WorldSocket::OnRead()
{ {
TcpSocket::OnRead(); TcpSocket::OnRead();
uint32 len = ibuf.GetLength(); if(!ibuf.GetLength())
printf("WorldSocket::OnRead() %u bytes\n",len);
if(!len)
{ {
this->CloseAndDelete(); this->CloseAndDelete();
return; return;
} }
// a valid header needs to have at least 4 bytes while(ibuf.GetLength() > 0) // when all packets from the current ibuf are transformed into WorldPackets the remaining len will be zero
if(len < 4 && (!_gothdr))
{
logerror("WorldSocket::OnRead(): Got %u bytes (header too small) - waiting for more data",len);
return;
}
uint8 *buf=new uint8[len];
ibuf.Read((char*)buf,len);
uint32 offset=0; // to skip data already read
while(len > 0) // when all packets from the current ibuf are transformed into WorldPackets the remaining len will be zero
{ {
if(_gothdr) // already got header, this packet has to be the data part if(_gothdr) // already got header, this packet has to be the data part
{ {
ASSERT(_remaining > 0); // case pktsize==0 is handled below
if(ibuf.GetLength() < _remaining)
{
logerror("Delaying WorldPacket generation, bufsize is %u but should be >= %u",ibuf.GetLength(),_remaining);
break;
}
_gothdr=false; _gothdr=false;
WorldPacket *wp = new WorldPacket; WorldPacket *wp = new WorldPacket(_remaining);
wp->append(buf+offset,_remaining); wp->resize(_remaining);
ibuf.Read((char*)wp->contents(),_remaining);
wp->SetOpcode(_opcode); wp->SetOpcode(_opcode);
GetSession()->AddToPktQueue(wp); GetSession()->AddToPktQueue(wp);
offset += _remaining; // skip the data already used
len -= _remaining; // and adjust the length
} }
else // no pending header stored, so this packet must be a header else // no pending header stored, so this packet must be a header
{ {
if(ibuf.GetLength() < sizeof(ServerPktHeader))
{
logerror("Delaying header reading, bufsize is %u but should be >= %u",ibuf.GetLength(),sizeof(ServerPktHeader));
break;
}
ServerPktHeader hdr; ServerPktHeader hdr;
memcpy(&hdr,buf+offset,sizeof(ServerPktHeader)); ibuf.Read((char*)&hdr,sizeof(ServerPktHeader));
_crypt.DecryptRecv((uint8*)&hdr,sizeof(ServerPktHeader)); _crypt.DecryptRecv((uint8*)&hdr,sizeof(ServerPktHeader));
_remaining = ntohs(hdr.size)-2; _remaining = ntohs(hdr.size)-2;
_opcode = hdr.cmd; _opcode = hdr.cmd;
@ -82,7 +77,6 @@ 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
return; return;
} }
@ -92,19 +86,13 @@ void WorldSocket::OnRead()
WorldPacket *wp = new WorldPacket; WorldPacket *wp = new WorldPacket;
wp->SetOpcode(_opcode); wp->SetOpcode(_opcode);
GetSession()->AddToPktQueue(wp); GetSession()->AddToPktQueue(wp);
offset += 4 ; // skip the data already used
len -= 4; // and adjust the lentgh
} }
else // there is a data part to fetch else // there is a data part to fetch
{ {
_gothdr=true; // only got the header, next packet wil contain the data _gothdr=true; // only got the header, next packet will contain the data
offset += 4 ; // skip the data already used
len -= 4; // and adjust the lentgh
} }
} }
} }
delete buf;
} }
void WorldSocket::SendWorldPacket(WorldPacket &pkt) void WorldSocket::SendWorldPacket(WorldPacket &pkt)
@ -116,7 +104,8 @@ void WorldSocket::SendWorldPacket(WorldPacket &pkt)
_crypt.EncryptSend((uint8*)&hdr, 6); _crypt.EncryptSend((uint8*)&hdr, 6);
ByteBuffer final(pkt.size()+6); ByteBuffer final(pkt.size()+6);
final.append((uint8*)&hdr,sizeof(ClientPktHeader)); final.append((uint8*)&hdr,sizeof(ClientPktHeader));
final.append(pkt); if(pkt.size())
final.append(pkt.contents(),pkt.size());
SendBuf((char*)final.contents(),final.size()); SendBuf((char*)final.contents(),final.size());
} }