changeset 98:f76e4ea4a224

Outdoor::Load
author Nomad
date Sun, 04 Nov 2012 03:58:34 +0200
parents b5e26a133fae
children 6305c1cd9f6e
files AudioPlayer.cpp Indoor.cpp Indoor_stuff.h LightmapBuilder.cpp Outdoor.cpp Outdoor.h PaletteManager.h Party.h mm7_1.cpp mm7_3.cpp mm7_4.cpp mm7_data.cpp mm7_data.h
diffstat 13 files changed, 793 insertions(+), 705 deletions(-) [+]
line wrap: on
line diff
--- a/AudioPlayer.cpp	Fri Nov 02 14:45:06 2012 +0200
+++ b/AudioPlayer.cpp	Sun Nov 04 03:58:34 2012 +0200
@@ -1616,7 +1616,7 @@
         return;
       }
       v59 = v2;
-      if ( pNumSoundDecorations <= v2 )
+      if ( _6807E0_num_decorations_with_sounds_6807B8 <= v2 )
         return;
       while ( 1 )
       {
@@ -1630,7 +1630,7 @@
           break;
 LABEL_89:
         ++v59;
-        if ( v59 >= pNumSoundDecorations )
+        if ( v59 >= _6807E0_num_decorations_with_sounds_6807B8 )
           return;
       }
       v48 = &pDecorationList->pDecorations[v44->uDecorationDescID];
--- a/Indoor.cpp	Fri Nov 02 14:45:06 2012 +0200
+++ b/Indoor.cpp	Sun Nov 04 03:58:34 2012 +0200
@@ -67,7 +67,7 @@
 
 
 //----- (0043F39E) --------------------------------------------------------
-void __fastcall sub_43F39E(IndoorLocation_drawstru *_this)
+void __fastcall PrepareDrawLists_BLV(IndoorLocation_drawstru *_this)
 {
   //int *v1; // ecx@1
   //double v2; // ST30_8@3
@@ -93,10 +93,9 @@
   {
     //v2 = pParty->flt_TorchlightColorB + 6.7553994e15;
     //v11 = LOBYTE(v2);
-    if ( (signed __int64)pParty->pPartyBuffs[16].uExpireTime <= 0 )
-      v5 = 800;
-    else
-      v5 = 800 * pParty->pPartyBuffs[16].uPower;
+    v5 = 800;
+    if (pParty->TorchlightActive())
+      v5 *= pParty->pPartyBuffs[16].uPower;
     //LOBYTE(v1) = byte_4E94D0;
     //v4 = pParty->flt_TorchlightColorR + 6.7553994e15;
     //v3 = pParty->flt_TorchlightColorG + 6.7553994e15;
@@ -310,7 +309,7 @@
   signed int v6; // [sp+8h] [bp-8h]@7
   int v7; // [sp+Ch] [bp-4h]@8
 
-  sub_43F39E(_this);
+  PrepareDrawLists_BLV(_this);
   if (pBLVRenderParams->uPartySectorID)
     IndoorLocation::ExecDraw(pRenderer->pRenderD3D != 0);
   pRenderer->DrawBillboardList_BLV();
@@ -325,7 +324,7 @@
       if ( (signed int)pStru170->std__vector_000FA8 > 0 )
       {
         v7 = 0;
-        v2 = (char *)&pStru170->field_FA8[0].field_C.field_4;
+        v2 = (char *)&pStru170->field_FA8[0].field_C._viewport_space_w;
         do
         {
           v3 = *((int *)v2 - 1);
@@ -873,7 +872,7 @@
                 v23 = 640 * stru_F8A590._viewport_space_y;
                 v119 = 640 * stru_F8A590._viewport_space_y;
                 v100 = v22;
-                if ( stru_F8A590._viewport_space_y <= stru_F8A590.field_4 )
+                if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w )
                 {
                   v24 = 2 * stru_F8A590._viewport_space_y;
                   v120 = 2 * stru_F8A590._viewport_space_y;
@@ -1197,7 +1196,7 @@
                     v24 += 2;
                     v120 = v24;
                     v119 = v23;
-                    if ( a2 > stru_F8A590.field_4 )
+                    if ( a2 > stru_F8A590._viewport_space_w )
                       break;
                     v21 = a2;
                   }
@@ -1646,7 +1645,7 @@
           {
             v4 = stru_F8A590._viewport_space_y;
             v5 = pBLVRenderParams->pRenderTarget;
-            if ( stru_F8A590._viewport_space_y <= stru_F8A590.field_4 )
+            if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w )
             {
               v6 = 640 * stru_F8A590._viewport_space_y;
               do
@@ -1657,7 +1656,7 @@
                 v5[v7] = -1;
                 ++v4;
               }
-              while ( v4 <= stru_F8A590.field_4 );
+              while ( v4 <= stru_F8A590._viewport_space_w );
             }
           }
         }
@@ -2027,7 +2026,7 @@
 
   //v5 = 0;
   //v6 = this;
-  pNumSoundDecorations = 0;
+  _6807E0_num_decorations_with_sounds_6807B8 = 0;
 
   #pragma region "loading from txt"
   /*sprintf(FileName, "levels\\%s", pFilename);
@@ -4611,10 +4610,10 @@
     pDecorationList->InitializeDecorationSprite(pDecortaion->uDecorationDescID);
 
     v15 = pDecorationList->pDecorations[pDecortaion->uDecorationDescID].uSoundID;
-    if (v15 && pNumSoundDecorations < 9)
+    if (v15 && _6807E0_num_decorations_with_sounds_6807B8 < 9)
     {
         pSoundList->_4A9A67(v15, 0);
-        v16 = pNumSoundDecorations++;
+        v16 = _6807E0_num_decorations_with_sounds_6807B8++;
         _6807B8_level_decorations_ids[v16] = i;
     }
 
--- a/Indoor_stuff.h	Fri Nov 02 14:45:06 2012 +0200
+++ b/Indoor_stuff.h	Sun Nov 04 03:58:34 2012 +0200
@@ -8,10 +8,10 @@
 #pragma pack(push, 1)
 struct stru170_stru2
 {
-  __int16 *_43F9E1(__int16 x, int y, __int16 z, int w);
+  void _43F9E1(__int16 x, int y, __int16 z, int w);
 
   int _viewport_space_y;
-  int field_4;
+  int _viewport_space_w;
   int field_8;
   int field_C;
   int field_10;
--- a/LightmapBuilder.cpp	Fri Nov 02 14:45:06 2012 +0200
+++ b/LightmapBuilder.cpp	Sun Nov 04 03:58:34 2012 +0200
@@ -264,7 +264,6 @@
     }
   }
 
-  __debugbreak(); // foil
   if (!pGame->pStru9Instance->_4980B9(a9, uNumVertices,
                                       a7->field_4.x, a7->field_4.y, a7->field_4.z,
                                       v11->pVertices, &v11->uNumVertices))
--- a/Outdoor.cpp	Fri Nov 02 14:45:06 2012 +0200
+++ b/Outdoor.cpp	Sun Nov 04 03:58:34 2012 +0200
@@ -1,3 +1,5 @@
+#include <assert.h>
+
 #include "Outdoor.h"
 #include "Party.h"
 #include "LayingItem.h"
@@ -1092,7 +1094,7 @@
   v1->pOMAP = (unsigned int *)v4;
   memset(v4, 0, 0x10000u);
   v5 = v1->pFaceIDLIST;
-  v1->field_DC = 0;
+  v1->numFaceIDListElems = 0;
   pAllocator->FreeChunk(v5);
   v1->pFaceIDLIST = 0;
   v6 = pAllocator->AllocNamedChunk(0, 2u, "IDLIST");
@@ -1173,8 +1175,8 @@
 //----- (0047D0A6) --------------------------------------------------------
 bool OutdoorLocation::Load(char *pFilename, ODMFace *File, size_t pNumItems, int thisa)
 {
-  OutdoorLocation *pOutdoorLocation; // esi@1
-  bool result; // eax@9
+  //OutdoorLocation *pOutdoorLocation; // esi@1
+  /*bool result; // eax@9
   bool v7; // ebx@9
   size_t v8; // eax@10
   void *v9; // eax@10
@@ -1193,8 +1195,8 @@
   ODMFace *v22; // ebx@26
   LayingItem *pItems; // ecx@27
   unsigned int v24; // eax@28
-  unsigned __int8 v25; // zf@28
-  unsigned __int8 v26; // sf@28
+  //unsigned __int8 v25; // zf@28
+  //unsigned __int8 v26; // sf@28
   ODMFace *v27; // eax@28
   const char *i; // edx@29
   unsigned __int16 v29; // ax@33
@@ -1205,81 +1207,81 @@
   TileDesc *v34; // eax@43
   unsigned int v35; // eax@43
   unsigned int v36; // edi@43
-  unsigned int v37; // edi@45
-  size_t v38; // eax@50
+  unsigned int v37; // edi@45*/
+  //size_t v38; // eax@50
   FILE *v39; // eax@50
-  unsigned int v40; // edi@56
-  void *v41; // eax@56
-  void *v42; // ebx@56
-  const void *v43; // ebx@59
-  const void *v44; // ebx@59
-  unsigned int v45; // eax@59
-  BSPModel *v46; // eax@59
-  unsigned int v47; // ecx@59
-  int v48; // ebx@60
-  BSPModel *v49; // eax@61
-  BSPModel *v50; // eax@61
-  BSPModel *v51; // eax@61
-  BSPModel *v52; // eax@61
-  BSPModel *v53; // eax@61
-  BSPModel *v54; // ecx@61
-  BSPModel *v55; // ecx@61
-  BSPModel *v56; // ecx@61
-  void *v57; // ST24_4@61
-  BSPModel *v58; // ecx@61
-  void *v59; // ST18_4@61
-  BSPModel *v60; // eax@61
-  __int16 v61; // ax@64
+  //unsigned int v40; // edi@56
+  //void *v41; // eax@56
+  //void *v42; // ebx@56
+  //const void *v43; // ebx@59
+  //const void *v44; // ebx@59
+  //unsigned int v45; // eax@59
+  //BSPModel *v46; // eax@59
+  //unsigned int v47; // ecx@59
+  //int v48; // ebx@60
+  //BSPModel *v49; // eax@61
+  //BSPModel *v50; // eax@61
+  //BSPModel *v51; // eax@61
+  //BSPModel *v52; // eax@61
+  //BSPModel *v53; // eax@61
+  //BSPModel *v54; // ecx@61
+  //BSPModel *v55; // ecx@61
+  //BSPModel *v56; // ecx@61
+  //void *v57; // ST24_4@61
+  //BSPModel *v58; // ecx@61
+  //void *v59; // ST18_4@61
+  //BSPModel *v60; // eax@61
+  //__int16 v61; // ax@64
   unsigned __int16 v62; // ax@65
-  ODMFace *v63; // ecx@65
-  unsigned __int16 v64; // ax@80
-  const char *v65; // ecx@80
-  int v66; // eax@81
-  void *v67; // eax@81
-  int v68; // ecx@81
-  void *v69; // eax@81
-  unsigned int v70; // eax@81
-  SpawnPointMM7 *v71; // eax@81
-  unsigned int v72; // ecx@81
-  size_t v73; // eax@81
-  int v74; // edi@87
-  void *v75; // edi@88
-  unsigned int v76; // edx@94
-  int v77; // ecx@94
-  char *v78; // eax@95
-  unsigned int v79; // edx@97
-  unsigned int v80; // eax@99
-  int v81; // eax@107
-  void *v82; // edi@114
-  size_t v83; // eax@120
-  const void *v84; // edi@120
-  const void *v85; // edi@120
-  BSPModel *v86; // eax@124
-  unsigned int v87; // eax@124
-  BSPModel *v88; // eax@126
-  BSPModel *v89; // eax@127
-  ODMFace *v90; // eax@129
-  const void *v91; // edi@138
-  const void *v92; // edi@141
-  const void *v93; // edi@141
-  const void *v94; // edi@144
-  const void *v95; // edi@144
-  const char *v96; // edi@147
-  unsigned int v97; // eax@147
-  TileDesc *v98; // eax@147
-  unsigned int v99; // eax@147
-  int v100; // ecx@150
-  unsigned int v101; // eax@157
+  //ODMFace *v63; // ecx@65
+  //unsigned __int16 v64; // ax@80
+  //const char *v65; // ecx@80
+  //int v66; // eax@81
+  //void *v67; // eax@81
+  //int v68; // ecx@81
+  //void *v69; // eax@81
+  //unsigned int v70; // eax@81
+  //SpawnPointMM7 *v71; // eax@81
+  //unsigned int v72; // ecx@81
+  //size_t v73; // eax@81
+  //int v74; // edi@87
+  //void *v75; // edi@88
+  //unsigned int v76; // edx@94
+  //int v77; // ecx@94
+  //char *v78; // eax@95
+  //unsigned int v79; // edx@97
+  //unsigned int v80; // eax@99
+  //int v81; // eax@107
+  //void *v82; // edi@114
+  //size_t v83; // eax@120
+  //const void *v84; // edi@120
+  //const void *v85; // edi@120
+  //BSPModel *v86; // eax@124
+  //unsigned int v87; // eax@124
+  //BSPModel *v88; // eax@126
+  //BSPModel *v89; // eax@127
+  //ODMFace *v90; // eax@129
+  //const void *v91; // edi@138
+  //const void *v92; // edi@141
+  //const void *v93; // edi@141
+  //const void *v94; // edi@144
+  //const void *v95; // edi@144
+  //const char *v96; // edi@147
+  //unsigned int v97; // eax@147
+  //TileDesc *v98; // eax@147
+  //unsigned int v99; // eax@147
+  //int v100; // ecx@150
+  //unsigned int v101; // eax@157
   int v102; // edi@159
