diff Events.cpp @ 2024:bb0da61e4a7e

substract item and AddItem for Alexis fix
author Ritor1
date Sat, 16 Nov 2013 00:02:24 +0600
parents c1c74df0a33e
children 4000f8184c29
line wrap: on
line diff
--- a/Events.cpp	Thu Nov 14 17:25:09 2013 +0600
+++ b/Events.cpp	Sat Nov 16 00:02:24 2013 +0600
@@ -954,19 +954,23 @@
             v4 = v124;
             break;
           }
-          v67 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix.data();
+          //v67 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix.data();
           for ( v65 = 0; v65 < 126; ++v65 )
           {
-            if ( (int)&pPlayers[uActiveCharacter]->pInventoryItemList[v67] == pValue )
+            v67 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&pPlayers[uActiveCharacter]->pInventoryMatrix[v65]);
+			if (v67)
+			{
+            if ( pPlayers[uActiveCharacter]->pInventoryItemList[v67 - 1].uItemID == pValue )
             {
-              pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v65);
+              pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(pPlayers[uActiveCharacter]->pInventoryMatrix[v65]);
               ++curr_seq_num;
               v4 = v124;
-              break;
+              goto substract;
             }
-            v67 += 4;
+			}
+            //v67 += 4;
           }
-          while ( (signed int)v65 < 126 );
+          //while ( (signed int)v65 < 126 );
           v69 = (int)&pPlayers[uActiveCharacter]->pEquipment;
           for ( v68 = 0; v68 < 16; ++v68 )
           {
@@ -981,15 +985,19 @@
           }
           for (int i = 1; i < 5; i++)
           {
-            v72 = (int)pPlayers[i]->pInventoryMatrix.data();
+            //v72 = (int)pPlayers[i]->pInventoryMatrix.data();
             for ( int v71 = 0; v71 < 126; ++v71 )
             {
-              if ( (int)&pPlayers[i]->pInventoryItemList[v72] == pValue )
+              v72 = pPlayers[i]->GetItemIDAtInventoryIndex(&pPlayers[i]->pInventoryMatrix[v71]);
+			  if (v72)
+			  {
+              if ( pPlayers[i]->pInventoryItemList[v72 - 1].uItemID == pValue )
               {
-                pPlayers[i]->RemoveItemAtInventoryIndex(v71);
-                break;
+                pPlayers[i]->RemoveItemAtInventoryIndex(pPlayers[i]->pInventoryMatrix[v71]);
+                goto substract;
               }
-              v72 += 4;
+			  }
+              //v72 += 4;
             }
             v73 = 0;
             v74 = (int)&pPlayers[i]->pEquipment;
@@ -1031,6 +1039,7 @@
           pPlayer = &pParty->pPlayers[player_choose];
           pPlayer->SubtractVariable((enum VariableType)EVT_WORD(_evt->v5), pValue);
         }
+substract:
         ++curr_seq_num;
         v4 = v124;
         break;