diff --git a/common/eq_packet.cpp b/common/eq_packet.cpp index f5c08a301..b2c3f6062 100644 --- a/common/eq_packet.cpp +++ b/common/eq_packet.cpp @@ -236,26 +236,6 @@ uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const return size+OpCodeBytes; } -/*EQProtocolPacket::EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) -: BasePacket(buf, len), - opcode(op) -{ - -uint32 offset; - opcode=ntohs(*(const uint16 *)buf); - offset=2; - - if (len-offset) { - pBuffer= new unsigned char[len-offset]; - memcpy(pBuffer,buf+offset,len-offset); - size=len-offset; - } else { - pBuffer=nullptr; - size=0; - } - OpMgr=&RawOpcodeManager; -}*/ - bool EQProtocolPacket::combine(const EQProtocolPacket *rhs) { bool result=false; @@ -287,74 +267,6 @@ bool result=false; } -/* -this is the code to do app-layer combining, instead of protocol layer. -this was taken out due to complex interactions with the opcode manager, -and will require a bit more thinking (likely moving into EQStream) to -get running again... but might be a good thing some day. - -bool EQApplicationPacket::combine(const EQApplicationPacket *rhs) -{ -uint32 newsize=0, offset=0; -unsigned char *tmpbuffer=nullptr; - - if (opcode!=OP_AppCombined) { - newsize=app_opcode_size+size+(size>254?3:1)+app_opcode_size+rhs->size+(rhs->size>254?3:1); - tmpbuffer=new unsigned char [newsize]; - offset=0; - if (size>254) { - tmpbuffer[offset++]=0xff; - *(uint16 *)(tmpbuffer+offset)=htons(size); - offset+=1; - } else { - tmpbuffer[offset++]=size; - } - offset+=serialize(tmpbuffer+offset); - } else { - newsize=size+app_opcode_size+rhs->size+(rhs->size>254?3:1); - tmpbuffer=new unsigned char [newsize]; - memcpy(tmpbuffer,pBuffer,size); - offset=size; - } - - if (rhs->size>254) { - tmpbuffer[offset++]=0xff; - *(uint16 *)(tmpbuffer+offset)=htons(rhs->size); - offset+=1; - } else { - tmpbuffer[offset++]=rhs->size; - } - offset+=rhs->serialize(tmpbuffer+offset); - - size=offset; - opcode=OP_AppCombined; - - delete[] pBuffer; - pBuffer=tmpbuffer; - - return true; -} -*/ - -bool EQProtocolPacket::ValidateCRC(const unsigned char *buffer, int length, uint32 Key) -{ -bool valid=false; - // OP_SessionRequest, OP_SessionResponse, OP_OutOfSession are not CRC'd - if (buffer[0]==0x00 && (buffer[1]==OP_SessionRequest || buffer[1]==OP_SessionResponse || buffer[1]==OP_OutOfSession)) { - valid=true; - } else { - uint16 comp_crc=CRC16(buffer,length-2,Key); - uint16 packet_crc=ntohs(*(const uint16 *)(buffer+length-2)); -#ifdef EQN_DEBUG - if (packet_crc && comp_crc != packet_crc) { - std::cout << "CRC mismatch: comp=" << std::hex << comp_crc << ", packet=" << packet_crc << std::dec << std::endl; - } -#endif - valid = (!packet_crc || comp_crc == packet_crc); - } - return valid; -} - uint32 EQProtocolPacket::Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize) { uint32 newlen=0; @@ -403,55 +315,6 @@ uint32 flag_offset=1,newlength; return newlength; } -void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey) -{ - if ((size >= 2) && buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) { - int Key=DecodeKey; - unsigned char *test=(unsigned char *)malloc(size); - buffer+=2; - size-=2; - - int i; - for (i = 0 ; i+4 <= size ; i+=4) - { - int pt = (*(int*)&buffer[i])^(Key); - Key = (*(int*)&buffer[i]); - *(int*)&test[i]=pt; - } - unsigned char KC=Key&0xFF; - for ( ; i < size ; i++) - { - test[i]=buffer[i]^KC; - } - memcpy(buffer,test,size); - free(test); - } -} - -void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey) -{ - if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) { - int Key=EncodeKey; - char *test=(char*)malloc(size); - int i; - buffer+=2; - size-=2; - for ( i = 0 ; i+4 <= size ; i+=4) - { - int pt = (*(int*)&buffer[i])^(Key); - Key = pt; - *(int*)&test[i]=pt; - } - unsigned char KC=Key&0xFF; - for ( ; i < size ; i++) - { - test[i]=buffer[i]^KC; - } - memcpy(buffer,test,size); - free(test); - } -} - EQApplicationPacket *EQApplicationPacket::Copy() const { return(new EQApplicationPacket(*this)); } @@ -515,4 +378,4 @@ std::string DumpPacketToString(const EQApplicationPacket* app){ std::ostringstream out; out << DumpPacketHexToString(app->pBuffer, app->size); return out.str(); -} \ No newline at end of file +} diff --git a/common/eq_packet.h b/common/eq_packet.h index 77b76b450..7eb79a75b 100644 --- a/common/eq_packet.h +++ b/common/eq_packet.h @@ -80,11 +80,8 @@ public: protected: - static bool ValidateCRC(const unsigned char *buffer, int length, uint32 Key); static uint32 Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize); static uint32 Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize); - static void ChatDecode(unsigned char *buffer, int size, int DecodeKey); - static void ChatEncode(unsigned char *buffer, int size, int EncodeKey); uint16 GetRawOpcode() const { return(opcode); }