# HG changeset patch # User Nomad # Date 1368271195 -7200 # Node ID 08fd1436ef355d14cb45eb0b61a2a40ae91c3669 # Parent a6ef7125f6e4963b231664b1fe6e3101d81cd2c7 enums & lod diff -r a6ef7125f6e4 -r 08fd1436ef35 GUIWindow.h --- a/GUIWindow.h Sat May 11 01:28:06 2013 +0200 +++ b/GUIWindow.h Sat May 11 13:19:55 2013 +0200 @@ -212,18 +212,18 @@ /* 251 */ enum MENU_STATE : __int32 { - MENU_MAIN = 0x0, - MENU_NEWGAME = 0x1, - MENU_CREDITS = 0x2, - MENU_SAVELOAD = 0x3, - MENU_FINISHED = 0x4, - MENU_5 = 0x5, - MENU_CREATEPARTY = 0x6, - MENU_NAMEPANELESC = 0x7, - MENU_CREDITSPROC = 0x8, - MENU_LoadingProcInMainMenu = 0x9, - MENU_10 = 0xA, - MENU_CREDITSCLOSE = 0xB, + MENU_MAIN = 0, + MENU_NEWGAME = 1, + MENU_CREDITS = 2, + MENU_SAVELOAD = 3, + MENU_EXIT_GAME = 4, + MENU_5 = 5, + MENU_CREATEPARTY = 6, + MENU_NAMEPANELESC = 7, + MENU_CREDITSPROC = 8, + MENU_LoadingProcInMainMenu = 9, + MENU_10 = 10, + MENU_CREDITSCLOSE = 11, }; diff -r a6ef7125f6e4 -r 08fd1436ef35 Game.cpp --- a/Game.cpp Sat May 11 01:28:06 2013 +0200 +++ b/Game.cpp Sat May 11 13:19:55 2013 +0200 @@ -258,15 +258,15 @@ Player *pPlayer; // esi@65 //OtherOverlay *pOtherOverlay; // esi@67 //signed int v8; // edi@67 - int pPlayerNum; // edi@69 + //int pPlayerNum; // edi@69 int *pHealth; // esi@71 - signed int v11; // esi@78 - int v12; // eax@83 + //signed int v11; // esi@78 + //int v12; // eax@83 const char *pLocationName; // [sp-4h] [bp-68h]@74 bool bLoading; // [sp+10h] [bp-54h]@1 - signed int bLoadinga; // [sp+10h] [bp-54h]@19 + //signed int bLoadinga; // [sp+10h] [bp-54h]@19 signed int v16; // [sp+14h] [bp-50h]@8 - int v17[4]; // [sp+18h] [bp-4Ch]@80 + //int v17[4]; // [sp+18h] [bp-4Ch]@80 MSG Msg; // [sp+28h] [bp-3Ch]@20 char Source[64]; // [sp+44h] [bp-20h]@76 @@ -276,7 +276,7 @@ { pParty->Reset(); dword_6BE340 = 0; - uGameState = GAME_STATE_0; + uGameState = GAME_STATE_PLAYING; LoadGame(uLoadGameUI_SelectedSlot); } @@ -314,7 +314,8 @@ pAsyncKeyboard->Resume(); if ( pRenderer->pRenderD3D ) pGame->pVisInstance->_4C1A02(); - bLoadinga = 0; + + bool game_finished = false; do { while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) ) @@ -349,7 +350,7 @@ pMouse->_469EA4(); pRenderer->EndScene(); } - if ( pVideoPlayer->pBinkMovie && !BinkWait(pVideoPlayer->pBinkMovie) ) + else if ( pVideoPlayer->pBinkMovie && !BinkWait(pVideoPlayer->pBinkMovie) ) { pRenderer->BeginScene(); pMouse->DrawCursorToTarget(); @@ -358,22 +359,13 @@ pRenderer->EndScene(); } - static int gtc_old = GetTickCount(); - int gtc = GetTickCount(); - auto evt_old = pEventTimer->uStartTime, - msc_old = pMiscTimer->uStartTime; - pEventTimer->Update(); - pMiscTimer->Update(); - Log::Warning(L"Evt/Msc/GTC dt: %u/%u/%u", pEventTimer->uTimeElapsed, pMiscTimer->uTimeElapsed, gtc - gtc_old); - gtc_old = gtc; - OnTimer(0); GameUI_StatusBar_UpdateTimedString(0); if ( pMiscTimer->bPaused && !pEventTimer->bPaused ) pMiscTimer->Resume(); if ( pEventTimer->bTackGameTime && !pParty->bTurnBasedModeOn ) pEventTimer->bTackGameTime = 0; - if ( !pEventTimer->bPaused && uGameState == GAME_STATE_0) + if ( !pEventTimer->bPaused && uGameState == GAME_STATE_PLAYING) { if ( !pEventTimer->bTackGameTime ) _494035_timed_effects__water_walking_damage__etc(); @@ -396,14 +388,14 @@ if (uGameState == GAME_FINISHED) //goto LABEL_96; { - bLoadinga = 1; + game_finished = true; continue; } if (uGameState == GAME_STATE_2) { pAudioPlayer->StopChannels(-1, -1); PrepareWorld(0); - uGameState = GAME_STATE_0; + uGameState = GAME_STATE_PLAYING; continue; } if ( (signed int)uGameState <= GAME_STATE_2 ) @@ -415,7 +407,7 @@ if ( (signed int)uGameState <= GAME_STATE_5 || uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU ) { //LABEL_96: - bLoadinga = 1; + game_finished = true; continue; } if ( uGameState != GAME_STATE_PARTY_DIED ) @@ -467,11 +459,9 @@ pParty->uTimePlayed += 0x276000ui64; LOWORD(pParty->uFlags) &= ~0x204; pParty->SetGold(0); - pOtherOverlayList->Reset(); + memset(pParty->pPartyBuffs, 0, 0x140u); - memset(pParty->pPartyBuffs, 0, 0x140u); - pPlayerNum = 1; if ( pParty->bTurnBasedModeOn == 1 ) { pTurnEngine->End(1); @@ -523,23 +513,27 @@ PrepareWorld(1); } InitializeActors(); - v11 = 0; - do + + + int num_conscious_players = 0; + int conscious_players_ids[4] = {-1, -1, -1, -1}; + for (int v11 = 0; v11 < 4; ++v11) { - if ( pPlayers[pPlayerNum]->CanAct() ) - v17[v11++] = pPlayerNum; - ++pPlayerNum; + if (pPlayers[v11 + 1]->CanAct()) + conscious_players_ids[num_conscious_players++] = v11; } - while ( pPlayerNum <= 4 ); - if ( v11 ) + if (num_conscious_players) { - v12 = rand(); - pPlayers[v17[v12 % v11]]->PlaySound(SPEECH_99, 0); + int idx = conscious_players_ids[rand() % num_conscious_players]; + assert(idx >= 0); + pPlayers[idx + 1]->PlaySound(SPEECH_99, 0); } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[524], 2u);// "Once again you've cheated death!.." "Вы снова обхитрили смерть! …" - uGameState = GAME_STATE_0; + uGameState = GAME_STATE_PLAYING; } - while ( !bLoadinga ); + while (!game_finished); + dword_6BE340 = 0; pEventTimer->Pause(); ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); @@ -547,7 +541,7 @@ { sub_491E3A(); LoadPlayerPortraintsAndVoices(); - uGameState = GAME_STATE_0; + uGameState = GAME_STATE_PLAYING; pIcons_LOD->dword_11B84 = pIcons_LOD->uNumLoadedFiles; bLoading = true; continue; diff -r a6ef7125f6e4 -r 08fd1436ef35 Game.h --- a/Game.h Sat May 11 01:28:06 2013 +0200 +++ b/Game.h Sat May 11 13:19:55 2013 +0200 @@ -27,13 +27,13 @@ /* 320 */ enum GAME_STATE { - GAME_STATE_0 = 0, + GAME_STATE_PLAYING = 0, GAME_FINISHED = 1, GAME_STATE_2 = 2, GAME_STATE_3 = 3, GAME_STATE_NEWGAME_OUT_GAMEMENU = 4, GAME_STATE_5 = 5, - GAME_STATE_6 = 6, + GAME_STATE_STARTING_NEW_GAME = 6, GAME_STATE_GAME_QUITTING_TO_MAIN_MENU = 7, GAME_STATE_PARTY_DIED = 8, GAME_STATE_FINAL_WINDOW = 9, diff -r a6ef7125f6e4 -r 08fd1436ef35 LOD.cpp --- a/LOD.cpp Sat May 11 01:28:06 2013 +0200 +++ b/LOD.cpp Sat May 11 13:19:55 2013 +0200 @@ -1001,7 +1001,7 @@ strcpy(pHeader->pSignature, "LOD"); pHeader->LODSize = 100; pHeader->uNumIndices = 1; - pDir->pFilename[15] = 0; + pDir->field_F = 0; pDir->uDataSize = 0; pDir->uOfsetFromSubindicesStart = 288; strcpy(pLODName, lod_name); @@ -1430,8 +1430,7 @@ //----- (00461FD4) ---LODFile_sub_461FD4---text:004632EA -------------------------------------------------- int LODWriteableFile::FixDirectoryOffsets() - { - LOD::Directory Lindx; +{ int total_size; // edi@1 int temp_offset; // ecx@5 FILE *tmp_file; // eax@9 @@ -1455,9 +1454,10 @@ tmp_file = fopen(Filename, "wb+"); if ( tmp_file ) - { + { fwrite((const void *)&header, sizeof(LOD::FileHeader), 1, tmp_file); - Lindx.Reset(); + + LOD::Directory Lindx; strcpy(Lindx.pFilename, "chapter"); Lindx.uOfsetFromSubindicesStart=uOffsetToSubIndex; //10h 16 Lindx.uDataSize=sizeof(LOD::Directory) * uNumSubDirs + total_size; //14h 20 @@ -1501,47 +1501,29 @@ //----- (00461F71) -------------------------------------------------------- bool LOD::File::AppendDirectory(LOD::Directory *pDir, const void *pData) { - if ( uNumSubDirs < 299 ) - { - memcpy(&pSubIndices[uNumSubDirs], pDir, sizeof(LOD::Directory)); - ++uNumSubDirs; - fwrite(pData, 1u, pDir->uDataSize, pOutputFileHandle); - return true; - } - else - { - MessageBoxA(0, "Unable to append item!", "LOD::File", 0x30u); - return false; - } + assert(uNumSubDirs < 299); + + memcpy(&pSubIndices[uNumSubDirs++], pDir, sizeof(LOD::Directory)); + fwrite(pData, 1, pDir->uDataSize, pOutputFileHandle); + return true; } //----- (00461F1E) -------------------------------------------------------- int LODWriteableFile::CreateTempFile() { - int result; // eax@2 - FILE *pFile; // eax@5; - if ( isFileOpened ) + if (!isFileOpened) + return 1; + + if (pIOBuffer && uIOBufferSize ) { - if (pIOBuffer && uIOBufferSize ) - { - uCurrentIndexDir = 0; - uNumSubDirs = 0; - pFile = fopen("lodapp.tmp", "wb+"); - pOutputFileHandle = pFile; - result =pFile? 1:7; - - } - else - { - result = 5; - } + uCurrentIndexDir = 0; + uNumSubDirs = 0; + pOutputFileHandle = fopen("lodapp.tmp", "wb+"); + return pOutputFileHandle ? 1 : 7; } else - { - result = 1; - } - return result; + return 5; } @@ -1566,8 +1548,7 @@ //----- (00461B48) -------------------------------------------------------- unsigned int LODWriteableFile::Write(const LOD::Directory *pDir, const void *pDirData, int a4) - { - LOD::Directory Lindx; +{ char Filename[256]; char NewFilename[256]; FILE *tmp_file; @@ -1631,8 +1612,9 @@ size_correction=0; else size_correction=pSubIndices[insert_index].uDataSize; + //create chapter index - Lindx.Reset(); + LOD::Directory Lindx; strcpy(Lindx.pFilename, "chapter"); Lindx.dword_000018=0; Lindx.word_00001E=0; @@ -1723,39 +1705,34 @@ //----- (00461A43) -------------------------------------------------------- bool LODWriteableFile::LoadFile(const char *pFilename, bool bWriting) - { - LOD::Directory lod_indx ; +{ + if (bWriting & 1) + pFile = fopen(pFilename, "rb"); + else + pFile = fopen(pFilename, "rb+"); + if (!pFile) + return false; - if (bWriting & 1) - pFile = fopen(pFilename, "rb"); - else - pFile = fopen(pFilename, "rb+"); - if (!pFile) - return false; + strcpy(pLODName, pFilename); + fread(&header, sizeof(LOD::FileHeader), 1, pFile); + + LOD::Directory lod_indx; + fread( &lod_indx,sizeof(LOD::Directory), 1, pFile); - strcpy(pLODName, pFilename); - fread(&header, sizeof(LOD::FileHeader), 1, pFile); - lod_indx.Reset(); - fread( &lod_indx,sizeof(LOD::Directory), 1, pFile); - fseek(pFile, 0, SEEK_SET); - isFileOpened = true; - strcpy(pContainerName, "chapter"); - uCurrentIndexDir = 0; - uLODDataSize = lod_indx.uDataSize; - uNumSubDirs = lod_indx.uNumSubIndices; - uOffsetToSubIndex = lod_indx.uOfsetFromSubindicesStart; - fseek(pFile, uOffsetToSubIndex, SEEK_SET); + fseek(pFile, 0, SEEK_SET); + isFileOpened = true; + strcpy(pContainerName, "chapter"); + uCurrentIndexDir = 0; + uLODDataSize = lod_indx.uDataSize; + uNumSubDirs = lod_indx.uNumSubIndices; + assert(uNumSubDirs <= 300); - if (uNumSubDirs > 300) - { - MessageBoxW(0, L"LODchapterPages exceed 300", L"LODFile", MB_ICONEXCLAMATION); - fclose(pFile); - return false; - } + uOffsetToSubIndex = lod_indx.uOfsetFromSubindicesStart; + fseek(pFile, uOffsetToSubIndex, SEEK_SET); - fread(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, pFile); - return true; - } + fread(pSubIndices, sizeof(LOD::Directory), uNumSubDirs, pFile); + return true; +} //----- (00461A11) -------------------------------------------------------- @@ -1859,17 +1836,6 @@ } -//----- (004617B6) -------------------------------------------------------- -void LOD::FileHeader::Reset() -{ - this->pSignature[0] = 0; - this->LodVersion[0] = 0; - this->LodDescription[0] = 0; - this->LODSize = 0; - this->dword_0000A8 = 0; - this->uNumIndices = 0; -} - //----- (00461790) -------------------------------------------------------- LOD::File::~File() { @@ -1903,22 +1869,6 @@ } -//----- (00461743) -------------------------------------------------------- -LOD::Directory *LOD::Directory::Reset() -{ - LOD::Directory *result; // eax@1 - - result = this; - this->pFilename[0] = 0; - this->uOfsetFromSubindicesStart = 0; - this->uDataSize = 0; - this->dword_000018 = 0; - this->uNumSubIndices = 0; - this->word_00001E = 0; - return result; -} - - //----- (0046172B) -------------------------------------------------------- LOD::Directory::Directory() { diff -r a6ef7125f6e4 -r 08fd1436ef35 LOD.h --- a/LOD.h Sat May 11 01:28:06 2013 +0200 +++ b/LOD.h Sat May 11 13:19:55 2013 +0200 @@ -19,6 +19,7 @@ #pragma pack(push, 1) struct FileHeader { + //----- (004617B6) -------------------------------------------------------- inline FileHeader() { memset(pSignature, 0, 4); @@ -26,10 +27,15 @@ memset(LodDescription, 0, 80); memset(array_0000B0, 0, 28); memset(array_0000CC, 0, 52); + + pSignature[0] = 0; + LodVersion[0] = 0; + LodDescription[0] = 0; + LODSize = 0; + dword_0000A8 = 0; + uNumIndices = 0; } - void Reset(); - char pSignature[4]; char LodVersion[80]; //char field_C[32]; @@ -48,10 +54,9 @@ struct Directory { Directory(); - Directory *Reset(); - - char pFilename[16]; + char pFilename[15]; + char field_F; unsigned int uOfsetFromSubindicesStart; unsigned int uDataSize; int dword_000018; diff -r a6ef7125f6e4 -r 08fd1436ef35 SaveLoad.cpp --- a/SaveLoad.cpp Sat May 11 01:28:06 2013 +0200 +++ b/SaveLoad.cpp Sat May 11 13:19:55 2013 +0200 @@ -229,7 +229,7 @@ //----- (0045F469) -------------------------------------------------------- void SaveGame( bool IsAutoSAve, bool NotSaveWorld ) - { +{ unsigned short *pScreenshot; // edi@5 int text_pos; // eax@6 FILE *pLLoidFile; // edi@24 @@ -250,7 +250,6 @@ ODMHeader odm_data; // [sp+218h] [bp-58h]@30 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 char *uncompressed_buff; // [sp+258h] [bp-18h]@2 unsigned int compressed_block_size; // [sp+260h] [bp-10h]@23 @@ -261,7 +260,8 @@ return; uncompressed_buff = (char*)malloc(1000000); - pLodDirectory.Reset(); + + LOD::Directory pLodDirectory; // [sp+22Ch] [bp-44h]@2 pPositionX = pParty->vPosition.x; pPositionY = pParty->vPosition.y; pPositionZ = pParty->vPosition.z; diff -r a6ef7125f6e4 -r 08fd1436ef35 Spells.cpp --- a/Spells.cpp Sat May 11 01:28:06 2013 +0200 +++ b/Spells.cpp Sat May 11 13:19:55 2013 +0200 @@ -232,79 +232,57 @@ //----- (00458585) -------------------------------------------------------- void SpellBuff::Reset() { - - this->uSkill = 0; - this->uPower = 0; - this->uExpireTime = 0i64; - this->uCaster = 0; - this->uFlags = 0; - if ( this->uOverlayID ) + uSkill = 0; + uPower = 0; + uExpireTime = 0i64; + uCaster = 0; + uFlags = 0; + if (uOverlayID) { - ((OtherOverlay *)&stru_5E4C90._decor_events[20 * this->uOverlayID + 105])->Reset(); + pOtherOverlayList->pOverlays[uOverlayID - 1].Reset(); pOtherOverlayList->bRedraw = true; - this->uOverlayID = 0; + uOverlayID = 0; } } //----- (004585CA) -------------------------------------------------------- signed int SpellBuff::_4585CA(__int64 a2) { - signed int result; // eax@3 - - if ( this->uExpireTime && (signed __int64)this->uExpireTime < a2 ) + if (uExpireTime && uExpireTime < a2) { - this->uExpireTime = 0i64; - this->uPower = 0; - this->uSkill = 0; - this->uOverlayID = 0; - result = 1; + uExpireTime = 0; + uPower = 0; + uSkill = 0; + uOverlayID = 0; + return true; } - else - { - result = 0; - } - return result; + return false; } //----- (004584E0) -------------------------------------------------------- -signed int SpellBuff::Apply(unsigned __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int a5, unsigned __int8 a6) +bool SpellBuff::Apply(unsigned __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int uOverlayID, unsigned __int8 caster) { - SpellBuff *v6; // esi@1 - signed int result; // eax@3 - int v8; // eax@4 + if (this->uExpireTime && uExpireTime < this->uExpireTime) + return false; - v6 = this; - if ( this->uExpireTime && (signed __int64)uExpireTime < (signed __int64)this->uExpireTime ) - { - result = 0; - } - else + this->uSkill = uSkillLevel; + this->uPower = uPower; + this->uExpireTime = uExpireTime; + if (this->uOverlayID && this->uOverlayID != uOverlayID) { - this->uSkill = uSkillLevel; - this->uPower = uPower; - LOWORD(v8) = this->uOverlayID; - this->uExpireTime = uExpireTime; - if ( (short)v8 ) - { - v8 = (unsigned __int16)v8; - if ( (unsigned __int16)v8 != a5 ) - { - ((OtherOverlay *)&stru_5E4C90._decor_events[20 * v8 + 105])->Reset(); - pOtherOverlayList->bRedraw = true; - v6->uOverlayID = 0; - } - } - v6->uOverlayID = a5; - v6->uCaster = a6; - result = 1; + pOtherOverlayList->pOverlays[this->uOverlayID - 1].Reset(); + pOtherOverlayList->bRedraw = true; + this->uOverlayID = 0; } - return result; + this->uOverlayID = uOverlayID; + this->uCaster = caster; + + return true; } //----- (0045384A) -------------------------------------------------------- void SpellStats::Initialize() - { - +{ int decode_step; char* test_string; bool break_loop; diff -r a6ef7125f6e4 -r 08fd1436ef35 Spells.h --- a/Spells.h Sat May 11 01:28:06 2013 +0200 +++ b/Spells.h Sat May 11 13:19:55 2013 +0200 @@ -155,7 +155,7 @@ uFlags = 0; } - signed int Apply(unsigned __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int a5, unsigned __int8 a6); + bool Apply(unsigned __int64 uExpireTime, unsigned __int16 uSkillLevel, unsigned __int16 uPower, int uOverlayID, unsigned __int8 caster); void Reset(); signed int _4585CA(__int64 a2); bool NotExpired(); diff -r a6ef7125f6e4 -r 08fd1436ef35 UIPartyCreation.cpp --- a/UIPartyCreation.cpp Sat May 11 01:28:06 2013 +0200 +++ b/UIPartyCreation.cpp Sat May 11 13:19:55 2013 +0200 @@ -653,16 +653,16 @@ // 4E28F8: using guessed type int pCurrentScreen; //----- (0049750E) -------------------------------------------------------- -void __cdecl DeleteCCharFont() +void DeleteCCharFont() { pAllocator->FreeChunk(pFontCChar); pFontCChar = 0; } //----- (00497526) -------------------------------------------------------- -bool __cdecl PlayerCreationUI_Loop() +bool PlayerCreationUI_Loop() { //RGBTexture *pTexture; // ebx@1 - UINT v1; // esi@1 + //UINT v1; // esi@1 unsigned int v2; // ecx@3 LONG uMouseX; // edi@6 LONG uMouseY; // eax@6 @@ -691,7 +691,6 @@ //Player *pPlayer; //pTexture = &pTexture_PCX; - v1 = 0; v26 = 0; pTexture_PCX.Release(); pTexture_PCX.Load("makeme.pcx", 0); @@ -703,7 +702,7 @@ SetCurrentMenuID((MENU_STATE)v2); while ( GetCurrentMenuID() == MENU_CREATEPARTY ) { - if ( pAsyncMouse != (void *)v1 ) + if (pAsyncMouse) pAsyncMouse->_46B736_consume_click_lists(1); uMouseX = pMouse->GetCursorPos(&v25)->x; uMouseY = pMouse->GetCursorPos(&v25)->y; @@ -727,7 +726,7 @@ while ( pControlsHead != (GUIButton *)v1 ); }*/ - while ( PeekMessageA(&Msg, (HWND)v1, v1, v1, PM_REMOVE) ) + while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) ) { if ( Msg.message == WM_QUIT ) Game_DeinitializeAndTerminate(0); @@ -751,15 +750,15 @@ v26 = 1; //v2 = 0; //goto LABEL_27; - SetCurrentMenuID((MENU_STATE)MENU_MAIN); + SetCurrentMenuID(MENU_MAIN); continue; } - if ( uGameState == GAME_STATE_6 )//if click OK in PlayerCreation Window + if ( uGameState == GAME_STATE_STARTING_NEW_GAME )//if click OK in PlayerCreation Window { - uGameState = v1; + uGameState = GAME_STATE_PLAYING; //v2 = 1; //goto LABEL_27; - SetCurrentMenuID((MENU_STATE)MENU_NEWGAME); + SetCurrentMenuID(MENU_NEWGAME); continue; } } @@ -768,6 +767,7 @@ pGUIWindow_CurrentMenu->Release(); pIcons_LOD->_4114F2(); + int v1 = 0; memset(v20, 0, 32); do { @@ -890,7 +890,7 @@ for (uint k = 0; k < 138; k++) { - if (&player->pInventoryItems[k]) + if (player->pInventoryItems[k].uItemID) player->pInventoryItems[k].SetIdentified(); } } diff -r a6ef7125f6e4 -r 08fd1436ef35 mm7_2.cpp --- a/mm7_2.cpp Sat May 11 01:28:06 2013 +0200 +++ b/mm7_2.cpp Sat May 11 13:19:55 2013 +0200 @@ -6283,10 +6283,6 @@ void SaveNewGame() { FILE *v3; // eax@7 - LOD::FileHeader this_; // [sp+Ch] [bp-16Ch]@3 - LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4 - LOD::Directory save_game_dir; // [sp+12Ch] [bp-4Ch]@9 - LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3 void *pSave; // [sp+170h] [bp-8h]@3 if ( pVideoPlayer->AnyMovieLoaded() ) @@ -6294,21 +6290,24 @@ pSave = pAllocator->AllocNamedChunk(0, 1000000, 0); pNew_LOD->CloseWriteFile(); remove("data\\new.lod"); - this_.Reset(); + + LOD::FileHeader this_; // [sp+Ch] [bp-16Ch]@3 strcpy(this_.LodVersion, "MMVII"); strcpy(this_.LodDescription, "newmaps for MMVII"); this_.LODSize = 100; this_.dword_0000A8 = 0; + + LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3 a3.dword_000018 = 0; a3.word_00001E = 0; strcpy(a3.pFilename, "current"); pNew_LOD->CreateNewLod(&this_, &a3, "data\\new.lod"); - if ( pNew_LOD->LoadFile("data\\new.lod", 0) ) + if (pNew_LOD->LoadFile("data\\new.lod", false)) { pNew_LOD->CreateTempFile(); pNew_LOD->uNumSubDirs = 0; - pDir.Reset(); - + + LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4 for (int i = pGames_LOD->uNumSubDirs / 2; i < pGames_LOD->uNumSubDirs; ++i) { memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir)); @@ -6316,11 +6315,13 @@ fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, v3); pNew_LOD->AppendDirectory(&pDir, pSave); } - save_game_dir.Reset(); + + LOD::Directory save_game_dir; // [sp+12Ch] [bp-4Ch]@9 strcpy(pSavegameHeader[0].pLocationName, "out01.odm"); strcpy(save_game_dir.pFilename, "header.bin"); - save_game_dir.uDataSize = 100; + save_game_dir.uDataSize = sizeof(SavegameHeader); pNew_LOD->AppendDirectory(&save_game_dir, &pSavegameHeader[0]); + pNew_LOD->FixDirectoryOffsets(); pParty->vPrevPosition.y = 0; pParty->vPrevPosition.x = 12552; @@ -9382,7 +9383,7 @@ //bool v9; // edx@16 //OtherOverlay *v10; // esi@44 //signed int v11; // edi@44 - unsigned int v12; // ecx@56 + //unsigned int v12; // ecx@56 HANDLE v13; // eax@68 unsigned int startms; // [sp+8h] [bp-24h]@55 RECT Rect; // [sp+Ch] [bp-20h]@15 @@ -9464,21 +9465,17 @@ while ( 1 ) { MainMenu_Loop(); - uGameState = GAME_STATE_0; + uGameState = GAME_STATE_PLAYING; //LABEL_21: while ( 1 ) { - switch (uGameState) - { - case GAME_FINISHED: - pGame->Deinitialize(); - return true; - } - if (GetCurrentMenuID() == MENU_FINISHED) - { - uGameState = GAME_FINISHED; - continue; - } + if (uGameState == GAME_FINISHED || + GetCurrentMenuID() == MENU_EXIT_GAME) + { + pGame->Deinitialize(); + return true; + } + if (GetCurrentMenuID() == MENU_NEWGAME) { if ( pAudioPlayer->hAILRedbook ) @@ -9499,13 +9496,17 @@ pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); SaveNewGame(); pGame->Loop(); - if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU ) + + if (uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU) { SetCurrentMenuID(MENU_NEWGAME); - uGameState = GAME_STATE_0; + uGameState = GAME_STATE_PLAYING; continue; } - break; + else if (uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU) + break; + + assert(false && "Invalid game state"); } if (GetCurrentMenuID() == MENU_CREDITS) { @@ -9517,7 +9518,7 @@ } if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) { - uGameState = GAME_STATE_0; + uGameState = GAME_STATE_PLAYING; } else { @@ -9554,22 +9555,20 @@ LABEL_49: if ( uGameState == GAME_STATE_3 ) { - v12 = 5; - SetCurrentMenuID((MENU_STATE)v12); - //goto LABEL_21; - uGameState = GAME_STATE_0; + SetCurrentMenuID(MENU_5); + uGameState = GAME_STATE_PLAYING; continue; } if ( uGameState == GAME_STATE_NEWGAME_OUT_GAMEMENU ) { SetCurrentMenuID(MENU_NEWGAME); - uGameState = GAME_STATE_0; + uGameState = GAME_STATE_PLAYING; continue; } if ( uGameState == GAME_STATE_GAME_QUITTING_TO_MAIN_MENU)// from the loaded game { pAudioPlayer->StopChannels(-1, -1); - uGameState = GAME_STATE_0; + uGameState = GAME_STATE_PLAYING; break; } } @@ -9847,20 +9846,20 @@ { switch (m) { - case -1: return L"-1"; - case MENU_MAIN: return L"MENU_MAIN"; - case MENU_NEWGAME: return L"MENU_NEWGAME"; - case MENU_CREDITS: return L"MENU_CREDITS"; - case MENU_SAVELOAD: return L"MENU_SAVELOAD"; - case MENU_FINISHED: return L"MENU_FINISHED"; - case MENU_5: return L"MENU_5"; - case MENU_CREATEPARTY: return L"MENU_CREATEPARTY"; + case -1: return L"-1"; + case MENU_MAIN: return L"MENU_MAIN"; + case MENU_NEWGAME: return L"MENU_NEWGAME"; + case MENU_CREDITS: return L"MENU_CREDITS"; + case MENU_SAVELOAD: return L"MENU_SAVELOAD"; + case MENU_EXIT_GAME: return L"MENU_EXIT_GAME"; + case MENU_5: return L"MENU_5"; + case MENU_CREATEPARTY: return L"MENU_CREATEPARTY"; case MENU_NAMEPANELESC: return L"MENU_NAMEPANELESC"; - case MENU_CREDITSPROC: return L"MENU_CREDITSPROC"; + case MENU_CREDITSPROC: return L"MENU_CREDITSPROC"; case MENU_LoadingProcInMainMenu: return L"MENU_LoadingProcInMainMenu"; - case MENU_10: return L"MENU_10"; + case MENU_10: return L"MENU_10"; case MENU_CREDITSCLOSE: return L"MENU_CREDITSCLOSE"; - default: return L"unk"; + default: return L"unk"; }; }; void SetCurrentMenuID(MENU_STATE uMenu) diff -r a6ef7125f6e4 -r 08fd1436ef35 mm7_5.cpp --- a/mm7_5.cpp Sat May 11 01:28:06 2013 +0200 +++ b/mm7_5.cpp Sat May 11 13:19:55 2013 +0200 @@ -2231,7 +2231,7 @@ continue; case UIMSG_C4: __debugbreak; - uGameState = GAME_STATE_0; + uGameState = GAME_STATE_PLAYING; strcpy((char *)pKeyActionMap->pPressedKeysBuffer, "2"); goto LABEL_524; case UIMSG_DD: @@ -3341,7 +3341,7 @@ break; case UIMSG_ExitToWindows: GUIWindow::Create(495, 337, 0, 0, WINDOW_PressedButton2, (int)pMainMenu_BtnExit, 0); - SetCurrentMenuID(MENU_FINISHED); + SetCurrentMenuID(MENU_EXIT_GAME); break; case UIMSG_PlayerCreation_SelectAttribute: pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) @@ -3435,7 +3435,7 @@ if ( PlayerCreation_ComputeAttributeBonus() || !PlayerCreation_Chose4Skills() ) GameUI_Footer_TimeLeft = GetTickCount() + 4000; else - uGameState = GAME_STATE_6; + uGameState = GAME_STATE_STARTING_NEW_GAME; break; case UIMSG_PlayerCreationClickReset: GUIWindow::Create(527, 431, 0, 0, WINDOW_PressedButton2, (int)pPlayerCreationUI_BtnReset, 0); diff -r a6ef7125f6e4 -r 08fd1436ef35 stru6.cpp --- a/stru6.cpp Sat May 11 01:28:06 2013 +0200 +++ b/stru6.cpp Sat May 11 13:19:55 2013 +0200 @@ -1286,11 +1286,6 @@ PlayerBuffAnim *v4; // esi@1 const char *v6; // [sp-4h] [bp-10h]@2 - //v3 = this; - //v4 = &array_0[uPlayerID]; - //v4[32].uSpellIconID_ = 0; pPlayerBuffs[]::field_4 - //v4[32].uSpellID = uSpellID; pPlayerBuffs[]::bRender - v4 = &pPlayerBuffs[uPlayerID]; v4->uSpellAnimTimeElapsed = 0; v4->bRender = uSpellID != 0; @@ -1298,7 +1293,6 @@ switch (uSpellID) { case SPELL_DISEASE: - //__debugbreak(); // spell id == 153 wtf , curse probably ? happening when attacked by harpies /disease(Ritor1)/ v6 = "zapp"; break; @@ -1367,16 +1361,12 @@ case SPELL_BODY_PROTECTION_FROM_MAGIC: v6 = "spell75"; break; default: - //v4[32].uSpellID = 0; v4->bRender = false; return; } - //v4[33].uSpellIconID = pIconsFrameTable->FindIcon(v6); v4->uSpellIconID = pIconsFrameTable->FindIcon(v6); - //if ( v4[32].uSpellID ) if (v4->bRender) - //v3->array_0[(signed __int16)uPlayerID + 33].uSpellAnimLength = 8 * pIconsFrameTable->pIcons[v4[33].uSpellIconID].uAnimLength; v4->uSpellAnimTime = 8 * pIconsFrameTable->pIcons[v4->uSpellIconID].uAnimLength; }