diff SaveLoad.cpp @ 869:715064ae1792

Слияние
author Ritor1
date Mon, 01 Apr 2013 09:05:51 +0600
parents e398541aee60
children 08fd1436ef35
line wrap: on
line diff
--- a/SaveLoad.cpp	Mon Apr 01 09:05:31 2013 +0600
+++ b/SaveLoad.cpp	Mon Apr 01 09:05:51 2013 +0600
@@ -230,77 +230,31 @@
 //----- (0045F469) --------------------------------------------------------
 void SaveGame( bool IsAutoSAve, bool NotSaveWorld )
     {
-  int result; // eax@1
   unsigned short *pScreenshot; // edi@5
   int text_pos; // eax@6
-  int v5; // eax@6
-  int v6; // eax@6
-  const char *v7; // edi@8
-  FILE *v8; // edi@24
+  FILE *pLLoidFile; // edi@24
   char* compressed_buf; // edi@30
-  void *v10; // esi@31
-  void *v11; // esi@31
-  void *v12; // esi@37
-  void *v13; // esi@37
-  void *v14; // esi@37
-  void *v15; // esi@37
-  void *v16; // esi@37
-  int v17; // esi@37
-  unsigned int v18; // ecx@38
-  unsigned int v19; // esi@39
-  BSPModel *v20; // edx@39
   char *data_write_pos; // esi@41
-  void *v22; // esi@41
-  BSPModel *v23; // eax@42
-  signed int v24; // edi@42
-  unsigned __int8 v25; // zf@43
-  unsigned __int8 v26; // sf@43
-  signed int v27; // edi@47
-  void *v28; // esi@50
-  void *v29; // esi@50
-  void *v30; // esi@50
-  void *v31; // esi@50
-  int v32; // esi@51
-  int v33; // eax@51
-  DWORD v34; // eax@59
-  //std::string v35; // [sp-18h] [bp-288h]@8
-  const char *v36; // [sp-10h] [bp-280h]@6
-  const char *v37; // [sp-Ch] [bp-27Ch]@6
-  unsigned int *v38; // [sp-8h] [bp-278h]@8
-  CHAR Buffer; // [sp+Ch] [bp-264h]@59
+  CHAR Buffer[128]; // [sp+Ch] [bp-264h]@59
   char Dir[255]; // [sp+8Ch] [bp-1E4h]@51
   char Drive[255]; // [sp+ACh] [bp-1C4h]@51
   SavegameHeader save_header; // [sp+CCh] [bp-1A4h]@10
-  //int v43; // [sp+CCh] [bp-1A4h]@10
-  //char Dest[20]; // [sp+E0h] [bp-190h]@10
-  //unsigned __int64 pTimePlayed; // [sp+F4h] [bp-17Ch]@10
   char Filename[255]; // [sp+130h] [bp-140h]@51
   char Ext[255]; // [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
+  char work_string[120]; // [sp+190h] [bp-E0h]@8
+  int pPositionY; // [sp+208h] [bp-68h]@2
   int pPositionX; // [sp+20Ch] [bp-64h]@2
-  int v53; // [sp+210h] [bp-60h]@2
-  int v54; // [sp+214h] [bp-5Ch]@2
+  int sPRotationY; // [sp+210h] [bp-60h]@2
+  int sPRotationX; // [sp+214h] [bp-5Ch]@2
   ODMHeader odm_data; // [sp+218h] [bp-58h]@30
-  char v56; // [sp+21Ch] [bp-54h]@30
-  char v57; // [sp+21Dh] [bp-53h]@30
-  char v58; // [sp+21Eh] [bp-52h]@30
-  char v59; // [sp+21Fh] [bp-51h]@30
-  int v60; // [sp+220h] [bp-50h]@30
-  int v61; // [sp+224h] [bp-4Ch]@30
-  int v62; // [sp+228h] [bp-48h]@2
+  int res; // [sp+224h] [bp-4Ch]@30
+  int pPositionZ; // [sp+228h] [bp-48h]@2
   LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2
   size_t Size; // [sp+250h] [bp-20h]@26
-  __int16 *v66; // [sp+254h] [bp-1Ch]@1
   char *uncompressed_buff; // [sp+258h] [bp-18h]@2
-  __int16 *v68; // [sp+25Ch] [bp-14h]@32
   unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23
-  int v70; // [sp+264h] [bp-Ch]@22
-  std::string *v71; // [sp+268h] [bp-8h]@8
-  int a3; // [sp+26Fh] [bp-1h]@8
-  
+ 
   //v66 = a2;
   strcpy(byte_6BE3B0, pCurrentMapName);
   if (!_strcmpi(pCurrentMapName, "d05.blv")) // arena
@@ -309,14 +263,16 @@
   uncompressed_buff = (char*)malloc(1000000);
   pLodDirectory.Reset();
   pPositionX = pParty->vPosition.x;
-  v51 = pParty->vPosition.y;
-  v62 = pParty->vPosition.z;
-  v53 = pParty->sRotationY;
-  v54 = pParty->sRotationX;
+  pPositionY = pParty->vPosition.y;
+  pPositionZ = pParty->vPosition.z;
+  sPRotationY = pParty->sRotationY;
+  sPRotationX = pParty->sRotationX;
   pParty->vPosition.x = pParty->vPrevPosition.x;
-  pParty->vPosition.y = pParty->vPrevPosition.z;
-  pParty->vPosition.z = pParty->vPrevPosition.y;
-  pParty->uFallStartY = pParty->vPrevPosition.y;
+  pParty->vPosition.z = pParty->vPrevPosition.z;
+  pParty->vPosition.y = pParty->vPrevPosition.y;
+
+  pParty->uFallStartY = pParty->vPrevPosition.z;
+
   pParty->sRotationY = pParty->sPrevRotationY;
   pParty->sRotationX = pParty->sPrevRotationX;
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
@@ -342,8 +298,8 @@
 
   if (pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0))
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 200); //  ! Code=%d
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 200); //  ! Code=%d
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:773", 0);
   }
 
   assert(sizeof(SavegameHeader) == 100);
