changeset 97:d7e68aebe0b3

Слияние
author Ritor1
date Sat, 03 Nov 2012 19:59:36 +0600
parents 51a5b0dc3f30 (current diff) b5e26a133fae (diff)
children 6305c1cd9f6e 2331a331d36a
files Indoor.cpp Outdoor.cpp SaveLoad.cpp mm7_2.cpp mm7_3.cpp mm7_4.cpp
diffstat 11 files changed, 285 insertions(+), 272 deletions(-) [+]
line wrap: on
line diff
--- a/GameUIs.cpp	Sat Nov 03 19:58:37 2012 +0600
+++ b/GameUIs.cpp	Sat Nov 03 19:59:36 2012 +0600
@@ -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/Indoor.cpp	Sat Nov 03 19:58:37 2012 +0600
+++ b/Indoor.cpp	Sat Nov 03 19:59:36 2012 +0600
@@ -453,8 +453,8 @@
   //char v21; // dl@27
   //unsigned int v22; // eax@44
   unsigned int v23; // eax@35
-  DWORD v24; // eax@37
-  int v25; // eax@38
+  //DWORD v24; // eax@37
+  //int v25; // eax@38
   //char *v26; // edi@38
   IDirect3DTexture2 *v27; // eax@42
   Texture *v28; // [sp+Ch] [bp-1Ch]@15
@@ -503,7 +503,7 @@
       static_vertices_F7C228[i].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[i]].y;
       static_vertices_F7C228[i].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[i]].z;
       static_vertices_F7C228[i].u = (signed short)pFace->pVertexUIDs[i];
-      static_vertices_F7C228[i].v = (signed short)pFace->pVertexUIDs[i];
+      static_vertices_F7C228[i].v = (signed short)pFace->pVertexVIDs[i];
     }
 
     if (!pVertices ||
@@ -568,19 +568,21 @@
 
         if (pFace->Animated())
         {
-          v24 = GetTickCount() / 4;
-          v25 = v24 - stru_5C6E00->uIntegerHalfPi;
-
+          //auto v24 = GetTickCount() / 4;
+          //auto v25 = v24 - stru_5C6E00->uIntegerHalfPi;
+          uint eightSeconds = GetTickCount() % 8000;
+          float angle = (eightSeconds / 8000.0f) * 2 * 3.1415f;
+
+          //animte lava back and forth
           for (uint i = 0; i < uNumVerticesa; ++i)
-            array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8));
+            //array_507D30[i].v += (double)(pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 & (unsigned int)(stru_5C6E00->SinCos(v25) >> 8));
+            array_507D30[i].v += pBitmaps_LOD->pTextures[pFace->uBitmapID].uHeightMinus1 * cosf(angle);
 
           v23 = pFace->uBitmapID;
           goto LABEL_42;
         }
-        else
+        else if (pFace->uAttributes & 0x4000)
         {
-          if (pFace->uAttributes & 0x4000)
-          {
             v23 = pTextureFrameTable->GetFrameTexture(
                             pFace->uBitmapID,
                             pBLVRenderParams->field_0_timer_);
@@ -591,7 +593,6 @@
                     else
                       pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | 6, v17, 0);
                     return;
-          }
         }
       }
     }
@@ -4445,9 +4446,9 @@
   }
   if ( !_strcmpi(pCurrentMapName, "out15.odm") || !_strcmpi(pCurrentMapName, "d23.blv") )
     bNoNPCHiring = 1;
-  pPaletteManager->field_267AD3 = 0;
-  pPaletteManager->field_267AD4 = 0;
-  pPaletteManager->field_267AD5 = 0;
+  pPaletteManager->pPalette_tintColor[0] = 0;
+  pPaletteManager->pPalette_tintColor[1] = 0;
+  pPaletteManager->pPalette_tintColor[2] = 0;
   pPaletteManager->RecalculateAll();
   if ( qword_A750D8 )
     qword_A750D8 = 0i64;
--- a/LightmapBuilder.cpp	Sat Nov 03 19:58:37 2012 +0600
+++ b/LightmapBuilder.cpp	Sat Nov 03 19:59:36 2012 +0600
@@ -264,6 +264,7 @@
     }
   }
 
+  __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	Sat Nov 03 19:58:37 2012 +0600
+++ b/Outdoor.cpp	Sat Nov 03 19:59:36 2012 +0600
@@ -366,7 +366,7 @@
   {
     v12 = (unsigned __int8)aTiletableLoadU[v10 + 39];
     uDefaultTravelTime_ByFoot = (unsigned __int8)byte_4ECA93[v10];
-    sprintf(pOut, "out%02d.odm", v12);
+    sprintfex(pOut, "out%02d.odm", v12);
     uLevel_StartingPointType = (unsigned __int8)byte_4ECACF[v10];
     return 1;
   }
@@ -703,28 +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;
-  if (v3)
-	{
-	pAllocator->FreeChunk(v3);
-	v3 = nullptr;
-	}
-  //pAllocator->FreeChunk(v3); 
-  v4 = v1->ptr_C;
-  v1->pAttributemap = 0;
-  pAllocator->FreeChunk(v4);
-  v1->ptr_C = 0;
   _47C7A9();
 }
 
@@ -1116,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) --------------------------------------------------------
@@ -1296,11 +1305,11 @@
   __int32 v134; // [sp+9A0h] [bp-1E0h]@38
   __int32 v135; // [sp+9ACh] [bp-1D4h]@38
   __int32 v136; // [sp+9D0h] [bp-1B0h]@10
