changeset 142:8b8fd4d83fdc

Various things here and there
author Nomad
date Tue, 12 Feb 2013 06:28:08 +0200
parents cca78efb377e
children b099dd069171
files Actor.h GUIWindow.cpp Game.cpp Outdoor.cpp Outdoor.h Overlays.cpp Overlays.h Render.cpp Render.h Spells.cpp mm7_3.cpp mm7_data.cpp mm7_data.h stru6.cpp stru6.h
diffstat 15 files changed, 157 insertions(+), 215 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.h	Tue Feb 12 03:02:13 2013 +0200
+++ b/Actor.h	Tue Feb 12 06:28:08 2013 +0200
@@ -40,8 +40,8 @@
 /*  361 */
 enum ACTOR_BUFF_INDEX
 {
-  ACTOR_BUFF_STONED = 0x5,
-  ACTOR_BUFF_PARALYZED = 0x6,
+  ACTOR_BUFF_STONED = 5,
+  ACTOR_BUFF_PARALYZED = 6,
 };
 
 
@@ -88,16 +88,16 @@
   Fleeing = 0x7,
   Stunned = 0x8,
   Fidgeting = 0x9,
-  Interacting = 0xA,
-  Removed = 0xB,
+  Interacting = 10,
+  Removed = 11,
   AttackingRanged2 = 0xC,
   AttackingRanged3 = 0xD,
   Stoned = 0xE,
   Paralyzed = 0xF,
-  Resurrected = 0x10,
+  Resurrected = 16,
   Summoned = 17,
-  AttackingRanged4 = 0x12,
-  Disabled = 0x13,
+  AttackingRanged4 = 18,
+  Disabled = 19,
 };
 
 /*  265 */
--- a/GUIWindow.cpp	Tue Feb 12 03:02:13 2013 +0200
+++ b/GUIWindow.cpp	Tue Feb 12 06:28:08 2013 +0200
@@ -978,7 +978,7 @@
   LoadSpellbook(pPlayer->pNumSpellBookPage);
   v3 = 0;
   a2 = 0;
-  v7 = (int)(&pPlayer->spellbook.pFireSpellbook + pPlayer->pNumSpellBookPage);
+  v7 = (int)&pPlayer->spellbook.pChapters[pPlayer->pNumSpellBookPage];
   do
   {
     if ( *(char *)(v7 + v3) )
--- a/Game.cpp	Tue Feb 12 03:02:13 2013 +0200
+++ b/Game.cpp	Tue Feb 12 06:28:08 2013 +0200
@@ -50,10 +50,10 @@
 //----- (0044103C) --------------------------------------------------------
 void Game::Draw()
 {
-  float v2; // ST24_4@11
+  //float v2; // ST24_4@11
   //double v3; // ST28_8@11
   int v4; // edi@26
-  int v5; // eax@35
+  //int v5; // eax@35
 
   uFlags2 &= 0xFFFFFFFDu;
   if ( pParty->_497FC5_check_party_perception_against_level() )
@@ -96,7 +96,7 @@
     {
       if ( pRenderer->pRenderD3D )
       {
-        v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0;
+        float v2 = (double)(((signed int)pMiscTimer->uTotalGameTimeElapsed >> 2) & 0x1F) * 0.032258064 * 6.0;
         //v3 = v2 + 6.7553994e15;
         //pRenderer->field_1036A8_bitmapid = LODWORD(v3);
         pRenderer->field_1036A8_bitmapid = floorf(v2 + 0.5f);
@@ -121,8 +121,8 @@
   pRenderer->BeginScene();
   if (pRenderer->pRenderD3D)
     pMouse->DrawCursorToTarget();
-  if (pOtherOverlayList->field_3EC)
-    viewparams->bRedrawGameUI = 1;
+  if (pOtherOverlayList->bRedraw)
+    viewparams->bRedrawGameUI = true;
   v4 = viewparams->bRedrawGameUI;
   GameUI_DrawStatusBar();
   if (!viewparams->bRedrawGameUI)
@@ -140,15 +140,17 @@
     GameUI_DrawMinimap(488, 16, 625, 133, viewparams->uMinimapZoom, pParty->uFlags & 2);
     if (v4)
     {
-      if ( !sub_4226C2() && pRenderer->pRenderD3D)
+      if ( !sub_4226C2() && pRenderer->pRenderD3D) // clear game viewport with transparent color
         pRenderer->FillRectFast(pViewport->uViewportX, pViewport->uViewportY, pViewport->uViewportZ - pViewport->uViewportX,
-          pViewport->uViewportW - pViewport->uViewportY + 1, pRenderer->uTargetGMask | pRenderer->uTargetBMask);//0x0000FFFF/*pRenderer->uTargetGMask | pRenderer->uTargetBMask*/ - white window
+                                pViewport->uViewportW - pViewport->uViewportY + 1,
+                                pRenderer->uTargetGMask | pRenderer->uTargetBMask);
       viewparams->field_48 = 0;
     }
   }
-  v5 = pOtherOverlayList->field_3EC;
-  pOtherOverlayList->field_3EC = 0;
-  viewparams->bRedrawGameUI = v5;
+
+  viewparams->bRedrawGameUI = pOtherOverlayList->bRedraw;
+  pOtherOverlayList->bRedraw = 0;
+
   GameUI_DrawPartySpells();
   if (v4 || pParty->pHirelings[0]._anim_end_time || pParty->pHirelings[1]._anim_end_time )
     DrawHiredNPCs();
--- a/Outdoor.cpp	Tue Feb 12 03:02:13 2013 +0200
+++ b/Outdoor.cpp	Tue Feb 12 06:28:08 2013 +0200
@@ -126,17 +126,20 @@
     pOutdoor->_47EF60(v5, v4, 1);
   }
   pGame->uFlags2 &= 0xFFFFFFFEu;
-  if ( pRenderer->pRenderD3D && pRenderer->bUsingSpecular )
+  if (pRenderer->pRenderD3D && pRenderer->bUsingSpecular)
     pGame->pLightmapBuilder->uFlags |= 1u;
   else
     pGame->pLightmapBuilder->uFlags &= 0xFFFFFFFEu;
+
   uNumDecorationsDrawnThisFrame = 0;
   _unused000 = 0;
   uNumSpritesDrawnThisFrame = 0;
   uNumBillboardsToDraw = 0;
-  DrawActors();
-  if ( !pOutdoorCamera->bDoNotRenderDecorations )
+
+  PrepareActorsDrawList();
+  if (!pOutdoorCamera->bDoNotRenderDecorations)
     pRenderer->DrawDecorations();
+
   pRenderer->DrawLayingItems_Shooting_Magic_ODM();
   pRenderer->TransformBillboardsAndSetPalettesODM();//Ritor1: do comment to test
   sub_485F53((Vec2_int_ *)unnamed_6BE060);
@@ -2894,16 +2897,16 @@
 }
 
 //----- (0047B42C) --------------------------------------------------------
