Mercurial > mm7
changeset 1435:94e4c3ef9b8e
Слияние
author | Ritor1 |
---|---|
date | Fri, 05 Jul 2013 21:16:12 +0600 |
parents | 03d6ea33a8c9 (current diff) 8bfdc44cebfd (diff) |
children | 883fea17dd9a |
files | UI/UIHouses.cpp |
diffstat | 42 files changed, 4918 insertions(+), 4967 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/Actor.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -29,7 +29,6 @@ #include "LOD.h" #include "Party.h" #include "GUIWindow.h" -#include "GUIFont.h" #include "MM7.h" #include "SpriteObject.h" @@ -1619,243 +1618,198 @@ AIDirection *__fastcall Actor::GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, AIDirection *pOut, int a4) { signed int v4; // eax@1 - unsigned int v5; // ecx@1 - unsigned int v6; // ebx@1 + signed int v5; // ecx@1 + //unsigned int v6; // ebx@1 int v7; // ecx@2 int v8; // ecx@3 int v9; // ecx@4 - BLVFace *v10; // eax@8 - unsigned int v11; // ecx@8 - signed int v12; // eax@9 - int v13; // ecx@9 - int v14; // eax@9 + //BLVFace *v10; // eax@8 + //unsigned int v11; // ecx@8 + //signed int v12; // eax@9 + //int v13; // ecx@9 + //int v14; // eax@9 int v15; // eax@11 int v16; // eax@12 int v17; // eax@13 int v18; // edx@15 - signed int v19; // eax@25 - signed int v20; // eax@28 - int v21; // ebx@28 - signed int v22; // eax@28 - BLVFace *v23; // eax@35 - int v24; // edx@35 - unsigned int v25; // ecx@35 - signed int v26; // eax@36 - int v27; // ecx@36 - int v28; // eax@36 - int v29; // eax@37 - signed int v30; // eax@42 + //signed int v19; // eax@25 + //signed int v20; // eax@28 + //int v21; // ebx@28 + //signed int v22; // eax@28 + //BLVFace *v23; // eax@35 + //int v24; // edx@35 + //unsigned int v25; // ecx@35 + //signed int v26; // eax@36 + //int v27; // ecx@36 + //int v28; // eax@36 + //int v29; // eax@37 + //signed int v30; // eax@42 double v31; // st7@45 double v32; // st6@45 double v33; // st7@45 AIDirection *result; // eax@48 - int v35; // [sp-18h] [bp-64h]@17 - int v36; // [sp-14h] [bp-60h]@17 + //int v35; // [sp-18h] [bp-64h]@17 + //int v36; // [sp-14h] [bp-60h]@17 Vec3_int_ v37; // [sp-10h] [bp-5Ch]@15 - int *v38; // [sp-4h] [bp-50h]@15 - int *v39; // [sp+0h] [bp-4Ch]@15 - int *v40; // [sp+4h] [bp-48h]@15 + //int *v38; // [sp-4h] [bp-50h]@15 + //int *v39; // [sp+0h] [bp-4Ch]@15 + //int *v40; // [sp+4h] [bp-48h]@15 AIDirection v41; // [sp+14h] [bp-38h]@46 float v42; // [sp+30h] [bp-1Ch]@23 float v43; // [sp+34h] [bp-18h]@45 - float v44; // [sp+38h] [bp-14h]@33 - float v45; // [sp+3Ch] [bp-10h]@33 + float outy2; // [sp+38h] [bp-14h]@33 + float outx2; // [sp+3Ch] [bp-10h]@33 int outz; // [sp+40h] [bp-Ch]@6 int outy; // [sp+44h] [bp-8h]@6 int outx; // [sp+48h] [bp-4h]@6 float a4a; // [sp+58h] [bp+Ch]@45 v4 = PID_ID(uObj1ID); - v5 = PID_TYPE(uObj1ID); - v6 = uObj2ID; - switch(v5) + //v6 = uObj2ID; + v5 = PID_ID(uObj2ID); + switch( PID_TYPE(uObj1ID) ) { - case OBJECT_Item: - { - v19 = v4; - outx = pSpriteObjects[v19].vPosition.x; - v13 = pSpriteObjects[v19].vPosition.y; - v14 = pSpriteObjects[v19].vPosition.z; - outy = v13; - outz = v14; - break; - } - case OBJECT_Actor: - { - outx = pActors[v4].vPosition.x; - outy = pActors[v4].vPosition.y; - LODWORD(v42) = pActors[v4].uActorHeight; - v11 = pActors[v4].vPosition.z - (unsigned int)(signed __int64)((double)SLODWORD(v42) * -0.75); - outz = v11; - break; - } - case OBJECT_Player: - { - if ( !v4 ) - { - outx = pParty->vPosition.x; - outy = pParty->vPosition.y; - v14 = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - outz = v14; - break;; - } - if ( v4 == 4 ) - { - v40 = &outz; - v39 = &outy; - v38 = &outx; - v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x; - v36 = 0; - v35 = 24; - Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); - break; - } - if ( v4 == 3 ) - { - v40 = &outz; - v39 = &outy; - v38 = &outx; - v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x; - v36 = 0; - v35 = 8; - Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); - break; - } - if ( v4 == 2 ) - { - v40 = &outz; - v39 = &outy; - v38 = &outx; - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; - *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x; - v36 = 0; - v35 = 8; - Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); - break; - } - if ( v4 == 1 ) - { - v40 = &outz; - v39 = &outy; - v38 = &outx; - v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; - v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; - *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x; - v36 = 0; - v35 = 24; - Vec3_int_::Rotate(v35, v18, v36, v37, v38, v39, v40); - break; - } - } - case OBJECT_Decoration: - { - v12 = v4; - outx = pLevelDecorations[v12].vPosition.x; - v13 = pLevelDecorations[v12].vPosition.y; - v14 = pLevelDecorations[v12].vPosition.z; - outy = v13; - outz = v14; - break; - } - default: - { - outz = 0; - outy = 0; - outx = 0; - break; - } - case OBJECT_BModel: - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - v10 = &pIndoor->pFaces[v4]; - outx = (v10->pBounding.x1 + v10->pBounding.x2) >> 1; - outy = (v10->pBounding.y1 + v10->pBounding.y2) >> 1; - v11 = (v10->pBounding.z1 + v10->pBounding.z2) >> 1; - outz = v11; - } - break; - } + case OBJECT_Item: + { + outx = pSpriteObjects[v4].vPosition.x; + outy = pSpriteObjects[v4].vPosition.y; + outz = pSpriteObjects[v4].vPosition.z; + break; + } + case OBJECT_Actor: + { + outx = pActors[v4].vPosition.x; + outy = pActors[v4].vPosition.y; + outz = pActors[v4].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v4].uActorHeight * -0.75); + break; + } + case OBJECT_Player: + { + if ( !v4 ) + { + outx = pParty->vPosition.x; + outy = pParty->vPosition.y; + outz = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + break; + } + if ( v4 == 4 ) + { + v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; + v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x; + Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz); + break; + } + if ( v4 == 3 ) + { + v18 = pParty->sRotationY - stru_5C6E00->uIntegerHalfPi; + v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x; + Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz); + break; + } + if ( v4 == 2 ) + { + v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; + *(_QWORD *)&v37.x = *(_QWORD *)&pParty->vPosition.x; + Vec3_int_::Rotate(8, v18, 0, v37, &outx, &outy, &outz); + break; + } + if ( v4 == 1 ) + { + v37.z = pParty->vPosition.z + (signed int)pParty->uPartyHeight / 3; + v18 = stru_5C6E00->uIntegerHalfPi + pParty->sRotationY; + *(_QWORD *)&v37 = *(_QWORD *)&pParty->vPosition.x; + Vec3_int_::Rotate(24, v18, 0, v37, &outx, &outy, &outz); + break; + } + } + case OBJECT_Decoration: + { + outx = pLevelDecorations[v4].vPosition.x; + outy = pLevelDecorations[v4].vPosition.y; + outz = pLevelDecorations[v4].vPosition.z; + break; + } + default: + { + outz = 0; + outy = 0; + outx = 0; + break; + } + case OBJECT_BModel: + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + outx = (pIndoor->pFaces[v4].pBounding.x1 + pIndoor->pFaces[v4].pBounding.x2) >> 1; + outy = (pIndoor->pFaces[v4].pBounding.y1 + pIndoor->pFaces[v4].pBounding.y2) >> 1; + outz = (pIndoor->pFaces[v4].pBounding.z1 + pIndoor->pFaces[v4].pBounding.z2) >> 1; + } + break; + } } - v20 = v6; - v21 = PID_TYPE(v6); - v22 = PID_ID(v20); - switch(v21) + + switch( PID_TYPE(uObj2ID) ) { - case OBJECT_Item: - { - v30 = v22; - LODWORD(v45) = pSpriteObjects[v30].vPosition.x; - v27 = pSpriteObjects[v30].vPosition.y; - v28 = pSpriteObjects[v30].vPosition.z; - LODWORD(v44) = v27; - a4 = v28; - break; - } - case OBJECT_Actor: - { - LODWORD(v45) = pActors[v22].vPosition.x; - LODWORD(v44) = pActors[v22].vPosition.y; - v25 = pActors[v22].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v22].uActorHeight * -0.75); - a4 = v25; - break; - } - case OBJECT_Player: - { - LODWORD(v45) = pParty->vPosition.x; - LODWORD(v44) = pParty->vPosition.y; - v29 = a4; - if ( !a4 ) - v29 = pParty->sEyelevel; - v28 = pParty->vPosition.z + v29; - a4 = v28; - break; - } - case OBJECT_Decoration: - { - v26 = v22; - LODWORD(v45) = pLevelDecorations[v26].vPosition.x; - v27 = pLevelDecorations[v26].vPosition.y; - v28 = pLevelDecorations[v26].vPosition.z; - LODWORD(v44) = v27; - a4 = v28; - break; - } - default: - { - a4 = 0; - v44 = 0.0; - v45 = 0.0; - break; - } - case OBJECT_BModel: - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - v23 = &pIndoor->pFaces[v22]; - v24 = v23->pBounding.y1; - LODWORD(v45) = (v23->pBounding.x1 + v23->pBounding.x2) >> 1; - LODWORD(v44) = (v24 + v23->pBounding.y2) >> 1; - v25 = (v23->pBounding.z1 + v23->pBounding.z2) >> 1; - a4 = v25; - } - break; - } + case OBJECT_Item: + { + outx2 = pSpriteObjects[v5].vPosition.x; + outy2 = pSpriteObjects[v5].vPosition.y; + a4 = pSpriteObjects[v5].vPosition.z; + break; + } + case OBJECT_Actor: + { + outx2 = pActors[v5].vPosition.x; + outy2 = pActors[v5].vPosition.y; + a4 = pActors[v5].vPosition.z - (unsigned int)(signed __int64)((double)pActors[v5].uActorHeight * -0.75); + break; + } + case OBJECT_Player: + { + outx2 = pParty->vPosition.x; + outy2 = pParty->vPosition.y; + if ( !a4 ) + a4 = pParty->sEyelevel; + a4 = pParty->vPosition.z + a4; + break; + } + case OBJECT_Decoration: + { + outx2 = pLevelDecorations[v5].vPosition.x; + outy2 = pLevelDecorations[v5].vPosition.y; + a4 = pLevelDecorations[v5].vPosition.z; + break; + } + default: + { + outx2 = 0.0; + outy2 = 0.0; + a4 = 0; + break; + } + case OBJECT_BModel: + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + outx2 = (pIndoor->pFaces[v5].pBounding.x1 + pIndoor->pFaces[v5].pBounding.x2) >> 1; + outy2 = (pIndoor->pFaces[v5].pBounding.y1 + pIndoor->pFaces[v5].pBounding.y2) >> 1; + a4 = (pIndoor->pFaces[v5].pBounding.z1 + pIndoor->pFaces[v5].pBounding.z2) >> 1; + } + break; + } } - v31 = (double)SLODWORD(v45) - (double)outx; + v31 = (double)outx2 - (double)outx; v42 = v31; - v32 = (double)SLODWORD(v44) - (double)outy; + v32 = (double)outy2 - (double)outy; v43 = v32; a4a = (double)a4 - (double)outz; - v45 = v32 * v32; - v44 = v31 * v31; - v33 = sqrt(a4a * a4a + v44 + v45); + outx2 = v32 * v32; + outy2 = v31 * v31; + v33 = sqrt(a4a * a4a + outy2 + outx2); if ( v33 <= 1.0 ) { v41.vDirection.x = 65536; @@ -1872,12 +1826,12 @@ v41.vDirection.y = (signed __int64)(1.0 / v33 * v43 * 65536.0); v41.vDirection.z = (signed __int64)(1.0 / v33 * a4a * 65536.0); v41.uDistance = (signed __int64)v33; - v41.uDistanceXZ = (signed __int64)sqrt(v44 + v45); + v41.uDistanceXZ = (signed __int64)sqrt(outy2 + outx2); v41.uYawAngle = stru_5C6E00->Atan2((signed __int64)v42, (signed __int64)v43); v41.uPitchAngle = stru_5C6E00->Atan2(v41.uDistanceXZ, (signed __int64)a4a); } result = pOut; - memcpy(pOut, &v41, 0x1Cu); + memcpy(pOut, &v41, sizeof(AIDirection)); return result; }
--- a/AudioPlayer.h Fri Jul 05 21:15:53 2013 +0600 +++ b/AudioPlayer.h Fri Jul 05 21:16:12 2013 +0600 @@ -102,6 +102,8 @@ SOUND_Arcomage_131 = 0x83, SOUND_Arcomage_WallUpgrade = 0x84, SOUND_GoldReceived = 0xC8, + SOUND_206 =206, + SOUND_207 =207, SOUND_OpenChest = 208, SOUND_PlayerCantCastSpell = 0xD1, SOUND_Bell = 0xD9,
--- a/Autonotes.h Fri Jul 05 21:15:53 2013 +0600 +++ b/Autonotes.h Fri Jul 05 21:16:12 2013 +0600 @@ -22,4 +22,4 @@ AUTONOTE_TYPE eType; }; #pragma pack(pop) -extern std::array<Autonote, 195> pAutonoteTxt; // weak +extern std::array<Autonote, 196> pAutonoteTxt; // weak
--- a/CastSpellInfo.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/CastSpellInfo.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -4387,7 +4387,7 @@ return; pGUIWindow_Settings = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell, (int)&pCastSpellInfo[result], 0); - pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_BE, 0, 0, "", 0); + pGUIWindow_Settings->CreateButton(game_viewport_x, game_viewport_y, game_viewport_width, game_viewport_height, 1, 0, UIMSG_CastSpell_Telekinesis, 0, 0, "", 0); sub_421B2C_PlaceInInventory_or_DropPickedItem(); return; }
--- a/Events.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/Events.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -5,6 +5,7 @@ #include <assert.h> #include <stdlib.h> +#include "Weather.h" #include "Texture.h" #include "mm7_data.h" #include "VideoPlayer.h"
--- a/GUIWindow.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/GUIWindow.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -22,6 +22,7 @@ #include "StorylineTextTable.h" #include "Events2D.h" #include "UI\UIHouses.h" +#include "UI\UIBooks.h" #include "texts.h" #include "Autonotes.h" #include "Awards.h" @@ -432,14 +433,14 @@ unsigned int v19; // edi@43 unsigned int v20; // edi@45 void *v21; // esi@45 - signed int v23; // [sp+10h] [bp-5Ch]@38 + signed int max_beacons; // [sp+10h] [bp-5Ch]@38 char *v25; // [sp+14h] [bp-58h]@21 GUIWindow v26; // [sp+18h] [bp-54h]@8 v1 = this; pAudioPlayer->StopChannels(-1, -1); InitializeBookFonts(); - v1->CreateButton(0x1DBu, 0x1BDu, 0x9Eu, 0x22u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); // Close + v1->CreateButton(475, 445, 158, 34, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); // Close pCurrentScreen = SCREEN_BOOKS; num_achieved_awards_2 = 0; dword_506528 = 0; @@ -451,7 +452,7 @@ byte_506360 = 0; pTexture_CurrentBook = pIcons_LOD->LoadTexturePtr("lb_bordr", TEXTURE_16BIT_PALETTE); pTexture_LloydBeacons[0] = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE); - pTexture_50635C = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE); + pTexture_LloydBeacons[1] = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE); pTex_tab_an_6b__zoom_on = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE); pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE); @@ -459,40 +460,27 @@ pBtn_Book_2 = v1->CreateButton(415, 48, 39, 36, 1, 0, UIMSG_LloydsBeacon_FlippingBtn, 1, 0, pGlobalTXT_LocalizationStrings[523], 0); // Recall Beacon v17 = &pParty->pPlayers[_506348_current_lloyd_playerid]; - v23 = 1; - v18 = v17->pActiveSkills[14]; - if ( HIBYTE(v18) & 1 || (v18 & 0x80u) != 0 ) - { - v23 = 5; - } - else - { - if ( v18 & 0x40 ) - v23 = 3; - } - v19 = 0; - if ( v23 > 0 ) + + max_beacons = 1; + v18 = v17->pActiveSkills[PLAYER_SKILL_WATER]; + if ( v18 & 0x100 || (v18 & 0x80) ) + max_beacons = 5; + else if ( v18 & 0x40 ) + max_beacons = 3; + + + for (int i =0; i< max_beacons; ++i) + CreateButton(pLloydsBeaconsPreviewXs[v19], pLloydsBeaconsPreviewYs[v19], + 92, 68, 1, 180, UIMSG_InstallBeacon, i, 0, "", 0); + + for (int i =0; i< 5; ++i) { - do - { - v1->CreateButton(pLloydsBeaconsPreviewXs[v19], pLloydsBeaconsPreviewYs[v19], 0x5Cu, 0x44u, 1, 180, UIMSG_InstallBeacon, v19, 0, "", 0); - ++v19; - } - while ( (signed int)v19 < v23 ); + if (v17->pInstalledBeacons[i].uBeaconTime >= (signed __int64)pParty->uTimePlayed) + LoadThumbnailLloydTexture(i, _506348_current_lloyd_playerid + 1); + else + memset(&v17->pInstalledBeacons[i], 0, sizeof(LloydBeacon)); } - v20 = 0; - v21 = v17->pInstalledBeacons; - do - { - if ( *(_QWORD *)v21 >= (signed __int64)pParty->uTimePlayed ) - LoadThumbnailLloydTexture(v20, _506348_current_lloyd_playerid + 1); - else - memset(v21, 0, 0x1Cu); - ++v20; - v21 = (char *)v21 + 28; - } - while ( (signed int)v20 < 5 ); - } + } break; case WINDOW_TownPortal: @@ -507,13 +495,7 @@ for (uint i = 0; i < 6; ++i) v1->CreateButton(pTownPortalBook_xs[i], pTownPortalBook_ys[i], pTownPortalBook_ws[i], pTownPortalBook_hs[i], 1, 182, UIMSG_ClickTownInTP, i, 0, "", nullptr); - /*v16 = 0; - do - { - v1->CreateButton(pTownPortalBook_xs[v16], pTownPortalBook_ys[v16], pTownPortalBook_ws[v16], pTownPortalBook_hs[v16], 1, 182, 0xB7u, v16, 0, "", 0); - ++v16; - } - while ( (signed int)v16 < 6 );*/ + } break; @@ -537,11 +519,11 @@ memset(achieved_awards.data(), 0, 4000); for ( i = dword_506528; i < 512; ++i ) { - v14 = (char *)pQuestTable[i-1];//(&dword_722F10)[4 * i]; - if ( _449B57_test_bit(pParty->_quest_bits, i) && v14 ) + // v14 = (char *)pQuestTable[i];//(&dword_722F10)[4 * i]; + if ( _449B57_test_bit(pParty->_quest_bits, i) && pQuestTable[i] ) { - v15 = num_achieved_awards++; - achieved_awards[v15] = (AwardType)i; + achieved_awards[num_achieved_awards] = (AwardType)i; + ++num_achieved_awards; } } v12 = num_achieved_awards; @@ -572,35 +554,38 @@ pTexture_50636C = pIcons_LOD->LoadTexturePtr("tab-an-8b", TEXTURE_16BIT_PALETTE); pTexture_506368 = pIcons_LOD->LoadTexturePtr("tab-an-8a", TEXTURE_16BIT_PALETTE); - pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 11, 0, pGlobalTXT_LocalizationStrings[193], pTex_tab_an_6b__zoom_on, 0); - pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 10, 0, pGlobalTXT_LocalizationStrings[192], pTex_tab_an_7b__zoot_on, 0); - pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 2, 0, pGlobalTXT_LocalizationStrings[85], pTexture_506394, 0); // "Potion Notes" - pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 3, 0, pGlobalTXT_LocalizationStrings[137], pTexture_50638C, 0); // "Fountain Notes" - pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 4, 0, pGlobalTXT_LocalizationStrings[8], pTexture_506384, 0); // "Obelisk Notes" - pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 5, 0, pGlobalTXT_LocalizationStrings[141], pTexture_50637C, 0); // "Seer Notes" - pBtn_Autonotes_Misc = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 6, 0, pGlobalTXT_LocalizationStrings[123], pTexture_506374, 0); // "Miscellaneous Notes" - pBtn_Autonotes_Instructors = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 7, 0, pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0); // "Instructors" + pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 11, 0, pGlobalTXT_LocalizationStrings[193], pTex_tab_an_6b__zoom_on, 0); + pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 10, 0, pGlobalTXT_LocalizationStrings[192], pTex_tab_an_7b__zoot_on, 0); + pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 2, 0, pGlobalTXT_LocalizationStrings[85], pTexture_506394, 0); // "Potion Notes" + pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 3, 0, pGlobalTXT_LocalizationStrings[137], pTexture_50638C, 0); // "Fountain Notes" + pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 4, 0, pGlobalTXT_LocalizationStrings[8], pTexture_506384, 0); // "Obelisk Notes" + pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 5, 0, pGlobalTXT_LocalizationStrings[141], pTexture_50637C, 0); // "Seer Notes" + pBtn_Autonotes_Misc = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 6, 0, pGlobalTXT_LocalizationStrings[123], pTexture_506374, 0); // "Miscellaneous Notes" + pBtn_Autonotes_Instructors = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 7, 0, pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0); // "Instructors" - v9 = pBtn_Autonotes_Instructors; - v10 = dword_506528; num_achieved_awards = 0; - while ( v10 < 196 ) - { - if ( _506568_autonote_type == pAutonoteTxt[v10-1].eType)//dword_72371C[2 * v10] ) + for ( i = dword_506528; i < 196; ++i ) + if ( _506568_autonote_type == pAutonoteTxt[i].eType)//dword_72371C[2 * v10] ) { - //v25 = (&dword_723718_autonote_related)[8 * (signed __int16)v10]; - v25 = (char *)pAutonoteTxt[v10-1].pText; - if ( (short)v10 ) + if ( i ) { - if ( _449B57_test_bit(pParty->_autonote_bits, v10) && v25 ) + if ( _449B57_test_bit(pParty->_autonote_bits, i) && pAutonoteTxt[i].pText ) { - v11 = num_achieved_awards++; - achieved_awards[v11] = (AwardType)v10; + + achieved_awards[num_achieved_awards] = (AwardType)i; + ++num_achieved_awards; } } } - ++v10; - } + } break; @@ -621,12 +606,18 @@ pTexture_50637C = pIcons_LOD->LoadTexturePtr("tabWon", TEXTURE_16BIT_PALETTE); pTexture_506378 = pIcons_LOD->LoadTexturePtr("tabWoff", TEXTURE_16BIT_PALETTE); - pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 0, 0, pGlobalTXT_LocalizationStrings[251], pTex_tab_an_6b__zoom_on, 0);// "Zoom In" - pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 1, 0, pGlobalTXT_LocalizationStrings[252], pTex_tab_an_7b__zoot_on, 0);// "Zoom Out" - pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 113, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 2, 0, pGlobalTXT_LocalizationStrings[192], (Texture *)"", 0);// Scroll Up - pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 150, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 3, 0, pGlobalTXT_LocalizationStrings[193], (Texture *)"", 0);// Scroll Down - pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 4, 0, pGlobalTXT_LocalizationStrings[573], (Texture *)"", 0);// "Scroll Right" - pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 50, 34, 1, 0, UIMSG_ClickBooksBtn, 5, 0, pGlobalTXT_LocalizationStrings[572], (Texture *)"", 0);// "Scroll Left" + pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 0, 0, pGlobalTXT_LocalizationStrings[251], pTex_tab_an_6b__zoom_on, 0);// "Zoom In" + pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 1, 0, pGlobalTXT_LocalizationStrings[252], pTex_tab_an_7b__zoot_on, 0);// "Zoom Out" + pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 113, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 2, 0, pGlobalTXT_LocalizationStrings[192], (Texture *)"", 0);// Scroll Up + pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 150, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 3, 0, pGlobalTXT_LocalizationStrings[193], (Texture *)"", 0);// Scroll Down + pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 4, 0, pGlobalTXT_LocalizationStrings[573], (Texture *)"", 0);// "Scroll Right" + pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 50, 34, 1, 0, + UIMSG_ClickBooksBtn, 5, 0, pGlobalTXT_LocalizationStrings[572], (Texture *)"", 0);// "Scroll Left" } break; @@ -649,8 +640,12 @@ pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE); pTex_tab_an_7a__zoot_off = pIcons_LOD->LoadTexturePtr("tab-an-7a", TEXTURE_16BIT_PALETTE); - pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_tab_an_6b__zoom_on->uTextureWidth, pTex_tab_an_6b__zoom_on->uTextureHeight, 1, 0, UIMSG_ClickBooksBtn, 11, 0, pGlobalTXT_LocalizationStrings[192], pTex_tab_an_6b__zoom_on, 0); - pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_tab_an_7b__zoot_on->uTextureHeight, pTex_tab_an_7b__zoot_on->uTextureHeight, 1, 0, UIMSG_ClickBooksBtn, 10, 0, pGlobalTXT_LocalizationStrings[193], pTex_tab_an_7b__zoot_on, 0); + pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, + pTex_tab_an_6b__zoom_on->uTextureWidth, pTex_tab_an_6b__zoom_on->uTextureHeight, 1, 0, + UIMSG_ClickBooksBtn, 11, 0, pGlobalTXT_LocalizationStrings[192], pTex_tab_an_6b__zoom_on, 0); + pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_tab_an_7b__zoot_on->uTextureHeight, + pTex_tab_an_7b__zoot_on->uTextureHeight, 1, 0, UIMSG_ClickBooksBtn, 10, 0, + pGlobalTXT_LocalizationStrings[193], pTex_tab_an_7b__zoot_on, 0); num_achieved_awards = 0; v26.uFrameX = 48; @@ -1800,7 +1795,7 @@ else { if ( v26 || !dword_591080 ) - v27 = HouseNPCData[v26 +1 - (dword_591080 != 0)]->pName; + v27 = HouseNPCData[v26 +1 - ((dword_591080 != 0)? 1:0)]->pName; else v27 = (char*)p2DEvents[pButton - 1].pProprieterName; v30 = v27; @@ -1975,7 +1970,7 @@ { if ( pCurrentScreen == SCREEN_CHEST ) { - Chest::DrawChestUI((unsigned int)pWindow->ptr_1C); + Chest::DrawChestUI(pWindow->par1C); } else if ( pCurrentScreen == SCREEN_CHEST_INVENTORY ) { @@ -2001,13 +1996,13 @@ pWindowList[pVisibleWindowsIdxs[i] - 1].HouseDialogManager(); if ( !window_SpeakInHouse ) continue; - if ( (signed int)window_SpeakInHouse->ptr_1C >= 53 ) + if ( window_SpeakInHouse->par1C >= 53 ) continue; - if ( pParty->field_3C._shop_ban_times[(signed int)window_SpeakInHouse->ptr_1C] <=pParty->uTimePlayed ) + if ( pParty->field_3C._shop_ban_times[window_SpeakInHouse->par1C] <=pParty->uTimePlayed ) { - if ( (signed int)window_SpeakInHouse->ptr_1C < 53 ) + if ( window_SpeakInHouse->par1C < 53 ) { - pParty->field_3C._shop_ban_times[(signed int)window_SpeakInHouse->ptr_1C] = 0; + pParty->field_3C._shop_ban_times[window_SpeakInHouse->par1C] = 0; } continue; } @@ -2350,170 +2345,14 @@ GUIWindow *pWindow; // ecx@1 pWindow = ptr_507BDC; - pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BDC->ptr_1C, 0, 0); + pMessageQueue_50CBD0->AddMessage((UIMessageType)ptr_507BDC->par1C, 0, 0); pWindow->Release(); ptr_507BDC = 0; pCurrentScreen = dword_506F0C[0]; pEventTimer->Resume(); } -//----- (00410DEC) -------------------------------------------------------- -unsigned int __cdecl DrawLloydBeaconsScreen() -{ - Player *pPlayer; // esi@1 - char *v1; // eax@1 - unsigned __int16 v2; // ax@6 - unsigned int result; // eax@11 - unsigned int v4; // esi@13 - unsigned int v5; // ecx@13 - char v6; // zf@13 - LloydBeacon *v7; // esi@14 - int v8; // eax@14 - unsigned __int64 v9; // kr08_8@14 - unsigned int v10; // esi@14 - unsigned int v11; // eax@14 - char *v12; // eax@19 - char *v13; // ecx@22 - int v14; // eax@27 - Texture *v19; // [sp-4h] [bp-8Ch]@4 - GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1 - unsigned int v23; // [sp+64h] [bp-24h]@14 - __int64 v24; // [sp+68h] [bp-20h]@14 - unsigned int v25; // [sp+70h] [bp-18h]@13 - char *Str; // [sp+74h] [bp-14h]@14 - int v27; // [sp+78h] [bp-10h]@11 - LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12 - RGBTexture *v29; // [sp+80h] [bp-8h]@12 - int uNumMaxBeacons; // [sp+84h] [bp-4h]@6 - pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid]; - pRenderer->DrawTextureIndexed(8u, 8u, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]); - v1 = pGlobalTXT_LocalizationStrings[523]; // Recall Beacon - pWindow.uFrameX = game_viewport_x; - pWindow.uFrameY = game_viewport_y; - pWindow.uFrameWidth = 428; - pWindow.uFrameHeight = game_viewport_height; - pWindow.uFrameZ = 435; - pWindow.uFrameW = game_viewport_w; - if ( !bRecallingBeacon ) - v1 = pGlobalTXT_LocalizationStrings[375]; // Set Beacon - sprintf(pTmpBuf.data(), "%s", v1); - pWindow.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf.data(), 3u); - if ( bRecallingBeacon ) - { - pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on); - v19 = pTex_tab_an_6a__zoom_off; - } - else - { - pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6a__zoom_off); - v19 = pTex_tab_an_6b__zoom_on; - } - pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19); - v2 = pPlayer->pActiveSkills[14]; - uNumMaxBeacons = 1; - if ( HIBYTE(v2) & 1 || (v2 & 0x80u) != 0 ) - { - uNumMaxBeacons = 5; - } - else - { - if ( v2 & 0x40 ) - uNumMaxBeacons = 3; - } - result = 0; - v27 = 0; - if ( uNumMaxBeacons > 0 ) - { - v29 = pSavegameThumbnails.data(); - v28 = pPlayer->pInstalledBeacons; - while ( 1 ) - { - pWindow.uFrameWidth = 92; - v4 = result; - pWindow.uFrameHeight = 68; - v5 = pLloydsBeaconsPreviewXs[result]; - pWindow.uFrameY = pLloydsBeaconsPreviewYs[result]; - v25 = pWindow.uFrameY; - pWindow.uFrameX = v5; - pWindow.uFrameW = pWindow.uFrameY + 67; - v6 = v29->pPixels == 0; - pWindow.uFrameZ = v5 + 91; - if ( !v6 ) - break; - if ( !bRecallingBeacon ) - { - pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook); - v14 = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0); - pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - v14 / 2, 1, pGlobalTXT_LocalizationStrings[19], 3); - } -LABEL_29: - ++v29; - ++v28; - result = v27++ + 1; - if ( v27 >= uNumMaxBeacons ) - goto LABEL_30; - } - pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook); - pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[v4], pLloydsBeaconsPreviewYs[v4], v29); - v7 = v28; - Str = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v28->field_18))].pName; - v8 = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0); - pWindow.uFrameY += -6 - v8; - pWindow.DrawTitleText(pSpellFont, 0, 0, 1u, Str, 3u); - v9 = v7->uBeaconTime - pParty->uTimePlayed; - LODWORD(v24) = LODWORD(v7->uBeaconTime) - LODWORD(pParty->uTimePlayed); - HIDWORD(v24) = HIDWORD(v9); - v23 = (unsigned __int64)((signed __int64)((double)v24 * 0.234375) / 60 / 60) >> 32; - v10 = (signed __int64)((double)v24 * 0.234375) / 60 / 60; - v11 = v10 / 0x18; - if ( (unsigned int)((signed __int64)((double)v24 * 0.234375) / 60 / 60) / 0x18 ) - { - v13 = pGlobalTXT_LocalizationStrings[57]; // Days - if ( v11 > 1 ) - { - sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13); - pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; - pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); - goto LABEL_29; - } - } - else - { - if ( (signed __int64)(__PAIR__(v23, v10) + 1) <= 23 ) - { - if ( (v23 & 0x80000000u) != 0 || (signed int)v23 <= 0 && v10 <= 1 ) - v12 = pGlobalTXT_LocalizationStrings[109];// Hour - else - v12 = pGlobalTXT_LocalizationStrings[110];// Hours - sprintf(pTmpBuf.data(), "%lu %s", v10 + 1, v12); - pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; - pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); - goto LABEL_29; - } - } - v13 = pGlobalTXT_LocalizationStrings[56]; // Day - sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13); - pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; - pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); - goto LABEL_29; - } -LABEL_30: - if ( byte_506360 ) - { - /*result = pMessageQueue_50CBD0->uNumMessages; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CloseAfterInstallBeacon; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; - *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_CloseAfterInstallBeacon, 0, 0); - } - return result; -} //----- (00467FB6) -------------------------------------------------------- void CreateScrollWindow() { @@ -2527,7 +2366,7 @@ a1.uFrameX = 1; a1.uFrameY = 1; a1.uFrameWidth = 468; - v0 = pFontSmallnum->CalcTextHeight(pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C], &a1, 0, 0) + v0 = pFontSmallnum->CalcTextHeight(pScrolls[pGUIWindow_ScrollWindow->par1C], &a1, 0, 0) + 2 * LOBYTE(pFontCreate->uFontHeight) + 24; a1.uFrameHeight = v0;
--- a/GUIWindow.h Fri Jul 05 21:15:53 2013 +0600 +++ b/GUIWindow.h Fri Jul 05 21:16:12 2013 +0600 @@ -151,7 +151,7 @@ UIMSG_ToggleShowDamage = 187, UIMSG_ScrollNPCPanel = 188, UIMSG_BD = 189, - UIMSG_CastSpell_BE = 190, + UIMSG_CastSpell_Telekinesis = 190, UIMSG_BF = 191, UIMSG_ClickAwardScrollBar = 192, UIMSG_C1 = 192,
--- a/Indoor.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/Indoor.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -1262,7 +1262,7 @@ //stru170 *v4; // ebx@1 //BLVFace *v5; // eax@1 //int v6; // ecx@2 - unsigned __int16 v7; // ax@11 + unsigned __int16 pTransitionSector; // ax@11 Vec3_short_ *v8; // esi@15 int v9; // edx@15 //signed int v10; // eax@18 @@ -1273,7 +1273,7 @@ int v15; // edx@24 //int v16; // esi@29 //BLVFace *v17; // edi@34 - unsigned __int16 v18; // ax@34 + //unsigned __int16 v18; // ax@34 char *v19; // eax@38 signed int v20; // ecx@38 char *v21; // eax@42 @@ -1303,7 +1303,6 @@ //v39 = &pIndoor->pFaces[uFaceID]; auto pFace = &pIndoor->pFaces[uFaceID]; - auto p = &nodes[node_id]; if (!pFace->Portal()) { @@ -1315,127 +1314,115 @@ return; } - if (p->uFaceID == uFaceID) - return; - if (!node_id && - pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 && // we are probably standing at the portal plane - pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 && - pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 && - pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 && - pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 && - pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) + if (nodes[node_id].uFaceID == uFaceID) + return; + if (!node_id && + pBLVRenderParams->vPartyPos.x >= pFace->pBounding.x1 - 16 && // we are probably standing at the portal plane + pBLVRenderParams->vPartyPos.x <= pFace->pBounding.x2 + 16 && + pBLVRenderParams->vPartyPos.y >= pFace->pBounding.y1 - 16 && + pBLVRenderParams->vPartyPos.y <= pFace->pBounding.y2 + 16 && + pBLVRenderParams->vPartyPos.z >= pFace->pBounding.z1 - 16 && + pBLVRenderParams->vPartyPos.z <= pFace->pBounding.z2 + 16 ) + { + if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x + + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y + + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane { - if ( abs(pFace->pFacePlane_old.dist + pBLVRenderParams->vPartyPos.x * pFace->pFacePlane_old.vNormal.x - + pBLVRenderParams->vPartyPos.y * pFace->pFacePlane_old.vNormal.y - + pBLVRenderParams->vPartyPos.z * pFace->pFacePlane_old.vNormal.z) <= 589824 ) // we sure are standing at the portal plane - { - v7 = pFace->uSectorID; - if ( nodes[0].uSectorID == v7 ) // draw back sector - v7 = pFace->uBackSectorID; - nodes[num_nodes].uSectorID = v7; - nodes[num_nodes].uFaceID = uFaceID; - nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; - nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; - nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; - nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; - nodes[num_nodes].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, - pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); - AddBspNodeToRenderList(++num_nodes - 1); - return; - } - //v5 = v39; - //v6 = a0; + pTransitionSector = pFace->uSectorID; + if ( nodes[0].uSectorID == pTransitionSector ) // draw back sector + pTransitionSector = pFace->uBackSectorID; + nodes[num_nodes].uSectorID = pTransitionSector; + nodes[num_nodes].uFaceID = uFaceID; + nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; + nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; + nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; + nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; + nodes[num_nodes].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, + pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); + AddBspNodeToRenderList(++num_nodes - 1); + return; } - - v8 = &pIndoor->pVertices[pFace->pVertexIDs[0]]; - v9 = pFace->pFacePlane_old.vNormal.x * (v8->x - pBLVRenderParams->vPartyPos.x) - + pFace->pFacePlane_old.vNormal.y * (v8->y - pBLVRenderParams->vPartyPos.y) - + pFace->pFacePlane_old.vNormal.z * (v8->z - pBLVRenderParams->vPartyPos.z); - if (p->uSectorID != pFace->uSectorID) - v9 = -v9; - if (v9 >= 0) - return; - - auto num_vertices = sub_423B5D(uFaceID); - if (num_vertices < 2) - return; - - auto face_min_screenspace_x = stru_50B700._screen_space_x[0], - face_max_screenspace_x = stru_50B700._screen_space_x[0]; - auto face_min_screenspace_y = stru_50B700._screen_space_y[0], - face_max_screenspace_y = stru_50B700._screen_space_y[0]; - for (uint i = 1; i < num_vertices; ++i) - { - if (face_min_screenspace_x > stru_50B700._screen_space_x[i]) - face_min_screenspace_x = stru_50B700._screen_space_x[i]; - if (face_max_screenspace_x < stru_50B700._screen_space_x[i]) - face_max_screenspace_x = stru_50B700._screen_space_x[i]; - - if (face_min_screenspace_y > stru_50B700._screen_space_y[i]) - face_min_screenspace_y = stru_50B700._screen_space_y[i]; - if (face_max_screenspace_y < stru_50B700._screen_space_y[i]) - face_max_screenspace_y = stru_50B700._screen_space_y[i]; - } + } + + v9 = pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pFace->pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) + + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pFace->pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) + + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pFace->pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z); + if (nodes[node_id].uSectorID != pFace->uSectorID) + v9 = -v9; + if (v9 >= 0) + return; + + auto num_vertices = sub_423B5D(uFaceID); + if (num_vertices < 2) + return; + + auto face_min_screenspace_x = stru_50B700._screen_space_x[0], + face_max_screenspace_x = stru_50B700._screen_space_x[0]; + auto face_min_screenspace_y = stru_50B700._screen_space_y[0], + face_max_screenspace_y = stru_50B700._screen_space_y[0]; + for (uint i = 1; i < num_vertices; ++i) + { + if (face_min_screenspace_x > stru_50B700._screen_space_x[i]) + face_min_screenspace_x = stru_50B700._screen_space_x[i]; + if (face_max_screenspace_x < stru_50B700._screen_space_x[i]) + face_max_screenspace_x = stru_50B700._screen_space_x[i]; + + if (face_min_screenspace_y > stru_50B700._screen_space_y[i]) + face_min_screenspace_y = stru_50B700._screen_space_y[i]; + if (face_max_screenspace_y < stru_50B700._screen_space_y[i]) + face_max_screenspace_y = stru_50B700._screen_space_y[i]; + } //_screen_space_x = 719, 568, 493 //savegame: qw , 0Bh and 0x1D4h //problem here when standing near/on portal, condition is false because of face_min_screenspace_x > p->uViewportZ - if (face_max_screenspace_x >= p->uViewportX && - face_min_screenspace_x <= p->uViewportZ && - face_max_screenspace_y >= p->uViewportY && - face_min_screenspace_y <= p->uViewportW && - sub_424829(num_vertices, &nodes[num_nodes].field_C, &p->field_C, uFaceID)) - { - //v17 = v39; - v18 = pFace->uSectorID; - if (p->uSectorID == v18 ) - v18 = pFace->uBackSectorID; - nodes[num_nodes].uSectorID = v18; - nodes[num_nodes].uFaceID = uFaceID; - nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; - nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; - nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; - nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; - //v38 = pGame->pStru10Instance; - //a0a = pGame->pIndoorCameraD3D; - v29 = false; - if (p->viewing_portal_id == -1) - { - v29 = pGame->pStru10Instance->CalcPortalShape(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); - } - else - { - static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64]; - static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64]; - - for (uint k = 0; k < pFace->uNumVertices; ++k) - { - static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[k]].x; - static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[k]].y; - static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[k]].z; - } - - - unsigned int a2 = pFace->uNumVertices; - pGame->pIndoorCameraD3D->CalcPortalShape(static_subAddFaceToRenderList_d3d_stru_F7AA08, - &a2, - static_subAddFaceToRenderList_d3d_stru_F79E08, - p->std__vector_0007AC, 4, 0, 0); - - v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &a2, - nodes[num_nodes].std__vector_0007AC, - nodes[num_nodes].pPortalBounding); - } - if ( 1 ) - { - assert(num_nodes < 150); - - nodes[num_nodes].viewing_portal_id = uFaceID; - AddBspNodeToRenderList(++num_nodes - 1); - } - if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) - pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); - //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace); - } + if (face_max_screenspace_x >= nodes[node_id].uViewportX && + face_min_screenspace_x <= nodes[node_id].uViewportZ && + face_max_screenspace_y >= nodes[node_id].uViewportY && + face_min_screenspace_y <= nodes[node_id].uViewportW && + sub_424829(num_vertices, &nodes[num_nodes].field_C, &nodes[node_id].field_C, uFaceID)) + { + pTransitionSector = pFace->uSectorID; + if (nodes[node_id].uSectorID == pTransitionSector ) + pTransitionSector = pFace->uBackSectorID; + nodes[num_nodes].uSectorID = pTransitionSector; + nodes[num_nodes].uFaceID = uFaceID; + nodes[num_nodes].uViewportX = pBLVRenderParams->uViewportX; + nodes[num_nodes].uViewportZ = pBLVRenderParams->uViewportZ; + nodes[num_nodes].uViewportY = pBLVRenderParams->uViewportY; + nodes[num_nodes].uViewportW = pBLVRenderParams->uViewportW; + v29 = false; + if (nodes[node_id].viewing_portal_id == -1)// + v29 = pGame->pStru10Instance->CalcPortalShape(pFace, nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); + else// + { + static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F7AA08[64]; + static RenderVertexSoft static_subAddFaceToRenderList_d3d_stru_F79E08[64]; + + for (uint k = 0; k < pFace->uNumVertices; ++k) + { + static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.x = pIndoor->pVertices[pFace->pVertexIDs[k]].x; + static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.y = pIndoor->pVertices[pFace->pVertexIDs[k]].y; + static_subAddFaceToRenderList_d3d_stru_F7AA08[k].vWorldPosition.z = pIndoor->pVertices[pFace->pVertexIDs[k]].z; + } + + unsigned int pNewNumVertices = pFace->uNumVertices; + pGame->pIndoorCameraD3D->CalcPortalShape(static_subAddFaceToRenderList_d3d_stru_F7AA08, &pNewNumVertices, + static_subAddFaceToRenderList_d3d_stru_F79E08, nodes[node_id].std__vector_0007AC, 4, 0, 0); + + v29 = pGame->pStru10Instance->_49C5DA(pFace, static_subAddFaceToRenderList_d3d_stru_F79E08, &pNewNumVertices, + nodes[num_nodes].std__vector_0007AC, nodes[num_nodes].pPortalBounding); + } + if ( 1 ) + { + assert(num_nodes < 150); + + nodes[num_nodes].viewing_portal_id = uFaceID; + AddBspNodeToRenderList(++num_nodes - 1); + } + if (pBLVRenderParams->uFlags & INDOOR_CAMERA_DRAW_SW_OUTLINES) + pGame->pIndoorCameraD3D->PrepareAndDrawDebugOutline(pFace, 0x1E1EFF); + //pGame->pIndoorCameraD3D->DebugDrawPortal(pFace); + } }
--- a/Indoor.h Fri Jul 05 21:15:53 2013 +0600 +++ b/Indoor.h Fri Jul 05 21:16:12 2013 +0600 @@ -1,9 +1,19 @@ #pragma once #include "VectorTypes.h" -#include "Weather.h" #include "Indoor_stuff.h" +#pragma pack(push, 1) +struct LocationTime_stru1 +{ + unsigned __int64 uLastVisitDay; + char sky_texture_name[12]; + int day_attrib; + int day_fogrange_1; + int day_fogrange_2; + char field_2F4[24]; +}; +#pragma pack(pop) /* 319 */ enum LEVEL_TYPE
--- a/IndoorCameraD3D.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/IndoorCameraD3D.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -1373,13 +1373,13 @@ RenderVertexSoft *v14; // eax@8 RenderVertexSoft *v15; // edx@8 Vec3_float_ a5; // [sp+18h] [bp-3Ch]@12 - float v17; // [sp+44h] [bp-10h]@1 - int v18; // [sp+48h] [bp-Ch]@5 + //float v17; // [sp+44h] [bp-10h]@1 + //int v18; // [sp+48h] [bp-Ch]@5 //stru9 *thisa; // [sp+4Ch] [bp-8h]@1 int a7a; // [sp+53h] [bp-1h]@5 //bool a6a; // [sp+70h] [bp+1Ch]@5 - v17 = 0.0; + //v17 = 0.0; //thisa = pGame->pStru9Instance; static RenderVertexSoft sr_vertices_50D9D8[64]; @@ -1388,41 +1388,44 @@ a7a = 0; v11 = 2 * (a6 == 0) + 1; //a6a = 0; - v18 = v11; + //v18 = v11; if (uNumVertices <= 0) return false; //v12 = *pOutNumVertices; //v13 = (char *)&a4->y; - uint i = 0; - while ( 1 ) + + //while ( 1 ) + for ( uint i = 0; i < uNumVertices; ++i ) + { + if (i % 2) + { + v14 = a1; + v15 = sr_vertices_50D9D8; + } + else { - if (i % 2) - { - v14 = a1; - v15 = sr_vertices_50D9D8; - } - else - { - v15 = a1; - v14 = sr_vertices_50D9D8; - } - if (i == uNumVertices - 1) - v14 = pVertices; - a5.x = a4[i].x; - a5.y = a4[i].y; - a5.z = a4[i].z; - pGame->pStru9Instance->CalcPortalShape(v15, *pOutNumVertices, v14, pOutNumVertices, &a5, a4[i].dot, (char *)&a7a, _unused); - //v12 = *pOutNumVertices; - if (*pOutNumVertices < v18) - break; - //result = a6a; - //v13 += 24; - if (++i >= uNumVertices) - return a7a; + v15 = a1; + v14 = sr_vertices_50D9D8; } - *pOutNumVertices = 0; - return true; + if (i == uNumVertices - 1) + v14 = pVertices; + a5.x = a4[i].x; + a5.y = a4[i].y; + a5.z = a4[i].z; + pGame->pStru9Instance->CalcPortalShape(v15, *pOutNumVertices, v14, pOutNumVertices, &a5, a4[i].dot, (char *)&a7a, _unused); + //v12 = *pOutNumVertices; + if (*pOutNumVertices < v11) + { + *pOutNumVertices = 0; + return true; + } + //result = a6a; + //v13 += 24; + //if (++i >= uNumVertices) + // + } + return a7a; } //----- (004371C3) --------------------------------------------------------
--- a/Monsters.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/Monsters.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -802,11 +802,11 @@ { case 's': pInfos[curr_rec_num].uMovementType=0;// short if (tolower(test_string[1])!='h') - pInfos[curr_rec_num].uMovementType=5; //?? + pInfos[curr_rec_num].uMovementType=5; //stationary? break; //short case 'l': pInfos[curr_rec_num].uMovementType=2; break; //long case 'm': pInfos[curr_rec_num].uMovementType=1; break; //med - case 'g': pInfos[curr_rec_num].uMovementType=3; break; //??? + case 'g': pInfos[curr_rec_num].uMovementType=3; break; //global? default: pInfos[curr_rec_num].uMovementType=4; //free }
--- a/Mouse.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/Mouse.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -631,7 +631,7 @@ if ( pParty->bTurnBasedModeOn == 1 ) { if ( pTurnEngine->field_4 == 3 ) - pTurnEngine->field_18 |= 8u; + pTurnEngine->field_18 |= TE_FLAG_8; } } }
--- a/NPC.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/NPC.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -1181,36 +1181,36 @@ switch (decode_step) { case 1: - pAutonoteTxt[i].pText=RemoveQuotes(test_string); + pAutonoteTxt[i+1].pText=RemoveQuotes(test_string); break; case 2: { if ( !_stricmp(test_string, "potion")) { - pAutonoteTxt[i].eType = AUTONOTE_POTION_RECEPIE; + pAutonoteTxt[i+1].eType = AUTONOTE_POTION_RECEPIE; break; } if ( !_stricmp(test_string, "stat") ) { - pAutonoteTxt[i].eType = AUTONOTE_STAT_HINT; + pAutonoteTxt[i+1].eType = AUTONOTE_STAT_HINT; break; } if ( !_stricmp(test_string, "seer") ) { - pAutonoteTxt[i].eType = AUTONOTE_SEER; + pAutonoteTxt[i+1].eType = AUTONOTE_SEER; break; } if ( !_stricmp(test_string, "obelisk") ) { - pAutonoteTxt[i].eType = AUTONOTE_OBELISK; + pAutonoteTxt[i+1].eType = AUTONOTE_OBELISK; break; } if ( !_stricmp(test_string, "teacher") ) { - pAutonoteTxt[i].eType = AUTONOTE_TEACHER; + pAutonoteTxt[i+1].eType = AUTONOTE_TEACHER; break; } - pAutonoteTxt[i].eType =AUTONOTE_MISC; + pAutonoteTxt[i+1].eType =AUTONOTE_MISC; break; } } @@ -1242,7 +1242,7 @@ pQuestsTXT_Raw = NULL; pQuestsTXT_Raw = (char *)pEvents_LOD->LoadRaw("quests.txt", 0); strtok(pQuestsTXT_Raw, "\r"); - + memset(pQuestTable.data(),0, sizeof(pQuestTable)); for (i=0; i<512; ++i) { test_string = strtok(NULL, "\r") + 1; @@ -1264,7 +1264,7 @@ if (temp_str_len) { if ( decode_step == 1) - pQuestTable[i] =RemoveQuotes(test_string); + pQuestTable[i+1] =RemoveQuotes(test_string); } else { @@ -1305,7 +1305,7 @@ //int v25; // [sp-4h] [bp-10h]@49 uDialogueType = uMessageParam + 1; - pCurrentNPCInfo = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 + pCurrentNPCInfo = HouseNPCData[pDialogueNPCCount -((dword_591080 != 0)?1:0 )];//- 1 if ( uMessageParam <= 24 ) { switch ( uMessageParam ) @@ -1640,7 +1640,7 @@ } else { - v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0) )];//+ 1 + v17 = HouseNPCData[_this + 1 - ((dword_591080 != 0)?1:0 )];//+ 1 if ( dialog_menu_id == HOUSE_DIALOGUE_OTHER ) { pDialogueWindow->Release();
--- a/Outdoor.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/Outdoor.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -5,7 +5,7 @@ #include <assert.h> #include "stru6.h" - +#include "Weather.h" #include "Sprites.h" #include "LightmapBuilder.h" #include "Outdoor.h" @@ -1147,7 +1147,7 @@ pTilemap = (unsigned __int8 *)pAllocator->AllocNamedChunk(pTilemap, 0x4000u, "TMAP");//tile map pAttributemap = (unsigned __int8 *)pAllocator->AllocNamedChunk(pAttributemap, 0x4000u, "AMAP");// pDmap=(struct DMap *)pAllocator->AllocNamedChunk(pDmap, 0x8000u, "DMAP"); - if (pHeightmap&&pTilemap&&pAttributemap&&pDmap) + if ( pHeightmap && pTilemap && pAttributemap && pDmap ) return true; else return false; @@ -3594,4 +3594,30 @@ pIcons_LOD->SyncLoadedFilesCount(); sprintf(pTmpBuf.data(), "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour); pTexture_RestUI_CurrentSkyFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); -} \ No newline at end of file +} + + +//----- (004626BA) -------------------------------------------------------- +OutdoorLocation::OutdoorLocation() +{ + subconstuctor(); + uLastSunlightUpdateMinute = 0; + + uNumBModels = 0; + pBModels = nullptr; +} + +//----- (004626CD) -------------------------------------------------------- +void OutdoorLocation::subconstuctor() +{ + //OutdoorLocationTerrain::OutdoorLocationTerrain(&this->pTerrain); + field_F0 = 0; + field_F4 = 0x40000000u; + //DLVHeader::DLVHeader(&v1->ddm); + pSpawnPoints = 0; + pBModels = 0; + pCmap = 0; + pFaceIDLIST = 0; + pOMAP = 0; +} +
--- a/Outdoor.h Fri Jul 05 21:15:53 2013 +0600 +++ b/Outdoor.h Fri Jul 05 21:16:12 2013 +0600 @@ -127,28 +127,8 @@ #pragma pack(push, 1) struct OutdoorLocation { - //----- (004626BA) -------------------------------------------------------- - OutdoorLocation() - { - subconstuctor(); - uLastSunlightUpdateMinute = 0; - - uNumBModels = 0; - pBModels = nullptr; - } - //----- (004626CD) -------------------------------------------------------- - void subconstuctor() - { - //OutdoorLocationTerrain::OutdoorLocationTerrain(&this->pTerrain); - field_F0 = 0; - field_F4 = 0x40000000u; - //DLVHeader::DLVHeader(&v1->ddm); - pSpawnPoints = 0; - pBModels = 0; - pCmap = 0; - pFaceIDLIST = 0; - pOMAP = 0; - } + OutdoorLocation(); + void subconstuctor(); void ExecDraw(unsigned int bRedraw); void PrepareActorsDrawList();
--- a/Outdoor_stuff.h Fri Jul 05 21:15:53 2013 +0600 +++ b/Outdoor_stuff.h Fri Jul 05 21:16:12 2013 +0600 @@ -15,7 +15,7 @@ } int _479295(); - void _4811A3(); + void DrawBorderTiles(); void _48276F_sr(); void _486089_normalize_v_18(); void _48607B(struct stru149 *a2);
--- a/Party.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/Party.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -813,7 +813,7 @@ pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 100; // default character ui - stats uFlags = 0; - memset(_autonote_bits, 0, 12); + memset(_autonote_bits, 0, 26); memset(_quest_bits, 0, 64); memset(pIsArtifactFound, 0, 29); _449B7E_toggle_bit(_quest_bits, PARTY_QUEST_EMERALD_RED_POTION_ACTIVE, 1);
--- a/Party.h Fri Jul 05 21:15:53 2013 +0600 +++ b/Party.h Fri Jul 05 21:16:12 2013 +0600 @@ -259,8 +259,8 @@ char uNumArenaLordWins; char pIsArtifactFound[29]; //7ba char field_7d7[39]; - unsigned char _autonote_bits[12]; - char field_80A[74]; + unsigned char _autonote_bits[26]; + char field_818[60]; char field_854[32]; int uNumArcomageWins; int uNumArcomageLoses;
--- a/Player.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/Player.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -91,21 +91,23 @@ unsigned char pBaseHealthPerLevelByClass[36] = {5, 7, 9, 9, 4, 6, 8, 8, 5, 6, 8, 8, 4, 5, 6, 6, 3, 4, 6, 6, 4, 5, 6, 6, 2, 3, 4, 4, 2, 3, 4, 4, 2, 3, 3, 3}; unsigned char pBaseManaPerLevelByClass[36] = {0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 2, 3, 3, 1, 2, 3, 3, 0, 2, 3, 3, 3, 4, 5, 5, 3, 4, 5, 5, 3, 4, 6, 6}; -unsigned char pConditionStrengthMultiplier[19] = {100, 100, 100, 120, 50, 200, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}; -unsigned char pConditionIntelligenceMultiplier[19] = {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}; -unsigned char pConditionWillpowerMultiplier[19] = {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}; -unsigned char pConditionEnduranceMultiplier[19] = {100, 100, 100, 100, 50, 150, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}; -unsigned char pConditionAccuracyMultiplier[19] = {100, 100, 100, 50, 10, 100, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}; -unsigned char pConditionSpeedMultiplier[19] = {100, 100, 100, 120, 20, 120, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}; -unsigned char pConditionLuckMultiplier[19] = {100, 100, 100, 100, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}; - -unsigned char pAgeingStrengthMultiplier[4] = {100, 75, 40, 10}; -unsigned char pAgeingIntelligenceMultiplier[4] = {100, 150, 100, 10}; -unsigned char pAgeingWillpowerMultiplier[4] = {100, 150, 100, 10}; -unsigned char pAgeingEnduranceMultiplier[4] = {100, 75, 40, 10}; -unsigned char pAgeingAccuracyMultiplier[4] = {100, 100, 40, 10}; -unsigned char pAgeingSpeedMultiplier[4] = {100, 100, 40, 10}; -unsigned char pAgeingLuckMultiplier[4] = {100, 100, 100, 100}; +unsigned char pConditionAttributeModifier[7][19] = +{{100, 100, 100, 120, 50, 200, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Might + {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Intelligence + {100, 100, 100, 50, 25, 10, 100, 100, 75, 60, 50, 30, 100, 100, 100, 100, 100, 1, 100}, //Willpower + {100, 100, 100, 100, 50, 150, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 100, 100}, //Endurance + {100, 100, 100, 50, 10, 100, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Accuracy + {100, 100, 100, 120, 20, 120, 75, 60, 50, 30, 25, 10, 100, 100, 100, 100, 100, 50, 100}, //Speed + {100, 100, 100, 100, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}}; //Luck + +unsigned char pAgingAttributeModifier[7][4] = +{{100, 75, 40, 10}, //Might + {100, 150, 100, 10}, //Intelligence + {100, 150, 100, 10}, //Willpower + {100, 75, 40, 10}, //Endurance + {100, 100, 40, 10}, //Accuracy + {100, 100, 40, 10}, //Speed + {100, 100, 100, 100}}; //Luck signed int pAgeingTable[4] = {50, 100, 150, 0xFFFF}; @@ -422,11 +424,11 @@ { return 1; } - else if (GetMajorConditionIdx() == 18) + else if (GetMajorConditionIdx() == Condition_Good) { return 0; } - else if (GetMajorConditionIdx() == 17 && (v2 == 78 || v2 > 80) && v2 <= 82) + else if (GetMajorConditionIdx() == Condition_Zombie && (v2 == 78 || v2 == 81 || v2 == 82)) { return 0; } @@ -897,10 +899,12 @@ { bool result; // eax@2 - if ( this->pConditions[2] | this->pConditions[12] | this->pConditions[13] | this->pConditions[14] | this->pConditions[15] | this->pConditions[16] ) - result = 0; + if ( this->pConditions[Condition_Sleep] || this->pConditions[Condition_Paralyzed] || + this->pConditions[Condition_Unconcious] || this->pConditions[Condition_Dead] || + this->pConditions[Condition_Pertified] || this->pConditions[Condition_Eradicated] ) + result = false; else - result = 1; + result = true; return result; } @@ -2402,176 +2406,43 @@ //----- (0048C93C) -------------------------------------------------------- int Player::GetActualMight() { - Player *v1; // esi@1 - unsigned int v2; // eax@1 - signed int v3; // ecx@1 - signed int v4; // ebx@4 - int v5; // edi@5 - int v6; // ST14_4@5 - - v1 = this; - v2 = this->sAgeModifier + GetBaseAge(); - v3 = 0; - while ( (signed int)v2 >= (signed int)pAgeingTable[v3] ) - { - ++v3; - if ( v3 >= 4 ) - { - v4 = 100; - goto LABEL_5; - } - } - v4 = pAgeingStrengthMultiplier[v3]; -LABEL_5: - v5 = pConditionStrengthMultiplier[GetMajorConditionIdx()]; - v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_STRENGTH, 0); - return v5 * v4 * v1->uMight / 100 / 100 + GetMagicalBonus((CHARACTER_ATTRIBUTE_TYPE)0) + v6 + v1->uMightBonus; + return GetActualAttribute(CHARACTER_ATTRIBUTE_STRENGTH); } //----- (0048C9C2) -------------------------------------------------------- int Player::GetActualIntelligence() { - Player *v1; // esi@1 - unsigned int sAge; // eax@1 - signed int uAgeLevel; // ecx@1 - signed int v4; // ebx@4 - int v5; // edi@5 - int v6; // ebp@5 - - v1 = this; - sAge = this->sAgeModifier + GetBaseAge(); - uAgeLevel = 0; - while ( (signed int)sAge >= (signed int)pAgeingTable[uAgeLevel] ) - { - ++uAgeLevel; - if ( uAgeLevel >= 4 ) - { - v4 = 100; - goto LABEL_5; - } - } - v4 = pAgeingIntelligenceMultiplier[uAgeLevel]; -LABEL_5: - v5 = pConditionIntelligenceMultiplier[GetMajorConditionIdx()]; - v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE, 0); - return v5 * v4 * v1->uIntelligence / 100 / 100 - + GetMagicalBonus(CHARACTER_ATTRIBUTE_INTELLIGENCE) - + v6 - + v1->uIntelligenceBonus; + return GetActualAttribute(CHARACTER_ATTRIBUTE_INTELLIGENCE); } //----- (0048CA3F) -------------------------------------------------------- int Player::GetActualWillpower() { - int v5; // edi@5 - - uint uActualAge = GetBaseAge() + sAgeModifier; - uint uAgeingMultiplier = 100; - for (uint i = 0; i < 4; ++i) - if (uActualAge >= pAgeingTable[i]) - uAgeingMultiplier = pAgeingWillpowerMultiplier[i]; - else break; - - v5 = pConditionWillpowerMultiplier[GetMajorConditionIdx()]; - return v5 * uAgeingMultiplier * uWillpower / 100 / 100 - + GetMagicalBonus(CHARACTER_ATTRIBUTE_WILLPOWER) - + GetItemsBonus(CHARACTER_ATTRIBUTE_WILLPOWER, 0) - + uWillpowerBonus; + return GetActualAttribute(CHARACTER_ATTRIBUTE_WILLPOWER); } //----- (0048CABC) -------------------------------------------------------- int Player::GetActualEndurance() { - uint uActualAge = GetBaseAge() + sAgeModifier; - uint uAgeingMultiplier = 100; - for (uint i = 0; i < 4; ++i) - if (uActualAge >= pAgeingTable[i]) - uAgeingMultiplier = pAgeingEnduranceMultiplier[i]; - else break; - - auto uConditionMult = pConditionEnduranceMultiplier[GetMajorConditionIdx()]; - auto uItemBonus = GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0); - return uConditionMult * uAgeingMultiplier * uEndurance / 100 / 100 - + GetMagicalBonus(CHARACTER_ATTRIBUTE_ENDURANCE) - + uItemBonus - + uEnduranceBonus; + return GetActualAttribute(CHARACTER_ATTRIBUTE_ENDURANCE); } //----- (0048CB39) -------------------------------------------------------- int Player::GetActualAccuracy() { - Player *v1; // esi@1 - unsigned int v2; // eax@1 - signed int v3; // ecx@1 - signed int v4; // ebx@4 - int v5; // edi@5 - int v6; // ebp@5 - - v1 = this; - v2 = this->sAgeModifier + GetBaseAge(); - v3 = 0; - while ( (signed int)v2 >= (signed int)pAgeingTable[v3] ) - { - ++v3; - if ( v3 >= 4 ) - { - v4 = 100; - goto LABEL_5; - } - } - v4 = pAgeingAccuracyMultiplier[v3]; -LABEL_5: - v5 = pConditionAccuracyMultiplier[GetMajorConditionIdx()]; - v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_ACCURACY, 0); - return v5 * v4 * v1->uAccuracy / 100 / 100 - + GetMagicalBonus(CHARACTER_ATTRIBUTE_ACCURACY) - + v6 - + v1->uAccuracyBonus; + return GetActualAttribute(CHARACTER_ATTRIBUTE_ACCURACY); } //----- (0048CBB6) -------------------------------------------------------- int Player::GetActualSpeed() { - Player *v1; // esi@1 - unsigned int v2; // eax@1 - signed int v3; // ecx@1 - signed int v4; // ebx@4 - int v5; // edi@5 - int v6; // ebp@5 - - v1 = this; - v2 = this->sAgeModifier + GetBaseAge(); - v3 = 0; - while ( (signed int)v2 >= (signed int)pAgeingTable[v3] ) - { - ++v3; - if ( v3 >= 4 ) - { - v4 = 100; - goto LABEL_5; - } - } - v4 = pAgeingSpeedMultiplier[v3]; -LABEL_5: - v5 = pConditionSpeedMultiplier[GetMajorConditionIdx()]; - v6 = GetItemsBonus(CHARACTER_ATTRIBUTE_SPEED, 0); - return v5 * v4 * v1->uSpeed / 100 / 100 - + GetMagicalBonus(CHARACTER_ATTRIBUTE_SPEED) - + v6 - + v1->uSpeedBonus; + return GetActualAttribute(CHARACTER_ATTRIBUTE_SPEED); } //----- (0048CC33) -------------------------------------------------------- int Player::GetActualLuck() { - signed int curr_age; // eax@7 - signed int i; // ecx@7 - signed int age_luck_pc; // ebx@10 - int condition_luck_pc; // edi@11 - int items_luck_bonus; // ebp@11 signed int npc_luck_bonus; // [sp+10h] [bp-4h]@1 - signed int magic_luck_bonus; // [sp+10h] [bp-4h]@1 - int full_luck; npc_luck_bonus = 0; if ( CheckHiredNPCSpeciality(Fool) ) @@ -2580,25 +2451,67 @@ npc_luck_bonus += 20; if ( CheckHiredNPCSpeciality(Psychic) ) npc_luck_bonus += 10; - curr_age = sAgeModifier + GetBaseAge(); - i = 0; - while ( curr_age >= pAgeingTable[i] ) - { - ++i; - if ( i >= 4 ) + + return GetActualAttribute(CHARACTER_ATTRIBUTE_LUCK) + + npc_luck_bonus; +} + +//----- (new function) -------------------------------------------------------- +int Player::GetActualAttribute( CHARACTER_ATTRIBUTE_TYPE attrId ) +{ + unsigned __int16 attrValue = 0; + unsigned __int16 attrBonus = 0; + switch (attrId) + { + case CHARACTER_ATTRIBUTE_STRENGTH: + attrValue = uMight; + attrBonus = uMightBonus; + break; + case CHARACTER_ATTRIBUTE_INTELLIGENCE: + attrValue = uIntelligence; + attrBonus = uIntelligenceBonus; + break; + case CHARACTER_ATTRIBUTE_WILLPOWER: + attrValue = uWillpower; + attrBonus = uWillpowerBonus; + break; + case CHARACTER_ATTRIBUTE_ENDURANCE: + attrValue = uEndurance; + attrBonus = uEnduranceBonus; + break; + case CHARACTER_ATTRIBUTE_ACCURACY: + attrValue = uAccuracy; + attrBonus = uAccuracyBonus; + break; + case CHARACTER_ATTRIBUTE_SPEED: + attrValue = uSpeed; + attrBonus = uSpeedBonus; + break; + case CHARACTER_ATTRIBUTE_LUCK: + attrValue = uLuck; + attrBonus = uLuckBonus; + break; + default: + return 0; + } + + uint uActualAge = this->sAgeModifier + GetBaseAge(); + uint uAgeingMultiplier = 100; + for (uint i = 0; i < 4; ++i) + { + if (uActualAge >= pAgeingTable[i]) + uAgeingMultiplier = pAgingAttributeModifier[attrId][i]; + else break; } - if (i < 4) - age_luck_pc = pAgeingLuckMultiplier[i]; - else - age_luck_pc = 100; - - condition_luck_pc = pConditionLuckMultiplier[GetMajorConditionIdx()]; - items_luck_bonus = GetItemsBonus(CHARACTER_ATTRIBUTE_LUCK, 0); - magic_luck_bonus = GetMagicalBonus(CHARACTER_ATTRIBUTE_LUCK); - full_luck = magic_luck_bonus + items_luck_bonus + npc_luck_bonus+ uLuckBonus - + condition_luck_pc * age_luck_pc * uLuck / 100 / 100; - return full_luck; + + auto uConditionMult = pConditionAttributeModifier[attrId][GetMajorConditionIdx()]; + int magicBonus = GetMagicalBonus(attrId); + int itemBonus = GetItemsBonus(attrId, 0); + return uConditionMult * uAgeingMultiplier * attrValue / 100 / 100 + + magicBonus + + magicBonus + + attrBonus; } //----- (0048CCF5) -------------------------------------------------------- @@ -7893,11 +7806,11 @@ { if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_autonote_bits[((signed __int16)var_value - 1) >> 3]) //&& (&dword_723718_autonote_related)[8 * a3] ) - && pAutonoteTxt[var_value-1].pText ) + && pAutonoteTxt[var_value].pText ) { v20 = pPlayers[currPlayerId + 1]; v20->PlaySound(SPEECH_96, 0); - v21 = pAutonoteTxt[var_value-1].eType;// dword_72371C[2 * a3]; + v21 = pAutonoteTxt[var_value].eType;// dword_72371C[2 * a3]; bFlashAutonotesBook = 1; _506568_autonote_type = v21; DrawPlayerBuffAnimBasedOnCondition(currPlayerId); @@ -7924,7 +7837,7 @@ if (v9->uItemID == 615) break; } - if (v9 != NULL || v9->uItemID != 615) + if (v9 != NULL && v9->uItemID != 615) { v10 = (int)((char *)this + 36 * 138); //originally 36 * v8. the code got to this condition only if v8 was equal to 138 *(int *)(v10 + 532) = 601; @@ -7998,7 +7911,7 @@ case VAR_QBits_QuestsDone: if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_quest_bits[((signed __int16)var_value - 1) >> 3]) // && (&dword_722F10)[4 * a3] ) - && pQuestTable[var_value-1] ) + && pQuestTable[var_value] ) { v14 = pPlayers[currPlayerId + 1]; bFlashQuestBook = 1; @@ -8425,7 +8338,7 @@ case VAR_QBits_QuestsDone: if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_quest_bits[((signed __int16)val - 1) >> 3]) //&& (&dword_722F10)[4 * val] ) - && pQuestTable[val-1] ) + && pQuestTable[val] ) { //v17 = pPlayers[uPlayerIdx + 1]; bFlashQuestBook = 1; @@ -8690,12 +8603,12 @@ } if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_autonote_bits[((signed __int16)val - 1) >> 3]) //&& (&dword_723718_autonote_related)[8 * val] ) - && pAutonoteTxt[val-1].pText ) + && pAutonoteTxt[val].pText ) { v23 = pPlayers[uPlayerIdx + 1]; v34 = 1; v23->PlaySound(SPEECH_96, 0); - v24 = pAutonoteTxt[val-1].eType;//dword_72371C[2 * val]; + v24 = pAutonoteTxt[val].eType;//dword_72371C[2 * val]; bFlashAutonotesBook = 1; _506568_autonote_type = v24; }
--- a/Player.h Fri Jul 05 21:15:53 2013 +0600 +++ b/Player.h Fri Jul 05 21:16:12 2013 +0600 @@ -477,6 +477,7 @@ bool CompareVariable(enum VariableType VarNum, signed int pValue); void UseItem_DrinkPotion_etc(signed int a2, int a3); bool AddItem(struct ItemGen *pItem); + int GetActualAttribute(CHARACTER_ATTRIBUTE_TYPE attrId); int GetBaseStrength(); int GetBaseIntelligence(); int GetBaseWillpower(); @@ -621,7 +622,6 @@ inline void SetZombie(bool state) {pConditions[Condition_Zombie] = state;} - __int64 pConditions[20]; unsigned __int64 uExperience; char pName[16];
--- a/Render.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/Render.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -1670,24 +1670,13 @@ // 4D864C: using guessed type char byte_4D864C; -void Render::RenderTerrainD3D() // New function. It's temporary +void Render::RenderTerrainD3D() // New function { char result; // al@3 - //int v1; // eax@3 - //int v2; // ebx@4 - //struct ODMFace *v4; // esi@6 int v6; // ecx@8 - //int v7; // ecx@8 - struct stru148 *v8; // ebx@8 -// RenderVertexSoft *v8a; // edi@3 - //char v11; // zf@8 + struct stru148 *pTile; // ebx@8 struct stru148 *v16; unsigned int v18; // edi@22 - //int v20; // edi@34 - //int v28; // eax@50 - //int v29; // ecx@55 - //int v30; // eax@57 - int v31; // eax@57 int v35; // edi@63 int v37; // eax@73 int v39; // eax@80 @@ -1697,156 +1686,145 @@ int v43; // [sp-Ch] [bp-64h]@2 const char *v44; // [sp-8h] [bp-60h]@2 int v45; // [sp-4h] [bp-5Ch]@2 - //float v48; // [sp+14h] [bp-44h]@8 - //void *v52; // [sp+24h] [bp-34h]@3 - bool v54; // [sp+2Ch] [bp-2Ch]@10 - int v55; // [sp+30h] [bp-28h]@34 int v56; int v57; // [sp+38h] [bp-20h]@36 - int v58; // [sp+3Ch] [bp-1Ch]@8 - int v63; // [sp+50h] [bp-8h]@3 int v64; // [sp+57h] [bp-1h]@2 int v62; - //struct IndoorCameraD3D *pIndoorCameraD3D; - //RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 - //warning: the game uses CW culling by default, ccw is incosistent pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); - - v63 = 0; - // basic optimizations - unsigned int uStartX, uEndX, uStartZ, uEndZ; - if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024) - { - uStartX = 0, uEndX = 128; - uStartZ = 0, uEndZ = 64 + 16; - } - else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536) - { - uStartX = 0, uEndX = 64 + 16; - uStartZ = 0, uEndZ = 128; - } - else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512) - { - uStartX = 64 - 16, uEndX = 128; - uStartZ = 0, uEndZ = 128; - } - else - { - uStartX = 0, uEndX = 128; - uStartZ = 64 - 16, uEndZ = 128; - } - uStartX = 0, uEndX = 128; - uStartZ = 0, uEndZ = 128; - static RenderVertexSoft pTerrainVertices[128 * 128]; - for (unsigned int z = uStartZ; z < uEndZ; ++z) - { - for (unsigned int x = uStartX; x < uEndX; ++x) - { - pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; - pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512; - pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; - //pIndoorCameraD3D = pGame->pIndoorCameraD3D; + static RenderVertexSoft pTerrainVertices[128 * 128];//vertexCountX and vertexCountZ + + // ------------------------------------------------------------------------- + // -64 0 0 64 + // + // -64 X 0 64 + // --------------- 64 + // | | | + // | | | + // | | | + // 0|------+------| Z + // | | | + // | | | + // | | | + // --------------- + // -64 + + int blockScale = 512; + int heightScale = 32; + for (unsigned int z = 0; z < 128; ++z) + { + for (unsigned int x = 0; x < 128; ++x) + { + pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * blockScale; + pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * blockScale; + pTerrainVertices[z * 128 + x].vWorldPosition.z = heightScale * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; pGame->pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); pGame->pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); } } - - for (unsigned int z = uStartZ; z < uEndZ - 1; ++z) - { - for (unsigned int x = uStartX; x < uEndX - 1; ++x) - { - v8 = &array_77EC08[pOutdoorCamera->numStru148s]; - v8->flags = 0; - v8->field_32 = 0; - //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x]; - //struct TileDesc *pTile = pTileTable->GetTileById(uTileID); - v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); - //v6 = v8->uTileBitmapID; - v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v8->uTileBitmapID]; - if (v8->uTileBitmapID == 0xFFFF) +//-------------------------------------------------------------------------------------------------------------------- + + // + for (unsigned int z = 0; z < 128; ++z) + { + for (unsigned int x = 0; x < 128; ++x) + { + pTile = &array_77EC08[pOutdoorCamera->numStru148s]; + pTile->flags = 0; + pTile->field_32 = 0; + pTile->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); + pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTile->uTileBitmapID]; + if (pTile->uTileBitmapID == 0xFFFF) continue; - v8->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); - v8->field_32 = 0; - v8->field_59 = 1; - //v8->field_5D = (char)WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8a->vWorldPosition.z) / 2 + 0.5f)); - //v8->field_5C = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f));; - v8->sTextureDeltaU = 0; - v8->sTextureDeltaV = 0; - memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft)); + //pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(x, z); + pTile->flags = pOutdoor->GetSomeOtherTileInfo(x, z); + pTile->field_32 = 0; + pTile->field_59 = 1; + pTile->sTextureDeltaU = 0; + pTile->sTextureDeltaV = 0; +// x,z x+1,z +// .____________. +// | | +// | | +// | | +// | | +// | | +// .____________. +// x,z+1 x+1,z+1 + memcpy(&array_73D150[0], &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft));//x, z array_73D150[0].u = 0; array_73D150[0].v = 0; - memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft)); + memcpy(&array_73D150[1], &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z array_73D150[1].u = 1; array_73D150[1].v = 0; - memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft)); + memcpy(&array_73D150[2], &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft));//x + 1, z + 1 array_73D150[2].u = 1; array_73D150[2].v = 1; - memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft)); + memcpy(&array_73D150[3], &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft));//x, z + 1 array_73D150[3].u = 0; array_73D150[3].v = 1; - v55 = 0; - v54 = false; - v58 = 0; - if (v58 == 4) // if all y == first y; primitive in xz plane - v8->field_32 |= 0x0001; - v8->pODMFace = nullptr; - v8->uNumVertices = 4; - v8->field_59 = 5; - - - uint norm_idx = pTerrainNormalIndices[2 * (x + 128 * z) + 1]; + //v58 = 0; + //if (v58 == 4) // if all y == first y; primitive in xz plane + //pTile->field_32 |= 0x0001; + pTile->pODMFace = nullptr; + pTile->uNumVertices = 4; + pTile->field_59 = 5; + +//shading ()---------------------------------------------------------------------------- + //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; + uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1];// 1 , 1 assert(norm_idx < uNumTerrainNormals); auto norm = pTerrainNormals + norm_idx; - float _f = (norm->x * (float)pOutdoor->vSunlight.x / 65536.0 - - norm->y * (float)pOutdoor->vSunlight.y / 65536.0 - - norm->z * (float)pOutdoor->vSunlight.z / 65536.0); - v8->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); + float _f = ((norm->x * (float)pOutdoor->vSunlight.x / 65536.0) - + (norm->y * (float)pOutdoor->vSunlight.y / 65536.0) - + (norm->z * (float)pOutdoor->vSunlight.z / 65536.0)); + pTile->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); +//----------------------------------------------------------------------------------------------- ++pOutdoorCamera->numStru148s; ++pOutdoorCamera->field_44; assert(pOutdoorCamera->numStru148s < 20000); - v8->uBModelID = 0; - v8->uBModelFaceID = 0; - v31 = (8 * (0 | (0 << 6))); - v8->field_50 = v31 | 6; - for (unsigned int k = 0; k < v8->uNumVertices; ++k) + pTile->uBModelID = 0; + pTile->uBModelFaceID = 0; + pTile->field_50 = (8 * (0 | (0 << 6))) | 6; + for (unsigned int k = 0; k < pTile->uNumVertices; ++k) { memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); array_50AC10[k]._rhw = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); } +// check the transparency and texture (tiles) mapping ( ())---------------------- bool transparent = false; - if ( v8->flags & 2 && v8->uTileBitmapID == pRenderer->hd_water_tile_id) - { - //v80 = false; - v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v6 = v8->uTileBitmapID; - if ( !_strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5) ) - transparent = true; - } + if ( !( pTile->flags & 1 ) ) // TextureFrameTable + { + if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id) + { + //transparent = false; + v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v6 = pTile->uTileBitmapID; + if ( !_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5) ) + transparent = true; + } assert(v6 < 1000); // many random crashes here // for all shore tiles - draw a tile water under them since they're half-empty - if (!_strnicmp(pBitmaps_LOD->pTextures[v8->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX - { - pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, FALSE); // no Z writing: the shore tile will be draw in the same place, so taking care about z-fighting - pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true); - pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE); - - } - - pRenderer->DrawTerrainPolygon(v8->uNumVertices, v8, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); - + if (!_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX + pTile->DrawBorderTiles(); + + pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); + } + //else // + //pTile->DrawBorderTiles(); +//-------------------------------------------------------------------------------------------------------------------------------- --pOutdoorCamera->numStru148s; --pOutdoorCamera->field_44; @@ -1870,15 +1848,12 @@ double v13; // ST2C_8@6 int v14; // eax@6 double v15; // st7@6 - stru148 *v16; // ebx@12 + stru148 *pTile; // ebx@12 unsigned __int16 v17; // ax@12 int v18; // eax@13 - int v19; // ecx@13 - int v20; // eax@13 - int v21; // eax@13 signed int v22; // eax@13 - Vec3_float_ *v23; // eax@15 - double v24; // st6@17 + Vec3_float_ *norm; // eax@15 + //double v24; // st6@17 double v25; // ST54_8@17 unsigned __int8 v26; // sf@17 unsigned __int8 v27; // of@17 @@ -1893,7 +1868,7 @@ char v35; // zf@47 unsigned int v36; // eax@50 int v37; // eax@54 - stru148 *v38; // ecx@55 + //stru148 *v38; // ecx@55 unsigned int v39; // eax@59 stru148 *v40; // ebx@62 unsigned __int16 pTileBitmapsID; // ax@62 @@ -1945,9 +1920,6 @@ float v87; // [sp+78h] [bp-58h]@122 int v88; // [sp+7Ch] [bp-54h]@1 int v89; // [sp+80h] [bp-50h]@6 - float v90; // [sp+84h] [bp-4Ch]@1 - float v91; // [sp+88h] [bp-48h]@1 - float v92; // [sp+8Ch] [bp-44h]@1 int v93; // [sp+90h] [bp-40h]@2 int X; // [sp+94h] [bp-3Ch]@1 float v95; // [sp+98h] [bp-38h]@21 @@ -1985,9 +1957,6 @@ v4 = 0; v88 = 0; v84 = a1 - 1; - v90 = (float)pOutdoor->vSunlight.x / 65536.0; - v91 = (float)pOutdoor->vSunlight.y / 65536.0; - v92 = (float)pOutdoor->vSunlight.z / 65536.0; /* if ( a1 - 1 > 0 ) { while ( 1 ) @@ -2043,31 +2012,28 @@ if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) break;*/ - v16 = &array_77EC08[pOutdoorCamera->numStru148s]; - v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( v16->uTileBitmapID != -1 ) - { - v19 = v97; - v16->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); - v16->field_32 = 0; - v20 = v93; - v16->field_59 = 1; - v16->terrain_grid_x = (char)v19; - v16->field_34 = *(_WORD *)(v20 + 2); - v21 = v89; - v16->terrain_grid_z = v89; - v22 = pTerrainNormalIndices[2 * (v19 + 128 * v21) + 1]; + pTile = &array_77EC08[pOutdoorCamera->numStru148s]; + 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 ) - v23 = 0; + norm = 0; else - v23 = &pTerrainNormals[v22]; - v24 = v92 * v23->z; - //v99 = v23; - thisf = 20.0 - (-v24 - v91 * v23->y - v90 * v23->x) * 20.0; + 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->numStru148s > 1999; //v26 = pOutdoorCamera->numStru148s - 1999 < 0; - v16->dimming_level = floorf(thisf + 0.5f); + pTile->dimming_level = floorf(thisf + 0.5f); if ( pOutdoorCamera->numStru148s >= 1999 ) return; ++pOutdoorCamera->numStru148s; @@ -2101,8 +2067,8 @@ }*/ v32 = (struct8 *)array_50AC10; v97 = (int)pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v23, &v95, array_50AC10, 4, 1); - pDecalBuilder->_49BE8A(v16, v23, &v95, array_50AC10, 4, 1); + 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 ) { @@ -2125,55 +2091,54 @@ v33 = 3; else v33 = v108 != 0 ? 5 : 0; - static_sub_0048034E_stru_154.ClassifyPolygon(v23, v95); + static_sub_0048034E_stru_154.ClassifyPolygon(norm, v95); if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v16->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); + 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; - v16->uNumVertices = a5; + pTile->uNumVertices = a5; if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) { if ( this_3 ) { v36 = sr_424CD7(v34); - v16->uNumVertices = v36; + pTile->uNumVertices = v36; OutdoorCamera::Project(v36); } if ( v108 ) { v36 = sr_424EE0_MakeFanFromTriangle(v34); - v16->uNumVertices = v36; + pTile->uNumVertices = v36; OutdoorCamera::Project(v36); } } //v37 = *(int *)&v16->flags; - if ( ~v16->flags & 1 ) + if ( ~pTile->flags & 1 ) { - if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->hd_water_tile_id ) + if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id ) { v80 = false; v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; } else { - v39 = v16->uTileBitmapID; + v39 = pTile->uTileBitmapID; v80 = true; } //v79 = 0; //v78 = pBitmaps_LOD->pHardwareTextures[v39]; - v16->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary - v77 = (int)v16; + pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary + v77 = (int)pTile; //v76 = v16->uNumVertices; //LABEL_161: - pRenderer->DrawTerrainPolygon(v16->uNumVertices, v16, pBitmaps_LOD->pHardwareTextures[v39], false, v80); + pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v39], false, v80); goto LABEL_162; } - v38 = v16; LABEL_56: - v38->_4811A3(); + pTile->DrawBorderTiles(); } LABEL_162: v4 = v88 + 1; @@ -2298,7 +2263,7 @@ v57 = *(int *)&v40->flags; if ( BYTE1(v57) & 1 ) { - v40->_4811A3(); + v40->DrawBorderTiles(); } else {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TurnEngine.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -0,0 +1,1739 @@ + +#include "MM7.h" +#include "mm7_data.h" +#include "Actor.h" +#include "Player.h" +#include "Party.h" +#include "AudioPlayer.h" +#include "SpriteObject.h" +#include "Time.h" +#include "stru298.h" +#include "IconFrameTable.h" +#include "Viewport.h" +#include "FactionTable.h" + +#include "TurnEngine.h" + + +#include "TurnEngine.h" +struct stru262_TurnBased *pTurnEngine = new stru262_TurnBased; + + +//----- (00404544) -------------------------------------------------------- +void stru262_TurnBased::SortTurnQueue() + { + + int active_actors; + TurnBased_QueueElem *v7; // eax@16 + TurnBased_QueueElem *v8; // ecx@18 + TurnBased_QueueElem temp_elem; + int i,j; + unsigned int p_type; + unsigned int p_id; + + active_actors = this->uActorQueueSize; + + for( i=0; i<uActorQueueSize; ++i) + { + p_type = PID_TYPE(pQueue[i].uPackedID); + p_id = PID_ID(pQueue[i].uPackedID); + + if ( p_type == OBJECT_Actor ) + { + pActors[p_id].uAttributes |= 0x80u; + if ( !pActors[p_id].CanAct() ) + { + --active_actors; + pQueue[i].field_4 = 1001; + pActors[p_id].uAttributes &= ~0x80; + } + } + else if ( p_type == OBJECT_Player) + { + if ( !pParty->pPlayers[p_id].CanAct() ) + { + --active_actors; + pQueue[i].field_4 = 1001; + } + } + } + //sort +if (uActorQueueSize>0) + { + + for( i=0; i<uActorQueueSize-1; ++i) + { + v7=&pQueue[i]; + for(j=i+1; j<uActorQueueSize;++j ) + { + v8=&pQueue[j]; + if ( v8->field_4 < v7->field_4 || + ((v8->field_4 == v7->field_4) && + ( + ((PID_TYPE(v8->uPackedID) == OBJECT_Player) && (PID_TYPE(v7->uPackedID) == OBJECT_Actor)) || + ((PID_TYPE(v8->uPackedID) == PID_TYPE(v7->uPackedID)) && (PID_ID(v8->uPackedID) < PID_ID(v7->uPackedID))) + ) + ) + ) + { + memcpy(&temp_elem,v7,sizeof(TurnBased_QueueElem)); + memcpy(v7,v8, sizeof(TurnBased_QueueElem)); + memcpy(v8, &temp_elem, sizeof(TurnBased_QueueElem)); + } + } + } + } + + uActorQueueSize = active_actors; + + if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) + { + uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1; + field_18 |= TE_PLAYER_TURN; + } + else + { + uActiveCharacter = 0; + field_18 &= ~TE_PLAYER_TURN; + } + + for(i=0; i<uActorQueueSize; ++i) + { + if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) + pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 0.46875); + } + + + } + +//----- (0040471C) -------------------------------------------------------- +void stru262_TurnBased::_40471C() + { + if ( pParty->bTurnBasedModeOn == 1 ) + { + if ( pTurnEngine->field_4 == 2 ) + _406457(0); + } + } + +//----- (004059DB) -------------------------------------------------------- +void stru262_TurnBased::Start() + { + //stru262_TurnBased *v1; // ebx@1 + int v3; // esi@1 + int v4; // eax@5 + unsigned int actor_id; // esi@7 + Actor *pActor; // edi@7 + unsigned int v7; // eax@9 + unsigned int v8; // edx@10 + //unsigned __int8 v9; // zf@14 + //unsigned __int8 v10; // sf@14 + //unsigned __int8 v11; // of@14 + //char *v12; // esi@15 + //int v13; // ecx@16 + //unsigned __int16 v14; // ax@17 + int v15; // ecx@18 + signed __int64 v16; // qax@19 + int v17; // edx@22 + unsigned int v18; // esi@27 + char *v19; // esi@32 + int v20; // edx@33 + char *v21; // eax@33 + int v22; // ecx@33 + int v23; // eax@34 + char *v24; // eax@34 + char *v25; // ecx@34 + int v26; // edx@34 + int v27; // eax@38 + int v28; // ecx@38 + AIDirection v30; // [sp+Ch] [bp-68h]@10 + AIDirection v31; // [sp+28h] [bp-4Ch]@10 + AIDirection a3; // [sp+44h] [bp-30h]@10 + //int v33; // [sp+60h] [bp-14h]@10 + int *v34; // [sp+64h] [bp-10h]@6 + int v35; // [sp+68h] [bp-Ch]@5 + Player *pPlayer; // [sp+6Ch] [bp-8h]@1 + int v40b; + unsigned int v37; // [sp+70h] [bp-4h]@7 + int activ_players[4]; + int players_recovery_time[4]; + int a_players_count; + int i,j; + int temp; + + + pTurnEngine->field_18 &= ~TE_FLAG_2; + //v1 = this; + pEventTimer->TrackGameTime(); + pAudioPlayer->StopChannels(-1, -1); + pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0); + pPlayer = pParty->pPlayers; + dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength; + dword_50C994 = 0; + + this->field_10 = 100; + this->field_0 = 0; + this->field_8 = 64; + this->field_4 = 1; + this->uActorQueueSize = 0; + + for ( v3 = 0; v3 < 4 ; ++v3 ) + { + if ( pParty->pPlayers[v3].CanAct() ) + { + this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Player,v3); + this->pQueue[this->uActorQueueSize].field_C = 2; + this->pQueue[this->uActorQueueSize].uActionLength = 0; + pParty->pTurnBasedPlayerRecoveryTimes[this->uActorQueueSize] = 0; + ++this->uActorQueueSize; + } + } + + for ( v3 = 0; v3 < ai_arrays_size ; ++v3 ) + { + actor_id = ai_near_actors_ids[v3]; + if (actor_id == 10) + continue; + if ( pActors[actor_id].CanAct() ) + { + if ( pActors[actor_id].uAttributes & 0x8000 ) + { + v8 = ai_near_actors_targets_pid[actor_id]; + pActors[actor_id].uAttributes |= 0x80; + memcpy(&v31, Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), v8, &a3, 0), sizeof(AIDirection)); + memcpy(&v30, &v31, sizeof(AIDirection)); + Actor::AI_StandOrBored(actor_id, 4, 32, &v30); + this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Actor,actor_id); + this->pQueue[this->uActorQueueSize].field_C = 2; + this->pQueue[this->uActorQueueSize].uActionLength = 0; + ++this->uActorQueueSize; + } + } + } + + a_players_count=0; + for ( v40b = 0; v40b < this->uActorQueueSize; ++v40b ) + { + //v13 = PID_TYPE(this->pQueue[0].uPackedID); + if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Player ) + { + if ( pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery != 0 ) + { + //v33 = pPlayers[(this->pQueue[0].uPackedID >> 3) + 1]->uTimeToRecovery; + v16 = (signed int)((double)pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery * 0.46875); + this->pQueue[v40b].field_4 = v16; + } + else + { + activ_players[a_players_count] = v40b; + ++a_players_count; + } + } + else if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Actor ) + { + v17 = rand() % 99; + if ( v17 < 33 ) + this->pQueue[v40b].field_4 = 1; + else + this->pQueue[v40b].field_4= (v17 >= 66)? 5 : 3; + } + else + { + this->pQueue[v40b].field_4 = 666; + } + this->pQueue[v40b].field_4 += 16; + } + + + if ( a_players_count > 0 ) + { + for (i=0; i<a_players_count; ++i) + players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0); + //sort players by recovery time + for (i=0; i < a_players_count-1; ++i) + { + for(j=i+1; j<a_players_count;++j ) + { + if (players_recovery_time[j] < players_recovery_time[i]) //swap values + { + temp = players_recovery_time[i]; + players_recovery_time[i] = players_recovery_time[j]; + players_recovery_time[j] = temp; + + temp = activ_players[i]; + activ_players[i] = activ_players[j]; + activ_players[j] = temp; + } + } + } + + for (i=0; i<a_players_count; ++i) + { + this->pQueue[activ_players[i]].field_4 = i+2; + } + } + this->SortTurnQueue(); + } + + + +//----- (00405CFF) -------------------------------------------------------- +void stru262_TurnBased::End(bool bPlaySound) + { + + ObjectType objType; // eax@13 + int objID; // esi@13 + int i; + + this->field_4 = 0; + + for( i=0; i<uActorQueueSize; ++i) + { + if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor ) + pActors[PID_ID(pQueue[i].uPackedID)].uAttributes &= ~0x80; + } + + for( i=0; i<uNumSpriteObjects; ++i) + { + if (pSpriteObjects[i].uAttributes & 4) + pSpriteObjects[i].uAttributes &= ~0x04; + } + + for( i=0; i<uActorQueueSize; ++i) + { + objType = (ObjectType)PID_TYPE(pQueue[i].uPackedID); + objID = PID_ID(pQueue[i].uPackedID); + if ( objType == OBJECT_Player ) + { + pPlayers[objID + 1]->uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 2.133333333333333); + } + else if ( objType == OBJECT_Actor ) + { + pActors[objID].pMonsterInfo.uRecoveryTime = (signed __int64)((double)pQueue[i].field_4 * 2.133333333333333); + } + } + + pAudioPlayer->StopChannels(-1, -1); + if ( bPlaySound != 0 ) + pAudioPlayer->PlaySound(SOUND_206, 0, 0, -1, 0, 0, 0, 0); + pTurnEngine->field_18 &= ~TE_FLAG_2; + pEventTimer->StopGameTime(); + dword_50C994 = 0; + dword_50C998_turnbased_icon_1A = 0; + } +// 50C994: using guessed type int dword_50C994; +// 50C998: using guessed type int dword_50C998_turnbased_icon_1A; + +//----- (00405E14) -------------------------------------------------------- +void stru262_TurnBased::_405E14() + { + stru262_TurnBased *v1; // esi@1 + int v2; // ecx@1 + SpellBuff *v3; // edi@2 + Actor *v4; // ebx@3 + signed int v5; // edx@20 + AIDirection *v6; // esi@21 + int v7; // eax@21 + int v8; // eax@21 + int v9; // eax@22 + int v10; // eax@23 + int v11; // eax@37 + int v12; // eax@44 + AIDirection a3; // [sp+4h] [bp-68h]@21 + AIDirection v14; // [sp+20h] [bp-4Ch]@21 + AIDirection v15; // [sp+3Ch] [bp-30h]@21 + Actor *v16; // [sp+58h] [bp-14h]@2 + int v17; // [sp+5Ch] [bp-10h]@6 + stru262_TurnBased *v18; // [sp+60h] [bp-Ch]@1 + int v19; // [sp+64h] [bp-8h]@8 + unsigned int v20; // [sp+68h] [bp-4h]@1 + + v1 = this; + v2 = 0; + v18 = v1; + v20 = 0; + if ( (signed int)uNumActors > 0 ) + { + //v3 = pActors;//[0].pActorBuffs; + v16 = pActors.data();//[0].pActorBuffs; + v3 = v16->pActorBuffs; + do + { + v4 = v16; + if ( SHIDWORD(v3[3].uExpireTime) < v2 || SHIDWORD(v3[3].uExpireTime) <= v2 && LODWORD(v3[3].uExpireTime) <= v2 ) + v17 = v2; + else + v17 = 1; + v19 = v2; + do + { + if ( v19 != 10 ) + { + v3->_4585CA(pParty->uTimePlayed); + v2 = 0; + } + ++v19; + ++v3; + } + while ( v19 < 22 ); + if ( v17 != 0 + && SHIDWORD(v4->pActorBuffs[3].uExpireTime) <= 0 + && (SHIDWORD(v4->pActorBuffs[3].uExpireTime) < 0 || LODWORD(v4->pActorBuffs[3].uExpireTime) <= 0) ) + v4->uActorHeight = pMonsterList->pMonsters[v4->pMonsterInfo.uID - 1].uMonsterHeight; + if ( !(v4->uAttributes & 0x80) ) + { + if ( !v4->pActorBuffs[5].uExpireTime ) + { + if ( !v4->pActorBuffs[6].uExpireTime ) + { + v5 = v4->uCurrentActionLength; + v4->uCurrentActionTime += pMiscTimer->uTimeElapsed; + if ( (signed int)v4->uCurrentActionTime >= v5 ) + { + v17 = ai_near_actors_targets_pid[v20]; + v6 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v20), v17, &a3, 0); + v7 = v4->uAIState; + memcpy(&v15, v6, sizeof(v15)); + v8 = v7 - 4; + memcpy(&v14, &v15, sizeof(v14)); + if ( v8 ) + { + v9 = v8 - 1; + if ( v9 ) + { + v10 = v9 - 6; + if ( v10 ) + { + if ( v10 != 8 ) + Actor::AI_StandOrBored(v20, v17, 32, &v14); + } + } + } + else + { + v4->uCurrentActionTime = 0; + v4->uCurrentActionLength = 0; + v4->uAIState = Dead; + v4->UpdateAnimation(); + } + v1 = v18; + v2 = 0; + } + } + } + } + ++v20; + v3 = v16[1].pActorBuffs; + ++v16; + } + while ( (signed int)v20 < (signed int)uNumActors ); + } + if ( v1->field_4 == 1 ) + { + v12 = v1->field_8; + if ( v12 == 64 ) + { + v1->_406A63(); + } + else + { + if ( v12 > 0 ) + { + v1->_406B9F(); + } + else + { + v1->_406AFE(); + v1->field_10 = 100; + } + } + v1->field_8 -= pEventTimer->uTimeElapsed; + return; + } + if ( v1->field_4 == 2 ) + { + if ( !(v1->field_18 & TE_FLAG_1) ) + { + v11 = v1->field_10; + if ( v11 == 100 ) + { + v1->StartTurn(); +LABEL_39: + v1->_40652A(); + return; + } + if ( v11 > 0 || v1->pQueue[0].field_4 <= 0 ) + { + v1->_4065B0(); + goto LABEL_39; + } + } + v1->NextTurn(); + return; + } + if ( v1->field_4 == 3 ) + { + if ( v1->uActionPointsLeft <= 0 || v1->field_18 & TE_FLAG_8 ) + { + v1->field_18 &= ~TE_FLAG_8; + v1->field_4 = 1; + v1->field_8 = 64; + } + else + { + v1->_406FA8(); + } + } + } + + +//----- (00406051) -------------------------------------------------------- +__int16 stru262_TurnBased::StartTurn() + { + stru262_TurnBased *v1; // esi@1 + int v2; // ecx@1 + int v3; // ebx@1 + char *v4; // edi@1 + int v5; // eax@4 + int v6; // eax@12 + char *v7; // eax@15 + TurnBased_QueueElem *v8; // edi@17 + unsigned int v9; // edx@23 + char *v10; // eax@26 + int v11; // eax@30 + int v12; // ebx@30 + char *v13; // edi@31 + int v15; // [sp+Ch] [bp-10h]@5 + TurnBased_QueueElem *v16; // [sp+10h] [bp-Ch]@3 + int v17; // [sp+14h] [bp-8h]@2 + int v18; // [sp+14h] [bp-8h]@16 + signed int v19; // [sp+18h] [bp-4h]@1 + int v20; // [sp+18h] [bp-4h]@14 + + v1 = this; + v2 = 0; + v19 = 0; + v3 = v1->uActorQueueSize; + v1->field_1C = 0; + v4 = (char *)&v1->pQueue[v3].field_4; + do + { + v17 = v2; + if ( v1->uActorQueueSize <= v2 ) + goto LABEL_11; + v16 = v1->pQueue; + while ( 1 ) + { + v5 = v16->uPackedID; + if ( PID_TYPE(v16->uPackedID) == OBJECT_Player) + break; +LABEL_8: + ++v17; + ++v16; + if ( v17 >= v1->uActorQueueSize ) + goto LABEL_11; + } + v15 = PID_ID(v5); + if ( !pPlayers[(PID_ID(v5)) + 1]->CanAct() || v19 != v15 ) + { + v2 = 0; + goto LABEL_8; + } + v2 = 0; +LABEL_11: + if ( v17 == v1->uActorQueueSize ) + { + *(int *)v4 = 100; + v6 = 8 * v19; + LOBYTE(v6) = PID(OBJECT_Player,v19); + *((int *)v4 + 2) = v2; + *((int *)v4 - 1) = v6; + *((int *)v4 + 1) = v2; + ++v3; + v4 += 16; + } + ++v19; + } + while ( v19 < 4 ); + v1->uActorQueueSize = v3; + v20 = v2; + if ( ai_arrays_size > v2 ) + { + v7 = (char *)&v1->pQueue[v3].field_4; + do + { + v18 = v2; + if ( v1->uActorQueueSize > v2 ) + { + v8 = v1->pQueue; + do + { + if ( PID_TYPE(v8->uPackedID) == OBJECT_Actor && ai_near_actors_ids[v20] == PID_ID(v8->uPackedID) ) + break; + ++v18; + ++v8; + } + while ( v18 < v1->uActorQueueSize ); + v2 = 0; + } + if ( v18 == v1->uActorQueueSize ) + { + v9 = ai_near_actors_ids[v20]; + *(int *)v7 = 1; + *((int *)v7 + 2) = v2; + *((int *)v7 - 1) = PID(OBJECT_Actor,v9); + *((int *)v7 + 1) = v2; + ++v3; + v7 += 16; + } + ++v20; + } + while ( v20 < ai_arrays_size ); + } + ++v1->field_0; + v1->uActorQueueSize = v3; + v1->field_10 = 100; + if ( v3 > 0 ) + { + v10 = (char *)&v1->pQueue[0].field_4; + do + { + if ( *(int *)v10 <= 0 ) + *(int *)v10 = 100; + ++v2; + v10 += 16; + } + while ( v2 < v1->uActorQueueSize ); + } + LOWORD(v11) = v1->_4063A1(); + v12 = 0; + if ( v1->uActorQueueSize > 0 ) + { + v13 = (char *)&v1->pQueue[0].field_4; + do + { + v11 = PID_TYPE(*((int *)v13 - 1)); + if ( (char)v11 == 4 ) + break; + if ( *(int *)v13 > 0 ) + break; + LOWORD(v11) = v1->_40680F(v12++); + v13 += 16; + } + while ( v12 < v1->uActorQueueSize ); + } + return v11; + } +// 4F75D8: using guessed type int ai_arrays_size; + +//----- (004061CA) -------------------------------------------------------- +void stru262_TurnBased::NextTurn() + { + stru262_TurnBased *v1; // esi@1 + TurnBased_QueueElem *v2; // ebp@1 + int v3; // ebx@1 + int v4; // edi@7 + Actor *v5; // eax@9 + int v6; // ecx@9 + signed int v7; // ebx@17 + int v8; // ebp@27 + TurnBased_QueueElem *v9; // edi@28 + int v10; // ecx@30 + unsigned __int16 v11; // ax@30 + signed int v12; // edx@35 + signed int v13; // [sp+10h] [bp-4h]@7 + + v1 = this; + SortTurnQueue(); + v2 = v1->pQueue; + v3 = 0; + if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) + uActiveCharacter = PID_ID(v1->pQueue[0].uPackedID) + 1; + else + uActiveCharacter = 0; + viewparams->bRedrawGameUI = 1; + if ( v1->field_1C ) + { + pTurnEngine->field_18 |= TE_FLAG_2; + return; + } + pTurnEngine->field_18 &= ~TE_FLAG_2; + if ( v1->pQueue[0].field_4 <= 0 ) + return; + v4 = 0; + v13 = 0; + if ( v1->uActorQueueSize <= 0 ) + goto LABEL_27; + do + { + if (PID_TYPE(v2->uPackedID) != OBJECT_Player) + { + v5 = &pActors[PID_ID(v2->uPackedID)]; + LOWORD(v6) = v5->uAIState; + if ( (short)v6 == 4 + || (short)v6 == 8 + || (short)v6 == 2 + || (short)v6 == 3 + || (short)v6 == 12 + || (short)v6 == 13 + || (short)v6 == 18 + || (short)v6 == 17 ) + { + v7 = v5->uCurrentActionLength; + v5->uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( (signed int)v5->uCurrentActionTime < v7 ) + { + v13 = 1; +LABEL_19: + v3 = 0; + goto LABEL_20; + } + v6 = (signed __int16)v6; + if ( (signed __int16)v6 == 4 ) + { + v3 = 0; + v5->uAIState = Dead; + v5->uCurrentActionTime = 0; + v5->uCurrentActionLength = 0; + v5->UpdateAnimation(); + } + else + { + if ( v6 != 8 ) + goto LABEL_19; + v3 = 0; + Actor::AI_StandOrBored(PID_ID(v2->uPackedID), ai_near_actors_targets_pid[PID_ID(v2->uPackedID)], 32, 0); + } + } + } +LABEL_20: + ++v4; + ++v2; + } + while ( v4 < v1->uActorQueueSize ); + + if ( v13 != v3 ) + { + v1->field_18 |= TE_FLAG_1; + return; + } +LABEL_27: + v1->field_18 &= ~TE_FLAG_1; + v8 = 0; + if ( v1->uActorQueueSize > v3 ) + { + v9 = v1->pQueue; + do + { + if (PID_TYPE(v9->uPackedID) != OBJECT_Player) + { + v10 = PID_ID(v9->uPackedID); + v11 = pActors[v10].uAIState; + if ( v11 != 5 ) + { + if ( v11 != 4 && v11 != 11 && v11 != 19 ) + { + if ( v11 != 17 ) + { + v12 = ai_near_actors_targets_pid[v10]; + v9->uActionLength = v3; + Actor::AI_StandOrBored(v10, v12, 32, (AIDirection *)v3); + } + } + } + } + ++v8; + ++v9; + } + while ( v8 < v1->uActorQueueSize ); + } + v1->field_4 = 3; + pParty->uTimePlayed += __PAIR__(v3, 213); + _494035_timed_effects__water_walking_damage__etc(); + v1->uActionPointsLeft = 130; + } + +//----- (004063A1) -------------------------------------------------------- +int stru262_TurnBased::_4063A1() + { + stru262_TurnBased *v1; // esi@1 + int v2; // ebp@1 + signed int result; // eax@1 + int v4; // edx@1 + int v5; // edx@3 + int v6; // edi@4 + int v7; // ecx@5 + Actor *v8; // ecx@11 + unsigned __int16 v9; // dx@12 + int v10; // edi@16 + int v11; // edx@17 + char v12; // zf@18 + + v1 = this; + SortTurnQueue(); + v2 = (int)&v1->pQueue[0].field_4; + result = 1; + viewparams->bRedrawGameUI = 1; + v4 = v1->pQueue[0].field_4; + if ( v4 ) + { + if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) + { + v5 = v1->uActorQueueSize; + while ( 1 ) + { + v6 = 0; + if ( v5 > 0 ) + { + v7 = (int)&v1->pQueue[0].field_4; + do + { + --*(int *)v7; + v5 = v1->uActorQueueSize; + ++v6; + v7 += 16; + } + while ( v6 < v5 ); + } + --v1->field_10; + if ( v1->field_10 <= 0 ) + break; + if ( !*(int *)v2 ) + goto LABEL_9; + } +LABEL_24: + result = 1; + } + else + { + v8 = &pActors[PID_ID(v1->pQueue[0].uPackedID)]; + if ( v4 > 0 ) + { + do + { + v9 = v8->uAIState; + if ( v9 == 5 ) + break; + if ( v9 == 4 || v9 == 19 || v9 == 11 ) + break; + v10 = 0; + if ( v1->uActorQueueSize > 0 ) + { + v11 = (int)&v1->pQueue[0].field_4; + do + { + v12 = (*(int *)v11)-- == 1; + if ( v12 ) + *(int *)(v11 + 4) = 0; + ++v10; + v11 += 16; + } + while ( v10 < v1->uActorQueueSize ); + } + --v1->field_10; + if ( v1->field_10 <= 0 ) + goto LABEL_24; + } + while ( *(int *)v2 > 0 ); + } +LABEL_9: + result = 0; + } + } + return result; + } + +//----- (00406457) -------------------------------------------------------- +int stru262_TurnBased::_406457(int a2) + { + stru262_TurnBased *v2; // esi@1 + signed int v3; // eax@1 + signed int v4; // ecx@2 + char *v5; // edx@2 + signed int v6; // eax@2 + int result; // eax@11 + int v8; // edx@13 + int v9; // ecx@14 + char v10; // zf@15 + + v2 = this; + v3 = *(&this->field_0 + 4 * (a2 + 2)); + if ( (*((char *)&this->field_0 + 16 * PID_TYPE(a2 + 2))) == OBJECT_Player) + { + v4 = PID_ID(v3); + v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[PID_ID(v3)]; + v6 = *(int *)v5; + if ( *(int *)v5 ) + *(int *)v5 = 0; + else + v6 = pPlayers[v4 + 1]->GetAttackRecoveryTime(0); + if ( v6 < 30 ) + v6 = 30; + } + else + { + v6 = pMonsterStats->pInfos[pActors[PID_ID(v3)].pMonsterInfo.uID].uRecoveryTime; + } + v2->pQueue[a2].field_4 = v6; + v2->SortTurnQueue(); + if (PID_TYPE(v2->pQueue[0].uPackedID) == OBJECT_Player) + uActiveCharacter = PID_ID(v2->pQueue[0].uPackedID) + 1; + else + uActiveCharacter = 0; + result = (int)&v2->pQueue[0].field_4; + viewparams->bRedrawGameUI = 1; + while ( *(int *)result > 0 ) + { + if ( v2->field_10 <= 0 ) + break; + v8 = 0; + if ( v2->uActorQueueSize > 0 ) + { + v9 = (int)&v2->pQueue[0].field_4; + do + { + v10 = (*(int *)v9)-- == 1; + if ( v10 ) + *(int *)(v9 + 4) = 0; + ++v8; + v9 += 16; + } + while ( v8 < v2->uActorQueueSize ); + } + --v2->field_10; + if ( v2->field_10 <= 0 ) + break; + } + return result; + } + +//----- (0040652A) -------------------------------------------------------- +void stru262_TurnBased::_40652A() +{ + int i; + int monster_ai_state; + Actor *monster; // eax@5 + + for (i=0; i<uActorQueueSize; ++i ) + { + if (pQueue[i].field_4 == 0) + { + if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) + break; + monster=&pActors[PID_ID(pQueue[i].uPackedID)]; + monster_ai_state=monster->uAIState; + if (monster_ai_state == Standing || + monster_ai_state == Fleeing || + monster_ai_state == Fidgeting) + { + pQueue[i].field_4 == pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime; + if (monster->pActorBuffs[7].uExpireTime > 0) + pQueue[i].field_4*=2; + + } + } + } +} + +//----- (004065B0) -------------------------------------------------------- +void stru262_TurnBased::_4065B0() +{ + int i; + + SortTurnQueue(); + if (pQueue[0].field_4 <= 0) + { + for (i=0; i<uActorQueueSize; ++i ) + { + if ((PID_TYPE(pQueue[i].uPackedID)==OBJECT_Player)|| (pQueue[i].field_4 > 0) ) + break; + if ((pQueue[i].uActionLength<=0) && (PID_TYPE(pQueue[i].uPackedID)==OBJECT_Actor)) + _40680F(i); + } + } + else + { + _4063A1(); + if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) + uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1; + else + uActiveCharacter = 0; + viewparams->bRedrawGameUI = 1; + } + + for (i=0; i<uActorQueueSize; ++i ) + _406648(i); +} + +//----- (00406648) -------------------------------------------------------- +void stru262_TurnBased::_406648(unsigned int a2) + { + TurnBased_QueueElem *v1; // ecx@1 + int v3; // eax@1 + unsigned int v4; // ebx@2 + Actor *v5; // esi@2 + signed int v6; // edi@5 + int v7; // ecx@6 + int v8; // eax@6 + int v9; // eax@7 + int v10; // eax@8 + int v11; // eax@9 + int v12; // eax@10 + int v13; // eax@11 + int v14; // eax@14 + unsigned int v15; // ecx@14 + unsigned int v16; // edx@14 + int v17; // eax@17 + int v18; // eax@20 + char v19; // al@24 + unsigned int v21; // [sp-8h] [bp-50h]@16 + int v22; // [sp-8h] [bp-50h]@17 + AIDirection *v23; // [sp-4h] [bp-4Ch]@14 + unsigned int v24; // [sp-4h] [bp-4Ch]@17 + char v25; // [sp-4h] [bp-4Ch]@20 + AIDirection a3; // [sp+Ch] [bp-3Ch]@2 + AIDirection a4; // [sp+28h] [bp-20h]@2 + TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1 + unsigned int a2a; // [sp+50h] [bp+8h]@2 + + v1 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2)); + v28 = v1; + v3 = v1->uPackedID; + if (PID_TYPE(v1->uPackedID) != OBJECT_Player) + { + v4 = PID_ID(v3); + a2a = ai_near_actors_targets_pid[PID_ID(v3)]; + memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3)); + memcpy(&a4, &a3, sizeof(a4)); + v5 = &pActors[PID_ID(v3)]; + LOWORD(v3) = v5->uAIState; + if ( (short)v3 != Dead ) + { + if ( (short)v3 != Disabled ) + { + if ( (short)v3 != Removed ) + { + v6 = v5->uCurrentActionLength; + v5->uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( (signed int)v5->uCurrentActionTime >= v6 ) + { + v7 = (signed __int16)v3; + v8 = (signed __int16)v3 - 2; + if ( !v8 ) + { + v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4); + stru_50FE08.Add( + v28->uPackedID, + 5120, + v5->vPosition.x, + v5->vPosition.y, + v5->vPosition.z + ((signed int)v5->uActorHeight >> 1), + v19, + 1); + goto LABEL_25; + } + v9 = v8 - 1; + if ( v9 ) + { + v10 = v9 - 1; + if ( !v10 ) + goto LABEL_21; + v11 = v10 - 4; + if ( !v11 ) + goto LABEL_25; + v12 = v11 - 4; + if ( v12 ) + { + v13 = v12 - 1; + if ( v13 ) + { + if ( v13 != Dead ) + { + if ( v7 != 4 ) + { + v14 = rand(); + v15 = v4; + v23 = &a4; + v16 = a2a; + if ( !(v14 % 2) ) + { + Actor::AI_Bored(v4, a2a, &a4); + return; + } + v21 = 64; +LABEL_26: + Actor::AI_Stand(v15, v16, v21, v23); + return; + } +LABEL_21: + v5->uCurrentActionTime = 0; + v5->uCurrentActionLength = 0; + v5->uAIState = Dead; + pActors[v4].UpdateAnimation(); + return; + } + v24 = v5->pMonsterInfo.uSpellSkillAndMastery2; + v22 = 3; + v17 = v5->pMonsterInfo.uSpell2ID; + } + else + { + v24 = v5->pMonsterInfo.uSpellSkillAndMastery1; + v22 = 2; + v17 = v5->pMonsterInfo.uSpell1ID; + } + Actor::AI_SpellAttack(v4, &a4, v17, v22, v24); +LABEL_25: + v16 = a2a; + v23 = &a4; + v21 = 0; + v15 = v4; + goto LABEL_26; + } + v18 = v5->pMonsterInfo.uMissleAttack2Type; + v25 = 1; + } + else + { + v18 = v5->pMonsterInfo.uMissleAttack1Type; + v25 = 0; + } + Actor::AI_RangedAttack(v4, &a4, v18, v25); + goto LABEL_25; + } + } + } + } + } + } +// 50FE08: using guessed type stru298 stru_50FE08; + +//----- (0040680F) -------------------------------------------------------- +__int16 stru262_TurnBased::_40680F(int a2) + { + TurnBased_QueueElem *v2; // eax@1 + unsigned int v3; // eax@1 + unsigned int v4; // edi@2 + Actor *v5; // ebx@2 + unsigned int *v6; // esi@7 + AIDirection *v7; // esi@10 + int v8; // eax@10 + unsigned int v9; // ecx@10 + signed int v10; // eax@13 + unsigned __int8 v11; // sf@19 + unsigned __int8 v12; // of@19 + int v13; // esi@29 + bool v14; // eax@29 + unsigned __int8 v15; // cl@33 + AIDirection a3; // [sp+Ch] [bp-44h]@10 + AIDirection v18; // [sp+28h] [bp-28h]@10 + int a2a; // [sp+44h] [bp-Ch]@2 + unsigned int v20; // [sp+48h] [bp-8h]@10 + TurnBased_QueueElem *v21; // [sp+4Ch] [bp-4h]@1 + signed int v22; // [sp+58h] [bp+8h]@10 + + v2 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2)); + v21 = v2; + v2->uActionLength = 0; + v3 = v2->uPackedID; + if ( (unsigned __int8)v3 & 3 ) + { + v3 = PID_ID(v3); + v4 = v3; + a2a = v3; + v5 = &pActors[v3]; + LOWORD(v3) = v5->uAIState; + if ( (short)v3 != 5 ) + { + if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 ) + { + v6 = (unsigned int *)&ai_near_actors_targets_pid[(int)v4]; + Actor::_SelectTarget((unsigned int)v4, &ai_near_actors_targets_pid[(int)v4], true); + if ( v5->pMonsterInfo.uHostilityType && !*v6 ) + v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + v22 = *v6; + v7 = Actor::GetDirectionInfo(PID(OBJECT_Actor,(int)v4), *v6, &a3, 0); + v8 = v5->uActorRadius; + memcpy(&a3, v7, sizeof(a3)); + memcpy(&v18, &a3, sizeof(v18)); + v9 = a3.uDistance - v8; + v20 = a3.uDistance - v8; + if ( ((a3.uDistance - v8) & 0x80000000u) != 0 ) + { + v9 = 0; + v20 = 0; + } + if (PID_TYPE(v22) == OBJECT_Actor) + //v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3); + v10 = pFactionTable->relations[(pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID) / 3 + 1][(v5->pMonsterInfo.uID - 1) / 3 + 1]; + else + v10 = 4; + if ( v10 == 1 ) + { + if ( (double)(signed int)v20 < 307.2 ) + goto LABEL_25; + } + else + { + if ( v10 == 2 ) + { + v12 = __OFSUB__(v9, 1024); + v11 = ((v9 - 1024) & 0x80000000u) != 0; + } + else + { + if ( v10 == 3 ) + { + v12 = __OFSUB__(v9, 2560); + v11 = ((v9 - 2560) & 0x80000000u) != 0; + } + else + { + if ( v10 != 4 ) + goto LABEL_26; + v12 = __OFSUB__(v9, 5120); + v11 = ((v9 - 5120) & 0x80000000u) != 0; + } + } + if ( v11 ^ v12 ) + { +LABEL_25: + v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + goto LABEL_26; + } + } +LABEL_26: + if ( v5->pMonsterInfo.uHostilityType != 4 || !v22 || (signed int)v9 >= 5120 ) + { + v13 = a2a; + goto LABEL_47; + } + v13 = a2a; + v14 = stru_50C198.special_ability_use_check(v5, a2a); + if ( v14 == 1 ) + { + if ( v5->pMonsterInfo.uMissleAttack2Type ) + { + Actor::AI_MissileAttack2(v13, v22, &v18); + goto LABEL_43; + } + } + else + { + if ( v14 > 1 && v14 <= 3 ) + { + if ( v14 == 2 ) + v15 = v5->pMonsterInfo.uSpell1ID; + else + v15 = v5->pMonsterInfo.uSpell2ID; + if ( v15 ) + { + if ( v14 == 2 ) + Actor::AI_SpellAttack1(v13, v22, &v18); + else + Actor::AI_SpellAttack2(v13, v22, &v18); + goto LABEL_43; + } + goto LABEL_44; + } + if ( v5->pMonsterInfo.uMissleAttack1Type ) + { + Actor::AI_MissileAttack1(v13, v22, &v18); +LABEL_43: + //v3 = v21; + v21->field_C = 1; +LABEL_48: + v21->uActionLength = v5->uCurrentActionLength; + //return (signed __int16)v3; + return (signed __int16)&v21; + } + } +LABEL_44: + if ( (double)(signed int)v20 < 307.2 ) + { + Actor::AI_MeleeAttack(v13, v22, &v18); + //v3 = v21; + v21->field_C = 3; + goto LABEL_48; + } +LABEL_47: + Actor::AI_Stand(v13, v22, 0x40u, &v18); + //v3 = v21; + v21->field_C = 0; + goto LABEL_48; + } + } + } + return (signed __int16)v3; + } + +//----- (00406A63) -------------------------------------------------------- +void stru262_TurnBased::_406A63() + { + stru262_TurnBased *v1; // ebx@1 + int v2; // esi@1 + unsigned __int8 v3; // zf@1 + unsigned __int8 v4; // sf@1 + signed int v5; // ecx@4 + AIDirection a3; // [sp+8h] [bp-44h]@5 + AIDirection v7; // [sp+24h] [bp-28h]@5 + unsigned int v8; // [sp+40h] [bp-Ch]@5 + signed int a2; // [sp+44h] [bp-8h]@1 + TurnBased_QueueElem *v10; // [sp+48h] [bp-4h]@2 + + v1 = this; + v2 = 0; + this->field_8 = 64; + dword_50C994 = 0; + uActiveCharacter = 0; + v3 = this->uActorQueueSize == 0; + v4 = this->uActorQueueSize < 0; + a2 = 0; + if ( !(v4 | v3) ) + { + v10 = this->pQueue; + while ( 1 ) + { + v5 = v10->uPackedID; + if (PID_TYPE(v10->uPackedID) == OBJECT_Actor) + { + v8 = ai_near_actors_targets_pid[PID_ID(v5)]; + memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, 0), sizeof(v7)); + if ( !v1->ActorTurn(a2) ) + Actor::AI_Stand(PID_ID(v10->uPackedID), v8, 32, &v7); + } + ++a2; + ++v10; + if ( a2 >= v1->uActorQueueSize ) + break; + v2 = 0; + } + } + } +// 50C994: using guessed type int dword_50C994; + +//----- (00406AFE) -------------------------------------------------------- +void stru262_TurnBased::_406AFE() + { + stru262_TurnBased *v1; // edi@1 + TurnBased_QueueElem *v2; // ebx@2 + int v3; // esi@4 + int v4; // ecx@5 + AIDirection a3; // [sp+4h] [bp-48h]@5 + AIDirection v6; // [sp+20h] [bp-2Ch]@5 + stru262_TurnBased *v7; // [sp+3Ch] [bp-10h]@1 + unsigned int v8; // [sp+40h] [bp-Ch]@4 + unsigned int v9; // [sp+44h] [bp-8h]@5 + int v10; // [sp+48h] [bp-4h]@1 + + v10 = 0; + v1 = this; + v7 = this; + if ( this->uActorQueueSize > 0 ) + { + v2 = this->pQueue; + do + { + if (PID_TYPE(v2->uPackedID) == OBJECT_Actor) + { + v3 = PID_ID(v2->uPackedID); + v8 = v3; + if ( pActors[v3].CanAct() ) + { + v4 = v2->uPackedID; + v9 = ai_near_actors_targets_pid[v3]; + memcpy(&v6, Actor::GetDirectionInfo(v4, v9, &a3, 0), sizeof(v6)); + Actor::AI_Stand(v8, v9, 32, &v6); + v2->field_C = 0; + v2->uActionLength = 0; + v1 = v7; + } + } + ++v10; + ++v2; + } + while ( v10 < v1->uActorQueueSize ); + } + v1->field_4 = 2; + v1->field_8 = 100; + } + +//----- (00406B9F) -------------------------------------------------------- +int stru262_TurnBased::_406B9F() + { + signed int result; // eax@1 + unsigned __int8 v2; // zf@1 + unsigned __int8 v3; // sf@1 + int v4; // esi@4 + unsigned int v5; // esi@5 + Actor *v6; // ebx@5 + unsigned __int16 v7; // cx@15 + AIDirection a3; // [sp+0h] [bp-50h]@15 + AIDirection v9; // [sp+1Ch] [bp-34h]@15 + signed int a1; // [sp+38h] [bp-18h]@4 + stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1 + unsigned int v12; // [sp+40h] [bp-10h]@5 + unsigned int v13; // [sp+44h] [bp-Ch]@8 + TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2 + signed int a2; // [sp+4Ch] [bp-4h]@1 + + result = 0; + thisa = this; + v2 = this->uActorQueueSize == 0; + v3 = this->uActorQueueSize < 0; + a2 = 0; + if ( !(v3 | v2) ) + { + v14 = this->pQueue; + while ( 1 ) + { + v4 = v14->uPackedID; + a1 = v14->uPackedID; + if (PID_TYPE(a1) != OBJECT_Player) + { + v5 = PID_ID(v4); + v12 = v5; + v6 = &pActors[v5]; + if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result + || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result ) + v13 = result; + else + v13 = 1; + if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result + && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) ) + result = 1; + if ( !(v13 != 0 || result || v6->uAIState == 5 || v6->uAIState == 11 || v6->uAIState == 19) ) + { + v13 = ai_near_actors_targets_pid[v5]; + memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9)); + v7 = v6->uAIState; + if ( v7 == 6 || v7 == 1 ) + { + if ( (double)(signed int)v9.uDistance < 307.2 ) + goto LABEL_26; + } + v6->uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength ) + { + if ( v7 == 4 ) + { + v6->uCurrentActionTime = 0; + v6->uCurrentActionLength = 0; + v6->uAIState = Dead; + v6->UpdateAnimation(); + } + if ( !thisa->ActorTurn(a2) ) +LABEL_26: + Actor::AI_Stand(v12, v13, 32, &v9); + } + } + } + ++a2; + result = (signed int)thisa; + ++v14; + if ( a2 >= thisa->uActorQueueSize ) + break; + result = 0; + } + } + return result; + } + +//----- (00406D10) -------------------------------------------------------- +bool stru262_TurnBased::ActorTurn(signed int a2) + { + int v2; // ecx@1 + //int v3; // ecx@2 + Actor *actor; // ebx@2 + //unsigned __int16 v5; // dx@2 + int *v6; // esi@7 + TurnBased_QueueElem *v7; // edi@7 + int v8; // eax@7 + AIDirection *v9; // esi@10 + int v10; // eax@10 + unsigned int v11; // ecx@10 + unsigned __int8 pHostileType; // al@12 + unsigned __int8 v13; // sf@16 + unsigned __int8 v14; // of@16 + unsigned int v15; // edx@22 + unsigned int v16; // ecx@23 + TurnBased_QueueElem *v17; // eax@25 + double v18; // st7@33 + double v19; // st6@33 + int v21; // [sp-8h] [bp-5Ch]@23 + int v22; // [sp-8h] [bp-5Ch]@26 + AIDirection *v23; // [sp-4h] [bp-58h]@23 + int v24; // [sp-4h] [bp-58h]@26 + AIDirection a3; // [sp+Ch] [bp-48h]@10 + AIDirection pDir; // [sp+28h] [bp-2Ch]@10 + int v27; // [sp+44h] [bp-10h]@33 + unsigned int v28; // [sp+48h] [bp-Ch]@10 + TurnBased_QueueElem *v29; // [sp+4Ch] [bp-8h]@7 + unsigned int uActorID; // [sp+50h] [bp-4h]@2 + unsigned int a2a; // [sp+5Ch] [bp+8h]@7 + + // __debugbreak();// + v2 = *(&this->field_0 + 4 * (a2 + 2)); + if (PID_TYPE(v2) == OBJECT_Player) + return 0; + uActorID = PID_ID(v2); + //uActorID = v3; + actor = &pActors[uActorID]; + //v5 = v4->uAIState; + if ( actor->uAIState == 5 || actor->uAIState == 4 || actor->uAIState == 11 || actor->uAIState == 19 || actor->uAIState == 17 ) + return 1; + v6 = &ai_near_actors_targets_pid[uActorID]; + v7 = &pTurnEngine->pQueue[a2]; + v8 = *v6; + v29 = &pTurnEngine->pQueue[a2]; + a2a = v8; + Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true); + if ( actor->pMonsterInfo.uHostilityType && !*v6 ) + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0); + v10 = actor->uActorRadius; + memcpy(&a3, v9, sizeof(a3)); + memcpy(&pDir, &a3, sizeof(pDir)); + v11 = a3.uDistance - v10; + v28 = a3.uDistance - v10; + if ( ((a3.uDistance - v10) & 0x80000000u) != 0 ) + { + v11 = 0; + v28 = 0; + } + pHostileType = actor->pMonsterInfo.uHostilityType; + if ( pHostileType == 1 ) + { + if ( (double)(signed int)v28 >= 307.2 ) + goto LABEL_21; + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + goto LABEL_21; + } + if ( pHostileType == 2 ) + { + v14 = __OFSUB__(v11, 1024); + v13 = ((v11 - 1024) & 0x80000000u) != 0; + } + else + { + if ( pHostileType != 3 ) + goto LABEL_21; + v14 = __OFSUB__(v11, 2560); + v13 = ((v11 - 2560) & 0x80000000u) != 0; + } + if ( v13 ^ v14 ) + { + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + } +LABEL_21: + if ( (signed __int64)actor->pActorBuffs[4].uExpireTime > 0 ) + { + if ( (signed int)v11 < 10240 ) + { + Actor::AI_Flee(uActorID, a2a, 0, &pDir); + v29->field_C = 4; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + Actor::AI_4032B2(uActorID, a2a, 1024, 0); + v29->field_C = 2; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + if ( actor->pMonsterInfo.uHostilityType != 4 ) + goto LABEL_46; + if ( !(actor->uAttributes & 0x020000) || actor->pMonsterInfo.uAIType == 1 ) + { + if ( actor->pMonsterInfo.uAIType == 1 ) + { + if ( actor->pMonsterInfo.uMovementType == 5 ) + { + Actor::AI_Stand(uActorID, a2a, 32, 0); + v29->field_C = 4; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + Actor::AI_Flee(uActorID, a2a, 32, 0); + v29->field_C = 4; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + if ( actor->pMonsterInfo.uAIType == 2 ) + { + v27 = actor->sCurrentHP; + v18 = (double)v27; + v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.2; + if ( v19 > v18 && (signed int)v11 < 10240 ) + { + if ( actor->pMonsterInfo.uMovementType == 5 ) + { + Actor::AI_Stand(uActorID, a2a, 32, 0); + v29->field_C = 4; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + Actor::AI_Flee(uActorID, a2a, 32, 0); + v29->field_C = 4; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + goto LABEL_39; + } + if ( actor->pMonsterInfo.uAIType == 3 ) + { + v27 = actor->sCurrentHP; + v18 = (double)v27; + v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.1; + if ( v19 > v18 && (signed int)v11 < 10240 ) + { + if ( actor->pMonsterInfo.uMovementType == 5 ) + { + Actor::AI_Stand(uActorID, a2a, 32, 0); + v29->field_C = 4; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + Actor::AI_Flee(uActorID, a2a, 32, 0); + v29->field_C = 4; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + goto LABEL_39; + } + } +LABEL_39: + if ( (double)(signed int)v28 < 307.2 ) + return 0; + if ( (signed int)v11 < 5120 ) + { + if ( actor->pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 ) + Actor::AI_Pursue1(uActorID, a2a, uActorID, 32, &pDir); + else + Actor::AI_Pursue2(uActorID, a2a, 32, &pDir, 307); + v29->field_C = 2; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } +LABEL_46: + if ( actor->pMonsterInfo.uMovementType == 0 ) + { + Actor::AI_4032B2(uActorID, a2a, 1024, 32); + v29->field_C = 2; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + if ( actor->pMonsterInfo.uMovementType == 1 ) + { + Actor::AI_4032B2(uActorID, a2a, 2560, 32); + v29->field_C = 2; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + if ( actor->pMonsterInfo.uMovementType == 2 ) + { + Actor::AI_4032B2(uActorID, a2a, 5120, 32); + v29->field_C = 2; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + if ( actor->pMonsterInfo.uMovementType == 4 ) + { + Actor::AI_4032B2(uActorID, a2a, 10240, 32); + v29->field_C = 2; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + if ( actor->pMonsterInfo.uMovementType == 5 ) + { + Actor::AI_Stand(uActorID, a2a, 32, 0); + v29->field_C = 2; + v29->uActionLength = actor->uCurrentActionLength; + return 1; + } + return 1; + } + +//----- (00406FA8) -------------------------------------------------------- +void stru262_TurnBased::_406FA8() + { + unsigned __int8 v1; // zf@1 + unsigned __int8 v2; // sf@1 + TurnBased_QueueElem *v3; // edi@2 + int v4; // eax@4 + Actor *v5; // ebx@4 + unsigned __int16 v6; // cx@4 + unsigned int *v7; // edx@8 + unsigned int v8; // esi@8 + unsigned __int8 v9; // of@13 + AIDirection a3; // [sp+Ch] [bp-6Ch]@8 + AIDirection v11; // [sp+28h] [bp-50h]@8 + AIDirection a4; // [sp+44h] [bp-34h]@8 + stru262_TurnBased *v13; // [sp+60h] [bp-18h]@1 + TurnBased_QueueElem *v14; // [sp+64h] [bp-14h]@2 + int uActorID; // [sp+68h] [bp-10h]@4 + unsigned int a2; // [sp+6Ch] [bp-Ch]@8 + int v17; // [sp+70h] [bp-8h]@1 + unsigned int v18; // [sp+74h] [bp-4h]@2 + + v17 = 0; + v1 = this->uActorQueueSize == 0; + v2 = this->uActorQueueSize < 0; + v13 = this; + if ( !(v2 | v1) ) + { + v3 = this->pQueue; + v18 = (char *)&pTurnEngine - (char *)this; + v14 = this->pQueue; + do + { + if (PID_TYPE(v3->uPackedID) != OBJECT_Player) + { + v4 = PID_ID(v3->uPackedID); + uActorID = v4; + v5 = &pActors[v4]; + v6 = v5->uAIState; + if ( v6 != 5 ) + { + if ( v6 != 11 ) + { + if ( v6 != 19 ) + { + if ( v6 != 17 ) + { + v7 = (unsigned int *)&ai_near_actors_targets_pid[v4]; + a2 = *v7; + v8 = a2; + Actor::_SelectTarget(v4, (int *)v7, true); + memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(v11)); + memcpy(&a4, &v11, sizeof(a4)); + v5->uCurrentActionTime += pMiscTimer->uTimeElapsed; + if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength ) + { + if (v5->uAIState == Dying) + { + v5->uCurrentActionTime = 0; + v5->uCurrentActionLength = 0; + v5->uAIState = Dead; + v5->UpdateAnimation(); + return; + } + if ( rand() % 2 ) + Actor::AI_Stand(uActorID, a2, 64, &a4); + else + Actor::AI_Bored(uActorID, a2, &a4); + } + } + } + } + } + } + ++v17; + v3 = v14 + 1; + v9 = __OFSUB__(v17, v13->uActorQueueSize); + v2 = v17 - v13->uActorQueueSize < 0; + ++v14; + } + while ( v2 ^ v9 ); + } + } +
--- a/TurnEngine.h Fri Jul 05 21:15:53 2013 +0600 +++ b/TurnEngine.h Fri Jul 05 21:16:12 2013 +0600 @@ -1,6 +1,14 @@ #pragma once +enum TURN_ENGINE_FLAGS + { + TE_FLAG_1 =1, + TE_FLAG_2 =2, + TE_PLAYER_TURN =4, + TE_FLAG_8 =8 + }; + /* 299 */ #pragma pack(push, 1) @@ -36,9 +44,9 @@ field_1C = 0; } - signed int _404544(); + void SortTurnQueue(); void _40471C(); - signed int Start(); + void Start(); void End(bool bPlaySound); void _405E14(); __int16 StartTurn(); @@ -52,19 +60,19 @@ void _406A63(); void _406AFE(); int _406B9F(); - bool _406D10(signed int a2); + bool ActorTurn(signed int a2); void _406FA8(); int field_0; int field_4; int field_8; - int uActorQueueSize; + int uActorQueueSize; //c int field_10; - int uActionPointsLeft; + int uActionPointsLeft; //14 int field_18; int field_1C; - TurnBased_QueueElem pQueue[2]; + TurnBased_QueueElem pQueue[504]; //20 }; #pragma pack(pop)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/Books/UIMapBook.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -0,0 +1,972 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> + +#include "..\..\MM7.h" +#include "..\..\Render.h" +#include "..\..\Mouse.h" +#include "..\UIBooks.h" +#include "..\..\MapInfo.h" +#include "..\..\GUIWindow.h" +#include "..\..\GUIFont.h" +#include "..\..\Party.h" +#include "..\..\AudioPlayer.h" +#include "..\..\Outdoor.h" +#include "..\..\LOD.h" +#include "..\..\Allocator.h" +#include "..\..\Viewport.h" +#include "..\..\Math.h" +#include "..\..\texts.h" +// +#include "..\..\mm7_data.h" + +//__int16 word_4E1D3A[777]; // weak +std::array<__int16, 6> pTownPortalBook_xs = {{260, 324, 147, 385, 390, 19}}; +std::array<__int16, 6> pTownPortalBook_ys = {{206, 84, 182, 239, 17, 283}}; +std::array<__int16, 6> pTownPortalBook_ws = {{ 80, 66, 68, 72, 67, 74}}; +std::array<__int16, 6> pTownPortalBook_hs = {{ 55, 56, 65, 67, 67, 59}}; + + +std::array<unsigned int, 5> pLloydsBeaconsPreviewXs = {{61, 281, 61, 281, 171}}; // 004E249C +std::array<unsigned int, 5> pLloydsBeaconsPreviewYs = {{84, 84, 228, 228, 155}}; +std::array<unsigned int, 5> pLloydsBeacons_SomeXs = {{59, 279, 59, 279, 169}}; +std::array<unsigned int, 5> pLloydsBeacons_SomeYs = {{82, 82, 226, 226, 153}}; + + + + + + +//----- (00411150) -------------------------------------------------------- +void BookUI_DrawTownPortalMap() +{ + //signed int v0; // edi@1 + //__int16 v1; // dx@8 + //POINT *v2; // edi@17 + int v3; // edi@17 + //__int16 v4; // dx@24 + GUIWindow v6; // [sp+Ch] [bp-64h]@1 + //POINT v7; // [sp+60h] [bp-10h]@17 + POINT a2; // [sp+68h] [bp-8h]@17 + + pRenderer->ClearZBuffer(0, 479); + pRenderer->DrawTextureTransparent(8, 8, pTexture_CurrentBook); + pRenderer->DrawTextureTransparent(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId)); + + v6.uFrameX = game_viewport_x; + v6.uFrameY = game_viewport_y; + v6.uFrameWidth = game_viewport_width; + v6.uFrameHeight = game_viewport_height; + v6.uFrameZ = game_viewport_z; + v6.uFrameW = game_viewport_w; + + const uint fountain_bits_lut[] = {PARTY_QUEST_FOUNTAIN_HARMONDALE, + PARTY_QUEST_FOUNTAIN_PIERPONT, + PARTY_QUEST_FOUNTAIN_NIGHON, + PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE, + PARTY_QUEST_FOUNTAIN_CELESTIA, + PARTY_QUEST_FOUNTAIN_THE_PIT}; + for (uint i = 0; i < 6; ++i) + { + + if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[i])) + pRenderer->DrawMaskToZBuffer(pTownPortalBook_xs[i], + pTownPortalBook_ys[i], + pTexture_TownPortalIcons[i], i + 1); + } + +/* v0 = 0; + do + { + if ( !v0 ) + { + v1 = 206; +LABEL_14: + if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v1) ) + goto LABEL_16; + goto LABEL_15; + } + if ( v0 == 1 ) + { + v1 = 208; + goto LABEL_14; + } + if ( v0 == 2 ) + { + v1 = 207; + goto LABEL_14; + } + if ( v0 == 3 ) + { + v1 = 211; + goto LABEL_14; + } + if ( v0 == 4 ) + { + v1 = 209; + goto LABEL_14; + } + if ( v0 == 5 ) + { + v1 = 210; + goto LABEL_14; + } +LABEL_15: + pRenderer->DrawMaskToZBuffer( + pTownPortalBook_xs[v0], + pTownPortalBook_ys[v0], + *(&pTexture_TownPortalHarmn + v0), + v0 + 1); +LABEL_16: + ++v0; + } + while ( v0 < 6 );*/ + + pMouse->GetCursorPos(&a2); + //v2 = pMouse->GetCursorPos(&a2); + v3 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF; + + if (v3) + { + if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[v3 - 1])) + pRenderer->DrawTextureIndexed(pTownPortalBook_xs[v3 - 1], pTownPortalBook_ys[v3 - 1], pTexture_TownPortalIcons[v3 - 1]); + } + v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); + + +/* if ( !v3 ) // Town Portal + { + v6.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3); // "Town Portal" + return; + } + if ( v3 == 1 ) + { + v4 = 206; +LABEL_30: + if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v4) ) + goto LABEL_31; + v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); // "Town Portal" + return; + } + if ( v3 == 2 ) + { + v4 = 208; + goto LABEL_30; + } + if ( v3 == 3 ) + { + v4 = 207; + goto LABEL_30; + } + if ( v3 == 4 ) + { + v4 = 211; + goto LABEL_30; + } + if ( v3 == 5 ) + { + v4 = 209; + goto LABEL_30; + } + if ( v3 == 6 ) + { + v4 = 210; + goto LABEL_30; + } +LABEL_31: + pRenderer->DrawTextureIndexed(word_4E1D3A[v3], pTownPortalBook_xs[v3 + 5], *(&pTex_tab_an_6b__zoom_on + v3)); + v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);*/ +} +// 4E1D3A: using guessed type __int16 word_4E1D3A[]; + +//----- (00410DEC) -------------------------------------------------------- +unsigned int __cdecl DrawLloydBeaconsScreen() +{ + Player *pPlayer; // esi@1 + char *v1; // eax@1 + unsigned __int16 v2; // ax@6 + unsigned int result; // eax@11 + unsigned int v4; // esi@13 + unsigned int v5; // ecx@13 + char v6; // zf@13 + LloydBeacon *v7; // esi@14 + int v8; // eax@14 + unsigned __int64 v9; // kr08_8@14 + unsigned int v10; // esi@14 + unsigned int v11; // eax@14 + char *v12; // eax@19 + char *v13; // ecx@22 + int v14; // eax@27 + Texture *v19; // [sp-4h] [bp-8Ch]@4 + GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1 + unsigned int v23; // [sp+64h] [bp-24h]@14 + __int64 v24; // [sp+68h] [bp-20h]@14 + unsigned int v25; // [sp+70h] [bp-18h]@13 + char *Str; // [sp+74h] [bp-14h]@14 + int v27; // [sp+78h] [bp-10h]@11 + LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12 + RGBTexture *v29; // [sp+80h] [bp-8h]@12 + int uNumMaxBeacons; // [sp+84h] [bp-4h]@6 + + pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid]; + pRenderer->DrawTextureIndexed(8u, 8u, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]); + v1 = pGlobalTXT_LocalizationStrings[523]; // Recall Beacon + pWindow.uFrameX = game_viewport_x; + pWindow.uFrameY = game_viewport_y; + pWindow.uFrameWidth = 428; + pWindow.uFrameHeight = game_viewport_height; + pWindow.uFrameZ = 435; + pWindow.uFrameW = game_viewport_w; + if ( !bRecallingBeacon ) + v1 = pGlobalTXT_LocalizationStrings[375]; // Set Beacon + sprintf(pTmpBuf.data(), "%s", v1); + pWindow.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf.data(), 3u); + if ( bRecallingBeacon ) + { + pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on); + v19 = pTex_tab_an_6a__zoom_off; + } + else + { + pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6a__zoom_off); + v19 = pTex_tab_an_6b__zoom_on; + } + pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19); + v2 = pPlayer->pActiveSkills[14]; + uNumMaxBeacons = 1; + if ( HIBYTE(v2) & 1 || (v2 & 0x80u) != 0 ) + { + uNumMaxBeacons = 5; + } + else + { + if ( v2 & 0x40 ) + uNumMaxBeacons = 3; + } + result = 0; + v27 = 0; + if ( uNumMaxBeacons > 0 ) + { + v29 = pSavegameThumbnails.data(); + v28 = pPlayer->pInstalledBeacons; + while ( 1 ) + { + pWindow.uFrameWidth = 92; + v4 = result; + pWindow.uFrameHeight = 68; + v5 = pLloydsBeaconsPreviewXs[result]; + pWindow.uFrameY = pLloydsBeaconsPreviewYs[result]; + v25 = pWindow.uFrameY; + pWindow.uFrameX = v5; + pWindow.uFrameW = pWindow.uFrameY + 67; + v6 = v29->pPixels == 0; + pWindow.uFrameZ = v5 + 91; + if ( !v6 ) + break; + if ( !bRecallingBeacon ) + { + pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook); + v14 = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0); + pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - v14 / 2, 1, pGlobalTXT_LocalizationStrings[19], 3); + } +LABEL_29: + ++v29; + ++v28; + result = v27++ + 1; + if ( v27 >= uNumMaxBeacons ) + goto LABEL_30; + } + pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook); + pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[v4], pLloydsBeaconsPreviewYs[v4], v29); + v7 = v28; + Str = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v28->field_18))].pName; + v8 = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0); + pWindow.uFrameY += -6 - v8; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1u, Str, 3u); + v9 = v7->uBeaconTime - pParty->uTimePlayed; + LODWORD(v24) = LODWORD(v7->uBeaconTime) - LODWORD(pParty->uTimePlayed); + HIDWORD(v24) = HIDWORD(v9); + v23 = (unsigned __int64)((signed __int64)((double)v24 * 0.234375) / 60 / 60) >> 32; + v10 = (signed __int64)((double)v24 * 0.234375) / 60 / 60; + v11 = v10 / 0x18; + if ( (unsigned int)((signed __int64)((double)v24 * 0.234375) / 60 / 60) / 0x18 ) + { + v13 = pGlobalTXT_LocalizationStrings[57]; // Days + if ( v11 > 1 ) + { + sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13); + pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); + goto LABEL_29; + } + } + else + { + if ( (signed __int64)(__PAIR__(v23, v10) + 1) <= 23 ) + { + if ( (v23 & 0x80000000u) != 0 || (signed int)v23 <= 0 && v10 <= 1 ) + v12 = pGlobalTXT_LocalizationStrings[109];// Hour + else + v12 = pGlobalTXT_LocalizationStrings[110];// Hours + sprintf(pTmpBuf.data(), "%lu %s", v10 + 1, v12); + pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); + goto LABEL_29; + } + } + v13 = pGlobalTXT_LocalizationStrings[56]; // Day + sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13); + pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); + goto LABEL_29; + } +LABEL_30: + if ( byte_506360 ) + { + /*result = pMessageQueue_50CBD0->uNumMessages; + if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CloseAfterInstallBeacon; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; + result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; + *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_CloseAfterInstallBeacon, 0, 0); + } + return result; +} + + +//----- (00413980) -------------------------------------------------------- +void BookUI_Map_Draw() + { + int v6; // eax@31 + unsigned int map_id; // eax@35 + Texture *buttnTxtr; // [sp-4h] [bp-DCh]@3 + char party_coord[120]; // [sp+Ch] [bp-CCh]@37 + GUIWindow map_window; // [sp+84h] [bp-54h]@35 + unsigned int textrX, textrY; + + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_12); + if ( BtnUp_flag || viewparams->field_2C / 128 >= 12 ) + { + buttnTxtr = pTex_tab_an_6a__zoom_off; + textrY = pViewport->uViewportTL_Y + 2; + textrX = pViewport->uViewportTL_X + 408; + } + else + { + buttnTxtr = pTex_tab_an_6b__zoom_on; + textrY = pViewport->uViewportTL_Y + 1; + textrX = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( BtnDown_flag || viewparams->field_2C / 128 <= 3 ) + { + buttnTxtr = pTex_tab_an_7a__zoot_off; + textrY = pViewport->uViewportTL_Y + 38; + textrX = pViewport->uViewportTL_X + 408; + } + else + { + buttnTxtr = pTex_tab_an_7b__zoot_on; + textrY = pViewport->uViewportTL_Y + 38; + textrX = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( Book_PageBtn3_flag ) + { + buttnTxtr = pTexture_506390; + textrY = pViewport->uViewportTL_Y + 113; + textrX = pViewport->uViewportTL_X + 408; + } + else + { + buttnTxtr = pTexture_506394; + textrY = pViewport->uViewportTL_Y + 113; + textrX = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( Book_PageBtn4_flag ) + { + buttnTxtr = pTexture_506388; + textrY = pViewport->uViewportTL_X + 150; + textrX = pViewport->uViewportTL_Y + 408; + } + else + { + buttnTxtr = pTexture_50638C; + textrY = pViewport->uViewportTL_X + 150; + textrX = pViewport->uViewportTL_Y + 399; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( Book_PageBtn5_flag ) + { + buttnTxtr = pTexture_506380; + textrY = pViewport->uViewportTL_Y + 188; + textrX = pViewport->uViewportTL_X + 408; + } + else + { + buttnTxtr = pTexture_506384; + textrY = pViewport->uViewportTL_Y + 188; + textrX = pViewport->uViewportTL_X + 397; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( Book_PageBtn6_flag ) + { + buttnTxtr = pTexture_506378; + textrY = pViewport->uViewportTL_Y + 226; + textrX = pViewport->uViewportTL_X + 408; + } + else + { + buttnTxtr = pTexture_50637C; + textrY = pViewport->uViewportTL_Y + 226; + textrX = pViewport->uViewportTL_X + 397; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( BtnDown_flag ) + viewparams->CenterOnParty2(); + if ( BtnUp_flag ) + viewparams->CenterOnParty(); + if ( Book_PageBtn3_flag ) + viewparams->_443219(); + if ( Book_PageBtn4_flag ) + viewparams->_443231(); + if ( Book_PageBtn5_flag ) + viewparams->_44323D(); + if ( Book_PageBtn6_flag ) + viewparams->_443225(); + + if ( BtnUp_flag | BtnDown_flag | Book_PageBtn3_flag | Book_PageBtn4_flag | Book_PageBtn5_flag | Book_PageBtn6_flag ) + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + BtnUp_flag = 0; + BtnDown_flag = 0; + Book_PageBtn6_flag = 0; + Book_PageBtn5_flag = 0; + Book_PageBtn4_flag = 0; + Book_PageBtn3_flag = 0; + DrawBook_Map_sub(97, 49, 361, 313, 0); + pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr); + map_window.uFrameWidth = game_viewport_width; + map_window.uFrameHeight = game_viewport_height; + map_window.uFrameX = game_viewport_x; + map_window.uFrameY = game_viewport_y; + map_window.uFrameZ = game_viewport_z; + map_window.uFrameW = game_viewport_w; + map_id = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( map_id ) + map_window.DrawTitleText(pBook2Font, -14, 12, ui_book_map_title_color, pMapStats->pInfos[map_id].pName, 3); + + map_window.uFrameX = 0; + sprintf(party_coord, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y); //"x: %d y: %d" + map_window.DrawTitleText(pFontComic, 0, 320, ui_book_map_coordinates_color, party_coord, 0); + } + +//----- (00442955) -------------------------------------------------------- +void DrawBook_Map_sub( unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074 ) + { + int v5; // ebx@1 + int v6; // edi@1 + BLVMapOutlines *v7; // eax@8 + unsigned __int8 v8; // zf@8 + unsigned __int8 v9; // sf@8 + int v10; // esi@10 + unsigned int v11; // edx@11 + __int16 v12; // cx@12 + signed int v13; // eax@15 + int v14; // eax@16 + Vec3_short_ *v15; // ecx@16 + int v16; // edx@16 + int v17; // ecx@16 + Vec3_short_ *v18; // eax@16 + int v19; // ecx@16 + int v20; // eax@16 + signed int v21; // esi@18 + int v22; // ecx@21 + BLVMapOutline *v23; // ecx@21 + Vec3_short_ *v24; // edx@21 + Vec3_short_ *v25; // eax@21 + int v26; // ecx@21 + unsigned __int16 *v27; // edi@21 + int v28; // edx@21 + int v29; // eax@21 + double v30; // st7@23 + signed __int64 v31; // qax@23 + unsigned short *v32; // edx@23 + int textr_width; // esi@23 + signed int v34; // eax@23 + signed int v35; // ecx@23 + int v36; // esi@27 + int v37; // ecx@27 + int v38; // edx@31 + unsigned int v39; // eax@33 + short *v40; // esi@33 + short *v41; // edi@33 + unsigned __int8 v42; // cf@33 + unsigned int v43; // ecx@33 + short *v44; // edi@33 + short *v45; // esi@33 + int v46; // ecx@33 + signed int v47; // esi@38 + signed int v48; // ecx@38 + int v49; // eax@38 + signed int v50; // edx@55 + unsigned int v51; // ecx@55 + int result; // eax@72 + int v53; // eax@75 + int v54; // esi@75 + int v55; // eax@75 + __int16 v56; // si@85 + double v57; // st7@85 + int v58; // ebx@85 + signed __int64 v59; // qax@85 + signed int v60; // edi@85 + signed __int64 v61; // qax@85 + signed int v62; // ebx@85 + signed int v63; // esi@85 + int v64; // eax@87 + unsigned int v65; // ebx@95 + unsigned short *v66; // edx@95 + unsigned __int16 *v67; // esi@96 + int v68; // edi@98 + unsigned __int16 v69; // cx@99 + unsigned int v70; // [sp-10h] [bp-48074h]@80 + unsigned int v71; // [sp-Ch] [bp-48070h]@80 + unsigned int v72; // [sp-8h] [bp-4806Ch]@80 + signed int v73; // [sp-4h] [bp-48068h]@59 + unsigned __int16 v74; // [sp-4h] [bp-48068h]@79 + unsigned short map_texture_16[147456]; // [sp+Ch] [bp-48058h]@23 + int v76; // [sp+4800Ch] [bp-58h]@23 + unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27 + unsigned __int16 *pPalette_16; // [sp+48014h] [bp-50h]@23 + unsigned int surfPitch; // [sp+48018h] [bp-4Ch]@1 + + int v81; // [sp+48020h] [bp-44h]@23 + unsigned __int16* render16_data; + unsigned char* texture8_data; + unsigned char* curr_line; + int scale_increment; + int scaled_posX; + int scaled_posY; + int stepX_r; + int stepY_r; + + + unsigned int teal; // [sp+48028h] [bp-3Ch]@8 + int v84; // [sp+4802Ch] [bp-38h]@1 + int screenCenter_X; // [sp+48030h] [bp-34h]@1 + int v86; // [sp+48034h] [bp-30h]@1 + int v87; // [sp+48038h] [bp-2Ch]@16 + unsigned int v88; // [sp+4803Ch] [bp-28h]@16 + int black; // [sp+48040h] [bp-24h]@8 + int screenCenterY; // [sp+48044h] [bp-20h]@1 + unsigned int i; // [sp+48048h] [bp-1Ch]@9 + unsigned int screenHeight; // [sp+4804Ch] [bp-18h]@16 + unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16 + signed int screenWidth; // [sp+48054h] [bp-10h]@8 + unsigned int v95; // [sp+48058h] [bp-Ch]@16 + int v96; // [sp+4805Ch] [bp-8h]@10 + const void *v97; // [sp+48060h] [bp-4h]@16 + unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85 + int a5a; // [sp+48070h] [bp+Ch]@86 + + tl_x = tl_x; + tl_y = tl_y; + screenCenter_X = (signed int)(tl_x + br_x) >> 1; + screenCenterY = (signed int)(tl_y + br_y) >> 1; + surfPitch = pRenderer->uTargetSurfacePitch; + pRenderer->SetRasterClipRect(tl_x, tl_y, br_x, br_y); + v5 = viewparams->field_2C; + v6 = viewparams->sViewCenterX; + v86 = viewparams->sViewCenterX; + v84 = viewparams->sViewCenterY; + if ( viewparams->field_2C != 384 ) + { + if ( viewparams->field_2C == 768 ) + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + v5 = 680; + } + } + else + { + v6 = viewparams->indoor_center_x; + v86 = viewparams->indoor_center_x; + v84 = viewparams->indoor_center_y; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + v5 = viewparams->field_2C - 34; + } + if ( uCurrentlyLoadedLevelType != LEVEL_Indoor) + { + screenWidth = br_x - tl_x + 1; + screenHeight = br_y - tl_y + 1; + render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch]; + texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask; + pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16; + scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / v5; + + v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2)); + + + teal = (unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16; + // v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16); + + // v32 = map_texture_16; + textr_width = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth; + stepY_r = (int)(signed __int64)((double)(- v84 - 22528 / (v5 / 384)+ 32768) / v30) << 16; + // v81 = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30); + black = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30); + + // v76 = textr_width; + scaled_posY = stepY_r >> 16; + //nearest neiborhood scaling + if ( texture8_data) + { + for(uint i=0; i<screenHeight;++i) + { + curr_line=&texture8_data[scaled_posY*textr_width]; + stepX_r=teal; + for(uint j=0; j<screenWidth;++j) + { + scaled_posX=stepX_r>>16; + map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)]; + stepX_r+=scale_increment; + } + stepY_r+=scale_increment; + scaled_posY=stepY_r>>16; + } + } + //move visible square to render + for(uint i=0; i<screenHeight;++i) + { + if ( screenWidth > 0 ) + { + memcpy((void*)&render16_data[surfPitch*i],(void*)&map_texture_16[i*screenWidth], screenWidth*2); + } + } + } + else + { + black = TargetColor(0, 0, 0); + teal = TargetColor(0, 0xFFu, 0xFFu); + v7 = pIndoor->pMapOutlines; + uNumBlueFacesInBLVMinimap = 0; + v8 = pIndoor->pMapOutlines->uNumOutlines == 0; + v9 = pIndoor->pMapOutlines->uNumOutlines < 0; + screenWidth = 0; + if ( !(v9 | v8) ) + { + i = 0; + do + { + v10 = (int)((char *)v7 + i + 4); + v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes; + if ( !(BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) )) + { + v12 = *(short *)((char *)v7 + i + 14); + if ( !(v12 & 1) ) + { + if ( !(!(v96 & 0x80) && (v11 & 0x80u) == 0 )) + { + v96 = (signed int)screenWidth >> 3; + v13 = screenWidth; + *(short *)(v10 + 10) = v12 | 1; + pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8); + } + } + if ( (!(v12 & 1) && !(!(v96 & 0x80) && (v11 & 0x80u) == 0 )) || v12 & 1) + { + v14 = *(short *)v10; + v88 = v5; + v15 = &pIndoor->pVertices[v14]; + v16 = v15->x; + v17 = v15->y - v84; + v93 = (unsigned __int16 *)(v16 - v6); + screenHeight = v17; + v18 = &pIndoor->pVertices[*(short *)(v10 + 2)]; + v19 = v18->x; + v20 = v18->y - v84; + v95 = v19 - v6; + v97 = (const void *)v20; + v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16; + v87 = (unsigned __int64)((signed int)screenHeight * (signed __int64)v5) >> 16; + v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16); + screenHeight = (unsigned __int64)(v20 * (signed __int64)v5) >> 16; + pRenderer->RasterLine2D( + screenCenter_X + v88, + screenCenterY - v87, + screenCenter_X + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16), + screenCenterY - screenHeight, + black); + v7 = pIndoor->pMapOutlines; + } + } + ++screenWidth; + i += 12; + } + while ( screenWidth < (signed int)v7->uNumOutlines ); + } + v21 = 0; + if ( (signed int)uNumBlueFacesInBLVMinimap > 0 ) + { + while ( 1 ) + { + v22 = pBlueFacesInBLVMinimapIDs[v21]; + v87 = v5; + v23 = &v7->pOutlines[v22]; + v24 = &pIndoor->pVertices[v23->uVertex1ID]; + v25 = &pIndoor->pVertices[v23->uVertex2ID]; + v26 = v25->x; + v27 = (unsigned __int16 *)(v24->x - v86); + v28 = v24->y - v84; + v29 = v25->y - v84; + v93 = v27; + screenHeight = v28; + v97 = (const void *)v29; + v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16; + v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16; + i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16; + v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16; + pRenderer->RasterLine2D( + screenCenter_X + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16), + screenCenterY - v88, + screenCenter_X + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16), + screenCenterY - v95, + teal); + ++v21; + if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap ) + break; + v7 = pIndoor->pMapOutlines; + } + v6 = v86; + } + } + v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 3; + v81 = pParty->vPosition.y - v84; + v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16); + v48 = 1; + v49 = screenCenterY - (int)v97 - 3; + if ( v47 >= (signed int)tl_x ) + { + if ( v47 > (signed int)br_x ) + { + if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 6) > (signed int)br_x ) + v48 = 0; + v47 = br_x; + } + } + else + { + if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X) < (signed int)tl_x ) + v48 = 0; + v47 = tl_x; + } + if ( v49 >= (signed int)tl_y ) + { + if ( v49 > br_y ) + { + if ( screenCenterY - (signed int)v97 - 6 > br_y ) + v48 = 0; + v49 = br_y; + } + } + else + { + if ( screenCenterY - (signed int)v97 < (signed int)tl_y ) + v48 = 0; + v49 = tl_y; + } + if ( v48 == 1 ) + { + v50 = 0; + v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask; + if ( (signed int)(pParty->sRotationY & stru_5C6E00->uDoublePiMask) >= 128 ) + { + if ( (signed int)v51 > 384 ) + { + if ( (signed int)v51 >= 640 ) + { + if ( (signed int)v51 > 896 ) + { + if ( (signed int)v51 >= 1152 ) + { + if ( (signed int)v51 > 1408 ) + { + if ( (signed int)v51 >= 1664 ) + { + if ( (signed int)v51 <= 1920 ) + v73 = 7; + } + else + { + v73 = 6; + } + } + else + { + v73 = 5; + } + } + else + { + v73 = 4; + } + } + else + { + v73 = 3; + } + } + else + { + v73 = 2; + } + if( (signed int)v51 <=1920) + v50 = v73; + } + else + v50 = 1; + } + pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50])); + } + result = TargetColor(0xFFu, 0xFFu, 0xFFu); + v95 = 0; + v86 = result; + if ( (signed int)uNumLevelDecorations > 0 ) + { + screenWidth = (unsigned int)&pLevelDecorations[0].vPosition; + do + { + if ( *(char *)(screenWidth - 2) & 8 ) + { + v53 = *(int *)(screenWidth + 4) - v84; + v93 = (unsigned __int16 *)(*(int *)screenWidth - v6); + screenHeight = v53; + v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X; + v97 = (const void *)((unsigned __int64)(v53 * (signed __int64)v5) >> 16); + v55 = screenCenterY - (int)v97; + if ( v54 >= pRenderer->raster_clip_x ) + { + if ( v54 <= pRenderer->raster_clip_z && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w ) + { + v74 = v86; + if ( v5 > 512 ) + { + v96 = v55 + 1; + black = v55 - 1; + pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, v86); + pRenderer->RasterLine2D(v54, black, v54, v96, v86); + ++v54; + v74 = v86; + v72 = v96; + v71 = v54; + v70 = black; + } + else + { + v72 = screenCenterY - (int)v97; + v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X; + v70 = screenCenterY - (int)v97; + } + pRenderer->RasterLine2D(v54, v70, v71, v72, v74); + } + } + } + ++v95; + result = v95; + screenWidth += 32; + } + while ( (signed int)v95 < (signed int)uNumLevelDecorations ); + } + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + screenCenterY = br_x - tl_x + 1; + v95 = br_y - tl_y + 1; + v77 = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch]; + v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2; + black = (1 << (v56 + 16)) / v5; + v57 = (double)(1 << (16 - v56)); + v58 = 22528 / (v5 / 384); + v59 = (signed __int64)((double)(v6 - v58 + 32768) / v57); + v60 = (int)v59 << 16; + v97 = (const void *)((int)v59 << 16); + v61 = (signed __int64)((double)(32768 - v58 - v84) / v57); + pPalette_16 = (unsigned __int16 *)(v60 >> 16); + v62 = (int)v61 << 16; + teal = v60 >> 16; + v63 = (signed __int16)v61; + a4a = map_texture_16; + result = TargetColor(0xCu, 0xCu, 0xCu); + screenCenter_X = 0; + for ( i = result; screenCenter_X < (signed int)v95; result = screenCenter_X ) + { + a5a = 0; + if ( screenCenterY > 0 ) + { + v96 = (v63 - 80) / 4; + v64 = teal; + do + { + v81 = (v64 - 80) / 4; + if ( !pOutdoor->_47F04C(v81, v96) ) + { + if ( pOutdoor->_47F097(v81, v96) ) + { + if ( !((a5a + screenCenter_X) % 2) ) + *a4a = i; + } + else + { + *a4a = 0; + } + } + ++a4a; + v97 = (char *)v97 + black; + v64 = (signed int)v97 >> 16; + ++a5a; + } + while ( a5a < screenCenterY ); + } + v62 += black; + v97 = (const void *)v60; + a4a += screenCenterY - a5a; + v63 = v62 >> 16; + ++screenCenter_X; + teal = (unsigned int)pPalette_16; + } + v65 = v95; + v66 = map_texture_16; + if ( (signed int)v95 > 0 ) + { + v67 = v77; + result = 2 * (surfPitch - screenCenterY); + do + { + if ( screenCenterY > 0 ) + { + v68 = screenCenterY; + do + { + v69 = *(short *)v66; + if ( !*(short *)v66 || v69 == (short)i ) + *v67 = v69; + ++v66; + ++v67; + --v68; + } + while ( v68 ); + } + v67 = (unsigned __int16 *)((char *)v67 + result); + --v65; + } + while ( v65 ); + } + } + } + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/Books/UINotesBooks.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -0,0 +1,654 @@ + +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> + +#include "..\..\MM7.h" +#include "..\..\Render.h" +#include "..\..\Mouse.h" +#include "..\UIBooks.h" +#include "..\..\MapInfo.h" +#include "..\..\GUIWindow.h" +#include "..\..\GUIFont.h" +#include "..\..\Party.h" +#include "..\..\AudioPlayer.h" +//#include "..\Outdoor.h" +#include "..\..\LOD.h" +#include "..\..\Allocator.h" +#include "..\..\Viewport.h" +//#include "..\Math.h" +#include "..\..\Awards.h" +#include "..\..\Autonotes.h" +#include "..\..\StorylineTextTable.h" +#include "..\..\texts.h" +// +#include "..\..\mm7_data.h" + + + + +//----- (00413D3C) -------------------------------------------------------- +static const char *GetDayPart() + { + if (pParty->uCurrentHour <= 4) + return pGlobalTXT_LocalizationStrings[567]; // "Night" + else if (pParty->uCurrentHour == 5) + return pGlobalTXT_LocalizationStrings[55]; // "Dawn" + else if (pParty->uCurrentHour == 20) + return pGlobalTXT_LocalizationStrings[566]; // "Dusk" + else + return pGlobalTXT_LocalizationStrings[56]; // "Day" + } + + + + + +//----- (00413D6F) -------------------------------------------------------- +void BookUI_Calendar_Draw() + { + unsigned int v0; // esi@1 + //char *v1; // eax@5 + int v2; // ecx@5 + char *v3; // eax@6 + GUIWindow a1; // [sp+Ch] [bp-60h]@5 + unsigned int v6; // [sp+60h] [bp-Ch]@1 + //int v7; // [sp+64h] [bp-8h]@1 + //int a5; // [sp+68h] [bp-4h]@1 + + + static unsigned int pDayMoonPhase[28] = // 4E1B18 + { + 0, 0, 0, + 1, 1, 1, 1, + 2, 2, 2, + 3, 3, 3, 3, + 4, 4, 4, + 3, 3, 3, 3, + 2, 2, 2, + 1, 1, 1, 1 + }; + + + v0 = pParty->uCurrentHour; + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13); + if ( (signed int)v0 <= 12 ) + { + if ( !v0 ) + v0 = 12; + } + else + { + v0 -= 12; + } + a1.uFrameX = game_viewport_x; + a1.uFrameY = game_viewport_y; + a1.uFrameWidth = game_viewport_width; + a1.uFrameHeight = game_viewport_height; + a1.uFrameZ = game_viewport_z; + a1.uFrameW = game_viewport_w; + a1.DrawTitleText(pBook2Font, 0, 0x16u, ui_book_calendar_title_color, pGlobalTXT_LocalizationStrings[186], 3); // "Time in Erathia" + + v2 = 0; + if ( pParty->uCurrentHour >= 12 ) + { + if ( pParty->uCurrentHour >= 24 ) + v2=0; + else + v2=1; + } + + sprintf(pTmpBuf.data(), "%s\t100:\t110%d:%02d %s - %s", + pGlobalTXT_LocalizationStrings[526], // "Time" + v0, + pParty->uCurrentMinute, + aAMPMNames[v2], + GetDayPart()); + a1.DrawText(pBookFont, 70, 55, ui_book_calendar_time_color, pTmpBuf.data(), 0, 0, 0); + + sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", + pGlobalTXT_LocalizationStrings[56], // "Day" + pParty->uDaysPlayed + 1, + aDayNames[pParty->uDaysPlayed % 7]); + a1.DrawText(pBookFont, 70, 2 * LOBYTE(pBookFont->uFontHeight) + 49, ui_book_calendar_day_color, pTmpBuf.data(), 0, 0, 0); + + sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", + pGlobalTXT_LocalizationStrings[146], // "Month" + pParty->uCurrentMonth + 1, + aMonthNames[pParty->uCurrentMonth]); + a1.DrawText(pBookFont, 70, 4 * LOBYTE(pBookFont->uFontHeight) + 43, ui_book_calendar_month_color, pTmpBuf.data(), 0, 0, 0); + + sprintf(pTmpBuf.data(), "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); // "Year" + a1.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, ui_book_calendar_year_color, pTmpBuf.data(), 0, 0, 0); + + sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[pDayMoonPhase[pParty->uDaysPlayed]]); // "Moon" + a1.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, ui_book_calendar_moon_color, pTmpBuf.data(), 0, 0, 0); + + v6 = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( v6 ) + v3 = pMapStats->pInfos[v6].pName; + else + v3 = "Unknown"; + sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], v3); // "Location" + a1.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, ui_book_calendar_location_color, pTmpBuf.data(), 0, 0, 0); + } + + + + + +//----- (00413126) -------------------------------------------------------- +void BookUI_Questbook_Draw() + { + unsigned int v0; // eax@3 + unsigned int v1; // eax@7 + int v2; // ecx@11 + int v3; // ebx@16 + int v4; // eax@19 + const char *v5; // edi@19 + int v6; // eax@19 + unsigned int v7; // edi@19 + unsigned int v8; // [sp-8h] [bp-68h]@3 + unsigned int v9; // [sp-8h] [bp-68h]@7 + Texture *v10; // [sp-4h] [bp-64h]@3 + Texture *v11; // [sp-4h] [bp-64h]@7 + GUIWindow a1; // [sp+Ch] [bp-54h]@9 + + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_CurrentBook); + if ( BtnUp_flag || !dword_506528 ) + { + v10 = pTex_tab_an_6a__zoom_off; + v8 = pViewport->uViewportTL_Y + 2; + v0 = pViewport->uViewportTL_X + 407; + } + else + { + v10 = pTex_tab_an_6b__zoom_on; + v8 = pViewport->uViewportTL_Y + 1; + v0 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v0, v8, v10); + if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 ) + { + v11 = pTex_tab_an_7a__zoot_off; + v9 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 407; + } + else + { + v11 = pTex_tab_an_7b__zoot_on; + v9 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v1, v9, v11); + a1.uFrameWidth = game_viewport_width; + a1.uFrameHeight = game_viewport_height; + a1.uFrameX = game_viewport_x; + a1.uFrameY = game_viewport_y; + a1.uFrameZ = game_viewport_z; + a1.uFrameW = game_viewport_w; + a1.DrawTitleText(pBook2Font, 0, 22, ui_book_quests_title_color, pGlobalTXT_LocalizationStrings[174], 3); //"Current Quests" + + a1.uFrameX = 48; + a1.uFrameY = 70; + a1.uFrameWidth = 360; + a1.uFrameHeight = 264; + a1.uFrameZ = 407; + a1.uFrameW = 333; + if ( BtnDown_flag && dword_506528 + num_achieved_awards < num_achieved_awards_2 ) + { + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + v2 = dword_50651C++; + dword_506528 += num_achieved_awards; + byte_506130[v2] = num_achieved_awards; + } + if ( BtnUp_flag && dword_50651C ) + { + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + --dword_50651C; + dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; + } + if ( !num_achieved_awards || (v3 = dword_506528, dword_506528 < 1) ) + { + v3 = 0; + dword_50651C = 0; + dword_506528 = 0; + } + BtnDown_flag = 0; + BtnUp_flag = 0; + num_achieved_awards = 0; + while ( v3 < num_achieved_awards_2 ) + { + v4 = achieved_awards[v3]; + ++num_achieved_awards; + v5 = pQuestTable[v4];//(&dword_722F10)[4 * v4]; + a1.DrawText(pAutonoteFont, 1, 0, ui_book_quests_text_color, pQuestTable[v4], 0, 0, 0);//(&dword_722F10)[4 * v4], 0, 0, 0); + v6 = pAutonoteFont->CalcTextHeight(v5, &a1, 1, 0); + v7 = a1.uFrameY + v6; + if ( (signed int)(a1.uFrameY + v6) > (signed int)a1.uFrameHeight ) + break; + pRenderer->DrawTextureTransparent(100, v7 + 12, pSpellBookPagesTextr_10); + ++v3; + a1.uFrameY = v7 + 24; + } + } + + +//----- (0041338E) -------------------------------------------------------- +void BookUI_Autonotes_Draw() + { + unsigned int v0; // eax@3 + unsigned int v1; // eax@7 + signed int v2; // ebp@11 + unsigned int v3; // eax@18 + unsigned int v4; // eax@24 + unsigned int v5; // eax@30 + unsigned int v6; // eax@36 + unsigned int v7; // eax@42 + signed int v8; // ebp@47 + int v9; // eax@52 + int v10; // eax@56 + int v11; // edx@57 + int v12; // ebp@64 + int v13; // eax@65 + const char *v14; // edi@65 + int v15; // eax@65 + unsigned int v16; // edi@65 + unsigned int v17; // [sp-8h] [bp-70h]@3 + unsigned int v18; // [sp-8h] [bp-70h]@7 + unsigned int v19; // [sp-8h] [bp-70h]@18 + unsigned int v20; // [sp-8h] [bp-70h]@24 + unsigned int v21; // [sp-8h] [bp-70h]@30 + unsigned int v22; // [sp-8h] [bp-70h]@36 + unsigned int v23; // [sp-8h] [bp-70h]@42 + Texture *v24; // [sp-4h] [bp-6Ch]@3 + Texture *v25; // [sp-4h] [bp-6Ch]@7 + Texture *v26; // [sp-4h] [bp-6Ch]@18 + Texture *v27; // [sp-4h] [bp-6Ch]@24 + Texture *v28; // [sp-4h] [bp-6Ch]@30 + Texture *v29; // [sp-4h] [bp-6Ch]@36 + Texture *v30; // [sp-4h] [bp-6Ch]@42 + signed __int16 v31; // [sp+10h] [bp-58h]@1 + char *v32; // [sp+10h] [bp-58h]@49 + GUIWindow a1; // [sp+14h] [bp-54h]@46 + + v31 = 0; + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_AutonotesBook); + if ( BtnUp_flag || !dword_506528 ) + { + v24 = pTex_tab_an_6a__zoom_off; + v17 = pViewport->uViewportTL_Y + 2; + v0 = pViewport->uViewportTL_X + 407; + } + else + { + v24 = pTex_tab_an_6b__zoom_on; + v17 = pViewport->uViewportTL_Y + 1; + v0 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v0, v17, v24); + if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 ) + { + v25 = pTex_tab_an_7a__zoot_off; + v18 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 407; + } + else + { + v25 = pTex_tab_an_7b__zoot_on; + v18 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v1, v18, v25); + if ( !Book_PageBtn3_flag )//Potions_page_flag + { + if (_506568_autonote_type != AUTONOTE_POTION_RECEPIE) + { + pRenderer->DrawTextureTransparent( + pViewport->uViewportTL_X + 408, + pViewport->uViewportTL_Y + 113, + pTexture_506390); + v2 = 1; + goto LABEL_16; + } + goto LABEL_14; + } + if (_506568_autonote_type == AUTONOTE_POTION_RECEPIE) + { +LABEL_14: + v2 = 1; + goto LABEL_15; + } + v2 = 1; + v31 = 1; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); +LABEL_15: + _506568_autonote_type = AUTONOTE_POTION_RECEPIE; + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTexture_506394); +LABEL_16: + if ( Book_PageBtn4_flag )//Fontains_page_flag + { + if ( _506568_autonote_type != v2 ) + { + v31 = v2; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + } + } + else + { + if ( _506568_autonote_type != v2 ) + { + v26 = pTexture_506388; + v19 = pViewport->uViewportTL_Y + 150; + v3 = pViewport->uViewportTL_X + 408; + goto LABEL_22; + } + } + v26 = pTexture_50638C; + _506568_autonote_type = v2; + v19 = pViewport->uViewportTL_Y + 150; + v3 = pViewport->uViewportTL_X + 399; +LABEL_22: + pRenderer->DrawTextureTransparent(v3, v19, v26); + if ( Book_PageBtn5_flag )//Autonotes_Obelisks_page_flag + { + if ( _506568_autonote_type != AUTONOTE_OBELISK) + { + v31 = v2; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + } + } + else + { + if ( _506568_autonote_type != AUTONOTE_OBELISK) + { + v27 = pTexture_506380; + v20 = pViewport->uViewportTL_Y + 188; + v4 = pViewport->uViewportTL_X + 408; + goto LABEL_28; + } + } + v27 = pTexture_506384; + _506568_autonote_type = AUTONOTE_OBELISK; + v20 = pViewport->uViewportTL_Y + 188; + v4 = pViewport->uViewportTL_X + 397; +LABEL_28: + pRenderer->DrawTextureTransparent(v4, v20, v27); + if ( Book_PageBtn6_flag )//Autonotes_Seer_page_flag + { + if ( _506568_autonote_type != AUTONOTE_SEER) + { + v31 = v2; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + } + } + else + { + if ( _506568_autonote_type != AUTONOTE_SEER) + { + v28 = pTexture_506378; + v21 = pViewport->uViewportTL_Y + 226; + v5 = pViewport->uViewportTL_X + 408; + goto LABEL_34; + } + } + v28 = pTexture_50637C; + _506568_autonote_type = AUTONOTE_SEER; + v21 = pViewport->uViewportTL_Y + 226; + v5 = pViewport->uViewportTL_X + 397; +LABEL_34: + pRenderer->DrawTextureTransparent(v5, v21, v28); + if ( Autonotes_Misc_page_flag ) + { + if ( _506568_autonote_type != AUTONOTE_MISC) + { + v31 = v2; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + } + } + else + { + if ( _506568_autonote_type != AUTONOTE_MISC) + { + v29 = pTexture_506370; + v22 = pViewport->uViewportTL_Y + 263; + v6 = pViewport->uViewportTL_X + 408; + goto LABEL_40; + } + } + v29 = pTexture_506374; + _506568_autonote_type = AUTONOTE_MISC; + v22 = pViewport->uViewportTL_Y + 264; + v6 = pViewport->uViewportTL_X + 397; +LABEL_40: + pRenderer->DrawTextureTransparent(v6, v22, v29); + if ( Autonotes_Instructors_page_flag ) + { + if ( _506568_autonote_type != AUTONOTE_TEACHER) + { + v31 = v2; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + } + } + else + { + if ( _506568_autonote_type != AUTONOTE_TEACHER) + { + v30 = pTexture_506368; + v23 = pViewport->uViewportTL_Y + 302; + v7 = pViewport->uViewportTL_X + 408; + goto LABEL_46; + } + } + v30 = pTexture_50636C; + _506568_autonote_type = AUTONOTE_TEACHER; + v23 = pViewport->uViewportTL_Y + 302; + v7 = pViewport->uViewportTL_X + 397; +LABEL_46: + pRenderer->DrawTextureTransparent(v7, v23, v30); + a1.uFrameWidth = game_viewport_width; + a1.uFrameHeight = game_viewport_height; + a1.uFrameX = game_viewport_x; + a1.uFrameY = game_viewport_y; + a1.uFrameZ = game_viewport_z; + a1.uFrameW = game_viewport_w; + a1.DrawTitleText(pBook2Font, 0, 22, ui_book_autonotes_title_color, pGlobalTXT_LocalizationStrings[154], 3); // "Auto notes" + + a1.uFrameX = 48; + a1.uFrameY = 70; + a1.uFrameWidth = 360; + a1.uFrameHeight = 264; + a1.uFrameZ = 407; + a1.uFrameW = 333; + if ( v31 ) + { + num_achieved_awards_2 = 0; + dword_506528 = 0; + dword_50651C = 0; + num_achieved_awards = 0; + v8 = 0; + do + { + //if ( dword_72371C[2 * v8] == dword_506568 ) + if ( pAutonoteTxt[v8].eType == _506568_autonote_type ) + { + //v32 = (&dword_723718_autonote_related)[8 * (signed __int16)v8]; + v32 = (char *)pAutonoteTxt[v8].pText; + if ( (short)v8 ) + { + if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 ) + { + v9 = num_achieved_awards++; + achieved_awards[v9] = (AwardType)v8; + } + } + } + ++v8; + } + while ( v8 < 196 ); + num_achieved_awards_2 = num_achieved_awards; + } + else + { + if ( BtnDown_flag ) + { + v10 = num_achieved_awards + dword_506528; + if ( num_achieved_awards + dword_506528 < num_achieved_awards_2 ) + { + v11 = dword_50651C++; + byte_506130[v11] = num_achieved_awards; + dword_506528 = v10; + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + } + } + if ( BtnUp_flag && dword_50651C ) + { + --dword_50651C; + dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + } + if ( !num_achieved_awards || dword_506528 < 1 ) + { + dword_506528 = 0; + dword_50651C = 0; + } + } + v12 = dword_506528; + Autonotes_Instructors_page_flag = 0; + BtnDown_flag = 0; + BtnUp_flag = 0; + num_achieved_awards = 0; + Autonotes_Misc_page_flag = 0; + Book_PageBtn6_flag = 0;//Autonotes_Seer_page_flag + Book_PageBtn5_flag = 0;//Autonotes_Obelisks_page_flag + Book_PageBtn4_flag = 0;//Fontains_page_flag + Book_PageBtn3_flag = 0;//Potions_page_flag + while ( v12 < num_achieved_awards_2 ) + { + v13 = achieved_awards[v12]; + ++num_achieved_awards; + //v14 = (&dword_723718_autonote_related)[8 * v13]; + v14 = pAutonoteTxt[v13].pText; + //a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0); + a1.DrawText(pAutonoteFont, 1, 0, ui_book_autonotes_text_color, pAutonoteTxt[v13].pText, 0, 0, 0); + v15 = pAutonoteFont->CalcTextHeight(v14, &a1, 1, 0); + v16 = a1.uFrameY + v15; + if ( (signed int)(a1.uFrameY + v15) > (signed int)a1.uFrameHeight ) + break; + pRenderer->DrawTextureTransparent(0x64u, v16 + 12, pSpellBookPagesTextr_10); + ++v12; + a1.uFrameY = v16 + 24; + } + } + + //----- (00412E85) -------------------------------------------------------- +void BookUI_Journal_Draw() +{ + unsigned int v0; // eax@3 + unsigned int v1; // eax@7 + int v2; // eax@10 + const char *v3; // eax@10 + signed int v4; // ecx@12 + int v5; // ecx@14 + int v6; // eax@21 + int v7; // esi@21 + char *v8; // eax@21 + char* v9; // eax@22 + unsigned int v11; // [sp-8h] [bp-64h]@3 + unsigned int v12; // [sp-8h] [bp-64h]@7 + Texture *v13; // [sp-4h] [bp-60h]@3 + Texture *v14; // [sp-4h] [bp-60h]@7 + GUIWindow a1; // [sp+8h] [bp-54h]@10 + + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_11); + if ( BtnUp_flag || !dword_506528 ) + { + v13 = pTex_tab_an_6a__zoom_off; + v11 = pViewport->uViewportTL_Y + 2; + v0 = pViewport->uViewportTL_X + 407; + } + else + { + v13 = pTex_tab_an_6b__zoom_on; + v11 = pViewport->uViewportTL_Y + 1; + v0 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v0, v11, v13); + + if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 ) + { + v14 = pTex_tab_an_7a__zoot_off; + v12 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 407; + } + else + { + v14 = pTex_tab_an_7b__zoot_on; + v12 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v1, v12, v14); + + if ( !byte_5C6D50[dword_506528] ) + { + v2 = achieved_awards[dword_506528]; + a1.uFrameWidth = game_viewport_width; + a1.uFrameX = game_viewport_x; + a1.uFrameY = game_viewport_y; + a1.uFrameHeight = game_viewport_height; + v3 = (const char *)pStorylineText->StoreLine[v2].pPageTitle;//field_4[]; + a1.uFrameZ = game_viewport_z; + a1.uFrameW = game_viewport_w; + if ( v3 ) + a1.DrawTitleText(pBook2Font, 0, 22, ui_book_journal_title_color, v3, 3); + } + + a1.uFrameX = 48; + a1.uFrameY = 70; + a1.uFrameWidth = 360; + a1.uFrameHeight = 264; + v4 = LOBYTE(pAutonoteFont->uFontHeight) - 3; + a1.uFrameZ = 407; + a1.uFrameHeight = v4 * 264 / v4; + a1.uFrameW = a1.uFrameHeight + 69; + if ( BtnDown_flag && dword_506528 + num_achieved_awards < num_achieved_awards_2 ) + { + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + v5 = dword_50651C++; + dword_506528 += num_achieved_awards; + byte_506130[v5] = num_achieved_awards; + } + if ( BtnUp_flag && dword_50651C ) + { + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + --dword_50651C; + dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; + } + if ( !num_achieved_awards || dword_506528 < 1 ) + { + dword_506528 = 0; + dword_50651C = 0; + } + BtnDown_flag = 0; + v6 = achieved_awards[dword_506528]; + BtnUp_flag = 0; + 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( + pStorylineText->StoreLine[v6].pText, + uActiveCharacter - 1, + 0, + 0, + 0, + (__int64 *)&pParty->field_3C._s_times[ v6 + 21]); + if ( v7 ) + { + v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]); + a1.DrawText(pAutonoteFont, 1, 0, ui_book_journal_text_color, (const char *)v9, 0, a1.uFrameY + a1.uFrameHeight, ui_book_journal_text_shadow); + ++num_achieved_awards; + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/Books/UISpellBook.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -0,0 +1,232 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> + +#include "..\..\MM7.h" +#include "..\..\Render.h" +#include "..\..\Mouse.h" +#include "..\UIBooks.h" +#include "..\..\GUIWindow.h" +#include "..\..\GUIFont.h" +#include "..\..\Party.h" +#include "..\..\AudioPlayer.h" +#include "..\..\LOD.h" +#include "..\..\Allocator.h" +#include "..\..\Viewport.h" +#include "..\..\texts.h" +// +#include "..\..\mm7_data.h" + + +std::array<char *, 9> spellbook_texture_filename_suffices = {{"f", "a", "w", "e", "s", "m", "b", "l", "d"}}; // weak + +//----- (00411300) -------------------------------------------------------- +void LoadSpellbook(unsigned int spell_school) + { + //unsigned int v1; // esi@1 + Player *pPlayer; // ecx@1 + char v3; // al@1 + //int v4; // edi@5 + //Texture *result; // eax@6 + //unsigned char *v6; // edi@7 + //unsigned int v7; // eax@7 + //unsigned __int8 v8; // sf@8 + //unsigned __int8 v9; // of@8 + char pContainer[20]; // [sp+Ch] [bp-1Ch]@7 + //Texture *v11; // [sp+20h] [bp-8h]@5 + //int v12; // [sp+24h] [bp-4h]@5 + + byte_506550 = 0; + //v1 = uID; + pPlayer = pPlayers[uActiveCharacter]; + v3 = pPlayer->uQuickSpell; + if ( v3 && (unsigned __int8)v3 / 11 == spell_school ) + quick_spell_at_page = (unsigned __int8)v3 - 11 * spell_school; + else + quick_spell_at_page = 0; + + for (uint i = 1; i < 12; ++i) + { + if (pPlayer->spellbook.pChapters[spell_school].bIsSpellAvailable[i - 1]) + { + sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]); + dword_506408[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); + + sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]); + dword_5063D8[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); + } + } + } + + + +//----- (00411597) -------------------------------------------------------- +void OnCloseSpellBook() + { + pAllocator->FreeChunk(pSpellFont); + pSpellFont = nullptr; + pAllocator->FreeChunk(pBookFont); + pBookFont = nullptr; + pAllocator->FreeChunk(pBook2Font); + pBook2Font = nullptr; + pAllocator->FreeChunk(pAutonoteFont); + pAutonoteFont = nullptr; + pTexture_mapbordr->Release(); + pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0); + pIcons_LOD->_4114F2(); + dword_506364 = 0; + } + + + +//----- (00412AF9) -------------------------------------------------------- +static void BookUI_Spellbook_DrawCurrentSchoolBackground() +{ + int v0; // ecx@1 + + v0 = 0; + if ( uActiveCharacter ) + v0 = pParty->pPlayers[uActiveCharacter - 1].lastOpenedSpellbookPage;//*((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2); + pRenderer->DrawTextureIndexed(8, 8, pSpellBookPagesTextr[v0]); + pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C); + pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448); +} + + + + + +//----- (00412B58) -------------------------------------------------------- +void DrawSpellBookContent(Player *player) +{ + //Player *v0; // ebx@1 + int v1; // ebp@1 + //unsigned int v2; // eax@1 + Texture *v3; // edi@1 + int v4; // esi@1 + Texture *v5; // eax@3 + Texture *v6; // edx@5 + int v7; // eax@8 + int v8; // eax@11 + POINT *v9; // esi@13 + int v10; // eax@13 + Texture *v11; // edx@14 + int v12; // eax@15 + signed int v13; // ecx@18 + unsigned int v14; // esi@18 + unsigned int v15; // edi@18 + Texture *pPageTexture; // eax@21 + unsigned int v17; // [sp-Ch] [bp-2Ch]@8 + unsigned int v18; // [sp-Ch] [bp-2Ch]@15 + unsigned int v19; // [sp-8h] [bp-28h]@8 + unsigned int v20; // [sp-8h] [bp-28h]@15 + Texture *v21; // [sp-4h] [bp-24h]@15 + signed int v22; // [sp-4h] [bp-24h]@22 + Texture *v23; // [sp+10h] [bp-10h]@5 + POINT a2; // [sp+18h] [bp-8h]@13 + POINT v24; + int v25; + + static unsigned int texture_tab_coord1[9][2]= + {{406, 9}, {406, 46}, {406, 84}, {406,121}, {407,158}, {405, 196}, {405, 234}, {405, 272}, {405,309} }; + + static unsigned int texture_tab_coord0[9][2]= + {{415, 10}, {415, 46}, {415, 83}, {415,121}, {415,158}, {416, 196}, {416, 234}, {416, 271}, {416,307} }; + + BookUI_Spellbook_DrawCurrentSchoolBackground(); + + //v0 = pPlayers[uActiveCharacter]; + v1 = 11 * player->lastOpenedSpellbookPage; + //v2 = pIcons_LOD->FindTextureByName("Pending"); + v3 = pIcons_LOD->GetTexture(pIcons_LOD->FindTextureByName("Pending")); + pRenderer->ClearZBuffer(0, 479); + v4 = 1; + if ( __OFSUB__(v1, v1 + 11) ^ 1 ) + { + do + { + if ( *(&player->_guilds_member_bits[v1 + 63] + v4) ) + { + v5 = (Texture *)dword_506408[v4]; + if ( v5 != v3 ) + { + if ( quick_spell_at_page == v4 ) + { + v6 = dword_5063D8[v4]; + v23 = dword_5063D8[v4]; + } + else + { + v23 = dword_506408[v4]; + v6 = v5; + } + if ( v6->pLevelOfDetail0_prolly_alpha_mask ) + { + v7 = player->lastOpenedSpellbookPage; + // v7 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]); + v19 = pViewport->uViewportTL_Y + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos; + v17 = pViewport->uViewportTL_X + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos; + if ( BYTE1(v6->pBits) & 2 ) + pRenderer->DrawTextureTransparent(v17, v19, v6); + else + pRenderer->DrawTextureIndexed(v17, v19, v6); + pRenderer->DrawMaskToZBuffer(pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos, + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos, v23, v4); + } + } + } + ++v4; + } + while ( v4 - 1 < 11 ); + } + + v9 = pMouse->GetCursorPos(&a2); + v10 = pRenderer->pActiveZBuffer[v9->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v24)->y]] & 0xFFFF; + if ( v10 ) + { + v11 = dword_5063D8[v10]; + if ( v11->pLevelOfDetail0_prolly_alpha_mask ) + { + v21 = dword_5063D8[v10]; + v12 = player->lastOpenedSpellbookPage; + // v12 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v10]); + v20 = pViewport->uViewportTL_Y + pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Ypos; + v18 = pViewport->uViewportTL_X + pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Xpos; + if ( BYTE1(v11->pBits) & 2 ) + pRenderer->DrawTextureTransparent(v18, v20, v21); + else + pRenderer->DrawTextureIndexed(v18, v20, v21); + } + } + v13 = 0; + a2.x = (LONG)&player->pActiveSkills[12]; + v14 = (unsigned int)&player->pActiveSkills[12]; + v15 = (unsigned int)&player->pActiveSkills[12]; + v25 = 0; + do + { + if ( *(short *)a2.x ) + { + if ( player->lastOpenedSpellbookPage == v13 ) + { + pPageTexture = pTextures_tabs[v13][1]; + v14=texture_tab_coord1[v13][0]; + v15=texture_tab_coord1[v13][1]; + } + else + { + pPageTexture = pTextures_tabs[v13][0]; + v14=texture_tab_coord0[v13][0]; + v15=texture_tab_coord0[v13][1]; + } + pRenderer->DrawTextureTransparent(v14, v15, pPageTexture); + v13 = v25; + } + a2.x += 2; + ++v13; + v25 = v13; + } + while ( v13 < 9 ); +} \ No newline at end of file
--- a/UI/UIBooks.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/UI/UIBooks.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -6,22 +6,14 @@ #include "..\MM7.h" -#include "..\Mouse.h" - -#include "..\MapInfo.h" +#include "UIBooks.h" +#include "..\Render.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" -#include "..\Party.h" #include "..\AudioPlayer.h" -#include "..\Outdoor.h" #include "..\LOD.h" #include "..\Allocator.h" -#include "..\Viewport.h" -#include "..\Math.h" -#include "..\Awards.h" -#include "..\Autonotes.h" -#include "..\StorylineTextTable.h" -#include "..\texts.h" + #include "..\mm7_data.h" @@ -30,152 +22,6 @@ - -//----- (00411150) -------------------------------------------------------- -void BookUI_DrawTownPortalMap() -{ - //signed int v0; // edi@1 - //__int16 v1; // dx@8 - //POINT *v2; // edi@17 - int v3; // edi@17 - //__int16 v4; // dx@24 - GUIWindow v6; // [sp+Ch] [bp-64h]@1 - //POINT v7; // [sp+60h] [bp-10h]@17 - POINT a2; // [sp+68h] [bp-8h]@17 - - pRenderer->ClearZBuffer(0, 479); - pRenderer->DrawTextureTransparent(8, 8, pTexture_CurrentBook); - pRenderer->DrawTextureTransparent(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId)); - - v6.uFrameX = game_viewport_x; - v6.uFrameY = game_viewport_y; - v6.uFrameWidth = game_viewport_width; - v6.uFrameHeight = game_viewport_height; - v6.uFrameZ = game_viewport_z; - v6.uFrameW = game_viewport_w; - - const uint fountain_bits_lut[] = {PARTY_QUEST_FOUNTAIN_HARMONDALE, - PARTY_QUEST_FOUNTAIN_PIERPONT, - PARTY_QUEST_FOUNTAIN_NIGHON, - PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE, - PARTY_QUEST_FOUNTAIN_CELESTIA, - PARTY_QUEST_FOUNTAIN_THE_PIT}; - for (uint i = 0; i < 6; ++i) - { - - if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[i])) - pRenderer->DrawMaskToZBuffer(pTownPortalBook_xs[i], - pTownPortalBook_ys[i], - pTexture_TownPortalIcons[i], i + 1); - } - -/* v0 = 0; - do - { - if ( !v0 ) - { - v1 = 206; -LABEL_14: - if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v1) ) - goto LABEL_16; - goto LABEL_15; - } - if ( v0 == 1 ) - { - v1 = 208; - goto LABEL_14; - } - if ( v0 == 2 ) - { - v1 = 207; - goto LABEL_14; - } - if ( v0 == 3 ) - { - v1 = 211; - goto LABEL_14; - } - if ( v0 == 4 ) - { - v1 = 209; - goto LABEL_14; - } - if ( v0 == 5 ) - { - v1 = 210; - goto LABEL_14; - } -LABEL_15: - pRenderer->DrawMaskToZBuffer( - pTownPortalBook_xs[v0], - pTownPortalBook_ys[v0], - *(&pTexture_TownPortalHarmn + v0), - v0 + 1); -LABEL_16: - ++v0; - } - while ( v0 < 6 );*/ - - pMouse->GetCursorPos(&a2); - //v2 = pMouse->GetCursorPos(&a2); - v3 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF; - - if (v3) - { - if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[v3 - 1])) - pRenderer->DrawTextureIndexed(pTownPortalBook_xs[v3 - 1], pTownPortalBook_ys[v3 - 1], pTexture_TownPortalIcons[v3 - 1]); - } - v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); - - -/* if ( !v3 ) // Town Portal - { - v6.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3); // "Town Portal" - return; - } - if ( v3 == 1 ) - { - v4 = 206; -LABEL_30: - if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v4) ) - goto LABEL_31; - v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); // "Town Portal" - return; - } - if ( v3 == 2 ) - { - v4 = 208; - goto LABEL_30; - } - if ( v3 == 3 ) - { - v4 = 207; - goto LABEL_30; - } - if ( v3 == 4 ) - { - v4 = 211; - goto LABEL_30; - } - if ( v3 == 5 ) - { - v4 = 209; - goto LABEL_30; - } - if ( v3 == 6 ) - { - v4 = 210; - goto LABEL_30; - } -LABEL_31: - pRenderer->DrawTextureIndexed(word_4E1D3A[v3], pTownPortalBook_xs[v3 + 5], *(&pTex_tab_an_6b__zoom_on + v3)); - v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);*/ -} -// 4E1D3A: using guessed type __int16 word_4E1D3A[]; - - - - //----- (00413CC6) -------------------------------------------------------- void BookUI_Draw(WindowType book) { @@ -195,111 +41,9 @@ -//----- (00413D3C) -------------------------------------------------------- -static const char *GetDayPart() -{ - if (pParty->uCurrentHour <= 4) - return pGlobalTXT_LocalizationStrings[567]; // "Night" - else if (pParty->uCurrentHour == 5) - return pGlobalTXT_LocalizationStrings[55]; // "Dawn" - else if (pParty->uCurrentHour == 20) - return pGlobalTXT_LocalizationStrings[566]; // "Dusk" - else - return pGlobalTXT_LocalizationStrings[56]; // "Day" -} -//----- (00413D6F) -------------------------------------------------------- -void BookUI_Calendar_Draw() -{ - unsigned int v0; // esi@1 - //char *v1; // eax@5 - int v2; // ecx@5 - char *v3; // eax@6 - GUIWindow a1; // [sp+Ch] [bp-60h]@5 - unsigned int v6; // [sp+60h] [bp-Ch]@1 - //int v7; // [sp+64h] [bp-8h]@1 - //int a5; // [sp+68h] [bp-4h]@1 - - - static unsigned int pDayMoonPhase[28] = // 4E1B18 - { - 0, 0, 0, - 1, 1, 1, 1, - 2, 2, 2, - 3, 3, 3, 3, - 4, 4, 4, - 3, 3, 3, 3, - 2, 2, 2, - 1, 1, 1, 1 - }; - - - v0 = pParty->uCurrentHour; - pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13); - if ( (signed int)v0 <= 12 ) - { - if ( !v0 ) - v0 = 12; - } - else - { - v0 -= 12; - } - a1.uFrameX = game_viewport_x; - a1.uFrameY = game_viewport_y; - a1.uFrameWidth = game_viewport_width; - a1.uFrameHeight = game_viewport_height; - a1.uFrameZ = game_viewport_z; - a1.uFrameW = game_viewport_w; - a1.DrawTitleText(pBook2Font, 0, 0x16u, ui_book_calendar_title_color, pGlobalTXT_LocalizationStrings[186], 3); // "Time in Erathia" - - v2 = 0; - if ( pParty->uCurrentHour >= 12 ) - { - if ( pParty->uCurrentHour >= 24 ) - v2=0; - else - v2=1; - } - - sprintf(pTmpBuf.data(), "%s\t100:\t110%d:%02d %s - %s", - pGlobalTXT_LocalizationStrings[526], // "Time" - v0, - pParty->uCurrentMinute, - aAMPMNames[v2], - GetDayPart()); - a1.DrawText(pBookFont, 70, 55, ui_book_calendar_time_color, pTmpBuf.data(), 0, 0, 0); - - sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", - pGlobalTXT_LocalizationStrings[56], // "Day" - pParty->uDaysPlayed + 1, - aDayNames[pParty->uDaysPlayed % 7]); - a1.DrawText(pBookFont, 70, 2 * LOBYTE(pBookFont->uFontHeight) + 49, ui_book_calendar_day_color, pTmpBuf.data(), 0, 0, 0); - - sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", - pGlobalTXT_LocalizationStrings[146], // "Month" - pParty->uCurrentMonth + 1, - aMonthNames[pParty->uCurrentMonth]); - a1.DrawText(pBookFont, 70, 4 * LOBYTE(pBookFont->uFontHeight) + 43, ui_book_calendar_month_color, pTmpBuf.data(), 0, 0, 0); - - sprintf(pTmpBuf.data(), "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); // "Year" - a1.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, ui_book_calendar_year_color, pTmpBuf.data(), 0, 0, 0); - - sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[pDayMoonPhase[pParty->uDaysPlayed]]); // "Moon" - a1.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, ui_book_calendar_moon_color, pTmpBuf.data(), 0, 0, 0); - - v6 = pMapStats->GetMapInfo(pCurrentMapName.data()); - if ( v6 ) - v3 = pMapStats->pInfos[v6].pName; - else - v3 = "Unknown"; - sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], v3); // "Location" - a1.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, ui_book_calendar_location_color, pTmpBuf.data(), 0, 0, 0); -} - - //----- (0041192C) -------------------------------------------------------- void InitializeBookTextures() @@ -360,43 +104,6 @@ -//----- (00411300) -------------------------------------------------------- -void LoadSpellbook(unsigned int spell_school) -{ - //unsigned int v1; // esi@1 - Player *pPlayer; // ecx@1 - char v3; // al@1 - //int v4; // edi@5 - //Texture *result; // eax@6 - //unsigned char *v6; // edi@7 - //unsigned int v7; // eax@7 - //unsigned __int8 v8; // sf@8 - //unsigned __int8 v9; // of@8 - char pContainer[20]; // [sp+Ch] [bp-1Ch]@7 - //Texture *v11; // [sp+20h] [bp-8h]@5 - //int v12; // [sp+24h] [bp-4h]@5 - - byte_506550 = 0; - //v1 = uID; - pPlayer = pPlayers[uActiveCharacter]; - v3 = pPlayer->uQuickSpell; - if ( v3 && (unsigned __int8)v3 / 11 == spell_school ) - quick_spell_at_page = (unsigned __int8)v3 - 11 * spell_school; - else - quick_spell_at_page = 0; - - for (uint i = 1; i < 12; ++i) - { - if (pPlayer->spellbook.pChapters[spell_school].bIsSpellAvailable[i - 1]) - { - sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]); - dword_506408[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); - - sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]); - dword_5063D8[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); - } - } -} //----- (0041140B) -------------------------------------------------------- void sub_41140B() @@ -447,1324 +154,9 @@ } -//----- (00411597) -------------------------------------------------------- -void OnCloseSpellBook() -{ - pAllocator->FreeChunk(pSpellFont); - pSpellFont = nullptr; - pAllocator->FreeChunk(pBookFont); - pBookFont = nullptr; - pAllocator->FreeChunk(pBook2Font); - pBook2Font = nullptr; - pAllocator->FreeChunk(pAutonoteFont); - pAutonoteFont = nullptr; - pTexture_mapbordr->Release(); - pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0); - pIcons_LOD->_4114F2(); - dword_506364 = 0; -} - -//----- (00412E85) -------------------------------------------------------- -void BookUI_Journal_Draw() -{ - unsigned int v0; // eax@3 - unsigned int v1; // eax@7 - int v2; // eax@10 - const char *v3; // eax@10 - signed int v4; // ecx@12 - int v5; // ecx@14 - int v6; // eax@21 - int v7; // esi@21 - char *v8; // eax@21 - char* v9; // eax@22 - unsigned int v11; // [sp-8h] [bp-64h]@3 - unsigned int v12; // [sp-8h] [bp-64h]@7 - Texture *v13; // [sp-4h] [bp-60h]@3 - Texture *v14; // [sp-4h] [bp-60h]@7 - GUIWindow a1; // [sp+8h] [bp-54h]@10 - - pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_11); - if ( BtnUp_flag || !dword_506528 ) - { - v13 = pTex_tab_an_6a__zoom_off; - v11 = pViewport->uViewportTL_Y + 2; - v0 = pViewport->uViewportTL_X + 407; - } - else - { - v13 = pTex_tab_an_6b__zoom_on; - v11 = pViewport->uViewportTL_Y + 1; - v0 = pViewport->uViewportTL_X + 398; - } - pRenderer->DrawTextureTransparent(v0, v11, v13); - - if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 ) - { - v14 = pTex_tab_an_7a__zoot_off; - v12 = pViewport->uViewportTL_Y + 38; - v1 = pViewport->uViewportTL_X + 407; - } - else - { - v14 = pTex_tab_an_7b__zoot_on; - v12 = pViewport->uViewportTL_Y + 38; - v1 = pViewport->uViewportTL_X + 398; - } - pRenderer->DrawTextureTransparent(v1, v12, v14); - - if ( !byte_5C6D50[dword_506528] ) - { - v2 = achieved_awards[dword_506528]; - a1.uFrameWidth = game_viewport_width; - a1.uFrameX = game_viewport_x; - a1.uFrameY = game_viewport_y; - a1.uFrameHeight = game_viewport_height; - v3 = (const char *)pStorylineText->StoreLine[v2].pPageTitle;//field_4[]; - a1.uFrameZ = game_viewport_z; - a1.uFrameW = game_viewport_w; - if ( v3 ) - a1.DrawTitleText(pBook2Font, 0, 22, ui_book_journal_title_color, v3, 3); - } - - a1.uFrameX = 48; - a1.uFrameY = 70; - a1.uFrameWidth = 360; - a1.uFrameHeight = 264; - v4 = LOBYTE(pAutonoteFont->uFontHeight) - 3; - a1.uFrameZ = 407; - a1.uFrameHeight = v4 * 264 / v4; - a1.uFrameW = a1.uFrameHeight + 69; - if ( BtnDown_flag && dword_506528 + num_achieved_awards < num_achieved_awards_2 ) - { - pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); - v5 = dword_50651C++; - dword_506528 += num_achieved_awards; - byte_506130[v5] = num_achieved_awards; - } - if ( BtnUp_flag && dword_50651C ) - { - pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); - --dword_50651C; - dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; - } - if ( !num_achieved_awards || dword_506528 < 1 ) - { - dword_506528 = 0; - dword_50651C = 0; - } - BtnDown_flag = 0; - v6 = achieved_awards[dword_506528]; - BtnUp_flag = 0; - 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( - pStorylineText->StoreLine[v6].pText, - uActiveCharacter - 1, - 0, - 0, - 0, - (__int64 *)&pParty->field_3C._s_times[ v6 + 21]); - if ( v7 ) - { - v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]); - a1.DrawText(pAutonoteFont, 1, 0, ui_book_journal_text_color, (const char *)v9, 0, a1.uFrameY + a1.uFrameHeight, ui_book_journal_text_shadow); - ++num_achieved_awards; - } -} - - -//----- (00413126) -------------------------------------------------------- -void BookUI_Questbook_Draw() -{ - unsigned int v0; // eax@3 - unsigned int v1; // eax@7 - int v2; // ecx@11 - int v3; // ebx@16 - int v4; // eax@19 - const char *v5; // edi@19 - int v6; // eax@19 - unsigned int v7; // edi@19 - unsigned int v8; // [sp-8h] [bp-68h]@3 - unsigned int v9; // [sp-8h] [bp-68h]@7 - Texture *v10; // [sp-4h] [bp-64h]@3 - Texture *v11; // [sp-4h] [bp-64h]@7 - GUIWindow a1; // [sp+Ch] [bp-54h]@9 - - pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_CurrentBook); - if ( BtnUp_flag || !dword_506528 ) - { - v10 = pTex_tab_an_6a__zoom_off; - v8 = pViewport->uViewportTL_Y + 2; - v0 = pViewport->uViewportTL_X + 407; - } - else - { - v10 = pTex_tab_an_6b__zoom_on; - v8 = pViewport->uViewportTL_Y + 1; - v0 = pViewport->uViewportTL_X + 398; - } - pRenderer->DrawTextureTransparent(v0, v8, v10); - if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 ) - { - v11 = pTex_tab_an_7a__zoot_off; - v9 = pViewport->uViewportTL_Y + 38; - v1 = pViewport->uViewportTL_X + 407; - } - else - { - v11 = pTex_tab_an_7b__zoot_on; - v9 = pViewport->uViewportTL_Y + 38; - v1 = pViewport->uViewportTL_X + 398; - } - pRenderer->DrawTextureTransparent(v1, v9, v11); - a1.uFrameWidth = game_viewport_width; - a1.uFrameHeight = game_viewport_height; - a1.uFrameX = game_viewport_x; - a1.uFrameY = game_viewport_y; - a1.uFrameZ = game_viewport_z; - a1.uFrameW = game_viewport_w; - a1.DrawTitleText(pBook2Font, 0, 22, ui_book_quests_title_color, pGlobalTXT_LocalizationStrings[174], 3); //"Current Quests" - - a1.uFrameX = 48; - a1.uFrameY = 70; - a1.uFrameWidth = 360; - a1.uFrameHeight = 264; - a1.uFrameZ = 407; - a1.uFrameW = 333; - if ( BtnDown_flag && dword_506528 + num_achieved_awards < num_achieved_awards_2 ) - { - pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); - v2 = dword_50651C++; - dword_506528 += num_achieved_awards; - byte_506130[v2] = num_achieved_awards; - } - if ( BtnUp_flag && dword_50651C ) - { - pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); - --dword_50651C; - dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; - } - if ( !num_achieved_awards || (v3 = dword_506528, dword_506528 < 1) ) - { - v3 = 0; - dword_50651C = 0; - dword_506528 = 0; - } - BtnDown_flag = 0; - BtnUp_flag = 0; - num_achieved_awards = 0; - while ( v3 < num_achieved_awards_2 ) - { - v4 = achieved_awards[v3]; - ++num_achieved_awards; - v5 = pQuestTable[v4-1];//(&dword_722F10)[4 * v4]; - a1.DrawText(pAutonoteFont, 1, 0, ui_book_quests_text_color, pQuestTable[v4-1], 0, 0, 0);//(&dword_722F10)[4 * v4], 0, 0, 0); - v6 = pAutonoteFont->CalcTextHeight(v5, &a1, 1, 0); - v7 = a1.uFrameY + v6; - if ( (signed int)(a1.uFrameY + v6) > (signed int)a1.uFrameHeight ) - break; - pRenderer->DrawTextureTransparent(100, v7 + 12, pSpellBookPagesTextr_10); - ++v3; - a1.uFrameY = v7 + 24; - } -} - - -//----- (0041338E) -------------------------------------------------------- -void BookUI_Autonotes_Draw() -{ - unsigned int v0; // eax@3 - unsigned int v1; // eax@7 - signed int v2; // ebp@11 - unsigned int v3; // eax@18 - unsigned int v4; // eax@24 - unsigned int v5; // eax@30 - unsigned int v6; // eax@36 - unsigned int v7; // eax@42 - signed int v8; // ebp@47 - int v9; // eax@52 - int v10; // eax@56 - int v11; // edx@57 - int v12; // ebp@64 - int v13; // eax@65 - const char *v14; // edi@65 - int v15; // eax@65 - unsigned int v16; // edi@65 - unsigned int v17; // [sp-8h] [bp-70h]@3 - unsigned int v18; // [sp-8h] [bp-70h]@7 - unsigned int v19; // [sp-8h] [bp-70h]@18 - unsigned int v20; // [sp-8h] [bp-70h]@24 - unsigned int v21; // [sp-8h] [bp-70h]@30 - unsigned int v22; // [sp-8h] [bp-70h]@36 - unsigned int v23; // [sp-8h] [bp-70h]@42 - Texture *v24; // [sp-4h] [bp-6Ch]@3 - Texture *v25; // [sp-4h] [bp-6Ch]@7 - Texture *v26; // [sp-4h] [bp-6Ch]@18 - Texture *v27; // [sp-4h] [bp-6Ch]@24 - Texture *v28; // [sp-4h] [bp-6Ch]@30 - Texture *v29; // [sp-4h] [bp-6Ch]@36 - Texture *v30; // [sp-4h] [bp-6Ch]@42 - signed __int16 v31; // [sp+10h] [bp-58h]@1 - char *v32; // [sp+10h] [bp-58h]@49 - GUIWindow a1; // [sp+14h] [bp-54h]@46 - - v31 = 0; - pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_AutonotesBook); - if ( BtnUp_flag || !dword_506528 ) - { - v24 = pTex_tab_an_6a__zoom_off; - v17 = pViewport->uViewportTL_Y + 2; - v0 = pViewport->uViewportTL_X + 407; - } - else - { - v24 = pTex_tab_an_6b__zoom_on; - v17 = pViewport->uViewportTL_Y + 1; - v0 = pViewport->uViewportTL_X + 398; - } - pRenderer->DrawTextureTransparent(v0, v17, v24); - if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 ) - { - v25 = pTex_tab_an_7a__zoot_off; - v18 = pViewport->uViewportTL_Y + 38; - v1 = pViewport->uViewportTL_X + 407; - } - else - { - v25 = pTex_tab_an_7b__zoot_on; - v18 = pViewport->uViewportTL_Y + 38; - v1 = pViewport->uViewportTL_X + 398; - } - pRenderer->DrawTextureTransparent(v1, v18, v25); - if ( !Book_PageBtn3_flag )//Potions_page_flag - { - if (_506568_autonote_type != AUTONOTE_POTION_RECEPIE) - { - pRenderer->DrawTextureTransparent( - pViewport->uViewportTL_X + 408, - pViewport->uViewportTL_Y + 113, - pTexture_506390); - v2 = 1; - goto LABEL_16; - } - goto LABEL_14; - } - if (_506568_autonote_type == AUTONOTE_POTION_RECEPIE) - { -LABEL_14: - v2 = 1; - goto LABEL_15; - } - v2 = 1; - v31 = 1; - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); -LABEL_15: - _506568_autonote_type = AUTONOTE_POTION_RECEPIE; - pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTexture_506394); -LABEL_16: - if ( Book_PageBtn4_flag )//Fontains_page_flag - { - if ( _506568_autonote_type != v2 ) - { - v31 = v2; - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); - } - } - else - { - if ( _506568_autonote_type != v2 ) - { - v26 = pTexture_506388; - v19 = pViewport->uViewportTL_Y + 150; - v3 = pViewport->uViewportTL_X + 408; - goto LABEL_22; - } - } - v26 = pTexture_50638C; - _506568_autonote_type = v2; - v19 = pViewport->uViewportTL_Y + 150; - v3 = pViewport->uViewportTL_X + 399; -LABEL_22: - pRenderer->DrawTextureTransparent(v3, v19, v26); - if ( Book_PageBtn5_flag )//Autonotes_Obelisks_page_flag - { - if ( _506568_autonote_type != AUTONOTE_OBELISK) - { - v31 = v2; - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); - } - } - else - { - if ( _506568_autonote_type != AUTONOTE_OBELISK) - { - v27 = pTexture_506380; - v20 = pViewport->uViewportTL_Y + 188; - v4 = pViewport->uViewportTL_X + 408; - goto LABEL_28; - } - } - v27 = pTexture_506384; - _506568_autonote_type = AUTONOTE_OBELISK; - v20 = pViewport->uViewportTL_Y + 188; - v4 = pViewport->uViewportTL_X + 397; -LABEL_28: - pRenderer->DrawTextureTransparent(v4, v20, v27); - if ( Book_PageBtn6_flag )//Autonotes_Seer_page_flag - { - if ( _506568_autonote_type != AUTONOTE_SEER) - { - v31 = v2; - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); - } - } - else - { - if ( _506568_autonote_type != AUTONOTE_SEER) - { - v28 = pTexture_506378; - v21 = pViewport->uViewportTL_Y + 226; - v5 = pViewport->uViewportTL_X + 408; - goto LABEL_34; - } - } - v28 = pTexture_50637C; - _506568_autonote_type = AUTONOTE_SEER; - v21 = pViewport->uViewportTL_Y + 226; - v5 = pViewport->uViewportTL_X + 397; -LABEL_34: - pRenderer->DrawTextureTransparent(v5, v21, v28); - if ( Autonotes_Misc_page_flag ) - { - if ( _506568_autonote_type != AUTONOTE_MISC) - { - v31 = v2; - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); - } - } - else - { - if ( _506568_autonote_type != AUTONOTE_MISC) - { - v29 = pTexture_506370; - v22 = pViewport->uViewportTL_Y + 263; - v6 = pViewport->uViewportTL_X + 408; - goto LABEL_40; - } - } - v29 = pTexture_506374; - _506568_autonote_type = AUTONOTE_MISC; - v22 = pViewport->uViewportTL_Y + 264; - v6 = pViewport->uViewportTL_X + 397; -LABEL_40: - pRenderer->DrawTextureTransparent(v6, v22, v29); - if ( Autonotes_Instructors_page_flag ) - { - if ( _506568_autonote_type != AUTONOTE_TEACHER) - { - v31 = v2; - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); - } - } - else - { - if ( _506568_autonote_type != AUTONOTE_TEACHER) - { - v30 = pTexture_506368; - v23 = pViewport->uViewportTL_Y + 302; - v7 = pViewport->uViewportTL_X + 408; - goto LABEL_46; - } - } - v30 = pTexture_50636C; - _506568_autonote_type = AUTONOTE_TEACHER; - v23 = pViewport->uViewportTL_Y + 302; - v7 = pViewport->uViewportTL_X + 397; -LABEL_46: - pRenderer->DrawTextureTransparent(v7, v23, v30); - a1.uFrameWidth = game_viewport_width; - a1.uFrameHeight = game_viewport_height; - a1.uFrameX = game_viewport_x; - a1.uFrameY = game_viewport_y; - a1.uFrameZ = game_viewport_z; - a1.uFrameW = game_viewport_w; - a1.DrawTitleText(pBook2Font, 0, 22, ui_book_autonotes_title_color, pGlobalTXT_LocalizationStrings[154], 3); // "Auto notes" - - a1.uFrameX = 48; - a1.uFrameY = 70; - a1.uFrameWidth = 360; - a1.uFrameHeight = 264; - a1.uFrameZ = 407; - a1.uFrameW = 333; - if ( v31 ) - { - num_achieved_awards_2 = 0; - dword_506528 = 0; - dword_50651C = 0; - num_achieved_awards = 0; - v8 = 0; - do - { - //if ( dword_72371C[2 * v8] == dword_506568 ) - if ( pAutonoteTxt[v8-1].eType == _506568_autonote_type ) - { - //v32 = (&dword_723718_autonote_related)[8 * (signed __int16)v8]; - v32 = (char *)pAutonoteTxt[v8-1].pText; - if ( (short)v8 ) - { - if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 ) - { - v9 = num_achieved_awards++; - achieved_awards[v9] = (AwardType)v8; - } - } - } - ++v8; - } - while ( v8 < 196 ); - num_achieved_awards_2 = num_achieved_awards; - } - else - { - if ( BtnDown_flag ) - { - v10 = num_achieved_awards + dword_506528; - if ( num_achieved_awards + dword_506528 < num_achieved_awards_2 ) - { - v11 = dword_50651C++; - byte_506130[v11] = num_achieved_awards; - dword_506528 = v10; - pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); - } - } - if ( BtnUp_flag && dword_50651C ) - { - --dword_50651C; - dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; - pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); - } - if ( !num_achieved_awards || dword_506528 < 1 ) - { - dword_506528 = 0; - dword_50651C = 0; - } - } - v12 = dword_506528; - Autonotes_Instructors_page_flag = 0; - BtnDown_flag = 0; - BtnUp_flag = 0; - num_achieved_awards = 0; - Autonotes_Misc_page_flag = 0; - Book_PageBtn6_flag = 0;//Autonotes_Seer_page_flag - Book_PageBtn5_flag = 0;//Autonotes_Obelisks_page_flag - Book_PageBtn4_flag = 0;//Fontains_page_flag - Book_PageBtn3_flag = 0;//Potions_page_flag - while ( v12 < num_achieved_awards_2 ) - { - v13 = achieved_awards[v12]; - ++num_achieved_awards; - //v14 = (&dword_723718_autonote_related)[8 * v13]; - v14 = pAutonoteTxt[v13-1].pText; - //a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0); - a1.DrawText(pAutonoteFont, 1, 0, ui_book_autonotes_text_color, pAutonoteTxt[v13-1].pText, 0, 0, 0); - v15 = pAutonoteFont->CalcTextHeight(v14, &a1, 1, 0); - v16 = a1.uFrameY + v15; - if ( (signed int)(a1.uFrameY + v15) > (signed int)a1.uFrameHeight ) - break; - pRenderer->DrawTextureTransparent(0x64u, v16 + 12, pSpellBookPagesTextr_10); - ++v12; - a1.uFrameY = v16 + 24; - } -} - - -//----- (00413980) -------------------------------------------------------- -void BookUI_Map_Draw() -{ - int v6; // eax@31 - unsigned int map_id; // eax@35 - Texture *buttnTxtr; // [sp-4h] [bp-DCh]@3 - char party_coord[120]; // [sp+Ch] [bp-CCh]@37 - GUIWindow map_window; // [sp+84h] [bp-54h]@35 - unsigned int textrX, textrY; - - pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_12); - if ( BtnUp_flag || viewparams->field_2C / 128 >= 12 ) - { - buttnTxtr = pTex_tab_an_6a__zoom_off; - textrY = pViewport->uViewportTL_Y + 2; - textrX = pViewport->uViewportTL_X + 408; - } - else - { - buttnTxtr = pTex_tab_an_6b__zoom_on; - textrY = pViewport->uViewportTL_Y + 1; - textrX = pViewport->uViewportTL_X + 398; - } - pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); - if ( BtnDown_flag || viewparams->field_2C / 128 <= 3 ) - { - buttnTxtr = pTex_tab_an_7a__zoot_off; - textrY = pViewport->uViewportTL_Y + 38; - textrX = pViewport->uViewportTL_X + 408; - } - else - { - buttnTxtr = pTex_tab_an_7b__zoot_on; - textrY = pViewport->uViewportTL_Y + 38; - textrX = pViewport->uViewportTL_X + 398; - } - pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); - if ( Book_PageBtn3_flag ) - { - buttnTxtr = pTexture_506390; - textrY = pViewport->uViewportTL_Y + 113; - textrX = pViewport->uViewportTL_X + 408; - } - else - { - buttnTxtr = pTexture_506394; - textrY = pViewport->uViewportTL_Y + 113; - textrX = pViewport->uViewportTL_X + 398; - } - pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); - if ( Book_PageBtn4_flag ) - { - buttnTxtr = pTexture_506388; - textrY = pViewport->uViewportTL_X + 150; - textrX = pViewport->uViewportTL_Y + 408; - } - else - { - buttnTxtr = pTexture_50638C; - textrY = pViewport->uViewportTL_X + 150; - textrX = pViewport->uViewportTL_Y + 399; - } - pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); - if ( Book_PageBtn5_flag ) - { - buttnTxtr = pTexture_506380; - textrY = pViewport->uViewportTL_Y + 188; - textrX = pViewport->uViewportTL_X + 408; - } - else - { - buttnTxtr = pTexture_506384; - textrY = pViewport->uViewportTL_Y + 188; - textrX = pViewport->uViewportTL_X + 397; - } - pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); - if ( Book_PageBtn6_flag ) - { - buttnTxtr = pTexture_506378; - textrY = pViewport->uViewportTL_Y + 226; - textrX = pViewport->uViewportTL_X + 408; - } - else - { - buttnTxtr = pTexture_50637C; - textrY = pViewport->uViewportTL_Y + 226; - textrX = pViewport->uViewportTL_X + 397; - } - pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); - if ( BtnDown_flag ) - viewparams->CenterOnParty2(); - if ( BtnUp_flag ) - viewparams->CenterOnParty(); - if ( Book_PageBtn3_flag ) - viewparams->_443219(); - if ( Book_PageBtn4_flag ) - viewparams->_443231(); - if ( Book_PageBtn5_flag ) - viewparams->_44323D(); - if ( Book_PageBtn6_flag ) - viewparams->_443225(); - - if ( BtnUp_flag | BtnDown_flag | Book_PageBtn3_flag | Book_PageBtn4_flag | Book_PageBtn5_flag | Book_PageBtn6_flag ) - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); - BtnUp_flag = 0; - BtnDown_flag = 0; - Book_PageBtn6_flag = 0; - Book_PageBtn5_flag = 0; - Book_PageBtn4_flag = 0; - Book_PageBtn3_flag = 0; - DrawBook_Map_sub(97, 49, 361, 313, 0); - pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr); - map_window.uFrameWidth = game_viewport_width; - map_window.uFrameHeight = game_viewport_height; - map_window.uFrameX = game_viewport_x; - map_window.uFrameY = game_viewport_y; - map_window.uFrameZ = game_viewport_z; - map_window.uFrameW = game_viewport_w; - map_id = pMapStats->GetMapInfo(pCurrentMapName.data()); - if ( map_id ) - map_window.DrawTitleText(pBook2Font, -14, 12, ui_book_map_title_color, pMapStats->pInfos[map_id].pName, 3); - - map_window.uFrameX = 0; - sprintf(party_coord, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y); //"x: %d y: %d" - map_window.DrawTitleText(pFontComic, 0, 320, ui_book_map_coordinates_color, party_coord, 0); -} - -//----- (00442955) -------------------------------------------------------- -void DrawBook_Map_sub( unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074 ) - { - int v5; // ebx@1 - int v6; // edi@1 - BLVMapOutlines *v7; // eax@8 - unsigned __int8 v8; // zf@8 - unsigned __int8 v9; // sf@8 - int v10; // esi@10 - unsigned int v11; // edx@11 - __int16 v12; // cx@12 - signed int v13; // eax@15 - int v14; // eax@16 - Vec3_short_ *v15; // ecx@16 - int v16; // edx@16 - int v17; // ecx@16 - Vec3_short_ *v18; // eax@16 - int v19; // ecx@16 - int v20; // eax@16 - signed int v21; // esi@18 - int v22; // ecx@21 - BLVMapOutline *v23; // ecx@21 - Vec3_short_ *v24; // edx@21 - Vec3_short_ *v25; // eax@21 - int v26; // ecx@21 - unsigned __int16 *v27; // edi@21 - int v28; // edx@21 - int v29; // eax@21 - double v30; // st7@23 - signed __int64 v31; // qax@23 - unsigned short *v32; // edx@23 - int textr_width; // esi@23 - signed int v34; // eax@23 - signed int v35; // ecx@23 - int v36; // esi@27 - int v37; // ecx@27 - int v38; // edx@31 - unsigned int v39; // eax@33 - short *v40; // esi@33 - short *v41; // edi@33 - unsigned __int8 v42; // cf@33 - unsigned int v43; // ecx@33 - short *v44; // edi@33 - short *v45; // esi@33 - int v46; // ecx@33 - signed int v47; // esi@38 - signed int v48; // ecx@38 - int v49; // eax@38 - signed int v50; // edx@55 - unsigned int v51; // ecx@55 - int result; // eax@72 - int v53; // eax@75 - int v54; // esi@75 - int v55; // eax@75 - __int16 v56; // si@85 - double v57; // st7@85 - int v58; // ebx@85 - signed __int64 v59; // qax@85 - signed int v60; // edi@85 - signed __int64 v61; // qax@85 - signed int v62; // ebx@85 - signed int v63; // esi@85 - int v64; // eax@87 - unsigned int v65; // ebx@95 - unsigned short *v66; // edx@95 - unsigned __int16 *v67; // esi@96 - int v68; // edi@98 - unsigned __int16 v69; // cx@99 - unsigned int v70; // [sp-10h] [bp-48074h]@80 - unsigned int v71; // [sp-Ch] [bp-48070h]@80 - unsigned int v72; // [sp-8h] [bp-4806Ch]@80 - signed int v73; // [sp-4h] [bp-48068h]@59 - unsigned __int16 v74; // [sp-4h] [bp-48068h]@79 - unsigned short map_texture_16[147456]; // [sp+Ch] [bp-48058h]@23 - int v76; // [sp+4800Ch] [bp-58h]@23 - unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27 - unsigned __int16 *pPalette_16; // [sp+48014h] [bp-50h]@23 - unsigned int surfPitch; // [sp+48018h] [bp-4Ch]@1 - - int v81; // [sp+48020h] [bp-44h]@23 - unsigned __int16* render16_data; - unsigned char* texture8_data; - unsigned char* curr_line; - int scale_increment; - int scaled_posX; - int scaled_posY; - int stepX_r; - int stepY_r; - - - unsigned int teal; // [sp+48028h] [bp-3Ch]@8 - int v84; // [sp+4802Ch] [bp-38h]@1 - int screenCenter_X; // [sp+48030h] [bp-34h]@1 - int v86; // [sp+48034h] [bp-30h]@1 - int v87; // [sp+48038h] [bp-2Ch]@16 - unsigned int v88; // [sp+4803Ch] [bp-28h]@16 - int black; // [sp+48040h] [bp-24h]@8 - int screenCenterY; // [sp+48044h] [bp-20h]@1 - unsigned int i; // [sp+48048h] [bp-1Ch]@9 - unsigned int screenHeight; // [sp+4804Ch] [bp-18h]@16 - unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16 - signed int screenWidth; // [sp+48054h] [bp-10h]@8 - unsigned int v95; // [sp+48058h] [bp-Ch]@16 - int v96; // [sp+4805Ch] [bp-8h]@10 - const void *v97; // [sp+48060h] [bp-4h]@16 - unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85 - int a5a; // [sp+48070h] [bp+Ch]@86 - - tl_x = tl_x; - tl_y = tl_y; - screenCenter_X = (signed int)(tl_x + br_x) >> 1; - screenCenterY = (signed int)(tl_y + br_y) >> 1; - surfPitch = pRenderer->uTargetSurfacePitch; - pRenderer->SetRasterClipRect(tl_x, tl_y, br_x, br_y); - v5 = viewparams->field_2C; - v6 = viewparams->sViewCenterX; - v86 = viewparams->sViewCenterX; - v84 = viewparams->sViewCenterY; - if ( viewparams->field_2C != 384 ) - { - if ( viewparams->field_2C == 768 ) - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - v5 = 680; - } - } - else - { - v6 = viewparams->indoor_center_x; - v86 = viewparams->indoor_center_x; - v84 = viewparams->indoor_center_y; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - v5 = viewparams->field_2C - 34; - } - if ( uCurrentlyLoadedLevelType != LEVEL_Indoor) - { - screenWidth = br_x - tl_x + 1; - screenHeight = br_y - tl_y + 1; - render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch]; - texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask; - pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16; - scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / v5; - - v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2)); - - - teal = (unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16; - v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16); - - v32 = map_texture_16; - textr_width = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth; - stepY_r = (int)(signed __int64)((double)(- v84 - 22528 / (v5 / 384)+ 32768) / v30) << 16; - v81 = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30); - black = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30); - - v76 = textr_width; - scaled_posY = stepY_r >> 16; - //nearest neiborhood scaling - if ( texture8_data) - { - for(uint i=0; i<screenHeight;++i) - { - curr_line=&texture8_data[scaled_posY*textr_width]; - stepX_r=teal; - for(uint j=0; j<screenWidth;++j) - { - scaled_posX=stepX_r>>16; - map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)]; - stepX_r+=scale_increment; - } - stepY_r+=scale_increment; - scaled_posY=stepY_r>>16; - } - } - //move visible square to render - for(uint i=0; i<screenHeight;++i) - { - if ( screenWidth > 0 ) - { - memcpy((void*)&render16_data[surfPitch*i],(void*)&map_texture_16[i*screenWidth], screenWidth*2); - } - } - } - else - { - black = TargetColor(0, 0, 0); - teal = TargetColor(0, 0xFFu, 0xFFu); - v7 = pIndoor->pMapOutlines; - uNumBlueFacesInBLVMinimap = 0; - v8 = pIndoor->pMapOutlines->uNumOutlines == 0; - v9 = pIndoor->pMapOutlines->uNumOutlines < 0; - screenWidth = 0; - if ( !(v9 | v8) ) - { - i = 0; - do - { - v10 = (int)((char *)v7 + i + 4); - v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes; - if ( !(BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) )) - { - v12 = *(short *)((char *)v7 + i + 14); - if ( !(v12 & 1) ) - { - if ( !(!(v96 & 0x80) && (v11 & 0x80u) == 0 )) - { - v96 = (signed int)screenWidth >> 3; - v13 = screenWidth; - *(short *)(v10 + 10) = v12 | 1; - pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8); - } - } - if ( (!(v12 & 1) && !(!(v96 & 0x80) && (v11 & 0x80u) == 0 )) || v12 & 1) - { - v14 = *(short *)v10; - v88 = v5; - v15 = &pIndoor->pVertices[v14]; - v16 = v15->x; - v17 = v15->y - v84; - v93 = (unsigned __int16 *)(v16 - v6); - screenHeight = v17; - v18 = &pIndoor->pVertices[*(short *)(v10 + 2)]; - v19 = v18->x; - v20 = v18->y - v84; - v95 = v19 - v6; - v97 = (const void *)v20; - v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16; - v87 = (unsigned __int64)((signed int)screenHeight * (signed __int64)v5) >> 16; - v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16); - screenHeight = (unsigned __int64)(v20 * (signed __int64)v5) >> 16; - pRenderer->RasterLine2D( - screenCenter_X + v88, - screenCenterY - v87, - screenCenter_X + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16), - screenCenterY - screenHeight, - black); - v7 = pIndoor->pMapOutlines; - } - } - ++screenWidth; - i += 12; - } - while ( screenWidth < (signed int)v7->uNumOutlines ); - } - v21 = 0; - if ( (signed int)uNumBlueFacesInBLVMinimap > 0 ) - { - while ( 1 ) - { - v22 = pBlueFacesInBLVMinimapIDs[v21]; - v87 = v5; - v23 = &v7->pOutlines[v22]; - v24 = &pIndoor->pVertices[v23->uVertex1ID]; - v25 = &pIndoor->pVertices[v23->uVertex2ID]; - v26 = v25->x; - v27 = (unsigned __int16 *)(v24->x - v86); - v28 = v24->y - v84; - v29 = v25->y - v84; - v93 = v27; - screenHeight = v28; - v97 = (const void *)v29; - v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16; - v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16; - i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16; - v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16; - pRenderer->RasterLine2D( - screenCenter_X + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16), - screenCenterY - v88, - screenCenter_X + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16), - screenCenterY - v95, - teal); - ++v21; - if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap ) - break; - v7 = pIndoor->pMapOutlines; - } - v6 = v86; - } - } - v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 3; - v81 = pParty->vPosition.y - v84; - v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16); - v48 = 1; - v49 = screenCenterY - (int)v97 - 3; - if ( v47 >= (signed int)tl_x ) - { - if ( v47 > (signed int)br_x ) - { - if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 6) > (signed int)br_x ) - v48 = 0; - v47 = br_x; - } - } - else - { - if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X) < (signed int)tl_x ) - v48 = 0; - v47 = tl_x; - } - if ( v49 >= (signed int)tl_y ) - { - if ( v49 > br_y ) - { - if ( screenCenterY - (signed int)v97 - 6 > br_y ) - v48 = 0; - v49 = br_y; - } - } - else - { - if ( screenCenterY - (signed int)v97 < (signed int)tl_y ) - v48 = 0; - v49 = tl_y; - } - if ( v48 == 1 ) - { - v50 = 0; - v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask; - if ( (signed int)(pParty->sRotationY & stru_5C6E00->uDoublePiMask) >= 128 ) - { - if ( (signed int)v51 > 384 ) - { - if ( (signed int)v51 >= 640 ) - { - if ( (signed int)v51 > 896 ) - { - if ( (signed int)v51 >= 1152 ) - { - if ( (signed int)v51 > 1408 ) - { - if ( (signed int)v51 >= 1664 ) - { - if ( (signed int)v51 <= 1920 ) - v73 = 7; - } - else - { - v73 = 6; - } - } - else - { - v73 = 5; - } - } - else - { - v73 = 4; - } - } - else - { - v73 = 3; - } - } - else - { - v73 = 2; - } - if( (signed int)v51 <=1920) - v50 = v73; - } - else - v50 = 1; - } - pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50])); - } - result = TargetColor(0xFFu, 0xFFu, 0xFFu); - v95 = 0; - v86 = result; - if ( (signed int)uNumLevelDecorations > 0 ) - { - screenWidth = (unsigned int)&pLevelDecorations[0].vPosition; - do - { - if ( *(char *)(screenWidth - 2) & 8 ) - { - v53 = *(int *)(screenWidth + 4) - v84; - v93 = (unsigned __int16 *)(*(int *)screenWidth - v6); - screenHeight = v53; - v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X; - v97 = (const void *)((unsigned __int64)(v53 * (signed __int64)v5) >> 16); - v55 = screenCenterY - (int)v97; - if ( v54 >= pRenderer->raster_clip_x ) - { - if ( v54 <= pRenderer->raster_clip_z && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w ) - { - v74 = v86; - if ( v5 > 512 ) - { - v96 = v55 + 1; - black = v55 - 1; - pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, v86); - pRenderer->RasterLine2D(v54, black, v54, v96, v86); - ++v54; - v74 = v86; - v72 = v96; - v71 = v54; - v70 = black; - } - else - { - v72 = screenCenterY - (int)v97; - v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X; - v70 = screenCenterY - (int)v97; - } - pRenderer->RasterLine2D(v54, v70, v71, v72, v74); - } - } - } - ++v95; - result = v95; - screenWidth += 32; - } - while ( (signed int)v95 < (signed int)uNumLevelDecorations ); - } - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - screenCenterY = br_x - tl_x + 1; - v95 = br_y - tl_y + 1; - v77 = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch]; - v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2; - black = (1 << (v56 + 16)) / v5; - v57 = (double)(1 << (16 - v56)); - v58 = 22528 / (v5 / 384); - v59 = (signed __int64)((double)(v6 - v58 + 32768) / v57); - v60 = (int)v59 << 16; - v97 = (const void *)((int)v59 << 16); - v61 = (signed __int64)((double)(32768 - v58 - v84) / v57); - pPalette_16 = (unsigned __int16 *)(v60 >> 16); - v62 = (int)v61 << 16; - teal = v60 >> 16; - v63 = (signed __int16)v61; - a4a = map_texture_16; - result = TargetColor(0xCu, 0xCu, 0xCu); - screenCenter_X = 0; - for ( i = result; screenCenter_X < (signed int)v95; result = screenCenter_X ) - { - a5a = 0; - if ( screenCenterY > 0 ) - { - v96 = (v63 - 80) / 4; - v64 = teal; - do - { - v81 = (v64 - 80) / 4; - if ( !pOutdoor->_47F04C(v81, v96) ) - { - if ( pOutdoor->_47F097(v81, v96) ) - { - if ( !((a5a + screenCenter_X) % 2) ) - *a4a = i; - } - else - { - *a4a = 0; - } - } - ++a4a; - v97 = (char *)v97 + black; - v64 = (signed int)v97 >> 16; - ++a5a; - } - while ( a5a < screenCenterY ); - } - v62 += black; - v97 = (const void *)v60; - a4a += screenCenterY - a5a; - v63 = v62 >> 16; - ++screenCenter_X; - teal = (unsigned int)pPalette_16; - } - v65 = v95; - v66 = map_texture_16; - if ( (signed int)v95 > 0 ) - { - v67 = v77; - result = 2 * (surfPitch - screenCenterY); - do - { - if ( screenCenterY > 0 ) - { - v68 = screenCenterY; - do - { - v69 = *(short *)v66; - if ( !*(short *)v66 || v69 == (short)i ) - *v67 = v69; - ++v66; - ++v67; - --v68; - } - while ( v68 ); - } - v67 = (unsigned __int16 *)((char *)v67 + result); - --v65; - } - while ( v65 ); - } - } - } - - - - - -//----- (00412AF9) -------------------------------------------------------- -static void BookUI_Spellbook_DrawCurrentSchoolBackground() -{ - int v0; // ecx@1 - - v0 = 0; - if ( uActiveCharacter ) - v0 = pParty->pPlayers[uActiveCharacter - 1].lastOpenedSpellbookPage;//*((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2); - pRenderer->DrawTextureIndexed(8, 8, pSpellBookPagesTextr[v0]); - pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C); - pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448); -} - - - - - -//----- (00412B58) -------------------------------------------------------- -void DrawSpellBookContent(Player *player) -{ - //Player *v0; // ebx@1 - int v1; // ebp@1 - //unsigned int v2; // eax@1 - Texture *v3; // edi@1 - int v4; // esi@1 - Texture *v5; // eax@3 - Texture *v6; // edx@5 - int v7; // eax@8 - int v8; // eax@11 - POINT *v9; // esi@13 - int v10; // eax@13 - Texture *v11; // edx@14 - int v12; // eax@15 - signed int v13; // ecx@18 - unsigned int v14; // esi@18 - unsigned int v15; // edi@18 - Texture *pPageTexture; // eax@21 - unsigned int v17; // [sp-Ch] [bp-2Ch]@8 - unsigned int v18; // [sp-Ch] [bp-2Ch]@15 - unsigned int v19; // [sp-8h] [bp-28h]@8 - unsigned int v20; // [sp-8h] [bp-28h]@15 - Texture *v21; // [sp-4h] [bp-24h]@15 - signed int v22; // [sp-4h] [bp-24h]@22 - Texture *v23; // [sp+10h] [bp-10h]@5 - POINT a2; // [sp+18h] [bp-8h]@13 - POINT v24; - int v25; - - static unsigned int texture_tab_coord1[9][2]= - {{406, 9}, {406, 46}, {406, 84}, {406,121}, {407,158}, {405, 196}, {405, 234}, {405, 272}, {405,309} }; - - static unsigned int texture_tab_coord0[9][2]= - {{415, 10}, {415, 46}, {415, 83}, {415,121}, {415,158}, {416, 196}, {416, 234}, {416, 271}, {416,307} }; - - BookUI_Spellbook_DrawCurrentSchoolBackground(); - - //v0 = pPlayers[uActiveCharacter]; - v1 = 11 * player->lastOpenedSpellbookPage; - //v2 = pIcons_LOD->FindTextureByName("Pending"); - v3 = pIcons_LOD->GetTexture(pIcons_LOD->FindTextureByName("Pending")); - pRenderer->ClearZBuffer(0, 479); - v4 = 1; - if ( __OFSUB__(v1, v1 + 11) ^ 1 ) - { - do - { - if ( *(&player->_guilds_member_bits[v1 + 63] + v4) ) - { - v5 = (Texture *)dword_506408[v4]; - if ( v5 != v3 ) - { - if ( quick_spell_at_page == v4 ) - { - v6 = dword_5063D8[v4]; - v23 = dword_5063D8[v4]; - } - else - { - v23 = dword_506408[v4]; - v6 = v5; - } - if ( v6->pLevelOfDetail0_prolly_alpha_mask ) - { - v7 = player->lastOpenedSpellbookPage; - // v7 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]); - v19 = pViewport->uViewportTL_Y + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos; - v17 = pViewport->uViewportTL_X + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos; - if ( BYTE1(v6->pBits) & 2 ) - pRenderer->DrawTextureTransparent(v17, v19, v6); - else - pRenderer->DrawTextureIndexed(v17, v19, v6); - pRenderer->DrawMaskToZBuffer(pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos, - pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos, v23, v4); - } - } - } - ++v4; - } - while ( v4 - 1 < 11 ); - } - - - v9 = pMouse->GetCursorPos(&a2); - v10 = pRenderer->pActiveZBuffer[v9->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v24)->y]] & 0xFFFF; - if ( v10 ) - { - v11 = dword_5063D8[v10]; - if ( v11->pLevelOfDetail0_prolly_alpha_mask ) - { - v21 = dword_5063D8[v10]; - v12 = player->lastOpenedSpellbookPage; - // v12 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v10]); - v20 = pViewport->uViewportTL_Y + pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Ypos; - v18 = pViewport->uViewportTL_X + pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Xpos; - if ( BYTE1(v11->pBits) & 2 ) - pRenderer->DrawTextureTransparent(v18, v20, v21); - else - pRenderer->DrawTextureIndexed(v18, v20, v21); - } - } - v13 = 0; - a2.x = (LONG)&player->pActiveSkills[12]; - v14 = (unsigned int)&player->pActiveSkills[12]; - v15 = (unsigned int)&player->pActiveSkills[12]; - v25 = 0; - do - { - if ( *(short *)a2.x ) - { - if ( player->lastOpenedSpellbookPage == v13 ) - { - pPageTexture = pTextures_tabs[v13][1]; - v14=texture_tab_coord1[v13][0]; - v15=texture_tab_coord1[v13][1]; - } - else - { - pPageTexture = pTextures_tabs[v13][0]; - v14=texture_tab_coord0[v13][0]; - v15=texture_tab_coord0[v13][1]; - } - pRenderer->DrawTextureTransparent(v14, v15, pPageTexture); - v13 = v25; - } - a2.x += 2; - ++v13; - v25 = v13; - } - while ( v13 < 9 ); -} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UIBooks.h Fri Jul 05 21:16:12 2013 +0600 @@ -0,0 +1,13 @@ +#pragma once + + + +extern std::array<__int16, 6> pTownPortalBook_xs; +extern std::array<__int16, 6> pTownPortalBook_ys; +extern std::array<__int16, 6> pTownPortalBook_ws; +extern std::array<__int16, 6> pTownPortalBook_hs; +extern std::array<std::array<unsigned char, 12>, 9> pSpellbookSpellIndices; // 4E2430 from pSpellbookSpellIndices[9][12] +extern std::array<unsigned int, 5> pLloydsBeaconsPreviewXs; // 004E249C +extern std::array<unsigned int, 5> pLloydsBeaconsPreviewYs; +extern std::array<unsigned int, 5> pLloydsBeacons_SomeXs; +extern std::array<unsigned int, 5> pLloydsBeacons_SomeYs; // idb \ No newline at end of file
--- a/UI/UIHouses.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/UI/UIHouses.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -527,8 +527,7 @@ { if (!(pNPCStats->pNewNPCData[i].uFlags & 0x80)) { - - HouseNPCData[uNumDialogueNPCPortraits+1- (dword_591080 != 0) ? 1 : 0] = &pNPCStats->pNewNPCData[i]; + HouseNPCData[uNumDialogueNPCPortraits+1-((dword_591080 != 0) ? 1 : 0) ] = &pNPCStats->pNewNPCData[i]; npc_id_arr[uNumDialogueNPCPortraits] = pNPCStats->pNewNPCData[i].uPortraitID; ++uNumDialogueNPCPortraits; if ((pNPCStats->pNewNPCData[i].uFlags & 3) != 2)
--- a/Viewport.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/Viewport.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -255,39 +255,25 @@ { signed int v0; // ebx@2 POINT *v1; // esi@3 - signed int v2; // eax@9 - BLVFace *v3; // eax@10 - unsigned int v4; // eax@11 - unsigned __int16 v5; // dx@14 signed int v6; // eax@14 char *v7; // esi@15 - //int *v8; // eax@19 int v9; // eax@19 - unsigned int v10; // eax@19 - int v11; // ecx@21 - ODMFace *v12; // eax@22 - LevelDecoration *v13; // esi@24 - __int16 v14; // ax@25 + unsigned int pTextureID; // eax@19 + int pEventID; // ecx@21 int v15; // ecx@29 signed int v16; // edx@30 - Actor *v17; // esi@30 int v18; // ebx@47 - unsigned __int16 v19; // ax@50 - const char *v20; // eax@51 signed int v21; // eax@58 - ItemGen *v22; // esi@62 - unsigned int v23; // eax@62 SpriteObject a1; // [sp+Ch] [bp-80h]@1 - //POINT v25; // [sp+7Ch] [bp-10h]@3 POINT a2; // [sp+84h] [bp-8h]@3 + int clickable_distance = 512; + v1 = pMouse->GetCursorPos(&a2); if ( pRenderer->pRenderD3D ) v0 = pGame->pVisInstance->get_picked_object_zbuf_val(); else - { v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]]; - } if ( PID_TYPE(v0) == OBJECT_Item) { @@ -296,221 +282,424 @@ if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) && a2.y < 1000 && pSpriteObjects[v21].uObjectDescID && (unsigned int)v0 < 0x2000000 ) { - v22 = &pSpriteObjects[v21].stru_24; - v23 = pSpriteObjects[v21].stru_24.uItemID; - if ( pItemsTable->pItems[v23].uEquipType == 18 ) + if ( pItemsTable->pItems[pSpriteObjects[v21].stru_24.uItemID].uEquipType == 18 ) { - party_finds_gold(v22->uSpecEnchantmentType, 0); + party_finds_gold(pSpriteObjects[v21].stru_24.uSpecEnchantmentType, 0); viewparams->bRedrawGameUI = 1; } else { - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v23].pUnidentifiedName); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[v21].stru_24.uItemID].pUnidentifiedName); ShowStatusBarString(pTmpBuf2.data(), 2u); - if ( v22->uItemID == 506 ) - _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); - if ( v22->uItemID == 455 ) - _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); - if ( !pParty->AddItem(v22) ) - pParty->SetHoldingItem(v22); + if ( pSpriteObjects[v21].stru_24.uItemID == 506 ) + _449B7E_toggle_bit(pParty->_quest_bits, 184, 1); + if ( pSpriteObjects[v21].stru_24.uItemID == 455 ) + _449B7E_toggle_bit(pParty->_quest_bits, 185, 1); + if ( !pParty->AddItem(&pSpriteObjects[v21].stru_24) ) + pParty->SetHoldingItem(&pSpriteObjects[v21].stru_24); } SpriteObject::OnInteraction(a2.y); return; } - v4 = pParty->pPickedItem.uItemID; if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; + return; + __debugbreak();//no checker + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); + return; } - if ( PID_TYPE(v0) != OBJECT_Actor) + if ( PID_TYPE(v0) == OBJECT_Actor) { - if ( PID_TYPE(v0) == OBJECT_Decoration) + v16 = (signed int)(unsigned __int16)v0 >> 3; + a2.y = v16; + if ( pActors[v16].uAIState == 5 ) { - v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; - if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 ) - { - v4 = pParty->pPickedItem.uItemID; + if ( (unsigned int)v0 < 0x2000000 ) + { + stru_50C198.LootActor(&pActors[v16]); + return; + } + if ( !pParty->pPickedItem.uItemID ) + return; + __debugbreak();//no checker + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); + return; + } + if ( GetAsyncKeyState(VK_SHIFT) >= 0 ) + { + if ( !pActors[v16].GetActorsRelation(0) && !(BYTE2(pActors[v16].uAttributes) & 8) ) + { + if ( HIWORD(v0) >= clickable_distance) + { if ( !pParty->pPickedItem.uItemID ) return; - goto LABEL_14; - } - v14 = v13->field_16_event_id; - if ( !v14 ) - { - if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) + __debugbreak();//no checker + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); + return; + } + if ( !pActors[v16].CanAct() ) + return; + v18 = a2.y; + Actor::AI_FaceObject(a2.y, 4, 0, 0); + if ( !pActors[v16].sNPC_ID ) { - v15 = stru_5E4C90._decor_events[v13->_idx_in_stru123 - 75] + 380; - activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; - EventProcessor(v15, 0, 1); - activeLevelDecoration = NULL; + if ( pNPCStats->pGroups_copy[pActors[v16].uGroup] ) + { + if ( pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[v16].uGroup]] ) + { + pParty->uFlags |= 2u; + strcpy(byte_5B0938.data(), pNPCStats->pCatchPhrases[pNPCStats->pGroups_copy[pActors[v16].uGroup]]); + sub_4451A8_press_any_key(0, 0, 0); + } + } + return; } + pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0); return; } - v11 = v14; + if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) + { + pTurnEngine->field_18 |= TE_FLAG_8; + return; + } + pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); } else { - if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= 512 ) - { - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; - } - v2 = PID_ID(v0); - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) { - v3 = &pIndoor->pFaces[v2]; - if ( !(v3->uAttributes & 0x2000000) ) - { -LABEL_11: - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - { - ShowNothingHereStatus(); - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - } -LABEL_14: - v5 = pItemsTable->pItems[v4].uSpriteID; - v6 = 0; - a1.uType = v5; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - LOWORD(v6) = 0; - else - { - v7 = (char *)&pObjectList->pObjects->uObjectID; - while ( v5 != *(short *)v7 ) - { - ++v6; - v7 += 56; - if ( v6 >= (signed int)pObjectList->uNumObjects ) - { - LOWORD(v6) = 0; - break; - } - } - } - a1.uObjectDescID = v6; - a1.vPosition.y = pParty->vPosition.y; - a1.spell_caster_pid = OBJECT_Player; - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; - a1.uSoundID = 0; - a1.uFacing = 0; - a1.uAttributes = 8; - a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); - a1.uSpriteFrameID = 0; - memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); - - extern int UnprojectX(int); - v9 = UnprojectX(v1->x); - a1.Create(pParty->sRotationY + v9, 184, 200, 0); - v10 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); - if (v10 != -1) - pIcons_LOD->pTextures[v10].Release(); - pMouse->RemoveHoldingItem(); - pIcons_LOD->SyncLoadedFilesCount(); - return; - } - v11 = pIndoor->pFaceExtras[v3->uFaceExtraID].uEventID; + pParty->uFlags |= PARTY_FLAGS_1_FALLING; + return; } - else - { - v12 = &pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[v2 & 0x3F]; - if ( !v12->Clickable()) - goto LABEL_11; - v11 = v12->sCogTriggeredID; - } + if ( uActiveCharacter && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell)) + pMessageQueue_50CBD0->AddMessage(UIMSG_CastQuickSpell, 0, 0); } - EventProcessor(v11, (unsigned __int16)v0, 1); return; } - v16 = (signed int)(unsigned __int16)v0 >> 3; - a2.y = v16; - v17 = &pActors[v16]; - if ( v17->uAIState == 5 ) + if ( PID_TYPE(v0) == OBJECT_Decoration) { - if ( (unsigned int)v0 < 0x2000000 ) + if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uDecorationDescID].uRadius) >= clickable_distance ) { - stru_50C198.LootActor(&pActors[v16]); + if ( !pParty->pPickedItem.uItemID ) + return; + __debugbreak();//no checker + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); return; } - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; + if ( !pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].field_16_event_id ) + { + if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) + { + v15 = stru_5E4C90._decor_events[pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]._idx_in_stru123 - 75] + 380; + activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; + EventProcessor(v15, 0, 1); + activeLevelDecoration = NULL; + } + return; + } + pEventID = pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].field_16_event_id; } - if ( GetAsyncKeyState(VK_SHIFT) >= 0 ) + if ( PID_TYPE(v0) == OBJECT_BModel && HIWORD(v0) < clickable_distance) { - if ( !v17->GetActorsRelation(0) && !(BYTE2(v17->uAttributes) & 8) ) + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { - if ( HIWORD(v0) >= 512) - { - v4 = pParty->pPickedItem.uItemID; + if ( !(pIndoor->pFaces[PID_ID(v0)].uAttributes & 0x2000000) ) + { + if ( !pParty->pPickedItem.uItemID ) + { + ShowNothingHereStatus(); if ( !pParty->pPickedItem.uItemID ) return; - goto LABEL_14; - } - if ( !v17->CanAct() ) - return; - v18 = a2.y; - Actor::AI_FaceObject(a2.y, 4u, 0, 0); - if ( !v17->sNPC_ID ) - { - v19 = pNPCStats->pGroups_copy[v17->uGroup]; - if ( v19 ) + } + __debugbreak();//no checker + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else { - v20 = pNPCStats->pCatchPhrases[v19]; - if ( v20 ) + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) { - pParty->uFlags |= 2u; - strcpy(byte_5B0938.data(), v20); - sub_4451A8_press_any_key(0, 0, 0); + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } } } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); return; } - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) - return; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_StartNPCDialogue; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v18; -LABEL_42: - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - return;*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0); - return; + pEventID = pIndoor->pFaceExtras[pIndoor->pFaces[PID_ID(v0)].uFaceExtraID].uEventID; } - if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) - { - pTurnEngine->field_18 |= 8u; - return; - } - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Attack; - goto LABEL_41; - }*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); + if ( !pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].Clickable()) + { + if ( !pParty->pPickedItem.uItemID ) + { + ShowNothingHereStatus(); + if ( !pParty->pPickedItem.uItemID ) + return; + } + __debugbreak();//no checker + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); + return; + } + pEventID = pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[PID_ID(v0) & 0x3F].sCogTriggeredID; + } + EventProcessor(pEventID, (unsigned __int16)v0, 1); + return; } - else + if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= clickable_distance ) { - if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) - { - pParty->uFlags |= PARTY_FLAGS_1_FALLING; + if ( !pParty->pPickedItem.uItemID ) return; - } - if ( uActiveCharacter - && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell)) + __debugbreak();//no checker + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else { - pMessageQueue_50CBD0->AddMessage(UIMSG_CastQuickSpell, 0, 0); - /*&& (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CastQuickSpell; -LABEL_41: - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - goto LABEL_42;*/ + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (pTextureID != -1) + pIcons_LOD->pTextures[pTextureID].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); + return; } }
--- a/Vis.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/Vis.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -133,7 +133,8 @@ { if (v13 == -1) v13 = i; - else if ((unsigned int)pBillboardRenderList[billboard->uParentBillboardID].sZValue < pBillboardRenderList[pRenderer->pBillboardRenderListD3D[v13].uParentBillboardID].sZValue) + else if ((unsigned int)pBillboardRenderList[billboard->uParentBillboardID].sZValue < + pBillboardRenderList[pRenderer->pBillboardRenderListD3D[v13].uParentBillboardID].sZValue) v13 = i; } } @@ -421,9 +422,9 @@ v8.object_type = VisObjectType_Sprite; v8.object_id = object_id; - v8.field_8 = a6; - v8.field_C = a5; - v8.field_10 = a4; + v8.at_ai_state = a6; + v8.no_at_ai_state = a5; + v8.select_flags = a4; Vis_static_sub_4C1944_stru_F8BDE8.uNumPointers = 0; PickBillboards_Keyboard(pick_depth, &Vis_static_sub_4C1944_stru_F8BDE8, &v8); Vis_static_sub_4C1944_stru_F8BDE8.create_object_pointers(Vis_SelectionList::Unique); @@ -731,7 +732,9 @@ } //----- (004C1EE5) -------------------------------------------------------- -void Vis::BLV_CreateIntersectFacesVertexCoordList(int *a, int *b, __int16 *intersect_face_vertex_coords_list_a, __int16 *intersect_face_vertex_coords_list_b, Vec3_short_ *IntersectPoint, BLVFace *pFace) +void Vis::BLV_CreateIntersectFacesVertexCoordList(int *a, int *b, __int16 *intersect_face_vertex_coords_list_a, + __int16 *intersect_face_vertex_coords_list_b, + Vec3_short_ *IntersectPoint, BLVFace *pFace) { if (pFace->uAttributes & FACE_XY_PLANE) { @@ -779,7 +782,9 @@ } //----- (004C2186) -------------------------------------------------------- -void Vis::ODM_CreateIntersectFacesVertexCoordList(int *a, int *b, __int16 *intersect_face_vertex_coords_list_a, __int16 *intersect_face_vertex_coords_list_b, Vec3_short_ *IntersectPoint, BLVFace *pFace, unsigned int uModelID) +void Vis::ODM_CreateIntersectFacesVertexCoordList(int *a, int *b, __int16 *intersect_face_vertex_coords_list_a, + __int16 *intersect_face_vertex_coords_list_b, + Vec3_short_ *IntersectPoint, BLVFace *pFace, unsigned int uModelID) { if (pFace->uAttributes & FACE_XY_PLANE) { @@ -894,8 +899,8 @@ v11[1].vWorldPosition.y = (double)pIndoorCamera->pos.y; v11[1].vWorldPosition.z = (double)pIndoorCamera->pos.z; - memcpy(pRay, &v11[1], 0x30u); - memcpy(&pRay[1], v11, sizeof(pRay[1])); + memcpy(pRay, &v11[1], sizeof(RenderVertexSoft)); + memcpy(&pRay[1], &v11[0], sizeof(RenderVertexSoft)); } //----- (004C2551) -------------------------------------------------------- @@ -915,7 +920,7 @@ return &this->object_pool[i]; } } - return false; + return nullptr; /*v4 = 0; if ( this->uNumPointers <= 0 ) return false; @@ -973,58 +978,62 @@ } //----- (004C264A) -------------------------------------------------------- -void Vis::sort_object_pointers(Vis_ObjectInfo **pPointers, int left, int right) -{ - int v4; // edx@1 - int v5; // ebx@1 - int v6; // esi@2 - signed int i; // ecx@2 - int v8; // eax@3 - int v9; // ebx@4 - int v10; // ebx@6 - Vis_ObjectInfo *v11; // eax@7 +void Vis::sort_object_pointers( Vis_ObjectInfo **pPointers, int start, int end ) + { + int sort_start; // edx@1 + int forward_sort_index; // esi@2 + signed int backward_sort_index; // ecx@2 + unsigned int last_z_val; // eax@3 + unsigned int more_lz_val; // ebx@4 + unsigned int less_lz_val; // ebx@6 + Vis_ObjectInfo *temp_pointer; // eax@7 Vis_ObjectInfo *a3a; // [sp+14h] [bp+Ch]@2 - v4 = left; - v5 = right; - if ( right > left ) + sort_start = start; + + if ( end > start ) { do { - v6 = v4 - 1; - a3a = pPointers[v5]; - for ( i = v5; ; pPointers[i] = v11 ) + forward_sort_index = sort_start - 1; + backward_sort_index = end; + do { - v8 = a3a->sZValue; - LOWORD(v8) = 0; + last_z_val = pPointers[end]->sZValue&0xFFFF0000; do { - ++v6; - v9 = pPointers[v6]->sZValue; - LOWORD(v9) = 0; + ++forward_sort_index; + more_lz_val = pPointers[forward_sort_index]->sZValue&0xFFFF0000; } - while ( v9 < (unsigned int)v8 ); + while ( more_lz_val < last_z_val ); + do { - if ( i < 1 ) + if ( backward_sort_index < 1 ) break; - --i; - v10 = pPointers[i]->sZValue; - LOWORD(v10) = 0; + --backward_sort_index; + less_lz_val = pPointers[backward_sort_index]->sZValue&0xFFFF0000; } - while ( v10 > (unsigned int)v8 ); - v11 = pPointers[v6]; - if ( v6 >= i ) - break; - pPointers[v6] = pPointers[i]; - } - v5 = right; - pPointers[v6] = pPointers[right]; - pPointers[right] = v11; - sort_object_pointers(pPointers, v4, v6 - 1); - v4 = v6 + 1; + while ( less_lz_val > last_z_val ); + + temp_pointer = pPointers[forward_sort_index]; + if ( forward_sort_index >= backward_sort_index ) + { + pPointers[forward_sort_index] = pPointers[end]; + pPointers[end] = temp_pointer; + } + else + { + pPointers[forward_sort_index] = pPointers[backward_sort_index]; + pPointers[backward_sort_index] = temp_pointer; + } + + } while ( forward_sort_index < backward_sort_index ); + + sort_object_pointers(pPointers, sort_start, forward_sort_index - 1); + sort_start = forward_sort_index + 1; } - while ( right > v6 + 1 ); + while ( end > forward_sort_index + 1 ); } } @@ -1403,7 +1412,7 @@ case VisObjectType_Sprite: { - v5 = filter->field_10; + v5 = filter->select_flags; int object_idx = PID_ID(pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid); int object_type = PID_TYPE(pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid); if ( v5 & 2 ) @@ -1436,11 +1445,11 @@ v10 = &pActors[object_idx]; int result = 1 << LOBYTE(v10->uAIState); - if ( result & filter->field_C - || !(result & filter->field_8) + if ( result & filter->no_at_ai_state + || !(result & filter->at_ai_state) || v5 & 8 && (result = MonsterStats::BelongsToSupertype(v10->pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD)) == 0 ) return false; - if ( !(filter->field_10 & 1) ) + if ( !(filter->select_flags & 1) ) return true; result = v10->GetActorsRelation(nullptr); @@ -1472,9 +1481,9 @@ if (filter->object_id != OBJECT_BLVDoor) return true; - if (no_event || face_attrib & filter->field_C) + if (no_event || face_attrib & filter->no_at_ai_state) return false; - return (face_attrib & filter->field_8) != 0; + return (face_attrib & filter->at_ai_state) != 0; } default: @@ -1515,31 +1524,32 @@ struct RenderVertexSoft pPickingRay[2]; //int v31; // [sp+20h] [bp-DCh]@5 struct RenderVertexSoft local_80[2]; - //int v32; // [sp+80h] [bp-7Ch]@22 - float v33; // [sp+E0h] [bp-1Ch]@33 - float v34; // [sp+E4h] [bp-18h]@32 - int v35; // [sp+E8h] [bp-14h]@5 - int v36; // [sp+ECh] [bp-10h]@5 + + float test_x; + float test_y; + + float t1_x; + float t1_y; + float t2_x; + float t2_y; + float swap_temp; int v37; // [sp+F0h] [bp-Ch]@5 - float v38; // [sp+F4h] [bp-8h]@17 - //void *v39; // [sp+F8h] [bp-4h]@1 + signed int v40; // [sp+108h] [bp+Ch]@17 - float v41; // [sp+108h] [bp+Ch]@32 + static Vis_SelectionList Vis_static_stru_F91E10; Vis_static_stru_F91E10.uNumPointers = 0; v3 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].uParentBillboardID; if (v3 == -1) return false; + if (pBillboardRenderList[v3].GetFloatZ() > fDepth) - { -LABEL_49: return false; - } + - v37 = pBillboardRenderList[v3].sZValue & 0xFFFF0000; - GetPolygonCenter(pRenderer->pBillboardRenderListD3D[v3].pQuards, 4, (float *)&v35, (float *)&v36); - CastPickRay(pPickingRay, *(float *)&v35, *(float *)&v36, fDepth); + GetPolygonCenter(pRenderer->pBillboardRenderListD3D[v3].pQuards, 4, &test_x, &test_y); + CastPickRay(pPickingRay, test_x, test_y, fDepth); if (uCurrentlyLoadedLevelType == LEVEL_Indoor) PickIndoorFaces_Mouse(fDepth, pPickingRay, &Vis_static_stru_F91E10, &vis_face_filter); else @@ -1549,95 +1559,82 @@ if (Vis_static_stru_F91E10.uNumPointers) { if (Vis_static_stru_F91E10.object_pointers[0]->actual_z > pBillboardRenderList[v3].actual_z) - return 1; + return true; } - else if ((double)(pViewport->uScreen_TL_X) <= *(float *)&v35 && - (double)pViewport->uScreen_BR_X >= *(float *)&v35 && - (double)pViewport->uScreen_TL_Y <= *(float *)&v36 && - (double)pViewport->uScreen_BR_Y >= *(float *)&v36) - return 1; - v40 = 0; - v10 = (int)&pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y; - LODWORD(v38) = (int)&pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y; - while ( 1 ) - { - v12 = *(float *)(v10 - 4); - v11 = *(float *)v10; - v13 = *(float *)(v10 - 4); - Vis_static_stru_F91E10.uNumPointers = 0; - if ( v13 >= (double)(pViewport->uScreen_TL_X)) + else if ((double)(pViewport->uScreen_TL_X) <= test_x && + (double)pViewport->uScreen_BR_X >= test_x && + (double)pViewport->uScreen_TL_Y <= test_y && + (double)pViewport->uScreen_BR_Y >= test_y) + return true; + + for (v40 = 0; v40 < 4; ++v40) { - if ( v12 <= (double)pViewport->uScreen_BR_X ) - { - if ( v11 >= (double)pViewport->uScreen_TL_Y ) + test_x=pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[v40].pos.x; + test_y= pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[v40].pos.y; + if ((double)(pViewport->uScreen_TL_X) <= test_x && + (double)pViewport->uScreen_BR_X >= test_x && + (double)pViewport->uScreen_TL_Y <= test_y && + (double)pViewport->uScreen_BR_Y >= test_y) { - if ( v11 <= (double)pViewport->uScreen_BR_Y ) - { - v14 = v11; - v15 = v12; - CastPickRay(local_80, SLODWORD(v15), v14, fDepth); - if ( uCurrentlyLoadedLevelType == 1 ) - PickIndoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter); - else - PickOutdoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter, false); - Vis_static_stru_F91E10.create_object_pointers(); - sort_object_pointers(Vis_static_stru_F91E10.object_pointers, 0, Vis_static_stru_F91E10.uNumPointers - 1); - if ( !Vis_static_stru_F91E10.uNumPointers ) - break; - else - { - //v18 = Vis_static_stru_F91E10.uNumPointers <= 0 ? 0 : (int); - //v19 = *(_DWORD *)(v18 + 4); - //LOWORD(v19) = 0; - if (Vis_static_stru_F91E10.object_pointers[0]->actual_z > pBillboardRenderList[v3].actual_z) - break; - } - } + CastPickRay(local_80, test_x, test_y, fDepth); + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + PickIndoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter); + else + PickOutdoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter, false); + Vis_static_stru_F91E10.create_object_pointers(); + sort_object_pointers(Vis_static_stru_F91E10.object_pointers, 0, Vis_static_stru_F91E10.uNumPointers - 1); + if ( !Vis_static_stru_F91E10.uNumPointers ) + return true; + if (Vis_static_stru_F91E10.object_pointers[0]->actual_z > pBillboardRenderList[v3].actual_z) + return true; } - } + } - ++v40; - v10 = LODWORD(v38) + 32; - LODWORD(v38) += 32; + if ( v40 >= 4 ) { - if ( uCurrentlyLoadedLevelType != 2 ) + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) return false; - v21 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.x; - v20 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[3].pos.x; - v22 = *(int *)(&pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y); - v34 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[3].pos.x; - LODWORD(v38) = v22; - v41 = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[1].pos.y; - if ( v21 > v20 ) + t1_x = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.x; + t2_x = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[3].pos.x; + + t1_y = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y; + t2_y = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[1].pos.y; + if ( t1_x > t2_x ) { - v33 = v21; - v21 = v34; - v20 = v33; + swap_temp = t1_x; + t1_x = t2_x; + t2_x = swap_temp; } - if ( v38 > (double)v41 ) - v41 = v38; + if ( t1_y > t2_y ) + test_y = t1_y; + else + test_y = t2_y; + Vis_static_stru_F91E10.uNumPointers = 0; - v23 = (v20 - v21) * 0.5; - if ( v23 < (double)(pViewport->uScreen_TL_X) - || v23 > (double)pViewport->uScreen_BR_X - || (double)pViewport->uScreen_TL_Y > v41 - || (double)pViewport->uScreen_BR_Y < v41 - || ((v25 = v23, CastPickRay(local_80, SLODWORD(v25), v41, fDepth), uCurrentlyLoadedLevelType != 1) ? - (PickOutdoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter, false)) : - (PickIndoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter)), - (Vis_static_stru_F91E10.create_object_pointers(), - sort_object_pointers(Vis_static_stru_F91E10.object_pointers, 0, Vis_static_stru_F91E10.uNumPointers - 1), - Vis_static_stru_F91E10.uNumPointers) - && (Vis_static_stru_F91E10.uNumPointers <= 0 ? (v28 = 0) : (v28 = (int)Vis_static_stru_F91E10.object_pointers), - v29 = *(_DWORD *)(v28 + 4), - LOWORD(v29) = 0, - v29 <= v37)) ) - return false; - break; - } + + test_x = (t2_x - t1_x) * 0.5; + if ((double)(pViewport->uScreen_TL_X) <= test_x && + (double)pViewport->uScreen_BR_X >= test_x && + (double)pViewport->uScreen_TL_Y <= test_y && + (double)pViewport->uScreen_BR_Y >= test_y) + { + CastPickRay(local_80, test_x, test_y, fDepth); + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + PickIndoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter); + else + PickOutdoorFaces_Mouse(fDepth, local_80, &Vis_static_stru_F91E10, &vis_face_filter, false); + Vis_static_stru_F91E10.create_object_pointers(); + sort_object_pointers(Vis_static_stru_F91E10.object_pointers, 0, Vis_static_stru_F91E10.uNumPointers - 1); + if ( !Vis_static_stru_F91E10.uNumPointers ) + return true; + if (Vis_static_stru_F91E10.object_pointers[0]->actual_z > pBillboardRenderList[v3].actual_z) + return true; + + } + } - return true; + return false; } // F93E18: using guessed type char static_byte_F93E18_init;
--- a/Vis.h Fri Jul 05 21:15:53 2013 +0600 +++ b/Vis.h Fri Jul 05 21:16:12 2013 +0600 @@ -16,9 +16,9 @@ { VisObjectType object_type; int object_id; // OBJECT_Actor, OBJECT_Player etc - int field_8; - int field_C; - int field_10; + int at_ai_state; + int no_at_ai_state; + int select_flags; }; #pragma pack(pop) extern Vis_SelectionFilter vis_sprite_filter_1; // 00F93E1C @@ -116,7 +116,7 @@ void BLV_CreateIntersectFacesVertexCoordList(int *a, int *b, __int16 *intersect_face_vertex_coords_list_a, __int16 *intersect_face_vertex_coords_list_b, Vec3_short_ *IntersectPoint, BLVFace *pFace); void ODM_CreateIntersectFacesVertexCoordList(int *a, int *b, __int16 *intersect_face_vertex_coords_list_a, __int16 *intersect_face_vertex_coords_list_b, Vec3_short_ *IntersectPoint, BLVFace *pFace, unsigned int uModelID); void CastPickRay(RenderVertexSoft *pRay, float fMouseX, float fMouseY, float fPickDepth); - void sort_object_pointers(Vis_ObjectInfo **pPointers, int left, int right); + void sort_object_pointers(Vis_ObjectInfo **pPointers, int start, int end); bool SortVerticesByX(struct RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd); bool SortVerticesByY(struct RenderVertexD3D3 *a2, unsigned int uStart, unsigned int uEnd); bool SortByScreenSpaceX(struct RenderVertexSoft *pArray, int sLeft, int sRight);
--- a/Weather.h Fri Jul 05 21:15:53 2013 +0600 +++ b/Weather.h Fri Jul 05 21:16:12 2013 +0600 @@ -2,21 +2,10 @@ #pragma pack(push, 1) -struct LocationTime_stru1 - { - unsigned __int64 uLastVisitDay; - char sky_texture_name[12]; - int day_attrib; - int day_fogrange_1; - int day_fogrange_2; - char field_2F4[24]; - }; -#pragma pack(pop) /* 255 */ -#pragma pack(push, 1) struct Weather { inline Weather():
--- a/mm7_2.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/mm7_2.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -6152,7 +6152,7 @@ assert(sizeof(GUIWindow) == 0x54); assert(sizeof(GUIProgressBar) == 0x1B8); assert(sizeof(GUIFont) == 0x1020); - assert(sizeof(stru262_TurnBased) == 0x40); + // assert(sizeof(stru262_TurnBased) == 0x40); assert(sizeof(ArcomageGame) == 0xFB); assert(sizeof(CastSpellInfo) == 0x14); assert(sizeof(ArcomageCard) == 0x6C); @@ -7583,7 +7583,7 @@ v127 = v9; v126 = v124; LABEL_268: - v116 = word_4EE088_sound_ids[v2->spell_id]; + v116 = word_4EE088_sound_ids[v2->spell_id - 1]; LABEL_269: v125 = v116 + 1; goto LABEL_29;
--- a/mm7_3.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/mm7_3.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -4,7 +4,7 @@ #include <assert.h> - +#include "Weather.h" #include "Texture.h" #include "mm7_data.h" #include "Sprites.h" @@ -7452,17 +7452,16 @@ } //----- (004811A3) -------------------------------------------------------- -void stru148::_4811A3() -{ - __debugbreak(); - - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0)); +void stru148::DrawBorderTiles() +{ + //__debugbreak(); + + pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false); pRenderer->DrawTerrainPolygon(uNumVertices, this, - pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_tile_id]], - 0, 0); - - ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1)); - pRenderer->DrawTerrainPolygon(uNumVertices, this, pBitmaps_LOD->pHardwareTextures[uTileBitmapID], 1, 1); + pBitmaps_LOD->pHardwareTextures[pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]], false, true); + + pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, true); + //pRenderer->DrawTerrainPolygon(uNumVertices, this, pBitmaps_LOD->pHardwareTextures[uTileBitmapID], true, true); } //----- (00481DB2) -------------------------------------------------------- @@ -12418,368 +12417,3 @@ return pCosTable[v2]; } -//----- (00404544) -------------------------------------------------------- -signed int stru262_TurnBased::_404544() -{ - stru262_TurnBased *v1; // ebx@1 - TurnBased_QueueElem *v2; // esi@2 - Actor *v3; // edi@4 - Actor *v4; // ecx@4 - Player *v5; // eax@7 - int v6; // ecx@15 - TurnBased_QueueElem *v7; // eax@16 - TurnBased_QueueElem *v8; // ecx@18 - int v9; // edx@19 - int v10; // esi@19 - int v11; // esi@21 - int v12; // ST0C_4@25 - int v13; // ST10_4@25 - int v14; // ST14_4@25 - int v15; // ST18_4@25 - signed int result; // eax@28 - TurnBased_QueueElem *v17; // edi@32 - int v18; // [sp+20h] [bp-Ch]@17 - int v19; // [sp+24h] [bp-8h]@1 - int v20; // [sp+28h] [bp-4h]@1 - signed int v21; // [sp+28h] [bp-4h]@16 - int v22; // [sp+28h] [bp-4h]@31 - - v20 = 0; - v1 = this; - v19 = this->uActorQueueSize; - if ( this->uActorQueueSize > 0 ) - { - v2 = this->pQueue; - do - { - if ( PID_TYPE(v2->uPackedID) == OBJECT_Actor ) - { - v3 = &pActors[PID_ID(v2->uPackedID)]; - v4 = &pActors[PID_ID(v2->uPackedID)]; - LOBYTE(v4->uAttributes) |= 0x80u; - if ( !v4->CanAct() ) - { - --v19; - v2->field_4 = 1001; - LOBYTE(v3->uAttributes) &= 0x7Fu; - } - } - if ( PID_TYPE(v2->uPackedID) == OBJECT_Player) - { - v5 = &pParty->pPlayers[v2->uPackedID >> 3]; - if ( v5->pConditions[14] - || v5->pConditions[16] - || v5->pConditions[15] - || v5->pConditions[13] - || v5->pConditions[12] - || v5->pConditions[2] ) - { - --v19; - v2->field_4 = 1001; - } - } - ++v20; - ++v2; - } - while ( v20 < v1->uActorQueueSize ); - } - v6 = v1->uActorQueueSize; - if ( v6 > 0 ) - { - v21 = 1; - v7 = v1->pQueue; - do - { - v18 = v21; - if ( v21 < v6 ) - { - v8 = v7 + 1; - do - { - v9 = v8->field_4; - v10 = v7->field_4; - if ( v9 < v10 - || v9 == v10 - && ((v11 = PID_TYPE(v8->uPackedID), v11 == OBJECT_Player) && PID_TYPE(v7->uPackedID) == OBJECT_Actor - || v11 == PID_TYPE(v7->uPackedID) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) - { - v12 = v7->uPackedID; - v13 = v7->field_4; - v14 = v7->uActionLength; - v15 = v7->field_C; - v7->uPackedID = v8->uPackedID; - v7->field_4 = v8->field_4; - v7->uActionLength = v8->uActionLength; - v7->field_C = v8->field_C; - v8->uPackedID = v12; - v8->field_4 = v13; - v8->uActionLength = v14; - v8->field_C = v15; - } - ++v18; - ++v8; - } - while ( v18 < v1->uActorQueueSize ); - } - ++v21; - v6 = v1->uActorQueueSize; - ++v7; - } - while ( v21 - 1 < v6 ); - } - v1->uActorQueueSize = v19; - result = v1->pQueue[0].uPackedID; - if ( PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) - { - result = PID_ID(result) + 1; - uActiveCharacter = result; - v1->field_18 |= 4u; - } - else - { - uActiveCharacter = 0; - v1->field_18 &= 0xFFFFFFFBu; - } - v22 = 0; - if ( v1->uActorQueueSize > 0 ) - { - v17 = v1->pQueue; - do - { - if ( PID_TYPE(v17->uPackedID) == OBJECT_Player) - pParty->pPlayers[PID_ID(v17->uPackedID)].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); - ++v22; - ++v17; - result = v22; - } - while ( v22 < v1->uActorQueueSize ); - } - return result; -} - -//----- (0040471C) -------------------------------------------------------- -void stru262_TurnBased::_40471C() -{ - if ( pParty->bTurnBasedModeOn == 1 ) - { - if ( pTurnEngine->field_4 == 2 ) - _406457(0); - } -} - -//----- (004059DB) -------------------------------------------------------- -signed int stru262_TurnBased::Start() -{ - //stru262_TurnBased *v1; // ebx@1 - unsigned int v2; // edi@1 - int v3; // esi@1 - int v4; // eax@5 - unsigned int v5; // esi@7 - Actor *pActor; // edi@7 - unsigned int v7; // eax@9 - unsigned int v8; // edx@10 - unsigned __int8 v9; // zf@14 - unsigned __int8 v10; // sf@14 - unsigned __int8 v11; // of@14 - char *v12; // esi@15 - int v13; // ecx@16 - unsigned __int16 v14; // ax@17 - int v15; // ecx@18 - signed __int64 v16; // qax@19 - int v17; // edx@22 - unsigned int v18; // esi@27 - char *v19; // esi@32 - int v20; // edx@33 - char *v21; // eax@33 - int v22; // ecx@33 - int v23; // eax@34 - char *v24; // eax@34 - char *v25; // ecx@34 - int v26; // edx@34 - int v27; // eax@38 - int v28; // ecx@38 - AIDirection v30; // [sp+Ch] [bp-68h]@10 - AIDirection v31; // [sp+28h] [bp-4Ch]@10 - AIDirection a3; // [sp+44h] [bp-30h]@10 - int v33; // [sp+60h] [bp-14h]@10 - int *v34; // [sp+64h] [bp-10h]@6 - int v35; // [sp+68h] [bp-Ch]@5 - Player *pPlayer; // [sp+6Ch] [bp-8h]@1 - int v40b; - unsigned int v37; // [sp+70h] [bp-4h]@7 - - pTurnEngine->field_18 &= 0xFFFFFFFDu; - //v1 = this; - pEventTimer->TrackGameTime(); - pAudioPlayer->StopChannels(-1, -1); - v2 = 0; - pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|SOUND_EnteringAHouse|0x1), 0, 0, -1, 0, 0, 0, 0); - pPlayer = pParty->pPlayers; - dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength; - dword_50C994 = 0; - this->field_10 = 100; - this->field_0 = 0; - this->field_8 = 64; - this->field_4 = 1; - this->uActorQueueSize = 0; - v3 = 0; - do - { - if ( pPlayer->CanAct() ) - { - *(&this->field_0 + 4 * (this->uActorQueueSize + 2)) = PID(OBJECT_Player,v3); - this->pQueue[this->uActorQueueSize].field_C = 2; - this->pQueue[this->uActorQueueSize].uActionLength = 0; - pParty->pTurnBasedPlayerRecoveryTimes[this->uActorQueueSize++] = 0; - } - ++pPlayer; - ++v3; - } - while ( pPlayer <= &pParty->pPlayers[3] ); - v35 = this->uActorQueueSize; - v4 = v35; - v40b = v35; - if ( v40b < v40b + ai_arrays_size ) - { - v34 = (int *)ai_near_actors_ids.data(); - do - { - v37 = *v34; - v5 = v37; - pActor = &pActors[v37]; - if ( v37 != 10 ) - { - if ( pActors[v37].CanAct() ) - { - v7 = pActor->uAttributes; - if ( v7 & 0x8000 ) - { - v8 = ai_near_actors_targets_pid[v5]; - LOBYTE(v7) = v7 | 0x80; - pActor->uAttributes = v7; - v33 = PID(OBJECT_Actor,v5); - memcpy(&v31, Actor::GetDirectionInfo(PID(OBJECT_Actor,v5), v8, &a3, 0), sizeof(v31)); - memcpy(&v30, &v31, sizeof(v30)); - Actor::AI_StandOrBored(v37, 4, 32, &v30); - *(&this->field_0 + 4 * (this->uActorQueueSize + 2)) = v33; - this->pQueue[this->uActorQueueSize].field_C = 2; - this->pQueue[this->uActorQueueSize++].uActionLength = 0; - } - } - v4 = v35; - } - ++v40b; - ++v34; - } - while ( v40b < v4 + ai_arrays_size ); - v2 = 0; - } - v11 = __OFSUB__(this->uActorQueueSize, v2); - v9 = this->uActorQueueSize == v2; - v10 = ((this->uActorQueueSize - v2) & 0x80000000u) != 0; - v37 = v2; - v40b = v2; - if ( !((unsigned __int8)(v10 ^ v11) | v9) ) - { - v12 = (char *)&this->pQueue[0].field_4; - while ( 1 ) - { - v13 = PID_TYPE(*((int *)v12 - 1)); - if ( v13 != OBJECT_Player ) - break; - v14 = pPlayers[(*((int *)v12 - 1) >> 3) + 1]->uTimeToRecovery; - if ( v14 != (short)v2 ) - { - v33 = v14; - v16 = (signed __int64)((double)v14 * 0.46875); - *(int *)v12 = v16; - goto LABEL_26; - } - v15 = v37++; - *(&a3.uDistance + v15) = v40b; -LABEL_26: - ++v40b; - v12 += 16; - if ( v40b >= this->uActorQueueSize ) - goto LABEL_27; - } - if ( v13 != 3 ) - { - *(int *)v12 = 666; - goto LABEL_26; - } - v17 = rand() % 99; - if ( v17 < 33 ) - { - *(int *)v12 = 1; - goto LABEL_26; - } - LODWORD(v16) = SHIDWORD(v16) < 66; - LOBYTE(v16) = SHIDWORD(v16) >= 66; - LODWORD(v16) = 2 * v16 + 3; - *(int *)v12 = v16; - goto LABEL_26; - } -LABEL_27: - v18 = 0; - if ( (signed int)v37 > (signed int)v2 ) - { - do - { - __debugbreak(); - *(&v31.uDistance + v18) = pParty->pPlayers[*(&this->field_0 + 4 * (*(&a3.uDistance + v18) + 2)) >> 3].GetAttackRecoveryTime(v2); - ++v18; - } - while ( (signed int)v18 < (signed int)v37 ); - if ( (signed int)v37 > (signed int)v2 ) - { - v35 = v2; - v34 = (int *)1; - do - { - v40b = (int)v34; - if ( (signed int)v34 < (signed int)v37 ) - { - v19 = (char *)&v31.uDistance + v35; - do - { - v20 = *(int *)v19; - v33 = 4 * v40b; - v21 = (char *)(&v31.uDistance + v40b); - v22 = *(int *)v21; - if ( *(int *)v21 < v20 ) - { - *(int *)v21 = v20; - v23 = v33; - *(int *)v19 = v22; - v24 = (char *)&a3.uDistance + v23; - v25 = (char *)&a3.uDistance + v35; - v26 = *(int *)v24; - *(int *)v24 = *(unsigned int *)((char *)&a3.uDistance + v35); - *(int *)v25 = v26; - v2 = 0; - } - ++v40b; - } - while ( v40b < (signed int)v37 ); - } - v34 = (int *)((char *)v34 + 1); - v35 += 4; - } - while ( (signed int)((char *)v34 - 1) < (signed int)v37 ); - if ( (signed int)v37 > (signed int)v2 ) - { - do - { - v27 = v2 + 2; - v28 = *(&a3.uDistance + v2++); - v11 = __OFSUB__(v2, v37); - v10 = ((v2 - v37) & 0x80000000u) != 0; - this->pQueue[v28].field_4 = v27; - } - while ( v10 ^ v11 ); - } - } - } - return this->_404544(); -}
--- a/mm7_4.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/mm7_4.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -5079,7 +5079,7 @@ v1 = *_this - 399; v2 = (*_this - 400) % 11 + 1; v11 = 4 * (*_this - 400) / 11; - sprintf(pTmpBuf.data(), "%s%03d", spellbook_texture_filename_suffices[v11 / 4], v2); + // sprintf(pTmpBuf.data(), "%s%03d", spellbook_texture_filename_suffices[v11 / 4], v2); not used if ( pMouse->GetCursorPos(&a2)->y <= 320 ) v3 = pMouse->GetCursorPos(&a2)->y + 30; else @@ -6276,250 +6276,3 @@ -//----- (00405CFF) -------------------------------------------------------- -void stru262_TurnBased::End(bool bPlaySound) -{ - stru262_TurnBased *v2; // edi@1 - int v3; // ebx@1 - int v4; // esi@1 - unsigned __int8 v5; // zf@1 - unsigned __int8 v6; // sf@1 - TurnBased_QueueElem *v7; // ecx@2 - unsigned __int16 *pAttributes; // ecx@7 - size_t v9; // edx@7 - unsigned __int16 v10; // ax@8 - TurnBased_QueueElem *v11; // ebx@12 - ObjectType objType; // eax@13 - int objID; // esi@13 - int v14; // [sp+Ch] [bp-4h]@11 - - v2 = this; - v3 = 0; - v4 = 0; - v5 = this->uActorQueueSize == 0; - v6 = this->uActorQueueSize < 0; - this->field_4 = 0; - if ( !(v6 | v5) ) - { - v7 = this->pQueue; - do - { - if ( PID_TYPE(v7->uPackedID) == OBJECT_Actor ) - LOBYTE(pActors[PID_ID(v7->uPackedID)].uAttributes) &= 0x7Fu; - ++v4; - ++v7; - } - while ( v4 < v2->uActorQueueSize ); - } - if ( (signed int)uNumSpriteObjects > 0 ) - { - pAttributes = &pSpriteObjects[0].uAttributes; - v9 = uNumSpriteObjects; - do - { - v10 = *pAttributes; - if ( *pAttributes & 4 ) - { - LOBYTE(v10) = v10 & 0xFB; - *pAttributes = v10; - } - pAttributes += 56; - --v9; - } - while ( v9 ); - } - v14 = 0; - if ( v2->uActorQueueSize > 0 ) - { - v11 = v2->pQueue; - do - { - objType = (ObjectType)PID_TYPE(v11->uPackedID); - objID = PID_ID(v11->uPackedID); - if ( objType == OBJECT_Player ) - { - pPlayers[objID + 1]->uTimeToRecovery = (signed __int64)((double)v11->field_4 * 2.133333333333333); - } - else - { - if ( objType == OBJECT_Actor ) - pActors[objID].pMonsterInfo.uRecoveryTime = (signed __int64)((double)v11->field_4 * 2.133333333333333); - } - ++v14; - ++v11; - } - while ( v14 < v2->uActorQueueSize ); - v3 = 0; - } - pAudioPlayer->StopChannels(-1, -1); - if ( bPlaySound != v3 ) - pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|SOUND_EnteringAHouse), v3, v3, -1, v3, v3, v3, v3); - pTurnEngine->field_18 &= 0xFFFFFFFDu; - pEventTimer->StopGameTime(); - dword_50C994 = v3; - dword_50C998_turnbased_icon_1A = v3; -} -// 50C994: using guessed type int dword_50C994; -// 50C998: using guessed type int dword_50C998_turnbased_icon_1A; - -//----- (00405E14) -------------------------------------------------------- -void stru262_TurnBased::_405E14() -{ - stru262_TurnBased *v1; // esi@1 - int v2; // ecx@1 - SpellBuff *v3; // edi@2 - Actor *v4; // ebx@3 - signed int v5; // edx@20 - AIDirection *v6; // esi@21 - int v7; // eax@21 - int v8; // eax@21 - int v9; // eax@22 - int v10; // eax@23 - int v11; // eax@37 - int v12; // eax@44 - AIDirection a3; // [sp+4h] [bp-68h]@21 - AIDirection v14; // [sp+20h] [bp-4Ch]@21 - AIDirection v15; // [sp+3Ch] [bp-30h]@21 - Actor *v16; // [sp+58h] [bp-14h]@2 - int v17; // [sp+5Ch] [bp-10h]@6 - stru262_TurnBased *v18; // [sp+60h] [bp-Ch]@1 - int v19; // [sp+64h] [bp-8h]@8 - unsigned int v20; // [sp+68h] [bp-4h]@1 - - v1 = this; - v2 = 0; - v18 = v1; - v20 = 0; - if ( (signed int)uNumActors > 0 ) - { - //v3 = pActors;//[0].pActorBuffs; - v16 = pActors.data();//[0].pActorBuffs; - v3 = v16->pActorBuffs; - do - { - v4 = v16; - if ( SHIDWORD(v3[3].uExpireTime) < v2 || SHIDWORD(v3[3].uExpireTime) <= v2 && LODWORD(v3[3].uExpireTime) <= v2 ) - v17 = v2; - else - v17 = 1; - v19 = v2; - do - { - if ( v19 != 10 ) - { - v3->_4585CA(pParty->uTimePlayed); - v2 = 0; - } - ++v19; - ++v3; - } - while ( v19 < 22 ); - if ( v17 != v2 - && SHIDWORD(v4->pActorBuffs[3].uExpireTime) <= v2 - && (SHIDWORD(v4->pActorBuffs[3].uExpireTime) < v2 || LODWORD(v4->pActorBuffs[3].uExpireTime) <= v2) ) - v4->uActorHeight = pMonsterList->pMonsters[v4->pMonsterInfo.uID - 1].uMonsterHeight; - if ( !(v4->uAttributes & 0x80) ) - { - if ( !v4->pActorBuffs[5].uExpireTime ) - { - if ( !v4->pActorBuffs[6].uExpireTime ) - { - v5 = v4->uCurrentActionLength; - v4->uCurrentActionTime += pMiscTimer->uTimeElapsed; - if ( (signed int)v4->uCurrentActionTime >= v5 ) - { - v17 = ai_near_actors_targets_pid[v20]; - v6 = Actor::GetDirectionInfo(PID(OBJECT_Actor,v20), v17, &a3, v2); - v7 = v4->uAIState; - memcpy(&v15, v6, sizeof(v15)); - v8 = v7 - 4; - memcpy(&v14, &v15, sizeof(v14)); - if ( v8 ) - { - v9 = v8 - 1; - if ( v9 ) - { - v10 = v9 - 6; - if ( v10 ) - { - if ( v10 != 8 ) - Actor::AI_StandOrBored(v20, v17, 32, &v14); - } - } - } - else - { - v4->uCurrentActionTime = 0; - v4->uCurrentActionLength = 0; - v4->uAIState = Dead; - v4->UpdateAnimation(); - } - v1 = v18; - v2 = 0; - } - } - } - } - ++v20; - v3 = v16[1].pActorBuffs; - ++v16; - } - while ( (signed int)v20 < (signed int)uNumActors ); - } - if ( v1->field_4 == 1 ) - { - v12 = v1->field_8; - if ( v12 == 64 ) - { - v1->_406A63(); - } - else - { - if ( v12 > v2 ) - { - v1->_406B9F(); - } - else - { - v1->_406AFE(); - v1->field_10 = 100; - } - } - v1->field_8 -= pEventTimer->uTimeElapsed; - return; - } - if ( v1->field_4 == 2 ) - { - if ( !(v1->field_18 & 1) ) - { - v11 = v1->field_10; - if ( v11 == 100 ) - { - v1->StartTurn(); -LABEL_39: - v1->_40652A(); - return; - } - if ( v11 > v2 || v1->pQueue[0].field_4 <= v2 ) - { - v1->_4065B0(); - goto LABEL_39; - } - } - v1->NextTurn(); - return; - } - if ( v1->field_4 == 3 ) - { - if ( v1->uActionPointsLeft <= v2 || v1->field_18 & 8 ) - { - v1->field_18 &= 0xFFFFFFF7u; - v1->field_4 = 1; - v1->field_8 = 64; - } - else - { - v1->_406FA8(); - } - } -} \ No newline at end of file
--- a/mm7_5.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/mm7_5.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -1774,12 +1774,9 @@ pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; continue; - case UIMSG_CastSpell_BE://??? - __debugbreak(); + case UIMSG_CastSpell_Telekinesis: if ( pRenderer->pRenderD3D ) - { LOWORD(v42) = pGame->pVisInstance->get_picked_object_zbuf_val(); - } else { uNumSeconds = (unsigned int)pMouse->GetCursorPos(&v210); @@ -2432,7 +2429,7 @@ } if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 3 ) continue; - if ( !(pTurnEngine->field_18 & 2) ) + if ( !(pTurnEngine->field_18 & TE_FLAG_2) ) { if ( pActors[uMessageParam].uAIState == 5 ) stru_50C198.LootActor(&pActors[uMessageParam]); @@ -2451,7 +2448,7 @@ } if ( pTurnEngine->field_4 == 1 || pTurnEngine->field_4 == 3 ) continue; - if ( !(pTurnEngine->field_18 & 2) ) + if ( !(pTurnEngine->field_18 & TE_FLAG_2) ) _42ECB5_PlayerAttacksActor(); continue; case UIMSG_ExitRest: @@ -4780,1278 +4777,6 @@ return v6; } -//----- (00406051) -------------------------------------------------------- -__int16 stru262_TurnBased::StartTurn() -{ - stru262_TurnBased *v1; // esi@1 - int v2; // ecx@1 - int v3; // ebx@1 - char *v4; // edi@1 - int v5; // eax@4 - int v6; // eax@12 - char *v7; // eax@15 - TurnBased_QueueElem *v8; // edi@17 - unsigned int v9; // edx@23 - char *v10; // eax@26 - int v11; // eax@30 - int v12; // ebx@30 - char *v13; // edi@31 - int v15; // [sp+Ch] [bp-10h]@5 - TurnBased_QueueElem *v16; // [sp+10h] [bp-Ch]@3 - int v17; // [sp+14h] [bp-8h]@2 - int v18; // [sp+14h] [bp-8h]@16 - signed int v19; // [sp+18h] [bp-4h]@1 - int v20; // [sp+18h] [bp-4h]@14 - - v1 = this; - v2 = 0; - v19 = 0; - v3 = v1->uActorQueueSize; - v1->field_1C = 0; - v4 = (char *)&v1->pQueue[v3].field_4; - do - { - v17 = v2; - if ( v1->uActorQueueSize <= v2 ) - goto LABEL_11; - v16 = v1->pQueue; - while ( 1 ) - { - v5 = v16->uPackedID; - if ( PID_TYPE(v16->uPackedID) == OBJECT_Player) - break; -LABEL_8: - ++v17; - ++v16; - if ( v17 >= v1->uActorQueueSize ) - goto LABEL_11; - } - v15 = PID_ID(v5); - if ( !pPlayers[(PID_ID(v5)) + 1]->CanAct() || v19 != v15 ) - { - v2 = 0; - goto LABEL_8; - } - v2 = 0; -LABEL_11: - if ( v17 == v1->uActorQueueSize ) - { - *(int *)v4 = 100; - v6 = 8 * v19; - LOBYTE(v6) = PID(OBJECT_Player,v19); - *((int *)v4 + 2) = v2; - *((int *)v4 - 1) = v6; - *((int *)v4 + 1) = v2; - ++v3; - v4 += 16; - } - ++v19; - } - while ( v19 < 4 ); - v1->uActorQueueSize = v3; - v20 = v2; - if ( ai_arrays_size > v2 ) - { - v7 = (char *)&v1->pQueue[v3].field_4; - do - { - v18 = v2; - if ( v1->uActorQueueSize > v2 ) - { - v8 = v1->pQueue; - do - { - if ( PID_TYPE(v8->uPackedID) == OBJECT_Actor && ai_near_actors_ids[v20] == PID_ID(v8->uPackedID) ) - break; - ++v18; - ++v8; - } - while ( v18 < v1->uActorQueueSize ); - v2 = 0; - } - if ( v18 == v1->uActorQueueSize ) - { - v9 = ai_near_actors_ids[v20]; - *(int *)v7 = 1; - *((int *)v7 + 2) = v2; - *((int *)v7 - 1) = PID(OBJECT_Actor,v9); - *((int *)v7 + 1) = v2; - ++v3; - v7 += 16; - } - ++v20; - } - while ( v20 < ai_arrays_size ); - } - ++v1->field_0; - v1->uActorQueueSize = v3; - v1->field_10 = 100; - if ( v3 > 0 ) - { - v10 = (char *)&v1->pQueue[0].field_4; - do - { - if ( *(int *)v10 <= 0 ) - *(int *)v10 = 100; - ++v2; - v10 += 16; - } - while ( v2 < v1->uActorQueueSize ); - } - LOWORD(v11) = v1->_4063A1(); - v12 = 0; - if ( v1->uActorQueueSize > 0 ) - { - v13 = (char *)&v1->pQueue[0].field_4; - do - { - v11 = PID_TYPE(*((int *)v13 - 1)); - if ( (char)v11 == 4 ) - break; - if ( *(int *)v13 > 0 ) - break; - LOWORD(v11) = v1->_40680F(v12++); - v13 += 16; - } - while ( v12 < v1->uActorQueueSize ); - } - return v11; -} -// 4F75D8: using guessed type int ai_arrays_size; - -//----- (004061CA) -------------------------------------------------------- -void stru262_TurnBased::NextTurn() -{ - stru262_TurnBased *v1; // esi@1 - TurnBased_QueueElem *v2; // ebp@1 - int v3; // ebx@1 - int v4; // edi@7 - Actor *v5; // eax@9 - int v6; // ecx@9 - signed int v7; // ebx@17 - int v8; // ebp@27 - TurnBased_QueueElem *v9; // edi@28 - int v10; // ecx@30 - unsigned __int16 v11; // ax@30 - signed int v12; // edx@35 - signed int v13; // [sp+10h] [bp-4h]@7 - - v1 = this; - _404544(); - v2 = v1->pQueue; - v3 = 0; - if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) - uActiveCharacter = PID_ID(v1->pQueue[0].uPackedID) + 1; - else - uActiveCharacter = 0; - viewparams->bRedrawGameUI = 1; - if ( v1->field_1C ) - { - pTurnEngine->field_18 |= 2u; - return; - } - pTurnEngine->field_18 &= 0xFFFFFFFDu; - if ( v1->pQueue[0].field_4 <= 0 ) - return; - v4 = 0; - v13 = 0; - if ( v1->uActorQueueSize <= 0 ) - goto LABEL_27; - do - { - if (PID_TYPE(v2->uPackedID) != OBJECT_Player) - { - v5 = &pActors[PID_ID(v2->uPackedID)]; - LOWORD(v6) = v5->uAIState; - if ( (short)v6 == 4 - || (short)v6 == 8 - || (short)v6 == 2 - || (short)v6 == 3 - || (short)v6 == 12 - || (short)v6 == 13 - || (short)v6 == 18 - || (short)v6 == 17 ) - { - v7 = v5->uCurrentActionLength; - v5->uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( (signed int)v5->uCurrentActionTime < v7 ) - { - v13 = 1; -LABEL_19: - v3 = 0; - goto LABEL_20; - } - v6 = (signed __int16)v6; - if ( (signed __int16)v6 == 4 ) - { - v3 = 0; - v5->uAIState = Dead; - v5->uCurrentActionTime = 0; - v5->uCurrentActionLength = 0; - v5->UpdateAnimation(); - } - else - { - if ( v6 != 8 ) - goto LABEL_19; - v3 = 0; - Actor::AI_StandOrBored(PID_ID(v2->uPackedID), ai_near_actors_targets_pid[PID_ID(v2->uPackedID)], 32, 0); - } - } - } -LABEL_20: - ++v4; - ++v2; - } - while ( v4 < v1->uActorQueueSize ); - if ( v13 != v3 ) - { - v1->field_18 |= 1u; - return; - } -LABEL_27: - v1->field_18 &= 0xFFFFFFFEu; - v8 = 0; - if ( v1->uActorQueueSize > v3 ) - { - v9 = v1->pQueue; - do - { - if (PID_TYPE(v9->uPackedID) != OBJECT_Player) - { - v10 = PID_ID(v9->uPackedID); - v11 = pActors[v10].uAIState; - if ( v11 != 5 ) - { - if ( v11 != 4 && v11 != 11 && v11 != 19 ) - { - if ( v11 != 17 ) - { - v12 = ai_near_actors_targets_pid[v10]; - v9->uActionLength = v3; - Actor::AI_StandOrBored(v10, v12, 32, (AIDirection *)v3); - } - } - } - } - ++v8; - ++v9; - } - while ( v8 < v1->uActorQueueSize ); - } - v1->field_4 = 3; - pParty->uTimePlayed += __PAIR__(v3, 213); - _494035_timed_effects__water_walking_damage__etc(); - v1->uActionPointsLeft = 130; -} - -//----- (004063A1) -------------------------------------------------------- -int stru262_TurnBased::_4063A1() -{ - stru262_TurnBased *v1; // esi@1 - int v2; // ebp@1 - signed int result; // eax@1 - int v4; // edx@1 - int v5; // edx@3 - int v6; // edi@4 - int v7; // ecx@5 - Actor *v8; // ecx@11 - unsigned __int16 v9; // dx@12 - int v10; // edi@16 - int v11; // edx@17 - char v12; // zf@18 - - v1 = this; - _404544(); - v2 = (int)&v1->pQueue[0].field_4; - result = 1; - viewparams->bRedrawGameUI = 1; - v4 = v1->pQueue[0].field_4; - if ( v4 ) - { - if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) - { - v5 = v1->uActorQueueSize; - while ( 1 ) - { - v6 = 0; - if ( v5 > 0 ) - { - v7 = (int)&v1->pQueue[0].field_4; - do - { - --*(int *)v7; - v5 = v1->uActorQueueSize; - ++v6; - v7 += 16; - } - while ( v6 < v5 ); - } - --v1->field_10; - if ( v1->field_10 <= 0 ) - break; - if ( !*(int *)v2 ) - goto LABEL_9; - } -LABEL_24: - result = 1; - } - else - { - v8 = &pActors[PID_ID(v1->pQueue[0].uPackedID)]; - if ( v4 > 0 ) - { - do - { - v9 = v8->uAIState; - if ( v9 == 5 ) - break; - if ( v9 == 4 || v9 == 19 || v9 == 11 ) - break; - v10 = 0; - if ( v1->uActorQueueSize > 0 ) - { - v11 = (int)&v1->pQueue[0].field_4; - do - { - v12 = (*(int *)v11)-- == 1; - if ( v12 ) - *(int *)(v11 + 4) = 0; - ++v10; - v11 += 16; - } - while ( v10 < v1->uActorQueueSize ); - } - --v1->field_10; - if ( v1->field_10 <= 0 ) - goto LABEL_24; - } - while ( *(int *)v2 > 0 ); - } -LABEL_9: - result = 0; - } - } - return result; -} - -//----- (00406457) -------------------------------------------------------- -int stru262_TurnBased::_406457(int a2) -{ - stru262_TurnBased *v2; // esi@1 - signed int v3; // eax@1 - signed int v4; // ecx@2 - char *v5; // edx@2 - signed int v6; // eax@2 - int result; // eax@11 - int v8; // edx@13 - int v9; // ecx@14 - char v10; // zf@15 - - v2 = this; - v3 = *(&this->field_0 + 4 * (a2 + 2)); - if ( (*((char *)&this->field_0 + 16 * PID_TYPE(a2 + 2))) == OBJECT_Player) - { - v4 = PID_ID(v3); - v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[PID_ID(v3)]; - v6 = *(int *)v5; - if ( *(int *)v5 ) - *(int *)v5 = 0; - else - v6 = pPlayers[v4 + 1]->GetAttackRecoveryTime(0); - if ( v6 < 30 ) - v6 = 30; - } - else - { - v6 = pMonsterStats->pInfos[pActors[PID_ID(v3)].pMonsterInfo.uID].uRecoveryTime; - } - v2->pQueue[a2].field_4 = v6; - v2->_404544(); - if (PID_TYPE(v2->pQueue[0].uPackedID) == OBJECT_Player) - uActiveCharacter = PID_ID(v2->pQueue[0].uPackedID) + 1; - else - uActiveCharacter = 0; - result = (int)&v2->pQueue[0].field_4; - viewparams->bRedrawGameUI = 1; - while ( *(int *)result > 0 ) - { - if ( v2->field_10 <= 0 ) - break; - v8 = 0; - if ( v2->uActorQueueSize > 0 ) - { - v9 = (int)&v2->pQueue[0].field_4; - do - { - v10 = (*(int *)v9)-- == 1; - if ( v10 ) - *(int *)(v9 + 4) = 0; - ++v8; - v9 += 16; - } - while ( v8 < v2->uActorQueueSize ); - } - --v2->field_10; - if ( v2->field_10 <= 0 ) - break; - } - return result; -} - -//----- (0040652A) -------------------------------------------------------- -void stru262_TurnBased::_40652A() -{ - int *v1; // edx@2 - Actor *v2; // eax@5 - unsigned __int16 v3; // si@5 - unsigned int v4; // esi@8 - int v5; // [sp+Ch] [bp-4h]@1 - - v5 = 0; - if ( this->uActorQueueSize > 0 ) - { - v1 = &this->pQueue[0].field_4; - do - { - if ( !*(int *)v1 ) - { - if ( PID_TYPE(*(v1 - 4)) == OBJECT_Player) - return; - v2 = &pActors[PID_ID(*(v1 - 1))]; - v3 = v2->uAIState; - if (v3 == Standing || v3 == Fleeing || v3 == Fidgeting) - { - v4 = pMonsterStats->pInfos[v2->pMonsterInfo.uID].uRecoveryTime; - *(int *)v1 = v4; - if ( (signed __int64)v2->pActorBuffs[7].uExpireTime > 0 ) - *(int *)v1 = 2 * v4; - } - } - ++v5; - v1 += 16; - } - while ( v5 < this->uActorQueueSize ); - } -} - -//----- (004065B0) -------------------------------------------------------- -void stru262_TurnBased::_4065B0() -{ - stru262_TurnBased *v1; // esi@1 - signed int v2; // eax@1 - int v3; // ebx@6 - int v4; // edi@7 - unsigned int v5; // edi@14 - - v1 = this; - LOWORD(v2) = _404544(); - if ( v1->pQueue[0].field_4 <= 0 - || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, PID_TYPE(v1->pQueue[0].uPackedID) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (PID_ID(v2)) + 1, uActiveCharacter = v2), - viewparams->bRedrawGameUI = 1, - v1->pQueue[0].field_4 <= 0) ) - { - v3 = 0; - if ( v1->uActorQueueSize > 0 ) - { - v4 = (int)v1->pQueue; - do - { - v2 = *(int *)v4; - if ( PID_TYPE(*(char *)v4) == OBJECT_Player || *(int *)(v4 + 4) > 0 ) - break; - if ( *(int *)(v4 + 8) <= 0 ) - { - LOWORD(v2) = v2 & 3; - if ( (char)v2 == 3 ) - LOWORD(v2) = v1->_40680F(v3); - } - ++v3; - v4 += 16; - } - while ( v3 < v1->uActorQueueSize ); - } - } - v5 = 0; - if ( v1->uActorQueueSize > 0 ) - { - do - v1->_406648(v5++); - while ( (signed int)v5 < v1->uActorQueueSize ); - } -} - -//----- (00406648) -------------------------------------------------------- -void stru262_TurnBased::_406648(unsigned int a2) -{ - TurnBased_QueueElem *v1; // ecx@1 - int v3; // eax@1 - unsigned int v4; // ebx@2 - Actor *v5; // esi@2 - signed int v6; // edi@5 - int v7; // ecx@6 - int v8; // eax@6 - int v9; // eax@7 - int v10; // eax@8 - int v11; // eax@9 - int v12; // eax@10 - int v13; // eax@11 - int v14; // eax@14 - unsigned int v15; // ecx@14 - unsigned int v16; // edx@14 - int v17; // eax@17 - int v18; // eax@20 - char v19; // al@24 - unsigned int v21; // [sp-8h] [bp-50h]@16 - int v22; // [sp-8h] [bp-50h]@17 - AIDirection *v23; // [sp-4h] [bp-4Ch]@14 - unsigned int v24; // [sp-4h] [bp-4Ch]@17 - char v25; // [sp-4h] [bp-4Ch]@20 - AIDirection a3; // [sp+Ch] [bp-3Ch]@2 - AIDirection a4; // [sp+28h] [bp-20h]@2 - TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1 - unsigned int a2a; // [sp+50h] [bp+8h]@2 - - v1 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2)); - v28 = v1; - v3 = v1->uPackedID; - if (PID_TYPE(v1->uPackedID) != OBJECT_Player) - { - v4 = PID_ID(v3); - a2a = ai_near_actors_targets_pid[PID_ID(v3)]; - memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3)); - memcpy(&a4, &a3, sizeof(a4)); - v5 = &pActors[PID_ID(v3)]; - LOWORD(v3) = v5->uAIState; - if ( (short)v3 != Dead ) - { - if ( (short)v3 != Disabled ) - { - if ( (short)v3 != Removed ) - { - v6 = v5->uCurrentActionLength; - v5->uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( (signed int)v5->uCurrentActionTime >= v6 ) - { - v7 = (signed __int16)v3; - v8 = (signed __int16)v3 - 2; - if ( !v8 ) - { - v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4); - stru_50FE08.Add( - v28->uPackedID, - 5120, - v5->vPosition.x, - v5->vPosition.y, - v5->vPosition.z + ((signed int)v5->uActorHeight >> 1), - v19, - 1); - goto LABEL_25; - } - v9 = v8 - 1; - if ( v9 ) - { - v10 = v9 - 1; - if ( !v10 ) - goto LABEL_21; - v11 = v10 - 4; - if ( !v11 ) - goto LABEL_25; - v12 = v11 - 4; - if ( v12 ) - { - v13 = v12 - 1; - if ( v13 ) - { - if ( v13 != Dead ) - { - if ( v7 != 4 ) - { - v14 = rand(); - v15 = v4; - v23 = &a4; - v16 = a2a; - if ( !(v14 % 2) ) - { - Actor::AI_Bored(v4, a2a, &a4); - return; - } - v21 = 64; -LABEL_26: - Actor::AI_Stand(v15, v16, v21, v23); - return; - } -LABEL_21: - v5->uCurrentActionTime = 0; - v5->uCurrentActionLength = 0; - v5->uAIState = Dead; - pActors[v4].UpdateAnimation(); - return; - } - v24 = v5->pMonsterInfo.uSpellSkillAndMastery2; - v22 = 3; - v17 = v5->pMonsterInfo.uSpell2ID; - } - else - { - v24 = v5->pMonsterInfo.uSpellSkillAndMastery1; - v22 = 2; - v17 = v5->pMonsterInfo.uSpell1ID; - } - Actor::AI_SpellAttack(v4, &a4, v17, v22, v24); -LABEL_25: - v16 = a2a; - v23 = &a4; - v21 = 0; - v15 = v4; - goto LABEL_26; - } - v18 = v5->pMonsterInfo.uMissleAttack2Type; - v25 = 1; - } - else - { - v18 = v5->pMonsterInfo.uMissleAttack1Type; - v25 = 0; - } - Actor::AI_RangedAttack(v4, &a4, v18, v25); - goto LABEL_25; - } - } - } - } - } -} -// 50FE08: using guessed type stru298 stru_50FE08; - -//----- (0040680F) -------------------------------------------------------- -__int16 stru262_TurnBased::_40680F(int a2) -{ - TurnBased_QueueElem *v2; // eax@1 - unsigned int v3; // eax@1 - unsigned int v4; // edi@2 - Actor *v5; // ebx@2 - unsigned int *v6; // esi@7 - AIDirection *v7; // esi@10 - int v8; // eax@10 - unsigned int v9; // ecx@10 - signed int v10; // eax@13 - unsigned __int8 v11; // sf@19 - unsigned __int8 v12; // of@19 - int v13; // esi@29 - bool v14; // eax@29 - unsigned __int8 v15; // cl@33 - AIDirection a3; // [sp+Ch] [bp-44h]@10 - AIDirection v18; // [sp+28h] [bp-28h]@10 - int a2a; // [sp+44h] [bp-Ch]@2 - unsigned int v20; // [sp+48h] [bp-8h]@10 - TurnBased_QueueElem *v21; // [sp+4Ch] [bp-4h]@1 - signed int v22; // [sp+58h] [bp+8h]@10 - - v2 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2)); - v21 = v2; - v2->uActionLength = 0; - v3 = v2->uPackedID; - if ( (unsigned __int8)v3 & 3 ) - { - v3 = PID_ID(v3); - v4 = v3; - a2a = v3; - v5 = &pActors[v3]; - LOWORD(v3) = v5->uAIState; - if ( (short)v3 != 5 ) - { - if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 ) - { - v6 = (unsigned int *)&ai_near_actors_targets_pid[(int)v4]; - Actor::_SelectTarget((unsigned int)v4, &ai_near_actors_targets_pid[(int)v4], true); - if ( v5->pMonsterInfo.uHostilityType && !*v6 ) - v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - v22 = *v6; - v7 = Actor::GetDirectionInfo(PID(OBJECT_Actor,(int)v4), *v6, &a3, 0); - v8 = v5->uActorRadius; - memcpy(&a3, v7, sizeof(a3)); - memcpy(&v18, &a3, sizeof(v18)); - v9 = a3.uDistance - v8; - v20 = a3.uDistance - v8; - if ( ((a3.uDistance - v8) & 0x80000000u) != 0 ) - { - v9 = 0; - v20 = 0; - } - if (PID_TYPE(v22) == OBJECT_Actor) - //v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3); - v10 = pFactionTable->relations[(pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID) / 3 + 1][(v5->pMonsterInfo.uID - 1) / 3 + 1]; - else - v10 = 4; - if ( v10 == 1 ) - { - if ( (double)(signed int)v20 < 307.2 ) - goto LABEL_25; - } - else - { - if ( v10 == 2 ) - { - v12 = __OFSUB__(v9, 1024); - v11 = ((v9 - 1024) & 0x80000000u) != 0; - } - else - { - if ( v10 == 3 ) - { - v12 = __OFSUB__(v9, 2560); - v11 = ((v9 - 2560) & 0x80000000u) != 0; - } - else - { - if ( v10 != 4 ) - goto LABEL_26; - v12 = __OFSUB__(v9, 5120); - v11 = ((v9 - 5120) & 0x80000000u) != 0; - } - } - if ( v11 ^ v12 ) - { -LABEL_25: - v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - goto LABEL_26; - } - } -LABEL_26: - if ( v5->pMonsterInfo.uHostilityType != 4 || !v22 || (signed int)v9 >= 5120 ) - { - v13 = a2a; - goto LABEL_47; - } - v13 = a2a; - v14 = stru_50C198.special_ability_use_check(v5, a2a); - if ( v14 == 1 ) - { - if ( v5->pMonsterInfo.uMissleAttack2Type ) - { - Actor::AI_MissileAttack2(v13, v22, &v18); - goto LABEL_43; - } - } - else - { - if ( v14 > 1 && v14 <= 3 ) - { - if ( v14 == 2 ) - v15 = v5->pMonsterInfo.uSpell1ID; - else - v15 = v5->pMonsterInfo.uSpell2ID; - if ( v15 ) - { - if ( v14 == 2 ) - Actor::AI_SpellAttack1(v13, v22, &v18); - else - Actor::AI_SpellAttack2(v13, v22, &v18); - goto LABEL_43; - } - goto LABEL_44; - } - if ( v5->pMonsterInfo.uMissleAttack1Type ) - { - Actor::AI_MissileAttack1(v13, v22, &v18); -LABEL_43: - //v3 = v21; - v21->field_C = 1; -LABEL_48: - v21->uActionLength = v5->uCurrentActionLength; - //return (signed __int16)v3; - return (signed __int16)&v21; - } - } -LABEL_44: - if ( (double)(signed int)v20 < 307.2 ) - { - Actor::AI_MeleeAttack(v13, v22, &v18); - //v3 = v21; - v21->field_C = 3; - goto LABEL_48; - } -LABEL_47: - Actor::AI_Stand(v13, v22, 0x40u, &v18); - //v3 = v21; - v21->field_C = 0; - goto LABEL_48; - } - } - } - return (signed __int16)v3; -} - -//----- (00406A63) -------------------------------------------------------- -void stru262_TurnBased::_406A63() -{ - stru262_TurnBased *v1; // ebx@1 - int v2; // esi@1 - unsigned __int8 v3; // zf@1 - unsigned __int8 v4; // sf@1 - signed int v5; // ecx@4 - AIDirection a3; // [sp+8h] [bp-44h]@5 - AIDirection v7; // [sp+24h] [bp-28h]@5 - unsigned int v8; // [sp+40h] [bp-Ch]@5 - signed int a2; // [sp+44h] [bp-8h]@1 - TurnBased_QueueElem *v10; // [sp+48h] [bp-4h]@2 - - v1 = this; - v2 = 0; - this->field_8 = 64; - dword_50C994 = 0; - uActiveCharacter = 0; - v3 = this->uActorQueueSize == 0; - v4 = this->uActorQueueSize < 0; - a2 = 0; - if ( !(v4 | v3) ) - { - v10 = this->pQueue; - while ( 1 ) - { - v5 = v10->uPackedID; - if (PID_TYPE(v10->uPackedID) == OBJECT_Actor) - { - v8 = ai_near_actors_targets_pid[PID_ID(v5)]; - memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7)); - if ( !v1->_406D10(a2) ) - Actor::AI_Stand(PID_ID(v10->uPackedID), v8, 0x20u, &v7); - } - ++a2; - ++v10; - if ( a2 >= v1->uActorQueueSize ) - break; - v2 = 0; - } - } -} -// 50C994: using guessed type int dword_50C994; - -//----- (00406AFE) -------------------------------------------------------- -void stru262_TurnBased::_406AFE() -{ - stru262_TurnBased *v1; // edi@1 - TurnBased_QueueElem *v2; // ebx@2 - int v3; // esi@4 - int v4; // ecx@5 - AIDirection a3; // [sp+4h] [bp-48h]@5 - AIDirection v6; // [sp+20h] [bp-2Ch]@5 - stru262_TurnBased *v7; // [sp+3Ch] [bp-10h]@1 - unsigned int v8; // [sp+40h] [bp-Ch]@4 - unsigned int v9; // [sp+44h] [bp-8h]@5 - int v10; // [sp+48h] [bp-4h]@1 - - v10 = 0; - v1 = this; - v7 = this; - if ( this->uActorQueueSize > 0 ) - { - v2 = this->pQueue; - do - { - if (PID_TYPE(v2->uPackedID) == OBJECT_Actor) - { - v3 = PID_ID(v2->uPackedID); - v8 = v3; - if ( pActors[v3].CanAct() ) - { - v4 = v2->uPackedID; - v9 = ai_near_actors_targets_pid[v3]; - memcpy(&v6, Actor::GetDirectionInfo(v4, v9, &a3, 0), sizeof(v6)); - Actor::AI_Stand(v8, v9, 0x20u, &v6); - v2->field_C = 0; - v2->uActionLength = 0; - v1 = v7; - } - } - ++v10; - ++v2; - } - while ( v10 < v1->uActorQueueSize ); - } - v1->field_4 = 2; - v1->field_8 = 100; -} - -//----- (00406B9F) -------------------------------------------------------- -int stru262_TurnBased::_406B9F() -{ - signed int result; // eax@1 - unsigned __int8 v2; // zf@1 - unsigned __int8 v3; // sf@1 - int v4; // esi@4 - unsigned int v5; // esi@5 - Actor *v6; // ebx@5 - unsigned __int16 v7; // cx@15 - AIDirection a3; // [sp+0h] [bp-50h]@15 - AIDirection v9; // [sp+1Ch] [bp-34h]@15 - signed int a1; // [sp+38h] [bp-18h]@4 - stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1 - unsigned int v12; // [sp+40h] [bp-10h]@5 - unsigned int v13; // [sp+44h] [bp-Ch]@8 - TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2 - signed int a2; // [sp+4Ch] [bp-4h]@1 - - result = 0; - thisa = this; - v2 = this->uActorQueueSize == 0; - v3 = this->uActorQueueSize < 0; - a2 = 0; - if ( !(v3 | v2) ) - { - v14 = this->pQueue; - while ( 1 ) - { - v4 = v14->uPackedID; - a1 = v14->uPackedID; - if (PID_TYPE(a1) != OBJECT_Player) - { - v5 = PID_ID(v4); - v12 = v5; - v6 = &pActors[v5]; - if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result - || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result ) - v13 = result; - else - v13 = 1; - if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result - && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) ) - result = 1; - if ( !(v13 != 0 || result || v6->uAIState == 5 || v6->uAIState == 11 || v6->uAIState == 19) ) - { - v13 = ai_near_actors_targets_pid[v5]; - memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9)); - v7 = v6->uAIState; - if ( v7 == 6 || v7 == 1 ) - { - if ( (double)(signed int)v9.uDistance < 307.2 ) - goto LABEL_26; - } - v6->uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength ) - { - if ( v7 == 4 ) - { - v6->uCurrentActionTime = 0; - v6->uCurrentActionLength = 0; - v6->uAIState = Dead; - v6->UpdateAnimation(); - } - if ( !thisa->_406D10(a2) ) -LABEL_26: - Actor::AI_Stand(v12, v13, 0x20u, &v9); - } - } - } - ++a2; - result = (signed int)thisa; - ++v14; - if ( a2 >= thisa->uActorQueueSize ) - break; - result = 0; - } - } - return result; -} - -//----- (00406D10) -------------------------------------------------------- -bool stru262_TurnBased::_406D10(signed int a2) -{ - int v2; // ecx@1 - //int v3; // ecx@2 - Actor *actor; // ebx@2 - //unsigned __int16 v5; // dx@2 - int *v6; // esi@7 - TurnBased_QueueElem *v7; // edi@7 - int v8; // eax@7 - AIDirection *v9; // esi@10 - int v10; // eax@10 - unsigned int v11; // ecx@10 - unsigned __int8 pHostileType; // al@12 - unsigned __int8 v13; // sf@16 - unsigned __int8 v14; // of@16 - unsigned int v15; // edx@22 - unsigned int v16; // ecx@23 - TurnBased_QueueElem *v17; // eax@25 - double v18; // st7@33 - double v19; // st6@33 - int v21; // [sp-8h] [bp-5Ch]@23 - int v22; // [sp-8h] [bp-5Ch]@26 - AIDirection *v23; // [sp-4h] [bp-58h]@23 - int v24; // [sp-4h] [bp-58h]@26 - AIDirection a3; // [sp+Ch] [bp-48h]@10 - AIDirection pDir; // [sp+28h] [bp-2Ch]@10 - int v27; // [sp+44h] [bp-10h]@33 - unsigned int v28; // [sp+48h] [bp-Ch]@10 - TurnBased_QueueElem *v29; // [sp+4Ch] [bp-8h]@7 - unsigned int uActorID; // [sp+50h] [bp-4h]@2 - unsigned int a2a; // [sp+5Ch] [bp+8h]@7 - - __debugbreak();// - v2 = *(&this->field_0 + 4 * (a2 + 2)); - if (PID_TYPE(v2) == OBJECT_Player) - return 0; - uActorID = PID_ID(v2); - //uActorID = v3; - actor = &pActors[uActorID]; - //v5 = v4->uAIState; - if ( actor->uAIState == 5 || actor->uAIState == 4 || actor->uAIState == 11 || actor->uAIState == 19 || actor->uAIState == 17 ) - return 1; - v6 = &ai_near_actors_targets_pid[uActorID]; - v7 = &pTurnEngine->pQueue[a2]; - v8 = *v6; - v29 = &pTurnEngine->pQueue[a2]; - a2a = v8; - Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true); - if ( actor->pMonsterInfo.uHostilityType && !*v6 ) - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - v9 = Actor::GetDirectionInfo(v7->uPackedID, a2a, &a3, 0); - v10 = actor->uActorRadius; - memcpy(&a3, v9, sizeof(a3)); - memcpy(&pDir, &a3, sizeof(pDir)); - v11 = a3.uDistance - v10; - v28 = a3.uDistance - v10; - if ( ((a3.uDistance - v10) & 0x80000000u) != 0 ) - { - v11 = 0; - v28 = 0; - } - pHostileType = actor->pMonsterInfo.uHostilityType; - if ( pHostileType == 1 ) - { - if ( (double)(signed int)v28 >= 307.2 ) - goto LABEL_21; - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - goto LABEL_21; - } - if ( pHostileType == 2 ) - { - v14 = __OFSUB__(v11, 1024); - v13 = ((v11 - 1024) & 0x80000000u) != 0; - } - else - { - if ( pHostileType != 3 ) - goto LABEL_21; - v14 = __OFSUB__(v11, 2560); - v13 = ((v11 - 2560) & 0x80000000u) != 0; - } - if ( v13 ^ v14 ) - { - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - } -LABEL_21: - if ( (signed __int64)actor->pActorBuffs[4].uExpireTime > 0 ) - { - if ( (signed int)v11 < 10240 ) - { - Actor::AI_Flee(uActorID, a2a, 0, &pDir); - v29->field_C = 4; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - Actor::AI_4032B2(uActorID, a2a, 1024, 0); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - if ( actor->pMonsterInfo.uHostilityType != 4 ) - goto LABEL_46; - if ( !(actor->uAttributes & 0x020000) || actor->pMonsterInfo.uAIType == 1 ) - { - if ( actor->pMonsterInfo.uAIType == 1 ) - { - if ( actor->pMonsterInfo.uMovementType == 5 ) - { - Actor::AI_Stand(uActorID, a2a, 32, 0); - v29->field_C = 4; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - Actor::AI_Flee(uActorID, a2a, 32, 0); - v29->field_C = 4; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - if ( actor->pMonsterInfo.uAIType == 2 ) - { - v27 = actor->sCurrentHP; - v18 = (double)v27; - v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.2; - if ( v19 > v18 && (signed int)v11 < 10240 ) - { - if ( actor->pMonsterInfo.uMovementType == 5 ) - { - Actor::AI_Stand(uActorID, a2a, 32, 0); - v29->field_C = 4; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - Actor::AI_Flee(uActorID, a2a, 32, 0); - v29->field_C = 4; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - goto LABEL_39; - } - if ( actor->pMonsterInfo.uAIType == 3 ) - { - v27 = actor->sCurrentHP; - v18 = (double)v27; - v19 = (double)(signed int)actor->pMonsterInfo.uHP * 0.1; - if ( v19 > v18 && (signed int)v11 < 10240 ) - { - if ( actor->pMonsterInfo.uMovementType == 5 ) - { - Actor::AI_Stand(uActorID, a2a, 32, 0); - v29->field_C = 4; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - Actor::AI_Flee(uActorID, a2a, 32, 0); - v29->field_C = 4; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - goto LABEL_39; - } - } -LABEL_39: - if ( (double)(signed int)v28 < 307.2 ) - return 0; - if ( (signed int)v11 < 5120 ) - { - if ( actor->pMonsterInfo.uMissleAttack1Type && (signed int)v11 < 1024 ) - Actor::AI_Pursue1(uActorID, a2a, uActorID, 32, &pDir); - else - Actor::AI_Pursue2(uActorID, a2a, 32, &pDir, 307); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } -LABEL_46: - if ( !actor->pMonsterInfo.uMovementType ) - { - Actor::AI_4032B2(uActorID, a2a, 1024, 32); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - if ( actor->pMonsterInfo.uMovementType == 1 ) - { - Actor::AI_4032B2(uActorID, a2a, 2560, 32); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - if ( actor->pMonsterInfo.uMovementType == 2 ) - { - Actor::AI_4032B2(uActorID, a2a, 5120, 32); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - if ( actor->pMonsterInfo.uMovementType == 4 ) - { - Actor::AI_4032B2(uActorID, a2a, 10240, 32); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - if ( actor->pMonsterInfo.uMovementType == 5 ) - { - Actor::AI_Stand(uActorID, a2a, 32, 0); - v29->field_C = 2; - v29->uActionLength = actor->uCurrentActionLength; - return 1; - } - return 1; -} - -//----- (00406FA8) -------------------------------------------------------- -void stru262_TurnBased::_406FA8() -{ - unsigned __int8 v1; // zf@1 - unsigned __int8 v2; // sf@1 - TurnBased_QueueElem *v3; // edi@2 - int v4; // eax@4 - Actor *v5; // ebx@4 - unsigned __int16 v6; // cx@4 - unsigned int *v7; // edx@8 - unsigned int v8; // esi@8 - unsigned __int8 v9; // of@13 - AIDirection a3; // [sp+Ch] [bp-6Ch]@8 - AIDirection v11; // [sp+28h] [bp-50h]@8 - AIDirection a4; // [sp+44h] [bp-34h]@8 - stru262_TurnBased *v13; // [sp+60h] [bp-18h]@1 - TurnBased_QueueElem *v14; // [sp+64h] [bp-14h]@2 - int uActorID; // [sp+68h] [bp-10h]@4 - unsigned int a2; // [sp+6Ch] [bp-Ch]@8 - int v17; // [sp+70h] [bp-8h]@1 - unsigned int v18; // [sp+74h] [bp-4h]@2 - - v17 = 0; - v1 = this->uActorQueueSize == 0; - v2 = this->uActorQueueSize < 0; - v13 = this; - if ( !(v2 | v1) ) - { - v3 = this->pQueue; - v18 = (char *)&pTurnEngine - (char *)this; - v14 = this->pQueue; - do - { - if (PID_TYPE(v3->uPackedID) != OBJECT_Player) - { - v4 = PID_ID(v3->uPackedID); - uActorID = v4; - v5 = &pActors[v4]; - v6 = v5->uAIState; - if ( v6 != 5 ) - { - if ( v6 != 11 ) - { - if ( v6 != 19 ) - { - if ( v6 != 17 ) - { - v7 = (unsigned int *)&ai_near_actors_targets_pid[v4]; - a2 = *v7; - v8 = a2; - Actor::_SelectTarget(v4, (int *)v7, true); - memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(v11)); - memcpy(&a4, &v11, sizeof(a4)); - v5->uCurrentActionTime += pMiscTimer->uTimeElapsed; - if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength ) - { - if (v5->uAIState == Dying) - { - v5->uCurrentActionTime = 0; - v5->uCurrentActionLength = 0; - v5->uAIState = Dead; - v5->UpdateAnimation(); - return; - } - if ( rand() % 2 ) - Actor::AI_Stand(uActorID, a2, 0x40u, &a4); - else - Actor::AI_Bored(uActorID, a2, &a4); - } - } - } - } - } - } - ++v17; - v3 = v14 + 1; - v9 = __OFSUB__(v17, v13->uActorQueueSize); - v2 = v17 - v13->uActorQueueSize < 0; - ++v14; - } - while ( v2 ^ v9 ); - } -} //----- (004070EF) -------------------------------------------------------- bool __fastcall sub_4070EF_prolly_collide_objects(unsigned int uObjID, unsigned int uObj2ID)
--- a/mm7_6.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/mm7_6.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -6,7 +6,7 @@ - +#include "Weather.h" #include "Sprites.h" #include "BSPModel.h" #include "OutdoorCamera.h" @@ -3053,7 +3053,7 @@ break; if (pParty->bTurnBasedModeOn && pTurnEngine->field_4 == 3) { - pTurnEngine->field_18 |= 8u; + pTurnEngine->field_18 |= TE_FLAG_8; break; } if ( uActiveCharacter ) @@ -3073,7 +3073,7 @@ { if (pParty->bTurnBasedModeOn) { - if (pTurnEngine->field_4 == OBJECT_Actor || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) + if (pTurnEngine->field_4 == 3 || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) { pParty->bTurnBasedModeOn = 0; pTurnEngine->End(true); @@ -3091,7 +3091,7 @@ break; if (pParty->bTurnBasedModeOn && pTurnEngine->field_4 == 3) { - pTurnEngine->field_18 |= 8u; + pTurnEngine->field_18 |= TE_FLAG_8; break; } if ( !uActiveCharacter ) @@ -3120,7 +3120,7 @@ break; if (pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3) { - pTurnEngine->field_18 |= 8u; + pTurnEngine->field_18 |= TE_FLAG_8; break; } pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0);
--- a/mm7_data.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/mm7_data.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -33,8 +33,7 @@ #include "MapInfo.h" struct MapStats *pMapStats; -#include "TurnEngine.h" -struct stru262_TurnBased *pTurnEngine = new stru262_TurnBased; + #include "CastSpellInfo.h" std::array<CastSpellInfo, 10> pCastSpellInfo; @@ -53,7 +52,7 @@ stru298 stru_50FE08; // weak #include "Autonotes.h" -std::array<Autonote, 195> pAutonoteTxt; // weak +std::array<Autonote, 196> pAutonoteTxt; // weak #include "Awards.h" std::array<Award, 105> pAwards; @@ -383,18 +382,7 @@ char aIcons[777]; // idb char aPending[777]; // idb char aCanTFindS[777]; // idb -std::array<char *, 9> spellbook_texture_filename_suffices = {{"f", "a", "w", "e", "s", "m", "b", "l", "d"}}; // weak -//__int16 word_4E1D3A[777]; // weak -std::array<__int16, 6> pTownPortalBook_xs = {{260, 324, 147, 385, 390, 19}}; -std::array<__int16, 6> pTownPortalBook_ys = {{206, 84, 182, 239, 17, 283}}; -std::array<__int16, 6> pTownPortalBook_ws = {{ 80, 66, 68, 72, 67, 74}}; -std::array<__int16, 6> pTownPortalBook_hs = {{ 55, 56, 65, 67, 67, 59}}; - -std::array<unsigned int, 5> pLloydsBeaconsPreviewXs = {{61, 281, 61, 281, 171}}; // 004E249C -std::array<unsigned int, 5> pLloydsBeaconsPreviewYs = {{84, 84, 228, 228, 155}}; -std::array<unsigned int, 5> pLloydsBeacons_SomeXs = {{59, 279, 59, 279, 169}}; -std::array<unsigned int, 5> pLloydsBeacons_SomeYs = {{82, 82, 226, 226, 153}}; std::array<char, 7> aSbwb00; // weak char aW[2]; // idb char aA[2]; // idb @@ -1284,7 +1272,7 @@ char *dword_721664; // idb std::array<NPCTopic, 789> pNPCTopics; char *dword_722F10; // idb -std::array<const char *, 512> pQuestTable; +std::array<const char *, 513> pQuestTable; _UNKNOWN unk_723714; // weak char *dword_723718_autonote_related; // idb int dword_72371C[777]; // weak
--- a/mm7_data.h Fri Jul 05 21:15:53 2013 +0600 +++ b/mm7_data.h Fri Jul 05 21:16:12 2013 +0600 @@ -331,17 +331,9 @@ extern char aIcons[]; // idb extern char aPending[]; // idb extern char aCanTFindS[]; // idb -extern std::array<char *, 9> spellbook_texture_filename_suffices; // weak + extern __int16 word_4E1D3A[]; // weak -extern std::array<__int16, 6> pTownPortalBook_xs; -extern std::array<__int16, 6> pTownPortalBook_ys; -extern std::array<__int16, 6> pTownPortalBook_ws; -extern std::array<__int16, 6> pTownPortalBook_hs; -extern std::array<std::array<unsigned char, 12>, 9> pSpellbookSpellIndices; // 4E2430 from pSpellbookSpellIndices[9][12] -extern std::array<unsigned int, 5> pLloydsBeaconsPreviewXs; // 004E249C -extern std::array<unsigned int, 5> pLloydsBeaconsPreviewYs; -extern std::array<unsigned int, 5> pLloydsBeacons_SomeXs; -extern std::array<unsigned int, 5> pLloydsBeacons_SomeYs; // idb + extern std::array<char, 7> aSbwb00; // weak extern char aW[2]; // idb extern char aA[2]; // idb @@ -927,7 +919,7 @@ extern char *dword_721660; // idb extern char *dword_721664; // idb extern char *dword_722F10; // idb -extern std::array<const char *, 512> pQuestTable; +extern std::array<const char *, 513> pQuestTable; extern _UNKNOWN unk_723714; // weak extern char *dword_723718_autonote_related; // idb extern int dword_72371C[]; // weak
--- a/stru10.cpp Fri Jul 05 21:15:53 2013 +0600 +++ b/stru10.cpp Fri Jul 05 21:16:12 2013 +0600 @@ -184,35 +184,29 @@ } } - + RenderVertexSoft v1; // [sp+30Ch] [bp-54h]@24 + v1.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].x; + v1.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].y; + v1.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]].z; + memcpy(&pOutVertices[0], &v1, sizeof(RenderVertexSoft)); - auto p1 = &pIndoor->pVertices[pFace->pVertexIDs[x_min_idx]]; - RenderVertexSoft v1; // [sp+30Ch] [bp-54h]@24 - v1.vWorldPosition.x = (float)p1->x; - v1.vWorldPosition.y = (float)p1->y; - v1.vWorldPosition.z = (float)p1->z; - memcpy(pOutVertices + 0, &v1, sizeof(RenderVertexSoft)); - - auto p2 = &pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]]; RenderVertexSoft v2; // [sp+30Ch] [bp-54h]@24 - v2.vWorldPosition.x = (float)p2->x; - v2.vWorldPosition.y = (float)p2->y; - v2.vWorldPosition.z = (float)p2->z; - memcpy(pOutVertices + 1, &v2, sizeof(RenderVertexSoft)); + v2.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].x; + v2.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].y; + v2.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[y_min_idx]].z; + memcpy(&pOutVertices[1], &v2, sizeof(RenderVertexSoft)); - auto p3 = &pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]]; RenderVertexSoft v3; // [sp+30Ch] [bp-54h]@24 - v3.vWorldPosition.x = (float)p3->x; - v3.vWorldPosition.y = (float)p3->y; - v3.vWorldPosition.z = (float)p3->z; - memcpy(pOutVertices + 2, &v3, sizeof(RenderVertexSoft)); + v3.vWorldPosition.x = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].x; + v3.vWorldPosition.y = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].y; + v3.vWorldPosition.z = (float)pIndoor->pVertices[pFace->pVertexIDs[x_max_idx]].z; + memcpy(&pOutVertices[2], &v3, sizeof(RenderVertexSoft)); - auto p4 = &pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]]; RenderVertexSoft v4; // [sp+30Ch] [bp-54h]@24 - v4.vWorldPosition.x = (double)p4->x; - v4.vWorldPosition.y = (double)p4->y; - v4.vWorldPosition.z = (double)p4->z; - memcpy(pOutVertices + 3, &v4, sizeof(RenderVertexSoft)); + v4.vWorldPosition.x = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].x; + v4.vWorldPosition.y = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].y; + v4.vWorldPosition.z = (double)pIndoor->pVertices[pFace->pVertexIDs[y_max_idx]].z; + memcpy(&pOutVertices[3], &v4, sizeof(RenderVertexSoft)); } @@ -259,7 +253,7 @@ switch (pFace->uPolygonType) { case POLYGON_VerticalWall: - a1.x = -pFace->pFacePlane.vNormal.y; + a1.x = -pFace->pFacePlane.vNormal.y;// a1.y = pFace->pFacePlane.vNormal.x; a1.z = 0.0f; a1.Normalize(); @@ -300,12 +294,12 @@ } if (pFace->uAttributes & 0x0200) { - face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2; + face_center_x = (pFaceLimits[0].vWorldPosition.x + pFaceLimits[2].vWorldPosition.x) / 2;// face_center_y = (pFaceLimits[0].vWorldPosition.y + pFaceLimits[2].vWorldPosition.y) / 2; face_center_z = (pFaceLimits[1].vWorldPosition.z + pFaceLimits[3].vWorldPosition.z) / 2; - a3 = face_center_x - pFaceLimits[0].vWorldPosition.x; - var_8 = face_center_z - pFaceLimits[1].vWorldPosition.z; + a3 = face_center_x - pFaceLimits[0].vWorldPosition.x;// + var_8 = face_center_z - pFaceLimits[1].vWorldPosition.z;// if (pFace->uPolygonType == POLYGON_VerticalWall) a3 /= a1.x; @@ -680,9 +674,9 @@ (v25.vWorldPosition.z - pBLVRenderParams->vPartyPos.z) * a1.z; if (fabs(_dp) < 1e-6f) { - memcpy(&v25, pOutBounding + 1, sizeof(RenderVertexSoft)); - memcpy(pOutBounding + 1, pOutBounding + 3, sizeof(RenderVertexSoft)); - memcpy(pOutBounding + 3, &v25, sizeof(RenderVertexSoft)); + memcpy(&v25, &pOutBounding[1], sizeof(RenderVertexSoft)); + memcpy(&pOutBounding[1], &pOutBounding[3], sizeof(RenderVertexSoft)); + memcpy(&pOutBounding[3], &v25, sizeof(RenderVertexSoft)); } //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) @@ -694,10 +688,10 @@ v26.vWorldPosition.y = pParty->vPosition.y; v26.vWorldPosition.z = pParty->vPosition.z + pParty->sEyelevel; // frustum - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, pOutBounding, 0xFF0000u, 0, 0); - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, pOutBounding + 1, 0xFF00u, 0, 0); - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, pOutBounding + 2, 0xFFu, 0, 0); - pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, pOutBounding + 3, 0xFFFFFFu, 0, 0); + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF0000u, &pOutBounding[0], 0xFF0000u, 0, 0); + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFF00u, &pOutBounding[1], 0xFF00u, 0, 0); + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFu, &pOutBounding[2], 0xFFu, 0, 0); + pGame->pIndoorCameraD3D->do_draw_debug_line_sw(&v26, 0xFFFFFFu, &pOutBounding[3], 0xFFFFFFu, 0, 0); bDoNotDrawPortalFrustum = true; } pGame->pIndoorCameraD3D->debug_outline_sw(pOutBounding, uNumVertices, 0x1EFF1Eu, 0.00019999999); // bounding @@ -767,61 +761,62 @@ // 4D864C: using guessed type char byte_4D864C; //----- (0049C681) -------------------------------------------------------- -bool stru10::CalcPortalShape(BLVFace *pFace, IndoorCameraD3D_Vec4 *a3, RenderVertexSoft *pOutBounding) +bool stru10::CalcPortalShape(BLVFace *pFace, IndoorCameraD3D_Vec4 *pPortalDataFrustum, RenderVertexSoft *pOutBounding) { RenderVertexSoft pLimits[4]; // [sp+Ch] [bp-C0h]@1 - CalcPolygonLimits(pFace, pLimits); + CalcPolygonLimits(pFace, pLimits);// //if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_DRAW_BLV_DEBUGS) // pGame->pIndoorCameraD3D->debug_outline_sw(pLimits, 4, 0xFF1E1E, 0.000099999997); if (CalcFaceBounding(pFace, pLimits, 4, pOutBounding)) - return _49C720(pOutBounding, a3) != 0; + return _49C720(pOutBounding, pPortalDataFrustum) != 0; return false; } + // 4D864C: using guessed type char byte_4D864C; //----- (0049C720) -------------------------------------------------------- -char stru10::_49C720(RenderVertexSoft *pFaceBounding, IndoorCameraD3D_Vec4 *a4) +char stru10::_49C720(RenderVertexSoft *pFaceBounding, IndoorCameraD3D_Vec4 *pPortalDataFrustum) { - Vec3_float_ a3; // [sp+4h] [bp-34h]@1 - a3.x = (double)pBLVRenderParams->vPartyPos.x; - a3.y = (double)pBLVRenderParams->vPartyPos.y; - a3.z = (double)pBLVRenderParams->vPartyPos.z; + Vec3_float_ pRayStart; // [sp+4h] [bp-34h]@1 + pRayStart.x = (double)pBLVRenderParams->vPartyPos.x; + pRayStart.y = (double)pBLVRenderParams->vPartyPos.y; + pRayStart.z = (double)pBLVRenderParams->vPartyPos.z; - if (FindFaceNormal(pFaceBounding, pFaceBounding + 1, &a3, a4) && - FindFaceNormal(pFaceBounding + 1, pFaceBounding + 2, &a3, a4 + 1) && - FindFaceNormal(pFaceBounding + 2, pFaceBounding + 3, &a3, a4 + 2) && - FindFaceNormal(pFaceBounding + 3, pFaceBounding, &a3, a4 + 3)) + if (FindFaceNormal(&pFaceBounding[0], &pFaceBounding[1], &pRayStart, &pPortalDataFrustum[0]) && + FindFaceNormal(&pFaceBounding[1], &pFaceBounding[2], &pRayStart, &pPortalDataFrustum[1]) && + FindFaceNormal(&pFaceBounding[2], &pFaceBounding[3], &pRayStart, &pPortalDataFrustum[2]) && + FindFaceNormal(&pFaceBounding[3], &pFaceBounding[0], &pRayStart, &pPortalDataFrustum[3])) return true; return false; } //----- (0049C7C5) -------------------------------------------------------- -bool stru10::FindFaceNormal(RenderVertexSoft *a1, RenderVertexSoft *a2, Vec3_float_ *a3, IndoorCameraD3D_Vec4 *a4) +bool stru10::FindFaceNormal(RenderVertexSoft *pFaceBounding1, RenderVertexSoft *pFaceBounding2, Vec3_float_ *pRayStart, IndoorCameraD3D_Vec4 *pPortalDataFrustum) { - Vec3_float_ v1; // [sp+4h] [bp-48h]@1 - Vec3_float_ v2; // [sp+10h] [bp-3Ch]@1 + Vec3_float_ ray_dir; // [sp+4h] [bp-48h]@1 + Vec3_float_ pRay2; // [sp+10h] [bp-3Ch]@1 - v1.x = a1->vWorldPosition.x - a3->x; - v1.y = a1->vWorldPosition.y - a3->y; - v1.z = a1->vWorldPosition.z - a3->z; - Vec3_float_::Cross(&v1, &v2, a2->vWorldPosition.x - a1->vWorldPosition.x, - a2->vWorldPosition.y - a1->vWorldPosition.y, - a2->vWorldPosition.z - a1->vWorldPosition.z); + ray_dir.x = pFaceBounding1->vWorldPosition.x - pRayStart->x;//get ray for cmera to bounding1 + ray_dir.y = pFaceBounding1->vWorldPosition.y - pRayStart->y; + ray_dir.z = pFaceBounding1->vWorldPosition.z - pRayStart->z; + Vec3_float_::Cross(&ray_dir, &pRay2, pFaceBounding2->vWorldPosition.x - pFaceBounding1->vWorldPosition.x, + pFaceBounding2->vWorldPosition.y - pFaceBounding1->vWorldPosition.y, + pFaceBounding2->vWorldPosition.z - pFaceBounding1->vWorldPosition.z); - float sqr_mag = v2.x * v2.x + v2.y * v2.y + v2.z * v2.z; + float sqr_mag = pRay2.x * pRay2.x + pRay2.y * pRay2.y + pRay2.z * pRay2.z; if (fabsf(sqr_mag) > 1e-6f) { float inv_mag = 1.0f / sqrtf(sqr_mag); - v2.x *= inv_mag; - v2.y *= inv_mag; - v2.z *= inv_mag; - //v2.Normalize(); + pRay2.x *= inv_mag; + pRay2.y *= inv_mag; + pRay2.z *= inv_mag; + pRay2.Normalize(); - a4->x = v2.x; - a4->y = v2.y; - a4->z = v2.z; - a4->dot = a3->z * v2.z + a3->y * v2.y + a3->x * v2.x; + pPortalDataFrustum->x = pRay2.x; + pPortalDataFrustum->y = pRay2.y; + pPortalDataFrustum->z = pRay2.z; + pPortalDataFrustum->dot = pRayStart->z * pRay2.z + pRayStart->y * pRay2.y + pRayStart->x * pRay2.x; return true; } return false;
--- a/stru10.h Fri Jul 05 21:15:53 2013 +0600 +++ b/stru10.h Fri Jul 05 21:16:12 2013 +0600 @@ -8,9 +8,9 @@ stru10(); virtual ~stru10(); char _49C5DA(struct BLVFace *pFace, struct RenderVertexSoft *pVertices, unsigned int *pNumVertices, struct IndoorCameraD3D_Vec4 *a5, struct RenderVertexSoft *pOutBounding); - bool CalcPortalShape(struct BLVFace *pFace, struct IndoorCameraD3D_Vec4 *a3, struct RenderVertexSoft *pOutBounding); - char _49C720(struct RenderVertexSoft *pFaceBounding, struct IndoorCameraD3D_Vec4 *a4); - bool FindFaceNormal(struct RenderVertexSoft *a1, struct RenderVertexSoft *a2, struct Vec3_float_ *a3, struct IndoorCameraD3D_Vec4 *a4); + bool CalcPortalShape(struct BLVFace *pFace, struct IndoorCameraD3D_Vec4 *pPortalDataFrustum, struct RenderVertexSoft *pOutBounding); + char _49C720(struct RenderVertexSoft *pFaceBounding, struct IndoorCameraD3D_Vec4 *pPortalDataFrustum); + bool FindFaceNormal(struct RenderVertexSoft *pFaceBounding1, struct RenderVertexSoft *pFaceBounding2, struct Vec3_float_ *pRayStart, struct IndoorCameraD3D_Vec4 *pPortalDataFrustum); bool FindFacePlane(struct RenderVertexSoft *face, struct Vec3_float_ *out_normal, float *out_distance); bool CalcFaceBounding(struct BLVFace *pFace, struct RenderVertexSoft *pFaceLimits, unsigned int uNumVertices, struct RenderVertexSoft *pOutBounding); void CalcPolygonLimits(struct BLVFace *pFace, struct RenderVertexSoft pOutVertices[4]);