changeset 111:e5d6903a077a

7.11.12
author Ritor1
date Wed, 07 Nov 2012 13:03:58 +0600
parents 430786d916d6
children 8feb2dfd2f89
files SaveLoad.cpp
diffstat 1 files changed, 260 insertions(+), 302 deletions(-) [+]
line wrap: on
line diff
--- a/SaveLoad.cpp	Tue Nov 06 17:30:24 2012 +0600
+++ b/SaveLoad.cpp	Wed Nov 07 13:03:58 2012 +0600
@@ -228,7 +228,7 @@
 int __fastcall SaveGame(int a1, __int16 *a2)
 {
   int result; // eax@1
-  void *v3; // edi@5
+  void *pScreenshot; // edi@5
   int v4; // eax@6
   int v5; // eax@6
   int v6; // eax@6
@@ -264,20 +264,19 @@
   const char *v36; // [sp-10h] [bp-280h]@6
   const char *v37; // [sp-Ch] [bp-27Ch]@6
   const char *v38; // [sp-8h] [bp-278h]@8
-  int v39; // [sp-4h] [bp-274h]@8
   CHAR Buffer; // [sp+Ch] [bp-264h]@59
   char Dir; // [sp+8Ch] [bp-1E4h]@51
   char Drive; // [sp+ACh] [bp-1C4h]@51
   int v43; // [sp+CCh] [bp-1A4h]@10
   char Dest[20]; // [sp+E0h] [bp-190h]@10
-  unsigned __int64 v45; // [sp+F4h] [bp-17Ch]@10
+  unsigned __int64 pTimePlayed; // [sp+F4h] [bp-17Ch]@10
   char Filename; // [sp+130h] [bp-140h]@51
   char Ext; // [sp+150h] [bp-120h]@51
   char v48; // [sp+151h] [bp-11Fh]@51
   char Source[32]; // [sp+170h] [bp-100h]@51
   char Str[120]; // [sp+190h] [bp-E0h]@8
   int v51; // [sp+208h] [bp-68h]@2
-  int v52; // [sp+20Ch] [bp-64h]@2
+  int pPositionX; // [sp+20Ch] [bp-64h]@2
   int v53; // [sp+210h] [bp-60h]@2
   int v54; // [sp+214h] [bp-5Ch]@2
   int Src; // [sp+218h] [bp-58h]@30
@@ -289,7 +288,6 @@
   int v61; // [sp+224h] [bp-4Ch]@30
   int v62; // [sp+228h] [bp-48h]@2
   LOD::Directory pDir; // [sp+22Ch] [bp-44h]@2
-  //std::string *v64; // [sp+24Ch] [bp-24h]@1
   size_t Size; // [sp+250h] [bp-20h]@26
   __int16 *v66; // [sp+254h] [bp-1Ch]@1
   void *DstBuf; // [sp+258h] [bp-18h]@2
@@ -300,17 +298,16 @@
   int a3; // [sp+26Fh] [bp-1h]@8
   
   v66 = a2;
-  //v64 = (std::string *)a1;
   strcpy(byte_6BE3B0, pCurrentMapName);
   if (!_strcmpi(pCurrentMapName, "d05.blv"))
     return false;
-  DstBuf = malloc(0xF4240u);
+  DstBuf = malloc(0xF4240);
   pDir.Reset();
-    v52 = pParty->vPosition.x;
-    v51 = pParty->vPosition.y;
-    v62 = pParty->vPosition.z;
-    v53 = pParty->sRotationY;
-    v54 = pParty->sRotationX;
+  pPositionX = pParty->vPosition.x;
+  v51 = pParty->vPosition.y;
+  v62 = pParty->vPosition.z;
+  v53 = pParty->sRotationY;
+  v54 = pParty->sRotationX;
   pParty->vPosition.x = pParty->vPrevPosition.x;
   pParty->vPosition.y = pParty->vPrevPosition.z;
   pParty->vPosition.z = pParty->vPrevPosition.y;
@@ -321,317 +318,278 @@
     pIndoor->stru1.uLastVisitDay = pParty->uTimePlayed;
   else
     pOutdoor->uLastVisitDay = pParty->uTimePlayed;
-  v3 = MakeScreenshot(150, 112);
+  pScreenshot = MakeScreenshot(150, 112);
   strcpy(pDir.pFilename, "image.pcx");
-  pRenderer->_49F5A2((int)v3, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
-  free(v3);
-  if ( pCurrentScreen == 11 )//Save
-    {
-      pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
-      pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0));
-      v4 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[190]);
-      pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение
-      v5 = pFontSmallnum->AlignText_Center(0xBAu, (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
-      pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot), 185, 0);
-      v6 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[165]);
-      pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите
-      pRenderer->Present();
-    }
-    if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
-    {
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d
-      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
-    }
-  else
-    {
-      v7 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp";
-    }
-    strcpy(Dest, pCurrentMapName);
-    v45 = pParty->uTimePlayed;
-    strcpy((char *)&pDir, "header.bin");
-    pDir.uDataSize = 100;
-    if ( pNew_LOD->Write(&pDir, &v43, 0) )
-    {
-      v39 = 201;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201);
+  pRenderer->_49F5A2((int)pScreenshot, 150, 112, DstBuf, 1000000, (int)&pDir.uDataSize);
+  free(pScreenshot);
+  if ( pCurrentScreen == 11 )//SaveScreen
+  {
+    pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+    pRenderer->DrawTextureIndexed(0x12, 0x8D, (Texture *)(uTextureID_save_up != -1 ? &pIcons_LOD->pTextures[uTextureID_save_up] : 0));
+    v4 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[190]);
+    pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v4 + 25, 219, 0, pGlobalTXT_LocalizationStrings[190], 0, 0, 0); //Сохранение
+    v5 = pFontSmallnum->AlignText_Center(0xBA, (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
+    pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v5 + 25, 0x103u, 0, (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot), 185, 0);
+    v6 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[165]);
+    pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v6 + 25, 299, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); //Пожалуйста, подождите
+    pRenderer->Present();
+   }
+  if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //Сохраненная игра повреждена! Code=%d
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
+  }
+  strcpy(Dest, pCurrentMapName);
+  pTimePlayed = pParty->uTimePlayed;
+  strcpy((char *)&pDir, "header.bin");
+  pDir.uDataSize = 100;
+  if ( pNew_LOD->Write(&pDir, &v43, 0) )
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
-    }
-    strcpy((char *)&pDir, "party.bin");
-    pDir.uDataSize = 90680;
-    if ( pNew_LOD->Write(&pDir, &pParty, 0) )
-    {
-      v39 = 202;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202);
+  }
+  strcpy((char *)&pDir, "party.bin");
+  pDir.uDataSize = 90680;
+  if ( pNew_LOD->Write(&pDir, &pParty, 0) )
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
-    }
-    strcpy((char *)&pDir, "clock.bin");
-    pDir.uDataSize = 40;
-    if ( pNew_LOD->Write(&pDir, &pEventTimer, 0) )
+  }
+  strcpy((char *)&pDir, "clock.bin");
+  pDir.uDataSize = 40;
+  if ( pNew_LOD->Write(&pDir, &pEventTimer, 0) )
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
+  }
+  strcpy((char *)&pDir, "overlay.bin");
+  pDir.uDataSize = 1008;
+  if ( pNew_LOD->Write(&pDir, &pOtherOverlayList, 0) )
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
+  }
+  strcpy((char *)&pDir, "npcdata.bin");
+  pDir.uDataSize = 38076;
+  if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) )
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
+  }
+  strcpy((char *)&pDir, "npcgroup.bin");
+  pDir.uDataSize = 102;
+  if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) )
+  {
+    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206);
+    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
+  }
+  for (int i =  1; i <= 4; ++i) // 4 - players
+  {
+    for (int j =  1; j <= 5; ++j) // 5 - images
     {
-      v39 = 203;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
-    }
-    strcpy((char *)&pDir, "overlay.bin");
-    pDir.uDataSize = 1008;
-    if ( pNew_LOD->Write(&pDir, &pOtherOverlayList, 0) )
+      sprintf(Str, "data\\lloyd%d%d.pcx", i, j);
+      v8 = fopen(Str, "rb");
+      if ( v8 )
+      {
+        sprintf(Str, "lloyd%d%d.pcx", i, j);
+        fseek(v8, 0, 2);
+        pDir.uDataSize = ftell(v8);
+        rewind(v8);
+        fread(DstBuf, pDir.uDataSize, 1, v8);
+        strcpy((char *)&pDir, Str);
+        fclose(v8);
+        remove(Str);
+        if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
+        {
+          sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207);
+          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
+          Size = 5080748;
+        }
+      }
+	}
+  }
+  if ( !a2 )
+  {
+    sub_42FA22_mess_with_laying_item_list();
+    v9 = (int)malloc(0xF4240);
+    v71 = (std::string *)v9;
+    Src = 91969;
+    v56 = 109;
+    v57 = 118;
+    v58 = 105;
+    v59 = 105;
+    v60 = 0;
+    v61 = 0;
+    memcpy((void *)v9, &Src, 0x10);
+    if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
     {
-      v39 = 204;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
-    }
-    strcpy((char *)&pDir, "npcdata.bin");
-    pDir.uDataSize = 38076;
-    if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) )
-    {
-      v39 = 205;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
-    }
-    strcpy((char *)&pDir, "npcgroup.bin");
-    pDir.uDataSize = 102;
-    if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) )
-    {
-      v39 = 206;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
+      pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces;
+      pIndoor->dlv.uNumBModels = 0;
+      pIndoor->dlv.uNumDecorations = uNumLevelDecorations;
+      memcpy(DstBuf, &pIndoor->dlv, 0x28);
+      v10 = (char *)DstBuf + 40;
+      memcpy(v10, pIndoor->_visible_outlines, 0x36B);
+      v11 = (char *)v10 + 875;
+      if ( (signed int)pIndoor->uNumFaces > 0 )
+      {
+        v68 = 0;
+        for (int i =  0; i <= (signed int)pIndoor->uNumFaces; ++i)
+        {
+          v38 = (char *)v68 + (unsigned int)pIndoor->pFaces + 44;
+          memcpy(v11, v38, 4);
+          v68 += 48;
+          v11 = (char *)v11 + 4;
+        }
+      }
+      if ( (signed int)uNumLevelDecorations > 0 )
+      {
+        v68 = &pLevelDecorations[0].field_2;
+        for (int i =  0; i <= (signed int)uNumLevelDecorations; ++i)
+        {
+          memcpy(v11, v68, 2);
+          v68 += 16;
+          v11 = (char *)v11 + 2;
+        }
+      }
+      memcpy(v11, &uNumActors, 4);
+      v12 = (char *)v11 + 4;
+      memcpy(v12, pActors, 836 * uNumActors);
+      v13 = (char *)v12 + 836 * uNumActors;
+      memcpy(v13, &uNumLayingItems, 4);
+      v13 = (char *)v13 + 4;
+      memcpy(v13, pLayingItems, 112 * uNumLayingItems);
+      v14 = (char *)v13 + 112 * uNumLayingItems;
+      memcpy(v14, &uNumChests, 4);
+      v14 = (char *)v14 + 4;
+      memcpy(v14, pChests, 5324 * uNumChests);
+      v15 = (char *)v14 + 5324 * uNumChests;
+      memcpy(v15, pIndoor->pDoors, 0x3E80);
+      v15 = (char *)v15 + 16000;
+      memcpy(v15, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size);
+      v16 = (char *)v15 + pIndoor->blv.uDoors_ddata_Size;
+      memcpy(v16, &stru_5E4C90, 0xC8);
+      v17 = (int)((char *)v16 + 200);
+      memcpy((void *)v17, &pIndoor->stru1, 0x38);
     }