-unsigned int OutdoorLocation::DrawActors()
+void OutdoorLocation::PrepareActorsDrawList()
 {
   unsigned int result; // eax@1
-  Actor *v1; // edi@2
-  __int16 v2; // ax@3
-  int v3; // esi@5
+  //Actor *v1; // edi@2
+  //__int16 v2; // ax@3
+  int z; // esi@5
   float v4; // ST48_4@8
-  double v5; // ST38_8@8
-  float v6; // ST48_4@10
-  double v7; // ST30_8@10
+  //double v5; // ST38_8@8
+  //float v6; // ST48_4@10
+  //double v7; // ST30_8@10
   unsigned int v8; // eax@11
   int v9; // edx@11
   __int16 v10; // dx@11
@@ -2925,7 +2928,7 @@
   int v26; // ST54_4@45
   int v27; // ecx@45
   RenderBillboard *v28; // esi@45
-  __int16 v29; // ax@46
+  //__int16 v29; // ax@46
   unsigned __int8 v30; // zf@46
   unsigned __int8 v31; // sf@46
   signed __int16 v32; // ax@49
@@ -2933,8 +2936,8 @@
   int v34; // ecx@54
   MonsterDesc *v35; // edx@54
   int v36; // ecx@54
-  unsigned __int8 v37; // zf@54
-  unsigned __int8 v38; // sf@54
+  //unsigned __int8 v37; // zf@54
+  //unsigned __int8 v38; // sf@54
   unsigned int v39; // [sp-8h] [bp-68h]@23
   unsigned int v40; // [sp-4h] [bp-64h]@23
   int v41; // [sp+24h] [bp-3Ch]@11
@@ -2950,70 +2953,64 @@
   int v51; // [sp+34h] [bp-2Ch]@41
   int v52; // [sp+34h] [bp-2Ch]@50
   int v53; // [sp+38h] [bp-28h]@36
-  int v54; // [sp+3Ch] [bp-24h]@2
+  //int v54; // [sp+3Ch] [bp-24h]@2
   int y; // [sp+40h] [bp-20h]@5
   int x; // [sp+44h] [bp-1Ch]@5
   int v57; // [sp+48h] [bp-18h]@45
   int v58; // [sp+4Ch] [bp-14h]@45
-  signed int v59; // [sp+50h] [bp-10h]@1
+  //signed int v59; // [sp+50h] [bp-10h]@1
   int X; // [sp+54h] [bp-Ch]@36
-  __int16 v61; // [sp+58h] [bp-8h]@5
+  //__int16 v61; // [sp+58h] [bp-8h]@5
   signed __int16 v62; // [sp+5Ch] [bp-4h]@25
 
-  result = 0;
-  v59 = 0;
-  if ( (signed int)uNumActors > 0 )
+  //result = 0;
+  //v59 = 0;
+  for (int i = 0; i < uNumActors; ++i)
   {
-    v54 = 0;
-    v1 = pActors;//[0].vPosition.z;
-    do
-    {
-	  v2 = v1->uAIState;
-	  v1->uAttributes &= 0xFFFFFFF7u;
-      if ( v2 == 11 || v2 == 19 )
-        goto LABEL_58;
-	  v3 = v1->vPosition.z;
+    //v54 = 0;
+    //v1 = pActors;//[0].vPosition.z;
+    //do
+    //{
+    auto actor = pActors + i;
+	  //v2 = actor->uAIState;
+
+	actor->uAttributes &= 0xFFFFFFF7u;
+    if (actor->uAIState == Removed || actor->uAIState == Disabled)
+      continue;
+
+	  z = actor->vPosition.z;
       v49 = 0;
-	  x = v1->vPosition.x;
-	  y = v1->vPosition.y;
-	  v61 = v1->vPosition.z;
-      if ( v2 == 17 )
+	  x = actor->vPosition.x;
+	  y = actor->vPosition.y;
+      if (actor->uAIState == Summoned)
       {
-		if ( (v1->uSummonerID & 7) != OBJECT_Actor || pActors[v1->uSummonerID >> 3].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 )
+		if ((actor->uSummonerID & 7) != OBJECT_Actor ||
+             pActors[actor->uSummonerID >> 3].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 )
         {
-			v6 = (double)v1->uActorHeight * 0.5;
-          v7 = v6 + 6.7553994e15;
-          v3 += LODWORD(v7);
-          v61 = v3;
+          z += floorf(actor->uActorHeight * 0.5f + 0.5f);
         }
         else
         {
           v49 = 1;
-		  pGame->pStru6Instance->_4A7F74(v1->vPosition.x, v1->vPosition.y, v3);
-          v4 = (1.0 - (double)*(signed int *)(v1 + 38) / (double)*((short *)v1 + 7))
-			  * (double)(2 * (signed int)v1->uActorHeight);
-          v5 = v4 + 6.7553994e15;
-          v3 -= LODWORD(v5);
-          v61 = v3;
-          if ( v3 > v1->vPosition.z )
-          {
-            v61 = v1->vPosition.z;
-            v3 = v1->vPosition.z;
-          }
+		  pGame->pStru6Instance->_4A7F74(actor->vPosition.x, actor->vPosition.y, z);
+          v4 = (1.0 - (double)actor->uCurrentActionTime / (double)actor->uCurrentActionLength) *
+			   (double)(2 * actor->uActorHeight);
+          z -= floorf(v4 + 0.5f);
+          if ( z > actor->vPosition.z )
+            z = actor->vPosition.z;
         }
       }
-      v8 = stru_5C6E00->Atan2(
-             v1->vPosition.x - pIndoorCamera->pos.x,
-             v1->vPosition.y - pIndoorCamera->pos.y);
-	  LOWORD(v9) = v1->uYawAngle;
+      v8 = stru_5C6E00->Atan2(actor->vPosition.x - pIndoorCamera->pos.x,
+                              actor->vPosition.y - pIndoorCamera->pos.y);
+	  LOWORD(v9) = actor->uYawAngle;
       v41 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v9 - v8) >> 8) & 7;
-	  v10 = v1->uCurrentActionAnimation;
+	  v10 = actor->uCurrentActionAnimation;
       if ( pParty->bTurnBasedModeOn )
       {
         if ( v10 != 1 )
         {
 LABEL_17:
-			v12 = v1->uCurrentActionTime;
+			v12 = actor->uCurrentActionTime;
           goto LABEL_18;
         }
         v11 = pMiscTimer->uTotalGameTimeElapsed;
@@ -3024,11 +3021,11 @@
           goto LABEL_17;
         v11 = pEventTimer->uTotalGameTimeElapsed;
       }
-      v12 = v54 + v11;
+      v12 = 32 * i + v11;
 LABEL_18:
-      if ( (signed __int64)v1->pActorBuffs[5].uExpireTime > 0 || (signed __int64)v1->pActorBuffs[6].uExpireTime > 0 )
+      if ( (signed __int64)actor->pActorBuffs[5].uExpireTime > 0 || (signed __int64)actor->pActorBuffs[6].uExpireTime > 0 )
         v12 = 0;
-	  v13 = v1->uAIState;
+	  v13 = actor->uAIState;
       if ( v13 == 17 && !v49 )
       {
         v40 = v12;
@@ -3038,7 +3035,7 @@
         goto LABEL_25;
       }
       v40 = v12;
-	  v39 = v1->pSpriteIDs[v10];
+	  v39 = actor->pSpriteIDs[v10];
       if ( v13 != 16 )
         goto LABEL_24;
       v14 = pSpriteFrameTable->GetFrameBy_x(v39, v12);
@@ -3057,7 +3054,7 @@
       if ( v15->uGlowRadius )
       {
         //LOBYTE(v16) = byte_4E94D3;
-        pMobileLightsStack->AddLight(x, y, v3, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3);
+        pMobileLightsStack->AddLight(x, y, z, 0, v15->uGlowRadius, 0xFFu, 0xFFu, 0xFFu, byte_4E94D3);
       }
       v17 = (x - pIndoorCamera->pos.x) << 16;
       if ( pIndoorCamera->sRotationX )
@@ -3067,13 +3064,13 @@
             + ((unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16);
         v50 = (unsigned __int64)(v17 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16;
         v53 = (unsigned __int64)(v18 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16;
-        v44 = (v3 - pIndoorCamera->pos.z) << 16;
+        v44 = (z - pIndoorCamera->pos.z) << 16;
         v19 = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16)
             + ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16);
         X = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_sine) >> 16)
           + ((unsigned __int64)(v47 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16);
         if ( v19 < 262144 || v19 > pOutdoorCamera->shading_dist_mist << 16 )
-          goto LABEL_58;
+          continue;
         v20 = v53 - v50;
         v42 = v53 - v50;
         v21 = ((unsigned __int64)(v44 * (signed __int64)pOutdoorCamera->camera_rotation_x_int_cosine) >> 16)
@@ -3086,12 +3083,12 @@
         v22 = (unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16;
         X = v22 + v51;
         if ( v22 + v51 < 262144 || v22 + v51 > pOutdoorCamera->shading_dist_mist << 16 )
-          goto LABEL_58;
+          continue;
         v23 = (unsigned __int64)(((x - pIndoorCamera->pos.x) << 16)
                                * (signed __int64)pOutdoorCamera->camera_rotation_y_int_sine) >> 16;
         v20 = ((unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v23;
         v42 = ((unsigned __int64)(v48 * (signed __int64)pOutdoorCamera->camera_rotation_y_int_cosine) >> 16) - v23;
-        v21 = (v3 - pIndoorCamera->pos.z) << 16;
+        v21 = (z - pIndoorCamera->pos.z) << 16;
       }
       v45 = v21;
       v24 = abs(v20);
@@ -3111,24 +3108,23 @@
         v46 = pViewport->uScreenCenterY - ((signed int)(((unsigned __int64)(v25 / X * v45) >> 16) + 32768) >> 16);
         result = uNumBillboardsToDraw;
         v28 = &pBillboardRenderList[uNumBillboardsToDraw];
-        if ( (signed int)uNumBillboardsToDraw >= 500 )
-          return result;
+        if (uNumBillboardsToDraw >= 500)
+          return;
         ++uNumBillboardsToDraw;
         ++uNumSpritesDrawnThisFrame;
-		v1->uAttributes |= 8u;
+		actor->uAttributes |= 8u;
         v28->uHwSpriteID = v15->pHwSpriteIDs[v41];
-        v29 = v15->uPaletteIndex;
         v28->uIndoorSectorID = 0;
-        v28->uPalette = v29;
+        v28->uPalette = v15->uPaletteIndex;
         v28->field_0 = (unsigned __int64)(v15->scale * (signed __int64)v58) >> 16;
-        v30 = HIDWORD(v1->pActorBuffs[3].uExpireTime) == 0;
-        v31 = SHIDWORD(v1->pActorBuffs[3].uExpireTime) < 0;
+        v30 = HIDWORD(actor->pActorBuffs[3].uExpireTime) == 0;
+        v31 = SHIDWORD(actor->pActorBuffs[3].uExpireTime) < 0;
         v28->field_4 = (unsigned __int64)(v15->scale * (signed __int64)v57) >> 16;
-        if ( v31 || v31 | v30 && LODWORD(v1->pActorBuffs[3].uExpireTime) <= 0u )
+        if ( v31 || v31 | v30 && LODWORD(actor->pActorBuffs[3].uExpireTime) <= 0u )
         {
-          if ( (signed __int64)v1->pActorBuffs[10].uExpireTime > 0i64 )
+          if ( (signed __int64)actor->pActorBuffs[10].uExpireTime > 0i64 )
           {
-            v52 = (unsigned __int64)(pGame->pStru6Instance->_4A806F(v1)
+            v52 = (unsigned __int64)(pGame->pStru6Instance->_4A806F(actor)
                                    * (signed __int64)v28->field_4) >> 16;
 LABEL_53:
             LOWORD(v27) = v43;
@@ -3137,44 +3133,42 @@
         }
         else
         {
-          v32 = v1->pActorBuffs[3].uPower;
+          v32 = actor->pActorBuffs[3].uPower;
           if ( v32 )
           {
-            v33 = v1->pActorBuffs[3].uPower;
+            v33 = actor->pActorBuffs[3].uPower;
             v28->field_0 = (unsigned __int64)(65536 / (unsigned __int16)v32 * (signed __int64)v28->field_0) >> 16;
             v52 = (unsigned __int64)(65536 / v33 * (signed __int64)v28->field_4) >> 16;
             goto LABEL_53;
           }
         }
         v28->uScreenSpaceX = v27;
+        v28->uScreenSpaceY = v46;
         v28->some_x = x;
-        v28->uScreenSpaceY = v46;
         v28->some_y = y;
-        v28->some_z = v61;
+        v28->some_z = z;
         HIWORD(v34) = HIWORD(X);
         LOWORD(v34) = 0;
         v28->uPaletteSubindex = 0;
-        v28->sZValue = v34 + (8 * v59 | 3);
-        v28->field_14 = v59;
+        v28->sZValue = v34 + (8 * i | OBJECT_Actor);
+        v28->field_14_actor_id = i;
         v35 = pMonsterList->pMonsters;
-		v36 = v1->pMonsterInfo.uID;
-        v37 = HIDWORD(v1->pActorBuffs[5].uExpireTime) == 0;
-        v38 = SHIDWORD(v1->pActorBuffs[5].uExpireTime) < 0;
+		v36 = actor->pMonsterInfo.uID;
         v28->field_1E = v62 | 0x200;
         v28->pSpriteFrame = v15;
         v28->uTintColor = *((int *)&v35[v36] - 36);
-        if ( !v38 && (!(v38 | v37) || LODWORD(v1->pActorBuffs[5].uExpireTime)) )
+        if (actor->pActorBuffs[ACTOR_BUFF_STONED].uExpireTime > 0)
           v28->field_1E = v62 | 0x200;
       }
-LABEL_58:
-      ++v59;
-      v54 += 32;
-      result = v59;
-      ++v1;
-    }
-    while ( v59 < (signed int)uNumActors );
+//LABEL_58:
+      //++v59;
+      //v54 += 32;
+      //result = v59;
+      //++v1;
+    //}
+    //while ( v59 < (signed int)uNumActors );
   }
-  return result;
+  //return result;
 }
 // 4E94D3: using guessed type char byte_4E94D3;
 // 5187E4: using guessed type int uNumSpritesDrawnThisFrame;
--- a/Outdoor.h	Tue Feb 12 03:02:13 2013 +0200
+++ b/Outdoor.h	Tue Feb 12 06:28:08 2013 +0200
@@ -140,7 +140,7 @@
   }
 
   void ExecDraw(unsigned int bRedraw);
