diff mm7_2.cpp @ 31:f4450ff595fe

BLV loading (looks like) done.
author Nomad
date Fri, 19 Oct 2012 03:36:38 +0200
parents 4723e86bc51c
children 916bec351934 bcc051713d20
line wrap: on
line diff
--- a/mm7_2.cpp	Thu Oct 18 03:21:58 2012 +0200
+++ b/mm7_2.cpp	Fri Oct 19 03:36:38 2012 +0200
@@ -11846,23 +11846,23 @@
 //----- (00461103) --------------------------------------------------------
 void __cdecl sub_461103()
 {
-  GUIProgressBar *v0; // ebx@1
-  signed int v1; // ebp@1
-  char *v2; // esi@2
+  //GUIProgressBar *v0; // ebx@1
+  //signed int v1; // ebp@1
+  //char *v2; // esi@2
   __int16 v3; // cx@3
   int v4; // edx@8
-  size_t v5; // edi@14
+  //size_t v5; // edi@14
   signed int v6; // esi@14
-  char *v7; // edx@15
+  //char *v7; // edx@15
   signed int v8; // ecx@16
   int v9; // ecx@23
   MonsterInfo *v10; // ebx@23
-  int *v11; // esi@23
+  //int *v11; // esi@23
   int v12; // esi@25
   int v13; // eax@26
   __int16 v14; // ax@41
-  signed int v15; // [sp+10h] [bp-4Ch]@1
-  signed int v16; // [sp+10h] [bp-4Ch]@14
+  //signed int v15; // [sp+10h] [bp-4Ch]@1
+  //signed int v16; // [sp+10h] [bp-4Ch]@14
   signed int v17; // [sp+14h] [bp-48h]@3
   signed int v18; // [sp+14h] [bp-48h]@23
   int v19; // [sp+18h] [bp-44h]@1
@@ -11870,141 +11870,153 @@
   int v21[16]; // [sp+1Ch] [bp-40h]@17
 
   sub_450218_prolly_generate_chests_loot();
-  v0 = pGameLoadingUI_ProgressBar;
+  //v0 = pGameLoadingUI_ProgressBar;
   pGameLoadingUI_ProgressBar->Progress();
   pParty->uFlags |= 2u;
   pParty->field_7B5_in_arena_quest = 0;
-  v1 = 0;
+  //v1 = 0;
   dword_5C6DF8 = 1;
   pNPCStats->field_17FC0 = 0;
   v19 = pMapStats->GetMapInfo(pCurrentMapName);
-  v15 = 0;
-  if ( (signed int)uNumActors > 0 )
-  {
-    v2 = (char *)&pActors[0].uNPC_ID;
-    do
-    {
-      v3 = *((short *)v2 + 32);
-      v17 = v1;
+
+  //v15 = 0;
+  for (uint i = 0; i < uNumActors; ++i)
+  //if ( (signed int)uNumActors > 0 )
+  {
+    auto pActor = pActors + i;
+    //v2 = (char *)&pActors[0].uNPC_ID;
+    //do
+    //{
+      v3 = pActor->pMonsterInfo.uID;
+      v17 = 0;
       if ( v3 >= 115 && v3 <= 186 || v3 >= 232 && v3 <= 249 )
         v17 = 1;
-      v1 = 0;
+      //v1 = 0;
       v4 = (v3 - 1) % 3;
       if ( 2 == v4 )
       {
-        if ( *(short *)v2 && *(short *)v2 < 5000 )
-          goto LABEL_13;
+        if ( pActor->uNPC_ID && pActor->uNPC_ID < 5000 )
+          continue;
       }
       else
       {
         if ( v4 != 1 )
         {
-          if ( v4 != 0 || *(short *)v2 )
-            goto LABEL_13;
+          if ( v4 != 0 || pActor->uNPC_ID )
+            continue;
           goto LABEL_12;
         }
       }
-      if ( *(short *)v2 > 0 && *(short *)v2 < 5000 )
-        goto LABEL_13;
+      if ( pActor->uNPC_ID > 0 && pActor->uNPC_ID < 5000 )
+        continue;
       if ( v17 )
       {
         pNPCStats->InitializeAdditionalNPCs(&pNPCStats->array_13EF4[pNPCStats->field_17FC0], v3, 0, v19);
         v14 = LOWORD(pNPCStats->field_17FC0) + 5000;
         ++pNPCStats->field_17FC0;
-        *(short *)v2 = v14;
-        goto LABEL_13;
+        pActor->uNPC_ID = v14;
+        continue;
       }
 LABEL_12:
-      *(short *)v2 = 0;
-LABEL_13:
-      ++v15;
-      v2 += 836;
-    }
-    while ( v15 < (signed int)uNumActors );
-  }
+      pActor->uNPC_ID = 0;
+//LABEL_13:
+      //++v15;
+      //v2 += 836;
+    //}
+    //while ( v15 < (signed int)uNumActors );
+  }
+
   pGameLoadingUI_ProgressBar->Progress();
-  v5 = uNumActors;
+
+  //v5 = uNumActors;
   v6 = 0;
   v20 = 0;
-  v16 = v1;
-  if ( (signed int)uNumActors > v1 )
-  {
-    v7 = (char *)&pActors[0].pMonsterInfo;
-    do
-    {
+  //v16 = v1;
+
+  for (uint i = 0; i < uNumActors; ++i)
+  {
+    auto pActor = pActors + i;
+    //v7 = (char *)&pActors[0].pMonsterInfo;
+    //do
+    //{
       v8 = 0;
-      if ( v6 > v1 )
+      if ( v6 > 0 )
       {
         do
         {
-          if ( v21[v8] == *((short *)v7 + 26) - 1 )
+          if ( v21[v8] == pActor->pMonsterInfo.uID - 1 )
             break;
           ++v8;
         }
         while ( v8 < v6 );
       }
+
       if ( v8 == v6 )
       {
-        v21[v6++] = *((short *)v7 + 26) - 1;
+        v21[v6++] = pActor->pMonsterInfo.uID - 1;
         v20 = v6;
         if ( v6 == 16 )
           break;
       }
-      ++v16;
-      v7 += 836;
-    }
-    while ( v16 < (signed int)v5 );
-  }
+      //++v16;
+      //v7 += 836;
+    //}
+    //while ( v16 < (signed int)v5 );
+  }
+
   pGameLoadingUI_ProgressBar->Progress();
-  if ( v6 > v1 )
-  {
+
+  if ( v6 > 0 )
+  {
+    int _v0 = 0;
     do
     {
-      v9 = v21[v1];
+      v9 = v21[_v0];
       v18 = 4;
       v10 = &pMonsterStats->pInfos[v9 + 1];
-      v11 = (int *)pMonsterList->pMonsters[v9].pSoundSampleIDs;
+      //v11 = (int *)pMonsterList->pMonsters[v9].pSoundSampleIDs;
+      auto v11 = &pMonsterList->pMonsters[v9];
       do
       {
-        pSoundList->_4A9A67(*(short *)v11, 0);
-        v11 = (int *)((char *)v11 + 2);
+        pSoundList->_4A9A67(v11->pSoundSampleIDs[4 - v18], 0);
+        //v11 = (int *)((char *)v11 + 2);
         --v18;
       }
       while ( v18 );
       v12 = 0;
       do
-        LOWORD(v13) = pSoundList->_4A9A67(v12++ + word_4EE088_sound_ids[v10->uSpell1ID], 1u);
+        v13 = pSoundList->_4A9A67(v12++ + word_4EE088_sound_ids[v10->uSpell1ID], 1);
       while ( v13 );
-      ++v1;
-    }
-    while ( v1 < v20 );
-    v0 = pGameLoadingUI_ProgressBar;
-    v1 = 0;
-  }
-  v0->Progress();
+      ++_v0;
+    }
+    while ( _v0 < v6 );
+    //v0 = pGameLoadingUI_ProgressBar;
+    //v1 = 0;
+  }
+
+  pGameLoadingUI_ProgressBar->Progress();
+
   if ( dword_6BE368_debug_settings_2 & 4 )