-  char FileName[32]; // [sp+A20h] [bp-160h]@8
-  //char v138; // [sp+A28h] [bp-158h]@12
-  char v139; // [sp+B1Ch] [bp-64h]@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
-  char *v141; // [sp+B40h] [bp-40h]@50
+  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
@@ -1317,26 +1326,26 @@
   strcpy(pContainer, pFilename);
   if ( bUnderwater )
   {
-    pPaletteManager->field_267AD3 = 0x10u;
-    pPaletteManager->field_267AD4 = 0xC2u;
-    pPaletteManager->field_267AD5 = 0x99u;
-    pPaletteManager->field_267AD0 = 0x25u;
-    pPaletteManager->field_267AD1 = 0x8Fu;
-    pPaletteManager->field_267AD2 = 0x5Cu;
+    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->field_267AD3 = 0;
-  pPaletteManager->field_267AD4 = 0;
-  pPaletteManager->field_267AD5 = 0;
-  if ( pPaletteManager->field_267AD0 != 0x80u
-    || pPaletteManager->field_267AD1 != 0x80u
-    || pPaletteManager->field_267AD2 != 0x80u )
+  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 )
   {
-    pPaletteManager->field_267AD0 = 0x80u;
-    pPaletteManager->field_267AD1 = 0x80u;
-    pPaletteManager->field_267AD2 = 0x80u;
+    pPaletteManager->pPalette_mistColor[0] = 0x80u;
+    pPaletteManager->pPalette_mistColor[1] = 0x80u;
+    pPaletteManager->pPalette_mistColor[2] = 0x80u;
     goto LABEL_7;
   }
 LABEL_8:
@@ -1412,10 +1421,9 @@
         pOutdoorLocation->pBModels[v12].pNodes = 0;
         FileName[0] = 0;
         v108 = (int)&pOutdoorLocation->pBModels[v12];
-        sprintf(FileName, "%s", v108);
+        sprintfex(FileName, "%s", v108);
         v13 = pOutdoorLocation->pBModels;
-        FileName[8] = 0;
-		v114 = (int)FileName;
+        v138 = 0;
         pOutdoorLocation->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,
@@ -1430,7 +1438,6 @@
         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);
-		v114 = (int)FileName;
         v16 = malloc(10 * pOutdoorLocation->pBModels[v12].uNumFaces);
         v107 = (int)File;
         v17 = pOutdoorLocation->pBModels;
@@ -1715,8 +1722,7 @@
       v108 = (int)&pOutdoorLocation->pBModels[v48];
       sprintf(FileName, "%s", v108);
       v49 = pOutdoorLocation->pBModels;
-	  FileName[8] = 0;
-      //v138 = 0;
+      v138 = 0;
       v50 = &v49[v48];
       v108 = (int)FileName;
       v107 = 12 * v50->pVertices.uNumVertices;
@@ -1883,8 +1889,9 @@
   memcpy(v71, uSourceLen, 24 * v72);
   pGameLoadingUI_ProgressBar->Progress();
   free((void *)HIDWORD(v142));
-  //v73 = strlen(pContainer);
-  strcpy(&pContainer[strlen(pContainer) - 4], ".ddm");
+  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);
   Str2 = 0;
--- a/Outdoor.h	Sat Nov 03 19:58:37 2012 +0600
+++ b/Outdoor.h	Sat Nov 03 19:59:36 2012 +0600
@@ -42,7 +42,8 @@
     this->ptr_C = 0;
     this->field_10 = 0;
     this->field_12 = 0;
-	this->pAttributemap = nullptr;
+
+    pAttributemap = nullptr;
   }
 
   void _47C7A9();
--- a/SaveLoad.cpp	Sat Nov 03 19:58:37 2012 +0600
+++ b/SaveLoad.cpp	Sat Nov 03 19:59:36 2012 +0600
@@ -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];
 
 
 
@@ -357,7 +357,7 @@
     }
     if ( pNew_LOD->Write(&pDir, DstBuf, 0) )
     {
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200);
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 200);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
     }
     else
@@ -371,7 +371,7 @@
     if ( pNew_LOD->Write(&pDir, &v43, 0) )
     {
       v39 = 201;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201);
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 201);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
     }
     strcpy((char *)&pDir, "party.bin");
@@ -379,7 +379,7 @@
     if ( pNew_LOD->Write(&pDir, &pParty, 0) )
     {
       v39 = 202;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202);
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 202);
     MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
     }
     strcpy((char *)&pDir, "Timer.bin");
@@ -387,7 +387,7 @@
     if ( pNew_LOD->Write(&pDir, &pEventTimer, 0) )
     {
       v39 = 203;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203);
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 203);
           MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
     }
     strcpy((char *)&pDir, "overlay.bin");
@@ -395,7 +395,7 @@
     if ( pNew_LOD->Write(&pDir, &pOtherOverlayList, 0) )
     {
       v39 = 204;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204);
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 204);
           MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
     }
     strcpy((char *)&pDir, "npcdata.bin");
@@ -403,7 +403,7 @@
     if ( pNew_LOD->Write(&pDir, pNPCStats->pNewNPCData, 0) )
     {
       v39 = 205;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205);
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 205);
           MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
     }
     strcpy((char *)&pDir, "npcgroup.bin");
@@ -411,7 +411,7 @@
     if ( pNew_LOD->Write(&pDir, pNPCStats->pGroups_copy, 0) )
     {
       v39 = 206;
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206);
+      sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 206);
           MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
     }
     v70 = 1;
@@ -620,13 +620,13 @@
       v69 += 16;
       memcpy((void *)(v9 + 8), &v69, 4u);
       memcpy((void *)(v9 + 12), &Size, 4u);
-      sprintf(Source, "%s%s", &Filename, &Ext);
+      sprintfex(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);
+        sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 208);
           MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
       }
       free((void *)v9);
@@ -639,7 +639,7 @@
         v34 = GetLastError();
         FormatMessageA(0x1000u, 0, v34, 0x400u, &Buffer, 0x80u, 0);
         v39 = 300;
-        sprintf(Str, pGlobalTXT_LocalizationStrings[612], 300);
+        sprintfex(Str, pGlobalTXT_LocalizationStrings[612], 300);
           MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1097", 0);
       }
     }
@@ -678,7 +678,7 @@
     strcpy((char *)&pDir, "header.bin");
     pDir.uDataSize = 100;
     pNew_LOD->Write(&pDir, (char *)&pSavegameHeader + v2, 0);