-  unsigned int DrawActors();
+  void PrepareActorsDrawList();
   void CreateDebugLocation();
   void Release();
   bool Load(const char *pFilename, ODMFace *File, size_t a4, int thisa);
--- a/Overlays.cpp	Tue Feb 12 03:02:13 2013 +0200
+++ b/Overlays.cpp	Tue Feb 12 06:28:08 2013 +0200
@@ -38,7 +38,7 @@
 {
   signed int v6; // edx@1
   OtherOverlayList *v7; // eax@1
-  signed int result; // eax@4
+  //signed int result; // eax@4
   signed int v9; // esi@6
   __int16 v10; // dx@9
   __int16 v11; // dx@11
@@ -81,9 +81,9 @@
   v7->pOverlays[0].field_6 = v11;
   v7->pOverlays[0].field_10 = a5;
   v7->pOverlays[0].field_E = a6;
-  result = 1;
-  this->field_3EC = 1;
-  return result;
+
+  bRedraw = true;
+  return true;
 }
 
 //----- (00441964) --------------------------------------------------------
--- a/Overlays.h	Tue Feb 12 03:02:13 2013 +0200
+++ b/Overlays.h	Tue Feb 12 06:28:08 2013 +0200
@@ -25,7 +25,7 @@
 struct OtherOverlayList
 {
   inline OtherOverlayList():  //----- (0045848D)
-    field_3E8(0), field_3EC(0)
+    field_3E8(0), bRedraw(false)
   {}
     
   int _4418B1(int a2, int a3, int a4, int a5);
@@ -34,7 +34,7 @@
 
   OtherOverlay pOverlays[50];
   int field_3E8;
-  int field_3EC;
+  int bRedraw;
 };
 #pragma pack(pop)
 