-    uNumActors = v1;
+    uNumActors = 0;
   if ( dword_6BE368_debug_settings_2 & 8 )
-    uNumLevelDecorations = v1;
+    uNumLevelDecorations = 0;
   sub_4613C4();
-  v0->Progress();
-  pIndoorCamera->pos.y = v1;
-  pIndoorCamera->pos.x = v1;
+
+  pGameLoadingUI_ProgressBar->Progress();
+
+  pIndoorCamera->pos.y = 0;
+  pIndoorCamera->pos.x = 0;
   pIndoorCamera->pos.z = 100;
-  pIndoorCamera->sRotationY = v1;
-  pIndoorCamera->sRotationX = v1;
+  pIndoorCamera->sRotationY = 0;
+  pIndoorCamera->sRotationX = 0;
   viewparams->bRedrawGameUI = 1;
-  uLevel_StartingPointType = v1;
+  uLevel_StartingPointType = 0;
   pSprites_LOD->_461397();
   pPaletteManager->LockTestAll();
-  if ( pParty->pPickedItem.uItemID != v1 )
+  if ( pParty->pPickedItem.uItemID != 0 )
     pMouse->SetCursorBitmapFromItemID(pParty->pPickedItem.uItemID);
 }
-// 4EE088: using guessed type __int16 word_4EE088_sound_ids[];
-// 5C6DF8: using guessed type int dword_5C6DF8;
-// 6BE35C: using guessed type int uLevel_StartingPointType;
-// 6BE368: using guessed type int dword_6BE368_debug_settings_2;
-// 461103: using guessed type int var_40[16];
+
 
 
 //----- (004613C4) --------------------------------------------------------
@@ -13140,6 +13152,7 @@
   sub_461103();
   if ( !_strcmpi(pCurrentMapName, "d11.blv") || !_strcmpi(pCurrentMapName, "d10.blv") )
   {
+    __debugbreak();
     v6 = uNumActors;
     if ( (signed int)uNumActors > 0 )
     {
@@ -13161,8 +13174,7 @@
   pGameLoadingUI_ProgressBar->Release();
   _flushall();
 }
-// 5C35C4: using guessed type int bDialogueUI_InitializeActor_NPC_ID;
-// 6BE3C4: using guessed type char bUnderwater;
+
 
 //----- (004649EF) --------------------------------------------------------
 int __fastcall ReadWindowsRegistryInt(const char *pKey, int uDefValue)
@@ -15094,7 +15106,7 @@
 
   v1 = uEquipType;
   _this.Reset();
-  v2 = (unsigned __int8)byte_4E8398[v1];
+  v2 = (unsigned __int8)byte_4E8394[v1 + 4];
   v3 = pPlayers[uActiveCharacter];
   v9 = v3;
   v11 = (int *)((char *)&v3->pEquipment + 4 * v2);