changeset 94:6c42178c226e

minor things
author Nomad
date Fri, 02 Nov 2012 14:42:09 +0200
parents c97dfd4b9600
children b5e26a133fae
files GameUIs.cpp Outdoor.cpp Outdoor.h SaveLoad.cpp SaveLoad.h mm7_2.cpp mm7_3.cpp mm7_data.h
diffstat 8 files changed, 139 insertions(+), 120 deletions(-) [+]
line wrap: on
line diff
--- a/GameUIs.cpp	Thu Nov 01 12:02:00 2012 +0200
+++ b/GameUIs.cpp	Fri Nov 02 14:42:09 2012 +0200
@@ -1,5 +1,6 @@
 #include <direct.h>
 #include <io.h>
+#include <assert.h>
 
 #include "GUIWindow.h"
 #include "GUIFont.h"
@@ -15,18 +16,18 @@
 {
   unsigned int v1; // ebp@5
   unsigned int v2; // eax@5
-  signed int v3; // ebp@11
+  //signed int v3; // ebp@11
   FILE *v4; // eax@14
   FILE *v5; // eax@18
   unsigned int v6; // eax@25
   GUIButton *v7; // eax@27
   const char *v8; // [sp-8h] [bp-26Ch]@25
-  char *v9; // [sp-4h] [bp-268h]@19
+  //char *v9; // [sp-4h] [bp-268h]@19
   enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25
   unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1
-  RGBTexture *pTex; // [sp+10h] [bp-254h]@12
-  SavegameHeader *Dest; // [sp+14h] [bp-250h]@12
-  const char *Str1; // [sp+18h] [bp-24Ch]@12
+  //RGBTexture *pTex; // [sp+10h] [bp-254h]@12
+  //SavegameHeader *Dest; // [sp+14h] [bp-250h]@12
+  //const char *Str1; // [sp+18h] [bp-24Ch]@12
   LODWriteableFile v15; // [sp+1Ch] [bp-248h]@1
   int v16; // [sp+260h] [bp-4h]@1
 
@@ -51,7 +52,7 @@
     pRenderer->DrawTextureIndexed(
       8u,
       8u,
-      (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+      (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
     if ( pCurrentScreen == 11 )
     {
       v1 = uTextureID_save_up;
@@ -67,7 +68,7 @@
     pRenderer->DrawTextureIndexed(
       351u,
       302u,
-      (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0));
+      (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
   }
   else
   {
@@ -90,46 +91,55 @@
     uLoadGameUI_SelectedSlot = 0;
   }
   v15.AllocSubIndicesAndIO(0x12Cu, 0);
-  v3 = 0;
-  if ( (signed int)uNumSavegameFiles > 0 )
+
+  assert(sizeof(SavegameHeader) == 0x64);
+
+  //v3 = 0;
+  for (uint i = 0; i < uNumSavegameFiles; ++i)
   {
-    Dest = pSavegameHeader;
-    pTex = pSavegameThumbnails;
-    Str1 = (const char *)pSavegameList->pSavesNames;
-    while ( 1 )
+    //Dest = pSavegameHeader;
+    //pTex = pSavegameThumbnails;
+    //Str1 = (const char *)pSavegameList->pSavesNames;
+    //while ( 1 )
+    //{
+    sprintf(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[i]);
+    if (_access(pTmpBuf, 6))
     {
-      sprintf(pTmpBuf, "saves\\%s", Str1);
-      if ( _access(pTmpBuf, 6) )
-        break;
-      v15.LoadFile(pTmpBuf, 1);
-      v4 = v15.FindContainer("header.bin", true);
-      if ( v4 )
-        fread(Dest, 0x64u, 1u, v4);
-      if ( !_strcmpi(Str1, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
-        strcpy(Dest->pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave"
-      v5 = v15.FindContainer("image.pcx", true);
-      if ( !v5 )
-      {
-        v9 = "";
-LABEL_22:
-        pSavegameUsedSlots[v3] = 0;
-        strcpy(Dest->pName, v9);
-        goto LABEL_23;
-      }
-      pTex->LoadFromFILE(v5, 0, true);
+      pSavegameUsedSlots[i] = 0;
+      strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty"
+      continue;
+    }
+
+    v15.LoadFile(pTmpBuf, 1);
+    v4 = v15.FindContainer("header.bin", true);
+    if ( v4 )
+      fread(&pSavegameHeader[i], 0x64u, 1u, v4);
+    if ( !_strcmpi(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7"
+      strcpy(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[16]);// "Autosave"
+
+    v5 = v15.FindContainer("image.pcx", true);
+    if ( !v5 )
+    {
+      pSavegameUsedSlots[i] = 0;
+      strcpy(pSavegameList->pSavesNames[i], "");
+    }
+    else
+    {
+      pSavegameThumbnails[i].LoadFromFILE(v5, 0, true);
       v15.CloseWriteFile();
-      pSavegameUsedSlots[v3] = 1;
-LABEL_23:
-      Str1 += 280;
-      ++pTex;
-      ++Dest;
-      ++v3;
-      if ( v3 >= (signed int)uNumSavegameFiles )
-        goto LABEL_24;
+      pSavegameUsedSlots[i] = 1;
     }
-    v9 = pGlobalTXT_LocalizationStrings[72];    // "Empty"
-    goto LABEL_22;
+//LABEL_23:
+      //Str1 += 280;
+      //++pTex;
+      //++Dest;
+      //++v3;
+      //if ( v3 >= (signed int)uNumSavegameFiles )
+      //  goto LABEL_24;
+    //}
+    //goto LABEL_22;
   }
+
 LABEL_24:
   v15.FreeSubIndexAndIO();
   if ( pCurrentScreen == 11 )
--- a/Outdoor.cpp	Thu Nov 01 12:02:00 2012 +0200
+++ b/Outdoor.cpp	Fri Nov 02 14:42:09 2012 +0200
@@ -703,23 +703,27 @@
 //----- (0047C7C2) --------------------------------------------------------
 void OutdoorLocationTerrain::Release()
 {
-  OutdoorLocationTerrain *v1; // esi@1
-  void *v2; // ST00_4@1
-  void *v3; // ST00_4@1
-  void *v4; // ST00_4@1
+  if (pHeightmap)
+  {
+    pAllocator->FreeChunk(this->pHeightmap);
+    pHeightmap = nullptr;
+  }
+  if (pTilemap)
+  {
+    pAllocator->FreeChunk(pTilemap);
+    pTilemap = nullptr;
+  }
+  if (pAttributemap)
+  {
+    pAllocator->FreeChunk(pAttributemap);
+    pAttributemap = nullptr;
+  }
+  if (ptr_C)
+  {
+    pAllocator->FreeChunk(ptr_C);
+    ptr_C = nullptr;
+  }
 
-  v1 = this;
-  pAllocator->FreeChunk(this->pHeightmap);
-  v2 = v1->pTilemap;
-  v1->pHeightmap = 0;
-  pAllocator->FreeChunk(v2);
-  v3 = v1->pAttributemap;
-  v1->pTilemap = 0;
-  pAllocator->FreeChunk(v3);
-  v4 = v1->ptr_C;
-  v1->pAttributemap = 0;
-  pAllocator->FreeChunk(v4);
-  v1->ptr_C = 0;
   _47C7A9();
 }
 
@@ -1111,49 +1115,59 @@
 //----- (0047CF9C) --------------------------------------------------------
 void OutdoorLocation::Release()
 {
-  OutdoorLocation *v1; // esi@1
-  signed int v2; // edi@1
-  int v3; // ebx@2
-  void *v4; // ST24_4@4
-  char *v5; // ebx@4
-  void **v6; // esi@4
+  //OutdoorLocation *v1; // esi@1
+  //signed int v2; // edi@1
+  //int v3; // ebx@2
+  //void *v4; // ST24_4@4
+  //char *v5; // ebx@4
+  //void **v6; // esi@4
 
-  v1 = this;
-  strcpy(this->pLevelFilename, "blank");
-  strcpy(v1->pLocationFileName, "default.odm");
-  strcpy(v1->pLocationFileDescription, "MM6 Outdoor v1.00");
-  strcpy(v1->pSkyTextureName, "sky043");
-  strcpy(v1->pGroundTileset, "hm005");
-  v2 = 0;
-  if ( (signed int)v1->uNumBModels > 0 )
+  //v1 = this;
+  strcpy(pLevelFilename, "blank");
+  strcpy(pLocationFileName, "default.odm");
+  strcpy(pLocationFileDescription, "MM6 Outdoor v1.00");
+  strcpy(pSkyTextureName, "sky043");
+  strcpy(pGroundTileset, "hm005");
+
+  if (pBModels)
+  {
+    for (uint i = 0; i < uNumBModels; ++i)
+      pBModels[i].Release();
+
+    pAllocator->FreeChunk(pBModels);
+    pBModels = nullptr;
+    uNumBModels = 0;
+  }
+
+  if (pSpawnPoints)
   {
-    v3 = 0;
-    do
-    {
-      ((BSPModel *)((char *)&v1->pBModels[v3] + 68))->Release();
-      ++v2;
-      ++v3;
-    }
-    while ( v2 < (signed int)v1->uNumBModels );
+    pAllocator->FreeChunk(pSpawnPoints);
+    pSpawnPoints = nullptr;
+  }
+  uNumSpawnPoints = 0;
+
+  pTerrain.Release();
+
+  if (ptr_D4)
+  {
+    pAllocator->FreeChunk(ptr_D4);
+    ptr_D4 = nullptr;
   }
-  v1->uNumBModels = 0;
-  v4 = v1->pBModels;
-  v1->uNumSpawnPoints = 0;
-  pAllocator->FreeChunk(v4);
-  pAllocator->FreeChunk(v1->pSpawnPoints);
-  v1->pBModels = 0;
-  v1->pSpawnPoints = 0;
-  v1->pTerrain.Release();
-  pAllocator->FreeChunk(v1->ptr_D4);
-  v1->ptr_D4 = 0;
-  v5 = (char *)&v1->pOMAP;
-  pAllocator->FreeChunk(v1->pOMAP);
-  v6 = (void **)&v1->pFaceIDLIST;
-  *(int *)v5 = 0;
-  pAllocator->FreeChunk(*v6);
-  *v6 = 0;
-  pAllocator->FreeChunk(pTerrainNormals);
-  pTerrainNormals = 0;
+  if (pOMAP)
+  {
+    pAllocator->FreeChunk(pOMAP);
+    pOMAP = nullptr;
+  }
+  if (pFaceIDLIST)
+  {
+    pAllocator->FreeChunk(pFaceIDLIST);
+    pFaceIDLIST = nullptr;
+  }
+  if (pTerrainNormals)
+  {
+    pAllocator->FreeChunk(pTerrainNormals);
+    pTerrainNormals = nullptr;
+  }
 }
 
 //----- (0047D0A6) --------------------------------------------------------
@@ -1336,7 +1350,7 @@
   }
 LABEL_8:
   _6807E0_num_decorations_6807B8 = 0;
-  sprintfex(FileName, "levels\\%s", pContainer);
+  sprintf(FileName, "levels\\%s", pContainer);
   if ( GetFileAttributesA(FileName) != -1 )
   {
     result = (bool)fopen(FileName, "rb");
@@ -1727,7 +1741,7 @@
       v5->pBModels[v48].pNodes = 0;
       FileName[0] = 0;
       v108 = (int)&v5->pBModels[v48];
-      sprintfex(FileName, "%s", v108);
+      sprintf(FileName, "%s", v108);
       v49 = v5->pBModels;
       v138 = 0;
       v50 = &v49[v48];
--- a/Outdoor.h	Thu Nov 01 12:02:00 2012 +0200
+++ b/Outdoor.h	Fri Nov 02 14:42:09 2012 +0200
@@ -42,6 +42,8 @@
     this->ptr_C = 0;
     this->field_10 = 0;
     this->field_12 = 0;
+
+    pAttributemap = nullptr;
   }
 
   void _47C7A9();
--- a/SaveLoad.cpp	Thu Nov 01 12:02:00 2012 +0200
+++ b/SaveLoad.cpp	Fri Nov 02 14:42:09 2012 +0200
@@ -27,8 +27,8 @@
 struct SavegameList *pSavegameList = new SavegameList;
 unsigned int uNumSavegameFiles;
 unsigned int pSavegameUsedSlots[45];
-struct RGBTexture *pSavegameThumbnails = new RGBTexture[45];
-SavegameHeader *pSavegameHeader = new SavegameHeader[45];
+struct RGBTexture pSavegameThumbnails[45];
+SavegameHeader    pSavegameHeader[45];
 
 
 
--- a/SaveLoad.h	Thu Nov 01 12:02:00 2012 +0200
+++ b/SaveLoad.h	Fri Nov 02 14:42:09 2012 +0200
@@ -29,5 +29,6 @@
 
 extern unsigned int uNumSavegameFiles;
 extern unsigned int pSavegameUsedSlots[45];
-extern struct SavegameList *pSavegameList;
-extern struct RGBTexture *pSavegameThumbnails;
\ No newline at end of file
+extern struct SavegameList  *pSavegameList;
+extern struct RGBTexture     pSavegameThumbnails[];
+extern struct SavegameHeader pSavegameHeader[];
\ No newline at end of file
--- a/mm7_2.cpp	Thu Nov 01 12:02:00 2012 +0200
+++ b/mm7_2.cpp	Fri Nov 02 14:42:09 2012 +0200
@@ -11471,7 +11471,7 @@
     pRenderer->DrawTextureIndexed(
       8u,
       8u,
-      (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+      uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0);
     if ( a4 )
     {
       v2 = uTextureID_save_up;
@@ -11482,23 +11482,20 @@
       v2 = uTextureID_load_up;
       v3 = uTextureID_LS_loadU;
     }
-    pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0));
-    pRenderer->DrawTextureIndexed(0x12u, 0x8Bu, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
-    pRenderer->DrawTextureIndexed(
-      0x15Fu,
-      0x12Eu,
-      (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0));
+    pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0));
+    pRenderer->DrawTextureIndexed(18, 139, (Texture *)(v2 != -1 ? &pIcons_LOD->pTextures[v2] : 0));
+    pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
     v1 = 255;
   }
   if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] )
   {
     memset(&Dst, 0, 0x54u);
     Dst.uFrameX = pGUIWindow_CurrentMenu->uFrameX + 240;
-    v4 = pGUIWindow_CurrentMenu->uFrameY - LOBYTE(pFontSmallnum->uFontHeight);
+    v4 = pGUIWindow_CurrentMenu->uFrameY - pFontSmallnum->uFontHeight;
     Dst.uFrameWidth = 220;
     v4 += 157;
     Dst.uFrameY = v4;
-    v5 = LOBYTE(pFontSmallnum->uFontHeight);
+    v5 = pFontSmallnum->uFontHeight;
     Dst.uFrameZ = Dst.uFrameX + 219;
     Dst.uFrameHeight = v5;
     Dst.uFrameW = v5 + v4 - 1;
@@ -11592,10 +11589,10 @@
     v18 = pGlobalTXT_LocalizationStrings[135];
     v19 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[135]);
     pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v19 + 25, 220, 0, v18, 0, 0, 0);
-    v20 = (const char *)(&pSavegameHeader + uLoadGameUI_SelectedSlot);
+    v20 = (const char *)(pSavegameHeader + uLoadGameUI_SelectedSlot);
     v21 = pFontSmallnum->AlignText_Center(
             0xBAu,
-            (const char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
+            (const char *)pSavegameHeader + 100 * uLoadGameUI_SelectedSlot);
     pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v21 + 25, 0x106u, 0, v20, 185, 0);
     v22 = pGlobalTXT_LocalizationStrings[165];
     v23 = pFontSmallnum->AlignText_Center(0xBAu, pGlobalTXT_LocalizationStrings[165]);
--- a/mm7_3.cpp	Thu Nov 01 12:02:00 2012 +0200
+++ b/mm7_3.cpp	Fri Nov 02 14:42:09 2012 +0200
@@ -2174,10 +2174,6 @@
     goto LABEL_74;
   }
 }
-// 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int);
-// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int);
-// 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int);
-
 
 
 
--- a/mm7_data.h	Thu Nov 01 12:02:00 2012 +0200
+++ b/mm7_data.h	Fri Nov 02 14:42:09 2012 +0200
@@ -2224,7 +2224,6 @@
 extern int dword_69B010[64];
 extern float flt_69B138_dist; // weak
 extern char byte_69BD41_unused; // weak
-extern struct SavegameHeader *pSavegameHeader;
 extern unsigned int uTextureID_x_u;
 extern unsigned int uTextureID_LS_saveU;
 extern unsigned int uTextureID_LS_loadU;