--- a/Render.cpp	Tue Feb 12 03:02:13 2013 +0200
+++ b/Render.cpp	Tue Feb 12 06:28:08 2013 +0200
@@ -2938,8 +2938,8 @@
 //----- (0047BACF) --------------------------------------------------------
 void Render::TransformBillboardsAndSetPalettesODM()
 {
-  int v0; // edi@1
-  char *v1; // esi@2
+  //int v0; // edi@1
+  //char *v1; // esi@2
   unsigned int v2; // edx@3
   int v3; // eax@3
   int v4; // edi@3
@@ -2954,7 +2954,7 @@
   int v13; // eax@14
   RenderBillboardTransform_local0 billboard; // [sp+4h] [bp-60h]@1
   int v15; // [sp+54h] [bp-10h]@13
-  int v16; // [sp+58h] [bp-Ch]@1
+  //int v16; // [sp+58h] [bp-Ch]@1
   int v17; // [sp+5Ch] [bp-8h]@2
   int v18; // [sp+60h] [bp-4h]@13
 
@@ -2966,20 +2966,21 @@
   billboard.uViewportY = pViewport->uViewportY;
   billboard.uViewportZ = pViewport->uViewportZ - 1;
   billboard.uViewportW = pViewport->uViewportW;
-  v0 = 0;
+  //v0 = 0;
   pOutdoorCamera->uNumBillboards = uNumBillboardsToDraw;
-  v16 = 0;
-  if ( (signed int)uNumBillboardsToDraw > 0 )
+
+  //v16 = 0;
+  for (int i = 0; i < uNumBillboardsToDraw; ++i)
   {
     v17 = 0;
     v1 = (char *)&pBillboardRenderList[0].uScreenSpaceY;
-    do
-    {
+    //do
+    //{
       billboard.uScreenSpaceX = *((short *)v1 - 1);
       v2 = *((short *)v1 - 5);
       billboard.uScreenSpaceY = *(short *)v1;
       v3 = *((int *)v1 - 10);
-      billboard.uParentBillboardID = v0;
+      billboard.uParentBillboardID = i;
       v4 = *((int *)v1 + 1);
       billboard.field_10 = v3;
       v5 = *((int *)v1 - 9);
@@ -3022,11 +3023,11 @@
         }
       }
       v17 += 5;
-      v0 = v16 + 1;
+      //v0 = v16 + 1;
       v1 += 52;
-      ++v16;
-    }
-    while ( v16 < (signed int)uNumBillboardsToDraw );
+      //++v16;
+    //}
+    //while ( v16 < (signed int)uNumBillboardsToDraw );
   }
 }
 