-  void *v103; // [sp-14h] [bp-B94h]@55
-  void *v104; // [sp-10h] [bp-B90h]@59
-  size_t v105; // [sp-Ch] [bp-B8Ch]@59
-  char *v106; // [sp-8h] [bp-B88h]@59
+  //void *v103; // [sp-14h] [bp-B94h]@55
+  //void *v104; // [sp-10h] [bp-B90h]@59
+  //size_t v105; // [sp-Ch] [bp-B8Ch]@59
+  //char *v106; // [sp-8h] [bp-B88h]@59
   int v107; // [sp-4h] [bp-B84h]@12
   int v108; // [sp+0h] [bp-B80h]@10
   char Src[968]; // [sp+10h] [bp-B70h]@110
   char Dst[968]; // [sp+3D8h] [bp-7A8h]@50
-  char Str[256]; // [sp+7A0h] [bp-3E0h]@50
+  /*char Str[256]; // [sp+7A0h] [bp-3E0h]@50
   char DstBuf; // [sp+8A0h] [bp-2E0h]@10
   __int32 Offset; // [sp+8A4h] [bp-2DCh]@10
   __int32 v114; // [sp+8B0h] [bp-2D0h]@10
@@ -1304,53 +1306,54 @@
   __int32 v133; // [sp+994h] [bp-1ECh]@38
   __int32 v134; // [sp+9A0h] [bp-1E0h]@38
   __int32 v135; // [sp+9ACh] [bp-1D4h]@38
-  __int32 v136; // [sp+9D0h] [bp-1B0h]@10
-  char FileName[8]; // [sp+A20h] [bp-160h]@8
-  char v138; // [sp+A28h] [bp-158h]@12
-  int v139; // [sp+B1Ch] [bp-64h]@10
-  char pContainer[32]; // [sp+B20h] [bp-60h]@1
-  int *v141; // [sp+B40h] [bp-40h]@50
-  __int64 v142; // [sp+B44h] [bp-3Ch]@55
-  size_t pSource; // [sp+B4Ch] [bp-34h]@56
-  int v144; // [sp+B50h] [bp-30h]@61
-  int v145; // [sp+B54h] [bp-2Ch]@68
+  __int32 v136; // [sp+9D0h] [bp-1B0h]@10*/
+  //char FileName[8]; // [sp+A20h] [bp-160h]@8
+  //char v138; // [sp+A28h] [bp-158h]@12
+  //int v139; // [sp+B1Ch] [bp-64h]@10
+  //char pContainer[32]; // [sp+B20h] [bp-60h]@1
+  //int *v141; // [sp+B40h] [bp-40h]@50
+  //__int64 v142; // [sp+B44h] [bp-3Ch]@55
+  //size_t pSource; // [sp+B4Ch] [bp-34h]@56
+  //int v144; // [sp+B50h] [bp-30h]@61
+  //int v145; // [sp+B54h] [bp-2Ch]@68
   ODMHeader header; // [sp+B58h] [bp-28h]@50
-  unsigned int pDestLen; // [sp+B68h] [bp-18h]@13
-  FILE *ptr; // [sp+B6Ch] [bp-14h]@12
-  void *v149; // [sp+B70h] [bp-10h]@19
+  //unsigned int pDestLen; // [sp+B68h] [bp-18h]@13
+  //FILE *ptr; // [sp+B6Ch] [bp-14h]@12
+  //void *v149; // [sp+B70h] [bp-10h]@19
   char *Str2; // [sp+B74h] [bp-Ch]@12
-  int v151; // [sp+B78h] [bp-8h]@59
-  void *uSourceLen; // [sp+B7Ch] [bp-4h]@59
+  //int v151; // [sp+B78h] [bp-8h]@59
+  //void *uSourceLen; // [sp+B7Ch] [bp-4h]@59
 
-  pOutdoorLocation = this;
-  strcpy(pContainer, pFilename);
-  if ( bUnderwater )
+  //pOutdoorLocation = this;
+  //strcpy(pContainer, pFilename);
+
+  if (bUnderwater)
   {
-    pPaletteManager->pPalette_tintColor[0] = 0x10u;
-    pPaletteManager->pPalette_tintColor[1] = 0xC2u;
-    pPaletteManager->pPalette_tintColor[2] = 0x99u;
-    pPaletteManager->pPalette_mistColor[0] = 0x25u;
-    pPaletteManager->pPalette_mistColor[1] = 0x8Fu;
-    pPaletteManager->pPalette_mistColor[2] = 0x5Cu;
-LABEL_7:
-    pPaletteManager->RecalculateAll();
-    goto LABEL_8;
+    pPaletteManager->pPalette_tintColor[0] = 0x10;
+    pPaletteManager->pPalette_tintColor[1] = 0xC2;
+    pPaletteManager->pPalette_tintColor[2] = 0x99;
+    pPaletteManager->pPalette_mistColor[0] = 0x25;
+    pPaletteManager->pPalette_mistColor[1] = 0x8F;
+    pPaletteManager->pPalette_mistColor[2] = 0x5C;
   }
-  pPaletteManager->pPalette_tintColor[0] = 0;
-  pPaletteManager->pPalette_tintColor[1] = 0;
-  pPaletteManager->pPalette_tintColor[2] = 0;
-  if ( pPaletteManager->pPalette_mistColor[0] != 0x80u
-    || pPaletteManager->pPalette_mistColor[1] != 0x80u
-    || pPaletteManager->pPalette_mistColor[2] != 0x80u )
+  else
   {
-    pPaletteManager->pPalette_mistColor[0] = 0x80u;
-    pPaletteManager->pPalette_mistColor[1] = 0x80u;
-    pPaletteManager->pPalette_mistColor[2] = 0x80u;
-    goto LABEL_7;
+    pPaletteManager->pPalette_tintColor[0] = 0;
+    pPaletteManager->pPalette_tintColor[1] = 0;
+    pPaletteManager->pPalette_tintColor[2] = 0;
+    if (pPaletteManager->pPalette_mistColor[0] != 0x80 ||
+        pPaletteManager->pPalette_mistColor[1] != 0x80 ||
+        pPaletteManager->pPalette_mistColor[2] != 0x80)
+    {
+      pPaletteManager->pPalette_mistColor[0] = 0x80;
+      pPaletteManager->pPalette_mistColor[1] = 0x80;
+      pPaletteManager->pPalette_mistColor[2] = 0x80;
+      pPaletteManager->RecalculateAll();
+    }
   }
