changeset 436:4a42c2f97aa2

some itemgen crashes fixed
author Gloval
date Sun, 24 Feb 2013 10:13:00 +0400
parents 4f451a616d3d
children 17c90e543e28
files Items.cpp Player.cpp mm7_2.cpp mm7_data.cpp mm7_data.h stru9.cpp
diffstat 6 files changed, 22 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/Items.cpp	Sun Feb 24 03:07:03 2013 +0200
+++ b/Items.cpp	Sun Feb 24 10:13:00 2013 +0400
@@ -1647,11 +1647,11 @@
   if ( v20 <= EQUIP_BOW )
   {
     v37 = v5->uBonusChanceWpSpecial[v54];
-    if ( !*(unsigned int *)v37 )
+    if ( !v37 )
       return;
     v38 = rand() % 100;
-    v36 = __OFSUB__(v38, *(unsigned int *)v37);
-    v35 = v38 - *(unsigned int *)v37 < 0;
+    v36 = __OFSUB__(v38, v37);
+    v35 = v38 - v37 < 0;
   }
   else
   {
@@ -1665,10 +1665,10 @@
       }
       return;
     }
-    v22 = (int)&uBonusChanceStandart[v6];
-    if ( !*(unsigned int *)v22 )
+    v22 = uBonusChanceStandart[v6];
+    if ( !v22 )
       return;
-    v24 = *(unsigned int *)v22;
+    v24 = v22;
     v25 = rand() % 100;
     if ( !uBonusChanceSpecial[v6] && !(v25 < v24))
         return;
--- a/Player.cpp	Sun Feb 24 03:07:03 2013 +0200
+++ b/Player.cpp	Sun Feb 24 10:13:00 2013 +0400
@@ -1784,7 +1784,7 @@
 }
 // 506128: using guessed type int areWeLoadingTexture;
 
-
+//identf
 //----- (00490EEE) --------------------------------------------------------
 int Player::_490EEE(ItemGen *pItem, int a3, int a4, int a5)
 {
--- a/mm7_2.cpp	Sun Feb 24 03:07:03 2013 +0200
+++ b/mm7_2.cpp	Sun Feb 24 10:13:00 2013 +0400
@@ -7911,9 +7911,9 @@
   v4 = rand();
   v34 = 0;
   v5 = v4 % 100;
-  v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14;
-  v7 = (unsigned __int8)byte_4E8168[v6 + 16];
-  v8 = (unsigned __int8)byte_4E8168[v6 + 17];
+ // v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14;
+  v7 = (unsigned __int8)byte_4E8168[v3->uIndex-1][2*v2->Treasure_prob];
+  v8 = (unsigned __int8)byte_4E8168[v3->uIndex-1][2*v2->Treasure_prob+1];
   v32 = v5;
   v33 = v7;
   v9 = rand();
@@ -8089,8 +8089,8 @@
       if ( (v3->uItemID & 0x80000000u) == 0 )
         goto LABEL_56;
       v4 = rand() % 5 + 1;
-      v5 = (unsigned __int8)byte_4E8168[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2];
-      v6 = (unsigned __int8)byte_4E8168[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3];
+      v5 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 2];
+      v6 = (unsigned __int8)byte_4E8168[abs((int)v3->uItemID)-1][2*v2->Treasure_prob+1];//[2 * (v2->Treasure_prob + 7 * abs((int)v3->uItemID)) + 3];
       v7 = rand();
       v8 = v6 - v5 + 1;
       v9 = v5 + v7 % v8;
--- a/mm7_data.cpp	Sun Feb 24 03:07:03 2013 +0200
+++ b/mm7_data.cpp	Sun Feb 24 10:13:00 2013 +0400
@@ -1104,7 +1104,14 @@
 char aEWorkMsdevMm_7[777]; // idb
 char aGammaControlNo[777]; // idb
 __int16 word_4E8152[11] = {0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30};
-char byte_4E8168[116];
+char byte_4E8168[7][14]={  //byte_4E8178
+	{ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, 
+	{ 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
+	{ 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3},
+	{ 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4},
+	{ 2, 2, 2, 2, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5},
+	{ 2, 2, 2, 2, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6},
+	{ 2, 2, 2, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}};
 char aD3dTextureName[777]; // idb
 char aLogd3d_txt[777]; // idb
 char byte_4E8394[204] =
--- a/mm7_data.h	Sun Feb 24 03:07:03 2013 +0200
+++ b/mm7_data.h	Sun Feb 24 10:13:00 2013 +0400
@@ -786,7 +786,7 @@
 extern char aEWorkMsdevMm_7[]; // idb
 extern char aGammaControlNo[]; // idb
 extern __int16 word_4E8152[11];
-extern char byte_4E8168[116];
+extern char byte_4E8168[7][14];
 extern char aD3dTextureName[]; // idb
 extern char aLogd3d_txt[]; // idb
 extern char byte_4E8394[]; // weak
--- a/stru9.cpp	Sun Feb 24 03:07:03 2013 +0200
+++ b/stru9.cpp	Sun Feb 24 10:13:00 2013 +0400
@@ -227,7 +227,7 @@
 //----- (00498737) --------------------------------------------------------
 void stru9::AddVertex(struct VertexBuffer *pVertexBuffer, struct RenderVertexSoft *pVertex)
 {
-  __debugbreak();
+//  __debugbreak();
   RenderVertexSoft *v3; // eax@1
 
   v3 = &pVertexBuffer->pVertices[pVertexBuffer->uNumVertices];