-    sprintf(pTmpBuf, "saves\\save%03d.mm7", v6);
+    sprintfex(pTmpBuf, "saves\\save%03d.mm7", v6);
     pNew_LOD->CloseWriteFile();
     CopyFileA("data\\new.lod", pTmpBuf, 0);
   }
--- a/SaveLoad.h	Sat Nov 03 19:58:37 2012 +0600
+++ b/SaveLoad.h	Sat Nov 03 19:59:36 2012 +0600
@@ -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	Sat Nov 03 19:58:37 2012 +0600
+++ b/mm7_2.cpp	Sat Nov 03 19:59:36 2012 +0600
@@ -145,7 +145,7 @@
   _this.uFrameZ = 334;
   v28 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-  sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);
+  sprintfex(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);
   _this.DrawText2(pFontArrus, 0, 0x104u, v30, pTmpBuf, 3u);
   if ( dword_F8B19C == 1 )
   {
@@ -206,7 +206,7 @@
       v0 = ptr_507BC0;
       if ( ptr_507BC0->field_40 == 1 )
       {
-        sprintf(pTmpBuf, "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]);
+        sprintfex(pTmpBuf, "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]);
         _this.DrawText2(pFontArrus, 0, 0x92u, v30, pTmpBuf, 3u);
         _this.DrawText2(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
         v3 = pFontArrus;
@@ -257,8 +257,8 @@
     v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
     v7 = v5->pName;
     v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-    sprintf(pTmpBuf, &byte_4F0F98, v8, v7, v6);
-    sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel);
+    sprintfex(pTmpBuf, &byte_4F0F98, v8, v7, v6);
+    sprintfex(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel);
     ptr_F8B1E8 = pTmpBuf2;
     memcpy(&a1, pDialogueWindow, sizeof(a1));
     w.uFrameWidth = 458;
@@ -310,7 +310,7 @@
   _this.uFrameZ = 334;
   *(int *)v13 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
   *(int *)v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-  sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank);
+  sprintfex(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank);
   _this.DrawText2(pFontArrus, 0, 0xDCu, v14[0], pTmpBuf, 3u);
   if ( dword_F8B19C != 1 )
   {
@@ -394,7 +394,7 @@
       v11 = pGlobalTXT_LocalizationStrings[112];
       v10 = pGlobalTXT_LocalizationStrings[244];
     }
-    sprintf(pTmpBuf, "%s\n%s", v10, v11);
+    sprintfex(pTmpBuf, "%s\n%s", v10, v11);
     _this.DrawText2(pFontArrus, 0, 0x92u, v14[0], pTmpBuf, 3u);
     _this.DrawText2(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u);
     v4 = pFontArrus;
@@ -681,7 +681,7 @@
             while ( (signed int)v10 < v8->pStartingPosActiveItem + v8->pNumPresenceButton );
             if ( v86 )
             {
-              sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pOutString);
+              sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], pOutString);
               v79.DrawText2(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
               pOutString = (GUIFont *)((149 - v89) / v86);
               if ( (149 - v89) / v86 > 32 )
@@ -731,7 +731,7 @@
             }
           }
           v26 = pTmpBuf;
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v85->pName, pClassNames[v85->uClass]);
+          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v85->pName, pClassNames[v85->uClass]);
           strcat(pTmpBuf, "\n \n");
           strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
           goto LABEL_97;
@@ -770,16 +770,16 @@
     v28 = *(int *)v84;
     if ( pDialogueWindow->pCurrentPosActiveItem != 2 )
       v28 = v81;
-    sprintf(&Dest, format_4E2DC8, v28);
-    sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString);
+    sprintfex(&Dest, format_4E2DC8, v28);
+    sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[178], pOutString);
     strcat(&Dest, pTmpBuf2);
     v90 = pFontArrus->CalcTextHeight(&Dest, &v79, 0, 0);
     strcat(&Dest, "\n \n");
     v29 = *(int *)v84;
     if ( pDialogueWindow->pCurrentPosActiveItem != 3 )
       v29 = v81;
-    sprintf(&a1, format_4E2DC8, v29);
-    sprintf(pTmpBuf2,
+    sprintfex(&a1, format_4E2DC8, v29);
+    sprintfex(pTmpBuf2,
       pGlobalTXT_LocalizationStrings[86],
       //(signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C],
       (signed __int64)p2DEvents[(unsigned int)ptr_507BC0->ptr_1C - 1].fPriceMultiplier,
@@ -790,7 +790,7 @@
     v30 = *(int *)v84;
     if ( pDialogueWindow->pCurrentPosActiveItem != 4 )
       v30 = v81;
-    sprintf(&v77, format_4E2DC8, v30);
+    sprintfex(&v77, format_4E2DC8, v30);
     strcat(&v77, pGlobalTXT_LocalizationStrings[160]);
     v82 = pFontArrus->CalcTextHeight(&v77, &v79, 0, 0);
     strcat(&v77, "\n \n");
@@ -802,7 +802,7 @@
       v32 = *(int *)v84;
       if ( pDialogueWindow->pCurrentPosActiveItem != 5 )
         v32 = v81;
-      sprintf(&v75, format_4E2DC8, v32);
+      sprintfex(&v75, format_4E2DC8, v32);
       strcat(&v75, pGlobalTXT_LocalizationStrings[611]);
       v87 = pFontArrus->CalcTextHeight(&v75, &v79, 0, 0);
     }
@@ -816,7 +816,7 @@
     if ( !(v37 ^ __OFSUB__(v34, v35)) )
     {
 LABEL_75:
-      sprintf(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
+      sprintfex(pTmpBuf, "%s%s%s%s", &Dest, &a1, &v77, &v75);
       v71 = 3;
       v69 = pTmpBuf;
       v67 = 0;
@@ -1215,7 +1215,7 @@
           if ( !v109 )
           {
 LABEL_105:
-            sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->uClass]);
+            sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->uClass]);
             strcat(pTmpBuf, "\n \n");
             strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
             v7 = pTmpBuf;