-LABEL_8:
-  pNumSoundDecorations = 0;
-  sprintf(FileName, "levels\\%s", pContainer);
+
+  _6807E0_num_decorations_with_sounds_6807B8 = 0;
+  /*sprintf(FileName, "levels\\%s", pContainer);
   if ( GetFileAttributesA(FileName) != -1 )
   {
     result = (bool)fopen(FileName, "rb");
@@ -1365,12 +1368,12 @@
     viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(pContainer, (enum TEXTURE_TYPE)v108);
     fread(&DstBuf, 0x180u, 1u, (FILE *)v7);
     fseek((FILE *)v7, Offset, 0);
-    fread(pOutdoorLocation, 0xB0u, 1u, (FILE *)v7);
-    pOutdoorLocation->LoadTileGroupIds();
-    pOutdoorLocation->_47F3EA();
-    strcpy(pOutdoorLocation->pGroundTileset, "grastyl");
+    fread(this, 0xB0u, 1u, (FILE *)v7);
+    LoadTileGroupIds();
+    _47F3EA();
+    strcpy(pGroundTileset, "grastyl");
     fseek((FILE *)v7, v114, 0);
-    fread(&pOutdoorLocation->uNumBModels, 4u, 1u, (FILE *)v7);
+    fread(&uNumBModels, 4u, 1u, (FILE *)v7);
     fseek((FILE *)v7, v115, 0);
     fread(&uNumLayingItems, 4u, 1u, (FILE *)v7);
     fseek((FILE *)v7, v116, 0);
@@ -1379,71 +1382,71 @@
     fread(&uNumActors, 4u, 1u, (FILE *)v7);
     fseek((FILE *)v7, v118, 0);
     fread(&uNumChests, 4u, 1u, (FILE *)v7);
-    pOutdoorLocation->pTerrain.Initialize();
+    pTerrain.Initialize();
     fseek((FILE *)v7, v119, 0);
-    fread(pOutdoorLocation->pTerrain.pHeightmap, 1u, 0x4000u, (FILE *)v7);
+    fread(pTerrain.pHeightmap, 1u, 0x4000u, (FILE *)v7);
     fseek((FILE *)v7, v120, 0);
-    fread(pOutdoorLocation->pTerrain.pTilemap, 1u, 0x4000u, (FILE *)v7);
+    fread(pTerrain.pTilemap, 1u, 0x4000u, (FILE *)v7);
     fseek((FILE *)v7, v121, 0);
-    fread(pOutdoorLocation->pTerrain.pAttributemap, 1u, 0x4000u, (FILE *)v7);
-    pOutdoorLocation->pTerrain._47C80A(0, 0, 128, 128);
-    pAllocator->FreeChunk(pOutdoorLocation->ptr_D4);
-    pOutdoorLocation->ptr_D4 = 0;
+    fread(pTerrain.pAttributemap, 1u, 0x4000u, (FILE *)v7);
+    pTerrain._47C80A(0, 0, 128, 128);
+    pAllocator->FreeChunk(ptr_D4);
+    ptr_D4 = 0;
     v9 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP");
-    v108 = (int)pOutdoorLocation->pOMAP;
-    pOutdoorLocation->ptr_D4 = v9;
+    v108 = (int)pOMAP;
+    ptr_D4 = v9;
     pAllocator->FreeChunk((void *)v108);
-    pOutdoorLocation->pOMAP = 0;
+    pOMAP = 0;
     v10 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP");
     v108 = 0;
-    pOutdoorLocation->pOMAP = (unsigned int *)v10;
+    pOMAP = (unsigned int *)v10;
     fseek((FILE *)v7, v136, v108);
     fread(&uNumTerrainNormals, 4u, 1u, (FILE *)v7);
     fread(pTerrainSomeOtherData, 1u, 0x20000u, (FILE *)v7);
     fread(pTerrainNormalIndices, 1u, 0x10000u, (FILE *)v7);
     pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm");
     fread(pTerrainNormals, 1u, 12 * uNumTerrainNormals, (FILE *)v7);
-    v11 = pAllocator->AllocNamedChunk(pOutdoorLocation->pBModels, 188 * pOutdoorLocation->uNumBModels, "BDdata");
+    v11 = pAllocator->AllocNamedChunk(pBModels, 188 * uNumBModels, "BDdata");
     v108 = 0;
-    pOutdoorLocation->pBModels = (BSPModel *)v11;
+    pBModels = (BSPModel *)v11;
     fseek((FILE *)v7, v122, v108);
-    fread(pOutdoorLocation->pBModels, 0xBCu, pOutdoorLocation->uNumBModels, (FILE *)v7);
+    fread(pBModels, 0xBCu, uNumBModels, (FILE *)v7);
     fseek((FILE *)v7, v123, 0);
     pNumItems = 0;
-    if ( (signed int)pOutdoorLocation->uNumBModels > 0 )
+    if ( (signed int)uNumBModels > 0 )
     {
       v12 = 0;
       while ( 1 )
       {
-        pOutdoorLocation->pBModels[v12].pVertices.pVertices = 0;
-        pOutdoorLocation->pBModels[v12].pFaces = 0;
-        pOutdoorLocation->pBModels[v12].pFacesOrdering = 0;
-        pOutdoorLocation->pBModels[v12].pNodes = 0;
+        pBModels[v12].pVertices.pVertices = 0;
+        pBModels[v12].pFaces = 0;
+        pBModels[v12].pFacesOrdering = 0;
+        pBModels[v12].pNodes = 0;
         FileName[0] = 0;
-        v108 = (int)&pOutdoorLocation->pBModels[v12];
+        v108 = (int)&pBModels[v12];
         sprintfex(FileName, "%s", v108);
-        v13 = pOutdoorLocation->pBModels;
+        v13 = pBModels;
         v138 = 0;
-        pOutdoorLocation->pBModels[v12].pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(v13[v12].pVertices.pVertices, 12 * v13[v12].pVertices.uNumVertices,
+        pBModels[v12].pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(v13[v12].pVertices.pVertices, 12 * v13[v12].pVertices.uNumVertices,
                                                                FileName);
-        pOutdoorLocation->pBModels[v12].pFaces = (ODMFace *)pAllocator->AllocNamedChunk(pOutdoorLocation->pBModels[v12].pFaces, 308 * pOutdoorLocation->pBModels[v12].uNumFaces,
+        pBModels[v12].pFaces = (ODMFace *)pAllocator->AllocNamedChunk(pBModels[v12].pFaces, 308 * pBModels[v12].uNumFaces,
                                                 FileName);
-        pOutdoorLocation->pBModels[v12].pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(pOutdoorLocation->pBModels[v12].pFacesOrdering,
-                                                                 2 * pOutdoorLocation->pBModels[v12].uNumFaces, FileName);
-        v14 = pAllocator->AllocNamedChunk(pOutdoorLocation->pBModels[v12].pNodes, 8 * pOutdoorLocation->pBModels[v12].uNumNodes, FileName);
-        v15 = pOutdoorLocation->pBModels;
+        pBModels[v12].pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(pBModels[v12].pFacesOrdering,
+                                                                 2 * pBModels[v12].uNumFaces, FileName);
+        v14 = pAllocator->AllocNamedChunk(pBModels[v12].pNodes, 8 * pBModels[v12].uNumNodes, FileName);
+        v15 = pBModels;
         v108 = (int)File;
         v15[v12].pNodes = (BSPNode *)v14;
-        fread(pOutdoorLocation->pBModels[v12].pVertices.pVertices, 0xCu, pOutdoorLocation->pBModels[v12].pVertices.uNumVertices, (FILE *)v108);
-        fread(pOutdoorLocation->pBModels[v12].pFaces, 0x134u, pOutdoorLocation->pBModels[v12].uNumFaces, (FILE *)File);
-        fread(pOutdoorLocation->pBModels[v12].pFacesOrdering, 2u, pOutdoorLocation->pBModels[v12].uNumFaces, (FILE *)File);
-        fread(pOutdoorLocation->pBModels[v12].pNodes, 8u, pOutdoorLocation->pBModels[v12].uNumNodes, (FILE *)File);
-        v16 = malloc(10 * pOutdoorLocation->pBModels[v12].uNumFaces);
+        fread(pBModels[v12].pVertices.pVertices, 0xCu, pBModels[v12].pVertices.uNumVertices, (FILE *)v108);
+        fread(pBModels[v12].pFaces, 0x134u, pBModels[v12].uNumFaces, (FILE *)File);
+        fread(pBModels[v12].pFacesOrdering, 2u, pBModels[v12].uNumFaces, (FILE *)File);
+        fread(pBModels[v12].pNodes, 8u, pBModels[v12].uNumNodes, (FILE *)File);
+        v16 = malloc(10 * pBModels[v12].uNumFaces);
         v107 = (int)File;
-        v17 = pOutdoorLocation->pBModels;
+        v17 = pBModels;
         ptr = (FILE *)v16;
         fread(v16, 0xAu, v17[v12].uNumFaces, (FILE *)File);
-        v18 = pOutdoorLocation->pBModels;
+        v18 = pBModels;
         Str2 = 0;
         if ( (signed int)v18[v12].uNumFaces > 0 )
           break;
@@ -1451,7 +1454,7 @@
         free(ptr);
         ++pNumItems;
         ++v12;
-        if ( (signed int)pNumItems >= (signed int)pOutdoorLocation->uNumBModels )
+        if ( (signed int)pNumItems >= (signed int)uNumBModels )
           goto LABEL_26;
       }
       pDestLen = 0;
@@ -1476,7 +1479,7 @@
             pTex->palette_id2 = pPaletteManager->LoadPalette(pTex->palette_id1);
           goto LABEL_20;
         }
-        pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(unsigned __int16 *)((char *)&pOutdoorLocation->pBModels[v12].pFaces->uTextureID + pDestLen));
+        pTextureFrameTable->LoadAnimationSequenceAndPalettes(*(unsigned __int16 *)((char *)&pBModels[v12].pFaces->uTextureID + pDestLen));
 LABEL_20:
         if ( *(short *)(thisa + 292) )
         {
@@ -1486,7 +1489,7 @@
             *(char *)(thisa + 30) &= 0xEFu;
         }
         ++Str2;
-        v18 = pOutdoorLocation->pBModels;
+        v18 = pBModels;
         pDestLen += 308;
         pFilename += 10;
         if ( (signed int)Str2 >= (signed int)v18[v12].uNumFaces )
@@ -1559,425 +1562,507 @@
     fseek((FILE *)v22, v127, 0);
     fread(pChests, 0x14CCu, uNumChests, (FILE *)v22);
     fseek((FILE *)v22, v128, 0);
-    fread(&pOutdoorLocation->field_DC, 4u, 1u, (FILE *)v22);
-    pAllocator->FreeChunk(pOutdoorLocation->pFaceIDLIST);
-    v32 = pOutdoorLocation->field_DC;
-    pOutdoorLocation->pFaceIDLIST = 0;
+    fread(&field_DC, 4u, 1u, (FILE *)v22);
+    pAllocator->FreeChunk(pFaceIDLIST);
+    v32 = field_DC;
+    pFaceIDLIST = 0;
     v33 = pAllocator->AllocNamedChunk(0, 2 * v32, "IDLIST");
     v108 = (int)v22;
-    pOutdoorLocation->pFaceIDLIST = (unsigned __int16 *)v33;
-    fread(v33, 2u, pOutdoorLocation->field_DC, (FILE *)v108);
+    pFaceIDLIST = (unsigned __int16 *)v33;
+    fread(v33, 2u, field_DC, (FILE *)v108);
     fseek((FILE *)v22, v129, 0);
-    fread(pOutdoorLocation->pOMAP, 4u, 0x4000u, (FILE *)v22);
+    fread(pOMAP, 4u, 0x4000u, (FILE *)v22);
     fseek((FILE *)v22, v130, 0);
-    fread(&pOutdoorLocation->uNumSpawnPoints, 4u, 1u, (FILE *)v22);
-    pOutdoorLocation->pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pOutdoorLocation->pSpawnPoints, 24 * pOutdoorLocation->uNumSpawnPoints, "Spawn");
+    fread(&uNumSpawnPoints, 4u, 1u, (FILE *)v22);
+    pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, 24 * uNumSpawnPoints, "Spawn");
     fseek((FILE *)v22, v131, 0);
-    fread(pOutdoorLocation->pSpawnPoints, 0x18u, pOutdoorLocation->uNumSpawnPoints, (FILE *)v22);
+    fread(pSpawnPoints, 0x18u, uNumSpawnPoints, (FILE *)v22);
     fseek((FILE *)v22, v132, 0);
-    fread(&pOutdoorLocation->ddm, 0x28u, 1u, (FILE *)v22);
+    fread(&ddm, 0x28u, 1u, (FILE *)v22);
     fseek((FILE *)v22, v133, 0);
     fread(&stru_5E4C90, 1u, 0xC8u, (FILE *)v22);
     fseek((FILE *)v22, v134, 0);
-    fread(&pOutdoorLocation->uLastVisitDay, 1u, 0x38u, (FILE *)v22);
+    fread(&uLastVisitDay, 1u, 0x38u, (FILE *)v22);
     fseek((FILE *)v22, v135, 0);
-    fread(&pOutdoorLocation->uLastVisitDay, 1u, 4u, (FILE *)v22);
-    thisa = (int)pOutdoorLocation->pTileTypes;
+    fread(&uLastVisitDay, 1u, 4u, (FILE *)v22);
+    thisa = (int)pTileTypes;
     pTileTable->InitializeTileset(4);
-    pTileTable->InitializeTileset(pOutdoorLocation->pTileTypes[0].uTileGroup);
-    pTileTable->InitializeTileset(pOutdoorLocation->pTileTypes[1].uTileGroup);
-    pTileTable->InitializeTileset(pOutdoorLocation->pTileTypes[2].uTileGroup);
-    pTileTable->InitializeTileset(pOutdoorLocation->pTileTypes[3].uTileGroup);
-    if ( pOutdoorLocation != (OutdoorLocation *)-96 && pOutdoorLocation->pSkyTextureName[0] )
+    pTileTable->InitializeTileset(pTileTypes[0].uTileGroup);
+    pTileTable->InitializeTileset(pTileTypes[1].uTileGroup);
+    pTileTable->InitializeTileset(pTileTypes[2].uTileGroup);
+    pTileTable->InitializeTileset(pTileTypes[3].uTileGroup);
+    if ( this != (OutdoorLocation *)-96 && pSkyTextureName[0] )
     {
       v108 = 0;
-      v107 = (int)pOutdoorLocation->pSkyTextureName;
+      v107 = (int)pSkyTextureName;
     }
     else
     {
       v108 = 0;
       v107 = (int)pDefaultSkyTexture;
     }
-    pOutdoorLocation->uSky_TextureID = pBitmaps_LOD->LoadTexture((const char *)v107, (enum TEXTURE_TYPE)v108);
-    strcpy(pOutdoorLocation->pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture);
-    v34 = pTileTable->GetTileById(pOutdoorLocation->pTileTypes[0].uTileID);
+    uSky_TextureID = pBitmaps_LOD->LoadTexture((const char *)v107, (enum TEXTURE_TYPE)v108);
+    strcpy(pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture);
+    v34 = pTileTable->GetTileById(pTileTypes[0].uTileID);
     v35 = pBitmaps_LOD->LoadTexture(v34->pTileName);
-    v36 = pOutdoorLocation->uSky_TextureID;
-    pOutdoorLocation->uMainTile_BitmapID = v35;
+    v36 = uSky_TextureID;
+    uMainTile_BitmapID = v35;
     if ( v36 != -1 )
       pBitmaps_LOD->pTextures[v36].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v36].palette_id1);
 
-    v37 = pOutdoorLocation->uMainTile_BitmapID;
+    v37 = uMainTile_BitmapID;
     if ( v37 != -1 )
       pBitmaps_LOD->pTextures[v37].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v37].palette_id1);
 
-    pOutdoorLocation->_47F0E2();
+    _47F0E2();
     pGameLoadingUI_ProgressBar->Progress();
     fclose((FILE *)v22);
     goto LABEL_150;
-  }
-  if ( !pGames_LOD->DoesContainerExist(pContainer) )
-    Abortf("Unable to find %s in Games.LOD", pContainer);
-  strcpy(FileName, pContainer);
-  strcpy(Str, pContainer);
-  Dst[strlen(Str) + 964] = 0;
+  }*/
+
+  assert(sizeof(BSPModel) == 188);
+
+  if (!pGames_LOD->DoesContainerExist(pFilename))
+    Abortf("Unable to find %s in Games.LOD", pFilename);
+
+  //strcpy(FileName, pContainer);
+  strcpy(Str, pFilename);
+  strcpy(Str + strlen(Str) - 4, ".odm");
   viewparams->uTextureID_LocationMap = pIcons_LOD->LoadTexture(Str, TEXTURE_16BIT_PALETTE);
