From: Laszlo T. <ave...@us...> - 2004-04-10 17:59:56
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17294 Modified Files: Actor.cpp CharAnimations.cpp CharAnimations.h GameControl.cpp Inventory.cpp Inventory.h Map.cpp Log Message: Fixed Inventory to use engine specific inventory size Index: Actor.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Actor.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** Actor.cpp 4 Apr 2004 20:22:38 -0000 1.40 --- Actor.cpp 10 Apr 2004 17:46:24 -0000 1.41 *************** *** 89,93 **** DeleteMe = false; FromGame = false; - // inventory = new Inventory; } --- 89,92 ---- *************** *** 103,107 **** free( ShortName ); } - // delete inventory; } --- 102,105 ---- Index: Map.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Map.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** Map.cpp 25 Mar 2004 16:58:20 -0000 1.80 --- Map.cpp 10 Apr 2004 17:46:24 -0000 1.81 *************** *** 258,263 **** if (!ca) continue; ! Animation* anim = ca->GetAnimation( actor->AnimID, ! actor->Orientation ); if (anim && anim->autoSwitchOnEnd && --- 258,262 ---- if (!ca) continue; ! Animation* anim = ca->GetAnimation( actor->AnimID, actor->Orientation ); if (anim && anim->autoSwitchOnEnd && Index: CharAnimations.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/CharAnimations.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** CharAnimations.h 25 Mar 2004 22:11:22 -0000 1.20 --- CharAnimations.h 10 Apr 2004 17:46:24 -0000 1.21 *************** *** 40,43 **** --- 40,44 ---- #endif + #define MAX_ORIENT 16 #define MAX_ANIMS 19 Index: Inventory.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Inventory.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Inventory.cpp 8 Apr 2004 17:06:02 -0000 1.6 --- Inventory.cpp 10 Apr 2004 17:46:24 -0000 1.7 *************** *** 24,33 **** #include "Inventory.h" - Inventory::Inventory() { - for (int i = 0; i < INVENTORY_SIZE; i++) { - slots.push_back( NULL ); - } } --- 24,29 ---- *************** *** 41,44 **** --- 37,51 ---- } + void Inventory::SetSlotCount(unsigned int size) + { + if(slots.size()) { + printf("Inventory size changed???\n"); + //we don't allow reassignment, + //if you want this, delete the previous slots here + abort(); + } + slots.assign((size_t) size, NULL); + } + /** if you supply a null string, then it checks if the slot is empty */ bool Inventory::HasItemInSlot(const char *resref, int slot) *************** *** 125,133 **** } ! void Inventory::SetSlotItem(CREItem* item, int slot) { ! int d = slot - slots.size() + 1; ! for ( ; d > 0 ; d--) ! slots.push_back( NULL ); if(slots[slot]) { delete slots[slot]; --- 132,141 ---- } ! void Inventory::SetSlotItem(CREItem* item, unsigned int slot) { ! if (slot>=slots.size() ) { ! printf("Invalid slot!\n"); ! abort(); ! } if(slots[slot]) { delete slots[slot]; *************** *** 136,140 **** } ! int Inventory::AddSlotItem(CREItem* item, int slot, CREItem **res_item) { // FIXME: join items if possible --- 144,148 ---- } ! int Inventory::AddSlotItem(CREItem* item, unsigned int slot, CREItem **res_item) { // FIXME: join items if possible Index: GameControl.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/GameControl.cpp,v retrieving revision 1.122 retrieving revision 1.123 diff -C2 -d -r1.122 -r1.123 *** GameControl.cpp 10 Apr 2004 10:34:32 -0000 1.122 --- GameControl.cpp 10 Apr 2004 17:46:24 -0000 1.123 *************** *** 1211,1215 **** bool GameControl::EvaluateDialogTrigger(Scriptable* target, DialogString* trigger) { - return true; int ORcount = 0; int result; --- 1211,1214 ---- Index: Inventory.h =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/Inventory.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Inventory.h 8 Apr 2004 17:06:02 -0000 1.5 --- Inventory.h 10 Apr 2004 17:46:24 -0000 1.6 *************** *** 68,72 **** private: std::vector<CREItem*> slots; - //CREItem* slots[38]; public: --- 68,71 ---- *************** *** 85,88 **** --- 84,90 ---- int GetSlotCount() { return slots.size(); }; + /** sets inventory size, for the first time */ + void SetSlotCount(unsigned int size); + /** returns CREItem in specified slot. if count != -1 it ** splits the item and returns only requuested amount */ *************** *** 91,102 **** /** adds CREItem to the inventory. If slot == -1, finds ** first eligible slot, eventually splitting the item to ! ** more slots. Returns true if successfull. ** FIXME: it should allow for cases when part of the item's amount ** can go in and part can't. Maybe return number instead? or CRE?*/ ! int AddSlotItem(CREItem* item, int slot, CREItem** res_item); /** flags: see ieCREItemFlagBits */ void DestroyItem(const char *resref, ieDword flags); ! void SetSlotItem(CREItem* item, int slot); /** returns weight of whole inventory, i.e. encumbrance? */ --- 93,104 ---- /** adds CREItem to the inventory. If slot == -1, finds ** first eligible slot, eventually splitting the item to ! ** more slots. Returns true if successful. ** FIXME: it should allow for cases when part of the item's amount ** can go in and part can't. Maybe return number instead? or CRE?*/ ! int AddSlotItem(CREItem* item, unsigned int slot, CREItem** res_item); /** flags: see ieCREItemFlagBits */ void DestroyItem(const char *resref, ieDword flags); ! void SetSlotItem(CREItem* item, unsigned int slot); /** returns weight of whole inventory, i.e. encumbrance? */ Index: CharAnimations.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/Core/CharAnimations.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** CharAnimations.cpp 27 Mar 2004 12:08:38 -0000 1.31 --- CharAnimations.cpp 10 Apr 2004 17:46:24 -0000 1.32 *************** *** 36,40 **** LoadedFlag = 0; for (int i = 0; i < MAX_ANIMS; i++) { ! for (int j = 0; j < 16; j++) { Anims[i][j] = NULL; } --- 36,40 ---- LoadedFlag = 0; for (int i = 0; i < MAX_ANIMS; i++) { ! for (int j = 0; j < MAX_ORIENT; j++) { Anims[i][j] = NULL; } *************** *** 69,76 **** case 5: { ! for (int AnimID = 0; ! AnimID < MAX_ANIMS; ! AnimID++) { ! for (int i = 0; i < 16; i += 2) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); --- 69,74 ---- case 5: { ! for (int AnimID = 0; AnimID < MAX_ANIMS; AnimID++) { ! for (int i = 0; i < MAX_ORIENT; i += 2) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); *************** *** 83,87 **** { for (int AnimID = 0; AnimID < MAX_ANIMS; AnimID++) { ! for (int i = 0; i < 16; i++) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); --- 81,85 ---- { for (int AnimID = 0; AnimID < MAX_ANIMS; AnimID++) { ! for (int i = 0; i < MAX_ORIENT; i++) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); *************** *** 97,101 **** { for (int AnimID = 0; AnimID < MAX_ANIMS; AnimID++) { ! for (int i = 0; i < 16; i++) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); --- 95,99 ---- { for (int AnimID = 0; AnimID < MAX_ANIMS; AnimID++) { ! for (int i = 0; i < MAX_ORIENT; i++) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); *************** *** 111,115 **** { for (int AnimID = 0; AnimID < MAX_ANIMS; AnimID++) { ! for (int i = 0; i < 16; i++) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); --- 109,113 ---- { for (int AnimID = 0; AnimID < MAX_ANIMS; AnimID++) { ! for (int i = 0; i < MAX_ORIENT; i++) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); *************** *** 131,135 **** { for (int AnimID = 0; AnimID < MAX_ANIMS; AnimID++) { ! for (int i = 0; i < 16; i += 2) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); --- 129,133 ---- { for (int AnimID = 0; AnimID < MAX_ANIMS; AnimID++) { ! for (int i = 0; i < MAX_ORIENT; i += 2) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); *************** *** 148,152 **** case IE_ANI_WALK: { ! for (int i = 0; i < 16; i++) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); --- 146,150 ---- case IE_ANI_WALK: { ! for (int i = 0; i < MAX_ORIENT; i++) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); *************** *** 164,168 **** default: { ! for (int i = 0; i < 16; i += 2) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); --- 162,166 ---- default: { ! for (int i = 0; i < MAX_ORIENT; i += 2) { if (Anims[AnimID][i]) delete( Anims[AnimID][i] ); *************** *** 255,261 **** */ ! Animation* CharAnimations::GetAnimation(unsigned char AnimID, ! unsigned char Orient) { //TODO: Implement Auto Resource Loading if (Anims[AnimID][Orient]) { --- 253,262 ---- */ ! Animation* CharAnimations::GetAnimation(unsigned char AnimID, unsigned char Orient) { + if(AnimID>=MAX_ANIMS) { + printf("Illegal animation ID\n"); + abort(); + } //TODO: Implement Auto Resource Loading if (Anims[AnimID][Orient]) { *************** *** 330,334 **** case IE_ANI_CODE_MIRROR_2: ! { switch (OrientCount) { case 9: --- 331,335 ---- case IE_ANI_CODE_MIRROR_2: ! { switch (OrientCount) { case 9: *************** *** 375,379 **** case IE_ANI_PST_START: { ! for (int j = 0; j < 16; j++) { Anims[IE_ANI_PST_START][j] = a; } --- 376,380 ---- case IE_ANI_PST_START: { ! for (int j = 0; j < MAX_ORIENT; j++) { Anims[IE_ANI_PST_START][j] = a; } *************** *** 396,407 **** case IE_ANI_PST_GHOST: ! { ! for (int i = 0; i < 18; i++) { ! for (int j = 0; j < 16; j++) { ! Anims[i][j] = NULL; ! } } } ! break; } if (Anims[AnimID][Orient]) { --- 397,411 ---- case IE_ANI_PST_GHOST: ! { ! for (int i = 0; i < 18; i++) { //MAX_ANIMS-1 ?? ! for (int j = 0; j < MAX_ORIENT; j++) { ! Anims[i][j] = NULL; } } ! } ! break; ! default: ! printf("Unknown mirror type\n"); ! abort(); } if (Anims[AnimID][Orient]) { |