@@ -1227,7 +1227,7 @@
             v77 = &v101;
             goto LABEL_15;
           }
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v108);
+          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v108);
           v101.DrawText2(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
           v108 = (149 - v106.y) / (signed int)v109;
           if ( (149 - v106.y) / (signed int)v109 > 32 )
@@ -1954,7 +1954,7 @@
           while ( (signed int)v6 < v2->pNumPresenceButton + v2->pStartingPosActiveItem );
           if ( v114 )
           {
-            sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v111);
+            sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v111);
             v104.DrawText2(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
             v111 = (const char **)((signed int)(149 - v112) / v114);
             if ( (signed int)(149 - v112) / v114 > 32 )
@@ -2004,7 +2004,7 @@
             return result;
           }
         }
-        sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->uClass]);
+        sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->uClass]);
         strcat(pTmpBuf, "\n \n");
         strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
         v21 = pTmpBuf;
@@ -2548,7 +2548,7 @@
         while ( (signed int)v39 < v37->pNumPresenceButton + v37->pStartingPosActiveItem );
         if ( v153 )
         {
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], _this);
+          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], _this);
           v144.DrawText2(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
           _this = (Player *)((149 - v152) / v153);
           if ( (149 - v152) / v153 > 32 )
@@ -2597,7 +2597,7 @@
           return;
         }
       }
-      sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v0->pName, pClassNames[v0->uClass]);
+      sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v0->pName, pClassNames[v0->uClass]);
       strcat(pTmpBuf, "\n \n");
       strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
       v11 = 0;
@@ -5154,7 +5154,7 @@
   {
     v4 = pClassNames[(unsigned __int8)v3[17]];
     v5 = ((Player *)(v3 - 168))->GetBaseLevel();
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[129], i, v5, v4);
+    sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[129], i, v5, v4);
     pWindow.DrawText2(
       pFont,
       1u,
@@ -5181,10 +5181,10 @@
   v9 = pGlobalTXT_LocalizationStrings[245];
   if ( v14 != 1 )
     v9 = pGlobalTXT_LocalizationStrings[132];
-  sprintf(pTmpBuf2, " %lu %s, %lu %s, %lu %s ", v14, v9, v18, v8, v17, v7);
+  sprintfex(pTmpBuf2, " %lu %s, %lu %s, %lu %s ", v14, v9, v18, v8, v17, v7);
   strcat(pTmpBuf, pTmpBuf2);
   pWindow.DrawText2(pFont, 1u, pWindow.uFrameHeight - 2 * LOBYTE(pFont->uFontHeight) - 5, 1u, pTmpBuf, 3u);
-  sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[94], v23);
+  sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[94], v23);
   pWindow.DrawText2(pFont, 1u, pWindow.uFrameHeight, 1u, pTmpBuf, 3u);
   BYTE1(dword_6BE364_game_settings_1) |= 0x40u;
   pRenderer->EndScene();
@@ -7640,7 +7640,7 @@
 LABEL_24:
         v44 = "%s C";
 LABEL_25:
-        result = (void *)sprintf(&Source, v44, v45);
+        result = (void *)sprintfex(&Source, v44, v45);
 LABEL_26:
         if ( Source == 48 )
           return result;
@@ -7710,14 +7710,14 @@
             v44 = "%s C";
           }
         }
-        sprintf(&Str2, v44, v45);
+        sprintfex(&Str2, v44, v45);
       }
       v26 = pMonsterList->GetMonsterByName(&Str2);
       v50 = (signed __int16)v26;
       v45 = &Str2;
       if ( (signed __int16)v26 == -1 )
       {
-        sprintf(&Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", v45);
+        sprintfex(&Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", v45);
         MessageBoxA(nullptr, &Str, nullptr, 0);
         ExitProcess(0);
       }
@@ -10330,7 +10330,7 @@
                                     }
                                     if ( _strcmpi(*(const char **)(v2 + 4), "Hammerhands") )
                                     {
-                                      sprintf(pTmpBuf, "Unknown monster spell %s", *(int *)(v2 + 4));
+                                      sprintfex(pTmpBuf, "Unknown monster spell %s", *(int *)(v2 + 4));
                                       MessageBoxA(nullptr, pTmpBuf, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Itemdata.cpp:1562", 0);
                                       result = 0;
                                       goto LABEL_76;
@@ -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]);
@@ -13532,7 +13529,7 @@
   v4 = hdc * BytesPerSector * SectorsPerCluster;
   if ( (unsigned int)v4 < 0x1E00000 )
   {
-    sprintf(
+    sprintfex(
       pTmpBuf,
       "Due to Window Virtual Memory requirements Might and Magic VII\nrequires 30MB of free hard drive space to operate properly.\n\nAvailable on Current Drive = %luk",
       (unsigned int)v4 / 1024i64);
@@ -13932,9 +13929,9 @@
   pBitmaps_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
   pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
   pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, pRenderer->uTargetGBits, pRenderer->uTargetBBits);
-  pPaletteManager->field_267AD0 = 128;
-  pPaletteManager->field_267AD1 = 128;
-  pPaletteManager->field_267AD2 = 128;
+  pPaletteManager->pPalette_mistColor[0] = 128;
+  pPaletteManager->pPalette_mistColor[1] = 128;
+  pPaletteManager->pPalette_mistColor[2] = 128;
   pPaletteManager->RecalculateAll();
   pSprites_LOD->field_ECAC = 1;
   pObjectList->InitializeSprites();
@@ -14017,7 +14014,7 @@
     v11 = 1;
     do
     {
-      sprintf(pTmpBuf, "data\\lloyd%d%d.pcx", v10, v11);
+      sprintfex(pTmpBuf, "data\\lloyd%d%d.pcx", v10, v11);
       remove(pTmpBuf);
       ++v11;
     }
@@ -14300,7 +14297,7 @@
   unsigned int v9; // [sp+184h] [bp-4h]@28
 
   //_getcwd(v5, 120);
-  //sprintf(pIniFilename, "%s\\mm6.ini", v5);
+  //sprintfex(pIniFilename, "%s\\mm6.ini", v5);
   viewparams = new ViewingParams;
   viewparams->uScreenX = GetPrivateProfileIntW(L"screen", L"vx1", 8, pIniFilename);
   viewparams->uScreenY = GetPrivateProfileIntW(L"screen", L"vy1", 8, pIniFilename);
@@ -14972,7 +14969,7 @@
             }
           }
 LABEL_174:
-          sprintf(&Src, "Unknown DirectDraw/Direct3D error number %X", v4);
+          sprintfex(&Src, "Unknown DirectDraw/Direct3D error number %X", v4);
           v13 = strlen(&Src);
           v12 = &Src;
           goto LABEL_175;
@@ -15165,7 +15162,7 @@
   a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
   v1 = pItemsTable->pItems[(unsigned int)ptr_507BC4->ptr_1C + 700].pName;
   v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-  sprintf(pTmpBuf, format_4E2D80, v2, v1);
+  sprintfex(pTmpBuf, format_4E2D80, v2, v1);
   a1.DrawText2(pFontCreate, 0, 0, 0, pTmpBuf, 3u);
   return a1.DrawText(
            pFontSmallnum,
@@ -15861,7 +15858,7 @@
         if ( pParty->pPickedItem.uItemID )
           return 1;
         v24 = (int)pItemsTable->pItems[v20].pUnidentifiedName;
-        sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], v24);
+        sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[471], v24);
         ShowStatusBarString(pTmpBuf2, 2u);
         if ( v19->uItemID == 506 )
           _449B7E_toggle_bit(pParty->_award_bits, 184, 1u);
--- a/mm7_3.cpp	Sat Nov 03 19:58:37 2012 +0600
+++ b/mm7_3.cpp	Sat Nov 03 19:59:36 2012 +0600
@@ -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);
-
 
 
 
@@ -15238,7 +15234,7 @@
   memset(&DstBuf, 0, 0x48u);
   if ( (signed int)v5 >= (signed int)uBufferSize )
   {
-    sprintf(&Args, "File %s Size %lu - Buffer size %lu", v3, v5, uBufferSize);
+    sprintfex(&Args, "File %s Size %lu - Buffer size %lu", v3, v5, uBufferSize);
     Abortf(&Args);
   }
   memcpy(Dst, ptr, v5);
@@ -15315,7 +15311,7 @@
   uLevelStrNumStrings = (signed __int16)v2 - 1;
   if ( v0 > 800 )
   {
-    sprintf(Args, "MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", v0 + 1);
+    sprintfex(Args, "MAX_EVENT_TEXT_LENGTH needs to be increased to %lu", v0 + 1);
     Abortf(Args);
   }
   v6 = 0;
@@ -15841,7 +15837,7 @@
   {
     if ( v10 )
     {
-      sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[409], v0->pName);// "Do you wish to leave %s?"
+      sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[409], v0->pName);// "Do you wish to leave %s?"
       v1 = pTmpBuf;
       goto LABEL_12;
     }
@@ -15874,7 +15870,7 @@
 
   pEventTimer->Pause();
   v0 = const_2();
-  sprintf(pContainer, "evt%02d", v0);
+  sprintfex(pContainer, "evt%02d", v0);
   if ( pParty->uAlignment )
   {
     if ( pParty->uAlignment != 2 )
@@ -15891,7 +15887,7 @@
   pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("outside", TEXTURE_16BIT_PALETTE)];
   v1 = pMapStats->GetMapInfo(pCurrentMapName);
   if ( v1 )
-    sprintf(byte_591098, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s"
+    sprintfex(byte_591098, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s"
   else
     strcpy(byte_591098, pGlobalTXT_LocalizationStrings[79]);// "Exit"
   result = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)17, 0, (int)byte_591098);
@@ -15967,9 +15963,9 @@
       v6 = v3;
       v5 = pGlobalTXT_LocalizationStrings[128]; // "It will take %d days to travel to %s."
     }
-    sprintf(pTmpBuf, v5, v6, v1->pName);
+    sprintfex(pTmpBuf, v5, v6, v1->pName);
     strcat(pTmpBuf, "\n \n");
-    sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[v9].pName);
+    sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[v9].pName);
     strcat(pTmpBuf, pTmpBuf2);
     v4 = pFontCreate->CalcTextHeight(pTmpBuf, &v7, 0, 0);
     v7.DrawText2(pFontCreate, 0, (212 - v4) / 2 + 101, 0, pTmpBuf, 3u);
@@ -16029,7 +16025,7 @@
   }
   if ( pGUIWindow2->ptr_1C == (void *)26 )
   {
-    sprintf(Str, "%s %s", GameUI_StatusBar_TimedString, pKeyActionMap->pPressedKeysBuffer);
+    sprintfex(Str, "%s %s", GameUI_StatusBar_TimedString, pKeyActionMap->pPressedKeysBuffer);
     v3 = pFontLucida->GetLineWidth(Str);
     pGUIWindow2->DrawText(pFontLucida, 13, 357, 0, Str, 0, 0, 0);
     pGUIWindow2->DrawFlashingInputCursor(v3 + 13, 357, pFontLucida);
@@ -16190,7 +16186,7 @@
   if ( v3 )
   {
     v4 = pTmpBuf;
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v0->pName, aNPCProfessionNames[v3]);
+    sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v0->pName, aNPCProfessionNames[v3]);
   }
   else
   {
@@ -16208,7 +16204,7 @@
     }
     if ( uDialogueType == 91 )
     {
-      sprintf(v4, pGlobalTXT_LocalizationStrings[576], dword_F8B1B4);// "Congratulations on your win: here's your stuff: %u gold."
+      sprintfex(v4, pGlobalTXT_LocalizationStrings[576], dword_F8B1B4);// "Congratulations on your win: here's your stuff: %u gold."
       pInString = v4;
       v8 = 0;
       goto LABEL_39;
@@ -16373,7 +16369,7 @@
         if ( v0->uFlags & 0x80 )
         {
 LABEL_59:
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[408], v0->pName);
+          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[408], v0->pName);
           v24 = pTmpBuf;
           goto LABEL_79;
         }