--- a/Render.h	Tue Feb 12 03:02:13 2013 +0200
+++ b/Render.h	Tue Feb 12 06:28:08 2013 +0200
@@ -57,7 +57,7 @@
   float fov_x;
   float fov_y;
   int sZValue;
-  int field_14;
+  int field_14_actor_id;
   unsigned __int16 uHwSpriteID;
   __int16 uPalette;
   __int16 uIndoorSectorID;
--- a/Spells.cpp	Tue Feb 12 03:02:13 2013 +0200
+++ b/Spells.cpp	Tue Feb 12 06:28:08 2013 +0200
@@ -51,7 +51,7 @@
   if ( v2 )
   {
     ((OtherOverlay *)&stru_5E4C90._decor_events[20 * v2 + 105])->Reset();
-    pOtherOverlayList->field_3EC = 1;
+    pOtherOverlayList->bRedraw = true;
     v1->uOverlayID = 0;
   }
 }
@@ -100,7 +100,7 @@
       if ( (unsigned __int16)v8 != a5 )
       {
         ((OtherOverlay *)&stru_5E4C90._decor_events[20 * v8 + 105])->Reset();
-        pOtherOverlayList->field_3EC = 1;
+        pOtherOverlayList->bRedraw = true;
         v6->uOverlayID = 0;
       }
     }
