From c00ad9aae3f580a534eea272e4c9e0b28cd3b392 Mon Sep 17 00:00:00 2001 From: "False.Genesis" Date: Sat, 3 Feb 2007 01:41:42 +0000 Subject: [PATCH] * added some more SMSG_(COMPRESSED_)UPDATE_OBJECT stuff. * we have year 2007 now --- src/Client/World/UpdateData.cpp | 71 +++++++++++++++--- src/Client/World/UpdateMask.h | 124 ++++++++++++++++++++++++++++++++ src/Client/main.cpp | 2 +- src/PseuWoW.vcproj | 3 + 4 files changed, 188 insertions(+), 12 deletions(-) create mode 100644 src/Client/World/UpdateMask.h diff --git a/src/Client/World/UpdateData.cpp b/src/Client/World/UpdateData.cpp index 13922e8..e48b417 100644 --- a/src/Client/World/UpdateData.cpp +++ b/src/Client/World/UpdateData.cpp @@ -1,11 +1,15 @@ #include "common.h" #include "ZCompressor.h" #include "WorldSession.h" +#include "Object.h" #include "UpdateData.h" +#include "UpdateFields.h" +#include "UpdateMask.h" + void WorldSession::_HandleCompressedUpdateObjectOpcode(WorldPacket& recvPacket) { - printf("-> COMPRESSED_UPDATE_OBJECT, pktlen=%u\n",recvPacket.size()); + //printf("-> COMPRESSED_UPDATE_OBJECT, pktlen=%u\n",recvPacket.size()); //recvPacket.hexlike(); uint32 realsize; recvPacket >> realsize; @@ -14,10 +18,9 @@ void WorldSession::_HandleCompressedUpdateObjectOpcode(WorldPacket& recvPacket) z.Compressed(true); z.RealSize(realsize); z.Inflate(); - printf("-> Uncompressed to %u bytes\n",z.size()); if(z.Compressed()) { - log("ERROR: _HandleCompressedUpdateObjectOpcode(): Inflate() failed!"); + logerror("_HandleCompressedUpdateObjectOpcode(): Inflate() failed!"); return; } WorldPacket wp; @@ -29,25 +32,71 @@ void WorldSession::_HandleCompressedUpdateObjectOpcode(WorldPacket& recvPacket) void WorldSession::_HandleUpdateObjectOpcode(WorldPacket& recvPacket) { - printf("-> UPDATE_OBJECT, pktlen=%u\n",recvPacket.size()); //recvPacket.hexlike(); uint8 utype; - uint32 usize; + uint8 unk8; + uint32 usize, ublocks; uint64 uguid; - //while(true) + recvPacket >> ublocks >> unk8; + logdebug("UpdateObject: ublocks=%u unk=%u",ublocks,unk8); + //while(true) // need to read full packet as soon as the structure is 100% known & implemented + // for now reading first object is enough { - recvPacket >> utype >> usize; + recvPacket >> utype; + logdebug("UpdateObject: utype=%u",utype); switch(utype) { case UPDATETYPE_OUT_OF_RANGE_OBJECTS: - for(uint16 i=0;i> usize; + for(uint16 i=0;i> uguid; - printf("DEBUG: GUID "I64FMT" out of range\n",uguid); - // TODO: delete object from known objects list + uguid = recvPacket.GetPackedGuid(); // not 100% sure if this is correct + uint8 maskblocks; + recvPacket >> maskblocks; + logdebug("UPDATETYPE_VALUES: guid="I64FMT" maskblocks=%u",uguid,maskblocks); + // need some help with the lines below, got no idea what to do now. + UpdateMask umask; + umask.SetCount(maskblocks*8); // ?? + std::vector udata; + //udata.resize(?) + + } break; + case UPDATETYPE_CREATE_OBJECT: + case UPDATETYPE_CREATE_OBJECT2: + { + uguid = recvPacket.GetPackedGuid(); + uint8 objtypeid; + recvPacket >> objtypeid; + logdebug("Create Object type %u with guid "I64FMT,objtypeid,uguid); + if(objtypeid==TYPEID_PLAYER) + { + + } + if(objtypeid==TYPEID_UNIT) + { + + } + if( (objtypeid==TYPEID_CORPSE) || (objtypeid==TYPEID_GAMEOBJECT) || (objtypeid==TYPEID_DYNAMICOBJECT)) + { + + } + + // (TODO) and then: Add object to objmgr + } + break; + + default: break; } diff --git a/src/Client/World/UpdateMask.h b/src/Client/World/UpdateMask.h new file mode 100644 index 0000000..cc68163 --- /dev/null +++ b/src/Client/World/UpdateMask.h @@ -0,0 +1,124 @@ +/* + * Copyright (C) 2005,2006,2007 MaNGOS + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __UPDATEMASK_H +#define __UPDATEMASK_H + +//#include "UpdateFields.h" +//#include "Errors.h" + +class UpdateMask +{ + public: + UpdateMask( ) : mCount( 0 ), mBlocks( 0 ), mUpdateMask( 0 ) { } + UpdateMask( const UpdateMask& mask ) : mUpdateMask( 0 ) { *this = mask; } + + ~UpdateMask( ) + { + if(mUpdateMask) + delete [] mUpdateMask; + } + + inline void SetBit (uint32 index) + { + ( (uint8 *)mUpdateMask )[ index >> 3 ] |= 1 << ( index & 0x7 ); + } + + inline void UnsetBit (uint32 index) + { + ( (uint8 *)mUpdateMask )[ index >> 3 ] &= (0xff ^ (1 << ( index & 0x7 ) ) ); + } + + inline bool GetBit (uint32 index) + { + return ( ( (uint8 *)mUpdateMask)[ index >> 3 ] & ( 1 << ( index & 0x7 ) )) != 0; + } + + inline uint32 GetBlockCount() { return mBlocks; } + inline uint32 GetLength() { return mBlocks << 2; } + inline uint32 GetCount() { return mCount; } + inline uint8* GetMask() { return (uint8*)mUpdateMask; } + + inline void SetCount (uint32 valuesCount) + { + if(mUpdateMask) + delete [] mUpdateMask; + + mCount = valuesCount; + mBlocks = (valuesCount + 31) / 32; + + mUpdateMask = new uint32[mBlocks]; + memset(mUpdateMask, 0, mBlocks << 2); + } + + inline void Clear() + { + if (mUpdateMask) + memset(mUpdateMask, 0, mBlocks << 2); + } + + inline UpdateMask& operator = ( const UpdateMask& mask ) + { + SetCount(mask.mCount); + memcpy(mUpdateMask, mask.mUpdateMask, mBlocks << 2); + + return *this; + } + + inline void operator &= ( const UpdateMask& mask ) + { + //ASSERT(mask.mCount <= mCount); + for (uint32 i = 0; i < mBlocks; i++) + mUpdateMask[i] &= mask.mUpdateMask[i]; + } + + inline void operator |= ( const UpdateMask& mask ) + { + //ASSERT(mask.mCount <= mCount); + for (uint32 i = 0; i < mBlocks; i++) + mUpdateMask[i] |= mask.mUpdateMask[i]; + } + + inline UpdateMask operator & ( const UpdateMask& mask ) const + { + //ASSERT(mask.mCount <= mCount); + + UpdateMask newmask; + newmask = *this; + newmask &= mask; + + return newmask; + } + + inline UpdateMask operator | ( const UpdateMask& mask ) const + { + //ASSERT(mask.mCount <= mCount); + + UpdateMask newmask; + newmask = *this; + newmask |= mask; + + return newmask; + } + + private: + uint32 mCount; + uint32 mBlocks; + uint32 *mUpdateMask; +}; +#endif diff --git a/src/Client/main.cpp b/src/Client/main.cpp index 1983e7a..9f1f49f 100644 --- a/src/Client/main.cpp +++ b/src/Client/main.cpp @@ -71,7 +71,7 @@ void abortproc(void) int main(int argc, char* argv[]) { try { - printf("\n (C) 2006, Snowstorm Software\n\n\n"); + printf("\n (C) 2006,2007 Snowstorm Software\n\n\n"); _HookSignals(); diff --git a/src/PseuWoW.vcproj b/src/PseuWoW.vcproj index 1471ef0..7ff9290 100644 --- a/src/PseuWoW.vcproj +++ b/src/PseuWoW.vcproj @@ -305,6 +305,9 @@ + +