# HG changeset patch # User Nomad # Date 1352175325 -7200 # Node ID 8be5293b6b3359aad1cbc999f6745d665708b9cf # Parent 67f843a23f8b4321b1b2f70aca5810822e98ae4e odm loading diff -r 67f843a23f8b -r 8be5293b6b33 Game.cpp --- a/Game.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/Game.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -449,7 +449,7 @@ dword_5B65C0 = 1; PrepareWorld(1u); } - UpdateActors(); + InitializeActors(); v11 = 0; do { diff -r 67f843a23f8b -r 8be5293b6b33 Indoor.cpp --- a/Indoor.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/Indoor.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -4493,8 +4493,8 @@ Abortf("Out of memory loading indoor level"); if ( !(dword_6BE364_game_settings_1 & 0x2000) ) { - UpdateActors(); - UpdateLayingItems(); + InitializeActors(); + InitializeLayingItems(); } BYTE1(dword_6BE364_game_settings_1) &= 0xDFu; if ( !v39 ) @@ -4653,8 +4653,8 @@ if ( v35 < 124 ) { v21 = v35 + 1; - pDecortaion->field_1C = v35 + 75; - v22 = stru_5E4C90.field_0[v21 + 74]; + pDecortaion->_idx_in_stru123 = v35 + 75; + v22 = stru_5E4C90._decor_events[v21 + 74 - 75]; v35 = v21; if ( !v22 ) pDecortaion->field_2 |= 0x20; diff -r 67f843a23f8b -r 8be5293b6b33 Indoor.h --- a/Indoor.h Sun Nov 04 13:58:15 2012 +0200 +++ b/Indoor.h Tue Nov 06 06:15:25 2012 +0200 @@ -36,7 +36,7 @@ __int16 field_16_event_id; __int16 field_18; __int16 field_1A; - __int16 field_1C; + __int16 _idx_in_stru123; __int16 field_1E; }; #pragma pack(pop) diff -r 67f843a23f8b -r 8be5293b6b33 LayingItem.cpp --- a/LayingItem.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/LayingItem.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -114,6 +114,8 @@ unsigned __int16 *pAttributes; // ecx@2 unsigned __int16 v3; // ax@2 + __debugbreak(); // find out what's going on + v1 = uLayingItemID; pLayingItems[v1].uObjectDescID = 0; if ( pParty->bTurnBasedModeOn == 1 ) diff -r 67f843a23f8b -r 8be5293b6b33 Outdoor.cpp --- a/Outdoor.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/Outdoor.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -2666,11 +2666,9 @@ } //----- (0047F138) -------------------------------------------------------- -int OutdoorLocation::PrepareDecorations() +bool OutdoorLocation::PrepareDecorations() { signed int v1; // ebx@1 - signed int v2; // edi@3 - LevelDecoration *v3; // esi@4 __int16 v4; // ax@5 int v5; // eax@7 __int16 v6; // ax@14 @@ -2680,42 +2678,38 @@ v8 = 0; if ( !_strcmpi(pCurrentMapName, "out09.odm") ) v8 = 1; - v2 = 0; - if ( (signed int)uNumLevelDecorations > 0 ) + + for (uint i = 0; i < uNumLevelDecorations; ++i) { - v3 = pLevelDecorations; - do - { - pDecorationList->InitializeDecorationSprite(v3->uDecorationDescID); - v4 = pDecorationList->pDecorations[v3->uDecorationDescID].uSoundID; + auto decor = pLevelDecorations + i; + + pDecorationList->InitializeDecorationSprite(decor->uDecorationDescID); + v4 = pDecorationList->pDecorations[decor->uDecorationDescID].uSoundID; if ( v4 && _6807E0_num_decorations_with_sounds_6807B8 < 9 ) { pSoundList->_4A9A67(v4, 0); v5 = _6807E0_num_decorations_with_sounds_6807B8++; - _6807B8_level_decorations_ids[v5] = v2; + _6807B8_level_decorations_ids[v5] = i; } - if ( v8 && v3->uCog == 20 ) - LOBYTE(v3->field_2) |= 0x40u; - if ( !v3->field_16_event_id ) + if ( v8 && decor->uCog == 20 ) + LOBYTE(decor->field_2) |= 0x40u; + if ( !decor->field_16_event_id ) { - if ( v3->IsInteractive() ) + if ( decor->IsInteractive() ) { if ( v1 < 124 ) { - v6 = v1++ + 75; - v3->field_1C = v6; - if ( !stru_5E4C90.field_0[v1 + 74] ) - LOBYTE(v3->field_2) |= 0x20u; + v6 = v1 + 75; + decor->_idx_in_stru123 = v6; + if ( !stru_5E4C90._decor_events[v1++] ) + LOBYTE(decor->field_2) |= 0x20u; } } } - ++v2; - ++v3; - } - while ( v2 < (signed int)uNumLevelDecorations ); } + pGameLoadingUI_ProgressBar->Progress(); - return 1; + return true; } // 6807E0: using guessed type int _6807E0_num_decorations_6807B8; diff -r 67f843a23f8b -r 8be5293b6b33 Outdoor.h --- a/Outdoor.h Sun Nov 04 13:58:15 2012 +0200 +++ b/Outdoor.h Tue Nov 06 06:15:25 2012 +0200 @@ -154,7 +154,7 @@ bool _47F04C(signed int a2, signed int a3); bool _47F097(signed int a2, signed int a3); bool _47F0E2(); - int PrepareDecorations(); + bool PrepareDecorations(); int _47F223_LooksLikeGenerateMonsterLoot(); bool InitalizeActors(int a1); bool _47F3EA(); diff -r 67f843a23f8b -r 8be5293b6b33 Spells.cpp --- a/Spells.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/Spells.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -50,7 +50,7 @@ this->uFlags = 0; if ( v2 ) { - ((OtherOverlay *)&stru_5E4C90.field_4B[20 * v2 + 105])->Reset(); + ((OtherOverlay *)&stru_5E4C90._decor_events[20 * v2 + 105])->Reset(); pOtherOverlayList->field_3EC = 1; v1->uOverlayID = 0; } @@ -99,7 +99,7 @@ v8 = (unsigned __int16)v8; if ( (unsigned __int16)v8 != a5 ) { - ((OtherOverlay *)&stru_5E4C90.field_4B[20 * v8 + 105])->Reset(); + ((OtherOverlay *)&stru_5E4C90._decor_events[20 * v8 + 105])->Reset(); pOtherOverlayList->field_3EC = 1; v6->uOverlayID = 0; } diff -r 67f843a23f8b -r 8be5293b6b33 mm7_1.cpp --- a/mm7_1.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/mm7_1.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -5080,7 +5080,7 @@ if ( !v25 ) { if ( v23->IsInteractive() ) - v26 = pNPCTopics[stru_5E4C90.field_0[v24->field_1C] + 379].pTopic; + v26 = pNPCTopics[stru_5E4C90._decor_events[v24->_idx_in_stru123 - 75] + 379].pTopic; else v26 = pDecorationList->pDecorations[v24->uDecorationDescID].field_20; goto LABEL_87; @@ -5876,7 +5876,7 @@ { if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) { - v15 = stru_5E4C90.field_0[v13->field_1C] + 380; + v15 = stru_5E4C90._decor_events[v13->_idx_in_stru123 - 75] + 380; _5C3420_pDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; EventProcessor(v15, 0, 1); _5C3420_pDecoration = 0; diff -r 67f843a23f8b -r 8be5293b6b33 mm7_2.cpp --- a/mm7_2.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/mm7_2.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -1,5 +1,6 @@ #include #include +#include #include "MapInfo.h" #include "Game.h" @@ -7501,11 +7502,11 @@ //----- (0044F57C) -------------------------------------------------------- -void *__fastcall SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *a2, int a3, int a4, int a5) -{ - MapInfo *v5; // esi@1 - SpawnPointMM7 *v6; // ebx@1 - void *result; // eax@2 +void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5) +{ + //MapInfo *v5; // esi@1 + //SpawnPointMM7 *v6; // ebx@1 + int v7; // eax@2 char v8; // zf@5 int v9; // edi@9 int v10; // eax@9 @@ -7540,123 +7541,139 @@ int v39; // edi@52 std::string v40; // [sp-18h] [bp-100h]@60 void *v41; // [sp-14h] [bp-FCh]@50 - void *v42; // [sp-10h] [bp-F8h]@50 - size_t v43; // [sp-Ch] [bp-F4h]@50 + //void *v42; // [sp-10h] [bp-F8h]@50 + //size_t v43; // [sp-Ch] [bp-F4h]@50 const char *v44; // [sp-8h] [bp-F0h]@13 char *v45; // [sp-4h] [bp-ECh]@9 - char Str; // [sp+Ch] [bp-DCh]@60 - char Str2; // [sp+2Ch] [bp-BCh]@29 + char Str[32]; // [sp+Ch] [bp-DCh]@60 + char Str2[120]; // [sp+2Ch] [bp-BCh]@29 unsigned int uFaceID; // [sp+A4h] [bp-44h]@52 - void *Src; // [sp+A8h] [bp-40h]@50 + MonsterInfo *Src; // [sp+A8h] [bp-40h]@50 int v50; // [sp+ACh] [bp-3Ch]@47 - char Source; // [sp+B0h] [bp-38h]@20 + char Source[32]; // [sp+B0h] [bp-38h]@20 int v52; // [sp+D0h] [bp-18h]@34 - void *v53; // [sp+D4h] [bp-14h]@34 + int v53; // [sp+D4h] [bp-14h]@34 int v54; // [sp+D8h] [bp-10h]@32 int v55; // [sp+DCh] [bp-Ch]@32 int v56; // [sp+E0h] [bp-8h]@8 int v57; // [sp+E4h] [bp-4h]@1 + //auto a2 = spawn; + v57 = 0; - v5 = pMapInfo; - v6 = a2; + //v5 = pMapInfo; + //v6 = spawn; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - result = (void *)pOutdoor->ddm.field_C_alert; - else - result = (void *)(uCurrentlyLoadedLevelType == LEVEL_Outdoor ? pIndoor->dlv.field_C_alert : 0); - if ( result ) - { - v8 = (a2->uAttributes & 1) == 0; - } - else - { - result = (void *)(a2->uAttributes & 1); - v8 = (char)result == 1; - } - if ( !v8 ) - { - result = (void *)(a2->uIndex - 1); - v56 = 1; - switch ( (int)result ) - { - case 0u: + v7 = pOutdoor->ddm.field_C_alert; + else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + v7 = pIndoor->dlv.field_C_alert; + else + v7 = 0; + + if (v7) + v8 = (spawn->uAttributes & 1) == 0; + else + v8 = (spawn->uAttributes & 1) == 1; + + if (v8) + return; + + //result = (void *)(spawn->uIndex - 1); + v56 = 1; + switch (spawn->uIndex - 1) + { + case 0u: v9 = pMapInfo->uEncounterMonster1AtLeast; v10 = rand(); - v11 = v5->uEncounterMonster1AtMost; - v45 = v5->pEncounterMonster1Texture; - v12 = v10 % (v11 - v9 + 1); - v13 = v5->field_34; - goto LABEL_20; - case 3u: + v11 = pMapInfo->uEncounterMonster1AtMost; v45 = pMapInfo->pEncounterMonster1Texture; - goto LABEL_13; - case 4u: - v45 = pMapInfo->pEncounterMonster2Texture; - goto LABEL_13; - case 5u: - v45 = pMapInfo->pEncounterMonster3Texture; -LABEL_13: + v12 = v10 % (v11 - v9 + 1); + v13 = pMapInfo->field_34; + goto LABEL_20; + + case 3u: + v45 = pMapInfo->pEncounterMonster1Texture; v44 = "%s A"; goto LABEL_25; - case 1u: + + case 4u: + v45 = pMapInfo->pEncounterMonster2Texture; + v44 = "%s A"; + goto LABEL_25; + + case 5u: + v45 = pMapInfo->pEncounterMonster3Texture; + v44 = "%s A"; + goto LABEL_25; + + case 1u: v9 = pMapInfo->uEncounterMonster2AtLeast; v14 = rand(); - v15 = v5->uEncounterMonster2AtMost; - v45 = v5->pEncounterMonster2Texture; + v15 = pMapInfo->uEncounterMonster2AtMost; + v45 = pMapInfo->pEncounterMonster2Texture; v12 = v14 % (v15 - v9 + 1); - v13 = v5->field_37; + v13 = pMapInfo->field_37; goto LABEL_20; - case 6u: + + case 6u: v45 = pMapInfo->pEncounterMonster1Texture; - goto LABEL_18; - case 7u: - v45 = pMapInfo->pEncounterMonster2Texture; - goto LABEL_18; - case 8u: - v45 = pMapInfo->pEncounterMonster3Texture; -LABEL_18: v44 = "%s B"; goto LABEL_25; - case 2u: + + case 7u: + v45 = pMapInfo->pEncounterMonster2Texture; + v44 = "%s B"; + goto LABEL_25; + + case 8u: + v45 = pMapInfo->pEncounterMonster3Texture; + v44 = "%s B"; + goto LABEL_25; + + case 2u: v9 = pMapInfo->uEncounterMonster3AtLeast; v16 = rand(); - v17 = v5->uEncounterMonster3AtMost; - v45 = v5->pEncounterMonster3Texture; + v17 = pMapInfo->uEncounterMonster3AtMost; + v45 = pMapInfo->pEncounterMonster3Texture; v12 = v16 % (v17 - v9 + 1); - v13 = v5->field_3A; + v13 = pMapInfo->field_3A; LABEL_20: v57 = v13; v56 = v9 + v12; - result = strcpy(&Source, v45); + strcpy(Source, v45); goto LABEL_26; - case 9u: + + case 9u: v45 = pMapInfo->pEncounterMonster1Texture; - goto LABEL_24; - case 0xAu: + v44 = "%s C"; + goto LABEL_25; + + case 0xAu: v45 = pMapInfo->pEncounterMonster2Texture; - goto LABEL_24; - case 0xBu: + v44 = "%s C"; + goto LABEL_25; + + case 0xBu: v45 = pMapInfo->pEncounterMonster3Texture; -LABEL_24: v44 = "%s C"; LABEL_25: - result = (void *)sprintfex(&Source, v44, v45); + sprintf(Source, v44, v45); LABEL_26: - if ( Source == 48 ) - return result; + if (Source[0] == '0') + return; + v57 += a3; if ( v57 > 4 ) v57 = 4; - strcpy(&Str2, &Source); + strcpy(Str2, Source); if ( a4 ) v56 = a4; v18 = v56; - result = (void *)(v56 + uNumActors); if ( (signed int)(v56 + uNumActors) >= 500 ) - return result; - v19 = v6->vPosition.x; - v20 = v6->vPosition.y; - v21 = v6->vPosition.z; + return; + v19 = spawn->vPosition.x; + v20 = spawn->vPosition.y; + v21 = spawn->vPosition.z; v54 = 0; v55 = v19; a4 = v20; @@ -7664,16 +7681,16 @@ if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) v54 = pIndoor->GetSector(v19, v20, v21); v53 = 0; - result = (void *)((((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64); v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; if ( v18 <= 0 ) - return result; + return; break; default: - return result; - } - do - { + return; + } + + for (uint i = v53; i < v56; ++i) + { v22 = &pActors[uNumActors]; pActors[uNumActors].Reset(); if ( v57 ) @@ -7692,47 +7709,48 @@ } if ( v24 == 1 ) { - v45 = &Source; + v45 = Source; v44 = "%s A"; } else { if ( v24 == 2 ) { - v45 = &Source; + v45 = Source; v44 = "%s B"; } else { if ( v24 != 3 ) goto LABEL_58; - v45 = &Source; + v45 = Source; v44 = "%s C"; } } - sprintfex(&Str2, v44, v45); - } - v26 = pMonsterList->GetMonsterByName(&Str2); + sprintf(Str2, v44, v45); + } + v26 = pMonsterList->GetMonsterByName(Str2); v50 = (signed __int16)v26; - v45 = &Str2; + v45 = Str2; if ( (signed __int16)v26 == -1 ) { - sprintfex(&Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", v45); - MessageBoxA(nullptr, &Str, nullptr, 0); + sprintfex(Str, "Can't create random monster: '%s'! See MapStats.txt and Monsters.txt!", v45); + MessageBoxA(nullptr, Str, nullptr, 0); ExitProcess(0); } v27 = &pMonsterList->pMonsters[(signed __int16)v26]; v28 = pMonsterStats->_4563FF(v45); if ( !v28 ) v28 = 1; - Src = (char *)&pMonsterStats + 88 * v28; - strcpy(v22->pActorName, *(const char **)Src); - v43 = 88; - v42 = Src; - v29 = *((short *)Src + 32); + Src = &pMonsterStats->pInfos[v28]; + strcpy(v22->pActorName, Src->pName); + //v43 = 88; + //v42 = Src; + v29 = Src->uHP; v41 = &v22->pMonsterInfo; v22->sCurrentHP = v29; - memcpy(v41, v42, v43); + assert(sizeof(MonsterInfo) == 88); + memcpy(v41, Src, sizeof(MonsterInfo)); v22->word_000086_some_monster_id = v50 + 1; v22->uActorRadius = v27->uMonsterRadius; v22->uActorHeight = v27->uMonsterHeight; @@ -7748,7 +7766,7 @@ v22->vInitialPosition.z = a3; v22->vPosition.z = a3; v22->uSectorID = v54; - v22->uGroup = v6->uGroup; + v22->uGroup = spawn->uGroup; v22->PrepareSprites((char)v45); v22->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; v32 = rand(); @@ -7756,13 +7774,13 @@ v34 = stru_5C6E00->SinCos(v32 % 2048); a4 = v34; a3 = (unsigned __int64)(v34 * (signed __int64)v52) >> 16; - v55 = a3 + v6->vPosition.x; + v55 = a3 + spawn->vPosition.x; v35 = stru_5C6E00->SinCos(v33 - stru_5C6E00->uIntegerHalfPi); a4 = v35; a3 = (unsigned __int64)(v35 * (signed __int64)v52) >> 16; - a4 = a3 + v6->vPosition.y; - v36 = v6->vPosition.z; - a3 = v6->vPosition.z; + a4 = a3 + spawn->vPosition.y; + v36 = spawn->vPosition.z; + a3 = spawn->vPosition.z; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) goto LABEL_55; v37 = pIndoor->GetSector(v55, a4, v36); @@ -7784,12 +7802,11 @@ } } LABEL_58: - v53 = (char *)v53 + 1; - result = v53; - } - while ( (signed int)v53 < v56 ); - } - return result; + ; + //v53 = (char *)v53 + 1; + //result = v53; + } + //while ( (signed int)v53 < v56 ); } @@ -7955,6 +7972,8 @@ int v33; // [sp+80h] [bp-8h]@1 int v34; // [sp+84h] [bp-4h]@1 + __debugbreak(); + auto a1 = this; v2 = a1; @@ -8619,39 +8638,27 @@ } //----- (00450AAA) -------------------------------------------------------- -void *__cdecl RespawnGlobalDecorations() -{ - signed int v0; // edi@1 - void *result; // eax@1 - signed int v2; // ebx@1 - LevelDecoration *v3; // esi@2 - - v0 = 0; - result = memset(stru_5E4C90.field_4B, 0, 0x7Du); - v2 = 0; - if ( (signed int)uNumLevelDecorations > 0 ) - { - v3 = pLevelDecorations; - do - { - if ( !v3->field_16_event_id ) - { - result = (void *)v3->IsInteractive(); - if ( result ) - { - if ( v0 < 124 ) - { - v3->field_1C = v0 + 75; - stru_5E4C90.field_4B[v0++] = v3->GetGlobalEvent(); - } - } - } - ++v2; - ++v3; - } - while ( v2 < (signed int)uNumLevelDecorations ); - } - return result; +void RespawnGlobalDecorations() +{ + memset(stru_5E4C90._decor_events, 0, 125); + + uint decorEventIdx = 0; + for (uint i = 0; i < uNumLevelDecorations; ++i) + { + auto decor = pLevelDecorations + i; + + if (!decor->field_16_event_id) + { + if (decor->IsInteractive()) + { + if (decorEventIdx < 124) + { + decor->_idx_in_stru123 = decorEventIdx + 75; + stru_5E4C90._decor_events[decorEventIdx++] = decor->GetGlobalEvent(); + } + } + } + } } //----- (00450B0A) -------------------------------------------------------- @@ -15924,9 +15931,9 @@ { if ( !pLevelDecorations[a1 >> 3].IsInteractive() ) return 1; - v10 = v8->field_1C; + v10 = v8->_idx_in_stru123; v24 = 1; - v11 = stru_5E4C90.field_0[v10] + 380; + v11 = stru_5E4C90._decor_events[v10 - 75] + 380; _5C3420_pDecoration = v8; EventProcessor(v11, 0, 1); _5C3420_pDecoration = 0; @@ -16396,7 +16403,7 @@ goto LABEL_36; } if ( v25->IsInteractive() ) - v24 = pNPCTopics[stru_5E4C90.field_0[v26->field_1C] + 379].pTopic; + v24 = pNPCTopics[stru_5E4C90._decor_events[v26->_idx_in_stru123 - 75] + 379].pTopic; else v24 = pDecorationList->pDecorations[v26->uDecorationDescID].field_20; LABEL_51: diff -r 67f843a23f8b -r 8be5293b6b33 mm7_3.cpp --- a/mm7_3.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/mm7_3.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -2443,7 +2443,7 @@ pParty->bFlying = 0; __debugbreak(); if (pParty->FlyActive()) - stru_5E4C90.field_4B[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;// 005E4D58 pOtherOverlayList [negindexing] + stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u;// 005E4D58 pOtherOverlayList [negindexing] } if ( v80 == -30000 ) { @@ -3162,7 +3162,7 @@ { LOBYTE(pParty->uFlags) &= 0x7Fu; bWaterWalk = 1; - *(short *)&stru_5E4C90.field_4B[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u; + *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u; if ( !(pParty->pPartyBuffs[18].uFlags & 1) && *(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[18].uCaster + 10] <= 0 ) bWaterWalk = 0; @@ -3553,7 +3553,7 @@ v123 = v113; if ( SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) >= 0 && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime)) ) - stru_5E4C90.field_4B[20 * pParty->pPartyBuffs[7].uOverlayID + 119] &= 0xFEu; + stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] &= 0xFEu; pParty->uFallStartY = v123; goto LABEL_141; } @@ -3568,7 +3568,7 @@ v113 = v123; if ( SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) >= 0 && (SHIDWORD(pParty->pPartyBuffs[7].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[7].uExpireTime)) ) - stru_5E4C90.field_4B[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u; + stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[7].uOverlayID + 119] |= 1u; LABEL_141: v32 = 0; if ( bJumping && !pParty->bFlying ) @@ -4052,7 +4052,7 @@ { LOBYTE(pParty->uFlags) &= 0x7Fu; v79 = 20 * pParty->pPartyBuffs[18].uOverlayID + 6180178; - *(short *)&stru_5E4C90.field_4B[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u; + *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[18].uOverlayID + 119] |= 1u; if ( !v122 || !v69 ) { if ( !v76 ) @@ -8313,15 +8313,15 @@ int v2; // ebx@3 unsigned int v3; // eax@3 MapInfo *v4; // edi@4 - int v5; // eax@8 - SpawnPointMM7 *v6; // edx@14 + //int v5; // eax@8 + //SpawnPointMM7 *v6; // edx@14 size_t v7; // eax@19 char *v8; // eax@19 char *v9; // eax@21 char Source[120]; // [sp+Ch] [bp-84h]@19 const char *pFilename; // [sp+84h] [bp-Ch]@1 - unsigned int v12; // [sp+88h] [bp-8h]@12 - int v13; // [sp+8Ch] [bp-4h]@11 + //unsigned int v12; // [sp+88h] [bp-8h]@12 + //int v13; // [sp+8Ch] [bp-4h]@11 pFilename = pLevelFilename; thisa->AllocSoftwareDrawBuffers(); @@ -8352,32 +8352,33 @@ (int)&thisa); if ( !(BYTE1(dword_6BE364_game_settings_1) & 0x20) ) { - UpdateActors(); - UpdateLayingItems(); + InitializeActors(); + InitializeLayingItems(); } BYTE1(dword_6BE364_game_settings_1) &= 0xDFu; - v5 = 0; + //v5 = 0; if ( !v2 ) thisa = 0; if ( thisa == (OutdoorCamera *)1 ) { - v13 = 0; - if ( (signed int)pOutdoor->uNumSpawnPoints > 0 ) - { - v12 = 0; - while ( 1 ) - { - v6 = &pOutdoor->pSpawnPoints[v12 / 0x18]; - if ( pOutdoor->pSpawnPoints[v12 / 0x18].uKind == 3 ) - SpawnEncounter(v4, v6, v5, v5, v5); - else - v4->SpawnRandomTreasure(v6); - ++v13; - v12 += 24; - if ( v13 >= (signed int)pOutdoor->uNumSpawnPoints ) - break; - v5 = 0; - } + //v13 = 0; + for (uint i = 0; i < pOutdoor->uNumSpawnPoints; ++i) + { + //v12 = 0; + //while ( 1 ) + //{ + auto spawn = pOutdoor->pSpawnPoints + i; + //v6 = &pOutdoor->pSpawnPoints[v12 / 0x18]; + if (spawn->uKind == 3 ) + SpawnEncounter(v4, spawn, 0, 0, 0); + else + v4->SpawnRandomTreasure(spawn); + //++v13; + //v12 += 24; + //if ( v13 >= (signed int)pOutdoor->uNumSpawnPoints ) + // break; + //v5 = 0; + //} } RespawnGlobalDecorations(); } @@ -17271,12 +17272,12 @@ v25 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((unsigned int)_evt->v8 << 8)) << 8)) << 8); if ( v25 ) { - stru_5E4C90.field_0[_5C3420_pDecoration->field_1C] = _evt->v5 - 124; + stru_5E4C90._decor_events[_5C3420_pDecoration->_idx_in_stru123 - 75] = _evt->v5 - 124; } else { v26 = _5C3420_pDecoration; - stru_5E4C90.field_0[_5C3420_pDecoration->field_1C] = 0; + stru_5E4C90._decor_events[_5C3420_pDecoration->_idx_in_stru123 - 75] = 0; LOBYTE(v26->field_2) |= 0x20u; } goto LABEL_291; diff -r 67f843a23f8b -r 8be5293b6b33 mm7_4.cpp --- a/mm7_4.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/mm7_4.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -3357,7 +3357,7 @@ v1 = uHoursToSleep; if ( uHoursToSleep > 240 ) - UpdateActors(); + InitializeActors(); v2 = (double)(7680 * v1) * 0.033333335; pParty->uTimePlayed += (signed __int64)v2; v3 = &pPlayers[1]; diff -r 67f843a23f8b -r 8be5293b6b33 mm7_5.cpp --- a/mm7_5.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/mm7_5.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -2229,7 +2229,7 @@ v66 = stru_4ECBB8[uMessageParam].rot_x; _5B65B4_npcdata_loword_house_or_other = stru_4ECBB8[uMessageParam].rot_y; _5B65B8_npcdata_hiword_house_or_other = v66; - UpdateActors(); + InitializeActors(); } v67 = pGUIWindow_CurrentMenu->Hint; if ( v67 ) @@ -11721,18 +11721,13 @@ //----- (00408768) -------------------------------------------------------- -char __cdecl UpdateActors() -{ - unsigned int v0; // edi@1 - __int16 v1; // ax@7 - char *v2; // esi@10 - char v3; // zf@13 +void InitializeActors() +{ signed int v5; // [sp+Ch] [bp-10h]@1 signed int v6; // [sp+10h] [bp-Ch]@1 signed int v7; // [sp+14h] [bp-8h]@1 signed int v8; // [sp+18h] [bp-4h]@1 - v0 = 0; v8 = 0; v6 = 0; v7 = 0; @@ -11741,65 +11736,48 @@ v8 = 1; if ( !_strcmpi(pCurrentMapName, "d26.blv") ) v6 = 1; - if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, 99) ) + if (_449B57_test_bit(pParty->_award_bits, 99)) v7 = 1; - v1 = _449B57_test_bit(pParty->_award_bits, 100); - if ( v1 ) + if (_449B57_test_bit(pParty->_award_bits, 100)) v5 = 1; - if ( (signed int)uNumActors > 0 ) - { - v2 = (char *)&pActors[0].vPosition; - do - { - if ( ((Actor *)(v2 - 142))->CanAct() || *((short *)v2 + 17) == 19 ) - { - v3 = *((short *)v2 + 17) == 19; - *(short *)v2 = *((short *)v2 + 10); - *((short *)v2 + 1) = *((short *)v2 + 11); - *((short *)v2 + 2) = *((short *)v2 + 12); - *((short *)v2 - 51) = *((short *)v2 - 17); - if ( !v3 ) - Actor::_403EB6(v0, dword_4F6E08[v0], *(int *)(v2 - 18), 0); - } - *(v2 - 81) = 0; - LOBYTE(v1) = 0; - if ( !v8 || v7 ) - { - if ( !v6 || v5 ) - { - LOBYTE(v1) = ((Actor *)(v2 - 142))->_438B9B(); - if ( (char)v1 ) - *(v2 - 104) &= 0xF7u; - } - } - *(v2 - 104) &= 0x7Fu; - if ( *(v2 - 104) & 0x40 ) - LOBYTE(v1) = Actor::_4031C1_update_job(v0, pParty->uCurrentHour, 1); - ++v0; - v2 += 836; - } - while ( (signed int)v0 < (signed int)uNumActors ); - } - return v1; + for (uint i = 0; i < uNumActors; ++i) + { + auto actor = pActors + i; + + if (actor->CanAct() || actor->uAIState == Disabled) + { + actor->vPosition.x = actor->vInitialPosition.x; + actor->vPosition.y = actor->vInitialPosition.y; + actor->vPosition.z = actor->vInitialPosition.z; + actor->sCurrentHP = actor->pMonsterInfo.uHP; + if (actor->uAIState != Disabled) + Actor::_403EB6(i, dword_4F6E08[i], actor->pMonsterInfo.uRecoveryTime, 0); + } + + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + + if (!v8 || v7) + if (!v6 || v5) + if (actor->_438B9B()) + BYTE2(actor->uAttributes) &= 0xF7u; + + BYTE2(actor->uAttributes) &= 0x7Fu; + if (BYTE2(actor->uAttributes) & 0x40) + Actor::_4031C1_update_job(i, pParty->uCurrentHour, 1); + } } //----- (00408896) -------------------------------------------------------- -void UpdateLayingItems() -{ - unsigned int v0; // edi@1 - char *v1; // esi@1 - char *result; // eax@7 - - v0 = 0; - v1 = (char *)&pLayingItems[0].uObjectDescID; - do - { - if ( *(short *)v1 && (v1[24] & 8 || pObjectList->pObjects[*(short *)v1].uFlags & 0x10) ) - LayingItem::_42F933(v0); - v1 += 112; - ++v0; - } - while ( (signed int)v1 < (signed int)((char *)&pObjectList->uNumObjects + 2) ); +void InitializeLayingItems() +{ + for (uint i = 0; i < uNumLayingItems; ++i) + { + auto item = pLayingItems + i; + + if (item->uItemType && + (item->uSoundID & 8 || pObjectList->pObjects[item->uItemType].uFlags & 0x10)) + LayingItem::_42F933(i); + } for (uint i = 0; i < 100; ++i) array_5118E8.pElements[i].field_C_time_left = 0; diff -r 67f843a23f8b -r 8be5293b6b33 mm7_6.cpp --- a/mm7_6.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/mm7_6.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -6499,7 +6499,7 @@ if ( v447->IsInteractive() ) { _5C3420_pDecoration = v447; - EventProcessor(stru_5E4C90.field_0[v447->field_1C] + 380, 0, 1); + EventProcessor(stru_5E4C90._decor_events[v447->_idx_in_stru123 - 75] + 380, 0, 1); _5C3420_pDecoration = (LevelDecoration *)v1; } } diff -r 67f843a23f8b -r 8be5293b6b33 mm7_data.cpp --- a/mm7_data.cpp Sun Nov 04 13:58:15 2012 +0200 +++ b/mm7_data.cpp Tue Nov 06 06:15:25 2012 +0200 @@ -803,7 +803,7 @@ char aUndefinedCobje[777]; // idb char aEWorkMsdevMm_7[777]; // idb char aGammaControlNo[777]; // idb -__int16 word_4E8152[11]; +__int16 word_4E8152[11] = {0, 0, 0, 90, 8, 2, 70, 20, 10, 50, 30}; char byte_4E8168[116]; char aD3dTextureName[777]; // idb char aLogd3d_txt[777]; // idb diff -r 67f843a23f8b -r 8be5293b6b33 mm7_data.h --- a/mm7_data.h Sun Nov 04 13:58:15 2012 +0200 +++ b/mm7_data.h Tue Nov 06 06:15:25 2012 +0200 @@ -2536,8 +2536,8 @@ bool __fastcall sub_4075DB(int a1, int a2, int a3, struct BLVFace *a4); bool __fastcall sub_4077F1(int a1, int a2, int a3, struct ODMFace *a4, struct BSPVertexBuffer *a5); bool __fastcall sub_407A1C(int x, int z, int y, struct Vec3_int_ v); // idb -char UpdateActors(); -void UpdateLayingItems(); +void InitializeActors(); +void InitializeLayingItems(); int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6); unsigned int __thiscall SearchAliveActors(unsigned int *pTotalActors); unsigned int __fastcall SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID); @@ -2832,12 +2832,12 @@ // int __cdecl crt_deconstruct_44C42C(); struct GUIFont *LoadFont(const char *pFontFile, const char *pFontPalette, ...); char *__fastcall FitTextInAWindow(const char *pInString, GUIFont *pFont, GUIWindow *pWindow, unsigned int uX, int a5); -void *__fastcall SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *a2, int a3, int a4, int a5); +void SpawnEncounter(struct MapInfo *pMapInfo, struct SpawnPointMM7 *spawn, int a3, int a4, int a5); int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); void __cdecl sub_450218_prolly_generate_chests_loot(); signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6); int __fastcall sub_45063B(struct MapInfo *a1, int a2); -void *__cdecl RespawnGlobalDecorations(); +void RespawnGlobalDecorations(); bool __fastcall SpawnActor(unsigned int uMonsterID); int __cdecl GetAlertStatus(); unsigned int __fastcall sub_452442(unsigned __int16 a1, unsigned __int16 a2, int a3, int a4); diff -r 67f843a23f8b -r 8be5293b6b33 stru123.h --- a/stru123.h Sun Nov 04 13:58:15 2012 +0200 +++ b/stru123.h Tue Nov 06 06:15:25 2012 +0200 @@ -6,7 +6,7 @@ struct stru123 { char field_0[75]; - char field_4B[125]; + char _decor_events[125]; }; #pragma pack(pop) extern stru123 stru_5E4C90; \ No newline at end of file