--- a/mm7_3.cpp	Tue Feb 12 03:02:13 2013 +0200
+++ b/mm7_3.cpp	Tue Feb 12 06:28:08 2013 +0200
@@ -13557,30 +13557,21 @@
 
 
 //----- (00441D38) --------------------------------------------------------
-void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int flags)
+void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap)
 {
   int uHeight; // ebx@6
-  //unsigned int v9; // edx@9
-  //unsigned int v10; // ebx@10
   __int16 v11; // cx@11
-  //BLVFace *v12; // ecx@17
-  //unsigned int v13; // ecx@21
   unsigned int v14; // ebx@23
   int v15; // eax@23
-  //unsigned int *v16; // ecx@28
   __int16 v17; // di@30
   double v18; // st7@30
   float v19; // ST38_4@30
   double v20; // st7@30
   double v21; // st6@30
   double v22; // st5@33
-  //unsigned __int16 *v26; // edx@37
   signed int v27; // eax@37
   unsigned __int16 *v28; // ecx@37
   signed int v29; // edi@40
-  //int v30; // eax@42
-  //unsigned __int16 *v31; // ebx@43
-  //signed int v32; // edi@46
   signed int v33; // ebx@50
   unsigned int v34; // eax@50
   signed int v35; // ecx@50
@@ -13598,7 +13589,6 @@
   int v47; // eax@108
   unsigned int v48; // ebx@114
   unsigned int v49; // ST64_4@114
-  //double v50; // ST20_8@117
   unsigned int v51; // [sp-10h] [bp-64h]@79
   unsigned int v52; // [sp-10h] [bp-64h]@100
   unsigned int v53; // [sp-Ch] [bp-60h]@79
@@ -13610,9 +13600,7 @@
   unsigned __int16 v59; // [sp-4h] [bp-58h]@100
   unsigned __int16 v60; // [sp+10h] [bp-44h]@66
   unsigned int v61; // [sp+10h] [bp-44h]@85
-  //unsigned __int16 *v62; // [sp+14h] [bp-40h]@30
   unsigned int v63; // [sp+14h] [bp-40h]@85
-  //int v64; // [sp+18h] [bp-3Ch]@39
   unsigned int v65; // [sp+18h] [bp-3Ch]@85
   unsigned int lPitch; // [sp+20h] [bp-34h]@1
   unsigned int lPitcha; // [sp+20h] [bp-34h]@23
@@ -13622,34 +13610,24 @@
   unsigned __int16 uBlue; // [sp+28h] [bp-2Ch]@1
   signed int uBluea; // [sp+28h] [bp-2Ch]@37
   int v73; // [sp+2Ch] [bp-28h]@30
-  //unsigned __int8 *v74; // [sp+30h] [bp-24h]@30
   int v76; // [sp+34h] [bp-20h]@91
   int v77; // [sp+34h] [bp-20h]@108
-  //signed int v78; // [sp+38h] [bp-1Ch]@37
   int v79; // [sp+38h] [bp-1Ch]@72
-  //signed int a2b; // [sp+40h] [bp-14h]@41
   char *a2c; // [sp+40h] [bp-14h]@68
-  //int a3a; // [sp+44h] [bp-10h]@40
   signed int uCenterY; // [sp+48h] [bp-Ch]@1
   signed int uCenterX; // [sp+4Ch] [bp-8h]@1
-  //signed int uZb; // [sp+5Ch] [bp+8h]@27
   signed int uWidth; // [sp+5Ch] [bp+8h]@30
-  //signed int uZd; // [sp+5Ch] [bp+8h]@45
   signed int uZe; // [sp+5Ch] [bp+8h]@67
   signed int uZf; // [sp+5Ch] [bp+8h]@85
   signed int uZg; // [sp+5Ch] [bp+8h]@105
   unsigned int uWa; // [sp+60h] [bp+Ch]@23
   float uWb; // [sp+60h] [bp+Ch]@30
-  //unsigned __int16 *uWc; // [sp+60h] [bp+Ch]@37
   unsigned int uWd; // [sp+60h] [bp+Ch]@95
   float uZooma; // [sp+64h] [bp+10h]@117
-  //signed int flagsa; // [sp+68h] [bp+14h]@42
   unsigned int flagsb; // [sp+68h] [bp+14h]@66
   Actor *flagsc; // [sp+68h] [bp+14h]@86
   unsigned int flagsd; // [sp+68h] [bp+14h]@105
 
-  //a3 = uY;
-  //a2 = uX;
   uCenterX = (uX + uZ) / 2;
   uCenterY = (uY + uW) / 2;
   lPitch = pRenderer->uTargetSurfacePitch;
@@ -13705,78 +13683,46 @@
 
       default: assert(false);
     }
