From d044ef713816d316b800440a841d37f9e136206f Mon Sep 17 00:00:00 2001 From: "False.Genesis" Date: Wed, 7 Mar 2007 17:09:39 +0000 Subject: [PATCH] * 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) --- bin/conf/PseuWoW.conf.default | 2 +- bin/scripts/_enterworld.def | 8 ++--- src/Client/World/UpdateData.cpp | 2 ++ src/Client/World/WorldSession.cpp | 4 +-- src/Client/World/WorldSocket.cpp | 51 ++++++++++++------------------- 5 files changed, 29 insertions(+), 38 deletions(-) diff --git a/bin/conf/PseuWoW.conf.default b/bin/conf/PseuWoW.conf.default index ad998cb..08e5a91 100644 --- a/bin/conf/PseuWoW.conf.default +++ b/bin/conf/PseuWoW.conf.default @@ -82,7 +82,7 @@ notifyping=1 showmyopcodes=0 // 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! // DO NOT put 1 here! disablespellcheck=0 diff --git a/bin/scripts/_enterworld.def b/bin/scripts/_enterworld.def index f0ae4bc..85372a4 100644 --- a/bin/scripts/_enterworld.def +++ b/bin/scripts/_enterworld.def @@ -4,11 +4,8 @@ LOG * World entered, executing appropriate script... -// not yet implemented -// CASTSPELL 836 - // MaNGOS: make PseuWoW invincible -SAY .gmon +// SAY .gmon // you can also teleport on every startup to a certain player... // simple: use the .goname command as usual. @@ -29,6 +26,9 @@ JOINCHANNEL help 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) // LOADDEF autobroadcast diff --git a/src/Client/World/UpdateData.cpp b/src/Client/World/UpdateData.cpp index 14ed5d5..c260631 100644 --- a/src/Client/World/UpdateData.cpp +++ b/src/Client/World/UpdateData.cpp @@ -337,6 +337,7 @@ void WorldSession::_QueryObjectInfo(uint64 guid) logdebug("Found unknown item: GUID="I64FMT" entry=%u",obj->GetGUID(),obj->GetEntry()); SendQueryItem(obj->GetEntry(),obj->GetGUID()); // not sure if sending GUID is correct } + break; } case TYPEID_PLAYER: { @@ -349,6 +350,7 @@ void WorldSession::_QueryObjectInfo(uint64 guid) { ((WorldObject*)obj)->SetName(name); } + break; } //case... } diff --git a/src/Client/World/WorldSession.cpp b/src/Client/World/WorldSession.cpp index 8243d94..ce36c1d 100644 --- a/src/Client/World/WorldSession.cpp +++ b/src/Client/World/WorldSession.cpp @@ -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()); } - 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; // 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",toString(target_guid)); diff --git a/src/Client/World/WorldSocket.cpp b/src/Client/World/WorldSocket.cpp index e25a4a6..285ebd6 100644 --- a/src/Client/World/WorldSocket.cpp +++ b/src/Client/World/WorldSocket.cpp @@ -35,43 +35,38 @@ void WorldSocket::OnException() void WorldSocket::OnRead() { TcpSocket::OnRead(); - uint32 len = ibuf.GetLength(); - printf("WorldSocket::OnRead() %u bytes\n",len); - if(!len) + if(!ibuf.GetLength()) { this->CloseAndDelete(); 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]; - 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 + while(ibuf.GetLength() > 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 { + 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; - WorldPacket *wp = new WorldPacket; - wp->append(buf+offset,_remaining); + WorldPacket *wp = new WorldPacket(_remaining); + wp->resize(_remaining); + ibuf.Read((char*)wp->contents(),_remaining); wp->SetOpcode(_opcode); 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 { + if(ibuf.GetLength() < sizeof(ServerPktHeader)) + { + logerror("Delaying header reading, bufsize is %u but should be >= %u",ibuf.GetLength(),sizeof(ServerPktHeader)); + break; + } ServerPktHeader hdr; - memcpy(&hdr,buf+offset,sizeof(ServerPktHeader)); + ibuf.Read((char*)&hdr,sizeof(ServerPktHeader)); _crypt.DecryptRecv((uint8*)&hdr,sizeof(ServerPktHeader)); _remaining = ntohs(hdr.size)-2; _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 // the lentgh of the following data part // TODO: invent some way how to recover the crypt (reconnect?) - delete buf; // drop the current queue content return; } @@ -92,19 +86,13 @@ void WorldSocket::OnRead() WorldPacket *wp = new WorldPacket; wp->SetOpcode(_opcode); GetSession()->AddToPktQueue(wp); - offset += 4 ; // skip the data already used - len -= 4; // and adjust the lentgh } else // there is a data part to fetch { - _gothdr=true; // only got the header, next packet wil contain the data - offset += 4 ; // skip the data already used - len -= 4; // and adjust the lentgh + _gothdr=true; // only got the header, next packet will contain the data } } } - - delete buf; } void WorldSocket::SendWorldPacket(WorldPacket &pkt) @@ -116,7 +104,8 @@ void WorldSocket::SendWorldPacket(WorldPacket &pkt) _crypt.EncryptSend((uint8*)&hdr, 6); ByteBuffer final(pkt.size()+6); final.append((uint8*)&hdr,sizeof(ClientPktHeader)); - final.append(pkt); + if(pkt.size()) + final.append(pkt.contents(),pkt.size()); SendBuf((char*)final.contents(),final.size()); }