-    v70 = 1;
-    do
-    {
-      v69 = 1;
-      do
-      {
-        v39 = v69;
-        v38 = (const char *)v70;
-        sprintf(Str, "data\\lloyd%d%d.pcx", v70, v69);
-        v8 = fopen(Str, "rb");
-        if ( v8 )
-        {
-          v39 = v69;
-          v38 = (const char *)v70;
-          sprintf(Str, "lloyd%d%d.pcx", v70, v69);
-          fseek(v8, 0, 2);
-          pDir.uDataSize = ftell(v8);
-          rewind(v8);
-          fread(DstBuf, pDir.uDataSize, 1u, v8);
-          strcpy((char *)&pDir, Str);
-          fclose(v8);
-          remove(Str);
-          if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
-          {
-            v39 = 207;
-            sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
-            Size = 5080748;
-          }
-        }
-        ++v69;
-      }
-      while ( (signed int)v69 <= 5 );
-      ++v70;
-    }
-    while ( v70 <= 4 );
-    if ( !a2 )
+    else
     {
-      sub_42FA22_mess_with_laying_item_list();
-      v9 = (int)malloc(0xF4240u);
-      v71 = (std::string *)v9;
-      Src = 91969;
-      v56 = 109;
-      v57 = 118;
-      v58 = 105;
-      v59 = 105;
-      v60 = 0;
-      v61 = 0;
-      memcpy((void *)v9, &Src, 0x10u);
-      if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
+      v18 = 0;
+      pOutdoor->ddm.uNumFacesInBModels = 0;
+      if ( (signed int)pOutdoor->uNumBModels > 0 )
       {
-        v10 = DstBuf;
-        pIndoor->dlv.uNumFacesInBModels = pIndoor->uNumFaces;
-        pIndoor->dlv.uNumBModels = 0;
-        pIndoor->dlv.uNumDecorations = uNumLevelDecorations;
-        memcpy(DstBuf, &pIndoor->dlv, 0x28u);
-        v10 = (char *)v10 + 40;
-        memcpy(v10, pIndoor->_visible_outlines, 0x36Bu);
-        v11 = (char *)v10 + 875;
-        v70 = 0;
-        if ( (signed int)pIndoor->uNumFaces > 0 )
+        v19 = pOutdoor->uNumBModels;
+        v20 = (char *)&pOutdoor->pBModels->uNumFaces;
+        do
         {
-          v68 = 0;
-          do
-          {
-            v38 = (char *)v68 + (unsigned int)pIndoor->pFaces + 44;
-            memcpy(v11, v38, 4u);
-            v68 += 48;
-            v11 = (char *)v11 + 4;
-            ++v70;
-          }
-          while ( v70 < (signed int)pIndoor->uNumFaces );
+          v18 += *(int *)v20;
+          v20 += 188;
+          --v19;
+          pOutdoor->ddm.uNumFacesInBModels = v18;
         }
-        v70 = 0;
-        if ( (signed int)uNumLevelDecorations > 0 )
+        while ( v19 );
+      }
+      v21 = DstBuf;
+      pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels;
+      pOutdoor->ddm.uNumDecorations = uNumLevelDecorations;
+      memcpy(DstBuf, &pOutdoor->ddm, 0x28);
+      v21 = (char *)v21 + 40;
+      memcpy(v21, pOutdoor->array_528, 0x3C8);
+      v21 = (char *)v21 + 968;
+      memcpy(v21, pOutdoor->array_8F0, 0x3C8);
+      v22 = (char *)v21 + 968;
+      if ( (signed int)pOutdoor->uNumBModels > 0 )
+      {
+        v23 = pOutdoor->pBModels;
+        v24 = 76;
+        for (int i =  0; i <= (signed int)pOutdoor->uNumBModels ; ++i)
         {
-          v68 = &pLevelDecorations[0].field_2;
-          do
+          v25 = *(int *)&v23->pModelName[v24] == 0;
+          v26 = *(int *)&v23->pModelName[v24] < 0;
+          if ( !(v26 | v25) )
           {
-            memcpy(v11, v68, 2u);
-            v68 += 16;
-            v11 = (char *)v11 + 2;
-            ++v70;
-          }
-          while ( v70 < (signed int)uNumLevelDecorations );
-        }
-        memcpy(v11, &uNumActors, 4u);
-        v12 = (char *)v11 + 4;
-        memcpy(v12, pActors, 836 * uNumActors);
-        v13 = (char *)v12 + 836 * uNumActors;
-        memcpy(v13, &uNumLayingItems, 4u);
-        v13 = (char *)v13 + 4;
-        memcpy(v13, pLayingItems, 112 * uNumLayingItems);
-        v14 = (char *)v13 + 112 * uNumLayingItems;
-        memcpy(v14, &uNumChests, 4u);
-        v14 = (char *)v14 + 4;
-        memcpy(v14, pChests, 5324 * uNumChests);
-        v15 = (char *)v14 + 5324 * uNumChests;
-        memcpy(v15, pIndoor->pDoors, 0x3E80u);
-        v15 = (char *)v15 + 16000;
-        memcpy(v15, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size);
-        v16 = (char *)v15 + pIndoor->blv.uDoors_ddata_Size;
-        memcpy(v16, &stru_5E4C90, 0xC8u);
-        v17 = (int)((char *)v16 + 200);
-        memcpy((void *)v17, &pIndoor->stru1, 0x38u);
-      }
-      else
-      {
-        v18 = 0;
-        pOutdoor->ddm.uNumFacesInBModels = 0;
-        if ( (signed int)pOutdoor->uNumBModels > 0 )
-        {
-          v19 = pOutdoor->uNumBModels;
-          v20 = (char *)&pOutdoor->pBModels->uNumFaces;
-          do
-          {
-            v18 += *(int *)v20;
-            v20 += 188;
-            --v19;
-            pOutdoor->ddm.uNumFacesInBModels = v18;
-          }
-          while ( v19 );
-        }
-        v21 = DstBuf;
-        pOutdoor->ddm.uNumBModels = pOutdoor->uNumBModels;
-        pOutdoor->ddm.uNumDecorations = uNumLevelDecorations;
-        memcpy(DstBuf, &pOutdoor->ddm, 0x28u);
-        v21 = (char *)v21 + 40;
-        memcpy(v21, pOutdoor->array_528, 0x3C8u);
-        v21 = (char *)v21 + 968;
-        memcpy(v21, pOutdoor->array_8F0, 0x3C8u);
-        v22 = (char *)v21 + 968;
-        v70 = 0;
-        if ( (signed int)pOutdoor->uNumBModels > 0 )
-        {
-          v23 = pOutdoor->pBModels;
-          v24 = 76;
-          do
-          {
-            v25 = *(int *)&v23->pModelName[v24] == 0;
-            v26 = *(int *)&v23->pModelName[v24] < 0;
-            v66 = 0;
-            if ( !(v26 | v25) )
+            v68 = 0;
+            for (int j =  0; j <= *(int *)&pOutdoor->pBModels->pModelName[v24]; ++j)
             {
-              v68 = 0;
-              do
-              {
-                v38 = (char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28;
-                memcpy(v22, v38, 4u);
-                v23 = pOutdoor->pBModels;
-                v68 += 154;
-                v22 = (char *)v22 + 4;
-                v66 = (__int16 *)((char *)v66 + 1);
-              }
-              while ( (signed int)v66 < *(int *)&pOutdoor->pBModels->pModelName[v24] );
+              v38 = (char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28;
+              memcpy(v22, v38, 4);
+              v23 = pOutdoor->pBModels;
+              v68 += 154;
+              v22 = (char *)v22 + 4;
             }
-            ++v70;
-            v24 += 188;
-          }
-          while ( v70 < (signed int)pOutdoor->uNumBModels );
+           }
+          v24 += 188;
         }
-        v27 = 0;
-        if ( (signed int)uNumLevelDecorations > 0 )
+      }
+      if ( (signed int)uNumLevelDecorations > 0 )
+      {
+        v66 = &pLevelDecorations[0].field_2;
+        for (int i =  0; i <= (signed int)uNumLevelDecorations; ++i)
         {
-          v66 = &pLevelDecorations[0].field_2;
-          do
-          {
-            memcpy(v22, v66, 2u);
-            v66 += 16;
-            v22 = (char *)v22 + 2;
-            ++v27;
-          }
-          while ( v27 < (signed int)uNumLevelDecorations );
+          memcpy(v22, v66, 2);
+          v66 += 16;
+          v22 = (char *)v22 + 2;
         }
-        memcpy(v22, &uNumActors, 4u);
-        v28 = (char *)v22 + 4;
-        memcpy(v28, pActors, 836 * uNumActors);
-        v29 = (char *)v28 + 836 * uNumActors;
-        memcpy(v29, &uNumLayingItems, 4u);
-        v29 = (char *)v29 + 4;
-        memcpy(v29, pLayingItems, 112 * uNumLayingItems);
-        v30 = (char *)v29 + 112 * uNumLayingItems;
-        memcpy(v30, &uNumChests, 4u);
-        v30 = (char *)v30 + 4;
-        memcpy(v30, pChests, 5324 * uNumChests);
-        v31 = (char *)v30 + 5324 * uNumChests;
-        memcpy(v31, &stru_5E4C90, 0xC8u);
-        v17 = (int)((char *)v31 + 200);
-        memcpy((void *)v17, &pOutdoor->uLastVisitDay, 0x38u);
-        v9 = (int)v71;
       }
-      v32 = v17 + 56;
-      strcpy(Source, pCurrentMapName);
-      _splitpath(Source, &Drive, &Dir, &Filename, &Ext);
-      v48 = 100;
-      Size = v32 - (int)DstBuf;
-      v69 = 999984;
-      LOBYTE(v33) = zlib::MemZip((char *)v9 + 16, (unsigned int *)&v69, DstBuf, v32 - (int)DstBuf);
-      if ( v33 || (signed int)v69 > (signed int)Size )
-      {
-        memcpy((void *)(v9 + 16), DstBuf, Size);
-        v69 = Size;
-      }
-      v69 += 16;
-      memcpy((void *)(v9 + 8), &v69, 4u);
-      memcpy((void *)(v9 + 12), &Size, 4u);
-      sprintf(Source, "%s%s", &Filename, &Ext);
-      strcpy((char *)&pDir, Source);
-      pDir.uDataSize = v69;
-      if ( pNew_LOD->Write(&pDir, (const void *)v9, 0) )
-      {
-        v39 = 208;
-        sprintf(Str, pGlobalTXT_LocalizationStrings[612], 208);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
-      }
-      free((void *)v9);
+      memcpy(v22, &uNumActors, 4);
+      v28 = (char *)v22 + 4;
+      memcpy(v28, pActors, 836 * uNumActors);
+      v29 = (char *)v28 + 836 * uNumActors;
+      memcpy(v29, &uNumLayingItems, 4);
+      v29 = (char *)v29 + 4;
+      memcpy(v29, pLayingItems, 112 * uNumLayingItems);
+      v30 = (char *)v29 + 112 * uNumLayingItems;
+      memcpy(v30, &uNumChests, 4);
+      v30 = (char *)v30 + 4;
+      memcpy(v30, pChests, 5324 * uNumChests);
+      v31 = (char *)v30 + 5324 * uNumChests;
+      memcpy(v31, &stru_5E4C90, 0xC8);
+      v17 = (int)((char *)v31 + 200);
+      memcpy((void *)v17, &pOutdoor->uLastVisitDay, 0x38);
+      v9 = (int)v71;
+    }
+    v32 = v17 + 56;
+    strcpy(Source, pCurrentMapName);
+    _splitpath(Source, &Drive, &Dir, &Filename, &Ext);
+    v48 = 100;
+    Size = v32 - (int)DstBuf;
+    v69 = 999984;
+    LOBYTE(v33) = zlib::MemZip((char *)v9 + 16, (unsigned int *)&v69, DstBuf, v32 - (int)DstBuf);
+    if ( v33 || (signed int)v69 > (signed int)Size )
+    {
+      memcpy((void *)(v9 + 16), DstBuf, Size);
+      v69 = Size;
     }
-    free(DstBuf);
-    if ( a1 )
+    v69 += 16;
+    memcpy((void *)(v9 + 8), &v69, 4);
+    memcpy((void *)(v9 + 12), &Size, 4);
+    sprintf(Source, "%s%s", &Filename, &Ext);
+    strcpy((char *)&pDir, Source);
+    pDir.uDataSize = v69;
+    if ( pNew_LOD->Write(&pDir, (const void *)v9, 0) )
     {
-      if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
-      {
-        v34 = GetLastError();
-        FormatMessageA(0x1000u, 0, v34, 0x400u, &Buffer, 0x80u, 0);
-        v39 = 300;
-        sprintf(Str, pGlobalTXT_LocalizationStrings[612], 300);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
-      }
+      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 208);
+      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
     }
-    pParty->vPosition.x = v52;
-    pParty->vPosition.y = v51;
-    pParty->vPosition.z = v62;
-    pParty->uFallStartY = v62;
-    pParty->sRotationY = v53;
-    result = v54;
-    pParty->sRotationX = v54;
+    free((void *)v9);
+  }
+  free(DstBuf);
+  if ( a1 )
+  {
+    if ( !CopyFileA("data\\new.lod", "saves\\autosave.mm7", 0) )
+    {
+      v34 = GetLastError();
+      FormatMessageA(0x1000, 0, v34, 0x400, &Buffer, 0x80, 0);
+      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 300);
+      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
+    }
+  }
+  pParty->vPosition.x = pPositionX;
+  pParty->vPosition.y = v51;
+  pParty->vPosition.z = v62;
+  pParty->uFallStartY = v62;
+  pParty->sRotationY = v53;
+  result = v54;
+  pParty->sRotationX = v54;
   return result;
 }