-//LABEL_37:
-    //v23 = v20 * 65536.0;
-    //v24 = v23 + 6.7553994e15;
+    assert(sizeof(pOdmMinimap) == 137 * 117 * sizeof(short));
+
     v70 = floorf(v20 * 65536.0 + 0.5f);//LODWORD(v24);
-    //uWe = uWb * 65536.0;
-    //v25 = uWe + 6.7553994e15;
-    //v78 = v70;
     uBluea = floorf(uWb * 65536.0 + 0.5f);//LODWORD(v25);
     v27 = uBluea >> 16;
     v28 = &pRenderer->pTargetSurface[uX + uY * lPitch];
-    if ( flags && pMapLod0)
-    {
-      auto pMinimap = (unsigned __int16 *)_56EFD8_minimap;
-      //if ( v74 )
-      //{
+    if (pMapLod0 && bRedrawOdmMinimap)
+    {
+      assert(uWidth == 137 && uHeight == 117);
+      //auto pMinimap = (unsigned __int16 *)pOdmMinimap;
+
         auto mapWidth = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth;
-        //if ( uHeight > 0 )
-        //{
-          //a3a = uHeight;
+
           v29 = v70 >> 16;
-          //do
+
           for (int y = 0; y < uHeight; ++y)
           {
-            //a2b = 0;
-            //if ( uWidth > 0 )
-            //{
               auto pMapLod0Line = &pMapLod0[v27 * mapWidth];
-              //flagsa = uWidth;
-              //a2b = uWidth;
               for (int x = 0; x < uWidth; ++x)
-              //do
-              {
-                //v31 = uWc;
-                //++uWc;
-                *pMinimap++ = pPal[pMapLod0Line[v29]];
-                //v78 += v73;
+              {
+                //*pMinimap++ = pPal[pMapLod0Line[v29]];
+                pOdmMinimap[y][x] = pPal[pMapLod0Line[v29]];
                 v29 = (v70 + x * v73) >> 16;
-                //--flagsa;
-              }
-              //while ( flagsa );
-            //}
-            //v78 = v70;
+              }
+
             v29 = v70 >> 16;
             v28 += 137 - uWidth;
             uBluea += v73;
             v27 = uBluea >> 16;
-            //--a3a;
-          }
-          //while ( a3a );
-        //}
-      //}
-    }
-
-    auto pMinimap = (unsigned __int16 *)_56EFD8_minimap;
-    //uZd = 117;
-    //do
+          }
+    }
+
     for (int y = 0; y < 117; ++y)
     {
-      //v32 = 137;
-      //do
       for (int x = 0; x < 137; ++x)
       {
-        *v28++ = *pMinimap++;
-        //++v28;
-        //++v26;
-        //--v32;
-      }
-      //while ( v32 );
+        *v28++ = pOdmMinimap[y][x];
+      }
       v28 += lPitch - 137;