@@ -356,66 +312,66 @@
   pLodDirectory.uDataSize = sizeof(SavegameHeader);
   if (pNew_LOD->Write(&pLodDirectory, &save_header, 0))
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 201);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 201);
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:784", 0);
   }
   strcpy(pLodDirectory.pFilename, "party.bin");
   pLodDirectory.uDataSize = sizeof(Party); //90680;
   if ( pNew_LOD->Write(&pLodDirectory, pParty, 0) )
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 202);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 202);
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:793", 0);
   }
   strcpy(pLodDirectory.pFilename, "clock.bin");
   pLodDirectory.uDataSize =sizeof(Timer);// 40;
   if ( pNew_LOD->Write(&pLodDirectory, pEventTimer, 0) )
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 203);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 203);
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:802", 0);
   }
   strcpy(pLodDirectory.pFilename, "overlay.bin");
   pLodDirectory.uDataSize =sizeof(OtherOverlayList);// 1008;
   if ( pNew_LOD->Write(&pLodDirectory, pOtherOverlayList, 0) )
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 204);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 204);
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:811", 0);
   }
   strcpy(pLodDirectory.pFilename, "npcdata.bin");
   pLodDirectory.uDataSize = 501 * sizeof(NPCData);
   assert(pLodDirectory.uDataSize == 38076);
   if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pNewNPCData, 0) )
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 205);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 205);
+    MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:820", 0);
   }
   strcpy(pLodDirectory.pFilename, "npcgroup.bin");
   pLodDirectory.uDataSize = 102;
   if ( pNew_LOD->Write(&pLodDirectory, pNPCStats->pGroups_copy, 0) )
   {
-    sprintf(Str, pGlobalTXT_LocalizationStrings[612], 206);
-    MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:829", 0);
+    sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 206);
+    MessageBoxA(nullptr, work_string, "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
     {
-      sprintf(Str, "data\\lloyd%d%d.pcx", i, j);
-      v8 = fopen(Str, "rb");
-      if ( v8 )
+      sprintf(work_string, "data\\lloyd%d%d.pcx", i, j);
+      pLLoidFile = fopen(work_string, "rb");
+      if ( pLLoidFile )
       {
         __debugbreak();
-        sprintf(Str, "lloyd%d%d.pcx", i, j);
-        fseek(v8, 0, 2);
-        pLodDirectory.uDataSize = ftell(v8);
-        rewind(v8);
-        fread(uncompressed_buff, pLodDirectory.uDataSize, 1, v8);
-        strcpy((char *)&pLodDirectory, Str);
-        fclose(v8);
-        remove(Str);
+        sprintf(work_string, "lloyd%d%d.pcx", i, j);
+        fseek(pLLoidFile, 0, SEEK_END);
+        pLodDirectory.uDataSize = ftell(pLLoidFile);
+        rewind(pLLoidFile);
+        fread(uncompressed_buff, pLodDirectory.uDataSize, 1, pLLoidFile);
+        strcpy(pLodDirectory.pFilename, work_string);
+        fclose(pLLoidFile);
+        remove(work_string);
         if ( pNew_LOD->Write(&pLodDirectory, uncompressed_buff, 0) )
         {
-          sprintf(Str, pGlobalTXT_LocalizationStrings[612], 207);
-          MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
+          sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 207);
+          MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:857", 0);
           Size = 5080748;
         }
       }
@@ -467,8 +423,8 @@
       data_write_pos += 112 * uNumSpriteObjects;
       memcpy(data_write_pos, &uNumChests, 4);
       data_write_pos += 4;
-      memcpy(data_write_pos, pChests, 5324 * uNumChests);
-      data_write_pos += 5324 * uNumChests;
+      memcpy(data_write_pos, pChests, sizeof(Chest)*uNumChests);//5324 *
+      data_write_pos += sizeof(Chest)* uNumChests;
       memcpy(data_write_pos, pIndoor->pDoors, 0x3E80);
       data_write_pos += 16000;
       memcpy(data_write_pos, pIndoor->ptr_0002B4_doors_ddata, pIndoor->blv.uDoors_ddata_Size);
@@ -516,8 +472,8 @@
       data_write_pos += 112 * uNumSpriteObjects;
       memcpy(data_write_pos, &uNumChests, 4);
       data_write_pos += 4;
-      memcpy(data_write_pos, pChests, 5324 * uNumChests);
-      data_write_pos += 5324 * uNumChests;
+      memcpy(data_write_pos, pChests, sizeof(Chest)* uNumChests);
+      data_write_pos += sizeof(Chest)* uNumChests;
       memcpy(data_write_pos, &stru_5E4C90, 0xC8);
       data_write_pos += 200;
       memcpy(data_write_pos, &pOutdoor->loc_time, 0x38);
@@ -525,11 +481,11 @@
     }
     strcpy(Source, pCurrentMapName);
     _splitpath(Source, Drive, Dir, Filename, Ext);