-  v141 = &v139;
-  v38 = strlen(pContainer);
-  strcpy((char *)&v139 + v38, ".odm");
-  v39 = pGames_LOD->FindContainer(pContainer, 1);
+  //v141 = &v139;
+  //v38 = strlen(pFilename);
+  //strcpy((char *)&v139 + v38, ".odm");
+  v39 = pGames_LOD->FindContainer(Str, 1);
+  //Str[strlen(Str) - 4] = 0;
+
   header.uCompressedSize = 0;
   header.uDecompressedSize = 0;
-  ptr = v39;
+  //ptr = v39;
   header.uVersion = 91969;
   header.pMagic[0] = 'm';
   header.pMagic[1] = 'v';
   header.pMagic[2] = 'i';
   header.pMagic[3] = 'i';
   fread(&header, 0x10u, 1u, v39);
-  if ( header.uVersion != 91969
-    || header.pMagic[0] != 'm'
-    || header.pMagic[1] != 'v'
-    || header.pMagic[2] != 'i'
-    || header.pMagic[3] != 'i' )
+  if (header.uVersion != 91969 ||
+      header.pMagic[0] != 'm' ||
+      header.pMagic[1] != 'v' ||
+      header.pMagic[2] != 'i' ||
+      header.pMagic[3] != 'i')
   {
-          MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:507", 0);
+    MessageBoxW(nullptr, L"Can't load file!",
+                L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:507", 0);
   }
-  v40 = header.uCompressedSize;
-  pSource = header.uDecompressedSize;
-  v41 = malloc(header.uDecompressedSize);
-  v42 = v41;
-  HIDWORD(v142) = (uint32)v41;
-  if ( v40 < pSource )
+  //v40 = header.uCompressedSize;
+  //pSource = header.uDecompressedSize;
+  //v41 = malloc(header.uDecompressedSize);
+  auto pSrcMem = (unsigned char *)malloc(header.uDecompressedSize);
+  auto pSrc = pSrcMem;
+  //v42 = v41;
+  //HIDWORD(v142) = (uint32)pSrc;
+  if (header.uCompressedSize < header.uDecompressedSize)
   {
-    pFilename = (char *)malloc(v40);
-    fread((void *)pFilename, v40, 1u, ptr);
-    zlib::MemUnzip(v42, &pSource, pFilename, v40);
-    free((void *)pFilename);
+    auto pComressedSrc = (char *)malloc(header.uCompressedSize);
+    fread(pComressedSrc, header.uCompressedSize, 1, v39);
+
+    uint actualDecompressedSize = header.uDecompressedSize;
+    zlib::MemUnzip(pSrc, &actualDecompressedSize, pComressedSrc, header.uCompressedSize);
+    free(pComressedSrc);
   }
   else
   {
-    fread(v41, pSource, 1u, ptr);
+    fread(pSrc, header.uDecompressedSize, 1, v39);
   }
-  memcpy(pOutdoorLocation, v42, 0xB0u);
-  v43 = (char *)v42 + 176;
-  pOutdoorLocation->LoadTileGroupIds();
-  pOutdoorLocation->_47F3EA();
-  strcpy(pOutdoorLocation->pGroundTileset, "grastyl");
+
+  memcpy(pLevelFilename, pSrc, 0x20);
+  memcpy(pLocationFileName, pSrc + 0x20, 0x20);
+  memcpy(pLocationFileDescription, pSrc + 0x40, 0x20);
+  memcpy(pSkyTextureName, pSrc + 0x60, 0x20);
+  memcpy(pGroundTileset, pSrc + 0x80, 0x20);
+  memcpy(pTileTypes, pSrc + 0xA0, 0x10);
+  pSrc += 0xB0;
+
+  //v43 = (char *)pSrc + 176;
+  LoadTileGroupIds();
+  _47F3EA();
+  strcpy(pGroundTileset, "grastyl");
   pGameLoadingUI_ProgressBar->Progress();
-  pOutdoorLocation->pTerrain.Initialize();
-  v108 = 16384;
-  v107 = (int)v43;
-  v106 = (char *)pOutdoorLocation->pTerrain.pHeightmap;
-  memcpy(v106, v43, 0x4000u);
-  v43 = (char *)v43 + 16384;
-  v105 = 16384;
-  v104 = (void *)v43;
-  v103 = pOutdoorLocation->pTerrain.pTilemap;
-  memcpy(v103, v43, 0x4000u);
-  v43 = (char *)v43 + 16384;
-  memcpy(pOutdoorLocation->pTerrain.pAttributemap, v43, 0x4000u);
-  v43 = (char *)v43 + 16384;
-  v108 = (int)pOutdoorLocation->ptr_D4;
-  pAllocator->FreeChunk((void *)v108);
-  pOutdoorLocation->ptr_D4 = 0;
-  pOutdoorLocation->ptr_D4 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP");
-  pOutdoorLocation->pTerrain._47C80A(0, 0, 128, 128);
+  pTerrain.Initialize();
+  //v108 = 16384;
+  //v107 = (int)v43;
+  //v106 = (char *)pTerrain.pHeightmap;
+  memcpy(pTerrain.pHeightmap, pSrc, 0x4000);
+  pSrc += 0x4000;
+
+  //v43 = (char *)v43 + 16384;
+  //v105 = 16384;
+  //v104 = (void *)v43;
+  //v103 = pTerrain.pTilemap;
+  memcpy(pTerrain.pTilemap, pSrc, 0x4000);
+  pSrc += 0x4000;
+
+  //v43 = (char *)v43 + 16384;
+  memcpy(pTerrain.pAttributemap, pSrc, 0x4000);
+  pSrc += 0x4000;
+
+  //v43 = (char *)v43 + 16384;
+  //v108 = (int)ptr_D4;
+  if (ptr_D4)
+  {
+    pAllocator->FreeChunk(ptr_D4);
+    ptr_D4 = nullptr;
+  }
+  ptr_D4 = pAllocator->AllocNamedChunk(0, 0x8000u, "CMAP");
+  pTerrain._47C80A(0, 0, 128, 128);
+
+  pGameLoadingUI_ProgressBar->Progress();
+  memcpy(&uNumTerrainNormals, pSrc, 4);
+  //v43 = (char *)v43 + 4;
+  memcpy(pTerrainSomeOtherData, pSrc + 4, 0x20000);
+  pSrc += 4 + 0x20000;
+  //v43 = (char *)v43 + 131072;
+  memcpy(pTerrainNormalIndices, pSrc, 0x10000);
+  pSrc += 0x10000;
+  //v43 = (char *)v43 + 65536;
+
+  //pFilename = (char *)(12 * uNumTerrainNormals);
+  pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm");
+  memcpy(pTerrainNormals, pSrc, 12 * uNumTerrainNormals);
+  pSrc += 12 * uNumTerrainNormals;
+  //v44 = (char *)v43 + (int)pFilename;
+  //v44 = (char *)v44 + 4;
+  //v45 = uNumBModels;
+  //v108 = (int)"BDdata";
+
+  pGameLoadingUI_ProgressBar->Progress();
+
+  //v107 = 188 * v45;
+  //v106 = (char *)pBModels;
+  //v46 = (BSPModel *)pAllocator->AllocNamedChunk(v106, 188 * v45, "BDdata");
+  //v47 = uNumBModels;
+  memcpy(&uNumBModels, pSrc, 4);
+  pBModels = (BSPModel *)pAllocator->AllocNamedChunk(pBModels, 188 * uNumBModels, "BDdata");
+  //pFilename = (char *)(188 * v47);
+  memcpy(pBModels, pSrc + 4, 188 * uNumBModels);
+  pSrc += 4 + 188 * uNumBModels;
+  
   pGameLoadingUI_ProgressBar->Progress();
-  memcpy(&uNumTerrainNormals, v43, 4u);
-  v43 = (char *)v43 + 4;
-  memcpy(pTerrainSomeOtherData, v43, 0x20000u);
-  v43 = (char *)v43 + 131072;
-  memcpy(pTerrainNormalIndices, v43, 0x10000u);
-  v43 = (char *)v43 + 65536;
-  pFilename = (char *)(12 * uNumTerrainNormals);
-  pTerrainNormals = (Vec3_float_ *)pAllocator->AllocNamedChunk(pTerrainNormals, 12 * uNumTerrainNormals, "TerNorm");
-  memcpy(pTerrainNormals, v43, (size_t)pFilename);
-  v44 = (char *)v43 + (int)pFilename;
-  memcpy(&pOutdoorLocation->uNumBModels, v44, 4u);
-  v44 = (char *)v44 + 4;
-  pGameLoadingUI_ProgressBar->Progress();
-  v45 = pOutdoorLocation->uNumBModels;
-  v108 = (int)"BDdata";
-  v107 = 188 * v45;
-  v106 = (char *)pOutdoorLocation->pBModels;
-  v46 = (BSPModel *)pAllocator->AllocNamedChunk(v106, 188 * v45, "BDdata");
-  v47 = pOutdoorLocation->uNumBModels;
-  pOutdoorLocation->pBModels = v46;
-  pFilename = (char *)(188 * v47);
-  memcpy(v46, v44, 188 * v47);
-  uSourceLen = (char *)v44 + (int)pFilename;
-  pGameLoadingUI_ProgressBar->Progress();
-  v151 = 0;
-  if ( (signed int)pOutdoorLocation->uNumBModels > 0 )
+
+  //uSourceLen = (char *)v44 + (int)pFilename;
+  //v151 = 0;
+  for (uint i = 0; i < uNumBModels; ++i)
   {
-    v48 = 0;
-    while ( 1 )
+    //v48 = 0;
+    auto model = pBModels + i;
+
+    model->pVertices.pVertices = nullptr;
+    model->pFaces = nullptr;
+    model->pFacesOrdering = nullptr;
+    model->pNodes = nullptr;
+      //FileName[0] = 0;
+      //v108 = (int)&pBModels[i];
+      //sprintf(FileName, "%s", v108);
+      //v49 = pBModels;
+      //v138 = 0;
+      //v50 = &pBModels[v48];
+      //v108 = (int)FileName;
+      //v107 = 12 * v50->pVertices.uNumVertices;
+      //v106 = (char *)v50->pVertices.pVertices;
+    assert(sizeof(Vec3_int_) == 12);
+    uint verticesSize = model->pVertices.uNumVertices * sizeof(Vec3_int_);
+    model->pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(model->pVertices.pVertices, verticesSize, "");
+    memcpy(model->pVertices.pVertices, pSrc, verticesSize);
+    pSrc += verticesSize;
+      //v51 = &pBModels[v48];
+      //v108 = (int)FileName;
+      //v107 = 308 * v51->uNumFaces;
+      //v106 = (char *)v51->pFaces;
+    assert(sizeof(ODMFace) == 308);
+    uint facesSize = model->uNumFaces * sizeof(ODMFace);
+    model->pFaces = (ODMFace *)pAllocator->AllocNamedChunk(model->pFaces, facesSize, "");
+    memcpy(model->pFaces, pSrc, facesSize);
+    pSrc += facesSize;
+      //v52 = &pBModels[v48];
+      //v108 = (int)FileName;
+      //v107 = 2 * v52->uNumFaces;
+      //v106 = (char *)v52->pFacesOrdering;
+    uint facesOrderingSize = model->uNumFaces * sizeof(short);
+    model->pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(model->pFacesOrdering, facesOrderingSize, "");
+    memcpy(model->pFacesOrdering, pSrc, facesOrderingSize);
+    pSrc += facesOrderingSize;
+      //v53 = &pBModels[v48];
+      //v108 = (int)FileName;
+      //v107 = 8 * v53->uNumNodes;
+      //v106 = (char *)v53->pNodes;
+    assert(sizeof(BSPNode) == 8);
+    uint nodesSize = model->uNumNodes * sizeof(BSPNode);
+    model->pNodes = (BSPNode *)pAllocator->AllocNamedChunk(model->pNodes, nodesSize, "");
+    memcpy(model->pNodes, pSrc, nodesSize);
+    pSrc += nodesSize;
+      //v54 = &pBModels[v48];
+      //v108 = 12 * v54->pVertices.uNumVertices;
+      //pFilename = (char *)v108;
+      //v107 = (int)uSourceLen;
+      //v106 = (char *)v54->pVertices.pVertices;
+      //memcpy(v106, uSourceLen, v108);
+      //uSourceLen = (char *)uSourceLen + (int)pFilename;
+      //v55 = &pBModels[v48];
+      //v105 = 308 * v55->uNumFaces;
+      //v104 = uSourceLen;
+      //v103 = v55->pFaces;
+      //pFilename = (char *)v105;
+      //memcpy(v103, uSourceLen, v105);
+      //v56 = &pBModels[v48];
+      //uSourceLen = (char *)uSourceLen + (int)pFilename;
+      //v57 = v56->pFacesOrdering;
+      //pFilename = (char *)(2 * v56->uNumFaces);
+      //memcpy(v57, uSourceLen, (size_t)pFilename);
+      //v58 = &pBModels[v48];
+      //uSourceLen = (char *)uSourceLen + (int)pFilename;
+      //v59 = v58->pNodes;
+      //pFilename = (char *)(8 * v58->uNumNodes);
+      //memcpy(v59, uSourceLen, (size_t)pFilename);
+      //uSourceLen = (char *)uSourceLen + (int)pFilename;
+    //ptr = (FILE *)malloc(10 * model->uNumFaces);
+    auto textureFilenames = (const char *)malloc(10 * model->uNumFaces);
+      //pFilename = (char *)(10 * pBModels[v48].uNumFaces);
+    memcpy((char *)textureFilenames, pSrc, 10 * model->uNumFaces);
+    pSrc += 10 * model->uNumFaces;
+      //v144 = 0;
+      //uSourceLen = (char *)uSourceLen + (int)pFilename;
+      //v60 = pBModels;
+    for (uint j = 0; j < model->uNumFaces; ++j)
     {
-      pOutdoorLocation->pBModels[v48].pVertices.pVertices = 0;
-      pOutdoorLocation->pBModels[v48].pFaces = 0;
-      pOutdoorLocation->pBModels[v48].pFacesOrdering = 0;
-      pOutdoorLocation->pBModels[v48].pNodes = 0;
-      FileName[0] = 0;
-      v108 = (int)&pOutdoorLocation->pBModels[v48];
-      sprintf(FileName, "%s", v108);
-      v49 = pOutdoorLocation->pBModels;
-      v138 = 0;
-      v50 = &v49[v48];
-      v108 = (int)FileName;
-      v107 = 12 * v50->pVertices.uNumVertices;
-      v106 = (char *)v50->pVertices.pVertices;
-      pOutdoorLocation->pBModels[v48].pVertices.pVertices = (Vec3_int_ *)pAllocator->AllocNamedChunk(v106, v107, FileName);
-      v51 = &pOutdoorLocation->pBModels[v48];
-      v108 = (int)FileName;
-      v107 = 308 * v51->uNumFaces;
-      v106 = (char *)v51->pFaces;
-      pOutdoorLocation->pBModels[v48].pFaces = (ODMFace *)pAllocator->AllocNamedChunk(v106, v107, FileName);
-      v52 = &pOutdoorLocation->pBModels[v48];
-      v108 = (int)FileName;
-      v107 = 2 * v52->uNumFaces;
-      v106 = (char *)v52->pFacesOrdering;
-      pOutdoorLocation->pBModels[v48].pFacesOrdering = (unsigned __int16 *)pAllocator->AllocNamedChunk(v106, v107, FileName);
-      v53 = &pOutdoorLocation->pBModels[v48];
-      v108 = (int)FileName;
-      v107 = 8 * v53->uNumNodes;
-      v106 = (char *)v53->pNodes;
-      pOutdoorLocation->pBModels[v48].pNodes = (BSPNode *)pAllocator->AllocNamedChunk(v106, v107, FileName);
-      v54 = &pOutdoorLocation->pBModels[v48];
-      v108 = 12 * v54->pVertices.uNumVertices;
-      pFilename = (char *)v108;
-      v107 = (int)uSourceLen;
-      v106 = (char *)v54->pVertices.pVertices;
-      memcpy(v106, uSourceLen, v108);
-      uSourceLen = (char *)uSourceLen + (int)pFilename;
-      v55 = &pOutdoorLocation->pBModels[v48];
-      v105 = 308 * v55->uNumFaces;
-      v104 = uSourceLen;
-      v103 = v55->pFaces;
-      pFilename = (char *)v105;
-      memcpy(v103, uSourceLen, v105);
-      v56 = &pOutdoorLocation->pBModels[v48];
-      uSourceLen = (char *)uSourceLen + (int)pFilename;
-      v57 = v56->pFacesOrdering;
-      pFilename = (char *)(2 * v56->uNumFaces);
-      memcpy(v57, uSourceLen, (size_t)pFilename);
-      v58 = &pOutdoorLocation->pBModels[v48];
-      uSourceLen = (char *)uSourceLen + (int)pFilename;
-      v59 = v58->pNodes;
-      pFilename = (char *)(8 * v58->uNumNodes);
-      memcpy(v59, uSourceLen, (size_t)pFilename);
-      uSourceLen = (char *)uSourceLen + (int)pFilename;
-      ptr = (FILE *)malloc(10 * pOutdoorLocation->pBModels[v48].uNumFaces);
-      pFilename = (char *)(10 * pOutdoorLocation->pBModels[v48].uNumFaces);
-      memcpy(ptr, uSourceLen, (size_t)pFilename);
-      v144 = 0;
-      uSourceLen = (char *)uSourceLen + (int)pFilename;
-      v60 = pOutdoorLocation->pBModels;
-      if ( (signed int)v60[v48].uNumFaces > 0 )
-        break;
-LABEL_74:
-      free(ptr);
-      ++v151;
-      ++v48;
-      if ( v151 >= (signed int)pOutdoorLocation->uNumBModels )
-        goto LABEL_75;
-    }
-    v149 = 0;
-    Str2 = (char *)ptr;
-    while ( 1 )
-    {
-      pFilename = (char *)v149 + (unsigned int)v60[v48].pFaces;
-      if ( !(pFilename[29] & 0x40) )
-        break;
-      v61 = pTextureFrameTable->FindTextureByName(Str2);
-      *((short *)pFilename + 136) = v61;
-      if ( !v61 )
+      auto texFilename = textureFilenames + j * 10;
+    //v149 = 0;
+    //Str2 = (char *)ptr;
+
+      auto face = model->pFaces + j;
+      //pFilename = (char *)v149 + (unsigned int)v60[v48].pFaces;
+      if (~face->uAttributes & 0x40)
       {
-        v62 = pBitmaps_LOD->LoadTexture(Str2);
-        v63 = (ODMFace *)pFilename;
-        BYTE1(v63->uAttributes) &= 0xBFu;
+        v62 = pBitmaps_LOD->LoadTexture(texFilename);
+//        v63 = (ODMFace *)pFilename;
+        goto LABEL_68;
+      }
+      //v61 = pTextureFrameTable->FindTextureByName(texFilename);
+      face->uTextureID = pTextureFrameTable->FindTextureByName(texFilename);
+      if (!face->uTextureID)
+      {
+        v62 = pBitmaps_LOD->LoadTexture(texFilename);
+        //v63 = (ODMFace *)pFilename;
+        BYTE1(face->uAttributes) &= 0xBFu;
 LABEL_68:
-        v63->uTextureID = v62;
-        v145 = (signed __int16)v62 != -1 ? (int)&pBitmaps_LOD->pTextures[(signed __int16)v62] : 0;
-        v108 = ((signed __int16)v62 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v62].palette_id1 : 36);
+        face->uTextureID = v62;
+        //v145 = (signed __int16)v62 != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62] : 0;
+        //v108 = ((signed __int16)v62 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v62].palette_id1 : 36);
         if ((signed __int16)v62 != -1)
-          pBitmaps_LOD->pTextures[v62].palette_id2 = pPaletteManager->LoadPalette(v108);
+          pBitmaps_LOD->pTextures[v62].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[v62].palette_id1);
         goto LABEL_69;
       }
-      v108 = *(unsigned __int16 *)((char *)&pOutdoorLocation->pBModels[v48].pFaces->uTextureID + (unsigned int)v149);
-      pTextureFrameTable->LoadAnimationSequenceAndPalettes(v108);
+      pTextureFrameTable->LoadAnimationSequenceAndPalettes(face->uTextureID);
 LABEL_69:
-      if ( *((short *)pFilename + 146) )
+      if (face->sCogTriggeredID)
       {
-        if ( ((ODMFace *)pFilename)->HasEventHint() )
-          pFilename[30] |= 0x10u;
+        if (face->HasEventHint())
+          BYTE2(face->uAttributes) |= 0x10u;
         else
-          pFilename[30] &= 0xEFu;
+          BYTE2(face->uAttributes) &= 0xEFu;
       }
-      ++v144;
-      v60 = pOutdoorLocation->pBModels;
-      v149 = (char *)v149 + 308;
-      Str2 += 10;
-      if ( v144 >= (signed int)v60[v48].uNumFaces )
-        goto LABEL_74;
-    }
-    v62 = pBitmaps_LOD->LoadTexture(Str2);
-    v63 = (ODMFace *)pFilename;
-    goto LABEL_68;
+      //++v144;
+      //v60 = pBModels;
+      //v149 = (char *)v149 + 308;
+      //Str2 += 10;
+      //if ( v144 >= (signed int)v60[v48].uNumFaces )
+        //goto LABEL_74;
+      }
+
+//LABEL_74:
+      free((void *)textureFilenames);
+//      ++v151;
+//      ++v48;
+//      if ( v151 >= (signed int)uNumBModels )
+//        goto LABEL_75;
   }
