# HG changeset patch # User Gloval # Date 1362167001 -14400 # Node ID 35f28d4c0ff9ac7950b9bcb232b12efaf3f53ab9 # Parent 8f70e52646ebaeda8fc76c8339ca52a93477955d GlobalEventInfo changed to LevelDecoration* activeLevelDecoration diff -r 8f70e52646eb -r 35f28d4c0ff9 Events.cpp --- a/Events.cpp Fri Mar 01 22:18:22 2013 +0400 +++ b/Events.cpp Fri Mar 01 23:43:21 2013 +0400 @@ -298,7 +298,7 @@ } player_choose = (uActiveCharacter == 0)?6:4; //4 - active or 6 - random player if active =0 curr_seq_num = start_event_seq_number; - if ( GlobalEventInfo ) + if ( activeLevelDecoration ) { uSomeEVT_NumEvents = uGlobalEVT_NumEvents; pSomeEVT = pGlobalEVT; @@ -524,15 +524,15 @@ //v7 = ""; break; case EVENT_ChangeEvent: - v25 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8); + v25 = EVT_DWORD(_evt->v5); if ( v25 ) { - stru_5E4C90._decor_events[GlobalEventInfo + 28] = _evt->v5 - 124; + stru_5E4C90._decor_events[activeLevelDecoration->_idx_in_stru123] = _evt->v5 - 124; } else { - v26 = (LevelDecoration *)GlobalEventInfo; - stru_5E4C90._decor_events[GlobalEventInfo + 28] = 0; + v26 = (LevelDecoration *)activeLevelDecoration; + stru_5E4C90._decor_events[activeLevelDecoration ->_idx_in_stru123] = 0; LOBYTE(v26->field_2) |= 0x20u; } ++curr_seq_num; @@ -722,7 +722,7 @@ pVideoPlayer->Unload(); window_SpeakInHouse->Release(); pParty->uFlags &= 0xFFFFFFFDu; - GlobalEventInfo = 1; + activeLevelDecoration = (LevelDecoration*)1; if ( EnterHouse(HOUSE_BODY_GUILD_ERATHIA) ) { pAudioPlayer->PlaySound((SoundID)0, 0, 0, -1, 0, 0, 0, 0); @@ -1253,9 +1253,9 @@ break; case EVENT_StatusText: v90 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - if ( GlobalEventInfo ) + if ( activeLevelDecoration ) { - if ( GlobalEventInfo == 1 ) + if ( activeLevelDecoration == (void*)1 ) { ptr_F8B1E8 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; ++curr_seq_num; @@ -1300,7 +1300,7 @@ break; case EVENT_ShowMessage: v92 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); - if ( GlobalEventInfo ) + if ( activeLevelDecoration ) { v93 = (char *)pNPCTopics[v92-1].pText;//(&dword_721664)[8 * v92]; byte_5B0938[0] = 0; @@ -1453,7 +1453,7 @@ } else { - pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((GlobalEventInfo == 0) + 1); + pGameLoadingUI_ProgressBar->uType = (GUIProgressBar::Type)((activeLevelDecoration == NULL) + 1); sub_44987B(v99, 0); v133 = 1; if ( pCurrentScreen == SCREEN_HOUSE ) diff -r 8f70e52646eb -r 35f28d4c0ff9 Indoor.cpp --- a/Indoor.cpp Fri Mar 01 22:18:22 2013 +0400 +++ b/Indoor.cpp Fri Mar 01 23:43:21 2013 +0400 @@ -41,7 +41,7 @@ LevelDecoration pLevelDecorations[3000]; size_t uNumLevelDecorations; -int GlobalEventInfo; +LevelDecoration* activeLevelDecoration; LEVEL_TYPE uCurrentlyLoadedLevelType = LEVEL_null; diff -r 8f70e52646eb -r 35f28d4c0ff9 Indoor.h --- a/Indoor.h Fri Mar 01 22:18:22 2013 +0400 +++ b/Indoor.h Fri Mar 01 23:43:21 2013 +0400 @@ -42,7 +42,7 @@ #pragma pack(pop) extern LevelDecoration pLevelDecorations[3000]; extern size_t uNumLevelDecorations; -extern int GlobalEventInfo; +extern LevelDecoration* activeLevelDecoration; diff -r 8f70e52646eb -r 35f28d4c0ff9 mm7_1.cpp --- a/mm7_1.cpp Fri Mar 01 22:18:22 2013 +0400 +++ b/mm7_1.cpp Fri Mar 01 23:43:21 2013 +0400 @@ -5244,9 +5244,9 @@ if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) { v15 = stru_5E4C90._decor_events[v13->_idx_in_stru123 - 75] + 380; - GlobalEventInfo = (int)&pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; + activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; EventProcessor(v15, 0, 1); - GlobalEventInfo = 0; + activeLevelDecoration = NULL; } return; } diff -r 8f70e52646eb -r 35f28d4c0ff9 mm7_2.cpp --- a/mm7_2.cpp Fri Mar 01 22:18:22 2013 +0400 +++ b/mm7_2.cpp Fri Mar 01 23:43:21 2013 +0400 @@ -4304,7 +4304,7 @@ pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pKeyActionMap->_459ED1(3); pKeyActionMap->ResetKeys(); - GlobalEventInfo = 0; + activeLevelDecoration = NULL; ptr_F8B1E8 = 0; if ( pDialogueNPCCount ) { @@ -15028,9 +15028,9 @@ v10 = v8->_idx_in_stru123; v24 = 1; v11 = stru_5E4C90._decor_events[v10 - 75] + 380; - GlobalEventInfo = (int)v8; + activeLevelDecoration = v8; EventProcessor(v11, 0, 1); - GlobalEventInfo = 0; + activeLevelDecoration = NULL; } break; diff -r 8f70e52646eb -r 35f28d4c0ff9 mm7_3.cpp --- a/mm7_3.cpp Fri Mar 01 22:18:22 2013 +0400 +++ b/mm7_3.cpp Fri Mar 01 23:43:21 2013 +0400 @@ -14065,7 +14065,7 @@ pEventTimer->Pause(); dword_5C3418 = v4; dword_5C341C = v3; - _591094_decoration = (LevelDecoration *)GlobalEventInfo; + _591094_decoration = activeLevelDecoration; pGUIWindow2 = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)19, a4, 0); pGUIWindow2->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 1u, 0x31u, "", 0); pGUIWindow2->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, 0x6Eu, 2u, 0x32u, "", 0); @@ -14079,11 +14079,11 @@ { pGUIWindow2->Release(); pGUIWindow2 = 0; - GlobalEventInfo = (int)_591094_decoration; + activeLevelDecoration = _591094_decoration; start_event_seq_number = dword_5C341C; EventProcessor(dword_5C3418, 0, 1); start_event_seq_number = 0; - GlobalEventInfo = 0; + activeLevelDecoration = NULL; pEventTimer->Resume(); } diff -r 8f70e52646eb -r 35f28d4c0ff9 mm7_4.cpp --- a/mm7_4.cpp Fri Mar 01 22:18:22 2013 +0400 +++ b/mm7_4.cpp Fri Mar 01 23:43:21 2013 +0400 @@ -9458,9 +9458,9 @@ else { ptr_F8B1E8 = 0; - GlobalEventInfo = 1; + activeLevelDecoration = (LevelDecoration*)1; EventProcessor(pEventNumber, 0, 1); - GlobalEventInfo = 0; + activeLevelDecoration = NULL; } } } @@ -11940,234 +11940,227 @@ //----- (004BC49B) -------------------------------------------------------- void OnSelectDialogueOption(DIALOGUE_TYPE newDialogueType) -{ - //unsigned int v1; // esi@1 - NPCData *speakingNPC; // ebp@1 - //unsigned int v3; // eax@1 - int npc_event_id; // ecx@10 - signed int v5; // edi@14 - char *v6; // esi@15 - const char *v7; // ecx@22 - signed int v8; // edi@37 - //unsigned int v9; // eax@56 - unsigned int v10; // ecx@57 - void *v11; // [sp-Ch] [bp-1Ch]@46 - int v12; // [sp-8h] [bp-18h]@46 - char *v13; // [sp-8h] [bp-18h]@60 - size_t v14; // [sp-4h] [bp-14h]@46 - const char *v15; // [sp-4h] [bp-14h]@60 - - //v1 = _this; - speakingNPC = GetNPCData(uDialogue_SpeakingActorNPC_ID); - //v3 = v1; - uDialogueType = newDialogueType; - if ( !speakingNPC->uFlags ) - { - speakingNPC->uFlags = 1; - //v3 = uDialogueType; - } - if ((newDialogueType>DIALOGUE_24)||(newDialogueType 84 && (signed int)newDialogueType <= 88 ) - { - ArenaFight(); - return; - } - } - goto LABEL_87; - } - if (speakingNPC->Hired()) - { - v8 = 0; - if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) - { - v6 = (char *)pNPCStats->pNewNPCData; - while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) ) - { - ++v8; - v6 += 76; - if ( v8 >= (signed int)pNPCStats->uNumNewNPCs ) - goto LABEL_44; - } - goto LABEL_43; - } + { + //unsigned int v1; // esi@1 + NPCData *speakingNPC; // ebp@1 + //unsigned int v3; // eax@1 + int npc_event_id; // ecx@10 + signed int v5; // edi@14 + char *v6; // esi@15 + const char *v7; // ecx@22 + signed int v8; // edi@37 + //unsigned int v9; // eax@56 + unsigned int v10; // ecx@57 + void *v11; // [sp-Ch] [bp-1Ch]@46 + int v12; // [sp-8h] [bp-18h]@46 + char *v13; // [sp-8h] [bp-18h]@60 + size_t v14; // [sp-4h] [bp-14h]@46 + const char *v15; // [sp-4h] [bp-14h]@60 + + //v1 = _this; + speakingNPC = GetNPCData(uDialogue_SpeakingActorNPC_ID); + //v3 = v1; + uDialogueType = newDialogueType; + if ( !speakingNPC->uFlags ) + { + speakingNPC->uFlags = 1; + //v3 = uDialogueType; + } + if ((newDialogueType>DIALOGUE_24)||(newDialogueType 84 && (signed int)newDialogueType <= 88 ) + { + ArenaFight(); + return; + } + } + goto LABEL_87; + } + if (speakingNPC->Hired()) + { + v8 = 0; + if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) + { + v6 = (char *)pNPCStats->pNewNPCData; + while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) ) + { + ++v8; + v6 += 76; + if ( v8 >= (signed int)pNPCStats->uNumNewNPCs ) + goto LABEL_44; + } + goto LABEL_43; + } LABEL_44: - if ( !pParty->pHirelings[0].pName || _strcmpi(pParty->pHirelings[0].pName, speakingNPC->pName) ) - { - if ( !pParty->pHirelings[1].pName || _strcmpi(pParty->pHirelings[1].pName, speakingNPC->pName) ) - { + if ( !pParty->pHirelings[0].pName || _strcmpi(pParty->pHirelings[0].pName, speakingNPC->pName) ) + { + if ( !pParty->pHirelings[1].pName || _strcmpi(pParty->pHirelings[1].pName, speakingNPC->pName) ) + { LABEL_51: - pParty->field_709 = 0; - sub_44A56A(); - dword_591084 = 0; - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - - goto LABEL_89; - } - v11 = &pParty->pHirelings[1]; - } - else - { - v11 = pParty->pHirelings; - } - memset(v11, 0, sizeof(NPCData)); - goto LABEL_51; - } - if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName ) - { - v7 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full"" + pParty->field_709 = 0; + sub_44A56A(); + dword_591084 = 0; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + + goto LABEL_89; + } + v11 = &pParty->pHirelings[1]; + } + else + { + v11 = pParty->pHirelings; + } + memset(v11, 0, sizeof(NPCData)); + goto LABEL_51; + } + if ( pParty->pHirelings[0].pName && pParty->pHirelings[1].pName ) + { + v7 = pGlobalTXT_LocalizationStrings[533]; // ""I cannot join you, you're party is full"" LABEL_64: - ShowStatusBarString(v7, 2u); - goto LABEL_87; - } - //v9 = v2->uProfession; - if ( speakingNPC->uProfession != 51 ) - { - v10 = pNPCStats->pProfessions[speakingNPC->uProfession - 1].uHirePrice; - if ( pParty->uNumGold < v10 ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold" - dialogue_show_profession_details = false; - uDialogueType = 13; - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); - v7 = pGlobalTXT_LocalizationStrings[155]; - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); - goto LABEL_87; - } - Party::TakeGold(v10); - } - LOBYTE(speakingNPC->uFlags) |= 0x80u; - if ( pParty->pHirelings[0].pName ) - { - memcpy(&pParty->pHirelings[1], speakingNPC, sizeof(pParty->pHirelings[1])); - v15 = speakingNPC->pName; - v13 = pParty->pHireling2Name; - } - else - { - memcpy(pParty->pHirelings, speakingNPC, 0x4Cu); - v15 = speakingNPC->pName; - v13 = pParty->pHireling1Name; - } - strcpy(v13, v15); - pParty->field_709 = 0; - sub_44A56A(); - - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - - if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) - pDialogue_SpeakingActor->uAIState = Removed; - if ( uActiveCharacter ) - pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0); - goto LABEL_87; - - - if (newDialogueType == DIALOGUE_9) - { - if ( !sub_4BB756(speakingNPC->uProfession) ) - { - if ( speakingNPC->uProfession != 41 ) - speakingNPC->bHasUsedTheAbility = 1; - - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - } - else - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u); //"Your packs are already full!" - } - - goto LABEL_87; - } - if (newDialogueType == DIALOGUE_13) - { - if (!speakingNPC->Hired()) - { - sub_4B3E1E(); - dialogue_show_profession_details = false; - goto LABEL_87; - } - else - { - v5 = 0; - if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) - { - v6 = (char *)pNPCStats->pNewNPCData; - while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) ) - { - ++v5; - v6 += 76; - if ( v5 >= (signed int)pNPCStats->uNumNewNPCs ) - goto LABEL_44; - } + ShowStatusBarString(v7, 2u); + goto LABEL_87; + } + //v9 = v2->uProfession; + if ( speakingNPC->uProfession != 51 ) + { + v10 = pNPCStats->pProfessions[speakingNPC->uProfession - 1].uHirePrice; + if ( pParty->uNumGold < v10 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold" + dialogue_show_profession_details = false; + uDialogueType = 13; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); + v7 = pGlobalTXT_LocalizationStrings[155]; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); + goto LABEL_87; + } + Party::TakeGold(v10); + } + LOBYTE(speakingNPC->uFlags) |= 0x80u; + if ( pParty->pHirelings[0].pName ) + { + memcpy(&pParty->pHirelings[1], speakingNPC, sizeof(pParty->pHirelings[1])); + v15 = speakingNPC->pName; + v13 = pParty->pHireling2Name; + } + else + { + memcpy(pParty->pHirelings, speakingNPC, 0x4Cu); + v15 = speakingNPC->pName; + v13 = pParty->pHireling1Name; + } + strcpy(v13, v15); + pParty->field_709 = 0; + sub_44A56A(); + + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + + if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) + pDialogue_SpeakingActor->uAIState = Removed; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_61, 0); + goto LABEL_87; + if (newDialogueType == DIALOGUE_9) + { + if ( !sub_4BB756(speakingNPC->uProfession) ) + { + if ( speakingNPC->uProfession != 41 ) + speakingNPC->bHasUsedTheAbility = 1; + + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + } + else + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u); //"Your packs are already full!" + } + + goto LABEL_87; + } + if (newDialogueType == DIALOGUE_13) + { + if (!speakingNPC->Hired()) + { + sub_4B3E1E(); + dialogue_show_profession_details = false; + goto LABEL_87; + } + else + { + v5 = 0; + if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) + { + v6 = (char *)pNPCStats->pNewNPCData; + while ( !(v6[8] & 0x80) || strcmp(speakingNPC->pName, *(const char **)v6) ) + { + ++v5; + v6 += 76; + if ( v5 >= (signed int)pNPCStats->uNumNewNPCs ) + goto LABEL_44; + } LABEL_43: - v6[8] &= 0x7Fu; - goto LABEL_44; - } - goto LABEL_44; - } - } - - } - else - { - switch(newDialogueType) - { - case DIALOGUE_19: npc_event_id = speakingNPC->evt_A; break; - case DIALOGUE_20: npc_event_id = speakingNPC->evt_B; break; - case DIALOGUE_21: npc_event_id = speakingNPC->evt_C; break; - case DIALOGUE_22: npc_event_id = speakingNPC->evt_D; break; - case DIALOGUE_23: npc_event_id = speakingNPC->evt_E; break; - case DIALOGUE_24: npc_event_id = speakingNPC->evt_F; break; - } - if ( (npc_event_id >= 200) && (npc_event_id <= 310) ) - sub_4B3FE5(npc_event_id); //200-310 - else if (( npc_event_id >= 400) && (npc_event_id <= 410) ) - { //400-410 - dword_F8B1D8 = newDialogueType; - DrawJoinGuildWindow(npc_event_id - 400); - } - else - { - switch ( npc_event_id ) - { - case 139: - sub_4B1ECE(); - break; - case 311: - sub_4BBA85_bounties(); - break; - case 399: - sub_4BBCDD(); - break; - default: - GlobalEventInfo = 1; - ptr_F8B1E8 = 0; - EventProcessor(npc_event_id, 0, 1); - GlobalEventInfo = 0; - break; - } - } - - - - - + v6[8] &= 0x7Fu; + goto LABEL_44; + } + goto LABEL_44; + } + } + } + else + { + switch(newDialogueType) + { + case DIALOGUE_19: npc_event_id = speakingNPC->evt_A; break; + case DIALOGUE_20: npc_event_id = speakingNPC->evt_B; break; + case DIALOGUE_21: npc_event_id = speakingNPC->evt_C; break; + case DIALOGUE_22: npc_event_id = speakingNPC->evt_D; break; + case DIALOGUE_23: npc_event_id = speakingNPC->evt_E; break; + case DIALOGUE_24: npc_event_id = speakingNPC->evt_F; break; + } + if ( (npc_event_id >= 200) && (npc_event_id <= 310) ) + sub_4B3FE5(npc_event_id); //200-310 + else if (( npc_event_id >= 400) && (npc_event_id <= 410) ) + { //400-410 + dword_F8B1D8 = newDialogueType; + DrawJoinGuildWindow(npc_event_id - 400); + } + else + { + switch ( npc_event_id ) + { + case 139: + sub_4B1ECE(); + break; + case 311: + sub_4BBA85_bounties(); + break; + case 399: + sub_4BBCDD(); + break; + default: + activeLevelDecoration = (LevelDecoration*)1; + ptr_F8B1E8 = 0; + EventProcessor(npc_event_id, 0, 1); + activeLevelDecoration = NULL; + break; + } + } + } LABEL_87: - if ( !dword_7241C8 ) - pGame->Draw(); + if ( !dword_7241C8 ) + pGame->Draw(); LABEL_89: - dword_7241C8 = 0; -} + dword_7241C8 = 0; + } diff -r 8f70e52646eb -r 35f28d4c0ff9 mm7_6.cpp --- a/mm7_6.cpp Fri Mar 01 22:18:22 2013 +0400 +++ b/mm7_6.cpp Fri Mar 01 23:43:21 2013 +0400 @@ -6356,9 +6356,9 @@ } if ( v447->IsInteractive() ) { - GlobalEventInfo = (int)v447; + activeLevelDecoration = v447; EventProcessor(stru_5E4C90._decor_events[v447->_idx_in_stru123 - 75] + 380, 0, 1); - GlobalEventInfo = 0; + activeLevelDecoration = NULL; } } } diff -r 8f70e52646eb -r 35f28d4c0ff9 mm7_data.cpp --- a/mm7_data.cpp Fri Mar 01 22:18:22 2013 +0400 +++ b/mm7_data.cpp Fri Mar 01 23:43:21 2013 +0400 @@ -2035,6 +2035,7 @@ int dword_5B65D0_dialogue_actor_npc_id; // weak int dword_5C3418; // weak int dword_5C341C; // weak +int _5C3420_pDecoration; char byte_5C3427[777]; // weak char GameUI_StatusBar_TimedString[200]; char pStatusBarString[200]; diff -r 8f70e52646eb -r 35f28d4c0ff9 mm7_data.h --- a/mm7_data.h Fri Mar 01 22:18:22 2013 +0400 +++ b/mm7_data.h Fri Mar 01 23:43:21 2013 +0400 @@ -1358,6 +1358,7 @@ extern int dword_5B65D0_dialogue_actor_npc_id; // weak extern int dword_5C3418; // weak extern int dword_5C341C; // weak +extern int _5C3420_pDecoration; extern char byte_5C3427[]; // weak extern char GameUI_StatusBar_TimedString[200]; extern char pStatusBarString[200];