Mercurial > mm7
changeset 1423:350959f13283
Слияние
author | Ritor1 |
---|---|
date | Tue, 30 Jul 2013 09:34:14 +0600 |
parents | 6bbcb91b3b7d (current diff) 4fff79f04dbd (diff) |
children | 5930342f092b |
files | AudioPlayer.cpp stru220.h |
diffstat | 43 files changed, 3009 insertions(+), 2827 deletions(-) [+] |
line wrap: on
line diff
--- a/AudioPlayer.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/AudioPlayer.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -1906,6 +1906,7 @@ bEAXSupported = 0; b3DSoundInitialized = 0; ReadWindowsRegistryString("3DSoundProvider", p3DSoundProvider, 128u, "NONE"); + __debugbreak(); // audioplayer.cpp(1926): warning C4700: uninitialized local variable 'v5' used CheckA3DSupport(v5); while ( AIL_enumerate_3D_providers(&v14, (HPROVIDER *)&hWnd, &Str1) ) {
--- a/AudioPlayer.h Tue Jul 30 09:33:52 2013 +0600 +++ b/AudioPlayer.h Tue Jul 30 09:34:14 2013 +0600 @@ -102,13 +102,16 @@ SOUND_Arcomage_131 = 0x83, SOUND_Arcomage_WallUpgrade = 0x84, SOUND_GoldReceived = 0xC8, - SOUND_206 =206, - SOUND_207 =207, + SOUND_203 = 203, + SOUND_206 = 206, + SOUND_207 = 207, SOUND_OpenChest = 208, SOUND_PlayerCantCastSpell = 0xD1, SOUND_Bell = 0xD9, SOUND_OpenBook = 230, SOUND_CloseBook = 231, + SOUND_11090 = 11090, + SOUND_12040 = 12040, SOUND_20001 = 0x4E21, };
--- a/CastSpellInfo.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/CastSpellInfo.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -1955,6 +1955,8 @@ { v730 = 0; } + + __debugbreak(); // castspellinfo.cpp(1962): warning C4700: uninitialized local variable 'v271' used if ( rand() % 100 < 10 * v2 || (rand() % 100 < 80 && (v731 == 3 || v731 == 4 )) || v245->GetValue() < 450 || @@ -1966,6 +1968,7 @@ { v295 = rand() % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType]; v245->uEnchantmentType = 0; + __debugbreak(); // castspellinfo.cpp(1971): warning C4700: uninitialized local variable 'v294' used for ( kk = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[v245->uItemID].uEquipType + 1]; ; kk += pItemsTable->pEnchantments[v294->uEnchantmentType].to_item[pItemsTable->pItems[v245->uItemID].uEquipType + 1] ) @@ -4067,29 +4070,25 @@ unsigned int CastSpellInfo::PushCastSpellInfo(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int spell_sound_id) { unsigned int result; // eax@1 - CastSpellInfo *v7; // edx@1 CastSpellInfo *v8; // ecx@5 result = 0; - v7 = this; - while ( v7->spellnum ) + for( result = 0; result < 10; result++ ) { - ++result; - ++v7; - if ( (signed int)result >= 10 ) - goto LABEL_8; + if(!this[result].spellnum) + { + v8 = &this[result]; + v8->spellnum = a2; + v8->uPlayerID = uPlayerID; + if ( a5 & 0x10 ) + v8->uPlayerID_2 = uPlayerID; + v8->field_6 = 0; + v8->spell_target_pid = 0; + v8->field_8 = a5; + v8->forced_spell_skill_level = skill_level; + v8->sound_id = spell_sound_id; + } } - v8 = &this[result]; - v8->spellnum = a2; - v8->uPlayerID = uPlayerID; - if ( a5 & 0x10 ) - v8->uPlayerID_2 = uPlayerID; - v8->field_6 = 0; - v8->spell_target_pid = 0; - v8->field_8 = a5; - v8->forced_spell_skill_level = skill_level; - v8->sound_id = spell_sound_id; -LABEL_8: if ( result == 10 ) result = -1; return result;
--- a/Chest.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/Chest.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -22,6 +22,7 @@ #include "ObjectList.h" #include "GUIWindow.h" #include "Time.h" +#include "Overlays.h" #include "mm7_data.h" #include "MM7.h" @@ -195,6 +196,35 @@ return true; } + +//----- (0042038D) -------------------------------------------------------- +void __cdecl ChestUI_WritePointedObjectStatusString() +{ + POINT *v0; // esi@2 + int v1; // ecx@2 + const char *v2; // eax@3 + POINT v3; // [sp+0h] [bp-10h]@2 + POINT a2; // [sp+8h] [bp-8h]@1 + + __debugbreak(); // invalid indexing + if ( pMouse->GetCursorPos(&a2)->y < 350 ) + { + v0 = pMouse->GetCursorPos(&a2); + v1 = pRenderer->pActiveZBuffer[v0->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v3)->y]]; + if ( v1 ) + { + auto _w = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + + 18 * *((short *)&pChests[0].igChestItems[139].uExpireTime + + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); + + _w = (ItemGen *)(&pChests[(unsigned int)pChestWindow->ptr_1C] -32 + + 18 * *((short *)&pChests[(unsigned int)pChestWindow->ptr_1C].igChestItems[139].uExpireTime + v1 + 3)); + v2 = _w->GetDisplayName(); + GameUI_SetFooterString(v2); + } + } +} + //----- (0042092D) -------------------------------------------------------- void Chest::DrawChestUI(signed int uChestID) { @@ -389,18 +419,13 @@ item_in_chest_count = CountChestItems(uChestID); if ( item_in_chest_count == -1 ) return 0; - v22 = 0; - if ( v5 > 0 ) - { - while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, pChestWindow->par1C) ) + for( int i = 0; i < v5; i++) + { + if ( Chest::CanPlaceItemAt(i, v4->uItemID, pChestWindow->par1C) ) { - ++v22; - if ( v22 >= v5 ) - goto LABEL_8; + v21 = i; } - v21 = v22; } -LABEL_8: if ( v22 == v5 ) { if ( uActiveCharacter )
--- a/DecalBuilder.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/DecalBuilder.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -401,6 +401,7 @@ { v40 = (int)&a8; v39 = v12->pVertices; + __debugbreak(); // warning C4700: uninitialized local variable 'v31' used pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, &a8b); v40 = (int)v31; v39 = v12->pVertices;
--- a/DecorationList.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/DecorationList.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -264,13 +264,12 @@ ++uID; ++v4; if ( uID >= (signed int)v2->uNumDecorations ) - goto LABEL_6; + return 0; } result = uID; } else { -LABEL_6: result = 0; } return result;
--- a/Events2D.h Tue Jul 30 09:33:52 2013 +0600 +++ b/Events2D.h Tue Jul 30 09:34:14 2013 +0600 @@ -1,46 +1,46 @@ #pragma once /* 296 */ -enum BildingType: unsigned short +enum BuildingType: unsigned short { - BildingType_WeaponShop = 1, - BildingType_ArmorShop = 2, - BildingType_MagicShop = 3, - BildingType_AlchemistShop = 4, - BildingType_FireGuild = 5, - BildingType_AirGuild = 6, - BildingType_WaterGuild = 7, - BildingType_EarthGuild = 8, - BildingType_SpiritGuild = 9, - BildingType_MindGuild = 10, - BildingType_BodyGuild = 11, - BildingType_LightGuild = 12, - BildingType_DarkGuild = 13, - BildingType_14 = 14, - BildingType_15 = 15, - BildingType_16 = 16, - BildingType_TownHall = 17, - BildingType_18 = 18, - BildingType_19 = 19, - BildingType_Throne_Room = 20, - BildingType_Tavern = 21, - BildingType_Bank = 22, - BildingType_Temple = 23, + BuildingType_WeaponShop = 1, + BuildingType_ArmorShop = 2, + BuildingType_MagicShop = 3, + BuildingType_AlchemistShop = 4, + BuildingType_FireGuild = 5, + BuildingType_AirGuild = 6, + BuildingType_WaterGuild = 7, + BuildingType_EarthGuild = 8, + BuildingType_SpiritGuild = 9, + BuildingType_MindGuild = 10, + BuildingType_BodyGuild = 11, + BuildingType_LightGuild = 12, + BuildingType_DarkGuild = 13, + BuildingType_14 = 14, + BuildingType_15 = 15, + BuildingType_16 = 16, + BuildingType_TownHall = 17, + BuildingType_18 = 18, + BuildingType_19 = 19, + BuildingType_Throne_Room = 20, + BuildingType_Tavern = 21, + BuildingType_Bank = 22, + BuildingType_Temple = 23, BuildingType_24 = 24, - BildingType_Unic = 25, - BildingType_1A = 26, - BildingType_Stables = 27, - BildingType_Boats = 28, - BildingType_House = 29, - BildingType_Training = 30, - BildingType_Jail = 31 + BuildingType_Unic = 25, + BuildingType_1A = 26, + BuildingType_Stables = 27, + BuildingType_Boats = 28, + BuildingType_House = 29, + BuildingType_Training = 30, + BuildingType_Jail = 31 }; /* 168 */ #pragma pack(push, 1) struct _2devent { - BildingType uType; + BuildingType uType; unsigned __int16 uAnimationID; char *pName; const char *pProprieterName;
--- a/GUIProgressBar.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/GUIProgressBar.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -203,15 +203,19 @@ floorf(v4 + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), 16, pRenderer->uTargetRMask); - goto LABEL_11; + pRenderer->EndScene(); + pRenderer->Present(); + return; } -LABEL_6: pRenderer->EndScene(); return; } if (!pLoadingBg.pPixels) - goto LABEL_6; + { + pRenderer->EndScene(); + return; + } pRenderer->DrawTextureRGB(0, 0, &pLoadingBg); pRenderer->SetRasterClipRect(0, 0, 0x27Fu, 0x1DFu); @@ -220,7 +224,6 @@ 0x1D7u); pRenderer->DrawTextureTransparent(0xACu, 0x1CBu, &pLoadingProgress); pRenderer->ResetTextureClipRect(); -LABEL_11: pRenderer->EndScene(); pRenderer->Present(); } \ No newline at end of file
--- a/GUIWindow.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/GUIWindow.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -249,11 +249,11 @@ //----- (0041D08F) -------------------------------------------------------- -void GUIWindow::_41D08F_set_keyboard_control_group(int a2, int a3, int a4, int a5) +void GUIWindow::_41D08F_set_keyboard_control_group(int num_buttons, int a3, int a4, int a5) { - if ( a2 ) + if (num_buttons) { - this->pNumPresenceButton = a2; + this->pNumPresenceButton = num_buttons; this->field_30 = a3; this->field_34 = a4; this->pCurrentPosActiveItem = a5; @@ -468,7 +468,8 @@ else if ( v18 & 0x40 ) max_beacons = 3; - + + __debugbreak(); // warning C4700: uninitialized local variable 'v19' used for (int i =0; i< max_beacons; ++i) CreateButton(pLloydsBeaconsPreviewXs[v19], pLloydsBeaconsPreviewYs[v19], 92, 68, 1, 180, UIMSG_InstallBeacon, i, 0, "", 0); @@ -670,7 +671,7 @@ { if ( v4 ) { - v5 = BuilDialogueString(v4, uActiveCharacter - 1, 0, 0, 0, v3); + v5 = BuildDialogueString(v4, uActiveCharacter - 1, 0, 0, 0, v3); v6 = pAutonoteFont->CalcTextHeight(v5, &v26, 1, 0); v7 = (v6 - 3) / (signed int)v26.uFrameHeight; v8 = v7 + 1; @@ -949,7 +950,7 @@ pWindow.uFrameZ += 8; if ( !pDialogueNPCCount ) { - if ( in_current_building_type == BildingType_Jail ) + if ( in_current_building_type == BuildingType_Jail ) { JailDialog(); if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) @@ -1056,56 +1057,56 @@ pWindow.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, pColor2, pTmpBuf.data(), 3); switch ( in_current_building_type ) { - case BildingType_WeaponShop: + case BuildingType_WeaponShop: WeaponShopDialog(); break; - case BildingType_ArmorShop: + case BuildingType_ArmorShop: ArmorShopDialog(); break; - case BildingType_MagicShop: + case BuildingType_MagicShop: MagicShopDialog(); break; - case BildingType_AlchemistShop: + case BuildingType_AlchemistShop: AlchemistDialog(); break; - case BildingType_FireGuild: - case BildingType_AirGuild: - case BildingType_WaterGuild: - case BildingType_EarthGuild: - case BildingType_SpiritGuild: - case BildingType_MindGuild: - case BildingType_BodyGuild: - case BildingType_LightGuild: - case BildingType_DarkGuild: + case BuildingType_FireGuild: + case BuildingType_AirGuild: + case BuildingType_WaterGuild: + case BuildingType_EarthGuild: + case BuildingType_SpiritGuild: + case BuildingType_MindGuild: + case BuildingType_BodyGuild: + case BuildingType_LightGuild: + case BuildingType_DarkGuild: GuildDialog(); break; - case BildingType_18: + case BuildingType_18: __debugbreak(); //What over the dialog? sub_4B6478(); break; - case BildingType_TownHall: + case BuildingType_TownHall: TownHallDialog(); break; - case BildingType_Tavern: + case BuildingType_Tavern: TavernDialog(); break; - case BildingType_Bank: + case BuildingType_Bank: BankDialog(); break; - case BildingType_Temple: + case BuildingType_Temple: TempleDialog(); break; - case BildingType_Stables: + case BuildingType_Stables: TravelByTransport(); break; - case BildingType_Training: + case BuildingType_Training: TrainingDialog(); break; - case BildingType_Jail: + case BuildingType_Jail: JailDialog(); break; default: - __debugbreak();//New BildingType + __debugbreak();//New BuildingType break; } }
--- a/GUIWindow.h Tue Jul 30 09:33:52 2013 +0600 +++ b/GUIWindow.h Tue Jul 30 09:34:14 2013 +0600 @@ -19,7 +19,7 @@ UIMSG_MouseLeftClickInScreen = 14, UIMSG_F = 15, - UIMSG_11 = 17, + UIMSG_ChangeCursor = 17, UIMSG_Attack = 23, @@ -229,7 +229,7 @@ enum DIALOGUE_TYPE { - DIALOGUE_9 = 9, + DIALOGUE_USE_NPC_ABILITY = 9, DIALOGUE_13 = 0xD, DIALOGUE_18 = 0x12, DIALOGUE_19 = 19, @@ -337,7 +337,7 @@ void DrawMessageBox(int arg0); GUIButton *GetControl(unsigned int uID); void Release(); - void _41D08F_set_keyboard_control_group(int a2, int a3, int a4, int a5); + void _41D08F_set_keyboard_control_group(int num_buttons, int a3, int a4, int a5); void _41D73D_draw_buff_tooltip(); static GUIWindow *Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, enum WindowType eWindowType, int pButton, const char* hint);
--- a/Game.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/Game.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -89,10 +89,12 @@ if ( pVideoPlayer->AnyMovieLoaded() ) { - if ( pRenderer->pRenderD3D ) - goto LABEL_22; - pRenderer->BeginSceneD3D(); - pMouse->DrawCursorToTarget(); + if ( !pRenderer->pRenderD3D ) + { + pRenderer->BeginSceneD3D(); + pMouse->DrawCursorToTarget(); + pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); + } } else { @@ -133,9 +135,8 @@ pGame->pLightmapBuilder->DrawLightmapsType(2); } } + pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); } - pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); -LABEL_22: //DEBUG: force redraw gui viewparams->bRedrawGameUI = true; @@ -1025,10 +1026,13 @@ || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0 && v3 <= 0x80 ) { - if ( v4 > 0 || v4 >= 0 ) - goto LABEL_12; - v3 = 0; - v4 = 0; + if ( v4 < 0 ) + { + v3 = 0; + v4 = 0; + uSomeGammaStartTime = v2; + v8 = __PAIR__(v4, v3); + } } else { @@ -1045,10 +1049,9 @@ v5 = __CFADD__(v3, -128); v3 -= 128; v4 = v5 + v4 - 1; + uSomeGammaStartTime = v2; + v8 = __PAIR__(v4, v3); } - uSomeGammaStartTime = v2; - v8 = __PAIR__(v4, v3); -LABEL_12: if ( uSomeGammaDeltaTime ) v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3)); else
--- a/GammaControl.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/GammaControl.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -72,16 +72,18 @@ { v3 = (double)v6 * 0.0039215689 * this->fGamma; if ( v3 >= 1.0 || (v4 = (signed __int64)(v3 * 65535.0), (signed int)v4 > 65535) ) - goto LABEL_12; - if ( (signed int)v4 < 0 ) + { + LODWORD(v4) = 65535; + } + else if ( (signed int)v4 < 0 ) { LODWORD(v4) = 0; - goto LABEL_8; } + else + { if ( (signed int)v4 > 65535 ) -LABEL_12: LODWORD(v4) = 65535; -LABEL_8: + } ++v6; v2[256] = v4; *v2 = v4;
--- a/Indoor.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/Indoor.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -62,7 +62,6 @@ stru320 stru_F8AD28; // idb stru337 stru_F81018; -stru167_wrap array_5118E8; BspRenderer_PortalViewportData stru_F8A590; BspRenderer *pBspRenderer = new BspRenderer; // idb stru141 stru_721530; @@ -412,7 +411,7 @@ sub_440BED(&_this); pParty->uFlags &= ~2; pGame->DrawParticles(); - array_5118E8._440F07(); + trail_particle_generator.UpdateParticles(); } //----- (004C0EF2) --------------------------------------------------------
--- a/Indoor_stuff.h Tue Jul 30 09:33:52 2013 +0600 +++ b/Indoor_stuff.h Tue Jul 30 09:34:14 2013 +0600 @@ -111,52 +111,6 @@ -/* 160 */ -#pragma pack(push, 1) -struct stru167 -{ - char field_0; - char field_1; - char field_2; - char field_3; - char field_4; - char field_5; - __int16 field_6_rnd_value; - __int16 field_8_rnd_value; - __int16 field_A_rnd_value; - __int16 field_C_time_left; - __int16 field_E_time_to_live; - char field_10; - char field_11; - char field_12; - char field_13; - __int16 bgr16; - char field_16; - char field_17; -}; -#pragma pack(pop) - - - -/* 363 */ -#pragma pack(push, 1) -struct stru167_wrap -{ - void _440F07(); - int Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr); - void _440E91(__int16 x, int y, int z, int a5, __int16 bgr); - - stru167 pElements[100]; - int uNumElements; - int field_964; -}; -#pragma pack(pop) -extern stru167_wrap array_5118E8; - - - - -
--- a/LightmapBuilder.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/LightmapBuilder.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -741,6 +741,7 @@ v5 = (char *)&a1->flt_2C; do { + __debugbreak(); // warning C4700: uninitialized local variable 'v7' used if ( *(float *)v5 < 0.0 || (v6 = *(float *)v5, /*UNDEF(v7),*/ v8 = 1.0 < v6, v9 = 0, v10 = 1.0 == v6, LOWORD(result) = v7, v6 <= 1.0) ) { @@ -749,6 +750,7 @@ v14 = 0.0 < v12; v15 = 0; v16 = 0.0 == v12; + __debugbreak(); // warning C4700: uninitialized local variable 'v13' used LOWORD(result) = v13; if ( v12 >= 0.0 ) v11 = *(float *)v5; @@ -880,6 +882,7 @@ a1.Normalize(); if ( uLightType & 4 ) { + __debugbreak(); // warning C4700: uninitialized local variable 'v18' used v22[1] = v18; uLightType = dword_4D86D8; v22[0] = v18; @@ -1473,6 +1476,7 @@ v25 = 1.0; } v9->field_10 = v25; + __debugbreak(); // warning C4700: uninitialized local variable 'v27' used if ( v9->field_14 < 0.0 || (v26 = v9->field_14, //UNDEF(v27), @@ -1487,6 +1491,7 @@ v34 = 0.0 < v32; v35 = 0; v36 = 0.0 == v32; + __debugbreak(); // warning C4700: uninitialized local variable 'v33' used BYTE1(result) = HIBYTE(v33); if ( v32 >= 0.0 ) v31 = v9->field_14;
--- a/NPC.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/NPC.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -1312,7 +1312,7 @@ { case 13: current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession); - current_npc_text = BuilDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); + current_npc_text = BuildDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); NPCHireableDialogPrepare(); dialogue_show_profession_details = false; goto _return; @@ -1391,7 +1391,7 @@ else v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pBenefits; current_npc_text = v17; - v18 = BuilDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0); + v18 = BuildDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0); dialogue_show_profession_details = ~dialogue_show_profession_details; current_npc_text = v18; } @@ -1511,7 +1511,7 @@ dialogue_show_profession_details = false; uDialogueType = 13; current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText; - current_npc_text = BuilDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); + current_npc_text = BuildDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); if ( uActiveCharacter ) pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); @@ -1657,7 +1657,7 @@ pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); if ( pDialogueNPCCount == 1 && dword_591080 ) { - sub_4B3B42(in_current_building_type); + InitializaDialogueOptions(in_current_building_type); } else {
--- a/NPC.h Tue Jul 30 09:33:52 2013 +0600 +++ b/NPC.h Tue Jul 30 09:34:14 2013 +0600 @@ -193,3 +193,5 @@ bool PartyHasDragon(); bool CheckHiredNPCSpeciality(unsigned int uProfession); + +int UseNPCSkill(NPCProf profession);
--- a/Outdoor.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/Outdoor.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -28,6 +28,7 @@ #include "Time.h" #include "Viewport.h" #include "Events.h" +#include "ParticleEngine.h" #include "mm7_data.h" #include "MM7.h" @@ -195,7 +196,7 @@ pGame->DrawParticles(); pWeather->Draw(); - array_5118E8._440F07(); + trail_particle_generator.UpdateParticles(); } //----- (00488E23) -------------------------------------------------------- @@ -782,7 +783,7 @@ a3d = v22 * v19 - v21 * v18; v16 = a3d + 6.7553994e15; v3->v_18.z = LODWORD(v16); - v3->_486089_normalize_v_18(); + v3->_normalize_v_18(); a3e = -((double)v3->v_18.x * v4->vWorldViewPosition.x) - (double)v3->v_18.y * v4->vWorldViewPosition.y - (double)v3->v_18.z * v4->vWorldViewPosition.z; @@ -3166,7 +3167,7 @@ return true; } //----- (0046D49E) -------------------------------------------------------- -int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int __unused, int *pIsOnWater, int *a6, int bWaterWalk) +int ODM_GetFloorLevel(int X, signed int Y, int Z, int __unused, int *pIsOnWater, int *bmodel_pid, int bWaterWalk) { BSPModel *pBModel; // esi@4 ODMFace *pFace; // ecx@11 @@ -3283,12 +3284,12 @@ } if ( v46 == 1 ) { - *a6 = 0; + *bmodel_pid = 0; return odm_floor_level[0]; } v27 = 0; if ( v46 <= 1 ) - *a6 = 0; + *bmodel_pid = 0; else { //v29 = 1; @@ -3318,9 +3319,9 @@ } } if ( !v27 ) - *a6 = 0; + *bmodel_pid = 0; else - *a6 = dword_721110[v27] | (dword_721160[v27] << 6); + *bmodel_pid = dword_721110[v27] | (dword_721160[v27] << 6); } if ( v27 ) { @@ -3333,6 +3334,7 @@ odm_floor_level[0] = odm_floor_level[v27]; return odm_floor_level[0]; } + //not sure if right- or left-handed coordinate space assumed, so this could be normal of inverse normal // for a right-handed system, that would be an inverse normal //----- (0046DCC8) --------------------------------------------------------
--- a/Outdoor_stuff.h Tue Jul 30 09:33:52 2013 +0600 +++ b/Outdoor_stuff.h Tue Jul 30 09:34:14 2013 +0600 @@ -18,7 +18,7 @@ int _479295(); void DrawBorderTiles(); //void _48276F_sr(); - void _486089_normalize_v_18(); + void _normalize_v_18(); void _48607B(struct stru149 *a2); float field_0;
--- a/ParticleEngine.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/ParticleEngine.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -12,6 +12,47 @@ #include "OutdoorCamera.h" #include "mm7_data.h" +TrailParticleGenerator trail_particle_generator; + + +//----- (00440DF5) -------------------------------------------------------- +void TrailParticleGenerator::AddParticle(int x, int y, int z, int bgr16) +{ + particles[num_particles].x = x; + particles[num_particles].y = y; + particles[num_particles].z = z; + particles[num_particles].time_to_live = rand() % 64 + 256; + particles[num_particles].time_left = particles[num_particles].time_to_live; + particles[num_particles].bgr16 = bgr16; + + num_particles++; + assert(num_particles < 100); +} + +//----- (00440E91) -------------------------------------------------------- +void TrailParticleGenerator::GenerateTrailParticles(int x, int y, int z, int bgr16) +{ + for (int i = 0; i < 5 + rand() % 6; ++i) + AddParticle(rand() % 33 + x - 16, + rand() % 33 + y - 16, + rand() % 33 + z, bgr16); +} + +//----- (00440F07) -------------------------------------------------------- +void TrailParticleGenerator::UpdateParticles() +{ + for (uint i = 0; i < 100; ++i) + { + if (particles[i].time_left > 0) + { + particles[i].x += rand() % 5 + 4; + particles[i].y += rand() % 5 - 2; + particles[i].z += rand() % 5 - 2; + particles[i].time_left -= pEventTimer->uTimeElapsed; + } + } +} + //----- (0048AAC5) -------------------------------------------------------- ParticleEngine::ParticleEngine() {
--- a/ParticleEngine.h Tue Jul 30 09:33:52 2013 +0600 +++ b/ParticleEngine.h Tue Jul 30 09:34:14 2013 +0600 @@ -127,4 +127,73 @@ int uEndParticle; int uTimeElapsed; }; -#pragma pack(pop) \ No newline at end of file +#pragma pack(pop) + + + + + + + + + + + +/* 160 */ +#pragma pack(push, 1) +struct TrailParticle // stru167 +{ + inline TrailParticle() + { + x = 0; + y = 0; + z = 0; + time_left = 0; + time_to_live = 0; + bgr16 = 0; + } + + char field_0; + char field_1; + char field_2; + char field_3; + char field_4; + char field_5; + __int16 x; + __int16 y; + __int16 z; + __int16 time_left; + __int16 time_to_live; + char field_10; + char field_11; + char field_12; + char field_13; + __int16 bgr16; + char field_16; + char field_17; +}; +#pragma pack(pop) + + +/* 363 */ +#pragma pack(push, 1) +struct TrailParticleGenerator // stru167_wrap +{ + public: + inline TrailParticleGenerator() + { + num_particles = 0; + } + + void GenerateTrailParticles(int x, int y, int z, int bgr16); + void UpdateParticles(); + + protected: + void AddParticle(int x, int y, int z, int bgr16); + + TrailParticle particles[100]; + int num_particles; + int field_964; +}; +#pragma pack(pop) +extern TrailParticleGenerator trail_particle_generator; // 005118E8 \ No newline at end of file
--- a/Player.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/Player.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -1066,25 +1066,25 @@ switch (building_type) { - case BildingType_WeaponShop: + case BuildingType_WeaponShop: if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) return 5; if (equipType > EQUIP_BOW) return 4; break; - case BildingType_ArmorShop: + case BuildingType_ArmorShop: if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) return 5; if ( equipType < EQUIP_ARMOUR || equipType > EQUIP_BOOTS) return 4; break; - case BildingType_MagicShop: + case BuildingType_MagicShop: if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) return 5; if ( pItemsTable->pItems[idemId].uSkillType != PLAYER_SKILL_MISC ) return 4; break; - case BildingType_AlchemistShop: + case BuildingType_AlchemistShop: if ((idemId >= ITEM_ARTIFACT_HERMES_SANDALS && idemId < ITEM_RECIPE_REJUVENATION) || idemId > ITEM_RECIPE_BODY_RESISTANCE) return 5; if ( !(equipType == EQUIP_REAGENT || equipType == EQUIP_POTION || equipType == EQUIP_MESSAGE_SCROLL)) @@ -2868,6 +2868,7 @@ { if ( HasItemEquipped((ITEM_EQUIP_TYPE)v14) ) { + __debugbreak(); // player.cpp(2871): warning C4700: uninitialized local variable 'v15' used if ( v15 == EQUIP_ARMOUR ) v46[v4++] = LOBYTE(v5->pEquipment.uArmor) - 1; if ( (!v15 || v15 == 1) && GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v15) == 4 ) @@ -2883,6 +2884,7 @@ { if ( HasItemEquipped((ITEM_EQUIP_TYPE)v16) ) { + __debugbreak(); // player.cpp(2886): warning C4700: uninitialized local variable 'v17' used if ( v17 == 2 ) v46[v4++] = LOBYTE(v5->pEquipment.uBow) - 1; if ( (!v17 || v17 == 1) @@ -3687,7 +3689,7 @@ Player *v21; // ecx@75 int v22; // eax@76 int v23; // edx@76 - int v24; // eax@79 + //int v24; // eax@79 int v25; // ecx@80 int v26; // edi@80 Player *v27; // ecx@84 @@ -4385,16 +4387,15 @@ v23 = this->pOwnItems[this->pEquipment.uMainHand].uItemID; if ( v6->pEquipment.uShield || pItemsTable->pItems[v23].uSkillType != 4 ) { - v24 = v23; v26 = pItemsTable->pItems[v23].uDamageRoll; v25 = pItemsTable->pItems[v23].uDamageDice; } else { - v25 = pItemsTable->pItems[v24].uDamageRoll; - v26 = pItemsTable->pItems[v24].uDamageDice + 1; + v25 = pItemsTable->pItems[v23].uDamageRoll; + v26 = pItemsTable->pItems[v23].uDamageDice + 1; } - v5 = pItemsTable->pItems[v24].uDamageMod + v25 * v26; + v5 = pItemsTable->pItems[v23].uDamageMod + v25 * v26; } } } @@ -5248,6 +5249,7 @@ assert(false && "Unknown attribute!"); + return 0; } //----- (00490109) -------------------------------------------------------- @@ -5329,10 +5331,9 @@ case 0x15u: case 0x18u: return SEX_FEMALE; - - default: - assert(false); - } + } + assert(false); + return SEX_MALE; } //----- (00490188) -------------------------------------------------------- @@ -5580,6 +5581,8 @@ ++counter; } } + + assert(false); } @@ -8632,6 +8635,9 @@ return false; } } + + assert(false); + return false; } // 5B65C4: using guessed type int dword_5B65C4; // 5B65CC: using guessed type int dword_5B65CC; @@ -8745,6 +8751,7 @@ result = Player_has_item(v5, *pPlayers, 0); if ( !result ) break; + __debugbreak(); // player.cpp(8748): warning C4700: uninitialized local variable 'v6' used result = v6->pEquipment.uArmor; if ( !result ) break; @@ -8759,6 +8766,8 @@ goto LABEL_6; } result = Player_has_item(604u, ::pPlayers[a1], 0); + __debugbreak(); // player.cpp(8764): warning C4700: uninitialized local variable 'v2' used + __debugbreak(); // player.cpp(8764): warning C4700: uninitialized local variable 'v3' used if ( !result || (result = v2->pEquipment.uArmor) == 0 || (result *= 9, *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v3) )
--- a/Render.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/Render.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -25,7 +25,6 @@ #include "Time.h" #include "Game.h" #include "LightmapBuilder.h" -#include "stru220.h" #include "ObjectList.h" #include "SpriteObject.h" #include "DecorationList.h" @@ -51,22 +50,11 @@ int uNumSpritesDrawnThisFrame; // weak RenderVertexSoft array_507D30[50]; -RenderVertexSoft array_508690[50]; -RenderVertexSoft array_508FF0[50]; -RenderVertexSoft array_509950[50]; -RenderVertexSoft array_50A2B0[50]; RenderVertexSoft array_50AC10[50]; - RenderVertexSoft array_73D150[20]; RenderVertexD3D3 d3d_vertex_buffer[50]; -RenderVertexSoft *ptr_801A04; -RenderVertexSoft *ptr_801A08; - -RenderVertexSoft pVerticesSR_801A10[384]; -RenderVertexSoft pVerticesSR_806210[384]; - void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); /* 384 */ @@ -384,585 +372,6 @@ } } -//----- (0048034E) -------------------------------------------------------- -void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4) -{ - //int v3; // esi@1 - int v4; // edi@1 - int v5; // ebx@2 - int v6; // eax@2 - int v7; // eax@3 - RenderVertexSoft *v8; // edi@3 - RenderVertexSoft *v9; // ebx@4 - RenderVertexSoft *v10; // ecx@4 - float v11; // eax@6 - double v12; // ST5C_8@6 - double v13; // ST2C_8@6 - int v14; // eax@6 - double v15; // st7@6 - struct Polygon *pTile; // ebx@12 - unsigned __int16 v17; // ax@12 - int v18; // eax@13 - signed int v22; // eax@13 - Vec3_float_ *norm; // eax@15 - //double v24; // st6@17 - double v25; // ST54_8@17 - unsigned __int8 v26; // sf@17 - unsigned __int8 v27; // of@17 - double v28; // st5@19 - double v29; // st5@19 - double v30; // st5@19 - double v31; // st5@19 - struct struct8 *v32; // esi@21 - double v3a; // st7@32 - int v33; // edi@38 - unsigned int v34; // ecx@47 - char v35; // zf@47 - unsigned int v36; // eax@50 - int v37; // eax@54 - //Polygon *v38; // ecx@55 - unsigned int v39; // eax@59 - struct Polygon *v40; // ebx@62 - unsigned __int16 pTileBitmapsID; // ax@62 - int v42; // eax@63 - LightmapBuilder *v43; // ecx@63 - int v44; // eax@63 - int v45; // eax@63 - int v46; // eax@63 - signed int v47; // eax@63 - Vec3_float_ *v48; // eax@65 - double v49; // st6@67 - double v50; // ST4C_8@67 - double v51; // st5@71 - double v52; // st5@71 - double v53; // st5@71 - double v54; // st7@84 - unsigned int v55; // ecx@98 - unsigned int v56; // eax@101 - int v57; // eax@105 - unsigned int v58; // eax@109 - struct Polygon *v59; // esi@112 - unsigned __int16 v60; // ax@112 - int v61; // eax@113 - signed int v62; // eax@113 - Vec3_float_ *v63; // eax@114 - double v64; // st6@116 - double v65; // ST3C_8@116 - double v66; // st5@120 - double v67; // st5@120 - double v68; // st5@120 - double v69; // st7@133 - int v70; // edi@138 - struct Polygon *v71; // esi@147 - unsigned int v72; // ecx@147 - unsigned int v73; // eax@150 - int v74; // eax@154 - unsigned int v75; // eax@158 - //unsigned int v76; // [sp-10h] [bp-E0h]@61 - int v77; // [sp-Ch] [bp-DCh]@61 - IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 - //int v79; // [sp-4h] [bp-D4h]@61 - bool v80; // [sp+0h] [bp-D0h]@59 - bool v81; // [sp+0h] [bp-D0h]@109 - int v82; // [sp+54h] [bp-7Ch]@1 - int v83; // [sp+60h] [bp-70h]@1 - int v84; // [sp+6Ch] [bp-64h]@1 - int v85; // [sp+70h] [bp-60h]@63 - float a4; // [sp+74h] [bp-5Ch]@73 - float v87; // [sp+78h] [bp-58h]@122 - int v88; // [sp+7Ch] [bp-54h]@1 - int v89; // [sp+80h] [bp-50h]@6 - int v93; // [sp+90h] [bp-40h]@2 - int X; // [sp+94h] [bp-3Ch]@1 - float v95; // [sp+98h] [bp-38h]@21 - LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 - int v97; // [sp+A0h] [bp-30h]@6 - int sX; // [sp+A4h] [bp-2Ch]@6 - unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 - int v100; // [sp+ACh] [bp-24h]@122 - int sY; // [sp+B0h] [bp-20h]@6 - RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 - unsigned int a5; // [sp+B8h] [bp-18h]@21 - RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 - Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 - RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 - RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 - char v108; // [sp+CFh] [bp-1h]@36 - float thisd; // [sp+D8h] [bp+8h]@6 - float thise; // [sp+D8h] [bp+8h]@6 - float thisf; // [sp+D8h] [bp+8h]@17 - IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 - float thisg; // [sp+D8h] [bp+8h]@67 - IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 - float thish; // [sp+D8h] [bp+8h]@116 - IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 - char this_3; // [sp+DBh] [bp+Bh]@30 - char this_3a; // [sp+DBh] [bp+Bh]@82 - char this_3b; // [sp+DBh] [bp+Bh]@131 - - static stru154 static_sub_0048034E_stru_154; - static stru154 stru_76D5A8; - //v3 = a1; - v82 = a2; - v83 = a3; - X = abs(unk4); - v4 = 0; - v88 = 0; - v84 = a1 - 1; -/* if ( a1 - 1 > 0 ) - { - while ( 1 ) - { - v5 = abs(X);//v5 = 13108 - v6 = abs(v83);//v6 = 13108 - --X; - //__debugbreak(); // uncoment & refactor following large if - v93 = (int)&stru_76E5C8[(v5 << 7) + v6]; - /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), - v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), - ((a8 = v9, - pVertices = &pVerticesSR_801A10[1] + v7, - v11 = v8->vWorldPosition.x, - v101 = v10, - v12 = v11 + 6.755399441055744e15, - sX = LODWORD(v12), - v13 = v8->vWorldPosition.y + 6.755399441055744e15, - sY = LODWORD(v13), - thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, - v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X - v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, - v89 = v14, - thise = v15 * 0.5, - _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z - WorldPosToGridCellX(sX), - WorldPosToGridCellZ(sY), - !byte_4D864C) - || !(pGame->uFlags & 0x80)) - && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ - /*if ( !&stru_76E5C8[(v5 << 7) + v6] ) - goto LABEL_162*/ - v8 = &pVerticesSR_806210[v4]; - //pVertices2 = &pVerticesSR_801A10[v4 + 1]; - //v102 = v8; - if (!v82) - { - pVertices = &pVerticesSR_801A10[v4]; - v101 = &pVerticesSR_806210[v4 + 1]; - } - else - { - pVertices = &pVerticesSR_801A10[v4 + 1]; - v101 = &pVerticesSR_806210[v4]; - } - sX = floorf(v8->vWorldPosition.x + 0.5f); - sY = floorf(v8->vWorldPosition.z + 0.5f); - v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); - v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); - /*WorldPosToGridCellX(sX); - WorldPosToGridCellZ(sY); - if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) - if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y - || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) - break;*/ - pTile = &array_77EC08[pOutdoorCamera->uNumPolygons]; - pTile->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( pTile->uTileBitmapID != -1 ) - { - pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); - pTile->field_32 = 0; - pTile->field_59 = 1; - pTile->terrain_grid_x = (char)v97; - pTile->field_34 = *(_WORD *)(v93 + 2); - pTile->terrain_grid_z = v89; - v22 = pTerrainNormalIndices[2 * (v97 + 128 * v89) + 1]; - if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) - norm = 0; - else - norm = &pTerrainNormals[v22]; - thisf = 20.0 - ( -(((float)pOutdoor->vSunlight.x / 65536.0) * norm->x) - - (((float)pOutdoor->vSunlight.y / 65536.0) * norm->y) - - (((float)pOutdoor->vSunlight.z / 65536.0) * norm->z)) * 20.0; - //v25 = thisf + 6.7553994e15; - //v27 = pOutdoorCamera->uNumPolygons > 1999; - //v26 = pOutdoorCamera->uNumPolygons - 1999 < 0; - pTile->dimming_level = floorf(thisf + 0.5f); - if ( pOutdoorCamera->uNumPolygons >= 1999 ) - return; - ++pOutdoorCamera->uNumPolygons; - //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary - //goto LABEL_126; - //{ - //--pOutdoorCamera->uNumPolygons; - //goto LABEL_162; - //} - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); - array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[3].u = 1.0; - array_50AC10[3].v = 0.0; - /*if ( !(byte_76D5C0 & 1) ) - { - byte_76D5C0 |= 1u; - stru154(stru_76D5A8); - atexit(loc_481199); - }*/ - v32 = (struct8 *)array_50AC10; - v97 = (int)pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &v95, array_50AC10, 4, 1); - pDecalBuilder->_49BE8A(pTile, norm, &v95, array_50AC10, 4, 1); - a5 = 4; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisa = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) - goto LABEL_162; - thisa->ViewTransform(array_50AC10, a5); - thisa->Project(array_50AC10, a5, 0); - } - this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 - || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; - v3a = (double)pOutdoorCamera->shading_dist_mist; - v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x - || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; - v33 = 0; - pGame->pLightmapBuilder->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3 ) - v33 = 3; - else - v33 = v108 != 0 ? 5 : 0; - static_sub_0048034E_stru_154.ClassifyPolygon(norm, v95); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - pTile->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); - v34 = a5; - //v35 = byte_4D864C == 0; - pTile->uNumVertices = a5; - if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) - { - if ( this_3 ) - { - v36 = sr_424CD7(v34); - pTile->uNumVertices = v36; - OutdoorCamera::Project(v36); - } - if ( v108 ) - { - v36 = sr_424EE0_MakeFanFromTriangle(v34); - pTile->uNumVertices = v36; - OutdoorCamera::Project(v36); - } - } - //v37 = *(int *)&v16->flags; - if ( ~pTile->flags & 1 ) - { - if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v80 = false; - v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v39 = pTile->uTileBitmapID; - v80 = true; - } - //v79 = 0; - //v78 = pBitmaps_LOD->pHardwareTextures[v39]; - pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary - v77 = (int)pTile; - //v76 = v16->uNumVertices; -//LABEL_161: - pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v39], false, v80); - goto LABEL_162; - } -LABEL_56: - pTile->DrawBorderTiles(); - } -LABEL_162: - v4 = v88 + 1; - if ( ++v88 >= v84 ) - return; - } - /* v40 = &array_77EC08[pOutdoorCamera->uNumPolygons]; - v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( v40->uTileBitmapID == -1 ) - goto LABEL_162; - v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); - BYTE1(v42) |= 0x80u; - v43 = pGame->pLightmapBuilder; - *(int *)&v40->flags = v42; - v44 = v93; - v40->field_59 = 1; - v40->terrain_grid_x = (char)v43; - v40->field_34 = *(_WORD *)(v44 + 2); - v45 = v89; - v40->terrain_grid_z = v89; - v46 = 4 * ((char)v43 + (v45 << 7)); - v85 = v46; - v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; - if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) - v48 = 0; - else - v48 = &pTerrainNormals[v47]; - v49 = v92 * v48->y; - //v99 = v48; - thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; - v50 = thisg + 6.755399441055744e15; - v40->dimming_level = LOBYTE(v50); - if ( LOBYTE(v50) < 0 ) - v40->dimming_level = 0; - if ( pOutdoorCamera->uNumPolygons >= 1999 ) - return; - ++pOutdoorCamera->uNumPolygons; - /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary - //goto LABEL_77; - { - --pOutdoorCamera->uNumPolygons; - goto LABEL_112; - }*/ - /*memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - static stru154 static_sub_0048034E_stru_76D590; - /*static bool __init_flag2 = false; - if (!__init_flag2) - { - __init_flag2 = true; - stru154::stru154(&static_sub_0048034E_stru_76D590); - }*/ - /*if ( !(byte_76D5C0 & 2) ) - { - byte_76D5C0 |= 2; - Polygon(stru_76D590); - atexit(loc_48118F); - }*/ - /*v96 = pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); - pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); - uNumVertices = 3; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisb = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) - { -//LABEL_77: - --pOutdoorCamera->uNumPolygons; - goto LABEL_112; - } - thisb->ViewTransform(array_50AC10, uNumVertices); - thisb->Project(array_50AC10, uNumVertices, 0); - } - this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; - v54 = (double)pOutdoorCamera->shading_dist_mist; - v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; - pVertices = 0; - v96->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3a ) - pVertices = (RenderVertexSoft *)3; - else - pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); - //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); - static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); - v55 = uNumVertices; - //v35 = byte_4D864C == 0; - v40->uNumVertices = uNumVertices; - if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) - { - if ( this_3a ) - { - v56 = sr_424CD7(v55); - } - else - { - if ( !v108 ) - goto LABEL_105; - v56 = sr_424EE0_MakeFanFromTriangle(v55); - } - v40->uNumVertices = v56; - OutdoorCamera::Project(v56); - } -LABEL_105: - v57 = *(int *)&v40->flags; - if ( BYTE1(v57) & 1 ) - { - v40->DrawBorderTiles(); - } - else - { - if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v81 = false; - v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v58 = v40->uTileBitmapID; - v81 = true; - } - pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); - } -LABEL_112: - v59 = &array_77EC08[pOutdoorCamera->uNumPolygons]; - //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->uNumPolygons]; - v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( v59->uTileBitmapID == -1 ) - goto LABEL_162; - *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); - v61 = v93; - v59->field_59 = 1; - v59->field_34 = *(_WORD *)(v61 + 2); - v59->terrain_grid_z = v89; - v59->terrain_grid_x = v97; - v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); - if ( v62 > (signed int)(uNumTerrainNormals - 1) ) - v63 = 0; - else - v63 = &pTerrainNormals[v62]; - v64 = v92 * v63->y; - //v99 = v63; - thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; - v59->dimming_level = floorf(thish + 0.5f); - if ( v59->dimming_level < 0 ) - v59->dimming_level = 0; - if ( pOutdoorCamera->uNumPolygons >= 1999 ) - return; - ++pOutdoorCamera->uNumPolygons; - if ( !sub_481FC9(v101, v102, pVertices2, v59) ) - { -//LABEL_126: - --pOutdoorCamera->uNumPolygons; - goto LABEL_162; - } - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[1].u = 1.0; - array_50AC10[1].v = 1.0; - memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 0.0; - static stru154 static_sub_0048034E_stru_76D578; - /*static bool __init_flag1 = false; - if (!__init_flag1) - { - __init_flag1 = true; - stru154::stru154(&static_sub_0048034E_stru_76D578); - }*/ - /* v96 = pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); - pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1); - v100 = 3; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisc = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) - //goto LABEL_126; - { - --pOutdoorCamera->uNumPolygons; - goto LABEL_162; - } - thisc->ViewTransform(array_50AC10, v100); - thisc->Project(array_50AC10, v100, 0); - } - this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 - || v101->vWorldViewPosition.x < 8.0; - v69 = (double)pOutdoorCamera->shading_dist_mist; - v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; - v70 = 0; - v96->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3b ) - v70 = 3; - else - v70 = v108 != 0 ? 5 : 0; - static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); - v71 = v59; - v72 = v100; - //v35 = byte_4D864C == 0; - v59->uNumVertices = v100;//??? - if ( !byte_4D864C && pGame->uFlags & 0x80 ) - goto LABEL_154; - if ( this_3b ) - { - v73 = sr_424CD7(v72); - } - else - { - if ( !v108 ) - { -LABEL_154: - v74 = v71->flags; - if ( !(BYTE1(v74) & 1) ) - { - if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v80 = false; - v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v75 = v71->uTileBitmapID; - v80 = true; - } - //v79 = 0; - v78 = pBitmaps_LOD->pHardwareTextures[v75]; - v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary - //v77 = (int)v71; - //v76 = v71->uNumVertices; - //goto LABEL_161; - pRenderer->DrawTerrainPolygon(v71->uNumVertices, (Polygon *)v71, v78, 0, v80); - goto LABEL_162; - } - v38 = (Polygon *)v71; - goto LABEL_56; - } - v73 = sr_424EE0_MakeFanFromTriangle(v72); - } - v71->uNumVertices = v73; - OutdoorCamera::Project(v73); - goto LABEL_154; - } - }*/ //----- (0047BACF) -------------------------------------------------------- @@ -1012,11 +421,12 @@ billboard.uFlags = pBillboard->field_1E; if (pBillboard->uHwSpriteID != -1) { - if (pRenderer->pRenderD3D) + if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering + //if (pRenderer->pRenderD3D) pRenderer->TransformBillboard(&billboard, &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], pBillboard->dimming_level, pBillboard); - else + /*else { assert(false); @@ -1024,7 +434,7 @@ if ( *(v1 - 10) & 2 ) v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); else - v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); + v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); v10 = (*(v1 - 9) & 1) == 0; billboard.pPalette = v9; if ( !v10 ) @@ -1039,7 +449,7 @@ v13 = *((short *)v1 - 8); if ( v13 >= 0 ) pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); - } + }*/ } } } @@ -2356,6 +1766,7 @@ if ( v9 == v10 ) { ddsd2.dwFlags = 0x1007u; + __debugbreak(); // warning C4700: uninitialized local variable 'v11' used ddsd2.ddsCaps.dwCaps = v11; goto LABEL_12; } @@ -3076,7 +2487,9 @@ Dst = 124; if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) return; + __debugbreak(); // warning C4700: uninitialized local variable 'v20' used v42 = v20; + __debugbreak(); // warning C4700: uninitialized local variable 'v19' used v6 = v19 >> 1; v3 = 0; } @@ -4794,6 +4207,7 @@ pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; } + __debugbreak(); // warning C4700: uninitialized local variable 'v6' used v9 = (int)v6; v10 = pFrontBuffer; // BUG @@ -5457,6 +4871,7 @@ { d3d_vertex_buffer[i].specular = 0; } + __debugbreak(); // warning C4700: uninitialized local variable 'v20' used d3d_vertex_buffer[i].specular = v20; d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v;
--- a/Render.h Tue Jul 30 09:33:52 2013 +0600 +++ b/Render.h Tue Jul 30 09:34:14 2013 +0600 @@ -510,18 +510,7 @@ extern RenderVertexSoft array_507D30[50]; -extern RenderVertexSoft array_508690[50]; -extern RenderVertexSoft array_508FF0[50]; -extern RenderVertexSoft array_509950[50]; -extern RenderVertexSoft array_50A2B0[50]; extern RenderVertexSoft array_50AC10[50]; - extern RenderVertexSoft array_73D150[20]; -extern RenderVertexD3D3 d3d_vertex_buffer[50]; - -extern RenderVertexSoft *ptr_801A04; -extern RenderVertexSoft *ptr_801A08; - -extern RenderVertexSoft pVerticesSR_801A10[384]; -extern RenderVertexSoft pVerticesSR_806210[384]; \ No newline at end of file +extern RenderVertexD3D3 d3d_vertex_buffer[50]; \ No newline at end of file
--- a/SpriteObject.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/SpriteObject.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -199,6 +199,9 @@ uNumSpriteObjects = v6 + 1; return v6; } + + assert(false); + return 0; } //----- (00471C03) -------------------------------------------------------- @@ -1090,9 +1093,6 @@ (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & 0x10)) SpriteObject::OnInteraction(i); } - - for (uint i = 0; i < 100; ++i) - array_5118E8.pElements[i].field_C_time_left = 0; } //----- (0046BEF1) -------------------------------------------------------- void SpriteObject::_46BEF1_apply_spells_aoe()
--- a/Texture.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/Texture.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -1680,6 +1680,7 @@ { *strchr(&Buf, 10) = 0; memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); + __debugbreak(); // warning C4700: uninitialized local variable 'Str1' used if ( v21 && *Str1 != 47 ) { if ( v21 < 2 ) @@ -1707,6 +1708,7 @@ if ( v21 && *Str1 != 47 ) { strcpy(v2->pTextures[v2->sNumTextures].pTextureName, Str1); + __debugbreak(); // warning C4700: uninitialized local variable 'Str' used v2->pTextures[v2->sNumTextures].uAnimTime = atoi(Str); v9 = 2; for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 )
--- a/UI/Books/UINotesBooks.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/UI/Books/UINotesBooks.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -637,7 +637,7 @@ num_achieved_awards = 0; //v7 = *pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6); v7 = (int)pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6); - v8 = BuilDialogueString( + v8 = BuildDialogueString( pStorylineText->StoreLine[v6].pText, uActiveCharacter - 1, 0,
--- a/UI/UIGuilds.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/UI/UIGuilds.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -182,8 +182,8 @@ v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14)); v16 = (int)window_SpeakInHouse->ptr_1C; uPlayerID = uActiveCharacter - 1; - v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, BildingType_MagicShop, v16, 2); - v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); + v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, BuildingType_MagicShop, v16, 2); + v18 = BuildDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); v19 = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0); working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorWhite, v18, 3); return;
--- a/UI/UIHouses.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/UI/UIHouses.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -13,7 +13,6 @@ #include "..\Mouse.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" -#include "..\Events2D.h" #include "..\Overlays.h" #include "..\Outdoor.h" #include "..\AudioPlayer.h" @@ -31,7 +30,7 @@ int dword_591080; // weak -int in_current_building_type; // 00F8B198 +BuildingType in_current_building_type; // 00F8B198 HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C #pragma pack(push, 1) @@ -315,6 +314,438 @@ }}; + +//----- (004B3A72) -------------------------------------------------------- +void InitializaDialogueOptions_Tavern(BuildingType type) +{ + int num_buttons; // esi@1 + + num_buttons = 0; + if (type == BuildingType_Tavern) + { + num_buttons = 2; + CreateButtonInColumn(0, 102); + CreateButtonInColumn(1, 103); + if ( pParty->HasItem(651) ) //Arcomage Deck + { + num_buttons = 3; + CreateButtonInColumn(2, 104); + } + } + pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2); + dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; +} +// F8B1E0: using guessed type int dword_F8B1E0; + +//----- (004B3AD4) -------------------------------------------------------- +void InitializaDialogueOptions_Shops(BuildingType type) +{ + switch (type) + { + case BuildingType_WeaponShop: + case BuildingType_ArmorShop: + case BuildingType_MagicShop: + { + CreateButtonInColumn(0, 3); + CreateButtonInColumn(1, 4); + CreateButtonInColumn(2, 5); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_AlchemistShop: + { + CreateButtonInColumn(0, 3); + CreateButtonInColumn(1, 4); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + } + + dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; +} +// F8B1E0: using guessed type int dword_F8B1E0; + +//----- (004B3B42) -------------------------------------------------------- +void InitializaDialogueOptions(BuildingType type) +{ + /*int v1; // ecx@18 + int v2; // ecx@19 + int v3; // ecx@20 + signed int v4; // esi@22 + signed int v5; // eax@22 + unsigned int v6; // edx@24 + int v7; // ecx@24 + int result; // eax@43 + int v9; // [sp-10h] [bp-14h]@28 + int v10; // [sp-Ch] [bp-10h]@28 + int v11; // [sp-8h] [bp-Ch]@28 + unsigned int v12; // [sp-4h] [bp-8h]@4 + unsigned int v13; // [sp-4h] [bp-8h]@5 + unsigned int v14; // [sp-4h] [bp-8h]@9 + unsigned int v15; // [sp-4h] [bp-8h]@10 + unsigned int v16; // [sp-4h] [bp-8h]@14 + int v17; // [sp-4h] [bp-8h]@28*/ + + switch (type) + { + case BuildingType_WeaponShop: + case BuildingType_ArmorShop: + case BuildingType_MagicShop: + case BuildingType_AlchemistShop: + { + CreateButtonInColumn(0, 2); + CreateButtonInColumn(1, 95); + CreateButtonInColumn(2, 94); + CreateButtonInColumn(3, 96); + pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2); + } + break; + + case BuildingType_FireGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 48); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_AirGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 49); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_WaterGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 50); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_EarthGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 51); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_SpiritGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 52); + CreateButtonInColumn(2, 61); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_MindGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 53); + CreateButtonInColumn(2, 61); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_BodyGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 54); + CreateButtonInColumn(2, 61); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_LightGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 55); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_DarkGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 56); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_14: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 48); + CreateButtonInColumn(2, 49); + CreateButtonInColumn(3, 50); + CreateButtonInColumn(4, 51); + pDialogueWindow->_41D08F_set_keyboard_control_group(5, 1, 0, 2); + } + break; + + case BuildingType_15: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 52); + CreateButtonInColumn(2, 53); + CreateButtonInColumn(3, 54); + pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2); + } + break; + + case BuildingType_16: + case BuildingType_TownHall: + { + int num_buttons = 1; + CreateButtonInColumn(0, 99); + + if (pParty->uFine) + { + num_buttons++; + CreateButtonInColumn(1, 100); + } + + pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2); + } + break; + + case BuildingType_Bank: + { + CreateButtonInColumn(0, 7); + CreateButtonInColumn(1, 8); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_Temple: + { + CreateButtonInColumn(0, 10); + CreateButtonInColumn(1, 11); + CreateButtonInColumn(2, 96); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_Stables: + case BuildingType_Boats: + { + CreateButtonInColumn(0, 105); + CreateButtonInColumn(1, 106); + CreateButtonInColumn(2, 107); + CreateButtonInColumn(3, 108); + pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2); + } + break; + + case BuildingType_Training: + { + CreateButtonInColumn(0, 17); + CreateButtonInColumn(1, 96); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_18: + case BuildingType_19: + case BuildingType_Throne_Room: + case BuildingType_24: + case BuildingType_Unic: + case BuildingType_1A: + case BuildingType_House: + case BuildingType_Jail: + break; + + default: + assert(false && "Invalid enumeration value"); + } + +/* if ( a1 > 13 ) + { + if ( a1 > 22 ) + { + if ( a1 == 23 ) + { + CreateButtonInColumn(0, 0xAu); + CreateButtonInColumn(1, 0xBu); + v14 = 96; +LABEL_41: + CreateButtonInColumn(2, v14); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 3; + goto LABEL_42; + } + if ( a1 <= 26 ) + goto LABEL_43; + if ( a1 > 28 ) + { + if ( a1 != 30 ) + goto LABEL_43; + CreateButtonInColumn(0, 0x11u); + v16 = 96; + goto LABEL_37; + } + CreateButtonInColumn(0, 0x69u); + CreateButtonInColumn(1, 0x6Au); + CreateButtonInColumn(2, 0x6Bu); + v12 = 108; + } + else + { + if ( a1 == 22 ) + { + CreateButtonInColumn(0, 7u); + v16 = 8; + goto LABEL_37; + } + v1 = a1 - 14; + if ( !v1 ) // == 14 + { + CreateButtonInColumn(0, 0x12u); + CreateButtonInColumn(1, 0x30u); + CreateButtonInColumn(2, 0x31u); + CreateButtonInColumn(3, 0x32u); + CreateButtonInColumn(4, 0x33u); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 5; + goto LABEL_42; + } + v2 = v1 - 1; + if ( v2 ) // > 15 + { + v3 = v2 - 2; + if ( v3 ) // > 17 + { + if ( v3 != 4 ) // 18, 19, 20 + goto LABEL_43; + CreateButtonInColumn(0, 0xFu); // 21 + CreateButtonInColumn(1, 0x10u); + v4 = 3; + CreateButtonInColumn(2, 0x60u); + v5 = (signed int)window_SpeakInHouse->ptr_1C; + if ( v5 < 108 || v5 > 120 ) + goto LABEL_28; + v4 = 4; + v6 = 101; + v7 = 3; + } + else // 16, 17 + { + v4 = 1; + CreateButtonInColumn(0, 0x63u); + if ( !pParty->uFine ) + { +LABEL_28: + v17 = 2; + v11 = 0; + v10 = 1; + v9 = v4; +LABEL_42: + pDialogueWindow->_41D08F_set_keyboard_control_group(v9, v10, v11, v17); + goto LABEL_43; + } + v4 = 2; + v7 = 1; + v6 = 100; + } + CreateButtonInColumn(v7, v6); + goto LABEL_28; + } + CreateButtonInColumn(0, 0x12u); // 15 + CreateButtonInColumn(1, 0x34u); + CreateButtonInColumn(2, 0x35u); + v12 = 54; + } +LABEL_39: + CreateButtonInColumn(3, v12); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 4; + goto LABEL_42; + } + if ( a1 == 13 ) + { + CreateButtonInColumn(0, 0x12u); + v16 = 56; +LABEL_37: + CreateButtonInColumn(1, v16); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 2; + goto LABEL_42; + } + switch ( a1 ) + { + case 1: + case 2: + case 3: + case 4: + CreateButtonInColumn(0, 2u); + CreateButtonInColumn(1, 0x5Fu); + CreateButtonInColumn(2, 0x5Eu); + v12 = 96; + goto LABEL_39; + case 5: + CreateButtonInColumn(0, 0x12u); + v13 = 48; + goto LABEL_9; + case 6: + CreateButtonInColumn(0, 0x12u); + v13 = 49; + goto LABEL_9; + case 7: + CreateButtonInColumn(0, 0x12u); + v13 = 50; + goto LABEL_9; + case 8: + CreateButtonInColumn(0, 0x12u); + v13 = 51; +LABEL_9: + CreateButtonInColumn(1, v13); + v14 = 72; + goto LABEL_41; + case 9: + CreateButtonInColumn(0, 0x12u); + v15 = 52; + goto LABEL_13; + case 10: + CreateButtonInColumn(0, 0x12u); + v15 = 53; + goto LABEL_13; + case 11: + CreateButtonInColumn(0, 0x12u); + v15 = 54; +LABEL_13: + CreateButtonInColumn(1, v15); + v14 = 61; + goto LABEL_41; + case 12: + CreateButtonInColumn(0, 0x12u); + v16 = 55; + goto LABEL_37; + default: + break; + } +LABEL_43:*/ + dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; +} +// F8B1E0: using guessed type int dword_F8B1E0; + + //----- (004B1784) -------------------------------------------------------- bool __cdecl HouseUI_CheckIfPlayerCanInteract() { @@ -441,13 +872,13 @@ pAudioPlayer->StopChannels(-1, -1); uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID; - in_current_building_type = pAnimatedRooms[uCurrentHouse_Animation].uBuildingType; - if ( in_current_building_type == BildingType_Throne_Room && pParty->uFine ) // going 2 jail + in_current_building_type = (BuildingType)pAnimatedRooms[uCurrentHouse_Animation].uBuildingType; + if ( in_current_building_type == BuildingType_Throne_Room && pParty->uFine ) // going 2 jail { uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID; uHouseID = HOUSE_JAIL; pParty->uTimePlayed = pParty->uTimePlayed + 0x7620000; - in_current_building_type = pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE_EMERALD_ISLE].uAnimationID].uBuildingType; + in_current_building_type = (BuildingType)pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE_EMERALD_ISLE].uAnimationID].uBuildingType; ++pParty->uNumPrisonTerms; pParty->uFine = 0; for (uint i = 0; i < 4; ++i) @@ -664,7 +1095,7 @@ //else if (dialog_menu_id == HOUSE_DIALOGUE_MAIN) { - if ( in_current_building_type == BildingType_Training ) + if ( in_current_building_type == BuildingType_Training ) { if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) { @@ -692,12 +1123,12 @@ v8 = window_SpeakInHouse; } //else - if ( in_current_building_type != BildingType_Training ) + if ( in_current_building_type != BuildingType_Training ) { v8 = window_SpeakInHouse; - if ((in_current_building_type == BildingType_Stables || in_current_building_type == BildingType_Boats) && + if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) && transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7] - || in_current_building_type != BildingType_Temple || uMessageParam != BildingType_MindGuild ) + || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild ) { //LABEL_9: pDialogueWindow->Release(); @@ -718,9 +1149,9 @@ } //LABEL_11: dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam; - if ( in_current_building_type < BildingType_19 ) + if ( in_current_building_type < BuildingType_19 ) { - v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE); + v9 = pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE); //v3 = dword_F8B198; ShopTexture = &pIcons_LOD->pTextures[v9]; //LABEL_13: @@ -729,20 +1160,20 @@ } //NEW - switch(in_current_building_type) + switch (in_current_building_type) { - case BildingType_FireGuild: - case BildingType_AirGuild: - case BildingType_WaterGuild: - case BildingType_EarthGuild: - case BildingType_SpiritGuild: - case BildingType_MindGuild: - case BildingType_BodyGuild: - case BildingType_LightGuild: - case BildingType_DarkGuild: - case BildingType_14: - case BildingType_15: - case BildingType_16: + case BuildingType_FireGuild: + case BuildingType_AirGuild: + case BuildingType_WaterGuild: + case BuildingType_EarthGuild: + case BuildingType_SpiritGuild: + case BuildingType_MindGuild: + case BuildingType_BodyGuild: + case BuildingType_LightGuild: + case BuildingType_DarkGuild: + case BuildingType_14: + case BuildingType_15: + case BuildingType_16: { if ( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472] >= (signed __int64)pParty->uTimePlayed && *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468] >= (signed __int64)pParty->uTimePlayed ) @@ -775,7 +1206,7 @@ //return; break; } - case BildingType_TownHall: + case BuildingType_TownHall: { if ( uMessageParam == 99 ) { @@ -981,20 +1412,20 @@ } break; } - case BildingType_Bank: + case BuildingType_Bank: { if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) pKeyActionMap->EnterText(1, 10, v8); return; break; } - case BildingType_WeaponShop: - case BildingType_ArmorShop: - case BildingType_MagicShop: - case BildingType_AlchemistShop: - case BildingType_Tavern: - case BildingType_Temple: - case BildingType_Training: + case BuildingType_WeaponShop: + case BuildingType_ArmorShop: + case BuildingType_MagicShop: + case BuildingType_AlchemistShop: + case BuildingType_Tavern: + case BuildingType_Temple: + case BuildingType_Training: { break; } @@ -1006,25 +1437,25 @@ } /* - if ( in_current_building_type > BildingType_Tavern ) + if ( in_current_building_type > BuildingType_Tavern ) { - if ( in_current_building_type == BildingType_Bank ) + if ( in_current_building_type == BuildingType_Bank ) { if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) pKeyActionMap->EnterText(1, 10, v8); return; } - if ( in_current_building_type != BildingType_Temple && in_current_building_type != BildingType_Training ) + if ( in_current_building_type != BuildingType_Temple && in_current_building_type != BuildingType_Training ) return; } //else - if ( in_current_building_type < BildingType_Tavern ) + if ( in_current_building_type < BuildingType_Tavern ) { if (in_current_building_type <= 0) return; - if ( in_current_building_type > BildingType_AlchemistShop ) + if ( in_current_building_type > BuildingType_AlchemistShop ) { - if ( in_current_building_type <= BildingType_16 ) + if ( in_current_building_type <= BuildingType_16 ) { if ( (signed __int64)__PAIR__( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472], @@ -1059,9 +1490,9 @@ } return; } - if ( in_current_building_type != BildingType_TownHall ) + if ( in_current_building_type != BuildingType_TownHall ) return; - if ( in_current_building_type == BildingType_TownHall ) + if ( in_current_building_type == BuildingType_TownHall ) { if ( uMessageParam == 99 ) { @@ -1284,7 +1715,7 @@ { pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3A72(in_current_building_type); + InitializaDialogueOptions_Tavern(in_current_building_type); break; } case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES: @@ -1328,7 +1759,7 @@ } } } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v48 = 0; if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) @@ -1356,7 +1787,7 @@ } } } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v53 = 0; if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) @@ -1385,7 +1816,7 @@ { pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3AD4(in_current_building_type); + InitializaDialogueOptions_Shops(in_current_building_type); break; } default: @@ -1408,7 +1839,7 @@ if ( pParty->uNumGold < v37 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); - if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern ) + if ( in_current_building_type == BuildingType_Training || in_current_building_type == BuildingType_Tavern ) v39 = 4; else v39 = 2; @@ -1471,7 +1902,7 @@ if ( pParty->uNumGold < v37 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); - if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern ) + if ( in_current_building_type == BuildingType_Training || in_current_building_type == BuildingType_Tavern ) v39 = 4; else v39 = 2; @@ -1493,7 +1924,7 @@ { pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3AD4(in_current_building_type); + InitializaDialogueOptions_Shops(in_current_building_type); } } } @@ -1543,7 +1974,7 @@ //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v47 = v8->ptr_1C; v48 = 0; @@ -1588,7 +2019,7 @@ //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v52 = v8->ptr_1C; v53 = 0; @@ -1697,10 +2128,10 @@ auto color_selected = TargetColor(255, 255, 155); v3 = 52 * (unsigned int)v0->ptr_1C; //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50); - //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BildingType_Stables) - 1) & 0xFFFFFFE7) + 50); + //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BuildingType_Stables) - 1) & 0xFFFFFFE7) + 50); //v4 = (signed __int64)((double)(signed int)v59 * p2DEvents_minus1__20[v3 / 4]); - v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BildingType_Stables ? 25 : 50; + v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BuildingType_Stables ? 25 : 50; v4 *= p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier; s1 = v4 * (100 - v1->GetMerchant()) / 100;
--- a/UI/UIHouses.h Tue Jul 30 09:33:52 2013 +0600 +++ b/UI/UIHouses.h Tue Jul 30 09:34:14 2013 +0600 @@ -1,4 +1,5 @@ #pragma once +#include "..\Events2D.h" enum HOUSE_DIALOGUE_MENU: __int32 { @@ -133,7 +134,12 @@ void __cdecl AlchemistDialog(); void __cdecl ArmorShopDialog(); + +void InitializaDialogueOptions_Tavern(BuildingType type); // idb +void InitializaDialogueOptions_Shops(BuildingType type); +void InitializaDialogueOptions(BuildingType type); + extern int uHouse_ExitPic; // weak extern int dword_591080; // weak -extern int in_current_building_type; // 00F8B198 +extern BuildingType in_current_building_type; // 00F8B198 extern HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C \ No newline at end of file
--- a/UI/UIShops.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/UI/UIShops.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -233,14 +233,14 @@ pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60]; if ( !v56 || !Str ) { - v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); - v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2); + v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { - v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v7 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } @@ -267,8 +267,8 @@ || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) ) return; v79 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; - v13 = pPlayer->SelectPhrasesTransaction(v79, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3); - v7 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + v13 = pPlayer->SelectPhrasesTransaction(v79, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3); + v7 = BuildDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); break; @@ -288,14 +288,14 @@ v4 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; if (!v4->Identified()) { - v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4); - v7 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v10 = pPlayer->SelectPhrasesTransaction(v4, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4); + v7 = BuildDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { - v7 = BuilDialogueString("%24", uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v7 = BuildDialogueString("%24", uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } @@ -315,8 +315,8 @@ || (!(pPlayer->pOwnItems[pNumActiveItem-1].uAttributes& 2)) ) return; v4 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; - v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); - v7 = BuilDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + v10 = pPlayer->SelectPhrasesTransaction(v4, BuildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); + v7 = BuildDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0); pTextHeight = (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorWhite, v7, 3); return; @@ -424,14 +424,14 @@ pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724]; if ( !v56 || !Str ) { - v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); - v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2); + v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { - v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v7 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } @@ -668,6 +668,8 @@ short text_color; int pActiveButton; + __debugbreak(); // uishops.cpp(952): warning C4700: uninitialized local variable 'v33' used + __debugbreak(); // uishops.cpp(981): warning C4700: uninitialized local variable 'v98' used memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); dialog_window.uFrameX = 483; dialog_window.uFrameWidth = 148; @@ -759,10 +761,10 @@ pItemCount = v74 - 1; selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74-1]; if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0) - v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; + v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; else v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" - v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v36 = BuildDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -831,10 +833,10 @@ else selected_item = &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v74 - 1]; if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 ) - v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; + v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; else v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" - v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v36 = BuildDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -893,9 +895,9 @@ || (v10 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v10) ) return; v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v10 - 1]; - v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3); - v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3)]; - v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0); + v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 3); + v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 3)]; + v36 = BuildDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -922,10 +924,10 @@ v5 = "%24"; else { - v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v3, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 4); + v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v3, BuildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 4); v5 = (char *)pMerchantsIdentifyPhrases[v8]; } - v6 = BuilDialogueString(v5, uActiveCharacter - 1, v3, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v6 = BuildDialogueString(v5, uActiveCharacter - 1, v3, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v115 = (174 - pFontArrus->CalcTextHeight(v6, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v6, 3); return; @@ -949,10 +951,11 @@ || (v32 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v32) || (!(pPlayers[uActiveCharacter]->pOwnItems[v32-1].uAttributes& 2)) ) return; + __debugbreak(); // warning C4700: uninitialized local variable 'v33' used v116 = &pPlayers[uActiveCharacter]->pInventoryItemList[v33 - 1]; - v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[v32 - 1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 5); + v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[v32 - 1], BuildingType_ArmorShop, window_SpeakInHouse->par1C, 5); v15 = (char *)pMerchantsRepairPhrases[v35]; - v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + v36 = BuildDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -977,8 +980,9 @@ { --pItemCount; v97 = uActiveCharacter - 1; - v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 2); - v100 = BuilDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, v98, (char *)window_SpeakInHouse->par1C, 2, 0); + __debugbreak(); // warning C4700: uninitialized local variable 'v98' used + v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2); + v100 = BuildDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, v98, (char *)window_SpeakInHouse->par1C, 2, 0); v103 = pFontArrus->CalcTextHeight(v100, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v103) / 2 + 138, pWhiteColor, v100, 3); } @@ -1360,14 +1364,14 @@ v70 = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; if ( !v63 || !Str ) { - v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2); + v71 = pPlayer->SelectPhrasesTransaction(v70, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2); v38 = (char *)pMerchantsBuyPhrases[v71]; } else { v38 = pGlobalTXT_LocalizationStrings[181]; } - v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v21 = BuildDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return ; @@ -1387,8 +1391,8 @@ || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) ) return; v87 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; - v45 = pPlayer->SelectPhrasesTransaction(v87, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3); - v21 = BuilDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + v45 = pPlayer->SelectPhrasesTransaction(v87, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3); + v21 = BuildDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v21, 3); return; @@ -1407,14 +1411,14 @@ v37 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; if (!v37->Identified()) { - v42 = pPlayer->SelectPhrasesTransaction(v37, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4); + v42 = pPlayer->SelectPhrasesTransaction(v37, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4); v38 = (char *)pMerchantsIdentifyPhrases[v42]; } else { v38 = "%24"; } - v21 = BuilDialogueString(v38, uActiveCharacter - 1, v37, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v21 = BuildDialogueString(v38, uActiveCharacter - 1, v37, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return; @@ -1563,14 +1567,14 @@ v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; if ( !v63 || !Str ) { - v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, v68, 2); + v71 = pPlayer->SelectPhrasesTransaction(v70, BuildingType_AlchemistShop, v68, 2); v38 = (char *)pMerchantsBuyPhrases[v71]; } else { v38 = pGlobalTXT_LocalizationStrings[181]; } - v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v21 = BuildDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return; @@ -1943,10 +1947,10 @@ v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" else { - v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); + v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); v10 = (char *)pMerchantsBuyPhrases[v75]; } - v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v30 = BuildDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; @@ -2074,10 +2078,10 @@ v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" else { - v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); + v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); v10 = (char *)pMerchantsBuyPhrases[v75]; } - v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v30 = BuildDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; @@ -2138,8 +2142,8 @@ || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) ) return; item = &pPlayers[uActiveCharacter]->pInventoryItemList[result - 1]; - v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3); - v30 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3); + v30 = BuildDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; @@ -2165,13 +2169,13 @@ item = &pPlayers[uActiveCharacter]->pInventoryItemList[result-1]; if ( item->uAttributes & 1 ) { - v5 = BuilDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v5 = BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v6 = (212 - pFontArrus->CalcTextHeight(v5, &dialog_window, 0, 0)) / 2 + 101; dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v5, 3); return; } - v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4); - v30 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v8], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4); + v30 = BuildDialogueString((char *)pMerchantsIdentifyPhrases[v8], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v30, 3); return; @@ -2197,8 +2201,8 @@ || (!(pPlayers[uActiveCharacter]->pOwnItems[result-1].uAttributes& 2)) ) return; item = &pPlayers[uActiveCharacter]->pInventoryItemList[result - 1]; - v29 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[result - 1], BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5); - v30 = BuilDialogueString((char *)pMerchantsRepairPhrases[v29], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + v29 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[result - 1], BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5); + v30 = BuildDialogueString((char *)pMerchantsRepairPhrases[v29], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; @@ -2558,7 +2562,7 @@ if ( pParty->uNumGold < uPriceItemService ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" - if ( in_current_building_type == BildingType_Training ) + if ( in_current_building_type == BuildingType_Training ) v55 = 4; else v55 = 2; @@ -2600,7 +2604,7 @@ if ( in_current_building_type <= 0 ) return; - if ( in_current_building_type <= BildingType_AlchemistShop ) + if ( in_current_building_type <= BuildingType_AlchemistShop ) { if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) { @@ -2631,7 +2635,7 @@ GameUI_DrawItemInfo(v7); return; } - if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) + if ( in_current_building_type <= BuildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) { v1 = pMouse->GetCursorPos(&a2); v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y]; @@ -2650,16 +2654,16 @@ if ( in_current_building_type > 0 ) { - if ( in_current_building_type > BildingType_MagicShop ) + if ( in_current_building_type > BuildingType_MagicShop ) { - if ( in_current_building_type == BildingType_Bank ) + if ( in_current_building_type == BuildingType_Bank ) { if ( !dword_F8B1E4 ) return; } else { - if ( in_current_building_type != BildingType_Temple ) + if ( in_current_building_type != BuildingType_Temple ) return; } PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Greeting_2);
--- a/UI/UiGame.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/UI/UiGame.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -287,7 +287,7 @@ a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u); a1.uFrameWidth -= 24; a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; - v14 = BuilDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); + v14 = BuildDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0); } } @@ -481,7 +481,7 @@ switch (uDialogueType) { case DIALOGUE_13: - pInString = BuilDialogueString(pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); break; case DIALOGUE_PROFESSION_DETAILS: @@ -489,11 +489,11 @@ auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; if (dialogue_show_profession_details) - pInString = BuilDialogueString(prof->pBenefits, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pBenefits, uActiveCharacter - 1, 0, 0, 0, 0); else if (pNPC->Hired()) - pInString = BuilDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); else - pInString = BuilDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); } break; @@ -535,9 +535,9 @@ auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; if (pNPC->Hired()) - pInString = BuilDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); else - pInString = BuilDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); } break; } @@ -1901,7 +1901,7 @@ { if ( pCurrentScreen == SCREEN_CHEST ) { - sub_42038D(); + ChestUI_WritePointedObjectStatusString(); //goto _return; if ( pMouse->uPointingObjectID == 0 ) {
--- a/_deleted.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/_deleted.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -726,7 +726,7 @@ v27 = -10000.0; if ( (signed int)v1 > 0 ) { - v4 = (char *)&array_508690[0].vWorldViewProjY; + v4 = (char *)&sr_508690[0].vWorldViewProjY; do { if ( *((float *)v4 - 1) < (double)v26 ) @@ -769,20 +769,20 @@ *(&v19 + v10) = i; } } - v11 = &array_508690[v19]; - v12 = &array_508690[v20]; - v13 = &array_508690[v21]; + v11 = &sr_508690[v19]; + v12 = &sr_508690[v20]; + v13 = &sr_508690[v21]; if ( LODWORD(v29) != 3 ) { - v11 = array_508690; - v13 = (RenderVertexSoft *)((char *)array_508690 + 16 * (3 * v1 - 3)); - v12 = &array_508690[1]; - v28 = array_508690[1].vWorldPosition.x - array_508690[0].vWorldPosition.x; - v27 = array_508690[1].vWorldPosition.y - array_508690[0].vWorldPosition.y; - v29 = array_508690[1].vWorldPosition.z - array_508690[0].vWorldPosition.z; - v26 = v13->vWorldPosition.x - array_508690[0].vWorldPosition.x; - v25 = v13->vWorldPosition.y - array_508690[0].vWorldPosition.y; - v24 = v13->vWorldPosition.z - array_508690[0].vWorldPosition.z; + v11 = sr_508690; + v13 = (RenderVertexSoft *)((char *)sr_508690 + 16 * (3 * v1 - 3)); + v12 = &sr_508690[1]; + v28 = sr_508690[1].vWorldPosition.x - sr_508690[0].vWorldPosition.x; + v27 = sr_508690[1].vWorldPosition.y - sr_508690[0].vWorldPosition.y; + v29 = sr_508690[1].vWorldPosition.z - sr_508690[0].vWorldPosition.z; + v26 = v13->vWorldPosition.x - sr_508690[0].vWorldPosition.x; + v25 = v13->vWorldPosition.y - sr_508690[0].vWorldPosition.y; + v24 = v13->vWorldPosition.z - sr_508690[0].vWorldPosition.z; if ( v24 * v27 - v25 * v29 == 0.0 ) { if ( v26 * v29 - v24 * v28 == 0.0 ) @@ -793,12 +793,12 @@ LODWORD(v26) = v14; if ( v14 >= 2 ) { - v15 = &array_508690[v14]; + v15 = &sr_508690[v14]; do { - v16 = v15->vWorldPosition.x - array_508690[0].vWorldPosition.x; - v17 = v15->vWorldPosition.y - array_508690[0].vWorldPosition.y; - v18 = v15->vWorldPosition.z - array_508690[0].vWorldPosition.z; + v16 = v15->vWorldPosition.x - sr_508690[0].vWorldPosition.x; + v17 = v15->vWorldPosition.y - sr_508690[0].vWorldPosition.y; + v18 = v15->vWorldPosition.z - sr_508690[0].vWorldPosition.z; v13 = v15; if ( v27 * v18 - v17 * v29 != 0.0 ) break; @@ -880,7 +880,7 @@ v5 = 0; if ( (signed int)a3->uNumVertices > 0 ) { - v6 = (char *)&array_508690[0].vWorldViewProjY; + v6 = (char *)&sr_508690[0].vWorldViewProjY; do { v7 = *((float *)v6 - 1) + 6.7553994e15; @@ -1587,7 +1587,7 @@ v39 = 0; if ( (signed int)v12->uNumVertices > 0 ) { - v40 = (char *)&array_508690[0].vWorldViewProjY; + v40 = (char *)&sr_508690[0].vWorldViewProjY; do { LODWORD(v64) = *((int *)v40 - 1); @@ -1615,7 +1615,7 @@ v46 = 0; if ( (signed int)v12->uNumVertices > 0 ) { - v47 = (char *)&array_508690[0].vWorldViewProjY; + v47 = (char *)&sr_508690[0].vWorldViewProjY; do { LODWORD(v61) = *((int *)v47 - 1); @@ -1646,7 +1646,7 @@ v51 = 0; if ( (signed int)v12->uNumVertices > 0 ) { - v52 = (char *)&array_508690[0].vWorldViewProjY; + v52 = (char *)&sr_508690[0].vWorldViewProjY; do { LODWORD(v62) = *((int *)v52 - 1); @@ -1663,7 +1663,7 @@ } } } - sr_sub_486B4E_push_outdoor_edges(array_508690, dword_50B638.data(), dword_50B570.data(), v12); + sr_sub_486B4E_push_outdoor_edges(sr_508690, dword_50B638.data(), dword_50B570.data(), v12); } LABEL_72: ++v79; @@ -1677,6 +1677,104 @@ return result; } +//----- (0047BC6F) -------------------------------------------------------- +unsigned __int16 *__fastcall sr_GetBillboardPalette(RenderBillboard *a1, int a2, signed int a3, int a4) +{ + int v4; // ebx@1 + int v6; // edx@4 + int v7; // ecx@5 + signed int v8; // eax@6 + signed __int64 v9; // qtt@11 + signed int v10; // eax@12 + int v11; // esi@17 + signed __int64 v12; // qtt@19 + double v13; // ST10_8@19 + int v14; // edi@25 + signed int v15; // edx@26 + signed __int64 v16; // qtt@29 + signed int v17; // eax@30 + int v18; // [sp+10h] [bp-8h]@1 + float a3a; // [sp+20h] [bp+8h]@19 + + v4 = a2; + v18 = a2; + if ( pParty->armageddon_timer ) + return PaletteManager::Get(a2); + if ( !pWeather->bNight ) + { + if (day_attrib & DAY_ATTRIB_FOG) + { + v14 = day_fogrange_1 << 16; + if ( a3 >= day_fogrange_1 << 16 ) + { + if ( a3 <= day_fogrange_2 << 16 ) + { + LODWORD(v16) = (a3 - v14) << 16; + HIDWORD(v16) = (a3 - v14) >> 16; + v15 = (unsigned __int64)(27 * v16 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16; + } + else + { + v15 = 27; + } + } + else + { + v15 = 0; + } + v17 = _43F55F_get_billboard_light_level(a1, v15); + if ( v17 > 27 ) + v17 = 27; + if ( !a3 ) + v17 = 27; + v7 = v18; + v6 = v17; + return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); + } + v11 = a4; + if ( a4 < 0 ) + v11 = 0; + LODWORD(v12) = a3 << 16; + HIDWORD(v12) = a3 >> 16; + a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20) + * pOutdoor->fFogDensity; + v13 = a3a + 6.7553994e15; + v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11); + if ( v10 > 27 ) + v10 = 27; + if ( v10 < a4 ) + v10 = a4; + if ( v10 > pOutdoor->max_terrain_dimming_level ) + v10 = pOutdoor->max_terrain_dimming_level; + return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); + } + v6 = 0; + if (pWeather->bNight) + { + v8 = 67108864; + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) + v8 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower << 26; + if ( a3 <= v8 ) + { + if ( a3 > 0 ) + { + LODWORD(v9) = a3 << 16; + HIDWORD(v9) = a3 >> 16; + v6 = (unsigned __int64)(27 * v9 / v8) >> 16; + } + } + else + { + v6 = 27; + } + v10 = _43F55F_get_billboard_light_level(a1, v6); + if ( v10 > 27 || !a3 ) + v10 = 27; + return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); + } + v7 = 0; + return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); +} //----- (00487389) -------------------------------------------------------- void Render::ExecOutdoorDrawSW() { @@ -3649,6 +3747,87 @@ return result; } +//----- (0047F4D3) -------------------------------------------------------- +void __fastcall _47F4D3_initialize_terrain_bezier_stuff(int band1, int band2, int band3) +{ + int v3; // edi@1 + //stru220 *v4; // esi@1 + double v5; // ST2C_8@3 + double v6; // st7@3 + //double v7; // [sp+18h] [bp-28h]@3 + //double v8; // [sp+20h] [bp-20h]@2 + int v9; // [sp+34h] [bp-Ch]@1 + int v10; // [sp+38h] [bp-8h]@1 + //signed int band3a; // [sp+48h] [bp+8h]@2 + + v9 = band2 * 512; + pOutdoorCamera->outdoor_grid_band_3 = band3; + v10 = band1 * 512; + v3 = band3 * 512; + pOutdoorCamera->uPickDepth = band3 * 512; + //v4 = terrain_76E5C8; // v4: 0 -> 65536 + for (uint i = 0; i < 16384; ++i) + //do + { + auto v4 = terrain_76E5C8[i]; + //band3a = 256; + //v8 = (double)(signed int)((char *)v4 + 256 - (int)terrain_76E5C8); + for (uint j = 0; j < 128; ++j) // band3a: 0 -> 128 + { + v5 = pow(j * 512 + 256, 2.0); + v6 = pow(i * 4 + 256, 2.0); + //*((float *)&v5 + 1) = sqrt(v6 + v5); + int v7 = floorf(sqrtf(v5 + v6) + 0.5f);//*((float *)&v5 + 1) + 6.7553994e15; + if (v7 >= v10) + { + if (v7 >= v9) + v4.field_0 = ((v7 >= v3) - 1) & 2; + else + v4.field_0 = 2; + } + else + { + v4.field_0 = 1; + } + //band3a += 512; + v4.distance = v7; + //++v4; + } + //while ( band3a < 65792 ); + } + //while ( (signed int)v4 < (signed int)arary_77E5C8 ); +} + +//----- (00481EFA) -------------------------------------------------------- +bool __fastcall _481EFA_clip_terrain_poly(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5) +{ + RenderVertexSoft *v5; // esi@1 + RenderVertexSoft *v6; // edx@1 + bool v7; // edi@2 + bool v8; // ecx@5 + bool v9; // esi@8 + bool v10; // eax@11 + double v11; // st7@14 + signed int v12; // esi@15 + signed int v13; // edx@18 + signed int v14; // ecx@21 + signed int v15; // eax@24 + RenderVertexSoft *v17; // [sp+Ch] [bp-8h]@1 + + v5 = a2; + v6 = a1; + v17 = v5; + v7 = a1->vWorldViewPosition.x < 8.0; + v8 = v5->vWorldViewPosition.x < 8.0; + v9 = a3->vWorldViewPosition.x < 8.0; + v10 = a4->vWorldViewPosition.x < 8.0; + return !(v8 & v9 & v10 & v7) + && ((v11 = (double)pOutdoorCamera->shading_dist_mist, v11 > v6->vWorldViewPosition.x) ? (v12 = 0) : (v12 = 1), + v11 > v17->vWorldViewPosition.x ? (v13 = 0) : (v13 = 1), + v11 > a3->vWorldViewPosition.x ? (v14 = 0) : (v14 = 1), + v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1), + !(v13 & v14 & v15 & v12)); +} //----- (00481212) -------------------------------------------------------- void Render::DrawTerrainSW(int a1, int a2, int a3, int a4) { @@ -3779,7 +3958,7 @@ v7 = abs(X); v8 = abs(v86); --X; - v92 = &stru_76E5C8[(v7 << 7) + v8]; + v92 = &terrain_76E5C8[(v7 << 7) + v8]; if ( !v92->field_0 || ((v9 = v6, v10 = &pVerticesSR_806210[v6], v104 = v10, !v85) ? (v11 = &pVerticesSR_801A10[v9], v12 = &pVerticesSR_806210[v9 + 1]) : (v11 = &pVerticesSR_806210[v9 + 1], v12 = &pVerticesSR_801A10[v9]), @@ -3807,7 +3986,7 @@ WorldPosToGridCellZ(v100), !byte_4D864C) || !(pGame->uFlags & 0x80)) - && !sub_481EFA(v10, v11, v102, v103, 1)) ) + && !_481EFA_clip_terrain_poly(v10, v11, v102, v103, 1)) ) goto LABEL_105; if ( v10->vWorldPosition.z != v11->vWorldPosition.z || v11->vWorldPosition.z != v103->vWorldPosition.z @@ -3851,7 +4030,7 @@ if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; ++pOutdoorCamera->uNumPolygons; - if ( !sub_481FC9(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) ) + if ( !_481FC9_terrain(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) ) goto LABEL_104; v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); memcpy(array_50AC10, v104, 0x30u); @@ -3972,7 +4151,7 @@ if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; ++pOutdoorCamera->uNumPolygons; - if ( !sub_481FC9((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) ) + if ( !_481FC9_terrain((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) ) goto LABEL_74; v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); memcpy(array_50AC10, v104, 0x30u); @@ -4019,7 +4198,7 @@ { sr_sub_4829B9((RenderVertexSoft *)HIDWORD(v101), v52, v104, v38, 0); LABEL_68: - sr_sub_481DB2(array_508690, v54, v38); + sr_sub_481DB2(sr_508690, v54, v38); LABEL_75: v17 = &array_77EC08[pOutdoorCamera->uNumPolygons]; v57 = pOutdoor->GetTileTexture(v101, v100); @@ -4062,7 +4241,7 @@ if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; ++pOutdoorCamera->uNumPolygons; - if ( !sub_481FC9(v102, v104, v103, v17) ) + if ( !_481FC9_terrain(v102, v104, v103, v17) ) { LABEL_104: --pOutdoorCamera->uNumPolygons; @@ -4122,7 +4301,7 @@ LABEL_37: sr_sub_4829B9(v35, v34, v67, v68, v69); LABEL_38: - sr_sub_481DB2(array_508690, v33, v17); + sr_sub_481DB2(sr_508690, v33, v17); goto LABEL_105; } goto LABEL_74; @@ -4147,12 +4326,43 @@ } } +//----- (00481FC9) -------------------------------------------------------- +int __fastcall _481FC9_terrain(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4)//Rotate camera +{ + float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14; + + if (a1->vWorldPosition.y == a2->vWorldPosition.y && a2->vWorldPosition.y == a3->vWorldPosition.y) + a4->flags |= 0x10; + var_c = a1->vWorldViewPosition.x - a2->vWorldViewPosition.x; + var_14 = a1->vWorldViewPosition.y - a2->vWorldViewPosition.y; + arg_0 = a1->vWorldViewPosition.z - a2->vWorldViewPosition.z; + var_10 = a3->vWorldViewPosition.x - a2->vWorldViewPosition.x; + var_8 = a3->vWorldViewPosition.y - a2->vWorldViewPosition.y; + var_4 = a3->vWorldViewPosition.z - a2->vWorldViewPosition.z; + arg_4 = a3->vWorldPosition.y - a2->vWorldPosition.y; + if (((a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.x - a2->vWorldPosition.x) - (a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.y - a2->vWorldPosition.y)) * (pIndoorCamera->pos.y - a2->vWorldPosition.z) + + ((a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.y - a2->vWorldPosition.y) - (a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.z - a2->vWorldPosition.z)) * (pIndoorCamera->pos.x - a2->vWorldPosition.x) + + ((a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.z - a2->vWorldPosition.z) - (a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.x - a2->vWorldPosition.x)) * (pIndoorCamera->pos.z - a2->vWorldPosition.y) < 0) + { + arg_4 = var_4 * var_14 - var_8 * arg_0; + a4->v_18.x = floorf(arg_4 + 0.5f); + arg_4 = var_10 * arg_0 - var_4 * var_c; + a4->v_18.y = floorf(arg_4 + 0.5f); + arg_4 = var_8 * var_c - var_10 * var_14; + a4->v_18.z = floorf(arg_4 + 0.5f); + a4->_normalize_v_18(); + arg_4 = -(a4->v_18.x * a2->vWorldViewPosition.x) - a4->v_18.y * a2->vWorldViewPosition.y - a4->v_18.z * a2->vWorldViewPosition.z; + a4->field_24 = floorf(arg_4 + 0.5f); + return true; + } + else + return false; +} //----- (00438250) -------------------------------------------------------- void IndoorCameraD3D::sr_Reset_list_0037C() { this->list_0037C_size = 0; } - //----- (00438240) -------------------------------------------------------- void IndoorCameraD3D::sr_438240_draw_lits() { @@ -7841,7 +8051,7 @@ return v117; v127 = a1; v1 = a1; - memcpy(array_508690, array_50AC10, 4 * ((unsigned int)(48 * a1) >> 2)); + memcpy(sr_508690, array_50AC10, 4 * ((unsigned int)(48 * a1) >> 2)); v2 = 0; do { @@ -8140,12 +8350,12 @@ v62 = SLODWORD(v61) <= (signed int)pViewport->uViewportBR_Y, v123 < 1) ) goto LABEL_112; - v63 = (char *)&array_508690[0].vWorldViewProjX; - v131 = array_508690; - v120 = (char *)&array_508690[0].vWorldViewProjX; - v140 = (char *)&array_508690[0].vWorldViewProjY; - v126 = (char *)&array_508690[0].flt_2C; - v135 = (char *)&array_508690[0]._rhw; + v63 = (char *)&sr_508690[0].vWorldViewProjX; + v131 = sr_508690; + v120 = (char *)&sr_508690[0].vWorldViewProjX; + v140 = (char *)&sr_508690[0].vWorldViewProjY; + v126 = (char *)&sr_508690[0].flt_2C; + v135 = (char *)&sr_508690[0]._rhw; v64 = (char *)&array_508FF0[0].flt_2C; v113 = v123; while ( 2 ) @@ -8227,10 +8437,10 @@ if ( v116 < 3 ) goto LABEL_112; v80 = v116; - memcpy(&array_508690[v116], array_508690, sizeof(array_508690[v116])); + memcpy(&sr_508690[v116], sr_508690, sizeof(sr_508690[v116])); if ( v116 > 0 ) { - v81 = (char *)&array_508690[0].vWorldViewProjX; + v81 = (char *)&sr_508690[0].vWorldViewProjX; v82 = v116; do { @@ -8274,7 +8484,7 @@ v90 = v116 - 3 < 0; if ( v116 > 3 ) { - memcpy(&array_508690[v116 + 1], &array_508690[1], sizeof(array_508690[v116 + 1])); + memcpy(&sr_508690[v116 + 1], &sr_508690[1], sizeof(sr_508690[v116 + 1])); if ( v116 > 0 ) { v105 = 1; @@ -8290,10 +8500,10 @@ v92 = v105 - v80; if ( v94 >= v80 ) v95 = v94 - v80; - if ( (array_508690[v92].vWorldViewProjX - array_508690[v93].vWorldViewProjX) - * (array_508690[v95].vWorldViewProjY - array_508690[v93].vWorldViewProjY) - - (array_508690[v95].vWorldViewProjX - array_508690[v93].vWorldViewProjX) - * (array_508690[v92].vWorldViewProjY - array_508690[v93].vWorldViewProjY) < 0.0 ) + if ( (sr_508690[v92].vWorldViewProjX - sr_508690[v93].vWorldViewProjX) + * (sr_508690[v95].vWorldViewProjY - sr_508690[v93].vWorldViewProjY) + - (sr_508690[v95].vWorldViewProjX - sr_508690[v93].vWorldViewProjX) + * (sr_508690[v92].vWorldViewProjY - sr_508690[v93].vWorldViewProjY) < 0.0 ) { ++v105; } @@ -8301,7 +8511,7 @@ { v96 = v105; if ( v105 < v80 || (v96 = v105 - v80, v105 - v80 < v80) ) - memcpy(&array_508690[v96], &array_508690[v96 + 1], 4 * ((unsigned int)(48 * v80 - 48 * v96) >> 2)); + memcpy(&sr_508690[v96], &sr_508690[v96 + 1], 4 * ((unsigned int)(48 * v80 - 48 * v96) >> 2)); --v80; } } @@ -8318,7 +8528,589 @@ return result; } - +//----- (0048034E) -------------------------------------------------------- +void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4) +{ + //int v3; // esi@1 + int v4; // edi@1 + int v5; // ebx@2 + int v6; // eax@2 + int v7; // eax@3 + RenderVertexSoft *v8; // edi@3 + RenderVertexSoft *v9; // ebx@4 + RenderVertexSoft *v10; // ecx@4 + float v11; // eax@6 + double v12; // ST5C_8@6 + double v13; // ST2C_8@6 + int v14; // eax@6 + double v15; // st7@6 + struct Polygon *pTile; // ebx@12 + unsigned __int16 v17; // ax@12 + int v18; // eax@13 + signed int v22; // eax@13 + Vec3_float_ *norm; // eax@15 + //double v24; // st6@17 + double v25; // ST54_8@17 + unsigned __int8 v26; // sf@17 + unsigned __int8 v27; // of@17 + double v28; // st5@19 + double v29; // st5@19 + double v30; // st5@19 + double v31; // st5@19 + struct struct8 *v32; // esi@21 + double v3a; // st7@32 + int v33; // edi@38 + unsigned int v34; // ecx@47 + char v35; // zf@47 + unsigned int v36; // eax@50 + int v37; // eax@54 + //Polygon *v38; // ecx@55 + unsigned int v39; // eax@59 + struct Polygon *v40; // ebx@62 + unsigned __int16 pTileBitmapsID; // ax@62 + int v42; // eax@63 + LightmapBuilder *v43; // ecx@63 + int v44; // eax@63 + int v45; // eax@63 + int v46; // eax@63 + signed int v47; // eax@63 + Vec3_float_ *v48; // eax@65 + double v49; // st6@67 + double v50; // ST4C_8@67 + double v51; // st5@71 + double v52; // st5@71 + double v53; // st5@71 + double v54; // st7@84 + unsigned int v55; // ecx@98 + unsigned int v56; // eax@101 + int v57; // eax@105 + unsigned int v58; // eax@109 + struct Polygon *v59; // esi@112 + unsigned __int16 v60; // ax@112 + int v61; // eax@113 + signed int v62; // eax@113 + Vec3_float_ *v63; // eax@114 + double v64; // st6@116 + double v65; // ST3C_8@116 + double v66; // st5@120 + double v67; // st5@120 + double v68; // st5@120 + double v69; // st7@133 + int v70; // edi@138 + struct Polygon *v71; // esi@147 + unsigned int v72; // ecx@147 + unsigned int v73; // eax@150 + int v74; // eax@154 + unsigned int v75; // eax@158 + //unsigned int v76; // [sp-10h] [bp-E0h]@61 + int v77; // [sp-Ch] [bp-DCh]@61 + IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 + //int v79; // [sp-4h] [bp-D4h]@61 + bool v80; // [sp+0h] [bp-D0h]@59 + bool v81; // [sp+0h] [bp-D0h]@109 + int v82; // [sp+54h] [bp-7Ch]@1 + int v83; // [sp+60h] [bp-70h]@1 + int v84; // [sp+6Ch] [bp-64h]@1 + int v85; // [sp+70h] [bp-60h]@63 + float a4; // [sp+74h] [bp-5Ch]@73 + float v87; // [sp+78h] [bp-58h]@122 + int v88; // [sp+7Ch] [bp-54h]@1 + int v89; // [sp+80h] [bp-50h]@6 + int v93; // [sp+90h] [bp-40h]@2 + int X; // [sp+94h] [bp-3Ch]@1 + float v95; // [sp+98h] [bp-38h]@21 + LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 + int v97; // [sp+A0h] [bp-30h]@6 + int sX; // [sp+A4h] [bp-2Ch]@6 + unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 + int v100; // [sp+ACh] [bp-24h]@122 + int sY; // [sp+B0h] [bp-20h]@6 + RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 + unsigned int a5; // [sp+B8h] [bp-18h]@21 + RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 + Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 + RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 + RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 + char v108; // [sp+CFh] [bp-1h]@36 + float thisd; // [sp+D8h] [bp+8h]@6 + float thise; // [sp+D8h] [bp+8h]@6 + float thisf; // [sp+D8h] [bp+8h]@17 + IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 + float thisg; // [sp+D8h] [bp+8h]@67 + IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 + float thish; // [sp+D8h] [bp+8h]@116 + IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 + char this_3; // [sp+DBh] [bp+Bh]@30 + char this_3a; // [sp+DBh] [bp+Bh]@82 + char this_3b; // [sp+DBh] [bp+Bh]@131 + + __debugbreak(); + static stru154 static_sub_0048034E_stru_154; + static stru154 stru_76D5A8; + //v3 = a1; + v82 = a2; + v83 = a3; + X = abs(unk4); + v4 = 0; + v88 = 0; + v84 = a1 - 1; + if ( a1 - 1 > 0 ) + { + while ( 1 ) + { + v5 = abs(X);//v5 = 13108 + v6 = abs(v83);//v6 = 13108 + --X; + //__debugbreak(); // uncoment & refactor following large if + v93 = (int)&terrain_76E5C8[(v5 << 7) + v6]; + if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), + v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), + ((a8 = v9, + pVertices = &pVerticesSR_801A10[1] + v7, + v11 = v8->vWorldPosition.x, + v101 = v10, + v12 = v11 + 6.755399441055744e15, + sX = LODWORD(v12), + v13 = v8->vWorldPosition.y + 6.755399441055744e15, + sY = LODWORD(v13), + thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, + v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X + v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, + v89 = v14, + thise = v15 * 0.5, + _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z + WorldPosToGridCellX(sX), + WorldPosToGridCellZ(sY), + !byte_4D864C) + || !(pGame->uFlags & 0x80)) + && !_481EFA_clip_terrain_poly(v8, v9, v101, pVertices, 1)) ) + if ( !&terrain_76E5C8[(v5 << 7) + v6] ) + goto LABEL_162 + v8 = &pVerticesSR_806210[v4]; + //pVertices2 = &pVerticesSR_801A10[v4 + 1]; + //v102 = v8; + if (!v82) + { + pVertices = &pVerticesSR_801A10[v4]; + v101 = &pVerticesSR_806210[v4 + 1]; + } + else + { + pVertices = &pVerticesSR_801A10[v4 + 1]; + v101 = &pVerticesSR_806210[v4]; + } + sX = floorf(v8->vWorldPosition.x + 0.5f); + sY = floorf(v8->vWorldPosition.z + 0.5f); + v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); + v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); + /*WorldPosToGridCellX(sX); + WorldPosToGridCellZ(sY); + if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !_481EFA_clip_terrain_poly(v8, pVertices, v101, pVertices2, 1)) + if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y + || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) + break; + pTile = &array_77EC08[pOutdoorCamera->uNumPolygons]; + pTile->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( pTile->uTileBitmapID != -1 ) + { + pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); + pTile->field_32 = 0; + pTile->field_59 = 1; + pTile->terrain_grid_x = (char)v97; + __debugbreak(); // warning C4700: uninitialized local variable 'v93' used + pTile->field_34 = *(_WORD *)(v93 + 2); + pTile->terrain_grid_z = v89; + v22 = pTerrainNormalIndices[2 * (v97 + 128 * v89) + 1]; + if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) + norm = 0; + else + norm = &pTerrainNormals[v22]; + thisf = 20.0 - ( -(((float)pOutdoor->vSunlight.x / 65536.0) * norm->x) - + (((float)pOutdoor->vSunlight.y / 65536.0) * norm->y) - + (((float)pOutdoor->vSunlight.z / 65536.0) * norm->z)) * 20.0; + //v25 = thisf + 6.7553994e15; + //v27 = pOutdoorCamera->uNumPolygons > 1999; + //v26 = pOutdoorCamera->uNumPolygons - 1999 < 0; + pTile->dimming_level = floorf(thisf + 0.5f); + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + //if ( !_481FC9_terrain(v8, pVertices, v101, v16) )//Ritor1: It's temporary + //goto LABEL_126; + //{ + //--pOutdoorCamera->uNumPolygons; + //goto LABEL_162; + //} + __debugbreak(); // warning C4700: uninitialized local variable 'v102' used + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + __debugbreak(); // warning C4700: uninitialized local variable 'pVertices2' used + memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); + array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[3].u = 1.0; + array_50AC10[3].v = 0.0; + if ( !(byte_76D5C0 & 1) ) + { + byte_76D5C0 |= 1u; + stru154(stru_76D5A8); + atexit(loc_481199); + } + v32 = (struct8 *)array_50AC10; + v97 = (int)pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &v95, array_50AC10, 4, 1); + pDecalBuilder->_49BE8A(pTile, norm, &v95, array_50AC10, 4, 1); + a5 = 4; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisa = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) + goto LABEL_162; + thisa->ViewTransform(array_50AC10, a5); + thisa->Project(array_50AC10, a5, 0); + } + this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 + || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; + v3a = (double)pOutdoorCamera->shading_dist_mist; + v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x + || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; + v33 = 0; + pGame->pLightmapBuilder->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3 ) + v33 = 3; + else + v33 = v108 != 0 ? 5 : 0; + static_sub_0048034E_stru_154.ClassifyPolygon(norm, v95); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - pTile->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); + v34 = a5; + //v35 = byte_4D864C == 0; + pTile->uNumVertices = a5; + if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) + { + if ( this_3 ) + { + v36 = sr_424CD7(v34); + pTile->uNumVertices = v36; + OutdoorCamera::Project(v36); + } + if ( v108 ) + { + v36 = sr_424EE0_MakeFanFromTriangle(v34); + pTile->uNumVertices = v36; + OutdoorCamera::Project(v36); + } + } + //v37 = *(int *)&v16->flags; + if ( ~pTile->flags & 1 ) + { + if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v80 = false; + v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v39 = pTile->uTileBitmapID; + v80 = true; + } + //v79 = 0; + //v78 = pBitmaps_LOD->pHardwareTextures[v39]; + pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary + v77 = (int)pTile; + //v76 = v16->uNumVertices; +//LABEL_161: + pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v39], false, v80); + goto LABEL_162; + } +LABEL_56: + pTile->DrawBorderTiles(); + } +LABEL_162: + v4 = v88 + 1; + if ( ++v88 >= v84 ) + return; + } + v40 = &array_77EC08[pOutdoorCamera->uNumPolygons]; + v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( v40->uTileBitmapID == -1 ) + goto LABEL_162; + v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); + BYTE1(v42) |= 0x80u; + v43 = pGame->pLightmapBuilder; + *(int *)&v40->flags = v42; + v44 = v93; + v40->field_59 = 1; + v40->terrain_grid_x = (char)v43; + v40->field_34 = *(_WORD *)(v44 + 2); + v45 = v89; + v40->terrain_grid_z = v89; + v46 = 4 * ((char)v43 + (v45 << 7)); + v85 = v46; + v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; + if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) + v48 = 0; + else + v48 = &pTerrainNormals[v47]; + v49 = v92 * v48->y; + //v99 = v48; + thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; + v50 = thisg + 6.755399441055744e15; + v40->dimming_level = LOBYTE(v50); + if ( LOBYTE(v50) < 0 ) + v40->dimming_level = 0; + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + if ( !_481FC9_terrain(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary + //goto LABEL_77; + { + --pOutdoorCamera->uNumPolygons; + goto LABEL_112; + } + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + static stru154 static_sub_0048034E_stru_76D590; + static bool __init_flag2 = false; + if (!__init_flag2) + { + __init_flag2 = true; + stru154::stru154(&static_sub_0048034E_stru_76D590); + } + if ( !(byte_76D5C0 & 2) ) + { + byte_76D5C0 |= 2; + Polygon(stru_76D590); + atexit(loc_48118F); + } + v96 = pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); + pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); + uNumVertices = 3; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisb = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) + { +//LABEL_77: + --pOutdoorCamera->uNumPolygons; + goto LABEL_112; + } + thisb->ViewTransform(array_50AC10, uNumVertices); + thisb->Project(array_50AC10, uNumVertices, 0); + } + this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; + v54 = (double)pOutdoorCamera->shading_dist_mist; + v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; + pVertices = 0; + v96->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3a ) + pVertices = (RenderVertexSoft *)3; + else + pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); + //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); + static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); + v55 = uNumVertices; + //v35 = byte_4D864C == 0; + v40->uNumVertices = uNumVertices; + if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) + { + if ( this_3a ) + { + v56 = sr_424CD7(v55); + } + else + { + if ( !v108 ) + goto LABEL_105; + v56 = sr_424EE0_MakeFanFromTriangle(v55); + } + v40->uNumVertices = v56; + OutdoorCamera::Project(v56); + } +LABEL_105: + v57 = *(int *)&v40->flags; + if ( BYTE1(v57) & 1 ) + { + v40->DrawBorderTiles(); + } + else + { + if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v81 = false; + v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v58 = v40->uTileBitmapID; + v81 = true; + } + pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); + } +LABEL_112: + v59 = &array_77EC08[pOutdoorCamera->uNumPolygons]; + //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->uNumPolygons]; + v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( v59->uTileBitmapID == -1 ) + goto LABEL_162; + *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); + v61 = v93; + v59->field_59 = 1; + v59->field_34 = *(_WORD *)(v61 + 2); + v59->terrain_grid_z = v89; + v59->terrain_grid_x = v97; + v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); + if ( v62 > (signed int)(uNumTerrainNormals - 1) ) + v63 = 0; + else + v63 = &pTerrainNormals[v62]; + v64 = v92 * v63->y; + //v99 = v63; + thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; + v59->dimming_level = floorf(thish + 0.5f); + if ( v59->dimming_level < 0 ) + v59->dimming_level = 0; + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + if ( !_481FC9_terrain(v101, v102, pVertices2, v59) ) + { +//LABEL_126: + --pOutdoorCamera->uNumPolygons; + goto LABEL_162; + } + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1].u = 1.0; + array_50AC10[1].v = 1.0; + memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 0.0; + static stru154 static_sub_0048034E_stru_76D578; + static bool __init_flag1 = false; + if (!__init_flag1) + { + __init_flag1 = true; + stru154::stru154(&static_sub_0048034E_stru_76D578); + } + v96 = pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); + pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1); + v100 = 3; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisc = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) + //goto LABEL_126; + { + --pOutdoorCamera->uNumPolygons; + goto LABEL_162; + } + thisc->ViewTransform(array_50AC10, v100); + thisc->Project(array_50AC10, v100, 0); + } + this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 + || v101->vWorldViewPosition.x < 8.0; + v69 = (double)pOutdoorCamera->shading_dist_mist; + v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; + v70 = 0; + v96->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3b ) + v70 = 3; + else + v70 = v108 != 0 ? 5 : 0; + static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); + v71 = v59; + v72 = v100; + //v35 = byte_4D864C == 0; + v59->uNumVertices = v100;//??? + if ( !byte_4D864C && pGame->uFlags & 0x80 ) + goto LABEL_154; + if ( this_3b ) + { + v73 = sr_424CD7(v72); + } + else + { + if ( !v108 ) + { +LABEL_154: + v74 = v71->flags; + if ( !(BYTE1(v74) & 1) ) + { + if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v80 = false; + v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v75 = v71->uTileBitmapID; + v80 = true; + } + //v79 = 0; + v78 = pBitmaps_LOD->pHardwareTextures[v75]; + v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary + //v77 = (int)v71; + //v76 = v71->uNumVertices; + //goto LABEL_161; + pRenderer->DrawTerrainPolygon(v71->uNumVertices, (Polygon *)v71, v78, 0, v80); + goto LABEL_162; + } + v38 = (Polygon *)v71; + goto LABEL_56; + } + v73 = sr_424EE0_MakeFanFromTriangle(v72); + } + v71->uNumVertices = v73; + OutdoorCamera::Project(v73); + goto LABEL_154; + } + } //----- (00424579) -------------------------------------------------------- int __fastcall sr_424579(int uFaceID, stru320 *a2) {
--- a/mm7_1.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/mm7_1.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -135,34 +135,6 @@ a1->DrawText(a2, 32, uY, 0, pTmpBuf.data(), 0, 0, 0); } -//----- (0042038D) -------------------------------------------------------- -void __cdecl sub_42038D() -{ - POINT *v0; // esi@2 - int v1; // ecx@2 - const char *v2; // eax@3 - POINT v3; // [sp+0h] [bp-10h]@2 - POINT a2; // [sp+8h] [bp-8h]@1 - - __debugbreak(); // invalid indexing - if ( pMouse->GetCursorPos(&a2)->y < 350 ) - { - v0 = pMouse->GetCursorPos(&a2); - v1 = pRenderer->pActiveZBuffer[v0->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v3)->y]]; - if ( v1 ) - { - auto _w = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C - + 18 * *((short *)&pChests[0].igChestItems[139].uExpireTime - + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); - - _w = (ItemGen *)(&pChests[(unsigned int)pChestWindow->ptr_1C] -32 - + 18 * *((short *)&pChests[(unsigned int)pChestWindow->ptr_1C].igChestItems[139].uExpireTime + v1 + 3)); - v2 = _w->GetDisplayName(); - GameUI_SetFooterString(v2); - } - } -} - //----- (004226C2) -------------------------------------------------------- bool PauseGameDrawing() { @@ -434,78 +406,14 @@ - - -//----- (00423AEE) -------------------------------------------------------- -void __cdecl reset_some_strus_flt_2Cs() +//----- (00424CD7) -------------------------------------------------------- +int sr_424CD7(unsigned int num_vertices) { - float *v0; // eax@1 - signed int v1; // ecx@1 - signed int v2; // edx@1 - float *v3; // eax@3 - signed int v4; // edx@3 - float *v5; // eax@5 - signed int v6; // edx@5 - float *v7; // eax@7 - signed int v8; // edx@7 - float *v9; // eax@9 - - v0 = &array_50AC10[0].flt_2C; - v1 = 50; - v2 = 50; - do - { - *v0 = 0.0; - v0 += 12; - --v2; - } - while ( v2 ); - v3 = &array_50A2B0[0].flt_2C; - v4 = 50; - do - { - *v3 = 0.0; - v3 += 12; - --v4; - } - while ( v4 ); - v5 = &array_509950[0].flt_2C; - v6 = 50; - do - { - *v5 = 0.0; - v5 += 12; - --v6; - } - while ( v6 ); - v7 = &array_508FF0[0].flt_2C; - v8 = 50; - do - { - *v7 = 0.0; - v7 += 12; - --v8; - } - while ( v8 ); - v9 = &array_508690[0].flt_2C; - do - { - *v9 = 0.0; - v9 += 12; - --v1; - } - while ( v1 ); -} - - -//----- (00424CD7) -------------------------------------------------------- -signed int __fastcall sr_424CD7(unsigned int uVertexID) -{ - unsigned int v1; // edx@1 + //unsigned int v1; // edx@1 signed int v2; // edi@1 char *v3; // esi@4 char *v4; // ecx@4 - unsigned int v5; // eax@4 + //unsigned int v5; // eax@4 char *v6; // edx@4 double v7; // st6@10 double v8; // st5@10 @@ -515,29 +423,30 @@ RenderVertexSoft *v12; // edi@22 char *v13; // eax@22 double v14; // st6@22 - signed int result; // eax@24 - unsigned int v16; // [sp+8h] [bp-28h]@4 + //signed int result; // eax@24 + //unsigned int v16; // [sp+8h] [bp-28h]@4 bool v17; // [sp+Ch] [bp-24h]@6 char *v18; // [sp+10h] [bp-20h]@4 char *v19; // [sp+14h] [bp-1Ch]@4 - signed int v20; // [sp+18h] [bp-18h]@1 + //signed int v20; // [sp+18h] [bp-18h]@1 RenderVertexSoft *v21; // [sp+1Ch] [bp-14h]@4 char *v22; // [sp+20h] [bp-10h]@4 char *v23; // [sp+24h] [bp-Ch]@4 char *v24; // [sp+28h] [bp-8h]@4 char *v25; // [sp+2Ch] [bp-4h]@4 + + if (!num_vertices) + return 0; - v1 = uVertexID; - memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID])); + //v1 = uVertexID; + memcpy(&array_50AC10[num_vertices], array_50AC10, sizeof(array_50AC10[0])); v2 = 0; - v20 = 0; + //v20 = 0; if ( array_50AC10[0].vWorldViewPosition.x >= 8.0 ) v2 = 1; - if ( (signed int)(uVertexID + 1) <= 1 ) - return 0; v3 = (char *)&array_507D30[0].vWorldViewPosition.z; v4 = (char *)&array_507D30[0].vWorldViewPosition.y; - v5 = v1; + //v5 = v1; v23 = (char *)&array_507D30[0]._rhw; v21 = array_507D30; v18 = (char *)&array_507D30[0].vWorldViewPosition.z; @@ -546,8 +455,10 @@ v24 = (char *)&array_507D30[0].v; v25 = (char *)&array_507D30[0].u; v6 = (char *)&array_50AC10[0].v; - v16 = v5; - do + //v16 = v1; + + int out_num_vertices = 0; + for (int i = 0; i < num_vertices; ++i) { v17 = *((float *)v6 + 5) >= 8.0; if ( v2 != v17 ) @@ -577,7 +488,19 @@ { v10 = 0; v11 = *(float *)v3 == *((float *)v6 - 5); - goto LABEL_19; + if ( ! (v11 | v10 ) ) + { + ++v21; + v22 += 48; + v24 += 48; + v25 += 48; + v4 += 48; + v3 += 48; + ++out_num_vertices; + v23 += 48; + v19 = v4; + v18 = v3; + } } } else @@ -586,25 +509,22 @@ { v10 = 0; v11 = *(float *)v3 == *((float *)v6 + 7); -LABEL_19: - if ( v11 | v10 ) - goto LABEL_21; - goto LABEL_20; + if ( ! (v11 | v10 ) ) + { + ++v21; + v22 += 48; + v24 += 48; + v25 += 48; + v4 += 48; + v3 += 48; + ++out_num_vertices; + v23 += 48; + v19 = v4; + v18 = v3; + } } } -LABEL_20: - ++v21; - v22 += 48; - v24 += 48; - v25 += 48; - v4 += 48; - v3 += 48; - ++v20; - v23 += 48; - v19 = v4; - v18 = v3; } -LABEL_21: if ( v17 ) { v12 = v21; @@ -612,7 +532,7 @@ v19 += 48; v18 += 48; v14 = 1.0 / (*((float *)v6 + 5) + 0.0000001); - ++v20; + ++out_num_vertices; v25 += 48; v24 += 48; v22 += 48; @@ -625,11 +545,7 @@ } v2 = v17; v6 += 48; - --v16; } - while ( v16 ); - result = v20; - if ( v20 < 3 ) - return 0; - return result; + + return out_num_vertices >= 3 ? out_num_vertices : 0; }
--- a/mm7_2.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/mm7_2.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -69,225 +69,153 @@ #include "Lights.h" //----- (004BB756) -------------------------------------------------------- -signed int __fastcall sub_4BB756(signed int a1) +int UseNPCSkill(NPCProf profession) { - unsigned int v1; // esi@8 - unsigned int v3; // ecx@10 - Player *v4; // esi@15 - int v5; // ebx@16 - int v6; // ST38_4@16 - Player *v7; // esi@18 - int v8; // ebx@19 - int v9; // ST30_4@19 - int v10; // ST44_4@19 - int v11; // ST48_4@19 - int v12; // ST4C_4@19 - int v13; // ST50_4@19 - int v14; // ST3C_4@19 - int v15; // ST40_4@19 - int v16; // ST34_4@19 - int v17; // ST38_4@19 - Player *v18; // esi@21 - int v19; // eax@26 - int v20; // eax@39 - SoundID v21; // [sp-20h] [bp-54h]@25 - signed int v22; // [sp-1Ch] [bp-50h]@25 - unsigned int v23; // [sp-18h] [bp-4Ch]@25 - signed int v24; // [sp-14h] [bp-48h]@25 - signed int v25; // [sp-10h] [bp-44h]@25 - int v26; // [sp-10h] [bp-44h]@32 - int v27; // [sp-Ch] [bp-40h]@25 - unsigned int v28; // [sp-Ch] [bp-40h]@32 - unsigned int v29; // [sp-8h] [bp-3Ch]@25 - __int16 v30; // [sp-8h] [bp-3Ch]@32 - int v31; // [sp-4h] [bp-38h]@25 - int v32; // [sp-4h] [bp-38h]@32 - - if ( a1 > 39 ) - { - if ( a1 != 40 ) + switch (profession) + { + case Healer: + { + for (int i = 0; i < 4; ++i) + pParty->pPlayers[i].sHealth = pParty->pPlayers[i].GetMaxHealth(); + } + break; + + case ExpertHealer: + { + for (int i = 0; i < 4; ++i) + { + auto player = &pParty->pPlayers[i]; + player->sHealth = player->GetMaxHealth(); + + for (int j = 0; j < 14; ++j) + player->pConditions[i] = 0; + player->pConditions[18] = 0; + } + } + break; + + case MasterHealer: { - if ( a1 == 41 ) + for (int i = 0; i < 4; ++i) { - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - dword_50C9DC = 195; - ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID); - return 0; + auto player = &pParty->pPlayers[i]; + player->sHealth = player->GetMaxHealth(); + + auto v5 = LODWORD(player->pConditions[19]);//*((int *)v4 - 32); + auto v6 = HIDWORD(player->pConditions[19]);//*((int *)v4 - 31); + memset(player->pConditions, 0, 0xA0u); + + __debugbreak(); + *(int *)&player->pActiveSkills[8] = v5; + *(int *)&player->pActiveSkills[10] = v6; } - if ( a1 == 42 ) + } + break; + + case Cook: + { + if (pParty->uNumFoodRations >= 13) + return 1; + + Party::GiveFood(1); + } + break; + + case Chef: + { + if (pParty->uNumFoodRations >= 13) + return 1; + + if (pParty->uNumFoodRations == 13) + Party::GiveFood(1); + else + Party::GiveFood(2); + } + break; + + case WindMaster: + { + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) { - v32 = 0; - v30 = 0; - v28 = 133; - v26 = 46; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); + pAudioPlayer->PlaySound(SOUND_203, 0, 0, -1, 0, 0, 0, 0); } else { - if ( a1 == 43 ) - { - v32 = 0; - v30 = 0; - v28 = 133; - v26 = 51; - } - else - { - if ( a1 != 52 ) - return 0; - v32 = 0; - v30 = 0; - v28 = 133; - v26 = 86; - } + auto v19 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); + pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + 60 * (256 * 2), 3, 1, v19, 0); + pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags |= 1u; + pAudioPlayer->PlaySound(SOUND_11090, 0, 0, -1, 0, 0, 0, 0); } - _42777D_CastSpell_UseWand_ShootArrow(v26, 0, v28, v30, v32); - return 0; } - v20 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); - pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + 46080, 3u, 0, v20, 0); - pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags |= 1u; - v31 = 0; - v29 = 0; - v27 = 0; - v25 = 0; - v24 = -1; - v23 = 0; - v22 = 0; - v21 = (SoundID)12040; -LABEL_40: - pAudioPlayer->PlaySound(v21, v22, v23, v24, v25, v27, v29, v31); - return 0; - } - if ( a1 == 39 ) - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + break; + + case WaterMaster: { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2u); - v31 = 0; - v29 = 0; - v27 = 0; - v25 = 0; - v24 = -1; - v23 = 0; - v22 = 0; - v21 = (SoundID)203; + auto v20 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + 60 * (256 * (2 + 1)), 3, 0, v20, 0); + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags |= 1u; + pAudioPlayer->PlaySound(SOUND_12040, 0, 0, -1, 0, 0, 0, 0); } - else + break; + + case GateMaster: { - v19 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); - pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + 30720, 3u, 1u, v19, 0); - pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags |= 1u; - v31 = 0; - v29 = 0; - v27 = 0; - v25 = 0; - v24 = -1; - v23 = 0; - v22 = 0; - v21 = (SoundID)11090; - } - pAudioPlayer->PlaySound(v21, v22, v23, v24, v25, v27, v29, v31); - return 0; - } - if ( a1 == 10 ) - { - v18 = pParty->pPlayers; - do - { - v18->sHealth = v18->GetMaxHealth(); - ++v18; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + dword_50C9DC = 195; + ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID); } - while ( (signed int)v18 < (signed int)pParty->pHirelings ); - return 0; - } - if ( a1 == 11 ) - { - v7 = pParty->pPlayers;//(char *)&pParty->pPlayers[0].pConditions[15]; - do - { - /*v8 = *((int *)v7 - 2); - v9 = *((int *)v7 - 1); - v10 = *(int *)v7; - v11 = *((int *)v7 + 1); - v12 = *((int *)v7 + 2); - v13 = *((int *)v7 + 3); - v14 = *((int *)v7 + 8); - v15 = *((int *)v7 + 9); - v16 = *((int *)v7 + 4); - v17 = *((int *)v7 + 5);*/ - v8 = LODWORD(v7->pConditions[14]); - v9 = HIDWORD(v7->pConditions[14]); - v10 = LODWORD(v7->pConditions[15]); - v11 = HIDWORD(v7->pConditions[15]); - v12 = LODWORD(v7->pConditions[16]); - v13 = HIDWORD(v7->pConditions[16]); - v14 = LODWORD(v7->pConditions[19]); - v15 = HIDWORD(v7->pConditions[19]); - v16 = LODWORD(v7->pConditions[17]); - v17 = HIDWORD(v7->pConditions[17]); - memset(v7, 0, 0xA0u); - LODWORD(v7->pConditions[16]) = v12; - HIDWORD(v7->pConditions[16]) = v13; - LODWORD(v7->pConditions[15]) = v10; - HIDWORD(v7->pConditions[15]) = v11; - HIDWORD(v7->pConditions[14]) = v9; - LODWORD(v7->pConditions[19]) = v14; - HIDWORD(v7->pConditions[19]) = v15; - LODWORD(v7->pConditions[17]) = v16; - LODWORD(v7->pConditions[14]) = v8; - HIDWORD(v7->pConditions[17]) = v17; - v7->sHealth = v7->GetMaxHealth(); - ++v7; - } - while ( v7 <= pPlayers[3] ); - return 0; - } - if ( a1 == 12 ) - { - v4 = pParty->pPlayers;//(char *)&pParty->pPlayers[0].pActiveSkills[8]; - do - { - v5 = LODWORD(v4->pConditions[19]);//*((int *)v4 - 32); - v6 = HIDWORD(v4->pConditions[19]);//*((int *)v4 - 31); - memset(v4->pConditions, 0, 0xA0u); - v4->pActiveSkills[8] = v5; - v4->pActiveSkills[10] = v6; - v4->sHealth = v4->GetMaxHealth(); - ++v4; - } - while ( v4 <= pPlayers[3] ); - return 0; - } - if ( a1 == 33 ) - { - v1 = 14; - if ( pParty->uNumFoodRations >= 0xE ) - return 1; - v3 = 1; -LABEL_13: - Party::GiveFood(v3); - if ( pParty->uNumFoodRations > v1 ) - pParty->uNumFoodRations = v1; - return 0; - } - if ( a1 == 34 ) - { - v1 = 14; - if ( pParty->uNumFoodRations >= 0xE ) - return 1; - v3 = 2; - goto LABEL_13; + break; + + case Acolyte: _42777D_CastSpell_UseWand_ShootArrow(46, 0, 133, 0, 0); break; + case Piper: _42777D_CastSpell_UseWand_ShootArrow(51, 0, 133, 0, 0); break; + case FallenWizard: _42777D_CastSpell_UseWand_ShootArrow(86, 0, 133, 0, 0); break; + + case Teacher: + case Instructor: + case Armsmaster: + case Weaponsmaster: + case Apprentice: + case Mystic: + case Spellmaster: + case Trader: + case Merchant: + case Scout: + case Herbalist: + case Apothecary: + case Tinker: + case Locksmith: + case Fool: + case ChimneySweep: + case Porter: + case QuarterMaster: + case Factor: + case Banker: + case Horseman: + case Bard: + case Enchanter: + case Cartographer: + case Explorer: + case Pirate: + case Squire: + case Psychic: + case Gypsy: + case Diplomat: + case Duper: + case Burglar: + case Acolyte2: + case Initiate: + case Prelate: + case Monk: + case Sage: + case Hunter: + break; + + default: + assert(false && "Invalid enum value"); } return 0; } -// 50C9DC: using guessed type int dword_50C9DC; //----- (004BBA85) -------------------------------------------------------- const char *sub_4BBA85_bounties() @@ -457,9 +385,6 @@ pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 1); } } -// F8B1B4: using guessed type int dword_F8B1B4; - -// 4EE088: using guessed type __int16 word_4EE088_sound_ids[]; //----- (004BC109) -------------------------------------------------------- void __cdecl ArenaFight() @@ -556,27 +481,28 @@ if ( uDialogueType == 85 ) { num_monsters = v4; - goto LABEL_22; - } - if ( uDialogueType == 86 ) + v4 /= 2; + } + else if ( uDialogueType == 86 ) { v5 = (signed __int64)((double)v26 * 1.5); - goto LABEL_20; - } - if ( uDialogueType == 87 ) + num_monsters = v5; + v4 /= 2; + } + else if ( uDialogueType == 87 ) { LODWORD(v5) = 2 * v4; -LABEL_20: num_monsters = v5; -LABEL_22: v4 /= 2; - goto LABEL_24; - } - if ( uDialogueType == 88 ) - num_monsters = 2 * v4; + } else - v4 = v27; -LABEL_24: + { + __debugbreak(); // warning C4700: uninitialized local variable 'v27' used + if ( uDialogueType == 88 ) + num_monsters = 2 * v4; + else + v4 = v27; + } if ( v4 < 1 ) v4 = 1; if ( v4 > 100 ) @@ -629,20 +555,20 @@ v16 = rand(); v17 = 3; v22 = 50; - goto LABEL_53; - } - if ( uDialogueType == 86 ) + v18 = v16 % v17; + v13 = v22; + v14 = v18 + 6; + } + else if ( uDialogueType == 86 ) { v16 = rand(); v17 = 7; v22 = 100; -LABEL_53: v18 = v16 % v17; v13 = v22; v14 = v18 + 6; - goto LABEL_55; - } - if ( uDialogueType == 87 ) + } + else if ( uDialogueType == 87 ) { v15 = rand() % 11; v13 = 200; @@ -661,7 +587,6 @@ v13 = gold_transaction_amount; } } -LABEL_55: i = 0; for ( gold_transaction_amount = v26 * v13; i < v14; ++i ) { @@ -705,7 +630,6 @@ if ( v0 == -1 ) { _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1)); -//LABEL_33: pVideoPlayer->_4BF5B2(); return 1; } @@ -715,29 +639,28 @@ { UI_CreateEndConversationButton(); dialog_menu_id = HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT; - sub_4B3AD4(in_current_building_type); + InitializaDialogueOptions_Shops(in_current_building_type); } else { if ( v0 != 102 && v0 != 103 && v0 != 104 ) { pVideoPlayer->_4BF5B2(); -//LABEL_28: dialog_menu_id = HOUSE_DIALOGUE_MAIN; - sub_4B3B42(in_current_building_type); + InitializaDialogueOptions(in_current_building_type); return 1; } pVideoPlayer->_4BF5B2(); UI_CreateEndConversationButton(); dialog_menu_id = HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN; - sub_4B3A72(in_current_building_type); + InitializaDialogueOptions_Tavern(in_current_building_type); } return 1; } pVideoPlayer->_4BF5B2(); UI_CreateEndConversationButton(); dialog_menu_id = HOUSE_DIALOGUE_MAIN; - sub_4B3B42(in_current_building_type); + InitializaDialogueOptions(in_current_building_type); return 1; } pDialogueNPCCount = 0; @@ -944,27 +867,21 @@ /*if ( (signed int)result < 40 ) { pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit; - goto LABEL_42; }*/ pMessageQueue_50CBD0->AddMessage(UIMSG_Quit, 1, 0); - goto LABEL_43; } else { pMessageQueue_50CBD0->AddMessage(UIMSG_ShowFinalWindow, 1, 0); - goto LABEL_43; /*if ( (signed int)result < 40 ) { pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5; -LABEL_42: pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; ++pMessageQueue_50CBD0->uNumMessages; - goto LABEL_43; }*/ } -LABEL_43: bGameoverLoop = 0; return result; } @@ -1179,19 +1096,25 @@ pTexture = pMapInfo->pEncounterMonster1Texture; v12 = v10 % (v11 - v9 + 1); v13 = pMapInfo->Dif_M1; - goto LABEL_20; + v57 = v13; + v56 = v9 + v12; + strcpy(Source, pTexture); + break; case 3u: pTexture = pMapInfo->pEncounterMonster1Texture; v44 = "%s A"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 4u: pTexture = pMapInfo->pEncounterMonster2Texture; v44 = "%s A"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 5u: pTexture = pMapInfo->pEncounterMonster3Texture; v44 = "%s A"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 1u: v9 = pMapInfo->uEncounterMonster2AtLeast; v14 = rand(); @@ -1199,19 +1122,25 @@ pTexture = pMapInfo->pEncounterMonster2Texture; v12 = v14 % (v15 - v9 + 1); v13 = pMapInfo->Dif_M2; - goto LABEL_20; + v57 = v13; + v56 = v9 + v12; + strcpy(Source, pTexture); + break; case 6u: pTexture = pMapInfo->pEncounterMonster1Texture; v44 = "%s B"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 7u: pTexture = pMapInfo->pEncounterMonster2Texture; v44 = "%s B"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 8u: pTexture = pMapInfo->pEncounterMonster3Texture; v44 = "%s B"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 2u: v9 = pMapInfo->uEncounterMonster3AtLeast; v16 = rand(); @@ -1219,50 +1148,49 @@ pTexture = pMapInfo->pEncounterMonster3Texture; v12 = v16 % (v17 - v9 + 1); v13 = pMapInfo->Dif_M3; -LABEL_20: v57 = v13; v56 = v9 + v12; strcpy(Source, pTexture); - goto LABEL_26; + break; case 9u: pTexture = pMapInfo->pEncounterMonster1Texture; v44 = "%s C"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 0xAu: pTexture = pMapInfo->pEncounterMonster2Texture; v44 = "%s C"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 0xBu: pTexture = pMapInfo->pEncounterMonster3Texture; v44 = "%s C"; -LABEL_25: sprintf(Source, v44, pTexture); -LABEL_26: - if (Source[0] == '0') - return; - v57 += a3; - if ( v57 > 4 ) - v57 = 4; - strcpy(Str2, Source); - if ( a4 ) - v56 = a4; - v18 = v56; - if ( (signed int)(v56 + uNumActors) >= 500 ) - return; - pSector = 0; - pPosX = spawn->vPosition.x; - a4 = spawn->vPosition.y; - a3 = spawn->vPosition.z; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z); - v53 = 0; - v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; - if ( v18 <= 0 ) - return; break; default: return; } + if (Source[0] == '0') + return; + v57 += a3; + if ( v57 > 4 ) + v57 = 4; + strcpy(Str2, Source); + if ( a4 ) + v56 = a4; + v18 = v56; + if ( (signed int)(v56 + uNumActors) >= 500 ) + return; + pSector = 0; + pPosX = spawn->vPosition.x; + a4 = spawn->vPosition.y; + a3 = spawn->vPosition.z; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z); + v53 = 0; + v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; + if ( v18 <= 0 ) + return; for (uint i = v53; i < v56; ++i) { pMonster = &pActors[uNumActors]; @@ -1296,7 +1224,7 @@ else { if ( v24 != 3 ) - goto LABEL_58; + continue; pTexture = Source; v44 = "%s C"; } @@ -1349,7 +1277,12 @@ v36 = spawn->vPosition.z; a3 = spawn->vPosition.z; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - goto LABEL_55; + { + if ( a5 ) + pMonster->uAttributes |= 0x080000; + ++uNumActors; + continue; + } v37 = pIndoor->GetSector(pPosX, a4, v36); if ( v37 == pSector ) { @@ -1360,15 +1293,13 @@ if ( abs(v38 - a3) <= 1024 ) { a3 = v39; -LABEL_55: if ( a5 ) pMonster->uAttributes |= 0x080000; ++uNumActors; - goto LABEL_58; + continue; } } } -LABEL_58: ; //v53 = (char *)v53 + 1; //result = v53; @@ -1511,7 +1442,7 @@ int v14; // edx@10 signed int v15; // ebx@20 unsigned __int16 v16; // dx@20 - char *v17; // ecx@21 + ObjectDesc *v17; // ecx@21 unsigned __int16 v18; // ax@24 int v19; // ST0C_4@27 int v20; // ST08_4@27 @@ -1519,7 +1450,7 @@ int v22; // eax@27 signed int v23; // ebx@29 unsigned __int16 v24; // dx@29 - char *v25; // ecx@30 + ObjectDesc *v25; // ecx@30 unsigned __int16 v26; // ax@33 //int v27; // ecx@35 //int v28; // eax@35 @@ -1561,97 +1492,75 @@ if ( a2->uIndex == 1 ) { v14 = rand() % 51 + 50; - } - else + a1a.stru_24.uItemID = 197; + v34 = v14; + } + else if ( a2->uIndex == 2 ) { - if ( a2->uIndex != 2 ) - { - if ( a2->uIndex == 3 ) + v14 = rand() % 101 + 100; + a1a.stru_24.uItemID = 197; + v34 = v14; + } + else if ( a2->uIndex == 3 ) { v14 = rand() % 301 + 200; + a1a.stru_24.uItemID = 198; + v34 = v14; } - else + else if ( a2->uIndex == 4 ) + { + v14 = rand() % 501 + 500; + a1a.stru_24.uItemID = 198; + v34 = v14; + } + else if ( a2->uIndex == 5 ) { - if ( a2->uIndex != 4 ) - { - if ( a2->uIndex == 5 ) - { - v14 = rand() % 1001 + 1000; - } - else + v14 = rand() % 1001 + 1000; + a1a.stru_24.uItemID = 199; + v34 = v14; + } + else if ( a2->uIndex == 6 ) + { + v14 = rand() % 3001 + 2000; + a1a.stru_24.uItemID = 199; + v34 = v14; + } + v15 = 0; + v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + v18 = 0; + for( int i = 0; i < pObjectList->uNumObjects; i++ ) { - if ( a2->uIndex != 6 ) - { -LABEL_20: - v15 = 0; - v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_24: - v18 = 0; - } - else - { - v17 = (char *)&pObjectList->pObjects->uObjectID; - while ( v16 != *(short *)v17 ) - { - ++v15; - v17 += 56; - if ( v15 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_24; - } - v18 = v15; - } - a1a.stru_24.SetIdentified(); - a1a.uObjectDescID = v18; - a1a.stru_24.uSpecEnchantmentType = v34; - goto LABEL_35; - } - v14 = rand() % 3001 + 2000; + if ( pObjectList->pObjects[i].uObjectID == v16 ) + { + v18 = i; + break; + } } - a1a.stru_24.uItemID = 199; -LABEL_19: - v34 = v14; - goto LABEL_20; - } - v14 = rand() % 501 + 500; - } - a1a.stru_24.uItemID = 198; - goto LABEL_19; - } - v14 = rand() % 101 + 100; - } - a1a.stru_24.uItemID = 197; - goto LABEL_19; - } - result = a1a.stru_24.GenerateArtifact(); - if ( !result ) - return result; - v23 = 0; - v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_33: - v26 = 0; + a1a.stru_24.SetIdentified(); + a1a.uObjectDescID = v18; + a1a.stru_24.uSpecEnchantmentType = v34; } else { - v25 = (char *)&pObjectList->pObjects->uObjectID; - while ( v24 != *(short *)v25 ) - { - ++v23; - v25 += 56; - if ( v23 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_33; - } - v26 = v23; - } - a1a.uObjectDescID = v26; - a1a.stru_24.Reset(); - -LABEL_35: + result = a1a.stru_24.GenerateArtifact(); + if ( !result ) + return result; + v23 = 0; + v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + v26 = 0; + for( int i = 0; i < pObjectList->uNumObjects; i++ ) + { + if( v24 == pObjectList->pObjects[i].uObjectID ) + { + v26 = i; + break; + } + } + a1a.uObjectDescID = v26; + a1a.stru_24.Reset(); + } a1a.vPosition.y = a2->vPosition.y; a1a.uAttributes = 0; a1a.uSoundID = 0; @@ -1685,23 +1594,15 @@ v8 = 0; v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; a1.uType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_5: - v11 = 0; - } - else - { - v10 = (char *)&pObjectList->pObjects->uObjectID; - while ( v9 != *(short *)v10 ) - { - ++v8; - v10 += 56; - if ( v8 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_5; - } - v11 = v8; - } + v11 = 0; + for( int i = 0; i < pObjectList->uNumObjects; i++ ) + { + if( v9 == pObjectList->pObjects[i].uObjectID ) + { + v11 = i; + break; + } + } a1.uObjectDescID = v11; a1.vPosition.y = a4; a1.vPosition.x = a3; @@ -1714,11 +1615,11 @@ } //----- (0045063B) -------------------------------------------------------- -int __fastcall sub_45063B(MapInfo *a1, int a2) +int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) { signed int v2; // edi@1 Actor *v3; // esi@2 - signed __int64 v4; // qax@3 + //signed __int64 v4; // qax@3 int result; // eax@8 int v6; // edi@11 int v7; // ebx@11 @@ -1735,33 +1636,49 @@ int v18; // eax@21 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 int v20; // [sp+24h] [bp-20h]@11 - MapInfo *v21; // [sp+28h] [bp-1Ch]@1 + //MapInfo *v21; // [sp+28h] [bp-1Ch]@1 int v22; // [sp+2Ch] [bp-18h]@3 int v23; // [sp+30h] [bp-14h]@11 - int v24; // [sp+34h] [bp-10h]@1 + //int v24; // [sp+34h] [bp-10h]@1 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 int v26; // [sp+3Ch] [bp-8h]@11 int v27; // [sp+40h] [bp-4h]@11 - - v21 = a1; - v24 = a2; + + if (!uNumActors) + return 0; + + //v21 = a1; + //v24 = a2; v2 = 0; - if ( (signed int)uNumActors <= 0 ) - goto LABEL_8; v3 = pActors.data(); while ( 1 ) { - v22 = v3->pMonsterInfo.uID - 1; - v4 = (signed __int64)((double)v22 * 0.3333333333333333); - if ( (int)v4 != 40 ) + if (v3->pMonsterInfo.uID >= 121 && v3->pMonsterInfo.uID <= 123 || // Dwarf FemaleC A-C + v3->pMonsterInfo.uID >= 124 && v3->pMonsterInfo.uID <= 126 || // Dwarf MaleA A-C + v3->pMonsterInfo.uID >= 133 && v3->pMonsterInfo.uID <= 135 || // Peasant Elf FemaleA A-C + !v3->CanAct()) { - if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) - break; + ++v2; + ++v3; + + if (v2 >= uNumActors) + return 0; + + continue; } - ++v2; - ++v3; - if ( v2 >= (signed int)uNumActors ) - goto LABEL_8; + + break; + //v22 = v3->pMonsterInfo.uID - 1; + //v4 = (signed __int64)((double)v22 * 0.3333333333333333); + //if ( (int)v4 != 40 ) + //{ + // if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) + // break; + //} + //++v2; + //++v3; + //if ( v2 >= (signed int)uNumActors ) + // goto LABEL_8; } if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) { @@ -1778,7 +1695,7 @@ v20 = stru_5C6E00->Sin(v7); v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; v8 = 0; - v19.uIndex = v24; + v19.uIndex = a2; v19.vPosition.y = v23 + pParty->vPosition.y; v19.vPosition.z = pParty->vPosition.z; v26 = 0; @@ -1792,22 +1709,16 @@ &v27, 0); v23 = 0; - if ( (signed int)pOutdoor->uNumBModels > 0 ) - { - while ( 1 ) - { - v9 = abs(v19.vPosition.y - pOutdoor->pBModels[v8].vBoundingCenter.y); - v10 = abs(v19.vPosition.x - pOutdoor->pBModels[v8].vBoundingCenter.x); - if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[v8].sBoundingRadius + 256 ) - break; - ++v23; - ++v8; - if ( v23 >= (signed int)pOutdoor->uNumBModels ) - goto LABEL_16; - } - v22 = 1; - } -LABEL_16: + for( int i = 0; i < pOutdoor->uNumBModels; i++ ) + { + v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); + v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); + if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) + { + v22 = 1; + break; + } + } v11 = uFaceID == 100; if ( uFaceID >= 100 ) break; @@ -1837,7 +1748,7 @@ v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16; v19.vPosition.y = v23 + pParty->vPosition.y; v19.vPosition.z = pParty->vPosition.z; - v19.uIndex = v24; + v19.uIndex = a2; v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z); if ( v17 == v22 ) { @@ -1855,13 +1766,12 @@ } if ( v11 ) { -LABEL_8: result = 0; } else { - SpawnEncounter(v21, &v19, 0, 0, 1); - result = v24; + SpawnEncounter(a1, &v19, 0, 0, 1); + result = a2; } return result; } @@ -1883,108 +1793,90 @@ int v12; // eax@21 int v13; // eax@22 - v1 = this; - rand(); - v2 = v1->uDecorationDescID; - if ( v2 > 208 ) - { - switch ( v2 ) - { - case 209: - result = rand() % 7 + 183; - break; - case 210: - result = 150; - break; - case 211: - result = 151; - break; - case 212: - result = 152; - break; - case 213: - result = 153; - break; - case 214: - result = 154; - break; - case 215: - result = 155; - break; - case 216: - result = 156; - break; - case 217: - result = 157; - break; - case 218: - result = 158; - break; - case 219: - result = 159; - break; - case 220: - result = 160; - break; - case 221: - result = 161; - break; - default: - goto LABEL_45; - } - } - else - { - if ( v2 == 208 ) - { - result = rand() % 7 + 176; - } - else - { - if ( v2 > 24 ) - { - v9 = v2 - 34; - if ( !v9 ) - return rand() % 6 + 4; - v10 = v9 - 150; - if ( !v10 ) - return 33; - v11 = v10 - 3; - if ( !v11 || (v12 = v11 - 3) == 0 ) - return 37; - v13 = v12 - 16; - if ( !v13 ) - return rand() % 7 + 162; - if ( v13 == 1 ) - return rand() % 7 + 169; - } - else - { - if ( v2 == 24 ) - return 36; - v3 = v2 - 4; - if ( !v3 ) - return 16; - v4 = v3 - 1; - if ( !v4 ) - return 32; - v5 = v4 - 1; - if ( !v5 ) - return rand() % 4 + 12; - v6 = v5 - 5; - if ( !v6 ) - return 34; - v7 = v6 - 2; - if ( !v7 ) - return 17; - if ( v7 == 1 ) - return 18; - } -LABEL_45: - result = 0; - } - } - return result; + switch (uDecorationDescID) + { + case 0: case 1: + case 2: case 3: + return 0; + + case 4: return 16; // dec01 "Trash Pile" + case 5: return 32; // dec02 "Campfire" + case 6: return 12 + rand() % 4; // dec03 "Cauldron" + case 7: case 8: + case 9: case 10: + return 0; + + case 11: return 34; // dec08 "Fruit plate" + case 12: + return 0; + + case 13: return 17; // dec10 "Trash Pile" + case 14: return 18; // dec11 "Filth" + case 15: case 16: case 17: + case 18: case 19: case 20: + case 21: case 22: case 23: + return 0; + + case 24: return 36; // dec21 "Keg" + case 25: case 26: case 27: case 28: case 29: + case 30: case 31: case 32: case 33: + return 0; + + case 34: return 4 + rand() % 6; // dec32 "Barrel" + case 35: case 36: case 37: case 38: case 39: + case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: + case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: + case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: + case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: + case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: + case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: + case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: + case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: + case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129: + case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139: + case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149: + case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159: + case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169: + case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: + case 180: case 181: case 182: case 183: + + case 184: return 33; // dec24 "Campfire" + case 185: case 186: + return 0; + + case 187: // dec88 "Mushroom" + case 190: // dec91 "Mushroom" + return 37; + + case 188: case 189: + case 191: case 192: case 193: case 194: case 195: case 196: + case 197: case 198: case 199: case 200: case 201: case 202: + case 203: case 204: case 205: + return 0; + + case 206: return 162 + rand() % 7; // dec60 + case 207: return 169 + rand() % 7; // dec61 + case 208: return 176 + rand() % 7; // dec62 + case 209: return 183 + rand() % 7; // dec63 + case 210: return 150; // dec64 "Magic Pedistal" + case 211: return 151; // dec65 "Magic Pedistal" + case 212: return 152; // dec66 "Magic Pedistal" + case 213: return 153; // dec67 "Magic Pedistal" + case 214: return 154; // dec68 "Magic Pedistal" + case 215: return 155; // dec69 "Magic Pedistal" + case 216: return 156; // dec70 "Magic Pedistal" + case 217: return 157; // dec71 "Magic Pedistal" + case 218: return 158; // dec72 "Magic Pedistal" + case 219: return 159; // dec73 "Magic Pedistal" + case 220: return 160; // dec74 "Magic Pedistal" + case 221: return 161; // dec75 "Magic Pedistal" + + case 222: case 223: case 224: + case 225: case 226: case 227: + return 0; + + default: assert(false && "Invalid Decoration"); + } } //----- (00450AAA) -------------------------------------------------------- @@ -2339,6 +2231,7 @@ LOWORD(v7) = v5 & 0xE0; v12 = v7 + v11; LOWORD(v7) = v8 & 0xE0; + __debugbreak(); // warning C4700: uninitialized local variable 'v10' used return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00) + (v5 & 0x1C00) + v9 @@ -2993,9 +2886,9 @@ case 0x80: return 3; // Master case 0x40: return 2; // Expert case 0x00: return 1; // Normal - default: - assert(false); - } + } + assert(false); + return 0; } //----- (0045828B) -------------------------------------------------------- @@ -3022,34 +2915,43 @@ if ( a1 < 78 ) { if ( a1 < 89 ) - goto LABEL_31; - goto LABEL_28; + { + v4 = 0; + v1 = 0; + v2 = 0; + return TargetColor(v2, v1, v4); + } } + else + { LABEL_25: - if ( a1 < 89 ) - { - v4 = 155; - v2 = 255; - goto LABEL_30; - } -LABEL_28: + if ( a1 < 89 ) + { + v4 = 155; + v2 = 255; + v1 = v2; + return TargetColor(v2, v1, v4); + } + } if ( a1 < 100 ) { v4 = 240; v2 = 192; - goto LABEL_30; + v1 = v2; + return TargetColor(v2, v1, v4); } -LABEL_31: v4 = 0; v1 = 0; - goto LABEL_32; + v2 = 0; + return TargetColor(v2, v1, v4); } LABEL_21: if ( a1 < 78 ) { v4 = 0; v1 = 128; - goto LABEL_23; + v2 = 255; + return TargetColor(v2, v1, v4); } goto LABEL_25; } @@ -3067,7 +2969,9 @@ if ( a1 < 56 ) { v2 = 225; - goto LABEL_13; + v4 = v2; + v1 = v2; + return TargetColor(v2, v1, v4); } goto LABEL_18; } @@ -3075,9 +2979,7 @@ if ( a1 < 45 ) { v2 = 128; -LABEL_13: v4 = v2; -LABEL_30: v1 = v2; return TargetColor(v2, v1, v4); } @@ -3088,7 +2990,6 @@ { v4 = 255; v1 = 128; -LABEL_32: v2 = 0; return TargetColor(v2, v1, v4); } @@ -3101,7 +3002,6 @@ { v4 = 0; v1 = 85; -LABEL_23: v2 = 255; return TargetColor(v2, v1, v4); } @@ -3192,9 +3092,9 @@ { if ( v4 != 1 ) { - if ( v4 != 0 || pActor->sNPC_ID ) - continue; - goto LABEL_12; + if ( v4 == 0 && pActor->sNPC_ID == 0 ) + pActor->sNPC_ID = 0; + continue; } } if ( pActor->sNPC_ID > 0 && pActor->sNPC_ID < 5000 ) @@ -3207,9 +3107,7 @@ pActor->sNPC_ID = v14; continue; } -LABEL_12: pActor->sNPC_ID = 0; -//LABEL_13: //++v15; //v2 += 836; //} @@ -4107,14 +4005,12 @@ else { if ( !pRenderer->pRenderD3D && !pRenderer->UsingDirect3D() || !AreRenderSurfacesOk() ) - //goto LABEL_20; { EndPaint(hWnd, &Paint); return 0; } } pRenderer->Present(); -//LABEL_20: EndPaint(hWnd, &Paint); return 0; } @@ -4399,25 +4295,27 @@ || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v13, &dwDisposition) || RegCreateKeyExA(v13, "1.0", 0, "", 0, 0xF003Fu, 0, &v14, &dwDisposition) ) - goto LABEL_7; - if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) ) + { + result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); + } + else if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) ) { RegCloseKey(v14); v14 = 0; -LABEL_7: result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); - goto LABEL_8; - } - v4 = RegCloseKey; - RegCloseKey(v14); - v14 = 0; - RegCloseKey(v13); - v13 = 0; - RegCloseKey(phkResult); - phkResult = 0; - result = RegCloseKey(hKey); - hKey = 0; -LABEL_8: + } + else + { + v4 = RegCloseKey; + RegCloseKey(v14); + v14 = 0; + RegCloseKey(v13); + v13 = 0; + RegCloseKey(phkResult); + phkResult = 0; + result = RegCloseKey(hKey); + hKey = 0; + } if ( v14 ) result = v4(v14); if ( v13 ) @@ -4578,7 +4476,6 @@ if ( a3 == 2 ) { v12 = 0; -LABEL_9: EndDialog(hDlg, v12); return 1; } @@ -4591,7 +4488,8 @@ if ( v4 ) { v12 = 1; - goto LABEL_9; + EndDialog(hDlg, v12); + return 1; } return 0; } @@ -5365,7 +5263,7 @@ assert(sizeof(IndoorCamera) == 0x50); assert(sizeof(Bloodsplat) == 0x28); assert(sizeof(BloodsplatContainer) == 0xA0C); - assert(sizeof(stru167) == 0x18); + assert(sizeof(TrailParticle) == 0x18); assert(sizeof(EventIndex) == 0xC); assert(sizeof(_2devent) == 0x34); assert(sizeof(stru176) == 0x20); @@ -5499,7 +5397,6 @@ { MainMenu_Loop(); uGameState = GAME_STATE_PLAYING; -//LABEL_21: while ( 1 ) { if (uGameState == GAME_FINISHED || @@ -5555,30 +5452,29 @@ if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) { uGameState = GAME_STATE_PLAYING; + pGame->Loop(); } else { - if (GetCurrentMenuID() != MENU_10) - goto LABEL_49; - pMouse->Activate(0); - - pParty->Reset(); - pParty->CreateDefaultParty(1); - crt_init_globals_46271C(); - extern OPENFILENAMEA ofn; - if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) - { - pMouse->Activate(1); - - break; - } - _chdir("..\\"); - strcpy(pCurrentMapName.data(), ofn.lpstrFileTitle); - pMouse->Activate(1); + if (GetCurrentMenuID() == MENU_10) + { + pMouse->Activate(0); + + pParty->Reset(); + pParty->CreateDefaultParty(1); + crt_init_globals_46271C(); + extern OPENFILENAMEA ofn; + if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) + { + pMouse->Activate(1); + break; + } + _chdir("..\\"); + strcpy(pCurrentMapName.data(), ofn.lpstrFileTitle); + pMouse->Activate(1); + pGame->Loop(); + } } -//LABEL_48: - pGame->Loop(); -LABEL_49: if ( uGameState == GAME_STATE_LOADING_GAME ) { SetCurrentMenuID(MENU_5); @@ -5773,7 +5669,7 @@ outdoor_grid_band_2 = 15; outdoor_grid_band_3 = 20; pOutdoorCamera->shading_dist_mist = 8192; - pOutdoorCamera->bNoSky = 0; + pOutdoorCamera->bNoSky = false; LOBYTE(viewparams->field_20) = 0; } mipmapping_terrain_mm1 = 1024; @@ -5787,7 +5683,11 @@ mipmapping_building_mm3 = 4096; pOutdoorCamera->shading_dist_shademist = 4096; pOutdoorCamera->outdoor_no_wavy_water = 0; - sub_47F4D3(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); + //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); + { + pOutdoorCamera->outdoor_grid_band_3 = outdoor_grid_band_3; + pOutdoorCamera->uPickDepth = outdoor_grid_band_3 * 512; + } } else { @@ -6162,13 +6062,13 @@ v29 = 640 * v3; while ( 2 ) { - v31 = 100; - v6 = &pRenderer->pActiveZBuffer[v2 + v5 - v4 / 2]; + v6 = &pRenderer->pActiveZBuffer[v2 + v5 - v4 / 2]-1; v7 = v0; - while ( 1 ) - { + //while ( 1 ) + for( int i = 0; i < 100; i++) + { + ++v6; v8 = *v6; - --v31; if ( (unsigned int)*v6 <= 0x2000000 ) { v9 = 0; @@ -6201,17 +6101,13 @@ } } } - if ( !v31 ) - break; - ++v6; - } + } v4 = -1; ++v30; v5 = v29 + 640; v29 += 640; - if ( v30 < v28 ) - continue; - break; + if ( v30 >= v28 ) + break; } v12 = 0; v10 = v0 == 0; @@ -6254,45 +6150,51 @@ if ( !(pSpriteObjects[v20].uAttributes & 0x10) ) { v23 = pSpriteObjects[v20].stru_24.GetDisplayName(); -LABEL_36: v24 = v23; - goto LABEL_51; - } - goto LABEL_41; - } - if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor) - { - if ( v20 >= 0xBB8 ) - return 0; - v24 = (const char *)&pActors[v20]; - goto LABEL_51; - } - if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration) - break; - if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel) - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - v21 = &pIndoor->pFaces[v20]; - if ( !(BYTE3(v21->uAttributes) & 2) ) - goto LABEL_41; - v22 = pIndoor->pFaceExtras[v21->uFaceExtraID].uEventID; - } - else - { - if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 >= pOutdoor->uNumBModels ) - goto LABEL_41; - v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID; - } - if ( v22 ) - { - v23 = GetEventHintString(v22); - if ( v23 ) - goto LABEL_36; + GameUI_SetFooterString(v24); + return v19; } } -LABEL_41: - ++v18; + else + { + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor) + { + if ( v20 >= 0xBB8 ) + return 0; + v24 = (const char *)&pActors[v20]; + GameUI_SetFooterString(v24); + return v19; + } + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration) + break; + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel) + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + v21 = &pIndoor->pFaces[v20]; + if ( BYTE3(v21->uAttributes) & 2 ) + v22 = pIndoor->pFaceExtras[v21->uFaceExtraID].uEventID; + } + else + { + if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 < pOutdoor->uNumBModels ) + { + v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID; + if ( v22 ) + { + v23 = GetEventHintString(v22); + if ( v23 ) + { + v24 = v23; + GameUI_SetFooterString(v24); + return v19; + } + } + } + } + } + } + ++v18; if ( v18 >= v0 ) return 0; } @@ -6304,13 +6206,14 @@ v23 = GetEventHintString(v27); if ( !v23 ) return v19; - goto LABEL_36; + v24 = v23; + GameUI_SetFooterString(v24); + return v19; } if ( v25->IsInteractive() ) v24 = pNPCTopics[stru_5E4C90._decor_events[v26->_idx_in_stru123 - 75] + 379].pTopic; else v24 = pDecorationList->pDecorations[v26->uDecorationDescID].field_20; -LABEL_51: GameUI_SetFooterString(v24); return v19; } @@ -6586,8 +6489,11 @@ if ( v151 != OBJECT_Actor) { if ( v6 != 9030 || v2->spell_skill != 4 ) - goto LABEL_246; - v2->_46BEF1_apply_spells_aoe(); + { + SpriteObject::OnInteraction(v153); + return 0; + } + v2->_46BEF1_apply_spells_aoe(); LABEL_233: if ( !v138 ) { @@ -6633,9 +6539,10 @@ v127 = 0; v126 = v115; v116 = v143; - goto LABEL_269; + v125 = v116 + 1; + pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133); + return 0; } -LABEL_246: SpriteObject::OnInteraction(v153); return 0; } @@ -6730,7 +6637,24 @@ if ( v52 >= (signed int)v93 ) goto LABEL_181; } - goto LABEL_202; + v95 = v52; + v2->uObjectDescID = v95; + if ( v95 == (short)v9 ) + SpriteObject::OnInteraction(v153); + v96 = v2->uSoundID; + v2->vVelocity.z = v9; + v2->vVelocity.y = v9; + v2->vVelocity.x = v9; + v2->uSpriteFrameID = v9; + if ( v96 == (short)v9 ) + v97 = 0; + else + v97 = (signed __int16)v96 + 4; + v133 = v9; + v131 = v9; + v130 = v97; + v92 = v153; + goto LABEL_267; } goto LABEL_181; } @@ -6807,11 +6731,10 @@ LOBYTE(v124) = v124 | 2; v127 = v9; v126 = v124; -LABEL_268: v116 = word_4EE088_sound_ids[v2->spell_id - 1]; -LABEL_269: v125 = v116 + 1; - goto LABEL_29; + pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133); + return 0; } v59 = v6 + 2; v60 = pObjectList->uNumObjects; @@ -6918,7 +6841,10 @@ v128 = -1; v127 = v66; v126 = v75; - goto LABEL_268; + v116 = word_4EE088_sound_ids[v2->spell_id - 1]; + v125 = v116 + 1; + pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133); + return 0; } if ( v7 == 4090 ) { @@ -7124,7 +7050,20 @@ v2->vVelocity.x = 0; v2->uSpriteFrameID = 0; if ( !v44 ) - goto LABEL_27; + { + v133 = v9; + v131 = v9; + v130 = v9; + v13 = 8 * v153; + v129 = v9; + v128 = -1; + LOBYTE(v13) = PID(OBJECT_Item,v153); + v127 = v9; + v126 = v13; + v125 = 8; + pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133); + return 0; + } } return 0; } @@ -7161,11 +7100,13 @@ if ( v52 >= (signed int)v51 ) goto LABEL_181; } - goto LABEL_202; + v95 = v52; } + else + { LABEL_181: v95 = 0; -LABEL_182: + } v2->uObjectDescID = v95; if ( v95 == (short)v9 ) SpriteObject::OnInteraction(v153); @@ -7225,8 +7166,8 @@ v2->uSpriteFrameID = 0; v147 = v38; stru_50FE08.Add(v38, 512, v40, v39, v37, 0, 0); - if ( HIBYTE(v3->uFlags) & 1 ) - array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, 0, v3->uParticleTrailColor); + if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + trail_particle_generator.GenerateTrailParticles(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, v3->uParticleTrailColor); v133 = 0; v131 = 0; v130 = 0; @@ -7234,7 +7175,9 @@ v128 = -1; v127 = 0; v126 = v147; - goto LABEL_28; + v125 = 8; + pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133); + return 0; } v27 = v26 - 410; if ( !v27 ) @@ -7283,12 +7226,11 @@ v2->vVelocity.z = v32; v149 = v102; stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32); - if ( HIBYTE(v3->uFlags) & 1 ) - array_5118E8._440E91( + if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + trail_particle_generator.GenerateTrailParticles( v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, - v32, v3->uParticleTrailColor); v105 = v2->uSoundID; if ( v105 == (short)v32 ) @@ -7302,7 +7244,10 @@ v128 = -1; v127 = v32; v126 = v149; - goto LABEL_268; + v116 = word_4EE088_sound_ids[v2->spell_id - 1]; + v125 = v116 + 1; + pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133); + return 0; } goto LABEL_195; } @@ -7327,9 +7272,24 @@ if ( v52 >= (signed int)v122 ) goto LABEL_181; } -LABEL_202: v95 = v52; - goto LABEL_182; + v2->uObjectDescID = v95; + if ( v95 == (short)v9 ) + SpriteObject::OnInteraction(v153); + v96 = v2->uSoundID; + v2->vVelocity.z = v9; + v2->vVelocity.y = v9; + v2->vVelocity.x = v9; + v2->uSpriteFrameID = v9; + if ( v96 == (short)v9 ) + v97 = 0; + else + v97 = (signed __int16)v96 + 4; + v133 = v9; + v131 = v9; + v130 = v97; + v92 = v153; + goto LABEL_267; } goto LABEL_181; } @@ -7341,7 +7301,6 @@ v2->uType = v117; if ( v20 | v44 ) { -LABEL_255: v121 = 0; } else @@ -7352,7 +7311,28 @@ ++v119; v120 += 56; if ( v119 >= (signed int)v118 ) - goto LABEL_255; + { + v121 = 0; + v2->uObjectDescID = v121; + if ( !v121 ) + SpriteObject::OnInteraction(v153); + v2->vVelocity.z = 0; + v2->vVelocity.y = 0; + v2->vVelocity.x = 0; + v2->uSpriteFrameID = 0; + v133 = v9; + v131 = v9; + v130 = v9; + v13 = 8 * v153; + v129 = v9; + v128 = -1; + LOBYTE(v13) = PID(OBJECT_Item,v153); + v127 = v9; + v126 = v13; + v125 = 8; + pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133); + return 0; + } } v121 = v119; } @@ -7363,7 +7343,6 @@ v2->vVelocity.y = 0; v2->vVelocity.x = 0; v2->uSpriteFrameID = 0; -LABEL_27: v133 = v9; v131 = v9; v130 = v9; @@ -7373,9 +7352,7 @@ LOBYTE(v13) = PID(OBJECT_Item,v153); v127 = v9; v126 = v13; -LABEL_28: v125 = 8; -LABEL_29: pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133); return 0; }
--- a/mm7_3.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/mm7_3.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -42,7 +42,6 @@ #include "Time.h" #include "IconFrameTable.h" #include "TurnEngine.h" -#include "stru220.h" #include "Events2D.h" #include "stru176.h" #include "stru298.h" @@ -1817,37 +1816,38 @@ pParty->sRotationX = _view_angle; if ( bJumping ) { - pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength(); + pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength(); + if ( bJumping != v36 && pParty->uFallSpeed <= v36 ) + { + if ( pParty->uFallSpeed < -500 && !pParty->bFlying ) + { + v41 = &pPlayers[1]; + do + { + if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 + (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0); + ++v41; + } + while ( (signed int)v41 <= (signed int)&pPlayers[4] ); + } + } + else + pParty->uFallStartY = party_z; } else { if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 ) { pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength(); - goto LABEL_92; + pParty->uFallStartY = party_z; } - if (pParty->uFlags & PARTY_FLAGS_1_LANDING) - goto LABEL_92; - pParty->uFallSpeed = 0; - } - if ( bJumping != v36 && pParty->uFallSpeed <= v36 ) - { - if ( pParty->uFallSpeed < -500 && !pParty->bFlying ) - { - v41 = &pPlayers[1]; - do - { - if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 - (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0); - ++v41; - } - while ( (signed int)v41 <= (signed int)&pPlayers[4] ); - } - goto LABEL_93; - } -LABEL_92: - pParty->uFallStartY = party_z; -LABEL_93: + else + { + if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) ) + pParty->uFallSpeed = 0; + pParty->uFallStartY = party_z; + } + } if ( v2 * v2 + v1 * v1 < 400 ) { v1 = 0; @@ -1924,9 +1924,8 @@ && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) ) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); viewparams->bRedrawGameUI = 1; - goto LABEL_152; } - if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) + else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v53 = integer_sqrt(v2 * v2 + v1 * v1); v80 = v53; @@ -1956,64 +1955,69 @@ } if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - goto LABEL_152; } - v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z; - v47 = v45 == 4; - v48 = v44->pFacePlane_old.vNormal.x; - if ( !v47 ) - { - v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; - if ( stru_721530.field_64 >> 3 > v80 ) - v80 = stru_721530.field_64 >> 3; - v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; - v81 = v44->pFacePlane_old.vNormal.y; - v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; - v82 = v44->pFacePlane_old.vNormal.z; - v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; - v2 += v50; - pParty->uFallSpeed += v82; - v74 = v44->pFacePlane_old.vNormal.z; - v51 = v44->pFacePlane_old.vNormal.y; - v69 = v44->pFacePlane_old.vNormal.x; - v80 = v51; - v1 += v81; - v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16); - if ( v52 > 0 ) - { - new_party_x += v52 * v69 >> 16; - new_party_y += v52 * v80 >> 16; - v87 += v52 * v74 >> 16; - } - v43 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) - uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - goto LABEL_152; - } - v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; - if ( stru_721530.field_64 >> 3 > v80 ) - v80 = stru_721530.field_64 >> 3; - v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; - v81 = v44->pFacePlane_old.vNormal.y; - v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; - v82 = v44->pFacePlane_old.vNormal.z; - v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; - v2 += v49; - v1 += v81; - pParty->uFallSpeed += v82; - if ( v2 * v2 + v1 * v1 >= 400 ) - { - v43 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) - uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - goto LABEL_152; - } - v2 = 0; - v1 = 0; - pParty->uFallSpeed = 0; + else + { + v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z; + v47 = v45 == 4; + v48 = v44->pFacePlane_old.vNormal.x; + if ( !v47 ) + { + v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; + if ( stru_721530.field_64 >> 3 > v80 ) + v80 = stru_721530.field_64 >> 3; + v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; + v81 = v44->pFacePlane_old.vNormal.y; + v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; + v82 = v44->pFacePlane_old.vNormal.z; + v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; + v2 += v50; + pParty->uFallSpeed += v82; + v74 = v44->pFacePlane_old.vNormal.z; + v51 = v44->pFacePlane_old.vNormal.y; + v69 = v44->pFacePlane_old.vNormal.x; + v80 = v51; + v1 += v81; + v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16); + if ( v52 > 0 ) + { + new_party_x += v52 * v69 >> 16; + new_party_y += v52 * v80 >> 16; + v87 += v52 * v74 >> 16; + } + v43 = stru_721530.uFaceID; + if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) + uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; + } + else + { + v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; + if ( stru_721530.field_64 >> 3 > v80 ) + v80 = stru_721530.field_64 >> 3; + v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; + v81 = v44->pFacePlane_old.vNormal.y; + v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; + v82 = v44->pFacePlane_old.vNormal.z; + v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; + v2 += v49; + v1 += v81; + pParty->uFallSpeed += v82; + if ( v2 * v2 + v1 * v1 >= 400 ) + { + v43 = stru_721530.uFaceID; + if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) + uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; + } + else + { + v2 = 0; + v1 = 0; + pParty->uFallSpeed = 0; + } + } + } } } -LABEL_152: v2 = (unsigned __int64)(58500i64 * v2) >> 16; v1 = (unsigned __int64)(58500i64 * v1) >> 16; ++v83; @@ -2029,8 +2033,11 @@ if ( integer_sqrt((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y) * (pParty->vPosition.y - new_party_y) + (pParty->vPosition.z - new_party_z) * (pParty->vPosition.z - new_party_z)) <= 16 ) - goto LABEL_188; - if ( v72 && (!bJumping || jumping_up) ) + { + pAudioPlayer->_4AA258(804); + pParty->walk_sound_timer = 64; + } + else if ( v72 && (!bJumping || jumping_up) ) { v66 = 0; v64 = 0; @@ -2046,13 +2053,16 @@ v57 = (SoundID)50; else v57 = (SoundID)64; - goto LABEL_175; + pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); } - v57 = (SoundID)63; - v56 = pAudioPlayer; - goto LABEL_175; + else + { + v57 = (SoundID)63; + v56 = pAudioPlayer; + pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); + } } - if ( v78 && (!bJumping || jumping_up) ) + else if ( v78 && (!bJumping || jumping_up) ) { v66 = 0; v64 = 0; @@ -2065,19 +2075,19 @@ { v57 = (SoundID)102; v56 = pAudioPlayer; - goto LABEL_175; } - v56 = pAudioPlayer; - if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) - v57 = (SoundID)89; - else - v57 = (SoundID)103; -LABEL_175: + else + { + v56 = pAudioPlayer; + if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) + v57 = (SoundID)89; + else + v57 = (SoundID)103; + } pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); } else { -LABEL_188: pAudioPlayer->_4AA258(804); pParty->walk_sound_timer = 64; } @@ -2208,8 +2218,8 @@ int bFeatherFall; // [sp+28h] [bp-6Ch]@4 int v105; // [sp+2Ch] [bp-68h]@24 int bWaterWalk; // [sp+30h] [bp-64h]@1 - bool v107; // [sp+34h] [bp-60h]@30 - int v108; // [sp+38h] [bp-5Ch]@1 + //bool v107; // [sp+34h] [bp-60h]@30 + //int v108; // [sp+38h] [bp-5Ch]@1 int v109; // [sp+3Ch] [bp-58h]@28 int v110; // [sp+40h] [bp-54h]@180 int v111; // [sp+44h] [bp-50h]@14 @@ -2231,7 +2241,7 @@ BSPModel *v127; // [sp+84h] [bp-10h]@1 int v128; // [sp+88h] [bp-Ch]@1 int v129; // [sp+8Ch] [bp-8h]@92 - int v130; // [sp+90h] [bp-4h]@14 + //int v130; // [sp+90h] [bp-4h]@14 v121 = pParty->uFallSpeed; pZ = pParty->vPosition.z; @@ -2248,22 +2258,12 @@ auto partyAtHighSlope = IsTerrainSlopeTooHigh(pParty->vPosition.x, pParty->vPosition.y); v114 = 0; v124 = 0; - v108 = 0; v102 = 0; v127 = 0; bWaterWalk = 0; if (!pParty->FeatherFallActive()) - //SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0 - //|| SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 && LODWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 ) { bFeatherFall = 0; - /*v119 = &pPlayers[1]; - while ( !(*v119)->WearsItem(536, 16) ) - { - ++v119; - if ( (signed int)v119 > (signed int)&pPlayers[4] ) - goto LABEL_9; - }*/ for (int i = 0; i < 4; ++i) if (pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY)) // seems like flying boots { @@ -2286,7 +2286,11 @@ pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].sMana <= 0 ) bWaterWalk = 0; } - v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &v130, &v108, bWaterWalk); + int bmodel_standing_on_pid; + int is_on_water = false; + v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk); + int is_not_on_bmodel = bmodel_standing_on_pid == 0; + v111 = v3; if ( bFeatherFall ) pParty->uFallStartY = v3; @@ -2317,7 +2321,7 @@ v109 = -1; if ( pParty->bFlying ) v109 = sub_46D8E3(pX, pY, pZ + pParty->uPartyHeight, (int)&v102); - v107 = v108 == 0; + //v107 = bmodel_standing_on_pid == 0; v105 = v111 + 1; if ( pZ <= v111 + 1 ) { @@ -2335,20 +2339,18 @@ pParty->walk_sound_timer -= pEventTimer->uTimeElapsed; else pParty->walk_sound_timer = 0; } - if (!bUnderwater - && SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0 - && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) < 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0) ) + if (!bUnderwater && pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime <= 0) pParty->bFlying = false; if (!bJumping) { - if ( pParty->floor_face_pid != PID(OBJECT_BModel, v108) ) + if ( pParty->floor_face_pid != PID(OBJECT_BModel, bmodel_standing_on_pid) ) { - if (v108) + if (bmodel_standing_on_pid) { - if ( v108 >> 6 < pOutdoor->uNumBModels ) + if ( (bmodel_standing_on_pid >> 6) < pOutdoor->uNumBModels ) { - v7 = pOutdoor->pBModels[v108 >> 6].pFaces; - v6 = v108 & 0x3F; + v7 = pOutdoor->pBModels[bmodel_standing_on_pid >> 6].pFaces; + v6 = bmodel_standing_on_pid & 0x3F; /*if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 ) { pParty->field_6F4_packedid = PID(OBJECT_BModel,v108); @@ -2356,13 +2358,13 @@ }*/ if ( BYTE3(v7[v6].uAttributes) & 4 ) { - pParty->floor_face_pid = PID(OBJECT_BModel, v108); + pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); v103 = v7[v6].sCogTriggeredID; } } } } - pParty->floor_face_pid = PID(OBJECT_BModel, v108); + pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); } _walk_speed = pParty->uWalkSpeed; _angle_y = pParty->sRotationY; @@ -2548,7 +2550,7 @@ v128 = v1; } - else if (partyAtHighSlope && !v108) + else if (partyAtHighSlope && !bmodel_standing_on_pid) { v2 += dx; v1 += dy; @@ -2634,7 +2636,7 @@ break; case PARTY_Jump: - if ( (!partyAtHighSlope || v108) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) + if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) { v126 = pParty->field_24 << 6; bJumping = 1; @@ -2678,7 +2680,7 @@ } else { - if ( v130 && v121 ) + if ( is_on_water && v121 ) sub_42F960_create_object(pX, pY, v111); v121 = 0; pZ = v111; @@ -2708,7 +2710,7 @@ } else if (!bJumping) { - if ( !v108 ) + if ( !bmodel_standing_on_pid ) { // rolling down the hill // how it's done: you get a little bit pushed in the air along terrain normal, getting in the air @@ -2802,18 +2804,18 @@ v40 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + pZ; } v122 = v40; - ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0); - v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &v130, &v97, 0); - auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &v130, &v110, 0); + ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); + v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &is_on_water, &v97, 0); + auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &v110, 0); v127 = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY); v42 = IsTerrainSlopeTooHigh(pX, _angle_y); - v107 = 0; + is_not_on_bmodel = false; v118 = v42; - if ( !v97 && !v110 && !v108 ) - v107 = 1; + if ( !v97 && !v110 && !bmodel_standing_on_pid ) + is_not_on_bmodel = true; v43 = 1; v44 = 1; - if ( bUnderwater || !v107 ) + if ( bUnderwater || !is_not_on_bmodel ) { pX = _angle_x; if ( v43 ) @@ -2835,7 +2837,7 @@ pY = _angle_y; else { - v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0); + v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= pZ ) { v43 = 1; @@ -2847,7 +2849,7 @@ } if ( stru_721530.field_7C >= stru_721530.field_6C ) { - if ( !v107 ) + if ( !is_not_on_bmodel ) { pX = stru_721530.normal2.x; pY = stru_721530.normal2.y; @@ -2878,9 +2880,8 @@ { v56 = integer_sqrt(v2 * v2 + v128 * v128); v118 = v56; - v57 = stru_5C6E00->Atan2( - _angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, - _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y); + v57 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, + _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y); v129 = v57; v58 = (BSPModel *)stru_5C6E00->Cos(v57); v127 = v58; @@ -2921,7 +2922,7 @@ v2 = 0; *(float *)&v128 = 0.0; } - if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 ) + if ( pParty->floor_face_pid != v45 && (v47->uAttributes & FACE_PRESSURE_PLATE)) { pParty->floor_face_pid = v45; v103 = v47->sCogTriggeredID; @@ -3036,7 +3037,7 @@ { if ( v114 && (!bJumping || v101) ) { - if ( !v107 + if ( !is_not_on_bmodel && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) ) { pAudioPlayer->PlaySound((SoundID)64, 804, 1, -1, 0, 0, 0, 0); @@ -3053,7 +3054,7 @@ { if ( v124 && (!bJumping || v101) ) { - if ( v107 + if ( is_not_on_bmodel || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 ) { v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; @@ -3080,14 +3081,14 @@ v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; v114 = WorldPosToGridCellX(pX); v66 = WorldPosToGridCellZ(pY) - 1; - v127 = (BSPModel *)(((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1); - v122 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1; + v127 = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1); + v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1; v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66); v68 = 0; - v69 = ((unsigned int)~v67 >> 1) & 1; + v69 = (~(unsigned int)v67 >> 1) & 1; if ( v114 == v126 && v66 == v65 && v122 && v69 ) v68 = 1; - if ( !v107 ) + if ( !is_not_on_bmodel ) v68 = 1; if ( v68 ) { @@ -3520,7 +3521,7 @@ v25 = 0; v16 = word_720B40_intercepts_zs[0] >= v27; if ( v15 <= 0 ) - goto LABEL_29; + return 0; do { if ( v31 >= 2 ) @@ -3555,7 +3556,6 @@ while ( v25 < v15 ); result = 1; if ( v31 != 1 ) -LABEL_29: result = 0; return result; } @@ -3658,7 +3658,7 @@ v21 = 0; v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24; if ( v11 <= 0 ) - goto LABEL_29; + return 0; do { if ( a4d >= 2 ) @@ -3693,7 +3693,6 @@ while ( v21 < v11 ); result = 1; if ( a4d != 1 ) -LABEL_29: result = 0; return result; } @@ -3892,10 +3891,37 @@ { v5 = v4 - 15; if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 ) - goto LABEL_11; + { + v4 += 16; + --v34; + if ( !v34 ) + return this->uNumVertices = v38; + continue; + } if ( *(float *)v5 <= (double)a2 ) - break; - if ( *(float *)(v4 + 1) <= (double)a2 ) + { + v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); + v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; + v36 = v6; + v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); + v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); + *(float *)&v37 = (double)v7 * v6; + v8 = *(float *)&v37 + 6.7553994e15; + v9 = (unsigned __int8)*v4; + *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; + v10 = *(float *)&v37 + 6.7553994e15; + v11 = (unsigned __int8)*(v4 - 2); + v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); + v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; + v12 = v39 + 6.7553994e15; + v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); + v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; + v14 = v39 + 6.7553994e15; + v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); + //this = v35; + v5 = (char *)&v30 + 4; + } + else if ( *(float *)(v4 + 1) <= (double)a2 ) { v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); v16 = (unsigned __int8)*v4; @@ -3928,9 +3954,8 @@ v40 += 4; *v25 = *(int *)v26; v25[1] = *(int *)(v26 + 4); - goto LABEL_9; + v5 = (char *)&v30 + 4; } -LABEL_10: v27 = v40; ++v38; *v40 = *(int *)v5; @@ -3942,36 +3967,12 @@ v40 += 4; *v27 = *(int *)v28; v27[1] = *(int *)(v28 + 4); -LABEL_11: v4 += 16; --v34; if ( !v34 ) - goto LABEL_12; + return this->uNumVertices = v38; } - v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); - v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; - v36 = v6; - v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); - v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); - *(float *)&v37 = (double)v7 * v6; - v8 = *(float *)&v37 + 6.7553994e15; - v9 = (unsigned __int8)*v4; - *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; - v10 = *(float *)&v37 + 6.7553994e15; - v11 = (unsigned __int8)*(v4 - 2); - v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); - v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; - v12 = v39 + 6.7553994e15; - v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); - v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; - v14 = v39 + 6.7553994e15; - v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); -LABEL_9: - //this = v35; - v5 = (char *)&v30 + 4; - goto LABEL_10; - } -LABEL_12: + } return this->uNumVertices = v38; } @@ -4037,10 +4038,37 @@ { v5 = v4 - 15; if ( *(float *)(v4 - 15) >= (double)a2 && *(float *)(v4 + 1) >= (double)a2 ) - goto LABEL_11; + { + v4 += 16; + --v34; + if ( !v34 ) + return this->uNumVertices = v38; + continue; + } if ( *(float *)v5 >= (double)a2 ) - break; - if ( *(float *)(v4 + 1) >= (double)a2 ) + { + v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); + v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; + v36 = v6; + v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); + v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); + *(float *)&v37 = (double)v7 * v6; + v8 = *(float *)&v37 + 6.7553994e15; + v9 = (unsigned __int8)*v4; + *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; + v10 = *(float *)&v37 + 6.7553994e15; + v11 = (unsigned __int8)*(v4 - 2); + v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); + v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; + v12 = v39 + 6.7553994e15; + v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); + v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; + v14 = v39 + 6.7553994e15; + v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); + //this = v35; + v5 = (char *)&v30 + 4; + } + else if ( *(float *)(v4 + 1) >= (double)a2 ) { v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); v16 = (unsigned __int8)*v4; @@ -4073,9 +4101,8 @@ v40 += 4; *v25 = *(int *)v26; v25[1] = *(int *)(v26 + 4); - goto LABEL_9; + v5 = (char *)&v30 + 4; } -LABEL_10: v27 = v40; ++v38; *v40 = *(int *)v5; @@ -4087,36 +4114,12 @@ v40 += 4; *v27 = *(int *)v28; v27[1] = *(int *)(v28 + 4); -LABEL_11: v4 += 16; --v34; if ( !v34 ) - goto LABEL_12; + return this->uNumVertices = v38; } - v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); - v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; - v36 = v6; - v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); - v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); - *(float *)&v37 = (double)v7 * v6; - v8 = *(float *)&v37 + 6.7553994e15; - v9 = (unsigned __int8)*v4; - *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; - v10 = *(float *)&v37 + 6.7553994e15; - v11 = (unsigned __int8)*(v4 - 2); - v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); - v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; - v12 = v39 + 6.7553994e15; - v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); - v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; - v14 = v39 + 6.7553994e15; - v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); -LABEL_9: - //this = v35; - v5 = (char *)&v30 + 4; - goto LABEL_10; - } -LABEL_12: + } return this->uNumVertices = v38; } @@ -4302,7 +4305,10 @@ } v4 = a1->uNumVertices; if ( v4 <= 0 ) - goto LABEL_16; + { + memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); + return v2->uNumVertices != 0; + } v5 = (char *)&a1->field_14[20]; v6 = v4; do @@ -4325,7 +4331,6 @@ v2->_477927(v10); return v2->uNumVertices != 0; } -LABEL_16: memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); return v2->uNumVertices != 0; } @@ -4909,12 +4914,10 @@ { v3 = v2->pFacePlane.vNormal.x; v4 = -v2->pFacePlane.vNormal.y; -LABEL_9: v5 = 0; v11 = 65536; - goto LABEL_5; - } - if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 ) + } + else if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 ) { thisa.x = -v2->pFacePlane.vNormal.y; thisa.y = v2->pFacePlane.vNormal.x; @@ -4922,13 +4925,16 @@ thisa.Normalize_float(); v4 = thisa.x; v3 = thisa.y; - goto LABEL_9; - } - v3 = 0; - v4 = 65536; - v11 = 0; - v5 = -65536; -LABEL_5: + v5 = 0; + v11 = 65536; + } + else + { + v3 = 0; + v4 = 65536; + v11 = 0; + v5 = -65536; + } v6 = v11; sTextureDeltaU = v2->sTextureDeltaU; v7 = v3; @@ -5611,8 +5617,8 @@ //int v5; // eax@8 //SpawnPointMM7 *v6; // edx@14 size_t v7; // eax@19 - char *v8; // eax@19 - char *v9; // eax@21 + //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 @@ -5621,7 +5627,7 @@ pFilename = pLevelFilename; thisa->AllocSoftwareDrawBuffers(); pOutdoorCamera->_485F64(); - pWeather->bRenderSnow = 0; + pWeather->bRenderSnow = false; pRenderer->ClearZBuffer(0, 479); thisa = (OutdoorCamera *)1; GetAlertStatus(); @@ -5691,22 +5697,16 @@ pOutdoor->UpdateSunlightVectors(); pOutdoorCamera->int_fov_rad = (signed __int64)pIndoorCamera->flt_1C_fov; pOutdoorCamera->int_fov_rad_inv = (signed __int64)pIndoorCamera->flt_20_inv_1C; - v8 = (char *)&array_77EC08[0].ptr_38; - do - { - *(int *)v8 = (int)&stru_8019C8; - v8 += 268; - } - while ( (signed int)v8 < (signed int)&unk_801A00 ); - v9 = (char *)&array_77EC08[0].prolly_tail; - do - { - *((int *)v9 - 1) = 0; - *(int *)v9 = 0; - *((int *)v9 - 5) = 0; - v9 += 268; - } - while ( (signed int)v9 < (signed int)&unk_801A0C ); + + for (int i = 0; i < 20000; ++i) + { + array_77EC08[i].ptr_38 = &stru_8019C8; + + array_77EC08[i].prolly_head = nullptr; + array_77EC08[i].prolly_tail = nullptr; + array_77EC08[i].ptr_48 = nullptr; + } + MM7Initialization(); } @@ -5748,146 +5748,39 @@ return v1; } -//----- (0047BC6F) -------------------------------------------------------- -unsigned __int16 *__fastcall GetBillboardPalette(RenderBillboard *a1, int a2, signed int a3, int a4) -{ - int v4; // ebx@1 - int v6; // edx@4 - int v7; // ecx@5 - signed int v8; // eax@6 - signed __int64 v9; // qtt@11 - signed int v10; // eax@12 - int v11; // esi@17 - signed __int64 v12; // qtt@19 - double v13; // ST10_8@19 - int v14; // edi@25 - signed int v15; // edx@26 - signed __int64 v16; // qtt@29 - signed int v17; // eax@30 - int v18; // [sp+10h] [bp-8h]@1 - float a3a; // [sp+20h] [bp+8h]@19 - - v4 = a2; - v18 = a2; - if ( pParty->armageddon_timer ) - return PaletteManager::Get(a2); - if ( !pWeather->bNight ) - { - if (day_attrib & DAY_ATTRIB_FOG) - { - v14 = day_fogrange_1 << 16; - if ( a3 >= day_fogrange_1 << 16 ) - { - if ( a3 <= day_fogrange_2 << 16 ) - { - LODWORD(v16) = (a3 - v14) << 16; - HIDWORD(v16) = (a3 - v14) >> 16; - v15 = (unsigned __int64)(27 * v16 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16; - } - else - { - v15 = 27; - } - } - else - { - v15 = 0; - } - v17 = _43F55F_get_billboard_light_level(a1, v15); - if ( v17 > 27 ) - v17 = 27; - if ( !a3 ) - v17 = 27; - v7 = v18; - v6 = v17; - return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); - } - v11 = a4; - if ( a4 < 0 ) - v11 = 0; - LODWORD(v12) = a3 << 16; - HIDWORD(v12) = a3 >> 16; - a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20) - * pOutdoor->fFogDensity; - v13 = a3a + 6.7553994e15; - v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11); - if ( v10 > 27 ) - v10 = 27; - if ( v10 < a4 ) - v10 = a4; - if ( v10 > pOutdoor->max_terrain_dimming_level ) - v10 = pOutdoor->max_terrain_dimming_level; - return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); - } - v6 = 0; - if (pWeather->bNight) - { - v8 = 67108864; - if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) - v8 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower << 26; - if ( a3 <= v8 ) - { - if ( a3 > 0 ) - { - LODWORD(v9) = a3 << 16; - HIDWORD(v9) = a3 >> 16; - v6 = (unsigned __int64)(27 * v9 / v8) >> 16; - } - } - else - { - v6 = 27; - } - v10 = _43F55F_get_billboard_light_level(a1, v6); - if ( v10 > 27 || !a3 ) - v10 = 27; - return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); - } - v7 = 0; - return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); -} //----- (0047C370) -------------------------------------------------------- -unsigned int __cdecl GetLevelFogColor() +unsigned int GetLevelFogColor() { - unsigned int result; // eax@2 signed __int64 v1; // qax@5 int v2; // eax@6 - if ( bUnderwater ) - { - result = 0xFF258F5C; - } - else - { - if (day_attrib & DAY_ATTRIB_FOG) - { + if (bUnderwater) + return 0xFF258F5C; + + if (day_attrib & DAY_ATTRIB_FOG) + { if ( pWeather->bNight ) // night-time fog { - __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad + __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad v2 = -(pWeather->bNight != 1); - result = (v2 & 0xE0E0E1) - 0xE0E0E1; + return (v2 & 0xE0E0E1) - 0xE0E0E1; } else { v1 = (signed __int64)((1.0 - pOutdoor->fFogDensity) * 200.0 + pOutdoor->fFogDensity * 31.0); - result = v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); + return v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); } - } - else - return 0; - } - return result; + } + + return 0; } -// 6BE030: using guessed type int day_attrib; -// 6BE3C4: using guessed type char bUnderwater; //----- (0047C3D7) -------------------------------------------------------- int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3) { int v3; // ecx@1 double v5; // st7@10 - signed int v6; // esi@10 signed int v7; // ecx@11 double v8; // st6@12 double v9; // st7@15 @@ -5903,44 +5796,73 @@ if ( v3 ) { v5 = (double)day_fogrange_1; - v6 = 216; if ( a3 < v5 ) - goto LABEL_11; - v8 = (double)day_fogrange_2; - if ( a3 > v8 ) - { -LABEL_13: - v7 = v6; - goto LABEL_19; - } - v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0); + { + v7 = 0; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; + } + else + { + v8 = (double)day_fogrange_2; + if ( a3 > v8 ) + { + v7 = 216; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; + } + v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0); + } } else { v9 = (double)day_fogrange_1; - v6 = 216; if ( a3 < v9 ) { -LABEL_11: v7 = 0; - goto LABEL_19; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; } - v10 = (double)day_fogrange_2; - if ( a3 > v10 ) - goto LABEL_13; - v11 = (a3 - v9) * 216.0 / (v10 - v9); - v12 = v11 + 6.7553994e15; - v7 = LODWORD(v12); - } - if ( v7 > v6 ) - { -LABEL_20: - v7 = v6; - goto LABEL_21; - } -LABEL_19: - if ( a3 == 0.0 ) - goto LABEL_20; + else + { + v10 = (double)day_fogrange_2; + if ( a3 > v10 ) + { + v7 = 216; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; + } + else + { + v11 = (a3 - v9) * 216.0 / (v10 - v9); + v12 = v11 + 6.7553994e15; + v7 = LODWORD(v12); + } + } + } + if ( v7 > 216 ) + { + v7 = 216; + } + else + { + if ( a3 == 0.0 ) + { + v7 = 216; + } + } LABEL_21: if ( a2 ) v7 = 248; @@ -6088,16 +6010,17 @@ // 6BE3C4: using guessed type char bUnderwater; //----- (0047F44B) -------------------------------------------------------- -unsigned int __stdcall WorldPosToGridCellX(signed int sWorldPosX) +unsigned int WorldPosToGridCellX(int sWorldPosX) { - return (sWorldPosX / 512) + 64; + return (sWorldPosX >> 9) + 64; // sar is in original exe, resulting -880 / 512 = -1 + // and -880 sar 9 = -2 } -// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); //----- (0047F458) -------------------------------------------------------- -unsigned int __stdcall WorldPosToGridCellZ(signed int sWorldPosZ) +unsigned int WorldPosToGridCellZ(int sWorldPosZ) { - return 64 - (sWorldPosZ / 512); + return 64 - (sWorldPosZ >> 9); // sar is in original exe, resulting -880 / 512 = -1 + // and -880 sar 9 = -2 } //----- (0047F469) -------------------------------------------------------- @@ -6112,56 +6035,6 @@ return (64 - a1) << 9; } -//----- (0047F4D3) -------------------------------------------------------- -void __fastcall sub_47F4D3(int band1, int band2, int band3) -{ - int v3; // edi@1 - //stru220 *v4; // esi@1 - double v5; // ST2C_8@3 - double v6; // st7@3 - //double v7; // [sp+18h] [bp-28h]@3 - //double v8; // [sp+20h] [bp-20h]@2 - int v9; // [sp+34h] [bp-Ch]@1 - int v10; // [sp+38h] [bp-8h]@1 - //signed int band3a; // [sp+48h] [bp+8h]@2 - - v9 = band2 * 512; - pOutdoorCamera->outdoor_grid_band_3 = band3; - v10 = band1 * 512; - v3 = band3 * 512; - pOutdoorCamera->uPickDepth = band3 * 512; - //v4 = stru_76E5C8; // v4: 0 -> 65536 - for (uint i = 0; i < 16384; ++i) - //do - { - auto v4 = stru_76E5C8[i]; - //band3a = 256; - //v8 = (double)(signed int)((char *)v4 + 256 - (int)stru_76E5C8); - for (uint j = 0; j < 128; ++j) // band3a: 0 -> 128 - { - v5 = pow(j * 512 + 256, 2.0); - v6 = pow(i * 4 + 256, 2.0); - //*((float *)&v5 + 1) = sqrt(v6 + v5); - int v7 = floorf(sqrtf(v5 + v6) + 0.5f);//*((float *)&v5 + 1) + 6.7553994e15; - if (v7 >= v10) - { - if (v7 >= v9) - v4.field_0 = ((v7 >= v3) - 1) & 2; - else - v4.field_0 = 2; - } - else - { - v4.field_0 = 1; - } - //band3a += 512; - v4.distance = v7; - //++v4; - } - //while ( band3a < 65792 ); - } - //while ( (signed int)v4 < (signed int)arary_77E5C8 ); -} //----- (004811A3) -------------------------------------------------------- void Polygon::DrawBorderTiles() @@ -6178,24 +6051,15 @@ //----- (00481EB7) -------------------------------------------------------- -void __cdecl ResetPolygons() +void ResetPolygons() { - int v0; // ecx@1 - char *v1; // eax@2 - - v0 = pOutdoorCamera->uNumPolygons; - if ( pOutdoorCamera->uNumPolygons > 0 ) - { - v1 = (char *)&array_77EC08[0].prolly_tail; - do - { - *((int *)v1 - 1) = 0; - *(int *)v1 = 0; - *((int *)v1 - 5) = 0; - v1 += 268; - --v0; - } - while ( v0 ); + for (auto i = 0; i < pOutdoorCamera->uNumPolygons; ++i) + { + array_77EC08[i].prolly_head = nullptr; + array_77EC08[i].prolly_tail = nullptr; + + array_77EC08[i].flags = 0; + array_77EC08[i].field_32 = 0; } } @@ -6211,70 +6075,6 @@ pOutdoorCamera->field_44 = 0; } -//----- (00481EFA) -------------------------------------------------------- -bool __fastcall sub_481EFA(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5) -{ - RenderVertexSoft *v5; // esi@1 - RenderVertexSoft *v6; // edx@1 - bool v7; // edi@2 - bool v8; // ecx@5 - bool v9; // esi@8 - bool v10; // eax@11 - double v11; // st7@14 - signed int v12; // esi@15 - signed int v13; // edx@18 - signed int v14; // ecx@21 - signed int v15; // eax@24 - RenderVertexSoft *v17; // [sp+Ch] [bp-8h]@1 - - v5 = a2; - v6 = a1; - v17 = v5; - v7 = a1->vWorldViewPosition.x < 8.0; - v8 = v5->vWorldViewPosition.x < 8.0; - v9 = a3->vWorldViewPosition.x < 8.0; - v10 = a4->vWorldViewPosition.x < 8.0; - return !(v8 & v9 & v10 & v7) - && ((v11 = (double)pOutdoorCamera->shading_dist_mist, v11 > v6->vWorldViewPosition.x) ? (v12 = 0) : (v12 = 1), - v11 > v17->vWorldViewPosition.x ? (v13 = 0) : (v13 = 1), - v11 > a3->vWorldViewPosition.x ? (v14 = 0) : (v14 = 1), - v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1), - !(v13 & v14 & v15 & v12)); -} - -//----- (00481FC9) -------------------------------------------------------- -int __fastcall sub_481FC9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4)//Rotate camera -{ - float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14; - - if (a1->vWorldPosition.y == a2->vWorldPosition.y && a2->vWorldPosition.y == a3->vWorldPosition.y) - a4->flags |= 0x10; - var_c = a1->vWorldViewPosition.x - a2->vWorldViewPosition.x; - var_14 = a1->vWorldViewPosition.y - a2->vWorldViewPosition.y; - arg_0 = a1->vWorldViewPosition.z - a2->vWorldViewPosition.z; - var_10 = a3->vWorldViewPosition.x - a2->vWorldViewPosition.x; - var_8 = a3->vWorldViewPosition.y - a2->vWorldViewPosition.y; - var_4 = a3->vWorldViewPosition.z - a2->vWorldViewPosition.z; - arg_4 = a3->vWorldPosition.y - a2->vWorldPosition.y; - if (((a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.x - a2->vWorldPosition.x) - (a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.y - a2->vWorldPosition.y)) * (pIndoorCamera->pos.y - a2->vWorldPosition.z) + - ((a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.y - a2->vWorldPosition.y) - (a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.z - a2->vWorldPosition.z)) * (pIndoorCamera->pos.x - a2->vWorldPosition.x) + - ((a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.z - a2->vWorldPosition.z) - (a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.x - a2->vWorldPosition.x)) * (pIndoorCamera->pos.z - a2->vWorldPosition.y) < 0) - { - arg_4 = var_4 * var_14 - var_8 * arg_0; - a4->v_18.x = floorf(arg_4 + 0.5f); - arg_4 = var_10 * arg_0 - var_4 * var_c; - a4->v_18.y = floorf(arg_4 + 0.5f); - arg_4 = var_8 * var_c - var_10 * var_14; - a4->v_18.z = floorf(arg_4 + 0.5f); - a4->_486089_normalize_v_18(); - arg_4 = -(a4->v_18.x * a2->vWorldViewPosition.x) - a4->v_18.y * a2->vWorldViewPosition.y - a4->v_18.z * a2->vWorldViewPosition.z; - a4->field_24 = floorf(arg_4 + 0.5f); - return true; - } - else - return false; -} - //----- (004823F4) -------------------------------------------------------- bool IsTerrainSlopeTooHigh(int pos_x, int pos_z) { @@ -6469,50 +6269,28 @@ } //----- (00486089) -------------------------------------------------------- -void Polygon::_486089_normalize_v_18() +void Polygon::_normalize_v_18() { - //Polygon *v1; // esi@1 double v2; // st7@1 double v3; // st6@1 - float v4; // ST18_4@2 double v5; // st5@1 - float v6; // ST14_4@2 - double v7; // st7@1 - float v8; // ST24_4@2 - float v9; // ST20_4@2 - double v10; // ST0C_8@2 - float v11; // ST18_4@2 - double v12; // ST0C_8@2 - float v13; // ST14_4@2 - double v14; // ST0C_8@2 - float v15; // [sp+20h] [bp-8h]@1 //v1 = this; v2 = (double)this->v_18.x; - v15 = v2; v3 = (double)this->v_18.y; v5 = (double)this->v_18.z; - v7 = sqrt(v5 * v5 + v3 * v3 + v2 * v2); - if ( v7 == 0.0 ) - { - this->v_18.x = 0; - this->v_18.y = 0; - this->v_18.z = 65536; + float len = sqrt(v5 * v5 + v3 * v3 + v2 * v2); + if (fabsf(len) < 1e-6f) + { + v_18.x = 0; + v_18.y = 0; + v_18.z = 65536; } else { - v8 = 1.0 / v7; - v9 = v8 * v15 * 65536.0; - v10 = v9 + 6.7553994e15; - this->v_18.x = LODWORD(v10); - v4 = v3; - v11 = v8 * v4 * 65536.0; - v12 = v11 + 6.7553994e15; - this->v_18.y = LODWORD(v12); - v6 = v5; - v13 = v8 * v6 * 65536.0; - v14 = v13 + 6.7553994e15; - this->v_18.z = LODWORD(v14); + v_18.x = round(v2 / len * 65536.0); + v_18.y = round(v3 / len * 65536.0); + v_18.y = round(v5 / len * 65536.0); } } @@ -6651,58 +6429,6 @@ return result; } - -//----- (00440DF5) -------------------------------------------------------- -int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr) -{ - int result; // eax@1 - - pElements[uNumElements].field_6_rnd_value = a2; - pElements[uNumElements].field_8_rnd_value = a3; - pElements[uNumElements].field_A_rnd_value = a4; - pElements[uNumElements].field_C_time_left = rand() % 64 + 256; - pElements[uNumElements].field_E_time_to_live = pElements[uNumElements].field_C_time_left; - result = 3 * uNumElements; - pElements[uNumElements++].bgr16 = bgr; - if (uNumElements >= 100 ) - uNumElements = 0; - return result; -} - -//----- (00440E91) -------------------------------------------------------- -void stru167_wrap::_440E91(__int16 x, int y, int z, int a5, __int16 bgr) -{ - stru167_wrap *v6; // edi@1 - int i; // esi@1 - int v8; // ST08_4@2 - int v9; // ST04_4@2 - int v10; // eax@2 - - v6 = this; - for ( i = 0; i < rand() % 6 + 5; ++i ) - { - v8 = z + rand() % 33; - v9 = rand() % 33 + y - 16; - v10 = rand(); - Push(v10 % 33 + x - 16, v9, v8, a5, bgr); - } -} - -//----- (00440F07) -------------------------------------------------------- -void stru167_wrap::_440F07() -{ - for (uint i = 0; i < 100; ++i) - { - if (pElements[i].field_C_time_left > 0) - { - pElements[i].field_A_rnd_value += rand() % 5 + 4; - pElements[i].field_6_rnd_value += rand() % 5 - 2; - pElements[i].field_8_rnd_value += rand() % 5 - 2; - pElements[i].field_C_time_left -= (short)pEventTimer->uTimeElapsed; - } - } -} - //----- (0044100D) -------------------------------------------------------- bool sub_44100D() { @@ -6835,126 +6561,126 @@ { if ( !_strnicmp(test_string, "wea", 3) ) { - p2DEvents[i].uType = BildingType_WeaponShop; + p2DEvents[i].uType = BuildingType_WeaponShop; break; } if ( !_strnicmp(test_string, "arm", 3) ) { - p2DEvents[i].uType = BildingType_ArmorShop; + p2DEvents[i].uType = BuildingType_ArmorShop; break; } if ( !_strnicmp(test_string, "mag", 3) ) { - p2DEvents[i].uType = BildingType_MagicShop; + p2DEvents[i].uType = BuildingType_MagicShop; break; } if ( !_strnicmp(test_string, "alc", 3) ) { - p2DEvents[i].uType = BildingType_AlchemistShop; + p2DEvents[i].uType = BuildingType_AlchemistShop; break; } if ( !_strnicmp(test_string, "sta", 3) ) { - p2DEvents[i].uType = BildingType_Stables; + p2DEvents[i].uType = BuildingType_Stables; break; } if ( !_strnicmp(test_string, "boa", 3) ) { - p2DEvents[i].uType = BildingType_Boats; + p2DEvents[i].uType = BuildingType_Boats; break; } if ( !_strnicmp(test_string, "tem", 3) ) { - p2DEvents[i].uType = BildingType_Temple; + p2DEvents[i].uType = BuildingType_Temple; break; } if ( !_strnicmp(test_string, "tra", 3) ) { - p2DEvents[i].uType = BildingType_Training; + p2DEvents[i].uType = BuildingType_Training; break; } if ( !_strnicmp(test_string, "tow", 3) ) { - p2DEvents[i].uType = BildingType_TownHall; + p2DEvents[i].uType = BuildingType_TownHall; break; } if ( !_strnicmp(test_string, "tav", 3) ) { - p2DEvents[i].uType = BildingType_Tavern; + p2DEvents[i].uType = BuildingType_Tavern; break; } if ( !_strnicmp(test_string, "ban", 3) ) { - p2DEvents[i].uType = BildingType_Bank; + p2DEvents[i].uType = BuildingType_Bank; break; } if ( !_strnicmp(test_string, "fir", 3) ) { - p2DEvents[i].uType = BildingType_FireGuild; + p2DEvents[i].uType = BuildingType_FireGuild; break; } if ( !_strnicmp(test_string, "air", 3) ) { - p2DEvents[i].uType = BildingType_AirGuild; + p2DEvents[i].uType = BuildingType_AirGuild; break; } if ( !_strnicmp(test_string, "wat", 3) ) { - p2DEvents[i].uType = BildingType_WaterGuild; + p2DEvents[i].uType = BuildingType_WaterGuild; break; } if ( !_strnicmp(test_string, "ear", 3) ) { - p2DEvents[i].uType = BildingType_EarthGuild; + p2DEvents[i].uType = BuildingType_EarthGuild; break; } if ( !_strnicmp(test_string, "spi", 3) ) { - p2DEvents[i].uType = BildingType_SpiritGuild; + p2DEvents[i].uType = BuildingType_SpiritGuild; break; } if ( !_strnicmp(test_string, "min", 3) ) { - p2DEvents[i].uType = BildingType_MindGuild; + p2DEvents[i].uType = BuildingType_MindGuild; break; } if ( !_strnicmp(test_string, "bod", 3) ) { - p2DEvents[i].uType = BildingType_BodyGuild; + p2DEvents[i].uType = BuildingType_BodyGuild; break; } if ( !_strnicmp(test_string, "lig", 3) ) { - p2DEvents[i].uType = BildingType_LightGuild; + p2DEvents[i].uType = BuildingType_LightGuild; break; } if ( !_strnicmp(test_string, "dar", 3) ) { - p2DEvents[i].uType = BildingType_DarkGuild; + p2DEvents[i].uType = BuildingType_DarkGuild; break; } if ( !_strnicmp(test_string, "ele", 3) ) { - p2DEvents[i].uType = BildingType_14; + p2DEvents[i].uType = BuildingType_14; break; } if ( !_strnicmp(test_string, "sel", 3) ) { - p2DEvents[i].uType = BildingType_15; + p2DEvents[i].uType = BuildingType_15; break; } if ( !_strnicmp(test_string, "mir", 3) ) { - p2DEvents[i].uType = BildingType_16; + p2DEvents[i].uType = BuildingType_16; break; } if ( !_strnicmp(test_string, "mer", 3) ) { - p2DEvents[i].uType = BildingType_TownHall; + p2DEvents[i].uType = BuildingType_TownHall; break; } - p2DEvents[i].uType = BildingType_18; + p2DEvents[i].uType = BuildingType_18; } break; @@ -7243,7 +6969,7 @@ } //----- (00444360) -------------------------------------------------------- -void __thiscall Level_LoadEvtAndStr(const char *pLevelName) +void Level_LoadEvtAndStr(const char *pLevelName) { char pContainerName[120]; // [sp+8h] [bp-98h]@1 @@ -7341,7 +7067,7 @@ } //----- (00444D80) -------------------------------------------------------- -signed int __cdecl GetTravelTime() +int GetTravelTime() { signed int v0; // esi@1
--- a/mm7_4.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/mm7_4.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -389,37 +389,41 @@ } v22 = 0; v38 = v5; - if ( v39 <= (signed int)v5 ) - goto LABEL_54; - v23 = 0; - do + if ( v39 > (signed int)v5 ) { - v24 = dword_720F20[v5 / 4]; - v25 = *(int *)((char *)dword_720F20.data() + v23); - if ( v24 == v25 ) - goto LABEL_50; - if ( v25 > a3 + 15 ) - { - if ( v24 >= v25 ) - goto LABEL_51; -LABEL_50: - v22 = v38; - v23 = v5; - goto LABEL_51; - } - if ( v24 > v25 && v24 <= a3 + 15 ) - goto LABEL_50; -LABEL_51: - ++v38; - v5 += 4; + v23 = 0; + do + { + v24 = dword_720F20[v5 / 4]; + v25 = *(int *)((char *)dword_720F20.data() + v23); + if ( v24 == v25 ) + { + v22 = v38; + v23 = v5; + } + else if ( v25 > a3 + 15 ) + { + if ( v24 < v25 ) + { + v22 = v38; + v23 = v5; + } + } + else if ( v24 > v25 && v24 <= a3 + 15 ) + { + v22 = v38; + v23 = v5; + } + ++v38; + v5 += 4; + } + while ( v38 < v39 ); + if ( v22 ) + { + *(int *)a4 = dword_720E80[v22] | (dword_720ED0[v22] << 6); + return dword_720F20[v22]; + } } - while ( v38 < v39 ); - if ( v22 ) - { - *(int *)a4 = dword_720E80[v22] | (dword_720ED0[v22] << 6); - return dword_720F20[v22]; - } -LABEL_54: *(int *)a4 = 0; return dword_720F20[v22]; } @@ -530,15 +534,8 @@ //----- (00487DA9) -------------------------------------------------------- void __cdecl sub_487DA9() { - char *v0; // eax@1 - - v0 = &array_77EC08[0].field_108; - do - { - *v0 = 0; - v0 += 268; - } - while ( (signed int)v0 < (signed int)&pVerticesSR_801A10[4] ); + for (int i = 0; i < 20000; ++i) + array_77EC08[i].field_108 = 0; } //----- (00487DBE) -------------------------------------------------------- @@ -585,9 +582,9 @@ v = v_replace; HSV2RGB(&r, &g, &b, h, s, v); - return (((uint)floorf(r * 255.0f + 0.5f) & 0xFF) << 16) | - (((uint)floorf(g * 255.0f + 0.5f) & 0xFF) << 8) | - ((uint)floorf(b * 255.0f + 0.5f) & 0xFF); + return (((uint)round(r * 255.0f) & 0xFF) << 16) | + (((uint)round(g * 255.0f) & 0xFF) << 8) | + (((uint)round(b * 255.0f) & 0xFF)); } //----- (0048B561) -------------------------------------------------------- @@ -1238,6 +1235,7 @@ || pPlayers[v12]->pPlayerBuffs[23].uExpireTime > 0 ) { v58 = 0; + v13->PlayEmotion(CHARACTER_EXPRESSION_37, v58); } else { @@ -1252,12 +1250,13 @@ strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[660]); GameUI_Footer_TimeLeft = 128; } - goto LABEL_39; } - v13 = pPlayers[v12]; + else + { + v13 = pPlayers[v12]; + v13->PlayEmotion(CHARACTER_EXPRESSION_37, v58); + } } - v13->PlayEmotion(CHARACTER_EXPRESSION_37, v58); -LABEL_39: ++v12; if ( v12 > 4 ) { @@ -1306,18 +1305,19 @@ if ( v21->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) + v22 + v21->uEndurance >= 1 || (signed __int64)v21->pPlayerBuffs[11].uExpireTime > 0 ) { - if ( v22 >= 1 ) - goto LABEL_59; - v59 = 0; - v56 = 13; + if ( v22 < 1 ) + { + v59 = 0; + v56 = 13; + v21->SetCondition(v56, v59); + } } else { v59 = 0; v56 = 14; + v21->SetCondition(v56, v59); } - v21->SetCondition(v56, v59); -LABEL_59: v23 = (int)&v21->field_E0; if ( v21->field_E0 ) { @@ -1605,7 +1605,6 @@ result = 0; if ( (signed int)this->uNumFrames <= 0 ) { -LABEL_5: result = 0; } else @@ -1616,7 +1615,7 @@ ++result; ++v4; if ( (signed int)result >= (signed int)_uNumFrames ) - goto LABEL_5; + return 0; } } return result; @@ -1858,7 +1857,11 @@ dword_AE336C = a1; v10 = 0; if ( (signed int)pNPCStats->uNumNPCNames[v4] <= 0 ) - goto LABEL_17; + { + v3 = rand() % (signed int)pNPCStats->uNumNPCNames[v4]; + } + else + { v9 = (int **)((char *)pNPCStats->pNPCNames + v4 * 4); do { @@ -1877,8 +1880,8 @@ if ( v8 && v8 != v7 ) v3 = v8 + rand() % (v7 - v8); else -LABEL_17: v3 = rand() % (signed int)pNPCStats->uNumNPCNames[v4]; + } } dword_AE3370 = v3; return pNPCStats->pNPCNames[0][v11 + 2 * v3]; @@ -1902,7 +1905,7 @@ } //----- (00495461) -------------------------------------------------------- -char *BuilDialogueString(char *lpsz, unsigned __int8 uPlayerID, ItemGen *a3, char *a4, int a5, __int64 *a6) +char *BuildDialogueString(char *lpsz, unsigned __int8 uPlayerID, ItemGen *a3, char *a4, int a5, __int64 *a6) { unsigned __int8 v6; // bl@1 Player *pPlayer; // ebx@3 @@ -2100,10 +2103,34 @@ goto _continue_strcat; case 11: v25 = GetPartyReputation(); - goto LABEL_46; + if ( v25 >= 25 ) + { + v11 = pGlobalTXT_LocalizationStrings[379]; + } + else + { + if ( v25 < 6 ) + { + if ( v25 >= -5 ) + { + v11 = pGlobalTXT_LocalizationStrings[399]; + } + else + { + if ( v25 < -24 ) + v11 = pGlobalTXT_LocalizationStrings[434]; + else + v11 = pGlobalTXT_LocalizationStrings[402]; + } + } + else + { + v11 = pGlobalTXT_LocalizationStrings[392]; + } + } + goto _continue_strcat; case 12: v25 = npc->rep; -LABEL_46: if ( v25 >= 25 ) { v11 = pGlobalTXT_LocalizationStrings[379]; @@ -3258,14 +3285,17 @@ v11 += 37; } while ( v9 < 4 ); + __debugbreak(); // warning C4700: uninitialized local variable 'v29' used if ( v29 == v14 ) { v25 = pClassNames[v10 + 1]; } else { + __debugbreak(); // warning C4700: uninitialized local variable 'v30' used if ( v30 == v14 )//crash { + __debugbreak(); // warning C4700: uninitialized local variable 'v31' used if ( v31 == v14 ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[634], pClassNames[v10 + 2], pClassNames[v10 + 3]);// %s %s . @@ -3536,249 +3566,6 @@ return pTmpBuf2.data(); } -//----- (004B3A72) -------------------------------------------------------- -void sub_4B3A72( int a1 ) - { - int num_buttons; // esi@1 - - num_buttons = 0; - if ( a1 == 21 ) - { - CreateButtonInColumn(0, 0x66u); - num_buttons = 2; - CreateButtonInColumn(1, 0x67u); - if ( pParty->HasItem(651) ) //Arcomage Deck - { - num_buttons = 3; - CreateButtonInColumn(2, 0x68u); - } - } - pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2); - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; -} -// F8B1E0: using guessed type int dword_F8B1E0; - -//----- (004B3AD4) -------------------------------------------------------- -void sub_4B3AD4( signed int a1 ) - { - if ( a1 > 0 ) - { - if ( a1 <= 3 ) - { - CreateButtonInColumn(0, 3u); - CreateButtonInColumn(1, 4u); - CreateButtonInColumn(2, 5u); - pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); - } - if ( a1 == 4 ) - { - CreateButtonInColumn(0, 3u); - CreateButtonInColumn(1, 4u); - pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); - } - } - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; -} -// F8B1E0: using guessed type int dword_F8B1E0; - -//----- (004B3B42) -------------------------------------------------------- -void sub_4B3B42( signed int a1 ) - { - int v1; // ecx@18 - int v2; // ecx@19 - int v3; // ecx@20 - signed int v4; // esi@22 - signed int v5; // eax@22 - unsigned int v6; // edx@24 - int v7; // ecx@24 - int result; // eax@43 - int v9; // [sp-10h] [bp-14h]@28 - int v10; // [sp-Ch] [bp-10h]@28 - int v11; // [sp-8h] [bp-Ch]@28 - unsigned int v12; // [sp-4h] [bp-8h]@4 - unsigned int v13; // [sp-4h] [bp-8h]@5 - unsigned int v14; // [sp-4h] [bp-8h]@9 - unsigned int v15; // [sp-4h] [bp-8h]@10 - unsigned int v16; // [sp-4h] [bp-8h]@14 - int v17; // [sp-4h] [bp-8h]@28 - - if ( a1 > 13 ) - { - if ( a1 > 22 ) - { - if ( a1 == 23 ) - { - CreateButtonInColumn(0, 0xAu); - CreateButtonInColumn(1, 0xBu); - v14 = 96; -LABEL_41: - CreateButtonInColumn(2, v14); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 3; - goto LABEL_42; - } - if ( a1 <= 26 ) - goto LABEL_43; - if ( a1 > 28 ) - { - if ( a1 != 30 ) - goto LABEL_43; - CreateButtonInColumn(0, 0x11u); - v16 = 96; - goto LABEL_37; - } - CreateButtonInColumn(0, 0x69u); - CreateButtonInColumn(1, 0x6Au); - CreateButtonInColumn(2, 0x6Bu); - v12 = 108; - } - else - { - if ( a1 == 22 ) - { - CreateButtonInColumn(0, 7u); - v16 = 8; - goto LABEL_37; - } - v1 = a1 - 14; - if ( !v1 ) - { - CreateButtonInColumn(0, 0x12u); - CreateButtonInColumn(1, 0x30u); - CreateButtonInColumn(2, 0x31u); - CreateButtonInColumn(3, 0x32u); - CreateButtonInColumn(4, 0x33u); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 5; - goto LABEL_42; - } - v2 = v1 - 1; - if ( v2 ) - { - v3 = v2 - 2; - if ( v3 ) - { - if ( v3 != 4 ) - goto LABEL_43; - CreateButtonInColumn(0, 0xFu); - CreateButtonInColumn(1, 0x10u); - v4 = 3; - CreateButtonInColumn(2, 0x60u); - v5 = (signed int)window_SpeakInHouse->ptr_1C; - if ( v5 < 108 || v5 > 120 ) - goto LABEL_28; - v4 = 4; - v6 = 101; - v7 = 3; - } - else - { - v4 = 1; - CreateButtonInColumn(0, 0x63u); - if ( !pParty->uFine ) - { -LABEL_28: - v17 = 2; - v11 = 0; - v10 = 1; - v9 = v4; -LABEL_42: - pDialogueWindow->_41D08F_set_keyboard_control_group(v9, v10, v11, v17); - goto LABEL_43; - } - v4 = 2; - v7 = 1; - v6 = 100; - } - CreateButtonInColumn(v7, v6); - goto LABEL_28; - } - CreateButtonInColumn(0, 0x12u); - CreateButtonInColumn(1, 0x34u); - CreateButtonInColumn(2, 0x35u); - v12 = 54; - } -LABEL_39: - CreateButtonInColumn(3, v12); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 4; - goto LABEL_42; - } - if ( a1 == 13 ) - { - CreateButtonInColumn(0, 0x12u); - v16 = 56; -LABEL_37: - CreateButtonInColumn(1, v16); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 2; - goto LABEL_42; - } - switch ( a1 ) - { - case 1: - case 2: - case 3: - case 4: - CreateButtonInColumn(0, 2u); - CreateButtonInColumn(1, 0x5Fu); - CreateButtonInColumn(2, 0x5Eu); - v12 = 96; - goto LABEL_39; - case 5: - CreateButtonInColumn(0, 0x12u); - v13 = 48; - goto LABEL_9; - case 6: - CreateButtonInColumn(0, 0x12u); - v13 = 49; - goto LABEL_9; - case 7: - CreateButtonInColumn(0, 0x12u); - v13 = 50; - goto LABEL_9; - case 8: - CreateButtonInColumn(0, 0x12u); - v13 = 51; -LABEL_9: - CreateButtonInColumn(1, v13); - v14 = 72; - goto LABEL_41; - case 9: - CreateButtonInColumn(0, 0x12u); - v15 = 52; - goto LABEL_13; - case 10: - CreateButtonInColumn(0, 0x12u); - v15 = 53; - goto LABEL_13; - case 11: - CreateButtonInColumn(0, 0x12u); - v15 = 54; -LABEL_13: - CreateButtonInColumn(1, v15); - v14 = 61; - goto LABEL_41; - case 12: - CreateButtonInColumn(0, 0x12u); - v16 = 55; - goto LABEL_37; - default: - break; - } -LABEL_43: - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; -} -// F8B1E0: using guessed type int dword_F8B1E0; - //----- (004B3E1E) -------------------------------------------------------- void __cdecl sub_4B3E1E() { @@ -3808,7 +3595,8 @@ { int v1; // edi@1 char *v2; // edi@1 - + + __debugbreak(); v1 = a4; uDialogueType = 78; current_npc_text = (char *)pNPCTopics[a4 + 168].pText; @@ -3830,7 +3618,7 @@ //----- (004B46A5) -------------------------------------------------------- void __fastcall DrawTextAtStatusBar( const char *Str, int a5 ) - { +{ int v4; // eax@1 pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar); v4 = pFontLucida->AlignText_Center(450, Str); @@ -3974,19 +3762,17 @@ ArenaFight(); return; } - else if(newDialogueType == DIALOGUE_9) + else if(newDialogueType == DIALOGUE_USE_NPC_ABILITY) { - if ( !sub_4BB756(speakingNPC->uProfession) ) + if (UseNPCSkill((NPCProf)speakingNPC->uProfession) == 0) { - if ( speakingNPC->uProfession != 41 ) + if ( speakingNPC->uProfession != GateMaster ) speakingNPC->bHasUsedTheAbility = 1; pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); } else - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u); //"Your packs are already full!" - } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2); //"Your packs are already full!" } else if(newDialogueType == DIALOGUE_13) { @@ -4090,22 +3876,22 @@ return 0; switch( p2DEvents[_2da_idx - 1].uType ) { - case BildingType_WeaponShop: + case BuildingType_WeaponShop: { test = pItemsTable->pItems[item->uItemID].uEquipType <= 2; break; } - case BildingType_ArmorShop: + case BuildingType_ArmorShop: { test = pItemsTable->pItems[item->uItemID].uEquipType >= 3; break; } - case BildingType_MagicShop: + case BuildingType_MagicShop: { test = pItemsTable->pItems[item->uItemID].uSkillType == 38 || pItemsTable->pItems[item->uItemID].uEquipType == 16; break; } - case BildingType_AlchemistShop: + case BuildingType_AlchemistShop: { test = pItemsTable->pItems[item->uItemID].uEquipType == 13 || pItemsTable->pItems[item->uItemID].uEquipType == 14 || (pItemsTable->pItems[item->uItemID].uEquipType > 14 && !(pItemsTable->pItems[item->uItemID].uEquipType != 17
--- a/mm7_5.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/mm7_5.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -2198,6 +2198,7 @@ default: if ( uMessageParam != 5 ) { + __debugbreak(); // warning C4700: uninitialized local variable 'v200' used sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v200); GameUI_SetFooterString(pTmpBuf.data()); continue; @@ -2264,7 +2265,7 @@ GameUI_SetFooterString(pTmpBuf.data()); continue; case UIMSG_ShowFinalWindow: - sprintf(pFinalMessage.data(), "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer." + sprintfex(pFinalMessage.data(), "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer." pGlobalTXT_LocalizationStrings[118],// "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment." pGlobalTXT_LocalizationStrings[167]);// "- The Might and Magic VII Development Team." ModalWindow(pFinalMessage.data(), 196); @@ -2568,7 +2569,7 @@ pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->EncM2percent) + 2); else pNPCData4 = (NPCData *)1; - if ( !sub_45063B(pMapInfo, (int)pNPCData4) ) + if ( !_45063B_spawn_some_monster(pMapInfo, (int)pNPCData4) ) pNPCData4 = 0; if ( pNPCData4 ) { @@ -3434,7 +3435,7 @@ case UIMSG_ChangeGameState: uGameState = GAME_FINISHED; break; - case UIMSG_11: + case UIMSG_ChangeCursor: pMouse->SetCursorBitmap("MICON2"); break; case UIMSG_3A: @@ -3582,6 +3583,7 @@ break; case UIMSG_PlayerCreationRemoveDownSkill: uPlayerCreationUI_SelectedCharacter = pParam; + __debugbreak(); pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(3) @@ -3598,13 +3600,10 @@ //----- (00436427) -------------------------------------------------------- double __cdecl get_shading_dist_mist() { - double result; // st7@2 - - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - result = (double)pOutdoorCamera->shading_dist_mist; + if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + return (double)pOutdoorCamera->shading_dist_mist; else - result = 16192.0; - return result; + return 16192.0; } //----- (0043648F) -------------------------------------------------------- @@ -4713,7 +4712,7 @@ v19 = 0; v29 = 0; if ( v17 <= 0 ) - goto LABEL_29; + return 0; do { if ( a3a >= 2 ) @@ -4748,7 +4747,6 @@ while ( v29 < v28 ); result = 1; if ( a3a != 1 ) -LABEL_29: result = 0; return result; } @@ -4848,7 +4846,7 @@ v25 = 0; v16 = dword_4F5B24_ys[1] >= a3; if ( v15 <= 0 ) - goto LABEL_29; + return 0; do { if ( a5a >= 2 ) @@ -4883,7 +4881,6 @@ while ( v25 < v15 ); result = 1; if ( a5a != 1 ) -LABEL_29: result = 0; return result; } @@ -5194,14 +5191,22 @@ { v35 = v27->uAttributes; if ( v35 & 2 || (v51 & 0x80000000u) != 0 || (signed int)v51 > 12 || (signed int)v28 >= 500 ) - goto LABEL_92; + { + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; + } LOWORD(v35) = v35 | 0x210; v27->uAttributes = v35; } else { if ( (signed int)pParty->pPickedItem.uItemID <= 245 ) - goto LABEL_92; + { + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; + } if ( (signed int)pParty->pPickedItem.uItemID <= 250 ) { v27->UpdateTempBonus(pParty->uTimePlayed); @@ -5212,7 +5217,11 @@ || v27->uEnchantmentType || v51 && v51 != 1 && v51 != 2 || (signed int)v33 >= 500 ) - goto LABEL_92; + { + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; + } v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4]; a2.y = (int)v29 << 7; v31 = (double)(signed int)((int)v29 << 7); @@ -5228,7 +5237,11 @@ || v27->uEnchantmentType || v51 && v51 != 1 && v51 != 2 || (signed int)v30 >= 500 ) - goto LABEL_92; + { + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; + } a2.y = (int)v29 << 7; v27->uSpecEnchantmentType = 40; v31 = (double)a2.y; @@ -5241,7 +5254,9 @@ v27->uAttributes = v32; } _50C9A8_item_enchantment_timer = 256; - goto LABEL_92; + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; } v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01; if ( v36 < 0.0 ) @@ -5255,7 +5270,9 @@ v37 = (signed __int64)((double)a2.y - v36 * (double)a2.y); v27->uMaxCharges = v37; v27->uNumCharges = (unsigned __int8)v37; - goto LABEL_92; + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; } v14 = v13 - 222; v15 = pParty->pPickedItem.uItemID - 222; @@ -5396,9 +5413,16 @@ if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) ) *(int *)(v22 + 552) |= 1u; if ( !dword_4E455C ) - goto LABEL_92; + { + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; + } v0->PlaySound(SPEECH_16, 0); - goto LABEL_91; + dword_4E455C = 0; + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; } if ( v45 ) { @@ -5437,10 +5461,8 @@ if ( v0->CanAct() ) v0->PlaySound(SPEECH_17, 0); ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u); -LABEL_91: dword_4E455C = 0; } -LABEL_92: pMouse->RemoveHoldingItem(); dword_50CDCC = 1; return; @@ -5530,4 +5552,5 @@ break; } assert(false); + return 0; } \ No newline at end of file
--- a/mm7_6.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/mm7_6.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -127,7 +127,20 @@ { v11 = 0; v12 = *(float *)v4 == *((float *)v7 - 5); - goto LABEL_19; + if ( ! (v12 | v11) ) + { + v26 += 48; + ++v24; + v25 += 48; + v27 += 48; + v28 += 48; + v5 += 48; + v4 += 48; + ++v22; + v23 += 48; + v21 = v5; + v20 = v4; + } } } else @@ -136,13 +149,22 @@ { v11 = 0; v12 = *(float *)v4 == *((float *)v7 + 7); -LABEL_19: - if ( v12 | v11 ) - goto LABEL_21; - goto LABEL_20; + if ( !(v12 | v11) ) + { + v26 += 48; + ++v24; + v25 += 48; + v27 += 48; + v28 += 48; + v5 += 48; + v4 += 48; + ++v22; + v23 += 48; + v21 = v5; + v20 = v4; + } } } -LABEL_20: v26 += 48; ++v24; v25 += 48; @@ -155,7 +177,6 @@ v21 = v5; v20 = v4; } -LABEL_21: if ( v19 ) { v13 = v24; @@ -328,28 +349,34 @@ v14 = 0; if ( v3 ) { - if ( !pActor->pMonsterInfo.uTreasureDiceRolls ) - goto LABEL_9; - do - { - ++v2; - v14 += rand() % pActor->pMonsterInfo.uTreasureDiceSides + 1; - } - while ( v2 < pActor->pMonsterInfo.uTreasureDiceRolls ); + if ( pActor->pMonsterInfo.uTreasureDiceRolls ) + { + do + { + ++v2; + v14 += rand() % pActor->pMonsterInfo.uTreasureDiceSides + 1; + } + while ( v2 < pActor->pMonsterInfo.uTreasureDiceRolls ); + if ( v14 ) + { + party_finds_gold(v14, 0); + viewparams->bRedrawGameUI = 1; + } + } } else { - if ( pItemsTable->pItems[pActor->array_000234[3].uItemID].uEquipType != 18 ) - goto LABEL_9; - v14 = pActor->array_000234[3].uSpecEnchantmentType; - pActor->array_000234[3].Reset(); + if ( pItemsTable->pItems[pActor->array_000234[3].uItemID].uEquipType == 18 ) + { + v14 = pActor->array_000234[3].uSpecEnchantmentType; + pActor->array_000234[3].Reset(); + if ( v14 ) + { + party_finds_gold(v14, 0); + viewparams->bRedrawGameUI = 1; + } + } } - if ( v14 ) - { - party_finds_gold(v14, 0); - viewparams->bRedrawGameUI = 1; - } -LABEL_9: if ( pActor->uCarriedItemID ) { Dst.Reset(); @@ -394,7 +421,6 @@ } pActor->array_000234[1].Reset(); } -LABEL_55: pActor->Remove(); return; } @@ -455,7 +481,9 @@ pActor->array_000234[1].Reset(); } if ( !v13 || rand() % 100 < 90 ) - goto LABEL_55; + { + pActor->Remove(); + } } //----- (00426E10) -------------------------------------------------------- @@ -624,7 +652,7 @@ } while ( v17 ^ v18 ); if ( v2 ) - goto LABEL_61; + return v23[rand() % v2]; } v19 = 0; do @@ -636,7 +664,6 @@ } while ( v19 < 4 ); if ( v2 ) -LABEL_61: result = v23[rand() % v2]; else result = 0; @@ -860,6 +887,8 @@ { v14 = a4 + v9; v15 = ((v7 + 15) >> 1) + v7 + 15; + v13 = __OFSUB__(v14, v15); + v12 = v14 - v15 < 0; } else { @@ -869,14 +898,15 @@ v11 = v7 + 15; v13 = __OFSUB__(v10, v11); v12 = v10 - v11 < 0; - goto LABEL_16; } - v14 = a4 + v9; - v15 = 2 * v7 + 30; + else + { + v14 = a4 + v9; + v15 = 2 * v7 + 30; + v13 = __OFSUB__(v14, v15); + v12 = v14 - v15 < 0; + } } - v13 = __OFSUB__(v14, v15); - v12 = v14 - v15 < 0; -LABEL_16: if ( v12 ^ v13 ) result = 0; else @@ -981,25 +1011,29 @@ break; case 0: v6 = pActor->pMonsterInfo.uResFire; - goto LABEL_12; + v4 = v5; + break; case 1: v6 = pActor->pMonsterInfo.uResAir; - goto LABEL_12; + v4 = v5; + break; case 2: v6 = pActor->pMonsterInfo.uResWater; - goto LABEL_12; + v4 = v5; + break; case 3: v6 = pActor->pMonsterInfo.uResEarth; - goto LABEL_12; + v4 = v5; + break; case 6: v6 = pActor->pMonsterInfo.uResSpirit; break; case 7: v6 = pActor->pMonsterInfo.uResMind; - goto LABEL_12; + v4 = v5; + break; case 8: v6 = pActor->pMonsterInfo.uResBody; -LABEL_12: v4 = v5; break; case 9: @@ -1050,52 +1084,41 @@ case 0u: v3 = pActor; v4 = pActor->pMonsterInfo.uResFire; - goto LABEL_12; case 1u: v3 = pActor; v4 = pActor->pMonsterInfo.uResAir; - goto LABEL_12; case 2u: v3 = pActor; v4 = pActor->pMonsterInfo.uResWater; - goto LABEL_12; case 3u: v3 = pActor; v4 = pActor->pMonsterInfo.uResEarth; - goto LABEL_12; case 7u: v3 = pActor; v4 = pActor->pMonsterInfo.uResMind; - goto LABEL_12; case 6u: v3 = pActor; v4 = pActor->pMonsterInfo.uResSpirit; - goto LABEL_12; case 8u: v3 = pActor; v4 = pActor->pMonsterInfo.uResBody; - goto LABEL_12; case 9u: v3 = pActor; v4 = pActor->pMonsterInfo.uResLight; - goto LABEL_12; case 0xAu: v3 = pActor; v4 = pActor->pMonsterInfo.uResDark; - goto LABEL_12; case 4u: v3 = pActor; v4 = pActor->pMonsterInfo.uResPhysical; -LABEL_12: - if ( v4 < 200 ) - result = rand() % (signed int)(((unsigned int)v3->pMonsterInfo.uLevel >> 2) + v4 + 30) < 30; - else - result = 0; break; default: - result = 1; - break; + return 1; } + if ( v4 < 200 ) + result = rand() % (signed int)(((unsigned int)v3->pMonsterInfo.uLevel >> 2) + v4 + 30) < 30; + else + result = 0; return result; } @@ -1549,7 +1572,6 @@ v13 = 0; if ( (signed int)uNumActors <= 0 ) { -LABEL_20: result = 0; } else @@ -1597,7 +1619,7 @@ ++v13; ++v1; if ( v13 >= (signed int)uNumActors ) - goto LABEL_20; + return 0; } result = 1; }
--- a/mm7_data.cpp Tue Jul 30 09:33:52 2013 +0600 +++ b/mm7_data.cpp Tue Jul 30 09:34:14 2013 +0600 @@ -231,9 +231,6 @@ 0x00000031, 0x00000031, 0x0000002D, 0x00000041 }}; -#include "stru220.h" -std::array<stru220, 16384> stru_76E5C8; - #include "stru176.h" stru176 array_5B5928_timers[100];
--- a/mm7_data.h Tue Jul 30 09:33:52 2013 +0600 +++ b/mm7_data.h Tue Jul 30 09:34:14 2013 +0600 @@ -1130,7 +1130,7 @@ void __cdecl nullsub_3(); // idb void __cdecl LoadActualSkyFrame(); void __cdecl Sleep6Hours(); -void __cdecl sub_42038D(); +void __cdecl ChestUI_WritePointedObjectStatusString(); void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal); // idb void OnChestLeftClick(); @@ -1146,7 +1146,7 @@ int __fastcall GetPortalScreenCoord(unsigned int uFaceID); signed int __fastcall sr_424579(int uFaceID, struct stru320 *a2); bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID); -signed int __fastcall sr_424CD7(unsigned int uVertexID); // idb +int sr_424CD7(unsigned int uVertexID); // idb signed int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID); // idb signed int __fastcall sr_4250FE(unsigned int uVertexID); // idb bool sr_42620A(struct RenderVertexSoft *p); @@ -1217,10 +1217,10 @@ void __cdecl OnMapLeave(); void /*__usercall*/ OnMapLoad(); -void __thiscall Level_LoadEvtAndStr(const char *pLevelName); +void Level_LoadEvtAndStr(const char *pLevelName); const char *__cdecl sub_444564(); char *__thiscall GetEventHintString(unsigned int uEventID); // idb -signed int __cdecl GetTravelTime(); +int GetTravelTime(); void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4); void __cdecl sub_4452BB(); const char *GetProfessionActionText(int a1); @@ -1256,7 +1256,7 @@ int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); 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); +int __fastcall _45063B_spawn_some_monster(struct MapInfo *a1, int a2); void RespawnGlobalDecorations(); bool __fastcall SpawnActor(unsigned int uMonsterID); int __cdecl GetAlertStatus(); @@ -1343,7 +1343,7 @@ bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2); void __cdecl check_event_triggers(); int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID); -int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int, int *pOnWater, int *a6, int bWaterWalk); +int ODM_GetFloorLevel(int X, signed int Y, int Z, int, int *pOnWater, int *bmodel_pid, int bWaterWalk); int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4); void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out); unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID); @@ -1376,21 +1376,17 @@ void __cdecl loc_47907F(); // idb bool __fastcall IsBModelVisible(unsigned int uModelID, int *unused); void __thiscall ODM_LoadAndInitialize(const char *pLevelFilename, struct OutdoorCamera *thisa); -unsigned __int16 *__fastcall GetBillboardPalette(struct RenderBillboard *a1, int a2, signed int a3, int a4); -unsigned int __cdecl GetLevelFogColor(); +unsigned int GetLevelFogColor(); int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3); signed int __fastcall GetActorTintColor(int max_dim, int min_dim, float distance, int a4, struct RenderBillboard *a5); -unsigned int __stdcall WorldPosToGridCellX(int); // weak -unsigned int __stdcall WorldPosToGridCellZ(int); // weak +unsigned int WorldPosToGridCellX(int); // weak +unsigned int WorldPosToGridCellZ(int); // weak int __stdcall GridCellToWorldPosX(int); // weak int __stdcall GridCellToWorldPosZ(int); // weak -void __fastcall sub_47F4D3(int band1, int band2, int band3); void __cdecl loc_48118F(); // idb void __cdecl loc_481199(); // idb -void __cdecl ResetPolygons(); +void ResetPolygons(); void __cdecl sub_481ED9_MessWithOutdoorCamera(); -bool __fastcall sub_481EFA(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5); -signed int __fastcall sub_481FC9(RenderVertexSoft *_ECX, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4); bool IsTerrainSlopeTooHigh(int pos_x, int pos_y); int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4); signed int __cdecl const_1_0(); @@ -1413,7 +1409,7 @@ unsigned int __fastcall _494820_training_time(unsigned int a1); char *__fastcall sub_495366(unsigned __int8 a1, unsigned __int8 a2); char *GetReputationString(signed int a1); -char *BuilDialogueString(char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6); +char *BuildDialogueString(char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6); void PlayerCreationUI_Draw(); void PlayerCreationUI_Initialize(); void DeleteCCharFont(); @@ -1448,9 +1444,6 @@ void SimpleHouseAndBoatsDialog(); void CreateButtonInColumn(int a1, unsigned int a2); void FillAviableSkillsToTeach(int _this); -void sub_4B3A72(int a1); // idb -void sub_4B3AD4(signed int a1); -void sub_4B3B42(signed int a1); void __cdecl sub_4B3E1E(); void DrawJoinGuildWindow(int pEventCode); void __fastcall sub_4B3FE5(int a4); @@ -1459,7 +1452,6 @@ void __fastcall DrawTextAtStatusBar(const char *Str, int a5); int __fastcall sub_4B46F8(int a1); -signed int __fastcall sub_4BB756(signed int a1); const char *sub_4BBA85_bounties(); void __cdecl sub_4BBCDD(); void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z); // idb
--- a/stru159.h Tue Jul 30 09:33:52 2013 +0600 +++ b/stru159.h Tue Jul 30 09:34:14 2013 +0600 @@ -9,7 +9,7 @@ char *video_name; int field_4; int house_npc_id; - unsigned __int8 uBuildingType; + unsigned __int8 uBuildingType; // enum BuildingType unsigned __int8 uRoomSoundId; unsigned __int16 padding_e; };
--- a/stru220.h Tue Jul 30 09:33:52 2013 +0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#pragma once - - - -/* 210 */ -#pragma pack(push, 1) -struct stru220 -{ - __int16 field_0;//char field_0; - //char field_1; - __int16 distance; -}; -#pragma pack(pop) -extern std::array<stru220, 16384> stru_76E5C8; \ No newline at end of file