-    v48 = 100;
+   
     Size = (int)data_write_pos - (int)uncompressed_buff;
     compressed_block_size = 999984;
-    LOBYTE(v33) = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size);
-    if ( v33 || (signed int)compressed_block_size > (signed int)Size )
+    res = zlib::MemZip((char *)compressed_buf + 16, (unsigned int *)&compressed_block_size, uncompressed_buff,Size);
+    if (res || (signed int)compressed_block_size > (signed int)Size )
     {
       memcpy((void *)(compressed_buf + 16), uncompressed_buff, Size);
       compressed_block_size = Size;
@@ -538,12 +494,12 @@
     memcpy(&((ODMHeader *)compressed_buf)->uCompressedSize, &compressed_block_size, 4);
     memcpy(&((ODMHeader *)compressed_buf)->uDecompressedSize, &Size, 4);
     sprintf(Source, "%s%s", &Filename, &Ext);
-    strcpy((char *)&pLodDirectory, Source);
+    strcpy(pLodDirectory.pFilename, Source);
     pLodDirectory.uDataSize = compressed_block_size;
     if ( pNew_LOD->Write(&pLodDirectory, (const void *)compressed_buf, 0) )
     {
-      sprintf(Str, pGlobalTXT_LocalizationStrings[612], 208);
-      MessageBoxA(nullptr, Str, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
+      sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 208);
+      MessageBoxA(nullptr, work_string, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\LoadSave.cpp:1071", 0);
     }
     free((void *)compressed_buf);
   }
@@ -552,18 +508,17 @@
   {
     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);
+      FormatMessageA(0x1000, 0, GetLastError(), 0x400, Buffer, 0x80, 0);
+      sprintf(work_string, pGlobalTXT_LocalizationStrings[612], 300);
+      MessageBoxA(nullptr, work_string, "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;
-  pParty->sRotationX = v54;
+  pParty->vPosition.y = pPositionY;
+  pParty->vPosition.z = pPositionZ;
+  pParty->uFallStartY = pPositionZ;
+  pParty->sRotationY = sPRotationY;
+  pParty->sRotationX = sPRotationX;
 }