@@ -19460,7 +19456,7 @@
   while ( v4 < 200 );
   if ( v4 >= 200 )
   {
-    sprintf(&Args, "Unable to find Door ID: %i!", uDoorID);
+    sprintfex(&Args, "Unable to find Door ID: %i!", uDoorID);
     Abortf(&Args);
   }
   v6 = &pIndoor->pDoors[v4];
--- a/mm7_4.cpp	Sat Nov 03 19:58:37 2012 +0600
+++ b/mm7_4.cpp	Sat Nov 03 19:59:36 2012 +0600
@@ -2943,7 +2943,7 @@
   do
   {
     v5 = result + 1;
-    sprintf(pTmpBuf, "%s%02d", *v3, result + 1);
+    sprintfex(pTmpBuf, "%s%02d", *v3, result + 1);
     pIcons_LOD->ReloadTexture(*v4, pTmpBuf, 2);
     result = v5;
     ++v4;
@@ -5126,7 +5126,7 @@
         if ( v16 + 10 * (unsigned __int8)*v15 == 552 )
         {
           v46 = v13->GetDisplayName();
-          sprintf(a1, format_4E2D80, v59, v46);
+          sprintfex(a1, format_4E2D80, v59, v46);
 LABEL_117:
           v11 = a1;
           goto LABEL_118;
@@ -5172,7 +5172,7 @@
 LABEL_108:
           strncpy(a1, v15, 2u);
           v51 = atoi(a1);
-          sprintf(a1, "%lu", v51);
+          sprintfex(a1, "%lu", v51);
           goto LABEL_117;
         }
         v26 = &p2DEvents[(signed int)a4 - 1].fPriceMultiplier;
@@ -5216,7 +5216,7 @@
             }
           }
 LABEL_98:
-          sprintf(a1, "%lu", v29);
+          sprintfex(a1, "%lu", v29);
           goto LABEL_117;
         }
         v34 = *v26;
@@ -5252,7 +5252,7 @@
             v53 = v56.field_C + 1;
             v50 = v56.field_14;
 LABEL_116:
-            sprintf(a1, pGlobalTXT_LocalizationStrings[378], aMonthNames[v50], v53, v54);
+            sprintfex(a1, pGlobalTXT_LocalizationStrings[378], aMonthNames[v50], v53, v54);
             goto LABEL_117;
           }
           v52 = pPlayers[4];
@@ -7244,7 +7244,7 @@
 }
 
 //----- (004A597D) --------------------------------------------------------
-void __cdecl Present_NoColorKey()
+void Present_NoColorKey()
 {
   //unsigned __int16 *v0; // eax@4
   unsigned __int16 *v1; // esi@4
@@ -7334,7 +7334,7 @@
         auto uHalfWidth = v20 = (pViewport->uViewportZ - pViewport->uViewportX) / 2;
         v13 = v24;
 
-        for (uint y = pViewport->uViewportY; y < pViewport->uViewportW; ++y)
+        for (uint y = pViewport->uViewportY; y < pViewport->uViewportW + 1; ++y)
         {
           //memcpy(pDst + pViewport->uViewportX + y * Dst.lPitch / 2,
           //       pSrc + pViewport->uViewportX + y * 640, (pViewport->uViewportZ - pViewport->uViewportX) * sizeof(__int16));
@@ -9513,7 +9513,7 @@
   v1 = *_this - 399;
   v2 = (*_this - 400) % 11 + 1;
   v11 = 4 * (*_this - 400) / 11;
-  sprintf(pTmpBuf, "%s%03d", spellbook_texture_filename_suffices[v11 / 4], v2);
+  sprintfex(pTmpBuf, "%s%03d", spellbook_texture_filename_suffices[v11 / 4], v2);
   if ( pMouse->GetCursorPos(&a2)->y <= 320 )
     v3 = pMouse->GetCursorPos(&a2)->y + 30;
   else
@@ -9536,7 +9536,7 @@
     v5 = v13;
   if ( v4 > v5 )
     v5 = v4;
-  sprintf(
+  sprintfex(
     pTmpBuf2,
     "%s\n\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s",
     pSpellStats->pInfos[v1].pDescription,
@@ -9573,7 +9573,7 @@
   a1.uFrameZ = a1.uFrameX + 107;
   a1.uFrameWidth = 108;
   a1.DrawText2(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v11 / 4 + 12], 3u);
-  sprintf(pTmpBuf, "%s\n%d", pGlobalTXT_LocalizationStrings[522], *(&pSpellDatas[0].uNormalLevelMana + 10 * v1));
+  sprintfex(pTmpBuf, "%s\n%d", pGlobalTXT_LocalizationStrings[522], *(&pSpellDatas[0].uNormalLevelMana + 10 * v1));
   return a1.DrawText2(
            pFontComic,
            0xCu,
@@ -9606,7 +9606,7 @@
     v4.uFrameX = 483;
     v4.uFrameWidth = 148;
     v4.uFrameZ = 334;
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427], pPlayer->pName, pGlobalTXT_LocalizationStrings[562]);// 
+    sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[427], pPlayer->pName, pGlobalTXT_LocalizationStrings[562]);// 
                                                 // "%s is in no condition to %s"
                                                 // "do anything"
     v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
@@ -10333,7 +10333,7 @@
       {
         if ( v31 == v14 )
         {
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[634], pClassNames[v10 + 2], pClassNames[v10 + 3]);
+          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[634], pClassNames[v10 + 2], pClassNames[v10 + 3]);
           return pTmpBuf;
         }
         v25 = pClassNames[v10 + 2];
@@ -10351,7 +10351,7 @@
     }
     v22 = pGlobalTXT_LocalizationStrings[633];
 LABEL_23:
-    sprintf(pTmpBuf, v22, v25);
+    sprintfex(pTmpBuf, v22, v25);
     return pTmpBuf;
   }
   if ( !v1->CanAct() )
@@ -10550,7 +10550,7 @@
     v24 = pSkillNames[v17];
     v21 = pGlobalTXT_LocalizationStrings[225];
 LABEL_90:
-    sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[534], v21, v24, v27);
+    sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[534], v21, v24, v27);
   }
   return pTmpBuf2;
 }
