changeset 1759:845a6503f55c

fixing some itemarray zero accesses
author Grumpy7
date Tue, 01 Oct 2013 06:17:32 +0200
parents 42a1874a2171
children a2ea57410b15
files Actor.cpp Items.h Player.cpp mm7_6.cpp
diffstat 4 files changed, 21 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Mon Sep 30 06:09:29 2013 +0200
+++ b/Actor.cpp	Tue Oct 01 06:17:32 2013 +0200
@@ -3012,7 +3012,7 @@
     break;
   }
 
-  if (rand() % 100 < 20)
+  if (rand() % 100 < 20 && drop.uItemID != 0)
   {
     sub_42F7EB_DropItemAt(pItemsTable->pItems[drop.uItemID].uSpriteID,
       actor->vPosition.x,
--- a/Items.h	Mon Sep 30 06:09:29 2013 +0200
+++ b/Items.h	Tue Oct 01 06:17:32 2013 +0200
@@ -273,11 +273,11 @@
                             // 72  Prevents falling damage.
   int uNumCharges; //10
   unsigned int uAttributes;  //14
-  unsigned __int8 uBodyAnchor;
-  char uMaxCharges;
-  char uHolderPlayer;
-  char field_1B;
-  unsigned __int64 uExpireTime;
+  unsigned __int8 uBodyAnchor; //18
+  char uMaxCharges;  //19
+  char uHolderPlayer;  //1A
+  char field_1B;  //1B
+  unsigned __int64 uExpireTime; //1C
 };
 #pragma pack(pop)
 
--- a/Player.cpp	Mon Sep 30 06:09:29 2013 +0200
+++ b/Player.cpp	Tue Oct 01 06:17:32 2013 +0200
@@ -2564,7 +2564,6 @@
 int Player::GetAttackRecoveryTime(bool bRangedAttack)
 {
   ItemGen  *weapon = nullptr;
-  ItemDesc *weapon_desc = nullptr;
   uint      weapon_recovery = base_recovery_times_per_weapon_type[0];
   if (bRangedAttack)
   {
@@ -2647,9 +2646,9 @@
         (weapon->GetPlayerSkillType() == PLAYER_SKILL_SWORD || weapon->GetPlayerSkillType() == PLAYER_SKILL_AXE || weapon->GetPlayerSkillType() == PLAYER_SKILL_BOW) )
     {
       if (SkillToMastery(pActiveSkills[weapon->GetPlayerSkillType()]) >= 2 )  // Expert   Sword, Axe & Bow   reduce recovery
-        sword_axe_bow_recovery_reduction = pActiveSkills[weapon_desc->uSkillType] & 0x3F;
-    }
-    if (weapon_desc->uSkillType == PLAYER_SKILL_BLASTER)
+        sword_axe_bow_recovery_reduction = pActiveSkills[weapon->GetPlayerSkillType()] & 0x3F;
+    }
+    if (weapon->GetPlayerSkillType() == PLAYER_SKILL_BLASTER)
       shooting_laser = true;
   }
 
@@ -5515,8 +5514,7 @@
           || var_type > VAR_History_28
           || (v22 = var_type - VAR_History_0, pParty->PartyTimes.HistoryEventTimes[v22])
           || (pParty->PartyTimes.HistoryEventTimes[v22] = pParty->uTimePlayed,
-              v23 = pStorylineText->StoreLine[v22].pText == 0,//*(&pStorylineText->field_0 + 3 * v22) == 0,
-              v23) )
+              pStorylineText->StoreLine[v22].pText == 0) )//*(&pStorylineText->field_0 + 3 * v22) == 0,
           return;
         bFlashHistoryBook = 1;
       }
@@ -5579,18 +5577,18 @@
         this->classType = (PLAYER_CLASS_TYPE)var_value;
         if ( (char)var_value == PLAYER_CLASS_LICH )
         {
-          v9 = NULL;
           for (int i = 0; i < 138; i++)
           {
             v9 = &this->pInventoryItemList[i];
             if (v9->uItemID == ITEM_LICH_JAR_EMPTY)
+            {
+              v9->uItemID = ITEM_LICH_JAR_FULL;
+              v9->uHolderPlayer = currPlayerId + 1;
+              v10 = (int)((char *)this + 36 * 138);
+              *(int *)(v10 + 532) = 601;
+              *(char *)(v10 + 558) = currPlayerId + 1;
               break;
-          }
-          if (v9 != NULL && v9->uItemID != ITEM_LICH_JAR_EMPTY)
-          {
-            v10 = (int)((char *)this + 36 * 138);   //originally 36 * v8. the code got to this condition only if v8 was equal to 138
-            *(int *)(v10 + 532) = 601;
-            *(char *)(v10 + 558) = currPlayerId + 1;
+            }
           }
           if ( this->sResFireBase < 20 )
             this->sResFireBase = 20;
@@ -5602,10 +5600,9 @@
             this->sResEarthBase = 20;
           this->sResMindBase = 200;
           this->sResBodyBase = 200;
-          v11 = this->GetSexByVoice();
           this->uPrevVoiceID = this->uVoiceID;
           this->uPrevFace = this->uCurrentFace;
-          if ( v11 )
+          if ( IsFemale() )
           {
             this->uCurrentFace = 21;
             this->uVoiceID = 21;
@@ -5857,10 +5854,10 @@
     {
       v16 = (int)((char *)&this->pConditions[16] + 2 * var_type);
       v17 = *(char *)v16;
-      if ( var_value <= VAR_BodyResistanceBonus )
+      if ( var_value <= 63 )
       {
         LOWORD(v15) = (unsigned __int8)var_value;
-        v18 = v15 | v17 & VAR_BodyResistanceBonus;
+        v18 = v15 | v17 & 63;
       }
       else
       {
--- a/mm7_6.cpp	Mon Sep 30 06:09:29 2013 +0200
+++ b/mm7_6.cpp	Tue Oct 01 06:17:32 2013 +0200
@@ -251,7 +251,7 @@
   }
   else
   {
-    if ( pActor->array_000234[3].GetItemEquipType() == 18 )
+    if ( pActor->array_000234[3].uItemID != 0 &&  pActor->array_000234[3].GetItemEquipType() == 18 )
 	{
 		v14 = pActor->array_000234[3].uSpecEnchantmentType;
 		pActor->array_000234[3].Reset();
@@ -262,7 +262,6 @@
 		}
 	}
   }
-  pActor->uCarriedItemID = 1;
   if ( pActor->uCarriedItemID )
   {
     Dst.Reset();