From 605fbd2df5ce88a2b1e52bc9691792ef7cb8e58b Mon Sep 17 00:00:00 2001 From: "False.Genesis" Date: Sun, 25 Feb 2007 22:04:15 +0000 Subject: [PATCH] * added the remaining base classes Object, Corpse, DynamicObject & WorldObject; added updating those classes * there is still a problem/exception with UPDATETYPE_OUT_OF_RANGE_OBJECTS, need to fix this later. * 100% working objects system, now need to add functions to the objects. (made a start with Player/Unit::GetGender()) --- src/Client/World/Bag.cpp | 14 +++ src/Client/World/Bag.h | 18 ++++ src/Client/World/Corpse.cpp | 14 +++ src/Client/World/Corpse.h | 16 ++++ src/Client/World/DynamicObject.cpp | 14 +++ src/Client/World/DynamicObject.h | 16 ++++ src/Client/World/GameObject.cpp | 14 +++ src/Client/World/GameObject.h | 16 ++++ src/Client/World/Item.cpp | 1 + src/Client/World/Item.h | 17 ++-- src/Client/World/ObjMgr.cpp | 5 +- src/Client/World/ObjMgr.h | 2 - src/Client/World/Object.cpp | 2 +- src/Client/World/Player.h | 134 +++++++++++++++++++++++++++++ src/Client/World/Unit.cpp | 11 +++ src/Client/World/Unit.h | 2 + src/Client/World/UpdateData.cpp | 33 ++++++- src/PseuWoW.vcproj | 24 ++++++ src/shared/tools.h | 3 + 19 files changed, 339 insertions(+), 17 deletions(-) create mode 100644 src/Client/World/Bag.cpp create mode 100644 src/Client/World/Bag.h create mode 100644 src/Client/World/Corpse.cpp create mode 100644 src/Client/World/Corpse.h create mode 100644 src/Client/World/DynamicObject.cpp create mode 100644 src/Client/World/DynamicObject.h create mode 100644 src/Client/World/GameObject.cpp create mode 100644 src/Client/World/GameObject.h diff --git a/src/Client/World/Bag.cpp b/src/Client/World/Bag.cpp new file mode 100644 index 0000000..6cbab08 --- /dev/null +++ b/src/Client/World/Bag.cpp @@ -0,0 +1,14 @@ +#include "Bag.h" + +Bag::Bag() : Item() +{ + _type |= TYPE_CONTAINER; + _typeid = TYPEID_CONTAINER; + _valuescount = CONTAINER_END; + _slot = 0; +} + +void Bag::Create(uint64 guid) +{ + Item::Create(guid); +} \ No newline at end of file diff --git a/src/Client/World/Bag.h b/src/Client/World/Bag.h new file mode 100644 index 0000000..b59d380 --- /dev/null +++ b/src/Client/World/Bag.h @@ -0,0 +1,18 @@ +#ifndef _BAG_H +#define _BAG_H + +#include "common.h" +#include "Item.h" + +class Bag : public Item +{ +public: + Bag(); + void Create(uint64); + +private: + +}; + + +#endif diff --git a/src/Client/World/Corpse.cpp b/src/Client/World/Corpse.cpp new file mode 100644 index 0000000..33d3336 --- /dev/null +++ b/src/Client/World/Corpse.cpp @@ -0,0 +1,14 @@ +#include "Corpse.h" + +Corpse::Corpse() +{ + _uint32values=NULL; + _type=TYPE_CORPSE; + _typeid=TYPEID_CORPSE; + _valuescount=CORPSE_END; +} + +void Corpse::Create(uint64 guid) +{ + Object::Create(guid); +} \ No newline at end of file diff --git a/src/Client/World/Corpse.h b/src/Client/World/Corpse.h new file mode 100644 index 0000000..389d075 --- /dev/null +++ b/src/Client/World/Corpse.h @@ -0,0 +1,16 @@ +#ifndef _CORPSE_H +#define _CORPSE_H + +#include "Object.h" + +class Corpse : public WorldObject +{ +public: + Corpse(); + void Create(uint64); + +private: + +}; + +#endif diff --git a/src/Client/World/DynamicObject.cpp b/src/Client/World/DynamicObject.cpp new file mode 100644 index 0000000..ae209d3 --- /dev/null +++ b/src/Client/World/DynamicObject.cpp @@ -0,0 +1,14 @@ +#include "DynamicObject.h" + +DynamicObject::DynamicObject() +{ + _uint32values=NULL; + _type=TYPE_DYNAMICOBJECT; + _typeid=TYPEID_DYNAMICOBJECT; + _valuescount=DYNAMICOBJECT_END; +} + +void DynamicObject::Create(uint64 guid) +{ + Object::Create(guid); +} \ No newline at end of file diff --git a/src/Client/World/DynamicObject.h b/src/Client/World/DynamicObject.h new file mode 100644 index 0000000..6066039 --- /dev/null +++ b/src/Client/World/DynamicObject.h @@ -0,0 +1,16 @@ +#ifndef _DYNAMICOBJECT_H +#define _DYNAMICOBJECT_H + +#include "Object.h" + +class DynamicObject : public WorldObject +{ +public: + DynamicObject(); + void Create(uint64); + +private: + +}; + +#endif diff --git a/src/Client/World/GameObject.cpp b/src/Client/World/GameObject.cpp new file mode 100644 index 0000000..41c00d8 --- /dev/null +++ b/src/Client/World/GameObject.cpp @@ -0,0 +1,14 @@ +#include "GameObject.h" + +GameObject::GameObject() +{ + _uint32values=NULL; + _type=TYPE_GAMEOBJECT; + _typeid=TYPEID_GAMEOBJECT; + _valuescount=GAMEOBJECT_END; +} + +void GameObject::Create(uint64 guid) +{ + Object::Create(guid); +} \ No newline at end of file diff --git a/src/Client/World/GameObject.h b/src/Client/World/GameObject.h new file mode 100644 index 0000000..eeb07dc --- /dev/null +++ b/src/Client/World/GameObject.h @@ -0,0 +1,16 @@ +#ifndef _GAMEOBJECT_H +#define _GAMEOBJECT_H + +#include "Object.h" + +class GameObject : public WorldObject +{ +public: + GameObject(); + void Create(uint64); + +private: + +}; + +#endif diff --git a/src/Client/World/Item.cpp b/src/Client/World/Item.cpp index 13f933c..4e5f12c 100644 --- a/src/Client/World/Item.cpp +++ b/src/Client/World/Item.cpp @@ -2,6 +2,7 @@ #include "UpdateFields.h" #include "Item.h" +#include "Bag.h" void WorldSession::_HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket) { diff --git a/src/Client/World/Item.h b/src/Client/World/Item.h index 93c702b..ba1456e 100644 --- a/src/Client/World/Item.h +++ b/src/Client/World/Item.h @@ -4,6 +4,8 @@ #include "common.h" #include "Object.h" +class Bag; + enum InventoryChangeFailure { EQUIP_ERR_OK = 0, @@ -395,21 +397,14 @@ public: void Create(uint64); uint8 GetSlot(void) { return _slot; } void SetSlot(uint8 nr) { _slot = nr; } - //void SetProto(ItemProto *proto) { _proto = proto; } - //ItemProto *GetProto(void) { return _proto; } uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); } uint32 GetCount() const { return GetUInt32Value (ITEM_FIELD_STACK_COUNT); } - //void SetBag(Bag *b) { _bag = b; } - //void GetBag(Bag *b) { _bag = b; } - //bool IsInBag() const { return _bag != NULL; } - /*bool Item::IsEquipped() const - { - return !IsInBag() && _slot < EQUIPMENT_SLOT_END; - }*/ + Bag *GetBag(void) { return _bag; } + bool IsInBag() const { return _bag != NULL; } -private: +protected: uint8 _slot; - // Bag *_bag; // not yet implemented + Bag *_bag; // not yet implemented }; diff --git a/src/Client/World/ObjMgr.cpp b/src/Client/World/ObjMgr.cpp index 9d20e09..ac6780d 100644 --- a/src/Client/World/ObjMgr.cpp +++ b/src/Client/World/ObjMgr.cpp @@ -1,5 +1,3 @@ -#include "common.h" -#include "Item.h" #include "ObjMgr.h" ObjMgr::~ObjMgr() @@ -18,8 +16,11 @@ void ObjMgr::Remove(uint64 guid) { for(ObjectList::iterator i = _obj.begin(); i!=_obj.end(); i++) if((*i)->GetGUID() == guid) + { _obj.erase(i); delete *i; + return; + } } diff --git a/src/Client/World/ObjMgr.h b/src/Client/World/ObjMgr.h index 6a49ee7..f3b36bf 100644 --- a/src/Client/World/ObjMgr.h +++ b/src/Client/World/ObjMgr.h @@ -4,8 +4,6 @@ #include "common.h" #include #include "Object.h" -#include "Player.h" -#include "Unit.h" #include "Item.h" typedef std::vector ItemProtoList; diff --git a/src/Client/World/Object.cpp b/src/Client/World/Object.cpp index 0be546a..7716c43 100644 --- a/src/Client/World/Object.cpp +++ b/src/Client/World/Object.cpp @@ -8,7 +8,7 @@ Object::Object() _uint32values=NULL; _type=TYPE_OBJECT; _typeid=TYPEID_OBJECT; - _valuescount=0; + _valuescount=0; // base class. this value will be set by derived classes } Object::~Object() diff --git a/src/Client/World/Player.h b/src/Client/World/Player.h index 249f03c..0d05894 100644 --- a/src/Client/World/Player.h +++ b/src/Client/World/Player.h @@ -6,6 +6,139 @@ #include "SysDefs.h" #include "Unit.h" +#define PLAYER_SLOT_START 0 + +#define EQUIPMENT_SLOT_START 0 +#define EQUIPMENT_SLOT_HEAD 0 +#define EQUIPMENT_SLOT_NECK 1 +#define EQUIPMENT_SLOT_SHOULDERS 2 +#define EQUIPMENT_SLOT_BODY 3 +#define EQUIPMENT_SLOT_CHEST 4 +#define EQUIPMENT_SLOT_WAIST 5 +#define EQUIPMENT_SLOT_LEGS 6 +#define EQUIPMENT_SLOT_FEET 7 +#define EQUIPMENT_SLOT_WRISTS 8 +#define EQUIPMENT_SLOT_HANDS 9 +#define EQUIPMENT_SLOT_FINGER1 10 +#define EQUIPMENT_SLOT_FINGER2 11 +#define EQUIPMENT_SLOT_TRINKET1 12 +#define EQUIPMENT_SLOT_TRINKET2 13 +#define EQUIPMENT_SLOT_BACK 14 +#define EQUIPMENT_SLOT_MAINHAND 15 +#define EQUIPMENT_SLOT_OFFHAND 16 +#define EQUIPMENT_SLOT_RANGED 17 +#define EQUIPMENT_SLOT_TABARD 18 +#define EQUIPMENT_SLOT_END 19 + +#define INVENTORY_SLOT_BAG_0 255 +#define INVENTORY_SLOT_BAG_START 19 +#define INVENTORY_SLOT_BAG_1 19 +#define INVENTORY_SLOT_BAG_2 20 +#define INVENTORY_SLOT_BAG_3 21 +#define INVENTORY_SLOT_BAG_4 22 +#define INVENTORY_SLOT_BAG_END 23 + +#define INVENTORY_SLOT_ITEM_START 23 +#define INVENTORY_SLOT_ITEM_1 23 +#define INVENTORY_SLOT_ITEM_2 24 +#define INVENTORY_SLOT_ITEM_3 25 +#define INVENTORY_SLOT_ITEM_4 26 +#define INVENTORY_SLOT_ITEM_5 27 +#define INVENTORY_SLOT_ITEM_6 28 +#define INVENTORY_SLOT_ITEM_7 29 +#define INVENTORY_SLOT_ITEM_8 30 +#define INVENTORY_SLOT_ITEM_9 31 +#define INVENTORY_SLOT_ITEM_10 32 +#define INVENTORY_SLOT_ITEM_11 33 +#define INVENTORY_SLOT_ITEM_12 34 +#define INVENTORY_SLOT_ITEM_13 35 +#define INVENTORY_SLOT_ITEM_14 36 +#define INVENTORY_SLOT_ITEM_15 37 +#define INVENTORY_SLOT_ITEM_16 38 +#define INVENTORY_SLOT_ITEM_END 39 + +#define BANK_SLOT_ITEM_START 39 +#define BANK_SLOT_ITEM_1 39 +#define BANK_SLOT_ITEM_2 40 +#define BANK_SLOT_ITEM_3 41 +#define BANK_SLOT_ITEM_4 42 +#define BANK_SLOT_ITEM_5 43 +#define BANK_SLOT_ITEM_6 44 +#define BANK_SLOT_ITEM_7 45 +#define BANK_SLOT_ITEM_8 46 +#define BANK_SLOT_ITEM_9 47 +#define BANK_SLOT_ITEM_10 48 +#define BANK_SLOT_ITEM_11 49 +#define BANK_SLOT_ITEM_12 50 +#define BANK_SLOT_ITEM_13 51 +#define BANK_SLOT_ITEM_14 52 +#define BANK_SLOT_ITEM_15 53 +#define BANK_SLOT_ITEM_16 54 +#define BANK_SLOT_ITEM_17 55 +#define BANK_SLOT_ITEM_18 56 +#define BANK_SLOT_ITEM_19 57 +#define BANK_SLOT_ITEM_20 58 +#define BANK_SLOT_ITEM_21 59 +#define BANK_SLOT_ITEM_22 60 +#define BANK_SLOT_ITEM_23 61 +#define BANK_SLOT_ITEM_24 62 +#define BANK_SLOT_ITEM_END 63 + +#define BANK_SLOT_BAG_START 63 +#define BANK_SLOT_BAG_1 63 +#define BANK_SLOT_BAG_2 64 +#define BANK_SLOT_BAG_3 65 +#define BANK_SLOT_BAG_4 66 +#define BANK_SLOT_BAG_5 67 +#define BANK_SLOT_BAG_6 68 +#define BANK_SLOT_BAG_END 69 + +// strored in m_buybackitems +#define BUYBACK_SLOT_START 69 +#define BUYBACK_SLOT_1 69 +#define BUYBACK_SLOT_2 70 +#define BUYBACK_SLOT_3 71 +#define BUYBACK_SLOT_4 72 +#define BUYBACK_SLOT_5 73 +#define BUYBACK_SLOT_6 74 +#define BUYBACK_SLOT_7 75 +#define BUYBACK_SLOT_8 76 +#define BUYBACK_SLOT_9 77 +#define BUYBACK_SLOT_10 78 +#define BUYBACK_SLOT_11 79 +#define BUYBACK_SLOT_12 80 +#define BUYBACK_SLOT_END 81 + +#define KEYRING_SLOT_START 81 +#define KEYRING_SLOT_END 97 + +// last+1 slot for item stored (in any way in player m_items data) +#define PLAYER_SLOT_END 97 +#define PLAYER_SLOTS_COUNT (PLAYER_SLOT_END - PLAYER_SLOT_START) + +#define TRADE_SLOT_COUNT 7 +#define TRADE_SLOT_TRADED_COUNT 6 +#define TRADE_SLOT_NONTRADED 6 + +enum MovementFlags +{ + MOVEMENTFLAG_FORWARD = 0x1, + MOVEMENTFLAG_BACKWARD = 0x2, + MOVEMENTFLAG_STRAFE_LEFT = 0x4, + MOVEMENTFLAG_STRAFE_RIGHT = 0x8, + MOVEMENTFLAG_LEFT = 0x10, + MOVEMENTFLAG_RIGHT = 0x20, + MOVEMENTFLAG_PITCH_UP = 0x40, + MOVEMENTFLAG_PITCH_DOWN = 0x80, + + MOVEMENTFLAG_WALK = 0x100, + MOVEMENTFLAG_JUMPING = 0x2000, + MOVEMENTFLAG_FALLING = 0x4000, + MOVEMENTFLAG_SWIMMING = 0x200000, + MOVEMENTFLAG_ONTRANSPORT = 0x2000000, + MOVEMENTFLAG_SPLINE = 0x4000000 +}; + struct PlayerEnumItem { uint32 displayId; @@ -47,6 +180,7 @@ class Player : public Unit public: Player(); void Create(uint64); + uint8 GetGender() { return GetUInt32Value(PLAYER_BYTES_3); } private: diff --git a/src/Client/World/Unit.cpp b/src/Client/World/Unit.cpp index f8f3366..34eec85 100644 --- a/src/Client/World/Unit.cpp +++ b/src/Client/World/Unit.cpp @@ -8,3 +8,14 @@ Unit::Unit() : WorldObject() _valuescount = UNIT_END; } +void Unit::Create(uint64 guid) +{ + Object::Create(guid); +} + +uint8 Unit::GetGender(void) +{ + uint32 temp = GetUInt32Value(UNIT_FIELD_BYTES_0); + return ((uint8*)&temp)[2]; +} + diff --git a/src/Client/World/Unit.h b/src/Client/World/Unit.h index 05202cc..833f90f 100644 --- a/src/Client/World/Unit.h +++ b/src/Client/World/Unit.h @@ -7,6 +7,8 @@ class Unit : public WorldObject { public: Unit(); + void Create(uint64); + uint8 GetGender(void); private: }; diff --git a/src/Client/World/UpdateData.cpp b/src/Client/World/UpdateData.cpp index 0530be0..53019b2 100644 --- a/src/Client/World/UpdateData.cpp +++ b/src/Client/World/UpdateData.cpp @@ -5,6 +5,10 @@ #include "UpdateFields.h" #include "Object.h" #include "Unit.h" +#include "Bag.h" +#include "GameObject.h" +#include "Corpse.h" +#include "DynamicObject.h" #include "ObjMgr.h" #include "UpdateMask.h" @@ -90,7 +94,13 @@ void WorldSession::_HandleUpdateObjectOpcode(WorldPacket& recvPacket) objmgr.Add(item); break; } - //case TYPEID_CONTAINER: // not yet handled + case TYPEID_CONTAINER: + { + Bag *bag = new Bag(); + bag->Create(uguid); + objmgr.Add(bag); + break; + } case TYPEID_UNIT: { Unit *unit = new Unit(); @@ -105,6 +115,27 @@ void WorldSession::_HandleUpdateObjectOpcode(WorldPacket& recvPacket) objmgr.Add(player); break; } + case TYPEID_GAMEOBJECT: + { + GameObject *go = new GameObject(); + go->Create(uguid); + objmgr.Add(go); + break; + } + case TYPEID_CORPSE: + { + Corpse *corpse = new Corpse(); + corpse->Create(uguid); + objmgr.Add(corpse); + break; + } + case TYPEID_DYNAMICOBJECT: + { + DynamicObject *dobj = new DynamicObject(); + dobj->Create(uguid); + objmgr.Add(dobj); + break; + } } this->_MovementUpdate(objtypeid, uguid, recvPacket); diff --git a/src/PseuWoW.vcproj b/src/PseuWoW.vcproj index dcc1a3a..812f82b 100644 --- a/src/PseuWoW.vcproj +++ b/src/PseuWoW.vcproj @@ -253,6 +253,12 @@ + + + + @@ -268,6 +274,24 @@ + + + + + + + + + + + + diff --git a/src/shared/tools.h b/src/shared/tools.h index 1f86ccc..61d0416 100644 --- a/src/shared/tools.h +++ b/src/shared/tools.h @@ -3,6 +3,9 @@ #include "common.h" +#define SETBIT(var,bit) ( (var)|=(1<<(bit)) ); +#define UNSETBIT(var,bit) ( (var)&=(~(1<<(bit))) ); +#define HASBIT(var,bit) ( (var)&(1<<(bit)) ); void printchex(std::string,bool); void printchex(char *in, uint32 len, bool);