Mercurial > might-and-magic-trilogy
diff mm7_3.cpp @ 2:2ca04ccb612a
NoCD, main menu, various
author | Nomad |
---|---|
date | Wed, 10 Oct 2012 14:21:15 +0200 |
parents | ac0fb48cd27a |
children | 540178ef9b18 |
line wrap: on
line diff
--- a/mm7_3.cpp Tue Oct 09 13:09:08 2012 +0200 +++ b/mm7_3.cpp Wed Oct 10 14:21:15 2012 +0200 @@ -5674,7 +5674,7 @@ pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0); strtok(pAwardsTXT_Raw, "\r"); v7 = pAwards; - do + for (uint i = 0; i < 104; ++i) { v1 = strtok(v0, "\r") + 1; v6 = v0; @@ -5721,7 +5721,7 @@ while ( (signed int)(v6 - 1) <= 2 && (char *)v5 == v0 ); ++v7; } - while ( (signed int)v7 < (signed int)&dword_7241C8 ); + //while ( (signed int)v7 < (signed int)&dword_7241C8 ); } // 7241C8: using guessed type int dword_7241C8; @@ -5744,7 +5744,7 @@ pScrollsTXT_Raw = (char *)pEvents_LOD->LoadRaw("scroll.txt", 0); strtok(pScrollsTXT_Raw, "\r"); v6 = pScrolls; - do + for (uint i = 0; i < 82; ++i) { v1 = strtok(v0, "\r") + 1; v2 = 0; @@ -5784,15 +5784,15 @@ while ( v2 - 1 <= 1 && (char *)v7 == v0 ); ++v6; } - while ( (signed int)v6 < (signed int)dword_723E80_award_related ); -} -// 723E80: using guessed type int dword_723E80_award_related[]; + //while ( (signed int)v6 < (signed int)dword_723E80_award_related ); +} + //----- (00476590) -------------------------------------------------------- void __cdecl InitializeMerchants() { char *v0; // ebx@1 - char **v1; // edi@3 + //char **v1; // edi@3 char *v2; // ecx@4 char v3; // dl@5 char *v4; // eax@5 @@ -5806,8 +5806,8 @@ pMerchantsTXT_Raw = 0; pMerchantsTXT_Raw = (char *)pEvents_LOD->LoadRaw("merchant.txt", 0); strtok(pMerchantsTXT_Raw, "\r"); - v1 = (char **)pMerchantsRepairPhrases; - do + //v1 = (char **)pMerchantsRepairPhrases; + for (uint i = 0; i < 7; ++i) { v7 = v0; v6 = (signed int)v0; @@ -5840,24 +5840,24 @@ { if ( v7 == (char *)1 ) { - *(v1 - 14) = RemoveQuotes(v2); + pMerchantsBuyPhrases[i] = RemoveQuotes(v2); } else { if ( v7 == (char *)2 ) { - *(v1 - 7) = RemoveQuotes(v2); + pMerchantsSellPhrases[i] = RemoveQuotes(v2); } else { if ( v7 == (char *)3 ) { - *v1 = RemoveQuotes(v2); + pMerchantsRepairPhrases[i] = RemoveQuotes(v2); } else { if ( v7 - 3 == (char *)1 ) - v1[7] = RemoveQuotes(v2); + pMerchantsIdentifyPhrases[i] = RemoveQuotes(v2); } } } @@ -5866,9 +5866,9 @@ v2 = (char *)(v5 + 1); } while ( (signed int)(v7 - 1) <= 4 && (char *)v6 == v0 ); - ++v1; - } - while ( (signed int)v1 < (signed int)pMerchantsIdentifyPhrases ); + //++v1; + } + //while ( (signed int)v1 < (signed int)pMerchantsIdentifyPhrases ); } //----- (00476682) -------------------------------------------------------- @@ -5890,7 +5890,7 @@ pTransitionsTXT_Raw = (char *)pEvents_LOD->LoadRaw("trans.txt", 0); strtok(pTransitionsTXT_Raw, "\r"); v6 = pTransitionStrings; - do + for (uint i = 0; i < 464; ++i) { v1 = strtok(v0, "\r") + 1; v2 = 0; @@ -5930,7 +5930,7 @@ while ( v2 - 1 <= 1 && (char *)v7 == v0 ); ++v6; } - while ( (signed int)v6 < (signed int)"awards.txt" ); + //while ( (signed int)v6 < (signed int)"awards.txt" ); } //----- (00476750) -------------------------------------------------------- @@ -5950,7 +5950,7 @@ pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0); strtok(pAutonoteTXT_Raw, "\r"); v0 = (char *)&stru_723720[0].eType; - do + for (uint i = 0; i < 195; ++i) { v1 = 0; v2 = strtok(0, "\r") + 1; @@ -6016,9 +6016,9 @@ while ( v1 - 1 <= 2 && !v6 ); v0 += 8; } - while ( (signed int)v0 < (signed int)&pScrolls[1] ); -} -// 723720: using guessed type Autonote stru_723720[195]; + //while ( (signed int)v0 < (signed int)&pScrolls[1] ); +} + //----- (004768A9) -------------------------------------------------------- void __cdecl InitializeQuests() @@ -6029,7 +6029,7 @@ char v3; // dl@5 char *v4; // ecx@5 int v5; // esi@9 - const char **v6; // [sp+10h] [bp-8h]@3 + //const char **v6; // [sp+10h] [bp-8h]@3 signed int v7; // [sp+14h] [bp-4h]@4 v0 = 0; @@ -6038,8 +6038,10 @@ pQuestsTXT_Raw = 0; pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0); strtok(pQuestsTXT_Raw, "\r"); - v6 = pQuestTable; - do + + //v6 = pQuestTable; + for (uint i = 0; i < 512; ++i) + //do { v1 = strtok(v0, "\r") + 1; v2 = 0; @@ -6071,15 +6073,15 @@ else { if ( v2 == 1 ) - *v6 = RemoveQuotes(v1); + pQuestTable[i] = RemoveQuotes(v1); } ++v2; v1 = (char *)(v5 + 1); } while ( v2 - 1 <= 1 && (char *)v7 == v0 ); - ++v6; - } - while ( (signed int)v6 < (signed int)&unk_723714 ); + //++v6; + } + //while ( (signed int)v6 < (signed int)&unk_723714 ); } @@ -6087,19 +6089,14 @@ //----- (00476977) -------------------------------------------------------- void NPCStats::Initialize2() { - NPCStats *v1; // esi@1 - char *v2; // ebx@1 - char *v3; // eax@3 char *v4; // eax@4 char v5; // dl@5 char *v6; // ecx@5 int v7; // edi@9 - char *v8; // eax@20 char *v9; // eax@21 char v10; // dl@22 char *v11; // ecx@22 int v12; // edi@26 - char *v13; // eax@37 char *v14; // eax@39 char v15; // dl@40 int v16; // ecx@40 @@ -6110,29 +6107,28 @@ signed int v21; // ecx@58 char *v22; // [sp+10h] [bp-10h]@4 char *v23; // [sp+10h] [bp-10h]@21 - char *v24; // [sp+10h] [bp-10h]@39 char *v25; // [sp+14h] [bp-Ch]@4 char *v26; // [sp+14h] [bp-Ch]@21 signed int v27; // [sp+14h] [bp-Ch]@39 - signed int v28; // [sp+18h] [bp-8h]@3 - signed int v29; // [sp+18h] [bp-8h]@20 + //signed int v28; // [sp+18h] [bp-8h]@3 + //signed int v29; // [sp+18h] [bp-8h]@20 signed int v30; // [sp+18h] [bp-8h]@37 char *v31; // [sp+1Ch] [bp-4h]@37 - v1 = this; - v2 = 0; - if ( this->pNPCTextTXT_Raw ) - pAllocator->FreeChunk(this->pNPCTextTXT_Raw); - v1->pNPCTextTXT_Raw = 0; - v3 = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0); - v1->pNPCTextTXT_Raw = v3; - strtok(v3, "\r"); - v28 = (signed int)&unk_72166C_pNPCText; - do - { - v4 = strtok(v2, "\r") + 1; - v22 = v2; - v25 = v2; + //v1 = this; + //v2 = 0; + if (pNPCTextTXT_Raw) + pAllocator->FreeChunk(pNPCTextTXT_Raw); + + //v3 = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0); + pNPCTextTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctext.txt", 0); + strtok(pNPCTextTXT_Raw, "\r"); + + for (uint i = 0; i < 789; ++i) + { + v4 = strtok(nullptr, "\r") + 1; + v22 = nullptr; + v25 = nullptr; do { v5 = *v4; @@ -6147,40 +6143,39 @@ v5 = v4[(int)v6]; } while ( v5 != 9 ); - v2 = 0; + //v2 = 0; } v7 = (int)&v4[(int)v6]; if ( !v4[(int)v6] ) v25 = (char *)1; *(char *)v7 = 0; - if ( v6 == v2 ) + if ( v6 == nullptr ) { v25 = (char *)1; } else { if ( v22 == (char *)1 ) - *(int *)v28 = (int)RemoveQuotes(v4); + pNPCTopics[i].pText = RemoveQuotes(v4); } ++v22; v4 = (char *)(v7 + 1); } - while ( (signed int)(v22 - 1) <= 1 && v25 == v2 ); - v28 += 8; - } - while ( v28 < (signed int)pQuestTable ); - if ( v1->pNPCTopicTXT_Raw != v2 ) - pAllocator->FreeChunk(v1->pNPCTopicTXT_Raw); - v1->pNPCTopicTXT_Raw = v2; - v8 = (char *)pEvents_LOD->LoadRaw("npctopic.txt", (int)v2); - v1->pNPCTopicTXT_Raw = v8; - strtok(v8, "\r"); - v29 = (signed int)&unk_721668_pNPCTopic; - do - { - v9 = strtok(v2, "\r") + 1; - v23 = v2; - v26 = v2; + while ( (signed int)(v22 - 1) <= 1 && v25 == nullptr ); + } + + if (pNPCTopicTXT_Raw) + pAllocator->FreeChunk(pNPCTopicTXT_Raw); + + //v8 = (char *)pEvents_LOD->LoadRaw("npctopic.txt", (int)v2); + pNPCTopicTXT_Raw = (char *)pEvents_LOD->LoadRaw("npctopic.txt", 0); + strtok(pNPCTopicTXT_Raw, "\r"); + + for (uint i = 0; i < 579; ++i) + { + v9 = strtok(nullptr, "\r") + 1; + v23 = nullptr; + v26 = nullptr; do { v10 = *v9; @@ -6195,42 +6190,43 @@ v10 = v9[(int)v11]; } while ( v10 != 9 ); - v2 = 0; + //v2 = 0; } v12 = (int)&v9[(int)v11]; if ( !v9[(int)v11] ) v26 = (char *)1; *(char *)v12 = 0; - if ( v11 == v2 ) + if ( v11 == nullptr ) { v26 = (char *)1; } else { if ( v23 == (char *)1 ) - *(int *)v29 = (int)RemoveQuotes(v9); + pNPCTopics[i].pTopic = RemoveQuotes(v9); } ++v23; v9 = (char *)(v12 + 1); } - while ( (signed int)(v23 - 1) <= 1 && v26 == v2 ); - v29 += 8; - } - while ( v29 < (signed int)&unk_722880 ); - if ( v1->pNPCDistTXT_Raw != v2 ) - pAllocator->FreeChunk(v1->pNPCDistTXT_Raw); - v1->pNPCDistTXT_Raw = v2; - v13 = (char *)pEvents_LOD->LoadRaw("npcdist.txt", (int)v2); - v1->pNPCDistTXT_Raw = v13; - strtok(v13, "\r"); - strtok(v2, "\r"); + while ( (signed int)(v23 - 1) <= 1 && v26 == nullptr ); + } + + if (pNPCDistTXT_Raw) + pAllocator->FreeChunk(pNPCDistTXT_Raw); + + //v13 = (char *)pEvents_LOD->LoadRaw("npcdist.txt", (int)v2); + pNPCDistTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcdist.txt", 0); + strtok(pNPCDistTXT_Raw, "\r"); + strtok(nullptr, "\r"); v30 = 1; - v31 = &v1->array_16544[0].field_4[1]; + v31 = &array_16544[0].field_4[1]; + + char *v2 = 0; while ( 2 ) { - v14 = strtok(v2, "\r") + 1; + v14 = strtok(nullptr, "\r") + 1; v27 = 0; - v24 = v2; + char *v24 = nullptr; do { v15 = *v14; @@ -6261,7 +6257,7 @@ { if ( (signed int)v2 < 77 ) { - v1->array_16544[(int)v2].field_4[v30] = atoi(v14); + array_16544[(int)v2].field_4[v30] = atoi(v14); goto LABEL_54; } v18 = v2 == 0; @@ -6283,7 +6279,7 @@ } break; } - v19 = v1->array_16544; + v19 = array_16544; v20 = 77; do { @@ -6296,10 +6292,11 @@ --v20; } while ( v20 ); - if ( v1->pNPCDistTXT_Raw ) - { - pAllocator->FreeChunk(v1->pNPCDistTXT_Raw); - v1->pNPCDistTXT_Raw = 0; + + if (pNPCDistTXT_Raw) + { + pAllocator->FreeChunk(pNPCDistTXT_Raw); + pNPCDistTXT_Raw = nullptr; } } @@ -6569,13 +6566,13 @@ //----- (0047702F) -------------------------------------------------------- void NPCStats::Initialize() { - NPCStats *v1; // edi@1 + //NPCStats *v1; // edi@1 char *v2; // ebx@1 - char *v3; // eax@1 + //char *v3; // eax@1 char *v4; // ebx@3 char v5; // al@4 int v6; // ecx@4 - char *v7; // eax@18 + //char *v7; // eax@18 char *v8; // ebx@18 char *v9; // ecx@19 char v10; // dl@20 @@ -6590,8 +6587,7 @@ char *v19; // [sp+18h] [bp-8h]@18 signed int v20; // [sp+1Ch] [bp-4h]@3 signed int v21; // [sp+1Ch] [bp-4h]@19 - - v1 = this; + //v1 = this; Initialize1(); Initialize2(); @@ -6603,13 +6599,13 @@ InitializeMerchants(); InitializeScrolls(); v2 = 0; - v1->field_17FC0 = 0; - v1->pNPCNamesTXT_Raw = 0; - v3 = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0); - v1->pNPCNamesTXT_Raw = v3; - strtok(v3, "\r"); + field_17FC0 = 0; + pNPCNamesTXT_Raw = 0; + //v3 = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0); + pNPCNamesTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcnames.txt", 0); + strtok(pNPCNamesTXT_Raw, "\r"); v18 = 0; - v16 = (char *)v1->pNPCNames; + v16 = (char *)pNPCNames; while ( 1 ) { v4 = strtok(v2, "\r") + 1; @@ -6648,8 +6644,8 @@ else { LABEL_45: - if ( v20 == 1 && !v1->uNumNPCNames[1] ) - v1->uNumNPCNames[1] = v18; + if ( v20 == 1 && !uNumNPCNames[1] ) + uNumNPCNames[1] = v18; } ++v20; v4 += v14 + 1; @@ -6661,16 +6657,16 @@ break; v2 = 0; } - v1->pNPCProfTXT_Raw = 0; - v1->uNumNPCNames[0] = v18; - v7 = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0); - v1->pNPCProfTXT_Raw = v7; - strtok(v7, "\r"); + pNPCProfTXT_Raw = 0; + uNumNPCNames[0] = v18; + //v7 = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0); + pNPCProfTXT_Raw = (char *)pEvents_LOD->LoadRaw("npcprof.txt", 0); + strtok(pNPCProfTXT_Raw, "\r"); strtok(0, "\r"); strtok(0, "\r"); strtok(0, "\r"); - v8 = (char *)&v1->pProfessions[0].pJoinText; - v19 = (char *)&v1->pProfessions[0].pJoinText; + v8 = (char *)&pProfessions[0].pJoinText; + v19 = (char *)&pProfessions[0].pJoinText; v13 = 58; do { @@ -6732,7 +6728,7 @@ v19 = v8; } while ( !v12 ); - v1->uNumNPCProfessions = 59; + uNumNPCProfessions = 59; } //----- (00477266) -------------------------------------------------------- @@ -16876,7 +16872,7 @@ 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, 0x280u, 0x1E0u, (enum WindowType)17, 0, (int)byte_591098); + result = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)17, 0, (int)byte_591098); pDialogueWindow = result; return result; } @@ -17066,10 +17062,8 @@ //----- (00445308) -------------------------------------------------------- -int __fastcall sub_445308(int a1) -{ - int result; // eax@12 - +const char *__fastcall sub_445308(int a1) +{ if ( a1 == 10 || a1 == 11 || a1 == 12 @@ -17081,12 +17075,11 @@ || a1 == 42 || a1 == 43 || a1 == 52 ) - result = *(&pNPCStats->field_13A60 + 5 * a1); - else - result = dword_722320; - return result; -} -// 722320: using guessed type int dword_722320; + return (const char *)*(&pNPCStats->field_13A60 + 5 * a1); + else + return pNPCTopics[407].pTopic; +} + //----- (00445350) -------------------------------------------------------- void __cdecl DrawDialogueUI() @@ -17246,7 +17239,7 @@ } if ( byte_5B0938[0] ) goto LABEL_24; - v7 = ptr_F8B1E8; + v7 = (char *)ptr_F8B1E8; LABEL_37: v8 = 0; goto LABEL_38; @@ -18154,7 +18147,7 @@ pVideoPlayer->Unload(); pVideoPlayer->bStopBeforeSchedule = 0; pVideoPlayer->field_40 = 0; - if ( pAsyncMouse ) + if (pAsyncMouse) pAsyncMouse->Suspend(); v128 = uGame_if_0_else_ui_id__11_save__else_load__8_drawSpellInfoPopup__22_final_window__26_keymapOptions__2_options__28_videoOptions; v13 = &pSomeEVT[v9]; @@ -18193,7 +18186,7 @@ if ( v128 == 13 ) pVideoPlayer->_4BF28F(pAnimatedRooms[uCurrentHouse_Animation].field_0, 1u); } - if ( pAsyncMouse ) + if (pAsyncMouse) pAsyncMouse->Resume(); goto LABEL_291; case EVENT_CheckSkill: @@ -18339,13 +18332,13 @@ if ( EnterHouse((enum HOUSE_TYPE)170) ) { pAudioPlayer->StopChannels(-1, -1); - ptr_507BC0 = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_HouseInterior, 170, 0); + ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 170, 0); ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, v7, 0); ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, v7, 0); ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, v7, 0); ptr_507BC0->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 4u, 0x34u, v7, 0); ptr_507BC0->CreateButton(0, 0, 0, 0, 1, 0, 0xB0u, 0, 9u, v7, 0); - ptr_F8B1E8 = (char *)dword_72193C; + ptr_F8B1E8 = pNPCTopics[90].pText; } } } @@ -18417,7 +18410,7 @@ if ( EnterHouse((enum HOUSE_TYPE)165) ) { pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0); - v47 = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_HouseInterior, 165, 0); + v47 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 165, 0); ptr_507BC0 = v47; v48 = v47->pControlsHead; if ( v48 ) @@ -19140,7 +19133,7 @@ v104 = 187; if ( uCurrentHouse_Animation != 167 ) v104 = v103; - ptr_507BC0 = GUIWindow::Create(0, 0, 0x280u, 0x1E0u, WINDOW_HouseInterior, v104, 0); + ptr_507BC0 = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0); ptr_507BC0->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 1u, 0x31u, v7, 0); ptr_507BC0->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 2u, 0x32u, v7, 0); ptr_507BC0->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, 0x6Eu, 3u, 0x33u, v7, 0);