@@ -10675,7 +10675,7 @@
     v2 = (&off_4EB080)[4 * uHouse_ExitPic];
     if ( !v2 )
     {
-      sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[411], v0);
+      sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[411], v0);
       v2 = pTmpBuf;
     }
     v3 = v2;
@@ -10691,7 +10691,7 @@
   v7 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
   v8 = v6->uProfession;
   if ( v8 )
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v8]);
+    sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v8]);
   else
     strcpy(pTmpBuf, v6->pName);
   a1.DrawText2(pFontCreate, 0x1E3u, 0x71u, v7, pTmpBuf, 3u);
@@ -10770,8 +10770,8 @@
           v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
           v31 = *(int *)v29;
           v32 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-          sprintf(pTmpBuf, &byte_4F0F98, v32, v31, v30);
-          sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * (unsigned __int8)v29[8]);
+          sprintfex(pTmpBuf, &byte_4F0F98, v32, v31, v30);
+          sprintfex(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * (unsigned __int8)v29[8]);
           ptr_F8B1E8 = pTmpBuf2;
           v15 = "";
           goto LABEL_45;
@@ -10813,8 +10813,8 @@
             }
             if ( uDialogueType != 84 )
               goto LABEL_49;
-            sprintf(pTmpBuf, format_4E2D80, v55, pItemsTable->pItems[dword_F8B1A8].pUnidentifiedName);
-            sprintf(pTmpBuf2, ptr_F8B1E8, pTmpBuf);
+            sprintfex(pTmpBuf, format_4E2D80, v55, pItemsTable->pItems[dword_F8B1A8].pUnidentifiedName);
+            sprintfex(pTmpBuf2, ptr_F8B1E8, pTmpBuf);
             ptr_F8B1E8 = pTmpBuf2;
             goto LABEL_45;
           }
@@ -11800,7 +11800,7 @@
   {
     pDialogueWindow->Release();
     pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
-    sprintf(byte_591098, pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[uHouse_ExitPic].pName);
+    sprintfex(byte_591098, pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[uHouse_ExitPic].pName);
     ptr_5076F4 = pDialogueWindow->CreateButton(
                    0x236u,
                    0x1BDu,
@@ -12194,7 +12194,7 @@
             while ( (signed int)v15 < v13->pNumPresenceButton + v13->pStartingPosActiveItem );
             if ( v72 )
             {
-              sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v73);// "Skill Cost: %lu"
+              sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v73);// "Skill Cost: %lu"
               v65.DrawText2(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
               v73 = (signed int)(149 - i) / v72;
               if ( v73 > 32 )
@@ -12244,7 +12244,7 @@
             else
             {
 LABEL_76:
-              sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v0->pName, pClassNames[v0->uClass]);// 
+              sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v0->pName, pClassNames[v0->uClass]);// 
                                                 // "Seek knowledge elsewhere %s the %s"
               strcat(pTmpBuf, "\n \n");
               strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
@@ -12302,7 +12302,7 @@
                 pOutdoor->SetFog();
             }
             v0->PlaySound(87, 0);
-            sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[430], v0->pName, v0->uLevel, v0->uLevel / 10 + 5);// 
+            sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[430], v0->pName, v0->uLevel, v0->uLevel / 10 + 5);// 
                                                 // "%s is now Level %lu and has earned %lu Skill Points!"
             ShowStatusBarString(pTmpBuf, 2u);
             goto LABEL_56;
@@ -12323,7 +12323,7 @@
           }
           return result;
         }
-        sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[538], v5 - LODWORD(v0->uExperience), v34 + 1);// 
+        sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[538], v5 - LODWORD(v0->uExperience), v34 + 1);// 
                                                 // "You need %d more experience to train to level %d"
         v35 = 0;
         v62 = 3;
@@ -12333,7 +12333,7 @@
       }
       else
       {
-        sprintf(pTmpBuf, "%s\n \n%s", pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]);// 
+        sprintfex(pTmpBuf, "%s\n \n%s", pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]);// 
                                                 // ""With your skills, you should be working here as a teacher.""
                                                 // ""Sorry, but we are unable to train you.""
         v35 = 0;
@@ -12384,7 +12384,7 @@
               v61 = pGlobalTXT_LocalizationStrings[536];// ""With your skills, you should be working here as a teacher.""
               v59 = "%s\n \n%s";
             }
-            sprintf(*v45, v59, v61, v64);
+            sprintfex(*v45, v59, v61, v64);
           }
           v47 = pFontArrus->CalcTextHeight(*v45, &v65, 0, 0);
           v43 = pDialogueWindow;
@@ -12666,7 +12666,7 @@
           if ( !v122 )
           {
 LABEL_140:
-            sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->uClass]);// 
+            sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[544], _this->pName, pClassNames[_this->uClass]);// 
                                                 // "Seek knowledge elsewhere %s the %s"
             strcat(pTmpBuf, "\n \n");
             strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further."
@@ -12679,7 +12679,7 @@
             v88 = &v112;
             goto LABEL_61;
           }
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v119);// "Skill Cost: %lu"
+          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v119);// "Skill Cost: %lu"
           v112.DrawText2(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
           v119 = (const char **)((149 - v118) / v122);
           if ( (149 - v118) / v122 > 32 )
@@ -13535,7 +13535,7 @@
         v3 = (int)(&v1->uIntelligence + dword_F8B19C);
         if ( *(short *)v3 )
         {
-          sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[403], pClassNames[dword_F8B19C + 20]);
+          sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[403], pClassNames[dword_F8B19C + 20]);
           ShowStatusBarString(pTmpBuf, 2u);
           pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0);
         }
@@ -13707,7 +13707,7 @@
   if ( !v61 )
   {
 LABEL_64:
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v58->pName, pClassNames[v58->uClass]);
+    sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v58->pName, pClassNames[v58->uClass]);
     strcat(pTmpBuf, "\n \n");
     strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
     v18 = pTmpBuf;
@@ -13721,7 +13721,7 @@
   }
   if ( Str )
   {
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v63);
+    sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v63);
     v52.DrawText2(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
   }
   v63 = (signed int)(149 - v62) / v61;