-LABEL_75:
+//LABEL_75:
   pGameLoadingUI_ProgressBar->Progress();
-  memcpy(&uNumLevelDecorations, uSourceLen, 4u);
-  uSourceLen = (char *)uSourceLen + 4;
-  if ( (uNumLevelDecorations & 0x80000000u) != 0 || (signed int)uNumLevelDecorations > 3000 )
-  {
-          MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:678", 0);
-  }
+
+  memcpy(&uNumLevelDecorations, pSrc, 4u);
+  //uSourceLen = (char *)uSourceLen + 4;
+  if (uNumLevelDecorations > 3000)
+    MessageBoxW(nullptr, L"Can't load file!",
+                L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:678", 0);
+
+  assert(sizeof(LevelDecoration) == 32);
+  //pFilename = (char *)(32 * uNumLevelDecorations);
+  memcpy(pLevelDecorations, pSrc + 4, uNumLevelDecorations * sizeof(LevelDecoration));
+  pSrc += 4 + 32 * uNumLevelDecorations;
+
   pGameLoadingUI_ProgressBar->Progress();
-  pFilename = (char *)(32 * uNumLevelDecorations);
-  memcpy(pLevelDecorations, uSourceLen, 32 * uNumLevelDecorations);
-  v151 = 0;
-  uSourceLen = (char *)uSourceLen + (int)pFilename;
-  if ( (signed int)uNumLevelDecorations > 0 )
+
+  //v151 = 0;
+  //uSourceLen = (char *)uSourceLen + (int)pFilename;
+  for (uint i = 0; i < uNumLevelDecorations; ++i)
   {
-    pFilename = (char *)pLevelDecorations;
-    do
-    {
-      memcpy(FileName, uSourceLen, 0x20u);
-      uSourceLen = (char *)uSourceLen + 32;
-      v64 = pDecorationList->GetDecorIdByName(FileName);
-      v65 = pFilename;
-      ++v151;
-      pFilename += 32;
-      *(short *)v65 = v64;
-    }
-    while ( v151 < (signed int)uNumLevelDecorations );
+    char name[256];
+    memcpy(name, pSrc, 32);
+    pSrc += 32;
+
+    pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(name);
+  }
+
+  pGameLoadingUI_ProgressBar->Progress();
+
+  memcpy(&numFaceIDListElems, pSrc, 4);
+
+  //uSourceLen = (char *)uSourceLen + 4;
+  //v108 = (int)pFaceIDLIST;
+  if (pFaceIDLIST)
+  {
+    pAllocator->FreeChunk(pFaceIDLIST);
+    pFaceIDLIST = nullptr;
   }
+  //v66 = field_DC;
+  //pFaceIDLIST = 0;
+  //v67 = pAllocator->AllocNamedChunk(0, 2 * v66, "IDLIST");
+  uint faceIDListSize = 2 * numFaceIDListElems;
+  pFaceIDLIST = (unsigned short *)pAllocator->AllocNamedChunk(0, faceIDListSize, "IDLIST");
+  //v68 = field_DC;
+  //pFaceIDLIST = (unsigned __int16 *)v67;
+  //pFilename = (char *)(2 * v68);
+  memcpy(pFaceIDLIST, pSrc + 4, faceIDListSize);
+  pSrc += 4 + faceIDListSize;
+
+  //uSourceLen = (char *)uSourceLen + (int)pFilename;
   pGameLoadingUI_ProgressBar->Progress();
-  memcpy(&pOutdoorLocation->field_DC, uSourceLen, 4u);
-  uSourceLen = (char *)uSourceLen + 4;
-  v108 = (int)pOutdoorLocation->pFaceIDLIST;
-  pAllocator->FreeChunk((void *)v108);
-  v66 = pOutdoorLocation->field_DC;
-  pOutdoorLocation->pFaceIDLIST = 0;
-  v67 = pAllocator->AllocNamedChunk(0, 2 * v66, "IDLIST");
-  v68 = pOutdoorLocation->field_DC;
-  pOutdoorLocation->pFaceIDLIST = (unsigned __int16 *)v67;
-  pFilename = (char *)(2 * v68);
-  memcpy(v67, uSourceLen, 2 * v68);
-  uSourceLen = (char *)uSourceLen + (int)pFilename;
-  pGameLoadingUI_ProgressBar->Progress();
-  v108 = (int)pOutdoorLocation->pOMAP;
-  pAllocator->FreeChunk((void *)v108);
-  pOutdoorLocation->pOMAP = 0;
-  v69 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP");
-  v108 = 65536;
-  pOutdoorLocation->pOMAP = (unsigned int *)v69;
-  memcpy(v69, uSourceLen, v108);
-  uSourceLen = (char *)uSourceLen + 65536;
+
+  //v108 = (int)pOMAP;
+  //pAllocator->FreeChunk((void *)v108);
+  //pOMAP = 0;
+  if (pOMAP)
+  {
+    pAllocator->FreeChunk(pOMAP);
+    pOMAP = nullptr;
+  }
+  //v69 = pAllocator->AllocNamedChunk(0, 0x10000u, "OMAP");
+  pOMAP = (unsigned int *)pAllocator->AllocNamedChunk(0, 0x10000, "OMAP");
+  //v108 = 65536;
+  //pOMAP = (unsigned int *)v69;
+  memcpy(pOMAP, pSrc, 65536);
+  pSrc += 65536;
+
+  //uSourceLen = (char *)uSourceLen + 65536;
   pGameLoadingUI_ProgressBar->Progress();
-  memcpy(&pOutdoorLocation->uNumSpawnPoints, uSourceLen, 4u);
-  uSourceLen = (char *)uSourceLen + 4;
+
+  memcpy(&uNumSpawnPoints, pSrc, 4);
+  //uSourceLen = (char *)uSourceLen + 4;
   pGameLoadingUI_ProgressBar->Progress();
-  v70 = pOutdoorLocation->uNumSpawnPoints;
-  v108 = (int)"Spawn";
-  v107 = 24 * v70;
-  v106 = (char *)pOutdoorLocation->pSpawnPoints;
-  v71 = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(v106, 24 * v70, "Spawn");
-  v72 = pOutdoorLocation->uNumSpawnPoints;
-  pOutdoorLocation->pSpawnPoints = v71;
-  memcpy(v71, uSourceLen, 24 * v72);
+  //v70 = uNumSpawnPoints;
+  //v108 = (int)"Spawn";
+  //v107 = 24 * v70;
+  //v106 = (char *)pSpawnPoints;
+  assert(sizeof(SpawnPointMM7) == 24);
+  uint spawnPointsSize = uNumSpawnPoints * sizeof(SpawnPointMM7);
+  pSpawnPoints = (SpawnPointMM7 *)pAllocator->AllocNamedChunk(pSpawnPoints, spawnPointsSize, "Spawn");
+  //v72 = uNumSpawnPoints;
+  //pSpawnPoints = v71;
+  memcpy(pSpawnPoints, pSrc + 4, spawnPointsSize);
+  pSrc += 4 + spawnPointsSize;
+
   pGameLoadingUI_ProgressBar->Progress();
-  free((void *)HIDWORD(v142));
-  v108 = (int)".ddm";
-  v73 = strlen(pContainer);
-  strcpy((char *)v141 + v73, (const char *)v108);
-  v151 = (int)pNew_LOD->FindContainer(pContainer, 1);//
-  fread(&header, 0x10u, 1u, (FILE *)v151);
+
+  free(pSrcMem);
+
+  //v108 = (int)".ddm";
+  //v73 = strlen(pContainer);
+  strcpy(Str + strlen(Str) - 4, ".ddm");
+  //strcpy((char *)v141 + v73, (const char *)v108);
+  v39 = pNew_LOD->FindContainer(Str, 1);//
+  fread(&header, 0x10u, 1u, v39);
   Str2 = 0;
-  if ( header.uVersion != 91969
-    || header.pMagic[0] != 'm'
-    || header.pMagic[1] != 'v'
-    || header.pMagic[2] != 'i'
-    || header.pMagic[3] != 'i' )
+  if (header.uVersion != 91969 ||
+      header.pMagic[0] != 'm' ||
+      header.pMagic[1] != 'v' ||
+      header.pMagic[2] != 'i' ||
+      header.pMagic[3] != 'i' )
   {
-          MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:746", 0);
+    MessageBoxW(nullptr, L"Can't load file!",
+                L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:746", 0);
     Str2 = (char *)1;
   }
-  v74 = 0;
-  pFilename = (char *)header.uCompressedSize;
-  v149 = 0;
-  pDestLen = header.uDecompressedSize;
+  //v74 = 0;
+  //pFilename = (char *)header.uCompressedSize;
+  //v149 = 0;
+  //pDestLen = header.uDecompressedSize;
   if ( !Str2 )
   {
-    v75 = malloc(header.uDecompressedSize);
-    v149 = v75;
-    if ( (unsigned int)pFilename <= pDestLen )
+    pSrcMem = (unsigned char *)malloc(header.uDecompressedSize);
+    pSrc = pSrcMem;
+    //v149 = v75;
+    if (header.uCompressedSize == header.uDecompressedSize)
+      fread(pSrc, header.uDecompressedSize, 1u, v39);
+    else if (header.uCompressedSize < header.uDecompressedSize)
     {
-      if ( pFilename == (const char *)pDestLen )
-      {
-        fread(v75, pDestLen, 1u, (FILE *)v151);
-      }
-      else
-      {
-        uSourceLen = malloc((size_t)pFilename);
-        fread(uSourceLen, (size_t)pFilename, 1u, (FILE *)v151);
-        zlib::MemUnzip(v75, &pDestLen, uSourceLen, (unsigned int)pFilename);
-        free(uSourceLen);
-      }
+      auto compressedMem = malloc(header.uCompressedSize);
+      fread(compressedMem, header.uCompressedSize, 1, v39);
+
+      uint actualDecompressedSize = header.uDecompressedSize;
+      zlib::MemUnzip(pSrc, &actualDecompressedSize, compressedMem, header.uCompressedSize);
+      free(compressedMem);
     }
     else
-    {
-          MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:765", 0);
-    }
-    memcpy(&pOutdoorLocation->ddm, v75, 0x28u);
-    v74 = (int)((char *)v75 + 40);
+      MessageBoxW(nullptr, L"Can't load file!",
+                  L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:765", 0);
+
+    assert(sizeof(DDM_DLV_Header) == 0x28);
+    memcpy(&ddm, pSrc, sizeof(DDM_DLV_Header));
+    pSrc += sizeof(DDM_DLV_Header);
+    //v74 = (int)((char *)v75 + 40);
   }
-  v76 = pOutdoorLocation->uNumBModels;
-  v77 = 0;
-  if ( (signed int)v76 > 0 )
+  //v76 = uNumBModels;
+  //v77 = actualNumFacesInLevel = 0;
+  uint actualNumFacesInLevel = 0;
+  for (uint i = 0; i < uNumBModels; ++i)
+    actualNumFacesInLevel += pBModels[i].uNumFaces;
+
+  //v79 = ddm.uNumFacesInBModels;
+  if (ddm.uNumFacesInBModels)
   {
-    v78 = (char *)&pOutdoorLocation->pBModels->uNumFaces;
-    do
+    if ( ddm.uNumBModels )
     {
-      v77 += *(int *)v78;
-      v78 += 188;
-      --v76;
-    }
-    while ( v76 );
-  }
-  v79 = pOutdoorLocation->ddm.uNumFacesInBModels;
-  if ( v79 )
-  {
-    if ( pOutdoorLocation->ddm.uNumBModels )
-    {
-      v80 = pOutdoorLocation->ddm.uNumDecorations;
-      if ( v80 )
+      //v80 = ddm.uNumDecorations;
+      if (ddm.uNumDecorations)
       {
-        if ( v79 != v77 || pOutdoorLocation->ddm.uNumBModels != pOutdoorLocation->uNumBModels || v80 != uNumLevelDecorations )
+        if (ddm.uNumFacesInBModels != actualNumFacesInLevel ||
+            ddm.uNumBModels != uNumBModels ||
+            ddm.uNumDecorations != uNumLevelDecorations )
           Str2 = (char *)1;
       }
     }
   }
+
   if ( BYTE1(dword_6BE364_game_settings_1) & 0x20 )
     pNumItems = 29030400;
   if ( Str2 )
   {
-    memset(Dst, 0, 0x3C8u);
-    memset(Src, 0, 0x3C8u);
-    goto LABEL_112;
+    __debugbreak();
+    //memset(Dst, 0, 0x3C8u);
+    //memset(Src, 0, 0x3C8u);
+    //goto LABEL_112;
   }
-  v81 = pOutdoorLocation->ddm.uLastRepawnDay;
-  if ( (unsigned int)((char *)File - v81) >= pNumItems || !v81 )
+  //v81 = ddm.uLastRepawnDay;
+  if ( (unsigned int)((char *)File - ddm.uLastRepawnDay) >= pNumItems || !ddm.uLastRepawnDay )
   {
-    memcpy(Dst, (const void *)v74, 0x3C8u);
-    memcpy(Src, (const void *)(v74 + 968), 0x3C8u);
+    __debugbreak();
+    /*
+    memcpy(Dst, pSrc, 0x3C8u);
+    memcpy(Src, pSrc + 968, 0x3C8u);
 LABEL_112:
-    free(v149);
+    free(pSrcMem);
     v25 = Str2 == 0;
-    pOutdoorLocation->ddm.uLastRepawnDay = (int)File;
+    ddm.uLastRepawnDay = (int)File;
     if ( v25 )
-      ++pOutdoorLocation->ddm.uNumRespawns;
+      ++ddm.uNumRespawns;
     v108 = 0;
     *(int *)thisa = 1;
     v151 = (int)pGames_LOD->FindContainer(pContainer, v108);
@@ -2006,178 +2091,209 @@
     }
     v74 = (int)((char *)v82 + 40);
     goto LABEL_120;
+    */
   }
   *(int *)thisa = 0;
 LABEL_120:
-  v108 = (int)".odm";
-  v83 = strlen(pContainer);
-  strcpy((char *)v141 + v83, (const char *)v108);
-  memcpy(pOutdoorLocation->array_528, (const void *)v74, 0x3C8u);
-  v84 = (const void *)(v74 + 968);
-  memcpy(pOutdoorLocation->array_8F0, v84, 0x3C8u);
-  v85 = (char *)v84 + 968;
+  //v108 = (int)".odm";
+  //v83 = strlen(pContainer);
+  //strcpy((char *)v141 + v83, (const char *)v108);
+  memcpy(array_528, pSrc, 0x3C8);
+  //v84 = (const void *)(v74 + 968);
+  memcpy(array_8F0, pSrc + 0x3C8, 0x3C8);
+  pSrc += 2 * 0x3C8;
+  //v85 = (char *)v84 + 968;
+
   pGameLoadingUI_ProgressBar->Progress();
+
   if ( *(int *)thisa )
   {
-    memcpy(pOutdoorLocation->array_528, Dst, 0x3C8u);
-    memcpy(pOutdoorLocation->array_8F0, Src, 0x3C8u);
+    __debugbreak();
+    memcpy(array_528, Dst, 0x3C8u);
+    memcpy(array_8F0, Src, 0x3C8u);
   }
-  v25 = pOutdoorLocation->uNumBModels == 0;
-  v26 = (pOutdoorLocation->uNumBModels & 0x80000000u) != 0;
-  v151 = 0;
-  if ( !(v26 | v25) )
+
+  //v25 = uNumBModels == 0;
+  //v26 = (uNumBModels & 0x80000000u) != 0;
+  //v151 = 0;
+  for (uint i = 0; i < uNumBModels; ++i)
   {
-    pNumItems = 0;
-    do
+    auto model = pBModels + i;
+    //pNumItems = 0;
+    //do
+    //{
+      //v86 = pBModels;
+      //thisa = 0;
+      //v87 = (unsigned int)((char *)v86 + pNumItems);
+    for (uint j = 0; j < model->uNumFaces; ++j)
     {
-      v86 = pOutdoorLocation->pBModels;
-      thisa = 0;
-      v87 = (unsigned int)((char *)v86 + pNumItems);
-      if ( *(int *)(v87 + 76) > 0 )
-      {
-        File = 0;
-        do
-        {
-          v106 = (char *)&File->uAttributes + *(int *)(v87 + 84);
-          memcpy(v106, v85, 4u);
-          v88 = pOutdoorLocation->pBModels;
-          ++File;
-          v85 = (char *)v85 + 4;
-          ++thisa;
-          v87 = (unsigned int)((char *)v88 + pNumItems);
-        }
-        while ( thisa < *(int *)(v87 + 76) );
-      }
-      v89 = pOutdoorLocation->pBModels;
-      thisa = 0;
-      if ( *(signed int *)((char *)&v89->uNumFaces + pNumItems) > 0 )
+      auto face = model->pFaces + j;
+
+      //if ( *(int *)(v87 + 76) > 0 )
+      //{
+        //File = 0;
+        //do
+        //{
+          //v106 = (char *)&File->uAttributes + *(int *)(v87 + 84);
+      memcpy(&face->uAttributes, pSrc, 4);
+      pSrc += 4;
+          //v88 = pBModels;
+          //++File;
+          //v85 = (char *)v85 + 4;
+          //++thisa;
+          //v87 = (unsigned int)((char *)v88 + pNumItems);
+        //}
+        //while ( thisa < *(int *)(v87 + 76) );
+    }
+
+      //v89 = pBModels;
+      //thisa = 0;
+    for (uint j = 0; j < model->uNumFaces; ++j)
+    {
+      auto face = model->pFaces + j;
+        //pFilename = 0;
+        //do
+        //{
+          //v90 = (ODMFace *)&pFilename[*(unsigned int *)((char *)&v89->pFaces + pNumItems)];
+          //File = v90;
+      if (face->sCogTriggeredID)
       {
-        pFilename = 0;
-        do
-        {
-          v90 = (ODMFace *)&pFilename[*(unsigned int *)((char *)&v89->pFaces + pNumItems)];
-          File = v90;
-          if ( v90->sCogTriggeredID )
-          {
-            if ( v90->HasEventHint() )
-              BYTE2(File->uAttributes) |= 0x10u;
-            else
-              BYTE2(File->uAttributes) &= 0xEFu;
-          }
-          ++thisa;
-          v89 = pOutdoorLocation->pBModels;
-          pFilename += 308;
-        }
-        while ( thisa < *(signed int *)((char *)&v89->uNumFaces + pNumItems) );
+        if (face->HasEventHint())
+          BYTE2(face->uAttributes) |= 0x10u;
+        else
+          BYTE2(face->uAttributes) &= 0xEFu;
       }
-      ++v151;
-      pNumItems += 188;
+          //++thisa;
+          //v89 = pBModels;
+          //pFilename += 308;
+        //}
+        //while ( thisa < *(signed int *)((char *)&v89->uNumFaces + pNumItems) );
     }
-    while ( v151 < (signed int)pOutdoorLocation->uNumBModels );
+      //++v151;
+      //pNumItems += 188;
+    //}
+    //while ( v151 < (signed int)uNumBModels );
   }
+
   pGameLoadingUI_ProgressBar->Progress();
-  v151 = 0;
-  if ( (signed int)uNumLevelDecorations > 0 )
+
+  //v151 = 0;
+  for (uint i = 0; i < uNumLevelDecorations; ++i)
   {
-    thisa = (int)&pLevelDecorations[0].field_2;
-    do
-    {
-      memcpy((void *)thisa, v85, 2u);
-      thisa += 32;
-      v85 = (char *)v85 + 2;
-      ++v151;
-    }
-    while ( v151 < (signed int)uNumLevelDecorations );
+    //thisa = (int)&pLevelDecorations[0].field_2;
+    //do
+    //{
+    memcpy(&pLevelDecorations[i].field_2, pSrc, 2);
+    pSrc += 2;
+      //thisa += 32;
+      //v85 = (char *)v85 + 2;
+      //++v151;
+    //}
+    //while ( v151 < (signed int)uNumLevelDecorations );
   }
+
   pGameLoadingUI_ProgressBar->Progress();
-  memcpy(&uNumActors, v85, 4u);
-  v91 = (char *)v85 + 4;
-  if ( (uNumActors & 0x80000000u) != 0 || (signed int)uNumActors > 500 )
-  {
-          MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:939", 0);
-  }
+
+  memcpy(&uNumActors, pSrc, 4);
+  //v91 = (char *)v85 + 4;
+  if (uNumActors > 500)
+    MessageBoxW(nullptr, L"Can't load file!",
+                L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:939", 0);
+
   pGameLoadingUI_ProgressBar->Progress();
-  pFilename = (char *)(836 * uNumActors);
-  memcpy(pActors, v91, 836 * uNumActors);
-  v92 = (char *)v91 + (int)pFilename;
+
+  assert(sizeof(Actor) == 836);
+  //pFilename = (char *)(836 * uNumActors);
+  memcpy(pActors, pSrc + 4, uNumActors * sizeof(Actor));
+  pSrc += 4 + uNumActors * sizeof(Actor);
+  //v92 = (char *)v91 + (int)pFilename;
   pGameLoadingUI_ProgressBar->Progress();
-  memcpy(&uNumLayingItems, v92, 4u);
-  v93 = (char *)v92 + 4;
-  if ( (uNumLayingItems & 0x80000000u) != 0 || (signed int)uNumLayingItems > 1000 )
-  {
-          MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:954", 0);
-  }
-  pGameLoadingUI_ProgressBar->Progress();
-  pFilename = (char *)(112 * uNumLayingItems);
-  memcpy(pLayingItems, v93, 112 * uNumLayingItems);
-  v94 = (char *)v93 + (int)pFilename;
+
+  memcpy(&uNumLayingItems, pSrc, 4);
+  //v93 = (char *)v92 + 4;
+  if (uNumLayingItems > 1000)
+    MessageBoxW(nullptr, L"Can't load file!",
+                L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:954", 0);
+
   pGameLoadingUI_ProgressBar->Progress();
-  memcpy(&uNumChests, v94, 4u);
-  v95 = (char *)v94 + 4;
-  if ( (uNumChests & 0x80000000u) != 0 || (signed int)uNumChests > 20 )
-  {
-          MessageBoxW(nullptr, L"Can't load file!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:968", 0);
-  }
+
+  assert(sizeof(LayingItem) == 112);
+  //pFilename = (char *)(112 * uNumLayingItems);
+  memcpy(pLayingItems, pSrc + 4, uNumLayingItems * sizeof(LayingItem));
+  pSrc += 4 + uNumLayingItems * sizeof(LayingItem);
+
+  //v94 = (char *)v93 + (int)pFilename;
   pGameLoadingUI_ProgressBar->Progress();
-  pFilename = (char *)(5324 * uNumChests);
-  memcpy(pChests, v95, 5324 * uNumChests);
-  v96 = (char *)v95 + (int)pFilename;
+
+  memcpy(&uNumChests, pSrc, 4);
+  //v95 = (char *)v94 + 4;
+  if (uNumChests > 20)
+    MessageBoxW(nullptr, L"Can't load file!",
+                L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odmap.cpp:968", 0);
+
   pGameLoadingUI_ProgressBar->Progress();
-  memcpy(&stru_5E4C90, v96, 0xC8u);
+
+  assert(sizeof(Chest) == 5324);
+  //pFilename = (char *)(5324 * uNumChests);
+  memcpy(pChests, pSrc + 4 , uNumChests * sizeof(Chest));
+  pSrc += 4 + uNumChests * sizeof(Chest);
+  //v96 = (char *)v95 + (int)pFilename;
   pGameLoadingUI_ProgressBar->Progress();
-  memcpy(&pOutdoorLocation->uLastVisitDay, v96 + 200, 0x38u);
-  free(v149);
+
+  memcpy(&stru_5E4C90, pSrc, 0xC8);
+  pSrc += 0xC8;
+
+  pGameLoadingUI_ProgressBar->Progress();
+  memcpy(&uLastVisitDay, pSrc, 0x38u);
+
+  free(pSrcMem);
+
   pTileTable->InitializeTileset(4);
-  thisa = (int)pOutdoorLocation->pTileTypes;
-  v108 = pOutdoorLocation->pTileTypes[0].uTileGroup;
-  pTileTable->InitializeTileset(v108);
-  v108 = pOutdoorLocation->pTileTypes[1].uTileGroup;
-  pTileTable->InitializeTileset(v108);
-  v108 = pOutdoorLocation->pTileTypes[2].uTileGroup;
-  pTileTable->InitializeTileset(v108);
-  v108 = pOutdoorLocation->pTileTypes[3].uTileGroup;
-  pTileTable->InitializeTileset(v108);
-  strcpy(pOutdoorLocation->pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture);
-  v97 = pOutdoorLocation->pTileTypes[0].uTileID;
-  v108 = 0;
-  v98 = pTileTable->GetTileById(v97);
-  v99 = pBitmaps_LOD->LoadTexture(v98->pTileName, (enum TEXTURE_TYPE)v108);
-  pOutdoorLocation->uMainTile_BitmapID = v99;
-  if ( v99 != -1 )
+  //thisa = (int)pTileTypes;
+  //v108 = pTileTypes[0].uTileGroup;
+  pTileTable->InitializeTileset(pTileTypes[0].uTileGroup);
+  //v108 = pTileTypes[1].uTileGroup;
+  pTileTable->InitializeTileset(pTileTypes[1].uTileGroup);
+  //v108 = pTileTypes[2].uTileGroup;
+  pTileTable->InitializeTileset(pTileTypes[2].uTileGroup);
+  //v108 = pTileTypes[3].uTileGroup;
+  pTileTable->InitializeTileset(pTileTypes[3].uTileGroup);
+  strcpy(pGroundTileset, byte_6BE124_cfg_textures_DefaultGroundTexture);
+  //v97 = pTileTypes[0].uTileID;
+  //v108 = 0;
+  auto v98 = pTileTable->GetTileById(pTileTypes[0].uTileID);
+  //v99 = pBitmaps_LOD->LoadTexture(v98->pTileName, TEXTURE_DEFAULT);
+  uMainTile_BitmapID = pBitmaps_LOD->LoadTexture(v98->pTileName, TEXTURE_DEFAULT);
+  if (uMainTile_BitmapID != -1)
+    pBitmaps_LOD->pTextures[uMainTile_BitmapID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[uMainTile_BitmapID].palette_id1);
+
+  _47F0E2();
+
+LABEL_150:
+  //v100 = HIDWORD(uLastVisitDay);
+  //LODWORD(v142) = LODWORD(uLastVisitDay);
+  //HIDWORD(v142) = v100;
+  if (uLastVisitDay)
   {
-    v108 = (v99 != -1 ? pBitmaps_LOD->pTextures[v99].palette_id1 : 36);
-    if (v99 != -1)
-      pBitmaps_LOD->pTextures[v99].palette_id2 = pPaletteManager->LoadPalette(v108);
-  }
-  pOutdoorLocation->_47F0E2();
-LABEL_150:
-  v100 = HIDWORD(pOutdoorLocation->uLastVisitDay);
-  LODWORD(v142) = LODWORD(pOutdoorLocation->uLastVisitDay);
-  HIDWORD(v142) = v100;
-  if ( v100 | (unsigned int)v142 )
-  {
-    v108 = 28;
-    if ( (signed int)((signed int)(signed __int64)((double)v142 * 0.234375) / 60 / 60 / 0x18u) % 28 != pParty->uDaysPlayed )
+    auto v108 = 28;
+    if ( (signed int)((signed int)(signed __int64)((double)uLastVisitDay * 0.234375) / 60 / 60 / 0x18u) % 28 != pParty->uDaysPlayed )
     {
       if ( rand() % 100 >= 20 )
         v108 = dword_4EC268[rand() % dword_4EC2A8];
       else
         v108 = dword_4EC28C[rand() % dword_4EC2AC];
-      sprintf(pOutdoorLocation->field_4F8, "plansky%d", v108);
+      sprintf(field_4F8, "plansky%d", v108);
     }
   }
   else
   {
-    strcpy(pOutdoorLocation->field_4F8, "plansky3");
+    strcpy(field_4F8, "plansky3");
   }
-  v101 = pBitmaps_LOD->LoadTexture(pOutdoorLocation->field_4F8);
-  pOutdoorLocation->uSky_TextureID = v101;
-  if ( v101 != -1 )
-  {
-    v108 = (v101 != -1 ? pBitmaps_LOD->pTextures[v101].palette_id1 : 36);
-    if (v101 != -1)
-      pBitmaps_LOD->pTextures[v101].palette_id2 = pPaletteManager->LoadPalette(v108);
-  }
+  //v101 = pBitmaps_LOD->LoadTexture(field_4F8);
+  uSky_TextureID = pBitmaps_LOD->LoadTexture(field_4F8);
+  if (uSky_TextureID != -1)
+    pBitmaps_LOD->pTextures[uSky_TextureID].palette_id2 = pPaletteManager->LoadPalette(pBitmaps_LOD->pTextures[uSky_TextureID].palette_id1);
+
   pPaletteManager->RecalculateAll();
   pSoundList->_4A9A67(53, 0);
   pSoundList->_4A9A67(92, 0);
@@ -2239,15 +2355,8 @@
     --thisa;
   }
   while ( thisa );
-  return 1;
+  return true;
 }
-// 4EC268: using guessed type int dword_4EC268[];
-// 4EC28C: using guessed type int dword_4EC28C[];
-// 4EC2A8: using guessed type int dword_4EC2A8;
-// 4EC2AC: using guessed type int dword_4EC2AC;
-// 6807E0: using guessed type int _6807E0_num_decorations_6807B8;
-// 6BE364: using guessed type int dword_6BE364_game_settings_1;
-// 6BE3C4: using guessed type char bUnderwater;
 
 //----- (0047ECC1) --------------------------------------------------------
 int OutdoorLocation::_47ECC1(signed int a2)
@@ -2586,10 +2695,10 @@
     {
       pDecorationList->InitializeDecorationSprite(v3->uDecorationDescID);
       v4 = pDecorationList->pDecorations[v3->uDecorationDescID].uSoundID;
-      if ( v4 && pNumSoundDecorations < 9 )
+      if ( v4 && _6807E0_num_decorations_with_sounds_6807B8 < 9 )
       {
         pSoundList->_4A9A67(v4, 0);
-        v5 = pNumSoundDecorations++;
+        v5 = _6807E0_num_decorations_with_sounds_6807B8++;
         _6807B8_level_decorations_ids[v5] = v2;
       }
       if ( v8 && v3->uCog == 20 )
@@ -2734,19 +2843,10 @@
 //----- (0047F420) --------------------------------------------------------
 bool OutdoorLocation::LoadTileGroupIds()
 {
-  char *v1; // esi@1
-  signed int v2; // edi@1
+  for (uint i = 0; i < 3; ++i)
+    pTileTypes[i].uTileID = pTileTable->method_487ED6(pTileTypes[i].uTileGroup, 1);
 
-  v1 = (char *)&this->pTileTypes[0].uTileID;
-  v2 = 3;
-  do
-  {
-    *(short *)v1 = pTileTable->method_487ED6(*((short *)v1 - 1), 1);
-    v1 += 4;
-    --v2;
-  }
-  while ( v2 );
-  return 1;
+  return true;
 }
 
 //----- (0047B42C) --------------------------------------------------------
--- a/Outdoor.h	Fri Nov 02 14:45:06 2012 +0200
+++ b/Outdoor.h	Sun Nov 04 03:58:34 2012 +0200
@@ -184,7 +184,7 @@
   struct OutdoorLocationTerrain pTerrain;
   void *ptr_D4;
   struct BSPModel *pBModels;
-  int field_DC;
+  unsigned int numFaceIDListElems;
   unsigned __int16 *pFaceIDLIST;
   unsigned int *pOMAP;
   unsigned int uSky_TextureID;
--- a/PaletteManager.h	Fri Nov 02 14:45:06 2012 +0200
+++ b/PaletteManager.h	Sun Nov 04 03:58:34 2012 +0200
@@ -31,8 +31,8 @@
   int pPaletteIDs[50];
   int _num_locked;
   int _pal_lock_test;
-  unsigned __int8 pPalette_mistColor[2];
-  char pPalette_tintColor[2];
+  unsigned __int8 pPalette_mistColor[3];
+  unsigned char pPalette_tintColor[3];
   char field_267AD6;
   char field_267AD7;
   unsigned int uNumTargetRBits;
--- a/Party.h	Fri Nov 02 14:45:06 2012 +0200
+++ b/Party.h	Sun Nov 04 03:58:34 2012 +0200
@@ -150,6 +150,7 @@
 
   inline bool WizardEyeActive()      {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uExpireTime > 0;}
   inline int  WizardEyeSkillLevel()  {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uSkill;}
+  inline bool TorchlightActive()     {return pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0;}
   inline bool FlyActive()            {return pPartyBuffs[PARTY_BUFF_FLY].uExpireTime > 0;}
   inline bool WaterWalkActive()      {return pPartyBuffs[PARTY_BUFF_WATER_WALK].uExpireTime > 0;}
   inline bool ImmolationActive()     {return pPartyBuffs[PARTY_BUFF_IMMOLATION].uExpireTime > 0;}
--- a/mm7_1.cpp	Fri Nov 02 14:45:06 2012 +0200
+++ b/mm7_1.cpp	Sun Nov 04 03:58:34 2012 +0200
@@ -7261,7 +7261,7 @@
   v10 = v65;
   v68 = 0;
   v5->_viewport_space_y = v7;
-  v5->field_4 = v8;
+  v5->_viewport_space_w = v8;
   v55 = v65;
   if ( v4 > 0 )
   {
@@ -7449,14 +7449,14 @@
   }
   v39 = a3;
   v40 = v73;
-  if ( v73 < a3->_viewport_space_y || (v41 = a3->field_4, v7 > v41) )
+  if ( v73 < a3->_viewport_space_y || (v41 = a3->_viewport_space_w, v7 > v41) )
     return 0;
   if ( v7 < a3->_viewport_space_y )
     v7 = a3->_viewport_space_y;
   if ( v73 > v41 )
   {
-    v40 = a3->field_4;
-    v73 = a3->field_4;
+    v40 = a3->_viewport_space_w;
+    v73 = a3->_viewport_space_w;
   }
   v71 = v7;
   if ( v7 <= v40 )
@@ -7510,7 +7510,7 @@
   }
   while ( v46 );
   v5->_viewport_space_y = v7;
-  v5->field_4 = v73;
+  v5->_viewport_space_w = v73;
   v5->field_8 = v5->array_18[v7];
   v48 = v5->array_3D8[v7];
   v5->field_10 = v7;
--- a/mm7_3.cpp	Fri Nov 02 14:45:06 2012 +0200
+++ b/mm7_3.cpp	Sun Nov 04 03:58:34 2012 +0200
@@ -12904,37 +12904,26 @@
 }
 
 //----- (0043F9E1) --------------------------------------------------------
-__int16 *stru170_stru2::_43F9E1(__int16 x, int y, __int16 z, int w)
-{
-  signed int v5; // edx@1
-  __int16 *result; // eax@1
-
-  auto a2 = x;
-  auto a3 = y;
-  auto a4 = z;
-  auto a5 = w;
-
-  this->_viewport_space_y = a3;
-  this->field_4 = a5;
-  v5 = 0;
-  result = this->array_3D8;
-  do
-  {
-    if ( v5 < a3 || v5 > a5 )
-    {
-      *result = -1;
-      *(result - 480) = 640;
-    }
-    else
-    {
-      *(result - 480) = a2;
-      *result = a4;
-    }
-    ++v5;
-    ++result;
-  }
-  while ( v5 < 480 );
-  return result;
+void stru170_stru2::_43F9E1(__int16 x, int y, __int16 z, int w)
+{
+  __debugbreak();
+
+  _viewport_space_y = y;
+  _viewport_space_w = w;
+
+  for (uint i = 0; i < 480; ++i)
+  {
+    if ( i < y || i > w )
+    {
+      array_3D8[i] = -1;
+      array_18[i] = 640;
+    }
+    else
+    {
+      array_18[i] = x;
+      array_3D8[i] = z;
+    } 
+  }
 }
 
 //----- (0043FA33) --------------------------------------------------------
--- a/mm7_4.cpp	Fri Nov 02 14:45:06 2012 +0200
+++ b/mm7_4.cpp	Sun Nov 04 03:58:34 2012 +0200
@@ -7958,7 +7958,7 @@
               v89 = v4->pLevelOfDetail3;
               v98 = stru_F8A590._viewport_space_y * pRenderer->uTargetSurfacePitch;
               v104 = 2 * pBLVRenderParams->field_0_timer_;
-              if ( stru_F8A590._viewport_space_y <= stru_F8A590.field_4 )
+              if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w )
               {
                 v12 = 2 * stru_F8A590._viewport_space_y;
                 v101 = 2 * stru_F8A590._viewport_space_y;
@@ -8290,7 +8290,7 @@
                   result = a2;
                   v101 += 2;
                   v99 += 640;
-                  if ( a2 > stru_F8A590.field_4 )
+                  if ( a2 > stru_F8A590._viewport_space_w )
                     break;
                   v12 = v101;
                   result = a2;
@@ -8444,7 +8444,7 @@
           v12 = stru_F8A590._viewport_space_y;
           v51 = v11;
           v60 = stru_F8A590._viewport_space_y;
-          if ( stru_F8A590._viewport_space_y <= stru_F8A590.field_4 )
+          if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w )
           {
             v13 = 2 * stru_F8A590._viewport_space_y;
             v14 = &stru_F83B80[stru_F8A590._viewport_space_y];
@@ -8573,7 +8573,7 @@
               ++i;
               v56 += 640;
               v55 += 2;
-              if ( v60 > stru_F8A590.field_4 )
+              if ( v60 > stru_F8A590._viewport_space_w )
                 break;
               v13 = v55;
               v12 = v60;
--- a/mm7_data.cpp	Fri Nov 02 14:45:06 2012 +0200
+++ b/mm7_data.cpp	Sun Nov 04 03:58:34 2012 +0200
@@ -2311,7 +2311,7 @@
 char *pPotionNotesTXT_Raw;
 char *pHistoryTXT_Raw;
 int _6807B8_level_decorations_ids[777]; // idb
-int pNumSoundDecorations; // weak
+int _6807E0_num_decorations_with_sounds_6807B8; // weak
 int _6807E8_level_decorations_ids[777]; // idb
 int _6836C8_num_decorations_6807E8; // weak
 int dword_69B010[64];
--- a/mm7_data.h	Fri Nov 02 14:45:06 2012 +0200
+++ b/mm7_data.h	Sun Nov 04 03:58:34 2012 +0200
@@ -2218,7 +2218,7 @@
 extern char *pPotionNotesTXT_Raw;
 extern char *pHistoryTXT_Raw;
 extern int _6807B8_level_decorations_ids[]; // idb
-extern int pNumSoundDecorations; // weak
+extern int _6807E0_num_decorations_with_sounds_6807B8; // weak
 extern int _6807E8_level_decorations_ids[]; // idb
 extern int _6836C8_num_decorations_6807E8; // weak
 extern int dword_69B010[64];
@@ -2757,7 +2757,7 @@
 bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1);
 void __fastcall WetsuitOn(unsigned int uPlayerID); // idb
 unsigned int __fastcall WetsuitOff(unsigned int uPlayerID);
-void __fastcall sub_43F39E(struct IndoorLocation_drawstru *_this);
+void __fastcall PrepareDrawLists_BLV(struct IndoorLocation_drawstru *_this);
 int /*__usercall*/ sr_sub_4D6FB0/*<eax>*/(struct stru315 *a1/*<ebp>*/);
 int /*__usercall*/ sr_sub_4D705A/*<eax>*/(struct stru315 *a1/*<ebp>*/);
 void __cdecl MessWithBillboards_BLV();