From aa703e896f79aa4285d2bf4aaabbc73b7487492c Mon Sep 17 00:00:00 2001 From: "False.Genesis" Date: Fri, 2 Feb 2007 01:28:28 +0000 Subject: [PATCH] temp. commit, more will come soon. crashes not yet fixed :/ --- bin/scripts/_onwhisper.def | 2 +- src/Client/HelperDefs.h | 8 +++ src/Client/World/Item.cpp | 14 ++++ src/Client/World/Item.h | 126 ++++++++++++++++++++++++++++++++++++ src/Client/World/Object.cpp | 20 +++++- src/Client/World/Object.h | 9 ++- src/PseuWoW.vcproj | 9 +++ src/shared.vcproj | 4 +- src/shared/common.h | 1 + 9 files changed, 187 insertions(+), 6 deletions(-) create mode 100644 src/Client/HelperDefs.h create mode 100644 src/Client/World/Item.cpp create mode 100644 src/Client/World/Item.h diff --git a/bin/scripts/_onwhisper.def b/bin/scripts/_onwhisper.def index 60fc295..3d37aaa 100644 --- a/bin/scripts/_onwhisper.def +++ b/bin/scripts/_onwhisper.def @@ -3,4 +3,4 @@ // EXECUTED EVERYTIME A WHISPER IS BEEING RECIEVED // comment out the following line if you dont need it -REPLY,0 No need to whisper me, i am not yet programmed for it! \ No newline at end of file +//REPLY,0 No need to whisper me, i am not yet programmed for it! \ No newline at end of file diff --git a/src/Client/HelperDefs.h b/src/Client/HelperDefs.h new file mode 100644 index 0000000..9d7c099 --- /dev/null +++ b/src/Client/HelperDefs.h @@ -0,0 +1,8 @@ +#ifndef _HELPERDEFS_H +#define _HELPERDEFS_H + +#define GUID_HIPART(x) (*(((uint32*)&(x))+1)) +#define GUID_LOPART(x) (*((uint32*)&(x))) +#define MAKE_GUID(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) ) + +#endif \ No newline at end of file diff --git a/src/Client/World/Item.cpp b/src/Client/World/Item.cpp new file mode 100644 index 0000000..f8b4f97 --- /dev/null +++ b/src/Client/World/Item.cpp @@ -0,0 +1,14 @@ +#include "WorldSession.h" +#include "UpdateFields.h" + +#include "Item.h" + +Item::Item() +{ + _type |= TYPE_ITEM; + _typeid = TYPEID_ITEM; + + _valuescount = ITEM_END; + _slot = 0; + //_bag = NULL; // not yet implemented +} \ No newline at end of file diff --git a/src/Client/World/Item.h b/src/Client/World/Item.h new file mode 100644 index 0000000..fb31d39 --- /dev/null +++ b/src/Client/World/Item.h @@ -0,0 +1,126 @@ +#ifndef _ITEM_H +#define _ITEM_H + +#include "common.h" +#include "Object.h" + +enum InventoryChangeFailure +{ + EQUIP_ERR_OK = 0, + EQUIP_ERR_YOU_MUST_REACH_LEVEL_N = 1, + EQUIP_ERR_SKILL_ISNT_HIGH_ENOUGH = 2, + EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT = 3, + EQUIP_ERR_BAG_FULL = 4, + EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG = 5, + EQUIP_ERR_CANT_TRADE_EQUIP_BAGS = 6, + EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE = 7, + EQUIP_ERR_NO_REQUIRED_PROFICIENCY = 8, + EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE = 9, + EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM = 10, + EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM2 = 11, + EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE2 = 12, + EQUIP_ERR_CANT_EQUIP_WITH_TWOHANDED = 13, + EQUIP_ERR_CANT_DUAL_WIELD = 14, + EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG = 15, + EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2 = 16, + EQUIP_ERR_CANT_CARRY_MORE_OF_THIS = 17, + EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE3 = 18, + EQUIP_ERR_ITEM_CANT_STACK = 19, + EQUIP_ERR_ITEM_CANT_BE_EQUIPPED = 20, + EQUIP_ERR_ITEMS_CANT_BE_SWAPPED = 21, + EQUIP_ERR_SLOT_IS_EMPTY = 22, + EQUIP_ERR_ITEM_NOT_FOUND = 23, + EQUIP_ERR_CANT_DROP_SOULBOUND = 24, + EQUIP_ERR_OUT_OF_RANGE = 25, + EQUIP_ERR_TRIED_TO_SPLIT_MORE_THAN_COUNT = 26, + EQUIP_ERR_COULDNT_SPLIT_ITEMS = 27, + EQUIP_ERR_MISSING_REAGENT = 28, + EQUIP_ERR_NOT_ENOUGH_MONEY = 29, + EQUIP_ERR_NOT_A_BAG = 30, + EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS = 31, + EQUIP_ERR_DONT_OWN_THAT_ITEM = 32, + EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER = 33, + EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT = 34, + EQUIP_ERR_TOO_FAR_AWAY_FROM_BANK = 35, + EQUIP_ERR_ITEM_LOCKED = 36, + EQUIP_ERR_YOU_ARE_STUNNED = 37, + EQUIP_ERR_YOU_ARE_DEAD = 38, + EQUIP_ERR_CANT_DO_RIGHT_NOW = 39, + EQUIP_ERR_BAG_FULL2 = 40, + EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER2 = 41, + EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH = 42, + EQUIP_ERR_STACKABLE_CANT_BE_WRAPPED = 43, + EQUIP_ERR_EQUIPPED_CANT_BE_WRAPPED = 44, + EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED = 45, + EQUIP_ERR_BOUND_CANT_BE_WRAPPED = 46, + EQUIP_ERR_UNIQUE_CANT_BE_WRAPPED = 47, + EQUIP_ERR_BAGS_CANT_BE_WRAPPED = 48, + EQUIP_ERR_ALREADY_LOOTED = 49, + EQUIP_ERR_INVENTORY_FULL = 50, + EQUIP_ERR_BANK_FULL = 51, + EQUIP_ERR_ITEM_IS_CURRENTLY_SOLD_OUT = 52, + EQUIP_ERR_BAG_FULL3 = 53, + EQUIP_ERR_ITEM_NOT_FOUND2 = 54, + EQUIP_ERR_ITEM_CANT_STACK2 = 55, + EQUIP_ERR_BAG_FULL4 = 56, + EQUIP_ERR_ITEM_SOLD_OUT = 57, + EQUIP_ERR_OBJECT_IS_BUSY = 58, + EQUIP_ERR_NONE = 59, + EQUIP_ERR_CANT_DO_IN_COMBAT = 60, + EQUIP_CANT_DO_WHILE_DISARMED = 61, + EQUIP_ERR_BAG_FULL6 = 62, + EQUIP_ITEM_RANK_NOT_ENOUGH = 63, + EQUIP_ITEM_REPUTATION_NOT_ENOUGH = 64, + EQUIP_MORE_THAN1_SPECIAL_BAG = 65 +}; + +enum BuyFailure +{ + BUY_ERR_CANT_FIND_ITEM = 0, + BUY_ERR_ITEM_ALREADY_SOLD = 1, + BUY_ERR_NOT_ENOUGHT_MONEY = 2, + BUY_ERR_SELLER_DONT_LIKE_YOU = 4, + BUY_ERR_DISTANCE_TOO_FAR = 5, + BUY_ERR_CANT_CARRY_MORE = 8, + BUY_ERR_LEVEL_REQUIRE = 11, + BUY_ERR_REPUTATION_REQUIRE = 12 +}; + +enum SellFailure +{ + SELL_ERR_CANT_FIND_ITEM = 1, + SELL_ERR_CANT_SELL_ITEM = 2, + SELL_ERR_CANT_FIND_VENDOR = 3 +}; + +class Item : public Object +{ +public: + Item(); + 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; + }*/ + +private: + uint8 _slot; + // Bag *_bag; // not yet implemented + // ItemProto *_proto; // not yet implemented. + // is it good to use a proto here? + + +}; + + + + +#endif \ No newline at end of file diff --git a/src/Client/World/Object.cpp b/src/Client/World/Object.cpp index 3bbfbf8..e33701b 100644 --- a/src/Client/World/Object.cpp +++ b/src/Client/World/Object.cpp @@ -17,6 +17,23 @@ Object::~Object() if(_uint32values) delete [] _uint32values; } + +void Object::_InitValues() +{ + _uint32values = new uint32[ _valuescount ]; + memset(_uint32values, 0, _valuescount*sizeof(uint32)); +} + +void Object::_Create( uint64 guid ) +{ + if(!_uint32values) + _InitValues(); + + SetUInt32Value( OBJECT_FIELD_GUID, GUID_LOPART(guid) ); + SetUInt32Value( OBJECT_FIELD_GUID+1, GUID_HIPART(guid) ); + SetUInt32Value( OBJECT_FIELD_TYPE, _type ); +} + WorldObject::WorldObject() { @@ -31,4 +48,5 @@ void WorldObject::SetPosition(float x, float y, float z, float o, uint16 _map) _z = z; _o = o; _m = _map; -} \ No newline at end of file +} + diff --git a/src/Client/World/Object.h b/src/Client/World/Object.h index da47642..9b32dcc 100644 --- a/src/Client/World/Object.h +++ b/src/Client/World/Object.h @@ -65,14 +65,20 @@ public: { _floatvalues[ index ] = value; } + inline void SetUInt32Value( uint16 index, float value ) + { + _uint32values[ index ] = value; + } protected: ~Object(); + void _Create(uint64 guid); + void _InitValues(void); uint16 _valuescount; union { - uint8 *_uint32values; + uint32 *_uint32values; float *_floatvalues; }; uint8 _type; @@ -88,7 +94,6 @@ public: inline float GetY(void) { return _y; } inline float GetZ(void) { return _z; } inline float GetO(void) { return _o; } - protected: float _x,_y,_z,_o; // coords, orientation uint16 _m; // map diff --git a/src/PseuWoW.vcproj b/src/PseuWoW.vcproj index c9afe36..6a853f2 100644 --- a/src/PseuWoW.vcproj +++ b/src/PseuWoW.vcproj @@ -159,6 +159,9 @@ + + @@ -266,6 +269,12 @@ + + + + diff --git a/src/shared.vcproj b/src/shared.vcproj index 9dd1c9c..1e6f6c9 100644 --- a/src/shared.vcproj +++ b/src/shared.vcproj @@ -24,7 +24,7 @@