@@ -13911,7 +13911,7 @@
             while ( (signed int)v62 < v4->pNumPresenceButton + v11 );
             if ( v65 )
             {
-              sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v64);
+              sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v64);
               v57.DrawText2(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
               v64 = (149 - (signed int)v66) / (signed int)v65;
               if ( v64 > 32 )
@@ -13963,7 +13963,7 @@
             else
             {
 LABEL_78:
-              sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v1->pName, pClassNames[v1->uClass]);
+              sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v1->pName, pClassNames[v1->uClass]);
               strcat(pTmpBuf, "\n \n");
               strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
               v22 = WORD2(v59);
@@ -14117,7 +14117,7 @@
   v41->uY = 0;
   if ( v1->_4B6FF9() )
   {
-    sprintf(a1, "%s %d %s", pGlobalTXT_LocalizationStrings[104], HIDWORD(v60), pGlobalTXT_LocalizationStrings[97]);
+    sprintfex(a1, "%s %d %s", pGlobalTXT_LocalizationStrings[104], HIDWORD(v60), pGlobalTXT_LocalizationStrings[97]);
     v63 = 0;
   }
   strcpy(&Dest, pGlobalTXT_LocalizationStrings[68]);
@@ -14412,14 +14412,14 @@
   if ( !v34 )
   {
 LABEL_40:
-    sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v1->pName, pClassNames[v1->uClass]);
+    sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[544], v1->pName, pClassNames[v1->uClass]);
     strcat(pTmpBuf, "\n \n");
     strcat(pTmpBuf, pGlobalTXT_LocalizationStrings[528]);
     v22 = v31;
     v23 = pFontArrus->CalcTextHeight(pTmpBuf, &v28, 0, 0);
     return (int)v28.DrawText2(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf, 3u);
   }
-  sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v32);
+  sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[401], v32);
   v28.DrawText2(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
   v32 = (149 - v33) / v34;
   if ( (149 - v33) / v34 > 32 )
@@ -14574,7 +14574,7 @@
       v59 = pDialogueWindow;
       v54 = v17;
       strcpy(&Dest, "");
-      sprintf(pTmpBuf2, pGlobalTXT_LocalizationStrings[405], s1);
+      sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[405], s1);
       v18 = pFontArrus->CalcTextHeight(pTmpBuf2, &v53, 0, 0);
       v19 = v16->pNumPresenceButton;
       v20 = v18 + v17 + 146;
@@ -14605,7 +14605,7 @@
           if ( pDialogueWindow->pCurrentPosActiveItem != s1 )
             v27 = *(const char **)v57;
           v47[1] = v27;
-          sprintf(a1, format_4E2DC8, v27);
+          sprintfex(a1, format_4E2DC8, v27);
           v66 = (unsigned __int8)byte_4F09B8[v26 * 4];
           if ( (signed int)ptr_507BC0->ptr_1C >= 63 )
           {
@@ -14628,7 +14628,7 @@
           if ( v61 != (Player *)v2 )
           {
             memcpy(&v32, (char *)&pMapStats + 68 * (unsigned __int8)byte_4F09B0[v26 * 4], 0x44u);
-            sprintf(
+            sprintfex(
               pTmpBuf,
               pGlobalTXT_LocalizationStrings[404],
               v66,
@@ -14690,7 +14690,7 @@
         v45 = (unsigned int)&v49;
         v44 = &v48;
         v43 = pTmpBuf2;
-        sprintf(pTmpBuf, "%s\n \n%s%s%s%s%s", pTmpBuf2, &v48, &v49, &v50, &v51, &Dest);
+        sprintfex(pTmpBuf, "%s\n \n%s%s%s%s%s", pTmpBuf2, &v48, &v49, &v50, &v51, &Dest);
         v53.DrawText2(pFontArrus, 0, 0x92u, 0, pTmpBuf, 3u);
       }
       else
@@ -15379,7 +15379,7 @@
   pEventTimer->Pause();
   pAudioPlayer->StopChannels(-1, -1);
   v11 = const_2();
-  sprintf(pContainer, "evt%02d", v11);
+  sprintfex(pContainer, "evt%02d", v11);
   if ( pParty->uAlignment )
   {
     if ( pParty->uAlignment != 2 )
@@ -15412,7 +15412,7 @@
         v20 = pMapStats->pInfos[v14].pName;
         v18 = pGlobalTXT_LocalizationStrings[410];
 LABEL_10:
-        sprintf(byte_591098, v18, v20);
+        sprintfex(byte_591098, v18, v20);
         goto LABEL_20;
       }
       v21 = pGlobalTXT_LocalizationStrings[79];
@@ -15535,7 +15535,7 @@
     do
     {
       v8 = v19;
-      sprintf(pContainer, "npc%03u", Dst[v19]);
+      sprintfex(pContainer, "npc%03u", Dst[v19]);
       v9 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
       ++v19;
       pDialogueNPCPortraits[v8] = &pIcons_LOD->pTextures[v9];
@@ -15641,7 +15641,7 @@
         v9 -= 12;
         v8 = 1;
       }
-      sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[414], v6, aAMPMNames[v7], v9, aAMPMNames[v8]);
+      sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[414], v6, aAMPMNames[v7], v9, aAMPMNames[v8]);
       ShowStatusBarString(pTmpBuf, 2u);
       if ( uActiveCharacter )
         pPlayers[uActiveCharacter]->PlaySound(3, 0);
@@ -15698,7 +15698,7 @@
     if ( !pIcons_LOD->uNumPrevLoadedFiles )
       pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
     v16 = const_2();
-    sprintf(pContainer, "evt%02d", v16);
+    sprintfex(pContainer, "evt%02d", v16);
     if ( pParty->uAlignment )
     {
       if ( pParty->uAlignment != 2 )
--- a/mm7_data.h	Sat Nov 03 19:58:37 2012 +0600
+++ b/mm7_data.h	Sat Nov 03 19:59:36 2012 +0600
@@ -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;