Mercurial > mm7
changeset 382:a4a5996fea5b
Fixed savelist problem
author | Gloval |
---|---|
date | Fri, 22 Feb 2013 23:46:31 +0400 |
parents | 243418228760 |
children | c3a0d94c07a5 |
files | GameUIs.cpp Indoor.cpp SaveLoad.cpp SaveLoad.h |
diffstat | 4 files changed, 41 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/GameUIs.cpp Fri Feb 22 22:27:45 2013 +0400 +++ b/GameUIs.cpp Fri Feb 22 23:46:31 2013 +0400 @@ -87,7 +87,7 @@ //Str1 = (const char *)pSavegameList->pSavesNames; //while ( 1 ) //{ - sprintf(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[i]); + sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[i].pSaveFileName); if (_access(pTmpBuf, 6)) { pSavegameUsedSlots[i] = 0; @@ -98,13 +98,13 @@ v4 = pLODFile.FindContainer("header.bin", true); if ( v4 ) fread(&pSavegameHeader[i], 0x64, 1, v4); - if ( !_strcmpi(pSavegameList->pSavesNames[i], pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" + if ( !_strcmpi(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave" v5 = pLODFile.FindContainer("image.pcx", true); if ( !v5 ) { pSavegameUsedSlots[i] = 0; - strcpy(pSavegameList->pSavesNames[i], ""); + strcpy(pSavegameList->pFileList[i].pSaveFileName, ""); } else { @@ -161,24 +161,16 @@ } //----- (0045E93E) -------------------------------------------------------- -void __cdecl GameUI_DrawSaveMenu() +void GameUI_DrawSaveMenu() { unsigned int v0; // ebp@4 unsigned int v1; // eax@4 - unsigned int *v2; // ebp@6 char *v3; // eax@7 FILE *v4; // eax@11 FILE *v5; // eax@11 - const char *v6; // ST64_4@14 - GUIButton *v7; // eax@16 - char *v8; // [sp+10h] [bp-254h]@6 - SavegameHeader *Dest; // [sp+14h] [bp-250h]@6 - RGBTexture *this_; // [sp+18h] [bp-24Ch]@6 LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1 - int v12; // [sp+260h] [bp-4h]@1 ++pIcons_LOD->uTexturePacksCount; - v12 = 0; if ( !pIcons_LOD->uNumPrevLoadedFiles ) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; memset(pSavegameUsedSlots, 0, 0xB4u); @@ -189,9 +181,7 @@ uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); - pRenderer->DrawTextureIndexed( - 8u, - 8u, + pRenderer->DrawTextureIndexed( 8u, 8u, (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0)); if ( pCurrentScreen == SCREEN_SAVEGAME ) { @@ -204,54 +194,48 @@ v1 = uTextureID_LS_loadU; } pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0)); - pRenderer->DrawTextureIndexed( - 0x15Fu, - 0x12Eu, + pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu, (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0)); pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0)); pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0); pRenderer->Present(); pSavegameList->Initialize(1u); v11.AllocSubIndicesAndIO(0x12Cu, 0); - v2 = pSavegameUsedSlots; - Dest = pSavegameHeader; - this_ = pSavegameThumbnails; - v8 = (char *)pSavegameList->pSavesNames; - do - { - v3 = v8; - if ( !*v8 ) + //v2 = pSavegameUsedSlots; + // Dest = pSavegameHeader; + // this_ = pSavegameThumbnails; + // v8 = (char *)pSavegameList->pSavesNames; + for (uint i = 0; i < 40; ++i) + { + v3 = pSavegameList->pFileList[i].pSaveFileName; + if ( !pSavegameList->pFileList[i].pSaveFileName ) v3 = "1.mm7"; sprintf(pTmpBuf, "saves\\%s", v3); if ( _access(pTmpBuf, 0) || _access(pTmpBuf, 6) ) { - v6 = pGlobalTXT_LocalizationStrings[72]; - *v2 = 0; - strcpy(Dest->pName, v6); + pSavegameUsedSlots[i] = 0; + strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]); } else { v11.LoadFile(pTmpBuf, 1); v4 = v11.FindContainer("header.bin", 1); - fread(Dest, 0x64u, 1u, v4); + fread(&pSavegameHeader[i], 100, 1u, v4); v5 = v11.FindContainer("image.pcx", 1); if ( v5 ) { - this_->LoadFromFILE(v5, 0, 1u); + pSavegameThumbnails[i].LoadFromFILE(v5, 0, 1u); v11.CloseWriteFile(); - *v2 = 1; + pSavegameUsedSlots[i] = 1; } else { - *v2 = 0; + pSavegameUsedSlots[i] = 0; } } - v8 += 280; - ++this_; - ++Dest; - ++v2; + } - while ( (signed int)v8 < (signed int)&_69FBB4_ptr_iterator_end ); + v11.FreeSubIndexAndIO(); uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE); @@ -273,5 +257,4 @@ (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0); pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, 0xA3u, 0x22u, 0, "", (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0); - v12 = -1; } \ No newline at end of file
--- a/Indoor.cpp Fri Feb 22 22:27:45 2013 +0400 +++ b/Indoor.cpp Fri Feb 22 23:46:31 2013 +0400 @@ -4670,8 +4670,8 @@ if (uItemID) { if (uItemID != 220 && pItemsTable->pItems[uItemID].uEquipType == EQUIP_POTION && - !p->stru_24._bonus_type) - p->stru_24._bonus_type = rand() % 15 + 5; + !p->stru_24.uEncantmentType) + p->stru_24.uEncantmentType = rand() % 15 + 5; pItemsTable->SetSpecialBonus(&p->stru_24); } }
--- a/SaveLoad.cpp Fri Feb 22 22:27:45 2013 +0400 +++ b/SaveLoad.cpp Fri Feb 22 23:46:31 2013 +0400 @@ -85,7 +85,7 @@ } } - sprintf(pTmpBuf, "saves\\%s", pSavegameList->pSavesNames[uSlot]); + sprintf(pTmpBuf, "saves\\%s", pSavegameList->pFileList[uSlot].pSaveFileName); pNew_LOD->CloseWriteFile(); if (!CopyFileA(pTmpBuf, "data\\new.lod", 0)) @@ -670,14 +670,14 @@ //----- (0045E297) -------------------------------------------------------- void SavegameList::Initialize(unsigned int bHideEmptySlots) { - //memset(pSavegameList, 0, 0x3138); - Reset(); + memset(pSavegameList, 0, 0x3138); + // Reset(); uNumSavegameFiles = 0; _chdir("saves"); { if (!bHideEmptySlots && _access(pGlobalTXT_LocalizationStrings[613], 0) != -1 ) // AutoSave.MM7 - strcpy(pSavesNames[uNumSavegameFiles++], pGlobalTXT_LocalizationStrings[613]); + strcpy(pSavegameList->pFileList[uNumSavegameFiles++].pSaveFileName, pGlobalTXT_LocalizationStrings[613]); for (uint i = 0; i < 40; ++i) { @@ -688,7 +688,7 @@ uint idx = i; if (!bHideEmptySlots) idx = uNumSavegameFiles; - strcpy(pSavesNames[idx], pTmpBuf); + strcpy(pSavegameList->pFileList[idx].pSaveFileName, pTmpBuf); ++uNumSavegameFiles; }
--- a/SaveLoad.h Fri Feb 22 22:27:45 2013 +0400 +++ b/SaveLoad.h Fri Feb 22 23:46:31 2013 +0400 @@ -1,23 +1,28 @@ #pragma once - +#pragma pack(push, 1) +struct SaveFile_ + { + char field_0[20]; + char pSaveFileName[260]; + }; +#pragma pack(pop) /* 243 */ #pragma pack(push, 1) struct SavegameList { - void Initialize(unsigned int a1); + static void Initialize(unsigned int a1); - inline void Reset() + /*inline void Reset() { for (int i = 0; i < 20; ++i) field_0[i] = 0; for (int i = 0; i < 44; ++i) pSavesNames[i][0] = 0; - } - - char field_0[20]; - char pSavesNames[44][280]; + }*/ + SaveFile_ pFileList[45]; + }; #pragma pack(pop)