-      //--uZd;
-    }
-    //while ( uZd );
+    }
     uNumBlueFacesInBLVMinimap = 0;
   }
   else
--- a/mm7_data.cpp	Tue Feb 12 03:02:13 2013 +0200
+++ b/mm7_data.cpp	Tue Feb 12 06:28:08 2013 +0200
@@ -1466,7 +1466,7 @@
 int bRingsShownInCharScreen; // weak
 int _unused000; // weak
 
-unsigned __int16 _56EFD8_minimap[117][137];
+unsigned __int16 pOdmMinimap[117][137];
 unsigned int uNumBlueFacesInBLVMinimap;
 unsigned __int16 pBlueFacesInBLVMinimapIDs[50];
 int pTextureIDs_isns[14];
--- a/mm7_data.h	Tue Feb 12 03:02:13 2013 +0200
+++ b/mm7_data.h	Tue Feb 12 06:28:08 2013 +0200
@@ -1310,7 +1310,7 @@
 extern int bRingsShownInCharScreen; // weak
 extern int _unused000; // weak
 
-extern unsigned __int16 _56EFD8_minimap[117][137];
+extern unsigned __int16 pOdmMinimap[117][137];
 extern unsigned int uNumBlueFacesInBLVMinimap;
 extern unsigned __int16 pBlueFacesInBLVMinimapIDs[50];
 extern int pTextureIDs_isns[14];
@@ -2000,7 +2000,7 @@
 void Load_isn_spells_21_27();
 void GameUI_DrawPartySpells();
 __int16 __fastcall sub_441A4E(int a1);
-void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int flags);
+void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap);
 int __fastcall DrawSpellbook_Map_sub(unsigned int x, unsigned int y, unsigned int a4, int a5, int _48074); // idb
 int __cdecl Initialize2DA();
 unsigned int __fastcall LoadEventsToBuffer(const char *pContainerName, char *a2, unsigned int uBufferSize);
--- a/stru6.cpp	Tue Feb 12 03:02:13 2013 +0200
+++ b/stru6.cpp	Tue Feb 12 06:28:08 2013 +0200
@@ -595,11 +595,11 @@
 }
 
 //----- (004A7E89) --------------------------------------------------------
-int stru6::_4A7E89_sparkles_on_actor_after_it_casts_buff(Actor *pActor, unsigned int uDiffuse)
+void stru6::_4A7E89_sparkles_on_actor_after_it_casts_buff(Actor *pActor, unsigned int uDiffuse)
 {
   Actor *v3; // edi@1
   int v4; // ebx@3
-  int result; // eax@5
+  //int result; // eax@5
   Particle_ Dst; // [sp+Ch] [bp-6Ch]@1
   int v7; // [sp+74h] [bp-4h]@2
   signed int pActora; // [sp+80h] [bp+8h]@1
@@ -632,7 +632,6 @@
     --pActora;
   }
   while ( pActora );
-  return result;
 }
 
 //----- (004A7F74) --------------------------------------------------------
@@ -1633,7 +1632,7 @@
       {
         v7 = pIconsFrameTable->GetFrame(*((int *)v2 + 2), v3);
         pRenderer->DrawTextureTransparent(*v1, 0x181u, &pIcons_LOD->pTextures[v7->uTextureID]);
-        pOtherOverlayList->field_3EC = 1;
+        pOtherOverlayList->bRedraw = true;
       }
       else
       {
--- a/stru6.h	Tue Feb 12 03:02:13 2013 +0200
+++ b/stru6.h	Tue Feb 12 06:28:08 2013 +0200
@@ -128,7 +128,7 @@
   void _4A7A66_miltiple_spell_collision_partifles___like_after_sparks_or_lightning(LayingItem *a1, unsigned int uDiffuse, unsigned int uTextureID, float a4);
   void _4A7C07(struct LayingItem *a2);
   void AddProjectile(struct LayingItem *a2, int a3, unsigned int uTextureID);
-  int _4A7E89_sparkles_on_actor_after_it_casts_buff(struct Actor *pActor, unsigned int uDiffuse);
+  void _4A7E89_sparkles_on_actor_after_it_casts_buff(struct Actor *pActor, unsigned int uDiffuse);
   void _4A7F74(int x, int y, int z);
   int _4A806F(struct Actor *pActor);
   void _4A80DC_some_stuff_sw(struct LayingItem *a2);