Mercurial > mm7
changeset 1449:27b7ee003c7c
Merge
author | Gloval |
---|---|
date | Tue, 06 Aug 2013 00:56:33 +0400 |
parents | 5a5d0c713d47 (current diff) 0c462cc807a1 (diff) |
children | 8ff3c675a726 9add223260ce |
files | Actor.cpp CastSpellInfo.cpp Game.cpp Player.cpp mm7_5.cpp mm7_6.cpp stru11.h stru12.h stru220.h |
diffstat | 86 files changed, 18764 insertions(+), 20254 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Actor.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -3041,7 +3041,7 @@ //----- (00402CED) -------------------------------------------------------- void Actor::PlaySound(unsigned int uActorID, unsigned int uSoundID) { - Actor *v2; // eax@1 + //Actor *v2; // eax@1 unsigned __int16 v3; // dx@1 int v4; // eax@3 int v5; // eax@4 @@ -3053,19 +3053,18 @@ unsigned int v11; // [sp-Ch] [bp-10h]@10 int v12; // [sp-8h] [bp-Ch]@10 - v2 = &pActors[uActorID]; - v3 = v2->pSoundSampleIDs[uSoundID]; + //v2 = &pActors[uActorID]; + v3 = pActors[uActorID].pSoundSampleIDs[uSoundID]; if ( v3 ) { - if ( (signed __int64)v2->pActorBuffs[3].uExpireTime <= 0 ) + if ( (signed __int64)pActors[uActorID].pActorBuffs[3].uExpireTime <= 0 ) { v12 = 0; - v8 = -1; } else { - v4 = v2->pActorBuffs[3].uPower - 2; + v4 = pActors[uActorID].pActorBuffs[3].uPower - 2; if ( v4 ) { v5 = v4 - 1; @@ -3086,7 +3085,6 @@ v6 = 33075; } v12 = v6; - v8 = 0; } pAudioPlayer->PlaySound((SoundID)(signed __int16)v3, PID(OBJECT_Actor, uActorID), 0, v8, 0, 0, 0, v12); @@ -5051,7 +5049,7 @@ v59 = 1; if ( player->HasItemEquipped(EQUIP_MAIN_HAND) ) { - auto main_hand_skill = pItemsTable->pItems[player->pInventoryItems[main_hand_idx - 1].uItemID].uSkillType; + auto main_hand_skill = pItemsTable->pItems[player->pInventoryItemList[main_hand_idx - 1].uItemID].uSkillType; //v55 = pItemsTable->pItems[player->pInventoryItems[main_hand_idx - 1].uItemID].uSkillType; //v28 = SkillToMastery(player->pActiveSkills[v55]); auto main_hand_mastery = SkillToMastery(player->pActiveSkills[main_hand_skill]); @@ -5260,7 +5258,7 @@ { if ( player->HasItemEquipped((ITEM_EQUIP_TYPE)v59) ) { - auto _s = (ItemGen *)&player->pInventoryItems[v57->uShield - 1]; + auto _s = (ItemGen *)&player->pInventoryItemList[v57->uShield - 1]; a4 = _s->_439DF3_get_additional_damage(&a2, &v62); if ( v62 && pMonster->sCurrentHP > 0 ) {
--- a/Arcomage.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Arcomage.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -68,6 +68,12 @@ int rand_interval(int min, int max); // idb void __fastcall intToString(int val, char *pOut); +//----- (0040DEDB) -------------------------------------------------------- +unsigned int R8G8B8_to_TargetFormat(int uColor) +{ + return TargetColor(LOBYTE(uColor), BYTE1(uColor), BYTE2(uColor)); +} + /* 388 */ #pragma pack(push, 1) struct ArcomageStartConditions
--- a/AudioPlayer.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/AudioPlayer.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -5,8 +5,6 @@ #include <string> #include <assert.h> -#include "stru11.h" - #include "mm7_data.h" #include "VideoPlayer.h" #include "AudioPlayer.h" @@ -69,8 +67,6 @@ //----- (004A9953) -------------------------------------------------------- void SoundList::Initialize() { - SoundList *pSoundList; // esi@1 - signed int v2; // edi@2 SoundDesc *pSoundDesc; // eax@5 void *pSoundData; // ebx@7 unsigned int uSoundSize; // eax@7 @@ -80,72 +76,52 @@ char pSoundName[120]; // [sp+4h] [bp-A4h]@4 AILSOUNDINFO pInfo; // [sp+7Ch] [bp-2Ch]@10 int v12; // [sp+A0h] [bp-8h]@12 - int a2; // [sp+A4h] [bp-4h]@1 - pSoundList = this; - a2 = 1; if ( sNumSounds > 1 ) { - v2 = 1; - //while ( 1 ) - do + for ( uint i = 1; i < pSoundList->sNumSounds; ++i ) { - sprintf(pSoundName, "%s", pSounds[v2].pSoundName); - // pSoundList->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[v2].uSoundID); //Ritor1: it's error - result: no sound - pSoundDesc = &pSoundList->pSounds[v2]; - if ( pSoundList->pSounds[v2].eType != SOUND_DESC_SYSTEM || (sprintf(pSoundName, "%s", pSounds[v2].pSoundName), - pSoundList->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[v2].uSoundID), + sprintf(pSoundName, "%s", pSounds[i].pSoundName); + pSoundDesc = &pSoundList->pSounds[i]; + if ( pSoundList->pSounds[i].eType != SOUND_DESC_SYSTEM || (sprintf(pSoundName, "%s", pSounds[i].pSoundName), + pSoundList->pSounds[i].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[i].uSoundID), !pAudioPlayer->b3DSoundInitialized) - || (pSoundDesc = &pSoundList->pSounds[v2], !(pSoundDesc->uFlags & SOUND_DESC_SWAP)) - || !pSoundDesc->pSoundData[0] ) // нужно перевернуть - goto LABEL_17; + || (pSoundDesc = &pSoundList->pSounds[i], !(pSoundDesc->uFlags & SOUND_DESC_SWAP)) + || !pSoundDesc->pSoundData[0] ) + continue; pSoundData = pSoundDesc->pSoundData[0]; uSoundSize = *(int *)pSoundData; pSoundBytes = (char *)pSoundData + 4; pType = AIL_file_type(pSoundBytes, uSoundSize); if ( !pType ) - //goto LABEL_15; - { - pSoundList->pSounds[v2].bDecompressed = false; - goto LABEL_16; - } + { + pSoundList->pSounds[i].bDecompressed = false; + pSoundList->UnloadSound(i, 1); + continue; + } v8 = pType - 1; if ( v8 ) - { - /*break; - pSoundList->pSounds[v2].p3DSound = pSoundList->pSounds[v2].pSoundData[0]; -LABEL_16: - pSoundList->_4A9DCD(a2, 1); -LABEL_17: - ++a2; - ++v2; - if ( a2 >= (signed int)pSoundList->uNumSounds ) - return; - }*/ - if ( v8 == 1 ) { - if ( AIL_WAV_info(pSoundBytes, &pInfo) && pInfo.uChannels != 2 ) + if ( v8 == 1 ) { - if ( !AIL_decompress_ADPCM(&pInfo, &pSoundList->pSounds[v2].p3DSound, &v12) ) + if ( AIL_WAV_info(pSoundBytes, &pInfo) && pInfo.uChannels != 2 ) { - pSoundList->pSounds[v2].p3DSound = 0; - pSoundList->pSounds[v2].bDecompressed = true; + if ( !AIL_decompress_ADPCM(&pInfo, &pSoundList->pSounds[i].p3DSound, &v12) ) + { + pSoundList->pSounds[i].p3DSound = 0; + pSoundList->pSounds[i].bDecompressed = true; + } } + pSoundList->UnloadSound(i, 1); + continue; } - goto LABEL_16; + pSoundList->pSounds[i].bDecompressed = false; + pSoundList->UnloadSound(i, 1); + continue; } -//LABEL_15: - pSoundList->pSounds[v2].bDecompressed = false; - goto LABEL_16; + pSoundList->pSounds[i].p3DSound = pSoundList->pSounds[i].pSoundData[0]; + pSoundList->UnloadSound(i, 1); } - pSoundList->pSounds[v2].p3DSound = pSoundList->pSounds[v2].pSoundData[0]; -LABEL_16: - pSoundList->UnloadSound(a2, 1); -LABEL_17: - ++a2; - ++v2; - } - while ( a2 < pSoundList->sNumSounds ); } } @@ -320,32 +296,23 @@ //----- (004A9D3E) -------------------------------------------------------- SoundDesc *SoundList::Release() { - SoundList *v1; // esi@1 - signed int v2; // ebx@1 - int v3; // edi@2 SoundDesc *result; // eax@3 void *v5; // ecx@3 - v1 = this; - v2 = 0; if ( (signed int)this->sNumSounds > 0 ) { - v3 = 0; - do + for ( uint i = 0; i < (signed int)this->sNumSounds; ++i ) { - result = v1->pSounds; - v5 = result[v3].pSoundData[0]; + result = this->pSounds; + v5 = result[i].pSoundData[0]; if ( v5 ) { ReleaseSoundData(v5); - v1->pSounds[v3].pSoundData[0] = 0; - result = (SoundDesc *)((char *)&v1->pSounds[v3] + 40); + this->pSounds[i].pSoundData[0] = 0; + result = (SoundDesc *)((char *)&this->pSounds[i] + 40); *(int *)&result->pSoundName[0] &= 0xFFFFFFFEu; } - ++v2; - ++v3; } - while ( v2 < (signed int)v1->sNumSounds ); } return result; } @@ -568,57 +535,39 @@ //----- (004AA258) -------------------------------------------------------- void AudioPlayer::_4AA258(int a2) { - AudioPlayer *v2; // esi@1 - int v3; // edi@4 - AudioPlayer_3DSample *v4; // ebx@5 - int v5; // ebx@11 - MixerChannel *v6; // edi@12 + if (!bPlayerReady) + return; - v2 = this; - if ( this->bPlayerReady ) - { - if ( this->b3DSoundInitialized && a2 && (v3 = 0, this->uNum3DSamples > 0) ) + if ( this->b3DSoundInitialized && a2 && this->uNum3DSamples > 0 ) { - v4 = this->p3DSamples; - while ( v4->field_4 != a2 || AIL_3D_sample_status(v4->hSample) != 4 ) + for ( uint i = 0; i < this->uNum3DSamples; ++i ) { - ++v3; - ++v4; - if ( v3 >= v2->uNum3DSamples ) - goto LABEL_9; + if ( this->p3DSamples[i].field_4 == a2 && AIL_3D_sample_status(this->p3DSamples[i].hSample) == 4 ) + AIL_end_3D_sample(this->p3DSamples[i].hSample); } - AIL_end_3D_sample(v2->p3DSamples[v3].hSample); + goto LABEL_9; } else { LABEL_9: - if ( v2->hDigDriver ) + if ( this->hDigDriver ) { - if ( a2 ) + if ( a2 && this->uMixerChannels > 0 ) { - v5 = 0; - if ( v2->uMixerChannels > 0 ) + for ( uint i = 0; i < this->uMixerChannels; ++i ) { - v6 = v2->pMixerChannels; - do + if ( this->pMixerChannels[i].source_pid == a2 ) { - if ( v6->source_pid == a2 ) + if ( AIL_sample_status(this->pMixerChannels[i].hSample) == AIL::Sample::Playing) { - if ( AIL_sample_status(v6->hSample) == AIL::Sample::Playing) - { - AIL_end_sample(v6->hSample); - FreeChannel(v6); - } + AIL_end_sample(this->pMixerChannels[i].hSample); + FreeChannel(&this->pMixerChannels[i]); } - ++v5; - ++v6; } - while ( v5 < v2->uMixerChannels ); } } } } - } } //----- (004AA306) -------------------------------------------------------- @@ -849,12 +798,6 @@ } } } - - - - - - LABEL_123: for (uint i = 0; i < uMixerChannels; ++i) { @@ -864,12 +807,10 @@ { if (channel->uSourceTrackIdx == sound_id) return; // already playing the same sound from the same source - return - AIL_end_sample(channel->hSample); // requested new sound from the same source - end & switch FreeChannel(channel); } } - LABEL_133: v62 = start_channel; //pAudioPlayer4 = pAudioPlayer; @@ -1042,9 +983,6 @@ return; } - - - __debugbreak(); // 3d sound stuff, refactor v12 = 13; if ( a3 < 0 ) @@ -1349,7 +1287,6 @@ { pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; v43 = (double)pParty->vPosition.y; -LABEL_100: pRenderVertexSoft.vWorldPosition.y = v43; v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; goto LABEL_101; @@ -1363,7 +1300,9 @@ } pRenderVertexSoft.vWorldPosition.x = (double)PartyX; v43 = (double)PartyY; - goto LABEL_100; + pRenderVertexSoft.vWorldPosition.y = v43; + v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; + goto LABEL_101; } } } @@ -1375,7 +1314,6 @@ } - //----- (004AAFCF) -------------------------------------------------------- void AudioPlayer::UpdateSounds() { @@ -1393,7 +1331,7 @@ SpriteObject *v12; // eax@14 Actor *v13; // eax@15 signed int v14; // edx@15 - BLVDoor *v15; // eax@19 + BLVDoor *pDoor; // eax@19 double v16; // st7@22 double v17; // st6@22 double v18; // st5@23 @@ -1456,181 +1394,172 @@ return; } - //v3 = this->b3DSoundInitialized == 0; - if (b3DSoundInitialized) + //v3 = this->b3DSoundInitialized == 0; + if ( b3DSoundInitialized ) + { + __debugbreak(); // refactor refactor + //v3 = this->uNum3DSamples == 0; + //v5 = this->uNum3DSamples < 0; + v59 = 0; + if (uNum3DSamples > 0) + { + v6 = this->p3DSamples; + while ( 1 ) { - __debugbreak(); // refactor refactor - //v3 = this->uNum3DSamples == 0; - //v5 = this->uNum3DSamples < 0; - v59 = 0; - if (uNum3DSamples > 0) + v7 = PID_TYPE(v6->field_4); + if ( AIL_3D_sample_status(v6->hSample) == 2 ) + { + AIL_end_3D_sample(v6->hSample); + pAudioPlayer->_4ABF23(v6); + } + if ( AIL_3D_sample_status(v6->hSample) != 4 ) + goto LABEL_35; + v8 = v7 - 1;// + if ( v8 )//> 1 + break; + if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )//==1 + goto LABEL_31; + pDoor = &pIndoor->pDoors[PID_ID(v6->field_4)]; + if ( pDoor->uDoorID ) + { + uNumRepeats = *pDoor->pXOffsets; + a1.vWorldPosition.x = (double)uNumRepeats; + uNumRepeats = *pDoor->pYOffsets; + a1.vWorldPosition.y = (double)uNumRepeats; + uNumRepeats = *pDoor->pZOffsets; + v11 = (double)uNumRepeats; + goto LABEL_21; + } +LABEL_35: + ++v59; + ++v6; + if ( v59 >= pAudioPlayer->uNum3DSamples ) + { + v2 = 0; + goto LABEL_37; + } + } + + v9 = v8 - 1;// + if ( v9 )//> 2 + { + v10 = v9 - 1;// + if ( !v10 )//3 { - v6 = this->p3DSamples; - while ( 1 ) + v13 = &pActors[PID_ID(v6->field_4)]; + uNumRepeats = v13->vPosition.x; + v14 = v13->vPosition.y; + a1.vWorldPosition.x = (double)uNumRepeats; + uNumRepeats = v13->vPosition.z; + a1.vWorldPosition.y = (double)v14; + v11 = (double)uNumRepeats; + goto LABEL_21; + } + if ( v10 != 2 )//4 + { + a1.vWorldPosition.x = (double)pParty->vPosition.x; + a1.vWorldPosition.y = (double)pParty->vPosition.y; + v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; + goto LABEL_21; + }//5 + v12 = (SpriteObject *)&pLevelDecorations[PID_ID(v6->field_4)]; + } + else//2 + { + v12 = &pSpriteObjects[PID_ID(v6->field_4)]; + } + a1.vWorldPosition.x = (double)v12->vPosition.x; + a1.vWorldPosition.y = (double)v12->vPosition.y; + v11 = (double)v12->vPosition.z; +LABEL_21: + a1.vWorldPosition.z = v11; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + v16 = pBLVRenderParams->fCosineNegX; + v17 = pBLVRenderParams->fSineNegX; + v55 = pBLVRenderParams->fCosineY; + v56 = pBLVRenderParams->fSineY; + if ( pBLVRenderParams->sPartyRotX ) + { + v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x; + *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y; + v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z; + if ( pRenderer->pRenderD3D ) { - v7 = PID_TYPE(v6->field_4); - if ( AIL_3D_sample_status(v6->hSample) == 2 ) - { - AIL_end_3D_sample(v6->hSample); - pAudioPlayer->_4ABF23(v6); - } - if ( AIL_3D_sample_status(v6->hSample) != 4 ) - goto LABEL_35; - v8 = v7 - 1; - if ( v8 ) - break; - if ( uCurrentlyLoadedLevelType != LEVEL_Indoor ) - goto LABEL_31; - v15 = &pIndoor->pDoors[PID_ID(v6->field_4)]; - if ( v15->uDoorID ) - { - uNumRepeats = *v15->pXOffsets; - a1.vWorldPosition.x = (double)uNumRepeats; - uNumRepeats = *v15->pYOffsets; - a1.vWorldPosition.y = (double)uNumRepeats; - uNumRepeats = *v15->pZOffsets; - v11 = (double)uNumRepeats; - goto LABEL_21; - } -LABEL_35: - ++v59; - ++v6; - if ( v59 >= pAudioPlayer->uNum3DSamples ) - { - v2 = 0; - goto LABEL_37; - } - } - - v9 = v8 - 1; - if ( v9 ) - { - v10 = v9 - 1; - if ( !v10 ) - { - v13 = &pActors[PID_ID(v6->field_4)]; - uNumRepeats = v13->vPosition.x; - v14 = v13->vPosition.y; - a1.vWorldPosition.x = (double)uNumRepeats; - uNumRepeats = v13->vPosition.z; - a1.vWorldPosition.y = (double)v14; - v11 = (double)uNumRepeats; - goto LABEL_21; - } - if ( v10 != 2 ) - { - a1.vWorldPosition.x = (double)pParty->vPosition.x; - a1.vWorldPosition.y = (double)pParty->vPosition.y; - v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; - goto LABEL_21; - } - v12 = (SpriteObject *)&pLevelDecorations[PID_ID(v6->field_4)]; + v19 = *(float *)&uNumRepeats * v56 + v58 * v55; + v20 = v58 * v56 - *(float *)&uNumRepeats * v55; } else { - v12 = &pSpriteObjects[PID_ID(v6->field_4)]; + v19 = v58 * v55 - *(float *)&uNumRepeats * v56; + v20 = v58 * v56 + *(float *)&uNumRepeats * v55; } - a1.vWorldPosition.x = (double)v12->vPosition.x; - a1.vWorldPosition.y = (double)v12->vPosition.y; - v11 = (double)v12->vPosition.z; -LABEL_21: - a1.vWorldPosition.z = v11; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + a1.vWorldViewPosition.x = v19 * v16 - v18 * v17; + a1.vWorldViewPosition.y = v20; + a1.vWorldViewPosition.z = v19 * v17 + v18 * v16; + } + else + { + v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x; + *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y; + if ( pRenderer->pRenderD3D ) { - v16 = pBLVRenderParams->fCosineNegX; - v17 = pBLVRenderParams->fSineNegX; - v55 = pBLVRenderParams->fCosineY; - v56 = pBLVRenderParams->fSineY; - if ( pBLVRenderParams->sPartyRotX ) - { - v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x; - *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y; - v18 = a1.vWorldPosition.z - (double)pParty->vPosition.z; - if ( pRenderer->pRenderD3D ) - { - v19 = *(float *)&uNumRepeats * v56 + v58 * v55; - v20 = v58 * v56 - *(float *)&uNumRepeats * v55; - } - else - { - v19 = v58 * v55 - *(float *)&uNumRepeats * v56; - v20 = v58 * v56 + *(float *)&uNumRepeats * v55; - } - a1.vWorldViewPosition.x = v19 * v16 - v18 * v17; - a1.vWorldViewPosition.y = v20; - a1.vWorldViewPosition.z = v19 * v17 + v18 * v16; - } - else - { - v58 = a1.vWorldPosition.x - (double)pParty->vPosition.x; - *(float *)&uNumRepeats = a1.vWorldPosition.y - (double)pParty->vPosition.y; - if ( pRenderer->pRenderD3D ) - { - a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55; - v21 = v58 * v56 - *(float *)&uNumRepeats * v55; - } - else - { - a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56; - v21 = v58 * v56 + *(float *)&uNumRepeats * v55; - } - a1.vWorldViewPosition.y = v21; - a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z; - } + a1.vWorldViewPosition.x = *(float *)&uNumRepeats * v56 + v58 * v55; + v21 = v58 * v56 - *(float *)&uNumRepeats * v55; } else { -LABEL_31: - pGame->pIndoorCameraD3D->ViewTransform(&a1, 1u); + a1.vWorldViewPosition.x = v58 * v55 - *(float *)&uNumRepeats * v56; + v21 = v58 * v56 + *(float *)&uNumRepeats * v55; } - v58 = a1.vWorldViewPosition.y * -0.012207031; - v22 = a1.vWorldViewPosition.x * 0.012207031; - *(float *)&uNumRepeats = v22; - v23 = abs((signed __int64)v22); - v24 = abs(0); - v25 = abs((signed __int64)v58); - if ( int_get_vector_length(v25, v24, v23) <= 100 ) - { - AIL_set_3D_position(v6->hSample, LODWORD(v58), 0.0, uNumRepeats); - v26 = -*(float *)&uNumRepeats; - v27 = -v58; - AIL_set_3D_orientation(v6->hSample, LODWORD(v27), 0.0, LODWORD(v26), 0.0, 1.0, 0.0); - } - else - { - AIL_end_3D_sample(v6->hSample); - pAudioPlayer->_4ABF23(v6); - } - goto LABEL_35; + a1.vWorldViewPosition.y = v21; + a1.vWorldViewPosition.z = a1.vWorldPosition.z - (double)pParty->vPosition.z; } } - - - - - - + else + { +LABEL_31: + pGame->pIndoorCameraD3D->ViewTransform(&a1, 1u); + } + v58 = a1.vWorldViewPosition.y * -0.012207031; + v22 = a1.vWorldViewPosition.x * 0.012207031; + *(float *)&uNumRepeats = v22; + v23 = abs((signed __int64)v22); + v24 = abs(0); + v25 = abs((signed __int64)v58); + if ( int_get_vector_length(v25, v24, v23) <= 100 ) + { + AIL_set_3D_position(v6->hSample, LODWORD(v58), 0.0, uNumRepeats); + v26 = -*(float *)&uNumRepeats; + v27 = -v58; + AIL_set_3D_orientation(v6->hSample, LODWORD(v27), 0.0, LODWORD(v26), 0.0, 1.0, 0.0); + } + else + { + AIL_end_3D_sample(v6->hSample); + pAudioPlayer->_4ABF23(v6); + } + goto LABEL_35; + } + } LABEL_37: for (uint i = 0; i < uMixerChannels; ++i) { - auto channel = pMixerChannels + i; - - if (AIL_sample_status(channel->hSample) == AIL::Sample::Done) + if (AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Done) { - AIL_end_sample(channel->hSample); - FreeChannel(channel); + AIL_end_sample(pMixerChannels[i].hSample); + FreeChannel(&pMixerChannels[i]); } } for (uint i = 0; i < uMixerChannels; ++i) { - auto channel = pMixerChannels + i; - if (channel->source_pid <= 0) + if (pMixerChannels[i].source_pid <= 0) continue; - int source_type = PID_TYPE(channel->source_pid), - source_id = PID_ID(channel->source_pid); + int source_type = PID_TYPE(pMixerChannels[i].source_pid), + source_id = PID_ID(pMixerChannels[i].source_pid); int source_x, source_y, source_z; @@ -1647,46 +1576,42 @@ assert(uCurrentlyLoadedLevelType == LEVEL_Indoor); assert(source_id < pIndoor->uNumDoors); - auto door = pIndoor->pDoors + source_id; - if (!door->uDoorID) + if (!pIndoor->pDoors[source_id].uDoorID) continue; - source_x = door->pXOffsets[0]; - source_y = door->pYOffsets[0]; - source_z = door->pZOffsets[0]; + source_x = pIndoor->pDoors[source_id].pXOffsets[0]; + source_y = pIndoor->pDoors[source_id].pYOffsets[0]; + source_z = pIndoor->pDoors[source_id].pZOffsets[0]; } break; case OBJECT_Item: { assert(source_id < uNumSpriteObjects); - auto object = &pSpriteObjects[source_id]; - source_x = object->vPosition.x; - source_y = object->vPosition.y; - source_z = object->vPosition.z; + source_x = pSpriteObjects[source_id].vPosition.x; + source_y = pSpriteObjects[source_id].vPosition.y; + source_z = pSpriteObjects[source_id].vPosition.z; } break; case OBJECT_Decoration: { assert(source_id < uNumLevelDecorations); - auto object = (SpriteObject *)&pLevelDecorations[source_id]; - source_x = object->vPosition.x; - source_y = object->vPosition.y; - source_z = object->vPosition.z; + source_x = pLevelDecorations[source_id].vPosition.x; + source_y = pLevelDecorations[source_id].vPosition.y; + source_z = pLevelDecorations[source_id].vPosition.z; } break; case OBJECT_Actor: { assert(source_id < uNumActors); - auto actor = &pActors[source_id]; - source_x = actor->vPosition.x; - source_y = actor->vPosition.y; - source_z = actor->vPosition.z; + source_x = pActors[source_id].vPosition.x; + source_y = pActors[source_id].vPosition.y; + source_z = pActors[source_id].vPosition.z; } break; @@ -1697,13 +1622,13 @@ if (auto sound_strength = GetSoundStrengthByDistanceFromParty(source_x, source_y, source_z)) { - AIL_set_sample_volume(channel->hSample, sound_strength); - AIL_set_sample_pan(channel->hSample, sub_4AB66C(source_x, source_y)); + AIL_set_sample_volume(pMixerChannels[i].hSample, sound_strength); + AIL_set_sample_pan(pMixerChannels[i].hSample, sub_4AB66C(source_x, source_y)); } else { - AIL_end_sample(channel->hSample); - FreeChannel(channel); + AIL_end_sample(pMixerChannels[i].hSample); + FreeChannel(&pMixerChannels[i]); } } @@ -1760,9 +1685,39 @@ if (!decor_desc->SoundOnDawn()) { if (!decor_desc->SoundOnDusk()) - goto LABEL_84; + { + if ( v55 == 0.0 ) + { + if ( v56 != 0.0 ) + { + v53 = 8 * _6807B8_level_decorations_ids[i]; + LOBYTE(v53) = v53 | OBJECT_Decoration; + PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); + } + continue; + } + if ( !decor->field_1A ) + decor->field_1A = (rand() % 15 + 1) << 7; + if ( v56 != 0.0 ) + { + v53 = 8 * _6807B8_level_decorations_ids[i]; + LOBYTE(v53) = v53 | OBJECT_Decoration; + PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); + } + continue; + } if ( v55 != 0.0 ) - goto LABEL_85; + { + if ( !decor->field_1A ) + decor->field_1A = (rand() % 15 + 1) << 7; + if ( v56 != 0.0 ) + { + v53 = 8 * _6807B8_level_decorations_ids[i]; + LOBYTE(v53) = v53 | OBJECT_Decoration; + PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); + } + continue; + } } v56 = 0.0; @@ -1773,26 +1728,28 @@ LODWORD(v56) = 1; LODWORD(v55) = 1; } -LABEL_84: - if ( v55 == 0.0 ) + if ( v55 == 0.0 ) + { + if ( v56 != 0.0 ) { -LABEL_87: - if ( v56 != 0.0 ) - { - v53 = 8 * _6807B8_level_decorations_ids[i]; - LOBYTE(v53) = v53 | OBJECT_Decoration; - PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); - } - continue; + v53 = 8 * _6807B8_level_decorations_ids[i]; + LOBYTE(v53) = v53 | OBJECT_Decoration; + PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); } -LABEL_85: - if ( !decor->field_1A ) - decor->field_1A = (rand() % 15 + 1) << 7; - goto LABEL_87; + continue; + } + if ( !decor->field_1A ) + decor->field_1A = (rand() % 15 + 1) << 7; + if ( v56 != 0.0 ) + { + v53 = 8 * _6807B8_level_decorations_ids[i]; + LOBYTE(v53) = v53 | OBJECT_Decoration; + PlaySound((SoundID)decor_desc->uSoundID, v53, uNumRepeats, -1, 0, 0, 0, 0); + } + continue; } } - //----- (004AB66C) -------------------------------------------------------- int __fastcall sub_4AB66C(int a1, int a2) { @@ -1807,42 +1764,34 @@ // 4AB66C: using guessed type int __fastcall sub_4AB66C(int, int); //----- (004AB6B1) -------------------------------------------------------- -int __fastcall GetSoundStrengthByDistanceFromParty(int a1, int a2, int a3) +int GetSoundStrengthByDistanceFromParty(int x, int y, int z) { - int v3; // esi@1 - int v4; // edi@1 - int v5; // ST08_4@1 - int v6; // esi@1 - int v7; // eax@1 - int v9; // [sp+10h] [bp+8h]@1 + int dir_x; // ST08_4@1 + int dir_y; // esi@1 + int dir_z; // eax@1 + int length; // [sp+10h] [bp+8h]@1 - v3 = a2; - v4 = a1; - v5 = abs(a3 - pParty->vPosition.z); - v6 = abs(v3 - pParty->vPosition.y); - v7 = abs(v4 - pParty->vPosition.x); - v9 = int_get_vector_length(v7, v6, v5); - if ( v9 <= 8192 ) - return 114 - (unsigned __int64)(signed __int64)((double)v9 * 0.0001220703125 * 100.0); + dir_z = abs(z - pParty->vPosition.z); + dir_y = abs(y - pParty->vPosition.y); + dir_x = abs(x - pParty->vPosition.x); + length = int_get_vector_length(dir_x, dir_y, dir_z); + if ( length <= 8192 ) + return 114 - (unsigned __int64)(signed __int64)((double)length * 0.0001220703125 * 100.0); else return 0; } - - //----- (004AB71F) -------------------------------------------------------- void AudioPlayer::StopChannels(int uStartChannel, int uEndChannel) { //AudioPlayer *v3; // esi@1 int v4; // ecx@1 - AudioPlayer_3DSample *v5; // edi@4 + //AudioPlayer_3DSample *v5; // edi@4 int v6; // ebx@12 MixerChannel *pChannel; // edi@14 //_STREAM *v8; // esi@23 int v9; // [sp+4h] [bp-4h]@3 - //v3 = this; - v4 = 0; if ( bPlayerReady ) { if ( b3DSoundInitialized ) @@ -1850,30 +1799,27 @@ v9 = 0; if ( uNum3DSamples > 0 ) { - v5 = p3DSamples;//;(char *)&p3DSamples[0].field_8; - do + //v5 = p3DSamples;//;(char *)&p3DSamples[0].field_8; + for ( v4 = 0; v4 < uNum3DSamples; ++v4 ) { if ( (uStartChannel == -1 || v4 < uStartChannel || v4 > uEndChannel) - && v5->field_8 - && pSoundList->pSounds[v5->field_8].eType != SOUND_DESC_SYSTEM) + && p3DSamples[v4].field_8 + && pSoundList->pSounds[p3DSamples[v4].field_8].eType != SOUND_DESC_SYSTEM) { - AIL_end_3D_sample(v5->hSample); - _4ABF23(v5); - v5->field_4 = 0; + AIL_end_3D_sample(p3DSamples[v4].hSample); + _4ABF23(&p3DSamples[v4]); + p3DSamples[v4].field_4 = 0; v4 = v9; } - ++v4; - v5 += 16; + //v5 += 16; v9 = v4; } - while ( v4 < uNum3DSamples ); } } - v6 = 0; if ( hDigDriver && uMixerChannels > 0 ) { pChannel = pMixerChannels; - do + for ( v6 = 0; v6 < uMixerChannels; ++v6 ) { if ( (uStartChannel == -1 || v6 < uStartChannel || v6 > uEndChannel) && pSoundList->pSounds[pChannel->uSourceTrackIdx].eType != SOUND_DESC_SYSTEM) @@ -1882,10 +1828,8 @@ FreeChannel(pChannel); pChannel->source_pid = 0; } - ++v6; ++pChannel; } - while (v6 < uMixerChannels); } if (hSequence) AIL_end_sequence(hSequence); @@ -1895,7 +1839,6 @@ } } - //----- (004AB818) -------------------------------------------------------- void AudioPlayer::LoadAudioSnd() { @@ -1962,6 +1905,7 @@ bEAXSupported = 0; b3DSoundInitialized = 0; ReadWindowsRegistryString("3DSoundProvider", p3DSoundProvider, 128u, "NONE"); + __debugbreak(); // audioplayer.cpp(1926): warning C4700: uninitialized local variable 'v5' used CheckA3DSupport(v5); while ( AIL_enumerate_3D_providers(&v14, (HPROVIDER *)&hWnd, &Str1) ) { @@ -2096,7 +2040,6 @@ } } - //----- (004ABC9B) -------------------------------------------------------- LSTATUS AudioPlayer::CheckA3DSupport(char a2) { @@ -2132,18 +2075,11 @@ //----- (004ABD5B) -------------------------------------------------------- void AudioPlayer::Release() //Освободить { - AudioPlayer *pAudioPlayer; // esi@1 - int v2; // edi@1 MixerChannel *pMixerChannel; // ebx@3 char v4; // dl@5 - int v5; // ebx@6 AudioPlayer_3DSample *p3DSample; // edi@7 - //int v7; // edx@14 - int v8; // ecx@14 void *v9; // ecx@15 - pAudioPlayer = this; - v2 = 0; if ( this->bPlayerReady ) { CloseHandle(pVideoPlayer->hMagicVid); @@ -2152,32 +2088,27 @@ if ( pAudioPlayer->uMixerChannels > 0 ) { pMixerChannel = pAudioPlayer->pMixerChannels; - do + for ( uint i = 0; i < pAudioPlayer->uMixerChannels; ++i ) { AIL_release_sample_handle(pMixerChannel->hSample); - ++v2; ++pMixerChannel; } - while ( v2 < pAudioPlayer->uMixerChannels ); } if ( ReadWindowsRegistryInt("Disable3DSound", 0) != 1 ) { - v5 = 0; pAudioPlayer->CheckA3DSupport(0);// pAudioPlayer->CheckA3DSupport(v4); if ( pAudioPlayer->uNum3DSamples > 0 ) { p3DSample = pAudioPlayer->p3DSamples; - do + for ( uint i = 0; i < pAudioPlayer->uNum3DSamples; ++i ) { if ( p3DSample->hSample ) { AIL_release_3D_sample_handle(p3DSample->hSample); p3DSample->hSample = 0; } - ++v5; ++p3DSample; } - while ( v5 < pAudioPlayer->uNum3DSamples ); } if ( pAudioPlayer->h3DSoundProvider ) { @@ -2185,11 +2116,10 @@ pAudioPlayer->h3DSoundProvider = 0; } } - v8 = (int)&pAudioPlayer->hAILRedbook; if ( pAudioPlayer->hAILRedbook ) { AIL_redbook_stop(pAudioPlayer->hAILRedbook); - AIL_redbook_set_volume((HREDBOOK)v8, pAudioPlayer->sRedbookVolume); + AIL_redbook_set_volume((HREDBOOK)&pAudioPlayer->hAILRedbook, pAudioPlayer->sRedbookVolume); AIL_redbook_close(pAudioPlayer->hAILRedbook); } AIL_shutdown(); @@ -2204,28 +2134,26 @@ //----- (004ABE55) -------------------------------------------------------- void AudioPlayer::FreeChannel(MixerChannel *pChannel) { - int v2; // ebx@1 + //int v2; // ebx@1 //AudioPlayer *v3; // esi@1 - SoundDesc *v4; // eax@2 + //SoundDesc *v4; // eax@2 unsigned __int8 v5; // zf@5 - unsigned __int8 v6; // sf@5 - char *v7; // edi@6 + //unsigned __int8 v6; // sf@5 + //char *v7; // edi@6 int num_same_sound_on_channels; // eax@8 - int v9; // ST04_4@8 + //int v9; // ST04_4@8 int v10; // ecx@12 int v11; // edi@13 int v12; // eax@13 - unsigned __int8 v13; // of@13 + //unsigned __int8 v13; // of@13 int v14[16]; // [sp+Ch] [bp-48h]@8 int num_playing_channels; // [sp+4Ch] [bp-8h]@5 - int v16; // [sp+50h] [bp-4h]@5 + //int v16; // [sp+50h] [bp-4h]@5 - v2 = 0; - //v3 = this; if (!pSoundList->pSounds) return; - v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx]; + //v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx]; if ( pSoundList->pSounds[pChannel->uSourceTrackIdx].eType == SOUND_DESC_SWAP) { if ( pSoundList->pSounds[pChannel->uSourceTrackIdx].pSoundData[0] && @@ -2233,19 +2161,17 @@ { num_playing_channels = 0; num_same_sound_on_channels = 0; - if ( this->uMixerChannels <=0 ) + if ( this->uMixerChannels <= 0 ) goto LABEL_16; - do + for ( uint i = 0; i < uMixerChannels; i++ ) { - if ( pChannel->uSourceTrackID ==pMixerChannels[v2].uSourceTrackID ) + if ( pChannel->uSourceTrackID == pMixerChannels[i].uSourceTrackID ) { - v14[num_same_sound_on_channels++] = v2; - if ( AIL_sample_status((HSAMPLE)pMixerChannels[v2].hSample) == AIL::Sample::Playing) + v14[num_same_sound_on_channels++] = i; + if ( AIL_sample_status((HSAMPLE)pMixerChannels[i].hSample) == AIL::Sample::Playing) ++num_playing_channels; } - ++v2; } - while ( v2 < uMixerChannels ); if ( !num_playing_channels ) { LABEL_16: @@ -2258,85 +2184,17 @@ v11 = v14[v10]; v12 = 16 * (v14[v10++] + 47); pMixerChannels[v11].uSourceTrackID = 0; - v13 = __OFSUB__(v10, num_same_sound_on_channels); - v6 = v10 - num_same_sound_on_channels < 0; + //v13 = __OFSUB__(v10, num_same_sound_on_channels); + //v6 = v10 - num_same_sound_on_channels < 0; *(unsigned int *)((char *)&bEAXSupported + v12) = 0; } - while (v10<num_same_sound_on_channels); + while (v10 < num_same_sound_on_channels); } } } } } - - -//----- (004AAEA6) -------------------------------------------------------- -int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1) -{ - double v1; // st7@1 - double v2; // st6@1 - int result; // eax@1 - double v4; // st5@2 - double v5; // st4@3 - double v6; // st3@3 - double v7; // st7@6 - double v8; // st6@7 - float v9; // [sp+0h] [bp-10h]@1 - float v10; // [sp+4h] [bp-Ch]@1 - float v11; // [sp+8h] [bp-8h]@2 - float v12; // [sp+8h] [bp-8h]@6 - float v13; // [sp+Ch] [bp-4h]@2 - float v14; // [sp+Ch] [bp-4h]@6 - - v1 = pBLVRenderParams->fCosineNegX; - v2 = pBLVRenderParams->fSineNegX; - v9 = pBLVRenderParams->fCosineY; - v10 = pBLVRenderParams->fSineY; - result = 0; - if ( pBLVRenderParams->sPartyRotX ) - { - v13 = a1->vWorldPosition.x - (double)pParty->vPosition.x; - v11 = a1->vWorldPosition.y - (double)pParty->vPosition.y; - v4 = a1->vWorldPosition.z - (double)pParty->vPosition.z; - if ( pRenderer->pRenderD3D ) - { - v5 = v11 * pBLVRenderParams->fSineY + v13 * pBLVRenderParams->fCosineY; - v6 = v13 * pBLVRenderParams->fSineY - v11 * pBLVRenderParams->fCosineY; - } - else - { - v5 = v13 * pBLVRenderParams->fCosineY - v11 * pBLVRenderParams->fSineY; - v6 = v13 * pBLVRenderParams->fSineY + v11 * pBLVRenderParams->fCosineY; - } - a1->vWorldViewPosition.x = v5 * v1 - v4 * v2; - a1->vWorldViewPosition.y = v6; - a1->vWorldViewPosition.z = v5 * v2 + v4 * v1; - } - else - { - v14 = a1->vWorldPosition.x - (double)pParty->vPosition.x; - v12 = a1->vWorldPosition.y - (double)pParty->vPosition.y; - v7 = a1->vWorldPosition.z - (double)pParty->vPosition.z; - if ( pRenderer->pRenderD3D ) - { - a1->vWorldViewPosition.x = v12 * pBLVRenderParams->fSineY + v14 * pBLVRenderParams->fCosineY; - v8 = v14 * v10 - v12 * v9; - } - else - { - a1->vWorldViewPosition.x = v14 * pBLVRenderParams->fCosineY - v12 * pBLVRenderParams->fSineY; - v8 = v14 * v10 + v12 * v9; - } - a1->vWorldViewPosition.y = v8; - a1->vWorldViewPosition.z = v7; - } - return result; -} - - - - //----- (004ABF23) -------------------------------------------------------- void AudioPlayer::_4ABF23(AudioPlayer_3DSample *a2) { @@ -2424,20 +2282,14 @@ //----- (004AC004) -------------------------------------------------------- void AudioPlayer::SetEAXPreferences() { - AudioPlayer *v1; // edi@1 - _PROVIDER *v2; // ST00_4@2 - _PROVIDER *v3; // ST00_4@2 float v4; // [sp+4h] [bp-4h]@2 - v1 = this; if ( this->bEAXSupported ) { - v2 = this->h3DSoundProvider; v4 = 0.0; - AIL_set_3D_provider_preference(v2, "EAX effect volume", (int *)&v4); - v3 = v1->h3DSoundProvider; + AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX effect volume", (int *)&v4); v4 = 1.0; - AIL_set_3D_provider_preference(v3, "EAX damping", (int *)&v4); + AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX damping", (int *)&v4); } } // 4D82DC: using guessed type int __stdcall AIL_set_3D_provider_preference(int, int, int); @@ -2445,24 +2297,22 @@ //----- (004AC041) -------------------------------------------------------- void AudioPlayer::SetMapEAX() { - AudioPlayer *v1; // esi@1 - unsigned int v2; // eax@1 + unsigned int pMapID; // eax@1 int v3; // [sp+4h] [bp-4h]@3 - v1 = this; - v2 = pMapStats->GetMapInfo(pCurrentMapName.data()); - if ( v1->b3DSoundInitialized && v1->bEAXSupported ) + pMapID = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( this->b3DSoundInitialized && this->bEAXSupported ) { - v3 = pMapStats->pInfos[v2].uEAXEnv; + v3 = pMapStats->pInfos[pMapID].uEAXEnv; if ( (unsigned int)v3 >= 0x1A ) { SetEAXPreferences(); - v1->field_214 = -1; + this->field_214 = -1; } else { - AIL_set_3D_provider_preference(v1->h3DSoundProvider, "EAX environment selection", &v3); - v1->field_214 = v3; + AIL_set_3D_provider_preference(this->h3DSoundProvider, "EAX environment selection", &v3); + this->field_214 = v3; } } } @@ -2542,154 +2392,110 @@ return 1; } - //----- (004A96BE) -------------------------------------------------------- void ReleaseSoundData(void *_this) { - int pID; // esi@1 - char *v2; // eax@1 - - pID = 0; - v2 = (char *)&pSounds[0].pSoundData; - while ( *(void **)v2 != _this ) + for ( uint i = 0; (void *)&pSounds[i].pSoundData < (void *)&pSounds[2999].pSoundData; i++ ) { - v2 += 128; - ++pID; - if ( v2 > (void *)&pSounds[2999].pSoundData)//(signed int)&pAudioPlayer->p3DSamples[6].field_8 ) - return; + if ( pSounds[i].pSoundData == _this ) + { + pAllocator->FreeChunk(_this); + memset(&pSounds[i], 0, 0x80u); + } } - pAllocator->FreeChunk(_this); - memset(&pSounds[pID], 0, 0x80u); + } //----- (004A96FF) -------------------------------------------------------- -SoundHeader *__fastcall FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName) +struct SoundHeader *FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName) { - unsigned int v3; // ebx@1 - unsigned int v4; // esi@1 - SoundHeader *result; // eax@2 +/* SoundHeader *result; // eax@2 + SoundHeader *pSound; signed int v6; // ebx@11 - int v7; // edi@13 - unsigned int v8; // esi@14 - unsigned int v9; // esi@20 - unsigned int v10; // [sp+Ch] [bp-4h]@1 - v3 = uEnd; - v10 = uEnd; - v4 = uStart; while ( 1 ) { - v6 = v3 - v4; - result = &pAudioPlayer->pSoundHeaders[v6 / 2 + v4]; - if ( !result ) - return result; - result = (SoundHeader *)_stricmp(pName, result->pSoundName); - if ( !result ) - uFindSound_BinSearch_ResultID = v6 / 2 + v4; - if ( v4 == v10 ) - goto LABEL_17; - if ( (signed int)result < 0 ) - break; - if ( v6 <= 4 ) + v6 = uEnd - uStart; + pSound = &pAudioPlayer->pSoundHeaders[v6 / 2 + uStart]; + if ( !pSound ) + return false; + result = (SoundHeader *)_stricmp(pName, pSound->pSoundName); + if ( !_stricmp(pName, pSound->pSoundName) ) + uFindSound_BinSearch_ResultID = v6 / 2 + uStart; + if ( uStart == uEnd ) { - v7 = v4; - if ( (signed int)v4 < (signed int)v10 ) - { - v9 = v4; - do - { - result = (SoundHeader *)_stricmp(pName, pAudioPlayer->pSoundHeaders[v9].pSoundName); - if ( !result ) - goto LABEL_24; - ++v7; - ++v9; - } - while ( v7 < (signed int)v10 ); - } -LABEL_17: uFindSound_BinSearch_ResultID = -1; return result; } - v4 += v6 / 2; + if ( (signed int)result < 0 ) + break; + + if ( v6 <= 4 ) + { + if ( (signed int)uStart < (signed int)uEnd ) + { + for ( uint i = uStart; i < (signed int)uEnd; ++i ) + { + if ( !_stricmp(pName, pAudioPlayer->pSoundHeaders[i].pSoundName) ) + { + uFindSound_BinSearch_ResultID = i; + return &pAudioPlayer->pSoundHeaders[i]; + } + } + } + uFindSound_BinSearch_ResultID = -1; + return false; + } + + uStart += v6 / 2; LABEL_10: - v3 = v10; + ; } if ( v6 > 4 ) { - v10 = v6 / 2 + v4; + uEnd = v6 / 2 + uStart; goto LABEL_10; } - v7 = v4; - if ( (signed int)v4 >= (signed int)v10 ) - goto LABEL_17; - v8 = v4; - while ( 1 ) + if ( (signed int)uStart >= (signed int)uEnd ) + { + uFindSound_BinSearch_ResultID = -1; + return false; + }*/ + for ( uint i = uStart; i < (signed int)uEnd; ++i ) { - result = (SoundHeader *)_stricmp(pName, pAudioPlayer->pSoundHeaders[v8].pSoundName); - if ( !result ) - break; - ++v7; - ++v8; - if ( v7 >= (signed int)v10 ) - goto LABEL_17; + if ( !_stricmp(pName, pAudioPlayer->pSoundHeaders[i].pSoundName) ) + { + uFindSound_BinSearch_ResultID = i; + return &pAudioPlayer->pSoundHeaders[i]; + } } -LABEL_24: - uFindSound_BinSearch_ResultID = v7; - return result; + uFindSound_BinSearch_ResultID = -1; + return false; } // F1B4C8: using guessed type int uFindSound_BinSearch_ResultID; //----- (004A97C6) -------------------------------------------------------- SoundData *LoadSound(const char *pSoundName, SoundData *pOutBuff, unsigned int uID) { - SoundData *v3; // edi@1 - int v4; // ecx@1 - //Sound *v5; // eax@1 - SoundHeader *v6; // esi@5 - unsigned int *pDecompressedSize; // ebx@5 - unsigned int v8; // eax@5 - unsigned int v9; // eax@7 - SoundData *result; // eax@9 - int v11; // esi@15 - int v12; // eax@15 - char *v13; // ecx@16 - int v14; // eax@19 - std::string v15; // [sp-18h] [bp-34h]@12 - const char *v16; // [sp-8h] [bp-24h]@12 - int v17; // [sp-4h] [bp-20h]@12 - char v18; // [sp+Ch] [bp-10h]@12 - int v19; // [sp+10h] [bp-Ch]@5 DWORD NumberOfBytesRead; // [sp+14h] [bp-8h]@8 - const char *pSoundName_; // [sp+18h] [bp-4h]@1 - pSoundName_ = pSoundName; - v3 = pOutBuff; - v4 = 0; for (uint i = 0; i < 3000; ++i) - { - if (pSounds[i].uID == uID) - return pSounds[i].pSoundData; - } - FindSound_BinSearch(0, pAudioPlayer->uNumSoundHeaders, pSoundName_); - if ( uFindSound_BinSearch_ResultID == -1 ) { - result = 0; - return result; + if (pSounds[i].uID == uID) + return pSounds[i].pSoundData; } - v6 = &pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID]; - pDecompressedSize = &v6->uDecompressedSize; - v8 = v6->uDecompressedSize; - v19 = v6->uDecompressedSize; - if ( v3 == (SoundData *)-1 ) - v3 = (SoundData *)pAllocator->AllocNamedChunk(0, v8 + 4, pSoundName_); - SetFilePointer(pAudioPlayer->hAudioSnd, v6->uFileOffset, 0, 0); - v9 = *pDecompressedSize; - if ( (signed int)v6->uCompressedSize >= (signed int)*pDecompressedSize ) + FindSound_BinSearch(0, pAudioPlayer->uNumSoundHeaders, pSoundName); + if ( uFindSound_BinSearch_ResultID == -1 ) + return 0; + if ( pOutBuff == (SoundData *)-1 ) + pOutBuff = (SoundData *)pAllocator->AllocNamedChunk(0, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize + 4, pSoundName); + SetFilePointer(pAudioPlayer->hAudioSnd, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uFileOffset, 0, 0); + if ( (signed int)pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize >= (signed int)pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize ) { - v6->uCompressedSize = v9; - if ( v9 ) + pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize = pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize; + if ( pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize ) { - ReadFile(pAudioPlayer->hAudioSnd, (char *)v3 + 4, v9, &NumberOfBytesRead, 0); + ReadFile(pAudioPlayer->hAudioSnd, (char *)pOutBuff + 4, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize, &NumberOfBytesRead, 0); } else { @@ -2698,38 +2504,25 @@ } else { - uID = (unsigned int)malloc(v6->uCompressedSize); - ReadFile(pAudioPlayer->hAudioSnd, (LPVOID)uID, v6->uCompressedSize, &NumberOfBytesRead, 0); - zlib::MemUnzip((char *)v3 + 4, &v6->uDecompressedSize, (const void *)uID, v6->uCompressedSize); + uID = (unsigned int)malloc(pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize); + ReadFile(pAudioPlayer->hAudioSnd, (LPVOID)uID, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize, &NumberOfBytesRead, 0); + zlib::MemUnzip((char *)pOutBuff + 4, &pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize, (const void *)uID, pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uCompressedSize); free((void *)uID); } - if ( v3 ) + if ( pOutBuff ) { - v11 = v19; - v12 = 0; - *(int *)v3 = v19; + *(int *)pOutBuff = pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize; uLastLoadedSoundID = 0; if ( pSounds[0].pSoundData ) { - v13 = (char *)&pSounds[0].pSoundData; - do - { - v13 += 128; - ++v12; - } - while ( *(int *)v13 ); - uLastLoadedSoundID = v12; + for ( uint i = 0; pSounds[i].pSoundData; i++ ) + ++uLastLoadedSoundID; } - v16 = pSounds[v12].SoundName; - strcpy((char *)v16, pSoundName_); - v14 = uLastLoadedSoundID++ << 7; - pSoundList->uTotalLoadedSoundSize += v11; - pSounds[uLastLoadedSoundID].pSoundData = v3; - result = v3; + strcpy((char *)pSounds[uLastLoadedSoundID].SoundName, pSoundName); + pSoundList->uTotalLoadedSoundSize += pAudioPlayer->pSoundHeaders[uFindSound_BinSearch_ResultID].uDecompressedSize; + pSounds[uLastLoadedSoundID].pSoundData = pOutBuff; + return pOutBuff; } else - { - result = 0; - } - return result; + return 0; }
--- a/AudioPlayer.h Tue Aug 06 00:52:46 2013 +0400 +++ b/AudioPlayer.h Tue Aug 06 00:56:33 2013 +0400 @@ -78,6 +78,7 @@ SOUND_7 = 7, SOUND_8 = 0x8, SOUND_27 = 0x1B, + SOUND_64 = 64, SOUND_Button = 66, SOUND_67 = 67, SOUND_71 = 71, @@ -88,6 +89,7 @@ SOUND_83 = 83, SOUND_84 = 84, SOUND_85 = 85, + SOUND_103 = 103, SOUND_Arcomage_LoseResources = 0x78, SOUND_Arcomage_AddResources = 0x79, SOUND_Arcomage_TowerWallDamage = 0x7A, @@ -102,13 +104,16 @@ SOUND_Arcomage_131 = 0x83, SOUND_Arcomage_WallUpgrade = 0x84, SOUND_GoldReceived = 0xC8, - SOUND_206 =206, - SOUND_207 =207, + SOUND_203 = 203, + SOUND_206 = 206, + SOUND_207 = 207, SOUND_OpenChest = 208, SOUND_PlayerCantCastSpell = 0xD1, SOUND_Bell = 0xD9, SOUND_OpenBook = 230, SOUND_CloseBook = 231, + SOUND_11090 = 11090, + SOUND_12040 = 12040, SOUND_20001 = 0x4E21, };
--- a/Awards.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Awards.h Tue Aug 06 00:56:33 2013 +0400 @@ -124,4 +124,4 @@ }; extern std::array<AwardType, 1000> achieved_awards; extern int num_achieved_awards; -extern int num_achieved_awards_2; \ No newline at end of file +extern int full_num_items_in_book; \ No newline at end of file
--- a/CShow.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/CShow.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -1,4 +1,4 @@ -#include <assert.h> +/*#include <assert.h> #include "CShow.h" @@ -26,3 +26,4 @@ } } +*/ \ No newline at end of file
--- a/CShow.h Tue Aug 06 00:52:46 2013 +0400 +++ b/CShow.h Tue Aug 06 00:56:33 2013 +0400 @@ -1,5 +1,5 @@ #pragma once - +#include "VideoPlayer.h" /* 302 */ @@ -15,7 +15,28 @@ MOVIE_Outro = 0x7, }; +inline void PlayFullscreenMovie(MovieType movie, bool bShowMouseAfterPlayback = false) +{ + extern unsigned int bNoVideo; + if (bNoVideo) return; + switch (movie) + { + case MOVIE_3DOLogo: VideoPlayer::MovieLoop("3dologo", 0, 0, 1); break; + case MOVIE_NWCLogo: VideoPlayer::MovieLoop("new world logo", 0, 1, 1); break; + case MOVIE_JVC: VideoPlayer::MovieLoop("jvc", 0, 1, 1); break; + case MOVIE_Intro: VideoPlayer::MovieLoop("Intro", 0, 1, 1); break; + case MOVIE_Emerald: VideoPlayer::MovieLoop("Intro Post", 0, 1, 1); break; + case MOVIE_Death: VideoPlayer::MovieLoop("losegame", 2, 1, 1); break; + case MOVIE_Outro: VideoPlayer::MovieLoop("end_seq1", 20, 1, 1); break; + + default: + assert(false && "Invalid movie requested in " __FUNCTION__); + break; + } +} + +/* #pragma pack(push, 1) class CShow { @@ -33,4 +54,4 @@ void (__thiscall ***vdestructor_ptr)(CShow *, bool); }; -#pragma pack(pop) \ No newline at end of file +#pragma pack(pop)*/ \ No newline at end of file
--- a/CastSpellInfo.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/CastSpellInfo.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -166,8 +166,8 @@ int v440; // eax@843 int v441; // eax@847 signed int v445; // edi@857 - int v446; // ecx@862 - LevelDecoration *v447; // edi@864 + //int v446; // ecx@862 + //LevelDecoration *v447; // edi@864 __int16 v448; // ax@864 char *v449; // esi@870 int v450; // eax@870 @@ -255,7 +255,7 @@ int v671; // [sp+4h] [bp-E80h]@146 int v675; // [sp+4h] [bp-E80h]@800 int v676; // [sp+4h] [bp-E80h]@807 - int v677; // [sp+4h] [bp-E80h]@861 + //int v677; // [sp+4h] [bp-E80h]@861 int v679[800]; // [sp+14h] [bp-E70h]@515 AIDirection a3; // [sp+C94h] [bp-1F0h]@21 int v681[4]; // [sp+CB0h] [bp-1D4h]@1137 @@ -467,7 +467,7 @@ pSpellSprite.uFacing = LOWORD(v715.uYawAngle); pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID]; - memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItems[pPlayer->pEquipment.uBow-1], sizeof(pSpellSprite.stru_24)); + memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItemList[pPlayer->pEquipment.uBow-1], sizeof(pSpellSprite.stru_24)); pSpellSprite.uAttributes = 256; if ( pParty->bTurnBasedModeOn == 1 ) pSpellSprite.uAttributes = 260; @@ -501,7 +501,7 @@ pSpellSprite.uFacing = LOWORD(v715.uYawAngle); pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID]; - memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItems[pPlayer->pEquipment.uMainHand-1],sizeof(pSpellSprite.stru_24)); + memcpy(&pSpellSprite.stru_24, &pPlayer->pInventoryItemList[pPlayer->pEquipment.uMainHand-1],sizeof(pSpellSprite.stru_24)); // &pParty->pPlayers[pCastSpell->uPlayerID].spellbook.pDarkSpellbook.bIsSpellAvailable[36 // * pParty->pPlayers[pCastSpell->uPlayerID].pEquipment.uMainHand + 5], ); v23 = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pSpellSprite.vPosition.z); @@ -991,7 +991,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2]; + v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2]; auto _itm = &pItemsTable->pItems[v730c->uItemID]; v730c->UpdateTempBonus(pParty->uTimePlayed); if ( v730c->uItemID < 64 || v730c->uItemID > 65 @@ -1879,7 +1879,7 @@ { if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - v240 = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2]; + v240 = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2]; if ( pItemsTable->pItems[v240->uItemID].uEquipType != 12 || v240->uAttributes & 2 ) { @@ -1938,7 +1938,7 @@ amount = 10 * v2; v730 = 1; pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - v245 = &pPlayer->pInventoryItems[a2]; + v245 = &pPlayer->pInventoryItemList[a2]; ItemDesc *_v725 = &pItemsTable->pItems[v245->uItemID]; if ( v731 == 1 || v731 == 2 && _v725->uEquipType > 2 || @@ -1955,6 +1955,8 @@ { v730 = 0; } + + __debugbreak(); // castspellinfo.cpp(1962): warning C4700: uninitialized local variable 'v271' used if ( rand() % 100 < 10 * v2 || (rand() % 100 < 80 && (v731 == 3 || v731 == 4 )) || v245->GetValue() < 450 || @@ -1966,6 +1968,7 @@ { v295 = rand() % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType]; v245->uEnchantmentType = 0; + __debugbreak(); // castspellinfo.cpp(1971): warning C4700: uninitialized local variable 'v294' used for ( kk = pItemsTable->pEnchantments[0].to_item[pItemsTable->pItems[v245->uItemID].uEquipType + 1]; ; kk += pItemsTable->pEnchantments[v294->uEnchantmentType].to_item[pItemsTable->pItems[v245->uItemID].uEquipType + 1] ) @@ -2971,31 +2974,26 @@ LODWORD(v727) = 1; break; } - dword_507CD8 = 1; - v677 = 1; + OpenedTelekinesis = true; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - v446 = pIndoor->pFaceExtras[pIndoor->pFaces[v445].uFaceExtraID].uEventID; + v448 = pIndoor->pFaceExtras[pIndoor->pFaces[v445].uFaceExtraID].uEventID; else - v446 = pOutdoor->pBModels[a2 >> 9].pFaces[v445 & 0x3F].sCogTriggeredID; - EventProcessor(v446, a2, v677); + v448 = pOutdoor->pBModels[a2 >> 9].pFaces[v445 & 0x3F].sCogTriggeredID; + EventProcessor(v448, a2, 1); LODWORD(v727) = 1; break; } - v447 = &pLevelDecorations[v445]; - dword_507CD8 = 1; - v448 = v447->field_16_event_id; - if (v448) + OpenedTelekinesis = true; + if ( pLevelDecorations[v445].field_16_event_id ) { - v677 = 1; - v446 = v448; - EventProcessor(v446, a2, v677); + EventProcessor(v448, a2, 1); LODWORD(v727) = 1; break; } - if ( v447->IsInteractive() ) + if ( pLevelDecorations[v445].IsInteractive() ) { - activeLevelDecoration = v447; - EventProcessor(stru_5E4C90._decor_events[v447->_idx_in_stru123 - 75] + 380, 0, 1); + activeLevelDecoration = &pLevelDecorations[v445]; + EventProcessor(stru_5E4C90._decor_events[pLevelDecorations[v445]._idx_in_stru123 - 75] + 380, 0, 1); activeLevelDecoration = NULL; } } @@ -3639,7 +3637,7 @@ break; __debugbreak(); //HIDWORD(v733) = (int)(char *)&pParty + 6972 * pCastSpell->uPlayerID_2 + 36 * a2 + 3040; - ItemGen *_v733 = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItems[a2]; + ItemGen *_v733 = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2]; ItemDesc *_v732 = &pItemsTable->pItems[_v733->uItemID]; _v733->UpdateTempBonus(pParty->uTimePlayed); if ( _v733->uItemID >= 64 && _v733->uItemID <= 65 @@ -4071,36 +4069,26 @@ //----- (00427DA0) -------------------------------------------------------- unsigned int CastSpellInfo::PushCastSpellInfo(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int spell_sound_id) { - unsigned int result; // eax@1 - CastSpellInfo *v7; // edx@1 - CastSpellInfo *v8; // ecx@5 - - result = 0; - v7 = this; - while ( v7->spellnum ) + for ( uint i = 0; i < 10; i++ ) { - ++result; - ++v7; - if ( (signed int)result >= 10 ) - goto LABEL_8; + if ( !this[i].spellnum ) + { + this[i].spellnum = a2; + this[i].uPlayerID = uPlayerID; + if ( a5 & 0x10 ) + this[i].uPlayerID_2 = uPlayerID; + this[i].field_6 = 0; + this[i].spell_target_pid = 0; + this[i].field_8 = a5; + this[i].forced_spell_skill_level = skill_level; + this[i].sound_id = spell_sound_id; + return i; + } } - v8 = &this[result]; - v8->spellnum = a2; - v8->uPlayerID = uPlayerID; - if ( a5 & 0x10 ) - v8->uPlayerID_2 = uPlayerID; - v8->field_6 = 0; - v8->spell_target_pid = 0; - v8->field_8 = a5; - v8->forced_spell_skill_level = skill_level; - v8->sound_id = spell_sound_id; -LABEL_8: - if ( result == 10 ) - result = -1; - return result; + return -1; } //----- (00427D48) -------------------------------------------------------- -void CastSpellInfo::_427D48(unsigned int uPlayerID) +void CastSpellInfo::_427D48(unsigned int uPlayerID)//Press S { CastSpellInfo *v2; // esi@1 signed int v3; // ebx@1
--- a/Chest.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Chest.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -22,6 +22,7 @@ #include "ObjectList.h" #include "GUIWindow.h" #include "Time.h" +#include "Overlays.h" #include "mm7_data.h" #include "MM7.h" @@ -43,215 +44,185 @@ //----- (0042041E) -------------------------------------------------------- bool Chest::Open( signed int uChestID ) { - //char *v1; // edi@5 - unsigned int v2; // eax@8 - GUIWindow *v3; // eax@15 - int v5; // edx@16 + unsigned int pMapID; // eax@8 + int pRandom; // edx@16 int v6; // eax@16 - ODMFace *v7; // eax@19 - int v8; // edx@19 - int v9; // edi@19 - signed int v10; // ebx@19 - int v11; // ecx@19 - int v12; // eax@19 - BLVFace *v13; // eax@20 - int v14; // ebx@21 - int v15; // edi@21 - int v16; // ecx@22 - __int64 v17; // qax@22 - double v18; // st7@23 - double v19; // st6@23 - double v20; // st7@23 - int v21; // ecx@26 - char v22[12]; // ST4C_12@28 - unsigned int *v23; // edi@28 - unsigned __int16 v24; // di@28 - signed int v25; // ecx@28 - char *v26; // edx@29 - unsigned __int16 v27; // ax@32 - //SpriteObject a1; // [sp+14h] [bp-B0h]@28 - int v29[4]; // [sp+84h] [bp-40h]@16 - //int v30; // [sp+88h] [bp-3Ch]@16 - //int v31; // [sp+8Ch] [bp-38h]@16 - //int v32; // [sp+90h] [bp-34h]@16 - float v33; // [sp+94h] [bp-30h]@23 - //char *v34; // [sp+98h] [bp-2Ch]@5 - int v35; // [sp+9Ch] [bp-28h]@16 + ODMFace *pODMFace; // eax@19 + BLVFace *pBLVFace; // eax@20 + int pObjectX; // ebx@21 + int pObjectZ; // edi@21 + double dir_x; // st7@23 + double dir_y; // st6@23 + double length_vector; // st7@23 + int pDepth; // ecx@26 + Vec3_int_ v; // ST4C_12@28 + bool flag_shout; // edi@28 + int pSpriteID[4]; // [sp+84h] [bp-40h]@16 Vec3_int_ pOut; // [sp+A0h] [bp-24h]@28 - int a4; // [sp+ACh] [bp-18h]@1 - int v38; // [sp+B0h] [bp-14h]@21 + int pObjectY; // [sp+B0h] [bp-14h]@21 int sRotX; // [sp+B4h] [bp-10h]@23 - float v40; // [sp+B8h] [bp-Ch]@23 - float v41; // [sp+BCh] [bp-8h]@23 + float dir_z; // [sp+BCh] [bp-8h]@23 int sRotY; // [sp+C0h] [bp-4h]@8 + SpriteObject pSpellObject; // [sp+14h] [bp-B0h]@28 - //a4 = uChestID; - assert(uChestID < 20); - if ((uChestID <0)&&(uChestID >=20) ) - return false; + assert( uChestID < 20 ); + if ( ( uChestID < 0 ) && ( uChestID >= 20 ) ) + return false; auto chest = &pChests[uChestID]; ++pIcons_LOD->uTexturePacksCount; if (!pIcons_LOD->uNumPrevLoadedFiles) pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; - - //v1 = (char *)&pChests[uChestID].uFlags; - //v34 = v1; if (!chest->Initialized()) Chest::PlaceItems(uChestID); if ( !uActiveCharacter ) - return 0; - *(float *)&sRotY = 0.0; - v2 = pMapStats->GetMapInfo(pCurrentMapName.data()); - if ( !chest->Trapped() || !v2 ) - goto LABEL_12; - if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[v2].LockX5 ) + return false; + flag_shout = false; + pMapID = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( chest->Trapped() && pMapID ) { - v29[0] = 811; - v29[1] = 812; - v29[2] = 813; - v29[3] = 814; - v5 = rand() % 4; - v6 = PID_ID(EvtTargetObj); - v35 = v5; - if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) + if ( pPlayers[uActiveCharacter]->GetDisarmTrap() < 2 * pMapStats->pInfos[pMapID].LockX5 ) { - v16 = v6; - v14 = pLevelDecorations[v6].vPosition.x; - v38 = pLevelDecorations[v6].vPosition.y; - v17 = pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight; - v15 = pLevelDecorations[v16].vPosition.z + (((signed int)v17 - HIDWORD(v17)) >> 1); - } - else - { - if ( PID_TYPE(EvtTargetObj) != OBJECT_BModel) - goto LABEL_12; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + pSpriteID[0] = 811; + pSpriteID[1] = 812; + pSpriteID[2] = 813; + pSpriteID[3] = 814; + pRandom = rand() % 4; + v6 = PID_ID(EvtTargetObj); + if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) + { + pObjectX = pLevelDecorations[v6].vPosition.x; + pObjectY = pLevelDecorations[v6].vPosition.y; + pObjectZ = pLevelDecorations[v6].vPosition.z + ( pDecorationList->pDecorations[pLevelDecorations[v6].uDecorationDescID].uDecorationHeight / 2 ); + } + if ( PID_TYPE(EvtTargetObj) == OBJECT_BModel) { - v7 = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F]; - v8 = v7->pBoundingBox.y1; - v9 = v7->pBoundingBox.z2; - v10 = v7->pBoundingBox.x1 + v7->pBoundingBox.x2; - v11 = v7->pBoundingBox.y2; - v12 = v7->pBoundingBox.z1; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + pODMFace = &pOutdoor->pBModels[EvtTargetObj >> 9].pFaces[(EvtTargetObj >> 3) & 0x3F]; + pObjectX = ( pODMFace->pBoundingBox.x1 + pODMFace->pBoundingBox.x2 ) / 2; + pObjectY = ( pODMFace->pBoundingBox.y1 + pODMFace->pBoundingBox.y2 ) / 2; + pObjectZ = ( pODMFace->pBoundingBox.z1 + pODMFace->pBoundingBox.z2 ) / 2; + } + else//Indoor + { + pBLVFace = &pIndoor->pFaces[v6]; + pObjectX = ( pBLVFace->pBounding.x1 + pBLVFace->pBounding.x2 ) / 2; + pObjectY = ( pBLVFace->pBounding.y1 + pBLVFace->pBounding.y2 ) / 2; + pObjectZ = ( pBLVFace->pBounding.z1 + pBLVFace->pBounding.z2 ) / 2; + } + } + dir_x = (double)pParty->vPosition.x - (double)pObjectX; + dir_y = (double)pParty->vPosition.y - (double)pObjectY; + dir_z = ( (double)pParty->sEyelevel + (double)pParty->vPosition.z ) - (double)pObjectZ; + length_vector = sqrt( (dir_x * dir_x) + (dir_y * dir_y) + (dir_z * dir_z) ); + if ( length_vector <= 1.0 ) + { + *(float *)&sRotX = 0.0; + *(float *)&sRotY = 0.0; } else { - v13 = &pIndoor->pFaces[v6]; - v8 = v13->pBounding.y1; - v9 = v13->pBounding.z2; - v10 = v13->pBounding.x1 + v13->pBounding.x2; - v11 = v13->pBounding.y2; - v12 = v13->pBounding.z1; + sRotY = (signed __int64)sqrt(dir_x * dir_x + dir_y * dir_y); + sRotX = stru_5C6E00->Atan2((signed __int64)dir_x, (signed __int64)dir_y); + sRotY = stru_5C6E00->Atan2(dir_y * dir_y, (signed __int64)dir_z); } - v14 = v10 >> 1; - v38 = (v8 + v11) >> 1; - v15 = (v12 + v9) >> 1; - } - v18 = (double)pParty->vPosition.x - (double)v14; - *(float *)&a4 = v18; - v19 = (double)pParty->vPosition.y - (double)v38; - v33 = v19; - v41 = (double)pParty->sEyelevel + (double)pParty->vPosition.z - (double)v15; - *(float *)&sRotY = v19 * v19; - *(float *)&sRotX = v18 * v18; - v20 = sqrt(v41 * v41 + *(float *)&sRotX + *(float *)&sRotY); - v40 = v20; - if ( v20 <= 1.0 ) - { - *(float *)&sRotX = 0.0; - *(float *)&sRotY = 0.0; - } - else - { - sRotY = (signed __int64)sqrt(*(float *)&sRotX + *(float *)&sRotY); - sRotX = stru_5C6E00->Atan2((signed __int64)*(float *)&a4, (signed __int64)v33); - sRotY = stru_5C6E00->Atan2(sRotY, (signed __int64)v41); - } - v21 = 256; - if ( v40 < 256.0 ) - v21 = (signed __int64)v40 / 4; - *(int *)&v22[8] = v15; - *(_QWORD *)v22 = __PAIR__(v38, v14); - Vec3_int_::Rotate(v21, sRotX, sRotY, *(Vec3_int_ *)v22, &pOut.x, &pOut.z, &pOut.y); - v23 = (unsigned int *)(&v29 + v35); - sub_42F7EB_DropItemAt(*v23, pOut.x, pOut.z, pOut.y, 0, 1, 0, 0x30u, 0); - - SpriteObject a1; // [sp+14h] [bp-B0h]@28 - //SpriteObject::SpriteObject(&a1); + pDepth = 256; + if ( length_vector < 256.0 ) + pDepth = (signed __int64)length_vector / 4; + v.x = pObjectX; + v.y = pObjectY; + v.z = pObjectZ; + Vec3_int_::Rotate(pDepth, sRotX, sRotY, v, &pOut.x, &pOut.z, &pOut.y); + sub_42F7EB_DropItemAt(pSpriteID[pRandom], pOut.x, pOut.z, pOut.y, 0, 1, 0, 48, 0); - a1.stru_24.Reset(); - v24 = *(short *)v23; - v25 = 0; - a1.spell_skill = 0; - a1.spell_level = 0; - a1.spell_id = 0; - a1.field_54 = 0; - a1.uType = v24; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_32: - v27 = 0; - } - else - { - v26 = (char *)&pObjectList->pObjects->uObjectID; - while ( v24 != *(short *)v26 ) + pSpellObject.stru_24.Reset(); + pSpellObject.spell_skill = 0; + pSpellObject.spell_level = 0; + pSpellObject.spell_id = 0; + pSpellObject.field_54 = 0; + pSpellObject.uType = pSpriteID[pRandom]; + pSpellObject.uObjectDescID = 0; + if ( pObjectList->uNumObjects ) { - ++v25; - v26 += 56; - if ( v25 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_32; + for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i ) + { + if ( pSpriteID[pRandom] == pObjectList->pObjects[i].uObjectID ) + pSpellObject.uObjectDescID = i; + } } - v27 = v25; + pSpellObject.vPosition.y = pOut.z; + pSpellObject.vPosition.x = pOut.x; + pSpellObject.vPosition.z = pOut.y; + pSpellObject.uSoundID = 0; + pSpellObject.uAttributes = 48; + pSpellObject.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); + pSpellObject.uSpriteFrameID = 0; + pSpellObject.spell_caster_pid = 0; + pSpellObject.spell_target_pid = 0; + pSpellObject.uFacing = 0; + pSpellObject.Create(0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); + pSpellObject.ExplosionTraps(); + chest->uFlags &= 0xFEu; + if ( uActiveCharacter && !qword_A750D8 && !OpenedTelekinesis ) + { + qword_A750D8 = 256i64; + PlayerSpeechID = SPEECH_5; + uSpeakingCharacter = uActiveCharacter; + } + pIcons_LOD->RemoveTexturesPackFromTextureList(); + OpenedTelekinesis = false; + return false; } - a1.uObjectDescID = v27; - a1.vPosition.y = pOut.z; - a1.vPosition.x = pOut.x; - a1.vPosition.z = pOut.y; - a1.uSoundID = 0; - a1.uAttributes = 48; - a1.uSectorID = pIndoor->GetSector(pOut.x, pOut.z, pOut.y); - a1.uSpriteFrameID = 0; - a1.spell_caster_pid = 0; - a1.spell_target_pid = 0; - a1.uFacing = 0; - a1.Create(0, 0, 0, 0); - pAudioPlayer->PlaySound(SOUND_8, 0, 0, -1, 0, 0, 0, 0); - a1._438E35(); - chest->SetInitialized(false);//*v34 &= 0xFEu; - if ( uActiveCharacter && !qword_A750D8 && !dword_507CD8 ) - { - qword_A750D8 = 256i64; - word_A750E0 = 5; - word_A750E2 = uActiveCharacter; - } - pIcons_LOD->_4114F2(); - dword_507CD8 = 0; - return 0; + chest->uFlags &= 0xFEu; + flag_shout = true; } - chest->SetInitialized(false);//*v1 &= 0xFEu; - sRotY = 1; -LABEL_12: pAudioPlayer->StopChannels(-1, -1); pAudioPlayer->PlaySound(SOUND_OpenChest, 0, 0, -1, 0, 0, 0, 0); - if ( *(float *)&sRotY != 0.0 ) + if ( flag_shout == true ) { - if ( !dword_507CD8 ) + if ( !OpenedTelekinesis ) pPlayers[uActiveCharacter]->PlaySound(SPEECH_4, 0); } - dword_507CD8 = 0; - + OpenedTelekinesis = false; pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Chest, uChestID, 0); - - pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit - pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0); - + pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);// Exit + pChestWindow->CreateButton( 7, 8, 460, 343, 1, 0, UIMSG_CHEST_ClickItem, 0, 0, "", 0); pCurrentScreen = SCREEN_CHEST; pEventTimer->Pause(); - return 1; + return true; +} + + +//----- (0042038D) -------------------------------------------------------- +void __cdecl ChestUI_WritePointedObjectStatusString() +{ + POINT *v0; // esi@2 + int v1; // ecx@2 + const char *v2; // eax@3 + POINT v3; // [sp+0h] [bp-10h]@2 + POINT a2; // [sp+8h] [bp-8h]@1 + + __debugbreak(); // invalid indexing + if ( pMouse->GetCursorPos(&a2)->y < 350 ) + { + v0 = pMouse->GetCursorPos(&a2); + v1 = pRenderer->pActiveZBuffer[v0->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v3)->y]]; + if ( v1 ) + { + auto _w = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + + 18 * *((short *)&pChests[0].igChestItems[139].uExpireTime + + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); + + _w = (ItemGen *)(&pChests[(unsigned int)pChestWindow->ptr_1C] -32 + + 18 * *((short *)&pChests[(unsigned int)pChestWindow->ptr_1C].igChestItems[139].uExpireTime + v1 + 3)); + v2 = _w->GetDisplayName(); + GameUI_SetFooterString(v2); + } + } } //----- (0042092D) -------------------------------------------------------- @@ -285,18 +256,18 @@ chest_offs_y = pChestPixelOffsetY[chestBitmapId]; chestWidthCells = pChestWidthsByType[chestBitmapId]; chestHeghtCells = pChestHeightsByType[chestBitmapId]; - sprintf(pTmpBuf.data(), "chest%02d", pChestList->pChests[chestBitmapId].uTextureID); + sprintfex(pTmpBuf.data(), "chest%02d", pChestList->pChests[chestBitmapId].uTextureID); v5 = pIcons_LOD->LoadTexture(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); pRenderer->DrawTextureIndexed(8u, 8u, pIcons_LOD->GetTexture(v5)); - for (item_counter = 0; item_counter< chestWidthCells * chestHeghtCells; ++item_counter) + for (item_counter = 0; item_counter < chestWidthCells * chestHeghtCells; ++item_counter) { chest_item_index = pChests[uChestID].pInventoryIndices[item_counter]; if ( chest_item_index > 0 ) { item_texture_id = pIcons_LOD->LoadTexture( //pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName, - pItemsTable->pItems[pChests[uChestID].igChestItems[chest_item_index-1].uItemID].pIconName, TEXTURE_16BIT_PALETTE); + pItemsTable->pItems[pChests[uChestID].igChestItems[chest_item_index - 1].uItemID].pIconName, TEXTURE_16BIT_PALETTE); item_texture = pIcons_LOD->GetTexture(item_texture_id); itemPixelWidth = item_texture->uTextureWidth; itemPixelHeght = item_texture->uTextureHeight; @@ -448,18 +419,13 @@ item_in_chest_count = CountChestItems(uChestID); if ( item_in_chest_count == -1 ) return 0; - v22 = 0; - if ( v5 > 0 ) - { - while ( !Chest::CanPlaceItemAt(v22, v4->uItemID, pChestWindow->par1C) ) + for( int i = 0; i < v5; i++) + { + if ( Chest::CanPlaceItemAt(i, v4->uItemID, pChestWindow->par1C) ) { - ++v22; - if ( v22 >= v5 ) - goto LABEL_8; + v21 = i; } - v21 = v22; } -LABEL_8: if ( v22 == v5 ) { if ( uActiveCharacter ) @@ -522,7 +488,6 @@ //----- (0042013E) -------------------------------------------------------- void Chest::PlaceItemAt( unsigned int put_cell_pos, unsigned int item_at_cell, signed int uChestID ) { - int uItemID; // edi@1 int v6; // edx@4 unsigned int v7; // eax@5
--- a/DecalBuilder.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/DecalBuilder.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -401,6 +401,7 @@ { v40 = (int)&a8; v39 = v12->pVertices; + __debugbreak(); // warning C4700: uninitialized local variable 'v31' used pGame->pIndoorCameraD3D->_436CDC_mess_with_lightmap__clipflag_2(v32, *v31, v12->pVertices, &a8b); v40 = (int)v31; v39 = v12->pVertices; @@ -522,7 +523,7 @@ } //----- (0049BE8A) -------------------------------------------------------- -bool DecalBuilder::_49BE8A(struct stru148 *a2, Vec3_float_ *_a3, float *a4, RenderVertexSoft *a5, unsigned int uStripType, char a7) +bool DecalBuilder::_49BE8A(struct Polygon *a2, Vec3_float_ *_a3, float *a4, RenderVertexSoft *a5, unsigned int uStripType, char a7) { bool result; // eax@1 RenderVertexSoft *v8; // edi@3
--- a/DecalBuilder.h Tue Aug 06 00:52:46 2013 +0400 +++ b/DecalBuilder.h Tue Aug 06 00:56:33 2013 +0400 @@ -168,7 +168,7 @@ char _49B790_build_decal_geometry(int a2, char a3, DecalBuilder_stru0 *a4, int a5, float a6, unsigned int uColorMultiplier, float a8, struct stru314 *a9, signed int a10, struct RenderVertexSoft *a11, char uClipFlags); bool ApplyBloodsplatDecals_IndoorFace(unsigned int uFaceID); char ApplyDecals_OutdoorFace(ODMFace *pFace); - bool _49BE8A(struct stru148 *a2, Vec3_float_ *a3, float *a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7); + bool _49BE8A(struct Polygon *a2, Vec3_float_ *a3, float *a4, struct RenderVertexSoft *a5, unsigned int uStripType, char a7); void DrawDecal(Decal *pDecal, float z_bias); void DrawDecals(float z_bias); void DrawBloodsplats();
--- a/DecorationList.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/DecorationList.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -264,13 +264,12 @@ ++uID; ++v4; if ( uID >= (signed int)v2->uNumDecorations ) - goto LABEL_6; + return 0; } result = uID; } else { -LABEL_6: result = 0; } return result;
--- a/Events.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Events.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -956,10 +956,10 @@ v4 = v124; break; } - v67 = (int)pPlayers[uActiveCharacter]->pInventoryIndices; + v67 = (int)pPlayers[uActiveCharacter]->pInventoryMatrix; for ( v65 = 0; v65 < 126; ++v65 ) { - if ( (int)&pPlayers[uActiveCharacter]->pInventoryItems[v67] == pValue ) + if ( (int)&pPlayers[uActiveCharacter]->pInventoryItemList[v67] == pValue ) { pPlayers[uActiveCharacter]->RemoveItemAtInventoryIndex(v65); ++curr_seq_num; @@ -972,7 +972,7 @@ v69 = (int)&pPlayers[uActiveCharacter]->pEquipment; for ( v68 = 0; v68 < 16; ++v68 ) { - if ( *(int *)v69 && (int)&pPlayers[uActiveCharacter]->pInventoryItems[v69] == pValue ) + if ( *(int *)v69 && (int)&pPlayers[uActiveCharacter]->pInventoryItemList[v69] == pValue ) { *(&pPlayers[uActiveCharacter]->pEquipment.uShield + v68) = 0; ++curr_seq_num; @@ -983,10 +983,10 @@ } for (int i = 1; i < 5; i++) { - v72 = (int)pPlayers[i]->pInventoryIndices; + v72 = (int)pPlayers[i]->pInventoryMatrix; for ( int v71 = 0; v71 < 126; ++v71 ) { - if ( (int)&pPlayers[i]->pInventoryItems[v72] == pValue ) + if ( (int)&pPlayers[i]->pInventoryItemList[v72] == pValue ) { pPlayers[i]->RemoveItemAtInventoryIndex(v71); break; @@ -995,7 +995,7 @@ } v73 = 0; v74 = (int)&pPlayers[i]->pEquipment; - while ( !*(int *)v74 || (int)&pPlayer->pInventoryItems[v74] != pValue ) + while ( !*(int *)v74 || (int)&pPlayer->pInventoryItemList[v74] != pValue ) { ++v73; v74 += 4;
--- a/Events2D.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Events2D.h Tue Aug 06 00:56:33 2013 +0400 @@ -1,46 +1,46 @@ #pragma once /* 296 */ -enum BildingType: unsigned short +enum BuildingType: unsigned short { - BildingType_WeaponShop = 1, - BildingType_ArmorShop = 2, - BildingType_MagicShop = 3, - BildingType_AlchemistShop = 4, - BildingType_FireGuild = 5, - BildingType_AirGuild = 6, - BildingType_WaterGuild = 7, - BildingType_EarthGuild = 8, - BildingType_SpiritGuild = 9, - BildingType_MindGuild = 10, - BildingType_BodyGuild = 11, - BildingType_LightGuild = 12, - BildingType_DarkGuild = 13, - BildingType_14 = 14, - BildingType_15 = 15, - BildingType_16 = 16, - BildingType_TownHall = 17, - BildingType_18 = 18, - BildingType_19 = 19, - BildingType_Throne_Room = 20, - BildingType_Tavern = 21, - BildingType_Bank = 22, - BildingType_Temple = 23, + BuildingType_WeaponShop = 1, + BuildingType_ArmorShop = 2, + BuildingType_MagicShop = 3, + BuildingType_AlchemistShop = 4, + BuildingType_FireGuild = 5, + BuildingType_AirGuild = 6, + BuildingType_WaterGuild = 7, + BuildingType_EarthGuild = 8, + BuildingType_SpiritGuild = 9, + BuildingType_MindGuild = 10, + BuildingType_BodyGuild = 11, + BuildingType_LightGuild = 12, + BuildingType_DarkGuild = 13, + BuildingType_14 = 14, + BuildingType_15 = 15, + BuildingType_16 = 16, + BuildingType_TownHall = 17, + BuildingType_18 = 18, + BuildingType_19 = 19, + BuildingType_Throne_Room = 20, + BuildingType_Tavern = 21, + BuildingType_Bank = 22, + BuildingType_Temple = 23, BuildingType_24 = 24, - BildingType_Unic = 25, - BildingType_1A = 26, - BildingType_Stables = 27, - BildingType_Boats = 28, - BildingType_House = 29, - BildingType_Training = 30, - BildingType_Jail = 31 + BuildingType_Unic = 25, + BuildingType_1A = 26, + BuildingType_Stables = 27, + BuildingType_Boats = 28, + BuildingType_House = 29, + BuildingType_Training = 30, + BuildingType_Jail = 31 }; /* 168 */ #pragma pack(push, 1) struct _2devent { - BildingType uType; + BuildingType uType; unsigned __int16 uAnimationID; char *pName; const char *pProprieterName;
--- a/GUIProgressBar.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/GUIProgressBar.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -203,15 +203,19 @@ floorf(v4 + 0.5f),//COERCE_UNSIGNED_INT64(v4 + 6.7553994e15), 16, pRenderer->uTargetRMask); - goto LABEL_11; + pRenderer->EndScene(); + pRenderer->Present(); + return; } -LABEL_6: pRenderer->EndScene(); return; } if (!pLoadingBg.pPixels) - goto LABEL_6; + { + pRenderer->EndScene(); + return; + } pRenderer->DrawTextureRGB(0, 0, &pLoadingBg); pRenderer->SetRasterClipRect(0, 0, 0x27Fu, 0x1DFu); @@ -220,7 +224,6 @@ 0x1D7u); pRenderer->DrawTextureTransparent(0xACu, 0x1CBu, &pLoadingProgress); pRenderer->ResetTextureClipRect(); -LABEL_11: pRenderer->EndScene(); pRenderer->Present(); } \ No newline at end of file
--- a/GUIWindow.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/GUIWindow.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -249,11 +249,11 @@ //----- (0041D08F) -------------------------------------------------------- -void GUIWindow::_41D08F_set_keyboard_control_group(int a2, int a3, int a4, int a5) +void GUIWindow::_41D08F_set_keyboard_control_group(int num_buttons, int a3, int a4, int a5) { - if ( a2 ) + if (num_buttons) { - this->pNumPresenceButton = a2; + this->pNumPresenceButton = num_buttons; this->field_30 = a3; this->field_34 = a4; this->pCurrentPosActiveItem = a5; @@ -304,7 +304,7 @@ pTexture_Dialogue_Background->Release(); pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); dword_5C35D4 = 0; if ( bFlipOnExit ) { @@ -326,17 +326,17 @@ } case WINDOW_SpellBook: { - sub_41140B(); - sub_411473(); + OnCloseSpellBookPage(); + OnCloseSpellBook(); break; } case WINDOW_Book: { - OnCloseSpellBook(); + OnCloseBook(); break; } - case WINDOW_ChangeLocation: - { + case WINDOW_ChangeLocation: + { pTexture_outside->Release(); pTexture_Dialogue_Background->Release(); pIcons_LOD->SyncLoadedFilesCount(); @@ -393,19 +393,10 @@ GUIButton *GUIWindow::GetControl(unsigned int uID) { GUIButton *result; // eax@1 - unsigned int v3; // ecx@1 result = this->pControlsHead; - v3 = uID; - if ( (signed int)uID > 0 ) - { - do - { - result = result->pNext; - --v3; - } - while ( v3 ); - } + for ( uID; uID; --uID ) + result = result->pNext; return result; } @@ -442,9 +433,9 @@ InitializeBookFonts(); 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; - dword_50651C = 0; + full_num_items_in_book = 0; + books_primary_item_per_page = 0; + books_page_number = 0; num_achieved_awards = 0; switch (v1->par1C) { @@ -468,9 +459,10 @@ else if ( v18 & 0x40 ) max_beacons = 3; - + + //__debugbreak(); // warning C4700: uninitialized local variable 'v19' used for (int i =0; i< max_beacons; ++i) - CreateButton(pLloydsBeaconsPreviewXs[v19], pLloydsBeaconsPreviewYs[v19], + CreateButton(pLloydsBeaconsPreviewXs[i], pLloydsBeaconsPreviewYs[i], 92, 68, 1, 180, UIMSG_InstallBeacon, i, 0, "", 0); for (int i =0; i< 5; ++i) @@ -492,7 +484,9 @@ pTexture_TownPortalIcons[3] = pIcons_LOD->LoadTexturePtr("tpisland", TEXTURE_16BIT_PALETTE); pTexture_TownPortalIcons[4] = pIcons_LOD->LoadTexturePtr("tpheaven", TEXTURE_16BIT_PALETTE); pTexture_TownPortalIcons[5] = pIcons_LOD->LoadTexturePtr("tphell", TEXTURE_16BIT_PALETTE); - + + static int pTownPortalBook_ws[6] = { 80, 66, 68, 72, 67, 74}; + static int pTownPortalBook_hs[6] = { 55, 56, 65, 67, 67, 59}; 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); @@ -517,7 +511,7 @@ pTex_tab_an_7b__zoot_on, 0); num_achieved_awards = 0; memset(achieved_awards.data(), 0, 4000); - for ( i = dword_506528; i < 512; ++i ) + for ( i = books_primary_item_per_page; i < 512; ++i ) { // v14 = (char *)pQuestTable[i];//(&dword_722F10)[4 * i]; if ( _449B57_test_bit(pParty->_quest_bits, i) && pQuestTable[i] ) @@ -528,7 +522,7 @@ } v12 = num_achieved_awards; num_achieved_awards = 0; - num_achieved_awards_2 = v12; + full_num_items_in_book = v12; } break; @@ -572,7 +566,7 @@ UIMSG_ClickBooksBtn, 7, 0, pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0); // "Instructors" num_achieved_awards = 0; - for ( i = dword_506528; i < 196; ++i ) + for ( i = books_primary_item_per_page; i < 196; ++i ) if ( _506568_autonote_type == pAutonoteTxt[i].eType)//dword_72371C[2 * v10] ) { if ( i ) @@ -658,17 +652,17 @@ v26.uFrameW = v26.uFrameHeight + 69; memset(&achieved_awards, 0, 4000); memset(byte_5C6D50.data(), 0, 0x64u); - if ( dword_506528 < 29 ) + if ( books_primary_item_per_page < 29 ) { - v3 = (__int64 *)&pParty->field_3C.field_4F0[2 * dword_506528]; - for(int i=dword_506528+1;i<dword_506528+31;i++) + v3 = (__int64 *)&pParty->field_3C.field_4F0[2 * books_primary_item_per_page]; + for(int i = books_primary_item_per_page+1; i < books_primary_item_per_page + 31; i++) { v4 = pStorylineText->StoreLine[i].pText; if ( *v3 ) { if ( v4 ) { - v5 = BuilDialogueString(v4, uActiveCharacter - 1, 0, 0, 0, v3); + v5 = BuildDialogueString(v4, uActiveCharacter - 1, 0, 0, 0, v3); v6 = pAutonoteFont->CalcTextHeight(v5, &v26, 1, 0); v7 = (v6 - 3) / (signed int)v26.uFrameHeight; v8 = v7 + 1; @@ -872,8 +866,8 @@ //v4 = (12 * pPlayer->lastOpenedSpellbookPage + pSpellbookSpellIndices[pPlayer->lastOpenedSpellbookPage][i + 1]); CreateButton(pViewport->uViewportTL_X + pIconPos[v4][pSpellbookSpellIndices[v4][i+1]].Xpos, pViewport->uViewportTL_Y + pIconPos[v4][pSpellbookSpellIndices[v4][i+1]].Ypos, //dword_4E20D0 - dword_506408[i + 1]->uTextureWidth, - dword_506408[i + 1]->uTextureHeight, + SBPageSSpellsTextureList[i + 1]->uTextureWidth, + SBPageSSpellsTextureList[i + 1]->uTextureHeight, 1, 79, UIMSG_SelectSpell, i, 0, "", 0); ++a2; //++v3; @@ -894,10 +888,10 @@ if (pPlayer->pActiveSkills[PLAYER_SKILL_LIGHT]) CreateButton(400, 271, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 7, 0, aSpellSchoolNames[7], 0); if (pPlayer->pActiveSkills[PLAYER_SKILL_DARK]) CreateButton(400, 307, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 8, 0, aSpellSchoolNames[8], 0); - CreateButton(476, 450, pTexture_506444->uTextureWidth, pTexture_506444->uTextureHeight, 1, 78, UIMSG_ClickInstallRemoveQuickSpellBtn, 0, 0, "", 0); - pBtn_InstallRemoveSpell = CreateButton(476, 450, 48, 32, 1, 78, UIMSG_ClickInstallRemoveQuickSpellBtn, 0, 0, "", pTexture_506444, 0); - CreateButton(561, 450, ptr_506440->uTextureWidth, ptr_506440->uTextureHeight, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); - pBtn_CloseBook = CreateButton(561, 450, 48, 32, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], ptr_506440, 0); + CreateButton(476, 450, pSBClickQuickSpellBtnTextr->uTextureWidth, pSBClickQuickSpellBtnTextr->uTextureHeight, 1, 78, UIMSG_ClickInstallRemoveQuickSpellBtn, 0, 0, "", 0); + pBtn_InstallRemoveSpell = CreateButton(476, 450, 48, 32, 1, 78, UIMSG_ClickInstallRemoveQuickSpellBtn, 0, 0, "", pSBClickQuickSpellBtnTextr, 0); + CreateButton(561, 450, pSpellBookClickCloseBtnTextr->uTextureWidth, pSpellBookClickCloseBtnTextr->uTextureHeight, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); + pBtn_CloseBook = CreateButton(561, 450, 48, 32, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pSpellBookClickCloseBtnTextr, 0); } // 50640C: using guessed type int dword_50640C[]; @@ -947,7 +941,7 @@ pWindow.uFrameZ += 8; if ( !pDialogueNPCCount ) { - if ( in_current_building_type == BildingType_Jail ) + if ( in_current_building_type == BuildingType_Jail ) { JailDialog(); if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) @@ -1054,56 +1048,56 @@ pWindow.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, pColor2, pTmpBuf.data(), 3); switch ( in_current_building_type ) { - case BildingType_WeaponShop: + case BuildingType_WeaponShop: WeaponShopDialog(); break; - case BildingType_ArmorShop: + case BuildingType_ArmorShop: ArmorShopDialog(); break; - case BildingType_MagicShop: + case BuildingType_MagicShop: MagicShopDialog(); break; - case BildingType_AlchemistShop: + case BuildingType_AlchemistShop: AlchemistDialog(); break; - case BildingType_FireGuild: - case BildingType_AirGuild: - case BildingType_WaterGuild: - case BildingType_EarthGuild: - case BildingType_SpiritGuild: - case BildingType_MindGuild: - case BildingType_BodyGuild: - case BildingType_LightGuild: - case BildingType_DarkGuild: + case BuildingType_FireGuild: + case BuildingType_AirGuild: + case BuildingType_WaterGuild: + case BuildingType_EarthGuild: + case BuildingType_SpiritGuild: + case BuildingType_MindGuild: + case BuildingType_BodyGuild: + case BuildingType_LightGuild: + case BuildingType_DarkGuild: GuildDialog(); break; - case BildingType_18: + case BuildingType_18: __debugbreak(); //What over the dialog? sub_4B6478(); break; - case BildingType_TownHall: + case BuildingType_TownHall: TownHallDialog(); break; - case BildingType_Tavern: + case BuildingType_Tavern: TavernDialog(); break; - case BildingType_Bank: + case BuildingType_Bank: BankDialog(); break; - case BildingType_Temple: + case BuildingType_Temple: TempleDialog(); break; - case BildingType_Stables: + case BuildingType_Stables: TravelByTransport(); break; - case BildingType_Training: + case BuildingType_Training: TrainingDialog(); break; - case BildingType_Jail: + case BuildingType_Jail: JailDialog(); break; default: - __debugbreak();//New BildingType + //__debugbreak();//New BuildingType (if enter Boat) break; } } @@ -1154,7 +1148,7 @@ v8 = pGlobalTXT_LocalizationStrings[57]; if ( v18 <= 1 ) v8 = pGlobalTXT_LocalizationStrings[56]; - sprintf(pTmpBuf2.data(), "%d %s ", v18, v8); + sprintfex(pTmpBuf2.data(), "%d %s ", v18, v8); strcat(pTmpBuf.data(), pTmpBuf2.data()); } if ( v7 ) @@ -1163,7 +1157,7 @@ v9 = pGlobalTXT_LocalizationStrings[109]; else v9 = pGlobalTXT_LocalizationStrings[110]; - sprintf(pTmpBuf2.data(), "%d %s ", v7, v9); + sprintfex(pTmpBuf2.data(), "%d %s ", v7, v9); strcat(pTmpBuf.data(), pTmpBuf2.data()); } if ( v16 && !v18 ) @@ -1172,7 +1166,7 @@ v10 = pGlobalTXT_LocalizationStrings[437];//"Minute" else v10 = pGlobalTXT_LocalizationStrings[436]; //"Minutes" - sprintf(pTmpBuf2.data(), "%d %s ", v16, v10); + sprintfex(pTmpBuf2.data(), "%d %s ", v16, v10); strcat(pTmpBuf.data(), pTmpBuf2.data()); } if ( v17 && !v7 ) @@ -1181,7 +1175,7 @@ v11 = pGlobalTXT_LocalizationStrings[439]; //"Second" else v11 = pGlobalTXT_LocalizationStrings[438]; //"Seconds" - sprintf(pTmpBuf2.data(), "%d %s ", v17, v11); + sprintfex(pTmpBuf2.data(), "%d %s ", v17, v11); strcat(pTmpBuf.data(), pTmpBuf2.data()); } v12 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
--- a/GUIWindow.h Tue Aug 06 00:52:46 2013 +0400 +++ b/GUIWindow.h Tue Aug 06 00:56:33 2013 +0400 @@ -19,7 +19,7 @@ UIMSG_MouseLeftClickInScreen = 14, UIMSG_F = 15, - UIMSG_11 = 17, + UIMSG_ChangeCursor = 17, UIMSG_Attack = 23, @@ -229,7 +229,7 @@ enum DIALOGUE_TYPE { - DIALOGUE_9 = 9, + DIALOGUE_USE_NPC_ABILITY = 9, DIALOGUE_13 = 0xD, DIALOGUE_18 = 0x12, DIALOGUE_19 = 19, @@ -337,7 +337,7 @@ void DrawMessageBox(int arg0); GUIButton *GetControl(unsigned int uID); void Release(); - void _41D08F_set_keyboard_control_group(int a2, int a3, int a4, int a5); + void _41D08F_set_keyboard_control_group(int num_buttons, int a3, int a4, int a5); void _41D73D_draw_buff_tooltip(); static GUIWindow *Create(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, enum WindowType eWindowType, int pButton, const char* hint); @@ -545,7 +545,7 @@ void BookUI_Calendar_Draw(); void BookUI_Journal_Draw(); -void OnCloseSpellBook(); +void OnCloseBook(); void InitializeBookTextures(); void InitializeBookFonts(); void DrawSpellBookContent(Player *player); @@ -553,8 +553,8 @@ void BookUI_DrawTownPortalMap(); void LoadSpellbook(unsigned int uID); // idb void DrawSpellDescriptionPopup(int spell_index); -void sub_41140B(); -void sub_411473(); +void OnCloseSpellBookPage(); +void OnCloseSpellBook(); @@ -724,6 +724,7 @@ extern int uTextureID_GameUI_CharSelectionFrame; // 50C98C extern unsigned int ui_mainmenu_copyright_color; +extern unsigned int ui_character_tooltip_header_default_color; extern unsigned int ui_character_default_text_color; extern unsigned int ui_character_skill_highlight_color; extern unsigned int ui_character_header_text_color; @@ -731,6 +732,12 @@ extern unsigned int ui_character_bonus_text_color_neg; extern unsigned int ui_character_skill_upgradeable_color; extern unsigned int ui_character_skill_default_color; +extern unsigned int ui_character_stat_default_color; +extern unsigned int ui_character_stat_buffed_color; +extern unsigned int ui_character_stat_debuffed_color; +extern unsigned int ui_character_skillinfo_can_learn; +extern unsigned int ui_character_skillinfo_can_learn_gm; +extern unsigned int ui_character_skillinfo_cant_learn; extern std::array<unsigned int, 6> ui_character_award_color; extern unsigned int ui_game_minimap_outline_color; extern unsigned int ui_game_minimap_actor_friendly_color; @@ -760,4 +767,8 @@ extern unsigned int ui_book_calendar_location_color; extern unsigned int ui_book_journal_title_color; extern unsigned int ui_book_journal_text_color; -extern unsigned int ui_book_journal_text_shadow; \ No newline at end of file +extern unsigned int ui_book_journal_text_shadow; +extern unsigned int ui_game_dialogue_npc_name_color; +extern unsigned int ui_game_dialogue_option_highlight_color; +extern unsigned int ui_game_dialogue_option_normal_color; +extern unsigned int ui_house_player_cant_interact_color; \ No newline at end of file
--- a/Game.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Game.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -16,8 +16,6 @@ #include "stru6.h" #include "stru9.h" #include "stru10.h" -#include "stru11.h" -#include "stru12.h" #include "Game.h" #include "Party.h" @@ -91,10 +89,12 @@ if ( pVideoPlayer->AnyMovieLoaded() ) { - if ( pRenderer->pRenderD3D ) - goto LABEL_22; - pRenderer->BeginSceneD3D(); - pMouse->DrawCursorToTarget(); + if ( !pRenderer->pRenderD3D ) + { + pRenderer->BeginSceneD3D(); + pMouse->DrawCursorToTarget(); + pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); + } } else { @@ -132,12 +132,11 @@ if (pRenderer->pRenderD3D) { pDecalBuilder->DrawBloodsplats(); - pGame->pLightmapBuilder->DrawLightmaps(2); + pGame->pLightmapBuilder->DrawLightmapsType(2); } } + pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); } - pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); -LABEL_22: //DEBUG: force redraw gui viewparams->bRedrawGameUI = true; @@ -787,7 +786,7 @@ } //----- (0044EC23) -------------------------------------------------------- -int Game::_44EC23(stru148 *a2, int *a3, signed int a4) +int Game::_44EC23(struct Polygon *a2, int *a3, signed int a4) { double v4; // st7@4 //double v5; // ST00_8@4 @@ -943,7 +942,8 @@ uSomeGammaStartTime = 0; uSomeGammaDeltaTime = 0; - pThreadWardInstance = new ThreadWard; + //pThreadWardInstance = new ThreadWard; + pThreadWardInstance = nullptr; pParticleEngine = new ParticleEngine; pMouse = pMouseInstance = new Mouse(pThreadWardInstance); pLightmapBuilder = new LightmapBuilder; @@ -952,9 +952,12 @@ pIndoorCameraD3D = new IndoorCameraD3D; pStru9Instance = new stru9; pStru10Instance = new stru10; - pStru11Instance = new stru11; - pStru12Instance = new stru12(pStru11Instance); - pCShow = new CShow; + //pStru11Instance = new stru11; + pStru11Instance = nullptr; + //pStru12Instance = new stru12(pStru11Instance); + pStru12Instance = nullptr; + //pCShow = new CShow; + pCShow = nullptr; pKeyboardInstance = new Keyboard; pGammaController = new GammaController; @@ -976,12 +979,12 @@ delete pGammaController; if (pKeyboardInstance) delete pKeyboardInstance; - if (pCShow) + /*if (pCShow) delete pCShow; if (pStru12Instance) delete pStru12Instance; if (pStru11Instance) - delete pStru11Instance; + delete pStru11Instance;*/ if (pStru10Instance) delete pStru10Instance; if (pStru9Instance) @@ -998,8 +1001,8 @@ delete pMouseInstance; if (pParticleEngine) delete pParticleEngine; - if (pThreadWardInstance) - delete pThreadWardInstance; + //if (pThreadWardInstance) + // delete pThreadWardInstance; } //----- (0044E904) -------------------------------------------------------- @@ -1023,10 +1026,13 @@ || SHIDWORD(v2) < ((unsigned int)v2 < LODWORD(uSomeGammaStartTime)) + HIDWORD(uSomeGammaStartTime) | v4 == 0 && v3 <= 0x80 ) { - if ( v4 > 0 || v4 >= 0 ) - goto LABEL_12; - v3 = 0; - v4 = 0; + if ( v4 < 0 ) + { + v3 = 0; + v4 = 0; + uSomeGammaStartTime = v2; + v8 = __PAIR__(v4, v3); + } } else { @@ -1043,10 +1049,9 @@ v5 = __CFADD__(v3, -128); v3 -= 128; v4 = v5 + v4 - 1; + uSomeGammaStartTime = v2; + v8 = __PAIR__(v4, v3); } - uSomeGammaStartTime = v2; - v8 = __PAIR__(v4, v3); -LABEL_12: if ( uSomeGammaDeltaTime ) v6 = (double)(signed __int64)(uSomeGammaDeltaTime - __PAIR__(v4, v3)); else
--- a/Game.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Game.h Tue Aug 06 00:56:33 2013 +0400 @@ -2,6 +2,7 @@ #include "VectorTypes.h" +#define GAME_FLAGS_1_01 0x01 #define GAME_FLAGS_1_DRAW_BLV_DEBUGS 0x08 #define GAME_FLAGS_2_SATURATE_LIGHTMAPS 0x02 #define GAME_FLAGS_2_ALTER_GRAVITY 0x08 @@ -77,8 +78,6 @@ class GammaController; struct stru9; struct stru10; -struct stru11; -struct stru12; /* 104 */ #pragma pack(push, 1) @@ -97,7 +96,7 @@ bool PickMouse(float fPickDepth, unsigned int uMouseX, unsigned int uMouseY, bool bOutline, struct Vis_SelectionFilter *sprite_filter, struct Vis_SelectionFilter *face_filter); bool PickKeyboard(bool bOutline, struct Vis_SelectionFilter *sprite_filter, struct Vis_SelectionFilter *face_filter); void OutlineSelection(); - signed int _44EC23(struct stru148 *a2, int *a3, signed int a4); + signed int _44EC23(struct Polygon *a2, int *a3, signed int a4); signed int _44ED0A(struct BLVFace *a2, int *a3, signed int a4); bool AlterGamma_BLV(struct BLVFace *pFace, unsigned int *pColor); bool AlterGamma_ODM(struct ODMFace *pFace, unsigned int *pColor); @@ -154,7 +153,7 @@ float fSaturation; unsigned __int64 uSomeGammaStartTime; __int64 uSomeGammaDeltaTime; - ThreadWard *pThreadWardInstance; + void/*ThreadWard*/ *pThreadWardInstance; ParticleEngine *pParticleEngine; Mouse *pMouseInstance; LightmapBuilder *pLightmapBuilder; @@ -163,9 +162,9 @@ IndoorCameraD3D *pIndoorCameraD3D; stru9 *pStru9Instance; stru10 *pStru10Instance; - stru11 *pStru11Instance; - stru12 *pStru12Instance; - CShow *pCShow; + void/*stru11*/ *pStru11Instance; + void/*stru12*/ *pStru12Instance; + void/*CShow*/ *pCShow; Keyboard *pKeyboardInstance; GammaController *pGammaController; int field_E74;
--- a/GammaControl.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/GammaControl.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -72,16 +72,18 @@ { v3 = (double)v6 * 0.0039215689 * this->fGamma; if ( v3 >= 1.0 || (v4 = (signed __int64)(v3 * 65535.0), (signed int)v4 > 65535) ) - goto LABEL_12; - if ( (signed int)v4 < 0 ) + { + LODWORD(v4) = 65535; + } + else if ( (signed int)v4 < 0 ) { LODWORD(v4) = 0; - goto LABEL_8; } + else + { if ( (signed int)v4 > 65535 ) -LABEL_12: LODWORD(v4) = 65535; -LABEL_8: + } ++v6; v2[256] = v4; *v2 = v4;
--- a/GammaControl.h Tue Aug 06 00:52:46 2013 +0400 +++ b/GammaControl.h Tue Aug 06 00:56:33 2013 +0400 @@ -1,5 +1,6 @@ #pragma once #include "lib\legacy_dx\d3d.h" +#include "OSAPI.h" #pragma pack(push, 1) class GammaController
--- a/Indoor.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Indoor.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -62,8 +62,7 @@ stru320 stru_F8AD28; // idb stru337 stru_F81018; -stru167_wrap array_5118E8; -BspRenderer_stru2 stru_F8A590; +BspRenderer_PortalViewportData stru_F8A590; BspRenderer *pBspRenderer = new BspRenderer; // idb stru141 stru_721530; std::array<stru352, 480> stru_F83B80; @@ -314,8 +313,9 @@ } else for (uint j = 0; j < pBspRenderer->num_faces; ++j ) { - pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[j].uNodeID].field_C; - IndoorLocation::ExecDraw_sw(pBspRenderer->faces[j].uFaceID); + __debugbreak(); // no SW + //pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[j].uNodeID].PortalScreenData; + //IndoorLocation::ExecDraw_sw(pBspRenderer->faces[j].uFaceID); } } @@ -347,22 +347,22 @@ for(int i=0; i < pBspRenderer->num_nodes; i++) { BspRenderer_stru0 *pNode = &pBspRenderer->nodes[i]; - v4 = pRenderer->uTargetSurfacePitch * pNode->field_C._viewport_space_y; - if ( pNode->field_C._viewport_space_y <= pNode->field_C._viewport_space_w ) + v4 = pRenderer->uTargetSurfacePitch * pNode->PortalScreenData._viewport_space_y; + if ( pNode->PortalScreenData._viewport_space_y <= pNode->PortalScreenData._viewport_space_w ) { //v5 = (char *)&pBspRenderer->nodes[0].field_C.array_3D8[pNode->field_C._viewport_space_y + v7]; - v5 = &pNode->field_C.viewport_right_side[pNode->field_C._viewport_space_y]; - v8 = &pNode->field_C.viewport_left_side[pNode->field_C._viewport_space_y]; + v5 = &pNode->PortalScreenData.viewport_right_side[pNode->PortalScreenData._viewport_space_y]; + v8 = &pNode->PortalScreenData.viewport_left_side[pNode->PortalScreenData._viewport_space_y]; do { v1[v4 + *v8] = 255; - ++pNode->field_C._viewport_space_y; + ++pNode->PortalScreenData._viewport_space_y; v1[v4 + *v5] = 255; v4 += pRenderer->uTargetSurfacePitch; ++v5; ++v8; } - while ( pNode->field_C._viewport_space_y <= pNode->field_C._viewport_space_w ); + while ( pNode->PortalScreenData._viewport_space_y <= pNode->PortalScreenData._viewport_space_w ); } } } @@ -411,7 +411,7 @@ sub_440BED(&_this); pParty->uFlags &= ~2; pGame->DrawParticles(); - array_5118E8._440F07(); + trail_particle_generator.UpdateParticles(); } //----- (004C0EF2) -------------------------------------------------------- @@ -583,13 +583,13 @@ } else { - v17 = 0xFFD0D0D0; + v17 = 0xFF808080; v23 = pFace->uBitmapID; v27 = pBitmaps_LOD->pHardwareTextures[v23]; } if (pFace->uAttributes & FACE_DO_NOT_LIGHT) - _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); + pRenderer->DrawIndoorPolygonNoLight(uNumVerticesa, uFaceID); else pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, PID(OBJECT_BModel, uFaceID), v17, 0); return; @@ -598,619 +598,6 @@ } } -//----- (004AFF79) -------------------------------------------------------- -void IndoorLocation::ExecDraw_sw(unsigned int uFaceID) -{ - unsigned int v1; // ebx@1 - BLVFace *v2; // esi@3 - unsigned int v3; // eax@3 - Texture *v4; // eax@8 - Texture *v5; // edi@8 - int v6; // eax@9 - int v7; // eax@9 - int v8; // ecx@17 - int v9; // ebx@17 - int v10; // eax@17 - int v11; // esi@17 - unsigned int v12; // eax@17 - int j; // ecx@19 - int v14; // edx@20 - int v15; // eax@20 - int v16; // edx@20 - int i; // ebx@22 - int v18; // ecx@23 - int v19; // eax@23 - int v20; // eax@23 - int v21; // eax@24 - unsigned __int8 *v22; // ecx@24 - int v23; // ebx@24 - int v24; // esi@25 - int v25; // eax@28 - unsigned __int16 *v26; // eax@28 - unsigned int v27; // eax@29 - int v28; // eax@30 - char *v29; // esi@31 - int v30; // eax@33 - int v31; // eax@33 - int v32; // eax@35 - int v33; // edx@35 - signed int v34; // ebx@35 - int v35; // eax@35 - int v36; // ebx@35 - signed int v37; // ebx@35 - signed int v38; // edi@35 - unsigned int v39; // edi@36 - int v40; // edx@40 - int v41; // ecx@40 - signed int v42; // edx@40 - int v43; // edx@42 - int v44; // eax@42 - unsigned __int16 *v45; // eax@43 - int *v46; // esi@44 - unsigned __int16 *v47; // edi@44 - unsigned int v48; // edx@44 - int v49; // ebx@44 - char v50; // cl@44 - char v51; // ch@44 - unsigned int v52; // ebx@46 - int v53; // edx@46 - unsigned int v54; // ebx@46 - int v55; // edx@46 - unsigned int v56; // ebx@47 - int v57; // edx@47 - int v58; // ebx@47 - int v59; // edx@47 - unsigned __int16 *v60; // eax@50 - int *v61; // esi@51 - unsigned __int16 *v62; // edi@51 - unsigned int v63; // edx@51 - int v64; // ebx@51 - char v65; // cl@51 - char v66; // ch@51 - unsigned int v67; // ebx@53 - int v68; // edx@53 - unsigned int v69; // ebx@53 - int v70; // edx@53 - unsigned int v71; // ebx@54 - int v72; // edx@54 - int v73; // ebx@54 - int v74; // edx@54 - unsigned __int16 *v75; // eax@58 - int *v76; // esi@59 - int v77; // edi@59 - unsigned int v78; // edx@59 - int v79; // ebx@59 - char v80; // cl@59 - char v81; // ch@59 - int v82; // ebx@61 - int v83; // edx@61 - unsigned int v84; // ebx@62 - int v85; // edx@62 - unsigned __int16 *v86; // eax@65 - int *v87; // esi@66 - int v88; // edi@66 - unsigned int v89; // edx@66 - int v90; // ebx@66 - char v91; // cl@66 - char v92; // ch@66 - int v93; // ebx@68 - int v94; // edx@68 - unsigned __int16 v95; // bx@69 - int v96; // edx@69 - unsigned __int8 *v97; // [sp+Ch] [bp-9Ch]@24 - unsigned __int8 *v98; // [sp+10h] [bp-98h]@24 - unsigned __int8 *v99; // [sp+14h] [bp-94h]@24 - unsigned __int8 *v100; // [sp+18h] [bp-90h]@24 - int v101; // [sp+1Ch] [bp-8Ch]@40 - int v102; // [sp+20h] [bp-88h]@31 - BLVFace *v103; // [sp+24h] [bp-84h]@3 - unsigned __int16 *v104; // [sp+28h] [bp-80h]@24 - int v105; // [sp+2Ch] [bp-7Ch]@30 - int v106; // [sp+30h] [bp-78h]@24 - int v107; // [sp+34h] [bp-74h]@9 - Texture *v108; // [sp+38h] [bp-70h]@8 - int v109; // [sp+3Ch] [bp-6Ch]@9 - unsigned int v110; // [sp+40h] [bp-68h]@24 - unsigned int v111; // [sp+44h] [bp-64h]@1 - int *k; // [sp+48h] [bp-60h]@31 - int v113; // [sp+4Ch] [bp-5Ch]@35 - int v114; // [sp+50h] [bp-58h]@35 - int v115; // [sp+54h] [bp-54h]@42 - unsigned __int8 *v116; // [sp+58h] [bp-50h]@35 - int v117; // [sp+5Ch] [bp-4Ch]@33 - int a1; // [sp+60h] [bp-48h]@27 - int v119; // [sp+64h] [bp-44h]@17 - int v120; // [sp+68h] [bp-40h]@23 - unsigned int v121; // [sp+6Ch] [bp-3Ch]@40 - unsigned int v122; // [sp+70h] [bp-38h]@35 - int v123; // [sp+74h] [bp-34h]@30 - int v124; // [sp+78h] [bp-30h]@17 - int v125; // [sp+7Ch] [bp-2Ch]@35 - unsigned int v126; // [sp+80h] [bp-28h]@9 - int v127; // [sp+84h] [bp-24h]@17 - int v128; // [sp+88h] [bp-20h]@9 - int *pZPixel; // [sp+8Ch] [bp-1Ch]@28 - int a2; // [sp+90h] [bp-18h]@16 - unsigned int v131; // [sp+94h] [bp-14h]@17 - unsigned __int16 *pColorPixel; // [sp+98h] [bp-10h]@28 - int v133; // [sp+9Ch] [bp-Ch]@17 - int v134; // [sp+A0h] [bp-8h]@17 - int v135; // [sp+A4h] [bp-4h]@24 - - v1 = uFaceID; - v111 = pRenderer->uTargetSurfacePitch; - if ( (uFaceID & 0x80000000u) == 0 ) - { - if ( (signed int)uFaceID < (signed int)pIndoor->uNumFaces ) - { - v2 = &pIndoor->pFaces[uFaceID]; - v103 = v2; - v3 = v2->uAttributes; - if ( !(BYTE1(v3) & 0x20) ) - { - if ( v3 & 0x400000 ) - { - sub_4ADD1D(uFaceID); - return; - } - if ( !(v3 & 0x10) || (sub_4AD504(uFaceID), pRenderer->pRenderD3D) ) - { - v4 = v2->GetTexture(); - ++pBLVRenderParams->uNumFacesRenderedThisFrame; - v5 = v4; - v108 = v4; - if ( v4 ) - { - v6 = v4->palette_id2; - LOBYTE(v2->uAttributes) |= 0x80u; - v109 = v6; - sub_4AE5F1(v1); - v126 = stru_F8AD28.pDeltaUV[0]; - v128 = stru_F8AD28.pDeltaUV[1]; - v107 = bUseLoResSprites; - v7 = GetPortalScreenCoord(v1); - if ( v7 ) - { - if ( sub_424829(v7, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) - { - if ( v2->uPolygonType == 1 ) - { - for ( i = 0; i < stru_F8AD28.uNumLightsApplied; stru_F8AD28._blv_lights_ys[v18] = v20 ) - { - v18 = i; - v120 = stru_F8AD28._blv_lights_xs[i]; - v134 = (unsigned __int64)(v120 * (signed __int64)-stru_F8AD28.plane_4.vNormal.y) >> 16; - v133 = stru_F8AD28.plane_4.vNormal.x; - v120 = stru_F8AD28._blv_lights_ys[i]; - v133 = (unsigned __int64)(v120 * (signed __int64)stru_F8AD28.plane_4.vNormal.x) >> 16; - v19 = v128; - stru_F8AD28._blv_lights_xs[i] = v126 - + v134 - + ((unsigned __int64)(v120 - * (signed __int64)stru_F8AD28.plane_4.vNormal.x) >> 16); - v20 = v19 - stru_F8AD28._blv_lights_zs[i++]; - } - } - else - { - if ( v2->uPolygonType != 3 ) - { - if ( v2->uPolygonType == 4 ) - { -LABEL_16: - a2 = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 ) - { - do - { - v8 = a2; - v9 = stru_F8AD28._blv_lights_xs[a2]; - v131 = stru_F8AD28._blv_lights_ys[a2]; - v10 = stru_F8AD28._blv_lights_zs[a2]; - v11 = (signed int)(v10 * stru_F8AD28.plane_4.vNormal.z - + stru_F8AD28.plane_4.dist - + v9 * stru_F8AD28.plane_4.vNormal.x - + v131 * stru_F8AD28.plane_4.vNormal.y) >> 16; - v119 = v9 - - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x - * (signed __int64)((signed int)(v10 * stru_F8AD28.plane_4.vNormal.z - + stru_F8AD28.plane_4.dist - + v9 * stru_F8AD28.plane_4.vNormal.x - + v131 * stru_F8AD28.plane_4.vNormal.y) >> 16)) >> 16); - v131 -= (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)v11) >> 16; - v127 = v10 - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z * (signed __int64)v11) >> 16); - stru_F8AD28._blv_lights_xs[a2] = ((unsigned __int64)(v119 - * (signed __int64)stru_F8AD28.vec_14.x) >> 16) - + ((unsigned __int64)((signed int)v131 - * (signed __int64)stru_F8AD28.vec_14.y) >> 16); - v124 = (unsigned __int64)(v119 * (signed __int64)stru_F8AD28.vec_20.x) >> 16; - v134 = (unsigned __int64)((signed int)v131 * (signed __int64)stru_F8AD28.vec_20.y) >> 16; - v133 = (unsigned __int64)(v127 * (signed __int64)stru_F8AD28.vec_20.z) >> 16; - v12 = v126; - stru_F8AD28._blv_lights_ys[v8] = v124 - + ((unsigned __int64)((signed int)v131 - * (signed __int64)stru_F8AD28.vec_20.y) >> 16) - + ((unsigned __int64)(v127 - * (signed __int64)stru_F8AD28.vec_20.z) >> 16); - stru_F8AD28._blv_lights_xs[v8] += v12; - stru_F8AD28._blv_lights_ys[v8] += v128; - ++a2; - } - while ( a2 < stru_F8AD28.uNumLightsApplied ); - v2 = v103; - } - goto LABEL_24; - } - if ( v2->uPolygonType != 5 ) - { - if ( v2->uPolygonType != 6 ) - goto LABEL_24; - goto LABEL_16; - } - } - for ( j = 0; j < stru_F8AD28.uNumLightsApplied; *(int *)v15 = v16 ) - { - v14 = v128; - stru_F8AD28._blv_lights_xs[j] += v126; - v15 = 4 * j + 16297672; - v16 = v14 - stru_F8AD28._blv_lights_ys[j++]; - } - } -LABEL_24: - v135 = 1; - pGame->_44ED0A(v2, &v135, 31); - v104 = sr_sub_47C24C_get_palette(v2, v109, 0, 1); - v134 = stru_F8AD28.field_44; - v106 = stru_F8AD28.field_48; - v21 = stru_F8A590._viewport_space_y; - a2 = stru_F8A590._viewport_space_y; - v110 = v111 * stru_F8A590._viewport_space_y; - v97 = v5->pLevelOfDetail0_prolly_alpha_mask; - v98 = v5->pLevelOfDetail1; - v99 = v5->pLevelOfDetail2; - v22 = v5->pLevelOfDetail3; - v23 = 640 * stru_F8A590._viewport_space_y; - v119 = 640 * stru_F8A590._viewport_space_y; - v100 = v22; - if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) - { - v24 = 2 * stru_F8A590._viewport_space_y; - v120 = 2 * stru_F8A590._viewport_space_y; - while ( 1 ) - { - a1 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24); - sub_4AE313(a1, v21, &stru_F81018.field_0); - if ( LOBYTE(viewparams->field_20) ) - { - v27 = v111 * (v24 - pBLVRenderParams->uViewportY); - pZPixel = &pBLVRenderParams->pTargetZBuffer[2 - * (*(__int16 *)((char *)stru_F8A590.viewport_left_side + v24) - + 320 * (v24 - pBLVRenderParams->uViewportY)) - - pBLVRenderParams->uViewportX]; - pColorPixel = &pBLVRenderParams->pRenderTarget[v27 - + 2 * *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24) - - pBLVRenderParams->uViewportX]; - v26 = &pBLVRenderParams->pRenderTarget[v27 - + 2 * *(__int16 *)((char *)stru_F8A590.viewport_right_side + v24) - - pBLVRenderParams->uViewportX]; - v23 = v119; - } - else - { - v25 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24); - pZPixel = &pBLVRenderParams->pTargetZBuffer[v25 + v23]; - pColorPixel = &pBLVRenderParams->pRenderTarget[v25 + v110]; - v26 = &pBLVRenderParams->pRenderTarget[v110 + *(__int16 *)((char *)stru_F8A590.viewport_right_side + v24)]; - } - v131 = (unsigned int)v26; - HIWORD(v28) = HIWORD(stru_F81018.field_0.field_0); - LOWORD(v28) = 0; - v105 = stru_F8AD28.field_0 | v28; - v123 = sub_4AE491(SHIWORD(stru_F81018.field_0.field_4), SHIWORD(stru_F81018.field_0.field_8)); - if ( (unsigned int)pColorPixel < v131 ) - { - v102 = v107 + v106; - v29 = (char *)&stru_F81018.field_34.field_8; - a1 += v134; - for ( k = &stru_F81018.field_34.field_8; ; v29 = (char *)k ) - { - sub_4AE313(a1, a2, (stru337_stru0 *)(v29 - 8)); - v30 = *((int *)v29 - 2); - LOWORD(v30) = 0; - v117 = v105; - v31 = stru_F8AD28.field_0 | v30; - if ( v105 <= (unsigned int)v31 ) - v117 = v31; - v105 = v31; - v32 = *((int *)v29 - 14); - v122 = *((int *)v29 - 14) >> v107; - v33 = *((int *)v29 - 13); - v125 = *((int *)v29 - 13) >> v107; - v34 = *((int *)v29 - 1) - v32; - v113 = (*(int *)v29 - v33) >> v102; - v35 = *((int *)v29 - 11); - v114 = v34 >> v102; - v116 = (&v97)[4 * v35]; - v36 = v35 + 16 - v5->uWidthLn2; - v133 = v35 + 16; - v127 = v35 + v36; - v37 = v5->uWidthMinus1 >> v35; - v38 = v5->uHeightMinus1 >> v35 << (v35 + 16); - v128 = v37; - v126 = v38; - v39 = (unsigned int)(LOBYTE(viewparams->field_20) ? &pColorPixel[2 * v134] : &pColorPixel[v134]); - if ( v39 > v131 ) - v39 = v131; - v40 = *((short *)v29 + 1); - v41 = *((short *)v29 - 1); - v121 = v39; - v42 = sub_4AE491(v41, v40); - v101 = v42; - v124 = (signed int)(v39 - (int)pColorPixel) >> 1; - if ( v123 >> 16 == v42 >> 16 || v135 & 2 ) - { - v123 = (int)sr_sub_47C24C_get_palette(v103, v109, v123 >> 16, 1); - if ( LOBYTE(viewparams->field_20) ) - { - v86 = pColorPixel; - if ( (unsigned int)pColorPixel < v121 ) - { - v87 = pZPixel; - v88 = v123; - v89 = v122; - v90 = v125; - v91 = v133; - v92 = v127; - if ( v124 & 2 ) - { - *pZPixel = v117; - v87 -= 2; - v86 = pColorPixel + 2; - goto LABEL_69; - } - do - { - v86 += 4; - v93 = *(&v116[v128 & (v89 >> v91)] + ((v126 & v90) >> v92)); - v94 = v117; - LOWORD(v93) = *(short *)(v88 + 2 * v93); - *v87 = v117; - v87[1] = v94; - v87[640] = v94; - v87[641] = v94; - *(v86 - 4) = v93; - *(v86 - 3) = v93; - v86[636] = v93; - v86[637] = v93; - v87[2] = v94; - v87[3] = v94; - v87[642] = v94; - v87[643] = v94; - v122 += v114; - v125 += v113; - v89 = v122; - v90 = v125; -LABEL_69: - v87 += 4; - v95 = *(short *)(v88 + 2 * *(&v116[v128 & (v89 >> v91)] + ((v126 & v90) >> v92))); - v96 = v114; - *(v86 - 2) = v95; - *(v86 - 1) = v95; - v86[638] = v95; - v86[639] = v95; - v122 += v96; - v125 += v113; - v89 = v122; - v90 = v125; - } - while ( (unsigned int)v86 < v121 ); - pColorPixel = v86; - pZPixel = v87; - } - } - else - { - v75 = pColorPixel; - if ( (unsigned int)pColorPixel < v121 ) - { - v76 = pZPixel; - v77 = v123; - v78 = v122; - v79 = v125; - v80 = v133; - v81 = v127; - if ( v124 & 1 ) - { - *pZPixel = v117; - --v76; - v75 = pColorPixel + 1; - goto LABEL_62; - } - do - { - v75 += 2; - v82 = *(&v116[v128 & (v78 >> v80)] + ((v126 & v79) >> v81)); - v83 = v117; - LOWORD(v82) = *(short *)(v77 + 2 * v82); - *v76 = v117; - *(v75 - 2) = v82; - v76[1] = v83; - v122 += v114; - v125 += v113; - v78 = v122; - v79 = v125; -LABEL_62: - v84 = (unsigned int)(&v116[v128 & (v78 >> v80)] + ((v126 & v79) >> v81)); - v76 += 2; - v85 = v114; - *(v75 - 1) = *(short *)(v77 + 2 * *(char *)v84); - v122 += v85; - v125 += v113; - v78 = v122; - v79 = v125; - } - while ( (unsigned int)v75 < v121 ); - pColorPixel = v75; - pZPixel = v76; - } - } - } - else - { - v43 = (v42 - v123) >> v106; - v44 = v123 - v43; - v123 = v43; - v115 = v44; - if ( LOBYTE(viewparams->field_20) ) - { - v60 = pColorPixel; - if ( (unsigned int)pColorPixel < v121 ) - { - v61 = pZPixel; - v62 = v104; - v63 = v122; - v64 = v125; - v65 = v133; - v66 = v127; - if ( v124 & 2 ) - { - *pZPixel = v117; - v61 += 2; - v60 = pColorPixel + 2; - goto LABEL_54; - } - do - { - v67 = (v128 & (v63 >> v65)) + ((v126 & v64) >> v66); - v68 = v123 + v115; - v60 += 4; - v115 = v68; - v69 = ((v68 & 0xFFFF0000u) >> 8) + v116[v67]; - v70 = v117; - LOWORD(v69) = v62[v69]; - *v61 = v117; - v61[1] = v70; - v61[640] = v70; - v61[641] = v70; - *(v60 - 4) = v69; - *(v60 - 3) = v69; - v60[636] = v69; - v60[637] = v69; - v61[2] = v70; - v61[3] = v70; - v61[642] = v70; - v61[643] = v70; - v122 += v114; - v125 += v113; - v63 = v122; - v64 = v125; - v61 += 4; -LABEL_54: - v71 = (v128 & (v63 >> v65)) + ((v126 & v64) >> v66); - v72 = v123 + v115; - v73 = v116[v71]; - v115 = v72; - LOWORD(v73) = v62[((v72 & 0xFFFF0000u) >> 8) + v73]; - v74 = v114; - *(v60 - 2) = v73; - *(v60 - 1) = v73; - v60[638] = v73; - v60[639] = v73; - v122 += v74; - v125 += v113; - v63 = v122; - v64 = v125; - } - while ( (unsigned int)v60 < v121 ); - pColorPixel = v60; - pZPixel = v61; - } - } - else - { - v45 = pColorPixel; - if ( (unsigned int)pColorPixel < v121 ) - { - v46 = pZPixel; - v47 = v104; - v48 = v122; - v49 = v125; - v50 = v133; - v51 = v127; - if ( v124 & 1 ) - { - *pZPixel = v117; - ++v46; - v45 = pColorPixel + 1; - goto LABEL_47; - } - do - { - v52 = (v128 & (v48 >> v50)) + ((v126 & v49) >> v51); - v53 = v123 + v115; - v45 += 2; - v115 = v53; - v54 = ((v53 & 0xFFFF0000u) >> 8) + v116[v52]; - v55 = v117; - LOWORD(v54) = v47[v54]; - *v46 = v117; - *(v45 - 2) = v54; - v46[1] = v55; - v122 += v114; - v125 += v113; - v48 = v122; - v49 = v125; - v46 += 2; -LABEL_47: - v56 = (v128 & (v48 >> v50)) + ((v126 & v49) >> v51); - v57 = v123 + v115; - v58 = v116[v56]; - v115 = v57; - LOWORD(v58) = v47[((v57 & 0xFFFF0000u) >> 8) + v58]; - v59 = v114; - *(v45 - 1) = v58; - v122 += v59; - v125 += v113; - v48 = v122; - v49 = v125; - } - while ( (unsigned int)v45 < v121 ); - pColorPixel = v45; - pZPixel = v46; - } - } - } - k += 13; - v5 = v108; - v123 = v101; - a1 += v134; - if ( (unsigned int)pColorPixel >= v131 ) - break; - } - v23 = v119; - v24 = v120; - } - ++a2; - v110 += v111; - v23 += 640; - v24 += 2; - v120 = v24; - v119 = v23; - if ( a2 > stru_F8A590._viewport_space_w ) - break; - v21 = a2; - } - } - return; - } - } - } - } - } - } - } -} -// 4AE491: using guessed type int __fastcall sub_4AE491(int, int); @@ -1337,7 +724,7 @@ 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, + nodes[num_nodes].PortalScreenData.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); AddBspNodeToRenderList(++num_nodes - 1); return; @@ -1379,7 +766,7 @@ 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)) + PortalFrustrum(num_vertices, &nodes[num_nodes].PortalScreenData, &nodes[node_id].PortalScreenData, uFaceID)) { pTransitionSector = pFace->uSectorID; if (nodes[node_id].uSectorID == pTransitionSector ) @@ -1481,7 +868,7 @@ v3->nodes[v3->num_nodes].uViewportZ = LOWORD(pBLVRenderParams->uViewportZ); v3->nodes[v3->num_nodes].uViewportY = LOWORD(pBLVRenderParams->uViewportY); v3->nodes[v3->num_nodes].uViewportW = LOWORD(pBLVRenderParams->uViewportW); - v3->nodes[v3->num_nodes++].field_C.GetViewportData( + v3->nodes[v3->num_nodes++].PortalScreenData.GetViewportData( SLOWORD(pBLVRenderParams->uViewportX), pBLVRenderParams->uViewportY, SLOWORD(pBLVRenderParams->uViewportZ), @@ -1532,7 +919,7 @@ && v23 <= *((short *)v20 + 2007) && v12 >= *((short *)v20 + 2006) && v22 <= *((short *)v20 + 2008) - && sub_424829(v10, &v3->nodes[v3->num_nodes].field_C, (BspRenderer_stru2 *)(v20 + 4020), uFaceID) ) + && PortalFrustrum(v10, &v3->nodes[v3->num_nodes].PortalScreenData, (BspRenderer_PortalViewportData *)(v20 + 4020), uFaceID) ) { v16 = v21->uSectorID; if ( *((short *)v20 + 2004) == v16 ) @@ -1587,11 +974,11 @@ if ( v1 < (signed int)pIndoor->uNumFaces ) { v2 = pBspRenderer->faces[i].uFaceID; - pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].field_C; + pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].PortalScreenData; v3 = GetPortalScreenCoord(v2); if ( v3 ) { - if ( sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) + if ( PortalFrustrum(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) { v4 = stru_F8A590._viewport_space_y; v5 = pBLVRenderParams->pRenderTarget; @@ -4623,8 +4010,8 @@ if ( pDest ) { qword_A750D8 = 256i64; - word_A750E0 = 46; - word_A750E2 = LOWORD(v34[rand() % v30]); + PlayerSpeechID = SPEECH_46; + uSpeakingCharacter = LOWORD(v34[rand() % v30]); } } } @@ -5612,9 +4999,9 @@ local_0.x = v5; local_0.y = (double)v2->vPosition.y; local_0.z = (double)v2->vPosition.z; - local_0.flt_10 = 0.0; - local_0.flt_14 = 0.0; - local_0.flt_18 = 0.0; + local_0.r = 0.0; + local_0.g = 0.0; + local_0.b = 0.0; local_0.flt_28 = 1.0; local_0.timeToLive = (rand() & 0x80) + 128; local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); @@ -5734,7 +5121,7 @@ pBspRenderer->nodes[0].uViewportZ = pBLVRenderParams->uViewportZ; pBspRenderer->nodes[0].uViewportY = pBLVRenderParams->uViewportY; pBspRenderer->nodes[0].uViewportX = pBLVRenderParams->uViewportX; - pBspRenderer->nodes[0].field_C.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, + pBspRenderer->nodes[0].PortalScreenData.GetViewportData(pBLVRenderParams->uViewportX, pBLVRenderParams->uViewportY, pBLVRenderParams->uViewportZ, pBLVRenderParams->uViewportW); pBspRenderer->nodes[0].uFaceID = -1; pBspRenderer->nodes[0].viewing_portal_id = -1; @@ -5746,7 +5133,7 @@ } //----- (0043F9E1) -------------------------------------------------------- -void BspRenderer_stru2::GetViewportData(__int16 x, int y, __int16 z, int w) +void BspRenderer_PortalViewportData::GetViewportData(__int16 x, int y, __int16 z, int w) { _viewport_space_y = y; _viewport_space_w = w; @@ -6831,139 +6218,102 @@ check_event_triggers(); } //----- (00424829) -------------------------------------------------------- -bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, int uFaceID) +// Finds out if current portal can be seen through the previous portal +bool PortalFrustrum(int pNumVertices, BspRenderer_PortalViewportData *far_portal, BspRenderer_PortalViewportData *near_portal, int uFaceID) { - //int v4; // edi@1 - //BspRenderer_stru2 *v5; // ebx@1 - int v6; // eax@3 int min_y; // esi@5 int max_y; // edx@5 - //int v9; // ecx@6 - int v10; // eax@12 - //int v11; // edi@13 - //int v12; // edx@18 + int current_ID; // eax@12 int v13; // eax@22 - //int v14; // edi@28 int v15; // ecx@29 - //int v16; // edi@30 - //int v17; // edx@35 int v18; // eax@39 int v19; // eax@44 int v20; // ecx@44 - //int v21; // edi@45 int v22; // edi@46 - //__int16 *v23; // ecx@47 int v24; // edx@48 - //int v25; // eax@50 int v26; // eax@55 signed int v27; // edi@55 - //int v28; // edx@56 int v29; // edx@57 - //int v30; // eax@59 int v31; // eax@64 signed int v32; // edi@64 - //int v33; // edx@65 int v34; // eax@66 int v35; // dx@66 __int16 v36; // dx@67 - __int16 v37; // di@67 + //__int16 v37; // di@67 __int16 v38; // dx@67 - //BspRenderer_stru2 *v39; // ecx@69 - //int v40; // edx@69 - //int v41; // edi@70 - //__int16 *v42; // eax@76 - //__int16 *v43; // eax@81 - //__int16 *v45; // eax@87 int v46; // edx@87 - //__int16 v47; // cx@88 - //int v48; // eax@93 int v49; // esi@93 - //__int16 *v50; // ecx@94 - //int v51; // eax@95 - //int v52; // eax@97 int v53; // [sp+Ch] [bp-34h]@44 int v54; // [sp+10h] [bp-30h]@0 - int v55; // [sp+14h] [bp-2Ch]@12 - //__int16 *v56; // [sp+14h] [bp-2Ch]@47 - //__int16 v57; // [sp+14h] [bp-2Ch]@76 - //__int16 v58; // [sp+14h] [bp-2Ch]@81 + int min_y_ID2; // [sp+14h] [bp-2Ch]@12 int v59; // [sp+14h] [bp-2Ch]@87 - //BspRenderer_stru2 *v60; // [sp+18h] [bp-28h]@1 int v61; // [sp+1Ch] [bp-24h]@29 int v62; // [sp+20h] [bp-20h]@0 - signed int v63; // [sp+24h] [bp-1Ch]@3 - signed int v64; // [sp+28h] [bp-18h]@3 - int v65; // [sp+2Ch] [bp-14h]@5 - //int v66; // [sp+2Ch] [bp-14h]@39 - //int v67; // [sp+30h] [bp-10h]@22 - int v68; // [sp+34h] [bp-Ch]@12 + signed int direction1; // [sp+24h] [bp-1Ch]@3 + signed int direction2; // [sp+28h] [bp-18h]@3 + int min_y_ID; // [sp+2Ch] [bp-14h]@5 int v69; // [sp+34h] [bp-Ch]@29 int v70; // [sp+34h] [bp-Ch]@46 - int v71; // [sp+34h] [bp-Ch]@75 - int v72; // [sp+34h] [bp-Ch]@80 - //int v73; // [sp+38h] [bp-8h]@11 - //int v74; // [sp+3Ch] [bp-4h]@1 - //int a3a; // [sp+48h] [bp+8h]@76 - //int a3b; // [sp+48h] [bp+8h]@87 - - //try graphic engine with function returning 1 always, and without - //return true; + if ( pNumVertices <= 1 ) return false; min_y = PortalFace._screen_space_y[0]; - v65 = 0; + min_y_ID = 0; max_y = PortalFace._screen_space_y[0]; + //face direction(направление фейса) if ( !PortalFace.direction ) { - v63 = 1; - v64 = -1; + direction1 = 1; + direction2 = -1; } else { - v63 = -1; - v64 = 1; + direction1 = -1; + direction2 = 1; } - for ( v6 = 1; v6 < pNumVertices; ++v6 ) + //get min and max y for portal(дать минимальное и максимальное значение y для портала) + for ( uint i = 1; i < pNumVertices; ++i ) { - if ( PortalFace._screen_space_y[v6] >= min_y ) + if (PortalFace._screen_space_y[i] < min_y) { - if ( PortalFace._screen_space_y[v6] > max_y ) - max_y = PortalFace._screen_space_y[v6]; + min_y_ID = i; + min_y = PortalFace._screen_space_y[i]; } - if ( PortalFace._screen_space_y[v6] < min_y ) + else if (PortalFace._screen_space_y[i] > max_y) { - v65 = v6; - min_y = PortalFace._screen_space_y[v6]; + max_y = PortalFace._screen_space_y[i]; } } if ( max_y == min_y ) return false; - v10 = v65; - a2->_viewport_space_y = min_y; - a2->_viewport_space_w = max_y; - v55 = v65; - - for ( v68 = 0; v68 < pNumVertices; ++v68 ) + //***************************************************************************************************************************** + far_portal->_viewport_space_y = min_y; + far_portal->_viewport_space_w = max_y; + current_ID = min_y_ID; + min_y_ID2 = min_y_ID; + + for ( uint i = 0; i < pNumVertices; ++i ) { - v10 += v64; - if ( v10 < pNumVertices ) + current_ID += direction2; + if ( current_ID < pNumVertices ) { - if ( v10 < 0 ) - v10 += pNumVertices; + if ( current_ID < 0 ) + current_ID += pNumVertices; } else - v10 -= pNumVertices; - if ( PortalFace._screen_space_y[v10] <= PortalFace._screen_space_y[v65] ) + current_ID -= pNumVertices; + if ( PortalFace._screen_space_y[current_ID] <= PortalFace._screen_space_y[min_y_ID] )//определение минимальной у { - v55 = v10; - v65 = v10; + min_y_ID2 = current_ID; + min_y_ID = current_ID; } - if ( PortalFace._screen_space_y[v10] == max_y ) + if ( PortalFace._screen_space_y[current_ID] == max_y ) break; } - v13 = v55 + v64; + + v13 = min_y_ID2 + direction2; if ( v13 < pNumVertices ) { if ( v13 < 0 ) @@ -6971,18 +6321,20 @@ } else v13 -= pNumVertices; - if ( PortalFace._screen_space_y[v13] != PortalFace._screen_space_y[v55] ) + if ( PortalFace._screen_space_y[v13] != PortalFace._screen_space_y[min_y_ID2] ) { - v62 = PortalFace._screen_space_x[v55] << 16; - v54 = ((PortalFace._screen_space_x[v13] - PortalFace._screen_space_x[v55]) << 16) / (PortalFace._screen_space_y[v13] - PortalFace._screen_space_y[v55]); - a2->viewport_left_side[min_y] = LOWORD(PortalFace._screen_space_x[v55]); + v62 = PortalFace._screen_space_x[min_y_ID2] << 16; + v54 = ((PortalFace._screen_space_x[v13] - PortalFace._screen_space_x[min_y_ID2]) << 16) / + (PortalFace._screen_space_y[v13] - PortalFace._screen_space_y[min_y_ID2]); + far_portal->viewport_left_side[min_y] = (short)PortalFace._screen_space_x[min_y_ID2]; } - v15 = v65; - v61 = v65; - + //**************************************************************************************************************************************** + // + v15 = min_y_ID; + v61 = min_y_ID; for ( v69 = 0; v69 < pNumVertices; ++v69 ) { - v15 += v63; + v15 += direction1; if ( v15 < pNumVertices ) { if ( v15 < 0 ) @@ -6990,15 +6342,15 @@ } else v15 -= pNumVertices; - if ( PortalFace._screen_space_y[v15] <= PortalFace._screen_space_y[v65] ) + if ( PortalFace._screen_space_y[v15] <= PortalFace._screen_space_y[min_y_ID] ) { v61 = v15; - v65 = v15; + min_y_ID = v15; } if ( PortalFace._screen_space_y[v15] == max_y ) break; } - v18 = v63 + v61; + v18 = direction1 + v61; if ( v18 < pNumVertices ) { if ( v18 < 0 ) @@ -7011,20 +6363,20 @@ if ( PortalFace._screen_space_y[v19] != PortalFace._screen_space_y[v61] ) { v61 = PortalFace._screen_space_x[v20] << 16; - v53 = ((PortalFace._screen_space_x[v19] - PortalFace._screen_space_x[v20]) << 16) / PortalFace._screen_space_y[v19] - PortalFace._screen_space_y[v20]; - a2->viewport_right_side[max_y] = LOWORD(PortalFace._screen_space_x[v20]); + v53 = ((PortalFace._screen_space_x[v19] - PortalFace._screen_space_x[v20]) << 16) / + (PortalFace._screen_space_y[v19] - PortalFace._screen_space_y[v20]); + far_portal->viewport_right_side[max_y] = (short)PortalFace._screen_space_x[v20]; } + //**************************************************************************************************************************************** v22 = min_y; if ( min_y <= max_y ) { - //v56 = &a2->array_3D8[v7]; - //v23 = &a2->array_18[v7]; for ( v70 = min_y; v70 <= max_y; ++v70 ) { v24 = v13; if ( v22 >= PortalFace._screen_space_y[v13] && v22 != max_y ) { - v13 = v64 + v13; + v13 = direction2 + v13; if ( v13 < pNumVertices ) { if ( v13 < 0 ) @@ -7033,17 +6385,16 @@ else v13 -= pNumVertices; v26 = v13; - //v27 = PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24]; if ( PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24] > 0 ) { - v54 = ((PortalFace._screen_space_x[v26] - PortalFace._screen_space_x[v24]) << 16) / PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24]; + v54 = ((PortalFace._screen_space_x[v26] - PortalFace._screen_space_x[v24]) << 16) / (PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24]); v62 = PortalFace._screen_space_x[v24] << 16; } } v29 = v18; if ( v70 >= PortalFace._screen_space_y[v18] && v70 != max_y ) { - v18 += v63; + v18 += direction1; if ( v18 < pNumVertices ) { if ( v18 < 0 ) @@ -7052,113 +6403,88 @@ else v18 -= pNumVertices; v31 = v18; - //v32 = PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29]; if ( PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29] > 0 ) { - v53 = ((PortalFace._screen_space_x[v31] - PortalFace._screen_space_x[v29]) << 16) / PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29]; + v53 = ((PortalFace._screen_space_x[v31] - PortalFace._screen_space_x[v29]) << 16) / (PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29]); v61 = PortalFace._screen_space_x[v29] << 16; } } - //v34 = (char *)a2->array_18 - (char *)a2->array_3D8; - //v35 = *(__int16 *)((char *)&a2->array_3D8[v70] + v34); - //v35 = HIWORD(v62); - a2->viewport_left_side[v70] = HIWORD(v62); - a2->viewport_right_side[v70] = HIWORD(v61); - //v34 = &a2->array_3D8[v70]; - //v35 = a2->array_3D8[v70]; - if ( a2->viewport_left_side[v70] > a2->viewport_right_side[v70] ) + far_portal->viewport_left_side[v70] = HIWORD(v62); + far_portal->viewport_right_side[v70] = HIWORD(v61); + if ( far_portal->viewport_left_side[v70] > far_portal->viewport_right_side[v70] ) { - v36 = a2->viewport_left_side[v70] ^ a2->viewport_right_side[v70]; - v37 = a2->viewport_right_side[v70]; - a2->viewport_left_side[v70] = v36; - v38 = v37 ^ v36; - a2->viewport_left_side[v70] ^= v38; - a2->viewport_right_side[v70] = v38; + v36 = far_portal->viewport_left_side[v70] ^ far_portal->viewport_right_side[v70]; + //v37 = far_portal->viewport_right_side[v70]; + far_portal->viewport_left_side[v70] = v36; + v38 = far_portal->viewport_right_side[v70] ^ v36; + far_portal->viewport_left_side[v70] ^= v38; + far_portal->viewport_right_side[v70] = v38; } - //++v56; v62 += v54; v22 = v70 + 1; v61 += v53; - //++v23; } } - if ( max_y < a3->_viewport_space_y ) - return false; - if ( min_y > a3->_viewport_space_w ) + //***************************************************************************************************************************** + // check portals coordinates and determine max, min(проверка координат порталов и определение макс, мин-ой у) + if ( max_y < near_portal->_viewport_space_y ) return false; - if ( min_y < a3->_viewport_space_y ) - min_y = a3->_viewport_space_y; - if ( max_y > a3->_viewport_space_w ) - max_y = a3->_viewport_space_w; + if ( min_y > near_portal->_viewport_space_w ) + return false; + if ( min_y < near_portal->_viewport_space_y ) + min_y = near_portal->_viewport_space_y; + if ( max_y > near_portal->_viewport_space_w ) + max_y = near_portal->_viewport_space_w; if ( min_y <= max_y ) { - //a3a = (char *)a2 - (char *)a3; - //v42 = &a3->array_3D8[v7]; - //v57 = *(__int16 *)((char *)v42 + a3a); - for ( v71 = min_y; v71 <= max_y; ++v71 ) + for ( min_y; min_y <= max_y; ++min_y ) { - if ( a2->viewport_left_side[v71] >= a3->viewport_left_side[v71] && a2->viewport_left_side[v71] <= a3->viewport_right_side[v71] ) + if ( far_portal->viewport_right_side[min_y] >= near_portal->viewport_left_side[min_y] + && far_portal->viewport_left_side[min_y] <= near_portal->viewport_right_side[min_y] ) break; - //++v57; - ++min_y; - //++v42; } } if ( max_y < min_y ) return false; - //a3a = (char *)a2 - (char *)a3; - //v43 = &a3->array_3D8[v8]; - //v58 = *(__int16 *)((char *)v43 + a3a); - for ( v72 = max_y; v72 >= min_y; --v72 ) + for ( max_y; max_y >= min_y; --max_y ) { - if ( a2->viewport_right_side[v72] >= a3->viewport_left_side[v72] && a2->viewport_left_side[v72] <= a3->viewport_right_side[v72] ) + if ( far_portal->viewport_right_side[max_y] >= near_portal->viewport_left_side[max_y] + && far_portal->viewport_left_side[max_y] <= near_portal->viewport_right_side[max_y] ) break; - //--v58; - --max_y; - //--v43; - //v8 = v8; } if ( min_y >= max_y ) return false; - //a3b = (char *)a3 - (char *)a2; + //************************************************************************************************************************************* v59 = min_y; - //v45 = &a2->array_18[v7]; - for ( v46 = max_y - min_y + 1; v46; --v46 ) { - //v47 = *(__int16 *)((char *)v45 + a3b); - if ( a2->viewport_left_side[v59] < a3->viewport_left_side[v59] ) - a2->viewport_left_side[v59] = a3->viewport_left_side[v59]; - if ( a2->viewport_right_side[v59] > a3->viewport_right_side[v59] ) - a2->viewport_right_side[v59] = a3->viewport_right_side[v59]; + if ( far_portal->viewport_left_side[v59] < near_portal->viewport_left_side[v59] ) + far_portal->viewport_left_side[v59] = near_portal->viewport_left_side[v59]; + if ( far_portal->viewport_right_side[v59] > near_portal->viewport_right_side[v59] ) + far_portal->viewport_right_side[v59] = near_portal->viewport_right_side[v59]; ++v59; - //++v45; } - a2->_viewport_space_y = min_y; - a2->_viewport_space_w = max_y; - a2->field_8 = a2->viewport_left_side[min_y]; - //v48 = a2->viewport_right_side[v7]; - a2->field_10 = min_y; - a2->field_14 = min_y; - a2->field_C = a2->viewport_right_side[min_y]; + far_portal->_viewport_space_y = min_y; + far_portal->_viewport_space_w = max_y; + far_portal->_viewport_space_x = far_portal->viewport_left_side[min_y]; + far_portal->_viewport_space_z = far_portal->viewport_right_side[min_y]; + far_portal->_viewport_x_minID = min_y; + far_portal->_viewport_z_maxID = min_y; v49 = min_y + 1; if ( v49 <= max_y ) { - //v50 = &a2->array_3D8[v49]; for ( v49; v49 <= max_y; ++v49 ) { - //v51 = a2->array_18[v49]; - if ( a2->viewport_left_side[v49] < a2->field_8 ) + if ( far_portal->viewport_left_side[v49] < far_portal->_viewport_space_x ) { - a2->field_8 = a2->viewport_left_side[v49]; - a2->field_10 = v49; + far_portal->_viewport_space_x = far_portal->viewport_left_side[v49]; + far_portal->_viewport_x_minID = v49; } - if ( a2->viewport_right_side[v49] > a2->field_C ) + if ( far_portal->viewport_right_side[v49] > far_portal->_viewport_space_z ) { - a2->field_C = a2->viewport_right_side[v49]; - a2->field_14 = v49; + far_portal->_viewport_space_z = far_portal->viewport_right_side[v49]; + far_portal->_viewport_z_maxID = v49; } - //++v50; } } return true; @@ -7169,16 +6495,8 @@ BLVFace *pFace; // ebx@1 int pNextVertices; // edx@11 int t; // ST28_4@12 - signed int v13; // edx@12 - signed __int64 v14; // qtt@12 - signed int v17; // eax@14 - signed __int64 v18; // qtt@14 - signed int v20; // edx@17 - int v25; // eax@22 int pScreenX; // eax@22 - int v31; // eax@27 int pScreenY; // eax@27 - int v35; // ST30_4@30 signed int left_num_vertices; // edi@31 signed int right_num_vertices; // ebx@41 signed int top_num_vertices; // edi@51 @@ -7189,12 +6507,10 @@ int v65; // ecx@83 signed int v71; // [sp+14h] [bp-14h]@75 bool current_vertices_flag; // [sp+18h] [bp-10h]@9 - int thisb; // [sp+18h] [bp-10h]@12 int thisf; // [sp+18h] [bp-10h]@74 signed int depth_num_vertices; // [sp+1Ch] [bp-Ch]@9 int v80; // [sp+1Ch] [bp-Ch]@76 bool next_vertices_flag; // [sp+20h] [bp-8h]@10 - signed int v90; // [sp+24h] [bp-4h]@51 pFace = &pIndoor->pFaces[uFaceID]; memset(&PortalFace, 0, sizeof(stru367)); @@ -7241,8 +6557,6 @@ &PortalFace._view_transformed_z[i + 3], &PortalFace._view_transformed_x[i + 3], &PortalFace._view_transformed_y[i + 3], 0); } } - //х: 55681665, 55681665, 53050369, 47787777, 45156481, 45156481 - //x: 0x0351 a281,0x0351 a281,0x0329 7c01,0x02d9 2f01,0x02b1 0881,0x02b1 0881 //***************************************************************************************************************************************** //check vertices for the nearest plane(проверка вершин есть ли в области за ближайшей плоскостью) if ( pFace->uNumVertices <= 0 ) @@ -7287,11 +6601,8 @@ { if ( next_vertices_flag )//следующая вершина за ближней границей { - v13 = 524288 - PortalFace._view_transformed_z[i + 2]; - LODWORD(v14) = v13 << 16; - HIDWORD(v14) = v13 >> 16; //t = near_clip - v0.z / v1.z - v0.z - t = v14 / PortalFace._view_transformed_z[i + 3] - PortalFace._view_transformed_z[i + 2]; + t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 2], PortalFace._view_transformed_z[i + 3] - PortalFace._view_transformed_z[i + 2]); //New_x = (v1.x - v0.x)*t + v0.x PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 3] - PortalFace._view_transformed_x[i + 2]) * t) >> 16) + PortalFace._view_transformed_x[i + 2]; @@ -7303,11 +6614,8 @@ } else// текущая вершина за ближней границей { - v17 = 524288 - PortalFace._view_transformed_z[i + 3]; - LODWORD(v18) = v17 << 16; - HIDWORD(v18) = v17 >> 16; //t = near_clip - v1.z / v0.z - v1.z - t = v18 / PortalFace._view_transformed_z[i + 2] - PortalFace._view_transformed_z[i + 3]; + t = fixpoint_div(524288 - PortalFace._view_transformed_z[i + 3], PortalFace._view_transformed_z[i + 2] - PortalFace._view_transformed_z[i + 3]); //New_x = (v0.x - v1.x)*t + v1.x PortalFace._view_transformed_x[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_x[i + 2] - PortalFace._view_transformed_x[i + 3]) * t) >> 16) + PortalFace._view_transformed_x[i + 3]; @@ -7379,15 +6687,16 @@ PortalFace._screen_space_x[i + 12] = pBLVRenderParams->uViewportCenterX - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenX) >> 16); PortalFace._screen_space_y[i + 12] = pBLVRenderParams->uViewportCenterY - ((unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)pScreenY) >> 16); } - //х -34, 4, 61, 83, 83, -34 - //y 211, 152, 172, 216, 273, 293 // результат: при повороте камеры, когда граница портала сдвигается к краю экрана, портал остается прозрачным(видимым) //****************************************************************************************************************************************** + //координаты как в Ида-базе игры так и в данном проекте перевёрнутые,т.е. портал который в правой части экрана имеет экранные координаты + //которые для левой части экрана. Например, x(оригинал) = 8, у нас х = 468(противоположный край экрана), точно также и с у. + // //check for left_clip plane(порверка по левой границе) left_num_vertices = 0; PortalFace._screen_space_x[depth_num_vertices + 12] = PortalFace._screen_space_x[12]; PortalFace._screen_space_y[depth_num_vertices + 12] = PortalFace._screen_space_y[12]; - current_vertices_flag = PortalFace._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX; + current_vertices_flag = PortalFace._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX;//8.0 if ( depth_num_vertices < 1 ) return 0; for ( uint i = 1; i <= depth_num_vertices; ++i ) @@ -7398,22 +6707,20 @@ if ( next_vertices_flag ) { //t = left_clip - v0.x / v1.x - v0.x - t = (signed __int64)(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 11]) - / (PortalFace._screen_space_x[i + 12] - PortalFace._screen_space_x[i + 11]); + t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 11], PortalFace._screen_space_x[i + 12] - PortalFace._screen_space_x[i + 11]); //New_y = (v1.y - v0.y)*t + v0.y - PortalFace._screen_space_y[left_num_vertices + 9] = (signed int)(PortalFace._screen_space_y[i + 12]- PortalFace._screen_space_y[i + 11]) - * t + PortalFace._screen_space_y[i + 11]; + PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)((PortalFace._screen_space_y[i + 12]- PortalFace._screen_space_y[i + 11]) + * t) >> 16) + PortalFace._screen_space_y[i + 11]; //New_x = left_clip PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; } else { //t = left_clip - v1.x / v0.x - v1.x - t = (signed __int64)(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 12]) - / (PortalFace._screen_space_x[i + 11] - PortalFace._screen_space_x[i + 12]); + t = fixpoint_div(pBLVRenderParams->uViewportX - PortalFace._screen_space_x[i + 12], PortalFace._screen_space_x[i + 11] - PortalFace._screen_space_x[i + 12]); //New_y = (v0.y - v1.y)*t + v1.y - PortalFace._screen_space_y[left_num_vertices + 9] = (signed int)( PortalFace._screen_space_y[i + 11] - PortalFace._screen_space_y[i + 12]) - * t + PortalFace._screen_space_y[i + 12]; + PortalFace._screen_space_y[left_num_vertices + 9] = ((signed int)(( PortalFace._screen_space_y[i + 11] - PortalFace._screen_space_y[i + 12]) + * t) >> 16) + PortalFace._screen_space_y[i + 12]; //New_x = left_clip PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; } @@ -7432,7 +6739,7 @@ right_num_vertices = 0; PortalFace._screen_space_x[left_num_vertices + 9] = PortalFace._screen_space_x[9]; PortalFace._screen_space_y[left_num_vertices + 9] = PortalFace._screen_space_y[9]; - current_vertices_flag = PortalFace._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ; + current_vertices_flag = PortalFace._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ;//468.0 if (left_num_vertices < 1) return 0; for ( uint i = 1; i <= left_num_vertices; ++i ) @@ -7443,22 +6750,20 @@ if ( next_vertices_flag ) { //t = right_clip - v1.x / v0.x - v1.x - t = (signed __int64)(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 9]) - / (PortalFace._screen_space_x[i + 8] - PortalFace._screen_space_x[i + 9]); + t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 8], PortalFace._screen_space_x[i + 9] - PortalFace._screen_space_x[i + 8]); //New_y = (v0.y - v1.y)*t + v1.y - PortalFace._screen_space_y[right_num_vertices + 6] = (signed int)(PortalFace._screen_space_y[i + 8] - PortalFace._screen_space_y[i + 9]) - * t + PortalFace._screen_space_y[i + 9]; + PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 9] - PortalFace._screen_space_y[i + 8]) + * t) >> 16) + PortalFace._screen_space_y[i + 8]; //New_x = right_clip PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; } else { //t = right_clip - v0.x / v1.x - v0.x - t = (signed __int64)(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 8]) - / (PortalFace._screen_space_x[i + 9] - PortalFace._screen_space_x[i + 8]); + t = fixpoint_div(pBLVRenderParams->uViewportZ - PortalFace._screen_space_x[i + 9], PortalFace._screen_space_x[i + 8] - PortalFace._screen_space_x[i + 9]); //New_y = (v1.y - v0.y)*t + v0.y - PortalFace._screen_space_y[right_num_vertices + 6] = (signed int)(PortalFace._screen_space_y[i + 9] - PortalFace._screen_space_y[i + 8]) - * t + PortalFace._screen_space_y[i + 8]; + PortalFace._screen_space_y[right_num_vertices + 6] = ((signed int)((PortalFace._screen_space_y[i + 8] - PortalFace._screen_space_y[i + 9]) + * t) >> 16) + PortalFace._screen_space_y[i + 9]; //New_x = right_clip PortalFace._screen_space_x[right_num_vertices + 6] = pBLVRenderParams->uViewportZ; } @@ -7478,7 +6783,7 @@ PortalFace._screen_space_x[right_num_vertices + 6] = PortalFace._screen_space_x[6]; PortalFace._screen_space_y[right_num_vertices + 6] = PortalFace._screen_space_y[6]; - current_vertices_flag = PortalFace._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY; + current_vertices_flag = PortalFace._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY;//8.0 if ( right_num_vertices < 1 ) return 0; for ( uint i = 1; i <= right_num_vertices; ++i ) @@ -7488,18 +6793,16 @@ { if ( next_vertices_flag ) { - t = (signed __int64)(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 5]) - / (PortalFace._screen_space_y[i + 6] - PortalFace._screen_space_y[i + 5]); - PortalFace._screen_space_x[top_num_vertices + 3] = (signed int)(PortalFace._screen_space_x[i + 6] - PortalFace._screen_space_x[i + 5]) - * t + PortalFace._screen_space_x[i + 5]; + t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 5], PortalFace._screen_space_y[i + 6] - PortalFace._screen_space_y[i + 5]); + PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 6] - PortalFace._screen_space_x[i + 5]) + * t) >> 16) + PortalFace._screen_space_x[i + 5]; PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; } else { - t = (signed __int64)(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 6]) - / (PortalFace._screen_space_y[i + 5] - PortalFace._screen_space_y[i + 6]); - PortalFace._screen_space_x[top_num_vertices + 3] = (signed int)(PortalFace._screen_space_x[i + 5]- PortalFace._screen_space_x[i + 6]) - * t + PortalFace._screen_space_x[i + 6]; + t = fixpoint_div(pBLVRenderParams->uViewportY - PortalFace._screen_space_y[i + 6], PortalFace._screen_space_y[i + 5] - PortalFace._screen_space_y[i + 6]); + PortalFace._screen_space_x[top_num_vertices + 3] = ((signed int)((PortalFace._screen_space_x[i + 5]- PortalFace._screen_space_x[i + 6]) + * t) >> 16) + PortalFace._screen_space_x[i + 6]; PortalFace._screen_space_y[top_num_vertices + 3] = pBLVRenderParams->uViewportY; } top_num_vertices++; @@ -7517,7 +6820,7 @@ bottom_num_vertices = 0; PortalFace._screen_space_x[top_num_vertices + 3] = PortalFace._screen_space_x[3]; PortalFace._screen_space_y[top_num_vertices + 3] = PortalFace._screen_space_y[3]; - current_vertices_flag = PortalFace._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW; + current_vertices_flag = PortalFace._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW;//351.0 if ( top_num_vertices < 1 ) return 0; for ( uint i =1; i <= top_num_vertices; ++i ) @@ -7527,18 +6830,16 @@ { if ( next_vertices_flag ) { - t = (signed __int64)(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 3]) - / (PortalFace._screen_space_y[i + 2] - PortalFace._screen_space_y[i + 3]); - PortalFace._screen_space_x[bottom_num_vertices] = (signed int)(PortalFace._screen_space_x[i + 2] - PortalFace._screen_space_x[i + 3]) - * t + PortalFace._screen_space_x[i + 3]; + t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 2], PortalFace._screen_space_y[i + 3] - PortalFace._screen_space_y[i + 2]); + PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 3] - PortalFace._screen_space_x[i + 2]) + * t) >> 16) + PortalFace._screen_space_x[i + 2]; PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; } else { - t = (signed __int64)(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 2]) - / (PortalFace._screen_space_y[i + 3] - PortalFace._screen_space_y[i + 2]); - PortalFace._screen_space_x[bottom_num_vertices] = (signed int)(PortalFace._screen_space_x[i + 3] - PortalFace._screen_space_x[i + 2]) - * t + PortalFace._screen_space_x[i + 2]; + t = fixpoint_div(pBLVRenderParams->uViewportW - PortalFace._screen_space_y[i + 3], PortalFace._screen_space_y[i + 2] - PortalFace._screen_space_y[i + 3]); + PortalFace._screen_space_x[bottom_num_vertices] = ((signed int)((PortalFace._screen_space_x[i + 2] - PortalFace._screen_space_x[i + 3]) + * t) >> 16) + PortalFace._screen_space_x[i + 3]; PortalFace._screen_space_y[bottom_num_vertices] = pBLVRenderParams->uViewportW; } bottom_num_vertices++; @@ -7551,8 +6852,6 @@ } current_vertices_flag = next_vertices_flag; } - //out_x: 83,8,8,61,83 - //out_y: 273,293,152,172,216 //*************************************************************************************************************************************** if ( !bottom_num_vertices ) @@ -7608,4 +6907,51 @@ PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; } return bottom_num_vertices; +} + +//----- (004AAEA6) -------------------------------------------------------- +int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1) +{ + double v4; // st5@2 + double v5; // st4@3 + float v11; // [sp+8h] [bp-8h]@2 + float v12; // [sp+8h] [bp-8h]@6 + float v13; // [sp+Ch] [bp-4h]@2 + float v14; // [sp+Ch] [bp-4h]@6 + + if ( pBLVRenderParams->sPartyRotX ) + { + v13 = a1->vWorldPosition.x - (double)pParty->vPosition.x; + v11 = a1->vWorldPosition.y - (double)pParty->vPosition.y; + v4 = a1->vWorldPosition.z - (double)pParty->vPosition.z; + if ( pRenderer->pRenderD3D ) + { + v5 = v11 * pBLVRenderParams->fSineY + v13 * pBLVRenderParams->fCosineY; + a1->vWorldViewPosition.y = v13 * pBLVRenderParams->fSineY - v11 * pBLVRenderParams->fCosineY; + } + else + { + v5 = v13 * pBLVRenderParams->fCosineY - v11 * pBLVRenderParams->fSineY; + a1->vWorldViewPosition.y = v13 * pBLVRenderParams->fSineY + v11 * pBLVRenderParams->fCosineY; + } + a1->vWorldViewPosition.x = v5 * pBLVRenderParams->fCosineNegX - v4 * pBLVRenderParams->fSineNegX; + a1->vWorldViewPosition.z = v5 * pBLVRenderParams->fSineNegX + v4 * pBLVRenderParams->fCosineNegX; + } + else + { + v14 = a1->vWorldPosition.x - (double)pParty->vPosition.x; + v12 = a1->vWorldPosition.y - (double)pParty->vPosition.y; + a1->vWorldViewPosition.z = a1->vWorldPosition.z - (double)pParty->vPosition.z; + if ( pRenderer->pRenderD3D ) + { + a1->vWorldViewPosition.x = v12 * pBLVRenderParams->fSineY + v14 * pBLVRenderParams->fCosineY; + a1->vWorldViewPosition.y = v14 * pBLVRenderParams->fSineY - v12 * pBLVRenderParams->fCosineY; + } + else + { + a1->vWorldViewPosition.x = v14 * pBLVRenderParams->fCosineY - v12 * pBLVRenderParams->fSineY; + a1->vWorldViewPosition.y = v14 * pBLVRenderParams->fSineY + v12 * pBLVRenderParams->fCosineY; + } + } + return 0; } \ No newline at end of file
--- a/Indoor.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Indoor.h Tue Aug 06 00:56:33 2013 +0400 @@ -440,7 +440,7 @@ static unsigned int GetLocationIndex(const char *Str1); static void ExecDraw(bool bD3D); - static void ExecDraw_sw(unsigned int uFaceID); + //static void ExecDraw_sw(unsigned int uFaceID); static void ExecDraw_d3d(unsigned int uFaceID, struct IndoorCameraD3D_Vec4 *pVertices, unsigned int uNumVertices, struct RenderVertexSoft *pPortalBounding); char pFilename[32]; @@ -561,7 +561,7 @@ int field_70; int uViewportCenterX; int uViewportCenterY; - struct BspRenderer_stru2 *field_7C; + struct BspRenderer_PortalViewportData *field_7C; unsigned int uNumFacesRenderedThisFrame; int field_84; int field_88;
--- a/IndoorCameraD3D.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/IndoorCameraD3D.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -136,17 +136,17 @@ int a2b; // [sp+18h] [bp+Ch]@5 int a3a; // [sp+1Ch] [bp+10h]@5 - to_x = (x - pBLVRenderParams->vPartyPos.x) << 16; - to_y = (y - pBLVRenderParams->vPartyPos.y) << 16; + to_x = x - pBLVRenderParams->vPartyPos.x; + to_y = y - pBLVRenderParams->vPartyPos.y; if ( pBLVRenderParams->sPartyRotX ) { to_z = (z - pBLVRenderParams->vPartyPos.z) << 16; if ( pRenderer->pRenderD3D ) { - v14 = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - + ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY) >> 16); - v9 = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) >> 16) - - ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + v14 = (unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) + + (unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY); + v9 = (unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) + - (unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY); } else { @@ -169,10 +169,10 @@ if ( pRenderer->pRenderD3D ) { v10 = pOutX; - *pOutX = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - + ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY) >> 16); - *pOutZ = ((unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) >> 16) - - ((unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + *pOutX = (unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sCosineY) + + (unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sSineY); + *pOutZ = (unsigned __int64)(to_x * (signed __int64)pBLVRenderParams->sSineY) + - (unsigned __int64)(to_y * (signed __int64)pBLVRenderParams->sCosineY); } else { @@ -499,308 +499,6 @@ return true; } -//----- (00438250) -------------------------------------------------------- -void IndoorCameraD3D::Reset_list_0037C() -{ - this->list_0037C_size = 0; -} - -//----- (00438240) -------------------------------------------------------- -void IndoorCameraD3D::_438240_draw_lits() -{ - IndoorCameraD3D *v1; // ebp@1 - int v2; // edi@2 - int v3; // ebx@3 - int v4; // esi@4 - double v5; // st7@6 - float v6; // ST00_4@8 - IndoorCameraD3D *v7; // esi@1 - float v8; // [sp+4h] [bp-28h]@6 - float v9; // [sp+8h] [bp-24h]@6 - unsigned int v10; // [sp+Ch] [bp-20h]@6 - char v11; // [sp+10h] [bp-1Ch]@6 - float v12; // [sp+14h] [bp-18h]@6 - int v13; // [sp+28h] [bp-4h]@1 - - v7 = this; - _438141_draw_list_0037C(); - v13 = 0; - v1 = v7; - if ( v7->list_E0380_size > 0 ) - { - v2 = (int)&v7->list_E0380[0].field_C04; - do - { - v3 = 0; - if ( *(int *)v2 > 0 ) - { - v4 = v2 - 3048; - do - { - if ( *(char *)(v2 - 3076) & 1 ) - { - LODWORD(v12) = 1; - v11 = 1; - v10 = *(int *)(v2 + 4); - v9 = 0.0; - v8 = *(float *)(v4 + 4); - v5 = *(float *)v4; - } - else - { - LODWORD(v12) = 0; - v11 = 1; - v10 = *(int *)(v2 + 4); - v9 = *(float *)(v4 - 16); - v8 = *(float *)(v4 - 20); - v5 = *(float *)(v4 - 24); - } - v6 = v5; - _437D4A_draw_some_vertices(v6, v8, v9, v10, v11, v12); - ++v3; - v4 += 48; - } - while ( v3 < *(int *)v2 ); - } - ++v13; - v2 += 3088; - } - while ( v13 < v1->list_E0380_size ); - } -} - -//----- (00438141) -------------------------------------------------------- -void IndoorCameraD3D::_438141_draw_list_0037C() -{ - IndoorCameraD3D *v1; // edi@1 - signed int v2; // ebx@1 - char *v3; // esi@2 - double v4; // st7@4 - float v5; // ST00_4@6 - float v6; // [sp+4h] [bp-20h]@4 - float v7; // [sp+8h] [bp-1Ch]@4 - unsigned int v8; // [sp+Ch] [bp-18h]@4 - char v9; // [sp+10h] [bp-14h]@4 - float v10; // [sp+14h] [bp-10h]@4 - - v1 = this; - v2 = 0; - if ( (signed int)this->list_0037C_size > 0 ) - { - v3 = (char *)&this->list_0037C[0].field_20; - do - { - if ( *(v3 - 32) & 1 ) - { - LODWORD(v10) = 1; - v9 = 1; - v8 = *((int *)v3 + 5); - v7 = 0.0; - v6 = *(float *)v3; - v4 = *((float *)v3 - 1); - } - else - { - LODWORD(v10) = 0; - v9 = 1; - v8 = *((int *)v3 + 5); - v7 = *((float *)v3 - 5); - v6 = *((float *)v3 - 6); - v4 = *((float *)v3 - 7); - } - v5 = v4; - _437D4A_draw_some_vertices(v5, v6, v7, v8, v9, v10); - ++v2; - v3 += 56; - } - while ( v2 < (signed int)v1->list_0037C_size ); - } -} - -//----- (00437D4A) -------------------------------------------------------- -void IndoorCameraD3D::_437D4A_draw_some_vertices(float x, float y, float z, unsigned int a5, char a6, float a7) -{ - IndoorCameraD3D *v7; // edx@1 - char *v8; // eax@1 - signed int v9; // ecx@1 - signed int v10; // edx@10 - char *v11; // ecx@10 - signed int uNumD3DVertices; // edi@16 - char *v13; // ecx@24 - unsigned int v14; // edx@25 - unsigned int v15; // eax@25 - int v16; // ebx@25 - int v17; // eax@26 - int v18; // edx@26 - IDirect3DDevice3 *v19; // ST24_4@27 - HRESULT v20; // eax@27 - RenderVertexSoft vert[20]; // [sp+0h] [bp-680h]@1 - RenderVertexD3D3 pD3DVertices[5]; // [sp+3C0h] [bp-2C0h]@15 - RenderVertexSoft a1; // [sp+640h] [bp-40h]@1 - //double v24; // [sp+670h] [bp-10h]@25 - //double v25; // [sp+678h] [bp-8h]@1 - - v7 = this; - a1.flt_2C = 0.0; - //HIDWORD(v25) = (int)this; - v8 = (char *)&vert[0].flt_2C; - v9 = 20; - do - { - *(float *)v8 = 0.0; - v8 += 48; - --v9; - } - while ( v9 ); - if ( LOBYTE(a7) ) - { - vert[0].vWorldViewProjX = x; - vert[0].vWorldViewProjY = y; - goto LABEL_15; - } - a1.vWorldPosition.x = x; - a1.vWorldPosition.y = y; - a1.vWorldPosition.z = z; - if ( pRenderer->pRenderD3D ) - { - LODWORD(a7) = 1; - if ( v7->CalcPortalShape( - &a1, - (unsigned int *)&a7, - vert, - v7->std__vector_000034_prolly_frustrum, - 4, - 1, - 0) == 1 - && SLODWORD(a7) < 1 ) - return; - } - else - { - vert[0].vWorldPosition.x = x; - vert[0].vWorldPosition.y = y; - vert[0].vWorldPosition.z = z; - } - ViewTransform(vert, 1u); - v10 = 0; - v11 = (char *)&vert[0].vWorldViewPosition; - do - { - if ( *(float *)v11 >= 8.0 ) - break; - ++v10; - v11 += 48; - } - while ( v10 < 1 ); - if ( v10 < 1 ) - { - Project(vert, 1u, 0); -LABEL_15: - pD3DVertices[0].pos.x = vert[0].vWorldViewProjX; - pD3DVertices[0].pos.y = vert[0].vWorldViewProjY; - pD3DVertices[0].specular = 0; - pD3DVertices[0].diffuse = a5; - if ( a6 ) - { - pD3DVertices[0].pos.z = 0.000099999997; - pD3DVertices[1].pos.x = vert[0].vWorldViewProjX; - pD3DVertices[2].pos.x = vert[0].vWorldViewProjX; - pD3DVertices[0].rhw = 0.001; - uNumD3DVertices = 5; - pD3DVertices[0].texcoord.x = 0.0; - pD3DVertices[1].diffuse = a5; - pD3DVertices[1].specular = 0; - pD3DVertices[0].texcoord.y = 0.0; - pD3DVertices[2].diffuse = a5; - pD3DVertices[2].specular = 0; - pD3DVertices[3].pos.y = vert[0].vWorldViewProjY; - pD3DVertices[3].diffuse = a5; - pD3DVertices[3].specular = 0; - pD3DVertices[4].pos.y = vert[0].vWorldViewProjY; - pD3DVertices[1].pos.y = vert[0].vWorldViewProjY - 1.0; - pD3DVertices[4].diffuse = a5; - pD3DVertices[4].specular = 0; - pD3DVertices[1].pos.z = 0.000099999997; - pD3DVertices[1].rhw = 0.001; - pD3DVertices[1].texcoord.x = 0.0; - pD3DVertices[1].texcoord.y = 0.0; - pD3DVertices[2].pos.y = vert[0].vWorldViewProjY + 1.0; - pD3DVertices[2].pos.z = 0.000099999997; - pD3DVertices[2].rhw = 0.001; - pD3DVertices[2].texcoord.x = 0.0; - pD3DVertices[2].texcoord.y = 0.0; - pD3DVertices[3].pos.x = vert[0].vWorldViewProjX - 1.0; - pD3DVertices[3].pos.z = 0.000099999997; - pD3DVertices[3].rhw = 0.001; - pD3DVertices[3].texcoord.x = 0.0; - pD3DVertices[3].texcoord.y = 0.0; - pD3DVertices[4].pos.x = vert[0].vWorldViewProjX + 1.0; - pD3DVertices[4].pos.z = 0.000099999997; - pD3DVertices[4].rhw = 0.001; - pD3DVertices[4].texcoord.x = 0.0; - pD3DVertices[4].texcoord.y = 0.0; - } - else - { - uNumD3DVertices = 1; - __debugbreak(); // make things right - *(unsigned int *)(&pD3DVertices[0].pos.z) = 0x38D1B717u; - pD3DVertices[0].texcoord.x = 0.0; - *(unsigned int *)(&pD3DVertices[0].rhw) = 0x3A83126Fu; - pD3DVertices[0].texcoord.y = 0.0; - } - if ( pRenderer->pRenderD3D ) - { - __debugbreak(); // decompilation bug - //v19 = pRenderer->pRenderD3D->pDevice; - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr)); - ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_POINTLIST, - D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, - pD3DVertices, - uNumD3DVertices, - 16)); - } - else - { - if ( (double)(signed int)pViewport->uViewportTL_X <= vert[0].vWorldViewProjX - 1.0 - && (double)(signed int)pViewport->uViewportBR_X > vert[0].vWorldViewProjX + 2.0 - && (double)(signed int)pViewport->uViewportTL_Y <= vert[0].vWorldViewProjY - 1.0 - && (double)(signed int)pViewport->uViewportBR_Y > vert[0].vWorldViewProjY + 2.0 - && uNumD3DVertices > 0 ) - { - v13 = (char *)&pD3DVertices[0].diffuse; - do - { - LODWORD(a7) = *((int *)v13 - 3); - //v25 = a7 + 6.7553994e15; - auto _v25 = floorf(a7 + 0.5f); - - //v24 = *((float *)v13 - 4) + 6.7553994e15; - auto _v24 = floorf(*((float *)v13 - 4) + 0.5f); - - v14 = *(int *)v13; - v15 = *(int *)v13; - v16 = (*(int *)v13 >> 3) & 0x1F; - if ( pRenderer->uTargetGBits == 5 ) - { - v17 = (v15 >> 6) & 0x3E0; - v18 = (v14 >> 9) & 0x7C00; - } - else - { - v17 = (v15 >> 5) & 0x7E0; - v18 = (v14 >> 8) & 0xF800; - } - v13 += 32; - --uNumD3DVertices; - pRenderer->pTargetSurface[(uint)_v24 + pRenderer->uTargetSurfacePitch * (uint)_v25] = v18 | v16 | (unsigned __int16)v17; - } - while ( uNumD3DVertices ); - } - } - } -} - //----- (00437C96) -------------------------------------------------------- void IndoorCameraD3D::do_draw_debug_line_d3d(const RenderVertexD3D3 *pLineBegin, unsigned int uDiffuseBegin, const RenderVertexD3D3 *pLineEnd, unsigned int uDiffuseEnd, float z_stuff) {
--- a/IndoorCameraD3D.h Tue Aug 06 00:52:46 2013 +0400 +++ b/IndoorCameraD3D.h Tue Aug 06 00:56:33 2013 +0400 @@ -147,10 +147,10 @@ void debug_outline_d3d(const struct RenderVertexD3D3 *pLineVertices, unsigned int uNumLines, int uDiffuse, float z_stuff); void do_draw_debug_line_sw(struct RenderVertexSoft *pLineBegin, unsigned int uStartDiffuse, struct RenderVertexSoft *pLineEnd, unsigned int uEndDiffuse, unsigned int uOutNumVertices, float z_stuff); void do_draw_debug_line_d3d(const struct RenderVertexD3D3 *pLineBegin, unsigned int uDiffuseBegin, const RenderVertexD3D3 *pLineEnd, unsigned int uDiffuseEnd, float z_stuff); - void _437D4A_draw_some_vertices(float x, float y, float z, unsigned int a5, char a6, float a7); - void _438141_draw_list_0037C(); - void _438240_draw_lits(); - void Reset_list_0037C(); + //void sr_437D4A_draw_some_vertices(float x, float y, float z, unsigned int a5, char a6, float a7); + //void sr_438141_draw_list_0037C(); + //void sr_438240_draw_lits(); + //void sr_Reset_list_0037C(); bool is_face_faced_to_camera(struct BLVFace *pFace, struct RenderVertexSoft *a2); bool GetFacetOrientation(char polyType, struct Vec3_float_ *a2, struct Vec3_float_ *a3, struct Vec3_float_ *a4); void ViewTransform(struct RenderVertexSoft *a1a, unsigned int uNumVertices);
--- a/Indoor_stuff.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Indoor_stuff.h Tue Aug 06 00:56:33 2013 +0400 @@ -6,21 +6,21 @@ /* 165 */ #pragma pack(push, 1) -struct BspRenderer_stru2 +struct BspRenderer_PortalViewportData { void GetViewportData(__int16 x, int y, __int16 z, int w); int _viewport_space_y; int _viewport_space_w; - int field_8; - int field_C; - int field_10; - int field_14; + int _viewport_space_x; + int _viewport_space_z; + int _viewport_x_minID; + int _viewport_z_maxID; __int16 viewport_left_side[480]; __int16 viewport_right_side[480]; }; #pragma pack(pop) -extern BspRenderer_stru2 stru_F8A590; +extern BspRenderer_PortalViewportData stru_F8A590; @@ -51,7 +51,7 @@ unsigned __int16 uViewportZ; unsigned __int16 uViewportW; __int16 field_A; - BspRenderer_stru2 field_C; + BspRenderer_PortalViewportData PortalScreenData; unsigned __int16 uFaceID; __int16 field_7A6; unsigned int viewing_portal_id; // portal through which we're seeing this node @@ -111,52 +111,6 @@ -/* 160 */ -#pragma pack(push, 1) -struct stru167 -{ - char field_0; - char field_1; - char field_2; - char field_3; - char field_4; - char field_5; - __int16 field_6_rnd_value; - __int16 field_8_rnd_value; - __int16 field_A_rnd_value; - __int16 field_C_time_left; - __int16 field_E_time_to_live; - char field_10; - char field_11; - char field_12; - char field_13; - __int16 bgr16; - char field_16; - char field_17; -}; -#pragma pack(pop) - - - -/* 363 */ -#pragma pack(push, 1) -struct stru167_wrap -{ - void _440F07(); - int Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr); - void _440E91(__int16 x, int y, int z, int a5, __int16 bgr); - - stru167 pElements[100]; - int uNumElements; - int field_964; -}; -#pragma pack(pop) -extern stru167_wrap array_5118E8; - - - - -
--- a/Items.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Items.h Tue Aug 06 00:56:33 2013 +0400 @@ -112,6 +112,8 @@ ITEM_LICH_JAR_FULL = 601, ITEM_WETSUIT = 604, ITEM_LICH_JAR_EMPTY = 615, + ITEM_RECIPE_REJUVENATION = 740, + ITEM_RECIPE_BODY_RESISTANCE = 771, }; /* 331 */
--- a/LOD.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/LOD.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -74,121 +74,73 @@ field_ECA0 = uNumLoadedSprites; } - - //----- (004355F7) -------------------------------------------------------- -void LODFile_IconsBitmaps::_4355F7() +void LODFile_IconsBitmaps::RemoveTexturesFromTextureList() { - LODFile_IconsBitmaps *v1; // esi@1 - int v2; // edi@2 - Texture *v3; // ebp@3 - struct IDirect3DTexture2 **v4; // eax@4 - struct IDirect3DTexture2 *v5; // eax@5 - struct IDirectDrawSurface **v6; // eax@7 - struct IDirectDrawSurface *v7; // eax@8 - int v8; // eax@11 - - v1 = this; if ( this->uTexturePacksCount ) { - v2 = this->uNumLoadedFiles - 1; - if ( v2 >= this->uNumPrevLoadedFiles ) + if ( (this->uNumLoadedFiles - 1) >= this->uNumPrevLoadedFiles ) { - v3 = &this->pTextures[v2]; - do + for ( uint i = this->uNumLoadedFiles - 1; i >= this->uNumPrevLoadedFiles; --i ) { - v3->Release(); - v4 = v1->pHardwareTextures; - if ( v4 ) + this->pTextures[i].Release(); + if ( this->pHardwareTextures ) { - v5 = v4[v2]; - if ( v5 ) + if ( this->pHardwareTextures[i] ) { - v5->Release(); - v1->pHardwareTextures[v2] = 0; + this->pHardwareTextures[i]->Release(); + this->pHardwareTextures[i] = 0; } } - v6 = v1->pHardwareSurfaces; - if ( v6 ) + if ( this->pHardwareSurfaces ) { - v7 = v6[v2]; - if ( v7 ) + if ( this->pHardwareSurfaces[i] ) { - v7->Release(); - v1->pHardwareSurfaces[v2] = 0; + this->pHardwareSurfaces[i]->Release(); + this->pHardwareSurfaces[i] = 0; } } - --v2; - --v3; } - while ( v2 >= v1->uNumPrevLoadedFiles ); } - v8 = v1->uNumPrevLoadedFiles; - v1->uNumPrevLoadedFiles = 0; - v1->uNumLoadedFiles = v8; - v1->uTexturePacksCount = 0; + this->uNumLoadedFiles = this->uNumPrevLoadedFiles; + this->uNumPrevLoadedFiles = 0; + this->uTexturePacksCount = 0; } } //----- (004114F2) -------------------------------------------------------- -void LODFile_IconsBitmaps::_4114F2() +void LODFile_IconsBitmaps::RemoveTexturesPackFromTextureList() { - LODFile_IconsBitmaps *v1; // esi@1 - int *pTexturePacksCount; // eax@1 - int v3; // ecx@1 - int v4; // ecx@2 - int v5; // edi@3 - Texture *v6; // ebx@4 - struct IDirect3DTexture2 **v7; // eax@5 - struct IDirect3DTexture2 *v8; // eax@6 - struct IDirectDrawSurface **v9; // eax@8 - struct IDirectDrawSurface *v10; // eax@9 - int v11; // eax@12 - - v1 = this; - pTexturePacksCount = &this->uTexturePacksCount; - v3 = this->uTexturePacksCount; - if ( v3 ) + if ( this->uTexturePacksCount ) { - v4 = v3 - 1; - *pTexturePacksCount = v4; - if ( !v4 ) + this->uTexturePacksCount--; + if ( !this->uTexturePacksCount ) { - v5 = v1->uNumLoadedFiles - 1; - if ( v5 >= v1->uNumPrevLoadedFiles ) + if ( (this->uNumLoadedFiles - 1) >= this->uNumPrevLoadedFiles ) { - v6 = &v1->pTextures[v5]; - do + for ( uint i = this->uNumLoadedFiles - 1; i >= this->uNumPrevLoadedFiles; --i ) { - v6->Release(); - v7 = v1->pHardwareTextures; - if ( v7 ) + this->pTextures[i].Release(); + if ( this->pHardwareTextures ) { - v8 = v7[v5]; - if ( v8 ) + if ( this->pHardwareTextures[i] ) { - v8->Release(); - v1->pHardwareTextures[v5] = 0; + this->pHardwareTextures[i]->Release(); + this->pHardwareTextures[i] = 0; } } - v9 = v1->pHardwareSurfaces; - if ( v9 ) + if ( this->pHardwareSurfaces ) { - v10 = v9[v5]; - if ( v10 ) + if ( this->pHardwareSurfaces[i] ) { - v10->Release(); - v1->pHardwareSurfaces[v5] = 0; + this->pHardwareSurfaces[i]->Release(); + this->pHardwareSurfaces[i] = 0; } } - --v5; - --v6; } - while ( v5 >= v1->uNumPrevLoadedFiles ); } - v11 = v1->uNumPrevLoadedFiles; - v1->uNumPrevLoadedFiles = 0; - v1->uNumLoadedFiles = v11; + this->uNumLoadedFiles = this->uNumPrevLoadedFiles; + this->uNumPrevLoadedFiles = 0; } } }
--- a/LOD.h Tue Aug 06 00:52:46 2013 +0400 +++ b/LOD.h Tue Aug 06 00:56:33 2013 +0400 @@ -159,8 +159,8 @@ int _410522(struct Texture *pDst, const char *pContainer, unsigned int uTextureType); void SetupPalettes(unsigned int uTargetRBits, unsigned int uTargetGBits, unsigned int uTargetBBits); void ReleaseAll2(); - void _4114F2(); - void _4355F7(); + void RemoveTexturesPackFromTextureList(); + void RemoveTexturesFromTextureList(); void _inlined_sub0(); void _inlined_sub1(); void _inlined_sub2();
--- a/LightmapBuilder.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/LightmapBuilder.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -1,3 +1,5 @@ +#include <assert.h> + #include "LightmapBuilder.h" #include "Game.h" #include "stru314.h" @@ -739,6 +741,7 @@ v5 = (char *)&a1->flt_2C; do { + __debugbreak(); // warning C4700: uninitialized local variable 'v7' used if ( *(float *)v5 < 0.0 || (v6 = *(float *)v5, /*UNDEF(v7),*/ v8 = 1.0 < v6, v9 = 0, v10 = 1.0 == v6, LOWORD(result) = v7, v6 <= 1.0) ) { @@ -747,6 +750,7 @@ v14 = 0.0 < v12; v15 = 0; v16 = 0.0 == v12; + __debugbreak(); // warning C4700: uninitialized local variable 'v13' used LOWORD(result) = v13; if ( v12 >= 0.0 ) v11 = *(float *)v5; @@ -878,6 +882,7 @@ a1.Normalize(); if ( uLightType & 4 ) { + __debugbreak(); // warning C4700: uninitialized local variable 'v18' used v22[1] = v18; uLightType = dword_4D86D8; v22[0] = v18; @@ -1311,22 +1316,22 @@ // 4E94D2: using guessed type char _4E94D2_light_type; //----- (0045D3C7) -------------------------------------------------------- -bool LightmapBuilder::_45D3C7(stru148 *a1) +bool LightmapBuilder::_45D3C7(struct Polygon *a1) { LightmapBuilder *v2; // ebx@1 - stru148 *result; // eax@1 + struct Polygon *result; // eax@1 float v4; // ecx@2 Span *i; // edi@5 v2 = this; - result = (stru148 *)a1->prolly_head; + result = (struct Polygon *)a1->prolly_head; if ( result && (v4 = result->field_4, *(int *)&v4) != 0 && *(unsigned int *)(LODWORD(v4) + 60) ) { for ( i = a1->prolly_head; ; i = i->pNext ) { result = i->pParent; if ( result->field_108 ) - result = (stru148 *)_45D426( + result = (struct Polygon *)_45D426( i, a1->pEdgeList1, a1->uEdgeList1Size, @@ -1471,6 +1476,7 @@ v25 = 1.0; } v9->field_10 = v25; + __debugbreak(); // warning C4700: uninitialized local variable 'v27' used if ( v9->field_14 < 0.0 || (v26 = v9->field_14, //UNDEF(v27), @@ -1485,6 +1491,7 @@ v34 = 0.0 < v32; v35 = 0; v36 = 0.0 == v32; + __debugbreak(); // warning C4700: uninitialized local variable 'v33' used BYTE1(result) = HIBYTE(v33); if ( v32 >= 0.0 ) v31 = v9->field_14; @@ -1575,16 +1582,16 @@ } //----- (0045D73F) -------------------------------------------------------- -void LightmapBuilder::DrawLightmaps(int a2) +void LightmapBuilder::DrawLightmapsType(int type) { - if ( a2 == 2 ) - DoDrawLightmaps(); + if (type == 2) + Draw_183808_Lightmaps(); } //----- (0045D74F) -------------------------------------------------------- -char LightmapBuilder::_45D74F_MessWithLight(int a2, int *a3) +bool LightmapBuilder::DrawLightmaps(int *indices) { - char v3; // zf@1 + //char v3; // zf@1 IDirect3DDevice3 *v4; // eax@2 HRESULT v5; // eax@2 //char *v6; // eax@2 @@ -1594,16 +1601,16 @@ HRESULT v10; // eax@8 HRESULT v11; // eax@8 HRESULT v12; // eax@8 - int *v13; // eax@8 - float v14; // ecx@15 - IDirect3DDevice3 *v15; // eax@21 - HRESULT v16; // eax@21 - IDirect3DDevice3 *v17; // eax@21 - HRESULT v18; // eax@21 - IDirect3DDevice3 *v19; // eax@21 - HRESULT v20; // eax@21 - IDirect3DDevice3 *v21; // eax@21 - HRESULT v22; // eax@21 + //int *v13; // eax@8 + //float v14; // ecx@15 + //IDirect3DDevice3 *v15; // eax@21 + //HRESULT v16; // eax@21 + //IDirect3DDevice3 *v17; // eax@21 + //HRESULT v18; // eax@21 + //IDirect3DDevice3 *v19; // eax@21 + //HRESULT v20; // eax@21 + //IDirect3DDevice3 *v21; // eax@21 + //HRESULT v22; // eax@21 //IDirect3DDevice3 *v23; // eax@23 std::string v25; // [sp+44h] [bp-44h]@12 signed int v26; // [sp+48h] [bp-40h]@21 @@ -1611,86 +1618,65 @@ Lightmap *v28; // [sp+50h] [bp-38h]@2 int v29; // [sp+54h] [bp-34h]@2 //float v30; // [sp+58h] [bp-30h]@2 - int arg4; // [sp+68h] [bp-20h]@8 - float v32; // [sp+6Ch] [bp-1Ch]@8 - float v33; // [sp+70h] [bp-18h]@8 + Vec3_float_ arg4; + //int arg4; // [sp+68h] [bp-20h]@8 + //float v32; // [sp+6Ch] [bp-1Ch]@8 + //float v33; // [sp+70h] [bp-18h]@8 int v34; // [sp+74h] [bp-14h]@19 int v35; // [sp+78h] [bp-10h]@2 - int *v36; // [sp+7Ch] [bp-Ch]@10 - int a1; // [sp+80h] [bp-8h]@12 - float v38; // [sp+84h] [bp-4h]@1 + //int *v36; // [sp+7Ch] [bp-Ch]@10 + //int a1; // [sp+80h] [bp-8h]@12 + //float v38; // [sp+84h] [bp-4h]@1 + + if (std__vector_000004_size == 0) + return 1; + - v3 = this->std__vector_000004_size == 0; - LODWORD(v38) = (int)this; - if ( !v3 ) + ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_CLAMP)); + + v7 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"); + if ( pRenderer->bUsingSpecular ) + pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, FALSE); + + if ( !byte_4D864C || !(pGame->uFlags & GAME_FLAGS_1_01) ) { - //v30 = 0.0; - //v4 = pRenderer->pRenderD3D->pDevice; - ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u)); - //v6 = (char *)stru_69BD44.c_str(); - //if ( !stru_69BD44.c_str() ) - // v6 = (char *)&dword_4D86F0; - v7 = pGame->pIndoorCameraD3D->LoadTextureAndGetHardwarePtr("effpar03"); - if ( pRenderer->bUsingSpecular ) - pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0); - if ( !byte_4D864C || !(pGame->uFlags & 1) ) - { ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE)); ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, FALSE)); ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, v7)); ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); - v13 = a3; - v33 = 1.0; - v32 = 1.0; - *(float *)&arg4 = 1.0; - if ( a3 ) + + arg4.x = 1.0f; + arg4.y = 1.0f; + arg4.z = 1.0f; + if (indices) { - if ( *a3 != -1 ) + for (auto i = indices; *i != -1; ++i) { - v36 = a3; - do - { - v28 = (Lightmap *)(3100 * *v13 + LODWORD(v38) + 4); - if ( !DrawLightmap(v28, (Vec3_float_ *)&arg4, 0.0) ) - { - MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1230", 0); - a1 = 5080812; - } - v13 = v36 + 1; - v36 = v13; - } - while ( *v13 != -1 ); + v28 = &std__vector_000004[*i]; + if ( !DrawLightmap(v28, &arg4, 0.0) ) + assert(false && "Invalid lightmap detected!"); } } else { - v14 = v38; - v36 = 0; - if ( *(unsigned int *)(LODWORD(v38) + 1587204) > 0 ) + for (auto i = 0; i < std__vector_000004_size; ++i) { - a1 = LODWORD(v38) + 4; - while ( 1 ) - { - if ( !DrawLightmap((Lightmap *)a1, (Vec3_float_ *)&arg4, 0.0) ) + auto _a1 = &std__vector_000004[(int)i]; + if ( !DrawLightmap(_a1, &arg4, 0.0) ) { MessageBoxW(nullptr, L"Invalid lightmap detected!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Light.cpp:1238", 0); v35 = 5080812; } - v36 = (int *)((char *)v36 + 1); - a1 += 3100; - if ( (signed int)v36 >= *(unsigned int *)(LODWORD(v38) + 1587204) ) - break; - v14 = v38; - } } } - v15 = pRenderer->pRenderD3D->pDevice; - ErrD3D(v15->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); - ErrD3D(v15->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); - ErrD3D(v15->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); - ErrD3D(v15->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); - } + + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, TRUE)); + } + if ( pRenderer->bUsingSpecular ) { //LODWORD(v30) = 1; @@ -1705,13 +1691,13 @@ //v28 = (Lightmap *)pRenderer->pRenderD3D->pDevice; ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0)); } - } - return 1; + + return true; } //----- (0045DA56) -------------------------------------------------------- -bool LightmapBuilder::DrawLightmaps2(float z_bias) +bool LightmapBuilder::DoDraw_183808_Lightmaps(float z_bias) { Vec3_float_ v; // [sp+Ch] [bp-1Ch]@2 v.z = 1.0; @@ -1796,7 +1782,7 @@ } //----- (0045DCA9) -------------------------------------------------------- -void LightmapBuilder::DoDrawLightmaps() +void LightmapBuilder::Draw_183808_Lightmaps() { if (!std__vector_183808_size) return; @@ -1815,7 +1801,7 @@ ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE)); - DrawLightmaps2(0.00050000002); + DoDraw_183808_Lightmaps(0.00050000002); ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE)); ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO));
--- a/LightmapBuilder.h Tue Aug 06 00:52:46 2013 +0400 +++ b/LightmapBuilder.h Tue Aug 06 00:56:33 2013 +0400 @@ -35,15 +35,15 @@ virtual ~LightmapBuilder() //----- (0045BBAA) {} - void DoDrawLightmaps(); + void Draw_183808_Lightmaps(); bool DrawLightmap(Lightmap *a1, Vec3_float_ *pColorMult, float z_bias); - bool DrawLightmaps2(float a2); - char _45D74F_MessWithLight(int a2, int *a3); - void DrawLightmaps(int a2); + bool DoDraw_183808_Lightmaps(float a2); + bool DrawLightmaps(int *indices = nullptr); + void DrawLightmapsType(int type); bool DrawDebugOutlines(char bit_one_for_list1__bit_two_for_list2); double _45D643(struct Edge *a1, float a2); int _45D426(struct Span *a1, struct Edge **a2, unsigned int a3, struct Edge *a4, int a5); - bool _45D3C7(struct stru148 *a1); + bool _45D3C7(struct Polygon *a1); bool StackLight_TerrainFace(struct StationaryLight *pLight, struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, int X, unsigned int *pSlot); bool StackLights_TerrainFace(struct Vec3_float_ *pNormal, float *a3, struct RenderVertexSoft *a1, unsigned int uStripType, bool bLightBackfaces); bool ApplyLight_ODM(struct StationaryLight *pLight, struct ODMFace *pFace, unsigned int *pSlot, char a4);
--- a/Mouse.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Mouse.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -12,7 +12,6 @@ #include "LOD.h" #include "Game.h" -#include "stru11.h" #include "TurnEngine.h" #include "Viewport.h" #include "GUIWindow.h" @@ -58,36 +57,25 @@ //----- (00469903) -------------------------------------------------------- void Mouse::SetCursorBitmap(const char *pName) { - Mouse *v2; // esi@1 - HCURSOR v3; // eax@10 - //int v4; // ecx@10 - double v5; // st7@11 - float v6; // ST04_4@12 - LONG v7; // eax@14 - LONG v8; // eax@17 - unsigned int v9; // eax@21 - float v10; // [sp+4h] [bp-18h]@11 struct tagPOINT Point; // [sp+14h] [bp-8h]@20 - v2 = this; if ( !this->bInitialized || !pName ) return; if ( _stricmp("MICON2", pName) ) pGame->uFlags2 &= 0xFFFFFFEFu; else pGame->uFlags2 |= 0x10u; - if ( _stricmp(v2->pCurrentCursorName, pName) ) - strcpy(v2->pCurrentCursorName, pName); + if ( _stricmp(this->pCurrentCursorName, pName) ) + strcpy(this->pCurrentCursorName, pName); ClearCursor(); - if ( _strnicmp(pName, "MICON1", 5u) ) + if ( _strnicmp(pName, "MICON1", 5) ) { - v9 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); - v2->uCursorTextureID = v9; - v2->uCursorTextureID_2 = v9; - v2->AllocCursorSystemMem(); - v2->field_C = 0; - v2->bRedraw = 1; - v2->bActive = 1; + this->uCursorTextureID = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); + this->uCursorTextureID_2 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); + this->AllocCursorSystemMem(); + this->field_C = 0; + this->bRedraw = 1; + this->bActive = 1; if ( !areWeLoadingTexture ) { if (uCursorTextureID != -1) @@ -96,28 +84,17 @@ } return; } - v2->bActive = 0; - v2->field_C = 1; + this->bActive = 0; + this->field_C = 1; if ( !strcmp(pName, "MICON1") ) - { - v3 = LoadCursorA(GetModuleHandleW(nullptr), "Arrow"); - SetClassLongA(hWnd, GCL_HCURSOR, (LONG)v3); - } + SetClassLongA(hWnd, GCL_HCURSOR, (LONG)LoadCursorA(GetModuleHandleW(nullptr), "Arrow")); else if ( !strcmp(pName, "MICON2") ) - { - v7 = (LONG)LoadCursorA(GetModuleHandleW(nullptr), "Target"); - SetClassLongA(hWnd, -12, v7); - } + SetClassLongA(hWnd, -12, (LONG)LoadCursorA(GetModuleHandleW(nullptr), "Target")); else if ( !strcmp(pName, "MICON3") ) - { - v8 = (LONG)LoadCursorA(0, (LPCSTR)IDC_WAIT); - SetClassLongA(hWnd, -12, v8); - } -//LABEL_18: - - GetCursorPos(&Point); - ClientToScreen(hWnd,&Point); - SetCursorPos(Point.x, Point.y); + SetClassLongA(hWnd, -12, (LONG)LoadCursorA(0, (LPCSTR)IDC_WAIT)); + GetCursorPos(&Point); + ClientToScreen(hWnd,&Point); + SetCursorPos(Point.x, Point.y); } // 506128: using guessed type int areWeLoadingTexture;
--- a/Mouse.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Mouse.h Tue Aug 06 00:56:33 2013 +0400 @@ -46,7 +46,7 @@ { public: //----- (00467E4E) -------------------------------------------------------- - inline Mouse(ThreadWard *pWard) + inline Mouse(void/*ThreadWard*/ *pWard) { uCursorTextureID = 0; uCursorTextureID_2 = 0; @@ -132,7 +132,7 @@ int field_104; unsigned int uMouseClickX; unsigned int uMouseClickY; - ThreadWard *pWard; + void/*ThreadWard*/ *pWard; }; #pragma pack(pop)
--- a/NPC.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/NPC.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -1312,7 +1312,7 @@ { case 13: current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession].pJoinText;//(char *)*(&pNPCStats->field_13A64 + 5 * v2->uProfession); - current_npc_text = BuilDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); + current_npc_text = BuildDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); NPCHireableDialogPrepare(); dialogue_show_profession_details = false; goto _return; @@ -1391,7 +1391,7 @@ else v17 = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pBenefits; current_npc_text = v17; - v18 = BuilDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0); + v18 = BuildDialogueString(v17, uActiveCharacter - 1, 0, 0, 0, 0); dialogue_show_profession_details = ~dialogue_show_profession_details; current_npc_text = v18; } @@ -1511,7 +1511,7 @@ dialogue_show_profession_details = false; uDialogueType = 13; current_npc_text = pNPCStats->pProfessions[pCurrentNPCInfo->uProfession - 1].pJoinText; - current_npc_text = BuilDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); + current_npc_text = BuildDialogueString((char *)current_npc_text, uActiveCharacter - 1, 0, 0, 0, 0); if ( uActiveCharacter ) pPlayers[uActiveCharacter]->PlaySound(SPEECH_NotEnoughGold, 0); ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); @@ -1657,7 +1657,7 @@ pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); if ( pDialogueNPCCount == 1 && dword_591080 ) { - sub_4B3B42(in_current_building_type); + InitializaDialogueOptions(in_current_building_type); } else {
--- a/NPC.h Tue Aug 06 00:52:46 2013 +0400 +++ b/NPC.h Tue Aug 06 00:56:33 2013 +0400 @@ -193,3 +193,5 @@ bool PartyHasDragon(); bool CheckHiredNPCSpeciality(unsigned int uProfession); + +int UseNPCSkill(NPCProf profession);
--- a/OSAPI.h Tue Aug 06 00:52:46 2013 +0400 +++ b/OSAPI.h Tue Aug 06 00:56:33 2013 +0400 @@ -1,8 +1,10 @@ #define WIN32_LEAN_AND_MEAN +#include <assert.h> #include <windows.h> #include <MMSystem.h> #pragma comment(lib, "winmm.lib") #undef DrawText -#undef PlaySound \ No newline at end of file +#undef PlaySound +#undef Polygon \ No newline at end of file
--- a/Outdoor.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Outdoor.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -28,6 +28,7 @@ #include "Time.h" #include "Viewport.h" #include "Events.h" +#include "ParticleEngine.h" #include "mm7_data.h" #include "MM7.h" @@ -36,6 +37,7 @@ #include "MapInfo.h" #include "OutdoorCamera.h" +#include "Outdoor_stuff.h" #include "BSPModel.h" #include "GUIWindow.h" @@ -46,7 +48,7 @@ stru149 stru_8019C8; -std::array<stru148, 2000 + 18000> array_77EC08; +std::array<struct Polygon, 2000 + 18000> array_77EC08; Surf stru_80C980; Edge defaultEdge; // weak Edge stru_80C9A4; @@ -106,7 +108,7 @@ pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel; if (bRedraw || pRenderer->pRenderD3D) { - ResetStru148s(); + ResetPolygons(); pOutdoorCamera->RotationToInts(); sub_481ED9_MessWithOutdoorCamera(); } @@ -125,43 +127,36 @@ if ( pParty->uCurrentMinute != pOutdoor->uLastSunlightUpdateMinute ) pOutdoor->UpdateSunlightVectors(); pOutdoor->UpdateFog(); - pGame->pIndoorCameraD3D->Reset_list_0037C(); - if (!bRedraw) - { - if ( !pRenderer->pRenderD3D ) - { - pRenderer->OnOutdoorRedrawSW(); - } - else - { - pRenderer->DrawSkyD3D(); - pRenderer->DrawBuildingsD3D(); - pRenderer->RenderTerrainD3D(); - //pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag - } - } - else if (pRenderer->pRenderD3D) + //pGame->pIndoorCameraD3D->sr_Reset_list_0037C(); + + if (pRenderer->pRenderD3D) // d3d - redraw always { pRenderer->DrawSkyD3D(); pRenderer->DrawBuildingsD3D(); pRenderer->RenderTerrainD3D(); - //pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag } else { - pRenderer->DrawBuildingsSW(); - pRenderer->RenderTerrainD3D(); - //pRenderer->DrawBezierTerrain();// Ritor1: temporarily lag - sr_sub_486F92_MessWithEdgesAndSpans(); - pOutdoorCamera->_487355(); + __debugbreak(); // no SW Rendering + /*if (!bRedraw) + pRenderer->OnOutdoorRedrawSW(); + else + { + pRenderer->DrawBuildingsSW(); + pRenderer->DrawBezierTerrain(); + sr_sub_486F92_MessWithEdgesAndSpans(); + pOutdoorCamera->_487355(); + }*/ } + + pMobileLightsStack->uNumLightsActive = 0; pStationaryLightsStack->uNumLightsActive = 0; - if ( !pRenderer->pRenderD3D ) + /*if ( !pRenderer->pRenderD3D ) { pRenderer->ExecOutdoorDrawSW(); - pGame->pIndoorCameraD3D->_438240_draw_lits(); - } + pGame->pIndoorCameraD3D->sr_438240_draw_lits(); + }*/ pGame->PushStationaryLights(-1); pGame->PrepareBloodsplats(); if (bRedraw) @@ -187,7 +182,7 @@ pRenderer->DrawSpriteObjects_ODM(); pRenderer->TransformBillboardsAndSetPalettesODM(); - sub_485F53((Vec2_int_ *)unnamed_6BE060.data()); + //sr_485F53((Vec2_int_ *)sr_6BE060.data()); } @@ -201,7 +196,7 @@ pGame->DrawParticles(); pWeather->Draw(); - array_5118E8._440F07(); + trail_particle_generator.UpdateParticles(); } //----- (00488E23) -------------------------------------------------------- @@ -695,9 +690,9 @@ } //----- (00482170) -------------------------------------------------------- -bool ODMFace::IsBackfaceCulled(ODMFace *a1, RenderVertexSoft *a2, stru148 *a3) +bool ODMFace::IsBackfaceCulled(ODMFace *a1, RenderVertexSoft *a2, struct Polygon *a3) { - stru148 *v3; // edi@1 + struct Polygon *v3; // edi@1 RenderVertexSoft *v4; // esi@1 unsigned int v5; // edx@1 RenderVertexSoft *v6; // ecx@2 @@ -788,7 +783,7 @@ a3d = v22 * v19 - v21 * v18; v16 = a3d + 6.7553994e15; v3->v_18.z = LODWORD(v16); - v3->_486089_normalize_v_18(); + v3->_normalize_v_18(); a3e = -((double)v3->v_18.x * v4->vWorldViewPosition.x) - (double)v3->v_18.y * v4->vWorldViewPosition.y - (double)v3->v_18.z * v4->vWorldViewPosition.z; @@ -3172,7 +3167,7 @@ return true; } //----- (0046D49E) -------------------------------------------------------- -int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int __unused, int *pIsOnWater, int *a6, int bWaterWalk) +int ODM_GetFloorLevel(int X, signed int Y, int Z, int __unused, int *pIsOnWater, int *bmodel_pid, int bWaterWalk) { BSPModel *pBModel; // esi@4 ODMFace *pFace; // ecx@11 @@ -3289,12 +3284,12 @@ } if ( v46 == 1 ) { - *a6 = 0; + *bmodel_pid = 0; return odm_floor_level[0]; } v27 = 0; if ( v46 <= 1 ) - *a6 = 0; + *bmodel_pid = 0; else { //v29 = 1; @@ -3324,9 +3319,9 @@ } } if ( !v27 ) - *a6 = 0; + *bmodel_pid = 0; else - *a6 = dword_721110[v27] | (dword_721160[v27] << 6); + *bmodel_pid = dword_721110[v27] | (dword_721160[v27] << 6); } if ( v27 ) { @@ -3339,6 +3334,7 @@ odm_floor_level[0] = odm_floor_level[v27]; return odm_floor_level[0]; } + //not sure if right- or left-handed coordinate space assumed, so this could be normal of inverse normal // for a right-handed system, that would be an inverse normal //----- (0046DCC8) --------------------------------------------------------
--- a/Outdoor.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Outdoor.h Tue Aug 06 00:56:33 2013 +0400 @@ -2,6 +2,7 @@ #include "Indoor.h" #include "TileFrameTable.h" +#include "BSPModel.h" #define DAY_ATTRIB_FOG 1 @@ -81,7 +82,7 @@ bool HasEventHint(); - static bool IsBackfaceCulled(struct ODMFace *a1, struct RenderVertexSoft *a2, struct stru148 *a3); + static bool IsBackfaceCulled(struct ODMFace *a1, struct RenderVertexSoft *a2, struct Polygon *a3); inline bool Invisible() const {return (uAttributes & FACE_INVISIBLE) != 0;} inline bool Visible() const {return !Invisible();}
--- a/OutdoorCamera.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/OutdoorCamera.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -8,27 +8,6 @@ #include "mm7_data.h" #include "Allocator.h" -//----- (00487355) -------------------------------------------------------- -bool OutdoorCamera::_487355() -{ - int v0; // esi@1 - stru148 *v1; // edi@2 - bool result; // eax@3 - - v0 = 0; - if ( pOutdoorCamera->numStru148s > 0 ) - { - v1 = array_77EC08.data(); - do - { - result = pGame->pLightmapBuilder->_45D3C7(v1); - ++v0; - ++v1; - } - while ( v0 < pOutdoorCamera->numStru148s ); - } - return result; -} //----- (00481E55) -------------------------------------------------------- void OutdoorCamera::Project(unsigned int uNumVertices) { @@ -81,7 +60,7 @@ this->field_4C = 360000; this->int_fov_rad_inv = 65536 / v4; this->field_50 = 115; - unnamed_6BE060[1] = 1; + //sr_6BE060[1] = 1; RotationToInts(); }
--- a/OutdoorCamera.h Tue Aug 06 00:52:46 2013 +0400 +++ b/OutdoorCamera.h Tue Aug 06 00:56:33 2013 +0400 @@ -27,7 +27,7 @@ void ReleaseSoftwareDrawBuffers(); static void Project(unsigned int uNumVertices); - static bool _487355(); + //static bool _487355(); @@ -43,7 +43,7 @@ int camera_rotation_y_int_cosine; int camera_rotation_x_int_sine; int camera_rotation_x_int_cosine; - int numStru148s; + int uNumPolygons; unsigned int uNumEdges; unsigned int uNumSurfs; unsigned int uNumSpans;
--- a/Outdoor_stuff.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Outdoor_stuff.h Tue Aug 06 00:56:33 2013 +0400 @@ -6,19 +6,20 @@ /* 141 */ +// stru148 #pragma pack(push, 1) -struct stru148 +struct Polygon { - inline stru148() + inline Polygon() { uNumVertices = 0; } int _479295(); void DrawBorderTiles(); - void _48276F_sr(); - void _486089_normalize_v_18(); - void _48607B(struct stru149 *a2); + //void _48276F_sr(); + void _normalize_v_18(); + void Create_48607B(struct stru149 *a2); float field_0; float field_4; @@ -61,6 +62,7 @@ char field_10B; }; #pragma pack(pop) +extern std::array<struct Polygon, 2000 + 18000> array_77EC08; /* 142 */ #pragma pack(push, 1) @@ -68,7 +70,7 @@ { int _48616B(int a2, int a3, int a4, int a5, int a6, int a7); int _48653D(int a2, int a3, int a4, int a5, int a6, int a7); - int sky_48694B(); + void Inverse_sky_48694B(); int field_0_party_dir_x; int field_4_party_dir_y; @@ -92,7 +94,7 @@ struct Span { Span *pNext; - struct stru148 *pParent; + struct Polygon *pParent; __int16 field_8; __int16 field_A; __int16 field_C; @@ -101,7 +103,6 @@ float field_14; }; #pragma pack(pop) -extern std::array<stru148, 2000 + 18000> array_77EC08; @@ -116,7 +117,7 @@ float field_10; Surf *pNext; Surf *pPrev; - struct stru148 *pParent; + struct Polygon *pParent; __int16 field_20; __int16 field_22; };
--- a/ParticleEngine.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/ParticleEngine.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -12,6 +12,47 @@ #include "OutdoorCamera.h" #include "mm7_data.h" +TrailParticleGenerator trail_particle_generator; + + +//----- (00440DF5) -------------------------------------------------------- +void TrailParticleGenerator::AddParticle(int x, int y, int z, int bgr16) +{ + particles[num_particles].x = x; + particles[num_particles].y = y; + particles[num_particles].z = z; + particles[num_particles].time_to_live = rand() % 64 + 256; + particles[num_particles].time_left = particles[num_particles].time_to_live; + particles[num_particles].bgr16 = bgr16; + + num_particles++; + assert(num_particles < 100); +} + +//----- (00440E91) -------------------------------------------------------- +void TrailParticleGenerator::GenerateTrailParticles(int x, int y, int z, int bgr16) +{ + for (int i = 0; i < 5 + rand() % 6; ++i) + AddParticle(rand() % 33 + x - 16, + rand() % 33 + y - 16, + rand() % 33 + z, bgr16); +} + +//----- (00440F07) -------------------------------------------------------- +void TrailParticleGenerator::UpdateParticles() +{ + for (uint i = 0; i < 100; ++i) + { + if (particles[i].time_left > 0) + { + particles[i].x += rand() % 5 + 4; + particles[i].y += rand() % 5 - 2; + particles[i].z += rand() % 5 - 2; + particles[i].time_left -= pEventTimer->uTimeElapsed; + } + } +} + //----- (0048AAC5) -------------------------------------------------------- ParticleEngine::ParticleEngine() { @@ -65,9 +106,9 @@ v4->_x = a2->x; v4->_y = a2->y; v4->_z = a2->z; - v4->flt_10 = a2->flt_10; - v4->flt_14 = a2->flt_14; - v4->flt_18 = a2->flt_18; + v4->flt_10 = a2->r; + v4->flt_14 = a2->g; + v4->flt_18 = a2->b; v5 = a2->uDiffuse; v4->uParticleColor = v5; v4->uLightColor_bgr = v5;
--- a/ParticleEngine.h Tue Aug 06 00:52:46 2013 +0400 +++ b/ParticleEngine.h Tue Aug 06 00:56:33 2013 +0400 @@ -23,9 +23,9 @@ float x; float y; float z; - float flt_10; - float flt_14; - float flt_18; + float r; + float g; + float b; unsigned int uDiffuse; int timeToLive; unsigned int uTextureID; @@ -127,4 +127,73 @@ int uEndParticle; int uTimeElapsed; }; -#pragma pack(pop) \ No newline at end of file +#pragma pack(pop) + + + + + + + + + + + +/* 160 */ +#pragma pack(push, 1) +struct TrailParticle // stru167 +{ + inline TrailParticle() + { + x = 0; + y = 0; + z = 0; + time_left = 0; + time_to_live = 0; + bgr16 = 0; + } + + char field_0; + char field_1; + char field_2; + char field_3; + char field_4; + char field_5; + __int16 x; + __int16 y; + __int16 z; + __int16 time_left; + __int16 time_to_live; + char field_10; + char field_11; + char field_12; + char field_13; + __int16 bgr16; + char field_16; + char field_17; +}; +#pragma pack(pop) + + +/* 363 */ +#pragma pack(push, 1) +struct TrailParticleGenerator // stru167_wrap +{ + public: + inline TrailParticleGenerator() + { + num_particles = 0; + } + + void GenerateTrailParticles(int x, int y, int z, int bgr16); + void UpdateParticles(); + + protected: + void AddParticle(int x, int y, int z, int bgr16); + + TrailParticle particles[100]; + int num_particles; + int field_964; +}; +#pragma pack(pop) +extern TrailParticleGenerator trail_particle_generator; // 005118E8 \ No newline at end of file
--- a/Party.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Party.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -84,12 +84,16 @@ uDefaultPartyHeight = 120; field_14 = 37; y_rotation_granularity = 25; + y_rotation_speed = 90; + uWalkSpeed = 384; - y_rotation_speed = 90; + walk_sound_timer = 0; + field_24 = 5; field_6FC = 0; field_708 = 15; field_0 = 25; + } //inlined @@ -252,7 +256,7 @@ while ( v2 <= &pParty->pPlayers[3] ) { v3 = 0; - v4 = v2->pInventoryItems; + v4 = v2->pInventoryItemList; do { if ( v4->uItemID == uItemID ) @@ -562,7 +566,7 @@ //v10 = uSkillIdx - 35 < 0; } //while (uSkillIdx < 36); - pItems = pCharacter->pInventoryItems; + pItems = pCharacter->pInventoryItemList; //v13 = 138; for (int i = 0; i < 138; i++) { @@ -1098,7 +1102,7 @@ if ( pPlayer->classType == PLAYER_CLASS_LICH ) { have_vessels_soul = false; - v7 = pPlayer->pInventoryItems;//[0].field_1A; + v7 = pPlayer->pInventoryItemList;//[0].field_1A; for ( uint i = 138; i; --i ) { if ( v7->uItemID == 601 && (unsigned __int8)v7->uHolderPlayer == pPlayerID + 1 ) @@ -1216,16 +1220,16 @@ //----- (0041F5BE) -------------------------------------------------------- void __cdecl Sleep6Hours() { - if ( _506F18_num_hours_to_sleep < 6 ) + if ( _506F18_num_minutes_to_sleep < 6 ) { pParty->pPlayers[3].SetAsleep(false); pParty->pPlayers[2].SetAsleep(false); pParty->pPlayers[1].SetAsleep(false); pParty->pPlayers[0].SetAsleep(false); - if ( _506F18_num_hours_to_sleep ) + if ( _506F18_num_minutes_to_sleep ) { - Rest(_506F18_num_hours_to_sleep); - _506F18_num_hours_to_sleep = 0; + Rest(_506F18_num_minutes_to_sleep); + _506F18_num_minutes_to_sleep = 0; LoadActualSkyFrame(); } if ( dword_506F14 == 2 ) @@ -1238,7 +1242,7 @@ pTexture_RestUI_CurrentHourglassFrame->Release(); pTexture_RestUI_CurrentHourglassFrame = 0; pTexture_RestUI_CurrentSkyFrame = 0; - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); pIcons_LOD->SyncLoadedFilesCount(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; @@ -1253,7 +1257,7 @@ else { Rest(6u); - _506F18_num_hours_to_sleep -= 6; + _506F18_num_minutes_to_sleep -= 6; LoadActualSkyFrame(); } viewparams->bRedrawGameUI = 1; @@ -1448,7 +1452,7 @@ if ( uActiveCharacter && (v2 = pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) { - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v2-1], &pParty->pPickedItem, 0x24u); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v2-1], &pParty->pPickedItem, 0x24u); pMouse->RemoveHoldingItem(); } else @@ -1460,7 +1464,7 @@ v4 = v3->AddItem(-1, pParty->pPickedItem.uItemID); if ( v4 ) { - memcpy(&pParty->pPlayers[v12].pInventoryItems[v4 - 1], &pParty->pPickedItem, 0x24u); + memcpy(&pParty->pPlayers[v12].pInventoryItemList[v4 - 1], &pParty->pPickedItem, 0x24u); pMouse->RemoveHoldingItem(); break; }
--- a/Party.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Party.h Tue Aug 06 00:56:33 2013 +0400 @@ -34,6 +34,7 @@ /* 355 */ enum PARTY_FLAGS_1: __int32 { + PARTY_FLAGS_1_WATER_DAMAGE = 0x0004, PARTY_FLAGS_1_FALLING = 0x0008, PARTY_FLAGS_1_ALERT_RED = 0x0010, PARTY_FLAGS_1_ALERT_YELLOW = 0x0020,
--- a/Player.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Player.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -84,6 +84,30 @@ }; +unsigned char pEquipTypeToBodyAnchor[21] = // 4E8398 +{ + 1, // EQUIP_OFF_HAND + 1, // EQUIP_MAIN_HAND + 2, // EQUIP_BOW + 3, // EQUIP_ARMOUR + 0, // EQUIP_SHIELD + 4, // EQUIP_HELMET + 5, // EQUIP_BELT + 6, // EQUIP_CLOAK + 7, // EQUIP_GAUNTLETS + 8, // EQUIP_BOOTS + 10, // EQUIP_RING + 9, // EQUIP_AMULET + 1, // EQUIP_WAND + 0, // EQUIP_REAGENT + 0, // EQUIP_POTION + 0, // EQUIP_SPELL_SCROLL + 0, // EQUIP_BOOK + 0, // EQUIP_MESSAGE_SCROLL + 0, // EQUIP_GOLD + 0, // EQUIP_GEM + 0 // EQUIP_NONE +}; unsigned char pBaseHealthByClass[12] = {40, 35, 35, 30, 30, 30, 25, 20, 20, 0, 0, 0}; @@ -119,9 +143,6 @@ signed int parameter_to_bonus_value[29] = {30, 25, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6}; -unsigned char pEquipTypeToBodyAnchor[20] = {1, 1, 2, 3, 0, 4, 5, 6, 7, 8, 10, 9, 1, 0, 0, 0, 0, 0, 0, 0}; - - unsigned short base_recovery_times_per_weapon_type[12] = { 100, // PLAYER_SKILL_STAFF && Unarmed withoud skill @@ -455,11 +476,11 @@ return 0; } - inv_index = this->pInventoryIndices[item_idx]; + inv_index = this->pInventoryMatrix[item_idx]; if ( inv_index < 0 ) { *pitem_index = -1 - inv_index; - inv_index = this->pInventoryIndices[-1 - inv_index]; + inv_index = this->pInventoryMatrix[-1 - inv_index]; } return inv_index; @@ -489,15 +510,15 @@ { for ( i = 0; i < enchant_count; ++i ) { - if (!(pInventoryItems[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED)) - pInventoryItems[item_index_tabl[rand() % avalible_items]].uAttributes |= ITEM_ENCHANTED; + if (!(pInventoryItemList[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED)) + pInventoryItemList[item_index_tabl[rand() % avalible_items]].uAttributes |= ITEM_ENCHANTED; } } else { for ( i = 0; i < avalible_items; ++i ) { - pInventoryItems[item_index_tabl[i]].uAttributes |= ITEM_ENCHANTED; + pInventoryItemList[item_index_tabl[i]].uAttributes |= ITEM_ENCHANTED; } } } @@ -508,35 +529,22 @@ { signed int speechCount = 0; // esi@4 signed int expressionCount = 0; // esi@4 - unsigned __int8 v8; // al@6 int pickedVariant; // esi@10 - int v14; // eax@12 CHARACTER_EXPRESSION_ID expression; // ebx@17 - signed int v17; // ecx@19 - unsigned int pSoundID; // edi@20 + signed int pSoundID; // ecx@19 int speechVariantArray[5]; // [sp+Ch] [bp-1Ch]@7 int expressionVariantArray[5]; - int pPlayerNum; // [sp+24h] [bp-4h]@1 unsigned int pickedSoundID; // [sp+30h] [bp+8h]@4 unsigned int expressionDuration = 0; - pPlayerNum = 1; - for (int i = 0; i < 4; ++i) - if (&pParty->pPlayers[i] == this) - { - pPlayerNum = i + 1; - break; - } - pickedSoundID = 0; if (uVoicesVolumeMultiplier) { for (int i = 0; i < 2; i++) { - v8 = SoundSetAction[speech][i]; - if ( v8 ) - { - speechVariantArray[speechCount] = v8; + if ( SoundSetAction[speech][i] ) + { + speechVariantArray[speechCount] = SoundSetAction[speech][i]; speechCount++; } } @@ -547,17 +555,16 @@ if (numberOfSubvariants > 0) { pickedSoundID = rand() % numberOfSubvariants + 2 * (pickedVariant + 50 * uVoiceID) + 4998; - pAudioPlayer->PlaySound((SoundID)pickedSoundID, PID(OBJECT_Player, pPlayerNum + 39), 0, -1, 0, 0, (int)(pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f), 0); + pAudioPlayer->PlaySound((SoundID)pickedSoundID, PID(OBJECT_Player, uActiveCharacter + 39), 0, -1, 0, 0, (int)(pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f), 0); } } } for (int i = 0; i < 5; i++) { - v14 = SoundSetAction[speech][i + 3]; - if ( v14 ) - { - expressionVariantArray[expressionCount] = v14; + if ( SoundSetAction[speech][i + 3] ) + { + expressionVariantArray[expressionCount] = SoundSetAction[speech][i + 3]; expressionCount++; } } @@ -566,25 +573,16 @@ expression = (CHARACTER_EXPRESSION_ID)expressionVariantArray[rand() % expressionCount]; if (expression == CHARACTER_EXPRESSION_21 && pickedSoundID ) { - if ( (signed int)pSoundList->sNumSounds <= 0 ) - { - v17 = 0; - } - else - { - pSoundID = pSoundList->pSounds[0].uSoundID; - v17 = 0; + pSoundID = 0; + if ( pSoundList->sNumSounds ) + { for (int i = 0; i < pSoundList->sNumSounds; i++) { - v17 = i; - if (pSoundID == pickedSoundID) - { - break; - } - pSoundID += 120; + if (pSoundList->pSounds[i].uSoundID == pickedSoundID) + pSoundID = i; } } - if ( pSoundList->pSounds[v17].pSoundData[0] ) + if ( pSoundList->pSounds[pSoundID].pSoundData[0] ) expressionDuration = (sLastTrackLengthMS << 7) / 1000; } PlayEmotion(expression, expressionDuration); @@ -828,7 +826,7 @@ int innerLoopPos = startOfInnerLoop; for (unsigned int x = 0; x < slotWidth; x++) { - if (pInventoryIndices[innerLoopPos] != 0) + if (pInventoryMatrix[innerLoopPos] != 0) { return false; } @@ -843,11 +841,11 @@ // 506128: using guessed type int areWeLoadingTexture; //----- (004925E6) -------------------------------------------------------- -int Player::FindFreeInventorySlot() +int Player::FindFreeInventoryListSlot() { for (int i = 0; i < 126; i++ ) { - if (pInventoryItems[i].uItemID == 0) + if (pInventoryItemList[i].uItemID == 0) { return i; } @@ -859,13 +857,9 @@ int Player::CreateItemInInventory(unsigned int uSlot, unsigned int uItemID) { int result; // eax@8 - Texture *texturePtr; // esi@10 - int *v9; // esi@13 - unsigned int widthInSlots; // [sp+0h] [bp-Ch]@10 signed int freeSlot; // [sp+8h] [bp-4h]@4 - unsigned int heightInSlots; // [sp+18h] [bp+Ch]@10 - - freeSlot = FindFreeInventorySlot(); + + freeSlot = FindFreeInventoryListSlot(); if ( freeSlot == -1 ) { if ( uActiveCharacter ) @@ -874,26 +868,9 @@ } else { - texturePtr = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); - widthInSlots = GetSizeInInventorySlots(texturePtr->uTextureWidth); - heightInSlots = GetSizeInInventorySlots(texturePtr->uTextureHeight); - if ( !areWeLoadingTexture ) - { - texturePtr->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - if (widthInSlots > 0) - { - v9 = &this->pInventoryIndices[uSlot]; - for (unsigned int i = 0; i < heightInSlots; i++) - { - memset32(v9, -1 - uSlot, widthInSlots); //TODO: try to come up with a better solution. negative values are used when drawing the inventory - nothing is drawn - v9 += INVETORYSLOTSWIDTH; - } - } + PutItemArInventoryIndex(uItemID, freeSlot, uSlot); result = freeSlot + 1; - this->pInventoryIndices[uSlot] = freeSlot + 1; - this->pInventoryItems[freeSlot].uItemID = uItemID; + this->pInventoryItemList[freeSlot].uItemID = uItemID; } return result; } @@ -902,212 +879,124 @@ //----- (00492700) -------------------------------------------------------- int Player::HasSkill(unsigned int uSkillType) { - signed int result; // eax@3 - - if ( (signed int)uSkillType >= 37 || this->pActiveSkills[uSkillType] ) - { - result = 1; + if ( uSkillType >= 37 || this->pActiveSkills[uSkillType] ) + { + return 1; } else { sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[67], this->pName); ShowStatusBarString(pTmpBuf.data(), 2u); - result = 0; - } - return result; + return 0; + } } //----- (00492745) -------------------------------------------------------- -int Player::WearItem(unsigned int uItemID) +void Player::WearItem( unsigned int uItemID ) { int item_body_anch; // edi@6 int item_indx; - //find empty slot - for(item_indx=0;item_indx<126;++item_indx) - if (pInventoryItems[item_indx].uItemID==0) - break; - if (item_indx==126) //not found - item_indx=-1; + item_indx = FindFreeInventoryListSlot(); if ( item_indx != -1 ) { - - pInventoryItems[item_indx].uItemID=uItemID; - item_body_anch=pEquipTypeToBodyAnchor[pItemsTable->pItems[uItemID].uEquipType]; - pEquipment.pIndices[item_body_anch]=item_indx+1; - pInventoryItems[item_indx].uBodyAnchor=item_body_anch+1; - - } - return 0; + pInventoryItemList[item_indx].uItemID = uItemID; + item_body_anch = pEquipTypeToBodyAnchor[pItemsTable->pItems[uItemID].uEquipType]; + pEquipment.pIndices[item_body_anch] = item_indx + 1; + pInventoryItemList[item_indx].uBodyAnchor = item_body_anch + 1; + } } //----- (004927A8) -------------------------------------------------------- -int Player::AddItem(int uSlot, unsigned int uItemID) -{ - signed int v3; // ebx@2 - signed int v4; // edi@3 - unsigned int v5; // esi@3 - unsigned int v7; // [sp-8h] [bp-18h]@8 - unsigned int v8; // [sp-4h] [bp-14h]@8 - Player *thisa; // [sp+Ch] [bp-4h]@1 - - thisa = this; - if ( uSlot == -1 ) - { - v3 = 0; - while ( true ) - { - v4 = 0; - v5 = v3; - do - { - if ( CanFitItem(v5, uItemID) ) +int Player::AddItem(int index, unsigned int uItemID) +{ + int xStartValue = 0; + int startOfInnerLoop = 0; + + if ( index == -1 ) + { + for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) + { + int innerLoopPos = startOfInnerLoop; + for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++) + { + if ( CanFitItem(innerLoopPos, uItemID) ) { - v8 = uItemID; - v7 = v5; - return CreateItemInInventory(v7, v8); + return CreateItemInInventory(innerLoopPos, uItemID); } - ++v4; - v5 += 14; - } - while ( v4 < 9 ); - ++v3; - if ( v3 < 14 ) - continue; - break; + innerLoopPos++; + } + startOfInnerLoop += INVETORYSLOTSWIDTH; } return 0; } - if ( !CanFitItem(uSlot, uItemID) ) + if ( !CanFitItem(index, uItemID) ) { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return 0; } - v8 = uItemID; - v7 = uSlot; - return CreateItemInInventory(v7, v8); + return CreateItemInInventory(index, uItemID); } //----- (00492826) -------------------------------------------------------- -int Player::AddItem2(int uSlot, ItemGen *Src) -{ - unsigned int v3; // ebx@1 - unsigned int v4; // esi@3 - signed int v5; // edi@3 - unsigned int v7; // [sp-8h] [bp-18h]@9 - ItemGen *v8; // [sp-4h] [bp-14h]@9 - Player *thisa; // [sp+Ch] [bp-4h]@1 - signed int uSlota; // [sp+18h] [bp+8h]@2 - - thisa = this; - v3 = Src->uItemID; +int Player::AddItem2(int index, ItemGen *Src) +{ + int xStartValue = 0; pItemsTable->SetSpecialBonus(Src); - if ( uSlot == -1 ) - { - uSlota = 0; - while ( true ) - { - v4 = uSlota; - v5 = 0; - do - { - if ( CanFitItem(v4, v3) ) + int startOfInnerLoop = 0; + + if ( index == -1 ) + { + for (int ycoord = 0; ycoord < INVETORYSLOTSHEIGHT; ycoord++) //TODO: change pInventoryMatrix to 2 dimensional array. + { + int innerLoopPos = startOfInnerLoop; + for (int xcoord = 0; xcoord < INVETORYSLOTSWIDTH; xcoord++) + { + if ( CanFitItem(innerLoopPos, Src->uItemID) ) { - v8 = Src; - v7 = v4; - return CreateItemInInventory2(v7, v8); + return CreateItemInInventory2(innerLoopPos, Src); } - ++v5; - v4 += 14; - } - while ( v5 < 14 ); - ++uSlota; - if ( uSlota < 9 ) - continue; - break; + innerLoopPos++; + } + startOfInnerLoop += INVETORYSLOTSWIDTH; } return 0; } - if ( !CanFitItem(uSlot, v3) ) + if ( !CanFitItem(index, Src->uItemID) ) return 0; - v8 = Src; - v7 = uSlot; - return CreateItemInInventory2(v7, v8); + return CreateItemInInventory2(index, Src); } //----- (0049289C) -------------------------------------------------------- -int Player::CreateItemInInventory2(unsigned int uSlot, ItemGen *Src) -{ - signed int v3; // ebx@1 - ItemGen *v4; // eax@1 +int Player::CreateItemInInventory2( unsigned int index, ItemGen *Src ) +{ + signed int freeSlot; // ebx@1 int result; // eax@6 - //unsigned int v6; // eax@7 - Texture *item_texture; // esi@7 - unsigned int v8; // edx@9 - int *pInvPos; // esi@10 - unsigned int slot_width; // [sp+4h] [bp-Ch]@7 - unsigned int slot_height; // [sp+8h] [bp-8h]@7 - Player *v12; // [sp+Ch] [bp-4h]@1 - - - v12 = this; - v3 = 0; - v4 = this->pInventoryItems; - while ( v4->uItemID ) - { - ++v3; - ++v4; - if ( v3 >= 126 ) - { - v3 = -1; - break; - } - } - if ( v3 == -1 ) + + freeSlot = FindFreeInventoryListSlot(); + if ( freeSlot == -1 ) { result = 0; } else { - item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[Src->uItemID].pIconName, TEXTURE_16BIT_PALETTE); - slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth); - slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight); - if ( !areWeLoadingTexture ) - { - item_texture->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - if ( slot_height > 0 ) - { - pInvPos = &pInventoryIndices[uSlot]; - do - { - if ( slot_width > 0 ) - memset32(pInvPos, -1 - uSlot, slot_width); - pInvPos +=14; - --slot_height; - } - while ( slot_height ); - } - pInventoryIndices[uSlot] = v3 + 1; - memcpy(&pInventoryItems[v3], Src, sizeof(ItemGen)); - result = v3 + 1; + PutItemArInventoryIndex(Src->uItemID, freeSlot, index); + memcpy(&pInventoryItemList[freeSlot], Src, sizeof(ItemGen)); + result = freeSlot + 1; } return result; } // 506128: using guessed type int areWeLoadingTexture; //----- (0049298B) -------------------------------------------------------- -int Player::PutItemArInventoryIndex( ItemGen *item, int item_id, int uSlot ) - { - //Player *v4; // ebx@1 - //unsigned int v5; // eax@1 +void Player::PutItemArInventoryIndex( int uItemID, int itemListPos, int index ) //originally accepted ItemGen* but needed only its uItemID +{ Texture *item_texture; // esi@1 int *pInvPos; // esi@4 unsigned int slot_width; // [sp+Ch] [bp-4h]@1 unsigned int slot_height; // [sp+18h] [bp+8h]@1 - item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[item->uItemID].pIconName, TEXTURE_16BIT_PALETTE); + item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth); slot_height = GetSizeInInventorySlots(item_texture->uTextureHeight); if ( !areWeLoadingTexture ) @@ -1115,35 +1004,30 @@ item_texture->Release(); pIcons_LOD->SyncLoadedFilesCount(); } - if ( (signed int)slot_height > 0 ) - { - pInvPos = &pInventoryIndices[uSlot]; //14x9 - do - { - if ( (signed int)slot_width > 0 ) - memset32(pInvPos, -1 - uSlot, slot_width); - pInvPos +=14; - --slot_height; - } - while ( slot_height ); - } - pInventoryIndices[uSlot] = item_id + 1; - return 1; + if ( slot_width > 0 ) + { + pInvPos = &pInventoryMatrix[index]; + for (unsigned int i = 0; i < slot_height; i++) + { + memset32(pInvPos, -1 - index, slot_width);//TODO: try to come up with a better solution. negative values are used when drawing the inventory - nothing is drawn + pInvPos += INVETORYSLOTSWIDTH; + } + } + pInventoryMatrix[index] = itemListPos + 1; } // 506128: using guessed type int areWeLoadingTexture; //----- (00492A36) -------------------------------------------------------- -void Player::RemoveItemAtInventoryIndex( unsigned int uSlot ) - { - +void Player::RemoveItemAtInventoryIndex( unsigned int index ) +{ ItemGen *item_in_slot; // ecx@1 Texture *item_texture; // esi@1 unsigned int slot_height; // ebp@1 int *pInvPos; // edx@4 unsigned int slot_width; // [sp+14h] [bp+4h]@1 - item_in_slot = &this->pInventoryItems[pInventoryIndices[uSlot]-1]; + item_in_slot = &this->pInventoryItemList[pInventoryMatrix[index]-1]; item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[item_in_slot->uItemID].pIconName, TEXTURE_16BIT_PALETTE); item_in_slot->Reset(); slot_width = GetSizeInInventorySlots(item_texture->uTextureWidth); @@ -1153,201 +1037,103 @@ item_texture->Release(); pIcons_LOD->SyncLoadedFilesCount(); } - if ( slot_height > 0 ) - { - pInvPos = &pInventoryIndices[uSlot]; - do - { - if (slot_width > 0 ) - memset32(pInvPos, 0, slot_width); - pInvPos += 14; - --slot_height; - } - while ( slot_height ); - } - + if ( slot_width > 0 ) + { + pInvPos = &pInventoryMatrix[index]; + for (unsigned int i = 0; i < slot_height; i++) + { + memset32(pInvPos, 0, slot_width); + pInvPos += INVETORYSLOTSWIDTH; + } + } } // 506128: using guessed type int areWeLoadingTexture; -//identf //----- (00490EEE) -------------------------------------------------------- -int Player::SelectPhrasesTransaction(ItemGen *pItem, int building_type, int BuildID_2Events, int ShopMenuType) -{ - int pSkillLevel; // eax@1 - int NotBuy; // eax@1 - int result; - signed int pEquipType; // esi@1 - float *pPriceMultiplier; // esi@26 - int pPriceItemService; // edi@26 - - pSkillLevel = GetActualSkillLevel(PLAYER_SKILL_MERCHANT); - NotBuy = 4; - pEquipType = pItemsTable->pItems[pItem->uItemID].uEquipType; - if ( (building_type != 4 || (signed int)pItem->uItemID < 740 || (signed int)pItem->uItemID > 771) - && ((signed int)pItem->uItemID >= 600 || (signed int)pItem->uItemID >= 529 && (signed int)pItem->uItemID <= 599) ) - return 5; - if ( building_type == BildingType_WeaponShop ) - { - if ( pEquipType > EQUIP_BOW ) - return NotBuy; - if (pItem->Stolen()) - return 6; - } - if ( building_type == BildingType_ArmorShop ) - { - if ( pEquipType < 3 && pEquipType > 9 ) - return NotBuy; - if (pItem->Stolen()) - return 6; - } - if ( building_type == BildingType_MagicShop ) - { - if ( pItemsTable->pItems[pItem->uItemID].uSkillType == 38 ) - { - if (pItem->Stolen()) - return 6; - pPriceMultiplier = &p2DEvents[BuildID_2Events - 1].fPriceMultiplier; - pPriceItemService = GetBuyingPrice(pItem->GetValue(), *pPriceMultiplier); - if ( ShopMenuType == 3 )//Sell - { - pPriceItemService = this->GetPriceSell(pItem->GetValue(), *pPriceMultiplier); - if (!pItem->Broken()) - { - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; - else - result = 1; - return result; - } - pPriceItemService = 1; - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; - else - result = 1; - return result; - } - if ( ShopMenuType == 4 )//Identify - { - pPriceItemService = this->GetPriceIdentification(*pPriceMultiplier); - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; - else - result = 1; - return result; - } - if ( ShopMenuType == 5 )//Repair - { - pPriceItemService = this->GetPriceRepair(pItem->GetValue(), *pPriceMultiplier); - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; - else - result = 1; - return result; - } - if ( ShopMenuType != 6 )//Buy and ??? - { - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; - else - result = 1; - return result; - } - pPriceItemService = this->GetPriceSell(pItem->GetValue(), *pPriceMultiplier) / 2; +int Player::SelectPhrasesTransaction(ItemGen *pItem, int building_type, int BuildID_2Events, int ShopMenuType) //TODO: probably move this somewhere else, not really Player:: stuff +{ + unsigned int idemId; // edx@1 + signed int equipType; // esi@1 + float multiplier; // ST04_4@26 + int price; // edi@26 + int merchantLevel; // [sp+10h] [bp-8h]@1 + int itemValue; + + merchantLevel = GetActualSkillLevel(PLAYER_SKILL_MERCHANT); + idemId = pItem->uItemID; + equipType = pItemsTable->pItems[idemId].uEquipType; + itemValue = pItem->GetValue(); + + switch (building_type) + { + case BuildingType_WeaponShop: + if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) + return 5; + if (equipType > EQUIP_BOW) + return 4; + break; + case BuildingType_ArmorShop: + if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) + return 5; + if ( equipType < EQUIP_ARMOUR || equipType > EQUIP_BOOTS) + return 4; + break; + case BuildingType_MagicShop: + if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) + return 5; + if ( pItemsTable->pItems[idemId].uSkillType != PLAYER_SKILL_MISC ) + return 4; + break; + case BuildingType_AlchemistShop: + if ((idemId >= ITEM_ARTIFACT_HERMES_SANDALS && idemId < ITEM_RECIPE_REJUVENATION) || idemId > ITEM_RECIPE_BODY_RESISTANCE) + return 5; + if ( !(equipType == EQUIP_REAGENT || equipType == EQUIP_POTION || equipType == EQUIP_MESSAGE_SCROLL)) + return 4; + break; + default: + assert(false); + break; + } + if (pItem->Stolen()) + return 6; + + multiplier = p2DEvents[BuildID_2Events - 1].fPriceMultiplier; + switch (ShopMenuType) + { + case 2: + price = GetBuyingPrice(itemValue, multiplier); + break; + case 3: if (pItem->Broken()) - pPriceItemService = 1; - if ( pPriceItemService >= 1 ) - { - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; - else - result = 1; - return result; - } - pPriceItemService = 1; - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; - else - result = 1; - return result; - } - if ( pEquipType != EQUIP_BOOK ) - return NotBuy; - } - if ( building_type == BildingType_AlchemistShop ) - { - if ( pEquipType < EQUIP_REAGENT ) - return NotBuy; - if ( pEquipType > EQUIP_POTION ) - { - if ( pEquipType != EQUIP_MESSAGE_SCROLL ) - return NotBuy; - } - if (pItem->Stolen()) - return 6; - } - pPriceMultiplier = &p2DEvents[BuildID_2Events - 1].fPriceMultiplier; - pPriceItemService = GetBuyingPrice(pItem->GetValue(), *pPriceMultiplier); - if ( ShopMenuType == 3 )//Sell - { - pPriceItemService = this->GetPriceSell(pItem->GetValue(), *pPriceMultiplier); - if (!pItem->Broken()) - { - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; + price = 1; else - result = 1; - return result; - } - pPriceItemService = 1; - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; - else - result = 1; - return result; - } - if ( ShopMenuType == 4 )//Identify - { - pPriceItemService = this->GetPriceIdentification(*pPriceMultiplier); - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; - else - result = 1; - return result; - } - if ( ShopMenuType == 5 )//Repair - { - pPriceItemService = this->GetPriceRepair(pItem->GetValue(), *pPriceMultiplier); - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; + price = this->GetPriceSell(itemValue, multiplier); + break; + case 4: + price = this->GetPriceIdentification(multiplier); + break; + case 5: + price = this->GetPriceRepair(itemValue, multiplier); + break; + default: + assert(false); + break; + } + if ( merchantLevel ) + { + if (price == itemValue) + { + return 3; + } else - result = 1; - return result; - } - if ( ShopMenuType != 6 )//Buy and ??? - { - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; - else - result = 1; - return result; - } - pPriceItemService = this->GetPriceSell(pItem->GetValue(), *pPriceMultiplier) / 2; - if (pItem->Broken()) - pPriceItemService = 1; - if ( pPriceItemService >= 1 ) - { - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; - else - result = 1; - return result; - } - pPriceItemService = 1; - if ( pSkillLevel ) - result = (pPriceItemService == pItem->GetValue()) + 2; + { + return 2; + } + } else - result = 1; - return result; + { + return 1; + } } //----- (0049107D) -------------------------------------------------------- @@ -1650,9 +1436,9 @@ Player::Player() { memset(&pEquipment, 0, sizeof(PlayerEquipment)); - memset(pInventoryIndices, 0, 126 * sizeof(int)); + memset(pInventoryMatrix, 0, 126 * sizeof(int)); for (uint i = 0; i < 126; ++i) - pInventoryItems[i].Reset(); + pInventoryItemList[i].Reset(); for (uint i = 0; i < 12; ++i) pEquippedItems[i].Reset(); @@ -1683,6 +1469,7 @@ uLuck = uLuckBonus = 0; uLevel = sLevelModifier = 0; sAgeModifier = 0; + sACModifier = 0; // memset(field_1F5, 0, 30); pure_luck_used=0; @@ -1826,7 +1613,7 @@ goto LABEL_15; } } - memcpy(&v9->pInventoryItems[v10-1], pItem, 0x24u); + memcpy(&v9->pInventoryItemList[v10-1], pItem, 0x24u); pItem->Reset(); pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); v19->PlaySound(SPEECH_60, 0); @@ -2126,7 +1913,7 @@ } if ( HasItemEquipped(EQUIP_MAIN_HAND) ) { - v6 = (ItemGen *)&v5->pInventoryItems[v5->pEquipment.uMainHand-1]; + v6 = (ItemGen *)&v5->pInventoryItemList[v5->pEquipment.uMainHand-1]; v7 = v6->uItemID; v8 = v6->uItemID; v9 = pItemsTable->pItems[v8].uDamageDice; @@ -2198,7 +1985,7 @@ { if ( v5->HasItemEquipped((ITEM_EQUIP_TYPE)0) ) { - v15 = (ItemGen *)&v5->pInventoryItems[v5->pEquipment.uShield - 1]; + v15 = (ItemGen *)&v5->pInventoryItemList[v5->pEquipment.uShield - 1]; v16 = v15->uItemID; v17 = v15->uItemID; if ( pItemsTable->pItems[v17].uEquipType != 4 ) @@ -2291,7 +2078,7 @@ int v7; // edi@4 v1 = this; - v2 = *(int *)&this->pInventoryItems[this->pEquipment.uMainHand-1]; + v2 = *(int *)&this->pInventoryItemList[this->pEquipment.uMainHand-1]; if ( v2 < 64 || v2 > 65 ) { v4 = GetActualAccuracy(); @@ -2381,7 +2168,7 @@ result = HasItemEquipped(EQUIP_BOW); if ( !result ) return result; - v4 = (ItemGen *)&v2->pInventoryItems[v2->pEquipment.uBow-1]; + v4 = (ItemGen *)&v2->pInventoryItemList[v2->pEquipment.uBow-1]; v5 = v4->uItemID; v6 = v4->uItemID; v15 = pItemsTable->pItems[v6].uDamageRoll; @@ -2631,13 +2418,13 @@ //----- (0048D62C) -------------------------------------------------------- ITEM_EQUIP_TYPE Player::GetEquippedItemEquipType(ITEM_EQUIP_TYPE uEquipSlot) { - return pItemsTable->pItems[pInventoryItems[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uEquipType; + return pItemsTable->pItems[pInventoryItemList[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uEquipType; } //----- (0048D651) -------------------------------------------------------- PLAYER_SKILL_TYPE Player::GetEquippedItemSkillType(ITEM_EQUIP_TYPE uEquipSlot) { - return (PLAYER_SKILL_TYPE)pItemsTable->pItems[pInventoryItems[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uSkillType; + return (PLAYER_SKILL_TYPE)pItemsTable->pItems[pInventoryItemList[pEquipment.pIndices[uEquipSlot] - 1].uItemID].uSkillType; } //----- (0048D676) -------------------------------------------------------- @@ -2680,7 +2467,7 @@ { v6 = 0; while ( !HasItemEquipped((ITEM_EQUIP_TYPE)v6) - || pInventoryItems[pEquipment.pIndices[v6] - 1].uItemID != item_id ) + || pInventoryItemList[pEquipment.pIndices[v6] - 1].uItemID != item_id ) { ++v6; if ( (signed int)v6 >= 16 ) @@ -2688,7 +2475,7 @@ } return 1; } - if ( HasItemEquipped(equip_type) && pInventoryItems[pEquipment.pIndices[equip_type - 1]].uItemID == item_id ) + if ( HasItemEquipped(equip_type) && pInventoryItemList[pEquipment.pIndices[equip_type - 1]].uItemID == item_id ) return 1; return 0; } @@ -3065,7 +2852,7 @@ break; case 17: v12 = 0; - v13 = this->pInventoryItems; + v13 = this->pInventoryItemList; do { if ( (signed int)v13->uItemID > 0 && (signed int)v13->uItemID <= 134 && !v13->Broken()) @@ -3081,6 +2868,7 @@ { if ( HasItemEquipped((ITEM_EQUIP_TYPE)v14) ) { + __debugbreak(); // player.cpp(2871): warning C4700: uninitialized local variable 'v15' used if ( v15 == EQUIP_ARMOUR ) v46[v4++] = LOBYTE(v5->pEquipment.uArmor) - 1; if ( (!v15 || v15 == 1) && GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v15) == 4 ) @@ -3096,6 +2884,7 @@ { if ( HasItemEquipped((ITEM_EQUIP_TYPE)v16) ) { + __debugbreak(); // player.cpp(2886): warning C4700: uninitialized local variable 'v17' used if ( v17 == 2 ) v46[v4++] = LOBYTE(v5->pEquipment.uBow) - 1; if ( (!v17 || v17 == 1) @@ -3108,17 +2897,17 @@ LABEL_36: if ( !v4 ) goto LABEL_87; - v48 = (int)&v5->pInventoryItems[(unsigned __int8)v46[rand() % v4]]; + v48 = (int)&v5->pInventoryItemList[(unsigned __int8)v46[rand() % v4]]; v11 = 3 * (pItemsTable->pItems[*(int *)v48].uMaterial + pItemsTable->pItems[*(int *)v48].uDamageMod); break; case 20: v19 = 0; - v20 = this->pInventoryIndices; + v20 = this->pInventoryMatrix; do { if ( *v20 > 0 ) { - v21 = *(int *)&v5->pInventoryItems[*v20-1]; + v21 = *(int *)&v5->pInventoryItemList[*v20-1]; if ( v21 > 0 ) { if ( v21 <= 134 ) @@ -3291,7 +3080,7 @@ goto LABEL_84; } v28 = v47; - memcpy(v27, &v5->pInventoryItems[v5->pInventoryIndices[v47]-1], 0x24u); + memcpy(v27, &v5->pInventoryItemList[v5->pInventoryMatrix[v47]-1], 0x24u); RemoveItemAtInventoryIndex(v28); LABEL_79: v42 = 0; @@ -3345,7 +3134,7 @@ { if ( !HasItemEquipped(EQUIP_BOW) ) goto LABEL_17; - weapon = &pInventoryItems[pEquipment.uBow - 1]; + weapon = &pInventoryItemList[pEquipment.uBow - 1]; weapon_desc = &pItemsTable->pItems[weapon->uItemID]; weapon_recovery = base_recovery_times_per_weapon_type[weapon_desc->uSkillType]; goto LABEL_17; @@ -3361,7 +3150,7 @@ if ( HasItemEquipped(EQUIP_MAIN_HAND) ) { - weapon = &pInventoryItems[pEquipment.uMainHand - 1]; + weapon = &pInventoryItemList[pEquipment.uMainHand - 1]; weapon_desc = &pItemsTable->pItems[weapon->uItemID]; if (weapon_desc->uEquipType == EQUIP_WAND) { @@ -3375,11 +3164,11 @@ if (HasItemEquipped(EQUIP_OFF_HAND) && GetEquippedItemEquipType(EQUIP_OFF_HAND) != EQUIP_SHIELD) // ADD: shield check because shield recovery is added later and can be accidentally doubled { - auto v12 = &pInventoryItems[pEquipment.uShield - 1]; + auto v12 = &pInventoryItemList[pEquipment.uShield - 1]; auto v12_desc = &pItemsTable->pItems[v12->uItemID]; if (base_recovery_times_per_weapon_type[v12_desc->uSkillType] > weapon_recovery) { - weapon = &pInventoryItems[pEquipment.uShield - 1]; + weapon = &pInventoryItemList[pEquipment.uShield - 1]; weapon_desc = &pItemsTable->pItems[weapon->uItemID]; weapon_recovery = base_recovery_times_per_weapon_type[pItemsTable->pItems[weapon->uItemID].uSkillType]; } @@ -3389,7 +3178,7 @@ uint armour_recovery = 0; if ( HasItemEquipped(EQUIP_ARMOUR) ) { - auto armour_skill_type = pItemsTable->pItems[pInventoryItems[pEquipment.uArmor - 1].uItemID].uSkillType; + auto armour_skill_type = pItemsTable->pItems[pInventoryItemList[pEquipment.uArmor - 1].uItemID].uSkillType; uint base_armour_recovery = base_recovery_times_per_weapon_type[armour_skill_type]; float armour_recovery_multipliers[4]; @@ -3432,7 +3221,7 @@ { float shield_recovery_multipliers[4] = {1, 0, 0, 0}; - auto shield = &pInventoryItems[pEquipment.uShield - 1]; + auto shield = &pInventoryItemList[pEquipment.uShield - 1]; auto skill_type = pItemsTable->pItems[shield->uItemID].uSkillType; uint shield_base_recovery = base_recovery_times_per_weapon_type[skill_type]; @@ -3865,12 +3654,12 @@ inv_indx = pEquipment.pIndices[i] - 1; if (a2==17) { - if ((pInventoryItems[inv_indx].uSpecEnchantmentType==17)||(pInventoryItems[inv_indx].uItemID==533)) //Elven Chainmail+Increases rate of Recovery + if ((pInventoryItemList[inv_indx].uSpecEnchantmentType==17)||(pInventoryItemList[inv_indx].uItemID==533)) //Elven Chainmail+Increases rate of Recovery return 50; } if (a2==24) { - if (pInventoryItems[inv_indx].uSpecEnchantmentType==24) //Increased Knockback. + if (pInventoryItemList[inv_indx].uSpecEnchantmentType==24) //Increased Knockback. return 5; } } @@ -3900,7 +3689,7 @@ Player *v21; // ecx@75 int v22; // eax@76 int v23; // edx@76 - int v24; // eax@79 + //int v24; // eax@79 int v25; // ecx@80 int v26; // edi@80 Player *v27; // ecx@84 @@ -4032,7 +3821,7 @@ { if ( v32 <= 11 ) { - v33 = v6->pInventoryItems[v31].uItemID; + v33 = v6->pInventoryItemList[v31].uItemID; v5 += pItemsTable->pItems[v33].uDamageDice + pItemsTable->pItems[v33].uDamageMod; } } @@ -4598,16 +4387,15 @@ v23 = this->pOwnItems[this->pEquipment.uMainHand].uItemID; if ( v6->pEquipment.uShield || pItemsTable->pItems[v23].uSkillType != 4 ) { - v24 = v23; v26 = pItemsTable->pItems[v23].uDamageRoll; v25 = pItemsTable->pItems[v23].uDamageDice; } else { - v25 = pItemsTable->pItems[v24].uDamageRoll; - v26 = pItemsTable->pItems[v24].uDamageDice + 1; + v25 = pItemsTable->pItems[v23].uDamageRoll; + v26 = pItemsTable->pItems[v23].uDamageDice + 1; } - v5 = pItemsTable->pItems[v24].uDamageMod + v25 * v26; + v5 = pItemsTable->pItems[v23].uDamageMod + v25 * v26; } } } @@ -5332,7 +5120,7 @@ { if ( v2->HasItemEquipped(v71) ) { - v11 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v2->pInventoryItems[*(_DWORD *)v9].uItemID].uEquipType; + v11 = (PLAYER_SKILL_TYPE)pItemsTable->pItems[v2->pInventoryItemList[*(_DWORD *)v9].uItemID].uEquipType; LOBYTE(v12) = this->GetActualSkillLevel(v11); a1 = v12; SkillToMastery(v12); @@ -5390,7 +5178,7 @@ { if ( v2->HasItemEquipped(v20) ) { - v22 = this->pInventoryItems[this->pEquipment.pIndices[v20]].uItemID; + v22 = this->pInventoryItemList[this->pEquipment.pIndices[v20]].uItemID; if ( pItemsTable->pItems[v22].uEquipType <= 1u ) break; } @@ -5461,6 +5249,7 @@ assert(false && "Unknown attribute!"); + return 0; } //----- (00490109) -------------------------------------------------------- @@ -5542,10 +5331,9 @@ case 0x15u: case 0x18u: return SEX_FEMALE; - - default: - assert(false); - } + } + assert(false); + return SEX_MALE; } //----- (00490188) -------------------------------------------------------- @@ -5793,6 +5581,8 @@ ++counter; } } + + assert(false); } @@ -5943,17 +5733,9 @@ //----- (004907E7) -------------------------------------------------------- unsigned int Player::GetStatColor(int uStat) { - __int16 uWhite; // si@1 int attribute_value; // edx@1 - unsigned __int8 pBaseAttrValue; // of@1 - __int16 uGreen; // [sp+8h] [bp-8h]@1 - __int16 uRed; // [sp+Ch] [bp-4h]@1 - - uRed = TargetColor(255, 35, 0); - uGreen = TargetColor(0, 255, 0); - uWhite = TargetColor(255, 255, 255); - pBaseAttrValue = StatTable[GetRace()][uStat].uBaseValue; - + + int base_attribute_value = StatTable[GetRace()][uStat].uBaseValue; switch (uStat) { case 0: attribute_value = uMight; break; @@ -5965,12 +5747,12 @@ case 6: attribute_value = uLuck; break; }; - if ( attribute_value == pBaseAttrValue ) - return uWhite; - else if ( attribute_value > pBaseAttrValue ) - return uGreen; + if (attribute_value == base_attribute_value) + return ui_character_stat_default_color; + else if (attribute_value > base_attribute_value) + return ui_character_stat_buffed_color; else - return uRed; + return ui_character_stat_debuffed_color; } //----- (004908A8) -------------------------------------------------------- @@ -5978,7 +5760,7 @@ { if ( pConditions[uCondition] && (uTime < pConditions[uCondition]) ) { - pConditions[uCondition]=0i64; + pConditions[uCondition] = 0i64; return true; } else @@ -6396,7 +6178,7 @@ { pMouse->RemoveHoldingItem(); pGUIWindow_CurrentMenu->Release(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; _42777D_CastSpell_UseWand_ShootArrow(scroll_id, player_num - 1, 0x85u, 1, 0); @@ -6762,7 +6544,7 @@ v23 = pParty->pPlayers;//[0].pInventoryItems; do { - v24 = v23->pInventoryItems; + v24 = v23->pInventoryItemList; v25 = 138; do { @@ -6851,7 +6633,7 @@ return v4 >= pValue; } while ( !v3->HasItemEquipped(v26) - || *(int *)&v3->pInventoryItems[*(int *)v27-1] != pValue ) + || *(int *)&v3->pInventoryItemList[*(int *)v27-1] != pValue ) { v26 = (ITEM_EQUIP_TYPE)((int)v26 + 1); v27 += 4; @@ -6948,7 +6730,7 @@ return false; case VAR_PlayerItemInHands: v15 = 0; - v16 = v3->pInventoryItems; + v16 = v3->pInventoryItemList; break; case VAR_FixedGold: v4 = pParty->uNumGold; @@ -7333,7 +7115,7 @@ v9 = NULL; for (int i = 0; i < 138; i++) { - v9 = &this->pInventoryItems[i]; + v9 = &this->pInventoryItemList[i]; if (v9->uItemID == ITEM_LICH_JAR_EMPTY) break; } @@ -8215,14 +7997,6 @@ v27->uReputation = 10000; } } -// 506568: using guessed type int dword_506568; -// 507948: using guessed type char bFlashHistoryBook; -// 507949: using guessed type char bFlashAutonotesBook; -// 50794A: using guessed type char bFlashQuestBook; -// 72371C: using guessed type int dword_72371C[]; -// 723E80: using guessed type int dword_723E80_award_related[]; - - //----- (0044B9C4) -------------------------------------------------------- @@ -8478,7 +8252,7 @@ pPlayers[v4 + 1]->PlaySound(SPEECH_96, 0); return true; case VAR_PlayerItemInHands: - v15 = this->pInventoryIndices; + v15 = this->pInventoryMatrix; break; case VAR_FixedGold: if ( (unsigned int)pValue > pParty->uNumGold ) @@ -8839,7 +8613,7 @@ } for (v3 = 1; v3 < 126; v3++) { - if ( *(&this->pInventoryItems[pInventoryIndices[v3] - 1].uItemID) == pValue ) + if ( *(&this->pInventoryItemList[pInventoryMatrix[v3] - 1].uItemID) == pValue ) { RemoveItemAtInventoryIndex(v3); return true; @@ -8853,6 +8627,9 @@ return false; } } + + //assert(false); + return false; } // 5B65C4: using guessed type int dword_5B65C4; // 5B65CC: using guessed type int dword_5B65CC; @@ -8873,42 +8650,9 @@ int v10; // [sp+34h] [bp-8h]@1 int *v11; // [sp+38h] [bp-4h]@1 - static unsigned char byte_4E8398[200] = // 4E8398 - { - 1, // EQUIP_OFF_HAND - 1, // EQUIP_MAIN_HAND - 2, // EQUIP_BOW - 3, // EQUIP_ARMOUR - 0, // EQUIP_SHIELD - 4, // EQUIP_HELMET - 5, // EQUIP_BELT - 6, // EQUIP_CLOAK - 7, // EQUIP_GAUNTLETS - 8, // EQUIP_BOOTS - 10, // EQUIP_RING - 9, // EQUIP_AMULET - 1, // EQUIP_WAND - 0, // EQUIP_REAGENT - 0, // EQUIP_POTION - 0, // EQUIP_SPELL_SCROLL - 0, // EQUIP_BOOK - 0, // EQUIP_MESSAGE_SCROLL - 0, // EQUIP_GOLD - 0, // EQUIP_GEM - 0, // EQUIP_NONE - // ??? - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, - 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0 - }; _this.Reset(); - v2 = byte_4E8398[uEquipType]; + v2 = pEquipTypeToBodyAnchor[uEquipType]; v3 = pPlayers[uActiveCharacter]; v11 = (int *)&v3->pEquipment.pIndices[v2]; v4 = *v11; @@ -8926,11 +8670,11 @@ } else { - v7 = v3->FindFreeInventorySlot(); + v7 = v3->FindFreeInventoryListSlot(); if (v7 >= 0) { pParty->pPickedItem.uBodyAnchor = v2 + 1; - memcpy(&v3->pInventoryItems[v7], &pParty->pPickedItem, sizeof(v3->pInventoryItems[v7])); + memcpy(&v3->pInventoryItemList[v7], &pParty->pPickedItem, sizeof(v3->pInventoryItemList[v7])); *v11 = v7 + 1; pMouse->RemoveHoldingItem(); } @@ -8985,46 +8729,36 @@ Player *v2; // edx@3 int v3; // ecx@3 Player **pPlayers; // esi@8 - unsigned int v5; // ecx@8 + //bool item_flag; Player *v6; // edx@9 - if ( a1 < 1 || a1 > 4 ) - { - if ( !a1 ) - { - pPlayers = &::pPlayers[1]; - v5 = 604; - while ( 1 ) - { - result = Player_has_item(v5, *pPlayers, 0); - if ( !result ) - break; - result = v6->pEquipment.uArmor; - if ( !result ) - break; - result *= 9; - if ( *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v5 ) - break; - ++pPlayers; - if ( (signed int)pPlayers >= (signed int)&qword_A750D8 ) - goto LABEL_13; - } - } - goto LABEL_6; - } - result = Player_has_item(604u, ::pPlayers[a1], 0); - if ( !result - || (result = v2->pEquipment.uArmor) == 0 - || (result *= 9, *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v3) ) - { -LABEL_6: - LOBYTE(result) = 0; - return result; - } -LABEL_13: - LOBYTE(result) = 1; - return result; -} + //if ( a1 < 1 || a1 > 4 ) + //{ + //if ( !a1 ) + //{ + //pPlayers = &::pPlayers[1]; + //v5 = 604; + //while ( 1 ) + assert ( a1 > 0 && a1 < 5 ); + for ( uint i = 1; i < 5; ++i ) + { + //item_flag = Player_has_item(604, *pPlayers, 0); + if ( !Player_has_item(604, ::pPlayers[i], 0) ) + return false; + //__debugbreak(); // player.cpp(8748): warning C4700: uninitialized local variable 'v6' used + //result = ::pPlayers[i]->pEquipment.uArmor; + if ( !::pPlayers[i]->pEquipment.uArmor ) + return false; + //result *= 9; + if (::pPlayers[i]->pEquippedItems[::pPlayers[i]->pEquipment.uArmor].uItemID != 604 ) + return false; + //++pPlayers; + //if ( (signed int)pPlayers >= (signed int)&qword_A750D8 ) + //return true; + } + return true; + } + //----- (0043EE15) -------------------------------------------------------- bool __fastcall Player_has_item(unsigned int uItemID, Player *pPlayer, char a3) { @@ -9032,9 +8766,9 @@ { for ( uint i = 0; i < 126; ++i ) { - if ( pPlayer->pInventoryIndices[i] > 0 ) - { - if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pInventoryIndices[i] - 1].uItemID == uItemID ) + if ( pPlayer->pInventoryMatrix[i] > 0 ) + { + if ( (unsigned int)pPlayer->pInventoryItemList[pPlayer->pInventoryMatrix[i] - 1].uItemID == uItemID ) return true; } } @@ -9042,7 +8776,7 @@ { if ( pPlayer->pEquipment.pIndices[i] ) { - if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pEquipment.pIndices[i] - 1].uItemID == uItemID ) + if ( (unsigned int)pPlayer->pInventoryItemList[pPlayer->pEquipment.pIndices[i] - 1].uItemID == uItemID ) return true; } } @@ -9460,7 +9194,7 @@ if ( v45->HasEnchantedItemEquipped(69) ) v77 >>= 1; if ( v45->HasItemEquipped(EQUIP_ARMOUR) - && *(_DWORD *)&v45->pInventoryItems[v45->pEquipment.uArmor-1] == 504 ) + && *(_DWORD *)&v45->pInventoryItemList[v45->pEquipment.uArmor-1] == 504 ) v77 >>= 1; v75 = 0; v47 = (int)&v45->pEquipment; @@ -9613,8 +9347,8 @@ if ( v38 == OBJECT_Player && !qword_A750D8 ) { qword_A750D8 = 256i64; - word_A750E0 = 44; - word_A750E2 = uActorID + 1; + PlayerSpeechID = SPEECH_44; + uSpeakingCharacter = uActorID + 1; } return; } @@ -9683,7 +9417,7 @@ *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; *((int *)pGUIWindow_Settings->ptr_1C + 3) = v6 - 1; *((short *)pGUIWindow_Settings->ptr_1C + 3) = a4; - ptr_50C9A4 = (ItemGen *)&v0->pInventoryItems[v6-1]; + ptr_50C9A4 = (ItemGen *)&v0->pInventoryItemList[v6-1]; unk_50C9A0 = 0; if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; @@ -9702,7 +9436,7 @@ { if ( !v8 ) return; - memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem)); + memcpy(&pParty->pPickedItem, &v0->pInventoryItemList[v8-1], sizeof(pParty->pPickedItem)); v0->RemoveItemAtInventoryIndex(a4); v9 = pParty->pPickedItem.uItemID; pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); @@ -9711,7 +9445,7 @@ v13 = v8; if ( v8 ) { - a2.y = (LONG)&v0->pInventoryItems[v8-1]; + a2.y = (LONG)&v0->pInventoryItemList[v8-1]; memcpy(&this_, (const void *)a2.y, sizeof(this_)); v0->RemoveItemAtInventoryIndex(a4); pX = v0->AddItem2(a4, &pParty->pPickedItem); @@ -9720,7 +9454,7 @@ pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem); if ( !pX ) { - v0->PutItemArInventoryIndex(&this_, v13 - 1, a4); + v0->PutItemArInventoryIndex(this_.uItemID, v13 - 1, a4); memcpy((void *)a2.y, &this_, sizeof(ItemGen)); return; } @@ -9734,7 +9468,7 @@ pX = v10; if ( v10 || (v10 = v0->AddItem(-1, pParty->pPickedItem.uItemID), (pX = v10) != 0) ) { - memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u); + memcpy(&v0->pInventoryItemList[v10-1], &pParty->pPickedItem, 0x24u); pMouse->RemoveHoldingItem(); } }
--- a/Player.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Player.h Tue Aug 06 00:56:33 2013 +0400 @@ -294,11 +294,12 @@ struct LloydBeacon { unsigned __int64 uBeaconTime; - int field_8; - int field_C; - int field_10; - int field_14; - int field_18; + int PartyPos_X; + int PartyPos_Y; + int PartyPos_Z; + __int16 PartyRot_X; + __int16 PartyRot_Y; + int SaveFileID; }; #pragma pack(pop) @@ -540,14 +541,14 @@ int GetDisarmTrap(); char GetLearningPercent(); bool CanFitItem(unsigned int uSlot, unsigned int uItemID); - int FindFreeInventorySlot(); + int FindFreeInventoryListSlot(); int CreateItemInInventory(unsigned int uSlot, unsigned int uItemID); int HasSkill(unsigned int uSkillType); - int WearItem(unsigned int uItemID); + void WearItem(unsigned int uItemID); int AddItem(int uSlot, unsigned int uItemID); int AddItem2(int uSlot, ItemGen *Src); - int CreateItemInInventory2(unsigned int uSlot, ItemGen *Src); - int PutItemArInventoryIndex(ItemGen *item, int item_id, int uSlot); + int CreateItemInInventory2(unsigned int index, ItemGen *Src); + void PutItemArInventoryIndex(int uItemID, int itemListPos, int uSlot); void RemoveItemAtInventoryIndex(unsigned int uSlot); bool CanAct(); bool CanSteal(); @@ -710,13 +711,13 @@ { struct { - ItemGen pInventoryItems[126]; + ItemGen pInventoryItemList[126]; ItemGen pEquippedItems[12]; }; ItemGen pOwnItems[138]; }; - int pInventoryIndices[126]; + int pInventoryMatrix[126]; __int16 sResFireBase; __int16 sResAirBase; __int16 sResWaterBase;
--- a/Render.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Render.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -25,7 +25,6 @@ #include "Time.h" #include "Game.h" #include "LightmapBuilder.h" -#include "stru220.h" #include "ObjectList.h" #include "SpriteObject.h" #include "DecorationList.h" @@ -51,22 +50,11 @@ int uNumSpritesDrawnThisFrame; // weak RenderVertexSoft array_507D30[50]; -RenderVertexSoft array_508690[50]; -RenderVertexSoft array_508FF0[50]; -RenderVertexSoft array_509950[50]; -RenderVertexSoft array_50A2B0[50]; RenderVertexSoft array_50AC10[50]; - RenderVertexSoft array_73D150[20]; RenderVertexD3D3 d3d_vertex_buffer[50]; -RenderVertexSoft *ptr_801A04; -RenderVertexSoft *ptr_801A08; - -RenderVertexSoft pVerticesSR_801A10[384]; -RenderVertexSoft pVerticesSR_806210[384]; - void SetBillboardBlendOptions(RenderBillboardD3D::OpacityType a1); /* 384 */ @@ -221,1475 +209,10 @@ return result; } -//----- (00487389) -------------------------------------------------------- -void Render::ExecOutdoorDrawSW() -{ - unsigned __int16 *v0; // ebx@1 - unsigned int v1; // esi@1 - stru148 *v2; // eax@1 - Span *v3; // edi@6 - stru148 *v4; // esi@9 - Texture *v5; // ebp@10 - int v6; // esi@16 - unsigned int v7; // edx@16 - char *v8; // ecx@17 - unsigned int v9; // edi@22 - int v10; // eax@26 - int v11; // eax@27 - unsigned int v12; // ebp@32 - Span *v13; // esi@33 - int v14; // ecx@37 - int v15; // eax@40 - Texture *v16; // ebp@51 - //unsigned int v17; // eax@51 - int v18; // eax@54 - char v19; // al@56 - unsigned int v20; // eax@57 - int v21; // ecx@57 - unsigned int v22; // eax@57 - stru149 *v23; // eax@65 - int v24; // eax@67 - ODMFace *v25; // eax@78 - signed int v26; // edx@79 - signed int v27; // ecx@79 - unsigned int v28; // eax@106 - unsigned int v29; // ebp@117 - Span *v30; // esi@118 - unsigned int v31; // ST04_4@124 - int v33; // [sp+18h] [bp-44h]@80 - signed int v34; // [sp+1Ch] [bp-40h]@3 - signed int v35; // [sp+20h] [bp-3Ch]@79 - Span **v36; // [sp+24h] [bp-38h]@4 - unsigned int v37; // [sp+28h] [bp-34h]@1 - unsigned __int16 *a1; // [sp+2Ch] [bp-30h]@1 - int a1a; // [sp+2Ch] [bp-30h]@26 - unsigned int a1b; // [sp+2Ch] [bp-30h]@116 - char v41; // [sp+30h] [bp-2Ch]@57 - - v0 = pRenderer->pTargetSurface; - v1 = pOutdoorCamera->numStru148s; - a1 = pRenderer->pTargetSurface; - v2 = array_77EC08.data(); - v37 = pOutdoorCamera->numStru148s; - if ( !(pParty->uFlags & 2) ) - { - v1 = uNumElementsIn80AA28; - v2 = ptr_80AA28[0]; - v37 = uNumElementsIn80AA28; - } - v34 = 0; - if ( (signed int)v1 > 0 ) - { - v36 = &v2->prolly_head; - do - { - if ( pParty->uFlags & 2 ) - v3 = *v36; - else - v3 = ptr_80AA28[v34]->prolly_head; - if ( v3 ) - { - v4 = v3->pParent; - if ( v4 ) - { - v5 = v4->pTexture; - if ( v5 ) - { - if ( v3->field_8 >= (signed int)pViewport->uViewportTL_X || v3->field_C != pViewport->uViewportTL_X ) - { - LOBYTE(v4->field_32) |= 2u; - v14 = *(int *)&v4->flags; - if ( v14 & 0x10 && v4->field_59 != 5 ) - { - dword_80AA20 = (v4->terrain_grid_z - 64) << 25; - dword_80AA1C = dword_80AA20 + 0x1FF0000; - dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; - dword_80AA18 = dword_80AA14 - 0x1FF0000; - byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( - v4->terrain_grid_z, - v4->terrain_grid_x - 1) >> 9) & 1; - if ( *(int *)&v4->flags & 2 || (v15 = *(int *)&v4->flags, BYTE1(v15) & 1) ) - { - if ( *(int *)&v4->flags & 2 ) - { - while ( 1 ) - { - if ( pOutdoorCamera->outdoor_no_wavy_water ) - sr_sub_48408A_prolly_odm_water_no_waves(v3); - else - sr_sub_485407_prolly_odm_water_wavy(v3); - v3->field_E = LOWORD(unnamed_6BE060[1]); - if ( v4->prolly_tail == v3 ) - break; - v3 = v3->pNext; - } - } - else - { - while ( 1 ) - { - v16 = v4->pTexture; - v4->pTexture = pBitmaps_LOD->LoadTexturePtr("wtrtyl"); - if ( pOutdoorCamera->outdoor_no_wavy_water ) - sr_sub_48408A_prolly_odm_water_no_waves(v3); - else - sr_sub_485407_prolly_odm_water_wavy(v3); - v18 = v4->terrain_grid_z - 64; - v4->pTexture = v16; - dword_80AA20 = v18 << 25; - dword_80AA1C = (v18 << 25) + 0x1FF0000; - dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; - dword_80AA18 = dword_80AA14 - 0x1FF0000; - byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( - v4->terrain_grid_z, - v4->terrain_grid_x - 1) >> 9) & 1; - sr_sub_484442(v3); - v3->field_E = LOWORD(unnamed_6BE060[1]); - if ( v4->prolly_tail == v3 ) - break; - v3 = v3->pNext; - } - } - } - else - { - while ( sr_sub_48408A_prolly_odm_water_no_waves(v3) ) - { - v3->field_E = LOWORD(unnamed_6BE060[1]); - if ( v4->prolly_tail == v3 ) - break; - v3 = v3->pNext; - } - } - } - else - { - v19 = v4->field_59; - if ( v19 != 5 ) - { - if ( v14 & 2 ) - { - while ( 1 ) - { - v28 = pBitmaps_LOD->LoadTexture("wtrtyla"); - v4->pTexture = (Texture *)(v28 != -1 ? &pBitmaps_LOD->pTextures[v28] : 0); - if ( !sr_sub_4847EB(v3) ) - break; - v4->pTexture = v5; - if ( !sr_sub_484442(v3) ) - break; - v3->field_E = LOWORD(unnamed_6BE060[1]); - if ( v4->prolly_tail == v3 ) - break; - v3 = v3->pNext; - v5 = v4->pTexture; - } - } - else - { - if ( v19 == 1 ) - { - dword_80AA20 = (v4->terrain_grid_z - 64) << 25; - dword_80AA1C = dword_80AA20 + 33488896; - dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; - dword_80AA18 = dword_80AA14 - 33488896; - byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( - v4->terrain_grid_z, - v4->terrain_grid_x - 1) >> 9) & 1; - while ( 1 ) - { - if ( !sr_sub_4847EB(v3) ) - sr_sub_48585C_mb_DrawSpan(v3, &pRenderer->pTargetSurface[v3->field_8 + 640 * v3->field_A], 0); - v3->field_E = LOWORD(unnamed_6BE060[1]); - if ( v4->prolly_tail == v3 ) - break; - v3 = v3->pNext; - } - } - } - goto LABEL_14; - } - v4->ptr_38 = (stru149 *)&v41; - v4->_479295(); - v20 = GetTickCount(); - v21 = *(int *)&v4->flags; - v22 = v20 >> 3; - if ( BYTE1(v21) & 4 ) - { - v4->sTextureDeltaV -= v22 & v4->pTexture->uHeightMinus1; - } - else - { - if ( BYTE1(v21) & 8 ) - v4->sTextureDeltaV += v22 & v4->pTexture->uHeightMinus1; - } - if ( BYTE1(v21) & 0x10 ) - { - v4->sTextureDeltaU -= v22 & v4->pTexture->uWidthMinus1; - } - else - { - if ( BYTE1(v21) & 0x20 ) - v4->sTextureDeltaU += v22 & v4->pTexture->uWidthMinus1; - } - v23 = v4->ptr_38; - v4->field_52 = 32; - v4->field_5A = 5; - if ( (double)abs(v23->field_C) > 52428.8 ) - { - v4->field_52 = 8; - v4->field_5A = 3; - } - v24 = *(int *)&v4->flags; - if ( !(v24 & 0x10000) ) - { - if ( !(v24 & 2) ) - { - v25 = v4->pODMFace; - if ( v25->uPolygonType == 1 ) - { - v26 = v25->pTextureUIDs[0]; - dword_80AA1C = v26; - dword_80AA20 = v26; - v27 = v25->pTextureVIDs[0]; - dword_80AA14 = v27; - dword_80AA18 = v27; - v35 = 1; - if ( v25->uNumVertices > 1u ) - { - v33 = (int)&v25->pTextureVIDs[1]; - do - { - if ( dword_80AA20 > *(short *)(v33 - 40) ) - dword_80AA20 = *(short *)(v33 - 40); - if ( v26 < *(short *)(v33 - 40) ) - { - v26 = *(short *)(v33 - 40); - dword_80AA1C = *(short *)(v33 - 40); - } - if ( dword_80AA18 > *(short *)v33 ) - dword_80AA18 = *(short *)v33; - if ( v27 < *(short *)v33 ) - { - v27 = *(short *)v33; - dword_80AA14 = *(short *)v33; - } - ++v35; - v33 += 2; - } - while ( v35 < v25->uNumVertices ); - v0 = a1; - } - dword_80AA20 = (dword_80AA20 + v4->sTextureDeltaU) << 16; - dword_80AA1C = ((v26 + v4->sTextureDeltaU) << 16) - 65536; - dword_80AA18 = (dword_80AA18 + v4->sTextureDeltaV) << 16; - dword_80AA14 = ((v27 + v4->sTextureDeltaV) << 16) - 65536; - } - while ( 1 ) - { - if ( !sr_sub_482E07(v3, v0) ) - sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); - v3->field_E = LOWORD(unnamed_6BE060[1]); - if ( v4->prolly_tail == v3 ) - break; - v3 = v3->pNext; - } - goto LABEL_14; - } - while ( 1 ) - { -LABEL_74: - if ( !sr_sub_4839BD(v3, v0) ) - sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); - v3->field_E = LOWORD(unnamed_6BE060[1]); - if ( v4->prolly_tail == v3 ) - break; - v3 = v3->pNext; - } - goto LABEL_14; - } - if ( v24 & 2 ) - goto LABEL_74; - while ( 1 ) - { - if ( !sr_sub_482A94(v3) ) - sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); - v3->field_E = LOWORD(unnamed_6BE060[1]); - if ( v4->prolly_tail == v3 ) - break; - v3 = v3->pNext; - } - } - } - else - { - v3->field_E = LOWORD(unnamed_6BE060[1]); - } - } - } - } -LABEL_14: - ++v34; - LOWORD(v2) = v34; - v36 += 67; - } - while ( v34 < (signed int)v37 ); - } - if ( pParty->uFlags & 2 ) - { - v6 = pOutdoorCamera->numStru148s; - v7 = 0; - uNumElementsIn80AA28 = 0; - if ( pOutdoorCamera->numStru148s > 0 ) - { - v8 = (char *)&array_77EC08[0].flags; - do - { - v2 = *(stru148 **)v8; - if ( (unsigned int)v2 & 0x20000 ) - { - ++v7; - *(int *)v8 = (unsigned int)v2 & 0xFFFDFFFF; - LOWORD(v2) = (short)v8 - 48; - *(&uNumElementsIn80AA28 + v7) = (unsigned int)(v8 - 48); - } - v8 += 268; - --v6; - } - while ( v6 ); - uNumElementsIn80AA28 = v7; - } - } - v9 = pOutdoorCamera->uNumSpans; - unnamed_6BE060[0] = pOutdoorCamera->uNumSpans; - if (pOutdoorCamera->numStru148s >= 1999) - return; - - array_77EC08[1999]._48607B(&stru_8019C8); - array_77EC08[1999].ptr_38->sky_48694B(); - - if (pOutdoor->uMainTile_BitmapID == -1) - { - array_77EC08[1999].pTexture = nullptr; - return; - } - else - array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uMainTile_BitmapID); - array_77EC08[1999].dimming_level = 23 - (-20 * pOutdoor->vSunlight.z >> 16); - if ( array_77EC08[1999].dimming_level > 20 ) - array_77EC08[1999].dimming_level = 20; - v10 = stru_5C6E00->Sin(pIndoorCamera->sRotationX); - array_77EC08[1999].v_18.y = 0; - array_77EC08[1999].v_18.x = v10; - array_77EC08[1999].v_18.z = stru_5C6E00->Cos(pIndoorCamera->sRotationX); - array_77EC08[1999].field_24 = 2048 - (pIndoorCamera->pos.z << 16); - a1a = (signed __int64)((double)(pIndoorCamera->pos.z * pOutdoorCamera->int_fov_rad) - / ((double)pOutdoorCamera->int_fov_rad + 8192.0) - + (double)pViewport->uScreenCenterY); - cos((double)pIndoorCamera->sRotationX * 0.0030664064); - sin((double)pIndoorCamera->sRotationX * 0.0030664064); - array_77EC08[1999]._48607B(&stru_8019C8); - array_77EC08[1999].ptr_38->sky_48694B(); - - if (pOutdoor->uSky_TextureID == -1) - { - array_77EC08[1999].pTexture = nullptr; - return; - } - else - array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uSky_TextureID); - array_77EC08[1999].dimming_level = 0; - v11 = stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16); - array_77EC08[1999].v_18.y = 0; - array_77EC08[1999].v_18.x = -v11; - array_77EC08[1999].v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16); - LOWORD(v2) = 224 * LOWORD(pMiscTimer->uTotalGameTimeElapsed); - array_77EC08[1999].field_24 = 0x2000000u; - array_77EC08[1999].sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed; - array_77EC08[1999].sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; - if ( day_attrib & DAY_ATTRIB_FOG - && (LOWORD(v2) = LOWORD(pParty->uCurrentHour), pParty->uCurrentHour >= 5) - && pParty->uCurrentHour < 0x15 - || bUnderwater ) - { - v2 = (stru148 *)*(short *)PaletteManager::Get_Mist_or_Red_LUT(array_77EC08[1999].pTexture->palette_id2, 31, 1); - a1b = (unsigned int)v2; - if ( (signed int)v9 <= 0 ) - return; - v29 = v9; - while ( 1 ) - { - v30 = &pSpans[v29 - 1]; - v2 = (stru148 *)v30->field_E; - if ( v2 != (stru148 *)unnamed_6BE060[1] ) - { - LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); - if ( v30->field_8 >= (signed int)pViewport->uViewportTL_X ) - goto LABEL_124; - if ( v30->field_C == pViewport->uViewportTL_X ) - { - v30->field_E = LOWORD(unnamed_6BE060[1]); - } - else - { - v30->field_8 = LOWORD(pViewport->uViewportTL_X); - v30->field_C -= LOWORD(pViewport->uViewportTL_X); - if ( v30->field_C >= 0 ) - { -LABEL_124: - v31 = v30->field_C; - v30->pParent = &array_77EC08[1999]; - fill_pixels_fast( - a1b, - &pRenderer->pTargetSurface[v30->field_8 + pRenderer->uTargetSurfacePitch * v30->field_A], - v31); - j_memset32(-65536, &pRenderer->pActiveZBuffer[v30->field_8 + 640 * v30->field_A], v30->field_C); - goto LABEL_125; - } - LOWORD(v2) = LOWORD(unnamed_6BE060[1]); - v30->field_E = LOWORD(unnamed_6BE060[1]); - } - } -LABEL_125: - --v29; - --v9; - if ( !v9 ) - return; - } - } - if ( (signed int)v9 > 0 ) - { - v12 = v9; - do - { - v13 = &pSpans[v12 - 1]; - v2 = (stru148 *)v13->field_E; - if ( v2 != (stru148 *)unnamed_6BE060[1] ) - { - LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); - if ( v13->field_8 >= (signed int)pViewport->uViewportTL_X ) - goto LABEL_109; - if ( v13->field_C != pViewport->uViewportTL_X ) - { - v13->field_8 = LOWORD(pViewport->uViewportTL_X); - v13->field_C -= LOWORD(pViewport->uViewportTL_X); - if ( v13->field_C >= 0 ) - { -LABEL_109: - if ( pOutdoorCamera->bNoSky ) - { - const_1_0(); - } - else - { - v13->pParent = &array_77EC08[1999]; - if ( !Render::DrawSkySW(v13, &array_77EC08[1999], a1a) ) - j_memset32(-65536, &pRenderer->pActiveZBuffer[v13->field_8 + 640 * v13->field_A], v13->field_C); - } - } - LOWORD(v2) = LOWORD(unnamed_6BE060[1]); - v13->field_E = LOWORD(unnamed_6BE060[1]); - goto LABEL_114; - } - v13->field_E = LOWORD(unnamed_6BE060[1]); - } -LABEL_114: - --v12; - --v9; - } - while ( v9 ); - } -} - -//----- (00485044) -------------------------------------------------------- -int Render::DrawSkySW(Span *a1, stru148 *a2, int a3) -{ - stru148 *v3; // esi@1 - Span *v4; // edi@1 - float v5; // ST2C_4@1 - signed int result; // eax@2 - int v7; // ST40_4@3 - stru149 *v8; // eax@3 - int v9; // ebx@3 - int v10; // ecx@3 - int v11; // edx@3 - int v12; // eax@3 - int v13; // ST28_4@5 - int v14; // eax@5 - signed __int64 v15; // qtt@11 - int v16; // ST28_4@11 - int v17; // eax@11 - signed int v18; // ecx@11 - int v19; // ST40_4@11 - int v20; // ST3C_4@11 - int v21; // ST30_4@11 - void *v22; // eax@11 - Texture *v23; // esi@11 - int v24; // ecx@11 - unsigned int v25; // esi@11 - int v26; // edi@11 - unsigned __int16 *v27; // eax@11 - int *v28; // ebx@12 - int v29; // edx@13 - unsigned __int16 v30; // cx@13 - int v31; // edx@14 - unsigned __int16 v32; // cx@14 - unsigned __int8 v33; // sf@15 - unsigned __int8 v34; // of@15 - double v35; // [sp+14h] [bp-38h]@1 - int v36; // [sp+18h] [bp-34h]@3 - signed int v37; // [sp+18h] [bp-34h]@11 - int v38; // [sp+1Ch] [bp-30h]@3 - signed int v39; // [sp+1Ch] [bp-30h]@11 - int v40; // [sp+20h] [bp-2Ch]@3 - void *v41; // [sp+20h] [bp-2Ch]@11 - int v42; // [sp+24h] [bp-28h]@3 - unsigned __int8 *v43; // [sp+24h] [bp-28h]@11 - int v44; // [sp+28h] [bp-24h]@11 - int v45; // [sp+2Ch] [bp-20h]@3 - signed int v46; // [sp+30h] [bp-1Ch]@3 - __int16 v47; // [sp+30h] [bp-1Ch]@11 - signed int v48; // [sp+34h] [bp-18h]@3 - int v49; // [sp+34h] [bp-18h]@11 - int v50; // [sp+38h] [bp-14h]@3 - unsigned __int16 *v51; // [sp+38h] [bp-14h]@11 - int v52; // [sp+3Ch] [bp-10h]@4 - int a1a; // [sp+40h] [bp-Ch]@3 - int v54; // [sp+44h] [bp-8h]@3 - int v55; // [sp+48h] [bp-4h]@3 - int v56; // [sp+54h] [bp+8h]@11 - int *v57; // [sp+54h] [bp+8h]@11 - - v3 = a2; - v4 = a1; - v5 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5 / tan(0.6457717418670654) + 0.5; - v35 = v5 + 6.7553994e15; - if ( LODWORD(v35) ) - { - v55 = 65536 / SLODWORD(v35); - v7 = 65536 / SLODWORD(v35) * (a3 - v4->field_A); - v8 = v3->ptr_38; - v42 = ((unsigned __int64)(v3->ptr_38->field_14 * (signed __int64)v7) >> 16) + v8->field_C; - v40 = ((unsigned __int64)(v8->field_20 * (signed __int64)v7) >> 16) + v3->ptr_38->field_18; - v38 = pOutdoorCamera->camera_rotation_y_int_sine; - HIDWORD(v35) = pOutdoorCamera->camera_rotation_y_int_cosine; - v45 = v4->field_C; - v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v7) >> 16) + v3->v_18.x; - v10 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); - v48 = 0; - v50 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); - v46 = -v3->field_24; - v11 = v4->field_A - 1; - v54 = v11; - v12 = 65536 / SLODWORD(v35) * (a3 - v11); - a1a = 65536 / SLODWORD(v35) * (a3 - v11); - while ( 1 ) - { - v52 = v9; - if ( v9 ) - { - v13 = abs(v46 >> 14); - v14 = abs(v9); - v11 = v54; - v10 = v50; - if ( v13 <= v14 ) - break; - v12 = a1a; - } - if ( v11 <= (signed int)pViewport->uViewportTL_Y ) - break; - v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v12) >> 16) + v3->v_18.x; - --v54; - a1a += v55; - v12 = a1a; - v11 = v54; - v48 = 1; - } - if ( v48 ) - v52 = ((unsigned __int64)(v3->v_18.z * (signed __int64)(v55 * (a3 + (signed int)v4->field_A - 2 * v11))) >> 16) - + v3->v_18.x; - LODWORD(v15) = v46 << 16; - HIDWORD(v15) = v46 >> 16; - v16 = v42 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v10) >> 16); - v17 = v40 + ((unsigned __int64)(v3->ptr_38->field_1C * (signed __int64)v10) >> 16); - v18 = v15 / v52; - v43 = v3->pTexture->pLevelOfDetail0_prolly_alpha_mask; - v19 = v3->sTextureDeltaU + ((signed int)((unsigned __int64)(v16 * v15 / v52) >> 16) >> 3); - v56 = v15 / v52; - v20 = v3->sTextureDeltaV + ((signed int)((unsigned __int64)(v17 * v15 / v52) >> 16) >> 3); - v21 = (unsigned __int64)(v55 * (signed __int64)v56) >> 16; - v39 = (signed int)((unsigned __int64)(v21 * (signed __int64)v38) >> 16) >> 3; - v37 = (signed int)((unsigned __int64)(v21 * (signed __int64)v36) >> 16) >> 3; - v22 = sr_sub_47C178(v18, v3, 0, 1); - v23 = v3->pTexture; - v41 = v22; - v47 = 16 - v23->uWidthLn2; - v44 = v23->uTextureWidth - 1; - v49 = (v23->uTextureHeight << 16) - 65536; - v24 = v4->field_8; - v51 = &pRenderer->pTargetSurface[v24 + pRenderer->uTargetSurfacePitch * v4->field_A]; - v57 = &pRenderer->pActiveZBuffer[v24 + 640 * v4->field_A]; - v25 = v19; - v26 = v20; - v27 = v51; - if ( !(v45 & 1) ) - goto LABEL_15; - --v45; - v27 = v51 - 1; - v28 = v57; - ++v57; - while ( 1 ) - { - *v28 = -65536; - v31 = v44 & (v25 >> 16); - v27 += 2; - v25 += v39; - v32 = *((short *)v41 + *(&v43[v31] + ((v49 & (unsigned int)v26) >> v47))); - v26 += v37; - *(v27 - 1) = v32; -LABEL_15: - v34 = __OFSUB__(v45, 2); - v33 = v45 - 2 < 0; - v45 -= 2; - if ( v33 ^ v34 ) - break; - v29 = v44 & (v25 >> 16); - v25 += v39; - v30 = *((short *)v41 + *(&v43[v29] + ((v49 & (unsigned int)v26) >> v47))); - v26 += v37; - v28 = v57; - *v27 = v30; - v57 += 2; - v28[1] = -65536; - } - result = 1; - } - else - { - result = 0; - } - return result; -} - -//----- (0047F5C6) -------------------------------------------------------- -float Render::DrawBezierTerrain() -{ - //__debugbreak();Ritor1: it's temporarily - //return 0; - - unsigned int pDirectionIndicator1; // ebx@1 - unsigned int pDirectionIndicator2; // edi@1 - unsigned int v2; // eax@1 - int v3; // eax@3 - int v4; // edi@3 - int v5; // ebx@3 - int v6; // esi@3 - unsigned int v7; // eax@3 - int v8; // eax@4 - unsigned int v9; // eax@6 - int v10; // eax@7 - //int v11; // ebx@9 - //int v12; // edi@9 - int v13; // eax@21 - int v14; // eax@31 - int v15; // edi@33 - int v16; // eax@34 - int v17; // edx@34 - int v18; // ebx@34 - int v19; // eax@36 - int v20; // eax@39 - int v21; // ecx@43 - //char v22; // zf@44 - int v23; // ecx@47 - //int v24; // edi@52 - int v25; // eax@54 - int v26; // ecx@54 - int v27; // eax@56 - int v28; // edx@60 - int v29; // ecx@61 - int v30; // ecx@64 - int v31; // ecx@68 - int v32; // eax@70 - //int v33; // ecx@71 - int v34; // eax@73 - int v35; // ecx@77 - int v36; // ecx@81 - int v37; // ecx@86 - int v38; // eax@88 - int v39; // ecx@88 - int v40; // eax@90 - int v41; // edx@94 - //int v42; // ecx@95 - int v43; // ecx@98 - int v44; // ecx@102 - int v45; // eax@104 - int v46; // eax@107 - int v47; // ecx@111 - int v48; // ecx@115 - int v49; // edi@120 - int v50; // eax@122 - int v51; // ecx@122 - int v52; // eax@124 - int v53; // edx@128 - int v54; // ecx@129 - int v55; // ecx@132 - int v56; // eax@139 - int v57; // ecx@140 - int v58; // eax@142 - int v59; // ecx@146 - //int v60; // ecx@147 - int v61; // ecx@150 - int v62; // ecx@155 - int v63; // eax@157 - int v64; // ecx@157 - int v65; // eax@159 - int v66; // edx@163 - int v67; // ecx@164 - int v68; // ecx@167 - //int v69; // eax@173 - int v70; // edi@178 - //int v71; // eax@178 - //int v72; // ecx@178 - //int x; // ebx@180 - //int v74; // eax@182 - //int v75; // eax@184 - IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 - int uStartZ; // ecx@184 - int v79; // ebx@185 - int v127; // esi@185 - int v86; // edi@196 - //int v87; // eax@196 - //int v88; // ecx@196 - //int v89; // eax@198 - //int v90; // ecx@200 - int v92; // ebx@203 - //int v93; // ST08_4@204 - int v97; // ST08_4@204 - float result; // eax@212 - //struct - //{ - int v106; // [sp+Ch] [bp-68h]@191 - int v103; // [sp+10h] [bp-64h]@190 - int v104; // [sp+12h] [bp-62h]@190 - //} v102; - int v105; // [sp+1Ch] [bp-58h]@1 - int v107; // [sp+20h] [bp-54h]@3 - int uEndZ; // [sp+24h] [bp-50h]@3 - int v108; // [sp+28h] [bp-4Ch]@9 - int v109; // [sp+2Ch] [bp-48h]@9 - int v110; // [sp+30h] [bp-44h]@9 - int v111; // [sp+34h] [bp-40h]@3 - int v112; // [sp+38h] [bp-3Ch]@6 - IndoorCameraD3D *pIndoorCameraD3D_4; // [sp+3Ch] [bp-38h]@9 - int v114; // [sp+40h] [bp-34h]@9 - int v115; // [sp+44h] [bp-30h]@9 - int v116; // [sp+48h] [bp-2Ch]@9 - //int v117; // [sp+4Ch] [bp-28h]@9 - int v118; // [sp+50h] [bp-24h]@9 - int v119; // [sp+54h] [bp-20h]@1 - int v120; // [sp+58h] [bp-1Ch]@1 - int i; // [sp+5Ch] [bp-18h]@1 - int v122; // [sp+60h] [bp-14h]@1 - int v123; // [sp+64h] [bp-10h]@1 - int v124; // [sp+68h] [bp-Ch]@1 - int v125; // [sp+6Ch] [bp-8h]@9 - int v126; // [sp+70h] [bp-4h]@9 - - v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2 - pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 - pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 - v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16;//88 - v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16;// 66 - v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X - v119 = pOutdoorCamera->outdoor_grid_band_3 + v123; - v2 = pOutdoorCamera->uCameraFovInDegrees + 15;//90 - i = v124 - pOutdoorCamera->outdoor_grid_band_3; - v122 = v123 - pOutdoorCamera->outdoor_grid_band_3; - - if ( v2 > 90 ) - v2 = 90; - v3 = (v2 << 11) / 720; - v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3); - v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1); - - v106 = stru_5C6E00->Cos(v4); - uEndZ = stru_5C6E00->Sin(v4); - - v111 = stru_5C6E00->Cos(v5); - v6 = stru_5C6E00->Sin(v5); - - v7 = v4 & stru_5C6E00->uPiMask; - if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) - v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7]; - else - v8 = stru_5C6E00->pTanTable[v7]; - v112 = abs(v8); - - v9 = v5 & stru_5C6E00->uPiMask; - if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) - v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9]; - else - v10 = stru_5C6E00->pTanTable[v9]; - v108 = abs(v10); - - //v11 = v124; - //v12 = v123; - v114 = 0; - v115 = 0; - pIndoorCameraD3D_4 = 0; - v125 = 0; - v126 = v124; - v118 = v123; - - v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; - v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; - uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; - v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; - - uint _i = 1; - uint j = 1; - - terrain_76DDC8[0] = -1; - terrain_76DFC8[0] = -1; - terrain_76E1C8[0] = -1; - terrain_76E3C8[0] = -1; - - for( uint _i = 1; _i < 128; _i++) - { - if ( v112 >= 0x10000 ) - { - int v1, v2; - /*v111 = 4294967296i64 / v112; - v114 += v111; - if ( v114 >= 65536 ) - { - v11 += v110; - v114 = (unsigned __int16)v114; - } - v12 += v109;*/ - } - else - { - v124 += v110; - v115 += v112; - if ( v112 + v115 >= 65536 ) - { - v123 += v109; - v115 = (unsigned __int16)v115; - } - } - if ( v124 < _i || v124 > v120 || v123 < v122 || v123 > v119 ) - break; - //v13 = v116++; - terrain_76E3C8[_i] = v124; - terrain_76E1C8[_i] = v123; - } - - for( j = 1; j < 128; j++ ) - { - if ( v108 >= 65536 ) - { - v111 = 4294967296i64 / v108; - v114 += v111;// - if ( v111 + v114 >= 65536 ) - { - v126 += uEndZ; - v114 = (unsigned __int16)v114;// - } - v118 += v106; - } - else - { - v125 += v108; - v126 += uEndZ; - if ( v125 >= 65536 ) - { - v118 += v106; - v125 = (unsigned __int16)v125; - } - } - //if ( v117 >= 128 ) - //break; - if ( v126 < _i ) - break; - if ( v126 > v120 ) - break; - v14 = v118; - if ( v118 < v122 ) - break; - if ( v118 > v119 ) - break; - terrain_76DFC8[j] = v126; - terrain_76DDC8[j] = v14; - } - v16 = 0; - v126 = 0; - v17 = j - 1; - v18 = _i - 1; - - switch ( v105 ) - { - case 0: - case 7: - { - //v116 = terrain_76DFC8[v17]; - if ( v120 > terrain_76DFC8[v17] ) - { - v125 = v120; - memset32(terrain_76D9C8.data(), v119 + 1, 4 * (v120 - terrain_76DFC8[v17] + 1)); - v19 = v120; - do - terrain_76DBC8[v126++] = v19--; - while ( v19 >= terrain_76DFC8[v17] ); - if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] ) - { - do - v20 = terrain_76DDC8[v17-- -1]; - while ( v20 == terrain_76DDC8[v17 -1] ); - } - v16 = v126; - --v17; - } - if ( v17 < 0 ) - v17 = 0; - v21 = terrain_76DFC8[v17]; - while ( 1 ) - { - v125 = terrain_76DFC8[v17]; - if ( v21 < v124 ) - break; - terrain_76DBC8[v16] = v21; - //v22 = terrain_76DDC8[v17] == 65535; - terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1; - if ( terrain_76DDC8[v17] == 65535 ) - { - terrain_76D9C8[v16] = v123 + 1; - break; - } - if ( !v17 ) - break; - if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 - 1] ) - { - do - v23 = terrain_76DDC8[v17-- -1]; - while ( v23 == terrain_76DDC8[v17 -1] ); - } - --v17; - v21 = v125 - 1; - ++v16; - } - v16 = 0; - //v24 = terrain_76E3C8[v18]; - v126 = 0; - if ( v120 > terrain_76E3C8[v18] ) - { - v125 = v120; - memset32(terrain_76D5C8.data(), v122, 4 * (v120 - terrain_76E3C8[v18] + 1)); - do - { - v25 = v126; - v26 = v125--; - ++v126; - terrain_76D7C8[v25] = v26; - } - while ( v125 >= terrain_76E3C8[v18] ); - if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) - { - do - v27 = terrain_76E1C8[v18-- -1]; - while ( v27 == terrain_76E1C8[v18 -1] ); - } - v16 = v126; - --v18; - } - if ( v18 < 0 ) - v18 = 0; - v28 = terrain_76E3C8[v18]; - while ( v28 >= v124 ) - { - v29 = terrain_76E1C8[v18]; - terrain_76D7C8[v16] = v28; - terrain_76D5C8[v16] = v29; - if ( v29 == 65535 ) - { - v31 = v123; - terrain_76D5C8[v16] = v31; - break; - } - if ( !v18 ) - break; - if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) - { - do - v30 = terrain_76E1C8[v18-- -1]; - while ( v30 == terrain_76E1C8[v18 -1] ); - } - --v18; - --v28; - ++v16; - } - break; - } - case 1: - case 2: - { - //v116 = terrain_76DDC8[v17]; - if ( v122 < terrain_76DDC8[v17] ) - { - v106 = v122; - memset32(terrain_76DBC8.data(), v120 + 1, 4 * (terrain_76DDC8[v17] - v122 + 1)); - for ( v32 = v122; v32 <= terrain_76DDC8[v17]; v32++) - terrain_76D9C8[v126++] = v32; - if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) - { - do - v34 = terrain_76DBC8[v17-- -1]; - while ( v34 == terrain_76DBC8[v17 -1] ); - } - v16 = v126; - --v17; - } - if ( v17 < 0 ) - v17 = 0; - v35 = terrain_76DDC8[v17]; - v125 = terrain_76DDC8[v17]; - while ( v35 <= v123 ) - { - //v22 = terrain_76DFC8[v17] == 65535; - terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1; - terrain_76D9C8[v16] = v125; - if ( terrain_76DFC8[v17] == 65535 ) - { - terrain_76DBC8[v16] = v124 + 1; - break; - } - if ( !v17 ) - break; - if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) - { - do - v36 = terrain_76DBC8[v17-- -1]; - while ( v36 == terrain_76DBC8[v17 -1] ); - } - --v17; - ++v125; - v35 = v125; - ++v16; - } - v16 = 0; - v126 = 0; - v37 = terrain_76E1C8[v18]; - if ( v122 < v37 ) - { - v114 = v122; - memset32(terrain_76D7C8.data(), i, 4 * (v37 - v122 + 1)); - do - { - v38 = v126; - v39 = v114; - ++v126; - ++v114; - terrain_76D5C8[v38] = v39; - } - while ( v114 <= terrain_76E1C8[v18] ); - if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) - { - do - v40 = terrain_76DFC8[v18-- -1]; - while ( v40 == terrain_76DFC8[v18 -1] ); - } - v16 = v126; - --v18; - } - if ( v18 < 0 ) - v18 = 0; - v41 = terrain_76E1C8[v18]; - while ( v41 <= v123 ) - { - terrain_76D5C8[v16] = v41; - terrain_76D7C8[v16] = terrain_76E3C8[v18]; - if ( terrain_76E3C8[v18] == 65535 ) - { - terrain_76D7C8[v16] = v124; - break; - } - if ( !v18 ) - break; - if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) - { - do - v43 = terrain_76DFC8[v18-- -1]; - while ( v43 == terrain_76DFC8[v18 -1] ); - } - --v18; - ++v41; - ++v16; - } - break; - } - case 5: - case 6: - { - //v116 = terrain_76DDC8[v17]; - if ( v119 > terrain_76DDC8[v17] ) - { - v106 = v119; - memset32(terrain_76DBC8.data(), i, 4 * (v119 - terrain_76DDC8[v17] + 1)); - for ( v45 = v119; v45 >= terrain_76DDC8[v17]; v45--) - terrain_76D9C8[v126++] = v45; - if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) - { - do - v46 = terrain_76DBC8[v17-- -1]; - while ( v46 == terrain_76DBC8[v17 -1] ); - } - v16 = v126; - --v17; - } - if ( v17 < 0 ) - v17 = 0; - v47 = terrain_76DDC8[v17]; - v125 = terrain_76DDC8[v17]; - while ( v47 >= v123 ) - { - //v22 = terrain_76DFC8[v17] == 65535; - terrain_76DBC8[v16] = terrain_76DFC8[v17]; - terrain_76D9C8[v16] = v125; - if ( terrain_76DFC8[v17] == 65535 ) - { - terrain_76DBC8[v16] = v124; - break; - } - if ( !v17 ) - break; - if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) - { - do - v48 = terrain_76DBC8[v17-- -1]; - while ( v48 == terrain_76DBC8[v17 -1] ); - } - --v17; - --v125; - v47 = v125; - ++v16; - } - v16 = 0; - v49 = terrain_76E1C8[v18]; - v126 = 0; - if ( v119 > v49 ) - { - v125 = v119; - memset32(terrain_76D7C8.data(), v120 + 1, 4 * (v119 - v49 + 1)); - do - { - v50 = v126; - v51 = v125--; - ++v126; - terrain_76D5C8[v50] = v51; - } - while ( v125 >= terrain_76E1C8[v18] ); - if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) - { - do - v52 = terrain_76DFC8[v18-- -1]; - while ( v52 == terrain_76DFC8[v18 -1] ); - } - v16 = v126; - --v18; - } - if ( v18 < 0 ) - v18 = 0; - v53 = terrain_76E1C8[v18]; - while ( v53 >= v123 ) - { - v54 = terrain_76E3C8[v18]; - terrain_76D5C8[v16] = v53; - terrain_76D7C8[v16] = v54 + 1; - if ( v54 == 65535 ) - { - terrain_76D7C8[v16] = v124 + 1; - break; - } - if ( !v18 ) - break; - if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) - { - do - v55 = terrain_76DFC8[v18-- -1]; - while ( v55 == terrain_76DFC8[v18 -1] ); - } - --v18; - --v53; - ++v16; - } - break; - } - case 3: - case 4: - { - //v116 = terrain_76DFC8[v17]; - if ( i < terrain_76DFC8[v17] ) - { - v106 = i; - memset32(terrain_76D9C8.data(), v122, 4 * (terrain_76DFC8[v17] - i + 1)); - v56 = i; - do - { - v57 = v126++; - terrain_76DBC8[v57] = v56++; - } - while ( v56 <= terrain_76DFC8[v17] ); - if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) - { - do - v58 = terrain_76DDC8[v17-- -1]; - while ( v58 == terrain_76DDC8[v17 -1] ); - } - v16 = v126; - --v17; - } - if ( v17 < 0 ) - v17 = 0; - v59 = terrain_76DFC8[v17]; - while ( 1 ) - { - v125 = v59; - if ( v59 > v124 ) - break; - terrain_76DBC8[v16] = v59; - //v60 = terrain_76DDC8[v17]; - terrain_76D9C8[v16] = terrain_76DDC8[v17]; - if ( terrain_76DDC8[v17] == 65535 ) - { - terrain_76D9C8[v16] = v123; - break; - } - if ( !v17 ) - break; - if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) - { - do - v61 = terrain_76DDC8[v17-- -1]; - while ( v61 == terrain_76DDC8[v17 -1] ); - } - --v17; - v59 = v125 + 1; - ++v16; - } - v16 = 0; - v126 = 0; - v62 = terrain_76E3C8[v18]; - if ( i < v62 ) - { - v114 = i; - memset32(terrain_76D5C8.data(), v119 + 1, 4 * (v62 - i + 1)); - do - { - v63 = v126; - v64 = v114; - ++v126; - ++v114; - terrain_76D7C8[v63] = v64; - } - while ( v114 <= terrain_76E3C8[v18] ); - if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) - { - do - v65 = terrain_76E1C8[v18-- -1]; - while ( v65 == terrain_76E1C8[v18 -1] ); - } - v16 = v126; - --v18; - } - if ( v18 < 0 ) - v18 = 0; - v66 = terrain_76E3C8[v18]; - while ( v66 <= v124 ) - { - v67 = terrain_76E1C8[v18]; - terrain_76D7C8[v16] = v66; - terrain_76D5C8[v16] = v67 + 1; - if ( terrain_76E1C8[v18] == 65535 ) - { - v31 = v123 + 1; - terrain_76D5C8[v16] = v31; - break; - } - if ( !v18 ) - break; - if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) - { - do - v68 = terrain_76E1C8[v18-- -1]; - while ( v68 == terrain_76E1C8[v18 -1] ); - } - --v18; - ++v66; - ++v16; - } - break; - } - default: - break; - } - //v69 = v16 - 1; - ptr_801A08 = pVerticesSR_806210; - ptr_801A04 = pVerticesSR_801A10; - //v126 = v69; - - if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//блок - { - for ( i = v16 - 1; i >= 1; --i ) - { - //v70 = i; - //v71 = terrain_76D7C8[i];//88 - //v72 = terrain_76DBC8[i];//0 - if ( terrain_76D7C8[i] < terrain_76DBC8[i] )//swap - { - terrain_76DBC8[i] = terrain_76D7C8[i]; - terrain_76D7C8[i] = terrain_76DBC8[i]; - } - //x = terrain_76DBC8[i];//0 - v111 = 0; - if ( terrain_76DBC8[i] <= 0 ) - terrain_76DBC8[i] = -terrain_76DBC8[i]; - //v74 = terrain_76D7C8[i]; - if ( terrain_76D7C8[i] <= 0 ) - terrain_76D7C8[i] = -terrain_76D7C8[i]; - uEndZ = terrain_76D7C8[i] + 2; - //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; - //uEndZ = v75; - //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; - uStartZ = terrain_76DBC8[i] - 2; - if ( terrain_76DBC8[i] - 2 < uEndZ ) - { - v127 = 0; - //v79 = (v73 - 66) << 9; - //v116 = v77; - //pHeight = v79; - v111 = uEndZ - uStartZ; - for (int z = uStartZ; z < uEndZ; ++z) - { - ptr_801A08[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; - ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; - ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); - - ptr_801A04[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512; - ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; - ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); - - if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) - { - pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); - pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); - - pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); - pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0); - } - //v79 += 512; - v127 ++; - //++v116; - //pHeight = v79; - } - //while ( v116 < v107 ); - } - v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); - v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); - if ( pRenderer->pRenderD3D )//Ritor1: do comment to test - Render::DrawTerrainD3D(v111, 0, v103, v104); - //Render::RenderTerrainD3D(); - else - Render::DrawTerrainSW(v111, 0, v103, v104); - } - } - else - { - for ( i = v16 - 1; i >= 1; --i ) - { - //v86 = i; - //v87 = terrain_76D5C8[i]; - //v88 = terrain_76D9C8[i]; - if ( terrain_76D5C8[i] < terrain_76D9C8[i] ) - { - terrain_76D9C8[i] = terrain_76D5C8[i]; - terrain_76D5C8[i] = terrain_76D9C8[i]; - } - //v89 = terrain_76D9C8[i]; - v111 = 0; - if ( terrain_76D9C8[i] <= 0 ) - terrain_76D9C8[i] = -terrain_76D9C8[i]; - //v90 = terrain_76D5C8[i]; - if ( terrain_76D5C8[i] <= 0 ) - terrain_76D5C8[i] = -terrain_76D5C8[i]; - pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D; - v107 = terrain_76D5C8[i] + 2; - if ( terrain_76D9C8[i] - 2 < terrain_76D5C8[i] + 2 ) - { - v86 = 0; - //v116 = terrain_76D9C8[i] - 2; - v92 = (66 - terrain_76D9C8[i]) << 9; - //pHeight = (66 - terrain_76D9C8[i]) << 9; - v111 = terrain_76D5C8[i] + 2 - (terrain_76D9C8[i] - 2); - //do - for ( v116 = terrain_76D9C8[i] - 2; v116 < v107; ++v116 ) - { - ptr_801A08[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 64) << 9; - ptr_801A08[v86].vWorldPosition.y = v92; - ptr_801A08[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v116); - - ptr_801A04[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 63) << 9; - ptr_801A04[v86].vWorldPosition.y = v92; - ptr_801A04[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v116); - if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) - { - pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1); - pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1); - pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0); - pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0); - } - v92 -= 512; - v86 += 48; - //++v116; - //pHeight = v92; - } - //while ( v116 < v107 ); - } - v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]); - v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]); - if ( pRenderer->pRenderD3D ) - Render::DrawTerrainD3D(v111, 1, v103, v104); - else - Render::DrawTerrainSW(v111, 1, v103, v104); - } - } - result = v126; - pOutdoorCamera->field_40 = v126; - return result; -} -// 47FFC4: inconsistent fpu stack -// 4D864C: using guessed type char byte_4D864C; - - void Render::RenderTerrainD3D() // New function { - char result; // al@3 int v6; // ecx@8 - struct stru148 *pTile; // ebx@8 - struct stru148 *v16; - unsigned int v18; // edi@22 - int v35; // edi@63 - int v37; // eax@73 - int v39; // eax@80 - char v40; // [sp-18h] [bp-70h]@2 - int v41; // [sp-14h] [bp-6Ch]@2 - int v42; // [sp-10h] [bp-68h]@2 - int v43; // [sp-Ch] [bp-64h]@2 - const char *v44; // [sp-8h] [bp-60h]@2 - int v45; // [sp-4h] [bp-5Ch]@2 - int v56; - int v57; // [sp+38h] [bp-20h]@36 - int v64; // [sp+57h] [bp-1h]@2 - int v62; + struct Polygon *pTilePolygon; // ebx@8 //warning: the game uses CW culling by default, ccw is incosistent pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); @@ -1731,20 +254,20 @@ { for (unsigned int x = 0; x < 127; ++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) + pTilePolygon = &array_77EC08[pOutdoorCamera->uNumPolygons]; + pTilePolygon->flags = 0; + pTilePolygon->field_32 = 0; + pTilePolygon->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); + pTilePolygon->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[pTilePolygon->uTileBitmapID]; + if (pTilePolygon->uTileBitmapID == 0xFFFF) continue; //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; + pTilePolygon->flags = pOutdoor->GetSomeOtherTileInfo(x, z); + pTilePolygon->field_32 = 0; + pTilePolygon->field_59 = 1; + pTilePolygon->sTextureDeltaU = 0; + pTilePolygon->sTextureDeltaV = 0; // x,z x+1,z // .____________. // | | @@ -1769,30 +292,30 @@ //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; + pTilePolygon->pODMFace = nullptr; + pTilePolygon->uNumVertices = 4; + pTilePolygon->field_59 = 5; //shading (затенение)---------------------------------------------------------------------------- //uint norm_idx = pTerrainNormalIndices[2 * (z * 128 + x) + 1]; - uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 1];//есть несовпадение в 1 кубик, тень надо поднять на 1 + uint norm_idx = pTerrainNormalIndices[2 * (x * 128 + z) + 2]; 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)); - pTile->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); + pTilePolygon->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); //----------------------------------------------------------------------------------------------- - ++pOutdoorCamera->numStru148s; + ++pOutdoorCamera->uNumPolygons; ++pOutdoorCamera->field_44; - assert(pOutdoorCamera->numStru148s < 20000); - - pTile->uBModelID = 0; - pTile->uBModelFaceID = 0; - pTile->field_50 = (8 * (0 | (0 << 6))) | 6; - for (unsigned int k = 0; k < pTile->uNumVertices; ++k) + assert(pOutdoorCamera->uNumPolygons < 20000); + + pTilePolygon->uBModelID = 0; + pTilePolygon->uBModelFaceID = 0; + pTilePolygon->field_50 = (8 * (0 | (0 << 6))) | 6; + for (unsigned int k = 0; k < pTilePolygon->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); @@ -1800,1119 +323,39 @@ // check the transparency and texture (tiles) mapping (проверка прозрачности и наложение текстур (тайлов))---------------------- bool transparent = false; - if ( !( pTile->flags & 1 ) ) // не поддерживается TextureFrameTable - { - if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id) + if ( !( pTilePolygon->flags & 1 ) ) // не поддерживается TextureFrameTable + { + if ( /*pTile->flags & 2 && */pTilePolygon->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) ) + v6 = pTilePolygon->uTileBitmapID; + if ( !_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->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[pTile->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX - pTile->DrawBorderTiles(); - - pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); + if (!_strnicmp(pBitmaps_LOD->pTextures[pTilePolygon->uTileBitmapID].pName, "wtrdr", 5)) // all shore tile filenames are wtrdrXXX + pTilePolygon->DrawBorderTiles(); + + pRenderer->DrawTerrainPolygon(pTilePolygon->uNumVertices, pTilePolygon, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); } //else //здесь уже пограничные тайлы воды //pTile->DrawBorderTiles(); //-------------------------------------------------------------------------------------------------------------------------------- - --pOutdoorCamera->numStru148s; + --pOutdoorCamera->uNumPolygons; --pOutdoorCamera->field_44; } } } -//----- (0048034E) -------------------------------------------------------- -void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4) -{ - //int v3; // esi@1 - int v4; // edi@1 - int v5; // ebx@2 - int v6; // eax@2 - int v7; // eax@3 - RenderVertexSoft *v8; // edi@3 - RenderVertexSoft *v9; // ebx@4 - RenderVertexSoft *v10; // ecx@4 - float v11; // eax@6 - double v12; // ST5C_8@6 - double v13; // ST2C_8@6 - int v14; // eax@6 - double v15; // st7@6 - stru148 *pTile; // ebx@12 - unsigned __int16 v17; // ax@12 - int v18; // eax@13 - signed int v22; // eax@13 - Vec3_float_ *norm; // eax@15 - //double v24; // st6@17 - double v25; // ST54_8@17 - unsigned __int8 v26; // sf@17 - unsigned __int8 v27; // of@17 - double v28; // st5@19 - double v29; // st5@19 - double v30; // st5@19 - double v31; // st5@19 - struct struct8 *v32; // esi@21 - double v3a; // st7@32 - int v33; // edi@38 - unsigned int v34; // ecx@47 - char v35; // zf@47 - unsigned int v36; // eax@50 - int v37; // eax@54 - //stru148 *v38; // ecx@55 - unsigned int v39; // eax@59 - stru148 *v40; // ebx@62 - unsigned __int16 pTileBitmapsID; // ax@62 - int v42; // eax@63 - LightmapBuilder *v43; // ecx@63 - int v44; // eax@63 - int v45; // eax@63 - int v46; // eax@63 - signed int v47; // eax@63 - Vec3_float_ *v48; // eax@65 - double v49; // st6@67 - double v50; // ST4C_8@67 - double v51; // st5@71 - double v52; // st5@71 - double v53; // st5@71 - double v54; // st7@84 - unsigned int v55; // ecx@98 - unsigned int v56; // eax@101 - int v57; // eax@105 - unsigned int v58; // eax@109 - stru148 *v59; // esi@112 - unsigned __int16 v60; // ax@112 - int v61; // eax@113 - signed int v62; // eax@113 - Vec3_float_ *v63; // eax@114 - double v64; // st6@116 - double v65; // ST3C_8@116 - double v66; // st5@120 - double v67; // st5@120 - double v68; // st5@120 - double v69; // st7@133 - int v70; // edi@138 - stru148 *v71; // esi@147 - unsigned int v72; // ecx@147 - unsigned int v73; // eax@150 - int v74; // eax@154 - unsigned int v75; // eax@158 - //unsigned int v76; // [sp-10h] [bp-E0h]@61 - int v77; // [sp-Ch] [bp-DCh]@61 - IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 - //int v79; // [sp-4h] [bp-D4h]@61 - bool v80; // [sp+0h] [bp-D0h]@59 - bool v81; // [sp+0h] [bp-D0h]@109 - int v82; // [sp+54h] [bp-7Ch]@1 - int v83; // [sp+60h] [bp-70h]@1 - int v84; // [sp+6Ch] [bp-64h]@1 - int v85; // [sp+70h] [bp-60h]@63 - float a4; // [sp+74h] [bp-5Ch]@73 - float v87; // [sp+78h] [bp-58h]@122 - int v88; // [sp+7Ch] [bp-54h]@1 - int v89; // [sp+80h] [bp-50h]@6 - int v93; // [sp+90h] [bp-40h]@2 - int X; // [sp+94h] [bp-3Ch]@1 - float v95; // [sp+98h] [bp-38h]@21 - LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 - int v97; // [sp+A0h] [bp-30h]@6 - int sX; // [sp+A4h] [bp-2Ch]@6 - unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 - int v100; // [sp+ACh] [bp-24h]@122 - int sY; // [sp+B0h] [bp-20h]@6 - RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 - unsigned int a5; // [sp+B8h] [bp-18h]@21 - RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 - Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 - RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 - RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 - char v108; // [sp+CFh] [bp-1h]@36 - float thisd; // [sp+D8h] [bp+8h]@6 - float thise; // [sp+D8h] [bp+8h]@6 - float thisf; // [sp+D8h] [bp+8h]@17 - IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 - float thisg; // [sp+D8h] [bp+8h]@67 - IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 - float thish; // [sp+D8h] [bp+8h]@116 - IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 - char this_3; // [sp+DBh] [bp+Bh]@30 - char this_3a; // [sp+DBh] [bp+Bh]@82 - char this_3b; // [sp+DBh] [bp+Bh]@131 - - static stru154 static_sub_0048034E_stru_154; - static stru154 stru_76D5A8; - //v3 = a1; - v82 = a2; - v83 = a3; - X = abs(unk4); - v4 = 0; - v88 = 0; - v84 = a1 - 1; -/* if ( a1 - 1 > 0 ) - { - while ( 1 ) - { - v5 = abs(X);//v5 = 13108 - v6 = abs(v83);//v6 = 13108 - --X; - //__debugbreak(); // uncoment & refactor following large if - v93 = (int)&stru_76E5C8[(v5 << 7) + v6]; - /*if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), - v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), - ((a8 = v9, - pVertices = &pVerticesSR_801A10[1] + v7, - v11 = v8->vWorldPosition.x, - v101 = v10, - v12 = v11 + 6.755399441055744e15, - sX = LODWORD(v12), - v13 = v8->vWorldPosition.y + 6.755399441055744e15, - sY = LODWORD(v13), - thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, - v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X - v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, - v89 = v14, - thise = v15 * 0.5, - _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z - WorldPosToGridCellX(sX), - WorldPosToGridCellZ(sY), - !byte_4D864C) - || !(pGame->uFlags & 0x80)) - && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ - /*if ( !&stru_76E5C8[(v5 << 7) + v6] ) - goto LABEL_162*/ - v8 = &pVerticesSR_806210[v4]; - //pVertices2 = &pVerticesSR_801A10[v4 + 1]; - //v102 = v8; - if (!v82) - { - pVertices = &pVerticesSR_801A10[v4]; - v101 = &pVerticesSR_806210[v4 + 1]; - } - else - { - pVertices = &pVerticesSR_801A10[v4 + 1]; - v101 = &pVerticesSR_806210[v4]; - } - sX = floorf(v8->vWorldPosition.x + 0.5f); - sY = floorf(v8->vWorldPosition.z + 0.5f); - v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); - v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); - /*WorldPosToGridCellX(sX); - WorldPosToGridCellZ(sY); - if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) - if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y - || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) - break;*/ - pTile = &array_77EC08[pOutdoorCamera->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 ) - norm = 0; - else - norm = &pTerrainNormals[v22]; - thisf = 20.0 - ( -(((float)pOutdoor->vSunlight.x / 65536.0) * norm->x) - - (((float)pOutdoor->vSunlight.y / 65536.0) * norm->y) - - (((float)pOutdoor->vSunlight.z / 65536.0) * norm->z)) * 20.0; - //v25 = thisf + 6.7553994e15; - //v27 = pOutdoorCamera->numStru148s > 1999; - //v26 = pOutdoorCamera->numStru148s - 1999 < 0; - pTile->dimming_level = floorf(thisf + 0.5f); - if ( pOutdoorCamera->numStru148s >= 1999 ) - return; - ++pOutdoorCamera->numStru148s; - //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary - //goto LABEL_126; - //{ - //--pOutdoorCamera->numStru148s; - //goto LABEL_162; - //} - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); - array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[3].u = 1.0; - array_50AC10[3].v = 0.0; - /*if ( !(byte_76D5C0 & 1) ) - { - byte_76D5C0 |= 1u; - stru154(stru_76D5A8); - atexit(loc_481199); - }*/ - v32 = (struct8 *)array_50AC10; - v97 = (int)pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &v95, array_50AC10, 4, 1); - pDecalBuilder->_49BE8A(pTile, norm, &v95, array_50AC10, 4, 1); - a5 = 4; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisa = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) - goto LABEL_162; - thisa->ViewTransform(array_50AC10, a5); - thisa->Project(array_50AC10, a5, 0); - } - this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 - || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; - v3a = (double)pOutdoorCamera->shading_dist_mist; - v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x - || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; - v33 = 0; - pGame->pLightmapBuilder->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3 ) - v33 = 3; - else - v33 = v108 != 0 ? 5 : 0; - static_sub_0048034E_stru_154.ClassifyPolygon(norm, v95); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - pTile->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); - v34 = a5; - //v35 = byte_4D864C == 0; - pTile->uNumVertices = a5; - if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) - { - if ( this_3 ) - { - v36 = sr_424CD7(v34); - pTile->uNumVertices = v36; - OutdoorCamera::Project(v36); - } - if ( v108 ) - { - v36 = sr_424EE0_MakeFanFromTriangle(v34); - pTile->uNumVertices = v36; - OutdoorCamera::Project(v36); - } - } - //v37 = *(int *)&v16->flags; - if ( ~pTile->flags & 1 ) - { - if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v80 = false; - v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v39 = pTile->uTileBitmapID; - v80 = true; - } - //v79 = 0; - //v78 = pBitmaps_LOD->pHardwareTextures[v39]; - pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary - v77 = (int)pTile; - //v76 = v16->uNumVertices; -//LABEL_161: - pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v39], false, v80); - goto LABEL_162; - } -LABEL_56: - pTile->DrawBorderTiles(); - } -LABEL_162: - v4 = v88 + 1; - if ( ++v88 >= v84 ) - return; - } - /* v40 = &array_77EC08[pOutdoorCamera->numStru148s]; - v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( v40->uTileBitmapID == -1 ) - goto LABEL_162; - v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); - BYTE1(v42) |= 0x80u; - v43 = pGame->pLightmapBuilder; - *(int *)&v40->flags = v42; - v44 = v93; - v40->field_59 = 1; - v40->terrain_grid_x = (char)v43; - v40->field_34 = *(_WORD *)(v44 + 2); - v45 = v89; - v40->terrain_grid_z = v89; - v46 = 4 * ((char)v43 + (v45 << 7)); - v85 = v46; - v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; - if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) - v48 = 0; - else - v48 = &pTerrainNormals[v47]; - v49 = v92 * v48->y; - //v99 = v48; - thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; - v50 = thisg + 6.755399441055744e15; - v40->dimming_level = LOBYTE(v50); - if ( LOBYTE(v50) < 0 ) - v40->dimming_level = 0; - if ( pOutdoorCamera->numStru148s >= 1999 ) - return; - ++pOutdoorCamera->numStru148s; - /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary - //goto LABEL_77; - { - --pOutdoorCamera->numStru148s; - goto LABEL_112; - }*/ - /*memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - static stru154 static_sub_0048034E_stru_76D590; - /*static bool __init_flag2 = false; - if (!__init_flag2) - { - __init_flag2 = true; - stru154::stru154(&static_sub_0048034E_stru_76D590); - }*/ - /*if ( !(byte_76D5C0 & 2) ) - { - byte_76D5C0 |= 2; - stru148(stru_76D590); - atexit(loc_48118F); - }*/ - /*v96 = pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); - pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); - uNumVertices = 3; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisb = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) - { -//LABEL_77: - --pOutdoorCamera->numStru148s; - goto LABEL_112; - } - thisb->ViewTransform(array_50AC10, uNumVertices); - thisb->Project(array_50AC10, uNumVertices, 0); - } - this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; - v54 = (double)pOutdoorCamera->shading_dist_mist; - v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; - pVertices = 0; - v96->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3a ) - pVertices = (RenderVertexSoft *)3; - else - pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); - //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); - static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); - v55 = uNumVertices; - //v35 = byte_4D864C == 0; - v40->uNumVertices = uNumVertices; - if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) - { - if ( this_3a ) - { - v56 = sr_424CD7(v55); - } - else - { - if ( !v108 ) - goto LABEL_105; - v56 = sr_424EE0_MakeFanFromTriangle(v55); - } - v40->uNumVertices = v56; - OutdoorCamera::Project(v56); - } -LABEL_105: - v57 = *(int *)&v40->flags; - if ( BYTE1(v57) & 1 ) - { - v40->DrawBorderTiles(); - } - else - { - if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v81 = false; - v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v58 = v40->uTileBitmapID; - v81 = true; - } - pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); - } -LABEL_112: - v59 = &array_77EC08[pOutdoorCamera->numStru148s]; - //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s]; - v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( v59->uTileBitmapID == -1 ) - goto LABEL_162; - *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); - v61 = v93; - v59->field_59 = 1; - v59->field_34 = *(_WORD *)(v61 + 2); - v59->terrain_grid_z = v89; - v59->terrain_grid_x = v97; - v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); - if ( v62 > (signed int)(uNumTerrainNormals - 1) ) - v63 = 0; - else - v63 = &pTerrainNormals[v62]; - v64 = v92 * v63->y; - //v99 = v63; - thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; - v59->dimming_level = floorf(thish + 0.5f); - if ( v59->dimming_level < 0 ) - v59->dimming_level = 0; - if ( pOutdoorCamera->numStru148s >= 1999 ) - return; - ++pOutdoorCamera->numStru148s; - if ( !sub_481FC9(v101, v102, pVertices2, v59) ) - { -//LABEL_126: - --pOutdoorCamera->numStru148s; - goto LABEL_162; - } - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[1].u = 1.0; - array_50AC10[1].v = 1.0; - memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 0.0; - static stru154 static_sub_0048034E_stru_76D578; - /*static bool __init_flag1 = false; - if (!__init_flag1) - { - __init_flag1 = true; - stru154::stru154(&static_sub_0048034E_stru_76D578); - }*/ - /* v96 = pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); - pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1); - v100 = 3; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisc = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) - //goto LABEL_126; - { - --pOutdoorCamera->numStru148s; - goto LABEL_162; - } - thisc->ViewTransform(array_50AC10, v100); - thisc->Project(array_50AC10, v100, 0); - } - this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 - || v101->vWorldViewPosition.x < 8.0; - v69 = (double)pOutdoorCamera->shading_dist_mist; - v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; - v70 = 0; - v96->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3b ) - v70 = 3; - else - v70 = v108 != 0 ? 5 : 0; - static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); - v71 = v59; - v72 = v100; - //v35 = byte_4D864C == 0; - v59->uNumVertices = v100;//??? - if ( !byte_4D864C && pGame->uFlags & 0x80 ) - goto LABEL_154; - if ( this_3b ) - { - v73 = sr_424CD7(v72); - } - else - { - if ( !v108 ) - { -LABEL_154: - v74 = v71->flags; - if ( !(BYTE1(v74) & 1) ) - { - if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) - { - v80 = false; - v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; - } - else - { - v75 = v71->uTileBitmapID; - v80 = true; - } - //v79 = 0; - v78 = pBitmaps_LOD->pHardwareTextures[v75]; - v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary - //v77 = (int)v71; - //v76 = v71->uNumVertices; - //goto LABEL_161; - pRenderer->DrawTerrainPolygon(v71->uNumVertices, (stru148 *)v71, v78, 0, v80); - goto LABEL_162; - } - v38 = (stru148 *)v71; - goto LABEL_56; - } - v73 = sr_424EE0_MakeFanFromTriangle(v72); - } - v71->uNumVertices = v73; - OutdoorCamera::Project(v73); - goto LABEL_154; - } - }*/ -// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); -// 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); -// 4D864C: using guessed type char byte_4D864C; -// 76D5C0: using guessed type char static_sub_0048034E_byte_76D5C0__init_flag; - -//----- (00481212) -------------------------------------------------------- -void Render::DrawTerrainSW(int a1, int a2, int a3, int a4) -{ - int v3; // esi@1 - int v4; // ecx@1 - int v5; // ST10_4@1 - int v6; // edi@1 - int v7; // ebx@2 - int v8; // eax@2 - int v9; // eax@3 - RenderVertexSoft *v10; // edi@3 - RenderVertexSoft *v11; // ebx@4 - RenderVertexSoft *v12; // ecx@4 - float v13; // eax@6 - int v14; // eax@6 - double v15; // st7@6 - double v16; // st7@6 - stru148 *v17; // ebx@12 - unsigned __int16 v18; // ax@12 - int v19; // eax@13 - float v20; // ecx@13 - stru220 *v21; // eax@13 - int v22; // eax@13 - signed int v23; // eax@13 - Vec3_float_ *v24; // eax@15 - double v25; // st7@18 - double v26; // st5@24 - double v27; // st5@24 - double v28; // st5@24 - double v29; // st5@24 - Game *v30; // eax@25 - RenderVertexSoft *v31; // edi@29 - double v32; // st7@31 - int v33; // esi@35 - RenderVertexSoft *v34; // edx@36 - RenderVertexSoft *v35; // ecx@36 - signed int v36; // eax@39 - signed int v37; // esi@40 - stru148 *v38; // ebx@43 - unsigned __int16 v39; // ax@43 - int v40; // eax@44 - float v41; // ecx@44 - stru220 *v42; // eax@44 - int v43; // eax@44 - int v44; // eax@44 - signed int v45; // eax@44 - Vec3_float_ *v46; // eax@46 - double v47; // st7@49 - double v48; // st5@57 - double v49; // st5@57 - double v50; // st5@57 - Game *v51; // eax@58 - RenderVertexSoft *v52; // edi@62 - double v53; // st7@63 - int v54; // esi@66 - signed int v55; // eax@69 - signed int v56; // esi@71 - unsigned __int16 v57; // ax@75 - stru220 *v58; // eax@76 - signed int v59; // eax@76 - Vec3_float_ *v60; // eax@77 - double v61; // st7@80 - double v62; // st5@88 - double v63; // st5@88 - double v64; // st5@88 - Game *v65; // eax@89 - double v66; // st7@94 - RenderVertexSoft *v67; // [sp-Ch] [bp-C4h]@36 - stru148 *v68; // [sp-8h] [bp-C0h]@36 - int v69; // [sp-4h] [bp-BCh]@36 - float v70; // [sp+Ch] [bp-ACh]@88 - double v71; // [sp+10h] [bp-A8h]@6 - double v72; // [sp+18h] [bp-A0h]@82 - double v73; // [sp+20h] [bp-98h]@6 - double v74; // [sp+28h] [bp-90h]@51 - double v75; // [sp+30h] [bp-88h]@6 - double v76; // [sp+38h] [bp-80h]@20 - double v77; // [sp+40h] [bp-78h]@6 - float v78; // [sp+48h] [bp-70h]@57 - float v79; // [sp+4Ch] [bp-6Ch]@6 - float v80; // [sp+50h] [bp-68h]@6 - int v81; // [sp+54h] [bp-64h]@1 - int v82; // [sp+58h] [bp-60h]@6 - int v83; // [sp+5Ch] [bp-5Ch]@82 - int v84; // [sp+60h] [bp-58h]@20 - int v85; // [sp+64h] [bp-54h]@1 - int v86; // [sp+68h] [bp-50h]@1 - int v87; // [sp+6Ch] [bp-4Ch]@51 - float v88; // [sp+70h] [bp-48h]@51 - int v89; // [sp+74h] [bp-44h]@6 - int v90; // [sp+78h] [bp-40h]@1 - float a3a; // [sp+7Ch] [bp-3Ch]@24 - stru220 *v92; // [sp+80h] [bp-38h]@2 - float v93; // [sp+84h] [bp-34h]@44 - int v94; // [sp+88h] [bp-30h]@6 - float v95; // [sp+8Ch] [bp-2Ch]@1 - float v96; // [sp+90h] [bp-28h]@1 - float v97; // [sp+94h] [bp-24h]@1 - int X; // [sp+98h] [bp-20h]@1 - float v99; // [sp+9Ch] [bp-1Ch]@6 - int v100; // [sp+A0h] [bp-18h]@6 - unsigned __int64 v101; // [sp+A4h] [bp-14h]@6 - RenderVertexSoft *v102; // [sp+ACh] [bp-Ch]@6 - RenderVertexSoft *v103; // [sp+B0h] [bp-8h]@6 - RenderVertexSoft *v104; // [sp+B4h] [bp-4h]@3 - float pNormalc; // [sp+C0h] [bp+8h]@6 - float pNormald; // [sp+C0h] [bp+8h]@6 - Vec3_float_ *pNormal; // [sp+C0h] [bp+8h]@17 - Vec3_float_ *pNormala; // [sp+C0h] [bp+8h]@48 - Vec3_float_ *pNormalb; // [sp+C0h] [bp+8h]@77 - - v3 = a1; - //v4 = *(short *)(a3 + 4); - //v5 = *(short *)(a3 + 6); - v85 = a2; - v86 = a3; //v4; - X = abs(a4); //v5 - v6 = 0; - v90 = 0; - v81 = v3 - 1; - v95 = (double)pOutdoor->vSunlight.x / 65536.0; - v96 = (double)pOutdoor->vSunlight.y / 65536.0; - v97 = (double)pOutdoor->vSunlight.z / 65536.0; - if ( v3 - 1 > 0 ) - { - while ( 1 ) - { - v7 = abs(X); - v8 = abs(v86); - --X; - v92 = &stru_76E5C8[(v7 << 7) + v8]; - if ( !v92->field_0 - || ((v9 = v6, v10 = &pVerticesSR_806210[v6], v104 = v10, !v85) ? (v11 = &pVerticesSR_801A10[v9], - v12 = &pVerticesSR_806210[v9 + 1]) : (v11 = &pVerticesSR_806210[v9 + 1], v12 = &pVerticesSR_801A10[v9]), - ((v103 = &pVerticesSR_801A10[v9 + 1], - v13 = v10->vWorldPosition.x, - v102 = v12, - v80 = v13, - v73 = v13 + 6.7553994e15, - v101 = __PAIR__((unsigned int)v11, LODWORD(v73)), - v79 = v10->vWorldPosition.y, - v75 = v79 + 6.7553994e15, - v100 = LODWORD(v75), - pNormalc = (v12->vWorldPosition.x + v10->vWorldPosition.x) * 0.5, - v71 = pNormalc + 6.7553994e15, - v89 = LODWORD(v71), - v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(pNormalc + 6.7553994e15)), - v15 = v11->vWorldPosition.y + v10->vWorldPosition.y, - v94 = v14, - pNormald = v15 * 0.5, - v16 = pNormald + 6.7553994e15, - v77 = v16, - v82 = LODWORD(v77), - LODWORD(v99) = WorldPosToGridCellZ(LODWORD(v16)), - WorldPosToGridCellX(v101), - WorldPosToGridCellZ(v100), - !byte_4D864C) - || !(pGame->uFlags & 0x80)) - && !sub_481EFA(v10, v11, v102, v103, 1)) ) - goto LABEL_105; - if ( v10->vWorldPosition.z != v11->vWorldPosition.z - || v11->vWorldPosition.z != v103->vWorldPosition.z - || v103->vWorldPosition.z != v102->vWorldPosition.z ) - break; - v17 = &array_77EC08[pOutdoorCamera->numStru148s]; - v18 = pOutdoor->GetTileTexture(v101, v100); - v17->uTileBitmapID = v18; - if ( v18 != -1 ) - { - v19 = pOutdoor->GetSomeOtherTileInfo(v101, v100); - LOWORD(v19) = v19 | 0x8010; - v20 = v99; - *(int *)&v17->flags = v19; - v21 = v92; - v17->field_59 = 1; - v17->terrain_grid_x = LOBYTE(v20); - v17->field_34 = v21->distance; - v22 = v94; - v17->terrain_grid_z = v94; - v23 = pTerrainNormalIndices[2 * (LODWORD(v20) + (v22 << 7)) + 1]; - if ( v23 < 0 || v23 > (signed int)(uNumTerrainNormals - 1) ) - v24 = 0; - else - v24 = &pTerrainNormals[v23]; - pNormal = v24; - if ( v24 ) - { - v25 = -(v97 * v24->z + v96 * v24->y + v95 * v24->x); - if ( v25 < 0.0 ) - v25 = 0.0; - v99 = v25 * 31.0; - v76 = v99 + 6.7553994e15; - v84 = LODWORD(v76); - v17->dimming_level = 31 - LOBYTE(v76); - } - else - { - v17->dimming_level = 0; - } - if ( pOutdoorCamera->numStru148s >= 1999 ) - return; - ++pOutdoorCamera->numStru148s; - if ( !sub_481FC9(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) ) - goto LABEL_104; - v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); - memcpy(array_50AC10, v104, 0x30u); - array_50AC10[0]._rhw = v26; - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - v27 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; - memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / v27; - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - v28 = v103->vWorldViewPosition.x + 0.0000001; - memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / v28; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - v29 = v102->vWorldViewPosition.x + 0.0000001; - memcpy(&array_50AC10[3], v102, sizeof(array_50AC10[3])); - array_50AC10[3]._rhw = 1.0 / v29; - array_50AC10[3].u = 1.0; - array_50AC10[3].v = 0.0; - pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1); - if ( stru_F8AD28.uNumLightsApplied <= 0 ) - { - v17->field_108 = 0; - } - else - { - v30 = pGame; - v17->field_108 = 1; - pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 4, pNormal); - } - if ( v104->vWorldViewPosition.x < 8.0 - || *(float *)(HIDWORD(v101) + 12) < 8.0 - || (v31 = v102, v102->vWorldViewPosition.x < 8.0) - || v103->vWorldViewPosition.x < 8.0 ) - { - v36 = sr_4250FE(4u); - } - else - { - v32 = (double)pOutdoorCamera->shading_dist_mist; - if ( v32 >= v104->vWorldViewPosition.x - && v32 >= *(float *)(HIDWORD(v101) + 12) - && v32 >= v102->vWorldViewPosition.x - && v32 >= v103->vWorldViewPosition.x ) - { - v33 = sr_4254D2(4); - v17->uNumVertices = v33; - if ( !v33 ) - goto LABEL_104; - v34 = (RenderVertexSoft *)HIDWORD(v101); - v35 = v104; - v69 = 0; - v68 = v17; - v67 = v31; - goto LABEL_37; - } - v36 = sr_4252E8(4u); - } - v37 = v36; - if ( !v36 ) - goto LABEL_104; -LABEL_41: - OutdoorCamera::Project(v37); -LABEL_102: - v33 = sr_4254D2(v37); - v17->uNumVertices = v33; - if ( !v33 ) - goto LABEL_104; - v17->_48276F_sr(); - goto LABEL_38; - } -LABEL_105: - v6 = v90++ + 1; - if ( v90 >= v81 ) - return; - } - v38 = &array_77EC08[pOutdoorCamera->numStru148s]; - v39 = pOutdoor->GetTileTexture(v101, v100); - v38->uTileBitmapID = v39; - if ( v39 == -1 ) - goto LABEL_105; - v40 = pOutdoor->GetSomeOtherTileInfo(v101, v100); - BYTE1(v40) |= 0x80u; - v41 = v99; - *(int *)&v38->flags = v40; - v42 = v92; - v38->field_59 = 1; - v38->terrain_grid_x = LOBYTE(v41); - v38->field_34 = v42->distance; - v43 = v94; - v38->terrain_grid_z = v94; - v44 = 2 * (LODWORD(v41) + (v43 << 7)); - LODWORD(v93) = v44 * 2; - v45 = pTerrainNormalIndices[v44 + 1]; - if ( v45 < 0 || v45 > (signed int)(uNumTerrainNormals - 1) ) - v46 = 0; - else - v46 = &pTerrainNormals[v45]; - pNormala = v46; - if ( v46 ) - { - v47 = -(v97 * v46->z + v96 * v46->y + v95 * v46->x); - if ( v47 < 0.0 ) - v47 = 0.0; - v88 = v47 * 31.0; - v74 = v88 + 6.7553994e15; - v87 = LODWORD(v74); - v38->dimming_level = 31 - LOBYTE(v74); - } - else - { - v38->dimming_level = 0; - } - if ( v38->dimming_level < 0 ) - v38->dimming_level = 0; - if ( pOutdoorCamera->numStru148s >= 1999 ) - return; - ++pOutdoorCamera->numStru148s; - if ( !sub_481FC9((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) ) - goto LABEL_74; - v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); - memcpy(array_50AC10, v104, 0x30u); - array_50AC10[0]._rhw = v48; - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - v49 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; - memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / v49; - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - v50 = v103->vWorldViewPosition.x + 0.0000001; - memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / v50; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0); - if ( stru_F8AD28.uNumLightsApplied <= 0 ) - { - v38->field_108 = 0; - } - else - { - v51 = pGame; - v38->field_108 = 1; - pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormala); - } - if ( v104->vWorldViewPosition.x < 8.0 - || *(float *)(HIDWORD(v101) + 12) < 8.0 - || (v52 = v103, v103->vWorldViewPosition.x < 8.0) ) - { - v55 = sr_4250FE(3u); - } - else - { - v53 = (double)pOutdoorCamera->shading_dist_mist; - if ( v53 >= v104->vWorldViewPosition.x - && v53 >= *(float *)(HIDWORD(v101) + 12) - && v53 >= v103->vWorldViewPosition.x ) - { - v54 = sr_4254D2(3); - v38->uNumVertices = v54; - if ( v54 ) - { - sr_sub_4829B9((RenderVertexSoft *)HIDWORD(v101), v52, v104, v38, 0); -LABEL_68: - sr_sub_481DB2(array_508690, v54, v38); -LABEL_75: - v17 = &array_77EC08[pOutdoorCamera->numStru148s]; - v57 = pOutdoor->GetTileTexture(v101, v100); - v17->uTileBitmapID = v57; - if ( v57 == -1 ) - goto LABEL_105; - *(int *)&v17->flags = pOutdoor->GetSomeOtherTileInfo(v101, v100); - v58 = v92; - v17->field_59 = 1; - v17->field_34 = v58->distance; - v17->terrain_grid_z = v94; - v17->terrain_grid_x = LOBYTE(v99); - v59 = *(unsigned __int16 *)((char *)pTerrainNormalIndices.data() + LODWORD(v93)); - if ( v59 > (signed int)(uNumTerrainNormals - 1) ) - { - pNormalb = 0; - v60 = 0; - } - else - { - v60 = &pTerrainNormals[v59]; - pNormalb = v60; - } - if ( v60 ) - { - v61 = -(v97 * v60->z + v96 * v60->y + v95 * v60->x); - if ( v61 < 0.0 ) - v61 = 0.0; - v93 = v61 * 31.0; - v72 = v93 + 6.7553994e15; - v83 = LODWORD(v72); - v17->dimming_level = 31 - LOBYTE(v72); - } - else - { - v17->dimming_level = 0; - } - if ( v17->dimming_level < 0 ) - v17->dimming_level = 0; - if ( pOutdoorCamera->numStru148s >= 1999 ) - return; - ++pOutdoorCamera->numStru148s; - if ( !sub_481FC9(v102, v104, v103, v17) ) - { -LABEL_104: - --pOutdoorCamera->numStru148s; - goto LABEL_105; - } - v62 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); - memcpy(array_50AC10, v104, 0x30u); - array_50AC10[0]._rhw = v62; - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - v63 = v103->vWorldViewPosition.x + 0.0000001; - memcpy(&array_50AC10[1], v103, sizeof(array_50AC10[1])); - array_50AC10[1]._rhw = 1.0 / v63; - array_50AC10[1].u = 1.0; - array_50AC10[1].v = 1.0; - v64 = v102->vWorldViewPosition.x + 0.0000001; - memcpy(&array_50AC10[2], v102, sizeof(array_50AC10[2])); - array_50AC10[2]._rhw = 1.0 / v64; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 0.0; - pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1); - if ( stru_F8AD28.uNumLightsApplied <= 0 ) - { - v17->field_108 = 0; - } - else - { - v65 = pGame; - v17->field_108 = 1; - pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormalb); - } - if ( v104->vWorldViewPosition.x < 8.0 || v103->vWorldViewPosition.x < 8.0 || v102->vWorldViewPosition.x < 8.0 ) - { - v37 = sr_4250FE(3u); - OutdoorCamera::Project(v37); - if ( !v37 ) - goto LABEL_104; - goto LABEL_102; - } - v66 = (double)pOutdoorCamera->shading_dist_mist; - if ( v66 < v104->vWorldViewPosition.x || v66 < v103->vWorldViewPosition.x || v66 < v102->vWorldViewPosition.x ) - { - v37 = sr_4252E8(3u); - if ( !v37 ) - goto LABEL_105; - goto LABEL_41; - } - v33 = sr_4254D2(3); - v17->uNumVertices = v33; - if ( !v33 ) - goto LABEL_104; - v34 = v104; - v35 = v102; - v69 = 0; - v68 = v17; - v67 = v103; -LABEL_37: - sr_sub_4829B9(v35, v34, v67, v68, v69); -LABEL_38: - sr_sub_481DB2(array_508690, v33, v17); - goto LABEL_105; - } - goto LABEL_74; - } - v55 = sr_4252E8(3u); - } - v56 = v55; - if ( v55 ) - { - OutdoorCamera::Project(v55); - v54 = sr_4254D2(v56); - v38->uNumVertices = v54; - if ( v54 ) - { - v38->_48276F_sr(); - goto LABEL_68; - } - } -LABEL_74: - --pOutdoorCamera->numStru148s; - goto LABEL_75; - } -} + //----- (0047BACF) -------------------------------------------------------- void Render::TransformBillboardsAndSetPalettesODM() @@ -2961,11 +404,12 @@ billboard.uFlags = pBillboard->field_1E; if (pBillboard->uHwSpriteID != -1) { - if (pRenderer->pRenderD3D) + if (!pRenderer->pRenderD3D) __debugbreak(); // no sw rendering + //if (pRenderer->pRenderD3D) pRenderer->TransformBillboard(&billboard, &pSprites_LOD->pHardwareSprites[pBillboard->uHwSpriteID], pBillboard->dimming_level, pBillboard); - else + /*else { assert(false); @@ -2973,7 +417,7 @@ if ( *(v1 - 10) & 2 ) v9 = PaletteManager::Get_Dark_or_Red_LUT(*((short *)v1 - 7), 0, 1); else - v9 = GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); + v9 = sr_GetBillboardPalette((RenderBillboard *)(v1 - 40), *((short *)v1 - 7), pBillboard->sZValue, *((short *)v1 + 1)); v10 = (*(v1 - 9) & 1) == 0; billboard.pPalette = v9; if ( !v10 ) @@ -2988,7 +432,7 @@ v13 = *((short *)v1 - 8); if ( v13 >= 0 ) pSprites_LOD->pSpriteHeaders[v13].DrawSprite_sw(&billboard, 1); - } + }*/ } } } @@ -3715,9 +1159,9 @@ local_0.x = v3; local_0.y = (double)*(signed int *)v0; local_0.z = (double)*((signed int *)v0 + 1); - local_0.flt_10 = 0.0; - local_0.flt_14 = 0.0; - local_0.flt_18 = 0.0; + local_0.r = 0.0; + local_0.g = 0.0; + local_0.b = 0.0; local_0.flt_28 = 1.0; local_0.timeToLive = (rand() & 0x80) + 128; local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01"); @@ -4305,6 +1749,7 @@ if ( v9 == v10 ) { ddsd2.dwFlags = 0x1007u; + __debugbreak(); // warning C4700: uninitialized local variable 'v11' used ddsd2.ddsCaps.dwCaps = v11; goto LABEL_12; } @@ -4355,7 +1800,7 @@ } //----- (004A2050) -------------------------------------------------------- -void Render::DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) +void Render::DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture) { Render *v5; // edi@1 unsigned int v6; // ebx@1 @@ -4422,10 +1867,10 @@ if ( v7->std__vector_000004_size) a2 = 0xFFFFFFFF; pGame->AlterGamma_ODM(a4, &a2); - if ( byte_4D864C && pGame->uFlags & 1 ) + if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) { v8 = ::GetActorTintColor(a3->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); - v7->_45D74F_MessWithLight(v8, 0); + v7->DrawLightmaps(/*v8, 0*/); } else { @@ -4517,7 +1962,7 @@ //v50 = (const char *)v5->pRenderD3D->pDevice; ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); //(*(void (**)(void))(*(int *)v50 + 88))(); - v53->_45D74F_MessWithLight(-1, 0); + v53->DrawLightmaps(/*-1, 0*/); for (uint i = 0; i < uNumVertices; ++i) { d3d_vertex_buffer[i].diffuse = a2; @@ -5025,7 +2470,9 @@ Dst = 124; if ( !pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, (DDSURFACEDESC2 *)&Dst, DDLOCK_WAIT) ) return; + __debugbreak(); // warning C4700: uninitialized local variable 'v20' used v42 = v20; + __debugbreak(); // warning C4700: uninitialized local variable 'v19' used v6 = v19 >> 1; v3 = 0; } @@ -5306,7 +2753,7 @@ //----- (0049F8B5) -------------------------------------------------------- FILE *Render::SavePCXImage(const char *Filename, char *a3, int a4, int a5) { - Render *v5; // esi@1 + //Render *v5; // esi@1 FILE *result; // eax@1 FILE *v7; // edi@4 int v8; // ecx@5 @@ -5328,7 +2775,6 @@ int v24; // [sp+9Ch] [bp-8h]@2 char *i; // [sp+A0h] [bp-4h]@8 - v5 = this; result = fopen(Filename, "wb"); Filename = (const char *)result; if ( result ) @@ -5389,16 +2835,16 @@ i = (char *)ptr + 2 * v24; do { - *((char *)ptr + v10) = (signed int)(v5->uTargetRMask & *(short *)a5) >> (LOBYTE(v5->uTargetGBits) - + LOBYTE(v5->uTargetBBits) - + v5->uTargetRBits + *((char *)ptr + v10) = (signed int)(this->uTargetRMask & *(short *)a5) >> (LOBYTE(this->uTargetGBits) + + LOBYTE(this->uTargetBBits) + + this->uTargetRBits - 8); - a3[v10] = (signed int)(v5->uTargetGMask & *(short *)a5) >> (LOBYTE(v5->uTargetBBits) - + LOBYTE(v5->uTargetGBits) + a3[v10] = (signed int)(this->uTargetGMask & *(short *)a5) >> (LOBYTE(this->uTargetBBits) + + LOBYTE(this->uTargetGBits) - 8); v11 = a5; a5 += 2; - i[v10++] = (v5->uTargetBMask & *(char *)v11) << (8 - LOBYTE(v5->uTargetBBits)); + i[v10++] = (this->uTargetBMask & *(char *)v11) << (8 - LOBYTE(this->uTargetBBits)); } while ( v10 < a4 ); } @@ -6743,6 +4189,7 @@ pFrontBuffer = (IDirectDrawSurface *)v1->pFrontBuffer2; ppBackBuffer = (IDirectDrawSurface **)&v1->pBackBuffer2; } + __debugbreak(); // warning C4700: uninitialized local variable 'v6' used v9 = (int)v6; v10 = pFrontBuffer; // BUG @@ -7079,10 +4526,7 @@ pRenderD3D->ClearTarget(true, 0x00F08020, true, 1.0); pRenderer->uNumBillboardsToDraw = 0; pRenderD3D->pDevice->BeginScene(); - if (!pRenderD3D->DoesRaiseExceptions()) - { - MessageBoxW(nullptr, L"Error executing scratch 3D operations", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\screen16_3d.cpp:360", 0); - } + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) uFogColor = GetLevelFogColor(); else @@ -7137,7 +4581,7 @@ return ::GetActorTintColor(tint, a4, a2, a5, a6); } -/*void Render::DrawTerrainPolygon_new(stru148 *a3, IDirect3DTexture2 *pTexture)//new function +/*void Render::DrawTerrainPolygon_new(Polygon *a3, IDirect3DTexture2 *pTexture)//new function { int v5; // ebx@1 int v6; // edi@1 @@ -7252,7 +4696,7 @@ }*/ //----- (004A26BC) -------------------------------------------------------- -void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) +void Render::DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders) { //RenderVertexSoft *pVertices; // esi@0 //int v7; // edi@1 @@ -7330,10 +4774,10 @@ /* v9 = pGame->pLightmapBuilder; v65 = v9; v10 = v9->std__vector_000004_size;*/ - if ( byte_4D864C && pGame->uFlags & 1 ) + if ( byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) { v11 = ::GetActorTintColor(a4->dimming_level, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); - pGame->pLightmapBuilder->_45D74F_MessWithLight(v11, 0); + pGame->pLightmapBuilder->DrawLightmaps(/*v11, 0*/); } else { @@ -7409,6 +4853,7 @@ { d3d_vertex_buffer[i].specular = 0; } + __debugbreak(); // warning C4700: uninitialized local variable 'v20' used d3d_vertex_buffer[i].specular = v20; d3d_vertex_buffer[i].texcoord.x = array_50AC10[i].u; d3d_vertex_buffer[i].texcoord.y = array_50AC10[i].v; @@ -7427,7 +4872,7 @@ //v63 = (const char *)v7->pRenderD3D->pDevice; ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); //(*(void (**)(void))(*(int *)v63 + 88))(); - pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); + pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); for (uint i = 0; i < uNumVertices; ++i) { d3d_vertex_buffer[i].diffuse = -1; @@ -7484,11 +4929,9 @@ // 4D864C: using guessed type char byte_4D864C; //----- (004A2DA3) -------------------------------------------------------- -void Render::DrawSkyPolygon(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture) +void Render::DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture) { int v7; // eax@7 - float v13; // ST3C_4@8 - int i; if ( !this->uNumD3DSceneBegins ) return; @@ -7501,7 +4944,7 @@ this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE); this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO); } - for ( i = 0; i < uNumVertices; ++i ) + for ( uint i = 0; i < uNumVertices; ++i ) { pVertices[i].pos.x = array_50AC10[i].vWorldViewProjX; pVertices[i].pos.y = array_50AC10[i].vWorldViewProjY; @@ -7511,10 +4954,7 @@ pVertices[i].diffuse = ::GetActorTintColor(31, 0, array_50AC10[i].vWorldViewPosition.x, 1, 0); v7 = 0; if (this->bUsingSpecular) - { - v13 = array_50AC10[i].vWorldViewPosition.x; - v7 = sub_47C3D7_get_fog_related_stuff(0, 1, v13); - } + v7 = sub_47C3D7_get_fog_related_stuff(0, 1, array_50AC10[i].vWorldViewPosition.x); pVertices[i].specular = v7; pVertices[i].texcoord.x = array_50AC10[i].u; pVertices[i].texcoord.y = array_50AC10[i].v; @@ -7526,7 +4966,7 @@ } //----- (004A2ED5) -------------------------------------------------------- -void Render::_4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex) +void Render::_4A2ED5(signed int a2, struct Polygon *a3, IDirect3DTexture2 *pHwTex) { signed int v4; // edi@2 int v5; // eax@3 @@ -7569,6 +5009,433 @@ } } + +//----- (00479A53) -------------------------------------------------------- +void Render::DrawIndoorPolygonNoLight(unsigned int uNumVertices, unsigned int uFaceID) +{ + BLVFace *pFace; // esi@1 + unsigned int v3; // edi@1 + PolygonType v4; // al@1 + double v5; // st7@3 + signed __int64 v6; // qax@3 + PolygonType v7; // cl@3 + int v8; // esi@7 + int v9; // eax@7 + unsigned int v10; // eax@7 + double v11; // st6@7 + int v12; // edx@7 + int v13; // eax@7 + char *v14; // esi@8 + void *v15; // ecx@9 + int v16; // eax@9 + int v17; // edi@9 + double v18; // st7@9 + signed int v19; // ebx@9 + void *v20; // ecx@9 + int v21; // ebx@11 + int v22; // eax@14 + signed __int64 v23; // qtt@16 + double v24; // st7@16 + unsigned __int8 v25; // sf@16 + unsigned __int8 v26; // of@16 + Render *v27; // ecx@17 + double v28; // st7@20 + char *v29; // ebx@20 + char *v30; // edx@20 + unsigned __int8 v31; // c0@21 + unsigned __int8 v32; // c3@21 + double v33; // st6@23 + char *v34; // esi@30 + const void *v35; // ecx@31 + int v36; // eax@31 + const void *v37; // edi@31 + signed __int64 v38; // qax@31 + int v39; // ecx@31 + int v40; // ebx@33 + int v41; // eax@36 + signed __int64 v42; // qtt@39 + int v43; // eax@39 + char v44; // zf@39 + double v45; // st7@39 + double v46; // st7@39 + unsigned int v47; // edx@40 + double v48; // st7@41 + RenderVertexSoft *v49; // ebx@41 + void *v50; // edi@43 + double v51; // st7@46 + RenderVertexSoft *v52; // edx@46 + void *v53; // edi@48 + char *v54; // ebx@52 + unsigned int v55; // eax@53 + unsigned int v56; // eax@55 + int v57; // ST10_4@55 + Texture *v58; // eax@55 + signed int v59; // [sp-4h] [bp-178h]@17 + struct Polygon *v60; // [sp+0h] [bp-174h]@17 + IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 + struct Polygon v62; // [sp+14h] [bp-160h]@6 + unsigned int v63; // [sp+120h] [bp-54h]@7 + double v64; // [sp+124h] [bp-50h]@7 + unsigned int v65; // [sp+128h] [bp-4Ch]@1 + unsigned int v66; // [sp+12Ch] [bp-48h]@7 + float v67; // [sp+130h] [bp-44h]@7 + __int64 v68; // [sp+134h] [bp-40h]@3 + __int64 v69; // [sp+13Ch] [bp-38h]@3 + int v70; // [sp+144h] [bp-30h]@3 + int X; // [sp+148h] [bp-2Ch]@9 + int v72; // [sp+14Ch] [bp-28h]@7 + float v73; // [sp+150h] [bp-24h]@16 + unsigned int v74; // [sp+154h] [bp-20h]@3 + RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 + float v76; // [sp+15Ch] [bp-18h]@9 + int v77; // [sp+160h] [bp-14h]@9 + int v78; // [sp+164h] [bp-10h]@7 + void *v79; // [sp+168h] [bp-Ch]@9 + float v80; // [sp+16Ch] [bp-8h]@3 + const void *v81; // [sp+170h] [bp-4h]@7 + + __debugbreak(); + + pFace = &pIndoor->pFaces[uFaceID]; + v65 = uFaceID; + v3 = uNumVertices; + v4 = pFace->uPolygonType; + if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor ) + { + if ( (signed int)uNumVertices > 0 ) + { + v54 = (char *)&array_507D30[0].u; + LODWORD(v80) = uNumVertices; + do + { + v69 = (GetTickCount() >> 5) - pBLVRenderParams->vPartyPos.x; + *(float *)v54 = (double)v69 + *(float *)v54; + *(float *)v54 = *(float *)v54 * 0.25; + v55 = GetTickCount(); + v54 += 48; + v44 = LODWORD(v80)-- == 1; + v68 = pBLVRenderParams->vPartyPos.y + (v55 >> 5); + *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25; + } + while ( !v44 ); + uFaceID = v65; + } + v56 = 8 * uFaceID; + LOBYTE(v56) = PID(OBJECT_BModel,uFaceID); + v57 = v56; + v58 = pFace->GetTexture(); + pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0); + return; + } + HIDWORD(v69) = pIndoorCamera->sRotationX; + HIDWORD(v68) = pIndoorCamera->pos.z; + *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY; + v70 = (signed __int64)((double)(pBLVRenderParams->field_40 * pBLVRenderParams->vPartyPos.z) + / (((double)pBLVRenderParams->field_40 + 16192.0) + * 65536.0) + + *(float *)&v74); + v5 = (double)pIndoorCamera->sRotationX * 0.0030664064; + *(float *)&v75 = v5; + v80 = cos(v5) * 16192.0; + v6 = (signed __int64)(*(float *)&v74 + - (double)pBLVRenderParams->field_40 + / ((v80 + 0.0000001) + * 65535.0) + * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68))); + v7 = pFace->uPolygonType; + if ( v7 == 4 || v7 == 3 ) + v70 = v6; + stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0); + v62.Create_48607B(&stru_8019C8); + v62.uTileBitmapID = pFace->uBitmapID; + v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0); + if ( !v62.pTexture ) + return; + v8 = pBLVRenderParams->sPartyRotX; + v62.dimming_level = 0; + v62.uNumVertices = v3; + v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX + 16); + v62.v_18.y = 0; + v62.v_18.x = -v9; + v62.v_18.z = -stru_5C6E00->Cos(v8 + 16); + v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX; + memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3])); + LODWORD(v80) = v10; + v62.field_24 = 33554432; + v64 = (double)(signed int)v10 * 0.5; + v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); + LODWORD(v80) = v62.pTexture->uTextureWidth; + v11 = 1.0 / (double)SLODWORD(v80); + LODWORD(v80) = v62.pTexture->uTextureHeight; + v12 = v62.pTexture->uWidthMinus1; + v13 = v62.pTexture->uHeightMinus1; + v67 = v11; + v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; + v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; + v78 = 0; + v81 = 0; + *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80); + if ( (signed int)v62.uNumVertices <= 0 ) + { +LABEL_17: + v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]; + v27 = pRenderer; + v60 = &v62; + v59 = v62.uNumVertices; + goto LABEL_18; + } + v14 = (char *)&array_507D30[0].vWorldViewProjY; + while ( 2 ) + { + v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14)); + LODWORD(v80) = v62.ptr_38->field_14; + v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16; + v16 = v77 + v62.ptr_38->field_C; + v77 = (int)v15; + v74 = v16; + LODWORD(v80) = v62.ptr_38->field_20; + v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16; + v79 = v15; + v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18); + LODWORD(v80) = v62.v_18.z; + v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16); + v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1)); + v18 = *(float *)v14 - 1.0; + v19 = -v62.field_24; + v77 = -v62.field_24; + X = (int)((char *)v79 + v62.v_18.x); + LODWORD(v76) = (signed __int64)v18; + v20 = (void *)(v72 * (v70 - LODWORD(v76))); + while ( 1 ) + { + v79 = v20; + if ( !X ) + goto LABEL_14; + v21 = abs(v19 >> 14); + if ( v21 <= abs(X) ) + break; + if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) + break; + v19 = v77; + v20 = v79; +LABEL_14: + LODWORD(v80) = v62.v_18.z; + v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16); + v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16; + --LODWORD(v76); + v20 = (char *)v20 + v72; + X = v22 + v62.v_18.x; + v78 = 1; + } + if ( !v78 ) + { + LODWORD(v23) = v77 << 16; + HIDWORD(v23) = v77 >> 16; + v79 = (void *)(v23 / X); + v77 = v17; + LODWORD(v80) = v62.ptr_38->field_10; + v77 = v17; + LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16); + LODWORD(v80) = v62.ptr_38->field_1C; + v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16)); + v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16; + LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16; + v14 += 48; + LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4); + v81 = (char *)v81 + 1; + v24 = (double)SLODWORD(v80) * 0.000015259022; + LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4); + v26 = __OFSUB__((int)v81, v62.uNumVertices); + v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0; + *((float *)v14 - 10) = v24 * v67; + *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1); + *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79; + if ( !(v25 ^ v26) ) + goto LABEL_17; + continue; + } + break; + } + LODWORD(v73) = 0; + v80 = v76; + if ( (signed int)v62.uNumVertices > 0 ) + { + v28 = (double)SLODWORD(v76); + LODWORD(v76) = (int)(char *)array_50AC10 + 28; + v29 = (char *)&array_50AC10[0].vWorldViewProjX; + v30 = (char *)&array_507D30[1].vWorldViewProjY; + v79 = array_50AC10; + v81 = array_507D30; + v78 = v62.uNumVertices; + do + { + v31 = v28 < *((float *)v30 - 12); + v32 = v28 == *((float *)v30 - 12); + ++LODWORD(v73); + memcpy(v79, v81, 0x30u); + v79 = (char *)v79 + 48; + LODWORD(v76) += 48; + v29 += 48; + if ( v31 | v32 || v28 >= *(float *)v30 ) + { + if ( v28 >= *((float *)v30 - 12) || v28 <= *(float *)v30 ) + goto LABEL_28; + v33 = (*((float *)v30 - 1) - *((float *)v30 - 13)) * v28 / (*(float *)v30 - *((float *)v30 - 12)) + + *((float *)v30 - 1); + } + else + { + v33 = (*((float *)v30 - 13) - *((float *)v30 - 1)) * v28 / (*((float *)v30 - 12) - *(float *)v30) + + *((float *)v30 - 13); + } + *(float *)v29 = v33; + v79 = (char *)v79 + 48; + v29 += 48; + ++LODWORD(v73); + *(unsigned int *)LODWORD(v76) = v28; + LODWORD(v76) += 48; +LABEL_28: + v81 = (char *)v81 + 48; + v30 += 48; + --v78; + } + while ( v78 ); + } + if ( SLODWORD(v73) <= 0 ) + goto LABEL_40; + v34 = (char *)&array_50AC10[0].vWorldViewProjY; + v65 = v77 >> 14; + HIDWORD(v69) = LODWORD(v73); + do + { + v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v34)); + v78 = v62.ptr_38->field_14; + v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16); + v36 = (int)((char *)v81 + v62.ptr_38->field_C); + v81 = v35; + v74 = v36; + v78 = v62.ptr_38->field_20; + v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16); + v78 = (int)v35; + v75 = (RenderVertexSoft *)((char *)v81 + v62.ptr_38->field_18); + v81 = (const void *)v62.v_18.z; + v78 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v35) >> 16; + v37 = (const void *)(v72 + * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v34 - 1))); + v38 = (signed __int64)(*(float *)v34 - 1.0); + v81 = 0; + LODWORD(v76) = v38; + v39 = v72 * (v70 - v38); + while ( 1 ) + { + v78 = v39; + if ( !X ) + goto LABEL_36; + v40 = abs(X); + if ( abs((signed __int64)v65) <= v40 ) + break; + if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) + break; + v39 = v78; +LABEL_36: + v78 = v62.v_18.z; + v41 = (unsigned __int64)(v62.v_18.z * (signed __int64)v39) >> 16; + --LODWORD(v76); + v39 += v72; + X = v41 + v62.v_18.x; + v81 = (const void *)1; + } + if ( v81 ) + { + v79 = (void *)v62.v_18.z; + v78 = 2 * LODWORD(v76); + v81 = (const void *)((unsigned __int64)(v62.v_18.z + * (signed __int64)(signed int)(signed __int64)(((double)v70 + - ((double)(2 * LODWORD(v76)) + - *(float *)v34)) + * (double)v72)) >> 16); + X = (int)((char *)v81 + v62.v_18.x); + } + LODWORD(v42) = v77 << 16; + HIDWORD(v42) = v77 >> 16; + v79 = (void *)(v42 / X); + v81 = v37; + v78 = v62.ptr_38->field_10; + v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16); + v43 = v74 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16); + v74 = (unsigned int)v37; + LODWORD(v76) = v43; + v78 = v62.ptr_38->field_1C; + v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16)); + v74 = (unsigned __int64)(v43 * v42 / X) >> 16; + v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16); + v34 += 48; + v78 = v66 + ((signed int)v74 >> 4); + v44 = HIDWORD(v69)-- == 1; + v45 = (double)v78 * 0.000015259022; + v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4); + *((float *)v34 - 10) = v45 * v67; + *((float *)v34 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1); + v46 = (double)(signed int)v79; + *((float *)v34 - 16) = 0.000015258789 * v46; + *((float *)v34 - 11) = 65536.0 / v46; + } + while ( !v44 ); +LABEL_40: + v47 = 0; + if ( SLODWORD(v73) > 0 ) + { + v48 = (double)SLODWORD(v80); + v75 = array_507D30; + v49 = array_50AC10; + HIDWORD(v69) = LODWORD(v73); + do + { + if ( v48 >= v49->vWorldViewProjY ) + { + v50 = v75; + ++v47; + ++v75; + memcpy(v50, v49, 0x30u); + } + ++v49; + --HIDWORD(v69); + } + while ( HIDWORD(v69) ); + } + v62.uNumVertices = v47; + pRenderer->_4A2ED5(v47, &v62, pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]); + *(float *)&v74 = 0.0; + if ( SLODWORD(v73) > 0 ) + { + v51 = (double)SLODWORD(v80); + v75 = array_507D30; + v52 = array_50AC10; + v80 = v73; + do + { + if ( v51 <= v52->vWorldViewProjY ) + { + v53 = v75; + ++v74; + ++v75; + memcpy(v53, v52, 0x30u); + } + ++v52; + --LODWORD(v80); + } + while ( v80 != 0.0 ); + } + v62.uNumVertices = v74; + v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]; + v60 = &v62; + v59 = v74; + v27 = pRenderer; +LABEL_18: + v27->_4A2ED5(v59, v60, v61); +} + + //----- (004A2FC0) -------------------------------------------------------- void Render::DrawIndoorPolygon(unsigned int uNumVertices, BLVFace *pFace, IDirect3DTexture2 *pHwTex, Texture *pTex, int uPackedID, unsigned int uColor, int a8) { @@ -7628,7 +5495,7 @@ else uColor = uCorrectedColor = 0xFF109010; } - if (byte_4D864C && pGame->uFlags & 1) + if (byte_4D864C && pGame->uFlags & GAME_FLAGS_1_01) { __debugbreak(); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); @@ -7653,7 +5520,7 @@ d3d_vertex_buffer, uNumVertices, 28)); - pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); + pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); } else { @@ -7733,7 +5600,7 @@ 28)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); - pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); + pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); for (uint i = 0; i < uNumVertices; ++i) d3d_vertex_buffer[i].diffuse = uCorrectedColor; @@ -7841,54 +5708,54 @@ v12 = ::GetActorTintColor(dimming_level, 0, pSoftBillboard->zbuffer_depth, 0, 0); } //v13 = (double)v25; - pBillboardRenderListD3D[v7].pQuards[0].specular = 0; - pBillboardRenderListD3D[v7].pQuards[0].diffuse = v12; - pBillboardRenderListD3D[v7].pQuards[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; + pBillboardRenderListD3D[v7].pQuads[0].specular = 0; + pBillboardRenderListD3D[v7].pQuads[0].diffuse = v12; + pBillboardRenderListD3D[v7].pQuads[0].pos.x = pSoftBillboard->uScreenSpaceX - v31 * a1; //v14 = (double)v24; //v32 = v14; - pBillboardRenderListD3D[v7].pQuards[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; + pBillboardRenderListD3D[v7].pQuads[0].pos.y = pSoftBillboard->uScreenSpaceY - v27 * v29; v15 = 1.0 - 1.0 / (pSoftBillboard->zbuffer_depth * 0.061758894); - pBillboardRenderListD3D[v7].pQuards[0].pos.z = v15; + pBillboardRenderListD3D[v7].pQuads[0].pos.z = v15; v16 = 1.0 / pSoftBillboard->zbuffer_depth; - pBillboardRenderListD3D[v7].pQuards[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; - pBillboardRenderListD3D[v7].pQuards[0].texcoord.x = 0.0; - pBillboardRenderListD3D[v7].pQuards[0].texcoord.y = 0.0; + pBillboardRenderListD3D[v7].pQuads[0].rhw = 1.0 / pSoftBillboard->zbuffer_depth; + pBillboardRenderListD3D[v7].pQuads[0].texcoord.x = 0.0; + pBillboardRenderListD3D[v7].pQuads[0].texcoord.y = 0.0; v17 = (double)((pSprite->uBufferWidth >> 1) - pSprite->uAreaX); v18 = (double)(pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight); if ( pSoftBillboard->uFlags & 4 ) v17 = v17 * -1.0; - pBillboardRenderListD3D[v7].pQuards[1].specular = 0; - pBillboardRenderListD3D[v7].pQuards[1].diffuse = v12; - pBillboardRenderListD3D[v7].pQuards[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; - pBillboardRenderListD3D[v7].pQuards[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; - pBillboardRenderListD3D[v7].pQuards[1].pos.z = v15; - pBillboardRenderListD3D[v7].pQuards[1].rhw = v16; - pBillboardRenderListD3D[v7].pQuards[1].texcoord.x = 0.0; - pBillboardRenderListD3D[v7].pQuards[1].texcoord.y = 1.0; + pBillboardRenderListD3D[v7].pQuads[1].specular = 0; + pBillboardRenderListD3D[v7].pQuads[1].diffuse = v12; + pBillboardRenderListD3D[v7].pQuads[1].pos.x = pSoftBillboard->uScreenSpaceX - v17 * a1; + pBillboardRenderListD3D[v7].pQuads[1].pos.y = pSoftBillboard->uScreenSpaceY - v18 * v29; + pBillboardRenderListD3D[v7].pQuads[1].pos.z = v15; + pBillboardRenderListD3D[v7].pQuads[1].rhw = v16; + pBillboardRenderListD3D[v7].pQuads[1].texcoord.x = 0.0; + pBillboardRenderListD3D[v7].pQuads[1].texcoord.y = 1.0; v19 = pSprite->uBufferHeight - pSprite->uAreaY - pSprite->uAreaHeight; v20 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); if ( pSoftBillboard->uFlags & 4 ) v20 = v20 * -1.0; - pBillboardRenderListD3D[v7].pQuards[2].specular = 0; - pBillboardRenderListD3D[v7].pQuards[2].diffuse = v12; - pBillboardRenderListD3D[v7].pQuards[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; - pBillboardRenderListD3D[v7].pQuards[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; - pBillboardRenderListD3D[v7].pQuards[2].pos.z = v15; - pBillboardRenderListD3D[v7].pQuards[2].rhw = v16; - pBillboardRenderListD3D[v7].pQuards[2].texcoord.x = 1.0; - pBillboardRenderListD3D[v7].pQuards[2].texcoord.y = 1.0; + pBillboardRenderListD3D[v7].pQuads[2].specular = 0; + pBillboardRenderListD3D[v7].pQuads[2].diffuse = v12; + pBillboardRenderListD3D[v7].pQuads[2].pos.x = v20 * a1 + pSoftBillboard->uScreenSpaceX; + pBillboardRenderListD3D[v7].pQuads[2].pos.y = pSoftBillboard->uScreenSpaceY - (double)v19 * v29; + pBillboardRenderListD3D[v7].pQuads[2].pos.z = v15; + pBillboardRenderListD3D[v7].pQuads[2].rhw = v16; + pBillboardRenderListD3D[v7].pQuads[2].texcoord.x = 1.0; + pBillboardRenderListD3D[v7].pQuads[2].texcoord.y = 1.0; v21 = pSprite->uBufferHeight - pSprite->uAreaY; v22 = (double)(pSprite->uAreaX + pSprite->uAreaWidth + (pSprite->uBufferWidth >> 1) - pSprite->uBufferWidth); if ( pSoftBillboard->uFlags & 4 ) v22 = v22 * -1.0; - pBillboardRenderListD3D[v7].pQuards[3].specular = 0; - pBillboardRenderListD3D[v7].pQuards[3].diffuse = v12; - pBillboardRenderListD3D[v7].pQuards[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; - pBillboardRenderListD3D[v7].pQuards[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; - pBillboardRenderListD3D[v7].pQuards[3].pos.z = v15; - pBillboardRenderListD3D[v7].pQuards[3].rhw = v16; - pBillboardRenderListD3D[v7].pQuards[3].texcoord.x = 1.0; - pBillboardRenderListD3D[v7].pQuards[3].texcoord.y = 0.0; + pBillboardRenderListD3D[v7].pQuads[3].specular = 0; + pBillboardRenderListD3D[v7].pQuads[3].diffuse = v12; + pBillboardRenderListD3D[v7].pQuads[3].pos.x = v22 * a1 + pSoftBillboard->uScreenSpaceX; + pBillboardRenderListD3D[v7].pQuads[3].pos.y = pSoftBillboard->uScreenSpaceY - (double)v21 * v29; + pBillboardRenderListD3D[v7].pQuads[3].pos.z = v15; + pBillboardRenderListD3D[v7].pQuads[3].rhw = v16; + pBillboardRenderListD3D[v7].pQuads[3].texcoord.x = 1.0; + pBillboardRenderListD3D[v7].pQuads[3].texcoord.y = 0.0; //v23 = pSprite->pTexture; pBillboardRenderListD3D[v7].uNumVertices = 4; pBillboardRenderListD3D[v7].z_order = pSoftBillboard->zbuffer_depth; @@ -7967,7 +5834,7 @@ v19 = stru_5C6E00->Sin(angle); v20 = stru_5C6E00->Sin(angle); v21 = stru_5C6E00->Cos(angle); - pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 + pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 + (double)(v18 >> 16)) * v16 - ((double)(unsigned __int16)v19 * 0.000015259022 @@ -7979,20 +5846,20 @@ - 12.0) * v11 + (double)a2->uScreenSpaceY; - pBillboardRenderListD3D[v8].pQuards[0].specular = 0; - pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; - pBillboardRenderListD3D[v8].pQuards[0].pos.y = v22; - pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); - pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; - pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; - pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; + pBillboardRenderListD3D[v8].pQuads[0].specular = 0; + pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; + pBillboardRenderListD3D[v8].pQuads[0].pos.y = v22; + pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 0.061758894); + pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; + pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; + pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; v31 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; v32 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); v25 = stru_5C6E00->Cos(angle); v26 = stru_5C6E00->Sin(angle); v27 = stru_5C6E00->Sin(angle); v28 = stru_5C6E00->Cos(angle); - pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 + pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v25 * 0.000015259022 + (double)(v25 >> 16)) * v31 - ((double)(unsigned __int16)v26 * 0.000015259022 @@ -8004,47 +5871,47 @@ - 12.0) * v11 + (double)a2->uScreenSpaceY; - pBillboardRenderListD3D[v8].pQuards[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuards[0].pos.z; - v30 = pBillboardRenderListD3D[v8].pQuards[0].rhw; - pBillboardRenderListD3D[v8].pQuards[1].pos.y = v29; - pBillboardRenderListD3D[v8].pQuards[1].specular = 0; - pBillboardRenderListD3D[v8].pQuards[1].rhw = v30; - pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; - pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; - pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; + pBillboardRenderListD3D[v8].pQuads[1].pos.z = pRenderer->pBillboardRenderListD3D[v8].pQuads[0].pos.z; + v30 = pBillboardRenderListD3D[v8].pQuads[0].rhw; + pBillboardRenderListD3D[v8].pQuads[1].pos.y = v29; + pBillboardRenderListD3D[v8].pQuads[1].specular = 0; + pBillboardRenderListD3D[v8].pQuads[1].rhw = v30; + pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; + pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; + pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; v23 = (double)(a2->uScreenSpaceX - 12) - (double) a2->uScreenSpaceX; v24 = (double)a2->uScreenSpaceY - (double)(a2->uScreenSpaceY - 12); v33 = stru_5C6E00->Cos(angle); v34 = stru_5C6E00->Sin(angle); v35 = stru_5C6E00->Sin(angle); v36 = stru_5C6E00->Cos(angle); - pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 + pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v33 * 0.000015259022 + (double)(v33 >> 16)) * v23 - ((double)(unsigned __int16)v34 * 0.000015259022 + (double)(v34 >> 16)) * v24) * v11 + (double) a2->uScreenSpaceX; - v37 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; + v37 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; v38 = (((double)(unsigned __int16)v36 * 0.000015259022 + (double)(v36 >> 16)) * v24 + ((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v23 - 12.0) * v11 + (double)a2->uScreenSpaceY; - pBillboardRenderListD3D[v8].pQuards[2].specular = 0; - pBillboardRenderListD3D[v8].pQuards[2].pos.z = v37; - pBillboardRenderListD3D[v8].pQuards[2].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; - pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; - pBillboardRenderListD3D[v8].pQuards[2].pos.y = v38; - pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; - pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; + pBillboardRenderListD3D[v8].pQuads[2].specular = 0; + pBillboardRenderListD3D[v8].pQuads[2].pos.z = v37; + pBillboardRenderListD3D[v8].pQuads[2].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; + pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; + pBillboardRenderListD3D[v8].pQuads[2].pos.y = v38; + pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; + pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; v39 = (double)(a2->uScreenSpaceX + 12) - (double) a2->uScreenSpaceX; v40 = (double)(a2->uScreenSpaceY - 25) - (double)(a2->uScreenSpaceY - 12); v41 = stru_5C6E00->Cos(angle); v42 = stru_5C6E00->Sin(angle); v43 = stru_5C6E00->Sin(angle); v44 = stru_5C6E00->Cos(angle); - pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 + pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v41 * 0.000015259022 + (double)(v41 >> 16)) * v39 - ((double)(unsigned __int16)v42 * 0.000015259022 @@ -8056,17 +5923,17 @@ - 12.0) * v11 + (double)a2->uScreenSpaceY; - v46 = pBillboardRenderListD3D[v8].pQuards[0].pos.z; - pBillboardRenderListD3D[v8].pQuards[3].specular = 0; - pBillboardRenderListD3D[v8].pQuards[3].pos.z = v46; - pBillboardRenderListD3D[v8].pQuards[3].rhw = pBillboardRenderListD3D[v8].pQuards[0].rhw; - pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; + v46 = pBillboardRenderListD3D[v8].pQuads[0].pos.z; + pBillboardRenderListD3D[v8].pQuads[3].specular = 0; + pBillboardRenderListD3D[v8].pQuads[3].pos.z = v46; + pBillboardRenderListD3D[v8].pQuads[3].rhw = pBillboardRenderListD3D[v8].pQuads[0].rhw; + pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; pBillboardRenderListD3D[v8].pTexture = a3; pBillboardRenderListD3D[v8].z_order = a2->zbuffer_depth; pBillboardRenderListD3D[v8].uNumVertices = 4; - pBillboardRenderListD3D[v8].pQuards[3].pos.y = v45; - pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; - pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; + pBillboardRenderListD3D[v8].pQuads[3].pos.y = v45; + pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; + pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; } } } @@ -8141,7 +6008,7 @@ v20 = stru_5C6E00->Sin(angle); v21 = stru_5C6E00->Sin(angle); v22 = stru_5C6E00->Cos(angle); - pBillboardRenderListD3D[v8].pQuards[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 + pBillboardRenderListD3D[v8].pQuads[0].pos.x = (((double)(unsigned __int16)v18 * 0.000015259022 + (double)(v18 >> 16)) * v16 - ((double)(unsigned __int16)v20 * 0.000015259022 @@ -8153,22 +6020,22 @@ - 12.0) * v11 + (double)a2->uScreenSpaceY; - pBillboardRenderListD3D[v8].pQuards[0].specular = 0; - pBillboardRenderListD3D[v8].pQuards[0].diffuse = uDiffuse; - pBillboardRenderListD3D[v8].pQuards[0].pos.y = v23; + pBillboardRenderListD3D[v8].pQuads[0].specular = 0; + pBillboardRenderListD3D[v8].pQuads[0].diffuse = uDiffuse; + pBillboardRenderListD3D[v8].pQuads[0].pos.y = v23; v24 = 1.0 - 1.0 / (v6 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); - pBillboardRenderListD3D[v8].pQuards[0].pos.z = v24; + pBillboardRenderListD3D[v8].pQuads[0].pos.z = v24; v25 = 1.0 / v6; - pBillboardRenderListD3D[v8].pQuards[0].rhw = v25; - pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; - pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; + pBillboardRenderListD3D[v8].pQuads[0].rhw = v25; + pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; + pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; v26 = (double)(a2->uScreenSpaceX - 12) - v13; v27 = (double)a2->uScreenSpaceY - v15; v28 = stru_5C6E00->Cos(angle); v29 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); v30 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); v31 = stru_5C6E00->Cos(angle); - pBillboardRenderListD3D[v8].pQuards[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 + pBillboardRenderListD3D[v8].pQuads[1].pos.x = (((double)(unsigned __int16)v28 * 0.000015259022 + (double)(v28 >> 16)) * v26 - ((double)(unsigned __int16)v29 * 0.000015259022 @@ -8180,20 +6047,20 @@ - 12.0) * v11 + (double)a2->uScreenSpaceY; - pBillboardRenderListD3D[v8].pQuards[1].pos.z = v24; - pBillboardRenderListD3D[v8].pQuards[1].pos.y = v32; - pBillboardRenderListD3D[v8].pQuards[1].specular = 0; - pBillboardRenderListD3D[v8].pQuards[1].rhw = v25; - pBillboardRenderListD3D[v8].pQuards[1].diffuse = uDiffuse; - pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; - pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; + pBillboardRenderListD3D[v8].pQuads[1].pos.z = v24; + pBillboardRenderListD3D[v8].pQuads[1].pos.y = v32; + pBillboardRenderListD3D[v8].pQuads[1].specular = 0; + pBillboardRenderListD3D[v8].pQuads[1].rhw = v25; + pBillboardRenderListD3D[v8].pQuads[1].diffuse = uDiffuse; + pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; + pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; v33 = (double)(a2->uScreenSpaceX + 12) - v13; v34 = (double)a2->uScreenSpaceY - v15; v35 = stru_5C6E00->Cos(angle); v36 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); v37 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); v38 = stru_5C6E00->Cos(angle); - pBillboardRenderListD3D[v8].pQuards[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 + pBillboardRenderListD3D[v8].pQuads[2].pos.x = (((double)(unsigned __int16)v35 * 0.000015259022 + (double)(v35 >> 16)) * v33 - ((double)(unsigned __int16)v36 * 0.000015259022 @@ -8205,20 +6072,20 @@ - 12.0) * v11 + (double)a2->uScreenSpaceY; - pBillboardRenderListD3D[v8].pQuards[2].specular = 0; - pBillboardRenderListD3D[v8].pQuards[2].pos.z = v24; - pBillboardRenderListD3D[v8].pQuards[2].rhw = v25; - pBillboardRenderListD3D[v8].pQuards[2].diffuse = uDiffuse; - pBillboardRenderListD3D[v8].pQuards[2].pos.y = v39; - pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; - pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; + pBillboardRenderListD3D[v8].pQuads[2].specular = 0; + pBillboardRenderListD3D[v8].pQuads[2].pos.z = v24; + pBillboardRenderListD3D[v8].pQuads[2].rhw = v25; + pBillboardRenderListD3D[v8].pQuads[2].diffuse = uDiffuse; + pBillboardRenderListD3D[v8].pQuads[2].pos.y = v39; + pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; + pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; v40 = (double)(a2->uScreenSpaceX + 12) - v13; v41 = (double)(a2->uScreenSpaceY - 25) - v15; v42 = stru_5C6E00->Cos(angle); v43 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); v44 = stru_5C6E00->Sin(v19 + stru_5C6E00->uIntegerHalfPi); v45 = stru_5C6E00->Cos(angle); - pBillboardRenderListD3D[v8].pQuards[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 + pBillboardRenderListD3D[v8].pQuads[3].pos.x = (((double)(unsigned __int16)v42 * 0.000015259022 + (double)(v42 >> 16)) * v40 - ((double)(unsigned __int16)v43 * 0.000015259022 @@ -8230,16 +6097,16 @@ - 12.0) * v11 + (double)a2->uScreenSpaceY; - pBillboardRenderListD3D[v8].pQuards[3].specular = 0; - pBillboardRenderListD3D[v8].pQuards[3].pos.z = v24; - pBillboardRenderListD3D[v8].pQuards[3].rhw = v25; - pBillboardRenderListD3D[v8].pQuards[3].diffuse = uDiffuse; + pBillboardRenderListD3D[v8].pQuads[3].specular = 0; + pBillboardRenderListD3D[v8].pQuads[3].pos.z = v24; + pBillboardRenderListD3D[v8].pQuads[3].rhw = v25; + pBillboardRenderListD3D[v8].pQuads[3].diffuse = uDiffuse; pBillboardRenderListD3D[v8].pTexture = a3; pBillboardRenderListD3D[v8].z_order = v6; pBillboardRenderListD3D[v8].uNumVertices = 4; - pBillboardRenderListD3D[v8].pQuards[3].pos.y = v46; - pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; - pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; + pBillboardRenderListD3D[v8].pQuads[3].pos.y = v46; + pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; + pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; } } @@ -8287,53 +6154,53 @@ v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); if (a2->uFlags & 4) v14 *= -1.0; - pBillboardRenderListD3D[v8].pQuards[0].diffuse = diffuse; - pBillboardRenderListD3D[v8].pQuards[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; - pBillboardRenderListD3D[v8].pQuards[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; - pBillboardRenderListD3D[v8].pQuards[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); - pBillboardRenderListD3D[v8].pQuards[0].rhw = 1.0 / a2->zbuffer_depth; - pBillboardRenderListD3D[v8].pQuards[0].specular = specular; - pBillboardRenderListD3D[v8].pQuards[0].texcoord.x = 0.0; - pBillboardRenderListD3D[v8].pQuards[0].texcoord.y = 0.0; + pBillboardRenderListD3D[v8].pQuads[0].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuads[0].pos.x = (double)a2->uScreenSpaceX - v14 * v30; + pBillboardRenderListD3D[v8].pQuads[0].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuads[0].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuads[0].rhw = 1.0 / a2->zbuffer_depth; + pBillboardRenderListD3D[v8].pQuads[0].specular = specular; + pBillboardRenderListD3D[v8].pQuads[0].texcoord.x = 0.0; + pBillboardRenderListD3D[v8].pQuads[0].texcoord.y = 0.0; v14 = (double)((int)pSprite->uBufferWidth / 2 - pSprite->uAreaX); v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); if ( a2->uFlags & 4 ) v14 = v14 * -1.0; - pBillboardRenderListD3D[v8].pQuards[1].specular = specular; - pBillboardRenderListD3D[v8].pQuards[1].diffuse = diffuse; - pBillboardRenderListD3D[v8].pQuards[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; - pBillboardRenderListD3D[v8].pQuards[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; - pBillboardRenderListD3D[v8].pQuards[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); - pBillboardRenderListD3D[v8].pQuards[1].rhw = 1.0 / a2->zbuffer_depth; - pBillboardRenderListD3D[v8].pQuards[1].texcoord.x = 0.0; - pBillboardRenderListD3D[v8].pQuards[1].texcoord.y = 1.0; + pBillboardRenderListD3D[v8].pQuads[1].specular = specular; + pBillboardRenderListD3D[v8].pQuads[1].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuads[1].pos.x = (double)a2->uScreenSpaceX - v14 * v30; + pBillboardRenderListD3D[v8].pQuads[1].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuads[1].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuads[1].rhw = 1.0 / a2->zbuffer_depth; + pBillboardRenderListD3D[v8].pQuads[1].texcoord.x = 0.0; + pBillboardRenderListD3D[v8].pQuads[1].texcoord.y = 1.0; v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth); v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaHeight - pSprite->uAreaY); if ( a2->uFlags & 4 ) v14 *= -1.0; - pBillboardRenderListD3D[v8].pQuards[2].diffuse = diffuse; - pBillboardRenderListD3D[v8].pQuards[2].specular = specular; - pBillboardRenderListD3D[v8].pQuards[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; - pBillboardRenderListD3D[v8].pQuards[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; - pBillboardRenderListD3D[v8].pQuards[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); - pBillboardRenderListD3D[v8].pQuards[2].rhw = 1.0 / a2->zbuffer_depth; - pBillboardRenderListD3D[v8].pQuards[2].texcoord.x = 1.0; - pBillboardRenderListD3D[v8].pQuards[2].texcoord.y = 1.0; + pBillboardRenderListD3D[v8].pQuads[2].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuads[2].specular = specular; + pBillboardRenderListD3D[v8].pQuads[2].pos.x = (double)a2->uScreenSpaceX + v14 * v30; + pBillboardRenderListD3D[v8].pQuads[2].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuads[2].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuads[2].rhw = 1.0 / a2->zbuffer_depth; + pBillboardRenderListD3D[v8].pQuads[2].texcoord.x = 1.0; + pBillboardRenderListD3D[v8].pQuads[2].texcoord.y = 1.0; v14 = (double)((int)pSprite->uAreaWidth + pSprite->uAreaX + pSprite->uBufferWidth / 2 - pSprite->uBufferWidth); v15 = (double)((int)pSprite->uBufferHeight - pSprite->uAreaY); if ( a2->uFlags & 4 ) v14 *= -1.0; - pBillboardRenderListD3D[v8].pQuards[3].diffuse = diffuse; - pBillboardRenderListD3D[v8].pQuards[3].specular = specular; - pBillboardRenderListD3D[v8].pQuards[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; - pBillboardRenderListD3D[v8].pQuards[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; - pBillboardRenderListD3D[v8].pQuards[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); - pBillboardRenderListD3D[v8].pQuards[3].rhw = 1.0 / a2->zbuffer_depth; - pBillboardRenderListD3D[v8].pQuards[3].texcoord.x = 1.0; - pBillboardRenderListD3D[v8].pQuards[3].texcoord.y = 0.0; + pBillboardRenderListD3D[v8].pQuads[3].diffuse = diffuse; + pBillboardRenderListD3D[v8].pQuads[3].specular = specular; + pBillboardRenderListD3D[v8].pQuads[3].pos.x = (double)a2->uScreenSpaceX + v14 * v30; + pBillboardRenderListD3D[v8].pQuads[3].pos.y = (double)a2->uScreenSpaceY - v15 * v29; + pBillboardRenderListD3D[v8].pQuads[3].pos.z = 1.0 - 1.0 / (a2->zbuffer_depth * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + pBillboardRenderListD3D[v8].pQuads[3].rhw = 1.0 / a2->zbuffer_depth; + pBillboardRenderListD3D[v8].pQuads[3].texcoord.x = 1.0; + pBillboardRenderListD3D[v8].pQuads[3].texcoord.y = 0.0; pBillboardRenderListD3D[v8].uNumVertices = 4; pBillboardRenderListD3D[v8].pTexture = pSprite->pTexture; @@ -8509,79 +6376,54 @@ } //----- (004A4CC9) -------------------------------------------------------- -void Render::_4A4CC9(stru6_stru1_indoor_sw_billboard *a1, int a2) -{ - int v3; // eax@1 - int v4; // edx@3 +void Render::_4A4CC9_AddSomeBillboard(stru6_stru1_indoor_sw_billboard *a1, int diffuse) +{ unsigned int v5; // eax@7 - int v6; // edi@7 char *v7; // edx@8 - char *v8; // ecx@8 - char v9; // zf@9 double v10; // st6@9 double v11; // st6@10 int v12; // ebx@13 - int v13; // ecx@16 - unsigned int v14; // [sp+Ch] [bp-4h]@1 - - auto _this = this; - - *(float *)&v14 = 1000000.0; - v3 = a1->field_10; - if ( v3 >= 3 ) - { - if ( v3 > 0 ) - { - _this = (Render *)&a1->field_14[62]; - v4 = a1->field_10; - do - { - if ( *(float *)&this->bUserDirect3D < (double)*(float *)&v14 ) - v14 = this->bUserDirect3D; - _this = (Render *)((char *)_this + 16); - --v4; - } - while ( v4 ); - } - v5 = Billboard_ProbablyAddToListAndSortByZOrder(v14); - v6 = 0; - pBillboardRenderListD3D[v5].field_90 = 0; - pBillboardRenderListD3D[v5].uParentBillboardID = -1; - pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; - if ( a1->field_10 > 0 ) - { - v7 = (char *)&a1->field_14[62]; - v8 = (char *)&pBillboardRenderListD3D[v5].pQuards[0].pos.z; - do - { - v9 = uCurrentlyLoadedLevelType == LEVEL_Indoor; - *((int *)v8 - 2) = *((int *)v7 - 2); - *((int *)v8 - 1) = *((int *)v7 - 1); - v10 = *(float *)v7; - if ( v9 ) - v11 = v10 * 0.061758894; - else - v11 = v10 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; - *(float *)v8 = 1.0 - 1.0 / v11; - *((float *)v8 + 1) = 1.0 / *(float *)v7; - if ( a2 & 0xFF000000 ) - v12 = *((int *)v7 + 1); - else - v12 = a2; - *((int *)v8 + 3) = 0; - *((int *)v8 + 2) = v12; - ++v6; - v7 += 16; - *((float *)v8 + 4) = 0.0; - *((float *)v8 + 5) = 0.0; - v8 += 32; - } - while ( v6 < a1->field_10 ); - } - v13 = a1->field_10; - pBillboardRenderListD3D[v5].pTexture = 0; - pBillboardRenderListD3D[v5].uNumVertices = v13; - LODWORD(pBillboardRenderListD3D[v5].z_order) = v14; + + if (a1->uNumVertices < 3) + return; + + float depth = 1000000.0; + for (uint i = 0; i < a1->uNumVertices; ++i) + { + if (a1->field_104[i].z < depth) + depth = a1->field_104[i * 4].z; + } + + v5 = Billboard_ProbablyAddToListAndSortByZOrder(depth); + pBillboardRenderListD3D[v5].field_90 = 0; + pBillboardRenderListD3D[v5].uParentBillboardID = -1; + pBillboardRenderListD3D[v5].uOpacity = RenderBillboardD3D::Opaque_2; + pBillboardRenderListD3D[v5].pTexture = 0; + pBillboardRenderListD3D[v5].uNumVertices = a1->uNumVertices; + pBillboardRenderListD3D[v5].z_order = depth; + + for (uint i = 0; i < a1->uNumVertices; ++i) + { + pBillboardRenderListD3D[v5].pQuads[i].pos.x = a1->field_104[i].x; + pBillboardRenderListD3D[v5].pQuads[i].pos.y = a1->field_104[i].y; + + v10 = a1->field_104[i].z; + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + v11 = v10 * 0.061758894; + else + v11 = v10 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist; + pBillboardRenderListD3D[v5].pQuads[i].pos.z = 1.0 - 1.0 / v11; + pBillboardRenderListD3D[v5].pQuads[i].rhw = 1.0 / a1->field_104[i].z; + + if (diffuse & 0xFF000000) + v12 = a1->field_104[i].diffuse; + else + v12 = diffuse; + pBillboardRenderListD3D[v5].pQuads[i].diffuse = v12; + pBillboardRenderListD3D[v5].pQuads[i].specular = 0; + + pBillboardRenderListD3D[v5].pQuads[i].texcoord.x = 0.0; + pBillboardRenderListD3D[v5].pQuads[i].texcoord.y = 0.0; } } @@ -8854,6 +6696,8 @@ double v39; // [sp+94h] [bp-Ch]@6 float v40; // [sp+9Ch] [bp-4h]@6 + __debugbreak(); + auto ecx0 = this; v3 = 0; if ( ecx0->pRenderD3D ) @@ -10649,12 +8493,6 @@ // 6BE364: using guessed type int dword_6BE364_game_settings_1; // A74C88: using guessed type int dword_A74C88; -//----- (0044EC20) -------------------------------------------------------- -bool RenderD3D::DoesRaiseExceptions() -{ - return true; -} - //----- (004524D8) -------------------------------------------------------- HWLTexture *RenderHWLContainer::LoadTexture(const char *pName, int bMipMaps) @@ -10881,20 +8719,20 @@ auto p = &pRenderer->pBillboardRenderListD3D[0]; for (int i = 0; i < p->uNumVertices; ++i) { - p->pQuards[i].pos.z -= p->pQuards[i].pos.z * 0.6; - //p->pQuards[i].rhw = + 0.8 * (1.0f - p->pQuards[i].rhw); - } - p->pQuards[0].pos.x = 10; - p->pQuards[0].pos.y = 10; - - p->pQuards[1].pos.x = 10; - p->pQuards[1].pos.y = 200; - - p->pQuards[2].pos.x = 100; - p->pQuards[2].pos.y = 200; - - p->pQuards[3].pos.x = 100; - p->pQuards[3].pos.y = 10; + p->pQuads[i].pos.z -= p->pQuads[i].pos.z * 0.6; + //p->pQuads[i].rhw = + 0.8 * (1.0f - p->pQuads[i].rhw); + } + p->pQuads[0].pos.x = 10; + p->pQuads[0].pos.y = 10; + + p->pQuads[1].pos.x = 10; + p->pQuads[1].pos.y = 200; + + p->pQuads[2].pos.x = 100; + p->pQuads[2].pos.y = 200; + + p->pQuads[3].pos.x = 100; + p->pQuads[3].pos.y = 10; if (p->uOpacity != RenderBillboardD3D::NoBlend) SetBillboardBlendOptions(p->uOpacity); @@ -10902,7 +8740,7 @@ pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, - p->pQuards, p->uNumVertices, + p->pQuads, p->uNumVertices, D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); }*/ @@ -10917,7 +8755,7 @@ pRenderer->pRenderD3D->pDevice->SetTexture(0, p->pTexture); ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, - p->pQuards, p->uNumVertices, + p->pQuads, p->uNumVertices, D3DDP_DONOTLIGHT | D3DDP_DONOTUPDATEEXTENTS)); } @@ -10987,3 +8825,11 @@ { pRenderer->Present(); } + + + +//----- (0044EC20) -------------------------------------------------------- +/*bool RenderD3D::DoesRaiseExceptions() +{ + return true; +}*/ \ No newline at end of file
--- a/Render.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Render.h Tue Aug 06 00:56:33 2013 +0400 @@ -6,7 +6,7 @@ #include "VectorTypes.h" -struct stru148; +struct Polygon; struct Texture; struct RGBTexture; struct RenderBillboardTransform_local0; @@ -196,7 +196,7 @@ IDirect3DTexture2 *pTexture; unsigned int uNumVertices; - RenderVertexD3D3 pQuards[4]; + RenderVertexD3D3 pQuads[4]; float z_order; OpacityType uOpacity; int field_90; @@ -223,8 +223,6 @@ struct RenderD3D { RenderD3D(); - - static bool DoesRaiseExceptions(); void GetAvailableDevices(RenderD3D__DevInfo **pOutDevices); void Release(); @@ -320,18 +318,19 @@ void BeginSceneD3D(); void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); unsigned int GetActorTintColor(float a2, int tint, int a4, int a5, RenderBillboard *a6); - void DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture); - void DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders); - void DrawSkyPolygon(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *pTexture); - void _4A2ED5(signed int a2, stru148 *a3, IDirect3DTexture2 *pHwTex); + void DrawPolygon(unsigned int uNumVertices, struct Polygon *a3, ODMFace *a4, IDirect3DTexture2 *pTexture); + void DrawTerrainPolygon(unsigned int uNumVertices, struct Polygon *a4, IDirect3DTexture2 *a5, bool transparent, bool clampAtTextureBorders); + void DrawSkyPolygon(unsigned int uNumVertices, struct Polygon *pSkyPolygon, IDirect3DTexture2 *pTexture); + void _4A2ED5(signed int a2, struct Polygon *a3, IDirect3DTexture2 *pHwTex); void DrawIndoorPolygon(unsigned int uNumVertices, struct BLVFace *a3, IDirect3DTexture2 *pHwTex, struct Texture *pTex, int uPackedID, unsigned int uColor, int a8); + void DrawIndoorPolygonNoLight(unsigned int uNumVertices, unsigned int uFaceID); void MakeParticleBillboardAndPush_BLV(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); void MakeParticleBillboardAndPush_ODM(RenderBillboardTransform_local0 *a2, IDirect3DTexture2 *a3, unsigned int uDiffuse, int angle); void TransformBillboard(RenderBillboardTransform_local0 *a2, Sprite *pSprite, int dimming_level, RenderBillboard *pBillboard); void DrawBillboard_Indoor(RenderBillboardTransform_local0 *pSoftBillboard, Sprite *pSprite, int dimming_level); int MakeParticleBillboardAndPush_BLV_Software(int screenSpaceX, int screenSpaceY, int z, int lightColor, int a6); void DrawProjectile(float srcX, float srcY, float a3, float a4, float dstX, float dstY, float a7, float a8, IDirect3DTexture2 *a9); - void _4A4CC9(struct stru6_stru1_indoor_sw_billboard *a1, int a2); + void _4A4CC9_AddSomeBillboard(struct stru6_stru1_indoor_sw_billboard *a1, int diffuse); bool LoadTexture(const char *pName, unsigned int bMipMaps, IDirectDrawSurface4 **pOutSurface, IDirect3DTexture2 **pOutTexture); bool MoveSpriteToDevice(Sprite *pSprite); void BeginScene(); @@ -356,18 +355,18 @@ int _4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, struct Vec2_int_ *pBitmapXY, unsigned __int16 *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7); void _4A6E7E(unsigned int a2, unsigned int a3, struct Texture *a4); char DrawBuildingsD3D(); - struct BSPModel *DrawBuildingsSW(); - int OnOutdoorRedrawSW(); + //struct BSPModel *DrawBuildingsSW(); + //int OnOutdoorRedrawSW(); void DrawSkyD3D(); - int DrawSkySW(struct Span *a1, stru148 *a2, int a3); + //int DrawSkySW(struct Span *a1, Polygon *a2, int a3); void PrepareDecorationsRenderList_ODM(); void DrawSpriteObjects_ODM(); void TransformBillboardsAndSetPalettesODM(); - float DrawBezierTerrain(); + //float DrawBezierTerrain(); void RenderTerrainD3D(); void DrawTerrainD3D(int a1, int edx0, int a3, int unk4); - void DrawTerrainSW(int a1, int a2, int a3, int a4); - void ExecOutdoorDrawSW(); + //void DrawTerrainSW(int a1, int a2, int a3, int a4); + //void ExecOutdoorDrawSW(); void ChangeBetweenWinFullscreenModes(); void DrawBillboardList_BLV(); @@ -511,18 +510,7 @@ extern RenderVertexSoft array_507D30[50]; -extern RenderVertexSoft array_508690[50]; -extern RenderVertexSoft array_508FF0[50]; -extern RenderVertexSoft array_509950[50]; -extern RenderVertexSoft array_50A2B0[50]; extern RenderVertexSoft array_50AC10[50]; - extern RenderVertexSoft array_73D150[20]; -extern RenderVertexD3D3 d3d_vertex_buffer[50]; - -extern RenderVertexSoft *ptr_801A04; -extern RenderVertexSoft *ptr_801A08; - -extern RenderVertexSoft pVerticesSR_801A10[384]; -extern RenderVertexSoft pVerticesSR_806210[384]; \ No newline at end of file +extern RenderVertexD3D3 d3d_vertex_buffer[50]; \ No newline at end of file
--- a/SaveLoad.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/SaveLoad.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -185,7 +185,7 @@ uint uEquipIdx = pParty->pPlayers[i].pEquipment.pIndices[j]; if (uEquipIdx) { - auto uItemID = pParty->pPlayers[i].pInventoryItems[uEquipIdx - 1].uItemID; + auto uItemID = pParty->pPlayers[i].pInventoryItemList[uEquipIdx - 1].uItemID; if (pItemsTable->pItems[uItemID].uEquipType == 12) { __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 @@ -222,7 +222,7 @@ for (uint i = 0; i < uNumSavegameFiles; ++i) pSavegameThumbnails[i].Release(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); pAudioPlayer->SetMasterVolume(pSoundVolumeLevels[uSoundVolumeMultiplier] * 128.0f); if (uTurnSpeed) @@ -568,7 +568,7 @@ pNew_LOD->_4621A7(); else ShowStatusBarString(pGlobalTXT_LocalizationStrings[583], 2u);// "No saving in the Arena" - pIcons_LOD->_4355F7(); + pIcons_LOD->RemoveTexturesFromTextureList(); pEventTimer->Resume(); ShowStatusBarString(pGlobalTXT_LocalizationStrings[656], 2u);// "Game Saved!" viewparams->bRedrawGameUI = true; @@ -795,34 +795,27 @@ v26 = pRenderer->uTargetSurfacePitch; if ( pRenderer->pTargetSurface ) { - v29 = 0; if ( height > 0 ) { - do + for ( v29 = 0; v29 < height; ++v29 ) { - v28 = 0; if ( width > 0 ) { v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0); - do + for ( v28 = 0; v28 < width; v28++ ) { - v16 = (signed __int64)((double)v28++ * v23 + 8.0); - *v3 = _this[v15 + (int)v16]; + *v3 = _this[v15 + (int)(signed __int64)((double)v28 * v23 + 8.0)]; ++v3; } - while ( v28 < width ); } - ++v29; } - while ( v29 < height ); } } else { if ( height > 0 ) { - v17 = height; - do + for ( v17 = height; v17; --v17 ) { if ( width > 0 ) { @@ -835,9 +828,7 @@ } v3 += width; } - --v17; } - while ( v17 ); } } pRenderer->EndScene(); @@ -847,11 +838,9 @@ //----- (0045E26C) -------------------------------------------------------- void __thiscall SaveScreenshot(const char *pFilename) { - const char *v1; // edi@1 unsigned __int16 *v2; // esi@1 - v1 = pFilename; v2 = MakeScreenshot(92, 68); - pRenderer->SavePCXImage(v1, (char *)v2, 92, 68); + pRenderer->SavePCXImage(pFilename, (char *)v2, 92, 68); free(v2); } \ No newline at end of file
--- a/SpriteObject.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/SpriteObject.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -53,46 +53,17 @@ //----- (0042F5ED) -------------------------------------------------------- int SpriteObject::Create(int yaw, int pitch, int a4, int a5) { - //SpriteObject *v5; // eax@1 signed int v6; // ebx@2 - //char *v7; // ecx@2 - //signed int result; // eax@6 - SpriteObject *v9; // ebx@7 - int v10; // edx@11 - int v11; // edi@18 - __int16 v12; // ax@18 int v13; // ST2C_4@20 - int v14; // eax@20 - int v15; // [sp-28h] [bp-38h]@14 - int v16; // [sp-24h] [bp-34h]@11 Vec3_int_ v17; // [sp-20h] [bp-30h]@11 - int *v18; // [sp-14h] [bp-24h]@11 - int *v19; // [sp-10h] [bp-20h]@11 - int *v20; // [sp-Ch] [bp-1Ch]@11 - //signed int v21; // [sp+8h] [bp-8h]@2 int angle; // [sp+Ch] [bp-4h]@1 - int a4a; // [sp+1Ch] [bp+Ch]@20 - int a4b; // [sp+1Ch] [bp+Ch]@20 int a5a; // [sp+20h] [bp+10h]@20 - //auto a1 = this; angle = yaw; - //v5 = a1; if (!uObjectDescID) return -1; v6 = 1000; - //v7 = (char *)&pSpriteObjects[0].uObjectDescID; - /*v21 = 0; - do - { - if ( !*(short *)v7 ) - break; - v7 += 112; - ++v6; - v21 = v6; - } - while ( (signed int)v7 < (signed int)((char *)&pObjectList->uNumObjects + 2) );*/ for (uint i = 0; i < MAX_SPRITE_OBJECTS; ++i) if (!pSpriteObjects[i].uObjectDescID) { @@ -104,89 +75,133 @@ return -1; field_64.x = vPosition.x; field_64.y = vPosition.y; - v9 = &pSpriteObjects[v6]; field_64.z = vPosition.z; assert(sizeof(SpriteObject) == 0x70); - memcpy(v9, this, sizeof(*this)); + memcpy(&pSpriteObjects[v6], this, sizeof(*this)); + if ( a5 == 0 ) + { + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; + } if ( a5 == 1 ) { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; v17.x = vPosition.x; v17.y = vPosition.y; v17.z = vPosition.z; - v16 = 0; - v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; - goto LABEL_16; + Vec3_int_::Rotate(24, stru_5C6E00->uIntegerHalfPi + pSpriteObjects[v6].uFacing, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } if ( a5 == 2 ) { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; - v17.x = vPosition.x; - v17.y = vPosition.y; - v17.z = vPosition.z; - v16 = 0; - v10 = stru_5C6E00->uIntegerHalfPi + v9->uFacing; - goto LABEL_14; - } - if ( a5 == 3 ) - { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; v17.x = vPosition.x; v17.y = vPosition.y; v17.z = vPosition.z; - v16 = 0; - v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; -LABEL_14: - v15 = 8; -LABEL_17: - Vec3_int_::Rotate(v15, v10, v16, v17, v18, v19, v20); - goto LABEL_18; + Vec3_int_::Rotate(8, stru_5C6E00->uIntegerHalfPi + pSpriteObjects[v6].uFacing, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } - if ( a5 == 4 ) + if ( a5 == 3 ) { - v20 = &v9->vPosition.z; - v19 = &v9->vPosition.y; - v18 = (int *)&v9->vPosition; v17.x = vPosition.x; v17.y = vPosition.y; v17.z = vPosition.z; - v16 = 0; - v10 = v9->uFacing - stru_5C6E00->uIntegerHalfPi; -LABEL_16: - v15 = 24; - goto LABEL_17; + Vec3_int_::Rotate(8, pSpriteObjects[v6].uFacing - stru_5C6E00->uIntegerHalfPi, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } -LABEL_18: - v11 = a4; - v12 = 0; - if ( a4 ) + if ( a5 == 4 ) { - a4a = stru_5C6E00->Cos(angle); - v13 = (unsigned __int64)(a4a * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - a4b = stru_5C6E00->Sin(angle); - a5a = (unsigned __int64)(a4b * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; - v14 = stru_5C6E00->Sin(pitch); - v9->vVelocity.x = (unsigned int)(v13 * v11) >> 16; - v9->vVelocity.y = (unsigned int)(a5a * v11) >> 16; - v12 = (unsigned int)(v14 * v11) >> 16; + v17.x = vPosition.x; + v17.y = vPosition.y; + v17.z = vPosition.z; + Vec3_int_::Rotate(24, pSpriteObjects[v6].uFacing - stru_5C6E00->uIntegerHalfPi, 0, v17, &pSpriteObjects[v6].vPosition.x, + &pSpriteObjects[v6].vPosition.y, &pSpriteObjects[v6].vPosition.z); + pSpriteObjects[v6].vVelocity.z = 0; + if ( a4 ) + { + v13 = (unsigned __int64)(stru_5C6E00->Cos(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + a5a = (unsigned __int64)(stru_5C6E00->Sin(angle) * (signed __int64)stru_5C6E00->Cos(pitch)) >> 16; + pSpriteObjects[v6].vVelocity.x = (unsigned int)(v13 * a4) >> 16; + pSpriteObjects[v6].vVelocity.y = (unsigned int)(a5a * a4) >> 16; + pSpriteObjects[v6].vVelocity.z = (unsigned int)(stru_5C6E00->Sin(pitch) * a4) >> 16; + } + else + { + pSpriteObjects[v6].vVelocity.y = 0; + pSpriteObjects[v6].vVelocity.x = 0; + } + if ( v6 >= (signed int)uNumSpriteObjects ) + uNumSpriteObjects = v6 + 1; + return v6; } - else - { - v9->vVelocity.y = 0; - v9->vVelocity.x = 0; - } - v9->vVelocity.z = v12; - if ( v6 >= (signed int)uNumSpriteObjects ) - uNumSpriteObjects = v6 + 1; - return v6; + assert(false); + return 0; } //----- (00471C03) -------------------------------------------------------- @@ -331,9 +346,9 @@ Dst.x = (double)v1->vPosition.x; Dst.y = (double)v1->vPosition.y; Dst.z = (double)v1->vPosition.z; - Dst.flt_10 = 0.0; - Dst.flt_14 = 0.0; - Dst.flt_18 = 0.0; + Dst.r = 0.0; + Dst.g = 0.0; + Dst.b = 0.0; if (v2->uFlags & OBJECT_DESC_TRIAL_FIRE ) { Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; @@ -455,9 +470,9 @@ Dst.x = (double)v1->vPosition.x; Dst.y = (double)v1->vPosition.y; Dst.z = (double)v1->vPosition.z; - Dst.flt_10 = 0.0; - Dst.flt_14 = 0.0; - Dst.flt_18 = 0.0; + Dst.r = 0.0; + Dst.g = 0.0; + Dst.b = 0.0; if ( v2->uFlags & OBJECT_DESC_TRIAL_FIRE ) { Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; @@ -738,9 +753,9 @@ Dst.x = (double)pSpriteObject->vPosition.x; Dst.y = (double)pSpriteObject->vPosition.y; Dst.z = (double)pSpriteObject->vPosition.z; - Dst.flt_10 = 0.0; - Dst.flt_14 = 0.0; - Dst.flt_18 = 0.0; + Dst.r = 0.0; + Dst.g = 0.0; + Dst.b = 0.0; if ( v29 & 0x200 ) { Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; @@ -928,9 +943,9 @@ Dst.x = (double)pSpriteObject->vPosition.x; Dst.y = (double)pSpriteObject->vPosition.y; Dst.z = (double)pSpriteObject->vPosition.z; - Dst.flt_10 = 0.0; - Dst.flt_14 = 0.0; - Dst.flt_18 = 0.0; + Dst.r = 0.0; + Dst.g = 0.0; + Dst.b = 0.0; if ( v10 & 0x200 ) { Dst.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_8; @@ -970,94 +985,73 @@ // 46DF1A: using guessed type int __fastcall 46DF1A_collide_against_actor(int, int); //----- (00438E35) -------------------------------------------------------- -void SpriteObject::_438E35() +void SpriteObject::ExplosionTraps() { - SpriteObject *v1; // edi@1 MapInfo *pMapInfo; // esi@1 - int v3; // ebx@1 - int v4; // eax@1 - int v5; // ebx@1 - unsigned int v6; // ecx@1 + int dir_x; // ebx@1 int v7; // edx@2 - unsigned int v8; // edx@4 - unsigned int v9; // edx@6 unsigned int v10; // eax@7 signed int v11; // ebx@8 - Player **v12; // esi@18 signed int v13; // edi@20 - int v15; // [sp+Ch] [bp-Ch]@1 - int v16; // [sp+10h] [bp-8h]@1 - signed int v17; // [sp+14h] [bp-4h]@8 - int v18; // [sp+14h] [bp-4h]@14 + int dir_y; // [sp+Ch] [bp-Ch]@1 + int dir_z; // [sp+10h] [bp-8h]@1 + DAMAGE_TYPE pDamageType; // [sp+14h] [bp-4h]@14 - v1 = this; pMapInfo = &pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName.data())]; - v3 = abs(pParty->vPosition.x - v1->vPosition.x); - v15 = abs(pParty->vPosition.y - v1->vPosition.y); - v16 = abs(pParty->vPosition.z + pParty->sEyelevel - v1->vPosition.z); - v4 = v3; - v5 = v15; - v6 = v16; - if ( v4 < v15 ) + dir_x = abs(pParty->vPosition.x - this->vPosition.x); + dir_y = abs(pParty->vPosition.y - this->vPosition.y); + dir_z = abs(pParty->vPosition.z + pParty->sEyelevel - this->vPosition.z); + if ( dir_x < dir_y ) { - v7 = v4; - v4 = v15; - v5 = v7; + v7 = dir_x; + dir_x = dir_y; + dir_y = v7; } - if ( v4 < v16 ) + if ( dir_x < dir_z ) { - v8 = v4; - v4 = v16; - v6 = v8; + v7 = dir_x; + dir_x = dir_z; + dir_z = v7; } - if ( v5 < (signed int)v6 ) + if ( dir_y < dir_z ) { - v9 = v6; - v6 = v5; - v5 = v9; + v7 = dir_z; + dir_z = dir_y; + dir_y = v7; } - v10 = ((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4; + v10 = ((unsigned int)(11 * dir_y) >> 5) + (dir_z / 4) + dir_x; if ( (signed int)v10 <= 768 ) { - v17 = 0; v11 = 5; if ( pMapInfo->Trap_D20 ) { - do - { - ++v17; + for ( uint i = 0; i < pMapInfo->Trap_D20; ++i ) v11 += rand() % 20 + 1; - } - while ( v17 < pMapInfo->Trap_D20 ); } - switch ( v1->uType ) + switch ( this->uType ) { - case 0x32Bu: - v18 = 0; + case 811: + pDamageType = DMGT_FIRE; + break; + case 812: + pDamageType = DMGT_ELECTR; break; - case 0x32Cu: - v18 = 1; + case 813: + pDamageType = DMGT_COLD; break; - case 0x32Du: - v18 = 2; + case 814: + pDamageType = DMGT_BODY; break; default: - //LOWORD(v10) = v1->uItemType - 814; - if ( v1->uType != 814 ) - return; - v18 = 8; - break; + return; } - v12 = &pPlayers[1]; - do + for ( uint i = 1; i <= 4; ++i ) { - if ( (*v12)->CanAct() && (v13 = (*v12)->GetPerception() + 20, rand() % v13 > 20) ) - (*v12)->PlaySound(SPEECH_6, 0); + if ( pPlayers[i]->CanAct() && (v13 = pPlayers[i]->GetPerception() + 20, rand() % v13 > 20) ) + pPlayers[i]->PlaySound(SPEECH_6, 0); else - (*v12)->ReceiveDamage(v11, (DAMAGE_TYPE)v18); - ++v12; + pPlayers[i]->ReceiveDamage(v11, pDamageType); } - while ( (signed int)v12 <= (signed int)&pPlayers[4] ); } } @@ -1099,9 +1093,6 @@ (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & 0x10)) SpriteObject::OnInteraction(i); } - - for (uint i = 0; i < 100; ++i) - array_5118E8.pElements[i].field_C_time_left = 0; } //----- (0046BEF1) -------------------------------------------------------- void SpriteObject::_46BEF1_apply_spells_aoe()
--- a/SpriteObject.h Tue Aug 06 00:52:46 2013 +0400 +++ b/SpriteObject.h Tue Aug 06 00:56:33 2013 +0400 @@ -16,7 +16,7 @@ SpriteObject(); int Create(int yaw, int pitch, int a4, int a5); void _46BEF1_apply_spells_aoe(); - void _438E35(); + void ExplosionTraps(); static void UpdateObject_fn0_BLV(unsigned int uLayingItemID); static void UpdateObject_fn0_ODM(unsigned int uLayingItemID);
--- a/Texture.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Texture.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -47,12 +47,12 @@ Texture *pTex_tab_an_7b__zoot_on; Texture *pTex_tab_an_6b__zoom_on; std::array<Texture *, 6> pTexture_TownPortalIcons; // [0]Harmonale, [1]Pierpont, [2]Nighon, [3]Evenmorn Island, [4]Celestia, [5]The Pit -std::array<Texture *, 12> dword_5063D8; -std::array<Texture *, 12> dword_506408; -Texture *pTexture_50643C; // idb -Texture *ptr_506440; -Texture *pTexture_506444; -Texture *pTexture_506448; // idb +std::array<Texture *, 12> SBPageCSpellsTextureList; +std::array<Texture *, 12> SBPageSSpellsTextureList; +Texture *pSBQuickSpellBtnTextr; +Texture *pSpellBookClickCloseBtnTextr; +Texture *pSBClickQuickSpellBtnTextr; +Texture *pSpellBookCloseBtnTextr; std::array<std::array<Texture *, 2>, 9> pTextures_tabs; Texture *pTexture_mapbordr; // idb Texture *pTexture_pagemask; // idb @@ -1680,6 +1680,7 @@ { *strchr(&Buf, 10) = 0; memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); + __debugbreak(); // warning C4700: uninitialized local variable 'Str1' used if ( v21 && *Str1 != 47 ) { if ( v21 < 2 ) @@ -1707,6 +1708,7 @@ if ( v21 && *Str1 != 47 ) { strcpy(v2->pTextures[v2->sNumTextures].pTextureName, Str1); + __debugbreak(); // warning C4700: uninitialized local variable 'Str' used v2->pTextures[v2->sNumTextures].uAnimTime = atoi(Str); v9 = 2; for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 )
--- a/Texture.h Tue Aug 06 00:52:46 2013 +0400 +++ b/Texture.h Tue Aug 06 00:56:33 2013 +0400 @@ -146,12 +146,12 @@ extern struct Texture *pTex_tab_an_6b__zoom_on; extern std::array<struct Texture *, 6> pTexture_TownPortalIcons; // [0]Harmonale, [1]Pierpont, [2]Nighon, [3]Evenmorn Island, [4]Celestia, [5]The Pit -extern std::array<struct Texture *, 12> dword_5063D8; -extern std::array<struct Texture *, 12> dword_506408; -extern struct Texture *pTexture_50643C; // idb -extern struct Texture *ptr_506440; -extern struct Texture *pTexture_506444; -extern struct Texture *pTexture_506448; // idb +extern std::array<struct Texture *, 12> SBPageCSpellsTextureList; +extern std::array<struct Texture *, 12> SBPageSSpellsTextureList; +extern struct Texture *pSBQuickSpellBtnTextr; +extern struct Texture *pSpellBookClickCloseBtnTextr; +extern struct Texture *pSBClickQuickSpellBtnTextr; +extern struct Texture *pSpellBookCloseBtnTextr; extern std::array<std::array<struct Texture *, 2>, 9> pTextures_tabs; extern struct Texture *pTexture_mapbordr; // idb extern struct Texture *pTexture_pagemask; // idb
--- a/UI/Books/UIMapBook.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/Books/UIMapBook.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -22,12 +22,8 @@ // #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}}; @@ -37,31 +33,24 @@ - - //----- (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 + GUIWindow TownPortalWindow; // [sp+Ch] [bp-64h]@1 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; - + TownPortalWindow.uFrameX = game_viewport_x; + TownPortalWindow.uFrameY = game_viewport_y; + TownPortalWindow.uFrameWidth = game_viewport_width; + TownPortalWindow.uFrameHeight = game_viewport_height; + TownPortalWindow.uFrameZ = game_viewport_z; + TownPortalWindow.uFrameW = game_viewport_w; + const uint fountain_bits_lut[] = {PARTY_QUEST_FOUNTAIN_HARMONDALE, PARTY_QUEST_FOUNTAIN_PIERPONT, PARTY_QUEST_FOUNTAIN_NIGHON, @@ -77,55 +66,7 @@ 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) @@ -133,86 +74,28 @@ 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);*/ + TownPortalWindow.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3); } -// 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 + char *pText; // eax@1 + int pTextHeight; // eax@14 + int RemainingTime; // kr08_8@14 + unsigned int pHours; // esi@14 + unsigned int pDays; // eax@14 + char *pSelectionText; // eax@19 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 BeaconID; // [sp+78h] [bp-10h]@11 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 + pRenderer->DrawTextureIndexed(8, 8, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]); + pText = pGlobalTXT_LocalizationStrings[523]; // Recall Beacon pWindow.uFrameX = game_viewport_x; pWindow.uFrameY = game_viewport_y; pWindow.uFrameWidth = 428; @@ -220,9 +103,9 @@ 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); + pText = pGlobalTXT_LocalizationStrings[375]; // Set Beacon + sprintf(pTmpBuf.data(), "%s", pText); + pWindow.DrawTitleText(pBook2Font, 0, 22, 0, pTmpBuf.data(), 3); if ( bRecallingBeacon ) { pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on); @@ -234,739 +117,591 @@ 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 ) + if ( HIBYTE(pPlayer->pActiveSkills[14]) & 1 || (pPlayer->pActiveSkills[14] & 0x80u) != 0 ) { uNumMaxBeacons = 5; } else { - if ( v2 & 0x40 ) + if ( pPlayer->pActiveSkills[14] & 0x40 ) uNumMaxBeacons = 3; } - result = 0; - v27 = 0; if ( uNumMaxBeacons > 0 ) { - v29 = pSavegameThumbnails.data(); - v28 = pPlayer->pInstalledBeacons; - while ( 1 ) + for ( BeaconID = 0; BeaconID < uNumMaxBeacons; BeaconID++ ) { pWindow.uFrameWidth = 92; - v4 = result; pWindow.uFrameHeight = 68; - v5 = pLloydsBeaconsPreviewXs[result]; - pWindow.uFrameY = pLloydsBeaconsPreviewYs[result]; - v25 = pWindow.uFrameY; - pWindow.uFrameX = v5; + pWindow.uFrameY = pLloydsBeaconsPreviewYs[BeaconID]; + pWindow.uFrameX = pLloydsBeaconsPreviewXs[BeaconID]; pWindow.uFrameW = pWindow.uFrameY + 67; - v6 = v29->pPixels == 0; - pWindow.uFrameZ = v5 + 91; - if ( !v6 ) - break; + pWindow.uFrameZ = pLloydsBeaconsPreviewXs[BeaconID] + 91; + //if ( pSavegameThumbnails[BeaconID].pPixels != 0 ) + if ( pPlayer->pInstalledBeacons[BeaconID].SaveFileID != 0 ) + { + pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook); + pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[BeaconID], pLloydsBeaconsPreviewYs[BeaconID], &pSavegameThumbnails[BeaconID]); + Str = pMapStats->pInfos[sub_410D99_get_map_index(pPlayer->pInstalledBeacons[BeaconID].SaveFileID)].pName; + pTextHeight = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0); + pWindow.uFrameY += -6 - pTextHeight; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1, Str, 3); + RemainingTime = pPlayer->pInstalledBeacons[BeaconID].uBeaconTime - pParty->uTimePlayed; + pHours = (signed __int64)((double)RemainingTime * 0.234375) / 60 / 60; + pDays = pHours / 24; + if ( pDays ) + { + sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[57]);//days + pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); + continue; + } + else + { + if ( pHours + 1 <= 23 ) + { + if ( pHours < 1 ) + pSelectionText = pGlobalTXT_LocalizationStrings[109];// Hour + else + pSelectionText = pGlobalTXT_LocalizationStrings[110];// Hours + sprintf(pTmpBuf.data(), "%lu %s", pHours + 1, pSelectionText); + pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); + continue; + } + } + sprintf(pTmpBuf.data(), "%lu %s", pDays + 1, pGlobalTXT_LocalizationStrings[56]);//Day + pWindow.uFrameY = pWindow.uFrameY + pWindow.uFrameHeight + 4; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); + continue; + } 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; + pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[BeaconID], pLloydsBeacons_SomeYs[BeaconID], pTexture_CurrentBook); + pTextHeight = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0); + pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - pTextHeight / 2, 1, pGlobalTXT_LocalizationStrings[19], 3);//Доступно } } - 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; + return BeaconID; } - //----- (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; +{ + 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(); + 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); + 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); - } + 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 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 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 + 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 pCenterY; // [sp+4802Ch] [bp-38h]@1 + int screenCenter_X; // [sp+48030h] [bp-34h]@1 + int pCenterX; // [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 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 + + screenCenter_X = (signed int)(tl_x + br_x) / 2; + screenCenterY = (signed int)(tl_y + br_y) / 2; + pRenderer->SetRasterClipRect(tl_x, tl_y, br_x, br_y); + pCenterX = viewparams->sViewCenterX; + pCenterY = viewparams->sViewCenterY; + if ( viewparams->field_2C != 384 ) + { + if ( viewparams->field_2C == 768 ) { - 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 + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + viewparams->field_2C = 680; + } + } + else + { + viewparams->sViewCenterX = viewparams->indoor_center_x; + pCenterX = viewparams->indoor_center_x; + pCenterY = viewparams->indoor_center_y; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + viewparams->field_2C = 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 * pRenderer->uTargetSurfacePitch]; + 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)) / viewparams->field_2C; - 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; + v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2)); + + teal = (unsigned int)(signed __int64)((double)(viewparams->sViewCenterX - 22528 / (viewparams->field_2C / 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)(- pCenterY - 22528 / (viewparams->field_2C / 384)+ 32768) / v30) << 16; + // v81 = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30); + black = (signed __int16)(signed __int64)((double)(viewparams->sViewCenterX - 22528 / (viewparams->field_2C / 384) + 32768) / v30); - 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 ) + // 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 ) { - 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); - } - } + scaled_posX=stepX_r>>16; + map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)]; + stepX_r+=scale_increment; } - else + 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[pRenderer->uTargetSurfacePitch * i],(void*)&map_texture_16[i*screenWidth], screenWidth*2); + } + } + else + { + black = TargetColor(0, 0, 0); + teal = TargetColor(0, 0xFFu, 0xFFu); + uNumBlueFacesInBLVMinimap = 0; + if ( pIndoor->pMapOutlines->uNumOutlines ) + { + for ( uint i = 0; i < pIndoor->pMapOutlines->uNumOutlines; ++i ) + { + if ( !(BYTE1(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes) & 0x20 + || (BYTE1(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes) & 0x20) )) { - 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 ) + if ( !(pIndoor->pMapOutlines->pOutlines[i].uFlags & 1) ) + { + if ( !(!(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes & 0x80) + && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80u) )) { - 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; + pIndoor->pMapOutlines->pOutlines[i].uFlags = pIndoor->pMapOutlines->pOutlines[i].uFlags | 1; + pIndoor->_visible_outlines[i >> 3] |= 1 << (7 - i % 8); } - } - 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; - } + } + if ( (!(pIndoor->pMapOutlines->pOutlines[i].uFlags & 1) + && !(!(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace1ID].uAttributes & 0x80) + && !(pIndoor->pFaces[pIndoor->pMapOutlines->pOutlines[i].uFace2ID].uAttributes & 0x80u) )) + || pIndoor->pMapOutlines->pOutlines[i].uFlags & 1) + { + v93 = (unsigned __int16 *)(pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].x - viewparams->sViewCenterX); + screenHeight = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].y - pCenterY; + v20 = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].y - pCenterY; + v95 = pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX; + v97 = (const void *)v20; + v88 = (unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex1ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16; + v87 = (unsigned __int64)((signed int)screenHeight * (signed __int64)viewparams->field_2C) >> 16; + v93 = (unsigned __int16 *)((unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16); + screenHeight = (unsigned __int64)(v20 * (signed __int64)viewparams->field_2C) >> 16; + pRenderer->RasterLine2D(screenCenter_X + v88, screenCenterY - v87, + screenCenter_X + ((unsigned __int64)((pIndoor->pVertices[pIndoor->pMapOutlines->pOutlines[i].uVertex2ID].x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16), screenCenterY - screenHeight, black); + } } - 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 + } + } + v21 = 0; + if ( (signed int)uNumBlueFacesInBLVMinimap > 0 ) + { + while ( 1 ) + { + v22 = pBlueFacesInBLVMinimapIDs[v21]; + v87 = viewparams->field_2C; + v23 = &pIndoor->pMapOutlines->pOutlines[v22]; + v24 = &pIndoor->pVertices[v23->uVertex1ID]; + v25 = &pIndoor->pVertices[v23->uVertex2ID]; + v26 = v25->x; + v27 = (unsigned __int16 *)(v24->x - pCenterX); + v28 = v24->y - pCenterY; + v29 = v25->y - pCenterY; + v93 = v27; + screenHeight = v28; + v97 = (const void *)v29; + v87 = (unsigned __int64)((signed int)v27 * (signed __int64)viewparams->field_2C) >> 16; + v88 = (unsigned __int64)(v28 * (signed __int64)viewparams->field_2C) >> 16; + uint i = (unsigned __int64)((v26 - pCenterX) * (signed __int64)viewparams->field_2C) >> 16; + v95 = (unsigned __int64)(v29 * (signed __int64)viewparams->field_2C) >> 16; + pRenderer->RasterLine2D(screenCenter_X + ((unsigned __int64)((signed int)v27 * (signed __int64)viewparams->field_2C) >> 16), + screenCenterY - v88, screenCenter_X + ((unsigned __int64)((v26 - pCenterX) * (signed __int64)viewparams->field_2C) >> 16), screenCenterY - v95, teal); + ++v21; + if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap ) + break; + } + viewparams->sViewCenterX = pCenterX; + } + } + v47 = ((unsigned __int64)((pParty->vPosition.x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X - 3; + v81 = pParty->vPosition.y - pCenterY; + v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - pCenterY) * (signed __int64)viewparams->field_2C) >> 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 - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X - 6) > (signed int)br_x ) + v48 = 0; + v47 = br_x; + } + } + else + { + if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - viewparams->sViewCenterX) * (signed __int64)viewparams->field_2C) >> 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 ) + { + v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask; + if ( (signed int)v51 <= 1920 ) + v50 = 7; + if ( (signed int)v51 < 1664 ) + v50 = 6; + if ( (signed int)v51 <= 1408 ) + v50 = 5; + if ( (signed int)v51 < 1152 ) + v50 = 4; + if ( (signed int)v51 <= 896 ) + v50 = 3; + if ( (signed int)v51 < 640 ) + v50 = 2; + if ( (signed int)v51 <= 384 ) + v50 = 1; + if ( (signed int)v51 < 128 ) + v50 = 0; + pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50])); + } + result = TargetColor(0xFFu, 0xFFu, 0xFFu); + pCenterX = result; + if ( (signed int)uNumLevelDecorations > 0 ) + { + for ( uint i = 0; i < (signed int)uNumLevelDecorations; ++i ) + { + if ( pLevelDecorations[i].field_2 & 8 ) + { + screenHeight = pLevelDecorations[i].vPosition.y - pCenterY; + v93 = (unsigned __int16 *)(pLevelDecorations[i].vPosition.x - viewparams->sViewCenterX); + v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X; + v97 = (const void *)((unsigned __int64)(screenHeight * (signed __int64)viewparams->field_2C) >> 16); + v55 = screenCenterY - (int)v97; + if ( v54 >= pRenderer->raster_clip_x ) { - 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 ( v54 <= pRenderer->raster_clip_z && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w ) + { + if ( viewparams->field_2C > 512 ) { - 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; + pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, pCenterX); + pRenderer->RasterLine2D(v54, v55 - 1, v54, v55 + 1, pCenterX); + ++v54; + v72 = v55 + 1; + v71 = v54; + v70 = v55 - 1; } - 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 ) + else { - 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; + v72 = screenCenterY - (int)v97; + v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)viewparams->field_2C) >> 16) + screenCenter_X; + v70 = screenCenterY - (int)v97; } - v65 = v95; - v66 = map_texture_16; - if ( (signed int)v95 > 0 ) + pRenderer->RasterLine2D(v54, v70, v71, v72, pCenterX); + } + } + } + } + } + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + screenCenterY = br_x - tl_x + 1; + v95 = br_y - tl_y + 1; + v77 = &pRenderer->pTargetSurface[tl_x + tl_y * pRenderer->uTargetSurfacePitch]; + v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2; + black = (1 << (v56 + 16)) / viewparams->field_2C; + v57 = (double)(1 << (16 - v56)); + v58 = 22528 / (viewparams->field_2C / 384); + v59 = (signed __int64)((double)(viewparams->sViewCenterX - v58 + 32768) / v57); + v60 = (int)v59 << 16; + v97 = (const void *)((int)v59 << 16); + v61 = (signed __int64)((double)(32768 - v58 - pCenterY) / 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); + for ( screenCenter_X = 0; screenCenter_X < (signed int)v95; ++screenCenter_X ) + { + if ( screenCenterY > 0 ) + { + v96 = (v63 - 80) / 4; + v64 = teal; + for ( a5a = 0; a5a < screenCenterY; ++a5a ) + { + v81 = (v64 - 80) / 4; + if ( !pOutdoor->_47F04C(v81, v96) ) + { + if ( pOutdoor->_47F097(v81, v96) ) { - 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 ); + if ( !((a5a + screenCenter_X) % 2) ) + *a4a = result; } + else + *a4a = 0; + } + ++a4a; + v97 = (char *)v97 + black; + v64 = (signed int)v97 >> 16; } + } + v62 += black; + v97 = (const void *)v60; + a4a += screenCenterY - a5a; + v63 = v62 >> 16; + teal = (unsigned int)pPalette_16; } - - + v66 = map_texture_16; + if ( (signed int)v95 > 0 ) + { + v67 = v77; + result = 2 * (pRenderer->uTargetSurfacePitch - screenCenterY); + for ( v65 = v95; v65; --v65 ) + { + if ( screenCenterY > 0 ) + { + for ( v68 = screenCenterY; v68; --v68 ) + { + v69 = *(short *)v66; + if ( !*(short *)v66 || v69 == (short)result ) + *v67 = v69; + ++v66; + ++v67; + } + } + v67 = (unsigned __int16 *)((char *)v67 + result); + } + } + } +}
--- a/UI/Books/UINotesBooks.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/Books/UINotesBooks.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -42,506 +42,395 @@ 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 - +{ + int am; // ecx@5 + char *pMapName; // eax@6 + GUIWindow calendar_window; // [sp+Ch] [bp-60h]@5 + unsigned int pMapID; // [sp+60h] [bp-Ch]@1 + unsigned int pHour; - 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 - }; - + 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" + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13); + pHour = pParty->uCurrentHour; + if ( (signed int)pHour >= 12 ) + { + pHour -= 12; + if ( !pHour ) + pHour = 12; + am = 1; + } + else + am = 0; - v2 = 0; - if ( pParty->uCurrentHour >= 12 ) - { - if ( pParty->uCurrentHour >= 24 ) - v2=0; - else - v2=1; - } + calendar_window.uFrameX = game_viewport_x; + calendar_window.uFrameY = game_viewport_y; + calendar_window.uFrameWidth = game_viewport_width; + calendar_window.uFrameHeight = game_viewport_height; + calendar_window.uFrameZ = game_viewport_z; + calendar_window.uFrameW = game_viewport_w; + calendar_window.DrawTitleText(pBook2Font, 0, 22, ui_book_calendar_title_color, pGlobalTXT_LocalizationStrings[186], 3); // "Time in Erathia" - 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:%02d %s - %s", pGlobalTXT_LocalizationStrings[526], // "Time" + pHour, pParty->uCurrentMinute, aAMPMNames[am], GetDayPart()); + calendar_window.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[56], // "Day" + pParty->uDaysPlayed + 1, aDayNames[pParty->uDaysPlayed % 7]); + calendar_window.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 - %s", pGlobalTXT_LocalizationStrings[146], // "Month" + pParty->uCurrentMonth + 1, aMonthNames[pParty->uCurrentMonth]); + calendar_window.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); + sprintf(pTmpBuf.data(), "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); // "Year" + calendar_window.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, ui_book_calendar_year_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); - } + sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[pDayMoonPhase[pParty->uDaysPlayed]]); // "Moon" + calendar_window.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, ui_book_calendar_moon_color, pTmpBuf.data(), 0, 0, 0); - - - + pMapID = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( pMapID ) + pMapName = pMapStats->pInfos[pMapID].pName; + else + pMapName = "Unknown"; + sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], pMapName); // "Location" + calendar_window.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 +{ + int pTextHeight; // eax@19 + GUIWindow questbook_window; // [sp+Ch] [bp-54h]@9 + + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_CurrentBook); + if ( BtnUp_flag || !books_primary_item_per_page )//Bookmark Up(Закладка вверх) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_tab_an_6a__zoom_off); + else + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_tab_an_6b__zoom_on); + + if ( BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book )//Bookmark Down(Закладка вниз) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_tab_an_7a__zoot_off); + else + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_tab_an_7b__zoot_on); + + questbook_window.uFrameWidth = game_viewport_width; + questbook_window.uFrameHeight = game_viewport_height; + questbook_window.uFrameX = game_viewport_x; + questbook_window.uFrameY = game_viewport_y; + questbook_window.uFrameZ = game_viewport_z; + questbook_window.uFrameW = game_viewport_w; + questbook_window.DrawTitleText(pBook2Font, 0, 22, ui_book_quests_title_color, pGlobalTXT_LocalizationStrings[174], 3); //"Current Quests" - 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; - } - } - + questbook_window.uFrameX = 48; + questbook_window.uFrameY = 70; + questbook_window.uFrameWidth = 360; + questbook_window.uFrameHeight = 264; + questbook_window.uFrameZ = 407; + questbook_window.uFrameW = 333; + if ( BtnDown_flag && books_primary_item_per_page + num_achieved_awards < full_num_items_in_book )//Click Bookmark Down + { + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + books_primary_item_per_page += num_achieved_awards; + books_num_items_per_page[books_page_number++] = num_achieved_awards; + } + if ( BtnUp_flag && books_page_number )//Click Bookmark Up + { + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + --books_page_number; + books_primary_item_per_page -= (unsigned __int8)books_num_items_per_page[books_page_number]; + } + if ( !num_achieved_awards || !books_primary_item_per_page ) + { + books_page_number = 0; + books_primary_item_per_page = 0; + } + BtnDown_flag = 0; + BtnUp_flag = 0; + num_achieved_awards = 0; + for ( uint i = books_primary_item_per_page; i < full_num_items_in_book; ++i ) + { + ++num_achieved_awards; + //v5 = pQuestTable[achieved_awards[v3]];//(&dword_722F10)[4 * v4]; + questbook_window.DrawText(pAutonoteFont, 1, 0, ui_book_quests_text_color, pQuestTable[achieved_awards[i]], 0, 0, 0);//(&dword_722F10)[4 * v4], 0, 0, 0); + pTextHeight = pAutonoteFont->CalcTextHeight(pQuestTable[achieved_awards[i]], &questbook_window, 1, 0); + if ( (signed int)(questbook_window.uFrameY + pTextHeight) > (signed int)questbook_window.uFrameHeight ) + break; + pRenderer->DrawTextureTransparent(100, (questbook_window.uFrameY + pTextHeight) + 12, pSpellBookPagesTextr_10); + questbook_window.uFrameY = (questbook_window.uFrameY + pTextHeight) + 24; + } +} //----- (0041338E) -------------------------------------------------------- void BookUI_Autonotes_Draw() +{ + 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 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 *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 autonotes_window; // [sp+14h] [bp-54h]@46 + + v31 = 0; + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_AutonotesBook); + if ( BtnUp_flag || !books_primary_item_per_page ) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_tab_an_6a__zoom_off); + else + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_tab_an_6b__zoom_on); + + if ( BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book ) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_tab_an_7a__zoot_off); + else + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_tab_an_7b__zoot_on); + + if ( Book_PageBtn3_flag )//Potions_page_flag + { + if (_506568_autonote_type == AUTONOTE_POTION_RECEPIE)//press again(повторное нажатие) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTexture_506394); + else//press(нажатие) { - 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 = 1; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + _506568_autonote_type = AUTONOTE_POTION_RECEPIE; + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTexture_506394); + } + } + else + { + if (_506568_autonote_type == AUTONOTE_POTION_RECEPIE)// default(по умолчанию при запуске окна) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTexture_506394); + else//Potions_page not active(вкладка снадобья не активна) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 113, pTexture_506390); + } - 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; - } + if ( Book_PageBtn4_flag )//Fontains_page_flag + { + if ( _506568_autonote_type == AUTONOTE_STAT_HINT ) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTexture_50638C); 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; - } + { + v31 = 1; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + _506568_autonote_type = AUTONOTE_STAT_HINT; + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTexture_50638C); + } + } + else + { + if ( _506568_autonote_type == AUTONOTE_STAT_HINT ) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTexture_50638C); + else + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 150, pTexture_506388); + } + + if ( Book_PageBtn5_flag )//Autonotes_Obelisks_page_flag + { + if ( _506568_autonote_type == AUTONOTE_OBELISK) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTexture_506384); 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); - } - } + { + v31 = 1; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + _506568_autonote_type = AUTONOTE_OBELISK; + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTexture_506384); + } + } + else + { + if ( _506568_autonote_type == AUTONOTE_OBELISK) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTexture_506384); + else + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 188, pTexture_506380); + } + + if ( Book_PageBtn6_flag )//Autonotes_Seer_page_flag + { + if ( _506568_autonote_type == AUTONOTE_SEER) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTexture_50637C); + else + { + v31 = 1; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + _506568_autonote_type = AUTONOTE_SEER; + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTexture_50637C); + } + } + else + { + if ( _506568_autonote_type == AUTONOTE_SEER) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTexture_50637C); + else + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 226, pTexture_506378); + } + + if ( Autonotes_Misc_page_flag ) + { + if ( _506568_autonote_type == AUTONOTE_MISC) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTexture_506374); + else + { + v31 = 1; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + _506568_autonote_type = AUTONOTE_MISC; + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTexture_506374); + } + } + else + { + if ( _506568_autonote_type == AUTONOTE_MISC) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTexture_506374); 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); - } - } + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 263, pTexture_506370); + } + + if ( Autonotes_Instructors_page_flag ) + { + if ( _506568_autonote_type == AUTONOTE_TEACHER) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTexture_50636C); + else + { + v31 = 1; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + _506568_autonote_type = AUTONOTE_TEACHER; + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTexture_50636C); + } + } + else + { + if ( _506568_autonote_type == AUTONOTE_TEACHER) + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTexture_50636C); 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 + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 302, pTexture_506368); + } + + autonotes_window.uFrameWidth = game_viewport_width; + autonotes_window.uFrameHeight = game_viewport_height; + autonotes_window.uFrameX = game_viewport_x; + autonotes_window.uFrameY = game_viewport_y; + autonotes_window.uFrameZ = game_viewport_z; + autonotes_window.uFrameW = game_viewport_w; + autonotes_window.DrawTitleText(pBook2Font, 0, 22, ui_book_autonotes_title_color, pGlobalTXT_LocalizationStrings[154], 3); // "Auto notes" + + autonotes_window.uFrameX = 48; + autonotes_window.uFrameY = 70; + autonotes_window.uFrameWidth = 360; + autonotes_window.uFrameHeight = 264; + autonotes_window.uFrameZ = 407; + autonotes_window.uFrameW = 333; + if ( v31 ) + { + full_num_items_in_book = 0; + books_primary_item_per_page = 0; + books_page_number = 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 ( _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; - } + if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 ) + { + v9 = num_achieved_awards++; + achieved_awards[v9] = (AwardType)v8; + } } - 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; - } + } + ++v8; + } + while ( v8 < 196 ); + full_num_items_in_book = num_achieved_awards; + } + else + { + if ( BtnDown_flag ) + { + v10 = num_achieved_awards + books_primary_item_per_page; + if ( num_achieved_awards + books_primary_item_per_page < full_num_items_in_book ) + { + v11 = books_page_number++; + books_num_items_per_page[v11] = num_achieved_awards; + books_primary_item_per_page = v10; + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + } + } + if ( BtnUp_flag && books_page_number ) + { + --books_page_number; + books_primary_item_per_page -= (unsigned __int8)books_num_items_per_page[books_page_number]; + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); } + if ( !num_achieved_awards || books_primary_item_per_page < 1 ) + { + books_primary_item_per_page = 0; + books_page_number = 0; + } + } + v12 = books_primary_item_per_page; + 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 < full_num_items_in_book ) + { + 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); + autonotes_window.DrawText(pAutonoteFont, 1, 0, ui_book_autonotes_text_color, pAutonoteTxt[v13].pText, 0, 0, 0); + v15 = pAutonoteFont->CalcTextHeight(v14, &autonotes_window, 1, 0); + v16 = autonotes_window.uFrameY + v15; + if ( (signed int)(autonotes_window.uFrameY + v15) > (signed int)autonotes_window.uFrameHeight ) + break; + pRenderer->DrawTextureTransparent(0x64u, v16 + 12, pSpellBookPagesTextr_10); + ++v12; + autonotes_window.uFrameY = v16 + 24; + } +} //----- (00412E85) -------------------------------------------------------- void BookUI_Journal_Draw() @@ -563,7 +452,7 @@ GUIWindow a1; // [sp+8h] [bp-54h]@10 pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_11); - if ( BtnUp_flag || !dword_506528 ) + if ( BtnUp_flag || !books_primary_item_per_page ) { v13 = pTex_tab_an_6a__zoom_off; v11 = pViewport->uViewportTL_Y + 2; @@ -577,7 +466,7 @@ } pRenderer->DrawTextureTransparent(v0, v11, v13); - if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 ) + if ( BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book ) { v14 = pTex_tab_an_7a__zoot_off; v12 = pViewport->uViewportTL_Y + 38; @@ -591,9 +480,9 @@ } pRenderer->DrawTextureTransparent(v1, v12, v14); - if ( !byte_5C6D50[dword_506528] ) + if ( !byte_5C6D50[books_primary_item_per_page] ) { - v2 = achieved_awards[dword_506528]; + v2 = achieved_awards[books_primary_item_per_page]; a1.uFrameWidth = game_viewport_width; a1.uFrameX = game_viewport_x; a1.uFrameY = game_viewport_y; @@ -613,40 +502,34 @@ 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 ) + if ( BtnDown_flag && books_primary_item_per_page + num_achieved_awards < full_num_items_in_book ) { 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; + v5 = books_page_number++; + books_primary_item_per_page += num_achieved_awards; + books_num_items_per_page[v5] = num_achieved_awards; } - if ( BtnUp_flag && dword_50651C ) + if ( BtnUp_flag && books_page_number ) { pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); - --dword_50651C; - dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; + --books_page_number; + books_primary_item_per_page -= (unsigned __int8)books_num_items_per_page[books_page_number]; } - if ( !num_achieved_awards || dword_506528 < 1 ) + if ( !num_achieved_awards || books_primary_item_per_page < 1 ) { - dword_506528 = 0; - dword_50651C = 0; + books_primary_item_per_page = 0; + books_page_number = 0; } BtnDown_flag = 0; - v6 = achieved_awards[dword_506528]; + v6 = achieved_awards[books_primary_item_per_page]; 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]); + v8 = BuildDialogueString(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]); + v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[books_primary_item_per_page]); 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; }
--- a/UI/Books/UISpellBook.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/Books/UISpellBook.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -24,46 +24,32 @@ //----- (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 +{ + char pContainer[20]; // [sp+Ch] [bp-1Ch]@7 + + byte_506550 = 0; + if ( pPlayers[uActiveCharacter]->uQuickSpell && (unsigned __int8)pPlayers[uActiveCharacter]->uQuickSpell / 11 == spell_school ) + quick_spell_at_page = (unsigned __int8)pPlayers[uActiveCharacter]->uQuickSpell - 11 * spell_school; + else + quick_spell_at_page = 0; - 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 <= 11; ++i) + { + if (pPlayers[uActiveCharacter]->spellbook.pChapters[spell_school].bIsSpellAvailable[i - 1]) + { + sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]); + SBPageSSpellsTextureList[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); - 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); - } - } + sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]); + SBPageCSpellsTextureList[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); } + } +} //----- (00411597) -------------------------------------------------------- -void OnCloseSpellBook() +void OnCloseBook() { pAllocator->FreeChunk(pSpellFont); pSpellFont = nullptr; @@ -75,7 +61,7 @@ pAutonoteFont = nullptr; pTexture_mapbordr->Release(); pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); dword_506364 = 0; } @@ -90,44 +76,21 @@ 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); + pRenderer->DrawTextureIndexed(476, 450, pSBQuickSpellBtnTextr); + pRenderer->DrawTextureIndexed(561, 450, pSpellBookCloseBtnTextr); } - - - - //----- (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 + Texture *PendingTexture; // edi@1 + Texture *pTexture; // edx@5 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 + unsigned int pX_coord; // esi@18 + unsigned int pY_coord; // 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} }; @@ -137,96 +100,69 @@ BookUI_Spellbook_DrawCurrentSchoolBackground(); - //v0 = pPlayers[uActiveCharacter]; - v1 = 11 * player->lastOpenedSpellbookPage; - //v2 = pIcons_LOD->FindTextureByName("Pending"); - v3 = pIcons_LOD->GetTexture(pIcons_LOD->FindTextureByName("Pending")); + PendingTexture = pIcons_LOD->GetTexture(pIcons_LOD->FindTextureByName("Pending")); pRenderer->ClearZBuffer(0, 479); - v4 = 1; - if ( __OFSUB__(v1, v1 + 11) ^ 1 ) + if ( (11 * player->lastOpenedSpellbookPage) || ((11 * player->lastOpenedSpellbookPage) + 11) )//??? maybe structure need fix { - do + for ( uint i = 1; i <= 11; ++i ) { - if ( *(&player->_guilds_member_bits[v1 + 63] + v4) ) + if (player->_guilds_member_bits[(11 * player->lastOpenedSpellbookPage) + i + 63] ) { - v5 = (Texture *)dword_506408[v4]; - if ( v5 != v3 ) + if ( SBPageSSpellsTextureList[i] != PendingTexture ) { - if ( quick_spell_at_page == v4 ) + if ( quick_spell_at_page == i ) + pTexture = SBPageCSpellsTextureList[i]; + else + pTexture = SBPageSSpellsTextureList[i]; + if ( pTexture->pLevelOfDetail0_prolly_alpha_mask ) { - 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); + pX_coord = pViewport->uViewportTL_X + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Xpos; + pY_coord = pViewport->uViewportTL_Y + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Ypos; + if ( BYTE1(pTexture->pBits) & 2 ) + pRenderer->DrawTextureTransparent(pX_coord, pY_coord, pTexture); else - pRenderer->DrawTextureIndexed(v17, v19, v6); - pRenderer->DrawMaskToZBuffer(pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos, - pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos, v23, v4); + pRenderer->DrawTextureIndexed(pX_coord, pY_coord, pTexture); + pRenderer->DrawMaskToZBuffer(pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Xpos, + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][i]].Ypos, pTexture, i); } } } - ++v4; } - while ( v4 - 1 < 11 ); } - v9 = pMouse->GetCursorPos(&a2); - v10 = pRenderer->pActiveZBuffer[v9->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v24)->y]] & 0xFFFF; + pMouse->GetCursorPos(&a2); + v10 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF; if ( v10 ) { - v11 = dword_5063D8[v10]; - if ( v11->pLevelOfDetail0_prolly_alpha_mask ) + if ( SBPageCSpellsTextureList[v10]->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); + pX_coord = pViewport->uViewportTL_X + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][v10]].Xpos; + pY_coord = pViewport->uViewportTL_Y + pIconPos[player->lastOpenedSpellbookPage][pSpellbookSpellIndices[player->lastOpenedSpellbookPage][v10]].Ypos; + if ( BYTE1(SBPageCSpellsTextureList[v10]->pBits) & 2 ) + pRenderer->DrawTextureTransparent(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]); else - pRenderer->DrawTextureIndexed(v18, v20, v21); + pRenderer->DrawTextureIndexed(pX_coord, pY_coord, SBPageCSpellsTextureList[v10]); } } - v13 = 0; - a2.x = (LONG)&player->pActiveSkills[12]; - v14 = (unsigned int)&player->pActiveSkills[12]; - v15 = (unsigned int)&player->pActiveSkills[12]; - v25 = 0; - do + pX_coord = (unsigned int)&player->pActiveSkills[12]; + pY_coord = (unsigned int)&player->pActiveSkills[12]; + for ( uint i = 0; i < 9; i++ ) { - if ( *(short *)a2.x ) + if ( player->pActiveSkills[12 + i] ) { - if ( player->lastOpenedSpellbookPage == v13 ) + if ( player->lastOpenedSpellbookPage == i ) { - pPageTexture = pTextures_tabs[v13][1]; - v14=texture_tab_coord1[v13][0]; - v15=texture_tab_coord1[v13][1]; + pPageTexture = pTextures_tabs[i][1]; + pX_coord = texture_tab_coord1[i][0]; + pY_coord = texture_tab_coord1[i][1]; } else { - pPageTexture = pTextures_tabs[v13][0]; - v14=texture_tab_coord0[v13][0]; - v15=texture_tab_coord0[v13][1]; + pPageTexture = pTextures_tabs[i][0]; + pX_coord = texture_tab_coord0[i][0]; + pY_coord = texture_tab_coord0[i][1]; } - pRenderer->DrawTextureTransparent(v14, v15, pPageTexture); - v13 = v25; + pRenderer->DrawTextureTransparent(pX_coord, pY_coord, pPageTexture); } - a2.x += 2; - ++v13; - v25 = v13; } - while ( v13 < 9 ); } \ No newline at end of file
--- a/UI/UIBooks.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UIBooks.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -48,8 +48,6 @@ //----- (0041192C) -------------------------------------------------------- void InitializeBookTextures() { - //signed int v0; // ebp@3 - //Texture **v1; // ebx@3 pAudioPlayer->StopChannels(-1, -1); @@ -60,9 +58,9 @@ pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); pSpellBookPagesTextr_9 = pIcons_LOD->LoadTexturePtr("book", TEXTURE_16BIT_PALETTE); pTexture_pagemask = pIcons_LOD->LoadTexturePtr("pagemask", TEXTURE_16BIT_PALETTE); - pTexture_506448 = pIcons_LOD->LoadTexturePtr("ib-m5-u", TEXTURE_16BIT_PALETTE); - ptr_506440 = pIcons_LOD->LoadTexturePtr("ib-m5-d", TEXTURE_16BIT_PALETTE); - pTexture_50643C = pIcons_LOD->LoadTexturePtr("ib-m6-u",TEXTURE_16BIT_PALETTE); + pSpellBookCloseBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m5-u", TEXTURE_16BIT_PALETTE); + pSpellBookClickCloseBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m5-d", TEXTURE_16BIT_PALETTE); + pSBQuickSpellBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m6-u",TEXTURE_16BIT_PALETTE); //v0 = 1; static const char *texNames[9] = // 004E24EC @@ -71,7 +69,7 @@ "SBSB00", "SBMB00", "SBBB00", "SBLB00", "SBDB00" }; - pTexture_506444 = pIcons_LOD->LoadTexturePtr("ib-m6-d",TEXTURE_16BIT_PALETTE); + pSBClickQuickSpellBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m6-d",TEXTURE_16BIT_PALETTE); for (uint i = 0; i < 9; ++i) { pSpellBookPagesTextr[i] = pIcons_LOD->LoadTexturePtr(texNames[i], TEXTURE_16BIT_PALETTE); @@ -106,31 +104,25 @@ //----- (0041140B) -------------------------------------------------------- -void sub_41140B() +void OnCloseSpellBookPage() { - signed int v0; // esi@1 - GUIButton *v1; // eax@3 - GUIButton *v2; // esi@4 + GUIButton *pNextButton; // esi@4 - v0 = 0; - do + for ( uint i = 1; i <= 11; i++ ) { - dword_5063D8[11+v0]->Release(); - dword_506408[11+v0]->Release(); - --v0; + SBPageCSpellsTextureList[i]->Release(); + SBPageSSpellsTextureList[i]->Release(); } - while ( v0 >= -11 ); pIcons_LOD->SyncLoadedFilesCount(); - v1 = pGUIWindow_CurrentMenu->pControlsHead; - if ( v1 ) + if ( pGUIWindow_CurrentMenu->pControlsHead ) { do { - v2 = v1->pNext; - pAllocator->FreeChunk(v1); - v1 = v2; + pNextButton = pGUIWindow_CurrentMenu->pControlsHead->pNext; + pAllocator->FreeChunk(pGUIWindow_CurrentMenu->pControlsHead); + pGUIWindow_CurrentMenu->pControlsHead = pNextButton; } - while ( v2 ); + while ( pNextButton ); } pGUIWindow_CurrentMenu->pControlsHead = 0; pGUIWindow_CurrentMenu->pControlsTail = 0; @@ -138,19 +130,19 @@ } //----- (00411473) -------------------------------------------------------- -void sub_411473() +void OnCloseSpellBook() { pTexture_pagemask->Release(); - pTexture_506448->Release(); - pTexture_50643C->Release(); + pSpellBookCloseBtnTextr->Release(); + pSBQuickSpellBtnTextr->Release(); for (uint i = 0; i < 9; ++i) - { - pSpellBookPagesTextr[i]->Release(); - pTextures_tabs[i][0]->Release(); - pTextures_tabs[i][1]->Release(); - } + { + pSpellBookPagesTextr[i]->Release(); + pTextures_tabs[i][0]->Release(); + pTextures_tabs[i][1]->Release(); + } pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); }
--- a/UI/UIBooks.h Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UIBooks.h Tue Aug 06 00:56:33 2013 +0400 @@ -4,8 +4,7 @@ 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;
--- a/UI/UICharacter.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UICharacter.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -34,6 +34,7 @@ unsigned int ui_mainmenu_copyright_color; +unsigned int ui_character_tooltip_header_default_color; unsigned int ui_character_default_text_color; unsigned int ui_character_skill_highlight_color; unsigned int ui_character_header_text_color; @@ -41,6 +42,12 @@ unsigned int ui_character_bonus_text_color_neg; unsigned int ui_character_skill_upgradeable_color; unsigned int ui_character_skill_default_color; +unsigned int ui_character_stat_default_color; +unsigned int ui_character_stat_buffed_color; +unsigned int ui_character_stat_debuffed_color; +unsigned int ui_character_skillinfo_can_learn; +unsigned int ui_character_skillinfo_can_learn_gm; +unsigned int ui_character_skillinfo_cant_learn; std::array<unsigned int, 6> ui_character_award_color; unsigned int ui_game_minimap_outline_color; @@ -77,6 +84,113 @@ unsigned int ui_book_journal_text_color; unsigned int ui_book_journal_text_shadow; +unsigned int ui_game_dialogue_npc_name_color; +unsigned int ui_game_dialogue_option_highlight_color; +unsigned int ui_game_dialogue_option_normal_color; + +unsigned int ui_house_player_cant_interact_color; + + + +void set_default_ui_skin() +{ + ui_mainmenu_copyright_color = TargetColor(255, 255, 255); + + ui_character_tooltip_header_default_color = TargetColor(255, 255, 155); + ui_character_default_text_color = TargetColor(255, 255, 255); + ui_character_header_text_color = TargetColor(255, 255, 155); + ui_character_bonus_text_color = TargetColor(0, 255, 0); + ui_character_bonus_text_color_neg = TargetColor(255, 0, 0); + + ui_character_skill_upgradeable_color = TargetColor(0, 175, 255); + ui_character_skill_default_color = TargetColor(255, 0, 0); + ui_character_skill_highlight_color = TargetColor(255, 0, 0); + + ui_character_stat_default_color = TargetColor(255, 255, 255); + ui_character_stat_buffed_color = TargetColor(0, 255, 0); + ui_character_stat_debuffed_color = TargetColor(255, 35, 0); + + ui_character_skillinfo_can_learn = TargetColor(255, 255, 255); + ui_character_skillinfo_can_learn_gm = TargetColor(255, 255, 0); + ui_character_skillinfo_cant_learn = TargetColor(255, 0, 0); + + ui_character_award_color[0] = TargetColor(248, 108, 160); + ui_character_award_color[1] = TargetColor(112, 220, 248); + ui_character_award_color[2] = TargetColor(192, 192, 240); + ui_character_award_color[3] = TargetColor( 64, 244, 96); + ui_character_award_color[4] = TargetColor(232, 244, 96); + ui_character_award_color[5] = TargetColor(240, 252, 192); + + ui_game_minimap_outline_color = TargetColor(0, 0, 255); + ui_game_minimap_actor_friendly_color = TargetColor(0, 255, 0); + ui_game_minimap_actor_hostile_color = TargetColor(255, 0, 0); + ui_game_minimap_actor_corpse_color = TargetColor(255, 255, 0); + ui_game_minimap_decoration_color_1 = TargetColor(255, 255, 255); + ui_game_minimap_projectile_color = TargetColor(255, 0, 0); + ui_game_minimap_treasure_color = TargetColor(0, 0, 255); + + ui_game_character_record_playerbuff_colors[0] = TargetColor(150, 212, 255); + ui_game_character_record_playerbuff_colors[1] = TargetColor(225, 225, 225); + ui_game_character_record_playerbuff_colors[2] = TargetColor(255, 128, 0); + ui_game_character_record_playerbuff_colors[3] = TargetColor(128, 128, 128); + ui_game_character_record_playerbuff_colors[4] = TargetColor(225, 225, 225); + ui_game_character_record_playerbuff_colors[5] = TargetColor(255, 85, 0); + ui_game_character_record_playerbuff_colors[6] = TargetColor(255, 128, 0); + ui_game_character_record_playerbuff_colors[7] = TargetColor(255, 85, 0); + ui_game_character_record_playerbuff_colors[8] = TargetColor(225, 225, 225); + ui_game_character_record_playerbuff_colors[9] = TargetColor(235, 15, 255); + ui_game_character_record_playerbuff_colors[10] = TargetColor(192, 192, 240); + ui_game_character_record_playerbuff_colors[11] = TargetColor(225, 225, 225); + ui_game_character_record_playerbuff_colors[12] = TargetColor(255, 128, 0); + ui_game_character_record_playerbuff_colors[13] = TargetColor(150, 212, 255); + ui_game_character_record_playerbuff_colors[14] = TargetColor(128, 128, 128); + ui_game_character_record_playerbuff_colors[15] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[16] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[17] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[18] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[19] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[20] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[21] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[22] = TargetColor(0, 128, 255); + ui_game_character_record_playerbuff_colors[23] = TargetColor(0, 128, 255); + + ui_gamemenu_video_gamma_title_color = TargetColor(255, 255, 155); + ui_gamemenu_keys_action_name_color = TargetColor(255, 255, 255); + ui_gamemenu_keys_key_selection_blink_color_1 = TargetColor(50, 0, 0); + ui_gamemenu_keys_key_selection_blink_color_2 = TargetColor(225, 205, 35); + ui_gamemenu_keys_key_default_color = TargetColor(255, 255, 255); + + ui_book_quests_title_color = TargetColor(255, 255, 255); + ui_book_quests_text_color = TargetColor(255, 255, 255); + ui_book_autonotes_title_color = TargetColor(255, 255, 255); + ui_book_autonotes_text_color = TargetColor(255, 255, 255); + ui_book_map_title_color = TargetColor(255, 255, 255); + ui_book_map_coordinates_color = TargetColor(255, 255, 255); + + ui_book_calendar_title_color = TargetColor(255, 255, 255); + ui_book_calendar_time_color = TargetColor(75, 75, 75); + ui_book_calendar_day_color = TargetColor(75, 75, 75); + ui_book_calendar_month_color = TargetColor(75, 75, 75); + ui_book_calendar_year_color = TargetColor(75, 75, 75); + ui_book_calendar_moon_color = TargetColor(75, 75, 75); + ui_book_calendar_location_color = TargetColor(75, 75, 75); + + ui_book_journal_title_color = TargetColor(255, 255, 255); + ui_book_journal_text_color = TargetColor(255, 255, 255); + ui_book_journal_text_shadow = TargetColor(0, 0, 0); + + ui_game_dialogue_npc_name_color = TargetColor(21, 153, 233); + ui_game_dialogue_option_highlight_color = TargetColor(225, 205, 35); + ui_game_dialogue_option_normal_color = TargetColor(255, 255, 255); + + ui_house_player_cant_interact_color = TargetColor(255, 255, 155); +} + + + + + + std::array<unsigned int, 16> papredoll_dbrds; unsigned int papredoll_drhs[4]; unsigned int papredoll_dlhus[4]; @@ -273,87 +387,6 @@ -void set_default_ui_skin() -{ - ui_mainmenu_copyright_color = TargetColor(255, 255, 255); - - ui_character_default_text_color = TargetColor(255, 255, 255); - ui_character_header_text_color = TargetColor(255, 255, 155); - ui_character_bonus_text_color = TargetColor(0, 255, 0); - ui_character_bonus_text_color_neg = TargetColor(255, 0, 0); - - ui_character_skill_upgradeable_color = TargetColor(0, 175, 255); - ui_character_skill_default_color = TargetColor(255, 0, 0); - ui_character_skill_highlight_color = TargetColor(255, 0, 0); - - ui_character_award_color[0] = TargetColor(248, 108, 160); - ui_character_award_color[1] = TargetColor(112, 220, 248); - ui_character_award_color[2] = TargetColor(192, 192, 240); - ui_character_award_color[3] = TargetColor( 64, 244, 96); - ui_character_award_color[4] = TargetColor(232, 244, 96); - ui_character_award_color[5] = TargetColor(240, 252, 192); - - ui_game_minimap_outline_color = TargetColor(0, 0, 255); - ui_game_minimap_actor_friendly_color = TargetColor(0, 255, 0); - ui_game_minimap_actor_hostile_color = TargetColor(255, 0, 0); - ui_game_minimap_actor_corpse_color = TargetColor(255, 255, 0); - ui_game_minimap_decoration_color_1 = TargetColor(255, 255, 255); - ui_game_minimap_projectile_color = TargetColor(255, 0, 0); - ui_game_minimap_treasure_color = TargetColor(0, 0, 255); - ui_game_character_record_playerbuff_colors[0] = TargetColor(150, 212, 255); - ui_game_character_record_playerbuff_colors[1] = TargetColor(225, 225, 225); - ui_game_character_record_playerbuff_colors[2] = TargetColor(255, 128, 0); - ui_game_character_record_playerbuff_colors[3] = TargetColor(128, 128, 128); - ui_game_character_record_playerbuff_colors[4] = TargetColor(225, 225, 225); - ui_game_character_record_playerbuff_colors[5] = TargetColor(255, 85, 0); - ui_game_character_record_playerbuff_colors[6] = TargetColor(255, 128, 0); - ui_game_character_record_playerbuff_colors[7] = TargetColor(255, 85, 0); - ui_game_character_record_playerbuff_colors[8] = TargetColor(225, 225, 225); - ui_game_character_record_playerbuff_colors[9] = TargetColor(235, 15, 255); - ui_game_character_record_playerbuff_colors[10] = TargetColor(192, 192, 240); - ui_game_character_record_playerbuff_colors[11] = TargetColor(225, 225, 225); - ui_game_character_record_playerbuff_colors[12] = TargetColor(255, 128, 0); - ui_game_character_record_playerbuff_colors[13] = TargetColor(150, 212, 255); - ui_game_character_record_playerbuff_colors[14] = TargetColor(128, 128, 128); - ui_game_character_record_playerbuff_colors[15] = TargetColor(255, 255, 155); - ui_game_character_record_playerbuff_colors[16] = TargetColor(255, 255, 155); - ui_game_character_record_playerbuff_colors[17] = TargetColor(255, 255, 155); - ui_game_character_record_playerbuff_colors[18] = TargetColor(255, 255, 155); - ui_game_character_record_playerbuff_colors[19] = TargetColor(255, 255, 155); - ui_game_character_record_playerbuff_colors[20] = TargetColor(255, 255, 155); - ui_game_character_record_playerbuff_colors[21] = TargetColor(255, 255, 155); - ui_game_character_record_playerbuff_colors[22] = TargetColor(0, 128, 255); - ui_game_character_record_playerbuff_colors[23] = TargetColor(0, 128, 255); - - ui_gamemenu_video_gamma_title_color = TargetColor(255, 255, 155); - ui_gamemenu_keys_action_name_color = TargetColor(255, 255, 255); - ui_gamemenu_keys_key_selection_blink_color_1 = TargetColor(50, 0, 0); - ui_gamemenu_keys_key_selection_blink_color_2 = TargetColor(225, 205, 35); - ui_gamemenu_keys_key_default_color = TargetColor(255, 255, 255); - - ui_book_quests_title_color = TargetColor(255, 255, 255); - ui_book_quests_text_color = TargetColor(255, 255, 255); - ui_book_autonotes_title_color = TargetColor(255, 255, 255); - ui_book_autonotes_text_color = TargetColor(255, 255, 255); - ui_book_map_title_color = TargetColor(255, 255, 255); - ui_book_map_coordinates_color = TargetColor(255, 255, 255); - - ui_book_calendar_title_color = TargetColor(255, 255, 255); - ui_book_calendar_time_color = TargetColor(75, 75, 75); - ui_book_calendar_day_color = TargetColor(75, 75, 75); - ui_book_calendar_month_color = TargetColor(75, 75, 75); - ui_book_calendar_year_color = TargetColor(75, 75, 75); - ui_book_calendar_moon_color = TargetColor(75, 75, 75); - ui_book_calendar_location_color = TargetColor(75, 75, 75); - - ui_book_journal_title_color = TargetColor(255, 255, 255); - ui_book_journal_text_color = TargetColor(255, 255, 255); - ui_book_journal_text_shadow = TargetColor(0, 0, 0); -} - - - - //----- (00421626) -------------------------------------------------------- GUIWindow *CharacterUI_Initialize(unsigned int _this) { @@ -594,49 +627,49 @@ strcat(pTmpBuf.data(), "\f00000"); pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf.data(), 0, 0, 0); - result = dword_506528; + result = books_primary_item_per_page; a1.uFrameX = 12; a1.uFrameY = 48; a1.uFrameWidth = 424; a1.uFrameHeight = 290; a1.uFrameZ = 435; a1.uFrameW = 337; - if (BtnDown_flag && num_achieved_awards + dword_506528 < num_achieved_awards_2) - result = dword_506528++ + 1; + if (BtnDown_flag && num_achieved_awards + books_primary_item_per_page < full_num_items_in_book) + result = books_primary_item_per_page++ + 1; if (BtnUp_flag && result) { --result; - dword_506528 = result; + books_primary_item_per_page = result; } - if ( dword_50651C < 0 ) + if ( books_page_number < 0 ) { result += num_achieved_awards; - dword_506528 = result; - if ( (signed int)(num_achieved_awards + result) > num_achieved_awards_2 ) + books_primary_item_per_page = result; + if ( (signed int)(num_achieved_awards + result) > full_num_items_in_book ) { - result = num_achieved_awards_2 - num_achieved_awards; - dword_506528 = result; + result = full_num_items_in_book - num_achieved_awards; + books_primary_item_per_page = result; } } - else if ( dword_50651C > 0 ) + else if ( books_page_number > 0 ) { result -= num_achieved_awards; - dword_506528 = result; + books_primary_item_per_page = result; if ( (result & 0x80000000u) != 0 ) { result = 0; - dword_506528 = result; + books_primary_item_per_page = result; } } //LABEL_14: BtnDown_flag = 0; BtnUp_flag = 0; num_achieved_awards = 0; - dword_50651C = 0; + books_page_number = 0; - for (uint i = result; i < num_achieved_awards_2; ++i) + for (uint i = result; i < full_num_items_in_book; ++i) { v5 = achieved_awards[i]; v6 = (char *)pAwards[v5].pText;//(char *)dword_723E80_award_related[v20 / 4]; @@ -928,14 +961,14 @@ if ( !bRingsShownInCharScreen ) pRenderer->DrawMaskToZBuffer(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]), player->pEquipment.uArmor); v6 = player->pEquipment.uMainHand; - if ( !v6 || (v7 = *(int *)&pPlayers[uPlayerID]->pInventoryItems[v6-1], pItemsTable->pItems[v7].uEquipType != 1) + if ( !v6 || (v7 = *(int *)&pPlayers[uPlayerID]->pInventoryItemList[v6-1], pItemsTable->pItems[v7].uEquipType != 1) && (pItemsTable->pItems[v7].uSkillType != 4 || pPlayers[uPlayerID]->pEquipment.uShield) ) pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1])); pMainHandNum4 = pPlayers[uPlayerID]->pEquipment.uMainHand; if ( pMainHandNum4 ) { - item_MainHand4 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum4 - 1]; + item_MainHand4 = &pPlayers[uPlayerID]->pInventoryItemList[pMainHandNum4 - 1]; pX_MainHand4 = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][1][0] - pItemsTable->pItems[item_MainHand4->uItemID].uEquipX; pY_MainHand4 = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][1][1] - pItemsTable->pItems[item_MainHand4->uItemID].uEquipY; if ( item_MainHand4->uItemID == 64 ) //blaster @@ -987,7 +1020,7 @@ pBowNum = pPlayers[uPlayerID]->pEquipment.uBow; //сначала рисуется лук if ( pBowNum ) { - itemBow = &pPlayers[uPlayerID]->pInventoryItems[pBowNum - 1]; + itemBow = &pPlayers[uPlayerID]->pInventoryItemList[pBowNum - 1]; pX_Bow = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][2][0] - pItemsTable->pItems[itemBow->uItemID].uEquipX; pY_Bow = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][2][1] - pItemsTable->pItems[itemBow->uItemID].uEquipY; pBowTextureNum = pIcons_LOD->LoadTexture(pItemsTable->pItems[itemBow->uItemID].pIconName, TEXTURE_16BIT_PALETTE); @@ -1031,7 +1064,7 @@ pCloakNum = pPlayers[uPlayerID]->pEquipment.uCloak;// потом плащ if ( pCloakNum ) { - item_Cloak = &pPlayers[uPlayerID]->pInventoryItems[pCloakNum - 1]; + item_Cloak = &pPlayers[uPlayerID]->pInventoryItemList[pCloakNum - 1]; switch ( item_Cloak->uItemID ) { case ITEM_RELIC_TWILIGHT: @@ -1096,7 +1129,7 @@ pArmorNum = pPlayers[uPlayerID]->pEquipment.uArmor;// потом броня if ( pArmorNum ) { - item_Armor = &pPlayers[uPlayerID]->pInventoryItems[pArmorNum - 1]; + item_Armor = &pPlayers[uPlayerID]->pInventoryItemList[pArmorNum - 1]; switch ( item_Armor->uItemID ) { case 504: @@ -1265,7 +1298,7 @@ pBootNum = pPlayers[uPlayerID]->pEquipment.uBoot;//далее обувь if ( pBootNum ) { - item_Boot = &pPlayers[uPlayerID]->pInventoryItems[pBootNum - 1]; + item_Boot = &pPlayers[uPlayerID]->pInventoryItemList[pBootNum - 1]; switch ( item_Boot->uItemID ) { case 529: @@ -1325,7 +1358,7 @@ } } pMainHandNum = pPlayers[uPlayerID]->pEquipment.uMainHand; - if ( !pMainHandNum || (v70 = *(int *)&pPlayers[uPlayerID]->pInventoryItems[pMainHandNum -1], pItemsTable->pItems[v70].uEquipType != 1) + if ( !pMainHandNum || (v70 = *(int *)&pPlayers[uPlayerID]->pInventoryItemList[pMainHandNum -1], pItemsTable->pItems[v70].uEquipType != 1) && (pItemsTable->pItems[v70].uSkillType != 4 || pPlayers[uPlayerID]->pEquipment.uShield) ) pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1], @@ -1333,7 +1366,7 @@ pBeltNum = pPlayers[uPlayerID]->pEquipment.uBelt;// далее пояс if ( pBeltNum ) { - item_Belt = &pPlayers[uPlayerID]->pInventoryItems[pBeltNum - 1]; + item_Belt = &pPlayers[uPlayerID]->pInventoryItemList[pBeltNum - 1]; switch ( item_Belt->uItemID ) { case ITEM_RILIC_TITANS_BELT: @@ -1396,7 +1429,7 @@ pMainHandNum2 = pPlayers[uPlayerID]->pEquipment.uMainHand; if ( pMainHandNum2 ) { - v83 = pPlayers[uPlayerID]->pInventoryItems[pMainHandNum2 - 1].uItemID; + v83 = pPlayers[uPlayerID]->pInventoryItemList[pMainHandNum2 - 1].uItemID; if ( pItemsTable->pItems[v83].uEquipType == 1 || pItemsTable->pItems[v83].uSkillType == PLAYER_SKILL_SPEAR && !pPlayers[uPlayerID]->pEquipment.uShield ) pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], @@ -1406,7 +1439,7 @@ pCloakCollarNum = pPlayers[uPlayerID]->pEquipment.uCloak;//далее воротник плаща if ( pCloakCollarNum ) { - item_CloakCollar = &pPlayers[uPlayerID]->pInventoryItems[pCloakCollarNum - 1]; + item_CloakCollar = &pPlayers[uPlayerID]->pInventoryItemList[pCloakCollarNum - 1]; switch ( item_CloakCollar->uItemID ) { case 525: @@ -1480,7 +1513,7 @@ pHelmNum = pPlayers[uPlayerID]->pEquipment.uHelm;//далее шлем if ( pHelmNum ) { - item_Helm = &pPlayers[uPlayerID]->pInventoryItems[pHelmNum-1]; + item_Helm = &pPlayers[uPlayerID]->pInventoryItemList[pHelmNum-1]; switch ( item_Helm->uItemID ) { case 521: @@ -1551,7 +1584,7 @@ pMainHandNum3 = pPlayers[uPlayerID]->pEquipment.uMainHand;//weapon in right hand if ( pMainHandNum3 ) { - item_MainHand3 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum3 - 1]; + item_MainHand3 = &pPlayers[uPlayerID]->pInventoryItemList[pMainHandNum3 - 1]; pX_MainHand3 = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][1][0] - pItemsTable->pItems[item_MainHand3->uItemID].uEquipX; pY_MainHand3 = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][1][1] - pItemsTable->pItems[item_MainHand3->uItemID].uEquipY; if ( item_MainHand3->uItemID == 64 ) @@ -1600,7 +1633,7 @@ pShieldNum = pPlayers[uPlayerID]->pEquipment.uShield;// далее щит if ( pShieldNum ) { - item_Shield = &pPlayers[uPlayerID]->pInventoryItems[pShieldNum - 1]; + item_Shield = &pPlayers[uPlayerID]->pInventoryItemList[pShieldNum - 1]; v149 = pItemsTable->pItems[item_Shield->uItemID].uSkillType; if ( v149 == 2 || v149 == 1 ) { @@ -1677,7 +1710,7 @@ pMainHandNum5 = pPlayers[uPlayerID]->pEquipment.uMainHand; if ( pMainHandNum5 ) { - item_MainHand5 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum5 - 1]; + item_MainHand5 = &pPlayers[uPlayerID]->pInventoryItemList[pMainHandNum5 - 1]; if ( pItemsTable->pItems[item_MainHand5->uItemID].uEquipType == 1 || pItemsTable->pItems[item_MainHand5->uItemID].uSkillType == PLAYER_SKILL_SPEAR && !pPlayers[uPlayerID]->pEquipment.uShield ) @@ -1716,13 +1749,13 @@ int i = 0; for (uint i = 0; i < 126; ++i) { - int v26 = (int)(player->pInventoryIndices + i); + int v26 = (int)(player->pInventoryMatrix + i); - if (player->pInventoryIndices[i] <= 0) + if (player->pInventoryMatrix[i] <= 0) continue; - int item_idx = player->pInventoryIndices[i]; - auto item = &player->pInventoryItems[item_idx - 1]; + int item_idx = player->pInventoryMatrix[i]; + auto item = &player->pInventoryItemList[item_idx - 1]; if (!item->uItemID) continue; @@ -1845,7 +1878,7 @@ CharacterUI_DrawItem(pPaperdollRingsX[i], pPaperdollRingsY[i], - &player->pInventoryItems[player->pEquipment.uRings[i] - 1], + &player->pInventoryItemList[player->pEquipment.uRings[i] - 1], player->pEquipment.uRings[i]); } @@ -1853,14 +1886,14 @@ if (player->pEquipment.uAmulet) { CharacterUI_DrawItem(493, 91, - &player->pInventoryItems[player->pEquipment.uAmulet - 1], + &player->pInventoryItemList[player->pEquipment.uAmulet - 1], player->pEquipment.uAmulet); } if (player->pEquipment.uGlove) { CharacterUI_DrawItem(586, 88, - &player->pInventoryItems[player->pEquipment.uGlove - 1], + &player->pInventoryItemList[player->pEquipment.uGlove - 1], player->pEquipment.uGlove); } } @@ -2549,8 +2582,8 @@ memset(pTmpBuf2.data(), 0, 0x7D0u); BtnDown_flag = 0; BtnUp_flag = 0; - dword_50651C = 0; - dword_506528 = 0; + books_page_number = 0; + books_primary_item_per_page = 0; for (int i = 0; i < 105; ++i) { if ( _449B57_test_bit(pPlayer->_guilds_member_bits, i) && pAwards[i].pText ) @@ -2558,11 +2591,11 @@ achieved_awards[num_achieved_awards++] = (AwardType)i; } } - num_achieved_awards_2 = num_achieved_awards; + full_num_items_in_book = num_achieved_awards; num_achieved_awards = 0; //sort awards index - if (num_achieved_awards_2 > 0) + if (full_num_items_in_book > 0) { std::stable_sort(achieved_awards.begin(), achieved_awards.end(), awardSort); } @@ -2688,7 +2721,7 @@ v2 = pPlayers[uActiveCharacter]->pEquipment.uShield; //v54 = pPlayers[uActiveCharacter]->pEquipment.uShield; //v53 = v1; - if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1 - 1]].uEquipType == 1 ) + if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItemList[v1 - 1]].uEquipType == 1 ) v51 = v1; v3 = pParty->pPickedItem.uItemID; if ( pParty->pPickedItem.uItemID ) @@ -2712,7 +2745,7 @@ { if ( (pSkillType == 8 || pSkillType == 1 || pSkillType == 2) && v1 - && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1-1]].uSkillType == 4 ) + && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItemList[v1-1]].uSkillType == 4 ) { LOBYTE(v5) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_SPEAR); if ( (signed int)SkillToMastery(v5) < 3 ) @@ -2771,12 +2804,12 @@ { if ( !*(int *)v7 ) { - v8 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + v8 = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot(); if ( v8 >= 0 ) { v9 = v52; pParty->pPickedItem.uBodyAnchor = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v8], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v8])); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v8], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v8])); *(&pPlayers[uActiveCharacter]->pEquipment.uShield + v9) = v8 + 1; pMouse->RemoveHoldingItem(); break; @@ -2830,14 +2863,14 @@ } else { - v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + v52 = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot(); if ( v52 < 0 ) return; if ( !v51 ) { pParty->pPickedItem.uBodyAnchor = 1; v17 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52])); pPlayers[uActiveCharacter]->pEquipment.uShield = v17; pMouse->RemoveHoldingItem(); return; @@ -2849,7 +2882,7 @@ pParty->SetHoldingItem((ItemGen *)(v15 + 532)); _this.uBodyAnchor = 1; v16 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52])); pPlayers[uActiveCharacter]->pEquipment.uShield = v16; } pPlayers[uActiveCharacter]->pEquipment.uMainHand = 0; @@ -2905,12 +2938,12 @@ } break; } - v23 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + v23 = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot(); if ( v23 < 0 ) return; pParty->pPickedItem.uBodyAnchor = 1; - v50 = (unsigned int)&pPlayers[uActiveCharacter]->pInventoryItems[v23]; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v23], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v23])); + v50 = (unsigned int)&pPlayers[uActiveCharacter]->pInventoryItemList[v23]; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v23], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v23])); pPlayers[uActiveCharacter]->pEquipment.uShield = v23 + 1; pMouse->RemoveHoldingItem(); if ( v52 != 12 ) @@ -2928,12 +2961,12 @@ } if ( !v1 ) { - v26 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + v26 = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot(); if ( v26 < 0 ) return; pParty->pPickedItem.uBodyAnchor = 2; - v50 = (unsigned int)&pPlayers[uActiveCharacter]->pInventoryItems[v26]; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v26], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v26])); + v50 = (unsigned int)&pPlayers[uActiveCharacter]->pInventoryItemList[v26]; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v26], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v26])); pPlayers[uActiveCharacter]->pEquipment.uMainHand = v26 + 1; pMouse->RemoveHoldingItem(); if ( v52 != 12 ) @@ -2999,7 +3032,7 @@ } else { - v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + v52 = pPlayers[uActiveCharacter]->FindFreeInventoryListSlot(); if ( v52 >= 0 ) { if ( v2 ) @@ -3011,7 +3044,7 @@ pParty->SetHoldingItem((ItemGen *)(v29 + 532)); _this.uBodyAnchor = 2; v30 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52])); pPlayers[uActiveCharacter]->pEquipment.uShield = 0; pPlayers[uActiveCharacter]->pEquipment.uMainHand = v30; } @@ -3019,7 +3052,7 @@ { pParty->pPickedItem.uBodyAnchor = 2; v31 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItemList[v52])); pPlayers[uActiveCharacter]->pEquipment.uMainHand = v31; pMouse->RemoveHoldingItem(); } @@ -3085,7 +3118,7 @@ v35 = pPlayers[uActiveCharacter]->pEquipment.uBow; if ( v35 ) { - auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v35 - 1]; + auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v35 - 1]; pParty->SetHoldingItem(_a); _a->Reset(); pPlayers[uActiveCharacter]->pEquipment.uBow = 0;
--- a/UI/UIGuilds.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UIGuilds.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -95,7 +95,7 @@ { if ( dialog_menu_id != HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) //buy skill { - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { if ( pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] ) { @@ -151,7 +151,7 @@ ++v7; } while ( v63 < 452 ); - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v8 = 0; v9 = 12; @@ -182,8 +182,8 @@ v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14)); v16 = (int)window_SpeakInHouse->ptr_1C; uPlayerID = uActiveCharacter - 1; - v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, BildingType_MagicShop, v16, 2); - v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); + v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, BuildingType_MagicShop, v16, 2); + v18 = BuildDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); v19 = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0); working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorWhite, v18, 3); return; @@ -199,7 +199,7 @@ pDialogueWindow->pNumPresenceButton = 0; return; } - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; v61 = 0; pSkillFlag = false;
--- a/UI/UIHouses.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UIHouses.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -13,7 +13,6 @@ #include "..\Mouse.h" #include "..\GUIWindow.h" #include "..\GUIFont.h" -#include "..\Events2D.h" #include "..\Overlays.h" #include "..\Outdoor.h" #include "..\AudioPlayer.h" @@ -31,7 +30,7 @@ int dword_591080; // weak -int in_current_building_type; // 00F8B198 +BuildingType in_current_building_type; // 00F8B198 HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C #pragma pack(push, 1) @@ -314,6 +313,485 @@ {"Player Castle Bad", 0x24, 0, 25, 0, 0} }}; + + +//----- (004B3A72) -------------------------------------------------------- +void InitializaDialogueOptions_Tavern(BuildingType type) +{ + int num_buttons; // esi@1 + + num_buttons = 0; + if (type == BuildingType_Tavern) + { + num_buttons = 2; + CreateButtonInColumn(0, 102); + CreateButtonInColumn(1, 103); + if ( pParty->HasItem(651) ) //Arcomage Deck + { + num_buttons = 3; + CreateButtonInColumn(2, 104); + } + } + pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2); + dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; +} +// F8B1E0: using guessed type int dword_F8B1E0; + +//----- (004B3AD4) -------------------------------------------------------- +void InitializaDialogueOptions_Shops(BuildingType type) +{ + switch (type) + { + case BuildingType_WeaponShop: + case BuildingType_ArmorShop: + case BuildingType_MagicShop: + { + CreateButtonInColumn(0, 3); + CreateButtonInColumn(1, 4); + CreateButtonInColumn(2, 5); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_AlchemistShop: + { + CreateButtonInColumn(0, 3); + CreateButtonInColumn(1, 4); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + } + + dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; +} +// F8B1E0: using guessed type int dword_F8B1E0; + +//----- (004B3B42) -------------------------------------------------------- +void InitializaDialogueOptions(BuildingType type) +{ + /*int v1; // ecx@18 + int v2; // ecx@19 + int v3; // ecx@20 + signed int v4; // esi@22 + signed int v5; // eax@22 + unsigned int v6; // edx@24 + int v7; // ecx@24 + int result; // eax@43 + int v9; // [sp-10h] [bp-14h]@28 + int v10; // [sp-Ch] [bp-10h]@28 + int v11; // [sp-8h] [bp-Ch]@28 + unsigned int v12; // [sp-4h] [bp-8h]@4 + unsigned int v13; // [sp-4h] [bp-8h]@5 + unsigned int v14; // [sp-4h] [bp-8h]@9 + unsigned int v15; // [sp-4h] [bp-8h]@10 + unsigned int v16; // [sp-4h] [bp-8h]@14 + int v17; // [sp-4h] [bp-8h]@28*/ + + switch (type) + { + case BuildingType_WeaponShop: + case BuildingType_ArmorShop: + case BuildingType_MagicShop: + case BuildingType_AlchemistShop: + { + CreateButtonInColumn(0, 2); + CreateButtonInColumn(1, 95); + CreateButtonInColumn(2, 94); + CreateButtonInColumn(3, 96); + pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2); + } + break; + + case BuildingType_FireGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 48); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_AirGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 49); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_WaterGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 50); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_EarthGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 51); + CreateButtonInColumn(2, 72); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_SpiritGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 52); + CreateButtonInColumn(2, 61); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_MindGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 53); + CreateButtonInColumn(2, 61); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_BodyGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 54); + CreateButtonInColumn(2, 61); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_LightGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 55); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_DarkGuild: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 56); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_14: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 48); + CreateButtonInColumn(2, 49); + CreateButtonInColumn(3, 50); + CreateButtonInColumn(4, 51); + pDialogueWindow->_41D08F_set_keyboard_control_group(5, 1, 0, 2); + } + break; + + case BuildingType_15: + { + CreateButtonInColumn(0, 18); + CreateButtonInColumn(1, 52); + CreateButtonInColumn(2, 53); + CreateButtonInColumn(3, 54); + pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2); + } + break; + + case BuildingType_16: + case BuildingType_TownHall: + { + int num_buttons = 1; + CreateButtonInColumn(0, 99); + + if (pParty->uFine) + { + num_buttons++; + CreateButtonInColumn(1, 100); + } + + pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2); + } + break; + + case BuildingType_Bank: + { + CreateButtonInColumn(0, 7); + CreateButtonInColumn(1, 8); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_Temple: + { + CreateButtonInColumn(0, 10); + CreateButtonInColumn(1, 11); + CreateButtonInColumn(2, 96); + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + } + break; + + case BuildingType_Stables: + case BuildingType_Boats: + { + CreateButtonInColumn(0, 105); + CreateButtonInColumn(1, 106); + CreateButtonInColumn(2, 107); + CreateButtonInColumn(3, 108); + pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2); + } + break; + + case BuildingType_Training: + { + CreateButtonInColumn(0, 17); + CreateButtonInColumn(1, 96); + pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); + } + break; + + case BuildingType_Tavern: + { + CreateButtonInColumn(0, 0xFu); + CreateButtonInColumn(1, 0x10u); + CreateButtonInColumn(2, 0x60u); + if ( (signed int)window_SpeakInHouse->ptr_1C < 108 || (signed int)window_SpeakInHouse->ptr_1C > 120 ) + { + pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); + break; + } + CreateButtonInColumn(3, 101); + pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 2); + } + break; + + case BuildingType_18: + case BuildingType_19: + case BuildingType_Throne_Room: + case BuildingType_24: + case BuildingType_Unic: + case BuildingType_1A: + case BuildingType_House: + case BuildingType_Jail: + break; + + default: + assert(false && "Invalid enumeration value"); + } + +/* if ( a1 > 13 ) + { + if ( a1 > 22 ) + { + if ( a1 == 23 ) + { + CreateButtonInColumn(0, 0xAu); + CreateButtonInColumn(1, 0xBu); + v14 = 96; +LABEL_41: + CreateButtonInColumn(2, v14); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 3; + goto LABEL_42; + } + if ( a1 <= 26 ) + goto LABEL_43; + if ( a1 > 28 ) + { + if ( a1 != 30 ) + goto LABEL_43; + CreateButtonInColumn(0, 0x11u); + v16 = 96; + goto LABEL_37; + } + CreateButtonInColumn(0, 0x69u); + CreateButtonInColumn(1, 0x6Au); + CreateButtonInColumn(2, 0x6Bu); + v12 = 108; + } + else + { + if ( a1 == 22 ) + { + CreateButtonInColumn(0, 7u); + v16 = 8; + goto LABEL_37; + } + v1 = a1 - 14; + if ( !v1 ) // == 14 + { + CreateButtonInColumn(0, 0x12u); + CreateButtonInColumn(1, 0x30u); + CreateButtonInColumn(2, 0x31u); + CreateButtonInColumn(3, 0x32u); + CreateButtonInColumn(4, 0x33u); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 5; + goto LABEL_42; + } + v2 = v1 - 1; + if ( v2 ) // > 15 + { + v3 = v2 - 2; + if ( v3 ) // > 17 + { + if ( v3 != 4 ) // 18, 19, 20 + goto LABEL_43; + CreateButtonInColumn(0, 0xFu); // 21 + CreateButtonInColumn(1, 0x10u); + v4 = 3; + CreateButtonInColumn(2, 0x60u); + v5 = (signed int)window_SpeakInHouse->ptr_1C; + if ( v5 < 108 || v5 > 120 ) + goto LABEL_28; + v4 = 4; + v6 = 101; + v7 = 3; + } + else // 16, 17 + { + v4 = 1; + CreateButtonInColumn(0, 0x63u); + if ( !pParty->uFine ) + { +LABEL_28: + v17 = 2; + v11 = 0; + v10 = 1; + v9 = v4; +LABEL_42: + pDialogueWindow->_41D08F_set_keyboard_control_group(v9, v10, v11, v17); + goto LABEL_43; + } + v4 = 2; + v7 = 1; + v6 = 100; + } + CreateButtonInColumn(v7, v6); + goto LABEL_28; + } + CreateButtonInColumn(0, 0x12u); // 15 + CreateButtonInColumn(1, 0x34u); + CreateButtonInColumn(2, 0x35u); + v12 = 54; + } +LABEL_39: + CreateButtonInColumn(3, v12); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 4; + goto LABEL_42; + } + if ( a1 == 13 ) + { + CreateButtonInColumn(0, 0x12u); + v16 = 56; +LABEL_37: + CreateButtonInColumn(1, v16); + v17 = 2; + v11 = 0; + v10 = 1; + v9 = 2; + goto LABEL_42; + } + switch ( a1 ) + { + case 1: + case 2: + case 3: + case 4: + CreateButtonInColumn(0, 2u); + CreateButtonInColumn(1, 0x5Fu); + CreateButtonInColumn(2, 0x5Eu); + v12 = 96; + goto LABEL_39; + case 5: + CreateButtonInColumn(0, 0x12u); + v13 = 48; + goto LABEL_9; + case 6: + CreateButtonInColumn(0, 0x12u); + v13 = 49; + goto LABEL_9; + case 7: + CreateButtonInColumn(0, 0x12u); + v13 = 50; + goto LABEL_9; + case 8: + CreateButtonInColumn(0, 0x12u); + v13 = 51; +LABEL_9: + CreateButtonInColumn(1, v13); + v14 = 72; + goto LABEL_41; + case 9: + CreateButtonInColumn(0, 0x12u); + v15 = 52; + goto LABEL_13; + case 10: + CreateButtonInColumn(0, 0x12u); + v15 = 53; + goto LABEL_13; + case 11: + CreateButtonInColumn(0, 0x12u); + v15 = 54; +LABEL_13: + CreateButtonInColumn(1, v15); + v14 = 61; + goto LABEL_41; + case 12: + CreateButtonInColumn(0, 0x12u); + v16 = 55; + goto LABEL_37; + default: + break; + } +LABEL_43:*/ + dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; +} +// F8B1E0: using guessed type int dword_F8B1E0; + + +//----- (004B1784) -------------------------------------------------------- +bool __cdecl HouseUI_CheckIfPlayerCanInteract() +{ + Player *pPlayer; // ebx@1 + bool result; // eax@2 + int v3; // eax@3 + GUIWindow v4; // [sp+4h] [bp-54h]@3 + + pPlayer = pPlayers[uActiveCharacter]; + if ( pPlayer->CanAct() ) + { + pDialogueWindow->pNumPresenceButton = dword_F8B1E0; + result = 1; + } + else + { + pDialogueWindow->pNumPresenceButton = 0; + memcpy(&v4, pPrimaryWindow, sizeof(v4)); + v4.uFrameX = 483; + v4.uFrameWidth = 148; + v4.uFrameZ = 334; + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], pPlayer->pName, pGlobalTXT_LocalizationStrings[562]);// + // "%s is in no condition to %s" + // "do anything" + v3 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &v4, 0, 0); + v4.DrawTitleText(pFontArrus, 0, (212 - v3) / 2 + 101, ui_house_player_cant_interact_color, pTmpBuf.data(), 3u); + result = 0; + } + return result; +} + //----- (0044622E) -------------------------------------------------------- bool EnterHouse(enum HOUSE_ID uHouseID) { @@ -409,13 +887,13 @@ pAudioPlayer->StopChannels(-1, -1); uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID; - in_current_building_type = pAnimatedRooms[uCurrentHouse_Animation].uBuildingType; - if ( in_current_building_type == BildingType_Throne_Room && pParty->uFine ) // going 2 jail + in_current_building_type = (BuildingType)pAnimatedRooms[uCurrentHouse_Animation].uBuildingType; + if ( in_current_building_type == BuildingType_Throne_Room && pParty->uFine ) // going 2 jail { uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID; uHouseID = HOUSE_JAIL; pParty->uTimePlayed = pParty->uTimePlayed + 0x7620000; - in_current_building_type = pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE_EMERALD_ISLE].uAnimationID].uBuildingType; + in_current_building_type = (BuildingType)pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE_EMERALD_ISLE].uAnimationID].uBuildingType; ++pParty->uNumPrisonTerms; pParty->uFine = 0; for (uint i = 0; i < 4; ++i) @@ -555,11 +1033,8 @@ //----- (004B1E92) -------------------------------------------------------- void PlayHouseSound(unsigned int uHouseID, HouseSoundID sound) { - //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) ) - if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId ) - pAudioPlayer->PlaySound( - //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)), - (SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)), + if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId ) + pAudioPlayer->PlaySound((SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)), 806, 0, -1, 0, 0, 0, 0); } @@ -635,7 +1110,7 @@ //else if (dialog_menu_id == HOUSE_DIALOGUE_MAIN) { - if ( in_current_building_type == BildingType_Training ) + if ( in_current_building_type == BuildingType_Training ) { if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) { @@ -663,12 +1138,12 @@ v8 = window_SpeakInHouse; } //else - if ( in_current_building_type != BildingType_Training ) + if ( in_current_building_type != BuildingType_Training ) { v8 = window_SpeakInHouse; - if ((in_current_building_type == BildingType_Stables || in_current_building_type == BildingType_Boats) && + if ((in_current_building_type == BuildingType_Stables || in_current_building_type == BuildingType_Boats) && transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7] - || in_current_building_type != BildingType_Temple || uMessageParam != BildingType_MindGuild ) + || in_current_building_type != BuildingType_Temple || uMessageParam != BuildingType_MindGuild ) { //LABEL_9: pDialogueWindow->Release(); @@ -689,9 +1164,9 @@ } //LABEL_11: dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam; - if ( in_current_building_type < BildingType_19 ) + if ( in_current_building_type < BuildingType_19 ) { - v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE); + v9 = pIcons_LOD->LoadTexture(off_4F03B8[(int)in_current_building_type], TEXTURE_16BIT_PALETTE); //v3 = dword_F8B198; ShopTexture = &pIcons_LOD->pTextures[v9]; //LABEL_13: @@ -700,20 +1175,20 @@ } //NEW - switch(in_current_building_type) + switch (in_current_building_type) { - case BildingType_FireGuild: - case BildingType_AirGuild: - case BildingType_WaterGuild: - case BildingType_EarthGuild: - case BildingType_SpiritGuild: - case BildingType_MindGuild: - case BildingType_BodyGuild: - case BildingType_LightGuild: - case BildingType_DarkGuild: - case BildingType_14: - case BildingType_15: - case BildingType_16: + case BuildingType_FireGuild: + case BuildingType_AirGuild: + case BuildingType_WaterGuild: + case BuildingType_EarthGuild: + case BuildingType_SpiritGuild: + case BuildingType_MindGuild: + case BuildingType_BodyGuild: + case BuildingType_LightGuild: + case BuildingType_DarkGuild: + case BuildingType_14: + case BuildingType_15: + case BuildingType_16: { if ( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472] >= (signed __int64)pParty->uTimePlayed && *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468] >= (signed __int64)pParty->uTimePlayed ) @@ -746,7 +1221,7 @@ //return; break; } - case BildingType_TownHall: + case BuildingType_TownHall: { if ( uMessageParam == 99 ) { @@ -952,20 +1427,20 @@ } break; } - case BildingType_Bank: + case BuildingType_Bank: { if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) pKeyActionMap->EnterText(1, 10, v8); return; break; } - case BildingType_WeaponShop: - case BildingType_ArmorShop: - case BildingType_MagicShop: - case BildingType_AlchemistShop: - case BildingType_Tavern: - case BildingType_Temple: - case BildingType_Training: + case BuildingType_WeaponShop: + case BuildingType_ArmorShop: + case BuildingType_MagicShop: + case BuildingType_AlchemistShop: + case BuildingType_Tavern: + case BuildingType_Temple: + case BuildingType_Training: { break; } @@ -977,25 +1452,25 @@ } /* - if ( in_current_building_type > BildingType_Tavern ) + if ( in_current_building_type > BuildingType_Tavern ) { - if ( in_current_building_type == BildingType_Bank ) + if ( in_current_building_type == BuildingType_Bank ) { if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) pKeyActionMap->EnterText(1, 10, v8); return; } - if ( in_current_building_type != BildingType_Temple && in_current_building_type != BildingType_Training ) + if ( in_current_building_type != BuildingType_Temple && in_current_building_type != BuildingType_Training ) return; } //else - if ( in_current_building_type < BildingType_Tavern ) + if ( in_current_building_type < BuildingType_Tavern ) { if (in_current_building_type <= 0) return; - if ( in_current_building_type > BildingType_AlchemistShop ) + if ( in_current_building_type > BuildingType_AlchemistShop ) { - if ( in_current_building_type <= BildingType_16 ) + if ( in_current_building_type <= BuildingType_16 ) { if ( (signed __int64)__PAIR__( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472], @@ -1030,9 +1505,9 @@ } return; } - if ( in_current_building_type != BildingType_TownHall ) + if ( in_current_building_type != BuildingType_TownHall ) return; - if ( in_current_building_type == BildingType_TownHall ) + if ( in_current_building_type == BuildingType_TownHall ) { if ( uMessageParam == 99 ) { @@ -1255,7 +1730,7 @@ { pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3A72(in_current_building_type); + InitializaDialogueOptions_Tavern(in_current_building_type); break; } case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES: @@ -1299,7 +1774,7 @@ } } } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v48 = 0; if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) @@ -1327,7 +1802,7 @@ } } } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v53 = 0; if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) @@ -1356,7 +1831,7 @@ { pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3AD4(in_current_building_type); + InitializaDialogueOptions_Shops(in_current_building_type); break; } default: @@ -1379,7 +1854,7 @@ if ( pParty->uNumGold < v37 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); - if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern ) + if ( in_current_building_type == BuildingType_Training || in_current_building_type == BuildingType_Tavern ) v39 = 4; else v39 = 2; @@ -1442,7 +1917,7 @@ if ( pParty->uNumGold < v37 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); - if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern ) + if ( in_current_building_type == BuildingType_Training || in_current_building_type == BuildingType_Tavern ) v39 = 4; else v39 = 2; @@ -1464,7 +1939,7 @@ { pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3AD4(in_current_building_type); + InitializaDialogueOptions_Shops(in_current_building_type); } } } @@ -1514,7 +1989,7 @@ //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v47 = v8->ptr_1C; v48 = 0; @@ -1559,7 +2034,7 @@ //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); } - if ( in_current_building_type == BildingType_WeaponShop ) + if ( in_current_building_type == BuildingType_WeaponShop ) { v52 = v8->ptr_1C; v53 = 0; @@ -1668,10 +2143,10 @@ auto color_selected = TargetColor(255, 255, 155); v3 = 52 * (unsigned int)v0->ptr_1C; //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50); - //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BildingType_Stables) - 1) & 0xFFFFFFE7) + 50); + //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BuildingType_Stables) - 1) & 0xFFFFFFE7) + 50); //v4 = (signed __int64)((double)(signed int)v59 * p2DEvents_minus1__20[v3 / 4]); - v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BildingType_Stables ? 25 : 50; + v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BuildingType_Stables ? 25 : 50; v4 *= p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier; s1 = v4 * (100 - v1->GetMerchant()) / 100; @@ -1679,7 +2154,7 @@ s1 = v4 / 3; if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN) { - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v16 = pDialogueWindow; v58 = 255; @@ -2363,7 +2838,7 @@ { case HOUSE_DIALOGUE_MAIN: { - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; sprintf(pTopic1, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 2 ? pColorYellow : pColorWhite); @@ -2436,7 +2911,7 @@ pNumActiveItem++; if ( pNumActiveItem >= pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ) { - sprintfex(pTmpBuf.data(), "%s%s%s%s", &pTopic1, &pTopic2, &pTopic3, &pTopic4); + sprintfex(pTmpBuf.data(), "%s%s%s%s", pTopic1, pTopic2, pTopic3, pTopic4); dialog_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf.data(), 3); } } @@ -2506,7 +2981,7 @@ PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); dialog_menu_id = HOUSE_DIALOGUE_NULL; sub_4BD8B5(); - sub_4B1D27(); + GetHouseGoodbyeSpeech(); pVideoPlayer->Unload(); window_SpeakInHouse->Release(); window_SpeakInHouse = 0; @@ -2526,7 +3001,7 @@ case HOUSE_DIALOGUE_LEARN_SKILLS: { - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; v0 = 0; v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); @@ -2627,7 +3102,7 @@ case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN: { - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v48 = 2; pShopOptions[0] = pGlobalTXT_LocalizationStrings[620]; @@ -2764,7 +3239,7 @@ { if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) { - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v4 = pDialogueWindow; v61 = pDialogueWindow; @@ -3171,7 +3646,7 @@ //i = v11; } - if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + if (HouseUI_CheckIfPlayerCanInteract()) { if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN ) { @@ -3179,7 +3654,7 @@ { if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) { - if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + if (HouseUI_CheckIfPlayerCanInteract()) { //i = 0; int _v0 = 0; @@ -3268,7 +3743,7 @@ } return; } - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) { //v31 = pNPCTopics[122].pText; //v32 = color2; @@ -3361,7 +3836,7 @@ goto LABEL_55; } - if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + if (HouseUI_CheckIfPlayerCanInteract()) { v43 = pDialogueWindow; v72 = 0; @@ -3493,7 +3968,7 @@ } if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN) { - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v5 = 0; @@ -3552,7 +4027,7 @@ return ; } - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; v8 = pDialogueWindow; v33 = 0; @@ -3960,6 +4435,7 @@ a1.DrawText(v47, 13, 354 - v48, 0, v49, 0, 0, 0); } } + //----- (004B4F4F) -------------------------------------------------------- void JailDialog() {
--- a/UI/UIHouses.h Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UIHouses.h Tue Aug 06 00:56:33 2013 +0400 @@ -1,4 +1,5 @@ #pragma once +#include "..\Events2D.h" enum HOUSE_DIALOGUE_MENU: __int32 { @@ -116,6 +117,7 @@ HouseSound_Goodbye = 4 // farewells when bought something }; +bool HouseUI_CheckIfPlayerCanInteract(); void TrainingDialog(); void JailDialog(); void MagicShopDialog(); @@ -132,7 +134,12 @@ void __cdecl AlchemistDialog(); void __cdecl ArmorShopDialog(); + +void InitializaDialogueOptions_Tavern(BuildingType type); // idb +void InitializaDialogueOptions_Shops(BuildingType type); +void InitializaDialogueOptions(BuildingType type); + extern int uHouse_ExitPic; // weak extern int dword_591080; // weak -extern int in_current_building_type; // 00F8B198 +extern BuildingType in_current_building_type; // 00F8B198 extern HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C \ No newline at end of file
--- a/UI/UIMainMenu.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UIMainMenu.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -352,7 +352,7 @@ pAllocator->FreeChunk(pFontQuick); pAllocator->FreeChunk(pFontCChar); pWindow_MainMenu->Release(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); pTexture.Release(); pTexture2.Release(); return MENU_MAIN; // return MENU_Main
--- a/UI/UIPartyCreation.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UIPartyCreation.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -741,7 +741,7 @@ } pTexture_PCX.Release(); pGUIWindow_CurrentMenu->Release(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); int v1 = 0; memset(v20, 0, 32);
--- a/UI/UIPopup.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UIPopup.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -29,6 +29,38 @@ static char static_sub_417BB5_out_string[1200]; // static to a file, not sub actually + +//----- (004179BC) -------------------------------------------------------- +void CharacterUI_DrawTooltip(const char *a1, const char *a2) +{ + //const char *v2; // ebx@1 + //const char *v3; // edi@1 + //unsigned int v4; // eax@1 + GUIWindow Dst; // [sp+Ch] [bp-5Ch]@1 + POINT v6; // [sp+60h] [bp-8h]@1 + + //v2 = a2; + //v3 = a1; + memset(&Dst, 0, 0x54u); + Dst.uFrameWidth = 384; + Dst.uFrameHeight = 256; + Dst.uFrameX = 128; + Dst.uFrameY = pMouse->GetCursorPos(&v6)->y + 30; + Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(a2, &Dst, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24; + Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; + Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1; + Dst.DrawMessageBox(0); + Dst.uFrameX += 12; + Dst.uFrameWidth -= 24; + Dst.uFrameY += 12; + Dst.uFrameHeight -= 12; + Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; + Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1; + sprintf(pTmpBuf.data(), "\f%05d%s\f00000\n", ui_character_tooltip_header_default_color, a1); + Dst.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3u); + Dst.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, a2, 0, 0, 0); +} + //----- (004151D9) -------------------------------------------------------- void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight) { @@ -1550,7 +1582,7 @@ && (signed int)v1 <= (signed int)i->uW ) { v3 = CharacterUI_GetSkillDescText(uActiveCharacter - 1, (PLAYER_SKILL_TYPE)i->msg_param); - sub_4179BC_draw_tooltip(pSkillNames[i->msg_param], v3); + CharacterUI_DrawTooltip(pSkillNames[i->msg_param], v3); v1 = pY; v0 = pX; } @@ -1558,16 +1590,14 @@ } else { - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[207], pSkillPointsAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[207], pSkillPointsAttributeDescription); } } //----- (00418083) -------------------------------------------------------- void __cdecl CharacterUI_StatsTab_ShowHint() - { - LONG _x; // esi@1 - LONG _y; // eax@1 +{ int pStringNum; // edi@1 signed int pTextColor; // eax@15 char *pHourWord; // ecx@17 @@ -1578,16 +1608,16 @@ int pHour; // [sp+14h] [bp-1Ch]@15 unsigned int pDay; // [sp+24h] [bp-Ch]@15 - _x = pMouse->GetCursorPos(&a2)->x; - _y = pMouse->GetCursorPos(&a2)->y; - for ( pStringNum = 0; pStringNum < (signed int)&off_4E2A12; ++pStringNum ) + pMouse->GetCursorPos(&a2); + for ( pStringNum = 0; pStringNum < stat_string_coord.size(); ++pStringNum ) { - if ( _x >= stat_string_coord[pStringNum].x && _x <= stat_string_coord[pStringNum].x + stat_string_coord[pStringNum].width ) + if (a2.x >= stat_string_coord[pStringNum].x && a2.x <= stat_string_coord[pStringNum].x + stat_string_coord[pStringNum].width ) { - if ( _y >= stat_string_coord[pStringNum].y && _y <= stat_string_coord[pStringNum].y + stat_string_coord[pStringNum].height ) + if (a2.y >= stat_string_coord[pStringNum].y && a2.y <= stat_string_coord[pStringNum].y + stat_string_coord[pStringNum].height ) break; } } + switch ( pStringNum ) { case 0:// Attributes @@ -1598,19 +1628,19 @@ case 5: case 6: if ( aAttributeNames[pStringNum] && pAttributeDescriptions[pStringNum] ) - sub_4179BC_draw_tooltip(aAttributeNames[pStringNum], pAttributeDescriptions[pStringNum]); + CharacterUI_DrawTooltip(aAttributeNames[pStringNum], pAttributeDescriptions[pStringNum]); break; case 7:// Health Points if ( pGlobalTXT_LocalizationStrings[108] && pHealthPointsAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[108], pHealthPointsAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[108], pHealthPointsAttributeDescription); break; case 8:// Spell Points if ( pGlobalTXT_LocalizationStrings[212] && pSpellPointsAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[212], pSpellPointsAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[212], pSpellPointsAttributeDescription); break; case 9:// Armor Class if ( pGlobalTXT_LocalizationStrings[12] && pArmourClassAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[12], pArmourClassAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[12], pArmourClassAttributeDescription); break; case 10:// Player Condition strcpy(pTmpBuf2.data(), pPlayerConditionAttributeDescription); @@ -1639,19 +1669,19 @@ } } if ( pGlobalTXT_LocalizationStrings[47] && pTmpBuf2.data() ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[47], pTmpBuf2.data()); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[47], pTmpBuf2.data()); break; case 11:// Fast Spell if ( pGlobalTXT_LocalizationStrings[172] && pFastSpellAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[172], pFastSpellAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[172], pFastSpellAttributeDescription); break; case 12:// Player Age if ( pGlobalTXT_LocalizationStrings[5] && pPlayerAgeAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[5], pPlayerAgeAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[5], pPlayerAgeAttributeDescription); break; case 13:// Player Level if ( pGlobalTXT_LocalizationStrings[131] && pPlayerLevelAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[131], pPlayerLevelAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[131], pPlayerLevelAttributeDescription); break; case 14://Experience v15 = pPlayers[uActiveCharacter]->uLevel; @@ -1672,60 +1702,61 @@ strcat(pTmpBuf.data(), pTmpBuf2.data()); sprintf(pTmpBuf2.data(), "%s\n \n%s", pPlayerExperienceAttributeDescription, pTmpBuf.data()); if ( pGlobalTXT_LocalizationStrings[83] && pTmpBuf2.data() ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[83], pTmpBuf2.data()); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[83], pTmpBuf2.data()); break; case 15:// Attack Bonus if ( pGlobalTXT_LocalizationStrings[587] && pAttackBonusAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[587], pAttackBonusAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[587], pAttackBonusAttributeDescription); break; case 16:// Attack Damage if ( pGlobalTXT_LocalizationStrings[588] && pAttackDamageAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[588], pAttackDamageAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[588], pAttackDamageAttributeDescription); break; case 17:// Missle Bonus if ( pGlobalTXT_LocalizationStrings[589] && pMissleBonusAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[589], pMissleBonusAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[589], pMissleBonusAttributeDescription); break; case 18:// Missle Damage if ( pGlobalTXT_LocalizationStrings[590] && pMissleDamageAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[590], pMissleDamageAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[590], pMissleDamageAttributeDescription); break; case 19:// Fire Resistance if ( pGlobalTXT_LocalizationStrings[87] && pFireResistanceAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[87], pFireResistanceAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[87], pFireResistanceAttributeDescription); break; case 20:// Air Resistance if ( pGlobalTXT_LocalizationStrings[6] && pAirResistanceAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[6], pAirResistanceAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[6], pAirResistanceAttributeDescription); break; case 21:// Water Resistance if ( pGlobalTXT_LocalizationStrings[240] && pWaterResistanceAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[240], pWaterResistanceAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[240], pWaterResistanceAttributeDescription); break; case 22:// Earth Resistance if ( pGlobalTXT_LocalizationStrings[70] && pEarthResistanceAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[70], pEarthResistanceAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[70], pEarthResistanceAttributeDescription); break; case 23:// Mind Resistance if ( pGlobalTXT_LocalizationStrings[142] && pMindResistanceAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[142], pMindResistanceAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[142], pMindResistanceAttributeDescription); break; case 24:// Body Resistance if ( pGlobalTXT_LocalizationStrings[29] && pBodyResistanceAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[29], pBodyResistanceAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[29], pBodyResistanceAttributeDescription); break; case 25: // Skill Points if ( pGlobalTXT_LocalizationStrings[207] && pSkillPointsAttributeDescription ) - sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[207], pSkillPointsAttributeDescription); + CharacterUI_DrawTooltip(pGlobalTXT_LocalizationStrings[207], pSkillPointsAttributeDescription); break; - case 26: - __debugbreak(); - //_y = (Player *)(4 * pPlayers[uActiveCharacter]->classType); - //v24 = *(char **)((char *)_y->pConditions + (int)pClassNames); - //v7 = *(char **)((char *)_y->pConditions + (int)pClassDescriptions); - //if ( v24 && v7 ) - //sub_4179BC_draw_tooltip(v24, v7); - break; + case 26: // Class description + { + auto v24 = pClassNames[pPlayers[uActiveCharacter]->classType]; + auto v7 = pClassDescriptions[pPlayers[uActiveCharacter]->classType]; + if (v7 && v24) + CharacterUI_DrawTooltip(v24, v7); + } + break; + default: break; }
--- a/UI/UIRest.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UIRest.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -35,7 +35,7 @@ pEventTimer->Pause(); if ( dword_506F14 != 2 ) GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0); - _506F18_num_hours_to_sleep = 0; + _506F18_num_minutes_to_sleep = 0; dword_506F14 = 0; uRestUI_FoodRequiredToRest = 2; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
--- a/UI/UIShops.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UIShops.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -127,7 +127,7 @@ { case HOUSE_DIALOGUE_MAIN: { - pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); + pNumActiveItem = HouseUI_CheckIfPlayerCanInteract(); if ( pNumActiveItem ) { pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; @@ -191,7 +191,7 @@ v109 = v48; } while ( (signed int)v48 < 6 ); - pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); + pNumActiveItem = HouseUI_CheckIfPlayerCanInteract(); if ( pNumActiveItem ) { v55 = 0; @@ -233,14 +233,14 @@ pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60]; if ( !v56 || !Str ) { - v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); - v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2); + v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { - v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v7 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } @@ -260,15 +260,15 @@ draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0); - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; if((v11 = pMouse->GetCursorPos(&v96)->x - 14, v106.x = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v88)->y - 17) >> 5), pMouse->GetCursorPos(&v94)->x <= 13) || pMouse->GetCursorPos(&v90)->x >= 462 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) ) return; - v79 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; - v13 = pPlayer->SelectPhrasesTransaction(v79, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3); - v7 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + v79 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; + v13 = pPlayer->SelectPhrasesTransaction(v79, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3); + v7 = BuildDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); break; @@ -279,23 +279,23 @@ draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; if((v2 = pMouse->GetCursorPos(&a2)->x - 14, v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5), pMouse->GetCursorPos(&v100)->x <= 13) || pMouse->GetCursorPos(&v92)->x >= 462 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) ) return; - v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; + v4 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; if (!v4->Identified()) { - v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4); - v7 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v10 = pPlayer->SelectPhrasesTransaction(v4, BuildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4); + v7 = BuildDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { - v7 = BuilDialogueString("%24", uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v7 = BuildDialogueString("%24", uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } @@ -307,16 +307,16 @@ draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0); - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + if ( !HouseUI_CheckIfPlayerCanInteract()) return; if( (v2 = pMouse->GetCursorPos(&a2)->x - 14, v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5), pMouse->GetCursorPos(&v100)->x <= 13) || pMouse->GetCursorPos(&v92)->x >= 462 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) || (!(pPlayer->pOwnItems[pNumActiveItem-1].uAttributes& 2)) ) return; - v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; - v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); - v7 = BuilDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + v4 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; + v10 = pPlayer->SelectPhrasesTransaction(v4, BuildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); + v7 = BuildDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0); pTextHeight = (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorWhite, v7, 3); return; @@ -382,7 +382,7 @@ pItemNum += 70; } while ( (signed int)v109 < 6 ); - pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); + pNumActiveItem = HouseUI_CheckIfPlayerCanInteract(); if ( pNumActiveItem ) { v55 = 0; @@ -424,14 +424,14 @@ pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724]; if ( !v56 || !Str ) { - v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); - v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BuildingType_WeaponShop, v61, 2); + v7 = BuildDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } else { - v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v7 = BuildDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); } @@ -448,7 +448,7 @@ case HOUSE_DIALOGUE_LEARN_SKILLS: { - if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + if (!HouseUI_CheckIfPlayerCanInteract()) return; v0 = 0; all_text_height = 0; @@ -566,7 +566,7 @@ int v29; // edx@26 signed int v31; // esi@31 unsigned int v32; // eax@33 - int v33; // eax@34 + //int v33; // eax@34 int v35; // eax@35 char *v36; // edx@36 signed int v38; // esi@42 @@ -615,7 +615,7 @@ __int32 v95; // ecx@120 void *v96; // ST14_4@122 unsigned __int8 v97; // bl@122 - ItemGen *v98; // ST10_4@122 + //ItemGen *v98; // ST10_4@122 int v99; // eax@122 char *v100; // eax@122 const char *v101; // ST18_4@122 @@ -668,6 +668,8 @@ short text_color; int pActiveButton; + //__debugbreak(); // uishops.cpp(952): warning C4700: uninitialized local variable 'v33' used + //__debugbreak(); // uishops.cpp(981): warning C4700: uninitialized local variable 'v98' used memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); dialog_window.uFrameX = 483; dialog_window.uFrameWidth = 148; @@ -678,7 +680,7 @@ { case HOUSE_DIALOGUE_MAIN: { - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; //"Buy Standard" pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; //"Buy Special" @@ -737,7 +739,7 @@ } v153 += 105; } - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; pItemCount = 0; for ( int i = 0; i < 8; ++i ) @@ -759,10 +761,10 @@ pItemCount = v74 - 1; selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74-1]; if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0) - v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; + v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; else v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" - v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v36 = BuildDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -803,7 +805,7 @@ ++v61; } while ( v61 < 8 ); - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; v68 = 0; pItemCount = 0; @@ -831,10 +833,10 @@ else selected_item = &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v74 - 1]; if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 ) - v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; + v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; else v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" - v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v36 = BuildDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -886,16 +888,16 @@ draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);//"Select the Item to Sell" - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + if ( !HouseUI_CheckIfPlayerCanInteract()) return; if((v9 = pMouse->GetCursorPos(&v139)->x - 14, pItemCount = (v9 >> 5) + 14 * ((pMouse->GetCursorPos(&v133)->y - 17) >> 5), pMouse->GetCursorPos(&v137)->x <= 13) || pMouse->GetCursorPos(&v129)->x >= 462 || (v10 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v10) ) return; - v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v10 - 1]; - v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3); - v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3)]; - v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0); + v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v10 - 1]; + v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 3); + v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BuildingType_ArmorShop, window_SpeakInHouse->par1C, 3)]; + v36 = BuildDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -906,7 +908,7 @@ draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); //"Select the Item to Identify" - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v1 = pMouse->GetCursorPos(&a2)->x - 14; pItemCount = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v128)->y - 17) >> 5); @@ -917,15 +919,15 @@ v2 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount); if ( v2 ) { - v3 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v2-1]; + v3 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v2-1]; if (v3->Identified()) v5 = "%24"; else { - v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v3, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 4); + v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v3, BuildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 4); v5 = (char *)pMerchantsIdentifyPhrases[v8]; } - v6 = BuilDialogueString(v5, uActiveCharacter - 1, v3, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v6 = BuildDialogueString(v5, uActiveCharacter - 1, v3, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v115 = (174 - pFontArrus->CalcTextHeight(v6, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v6, 3); return; @@ -940,7 +942,7 @@ draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0); - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + if ( !HouseUI_CheckIfPlayerCanInteract()) return; if( (v31 = pMouse->GetCursorPos(&v135)->x - 14, pItemCount = (v31 >> 5) + 14 * ((pMouse->GetCursorPos(&v142)->y - 17) >> 5), @@ -949,10 +951,11 @@ || (v32 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v32) || (!(pPlayers[uActiveCharacter]->pOwnItems[v32-1].uAttributes& 2)) ) return; - v116 = &pPlayers[uActiveCharacter]->pInventoryItems[v33 - 1]; - v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItems[v32 - 1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 5); + //__debugbreak(); // warning C4700: uninitialized local variable 'v33' used + v116 = &pPlayers[uActiveCharacter]->pInventoryItemList[v32 - 1]; + v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[v32 - 1], BuildingType_ArmorShop, window_SpeakInHouse->par1C, 5); v15 = (char *)pMerchantsRepairPhrases[v35]; - v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + v36 = BuildDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); return; @@ -962,7 +965,7 @@ { pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0); //"Select the Item to Buy" - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; pItemCount = 0; for( int i = 0; i < 6 ; ++i ) @@ -977,8 +980,9 @@ { --pItemCount; v97 = uActiveCharacter - 1; - v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 2); - v100 = BuilDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, v98, (char *)window_SpeakInHouse->par1C, 2, 0); + //__debugbreak(); // warning C4700: uninitialized local variable 'v98' used + v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BuildingType_ArmorShop, window_SpeakInHouse->par1C, 2); + v100 = BuildDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], (char *)window_SpeakInHouse->par1C, 2, 0); v103 = pFontArrus->CalcTextHeight(v100, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v103) / 2 + 138, pWhiteColor, v100, 3); } @@ -1020,7 +1024,7 @@ break; case HOUSE_DIALOGUE_LEARN_SKILLS: { - if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if (!HouseUI_CheckIfPlayerCanInteract() ) return; v152 = 0; v38 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); @@ -1219,7 +1223,7 @@ { case HOUSE_DIALOGUE_MAIN: { - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; @@ -1318,7 +1322,7 @@ ++v114; } while ( v114 < 6 ); - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v62 = 0; v109 = 0; @@ -1360,14 +1364,14 @@ v70 = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; if ( !v63 || !Str ) { - v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2); + v71 = pPlayer->SelectPhrasesTransaction(v70, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2); v38 = (char *)pMerchantsBuyPhrases[v71]; } else { v38 = pGlobalTXT_LocalizationStrings[181]; } - v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v21 = BuildDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return ; @@ -1380,15 +1384,15 @@ draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0); - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; if ((v43 = pMouse->GetCursorPos(&v99)->x - 14, v109 = (v43 >> 5) + 14 * ((pMouse->GetCursorPos(&v95)->y - 17) >> 5), pMouse->GetCursorPos(&v102)->x <= 13) || pMouse->GetCursorPos(&v100)->x >= 462 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) ) return; - v87 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; - v45 = pPlayer->SelectPhrasesTransaction(v87, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3); - v21 = BuilDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + v87 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; + v45 = pPlayer->SelectPhrasesTransaction(v87, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3); + v21 = BuildDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v21, 3); return; @@ -1398,23 +1402,23 @@ draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) return; if ((v36 = pMouse->GetCursorPos(&a2)->x - 14, v109 = (v36 >> 5) + 14 * ((pMouse->GetCursorPos(&v94)->y - 17) >> 5), pMouse->GetCursorPos(&v101)->x <= 13) || pMouse->GetCursorPos(&v97)->x >= 462 || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) ) return; - v37 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; + v37 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; if (!v37->Identified()) { - v42 = pPlayer->SelectPhrasesTransaction(v37, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4); + v42 = pPlayer->SelectPhrasesTransaction(v37, BuildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4); v38 = (char *)pMerchantsIdentifyPhrases[v42]; } else { v38 = "%24"; } - v21 = BuilDialogueString(v38, uActiveCharacter - 1, v37, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v21 = BuildDialogueString(v38, uActiveCharacter - 1, v37, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return; @@ -1520,7 +1524,7 @@ ++v114; } while ( v114 < 6 ); - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v62 = 0; v109 = 0; @@ -1563,14 +1567,14 @@ v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; if ( !v63 || !Str ) { - v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, v68, 2); + v71 = pPlayer->SelectPhrasesTransaction(v70, BuildingType_AlchemistShop, v68, 2); v38 = (char *)pMerchantsBuyPhrases[v71]; } else { v38 = pGlobalTXT_LocalizationStrings[181]; } - v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v21 = BuildDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); return; @@ -1580,7 +1584,7 @@ } case HOUSE_DIALOGUE_LEARN_SKILLS: { - if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + if (!HouseUI_CheckIfPlayerCanInteract()) return; all_text_height = 0; v5 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); @@ -1790,7 +1794,7 @@ pYellowColor = TargetColor(225, 205, 35); if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN) { - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; //"Buy Standard" pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; //"Buy Special" @@ -1888,7 +1892,7 @@ ++v122; } while ( v122 < 6 ); - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v66 = 0; v117 = 0; @@ -1943,10 +1947,10 @@ v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" else { - v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); + v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); v10 = (char *)pMerchantsBuyPhrases[v75]; } - v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v30 = BuildDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; @@ -2019,7 +2023,7 @@ ++v122; } while ( v122 < 6 ); - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v66 = 0; v117 = 0; @@ -2074,10 +2078,10 @@ v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" else { - v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); + v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); v10 = (char *)pMerchantsBuyPhrases[v75]; } - v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v30 = BuildDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; @@ -2129,7 +2133,7 @@ draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);// "Select the Item to Sell" - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() + if ( !HouseUI_CheckIfPlayerCanInteract() || (v11 = pMouse->GetCursorPos(&v107)->x - 14, v117 = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v99)->y - 17) >> 5), result = (int)pMouse->GetCursorPos(&v105), @@ -2137,9 +2141,9 @@ || (result = (int)pMouse->GetCursorPos(&v101), *(int *)result >= 462) || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) ) return; - item = &pPlayers[uActiveCharacter]->pInventoryItems[result - 1]; - v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3); - v30 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + item = &pPlayers[uActiveCharacter]->pInventoryItemList[result - 1]; + v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3); + v30 = BuildDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; @@ -2149,7 +2153,7 @@ draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);// "Select the Item to Identify" - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v2 = pMouse->GetCursorPos(&a2)->x - 14; v117 = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v98)->y - 17) >> 5); @@ -2162,16 +2166,16 @@ result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117); if ( result ) { - item = &pPlayers[uActiveCharacter]->pInventoryItems[result-1]; + item = &pPlayers[uActiveCharacter]->pInventoryItemList[result-1]; if ( item->uAttributes & 1 ) { - v5 = BuilDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v5 = BuildDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v6 = (212 - pFontArrus->CalcTextHeight(v5, &dialog_window, 0, 0)) / 2 + 101; dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v5, 3); return; } - v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4); - v30 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v8], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4); + v30 = BuildDialogueString((char *)pMerchantsIdentifyPhrases[v8], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v30, 3); return; @@ -2186,7 +2190,7 @@ draw_leather(); CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);// "Select the Item to Repair" - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() + if ( !HouseUI_CheckIfPlayerCanInteract() || (pTextHeight = pMouse->GetCursorPos(&v110)->x - 14, v117 = (pTextHeight >> 5) + 14 * ((pMouse->GetCursorPos(&v108)->y - 17) >> 5), result = (int)pMouse->GetCursorPos(&v106), @@ -2196,16 +2200,16 @@ // || (result *= 9, !(pPlayers[uActiveCharacter]->field_1F5[4 * result + 15] & 2)) ) || (!(pPlayers[uActiveCharacter]->pOwnItems[result-1].uAttributes& 2)) ) return; - item = &pPlayers[uActiveCharacter]->pInventoryItems[result - 1]; - v29 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItems[result - 1], BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5); - v30 = BuilDialogueString((char *)pMerchantsRepairPhrases[v29], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + item = &pPlayers[uActiveCharacter]->pInventoryItemList[result - 1]; + v29 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[result - 1], BuildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5); + v30 = BuildDialogueString((char *)pMerchantsRepairPhrases[v29], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); return; } if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) { - if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( HouseUI_CheckIfPlayerCanInteract() ) { v3 = 0; all_text_height = 0; @@ -2318,7 +2322,7 @@ OnInventoryLeftClick(); return; } - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) { pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); return; @@ -2352,7 +2356,7 @@ if ( taken_item ) { bought_item->SetIdentified(); - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[taken_item - 1], bought_item, 0x24u); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[taken_item - 1], bought_item, 0x24u); dword_F8B1E4 = 1; Party::TakeGold(uPriceItemService); viewparams->bRedrawGameUI = 1; @@ -2372,7 +2376,7 @@ || pMouse->GetCursorPos(&cursor)->x >= 462 || (v15 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79), !v15) ) return; - if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItems[v15 - 1], (int)window_SpeakInHouse->ptr_1C) ) + if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItemList[v15 - 1], (int)window_SpeakInHouse->ptr_1C) ) { dword_F8B1E4 = 1; pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)window_SpeakInHouse->ptr_1C); @@ -2395,7 +2399,7 @@ if ( pItemID ) { uPriceItemService = pPlayers[uActiveCharacter]->GetPriceIdentification(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); - item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1]; if ( !(item->uAttributes & 1) ) { if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) @@ -2432,9 +2436,9 @@ pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); if ( pItemID ) { - item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + item = &pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1]; pPriceMultiplier = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; - auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[pItemID - 1]; uPriceItemService = pPlayers[uActiveCharacter]->GetPriceRepair(_v->GetValue(), pPriceMultiplier); if ( item->uAttributes & 2 ) { @@ -2510,14 +2514,14 @@ if ( v39 ) { bought_item->SetIdentified(); - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1], bought_item, sizeof(ItemGen)); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItemList[v39 - 1], bought_item, sizeof(ItemGen)); if ( pPlayers[uActiveCharacter]->CanSteal() ) { if ( GetAsyncKeyState(VK_CONTROL) ) { if ( uNumSeconds == 1 || uNumSeconds == 2 ) { - pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1].SetStolen(); + pPlayers[uActiveCharacter]->pInventoryItemList[v39 - 1].SetStolen(); sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6); viewparams->bRedrawGameUI = 1; bought_item->Reset(); @@ -2558,7 +2562,7 @@ if ( pParty->uNumGold < uPriceItemService ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" - if ( in_current_building_type == BildingType_Training ) + if ( in_current_building_type == BuildingType_Training ) v55 = 4; else v55 = 2; @@ -2600,7 +2604,7 @@ if ( in_current_building_type <= 0 ) return; - if ( in_current_building_type <= BildingType_AlchemistShop ) + if ( in_current_building_type <= BuildingType_AlchemistShop ) { if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) { @@ -2614,7 +2618,7 @@ || pMouse->GetCursorPos(&v12)->x >= 462 || (v9 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v5)) == 0 ) return; - GameUI_DrawItemInfo(&pPlayers[uActiveCharacter]->pInventoryItems[v9 - 1]); + GameUI_DrawItemInfo(&pPlayers[uActiveCharacter]->pInventoryItemList[v9 - 1]); return; } if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL ) @@ -2631,7 +2635,7 @@ GameUI_DrawItemInfo(v7); return; } - if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) + if ( in_current_building_type <= BuildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) { v1 = pMouse->GetCursorPos(&a2); v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y]; @@ -2642,65 +2646,52 @@ } } //----- (004B1D27) -------------------------------------------------------- -void __cdecl sub_4B1D27() +void __cdecl GetHouseGoodbyeSpeech() { - int v0; // edx@2 - unsigned int v1; // ecx@7 signed int v2; // edi@10 - int v3; // esi@10 - __int16 v4; // ax@15 signed int v5; // edi@20 - int v6; // esi@20 int v7[4]; // [sp+Ch] [bp-10h]@12 if ( in_current_building_type > 0 ) { - v0 = 3; - if ( in_current_building_type > BildingType_MagicShop ) + if ( in_current_building_type > BuildingType_MagicShop ) { - if ( in_current_building_type == BildingType_Bank ) + if ( in_current_building_type == BuildingType_Bank ) { if ( !dword_F8B1E4 ) return; } else { - if ( in_current_building_type != BildingType_Temple ) + if ( in_current_building_type != BuildingType_Temple ) return; } - v1 = (unsigned int)window_SpeakInHouse->ptr_1C; - PlayHouseSound(v1, (HouseSoundID)v0); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Greeting_2); return; } - v1 = (unsigned int)window_SpeakInHouse->ptr_1C; - if ( (signed __int64)pParty->field_3C._shop_ban_times[v1 ]<= (signed __int64)pParty->uTimePlayed ) + if ( (signed __int64)pParty->field_3C._shop_ban_times[(unsigned int)window_SpeakInHouse->ptr_1C]<= (signed __int64)pParty->uTimePlayed ) { - if ( pParty->uNumGold <= 0x2710 ) + if ( pParty->uNumGold <= 10000 ) { if ( !dword_F8B1E4 ) return; - v0 = 4; - PlayHouseSound(v1, (HouseSoundID)v0); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Goodbye); return; } - PlayHouseSound(v1, (HouseSoundID)(dword_F8B1E4 + 3)); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)(dword_F8B1E4 + 3)); if ( !dword_F8B1E4 && !qword_A750D8 ) { v5 = 0; - v6 = 1; - do + for ( uint i = 1; i <= 4; ++i ) { - if ( pPlayers[v6]->CanAct() ) - v7[v5++] = v6; - ++v6; + if ( pPlayers[i]->CanAct() ) + v7[v5++] = i; } - while ( v6 <= 4 ); if ( v5 ) { qword_A750D8 = 256i64; - word_A750E0 = 80; - v4 = LOWORD(v7[rand() % v5]); - word_A750E2 = v4; + PlayerSpeechID = SPEECH_80; + uSpeakingCharacter = v7[rand() % v5]; return; } } @@ -2710,20 +2701,16 @@ if ( !qword_A750D8 ) { v2 = 0; - v3 = 1; - do + for ( uint i = 1; i <= 4; ++i ) { - if ( pPlayers[v3]->CanAct() ) - v7[v2++] = v3; - ++v3; + if ( pPlayers[i]->CanAct() ) + v7[v2++] = i; } - while ( v3 <= 4 ); if ( v2 ) { qword_A750D8 = 256i64; - word_A750E0 = 80; - v4 = LOWORD(v7[rand() % v2]); - word_A750E2 = v4; + PlayerSpeechID = SPEECH_80; + uSpeakingCharacter = v7[rand() % v2]; return; } }
--- a/UI/UiGame.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/UI/UiGame.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -60,7 +60,7 @@ //v3 = player; if (auto slot = player->AddItem(-1, pParty->pPickedItem.uItemID)) { - memcpy(&player->pInventoryItems[slot-1], &pParty->pPickedItem, 0x24u); + memcpy(&player->pInventoryItemList[slot-1], &pParty->pPickedItem, 0x24u); viewparams->bRedrawGameUI = true; pMouse->RemoveHoldingItem(); return; @@ -287,7 +287,7 @@ a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u); a1.uFrameWidth -= 24; a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; - v14 = BuilDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); + v14 = BuildDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0); } } @@ -403,7 +403,7 @@ { NPCData *pNPC; // ebx@2 int pGreetType; // eax@2 - unsigned __int16 v2; // di@2 + //unsigned __int16 v2; // di@2 //unsigned int v3; // eax@2 char *v4; // esi@3 //int v5; // eax@11 @@ -423,7 +423,7 @@ //unsigned __int16 v30; // cx@83 int v31; // ecx@86 int v32; // ebx@93 - unsigned int v33; // eax@93 + //unsigned int v33; // eax@93 GUIWindow *v34; // ecx@93 int v35; // esi@93 int i; // eax@93 @@ -458,9 +458,9 @@ v51.uFrameWidth -= 10; v51.uFrameZ -= 10; //v54 = v1; - TargetColor(0xFFu, 0xFFu, 0xFFu); - TargetColor(0xE1u, 0xCDu, 0x23u); - v2 = TargetColor(0x15u, 0x99u, 0xE9u); + //TargetColor(0xFFu, 0xFFu, 0xFFu); + //TargetColor(0xE1u, 0xCDu, 0x23u); + //v2 = TargetColor(0x15u, 0x99u, 0xE9u); pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background); pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? &pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0)); pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0)); @@ -474,14 +474,14 @@ else strcpy(pTmpBuf.data(), pNPC->pName); - v51.DrawTitleText(pFontArrus, 483, 112, v2, pTmpBuf.data(), 3); + v51.DrawTitleText(pFontArrus, 483, 112, ui_game_dialogue_npc_name_color, pTmpBuf.data(), 3); pParty->GetPartyFame(); pInString = nullptr; switch (uDialogueType) { case DIALOGUE_13: - pInString = BuilDialogueString(pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); break; case DIALOGUE_PROFESSION_DETAILS: @@ -489,11 +489,11 @@ auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; if (dialogue_show_profession_details) - pInString = BuilDialogueString(prof->pBenefits, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pBenefits, uActiveCharacter - 1, 0, 0, 0, 0); else if (pNPC->Hired()) - pInString = BuilDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); else - pInString = BuilDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); } break; @@ -535,9 +535,9 @@ auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; if (pNPC->Hired()) - pInString = BuilDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); else - pInString = BuilDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + pInString = BuildDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); } break; } @@ -696,8 +696,6 @@ v32 = 0; - //pInString = (char *)TargetColor(0xFFu, 0xFFu, 0xFFu); - v33 = TargetColor(0xE1u, 0xCDu, 0x23u); v34 = pDialogueWindow; //v54 = v33; v35 = pDialogueWindow->pStartingPosActiveItem; @@ -739,9 +737,9 @@ v43->uHeight = v44; v42 = v45 + v44 - 1; v43->uW = v42; - v47 = v33; + v47 = ui_game_dialogue_option_highlight_color; if ( (unsigned __int16 *)pDialogueWindow->pCurrentPosActiveItem != v46 ) - v47 = TargetColor(0xFFu, 0xFFu, 0xFFu); + v47 = ui_game_dialogue_option_normal_color; v52.DrawTitleText(pFontArrus, 0, v45, v47, Str, 3u); v34 = pDialogueWindow; ++v55; @@ -998,21 +996,21 @@ strcat(pTmpBuf.data(), "\f00000\n"); v20 = UI_GetHealthManaStringColor(player->sHealth, player->GetMaxHealth()); - sprintf(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", - pGlobalTXT_LocalizationStrings[108], // "Hit Points" - v20, player->sHealth, player->GetMaxHealth()); + sprintfex(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", + pGlobalTXT_LocalizationStrings[108], // "Hit Points" + v20, player->sHealth, player->GetMaxHealth()); strcat(pTmpBuf.data(), pTmpBuf2.data()); v24 = UI_GetHealthManaStringColor(player->sMana, player->GetMaxMana()); - sprintf(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", - pGlobalTXT_LocalizationStrings[212], // "Spell Points" - v24, player->sMana, player->GetMaxMana()); + sprintfex(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", + pGlobalTXT_LocalizationStrings[212], // "Spell Points" + v24, player->sMana, player->GetMaxMana()); strcat(pTmpBuf.data(), pTmpBuf2.data()); v25 = player->GetMajorConditionIdx(); - sprintf(pTmpBuf2.data(), "%s: \f%05d%s\f00000\n", - pGlobalTXT_LocalizationStrings[47], // "Condition - GetConditionDrawColor(v25), aCharacterConditionNames[v25]); + sprintfex(pTmpBuf2.data(), "%s: \f%05d%s\f00000\n", + pGlobalTXT_LocalizationStrings[47], // "Condition + GetConditionDrawColor(v25), aCharacterConditionNames[v25]); strcat(pTmpBuf.data(), pTmpBuf2.data()); v28 = player->uQuickSpell; @@ -1042,7 +1040,7 @@ v39 = ""; if ( uFramesetIDa == 0 ) v39 = pGlobalTXT_LocalizationStrings[153]; // "None" - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[450], v39); // "Active Spells: %s" + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[450], v39); // "Active Spells: %s" window->DrawText(pFontArrus, 14, 114, 0, pTmpBuf.data(), 0, 0, 0); } @@ -1903,7 +1901,7 @@ { if ( pCurrentScreen == SCREEN_CHEST ) { - sub_42038D(); + ChestUI_WritePointedObjectStatusString(); //goto _return; if ( pMouse->uPointingObjectID == 0 ) { @@ -1969,7 +1967,7 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - pItemGen = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v14-1]; + pItemGen = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v14-1]; //goto LABEL_49; v17 = pItemGen->GetDisplayName(); GameUI_SetFooterString(v17); @@ -2194,23 +2192,23 @@ int v16; // eax@57 int v19; // eax@62 Texture *pPortrait; // [sp-4h] [bp-1Ch]@27 - unsigned int v22; // [sp+14h] [bp-4h]@1 + //unsigned int v22; // [sp+14h] [bp-4h]@1 - v22 = _this; + //v22 = _this; if ( qword_A750D8 ) { qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed; if ( qword_A750D8 <= 0 ) { - if ( pPlayers[word_A750E2]->CanAct() ) - pPlayers[word_A750E2]->PlaySound((PlayerSpeech)word_A750E0, 0); + if ( pPlayers[uSpeakingCharacter]->CanAct() ) + pPlayers[uSpeakingCharacter]->PlaySound(PlayerSpeechID, 0); qword_A750D8 = 0i64; } } for (uint i = 0; i < 4; ++i) { - Player* pPlayer = pParty->pPlayers + i; + Player* pPlayer = &pParty->pPlayers[i]; if (pPlayer->IsEradicated()) { @@ -2265,7 +2263,7 @@ pFrame = pPlayerFrameTable->GetFrameBy_y(&pPlayer->_expression21_frameset, &pPlayer->_expression21_animtime, pMiscTimer->uTimeElapsed); else pFrame = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed); - if (pPlayer->field_1AA2 != pFrame->uTextureID - 1 || v22 ) + if (pPlayer->field_1AA2 != pFrame->uTextureID - 1 || _this ) { pPlayer->field_1AA2 = pFrame->uTextureID - 1; pFace = (Texture *)pTextures_PlayerFaces[i][pPlayer->field_1AA2];//pFace = (Texture *)pTextures_PlayerFaces[i][pFrame->uTextureID];
--- a/VideoPlayer.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/VideoPlayer.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -305,15 +305,19 @@ if (!bNoVideo) { pRenderer->PresentBlackScreen(); - pGame->pCShow->PlayMovie(MOVIE_3DOLogo, 1); + PlayFullscreenMovie(MOVIE_3DOLogo, true); + //pGame->pCShow->PlayMovie(MOVIE_3DOLogo, 1); if ( !pVideoPlayer->bStopBeforeSchedule ) { - pGame->pCShow->PlayMovie(MOVIE_NWCLogo, 1); + PlayFullscreenMovie(MOVIE_NWCLogo, true); + //pGame->pCShow->PlayMovie(MOVIE_NWCLogo, 1); if ( !pVideoPlayer->bStopBeforeSchedule ) { - pGame->pCShow->PlayMovie(MOVIE_JVC, 1); + PlayFullscreenMovie(MOVIE_JVC, true); + //pGame->pCShow->PlayMovie(MOVIE_JVC, 1); if ( !pVideoPlayer->bStopBeforeSchedule ) - pGame->pCShow->PlayMovie(MOVIE_Intro, 1); + PlayFullscreenMovie(MOVIE_Intro, true); + //pGame->pCShow->PlayMovie(MOVIE_Intro, 1); } } } @@ -896,39 +900,27 @@ //----- (004BF1E6) -------------------------------------------------------- _SMACK *VideoPlayer::OpenSmack(const char *pFilename) { - VideoPlayer *pVideoPlayer; // esi@1 - signed int v3; // edi@1 - int v4; // ebx@2 - signed int v5; // edi@5 - //int v6; // ebx@6 - //HANDLE v8; // [sp-Ch] [bp-1Ch]@10 - //unsigned int v9; // [sp-8h] [bp-18h]@10 - //signed int v10; // [sp-4h] [bp-14h]@10 - - pVideoPlayer = this; - if ( (signed int)this->uNumMightVideoHeaders > 0 ) + if ( this->uNumMightVideoHeaders ) { - for ( v3 = 0; v3 < (signed int)pVideoPlayer->uNumMightVideoHeaders; ++v3) + for ( uint i = 0; i < (signed int)this->uNumMightVideoHeaders; ++i) { - v4 = _stricmp(pVideoPlayer->pMightVideoHeaders[v3].pVideoName, pFilename); - if ( !v4 ) - { - SetFilePointer(pVideoPlayer->hMightVid, pVideoPlayer->pMightVideoHeaders[v3].uFileOffset, 0, 0); - return SmackOpen(pVideoPlayer->hMightVid, 0x7140, -1);//problem training house video in WinXP - } + if ( !_stricmp(this->pMightVideoHeaders[i].pVideoName, pFilename) ) + { + SetFilePointer(this->hMightVid, this->pMightVideoHeaders[i].uFileOffset, 0, 0); + return SmackOpen(this->hMightVid, 0x7140, -1); + } } } - v5 = 0; - if ( (signed int)pVideoPlayer->uNumMagicVideoHeaders > 0 ) + if ( this->uNumMagicVideoHeaders ) { - while ( _stricmp(pVideoPlayer->pMagicVideoHeaders[v5].pVideoName, pFilename) ) + for ( uint i = 0; i < (signed int)this->uNumMagicVideoHeaders; ++i ) { - ++v5; - if ( v5 >= (signed int)pVideoPlayer->uNumMagicVideoHeaders ) - return 0; + if ( !_stricmp(this->pMagicVideoHeaders[i].pVideoName, pFilename) ) + { + SetFilePointer(this->hMagicVid, this->pMagicVideoHeaders[i].uFileOffset, 0, 0); + return SmackOpen(this->hMagicVid, 0x7140, -1); + } } - SetFilePointer(pVideoPlayer->hMagicVid, pVideoPlayer->pMagicVideoHeaders[v5].uFileOffset, 0, 0); - return SmackOpen(pVideoPlayer->hMagicVid, 0x7140, -1); } return 0; } @@ -936,67 +928,35 @@ //----- (004BF28F) -------------------------------------------------------- void VideoPlayer::OpenHouseMovie(const char *pMovieName, unsigned int a3_1) { - VideoPlayer *v3; // esi@1 - std::string *v4; // ecx@3 - _SMACK *v5; // eax@4 - _SMACK *v6; // eax@7 - int v7; // eax@7 - int v8; // ecx@7 - unsigned int v9; // ebx@8 - unsigned int v10; // eax@8 - signed __int64 v11; // qax@9 - char *v12; // [sp-20h] [bp-54h]@3 - int v13; // [sp-1Ch] [bp-50h]@3 - std::string v14; // [sp-18h] [bp-4Ch]@3 - const char *v15; // [sp-8h] [bp-3Ch]@3 - int v16; // [sp-4h] [bp-38h]@3 - char Str2[0x30]; // [sp+Ch] [bp-28h]@4 - std::string *v18; // [sp+3Ch] [bp+8h]@3 - std::string *v19; // [sp+3Ch] [bp+8h]@5 - unsigned __int16 *v20; // [sp+3Ch] [bp+8h]@8 - - v3 = this; if ( !this->field_54 ) { Prepare(); - v3->bLoopPlaying = a3_1; - if ( LOBYTE(v3->field_104) == 1 ) + this->bLoopPlaying = a3_1; + if ( LOBYTE(this->field_104) == 1 ) { - v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925"; - v12 = "Unsupported Bink playback!"; - MessageBoxA(nullptr, v12, v15, 0); + MessageBoxA(nullptr, "Unsupported Bink playback!", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:925", 0); return; } sprintfex(Str2, "%s.smk", pMovieName); - v5 = OpenSmack(Str2); - v3->pSmackerMovie = v5; - if ( !v5 ) + this->pSmackerMovie = OpenSmack(Str2); + if ( !this->pSmackerMovie ) { - v3->Unload(); + this->Unload(); sprintf(pTmpBuf.data(), "Can't load %s", &Str2); - v15 = "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937"; - MessageBoxA(nullptr, pTmpBuf.data(), v15, 0); + MessageBoxA(nullptr, pTmpBuf.data(), "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Video.cpp:937", 0); return; } - v16 = (int)pMovieName; - v3->uMovieFormat = 1; - strcpy(v3->pCurrentMovieName, (const char *)v16); - v6 = v3->pSmackerMovie; - v3->dword_0000A0 = 1; - v7 = SmackBufferOpen(v3->hWindow, 4, LOWORD(v6->Width), LOWORD(v6->Height), LOWORD(v6->Width), LOWORD(v6->Height)); - v3->pSmackerBuffer = (_SMACKBUF *)v7; - if ( v7 ) + this->uMovieFormat = 1; + strcpy(this->pCurrentMovieName, (const char *)pMovieName); + this->dword_0000A0 = 1; + this->pSmackerBuffer = (_SMACKBUF *)SmackBufferOpen(this->hWindow, 4, LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height), LOWORD(this->pSmackerMovie->Width), LOWORD(this->pSmackerMovie->Height)); + if ( this->pSmackerBuffer ) { pRenderer->BeginScene(); - v9 = pRenderer->uTargetSurfacePitch; - v20 = pRenderer->pTargetSurface; - v10 = SmackCheckSurfaceFromat(); - SmackToBuffer(v3->pSmackerMovie, 8, 8, 2 * v9, pRenderer->field_14, v20, v10); + SmackToBuffer(this->pSmackerMovie, 8, 8, 2 * pRenderer->uTargetSurfacePitch, pRenderer->field_14, pRenderer->pTargetSurface, SmackCheckSurfaceFromat()); pRenderer->EndScene(); } - v16 = 32767; - v11 = (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0); - SmackVolumePan(v3->pSmackerMovie, 1040384, v11, 32767); + SmackVolumePan(this->pSmackerMovie, 1040384, (signed __int64)(pSoundVolumeLevels[(char)uSoundVolumeMultiplier] * 32767.0), 32767); } } @@ -1009,62 +969,48 @@ //----- (004BF411) -------------------------------------------------------- void VideoPlayer::OpenGlobalMovie(const char *pFilename, unsigned int bLoop, int a4) { - VideoPlayer *pVideoPlayer; // esi@1 - _BINK *pVideoOpen; // eax@2 - _SMACK *v6; // eax@3 - _BINK *pBinkMovie; // eax@5 - _SMACK *v8; // eax@7 - char *v9; // eax@7 unsigned int v10; // eax@11 - _SMACKBLIT *v11; // eax@14 - const char *v12; // [sp-4h] [bp-38h]@8 char pVideoName[120]; // [sp+Ch] [bp-28h]@2 - pVideoPlayer = this; if ( !this->field_54 ) { Prepare(); - pVideoPlayer->bLoopPlaying = bLoop; + this->bLoopPlaying = bLoop; sprintf(pVideoName, "%s.bik", pFilename); - pVideoOpen = OpenBink(pVideoName); - pVideoPlayer->pBinkMovie = pVideoOpen; - if ( pVideoOpen ) + this->pBinkMovie = OpenBink(pVideoName); + if ( this->pBinkMovie ) { - pVideoPlayer->uMovieFormat = 2; - strcpy(pVideoPlayer->pCurrentMovieName, pFilename); - pBinkMovie = pVideoPlayer->pBinkMovie; - pVideoPlayer->dword_0000A0 = 1; + this->uMovieFormat = 2; + strcpy(this->pCurrentMovieName, pFilename); + pBinkMovie = this->pBinkMovie; + this->dword_0000A0 = 1; if ( pBinkMovie ) - pVideoPlayer->pBinkBuffer = CreateBinkBuffer(pVideoPlayer->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0); + this->pBinkBuffer = CreateBinkBuffer(this->hWindow, pBinkMovie->uWidth, pBinkMovie->uHeight, 0); } else { Unload(); sprintfex(pVideoName, "%s.smk", pFilename); - v6 = OpenSmack(pVideoName); - pVideoPlayer->pSmackerMovie = v6; - if ( !v6 ) + this->pSmackerMovie = OpenSmack(pVideoName); + if ( !this->pSmackerMovie ) { Unload(); sprintf(pVideoName, "Can't load file - anims\\%s.smk", pFilename); MessageBoxA(0, pVideoName, "Smacker Error", 0); return; } - pVideoPlayer->uMovieFormat = 1; - strcpy(pVideoPlayer->pCurrentMovieName, pFilename); - v8 = pVideoPlayer->pSmackerMovie; - pVideoPlayer->dword_0000A0 = 2; - v9 = (char *)malloc(v8->Width * v8->Height); - pVideoPlayer->pSomeSmackerBuffer = v9; - if ( !v9 ) + this->uMovieFormat = 1; + strcpy(this->pCurrentMovieName, pFilename); + this->dword_0000A0 = 2; + this->pSomeSmackerBuffer = (char *)malloc(this->pSmackerMovie->Width * this->pSmackerMovie->Height); + if ( !this->pSomeSmackerBuffer ) { Unload(); - v12 = "Can't allocate memory for buffer"; - sprintf(pVideoName, v12); - MessageBoxA(0, pVideoName, "Smacker Error", 0); + sprintf(pVideoName, "Can't allocate memory for buffer"); + MessageBoxA(0, pVideoName, "Smacker Error", 0); return; } - SmackToBuffer(pVideoPlayer->pSmackerMovie, 0, 0, pVideoPlayer->pSmackerMovie->Width, pVideoPlayer->pSmackerMovie->Height, v9, 0); + SmackToBuffer(this->pSmackerMovie, 0, 0, this->pSmackerMovie->Width, this->pSmackerMovie->Height, this->pSomeSmackerBuffer, 0); v10 = SmackCheckSurfaceFromat(); if ( a4 ) @@ -1077,13 +1023,11 @@ Log::Warning(L"Smacker seems to use lower resolution because it thinks CPU is slow"); } - v11 = SmackBlitOpen(v10); - pVideoPlayer->pSmackMovieBlit = v11; - if ( !v11 ) + this->pSmackMovieBlit = SmackBlitOpen(v10); + if ( !this->pSmackMovieBlit ) { Unload(); - v12 = "Failed to open Blit API"; - sprintf(pVideoName, v12); + sprintf(pVideoName, "Failed to open Blit API"); MessageBoxA(0, pVideoName, "Smacker Error", 0); return; } @@ -1095,22 +1039,15 @@ //----- (004BF5B2) -------------------------------------------------------- void VideoPlayer::_4BF5B2() { - VideoPlayer *v1; // esi@1 - unsigned int v2; // eax@1 - _BINK **v3; // edi@2 - - v1 = this; - v2 = this->uMovieFormat; - if ( v2 == 2 ) + if ( this->uMovieFormat == 2 ) { - v3 = &this->pBinkMovie; BinkGoto(pBinkMovie, 1, 0); BinkDoFrame(pBinkMovie); BinkNextFrame(pBinkMovie); } else { - if ( v2 != 1 ) + if ( this->uMovieFormat != 1 ) return; SmackGoto(pSmackerMovie, 1); if ( pVersion->pVersionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || pVersion->pVersionInfo.dwMajorVersion != 4 ) @@ -1120,7 +1057,7 @@ } } pMouse->_469E24(); - if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !v1->pSmackerMovie ) + if ( window_SpeakInHouse && window_SpeakInHouse->ptr_1C == (void *)165 && !this->pSmackerMovie ) { bGameoverLoop = 1; sub_4BD8B5(); @@ -1142,27 +1079,16 @@ //----- (004BF73A) -------------------------------------------------------- void VideoPlayer::SelectMovieType() { - VideoPlayer *v1; // esi@1 - int v2; // edi@1 - unsigned __int8 v3; // bl@1 - int v4; // edi@1 char Source[32]; // [sp+Ch] [bp-40h]@1 - v1 = this; - v2 = this->dword_0000A0; - v3 = LOBYTE(this->bLoopPlaying); strcpy(Source, this->pCurrentMovieName); Unload(); - v4 = v2 - 1; - if ( v4 ) - { - if ( v4 == 1 ) - OpenGlobalMovie(Source, v3, 1); - } + if ( this->dword_0000A0 == 1 ) + OpenHouseMovie(Source, LOBYTE(this->bLoopPlaying)); + else if ( this->dword_0000A0 == 2 ) + OpenGlobalMovie(Source, LOBYTE(this->bLoopPlaying), 1); else - { - OpenHouseMovie(Source, v3); - } + __debugbreak(); } //----- (004BF8F6) -------------------------------------------------------- @@ -1170,7 +1096,8 @@ { bStopBeforeSchedule = 0; pResetflag = 0; - pGame->pCShow->PlayMovie(MOVIE_Death, 1); + PlayFullscreenMovie(MOVIE_Death, true); + //pGame->pCShow->PlayMovie(MOVIE_Death, 1); } //----- (004BE6F5) --------------------------------------------------------
--- a/Vis.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/Vis.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -173,8 +173,8 @@ //while ( v8 ); } - if (min_x < pRenderer->pBillboardRenderListD3D[v13].pQuards[0].pos.x || pRenderer->pBillboardRenderListD3D[v13].pQuards[0].pos.y > min_y || - pRenderer->pBillboardRenderListD3D[v13].pQuards[3].pos.x < max_x || pRenderer->pBillboardRenderListD3D[v13].pQuards[1].pos.y < max_y) + if (min_x < pRenderer->pBillboardRenderListD3D[v13].pQuads[0].pos.x || pRenderer->pBillboardRenderListD3D[v13].pQuads[0].pos.y > min_y || + pRenderer->pBillboardRenderListD3D[v13].pQuads[3].pos.x < max_x || pRenderer->pBillboardRenderListD3D[v13].pQuads[1].pos.y < max_y) return false; return true; @@ -265,12 +265,12 @@ return false; //result = a1; - v5 = a1->pQuards[0].pos.x; - a1a = a1->pQuards[3].pos.x; - v6 = a1->pQuards[0].pos.y; - //result = (RenderBillboardD3D *)LODWORD(result->pQuards[1].pos.y); + v5 = a1->pQuads[0].pos.x; + a1a = a1->pQuads[3].pos.x; + v6 = a1->pQuads[0].pos.y; + //result = (RenderBillboardD3D *)LODWORD(result->pQuads[1].pos.y); v29 = v6; - v28 = a1->pQuards[1].pos.y; + v28 = a1->pQuads[1].pos.y; if ( v5 > a1a ) { v7 = v5; @@ -1548,7 +1548,7 @@ return false; - GetPolygonCenter(pRenderer->pBillboardRenderListD3D[v3].pQuards, 4, &test_x, &test_y); + GetPolygonCenter(pRenderer->pBillboardRenderListD3D[v3].pQuads, 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); @@ -1569,8 +1569,8 @@ for (v40 = 0; v40 < 4; ++v40) { - test_x=pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[v40].pos.x; - test_y= pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[v40].pos.y; + test_x=pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuads[v40].pos.x; + test_y= pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuads[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 && @@ -1595,11 +1595,11 @@ { if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) return false; - t1_x = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.x; - t2_x = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[3].pos.x; + t1_x = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuads[0].pos.x; + t2_x = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuads[3].pos.x; - t1_y = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[0].pos.y; - t2_y = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuards[1].pos.y; + t1_y = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuads[0].pos.y; + t2_y = pRenderer->pBillboardRenderListD3D[uD3DBillboardIdx].pQuads[1].pos.y; if ( t1_x > t2_x ) { swap_temp = t1_x;
--- a/_deleted.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/_deleted.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -1,5 +1,11027 @@ - /* + + +// 128 +#pragma pack(push, 1) +struct stru11 +{ + + stru11(); + + void CheckCPU(); + void RunCPUID(); + void RunCPUID_op1(); + void RunCPUID_op2(); + void RunCPUID_ext2_3_4(); + + int cpuid_00000000_eax_numops; + int cpuid_00000000_ebx_vendorstr1; + int cpuid_00000000_edx_vendorstr2; + int cpuid_00000000_ecx_vendorstr3; + char pCPUString[16]; + int cpuid_00000001_eax; + int cpuid_00000001_edx; + int cpuid_00000002_eax; + int cpuid_00000002_ebx; + int cpuid_00000002_ecx; + int cpuid_00000002_edx; + int field_38; + int field_3C; + int field_40[8]; + int cpuid_80000000_edx; + int cpuid_80000001_eax; + int cpuid_80000001_edx; + int cpuid_80000002_registers[4]; + int cpuid_80000003_registers[4]; + int cpuid_80000004_registers[4]; + int cpuid_80000005_ebx; + int cpuid_80000005_ecx; + int cpuid_80000005_edx; + int cpuid_80000006_ecx; + int field_AC; + int uProcessorManufacturer; + int cpuid_80000002_registers2[4]; + int cpuid_80000003_registers2[4]; + int cpuid_80000004_registers2[4]; + int field_E4; +}; +#pragma pack(pop) + + + +// 130 +#pragma pack(push, 1) +struct stru12_MemoryBlock +{ + stru12_MemoryBlock(int a2); + ~stru12_MemoryBlock(); + + + void *pAlignedBlock; + void *pBlockBase; +}; +#pragma pack(pop) + +// 129 +#pragma pack(push, 1) +struct stru12 +{ + stru12(stru11 *pStru11); + ~stru12(); + + void _4898E6(); + + void (__thiscall *vdestructor_ptr)(stru12 *); + int field_4[16]; + int field_44; + int field_48; + int field_4C; + int field_50; + int field_54; + int field_58; + stru12_MemoryBlock *pMemBlocks[12]; + int field_8C; +}; +#pragma pack(pop) + + + + +//----- (00438526) -------------------------------------------------------- +stru11::stru11() +{ + stru11 *v1; // esi@1 + signed int v2; // eax@1 + char *v3; // edx@1 + + v1 = this; + v2 = 0; + this->cpuid_00000000_eax_numops = 0; + this->cpuid_00000001_eax = 0; + this->cpuid_00000001_edx = 0; + this->field_38 = 0; + this->field_3C = 0; + this->cpuid_80000000_edx = 0; + this->cpuid_80000001_eax = 0; + this->cpuid_80000001_edx = 0; + this->cpuid_80000005_ebx = 0; + this->cpuid_80000005_ecx = 0; + this->cpuid_80000005_edx = 0; + this->cpuid_80000006_ecx = 0; + this->field_AC = 0; + this->uProcessorManufacturer = 0; + LOBYTE(this->cpuid_80000002_registers2[0]) = 0; + v3 = (char *)&this->cpuid_00000002_eax; + do + { + if ( v2 < 3 ) + *((int *)v3 - 9) = 0; + if ( v2 < 4 ) + *(int *)v3 = 0; + if ( v2 < 12 ) + *((int *)v3 + 17) = 0; + if ( v2 < 13 ) + this->pCPUString[v2] = 0; + if ( v2 < 30 ) + *((char *)this->field_40 + v2) = 0; + *((char *)&this->cpuid_80000002_registers2[0] + v2++ + 1) = 0; + v3 += 4; + } + while ( v2 < 48 ); + CheckCPU(); +} + +//----- (004385B5) -------------------------------------------------------- +void stru11::CheckCPU() +{ + int v5; // [sp-4h] [bp-10h]@0 + signed int v6; // [sp+4h] [bp-8h]@1 + signed int v7; // [sp+8h] [bp-4h]@1 + + _CF = 0; + _OF = 0; + _ZF = 1; + _SF = 0; + v7 = 0; + __asm { pushf } + v6 = 3; + if ( v5 != (v5 ^ 0x40000) ) + { + __asm { popf } + v6 = 4; + __asm { pushf } + if ( v5 != (v5 ^ 0x200000) ) + { + v7 = 1; + v6 = 0; + } + } + if ( v6 == 3 ) + { + this->field_AC = 1; + } + else + { + if ( v6 == 4 ) + { + this->field_AC = 2; + } + else + { + if ( v7 ) + { + this->field_AC = 2; + RunCPUID(); + } + else + { + this->field_AC = 0; + } + } + } +} + +//----- (00438659) -------------------------------------------------------- +void stru11::RunCPUID() +{ + stru11 *v6; // esi@1 + unsigned int uNumOps; // edi@1 + int uNumExtOps; // edi@16 + char pCyrixString[16]; // [sp+Ch] [bp-60h]@1 + char pCentaurString[16]; // [sp+1Ch] [bp-50h]@1 + char pAMDString[16]; // [sp+2Ch] [bp-40h]@1 + char pIntelString[16]; // [sp+3Ch] [bp-30h]@1 + char pCPUString[16]; // [sp+4Ch] [bp-20h]@1 + stru11 *thisa; // [sp+5Ch] [bp-10h]@1 + char *v35; // [sp+60h] [bp-Ch]@1 + int v36; // [sp+64h] [bp-8h]@1 + int v37; // [sp+68h] [bp-4h]@1 + + thisa = this; + *(int *)pIntelString = *(int *)"GenuineIntel"; + *(int *)&pIntelString[4] = *(int *)"ineIntel"; + *(int *)&pIntelString[8] = *(int *)"ntel"; + pIntelString[12] = aGenuineintel[12]; + *(int *)pAMDString = *(int *)"AuthenticAMD"; + *(int *)&pAMDString[4] = *(int *)"enticAMD"; + *(int *)&pAMDString[8] = *(int *)"cAMD"; + pAMDString[12] = aAuthenticamd[12]; + *(int *)pCyrixString = *(int *)"CyrixInstead"; + *(int *)&pCyrixString[4] = *(int *)"xInstead"; + *(int *)&pCyrixString[8] = *(int *)"tead"; + pCyrixString[12] = aCyrixinstead[12]; + *(int *)pCentaurString = *(int *)"CentaurHauls"; + *(int *)&pCentaurString[4] = *(int *)"aurHauls"; + *(int *)&pCentaurString[8] = *(int *)"auls"; + v37 = 0; + v36 = 0; + pCentaurString[12] = aCentaurhauls[12]; + v35 = pCPUString; + pCPUString[12] = 0; + _EAX = 0; + __asm { cpuid } + v37 = _EAX; + *(int *)pCPUString = _EBX; + *(int *)&pCPUString[4] = _EDX; + *(int *)&pCPUString[8] = _ECX; + v6 = thisa; + uNumOps = _EAX; + thisa->cpuid_00000000_ebx_vendorstr1 = _EBX; + v6->cpuid_00000000_edx_vendorstr2 = *(int *)&pCPUString[4]; + v6->cpuid_00000000_ecx_vendorstr3 = *(int *)&pCPUString[8]; + v6->cpuid_00000000_eax_numops = _EAX; + strcpy(v6->pCPUString, pCPUString); + if ( strcmp(pIntelString, pCPUString) ) + { + if ( strcmp(pAMDString, pCPUString) ) + { + if ( strcmp(pCyrixString, pCPUString) ) + { + if ( strcmp(pCentaurString, pCPUString) ) + v6->uProcessorManufacturer = 0; + else + v6->uProcessorManufacturer = 4; + } + else + { + v6->uProcessorManufacturer = 3; + } + } + else + { + v6->uProcessorManufacturer = 2; + } + } + else + { + v6->uProcessorManufacturer = 1; + } + if ( uNumOps >= 1 ) + RunCPUID_op1(); + if ( uNumOps >= 2 ) + RunCPUID_op2(); + _EAX = 0x80000000u; + __asm { cpuid } + if ( !(_EAX & 0x80000000) ) + _EAX = 0x80000000u; + v36 = _EAX; + v6->cpuid_80000000_edx = _EAX; + uNumExtOps = _EAX ^ 0x80000000; + if ( (_EAX ^ 0x80000000u) >= 1 ) + { + _EAX = 0x80000001u; + __asm { cpuid } + thisa = (stru11 *)_EAX; + v35 = (char *)_EDX; + v6->cpuid_80000001_eax = _EAX; + v6->cpuid_80000001_edx = (int)v35; + } + if ( (unsigned int)uNumExtOps >= 4 ) + RunCPUID_ext2_3_4(); + if ( (unsigned int)uNumExtOps >= 5 ) + { + _EAX = 0x80000005u; + __asm { cpuid } + thisa = (stru11 *)_EBX; + v35 = (char *)_ECX; + v36 = _EDX; + v6->cpuid_80000005_ebx = _EBX; + v6->cpuid_80000005_ecx = (int)v35; + v6->cpuid_80000005_edx = v36; + } + if ( (unsigned int)uNumExtOps >= 6 ) + { + _EAX = 0x80000006u; + __asm { cpuid } + v6->cpuid_80000006_ecx = _ECX; + } +} + +//----- (00438821) -------------------------------------------------------- +void stru11::RunCPUID_op1() +{ + stru11 *v1; // esi@1 + unsigned int v7; // ecx@1 + int v8; // eax@3 + int v9; // eax@10 + signed int v10; // eax@11 + int v11; // ecx@11 + int v12; // eax@15 + signed int v13; // eax@19 + int v14; // ecx@19 + signed int v15; // eax@25 + int v16; // ecx@25 + signed int v17; // eax@34 + int v18; // ecx@34 + + v1 = this; + _EAX = 1; + __asm { cpuid } + v7 = _EAX; + v1->cpuid_00000001_edx = _EDX; + v1->cpuid_00000001_eax = _EAX; + if ( (_EAX & 0x3000) == 8192 ) + { + LOBYTE(v1->cpuid_80000002_registers2[0]) = 1; + v7 = 0; + } + v8 = (v7 >> 8) & 0xF; + switch ( v8 ) + { + case 4: + v1->field_AC = 2; + break; + case 5: + v1->field_AC = 15; + break; + case 6: + v1->field_AC = 36; + break; + default: + v1->field_AC = 49; + break; + } + v9 = v1->uProcessorManufacturer; + if ( v9 == 1 ) + { + v10 = 0; + v11 = v7 & 0x3FF0; + while ( v11 != dword_4E4948[2 * v10] ) + { + ++v10; + if ( v10 >= 17 ) + return; + } + v12 = dword_4E494C[2 * v10]; + goto LABEL_39; + } + if ( v9 == 2 ) + { + if ( (v7 & 0xF00) == dword_4E49D0[0] ) + { + v12 = dword_4E49D4[0]; + } + else + { + v13 = 1; + v14 = v7 & 0x3FF0; + while ( v14 != dword_4E49D0[2 * v13] ) + { + ++v13; + if ( v13 >= 9 ) + return; + } + v12 = dword_4E49D4[2 * v13]; + } + goto LABEL_39; + } + if ( v9 != 3 ) + { + if ( v9 != 4 ) + return; + v17 = 0; + v18 = v7 & 0x3FF0; + while ( v18 != dword_4E4A40[2 * v17] ) + { + ++v17; + if ( v17 >= 2 ) + return; + } + v12 = dword_4E4A44[2 * v17]; + goto LABEL_39; + } + v15 = 1; + v16 = v7 & 0x3FF0; + while ( v16 != dword_4E4A18[2 * v15] ) + { + ++v15; + if ( v15 >= 5 ) + goto LABEL_30; + } + v1->field_AC = dword_4E4A1C[2 * v15]; +LABEL_30: + v12 = 24; + if ( v1->field_AC == 24 ) + { + if ( _EDX != 1 ) + v12 = (((_EDX != 261) - 1) & 0xA) + 15; +LABEL_39: + v1->field_AC = v12; + } +} + +//----- (00438992) -------------------------------------------------------- +void stru11::RunCPUID_op2() +{ + stru11 *v1; // edi@1 + int v7; // eax@1 + signed int v8; // ecx@2 + unsigned __int8 v9; // al@3 + signed int v10; // ecx@14 + unsigned __int8 v11; // al@15 + int v12; // [sp+Ch] [bp-14h]@1 + int v13; // [sp+10h] [bp-10h]@1 + int v14; // [sp+14h] [bp-Ch]@1 + int v15; // [sp+18h] [bp-8h]@1 + int *v16; // [sp+1Ch] [bp-4h]@1 + + v1 = this; + v16 = &v12; + _EAX = 2; + __asm { cpuid } + v12 = _EAX; + v13 = _EBX; + v14 = _ECX; + v15 = _EDX; + v1->cpuid_00000002_eax = _EAX; + v1->cpuid_00000002_ebx = v13; + v1->cpuid_00000002_ecx = v14; + v1->cpuid_00000002_edx = v15; + v7 = v1->field_AC; + if ( v7 == 40 ) + { + v8 = 0; + while ( 1 ) + { + v9 = *((char *)&v12 + v8); + if ( v9 == 64 ) + { + v1->field_AC = 43; + return; + } + if ( v9 >= 0x41u && v9 <= 0x43u ) + { + v1->field_AC = 41; + return; + } + if ( v9 >= 0x44u && v9 <= 0x45u ) + break; + ++v8; + if ( v8 >= 16 ) + return; + } + v1->field_AC = 42; + } + else + { + if ( v7 == 45 ) + { + v10 = 0; + while ( 1 ) + { + v11 = *((char *)&v12 + v10); + if ( v11 >= 0x40u && v11 <= 0x43u ) + { + v1->field_AC = 46; + return; + } + if ( v11 >= 0x44u && v11 <= 0x45u ) + break; + ++v10; + if ( v10 >= 16 ) + return; + } + v1->field_AC = 47; + } + } +} + +//----- (00438A67) -------------------------------------------------------- +void stru11::RunCPUID_ext2_3_4() +{ + stru11 *v1; // edi@1 + stru11 *v17; // eax@1 + int v18[3][4]; // [sp+Ch] [bp-38h]@1 + stru11 *v19; // [sp+3Ch] [bp-8h]@1 + + v1 = this; + v19 = this; + _EAX = 0x80000002u; + __asm { cpuid } + v18[0][0] = _EAX; + *(_QWORD *)&v18[0][1] = __PAIR__(_ECX, _EBX); + v18[0][3] = _EDX; + _EAX = 0x80000003u; + __asm { cpuid } + v18[1][0] = _EAX; + *(_QWORD *)&v18[1][1] = __PAIR__(_ECX, _EBX); + v18[1][3] = _EDX; + _EAX = 0x80000004u; + __asm { cpuid } + v18[2][0] = _EAX; + *(_QWORD *)&v18[2][1] = __PAIR__(_ECX, _EBX); + v18[2][3] = _EDX; + v17 = v19; + memcpy(v1->cpuid_80000002_registers, v18, 0x30u); + memcpy((char *)&v17->cpuid_80000002_registers2[0] + 1, v18, 0x30u); +} + + + +//----- (0048958E) -------------------------------------------------------- +stru12_MemoryBlock::stru12_MemoryBlock(int a2) +{ + stru12_MemoryBlock *v2; // esi@1 + void *v3; // eax@1 + void *v4; // ecx@1 + stru12_MemoryBlock *result; // eax@1 + + v2 = this; + v3 = operator new(8 * a2 + 16); + v2->pBlockBase = v3; + v4 = (char *)v3 + PID_TYPE(-(signed int)v3); + result = v2; + v2->pAlignedBlock = v4; +} + +//----- (004895B7) -------------------------------------------------------- +stru12::stru12(stru11 *pStru11) +{ + stru12 *v2; // esi@1 + + v2 = this; + this->field_44 = 0x41000000u; + this->field_4C = 0x46000000u; + //this->vdestructor_ptr = stru12::_4898E6; + this->field_48 = 0; + this->field_50 = 0; + this->field_54 = 0x33D6BF95u; + this->field_58 = 0; + + for (int i = 0; i < 12; ++i) + v2->pMemBlocks[i] = new stru12_MemoryBlock(640); +} + +//----- (00489810) -------------------------------------------------------- +stru12::~stru12() +{ + for (int i = 0; i < 12; ++i) + delete pMemBlocks[i]; +} + +//----- (004898BF) -------------------------------------------------------- +stru12_MemoryBlock::~stru12_MemoryBlock() +{ + stru12_MemoryBlock *v2; // esi@1 + void *v3; // ST00_4@1 + + v2 = this; + v3 = this->pBlockBase; + this->pAlignedBlock = 0; + free(v3); + v2->pBlockBase = 0; + //if ( a2 & 1 ) + // free(v2); +} + +//----- (004898E6) -------------------------------------------------------- +void stru12::_4898E6() +{ + void *v1; // eax@1 + void *v2; // edx@1 + char *v3; // edi@2 + double v4; // st7@2 + char *v5; // ebx@2 + double v6; // st6@3 + double v7; // st5@3 + double v8; // st4@3 + int v9; // esi@3 + double v10; // st3@3 + float v11; // ST34_4@5 + double v12; // st6@10 + double v13; // ST0C_8@10 + char *v14; // [sp+14h] [bp-44h]@2 + char *v15; // [sp+18h] [bp-40h]@2 + char *v16; // [sp+1Ch] [bp-3Ch]@2 + char *v17; // [sp+20h] [bp-38h]@2 + char *v18; // [sp+24h] [bp-34h]@2 + float v19; // [sp+30h] [bp-28h]@3 + float v20; // [sp+38h] [bp-20h]@3 + char *v21; // [sp+3Ch] [bp-1Ch]@2 + int v22; // [sp+40h] [bp-18h]@1 + char *v23; // [sp+44h] [bp-14h]@2 + char *v24; // [sp+48h] [bp-10h]@2 + int v25; // [sp+4Ch] [bp-Ch]@2 + float v26; // [sp+50h] [bp-8h]@3 + float v27; // [sp+54h] [bp-4h]@3 + + __debugbreak(); + v22 = 0; + v1 = this->pMemBlocks[1]->pAlignedBlock; + v2 = this->pMemBlocks[6]->pAlignedBlock; + if ( this->field_8C > 0 ) + { + v24 = (char *)((char *)pMemBlocks[0]->pAlignedBlock - v1); + v23 = (char *)((char *)pMemBlocks[2]->pAlignedBlock - v1); + v18 = (char *)((char *)pMemBlocks[7]->pAlignedBlock - v2); + v17 = (char *)((char *)pMemBlocks[8]->pAlignedBlock - v2); + v25 = (int)v1 - (int)v2; + v16 = (char *)((char *)pMemBlocks[9]->pAlignedBlock - v2); + v3 = (char *)((char *)pMemBlocks[4]->pAlignedBlock - v2); + v15 = (char *)((char *)pMemBlocks[10]->pAlignedBlock - v2); + v4 = 1.0; + v5 = (char *)((char *)pMemBlocks[5]->pAlignedBlock - v2); + v21 = (char *)((char *)pMemBlocks[3]->pAlignedBlock - v2); + v14 = (char *)((char *)pMemBlocks[11]->pAlignedBlock - v2); + do + { + v26 = *(float *)&v24[(int)((char *)v2 + v25)] - (double)pIndoorCamera->pos.x; + v27 = *(float *)((char *)v2 + v25) - (double)pIndoorCamera->pos.y; + v6 = *(float *)&v23[(int)((char *)v2 + v25)] - (double)pIndoorCamera->pos.z; + v7 = pIndoorCamera->fRotationYCosine; + v8 = pIndoorCamera->fRotationYSine; + v20 = pIndoorCamera->fRotationXCosine; + v19 = pIndoorCamera->fRotationXSine; + v9 = (int)((char *)v2 + (int)v21); + v10 = v27 * pIndoorCamera->fRotationYSine + pIndoorCamera->fRotationYCosine * v26; + if ( pIndoorCamera->sRotationX ) + { + v11 = v10; + *(float *)v9 = v11 * pIndoorCamera->fRotationXCosine + pIndoorCamera->fRotationXSine * v6; + *(float *)((char *)v2 + (int)v3) = v7 * v27 - v8 * v26; + *(float *)((char *)v2 + (int)v5) = v20 * v6 - v11 * v19; + } + else + { + *(float *)v9 = v10; + *(float *)((char *)v2 + (int)v3) = v7 * v27 - v8 * v26; + *(float *)((char *)v2 + (int)v5) = v6; + } + if ( *(float *)v9 >= 8.0 ) + { + if ( (double)pOutdoorCamera->shading_dist_mist >= *(float *)v9 ) + { + *(int *)v2 = 0; + v12 = v4 / (*(float *)v9 + 0.0000001) * (double)pOutdoorCamera->int_fov_rad; + *(float *)((char *)v2 + (int)v18) = (double)pViewport->uScreenCenterX + - v12 * *(float *)((char *)v2 + (int)v3); + *(float *)((char *)v2 + (int)v17) = (double)pViewport->uScreenCenterY + - v12 * *(float *)((char *)v2 + (int)v5); + *(float *)((char *)v2 + (int)v16) = v4 + - v4 / (*(float *)v9 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); + *(float *)((char *)v2 + (int)v15) = v4 / (*(float *)v9 + 0.0000001); + v13 = *(float *)v9 + 6.7553994e15; + v4 = 1.0; + *(int *)((char *)v2 + (int)v14) = LODWORD(v13); + } + else + { + *(int *)v2 = 2; + } + } + else + { + *(int *)v2 = 1; + } + ++v22; + v2 = (char *)v2 + 4; + } + while ( v22 < this->field_8C ); + } + this->field_8C = 0; +} + + +//----- (0048276F) -------------------------------------------------------- +void Polygon::_48276F_sr() +{ + unsigned int v1; // ebx@1 + float v2; // edx@2 + double v3; // st7@2 + char *v4; // ecx@3 + float v5; // eax@5 + float v6; // eax@7 + float v7; // eax@9 + float v8; // ecx@13 + int i; // eax@16 + int v10; // edx@20 + RenderVertexSoft *v11; // ecx@22 + RenderVertexSoft *v12; // edx@22 + RenderVertexSoft *v13; // esi@22 + int v14; // ebx@26 + RenderVertexSoft *v15; // ebx@27 + double v16; // st6@28 + double v17; // st5@28 + double v18; // st4@28 + int v19; // [sp+4h] [bp-2Ch]@20 + int v20; // [sp+8h] [bp-28h]@22 + int v21; // [sp+Ch] [bp-24h]@22 + Polygon *v22; // [sp+10h] [bp-20h]@1 + float v23; // [sp+14h] [bp-1Ch]@11 + float v24; // [sp+18h] [bp-18h]@7 + float v25; // [sp+1Ch] [bp-14h]@5 + float v26; // [sp+20h] [bp-10h]@2 + float v27; // [sp+24h] [bp-Ch]@2 + float v28; // [sp+28h] [bp-8h]@2 + float v29; // [sp+2Ch] [bp-4h]@9 + + v1 = this->uNumVertices; + v22 = this; + if ( (signed int)v1 >= 3 ) + { + LODWORD(v2) = 0; + v26 = 10000.0; + v28 = 10000.0; + v3 = -10000.0; + v27 = -10000.0; + if ( (signed int)v1 > 0 ) + { + v4 = (char *)&sr_508690[0].vWorldViewProjY; + do + { + if ( *((float *)v4 - 1) < (double)v26 ) + { + LODWORD(v5) = *((int *)v4 - 1); + v25 = v2; + v26 = v5; + } + if ( *((float *)v4 - 1) > (double)v27 ) + { + LODWORD(v6) = *((int *)v4 - 1); + v24 = v2; + v27 = v6; + } + if ( *(float *)v4 < (double)v28 ) + { + LODWORD(v7) = *(int *)v4; + v29 = v2; + v28 = v7; + } + if ( v3 < *(float *)v4 ) + { + v3 = *(float *)v4; + v23 = v2; + } + ++LODWORD(v2); + v4 += 48; + } + while ( SLODWORD(v2) < (signed int)v1 ); + } + v8 = v29; + if ( LODWORD(v29) == LODWORD(v25) || LODWORD(v29) == LODWORD(v24) ) + v8 = v23; + v29 = 0.0; + for ( i = 0; i < (signed int)v1; ++i ) + { + if ( i == LODWORD(v25) || i == LODWORD(v24) || i == LODWORD(v8) ) + { + v10 = LODWORD(v29)++; + *(&v19 + v10) = i; + } + } + v11 = &sr_508690[v19]; + v12 = &sr_508690[v20]; + v13 = &sr_508690[v21]; + if ( LODWORD(v29) != 3 ) + { + v11 = sr_508690; + v13 = (RenderVertexSoft *)((char *)sr_508690 + 16 * (3 * v1 - 3)); + v12 = &sr_508690[1]; + v28 = sr_508690[1].vWorldPosition.x - sr_508690[0].vWorldPosition.x; + v27 = sr_508690[1].vWorldPosition.y - sr_508690[0].vWorldPosition.y; + v29 = sr_508690[1].vWorldPosition.z - sr_508690[0].vWorldPosition.z; + v26 = v13->vWorldPosition.x - sr_508690[0].vWorldPosition.x; + v25 = v13->vWorldPosition.y - sr_508690[0].vWorldPosition.y; + v24 = v13->vWorldPosition.z - sr_508690[0].vWorldPosition.z; + if ( v24 * v27 - v25 * v29 == 0.0 ) + { + if ( v26 * v29 - v24 * v28 == 0.0 ) + { + if ( v25 * v28 - v26 * v27 == 0.0 ) + { + v14 = v1 - 2; + LODWORD(v26) = v14; + if ( v14 >= 2 ) + { + v15 = &sr_508690[v14]; + do + { + v16 = v15->vWorldPosition.x - sr_508690[0].vWorldPosition.x; + v17 = v15->vWorldPosition.y - sr_508690[0].vWorldPosition.y; + v18 = v15->vWorldPosition.z - sr_508690[0].vWorldPosition.z; + v13 = v15; + if ( v27 * v18 - v17 * v29 != 0.0 ) + break; + if ( v16 * v29 - v18 * v28 != 0.0 ) + break; + if ( v28 * v17 - v16 * v27 != 0.0 ) + break; + --LODWORD(v26); + --v15; + } + while ( SLODWORD(v26) >= 2 ); + } + } + } + } + } + sr_sub_4829B9(v11, v12, v13, v22, 1); + } +} + + +//----- (004829B9) -------------------------------------------------------- +Polygon *__fastcall sr_sub_4829B9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, Polygon *a4, int a5) +{ + double v5; // st7@1 + RenderVertexSoft *v6; // esi@1 + double v7; // st6@1 + Polygon *result; // eax@3 + double v9; // st6@3 + double v10; // st5@3 + float v11; // ST0C_4@3 + float v12; // ST04_4@3 + double v13; // st4@3 + float v14; // [sp+8h] [bp-Ch]@1 + float v15; // [sp+10h] [bp-4h]@1 + float v16; // [sp+1Ch] [bp+8h]@1 + float v17; // [sp+1Ch] [bp+8h]@3 + + v5 = a2->vWorldViewProjX - a1->vWorldViewProjX; + v6 = a3; + v16 = a3->vWorldViewProjY - a1->vWorldViewProjY; + v15 = a2->vWorldViewProjY - a1->vWorldViewProjY; + v14 = v6->vWorldViewProjX - a1->vWorldViewProjX; + v7 = v16 * v5 - v14 * v15; + if ( v7 == 0.0 ) + v7 = 0.0000001; + result = a4; + v9 = 1.0 / v7; + v10 = 1.0 / a1->vWorldViewPosition.x; + v11 = 1.0 / a2->vWorldViewPosition.x - v10; + v12 = 1.0 / v6->vWorldViewPosition.x - v10; + v13 = (v11 * v16 - v12 * v15) * v9; + v17 = (v11 * v14 - v12 * v5) * -v9; + a4->field_C = a1->vWorldViewProjX; + a4->field_10 = a1->vWorldViewProjY; + a4->field_0 = v10; + a4->field_8 = v17; + a4->field_4 = v13; + return result; +} + +//----- (00481DB2) -------------------------------------------------------- +char __fastcall sr_sub_481DB2(RenderVertexSoft *a1, signed int a2, Polygon *a3) +{ + int v3; // eax@2 + int v4; // esi@2 + signed int v5; // esi@2 + char *v6; // edi@3 + double v7; // ST14_8@4 + double v8; // ST0C_8@4 + char result; // al@5 + + if ( a2 >= 3 ) + { + v3 = a3->uTileBitmapID; + v4 = a3->uTileBitmapID; + a3->ptr_38 = &stru_8019C8; + a3->pTexture = (Texture *)(v4 != -1 ? (int)&pBitmaps_LOD->pTextures[v3] : 0); + v5 = 0; + if ( (signed int)a3->uNumVertices > 0 ) + { + v6 = (char *)&sr_508690[0].vWorldViewProjY; + do + { + v7 = *((float *)v6 - 1) + 6.7553994e15; + dword_50B638[v5] = LODWORD(v7); + v8 = *(float *)v6 + 6.7553994e15; + v6 += 48; + dword_50B570[v5++] = LODWORD(v8); + } + while ( v5 < (signed int)a3->uNumVertices ); + } + result = sr_sub_486B4E_push_outdoor_edges(a1, dword_50B638.data(), dword_50B570.data(), a3); + } + return result; +} + +//----- (00486B4E) -------------------------------------------------------- +char __fastcall sr_sub_486B4E_push_outdoor_edges(RenderVertexSoft *a1, int *a2, int *a3, Polygon *a4)//maybe DrawPolygonSW +{ + Polygon *v4; // esi@1 + RenderVertexSoft *v5; // edi@1 + char v6; // zf@1 + unsigned int v7; // eax@3 + int v8; // ebx@3 + int *v9; // ecx@7 + int v10; // ebx@8 + int v11; // eax@10 + double v12; // st7@14 + int *v13; // edx@14 + double v14; // st6@14 + double v15; // st7@16 + int v16; // edi@16 + double v17; // st7@16 + double v18; // st7@16 + int v19; // edi@18 + double v20; // st7@18 + double v21; // st7@18 + Edge *i; // edx@20 + double v23; // st7@28 + Edge *v24; // eax@28 + std::string v26; // [sp-18h] [bp-98h]@2 + const char *v27; // [sp-8h] [bp-88h]@2 + int v28; // [sp-4h] [bp-84h]@2 + double v29; // [sp+Ch] [bp-74h]@28 + double v30; // [sp+14h] [bp-6Ch]@28 + double v31; // [sp+1Ch] [bp-64h]@20 + double v32; // [sp+24h] [bp-5Ch]@16 + double v33; // [sp+2Ch] [bp-54h]@14 + unsigned int v34; // [sp+34h] [bp-4Ch]@2 + unsigned __int64 v35; // [sp+38h] [bp-48h]@28 + int v36; // [sp+40h] [bp-40h]@28 + int v37; // [sp+44h] [bp-3Ch]@20 + float v38; // [sp+48h] [bp-38h]@18 + int v39; // [sp+4Ch] [bp-34h]@16 + int v40; // [sp+50h] [bp-30h]@14 + int v41; // [sp+54h] [bp-2Ch]@3 + RenderVertexSoft *v42; // [sp+58h] [bp-28h]@1 + int v43; // [sp+5Ch] [bp-24h]@14 + int v44; // [sp+60h] [bp-20h]@6 + int v45; // [sp+64h] [bp-1Ch]@6 + unsigned int v46; // [sp+68h] [bp-18h]@7 + int *v47; // [sp+6Ch] [bp-14h]@1 + int v48; // [sp+70h] [bp-10h]@7 + float *v49; // [sp+74h] [bp-Ch]@7 + float v50; // [sp+78h] [bp-8h]@10 + float v51; // [sp+7Ch] [bp-4h]@14 + + v4 = a4; + v5 = a1; + v47 = a2; + v6 = (HIBYTE(a4->flags) & 0x40) == 0; + v42 = a1; + if ( !v6 ) + { + MessageBoxW(nullptr, L"The Texture Frame Table is not a supported feature.", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odspan.cpp:162", 0); + } + LOBYTE(v7) = v4->field_108; + v8 = v4->uNumVertices; + v4->field_108 = 0; + BYTE3(a4) = v7; + v41 = v8; + if ( v8 > 0 ) + { + if ( (signed int)pOutdoorCamera->uNumSurfs < 1999 ) + { + v7 = pOutdoorCamera->uNumEdges; + if ( (signed int)pOutdoorCamera->uNumEdges < 5979 ) + { + v4->uEdgeList1Size = 0; + v4->uEdgeList2Size = 0; + v45 = -1; + v34 = v7; + v28 = v8; + v27 = (const char *)v5; + v44 = 10000; + pGame->pLightmapBuilder->_45CB89(v5, v8); + if ( v8 > 0 ) + { + v9 = a3; + v48 = 1; + v49 = &v5->flt_2C; + v46 = (char *)v47 - (char *)a3; + do + { + v10 = v48; + ++pOutdoorCamera->uNumEdges; + if ( v48 >= v41 ) + v10 = 0; + v11 = *v9; + LODWORD(v50) = *v9; + if ( SLODWORD(v50) > v45 ) + v45 = v11; + if ( v11 < v44 ) + v44 = v11; + v12 = (double)SLODWORD(v50); + v13 = &a3[v10]; + v51 = v12; + v14 = (double)*v13; + v50 = v14; + *(float *)&v40 = v14 - v12; + v33 = *(float *)&v40 + 6.7553994e15; + v43 = LODWORD(v33); + if ( LODWORD(v33) ) + { + if ( SLODWORD(v33) >= 0 ) + { + v19 = (int)((char *)v9 + v46); + ptr_80C978_Edges->field_8 = 1; + LODWORD(v38) = (int)&v47[v10]; + v40 = *(unsigned int *)LODWORD(v38) - *(int *)v19; + v6 = BYTE3(a4) == 0; + v20 = (double)v40; + v40 = *v13 - *v9; + v21 = v20 / (double)v40; + ptr_80C978_Edges->field_4 = v21; + ptr_80C978_Edges->field_0 = (v51 - (double)*v9) * v21 + (double)*(signed int *)v19; + if ( !v6 ) + { + ptr_80C978_Edges->field_1C = *v49; + ptr_80C978_Edges->field_20 = v42[v10].flt_2C; + ptr_80C978_Edges->field_24 = (double)*(signed int *)v19; + ptr_80C978_Edges->field_28 = (double)(signed int)*(unsigned int *)LODWORD(v38); + ptr_80C978_Edges->field_2C = (double)*v9; + ptr_80C978_Edges->field_30 = (double)*v13; + v4->pEdgeList1[v4->uEdgeList1Size++] = ptr_80C978_Edges; + } + } + else + { + v32 = v51 + 6.7553994e15; + v39 = LODWORD(v32); + v51 = v50; + v15 = (double)SLODWORD(v32); + ptr_80C978_Edges->field_8 = 0; + v16 = (int)&v47[v10]; + v50 = v15; + v40 = *(int *)((char *)v9 + v46) - *(int *)v16; + v6 = BYTE3(a4) == 0; + v17 = (double)v40; + v40 = *v9 - *v13; + v18 = v17 / (double)v40; + ptr_80C978_Edges->field_4 = v18; + ptr_80C978_Edges->field_0 = (v51 - (double)*v13) * v18 + (double)*(signed int *)v16; + if ( !v6 ) + { + ptr_80C978_Edges->field_1C = v42[v10].flt_2C; + ptr_80C978_Edges->field_20 = *v49; + ptr_80C978_Edges->field_24 = (double)*(signed int *)v16; + ptr_80C978_Edges->field_28 = (double)*(int *)((char *)v9 + v46); + ptr_80C978_Edges->field_2C = (double)*v13; + ptr_80C978_Edges->field_30 = (double)*v9; + v4->pEdgeList2[v4->uEdgeList2Size++] = ptr_80C978_Edges; + } + } + v31 = v51 + 6.7553994e15; + v37 = LODWORD(v31); + for ( i = &pNewEdges[LODWORD(v31)]; i->pNext->field_0 < (double)ptr_80C978_Edges->field_0; i = i->pNext ) + ; + if ( i->field_0 != ptr_80C978_Edges->field_0 || i->field_8 || ptr_80C978_Edges->field_8 != 1 ) + { + ptr_80C978_Edges->pNext = i->pNext; + i->pNext = ptr_80C978_Edges; + } + else + { + ptr_80C978_Edges->pNext = i; + i->pPrev->pNext = ptr_80C978_Edges; + } + v23 = v50 - 1.0; + *(float *)&v40 = v23; + v38 = v23; + v30 = v38 + 6.7553994e15; + v36 = LODWORD(v30); + ptr_80C978_Edges->ptr_18 = ptr_80CA10[LODWORD(v30)]; + v29 = *(float *)&v40 + 6.7553994e15; + v35 = __PAIR__(v40, LODWORD(v29)); + v24 = ptr_80C978_Edges; + ptr_80CA10[LODWORD(v29)] = ptr_80C978_Edges; + v24->pSurf = ptr_80C97C_Surfs; + if ( ptr_80C978_Edges < &pEdges[5999] ) + ++ptr_80C978_Edges; + } + ++v48; + v49 += 12; + ++v9; + } + while ( v48 - 1 < v41 ); + } + LOBYTE(v7) = v34; + if ( pOutdoorCamera->uNumEdges != v34 ) + { + v4->ptr_48 = 0; + ptr_80C97C_Surfs->field_22 = 0; + ptr_80C97C_Surfs->pParent = v4; + ptr_80C97C_Surfs->field_4 = v4->field_4; + ptr_80C97C_Surfs->field_8 = v4->field_8; + ptr_80C97C_Surfs->field_0 = v4->field_0; + ptr_80C97C_Surfs->field_C = v4->field_C; + ptr_80C97C_Surfs->field_10 = v4->field_10; + LOBYTE(v7) = (char)pSurfs + 28; + if ( ptr_80C97C_Surfs < &pSurfs[1999] ) + { + ++ptr_80C97C_Surfs; + ++pOutdoorCamera->uNumSurfs; + } + if ( BYTE3(a4) ) + v4->field_108 = 1; + } + } + } + } + return v7; +} + +//----- (00482A94) -------------------------------------------------------- +int sr_sub_482A94(Span *_this) +{ + stru315 *v1; // ebp@0 + Span *v2; // edi@1 + Polygon *v3; // esi@1 + int v4; // ecx@1 + stru149 *v5; // eax@1 + stru149 *v6; // eax@1 + int v7; // edx@1 + int v8; // eax@1 + int v9; // ecx@1 + int v10; // edx@1 + int v11; // ebx@1 + int v12; // eax@1 + signed int v13; // ebx@1 + int v14; // ebx@2 + signed __int64 v15; // qtt@3 + stru149 *v16; // eax@3 + signed int v17; // ebx@3 + Texture *v18; // eax@14 + unsigned __int16 *v19; // eax@15 + stru149 *v20; // eax@21 + signed int v21; // eax@21 + int v22; // eax@21 + int v23; // ecx@21 + Texture *v24; // edx@21 + signed int v25; // eax@21 + signed int v27; // [sp-4h] [bp-A4h]@8 + int v28; // [sp+Ch] [bp-94h]@1 + int v29; // [sp+10h] [bp-90h]@1 + stru316 a2; // [sp+14h] [bp-8Ch]@21 + stru315 a1; // [sp+3Ch] [bp-64h]@1 + int v32; // [sp+80h] [bp-20h]@1 + int v33; // [sp+84h] [bp-1Ch]@1 + int v34; // [sp+88h] [bp-18h]@1 + int v35; // [sp+8Ch] [bp-14h]@1 + int v36; // [sp+90h] [bp-10h]@1 + int v37; // [sp+94h] [bp-Ch]@1 + int v38; // [sp+98h] [bp-8h]@1 + int X; // [sp+9Ch] [bp-4h]@1 + + v2 = _this; + v3 = _this->pParent; + v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A); + v5 = v3->ptr_38; + v38 = v4; + v37 = v5->field_14; + v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16; + v6 = v3->ptr_38; + v7 = v38 + v6->field_C; + v37 = v6->field_20; + v33 = v7; + v8 = ((unsigned __int64)(v37 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18; + v38 = v4; + v34 = v8; + v37 = v3->v_18.z; + v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16; + v9 = v3->v_18.x; + v28 = v3->sTextureDeltaU << 16; + v35 = v3->sTextureDeltaV << 16; + v10 = v2->field_8; + v29 = pOutdoorCamera->camera_rotation_y_int_sine; + v32 = pOutdoorCamera->camera_rotation_y_int_cosine; + a1.field_28 = v2->field_C; + v11 = v3->field_24; + v37 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v10); + v12 = v3->v_18.y; + v13 = -v11; + v36 = v13; + X = ((unsigned __int64)(v37 * (signed __int64)v12) >> 16) + v38 + v9; + if ( !X || (v14 = abs(v13 >> 14), v14 > abs(X)) ) + return 0; + LODWORD(v15) = v36 << 16; + HIDWORD(v15) = v36 >> 16; + v38 = v15 / X; + v16 = v3->ptr_38; + X = v37; + v36 = v16->field_10; + X = v37; + v36 = v33 + ((unsigned __int64)(v36 * (signed __int64)v37) >> 16); + v33 = v3->ptr_38->field_1C; + X = (unsigned __int64)(v33 * (signed __int64)v37) >> 16; + v34 += (unsigned __int64)(v33 * (signed __int64)v37) >> 16; + v17 = 2; + a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; + if ( v38 >= mipmapping_building_mm1 << 16 ) + { + if ( v38 >= mipmapping_building_mm2 << 16 ) + { + if ( v38 >= mipmapping_building_mm3 << 16 ) + { + if ( bUseLoResSprites ) + goto LABEL_12; + v27 = 3; + } + else + { + v27 = 2; + } + v17 = v27; + goto LABEL_12; + } + v17 = 1; + } + else + { + v17 = 0; + } +LABEL_12: + if ( v17 < (signed int)v3->ptr_48 ) + v17 = (signed int)v3->ptr_48; + v18 = v3->pTexture; + if ( v17 ) + { + if ( v17 == 1 ) + { + v19 = (unsigned __int16 *)v18->pLevelOfDetail1; + } + else + { + if ( v17 == 2 ) + v19 = (unsigned __int16 *)v18->pLevelOfDetail2; + else + v19 = (unsigned __int16 *)v18->pLevelOfDetail3; + } + } + else + { + v19 = (unsigned __int16 *)v18->pLevelOfDetail0_prolly_alpha_mask; + } + a1.pTextureLOD = v19; + X = (unsigned __int64)(v36 * (signed __int64)v38) >> 16; + v20 = v3->ptr_38; + X = v38; + a1.field_30 = v28 + ((unsigned __int64)(v36 * (signed __int64)v38) >> 16) - v20->field_24; + X = (unsigned __int64)(v34 * (signed __int64)v38) >> 16; + v21 = X - v3->ptr_38->field_28 - v35; + a1.field_30 >>= v17 + bUseLoResSprites; + a1.field_2C = v21 >> (v17 + bUseLoResSprites); + v35 = pOutdoorCamera->int_fov_rad_inv; + v37 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v38) >> 16) >> (v17 + bUseLoResSprites); + a1.field_4 = (unsigned __int64)(v37 * (signed __int64)v29) >> 16; + X = (unsigned __int64)(v37 * (signed __int64)v32) >> 16; + a1.field_0 = -(signed int)((unsigned __int64)(v37 * (signed __int64)v32) >> 16); + v22 = v2->field_A; + a1.pColorBuffer = &pRenderer->pTargetSurface[v2->field_8 + pRenderer->uTargetSurfacePitch * v2->field_A]; + HIWORD(v23) = HIWORD(v38); + a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v2->field_8 + 640 * v22]; + LOWORD(v23) = 0; + a1.field_24 = v23 | v3->field_50; + v24 = v3->pTexture; + v32 = (signed int)v24->uTextureWidth >> v17; + v25 = (signed int)v24->uTextureHeight >> v17; + a1.field_10 = v17 - v24->uWidthLn2 + 16; + a1.field_C = v32 - 1; + a1.field_8 = (v25 << 16) - 65536; + a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v38, v3, pOutdoorCamera->building_gamme, 1u, 1); + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + sr_sub_485975(&a1, (stru315 *)&a2); + else + sr_sub_4D6FB0(v1); + return 1; +} + +//----- (004789DE) -------------------------------------------------------- +BSPModel *Render::DrawBuildingsSW() +{ + BSPModel *result; // eax@1 + BSPModel *v1; // ebx@2 + int v2; // eax@4 + ODMFace *v3; // edi@4 + int v4; // ecx@6 + int v5; // eax@6 + int v6; // ecx@6 + int v7; // ecx@6 + double v8; // st7@7 + char *v9; // ebx@7 + int v10; // eax@9 + double v11; // st7@9 + Polygon *v12; // ebx@19 + double v13; // st7@21 + double v14; // ST4C_8@23 + int v15; // eax@23 + int v16; // eax@27 + int v17; // ecx@29 + unsigned __int8 v18; // sf@29 + unsigned __int8 v19; // of@29 + int v20; // ecx@30 + int v21; // eax@31 + int v22; // eax@31 + int v23; // eax@35 + int v24; // eax@39 + Texture *v25; // eax@43 + int v26; // esi@43 + signed int v27; // ecx@43 + double v28; // st6@43 + double v29; // st5@43 + unsigned short *v30; // edx@44 + int v31; // eax@44 + double v32; // st4@45 + int v33; // ecx@45 + char v34; // zf@45 + BSPVertexBuffer *v35; // eax@50 + unsigned int v36; // eax@53 + signed int v37; // esi@53 + int v38; // eax@54 + signed int v39; // edx@55 + char *v40; // ecx@56 + double v41; // ST1C_8@57 + double v42; // ST24_8@57 + signed int v43; // eax@60 + signed int v44; // esi@60 + int v45; // eax@61 + signed int v46; // edx@62 + char *v47; // ecx@63 + double v48; // ST34_8@64 + double v49; // ST44_8@64 + int v50; // eax@66 + signed int v51; // ecx@67 + char *v52; // edx@68 + double v53; // ST3C_8@69 + double v54; // ST2C_8@69 + float v55; // [sp+44h] [bp-7Ch]@50 + float v56; // [sp+48h] [bp-78h]@50 + float v57; // [sp+4Ch] [bp-74h]@50 + float v58; // [sp+50h] [bp-70h]@64 + int v59; // [sp+54h] [bp-6Ch]@64 + int v60; // [sp+58h] [bp-68h]@69 + float v61; // [sp+5Ch] [bp-64h]@64 + float v62; // [sp+60h] [bp-60h]@69 + float v63; // [sp+64h] [bp-5Ch]@57 + float v64; // [sp+68h] [bp-58h]@57 + int v65; // [sp+6Ch] [bp-54h]@64 + int v66; // [sp+70h] [bp-50h]@1 + int v67; // [sp+74h] [bp-4Ch]@6 + int v68; // [sp+78h] [bp-48h]@4 + int v69; // [sp+7Ch] [bp-44h]@57 + int v70; // [sp+80h] [bp-40h]@69 + int v71; // [sp+84h] [bp-3Ch]@23 + float v72; // [sp+88h] [bp-38h]@69 + int v73; // [sp+8Ch] [bp-34h]@57 + int v74; // [sp+90h] [bp-30h]@6 + int v75; // [sp+94h] [bp-2Ch]@6 + ODMFace *v76; // [sp+98h] [bp-28h]@4 + int v77; // [sp+9Ch] [bp-24h]@6 + BSPModel *v78; // [sp+A0h] [bp-20h]@2 + int v79; // [sp+A4h] [bp-1Ch]@4 + int a1; // [sp+A8h] [bp-18h]@1 + unsigned short *v81; // [sp+ACh] [bp-14h]@7 + int v82; // [sp+B0h] [bp-10h]@6 + int v83; // [sp+B4h] [bp-Ch]@6 + signed int v84; // [sp+B8h] [bp-8h]@7 + int a2; // [sp+BCh] [bp-4h]@1 + + a2 = 0; + a1 = 0; + result = (BSPModel *)pOutdoor->pBModels; + v66 = pOutdoor->uNumBModels; + if ( (signed int)pOutdoor->uNumBModels > 0 ) + { + v1 = pOutdoor->pBModels; + v78 = pOutdoor->pBModels; + while ( 1 ) + { + if ( IsBModelVisible(a1, &a2) ) + { + v1->field_40 |= 1u; + v2 = v1->uNumFaces; + v3 = v1->pFaces; + v74 = 0; + v76 = v3; + v68 = v2; + if ( v2 > 0 ) + break; + } +LABEL_73: + ++a1; + ++v1; + result = (BSPModel *)a1; + v78 = v1; + if ( a1 >= v66 ) + return result; + } + while ( 1 ) + { + if ( !v3->Invisible() ) + { + v4 = 3 * v3->pVertexIDs[0]; + v5 = (int)((char *)v1 - 8); + v67 = (int)((char *)v1 - 8); + v6 = *(_DWORD *)(*(&v1->uNumConvexFaces - 2) + 4 * v4 + 8) + 4; + v82 = 0; + v83 = v6; + v74 = 0; + v7 = v3->uNumVertices; + v75 = 0; + v77 = v7; + if ( v7 > 0 ) + { + v8 = (double)v83; + v9 = (char *)&array_73D150[0].vWorldViewPosition; + v81 = v3->pVertexIDs; + v83 = v7; + *(float *)&v84 = v8; + while ( 1 ) + { + v10 = *(int *)(v5 + 4) + 12 * *(short *)v81; + *((float *)v9 - 3) = (double)*(signed int *)v10 + 4.0; + *((float *)v9 - 2) = (double)*(signed int *)(v10 + 4) + 4.0; + v11 = (double)*(signed int *)(v10 + 8) + 4.0; + *((float *)v9 - 1) = v11; + if ( *(float *)&v84 == v11 ) + ++v82; + pGame->pIndoorCameraD3D->ViewTransform((RenderVertexSoft *)(v9 - 12), 1u); + if ( *(float *)v9 < 8.0 || (double)pOutdoorCamera->shading_dist_mist < *(float *)v9 ) + { + if ( *(float *)v9 >= 8.0 ) + v75 = 1; + else + v74 = 1; + } + else + { + pGame->pIndoorCameraD3D->Project((RenderVertexSoft *)(v9 - 12), 1u, 0); + } + v81 += 2; + v9 += 48; + --v83; + if ( !v83 ) + break; + v5 = v67; + } + v7 = v77; + } + v12 = &array_77EC08[pOutdoorCamera->uNumPolygons]; + *(int *)&v12->flags = 0; + if ( v82 == v7 ) + *(int *)&v12->flags = 65536; + v12->pODMFace = v3; + v12->uNumVertices = v7; + v12->field_59 = 5; + v84 = v3->pFacePlane.vNormal.x; + v83 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.x) >> 16; + v82 = -pOutdoor->vSunlight.y; + v84 = v3->pFacePlane.vNormal.y; + v82 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.y) >> 16; + v81 = (unsigned __int16 *)-pOutdoor->vSunlight.z; + v84 = v3->pFacePlane.vNormal.z; + v81 = (unsigned __int16 *)((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16); + v84 = v83 + v82 + ((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16); + v13 = (double)v84 * 0.000015258789; + if ( v13 < 0.0 ) + v13 = 0.0; + *(float *)&v84 = v13 * 31.0; + v14 = *(float *)&v84 + 6.7553994e15; + v71 = LODWORD(v14); + v15 = (int)&v12->dimming_level; + v12->dimming_level = 31 - LOBYTE(v14); + if ( (char)(31 - LOBYTE(v14)) < 0 ) + *(char *)v15 = 0; + if ( *(char *)v15 > 31 ) + *(char *)v15 = 31; + v16 = v3->uTextureID; + if ( BYTE1(v3->uAttributes) & 0x40 ) + v16 = pTextureFrameTable->GetFrameTexture(v16, pEventTimer->uTotalGameTimeElapsed); + v17 = v16; + result = (BSPModel *)&pBitmaps_LOD->pTextures[v16]; + v19 = __OFSUB__(pOutdoorCamera->uNumPolygons, 1999); + v18 = pOutdoorCamera->uNumPolygons - 1999 < 0; + v12->pTexture = (Texture *)(v17 != -1 ? (int)result : 0); + if ( !(v18 ^ v19) ) + return result; + ++pOutdoorCamera->uNumPolygons; + ++pOutdoorCamera->field_44; + if ( !ODMFace::IsBackfaceCulled(v3, array_73D150, v12) ) + { +LABEL_71: + --pOutdoorCamera->uNumPolygons; + --pOutdoorCamera->field_44; + goto LABEL_72; + } + LOBYTE(v20) = v79; + v21 = a1; + v3->bVisible = 1; + v12->uBModelFaceID = v20; + LOWORD(v20) = (unsigned __int8)v20; + v12->uBModelID = v21; + v22 = 8 * (v20 | (v21 << 6)); + LOBYTE(v22) = v22 | 6; + v12->field_50 = v22; + if ( v3->uAttributes & 0x10 ) + *(int *)&v12->flags |= 2u; + if ( BYTE2(v3->uAttributes) & 0x40 ) + HIBYTE(v12->flags) |= 4u; + v23 = v3->uAttributes; + if ( v23 & 4 ) + { + HIBYTE(v12->flags) |= 4u; + } + else + { + if ( v23 & 0x20 ) + HIBYTE(v12->flags) |= 8u; + } + v24 = v3->uAttributes; + if ( BYTE1(v24) & 8 ) + { + HIBYTE(v12->flags) |= 0x20u; + } + else + { + if ( v24 & 0x40 ) + HIBYTE(v12->flags) |= 0x10u; + } + v25 = v12->pTexture; + v26 = v77; + v27 = v25->uTextureWidth; + v84 = v25->uTextureHeight; + v28 = 1.0 / (double)v27; + v29 = 1.0 / (double)v84; + if ( v77 > 0 ) + { + v30 = v3->pTextureVIDs; + v31 = 0; + v83 = v77; + do + { + v32 = 1.0 / (*(float *)(v31 * 48 + 7590236) + 0.0000001); + memcpy(&array_50AC10[v31], &array_73D150[v31], sizeof(array_50AC10[v31])); + ++v31; + array_50A2B0[v31 + 49]._rhw = v32; + v84 = v12->sTextureDeltaU + *(short *)(v30 - 40); + array_50A2B0[v31 + 49].u = (double)v84 * v28; + v33 = v12->sTextureDeltaV + *(short *)v30; + v30 += 2; + v34 = v83-- == 1; + v84 = v33; + array_50A2B0[v31 + 49].v = (double)v33 * v29; + } + while ( !v34 ); + v3 = v76; + v26 = v77; + } + + static stru154 static_sub_004789DE_stru_73C818; // idb + + pGame->pLightmapBuilder->ApplyLights_OutdoorFace((ODMFace *)v3); + if ( stru_F8AD28.uNumLightsApplied <= 0 ) + { + v12->field_108 = 0; + } + else + { + v35 = (BSPVertexBuffer *)(v78 - 2); + v12->field_108 = 1; + + static_sub_004789DE_stru_73C818.GetFacePlaneAndClassify((ODMFace *)v3, v35); + v55 = static_sub_004789DE_stru_73C818.face_plane.vNormal.x; + v56 = static_sub_004789DE_stru_73C818.face_plane.vNormal.y; + v57 = static_sub_004789DE_stru_73C818.face_plane.vNormal.z; + pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, v26, (Vec3_float_ *)&v55); + } + if ( v74 ) + { + v36 = sr_4250FE(v26); + v37 = v36; + if ( !v36 || (OutdoorCamera::Project(v36), v38 = sr_4254D2(v37), (v12->uNumVertices = v38) == 0) ) + goto LABEL_71; + v12->_48276F_sr(); + v39 = 0; + if ( (signed int)v12->uNumVertices > 0 ) + { + v40 = (char *)&sr_508690[0].vWorldViewProjY; + do + { + LODWORD(v64) = *((int *)v40 - 1); + v41 = v64 + 6.7553994e15; + v69 = LODWORD(v41); + dword_50B638[v39] = LODWORD(v41); + LODWORD(v63) = *(int *)v40; + v42 = v63 + 6.7553994e15; + v73 = LODWORD(v42); + v40 += 48; + dword_50B570[v39++] = LODWORD(v42); + } + while ( v39 < (signed int)v12->uNumVertices ); + } + } + else + { + if ( v75 ) + { + v43 = sr_4252E8(v26); + v44 = v43; + if ( !v43 || (OutdoorCamera::Project(v43), v45 = sr_4254D2(v44), (v12->uNumVertices = v45) == 0) ) + goto LABEL_71; + v12->_48276F_sr(); + v46 = 0; + if ( (signed int)v12->uNumVertices > 0 ) + { + v47 = (char *)&sr_508690[0].vWorldViewProjY; + do + { + LODWORD(v61) = *((int *)v47 - 1); + v48 = v61 + 6.7553994e15; + v65 = LODWORD(v48); + dword_50B638[v46] = LODWORD(v48); + LODWORD(v58) = *(int *)v47; + v49 = v58 + 6.7553994e15; + v59 = LODWORD(v49); + v47 += 48; + dword_50B570[v46++] = LODWORD(v49); + } + while ( v46 < (signed int)v12->uNumVertices ); + } + } + else + { + v50 = sr_4254D2(v26); + v12->uNumVertices = v50; + if ( !v50 ) + goto LABEL_71; + sr_sub_4829B9( + &array_73D150[v3->uGradientVertex1], + &array_73D150[v3->uGradientVertex2], + &array_73D150[v3->uGradientVertex3], + v12, + 0); + v51 = 0; + if ( (signed int)v12->uNumVertices > 0 ) + { + v52 = (char *)&sr_508690[0].vWorldViewProjY; + do + { + LODWORD(v62) = *((int *)v52 - 1); + v53 = v62 + 6.7553994e15; + v60 = LODWORD(v53); + dword_50B638[v51] = LODWORD(v53); + LODWORD(v72) = *(int *)v52; + v54 = v72 + 6.7553994e15; + v70 = LODWORD(v54); + v52 += 48; + dword_50B570[v51++] = LODWORD(v54); + } + while ( v51 < (signed int)v12->uNumVertices ); + } + } + } + sr_sub_486B4E_push_outdoor_edges(sr_508690, dword_50B638.data(), dword_50B570.data(), v12); + } +LABEL_72: + ++v79; + v1 = v78; + ++v3; + v76 = v3; + if ( v79 >= v68 ) + goto LABEL_73; + } + } + return result; +} + +//----- (0047BC6F) -------------------------------------------------------- +unsigned __int16 *__fastcall sr_GetBillboardPalette(RenderBillboard *a1, int a2, signed int a3, int a4) +{ + int v4; // ebx@1 + int v6; // edx@4 + int v7; // ecx@5 + signed int v8; // eax@6 + signed __int64 v9; // qtt@11 + signed int v10; // eax@12 + int v11; // esi@17 + signed __int64 v12; // qtt@19 + double v13; // ST10_8@19 + int v14; // edi@25 + signed int v15; // edx@26 + signed __int64 v16; // qtt@29 + signed int v17; // eax@30 + int v18; // [sp+10h] [bp-8h]@1 + float a3a; // [sp+20h] [bp+8h]@19 + + v4 = a2; + v18 = a2; + if ( pParty->armageddon_timer ) + return PaletteManager::Get(a2); + if ( !pWeather->bNight ) + { + if (day_attrib & DAY_ATTRIB_FOG) + { + v14 = day_fogrange_1 << 16; + if ( a3 >= day_fogrange_1 << 16 ) + { + if ( a3 <= day_fogrange_2 << 16 ) + { + LODWORD(v16) = (a3 - v14) << 16; + HIDWORD(v16) = (a3 - v14) >> 16; + v15 = (unsigned __int64)(27 * v16 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16; + } + else + { + v15 = 27; + } + } + else + { + v15 = 0; + } + v17 = _43F55F_get_billboard_light_level(a1, v15); + if ( v17 > 27 ) + v17 = 27; + if ( !a3 ) + v17 = 27; + v7 = v18; + v6 = v17; + return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); + } + v11 = a4; + if ( a4 < 0 ) + v11 = 0; + LODWORD(v12) = a3 << 16; + HIDWORD(v12) = a3 >> 16; + a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20) + * pOutdoor->fFogDensity; + v13 = a3a + 6.7553994e15; + v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11); + if ( v10 > 27 ) + v10 = 27; + if ( v10 < a4 ) + v10 = a4; + if ( v10 > pOutdoor->max_terrain_dimming_level ) + v10 = pOutdoor->max_terrain_dimming_level; + return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); + } + v6 = 0; + if (pWeather->bNight) + { + v8 = 67108864; + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) + v8 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower << 26; + if ( a3 <= v8 ) + { + if ( a3 > 0 ) + { + LODWORD(v9) = a3 << 16; + HIDWORD(v9) = a3 >> 16; + v6 = (unsigned __int64)(27 * v9 / v8) >> 16; + } + } + else + { + v6 = 27; + } + v10 = _43F55F_get_billboard_light_level(a1, v6); + if ( v10 > 27 || !a3 ) + v10 = 27; + return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); + } + v7 = 0; + return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); +} +//----- (00487389) -------------------------------------------------------- +void Render::ExecOutdoorDrawSW() +{ + unsigned __int16 *v0; // ebx@1 + unsigned int v1; // esi@1 + Polygon *v2; // eax@1 + Span *v3; // edi@6 + Polygon *v4; // esi@9 + Texture *v5; // ebp@10 + int v6; // esi@16 + unsigned int v7; // edx@16 + char *v8; // ecx@17 + unsigned int v9; // edi@22 + int v10; // eax@26 + int v11; // eax@27 + unsigned int v12; // ebp@32 + Span *v13; // esi@33 + int v14; // ecx@37 + int v15; // eax@40 + Texture *v16; // ebp@51 + //unsigned int v17; // eax@51 + int v18; // eax@54 + char v19; // al@56 + unsigned int v20; // eax@57 + int v21; // ecx@57 + unsigned int v22; // eax@57 + stru149 *v23; // eax@65 + int v24; // eax@67 + ODMFace *v25; // eax@78 + signed int v26; // edx@79 + signed int v27; // ecx@79 + unsigned int v28; // eax@106 + unsigned int v29; // ebp@117 + Span *v30; // esi@118 + unsigned int v31; // ST04_4@124 + int v33; // [sp+18h] [bp-44h]@80 + signed int v34; // [sp+1Ch] [bp-40h]@3 + signed int v35; // [sp+20h] [bp-3Ch]@79 + Span **v36; // [sp+24h] [bp-38h]@4 + unsigned int v37; // [sp+28h] [bp-34h]@1 + unsigned __int16 *a1; // [sp+2Ch] [bp-30h]@1 + int a1a; // [sp+2Ch] [bp-30h]@26 + unsigned int a1b; // [sp+2Ch] [bp-30h]@116 + char v41; // [sp+30h] [bp-2Ch]@57 + + v0 = pRenderer->pTargetSurface; + v1 = pOutdoorCamera->uNumPolygons; + a1 = pRenderer->pTargetSurface; + v2 = array_77EC08.data(); + v37 = pOutdoorCamera->uNumPolygons; + if ( !(pParty->uFlags & 2) ) + { + v1 = uNumElementsIn80AA28; + v2 = ptr_80AA28[0]; + v37 = uNumElementsIn80AA28; + } + v34 = 0; + if ( (signed int)v1 > 0 ) + { + v36 = &v2->prolly_head; + do + { + if ( pParty->uFlags & 2 ) + v3 = *v36; + else + v3 = ptr_80AA28[v34]->prolly_head; + if ( v3 ) + { + v4 = v3->pParent; + if ( v4 ) + { + v5 = v4->pTexture; + if ( v5 ) + { + if ( v3->field_8 >= (signed int)pViewport->uViewportTL_X || v3->field_C != pViewport->uViewportTL_X ) + { + LOBYTE(v4->field_32) |= 2u; + v14 = *(int *)&v4->flags; + if ( v14 & 0x10 && v4->field_59 != 5 ) + { + dword_80AA20 = (v4->terrain_grid_z - 64) << 25; + dword_80AA1C = dword_80AA20 + 0x1FF0000; + dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; + dword_80AA18 = dword_80AA14 - 0x1FF0000; + byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( + v4->terrain_grid_z, + v4->terrain_grid_x - 1) >> 9) & 1; + if ( *(int *)&v4->flags & 2 || (v15 = *(int *)&v4->flags, BYTE1(v15) & 1) ) + { + if ( *(int *)&v4->flags & 2 ) + { + while ( 1 ) + { + if ( pOutdoorCamera->outdoor_no_wavy_water ) + sr_sub_48408A_prolly_odm_water_no_waves(v3); + else + sr_sub_485407_prolly_odm_water_wavy(v3); + v3->field_E = LOWORD(sr_6BE060[1]); + if ( v4->prolly_tail == v3 ) + break; + v3 = v3->pNext; + } + } + else + { + while ( 1 ) + { + v16 = v4->pTexture; + v4->pTexture = pBitmaps_LOD->LoadTexturePtr("wtrtyl"); + if ( pOutdoorCamera->outdoor_no_wavy_water ) + sr_sub_48408A_prolly_odm_water_no_waves(v3); + else + sr_sub_485407_prolly_odm_water_wavy(v3); + v18 = v4->terrain_grid_z - 64; + v4->pTexture = v16; + dword_80AA20 = v18 << 25; + dword_80AA1C = (v18 << 25) + 0x1FF0000; + dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; + dword_80AA18 = dword_80AA14 - 0x1FF0000; + byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( + v4->terrain_grid_z, + v4->terrain_grid_x - 1) >> 9) & 1; + sr_sub_484442(v3); + v3->field_E = LOWORD(sr_6BE060[1]); + if ( v4->prolly_tail == v3 ) + break; + v3 = v3->pNext; + } + } + } + else + { + while ( sr_sub_48408A_prolly_odm_water_no_waves(v3) ) + { + v3->field_E = LOWORD(sr_6BE060[1]); + if ( v4->prolly_tail == v3 ) + break; + v3 = v3->pNext; + } + } + } + else + { + v19 = v4->field_59; + if ( v19 != 5 ) + { + if ( v14 & 2 ) + { + while ( 1 ) + { + v28 = pBitmaps_LOD->LoadTexture("wtrtyla"); + v4->pTexture = (Texture *)(v28 != -1 ? &pBitmaps_LOD->pTextures[v28] : 0); + if ( !sr_sub_4847EB(v3) ) + break; + v4->pTexture = v5; + if ( !sr_sub_484442(v3) ) + break; + v3->field_E = LOWORD(sr_6BE060[1]); + if ( v4->prolly_tail == v3 ) + break; + v3 = v3->pNext; + v5 = v4->pTexture; + } + } + else + { + if ( v19 == 1 ) + { + dword_80AA20 = (v4->terrain_grid_z - 64) << 25; + dword_80AA1C = dword_80AA20 + 33488896; + dword_80AA14 = (v4->terrain_grid_x << 25) + 0x7FFF0000; + dword_80AA18 = dword_80AA14 - 33488896; + byte_80AA10 = ((unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo( + v4->terrain_grid_z, + v4->terrain_grid_x - 1) >> 9) & 1; + while ( 1 ) + { + if ( !sr_sub_4847EB(v3) ) + sr_sub_48585C_mb_DrawSpan(v3, &pRenderer->pTargetSurface[v3->field_8 + 640 * v3->field_A], 0); + v3->field_E = LOWORD(sr_6BE060[1]); + if ( v4->prolly_tail == v3 ) + break; + v3 = v3->pNext; + } + } + } + goto LABEL_14; + } + v4->ptr_38 = (stru149 *)&v41; + v4->_479295(); + v20 = GetTickCount(); + v21 = *(int *)&v4->flags; + v22 = v20 >> 3; + if ( BYTE1(v21) & 4 ) + { + v4->sTextureDeltaV -= v22 & v4->pTexture->uHeightMinus1; + } + else + { + if ( BYTE1(v21) & 8 ) + v4->sTextureDeltaV += v22 & v4->pTexture->uHeightMinus1; + } + if ( BYTE1(v21) & 0x10 ) + { + v4->sTextureDeltaU -= v22 & v4->pTexture->uWidthMinus1; + } + else + { + if ( BYTE1(v21) & 0x20 ) + v4->sTextureDeltaU += v22 & v4->pTexture->uWidthMinus1; + } + v23 = v4->ptr_38; + v4->field_52 = 32; + v4->field_5A = 5; + if ( (double)abs(v23->field_C) > 52428.8 ) + { + v4->field_52 = 8; + v4->field_5A = 3; + } + v24 = *(int *)&v4->flags; + if ( !(v24 & 0x10000) ) + { + if ( !(v24 & 2) ) + { + v25 = v4->pODMFace; + if ( v25->uPolygonType == 1 ) + { + v26 = v25->pTextureUIDs[0]; + dword_80AA1C = v26; + dword_80AA20 = v26; + v27 = v25->pTextureVIDs[0]; + dword_80AA14 = v27; + dword_80AA18 = v27; + v35 = 1; + if ( v25->uNumVertices > 1u ) + { + v33 = (int)&v25->pTextureVIDs[1]; + do + { + if ( dword_80AA20 > *(short *)(v33 - 40) ) + dword_80AA20 = *(short *)(v33 - 40); + if ( v26 < *(short *)(v33 - 40) ) + { + v26 = *(short *)(v33 - 40); + dword_80AA1C = *(short *)(v33 - 40); + } + if ( dword_80AA18 > *(short *)v33 ) + dword_80AA18 = *(short *)v33; + if ( v27 < *(short *)v33 ) + { + v27 = *(short *)v33; + dword_80AA14 = *(short *)v33; + } + ++v35; + v33 += 2; + } + while ( v35 < v25->uNumVertices ); + v0 = a1; + } + dword_80AA20 = (dword_80AA20 + v4->sTextureDeltaU) << 16; + dword_80AA1C = ((v26 + v4->sTextureDeltaU) << 16) - 65536; + dword_80AA18 = (dword_80AA18 + v4->sTextureDeltaV) << 16; + dword_80AA14 = ((v27 + v4->sTextureDeltaV) << 16) - 65536; + } + while ( 1 ) + { + if ( !sr_sub_482E07(v3, v0) ) + sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); + v3->field_E = LOWORD(sr_6BE060[1]); + if ( v4->prolly_tail == v3 ) + break; + v3 = v3->pNext; + } + goto LABEL_14; + } + while ( 1 ) + { +LABEL_74: + if ( !sr_sub_4839BD(v3, v0) ) + sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); + v3->field_E = LOWORD(sr_6BE060[1]); + if ( v4->prolly_tail == v3 ) + break; + v3 = v3->pNext; + } + goto LABEL_14; + } + if ( v24 & 2 ) + goto LABEL_74; + while ( 1 ) + { + if ( !sr_sub_482A94(v3) ) + sr_sub_48585C_mb_DrawSpan(v3, &v0[v3->field_8 + 640 * v3->field_A], 0); + v3->field_E = LOWORD(sr_6BE060[1]); + if ( v4->prolly_tail == v3 ) + break; + v3 = v3->pNext; + } + } + } + else + { + v3->field_E = LOWORD(sr_6BE060[1]); + } + } + } + } +LABEL_14: + ++v34; + LOWORD(v2) = v34; + v36 += 67; + } + while ( v34 < (signed int)v37 ); + } + if ( pParty->uFlags & 2 ) + { + v6 = pOutdoorCamera->uNumPolygons; + v7 = 0; + uNumElementsIn80AA28 = 0; + if ( pOutdoorCamera->uNumPolygons > 0 ) + { + v8 = (char *)&array_77EC08[0].flags; + do + { + v2 = *(Polygon **)v8; + if ( (unsigned int)v2 & 0x20000 ) + { + ++v7; + *(int *)v8 = (unsigned int)v2 & 0xFFFDFFFF; + LOWORD(v2) = (short)v8 - 48; + *(&uNumElementsIn80AA28 + v7) = (unsigned int)(v8 - 48); + } + v8 += 268; + --v6; + } + while ( v6 ); + uNumElementsIn80AA28 = v7; + } + } + v9 = pOutdoorCamera->uNumSpans; + sr_6BE060[0] = pOutdoorCamera->uNumSpans; + if (pOutdoorCamera->uNumPolygons >= 1999) + return; + + array_77EC08[1999].Create_48607B(&stru_8019C8); + array_77EC08[1999].ptr_38->Inverse_sky_48694B(); + + if (pOutdoor->uMainTile_BitmapID == -1) + { + array_77EC08[1999].pTexture = nullptr; + return; + } + else + array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uMainTile_BitmapID); + array_77EC08[1999].dimming_level = 23 - (-20 * pOutdoor->vSunlight.z >> 16); + if ( array_77EC08[1999].dimming_level > 20 ) + array_77EC08[1999].dimming_level = 20; + v10 = stru_5C6E00->Sin(pIndoorCamera->sRotationX); + array_77EC08[1999].v_18.y = 0; + array_77EC08[1999].v_18.x = v10; + array_77EC08[1999].v_18.z = stru_5C6E00->Cos(pIndoorCamera->sRotationX); + array_77EC08[1999].field_24 = 2048 - (pIndoorCamera->pos.z << 16); + a1a = (signed __int64)((double)(pIndoorCamera->pos.z * pOutdoorCamera->int_fov_rad) + / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + + (double)pViewport->uScreenCenterY); + cos((double)pIndoorCamera->sRotationX * 0.0030664064); + sin((double)pIndoorCamera->sRotationX * 0.0030664064); + array_77EC08[1999].Create_48607B(&stru_8019C8); + array_77EC08[1999].ptr_38->Inverse_sky_48694B(); + + if (pOutdoor->uSky_TextureID == -1) + { + array_77EC08[1999].pTexture = nullptr; + return; + } + else + array_77EC08[1999].pTexture = pBitmaps_LOD->GetTexture(pOutdoor->uSky_TextureID); + array_77EC08[1999].dimming_level = 0; + v11 = stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16); + array_77EC08[1999].v_18.y = 0; + array_77EC08[1999].v_18.x = -v11; + array_77EC08[1999].v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16); + LOWORD(v2) = 224 * LOWORD(pMiscTimer->uTotalGameTimeElapsed); + array_77EC08[1999].field_24 = 0x2000000u; + array_77EC08[1999].sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed; + array_77EC08[1999].sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; + if ( day_attrib & DAY_ATTRIB_FOG + && (LOWORD(v2) = LOWORD(pParty->uCurrentHour), pParty->uCurrentHour >= 5) + && pParty->uCurrentHour < 0x15 + || bUnderwater ) + { + v2 = (Polygon *)*(short *)PaletteManager::Get_Mist_or_Red_LUT(array_77EC08[1999].pTexture->palette_id2, 31, 1); + a1b = (unsigned int)v2; + if ( (signed int)v9 <= 0 ) + return; + v29 = v9; + while ( 1 ) + { + v30 = &pSpans[v29 - 1]; + v2 = (Polygon *)v30->field_E; + if ( v2 != (Polygon *)sr_6BE060[1] ) + { + LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); + if ( v30->field_8 >= (signed int)pViewport->uViewportTL_X ) + goto LABEL_124; + if ( v30->field_C == pViewport->uViewportTL_X ) + { + v30->field_E = LOWORD(sr_6BE060[1]); + } + else + { + v30->field_8 = LOWORD(pViewport->uViewportTL_X); + v30->field_C -= LOWORD(pViewport->uViewportTL_X); + if ( v30->field_C >= 0 ) + { +LABEL_124: + v31 = v30->field_C; + v30->pParent = &array_77EC08[1999]; + fill_pixels_fast( + a1b, + &pRenderer->pTargetSurface[v30->field_8 + pRenderer->uTargetSurfacePitch * v30->field_A], + v31); + j_memset32(-65536, &pRenderer->pActiveZBuffer[v30->field_8 + 640 * v30->field_A], v30->field_C); + goto LABEL_125; + } + LOWORD(v2) = LOWORD(sr_6BE060[1]); + v30->field_E = LOWORD(sr_6BE060[1]); + } + } +LABEL_125: + --v29; + --v9; + if ( !v9 ) + return; + } + } + if ( (signed int)v9 > 0 ) + { + v12 = v9; + do + { + v13 = &pSpans[v12 - 1]; + v2 = (Polygon *)v13->field_E; + if ( v2 != (Polygon *)sr_6BE060[1] ) + { + LOWORD(v2) = LOWORD(pViewport->uViewportTL_X); + if ( v13->field_8 >= (signed int)pViewport->uViewportTL_X ) + goto LABEL_109; + if ( v13->field_C != pViewport->uViewportTL_X ) + { + v13->field_8 = LOWORD(pViewport->uViewportTL_X); + v13->field_C -= LOWORD(pViewport->uViewportTL_X); + if ( v13->field_C >= 0 ) + { +LABEL_109: + if ( pOutdoorCamera->bNoSky ) + { + const_1_0(); + } + else + { + v13->pParent = &array_77EC08[1999]; + if ( !Render::DrawSkySW(v13, &array_77EC08[1999], a1a) ) + j_memset32(-65536, &pRenderer->pActiveZBuffer[v13->field_8 + 640 * v13->field_A], v13->field_C); + } + } + LOWORD(v2) = LOWORD(sr_6BE060[1]); + v13->field_E = LOWORD(sr_6BE060[1]); + goto LABEL_114; + } + v13->field_E = LOWORD(sr_6BE060[1]); + } +LABEL_114: + --v12; + --v9; + } + while ( v9 ); + } +} + +//----- (00485044) -------------------------------------------------------- +int Render::DrawSkySW(Span *a1, Polygon *a2, int a3) +{ + Polygon *v3; // esi@1 + Span *v4; // edi@1 + float v5; // ST2C_4@1 + signed int result; // eax@2 + int v7; // ST40_4@3 + stru149 *v8; // eax@3 + int v9; // ebx@3 + int v10; // ecx@3 + int v11; // edx@3 + int v12; // eax@3 + int v13; // ST28_4@5 + int v14; // eax@5 + signed __int64 v15; // qtt@11 + int v16; // ST28_4@11 + int v17; // eax@11 + signed int v18; // ecx@11 + int v19; // ST40_4@11 + int v20; // ST3C_4@11 + int v21; // ST30_4@11 + void *v22; // eax@11 + Texture *v23; // esi@11 + int v24; // ecx@11 + unsigned int v25; // esi@11 + int v26; // edi@11 + unsigned __int16 *v27; // eax@11 + int *v28; // ebx@12 + int v29; // edx@13 + unsigned __int16 v30; // cx@13 + int v31; // edx@14 + unsigned __int16 v32; // cx@14 + unsigned __int8 v33; // sf@15 + unsigned __int8 v34; // of@15 + double v35; // [sp+14h] [bp-38h]@1 + int v36; // [sp+18h] [bp-34h]@3 + signed int v37; // [sp+18h] [bp-34h]@11 + int v38; // [sp+1Ch] [bp-30h]@3 + signed int v39; // [sp+1Ch] [bp-30h]@11 + int v40; // [sp+20h] [bp-2Ch]@3 + void *v41; // [sp+20h] [bp-2Ch]@11 + int v42; // [sp+24h] [bp-28h]@3 + unsigned __int8 *v43; // [sp+24h] [bp-28h]@11 + int v44; // [sp+28h] [bp-24h]@11 + int v45; // [sp+2Ch] [bp-20h]@3 + signed int v46; // [sp+30h] [bp-1Ch]@3 + __int16 v47; // [sp+30h] [bp-1Ch]@11 + signed int v48; // [sp+34h] [bp-18h]@3 + int v49; // [sp+34h] [bp-18h]@11 + int v50; // [sp+38h] [bp-14h]@3 + unsigned __int16 *v51; // [sp+38h] [bp-14h]@11 + int v52; // [sp+3Ch] [bp-10h]@4 + int a1a; // [sp+40h] [bp-Ch]@3 + int v54; // [sp+44h] [bp-8h]@3 + int v55; // [sp+48h] [bp-4h]@3 + int v56; // [sp+54h] [bp+8h]@11 + int *v57; // [sp+54h] [bp+8h]@11 + + v3 = a2; + v4 = a1; + v5 = (double)(pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5 / tan(0.6457717418670654) + 0.5; + v35 = v5 + 6.7553994e15; + if ( LODWORD(v35) ) + { + v55 = 65536 / SLODWORD(v35); + v7 = 65536 / SLODWORD(v35) * (a3 - v4->field_A); + v8 = v3->ptr_38; + v42 = ((unsigned __int64)(v3->ptr_38->field_14 * (signed __int64)v7) >> 16) + v8->field_C; + v40 = ((unsigned __int64)(v8->field_20 * (signed __int64)v7) >> 16) + v3->ptr_38->field_18; + v38 = pOutdoorCamera->camera_rotation_y_int_sine; + HIDWORD(v35) = pOutdoorCamera->camera_rotation_y_int_cosine; + v45 = v4->field_C; + v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v7) >> 16) + v3->v_18.x; + v10 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); + v48 = 0; + v50 = 65536 / SLODWORD(v35) * (pViewport->uScreenCenterX - v4->field_8); + v46 = -v3->field_24; + v11 = v4->field_A - 1; + v54 = v11; + v12 = 65536 / SLODWORD(v35) * (a3 - v11); + a1a = 65536 / SLODWORD(v35) * (a3 - v11); + while ( 1 ) + { + v52 = v9; + if ( v9 ) + { + v13 = abs(v46 >> 14); + v14 = abs(v9); + v11 = v54; + v10 = v50; + if ( v13 <= v14 ) + break; + v12 = a1a; + } + if ( v11 <= (signed int)pViewport->uViewportTL_Y ) + break; + v9 = ((unsigned __int64)(v3->v_18.z * (signed __int64)v12) >> 16) + v3->v_18.x; + --v54; + a1a += v55; + v12 = a1a; + v11 = v54; + v48 = 1; + } + if ( v48 ) + v52 = ((unsigned __int64)(v3->v_18.z * (signed __int64)(v55 * (a3 + (signed int)v4->field_A - 2 * v11))) >> 16) + + v3->v_18.x; + LODWORD(v15) = v46 << 16; + HIDWORD(v15) = v46 >> 16; + v16 = v42 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v10) >> 16); + v17 = v40 + ((unsigned __int64)(v3->ptr_38->field_1C * (signed __int64)v10) >> 16); + v18 = v15 / v52; + v43 = v3->pTexture->pLevelOfDetail0_prolly_alpha_mask; + v19 = v3->sTextureDeltaU + ((signed int)((unsigned __int64)(v16 * v15 / v52) >> 16) >> 3); + v56 = v15 / v52; + v20 = v3->sTextureDeltaV + ((signed int)((unsigned __int64)(v17 * v15 / v52) >> 16) >> 3); + v21 = (unsigned __int64)(v55 * (signed __int64)v56) >> 16; + v39 = (signed int)((unsigned __int64)(v21 * (signed __int64)v38) >> 16) >> 3; + v37 = (signed int)((unsigned __int64)(v21 * (signed __int64)v36) >> 16) >> 3; + v22 = sr_sub_47C178(v18, v3, 0, 1); + v23 = v3->pTexture; + v41 = v22; + v47 = 16 - v23->uWidthLn2; + v44 = v23->uTextureWidth - 1; + v49 = (v23->uTextureHeight << 16) - 65536; + v24 = v4->field_8; + v51 = &pRenderer->pTargetSurface[v24 + pRenderer->uTargetSurfacePitch * v4->field_A]; + v57 = &pRenderer->pActiveZBuffer[v24 + 640 * v4->field_A]; + v25 = v19; + v26 = v20; + v27 = v51; + if ( !(v45 & 1) ) + goto LABEL_15; + --v45; + v27 = v51 - 1; + v28 = v57; + ++v57; + while ( 1 ) + { + *v28 = -65536; + v31 = v44 & (v25 >> 16); + v27 += 2; + v25 += v39; + v32 = *((short *)v41 + *(&v43[v31] + ((v49 & (unsigned int)v26) >> v47))); + v26 += v37; + *(v27 - 1) = v32; +LABEL_15: + v34 = __OFSUB__(v45, 2); + v33 = v45 - 2 < 0; + v45 -= 2; + if ( v33 ^ v34 ) + break; + v29 = v44 & (v25 >> 16); + v25 += v39; + v30 = *((short *)v41 + *(&v43[v29] + ((v49 & (unsigned int)v26) >> v47))); + v26 += v37; + v28 = v57; + *v27 = v30; + v57 += 2; + v28[1] = -65536; + } + result = 1; + } + else + { + result = 0; + } + return result; +} + +//----- (0047F5C6) -------------------------------------------------------- +float Render::DrawBezierTerrain() +{ + unsigned int pDirectionIndicator1; // ebx@1 + unsigned int pDirectionIndicator2; // edi@1 + unsigned int v2; // eax@1 + int v3; // eax@3 + int v4; // edi@3 + int v5; // ebx@3 + int v6; // esi@3 + unsigned int v7; // eax@3 + int v8; // eax@4 + unsigned int v9; // eax@6 + int v10; // eax@7 + //int v11; // ebx@9 + //int v12; // edi@9 + int v13; // eax@21 + int v14; // eax@31 + int v15; // edi@33 + int v16; // eax@34 + int v17; // edx@34 + int v18; // ebx@34 + int v19; // eax@36 + int v20; // eax@39 + int v21; // ecx@43 + //char v22; // zf@44 + int v23; // ecx@47 + //int v24; // edi@52 + int v25; // eax@54 + int v26; // ecx@54 + int v27; // eax@56 + int v28; // edx@60 + int v29; // ecx@61 + int v30; // ecx@64 + int v31; // ecx@68 + int v32; // eax@70 + //int v33; // ecx@71 + int v34; // eax@73 + int v35; // ecx@77 + int v36; // ecx@81 + int v37; // ecx@86 + int v38; // eax@88 + int v39; // ecx@88 + int v40; // eax@90 + int v41; // edx@94 + //int v42; // ecx@95 + int v43; // ecx@98 + int v44; // ecx@102 + int v45; // eax@104 + int v46; // eax@107 + int v47; // ecx@111 + int v48; // ecx@115 + int v49; // edi@120 + int v50; // eax@122 + int v51; // ecx@122 + int v52; // eax@124 + int v53; // edx@128 + int v54; // ecx@129 + int v55; // ecx@132 + int v56; // eax@139 + int v57; // ecx@140 + int v58; // eax@142 + int v59; // ecx@146 + //int v60; // ecx@147 + int v61; // ecx@150 + int v62; // ecx@155 + int v63; // eax@157 + int v64; // ecx@157 + int v65; // eax@159 + int v66; // edx@163 + int v67; // ecx@164 + int v68; // ecx@167 + //int v69; // eax@173 + int v70; // edi@178 + //int v71; // eax@178 + //int v72; // ecx@178 + //int x; // ebx@180 + //int v74; // eax@182 + //int v75; // eax@184 + IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 + int uStartZ; // ecx@184 + int v79; // ebx@185 + int v127; // esi@185 + int v86; // edi@196 + //int v87; // eax@196 + //int v88; // ecx@196 + //int v89; // eax@198 + //int v90; // ecx@200 + int v92; // ebx@203 + //int v93; // ST08_4@204 + int v97; // ST08_4@204 + float result; // eax@212 + //struct + //{ + int v106; // [sp+Ch] [bp-68h]@191 + int v103; // [sp+10h] [bp-64h]@190 + int v104; // [sp+12h] [bp-62h]@190 + //} v102; + int v105; // [sp+1Ch] [bp-58h]@1 + int v107; // [sp+20h] [bp-54h]@3 + int uEndZ; // [sp+24h] [bp-50h]@3 + int v108; // [sp+28h] [bp-4Ch]@9 + int v109; // [sp+2Ch] [bp-48h]@9 + int v110; // [sp+30h] [bp-44h]@9 + int v111; // [sp+34h] [bp-40h]@3 + int v112; // [sp+38h] [bp-3Ch]@6 + IndoorCameraD3D *pIndoorCameraD3D_4; // [sp+3Ch] [bp-38h]@9 + int v114; // [sp+40h] [bp-34h]@9 + int v115; // [sp+44h] [bp-30h]@9 + int v116; // [sp+48h] [bp-2Ch]@9 + //int v117; // [sp+4Ch] [bp-28h]@9 + int v118; // [sp+50h] [bp-24h]@9 + int v119; // [sp+54h] [bp-20h]@1 + int v120; // [sp+58h] [bp-1Ch]@1 + int i; // [sp+5Ch] [bp-18h]@1 + int v122; // [sp+60h] [bp-14h]@1 + int v123; // [sp+64h] [bp-10h]@1 + int v124; // [sp+68h] [bp-Ch]@1 + int v125; // [sp+6Ch] [bp-8h]@9 + int v126; // [sp+70h] [bp-4h]@9 + + v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2);//2 + pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 + pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 + v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->Cos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16;//88 + v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->Sin(pDirectionIndicator2)) >> 16;// 66 + v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X + v119 = pOutdoorCamera->outdoor_grid_band_3 + v123; + v2 = pOutdoorCamera->uCameraFovInDegrees + 15;//90 + i = v124 - pOutdoorCamera->outdoor_grid_band_3; + v122 = v123 - pOutdoorCamera->outdoor_grid_band_3; + + if ( v2 > 90 ) + v2 = 90; + v3 = (v2 << 11) / 720; + v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3); + v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1); + + v106 = stru_5C6E00->Cos(v4); + uEndZ = stru_5C6E00->Sin(v4); + + v111 = stru_5C6E00->Cos(v5); + v6 = stru_5C6E00->Sin(v5); + + v7 = v4 & stru_5C6E00->uPiMask; + if ( (v4 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) + v8 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v7]; + else + v8 = stru_5C6E00->pTanTable[v7]; + v112 = abs(v8); + + v9 = v5 & stru_5C6E00->uPiMask; + if ( (v5 & stru_5C6E00->uPiMask) >= stru_5C6E00->uIntegerHalfPi ) + v10 = -stru_5C6E00->pTanTable[stru_5C6E00->uIntegerPi - v9]; + else + v10 = stru_5C6E00->pTanTable[v9]; + v108 = abs(v10); + + //v11 = v124; + //v12 = v123; + v114 = 0; + v115 = 0; + pIndoorCameraD3D_4 = 0; + v125 = 0; + v126 = v124; + v118 = v123; + + v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; + v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; + uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; + v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; + + uint _i = 1; + uint j = 1; + + terrain_76DDC8[0] = -1; + terrain_76DFC8[0] = -1; + terrain_76E1C8[0] = -1; + terrain_76E3C8[0] = -1; + + for( uint _i = 1; _i < 128; _i++) + { + if ( v112 >= 0x10000 ) + { + int v1, v2; + //v111 = 4294967296i64 / v112; + //v114 += v111; + //if ( v114 >= 65536 ) + //{ + // v11 += v110; + // v114 = (unsigned __int16)v114; + //} + //v12 += v109; + } + else + { + v124 += v110; + v115 += v112; + if ( v112 + v115 >= 65536 ) + { + v123 += v109; + v115 = (unsigned __int16)v115; + } + } + if ( v124 < _i || v124 > v120 || v123 < v122 || v123 > v119 ) + break; + //v13 = v116++; + terrain_76E3C8[_i] = v124; + terrain_76E1C8[_i] = v123; + } + + for( j = 1; j < 128; j++ ) + { + if ( v108 >= 65536 ) + { + v111 = 4294967296i64 / v108; + v114 += v111;// + if ( v111 + v114 >= 65536 ) + { + v126 += uEndZ; + v114 = (unsigned __int16)v114;// + } + v118 += v106; + } + else + { + v125 += v108; + v126 += uEndZ; + if ( v125 >= 65536 ) + { + v118 += v106; + v125 = (unsigned __int16)v125; + } + } + //if ( v117 >= 128 ) + //break; + if ( v126 < _i ) + break; + if ( v126 > v120 ) + break; + v14 = v118; + if ( v118 < v122 ) + break; + if ( v118 > v119 ) + break; + terrain_76DFC8[j] = v126; + terrain_76DDC8[j] = v14; + } + v16 = 0; + v126 = 0; + v17 = j - 1; + v18 = _i - 1; + + switch ( v105 ) + { + case 0: + case 7: + { + //v116 = terrain_76DFC8[v17]; + if ( v120 > terrain_76DFC8[v17] ) + { + v125 = v120; + memset32(terrain_76D9C8.data(), v119 + 1, 4 * (v120 - terrain_76DFC8[v17] + 1)); + v19 = v120; + do + terrain_76DBC8[v126++] = v19--; + while ( v19 >= terrain_76DFC8[v17] ); + if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 + 127] ) + { + do + v20 = terrain_76DDC8[v17-- -1]; + while ( v20 == terrain_76DDC8[v17 -1] ); + } + v16 = v126; + --v17; + } + if ( v17 < 0 ) + v17 = 0; + v21 = terrain_76DFC8[v17]; + while ( 1 ) + { + v125 = terrain_76DFC8[v17]; + if ( v21 < v124 ) + break; + terrain_76DBC8[v16] = v21; + //v22 = terrain_76DDC8[v17] == 65535; + terrain_76D9C8[v16] = terrain_76DDC8[v17] + 1; + if ( terrain_76DDC8[v17] == 65535 ) + { + terrain_76D9C8[v16] = v123 + 1; + break; + } + if ( !v17 ) + break; + if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 - 1] ) + { + do + v23 = terrain_76DDC8[v17-- -1]; + while ( v23 == terrain_76DDC8[v17 -1] ); + } + --v17; + v21 = v125 - 1; + ++v16; + } + v16 = 0; + //v24 = terrain_76E3C8[v18]; + v126 = 0; + if ( v120 > terrain_76E3C8[v18] ) + { + v125 = v120; + memset32(terrain_76D5C8.data(), v122, 4 * (v120 - terrain_76E3C8[v18] + 1)); + do + { + v25 = v126; + v26 = v125--; + ++v126; + terrain_76D7C8[v25] = v26; + } + while ( v125 >= terrain_76E3C8[v18] ); + if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) + { + do + v27 = terrain_76E1C8[v18-- -1]; + while ( v27 == terrain_76E1C8[v18 -1] ); + } + v16 = v126; + --v18; + } + if ( v18 < 0 ) + v18 = 0; + v28 = terrain_76E3C8[v18]; + while ( v28 >= v124 ) + { + v29 = terrain_76E1C8[v18]; + terrain_76D7C8[v16] = v28; + terrain_76D5C8[v16] = v29; + if ( v29 == 65535 ) + { + v31 = v123; + terrain_76D5C8[v16] = v31; + break; + } + if ( !v18 ) + break; + if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) + { + do + v30 = terrain_76E1C8[v18-- -1]; + while ( v30 == terrain_76E1C8[v18 -1] ); + } + --v18; + --v28; + ++v16; + } + break; + } + case 1: + case 2: + { + //v116 = terrain_76DDC8[v17]; + if ( v122 < terrain_76DDC8[v17] ) + { + v106 = v122; + memset32(terrain_76DBC8.data(), v120 + 1, 4 * (terrain_76DDC8[v17] - v122 + 1)); + for ( v32 = v122; v32 <= terrain_76DDC8[v17]; v32++) + terrain_76D9C8[v126++] = v32; + if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) + { + do + v34 = terrain_76DBC8[v17-- -1]; + while ( v34 == terrain_76DBC8[v17 -1] ); + } + v16 = v126; + --v17; + } + if ( v17 < 0 ) + v17 = 0; + v35 = terrain_76DDC8[v17]; + v125 = terrain_76DDC8[v17]; + while ( v35 <= v123 ) + { + //v22 = terrain_76DFC8[v17] == 65535; + terrain_76DBC8[v16] = terrain_76DFC8[v17] + 1; + terrain_76D9C8[v16] = v125; + if ( terrain_76DFC8[v17] == 65535 ) + { + terrain_76DBC8[v16] = v124 + 1; + break; + } + if ( !v17 ) + break; + if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) + { + do + v36 = terrain_76DBC8[v17-- -1]; + while ( v36 == terrain_76DBC8[v17 -1] ); + } + --v17; + ++v125; + v35 = v125; + ++v16; + } + v16 = 0; + v126 = 0; + v37 = terrain_76E1C8[v18]; + if ( v122 < v37 ) + { + v114 = v122; + memset32(terrain_76D7C8.data(), i, 4 * (v37 - v122 + 1)); + do + { + v38 = v126; + v39 = v114; + ++v126; + ++v114; + terrain_76D5C8[v38] = v39; + } + while ( v114 <= terrain_76E1C8[v18] ); + if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) + { + do + v40 = terrain_76DFC8[v18-- -1]; + while ( v40 == terrain_76DFC8[v18 -1] ); + } + v16 = v126; + --v18; + } + if ( v18 < 0 ) + v18 = 0; + v41 = terrain_76E1C8[v18]; + while ( v41 <= v123 ) + { + terrain_76D5C8[v16] = v41; + terrain_76D7C8[v16] = terrain_76E3C8[v18]; + if ( terrain_76E3C8[v18] == 65535 ) + { + terrain_76D7C8[v16] = v124; + break; + } + if ( !v18 ) + break; + if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) + { + do + v43 = terrain_76DFC8[v18-- -1]; + while ( v43 == terrain_76DFC8[v18 -1] ); + } + --v18; + ++v41; + ++v16; + } + break; + } + case 5: + case 6: + { + //v116 = terrain_76DDC8[v17]; + if ( v119 > terrain_76DDC8[v17] ) + { + v106 = v119; + memset32(terrain_76DBC8.data(), i, 4 * (v119 - terrain_76DDC8[v17] + 1)); + for ( v45 = v119; v45 >= terrain_76DDC8[v17]; v45--) + terrain_76D9C8[v126++] = v45; + if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) + { + do + v46 = terrain_76DBC8[v17-- -1]; + while ( v46 == terrain_76DBC8[v17 -1] ); + } + v16 = v126; + --v17; + } + if ( v17 < 0 ) + v17 = 0; + v47 = terrain_76DDC8[v17]; + v125 = terrain_76DDC8[v17]; + while ( v47 >= v123 ) + { + //v22 = terrain_76DFC8[v17] == 65535; + terrain_76DBC8[v16] = terrain_76DFC8[v17]; + terrain_76D9C8[v16] = v125; + if ( terrain_76DFC8[v17] == 65535 ) + { + terrain_76DBC8[v16] = v124; + break; + } + if ( !v17 ) + break; + if ( terrain_76DDC8[v17] == terrain_76DBC8[v17 -1] ) + { + do + v48 = terrain_76DBC8[v17-- -1]; + while ( v48 == terrain_76DBC8[v17 -1] ); + } + --v17; + --v125; + v47 = v125; + ++v16; + } + v16 = 0; + v49 = terrain_76E1C8[v18]; + v126 = 0; + if ( v119 > v49 ) + { + v125 = v119; + memset32(terrain_76D7C8.data(), v120 + 1, 4 * (v119 - v49 + 1)); + do + { + v50 = v126; + v51 = v125--; + ++v126; + terrain_76D5C8[v50] = v51; + } + while ( v125 >= terrain_76E1C8[v18] ); + if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) + { + do + v52 = terrain_76DFC8[v18-- -1]; + while ( v52 == terrain_76DFC8[v18 -1] ); + } + v16 = v126; + --v18; + } + if ( v18 < 0 ) + v18 = 0; + v53 = terrain_76E1C8[v18]; + while ( v53 >= v123 ) + { + v54 = terrain_76E3C8[v18]; + terrain_76D5C8[v16] = v53; + terrain_76D7C8[v16] = v54 + 1; + if ( v54 == 65535 ) + { + terrain_76D7C8[v16] = v124 + 1; + break; + } + if ( !v18 ) + break; + if ( terrain_76E1C8[v18] == terrain_76DFC8[v18 -1] ) + { + do + v55 = terrain_76DFC8[v18-- -1]; + while ( v55 == terrain_76DFC8[v18 -1] ); + } + --v18; + --v53; + ++v16; + } + break; + } + case 3: + case 4: + { + //v116 = terrain_76DFC8[v17]; + if ( i < terrain_76DFC8[v17] ) + { + v106 = i; + memset32(terrain_76D9C8.data(), v122, 4 * (terrain_76DFC8[v17] - i + 1)); + v56 = i; + do + { + v57 = v126++; + terrain_76DBC8[v57] = v56++; + } + while ( v56 <= terrain_76DFC8[v17] ); + if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) + { + do + v58 = terrain_76DDC8[v17-- -1]; + while ( v58 == terrain_76DDC8[v17 -1] ); + } + v16 = v126; + --v17; + } + if ( v17 < 0 ) + v17 = 0; + v59 = terrain_76DFC8[v17]; + while ( 1 ) + { + v125 = v59; + if ( v59 > v124 ) + break; + terrain_76DBC8[v16] = v59; + //v60 = terrain_76DDC8[v17]; + terrain_76D9C8[v16] = terrain_76DDC8[v17]; + if ( terrain_76DDC8[v17] == 65535 ) + { + terrain_76D9C8[v16] = v123; + break; + } + if ( !v17 ) + break; + if ( terrain_76DFC8[v17] == terrain_76DDC8[v17 -1] ) + { + do + v61 = terrain_76DDC8[v17-- -1]; + while ( v61 == terrain_76DDC8[v17 -1] ); + } + --v17; + v59 = v125 + 1; + ++v16; + } + v16 = 0; + v126 = 0; + v62 = terrain_76E3C8[v18]; + if ( i < v62 ) + { + v114 = i; + memset32(terrain_76D5C8.data(), v119 + 1, 4 * (v62 - i + 1)); + do + { + v63 = v126; + v64 = v114; + ++v126; + ++v114; + terrain_76D7C8[v63] = v64; + } + while ( v114 <= terrain_76E3C8[v18] ); + if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) + { + do + v65 = terrain_76E1C8[v18-- -1]; + while ( v65 == terrain_76E1C8[v18 -1] ); + } + v16 = v126; + --v18; + } + if ( v18 < 0 ) + v18 = 0; + v66 = terrain_76E3C8[v18]; + while ( v66 <= v124 ) + { + v67 = terrain_76E1C8[v18]; + terrain_76D7C8[v16] = v66; + terrain_76D5C8[v16] = v67 + 1; + if ( terrain_76E1C8[v18] == 65535 ) + { + v31 = v123 + 1; + terrain_76D5C8[v16] = v31; + break; + } + if ( !v18 ) + break; + if ( terrain_76E3C8[v18] == terrain_76E1C8[v18 -1] ) + { + do + v68 = terrain_76E1C8[v18-- -1]; + while ( v68 == terrain_76E1C8[v18 -1] ); + } + --v18; + ++v66; + ++v16; + } + break; + } + default: + break; + } + //v69 = v16 - 1; + ptr_801A08 = pVerticesSR_806210; + ptr_801A04 = pVerticesSR_801A10; + //v126 = v69; + + if ( v105 && v105 != 7 && v105 != 3 && v105 != 4 )//блок + { + for ( i = v16 - 1; i >= 1; --i ) + { + //v70 = i; + //v71 = terrain_76D7C8[i];//88 + //v72 = terrain_76DBC8[i];//0 + if ( terrain_76D7C8[i] < terrain_76DBC8[i] )//swap + { + terrain_76DBC8[i] = terrain_76D7C8[i]; + terrain_76D7C8[i] = terrain_76DBC8[i]; + } + //x = terrain_76DBC8[i];//0 + v111 = 0; + if ( terrain_76DBC8[i] <= 0 ) + terrain_76DBC8[i] = -terrain_76DBC8[i]; + //v74 = terrain_76D7C8[i]; + if ( terrain_76D7C8[i] <= 0 ) + terrain_76D7C8[i] = -terrain_76D7C8[i]; + uEndZ = terrain_76D7C8[i] + 2; + //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; + //uEndZ = v75; + //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; + uStartZ = terrain_76DBC8[i] - 2; + if ( terrain_76DBC8[i] - 2 < uEndZ ) + { + v127 = 0; + //v79 = (v73 - 66) << 9; + //v116 = v77; + //pHeight = v79; + v111 = uEndZ - uStartZ; + for (int z = uStartZ; z < uEndZ; ++z) + { + ptr_801A08[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512;//pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; + ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; + ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); + + ptr_801A04[v127].vWorldPosition.x = (-64 + terrain_76DBC8[i]) * 512; + ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; + ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); + + if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) + { + pIndoorCameraD3D_4->ViewTransform(&ptr_801A08[v127], 1); + pIndoorCameraD3D_4->ViewTransform(&ptr_801A04[v127], 1); + + pIndoorCameraD3D_4->Project(&ptr_801A08[v127], 1, 0); + pIndoorCameraD3D_4->Project(&ptr_801A04[v127], 1, 0); + } + //v79 += 512; + v127 ++; + //++v116; + //pHeight = v79; + } + //while ( v116 < v107 ); + } + v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); + v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); + if ( pRenderer->pRenderD3D )//Ritor1: do comment to test + Render::DrawTerrainD3D(v111, 0, v103, v104); + //Render::RenderTerrainD3D(); + else + Render::DrawTerrainSW(v111, 0, v103, v104); + } + } + else + { + for ( i = v16 - 1; i >= 1; --i ) + { + //v86 = i; + //v87 = terrain_76D5C8[i]; + //v88 = terrain_76D9C8[i]; + if ( terrain_76D5C8[i] < terrain_76D9C8[i] ) + { + terrain_76D9C8[i] = terrain_76D5C8[i]; + terrain_76D5C8[i] = terrain_76D9C8[i]; + } + //v89 = terrain_76D9C8[i]; + v111 = 0; + if ( terrain_76D9C8[i] <= 0 ) + terrain_76D9C8[i] = -terrain_76D9C8[i]; + //v90 = terrain_76D5C8[i]; + if ( terrain_76D5C8[i] <= 0 ) + terrain_76D5C8[i] = -terrain_76D5C8[i]; + pIndoorCameraD3D_4 = pGame->pIndoorCameraD3D; + v107 = terrain_76D5C8[i] + 2; + if ( terrain_76D9C8[i] - 2 < terrain_76D5C8[i] + 2 ) + { + v86 = 0; + //v116 = terrain_76D9C8[i] - 2; + v92 = (66 - terrain_76D9C8[i]) << 9; + //pHeight = (66 - terrain_76D9C8[i]) << 9; + v111 = terrain_76D5C8[i] + 2 - (terrain_76D9C8[i] - 2); + //do + for ( v116 = terrain_76D9C8[i] - 2; v116 < v107; ++v116 ) + { + ptr_801A08[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 64) << 9; + ptr_801A08[v86].vWorldPosition.y = v92; + ptr_801A08[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86], v116); + + ptr_801A04[v86].vWorldPosition.x = (terrain_76DBC8[v86] - 63) << 9; + ptr_801A04[v86].vWorldPosition.y = v92; + ptr_801A04[v86].vWorldPosition.z = pOutdoor->GetHeightOnTerrain(terrain_76DBC8[v86] + 1, v116); + if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) + { + pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1); + pIndoorCameraD3D_4->ViewTransform((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1); + pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A08 + v86, 1, 0); + pIndoorCameraD3D_4->Project((RenderVertexSoft *)(char *)ptr_801A04 + v86, 1, 0); + } + v92 -= 512; + v86 += 48; + //++v116; + //pHeight = v92; + } + //while ( v116 < v107 ); + } + v103 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[v86]); + v104 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[v86]); + if ( pRenderer->pRenderD3D ) + Render::DrawTerrainD3D(v111, 1, v103, v104); + else + Render::DrawTerrainSW(v111, 1, v103, v104); + } + } + result = v126; + pOutdoorCamera->field_40 = v126; + return result; +} +//----- (00482E07) -------------------------------------------------------- +signed int __fastcall sr_sub_482E07(Span *ecx0, unsigned __int16 *pRenderTarget) +{ + stru315 *v2; // ebp@0 + Polygon *v3; // esi@1 + int v4; // edi@1 + int v5; // edi@1 + stru149 *v6; // eax@1 + stru149 *v7; // eax@1 + int v8; // edx@1 + int v9; // eax@1 + int v10; // edi@1 + int v11; // eax@1 + unsigned __int64 v12; // qax@1 + int v13; // eax@1 + signed __int64 v14; // qtt@3 + int v15; // ebx@4 + signed __int64 v16; // qtt@5 + int v17; // eax@5 + unsigned __int16 *v18; // eax@7 + Texture *v19; // eax@8 + Texture *v20; // eax@10 + Texture *v21; // eax@12 + Texture *v22; // eax@14 + int v23; // ecx@17 + Texture *v24; // ebx@17 + signed int v25; // edx@17 + signed int v26; // eax@17 + char v27; // bl@17 + stru149 *v28; // eax@18 + stru149 *v29; // eax@18 + int v30; // eax@18 + int v31; // eax@18 + unsigned int v32; // edx@18 + int v33; // edi@21 + signed __int64 v34; // qtt@22 + signed int v35; // ecx@22 + int v36; // eax@24 + stru149 *v37; // eax@24 + int v38; // edi@24 + int v39; // eax@24 + int v40; // edi@35 + signed __int64 v41; // qtt@36 + int v42; // edx@36 + stru149 *v43; // eax@36 + int v44; // edi@36 + int v45; // eax@36 + Span *v46; // edi@44 + stru149 *v47; // eax@44 + stru149 *v48; // eax@44 + int v49; // eax@44 + int v50; // ecx@44 + unsigned int v51; // edx@44 + int v52; // edi@46 + signed __int64 v53; // qtt@47 + unsigned int v54; // ecx@47 + int v55; // eax@49 + stru149 *v56; // eax@49 + int v57; // edi@49 + int v58; // eax@49 + int v59; // edi@60 + signed __int64 v60; // qtt@61 + int v61; // edx@61 + stru149 *v62; // eax@61 + int v63; // edi@61 + int v64; // eax@61 + int v66; // [sp+Ch] [bp-B8h]@1 + int v67; // [sp+10h] [bp-B4h]@1 + int v68; // [sp+14h] [bp-B0h]@1 + int v69; // [sp+18h] [bp-ACh]@1 + int v70; // [sp+1Ch] [bp-A8h]@5 + int v71; // [sp+20h] [bp-A4h]@1 + signed int v72; // [sp+24h] [bp-A0h]@1 + stru316 a2; // [sp+28h] [bp-9Ch]@18 + int v74; // [sp+50h] [bp-74h]@17 + stru315 a1; // [sp+54h] [bp-70h]@5 + Span *v76; // [sp+98h] [bp-2Ch]@1 + unsigned __int16 *v77; // [sp+9Ch] [bp-28h]@1 + int v78; // [sp+A0h] [bp-24h]@17 + int v79; // [sp+A4h] [bp-20h]@3 + int v80; // [sp+A8h] [bp-1Ch]@3 + int v81; // [sp+ACh] [bp-18h]@1 + int X; // [sp+B0h] [bp-14h]@2 + int v83; // [sp+B4h] [bp-10h]@1 + int v84; // [sp+B8h] [bp-Ch]@1 + int v85; // [sp+BCh] [bp-8h]@1 + int v86; // [sp+C0h] [bp-4h]@18 + + v85 = ecx0->field_C; + v3 = ecx0->pParent; + v4 = pViewport->uScreenCenterY - ecx0->field_A; + v77 = pRenderTarget; + v5 = pOutdoorCamera->int_fov_rad_inv * v4; + v6 = v3->ptr_38; + v76 = ecx0; + v81 = v5; + v83 = v6->field_14; + v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16; + v7 = v3->ptr_38; + v8 = v81 + v7->field_C; + v83 = v7->field_20; + v67 = v8; + v9 = ((unsigned __int64)(v83 * (signed __int64)v5) >> 16) + v3->ptr_38->field_18; + v81 = v5; + v71 = v9; + v83 = v3->v_18.z; + v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16; + v68 = v3->sTextureDeltaU << 16; + v69 = v3->sTextureDeltaV << 16; + v72 = -v3->field_24; + v10 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - ecx0->field_8); + v11 = v3->v_18.y; + v66 = v81 + v3->v_18.x; + v83 = v10; + v12 = v10 * (signed __int64)v11; + v81 = v12 >> 16; + v13 = v66 + (v12 >> 16); + v84 = v13; + if ( !v13 + || (X = v72 >> 15, v83 = abs(v13), abs(v72 >> 15) >= v83) + || (LODWORD(v14) = v72 << 16, + HIDWORD(v14) = v72 >> 16, + v79 = v14 / v84, + v80 = v10 - v85 * pOutdoorCamera->int_fov_rad_inv, + v81 = (unsigned __int64)(v80 * (signed __int64)v3->v_18.y) >> 16, + (v84 = v66 + v81) == 0) + || (v15 = abs(v66 + v81), abs(X) >= v15) ) + return 0; + LODWORD(v16) = v72 << 16; + HIDWORD(v16) = v72 >> 16; + v70 = v16 / v84; + v17 = v16 / v84; + a1.field_24 = v79; + if ( v79 >= v17 ) + a1.field_24 = v17; + v18 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; + a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; + v84 = 2; + if ( a1.field_24 >= mipmapping_building_mm1 << 16 ) + { + if ( a1.field_24 >= mipmapping_building_mm2 << 16 ) + { + if ( a1.field_24 >= mipmapping_building_mm3 << 16 ) + { + if ( bUseLoResSprites ) + goto LABEL_16; + v22 = v3->pTexture; + v84 = 3; + v18 = (unsigned __int16 *)v22->pLevelOfDetail3; + } + else + { + v21 = v3->pTexture; + v84 = 2; + v18 = (unsigned __int16 *)v21->pLevelOfDetail2; + } + } + else + { + v20 = v3->pTexture; + v84 = 1; + v18 = (unsigned __int16 *)v20->pLevelOfDetail1; + } + } + else + { + v19 = v3->pTexture; + v84 = 0; + v18 = (unsigned __int16 *)v19->pLevelOfDetail0_prolly_alpha_mask; + } + a1.pTextureLOD = v18; +LABEL_16: + if ( v18 ) + { + v23 = v3->field_5A; + v83 = v3->field_52; + v24 = v3->pTexture; + v74 = v23; + v78 = v85 >> v23; + v25 = v24->uTextureWidth; + v81 = v85 - (v85 >> v23 << v23); + v26 = (signed int)v24->uTextureHeight >> v84; + a1.field_10 = v84 - v24->uWidthLn2 + 16; + v27 = v84 + bUseLoResSprites; + a1.field_8 = (v26 << 16) - 65536; + a1.field_C = (v25 >> v84) - 1; + if ( v79 >= v70 ) + { + v46 = v76; + a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v70, v3, pOutdoorCamera->building_gamme, 0, 1); + v47 = v3->ptr_38; + v79 = v80; + v86 = v47->field_10; + v79 = v80; + v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16); + v86 = v3->ptr_38->field_1C; + v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16); + v79 = (unsigned __int64)(v84 * (signed __int64)v70) >> 16; + v48 = v3->ptr_38; + v79 = v70; + a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v70) >> 16) - v48->field_24; + v79 = (unsigned __int64)(v86 * (signed __int64)v70) >> 16; + v49 = ((unsigned __int64)(v86 * (signed __int64)v70) >> 16) - v3->ptr_38->field_28; + a1.field_30 >>= v27; + a1.field_2C = (v69 + v49) >> v27; + a1.field_14 = dword_80AA20 >> v27; + a1.field_18 = dword_80AA1C >> v27; + a1.field_1C = dword_80AA18 >> v27; + v50 = v46->field_8; + a1.field_20 = dword_80AA14 >> v27; + v51 = v50 + pRenderer->uTargetSurfacePitch * v46->field_A; + a1.pDepthBuffer = (unsigned int *)(&pRenderer->pActiveZBuffer[640 * v46->field_A - 1] + v85 + v50); + a1.pColorBuffer = &v77[v85 - 1] + v51; + v80 += pOutdoorCamera->int_fov_rad_inv << v74; + if ( v78 > 0 ) + { + do + { + v77 = (unsigned __int16 *)v3->v_18.y; + v86 = (unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16; + v84 = v66 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16); + if ( v66 + (unsigned int)((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16) + && (v52 = abs((signed __int64)v66 + ((__int64)((signed int)v77 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v52) ) + { + LODWORD(v53) = v72 << 16; + HIDWORD(v53) = v72 >> 16; + v86 = v53 / v84; + v54 = v53 / v84; + v84 = v53 / v84; + } + else + { + v84 = 0x40000000u; + v54 = 0x40000000u; + } + HIWORD(v55) = HIWORD(v54); + LOWORD(v55) = 0; + a1.field_24 = v3->field_50 | v55; + v77 = (unsigned __int16 *)v3->ptr_38->field_10; + v77 = (unsigned __int16 *)(v67 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16)); + v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16; + v56 = v3->ptr_38; + v57 = ((unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16) - v56->field_24; + v77 = (unsigned __int16 *)v56->field_1C; + v77 = (unsigned __int16 *)(v71 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16)); + v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16; + v58 = (((v69 + v86 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74; + a1.field_4 = (((v68 + v57) >> v27) - a1.field_30) >> v74; + a1.field_0 = v58; + a1.field_28 = v83; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + { + if ( v3->pODMFace->uPolygonType == 1 ) + sr_sub_485BAE(&a1, &a2); + else + sr_sub_485AFF(&a1, &a2); + } + else + { + if ( v3->pODMFace->uPolygonType == 1 ) + sr_sub_4D71F8(&a1); + else + sr_sub_4D714C(&a1); + } + a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F( + &a2, + v76, + v84, + v3, + pOutdoorCamera->building_gamme, + 0, + 0); + v80 += pOutdoorCamera->int_fov_rad_inv << v74; + --v78; + } + while ( v78 ); + } + if ( !v81 ) + return 1; + v83 = v3->v_18.y; + v86 = (unsigned __int64)(v83 * (signed __int64)v80) >> 16; + v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); + if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) ) + { + v59 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16)); + if ( abs(X) < v59 ) + { + LODWORD(v60) = v72 << 16; + HIDWORD(v60) = v72 >> 16; + v86 = v60 / v84; + HIWORD(v61) = (unsigned int)(v60 / v84) >> 16; + LOWORD(v61) = 0; + a1.field_24 = v61 | v3->field_50; + v83 = v3->ptr_38->field_10; + v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); + v86 = (unsigned __int64)(v83 * v60 / v84) >> 16; + v62 = v3->ptr_38; + v63 = ((unsigned __int64)(v83 * v60 / v84) >> 16) - v62->field_24; + v83 = v62->field_1C; + v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); + v86 = (unsigned __int64)(v83 * v60 / v84) >> 16; + v64 = (((signed int)(v69 + ((unsigned __int64)(v83 * v60 / v84) >> 16) - v3->ptr_38->field_28) >> v27) + - a1.field_2C) >> v74; + a1.field_4 = (((v68 + v63) >> v27) - a1.field_30) >> v74; + a1.field_0 = v64; + a1.field_28 = v81; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + { + if ( v3->pODMFace->uPolygonType == 1 ) + sr_sub_485BAE(&a1, &a2); + else + sr_sub_485AFF(&a1, &a2); + } + else + { + if ( v3->pODMFace->uPolygonType == 1 ) + sr_sub_4D71F8(&a1); + else + sr_sub_4D714C(&a1); + } + return 1; + } + } + } + else + { + a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v79, v3, pOutdoorCamera->building_gamme, 1u, 1); + v28 = v3->ptr_38; + v85 = v10; + v86 = v28->field_10; + v85 = v10; + v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16); + v86 = v3->ptr_38->field_1C; + v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16); + v85 = (unsigned __int64)(v84 * (signed __int64)v79) >> 16; + v29 = v3->ptr_38; + v85 = v79; + a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v79) >> 16) - v29->field_24; + v85 = (unsigned __int64)(v86 * (signed __int64)v79) >> 16; + v30 = ((unsigned __int64)(v86 * (signed __int64)v79) >> 16) - v3->ptr_38->field_28; + a1.field_30 >>= v27; + a1.field_2C = (v69 + v30) >> v27; + a1.field_14 = dword_80AA20 >> v27; + a1.field_18 = dword_80AA1C >> v27; + a1.field_1C = dword_80AA18 >> v27; + a1.field_20 = dword_80AA14 >> v27; + v31 = v76->field_A; + v32 = pRenderer->uTargetSurfacePitch * v76->field_A; + v86 = v76->field_8; + a1.pColorBuffer = &v77[v86 + v32]; + a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v86 + 640 * v31]; + v80 = v10 - (pOutdoorCamera->int_fov_rad_inv << v74); + if ( v78 > 0 ) + { + v86 = v78; + do + { + v78 = v3->v_18.y; + v85 = (unsigned __int64)(v78 * (signed __int64)v80) >> 16; + v84 = v66 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16); + if ( v66 + (unsigned int)((unsigned __int64)(v78 * (signed __int64)v80) >> 16) + && (v33 = abs((signed __int64)v66 + ((__int64)(v78 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v33) ) + { + LODWORD(v34) = v72 << 16; + HIDWORD(v34) = v72 >> 16; + v85 = v34 / v84; + v35 = v34 / v84; + v84 = v34 / v84; + } + else + { + v84 = 1073741824; + v35 = 1073741824; + } + HIWORD(v36) = HIWORD(v35); + LOWORD(v36) = 0; + a1.field_24 = v3->field_50 | v36; + v78 = v3->ptr_38->field_10; + v78 = v67 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16); + v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16; + v37 = v3->ptr_38; + v38 = ((unsigned __int64)(v78 * (signed __int64)v35) >> 16) - v37->field_24; + v78 = v37->field_1C; + v78 = v71 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16); + v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16; + v39 = (((v69 + v85 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74; + a1.field_4 = (((v68 + v38) >> v27) - a1.field_30) >> v74; + a1.field_0 = v39; + a1.field_28 = v83; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + { + if ( v3->pODMFace->uPolygonType == 1 ) + sr_sub_485A24(&a1, (stru315 *)&a2); + else + sr_sub_485975(&a1, (stru315 *)&a2); + } + else + { + if ( v3->pODMFace->uPolygonType == 1 ) + sr_sub_4D705A(v2); + else + sr_sub_4D6FB0(v2); + } + a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F( + &a2, + v76, + v84, + v3, + pOutdoorCamera->building_gamme, + 1u, + 0); + v80 -= pOutdoorCamera->int_fov_rad_inv << v74; + --v86; + } + while ( v86 ); + } + if ( !v81 ) + return 1; + v83 = v3->v_18.y; + v76 = (Span *)((unsigned __int64)(v83 * (signed __int64)v80) >> 16); + v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); + if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) ) + { + v40 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16)); + if ( abs(X) < v40 ) + { + LODWORD(v41) = v72 << 16; + HIDWORD(v41) = v72 >> 16; + X = v41 / v84; + HIWORD(v42) = (unsigned int)(v41 / v84) >> 16; + LOWORD(v42) = 0; + a1.field_24 = v42 | v3->field_50; + v83 = v3->ptr_38->field_10; + v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); + X = (unsigned __int64)(v83 * v41 / v84) >> 16; + v43 = v3->ptr_38; + v44 = ((unsigned __int64)(v83 * v41 / v84) >> 16) - v43->field_24; + v83 = v43->field_1C; + v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); + X = (unsigned __int64)(v83 * v41 / v84) >> 16; + v45 = (((signed int)(v69 + ((unsigned __int64)(v83 * v41 / v84) >> 16) - v3->ptr_38->field_28) >> v27) + - a1.field_2C) >> v74; + a1.field_4 = (((v68 + v44) >> v27) - a1.field_30) >> v74; + a1.field_0 = v45; + a1.field_28 = v81; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + { + if ( v3->pODMFace->uPolygonType == 1 ) + sr_sub_485A24(&a1, (stru315 *)&a2); + else + sr_sub_485975(&a1, (stru315 *)&a2); + } + else + { + if ( v3->pODMFace->uPolygonType == 1 ) + sr_sub_4D705A(v2); + else + sr_sub_4D6FB0(v2); + } + return 1; + } + } + } + } + return 0; +} + +//----- (00485AFF) -------------------------------------------------------- +stru315 *__fastcall sr_sub_485AFF(stru315 *a1, stru316 *a2) +{ + stru315 *result; // eax@1 + int i; // ecx@1 + int v4; // esi@2 + int v5; // esi@2 + int v6; // ecx@2 + int v7; // esi@3 + int v8; // edi@3 + int v9; // ebx@3 + int v10; // ecx@8 + unsigned __int16 *v11; // esi@10 + unsigned int *v12; // ecx@12 + int v13; // esi@12 + int v14; // [sp+0h] [bp-4h]@2 + + result = a1; + for ( i = a1->field_28; i; i = result->field_28 ) + { + v4 = result->field_8 & result->field_2C; + result->field_28 = i - 1; + v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10); + v6 = *((char *)result->pTextureLOD + v5); + v14 = *((char *)result->pTextureLOD + v5); + if ( a2->field_20 ) + { + v7 = HIWORD(a2->field_14); + v8 = a2->field_C; + v9 = v7; + if ( v7 >= v8 ) + v9 = a2->field_C; + if ( a2->field_8 - v9 <= 0 ) + { + v10 = 0; + } + else + { + if ( v7 >= v8 ) + v7 = a2->field_C; + v10 = a2->field_8 - v7; + } + v11 = a2->field_24_palette; + v6 = v14 + (v10 << 8); + } + else + { + v11 = result->field_34_palette; + } + *result->pColorBuffer = v11[v6]; + v12 = result->pDepthBuffer; + v13 = result->field_24; + --result->pColorBuffer; + *v12 = v13; + --result->pDepthBuffer; + a2->field_14 -= a2->field_18; + result->field_30 += result->field_4; + result->field_2C += result->field_0; + } + --result->field_28; + return result; +} + +//----- (0047F4D3) -------------------------------------------------------- +void __fastcall _47F4D3_initialize_terrain_bezier_stuff(int band1, int band2, int band3) +{ + int v3; // edi@1 + //stru220 *v4; // esi@1 + double v5; // ST2C_8@3 + double v6; // st7@3 + //double v7; // [sp+18h] [bp-28h]@3 + //double v8; // [sp+20h] [bp-20h]@2 + int v9; // [sp+34h] [bp-Ch]@1 + int v10; // [sp+38h] [bp-8h]@1 + //signed int band3a; // [sp+48h] [bp+8h]@2 + + v9 = band2 * 512; + pOutdoorCamera->outdoor_grid_band_3 = band3; + v10 = band1 * 512; + v3 = band3 * 512; + pOutdoorCamera->uPickDepth = band3 * 512; + //v4 = terrain_76E5C8; // v4: 0 -> 65536 + for (uint i = 0; i < 16384; ++i) + //do + { + auto v4 = terrain_76E5C8[i]; + //band3a = 256; + //v8 = (double)(signed int)((char *)v4 + 256 - (int)terrain_76E5C8); + for (uint j = 0; j < 128; ++j) // band3a: 0 -> 128 + { + v5 = pow(j * 512 + 256, 2.0); + v6 = pow(i * 4 + 256, 2.0); + //*((float *)&v5 + 1) = sqrt(v6 + v5); + int v7 = floorf(sqrtf(v5 + v6) + 0.5f);//*((float *)&v5 + 1) + 6.7553994e15; + if (v7 >= v10) + { + if (v7 >= v9) + v4.field_0 = ((v7 >= v3) - 1) & 2; + else + v4.field_0 = 2; + } + else + { + v4.field_0 = 1; + } + //band3a += 512; + v4.distance = v7; + //++v4; + } + //while ( band3a < 65792 ); + } + //while ( (signed int)v4 < (signed int)arary_77E5C8 ); +} + +//----- (00481EFA) -------------------------------------------------------- +bool __fastcall _481EFA_clip_terrain_poly(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5) +{ + RenderVertexSoft *v5; // esi@1 + RenderVertexSoft *v6; // edx@1 + bool v7; // edi@2 + bool v8; // ecx@5 + bool v9; // esi@8 + bool v10; // eax@11 + double v11; // st7@14 + signed int v12; // esi@15 + signed int v13; // edx@18 + signed int v14; // ecx@21 + signed int v15; // eax@24 + RenderVertexSoft *v17; // [sp+Ch] [bp-8h]@1 + + v5 = a2; + v6 = a1; + v17 = v5; + v7 = a1->vWorldViewPosition.x < 8.0; + v8 = v5->vWorldViewPosition.x < 8.0; + v9 = a3->vWorldViewPosition.x < 8.0; + v10 = a4->vWorldViewPosition.x < 8.0; + return !(v8 & v9 & v10 & v7) + && ((v11 = (double)pOutdoorCamera->shading_dist_mist, v11 > v6->vWorldViewPosition.x) ? (v12 = 0) : (v12 = 1), + v11 > v17->vWorldViewPosition.x ? (v13 = 0) : (v13 = 1), + v11 > a3->vWorldViewPosition.x ? (v14 = 0) : (v14 = 1), + v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1), + !(v13 & v14 & v15 & v12)); +} +//----- (00481212) -------------------------------------------------------- +void Render::DrawTerrainSW(int a1, int a2, int a3, int a4) +{ + int v3; // esi@1 + int v4; // ecx@1 + int v5; // ST10_4@1 + int v6; // edi@1 + int v7; // ebx@2 + int v8; // eax@2 + int v9; // eax@3 + RenderVertexSoft *v10; // edi@3 + RenderVertexSoft *v11; // ebx@4 + RenderVertexSoft *v12; // ecx@4 + float v13; // eax@6 + int v14; // eax@6 + double v15; // st7@6 + double v16; // st7@6 + Polygon *v17; // ebx@12 + unsigned __int16 v18; // ax@12 + int v19; // eax@13 + float v20; // ecx@13 + stru220 *v21; // eax@13 + int v22; // eax@13 + signed int v23; // eax@13 + Vec3_float_ *v24; // eax@15 + double v25; // st7@18 + double v26; // st5@24 + double v27; // st5@24 + double v28; // st5@24 + double v29; // st5@24 + Game *v30; // eax@25 + RenderVertexSoft *v31; // edi@29 + double v32; // st7@31 + int v33; // esi@35 + RenderVertexSoft *v34; // edx@36 + RenderVertexSoft *v35; // ecx@36 + signed int v36; // eax@39 + signed int v37; // esi@40 + Polygon *v38; // ebx@43 + unsigned __int16 v39; // ax@43 + int v40; // eax@44 + float v41; // ecx@44 + stru220 *v42; // eax@44 + int v43; // eax@44 + int v44; // eax@44 + signed int v45; // eax@44 + Vec3_float_ *v46; // eax@46 + double v47; // st7@49 + double v48; // st5@57 + double v49; // st5@57 + double v50; // st5@57 + Game *v51; // eax@58 + RenderVertexSoft *v52; // edi@62 + double v53; // st7@63 + int v54; // esi@66 + signed int v55; // eax@69 + signed int v56; // esi@71 + unsigned __int16 v57; // ax@75 + stru220 *v58; // eax@76 + signed int v59; // eax@76 + Vec3_float_ *v60; // eax@77 + double v61; // st7@80 + double v62; // st5@88 + double v63; // st5@88 + double v64; // st5@88 + Game *v65; // eax@89 + double v66; // st7@94 + RenderVertexSoft *v67; // [sp-Ch] [bp-C4h]@36 + Polygon *v68; // [sp-8h] [bp-C0h]@36 + int v69; // [sp-4h] [bp-BCh]@36 + float v70; // [sp+Ch] [bp-ACh]@88 + double v71; // [sp+10h] [bp-A8h]@6 + double v72; // [sp+18h] [bp-A0h]@82 + double v73; // [sp+20h] [bp-98h]@6 + double v74; // [sp+28h] [bp-90h]@51 + double v75; // [sp+30h] [bp-88h]@6 + double v76; // [sp+38h] [bp-80h]@20 + double v77; // [sp+40h] [bp-78h]@6 + float v78; // [sp+48h] [bp-70h]@57 + float v79; // [sp+4Ch] [bp-6Ch]@6 + float v80; // [sp+50h] [bp-68h]@6 + int v81; // [sp+54h] [bp-64h]@1 + int v82; // [sp+58h] [bp-60h]@6 + int v83; // [sp+5Ch] [bp-5Ch]@82 + int v84; // [sp+60h] [bp-58h]@20 + int v85; // [sp+64h] [bp-54h]@1 + int v86; // [sp+68h] [bp-50h]@1 + int v87; // [sp+6Ch] [bp-4Ch]@51 + float v88; // [sp+70h] [bp-48h]@51 + int v89; // [sp+74h] [bp-44h]@6 + int v90; // [sp+78h] [bp-40h]@1 + float a3a; // [sp+7Ch] [bp-3Ch]@24 + stru220 *v92; // [sp+80h] [bp-38h]@2 + float v93; // [sp+84h] [bp-34h]@44 + int v94; // [sp+88h] [bp-30h]@6 + float v95; // [sp+8Ch] [bp-2Ch]@1 + float v96; // [sp+90h] [bp-28h]@1 + float v97; // [sp+94h] [bp-24h]@1 + int X; // [sp+98h] [bp-20h]@1 + float v99; // [sp+9Ch] [bp-1Ch]@6 + int v100; // [sp+A0h] [bp-18h]@6 + unsigned __int64 v101; // [sp+A4h] [bp-14h]@6 + RenderVertexSoft *v102; // [sp+ACh] [bp-Ch]@6 + RenderVertexSoft *v103; // [sp+B0h] [bp-8h]@6 + RenderVertexSoft *v104; // [sp+B4h] [bp-4h]@3 + float pNormalc; // [sp+C0h] [bp+8h]@6 + float pNormald; // [sp+C0h] [bp+8h]@6 + Vec3_float_ *pNormal; // [sp+C0h] [bp+8h]@17 + Vec3_float_ *pNormala; // [sp+C0h] [bp+8h]@48 + Vec3_float_ *pNormalb; // [sp+C0h] [bp+8h]@77 + + v3 = a1; + //v4 = *(short *)(a3 + 4); + //v5 = *(short *)(a3 + 6); + v85 = a2; + v86 = a3; //v4; + X = abs(a4); //v5 + v6 = 0; + v90 = 0; + v81 = v3 - 1; + v95 = (double)pOutdoor->vSunlight.x / 65536.0; + v96 = (double)pOutdoor->vSunlight.y / 65536.0; + v97 = (double)pOutdoor->vSunlight.z / 65536.0; + if ( v3 - 1 > 0 ) + { + while ( 1 ) + { + v7 = abs(X); + v8 = abs(v86); + --X; + v92 = &terrain_76E5C8[(v7 << 7) + v8]; + if ( !v92->field_0 + || ((v9 = v6, v10 = &pVerticesSR_806210[v6], v104 = v10, !v85) ? (v11 = &pVerticesSR_801A10[v9], + v12 = &pVerticesSR_806210[v9 + 1]) : (v11 = &pVerticesSR_806210[v9 + 1], v12 = &pVerticesSR_801A10[v9]), + ((v103 = &pVerticesSR_801A10[v9 + 1], + v13 = v10->vWorldPosition.x, + v102 = v12, + v80 = v13, + v73 = v13 + 6.7553994e15, + v101 = __PAIR__((unsigned int)v11, LODWORD(v73)), + v79 = v10->vWorldPosition.y, + v75 = v79 + 6.7553994e15, + v100 = LODWORD(v75), + pNormalc = (v12->vWorldPosition.x + v10->vWorldPosition.x) * 0.5, + v71 = pNormalc + 6.7553994e15, + v89 = LODWORD(v71), + v14 = WorldPosToGridCellX(COERCE_UNSIGNED_INT64(pNormalc + 6.7553994e15)), + v15 = v11->vWorldPosition.y + v10->vWorldPosition.y, + v94 = v14, + pNormald = v15 * 0.5, + v16 = pNormald + 6.7553994e15, + v77 = v16, + v82 = LODWORD(v77), + LODWORD(v99) = WorldPosToGridCellZ(LODWORD(v16)), + WorldPosToGridCellX(v101), + WorldPosToGridCellZ(v100), + !byte_4D864C) + || !(pGame->uFlags & 0x80)) + && !_481EFA_clip_terrain_poly(v10, v11, v102, v103, 1)) ) + goto LABEL_105; + if ( v10->vWorldPosition.z != v11->vWorldPosition.z + || v11->vWorldPosition.z != v103->vWorldPosition.z + || v103->vWorldPosition.z != v102->vWorldPosition.z ) + break; + v17 = &array_77EC08[pOutdoorCamera->uNumPolygons]; + v18 = pOutdoor->GetTileTexture(v101, v100); + v17->uTileBitmapID = v18; + if ( v18 != -1 ) + { + v19 = pOutdoor->GetSomeOtherTileInfo(v101, v100); + LOWORD(v19) = v19 | 0x8010; + v20 = v99; + *(int *)&v17->flags = v19; + v21 = v92; + v17->field_59 = 1; + v17->terrain_grid_x = LOBYTE(v20); + v17->field_34 = v21->distance; + v22 = v94; + v17->terrain_grid_z = v94; + v23 = pTerrainNormalIndices[2 * (LODWORD(v20) + (v22 << 7)) + 1]; + if ( v23 < 0 || v23 > (signed int)(uNumTerrainNormals - 1) ) + v24 = 0; + else + v24 = &pTerrainNormals[v23]; + pNormal = v24; + if ( v24 ) + { + v25 = -(v97 * v24->z + v96 * v24->y + v95 * v24->x); + if ( v25 < 0.0 ) + v25 = 0.0; + v99 = v25 * 31.0; + v76 = v99 + 6.7553994e15; + v84 = LODWORD(v76); + v17->dimming_level = 31 - LOBYTE(v76); + } + else + { + v17->dimming_level = 0; + } + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + if ( !_481FC9_terrain(v10, (RenderVertexSoft *)HIDWORD(v101), v102, v17) ) + goto LABEL_104; + v26 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); + memcpy(array_50AC10, v104, 0x30u); + array_50AC10[0]._rhw = v26; + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + v27 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; + memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / v27; + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + v28 = v103->vWorldViewPosition.x + 0.0000001; + memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / v28; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + v29 = v102->vWorldViewPosition.x + 0.0000001; + memcpy(&array_50AC10[3], v102, sizeof(array_50AC10[3])); + array_50AC10[3]._rhw = 1.0 / v29; + array_50AC10[3].u = 1.0; + array_50AC10[3].v = 0.0; + pGame->pLightmapBuilder->StackLights_TerrainFace(pNormal, &a3a, array_50AC10, 4u, 1); + if ( stru_F8AD28.uNumLightsApplied <= 0 ) + { + v17->field_108 = 0; + } + else + { + v30 = pGame; + v17->field_108 = 1; + pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 4, pNormal); + } + if ( v104->vWorldViewPosition.x < 8.0 + || *(float *)(HIDWORD(v101) + 12) < 8.0 + || (v31 = v102, v102->vWorldViewPosition.x < 8.0) + || v103->vWorldViewPosition.x < 8.0 ) + { + v36 = sr_4250FE(4u); + } + else + { + v32 = (double)pOutdoorCamera->shading_dist_mist; + if ( v32 >= v104->vWorldViewPosition.x + && v32 >= *(float *)(HIDWORD(v101) + 12) + && v32 >= v102->vWorldViewPosition.x + && v32 >= v103->vWorldViewPosition.x ) + { + v33 = sr_4254D2(4); + v17->uNumVertices = v33; + if ( !v33 ) + goto LABEL_104; + v34 = (RenderVertexSoft *)HIDWORD(v101); + v35 = v104; + v69 = 0; + v68 = v17; + v67 = v31; + goto LABEL_37; + } + v36 = sr_4252E8(4u); + } + v37 = v36; + if ( !v36 ) + goto LABEL_104; +LABEL_41: + OutdoorCamera::Project(v37); +LABEL_102: + v33 = sr_4254D2(v37); + v17->uNumVertices = v33; + if ( !v33 ) + goto LABEL_104; + v17->_48276F_sr(); + goto LABEL_38; + } +LABEL_105: + v6 = v90++ + 1; + if ( v90 >= v81 ) + return; + } + v38 = &array_77EC08[pOutdoorCamera->uNumPolygons]; + v39 = pOutdoor->GetTileTexture(v101, v100); + v38->uTileBitmapID = v39; + if ( v39 == -1 ) + goto LABEL_105; + v40 = pOutdoor->GetSomeOtherTileInfo(v101, v100); + BYTE1(v40) |= 0x80u; + v41 = v99; + *(int *)&v38->flags = v40; + v42 = v92; + v38->field_59 = 1; + v38->terrain_grid_x = LOBYTE(v41); + v38->field_34 = v42->distance; + v43 = v94; + v38->terrain_grid_z = v94; + v44 = 2 * (LODWORD(v41) + (v43 << 7)); + LODWORD(v93) = v44 * 2; + v45 = pTerrainNormalIndices[v44 + 1]; + if ( v45 < 0 || v45 > (signed int)(uNumTerrainNormals - 1) ) + v46 = 0; + else + v46 = &pTerrainNormals[v45]; + pNormala = v46; + if ( v46 ) + { + v47 = -(v97 * v46->z + v96 * v46->y + v95 * v46->x); + if ( v47 < 0.0 ) + v47 = 0.0; + v88 = v47 * 31.0; + v74 = v88 + 6.7553994e15; + v87 = LODWORD(v74); + v38->dimming_level = 31 - LOBYTE(v74); + } + else + { + v38->dimming_level = 0; + } + if ( v38->dimming_level < 0 ) + v38->dimming_level = 0; + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + if ( !_481FC9_terrain((RenderVertexSoft *)HIDWORD(v101), v103, v104, v38) ) + goto LABEL_74; + v48 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); + memcpy(array_50AC10, v104, 0x30u); + array_50AC10[0]._rhw = v48; + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + v49 = *(float *)(HIDWORD(v101) + 12) + 0.0000001; + memcpy(&array_50AC10[1], (void *)HIDWORD(v101), sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / v49; + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + v50 = v103->vWorldViewPosition.x + 0.0000001; + memcpy(&array_50AC10[2], v103, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / v50; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + pGame->pLightmapBuilder->StackLights_TerrainFace(pNormala, &v78, array_50AC10, 3u, 0); + if ( stru_F8AD28.uNumLightsApplied <= 0 ) + { + v38->field_108 = 0; + } + else + { + v51 = pGame; + v38->field_108 = 1; + pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormala); + } + if ( v104->vWorldViewPosition.x < 8.0 + || *(float *)(HIDWORD(v101) + 12) < 8.0 + || (v52 = v103, v103->vWorldViewPosition.x < 8.0) ) + { + v55 = sr_4250FE(3u); + } + else + { + v53 = (double)pOutdoorCamera->shading_dist_mist; + if ( v53 >= v104->vWorldViewPosition.x + && v53 >= *(float *)(HIDWORD(v101) + 12) + && v53 >= v103->vWorldViewPosition.x ) + { + v54 = sr_4254D2(3); + v38->uNumVertices = v54; + if ( v54 ) + { + sr_sub_4829B9((RenderVertexSoft *)HIDWORD(v101), v52, v104, v38, 0); +LABEL_68: + sr_sub_481DB2(sr_508690, v54, v38); +LABEL_75: + v17 = &array_77EC08[pOutdoorCamera->uNumPolygons]; + v57 = pOutdoor->GetTileTexture(v101, v100); + v17->uTileBitmapID = v57; + if ( v57 == -1 ) + goto LABEL_105; + *(int *)&v17->flags = pOutdoor->GetSomeOtherTileInfo(v101, v100); + v58 = v92; + v17->field_59 = 1; + v17->field_34 = v58->distance; + v17->terrain_grid_z = v94; + v17->terrain_grid_x = LOBYTE(v99); + v59 = *(unsigned __int16 *)((char *)pTerrainNormalIndices.data() + LODWORD(v93)); + if ( v59 > (signed int)(uNumTerrainNormals - 1) ) + { + pNormalb = 0; + v60 = 0; + } + else + { + v60 = &pTerrainNormals[v59]; + pNormalb = v60; + } + if ( v60 ) + { + v61 = -(v97 * v60->z + v96 * v60->y + v95 * v60->x); + if ( v61 < 0.0 ) + v61 = 0.0; + v93 = v61 * 31.0; + v72 = v93 + 6.7553994e15; + v83 = LODWORD(v72); + v17->dimming_level = 31 - LOBYTE(v72); + } + else + { + v17->dimming_level = 0; + } + if ( v17->dimming_level < 0 ) + v17->dimming_level = 0; + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + if ( !_481FC9_terrain(v102, v104, v103, v17) ) + { +LABEL_104: + --pOutdoorCamera->uNumPolygons; + goto LABEL_105; + } + v62 = 1.0 / (v104->vWorldViewPosition.x + 0.0000001); + memcpy(array_50AC10, v104, 0x30u); + array_50AC10[0]._rhw = v62; + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + v63 = v103->vWorldViewPosition.x + 0.0000001; + memcpy(&array_50AC10[1], v103, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / v63; + array_50AC10[1].u = 1.0; + array_50AC10[1].v = 1.0; + v64 = v102->vWorldViewPosition.x + 0.0000001; + memcpy(&array_50AC10[2], v102, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / v64; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 0.0; + pGame->pLightmapBuilder->StackLights_TerrainFace(pNormalb, &v70, array_50AC10, 3u, 1); + if ( stru_F8AD28.uNumLightsApplied <= 0 ) + { + v17->field_108 = 0; + } + else + { + v65 = pGame; + v17->field_108 = 1; + pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, 3, pNormalb); + } + if ( v104->vWorldViewPosition.x < 8.0 || v103->vWorldViewPosition.x < 8.0 || v102->vWorldViewPosition.x < 8.0 ) + { + v37 = sr_4250FE(3u); + OutdoorCamera::Project(v37); + if ( !v37 ) + goto LABEL_104; + goto LABEL_102; + } + v66 = (double)pOutdoorCamera->shading_dist_mist; + if ( v66 < v104->vWorldViewPosition.x || v66 < v103->vWorldViewPosition.x || v66 < v102->vWorldViewPosition.x ) + { + v37 = sr_4252E8(3u); + if ( !v37 ) + goto LABEL_105; + goto LABEL_41; + } + v33 = sr_4254D2(3); + v17->uNumVertices = v33; + if ( !v33 ) + goto LABEL_104; + v34 = v104; + v35 = v102; + v69 = 0; + v68 = v17; + v67 = v103; +LABEL_37: + sr_sub_4829B9(v35, v34, v67, v68, v69); +LABEL_38: + sr_sub_481DB2(sr_508690, v33, v17); + goto LABEL_105; + } + goto LABEL_74; + } + v55 = sr_4252E8(3u); + } + v56 = v55; + if ( v55 ) + { + OutdoorCamera::Project(v55); + v54 = sr_4254D2(v56); + v38->uNumVertices = v54; + if ( v54 ) + { + v38->_48276F_sr(); + goto LABEL_68; + } + } +LABEL_74: + --pOutdoorCamera->uNumPolygons; + goto LABEL_75; + } +} + +//----- (00481FC9) -------------------------------------------------------- +int __fastcall _481FC9_terrain(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4)//Rotate camera +{ + float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14; + + if (a1->vWorldPosition.y == a2->vWorldPosition.y && a2->vWorldPosition.y == a3->vWorldPosition.y) + a4->flags |= 0x10; + var_c = a1->vWorldViewPosition.x - a2->vWorldViewPosition.x; + var_14 = a1->vWorldViewPosition.y - a2->vWorldViewPosition.y; + arg_0 = a1->vWorldViewPosition.z - a2->vWorldViewPosition.z; + var_10 = a3->vWorldViewPosition.x - a2->vWorldViewPosition.x; + var_8 = a3->vWorldViewPosition.y - a2->vWorldViewPosition.y; + var_4 = a3->vWorldViewPosition.z - a2->vWorldViewPosition.z; + arg_4 = a3->vWorldPosition.y - a2->vWorldPosition.y; + if (((a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.x - a2->vWorldPosition.x) - (a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.y - a2->vWorldPosition.y)) * (pIndoorCamera->pos.y - a2->vWorldPosition.z) + + ((a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.y - a2->vWorldPosition.y) - (a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.z - a2->vWorldPosition.z)) * (pIndoorCamera->pos.x - a2->vWorldPosition.x) + + ((a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.z - a2->vWorldPosition.z) - (a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.x - a2->vWorldPosition.x)) * (pIndoorCamera->pos.z - a2->vWorldPosition.y) < 0) + { + arg_4 = var_4 * var_14 - var_8 * arg_0; + a4->v_18.x = floorf(arg_4 + 0.5f); + arg_4 = var_10 * arg_0 - var_4 * var_c; + a4->v_18.y = floorf(arg_4 + 0.5f); + arg_4 = var_8 * var_c - var_10 * var_14; + a4->v_18.z = floorf(arg_4 + 0.5f); + a4->_normalize_v_18(); + arg_4 = -(a4->v_18.x * a2->vWorldViewPosition.x) - a4->v_18.y * a2->vWorldViewPosition.y - a4->v_18.z * a2->vWorldViewPosition.z; + a4->field_24 = floorf(arg_4 + 0.5f); + return true; + } + else + return false; +} +//----- (00438250) -------------------------------------------------------- +void IndoorCameraD3D::sr_Reset_list_0037C() +{ + this->list_0037C_size = 0; +} +//----- (00438240) -------------------------------------------------------- +void IndoorCameraD3D::sr_438240_draw_lits() +{ + IndoorCameraD3D *v1; // ebp@1 + int v2; // edi@2 + int v3; // ebx@3 + int v4; // esi@4 + double v5; // st7@6 + float v6; // ST00_4@8 + IndoorCameraD3D *v7; // esi@1 + float v8; // [sp+4h] [bp-28h]@6 + float v9; // [sp+8h] [bp-24h]@6 + unsigned int v10; // [sp+Ch] [bp-20h]@6 + char v11; // [sp+10h] [bp-1Ch]@6 + float v12; // [sp+14h] [bp-18h]@6 + int v13; // [sp+28h] [bp-4h]@1 + + v7 = this; + sr_438141_draw_list_0037C(); + v13 = 0; + v1 = v7; + if ( v7->list_E0380_size > 0 ) + { + v2 = (int)&v7->list_E0380[0].field_C04; + do + { + v3 = 0; + if ( *(int *)v2 > 0 ) + { + v4 = v2 - 3048; + do + { + if ( *(char *)(v2 - 3076) & 1 ) + { + LODWORD(v12) = 1; + v11 = 1; + v10 = *(int *)(v2 + 4); + v9 = 0.0; + v8 = *(float *)(v4 + 4); + v5 = *(float *)v4; + } + else + { + LODWORD(v12) = 0; + v11 = 1; + v10 = *(int *)(v2 + 4); + v9 = *(float *)(v4 - 16); + v8 = *(float *)(v4 - 20); + v5 = *(float *)(v4 - 24); + } + v6 = v5; + sr_437D4A_draw_some_vertices(v6, v8, v9, v10, v11, v12); + ++v3; + v4 += 48; + } + while ( v3 < *(int *)v2 ); + } + ++v13; + v2 += 3088; + } + while ( v13 < v1->list_E0380_size ); + } +} + +//----- (00437D4A) -------------------------------------------------------- +void IndoorCameraD3D::sr_437D4A_draw_some_vertices(float x, float y, float z, unsigned int a5, char a6, float a7) +{ + IndoorCameraD3D *v7; // edx@1 + char *v8; // eax@1 + signed int v9; // ecx@1 + signed int v10; // edx@10 + char *v11; // ecx@10 + signed int uNumD3DVertices; // edi@16 + char *v13; // ecx@24 + unsigned int v14; // edx@25 + unsigned int v15; // eax@25 + int v16; // ebx@25 + int v17; // eax@26 + int v18; // edx@26 + IDirect3DDevice3 *v19; // ST24_4@27 + HRESULT v20; // eax@27 + RenderVertexSoft vert[20]; // [sp+0h] [bp-680h]@1 + RenderVertexD3D3 pD3DVertices[5]; // [sp+3C0h] [bp-2C0h]@15 + RenderVertexSoft a1; // [sp+640h] [bp-40h]@1 + //double v24; // [sp+670h] [bp-10h]@25 + //double v25; // [sp+678h] [bp-8h]@1 + + v7 = this; + a1.flt_2C = 0.0; + //HIDWORD(v25) = (int)this; + v8 = (char *)&vert[0].flt_2C; + v9 = 20; + do + { + *(float *)v8 = 0.0; + v8 += 48; + --v9; + } + while ( v9 ); + if ( LOBYTE(a7) ) + { + vert[0].vWorldViewProjX = x; + vert[0].vWorldViewProjY = y; + goto LABEL_15; + } + a1.vWorldPosition.x = x; + a1.vWorldPosition.y = y; + a1.vWorldPosition.z = z; + if ( pRenderer->pRenderD3D ) + { + LODWORD(a7) = 1; + if ( v7->CalcPortalShape( + &a1, + (unsigned int *)&a7, + vert, + v7->std__vector_000034_prolly_frustrum, + 4, + 1, + 0) == 1 + && SLODWORD(a7) < 1 ) + return; + } + else + { + vert[0].vWorldPosition.x = x; + vert[0].vWorldPosition.y = y; + vert[0].vWorldPosition.z = z; + } + ViewTransform(vert, 1u); + v10 = 0; + v11 = (char *)&vert[0].vWorldViewPosition; + do + { + if ( *(float *)v11 >= 8.0 ) + break; + ++v10; + v11 += 48; + } + while ( v10 < 1 ); + if ( v10 < 1 ) + { + Project(vert, 1u, 0); +LABEL_15: + pD3DVertices[0].pos.x = vert[0].vWorldViewProjX; + pD3DVertices[0].pos.y = vert[0].vWorldViewProjY; + pD3DVertices[0].specular = 0; + pD3DVertices[0].diffuse = a5; + if ( a6 ) + { + pD3DVertices[0].pos.z = 0.000099999997; + pD3DVertices[1].pos.x = vert[0].vWorldViewProjX; + pD3DVertices[2].pos.x = vert[0].vWorldViewProjX; + pD3DVertices[0].rhw = 0.001; + uNumD3DVertices = 5; + pD3DVertices[0].texcoord.x = 0.0; + pD3DVertices[1].diffuse = a5; + pD3DVertices[1].specular = 0; + pD3DVertices[0].texcoord.y = 0.0; + pD3DVertices[2].diffuse = a5; + pD3DVertices[2].specular = 0; + pD3DVertices[3].pos.y = vert[0].vWorldViewProjY; + pD3DVertices[3].diffuse = a5; + pD3DVertices[3].specular = 0; + pD3DVertices[4].pos.y = vert[0].vWorldViewProjY; + pD3DVertices[1].pos.y = vert[0].vWorldViewProjY - 1.0; + pD3DVertices[4].diffuse = a5; + pD3DVertices[4].specular = 0; + pD3DVertices[1].pos.z = 0.000099999997; + pD3DVertices[1].rhw = 0.001; + pD3DVertices[1].texcoord.x = 0.0; + pD3DVertices[1].texcoord.y = 0.0; + pD3DVertices[2].pos.y = vert[0].vWorldViewProjY + 1.0; + pD3DVertices[2].pos.z = 0.000099999997; + pD3DVertices[2].rhw = 0.001; + pD3DVertices[2].texcoord.x = 0.0; + pD3DVertices[2].texcoord.y = 0.0; + pD3DVertices[3].pos.x = vert[0].vWorldViewProjX - 1.0; + pD3DVertices[3].pos.z = 0.000099999997; + pD3DVertices[3].rhw = 0.001; + pD3DVertices[3].texcoord.x = 0.0; + pD3DVertices[3].texcoord.y = 0.0; + pD3DVertices[4].pos.x = vert[0].vWorldViewProjX + 1.0; + pD3DVertices[4].pos.z = 0.000099999997; + pD3DVertices[4].rhw = 0.001; + pD3DVertices[4].texcoord.x = 0.0; + pD3DVertices[4].texcoord.y = 0.0; + } + else + { + uNumD3DVertices = 1; + __debugbreak(); // make things right + *(unsigned int *)(&pD3DVertices[0].pos.z) = 0x38D1B717u; + pD3DVertices[0].texcoord.x = 0.0; + *(unsigned int *)(&pD3DVertices[0].rhw) = 0x3A83126Fu; + pD3DVertices[0].texcoord.y = 0.0; + } + if ( pRenderer->pRenderD3D ) + { + __debugbreak(); // decompilation bug + //v19 = pRenderer->pRenderD3D->pDevice; + ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(0, nullptr)); + ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(D3DPT_POINTLIST, + D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, + pD3DVertices, + uNumD3DVertices, + 16)); + } + else + { + if ( (double)(signed int)pViewport->uViewportTL_X <= vert[0].vWorldViewProjX - 1.0 + && (double)(signed int)pViewport->uViewportBR_X > vert[0].vWorldViewProjX + 2.0 + && (double)(signed int)pViewport->uViewportTL_Y <= vert[0].vWorldViewProjY - 1.0 + && (double)(signed int)pViewport->uViewportBR_Y > vert[0].vWorldViewProjY + 2.0 + && uNumD3DVertices > 0 ) + { + v13 = (char *)&pD3DVertices[0].diffuse; + do + { + LODWORD(a7) = *((int *)v13 - 3); + //v25 = a7 + 6.7553994e15; + auto _v25 = floorf(a7 + 0.5f); + + //v24 = *((float *)v13 - 4) + 6.7553994e15; + auto _v24 = floorf(*((float *)v13 - 4) + 0.5f); + + v14 = *(int *)v13; + v15 = *(int *)v13; + v16 = (*(int *)v13 >> 3) & 0x1F; + if ( pRenderer->uTargetGBits == 5 ) + { + v17 = (v15 >> 6) & 0x3E0; + v18 = (v14 >> 9) & 0x7C00; + } + else + { + v17 = (v15 >> 5) & 0x7E0; + v18 = (v14 >> 8) & 0xF800; + } + v13 += 32; + --uNumD3DVertices; + pRenderer->pTargetSurface[(uint)_v24 + pRenderer->uTargetSurfacePitch * (uint)_v25] = v18 | v16 | (unsigned __int16)v17; + } + while ( uNumD3DVertices ); + } + } + } +} + +//----- (0047BEB1) -------------------------------------------------------- +int __fastcall sr_sub_47BEB1(signed int a1, Polygon *a2, int terrain_gamma, int a4, int *a5, int *a6, int a7, int a8) +{ + Polygon *v8; // ebx@1 + signed int v9; // edx@1 + int v10; // eax@5 + signed int v11; // eax@9 + signed int v12; // eax@15 + signed __int64 v13; // qtt@21 + int *v14; // ecx@30 + int *v15; // edi@30 + int v16; // ebx@32 + signed __int64 v17; // qtt@37 + double v18; // ST10_8@37 + double v19; // ST10_8@38 + int v20; // edi@39 + int result; // eax@46 + int *v22; // eax@48 + signed int v23; // edx@51 + signed __int64 v24; // qtt@51 + int v25; // ecx@51 + signed int v26; // [sp+14h] [bp-4h]@1 + float v27; // [sp+28h] [bp+10h]@37 + float v28; // [sp+28h] [bp+10h]@38 + int v29; // [sp+2Ch] [bp+14h]@37 + + v8 = a2; + v9 = a1; + v26 = a1; + if ( pParty->armageddon_timer ) + { + *a5 = -1; + *a6 = -1; + *(char *)a7 = 1; +LABEL_46: + result = a8; + *(char *)a8 = 0; + return result; + } + if ( a1 < 0 ) + { + v26 = v8->field_34 << 16; + v9 = v8->field_34 << 16; + } + v10 = pWeather->bNight; + if ( bUnderwater == 1 ) + v10 = 0; + if ( !v10 ) + { + if ( !(day_attrib & DAY_ATTRIB_FOG) && !bUnderwater ) + { + v14 = a5; + v15 = a6; + if ( !v9 ) + { + *a5 = 31; + *a6 = -1; + } + v16 = v8->dimming_level - terrain_gamma; + if ( v16 >= 0 ) + { + if ( v16 > 27 ) + v16 = 27; + } + else + { + v16 = 0; + } + *a6 = 27; + if ( a4 ) + { + v28 = pOutdoor->fFogDensity * 27.0; + v19 = v28 + 6.7553994e15; + v29 = LODWORD(v19); + } + else + { + LODWORD(v17) = v9 << 16; + HIDWORD(v17) = v9 >> 16; + v27 = (double)(signed int)(((unsigned __int64)(v17 / (pOutdoorCamera->shading_dist_shade << 16) * (31 - *a6)) >> 16) + + *a6) + * pOutdoor->fFogDensity; + v18 = v27 + 6.7553994e15; + v29 = LODWORD(v18); + } + *v14 = v16 + v29; + v20 = *v15; + if ( v16 + v29 > v20 ) + *v14 = v20; + if ( *v14 < v16 ) + *v14 = v16; + if ( *v14 > pOutdoor->max_terrain_dimming_level ) + *v14 = pOutdoor->max_terrain_dimming_level; + goto LABEL_45; + } + if ( v9 >= day_fogrange_1 << 16 ) + { + if ( v9 <= day_fogrange_2 << 16 ) + { + v23 = v9 - (day_fogrange_1 << 16); + LODWORD(v24) = v23 << 16; + HIDWORD(v24) = v23 >> 16; + v25 = (unsigned __int64)(27 * v24 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16; + v22 = a5; + *a5 = v25; + if ( v25 > 27 ) + goto LABEL_54; + v9 = v26; + } + else + { + v22 = a5; + *a5 = 27; + } + } + else + { + v22 = a5; + *a5 = 0; + } + if ( v9 ) + { +LABEL_55: + if ( a4 ) + *v22 = 31; + *a6 = 31; + *(char *)a7 = 0; + goto LABEL_59; + } +LABEL_54: + *v22 = 27; + goto LABEL_55; + } + if ( v10 == 1 ) + { + v11 = 1; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 0x10 ) + { + v12 = 0; + } + else + { + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) + { + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime <= 0 ) + v11 = 0; + else + v11 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower; + } + v12 = v11 << 26; + } + if ( a4 ) + goto LABEL_24; + if ( v9 <= v12 ) + { + if ( v9 > 0 ) + { + LODWORD(v13) = v9 << 16; + HIDWORD(v13) = v9 >> 16; + v9 = v26; + *a5 = (unsigned __int64)(27 * v13 / v12) >> 16; + } + if ( *a5 > 27 ) + goto LABEL_24; + } + else + { + *a5 = 27; + } + if ( v9 ) + { +LABEL_25: + if ( v8->field_32 & 4 ) + *a5 = 27; + *a6 = 27; +LABEL_45: + *(char *)a7 = 0; + goto LABEL_46; + } +LABEL_24: + *a5 = 27; + goto LABEL_25; + } + *a5 = -1; + *a6 = -1; + *(char *)a7 = 1; +LABEL_59: + result = a8; + *(char *)a8 = 1; + return result; +} +//----- (0047C24C) -------------------------------------------------------- +unsigned __int16 *__fastcall sr_sub_47C24C_get_palette(BLVFace *a1, int a2, int a3, char a4) +{ + int v4; // esi@1 + int v5; // eax@2 + int a3a; // [sp+4h] [bp-4h]@1 + + v4 = a2; + a3a = 1; + if ( a4 ) + { + v5 = pGame->_44ED0A(a1, &a3a, 31); + if ( v5 != -1 ) + a3 = v5; + } + return PaletteManager::Get_Dark_or_Red_LUT(v4, a3, a3a); +} +//----- (00438141) -------------------------------------------------------- +void IndoorCameraD3D::sr_438141_draw_list_0037C() +{ + IndoorCameraD3D *v1; // edi@1 + signed int v2; // ebx@1 + char *v3; // esi@2 + double v4; // st7@4 + float v5; // ST00_4@6 + float v6; // [sp+4h] [bp-20h]@4 + float v7; // [sp+8h] [bp-1Ch]@4 + unsigned int v8; // [sp+Ch] [bp-18h]@4 + char v9; // [sp+10h] [bp-14h]@4 + float v10; // [sp+14h] [bp-10h]@4 + + v1 = this; + v2 = 0; + if ( (signed int)this->list_0037C_size > 0 ) + { + v3 = (char *)&this->list_0037C[0].field_20; + do + { + if ( *(v3 - 32) & 1 ) + { + LODWORD(v10) = 1; + v9 = 1; + v8 = *((int *)v3 + 5); + v7 = 0.0; + v6 = *(float *)v3; + v4 = *((float *)v3 - 1); + } + else + { + LODWORD(v10) = 0; + v9 = 1; + v8 = *((int *)v3 + 5); + v7 = *((float *)v3 - 5); + v6 = *((float *)v3 - 6); + v4 = *((float *)v3 - 7); + } + v5 = v4; + sr_437D4A_draw_some_vertices(v5, v6, v7, v8, v9, v10); + ++v2; + v3 += 56; + } + while ( v2 < (signed int)v1->list_0037C_size ); + } +} +//----- (00485BAE) -------------------------------------------------------- +stru315 *__fastcall sr_sub_485BAE(stru315 *a1, stru316 *a2) +{ + stru315 *result; // eax@1 + int i; // ecx@1 + int v4; // ecx@2 + int v5; // ecx@4 + int v6; // ecx@6 + int v7; // ecx@8 + int v8; // esi@10 + int v9; // ecx@10 + int v10; // esi@11 + int v11; // edi@11 + int v12; // ebx@11 + int v13; // ecx@16 + unsigned __int16 *v14; // esi@18 + unsigned int *v15; // ecx@20 + int v16; // esi@20 + int v17; // [sp+0h] [bp-4h]@10 + + result = a1; + for ( i = a1->field_28; i; i = result->field_28 ) + { + result->field_28 = i - 1; + v4 = result->field_18; + if ( result->field_30 > v4 ) + result->field_30 = v4; + v5 = result->field_20; + if ( result->field_2C > v5 ) + result->field_2C = v5; + v6 = result->field_14; + if ( result->field_30 < v6 ) + result->field_30 = v6; + v7 = result->field_1C; + if ( result->field_2C < v7 ) + result->field_2C = v7; + v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10); + v9 = *((char *)result->pTextureLOD + v8); + v17 = *((char *)result->pTextureLOD + v8); + if ( a2->field_20 ) + { + v10 = HIWORD(a2->field_14); + v11 = a2->field_C; + v12 = v10; + if ( v10 >= v11 ) + v12 = a2->field_C; + if ( a2->field_8 - v12 <= 0 ) + { + v13 = 0; + } + else + { + if ( v10 >= v11 ) + v10 = a2->field_C; + v13 = a2->field_8 - v10; + } + v14 = a2->field_24_palette; + v9 = v17 + (v13 << 8); + } + else + { + v14 = result->field_34_palette; + } + *result->pColorBuffer = v14[v9]; + v15 = result->pDepthBuffer; + v16 = result->field_24; + --result->pColorBuffer; + *v15 = v16; + --result->pDepthBuffer; + a2->field_14 -= a2->field_18; + result->field_30 += result->field_4; + result->field_2C += result->field_0; + } + --result->field_28; + return result; +} + +//----- (00485C89) -------------------------------------------------------- +stru315 *__fastcall sr_sub_485C89(stru315 *a1, stru316 *a2) +{ + stru315 *result; // eax@1 + int i; // ecx@1 + int v4; // esi@2 + int v5; // esi@2 + int v6; // ecx@2 + int v7; // esi@4 + int v8; // edi@4 + int v9; // ecx@9 + unsigned __int16 *v10; // esi@11 + unsigned int *v11; // ecx@14 + int v12; // esi@14 + int v13; // [sp+0h] [bp-4h]@2 + + result = a1; + for ( i = a1->field_28; i; i = result->field_28 ) + { + v4 = result->field_8 & result->field_2C; + result->field_28 = i - 1; + v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10); + v6 = *((char *)result->pTextureLOD + v5); + v13 = *((char *)result->pTextureLOD + v5); + if ( *((char *)result->pTextureLOD + v5) ) + { + if ( a2->field_20 ) + { + v7 = HIWORD(a2->field_10); + v8 = v7; + if ( v7 >= a2->field_C ) + v8 = a2->field_C; + if ( a2->field_8 - v8 <= 0 ) + { + v9 = 0; + } + else + { + if ( v7 >= a2->field_C ) + v7 = a2->field_C; + v9 = a2->field_8 - v7; + } + v10 = a2->field_24_palette; + v6 = v13 + (v9 << 8); + } + else + { + v10 = result->field_34_palette; + } + *result->pColorBuffer = v10[v6]; + } + v11 = result->pDepthBuffer; + v12 = result->field_24; + ++result->pColorBuffer; + *v11 = v12; + ++result->pDepthBuffer; + a2->field_10 += a2->field_18; + result->field_30 += result->field_4; + result->field_2C += result->field_0; + } + --result->field_28; + return result; +} + +//----- (00485D3E) -------------------------------------------------------- +stru315 *__fastcall sr_sub_485D3E(stru315 *a1, stru316 *a2) +{ + stru315 *result; // eax@1 + int i; // ecx@1 + int v4; // ecx@2 + int v5; // ecx@4 + int v6; // ecx@6 + int v7; // ecx@8 + int v8; // esi@10 + int v9; // ecx@10 + int v10; // esi@12 + int v11; // edi@12 + int v12; // ecx@17 + unsigned __int16 *v13; // esi@19 + unsigned int *v14; // ecx@22 + int v15; // esi@22 + int v16; // [sp+0h] [bp-4h]@10 + + result = a1; + for ( i = a1->field_28; i; i = result->field_28 ) + { + result->field_28 = i - 1; + v4 = result->field_18; + if ( result->field_30 > v4 ) + result->field_30 = v4; + v5 = result->field_20; + if ( result->field_2C > v5 ) + result->field_2C = v5; + v6 = result->field_14; + if ( result->field_30 < v6 ) + result->field_30 = v6; + v7 = result->field_1C; + if ( result->field_2C < v7 ) + result->field_2C = v7; + v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10); + v9 = *((char *)result->pTextureLOD + v8); + v16 = *((char *)result->pTextureLOD + v8); + if ( *((char *)result->pTextureLOD + v8) ) + { + if ( a2->field_20 ) + { + v10 = HIWORD(a2->field_10); + v11 = v10; + if ( v10 >= a2->field_C ) + v11 = a2->field_C; + if ( a2->field_8 - v11 <= 0 ) + { + v12 = 0; + } + else + { + if ( v10 >= a2->field_C ) + v10 = a2->field_C; + v12 = a2->field_8 - v10; + } + v13 = a2->field_24_palette; + v9 = v16 + (v12 << 8); + } + else + { + v13 = result->field_34_palette; + } + *result->pColorBuffer = v13[v9]; + } + v14 = result->pDepthBuffer; + v15 = result->field_24; + ++result->pColorBuffer; + *v14 = v15; + ++result->pDepthBuffer; + a2->field_10 += a2->field_18; + result->field_30 += result->field_4; + result->field_2C += result->field_0; + } + --result->field_28; + return result; +} + +//----- (0047C178) -------------------------------------------------------- +void *__fastcall sr_sub_47C178(signed int a1, Polygon *a2, int terrain_gamma, int a4) +{ + Polygon *v4; // esi@1 + void *result; // eax@2 + int v6; // [sp+4h] [bp-8h]@3 + int v7; // [sp+8h] [bp-4h]@3 + + v4 = a2; + if ( pParty->armageddon_timer ) + { + result = PaletteManager::Get(a2->pTexture->palette_id2); + } + else + { + sr_sub_47BEB1(a1, a2, terrain_gamma, a4, &v6, &v7, (int)((char *)&terrain_gamma + 3), (int)((char *)&a4 + 3)); + result = sr_sub_47C1CA(v4, SBYTE3(a4), v6, v7); + } + return result; +} + +//----- (0047C1CA) -------------------------------------------------------- +void *__fastcall sr_sub_47C1CA(Polygon *a1, char a2, int a3, signed int a4) +{ + Polygon *v4; // esi@1 + void *result; // eax@2 + int v6; // edx@3 + int v7; // ecx@8 + int a3a; // [sp+4h] [bp-8h]@1 + char v9; // [sp+8h] [bp-4h]@1 + + v9 = a2; + v4 = a1; + a3a = 1; + if ( pParty->armageddon_timer ) + { + result = PaletteManager::Get(a1->pTexture->palette_id2); + } + else + { + v6 = pGame->_44EC23(a1, &a3a, a4); + if ( v6 == -1 ) + v6 = a3; + if ( v9 == 1 ) + { + if ( v6 != -1 || a4 != -1 ) + { + v7 = v4->pTexture->palette_id2; + } + else + { + v6 = 0; + v7 = 0; + } + result = PaletteManager::Get_Mist_or_Red_LUT(v7, v6, a3a); + } + else + { + result = PaletteManager::Get_Dark_or_Red_LUT(v4->pTexture->palette_id2, v6, a3a); + } + } + return result; +} + +//----- (0047C28C) -------------------------------------------------------- +char *__fastcall sr_sub_47C28C_get_palette(Polygon *a1, char a2, signed int a3, signed int a4) +{ + Polygon *v4; // esi@1 + char *result; // eax@2 + signed int v6; // eax@3 + int v7; // ecx@8 + int a2a; // [sp+4h] [bp-8h]@1 + char v9; // [sp+8h] [bp-4h]@1 + + v9 = a2; + v4 = a1; + a2a = 1; + if ( pParty->armageddon_timer ) + { + result = (char *)pPaletteManager->field_199600_palettes[a1->pTexture->palette_id2]; + } + else + { + v6 = pGame->_44EC23(a1, &a2a, a4); + if ( v6 != -1 ) + a3 = v6; + if ( v9 == 1 ) + { + if ( a3 != -1 || a4 != -1 ) + v7 = v4->pTexture->palette_id2; + else + v7 = 0; + result = (char *)PaletteManager::_47C30E_get_palette(v7, a2a); + } + else + { + result = (char *)PaletteManager::_47C33F_get_palette(v4->pTexture->palette_id2, a2a); + } + } + return result; +} + +//----- (004AFF79) -------------------------------------------------------- +void IndoorLocation::ExecDraw_sw(unsigned int uFaceID) +{ + unsigned int v1; // ebx@1 + BLVFace *v2; // esi@3 + unsigned int v3; // eax@3 + Texture *v4; // eax@8 + Texture *v5; // edi@8 + int v6; // eax@9 + int v7; // eax@9 + int v8; // ecx@17 + int v9; // ebx@17 + int v10; // eax@17 + int v11; // esi@17 + unsigned int v12; // eax@17 + int j; // ecx@19 + int v14; // edx@20 + int v15; // eax@20 + int v16; // edx@20 + int i; // ebx@22 + int v18; // ecx@23 + int v19; // eax@23 + int v20; // eax@23 + int v21; // eax@24 + unsigned __int8 *v22; // ecx@24 + int v23; // ebx@24 + int v24; // esi@25 + int v25; // eax@28 + unsigned __int16 *v26; // eax@28 + unsigned int v27; // eax@29 + int v28; // eax@30 + char *v29; // esi@31 + int v30; // eax@33 + int v31; // eax@33 + int v32; // eax@35 + int v33; // edx@35 + signed int v34; // ebx@35 + int v35; // eax@35 + int v36; // ebx@35 + signed int v37; // ebx@35 + signed int v38; // edi@35 + unsigned int v39; // edi@36 + int v40; // edx@40 + int v41; // ecx@40 + signed int v42; // edx@40 + int v43; // edx@42 + int v44; // eax@42 + unsigned __int16 *v45; // eax@43 + int *v46; // esi@44 + unsigned __int16 *v47; // edi@44 + unsigned int v48; // edx@44 + int v49; // ebx@44 + char v50; // cl@44 + char v51; // ch@44 + unsigned int v52; // ebx@46 + int v53; // edx@46 + unsigned int v54; // ebx@46 + int v55; // edx@46 + unsigned int v56; // ebx@47 + int v57; // edx@47 + int v58; // ebx@47 + int v59; // edx@47 + unsigned __int16 *v60; // eax@50 + int *v61; // esi@51 + unsigned __int16 *v62; // edi@51 + unsigned int v63; // edx@51 + int v64; // ebx@51 + char v65; // cl@51 + char v66; // ch@51 + unsigned int v67; // ebx@53 + int v68; // edx@53 + unsigned int v69; // ebx@53 + int v70; // edx@53 + unsigned int v71; // ebx@54 + int v72; // edx@54 + int v73; // ebx@54 + int v74; // edx@54 + unsigned __int16 *v75; // eax@58 + int *v76; // esi@59 + int v77; // edi@59 + unsigned int v78; // edx@59 + int v79; // ebx@59 + char v80; // cl@59 + char v81; // ch@59 + int v82; // ebx@61 + int v83; // edx@61 + unsigned int v84; // ebx@62 + int v85; // edx@62 + unsigned __int16 *v86; // eax@65 + int *v87; // esi@66 + int v88; // edi@66 + unsigned int v89; // edx@66 + int v90; // ebx@66 + char v91; // cl@66 + char v92; // ch@66 + int v93; // ebx@68 + int v94; // edx@68 + unsigned __int16 v95; // bx@69 + int v96; // edx@69 + unsigned __int8 *v97; // [sp+Ch] [bp-9Ch]@24 + unsigned __int8 *v98; // [sp+10h] [bp-98h]@24 + unsigned __int8 *v99; // [sp+14h] [bp-94h]@24 + unsigned __int8 *v100; // [sp+18h] [bp-90h]@24 + int v101; // [sp+1Ch] [bp-8Ch]@40 + int v102; // [sp+20h] [bp-88h]@31 + BLVFace *v103; // [sp+24h] [bp-84h]@3 + unsigned __int16 *v104; // [sp+28h] [bp-80h]@24 + int v105; // [sp+2Ch] [bp-7Ch]@30 + int v106; // [sp+30h] [bp-78h]@24 + int v107; // [sp+34h] [bp-74h]@9 + Texture *v108; // [sp+38h] [bp-70h]@8 + int v109; // [sp+3Ch] [bp-6Ch]@9 + unsigned int v110; // [sp+40h] [bp-68h]@24 + unsigned int v111; // [sp+44h] [bp-64h]@1 + int *k; // [sp+48h] [bp-60h]@31 + int v113; // [sp+4Ch] [bp-5Ch]@35 + int v114; // [sp+50h] [bp-58h]@35 + int v115; // [sp+54h] [bp-54h]@42 + unsigned __int8 *v116; // [sp+58h] [bp-50h]@35 + int v117; // [sp+5Ch] [bp-4Ch]@33 + int a1; // [sp+60h] [bp-48h]@27 + int v119; // [sp+64h] [bp-44h]@17 + int v120; // [sp+68h] [bp-40h]@23 + unsigned int v121; // [sp+6Ch] [bp-3Ch]@40 + unsigned int v122; // [sp+70h] [bp-38h]@35 + int v123; // [sp+74h] [bp-34h]@30 + int v124; // [sp+78h] [bp-30h]@17 + int v125; // [sp+7Ch] [bp-2Ch]@35 + unsigned int v126; // [sp+80h] [bp-28h]@9 + int v127; // [sp+84h] [bp-24h]@17 + int v128; // [sp+88h] [bp-20h]@9 + int *pZPixel; // [sp+8Ch] [bp-1Ch]@28 + int a2; // [sp+90h] [bp-18h]@16 + unsigned int v131; // [sp+94h] [bp-14h]@17 + unsigned __int16 *pColorPixel; // [sp+98h] [bp-10h]@28 + int v133; // [sp+9Ch] [bp-Ch]@17 + int v134; // [sp+A0h] [bp-8h]@17 + int v135; // [sp+A4h] [bp-4h]@24 + + v1 = uFaceID; + v111 = pRenderer->uTargetSurfacePitch; + if ( (uFaceID & 0x80000000u) == 0 ) + { + if ( (signed int)uFaceID < (signed int)pIndoor->uNumFaces ) + { + v2 = &pIndoor->pFaces[uFaceID]; + v103 = v2; + v3 = v2->uAttributes; + if ( !(BYTE1(v3) & 0x20) ) + { + if ( v3 & 0x400000 ) + { + sr_4ADD1D(uFaceID); + return; + } + if ( !(v3 & 0x10) || (sr_4AD504(uFaceID), pRenderer->pRenderD3D) ) + { + v4 = v2->GetTexture(); + ++pBLVRenderParams->uNumFacesRenderedThisFrame; + v5 = v4; + v108 = v4; + if ( v4 ) + { + v6 = v4->palette_id2; + LOBYTE(v2->uAttributes) |= 0x80u; + v109 = v6; + sr_4AE5F1(v1); + v126 = stru_F8AD28.pDeltaUV[0]; + v128 = stru_F8AD28.pDeltaUV[1]; + v107 = bUseLoResSprites; + v7 = GetPortalScreenCoord(v1); + if ( v7 ) + { + if ( PortalFrustrum(v7, &stru_F8A590, pBLVRenderParams->field_7C, v1) ) + { + if ( v2->uPolygonType == 1 ) + { + for ( i = 0; i < stru_F8AD28.uNumLightsApplied; stru_F8AD28._blv_lights_ys[v18] = v20 ) + { + v18 = i; + v120 = stru_F8AD28._blv_lights_xs[i]; + v134 = (unsigned __int64)(v120 * (signed __int64)-stru_F8AD28.plane_4.vNormal.y) >> 16; + v133 = stru_F8AD28.plane_4.vNormal.x; + v120 = stru_F8AD28._blv_lights_ys[i]; + v133 = (unsigned __int64)(v120 * (signed __int64)stru_F8AD28.plane_4.vNormal.x) >> 16; + v19 = v128; + stru_F8AD28._blv_lights_xs[i] = v126 + + v134 + + ((unsigned __int64)(v120 + * (signed __int64)stru_F8AD28.plane_4.vNormal.x) >> 16); + v20 = v19 - stru_F8AD28._blv_lights_zs[i++]; + } + } + else + { + if ( v2->uPolygonType != 3 ) + { + if ( v2->uPolygonType == 4 ) + { +LABEL_16: + a2 = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 ) + { + do + { + v8 = a2; + v9 = stru_F8AD28._blv_lights_xs[a2]; + v131 = stru_F8AD28._blv_lights_ys[a2]; + v10 = stru_F8AD28._blv_lights_zs[a2]; + v11 = (signed int)(v10 * stru_F8AD28.plane_4.vNormal.z + + stru_F8AD28.plane_4.dist + + v9 * stru_F8AD28.plane_4.vNormal.x + + v131 * stru_F8AD28.plane_4.vNormal.y) >> 16; + v119 = v9 + - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x + * (signed __int64)((signed int)(v10 * stru_F8AD28.plane_4.vNormal.z + + stru_F8AD28.plane_4.dist + + v9 * stru_F8AD28.plane_4.vNormal.x + + v131 * stru_F8AD28.plane_4.vNormal.y) >> 16)) >> 16); + v131 -= (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)v11) >> 16; + v127 = v10 - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z * (signed __int64)v11) >> 16); + stru_F8AD28._blv_lights_xs[a2] = ((unsigned __int64)(v119 + * (signed __int64)stru_F8AD28.vec_14.x) >> 16) + + ((unsigned __int64)((signed int)v131 + * (signed __int64)stru_F8AD28.vec_14.y) >> 16); + v124 = (unsigned __int64)(v119 * (signed __int64)stru_F8AD28.vec_20.x) >> 16; + v134 = (unsigned __int64)((signed int)v131 * (signed __int64)stru_F8AD28.vec_20.y) >> 16; + v133 = (unsigned __int64)(v127 * (signed __int64)stru_F8AD28.vec_20.z) >> 16; + v12 = v126; + stru_F8AD28._blv_lights_ys[v8] = v124 + + ((unsigned __int64)((signed int)v131 + * (signed __int64)stru_F8AD28.vec_20.y) >> 16) + + ((unsigned __int64)(v127 + * (signed __int64)stru_F8AD28.vec_20.z) >> 16); + stru_F8AD28._blv_lights_xs[v8] += v12; + stru_F8AD28._blv_lights_ys[v8] += v128; + ++a2; + } + while ( a2 < stru_F8AD28.uNumLightsApplied ); + v2 = v103; + } + goto LABEL_24; + } + if ( v2->uPolygonType != 5 ) + { + if ( v2->uPolygonType != 6 ) + goto LABEL_24; + goto LABEL_16; + } + } + for ( j = 0; j < stru_F8AD28.uNumLightsApplied; *(int *)v15 = v16 ) + { + v14 = v128; + stru_F8AD28._blv_lights_xs[j] += v126; + v15 = 4 * j + 16297672; + v16 = v14 - stru_F8AD28._blv_lights_ys[j++]; + } + } +LABEL_24: + v135 = 1; + pGame->_44ED0A(v2, &v135, 31); + v104 = sr_sub_47C24C_get_palette(v2, v109, 0, 1); + v134 = stru_F8AD28.field_44; + v106 = stru_F8AD28.field_48; + v21 = stru_F8A590._viewport_space_y; + a2 = stru_F8A590._viewport_space_y; + v110 = v111 * stru_F8A590._viewport_space_y; + v97 = v5->pLevelOfDetail0_prolly_alpha_mask; + v98 = v5->pLevelOfDetail1; + v99 = v5->pLevelOfDetail2; + v22 = v5->pLevelOfDetail3; + v23 = 640 * stru_F8A590._viewport_space_y; + v119 = 640 * stru_F8A590._viewport_space_y; + v100 = v22; + if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) + { + v24 = 2 * stru_F8A590._viewport_space_y; + v120 = 2 * stru_F8A590._viewport_space_y; + while ( 1 ) + { + a1 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24); + sr_4AE313(a1, v21, &stru_F81018.field_0); + if ( LOBYTE(viewparams->field_20) ) + { + v27 = v111 * (v24 - pBLVRenderParams->uViewportY); + pZPixel = &pBLVRenderParams->pTargetZBuffer[2 + * (*(__int16 *)((char *)stru_F8A590.viewport_left_side + v24) + + 320 * (v24 - pBLVRenderParams->uViewportY)) + - pBLVRenderParams->uViewportX]; + pColorPixel = &pBLVRenderParams->pRenderTarget[v27 + + 2 * *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24) + - pBLVRenderParams->uViewportX]; + v26 = &pBLVRenderParams->pRenderTarget[v27 + + 2 * *(__int16 *)((char *)stru_F8A590.viewport_right_side + v24) + - pBLVRenderParams->uViewportX]; + v23 = v119; + } + else + { + v25 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v24); + pZPixel = &pBLVRenderParams->pTargetZBuffer[v25 + v23]; + pColorPixel = &pBLVRenderParams->pRenderTarget[v25 + v110]; + v26 = &pBLVRenderParams->pRenderTarget[v110 + *(__int16 *)((char *)stru_F8A590.viewport_right_side + v24)]; + } + v131 = (unsigned int)v26; + HIWORD(v28) = HIWORD(stru_F81018.field_0.field_0); + LOWORD(v28) = 0; + v105 = stru_F8AD28.field_0 | v28; + v123 = sr_4AE491(SHIWORD(stru_F81018.field_0.field_4), SHIWORD(stru_F81018.field_0.field_8)); + if ( (unsigned int)pColorPixel < v131 ) + { + v102 = v107 + v106; + v29 = (char *)&stru_F81018.field_34.field_8; + a1 += v134; + for ( k = &stru_F81018.field_34.field_8; ; v29 = (char *)k ) + { + sr_4AE313(a1, a2, (stru337_stru0 *)(v29 - 8)); + v30 = *((int *)v29 - 2); + LOWORD(v30) = 0; + v117 = v105; + v31 = stru_F8AD28.field_0 | v30; + if ( v105 <= (unsigned int)v31 ) + v117 = v31; + v105 = v31; + v32 = *((int *)v29 - 14); + v122 = *((int *)v29 - 14) >> v107; + v33 = *((int *)v29 - 13); + v125 = *((int *)v29 - 13) >> v107; + v34 = *((int *)v29 - 1) - v32; + v113 = (*(int *)v29 - v33) >> v102; + v35 = *((int *)v29 - 11); + v114 = v34 >> v102; + v116 = (&v97)[4 * v35]; + v36 = v35 + 16 - v5->uWidthLn2; + v133 = v35 + 16; + v127 = v35 + v36; + v37 = v5->uWidthMinus1 >> v35; + v38 = v5->uHeightMinus1 >> v35 << (v35 + 16); + v128 = v37; + v126 = v38; + v39 = (unsigned int)(LOBYTE(viewparams->field_20) ? &pColorPixel[2 * v134] : &pColorPixel[v134]); + if ( v39 > v131 ) + v39 = v131; + v40 = *((short *)v29 + 1); + v41 = *((short *)v29 - 1); + v121 = v39; + v42 = sr_4AE491(v41, v40); + v101 = v42; + v124 = (signed int)(v39 - (int)pColorPixel) >> 1; + if ( v123 >> 16 == v42 >> 16 || v135 & 2 ) + { + v123 = (int)sr_sub_47C24C_get_palette(v103, v109, v123 >> 16, 1); + if ( LOBYTE(viewparams->field_20) ) + { + v86 = pColorPixel; + if ( (unsigned int)pColorPixel < v121 ) + { + v87 = pZPixel; + v88 = v123; + v89 = v122; + v90 = v125; + v91 = v133; + v92 = v127; + if ( v124 & 2 ) + { + *pZPixel = v117; + v87 -= 2; + v86 = pColorPixel + 2; + goto LABEL_69; + } + do + { + v86 += 4; + v93 = *(&v116[v128 & (v89 >> v91)] + ((v126 & v90) >> v92)); + v94 = v117; + LOWORD(v93) = *(short *)(v88 + 2 * v93); + *v87 = v117; + v87[1] = v94; + v87[640] = v94; + v87[641] = v94; + *(v86 - 4) = v93; + *(v86 - 3) = v93; + v86[636] = v93; + v86[637] = v93; + v87[2] = v94; + v87[3] = v94; + v87[642] = v94; + v87[643] = v94; + v122 += v114; + v125 += v113; + v89 = v122; + v90 = v125; +LABEL_69: + v87 += 4; + v95 = *(short *)(v88 + 2 * *(&v116[v128 & (v89 >> v91)] + ((v126 & v90) >> v92))); + v96 = v114; + *(v86 - 2) = v95; + *(v86 - 1) = v95; + v86[638] = v95; + v86[639] = v95; + v122 += v96; + v125 += v113; + v89 = v122; + v90 = v125; + } + while ( (unsigned int)v86 < v121 ); + pColorPixel = v86; + pZPixel = v87; + } + } + else + { + v75 = pColorPixel; + if ( (unsigned int)pColorPixel < v121 ) + { + v76 = pZPixel; + v77 = v123; + v78 = v122; + v79 = v125; + v80 = v133; + v81 = v127; + if ( v124 & 1 ) + { + *pZPixel = v117; + --v76; + v75 = pColorPixel + 1; + goto LABEL_62; + } + do + { + v75 += 2; + v82 = *(&v116[v128 & (v78 >> v80)] + ((v126 & v79) >> v81)); + v83 = v117; + LOWORD(v82) = *(short *)(v77 + 2 * v82); + *v76 = v117; + *(v75 - 2) = v82; + v76[1] = v83; + v122 += v114; + v125 += v113; + v78 = v122; + v79 = v125; +LABEL_62: + v84 = (unsigned int)(&v116[v128 & (v78 >> v80)] + ((v126 & v79) >> v81)); + v76 += 2; + v85 = v114; + *(v75 - 1) = *(short *)(v77 + 2 * *(char *)v84); + v122 += v85; + v125 += v113; + v78 = v122; + v79 = v125; + } + while ( (unsigned int)v75 < v121 ); + pColorPixel = v75; + pZPixel = v76; + } + } + } + else + { + v43 = (v42 - v123) >> v106; + v44 = v123 - v43; + v123 = v43; + v115 = v44; + if ( LOBYTE(viewparams->field_20) ) + { + v60 = pColorPixel; + if ( (unsigned int)pColorPixel < v121 ) + { + v61 = pZPixel; + v62 = v104; + v63 = v122; + v64 = v125; + v65 = v133; + v66 = v127; + if ( v124 & 2 ) + { + *pZPixel = v117; + v61 += 2; + v60 = pColorPixel + 2; + goto LABEL_54; + } + do + { + v67 = (v128 & (v63 >> v65)) + ((v126 & v64) >> v66); + v68 = v123 + v115; + v60 += 4; + v115 = v68; + v69 = ((v68 & 0xFFFF0000u) >> 8) + v116[v67]; + v70 = v117; + LOWORD(v69) = v62[v69]; + *v61 = v117; + v61[1] = v70; + v61[640] = v70; + v61[641] = v70; + *(v60 - 4) = v69; + *(v60 - 3) = v69; + v60[636] = v69; + v60[637] = v69; + v61[2] = v70; + v61[3] = v70; + v61[642] = v70; + v61[643] = v70; + v122 += v114; + v125 += v113; + v63 = v122; + v64 = v125; + v61 += 4; +LABEL_54: + v71 = (v128 & (v63 >> v65)) + ((v126 & v64) >> v66); + v72 = v123 + v115; + v73 = v116[v71]; + v115 = v72; + LOWORD(v73) = v62[((v72 & 0xFFFF0000u) >> 8) + v73]; + v74 = v114; + *(v60 - 2) = v73; + *(v60 - 1) = v73; + v60[638] = v73; + v60[639] = v73; + v122 += v74; + v125 += v113; + v63 = v122; + v64 = v125; + } + while ( (unsigned int)v60 < v121 ); + pColorPixel = v60; + pZPixel = v61; + } + } + else + { + v45 = pColorPixel; + if ( (unsigned int)pColorPixel < v121 ) + { + v46 = pZPixel; + v47 = v104; + v48 = v122; + v49 = v125; + v50 = v133; + v51 = v127; + if ( v124 & 1 ) + { + *pZPixel = v117; + ++v46; + v45 = pColorPixel + 1; + goto LABEL_47; + } + do + { + v52 = (v128 & (v48 >> v50)) + ((v126 & v49) >> v51); + v53 = v123 + v115; + v45 += 2; + v115 = v53; + v54 = ((v53 & 0xFFFF0000u) >> 8) + v116[v52]; + v55 = v117; + LOWORD(v54) = v47[v54]; + *v46 = v117; + *(v45 - 2) = v54; + v46[1] = v55; + v122 += v114; + v125 += v113; + v48 = v122; + v49 = v125; + v46 += 2; +LABEL_47: + v56 = (v128 & (v48 >> v50)) + ((v126 & v49) >> v51); + v57 = v123 + v115; + v58 = v116[v56]; + v115 = v57; + LOWORD(v58) = v47[((v57 & 0xFFFF0000u) >> 8) + v58]; + v59 = v114; + *(v45 - 1) = v58; + v122 += v59; + v125 += v113; + v48 = v122; + v49 = v125; + } + while ( (unsigned int)v45 < v121 ); + pColorPixel = v45; + pZPixel = v46; + } + } + } + k += 13; + v5 = v108; + v123 = v101; + a1 += v134; + if ( (unsigned int)pColorPixel >= v131 ) + break; + } + v23 = v119; + v24 = v120; + } + ++a2; + v110 += v111; + v23 += 640; + v24 += 2; + v120 = v24; + v119 = v23; + if ( a2 > stru_F8A590._viewport_space_w ) + break; + v21 = a2; + } + } + return; + } + } + } + } + } + } + } +} +//----- (00485E1F) -------------------------------------------------------- +void *__fastcall sr_sub_485E1F(stru316 *a1, Span *a2, int a3, Polygon *a4, int a5, unsigned __int8 a6, char a7) +{ + stru316 *v7; // esi@1 + signed int *v8; // edi@1 + signed int *v9; // ebx@1 + char v10; // zf@1 + int v11; // eax@1 + Span *v12; // ecx@3 + double v13; // ST24_8@3 + double v14; // ST24_8@3 + int v15; // eax@3 + signed int v16; // ST14_4@4 + char v17; // dl@4 + signed int v18; // ST10_4@4 + void *v19; // eax@4 + signed int v20; // ST14_4@5 + char v21; // dl@5 + int v22; // ST10_4@5 + signed int v23; // ST14_4@6 + char v24; // dl@6 + Span *v26; // [sp+10h] [bp-8h]@1 + char v27; // [sp+16h] [bp-2h]@1 + char v28; // [sp+17h] [bp-1h]@1 + float v29; // [sp+30h] [bp+18h]@3 + float v30; // [sp+30h] [bp+18h]@3 + + v7 = a1; + v26 = a2; + v8 = &a1->field_C; + v9 = &a1->field_8; + v10 = a1->field_0 == 0; + v27 = a1->field_4 != 0; + v28 = !v10; + sr_sub_47BEB1(a3, a4, a5, 0, &a1->field_8, &a1->field_C, (int)&v27, (int)&v28); + v7->field_24_palette = (unsigned __int16 *)sr_sub_47C28C_get_palette(a4, v28, *v9, *v8); + v11 = a4->field_108; + v7->field_20 = v11; + if ( v11 ) + { + if ( a7 ) + { + v12 = v26; + v29 = v26->field_10 * 31.0; + v13 = v29 + 6.7553994e15; + v7->field_10 = LODWORD(v13) << 16; + v30 = v12->field_14 * 31.0; + v14 = v30 + 6.7553994e15; + v15 = v7->field_10; + v7->field_14 = LODWORD(v14) << 16; + v7->field_18 = -((v15 - (LODWORD(v14) << 16)) / v12->field_C); + } + v16 = *v8; + v17 = v28; + v18 = *v9; + v7->field_1C = a6; + v19 = sr_sub_47C28C_get_palette(a4, v17, v18, v16); + } + else + { + v20 = *v8; + v21 = v28; + v7->field_10 = 0; + v7->field_14 = 0; + v22 = *v9; + v7->field_18 = 0; + v7->field_1C = 0; + v19 = sr_sub_47C1CA(a4, v21, v22, v20); + } + v23 = *v8; + v24 = v28; + v7->field_24_palette = (unsigned __int16 *)v19; + return sr_sub_47C1CA(a4, v24, *v9, v23); +} + +//----- (00486F92) -------------------------------------------------------- +void __cdecl sr_sub_486F92_MessWithEdgesAndSpans() +{ + Span *v0; // ebx@1 + int v1; // eax@2 + Edge *v2; // ecx@3 + Edge *v3; // edx@3 + Edge *v4; // esi@6 + Edge *v5; // eax@7 + Edge *v6; // ecx@8 + Surf *v7; // esi@11 + double v8; // st7@13 + Surf *v9; // edi@13 + double v10; // st6@13 + double v11; // st7@14 + signed __int64 v12; // qax@14 + Polygon *v13; // eax@15 + Span *v14; // ecx@17 + double v15; // st7@28 + signed __int64 v16; // qax@28 + Polygon *v17; // eax@29 + Span *v18; // ecx@31 + Edge *i; // eax@40 + Edge *v20; // ecx@43 + Edge *v21; // esi@44 + double v22; // st7@45 + Edge *v23; // edx@48 + unsigned int v24; // [sp+10h] [bp-10h]@2 + float v25; // [sp+14h] [bp-Ch]@3 + Edge *v26; // [sp+18h] [bp-8h]@8 + unsigned int v27; // [sp+1Ch] [bp-4h]@1 + + v0 = pSpans; + stru_80C9D8.pSurf = &stru_80C980; + stru_80C9D8.field_0 = (double)(signed int)pViewport->uViewportTL_X; + stru_80C9A4.pSurf = &stru_80C980; + stru_80C980.pPrev = &stru_80C980; + stru_80C980.pNext = &stru_80C980; + stru_80C9A4.field_0 = (double)(signed int)pViewport->uViewportBR_X; + stru_80C980.field_8 = 0.0; + stru_80C980.field_4 = 0.0; + stru_80C9D8.pNext = &stru_80C9A4; + stru_80C9D8.pPrev = 0; + stru_80C9D8.field_8 = 1; + stru_80C9A4.pNext = 0; + stru_80C9A4.pPrev = &stru_80C9D8; + stru_80C9A4.field_8 = 0; + LODWORD(stru_80C980.field_0) = 0xC97423F0u; + v27 = pViewport->uViewportTL_Y; + if ( (signed int)pViewport->uViewportTL_Y > (signed int)pViewport->uViewportBR_Y ) + { +LABEL_51: + v0->field_8 = -1; + } + else + { + v1 = 52 * pViewport->uViewportTL_Y; + v24 = 52 * pViewport->uViewportTL_Y; + while ( 1 ) + { + v2 = *(Edge **)((char *)&pNewEdges->pNext + v1); + v3 = &stru_80C9D8; + v25 = (double)(signed int)v27; + if ( v2 != &defaultEdge ) + { + do + { + while ( 1 ) + { + v4 = v3->pNext; + if ( v2->field_0 <= (double)v4->field_0 ) + break; + v3 = v3->pNext; + } + v5 = v2->pNext; + v2->pNext = v4; + v2->pPrev = v3; + v3->pNext->pPrev = v2; + v3->pNext = v2; + v3 = v2; + v2 = v5; + } + while ( v5 != &defaultEdge ); + } + v6 = stru_80C9D8.pNext; + stru_80C980.field_20 = 0; + stru_80C980.field_22 = 1; + v26 = stru_80C9D8.pNext; + if ( stru_80C9D8.pNext ) + { + while ( 1 ) + { + v7 = v6->pSurf; + if ( v6->field_8 ) + { + ++v7->field_22; + if ( v7->field_22 == 1 ) + { + v8 = v6->field_0 + 2.0; + v9 = stru_80C980.pNext; + v10 = (v8 - v7->field_C) * v7->field_4 + (v25 - v7->field_10) * v7->field_8 + v7->field_0; + if ( v10 <= (v8 - stru_80C980.pNext->field_C) * stru_80C980.pNext->field_4 + + (v25 - stru_80C980.pNext->field_10) * stru_80C980.pNext->field_8 + + stru_80C980.pNext->field_0 ) + { + do + v9 = v9->pNext; + while ( v10 <= (v8 - v9->field_C) * v9->field_4 + (v25 - v9->field_10) * v9->field_8 + v9->field_0 ); + v7->pNext = v9; + v7->pPrev = v9->pPrev; + v9->pPrev->pNext = v7; + v9->pPrev = v7; + } + else + { + v11 = v6->field_0 + 0.5; + v12 = (signed __int64)(v11 - (double)stru_80C980.pNext->field_20); + v0->field_C = v12; + if ( (signed __int16)v12 > 0 ) + { + v0->field_A = v27; + v0->field_8 = v9->field_20; + v13 = v9->pParent; + v0->pParent = v13; + if ( v13 ) + { + if ( v13->prolly_head ) + { + v14 = v13->prolly_tail; + if ( !v14 ) + return; + v14->pNext = v0; + } + else + { + v13->prolly_head = v0; + } + v13->prolly_tail = v0; + } + if ( (signed int)pOutdoorCamera->uNumSpans >= 12499 ) + return; + ++v0; + ++pOutdoorCamera->uNumSpans; + } + v6 = v26; + v7->field_20 = (signed __int64)v11; + v7->pNext = v9; + v9->pPrev = v7; + stru_80C980.pNext = v7; + v7->pPrev = &stru_80C980; + } + } + } + else + { + --v7->field_22; + if ( !v7->field_22 ) + { + if ( stru_80C980.pNext == v7 ) + { + v15 = v6->field_0 + 0.5; + v16 = (signed __int64)(v15 - (double)v7->field_20); + v0->field_C = v16; + if ( (signed __int16)v16 > 0 ) + { + v0->field_A = v27; + v0->field_8 = v7->field_20; + v17 = v7->pParent; + v0->pParent = v17; + if ( v17 ) + { + if ( v17->prolly_head ) + { + v18 = v17->prolly_tail; + if ( !v18 ) + return; + v18->pNext = v0; + } + else + { + v17->prolly_head = v0; + } + v17->prolly_tail = v0; + } + if ( (signed int)pOutdoorCamera->uNumSpans >= 12499 ) + return; + ++v0; + ++pOutdoorCamera->uNumSpans; + } + v7->pNext->field_20 = (signed __int64)v15; + v6 = v26; + } + v7->pNext->pPrev = v7->pPrev; + v7->pPrev->pNext = v7->pNext; + } + } + v26 = v6->pNext; + if ( !v26 ) + break; + v6 = v6->pNext; + } + } + for ( i = ptr_80CA10[v27]; i; i = i->ptr_18 ) + { + i->pPrev->pNext = i->pNext; + i->pNext->pPrev = i->pPrev; + } + v20 = stru_80C9D8.pNext; + if ( stru_80C9D8.pNext != &stru_80C9A4 ) + break; +LABEL_50: + ++v27; + v1 = v24 + 52; + v24 += 52; + if ( (signed int)v27 > (signed int)pViewport->uViewportBR_Y ) + goto LABEL_51; + } + while ( 1 ) + { + v21 = v20->pNext; + if ( !v21 ) + break; + v22 = v20->field_4 + v20->field_0; + v20->field_0 = v22; + if ( v22 < stru_80C9D8.field_0 ) + v20->field_0 = stru_80C9D8.field_0 + 0.0000001; + while ( 1 ) + { + v23 = v20->pPrev; + if ( v20->field_0 >= (double)v23->field_0 ) + break; + v23->pNext = v20->pNext; + v20->pNext->pPrev = v23; + v23->pPrev->pNext = v20; + v20->pPrev = v23->pPrev; + v20->pNext = v23; + v23->pPrev = v20; + } + v20 = v21; + if ( v21 == &stru_80C9A4 ) + goto LABEL_50; + } + } +} + +//----- (00487355) -------------------------------------------------------- +bool OutdoorCamera::_487355() +{ + int v0; // esi@1 + Polygon *v1; // edi@2 + bool result; // eax@3 + + v0 = 0; + if ( pOutdoorCamera->uNumPolygons > 0 ) + { + v1 = array_77EC08.data(); + do + { + result = pGame->pLightmapBuilder->_45D3C7(v1); + ++v0; + ++v1; + } + while ( v0 < pOutdoorCamera->uNumPolygons ); + } + return result; +} + +//----- (00479332) -------------------------------------------------------- +int Render::OnOutdoorRedrawSW() +{ + signed int result; // eax@1 + unsigned int v1; // edi@1 + char *v2; // esi@2 + char v3; // cl@3 + double v4; // st7@4 + float v5; // ST34_4@6 + double v6; // ST24_8@6 + int v7; // eax@6 + unsigned int v8; // eax@11 + signed int v9; // eax@13 + Vec3_float_ *v10; // eax@14 + double v11; // st7@17 + float v12; // ST34_4@19 + double v13; // ST1C_8@19 + float v14; // [sp+4h] [bp-34h]@1 + float v15; // [sp+8h] [bp-30h]@1 + float v16; // [sp+Ch] [bp-2Ch]@1 + + v14 = (double)pOutdoor->vSunlight.x / 65536.0; + result = 0; + v1 = (unsigned int)&array_77EC08[pOutdoorCamera->uNumPolygons]; + v15 = (double)pOutdoor->vSunlight.y / 65536.0; + v16 = (double)pOutdoor->vSunlight.z / 65536.0; + if ( v1 > (unsigned int)array_77EC08.data() ) + { + v2 = (char *)&array_77EC08[0].pODMFace; + while ( 1 ) + { + v3 = v2[5]; + if ( v3 == 5 ) + break; + if ( v3 == 1 ) + { + v9 = pTerrainNormalIndices[((*((int *)v2 - 9) >> 15) & 1) + + 2 * ((unsigned __int8)v2[9] + ((unsigned __int8)v2[8] << 7))]; + if ( v9 > (signed int)(uNumTerrainNormals - 1) ) + v10 = 0; + else + v10 = &pTerrainNormals[v9]; + if ( v10 ) + { + v11 = -(v16 * v10->z + v15 * v10->y + v14 * v10->x); + if ( v11 < 0.0 ) + v11 = 0.0; + v12 = v11 * 31.0; + v13 = v12 + 6.7553994e15; + v2[4] = 31 - LOBYTE(v13); + } + else + { + v2[4] = 0; + } + if ( v2[4] < 0 ) + v2[4] = 0; + goto LABEL_23; + } +LABEL_24: + v2 += 268; + if ( (unsigned int)(v2 - 84) >= v1 ) + return result; + } + v4 = (double)(signed int)(((unsigned __int64)(**(int **)v2 * (signed __int64)-pOutdoor->vSunlight.x) >> 16) + + ((unsigned __int64)(*(int *)(*(int *)v2 + 4) * (signed __int64)-pOutdoor->vSunlight.y) >> 16) + + ((unsigned __int64)(*(int *)(*(int *)v2 + 8) * (signed __int64)-pOutdoor->vSunlight.z) >> 16)) + * 0.000015258789; + if ( v4 < 0.0 ) + v4 = 0.0; + v5 = v4 * 31.0; + v6 = v5 + 6.7553994e15; + v7 = (int)(v2 + 4); + v2[4] = 31 - LOBYTE(v6); + if ( (char)(31 - LOBYTE(v6)) < 0 ) + *(char *)v7 = 0; + if ( *(char *)v7 > 31 ) + *(char *)v7 = 31; + if ( *(char *)(*(int *)v2 + 29) & 0x40 ) + { + v8 = pTextureFrameTable->GetFrameTexture( + *((short *)v2 - 4), + pEventTimer->uTotalGameTimeElapsed); + *((int *)v2 - 6) = v8 != -1 ? (int)&pBitmaps_LOD->pTextures[v8] : 0; + } +LABEL_23: + result = 1; + goto LABEL_24; + } + return result; +} +//----- (00485A24) -------------------------------------------------------- +stru315 *__fastcall sr_sub_485A24(stru315 *a1, stru315 *a2) +{ + stru315 *result; // eax@1 + int i; // ecx@1 + int v4; // ecx@2 + int v5; // ecx@4 + int v6; // ecx@6 + int v7; // ecx@8 + int v8; // esi@10 + int v9; // ecx@10 + int v10; // esi@11 + int v11; // edi@11 + int v12; // ebx@11 + int v13; // ecx@16 + unsigned __int16 *v14; // esi@18 + unsigned int *v15; // ecx@20 + int v16; // esi@20 + int v17; // [sp+0h] [bp-4h]@10 + + result = a1; + for ( i = a1->field_28; i; i = result->field_28 ) + { + result->field_28 = i - 1; + v4 = result->field_18; + if ( result->field_30 > v4 ) + result->field_30 = v4; + v5 = result->field_20; + if ( result->field_2C > v5 ) + result->field_2C = v5; + v6 = result->field_14; + if ( result->field_30 < v6 ) + result->field_30 = v6; + v7 = result->field_1C; + if ( result->field_2C < v7 ) + result->field_2C = v7; + v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10); + v9 = *((char *)result->pTextureLOD + v8); + v17 = *((char *)result->pTextureLOD + v8); + if ( a2->field_20 ) + { + v10 = HIWORD(a2->field_10); + v11 = a2->field_C; + v12 = v10; + if ( v10 >= v11 ) + v12 = a2->field_C; + if ( a2->field_8 - v12 <= 0 ) + { + v13 = 0; + } + else + { + if ( v10 >= v11 ) + v10 = a2->field_C; + v13 = a2->field_8 - v10; + } + v14 = (unsigned __int16 *)a2->field_24; + v9 = v17 + (v13 << 8); + } + else + { + v14 = result->field_34_palette; + } + *result->pColorBuffer = v14[v9]; + v15 = result->pDepthBuffer; + v16 = result->field_24; + ++result->pColorBuffer; + *v15 = v16; + ++result->pDepthBuffer; + a2->field_10 += a2->field_18; + result->field_30 += result->field_4; + result->field_2C += result->field_0; + } + --result->field_28; + return result; +} +//----- (00485975) -------------------------------------------------------- +stru315 *__fastcall sr_sub_485975(stru315 *a1, stru315 *a2) +{ + stru315 *result; // eax@1 + int i; // ecx@1 + int v4; // esi@2 + int v5; // esi@2 + int v6; // ecx@2 + int v7; // esi@3 + int v8; // edi@3 + int v9; // ebx@3 + int v10; // ecx@8 + unsigned __int16 *v11; // esi@10 + unsigned int *v12; // ecx@12 + int v13; // esi@12 + int v14; // [sp+0h] [bp-4h]@2 + + result = a1; + for ( i = a1->field_28; i; i = result->field_28 ) + { + v4 = result->field_8 & result->field_2C; + result->field_28 = i - 1; + v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10); + v6 = *((char *)result->pTextureLOD + v5); + v14 = *((char *)result->pTextureLOD + v5); + if ( a2->field_20 ) + { + v7 = HIWORD(a2->field_10); + v8 = a2->field_C; + v9 = v7; + if ( v7 >= v8 ) + v9 = a2->field_C; + if ( a2->field_8 - v9 <= 0 ) + { + v10 = 0; + } + else + { + if ( v7 >= v8 ) + v7 = a2->field_C; + v10 = a2->field_8 - v7; + } + v11 = (unsigned __int16 *)a2->field_24; + v6 = v14 + (v10 << 8); + } + else + { + v11 = result->field_34_palette; + } + *result->pColorBuffer = v11[v6]; + v12 = result->pDepthBuffer; + v13 = result->field_24; + ++result->pColorBuffer; + *v12 = v13; + ++result->pDepthBuffer; + a2->field_10 += a2->field_18; + result->field_30 += result->field_4; + result->field_2C += result->field_0; + } + --result->field_28; + return result; +} +//----- (004839BD) -------------------------------------------------------- +signed int __fastcall sr_sub_4839BD(Span *ecx0, unsigned __int16 *pTargetSurface) +{ + stru315 *v2; // ebp@0 + int v3; // eax@1 + int v4; // edi@1 + Polygon *v5; // esi@1 + unsigned int v6; // ebx@1 + int v7; // ecx@1 + int v8; // ebx@1 + int v9; // ecx@1 + int v10; // eax@1 + stru149 *v11; // eax@1 + int v12; // edx@1 + int v13; // eax@1 + int v14; // edi@1 + int v15; // ecx@1 + int v16; // eax@1 + signed int v17; // edi@1 + int v18; // edi@2 + signed __int64 v19; // qtt@3 + int v20; // edi@3 + unsigned __int16 *v21; // eax@3 + Texture *v22; // eax@4 + Texture *v23; // eax@6 + Texture *v24; // eax@8 + Texture *v25; // eax@10 + stru149 *v26; // eax@13 + int v27; // edi@13 + signed int v28; // edx@13 + Texture *v29; // ebx@13 + int v30; // edi@13 + signed int v31; // edx@13 + signed int v32; // eax@13 + signed int v33; // eax@13 + int v34; // ebx@13 + int v35; // eax@15 + int v36; // ebx@15 + int v37; // eax@16 + signed __int64 v38; // qtt@17 + int v39; // ecx@17 + int v40; // eax@19 + stru149 *v41; // eax@21 + int v42; // ebx@21 + int v43; // ebx@21 + int v44; // eax@21 + char v45; // zf@25 + int v46; // eax@28 + int v47; // eax@28 + int v48; // ebx@28 + int v49; // eax@29 + signed __int64 v50; // qtt@30 + int v51; // ecx@30 + int v52; // eax@30 + int v53; // edx@31 + stru149 *v54; // eax@33 + int v55; // ebx@33 + signed int v56; // ebx@33 + int v57; // eax@33 + unsigned __int64 v58; // qax@33 + int v60; // [sp+Ch] [bp-BCh]@1 + Span *v61; // [sp+10h] [bp-B8h]@1 + int v62; // [sp+14h] [bp-B4h]@2 + int v63; // [sp+18h] [bp-B0h]@1 + stru315 a1; // [sp+1Ch] [bp-ACh]@1 + stru316 a2; // [sp+60h] [bp-68h]@13 + int v66; // [sp+88h] [bp-40h]@13 + int v67; // [sp+8Ch] [bp-3Ch]@1 + int v68; // [sp+90h] [bp-38h]@13 + int v69; // [sp+94h] [bp-34h]@3 + int v70; // [sp+98h] [bp-30h]@1 + int v71; // [sp+9Ch] [bp-2Ch]@1 + int v72; // [sp+A0h] [bp-28h]@1 + int v73; // [sp+A4h] [bp-24h]@13 + int v74; // [sp+A8h] [bp-20h]@1 + int v75; // [sp+ACh] [bp-1Ch]@3 + int v76; // [sp+B0h] [bp-18h]@1 + int v77; // [sp+B4h] [bp-14h]@1 + int X; // [sp+B8h] [bp-10h]@1 + int v79; // [sp+BCh] [bp-Ch]@21 + int v80; // [sp+C0h] [bp-8h]@13 + unsigned int v81; // [sp+C4h] [bp-4h]@1 + + v3 = ecx0->field_A; + v4 = ecx0->field_8; + v5 = ecx0->pParent; + v6 = v4 + pRenderer->uTargetSurfacePitch * ecx0->field_A; + v61 = ecx0; + v7 = ecx0->field_C; + a1.pColorBuffer = &pTargetSurface[v6]; + v74 = v7; + a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v4 + 640 * v3]; + v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4); + v9 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v3); + v10 = v5->ptr_38->field_14; + v76 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4); + v72 = v10; + v81 = (unsigned __int64)(v10 * (signed __int64)v9) >> 16; + v11 = v5->ptr_38; + v12 = v81 + v11->field_C; + v72 = v11->field_20; + v67 = v12; + v13 = ((unsigned __int64)(v72 * (signed __int64)v9) >> 16) + v5->ptr_38->field_18; + v81 = v9; + v70 = v13; + v72 = v5->v_18.z; + v81 = (unsigned __int64)(v72 * (signed __int64)v9) >> 16; + v14 = v5->field_24; + v15 = v81 + v5->v_18.x; + v71 = v5->sTextureDeltaU << 16; + v63 = v5->sTextureDeltaV << 16; + v16 = v5->v_18.y; + v17 = -v14; + v60 = v15; + v77 = v17; + v81 = (unsigned __int64)(v76 * (signed __int64)v16) >> 16; + X = v81 + v15; + if ( !(v81 + v15) || (v62 = v17 >> 14, v18 = abs(v17 >> 14), v18 > abs(X)) ) + return 0; + LODWORD(v19) = v77 << 16; + HIDWORD(v19) = v77 >> 16; + v69 = v19 / X; + v20 = v19 / X; + v21 = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2; + a1.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2; + v75 = 2; + if ( v20 >= mipmapping_building_mm1 << 16 ) + { + if ( v20 >= mipmapping_building_mm2 << 16 ) + { + if ( v20 >= mipmapping_building_mm3 << 16 ) + { + if ( bUseLoResSprites ) + goto LABEL_12; + v25 = v5->pTexture; + v75 = 3; + v21 = (unsigned __int16 *)v25->pLevelOfDetail3; + } + else + { + v24 = v5->pTexture; + v75 = 2; + v21 = (unsigned __int16 *)v24->pLevelOfDetail2; + } + } + else + { + v23 = v5->pTexture; + v75 = 1; + v21 = (unsigned __int16 *)v23->pLevelOfDetail1; + } + } + else + { + v22 = v5->pTexture; + v75 = 0; + v21 = (unsigned __int16 *)v22->pLevelOfDetail0_prolly_alpha_mask; + } + a1.pTextureLOD = v21; +LABEL_12: + if ( v21 ) + { + a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, v20, v5, pOutdoorCamera->building_gamme, 1u, 1); + a1.field_28 = 16; + v66 = v74 >> 4; + v81 = v8; + v26 = v5->ptr_38; + v72 = v74 - 16 * (v74 >> 4); + v76 = v26->field_10; + v81 = v8; + v74 = v67 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16); + v76 = v5->ptr_38->field_1C; + v76 = v70 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16); + v81 = (unsigned __int64)(v74 * (signed __int64)v20) >> 16; + v27 = ((unsigned __int64)(v74 * (signed __int64)v20) >> 16) - v5->ptr_38->field_24; + v81 = (unsigned __int64)(v76 * (signed __int64)v69) >> 16; + v28 = v63 + ((unsigned __int64)(v76 * (signed __int64)v69) >> 16) - v5->ptr_38->field_28; + v76 = v75 + bUseLoResSprites; + v73 = v8 - 16 * pOutdoorCamera->int_fov_rad_inv; + v29 = v5->pTexture; + v30 = (v71 + v27) >> v76; + v31 = v28 >> v76; + v32 = (signed int)v29->uTextureWidth >> v75; + v74 = (signed __int16)v75; + v68 = v31; + v80 = v32; + v33 = (signed int)v29->uTextureHeight >> v75; + v34 = v75 - v29->uWidthLn2; + a1.field_8 = (v33 << 16) - 65536; + v81 = 2 * pMiscTimer->uTotalGameTimeElapsed; + a1.field_10 = v34 + 16; + a1.field_C = v80 - 1; + if ( v66 > 0 ) + { + v74 = v66; + v66 = 12 - v75; + do + { + v80 = v5->v_18.y; + v35 = (unsigned __int64)(v80 * (signed __int64)v73) >> 16; + v36 = v35 + v60; + X = v35 + v60; + if ( v35 + v60 && (v80 = abs(v62), v37 = abs(v36), v80 <= v37) ) + { + LODWORD(v38) = v77 << 16; + HIDWORD(v38) = v77 >> 16; + v80 = v38 / X; + v39 = v38 / X; + X = v38 / X; + } + else + { + X = 0x40000000u; + v39 = 0x40000000u; + } + HIWORD(v40) = HIWORD(v39); + if ( v39 <= v69 ) + HIWORD(v40) = HIWORD(v69); + LOWORD(v40) = 0; + a1.field_24 = v5->field_50 | v40; + v79 = v5->ptr_38->field_10; + v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16); + v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16; + v41 = v5->ptr_38; + v42 = ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v41->field_24; + v79 = v41->field_1C; + v79 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16); + v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16; + v43 = (v71 + v42) >> v76; + v79 = (signed int)(v63 + ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v5->ptr_38->field_28) >> v76; + a1.field_4 = (v43 - v30) >> 4; + a1.field_0 = (v79 - v68) >> 4; + a1.field_30 = v30 + 4 * stru_5C6E00->Cos(v81 + (v68 >> v66)); + v44 = stru_5C6E00->Sin(v81 + (v30 >> v66)); + a1.field_2C = v68 + 4 * v44; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + sr_sub_485975(&a1, (stru315 *)&a2); + else + sr_sub_4D6FB0(v2); + a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, X, v5, pOutdoorCamera->building_gamme, 1u, 0); + v73 -= 16 * pOutdoorCamera->int_fov_rad_inv; + v45 = v74-- == 1; + a1.field_28 = 16; + v30 = v43; + v68 = v79; + } + while ( !v45 ); + v31 = v79; + } + if ( !v72 ) + return 1; + v66 = 12 - v75; + a1.field_30 = v30 + 4 * stru_5C6E00->Cos(v81 + (v31 >> (12 - v75))); + v46 = stru_5C6E00->Sin(v81 + (v30 >> v66)); + a1.field_2C = v68 + 4 * v46; + v79 = v5->v_18.y; + v80 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16; + v47 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16; + v48 = v47 + v60; + X = v47 + v60; + if ( v47 + v60 ) + { + v79 = abs(v62); + v49 = abs(v48); + if ( v79 <= v49 ) + { + LODWORD(v50) = v77 << 16; + HIDWORD(v50) = v77 >> 16; + v77 = v50 / X; + v51 = v50 / X; + HIWORD(v52) = HIWORD(v69); + if ( v51 <= v69 ) + { + LOWORD(v52) = 0; + a1.field_24 = v52 | v5->field_50; + } + else + { + HIWORD(v53) = HIWORD(v51); + LOWORD(v53) = 0; + a1.field_24 = v53 | v5->field_50; + } + v79 = v5->ptr_38->field_10; + v77 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16; + v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16); + v67 = (unsigned __int64)(v79 * (signed __int64)v51) >> 16; + v54 = v5->ptr_38; + v55 = v67 - v54->field_24; + v79 = v54->field_1C; + v56 = v71 + v55; + v71 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16; + v57 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16); + v79 = v57; + v58 = v57 * (signed __int64)v51; + v70 = v58 >> 16; + LODWORD(v58) = (signed int)(v63 + (v58 >> 16) - v5->ptr_38->field_28) >> v76; + a1.field_4 = ((v56 >> v76) - v30) >> 4; + a1.field_0 = ((signed int)v58 - v68) >> 4; + a1.field_28 = v72; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + sr_sub_485975(&a1, (stru315 *)&a2); + else + sr_sub_4D6FB0(v2); + return 1; + } + } + } + return 0; +} + +//----- (0048408A) -------------------------------------------------------- +signed int sr_sub_48408A_prolly_odm_water_no_waves(Span *_this) +{ + stru315 *v1; // ebp@0 + Span *v2; // edi@1 + Polygon *v3; // esi@1 + int v4; // ecx@1 + stru149 *v5; // eax@1 + stru149 *v6; // eax@1 + int v7; // edx@1 + int v8; // eax@1 + int v9; // ebx@1 + int v10; // eax@1 + int v11; // ecx@1 + int v12; // eax@1 + int v13; // ecx@1 + int v14; // eax@1 + signed int v15; // ecx@1 + int v16; // ebx@1 + signed __int64 v17; // qtt@3 + stru149 *v18; // eax@3 + int v19; // ebx@3 + Texture *v20; // eax@4 + unsigned __int16 *v21; // eax@4 + Texture *v22; // eax@6 + Texture *v23; // ecx@8 + Texture *v24; // eax@10 + stru149 *v25; // eax@12 + signed int v26; // eax@12 + int v27; // ecx@12 + int v28; // eax@14 + int v29; // edx@14 + int v30; // ecx@14 + Texture *v31; // esi@14 + int v32; // edx@14 + int v33; // eax@14 + int v35; // [sp+Ch] [bp-8Ch]@1 + int v36; // [sp+10h] [bp-88h]@1 + stru316 a2; // [sp+14h] [bp-84h]@14 + stru315 a1; // [sp+3Ch] [bp-5Ch]@1 + int v39; // [sp+80h] [bp-18h]@1 + int v40; // [sp+84h] [bp-14h]@1 + int v41; // [sp+88h] [bp-10h]@1 + int v42; // [sp+8Ch] [bp-Ch]@1 + int v43; // [sp+90h] [bp-8h]@2 + int v44; // [sp+94h] [bp-4h]@1 + + v2 = _this; + v3 = _this->pParent; + v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A); + v5 = v3->ptr_38; + v44 = v4; + v42 = v5->field_14; + v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16; + v6 = v3->ptr_38; + v7 = v44 + v6->field_C; + v42 = v6->field_20; + v39 = v7; + v8 = ((unsigned __int64)(v42 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18; + v44 = v4; + v41 = v8; + v42 = v3->v_18.z; + v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16; + v9 = v44 + v3->v_18.x; + v35 = stru_5C6E00->Sin(pIndoorCamera->sRotationY); + v10 = stru_5C6E00->Cos(pIndoorCamera->sRotationY); + v11 = v2->field_8; + v36 = v10; + a1.field_28 = v2->field_C; + v12 = pViewport->uScreenCenterX - v11; + v13 = v3->field_24; + v42 = pOutdoorCamera->int_fov_rad_inv * v12; + v14 = v3->v_18.y; + v15 = -v13; + v40 = v15; + v16 = ((unsigned __int64)(v42 * (signed __int64)v14) >> 16) + v9; + v44 = v16; + if ( !v16 || (v43 = abs(v15 >> 14), v43 > abs(v16)) ) + return 0; + LODWORD(v17) = v40 << 16; + HIDWORD(v17) = v40 >> 16; + v43 = v17 / v44; + v18 = v3->ptr_38; + v44 = v42; + v40 = v18->field_10; + v44 = v42; + v40 = v39 + ((unsigned __int64)(v40 * (signed __int64)v42) >> 16); + v39 = v3->ptr_38->field_1C; + v44 = (unsigned __int64)(v39 * (signed __int64)v42) >> 16; + v19 = v43; + v41 += (unsigned __int64)(v39 * (signed __int64)v42) >> 16; + a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; + v44 = 2; + if ( v43 < mipmapping_terrain_mm1 << 16 ) + { + v20 = v3->pTexture; + v44 = 0; + v21 = (unsigned __int16 *)v20->pLevelOfDetail0_prolly_alpha_mask; +LABEL_11: + a1.pTextureLOD = v21; + goto LABEL_12; + } + if ( v43 < mipmapping_terrain_mm2 << 16 ) + { + v22 = v3->pTexture; + v44 = 1; + v21 = (unsigned __int16 *)v22->pLevelOfDetail1; + goto LABEL_11; + } + if ( v43 >= mipmapping_terrain_mm3 << 16 ) + { + if ( !bUseLoResSprites ) + { + v24 = v3->pTexture; + v44 = 3; + v21 = (unsigned __int16 *)v24->pLevelOfDetail3; + goto LABEL_11; + } + } + else + { + v23 = v3->pTexture; + v44 = 2; + a1.pTextureLOD = (unsigned __int16 *)v23->pLevelOfDetail2; + } +LABEL_12: + v43 = (unsigned __int64)(v40 * (signed __int64)v43) >> 16; + v25 = v3->ptr_38; + v43 = v19; + a1.field_30 = ((unsigned __int64)(v40 * (signed __int64)v19) >> 16) - v25->field_24; + v43 = (unsigned __int64)(v41 * (signed __int64)v19) >> 16; + v26 = ((unsigned __int64)(v41 * (signed __int64)v19) >> 16) - v3->ptr_38->field_28; + v27 = bUseLoResSprites + v44 + 2; + a1.field_30 >>= v27; + v41 = bUseLoResSprites + v44 + 2; + a1.field_2C = v26 >> v27; + if ( byte_80AA10 ) + { + a1.field_14 = dword_80AA20 >> v27; + a1.field_18 = dword_80AA1C >> v27; + a1.field_1C = dword_80AA18 >> v27; + a1.field_20 = dword_80AA14 >> v27; + } + v41 = pOutdoorCamera->int_fov_rad_inv; + v42 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v19) >> 16) >> v27; + a1.field_4 = (unsigned __int64)(v42 * (signed __int64)v35) >> 16; + v43 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16; + a1.field_0 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16; + a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v19, v3, pOutdoorCamera->terrain_gamma, 1u, 1); + LOWORD(v19) = 0; + v28 = v2->field_A; + v29 = v2->field_A; + a1.field_24 = v19; + v30 = v2->field_8; + a1.pColorBuffer = &pRenderer->pTargetSurface[v30 + pRenderer->uTargetSurfacePitch * v29]; + a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v30 + 640 * v28]; + v31 = v3->pTexture; + v32 = ((signed int)v31->uTextureWidth >> v44) - 1; + v33 = ((signed int)v31->uTextureHeight >> v44 << 16) - 65536; + a1.field_10 = v44 - v31->uWidthLn2 + 16; + a1.field_C = v32; + a1.field_8 = v33; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + { + if ( byte_80AA10 ) + sr_sub_485A24(&a1, (stru315 *)&a2); + else + sr_sub_485975(&a1, (stru315 *)&a2); + } + else + { + if ( byte_80AA10 ) + sr_sub_4D705A(v1); + else + sr_sub_4D6FB0(v1); + } + return 1; +} + +//----- (00484442) -------------------------------------------------------- +signed int sr_sub_484442(Span *_this) +{ + int v1; // ebp@0 + Span *v2; // edi@1 + Polygon *v3; // esi@1 + int v4; // ecx@1 + stru149 *v5; // eax@1 + stru149 *v6; // eax@1 + int v7; // edx@1 + int v8; // eax@1 + int v9; // ebx@1 + int v10; // eax@1 + int v11; // ecx@1 + int v12; // eax@1 + int v13; // ecx@1 + signed int v14; // ecx@1 + int v15; // ebx@1 + signed __int64 v16; // qtt@3 + int v17; // ecx@3 + int v18; // ebx@3 + int v19; // eax@3 + signed int v20; // ebx@3 + unsigned __int16 *v21; // eax@4 + stru149 *v22; // eax@12 + signed int v23; // eax@12 + int v24; // ecx@12 + int v25; // ecx@14 + unsigned int *v26; // eax@14 + Texture *v27; // esi@14 + signed int v28; // edi@14 + signed int v29; // eax@14 + signed int v31; // [sp+Ch] [bp-90h]@1 + int v32; // [sp+10h] [bp-8Ch]@1 + int v33; // [sp+14h] [bp-88h]@1 + stru316 v34; // [sp+18h] [bp-84h]@14 + stru315 v35; // [sp+40h] [bp-5Ch]@1 + int v36; // [sp+84h] [bp-18h]@1 + int v37; // [sp+88h] [bp-14h]@1 + int v38; // [sp+8Ch] [bp-10h]@1 + int v39; // [sp+90h] [bp-Ch]@1 + int v40; // [sp+94h] [bp-8h]@1 + int v41; // [sp+98h] [bp-4h]@1 + + v2 = _this; + v3 = _this->pParent; + v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A); + v5 = v3->ptr_38; + v40 = v4; + v39 = v5->field_14; + v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16; + v6 = v3->ptr_38; + v7 = v40 + v6->field_C; + v39 = v6->field_20; + v36 = v7; + v8 = ((unsigned __int64)(v39 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18; + v40 = v4; + v38 = v8; + v39 = v3->v_18.z; + v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16; + v9 = v40 + v3->v_18.x; + v32 = stru_5C6E00->Sin(pIndoorCamera->sRotationY); + v10 = stru_5C6E00->Cos(pIndoorCamera->sRotationY); + v11 = v2->field_8; + v33 = v10; + v35.field_28 = v2->field_C; + v12 = pViewport->uScreenCenterX - v11; + v13 = v3->field_24; + v41 = pOutdoorCamera->int_fov_rad_inv * v12; + v14 = -v13; + v31 = v14; + v15 = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * v12 * (signed __int64)v3->v_18.y) >> 16) + v9; + v37 = v15; + if ( !v15 || (v39 = abs(v14 >> 14), v39 > abs(v15)) ) + return 0; + LODWORD(v16) = v31 << 16; + HIDWORD(v16) = v31 >> 16; + v40 = v16 / v37; + v17 = v16 / v37; + v18 = v41; + HIWORD(v19) = (unsigned int)(v16 / v37) >> 16; + LOWORD(v19) = 0; + v35.field_24 = v19; + v37 = v36 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v41) >> 16); + v36 = v3->ptr_38->field_1C; + v41 = (unsigned __int64)(v36 * (signed __int64)v41) >> 16; + v38 += (unsigned __int64)(v36 * (signed __int64)v18) >> 16; + v20 = 2; + v35.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; + if ( v17 < mipmapping_terrain_mm1 << 16 ) + { + v20 = 0; + v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail0_prolly_alpha_mask; +LABEL_11: + v35.pTextureLOD = v21; + goto LABEL_12; + } + if ( v17 < mipmapping_terrain_mm2 << 16 ) + { + v20 = 1; + v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail1; + goto LABEL_11; + } + if ( v17 < mipmapping_terrain_mm3 << 16 ) + { + v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; + goto LABEL_11; + } + if ( !bUseLoResSprites ) + { + v20 = 3; + v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail3; + goto LABEL_11; + } +LABEL_12: + v41 = (unsigned __int64)(v37 * (signed __int64)v17) >> 16; + v22 = v3->ptr_38; + v41 = v17; + v35.field_30 = ((unsigned __int64)(v37 * (signed __int64)v17) >> 16) - v22->field_24; + v23 = ((unsigned __int64)(v38 * (signed __int64)v17) >> 16) - v3->ptr_38->field_28; + v24 = bUseLoResSprites + v20 + 2; + v35.field_30 >>= v24; + v38 = bUseLoResSprites + v20 + 2; + v35.field_2C = v23 >> v24; + if ( byte_80AA10 ) + { + v35.field_14 = dword_80AA20 >> v24; + v35.field_18 = dword_80AA1C >> v24; + v35.field_1C = dword_80AA18 >> v24; + v35.field_20 = dword_80AA14 >> v24; + } + v38 = pOutdoorCamera->int_fov_rad_inv; + v39 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v40) >> 16) >> v24; + v35.field_4 = (unsigned __int64)(v39 * (signed __int64)v32) >> 16; + v41 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16; + v35.field_0 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16; + v35.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&v34, v2, v40, v3, pOutdoorCamera->terrain_gamma, 1u, 1); + v25 = v2->field_8; + v26 = (unsigned int *)&pRenderer->pActiveZBuffer[v25 + 640 * v2->field_A]; + v35.pColorBuffer = &pRenderer->pTargetSurface[v25 + pRenderer->uTargetSurfacePitch * v2->field_A]; + v35.pDepthBuffer = v26; + v27 = v3->pTexture; + v28 = (signed int)v27->uTextureWidth >> v20; + v29 = (signed int)v27->uTextureHeight >> v20; + v35.field_10 = v20 - v27->uWidthLn2 + 16; + v35.field_C = v28 - 1; + v35.field_8 = (v29 << 16) - 65536; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + { + if ( byte_80AA10 ) + sr_sub_485D3E(&v35, &v34); + else + sr_sub_485C89(&v35, &v34); + } + else + { + if ( byte_80AA10 ) + sr_sub_4D72EC(v1); + else + sr_sub_4D73DF(v1); + } + return 1; +} + +//----- (004847EB) -------------------------------------------------------- +int sr_sub_4847EB(Span *_this) +{ + stru315 *v1; // ebp@0 + int v2; // ebx@1 + int v3; // edx@1 + Polygon *v4; // esi@1 + int v5; // eax@1 + signed int v6; // eax@3 + int v7; // edi@3 + stru149 *v8; // eax@3 + stru149 *v9; // eax@3 + int v10; // edx@3 + int v11; // eax@3 + signed int v12; // ebx@3 + int v13; // ebx@4 + signed __int64 v14; // qtt@5 + int v15; // eax@5 + signed int v16; // ebx@5 + unsigned __int16 *v17; // ecx@6 + stru149 *v18; // eax@14 + stru149 *v19; // eax@14 + signed int v20; // eax@14 + int v21; // ecx@14 + Texture *v22; // edx@16 + signed int v23; // eax@16 + int v24; // ebx@16 + int v25; // edi@17 + int v26; // ebx@17 + int v27; // eax@17 + int v28; // edi@17 + int v29; // eax@18 + signed __int64 v30; // qtt@19 + int v31; // ecx@19 + int v32; // eax@19 + stru149 *v33; // eax@21 + signed int v34; // edi@21 + int v35; // ebx@21 + signed int v36; // edi@21 + signed __int64 v37; // qtt@21 + signed int v38; // ebx@21 + int v39; // ebx@29 + int v40; // eax@32 + unsigned __int64 v41; // qax@32 + int v42; // edi@32 + int v43; // eax@33 + signed __int64 v44; // qtt@34 + int v45; // ecx@34 + int v46; // eax@34 + stru149 *v47; // eax@36 + signed int v48; // edi@36 + int v49; // eax@36 + int v50; // eax@47 + unsigned __int64 v51; // qax@47 + int v52; // edi@47 + int v53; // eax@48 + signed __int64 v54; // qtt@49 + int v55; // ecx@49 + int v56; // eax@49 + stru149 *v57; // eax@51 + signed int v58; // edi@51 + int v59; // eax@51 + Span *v61; // [sp+Ch] [bp-B0h]@1 + int v62; // [sp+10h] [bp-ACh]@3 + int v63; // [sp+14h] [bp-A8h]@3 + int v64; // [sp+18h] [bp-A4h]@3 + int v65; // [sp+1Ch] [bp-A0h]@3 + signed int v66; // [sp+20h] [bp-9Ch]@3 + signed int v67; // [sp+24h] [bp-98h]@3 + int v68; // [sp+28h] [bp-94h]@1 + char v69; // [sp+2Ch] [bp-90h]@1 + stru315 sr; // [sp+30h] [bp-8Ch]@1 + stru316 sr2; // [sp+74h] [bp-48h]@14 + int v72; // [sp+9Ch] [bp-20h]@5 + int v73; // [sp+A0h] [bp-1Ch]@1 + int v74; // [sp+A4h] [bp-18h]@3 + int v75; // [sp+A8h] [bp-14h]@21 + int v76; // [sp+ACh] [bp-10h]@1 + int v77; // [sp+B0h] [bp-Ch]@14 + int v78; // [sp+B4h] [bp-8h]@3 + int v79; // [sp+B8h] [bp-4h]@3 + + v2 = _this->field_A; + v3 = _this->field_8; + v4 = _this->pParent; + v73 = 0; + v61 = _this; + sr.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2]; + v76 = v3; + v5 = _this->field_C; + sr.pColorBuffer = &pRenderer->pTargetSurface[v3 + pRenderer->uTargetSurfacePitch * v2]; + v68 = texmapping_terrain_subdivsize; + v69 = texmapping_terrain_subdivpow2; + if ( v5 >= texmapping_terrain_subdivsize ) + v73 = texmapping_terrain_subdivsize - (v3 & (texmapping_terrain_subdivsize - 1)); + v6 = v5 - v73; + v67 = v6 >> texmapping_terrain_subdivpow2; + v62 = v6 - (v6 >> texmapping_terrain_subdivpow2 << texmapping_terrain_subdivpow2); + v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76); + v8 = v4->ptr_38; + v79 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76); + v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2); + v76 = v8->field_14; + v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16; + v9 = v4->ptr_38; + v10 = v78 + v9->field_C; + v76 = v9->field_20; + v65 = v10; + v11 = ((unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16) + + v4->ptr_38->field_18; + v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2); + v64 = v11; + v76 = v4->v_18.z; + v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16; + v12 = -v4->field_24; + v63 = v78 + v4->v_18.x; + v66 = -v4->field_24; + v78 = (unsigned __int64)(v79 * (signed __int64)v4->v_18.y) >> 16; + v74 = v78 + v63; + if ( !(v78 + v63) || (v76 = v12 >> 14, v13 = abs(v12 >> 14), v13 > abs(v74)) ) + return 0; + LODWORD(v14) = v66 << 16; + HIDWORD(v14) = v66 >> 16; + v72 = v14 / v74; + sr.pTextureLOD = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2; + v15 = v14 / v74; + v16 = 2; + if ( v15 >= mipmapping_terrain_mm1 << 16 ) + { + if ( v15 >= mipmapping_terrain_mm2 << 16 ) + { + if ( v15 >= mipmapping_terrain_mm3 << 16 ) + { + if ( bUseLoResSprites ) + goto LABEL_14; + v16 = 3; + v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail3; + } + else + { + v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2; + } + } + else + { + v16 = 1; + v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail1; + } + } + else + { + v16 = 0; + v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail0_prolly_alpha_mask; + } + sr.pTextureLOD = v17; +LABEL_14: + sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v15, v4, pOutdoorCamera->terrain_gamma, 1u, 1); + v18 = v4->ptr_38; + v78 = v7; + v79 = v18->field_10; + v78 = v7; + v77 = v65 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16); + v79 = v4->ptr_38->field_1C; + v79 = v64 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16); + v78 = (unsigned __int64)(v77 * (signed __int64)v72) >> 16; + v19 = v4->ptr_38; + v78 = v72; + sr.field_30 = ((unsigned __int64)(v77 * (signed __int64)v72) >> 16) - v19->field_24; + v78 = (unsigned __int64)(v79 * (signed __int64)v72) >> 16; + v20 = ((unsigned __int64)(v79 * (signed __int64)v72) >> 16) - v4->ptr_38->field_28; + v21 = bUseLoResSprites + v16 + 2; + sr.field_30 >>= v21; + v78 = bUseLoResSprites + v16 + 2; + sr.field_2C = v20 >> v21; + if ( byte_80AA10 ) + { + sr.field_14 = dword_80AA20 >> v21; + sr.field_18 = dword_80AA1C >> v21; + sr.field_1C = dword_80AA18 >> v21; + sr.field_20 = dword_80AA14 >> v21; + } + v22 = v4->pTexture; + v79 = (signed int)v22->uTextureWidth >> v16; + v23 = (signed int)v22->uTextureHeight >> v16; + v24 = v16 - v22->uWidthLn2 + 16; + sr.field_8 = (v23 << 16) - 65536; + sr.field_10 = v24; + sr.field_C = v79 - 1; + if ( v73 ) + { + v25 = v7 - v73 * pOutdoorCamera->int_fov_rad_inv; + v26 = v25; + v77 = v4->v_18.y; + v79 = v25; + v27 = (unsigned __int64)(v77 * (signed __int64)v25) >> 16; + v28 = v27 + v63; + v74 = v27 + v63; + if ( !(v27 + v63) || (v77 = abs(v76), v29 = abs(v28), v77 > v29) ) + return 0; + LODWORD(v30) = v66 << 16; + HIDWORD(v30) = v66 >> 16; + v77 = v30 / v74; + v31 = v30 / v74; + HIWORD(v32) = HIWORD(v72); + if ( v72 <= v31 ) + HIWORD(v32) = HIWORD(v31); + LOWORD(v32) = 0; + v77 = v26; + sr.field_24 = v32; + v74 = v4->ptr_38->field_10; + v74 = v65 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16); + v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16; + v33 = v4->ptr_38; + v77 = v26; + v34 = ((unsigned __int64)(v74 * (signed __int64)v31) >> 16) - v33->field_24; + v74 = v33->field_1C; + v74 = v64 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16); + v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16; + v35 = (v77 - v4->ptr_38->field_28) >> v78; + v74 = v73 << 16; + v36 = (v34 >> v78) - sr.field_30; + LODWORD(v37) = v36 << 16; + HIDWORD(v37) = v36 >> 16; + v38 = v35 - sr.field_2C; + sr.field_4 = v37 / (v73 << 16); + v75 = v73 << 16; + LODWORD(v37) = v38 << 16; + HIDWORD(v37) = v38 >> 16; + v77 = v37 / (v73 << 16); + sr.field_0 = v37 / (v73 << 16); + sr.field_28 = v73; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + { + if ( byte_80AA10 ) + sr_sub_485A24(&sr, (stru315 *)&sr2); + else + sr_sub_485975(&sr, (stru315 *)&sr2); + } + else + { + if ( byte_80AA10 ) + sr_sub_4D705A(v1); + else + sr_sub_4D6FB0(v1); + } + v39 = v79 - (pOutdoorCamera->int_fov_rad_inv << v69); + } + else + { + v79 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69); + v39 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69); + } + sr.field_28 = v68; + while ( v67 > 0 ) + { + v40 = v4->v_18.y; + --v67; + v75 = v40; + v41 = v40 * (signed __int64)v39; + v79 = v41 >> 16; + LODWORD(v41) = v41 >> 16; + v42 = v41 + v63; + v74 = v41 + v63; + if ( !((int)v41 + v63) || (v75 = abs(v76), v43 = abs(v42), v75 > v43) ) + return 0; + LODWORD(v44) = v66 << 16; + HIDWORD(v44) = v66 >> 16; + v73 = v44 / v74; + v45 = v44 / v74; + HIWORD(v46) = HIWORD(v72); + if ( v72 <= v45 ) + HIWORD(v46) = HIWORD(v45); + LOWORD(v46) = 0; + v79 = v39; + sr.field_24 = v46; + v75 = v4->ptr_38->field_10; + v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16); + v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16; + v47 = v4->ptr_38; + v79 = v39; + v48 = ((unsigned __int64)(v75 * (signed __int64)v45) >> 16) - v47->field_24; + v75 = v47->field_1C; + v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16); + v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16; + v49 = (((v79 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69; + sr.field_4 = ((v48 >> v78) - sr.field_30) >> v69; + sr.field_0 = v49; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + { + if ( byte_80AA10 ) + sr_sub_485A24(&sr, (stru315 *)&sr2); + else + sr_sub_485975(&sr, (stru315 *)&sr2); + } + else + { + if ( byte_80AA10 ) + sr_sub_4D705A(v1); + else + sr_sub_4D6FB0(v1); + } + sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v73, v4, pOutdoorCamera->terrain_gamma, 1u, 0); + sr.field_28 = v68; + v39 -= pOutdoorCamera->int_fov_rad_inv << v69; + } + if ( !v62 ) + return 1; + v50 = v4->v_18.y; + v75 = v50; + v51 = v50 * (signed __int64)v39; + v79 = v51 >> 16; + LODWORD(v51) = v51 >> 16; + v52 = v51 + v63; + v74 = v51 + v63; + if ( (int)v51 + v63 ) + { + v75 = abs(v76); + v53 = abs(v52); + if ( v75 <= v53 ) + { + LODWORD(v54) = v66 << 16; + HIDWORD(v54) = v66 >> 16; + v76 = v54 / v74; + v55 = v54 / v74; + HIWORD(v56) = HIWORD(v72); + if ( v72 <= v55 ) + HIWORD(v56) = HIWORD(v55); + LOWORD(v56) = 0; + v76 = v39; + sr.field_24 = v56; + v75 = v4->ptr_38->field_10; + v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16); + v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16; + v57 = v4->ptr_38; + v76 = v39; + v58 = ((unsigned __int64)(v75 * (signed __int64)v55) >> 16) - v57->field_24; + v75 = v57->field_1C; + v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16); + v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16; + v59 = (((v76 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69; + sr.field_4 = ((v58 >> v78) - sr.field_30) >> v69; + sr.field_0 = v59; + sr.field_28 = v62; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + { + if ( byte_80AA10 ) + sr_sub_485A24(&sr, (stru315 *)&sr2); + else + sr_sub_485975(&sr, (stru315 *)&sr2); + } + else + { + if ( byte_80AA10 ) + sr_sub_4D705A(v1); + else + sr_sub_4D6FB0(v1); + } + return 1; + } + } + return 0; +} + +//----- (00485407) -------------------------------------------------------- +signed int __fastcall sr_sub_485407_prolly_odm_water_wavy(Span *a1) +{ + stru315 *v1; // ebp@0 + int v2; // eax@1 + int v3; // edx@1 + unsigned int v4; // edi@1 + Polygon *v5; // esi@1 + int v6; // ecx@1 + int v7; // ebx@1 + int v8; // ecx@1 + stru149 *v9; // eax@1 + stru149 *v10; // eax@1 + int v11; // edx@1 + int v12; // eax@1 + int v13; // eax@1 + int v14; // ecx@1 + signed int v15; // edi@1 + int v16; // edi@2 + signed __int64 v17; // qtt@3 + int v18; // edi@3 + int v19; // eax@3 + unsigned __int8 *pLOD; // eax@3 + Texture *v21; // eax@4 + Texture *v22; // eax@6 + Texture *v23; // eax@8 + Texture *v24; // eax@10 + stru149 *v25; // eax@13 + stru149 *v26; // eax@13 + signed int v27; // ebx@13 + stru149 *v28; // eax@13 + Texture *v29; // esi@13 + signed int v30; // ebx@13 + signed int v31; // edi@13 + signed int v32; // edx@13 + signed int v33; // eax@13 + int v34; // esi@13 + int v35; // eax@13 + unsigned __int64 v36; // qax@13 + int v37; // eax@13 + unsigned __int64 v38; // qax@13 + char v39; // cl@14 + stru316 a2; // [sp+Ch] [bp-90h]@13 + stru315 a1a; // [sp+34h] [bp-68h]@1 + Span *v43; // [sp+78h] [bp-24h]@1 + int v44; // [sp+7Ch] [bp-20h]@1 + int v45; // [sp+80h] [bp-1Ch]@1 + int v46; // [sp+84h] [bp-18h]@1 + Span *v47; // [sp+88h] [bp-14h]@1 + int v48; // [sp+8Ch] [bp-10h]@1 + int v49; // [sp+90h] [bp-Ch]@3 + int i; // [sp+94h] [bp-8h]@3 + int X; // [sp+98h] [bp-4h]@1 + + v2 = a1->field_A; + v3 = a1->field_8; + v4 = v3 + pRenderer->uTargetSurfacePitch * a1->field_A; + v5 = a1->pParent; + v43 = a1; + v6 = a1->field_C; + a1a.pColorBuffer = &pRenderer->pTargetSurface[v4]; + v46 = v6; + v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v3); + v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2); + a1a.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2]; + v9 = v5->ptr_38; + v47 = (Span *)v7; + X = v8; + v48 = v9->field_14; + X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16; + v10 = v5->ptr_38; + v11 = X + v10->field_C; + v48 = v10->field_20; + v44 = v11; + v12 = ((unsigned __int64)(v48 * (signed __int64)v8) >> 16) + v5->ptr_38->field_18; + X = v8; + v45 = v12; + v48 = v5->v_18.z; + X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16; + v13 = v5->v_18.y; + v14 = X + v5->v_18.x; + v15 = -v5->field_24; + v48 = -v5->field_24; + X = ((unsigned __int64)(v7 * (signed __int64)v13) >> 16) + v14; + if ( !X || (v16 = abs(v15 >> 14), v16 > abs(X)) ) + return 0; + LODWORD(v17) = v48 << 16; + HIDWORD(v17) = v48 >> 16; + i = v17 / X; + v18 = v17 / X; + HIWORD(v19) = (unsigned int)(v17 / X) >> 16; + LOWORD(v19) = 0; + a1a.field_24 = v19; + pLOD = v5->pTexture->pLevelOfDetail2; + a1a.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2; + v49 = 2; + if ( v18 >= mipmapping_terrain_mm1 << 16 ) + { + if ( v18 >= mipmapping_terrain_mm2 << 16 ) + { + if ( v18 >= mipmapping_terrain_mm3 << 16 ) + { + if ( bUseLoResSprites ) + goto LABEL_12; + v24 = v5->pTexture; + v49 = 3; + pLOD = v24->pLevelOfDetail3; + } + else + { + v23 = v5->pTexture; + v49 = 2; + pLOD = v23->pLevelOfDetail2; + } + } + else + { + v22 = v5->pTexture; + v49 = 1; + pLOD = v22->pLevelOfDetail1; + } + } + else + { + v21 = v5->pTexture; + v49 = 0; + pLOD = v21->pLevelOfDetail0_prolly_alpha_mask; + } + a1a.pTextureLOD = (unsigned __int16 *)pLOD; +LABEL_12: + if ( !pLOD ) + return 0; + a1a.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v43, v18, v5, pOutdoorCamera->terrain_gamma, 1u, 1); + a1a.field_28 = 16; + v43 = (Span *)(v46 >> 4); + X = v7; + v25 = v5->ptr_38; + v48 = v46 - 16 * (v46 >> 4); + v46 = v25->field_10; + X = v7; + v46 = v44 + ((unsigned __int64)(v46 * (signed __int64)v7) >> 16); + v44 = v5->ptr_38->field_1C; + v45 += (unsigned __int64)(v44 * (signed __int64)v7) >> 16; + X = (unsigned __int64)(v46 * (signed __int64)v18) >> 16; + v26 = v5->ptr_38; + X = v18; + v27 = ((unsigned __int64)(v46 * (signed __int64)v18) >> 16) - v26->field_24; + X = (unsigned __int64)(v45 * (signed __int64)v18) >> 16; + v28 = v5->ptr_38; + v29 = v5->pTexture; + v44 = bUseLoResSprites + v49 + 2; + v30 = v27 >> v44; + v31 = (signed int)(((unsigned __int64)(v45 * (signed __int64)v18) >> 16) - v28->field_28) >> v44; + v32 = (signed int)v29->uTextureWidth >> v49; + v33 = (signed int)v29->uTextureHeight >> v49; + v34 = v49 - v29->uWidthLn2; + a1a.field_8 = (v33 << 16) - 65536; + X = 2 * pMiscTimer->uTotalGameTimeElapsed; + v45 = pOutdoorCamera->int_fov_rad_inv; + a1a.field_10 = v34 + 16; + a1a.field_C = v32 - 1; + i = (unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)i) >> 16; + v47 = (Span *)(i >> v44); + v35 = stru_5C6E00->Sin(pIndoorCamera->sRotationY); + v36 = (signed int)v47 * (signed __int64)v35; + i = v36 >> 16; + a1a.field_4 = v36 >> 16; + v37 = stru_5C6E00->Cos(pIndoorCamera->sRotationY); + v38 = (signed int)v47 * (signed __int64)v37; + i = v38 >> 16; + a1a.field_0 = v38 >> 16; + if ( (signed int)v43 > 0 ) + { + v47 = v43; + v39 = 12 - v49; + for ( i = 12 - v49; ; v39 = i ) + { + a1a.field_30 = v30 + 4 * stru_5C6E00->Cos(X + (v31 >> v39)); + a1a.field_2C = v31 + 4 * stru_5C6E00->Sin(X + (v30 >> i)); + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + sr_sub_485975(&a1a, (stru315 *)&a2); + else + sr_sub_4D6FB0(v1); + a1a.field_28 = 16; + v30 += 16 * a1a.field_4; + v31 += 16 * a1a.field_0; + v47 = (Span *)((char *)v47 - 1); + if ( !v47 ) + break; + } + } + if ( v48 ) + { + i = 12 - v49; + a1a.field_30 = v30 + 4 * stru_5C6E00->Cos(X + (v31 >> (12 - v49))); + a1a.field_2C = v31 + 4 * stru_5C6E00->Sin(X + (v30 >> i)); + a1a.field_28 = v48; + if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) + sr_sub_485975(&a1a, (stru315 *)&a2); + else + sr_sub_4D6FB0(v1); + } + return 1; +} + +//----- (0048585C) -------------------------------------------------------- +signed int __fastcall sr_sub_48585C_mb_DrawSpan(Span *a1, unsigned __int16 *pRenderTarget, int a4) +{ + Span *v3; // esi@1 + Polygon *v4; // edi@1 + int v5; // ebx@2 + signed __int64 v6; // qtt@3 + int v7; // ebx@3 + signed int v8; // ecx@3 + void *v9; // eax@5 + int v10; // ecx@5 + unsigned __int16 *pPixels; // [sp+Ch] [bp-14h]@1 + signed int v13; // [sp+10h] [bp-10h]@1 + int X; // [sp+18h] [bp-8h]@1 + + v3 = a1; + pPixels = pRenderTarget; + v4 = a1->pParent; + v13 = -v4->field_24; + X = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv + * (pViewport->uScreenCenterX - (signed int)a1->field_8) + * (signed __int64)v4->v_18.y) >> 16) + + ((unsigned __int64)(v4->v_18.z + * (signed __int64)(pOutdoorCamera->int_fov_rad_inv + * (pViewport->uScreenCenterY - (signed int)a1->field_A))) >> 16) + + v4->v_18.x; + if ( X && (v5 = abs(-v4->field_24 >> 14), v5 <= abs(X)) ) + { + LODWORD(v6) = v13 << 16; + HIDWORD(v6) = v13 >> 16; + v7 = v6 / X; + v8 = v6 / X; + } + else + { + v7 = pOutdoorCamera->shading_dist_mist << 16; + v8 = pOutdoorCamera->shading_dist_mist << 16; + } + v9 = sr_sub_47C178(v8, v4, pOutdoorCamera->terrain_gamma, a4); + fill_pixels_fast(*((short *)v9 + v4->pTexture->uDecompressedSize), pPixels, v3->field_C); + HIWORD(v10) = HIWORD(v7); + LOWORD(v10) = 0; + j_memset32(v10, &pRenderer->pActiveZBuffer[v3->field_8 + 640 * v3->field_A], v3->field_C); + return 1; +} +//----- (004252E8) -------------------------------------------------------- +signed int __fastcall sr_4252E8(unsigned int uVertexID) +{ + unsigned int v1; // edx@1 + double v2; // st7@1 + char *v3; // edi@5 + char *v4; // esi@5 + char *v5; // ecx@5 + int v6; // ebx@6 + double v7; // st6@11 + double v8; // st5@11 + double v9; // st6@12 + unsigned __int8 v10; // c2@16 + unsigned __int8 v11; // c3@16 + void *v12; // edi@23 + double v13; // st6@23 + char *v14; // ecx@23 + char v15; // zf@24 + signed int result; // eax@25 + unsigned int v17; // [sp+8h] [bp-28h]@5 + bool v18; // [sp+Ch] [bp-24h]@2 + bool v19; // [sp+10h] [bp-20h]@7 + char *v20; // [sp+14h] [bp-1Ch]@5 + char *v21; // [sp+18h] [bp-18h]@5 + signed int v22; // [sp+1Ch] [bp-14h]@1 + RenderVertexSoft *v23; // [sp+20h] [bp-10h]@5 + char *v24; // [sp+24h] [bp-Ch]@5 + char *v25; // [sp+28h] [bp-8h]@5 + char *v26; // [sp+2Ch] [bp-4h]@5 + + v1 = uVertexID; + v2 = (double)pOutdoorCamera->shading_dist_mist; + memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID])); + v22 = 0; + v18 = array_50AC10[0].vWorldViewPosition.x <= v2; + if ( (signed int)(uVertexID + 1) <= 1 ) + return 0; + v3 = (char *)&array_507D30[0].vWorldViewPosition.z; + v4 = (char *)&array_507D30[0].vWorldViewPosition.y; + v25 = (char *)&array_507D30[0]._rhw; + v23 = array_507D30; + v20 = (char *)&array_507D30[0].vWorldViewPosition.z; + v21 = (char *)&array_507D30[0].vWorldViewPosition.y; + v24 = (char *)&array_507D30[0].vWorldViewPosition; + v26 = (char *)&array_507D30[0].flt_2C; + v5 = (char *)&array_50AC10[0].vWorldViewPosition; + v17 = v1; + do + { + v6 = (int)(v5 + 48); + v19 = v2 >= *((float *)v5 + 12); + if ( v18 != v19 ) + { + if ( v19 ) + { + v7 = (v2 - *(float *)v5) / (*(float *)v6 - *(float *)v5); + *(float *)v4 = (*((float *)v5 + 13) - *((float *)v5 + 1)) * v7 + *((float *)v5 + 1); + *(float *)v3 = (*((float *)v5 + 14) - *((float *)v5 + 2)) * v7 + *((float *)v5 + 2); + v8 = (*((float *)v5 + 20) - *((float *)v5 + 8)) * v7 + *((float *)v5 + 8); + } + else + { + v9 = (v2 - *(float *)v6) / (*(float *)v5 - *(float *)v6); + *(float *)v4 = (*((float *)v5 + 1) - *((float *)v5 + 13)) * v9 + *((float *)v5 + 13); + *(float *)v3 = (*((float *)v5 + 2) - *((float *)v5 + 14)) * v9 + *((float *)v5 + 14); + v8 = (*((float *)v5 + 8) - *((float *)v5 + 20)) * v9 + *((float *)v5 + 20); + } + *(float *)v26 = v8; + *(float *)v24 = v2; + *(float *)v25 = 1.0 / v2; + if ( v18 ) + { + if ( v2 == *(float *)v5 && *(float *)v4 == *((float *)v5 + 1) ) + { + v10 = 0; + v11 = *(float *)v3 == *((float *)v5 + 2); + goto LABEL_20; + } + } + else + { + if ( v2 == *(float *)v6 && *(float *)v4 == *((float *)v5 + 13) ) + { + v10 = 0; + v11 = *(float *)v3 == *((float *)v5 + 14); +LABEL_20: + if ( v11 | v10 ) + goto LABEL_22; + goto LABEL_21; + } + } +LABEL_21: + ++v23; + v24 += 48; + v26 += 48; + v4 += 48; + v3 += 48; + ++v22; + v25 += 48; + v21 = v4; + v20 = v3; + } +LABEL_22: + if ( v19 ) + { + v12 = v23; + v21 += 48; + v20 += 48; + v13 = 1.0 / (*(float *)v6 + 0.0000001); + ++v22; + v26 += 48; + v24 += 48; + ++v23; + memcpy(v12, v5 + 36, 0x30u); + v14 = v25; + v25 += 48; + v4 = v21; + v3 = v20; + *(float *)v14 = v13; + } + v15 = v17-- == 1; + v18 = v19; + v5 = (char *)v6; + } + while ( !v15 ); + result = v22; + if ( v22 < 3 ) + return 0; + return result; +} + +//----- (004250FE) -------------------------------------------------------- +signed int __fastcall sr_4250FE(unsigned int uVertexID) +{ + unsigned int v1; // edx@1 + char *v2; // edi@5 + char *v3; // esi@5 + char *v4; // ecx@5 + int v5; // ebx@6 + double v6; // st6@11 + double v7; // st5@11 + double v8; // st6@12 + unsigned __int8 v9; // c2@16 + unsigned __int8 v10; // c3@16 + void *v11; // edi@23 + double v12; // st6@23 + char *v13; // ecx@23 + char v14; // zf@24 + signed int result; // eax@25 + unsigned int v16; // [sp+8h] [bp-28h]@5 + bool v17; // [sp+Ch] [bp-24h]@2 + bool v18; // [sp+10h] [bp-20h]@7 + char *v19; // [sp+14h] [bp-1Ch]@5 + char *v20; // [sp+18h] [bp-18h]@5 + signed int v21; // [sp+1Ch] [bp-14h]@1 + RenderVertexSoft *v22; // [sp+20h] [bp-10h]@5 + char *v23; // [sp+24h] [bp-Ch]@5 + char *v24; // [sp+28h] [bp-8h]@5 + char *v25; // [sp+2Ch] [bp-4h]@5 + + v1 = uVertexID; + memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID])); + v21 = 0; + v17 = array_50AC10[0].vWorldViewPosition.x >= 8.0; + if ( (signed int)(uVertexID + 1) <= 1 ) + return 0; + v2 = (char *)&array_507D30[0].vWorldViewPosition.z; + v3 = (char *)&array_507D30[0].vWorldViewPosition.y; + v24 = (char *)&array_507D30[0]._rhw; + v22 = array_507D30; + v19 = (char *)&array_507D30[0].vWorldViewPosition.z; + v20 = (char *)&array_507D30[0].vWorldViewPosition.y; + v23 = (char *)&array_507D30[0].vWorldViewPosition; + v25 = (char *)&array_507D30[0].flt_2C; + v4 = (char *)&array_50AC10[0].vWorldViewPosition; + v16 = v1; + do + { + v5 = (int)(v4 + 48); + v18 = *((float *)v4 + 12) >= 8.0; + if ( v17 != v18 ) + { + if ( v18 ) + { + v6 = (8.0 - *(float *)v4) / (*(float *)v5 - *(float *)v4); + *(float *)v3 = (*((float *)v4 + 13) - *((float *)v4 + 1)) * v6 + *((float *)v4 + 1); + *(float *)v2 = (*((float *)v4 + 14) - *((float *)v4 + 2)) * v6 + *((float *)v4 + 2); + v7 = (*((float *)v4 + 20) - *((float *)v4 + 8)) * v6 + *((float *)v4 + 8); + } + else + { + v8 = (8.0 - *(float *)v5) / (*(float *)v4 - *(float *)v5); + *(float *)v3 = (*((float *)v4 + 1) - *((float *)v4 + 13)) * v8 + *((float *)v4 + 13); + *(float *)v2 = (*((float *)v4 + 2) - *((float *)v4 + 14)) * v8 + *((float *)v4 + 14); + v7 = (*((float *)v4 + 8) - *((float *)v4 + 20)) * v8 + *((float *)v4 + 20); + } + *(float *)v25 = v7; + *(float *)v23 = 8.0; + *(int *)v24 = 0x3E000000u; + if ( v17 ) + { + if ( 8.0 == *(float *)v4 && *(float *)v3 == *((float *)v4 + 1) ) + { + v9 = 0; + v10 = *(float *)v2 == *((float *)v4 + 2); + goto LABEL_20; + } + } + else + { + if ( 8.0 == *(float *)v5 && *(float *)v3 == *((float *)v4 + 13) ) + { + v9 = 0; + v10 = *(float *)v2 == *((float *)v4 + 14); +LABEL_20: + if ( v10 | v9 ) + goto LABEL_22; + goto LABEL_21; + } + } +LABEL_21: + ++v22; + v23 += 48; + v25 += 48; + v3 += 48; + v2 += 48; + ++v21; + v24 += 48; + v20 = v3; + v19 = v2; + } +LABEL_22: + if ( v18 ) + { + v11 = v22; + v20 += 48; + v19 += 48; + v12 = 1.0 / (*(float *)v5 + 0.0000001); + ++v21; + v25 += 48; + v23 += 48; + ++v22; + memcpy(v11, v4 + 36, 0x30u); + v13 = v24; + v24 += 48; + v3 = v20; + v2 = v19; + *(float *)v13 = v12; + } + v14 = v16-- == 1; + v17 = v18; + v4 = (char *)v5; + } + while ( !v14 ); + result = v21; + if ( v21 < 3 ) + return 0; + return result; +} + + +//----- (004254D2) -------------------------------------------------------- +int __fastcall sr_4254D2(signed int a1) +{ + signed int v1; // ebx@2 + int v2; // ecx@2 + int result; // eax@11 + double v4; // ST74_8@12 + bool v5; // edi@12 + char *v6; // esi@13 + char *v7; // ebx@13 + double v8; // st7@15 + double v9; // st7@16 + double v10; // st6@16 + double v11; // st7@17 + float v12; // eax@18 + double v13; // ST4C_8@19 + double v14; // ST10_8@19 + double v15; // ST28_8@20 + double v16; // ST34_8@20 + char v17; // zf@20 + double v18; // ST18_8@21 + double v19; // ST3C_8@21 + double v20; // ST44_8@22 + double v21; // ST54_8@22 + void *v22; // edi@26 + double v23; // ST54_8@29 + bool v24; // esi@29 + char *v25; // edi@30 + char *v26; // ebx@30 + bool v27; // ecx@32 + double v28; // st7@33 + double v29; // st7@34 + double v30; // st6@34 + double v31; // st7@35 + double v32; // ST44_8@37 + double v33; // ST3C_8@37 + double v34; // ST18_8@38 + double v35; // ST34_8@38 + char v36; // zf@38 + double v37; // ST28_8@39 + double v38; // ST10_8@39 + double v39; // ST20_8@40 + double v40; // ST5C_8@40 + void *v41; // edi@44 + double v42; // ST5C_8@47 + bool v43; // edi@47 + char *v44; // esi@48 + char *v45; // ebx@48 + bool v46; // ecx@49 + double v47; // st6@50 + double v48; // st6@51 + double v49; // st5@51 + double v50; // st6@52 + double v51; // ST20_8@54 + double v52; // ST54_8@54 + double v53; // ST44_8@55 + double v54; // ST3C_8@55 + char v55; // zf@55 + double v56; // ST18_8@56 + double v57; // ST34_8@56 + double v58; // ST28_8@57 + double v59; // ST10_8@57 + void *v60; // edi@61 + double v61; // ST5C_8@64 + bool v62; // edi@64 + char *v63; // esi@65 + char *v64; // ebx@65 + bool v65; // ecx@66 + double v66; // st6@67 + double v67; // st6@68 + double v68; // st5@68 + double v69; // st6@69 + double v70; // ST20_8@71 + double v71; // ST54_8@71 + double v72; // ST44_8@72 + double v73; // ST3C_8@72 + char v74; // zf@72 + double v75; // ST18_8@73 + double v76; // ST34_8@73 + double v77; // ST28_8@74 + double v78; // ST10_8@74 + void *v79; // edi@78 + int v80; // ebx@81 + char *v81; // ecx@82 + signed int v82; // esi@82 + float v83; // ST78_4@83 + double v84; // ST5C_8@83 + float v85; // eax@84 + double v86; // ST20_8@85 + double v87; // ST54_8@88 + float v88; // eax@89 + double v89; // ST44_8@90 + unsigned __int8 v90; // sf@94 + unsigned __int8 v91; // of@94 + int v92; // edx@97 + int v93; // esi@97 + int v94; // edi@97 + int v95; // eax@97 + int v96; // eax@104 + double v97; // [sp+4Ch] [bp-8Ch]@32 + double v98; // [sp+54h] [bp-84h]@49 + double v99; // [sp+54h] [bp-84h]@66 + float v100; // [sp+5Ch] [bp-7Ch]@1 + float v101; // [sp+60h] [bp-78h]@1 + float v102; // [sp+64h] [bp-74h]@1 + double v103; // [sp+6Ch] [bp-6Ch]@14 + float v104; // [sp+A8h] [bp-30h]@1 + signed int v105; // [sp+A8h] [bp-30h]@96 + bool v106; // [sp+ACh] [bp-2Ch]@14 + bool v107; // [sp+ACh] [bp-2Ch]@32 + bool v108; // [sp+ACh] [bp-2Ch]@49 + bool v109; // [sp+ACh] [bp-2Ch]@66 + signed int v110; // [sp+B0h] [bp-28h]@12 + char *v111; // [sp+B8h] [bp-20h]@30 + signed int v112; // [sp+B8h] [bp-20h]@48 + signed int v113; // [sp+B8h] [bp-20h]@65 + char *v114; // [sp+BCh] [bp-1Ch]@13 + signed int v115; // [sp+BCh] [bp-1Ch]@29 + signed int v116; // [sp+BCh] [bp-1Ch]@64 + signed int v117; // [sp+C0h] [bp-18h]@1 + char *v118; // [sp+C0h] [bp-18h]@30 + char *v119; // [sp+C0h] [bp-18h]@48 + char *v120; // [sp+C0h] [bp-18h]@65 + char *v121; // [sp+C4h] [bp-14h]@13 + char *v122; // [sp+C4h] [bp-14h]@30 + signed int v123; // [sp+C4h] [bp-14h]@47 + char *v124; // [sp+C8h] [bp-10h]@30 + char *v125; // [sp+C8h] [bp-10h]@48 + char *v126; // [sp+C8h] [bp-10h]@65 + signed int v127; // [sp+CCh] [bp-Ch]@2 + char *v128; // [sp+CCh] [bp-Ch]@13 + char *v129; // [sp+CCh] [bp-Ch]@30 + RenderVertexSoft *v130; // [sp+CCh] [bp-Ch]@48 + RenderVertexSoft *v131; // [sp+CCh] [bp-Ch]@65 + RenderVertexSoft *v132; // [sp+D0h] [bp-8h]@13 + char *v133; // [sp+D0h] [bp-8h]@30 + char *v134; // [sp+D0h] [bp-8h]@48 + char *v135; // [sp+D0h] [bp-8h]@65 + signed int v136; // [sp+D4h] [bp-4h]@1 + char *v137; // [sp+D4h] [bp-4h]@13 + RenderVertexSoft *v138; // [sp+D4h] [bp-4h]@30 + char *v139; // [sp+D4h] [bp-4h]@48 + char *v140; // [sp+D4h] [bp-4h]@65 + + v101 = (double)(signed int)pViewport->uViewportTL_X; + v100 = (double)(signed int)pViewport->uViewportBR_X; + v117 = a1; + v136 = 1; + v104 = (double)(signed int)pViewport->uViewportTL_Y; + v102 = (double)(pViewport->uViewportBR_Y + 1); + if ( a1 <= 0 ) + return v117; + v127 = a1; + v1 = a1; + memcpy(sr_508690, array_50AC10, 4 * ((unsigned int)(48 * a1) >> 2)); + v2 = 0; + do + { + if ( array_50AC10[v2].vWorldViewProjX < (double)v101 || array_50AC10[v2].vWorldViewProjX > (double)v100 ) + v136 = 0; + if ( *(float *)(v2 * 48 + 5286956) < (double)v104 || *(float *)(v2 * 48 + 5286956) > (double)v102 ) + v136 = 0; + ++v2; + --v127; + } + while ( v127 ); + if ( v136 ) + return v117; + v110 = 0; + memcpy(&array_50AC10[v1], array_50AC10, sizeof(array_50AC10[v1])); + v4 = array_50AC10[0].vWorldViewProjX + 6.7553994e15; + v5 = SLODWORD(v4) >= (signed int)pViewport->uViewportTL_X; + if ( v117 < 1 ) + goto LABEL_112; + v6 = (char *)&array_50A2B0[0].vWorldViewProjY; + v132 = array_50A2B0; + v137 = (char *)&array_50A2B0[0].vWorldViewProjX; + v128 = (char *)&array_50A2B0[0].vWorldViewProjY; + v121 = (char *)&array_50A2B0[0].flt_2C; + v114 = (char *)&array_50A2B0[0]._rhw; + v7 = (char *)&array_50AC10[0].flt_2C; + do + { + v103 = *((float *)v7 + 7) + 6.7553994e15; + v106 = SLODWORD(v103) >= (signed int)pViewport->uViewportTL_X; + if ( !(v5 ^ v106) ) + goto LABEL_25; + v8 = v101; + if ( SLODWORD(v103) >= (signed int)pViewport->uViewportTL_X ) + { + v9 = (v8 - *((float *)v7 - 5)) / (*((float *)v7 + 7) - *((float *)v7 - 5)); + *(float *)v6 = (*((float *)v7 + 8) - *((float *)v7 - 4)) * v9 + *((float *)v7 - 4); + *(float *)v114 = (*((float *)v7 + 9) - *((float *)v7 - 3)) * v9 + *((float *)v7 - 3); + v10 = (*((float *)v7 + 12) - *(float *)v7) * v9 + *(float *)v7; + } + else + { + v11 = (v8 - *((float *)v7 + 7)) / (*((float *)v7 - 5) - *((float *)v7 + 7)); + *(float *)v6 = (*((float *)v7 - 4) - *((float *)v7 + 8)) * v11 + *((float *)v7 + 8); + *(float *)v114 = (*((float *)v7 - 3) - *((float *)v7 + 9)) * v11 + *((float *)v7 + 9); + v10 = (*(float *)v7 - *((float *)v7 + 12)) * v11 + *((float *)v7 + 12); + } + *(float *)v121 = v10; + *(int *)v137 = LODWORD(v101); + LODWORD(v12) = *(int *)v6; + if ( v5 ) + { + v13 = v12 + 6.7553994e15; + v14 = *((float *)v7 - 4) + 6.7553994e15; + if ( LODWORD(v13) == LODWORD(v14) ) + { + v15 = *(float *)v137 + 6.7553994e15; + v16 = *((float *)v7 - 5) + 6.7553994e15; + v17 = LODWORD(v15) == LODWORD(v16); + goto LABEL_23; + } + } + else + { + v18 = v12 + 6.7553994e15; + v19 = *((float *)v7 + 8) + 6.7553994e15; + if ( LODWORD(v18) == LODWORD(v19) ) + { + v20 = *(float *)v137 + 6.7553994e15; + v21 = *((float *)v7 + 7) + 6.7553994e15; + v17 = LODWORD(v20) == LODWORD(v21); +LABEL_23: + if ( v17 ) + goto LABEL_25; + goto LABEL_24; + } + } +LABEL_24: + v121 += 48; + v114 += 48; + v6 += 48; + ++v110; + ++v132; + v128 = v6; + v137 += 48; +LABEL_25: + if ( v106 ) + { + v22 = v132; + v128 += 48; + ++v110; + v114 += 48; + v121 += 48; + v137 += 48; + ++v132; + memcpy(v22, v7 + 4, 0x30u); + v6 = v128; + } + v5 = v106; + v7 += 48; + --v117; + } + while ( v117 ); + if ( v110 < 3 + || (v115 = 0, + memcpy(&array_50A2B0[v110], array_50A2B0, sizeof(array_50A2B0[v110])), + v23 = array_50A2B0[0].vWorldViewProjX + 6.7553994e15, + v24 = SLODWORD(v23) <= (signed int)pViewport->uViewportBR_X, + v110 < 1) ) + goto LABEL_112; + v25 = (char *)&array_509950[0]._rhw; + v138 = array_509950; + v129 = (char *)&array_50A2B0[0].vWorldViewProjX; + v118 = (char *)&array_50A2B0[0].vWorldViewProjY; + v133 = (char *)&array_509950[0].vWorldViewProjX; + v122 = (char *)&array_509950[0].vWorldViewProjY; + v124 = (char *)&array_509950[0].flt_2C; + v111 = (char *)&array_509950[0]._rhw; + v26 = (char *)&array_50A2B0[0].flt_2C; + while ( 2 ) + { + v97 = *((float *)v26 + 7) + 6.7553994e15; + v27 = SLODWORD(v97) <= (signed int)pViewport->uViewportBR_X; + v107 = SLODWORD(v97) <= (signed int)pViewport->uViewportBR_X; + if ( v24 != v27 ) + { + v28 = v100; + if ( SLODWORD(v97) <= (signed int)pViewport->uViewportBR_X ) + { + v29 = (v28 - *((float *)v26 - 5)) / (*((float *)v26 + 7) - *((float *)v26 - 5)); + *(float *)v122 = (*((float *)v26 + 8) - *((float *)v26 - 4)) * v29 + *((float *)v26 - 4); + *(float *)v25 = (*((float *)v26 + 9) - *((float *)v26 - 3)) * v29 + *((float *)v26 - 3); + v30 = (*((float *)v26 + 12) - *(float *)v26) * v29 + *(float *)v26; + } + else + { + v31 = (v28 - *((float *)v26 + 7)) / (*((float *)v26 - 5) - *((float *)v26 + 7)); + *(float *)v122 = (*((float *)v26 - 4) - *((float *)v26 + 8)) * v31 + *((float *)v26 + 8); + *(float *)v25 = (*((float *)v26 - 3) - *((float *)v26 + 9)) * v31 + *((float *)v26 + 9); + v30 = (*(float *)v26 - *((float *)v26 + 12)) * v31 + *((float *)v26 + 12); + } + *(float *)v124 = v30; + *(int *)v133 = LODWORD(v100); + if ( v24 ) + { + v32 = *(float *)v122 + 6.7553994e15; + v33 = *((float *)v26 - 4) + 6.7553994e15; + if ( LODWORD(v32) == LODWORD(v33) ) + { + v34 = *(float *)v133 + 6.7553994e15; + v35 = *((float *)v26 - 5) + 6.7553994e15; + v36 = LODWORD(v34) == LODWORD(v35); + goto LABEL_41; + } + goto LABEL_42; + } + v37 = *(float *)v118 + 6.7553994e15; + v38 = *((float *)v26 + 8) + 6.7553994e15; + if ( LODWORD(v37) != LODWORD(v38) ) + goto LABEL_42; + v39 = *(float *)v129 + 6.7553994e15; + v40 = *((float *)v26 + 7) + 6.7553994e15; + v36 = LODWORD(v39) == LODWORD(v40); +LABEL_41: + if ( !v36 ) + { +LABEL_42: + v129 += 48; + v118 += 48; + v133 += 48; + v122 += 48; + v124 += 48; + v111 += 48; + ++v115; + ++v138; + } + } + if ( v27 ) + { + v41 = v138; + ++v115; + v111 += 48; + v124 += 48; + v122 += 48; + v133 += 48; + v118 += 48; + v129 += 48; + ++v138; + memcpy(v41, v26 + 4, 0x30u); + } + v24 = v107; + v26 += 48; + --v110; + if ( v110 ) + { + v25 = v111; + continue; + } + break; + } + if ( v115 < 3 + || (v123 = 0, + memcpy(&array_509950[v115], array_509950, sizeof(array_509950[v115])), + v42 = array_509950[0].vWorldViewProjY + 6.7553994e15, + v43 = SLODWORD(v42) >= (signed int)pViewport->uViewportTL_Y, + v115 < 1) ) + goto LABEL_112; + v44 = (char *)&array_508FF0[0].vWorldViewProjX; + v130 = array_508FF0; + v119 = (char *)&array_508FF0[0].vWorldViewProjX; + v139 = (char *)&array_508FF0[0].vWorldViewProjY; + v125 = (char *)&array_508FF0[0].flt_2C; + v134 = (char *)&array_508FF0[0]._rhw; + v45 = (char *)&array_509950[0].flt_2C; + v112 = v115; + while ( 2 ) + { + v98 = *((float *)v45 + 8) + 6.7553994e15; + v46 = SLODWORD(v98) >= (signed int)pViewport->uViewportTL_Y; + v108 = SLODWORD(v98) >= (signed int)pViewport->uViewportTL_Y; + if ( v43 != v46 ) + { + v47 = v104; + if ( SLODWORD(v98) >= (signed int)pViewport->uViewportTL_Y ) + { + v48 = (v47 - *((float *)v45 - 4)) / (*((float *)v45 + 8) - *((float *)v45 - 4)); + *(float *)v44 = (*((float *)v45 + 7) - *((float *)v45 - 5)) * v48 + *((float *)v45 - 5); + *(float *)v134 = (*((float *)v45 + 9) - *((float *)v45 - 3)) * v48 + *((float *)v45 - 3); + v49 = (*((float *)v45 + 12) - *(float *)v45) * v48 + *(float *)v45; + } + else + { + v50 = (v47 - *((float *)v45 + 8)) / (*((float *)v45 - 4) - *((float *)v45 + 8)); + *(float *)v44 = (*((float *)v45 - 5) - *((float *)v45 + 7)) * v50 + *((float *)v45 + 7); + *(float *)v134 = (*((float *)v45 - 3) - *((float *)v45 + 9)) * v50 + *((float *)v45 + 9); + v49 = (*(float *)v45 - *((float *)v45 + 12)) * v50 + *((float *)v45 + 12); + } + *(float *)v125 = v49; + *(float *)v139 = v104; + if ( v43 ) + { + v51 = v104 + 6.7553994e15; + v52 = *((float *)v45 - 4) + 6.7553994e15; + if ( LODWORD(v51) == LODWORD(v52) ) + { + v53 = *(float *)v44 + 6.7553994e15; + v54 = *((float *)v45 - 5) + 6.7553994e15; + v55 = LODWORD(v53) == LODWORD(v54); + goto LABEL_58; + } + goto LABEL_59; + } + v56 = v104 + 6.7553994e15; + v57 = *((float *)v45 + 8) + 6.7553994e15; + if ( LODWORD(v56) != LODWORD(v57) ) + goto LABEL_59; + v58 = *(float *)v44 + 6.7553994e15; + v59 = *((float *)v45 + 7) + 6.7553994e15; + v55 = LODWORD(v58) == LODWORD(v59); +LABEL_58: + if ( !v55 ) + { +LABEL_59: + v139 += 48; + v125 += 48; + v134 += 48; + v44 += 48; + ++v123; + ++v130; + v119 = v44; + } + } + if ( v46 ) + { + v60 = v130; + v119 += 48; + ++v123; + v134 += 48; + v125 += 48; + v139 += 48; + ++v130; + memcpy(v60, v45 + 4, 0x30u); + v44 = v119; + } + v43 = v108; + v45 += 48; + --v112; + if ( v112 ) + continue; + break; + } + if ( v123 < 3 + || (v116 = 0, + memcpy(&array_508FF0[v123], array_508FF0, sizeof(array_508FF0[v123])), + v61 = array_508FF0[0].vWorldViewProjY + 6.7553994e15, + v62 = SLODWORD(v61) <= (signed int)pViewport->uViewportBR_Y, + v123 < 1) ) + goto LABEL_112; + v63 = (char *)&sr_508690[0].vWorldViewProjX; + v131 = sr_508690; + v120 = (char *)&sr_508690[0].vWorldViewProjX; + v140 = (char *)&sr_508690[0].vWorldViewProjY; + v126 = (char *)&sr_508690[0].flt_2C; + v135 = (char *)&sr_508690[0]._rhw; + v64 = (char *)&array_508FF0[0].flt_2C; + v113 = v123; + while ( 2 ) + { + v99 = *((float *)v64 + 8) + 6.7553994e15; + v65 = SLODWORD(v99) <= (signed int)pViewport->uViewportBR_Y; + v109 = SLODWORD(v99) <= (signed int)pViewport->uViewportBR_Y; + if ( v62 != v65 ) + { + v66 = v102; + if ( SLODWORD(v99) <= (signed int)pViewport->uViewportBR_Y ) + { + v67 = (v66 - *((float *)v64 - 4)) / (*((float *)v64 + 8) - *((float *)v64 - 4)); + *(float *)v63 = (*((float *)v64 + 7) - *((float *)v64 - 5)) * v67 + *((float *)v64 - 5); + *(float *)v135 = (*((float *)v64 + 9) - *((float *)v64 - 3)) * v67 + *((float *)v64 - 3); + v68 = (*((float *)v64 + 12) - *(float *)v64) * v67 + *(float *)v64; + } + else + { + v69 = (v66 - *((float *)v64 + 8)) / (*((float *)v64 - 4) - *((float *)v64 + 8)); + *(float *)v63 = (*((float *)v64 - 5) - *((float *)v64 + 7)) * v69 + *((float *)v64 + 7); + *(float *)v135 = (*((float *)v64 - 3) - *((float *)v64 + 9)) * v69 + *((float *)v64 + 9); + v68 = (*(float *)v64 - *((float *)v64 + 12)) * v69 + *((float *)v64 + 12); + } + *(float *)v126 = v68; + *(float *)v140 = v102; + if ( v62 ) + { + v70 = v102 + 6.7553994e15; + v71 = *((float *)v64 - 4) + 6.7553994e15; + if ( LODWORD(v70) == LODWORD(v71) ) + { + v72 = *(float *)v63 + 6.7553994e15; + v73 = *((float *)v64 - 5) + 6.7553994e15; + v74 = LODWORD(v72) == LODWORD(v73); + goto LABEL_75; + } + goto LABEL_76; + } + v75 = v102 + 6.7553994e15; + v76 = *((float *)v64 + 8) + 6.7553994e15; + if ( LODWORD(v75) != LODWORD(v76) ) + goto LABEL_76; + v77 = *(float *)v63 + 6.7553994e15; + v78 = *((float *)v64 + 7) + 6.7553994e15; + v74 = LODWORD(v77) == LODWORD(v78); +LABEL_75: + if ( !v74 ) + { +LABEL_76: + v140 += 48; + v126 += 48; + v135 += 48; + v63 += 48; + ++v116; + ++v131; + v120 = v63; + } + } + if ( v65 ) + { + v79 = v131; + v120 += 48; + ++v116; + v135 += 48; + v126 += 48; + v140 += 48; + ++v131; + memcpy(v79, v64 + 4, 0x30u); + v63 = v120; + } + v62 = v109; + v64 += 48; + --v113; + if ( v113 ) + continue; + break; + } + if ( v116 < 3 ) + goto LABEL_112; + v80 = v116; + memcpy(&sr_508690[v116], sr_508690, sizeof(sr_508690[v116])); + if ( v116 > 0 ) + { + v81 = (char *)&sr_508690[0].vWorldViewProjX; + v82 = v116; + do + { + LODWORD(v83) = *(int *)v81; + *((float *)v81 - 3) = 1.0 / *((float *)v81 + 2); + v84 = v83 + 6.7553994e15; + if ( SLODWORD(v84) <= (signed int)pViewport->uViewportBR_X ) + { + v86 = *(float *)v81 + 6.7553994e15; + if ( SLODWORD(v86) >= (signed int)pViewport->uViewportTL_X ) + goto LABEL_88; + v85 = v101; + } + else + { + v85 = v100; + } + *(int *)v81 = LODWORD(v85); +LABEL_88: + v87 = *((float *)v81 + 1) + 6.7553994e15; + if ( SLODWORD(v87) > (signed int)pViewport->uViewportBR_Y ) + { + v88 = v102; +LABEL_92: + *((int *)v81 + 1) = LODWORD(v88); + goto LABEL_93; + } + v89 = *((float *)v81 + 1) + 6.7553994e15; + if ( SLODWORD(v89) < (signed int)pViewport->uViewportTL_Y ) + { + v88 = v104; + goto LABEL_92; + } +LABEL_93: + v81 += 48; + --v82; + } + while ( v82 ); + } + v91 = __OFSUB__(v116, 3); + v90 = v116 - 3 < 0; + if ( v116 > 3 ) + { + memcpy(&sr_508690[v116 + 1], &sr_508690[1], sizeof(sr_508690[v116 + 1])); + if ( v116 > 0 ) + { + v105 = 1; + do + { + v92 = v105; + v93 = v105 - 1; + v94 = v105 + 1; + v95 = v105 + 1; + if ( v105 - 1 >= v80 ) + v93 -= v80; + if ( v105 >= v80 ) + v92 = v105 - v80; + if ( v94 >= v80 ) + v95 = v94 - v80; + if ( (sr_508690[v92].vWorldViewProjX - sr_508690[v93].vWorldViewProjX) + * (sr_508690[v95].vWorldViewProjY - sr_508690[v93].vWorldViewProjY) + - (sr_508690[v95].vWorldViewProjX - sr_508690[v93].vWorldViewProjX) + * (sr_508690[v92].vWorldViewProjY - sr_508690[v93].vWorldViewProjY) < 0.0 ) + { + ++v105; + } + else + { + v96 = v105; + if ( v105 < v80 || (v96 = v105 - v80, v105 - v80 < v80) ) + memcpy(&sr_508690[v96], &sr_508690[v96 + 1], 4 * ((unsigned int)(48 * v80 - 48 * v96) >> 2)); + --v80; + } + } + while ( v105 - 1 < v80 ); + } + v91 = __OFSUB__(v80, 3); + v90 = v80 - 3 < 0; + } + if ( v90 ^ v91 ) +LABEL_112: + result = 0; + else + result = v80; + return result; +} + +//----- (0048034E) -------------------------------------------------------- +void Render::DrawTerrainD3D(int a1, int a2, int a3, int unk4) +{ + //int v3; // esi@1 + int v4; // edi@1 + int v5; // ebx@2 + int v6; // eax@2 + int v7; // eax@3 + RenderVertexSoft *v8; // edi@3 + RenderVertexSoft *v9; // ebx@4 + RenderVertexSoft *v10; // ecx@4 + float v11; // eax@6 + double v12; // ST5C_8@6 + double v13; // ST2C_8@6 + int v14; // eax@6 + double v15; // st7@6 + struct Polygon *pTile; // ebx@12 + unsigned __int16 v17; // ax@12 + int v18; // eax@13 + signed int v22; // eax@13 + Vec3_float_ *norm; // eax@15 + //double v24; // st6@17 + double v25; // ST54_8@17 + unsigned __int8 v26; // sf@17 + unsigned __int8 v27; // of@17 + double v28; // st5@19 + double v29; // st5@19 + double v30; // st5@19 + double v31; // st5@19 + struct struct8 *v32; // esi@21 + double v3a; // st7@32 + int v33; // edi@38 + unsigned int v34; // ecx@47 + char v35; // zf@47 + unsigned int v36; // eax@50 + int v37; // eax@54 + //Polygon *v38; // ecx@55 + unsigned int v39; // eax@59 + struct Polygon *v40; // ebx@62 + unsigned __int16 pTileBitmapsID; // ax@62 + int v42; // eax@63 + LightmapBuilder *v43; // ecx@63 + int v44; // eax@63 + int v45; // eax@63 + int v46; // eax@63 + signed int v47; // eax@63 + Vec3_float_ *v48; // eax@65 + double v49; // st6@67 + double v50; // ST4C_8@67 + double v51; // st5@71 + double v52; // st5@71 + double v53; // st5@71 + double v54; // st7@84 + unsigned int v55; // ecx@98 + unsigned int v56; // eax@101 + int v57; // eax@105 + unsigned int v58; // eax@109 + struct Polygon *v59; // esi@112 + unsigned __int16 v60; // ax@112 + int v61; // eax@113 + signed int v62; // eax@113 + Vec3_float_ *v63; // eax@114 + double v64; // st6@116 + double v65; // ST3C_8@116 + double v66; // st5@120 + double v67; // st5@120 + double v68; // st5@120 + double v69; // st7@133 + int v70; // edi@138 + struct Polygon *v71; // esi@147 + unsigned int v72; // ecx@147 + unsigned int v73; // eax@150 + int v74; // eax@154 + unsigned int v75; // eax@158 + //unsigned int v76; // [sp-10h] [bp-E0h]@61 + int v77; // [sp-Ch] [bp-DCh]@61 + IDirect3DTexture2 *v78; // [sp-8h] [bp-D8h]@61 + //int v79; // [sp-4h] [bp-D4h]@61 + bool v80; // [sp+0h] [bp-D0h]@59 + bool v81; // [sp+0h] [bp-D0h]@109 + int v82; // [sp+54h] [bp-7Ch]@1 + int v83; // [sp+60h] [bp-70h]@1 + int v84; // [sp+6Ch] [bp-64h]@1 + int v85; // [sp+70h] [bp-60h]@63 + float a4; // [sp+74h] [bp-5Ch]@73 + float v87; // [sp+78h] [bp-58h]@122 + int v88; // [sp+7Ch] [bp-54h]@1 + int v89; // [sp+80h] [bp-50h]@6 + int v93; // [sp+90h] [bp-40h]@2 + int X; // [sp+94h] [bp-3Ch]@1 + float v95; // [sp+98h] [bp-38h]@21 + LightmapBuilder *v96; // [sp+9Ch] [bp-34h]@73 + int v97; // [sp+A0h] [bp-30h]@6 + int sX; // [sp+A4h] [bp-2Ch]@6 + unsigned int uNumVertices; // [sp+A8h] [bp-28h]@73 + int v100; // [sp+ACh] [bp-24h]@122 + int sY; // [sp+B0h] [bp-20h]@6 + RenderVertexSoft *v102; // [sp+B4h] [bp-1Ch]@3 + unsigned int a5; // [sp+B8h] [bp-18h]@21 + RenderVertexSoft *v101; // [sp+BCh] [bp-14h]@6 + Vec3_float_ *v99; // [sp+C0h] [bp-10h]@17 + RenderVertexSoft *pVertices; // [sp+C4h] [bp-Ch]@6 + RenderVertexSoft *pVertices2; // [sp+C8h] [bp-8h]@6 + char v108; // [sp+CFh] [bp-1h]@36 + float thisd; // [sp+D8h] [bp+8h]@6 + float thise; // [sp+D8h] [bp+8h]@6 + float thisf; // [sp+D8h] [bp+8h]@17 + IndoorCameraD3D *thisa; // [sp+D8h] [bp+8h]@23 + float thisg; // [sp+D8h] [bp+8h]@67 + IndoorCameraD3D *thisb; // [sp+D8h] [bp+8h]@75 + float thish; // [sp+D8h] [bp+8h]@116 + IndoorCameraD3D *thisc; // [sp+D8h] [bp+8h]@124 + char this_3; // [sp+DBh] [bp+Bh]@30 + char this_3a; // [sp+DBh] [bp+Bh]@82 + char this_3b; // [sp+DBh] [bp+Bh]@131 + + __debugbreak(); + static stru154 static_sub_0048034E_stru_154; + static stru154 stru_76D5A8; + //v3 = a1; + v82 = a2; + v83 = a3; + X = abs(unk4); + v4 = 0; + v88 = 0; + v84 = a1 - 1; + if ( a1 - 1 > 0 ) + { + while ( 1 ) + { + v5 = abs(X);//v5 = 13108 + v6 = abs(v83);//v6 = 13108 + --X; + //__debugbreak(); // uncoment & refactor following large if + v93 = (int)&terrain_76E5C8[(v5 << 7) + v6]; + if ( !v93->field_0 || ((v7 = 48 * v4, v8 = &pVerticesSR_806210[v4], a2 = v8, !v82) ? (v9 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7), + v10 = &pVerticesSR_806210[1] + v7) : (v9 = &pVerticesSR_806210[1] + v7, v10 = (RenderVertexSoft *)((char *)&pVerticesSR_801A10 + v7)), + ((a8 = v9, + pVertices = &pVerticesSR_801A10[1] + v7, + v11 = v8->vWorldPosition.x, + v101 = v10, + v12 = v11 + 6.755399441055744e15, + sX = LODWORD(v12), + v13 = v8->vWorldPosition.y + 6.755399441055744e15, + sY = LODWORD(v13), + thisd = (v10->vWorldPosition.x + v8->vWorldPosition.x) * 0.5, + v14 = WorldPosToGridCellX(floorf(thisd + 0.5f)),//maybe current camera position X + v15 = v9->vWorldPosition.y + v8->vWorldPosition.y, + v89 = v14, + thise = v15 * 0.5, + _this = (LightmapBuilder *)WorldPosToGridCellZ(floorf(thisd + 0.5f)),//maybe current camera position Z + WorldPosToGridCellX(sX), + WorldPosToGridCellZ(sY), + !byte_4D864C) + || !(pGame->uFlags & 0x80)) + && !_481EFA_clip_terrain_poly(v8, v9, v101, pVertices, 1)) ) + if ( !&terrain_76E5C8[(v5 << 7) + v6] ) + goto LABEL_162 + v8 = &pVerticesSR_806210[v4]; + //pVertices2 = &pVerticesSR_801A10[v4 + 1]; + //v102 = v8; + if (!v82) + { + pVertices = &pVerticesSR_801A10[v4]; + v101 = &pVerticesSR_806210[v4 + 1]; + } + else + { + pVertices = &pVerticesSR_801A10[v4 + 1]; + v101 = &pVerticesSR_806210[v4]; + } + sX = floorf(v8->vWorldPosition.x + 0.5f); + sY = floorf(v8->vWorldPosition.z + 0.5f); + v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); + v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); + /*WorldPosToGridCellX(sX); + WorldPosToGridCellZ(sY); + if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !_481EFA_clip_terrain_poly(v8, pVertices, v101, pVertices2, 1)) + if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y + || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) + break; + pTile = &array_77EC08[pOutdoorCamera->uNumPolygons]; + pTile->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( pTile->uTileBitmapID != -1 ) + { + pTile->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); + pTile->field_32 = 0; + pTile->field_59 = 1; + pTile->terrain_grid_x = (char)v97; + __debugbreak(); // warning C4700: uninitialized local variable 'v93' used + pTile->field_34 = *(_WORD *)(v93 + 2); + pTile->terrain_grid_z = v89; + v22 = pTerrainNormalIndices[2 * (v97 + 128 * v89) + 1]; + if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) + norm = 0; + else + norm = &pTerrainNormals[v22]; + thisf = 20.0 - ( -(((float)pOutdoor->vSunlight.x / 65536.0) * norm->x) - + (((float)pOutdoor->vSunlight.y / 65536.0) * norm->y) - + (((float)pOutdoor->vSunlight.z / 65536.0) * norm->z)) * 20.0; + //v25 = thisf + 6.7553994e15; + //v27 = pOutdoorCamera->uNumPolygons > 1999; + //v26 = pOutdoorCamera->uNumPolygons - 1999 < 0; + pTile->dimming_level = floorf(thisf + 0.5f); + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + //if ( !_481FC9_terrain(v8, pVertices, v101, v16) )//Ritor1: It's temporary + //goto LABEL_126; + //{ + //--pOutdoorCamera->uNumPolygons; + //goto LABEL_162; + //} + __debugbreak(); // warning C4700: uninitialized local variable 'v102' used + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + __debugbreak(); // warning C4700: uninitialized local variable 'pVertices2' used + memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); + array_50AC10[3]._rhw = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[3].u = 1.0; + array_50AC10[3].v = 0.0; + if ( !(byte_76D5C0 & 1) ) + { + byte_76D5C0 |= 1u; + stru154(stru_76D5A8); + atexit(loc_481199); + } + v32 = (struct8 *)array_50AC10; + v97 = (int)pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(norm, &v95, array_50AC10, 4, 1); + pDecalBuilder->_49BE8A(pTile, norm, &v95, array_50AC10, 4, 1); + a5 = 4; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisa = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) + goto LABEL_162; + thisa->ViewTransform(array_50AC10, a5); + thisa->Project(array_50AC10, a5, 0); + } + this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 + || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; + v3a = (double)pOutdoorCamera->shading_dist_mist; + v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x + || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; + v33 = 0; + pGame->pLightmapBuilder->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3 ) + v33 = 3; + else + v33 = v108 != 0 ? 5 : 0; + static_sub_0048034E_stru_154.ClassifyPolygon(norm, v95); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - pTile->dimming_level, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); + v34 = a5; + //v35 = byte_4D864C == 0; + pTile->uNumVertices = a5; + if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) + { + if ( this_3 ) + { + v36 = sr_424CD7(v34); + pTile->uNumVertices = v36; + OutdoorCamera::Project(v36); + } + if ( v108 ) + { + v36 = sr_424EE0_MakeFanFromTriangle(v34); + pTile->uNumVertices = v36; + OutdoorCamera::Project(v36); + } + } + //v37 = *(int *)&v16->flags; + if ( ~pTile->flags & 1 ) + { + if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v80 = false; + v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v39 = pTile->uTileBitmapID; + v80 = true; + } + //v79 = 0; + //v78 = pBitmaps_LOD->pHardwareTextures[v39]; + pTile->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary + v77 = (int)pTile; + //v76 = v16->uNumVertices; +//LABEL_161: + pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v39], false, v80); + goto LABEL_162; + } +LABEL_56: + pTile->DrawBorderTiles(); + } +LABEL_162: + v4 = v88 + 1; + if ( ++v88 >= v84 ) + return; + } + v40 = &array_77EC08[pOutdoorCamera->uNumPolygons]; + v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( v40->uTileBitmapID == -1 ) + goto LABEL_162; + v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); + BYTE1(v42) |= 0x80u; + v43 = pGame->pLightmapBuilder; + *(int *)&v40->flags = v42; + v44 = v93; + v40->field_59 = 1; + v40->terrain_grid_x = (char)v43; + v40->field_34 = *(_WORD *)(v44 + 2); + v45 = v89; + v40->terrain_grid_z = v89; + v46 = 4 * ((char)v43 + (v45 << 7)); + v85 = v46; + v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; + if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) + v48 = 0; + else + v48 = &pTerrainNormals[v47]; + v49 = v92 * v48->y; + //v99 = v48; + thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; + v50 = thisg + 6.755399441055744e15; + v40->dimming_level = LOBYTE(v50); + if ( LOBYTE(v50) < 0 ) + v40->dimming_level = 0; + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + if ( !_481FC9_terrain(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary + //goto LABEL_77; + { + --pOutdoorCamera->uNumPolygons; + goto LABEL_112; + } + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + static stru154 static_sub_0048034E_stru_76D590; + static bool __init_flag2 = false; + if (!__init_flag2) + { + __init_flag2 = true; + stru154::stru154(&static_sub_0048034E_stru_76D590); + } + if ( !(byte_76D5C0 & 2) ) + { + byte_76D5C0 |= 2; + Polygon(stru_76D590); + atexit(loc_48118F); + } + v96 = pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); + pDecalBuilder->_49BE8A(v40, v48, &a4, array_50AC10, 3, 0); + uNumVertices = 3; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisb = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) + { +//LABEL_77: + --pOutdoorCamera->uNumPolygons; + goto LABEL_112; + } + thisb->ViewTransform(array_50AC10, uNumVertices); + thisb->Project(array_50AC10, uNumVertices, 0); + } + this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; + v54 = (double)pOutdoorCamera->shading_dist_mist; + v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; + pVertices = 0; + v96->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3a ) + pVertices = (RenderVertexSoft *)3; + else + pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); + //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); + static_sub_0048034E_stru_76D590.ClassifyPolygon(v48, *(float *)&a4); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); + v55 = uNumVertices; + //v35 = byte_4D864C == 0; + v40->uNumVertices = uNumVertices; + if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) + { + if ( this_3a ) + { + v56 = sr_424CD7(v55); + } + else + { + if ( !v108 ) + goto LABEL_105; + v56 = sr_424EE0_MakeFanFromTriangle(v55); + } + v40->uNumVertices = v56; + OutdoorCamera::Project(v56); + } +LABEL_105: + v57 = *(int *)&v40->flags; + if ( BYTE1(v57) & 1 ) + { + v40->DrawBorderTiles(); + } + else + { + if ( v57 & 2 && v40->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v81 = false; + v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v58 = v40->uTileBitmapID; + v81 = true; + } + pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); + } +LABEL_112: + v59 = &array_77EC08[pOutdoorCamera->uNumPolygons]; + //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->uNumPolygons]; + v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( v59->uTileBitmapID == -1 ) + goto LABEL_162; + *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); + v61 = v93; + v59->field_59 = 1; + v59->field_34 = *(_WORD *)(v61 + 2); + v59->terrain_grid_z = v89; + v59->terrain_grid_x = v97; + v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); + if ( v62 > (signed int)(uNumTerrainNormals - 1) ) + v63 = 0; + else + v63 = &pTerrainNormals[v62]; + v64 = v92 * v63->y; + //v99 = v63; + thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; + v59->dimming_level = floorf(thish + 0.5f); + if ( v59->dimming_level < 0 ) + v59->dimming_level = 0; + if ( pOutdoorCamera->uNumPolygons >= 1999 ) + return; + ++pOutdoorCamera->uNumPolygons; + if ( !_481FC9_terrain(v101, v102, pVertices2, v59) ) + { +//LABEL_126: + --pOutdoorCamera->uNumPolygons; + goto LABEL_162; + } + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0]._rhw = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); + array_50AC10[1]._rhw = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1].u = 1.0; + array_50AC10[1].v = 1.0; + memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); + array_50AC10[2]._rhw = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 0.0; + static stru154 static_sub_0048034E_stru_76D578; + static bool __init_flag1 = false; + if (!__init_flag1) + { + __init_flag1 = true; + stru154::stru154(&static_sub_0048034E_stru_76D578); + } + v96 = pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); + pDecalBuilder->_49BE8A(v40, v63, &v87, array_50AC10, 3, 1); + v100 = 3; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisc = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) + //goto LABEL_126; + { + --pOutdoorCamera->uNumPolygons; + goto LABEL_162; + } + thisc->ViewTransform(array_50AC10, v100); + thisc->Project(array_50AC10, v100, 0); + } + this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 + || v101->vWorldViewPosition.x < 8.0; + v69 = (double)pOutdoorCamera->shading_dist_mist; + v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; + v70 = 0; + v96->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3b ) + v70 = 3; + else + v70 = v108 != 0 ? 5 : 0; + static_sub_0048034E_stru_76D578.ClassifyPolygon(v63, v87); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - v40->dimming_level, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); + v71 = v59; + v72 = v100; + //v35 = byte_4D864C == 0; + v59->uNumVertices = v100;//??? + if ( !byte_4D864C && pGame->uFlags & 0x80 ) + goto LABEL_154; + if ( this_3b ) + { + v73 = sr_424CD7(v72); + } + else + { + if ( !v108 ) + { +LABEL_154: + v74 = v71->flags; + if ( !(BYTE1(v74) & 1) ) + { + if ( v74 & 2 && v71->uTileBitmapID == pRenderer->hd_water_tile_id ) + { + v80 = false; + v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + } + else + { + v75 = v71->uTileBitmapID; + v80 = true; + } + //v79 = 0; + v78 = pBitmaps_LOD->pHardwareTextures[v75]; + v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary + //v77 = (int)v71; + //v76 = v71->uNumVertices; + //goto LABEL_161; + pRenderer->DrawTerrainPolygon(v71->uNumVertices, (Polygon *)v71, v78, 0, v80); + goto LABEL_162; + } + v38 = (Polygon *)v71; + goto LABEL_56; + } + v73 = sr_424EE0_MakeFanFromTriangle(v72); + } + v71->uNumVertices = v73; + OutdoorCamera::Project(v73); + goto LABEL_154; + } + } +//----- (00424579) -------------------------------------------------------- +int __fastcall sr_424579(int uFaceID, stru320 *a2) +{ + BLVFace *v2; // eax@1 + Vec3_short_ *v3; // ebx@1 + Vec3_short_ *v4; // esi@1 + unsigned int v5; // esi@3 + int v7; // ST1C_4@5 + int v8; // ST1C_4@5 + int v9; // ST1C_4@5 + int v10; // ST1C_4@5 + int v11; // esi@5 + int v12; // ST1C_4@5 + unsigned int v15; // ecx@8 + unsigned int v19; // ecx@13 + signed int v20; // ecx@16 + signed int result; // eax@20 + signed int v24; // edx@22 + unsigned int v25; // [sp+Ch] [bp-1Ch]@3 + float v26; // [sp+14h] [bp-14h]@3 + float v27; // [sp+1Ch] [bp-Ch]@3 + float v28; // [sp+20h] [bp-8h]@3 + signed int v29; // [sp+24h] [bp-4h]@3 + + v2 = &pIndoor->pFaces[uFaceID]; + v3 = pIndoor->pVertices; + v4 = &pIndoor->pVertices[*v2->pVertexIDs]; + if ( v2->pFacePlane_old.vNormal.x * ((signed __int16)*(int *)&v4->x - pBLVRenderParams->vPartyPos.x) + + v2->pFacePlane_old.vNormal.y * ((signed __int16)(*(int *)&v4->x >> 16) - pBLVRenderParams->vPartyPos.y) + + v2->pFacePlane_old.vNormal.z * (v4->z - pBLVRenderParams->vPartyPos.z) < 0 ) + { + PortalFace.field_0 = 1; + } + else + { + PortalFace.field_0 = 0; + if ( !(v2->uAttributes & 1) ) + return 0; + } + v29 = 0; + v5 = v2->uNumVertices; + __asm { fld pBLVRenderParams->fCosineY } + v28 = pBLVRenderParams->fSineY; + v26 = pBLVRenderParams->fCosineNegX; + v27 = pBLVRenderParams->fSineNegX; + v25 = v5; + if ( (signed int)v5 > 0 ) + { + _ECX = (char *)&array_50AC10[0].vWorldPosition.z; + do + { + v7 = v3[v2->pVertexIDs[v29]].x; + __asm + { + fild [ebp+var_10] + fstp dword ptr [ecx-8] + } + v8 = v3[v2->pVertexIDs[v29]].y; + __asm + { + fild [ebp+var_10] + fstp dword ptr [ecx-4] + } + v9 = v3[v2->pVertexIDs[v29]].z; + __asm + { + fild [ebp+var_10] + fstp dword ptr [ecx] + } + _ECX += 48; + v10 = a2->pDeltaUV[0] + v2->pVertexUIDs[v29]; + __asm + { + fild [ebp+var_10] + fstp dword ptr [ecx-14h] + } + v11 = a2->pDeltaUV[1] + v2->pVertexVIDs[v29++]; + v12 = v11; + v5 = v25; + __asm + { + fild [ebp+var_10] + fstp dword ptr [ecx-10h] + } + } + while ( v29 < (signed int)v25 ); + } + _EDX = (char *)&array_50AC10[0].vWorldViewPosition; + if ( pBLVRenderParams->sPartyRotX ) + { + if ( (signed int)v5 > 0 ) + { + __asm + { + fild pBLVRenderParams->vPartyPos.x + fild pBLVRenderParams->vPartyPos.y + fild pBLVRenderParams->vPartyPos.z + } + _EAX = (char *)&array_50AC10[0].vWorldPosition.z; + v15 = v5; + do + { + __asm + { + fld dword ptr [eax-8] + fsub st, st(3) + fld dword ptr [eax-4] + fsub st, st(3) + fld st(1) + fmul st, st(6) + fld st(1) + fmul [ebp+var_8] + fsubp st(1), st + fstp [ebp+var_4] + fld dword ptr [eax] + fsub st, st(3) + } + _EAX += 48; + --v15; + __asm + { + fstp [ebp+var_10] + fld [ebp+var_4] + fmul [ebp+var_14] + fld [ebp+var_10] + fmul [ebp+var_C] + fsubp st(1), st + fstp dword ptr [eax-2Ch] + fld st(1) + fmul [ebp+var_8] + fld st(1) + fmul st, st(7) + faddp st(1), st + fstp dword ptr [eax-28h] + fstp st + fstp st + fld [ebp+var_4] + fmul [ebp+var_C] + fld [ebp+var_10] + fmul [ebp+var_14] + faddp st(1), st + fstp dword ptr [eax-24h] + } + } + while ( v15 ); +LABEL_15: + __asm + { + fstp st + fstp st + fstp st + } + goto LABEL_16; + } + } + else + { + if ( (signed int)v5 > 0 ) + { + __asm + { + fild pBLVRenderParams->vPartyPos.x + fild pBLVRenderParams->vPartyPos.y + fild pBLVRenderParams->vPartyPos.z + } + _EAX = (char *)&array_50AC10[0].vWorldViewPosition; + v19 = v5; + do + { + __asm + { + fld dword ptr [eax-0Ch] + fsub st, st(3) + fld dword ptr [eax-8] + fsub st, st(3) + fld st(1) + fmul st, st(6) + fld st(1) + fmul [ebp+var_8] + fsubp st(1), st + fstp dword ptr [eax] + fld st(1) + fmul [ebp+var_8] + fld st(1) + fmul st, st(7) + } + _EAX += 48; + --v19; + __asm + { + faddp st(1), st + fstp dword ptr [eax-2Ch] + fstp st + fstp st + fld dword ptr [eax-34h] + fsub st, st(1) + fstp dword ptr [eax-28h] + } + } + while ( v19 ); + goto LABEL_15; + } + } +LABEL_16: + v20 = 0; + __asm { fstp st } + if ( (signed int)v5 <= 0 ) + return 0; + do + { + __asm + { + fld dword ptr [edx] + fcomp ds:flt_4D8524 + fnstsw ax + } + if ( !(HIBYTE(_AX) & 1) ) + break; + ++v20; + _EDX += 48; + } + while ( v20 < (signed int)v5 ); + if ( v20 >= (signed int)v5 ) + return 0; + result = sr_424CD7(v5); + if ( result > 0 ) + { + __asm { fild pBLVRenderParams->field_40 } + _ECX = (char *)&array_507D30[0].vWorldViewPosition; + v24 = result; + __asm + { + fmul ds:flt_4D84A4 + fild pBLVRenderParams->uViewportCenterX + fild pBLVRenderParams->uViewportCenterY + } + do + { + __asm + { + fld1 + fdiv dword ptr [ecx] + } + _ECX += 48; + --v24; + __asm + { + fld st + fmul dword ptr [ecx-2Ch] + fmul st, st(4) + fsubr st, st(3) + fstp dword ptr [ecx-24h] + fmul dword ptr [ecx-28h] + fmul st, st(3) + fsubr st, st(1) + fstp dword ptr [ecx-20h] + } + } + while ( v24 ); + __asm + { + fstp st + fstp st + fstp st + } + } + memcpy(&array_507D30[result], array_507D30, sizeof(array_507D30[result])); + return result; +} + +//----- (00423B4A) -------------------------------------------------------- +void __cdecl sub_423B4A() +{ + float *v0; // eax@1 + signed int v1; // ecx@1 + + v0 = &array_507D30[0].flt_2C; + v1 = 50; + do + { + *v0 = 0.0; + v0 += 12; + --v1; + } + while ( v1 ); +} + +//----- (004AD504) -------------------------------------------------------- +int __fastcall sr_4AD504(signed int sFaceID) +{ + int result; // eax@1 + signed int v2; // ebx@1 + BLVFace *v3; // esi@3 + Texture *v4; // edi@6 + int v5; // eax@7 + int v6; // edx@7 + int v7; // ecx@7 + int v8; // ebx@8 + int v9; // eax@8 + int v10; // ebx@8 + unsigned int v11; // ebx@9 + int v12; // esi@10 + int v13; // eax@13 + unsigned __int16 *v14; // eax@13 + unsigned int v15; // eax@14 + unsigned __int16 *v16; // ebx@14 + int v17; // eax@15 + int v18; // ebx@15 + int v19; // esi@15 + int v20; // ecx@15 + int v21; // eax@15 + stru193_math *v22; // ebx@15 + int v23; // eax@15 + char *v24; // esi@16 + int v25; // eax@18 + int v26; // eax@18 + int v27; // eax@20 + signed int v28; // esi@20 + signed int v29; // edx@20 + signed int v30; // esi@20 + signed int v31; // edi@20 + int v32; // esi@20 + int v33; // eax@26 + int *v34; // esi@27 + unsigned __int16 *v35; // edi@27 + unsigned int v36; // edx@27 + int v37; // ebx@27 + char v38; // cl@27 + char v39; // ch@27 + int v40; // ebx@29 + int v41; // edx@29 + unsigned int v42; // ebx@30 + int v43; // edx@30 + int v44; // eax@33 + int *v45; // esi@34 + unsigned __int16 *v46; // edi@34 + unsigned int v47; // edx@34 + int v48; // ebx@34 + char v49; // cl@34 + char v50; // ch@34 + int v51; // ebx@36 + int v52; // edx@36 + unsigned __int16 v53; // bx@37 + int v54; // edx@37 + int v55; // eax@40 + int v56; // eax@41 + int *v57; // esi@42 + unsigned __int16 *v58; // edi@42 + unsigned int v59; // edx@42 + int v60; // ebx@42 + char v61; // cl@42 + char v62; // ch@42 + unsigned int v63; // ebx@44 + int v64; // edx@44 + unsigned int v65; // ebx@44 + int v66; // edx@44 + unsigned int v67; // ebx@45 + int v68; // edx@45 + int v69; // ebx@45 + int v70; // edx@45 + int v71; // eax@48 + int *v72; // esi@49 + unsigned __int16 *v73; // edi@49 + unsigned int v74; // edx@49 + int v75; // ebx@49 + char v76; // cl@49 + char v77; // ch@49 + unsigned int v78; // ebx@51 + int v79; // edx@51 + unsigned int v80; // ebx@51 + int v81; // edx@51 + unsigned int v82; // ebx@52 + int v83; // edx@52 + int v84; // ebx@52 + int v85; // edx@52 + unsigned __int8 *v86; // [sp+Ch] [bp-98h]@9 + unsigned __int8 *v87; // [sp+10h] [bp-94h]@9 + unsigned __int8 *v88; // [sp+14h] [bp-90h]@9 + unsigned __int8 *v89; // [sp+18h] [bp-8Ch]@9 + int v90; // [sp+1Ch] [bp-88h]@20 + BLVFace *v91; // [sp+20h] [bp-84h]@3 + int v92; // [sp+24h] [bp-80h]@7 + int i; // [sp+28h] [bp-7Ch]@7 + unsigned __int16 *v94; // [sp+2Ch] [bp-78h]@9 + unsigned int v95; // [sp+30h] [bp-74h]@1 + Texture *v96; // [sp+34h] [bp-70h]@6 + int v97; // [sp+38h] [bp-6Ch]@15 + unsigned int v98; // [sp+3Ch] [bp-68h]@9 + int v99; // [sp+40h] [bp-64h]@9 + int v100; // [sp+44h] [bp-60h]@24 + int v101; // [sp+48h] [bp-5Ch]@10 + int v102; // [sp+4Ch] [bp-58h]@20 + int v103; // [sp+50h] [bp-54h]@20 + int v104; // [sp+54h] [bp-50h]@9 + unsigned __int8 *v105; // [sp+58h] [bp-4Ch]@20 + int v106; // [sp+5Ch] [bp-48h]@24 + int v107; // [sp+60h] [bp-44h]@20 + int v108; // [sp+64h] [bp-40h]@20 + int v109; // [sp+68h] [bp-3Ch]@20 + int v110; // [sp+6Ch] [bp-38h]@15 + int v111; // [sp+70h] [bp-34h]@20 + int a1; // [sp+74h] [bp-30h]@12 + int a2; // [sp+78h] [bp-2Ch]@9 + int *v114; // [sp+7Ch] [bp-28h]@16 + int v115; // [sp+80h] [bp-24h]@18 + int v116; // [sp+84h] [bp-20h]@7 + unsigned int v117; // [sp+88h] [bp-1Ch]@15 + unsigned int v118; // [sp+8Ch] [bp-18h]@24 + int *v119; // [sp+90h] [bp-14h]@13 + int v120; // [sp+94h] [bp-10h]@15 + unsigned int v121; // [sp+98h] [bp-Ch]@15 + unsigned __int16 *v122; // [sp+9Ch] [bp-8h]@15 + unsigned int v123; // [sp+A0h] [bp-4h]@13 + + result = pRenderer->uTargetSurfacePitch; + v2 = sFaceID; + v95 = pRenderer->uTargetSurfacePitch; + if ( sFaceID >= 0 ) + { + if ( sFaceID < (signed int)pIndoor->uNumFaces ) + { + v3 = &pIndoor->pFaces[sFaceID]; + v91 = &pIndoor->pFaces[sFaceID]; + if ( !pRenderer->pRenderD3D ) + { + result = GetPortalScreenCoord(sFaceID); + if ( result ) + { + result = PortalFrustrum(result, &stru_F8A590, pBLVRenderParams->field_7C, v2); + if ( result ) + { + result = (int)v3->GetTexture(); + v4 = (Texture *)result; + v96 = (Texture *)result; + if ( result ) + { + v5 = *(short *)(result + 38); + LOBYTE(v3->uAttributes) |= 0x80u; + v92 = v5; + sr_4AE5F1(v2); + ++pBLVRenderParams->field_84; + v6 = stru_F8AD28.pDeltaUV[0]; + v116 = stru_F8AD28.pDeltaUV[1]; + v7 = 0; + for ( i = bUseLoResSprites; v7 < stru_F8AD28.uNumLightsApplied; *(int *)v9 = v10 ) + { + v8 = v116; + stru_F8AD28._blv_lights_xs[v7] += v6; + v9 = 4 * v7 + 16297672; + v10 = v8 - stru_F8AD28._blv_lights_ys[v7++]; + } + v94 = sr_sub_47C24C_get_palette(v3, v92, 0, 1); + result = stru_F8A590._viewport_space_y; + a2 = stru_F8A590._viewport_space_y; + v11 = stru_F8A590._viewport_space_y * pRenderer->uTargetSurfacePitch; + v99 = 640 * stru_F8A590._viewport_space_y; + v86 = v4->pLevelOfDetail0_prolly_alpha_mask; + v87 = v4->pLevelOfDetail1; + v88 = v4->pLevelOfDetail2; + v89 = v4->pLevelOfDetail3; + v98 = stru_F8A590._viewport_space_y * pRenderer->uTargetSurfacePitch; + v104 = 2 * pBLVRenderParams->field_0_timer_; + if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) + { + v12 = 2 * stru_F8A590._viewport_space_y; + v101 = 2 * stru_F8A590._viewport_space_y; + while ( 1 ) + { + a1 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v12); + sr_4AE313(a1, result, &stru_F81018.field_0); + if ( LOBYTE(viewparams->field_20) ) + { + v15 = v95 * (v12 - pBLVRenderParams->uViewportY); + v119 = &pBLVRenderParams->pTargetZBuffer[2 + * (*(__int16 *)((char *)stru_F8A590.viewport_left_side + v12) + + 320 * (v12 - pBLVRenderParams->uViewportY)) + - pBLVRenderParams->uViewportX]; + v16 = &pBLVRenderParams->pRenderTarget[v15 + + 2 * *(__int16 *)((char *)stru_F8A590.viewport_left_side + v12) + - pBLVRenderParams->uViewportX]; + v14 = &pBLVRenderParams->pRenderTarget[v15 + + 2 * *(__int16 *)((char *)stru_F8A590.viewport_right_side + v12) + - pBLVRenderParams->uViewportX]; + v123 = (unsigned int)v16; + } + else + { + v13 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v12); + v119 = &pBLVRenderParams->pTargetZBuffer[v13 + v99]; + v123 = (unsigned int)&pBLVRenderParams->pRenderTarget[v13 + v11]; + v14 = &pBLVRenderParams->pRenderTarget[v11 + *(__int16 *)((char *)stru_F8A590.viewport_right_side + v12)]; + } + v117 = (unsigned int)v14; + HIWORD(v17) = HIWORD(stru_F81018.field_0.field_0); + v18 = stru_F81018.field_0.field_10; + LOWORD(v17) = 0; + v97 = stru_F8AD28.field_0 | v17; + v110 = sr_4AE491(SHIWORD(stru_F81018.field_0.field_4), SHIWORD(stru_F81018.field_0.field_8)); + v19 = stru_F81018.field_0.field_4 >> i; + v20 = 11 - v18; + v116 = stru_F81018.field_0.field_8 >> i; + v21 = stru_F81018.field_0.field_8 >> i >> (11 - v18); + v22 = stru_5C6E00; + v122 = (unsigned __int16 *)v20; + v121 = (stru_F81018.field_0.field_4 >> i) + 4 * stru_5C6E00->Cos(v104 + v21); + v23 = stru_5C6E00->Sin(v104 + (v19 >> (char)v122)); + v120 = v116 + 4 * v23; + if ( v123 < v117 ) + { + v24 = (char *)&stru_F81018.field_34.field_8; + v114 = &stru_F81018.field_34.field_8; + a1 += 16; + while ( 1 ) + { + sr_4AE313(a1, a2, (stru337_stru0 *)(v24 - 8)); + v25 = *((int *)v24 - 2); + LOWORD(v25) = 0; + v115 = v97; + v26 = stru_F8AD28.field_0 | v25; + if ( v97 <= (unsigned int)v26 ) + v115 = v26; + v97 = v26; + v27 = *((int *)v24 - 11); + v28 = *((int *)v24 - 1); + v105 = (&v86)[4 * v27]; + v111 = v27 + 16; + v29 = v4->uWidthMinus1; + v109 = v27 + v27 + 16 - v4->uWidthLn2; + v107 = v29 >> v27; + v30 = v28 >> i; + v102 = v4->uHeightMinus1 >> v27 << (v27 + 16); + v31 = *v114 >> i; + v122 = (unsigned __int16 *)(11 - v27); + v116 = v30 + 4 * stru_5C6E00->Cos(v104 + (v31 >> (11 - v27))); + v90 = v31 + 4 * stru_5C6E00->Sin(v104 + (v30 >> (char)v122)); + v108 = (signed int)(v116 - v121) >> 4; + v103 = (v90 - v120) >> 4; + v32 = v123 + 32; + if ( LOBYTE(viewparams->field_20) ) + v32 = v123 + 64; + if ( v32 > v117 ) + v32 = v117; + v118 = v32; + v100 = sr_4AE491(*((short *)v114 - 1), *((short *)v114 + 1)); + v106 = (signed int)(v32 - v123) >> 1; + if ( v110 >> 16 == v100 >> 16 ) + { + v122 = sr_sub_47C24C_get_palette(v91, v92, v110 >> 16, 1); + if ( LOBYTE(viewparams->field_20) ) + { + v44 = v123; + if ( v123 < v118 ) + { + v45 = v119; + v46 = v122; + v47 = v121; + v48 = v120; + v49 = v111; + v50 = v109; + if ( v106 & 2 ) + { + *v119 = v115; + v45 -= 2; + v44 = v123 + 4; + goto LABEL_37; + } + do + { + v44 += 8; + v51 = *(&v105[v107 & (v47 >> v49)] + ((v102 & (unsigned int)v48) >> v50)); + v52 = v115; + LOWORD(v51) = v46[v51]; + *v45 = v115; + v45[1] = v52; + v45[640] = v52; + v45[641] = v52; + *(short *)(v44 - 8) = v51; + *(short *)(v44 - 6) = v51; + *(short *)(v44 + 1272) = v51; + *(short *)(v44 + 1274) = v51; + v45[2] = v52; + v45[3] = v52; + v45[642] = v52; + v45[643] = v52; + v121 += v108; + v120 += v103; + v47 = v121; + v48 = v120; +LABEL_37: + v45 += 4; + v53 = v46[*(&v105[v107 & (v47 >> v49)] + ((v102 & (unsigned int)v48) >> v50))]; + v54 = v108; + *(short *)(v44 - 4) = v53; + *(short *)(v44 - 2) = v53; + *(short *)(v44 + 1276) = v53; + *(short *)(v44 + 1278) = v53; + v121 += v54; + v120 += v103; + v47 = v121; + v48 = v120; + } + while ( v44 < v118 ); + v123 = v44; + v119 = v45; + } + } + else + { + v33 = v123; + if ( v123 < v118 ) + { + v34 = v119; + v35 = v122; + v36 = v121; + v37 = v120; + v38 = v111; + v39 = v109; + if ( v106 & 1 ) + { + *v119 = v115; + --v34; + v33 = v123 + 2; + goto LABEL_30; + } + do + { + v33 += 4; + v40 = *(&v105[v107 & (v36 >> v38)] + ((v102 & (unsigned int)v37) >> v39)); + v41 = v115; + LOWORD(v40) = v35[v40]; + *v34 = v115; + *(short *)(v33 - 4) = v40; + v34[1] = v41; + v121 += v108; + v120 += v103; + v36 = v121; + v37 = v120; +LABEL_30: + v42 = (unsigned int)(&v105[v107 & (v36 >> v38)] + ((v102 & (unsigned int)v37) >> v39)); + v34 += 2; + v43 = v108; + *(short *)(v33 - 2) = v35[*(char *)v42]; + v121 += v43; + v120 += v103; + v36 = v121; + v37 = v120; + } + while ( v33 < v118 ); + v123 = v33; + v119 = v34; + } + } + } + else + { + v55 = v110 - ((v100 - v110) >> 4); + v110 = (v100 - v110) >> 4; + v122 = (unsigned __int16 *)v55; + if ( LOBYTE(viewparams->field_20) ) + { + v71 = v123; + if ( v123 < v118 ) + { + v72 = v119; + v73 = v94; + v74 = v121; + v75 = v120; + v76 = v111; + v77 = v109; + if ( v106 & 2 ) + { + *v119 = v115; + v72 += 2; + v71 = v123 + 4; + goto LABEL_52; + } + do + { + v78 = (v107 & (v74 >> v76)) + ((v102 & (unsigned int)v75) >> v77); + v79 = (int)((char *)v122 + v110); + v71 += 8; + v122 = (unsigned __int16 *)v79; + v80 = ((v79 & 0xFFFF0000u) >> 8) + v105[v78]; + v81 = v115; + LOWORD(v80) = v73[v80]; + *v72 = v115; + v72[1] = v81; + v72[640] = v81; + v72[641] = v81; + *(short *)(v71 - 8) = v80; + *(short *)(v71 - 6) = v80; + *(short *)(v71 + 1272) = v80; + *(short *)(v71 + 1274) = v80; + v72[2] = v81; + v72[3] = v81; + v72[642] = v81; + v72[643] = v81; + v121 += v108; + v120 += v103; + v74 = v121; + v75 = v120; + v72 += 4; +LABEL_52: + v82 = (v107 & (v74 >> v76)) + ((v102 & (unsigned int)v75) >> v77); + v83 = (int)((char *)v122 + v110); + v84 = v105[v82]; + v122 = (unsigned __int16 *)v83; + LOWORD(v84) = v73[((v83 & 0xFFFF0000u) >> 8) + v84]; + v85 = v108; + *(short *)(v71 - 4) = v84; + *(short *)(v71 - 2) = v84; + *(short *)(v71 + 1276) = v84; + *(short *)(v71 + 1278) = v84; + v121 += v85; + v120 += v103; + v74 = v121; + v75 = v120; + } + while ( v71 < v118 ); + v123 = v71; + v119 = v72; + } + } + else + { + v56 = v123; + if ( v123 < v118 ) + { + v57 = v119; + v58 = v94; + v59 = v121; + v60 = v120; + v61 = v111; + v62 = v109; + if ( v106 & 1 ) + { + *v119 = v115; + ++v57; + v56 = v123 + 2; + goto LABEL_45; + } + do + { + v63 = (v107 & (v59 >> v61)) + ((v102 & (unsigned int)v60) >> v62); + v64 = (int)((char *)v122 + v110); + v56 += 4; + v122 = (unsigned __int16 *)v64; + v65 = ((v64 & 0xFFFF0000u) >> 8) + v105[v63]; + v66 = v115; + LOWORD(v65) = v58[v65]; + *v57 = v115; + *(short *)(v56 - 4) = v65; + v57[1] = v66; + v121 += v108; + v120 += v103; + v59 = v121; + v60 = v120; + v57 += 2; +LABEL_45: + v67 = (v107 & (v59 >> v61)) + ((v102 & (unsigned int)v60) >> v62); + v68 = (int)((char *)v122 + v110); + v69 = v105[v67]; + v122 = (unsigned __int16 *)v68; + LOWORD(v69) = v58[((v68 & 0xFFFF0000u) >> 8) + v69]; + v70 = v108; + *(short *)(v56 - 2) = v69; + v121 += v70; + v120 += v103; + v59 = v121; + v60 = v120; + } + while ( v56 < v118 ); + v123 = v56; + v119 = v57; + } + } + } + v114 += 13; + v110 = v100; + a1 += 16; + v4 = v96; + v121 = v116; + v120 = v90; + if ( v123 >= v117 ) + break; + v24 = (char *)v114; + v22 = stru_5C6E00; + } + } + ++a2; + v98 += v95; + result = a2; + v101 += 2; + v99 += 640; + if ( a2 > stru_F8A590._viewport_space_w ) + break; + v12 = v101; + result = a2; + v11 = v98; + } + } + } + } + } + } + } + } + return result; +} + +//----- (004AE313) -------------------------------------------------------- +int __fastcall sr_4AE313(int viewport_space_x, int viewport_space_y, stru337_stru0 *p) +{ + int _dy; // ebx@1 + int _dx; // edi@1 + int v5; // ecx@1 + int v6; // esi@1 + int v7; // ST18_4@2 + signed __int64 v8; // qtt@3 + unsigned int v9; // ecx@3 + int result; // eax@8 + int v11; // [sp+Ch] [bp-8h]@1 + + _dy = pBLVRenderParams->uViewportCenterY - viewport_space_y; + _dx = pBLVRenderParams->uViewportCenterX - viewport_space_x; + ++pBLVRenderParams->field_88; + v5 = (pBLVRenderParams->uViewportCenterY - viewport_space_y) * stru_F8AD28.vec_80.y + stru_F8AD28.field_7C; + v6 = v5 + _dx * stru_F8AD28.vec_80.x; + v11 = v5 + _dx * stru_F8AD28.vec_80.x; + if ( v5 + _dx * stru_F8AD28.vec_80.x && (v7 = abs(stru_F8AD28.vec_80.z) >> 14, v7 <= abs(v6)) ) + { + LODWORD(v8) = stru_F8AD28.vec_80.z << 16; + HIDWORD(v8) = stru_F8AD28.vec_80.z >> 16; + v9 = v8 / v11; + } + else + { + v9 = 0x40000000u; + } + if ( (signed int)v9 >= stru_F8AD28.field_34 ) + p->field_0 = v9; + else + p->field_0 = stru_F8AD28.field_34; + p->field_4 = ((unsigned __int64)((_dy * stru_F8AD28.vec_8C.z + stru_F8AD28.vec_8C.x + _dx * stru_F8AD28.vec_8C.y) + * (signed __int64)(signed int)v9) >> 16) + + stru_F8AD28.field_98 + + (stru_F8AD28.pDeltaUV[0] << 16); + p->field_8 = ((unsigned __int64)((_dy * stru_F8AD28.vec_9C.z + stru_F8AD28.vec_9C.x + _dx * stru_F8AD28.vec_9C.y) + * (signed __int64)(signed int)v9) >> 16) + + stru_F8AD28.field_A8 + + (stru_F8AD28.pDeltaUV[1] << 16); + result = abs((__int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)(signed int)v9) >> 16); + if ( result < 369620 || bUseLoResSprites ) + { + if ( result < 184810 ) + p->field_10 = result > 92405; + else + p->field_10 = 2; + } + else + { + p->field_10 = 3; + } + return result; +} +//----- (004AE491) -------------------------------------------------------- +int __fastcall sr_4AE491(signed int a1, signed int a2) +{ + signed int v2; // eax@1 + signed int v3; // edi@1 + int v4; // ecx@1 + int v5; // esi@2 + int v6; // eax@2 + int v7; // ebx@2 + unsigned int v8; // ecx@2 + int v9; // edx@5 + int v10; // edx@7 + unsigned int v11; // eax@8 + int v13; // [sp+4h] [bp-18h]@2 + int v14; // [sp+8h] [bp-14h]@2 + signed int v15; // [sp+Ch] [bp-10h]@1 + int v16; // [sp+14h] [bp-8h]@1 + int v17; // [sp+18h] [bp-4h]@1 + + v2 = a1 >> SLOBYTE(stru_F8AD28.field_38); + v3 = a2 >> SLOBYTE(stru_F8AD28.field_38); + v17 = stru_F8AD28.uCurrentAmbientLightLevel; + v4 = 0; + v15 = v2; + v16 = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 ) + { + do + { + v5 = v16; + v13 = abs(v2 - stru_F8AD28._blv_lights_xs[v16]); + v14 = abs(v3 - stru_F8AD28._blv_lights_ys[v16]); + v6 = stru_F8AD28._blv_lights_light_dot_faces[v16]; + v7 = v13; + v8 = v14; + if ( v6 < v13 ) + { + v6 = v13; + v7 = stru_F8AD28._blv_lights_light_dot_faces[v16]; + } + if ( v6 < v14 ) + { + v9 = v6; + v6 = v14; + v8 = v9; + } + if ( v7 < (signed int)v8 ) + { + v10 = v8; + v8 = v7; + v7 = v10; + } + v11 = ((unsigned int)(11 * v7) >> 5) + (v8 >> 2) + v6; + if ( (signed int)v11 < stru_F8AD28._blv_lights_radii[v5] ) + v17 += 30 * (v11 * stru_F8AD28._blv_lights_inv_radii[v5] - 65536); + ++v16; + v2 = v15; + } + while ( v16 < stru_F8AD28.uNumLightsApplied ); + v4 = 0; + } + if ( stru_F8AD28.field_3E4 != v4 ) + v17 -= stru_F8AD28.field_3E8 * (v2 - stru_F8AD28.field_3F0) + stru_F8AD28.field_3EC * (v3 - stru_F8AD28.field_3F4); + if ( v17 >= v4 ) + { + if ( v17 > 2031616 ) + v17 = 2031616; + } + else + { + v17 = v4; + } + ++pBLVRenderParams->field_8C; + return v17; +} + +//----- (004AE5F1) -------------------------------------------------------- +void __fastcall sr_4AE5F1(unsigned int uFaceID) +{ + BLVFace *v1; // esi@1 + BLVFaceExtra *v2; // ebx@1 + int v3; // eax@1 + int v4; // edi@1 + Texture *v5; // edi@1 + int v6; // eax@1 + unsigned int v7; // eax@1 + unsigned int v8; // ecx@1 + unsigned int v9; // eax@1 + unsigned int v10; // ecx@5 + int v11; // edi@10 + int v12; // ecx@10 + int v13; // eax@10 + int v14; // edx@10 + int v15; // ebx@12 + double v16; // st7@16 + int v17; // eax@16 + char *v18; // ebx@17 + int v19; // ecx@19 + int v20; // eax@19 + int v21; // edx@21 + int v22; // eax@23 + int v23; // ST04_4@26 + int v24; // edi@26 + double v25; // st6@26 + int v26; // eax@26 + double v27; // st6@26 + int v28; // ecx@26 + char v29; // al@26 + int v30; // edx@28 + int v31; // ecx@28 + BLVLightMM7 *v32; // ecx@32 + int v33; // edi@33 + int v34; // edx@33 + int v35; // eax@33 + int v36; // edi@35 + int v37; // edx@37 + int v38; // ebx@39 + int v39; // edi@42 + int v40; // eax@42 + char *v41; // ebx@45 + signed int v42; // ecx@47 + int v43; // edi@47 + int v44; // eax@49 + int v45; // edx@51 + int v46; // eax@53 + int v47; // ST04_4@55 + int v48; // edi@55 + double v49; // st6@55 + int v50; // eax@55 + double v51; // st6@55 + int v52; // eax@55 + int v53; // ecx@57 + int v54; // ecx@58 + int v55; // ecx@59 + int v56; // edx@62 + int v57; // ecx@62 + int v58; // eax@63 + int v59; // edx@64 + int v60; // ecx@67 + int v61; // edx@67 + int v62; // eax@68 + int v63; // edx@69 + signed int v64; // ecx@72 + double v65; // st7@75 + Vec3_int_ v66; // [sp+Ch] [bp-34h]@9 + Vec3_int_ v67; // [sp+18h] [bp-28h]@9 + BLVFaceExtra *v68; // [sp+24h] [bp-1Ch]@1 + int v69; // [sp+28h] [bp-18h]@10 + int v70; // [sp+2Ch] [bp-14h]@10 + int X; // [sp+30h] [bp-10h]@10 + int v72; // [sp+34h] [bp-Ch]@10 + int v73; // [sp+38h] [bp-8h]@10 + int v74; // [sp+3Ch] [bp-4h]@10 + + v1 = &pIndoor->pFaces[uFaceID]; + v2 = &pIndoor->pFaceExtras[v1->uFaceExtraID]; + v3 = v1->uBitmapID; + v4 = v1->uBitmapID; + v68 = v2; + v5 = (Texture *)(v4 != -1 ? (int)&pBitmaps_LOD->pTextures[v3] : 0); + v6 = 8 * uFaceID; + LOBYTE(v6) = PID(OBJECT_BModel,uFaceID); + stru_F8AD28.field_0 = v6; + stru_F8AD28.plane_4.vNormal.x = v1->pFacePlane_old.vNormal.x; + stru_F8AD28.plane_4.vNormal.y = v1->pFacePlane_old.vNormal.y; + stru_F8AD28.plane_4.vNormal.z = v1->pFacePlane_old.vNormal.z; + stru_F8AD28.plane_4.dist = v1->pFacePlane_old.dist; + stru_F8AD28.pDeltaUV[0] = v2->sTextureDeltaU; + stru_F8AD28.pDeltaUV[1] = v2->sTextureDeltaV; + v7 = GetTickCount(); + v8 = v1->uAttributes; + v9 = v7 >> 3; + if ( v8 & 4 ) + { + stru_F8AD28.pDeltaUV[1] -= v9 & v5->uHeightMinus1; + } + else + { + if ( v8 & 0x20 ) + stru_F8AD28.pDeltaUV[1] += v9 & v5->uHeightMinus1; + } + v10 = v1->uAttributes; + if ( BYTE1(v10) & 8 ) + { + stru_F8AD28.pDeltaUV[0] -= v9 & v5->uWidthMinus1; + } + else + { + if ( v10 & 0x40 ) + stru_F8AD28.pDeltaUV[0] += v9 & v5->uWidthMinus1; + } + v1->_get_normals(&v67, &v66); + stru_F8AD28.vec_14.x = v67.x; + stru_F8AD28.vec_14.y = v67.y; + stru_F8AD28.vec_14.z = v67.z; + stru_F8AD28.vec_20.x = v66.x; + stru_F8AD28.vec_20.y = v66.y; + stru_F8AD28.vec_20.z = v66.z; + stru_F8AD28.uDefaultAmbientLightLevel = v2->field_22; + if ( pBLVRenderParams->sPartyRotX ) + { + v74 = (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; + v74 = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v74; + X = (unsigned __int64)(stru_F8AD28.plane_4.vNormal.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; + stru_F8AD28.rotated_normal.x = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - X; + stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x + * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y + * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + stru_F8AD28.rotated_normal.z = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) + + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z + * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); + v70 = (unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; + v74 = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v70; + v70 = (unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; + stru_F8AD28.vec_60.y = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v70; + stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + stru_F8AD28.field_6C = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); + v70 = (unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; + v74 = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v70; + X = (unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16; + v72 = (unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16; + v70 = (unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; + stru_F8AD28.vec_70.x = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v70; + stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + stru_F8AD28.vec_70.z = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); + v74 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y + - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x; + v11 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y + + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x); + v73 = -65536 * pBLVRenderParams->vPartyPos.z; + v70 = (unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; + v12 = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v70; + v69 = (unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; + v13 = pBLVRenderParams->vPartyPos.y; + v70 = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) + + ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); + v14 = pBLVRenderParams->vPartyPos.x; + } + else + { + v70 = (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; + stru_F8AD28.rotated_normal.x = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x + * (signed __int64)pBLVRenderParams->sCosineY) >> 16) + - v70; + stru_F8AD28.rotated_normal.z = stru_F8AD28.plane_4.vNormal.z; + stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x + * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y + * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + v70 = (unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; + stru_F8AD28.vec_60.y = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) + - v70; + stru_F8AD28.field_6C = stru_F8AD28.vec_14.z; + stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + v70 = (unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; + stru_F8AD28.vec_70.x = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) + - v70; + v69 = (unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16; + v14 = pBLVRenderParams->vPartyPos.x; + stru_F8AD28.vec_70.z = stru_F8AD28.vec_20.z; + v13 = pBLVRenderParams->vPartyPos.y; + stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + v12 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y + - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x; + v11 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y + + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x); + v70 = -65536 * pBLVRenderParams->vPartyPos.z; + } + stru_F8AD28.field_7C = stru_F8AD28.rotated_normal.x; + stru_F8AD28.vec_60.x = stru_F8AD28.plane_4.vNormal.z * pBLVRenderParams->vPartyPos.z + + stru_F8AD28.plane_4.dist + + stru_F8AD28.plane_4.vNormal.y * v13 + + stru_F8AD28.plane_4.vNormal.x * v14; + stru_F8AD28.vec_80.x = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) + * (signed __int64)stru_F8AD28.rotated_normal.y) >> 16; + stru_F8AD28.vec_80.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) + * (signed __int64)stru_F8AD28.rotated_normal.z) >> 16; + stru_F8AD28.vec_80.z = -stru_F8AD28.vec_60.x; + stru_F8AD28.vec_8C.x = stru_F8AD28.vec_60.y; + stru_F8AD28.vec_8C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_60.z) >> 16; + stru_F8AD28.vec_8C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.field_6C) >> 16; + X = (unsigned __int64)(stru_F8AD28.vec_60.y * (signed __int64)v12) >> 16; + v15 = v70; + v70 = (unsigned __int64)(stru_F8AD28.field_6C * (signed __int64)v70) >> 16; + stru_F8AD28.vec_9C.x = stru_F8AD28.vec_70.x; + stru_F8AD28.field_98 = -(X + ((unsigned __int64)(stru_F8AD28.vec_60.z * (signed __int64)v11) >> 16) + v70); + stru_F8AD28.vec_9C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.y) >> 16; + stru_F8AD28.vec_9C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.z) >> 16; + X = (unsigned __int64)(stru_F8AD28.vec_70.x * (signed __int64)v12) >> 16; + v69 = (unsigned __int64)(stru_F8AD28.vec_70.y * (signed __int64)v11) >> 16; + v70 = (unsigned __int64)(stru_F8AD28.vec_70.z * (signed __int64)v15) >> 16; + stru_F8AD28.field_38 = 0; + stru_F8AD28.field_A8 = -(X + + ((unsigned __int64)(stru_F8AD28.vec_70.y * (signed __int64)v11) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_70.z * (signed __int64)v15) >> 16)); + if ( *(int *)&v68->field_4 || *(int *)&v68->field_8 ) + { + stru_F8AD28.field_3E4 = 1; + stru_F8AD28.field_3E8 = *(int *)&v68->field_4; + stru_F8AD28.field_3EC = *(int *)&v68->field_8; + stru_F8AD28.field_3F0 = v68->field_1E; + stru_F8AD28.field_3F4 = v68->field_20; + } + else + { + stru_F8AD28.field_3E4 = 0; + } + v16 = 0.0039215689; + v17 = 116 * v1->uSectorID; + v69 = v17; + v74 = 0; + v73 = 0; + stru_F8AD28.uCurrentAmbientLightLevel = (stru_F8AD28.uDefaultAmbientLightLevel + *(__int16 *)((char *)&pIndoor->pSectors->uMinAmbientLightLevel + v17)) << 16; + v70 = pMobileLightsStack->uNumLightsActive; + if ( pMobileLightsStack->uNumLightsActive > 0 ) + { + v18 = (char *)&pMobileLightsStack->pLights[0].vPosition.y; + do + { + if ( v74 >= 20 ) + break; + v19 = *((short *)v18 + 2); + v20 = *((short *)v18 - 1); + if ( v20 > v1->pBounding.x1 - v19 ) + { + if ( v20 < v19 + v1->pBounding.x2 ) + { + v21 = *(short *)v18; + if ( v21 > v1->pBounding.y1 - v19 ) + { + if ( v21 < v19 + v1->pBounding.y2 ) + { + v22 = *((short *)v18 + 1); + if ( v22 > v1->pBounding.z1 - v19 ) + { + if ( v22 < v19 + v1->pBounding.z2 ) + { + X = (v1->pFacePlane_old.dist + + *((short *)v18 + 1) * v1->pFacePlane_old.vNormal.z + + v21 * v1->pFacePlane_old.vNormal.y + + *((short *)v18 - 1) * v1->pFacePlane_old.vNormal.x) >> 16; + if ( X <= v19 ) + { + v23 = X; + v24 = v74; + stru_F8AD28._blv_lights_radii[v74] = v19; + stru_F8AD28._blv_lights_inv_radii[v24] = 65536 / v19; + *(int *)((char *)&stru_F8AD28.field_240 + v24 * 4) = *((short *)v18 + 5) << 16; + stru_F8AD28._blv_lights_xs[v24] = *((short *)v18 - 1); + stru_F8AD28._blv_lights_ys[v24] = *(short *)v18; + stru_F8AD28._blv_lights_zs[v24] = *((short *)v18 + 1); + v68 = (BLVFaceExtra *)(unsigned __int8)v18[6]; + v25 = (double)(signed int)v68 * v16; + v68 = (BLVFaceExtra *)(unsigned __int8)v18[7]; + v26 = (unsigned __int8)v18[8]; + *(float *)(v24 * 4 + 16297992) = v25; + v27 = (double)(signed int)v68; + v68 = (BLVFaceExtra *)v26; + *(float *)(v24 * 4 + 16298072) = v27 * v16; + *(float *)(v24 * 4 + 16298152) = (double)(signed int)v68 * v16; + v16 = 0.0039215689; + stru_F8AD28._blv_lights_light_dot_faces[v24] = abs(v23); + v28 = v74; + v29 = v18[9]; + ++v74; + stru_F8AD28._blv_lights_types[v28] = v29; + } + } + } + } + } + } + } + ++v73; + v18 += 18; + v17 = v69; + } + while ( v73 < v70 ); + } + v30 = 0; + v73 = 0; + v31 = *(__int16 *)((char *)&pIndoor->pSectors->uNumLights + v17); + v70 = *(__int16 *)((char *)&pIndoor->pSectors->uNumLights + v17); + if ( v31 > 0 ) + { + while ( v74 < 20 ) + { + v32 = &pIndoor->pLights[*(&(*(BLVLightMM7 **)((char *)&pIndoor->pSectors->pLights + v17))->vPosition.x + v30)]; + if ( !(v32->uAtributes & 8) ) + { + v33 = v1->pBounding.x1; + v34 = v32->vPosition.x; + X = v32->uBrightness; + v35 = v32->uRadius; + v68 = (BLVFaceExtra *)v32->uRadius; + if ( v34 > v33 - v35 ) + { + if ( v34 < v35 + v1->pBounding.x2 ) + { + v36 = v32->vPosition.y; + if ( v36 > v1->pBounding.y1 - v35 ) + { + if ( v36 < v35 + v1->pBounding.y2 ) + { + v37 = v32->vPosition.z; + if ( v37 > v1->pBounding.z1 - v35 ) + { + if ( v37 < v35 + v1->pBounding.z2 ) + { + v38 = (v1->pFacePlane_old.dist + + v32->vPosition.x * v1->pFacePlane_old.vNormal.x + + v37 * v1->pFacePlane_old.vNormal.z + + v36 * v1->pFacePlane_old.vNormal.y) >> 16; + if ( v38 >= 0 ) + { + if ( v38 <= v35 && v35 ) + { + v39 = v74; + stru_F8AD28._blv_lights_radii[v74] = v35; + stru_F8AD28._blv_lights_inv_radii[v39] = 65536 / (signed int)v68; + *(int *)((char *)&stru_F8AD28.field_240 + v39 * 4) = X << 16; + stru_F8AD28._blv_lights_xs[v39] = v32->vPosition.x; + stru_F8AD28._blv_lights_ys[v39] = v32->vPosition.y; + stru_F8AD28._blv_lights_zs[v39] = v32->vPosition.z; + v68 = (BLVFaceExtra *)v32->uRed; + stru_F8AD28._blv_lights_rs[v39] = (double)(signed int)v68 * v16; + v68 = (BLVFaceExtra *)v32->uGreen; + stru_F8AD28._blv_lights_gs[v39] = (double)(signed int)v68 * v16; + v68 = (BLVFaceExtra *)v32->uBlue; + stru_F8AD28._blv_lights_bs[v39] = (double)(signed int)v68 * v16; + v16 = 0.0039215689; + stru_F8AD28._blv_lights_light_dot_faces[v39] = abs(v38); + v40 = v74++; + stru_F8AD28._blv_lights_types[v40] = 1; + } + } + } + } + } + } + } + } + } + v30 = v73++ + 1; + if ( v73 >= v70 ) + break; + v17 = v69; + } + } + v73 = 0; + if ( pStationaryLightsStack->uNumLightsActive > 0 ) + { + v41 = (char *)&pStationaryLightsStack->pLights[0].vPosition.y; + do + { + if ( v74 >= 20 ) + break; + v42 = *((short *)v41 + 2); + v43 = *((short *)v41 - 1); + if ( v43 > v1->pBounding.x1 - v42 ) + { + if ( v43 < v42 + v1->pBounding.x2 ) + { + v44 = *(short *)v41; + if ( v44 > v1->pBounding.y1 - v42 ) + { + if ( v44 < v42 + v1->pBounding.y2 ) + { + v45 = *((short *)v41 + 1); + if ( v45 > v1->pBounding.z1 - v42 ) + { + if ( v45 < v42 + v1->pBounding.z2 ) + { + v46 = (v1->pFacePlane_old.dist + + *(short *)v41 * v1->pFacePlane_old.vNormal.y + + v43 * v1->pFacePlane_old.vNormal.x + + v45 * v1->pFacePlane_old.vNormal.z) >> 16; + v69 = v46; + if ( v46 >= 0 ) + { + if ( v46 <= v42 ) + { + v47 = v69; + v48 = v74; + stru_F8AD28._blv_lights_radii[v74] = v42; + stru_F8AD28._blv_lights_inv_radii[v48] = 65536 / v42; + stru_F8AD28._blv_lights_xs[v48] = *((short *)v41 - 1); + stru_F8AD28._blv_lights_ys[v48] = *(short *)v41; + stru_F8AD28._blv_lights_zs[v48] = *((short *)v41 + 1); + v68 = (BLVFaceExtra *)(unsigned __int8)v41[6]; + v49 = (double)(signed int)v68 * v16; + v68 = (BLVFaceExtra *)(unsigned __int8)v41[7]; + v50 = (unsigned __int8)v41[8]; + stru_F8AD28._blv_lights_rs[v48] = v49; + v51 = (double)(signed int)v68; + v68 = (BLVFaceExtra *)v50; + stru_F8AD28._blv_lights_gs[v48] = v51 * v16; + stru_F8AD28._blv_lights_bs[v48] = (double)(signed int)v68 * v16; + v16 = 0.0039215689; + stru_F8AD28._blv_lights_light_dot_faces[v48] = abs(v47); + v52 = v74++; + stru_F8AD28._blv_lights_types[v52] = 1; + } + } + } + } + } + } + } + } + ++v73; + v41 += 12; + } + while ( v73 < pStationaryLightsStack->uNumLightsActive ); + } + stru_F8AD28.uNumLightsApplied = v74; + v53 = v1->pBounding.x2; + if ( pBLVRenderParams->vPartyPos.x <= v53 ) + { + v55 = v1->pBounding.x1; + if ( pBLVRenderParams->vPartyPos.x >= v55 ) + v54 = 0; + else + v54 = v55 - pBLVRenderParams->vPartyPos.x; + } + else + { + v54 = pBLVRenderParams->vPartyPos.x - v53; + } + v56 = v1->pBounding.y2; + v57 = v54 * v54; + if ( pBLVRenderParams->vPartyPos.y <= v56 ) + { + v59 = v1->pBounding.y1; + if ( pBLVRenderParams->vPartyPos.y >= v59 ) + v58 = 0; + else + v58 = v59 - pBLVRenderParams->vPartyPos.y; + } + else + { + v58 = pBLVRenderParams->vPartyPos.y - v56; + } + v60 = v58 * v58 + v57; + v61 = v1->pBounding.z2; + if ( pBLVRenderParams->vPartyPos.z <= v61 ) + { + v63 = v1->pBounding.z1; + if ( pBLVRenderParams->vPartyPos.z >= v63 ) + v62 = 0; + else + v62 = v63 - pBLVRenderParams->vPartyPos.z; + } + else + { + v62 = pBLVRenderParams->vPartyPos.z - v61; + } + v64 = v62 * v62 + v60; + if ( v64 ) + stru_F8AD28.field_34 = integer_sqrt(v64) << 16; + else + stru_F8AD28.field_34 = 0; + v68 = (BLVFaceExtra *)abs(stru_F8AD28.rotated_normal.y); + v65 = (double)(signed int)v68; + if ( v65 >= 655.36 ) + { + if ( v65 >= 26214.4 ) + { + if ( v65 >= 45875.2 ) + { + stru_F8AD28.field_44 = 8; + stru_F8AD28.field_48 = 3; + } + else + { + stru_F8AD28.field_44 = 16; + stru_F8AD28.field_48 = 4; + } + } + else + { + stru_F8AD28.field_44 = 32; + stru_F8AD28.field_48 = 5; + } + } + else + { + stru_F8AD28.field_44 = 64; + stru_F8AD28.field_48 = 6; + } +} + +//----- (004AF412) -------------------------------------------------------- +int __cdecl sr_4AF412() +{ + int v0; // ST20_4@2 + int v1; // ST20_4@2 + int v2; // ST20_4@2 + int v3; // esi@2 + int v4; // ST20_4@2 + int v5; // ecx@2 + int v6; // ebx@2 + int v7; // edi@2 + int v8; // edx@2 + int v9; // eax@2 + int result; // eax@4 + + stru_F8AD28.plane_4.vNormal.z = -65536; + stru_F8AD28.vec_20.y = -65536; + stru_F8AD28.plane_4.vNormal.x = 0; + stru_F8AD28.plane_4.vNormal.y = 0; + stru_F8AD28.plane_4.dist = (pBLVRenderParams->vPartyPos.z + 800) << 16; + stru_F8AD28.vec_14.x = 65536; + stru_F8AD28.vec_14.y = 0; + stru_F8AD28.vec_14.z = 0; + stru_F8AD28.vec_20.x = 0; + stru_F8AD28.vec_20.z = 0; + stru_F8AD28.uDefaultAmbientLightLevel = 0; + if ( pBLVRenderParams->sPartyRotX ) + { + v0 = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) + - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)pBLVRenderParams->sSineY) >> 16); + stru_F8AD28.rotated_normal.x = ((unsigned __int64)(v0 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) + - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z + * (signed __int64)pBLVRenderParams->sSineNegX) >> 16); + stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x + * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y + * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + stru_F8AD28.rotated_normal.z = ((unsigned __int64)(v0 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) + + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z + * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); + v1 = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) + - ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16); + stru_F8AD28.vec_60.y = ((unsigned __int64)(v1 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) + - ((unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16); + stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + stru_F8AD28.field_6C = ((unsigned __int64)(v1 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); + v2 = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) + - ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16); + stru_F8AD28.vec_70.x = ((unsigned __int64)(v2 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) + - ((unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16); + stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + stru_F8AD28.vec_70.z = ((unsigned __int64)(v2 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); + v3 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y + + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x); + v4 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y + - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x; + v5 = ((unsigned __int64)(v4 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) + - ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16); + v6 = pBLVRenderParams->vPartyPos.z; + v7 = ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) + + ((unsigned __int64)(v4 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16); + v8 = pBLVRenderParams->vPartyPos.y; + v9 = pBLVRenderParams->vPartyPos.x; + } + else + { + stru_F8AD28.rotated_normal.x = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x + * (signed __int64)pBLVRenderParams->sCosineY) >> 16) + - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y + * (signed __int64)pBLVRenderParams->sSineY) >> 16); + stru_F8AD28.rotated_normal.z = stru_F8AD28.plane_4.vNormal.z; + stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x + * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y + * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + stru_F8AD28.vec_60.y = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) + - ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16); + stru_F8AD28.field_6C = stru_F8AD28.vec_14.z; + stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + stru_F8AD28.vec_70.x = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) + - ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16); + v8 = pBLVRenderParams->vPartyPos.y; + stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); + stru_F8AD28.vec_70.z = stru_F8AD28.vec_20.z; + v9 = pBLVRenderParams->vPartyPos.x; + v5 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y + - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x; + v6 = pBLVRenderParams->vPartyPos.z; + v3 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y + + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x); + v7 = -65536 * pBLVRenderParams->vPartyPos.z; + } + stru_F8AD28.field_7C = stru_F8AD28.rotated_normal.x; + stru_F8AD28.vec_60.x = stru_F8AD28.plane_4.vNormal.y * v8 + + stru_F8AD28.plane_4.dist + + stru_F8AD28.plane_4.vNormal.x * v9 + + stru_F8AD28.plane_4.vNormal.z * v6; + stru_F8AD28.vec_80.x = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) + * (signed __int64)stru_F8AD28.rotated_normal.y) >> 16; + stru_F8AD28.vec_80.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) + * (signed __int64)stru_F8AD28.rotated_normal.z) >> 16; + stru_F8AD28.vec_80.z = -stru_F8AD28.vec_60.x; + stru_F8AD28.vec_8C.x = stru_F8AD28.vec_60.y; + stru_F8AD28.vec_8C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_60.z) >> 16; + stru_F8AD28.vec_8C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.field_6C) >> 16; + stru_F8AD28.vec_9C.x = stru_F8AD28.vec_70.x; + stru_F8AD28.field_98 = -(((unsigned __int64)(stru_F8AD28.vec_60.y * (signed __int64)v5) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_60.z * (signed __int64)v3) >> 16) + + ((unsigned __int64)(stru_F8AD28.field_6C * (signed __int64)v7) >> 16)); + stru_F8AD28.vec_9C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.y) >> 16; + stru_F8AD28.vec_9C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.z) >> 16; + result = 0; + stru_F8AD28.field_A8 = -(((unsigned __int64)(stru_F8AD28.vec_70.x * (signed __int64)v5) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_70.y * (signed __int64)v3) >> 16) + + ((unsigned __int64)(stru_F8AD28.vec_70.z * (signed __int64)v7) >> 16)); + stru_F8AD28.field_38 = 0; + stru_F8AD28.field_3E4 = 0; + stru_F8AD28.uCurrentAmbientLightLevel = 0; + stru_F8AD28.uNumLightsApplied = 0; + stru_F8AD28.field_34 = 0; + return result; +} +//----- (004ADD1D) -------------------------------------------------------- +void __fastcall sr_4ADD1D(int uFaceID) +{ + int v1; // edi@1 + BLVFace *v2; // esi@3 + signed int v3; // ebx@4 + Texture *v4; // edi@9 + signed int v5; // eax@9 + char *v6; // edi@12 + signed int v7; // eax@15 + unsigned int v8; // eax@16 + __int16 v9; // cx@19 + unsigned __int8 *v10; // eax@19 + unsigned __int16 *v11; // eax@19 + int v12; // edi@19 + int v13; // ebx@20 + stru352 *v14; // esi@20 + DWORD v15; // eax@22 + signed int v16; // ecx@22 + signed int v17; // ST68_4@22 + int v18; // eax@22 + int v19; // ecx@22 + unsigned int v20; // esi@23 + int v21; // edi@23 + int v22; // eax@23 + int *v23; // ebx@24 + int v24; // edx@24 + int v25; // ebx@25 + unsigned __int16 v26; // cx@25 + int v27; // edx@26 + unsigned __int16 v28; // cx@26 + unsigned __int8 v29; // sf@27 + unsigned __int8 v30; // of@27 + unsigned int v31; // esi@29 + int v32; // edi@29 + unsigned __int16 *v33; // eax@29 + int *v34; // ebx@30 + int v35; // edx@30 + int v36; // ebx@31 + unsigned __int16 v37; // cx@31 + int v38; // edx@32 + unsigned __int16 v39; // cx@32 + Texture *v40; // [sp-10h] [bp-6Ch]@16 + int v41; // [sp-Ch] [bp-68h]@15 + unsigned int v42; // [sp+10h] [bp-4Ch]@1 + signed int v43; // [sp+14h] [bp-48h]@12 + signed int v44; // [sp+14h] [bp-48h]@22 + int v45; // [sp+1Ch] [bp-40h]@22 + int v46; // [sp+20h] [bp-3Ch]@22 + int v47; // [sp+24h] [bp-38h]@19 + char v48; // [sp+28h] [bp-34h]@19 + int v49; // [sp+2Ch] [bp-30h]@19 + unsigned __int8 *v50; // [sp+30h] [bp-2Ch]@19 + unsigned __int16 *v51; // [sp+34h] [bp-28h]@19 + int v52; // [sp+38h] [bp-24h]@22 + int v53; // [sp+3Ch] [bp-20h]@22 + signed int v54; // [sp+40h] [bp-1Ch]@12 + int v55; // [sp+40h] [bp-1Ch]@20 + int v56; // [sp+44h] [bp-18h]@20 + stru352 *i; // [sp+48h] [bp-14h]@20 + unsigned __int16 *v58; // [sp+4Ch] [bp-10h]@23 + int v59; // [sp+50h] [bp-Ch]@4 + int v60; // [sp+50h] [bp-Ch]@19 + int v61; // [sp+54h] [bp-8h]@22 + int *v62; // [sp+58h] [bp-4h]@23 + int *v63; // [sp+58h] [bp-4h]@29 + + v1 = uFaceID; + v42 = pRenderer->uTargetSurfacePitch; + if ( uFaceID >= 0 && uFaceID < (signed int)pIndoor->uNumFaces ) + { + v2 = &pIndoor->pFaces[uFaceID]; + if ( pRenderer->pRenderD3D ) + { + v3 = sr_424579(uFaceID, &stru_F8AD28); + v59 = v3; + } + else + { + v59 = GetPortalScreenCoord(uFaceID); + v3 = v59; + } + if ( v3 && (pRenderer->pRenderD3D || PortalFrustrum(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1)) ) + { + v4 = v2->GetTexture(); + v5 = 0; + if ( v4 ) + { + if ( pRenderer->pRenderD3D ) + { + if ( v3 > 0 ) + { + v54 = v3; + v43 = v3; + v6 = (char *)&array_507D30[0].v; + do + { + *((float *)v6 - 1) = (double)((GetTickCount() >> 5) - pBLVRenderParams->vPartyPos.x) + *((float *)v6 - 1); + *(float *)v6 = (double)(pBLVRenderParams->vPartyPos.y + (GetTickCount() >> 5)) + *(float *)v6; + v6 += 48; + --v54; + } + while ( v54 ); + v3 = v59; + v5 = v43; + } + v7 = v5; + v41 = stru_F8AD28.field_0; + array_507D30[v7].u = array_507D30[v7].u * 0.25; + array_507D30[v7].v = array_507D30[v7].v * 0.25; + if ( BYTE1(v2->uAttributes) & 0x40 ) + { + v40 = v2->GetTexture(); + v8 = pTextureFrameTable->GetFrameTexture(v2->uBitmapID, pBLVRenderParams->field_0_timer_); + } + else + { + v40 = v2->GetTexture(); + v8 = v2->uBitmapID; + } + pRenderer->DrawIndoorPolygon(v3, v2, pBitmaps_LOD->pHardwareTextures[v8], v40, v41, -1, 0); + } + else + { + v49 = v4->uWidthMinus1; + v47 = v4->uHeightMinus1 << 16; + v9 = 16 - v4->uWidthLn2; + v10 = v4->pLevelOfDetail0_prolly_alpha_mask; + LOBYTE(v2->uAttributes) |= 0x80u; + v48 = v9; + v50 = v10; + sr_4AF412(); + ++pBLVRenderParams->uNumFacesRenderedThisFrame; + v11 = sr_sub_47C24C_get_palette(v2, v4->palette_id2, 0, 1); + v12 = stru_F8A590._viewport_space_y; + v51 = v11; + v60 = stru_F8A590._viewport_space_y; + if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) + { + v13 = 2 * stru_F8A590._viewport_space_y; + v14 = &stru_F83B80[stru_F8A590._viewport_space_y]; + v55 = 2 * stru_F8A590._viewport_space_y; + v56 = 640 * stru_F8A590._viewport_space_y; + for ( i = &stru_F83B80[stru_F8A590._viewport_space_y]; ; v14 = i ) + { + sr_4AE1E7(v12, *(__int16 *)((char *)stru_F8A590.viewport_left_side + v13), v12); + v14->field_0 += (GetTickCount() << 11) - (pBLVRenderParams->vPartyPos.x << 16); + v15 = GetTickCount(); + v16 = v14->field_0; + v14->field_4 += (32 * pBLVRenderParams->vPartyPos.y + v15) << 11; + v45 = v14->field_4 >> 3; + v44 = v16 >> 3; + v17 = (signed int)((unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)v14->field_28) >> 16) >> 3; + v52 = (unsigned __int64)(v17 * (signed __int64)-pBLVRenderParams->sSineY) >> 16; + v53 = (unsigned __int64)(v17 * (signed __int64)pBLVRenderParams->sCosineY) >> 16; + v18 = v14->field_28; + v19 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v13); + LOWORD(v18) = 0; + v46 = stru_F8AD28.field_0 | v18; + v61 = *(__int16 *)((char *)stru_F8A590.viewport_right_side + v13) - v19; + if ( LOBYTE(viewparams->field_20) ) + { + v63 = &pBLVRenderParams->pTargetZBuffer[2 * (v19 + 320 * (v13 - pBLVRenderParams->uViewportY)) + - pBLVRenderParams->uViewportX]; + v31 = v44; + v32 = v45; + v33 = &pBLVRenderParams->pRenderTarget[v42 * (v13 - pBLVRenderParams->uViewportY) + + 2 * v19 + - pBLVRenderParams->uViewportX]; + if ( v61 & 1 ) + { + --v61; + v33 = &pBLVRenderParams->pRenderTarget[v42 * (v13 - pBLVRenderParams->uViewportY) + + 2 * v19 + - pBLVRenderParams->uViewportX + - 2]; + v34 = &pBLVRenderParams->pTargetZBuffer[2 * (v19 + 320 * (v13 - pBLVRenderParams->uViewportY)) + - pBLVRenderParams->uViewportX]; + v35 = v46; + v63 += 2; + goto LABEL_32; + } + while ( 1 ) + { + v30 = __OFSUB__(v61, 2); + v29 = v61 - 2 < 0; + v61 -= 2; + if ( v29 ^ v30 ) + break; + v36 = *(&v50[v49 & (v31 >> 16)] + ((v47 & (unsigned int)v32) >> v48)); + v31 += v52; + v37 = v51[v36]; + v32 += v53; + v34 = v63; + v35 = v46; + *v33 = v37; + v33[1] = v37; + v33[640] = v37; + v33[641] = v37; + v63 += 4; + v34[2] = v46; + v34[3] = v46; + v34[642] = v46; + v34[643] = v46; +LABEL_32: + *v34 = v35; + v34[1] = v35; + v34[640] = v35; + v34[641] = v35; + v38 = v49 & (v31 >> 16); + v33 += 4; + v31 += v52; + v39 = v51[*(&v50[v38] + ((v47 & (unsigned int)v32) >> v48))]; + v32 += v53; + *(v33 - 2) = v39; + *(v33 - 1) = v39; + v33[638] = v39; + v33[639] = v39; + } + } + else + { + v58 = &pBLVRenderParams->pRenderTarget[v19 + v12 * pRenderer->uTargetSurfacePitch]; + v62 = &pBLVRenderParams->pTargetZBuffer[v56 + v19]; + v20 = v44; + v21 = v45; + v22 = (int)v58; + if ( v61 & 1 ) + { + --v61; + v22 = (int)(v58 - 1); + v23 = &pBLVRenderParams->pTargetZBuffer[v56 + v19]; + v24 = v46; + ++v62; + goto LABEL_26; + } + while ( 1 ) + { + v30 = __OFSUB__(v61, 2); + v29 = v61 - 2 < 0; + v61 -= 2; + if ( v29 ^ v30 ) + break; + v25 = *(&v50[v49 & (v20 >> 16)] + ((v47 & (unsigned int)v21) >> v48)); + v20 += v52; + v26 = v51[v25]; + v21 += v53; + v23 = v62; + v24 = v46; + *(short *)v22 = v26; + v62 += 2; + v23[1] = v46; +LABEL_26: + *v23 = v24; + v27 = v49 & (v20 >> 16); + v22 += 4; + v20 += v52; + v28 = v51[*(&v50[v27] + ((v47 & (unsigned int)v21) >> v48))]; + v21 += v53; + *(short *)(v22 - 2) = v28; + } + } + ++v60; + ++i; + v56 += 640; + v55 += 2; + if ( v60 > stru_F8A590._viewport_space_w ) + break; + v13 = v55; + v12 = v60; + } + } + } + } + } + } +} +//----- (004AE1E7) -------------------------------------------------------- +int __fastcall sr_4AE1E7(int a1, int a2, int a3) +{ + int v3; // ebx@1 + int v4; // edi@1 + int v5; // esi@1 + signed __int64 v6; // qtt@3 + int v7; // esi@3 + int v8; // eax@5 + int result; // eax@5 + int v10; // edx@5 + int v11; // [sp+Ch] [bp-8h]@1 + int v12; // [sp+1Ch] [bp+8h]@2 + + v3 = pBLVRenderParams->uViewportCenterY - a3; + v4 = pBLVRenderParams->uViewportCenterX - a2; + v11 = a1; + v5 = (pBLVRenderParams->uViewportCenterY - a3) * stru_F8AD28.vec_80.y + + stru_F8AD28.field_7C + + (pBLVRenderParams->uViewportCenterX - a2) * stru_F8AD28.vec_80.x; + if ( v5 && (v12 = abs(stru_F8AD28.vec_80.z) >> 14, v12 <= abs(v5)) ) + { + LODWORD(v6) = stru_F8AD28.vec_80.z << 16; + HIDWORD(v6) = stru_F8AD28.vec_80.z >> 16; + v7 = v6 / (v3 * stru_F8AD28.vec_80.y + stru_F8AD28.field_7C + v4 * stru_F8AD28.vec_80.x); + } + else + { + v7 = 1073741824; + } + v8 = stru_F8AD28.vec_9C.z; + stru_F83B80[v11].field_0 = ((unsigned __int64)((v3 * stru_F8AD28.vec_8C.z + + stru_F8AD28.vec_8C.x + + v4 * stru_F8AD28.vec_8C.y) + * (signed __int64)v7) >> 16) + + stru_F8AD28.field_98; + result = (unsigned __int64)((v3 * v8 + stru_F8AD28.vec_9C.x + v4 * stru_F8AD28.vec_9C.y) * (signed __int64)v7) >> 16; + v10 = result + stru_F8AD28.field_A8; + stru_F83B80[v11].field_28 = v7; + stru_F83B80[v11].field_4 = v10; + return result; +} //----- (004AC1C9) -------------------------------------------------------- int __thiscall _4AC1C9_get_cpu_speed(unsigned int _this, Vec4_int_ *a2) { @@ -491,4 +11513,767 @@ a2->z = Dst.z; a2->w = Dst.w; return result; -}*/ \ No newline at end of file +} + +//----- (004D714C) -------------------------------------------------------- +int __cdecl sr_sub_4D714C(stru315 *a1) +{ + stru315 *v1; // ebp@0 + stru315 *v2; // ebp@1 + unsigned int v3; // esi@1 + int v4; // edi@1 + int result; // eax@1 + unsigned int *v6; // ebx@2 + int v7; // edx@2 + int v8; // ebx@3 + unsigned __int16 v9; // cx@3 + unsigned int *v10; // ebx@3 + int v11; // edx@3 + int v12; // ebx@4 + unsigned __int8 v13; // sf@5 + unsigned __int8 v14; // of@5 + + v2 = (stru315 *)v1->field_8; + v3 = v2->field_30; + v4 = v2->field_2C; + result = (int)v2->pColorBuffer; + if ( !(v2->field_28 & 1) ) + goto LABEL_5; + --v2->field_28; + result += 2; + v6 = v2->pDepthBuffer; + v7 = v2->field_24; + --v2->pDepthBuffer; + *v6 = v7; + while ( 1 ) + { + v12 = *((char *)v2->pTextureLOD + + (v2->field_C & (v3 >> 16)) + + ((v2->field_8 & (unsigned int)v4) >> LOBYTE(v2->field_10))); + result -= 4; + v3 += v2->field_4; + v4 += v2->field_0; + *(short *)(result + 2) = v2->field_34_palette[v12]; +LABEL_5: + v14 = __OFSUB__(v2->field_28, 2); + v13 = v2->field_28 - 2 < 0; + v2->field_28 -= 2; + if ( v13 ^ v14 ) + break; + v8 = *((char *)v2->pTextureLOD + + (v2->field_C & (v3 >> 16)) + + ((v2->field_8 & (unsigned int)v4) >> LOBYTE(v2->field_10))); + v3 += v2->field_4; + v9 = v2->field_34_palette[v8]; + v4 += v2->field_0; + v10 = v2->pDepthBuffer; + v11 = v2->field_24; + *(short *)result = v9; + v2->pDepthBuffer -= 2; + *v10 = v11; + *(v10 - 1) = v11; + } + v2->pColorBuffer = (unsigned __int16 *)result; + v2->field_30 = v3; + v2->field_2C = v4; + return result; +} + +//----- (004D6FB0) -------------------------------------------------------- +int sr_sub_4D6FB0(stru315 *a1) +{ + int v1; // ebp@1 + unsigned int v2; // esi@1 + unsigned int v3; // edi@1 + int result; // eax@1 + int v5; // ebx@2 + int v6; // edx@2 + int v7; // ebx@3 + __int16 v8; // cx@3 + int v9; // ebx@4 + unsigned __int8 v10; // sf@5 + unsigned __int8 v11; // of@5 + + v1 = a1->field_8; + v2 = *(int *)(v1 + 48); + v3 = *(int *)(v1 + 44); + result = *(int *)(v1 + 64); + if ( !(*(int *)(v1 + 40) & 1) ) + goto LABEL_5; + --*(int *)(v1 + 40); + result -= 2; + v5 = *(int *)(v1 + 60); + v6 = *(int *)(v1 + 36); + *(int *)(v1 + 60) += 4; + while ( 1 ) + { + *(int *)v5 = v6; + v9 = *(char *)(*(int *)(v1 + 56) + + (*(int *)(v1 + 12) & (v2 >> 16)) + + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))); + result += 4; + v2 += *(int *)(v1 + 4); + v3 += *(int *)v1; + *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52) + 2 * v9); +LABEL_5: + v11 = __OFSUB__(*(int *)(v1 + 40), 2); + v10 = *(int *)(v1 + 40) - 2 < 0; + *(int *)(v1 + 40) -= 2; + if ( v10 ^ v11 ) + break; + v7 = *(char *)(*(int *)(v1 + 56) + + (*(int *)(v1 + 12) & (v2 >> 16)) + + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))); + v2 += *(int *)(v1 + 4); + v8 = *(short *)(*(int *)(v1 + 52) + 2 * v7); + v3 += *(int *)v1; + v5 = *(int *)(v1 + 60); + v6 = *(int *)(v1 + 36); + *(short *)result = v8; + *(int *)(v1 + 60) += 8; + *(int *)(v5 + 4) = v6; + } + *(int *)(v1 + 64) = result; + *(int *)(v1 + 48) = v2; + *(int *)(v1 + 44) = v3; + return result; +} + +//----- (004D705A) -------------------------------------------------------- +int sr_sub_4D705A(stru315 *a1) +{ + int v1; // ebp@1 + unsigned int v2; // esi@1 + unsigned int v3; // edi@1 + int result; // eax@1 + int v5; // ebx@2 + int v6; // edx@2 + unsigned int v7; // ebx@3 + unsigned int v8; // edx@3 + __int16 v9; // cx@11 + unsigned int v10; // ebx@12 + unsigned int v11; // edx@12 + unsigned __int8 v12; // sf@21 + unsigned __int8 v13; // of@21 + + v1 = a1->field_8; + v2 = *(int *)(v1 + 48); + v3 = *(int *)(v1 + 44); + result = *(int *)(v1 + 64); + if ( !(*(int *)(v1 + 40) & 1) ) + goto LABEL_21; + --*(int *)(v1 + 40); + result -= 2; + v5 = *(int *)(v1 + 60); + v6 = *(int *)(v1 + 36); + *(int *)(v1 + 60) += 4; + while ( 1 ) + { + *(int *)v5 = v6; + v10 = v3; + v11 = v2; + if ( (signed int)v2 < *(int *)(v1 + 20) ) + v11 = *(int *)(v1 + 20); + if ( (signed int)v3 < *(int *)(v1 + 28) ) + v10 = *(int *)(v1 + 28); + if ( (signed int)v11 > *(int *)(v1 + 24) ) + v11 = *(int *)(v1 + 24); + if ( (signed int)v10 > *(int *)(v1 + 32) ) + v10 = *(int *)(v1 + 32); + result += 4; + v2 += *(int *)(v1 + 4); + v3 += *(int *)v1; + *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52) + + 2 + * *(char *)(*(int *)(v1 + 56) + + (*(int *)(v1 + 12) & (v11 >> 16)) + + ((*(int *)(v1 + 8) & v10) >> *(char *)(v1 + 16)))); +LABEL_21: + v13 = __OFSUB__(*(int *)(v1 + 40), 2); + v12 = *(int *)(v1 + 40) - 2 < 0; + *(int *)(v1 + 40) -= 2; + if ( v12 ^ v13 ) + break; + v7 = v3; + v8 = v2; + if ( (signed int)v2 < *(int *)(v1 + 20) ) + v8 = *(int *)(v1 + 20); + if ( (signed int)v3 < *(int *)(v1 + 28) ) + v7 = *(int *)(v1 + 28); + if ( (signed int)v8 > *(int *)(v1 + 24) ) + v8 = *(int *)(v1 + 24); + if ( (signed int)v7 > *(int *)(v1 + 32) ) + v7 = *(int *)(v1 + 32); + v2 += *(int *)(v1 + 4); + v9 = *(short *)(*(int *)(v1 + 52) + + 2 + * *(char *)(*(int *)(v1 + 56) + + (*(int *)(v1 + 12) & (v8 >> 16)) + + ((*(int *)(v1 + 8) & v7) >> *(char *)(v1 + 16)))); + v3 += *(int *)v1; + v5 = *(int *)(v1 + 60); + v6 = *(int *)(v1 + 36); + *(short *)result = v9; + *(int *)(v1 + 60) += 8; + *(int *)(v5 + 4) = v6; + } + *(int *)(v1 + 64) = result; + *(int *)(v1 + 48) = v2; + *(int *)(v1 + 44) = v3; + return result; +} + +//----- (004D71F8) -------------------------------------------------------- +int __cdecl sr_sub_4D71F8(stru315 *a1) +{ + stru315 *v1; // ebp@0 + stru315 *v2; // ebp@1 + int v3; // esi@1 + int v4; // edi@1 + int result; // eax@1 + unsigned int *v6; // ebx@2 + int v7; // edx@2 + int v8; // ebx@3 + unsigned int v9; // edx@3 + unsigned __int16 v10; // cx@11 + unsigned int *v11; // ebx@11 + int v12; // edx@11 + int v13; // ebx@12 + unsigned int v14; // edx@12 + unsigned __int8 v15; // sf@21 + unsigned __int8 v16; // of@21 + + v2 = (stru315 *)v1->field_8; + v3 = v2->field_30; + v4 = v2->field_2C; + result = (int)v2->pColorBuffer; + if ( !(v2->field_28 & 1) ) + goto LABEL_21; + --v2->field_28; + result += 2; + v6 = v2->pDepthBuffer; + v7 = v2->field_24; + --v2->pDepthBuffer; + *v6 = v7; + while ( 1 ) + { + v13 = v4; + v14 = v3; + if ( v3 < v2->field_14 ) + v14 = v2->field_14; + if ( v4 < v2->field_1C ) + v13 = v2->field_1C; + if ( (signed int)v14 > v2->field_18 ) + v14 = v2->field_18; + if ( v13 > v2->field_20 ) + v13 = v2->field_20; + result -= 4; + v3 += v2->field_4; + v4 += v2->field_0; + *(short *)(result + 2) = v2->field_34_palette[*((char *)v2->pTextureLOD + + (v2->field_C & (v14 >> 16)) + + ((v2->field_8 & (unsigned int)v13) >> LOBYTE(v2->field_10)))]; +LABEL_21: + v16 = __OFSUB__(v2->field_28, 2); + v15 = v2->field_28 - 2 < 0; + v2->field_28 -= 2; + if ( v15 ^ v16 ) + break; + v8 = v4; + v9 = v3; + if ( v3 < v2->field_14 ) + v9 = v2->field_14; + if ( v4 < v2->field_1C ) + v8 = v2->field_1C; + if ( (signed int)v9 > v2->field_18 ) + v9 = v2->field_18; + if ( v8 > v2->field_20 ) + v8 = v2->field_20; + v3 += v2->field_4; + v10 = v2->field_34_palette[*((char *)v2->pTextureLOD + + (v2->field_C & (v9 >> 16)) + + ((v2->field_8 & (unsigned int)v8) >> LOBYTE(v2->field_10)))]; + v4 += v2->field_0; + v11 = v2->pDepthBuffer; + v12 = v2->field_24; + *(short *)result = v10; + v2->pDepthBuffer -= 2; + *v11 = v12; + *(v11 - 1) = v12; + } + v2->pColorBuffer = (unsigned __int16 *)result; + v2->field_30 = v3; + v2->field_2C = v4; + return result; +} + +//----- (004D754B) -------------------------------------------------------- +void __cdecl sr_sub_4D754B(stru315 *a1, stru316 *a2) +{ + int v2; // ecx@1 + unsigned int v3; // eax@2 + int v4; // ecx@2 + int v5; // eax@10 + unsigned __int16 *v6; // edx@10 + int v7; // ebx@11 + int v8; // ecx@13 + unsigned __int16 v9; // bx@16 + int v10; // ecx@16 + unsigned __int16 *v11; // eax@16 + unsigned int *v12; // edx@16 + int v13; // ecx@16 + int v14; // eax@16 + int v15; // ebx@16 + int v16; // [sp-4h] [bp-Ch]@2 + + v2 = a1->field_28; + if ( v2 ) + { + do + { + v16 = v2; + v3 = a1->field_30; + v4 = a1->field_2C; + if ( (signed int)v3 >= a1->field_18 ) + v3 = a1->field_18; + if ( (signed int)v3 <= a1->field_14 ) + v3 = a1->field_14; + if ( v4 >= a1->field_20 ) + v4 = a1->field_20; + if ( v4 <= a1->field_1C ) + v4 = a1->field_1C; + v5 = *((char *)a1->pTextureLOD + (a1->field_C & (v3 >> 16)) + (((unsigned int)v4 & a1->field_8) >> a1->field_10)); + v6 = a1->field_34_palette; + if ( a2->field_20 ) + { + v7 = (unsigned int)a2->field_10 >> 16; + if ( v7 >= a2->field_C ) + v7 = a2->field_C; + v8 = 0; + if ( a2->field_8 - v7 >= 0 ) + v8 = a2->field_8 - v7; + v5 += v8 << 8; + v6 = a2->field_24_palette; + } + v9 = v6[v5]; + v10 = a1->field_24; + v11 = a1->pColorBuffer; + v12 = a1->pDepthBuffer; + *v11 = v9; + *v12 = v10; + a1->pColorBuffer = v11 + 1; + a1->pDepthBuffer = v12 + 1; + v13 = a1->field_30; + a2->field_10 += a2->field_18; + v14 = a1->field_2C; + v15 = a1->field_0; + a1->field_30 = a1->field_4 + v13; + a1->field_2C = v15 + v14; + v2 = v16 - 1; + } + while ( v16 != 1 ); + } +} +//----- (004D73DF) -------------------------------------------------------- +int sr_sub_4D73DF(int a1) +{ + int v1; // ebp@1 + unsigned int v2; // esi@1 + unsigned int v3; // edi@1 + int result; // eax@1 + int v5; // ebx@2 + int v6; // edx@2 + int v7; // edx@3 + int v8; // edx@6 + unsigned __int8 v9; // sf@9 + unsigned __int8 v10; // of@9 + + v1 = *(int *)(a1 + 8); + v2 = *(int *)(v1 + 48); + v3 = *(int *)(v1 + 44); + result = *(int *)(v1 + 64); + if ( !(*(int *)(v1 + 40) & 1) ) + goto LABEL_9; + --*(int *)(v1 + 40); + result -= 2; + v5 = *(int *)(v1 + 60); + v6 = *(int *)(v1 + 36); + *(int *)(v1 + 60) += 4; + while ( 1 ) + { + *(int *)v5 = v6; + v8 = *(int *)(v1 + 12) & (v2 >> 16); + result += 4; + v2 += *(int *)(v1 + 4); + if ( *(char *)(*(int *)(v1 + 56) + v8 + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))) ) + *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52) + + 2 + * *(char *)(*(int *)(v1 + 56) + + v8 + + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16)))); + v3 += *(int *)v1; +LABEL_9: + v10 = __OFSUB__(*(int *)(v1 + 40), 2); + v9 = *(int *)(v1 + 40) - 2 < 0; + *(int *)(v1 + 40) -= 2; + if ( v9 ^ v10 ) + break; + v7 = *(int *)(v1 + 12) & (v2 >> 16); + v2 += *(int *)(v1 + 4); + if ( *(char *)(*(int *)(v1 + 56) + v7 + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))) ) + *(short *)result = *(short *)(*(int *)(v1 + 52) + + 2 + * *(char *)(*(int *)(v1 + 56) + + v7 + + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16)))); + v3 += *(int *)v1; + v5 = *(int *)(v1 + 60); + v6 = *(int *)(v1 + 36); + *(int *)(v1 + 60) += 8; + *(int *)(v5 + 4) = v6; + } + return result; +} + +//----- (004D72EC) -------------------------------------------------------- +int sr_sub_4D72EC(int a1) +{ + int v1; // ebp@1 + unsigned int v2; // esi@1 + unsigned int v3; // edi@1 + int result; // eax@1 + int v5; // ebx@2 + int v6; // edx@2 + unsigned int v7; // edx@3 + unsigned int v8; // ebx@3 + int v9; // ebx@11 + unsigned int v10; // edx@14 + unsigned int v11; // ebx@14 + int v12; // ebx@22 + unsigned __int8 v13; // sf@25 + unsigned __int8 v14; // of@25 + + v1 = *(int *)(a1 + 8); + v2 = *(int *)(v1 + 48); + v3 = *(int *)(v1 + 44); + result = *(int *)(v1 + 64); + if ( !(*(int *)(v1 + 40) & 1) ) + goto LABEL_25; + --*(int *)(v1 + 40); + result -= 2; + v5 = *(int *)(v1 + 60); + v6 = *(int *)(v1 + 36); + *(int *)(v1 + 60) += 4; + while ( 1 ) + { + *(int *)v5 = v6; + v10 = v2; + v11 = v3; + if ( (signed int)v2 < *(int *)(v1 + 20) ) + v10 = *(int *)(v1 + 20); + if ( (signed int)v3 < *(int *)(v1 + 28) ) + v11 = *(int *)(v1 + 28); + if ( (signed int)v10 > *(int *)(v1 + 24) ) + v10 = *(int *)(v1 + 24); + if ( (signed int)v11 > *(int *)(v1 + 32) ) + v11 = *(int *)(v1 + 32); + v12 = *(char *)(*(int *)(v1 + 56) + + (*(int *)(v1 + 12) & (v10 >> 16)) + + ((*(int *)(v1 + 8) & v11) >> *(char *)(v1 + 16))); + result += 4; + v2 += *(int *)(v1 + 4); + if ( v12 ) + *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52) + 2 * v12); + v3 += *(int *)v1; +LABEL_25: + v14 = __OFSUB__(*(int *)(v1 + 40), 2); + v13 = *(int *)(v1 + 40) - 2 < 0; + *(int *)(v1 + 40) -= 2; + if ( v13 ^ v14 ) + break; + v7 = v2; + v8 = v3; + if ( (signed int)v2 < *(int *)(v1 + 20) ) + v7 = *(int *)(v1 + 20); + if ( (signed int)v3 < *(int *)(v1 + 28) ) + v8 = *(int *)(v1 + 28); + if ( (signed int)v7 > *(int *)(v1 + 24) ) + v7 = *(int *)(v1 + 24); + if ( (signed int)v8 > *(int *)(v1 + 32) ) + v8 = *(int *)(v1 + 32); + v9 = *(char *)(*(int *)(v1 + 56) + + (*(int *)(v1 + 12) & (v7 >> 16)) + + ((*(int *)(v1 + 8) & v8) >> *(char *)(v1 + 16))); + v2 += *(int *)(v1 + 4); + if ( v9 ) + *(short *)result = *(short *)(*(int *)(v1 + 52) + 2 * v9); + v3 += *(int *)v1; + v5 = *(int *)(v1 + 60); + v6 = *(int *)(v1 + 36); + *(int *)(v1 + 60) += 8; + *(int *)(v5 + 4) = v6; + } + return result; +} + +//----- (004D7630) -------------------------------------------------------- +void __cdecl sr_sub_4D7630(stru315 *a1, stru316 *a2) +{ + int v2; // ecx@1 + int v3; // eax@2 + unsigned __int16 *v4; // edx@2 + int v5; // ebx@3 + int v6; // ecx@5 + unsigned __int16 v7; // bx@8 + int v8; // ecx@8 + unsigned __int16 *v9; // eax@8 + unsigned int *v10; // edx@8 + int v11; // ecx@8 + int v12; // eax@8 + int v13; // ebx@8 + int v14; // [sp-4h] [bp-Ch]@2 + + v2 = a1->field_28; + if ( v2 ) + { + do + { + v14 = v2; + v3 = *((char *)a1->pTextureLOD + + (a1->field_C & ((unsigned int)a1->field_30 >> 16)) + + ((unsigned int)(a1->field_2C & a1->field_8) >> a1->field_10)); + v4 = a1->field_34_palette; + if ( a2->field_20 ) + { + v5 = (unsigned int)a2->field_14 >> 16; + if ( v5 >= a2->field_C ) + v5 = a2->field_C; + v6 = 0; + if ( a2->field_8 - v5 >= 0 ) + v6 = a2->field_8 - v5; + v3 += v6 << 8; + v4 = a2->field_24_palette; + } + v7 = v4[v3]; + v8 = a1->field_24; + v9 = a1->pColorBuffer; + v10 = a1->pDepthBuffer; + *v9 = v7; + *v10 = v8; + a1->pColorBuffer = v9 - 1; + a1->pDepthBuffer = v10 - 1; + v11 = a1->field_30; + a2->field_14 -= a2->field_18; + v12 = a1->field_2C; + v13 = a1->field_0; + a1->field_30 = a1->field_4 + v11; + a1->field_2C = v13 + v12; + v2 = v14 - 1; + } + while ( v14 != 1 ); + } +} + +//----- (004D76ED) -------------------------------------------------------- +void __cdecl sr_sub_4D76ED(stru315 *a1, stru316 *a2) +{ + int v2; // ecx@1 + unsigned int v3; // eax@2 + int v4; // ecx@2 + int v5; // eax@10 + unsigned __int16 *v6; // edx@10 + int v7; // ebx@11 + int v8; // ecx@13 + unsigned __int16 v9; // bx@16 + int v10; // ecx@16 + unsigned __int16 *v11; // eax@16 + unsigned int *v12; // edx@16 + int v13; // ecx@16 + int v14; // eax@16 + int v15; // ebx@16 + int v16; // [sp-4h] [bp-Ch]@2 + + v2 = a1->field_28; + if ( v2 ) + { + do + { + v16 = v2; + v3 = a1->field_30; + v4 = a1->field_2C; + if ( (signed int)v3 >= a1->field_18 ) + v3 = a1->field_18; + if ( (signed int)v3 <= a1->field_14 ) + v3 = a1->field_14; + if ( v4 >= a1->field_20 ) + v4 = a1->field_20; + if ( v4 <= a1->field_1C ) + v4 = a1->field_1C; + v5 = *((char *)a1->pTextureLOD + (a1->field_C & (v3 >> 16)) + (((unsigned int)v4 & a1->field_8) >> a1->field_10)); + v6 = a1->field_34_palette; + if ( a2->field_20 ) + { + v7 = (unsigned int)a2->field_14 >> 16; + if ( v7 >= a2->field_C ) + v7 = a2->field_C; + v8 = 0; + if ( a2->field_8 - v7 >= 0 ) + v8 = a2->field_8 - v7; + v5 += v8 << 8; + v6 = a2->field_24_palette; + } + v9 = v6[v5]; + v10 = a1->field_24; + v11 = a1->pColorBuffer; + v12 = a1->pDepthBuffer; + *v11 = v9; + *v12 = v10; + a1->pColorBuffer = v11 - 1; + a1->pDepthBuffer = v12 - 1; + v13 = a1->field_30; + a2->field_14 -= a2->field_18; + v14 = a1->field_2C; + v15 = a1->field_0; + a1->field_30 = a1->field_4 + v13; + a1->field_2C = v15 + v14; + v2 = v16 - 1; + } + while ( v16 != 1 ); + } +} + +//----- (004D77D2) -------------------------------------------------------- +void __cdecl sr_sub_4D77D2(stru315 *a1, stru316 *a2) +{ + int v2; // ecx@1 + unsigned __int16 *v3; // ebx@2 + int v4; // eax@2 + unsigned __int16 *v5; // edx@2 + int v6; // ebx@4 + int v7; // ecx@6 + unsigned __int16 v8; // bx@9 + int v9; // ecx@9 + unsigned int *v10; // edx@9 + unsigned int *v11; // edx@10 + int v12; // ecx@10 + int v13; // eax@10 + int v14; // ebx@10 + int v15; // [sp-4h] [bp-Ch]@2 + + v2 = a1->field_28; + if ( v2 ) + { + do + { + v15 = v2; + v3 = a1->pTextureLOD; + v4 = *((char *)v3 + + (a1->field_C & ((unsigned int)a1->field_30 >> 16)) + + ((unsigned int)(a1->field_2C & a1->field_8) >> a1->field_10)); + v5 = a1->field_34_palette; + if ( *((char *)v3 + + (a1->field_C & ((unsigned int)a1->field_30 >> 16)) + + ((unsigned int)(a1->field_2C & a1->field_8) >> a1->field_10)) ) + { + if ( a2->field_20 ) + { + v6 = (unsigned int)a2->field_10 >> 16; + if ( v6 >= a2->field_C ) + v6 = a2->field_C; + v7 = 0; + if ( a2->field_8 - v6 >= 0 ) + v7 = a2->field_8 - v6; + v4 += v7 << 8; + v5 = a2->field_24_palette; + } + v8 = v5[v4]; + v9 = a1->field_24; + v10 = a1->pDepthBuffer; + *a1->pColorBuffer = v8; + *v10 = v9; + } + v11 = a1->pDepthBuffer + 1; + ++a1->pColorBuffer; + a1->pDepthBuffer = v11; + v12 = a1->field_30; + a2->field_10 += a2->field_18; + v13 = a1->field_2C; + v14 = a1->field_0; + a1->field_30 = a1->field_4 + v12; + a1->field_2C = v14 + v13; + v2 = v15 - 1; + } + while ( v15 != 1 ); + } +} +//----- (004D789A) -------------------------------------------------------- +void __cdecl sr_sub_4D789A(stru315 *a1, stru316 *a2) +{ + int v2; // ecx@1 + unsigned int v3; // eax@2 + int v4; // ecx@2 + int v5; // eax@10 + unsigned __int16 *v6; // edx@10 + int v7; // ebx@12 + int v8; // ecx@14 + unsigned __int16 v9; // bx@17 + int v10; // ecx@17 + unsigned int *v11; // edx@17 + unsigned int *v12; // edx@18 + int v13; // ecx@18 + int v14; // eax@18 + int v15; // ebx@18 + int v16; // [sp-4h] [bp-Ch]@2 + + v2 = a1->field_28; + if ( v2 ) + { + do + { + v16 = v2; + v3 = a1->field_30; + v4 = a1->field_2C; + if ( (signed int)v3 >= a1->field_18 ) + v3 = a1->field_18; + if ( (signed int)v3 <= a1->field_14 ) + v3 = a1->field_14; + if ( v4 >= a1->field_20 ) + v4 = a1->field_20; + if ( v4 <= a1->field_1C ) + v4 = a1->field_1C; + v5 = *((char *)a1->pTextureLOD + (a1->field_C & (v3 >> 16)) + (((unsigned int)v4 & a1->field_8) >> a1->field_10)); + v6 = a1->field_34_palette; + if ( v5 ) + { + if ( a2->field_20 ) + { + v7 = (unsigned int)a2->field_10 >> 16; + if ( v7 >= a2->field_C ) + v7 = a2->field_C; + v8 = 0; + if ( a2->field_8 - v7 >= 0 ) + v8 = a2->field_8 - v7; + v5 += v8 << 8; + v6 = a2->field_24_palette; + } + v9 = v6[v5]; + v10 = a1->field_24; + v11 = a1->pDepthBuffer; + *a1->pColorBuffer = v9; + *v11 = v10; + } + v12 = a1->pDepthBuffer + 1; + ++a1->pColorBuffer; + a1->pDepthBuffer = v12; + v13 = a1->field_30; + a2->field_10 += a2->field_18; + v14 = a1->field_2C; + v15 = a1->field_0; + a1->field_30 = a1->field_4 + v13; + a1->field_2C = v15 + v14; + v2 = v16 - 1; + } + while ( v16 != 1 ); + } +} +*/ \ No newline at end of file
--- a/mm7_1.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/mm7_1.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -135,34 +135,6 @@ a1->DrawText(a2, 32, uY, 0, pTmpBuf.data(), 0, 0, 0); } -//----- (0042038D) -------------------------------------------------------- -void __cdecl sub_42038D() -{ - POINT *v0; // esi@2 - int v1; // ecx@2 - const char *v2; // eax@3 - POINT v3; // [sp+0h] [bp-10h]@2 - POINT a2; // [sp+8h] [bp-8h]@1 - - __debugbreak(); // invalid indexing - if ( pMouse->GetCursorPos(&a2)->y < 350 ) - { - v0 = pMouse->GetCursorPos(&a2); - v1 = pRenderer->pActiveZBuffer[v0->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v3)->y]]; - if ( v1 ) - { - auto _w = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C - + 18 * *((short *)&pChests[0].igChestItems[139].uExpireTime - + v1 + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); - - _w = (ItemGen *)(&pChests[(unsigned int)pChestWindow->ptr_1C] -32 - + 18 * *((short *)&pChests[(unsigned int)pChestWindow->ptr_1C].igChestItems[139].uExpireTime + v1 + 3)); - v2 = _w->GetDisplayName(); - GameUI_SetFooterString(v2); - } - } -} - //----- (004226C2) -------------------------------------------------------- bool PauseGameDrawing() { @@ -434,368 +406,14 @@ - - -//----- (00423AEE) -------------------------------------------------------- -void __cdecl reset_some_strus_flt_2Cs() -{ - float *v0; // eax@1 - signed int v1; // ecx@1 - signed int v2; // edx@1 - float *v3; // eax@3 - signed int v4; // edx@3 - float *v5; // eax@5 - signed int v6; // edx@5 - float *v7; // eax@7 - signed int v8; // edx@7 - float *v9; // eax@9 - - v0 = &array_50AC10[0].flt_2C; - v1 = 50; - v2 = 50; - do - { - *v0 = 0.0; - v0 += 12; - --v2; - } - while ( v2 ); - v3 = &array_50A2B0[0].flt_2C; - v4 = 50; - do - { - *v3 = 0.0; - v3 += 12; - --v4; - } - while ( v4 ); - v5 = &array_509950[0].flt_2C; - v6 = 50; - do - { - *v5 = 0.0; - v5 += 12; - --v6; - } - while ( v6 ); - v7 = &array_508FF0[0].flt_2C; - v8 = 50; - do - { - *v7 = 0.0; - v7 += 12; - --v8; - } - while ( v8 ); - v9 = &array_508690[0].flt_2C; - do - { - *v9 = 0.0; - v9 += 12; - --v1; - } - while ( v1 ); -} - -//----- (00423B4A) -------------------------------------------------------- -void __cdecl sub_423B4A() -{ - float *v0; // eax@1 - signed int v1; // ecx@1 - - v0 = &array_507D30[0].flt_2C; - v1 = 50; - do - { - *v0 = 0.0; - v0 += 12; - --v1; - } - while ( v1 ); -} - -//----- (00424579) -------------------------------------------------------- -int __fastcall sub_424579(int uFaceID, stru320 *a2) +//----- (00424CD7) -------------------------------------------------------- +int sr_424CD7(unsigned int num_vertices) { - __debugbreak(); - return 0; - /*BLVFace *v2; // eax@1 - Vec3_short_ *v3; // ebx@1 - Vec3_short_ *v4; // esi@1 - unsigned int v5; // esi@3 - int v7; // ST1C_4@5 - int v8; // ST1C_4@5 - int v9; // ST1C_4@5 - int v10; // ST1C_4@5 - int v11; // esi@5 - int v12; // ST1C_4@5 - unsigned int v15; // ecx@8 - unsigned int v19; // ecx@13 - signed int v20; // ecx@16 - signed int result; // eax@20 - signed int v24; // edx@22 - unsigned int v25; // [sp+Ch] [bp-1Ch]@3 - float v26; // [sp+14h] [bp-14h]@3 - float v27; // [sp+1Ch] [bp-Ch]@3 - float v28; // [sp+20h] [bp-8h]@3 - signed int v29; // [sp+24h] [bp-4h]@3 - - v2 = &pIndoor->pFaces[uFaceID]; - v3 = pIndoor->pVertices; - v4 = &pIndoor->pVertices[*v2->pVertexIDs]; - if ( v2->pFacePlane_old.vNormal.x * ((signed __int16)*(int *)&v4->x - pBLVRenderParams->vPartyPos.x) - + v2->pFacePlane_old.vNormal.y * ((signed __int16)(*(int *)&v4->x >> 16) - pBLVRenderParams->vPartyPos.y) - + v2->pFacePlane_old.vNormal.z * (v4->z - pBLVRenderParams->vPartyPos.z) < 0 ) - { - PortalFace.field_0 = 1; - } - else - { - PortalFace.field_0 = 0; - if ( !(v2->uAttributes & 1) ) - return 0; - } - v29 = 0; - v5 = v2->uNumVertices; - __asm { fld pBLVRenderParams->fCosineY } - v28 = pBLVRenderParams->fSineY; - v26 = pBLVRenderParams->fCosineNegX; - v27 = pBLVRenderParams->fSineNegX; - v25 = v5; - if ( (signed int)v5 > 0 ) - { - _ECX = (char *)&array_50AC10[0].vWorldPosition.z; - do - { - v7 = v3[v2->pVertexIDs[v29]].x; - __asm - { - fild [ebp+var_10] - fstp dword ptr [ecx-8] - } - v8 = v3[v2->pVertexIDs[v29]].y; - __asm - { - fild [ebp+var_10] - fstp dword ptr [ecx-4] - } - v9 = v3[v2->pVertexIDs[v29]].z; - __asm - { - fild [ebp+var_10] - fstp dword ptr [ecx] - } - _ECX += 48; - v10 = a2->pDeltaUV[0] + v2->pVertexUIDs[v29]; - __asm - { - fild [ebp+var_10] - fstp dword ptr [ecx-14h] - } - v11 = a2->pDeltaUV[1] + v2->pVertexVIDs[v29++]; - v12 = v11; - v5 = v25; - __asm - { - fild [ebp+var_10] - fstp dword ptr [ecx-10h] - } - } - while ( v29 < (signed int)v25 ); - } - _EDX = (char *)&array_50AC10[0].vWorldViewPosition; - if ( pBLVRenderParams->sPartyRotX ) - { - if ( (signed int)v5 > 0 ) - { - __asm - { - fild pBLVRenderParams->vPartyPos.x - fild pBLVRenderParams->vPartyPos.y - fild pBLVRenderParams->vPartyPos.z - } - _EAX = (char *)&array_50AC10[0].vWorldPosition.z; - v15 = v5; - do - { - __asm - { - fld dword ptr [eax-8] - fsub st, st(3) - fld dword ptr [eax-4] - fsub st, st(3) - fld st(1) - fmul st, st(6) - fld st(1) - fmul [ebp+var_8] - fsubp st(1), st - fstp [ebp+var_4] - fld dword ptr [eax] - fsub st, st(3) - } - _EAX += 48; - --v15; - __asm - { - fstp [ebp+var_10] - fld [ebp+var_4] - fmul [ebp+var_14] - fld [ebp+var_10] - fmul [ebp+var_C] - fsubp st(1), st - fstp dword ptr [eax-2Ch] - fld st(1) - fmul [ebp+var_8] - fld st(1) - fmul st, st(7) - faddp st(1), st - fstp dword ptr [eax-28h] - fstp st - fstp st - fld [ebp+var_4] - fmul [ebp+var_C] - fld [ebp+var_10] - fmul [ebp+var_14] - faddp st(1), st - fstp dword ptr [eax-24h] - } - } - while ( v15 ); -LABEL_15: - __asm - { - fstp st - fstp st - fstp st - } - goto LABEL_16; - } - } - else - { - if ( (signed int)v5 > 0 ) - { - __asm - { - fild pBLVRenderParams->vPartyPos.x - fild pBLVRenderParams->vPartyPos.y - fild pBLVRenderParams->vPartyPos.z - } - _EAX = (char *)&array_50AC10[0].vWorldViewPosition; - v19 = v5; - do - { - __asm - { - fld dword ptr [eax-0Ch] - fsub st, st(3) - fld dword ptr [eax-8] - fsub st, st(3) - fld st(1) - fmul st, st(6) - fld st(1) - fmul [ebp+var_8] - fsubp st(1), st - fstp dword ptr [eax] - fld st(1) - fmul [ebp+var_8] - fld st(1) - fmul st, st(7) - } - _EAX += 48; - --v19; - __asm - { - faddp st(1), st - fstp dword ptr [eax-2Ch] - fstp st - fstp st - fld dword ptr [eax-34h] - fsub st, st(1) - fstp dword ptr [eax-28h] - } - } - while ( v19 ); - goto LABEL_15; - } - } -LABEL_16: - v20 = 0; - __asm { fstp st } - if ( (signed int)v5 <= 0 ) - return 0; - do - { - __asm - { - fld dword ptr [edx] - fcomp ds:flt_4D8524 - fnstsw ax - } - if ( !(HIBYTE(_AX) & 1) ) - break; - ++v20; - _EDX += 48; - } - while ( v20 < (signed int)v5 ); - if ( v20 >= (signed int)v5 ) - return 0; - result = sr_424CD7(v5); - if ( result > 0 ) - { - __asm { fild pBLVRenderParams->field_40 } - _ECX = (char *)&array_507D30[0].vWorldViewPosition; - v24 = result; - __asm - { - fmul ds:flt_4D84A4 - fild pBLVRenderParams->uViewportCenterX - fild pBLVRenderParams->uViewportCenterY - } - do - { - __asm - { - fld1 - fdiv dword ptr [ecx] - } - _ECX += 48; - --v24; - __asm - { - fld st - fmul dword ptr [ecx-2Ch] - fmul st, st(4) - fsubr st, st(3) - fstp dword ptr [ecx-24h] - fmul dword ptr [ecx-28h] - fmul st, st(3) - fsubr st, st(1) - fstp dword ptr [ecx-20h] - } - } - while ( v24 ); - __asm - { - fstp st - fstp st - fstp st - } - } - memcpy(&array_507D30[result], array_507D30, sizeof(array_507D30[result])); - return result;*/ -} - -// 50B700: using guessed type int PortalFace.field_0; - -//----- (00424CD7) -------------------------------------------------------- -signed int __fastcall sr_424CD7(unsigned int uVertexID) -{ - unsigned int v1; // edx@1 + //unsigned int v1; // edx@1 signed int v2; // edi@1 char *v3; // esi@4 char *v4; // ecx@4 - unsigned int v5; // eax@4 + //unsigned int v5; // eax@4 char *v6; // edx@4 double v7; // st6@10 double v8; // st5@10 @@ -805,29 +423,30 @@ RenderVertexSoft *v12; // edi@22 char *v13; // eax@22 double v14; // st6@22 - signed int result; // eax@24 - unsigned int v16; // [sp+8h] [bp-28h]@4 + //signed int result; // eax@24 + //unsigned int v16; // [sp+8h] [bp-28h]@4 bool v17; // [sp+Ch] [bp-24h]@6 char *v18; // [sp+10h] [bp-20h]@4 char *v19; // [sp+14h] [bp-1Ch]@4 - signed int v20; // [sp+18h] [bp-18h]@1 + //signed int v20; // [sp+18h] [bp-18h]@1 RenderVertexSoft *v21; // [sp+1Ch] [bp-14h]@4 char *v22; // [sp+20h] [bp-10h]@4 char *v23; // [sp+24h] [bp-Ch]@4 char *v24; // [sp+28h] [bp-8h]@4 char *v25; // [sp+2Ch] [bp-4h]@4 + + if (!num_vertices) + return 0; - v1 = uVertexID; - memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID])); + //v1 = uVertexID; + memcpy(&array_50AC10[num_vertices], array_50AC10, sizeof(array_50AC10[0])); v2 = 0; - v20 = 0; + //v20 = 0; if ( array_50AC10[0].vWorldViewPosition.x >= 8.0 ) v2 = 1; - if ( (signed int)(uVertexID + 1) <= 1 ) - return 0; v3 = (char *)&array_507D30[0].vWorldViewPosition.z; v4 = (char *)&array_507D30[0].vWorldViewPosition.y; - v5 = v1; + //v5 = v1; v23 = (char *)&array_507D30[0]._rhw; v21 = array_507D30; v18 = (char *)&array_507D30[0].vWorldViewPosition.z; @@ -836,8 +455,10 @@ v24 = (char *)&array_507D30[0].v; v25 = (char *)&array_507D30[0].u; v6 = (char *)&array_50AC10[0].v; - v16 = v5; - do + //v16 = v1; + + int out_num_vertices = 0; + for (int i = 0; i < num_vertices; ++i) { v17 = *((float *)v6 + 5) >= 8.0; if ( v2 != v17 ) @@ -867,8 +488,9 @@ { v10 = 0; v11 = *(float *)v3 == *((float *)v6 - 5); - goto LABEL_19; - } + if ( v11 | v10 ) + goto LABEL_21; + } } else { @@ -876,20 +498,17 @@ { v10 = 0; v11 = *(float *)v3 == *((float *)v6 + 7); -LABEL_19: if ( v11 | v10 ) goto LABEL_21; - goto LABEL_20; } } -LABEL_20: ++v21; v22 += 48; v24 += 48; v25 += 48; v4 += 48; v3 += 48; - ++v20; + ++out_num_vertices; v23 += 48; v19 = v4; v18 = v3; @@ -902,7 +521,7 @@ v19 += 48; v18 += 48; v14 = 1.0 / (*((float *)v6 + 5) + 0.0000001); - ++v20; + ++out_num_vertices; v25 += 48; v24 += 48; v22 += 48; @@ -915,11 +534,7 @@ } v2 = v17; v6 += 48; - --v16; } - while ( v16 ); - result = v20; - if ( v20 < 3 ) - return 0; - return result; + + return out_num_vertices >= 3 ? out_num_vertices : 0; }
--- a/mm7_2.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/mm7_2.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -69,225 +69,153 @@ #include "Lights.h" //----- (004BB756) -------------------------------------------------------- -signed int __fastcall sub_4BB756(signed int a1) +int UseNPCSkill(NPCProf profession) { - unsigned int v1; // esi@8 - unsigned int v3; // ecx@10 - Player *v4; // esi@15 - int v5; // ebx@16 - int v6; // ST38_4@16 - Player *v7; // esi@18 - int v8; // ebx@19 - int v9; // ST30_4@19 - int v10; // ST44_4@19 - int v11; // ST48_4@19 - int v12; // ST4C_4@19 - int v13; // ST50_4@19 - int v14; // ST3C_4@19 - int v15; // ST40_4@19 - int v16; // ST34_4@19 - int v17; // ST38_4@19 - Player *v18; // esi@21 - int v19; // eax@26 - int v20; // eax@39 - SoundID v21; // [sp-20h] [bp-54h]@25 - signed int v22; // [sp-1Ch] [bp-50h]@25 - unsigned int v23; // [sp-18h] [bp-4Ch]@25 - signed int v24; // [sp-14h] [bp-48h]@25 - signed int v25; // [sp-10h] [bp-44h]@25 - int v26; // [sp-10h] [bp-44h]@32 - int v27; // [sp-Ch] [bp-40h]@25 - unsigned int v28; // [sp-Ch] [bp-40h]@32 - unsigned int v29; // [sp-8h] [bp-3Ch]@25 - __int16 v30; // [sp-8h] [bp-3Ch]@32 - int v31; // [sp-4h] [bp-38h]@25 - int v32; // [sp-4h] [bp-38h]@32 - - if ( a1 > 39 ) - { - if ( a1 != 40 ) + switch (profession) + { + case Healer: + { + for (int i = 0; i < 4; ++i) + pParty->pPlayers[i].sHealth = pParty->pPlayers[i].GetMaxHealth(); + } + break; + + case ExpertHealer: + { + for (int i = 0; i < 4; ++i) + { + auto player = &pParty->pPlayers[i]; + player->sHealth = player->GetMaxHealth(); + + for (int j = 0; j < 14; ++j) + player->pConditions[i] = 0; + player->pConditions[18] = 0; + } + } + break; + + case MasterHealer: { - if ( a1 == 41 ) + for (int i = 0; i < 4; ++i) { - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - dword_50C9DC = 195; - ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID); - return 0; + auto player = &pParty->pPlayers[i]; + player->sHealth = player->GetMaxHealth(); + + auto v5 = LODWORD(player->pConditions[19]);//*((int *)v4 - 32); + auto v6 = HIDWORD(player->pConditions[19]);//*((int *)v4 - 31); + memset(player->pConditions, 0, 0xA0u); + + __debugbreak(); + *(int *)&player->pActiveSkills[8] = v5; + *(int *)&player->pActiveSkills[10] = v6; } - if ( a1 == 42 ) + } + break; + + case Cook: + { + if (pParty->uNumFoodRations >= 13) + return 1; + + Party::GiveFood(1); + } + break; + + case Chef: + { + if (pParty->uNumFoodRations >= 13) + return 1; + + if (pParty->uNumFoodRations == 13) + Party::GiveFood(1); + else + Party::GiveFood(2); + } + break; + + case WindMaster: + { + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) { - v32 = 0; - v30 = 0; - v28 = 133; - v26 = 46; + ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2); + pAudioPlayer->PlaySound(SOUND_203, 0, 0, -1, 0, 0, 0, 0); } else { - if ( a1 == 43 ) - { - v32 = 0; - v30 = 0; - v28 = 133; - v26 = 51; - } - else - { - if ( a1 != 52 ) - return 0; - v32 = 0; - v30 = 0; - v28 = 133; - v26 = 86; - } + auto v19 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); + pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + 60 * (256 * 2), 3, 1, v19, 0); + pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags |= 1u; + pAudioPlayer->PlaySound(SOUND_11090, 0, 0, -1, 0, 0, 0, 0); } - _42777D_CastSpell_UseWand_ShootArrow(v26, 0, v28, v30, v32); - return 0; } - v20 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); - pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + 46080, 3u, 0, v20, 0); - pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags |= 1u; - v31 = 0; - v29 = 0; - v27 = 0; - v25 = 0; - v24 = -1; - v23 = 0; - v22 = 0; - v21 = (SoundID)12040; -LABEL_40: - pAudioPlayer->PlaySound(v21, v22, v23, v24, v25, v27, v29, v31); - return 0; - } - if ( a1 == 39 ) - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + break; + + case WaterMaster: { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[494], 2u); - v31 = 0; - v29 = 0; - v27 = 0; - v25 = 0; - v24 = -1; - v23 = 0; - v22 = 0; - v21 = (SoundID)203; + auto v20 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + 60 * (256 * (2 + 1)), 3, 0, v20, 0); + pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags |= 1u; + pAudioPlayer->PlaySound(SOUND_12040, 0, 0, -1, 0, 0, 0, 0); } - else + break; + + case GateMaster: { - v19 = pOtherOverlayList->_4418B1(10008, 203, 0, 65536); - pParty->pPartyBuffs[PARTY_BUFF_FLY].Apply(pParty->uTimePlayed + 30720, 3u, 1u, v19, 0); - pParty->pPartyBuffs[PARTY_BUFF_FLY].uFlags |= 1u; - v31 = 0; - v29 = 0; - v27 = 0; - v25 = 0; - v24 = -1; - v23 = 0; - v22 = 0; - v21 = (SoundID)11090; - } - pAudioPlayer->PlaySound(v21, v22, v23, v24, v25, v27, v29, v31); - return 0; - } - if ( a1 == 10 ) - { - v18 = pParty->pPlayers; - do - { - v18->sHealth = v18->GetMaxHealth(); - ++v18; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + dword_50C9DC = 195; + ptr_50C9E0 = GetNPCData(sDialogue_SpeakingActorNPC_ID); } - while ( (signed int)v18 < (signed int)pParty->pHirelings ); - return 0; - } - if ( a1 == 11 ) - { - v7 = pParty->pPlayers;//(char *)&pParty->pPlayers[0].pConditions[15]; - do - { - /*v8 = *((int *)v7 - 2); - v9 = *((int *)v7 - 1); - v10 = *(int *)v7; - v11 = *((int *)v7 + 1); - v12 = *((int *)v7 + 2); - v13 = *((int *)v7 + 3); - v14 = *((int *)v7 + 8); - v15 = *((int *)v7 + 9); - v16 = *((int *)v7 + 4); - v17 = *((int *)v7 + 5);*/ - v8 = LODWORD(v7->pConditions[14]); - v9 = HIDWORD(v7->pConditions[14]); - v10 = LODWORD(v7->pConditions[15]); - v11 = HIDWORD(v7->pConditions[15]); - v12 = LODWORD(v7->pConditions[16]); - v13 = HIDWORD(v7->pConditions[16]); - v14 = LODWORD(v7->pConditions[19]); - v15 = HIDWORD(v7->pConditions[19]); - v16 = LODWORD(v7->pConditions[17]); - v17 = HIDWORD(v7->pConditions[17]); - memset(v7, 0, 0xA0u); - LODWORD(v7->pConditions[16]) = v12; - HIDWORD(v7->pConditions[16]) = v13; - LODWORD(v7->pConditions[15]) = v10; - HIDWORD(v7->pConditions[15]) = v11; - HIDWORD(v7->pConditions[14]) = v9; - LODWORD(v7->pConditions[19]) = v14; - HIDWORD(v7->pConditions[19]) = v15; - LODWORD(v7->pConditions[17]) = v16; - LODWORD(v7->pConditions[14]) = v8; - HIDWORD(v7->pConditions[17]) = v17; - v7->sHealth = v7->GetMaxHealth(); - ++v7; - } - while ( v7 <= pPlayers[3] ); - return 0; - } - if ( a1 == 12 ) - { - v4 = pParty->pPlayers;//(char *)&pParty->pPlayers[0].pActiveSkills[8]; - do - { - v5 = LODWORD(v4->pConditions[19]);//*((int *)v4 - 32); - v6 = HIDWORD(v4->pConditions[19]);//*((int *)v4 - 31); - memset(v4->pConditions, 0, 0xA0u); - v4->pActiveSkills[8] = v5; - v4->pActiveSkills[10] = v6; - v4->sHealth = v4->GetMaxHealth(); - ++v4; - } - while ( v4 <= pPlayers[3] ); - return 0; - } - if ( a1 == 33 ) - { - v1 = 14; - if ( pParty->uNumFoodRations >= 0xE ) - return 1; - v3 = 1; -LABEL_13: - Party::GiveFood(v3); - if ( pParty->uNumFoodRations > v1 ) - pParty->uNumFoodRations = v1; - return 0; - } - if ( a1 == 34 ) - { - v1 = 14; - if ( pParty->uNumFoodRations >= 0xE ) - return 1; - v3 = 2; - goto LABEL_13; + break; + + case Acolyte: _42777D_CastSpell_UseWand_ShootArrow(46, 0, 133, 0, 0); break; + case Piper: _42777D_CastSpell_UseWand_ShootArrow(51, 0, 133, 0, 0); break; + case FallenWizard: _42777D_CastSpell_UseWand_ShootArrow(86, 0, 133, 0, 0); break; + + case Teacher: + case Instructor: + case Armsmaster: + case Weaponsmaster: + case Apprentice: + case Mystic: + case Spellmaster: + case Trader: + case Merchant: + case Scout: + case Herbalist: + case Apothecary: + case Tinker: + case Locksmith: + case Fool: + case ChimneySweep: + case Porter: + case QuarterMaster: + case Factor: + case Banker: + case Horseman: + case Bard: + case Enchanter: + case Cartographer: + case Explorer: + case Pirate: + case Squire: + case Psychic: + case Gypsy: + case Diplomat: + case Duper: + case Burglar: + case Acolyte2: + case Initiate: + case Prelate: + case Monk: + case Sage: + case Hunter: + break; + + default: + assert(false && "Invalid enum value"); } return 0; } -// 50C9DC: using guessed type int dword_50C9DC; //----- (004BBA85) -------------------------------------------------------- const char *sub_4BBA85_bounties() @@ -457,9 +385,6 @@ pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 1); } } -// F8B1B4: using guessed type int dword_F8B1B4; - -// 4EE088: using guessed type __int16 word_4EE088_sound_ids[]; //----- (004BC109) -------------------------------------------------------- void __cdecl ArenaFight() @@ -556,27 +481,28 @@ if ( uDialogueType == 85 ) { num_monsters = v4; - goto LABEL_22; - } - if ( uDialogueType == 86 ) + v4 /= 2; + } + else if ( uDialogueType == 86 ) { v5 = (signed __int64)((double)v26 * 1.5); - goto LABEL_20; - } - if ( uDialogueType == 87 ) + num_monsters = v5; + v4 /= 2; + } + else if ( uDialogueType == 87 ) { LODWORD(v5) = 2 * v4; -LABEL_20: num_monsters = v5; -LABEL_22: v4 /= 2; - goto LABEL_24; - } - if ( uDialogueType == 88 ) - num_monsters = 2 * v4; + } else - v4 = v27; -LABEL_24: + { + __debugbreak(); // warning C4700: uninitialized local variable 'v27' used + if ( uDialogueType == 88 ) + num_monsters = 2 * v4; + else + v4 = v27; + } if ( v4 < 1 ) v4 = 1; if ( v4 > 100 ) @@ -629,20 +555,20 @@ v16 = rand(); v17 = 3; v22 = 50; - goto LABEL_53; - } - if ( uDialogueType == 86 ) + v18 = v16 % v17; + v13 = v22; + v14 = v18 + 6; + } + else if ( uDialogueType == 86 ) { v16 = rand(); v17 = 7; v22 = 100; -LABEL_53: v18 = v16 % v17; v13 = v22; v14 = v18 + 6; - goto LABEL_55; - } - if ( uDialogueType == 87 ) + } + else if ( uDialogueType == 87 ) { v15 = rand() % 11; v13 = 200; @@ -661,7 +587,6 @@ v13 = gold_transaction_amount; } } -LABEL_55: i = 0; for ( gold_transaction_amount = v26 * v13; i < v14; ++i ) { @@ -705,7 +630,6 @@ if ( v0 == -1 ) { _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1)); -//LABEL_33: pVideoPlayer->_4BF5B2(); return 1; } @@ -715,29 +639,28 @@ { UI_CreateEndConversationButton(); dialog_menu_id = HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT; - sub_4B3AD4(in_current_building_type); + InitializaDialogueOptions_Shops(in_current_building_type); } else { if ( v0 != 102 && v0 != 103 && v0 != 104 ) { pVideoPlayer->_4BF5B2(); -//LABEL_28: dialog_menu_id = HOUSE_DIALOGUE_MAIN; - sub_4B3B42(in_current_building_type); + InitializaDialogueOptions(in_current_building_type); return 1; } pVideoPlayer->_4BF5B2(); UI_CreateEndConversationButton(); dialog_menu_id = HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN; - sub_4B3A72(in_current_building_type); + InitializaDialogueOptions_Tavern(in_current_building_type); } return 1; } pVideoPlayer->_4BF5B2(); UI_CreateEndConversationButton(); dialog_menu_id = HOUSE_DIALOGUE_MAIN; - sub_4B3B42(in_current_building_type); + InitializaDialogueOptions(in_current_building_type); return 1; } pDialogueNPCCount = 0; @@ -944,796 +867,28 @@ /*if ( (signed int)result < 40 ) { pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_Quit; - goto LABEL_42; }*/ pMessageQueue_50CBD0->AddMessage(UIMSG_Quit, 1, 0); - goto LABEL_43; } else { pMessageQueue_50CBD0->AddMessage(UIMSG_ShowFinalWindow, 1, 0); - goto LABEL_43; /*if ( (signed int)result < 40 ) { pMessageQueue_50CBD0->pMessages[result].eType = UIMSG_C5; -LABEL_42: pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; ++pMessageQueue_50CBD0->uNumMessages; - goto LABEL_43; }*/ } -LABEL_43: bGameoverLoop = 0; return result; } -//----- (004D6FB0) -------------------------------------------------------- -int /*__usercall*/ sr_sub_4D6FB0/*<eax>*/(stru315 *a1/*<ebp>*/) -{ - int v1; // ebp@1 - unsigned int v2; // esi@1 - unsigned int v3; // edi@1 - int result; // eax@1 - int v5; // ebx@2 - int v6; // edx@2 - int v7; // ebx@3 - __int16 v8; // cx@3 - int v9; // ebx@4 - unsigned __int8 v10; // sf@5 - unsigned __int8 v11; // of@5 - - v1 = a1->field_8; - v2 = *(int *)(v1 + 48); - v3 = *(int *)(v1 + 44); - result = *(int *)(v1 + 64); - if ( !(*(int *)(v1 + 40) & 1) ) - goto LABEL_5; - --*(int *)(v1 + 40); - result -= 2; - v5 = *(int *)(v1 + 60); - v6 = *(int *)(v1 + 36); - *(int *)(v1 + 60) += 4; - while ( 1 ) - { - *(int *)v5 = v6; - v9 = *(char *)(*(int *)(v1 + 56) - + (*(int *)(v1 + 12) & (v2 >> 16)) - + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))); - result += 4; - v2 += *(int *)(v1 + 4); - v3 += *(int *)v1; - *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52) + 2 * v9); -LABEL_5: - v11 = __OFSUB__(*(int *)(v1 + 40), 2); - v10 = *(int *)(v1 + 40) - 2 < 0; - *(int *)(v1 + 40) -= 2; - if ( v10 ^ v11 ) - break; - v7 = *(char *)(*(int *)(v1 + 56) - + (*(int *)(v1 + 12) & (v2 >> 16)) - + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))); - v2 += *(int *)(v1 + 4); - v8 = *(short *)(*(int *)(v1 + 52) + 2 * v7); - v3 += *(int *)v1; - v5 = *(int *)(v1 + 60); - v6 = *(int *)(v1 + 36); - *(short *)result = v8; - *(int *)(v1 + 60) += 8; - *(int *)(v5 + 4) = v6; - } - *(int *)(v1 + 64) = result; - *(int *)(v1 + 48) = v2; - *(int *)(v1 + 44) = v3; - return result; -} - -//----- (004D705A) -------------------------------------------------------- -int /*__usercall*/ sr_sub_4D705A/*<eax>*/(stru315 *a1/*<ebp>*/) -{ - int v1; // ebp@1 - unsigned int v2; // esi@1 - unsigned int v3; // edi@1 - int result; // eax@1 - int v5; // ebx@2 - int v6; // edx@2 - unsigned int v7; // ebx@3 - unsigned int v8; // edx@3 - __int16 v9; // cx@11 - unsigned int v10; // ebx@12 - unsigned int v11; // edx@12 - unsigned __int8 v12; // sf@21 - unsigned __int8 v13; // of@21 - - v1 = a1->field_8; - v2 = *(int *)(v1 + 48); - v3 = *(int *)(v1 + 44); - result = *(int *)(v1 + 64); - if ( !(*(int *)(v1 + 40) & 1) ) - goto LABEL_21; - --*(int *)(v1 + 40); - result -= 2; - v5 = *(int *)(v1 + 60); - v6 = *(int *)(v1 + 36); - *(int *)(v1 + 60) += 4; - while ( 1 ) - { - *(int *)v5 = v6; - v10 = v3; - v11 = v2; - if ( (signed int)v2 < *(int *)(v1 + 20) ) - v11 = *(int *)(v1 + 20); - if ( (signed int)v3 < *(int *)(v1 + 28) ) - v10 = *(int *)(v1 + 28); - if ( (signed int)v11 > *(int *)(v1 + 24) ) - v11 = *(int *)(v1 + 24); - if ( (signed int)v10 > *(int *)(v1 + 32) ) - v10 = *(int *)(v1 + 32); - result += 4; - v2 += *(int *)(v1 + 4); - v3 += *(int *)v1; - *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52) - + 2 - * *(char *)(*(int *)(v1 + 56) - + (*(int *)(v1 + 12) & (v11 >> 16)) - + ((*(int *)(v1 + 8) & v10) >> *(char *)(v1 + 16)))); -LABEL_21: - v13 = __OFSUB__(*(int *)(v1 + 40), 2); - v12 = *(int *)(v1 + 40) - 2 < 0; - *(int *)(v1 + 40) -= 2; - if ( v12 ^ v13 ) - break; - v7 = v3; - v8 = v2; - if ( (signed int)v2 < *(int *)(v1 + 20) ) - v8 = *(int *)(v1 + 20); - if ( (signed int)v3 < *(int *)(v1 + 28) ) - v7 = *(int *)(v1 + 28); - if ( (signed int)v8 > *(int *)(v1 + 24) ) - v8 = *(int *)(v1 + 24); - if ( (signed int)v7 > *(int *)(v1 + 32) ) - v7 = *(int *)(v1 + 32); - v2 += *(int *)(v1 + 4); - v9 = *(short *)(*(int *)(v1 + 52) - + 2 - * *(char *)(*(int *)(v1 + 56) - + (*(int *)(v1 + 12) & (v8 >> 16)) - + ((*(int *)(v1 + 8) & v7) >> *(char *)(v1 + 16)))); - v3 += *(int *)v1; - v5 = *(int *)(v1 + 60); - v6 = *(int *)(v1 + 36); - *(short *)result = v9; - *(int *)(v1 + 60) += 8; - *(int *)(v5 + 4) = v6; - } - *(int *)(v1 + 64) = result; - *(int *)(v1 + 48) = v2; - *(int *)(v1 + 44) = v3; - return result; -} - -//----- (004D714C) -------------------------------------------------------- -int __cdecl sr_sub_4D714C(stru315 *a1) -{ - stru315 *v1; // ebp@0 - stru315 *v2; // ebp@1 - unsigned int v3; // esi@1 - int v4; // edi@1 - int result; // eax@1 - unsigned int *v6; // ebx@2 - int v7; // edx@2 - int v8; // ebx@3 - unsigned __int16 v9; // cx@3 - unsigned int *v10; // ebx@3 - int v11; // edx@3 - int v12; // ebx@4 - unsigned __int8 v13; // sf@5 - unsigned __int8 v14; // of@5 - - v2 = (stru315 *)v1->field_8; - v3 = v2->field_30; - v4 = v2->field_2C; - result = (int)v2->pColorBuffer; - if ( !(v2->field_28 & 1) ) - goto LABEL_5; - --v2->field_28; - result += 2; - v6 = v2->pDepthBuffer; - v7 = v2->field_24; - --v2->pDepthBuffer; - *v6 = v7; - while ( 1 ) - { - v12 = *((char *)v2->pTextureLOD - + (v2->field_C & (v3 >> 16)) - + ((v2->field_8 & (unsigned int)v4) >> LOBYTE(v2->field_10))); - result -= 4; - v3 += v2->field_4; - v4 += v2->field_0; - *(short *)(result + 2) = v2->field_34_palette[v12]; -LABEL_5: - v14 = __OFSUB__(v2->field_28, 2); - v13 = v2->field_28 - 2 < 0; - v2->field_28 -= 2; - if ( v13 ^ v14 ) - break; - v8 = *((char *)v2->pTextureLOD - + (v2->field_C & (v3 >> 16)) - + ((v2->field_8 & (unsigned int)v4) >> LOBYTE(v2->field_10))); - v3 += v2->field_4; - v9 = v2->field_34_palette[v8]; - v4 += v2->field_0; - v10 = v2->pDepthBuffer; - v11 = v2->field_24; - *(short *)result = v9; - v2->pDepthBuffer -= 2; - *v10 = v11; - *(v10 - 1) = v11; - } - v2->pColorBuffer = (unsigned __int16 *)result; - v2->field_30 = v3; - v2->field_2C = v4; - return result; -} -// 4D714C: inconsistent function type and number of purged bytes - -//----- (004D71F8) -------------------------------------------------------- -int __cdecl sr_sub_4D71F8(stru315 *a1) -{ - stru315 *v1; // ebp@0 - stru315 *v2; // ebp@1 - int v3; // esi@1 - int v4; // edi@1 - int result; // eax@1 - unsigned int *v6; // ebx@2 - int v7; // edx@2 - int v8; // ebx@3 - unsigned int v9; // edx@3 - unsigned __int16 v10; // cx@11 - unsigned int *v11; // ebx@11 - int v12; // edx@11 - int v13; // ebx@12 - unsigned int v14; // edx@12 - unsigned __int8 v15; // sf@21 - unsigned __int8 v16; // of@21 - - v2 = (stru315 *)v1->field_8; - v3 = v2->field_30; - v4 = v2->field_2C; - result = (int)v2->pColorBuffer; - if ( !(v2->field_28 & 1) ) - goto LABEL_21; - --v2->field_28; - result += 2; - v6 = v2->pDepthBuffer; - v7 = v2->field_24; - --v2->pDepthBuffer; - *v6 = v7; - while ( 1 ) - { - v13 = v4; - v14 = v3; - if ( v3 < v2->field_14 ) - v14 = v2->field_14; - if ( v4 < v2->field_1C ) - v13 = v2->field_1C; - if ( (signed int)v14 > v2->field_18 ) - v14 = v2->field_18; - if ( v13 > v2->field_20 ) - v13 = v2->field_20; - result -= 4; - v3 += v2->field_4; - v4 += v2->field_0; - *(short *)(result + 2) = v2->field_34_palette[*((char *)v2->pTextureLOD - + (v2->field_C & (v14 >> 16)) - + ((v2->field_8 & (unsigned int)v13) >> LOBYTE(v2->field_10)))]; -LABEL_21: - v16 = __OFSUB__(v2->field_28, 2); - v15 = v2->field_28 - 2 < 0; - v2->field_28 -= 2; - if ( v15 ^ v16 ) - break; - v8 = v4; - v9 = v3; - if ( v3 < v2->field_14 ) - v9 = v2->field_14; - if ( v4 < v2->field_1C ) - v8 = v2->field_1C; - if ( (signed int)v9 > v2->field_18 ) - v9 = v2->field_18; - if ( v8 > v2->field_20 ) - v8 = v2->field_20; - v3 += v2->field_4; - v10 = v2->field_34_palette[*((char *)v2->pTextureLOD - + (v2->field_C & (v9 >> 16)) - + ((v2->field_8 & (unsigned int)v8) >> LOBYTE(v2->field_10)))]; - v4 += v2->field_0; - v11 = v2->pDepthBuffer; - v12 = v2->field_24; - *(short *)result = v10; - v2->pDepthBuffer -= 2; - *v11 = v12; - *(v11 - 1) = v12; - } - v2->pColorBuffer = (unsigned __int16 *)result; - v2->field_30 = v3; - v2->field_2C = v4; - return result; -} -// 4D71F8: inconsistent function type and number of purged bytes - -//----- (004D72EC) -------------------------------------------------------- -int /*__usercall*/ sr_sub_4D72EC/*<eax>*/(int a1/*<ebp>*/) -{ - int v1; // ebp@1 - unsigned int v2; // esi@1 - unsigned int v3; // edi@1 - int result; // eax@1 - int v5; // ebx@2 - int v6; // edx@2 - unsigned int v7; // edx@3 - unsigned int v8; // ebx@3 - int v9; // ebx@11 - unsigned int v10; // edx@14 - unsigned int v11; // ebx@14 - int v12; // ebx@22 - unsigned __int8 v13; // sf@25 - unsigned __int8 v14; // of@25 - - v1 = *(int *)(a1 + 8); - v2 = *(int *)(v1 + 48); - v3 = *(int *)(v1 + 44); - result = *(int *)(v1 + 64); - if ( !(*(int *)(v1 + 40) & 1) ) - goto LABEL_25; - --*(int *)(v1 + 40); - result -= 2; - v5 = *(int *)(v1 + 60); - v6 = *(int *)(v1 + 36); - *(int *)(v1 + 60) += 4; - while ( 1 ) - { - *(int *)v5 = v6; - v10 = v2; - v11 = v3; - if ( (signed int)v2 < *(int *)(v1 + 20) ) - v10 = *(int *)(v1 + 20); - if ( (signed int)v3 < *(int *)(v1 + 28) ) - v11 = *(int *)(v1 + 28); - if ( (signed int)v10 > *(int *)(v1 + 24) ) - v10 = *(int *)(v1 + 24); - if ( (signed int)v11 > *(int *)(v1 + 32) ) - v11 = *(int *)(v1 + 32); - v12 = *(char *)(*(int *)(v1 + 56) - + (*(int *)(v1 + 12) & (v10 >> 16)) - + ((*(int *)(v1 + 8) & v11) >> *(char *)(v1 + 16))); - result += 4; - v2 += *(int *)(v1 + 4); - if ( v12 ) - *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52) + 2 * v12); - v3 += *(int *)v1; -LABEL_25: - v14 = __OFSUB__(*(int *)(v1 + 40), 2); - v13 = *(int *)(v1 + 40) - 2 < 0; - *(int *)(v1 + 40) -= 2; - if ( v13 ^ v14 ) - break; - v7 = v2; - v8 = v3; - if ( (signed int)v2 < *(int *)(v1 + 20) ) - v7 = *(int *)(v1 + 20); - if ( (signed int)v3 < *(int *)(v1 + 28) ) - v8 = *(int *)(v1 + 28); - if ( (signed int)v7 > *(int *)(v1 + 24) ) - v7 = *(int *)(v1 + 24); - if ( (signed int)v8 > *(int *)(v1 + 32) ) - v8 = *(int *)(v1 + 32); - v9 = *(char *)(*(int *)(v1 + 56) - + (*(int *)(v1 + 12) & (v7 >> 16)) - + ((*(int *)(v1 + 8) & v8) >> *(char *)(v1 + 16))); - v2 += *(int *)(v1 + 4); - if ( v9 ) - *(short *)result = *(short *)(*(int *)(v1 + 52) + 2 * v9); - v3 += *(int *)v1; - v5 = *(int *)(v1 + 60); - v6 = *(int *)(v1 + 36); - *(int *)(v1 + 60) += 8; - *(int *)(v5 + 4) = v6; - } - return result; -} - -//----- (004D73DF) -------------------------------------------------------- -int /*__usercall*/ sr_sub_4D73DF/*<eax>*/(int a1/*<ebp>*/) -{ - int v1; // ebp@1 - unsigned int v2; // esi@1 - unsigned int v3; // edi@1 - int result; // eax@1 - int v5; // ebx@2 - int v6; // edx@2 - int v7; // edx@3 - int v8; // edx@6 - unsigned __int8 v9; // sf@9 - unsigned __int8 v10; // of@9 - - v1 = *(int *)(a1 + 8); - v2 = *(int *)(v1 + 48); - v3 = *(int *)(v1 + 44); - result = *(int *)(v1 + 64); - if ( !(*(int *)(v1 + 40) & 1) ) - goto LABEL_9; - --*(int *)(v1 + 40); - result -= 2; - v5 = *(int *)(v1 + 60); - v6 = *(int *)(v1 + 36); - *(int *)(v1 + 60) += 4; - while ( 1 ) - { - *(int *)v5 = v6; - v8 = *(int *)(v1 + 12) & (v2 >> 16); - result += 4; - v2 += *(int *)(v1 + 4); - if ( *(char *)(*(int *)(v1 + 56) + v8 + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))) ) - *(short *)(result - 2) = *(short *)(*(int *)(v1 + 52) - + 2 - * *(char *)(*(int *)(v1 + 56) - + v8 - + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16)))); - v3 += *(int *)v1; -LABEL_9: - v10 = __OFSUB__(*(int *)(v1 + 40), 2); - v9 = *(int *)(v1 + 40) - 2 < 0; - *(int *)(v1 + 40) -= 2; - if ( v9 ^ v10 ) - break; - v7 = *(int *)(v1 + 12) & (v2 >> 16); - v2 += *(int *)(v1 + 4); - if ( *(char *)(*(int *)(v1 + 56) + v7 + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16))) ) - *(short *)result = *(short *)(*(int *)(v1 + 52) - + 2 - * *(char *)(*(int *)(v1 + 56) - + v7 - + ((*(int *)(v1 + 8) & v3) >> *(char *)(v1 + 16)))); - v3 += *(int *)v1; - v5 = *(int *)(v1 + 60); - v6 = *(int *)(v1 + 36); - *(int *)(v1 + 60) += 8; - *(int *)(v5 + 4) = v6; - } - return result; -} - -//----- (004D754B) -------------------------------------------------------- -void __cdecl sr_sub_4D754B(stru315 *a1, stru316 *a2) -{ - int v2; // ecx@1 - unsigned int v3; // eax@2 - int v4; // ecx@2 - int v5; // eax@10 - unsigned __int16 *v6; // edx@10 - int v7; // ebx@11 - int v8; // ecx@13 - unsigned __int16 v9; // bx@16 - int v10; // ecx@16 - unsigned __int16 *v11; // eax@16 - unsigned int *v12; // edx@16 - int v13; // ecx@16 - int v14; // eax@16 - int v15; // ebx@16 - int v16; // [sp-4h] [bp-Ch]@2 - - v2 = a1->field_28; - if ( v2 ) - { - do - { - v16 = v2; - v3 = a1->field_30; - v4 = a1->field_2C; - if ( (signed int)v3 >= a1->field_18 ) - v3 = a1->field_18; - if ( (signed int)v3 <= a1->field_14 ) - v3 = a1->field_14; - if ( v4 >= a1->field_20 ) - v4 = a1->field_20; - if ( v4 <= a1->field_1C ) - v4 = a1->field_1C; - v5 = *((char *)a1->pTextureLOD + (a1->field_C & (v3 >> 16)) + (((unsigned int)v4 & a1->field_8) >> a1->field_10)); - v6 = a1->field_34_palette; - if ( a2->field_20 ) - { - v7 = (unsigned int)a2->field_10 >> 16; - if ( v7 >= a2->field_C ) - v7 = a2->field_C; - v8 = 0; - if ( a2->field_8 - v7 >= 0 ) - v8 = a2->field_8 - v7; - v5 += v8 << 8; - v6 = a2->field_24_palette; - } - v9 = v6[v5]; - v10 = a1->field_24; - v11 = a1->pColorBuffer; - v12 = a1->pDepthBuffer; - *v11 = v9; - *v12 = v10; - a1->pColorBuffer = v11 + 1; - a1->pDepthBuffer = v12 + 1; - v13 = a1->field_30; - a2->field_10 += a2->field_18; - v14 = a1->field_2C; - v15 = a1->field_0; - a1->field_30 = a1->field_4 + v13; - a1->field_2C = v15 + v14; - v2 = v16 - 1; - } - while ( v16 != 1 ); - } -} - -//----- (004D7630) -------------------------------------------------------- -void __cdecl sr_sub_4D7630(stru315 *a1, stru316 *a2) -{ - int v2; // ecx@1 - int v3; // eax@2 - unsigned __int16 *v4; // edx@2 - int v5; // ebx@3 - int v6; // ecx@5 - unsigned __int16 v7; // bx@8 - int v8; // ecx@8 - unsigned __int16 *v9; // eax@8 - unsigned int *v10; // edx@8 - int v11; // ecx@8 - int v12; // eax@8 - int v13; // ebx@8 - int v14; // [sp-4h] [bp-Ch]@2 - - v2 = a1->field_28; - if ( v2 ) - { - do - { - v14 = v2; - v3 = *((char *)a1->pTextureLOD - + (a1->field_C & ((unsigned int)a1->field_30 >> 16)) - + ((unsigned int)(a1->field_2C & a1->field_8) >> a1->field_10)); - v4 = a1->field_34_palette; - if ( a2->field_20 ) - { - v5 = (unsigned int)a2->field_14 >> 16; - if ( v5 >= a2->field_C ) - v5 = a2->field_C; - v6 = 0; - if ( a2->field_8 - v5 >= 0 ) - v6 = a2->field_8 - v5; - v3 += v6 << 8; - v4 = a2->field_24_palette; - } - v7 = v4[v3]; - v8 = a1->field_24; - v9 = a1->pColorBuffer; - v10 = a1->pDepthBuffer; - *v9 = v7; - *v10 = v8; - a1->pColorBuffer = v9 - 1; - a1->pDepthBuffer = v10 - 1; - v11 = a1->field_30; - a2->field_14 -= a2->field_18; - v12 = a1->field_2C; - v13 = a1->field_0; - a1->field_30 = a1->field_4 + v11; - a1->field_2C = v13 + v12; - v2 = v14 - 1; - } - while ( v14 != 1 ); - } -} - -//----- (004D76ED) -------------------------------------------------------- -void __cdecl sr_sub_4D76ED(stru315 *a1, stru316 *a2) -{ - int v2; // ecx@1 - unsigned int v3; // eax@2 - int v4; // ecx@2 - int v5; // eax@10 - unsigned __int16 *v6; // edx@10 - int v7; // ebx@11 - int v8; // ecx@13 - unsigned __int16 v9; // bx@16 - int v10; // ecx@16 - unsigned __int16 *v11; // eax@16 - unsigned int *v12; // edx@16 - int v13; // ecx@16 - int v14; // eax@16 - int v15; // ebx@16 - int v16; // [sp-4h] [bp-Ch]@2 - - v2 = a1->field_28; - if ( v2 ) - { - do - { - v16 = v2; - v3 = a1->field_30; - v4 = a1->field_2C; - if ( (signed int)v3 >= a1->field_18 ) - v3 = a1->field_18; - if ( (signed int)v3 <= a1->field_14 ) - v3 = a1->field_14; - if ( v4 >= a1->field_20 ) - v4 = a1->field_20; - if ( v4 <= a1->field_1C ) - v4 = a1->field_1C; - v5 = *((char *)a1->pTextureLOD + (a1->field_C & (v3 >> 16)) + (((unsigned int)v4 & a1->field_8) >> a1->field_10)); - v6 = a1->field_34_palette; - if ( a2->field_20 ) - { - v7 = (unsigned int)a2->field_14 >> 16; - if ( v7 >= a2->field_C ) - v7 = a2->field_C; - v8 = 0; - if ( a2->field_8 - v7 >= 0 ) - v8 = a2->field_8 - v7; - v5 += v8 << 8; - v6 = a2->field_24_palette; - } - v9 = v6[v5]; - v10 = a1->field_24; - v11 = a1->pColorBuffer; - v12 = a1->pDepthBuffer; - *v11 = v9; - *v12 = v10; - a1->pColorBuffer = v11 - 1; - a1->pDepthBuffer = v12 - 1; - v13 = a1->field_30; - a2->field_14 -= a2->field_18; - v14 = a1->field_2C; - v15 = a1->field_0; - a1->field_30 = a1->field_4 + v13; - a1->field_2C = v15 + v14; - v2 = v16 - 1; - } - while ( v16 != 1 ); - } -} - -//----- (004D77D2) -------------------------------------------------------- -void __cdecl sr_sub_4D77D2(stru315 *a1, stru316 *a2) -{ - int v2; // ecx@1 - unsigned __int16 *v3; // ebx@2 - int v4; // eax@2 - unsigned __int16 *v5; // edx@2 - int v6; // ebx@4 - int v7; // ecx@6 - unsigned __int16 v8; // bx@9 - int v9; // ecx@9 - unsigned int *v10; // edx@9 - unsigned int *v11; // edx@10 - int v12; // ecx@10 - int v13; // eax@10 - int v14; // ebx@10 - int v15; // [sp-4h] [bp-Ch]@2 - - v2 = a1->field_28; - if ( v2 ) - { - do - { - v15 = v2; - v3 = a1->pTextureLOD; - v4 = *((char *)v3 - + (a1->field_C & ((unsigned int)a1->field_30 >> 16)) - + ((unsigned int)(a1->field_2C & a1->field_8) >> a1->field_10)); - v5 = a1->field_34_palette; - if ( *((char *)v3 - + (a1->field_C & ((unsigned int)a1->field_30 >> 16)) - + ((unsigned int)(a1->field_2C & a1->field_8) >> a1->field_10)) ) - { - if ( a2->field_20 ) - { - v6 = (unsigned int)a2->field_10 >> 16; - if ( v6 >= a2->field_C ) - v6 = a2->field_C; - v7 = 0; - if ( a2->field_8 - v6 >= 0 ) - v7 = a2->field_8 - v6; - v4 += v7 << 8; - v5 = a2->field_24_palette; - } - v8 = v5[v4]; - v9 = a1->field_24; - v10 = a1->pDepthBuffer; - *a1->pColorBuffer = v8; - *v10 = v9; - } - v11 = a1->pDepthBuffer + 1; - ++a1->pColorBuffer; - a1->pDepthBuffer = v11; - v12 = a1->field_30; - a2->field_10 += a2->field_18; - v13 = a1->field_2C; - v14 = a1->field_0; - a1->field_30 = a1->field_4 + v12; - a1->field_2C = v14 + v13; - v2 = v15 - 1; - } - while ( v15 != 1 ); - } -} - -//----- (004D789A) -------------------------------------------------------- -void __cdecl sr_sub_4D789A(stru315 *a1, stru316 *a2) -{ - int v2; // ecx@1 - unsigned int v3; // eax@2 - int v4; // ecx@2 - int v5; // eax@10 - unsigned __int16 *v6; // edx@10 - int v7; // ebx@12 - int v8; // ecx@14 - unsigned __int16 v9; // bx@17 - int v10; // ecx@17 - unsigned int *v11; // edx@17 - unsigned int *v12; // edx@18 - int v13; // ecx@18 - int v14; // eax@18 - int v15; // ebx@18 - int v16; // [sp-4h] [bp-Ch]@2 - - v2 = a1->field_28; - if ( v2 ) - { - do - { - v16 = v2; - v3 = a1->field_30; - v4 = a1->field_2C; - if ( (signed int)v3 >= a1->field_18 ) - v3 = a1->field_18; - if ( (signed int)v3 <= a1->field_14 ) - v3 = a1->field_14; - if ( v4 >= a1->field_20 ) - v4 = a1->field_20; - if ( v4 <= a1->field_1C ) - v4 = a1->field_1C; - v5 = *((char *)a1->pTextureLOD + (a1->field_C & (v3 >> 16)) + (((unsigned int)v4 & a1->field_8) >> a1->field_10)); - v6 = a1->field_34_palette; - if ( v5 ) - { - if ( a2->field_20 ) - { - v7 = (unsigned int)a2->field_10 >> 16; - if ( v7 >= a2->field_C ) - v7 = a2->field_C; - v8 = 0; - if ( a2->field_8 - v7 >= 0 ) - v8 = a2->field_8 - v7; - v5 += v8 << 8; - v6 = a2->field_24_palette; - } - v9 = v6[v5]; - v10 = a1->field_24; - v11 = a1->pDepthBuffer; - *a1->pColorBuffer = v9; - *v11 = v10; - } - v12 = a1->pDepthBuffer + 1; - ++a1->pColorBuffer; - a1->pDepthBuffer = v12; - v13 = a1->field_30; - a2->field_10 += a2->field_18; - v14 = a1->field_2C; - v15 = a1->field_0; - a1->field_30 = a1->field_4 + v13; - a1->field_2C = v15 + v14; - v2 = v16 - 1; - } - while ( v16 != 1 ); - } -} + + + //----- (00451007) -------------------------------------------------------- int stru350::sub_451007_scale_image_bicubic(unsigned short *pSrc, int srcWidth, int srcHeight, int srcPitch, //changing this to some library function might be a good idea @@ -1941,19 +1096,25 @@ pTexture = pMapInfo->pEncounterMonster1Texture; v12 = v10 % (v11 - v9 + 1); v13 = pMapInfo->Dif_M1; - goto LABEL_20; + v57 = v13; + v56 = v9 + v12; + strcpy(Source, pTexture); + break; case 3u: pTexture = pMapInfo->pEncounterMonster1Texture; v44 = "%s A"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 4u: pTexture = pMapInfo->pEncounterMonster2Texture; v44 = "%s A"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 5u: pTexture = pMapInfo->pEncounterMonster3Texture; v44 = "%s A"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 1u: v9 = pMapInfo->uEncounterMonster2AtLeast; v14 = rand(); @@ -1961,19 +1122,25 @@ pTexture = pMapInfo->pEncounterMonster2Texture; v12 = v14 % (v15 - v9 + 1); v13 = pMapInfo->Dif_M2; - goto LABEL_20; + v57 = v13; + v56 = v9 + v12; + strcpy(Source, pTexture); + break; case 6u: pTexture = pMapInfo->pEncounterMonster1Texture; v44 = "%s B"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 7u: pTexture = pMapInfo->pEncounterMonster2Texture; v44 = "%s B"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 8u: pTexture = pMapInfo->pEncounterMonster3Texture; v44 = "%s B"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 2u: v9 = pMapInfo->uEncounterMonster3AtLeast; v16 = rand(); @@ -1981,50 +1148,49 @@ pTexture = pMapInfo->pEncounterMonster3Texture; v12 = v16 % (v17 - v9 + 1); v13 = pMapInfo->Dif_M3; -LABEL_20: v57 = v13; v56 = v9 + v12; strcpy(Source, pTexture); - goto LABEL_26; + break; case 9u: pTexture = pMapInfo->pEncounterMonster1Texture; v44 = "%s C"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 0xAu: pTexture = pMapInfo->pEncounterMonster2Texture; v44 = "%s C"; - goto LABEL_25; + sprintf(Source, v44, pTexture); + break; case 0xBu: pTexture = pMapInfo->pEncounterMonster3Texture; v44 = "%s C"; -LABEL_25: sprintf(Source, v44, pTexture); -LABEL_26: - if (Source[0] == '0') - return; - v57 += a3; - if ( v57 > 4 ) - v57 = 4; - strcpy(Str2, Source); - if ( a4 ) - v56 = a4; - v18 = v56; - if ( (signed int)(v56 + uNumActors) >= 500 ) - return; - pSector = 0; - pPosX = spawn->vPosition.x; - a4 = spawn->vPosition.y; - a3 = spawn->vPosition.z; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z); - v53 = 0; - v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; - if ( v18 <= 0 ) - return; break; default: return; } + if (Source[0] == '0') + return; + v57 += a3; + if ( v57 > 4 ) + v57 = 4; + strcpy(Str2, Source); + if ( a4 ) + v56 = a4; + v18 = v56; + if ( (signed int)(v56 + uNumActors) >= 500 ) + return; + pSector = 0; + pPosX = spawn->vPosition.x; + a4 = spawn->vPosition.y; + a3 = spawn->vPosition.z; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + pSector = pIndoor->GetSector(spawn->vPosition.x, spawn->vPosition.y, spawn->vPosition.z); + v53 = 0; + v52 = (((uCurrentlyLoadedLevelType != LEVEL_Outdoor) - 1) & 0x40) + 64; + if ( v18 <= 0 ) + return; for (uint i = v53; i < v56; ++i) { pMonster = &pActors[uNumActors]; @@ -2058,7 +1224,7 @@ else { if ( v24 != 3 ) - goto LABEL_58; + continue; pTexture = Source; v44 = "%s C"; } @@ -2111,7 +1277,12 @@ v36 = spawn->vPosition.z; a3 = spawn->vPosition.z; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - goto LABEL_55; + { + if ( a5 ) + pMonster->uAttributes |= 0x080000; + ++uNumActors; + continue; + } v37 = pIndoor->GetSector(pPosX, a4, v36); if ( v37 == pSector ) { @@ -2122,15 +1293,13 @@ if ( abs(v38 - a3) <= 1024 ) { a3 = v39; -LABEL_55: if ( a5 ) pMonster->uAttributes |= 0x080000; ++uNumActors; - goto LABEL_58; + continue; } } } -LABEL_58: ; //v53 = (char *)v53 + 1; //result = v53; @@ -2273,7 +1442,7 @@ int v14; // edx@10 signed int v15; // ebx@20 unsigned __int16 v16; // dx@20 - char *v17; // ecx@21 + ObjectDesc *v17; // ecx@21 unsigned __int16 v18; // ax@24 int v19; // ST0C_4@27 int v20; // ST08_4@27 @@ -2281,7 +1450,7 @@ int v22; // eax@27 signed int v23; // ebx@29 unsigned __int16 v24; // dx@29 - char *v25; // ecx@30 + ObjectDesc *v25; // ecx@30 unsigned __int16 v26; // ax@33 //int v27; // ecx@35 //int v28; // eax@35 @@ -2323,97 +1492,75 @@ if ( a2->uIndex == 1 ) { v14 = rand() % 51 + 50; - } - else + a1a.stru_24.uItemID = 197; + v34 = v14; + } + else if ( a2->uIndex == 2 ) { - if ( a2->uIndex != 2 ) - { - if ( a2->uIndex == 3 ) + v14 = rand() % 101 + 100; + a1a.stru_24.uItemID = 197; + v34 = v14; + } + else if ( a2->uIndex == 3 ) { v14 = rand() % 301 + 200; + a1a.stru_24.uItemID = 198; + v34 = v14; } - else + else if ( a2->uIndex == 4 ) + { + v14 = rand() % 501 + 500; + a1a.stru_24.uItemID = 198; + v34 = v14; + } + else if ( a2->uIndex == 5 ) { - if ( a2->uIndex != 4 ) - { - if ( a2->uIndex == 5 ) - { - v14 = rand() % 1001 + 1000; - } - else + v14 = rand() % 1001 + 1000; + a1a.stru_24.uItemID = 199; + v34 = v14; + } + else if ( a2->uIndex == 6 ) + { + v14 = rand() % 3001 + 2000; + a1a.stru_24.uItemID = 199; + v34 = v14; + } + v15 = 0; + v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + v18 = 0; + for( int i = 0; i < pObjectList->uNumObjects; i++ ) { - if ( a2->uIndex != 6 ) - { -LABEL_20: - v15 = 0; - v16 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_24: - v18 = 0; - } - else - { - v17 = (char *)&pObjectList->pObjects->uObjectID; - while ( v16 != *(short *)v17 ) - { - ++v15; - v17 += 56; - if ( v15 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_24; - } - v18 = v15; - } - a1a.stru_24.SetIdentified(); - a1a.uObjectDescID = v18; - a1a.stru_24.uSpecEnchantmentType = v34; - goto LABEL_35; - } - v14 = rand() % 3001 + 2000; + if ( pObjectList->pObjects[i].uObjectID == v16 ) + { + v18 = i; + break; + } } - a1a.stru_24.uItemID = 199; -LABEL_19: - v34 = v14; - goto LABEL_20; - } - v14 = rand() % 501 + 500; - } - a1a.stru_24.uItemID = 198; - goto LABEL_19; - } - v14 = rand() % 101 + 100; - } - a1a.stru_24.uItemID = 197; - goto LABEL_19; - } - result = a1a.stru_24.GenerateArtifact(); - if ( !result ) - return result; - v23 = 0; - v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_33: - v26 = 0; + a1a.stru_24.SetIdentified(); + a1a.uObjectDescID = v18; + a1a.stru_24.uSpecEnchantmentType = v34; } else { - v25 = (char *)&pObjectList->pObjects->uObjectID; - while ( v24 != *(short *)v25 ) - { - ++v23; - v25 += 56; - if ( v23 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_33; - } - v26 = v23; - } - a1a.uObjectDescID = v26; - a1a.stru_24.Reset(); - -LABEL_35: + result = a1a.stru_24.GenerateArtifact(); + if ( !result ) + return result; + v23 = 0; + v24 = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + a1a.uType = pItemsTable->pItems[a1a.stru_24.uItemID].uSpriteID; + v26 = 0; + for( int i = 0; i < pObjectList->uNumObjects; i++ ) + { + if( v24 == pObjectList->pObjects[i].uObjectID ) + { + v26 = i; + break; + } + } + a1a.uObjectDescID = v26; + a1a.stru_24.Reset(); + } a1a.vPosition.y = a2->vPosition.y; a1a.uAttributes = 0; a1a.uSoundID = 0; @@ -2447,23 +1594,15 @@ v8 = 0; v9 = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; a1.uType = pItemsTable->pItems[a1.stru_24.uItemID].uSpriteID; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_5: - v11 = 0; - } - else - { - v10 = (char *)&pObjectList->pObjects->uObjectID; - while ( v9 != *(short *)v10 ) - { - ++v8; - v10 += 56; - if ( v8 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_5; - } - v11 = v8; - } + v11 = 0; + for( int i = 0; i < pObjectList->uNumObjects; i++ ) + { + if( v9 == pObjectList->pObjects[i].uObjectID ) + { + v11 = i; + break; + } + } a1.uObjectDescID = v11; a1.vPosition.y = a4; a1.vPosition.x = a3; @@ -2476,11 +1615,11 @@ } //----- (0045063B) -------------------------------------------------------- -int __fastcall sub_45063B(MapInfo *a1, int a2) +int __fastcall _45063B_spawn_some_monster(MapInfo *a1, int a2) { signed int v2; // edi@1 Actor *v3; // esi@2 - signed __int64 v4; // qax@3 + //signed __int64 v4; // qax@3 int result; // eax@8 int v6; // edi@11 int v7; // ebx@11 @@ -2497,33 +1636,49 @@ int v18; // eax@21 SpawnPointMM7 v19; // [sp+Ch] [bp-38h]@1 int v20; // [sp+24h] [bp-20h]@11 - MapInfo *v21; // [sp+28h] [bp-1Ch]@1 + //MapInfo *v21; // [sp+28h] [bp-1Ch]@1 int v22; // [sp+2Ch] [bp-18h]@3 int v23; // [sp+30h] [bp-14h]@11 - int v24; // [sp+34h] [bp-10h]@1 + //int v24; // [sp+34h] [bp-10h]@1 unsigned int uFaceID; // [sp+38h] [bp-Ch]@10 int v26; // [sp+3Ch] [bp-8h]@11 int v27; // [sp+40h] [bp-4h]@11 - - v21 = a1; - v24 = a2; + + if (!uNumActors) + return 0; + + //v21 = a1; + //v24 = a2; v2 = 0; - if ( (signed int)uNumActors <= 0 ) - goto LABEL_8; v3 = pActors.data(); while ( 1 ) { - v22 = v3->pMonsterInfo.uID - 1; - v4 = (signed __int64)((double)v22 * 0.3333333333333333); - if ( (int)v4 != 40 ) + if (v3->pMonsterInfo.uID >= 121 && v3->pMonsterInfo.uID <= 123 || // Dwarf FemaleC A-C + v3->pMonsterInfo.uID >= 124 && v3->pMonsterInfo.uID <= 126 || // Dwarf MaleA A-C + v3->pMonsterInfo.uID >= 133 && v3->pMonsterInfo.uID <= 135 || // Peasant Elf FemaleA A-C + !v3->CanAct()) { - if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) - break; + ++v2; + ++v3; + + if (v2 >= uNumActors) + return 0; + + continue; } - ++v2; - ++v3; - if ( v2 >= (signed int)uNumActors ) - goto LABEL_8; + + break; + //v22 = v3->pMonsterInfo.uID - 1; + //v4 = (signed __int64)((double)v22 * 0.3333333333333333); + //if ( (int)v4 != 40 ) + //{ + // if ( (int)v4 != 41 && (int)v4 != 44 && v3->CanAct() ) + // break; + //} + //++v2; + //++v3; + //if ( v2 >= (signed int)uNumActors ) + // goto LABEL_8; } if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) { @@ -2540,7 +1695,7 @@ v20 = stru_5C6E00->Sin(v7); v23 = (unsigned __int64)(v20 * (signed __int64)v6) >> 16; v8 = 0; - v19.uIndex = v24; + v19.uIndex = a2; v19.vPosition.y = v23 + pParty->vPosition.y; v19.vPosition.z = pParty->vPosition.z; v26 = 0; @@ -2554,22 +1709,16 @@ &v27, 0); v23 = 0; - if ( (signed int)pOutdoor->uNumBModels > 0 ) - { - while ( 1 ) - { - v9 = abs(v19.vPosition.y - pOutdoor->pBModels[v8].vBoundingCenter.y); - v10 = abs(v19.vPosition.x - pOutdoor->pBModels[v8].vBoundingCenter.x); - if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[v8].sBoundingRadius + 256 ) - break; - ++v23; - ++v8; - if ( v23 >= (signed int)pOutdoor->uNumBModels ) - goto LABEL_16; - } - v22 = 1; - } -LABEL_16: + for( int i = 0; i < pOutdoor->uNumBModels; i++ ) + { + v9 = abs(v19.vPosition.y - pOutdoor->pBModels[i].vBoundingCenter.y); + v10 = abs(v19.vPosition.x - pOutdoor->pBModels[i].vBoundingCenter.x); + if ( int_get_vector_length(v10, v9, 0) < pOutdoor->pBModels[i].sBoundingRadius + 256 ) + { + v22 = 1; + break; + } + } v11 = uFaceID == 100; if ( uFaceID >= 100 ) break; @@ -2599,7 +1748,7 @@ v23 = (unsigned __int64)(v16 * (signed __int64)v12) >> 16; v19.vPosition.y = v23 + pParty->vPosition.y; v19.vPosition.z = pParty->vPosition.z; - v19.uIndex = v24; + v19.uIndex = a2; v17 = pIndoor->GetSector(v19.vPosition.x, v23 + pParty->vPosition.y, pParty->vPosition.z); if ( v17 == v22 ) { @@ -2617,13 +1766,12 @@ } if ( v11 ) { -LABEL_8: result = 0; } else { - SpawnEncounter(v21, &v19, 0, 0, 1); - result = v24; + SpawnEncounter(a1, &v19, 0, 0, 1); + result = a2; } return result; } @@ -2645,108 +1793,90 @@ int v12; // eax@21 int v13; // eax@22 - v1 = this; - rand(); - v2 = v1->uDecorationDescID; - if ( v2 > 208 ) - { - switch ( v2 ) - { - case 209: - result = rand() % 7 + 183; - break; - case 210: - result = 150; - break; - case 211: - result = 151; - break; - case 212: - result = 152; - break; - case 213: - result = 153; - break; - case 214: - result = 154; - break; - case 215: - result = 155; - break; - case 216: - result = 156; - break; - case 217: - result = 157; - break; - case 218: - result = 158; - break; - case 219: - result = 159; - break; - case 220: - result = 160; - break; - case 221: - result = 161; - break; - default: - goto LABEL_45; - } - } - else - { - if ( v2 == 208 ) - { - result = rand() % 7 + 176; - } - else - { - if ( v2 > 24 ) - { - v9 = v2 - 34; - if ( !v9 ) - return rand() % 6 + 4; - v10 = v9 - 150; - if ( !v10 ) - return 33; - v11 = v10 - 3; - if ( !v11 || (v12 = v11 - 3) == 0 ) - return 37; - v13 = v12 - 16; - if ( !v13 ) - return rand() % 7 + 162; - if ( v13 == 1 ) - return rand() % 7 + 169; - } - else - { - if ( v2 == 24 ) - return 36; - v3 = v2 - 4; - if ( !v3 ) - return 16; - v4 = v3 - 1; - if ( !v4 ) - return 32; - v5 = v4 - 1; - if ( !v5 ) - return rand() % 4 + 12; - v6 = v5 - 5; - if ( !v6 ) - return 34; - v7 = v6 - 2; - if ( !v7 ) - return 17; - if ( v7 == 1 ) - return 18; - } -LABEL_45: - result = 0; - } - } - return result; + switch (uDecorationDescID) + { + case 0: case 1: + case 2: case 3: + return 0; + + case 4: return 16; // dec01 "Trash Pile" + case 5: return 32; // dec02 "Campfire" + case 6: return 12 + rand() % 4; // dec03 "Cauldron" + case 7: case 8: + case 9: case 10: + return 0; + + case 11: return 34; // dec08 "Fruit plate" + case 12: + return 0; + + case 13: return 17; // dec10 "Trash Pile" + case 14: return 18; // dec11 "Filth" + case 15: case 16: case 17: + case 18: case 19: case 20: + case 21: case 22: case 23: + return 0; + + case 24: return 36; // dec21 "Keg" + case 25: case 26: case 27: case 28: case 29: + case 30: case 31: case 32: case 33: + return 0; + + case 34: return 4 + rand() % 6; // dec32 "Barrel" + case 35: case 36: case 37: case 38: case 39: + case 40: case 41: case 42: case 43: case 44: case 45: case 46: case 47: case 48: case 49: + case 50: case 51: case 52: case 53: case 54: case 55: case 56: case 57: case 58: case 59: + case 60: case 61: case 62: case 63: case 64: case 65: case 66: case 67: case 68: case 69: + case 70: case 71: case 72: case 73: case 74: case 75: case 76: case 77: case 78: case 79: + case 80: case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88: case 89: + case 90: case 91: case 92: case 93: case 94: case 95: case 96: case 97: case 98: case 99: + case 100: case 101: case 102: case 103: case 104: case 105: case 106: case 107: case 108: case 109: + case 110: case 111: case 112: case 113: case 114: case 115: case 116: case 117: case 118: case 119: + case 120: case 121: case 122: case 123: case 124: case 125: case 126: case 127: case 128: case 129: + case 130: case 131: case 132: case 133: case 134: case 135: case 136: case 137: case 138: case 139: + case 140: case 141: case 142: case 143: case 144: case 145: case 146: case 147: case 148: case 149: + case 150: case 151: case 152: case 153: case 154: case 155: case 156: case 157: case 158: case 159: + case 160: case 161: case 162: case 163: case 164: case 165: case 166: case 167: case 168: case 169: + case 170: case 171: case 172: case 173: case 174: case 175: case 176: case 177: case 178: case 179: + case 180: case 181: case 182: case 183: + + case 184: return 33; // dec24 "Campfire" + case 185: case 186: + return 0; + + case 187: // dec88 "Mushroom" + case 190: // dec91 "Mushroom" + return 37; + + case 188: case 189: + case 191: case 192: case 193: case 194: case 195: case 196: + case 197: case 198: case 199: case 200: case 201: case 202: + case 203: case 204: case 205: + return 0; + + case 206: return 162 + rand() % 7; // dec60 + case 207: return 169 + rand() % 7; // dec61 + case 208: return 176 + rand() % 7; // dec62 + case 209: return 183 + rand() % 7; // dec63 + case 210: return 150; // dec64 "Magic Pedistal" + case 211: return 151; // dec65 "Magic Pedistal" + case 212: return 152; // dec66 "Magic Pedistal" + case 213: return 153; // dec67 "Magic Pedistal" + case 214: return 154; // dec68 "Magic Pedistal" + case 215: return 155; // dec69 "Magic Pedistal" + case 216: return 156; // dec70 "Magic Pedistal" + case 217: return 157; // dec71 "Magic Pedistal" + case 218: return 158; // dec72 "Magic Pedistal" + case 219: return 159; // dec73 "Magic Pedistal" + case 220: return 160; // dec74 "Magic Pedistal" + case 221: return 161; // dec75 "Magic Pedistal" + + case 222: case 223: case 224: + case 225: case 226: case 227: + return 0; + + default: assert(false && "Invalid Decoration"); + } } //----- (00450AAA) -------------------------------------------------------- @@ -3101,6 +2231,7 @@ LOWORD(v7) = v5 & 0xE0; v12 = v7 + v11; LOWORD(v7) = v8 & 0xE0; + __debugbreak(); // warning C4700: uninitialized local variable 'v10' used return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00) + (v5 & 0x1C00) + v9 @@ -3755,9 +2886,9 @@ case 0x80: return 3; // Master case 0x40: return 2; // Expert case 0x00: return 1; // Normal - default: - assert(false); - } + } + assert(false); + return 0; } //----- (0045828B) -------------------------------------------------------- @@ -3784,34 +2915,43 @@ if ( a1 < 78 ) { if ( a1 < 89 ) - goto LABEL_31; - goto LABEL_28; + { + v4 = 0; + v1 = 0; + v2 = 0; + return TargetColor(v2, v1, v4); + } } + else + { LABEL_25: - if ( a1 < 89 ) - { - v4 = 155; - v2 = 255; - goto LABEL_30; - } -LABEL_28: + if ( a1 < 89 ) + { + v4 = 155; + v2 = 255; + v1 = v2; + return TargetColor(v2, v1, v4); + } + } if ( a1 < 100 ) { v4 = 240; v2 = 192; - goto LABEL_30; + v1 = v2; + return TargetColor(v2, v1, v4); } -LABEL_31: v4 = 0; v1 = 0; - goto LABEL_32; + v2 = 0; + return TargetColor(v2, v1, v4); } LABEL_21: if ( a1 < 78 ) { v4 = 0; v1 = 128; - goto LABEL_23; + v2 = 255; + return TargetColor(v2, v1, v4); } goto LABEL_25; } @@ -3829,7 +2969,9 @@ if ( a1 < 56 ) { v2 = 225; - goto LABEL_13; + v4 = v2; + v1 = v2; + return TargetColor(v2, v1, v4); } goto LABEL_18; } @@ -3837,9 +2979,7 @@ if ( a1 < 45 ) { v2 = 128; -LABEL_13: v4 = v2; -LABEL_30: v1 = v2; return TargetColor(v2, v1, v4); } @@ -3850,7 +2990,6 @@ { v4 = 255; v1 = 128; -LABEL_32: v2 = 0; return TargetColor(v2, v1, v4); } @@ -3863,7 +3002,6 @@ { v4 = 0; v1 = 85; -LABEL_23: v2 = 255; return TargetColor(v2, v1, v4); } @@ -3954,9 +3092,9 @@ { if ( v4 != 1 ) { - if ( v4 != 0 || pActor->sNPC_ID ) - continue; - goto LABEL_12; + if ( v4 == 0 && pActor->sNPC_ID == 0 ) + pActor->sNPC_ID = 0; + continue; } } if ( pActor->sNPC_ID > 0 && pActor->sNPC_ID < 5000 ) @@ -3969,9 +3107,7 @@ pActor->sNPC_ID = v14; continue; } -LABEL_12: pActor->sNPC_ID = 0; -//LABEL_13: //++v15; //v2 += 836; //} @@ -4104,33 +3240,29 @@ // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; //----- (004621DA) -------------------------------------------------------- -int __fastcall int_get_vector_length(signed int a1, signed int a2, signed int a3) +int int_get_vector_length(signed int x, signed int y, signed int z) { signed int v3; // eax@2 - signed int v4; // eax@3 - signed int v5; // esi@4 - signed int v6; // esi@6 - - if ( a1 < a2 ) - { - v3 = a1; - a1 = a2; - a2 = v3; - } - v4 = a3; - if ( a1 < a3 ) - { - v5 = a1; - a1 = a3; - v4 = v5; - } - if ( a2 < v4 ) - { - v6 = a2; - a2 = v4; - v4 = v6; - } - return (11 * a2 >> 5) + a1 + (v4 >> 2); + + if ( x < y ) + { + v3 = x; + x = y; + y = v3; + } + if ( x < z ) + { + v3 = x; + x = z; + z = v3; + } + if ( y < z ) + { + v3 = y; + y = z; + z = v3; + } + return (11 * y >> 5) + x + (z >> 2); } OPENFILENAMEA ofn; @@ -4237,7 +3369,7 @@ { if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) { - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); pGUIWindow_CurrentMenu->Release(); pGUIWindow_CurrentMenu = 0; pCurrentScreen = SCREEN_GAME; @@ -4296,7 +3428,7 @@ pGUIWindow2 = 0; } pWindow_MainMenu->Release(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); } //----- (004637EB) -------------------------------------------------------- @@ -4873,14 +4005,12 @@ else { if ( !pRenderer->pRenderD3D && !pRenderer->UsingDirect3D() || !AreRenderSurfacesOk() ) - //goto LABEL_20; { EndPaint(hWnd, &Paint); return 0; } } pRenderer->Present(); -//LABEL_20: EndPaint(hWnd, &Paint); return 0; } @@ -5165,25 +4295,27 @@ || RegCreateKeyExA(hKey, "New World Computing", 0, "", 0, 0xF003Fu, 0, &phkResult, &dwDisposition) || RegCreateKeyExA(phkResult, "Might and Magic VII", 0, "", 0, 0xF003Fu, 0, &v13, &dwDisposition) || RegCreateKeyExA(v13, "1.0", 0, "", 0, 0xF003Fu, 0, &v14, &dwDisposition) ) - goto LABEL_7; - if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) ) + { + result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); + } + else if ( RegQueryValueExA(v14, lpValueName, 0, &Type, Dest, &cbData) ) { RegCloseKey(v14); v14 = 0; -LABEL_7: result = (LSTATUS)strncpy((char *)Dest, pDefaultValue, uBufLen); - goto LABEL_8; - } - v4 = RegCloseKey; - RegCloseKey(v14); - v14 = 0; - RegCloseKey(v13); - v13 = 0; - RegCloseKey(phkResult); - phkResult = 0; - result = RegCloseKey(hKey); - hKey = 0; -LABEL_8: + } + else + { + v4 = RegCloseKey; + RegCloseKey(v14); + v14 = 0; + RegCloseKey(v13); + v13 = 0; + RegCloseKey(phkResult); + phkResult = 0; + result = RegCloseKey(hKey); + hKey = 0; + } if ( v14 ) result = v4(v14); if ( v13 ) @@ -5344,7 +4476,6 @@ if ( a3 == 2 ) { v12 = 0; -LABEL_9: EndDialog(hDlg, v12); return 1; } @@ -5357,7 +4488,8 @@ if ( v4 ) { v12 = 1; - goto LABEL_9; + EndDialog(hDlg, v12); + return 1; } return 0; } @@ -6131,7 +5263,7 @@ assert(sizeof(IndoorCamera) == 0x50); assert(sizeof(Bloodsplat) == 0x28); assert(sizeof(BloodsplatContainer) == 0xA0C); - assert(sizeof(stru167) == 0x18); + assert(sizeof(TrailParticle) == 0x18); assert(sizeof(EventIndex) == 0xC); assert(sizeof(_2devent) == 0x34); assert(sizeof(stru176) == 0x20); @@ -6247,20 +5379,10 @@ pGame->Deinitialize(); return 1; } - - Log::Warning(L"MM init: ok"); pEventTimer->Pause(); - if ( pRenderer->bUserDirect3D && pRenderer->uAcquiredDirect3DDevice == 1 ) - { - SetWindowPos(hWnd, (HWND)((int)HWND_MESSAGE|0x2), 320, 240, 640, 480, 0); - Rect.left = 325; - Rect.top = 245; - Rect.right = 326; - Rect.bottom = 246; - ClipCursor(&Rect); - } + SetUserInterface(PartyAlignment_Neutral, false); ShowIntroVideo_and_LoadingScreen(); WriteWindowsRegistryInt("Ran once", 1); @@ -6275,7 +5397,6 @@ { MainMenu_Loop(); uGameState = GAME_STATE_PLAYING; -//LABEL_21: while ( 1 ) { if (uGameState == GAME_FINISHED || @@ -6302,7 +5423,8 @@ } DeleteCCharFont(); bFlashQuestBook = true; - pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); + PlayFullscreenMovie(MOVIE_Emerald); + //pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); SaveNewGame(); if (bNoMargareth) @@ -6330,30 +5452,29 @@ if (GetCurrentMenuID() == MENU_5 || GetCurrentMenuID() == MENU_LoadingProcInMainMenu) { uGameState = GAME_STATE_PLAYING; + pGame->Loop(); } else { - if (GetCurrentMenuID() != MENU_10) - goto LABEL_49; - pMouse->Activate(0); - - pParty->Reset(); - pParty->CreateDefaultParty(1); - crt_init_globals_46271C(); - extern OPENFILENAMEA ofn; - if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) - { - pMouse->Activate(1); - - break; - } - _chdir("..\\"); - strcpy(pCurrentMapName.data(), ofn.lpstrFileTitle); - pMouse->Activate(1); + if (GetCurrentMenuID() == MENU_10) + { + pMouse->Activate(0); + + pParty->Reset(); + pParty->CreateDefaultParty(1); + crt_init_globals_46271C(); + extern OPENFILENAMEA ofn; + if ( !GetOpenFileNameA((LPOPENFILENAMEA)&ofn) ) + { + pMouse->Activate(1); + break; + } + _chdir("..\\"); + strcpy(pCurrentMapName.data(), ofn.lpstrFileTitle); + pMouse->Activate(1); + pGame->Loop(); + } } -//LABEL_48: - pGame->Loop(); -LABEL_49: if ( uGameState == GAME_STATE_LOADING_GAME ) { SetCurrentMenuID(MENU_5); @@ -6548,7 +5669,7 @@ outdoor_grid_band_2 = 15; outdoor_grid_band_3 = 20; pOutdoorCamera->shading_dist_mist = 8192; - pOutdoorCamera->bNoSky = 0; + pOutdoorCamera->bNoSky = false; LOBYTE(viewparams->field_20) = 0; } mipmapping_terrain_mm1 = 1024; @@ -6562,7 +5683,11 @@ mipmapping_building_mm3 = 4096; pOutdoorCamera->shading_dist_shademist = 4096; pOutdoorCamera->outdoor_no_wavy_water = 0; - sub_47F4D3(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); + //_47F4D3_initialize_terrain_bezier_stuff(outdoor_grid_band_1, outdoor_grid_band_2, outdoor_grid_band_3); + { + pOutdoorCamera->outdoor_grid_band_3 = outdoor_grid_band_3; + pOutdoorCamera->uPickDepth = outdoor_grid_band_3 * 512; + } } else { @@ -6937,13 +6062,13 @@ v29 = 640 * v3; while ( 2 ) { - v31 = 100; - v6 = &pRenderer->pActiveZBuffer[v2 + v5 - v4 / 2]; + v6 = &pRenderer->pActiveZBuffer[v2 + v5 - v4 / 2]-1; v7 = v0; - while ( 1 ) - { + //while ( 1 ) + for( int i = 0; i < 100; i++) + { + ++v6; v8 = *v6; - --v31; if ( (unsigned int)*v6 <= 0x2000000 ) { v9 = 0; @@ -6976,17 +6101,13 @@ } } } - if ( !v31 ) - break; - ++v6; - } + } v4 = -1; ++v30; v5 = v29 + 640; v29 += 640; - if ( v30 < v28 ) - continue; - break; + if ( v30 >= v28 ) + break; } v12 = 0; v10 = v0 == 0; @@ -7029,45 +6150,51 @@ if ( !(pSpriteObjects[v20].uAttributes & 0x10) ) { v23 = pSpriteObjects[v20].stru_24.GetDisplayName(); -LABEL_36: v24 = v23; - goto LABEL_51; - } - goto LABEL_41; - } - if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor) - { - if ( v20 >= 0xBB8 ) - return 0; - v24 = (const char *)&pActors[v20]; - goto LABEL_51; - } - if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration) - break; - if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel) - { - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - v21 = &pIndoor->pFaces[v20]; - if ( !(BYTE3(v21->uAttributes) & 2) ) - goto LABEL_41; - v22 = pIndoor->pFaceExtras[v21->uFaceExtraID].uEventID; - } - else - { - if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 >= pOutdoor->uNumBModels ) - goto LABEL_41; - v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID; - } - if ( v22 ) - { - v23 = GetEventHintString(v22); - if ( v23 ) - goto LABEL_36; + GameUI_SetFooterString(v24); + return v19; } } -LABEL_41: - ++v18; + else + { + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor) + { + if ( v20 >= 0xBB8 ) + return 0; + v24 = (const char *)&pActors[v20]; + GameUI_SetFooterString(v24); + return v19; + } + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration) + break; + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel) + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + v21 = &pIndoor->pFaces[v20]; + if ( BYTE3(v21->uAttributes) & 2 ) + v22 = pIndoor->pFaceExtras[v21->uFaceExtraID].uEventID; + } + else + { + if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 < pOutdoor->uNumBModels ) + { + v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID; + if ( v22 ) + { + v23 = GetEventHintString(v22); + if ( v23 ) + { + v24 = v23; + GameUI_SetFooterString(v24); + return v19; + } + } + } + } + } + } + ++v18; if ( v18 >= v0 ) return 0; } @@ -7079,13 +6206,14 @@ v23 = GetEventHintString(v27); if ( !v23 ) return v19; - goto LABEL_36; + v24 = v23; + GameUI_SetFooterString(v24); + return v19; } if ( v25->IsInteractive() ) v24 = pNPCTopics[stru_5E4C90._decor_events[v26->_idx_in_stru123 - 75] + 379].pTopic; else v24 = pDecorationList->pDecorations[v26->uDecorationDescID].field_20; -LABEL_51: GameUI_SetFooterString(v24); return v19; } @@ -7121,11 +6249,11 @@ //----- (0046BFFA) -------------------------------------------------------- bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2) { - SpriteObject *v2; // esi@1 + //SpriteObject *v2; // esi@1 ObjectDesc *v3; // ebx@1 unsigned __int16 v5; // cx@9 - unsigned __int16 v6; // cx@14 - signed int v7; // edx@14 + //unsigned __int16 v6; // cx@14 + //signed int v7; // edx@14 unsigned int v8; // eax@19 unsigned int v9; // edi@19 signed int v10; // ebx@19 @@ -7133,7 +6261,7 @@ unsigned __int16 v12; // ax@23 int v13; // eax@27 unsigned int v14; // ebx@33 - unsigned __int16 v15; // ax@35 + //unsigned __int16 v15; // ax@35 int v16; // eax@36 unsigned int v17; // eax@37 __int16 v18; // di@37 @@ -7191,11 +6319,11 @@ char *v70; // edx@125 unsigned __int16 v71; // ax@128 unsigned int v72; // ebx@131 - int v73; // ST14_4@132 - int v74; // ST10_4@132 - int v75; // ebx@132 - int v76; // ST0C_4@132 - unsigned __int16 v77; // ax@132 + //int v73; // ST14_4@132 + //int v74; // ST10_4@132 + //int v75; // ebx@132 + //int v76; // ST0C_4@132 + //unsigned __int16 v77; // ax@132 int v78; // eax@133 char v79; // zf@139 unsigned int v80; // eax@140 @@ -7219,11 +6347,11 @@ unsigned __int16 v98; // ax@191 unsigned int v99; // ecx@191 char v100; // ST18_1@198 - int v101; // ST14_4@198 + //int v101; // ST14_4@198 int v102; // eax@198 - int v103; // ST10_4@198 - int v104; // ST0C_4@198 - unsigned __int16 v105; // ax@200 + //int v103; // ST10_4@198 + //int v104; // ST0C_4@198 + //unsigned __int16 v105; // ax@200 signed int v106; // eax@208 unsigned int v107; // edx@220 signed int v108; // ebx@225 @@ -7234,7 +6362,7 @@ unsigned __int16 v113; // si@241 int v114; // eax@242 int v115; // eax@245 - signed int v116; // eax@245 + //signed int v116; // eax@245 unsigned __int16 v117; // ax@251 unsigned int v118; // ecx@251 signed int v119; // ebx@251 @@ -7244,14 +6372,14 @@ char *v123; // edx@261 int v124; // eax@267 int v125; // [sp-20h] [bp-4Ch]@28 - signed int v126; // [sp-1Ch] [bp-48h]@27 - unsigned int v127; // [sp-18h] [bp-44h]@27 - signed int v128; // [sp-14h] [bp-40h]@27 - signed int v129; // [sp-10h] [bp-3Ch]@27 - int v130; // [sp-Ch] [bp-38h]@27 - unsigned int v131; // [sp-8h] [bp-34h]@27 + //signed int v126; // [sp-1Ch] [bp-48h]@27 + //unsigned int v127; // [sp-18h] [bp-44h]@27 + //signed int v128; // [sp-14h] [bp-40h]@27 + //signed int v129; // [sp-10h] [bp-3Ch]@27 + //int v130; // [sp-Ch] [bp-38h]@27 + //unsigned int v131; // [sp-8h] [bp-34h]@27 char v132; // [sp-8h] [bp-34h]@131 - int v133; // [sp-4h] [bp-30h]@27 + //int v133; // [sp-4h] [bp-30h]@27 char v134; // [sp-4h] [bp-30h]@131 signed int v135; // [sp-4h] [bp-30h]@217 int v136; // [sp+Ch] [bp-20h]@208 @@ -7267,63 +6395,64 @@ signed int v146; // [sp+20h] [bp-Ch]@60 int v147; // [sp+20h] [bp-Ch]@72 signed int v148; // [sp+20h] [bp-Ch]@158 - int v149; // [sp+20h] [bp-Ch]@198 + //int v149; // [sp+20h] [bp-Ch]@198 unsigned __int16 v150; // [sp+20h] [bp-Ch]@208 int v151; // [sp+24h] [bp-8h]@1 signed int v152; // [sp+24h] [bp-8h]@208 unsigned int v153; // [sp+28h] [bp-4h]@1 v153 = uLayingItemID; - v2 = &pSpriteObjects[uLayingItemID]; - v3 = &pObjectList->pObjects[v2->uObjectDescID]; + //v2 = &pSpriteObjects[uLayingItemID]; + v3 = &pObjectList->pObjects[pSpriteObjects[uLayingItemID].uObjectDescID]; v145 = a2; v151 = PID_TYPE(a2); if ( PID_TYPE(a2) == OBJECT_Actor) { - if ( PID_TYPE(v2->spell_caster_pid) == OBJECT_Actor && !pActors[PID_ID(v2->spell_caster_pid)].GetActorsRelation(&pActors[PID_ID(a2)]) ) + if ( PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) == OBJECT_Actor + && !pActors[PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid)].GetActorsRelation(&pActors[PID_ID(a2)]) ) return 1; } else { - if ( PID_TYPE(a2) == OBJECT_Player && PID_TYPE(v2->spell_caster_pid) == OBJECT_Player) + if ( PID_TYPE(a2) == OBJECT_Player && PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) == OBJECT_Player) return 1; } if ( pParty->bTurnBasedModeOn == 1 ) { - v5 = v2->uAttributes; + v5 = pSpriteObjects[uLayingItemID].uAttributes; if ( v5 & 4 ) { --pTurnEngine->field_1C; - v2->uAttributes = v5 & 0xFFFB; + pSpriteObjects[uLayingItemID].uAttributes = v5 & 0xFFFB; } } - if ( v151 == OBJECT_BModel && PID_TYPE(v2->spell_caster_pid) != OBJECT_Player) + if ( v151 == OBJECT_BModel && PID_TYPE(pSpriteObjects[uLayingItemID].spell_caster_pid) != OBJECT_Player) { - if (PID_ID(v2->spell_caster_pid)<500) //bugfix PID_ID(v2->spell_caster_pid)==1000 - BYTE2(pActors[PID_ID(v2->spell_caster_pid)].uAttributes) |= 4; + if (PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid) < 500) //bugfix PID_ID(v2->spell_caster_pid)==1000 + BYTE2(pActors[PID_ID(pSpriteObjects[uLayingItemID].spell_caster_pid)].uAttributes) |= 4; } - v6 = v2->uType; - v7 = v2->uType; - if ( v7 > 3060 ) - { - if ( v7 > 6090 ) + //v6 = v2->uType; + //v7 = v2->uType; + if ( pSpriteObjects[uLayingItemID].uType > 3060 ) + { + if ( pSpriteObjects[uLayingItemID].uType > 6090 ) { - if ( v7 > 8090 ) + if ( pSpriteObjects[uLayingItemID].uType > 8090 ) { - if ( v7 == 9010 ) + if ( pSpriteObjects[uLayingItemID].uType == 9010 ) goto LABEL_247; - if ( v7 != 9030 ) + if ( pSpriteObjects[uLayingItemID].uType != 9030 ) { - if ( v7 != 9040 ) + if ( pSpriteObjects[uLayingItemID].uType != 9040 ) { - if ( v7 != 9080 ) + if ( pSpriteObjects[uLayingItemID].uType != 9080 ) return 0; LABEL_191: - v98 = v6 + 1; + v98 = pSpriteObjects[uLayingItemID].uType + 1; v99 = pObjectList->uNumObjects; v32 = 0; - v2->uType = v98; + pSpriteObjects[uLayingItemID].uType = v98; v146 = 0; if ( (signed int)v99 > 0 ) { @@ -7333,19 +6462,76 @@ ++v146; v144 += 56; if ( v146 >= (signed int)v99 ) - goto LABEL_195; + { + pSpriteObjects[uLayingItemID].uObjectDescID = 0; + if ( !v32 ) + SpriteObject::OnInteraction(v153); + v100 = pSpriteObjects[uLayingItemID].field_61; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v32; + v102 = 8 * v153; + LOBYTE(v102) = PID(OBJECT_Item,v153); + pSpriteObjects[uLayingItemID].vVelocity.x = v32; + pSpriteObjects[uLayingItemID].vVelocity.y = v32; + pSpriteObjects[uLayingItemID].vVelocity.z = v32; + stru_50FE08.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32); + if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor); + if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 ) + v47 = 0; + else + v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32); + return 0; + } } - goto LABEL_80; + pSpriteObjects[uLayingItemID].uObjectDescID = v146; + if ( v146 == (short)v32 ) + SpriteObject::OnInteraction(v153); + v100 = pSpriteObjects[uLayingItemID].field_61; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v32; + v102 = 8 * v153; + LOBYTE(v102) = PID(OBJECT_Item,v153); + pSpriteObjects[uLayingItemID].vVelocity.x = v32; + pSpriteObjects[uLayingItemID].vVelocity.y = v32; + pSpriteObjects[uLayingItemID].vVelocity.z = v32; + stru_50FE08.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32); + if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor); + if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 ) + v47 = 0; + else + v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32); + return 0; } -LABEL_195: - v46 = 0; - goto LABEL_196; + pSpriteObjects[uLayingItemID].uObjectDescID = 0; + if ( !v32 ) + SpriteObject::OnInteraction(v153); + v100 = pSpriteObjects[uLayingItemID].field_61; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v32; + v102 = 8 * v153; + LOBYTE(v102) = PID(OBJECT_Item,v153); + pSpriteObjects[uLayingItemID].vVelocity.x = v32; + pSpriteObjects[uLayingItemID].vVelocity.y = v32; + pSpriteObjects[uLayingItemID].vVelocity.z = v32; + stru_50FE08.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32); + if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor); + if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 ) + v47 = 0; + else + v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32); + return 0; } goto LABEL_93; } LABEL_172: v143 = 17030; - switch ( v6 ) + switch ( pSpriteObjects[uLayingItemID].uType ) { case 0x1798u: v143 = 15040; @@ -7360,14 +6546,17 @@ v138 = 1; if ( v151 != OBJECT_Actor) { - if ( v6 != 9030 || v2->spell_skill != 4 ) - goto LABEL_246; - v2->_46BEF1_apply_spells_aoe(); + if ( pSpriteObjects[uLayingItemID].uType != 9030 || pSpriteObjects[uLayingItemID].spell_skill != 4 ) + { + SpriteObject::OnInteraction(v153); + return 0; + } + pSpriteObjects[uLayingItemID]._46BEF1_apply_spells_aoe(); LABEL_233: if ( !v138 ) { v109 = pObjectList->uNumObjects; - ++v2->uType; + ++pSpriteObjects[uLayingItemID].uType; v110 = 0; if ( (signed int)v109 <= 0 ) { @@ -7377,7 +6566,7 @@ else { v111 = (char *)&pObjectList->pObjects->uObjectID; - while ( v2->uType != *(short *)v111 ) + while ( pSpriteObjects[uLayingItemID].uType != *(short *)v111 ) { ++v110; v111 += 56; @@ -7386,41 +6575,34 @@ } v112 = v110; } - v2->uObjectDescID = v112; + pSpriteObjects[uLayingItemID].uObjectDescID = v112; if ( !v112 ) SpriteObject::OnInteraction(v153); - v2->vVelocity.z = 0; - v2->vVelocity.y = 0; - v2->vVelocity.x = 0; - v2->uSpriteFrameID = 0; - v113 = v2->uSoundID; + pSpriteObjects[uLayingItemID].vVelocity.z = 0; + pSpriteObjects[uLayingItemID].vVelocity.y = 0; + pSpriteObjects[uLayingItemID].vVelocity.x = 0; + pSpriteObjects[uLayingItemID].uSpriteFrameID = 0; + v113 = pSpriteObjects[uLayingItemID].uSoundID; if ( v113 ) v114 = (signed __int16)v113 + 4; else v114 = 0; - v133 = 0; - v131 = 0; - v130 = v114; v115 = 8 * v153; - v129 = 0; - v128 = -1; LOBYTE(v115) = PID(OBJECT_Item,v153); - v127 = 0; - v126 = v115; - v116 = v143; - goto LABEL_269; + v125 = v143 + 1; + pAudioPlayer->PlaySound((SoundID)v125, v115, 0, -1, 0, v114, 0, 0); + return 0; } -LABEL_246: SpriteObject::OnInteraction(v153); return 0; } v106 = v145; v150 = 0; v139 = PID_ID(v106); - v137 = v2->spell_level; - v152 = v2->spell_skill; - v136 = v2->spell_id; - if ( v6 == 9030 ) + v137 = pSpriteObjects[uLayingItemID].spell_level; + v152 = pSpriteObjects[uLayingItemID].spell_skill; + v136 = pSpriteObjects[uLayingItemID].spell_id; + if ( pSpriteObjects[uLayingItemID].uType == 9030 ) { v150 = 2; if ( v152 == 2 ) @@ -7434,48 +6616,44 @@ } BYTE2(pActors[v139].uAttributes) |= 8u; } - if ( v7 == 6040 ) + if ( pSpriteObjects[uLayingItemID].uType == 6040 ) { v135 = 7; } else { - if ( v7 == 8030 ) + if ( pSpriteObjects[uLayingItemID].uType == 8030 ) { v135 = 9; } else { - if ( v7 != 9030 ) + if ( pSpriteObjects[uLayingItemID].uType != 9030 ) { v107 = v136; LABEL_222: - if ( v6 != 9030 || v152 != 4 ) + if ( pSpriteObjects[uLayingItemID].uType != 9030 || v152 != 4 ) { v108 = v139; if ( stru_50C198.GetMagicalResistance(&pActors[v139], v107) ) { v138 = 0; - if ( v2->uType == 8030 ) + if ( pSpriteObjects[uLayingItemID].uType == 8030 ) { pActors[v108].uAIState = Standing; pActors[v108].UpdateAnimation(); } - pActors[v108].pActorBuffs[v136].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335), - v152, - v150, - 0, - 0); + pActors[v108].pActorBuffs[v136].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v137 << 7) * 0.033333335), + v152, v150, 0, 0); } } else { - v2->_46BEF1_apply_spells_aoe(); + pSpriteObjects[uLayingItemID]._46BEF1_apply_spells_aoe(); } - v2->spell_level = 0; - v2->spell_skill = 0; - v2->spell_id = 0; + pSpriteObjects[uLayingItemID].spell_level = 0; + pSpriteObjects[uLayingItemID].spell_skill = 0; + pSpriteObjects[uLayingItemID].spell_id = 0; goto LABEL_233; } v135 = 10; @@ -7484,42 +6662,60 @@ v107 = v135; goto LABEL_222; } - if ( v7 == 8090 || v7 == 7030 || v7 == 7090 || v7 == 8000 ) + if ( pSpriteObjects[uLayingItemID].uType == 8090 || pSpriteObjects[uLayingItemID].uType == 7030 || pSpriteObjects[uLayingItemID].uType == 7090 || pSpriteObjects[uLayingItemID].uType == 8000 ) goto LABEL_93; - if ( v7 == 8010 ) + if ( pSpriteObjects[uLayingItemID].uType == 8010 ) { if ( v151 == 3 && MonsterStats::BelongsToSupertype(pActors[PID_ID(v145)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) sub_43A97E(v153, v145); v93 = pObjectList->uNumObjects; - ++v2->uType; + ++pSpriteObjects[uLayingItemID].uType; v9 = 0; v52 = 0; if ( (signed int)v93 > 0 ) { v94 = (char *)&pObjectList->pObjects->uObjectID; - while ( v2->uType != *(short *)v94 ) + while ( pSpriteObjects[uLayingItemID].uType != *(short *)v94 ) { ++v52; v94 += 56; if ( v52 >= (signed int)v93 ) goto LABEL_181; } - goto LABEL_202; + v95 = v52; + pSpriteObjects[uLayingItemID].uObjectDescID = v95; + if ( v95 == (short)v9 ) + SpriteObject::OnInteraction(v153); + v96 = pSpriteObjects[uLayingItemID].uSoundID; + pSpriteObjects[uLayingItemID].vVelocity.z = v9; + pSpriteObjects[uLayingItemID].vVelocity.y = v9; + pSpriteObjects[uLayingItemID].vVelocity.x = v9; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v9; + if ( v96 == (short)v9 ) + v97 = 0; + else + v97 = (signed __int16)v96 + 4; + v92 = v153; + v124 = 8 * v92; + LOBYTE(v124) = v124 | 2; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v97, v9, v9); + return 0; } goto LABEL_181; } - v79 = v7 == 8030; + v79 = pSpriteObjects[uLayingItemID].uType == 8030; } else { - if ( v7 == 6090 ) + if ( pSpriteObjects[uLayingItemID].uType == 6090 ) goto LABEL_93; - if ( v7 <= 4070 ) + if ( pSpriteObjects[uLayingItemID].uType <= 4070 ) { - if ( v7 != 4070 ) + if ( pSpriteObjects[uLayingItemID].uType != 4070 ) { - v48 = v7 - 3090; + v48 = pSpriteObjects[uLayingItemID].uType - 3090; if ( v48 ) { v49 = v48 - 2; @@ -7532,13 +6728,13 @@ v44 = v45 == 0; goto LABEL_91; } - v54 = v6 - 1; + v54 = pSpriteObjects[uLayingItemID].uType - 1; v55 = pObjectList->uNumObjects; v9 = 0; v56 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uType = v54; + pSpriteObjects[uLayingItemID].uType = v54; if ( v20 | v44 ) { LABEL_102: @@ -7556,45 +6752,31 @@ } v58 = v56; } - v2->uObjectDescID = v58; + pSpriteObjects[uLayingItemID].uObjectDescID = v58; if ( !v58 ) SpriteObject::OnInteraction(v153); - v14 = v153; - v2->vVelocity.z = 0; - v2->vVelocity.y = 0; - v2->vVelocity.x = 0; - v2->uSpriteFrameID = 0; + pSpriteObjects[uLayingItemID].vVelocity.z = 0; + pSpriteObjects[uLayingItemID].vVelocity.y = 0; + pSpriteObjects[uLayingItemID].vVelocity.x = 0; + pSpriteObjects[uLayingItemID].uSpriteFrameID = 0; sub_43A97E(v153, v145); -LABEL_35: - v15 = v2->uSoundID; - if ( v15 == (short)v9 ) + if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v9 ) v16 = 0; else - v16 = (signed __int16)v15 + 4; - v133 = v9; - v131 = v9; - v130 = v16; - v92 = v14; -LABEL_267: - v124 = 8 * v92; - v129 = v9; - v128 = -1; + v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v124 = 8 * v153; LOBYTE(v124) = v124 | 2; - v127 = v9; - v126 = v124; -LABEL_268: - v116 = word_4EE088_sound_ids[v2->spell_id - 1]; -LABEL_269: - v125 = v116 + 1; - goto LABEL_29; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9); + return 0; } - v59 = v6 + 2; + v59 = pSpriteObjects[uLayingItemID].uType + 2; v60 = pObjectList->uNumObjects; v9 = 0; v61 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uType = v59; + pSpriteObjects[uLayingItemID].uType = v59; if ( v20 | v44 ) { LABEL_111: @@ -7612,14 +6794,14 @@ } v63 = v61; } - v2->uObjectDescID = v63; + pSpriteObjects[uLayingItemID].uObjectDescID = v63; if ( !v63 ) SpriteObject::OnInteraction(v153); - v64 = v2->uFacing - stru_5C6E00->uIntegerDoublePi; - v44 = v2->spell_skill == 4; - v2->vVelocity.z = 0; - v2->vVelocity.y = 0; - v2->vVelocity.x = 0; + v64 = pSpriteObjects[uLayingItemID].uFacing - stru_5C6E00->uIntegerDoublePi; + v44 = pSpriteObjects[uLayingItemID].spell_skill == 4; + pSpriteObjects[uLayingItemID].vVelocity.z = 0; + pSpriteObjects[uLayingItemID].vVelocity.y = 0; + pSpriteObjects[uLayingItemID].vVelocity.x = 0; v65 = 7; if ( v44 ) v65 = 9; @@ -7629,25 +6811,30 @@ do { v64 += (signed int)stru_5C6E00->uIntegerHalfPi >> 1; - v2->Create(v64, 0, 1000, 0); + pSpriteObjects[uLayingItemID].Create(v64, 0, 1000, 0); --v141; } while ( v141 ); } -LABEL_160: - v14 = v153; -LABEL_34: - SpriteObject::OnInteraction(v14); - goto LABEL_35; + SpriteObject::OnInteraction(v153); + if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v9 ) + v16 = 0; + else + v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v124 = 8 * v153; + LOBYTE(v124) = v124 | 2; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9); + return 0; } if ( v151 == 6 || v151 == 5 || (v66 = 0, !v151) ) return 1; - v67 = v6 + 1; + v67 = pSpriteObjects[uLayingItemID].uType + 1; v68 = pObjectList->uNumObjects; v69 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uType = v67; + pSpriteObjects[uLayingItemID].uType = v67; if ( v20 | v44 ) { LABEL_128: @@ -7665,45 +6852,34 @@ } v71 = v69; } - v2->uObjectDescID = v71; + pSpriteObjects[uLayingItemID].uObjectDescID = v71; if ( !v71 ) SpriteObject::OnInteraction(v153); v134 = 0; v72 = v153; v132 = 0; -LABEL_132: - v73 = v2->vPosition.z; - v74 = v2->vPosition.y; - v75 = PID(OBJECT_Item,v72); - v2->vVelocity.z = v66; - v2->vVelocity.y = v66; - v76 = v2->vPosition.x; - v2->vVelocity.x = v66; - v2->uSpriteFrameID = v66; - stru_50FE08.Add(v75, 512, v76, v74, v73, v132, v134); - v77 = v2->uSoundID; - if ( v77 == (short)v66 ) + pSpriteObjects[uLayingItemID].vVelocity.z = v66; + pSpriteObjects[uLayingItemID].vVelocity.y = v66; + pSpriteObjects[uLayingItemID].vVelocity.x = v66; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v66; + stru_50FE08.Add(PID(OBJECT_Item,v72), 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v132, v134); + if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v66 ) v78 = 0; else - v78 = (signed __int16)v77 + 4; - v133 = v66; - v131 = v66; - v130 = v78; - v129 = v66; - v128 = -1; - v127 = v66; - v126 = v75; - goto LABEL_268; + v78 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + pAudioPlayer->PlaySound((SoundID)v125, pSpriteObjects[uLayingItemID].vPosition.x, v66, -1, v66, v78, v66, v66); + return 0; } - if ( v7 == 4090 ) + if ( pSpriteObjects[uLayingItemID].uType == 4090 ) { - v84 = v6 + 2; + v84 = pSpriteObjects[uLayingItemID].uType + 2; v85 = pObjectList->uNumObjects; v9 = 0; v86 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uType = v84; + pSpriteObjects[uLayingItemID].uType = v84; if ( v20 | v44 ) { LABEL_155: @@ -7721,13 +6897,13 @@ } v88 = v86; } - v2->uObjectDescID = v88; + pSpriteObjects[uLayingItemID].uObjectDescID = v88; if ( !v88 ) SpriteObject::OnInteraction(v153); - v89 = v2->uFacing - stru_5C6E00->uIntegerDoublePi; - v2->vVelocity.z = 0; - v2->vVelocity.y = 0; - v2->vVelocity.x = 0; + v89 = pSpriteObjects[uLayingItemID].uFacing - stru_5C6E00->uIntegerDoublePi; + pSpriteObjects[uLayingItemID].vVelocity.z = 0; + pSpriteObjects[uLayingItemID].vVelocity.y = 0; + pSpriteObjects[uLayingItemID].vVelocity.x = 0; v142 = v89; v148 = 7; do @@ -7737,20 +6913,29 @@ pRnd->SetRange(5, 500); v91 = pRnd->GetInRange(); v142 += (signed int)stru_5C6E00->uIntegerHalfPi >> 1; - v2->Create(v90 + v142, 0, v91, 0); + pSpriteObjects[uLayingItemID].Create(v90 + v142, 0, v91, 0); --v148; } while ( v148 ); - goto LABEL_160; + SpriteObject::OnInteraction(v153); + if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v9 ) + v16 = 0; + else + v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v124 = 8 * v153; + LOBYTE(v124) = v124 | 2; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v16, v9, v9); + return 0; } - if ( v7 == 4092 ) + if ( pSpriteObjects[uLayingItemID].uType == 4092 ) { v80 = pObjectList->uNumObjects; v66 = 0; v81 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uType = 4091; + pSpriteObjects[uLayingItemID].uType = 4091; if ( v20 | v44 ) { LABEL_144: @@ -7768,31 +6953,42 @@ } v83 = v81; } - v2->uObjectDescID = v83; + pSpriteObjects[uLayingItemID].uObjectDescID = v83; if ( !v83 ) SpriteObject::OnInteraction(v153); v134 = 0; v72 = v153; - v132 = v2->field_61; - goto LABEL_132; + v132 = pSpriteObjects[uLayingItemID].field_61; + pSpriteObjects[uLayingItemID].vVelocity.z = v66; + pSpriteObjects[uLayingItemID].vVelocity.y = v66; + pSpriteObjects[uLayingItemID].vVelocity.x = v66; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v66; + stru_50FE08.Add(PID(OBJECT_Item,v72), 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v132, v134); + if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v66 ) + v78 = 0; + else + v78 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + pAudioPlayer->PlaySound((SoundID)v125, pSpriteObjects[uLayingItemID].vPosition.x, v66, -1, v66, v78, v66, v66); + return 0; } - if ( v7 == 4100 || v7 == 6010 ) + if ( pSpriteObjects[uLayingItemID].uType == 4100 || pSpriteObjects[uLayingItemID].uType == 6010 ) goto LABEL_93; - v79 = v7 == 6040; + v79 = pSpriteObjects[uLayingItemID].uType == 6040; } if ( !v79 ) return 0; goto LABEL_172; } - if ( v7 == 3060 ) + if ( pSpriteObjects[uLayingItemID].uType == 3060 ) goto LABEL_93; - if ( v7 <= 555 ) - { - if ( v7 == 555 ) + if ( pSpriteObjects[uLayingItemID].uType <= 555 ) + { + if ( pSpriteObjects[uLayingItemID].uType == 555 ) { sub_43A97E(v153, v145); v23 = pObjectList->uNumObjects; - ++v2->uType; + ++pSpriteObjects[uLayingItemID].uType; v18 = 0; v24 = 0; if ( (signed int)v23 <= 0 ) @@ -7803,7 +6999,7 @@ else { v25 = (char *)&pObjectList->pObjects->uObjectID; - while ( v2->uType != *(short *)v25 ) + while ( pSpriteObjects[uLayingItemID].uType != *(short *)v25 ) { ++v24; v25 += 56; @@ -7813,17 +7009,17 @@ v22 = v24; } LABEL_42: - v2->uObjectDescID = v22; + pSpriteObjects[uLayingItemID].uObjectDescID = v22; if ( v22 == v18 ) SpriteObject::OnInteraction(v153); - v2->vVelocity.z = v18; - v2->vVelocity.y = v18; - v2->vVelocity.x = v18; - v2->uSpriteFrameID = v18; + pSpriteObjects[uLayingItemID].vVelocity.z = v18; + pSpriteObjects[uLayingItemID].vVelocity.y = v18; + pSpriteObjects[uLayingItemID].vVelocity.x = v18; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v18; } else { - switch ( v7 ) + switch ( pSpriteObjects[uLayingItemID].uType ) { case 500: case 505: @@ -7836,32 +7032,42 @@ case 540: sub_43A97E(v153, v145); v8 = pObjectList->uNumObjects; - ++v2->uType; + ++pSpriteObjects[uLayingItemID].uType; v9 = 0; v10 = 0; if ( (signed int)v8 <= 0 ) - goto LABEL_23; + { + v12 = 0; + goto LABEL_24; + } v11 = (char *)&pObjectList->pObjects->uObjectID; break; case 545: case 550: - if ( v2->stru_24.uItemID != 405 && v2->stru_24.uSpecEnchantmentType != 3 ) + if ( pSpriteObjects[uLayingItemID].stru_24.uItemID != 405 && pSpriteObjects[uLayingItemID].stru_24.uSpecEnchantmentType != 3 ) { - v14 = v153; - v9 = 0; - v2->vVelocity.z = 0; - v2->vVelocity.y = 0; - v2->vVelocity.x = 0; - v2->uSpriteFrameID = 0; + pSpriteObjects[uLayingItemID].vVelocity.z = 0; + pSpriteObjects[uLayingItemID].vVelocity.y = 0; + pSpriteObjects[uLayingItemID].vVelocity.x = 0; + pSpriteObjects[uLayingItemID].uSpriteFrameID = 0; sub_43A97E(v153, v145); - goto LABEL_34; + SpriteObject::OnInteraction(v153); + if ( pSpriteObjects[uLayingItemID].uSoundID == 0 ) + v16 = 0; + else + v16 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v124 = 8 * v153; + LOBYTE(v124) = v124 | 2; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v124, 0, -1, 0, v16, 0, 0); + return 0; } v17 = pObjectList->uNumObjects; v18 = 0; v19 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uType = 600; + pSpriteObjects[uLayingItemID].uType = 600; if ( v20 | v44 ) goto LABEL_41; v21 = (char *)&pObjectList->pObjects->uObjectID; @@ -7877,35 +7083,39 @@ default: return 0; } - while ( v2->uType != *(short *)v11 ) + while ( pSpriteObjects[uLayingItemID].uType != *(short *)v11 ) { ++v10; v11 += 56; if ( v10 >= (signed int)v8 ) { -LABEL_23: v12 = 0; goto LABEL_24; } } v12 = v10; LABEL_24: - v2->uObjectDescID = v12; + pSpriteObjects[uLayingItemID].uObjectDescID = v12; if ( !v12 ) SpriteObject::OnInteraction(v153); - v44 = v2->uType == 555; - v2->vVelocity.z = 0; - v2->vVelocity.y = 0; - v2->vVelocity.x = 0; - v2->uSpriteFrameID = 0; + v44 = pSpriteObjects[uLayingItemID].uType == 555; + pSpriteObjects[uLayingItemID].vVelocity.z = 0; + pSpriteObjects[uLayingItemID].vVelocity.y = 0; + pSpriteObjects[uLayingItemID].vVelocity.x = 0; + pSpriteObjects[uLayingItemID].uSpriteFrameID = 0; if ( !v44 ) - goto LABEL_27; + { + v13 = 8 * v153; + LOBYTE(v13) = PID(OBJECT_Item,v153); + pAudioPlayer->PlaySound(SOUND_8, v13, v9, -1, v9, v9, v9, v9); + return 0; + } } return 0; } - if ( v7 > 1100 ) - { - v41 = v7 - 2030; + if ( pSpriteObjects[uLayingItemID].uType > 1100 ) + { + v41 = pSpriteObjects[uLayingItemID].uType - 2030; if ( !v41 ) goto LABEL_247; v42 = v41 - 30; @@ -7923,52 +7133,55 @@ LABEL_93: sub_43A97E(v153, v145); v51 = pObjectList->uNumObjects; - ++v2->uType; + ++pSpriteObjects[uLayingItemID].uType; v9 = 0; v52 = 0; if ( (signed int)v51 > 0 ) { v53 = (char *)&pObjectList->pObjects->uObjectID; - while ( v2->uType != *(short *)v53 ) + while ( pSpriteObjects[uLayingItemID].uType != *(short *)v53 ) { ++v52; v53 += 56; if ( v52 >= (signed int)v51 ) goto LABEL_181; } - goto LABEL_202; + v95 = v52; } + else + { LABEL_181: v95 = 0; -LABEL_182: - v2->uObjectDescID = v95; + } + pSpriteObjects[uLayingItemID].uObjectDescID = v95; if ( v95 == (short)v9 ) SpriteObject::OnInteraction(v153); - v96 = v2->uSoundID; - v2->vVelocity.z = v9; - v2->vVelocity.y = v9; - v2->vVelocity.x = v9; - v2->uSpriteFrameID = v9; + v96 = pSpriteObjects[uLayingItemID].uSoundID; + pSpriteObjects[uLayingItemID].vVelocity.z = v9; + pSpriteObjects[uLayingItemID].vVelocity.y = v9; + pSpriteObjects[uLayingItemID].vVelocity.x = v9; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v9; if ( v96 == (short)v9 ) v97 = 0; else v97 = (signed __int16)v96 + 4; - v133 = v9; - v131 = v9; - v130 = v97; v92 = v153; - goto LABEL_267; - } - if ( v7 == 1100 ) + v124 = 8 * v92; + LOBYTE(v124) = v124 | 2; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v97, v9, v9); + return 0; + } + if ( pSpriteObjects[uLayingItemID].uType == 1100 ) goto LABEL_93; - v26 = v7 - 600; + v26 = pSpriteObjects[uLayingItemID].uType - 600; if ( !v26 ) { v33 = pObjectList->uNumObjects; v34 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uType = 601; + pSpriteObjects[uLayingItemID].uType = 601; if ( v20 | v44 ) { LABEL_69: @@ -7986,30 +7199,24 @@ } v36 = v34; } - v2->uObjectDescID = v36; + pSpriteObjects[uLayingItemID].uObjectDescID = v36; if ( !v36 ) SpriteObject::OnInteraction(v153); - v37 = v2->vPosition.z; - v2->vVelocity.z = 0; + v37 = pSpriteObjects[uLayingItemID].vPosition.z; + pSpriteObjects[uLayingItemID].vVelocity.z = 0; v38 = 8 * v153; - v39 = v2->vPosition.y; + v39 = pSpriteObjects[uLayingItemID].vPosition.y; LOBYTE(v38) = PID(OBJECT_Item,v153); - v2->vVelocity.y = 0; - v2->vVelocity.x = 0; - v40 = v2->vPosition.x; - v2->uSpriteFrameID = 0; + pSpriteObjects[uLayingItemID].vVelocity.y = 0; + pSpriteObjects[uLayingItemID].vVelocity.x = 0; + v40 = pSpriteObjects[uLayingItemID].vPosition.x; + pSpriteObjects[uLayingItemID].uSpriteFrameID = 0; v147 = v38; stru_50FE08.Add(v38, 512, v40, v39, v37, 0, 0); - if ( HIBYTE(v3->uFlags) & 1 ) - array_5118E8._440E91(v2->vPosition.x, v2->vPosition.y, v2->vPosition.z, 0, v3->uParticleTrailColor); - v133 = 0; - v131 = 0; - v130 = 0; - v129 = 0; - v128 = -1; - v127 = 0; - v126 = v147; - goto LABEL_28; + if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor); + pAudioPlayer->PlaySound(SOUND_8, v147, 0, -1, 0, 0, 0, 0); + return 0; } v27 = v26 - 410; if ( !v27 ) @@ -8025,10 +7232,10 @@ LABEL_59: if ( v151 != 3 ) { - v30 = v6 + 1; + v30 = pSpriteObjects[uLayingItemID].uType + 1; v31 = pObjectList->uNumObjects; v32 = 0; - v2->uType = v30; + pSpriteObjects[uLayingItemID].uType = v30; v146 = 0; if ( (signed int)v31 > 0 ) { @@ -8038,48 +7245,73 @@ ++v146; v140 += 56; if ( v146 >= (signed int)v31 ) - goto LABEL_195; + { + v46 = 0; + pSpriteObjects[uLayingItemID].uObjectDescID = v46; + if ( v46 == (short)v32 ) + SpriteObject::OnInteraction(v153); + v100 = pSpriteObjects[uLayingItemID].field_61; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v32; + v102 = 8 * v153; + LOBYTE(v102) = PID(OBJECT_Item,v153); + pSpriteObjects[uLayingItemID].vVelocity.x = v32; + pSpriteObjects[uLayingItemID].vVelocity.y = v32; + pSpriteObjects[uLayingItemID].vVelocity.z = v32; + stru_50FE08.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32); + if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor); + if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 ) + v47 = 0; + else + v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32); + return 0; + } } -LABEL_80: v46 = v146; -LABEL_196: - v2->uObjectDescID = v46; + pSpriteObjects[uLayingItemID].uObjectDescID = v46; if ( v46 == (short)v32 ) SpriteObject::OnInteraction(v153); - v100 = v2->field_61; - v101 = v2->vPosition.z; - v2->uSpriteFrameID = v32; + v100 = pSpriteObjects[uLayingItemID].field_61; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v32; v102 = 8 * v153; - v103 = v2->vPosition.y; LOBYTE(v102) = PID(OBJECT_Item,v153); - v2->vVelocity.x = v32; - v2->vVelocity.y = v32; - v104 = v2->vPosition.x; - v2->vVelocity.z = v32; - v149 = v102; - stru_50FE08.Add(v102, 512, v104, v103, v101, v100, v32); - if ( HIBYTE(v3->uFlags) & 1 ) - array_5118E8._440E91( - v2->vPosition.x, - v2->vPosition.y, - v2->vPosition.z, - v32, - v3->uParticleTrailColor); - v105 = v2->uSoundID; - if ( v105 == (short)v32 ) + pSpriteObjects[uLayingItemID].vVelocity.x = v32; + pSpriteObjects[uLayingItemID].vVelocity.y = v32; + pSpriteObjects[uLayingItemID].vVelocity.z = v32; + stru_50FE08.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32); + if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor); + if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 ) v47 = 0; else - v47 = (signed __int16)v105 + 4; - v133 = v32; - v131 = v32; - v130 = v47; - v129 = v32; - v128 = -1; - v127 = v32; - v126 = v149; - goto LABEL_268; + v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32); + return 0; } - goto LABEL_195; + v46 = 0; + pSpriteObjects[uLayingItemID].uObjectDescID = v46; + if ( v46 == (short)v32 ) + SpriteObject::OnInteraction(v153); + v100 = pSpriteObjects[uLayingItemID].field_61; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v32; + v102 = 8 * v153; + LOBYTE(v102) = PID(OBJECT_Item,v153); + pSpriteObjects[uLayingItemID].vVelocity.x = v32; + pSpriteObjects[uLayingItemID].vVelocity.y = v32; + pSpriteObjects[uLayingItemID].vVelocity.z = v32; + stru_50FE08.Add(v102, 512, pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v100, v32); + if (v3->uFlags & OBJECT_DESC_TRIAL_PARTICLE) + trail_particle_generator.GenerateTrailParticles(pSpriteObjects[uLayingItemID].vPosition.x, pSpriteObjects[uLayingItemID].vPosition.y, pSpriteObjects[uLayingItemID].vPosition.z, v3->uParticleTrailColor); + if ( pSpriteObjects[uLayingItemID].uSoundID == (short)v32 ) + v47 = 0; + else + v47 = (signed __int16)pSpriteObjects[uLayingItemID].uSoundID + 4; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v102, v32, -1, v32, v47, v32, v32); + return 0; } return 1; } @@ -8090,33 +7322,48 @@ { sub_43A97E(v153, v145); v122 = pObjectList->uNumObjects; - ++v2->uType; + ++pSpriteObjects[uLayingItemID].uType; v52 = 0; if ( (signed int)v122 > 0 ) { v123 = (char *)&pObjectList->pObjects->uObjectID; - while ( v2->uType != *(short *)v123 ) + while ( pSpriteObjects[uLayingItemID].uType != *(short *)v123 ) { ++v52; v123 += 56; if ( v52 >= (signed int)v122 ) goto LABEL_181; } -LABEL_202: v95 = v52; - goto LABEL_182; + pSpriteObjects[uLayingItemID].uObjectDescID = v95; + if ( v95 == (short)v9 ) + SpriteObject::OnInteraction(v153); + v96 = pSpriteObjects[uLayingItemID].uSoundID; + pSpriteObjects[uLayingItemID].vVelocity.z = v9; + pSpriteObjects[uLayingItemID].vVelocity.y = v9; + pSpriteObjects[uLayingItemID].vVelocity.x = v9; + pSpriteObjects[uLayingItemID].uSpriteFrameID = v9; + if ( v96 == (short)v9 ) + v97 = 0; + else + v97 = (signed __int16)v96 + 4; + v92 = v153; + v124 = 8 * v92; + LOBYTE(v124) = v124 | 2; + v125 = word_4EE088_sound_ids[pSpriteObjects[uLayingItemID].spell_id - 1] + 1; + pAudioPlayer->PlaySound((SoundID)v125, v124, v9, -1, v9, v97, v9, v9); + return 0; } goto LABEL_181; } - v117 = v6 + 1; + v117 = pSpriteObjects[uLayingItemID].uType + 1; v118 = pObjectList->uNumObjects; v119 = 0; v44 = pObjectList->uNumObjects == 0; v20 = (pObjectList->uNumObjects & 0x80000000u) != 0; - v2->uType = v117; + pSpriteObjects[uLayingItemID].uType = v117; if ( v20 | v44 ) { -LABEL_255: v121 = 0; } else @@ -8127,30 +7374,32 @@ ++v119; v120 += 56; if ( v119 >= (signed int)v118 ) - goto LABEL_255; + { + v121 = 0; + pSpriteObjects[uLayingItemID].uObjectDescID = v121; + if ( !v121 ) + SpriteObject::OnInteraction(v153); + pSpriteObjects[uLayingItemID].vVelocity.z = 0; + pSpriteObjects[uLayingItemID].vVelocity.y = 0; + pSpriteObjects[uLayingItemID].vVelocity.x = 0; + pSpriteObjects[uLayingItemID].uSpriteFrameID = 0; + v13 = 8 * v153; + LOBYTE(v13) = PID(OBJECT_Item,v153); + pAudioPlayer->PlaySound(SOUND_8, v13, v9, -1, v9, v9, v9, v9); + return 0; + } } v121 = v119; } - v2->uObjectDescID = v121; + pSpriteObjects[uLayingItemID].uObjectDescID = v121; if ( !v121 ) SpriteObject::OnInteraction(v153); - v2->vVelocity.z = 0; - v2->vVelocity.y = 0; - v2->vVelocity.x = 0; - v2->uSpriteFrameID = 0; -LABEL_27: - v133 = v9; - v131 = v9; - v130 = v9; + pSpriteObjects[uLayingItemID].vVelocity.z = 0; + pSpriteObjects[uLayingItemID].vVelocity.y = 0; + pSpriteObjects[uLayingItemID].vVelocity.x = 0; + pSpriteObjects[uLayingItemID].uSpriteFrameID = 0; v13 = 8 * v153; - v129 = v9; - v128 = -1; LOBYTE(v13) = PID(OBJECT_Item,v153); - v127 = v9; - v126 = v13; -LABEL_28: - v125 = 8; -LABEL_29: - pAudioPlayer->PlaySound((SoundID)v125, v126, v127, v128, v129, v130, v131, v133); + pAudioPlayer->PlaySound(SOUND_8, v13, v9, -1, v9, v9, v9, v9); return 0; }
--- a/mm7_3.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/mm7_3.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -42,7 +42,6 @@ #include "Time.h" #include "IconFrameTable.h" #include "TurnEngine.h" -#include "stru220.h" #include "Events2D.h" #include "stru176.h" #include "stru298.h" @@ -1817,37 +1816,38 @@ pParty->sRotationX = _view_angle; if ( bJumping ) { - pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength(); + pParty->uFallSpeed += -2 * pEventTimer->uTimeElapsed * GetGravityStrength(); + if ( bJumping != v36 && pParty->uFallSpeed <= v36 ) + { + if ( pParty->uFallSpeed < -500 && !pParty->bFlying ) + { + v41 = &pPlayers[1]; + do + { + if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 + (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0); + ++v41; + } + while ( (signed int)v41 <= (signed int)&pPlayers[4] ); + } + } + else + pParty->uFallStartY = party_z; } else { if ( pIndoor->pFaces[uFaceID].pFacePlane_old.vNormal.z < 32768 ) { pParty->uFallSpeed -= pEventTimer->uTimeElapsed * GetGravityStrength(); - goto LABEL_92; + pParty->uFallStartY = party_z; } - if (pParty->uFlags & PARTY_FLAGS_1_LANDING) - goto LABEL_92; - pParty->uFallSpeed = 0; - } - if ( bJumping != v36 && pParty->uFallSpeed <= v36 ) - { - if ( pParty->uFallSpeed < -500 && !pParty->bFlying ) - { - v41 = &pPlayers[1]; - do - { - if ( !(*v41)->HasEnchantedItemEquipped(72) && !(*v41)->WearsItem(ITEM_ARTIFACT_HERMES_SANDALS, EQUIP_BOOTS) ) //was 8 - (*v41)->PlayEmotion(CHARACTER_EXPRESSION_SCARED, 0); - ++v41; - } - while ( (signed int)v41 <= (signed int)&pPlayers[4] ); - } - goto LABEL_93; - } -LABEL_92: - pParty->uFallStartY = party_z; -LABEL_93: + else + { + if (! (pParty->uFlags & PARTY_FLAGS_1_LANDING) ) + pParty->uFallSpeed = 0; + pParty->uFallStartY = party_z; + } + } if ( v2 * v2 + v1 * v1 < 400 ) { v1 = 0; @@ -1924,9 +1924,8 @@ && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime)) ) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); viewparams->bRedrawGameUI = 1; - goto LABEL_152; } - if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) + else if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v53 = integer_sqrt(v2 * v2 + v1 * v1); v80 = v53; @@ -1956,64 +1955,69 @@ } if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - goto LABEL_152; } - v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z; - v47 = v45 == 4; - v48 = v44->pFacePlane_old.vNormal.x; - if ( !v47 ) - { - v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; - if ( stru_721530.field_64 >> 3 > v80 ) - v80 = stru_721530.field_64 >> 3; - v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; - v81 = v44->pFacePlane_old.vNormal.y; - v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; - v82 = v44->pFacePlane_old.vNormal.z; - v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; - v2 += v50; - pParty->uFallSpeed += v82; - v74 = v44->pFacePlane_old.vNormal.z; - v51 = v44->pFacePlane_old.vNormal.y; - v69 = v44->pFacePlane_old.vNormal.x; - v80 = v51; - v1 += v81; - v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16); - if ( v52 > 0 ) - { - new_party_x += v52 * v69 >> 16; - new_party_y += v52 * v80 >> 16; - v87 += v52 * v74 >> 16; - } - v43 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) - uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - goto LABEL_152; - } - v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; - if ( stru_721530.field_64 >> 3 > v80 ) - v80 = stru_721530.field_64 >> 3; - v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; - v81 = v44->pFacePlane_old.vNormal.y; - v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; - v82 = v44->pFacePlane_old.vNormal.z; - v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; - v2 += v49; - v1 += v81; - pParty->uFallSpeed += v82; - if ( v2 * v2 + v1 * v1 >= 400 ) - { - v43 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) - uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; - goto LABEL_152; - } - v2 = 0; - v1 = 0; - pParty->uFallSpeed = 0; + else + { + v46 = pParty->uFallSpeed * v44->pFacePlane_old.vNormal.z; + v47 = v45 == 4; + v48 = v44->pFacePlane_old.vNormal.x; + if ( !v47 ) + { + v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; + if ( stru_721530.field_64 >> 3 > v80 ) + v80 = stru_721530.field_64 >> 3; + v50 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; + v81 = v44->pFacePlane_old.vNormal.y; + v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; + v82 = v44->pFacePlane_old.vNormal.z; + v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; + v2 += v50; + pParty->uFallSpeed += v82; + v74 = v44->pFacePlane_old.vNormal.z; + v51 = v44->pFacePlane_old.vNormal.y; + v69 = v44->pFacePlane_old.vNormal.x; + v80 = v51; + v1 += v81; + v52 = stru_721530.prolly_normal_d - ((v44->pFacePlane_old.dist + v87 * v74 + new_party_y * v51 + new_party_x * v69) >> 16); + if ( v52 > 0 ) + { + new_party_x += v52 * v69 >> 16; + new_party_y += v52 * v80 >> 16; + v87 += v52 * v74 >> 16; + } + v43 = stru_721530.uFaceID; + if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) + uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; + } + else + { + v80 = abs(v1 * v44->pFacePlane_old.vNormal.y + v46 + v2 * v48) >> 16; + if ( stru_721530.field_64 >> 3 > v80 ) + v80 = stru_721530.field_64 >> 3; + v49 = (unsigned __int64)(v80 * (signed __int64)v44->pFacePlane_old.vNormal.x) >> 16; + v81 = v44->pFacePlane_old.vNormal.y; + v81 = (unsigned __int64)(v80 * (signed __int64)v81) >> 16; + v82 = v44->pFacePlane_old.vNormal.z; + v82 = (unsigned __int64)(v80 * (signed __int64)v82) >> 16; + v2 += v49; + v1 += v81; + pParty->uFallSpeed += v82; + if ( v2 * v2 + v1 * v1 >= 400 ) + { + v43 = stru_721530.uFaceID; + if ( pParty->floor_face_pid != PID_ID(v43) && BYTE3(v44->uAttributes) & 4 ) + uFaceEvent = pIndoor->pFaceExtras[v44->uFaceExtraID].uEventID; + } + else + { + v2 = 0; + v1 = 0; + pParty->uFallSpeed = 0; + } + } + } } } -LABEL_152: v2 = (unsigned __int64)(58500i64 * v2) >> 16; v1 = (unsigned __int64)(58500i64 * v1) >> 16; ++v83; @@ -2029,8 +2033,11 @@ if ( integer_sqrt((pParty->vPosition.x - new_party_x) * (pParty->vPosition.x - new_party_x) + (pParty->vPosition.y - new_party_y) * (pParty->vPosition.y - new_party_y) + (pParty->vPosition.z - new_party_z) * (pParty->vPosition.z - new_party_z)) <= 16 ) - goto LABEL_188; - if ( v72 && (!bJumping || jumping_up) ) + { + pAudioPlayer->_4AA258(804); + pParty->walk_sound_timer = 64; + } + else if ( v72 && (!bJumping || jumping_up) ) { v66 = 0; v64 = 0; @@ -2046,13 +2053,16 @@ v57 = (SoundID)50; else v57 = (SoundID)64; - goto LABEL_175; + pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); } - v57 = (SoundID)63; - v56 = pAudioPlayer; - goto LABEL_175; + else + { + v57 = (SoundID)63; + v56 = pAudioPlayer; + pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); + } } - if ( v78 && (!bJumping || jumping_up) ) + else if ( v78 && (!bJumping || jumping_up) ) { v66 = 0; v64 = 0; @@ -2065,19 +2075,19 @@ { v57 = (SoundID)102; v56 = pAudioPlayer; - goto LABEL_175; } - v56 = pAudioPlayer; - if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) - v57 = (SoundID)89; - else - v57 = (SoundID)103; -LABEL_175: + else + { + v56 = pAudioPlayer; + if ( BYTE2(pIndoor->pFaces[uFaceID].uAttributes) & 0x20 ) + v57 = (SoundID)89; + else + v57 = (SoundID)103; + } pAudioPlayer->PlaySound(v57, v58, v59, v60, v61, v62, v64, v66); } else { -LABEL_188: pAudioPlayer->_4AA258(804); pParty->walk_sound_timer = 64; } @@ -2098,41 +2108,13 @@ } //----- (00473893) -------------------------------------------------------- -void __cdecl ODM_ProcessPartyActions() +void ODM_ProcessPartyActions() { - //int _zero; // esi@1 int v1; // edi@1 int v2; // ebx@1 int v3; // eax@14 - //Player **v4; // esi@21 - //int v5; // eax@24 int v6; // esi@45 ODMFace *v7; // ecx@45 - //unsigned int v8; // eax@71 - //double v9; // st7@72 - //signed __int64 v10; // qax@74 - //double v11; // st7@75 - //int v12; // ecx@77 - //int v13; // eax@84 - //double v14; // st7@84 - //int v15; // eax@87 - //double v16; // st7@87 - //int v17; // eax@88 - //double v18; // st7@88 - //int v19; // eax@89 - //double v20; // st7@89 - //int v21; // eax@92 - //double v22; // st7@92 - //int v23; // eax@96 - //double v24; // st7@96 - //int v25; // eax@97 - //double v26; // st7@97 - //int v27; // eax@98 - //double v28; // st7@98 - //signed __int64 v29; // qax@98 - //unsigned int v30; // eax@103 - int v31; // eax@130 - //int v32; // ecx@141 signed int v33; // eax@143 int v34; // esi@143 int v35; // esi@147 @@ -2141,19 +2123,17 @@ signed int v38; // eax@159 signed int i; // esi@159 int v40; // esi@162 - //Player **v41; // esi@172 bool v42; // eax@180 signed int v43; // ecx@184 signed int v44; // edx@184 int v45; // ecx@200 - BSPModel *v46; // eax@203 - ODMFace *v47; // esi@203 + BSPModel *pModel; // eax@203 + ODMFace *pODMFace; // esi@203 int v48; // eax@203 char v49; // zf@203 char v50; // sf@203 unsigned __int8 v51; // of@203 int v52; // eax@203 - unsigned __int8 v53; // dl@205 BSPModel *v54; // eax@215 int v55; // eax@217 signed int v56; // ebx@228 @@ -2163,8 +2143,6 @@ BSPModel *v60; // eax@228 unsigned __int64 v61; // qax@228 int v62; // eax@241 - signed int v63; // ST04_4@255 - signed int v64; // eax@255 unsigned int v65; // ebx@263 unsigned int v66; // esi@263 int v67; // eax@263 @@ -2174,8 +2152,6 @@ int v71; // esi@271 int v72; // edi@271 int v73; // eax@271 - Player **v74; // esi@283 - int v75; // eax@284 unsigned int v76; // edi@293 bool v77; // edx@297 bool v78; // ecx@303 @@ -2183,9 +2159,7 @@ __int16 v80; // dx@317 int v81; // ebx@318 int v82; // ecx@318 - int v83; // eax@321 - Player **v84; // esi@333 - int v85; // eax@334 + int pTerrainHeight; // eax@321 int v86; // [sp-20h] [bp-B4h]@246 int v87; // [sp-20h] [bp-B4h]@248 signed int v88; // [sp-1Ch] [bp-B0h]@246 @@ -2193,23 +2167,16 @@ signed int v90; // [sp-14h] [bp-A8h]@246 signed int v91; // [sp-10h] [bp-A4h]@246 int v92; // [sp-Ch] [bp-A0h]@246 - //int v93; // [sp-8h] [bp-9Ch]@104 unsigned int v94; // [sp-8h] [bp-9Ch]@246 - //int v95; // [sp-4h] [bp-98h]@104 int v96; // [sp-4h] [bp-98h]@246 int v97; // [sp+Ch] [bp-88h]@180 Vec3_int_ v98; - //int v98; // [sp+10h] [bp-84h]@147 - //int v99; // [sp+14h] [bp-80h]@147 - //int v100; // [sp+18h] [bp-7Ch]@147 bool v101; // [sp+1Ch] [bp-78h]@33 int v102; // [sp+20h] [bp-74h]@1 int v103; // [sp+24h] [bp-70h]@1 int bFeatherFall; // [sp+28h] [bp-6Ch]@4 int v105; // [sp+2Ch] [bp-68h]@24 int bWaterWalk; // [sp+30h] [bp-64h]@1 - bool v107; // [sp+34h] [bp-60h]@30 - int v108; // [sp+38h] [bp-5Ch]@1 int v109; // [sp+3Ch] [bp-58h]@28 int v110; // [sp+40h] [bp-54h]@180 int v111; // [sp+44h] [bp-50h]@14 @@ -2220,20 +2187,15 @@ int pX; // [sp+58h] [bp-3Ch]@1 int pY; // [sp+5Ch] [bp-38h]@1 int v118; // [sp+60h] [bp-34h]@1 - //Player **v119; // [sp+64h] [bp-30h]@4 int _angle_x; // [sp+68h] [bp-2Ch]@48 - int v121; // [sp+6Ch] [bp-28h]@1 unsigned int v122; // [sp+70h] [bp-24h]@180 int pZ; // [sp+74h] [bp-20h]@1 int v124; // [sp+78h] [bp-1Ch]@1 int _angle_y; // [sp+7Ch] [bp-18h]@48 int v126; // [sp+80h] [bp-14h]@48 - BSPModel *v127; // [sp+84h] [bp-10h]@1 int v128; // [sp+88h] [bp-Ch]@1 int v129; // [sp+8Ch] [bp-8h]@92 - int v130; // [sp+90h] [bp-4h]@14 - - v121 = pParty->uFallSpeed; + pZ = pParty->vPosition.z; v1 = 0; v103 = 0; @@ -2248,22 +2210,12 @@ auto partyAtHighSlope = IsTerrainSlopeTooHigh(pParty->vPosition.x, pParty->vPosition.y); v114 = 0; v124 = 0; - v108 = 0; v102 = 0; - v127 = 0; + pModel = 0; bWaterWalk = 0; if (!pParty->FeatherFallActive()) - //SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) < 0 - //|| SHIDWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 && LODWORD(pParty->pPartyBuffs[5].uExpireTime) <= 0 ) { bFeatherFall = 0; - /*v119 = &pPlayers[1]; - while ( !(*v119)->WearsItem(536, 16) ) - { - ++v119; - if ( (signed int)v119 > (signed int)&pPlayers[4] ) - goto LABEL_9; - }*/ for (int i = 0; i < 4; ++i) if (pParty->pPlayers[i].WearsItem(ITEM_ARTIFACT_LADYS_ESCORT, EQIUP_ANY)) // seems like flying boots { @@ -2283,11 +2235,14 @@ bWaterWalk = 1; *(short *)&stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uOverlayID + 119] |= 1u; if (!(pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags & 1) && - pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster-1].sMana <= 0 ) - //*(int *)&pParty->pArtifactsFound[6972 * pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster + 10] <= 0 ) + pParty->pPlayers[pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uCaster - 1].sMana <= 0 ) bWaterWalk = 0; } - v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &v130, &v108, bWaterWalk); + int bmodel_standing_on_pid; + int is_on_water = false; + v3 = ODM_GetFloorLevel(pX, pY, pZ, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, bWaterWalk); + int is_not_on_bmodel = bmodel_standing_on_pid == 0; + v111 = v3; if ( bFeatherFall ) pParty->uFallStartY = v3; @@ -2318,7 +2273,7 @@ v109 = -1; if ( pParty->bFlying ) v109 = sub_46D8E3(pX, pY, pZ + pParty->uPartyHeight, (int)&v102); - v107 = v108 == 0; + //v107 = bmodel_standing_on_pid == 0; v105 = v111 + 1; if ( pZ <= v111 + 1 ) { @@ -2336,20 +2291,18 @@ pParty->walk_sound_timer -= pEventTimer->uTimeElapsed; else pParty->walk_sound_timer = 0; } - if (!bUnderwater - && SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0 - && (SHIDWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) < 0 || LODWORD(pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime) <= 0) ) + if (!bUnderwater && pParty->pPartyBuffs[PARTY_BUFF_FLY].uExpireTime <= 0) pParty->bFlying = false; if (!bJumping) { - if ( pParty->floor_face_pid != PID(OBJECT_BModel, v108) ) + if ( pParty->floor_face_pid != PID(OBJECT_BModel, bmodel_standing_on_pid) ) { - if (v108) + if (bmodel_standing_on_pid) { - if ( v108 >> 6 < pOutdoor->uNumBModels ) + if ( (bmodel_standing_on_pid >> 6) < pOutdoor->uNumBModels ) { - v7 = pOutdoor->pBModels[v108 >> 6].pFaces; - v6 = v108 & 0x3F; + v7 = pOutdoor->pBModels[bmodel_standing_on_pid >> 6].pFaces; + v6 = bmodel_standing_on_pid & 0x3F; /*if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 ) { pParty->field_6F4_packedid = PID(OBJECT_BModel,v108); @@ -2357,13 +2310,13 @@ }*/ if ( BYTE3(v7[v6].uAttributes) & 4 ) { - pParty->floor_face_pid = PID(OBJECT_BModel, v108); + pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); v103 = v7[v6].sCogTriggeredID; } } } } - pParty->floor_face_pid = PID(OBJECT_BModel, v108); + pParty->floor_face_pid = PID(OBJECT_BModel, bmodel_standing_on_pid); } _walk_speed = pParty->uWalkSpeed; _angle_y = pParty->sRotationY; @@ -2400,7 +2353,7 @@ } v1 = 0; v2 = 0; - v121 = 0; + pParty->uFallSpeed = 0; *(float *)&v128 = 0.0; if ( v102 && pZ < v109 && (signed int)(pParty->uPartyHeight + pZ) >= v109 ) { @@ -2415,7 +2368,7 @@ v113 = pParty->field_6F0; } pParty->uFallSpeed = 0; - v127 = (BSPModel *)1; + pModel = (BSPModel *)1; } } } @@ -2432,9 +2385,9 @@ pZ -= 30; v113 -= 30; pParty->uFallSpeed = 0; - v121 = 0; + //pParty->uFallSpeed = 0; pParty->bFlying = 1; - v127 = (BSPModel *)1; + pModel = (BSPModel *)1; if ( pZ <= v111 ) { pParty->bFlying = 0; @@ -2539,7 +2492,7 @@ float sin_y = sinf(2 * 3.141592653589 * _angle_y / 2048.0), cos_y = cosf(2 * 3.141592653589 * _angle_y / 2048.0); - int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; + int dx = cos_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; int dy = sin_y * pParty->uWalkSpeed * fWalkSpeedMultiplier; if (pParty->bFlying) @@ -2549,7 +2502,7 @@ v128 = v1; } - else if (partyAtHighSlope && !v108) + else if (partyAtHighSlope && !bmodel_standing_on_pid) { v2 += dx; v1 += dy; @@ -2613,7 +2566,6 @@ } break; - case PARTY_CenterView: _angle_x = 0; break; @@ -2635,11 +2587,11 @@ break; case PARTY_Jump: - if ( (!partyAtHighSlope || v108) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) + if ( (!partyAtHighSlope || bmodel_standing_on_pid) && !bJumping && pParty->field_24 && !(pParty->uFlags & 4) && !(BYTE1(pParty->uFlags) & 2) ) { v126 = pParty->field_24 << 6; bJumping = 1; - v121 = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)v121); + pParty->uFallSpeed = (signed __int64)((double)(pParty->field_24 << 6) * 1.5 + (double)pParty->uFallSpeed); } break; @@ -2665,30 +2617,26 @@ { if ( pParty->bFlying ) { -//LABEL_130: - v31 = GetTickCount(); - v126 = stru_5C6E00->Cos(v31); + v126 = stru_5C6E00->Cos(GetTickCount()); v129 = (unsigned __int64)(4i64 * v126) >> 16; pZ = v113 + v129; - if ( v127 ) + if ( pModel ) pZ = v113; if (pParty->FlyActive()) stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] &= 0xFEu; pParty->uFallStartY = pZ; - //goto LABEL_141; } - else - { - if ( v130 && v121 ) - sub_42F960_create_object(pX, pY, v111); - v121 = 0; - pZ = v111; - pParty->uFallStartY = v111; - v113 = pZ; - if (pParty->FlyActive()) - stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u; - - } + else + { + if ( is_on_water && pParty->uFallSpeed ) + sub_42F960_create_object(pX, pY, v111); + pParty->uFallSpeed = 0; + pZ = v111; + pParty->uFallStartY = v111; + v113 = pZ; + if (pParty->FlyActive()) + stru_5E4C90._decor_events[20 * pParty->pPartyBuffs[PARTY_BUFF_FLY].uOverlayID + 119] |= 1u; + } } else { @@ -2700,33 +2648,33 @@ if (bJumping && !pParty->bFlying) { v33 = -(pEventTimer->uTimeElapsed * GetGravityStrength()); - v34 = v121 + 2 * v33; - v121 += 2 * v33; + v34 = pParty->uFallSpeed + 2 * v33; + pParty->uFallSpeed += 2 * v33; } else if (!partyAtHighSlope) { - v34 = v121; + v34 = pParty->uFallSpeed; } else if (!bJumping) { - if ( !v108 ) + if ( !bmodel_standing_on_pid ) { // rolling down the hill // how it's done: you get a little bit pushed in the air along terrain normal, getting in the air // and falling to the gravity, gradually sliding downwards. nice trick pZ = v111; ODM_GetTerrainNormalAt(pX, pY, &v98); - v35 = v121 + -8 * pEventTimer->uTimeElapsed * GetGravityStrength(); + v35 = pParty->uFallSpeed + -8 * pEventTimer->uTimeElapsed * GetGravityStrength(); v129 = abs((signed __int64)v2 * v98.x + (signed __int64)v1 * v98.y + (signed __int64)v35 * v98.z) >> 16; v2 += (unsigned __int64)(v129 * (signed __int64)v98.x) >> 16; v1 += (unsigned __int64)(v129 * (signed __int64)v98.y) >> 16; v34 = v35 + ((unsigned __int64)(v129 * (signed __int64)v98.z) >> 16); v128 = v1; - v121 = v34; + pParty->uFallSpeed = v34; } } else - v34 = v121; + v34 = pParty->uFallSpeed; //LABEL_164: if(bJumping) @@ -2775,7 +2723,7 @@ stru_721530.normal.z = stru_721530.prolly_normal_d + pZ + 1; stru_721530.field_34.z = stru_721530.field_C + pZ + 1; stru_721530.field_20 = v128; - stru_721530.field_24 = v121; + stru_721530.field_24 = pParty->uFallSpeed; v36 = 0; stru_721530.uSectorID = 0; if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == 3 ) @@ -2799,22 +2747,22 @@ { _angle_x = pX + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.x) >> 16); _angle_y = pY + ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.y) >> 16); - v127 = (BSPModel *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16); + pModel = (BSPModel *)((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16); v40 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + pZ; } v122 = v40; - ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0); - v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &v130, &v97, 0); - auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &v130, &v110, 0); - v127 = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY); + ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); + v129 = ODM_GetFloorLevel(_angle_x, pY, v40, pParty->uPartyHeight, &is_on_water, &v97, 0); + auto v119 = ODM_GetFloorLevel(pX, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &v110, 0); + pModel = (BSPModel *)IsTerrainSlopeTooHigh(_angle_x, pY); v42 = IsTerrainSlopeTooHigh(pX, _angle_y); - v107 = 0; + is_not_on_bmodel = false; v118 = v42; - if ( !v97 && !v110 && !v108 ) - v107 = 1; + if ( !v97 && !v110 && !bmodel_standing_on_pid ) + is_not_on_bmodel = true; v43 = 1; v44 = 1; - if ( bUnderwater || !v107 ) + if ( bUnderwater || !is_not_on_bmodel ) { pX = _angle_x; if ( v43 ) @@ -2822,7 +2770,7 @@ } else { - if ( v127 && v129 > pZ ) + if ( pModel && v129 > pZ ) v44 = 0; if ( v118 && v119 > pZ ) v43 = 0; @@ -2836,8 +2784,8 @@ pY = _angle_y; else { - v127 = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &v130, &v108, 0); - if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)v127 <= pZ ) + pModel = (BSPModel *)ODM_GetFloorLevel(_angle_x, _angle_y, v40, pParty->uPartyHeight, &is_on_water, &bmodel_standing_on_pid, 0); + if ( IsTerrainSlopeTooHigh(_angle_x, _angle_y) && (signed int)pModel <= pZ ) { v43 = 1; pX = _angle_x; @@ -2848,7 +2796,7 @@ } if ( stru_721530.field_7C >= stru_721530.field_6C ) { - if ( !v107 ) + if ( !is_not_on_bmodel ) { pX = stru_721530.normal2.x; pY = stru_721530.normal2.y; @@ -2868,28 +2816,27 @@ viewparams->bRedrawGameUI = 1; v2 = (unsigned __int64)(58500i64 * v2) >> 16; - v127 = (BSPModel *)58500; + pModel = (BSPModel *)58500; v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * v121) >> 16; + v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; ++v126; - v121 = (unsigned __int64)(58500i64 * v121) >> 16; + pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; continue; } if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v56 = integer_sqrt(v2 * v2 + v128 * v128); v118 = v56; - v57 = stru_5C6E00->Atan2( - _angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, - _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y); + v57 = stru_5C6E00->Atan2(_angle_x - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.x, + _angle_y - pLevelDecorations[(signed int)stru_721530.uFaceID >> 3].vPosition.y); v129 = v57; v58 = (BSPModel *)stru_5C6E00->Cos(v57); - v127 = v58; + pModel = v58; v59 = (signed int)v58 * (signed __int64)v56; v122 = v59 >> 16; v2 = v59 >> 16; v60 = (BSPModel *)stru_5C6E00->Sin(v129); - v127 = v60; + pModel = v60; v61 = (signed int)v60 * (signed __int64)v118; v122 = v61 >> 16; v128 = v61 >> 16; @@ -2899,128 +2846,125 @@ if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { pParty->bFlying = 0; - v46 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; - v127 = v46; - v47 = &v46->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F]; - v48 = v47->pBoundingBox.z2 - v47->pBoundingBox.z1; + pModel = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; + //v127 = v46; + pODMFace = &pModel->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F]; + v48 = pODMFace->pBoundingBox.z2 - pODMFace->pBoundingBox.z1; v51 = __OFSUB__(v48, 32); v49 = v48 == 32; v50 = v48 - 32 < 0; - v52 = v47->pFacePlane.vNormal.z; + v52 = pODMFace->pFacePlane.vNormal.z; v129 = (unsigned __int8)(v50 ^ v51 | v49); v119 = v52 < 46378; if ( bUnderwater == 1 ) v119 = 0; - v53 = v47->uPolygonType; - if ( v53 == 3 ) + if ( pODMFace->uPolygonType == POLYGON_Floor ) { - if ( v121 < 0 ) - v121 = 0; - pZ = v127->pVertices.pVertices[v47->pVertexIDs[0]].z + 1; - if ( v2 * v2 + v128 * v128 < 400 ) - { - v2 = 0; - *(float *)&v128 = 0.0; - } - if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 ) - { - pParty->floor_face_pid = v45; - v103 = v47->sCogTriggeredID; - } - v2 = (unsigned __int64)(58500i64 * v2) >> 16; - v127 = (BSPModel *)58500; - v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * v121) >> 16; - ++v126; - v121 = (unsigned __int64)(58500i64 * v121) >> 16; - continue; + if ( pParty->uFallSpeed < 0 ) + pParty->uFallSpeed = 0; + pZ = pModel->pVertices.pVertices[pODMFace->pVertexIDs[0]].z + 1; + if ( v2 * v2 + v128 * v128 < 400 ) + { + v2 = 0; + *(float *)&v128 = 0.0; + } + if ( pParty->floor_face_pid != v45 && (pODMFace->uAttributes & FACE_PRESSURE_PLATE)) + { + pParty->floor_face_pid = v45; + v103 = pODMFace->sCogTriggeredID; + } + v2 = (unsigned __int64)(58500i64 * v2) >> 16; + pModel = (BSPModel *)58500; + v128 = (unsigned __int64)(58500i64 * v128) >> 16; + v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; + ++v126; + pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; + continue; } - if ( !v129 && (v53 != 4 || v119) ) + if ( !v129 && (pODMFace->uPolygonType != POLYGON_InBetweenFloorAndWall || v119) )// упёрся в столб { - v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16; + v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; if ( stru_721530.field_64 >> 3 > v118 ) v118 = stru_721530.field_64 >> 3; - v129 = v47->pFacePlane.vNormal.x; - v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16; - _walk_speed = v47->pFacePlane.vNormal.y; - _walk_speed = (unsigned __int64)(v118 * (signed __int64)_walk_speed) >> 16; + v129 = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.x) >> 16; + _walk_speed = (unsigned __int64)(v118 * (signed __int64)pODMFace->pFacePlane.vNormal.y) >> 16; v54 = 0; if ( !v119 ) { - v127 = (BSPModel *)v47->pFacePlane.vNormal.z; - v127 = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)v127) >> 16); - v54 = v127; + pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.z; + pModel = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)pModel) >> 16); + v54 = pModel; } - v121 += (int)v54; + pParty->uFallSpeed += (int)v54; v128 += _walk_speed; v2 += v129; v55 = stru_721530.prolly_normal_d - - ((signed int)(v47->pFacePlane.dist - + v122 * v47->pFacePlane.vNormal.z - + _angle_y * v47->pFacePlane.vNormal.y - + _angle_x * v47->pFacePlane.vNormal.x) >> 16); + - ((signed int)(pODMFace->pFacePlane.dist + + v122 * pODMFace->pFacePlane.vNormal.z + + _angle_y * pODMFace->pFacePlane.vNormal.y + + _angle_x * pODMFace->pFacePlane.vNormal.x) >> 16); if ( v55 > 0 ) { - pX = _angle_x + (v47->pFacePlane.vNormal.x * v55 >> 16); - pY = _angle_y + (v47->pFacePlane.vNormal.y * v55 >> 16); + pX = _angle_x + (pODMFace->pFacePlane.vNormal.x * v55 >> 16); + pY = _angle_y + (pODMFace->pFacePlane.vNormal.y * v55 >> 16); if ( !v119 ) - pZ = v122 + (v47->pFacePlane.vNormal.z * v55 >> 16); + pZ = v122 + (pODMFace->pFacePlane.vNormal.z * v55 >> 16); } //LABEL_220: v45 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 ) + if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 ) { pParty->floor_face_pid = v45; - v103 = v47->sCogTriggeredID; + v103 = pODMFace->sCogTriggeredID; } v2 = (unsigned __int64)(58500i64 * v2) >> 16; - v127 = (BSPModel *)58500; + pModel = (BSPModel *)58500; v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * v121) >> 16; + v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; ++v126; - v121 = (unsigned __int64)(58500i64 * v121) >> 16; + pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; continue; } - v118 = abs(v128 * v47->pFacePlane.vNormal.y + v121 * v52 + v2 * v47->pFacePlane.vNormal.x) >> 16; + v118 = abs(v128 * pODMFace->pFacePlane.vNormal.y + pParty->uFallSpeed * v52 + v2 * pODMFace->pFacePlane.vNormal.x) >> 16; if ( stru_721530.field_64 >> 3 > v118 ) v118 = stru_721530.field_64 >> 3; - v122 = v47->pFacePlane.vNormal.x; + v122 = pODMFace->pFacePlane.vNormal.x; v122 = (unsigned __int64)(v118 * (signed __int64)(signed int)v122) >> 16; - v127 = (BSPModel *)v47->pFacePlane.vNormal.y; - v127 = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)v127) >> 16); - v129 = v47->pFacePlane.vNormal.z; + pModel = (BSPModel *)pODMFace->pFacePlane.vNormal.y; + pModel = (BSPModel *)((unsigned __int64)(v118 * (signed __int64)(signed int)pModel) >> 16); + v129 = pODMFace->pFacePlane.vNormal.z; v129 = (unsigned __int64)(v118 * (signed __int64)v129) >> 16; - v121 += v129; + pParty->uFallSpeed += v129; v2 += v122; - v128 += (int)v127; + v128 += (int)pModel; if ( v2 * v2 + v128 * v128 >= 400 ) { v45 = stru_721530.uFaceID; - if ( pParty->floor_face_pid != v45 && BYTE3(v47->uAttributes) & 4 ) + if ( pParty->floor_face_pid != v45 && BYTE3(pODMFace->uAttributes) & 4 ) { pParty->floor_face_pid = v45; - v103 = v47->sCogTriggeredID; + v103 = pODMFace->sCogTriggeredID; } v2 = (unsigned __int64)(58500i64 * v2) >> 16; - v127 = (BSPModel *)58500; + pModel = (BSPModel *)58500; v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * v121) >> 16; + v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; ++v126; - v121 = (unsigned __int64)(58500i64 * v121) >> 16; + pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; continue; } v2 = 0; - v121 = 0; + pParty->uFallSpeed = 0; *(float *)&v128 = 0.0; } } //LABEL_234: v2 = (unsigned __int64)(58500i64 * v2) >> 16; - v127 = (BSPModel *)58500; + pModel = (BSPModel *)58500; v128 = (unsigned __int64)(58500i64 * v128) >> 16; - v122 = (unsigned __int64)(58500i64 * v121) >> 16; + v122 = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; ++v126; - v121 = (unsigned __int64)(58500i64 * v121) >> 16; + pParty->uFallSpeed = (unsigned __int64)(58500i64 * pParty->uFallSpeed) >> 16; } while ( v126 < 100 ); if ( bWalkSound && pParty->walk_sound_timer <= 0 ) @@ -3037,59 +2981,36 @@ { if ( v114 && (!bJumping || v101) ) { - if ( !v107 + if ( !is_not_on_bmodel && !(BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20) ) { - - v90 = -1; - v89 = 1; - v88 = 804; - v87 = 64; - pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0); + pAudioPlayer->PlaySound(SOUND_64, 804, 1, -1, 0, 0, 0, 0); } else { - v90 = -1; - v89 = 1; - v88 = 804; - v86 = 1; - //LABEL_255: - v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; - v64 = WorldPosToGridCellX(pParty->vPosition.x); - v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86); - pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0); + //v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; + //v64 = WorldPosToGridCellX(pParty->vPosition.x); + v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 1); + pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0); } } else { if ( v124 && (!bJumping || v101) ) { - if ( v107 + if ( is_not_on_bmodel || BYTE1(pOutdoor->pBModels[pParty->floor_face_pid >> 9].pFaces[(pParty->floor_face_pid >> 3) & 0x3F].uAttributes) & 0x20 ) { - - v90 = -1; - v89 = 1; - v88 = 804; - v86 = 0; - v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; - v64 = WorldPosToGridCellX(pParty->vPosition.x); - v87 = pOutdoor->GetSoundIdByPosition(v64, v63, v86); - pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0); + //v63 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; + //v64 = WorldPosToGridCellX(pParty->vPosition.x); + v87 = pOutdoor->GetSoundIdByPosition(WorldPosToGridCellX(pParty->vPosition.x), WorldPosToGridCellZ(pParty->vPosition.y) - 1, 0); + pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0); } else - { - v90 = -1; - v89 = 1; - v88 = 804; - v87 = 103; - //LABEL_257: - pAudioPlayer->PlaySound((SoundID)v87, v88, v89, v90, 0, 0, 0, 0); - } + pAudioPlayer->PlaySound(SOUND_103, 804, 1, -1, 0, 0, 0, 0); } else { - //LABEL_344: pAudioPlayer->_4AA258(804); pParty->walk_sound_timer = 64; } @@ -3104,21 +3025,21 @@ v65 = WorldPosToGridCellZ(pParty->vPosition.y) - 1; v114 = WorldPosToGridCellX(pX); v66 = WorldPosToGridCellZ(pY) - 1; - v127 = (BSPModel *)(((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1); - v122 = ((unsigned int)~pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1; + pModel = (BSPModel *)((~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v65) >> 1) & 1); + v122 = (~(unsigned int)pOutdoor->ActuallyGetSomeOtherTileInfo(v114, v65) >> 1) & 1; v67 = pOutdoor->ActuallyGetSomeOtherTileInfo(v126, v66); v68 = 0; - v69 = ((unsigned int)~v67 >> 1) & 1; + v69 = (~(unsigned int)v67 >> 1) & 1; if ( v114 == v126 && v66 == v65 && v122 && v69 ) v68 = 1; - if ( !v107 ) + if ( !is_not_on_bmodel ) v68 = 1; if ( v68 ) { v70 = pZ; v71 = pX; v72 = pY; - pParty->uFallSpeed = v121; + //pParty->uFallSpeed = v121; v73 = pZ; pParty->vPosition.x = pX; pParty->vPosition.y = pY; @@ -3140,7 +3061,7 @@ pParty->uFallSpeed = 0; v73 = v105; pParty->vPosition.z = v105; - if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater ) + if ( pParty->uFallStartY - v70 > 512 && !bFeatherFall && v70 <= v105 && !bUnderwater )//Fall to the ground(падение на землю с высоты) { if ( pParty->uFlags & PARTY_FLAGS_1_LANDING ) { @@ -3148,20 +3069,14 @@ } else { - v74 = &pPlayers[1]; - do + for ( uint i = 1; i <= 4; ++i ) { - v110 = (*v74)->GetMaxHealth(); - (*v74)->ReceiveDamage( - (signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, + v110 = pPlayers[i]->GetMaxHealth(); + pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, DMGT_PHISYCAL); - v75 = (*v74)->GetActualEndurance(); - v110 = 20 - (*v74)->GetParameterBonus(v75); - (*v74)->SetRecoveryTime( - (signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); - ++v74; + v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance()); + pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); } - while ( (signed int)v74 <= (signed int)&pPlayers[4] ); v73 = pParty->vPosition.z; } } @@ -3180,14 +3095,14 @@ return; } v76 = pParty->bFlying; - if ( pParty->bFlying || v101 == 0 || bWaterWalk || !v127 ) + if ( pParty->bFlying || v101 == 0 || bWaterWalk || !pModel ) v77 = 1; else v77 = v122 != 0; v114 = 0; if ( !pParty->bFlying && v101 != 0 && !bWaterWalk ) { - if ( v127 ) + if ( pModel ) { v78 = v69 != 0; } @@ -3244,14 +3159,13 @@ pParty->vPosition.z = 8160; } LOWORD(pParty->uFlags) &= 0xFDFBu; - pParty->uFallSpeed = v121; + //pParty->uFallSpeed = v121; pParty->field_6F0 = v113; - if ( v114 ) - { - v83 = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1); - v82 = pParty->vPosition.z; - if ( pParty->vPosition.z <= v83 ) - pParty->uFlags |= 4u; + if ( v114 )//party stand to the water(группа стоит на воде) + { + pTerrainHeight = GetTerrainHeightsAroundParty2(pParty->vPosition.x, pParty->vPosition.y, &v110, 1); + if ( pParty->vPosition.z <= pTerrainHeight + 1 )//положение группы всегда +1 + pParty->uFlags |= PARTY_FLAGS_1_WATER_DAMAGE; } if ( !v103 || (EventProcessor(v103, 0, 1), pParty->vPosition.x == pX) @@ -3263,7 +3177,7 @@ v82 = v105; pParty->uFallSpeed = 0; pParty->vPosition.z = v105; - if ( pParty->uFallStartY - v81 > 512 && !bFeatherFall && v81 <= v105 && !bUnderwater ) + if ( pParty->uFallStartY - v81 > 512 && !bFeatherFall && v81 <= v105 && !bUnderwater )//Fall to the water(падение на воду с высоты) { if ( pParty->uFlags & PARTY_FLAGS_1_LANDING ) { @@ -3271,19 +3185,14 @@ } else { - v84 = &pPlayers[1]; - do + for ( uint i = 1; i <= 4; ++i ) { - v110 = (*v84)->GetMaxHealth(); - (*v84)->ReceiveDamage( - (signed int)((pParty->uFallStartY - v81) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, + v110 = pPlayers[i]->GetMaxHealth(); + pPlayers[i]->ReceiveDamage((signed int)((pParty->uFallStartY - v81) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, DMGT_PHISYCAL); - v85 = (*v84)->GetActualEndurance(); - v110 = 20 - (*v84)->GetParameterBonus(v85); - (*v84)->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); - ++v84; + v110 = 20 - pPlayers[i]->GetParameterBonus(pPlayers[i]->GetActualEndurance()); + pPlayers[i]->SetRecoveryTime((signed __int64)((double)v110 * flt_6BE3A4_debug_recmod1 * 2.133333333333333)); } - while ( (signed int)v84 <= (signed int)&pPlayers[4] ); v82 = pParty->vPosition.z; } } @@ -3545,7 +3454,7 @@ v25 = 0; v16 = word_720B40_intercepts_zs[0] >= v27; if ( v15 <= 0 ) - goto LABEL_29; + return 0; do { if ( v31 >= 2 ) @@ -3580,7 +3489,6 @@ while ( v25 < v15 ); result = 1; if ( v31 != 1 ) -LABEL_29: result = 0; return result; } @@ -3683,7 +3591,7 @@ v21 = 0; v12 = word_7209A0_intercepts_ys_plus_ys[0] >= v24; if ( v11 <= 0 ) - goto LABEL_29; + return 0; do { if ( a4d >= 2 ) @@ -3718,7 +3626,6 @@ while ( v21 < v11 ); result = 1; if ( a4d != 1 ) -LABEL_29: result = 0; return result; } @@ -3854,7 +3761,6 @@ return result; } -// 47730C: using guessed type int __stdcall const_1(int); //----- (004775ED) -------------------------------------------------------- int stru6_stru1_indoor_sw_billboard::_4775ED(float a2) @@ -3899,29 +3805,56 @@ float v39; // [sp+D0h] [bp-8h]@6 int *v40; // [sp+D4h] [bp-4h]@2 - v2 = (char *)&this->field_14[4 * this->field_10 + 20]; + v2 = (char *)&this->field_64[4 * this->uNumVertices]; v38 = 0; - *(int *)v2 = this->field_14[20]; + *(int *)v2 = this->field_64[0]; v2 += 4; - *(int *)v2 = this->field_14[21]; + *(int *)v2 = this->field_64[1]; v2 += 4; - *(int *)v2 = this->field_14[22]; - *((int *)v2 + 1) = this->field_14[23]; - v3 = this->field_10; + *(int *)v2 = this->field_64[2]; + *((int *)v2 + 1) = this->field_64[3]; + v3 = this->uNumVertices; v35 = this; if ( v3 > 0 ) { - v40 = &this->field_14[40]; - v4 = (char *)&this->field_14[23] + 3; + v40 = &this->field_64[20]; + v4 = (char *)&this->field_64[3] + 3; v34 = v3; while ( 1 ) { v5 = v4 - 15; if ( *(float *)(v4 - 15) <= (double)a2 && *(float *)(v4 + 1) <= (double)a2 ) - goto LABEL_11; + { + v4 += 16; + --v34; + if ( !v34 ) + return this->uNumVertices = v38; + continue; + } if ( *(float *)v5 <= (double)a2 ) - break; - if ( *(float *)(v4 + 1) <= (double)a2 ) + { + v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); + v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; + v36 = v6; + v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); + v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); + *(float *)&v37 = (double)v7 * v6; + v8 = *(float *)&v37 + 6.7553994e15; + v9 = (unsigned __int8)*v4; + *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; + v10 = *(float *)&v37 + 6.7553994e15; + v11 = (unsigned __int8)*(v4 - 2); + v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); + v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; + v12 = v39 + 6.7553994e15; + v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); + v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; + v14 = v39 + 6.7553994e15; + v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); + //this = v35; + v5 = (char *)&v30 + 4; + } + else if ( *(float *)(v4 + 1) <= (double)a2 ) { v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); v16 = (unsigned __int8)*v4; @@ -3954,9 +3887,8 @@ v40 += 4; *v25 = *(int *)v26; v25[1] = *(int *)(v26 + 4); - goto LABEL_9; + v5 = (char *)&v30 + 4; } -LABEL_10: v27 = v40; ++v38; *v40 = *(int *)v5; @@ -3968,39 +3900,13 @@ v40 += 4; *v27 = *(int *)v28; v27[1] = *(int *)(v28 + 4); -LABEL_11: v4 += 16; --v34; if ( !v34 ) - goto LABEL_12; + return this->uNumVertices = v38; } - v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); - v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; - v36 = v6; - v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); - v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); - *(float *)&v37 = (double)v7 * v6; - v8 = *(float *)&v37 + 6.7553994e15; - v9 = (unsigned __int8)*v4; - *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; - v10 = *(float *)&v37 + 6.7553994e15; - v11 = (unsigned __int8)*(v4 - 2); - v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); - v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; - v12 = v39 + 6.7553994e15; - v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); - v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; - v14 = v39 + 6.7553994e15; - v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); -LABEL_9: - //this = v35; - v5 = (char *)&v30 + 4; - goto LABEL_10; - } -LABEL_12: - result = v38; - this->field_10 = v38; - return result; + } + return this->uNumVertices = v38; } //----- (00477927) -------------------------------------------------------- @@ -4046,29 +3952,56 @@ float v39; // [sp+D0h] [bp-8h]@6 int *v40; // [sp+D4h] [bp-4h]@2 - v2 = (char *)&this->field_14[4 * this->field_10 + 20]; + v2 = (char *)&this->field_64[4 * this->uNumVertices]; v38 = 0; - *(int *)v2 = this->field_14[20]; + *(int *)v2 = this->field_64[0]; v2 += 4; - *(int *)v2 = this->field_14[21]; + *(int *)v2 = this->field_64[1]; v2 += 4; - *(int *)v2 = this->field_14[22]; - *((int *)v2 + 1) = this->field_14[23]; - v3 = this->field_10; + *(int *)v2 = this->field_64[2]; + *((int *)v2 + 1) = this->field_64[3]; + v3 = this->uNumVertices; v35 = this; if ( v3 > 0 ) { - v40 = &this->field_14[40]; - v4 = (char *)&this->field_14[23] + 3; + v40 = &this->field_64[20]; + v4 = (char *)&this->field_64[3] + 3; v34 = v3; while ( 1 ) { v5 = v4 - 15; if ( *(float *)(v4 - 15) >= (double)a2 && *(float *)(v4 + 1) >= (double)a2 ) - goto LABEL_11; + { + v4 += 16; + --v34; + if ( !v34 ) + return this->uNumVertices = v38; + continue; + } if ( *(float *)v5 >= (double)a2 ) - break; - if ( *(float *)(v4 + 1) >= (double)a2 ) + { + v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); + v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; + v36 = v6; + v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); + v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); + *(float *)&v37 = (double)v7 * v6; + v8 = *(float *)&v37 + 6.7553994e15; + v9 = (unsigned __int8)*v4; + *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; + v10 = *(float *)&v37 + 6.7553994e15; + v11 = (unsigned __int8)*(v4 - 2); + v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); + v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; + v12 = v39 + 6.7553994e15; + v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); + v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; + v14 = v39 + 6.7553994e15; + v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); + //this = v35; + v5 = (char *)&v30 + 4; + } + else if ( *(float *)(v4 + 1) >= (double)a2 ) { v15 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); v16 = (unsigned __int8)*v4; @@ -4101,9 +4034,8 @@ v40 += 4; *v25 = *(int *)v26; v25[1] = *(int *)(v26 + 4); - goto LABEL_9; + v5 = (char *)&v30 + 4; } -LABEL_10: v27 = v40; ++v38; *v40 = *(int *)v5; @@ -4115,39 +4047,13 @@ v40 += 4; *v27 = *(int *)v28; v27[1] = *(int *)(v28 + 4); -LABEL_11: v4 += 16; --v34; if ( !v34 ) - goto LABEL_12; + return this->uNumVertices = v38; } - v6 = (a2 - *(float *)v5) / (*(float *)(v4 + 1) - *(float *)v5); - v7 = (unsigned __int8)v4[16] - (unsigned int)(unsigned __int8)*v4; - v36 = v6; - v31 = (*(float *)(v4 + 5) - *(float *)(v4 - 11)) * v6 + *(float *)(v4 - 11); - v32 = (*(float *)(v4 + 9) - *(float *)(v4 - 7)) * v6 + *(float *)(v4 - 7); - *(float *)&v37 = (double)v7 * v6; - v8 = *(float *)&v37 + 6.7553994e15; - v9 = (unsigned __int8)*v4; - *(float *)&v37 = (double)((unsigned __int8)v4[15] - (unsigned int)(unsigned __int8)*(v4 - 1)) * v36; - v10 = *(float *)&v37 + 6.7553994e15; - v11 = (unsigned __int8)*(v4 - 2); - v37 = LODWORD(v10) + (unsigned __int8)*(v4 - 1); - v39 = (double)((unsigned int)(unsigned __int8)v4[14] - v11) * v36; - v12 = v39 + 6.7553994e15; - v13 = LODWORD(v12) + (unsigned __int8)*(v4 - 2); - v39 = (double)((*(int *)(v4 + 13) & 0xFF) - (*(int *)(v4 - 3) & 0xFFu)) * v36; - v14 = v39 + 6.7553994e15; - v33 = (LODWORD(v14) + (*(int *)(v4 - 3) & 0xFF)) | ((v13 | ((v37 | ((LODWORD(v8) + v9) << 8)) << 8)) << 8); -LABEL_9: - //this = v35; - v5 = (char *)&v30 + 4; - goto LABEL_10; - } -LABEL_12: - result = v38; - this->field_10 = v38; - return result; + } + return this->uNumVertices = v38; } //----- (00477C61) -------------------------------------------------------- @@ -4199,7 +4105,7 @@ if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) { v2 = 0; - if ( this->field_10 > 0 ) + if ( this->uNumVertices > 0 ) { v3 = (int)&this->field_14[1]; do @@ -4252,7 +4158,7 @@ *(float *)(v3 + 80) = v11; v3 += 16; } - while ( v2 < this->field_10 ); + while ( v2 < this->uNumVertices ); } } else @@ -4298,7 +4204,7 @@ } while ( v31 ); } - this->field_10 = 3; + this->uNumVertices = 3; return 1; } @@ -4330,9 +4236,12 @@ v10 = (double)pOutdoorCamera->shading_dist_mist; v3 = 8.0; } - v4 = a1->field_10; + v4 = a1->uNumVertices; if ( v4 <= 0 ) - goto LABEL_16; + { + memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); + return v2->uNumVertices != 0; + } v5 = (char *)&a1->field_14[20]; v6 = v4; do @@ -4353,15 +4262,14 @@ if ( v9 ) { v2->_477927(v10); - return v2->field_10 != 0; + return v2->uNumVertices != 0; } -LABEL_16: memcpy(&v2->field_14[40], &v2->field_14[20], 16 * v4); - return v2->field_10 != 0; + return v2->uNumVertices != 0; } v7 = v3; _4775ED(v7); - return v2->field_10 != 0; + return v2->uNumVertices != 0; } //----- (0047802A) -------------------------------------------------------- @@ -4378,7 +4286,7 @@ v16 = 0; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) { - for(int i = 0; i < a1->field_10; i++) + for(int i = 0; i < a1->uNumVertices; i++) { v6 = (double)pBLVRenderParams->field_40 * 0.000015258789 / a1->field_B4[i*4]; if ( pRenderer->pRenderD3D ) @@ -4409,7 +4317,7 @@ } else { - for(int i = 0; i < a1->field_10; i++) + for(int i = 0; i < a1->uNumVertices; i++) { v12 = (double)pOutdoorCamera->int_fov_rad / a1->field_B4[i*4]; a1->field_B4[i*4+20] = (double)pViewport->uScreenCenterX - v12 * a1->field_B4[i*4+1]; @@ -4446,14 +4354,14 @@ //----- (0047840D) -------------------------------------------------------- char Render::DrawBuildingsD3D() { - IndoorCameraD3D *v0; // eax@3 + //IndoorCameraD3D *v0; // eax@3 char result; // al@3 BSPModel *v2; // ebx@4 int v3; // eax@6 ODMFace *pFace; // esi@6 Vec3_int_ *v5; // ecx@8 int v6; // eax@8 - stru148 *v7; // ebx@8 + struct Polygon *v7; // ebx@8 LightmapBuilder *v8; // eax@8 int v9; // ecx@8 char v10; // zf@8 @@ -4477,9 +4385,9 @@ int v26; // eax@57 int v27; // eax@57 int v28; // eax@58 - int v29; // edx@58 - double v30; // st7@59 - LightmapBuilder *v31; // edi@63 + //int v29; // edx@58 + //double v30; // st7@59 + //LightmapBuilder *v31; // edi@63 signed int v32; // eax@73 int v33; // eax@78 unsigned int v34; // eax@80 @@ -4487,16 +4395,16 @@ int v36; // [sp-14h] [bp-6Ch]@69 RenderVertexSoft *v37; // [sp-10h] [bp-68h]@69 int v38; // [sp-Ch] [bp-64h]@69 - LightmapBuilder *v39; // [sp-8h] [bp-60h]@2 + //LightmapBuilder *v39; // [sp-8h] [bp-60h]@2 int v40; // [sp-4h] [bp-5Ch]@2 - std::string *v41; // [sp+Ch] [bp-4Ch]@2 + //std::string *v41; // [sp+Ch] [bp-4Ch]@2 int v41b; int v42; // [sp+10h] [bp-48h]@6 LightmapBuilder *pLightmapBuilder; // [sp+14h] [bp-44h]@8 float v44; // [sp+18h] [bp-40h]@10 float v45; // [sp+1Ch] [bp-3Ch]@10 ODMFace *v46; // [sp+20h] [bp-38h]@6 - IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3 + //IndoorCameraD3D *v47; // [sp+24h] [bp-34h]@3 unsigned int v48; // [sp+28h] [bp-30h]@8 int v49; // [sp+2Ch] [bp-2Ch]@10 int v50; // [sp+30h] [bp-28h]@34 @@ -4512,12 +4420,11 @@ if ( !pRenderer->pRenderD3D ) { - MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); - } + MessageBoxW(nullptr, L"D3D version of RenderBuildings called in software!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odbuild.cpp:73", 0); + } + unused = 0; - v0 = pGame->pIndoorCameraD3D; a1 = 0; - v47 = v0; result = LOBYTE(pOutdoor->pBModels); v41b = pOutdoor->uNumBModels; if ( (signed int)pOutdoor->uNumBModels > 0 ) @@ -4553,10 +4460,11 @@ v5 = v2->pVertices.pVertices; v6 = pFace->pVertexIDs[0]; v53 = 0; - v7 = &array_77EC08[pOutdoorCamera->numStru148s]; + v7 = &array_77EC08[pOutdoorCamera->uNumPolygons]; //v8 = *(LightmapBuilder **)(v5 + 12 * v6 + 8); v8 = (LightmapBuilder *)v5[v6].z; - *(int *)&v7->flags = 0; + v7->flags = 0; + v7->field_32 = 0; pLightmapBuilder = v8; v9 = pFace->uTextureID; v10 = (BYTE1(pFace->uAttributes) & 0x40) == 0; @@ -4695,7 +4603,7 @@ if ( *(float *)&pLightmapBuilder == v23->vWorldPosition.z ) ++v53; //v47->ViewTransform((RenderVertexSoft *)(v23 - 12), 1u); - v47->ViewTransform(v23, 1u); + pGame->pIndoorCameraD3D->ViewTransform(v23, 1u); if ( v23->vWorldViewPosition.x < 8.0 || (double)pOutdoorCamera->shading_dist_mist < v23->vWorldViewPosition.x ) { if ( v23->vWorldViewPosition.x >= 8.0 ) @@ -4705,7 +4613,7 @@ } else { - v47->Project(v23, 1u, 0); + pGame->pIndoorCameraD3D->Project(v23, 1u, 0); } ++v23;// += 48; --v51; @@ -4735,9 +4643,9 @@ v7->dimming_level = 0; if ( v7->dimming_level > 31 ) v7->dimming_level = 31; - if ( pOutdoorCamera->numStru148s >= 1999 + 5000) + if ( pOutdoorCamera->uNumPolygons >= 1999 + 5000) return result; - ++pOutdoorCamera->numStru148s; + ++pOutdoorCamera->uNumPolygons; ++pOutdoorCamera->field_44; if ( ODMFace::IsBackfaceCulled(pFace, array_73D150, v7) ) { @@ -4750,19 +4658,12 @@ v27 = 8 * (v25 | (v26 << 6)); LOBYTE(v27) = v27 | 6; v7->field_50 = v27; - if ( v18 > 0 ) + + for (v28 = 0; v28 < v18; ++v28) { - v28 = 0; - v29 = v18; - do - { - v30 = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001); memcpy(&array_50AC10[v28], &array_73D150[v28], sizeof(array_50AC10[v28])); - ++v28; - --v29; - array_50A2B0[v28 + 49]._rhw = v30; - } - while ( v29 ); + array_50AC10[v28]._rhw = 1.0 / (array_73D150[v28].vWorldViewPosition.x + 0.0000001); + pFace = v46; } @@ -4778,20 +4679,18 @@ }*/ v40 = (int)pFace; - pLightmapBuilder = pGame->pLightmapBuilder; - v31 = pLightmapBuilder; - pLightmapBuilder->ApplyLights_OutdoorFace(pFace); + pGame->pLightmapBuilder->ApplyLights_OutdoorFace(pFace); pDecalBuilder->ApplyDecals_OutdoorFace(pFace); - v31->std__vector_000004_size = 0; - LOBYTE(v31) = 0; + pGame->pLightmapBuilder->std__vector_000004_size = 0; + + int v31 = 0; if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) { - v31 = (LightmapBuilder *)(v50 ? 3 : v49 != 0 ? 5 : 0); + v31 = v50 ? 3 : v49 != 0 ? 5 : 0; static_RenderBuildingsD3D_stru_73C834.GetFacePlaneAndClassify(pFace, &v56->pVertices); if ( pDecalBuilder->uNumDecals > 0 ) { v40 = -1; - v39 = v31; v38 = 0; v37 = array_50AC10; v36 = uNumVertices; @@ -4806,7 +4705,7 @@ } } if ( stru_F8AD28.uNumLightsApplied > 0 ) - pLightmapBuilder->ApplyLights( + pGame->pLightmapBuilder->ApplyLights( &stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, @@ -4845,7 +4744,7 @@ } goto LABEL_85; } - --pOutdoorCamera->numStru148s; + --pOutdoorCamera->uNumPolygons; --pOutdoorCamera->field_44; LABEL_85: v54 = (Vec3_int_ *)((char *)v54 + 1); @@ -4860,414 +4759,6 @@ } // 73C84C: using guessed type char static_RenderBuildingsD3D_byte_73C84C_init_flag; -//----- (004789DE) -------------------------------------------------------- -BSPModel *Render::DrawBuildingsSW() -{ - BSPModel *result; // eax@1 - BSPModel *v1; // ebx@2 - int v2; // eax@4 - ODMFace *v3; // edi@4 - int v4; // ecx@6 - int v5; // eax@6 - int v6; // ecx@6 - int v7; // ecx@6 - double v8; // st7@7 - char *v9; // ebx@7 - int v10; // eax@9 - double v11; // st7@9 - stru148 *v12; // ebx@19 - double v13; // st7@21 - double v14; // ST4C_8@23 - int v15; // eax@23 - int v16; // eax@27 - int v17; // ecx@29 - unsigned __int8 v18; // sf@29 - unsigned __int8 v19; // of@29 - int v20; // ecx@30 - int v21; // eax@31 - int v22; // eax@31 - int v23; // eax@35 - int v24; // eax@39 - Texture *v25; // eax@43 - int v26; // esi@43 - signed int v27; // ecx@43 - double v28; // st6@43 - double v29; // st5@43 - unsigned short *v30; // edx@44 - int v31; // eax@44 - double v32; // st4@45 - int v33; // ecx@45 - char v34; // zf@45 - BSPVertexBuffer *v35; // eax@50 - unsigned int v36; // eax@53 - signed int v37; // esi@53 - int v38; // eax@54 - signed int v39; // edx@55 - char *v40; // ecx@56 - double v41; // ST1C_8@57 - double v42; // ST24_8@57 - signed int v43; // eax@60 - signed int v44; // esi@60 - int v45; // eax@61 - signed int v46; // edx@62 - char *v47; // ecx@63 - double v48; // ST34_8@64 - double v49; // ST44_8@64 - int v50; // eax@66 - signed int v51; // ecx@67 - char *v52; // edx@68 - double v53; // ST3C_8@69 - double v54; // ST2C_8@69 - float v55; // [sp+44h] [bp-7Ch]@50 - float v56; // [sp+48h] [bp-78h]@50 - float v57; // [sp+4Ch] [bp-74h]@50 - float v58; // [sp+50h] [bp-70h]@64 - int v59; // [sp+54h] [bp-6Ch]@64 - int v60; // [sp+58h] [bp-68h]@69 - float v61; // [sp+5Ch] [bp-64h]@64 - float v62; // [sp+60h] [bp-60h]@69 - float v63; // [sp+64h] [bp-5Ch]@57 - float v64; // [sp+68h] [bp-58h]@57 - int v65; // [sp+6Ch] [bp-54h]@64 - int v66; // [sp+70h] [bp-50h]@1 - int v67; // [sp+74h] [bp-4Ch]@6 - int v68; // [sp+78h] [bp-48h]@4 - int v69; // [sp+7Ch] [bp-44h]@57 - int v70; // [sp+80h] [bp-40h]@69 - int v71; // [sp+84h] [bp-3Ch]@23 - float v72; // [sp+88h] [bp-38h]@69 - int v73; // [sp+8Ch] [bp-34h]@57 - int v74; // [sp+90h] [bp-30h]@6 - int v75; // [sp+94h] [bp-2Ch]@6 - ODMFace *v76; // [sp+98h] [bp-28h]@4 - int v77; // [sp+9Ch] [bp-24h]@6 - BSPModel *v78; // [sp+A0h] [bp-20h]@2 - int v79; // [sp+A4h] [bp-1Ch]@4 - int a1; // [sp+A8h] [bp-18h]@1 - unsigned short *v81; // [sp+ACh] [bp-14h]@7 - int v82; // [sp+B0h] [bp-10h]@6 - int v83; // [sp+B4h] [bp-Ch]@6 - signed int v84; // [sp+B8h] [bp-8h]@7 - int a2; // [sp+BCh] [bp-4h]@1 - - a2 = 0; - a1 = 0; - result = (BSPModel *)pOutdoor->pBModels; - v66 = pOutdoor->uNumBModels; - if ( (signed int)pOutdoor->uNumBModels > 0 ) - { - v1 = pOutdoor->pBModels; - v78 = pOutdoor->pBModels; - while ( 1 ) - { - if ( IsBModelVisible(a1, &a2) ) - { - v1->field_40 |= 1u; - v2 = v1->uNumFaces; - v3 = v1->pFaces; - v74 = 0; - v76 = v3; - v68 = v2; - if ( v2 > 0 ) - break; - } -LABEL_73: - ++a1; - ++v1; - result = (BSPModel *)a1; - v78 = v1; - if ( a1 >= v66 ) - return result; - } - while ( 1 ) - { - if ( !v3->Invisible() ) - { - v4 = 3 * v3->pVertexIDs[0]; - v5 = (int)((char *)v1 - 8); - v67 = (int)((char *)v1 - 8); - v6 = *(_DWORD *)(*(&v1->uNumConvexFaces - 2) + 4 * v4 + 8) + 4; - v82 = 0; - v83 = v6; - v74 = 0; - v7 = v3->uNumVertices; - v75 = 0; - v77 = v7; - if ( v7 > 0 ) - { - v8 = (double)v83; - v9 = (char *)&array_73D150[0].vWorldViewPosition; - v81 = v3->pVertexIDs; - v83 = v7; - *(float *)&v84 = v8; - while ( 1 ) - { - v10 = *(int *)(v5 + 4) + 12 * *(short *)v81; - *((float *)v9 - 3) = (double)*(signed int *)v10 + 4.0; - *((float *)v9 - 2) = (double)*(signed int *)(v10 + 4) + 4.0; - v11 = (double)*(signed int *)(v10 + 8) + 4.0; - *((float *)v9 - 1) = v11; - if ( *(float *)&v84 == v11 ) - ++v82; - pGame->pIndoorCameraD3D->ViewTransform((RenderVertexSoft *)(v9 - 12), 1u); - if ( *(float *)v9 < 8.0 || (double)pOutdoorCamera->shading_dist_mist < *(float *)v9 ) - { - if ( *(float *)v9 >= 8.0 ) - v75 = 1; - else - v74 = 1; - } - else - { - pGame->pIndoorCameraD3D->Project((RenderVertexSoft *)(v9 - 12), 1u, 0); - } - v81 += 2; - v9 += 48; - --v83; - if ( !v83 ) - break; - v5 = v67; - } - v7 = v77; - } - v12 = &array_77EC08[pOutdoorCamera->numStru148s]; - *(int *)&v12->flags = 0; - if ( v82 == v7 ) - *(int *)&v12->flags = 65536; - v12->pODMFace = v3; - v12->uNumVertices = v7; - v12->field_59 = 5; - v84 = v3->pFacePlane.vNormal.x; - v83 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.x) >> 16; - v82 = -pOutdoor->vSunlight.y; - v84 = v3->pFacePlane.vNormal.y; - v82 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.y) >> 16; - v81 = (unsigned __int16 *)-pOutdoor->vSunlight.z; - v84 = v3->pFacePlane.vNormal.z; - v81 = (unsigned __int16 *)((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16); - v84 = v83 + v82 + ((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16); - v13 = (double)v84 * 0.000015258789; - if ( v13 < 0.0 ) - v13 = 0.0; - *(float *)&v84 = v13 * 31.0; - v14 = *(float *)&v84 + 6.7553994e15; - v71 = LODWORD(v14); - v15 = (int)&v12->dimming_level; - v12->dimming_level = 31 - LOBYTE(v14); - if ( (char)(31 - LOBYTE(v14)) < 0 ) - *(char *)v15 = 0; - if ( *(char *)v15 > 31 ) - *(char *)v15 = 31; - v16 = v3->uTextureID; - if ( BYTE1(v3->uAttributes) & 0x40 ) - v16 = pTextureFrameTable->GetFrameTexture(v16, pEventTimer->uTotalGameTimeElapsed); - v17 = v16; - result = (BSPModel *)&pBitmaps_LOD->pTextures[v16]; - v19 = __OFSUB__(pOutdoorCamera->numStru148s, 1999); - v18 = pOutdoorCamera->numStru148s - 1999 < 0; - v12->pTexture = (Texture *)(v17 != -1 ? (int)result : 0); - if ( !(v18 ^ v19) ) - return result; - ++pOutdoorCamera->numStru148s; - ++pOutdoorCamera->field_44; - if ( !ODMFace::IsBackfaceCulled(v3, array_73D150, v12) ) - { -LABEL_71: - --pOutdoorCamera->numStru148s; - --pOutdoorCamera->field_44; - goto LABEL_72; - } - LOBYTE(v20) = v79; - v21 = a1; - v3->bVisible = 1; - v12->uBModelFaceID = v20; - LOWORD(v20) = (unsigned __int8)v20; - v12->uBModelID = v21; - v22 = 8 * (v20 | (v21 << 6)); - LOBYTE(v22) = v22 | 6; - v12->field_50 = v22; - if ( v3->uAttributes & 0x10 ) - *(int *)&v12->flags |= 2u; - if ( BYTE2(v3->uAttributes) & 0x40 ) - HIBYTE(v12->flags) |= 4u; - v23 = v3->uAttributes; - if ( v23 & 4 ) - { - HIBYTE(v12->flags) |= 4u; - } - else - { - if ( v23 & 0x20 ) - HIBYTE(v12->flags) |= 8u; - } - v24 = v3->uAttributes; - if ( BYTE1(v24) & 8 ) - { - HIBYTE(v12->flags) |= 0x20u; - } - else - { - if ( v24 & 0x40 ) - HIBYTE(v12->flags) |= 0x10u; - } - v25 = v12->pTexture; - v26 = v77; - v27 = v25->uTextureWidth; - v84 = v25->uTextureHeight; - v28 = 1.0 / (double)v27; - v29 = 1.0 / (double)v84; - if ( v77 > 0 ) - { - v30 = v3->pTextureVIDs; - v31 = 0; - v83 = v77; - do - { - v32 = 1.0 / (*(float *)(v31 * 48 + 7590236) + 0.0000001); - memcpy(&array_50AC10[v31], &array_73D150[v31], sizeof(array_50AC10[v31])); - ++v31; - array_50A2B0[v31 + 49]._rhw = v32; - v84 = v12->sTextureDeltaU + *(short *)(v30 - 40); - array_50A2B0[v31 + 49].u = (double)v84 * v28; - v33 = v12->sTextureDeltaV + *(short *)v30; - v30 += 2; - v34 = v83-- == 1; - v84 = v33; - array_50A2B0[v31 + 49].v = (double)v33 * v29; - } - while ( !v34 ); - v3 = v76; - v26 = v77; - } - - static stru154 static_sub_004789DE_stru_73C818; // idb - /*static bool __init_flag = false; - if (!__init_flag) - { - __init_flag = true; - - static_sub_004789DE_byte_73C830__init_flag |= 1u; - stru154::stru154(&static_sub_004789DE_stru_73C818); - }*/ - - pGame->pLightmapBuilder->ApplyLights_OutdoorFace((ODMFace *)v3); - if ( stru_F8AD28.uNumLightsApplied <= 0 ) - { - v12->field_108 = 0; - } - else - { - v35 = (BSPVertexBuffer *)(v78 - 2); - v12->field_108 = 1; - - static_sub_004789DE_stru_73C818.GetFacePlaneAndClassify((ODMFace *)v3, v35); - v55 = static_sub_004789DE_stru_73C818.face_plane.vNormal.x; - v56 = static_sub_004789DE_stru_73C818.face_plane.vNormal.y; - v57 = static_sub_004789DE_stru_73C818.face_plane.vNormal.z; - pGame->pLightmapBuilder->_45CA88(&stru_F8AD28, array_50AC10, v26, (Vec3_float_ *)&v55); - } - if ( v74 ) - { - v36 = sr_4250FE(v26); - v37 = v36; - if ( !v36 || (OutdoorCamera::Project(v36), v38 = sr_4254D2(v37), (v12->uNumVertices = v38) == 0) ) - goto LABEL_71; - v12->_48276F_sr(); - v39 = 0; - if ( (signed int)v12->uNumVertices > 0 ) - { - v40 = (char *)&array_508690[0].vWorldViewProjY; - do - { - LODWORD(v64) = *((int *)v40 - 1); - v41 = v64 + 6.7553994e15; - v69 = LODWORD(v41); - dword_50B638[v39] = LODWORD(v41); - LODWORD(v63) = *(int *)v40; - v42 = v63 + 6.7553994e15; - v73 = LODWORD(v42); - v40 += 48; - dword_50B570[v39++] = LODWORD(v42); - } - while ( v39 < (signed int)v12->uNumVertices ); - } - } - else - { - if ( v75 ) - { - v43 = sr_4252E8(v26); - v44 = v43; - if ( !v43 || (OutdoorCamera::Project(v43), v45 = sr_4254D2(v44), (v12->uNumVertices = v45) == 0) ) - goto LABEL_71; - v12->_48276F_sr(); - v46 = 0; - if ( (signed int)v12->uNumVertices > 0 ) - { - v47 = (char *)&array_508690[0].vWorldViewProjY; - do - { - LODWORD(v61) = *((int *)v47 - 1); - v48 = v61 + 6.7553994e15; - v65 = LODWORD(v48); - dword_50B638[v46] = LODWORD(v48); - LODWORD(v58) = *(int *)v47; - v49 = v58 + 6.7553994e15; - v59 = LODWORD(v49); - v47 += 48; - dword_50B570[v46++] = LODWORD(v49); - } - while ( v46 < (signed int)v12->uNumVertices ); - } - } - else - { - v50 = sr_4254D2(v26); - v12->uNumVertices = v50; - if ( !v50 ) - goto LABEL_71; - sr_sub_4829B9( - &array_73D150[v3->uGradientVertex1], - &array_73D150[v3->uGradientVertex2], - &array_73D150[v3->uGradientVertex3], - v12, - 0); - v51 = 0; - if ( (signed int)v12->uNumVertices > 0 ) - { - v52 = (char *)&array_508690[0].vWorldViewProjY; - do - { - LODWORD(v62) = *((int *)v52 - 1); - v53 = v62 + 6.7553994e15; - v60 = LODWORD(v53); - dword_50B638[v51] = LODWORD(v53); - LODWORD(v72) = *(int *)v52; - v54 = v72 + 6.7553994e15; - v70 = LODWORD(v54); - v52 += 48; - dword_50B570[v51++] = LODWORD(v54); - } - while ( v51 < (signed int)v12->uNumVertices ); - } - } - } - sr_sub_486B4E_push_outdoor_edges(array_508690, dword_50B638.data(), dword_50B570.data(), v12); - } -LABEL_72: - ++v79; - v1 = v78; - ++v3; - v76 = v3; - if ( v79 >= v68 ) - goto LABEL_73; - } - } - return result; -} -// 50B570: using guessed type int dword_50B570[]; -// 50B638: using guessed type int dword_50B638[]; -// 73C830: using guessed type char static_sub_004789DE_byte_73C830__init_flag; //----- (00479089) -------------------------------------------------------- bool __fastcall IsBModelVisible(unsigned int uModelID, int *reachable) @@ -5339,9 +4830,8 @@ } //----- (00479295) -------------------------------------------------------- -int stru148::_479295() +int Polygon::_479295() { - stru148 *v1; // edi@1 ODMFace *v2; // esi@1 int v3; // ecx@4 int v4; // eax@4 @@ -5352,18 +4842,15 @@ Vec3_int_ thisa; // [sp+Ch] [bp-10h]@8 int v11; // [sp+18h] [bp-4h]@4 - v1 = this; v2 = this->pODMFace; if ( !v2->pFacePlane.vNormal.z ) { v3 = v2->pFacePlane.vNormal.x; v4 = -v2->pFacePlane.vNormal.y; -LABEL_9: v5 = 0; v11 = 65536; - goto LABEL_5; - } - if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 ) + } + else if ( (v2->pFacePlane.vNormal.x || v2->pFacePlane.vNormal.y) && abs(v2->pFacePlane.vNormal.z) < 59082 ) { thisa.x = -v2->pFacePlane.vNormal.y; thisa.y = v2->pFacePlane.vNormal.x; @@ -5371,113 +4858,25 @@ thisa.Normalize_float(); v4 = thisa.x; v3 = thisa.y; - goto LABEL_9; - } - v3 = 0; - v4 = 65536; - v11 = 0; - v5 = -65536; -LABEL_5: + v5 = 0; + v11 = 65536; + } + else + { + v3 = 0; + v4 = 65536; + v11 = 0; + v5 = -65536; + } v6 = v11; - v1->sTextureDeltaU = v2->sTextureDeltaU; + sTextureDeltaU = v2->sTextureDeltaU; v7 = v3; - v8 = v1->ptr_38; - v1->sTextureDeltaV = v2->sTextureDeltaV; + v8 = ptr_38; + sTextureDeltaV = v2->sTextureDeltaV; v8->_48616B(v4, v7, 0, 0, v5, v6); return 1; } -//----- (00479332) -------------------------------------------------------- -int Render::OnOutdoorRedrawSW() -{ - signed int result; // eax@1 - unsigned int v1; // edi@1 - char *v2; // esi@2 - char v3; // cl@3 - double v4; // st7@4 - float v5; // ST34_4@6 - double v6; // ST24_8@6 - int v7; // eax@6 - unsigned int v8; // eax@11 - signed int v9; // eax@13 - Vec3_float_ *v10; // eax@14 - double v11; // st7@17 - float v12; // ST34_4@19 - double v13; // ST1C_8@19 - float v14; // [sp+4h] [bp-34h]@1 - float v15; // [sp+8h] [bp-30h]@1 - float v16; // [sp+Ch] [bp-2Ch]@1 - - v14 = (double)pOutdoor->vSunlight.x / 65536.0; - result = 0; - v1 = (unsigned int)&array_77EC08[pOutdoorCamera->numStru148s]; - v15 = (double)pOutdoor->vSunlight.y / 65536.0; - v16 = (double)pOutdoor->vSunlight.z / 65536.0; - if ( v1 > (unsigned int)array_77EC08.data() ) - { - v2 = (char *)&array_77EC08[0].pODMFace; - while ( 1 ) - { - v3 = v2[5]; - if ( v3 == 5 ) - break; - if ( v3 == 1 ) - { - v9 = pTerrainNormalIndices[((*((int *)v2 - 9) >> 15) & 1) - + 2 * ((unsigned __int8)v2[9] + ((unsigned __int8)v2[8] << 7))]; - if ( v9 > (signed int)(uNumTerrainNormals - 1) ) - v10 = 0; - else - v10 = &pTerrainNormals[v9]; - if ( v10 ) - { - v11 = -(v16 * v10->z + v15 * v10->y + v14 * v10->x); - if ( v11 < 0.0 ) - v11 = 0.0; - v12 = v11 * 31.0; - v13 = v12 + 6.7553994e15; - v2[4] = 31 - LOBYTE(v13); - } - else - { - v2[4] = 0; - } - if ( v2[4] < 0 ) - v2[4] = 0; - goto LABEL_23; - } -LABEL_24: - v2 += 268; - if ( (unsigned int)(v2 - 84) >= v1 ) - return result; - } - v4 = (double)(signed int)(((unsigned __int64)(**(int **)v2 * (signed __int64)-pOutdoor->vSunlight.x) >> 16) - + ((unsigned __int64)(*(int *)(*(int *)v2 + 4) * (signed __int64)-pOutdoor->vSunlight.y) >> 16) - + ((unsigned __int64)(*(int *)(*(int *)v2 + 8) * (signed __int64)-pOutdoor->vSunlight.z) >> 16)) - * 0.000015258789; - if ( v4 < 0.0 ) - v4 = 0.0; - v5 = v4 * 31.0; - v6 = v5 + 6.7553994e15; - v7 = (int)(v2 + 4); - v2[4] = 31 - LOBYTE(v6); - if ( (char)(31 - LOBYTE(v6)) < 0 ) - *(char *)v7 = 0; - if ( *(char *)v7 > 31 ) - *(char *)v7 = 31; - if ( *(char *)(*(int *)v2 + 29) & 0x40 ) - { - v8 = pTextureFrameTable->GetFrameTexture( - *((short *)v2 - 4), - pEventTimer->uTotalGameTimeElapsed); - *((int *)v2 - 6) = v8 != -1 ? (int)&pBitmaps_LOD->pTextures[v8] : 0; - } -LABEL_23: - result = 1; - goto LABEL_24; - } - return result; -} unsigned short *LoadTgaTexture(const wchar_t *filename, int *out_width = nullptr, int *out_height = nullptr) { @@ -5962,14 +5361,12 @@ int v9; // eax@4 int v10; // ebx@4 signed __int64 v11; // qax@6 - //double v12; // st7@6 int v13; // edi@6 int v14; // ecx@6 - //int v15; // eax@8 int v16; // eax@12 - signed __int64 v17; // qtt@13 + //signed __int64 v17; // qtt@13 signed int pShading; // ecx@13 - stru148 pSky; // [sp+14h] [bp-150h]@1 + struct Polygon pSkyPolygon; // [sp+14h] [bp-150h]@1 float v28; // [sp+12Ch] [bp-38h]@2 int v29; // [sp+130h] [bp-34h]@4 int v30; // [sp+134h] [bp-30h]@1 @@ -5977,11 +5374,11 @@ int v33; // [sp+140h] [bp-24h]@2 int v34; // [sp+144h] [bp-20h]@1 int v35; // [sp+148h] [bp-1Ch]@4 - int v36; // [sp+14Ch] [bp-18h]@2 + int screen_center_x; // [sp+14Ch] [bp-18h]@2 int v37; // [sp+154h] [bp-10h]@8 int v38; // [sp+158h] [bp-Ch]@1 int v39; // [sp+15Ch] [bp-8h]@4 - int v40; // [sp+160h] [bp-4h]@7 + //int v40; // [sp+160h] [bp-4h]@7 extern bool new_sky; if (new_sky) @@ -5991,48 +5388,59 @@ } v30 = ((double)(pOutdoorCamera->int_fov_rad * pIndoorCamera->pos.z) - / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + pViewport->uScreenCenterY); + / ((double)pOutdoorCamera->int_fov_rad + 8192.0) + pViewport->uScreenCenterY);//184 изменяется при подъёме на высоту v38 = pViewport->uScreenCenterY - pOutdoorCamera->int_fov_rad / (pOutdoorCamera->shading_dist_mist * cos(pIndoorCamera->sRotationX * 0.003066406352445483) + 0.0000001000000011686097) * - (pOutdoorCamera->shading_dist_mist * -sin(pIndoorCamera->sRotationX * 0.003066406352445483) - pIndoorCamera->pos.z); - - pSky._48607B(&stru_8019C8); - pSky.ptr_38->sky_48694B(); - pSky.uTileBitmapID = pOutdoor->uSky_TextureID;//номер текстуры - pSky.pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? &pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID] : 0);//текстура неба + (pOutdoorCamera->shading_dist_mist * -sin(pIndoorCamera->sRotationX * 0.003066406352445483) - pIndoorCamera->pos.z);//61 / 184 / 310 изменяется при наклоне камеры + + pSkyPolygon.Create_48607B(&stru_8019C8); + pSkyPolygon.ptr_38->Inverse_sky_48694B();//maybe creating skydome(возможно создание купола неба) + pSkyPolygon.uTileBitmapID = pOutdoor->uSky_TextureID;//номер текстуры + pSkyPolygon.pTexture = (Texture *)(pOutdoor->uSky_TextureID != -1 ? &pBitmaps_LOD->pTextures[pOutdoor->uSky_TextureID] : 0);//текстура неба if (pOutdoor->uSky_TextureID == -1) return; - pSky.dimming_level = 0;//затемнение - pSky.uNumVertices = 4;//количество вершин - - //centering(центруем)--------------------------------------------------------------- - pSky.v_18.x = -stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16);//-3216 - pSky.v_18.y = 0; - pSky.v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16);//-65457 - //--------------------------------------------------------------------------- - - pSky.field_24 = 0x2000000; - - pSky.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed; - pSky.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; + pSkyPolygon.dimming_level = 0;//затемнение + pSkyPolygon.uNumVertices = 4;//количество вершин + + //centering(центруем)--наклон камеры ----------------------------------------// + pSkyPolygon.v_18.x = -stru_5C6E00->Sin(pIndoorCamera->sRotationX + 16);//-3216, вверх: -28020, вниз: 22078 + pSkyPolygon.v_18.y = 0; + pSkyPolygon.v_18.z = -stru_5C6E00->Cos(pIndoorCamera->sRotationX + 16);//-65457, вверх: -59244, вниз: -61705 + //---------------------------------------------------------------------------// + + pSkyPolygon.field_24 = 0x2000000; + + pSkyPolygon.sTextureDeltaU = 224 * pMiscTimer->uTotalGameTimeElapsed;//60928 + pSkyPolygon.sTextureDeltaV = 224 * pMiscTimer->uTotalGameTimeElapsed; //sky position(положение неба)---------------------------------------------- - array_50AC10[0].vWorldViewProjX = pViewport->uViewportTL_X; - array_50AC10[0].vWorldViewProjY = pViewport->uViewportTL_Y; - - array_50AC10[1].vWorldViewProjX = pViewport->uViewportTL_X; - array_50AC10[1].vWorldViewProjY = v38; - - array_50AC10[2].vWorldViewProjX = pViewport->uViewportBR_X; - array_50AC10[2].vWorldViewProjY = v38; - - array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X; - array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y; + // X + // 0._____________________________.3 + // |8,8 468,8 | + // | | + // | | + // Y| | + // | | + // |8,? 468,? | + // 1._____________________________.2 + // + + array_50AC10[0].vWorldViewProjX = pViewport->uViewportTL_X;//8 + array_50AC10[0].vWorldViewProjY = pViewport->uViewportTL_Y;//8 + + array_50AC10[1].vWorldViewProjX = pViewport->uViewportTL_X;//8 + array_50AC10[1].vWorldViewProjY = v38;//61 / 184 / 310 + + array_50AC10[2].vWorldViewProjX = pViewport->uViewportBR_X;//468 + array_50AC10[2].vWorldViewProjY = v38;//61 / 184 / 310 + + array_50AC10[3].vWorldViewProjX = pViewport->uViewportBR_X;//468 + array_50AC10[3].vWorldViewProjY = pViewport->uViewportTL_Y;//8 //-------------------------------------------------------------------------- //pParty->sRotationY / 2048.0f - // move sky(двидение неба)--------------include----------------------------- + // move sky(движение неба)--------------include(вставка)--------------------- float t = (GetTickCount() % 96000) / 96000.0f; array_50AC10[0].u = t - pParty->sRotationY / 1024.0f; array_50AC10[0].v = t - pParty->sRotationX / 512.0f; @@ -6045,25 +5453,31 @@ array_50AC10[3].u = 1 + t - pParty->sRotationY / 1024.0f; array_50AC10[3].v = t - pParty->sRotationX / 512.0f; - //-------------------------------------------------------------------------- + //--------------------------------------------------------------------------// //rotate skydome(вращение купола неба)-------------------------------------- - v36 = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) * 0.5;//центр экрана 230 - v33 = 65536 / (signed int)(v36 / tan(0.6457717418670654) + 0.5);//214 - - for (uint i = 0; i < pSky.uNumVertices; ++i) + // В игре принята своя система измерения углов. Полный угол в 2П радиан соответствует 65536 еденицам. Значению угла 0 соответствует + // направление на восток, значению 16384(0х4000) - на север и т.д.. + + //нахождение вектора взгляда------------------------------------------------ + //положение камеры---------------------------------------------------------- + screen_center_x = (pViewport->uViewportBR_X - pViewport->uViewportTL_X) / 2;//центр экрана по X = 230 + v33 = 65536 / (signed int)(screen_center_x / tan(0.6457717418670654) + 0.5);//360 : (расстояние от экрана до камеры в пикселях) = 214 + //-------------------------------------------------------------------------- + + for (uint i = 0; i < pSkyPolygon.uNumVertices; ++i) { v29 = floorf(array_50AC10[i].vWorldViewProjY + 0.5f);//8 - v39 = (unsigned __int64)(pSky.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;//0 - v8 = v39 + pSky.ptr_38->field_C;//0 - - v39 = (unsigned __int64)(pSky.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;//0 - v36 = v39 + pSky.ptr_38->field_18;//65536 - - v9 = (unsigned __int64)(pSky.v_18.z * v33 * (v30 - v29)) / 65536;//27917 - v10 = pSky.v_18.x + v9;//24701 - v39 = pSky.v_18.x + v9;//24701 - if ( pSky.v_18.x + v9 > 0 ) + v39 = (unsigned __int64)(pSkyPolygon.ptr_38->field_14 * v33 * (v30 - v29)) / 65536;//0 + v8 = v39 + pSkyPolygon.ptr_38->field_C;//0 + + v39 = (unsigned __int64)(pSkyPolygon.ptr_38->field_20 * v33 * (v30 - v29)) / 65536;//0 + screen_center_x = v39 + pSkyPolygon.ptr_38->field_18;//65536 + + v9 = (unsigned __int64)(pSkyPolygon.v_18.z * v33 * (v30 - v29)) / 65536;//27917 + v10 = pSkyPolygon.v_18.x + v9;//24701 + v39 = pSkyPolygon.v_18.x + v9;//24701 + if ( pSkyPolygon.v_18.x + v9 > 0 ) { v10 = 0; v39 = 0; @@ -6072,501 +5486,74 @@ v38 = v10; //v12 = array_50AC10[i].vWorldViewProjY - 1.0; v13 = v33 * (pViewport->uScreenCenterX - (signed __int64)array_50AC10[i].vWorldViewProjX); - v34 = -pSky.field_24; + v34 = -pSkyPolygon.field_24; v32 = (signed __int64)array_50AC10[i].vWorldViewProjY - 1.0; v14 = v33 * (v30 - v32); while ( 1 ) { - v40 = v14; + //v40 = v14; if ( !v10 ) { - v37 = pSky.v_18.z; - v16 = (unsigned __int64)(pSky.v_18.z * (signed __int64)v14) >> 16; + v37 = pSkyPolygon.v_18.z; + v16 = (unsigned __int64)(pSkyPolygon.v_18.z * (signed __int64)v14) >> 16; --v32; v14 += v33; - v10 = pSky.v_18.x + v16; - v39 = pSky.v_18.x + v16; - v38 = pSky.v_18.x + v16; + v10 = pSkyPolygon.v_18.x + v16; + v39 = pSkyPolygon.v_18.x + v16; + v38 = pSkyPolygon.v_18.x + v16; break; } - v37 = abs(v34 >> 14); + v37 = abs(v34 >> 14);//2048 if ( abs(v34 >> 14) <= abs(v10) || v32 <= pViewport->uViewportTL_Y ) { if ( v39 <= 0 ) break; } - v14 = v40; - v37 = pSky.v_18.z; - v16 = (unsigned __int64)(pSky.v_18.z * v14) >> 16; + //v14 = v40; + v37 = pSkyPolygon.v_18.z; + v16 = (unsigned __int64)(pSkyPolygon.v_18.z * v14) >> 16; --v32; v14 += v33; - v10 = pSky.v_18.x + v16; - v39 = pSky.v_18.x + v16; - v38 = pSky.v_18.x + v16; + v10 = pSkyPolygon.v_18.x + v16; + v39 = pSkyPolygon.v_18.x + v16; + v38 = pSkyPolygon.v_18.x + v16; break; } - LODWORD(v17) = v34 << 16; - HIDWORD(v17) = v34 >> 16; - pShading = v17 / v38; + pShading = fixpoint_div(v34, v38); if ( pShading < 0 ) pShading = pOutdoorCamera->shading_dist_mist; - v37 += ((unsigned __int64)(pSky.ptr_38->field_10 * v13) >> 16); - v36 += ((unsigned __int64)(pSky.ptr_38->field_1C * v13) >> 16); + v37 += ((unsigned __int64)(pSkyPolygon.ptr_38->field_10 * v13) >> 16); + screen_center_x += ((unsigned __int64)(pSkyPolygon.ptr_38->field_1C * v13) >> 16); v35 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v37, pShading) / 8; - v36 = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(v36, pShading) / 8; + screen_center_x = 224 * pMiscTimer->uTotalGameTimeElapsed + fixpoint_sub0(screen_center_x, pShading) / 8; //array_50AC10[i].vWorldViewPosition.x = pOutdoorCamera->shading_dist_mist; //array_50AC10[i].vWorldPosition.x = v36 / (pSky.pTexture->uTextureHeight * 65536.0); //array_50AC10[i].vWorldPosition.y = 1.0 / (pOutdoorCamera->shading_dist_mist >> 16); //array_50AC10[i].vWorldPosition.z = v35 / (pSky.pTexture->uTextureWidth * 65536.0); - //array_50AC10[i]._rhw = 1.0f / (v18 >> 16); - //array_50AC10[i].u = (double)v35 / (65536.0 * pSky.pTexture->uTextureWidth); - //array_50AC10[i].v = (double)v36 / (65536.0 * pSky.pTexture->uTextureHeight); + //array_50AC10[i]._rhw = 1.0f / (pShading >> 16); + //array_50AC10[i].u = (double)v35 / (65536.0 * pSkyPolygon.pTexture->uTextureWidth); + //array_50AC10[i].v = (double)screen_center_x / (65536.0 * pSkyPolygon.pTexture->uTextureHeight); //----------------------------------------------------------------------------------------- array_50AC10[i]._rhw = 1.0f; } //if ( i == _this.uNumVertices - 1 ) //{ - pRenderer->DrawSkyPolygon(pSky.uNumVertices, &pSky, pBitmaps_LOD->pHardwareTextures[pSky.uTileBitmapID]); + pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[pSkyPolygon.uTileBitmapID]); array_50AC10[0].vWorldViewProjY = v38; array_50AC10[1].vWorldViewProjY = array_50AC10[1].vWorldViewProjY + 30.0; array_50AC10[2].vWorldViewProjY = array_50AC10[2].vWorldViewProjY + 30.0; array_50AC10[3].vWorldViewProjY = v38; - pRenderer->DrawSkyPolygon(pSky.uNumVertices, &pSky, pBitmaps_LOD->pHardwareTextures[pSky.uTileBitmapID]); + pRenderer->DrawSkyPolygon(pSkyPolygon.uNumVertices, &pSkyPolygon, pBitmaps_LOD->pHardwareTextures[pSkyPolygon.uTileBitmapID]); //} } -//----- (00479A53) -------------------------------------------------------- -void __fastcall _479A53_draw_some_blv_poly(unsigned int uNumVertices, unsigned int uFaceID) -{ - BLVFace *pFace; // esi@1 - unsigned int v3; // edi@1 - PolygonType v4; // al@1 - double v5; // st7@3 - signed __int64 v6; // qax@3 - PolygonType v7; // cl@3 - int v8; // esi@7 - int v9; // eax@7 - unsigned int v10; // eax@7 - double v11; // st6@7 - int v12; // edx@7 - int v13; // eax@7 - char *v14; // esi@8 - void *v15; // ecx@9 - int v16; // eax@9 - int v17; // edi@9 - double v18; // st7@9 - signed int v19; // ebx@9 - void *v20; // ecx@9 - int v21; // ebx@11 - int v22; // eax@14 - signed __int64 v23; // qtt@16 - double v24; // st7@16 - unsigned __int8 v25; // sf@16 - unsigned __int8 v26; // of@16 - Render *v27; // ecx@17 - double v28; // st7@20 - char *v29; // ebx@20 - char *v30; // edx@20 - unsigned __int8 v31; // c0@21 - unsigned __int8 v32; // c3@21 - double v33; // st6@23 - char *v34; // esi@30 - const void *v35; // ecx@31 - int v36; // eax@31 - const void *v37; // edi@31 - signed __int64 v38; // qax@31 - int v39; // ecx@31 - int v40; // ebx@33 - int v41; // eax@36 - signed __int64 v42; // qtt@39 - int v43; // eax@39 - char v44; // zf@39 - double v45; // st7@39 - double v46; // st7@39 - unsigned int v47; // edx@40 - double v48; // st7@41 - RenderVertexSoft *v49; // ebx@41 - void *v50; // edi@43 - double v51; // st7@46 - RenderVertexSoft *v52; // edx@46 - void *v53; // edi@48 - char *v54; // ebx@52 - unsigned int v55; // eax@53 - unsigned int v56; // eax@55 - int v57; // ST10_4@55 - Texture *v58; // eax@55 - signed int v59; // [sp-4h] [bp-178h]@17 - stru148 *v60; // [sp+0h] [bp-174h]@17 - IDirect3DTexture2 *v61; // [sp+4h] [bp-170h]@17 - stru148 v62; // [sp+14h] [bp-160h]@6 - unsigned int v63; // [sp+120h] [bp-54h]@7 - double v64; // [sp+124h] [bp-50h]@7 - unsigned int v65; // [sp+128h] [bp-4Ch]@1 - unsigned int v66; // [sp+12Ch] [bp-48h]@7 - float v67; // [sp+130h] [bp-44h]@7 - __int64 v68; // [sp+134h] [bp-40h]@3 - __int64 v69; // [sp+13Ch] [bp-38h]@3 - int v70; // [sp+144h] [bp-30h]@3 - int X; // [sp+148h] [bp-2Ch]@9 - int v72; // [sp+14Ch] [bp-28h]@7 - float v73; // [sp+150h] [bp-24h]@16 - unsigned int v74; // [sp+154h] [bp-20h]@3 - RenderVertexSoft *v75; // [sp+158h] [bp-1Ch]@3 - float v76; // [sp+15Ch] [bp-18h]@9 - int v77; // [sp+160h] [bp-14h]@9 - int v78; // [sp+164h] [bp-10h]@7 - void *v79; // [sp+168h] [bp-Ch]@9 - float v80; // [sp+16Ch] [bp-8h]@3 - const void *v81; // [sp+170h] [bp-4h]@7 - - __debugbreak(); - - pFace = &pIndoor->pFaces[uFaceID]; - v65 = uFaceID; - v3 = uNumVertices; - v4 = pFace->uPolygonType; - if ( v4 == POLYGON_InBetweenFloorAndWall || v4 == POLYGON_Floor ) - { - if ( (signed int)uNumVertices > 0 ) - { - v54 = (char *)&array_507D30[0].u; - LODWORD(v80) = uNumVertices; - do - { - v69 = (GetTickCount() >> 5) - pBLVRenderParams->vPartyPos.x; - *(float *)v54 = (double)v69 + *(float *)v54; - *(float *)v54 = *(float *)v54 * 0.25; - v55 = GetTickCount(); - v54 += 48; - v44 = LODWORD(v80)-- == 1; - v68 = pBLVRenderParams->vPartyPos.y + (v55 >> 5); - *((float *)v54 - 11) = ((double)v68 + *((float *)v54 - 11)) * 0.25; - } - while ( !v44 ); - uFaceID = v65; - } - v56 = 8 * uFaceID; - LOBYTE(v56) = PID(OBJECT_BModel,uFaceID); - v57 = v56; - v58 = pFace->GetTexture(); - pRenderer->DrawIndoorPolygon(v3, pFace, pBitmaps_LOD->pHardwareTextures[pFace->uBitmapID], v58, v57, -1, 0); - return; - } - HIDWORD(v69) = pIndoorCamera->sRotationX; - HIDWORD(v68) = pIndoorCamera->pos.z; - *(float *)&v74 = (double)pBLVRenderParams->uViewportCenterY; - v70 = (signed __int64)((double)(pBLVRenderParams->field_40 * pBLVRenderParams->vPartyPos.z) - / (((double)pBLVRenderParams->field_40 + 16192.0) - * 65536.0) - + *(float *)&v74); - v5 = (double)pIndoorCamera->sRotationX * 0.0030664064; - *(float *)&v75 = v5; - v80 = cos(v5) * 16192.0; - v6 = (signed __int64)(*(float *)&v74 - - (double)pBLVRenderParams->field_40 - / ((v80 + 0.0000001) - * 65535.0) - * (sin(*(float *)&v75) * -16192.0 - (double)SHIDWORD(v68))); - v7 = pFace->uPolygonType; - if ( v7 == 4 || v7 == 3 ) - v70 = v6; - stru_8019C8._48653D(65536, 0, 0, 0, 65536, 0); - v62._48607B(&stru_8019C8); - v62.uTileBitmapID = pFace->uBitmapID; - v62.pTexture = (Texture *)((signed __int16)v62.uTileBitmapID != -1 ? &pBitmaps_LOD->pTextures[(signed __int16)v62.uTileBitmapID] : 0); - if ( !v62.pTexture ) - return; - v8 = pBLVRenderParams->sPartyRotX; - v62.dimming_level = 0; - v62.uNumVertices = v3; - v9 = stru_5C6E00->Sin(pBLVRenderParams->sPartyRotX + 16); - v62.v_18.y = 0; - v62.v_18.x = -v9; - v62.v_18.z = -stru_5C6E00->Cos(v8 + 16); - v10 = pBLVRenderParams->uViewportZ - pBLVRenderParams->uViewportX; - memcpy(&array_507D30[v3], array_507D30, sizeof(array_507D30[v3])); - LODWORD(v80) = v10; - v62.field_24 = 33554432; - v64 = (double)(signed int)v10 * 0.5; - v72 = 65536 / (signed int)(signed __int64)(v64 / tan(0.6457717418670654) + 0.5); - LODWORD(v80) = v62.pTexture->uTextureWidth; - v11 = 1.0 / (double)SLODWORD(v80); - LODWORD(v80) = v62.pTexture->uTextureHeight; - v12 = v62.pTexture->uWidthMinus1; - v13 = v62.pTexture->uHeightMinus1; - v67 = v11; - v63 = 224 * pMiscTimer->uTotalGameTimeElapsed & v13; - v66 = 224 * pMiscTimer->uTotalGameTimeElapsed & v12; - v78 = 0; - v81 = 0; - *((float *)&v68 + 1) = 1.0 / (double)SLODWORD(v80); - if ( (signed int)v62.uNumVertices <= 0 ) - { -LABEL_17: - v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]; - v27 = pRenderer; - v60 = &v62; - v59 = v62.uNumVertices; - goto LABEL_18; - } - v14 = (char *)&array_507D30[0].vWorldViewProjY; - while ( 2 ) - { - v15 = (void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v14)); - LODWORD(v80) = v62.ptr_38->field_14; - v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16; - v16 = v77 + v62.ptr_38->field_C; - v77 = (int)v15; - v74 = v16; - LODWORD(v80) = v62.ptr_38->field_20; - v77 = (unsigned __int64)(SLODWORD(v80) * (signed __int64)(signed int)v15) >> 16; - v79 = v15; - v75 = (RenderVertexSoft *)(v77 + v62.ptr_38->field_18); - LODWORD(v80) = v62.v_18.z; - v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v15) >> 16); - v17 = v72 * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v14 - 1)); - v18 = *(float *)v14 - 1.0; - v19 = -v62.field_24; - v77 = -v62.field_24; - X = (int)((char *)v79 + v62.v_18.x); - LODWORD(v76) = (signed __int64)v18; - v20 = (void *)(v72 * (v70 - LODWORD(v76))); - while ( 1 ) - { - v79 = v20; - if ( !X ) - goto LABEL_14; - v21 = abs(v19 >> 14); - if ( v21 <= abs(X) ) - break; - if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) - break; - v19 = v77; - v20 = v79; -LABEL_14: - LODWORD(v80) = v62.v_18.z; - v79 = (void *)((unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16); - v22 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v20) >> 16; - --LODWORD(v76); - v20 = (char *)v20 + v72; - X = v22 + v62.v_18.x; - v78 = 1; - } - if ( !v78 ) - { - LODWORD(v23) = v77 << 16; - HIDWORD(v23) = v77 >> 16; - v79 = (void *)(v23 / X); - v77 = v17; - LODWORD(v80) = v62.ptr_38->field_10; - v77 = v17; - LODWORD(v76) = v74 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16); - LODWORD(v80) = v62.ptr_38->field_1C; - v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(SLODWORD(v80) * (signed __int64)v17) >> 16)); - v77 = (unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16; - LODWORD(v73) = (unsigned __int64)((signed int)v75 * v23 / X) >> 16; - v14 += 48; - LODWORD(v80) = v66 + ((signed int)((unsigned __int64)(SLODWORD(v76) * v23 / X) >> 16) >> 4); - v81 = (char *)v81 + 1; - v24 = (double)SLODWORD(v80) * 0.000015259022; - LODWORD(v80) = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v23 / X) >> 16) >> 4); - v26 = __OFSUB__((int)v81, v62.uNumVertices); - v25 = (signed int)((char *)v81 - v62.uNumVertices) < 0; - *((float *)v14 - 10) = v24 * v67; - *((float *)v14 - 9) = (double)SLODWORD(v80) * 0.000015259022 * *((float *)&v68 + 1); - *((float *)v14 - 11) = 65536.0 / (double)(signed int)v79; - if ( !(v25 ^ v26) ) - goto LABEL_17; - continue; - } - break; - } - LODWORD(v73) = 0; - v80 = v76; - if ( (signed int)v62.uNumVertices > 0 ) - { - v28 = (double)SLODWORD(v76); - LODWORD(v76) = (int)(char *)array_50AC10 + 28; - v29 = (char *)&array_50AC10[0].vWorldViewProjX; - v30 = (char *)&array_507D30[1].vWorldViewProjY; - v79 = array_50AC10; - v81 = array_507D30; - v78 = v62.uNumVertices; - do - { - v31 = v28 < *((float *)v30 - 12); - v32 = v28 == *((float *)v30 - 12); - ++LODWORD(v73); - memcpy(v79, v81, 0x30u); - v79 = (char *)v79 + 48; - LODWORD(v76) += 48; - v29 += 48; - if ( v31 | v32 || v28 >= *(float *)v30 ) - { - if ( v28 >= *((float *)v30 - 12) || v28 <= *(float *)v30 ) - goto LABEL_28; - v33 = (*((float *)v30 - 1) - *((float *)v30 - 13)) * v28 / (*(float *)v30 - *((float *)v30 - 12)) - + *((float *)v30 - 1); - } - else - { - v33 = (*((float *)v30 - 13) - *((float *)v30 - 1)) * v28 / (*((float *)v30 - 12) - *(float *)v30) - + *((float *)v30 - 13); - } - *(float *)v29 = v33; - v79 = (char *)v79 + 48; - v29 += 48; - ++LODWORD(v73); - *(unsigned int *)LODWORD(v76) = v28; - LODWORD(v76) += 48; -LABEL_28: - v81 = (char *)v81 + 48; - v30 += 48; - --v78; - } - while ( v78 ); - } - if ( SLODWORD(v73) <= 0 ) - goto LABEL_40; - v34 = (char *)&array_50AC10[0].vWorldViewProjY; - v65 = v77 >> 14; - HIDWORD(v69) = LODWORD(v73); - do - { - v35 = (const void *)(v72 * (v70 - (unsigned __int64)(signed __int64)*(float *)v34)); - v78 = v62.ptr_38->field_14; - v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16); - v36 = (int)((char *)v81 + v62.ptr_38->field_C); - v81 = v35; - v74 = v36; - v78 = v62.ptr_38->field_20; - v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v35) >> 16); - v78 = (int)v35; - v75 = (RenderVertexSoft *)((char *)v81 + v62.ptr_38->field_18); - v81 = (const void *)v62.v_18.z; - v78 = (unsigned __int64)(v62.v_18.z * (signed __int64)(signed int)v35) >> 16; - v37 = (const void *)(v72 - * (pBLVRenderParams->uViewportCenterX - (unsigned __int64)(signed __int64)*((float *)v34 - 1))); - v38 = (signed __int64)(*(float *)v34 - 1.0); - v81 = 0; - LODWORD(v76) = v38; - v39 = v72 * (v70 - v38); - while ( 1 ) - { - v78 = v39; - if ( !X ) - goto LABEL_36; - v40 = abs(X); - if ( abs((signed __int64)v65) <= v40 ) - break; - if ( SLODWORD(v76) <= (signed int)pViewport->uViewportTL_Y ) - break; - v39 = v78; -LABEL_36: - v78 = v62.v_18.z; - v41 = (unsigned __int64)(v62.v_18.z * (signed __int64)v39) >> 16; - --LODWORD(v76); - v39 += v72; - X = v41 + v62.v_18.x; - v81 = (const void *)1; - } - if ( v81 ) - { - v79 = (void *)v62.v_18.z; - v78 = 2 * LODWORD(v76); - v81 = (const void *)((unsigned __int64)(v62.v_18.z - * (signed __int64)(signed int)(signed __int64)(((double)v70 - - ((double)(2 * LODWORD(v76)) - - *(float *)v34)) - * (double)v72)) >> 16); - X = (int)((char *)v81 + v62.v_18.x); - } - LODWORD(v42) = v77 << 16; - HIDWORD(v42) = v77 >> 16; - v79 = (void *)(v42 / X); - v81 = v37; - v78 = v62.ptr_38->field_10; - v81 = (const void *)((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16); - v43 = v74 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16); - v74 = (unsigned int)v37; - LODWORD(v76) = v43; - v78 = v62.ptr_38->field_1C; - v75 = (RenderVertexSoft *)((char *)v75 + ((unsigned __int64)(v78 * (signed __int64)(signed int)v37) >> 16)); - v74 = (unsigned __int64)(v43 * v42 / X) >> 16; - v81 = (const void *)((unsigned __int64)((signed int)v75 * v42 / X) >> 16); - v34 += 48; - v78 = v66 + ((signed int)v74 >> 4); - v44 = HIDWORD(v69)-- == 1; - v45 = (double)v78 * 0.000015259022; - v78 = v63 + ((signed int)((unsigned __int64)((signed int)v75 * v42 / X) >> 16) >> 4); - *((float *)v34 - 10) = v45 * v67; - *((float *)v34 - 9) = (double)v78 * 0.000015259022 * *((float *)&v68 + 1); - v46 = (double)(signed int)v79; - *((float *)v34 - 16) = 0.000015258789 * v46; - *((float *)v34 - 11) = 65536.0 / v46; - } - while ( !v44 ); -LABEL_40: - v47 = 0; - if ( SLODWORD(v73) > 0 ) - { - v48 = (double)SLODWORD(v80); - v75 = array_507D30; - v49 = array_50AC10; - HIDWORD(v69) = LODWORD(v73); - do - { - if ( v48 >= v49->vWorldViewProjY ) - { - v50 = v75; - ++v47; - ++v75; - memcpy(v50, v49, 0x30u); - } - ++v49; - --HIDWORD(v69); - } - while ( HIDWORD(v69) ); - } - v62.uNumVertices = v47; - pRenderer->_4A2ED5(v47, &v62, pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]); - *(float *)&v74 = 0.0; - if ( SLODWORD(v73) > 0 ) - { - v51 = (double)SLODWORD(v80); - v75 = array_507D30; - v52 = array_50AC10; - v80 = v73; - do - { - if ( v51 <= v52->vWorldViewProjY ) - { - v53 = v75; - ++v74; - ++v75; - memcpy(v53, v52, 0x30u); - } - ++v52; - --LODWORD(v80); - } - while ( v80 != 0.0 ); - } - v62.uNumVertices = v74; - v61 = pBitmaps_LOD->pHardwareTextures[(signed __int16)v62.uTileBitmapID]; - v60 = &v62; - v59 = v74; - v27 = pRenderer; -LABEL_18: - v27->_4A2ED5(v59, v60, v61); -} - //----- (0047A384) -------------------------------------------------------- void ODM_LoadAndInitialize(const char *pLevelFilename, OutdoorCamera *thisa) { @@ -6576,8 +5563,8 @@ //int v5; // eax@8 //SpawnPointMM7 *v6; // edx@14 size_t v7; // eax@19 - char *v8; // eax@19 - char *v9; // eax@21 + //char *v8; // eax@19 + //char *v9; // eax@21 char Source[120]; // [sp+Ch] [bp-84h]@19 const char *pFilename; // [sp+84h] [bp-Ch]@1 //unsigned int v12; // [sp+88h] [bp-8h]@12 @@ -6586,7 +5573,7 @@ pFilename = pLevelFilename; thisa->AllocSoftwareDrawBuffers(); pOutdoorCamera->_485F64(); - pWeather->bRenderSnow = 0; + pWeather->bRenderSnow = false; pRenderer->ClearZBuffer(0, 479); thisa = (OutdoorCamera *)1; GetAlertStatus(); @@ -6656,22 +5643,16 @@ pOutdoor->UpdateSunlightVectors(); pOutdoorCamera->int_fov_rad = (signed __int64)pIndoorCamera->flt_1C_fov; pOutdoorCamera->int_fov_rad_inv = (signed __int64)pIndoorCamera->flt_20_inv_1C; - v8 = (char *)&array_77EC08[0].ptr_38; - do - { - *(int *)v8 = (int)&stru_8019C8; - v8 += 268; - } - while ( (signed int)v8 < (signed int)&unk_801A00 ); - v9 = (char *)&array_77EC08[0].prolly_tail; - do - { - *((int *)v9 - 1) = 0; - *(int *)v9 = 0; - *((int *)v9 - 5) = 0; - v9 += 268; - } - while ( (signed int)v9 < (signed int)&unk_801A0C ); + + for (int i = 0; i < 20000; ++i) + { + array_77EC08[i].ptr_38 = &stru_8019C8; + + array_77EC08[i].prolly_head = nullptr; + array_77EC08[i].prolly_tail = nullptr; + array_77EC08[i].ptr_48 = nullptr; + } + MM7Initialization(); } @@ -6713,462 +5694,39 @@ return v1; } -//----- (0047BC6F) -------------------------------------------------------- -unsigned __int16 *__fastcall GetBillboardPalette(RenderBillboard *a1, int a2, signed int a3, int a4) -{ - int v4; // ebx@1 - int v6; // edx@4 - int v7; // ecx@5 - signed int v8; // eax@6 - signed __int64 v9; // qtt@11 - signed int v10; // eax@12 - int v11; // esi@17 - signed __int64 v12; // qtt@19 - double v13; // ST10_8@19 - int v14; // edi@25 - signed int v15; // edx@26 - signed __int64 v16; // qtt@29 - signed int v17; // eax@30 - int v18; // [sp+10h] [bp-8h]@1 - float a3a; // [sp+20h] [bp+8h]@19 - - v4 = a2; - v18 = a2; - if ( pParty->armageddon_timer ) - return PaletteManager::Get(a2); - if ( !pWeather->bNight ) - { - if (day_attrib & DAY_ATTRIB_FOG) - { - v14 = day_fogrange_1 << 16; - if ( a3 >= day_fogrange_1 << 16 ) - { - if ( a3 <= day_fogrange_2 << 16 ) - { - LODWORD(v16) = (a3 - v14) << 16; - HIDWORD(v16) = (a3 - v14) >> 16; - v15 = (unsigned __int64)(27 * v16 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16; - } - else - { - v15 = 27; - } - } - else - { - v15 = 0; - } - v17 = _43F55F_get_billboard_light_level(a1, v15); - if ( v17 > 27 ) - v17 = 27; - if ( !a3 ) - v17 = 27; - v7 = v18; - v6 = v17; - return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); - } - v11 = a4; - if ( a4 < 0 ) - v11 = 0; - LODWORD(v12) = a3 << 16; - HIDWORD(v12) = a3 >> 16; - a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20) - * pOutdoor->fFogDensity; - v13 = a3a + 6.7553994e15; - v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11); - if ( v10 > 27 ) - v10 = 27; - if ( v10 < a4 ) - v10 = a4; - if ( v10 > pOutdoor->max_terrain_dimming_level ) - v10 = pOutdoor->max_terrain_dimming_level; - return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); - } - v6 = 0; - if (pWeather->bNight) - { - v8 = 67108864; - if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) - v8 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower << 26; - if ( a3 <= v8 ) - { - if ( a3 > 0 ) - { - LODWORD(v9) = a3 << 16; - HIDWORD(v9) = a3 >> 16; - v6 = (unsigned __int64)(27 * v9 / v8) >> 16; - } - } - else - { - v6 = 27; - } - v10 = _43F55F_get_billboard_light_level(a1, v6); - if ( v10 > 27 || !a3 ) - v10 = 27; - return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); - } - v7 = 0; - return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); -} -// 6BE030: using guessed type int day_attrib; -// 6BE040: using guessed type int day_fogrange_1; -// 6BE044: using guessed type int day_fogrange_2; - -//----- (0047BEB1) -------------------------------------------------------- -int __fastcall sr_sub_47BEB1(signed int a1, stru148 *a2, int terrain_gamma, int a4, int *a5, int *a6, int a7, int a8) -{ - stru148 *v8; // ebx@1 - signed int v9; // edx@1 - int v10; // eax@5 - signed int v11; // eax@9 - signed int v12; // eax@15 - signed __int64 v13; // qtt@21 - int *v14; // ecx@30 - int *v15; // edi@30 - int v16; // ebx@32 - signed __int64 v17; // qtt@37 - double v18; // ST10_8@37 - double v19; // ST10_8@38 - int v20; // edi@39 - int result; // eax@46 - int *v22; // eax@48 - signed int v23; // edx@51 - signed __int64 v24; // qtt@51 - int v25; // ecx@51 - signed int v26; // [sp+14h] [bp-4h]@1 - float v27; // [sp+28h] [bp+10h]@37 - float v28; // [sp+28h] [bp+10h]@38 - int v29; // [sp+2Ch] [bp+14h]@37 - - v8 = a2; - v9 = a1; - v26 = a1; - if ( pParty->armageddon_timer ) - { - *a5 = -1; - *a6 = -1; - *(char *)a7 = 1; -LABEL_46: - result = a8; - *(char *)a8 = 0; - return result; - } - if ( a1 < 0 ) - { - v26 = v8->field_34 << 16; - v9 = v8->field_34 << 16; - } - v10 = pWeather->bNight; - if ( bUnderwater == 1 ) - v10 = 0; - if ( !v10 ) - { - if ( !(day_attrib & DAY_ATTRIB_FOG) && !bUnderwater ) - { - v14 = a5; - v15 = a6; - if ( !v9 ) - { - *a5 = 31; - *a6 = -1; - } - v16 = v8->dimming_level - terrain_gamma; - if ( v16 >= 0 ) - { - if ( v16 > 27 ) - v16 = 27; - } - else - { - v16 = 0; - } - *a6 = 27; - if ( a4 ) - { - v28 = pOutdoor->fFogDensity * 27.0; - v19 = v28 + 6.7553994e15; - v29 = LODWORD(v19); - } - else - { - LODWORD(v17) = v9 << 16; - HIDWORD(v17) = v9 >> 16; - v27 = (double)(signed int)(((unsigned __int64)(v17 / (pOutdoorCamera->shading_dist_shade << 16) * (31 - *a6)) >> 16) - + *a6) - * pOutdoor->fFogDensity; - v18 = v27 + 6.7553994e15; - v29 = LODWORD(v18); - } - *v14 = v16 + v29; - v20 = *v15; - if ( v16 + v29 > v20 ) - *v14 = v20; - if ( *v14 < v16 ) - *v14 = v16; - if ( *v14 > pOutdoor->max_terrain_dimming_level ) - *v14 = pOutdoor->max_terrain_dimming_level; - goto LABEL_45; - } - if ( v9 >= day_fogrange_1 << 16 ) - { - if ( v9 <= day_fogrange_2 << 16 ) - { - v23 = v9 - (day_fogrange_1 << 16); - LODWORD(v24) = v23 << 16; - HIDWORD(v24) = v23 >> 16; - v25 = (unsigned __int64)(27 * v24 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16; - v22 = a5; - *a5 = v25; - if ( v25 > 27 ) - goto LABEL_54; - v9 = v26; - } - else - { - v22 = a5; - *a5 = 27; - } - } - else - { - v22 = a5; - *a5 = 0; - } - if ( v9 ) - { -LABEL_55: - if ( a4 ) - *v22 = 31; - *a6 = 31; - *(char *)a7 = 0; - goto LABEL_59; - } -LABEL_54: - *v22 = 27; - goto LABEL_55; - } - if ( v10 == 1 ) - { - v11 = 1; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 0x10 ) - { - v12 = 0; - } - else - { - if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) - { - if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime <= 0 ) - v11 = 0; - else - v11 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower; - } - v12 = v11 << 26; - } - if ( a4 ) - goto LABEL_24; - if ( v9 <= v12 ) - { - if ( v9 > 0 ) - { - LODWORD(v13) = v9 << 16; - HIDWORD(v13) = v9 >> 16; - v9 = v26; - *a5 = (unsigned __int64)(27 * v13 / v12) >> 16; - } - if ( *a5 > 27 ) - goto LABEL_24; - } - else - { - *a5 = 27; - } - if ( v9 ) - { -LABEL_25: - if ( v8->field_32 & 4 ) - *a5 = 27; - *a6 = 27; -LABEL_45: - *(char *)a7 = 0; - goto LABEL_46; - } -LABEL_24: - *a5 = 27; - goto LABEL_25; - } - *a5 = -1; - *a6 = -1; - *(char *)a7 = 1; -LABEL_59: - result = a8; - *(char *)a8 = 1; - return result; -} - -//----- (0047C178) -------------------------------------------------------- -void *__fastcall sr_sub_47C178(signed int a1, stru148 *a2, int terrain_gamma, int a4) -{ - stru148 *v4; // esi@1 - void *result; // eax@2 - int v6; // [sp+4h] [bp-8h]@3 - int v7; // [sp+8h] [bp-4h]@3 - - v4 = a2; - if ( pParty->armageddon_timer ) - { - result = PaletteManager::Get(a2->pTexture->palette_id2); - } - else - { - sr_sub_47BEB1(a1, a2, terrain_gamma, a4, &v6, &v7, (int)((char *)&terrain_gamma + 3), (int)((char *)&a4 + 3)); - result = sr_sub_47C1CA(v4, SBYTE3(a4), v6, v7); - } - return result; -} - -//----- (0047C1CA) -------------------------------------------------------- -void *__fastcall sr_sub_47C1CA(stru148 *a1, char a2, int a3, signed int a4) -{ - stru148 *v4; // esi@1 - void *result; // eax@2 - int v6; // edx@3 - int v7; // ecx@8 - int a3a; // [sp+4h] [bp-8h]@1 - char v9; // [sp+8h] [bp-4h]@1 - - v9 = a2; - v4 = a1; - a3a = 1; - if ( pParty->armageddon_timer ) - { - result = PaletteManager::Get(a1->pTexture->palette_id2); - } - else - { - v6 = pGame->_44EC23(a1, &a3a, a4); - if ( v6 == -1 ) - v6 = a3; - if ( v9 == 1 ) - { - if ( v6 != -1 || a4 != -1 ) - { - v7 = v4->pTexture->palette_id2; - } - else - { - v6 = 0; - v7 = 0; - } - result = PaletteManager::Get_Mist_or_Red_LUT(v7, v6, a3a); - } - else - { - result = PaletteManager::Get_Dark_or_Red_LUT(v4->pTexture->palette_id2, v6, a3a); - } - } - return result; -} - -//----- (0047C24C) -------------------------------------------------------- -unsigned __int16 *__fastcall sr_sub_47C24C_get_palette(BLVFace *a1, int a2, int a3, char a4) -{ - int v4; // esi@1 - int v5; // eax@2 - int a3a; // [sp+4h] [bp-4h]@1 - - v4 = a2; - a3a = 1; - if ( a4 ) - { - v5 = pGame->_44ED0A(a1, &a3a, 31); - if ( v5 != -1 ) - a3 = v5; - } - return PaletteManager::Get_Dark_or_Red_LUT(v4, a3, a3a); -} - -//----- (0047C28C) -------------------------------------------------------- -char *__fastcall sr_sub_47C28C_get_palette(stru148 *a1, char a2, signed int a3, signed int a4) -{ - stru148 *v4; // esi@1 - char *result; // eax@2 - signed int v6; // eax@3 - int v7; // ecx@8 - int a2a; // [sp+4h] [bp-8h]@1 - char v9; // [sp+8h] [bp-4h]@1 - - v9 = a2; - v4 = a1; - a2a = 1; - if ( pParty->armageddon_timer ) - { - result = (char *)pPaletteManager->field_199600_palettes[a1->pTexture->palette_id2]; - } - else - { - v6 = pGame->_44EC23(a1, &a2a, a4); - if ( v6 != -1 ) - a3 = v6; - if ( v9 == 1 ) - { - if ( a3 != -1 || a4 != -1 ) - v7 = v4->pTexture->palette_id2; - else - v7 = 0; - result = (char *)PaletteManager::_47C30E_get_palette(v7, a2a); - } - else - { - result = (char *)PaletteManager::_47C33F_get_palette(v4->pTexture->palette_id2, a2a); - } - } - return result; -} -// 4D864C: using guessed type char byte_4D864C; //----- (0047C370) -------------------------------------------------------- -unsigned int __cdecl GetLevelFogColor() +unsigned int GetLevelFogColor() { - unsigned int result; // eax@2 signed __int64 v1; // qax@5 int v2; // eax@6 - if ( bUnderwater ) - { - result = 0xFF258F5C; - } - else - { - if (day_attrib & DAY_ATTRIB_FOG) - { + if (bUnderwater) + return 0xFF258F5C; + + if (day_attrib & DAY_ATTRIB_FOG) + { if ( pWeather->bNight ) // night-time fog { - __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad + __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad v2 = -(pWeather->bNight != 1); - result = (v2 & 0xE0E0E1) - 0xE0E0E1; + return (v2 & 0xE0E0E1) - 0xE0E0E1; } else { v1 = (signed __int64)((1.0 - pOutdoor->fFogDensity) * 200.0 + pOutdoor->fFogDensity * 31.0); - result = v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); + return v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); } - } - else - return 0; - } - return result; + } + + return 0; } -// 6BE030: using guessed type int day_attrib; -// 6BE3C4: using guessed type char bUnderwater; //----- (0047C3D7) -------------------------------------------------------- int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3) { int v3; // ecx@1 double v5; // st7@10 - signed int v6; // esi@10 signed int v7; // ecx@11 double v8; // st6@12 double v9; // st7@15 @@ -7184,44 +5742,73 @@ if ( v3 ) { v5 = (double)day_fogrange_1; - v6 = 216; if ( a3 < v5 ) - goto LABEL_11; - v8 = (double)day_fogrange_2; - if ( a3 > v8 ) - { -LABEL_13: - v7 = v6; - goto LABEL_19; - } - v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0); + { + v7 = 0; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; + } + else + { + v8 = (double)day_fogrange_2; + if ( a3 > v8 ) + { + v7 = 216; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; + } + v7 = (signed __int64)((a3 - v5) / (v8 - v5) * 216.0); + } } else { v9 = (double)day_fogrange_1; - v6 = 216; if ( a3 < v9 ) { -LABEL_11: v7 = 0; - goto LABEL_19; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; } - v10 = (double)day_fogrange_2; - if ( a3 > v10 ) - goto LABEL_13; - v11 = (a3 - v9) * 216.0 / (v10 - v9); - v12 = v11 + 6.7553994e15; - v7 = LODWORD(v12); - } - if ( v7 > v6 ) - { -LABEL_20: - v7 = v6; - goto LABEL_21; - } -LABEL_19: - if ( a3 == 0.0 ) - goto LABEL_20; + else + { + v10 = (double)day_fogrange_2; + if ( a3 > v10 ) + { + v7 = 216; + if ( a3 == 0.0 ) + { + v7 = 216; + } + goto LABEL_21; + } + else + { + v11 = (a3 - v9) * 216.0 / (v10 - v9); + v12 = v11 + 6.7553994e15; + v7 = LODWORD(v12); + } + } + } + if ( v7 > 216 ) + { + v7 = 216; + } + else + { + if ( a3 == 0.0 ) + { + v7 = 216; + } + } LABEL_21: if ( a2 ) v7 = 248; @@ -7369,16 +5956,17 @@ // 6BE3C4: using guessed type char bUnderwater; //----- (0047F44B) -------------------------------------------------------- -unsigned int __stdcall WorldPosToGridCellX(signed int sWorldPosX) +unsigned int WorldPosToGridCellX(int sWorldPosX) { - return (sWorldPosX / 512) + 64; + return (sWorldPosX >> 9) + 64; // sar is in original exe, resulting -880 / 512 = -1 + // and -880 sar 9 = -2 } -// 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); //----- (0047F458) -------------------------------------------------------- -unsigned int __stdcall WorldPosToGridCellZ(signed int sWorldPosZ) +unsigned int WorldPosToGridCellZ(int sWorldPosZ) { - return 64 - (sWorldPosZ / 512); + return 64 - (sWorldPosZ >> 9); // sar is in original exe, resulting -880 / 512 = -1 + // and -880 sar 9 = -2 } //----- (0047F469) -------------------------------------------------------- @@ -7393,59 +5981,9 @@ return (64 - a1) << 9; } -//----- (0047F4D3) -------------------------------------------------------- -void __fastcall sub_47F4D3(int band1, int band2, int band3) -{ - int v3; // edi@1 - //stru220 *v4; // esi@1 - double v5; // ST2C_8@3 - double v6; // st7@3 - //double v7; // [sp+18h] [bp-28h]@3 - //double v8; // [sp+20h] [bp-20h]@2 - int v9; // [sp+34h] [bp-Ch]@1 - int v10; // [sp+38h] [bp-8h]@1 - //signed int band3a; // [sp+48h] [bp+8h]@2 - - v9 = band2 * 512; - pOutdoorCamera->outdoor_grid_band_3 = band3; - v10 = band1 * 512; - v3 = band3 * 512; - pOutdoorCamera->uPickDepth = band3 * 512; - //v4 = stru_76E5C8; // v4: 0 -> 65536 - for (uint i = 0; i < 16384; ++i) - //do - { - auto v4 = stru_76E5C8[i]; - //band3a = 256; - //v8 = (double)(signed int)((char *)v4 + 256 - (int)stru_76E5C8); - for (uint j = 0; j < 128; ++j) // band3a: 0 -> 128 - { - v5 = pow(j * 512 + 256, 2.0); - v6 = pow(i * 4 + 256, 2.0); - //*((float *)&v5 + 1) = sqrt(v6 + v5); - int v7 = floorf(sqrtf(v5 + v6) + 0.5f);//*((float *)&v5 + 1) + 6.7553994e15; - if (v7 >= v10) - { - if (v7 >= v9) - v4.field_0 = ((v7 >= v3) - 1) & 2; - else - v4.field_0 = 2; - } - else - { - v4.field_0 = 1; - } - //band3a += 512; - v4.distance = v7; - //++v4; - } - //while ( band3a < 65792 ); - } - //while ( (signed int)v4 < (signed int)arary_77E5C8 ); -} //----- (004811A3) -------------------------------------------------------- -void stru148::DrawBorderTiles() +void Polygon::DrawBorderTiles() { //__debugbreak(); @@ -7457,63 +5995,17 @@ //pRenderer->DrawTerrainPolygon(uNumVertices, this, pBitmaps_LOD->pHardwareTextures[uTileBitmapID], true, true); } -//----- (00481DB2) -------------------------------------------------------- -char __fastcall sr_sub_481DB2(RenderVertexSoft *a1, signed int a2, stru148 *a3) -{ - int v3; // eax@2 - int v4; // esi@2 - signed int v5; // esi@2 - char *v6; // edi@3 - double v7; // ST14_8@4 - double v8; // ST0C_8@4 - char result; // al@5 - - if ( a2 >= 3 ) - { - v3 = a3->uTileBitmapID; - v4 = a3->uTileBitmapID; - a3->ptr_38 = &stru_8019C8; - a3->pTexture = (Texture *)(v4 != -1 ? (int)&pBitmaps_LOD->pTextures[v3] : 0); - v5 = 0; - if ( (signed int)a3->uNumVertices > 0 ) - { - v6 = (char *)&array_508690[0].vWorldViewProjY; - do - { - v7 = *((float *)v6 - 1) + 6.7553994e15; - dword_50B638[v5] = LODWORD(v7); - v8 = *(float *)v6 + 6.7553994e15; - v6 += 48; - dword_50B570[v5++] = LODWORD(v8); - } - while ( v5 < (signed int)a3->uNumVertices ); - } - result = sr_sub_486B4E_push_outdoor_edges(a1, dword_50B638.data(), dword_50B570.data(), a3); - } - return result; -} -// 50B570: using guessed type int dword_50B570[]; -// 50B638: using guessed type int dword_50B638[]; //----- (00481EB7) -------------------------------------------------------- -void __cdecl ResetStru148s() +void ResetPolygons() { - int v0; // ecx@1 - char *v1; // eax@2 - - v0 = pOutdoorCamera->numStru148s; - if ( pOutdoorCamera->numStru148s > 0 ) - { - v1 = (char *)&array_77EC08[0].prolly_tail; - do - { - *((int *)v1 - 1) = 0; - *(int *)v1 = 0; - *((int *)v1 - 5) = 0; - v1 += 268; - --v0; - } - while ( v0 ); + for (auto i = 0; i < pOutdoorCamera->uNumPolygons; ++i) + { + array_77EC08[i].prolly_head = nullptr; + array_77EC08[i].prolly_tail = nullptr; + + array_77EC08[i].flags = 0; + array_77EC08[i].field_32 = 0; } } @@ -7521,7 +6013,7 @@ void __cdecl sub_481ED9_MessWithOutdoorCamera() { stru_8019C8._48616B(65536, 0, 0, 0, 65536, 0); - pOutdoorCamera->numStru148s = 0; + pOutdoorCamera->uNumPolygons = 0; pOutdoorCamera->uNumEdges = 0; pOutdoorCamera->uNumSpans = 0; pOutdoorCamera->uNumSurfs = 0; @@ -7529,70 +6021,6 @@ pOutdoorCamera->field_44 = 0; } -//----- (00481EFA) -------------------------------------------------------- -bool __fastcall sub_481EFA(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5) -{ - RenderVertexSoft *v5; // esi@1 - RenderVertexSoft *v6; // edx@1 - bool v7; // edi@2 - bool v8; // ecx@5 - bool v9; // esi@8 - bool v10; // eax@11 - double v11; // st7@14 - signed int v12; // esi@15 - signed int v13; // edx@18 - signed int v14; // ecx@21 - signed int v15; // eax@24 - RenderVertexSoft *v17; // [sp+Ch] [bp-8h]@1 - - v5 = a2; - v6 = a1; - v17 = v5; - v7 = a1->vWorldViewPosition.x < 8.0; - v8 = v5->vWorldViewPosition.x < 8.0; - v9 = a3->vWorldViewPosition.x < 8.0; - v10 = a4->vWorldViewPosition.x < 8.0; - return !(v8 & v9 & v10 & v7) - && ((v11 = (double)pOutdoorCamera->shading_dist_mist, v11 > v6->vWorldViewPosition.x) ? (v12 = 0) : (v12 = 1), - v11 > v17->vWorldViewPosition.x ? (v13 = 0) : (v13 = 1), - v11 > a3->vWorldViewPosition.x ? (v14 = 0) : (v14 = 1), - v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1), - !(v13 & v14 & v15 & v12)); -} - -//----- (00481FC9) -------------------------------------------------------- -int __fastcall sub_481FC9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4)//Rotate camera -{ - float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14; - - if (a1->vWorldPosition.y == a2->vWorldPosition.y && a2->vWorldPosition.y == a3->vWorldPosition.y) - a4->flags |= 0x10; - var_c = a1->vWorldViewPosition.x - a2->vWorldViewPosition.x; - var_14 = a1->vWorldViewPosition.y - a2->vWorldViewPosition.y; - arg_0 = a1->vWorldViewPosition.z - a2->vWorldViewPosition.z; - var_10 = a3->vWorldViewPosition.x - a2->vWorldViewPosition.x; - var_8 = a3->vWorldViewPosition.y - a2->vWorldViewPosition.y; - var_4 = a3->vWorldViewPosition.z - a2->vWorldViewPosition.z; - arg_4 = a3->vWorldPosition.y - a2->vWorldPosition.y; - if (((a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.x - a2->vWorldPosition.x) - (a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.y - a2->vWorldPosition.y)) * (pIndoorCamera->pos.y - a2->vWorldPosition.z) + - ((a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.y - a2->vWorldPosition.y) - (a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.z - a2->vWorldPosition.z)) * (pIndoorCamera->pos.x - a2->vWorldPosition.x) + - ((a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.z - a2->vWorldPosition.z) - (a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.x - a2->vWorldPosition.x)) * (pIndoorCamera->pos.z - a2->vWorldPosition.y) < 0) - { - arg_4 = var_4 * var_14 - var_8 * arg_0; - a4->v_18.x = floorf(arg_4 + 0.5f); - arg_4 = var_10 * arg_0 - var_4 * var_c; - a4->v_18.y = floorf(arg_4 + 0.5f); - arg_4 = var_8 * var_c - var_10 * var_14; - a4->v_18.z = floorf(arg_4 + 0.5f); - a4->_486089_normalize_v_18(); - arg_4 = -(a4->v_18.x * a2->vWorldViewPosition.x) - a4->v_18.y * a2->vWorldViewPosition.y - a4->v_18.z * a2->vWorldViewPosition.z; - a4->field_24 = floorf(arg_4 + 0.5f); - return true; - } - else - return false; -} - //----- (004823F4) -------------------------------------------------------- bool IsTerrainSlopeTooHigh(int pos_x, int pos_z) { @@ -7761,2602 +6189,18 @@ return y_x1z1; } -//----- (0048276F) -------------------------------------------------------- -void stru148::_48276F_sr() -{ - unsigned int v1; // ebx@1 - float v2; // edx@2 - double v3; // st7@2 - char *v4; // ecx@3 - float v5; // eax@5 - float v6; // eax@7 - float v7; // eax@9 - float v8; // ecx@13 - int i; // eax@16 - int v10; // edx@20 - RenderVertexSoft *v11; // ecx@22 - RenderVertexSoft *v12; // edx@22 - RenderVertexSoft *v13; // esi@22 - int v14; // ebx@26 - RenderVertexSoft *v15; // ebx@27 - double v16; // st6@28 - double v17; // st5@28 - double v18; // st4@28 - int v19; // [sp+4h] [bp-2Ch]@20 - int v20; // [sp+8h] [bp-28h]@22 - int v21; // [sp+Ch] [bp-24h]@22 - stru148 *v22; // [sp+10h] [bp-20h]@1 - float v23; // [sp+14h] [bp-1Ch]@11 - float v24; // [sp+18h] [bp-18h]@7 - float v25; // [sp+1Ch] [bp-14h]@5 - float v26; // [sp+20h] [bp-10h]@2 - float v27; // [sp+24h] [bp-Ch]@2 - float v28; // [sp+28h] [bp-8h]@2 - float v29; // [sp+2Ch] [bp-4h]@9 - - v1 = this->uNumVertices; - v22 = this; - if ( (signed int)v1 >= 3 ) - { - LODWORD(v2) = 0; - v26 = 10000.0; - v28 = 10000.0; - v3 = -10000.0; - v27 = -10000.0; - if ( (signed int)v1 > 0 ) - { - v4 = (char *)&array_508690[0].vWorldViewProjY; - do - { - if ( *((float *)v4 - 1) < (double)v26 ) - { - LODWORD(v5) = *((int *)v4 - 1); - v25 = v2; - v26 = v5; - } - if ( *((float *)v4 - 1) > (double)v27 ) - { - LODWORD(v6) = *((int *)v4 - 1); - v24 = v2; - v27 = v6; - } - if ( *(float *)v4 < (double)v28 ) - { - LODWORD(v7) = *(int *)v4; - v29 = v2; - v28 = v7; - } - if ( v3 < *(float *)v4 ) - { - v3 = *(float *)v4; - v23 = v2; - } - ++LODWORD(v2); - v4 += 48; - } - while ( SLODWORD(v2) < (signed int)v1 ); - } - v8 = v29; - if ( LODWORD(v29) == LODWORD(v25) || LODWORD(v29) == LODWORD(v24) ) - v8 = v23; - v29 = 0.0; - for ( i = 0; i < (signed int)v1; ++i ) - { - if ( i == LODWORD(v25) || i == LODWORD(v24) || i == LODWORD(v8) ) - { - v10 = LODWORD(v29)++; - *(&v19 + v10) = i; - } - } - v11 = &array_508690[v19]; - v12 = &array_508690[v20]; - v13 = &array_508690[v21]; - if ( LODWORD(v29) != 3 ) - { - v11 = array_508690; - v13 = (RenderVertexSoft *)((char *)array_508690 + 16 * (3 * v1 - 3)); - v12 = &array_508690[1]; - v28 = array_508690[1].vWorldPosition.x - array_508690[0].vWorldPosition.x; - v27 = array_508690[1].vWorldPosition.y - array_508690[0].vWorldPosition.y; - v29 = array_508690[1].vWorldPosition.z - array_508690[0].vWorldPosition.z; - v26 = v13->vWorldPosition.x - array_508690[0].vWorldPosition.x; - v25 = v13->vWorldPosition.y - array_508690[0].vWorldPosition.y; - v24 = v13->vWorldPosition.z - array_508690[0].vWorldPosition.z; - if ( v24 * v27 - v25 * v29 == 0.0 ) - { - if ( v26 * v29 - v24 * v28 == 0.0 ) - { - if ( v25 * v28 - v26 * v27 == 0.0 ) - { - v14 = v1 - 2; - LODWORD(v26) = v14; - if ( v14 >= 2 ) - { - v15 = &array_508690[v14]; - do - { - v16 = v15->vWorldPosition.x - array_508690[0].vWorldPosition.x; - v17 = v15->vWorldPosition.y - array_508690[0].vWorldPosition.y; - v18 = v15->vWorldPosition.z - array_508690[0].vWorldPosition.z; - v13 = v15; - if ( v27 * v18 - v17 * v29 != 0.0 ) - break; - if ( v16 * v29 - v18 * v28 != 0.0 ) - break; - if ( v28 * v17 - v16 * v27 != 0.0 ) - break; - --LODWORD(v26); - --v15; - } - while ( SLODWORD(v26) >= 2 ); - } - } - } - } - } - sr_sub_4829B9(v11, v12, v13, v22, 1); - } -} - -//----- (004829B9) -------------------------------------------------------- -stru148 *__fastcall sr_sub_4829B9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4, int a5) -{ - double v5; // st7@1 - RenderVertexSoft *v6; // esi@1 - double v7; // st6@1 - stru148 *result; // eax@3 - double v9; // st6@3 - double v10; // st5@3 - float v11; // ST0C_4@3 - float v12; // ST04_4@3 - double v13; // st4@3 - float v14; // [sp+8h] [bp-Ch]@1 - float v15; // [sp+10h] [bp-4h]@1 - float v16; // [sp+1Ch] [bp+8h]@1 - float v17; // [sp+1Ch] [bp+8h]@3 - - v5 = a2->vWorldViewProjX - a1->vWorldViewProjX; - v6 = a3; - v16 = a3->vWorldViewProjY - a1->vWorldViewProjY; - v15 = a2->vWorldViewProjY - a1->vWorldViewProjY; - v14 = v6->vWorldViewProjX - a1->vWorldViewProjX; - v7 = v16 * v5 - v14 * v15; - if ( v7 == 0.0 ) - v7 = 0.0000001; - result = a4; - v9 = 1.0 / v7; - v10 = 1.0 / a1->vWorldViewPosition.x; - v11 = 1.0 / a2->vWorldViewPosition.x - v10; - v12 = 1.0 / v6->vWorldViewPosition.x - v10; - v13 = (v11 * v16 - v12 * v15) * v9; - v17 = (v11 * v14 - v12 * v5) * -v9; - a4->field_C = a1->vWorldViewProjX; - a4->field_10 = a1->vWorldViewProjY; - a4->field_0 = v10; - a4->field_8 = v17; - a4->field_4 = v13; - return result; -} - //----- (00482A90) -------------------------------------------------------- signed int __cdecl const_1_0() { return 1; } -//----- (00482A94) -------------------------------------------------------- -int sr_sub_482A94(Span *_this) -{ - stru315 *v1; // ebp@0 - Span *v2; // edi@1 - stru148 *v3; // esi@1 - int v4; // ecx@1 - stru149 *v5; // eax@1 - stru149 *v6; // eax@1 - int v7; // edx@1 - int v8; // eax@1 - int v9; // ecx@1 - int v10; // edx@1 - int v11; // ebx@1 - int v12; // eax@1 - signed int v13; // ebx@1 - int v14; // ebx@2 - signed __int64 v15; // qtt@3 - stru149 *v16; // eax@3 - signed int v17; // ebx@3 - Texture *v18; // eax@14 - unsigned __int16 *v19; // eax@15 - stru149 *v20; // eax@21 - signed int v21; // eax@21 - int v22; // eax@21 - int v23; // ecx@21 - Texture *v24; // edx@21 - signed int v25; // eax@21 - signed int v27; // [sp-4h] [bp-A4h]@8 - int v28; // [sp+Ch] [bp-94h]@1 - int v29; // [sp+10h] [bp-90h]@1 - stru316 a2; // [sp+14h] [bp-8Ch]@21 - stru315 a1; // [sp+3Ch] [bp-64h]@1 - int v32; // [sp+80h] [bp-20h]@1 - int v33; // [sp+84h] [bp-1Ch]@1 - int v34; // [sp+88h] [bp-18h]@1 - int v35; // [sp+8Ch] [bp-14h]@1 - int v36; // [sp+90h] [bp-10h]@1 - int v37; // [sp+94h] [bp-Ch]@1 - int v38; // [sp+98h] [bp-8h]@1 - int X; // [sp+9Ch] [bp-4h]@1 - - v2 = _this; - v3 = _this->pParent; - v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A); - v5 = v3->ptr_38; - v38 = v4; - v37 = v5->field_14; - v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16; - v6 = v3->ptr_38; - v7 = v38 + v6->field_C; - v37 = v6->field_20; - v33 = v7; - v8 = ((unsigned __int64)(v37 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18; - v38 = v4; - v34 = v8; - v37 = v3->v_18.z; - v38 = (unsigned __int64)(v37 * (signed __int64)v4) >> 16; - v9 = v3->v_18.x; - v28 = v3->sTextureDeltaU << 16; - v35 = v3->sTextureDeltaV << 16; - v10 = v2->field_8; - v29 = pOutdoorCamera->camera_rotation_y_int_sine; - v32 = pOutdoorCamera->camera_rotation_y_int_cosine; - a1.field_28 = v2->field_C; - v11 = v3->field_24; - v37 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v10); - v12 = v3->v_18.y; - v13 = -v11; - v36 = v13; - X = ((unsigned __int64)(v37 * (signed __int64)v12) >> 16) + v38 + v9; - if ( !X || (v14 = abs(v13 >> 14), v14 > abs(X)) ) - return 0; - LODWORD(v15) = v36 << 16; - HIDWORD(v15) = v36 >> 16; - v38 = v15 / X; - v16 = v3->ptr_38; - X = v37; - v36 = v16->field_10; - X = v37; - v36 = v33 + ((unsigned __int64)(v36 * (signed __int64)v37) >> 16); - v33 = v3->ptr_38->field_1C; - X = (unsigned __int64)(v33 * (signed __int64)v37) >> 16; - v34 += (unsigned __int64)(v33 * (signed __int64)v37) >> 16; - v17 = 2; - a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; - if ( v38 >= mipmapping_building_mm1 << 16 ) - { - if ( v38 >= mipmapping_building_mm2 << 16 ) - { - if ( v38 >= mipmapping_building_mm3 << 16 ) - { - if ( bUseLoResSprites ) - goto LABEL_12; - v27 = 3; - } - else - { - v27 = 2; - } - v17 = v27; - goto LABEL_12; - } - v17 = 1; - } - else - { - v17 = 0; - } -LABEL_12: - if ( v17 < (signed int)v3->ptr_48 ) - v17 = (signed int)v3->ptr_48; - v18 = v3->pTexture; - if ( v17 ) - { - if ( v17 == 1 ) - { - v19 = (unsigned __int16 *)v18->pLevelOfDetail1; - } - else - { - if ( v17 == 2 ) - v19 = (unsigned __int16 *)v18->pLevelOfDetail2; - else - v19 = (unsigned __int16 *)v18->pLevelOfDetail3; - } - } - else - { - v19 = (unsigned __int16 *)v18->pLevelOfDetail0_prolly_alpha_mask; - } - a1.pTextureLOD = v19; - X = (unsigned __int64)(v36 * (signed __int64)v38) >> 16; - v20 = v3->ptr_38; - X = v38; - a1.field_30 = v28 + ((unsigned __int64)(v36 * (signed __int64)v38) >> 16) - v20->field_24; - X = (unsigned __int64)(v34 * (signed __int64)v38) >> 16; - v21 = X - v3->ptr_38->field_28 - v35; - a1.field_30 >>= v17 + bUseLoResSprites; - a1.field_2C = v21 >> (v17 + bUseLoResSprites); - v35 = pOutdoorCamera->int_fov_rad_inv; - v37 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v38) >> 16) >> (v17 + bUseLoResSprites); - a1.field_4 = (unsigned __int64)(v37 * (signed __int64)v29) >> 16; - X = (unsigned __int64)(v37 * (signed __int64)v32) >> 16; - a1.field_0 = -(signed int)((unsigned __int64)(v37 * (signed __int64)v32) >> 16); - v22 = v2->field_A; - a1.pColorBuffer = &pRenderer->pTargetSurface[v2->field_8 + pRenderer->uTargetSurfacePitch * v2->field_A]; - HIWORD(v23) = HIWORD(v38); - a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v2->field_8 + 640 * v22]; - LOWORD(v23) = 0; - a1.field_24 = v23 | v3->field_50; - v24 = v3->pTexture; - v32 = (signed int)v24->uTextureWidth >> v17; - v25 = (signed int)v24->uTextureHeight >> v17; - a1.field_10 = v17 - v24->uWidthLn2 + 16; - a1.field_C = v32 - 1; - a1.field_8 = (v25 << 16) - 65536; - a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v38, v3, pOutdoorCamera->building_gamme, 1u, 1); - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - sr_sub_485975(&a1, (stru315 *)&a2); - else - sr_sub_4D6FB0(v1); - return 1; -} - -//----- (00482E07) -------------------------------------------------------- -signed int __fastcall sr_sub_482E07(Span *ecx0, unsigned __int16 *pRenderTarget) -{ - stru315 *v2; // ebp@0 - stru148 *v3; // esi@1 - int v4; // edi@1 - int v5; // edi@1 - stru149 *v6; // eax@1 - stru149 *v7; // eax@1 - int v8; // edx@1 - int v9; // eax@1 - int v10; // edi@1 - int v11; // eax@1 - unsigned __int64 v12; // qax@1 - int v13; // eax@1 - signed __int64 v14; // qtt@3 - int v15; // ebx@4 - signed __int64 v16; // qtt@5 - int v17; // eax@5 - unsigned __int16 *v18; // eax@7 - Texture *v19; // eax@8 - Texture *v20; // eax@10 - Texture *v21; // eax@12 - Texture *v22; // eax@14 - int v23; // ecx@17 - Texture *v24; // ebx@17 - signed int v25; // edx@17 - signed int v26; // eax@17 - char v27; // bl@17 - stru149 *v28; // eax@18 - stru149 *v29; // eax@18 - int v30; // eax@18 - int v31; // eax@18 - unsigned int v32; // edx@18 - int v33; // edi@21 - signed __int64 v34; // qtt@22 - signed int v35; // ecx@22 - int v36; // eax@24 - stru149 *v37; // eax@24 - int v38; // edi@24 - int v39; // eax@24 - int v40; // edi@35 - signed __int64 v41; // qtt@36 - int v42; // edx@36 - stru149 *v43; // eax@36 - int v44; // edi@36 - int v45; // eax@36 - Span *v46; // edi@44 - stru149 *v47; // eax@44 - stru149 *v48; // eax@44 - int v49; // eax@44 - int v50; // ecx@44 - unsigned int v51; // edx@44 - int v52; // edi@46 - signed __int64 v53; // qtt@47 - unsigned int v54; // ecx@47 - int v55; // eax@49 - stru149 *v56; // eax@49 - int v57; // edi@49 - int v58; // eax@49 - int v59; // edi@60 - signed __int64 v60; // qtt@61 - int v61; // edx@61 - stru149 *v62; // eax@61 - int v63; // edi@61 - int v64; // eax@61 - int v66; // [sp+Ch] [bp-B8h]@1 - int v67; // [sp+10h] [bp-B4h]@1 - int v68; // [sp+14h] [bp-B0h]@1 - int v69; // [sp+18h] [bp-ACh]@1 - int v70; // [sp+1Ch] [bp-A8h]@5 - int v71; // [sp+20h] [bp-A4h]@1 - signed int v72; // [sp+24h] [bp-A0h]@1 - stru316 a2; // [sp+28h] [bp-9Ch]@18 - int v74; // [sp+50h] [bp-74h]@17 - stru315 a1; // [sp+54h] [bp-70h]@5 - Span *v76; // [sp+98h] [bp-2Ch]@1 - unsigned __int16 *v77; // [sp+9Ch] [bp-28h]@1 - int v78; // [sp+A0h] [bp-24h]@17 - int v79; // [sp+A4h] [bp-20h]@3 - int v80; // [sp+A8h] [bp-1Ch]@3 - int v81; // [sp+ACh] [bp-18h]@1 - int X; // [sp+B0h] [bp-14h]@2 - int v83; // [sp+B4h] [bp-10h]@1 - int v84; // [sp+B8h] [bp-Ch]@1 - int v85; // [sp+BCh] [bp-8h]@1 - int v86; // [sp+C0h] [bp-4h]@18 - - v85 = ecx0->field_C; - v3 = ecx0->pParent; - v4 = pViewport->uScreenCenterY - ecx0->field_A; - v77 = pRenderTarget; - v5 = pOutdoorCamera->int_fov_rad_inv * v4; - v6 = v3->ptr_38; - v76 = ecx0; - v81 = v5; - v83 = v6->field_14; - v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16; - v7 = v3->ptr_38; - v8 = v81 + v7->field_C; - v83 = v7->field_20; - v67 = v8; - v9 = ((unsigned __int64)(v83 * (signed __int64)v5) >> 16) + v3->ptr_38->field_18; - v81 = v5; - v71 = v9; - v83 = v3->v_18.z; - v81 = (unsigned __int64)(v83 * (signed __int64)v5) >> 16; - v68 = v3->sTextureDeltaU << 16; - v69 = v3->sTextureDeltaV << 16; - v72 = -v3->field_24; - v10 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - ecx0->field_8); - v11 = v3->v_18.y; - v66 = v81 + v3->v_18.x; - v83 = v10; - v12 = v10 * (signed __int64)v11; - v81 = v12 >> 16; - v13 = v66 + (v12 >> 16); - v84 = v13; - if ( !v13 - || (X = v72 >> 15, v83 = abs(v13), abs(v72 >> 15) >= v83) - || (LODWORD(v14) = v72 << 16, - HIDWORD(v14) = v72 >> 16, - v79 = v14 / v84, - v80 = v10 - v85 * pOutdoorCamera->int_fov_rad_inv, - v81 = (unsigned __int64)(v80 * (signed __int64)v3->v_18.y) >> 16, - (v84 = v66 + v81) == 0) - || (v15 = abs(v66 + v81), abs(X) >= v15) ) - return 0; - LODWORD(v16) = v72 << 16; - HIDWORD(v16) = v72 >> 16; - v70 = v16 / v84; - v17 = v16 / v84; - a1.field_24 = v79; - if ( v79 >= v17 ) - a1.field_24 = v17; - v18 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; - a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; - v84 = 2; - if ( a1.field_24 >= mipmapping_building_mm1 << 16 ) - { - if ( a1.field_24 >= mipmapping_building_mm2 << 16 ) - { - if ( a1.field_24 >= mipmapping_building_mm3 << 16 ) - { - if ( bUseLoResSprites ) - goto LABEL_16; - v22 = v3->pTexture; - v84 = 3; - v18 = (unsigned __int16 *)v22->pLevelOfDetail3; - } - else - { - v21 = v3->pTexture; - v84 = 2; - v18 = (unsigned __int16 *)v21->pLevelOfDetail2; - } - } - else - { - v20 = v3->pTexture; - v84 = 1; - v18 = (unsigned __int16 *)v20->pLevelOfDetail1; - } - } - else - { - v19 = v3->pTexture; - v84 = 0; - v18 = (unsigned __int16 *)v19->pLevelOfDetail0_prolly_alpha_mask; - } - a1.pTextureLOD = v18; -LABEL_16: - if ( v18 ) - { - v23 = v3->field_5A; - v83 = v3->field_52; - v24 = v3->pTexture; - v74 = v23; - v78 = v85 >> v23; - v25 = v24->uTextureWidth; - v81 = v85 - (v85 >> v23 << v23); - v26 = (signed int)v24->uTextureHeight >> v84; - a1.field_10 = v84 - v24->uWidthLn2 + 16; - v27 = v84 + bUseLoResSprites; - a1.field_8 = (v26 << 16) - 65536; - a1.field_C = (v25 >> v84) - 1; - if ( v79 >= v70 ) - { - v46 = v76; - a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v70, v3, pOutdoorCamera->building_gamme, 0, 1); - v47 = v3->ptr_38; - v79 = v80; - v86 = v47->field_10; - v79 = v80; - v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16); - v86 = v3->ptr_38->field_1C; - v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v80) >> 16); - v79 = (unsigned __int64)(v84 * (signed __int64)v70) >> 16; - v48 = v3->ptr_38; - v79 = v70; - a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v70) >> 16) - v48->field_24; - v79 = (unsigned __int64)(v86 * (signed __int64)v70) >> 16; - v49 = ((unsigned __int64)(v86 * (signed __int64)v70) >> 16) - v3->ptr_38->field_28; - a1.field_30 >>= v27; - a1.field_2C = (v69 + v49) >> v27; - a1.field_14 = dword_80AA20 >> v27; - a1.field_18 = dword_80AA1C >> v27; - a1.field_1C = dword_80AA18 >> v27; - v50 = v46->field_8; - a1.field_20 = dword_80AA14 >> v27; - v51 = v50 + pRenderer->uTargetSurfacePitch * v46->field_A; - a1.pDepthBuffer = (unsigned int *)(&pRenderer->pActiveZBuffer[640 * v46->field_A - 1] + v85 + v50); - a1.pColorBuffer = &v77[v85 - 1] + v51; - v80 += pOutdoorCamera->int_fov_rad_inv << v74; - if ( v78 > 0 ) - { - do - { - v77 = (unsigned __int16 *)v3->v_18.y; - v86 = (unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16; - v84 = v66 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16); - if ( v66 + (unsigned int)((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16) - && (v52 = abs((signed __int64)v66 + ((__int64)((signed int)v77 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v52) ) - { - LODWORD(v53) = v72 << 16; - HIDWORD(v53) = v72 >> 16; - v86 = v53 / v84; - v54 = v53 / v84; - v84 = v53 / v84; - } - else - { - v84 = 0x40000000u; - v54 = 0x40000000u; - } - HIWORD(v55) = HIWORD(v54); - LOWORD(v55) = 0; - a1.field_24 = v3->field_50 | v55; - v77 = (unsigned __int16 *)v3->ptr_38->field_10; - v77 = (unsigned __int16 *)(v67 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16)); - v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16; - v56 = v3->ptr_38; - v57 = ((unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16) - v56->field_24; - v77 = (unsigned __int16 *)v56->field_1C; - v77 = (unsigned __int16 *)(v71 + ((unsigned __int64)((signed int)v77 * (signed __int64)v80) >> 16)); - v86 = (unsigned __int64)((signed int)v77 * (signed __int64)(signed int)v54) >> 16; - v58 = (((v69 + v86 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74; - a1.field_4 = (((v68 + v57) >> v27) - a1.field_30) >> v74; - a1.field_0 = v58; - a1.field_28 = v83; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - { - if ( v3->pODMFace->uPolygonType == 1 ) - sr_sub_485BAE(&a1, &a2); - else - sr_sub_485AFF(&a1, &a2); - } - else - { - if ( v3->pODMFace->uPolygonType == 1 ) - sr_sub_4D71F8(&a1); - else - sr_sub_4D714C(&a1); - } - a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F( - &a2, - v76, - v84, - v3, - pOutdoorCamera->building_gamme, - 0, - 0); - v80 += pOutdoorCamera->int_fov_rad_inv << v74; - --v78; - } - while ( v78 ); - } - if ( !v81 ) - return 1; - v83 = v3->v_18.y; - v86 = (unsigned __int64)(v83 * (signed __int64)v80) >> 16; - v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); - if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) ) - { - v59 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16)); - if ( abs(X) < v59 ) - { - LODWORD(v60) = v72 << 16; - HIDWORD(v60) = v72 >> 16; - v86 = v60 / v84; - HIWORD(v61) = (unsigned int)(v60 / v84) >> 16; - LOWORD(v61) = 0; - a1.field_24 = v61 | v3->field_50; - v83 = v3->ptr_38->field_10; - v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); - v86 = (unsigned __int64)(v83 * v60 / v84) >> 16; - v62 = v3->ptr_38; - v63 = ((unsigned __int64)(v83 * v60 / v84) >> 16) - v62->field_24; - v83 = v62->field_1C; - v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); - v86 = (unsigned __int64)(v83 * v60 / v84) >> 16; - v64 = (((signed int)(v69 + ((unsigned __int64)(v83 * v60 / v84) >> 16) - v3->ptr_38->field_28) >> v27) - - a1.field_2C) >> v74; - a1.field_4 = (((v68 + v63) >> v27) - a1.field_30) >> v74; - a1.field_0 = v64; - a1.field_28 = v81; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - { - if ( v3->pODMFace->uPolygonType == 1 ) - sr_sub_485BAE(&a1, &a2); - else - sr_sub_485AFF(&a1, &a2); - } - else - { - if ( v3->pODMFace->uPolygonType == 1 ) - sr_sub_4D71F8(&a1); - else - sr_sub_4D714C(&a1); - } - return 1; - } - } - } - else - { - a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v76, v79, v3, pOutdoorCamera->building_gamme, 1u, 1); - v28 = v3->ptr_38; - v85 = v10; - v86 = v28->field_10; - v85 = v10; - v84 = v67 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16); - v86 = v3->ptr_38->field_1C; - v86 = v71 + ((unsigned __int64)(v86 * (signed __int64)v10) >> 16); - v85 = (unsigned __int64)(v84 * (signed __int64)v79) >> 16; - v29 = v3->ptr_38; - v85 = v79; - a1.field_30 = v68 + ((unsigned __int64)(v84 * (signed __int64)v79) >> 16) - v29->field_24; - v85 = (unsigned __int64)(v86 * (signed __int64)v79) >> 16; - v30 = ((unsigned __int64)(v86 * (signed __int64)v79) >> 16) - v3->ptr_38->field_28; - a1.field_30 >>= v27; - a1.field_2C = (v69 + v30) >> v27; - a1.field_14 = dword_80AA20 >> v27; - a1.field_18 = dword_80AA1C >> v27; - a1.field_1C = dword_80AA18 >> v27; - a1.field_20 = dword_80AA14 >> v27; - v31 = v76->field_A; - v32 = pRenderer->uTargetSurfacePitch * v76->field_A; - v86 = v76->field_8; - a1.pColorBuffer = &v77[v86 + v32]; - a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v86 + 640 * v31]; - v80 = v10 - (pOutdoorCamera->int_fov_rad_inv << v74); - if ( v78 > 0 ) - { - v86 = v78; - do - { - v78 = v3->v_18.y; - v85 = (unsigned __int64)(v78 * (signed __int64)v80) >> 16; - v84 = v66 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16); - if ( v66 + (unsigned int)((unsigned __int64)(v78 * (signed __int64)v80) >> 16) - && (v33 = abs((signed __int64)v66 + ((__int64)(v78 * (signed __int64)v80) >> 16)), abs((signed __int64)X) < v33) ) - { - LODWORD(v34) = v72 << 16; - HIDWORD(v34) = v72 >> 16; - v85 = v34 / v84; - v35 = v34 / v84; - v84 = v34 / v84; - } - else - { - v84 = 1073741824; - v35 = 1073741824; - } - HIWORD(v36) = HIWORD(v35); - LOWORD(v36) = 0; - a1.field_24 = v3->field_50 | v36; - v78 = v3->ptr_38->field_10; - v78 = v67 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16); - v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16; - v37 = v3->ptr_38; - v38 = ((unsigned __int64)(v78 * (signed __int64)v35) >> 16) - v37->field_24; - v78 = v37->field_1C; - v78 = v71 + ((unsigned __int64)(v78 * (signed __int64)v80) >> 16); - v85 = (unsigned __int64)(v78 * (signed __int64)v35) >> 16; - v39 = (((v69 + v85 - v3->ptr_38->field_28) >> v27) - a1.field_2C) >> v74; - a1.field_4 = (((v68 + v38) >> v27) - a1.field_30) >> v74; - a1.field_0 = v39; - a1.field_28 = v83; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - { - if ( v3->pODMFace->uPolygonType == 1 ) - sr_sub_485A24(&a1, (stru315 *)&a2); - else - sr_sub_485975(&a1, (stru315 *)&a2); - } - else - { - if ( v3->pODMFace->uPolygonType == 1 ) - sr_sub_4D705A(v2); - else - sr_sub_4D6FB0(v2); - } - a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F( - &a2, - v76, - v84, - v3, - pOutdoorCamera->building_gamme, - 1u, - 0); - v80 -= pOutdoorCamera->int_fov_rad_inv << v74; - --v86; - } - while ( v86 ); - } - if ( !v81 ) - return 1; - v83 = v3->v_18.y; - v76 = (Span *)((unsigned __int64)(v83 * (signed __int64)v80) >> 16); - v84 = v66 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); - if ( v66 + (unsigned int)((unsigned __int64)(v83 * (signed __int64)v80) >> 16) ) - { - v40 = abs((signed __int64)v66 + ((__int64)(v83 * (signed __int64)v80) >> 16)); - if ( abs(X) < v40 ) - { - LODWORD(v41) = v72 << 16; - HIDWORD(v41) = v72 >> 16; - X = v41 / v84; - HIWORD(v42) = (unsigned int)(v41 / v84) >> 16; - LOWORD(v42) = 0; - a1.field_24 = v42 | v3->field_50; - v83 = v3->ptr_38->field_10; - v83 = v67 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); - X = (unsigned __int64)(v83 * v41 / v84) >> 16; - v43 = v3->ptr_38; - v44 = ((unsigned __int64)(v83 * v41 / v84) >> 16) - v43->field_24; - v83 = v43->field_1C; - v83 = v71 + ((unsigned __int64)(v83 * (signed __int64)v80) >> 16); - X = (unsigned __int64)(v83 * v41 / v84) >> 16; - v45 = (((signed int)(v69 + ((unsigned __int64)(v83 * v41 / v84) >> 16) - v3->ptr_38->field_28) >> v27) - - a1.field_2C) >> v74; - a1.field_4 = (((v68 + v44) >> v27) - a1.field_30) >> v74; - a1.field_0 = v45; - a1.field_28 = v81; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - { - if ( v3->pODMFace->uPolygonType == 1 ) - sr_sub_485A24(&a1, (stru315 *)&a2); - else - sr_sub_485975(&a1, (stru315 *)&a2); - } - else - { - if ( v3->pODMFace->uPolygonType == 1 ) - sr_sub_4D705A(v2); - else - sr_sub_4D6FB0(v2); - } - return 1; - } - } - } - } - return 0; -} - -//----- (004839BD) -------------------------------------------------------- -signed int __fastcall sr_sub_4839BD(Span *ecx0, unsigned __int16 *pTargetSurface) -{ - stru315 *v2; // ebp@0 - int v3; // eax@1 - int v4; // edi@1 - stru148 *v5; // esi@1 - unsigned int v6; // ebx@1 - int v7; // ecx@1 - int v8; // ebx@1 - int v9; // ecx@1 - int v10; // eax@1 - stru149 *v11; // eax@1 - int v12; // edx@1 - int v13; // eax@1 - int v14; // edi@1 - int v15; // ecx@1 - int v16; // eax@1 - signed int v17; // edi@1 - int v18; // edi@2 - signed __int64 v19; // qtt@3 - int v20; // edi@3 - unsigned __int16 *v21; // eax@3 - Texture *v22; // eax@4 - Texture *v23; // eax@6 - Texture *v24; // eax@8 - Texture *v25; // eax@10 - stru149 *v26; // eax@13 - int v27; // edi@13 - signed int v28; // edx@13 - Texture *v29; // ebx@13 - int v30; // edi@13 - signed int v31; // edx@13 - signed int v32; // eax@13 - signed int v33; // eax@13 - int v34; // ebx@13 - int v35; // eax@15 - int v36; // ebx@15 - int v37; // eax@16 - signed __int64 v38; // qtt@17 - int v39; // ecx@17 - int v40; // eax@19 - stru149 *v41; // eax@21 - int v42; // ebx@21 - int v43; // ebx@21 - int v44; // eax@21 - char v45; // zf@25 - int v46; // eax@28 - int v47; // eax@28 - int v48; // ebx@28 - int v49; // eax@29 - signed __int64 v50; // qtt@30 - int v51; // ecx@30 - int v52; // eax@30 - int v53; // edx@31 - stru149 *v54; // eax@33 - int v55; // ebx@33 - signed int v56; // ebx@33 - int v57; // eax@33 - unsigned __int64 v58; // qax@33 - int v60; // [sp+Ch] [bp-BCh]@1 - Span *v61; // [sp+10h] [bp-B8h]@1 - int v62; // [sp+14h] [bp-B4h]@2 - int v63; // [sp+18h] [bp-B0h]@1 - stru315 a1; // [sp+1Ch] [bp-ACh]@1 - stru316 a2; // [sp+60h] [bp-68h]@13 - int v66; // [sp+88h] [bp-40h]@13 - int v67; // [sp+8Ch] [bp-3Ch]@1 - int v68; // [sp+90h] [bp-38h]@13 - int v69; // [sp+94h] [bp-34h]@3 - int v70; // [sp+98h] [bp-30h]@1 - int v71; // [sp+9Ch] [bp-2Ch]@1 - int v72; // [sp+A0h] [bp-28h]@1 - int v73; // [sp+A4h] [bp-24h]@13 - int v74; // [sp+A8h] [bp-20h]@1 - int v75; // [sp+ACh] [bp-1Ch]@3 - int v76; // [sp+B0h] [bp-18h]@1 - int v77; // [sp+B4h] [bp-14h]@1 - int X; // [sp+B8h] [bp-10h]@1 - int v79; // [sp+BCh] [bp-Ch]@21 - int v80; // [sp+C0h] [bp-8h]@13 - unsigned int v81; // [sp+C4h] [bp-4h]@1 - - v3 = ecx0->field_A; - v4 = ecx0->field_8; - v5 = ecx0->pParent; - v6 = v4 + pRenderer->uTargetSurfacePitch * ecx0->field_A; - v61 = ecx0; - v7 = ecx0->field_C; - a1.pColorBuffer = &pTargetSurface[v6]; - v74 = v7; - a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v4 + 640 * v3]; - v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4); - v9 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v3); - v10 = v5->ptr_38->field_14; - v76 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v4); - v72 = v10; - v81 = (unsigned __int64)(v10 * (signed __int64)v9) >> 16; - v11 = v5->ptr_38; - v12 = v81 + v11->field_C; - v72 = v11->field_20; - v67 = v12; - v13 = ((unsigned __int64)(v72 * (signed __int64)v9) >> 16) + v5->ptr_38->field_18; - v81 = v9; - v70 = v13; - v72 = v5->v_18.z; - v81 = (unsigned __int64)(v72 * (signed __int64)v9) >> 16; - v14 = v5->field_24; - v15 = v81 + v5->v_18.x; - v71 = v5->sTextureDeltaU << 16; - v63 = v5->sTextureDeltaV << 16; - v16 = v5->v_18.y; - v17 = -v14; - v60 = v15; - v77 = v17; - v81 = (unsigned __int64)(v76 * (signed __int64)v16) >> 16; - X = v81 + v15; - if ( !(v81 + v15) || (v62 = v17 >> 14, v18 = abs(v17 >> 14), v18 > abs(X)) ) - return 0; - LODWORD(v19) = v77 << 16; - HIDWORD(v19) = v77 >> 16; - v69 = v19 / X; - v20 = v19 / X; - v21 = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2; - a1.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2; - v75 = 2; - if ( v20 >= mipmapping_building_mm1 << 16 ) - { - if ( v20 >= mipmapping_building_mm2 << 16 ) - { - if ( v20 >= mipmapping_building_mm3 << 16 ) - { - if ( bUseLoResSprites ) - goto LABEL_12; - v25 = v5->pTexture; - v75 = 3; - v21 = (unsigned __int16 *)v25->pLevelOfDetail3; - } - else - { - v24 = v5->pTexture; - v75 = 2; - v21 = (unsigned __int16 *)v24->pLevelOfDetail2; - } - } - else - { - v23 = v5->pTexture; - v75 = 1; - v21 = (unsigned __int16 *)v23->pLevelOfDetail1; - } - } - else - { - v22 = v5->pTexture; - v75 = 0; - v21 = (unsigned __int16 *)v22->pLevelOfDetail0_prolly_alpha_mask; - } - a1.pTextureLOD = v21; -LABEL_12: - if ( v21 ) - { - a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, v20, v5, pOutdoorCamera->building_gamme, 1u, 1); - a1.field_28 = 16; - v66 = v74 >> 4; - v81 = v8; - v26 = v5->ptr_38; - v72 = v74 - 16 * (v74 >> 4); - v76 = v26->field_10; - v81 = v8; - v74 = v67 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16); - v76 = v5->ptr_38->field_1C; - v76 = v70 + ((unsigned __int64)(v76 * (signed __int64)v8) >> 16); - v81 = (unsigned __int64)(v74 * (signed __int64)v20) >> 16; - v27 = ((unsigned __int64)(v74 * (signed __int64)v20) >> 16) - v5->ptr_38->field_24; - v81 = (unsigned __int64)(v76 * (signed __int64)v69) >> 16; - v28 = v63 + ((unsigned __int64)(v76 * (signed __int64)v69) >> 16) - v5->ptr_38->field_28; - v76 = v75 + bUseLoResSprites; - v73 = v8 - 16 * pOutdoorCamera->int_fov_rad_inv; - v29 = v5->pTexture; - v30 = (v71 + v27) >> v76; - v31 = v28 >> v76; - v32 = (signed int)v29->uTextureWidth >> v75; - v74 = (signed __int16)v75; - v68 = v31; - v80 = v32; - v33 = (signed int)v29->uTextureHeight >> v75; - v34 = v75 - v29->uWidthLn2; - a1.field_8 = (v33 << 16) - 65536; - v81 = 2 * pMiscTimer->uTotalGameTimeElapsed; - a1.field_10 = v34 + 16; - a1.field_C = v80 - 1; - if ( v66 > 0 ) - { - v74 = v66; - v66 = 12 - v75; - do - { - v80 = v5->v_18.y; - v35 = (unsigned __int64)(v80 * (signed __int64)v73) >> 16; - v36 = v35 + v60; - X = v35 + v60; - if ( v35 + v60 && (v80 = abs(v62), v37 = abs(v36), v80 <= v37) ) - { - LODWORD(v38) = v77 << 16; - HIDWORD(v38) = v77 >> 16; - v80 = v38 / X; - v39 = v38 / X; - X = v38 / X; - } - else - { - X = 0x40000000u; - v39 = 0x40000000u; - } - HIWORD(v40) = HIWORD(v39); - if ( v39 <= v69 ) - HIWORD(v40) = HIWORD(v69); - LOWORD(v40) = 0; - a1.field_24 = v5->field_50 | v40; - v79 = v5->ptr_38->field_10; - v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16); - v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16; - v41 = v5->ptr_38; - v42 = ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v41->field_24; - v79 = v41->field_1C; - v79 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16); - v80 = (unsigned __int64)(v79 * (signed __int64)v39) >> 16; - v43 = (v71 + v42) >> v76; - v79 = (signed int)(v63 + ((unsigned __int64)(v79 * (signed __int64)v39) >> 16) - v5->ptr_38->field_28) >> v76; - a1.field_4 = (v43 - v30) >> 4; - a1.field_0 = (v79 - v68) >> 4; - a1.field_30 = v30 + 4 * stru_5C6E00->Cos(v81 + (v68 >> v66)); - v44 = stru_5C6E00->Sin(v81 + (v30 >> v66)); - a1.field_2C = v68 + 4 * v44; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - sr_sub_485975(&a1, (stru315 *)&a2); - else - sr_sub_4D6FB0(v2); - a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v61, X, v5, pOutdoorCamera->building_gamme, 1u, 0); - v73 -= 16 * pOutdoorCamera->int_fov_rad_inv; - v45 = v74-- == 1; - a1.field_28 = 16; - v30 = v43; - v68 = v79; - } - while ( !v45 ); - v31 = v79; - } - if ( !v72 ) - return 1; - v66 = 12 - v75; - a1.field_30 = v30 + 4 * stru_5C6E00->Cos(v81 + (v31 >> (12 - v75))); - v46 = stru_5C6E00->Sin(v81 + (v30 >> v66)); - a1.field_2C = v68 + 4 * v46; - v79 = v5->v_18.y; - v80 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16; - v47 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16; - v48 = v47 + v60; - X = v47 + v60; - if ( v47 + v60 ) - { - v79 = abs(v62); - v49 = abs(v48); - if ( v79 <= v49 ) - { - LODWORD(v50) = v77 << 16; - HIDWORD(v50) = v77 >> 16; - v77 = v50 / X; - v51 = v50 / X; - HIWORD(v52) = HIWORD(v69); - if ( v51 <= v69 ) - { - LOWORD(v52) = 0; - a1.field_24 = v52 | v5->field_50; - } - else - { - HIWORD(v53) = HIWORD(v51); - LOWORD(v53) = 0; - a1.field_24 = v53 | v5->field_50; - } - v79 = v5->ptr_38->field_10; - v77 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16; - v79 = v67 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16); - v67 = (unsigned __int64)(v79 * (signed __int64)v51) >> 16; - v54 = v5->ptr_38; - v55 = v67 - v54->field_24; - v79 = v54->field_1C; - v56 = v71 + v55; - v71 = (unsigned __int64)(v79 * (signed __int64)v73) >> 16; - v57 = v70 + ((unsigned __int64)(v79 * (signed __int64)v73) >> 16); - v79 = v57; - v58 = v57 * (signed __int64)v51; - v70 = v58 >> 16; - LODWORD(v58) = (signed int)(v63 + (v58 >> 16) - v5->ptr_38->field_28) >> v76; - a1.field_4 = ((v56 >> v76) - v30) >> 4; - a1.field_0 = ((signed int)v58 - v68) >> 4; - a1.field_28 = v72; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - sr_sub_485975(&a1, (stru315 *)&a2); - else - sr_sub_4D6FB0(v2); - return 1; - } - } - } - return 0; -} -// 4D864C: using guessed type char byte_4D864C; -// 6BE0E4: using guessed type int mipmapping_building_mm1; -// 6BE0E8: using guessed type int mipmapping_building_mm2; -// 6BE0EC: using guessed type int mipmapping_building_mm3; - -//----- (0048408A) -------------------------------------------------------- -signed int sr_sub_48408A_prolly_odm_water_no_waves(Span *_this) -{ - stru315 *v1; // ebp@0 - Span *v2; // edi@1 - stru148 *v3; // esi@1 - int v4; // ecx@1 - stru149 *v5; // eax@1 - stru149 *v6; // eax@1 - int v7; // edx@1 - int v8; // eax@1 - int v9; // ebx@1 - int v10; // eax@1 - int v11; // ecx@1 - int v12; // eax@1 - int v13; // ecx@1 - int v14; // eax@1 - signed int v15; // ecx@1 - int v16; // ebx@1 - signed __int64 v17; // qtt@3 - stru149 *v18; // eax@3 - int v19; // ebx@3 - Texture *v20; // eax@4 - unsigned __int16 *v21; // eax@4 - Texture *v22; // eax@6 - Texture *v23; // ecx@8 - Texture *v24; // eax@10 - stru149 *v25; // eax@12 - signed int v26; // eax@12 - int v27; // ecx@12 - int v28; // eax@14 - int v29; // edx@14 - int v30; // ecx@14 - Texture *v31; // esi@14 - int v32; // edx@14 - int v33; // eax@14 - int v35; // [sp+Ch] [bp-8Ch]@1 - int v36; // [sp+10h] [bp-88h]@1 - stru316 a2; // [sp+14h] [bp-84h]@14 - stru315 a1; // [sp+3Ch] [bp-5Ch]@1 - int v39; // [sp+80h] [bp-18h]@1 - int v40; // [sp+84h] [bp-14h]@1 - int v41; // [sp+88h] [bp-10h]@1 - int v42; // [sp+8Ch] [bp-Ch]@1 - int v43; // [sp+90h] [bp-8h]@2 - int v44; // [sp+94h] [bp-4h]@1 - - v2 = _this; - v3 = _this->pParent; - v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A); - v5 = v3->ptr_38; - v44 = v4; - v42 = v5->field_14; - v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16; - v6 = v3->ptr_38; - v7 = v44 + v6->field_C; - v42 = v6->field_20; - v39 = v7; - v8 = ((unsigned __int64)(v42 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18; - v44 = v4; - v41 = v8; - v42 = v3->v_18.z; - v44 = (unsigned __int64)(v42 * (signed __int64)v4) >> 16; - v9 = v44 + v3->v_18.x; - v35 = stru_5C6E00->Sin(pIndoorCamera->sRotationY); - v10 = stru_5C6E00->Cos(pIndoorCamera->sRotationY); - v11 = v2->field_8; - v36 = v10; - a1.field_28 = v2->field_C; - v12 = pViewport->uScreenCenterX - v11; - v13 = v3->field_24; - v42 = pOutdoorCamera->int_fov_rad_inv * v12; - v14 = v3->v_18.y; - v15 = -v13; - v40 = v15; - v16 = ((unsigned __int64)(v42 * (signed __int64)v14) >> 16) + v9; - v44 = v16; - if ( !v16 || (v43 = abs(v15 >> 14), v43 > abs(v16)) ) - return 0; - LODWORD(v17) = v40 << 16; - HIDWORD(v17) = v40 >> 16; - v43 = v17 / v44; - v18 = v3->ptr_38; - v44 = v42; - v40 = v18->field_10; - v44 = v42; - v40 = v39 + ((unsigned __int64)(v40 * (signed __int64)v42) >> 16); - v39 = v3->ptr_38->field_1C; - v44 = (unsigned __int64)(v39 * (signed __int64)v42) >> 16; - v19 = v43; - v41 += (unsigned __int64)(v39 * (signed __int64)v42) >> 16; - a1.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; - v44 = 2; - if ( v43 < mipmapping_terrain_mm1 << 16 ) - { - v20 = v3->pTexture; - v44 = 0; - v21 = (unsigned __int16 *)v20->pLevelOfDetail0_prolly_alpha_mask; -LABEL_11: - a1.pTextureLOD = v21; - goto LABEL_12; - } - if ( v43 < mipmapping_terrain_mm2 << 16 ) - { - v22 = v3->pTexture; - v44 = 1; - v21 = (unsigned __int16 *)v22->pLevelOfDetail1; - goto LABEL_11; - } - if ( v43 >= mipmapping_terrain_mm3 << 16 ) - { - if ( !bUseLoResSprites ) - { - v24 = v3->pTexture; - v44 = 3; - v21 = (unsigned __int16 *)v24->pLevelOfDetail3; - goto LABEL_11; - } - } - else - { - v23 = v3->pTexture; - v44 = 2; - a1.pTextureLOD = (unsigned __int16 *)v23->pLevelOfDetail2; - } -LABEL_12: - v43 = (unsigned __int64)(v40 * (signed __int64)v43) >> 16; - v25 = v3->ptr_38; - v43 = v19; - a1.field_30 = ((unsigned __int64)(v40 * (signed __int64)v19) >> 16) - v25->field_24; - v43 = (unsigned __int64)(v41 * (signed __int64)v19) >> 16; - v26 = ((unsigned __int64)(v41 * (signed __int64)v19) >> 16) - v3->ptr_38->field_28; - v27 = bUseLoResSprites + v44 + 2; - a1.field_30 >>= v27; - v41 = bUseLoResSprites + v44 + 2; - a1.field_2C = v26 >> v27; - if ( byte_80AA10 ) - { - a1.field_14 = dword_80AA20 >> v27; - a1.field_18 = dword_80AA1C >> v27; - a1.field_1C = dword_80AA18 >> v27; - a1.field_20 = dword_80AA14 >> v27; - } - v41 = pOutdoorCamera->int_fov_rad_inv; - v42 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v19) >> 16) >> v27; - a1.field_4 = (unsigned __int64)(v42 * (signed __int64)v35) >> 16; - v43 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16; - a1.field_0 = (unsigned __int64)(v42 * (signed __int64)v36) >> 16; - a1.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v2, v19, v3, pOutdoorCamera->terrain_gamma, 1u, 1); - LOWORD(v19) = 0; - v28 = v2->field_A; - v29 = v2->field_A; - a1.field_24 = v19; - v30 = v2->field_8; - a1.pColorBuffer = &pRenderer->pTargetSurface[v30 + pRenderer->uTargetSurfacePitch * v29]; - a1.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v30 + 640 * v28]; - v31 = v3->pTexture; - v32 = ((signed int)v31->uTextureWidth >> v44) - 1; - v33 = ((signed int)v31->uTextureHeight >> v44 << 16) - 65536; - a1.field_10 = v44 - v31->uWidthLn2 + 16; - a1.field_C = v32; - a1.field_8 = v33; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - { - if ( byte_80AA10 ) - sr_sub_485A24(&a1, (stru315 *)&a2); - else - sr_sub_485975(&a1, (stru315 *)&a2); - } - else - { - if ( byte_80AA10 ) - sr_sub_4D705A(v1); - else - sr_sub_4D6FB0(v1); - } - return 1; -} - -//----- (00484442) -------------------------------------------------------- -signed int sr_sub_484442(Span *_this) -{ - int v1; // ebp@0 - Span *v2; // edi@1 - stru148 *v3; // esi@1 - int v4; // ecx@1 - stru149 *v5; // eax@1 - stru149 *v6; // eax@1 - int v7; // edx@1 - int v8; // eax@1 - int v9; // ebx@1 - int v10; // eax@1 - int v11; // ecx@1 - int v12; // eax@1 - int v13; // ecx@1 - signed int v14; // ecx@1 - int v15; // ebx@1 - signed __int64 v16; // qtt@3 - int v17; // ecx@3 - int v18; // ebx@3 - int v19; // eax@3 - signed int v20; // ebx@3 - unsigned __int16 *v21; // eax@4 - stru149 *v22; // eax@12 - signed int v23; // eax@12 - int v24; // ecx@12 - int v25; // ecx@14 - unsigned int *v26; // eax@14 - Texture *v27; // esi@14 - signed int v28; // edi@14 - signed int v29; // eax@14 - signed int v31; // [sp+Ch] [bp-90h]@1 - int v32; // [sp+10h] [bp-8Ch]@1 - int v33; // [sp+14h] [bp-88h]@1 - stru316 v34; // [sp+18h] [bp-84h]@14 - stru315 v35; // [sp+40h] [bp-5Ch]@1 - int v36; // [sp+84h] [bp-18h]@1 - int v37; // [sp+88h] [bp-14h]@1 - int v38; // [sp+8Ch] [bp-10h]@1 - int v39; // [sp+90h] [bp-Ch]@1 - int v40; // [sp+94h] [bp-8h]@1 - int v41; // [sp+98h] [bp-4h]@1 - - v2 = _this; - v3 = _this->pParent; - v4 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - _this->field_A); - v5 = v3->ptr_38; - v40 = v4; - v39 = v5->field_14; - v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16; - v6 = v3->ptr_38; - v7 = v40 + v6->field_C; - v39 = v6->field_20; - v36 = v7; - v8 = ((unsigned __int64)(v39 * (signed __int64)v4) >> 16) + v3->ptr_38->field_18; - v40 = v4; - v38 = v8; - v39 = v3->v_18.z; - v40 = (unsigned __int64)(v39 * (signed __int64)v4) >> 16; - v9 = v40 + v3->v_18.x; - v32 = stru_5C6E00->Sin(pIndoorCamera->sRotationY); - v10 = stru_5C6E00->Cos(pIndoorCamera->sRotationY); - v11 = v2->field_8; - v33 = v10; - v35.field_28 = v2->field_C; - v12 = pViewport->uScreenCenterX - v11; - v13 = v3->field_24; - v41 = pOutdoorCamera->int_fov_rad_inv * v12; - v14 = -v13; - v31 = v14; - v15 = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * v12 * (signed __int64)v3->v_18.y) >> 16) + v9; - v37 = v15; - if ( !v15 || (v39 = abs(v14 >> 14), v39 > abs(v15)) ) - return 0; - LODWORD(v16) = v31 << 16; - HIDWORD(v16) = v31 >> 16; - v40 = v16 / v37; - v17 = v16 / v37; - v18 = v41; - HIWORD(v19) = (unsigned int)(v16 / v37) >> 16; - LOWORD(v19) = 0; - v35.field_24 = v19; - v37 = v36 + ((unsigned __int64)(v3->ptr_38->field_10 * (signed __int64)v41) >> 16); - v36 = v3->ptr_38->field_1C; - v41 = (unsigned __int64)(v36 * (signed __int64)v41) >> 16; - v38 += (unsigned __int64)(v36 * (signed __int64)v18) >> 16; - v20 = 2; - v35.pTextureLOD = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; - if ( v17 < mipmapping_terrain_mm1 << 16 ) - { - v20 = 0; - v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail0_prolly_alpha_mask; -LABEL_11: - v35.pTextureLOD = v21; - goto LABEL_12; - } - if ( v17 < mipmapping_terrain_mm2 << 16 ) - { - v20 = 1; - v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail1; - goto LABEL_11; - } - if ( v17 < mipmapping_terrain_mm3 << 16 ) - { - v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail2; - goto LABEL_11; - } - if ( !bUseLoResSprites ) - { - v20 = 3; - v21 = (unsigned __int16 *)v3->pTexture->pLevelOfDetail3; - goto LABEL_11; - } -LABEL_12: - v41 = (unsigned __int64)(v37 * (signed __int64)v17) >> 16; - v22 = v3->ptr_38; - v41 = v17; - v35.field_30 = ((unsigned __int64)(v37 * (signed __int64)v17) >> 16) - v22->field_24; - v23 = ((unsigned __int64)(v38 * (signed __int64)v17) >> 16) - v3->ptr_38->field_28; - v24 = bUseLoResSprites + v20 + 2; - v35.field_30 >>= v24; - v38 = bUseLoResSprites + v20 + 2; - v35.field_2C = v23 >> v24; - if ( byte_80AA10 ) - { - v35.field_14 = dword_80AA20 >> v24; - v35.field_18 = dword_80AA1C >> v24; - v35.field_1C = dword_80AA18 >> v24; - v35.field_20 = dword_80AA14 >> v24; - } - v38 = pOutdoorCamera->int_fov_rad_inv; - v39 = (signed int)((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)v40) >> 16) >> v24; - v35.field_4 = (unsigned __int64)(v39 * (signed __int64)v32) >> 16; - v41 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16; - v35.field_0 = (unsigned __int64)(v39 * (signed __int64)v33) >> 16; - v35.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&v34, v2, v40, v3, pOutdoorCamera->terrain_gamma, 1u, 1); - v25 = v2->field_8; - v26 = (unsigned int *)&pRenderer->pActiveZBuffer[v25 + 640 * v2->field_A]; - v35.pColorBuffer = &pRenderer->pTargetSurface[v25 + pRenderer->uTargetSurfacePitch * v2->field_A]; - v35.pDepthBuffer = v26; - v27 = v3->pTexture; - v28 = (signed int)v27->uTextureWidth >> v20; - v29 = (signed int)v27->uTextureHeight >> v20; - v35.field_10 = v20 - v27->uWidthLn2 + 16; - v35.field_C = v28 - 1; - v35.field_8 = (v29 << 16) - 65536; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - { - if ( byte_80AA10 ) - sr_sub_485D3E(&v35, &v34); - else - sr_sub_485C89(&v35, &v34); - } - else - { - if ( byte_80AA10 ) - sr_sub_4D72EC(v1); - else - sr_sub_4D73DF(v1); - } - return 1; -} - -//----- (004847EB) -------------------------------------------------------- -int sr_sub_4847EB(Span *_this) -{ - stru315 *v1; // ebp@0 - int v2; // ebx@1 - int v3; // edx@1 - stru148 *v4; // esi@1 - int v5; // eax@1 - signed int v6; // eax@3 - int v7; // edi@3 - stru149 *v8; // eax@3 - stru149 *v9; // eax@3 - int v10; // edx@3 - int v11; // eax@3 - signed int v12; // ebx@3 - int v13; // ebx@4 - signed __int64 v14; // qtt@5 - int v15; // eax@5 - signed int v16; // ebx@5 - unsigned __int16 *v17; // ecx@6 - stru149 *v18; // eax@14 - stru149 *v19; // eax@14 - signed int v20; // eax@14 - int v21; // ecx@14 - Texture *v22; // edx@16 - signed int v23; // eax@16 - int v24; // ebx@16 - int v25; // edi@17 - int v26; // ebx@17 - int v27; // eax@17 - int v28; // edi@17 - int v29; // eax@18 - signed __int64 v30; // qtt@19 - int v31; // ecx@19 - int v32; // eax@19 - stru149 *v33; // eax@21 - signed int v34; // edi@21 - int v35; // ebx@21 - signed int v36; // edi@21 - signed __int64 v37; // qtt@21 - signed int v38; // ebx@21 - int v39; // ebx@29 - int v40; // eax@32 - unsigned __int64 v41; // qax@32 - int v42; // edi@32 - int v43; // eax@33 - signed __int64 v44; // qtt@34 - int v45; // ecx@34 - int v46; // eax@34 - stru149 *v47; // eax@36 - signed int v48; // edi@36 - int v49; // eax@36 - int v50; // eax@47 - unsigned __int64 v51; // qax@47 - int v52; // edi@47 - int v53; // eax@48 - signed __int64 v54; // qtt@49 - int v55; // ecx@49 - int v56; // eax@49 - stru149 *v57; // eax@51 - signed int v58; // edi@51 - int v59; // eax@51 - Span *v61; // [sp+Ch] [bp-B0h]@1 - int v62; // [sp+10h] [bp-ACh]@3 - int v63; // [sp+14h] [bp-A8h]@3 - int v64; // [sp+18h] [bp-A4h]@3 - int v65; // [sp+1Ch] [bp-A0h]@3 - signed int v66; // [sp+20h] [bp-9Ch]@3 - signed int v67; // [sp+24h] [bp-98h]@3 - int v68; // [sp+28h] [bp-94h]@1 - char v69; // [sp+2Ch] [bp-90h]@1 - stru315 sr; // [sp+30h] [bp-8Ch]@1 - stru316 sr2; // [sp+74h] [bp-48h]@14 - int v72; // [sp+9Ch] [bp-20h]@5 - int v73; // [sp+A0h] [bp-1Ch]@1 - int v74; // [sp+A4h] [bp-18h]@3 - int v75; // [sp+A8h] [bp-14h]@21 - int v76; // [sp+ACh] [bp-10h]@1 - int v77; // [sp+B0h] [bp-Ch]@14 - int v78; // [sp+B4h] [bp-8h]@3 - int v79; // [sp+B8h] [bp-4h]@3 - - v2 = _this->field_A; - v3 = _this->field_8; - v4 = _this->pParent; - v73 = 0; - v61 = _this; - sr.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2]; - v76 = v3; - v5 = _this->field_C; - sr.pColorBuffer = &pRenderer->pTargetSurface[v3 + pRenderer->uTargetSurfacePitch * v2]; - v68 = texmapping_terrain_subdivsize; - v69 = texmapping_terrain_subdivpow2; - if ( v5 >= texmapping_terrain_subdivsize ) - v73 = texmapping_terrain_subdivsize - (v3 & (texmapping_terrain_subdivsize - 1)); - v6 = v5 - v73; - v67 = v6 >> texmapping_terrain_subdivpow2; - v62 = v6 - (v6 >> texmapping_terrain_subdivpow2 << texmapping_terrain_subdivpow2); - v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76); - v8 = v4->ptr_38; - v79 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v76); - v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2); - v76 = v8->field_14; - v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16; - v9 = v4->ptr_38; - v10 = v78 + v9->field_C; - v76 = v9->field_20; - v65 = v10; - v11 = ((unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16) - + v4->ptr_38->field_18; - v78 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2); - v64 = v11; - v76 = v4->v_18.z; - v78 = (unsigned __int64)(v76 * (signed __int64)(pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2))) >> 16; - v12 = -v4->field_24; - v63 = v78 + v4->v_18.x; - v66 = -v4->field_24; - v78 = (unsigned __int64)(v79 * (signed __int64)v4->v_18.y) >> 16; - v74 = v78 + v63; - if ( !(v78 + v63) || (v76 = v12 >> 14, v13 = abs(v12 >> 14), v13 > abs(v74)) ) - return 0; - LODWORD(v14) = v66 << 16; - HIDWORD(v14) = v66 >> 16; - v72 = v14 / v74; - sr.pTextureLOD = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2; - v15 = v14 / v74; - v16 = 2; - if ( v15 >= mipmapping_terrain_mm1 << 16 ) - { - if ( v15 >= mipmapping_terrain_mm2 << 16 ) - { - if ( v15 >= mipmapping_terrain_mm3 << 16 ) - { - if ( bUseLoResSprites ) - goto LABEL_14; - v16 = 3; - v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail3; - } - else - { - v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail2; - } - } - else - { - v16 = 1; - v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail1; - } - } - else - { - v16 = 0; - v17 = (unsigned __int16 *)v4->pTexture->pLevelOfDetail0_prolly_alpha_mask; - } - sr.pTextureLOD = v17; -LABEL_14: - sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v15, v4, pOutdoorCamera->terrain_gamma, 1u, 1); - v18 = v4->ptr_38; - v78 = v7; - v79 = v18->field_10; - v78 = v7; - v77 = v65 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16); - v79 = v4->ptr_38->field_1C; - v79 = v64 + ((unsigned __int64)(v79 * (signed __int64)v7) >> 16); - v78 = (unsigned __int64)(v77 * (signed __int64)v72) >> 16; - v19 = v4->ptr_38; - v78 = v72; - sr.field_30 = ((unsigned __int64)(v77 * (signed __int64)v72) >> 16) - v19->field_24; - v78 = (unsigned __int64)(v79 * (signed __int64)v72) >> 16; - v20 = ((unsigned __int64)(v79 * (signed __int64)v72) >> 16) - v4->ptr_38->field_28; - v21 = bUseLoResSprites + v16 + 2; - sr.field_30 >>= v21; - v78 = bUseLoResSprites + v16 + 2; - sr.field_2C = v20 >> v21; - if ( byte_80AA10 ) - { - sr.field_14 = dword_80AA20 >> v21; - sr.field_18 = dword_80AA1C >> v21; - sr.field_1C = dword_80AA18 >> v21; - sr.field_20 = dword_80AA14 >> v21; - } - v22 = v4->pTexture; - v79 = (signed int)v22->uTextureWidth >> v16; - v23 = (signed int)v22->uTextureHeight >> v16; - v24 = v16 - v22->uWidthLn2 + 16; - sr.field_8 = (v23 << 16) - 65536; - sr.field_10 = v24; - sr.field_C = v79 - 1; - if ( v73 ) - { - v25 = v7 - v73 * pOutdoorCamera->int_fov_rad_inv; - v26 = v25; - v77 = v4->v_18.y; - v79 = v25; - v27 = (unsigned __int64)(v77 * (signed __int64)v25) >> 16; - v28 = v27 + v63; - v74 = v27 + v63; - if ( !(v27 + v63) || (v77 = abs(v76), v29 = abs(v28), v77 > v29) ) - return 0; - LODWORD(v30) = v66 << 16; - HIDWORD(v30) = v66 >> 16; - v77 = v30 / v74; - v31 = v30 / v74; - HIWORD(v32) = HIWORD(v72); - if ( v72 <= v31 ) - HIWORD(v32) = HIWORD(v31); - LOWORD(v32) = 0; - v77 = v26; - sr.field_24 = v32; - v74 = v4->ptr_38->field_10; - v74 = v65 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16); - v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16; - v33 = v4->ptr_38; - v77 = v26; - v34 = ((unsigned __int64)(v74 * (signed __int64)v31) >> 16) - v33->field_24; - v74 = v33->field_1C; - v74 = v64 + ((unsigned __int64)(v74 * (signed __int64)v26) >> 16); - v77 = (unsigned __int64)(v74 * (signed __int64)v31) >> 16; - v35 = (v77 - v4->ptr_38->field_28) >> v78; - v74 = v73 << 16; - v36 = (v34 >> v78) - sr.field_30; - LODWORD(v37) = v36 << 16; - HIDWORD(v37) = v36 >> 16; - v38 = v35 - sr.field_2C; - sr.field_4 = v37 / (v73 << 16); - v75 = v73 << 16; - LODWORD(v37) = v38 << 16; - HIDWORD(v37) = v38 >> 16; - v77 = v37 / (v73 << 16); - sr.field_0 = v37 / (v73 << 16); - sr.field_28 = v73; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - { - if ( byte_80AA10 ) - sr_sub_485A24(&sr, (stru315 *)&sr2); - else - sr_sub_485975(&sr, (stru315 *)&sr2); - } - else - { - if ( byte_80AA10 ) - sr_sub_4D705A(v1); - else - sr_sub_4D6FB0(v1); - } - v39 = v79 - (pOutdoorCamera->int_fov_rad_inv << v69); - } - else - { - v79 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69); - v39 = v7 - (pOutdoorCamera->int_fov_rad_inv << v69); - } - sr.field_28 = v68; - while ( v67 > 0 ) - { - v40 = v4->v_18.y; - --v67; - v75 = v40; - v41 = v40 * (signed __int64)v39; - v79 = v41 >> 16; - LODWORD(v41) = v41 >> 16; - v42 = v41 + v63; - v74 = v41 + v63; - if ( !((int)v41 + v63) || (v75 = abs(v76), v43 = abs(v42), v75 > v43) ) - return 0; - LODWORD(v44) = v66 << 16; - HIDWORD(v44) = v66 >> 16; - v73 = v44 / v74; - v45 = v44 / v74; - HIWORD(v46) = HIWORD(v72); - if ( v72 <= v45 ) - HIWORD(v46) = HIWORD(v45); - LOWORD(v46) = 0; - v79 = v39; - sr.field_24 = v46; - v75 = v4->ptr_38->field_10; - v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16); - v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16; - v47 = v4->ptr_38; - v79 = v39; - v48 = ((unsigned __int64)(v75 * (signed __int64)v45) >> 16) - v47->field_24; - v75 = v47->field_1C; - v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16); - v79 = (unsigned __int64)(v75 * (signed __int64)v45) >> 16; - v49 = (((v79 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69; - sr.field_4 = ((v48 >> v78) - sr.field_30) >> v69; - sr.field_0 = v49; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - { - if ( byte_80AA10 ) - sr_sub_485A24(&sr, (stru315 *)&sr2); - else - sr_sub_485975(&sr, (stru315 *)&sr2); - } - else - { - if ( byte_80AA10 ) - sr_sub_4D705A(v1); - else - sr_sub_4D6FB0(v1); - } - sr.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&sr2, v61, v73, v4, pOutdoorCamera->terrain_gamma, 1u, 0); - sr.field_28 = v68; - v39 -= pOutdoorCamera->int_fov_rad_inv << v69; - } - if ( !v62 ) - return 1; - v50 = v4->v_18.y; - v75 = v50; - v51 = v50 * (signed __int64)v39; - v79 = v51 >> 16; - LODWORD(v51) = v51 >> 16; - v52 = v51 + v63; - v74 = v51 + v63; - if ( (int)v51 + v63 ) - { - v75 = abs(v76); - v53 = abs(v52); - if ( v75 <= v53 ) - { - LODWORD(v54) = v66 << 16; - HIDWORD(v54) = v66 >> 16; - v76 = v54 / v74; - v55 = v54 / v74; - HIWORD(v56) = HIWORD(v72); - if ( v72 <= v55 ) - HIWORD(v56) = HIWORD(v55); - LOWORD(v56) = 0; - v76 = v39; - sr.field_24 = v56; - v75 = v4->ptr_38->field_10; - v75 = v65 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16); - v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16; - v57 = v4->ptr_38; - v76 = v39; - v58 = ((unsigned __int64)(v75 * (signed __int64)v55) >> 16) - v57->field_24; - v75 = v57->field_1C; - v75 = v64 + ((unsigned __int64)(v75 * (signed __int64)v39) >> 16); - v76 = (unsigned __int64)(v75 * (signed __int64)v55) >> 16; - v59 = (((v76 - v4->ptr_38->field_28) >> v78) - sr.field_2C) >> v69; - sr.field_4 = ((v58 >> v78) - sr.field_30) >> v69; - sr.field_0 = v59; - sr.field_28 = v62; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - { - if ( byte_80AA10 ) - sr_sub_485A24(&sr, (stru315 *)&sr2); - else - sr_sub_485975(&sr, (stru315 *)&sr2); - } - else - { - if ( byte_80AA10 ) - sr_sub_4D705A(v1); - else - sr_sub_4D6FB0(v1); - } - return 1; - } - } - return 0; -} -// 4D864C: using guessed type char byte_4D864C; -// 6BE050: using guessed type int texmapping_terrain_subdivsize; -// 6BE054: using guessed type int texmapping_terrain_subdivpow2; -// 6BE0F0: using guessed type int mipmapping_terrain_mm1; -// 6BE0F4: using guessed type int mipmapping_terrain_mm2; -// 6BE0F8: using guessed type int mipmapping_terrain_mm3; -// 80AA10: using guessed type char byte_80AA10; -// 80AA14: using guessed type int dword_80AA14; -// 80AA18: using guessed type int dword_80AA18; -// 80AA1C: using guessed type int dword_80AA1C; -// 80AA20: using guessed type int dword_80AA20; - -//----- (00485407) -------------------------------------------------------- -signed int __fastcall sr_sub_485407_prolly_odm_water_wavy(Span *a1) -{ - stru315 *v1; // ebp@0 - int v2; // eax@1 - int v3; // edx@1 - unsigned int v4; // edi@1 - stru148 *v5; // esi@1 - int v6; // ecx@1 - int v7; // ebx@1 - int v8; // ecx@1 - stru149 *v9; // eax@1 - stru149 *v10; // eax@1 - int v11; // edx@1 - int v12; // eax@1 - int v13; // eax@1 - int v14; // ecx@1 - signed int v15; // edi@1 - int v16; // edi@2 - signed __int64 v17; // qtt@3 - int v18; // edi@3 - int v19; // eax@3 - unsigned __int8 *pLOD; // eax@3 - Texture *v21; // eax@4 - Texture *v22; // eax@6 - Texture *v23; // eax@8 - Texture *v24; // eax@10 - stru149 *v25; // eax@13 - stru149 *v26; // eax@13 - signed int v27; // ebx@13 - stru149 *v28; // eax@13 - Texture *v29; // esi@13 - signed int v30; // ebx@13 - signed int v31; // edi@13 - signed int v32; // edx@13 - signed int v33; // eax@13 - int v34; // esi@13 - int v35; // eax@13 - unsigned __int64 v36; // qax@13 - int v37; // eax@13 - unsigned __int64 v38; // qax@13 - char v39; // cl@14 - stru316 a2; // [sp+Ch] [bp-90h]@13 - stru315 a1a; // [sp+34h] [bp-68h]@1 - Span *v43; // [sp+78h] [bp-24h]@1 - int v44; // [sp+7Ch] [bp-20h]@1 - int v45; // [sp+80h] [bp-1Ch]@1 - int v46; // [sp+84h] [bp-18h]@1 - Span *v47; // [sp+88h] [bp-14h]@1 - int v48; // [sp+8Ch] [bp-10h]@1 - int v49; // [sp+90h] [bp-Ch]@3 - int i; // [sp+94h] [bp-8h]@3 - int X; // [sp+98h] [bp-4h]@1 - - v2 = a1->field_A; - v3 = a1->field_8; - v4 = v3 + pRenderer->uTargetSurfacePitch * a1->field_A; - v5 = a1->pParent; - v43 = a1; - v6 = a1->field_C; - a1a.pColorBuffer = &pRenderer->pTargetSurface[v4]; - v46 = v6; - v7 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterX - v3); - v8 = pOutdoorCamera->int_fov_rad_inv * (pViewport->uScreenCenterY - v2); - a1a.pDepthBuffer = (unsigned int *)&pRenderer->pActiveZBuffer[v3 + 640 * v2]; - v9 = v5->ptr_38; - v47 = (Span *)v7; - X = v8; - v48 = v9->field_14; - X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16; - v10 = v5->ptr_38; - v11 = X + v10->field_C; - v48 = v10->field_20; - v44 = v11; - v12 = ((unsigned __int64)(v48 * (signed __int64)v8) >> 16) + v5->ptr_38->field_18; - X = v8; - v45 = v12; - v48 = v5->v_18.z; - X = (unsigned __int64)(v48 * (signed __int64)v8) >> 16; - v13 = v5->v_18.y; - v14 = X + v5->v_18.x; - v15 = -v5->field_24; - v48 = -v5->field_24; - X = ((unsigned __int64)(v7 * (signed __int64)v13) >> 16) + v14; - if ( !X || (v16 = abs(v15 >> 14), v16 > abs(X)) ) - return 0; - LODWORD(v17) = v48 << 16; - HIDWORD(v17) = v48 >> 16; - i = v17 / X; - v18 = v17 / X; - HIWORD(v19) = (unsigned int)(v17 / X) >> 16; - LOWORD(v19) = 0; - a1a.field_24 = v19; - pLOD = v5->pTexture->pLevelOfDetail2; - a1a.pTextureLOD = (unsigned __int16 *)v5->pTexture->pLevelOfDetail2; - v49 = 2; - if ( v18 >= mipmapping_terrain_mm1 << 16 ) - { - if ( v18 >= mipmapping_terrain_mm2 << 16 ) - { - if ( v18 >= mipmapping_terrain_mm3 << 16 ) - { - if ( bUseLoResSprites ) - goto LABEL_12; - v24 = v5->pTexture; - v49 = 3; - pLOD = v24->pLevelOfDetail3; - } - else - { - v23 = v5->pTexture; - v49 = 2; - pLOD = v23->pLevelOfDetail2; - } - } - else - { - v22 = v5->pTexture; - v49 = 1; - pLOD = v22->pLevelOfDetail1; - } - } - else - { - v21 = v5->pTexture; - v49 = 0; - pLOD = v21->pLevelOfDetail0_prolly_alpha_mask; - } - a1a.pTextureLOD = (unsigned __int16 *)pLOD; -LABEL_12: - if ( !pLOD ) - return 0; - a1a.field_34_palette = (unsigned __int16 *)sr_sub_485E1F(&a2, v43, v18, v5, pOutdoorCamera->terrain_gamma, 1u, 1); - a1a.field_28 = 16; - v43 = (Span *)(v46 >> 4); - X = v7; - v25 = v5->ptr_38; - v48 = v46 - 16 * (v46 >> 4); - v46 = v25->field_10; - X = v7; - v46 = v44 + ((unsigned __int64)(v46 * (signed __int64)v7) >> 16); - v44 = v5->ptr_38->field_1C; - v45 += (unsigned __int64)(v44 * (signed __int64)v7) >> 16; - X = (unsigned __int64)(v46 * (signed __int64)v18) >> 16; - v26 = v5->ptr_38; - X = v18; - v27 = ((unsigned __int64)(v46 * (signed __int64)v18) >> 16) - v26->field_24; - X = (unsigned __int64)(v45 * (signed __int64)v18) >> 16; - v28 = v5->ptr_38; - v29 = v5->pTexture; - v44 = bUseLoResSprites + v49 + 2; - v30 = v27 >> v44; - v31 = (signed int)(((unsigned __int64)(v45 * (signed __int64)v18) >> 16) - v28->field_28) >> v44; - v32 = (signed int)v29->uTextureWidth >> v49; - v33 = (signed int)v29->uTextureHeight >> v49; - v34 = v49 - v29->uWidthLn2; - a1a.field_8 = (v33 << 16) - 65536; - X = 2 * pMiscTimer->uTotalGameTimeElapsed; - v45 = pOutdoorCamera->int_fov_rad_inv; - a1a.field_10 = v34 + 16; - a1a.field_C = v32 - 1; - i = (unsigned __int64)(pOutdoorCamera->int_fov_rad_inv * (signed __int64)i) >> 16; - v47 = (Span *)(i >> v44); - v35 = stru_5C6E00->Sin(pIndoorCamera->sRotationY); - v36 = (signed int)v47 * (signed __int64)v35; - i = v36 >> 16; - a1a.field_4 = v36 >> 16; - v37 = stru_5C6E00->Cos(pIndoorCamera->sRotationY); - v38 = (signed int)v47 * (signed __int64)v37; - i = v38 >> 16; - a1a.field_0 = v38 >> 16; - if ( (signed int)v43 > 0 ) - { - v47 = v43; - v39 = 12 - v49; - for ( i = 12 - v49; ; v39 = i ) - { - a1a.field_30 = v30 + 4 * stru_5C6E00->Cos(X + (v31 >> v39)); - a1a.field_2C = v31 + 4 * stru_5C6E00->Sin(X + (v30 >> i)); - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - sr_sub_485975(&a1a, (stru315 *)&a2); - else - sr_sub_4D6FB0(v1); - a1a.field_28 = 16; - v30 += 16 * a1a.field_4; - v31 += 16 * a1a.field_0; - v47 = (Span *)((char *)v47 - 1); - if ( !v47 ) - break; - } - } - if ( v48 ) - { - i = 12 - v49; - a1a.field_30 = v30 + 4 * stru_5C6E00->Cos(X + (v31 >> (12 - v49))); - a1a.field_2C = v31 + 4 * stru_5C6E00->Sin(X + (v30 >> i)); - a1a.field_28 = v48; - if ( byte_4D864C && BYTE1(pGame->uFlags) & 8 ) - sr_sub_485975(&a1a, (stru315 *)&a2); - else - sr_sub_4D6FB0(v1); - } - return 1; -} - -//----- (0048585C) -------------------------------------------------------- -signed int __fastcall sr_sub_48585C_mb_DrawSpan(Span *a1, unsigned __int16 *pRenderTarget, int a4) -{ - Span *v3; // esi@1 - stru148 *v4; // edi@1 - int v5; // ebx@2 - signed __int64 v6; // qtt@3 - int v7; // ebx@3 - signed int v8; // ecx@3 - void *v9; // eax@5 - int v10; // ecx@5 - unsigned __int16 *pPixels; // [sp+Ch] [bp-14h]@1 - signed int v13; // [sp+10h] [bp-10h]@1 - int X; // [sp+18h] [bp-8h]@1 - - v3 = a1; - pPixels = pRenderTarget; - v4 = a1->pParent; - v13 = -v4->field_24; - X = ((unsigned __int64)(pOutdoorCamera->int_fov_rad_inv - * (pViewport->uScreenCenterX - (signed int)a1->field_8) - * (signed __int64)v4->v_18.y) >> 16) - + ((unsigned __int64)(v4->v_18.z - * (signed __int64)(pOutdoorCamera->int_fov_rad_inv - * (pViewport->uScreenCenterY - (signed int)a1->field_A))) >> 16) - + v4->v_18.x; - if ( X && (v5 = abs(-v4->field_24 >> 14), v5 <= abs(X)) ) - { - LODWORD(v6) = v13 << 16; - HIDWORD(v6) = v13 >> 16; - v7 = v6 / X; - v8 = v6 / X; - } - else - { - v7 = pOutdoorCamera->shading_dist_mist << 16; - v8 = pOutdoorCamera->shading_dist_mist << 16; - } - v9 = sr_sub_47C178(v8, v4, pOutdoorCamera->terrain_gamma, a4); - fill_pixels_fast(*((short *)v9 + v4->pTexture->uDecompressedSize), pPixels, v3->field_C); - HIWORD(v10) = HIWORD(v7); - LOWORD(v10) = 0; - j_memset32(v10, &pRenderer->pActiveZBuffer[v3->field_8 + 640 * v3->field_A], v3->field_C); - return 1; -} - -//----- (00485975) -------------------------------------------------------- -stru315 *__fastcall sr_sub_485975(stru315 *a1, stru315 *a2) -{ - stru315 *result; // eax@1 - int i; // ecx@1 - int v4; // esi@2 - int v5; // esi@2 - int v6; // ecx@2 - int v7; // esi@3 - int v8; // edi@3 - int v9; // ebx@3 - int v10; // ecx@8 - unsigned __int16 *v11; // esi@10 - unsigned int *v12; // ecx@12 - int v13; // esi@12 - int v14; // [sp+0h] [bp-4h]@2 - - result = a1; - for ( i = a1->field_28; i; i = result->field_28 ) - { - v4 = result->field_8 & result->field_2C; - result->field_28 = i - 1; - v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10); - v6 = *((char *)result->pTextureLOD + v5); - v14 = *((char *)result->pTextureLOD + v5); - if ( a2->field_20 ) - { - v7 = HIWORD(a2->field_10); - v8 = a2->field_C; - v9 = v7; - if ( v7 >= v8 ) - v9 = a2->field_C; - if ( a2->field_8 - v9 <= 0 ) - { - v10 = 0; - } - else - { - if ( v7 >= v8 ) - v7 = a2->field_C; - v10 = a2->field_8 - v7; - } - v11 = (unsigned __int16 *)a2->field_24; - v6 = v14 + (v10 << 8); - } - else - { - v11 = result->field_34_palette; - } - *result->pColorBuffer = v11[v6]; - v12 = result->pDepthBuffer; - v13 = result->field_24; - ++result->pColorBuffer; - *v12 = v13; - ++result->pDepthBuffer; - a2->field_10 += a2->field_18; - result->field_30 += result->field_4; - result->field_2C += result->field_0; - } - --result->field_28; - return result; -} - -//----- (00485A24) -------------------------------------------------------- -stru315 *__fastcall sr_sub_485A24(stru315 *a1, stru315 *a2) -{ - stru315 *result; // eax@1 - int i; // ecx@1 - int v4; // ecx@2 - int v5; // ecx@4 - int v6; // ecx@6 - int v7; // ecx@8 - int v8; // esi@10 - int v9; // ecx@10 - int v10; // esi@11 - int v11; // edi@11 - int v12; // ebx@11 - int v13; // ecx@16 - unsigned __int16 *v14; // esi@18 - unsigned int *v15; // ecx@20 - int v16; // esi@20 - int v17; // [sp+0h] [bp-4h]@10 - - result = a1; - for ( i = a1->field_28; i; i = result->field_28 ) - { - result->field_28 = i - 1; - v4 = result->field_18; - if ( result->field_30 > v4 ) - result->field_30 = v4; - v5 = result->field_20; - if ( result->field_2C > v5 ) - result->field_2C = v5; - v6 = result->field_14; - if ( result->field_30 < v6 ) - result->field_30 = v6; - v7 = result->field_1C; - if ( result->field_2C < v7 ) - result->field_2C = v7; - v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10); - v9 = *((char *)result->pTextureLOD + v8); - v17 = *((char *)result->pTextureLOD + v8); - if ( a2->field_20 ) - { - v10 = HIWORD(a2->field_10); - v11 = a2->field_C; - v12 = v10; - if ( v10 >= v11 ) - v12 = a2->field_C; - if ( a2->field_8 - v12 <= 0 ) - { - v13 = 0; - } - else - { - if ( v10 >= v11 ) - v10 = a2->field_C; - v13 = a2->field_8 - v10; - } - v14 = (unsigned __int16 *)a2->field_24; - v9 = v17 + (v13 << 8); - } - else - { - v14 = result->field_34_palette; - } - *result->pColorBuffer = v14[v9]; - v15 = result->pDepthBuffer; - v16 = result->field_24; - ++result->pColorBuffer; - *v15 = v16; - ++result->pDepthBuffer; - a2->field_10 += a2->field_18; - result->field_30 += result->field_4; - result->field_2C += result->field_0; - } - --result->field_28; - return result; -} - -//----- (00485AFF) -------------------------------------------------------- -stru315 *__fastcall sr_sub_485AFF(stru315 *a1, stru316 *a2) -{ - stru315 *result; // eax@1 - int i; // ecx@1 - int v4; // esi@2 - int v5; // esi@2 - int v6; // ecx@2 - int v7; // esi@3 - int v8; // edi@3 - int v9; // ebx@3 - int v10; // ecx@8 - unsigned __int16 *v11; // esi@10 - unsigned int *v12; // ecx@12 - int v13; // esi@12 - int v14; // [sp+0h] [bp-4h]@2 - - result = a1; - for ( i = a1->field_28; i; i = result->field_28 ) - { - v4 = result->field_8 & result->field_2C; - result->field_28 = i - 1; - v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10); - v6 = *((char *)result->pTextureLOD + v5); - v14 = *((char *)result->pTextureLOD + v5); - if ( a2->field_20 ) - { - v7 = HIWORD(a2->field_14); - v8 = a2->field_C; - v9 = v7; - if ( v7 >= v8 ) - v9 = a2->field_C; - if ( a2->field_8 - v9 <= 0 ) - { - v10 = 0; - } - else - { - if ( v7 >= v8 ) - v7 = a2->field_C; - v10 = a2->field_8 - v7; - } - v11 = a2->field_24_palette; - v6 = v14 + (v10 << 8); - } - else - { - v11 = result->field_34_palette; - } - *result->pColorBuffer = v11[v6]; - v12 = result->pDepthBuffer; - v13 = result->field_24; - --result->pColorBuffer; - *v12 = v13; - --result->pDepthBuffer; - a2->field_14 -= a2->field_18; - result->field_30 += result->field_4; - result->field_2C += result->field_0; - } - --result->field_28; - return result; -} - -//----- (00485BAE) -------------------------------------------------------- -stru315 *__fastcall sr_sub_485BAE(stru315 *a1, stru316 *a2) -{ - stru315 *result; // eax@1 - int i; // ecx@1 - int v4; // ecx@2 - int v5; // ecx@4 - int v6; // ecx@6 - int v7; // ecx@8 - int v8; // esi@10 - int v9; // ecx@10 - int v10; // esi@11 - int v11; // edi@11 - int v12; // ebx@11 - int v13; // ecx@16 - unsigned __int16 *v14; // esi@18 - unsigned int *v15; // ecx@20 - int v16; // esi@20 - int v17; // [sp+0h] [bp-4h]@10 - - result = a1; - for ( i = a1->field_28; i; i = result->field_28 ) - { - result->field_28 = i - 1; - v4 = result->field_18; - if ( result->field_30 > v4 ) - result->field_30 = v4; - v5 = result->field_20; - if ( result->field_2C > v5 ) - result->field_2C = v5; - v6 = result->field_14; - if ( result->field_30 < v6 ) - result->field_30 = v6; - v7 = result->field_1C; - if ( result->field_2C < v7 ) - result->field_2C = v7; - v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10); - v9 = *((char *)result->pTextureLOD + v8); - v17 = *((char *)result->pTextureLOD + v8); - if ( a2->field_20 ) - { - v10 = HIWORD(a2->field_14); - v11 = a2->field_C; - v12 = v10; - if ( v10 >= v11 ) - v12 = a2->field_C; - if ( a2->field_8 - v12 <= 0 ) - { - v13 = 0; - } - else - { - if ( v10 >= v11 ) - v10 = a2->field_C; - v13 = a2->field_8 - v10; - } - v14 = a2->field_24_palette; - v9 = v17 + (v13 << 8); - } - else - { - v14 = result->field_34_palette; - } - *result->pColorBuffer = v14[v9]; - v15 = result->pDepthBuffer; - v16 = result->field_24; - --result->pColorBuffer; - *v15 = v16; - --result->pDepthBuffer; - a2->field_14 -= a2->field_18; - result->field_30 += result->field_4; - result->field_2C += result->field_0; - } - --result->field_28; - return result; -} - -//----- (00485C89) -------------------------------------------------------- -stru315 *__fastcall sr_sub_485C89(stru315 *a1, stru316 *a2) -{ - stru315 *result; // eax@1 - int i; // ecx@1 - int v4; // esi@2 - int v5; // esi@2 - int v6; // ecx@2 - int v7; // esi@4 - int v8; // edi@4 - int v9; // ecx@9 - unsigned __int16 *v10; // esi@11 - unsigned int *v11; // ecx@14 - int v12; // esi@14 - int v13; // [sp+0h] [bp-4h]@2 - - result = a1; - for ( i = a1->field_28; i; i = result->field_28 ) - { - v4 = result->field_8 & result->field_2C; - result->field_28 = i - 1; - v5 = (result->field_C & HIWORD(result->field_30)) + (v4 >> result->field_10); - v6 = *((char *)result->pTextureLOD + v5); - v13 = *((char *)result->pTextureLOD + v5); - if ( *((char *)result->pTextureLOD + v5) ) - { - if ( a2->field_20 ) - { - v7 = HIWORD(a2->field_10); - v8 = v7; - if ( v7 >= a2->field_C ) - v8 = a2->field_C; - if ( a2->field_8 - v8 <= 0 ) - { - v9 = 0; - } - else - { - if ( v7 >= a2->field_C ) - v7 = a2->field_C; - v9 = a2->field_8 - v7; - } - v10 = a2->field_24_palette; - v6 = v13 + (v9 << 8); - } - else - { - v10 = result->field_34_palette; - } - *result->pColorBuffer = v10[v6]; - } - v11 = result->pDepthBuffer; - v12 = result->field_24; - ++result->pColorBuffer; - *v11 = v12; - ++result->pDepthBuffer; - a2->field_10 += a2->field_18; - result->field_30 += result->field_4; - result->field_2C += result->field_0; - } - --result->field_28; - return result; -} - -//----- (00485D3E) -------------------------------------------------------- -stru315 *__fastcall sr_sub_485D3E(stru315 *a1, stru316 *a2) -{ - stru315 *result; // eax@1 - int i; // ecx@1 - int v4; // ecx@2 - int v5; // ecx@4 - int v6; // ecx@6 - int v7; // ecx@8 - int v8; // esi@10 - int v9; // ecx@10 - int v10; // esi@12 - int v11; // edi@12 - int v12; // ecx@17 - unsigned __int16 *v13; // esi@19 - unsigned int *v14; // ecx@22 - int v15; // esi@22 - int v16; // [sp+0h] [bp-4h]@10 - - result = a1; - for ( i = a1->field_28; i; i = result->field_28 ) - { - result->field_28 = i - 1; - v4 = result->field_18; - if ( result->field_30 > v4 ) - result->field_30 = v4; - v5 = result->field_20; - if ( result->field_2C > v5 ) - result->field_2C = v5; - v6 = result->field_14; - if ( result->field_30 < v6 ) - result->field_30 = v6; - v7 = result->field_1C; - if ( result->field_2C < v7 ) - result->field_2C = v7; - v8 = (result->field_C & HIWORD(result->field_30)) + ((result->field_2C & result->field_8) >> result->field_10); - v9 = *((char *)result->pTextureLOD + v8); - v16 = *((char *)result->pTextureLOD + v8); - if ( *((char *)result->pTextureLOD + v8) ) - { - if ( a2->field_20 ) - { - v10 = HIWORD(a2->field_10); - v11 = v10; - if ( v10 >= a2->field_C ) - v11 = a2->field_C; - if ( a2->field_8 - v11 <= 0 ) - { - v12 = 0; - } - else - { - if ( v10 >= a2->field_C ) - v10 = a2->field_C; - v12 = a2->field_8 - v10; - } - v13 = a2->field_24_palette; - v9 = v16 + (v12 << 8); - } - else - { - v13 = result->field_34_palette; - } - *result->pColorBuffer = v13[v9]; - } - v14 = result->pDepthBuffer; - v15 = result->field_24; - ++result->pColorBuffer; - *v14 = v15; - ++result->pDepthBuffer; - a2->field_10 += a2->field_18; - result->field_30 += result->field_4; - result->field_2C += result->field_0; - } - --result->field_28; - return result; -} - -//----- (00485E1F) -------------------------------------------------------- -void *__fastcall sr_sub_485E1F(stru316 *a1, Span *a2, int a3, stru148 *a4, int a5, unsigned __int8 a6, char a7) -{ - stru316 *v7; // esi@1 - signed int *v8; // edi@1 - signed int *v9; // ebx@1 - char v10; // zf@1 - int v11; // eax@1 - Span *v12; // ecx@3 - double v13; // ST24_8@3 - double v14; // ST24_8@3 - int v15; // eax@3 - signed int v16; // ST14_4@4 - char v17; // dl@4 - signed int v18; // ST10_4@4 - void *v19; // eax@4 - signed int v20; // ST14_4@5 - char v21; // dl@5 - int v22; // ST10_4@5 - signed int v23; // ST14_4@6 - char v24; // dl@6 - Span *v26; // [sp+10h] [bp-8h]@1 - char v27; // [sp+16h] [bp-2h]@1 - char v28; // [sp+17h] [bp-1h]@1 - float v29; // [sp+30h] [bp+18h]@3 - float v30; // [sp+30h] [bp+18h]@3 - - v7 = a1; - v26 = a2; - v8 = &a1->field_C; - v9 = &a1->field_8; - v10 = a1->field_0 == 0; - v27 = a1->field_4 != 0; - v28 = !v10; - sr_sub_47BEB1(a3, a4, a5, 0, &a1->field_8, &a1->field_C, (int)&v27, (int)&v28); - v7->field_24_palette = (unsigned __int16 *)sr_sub_47C28C_get_palette(a4, v28, *v9, *v8); - v11 = a4->field_108; - v7->field_20 = v11; - if ( v11 ) - { - if ( a7 ) - { - v12 = v26; - v29 = v26->field_10 * 31.0; - v13 = v29 + 6.7553994e15; - v7->field_10 = LODWORD(v13) << 16; - v30 = v12->field_14 * 31.0; - v14 = v30 + 6.7553994e15; - v15 = v7->field_10; - v7->field_14 = LODWORD(v14) << 16; - v7->field_18 = -((v15 - (LODWORD(v14) << 16)) / v12->field_C); - } - v16 = *v8; - v17 = v28; - v18 = *v9; - v7->field_1C = a6; - v19 = sr_sub_47C28C_get_palette(a4, v17, v18, v16); - } - else - { - v20 = *v8; - v21 = v28; - v7->field_10 = 0; - v7->field_14 = 0; - v22 = *v9; - v7->field_18 = 0; - v7->field_1C = 0; - v19 = sr_sub_47C1CA(a4, v21, v22, v20); - } - v23 = *v8; - v24 = v28; - v7->field_24_palette = (unsigned __int16 *)v19; - return sr_sub_47C1CA(a4, v24, *v9, v23); -} + + + //----- (00485F53) -------------------------------------------------------- -void __thiscall sub_485F53(Vec2_int_ *v) +void __thiscall sr_485F53(Vec2_int_ *v) { ++v->y; if ( v->y > 1000 ) @@ -10364,57 +6208,35 @@ } //----- (0048607B) -------------------------------------------------------- -void stru148::_48607B(stru149 *a2) +void Polygon::Create_48607B(stru149 *a2) { this->pTexture = 0; this->ptr_38 = a2; } //----- (00486089) -------------------------------------------------------- -void stru148::_486089_normalize_v_18() +void Polygon::_normalize_v_18() { - //stru148 *v1; // esi@1 double v2; // st7@1 double v3; // st6@1 - float v4; // ST18_4@2 double v5; // st5@1 - float v6; // ST14_4@2 - double v7; // st7@1 - float v8; // ST24_4@2 - float v9; // ST20_4@2 - double v10; // ST0C_8@2 - float v11; // ST18_4@2 - double v12; // ST0C_8@2 - float v13; // ST14_4@2 - double v14; // ST0C_8@2 - float v15; // [sp+20h] [bp-8h]@1 //v1 = this; v2 = (double)this->v_18.x; - v15 = v2; v3 = (double)this->v_18.y; v5 = (double)this->v_18.z; - v7 = sqrt(v5 * v5 + v3 * v3 + v2 * v2); - if ( v7 == 0.0 ) - { - this->v_18.x = 0; - this->v_18.y = 0; - this->v_18.z = 65536; + float len = sqrt(v5 * v5 + v3 * v3 + v2 * v2); + if (fabsf(len) < 1e-6f) + { + v_18.x = 0; + v_18.y = 0; + v_18.z = 65536; } else { - v8 = 1.0 / v7; - v9 = v8 * v15 * 65536.0; - v10 = v9 + 6.7553994e15; - this->v_18.x = LODWORD(v10); - v4 = v3; - v11 = v8 * v4 * 65536.0; - v12 = v11 + 6.7553994e15; - this->v_18.y = LODWORD(v12); - v6 = v5; - v13 = v8 * v6 * 65536.0; - v14 = v13 + 6.7553994e15; - this->v_18.z = LODWORD(v14); + v_18.x = round(v2 / len * 65536.0); + v_18.y = round(v3 / len * 65536.0); + v_18.y = round(v5 / len * 65536.0); } } @@ -10528,298 +6350,17 @@ } //----- (0048694B) -------------------------------------------------------- -int stru149::sky_48694B() +void stru149::Inverse_sky_48694B() { - int v1; // eax@1 - int v2; // ST04_4@1 - int v3; // ST00_4@1 - int v4; // eax@1 - int v5; // ST0C_4@1 - int result; // eax@1 - - v1 = this->field_C; this->field_18 = -this->field_18; this->field_1C = -this->field_1C; this->field_20 = -this->field_20; - v2 = (unsigned __int64)(v1 * (signed __int64)this->field_0_party_dir_x) >> 16; - v3 = this->field_18; - v4 = this->field_0_party_dir_x; - this->field_24 = v2 + this->field_24 = ((unsigned __int64)(this->field_C * (signed __int64)this->field_0_party_dir_x) >> 16) + ((unsigned __int64)(this->field_10 * (signed __int64)this->field_4_party_dir_y) >> 16) + ((unsigned __int64)(this->field_14 * (signed __int64)this->field_8) >> 16); - v5 = (unsigned __int64)(v3 * (signed __int64)v4) >> 16; - result = (unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16; - this->field_28 = v5 + result + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16); - return result; -} - -//----- (00486B4E) -------------------------------------------------------- -char __fastcall sr_sub_486B4E_push_outdoor_edges(RenderVertexSoft *a1, int *a2, int *a3, stru148 *a4)//maybe DrawPolygonSW -{ - stru148 *v4; // esi@1 - RenderVertexSoft *v5; // edi@1 - char v6; // zf@1 - unsigned int v7; // eax@3 - int v8; // ebx@3 - int *v9; // ecx@7 - int v10; // ebx@8 - int v11; // eax@10 - double v12; // st7@14 - int *v13; // edx@14 - double v14; // st6@14 - double v15; // st7@16 - int v16; // edi@16 - double v17; // st7@16 - double v18; // st7@16 - int v19; // edi@18 - double v20; // st7@18 - double v21; // st7@18 - Edge *i; // edx@20 - double v23; // st7@28 - Edge *v24; // eax@28 - std::string v26; // [sp-18h] [bp-98h]@2 - const char *v27; // [sp-8h] [bp-88h]@2 - int v28; // [sp-4h] [bp-84h]@2 - double v29; // [sp+Ch] [bp-74h]@28 - double v30; // [sp+14h] [bp-6Ch]@28 - double v31; // [sp+1Ch] [bp-64h]@20 - double v32; // [sp+24h] [bp-5Ch]@16 - double v33; // [sp+2Ch] [bp-54h]@14 - unsigned int v34; // [sp+34h] [bp-4Ch]@2 - unsigned __int64 v35; // [sp+38h] [bp-48h]@28 - int v36; // [sp+40h] [bp-40h]@28 - int v37; // [sp+44h] [bp-3Ch]@20 - float v38; // [sp+48h] [bp-38h]@18 - int v39; // [sp+4Ch] [bp-34h]@16 - int v40; // [sp+50h] [bp-30h]@14 - int v41; // [sp+54h] [bp-2Ch]@3 - RenderVertexSoft *v42; // [sp+58h] [bp-28h]@1 - int v43; // [sp+5Ch] [bp-24h]@14 - int v44; // [sp+60h] [bp-20h]@6 - int v45; // [sp+64h] [bp-1Ch]@6 - unsigned int v46; // [sp+68h] [bp-18h]@7 - int *v47; // [sp+6Ch] [bp-14h]@1 - int v48; // [sp+70h] [bp-10h]@7 - float *v49; // [sp+74h] [bp-Ch]@7 - float v50; // [sp+78h] [bp-8h]@10 - float v51; // [sp+7Ch] [bp-4h]@14 - - v4 = a4; - v5 = a1; - v47 = a2; - v6 = (HIBYTE(a4->flags) & 0x40) == 0; - v42 = a1; - if ( !v6 ) - { - MessageBoxW(nullptr, L"The Texture Frame Table is not a supported feature.", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Odspan.cpp:162", 0); - } - LOBYTE(v7) = v4->field_108; - v8 = v4->uNumVertices; - v4->field_108 = 0; - BYTE3(a4) = v7; - v41 = v8; - if ( v8 > 0 ) - { - if ( (signed int)pOutdoorCamera->uNumSurfs < 1999 ) - { - v7 = pOutdoorCamera->uNumEdges; - if ( (signed int)pOutdoorCamera->uNumEdges < 5979 ) - { - v4->uEdgeList1Size = 0; - v4->uEdgeList2Size = 0; - v45 = -1; - v34 = v7; - v28 = v8; - v27 = (const char *)v5; - v44 = 10000; - pGame->pLightmapBuilder->_45CB89(v5, v8); - if ( v8 > 0 ) - { - v9 = a3; - v48 = 1; - v49 = &v5->flt_2C; - v46 = (char *)v47 - (char *)a3; - do - { - v10 = v48; - ++pOutdoorCamera->uNumEdges; - if ( v48 >= v41 ) - v10 = 0; - v11 = *v9; - LODWORD(v50) = *v9; - if ( SLODWORD(v50) > v45 ) - v45 = v11; - if ( v11 < v44 ) - v44 = v11; - v12 = (double)SLODWORD(v50); - v13 = &a3[v10]; - v51 = v12; - v14 = (double)*v13; - v50 = v14; - *(float *)&v40 = v14 - v12; - v33 = *(float *)&v40 + 6.7553994e15; - v43 = LODWORD(v33); - if ( LODWORD(v33) ) - { - if ( SLODWORD(v33) >= 0 ) - { - v19 = (int)((char *)v9 + v46); - ptr_80C978_Edges->field_8 = 1; - LODWORD(v38) = (int)&v47[v10]; - v40 = *(unsigned int *)LODWORD(v38) - *(int *)v19; - v6 = BYTE3(a4) == 0; - v20 = (double)v40; - v40 = *v13 - *v9; - v21 = v20 / (double)v40; - ptr_80C978_Edges->field_4 = v21; - ptr_80C978_Edges->field_0 = (v51 - (double)*v9) * v21 + (double)*(signed int *)v19; - if ( !v6 ) - { - ptr_80C978_Edges->field_1C = *v49; - ptr_80C978_Edges->field_20 = v42[v10].flt_2C; - ptr_80C978_Edges->field_24 = (double)*(signed int *)v19; - ptr_80C978_Edges->field_28 = (double)(signed int)*(unsigned int *)LODWORD(v38); - ptr_80C978_Edges->field_2C = (double)*v9; - ptr_80C978_Edges->field_30 = (double)*v13; - v4->pEdgeList1[v4->uEdgeList1Size++] = ptr_80C978_Edges; - } - } - else - { - v32 = v51 + 6.7553994e15; - v39 = LODWORD(v32); - v51 = v50; - v15 = (double)SLODWORD(v32); - ptr_80C978_Edges->field_8 = 0; - v16 = (int)&v47[v10]; - v50 = v15; - v40 = *(int *)((char *)v9 + v46) - *(int *)v16; - v6 = BYTE3(a4) == 0; - v17 = (double)v40; - v40 = *v9 - *v13; - v18 = v17 / (double)v40; - ptr_80C978_Edges->field_4 = v18; - ptr_80C978_Edges->field_0 = (v51 - (double)*v13) * v18 + (double)*(signed int *)v16; - if ( !v6 ) - { - ptr_80C978_Edges->field_1C = v42[v10].flt_2C; - ptr_80C978_Edges->field_20 = *v49; - ptr_80C978_Edges->field_24 = (double)*(signed int *)v16; - ptr_80C978_Edges->field_28 = (double)*(int *)((char *)v9 + v46); - ptr_80C978_Edges->field_2C = (double)*v13; - ptr_80C978_Edges->field_30 = (double)*v9; - v4->pEdgeList2[v4->uEdgeList2Size++] = ptr_80C978_Edges; - } - } - v31 = v51 + 6.7553994e15; - v37 = LODWORD(v31); - for ( i = &pNewEdges[LODWORD(v31)]; i->pNext->field_0 < (double)ptr_80C978_Edges->field_0; i = i->pNext ) - ; - if ( i->field_0 != ptr_80C978_Edges->field_0 || i->field_8 || ptr_80C978_Edges->field_8 != 1 ) - { - ptr_80C978_Edges->pNext = i->pNext; - i->pNext = ptr_80C978_Edges; - } - else - { - ptr_80C978_Edges->pNext = i; - i->pPrev->pNext = ptr_80C978_Edges; - } - v23 = v50 - 1.0; - *(float *)&v40 = v23; - v38 = v23; - v30 = v38 + 6.7553994e15; - v36 = LODWORD(v30); - ptr_80C978_Edges->ptr_18 = ptr_80CA10[LODWORD(v30)]; - v29 = *(float *)&v40 + 6.7553994e15; - v35 = __PAIR__(v40, LODWORD(v29)); - v24 = ptr_80C978_Edges; - ptr_80CA10[LODWORD(v29)] = ptr_80C978_Edges; - v24->pSurf = ptr_80C97C_Surfs; - if ( ptr_80C978_Edges < &pEdges[5999] ) - ++ptr_80C978_Edges; - } - ++v48; - v49 += 12; - ++v9; - } - while ( v48 - 1 < v41 ); - } - LOBYTE(v7) = v34; - if ( pOutdoorCamera->uNumEdges != v34 ) - { - v4->ptr_48 = 0; - ptr_80C97C_Surfs->field_22 = 0; - ptr_80C97C_Surfs->pParent = v4; - ptr_80C97C_Surfs->field_4 = v4->field_4; - ptr_80C97C_Surfs->field_8 = v4->field_8; - ptr_80C97C_Surfs->field_0 = v4->field_0; - ptr_80C97C_Surfs->field_C = v4->field_C; - ptr_80C97C_Surfs->field_10 = v4->field_10; - LOBYTE(v7) = (char)pSurfs + 28; - if ( ptr_80C97C_Surfs < &pSurfs[1999] ) - { - ++ptr_80C97C_Surfs; - ++pOutdoorCamera->uNumSurfs; - } - if ( BYTE3(a4) ) - v4->field_108 = 1; - } - } - } - } - return v7; -} - -//----- (00440DF5) -------------------------------------------------------- -int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr) -{ - int result; // eax@1 - - pElements[uNumElements].field_6_rnd_value = a2; - pElements[uNumElements].field_8_rnd_value = a3; - pElements[uNumElements].field_A_rnd_value = a4; - pElements[uNumElements].field_C_time_left = rand() % 64 + 256; - pElements[uNumElements].field_E_time_to_live = pElements[uNumElements].field_C_time_left; - result = 3 * uNumElements; - pElements[uNumElements++].bgr16 = bgr; - if (uNumElements >= 100 ) - uNumElements = 0; - return result; -} - -//----- (00440E91) -------------------------------------------------------- -void stru167_wrap::_440E91(__int16 x, int y, int z, int a5, __int16 bgr) -{ - stru167_wrap *v6; // edi@1 - int i; // esi@1 - int v8; // ST08_4@2 - int v9; // ST04_4@2 - int v10; // eax@2 - - v6 = this; - for ( i = 0; i < rand() % 6 + 5; ++i ) - { - v8 = z + rand() % 33; - v9 = rand() % 33 + y - 16; - v10 = rand(); - Push(v10 % 33 + x - 16, v9, v8, a5, bgr); - } -} - -//----- (00440F07) -------------------------------------------------------- -void stru167_wrap::_440F07() -{ - for (uint i = 0; i < 100; ++i) - { - if (pElements[i].field_C_time_left > 0) - { - pElements[i].field_A_rnd_value += rand() % 5 + 4; - pElements[i].field_6_rnd_value += rand() % 5 - 2; - pElements[i].field_8_rnd_value += rand() % 5 - 2; - pElements[i].field_C_time_left -= (short)pEventTimer->uTimeElapsed; - } - } + this->field_28 = ((unsigned __int64)(this->field_18 * (signed __int64)this->field_0_party_dir_x) >> 16) + + ((unsigned __int64)(this->field_1C * (signed __int64)this->field_4_party_dir_y) >> 16) + + ((unsigned __int64)(this->field_20 * (signed __int64)this->field_8) >> 16); } //----- (0044100D) -------------------------------------------------------- @@ -10954,126 +6495,126 @@ { if ( !_strnicmp(test_string, "wea", 3) ) { - p2DEvents[i].uType = BildingType_WeaponShop; + p2DEvents[i].uType = BuildingType_WeaponShop; break; } if ( !_strnicmp(test_string, "arm", 3) ) { - p2DEvents[i].uType = BildingType_ArmorShop; + p2DEvents[i].uType = BuildingType_ArmorShop; break; } if ( !_strnicmp(test_string, "mag", 3) ) { - p2DEvents[i].uType = BildingType_MagicShop; + p2DEvents[i].uType = BuildingType_MagicShop; break; } if ( !_strnicmp(test_string, "alc", 3) ) { - p2DEvents[i].uType = BildingType_AlchemistShop; + p2DEvents[i].uType = BuildingType_AlchemistShop; break; } if ( !_strnicmp(test_string, "sta", 3) ) { - p2DEvents[i].uType = BildingType_Stables; + p2DEvents[i].uType = BuildingType_Stables; break; } if ( !_strnicmp(test_string, "boa", 3) ) { - p2DEvents[i].uType = BildingType_Boats; + p2DEvents[i].uType = BuildingType_Boats; break; } if ( !_strnicmp(test_string, "tem", 3) ) { - p2DEvents[i].uType = BildingType_Temple; + p2DEvents[i].uType = BuildingType_Temple; break; } if ( !_strnicmp(test_string, "tra", 3) ) { - p2DEvents[i].uType = BildingType_Training; + p2DEvents[i].uType = BuildingType_Training; break; } if ( !_strnicmp(test_string, "tow", 3) ) { - p2DEvents[i].uType = BildingType_TownHall; + p2DEvents[i].uType = BuildingType_TownHall; break; } if ( !_strnicmp(test_string, "tav", 3) ) { - p2DEvents[i].uType = BildingType_Tavern; + p2DEvents[i].uType = BuildingType_Tavern; break; } if ( !_strnicmp(test_string, "ban", 3) ) { - p2DEvents[i].uType = BildingType_Bank; + p2DEvents[i].uType = BuildingType_Bank; break; } if ( !_strnicmp(test_string, "fir", 3) ) { - p2DEvents[i].uType = BildingType_FireGuild; + p2DEvents[i].uType = BuildingType_FireGuild; break; } if ( !_strnicmp(test_string, "air", 3) ) { - p2DEvents[i].uType = BildingType_AirGuild; + p2DEvents[i].uType = BuildingType_AirGuild; break; } if ( !_strnicmp(test_string, "wat", 3) ) { - p2DEvents[i].uType = BildingType_WaterGuild; + p2DEvents[i].uType = BuildingType_WaterGuild; break; } if ( !_strnicmp(test_string, "ear", 3) ) { - p2DEvents[i].uType = BildingType_EarthGuild; + p2DEvents[i].uType = BuildingType_EarthGuild; break; } if ( !_strnicmp(test_string, "spi", 3) ) { - p2DEvents[i].uType = BildingType_SpiritGuild; + p2DEvents[i].uType = BuildingType_SpiritGuild; break; } if ( !_strnicmp(test_string, "min", 3) ) { - p2DEvents[i].uType = BildingType_MindGuild; + p2DEvents[i].uType = BuildingType_MindGuild; break; } if ( !_strnicmp(test_string, "bod", 3) ) { - p2DEvents[i].uType = BildingType_BodyGuild; + p2DEvents[i].uType = BuildingType_BodyGuild; break; } if ( !_strnicmp(test_string, "lig", 3) ) { - p2DEvents[i].uType = BildingType_LightGuild; + p2DEvents[i].uType = BuildingType_LightGuild; break; } if ( !_strnicmp(test_string, "dar", 3) ) { - p2DEvents[i].uType = BildingType_DarkGuild; + p2DEvents[i].uType = BuildingType_DarkGuild; break; } if ( !_strnicmp(test_string, "ele", 3) ) { - p2DEvents[i].uType = BildingType_14; + p2DEvents[i].uType = BuildingType_14; break; } if ( !_strnicmp(test_string, "sel", 3) ) { - p2DEvents[i].uType = BildingType_15; + p2DEvents[i].uType = BuildingType_15; break; } if ( !_strnicmp(test_string, "mir", 3) ) { - p2DEvents[i].uType = BildingType_16; + p2DEvents[i].uType = BuildingType_16; break; } if ( !_strnicmp(test_string, "mer", 3) ) { - p2DEvents[i].uType = BildingType_TownHall; + p2DEvents[i].uType = BuildingType_TownHall; break; } - p2DEvents[i].uType = BildingType_18; + p2DEvents[i].uType = BuildingType_18; } break; @@ -11362,7 +6903,7 @@ } //----- (00444360) -------------------------------------------------------- -void __thiscall Level_LoadEvtAndStr(const char *pLevelName) +void Level_LoadEvtAndStr(const char *pLevelName) { char pContainerName[120]; // [sp+8h] [bp-98h]@1 @@ -11460,7 +7001,7 @@ } //----- (00444D80) -------------------------------------------------------- -signed int __cdecl GetTravelTime() +int GetTravelTime() { signed int v0; // esi@1
--- a/mm7_4.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/mm7_4.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -12,8 +12,6 @@ #include "OutdoorCamera.h" #include "Mouse.h" #include "stru6.h" -#include "stru11.h" -#include "stru12.h" #include "LightmapBuilder.h" #include "MM7.h" @@ -391,37 +389,41 @@ } v22 = 0; v38 = v5; - if ( v39 <= (signed int)v5 ) - goto LABEL_54; - v23 = 0; - do + if ( v39 > (signed int)v5 ) { - v24 = dword_720F20[v5 / 4]; - v25 = *(int *)((char *)dword_720F20.data() + v23); - if ( v24 == v25 ) - goto LABEL_50; - if ( v25 > a3 + 15 ) - { - if ( v24 >= v25 ) - goto LABEL_51; -LABEL_50: - v22 = v38; - v23 = v5; - goto LABEL_51; - } - if ( v24 > v25 && v24 <= a3 + 15 ) - goto LABEL_50; -LABEL_51: - ++v38; - v5 += 4; + v23 = 0; + do + { + v24 = dword_720F20[v5 / 4]; + v25 = *(int *)((char *)dword_720F20.data() + v23); + if ( v24 == v25 ) + { + v22 = v38; + v23 = v5; + } + else if ( v25 > a3 + 15 ) + { + if ( v24 < v25 ) + { + v22 = v38; + v23 = v5; + } + } + else if ( v24 > v25 && v24 <= a3 + 15 ) + { + v22 = v38; + v23 = v5; + } + ++v38; + v5 += 4; + } + while ( v38 < v39 ); + if ( v22 ) + { + *(int *)a4 = dword_720E80[v22] | (dword_720ED0[v22] << 6); + return dword_720F20[v22]; + } } - while ( v38 < v39 ); - if ( v22 ) - { - *(int *)a4 = dword_720E80[v22] | (dword_720ED0[v22] << 6); - return dword_720F20[v22]; - } -LABEL_54: *(int *)a4 = 0; return dword_720F20[v22]; } @@ -529,264 +531,11 @@ } } -//----- (00486F92) -------------------------------------------------------- -void __cdecl sr_sub_486F92_MessWithEdgesAndSpans() -{ - Span *v0; // ebx@1 - int v1; // eax@2 - Edge *v2; // ecx@3 - Edge *v3; // edx@3 - Edge *v4; // esi@6 - Edge *v5; // eax@7 - Edge *v6; // ecx@8 - Surf *v7; // esi@11 - double v8; // st7@13 - Surf *v9; // edi@13 - double v10; // st6@13 - double v11; // st7@14 - signed __int64 v12; // qax@14 - stru148 *v13; // eax@15 - Span *v14; // ecx@17 - double v15; // st7@28 - signed __int64 v16; // qax@28 - stru148 *v17; // eax@29 - Span *v18; // ecx@31 - Edge *i; // eax@40 - Edge *v20; // ecx@43 - Edge *v21; // esi@44 - double v22; // st7@45 - Edge *v23; // edx@48 - unsigned int v24; // [sp+10h] [bp-10h]@2 - float v25; // [sp+14h] [bp-Ch]@3 - Edge *v26; // [sp+18h] [bp-8h]@8 - unsigned int v27; // [sp+1Ch] [bp-4h]@1 - - v0 = pSpans; - stru_80C9D8.pSurf = &stru_80C980; - stru_80C9D8.field_0 = (double)(signed int)pViewport->uViewportTL_X; - stru_80C9A4.pSurf = &stru_80C980; - stru_80C980.pPrev = &stru_80C980; - stru_80C980.pNext = &stru_80C980; - stru_80C9A4.field_0 = (double)(signed int)pViewport->uViewportBR_X; - stru_80C980.field_8 = 0.0; - stru_80C980.field_4 = 0.0; - stru_80C9D8.pNext = &stru_80C9A4; - stru_80C9D8.pPrev = 0; - stru_80C9D8.field_8 = 1; - stru_80C9A4.pNext = 0; - stru_80C9A4.pPrev = &stru_80C9D8; - stru_80C9A4.field_8 = 0; - LODWORD(stru_80C980.field_0) = 0xC97423F0u; - v27 = pViewport->uViewportTL_Y; - if ( (signed int)pViewport->uViewportTL_Y > (signed int)pViewport->uViewportBR_Y ) - { -LABEL_51: - v0->field_8 = -1; - } - else - { - v1 = 52 * pViewport->uViewportTL_Y; - v24 = 52 * pViewport->uViewportTL_Y; - while ( 1 ) - { - v2 = *(Edge **)((char *)&pNewEdges->pNext + v1); - v3 = &stru_80C9D8; - v25 = (double)(signed int)v27; - if ( v2 != &defaultEdge ) - { - do - { - while ( 1 ) - { - v4 = v3->pNext; - if ( v2->field_0 <= (double)v4->field_0 ) - break; - v3 = v3->pNext; - } - v5 = v2->pNext; - v2->pNext = v4; - v2->pPrev = v3; - v3->pNext->pPrev = v2; - v3->pNext = v2; - v3 = v2; - v2 = v5; - } - while ( v5 != &defaultEdge ); - } - v6 = stru_80C9D8.pNext; - stru_80C980.field_20 = 0; - stru_80C980.field_22 = 1; - v26 = stru_80C9D8.pNext; - if ( stru_80C9D8.pNext ) - { - while ( 1 ) - { - v7 = v6->pSurf; - if ( v6->field_8 ) - { - ++v7->field_22; - if ( v7->field_22 == 1 ) - { - v8 = v6->field_0 + 2.0; - v9 = stru_80C980.pNext; - v10 = (v8 - v7->field_C) * v7->field_4 + (v25 - v7->field_10) * v7->field_8 + v7->field_0; - if ( v10 <= (v8 - stru_80C980.pNext->field_C) * stru_80C980.pNext->field_4 - + (v25 - stru_80C980.pNext->field_10) * stru_80C980.pNext->field_8 - + stru_80C980.pNext->field_0 ) - { - do - v9 = v9->pNext; - while ( v10 <= (v8 - v9->field_C) * v9->field_4 + (v25 - v9->field_10) * v9->field_8 + v9->field_0 ); - v7->pNext = v9; - v7->pPrev = v9->pPrev; - v9->pPrev->pNext = v7; - v9->pPrev = v7; - } - else - { - v11 = v6->field_0 + 0.5; - v12 = (signed __int64)(v11 - (double)stru_80C980.pNext->field_20); - v0->field_C = v12; - if ( (signed __int16)v12 > 0 ) - { - v0->field_A = v27; - v0->field_8 = v9->field_20; - v13 = v9->pParent; - v0->pParent = v13; - if ( v13 ) - { - if ( v13->prolly_head ) - { - v14 = v13->prolly_tail; - if ( !v14 ) - return; - v14->pNext = v0; - } - else - { - v13->prolly_head = v0; - } - v13->prolly_tail = v0; - } - if ( (signed int)pOutdoorCamera->uNumSpans >= 12499 ) - return; - ++v0; - ++pOutdoorCamera->uNumSpans; - } - v6 = v26; - v7->field_20 = (signed __int64)v11; - v7->pNext = v9; - v9->pPrev = v7; - stru_80C980.pNext = v7; - v7->pPrev = &stru_80C980; - } - } - } - else - { - --v7->field_22; - if ( !v7->field_22 ) - { - if ( stru_80C980.pNext == v7 ) - { - v15 = v6->field_0 + 0.5; - v16 = (signed __int64)(v15 - (double)v7->field_20); - v0->field_C = v16; - if ( (signed __int16)v16 > 0 ) - { - v0->field_A = v27; - v0->field_8 = v7->field_20; - v17 = v7->pParent; - v0->pParent = v17; - if ( v17 ) - { - if ( v17->prolly_head ) - { - v18 = v17->prolly_tail; - if ( !v18 ) - return; - v18->pNext = v0; - } - else - { - v17->prolly_head = v0; - } - v17->prolly_tail = v0; - } - if ( (signed int)pOutdoorCamera->uNumSpans >= 12499 ) - return; - ++v0; - ++pOutdoorCamera->uNumSpans; - } - v7->pNext->field_20 = (signed __int64)v15; - v6 = v26; - } - v7->pNext->pPrev = v7->pPrev; - v7->pPrev->pNext = v7->pNext; - } - } - v26 = v6->pNext; - if ( !v26 ) - break; - v6 = v6->pNext; - } - } - for ( i = ptr_80CA10[v27]; i; i = i->ptr_18 ) - { - i->pPrev->pNext = i->pNext; - i->pNext->pPrev = i->pPrev; - } - v20 = stru_80C9D8.pNext; - if ( stru_80C9D8.pNext != &stru_80C9A4 ) - break; -LABEL_50: - ++v27; - v1 = v24 + 52; - v24 += 52; - if ( (signed int)v27 > (signed int)pViewport->uViewportBR_Y ) - goto LABEL_51; - } - while ( 1 ) - { - v21 = v20->pNext; - if ( !v21 ) - break; - v22 = v20->field_4 + v20->field_0; - v20->field_0 = v22; - if ( v22 < stru_80C9D8.field_0 ) - v20->field_0 = stru_80C9D8.field_0 + 0.0000001; - while ( 1 ) - { - v23 = v20->pPrev; - if ( v20->field_0 >= (double)v23->field_0 ) - break; - v23->pNext = v20->pNext; - v20->pNext->pPrev = v23; - v23->pPrev->pNext = v20; - v20->pPrev = v23->pPrev; - v20->pNext = v23; - v23->pPrev = v20; - } - v20 = v21; - if ( v21 == &stru_80C9A4 ) - goto LABEL_50; - } - } -} -// 4EC3EC: using guessed type Edge defaultEdge; - //----- (00487DA9) -------------------------------------------------------- void __cdecl sub_487DA9() { - char *v0; // eax@1 - - v0 = &array_77EC08[0].field_108; - do - { - *v0 = 0; - v0 += 268; - } - while ( (signed int)v0 < (signed int)&pVerticesSR_801A10[4] ); + for (int i = 0; i < 20000; ++i) + array_77EC08[i].field_108 = 0; } //----- (00487DBE) -------------------------------------------------------- @@ -814,170 +563,6 @@ } while ( v2 ); } -// 4EC3EC: using guessed type Edge defaultEdge; - -//----- (0048958E) -------------------------------------------------------- -stru12_MemoryBlock::stru12_MemoryBlock(int a2) -{ - stru12_MemoryBlock *v2; // esi@1 - void *v3; // eax@1 - void *v4; // ecx@1 - stru12_MemoryBlock *result; // eax@1 - - v2 = this; - v3 = operator new(8 * a2 + 16); - v2->pBlockBase = v3; - v4 = (char *)v3 + PID_TYPE(-(signed int)v3); - result = v2; - v2->pAlignedBlock = v4; -} - -//----- (004895B7) -------------------------------------------------------- -stru12::stru12(stru11 *pStru11) -{ - stru12 *v2; // esi@1 - - v2 = this; - this->field_44 = 0x41000000u; - this->field_4C = 0x46000000u; - //this->vdestructor_ptr = stru12::_4898E6; - this->field_48 = 0; - this->field_50 = 0; - this->field_54 = 0x33D6BF95u; - this->field_58 = 0; - - for (int i = 0; i < 12; ++i) - v2->pMemBlocks[i] = new stru12_MemoryBlock(640); -} - -//----- (00489810) -------------------------------------------------------- -stru12::~stru12() -{ - for (int i = 0; i < 12; ++i) - delete pMemBlocks[i]; -} - -//----- (004898BF) -------------------------------------------------------- -stru12_MemoryBlock::~stru12_MemoryBlock() -{ - stru12_MemoryBlock *v2; // esi@1 - void *v3; // ST00_4@1 - - v2 = this; - v3 = this->pBlockBase; - this->pAlignedBlock = 0; - free(v3); - v2->pBlockBase = 0; - /*if ( a2 & 1 ) - free(v2);*/ -} - -//----- (004898E6) -------------------------------------------------------- -void stru12::_4898E6() -{ - void *v1; // eax@1 - void *v2; // edx@1 - char *v3; // edi@2 - double v4; // st7@2 - char *v5; // ebx@2 - double v6; // st6@3 - double v7; // st5@3 - double v8; // st4@3 - int v9; // esi@3 - double v10; // st3@3 - float v11; // ST34_4@5 - double v12; // st6@10 - double v13; // ST0C_8@10 - char *v14; // [sp+14h] [bp-44h]@2 - char *v15; // [sp+18h] [bp-40h]@2 - char *v16; // [sp+1Ch] [bp-3Ch]@2 - char *v17; // [sp+20h] [bp-38h]@2 - char *v18; // [sp+24h] [bp-34h]@2 - float v19; // [sp+30h] [bp-28h]@3 - float v20; // [sp+38h] [bp-20h]@3 - char *v21; // [sp+3Ch] [bp-1Ch]@2 - int v22; // [sp+40h] [bp-18h]@1 - char *v23; // [sp+44h] [bp-14h]@2 - char *v24; // [sp+48h] [bp-10h]@2 - int v25; // [sp+4Ch] [bp-Ch]@2 - float v26; // [sp+50h] [bp-8h]@3 - float v27; // [sp+54h] [bp-4h]@3 - - __debugbreak(); - v22 = 0; - v1 = this->pMemBlocks[1]->pAlignedBlock; - v2 = this->pMemBlocks[6]->pAlignedBlock; - if ( this->field_8C > 0 ) - { - v24 = (char *)((char *)pMemBlocks[0]->pAlignedBlock - v1); - v23 = (char *)((char *)pMemBlocks[2]->pAlignedBlock - v1); - v18 = (char *)((char *)pMemBlocks[7]->pAlignedBlock - v2); - v17 = (char *)((char *)pMemBlocks[8]->pAlignedBlock - v2); - v25 = (int)v1 - (int)v2; - v16 = (char *)((char *)pMemBlocks[9]->pAlignedBlock - v2); - v3 = (char *)((char *)pMemBlocks[4]->pAlignedBlock - v2); - v15 = (char *)((char *)pMemBlocks[10]->pAlignedBlock - v2); - v4 = 1.0; - v5 = (char *)((char *)pMemBlocks[5]->pAlignedBlock - v2); - v21 = (char *)((char *)pMemBlocks[3]->pAlignedBlock - v2); - v14 = (char *)((char *)pMemBlocks[11]->pAlignedBlock - v2); - do - { - v26 = *(float *)&v24[(int)((char *)v2 + v25)] - (double)pIndoorCamera->pos.x; - v27 = *(float *)((char *)v2 + v25) - (double)pIndoorCamera->pos.y; - v6 = *(float *)&v23[(int)((char *)v2 + v25)] - (double)pIndoorCamera->pos.z; - v7 = pIndoorCamera->fRotationYCosine; - v8 = pIndoorCamera->fRotationYSine; - v20 = pIndoorCamera->fRotationXCosine; - v19 = pIndoorCamera->fRotationXSine; - v9 = (int)((char *)v2 + (int)v21); - v10 = v27 * pIndoorCamera->fRotationYSine + pIndoorCamera->fRotationYCosine * v26; - if ( pIndoorCamera->sRotationX ) - { - v11 = v10; - *(float *)v9 = v11 * pIndoorCamera->fRotationXCosine + pIndoorCamera->fRotationXSine * v6; - *(float *)((char *)v2 + (int)v3) = v7 * v27 - v8 * v26; - *(float *)((char *)v2 + (int)v5) = v20 * v6 - v11 * v19; - } - else - { - *(float *)v9 = v10; - *(float *)((char *)v2 + (int)v3) = v7 * v27 - v8 * v26; - *(float *)((char *)v2 + (int)v5) = v6; - } - if ( *(float *)v9 >= 8.0 ) - { - if ( (double)pOutdoorCamera->shading_dist_mist >= *(float *)v9 ) - { - *(int *)v2 = 0; - v12 = v4 / (*(float *)v9 + 0.0000001) * (double)pOutdoorCamera->int_fov_rad; - *(float *)((char *)v2 + (int)v18) = (double)pViewport->uScreenCenterX - - v12 * *(float *)((char *)v2 + (int)v3); - *(float *)((char *)v2 + (int)v17) = (double)pViewport->uScreenCenterY - - v12 * *(float *)((char *)v2 + (int)v5); - *(float *)((char *)v2 + (int)v16) = v4 - - v4 / (*(float *)v9 * 1000.0 / (double)pOutdoorCamera->shading_dist_mist); - *(float *)((char *)v2 + (int)v15) = v4 / (*(float *)v9 + 0.0000001); - v13 = *(float *)v9 + 6.7553994e15; - v4 = 1.0; - *(int *)((char *)v2 + (int)v14) = LODWORD(v13); - } - else - { - *(int *)v2 = 2; - } - } - else - { - *(int *)v2 = 1; - } - ++v22; - v2 = (char *)v2 + 4; - } - while ( v22 < this->field_8C ); - } - this->field_8C = 0; -} //----- (0048A959) -------------------------------------------------------- unsigned int ReplaceHSV(unsigned int uColor, float h_replace, float s_replace, float v_replace) @@ -997,9 +582,9 @@ v = v_replace; HSV2RGB(&r, &g, &b, h, s, v); - return (((uint)floorf(r * 255.0f + 0.5f) & 0xFF) << 16) | - (((uint)floorf(g * 255.0f + 0.5f) & 0xFF) << 8) | - ((uint)floorf(b * 255.0f + 0.5f) & 0xFF); + return (((uint)round(r * 255.0f) & 0xFF) << 16) | + (((uint)round(g * 255.0f) & 0xFF) << 8) | + (((uint)round(b * 255.0f) & 0xFF)); } //----- (0048B561) -------------------------------------------------------- @@ -1302,7 +887,7 @@ { //v23 = v21->pEquipment.pIndices; auto _idx = v21->pEquipment.pIndices[v22]; - v24 = v21->pInventoryItems[_idx].uItemID; + v24 = v21->pInventoryItemList[_idx].uItemID; if ( v24 > 134 ) { if ( v24 == 529 ) @@ -1321,7 +906,7 @@ } else { - v25 = v21->pInventoryItems[_idx].uSpecEnchantmentType; + v25 = v21->pInventoryItemList[_idx].uSpecEnchantmentType; if ( v25 <= 50 ) { if ( v25 != 50 ) @@ -1369,7 +954,7 @@ if ( v48 ) { v31 = 0; - v32 = (char *)v21->pInventoryItems; + v32 = (char *)v21->pInventoryItemList; while ( *(int *)v32 != 601 || (unsigned __int8)v32[26] != v49 + 1 ) { ++v31; @@ -1523,9 +1108,9 @@ //void *v10; // esi@25 unsigned int v11; // ecx@27 signed int v12; // edi@29 - Player *v13; // ecx@30 - Player *v14; // esi@35 - double v15; // st7@35 + //Player *v13; // ecx@30 + //Player *v14; // esi@35 + //double v15; // st7@35 Player **v16; // esi@43 Player *v17; // edi@44 double v18; // st7@44 @@ -1568,7 +1153,7 @@ //unsigned int v55; // [sp-8h] [bp-38h]@18 unsigned int v56; // [sp-8h] [bp-38h]@55 //int v57; // [sp-4h] [bp-34h]@18 - int v58; // [sp-4h] [bp-34h]@33 + //int v58; // [sp-4h] [bp-34h]@33 int v59; // [sp-4h] [bp-34h]@55 //unsigned int v60; // [sp+10h] [bp-20h]@1 unsigned int v61; // [sp+14h] [bp-1Ch]@1 @@ -1638,45 +1223,46 @@ } v11 = LODWORD(pParty->uTimePlayed); - if ( pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed ) + if ( pParty->uFlags & 4 && pParty->field_6FC < (signed __int64)pParty->uTimePlayed )//water damage error { - v12 = 1; + //v12 = 1; pParty->field_6FC = LODWORD(pParty->uTimePlayed) + 128; viewparams->bRedrawGameUI = 1; - while ( 1 ) + //while ( 1 ) + for ( v12 = 1; v12 <= 4; ++v12 ) { if ( pPlayers[v12]->WearsItem(ITEM_RELIC_HARECS_LEATHER, EQUIP_ARMOUR) || pPlayers[v12]->HasEnchantedItemEquipped(71) || pPlayers[v12]->pPlayerBuffs[23].uExpireTime > 0 ) { - v58 = 0; + //v58 = 0; + pPlayers[v12]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); } else { - v58 = 0; + //v58 = 0; if ( !sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(v12) ) { - v14 = pPlayers[v12]; - v15 = (double)pPlayers[v12]->GetMaxHealth() * 0.1; - v14->ReceiveDamage((signed __int64)v15, DMGT_FIRE); + //v14 = pPlayers[v12]; + //v15 = (double)pPlayers[v12]->GetMaxHealth() * 0.1; + pPlayers[v12]->ReceiveDamage((signed __int64)pPlayers[v12]->GetMaxHealth() * 0.1, DMGT_FIRE); if ( pParty->uFlags & 4 ) { strcpy(GameUI_Footer_TimedString.data(), pGlobalTXT_LocalizationStrings[660]); GameUI_Footer_TimeLeft = 128; } - goto LABEL_39; } - v13 = pPlayers[v12]; + else + pPlayers[v12]->PlayEmotion(CHARACTER_EXPRESSION_37, 0); } - v13->PlayEmotion(CHARACTER_EXPRESSION_37, v58); -LABEL_39: - ++v12; - if ( v12 > 4 ) - { - v11 = LODWORD(pParty->uTimePlayed); - break; + //++v12; + //if ( v12 > 4 ) + //{ + //v11 = LODWORD(pParty->uTimePlayed); + //break; } - } + v11 = LODWORD(pParty->uTimePlayed); + //} } if ( pParty->uFlags & 0x200 && pParty->field_6FC < (signed __int64)__PAIR__(HIDWORD(pParty->uTimePlayed), v11) ) { @@ -1718,18 +1304,19 @@ if ( v21->GetItemsBonus(CHARACTER_ATTRIBUTE_ENDURANCE, 0) + v22 + v21->uEndurance >= 1 || (signed __int64)v21->pPlayerBuffs[11].uExpireTime > 0 ) { - if ( v22 >= 1 ) - goto LABEL_59; - v59 = 0; - v56 = 13; + if ( v22 < 1 ) + { + v59 = 0; + v56 = 13; + v21->SetCondition(v56, v59); + } } else { v59 = 0; v56 = 14; + v21->SetCondition(v56, v59); } - v21->SetCondition(v56, v59); -LABEL_59: v23 = (int)&v21->field_E0; if ( v21->field_E0 ) { @@ -2017,7 +1604,6 @@ result = 0; if ( (signed int)this->uNumFrames <= 0 ) { -LABEL_5: result = 0; } else @@ -2028,7 +1614,7 @@ ++result; ++v4; if ( (signed int)result >= (signed int)_uNumFrames ) - goto LABEL_5; + return 0; } } return result; @@ -2270,7 +1856,11 @@ dword_AE336C = a1; v10 = 0; if ( (signed int)pNPCStats->uNumNPCNames[v4] <= 0 ) - goto LABEL_17; + { + v3 = rand() % (signed int)pNPCStats->uNumNPCNames[v4]; + } + else + { v9 = (int **)((char *)pNPCStats->pNPCNames + v4 * 4); do { @@ -2289,8 +1879,8 @@ if ( v8 && v8 != v7 ) v3 = v8 + rand() % (v7 - v8); else -LABEL_17: v3 = rand() % (signed int)pNPCStats->uNumNPCNames[v4]; + } } dword_AE3370 = v3; return pNPCStats->pNPCNames[0][v11 + 2 * v3]; @@ -2314,7 +1904,7 @@ } //----- (00495461) -------------------------------------------------------- -char *BuilDialogueString(char *lpsz, unsigned __int8 uPlayerID, ItemGen *a3, char *a4, int a5, __int64 *a6) +char *BuildDialogueString(char *lpsz, unsigned __int8 uPlayerID, ItemGen *a3, char *a4, int a5, __int64 *a6) { unsigned __int8 v6; // bl@1 Player *pPlayer; // ebx@3 @@ -2512,10 +2102,34 @@ goto _continue_strcat; case 11: v25 = GetPartyReputation(); - goto LABEL_46; + if ( v25 >= 25 ) + { + v11 = pGlobalTXT_LocalizationStrings[379]; + } + else + { + if ( v25 < 6 ) + { + if ( v25 >= -5 ) + { + v11 = pGlobalTXT_LocalizationStrings[399]; + } + else + { + if ( v25 < -24 ) + v11 = pGlobalTXT_LocalizationStrings[434]; + else + v11 = pGlobalTXT_LocalizationStrings[402]; + } + } + else + { + v11 = pGlobalTXT_LocalizationStrings[392]; + } + } + goto _continue_strcat; case 12: v25 = npc->rep; -LABEL_46: if ( v25 >= 25 ) { v11 = pGlobalTXT_LocalizationStrings[379]; @@ -2609,7 +2223,7 @@ case 24: { v46 = a3->GetDisplayName(); - sprintf(a1, format_4E2D80, v59, v46); + sprintfex(a1, format_4E2D80, v59, v46); v11 = a1; goto _continue_strcat; } @@ -2683,7 +2297,7 @@ } } _continue_sprintf: - sprintf(a1, "%lu", v29); + sprintfex(a1, "%lu", v29); v11 = a1; goto _continue_strcat; } @@ -2718,7 +2332,7 @@ v54 = v57.field_18_expire_year; v53 = v57.field_C_expire_day + 1; v50 = v57.field_14_exprie_month; - sprintf(a1, pGlobalTXT_LocalizationStrings[378], aMonthNames[v50], v53, v54); + sprintfex(a1, pGlobalTXT_LocalizationStrings[378], aMonthNames[v50], v53, v54); v11 = a1; goto _continue_strcat; } @@ -2742,7 +2356,7 @@ v54 = v56.field_18_expire_year; v53 = v56.field_C_expire_day + 1; v50 = v56.field_14_exprie_month; - sprintf(a1, pGlobalTXT_LocalizationStrings[378], aMonthNames[v50], v53, v54); + sprintfex(a1, pGlobalTXT_LocalizationStrings[378], aMonthNames[v50], v53, v54); v11 = a1; goto _continue_strcat; } @@ -3310,1682 +2924,28 @@ } //----- (004A7063) -------------------------------------------------------- -int __thiscall sub_4A7063(unsigned int uDiffuse, float a2) +unsigned int ModulateColor(unsigned int diffuse, float multiplier) { - float v2; // ST1C_4@1 - double v3; // ST14_8@1 - signed int v4; // ebx@1 - float v5; // ST1C_4@1 - double v6; // ST14_8@1 - signed int v7; // edi@1 - double v8; // ST0C_8@1 - signed int v9; // esi@1 - signed int v10; // ecx@1 - double v12; // [sp+8h] [bp-18h]@1 - unsigned __int64 v13; // [sp+18h] [bp-8h]@1 + float alpha = multiplier * ((diffuse >> 24) & 0xFF); + int a = (int)floorf(alpha + 0.5f); + a = max(0, min(255, a)); - v2 = (double)(uDiffuse >> 24) * a2; - v3 = v2 + 6.7553994e15; - v4 = LODWORD(v3); - v5 = (double)((uDiffuse >> 16) & 0xFF) * a2; - v6 = v5 + 6.7553994e15; - v7 = LODWORD(v6); - *((float *)&v6 + 1) = (double)((unsigned __int16)uDiffuse >> 8) * a2; - v8 = *((float *)&v6 + 1) + 6.7553994e15; - v13 = __PAIR__(LODWORD(v6), LODWORD(v8)); - v9 = LODWORD(v8); - *((float *)&v6 + 1) = (double)(unsigned __int8)uDiffuse * a2; - v12 = *((float *)&v6 + 1) + 6.7553994e15; - v10 = LODWORD(v12); - if ( v4 > 255 ) - v4 = 255; - if ( v4 < 0 ) - v4 = 0; - if ( SHIDWORD(v13) > 255 ) - v7 = 255; - if ( v7 < 0 ) - v7 = 0; - if ( (signed int)v13 > 255 ) - v9 = 255; - if ( v9 < 0 ) - v9 = 0; - if ( SLODWORD(v12) > 255 ) - v10 = 255; - if ( v10 < 0 ) - v10 = 0; - return v10 | ((v9 | ((v7 | (v4 << 8)) << 8)) << 8); + float red = multiplier * ((diffuse >> 16) & 0xFF); + int r = (int)floorf(red + 0.5f); + r = max(0, min(255, r)); + + float green = multiplier * ((diffuse >> 8) & 0xFF); + int g = (int)floorf(green + 0.5f); + g = max(0, min(255, g)); + + float blue = multiplier * ((diffuse >> 0) & 0xFF); + int b = (int)floorf(blue + 0.5f); + b = max(0, min(255, b)); + + return (a << 24) | (r << 16) | (g << 8) | b; } -//----- (004AD504) -------------------------------------------------------- -int __fastcall sub_4AD504(signed int sFaceID) -{ - int result; // eax@1 - signed int v2; // ebx@1 - BLVFace *v3; // esi@3 - Texture *v4; // edi@6 - int v5; // eax@7 - int v6; // edx@7 - int v7; // ecx@7 - int v8; // ebx@8 - int v9; // eax@8 - int v10; // ebx@8 - unsigned int v11; // ebx@9 - int v12; // esi@10 - int v13; // eax@13 - unsigned __int16 *v14; // eax@13 - unsigned int v15; // eax@14 - unsigned __int16 *v16; // ebx@14 - int v17; // eax@15 - int v18; // ebx@15 - int v19; // esi@15 - int v20; // ecx@15 - int v21; // eax@15 - stru193_math *v22; // ebx@15 - int v23; // eax@15 - char *v24; // esi@16 - int v25; // eax@18 - int v26; // eax@18 - int v27; // eax@20 - signed int v28; // esi@20 - signed int v29; // edx@20 - signed int v30; // esi@20 - signed int v31; // edi@20 - int v32; // esi@20 - int v33; // eax@26 - int *v34; // esi@27 - unsigned __int16 *v35; // edi@27 - unsigned int v36; // edx@27 - int v37; // ebx@27 - char v38; // cl@27 - char v39; // ch@27 - int v40; // ebx@29 - int v41; // edx@29 - unsigned int v42; // ebx@30 - int v43; // edx@30 - int v44; // eax@33 - int *v45; // esi@34 - unsigned __int16 *v46; // edi@34 - unsigned int v47; // edx@34 - int v48; // ebx@34 - char v49; // cl@34 - char v50; // ch@34 - int v51; // ebx@36 - int v52; // edx@36 - unsigned __int16 v53; // bx@37 - int v54; // edx@37 - int v55; // eax@40 - int v56; // eax@41 - int *v57; // esi@42 - unsigned __int16 *v58; // edi@42 - unsigned int v59; // edx@42 - int v60; // ebx@42 - char v61; // cl@42 - char v62; // ch@42 - unsigned int v63; // ebx@44 - int v64; // edx@44 - unsigned int v65; // ebx@44 - int v66; // edx@44 - unsigned int v67; // ebx@45 - int v68; // edx@45 - int v69; // ebx@45 - int v70; // edx@45 - int v71; // eax@48 - int *v72; // esi@49 - unsigned __int16 *v73; // edi@49 - unsigned int v74; // edx@49 - int v75; // ebx@49 - char v76; // cl@49 - char v77; // ch@49 - unsigned int v78; // ebx@51 - int v79; // edx@51 - unsigned int v80; // ebx@51 - int v81; // edx@51 - unsigned int v82; // ebx@52 - int v83; // edx@52 - int v84; // ebx@52 - int v85; // edx@52 - unsigned __int8 *v86; // [sp+Ch] [bp-98h]@9 - unsigned __int8 *v87; // [sp+10h] [bp-94h]@9 - unsigned __int8 *v88; // [sp+14h] [bp-90h]@9 - unsigned __int8 *v89; // [sp+18h] [bp-8Ch]@9 - int v90; // [sp+1Ch] [bp-88h]@20 - BLVFace *v91; // [sp+20h] [bp-84h]@3 - int v92; // [sp+24h] [bp-80h]@7 - int i; // [sp+28h] [bp-7Ch]@7 - unsigned __int16 *v94; // [sp+2Ch] [bp-78h]@9 - unsigned int v95; // [sp+30h] [bp-74h]@1 - Texture *v96; // [sp+34h] [bp-70h]@6 - int v97; // [sp+38h] [bp-6Ch]@15 - unsigned int v98; // [sp+3Ch] [bp-68h]@9 - int v99; // [sp+40h] [bp-64h]@9 - int v100; // [sp+44h] [bp-60h]@24 - int v101; // [sp+48h] [bp-5Ch]@10 - int v102; // [sp+4Ch] [bp-58h]@20 - int v103; // [sp+50h] [bp-54h]@20 - int v104; // [sp+54h] [bp-50h]@9 - unsigned __int8 *v105; // [sp+58h] [bp-4Ch]@20 - int v106; // [sp+5Ch] [bp-48h]@24 - int v107; // [sp+60h] [bp-44h]@20 - int v108; // [sp+64h] [bp-40h]@20 - int v109; // [sp+68h] [bp-3Ch]@20 - int v110; // [sp+6Ch] [bp-38h]@15 - int v111; // [sp+70h] [bp-34h]@20 - int a1; // [sp+74h] [bp-30h]@12 - int a2; // [sp+78h] [bp-2Ch]@9 - int *v114; // [sp+7Ch] [bp-28h]@16 - int v115; // [sp+80h] [bp-24h]@18 - int v116; // [sp+84h] [bp-20h]@7 - unsigned int v117; // [sp+88h] [bp-1Ch]@15 - unsigned int v118; // [sp+8Ch] [bp-18h]@24 - int *v119; // [sp+90h] [bp-14h]@13 - int v120; // [sp+94h] [bp-10h]@15 - unsigned int v121; // [sp+98h] [bp-Ch]@15 - unsigned __int16 *v122; // [sp+9Ch] [bp-8h]@15 - unsigned int v123; // [sp+A0h] [bp-4h]@13 - result = pRenderer->uTargetSurfacePitch; - v2 = sFaceID; - v95 = pRenderer->uTargetSurfacePitch; - if ( sFaceID >= 0 ) - { - if ( sFaceID < (signed int)pIndoor->uNumFaces ) - { - v3 = &pIndoor->pFaces[sFaceID]; - v91 = &pIndoor->pFaces[sFaceID]; - if ( !pRenderer->pRenderD3D ) - { - result = GetPortalScreenCoord(sFaceID); - if ( result ) - { - result = sub_424829(result, &stru_F8A590, pBLVRenderParams->field_7C, v2); - if ( result ) - { - result = (int)v3->GetTexture(); - v4 = (Texture *)result; - v96 = (Texture *)result; - if ( result ) - { - v5 = *(short *)(result + 38); - LOBYTE(v3->uAttributes) |= 0x80u; - v92 = v5; - sub_4AE5F1(v2); - ++pBLVRenderParams->field_84; - v6 = stru_F8AD28.pDeltaUV[0]; - v116 = stru_F8AD28.pDeltaUV[1]; - v7 = 0; - for ( i = bUseLoResSprites; v7 < stru_F8AD28.uNumLightsApplied; *(int *)v9 = v10 ) - { - v8 = v116; - stru_F8AD28._blv_lights_xs[v7] += v6; - v9 = 4 * v7 + 16297672; - v10 = v8 - stru_F8AD28._blv_lights_ys[v7++]; - } - v94 = sr_sub_47C24C_get_palette(v3, v92, 0, 1); - result = stru_F8A590._viewport_space_y; - a2 = stru_F8A590._viewport_space_y; - v11 = stru_F8A590._viewport_space_y * pRenderer->uTargetSurfacePitch; - v99 = 640 * stru_F8A590._viewport_space_y; - v86 = v4->pLevelOfDetail0_prolly_alpha_mask; - v87 = v4->pLevelOfDetail1; - v88 = v4->pLevelOfDetail2; - v89 = v4->pLevelOfDetail3; - v98 = stru_F8A590._viewport_space_y * pRenderer->uTargetSurfacePitch; - v104 = 2 * pBLVRenderParams->field_0_timer_; - if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) - { - v12 = 2 * stru_F8A590._viewport_space_y; - v101 = 2 * stru_F8A590._viewport_space_y; - while ( 1 ) - { - a1 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v12); - sub_4AE313(a1, result, &stru_F81018.field_0); - if ( LOBYTE(viewparams->field_20) ) - { - v15 = v95 * (v12 - pBLVRenderParams->uViewportY); - v119 = &pBLVRenderParams->pTargetZBuffer[2 - * (*(__int16 *)((char *)stru_F8A590.viewport_left_side + v12) - + 320 * (v12 - pBLVRenderParams->uViewportY)) - - pBLVRenderParams->uViewportX]; - v16 = &pBLVRenderParams->pRenderTarget[v15 - + 2 * *(__int16 *)((char *)stru_F8A590.viewport_left_side + v12) - - pBLVRenderParams->uViewportX]; - v14 = &pBLVRenderParams->pRenderTarget[v15 - + 2 * *(__int16 *)((char *)stru_F8A590.viewport_right_side + v12) - - pBLVRenderParams->uViewportX]; - v123 = (unsigned int)v16; - } - else - { - v13 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v12); - v119 = &pBLVRenderParams->pTargetZBuffer[v13 + v99]; - v123 = (unsigned int)&pBLVRenderParams->pRenderTarget[v13 + v11]; - v14 = &pBLVRenderParams->pRenderTarget[v11 + *(__int16 *)((char *)stru_F8A590.viewport_right_side + v12)]; - } - v117 = (unsigned int)v14; - HIWORD(v17) = HIWORD(stru_F81018.field_0.field_0); - v18 = stru_F81018.field_0.field_10; - LOWORD(v17) = 0; - v97 = stru_F8AD28.field_0 | v17; - v110 = sub_4AE491(SHIWORD(stru_F81018.field_0.field_4), SHIWORD(stru_F81018.field_0.field_8)); - v19 = stru_F81018.field_0.field_4 >> i; - v20 = 11 - v18; - v116 = stru_F81018.field_0.field_8 >> i; - v21 = stru_F81018.field_0.field_8 >> i >> (11 - v18); - v22 = stru_5C6E00; - v122 = (unsigned __int16 *)v20; - v121 = (stru_F81018.field_0.field_4 >> i) + 4 * stru_5C6E00->Cos(v104 + v21); - v23 = stru_5C6E00->Sin(v104 + (v19 >> (char)v122)); - v120 = v116 + 4 * v23; - if ( v123 < v117 ) - { - v24 = (char *)&stru_F81018.field_34.field_8; - v114 = &stru_F81018.field_34.field_8; - a1 += 16; - while ( 1 ) - { - sub_4AE313(a1, a2, (stru337_stru0 *)(v24 - 8)); - v25 = *((int *)v24 - 2); - LOWORD(v25) = 0; - v115 = v97; - v26 = stru_F8AD28.field_0 | v25; - if ( v97 <= (unsigned int)v26 ) - v115 = v26; - v97 = v26; - v27 = *((int *)v24 - 11); - v28 = *((int *)v24 - 1); - v105 = (&v86)[4 * v27]; - v111 = v27 + 16; - v29 = v4->uWidthMinus1; - v109 = v27 + v27 + 16 - v4->uWidthLn2; - v107 = v29 >> v27; - v30 = v28 >> i; - v102 = v4->uHeightMinus1 >> v27 << (v27 + 16); - v31 = *v114 >> i; - v122 = (unsigned __int16 *)(11 - v27); - v116 = v30 + 4 * stru_5C6E00->Cos(v104 + (v31 >> (11 - v27))); - v90 = v31 + 4 * stru_5C6E00->Sin(v104 + (v30 >> (char)v122)); - v108 = (signed int)(v116 - v121) >> 4; - v103 = (v90 - v120) >> 4; - v32 = v123 + 32; - if ( LOBYTE(viewparams->field_20) ) - v32 = v123 + 64; - if ( v32 > v117 ) - v32 = v117; - v118 = v32; - v100 = sub_4AE491(*((short *)v114 - 1), *((short *)v114 + 1)); - v106 = (signed int)(v32 - v123) >> 1; - if ( v110 >> 16 == v100 >> 16 ) - { - v122 = sr_sub_47C24C_get_palette(v91, v92, v110 >> 16, 1); - if ( LOBYTE(viewparams->field_20) ) - { - v44 = v123; - if ( v123 < v118 ) - { - v45 = v119; - v46 = v122; - v47 = v121; - v48 = v120; - v49 = v111; - v50 = v109; - if ( v106 & 2 ) - { - *v119 = v115; - v45 -= 2; - v44 = v123 + 4; - goto LABEL_37; - } - do - { - v44 += 8; - v51 = *(&v105[v107 & (v47 >> v49)] + ((v102 & (unsigned int)v48) >> v50)); - v52 = v115; - LOWORD(v51) = v46[v51]; - *v45 = v115; - v45[1] = v52; - v45[640] = v52; - v45[641] = v52; - *(short *)(v44 - 8) = v51; - *(short *)(v44 - 6) = v51; - *(short *)(v44 + 1272) = v51; - *(short *)(v44 + 1274) = v51; - v45[2] = v52; - v45[3] = v52; - v45[642] = v52; - v45[643] = v52; - v121 += v108; - v120 += v103; - v47 = v121; - v48 = v120; -LABEL_37: - v45 += 4; - v53 = v46[*(&v105[v107 & (v47 >> v49)] + ((v102 & (unsigned int)v48) >> v50))]; - v54 = v108; - *(short *)(v44 - 4) = v53; - *(short *)(v44 - 2) = v53; - *(short *)(v44 + 1276) = v53; - *(short *)(v44 + 1278) = v53; - v121 += v54; - v120 += v103; - v47 = v121; - v48 = v120; - } - while ( v44 < v118 ); - v123 = v44; - v119 = v45; - } - } - else - { - v33 = v123; - if ( v123 < v118 ) - { - v34 = v119; - v35 = v122; - v36 = v121; - v37 = v120; - v38 = v111; - v39 = v109; - if ( v106 & 1 ) - { - *v119 = v115; - --v34; - v33 = v123 + 2; - goto LABEL_30; - } - do - { - v33 += 4; - v40 = *(&v105[v107 & (v36 >> v38)] + ((v102 & (unsigned int)v37) >> v39)); - v41 = v115; - LOWORD(v40) = v35[v40]; - *v34 = v115; - *(short *)(v33 - 4) = v40; - v34[1] = v41; - v121 += v108; - v120 += v103; - v36 = v121; - v37 = v120; -LABEL_30: - v42 = (unsigned int)(&v105[v107 & (v36 >> v38)] + ((v102 & (unsigned int)v37) >> v39)); - v34 += 2; - v43 = v108; - *(short *)(v33 - 2) = v35[*(char *)v42]; - v121 += v43; - v120 += v103; - v36 = v121; - v37 = v120; - } - while ( v33 < v118 ); - v123 = v33; - v119 = v34; - } - } - } - else - { - v55 = v110 - ((v100 - v110) >> 4); - v110 = (v100 - v110) >> 4; - v122 = (unsigned __int16 *)v55; - if ( LOBYTE(viewparams->field_20) ) - { - v71 = v123; - if ( v123 < v118 ) - { - v72 = v119; - v73 = v94; - v74 = v121; - v75 = v120; - v76 = v111; - v77 = v109; - if ( v106 & 2 ) - { - *v119 = v115; - v72 += 2; - v71 = v123 + 4; - goto LABEL_52; - } - do - { - v78 = (v107 & (v74 >> v76)) + ((v102 & (unsigned int)v75) >> v77); - v79 = (int)((char *)v122 + v110); - v71 += 8; - v122 = (unsigned __int16 *)v79; - v80 = ((v79 & 0xFFFF0000u) >> 8) + v105[v78]; - v81 = v115; - LOWORD(v80) = v73[v80]; - *v72 = v115; - v72[1] = v81; - v72[640] = v81; - v72[641] = v81; - *(short *)(v71 - 8) = v80; - *(short *)(v71 - 6) = v80; - *(short *)(v71 + 1272) = v80; - *(short *)(v71 + 1274) = v80; - v72[2] = v81; - v72[3] = v81; - v72[642] = v81; - v72[643] = v81; - v121 += v108; - v120 += v103; - v74 = v121; - v75 = v120; - v72 += 4; -LABEL_52: - v82 = (v107 & (v74 >> v76)) + ((v102 & (unsigned int)v75) >> v77); - v83 = (int)((char *)v122 + v110); - v84 = v105[v82]; - v122 = (unsigned __int16 *)v83; - LOWORD(v84) = v73[((v83 & 0xFFFF0000u) >> 8) + v84]; - v85 = v108; - *(short *)(v71 - 4) = v84; - *(short *)(v71 - 2) = v84; - *(short *)(v71 + 1276) = v84; - *(short *)(v71 + 1278) = v84; - v121 += v85; - v120 += v103; - v74 = v121; - v75 = v120; - } - while ( v71 < v118 ); - v123 = v71; - v119 = v72; - } - } - else - { - v56 = v123; - if ( v123 < v118 ) - { - v57 = v119; - v58 = v94; - v59 = v121; - v60 = v120; - v61 = v111; - v62 = v109; - if ( v106 & 1 ) - { - *v119 = v115; - ++v57; - v56 = v123 + 2; - goto LABEL_45; - } - do - { - v63 = (v107 & (v59 >> v61)) + ((v102 & (unsigned int)v60) >> v62); - v64 = (int)((char *)v122 + v110); - v56 += 4; - v122 = (unsigned __int16 *)v64; - v65 = ((v64 & 0xFFFF0000u) >> 8) + v105[v63]; - v66 = v115; - LOWORD(v65) = v58[v65]; - *v57 = v115; - *(short *)(v56 - 4) = v65; - v57[1] = v66; - v121 += v108; - v120 += v103; - v59 = v121; - v60 = v120; - v57 += 2; -LABEL_45: - v67 = (v107 & (v59 >> v61)) + ((v102 & (unsigned int)v60) >> v62); - v68 = (int)((char *)v122 + v110); - v69 = v105[v67]; - v122 = (unsigned __int16 *)v68; - LOWORD(v69) = v58[((v68 & 0xFFFF0000u) >> 8) + v69]; - v70 = v108; - *(short *)(v56 - 2) = v69; - v121 += v70; - v120 += v103; - v59 = v121; - v60 = v120; - } - while ( v56 < v118 ); - v123 = v56; - v119 = v57; - } - } - } - v114 += 13; - v110 = v100; - a1 += 16; - v4 = v96; - v121 = v116; - v120 = v90; - if ( v123 >= v117 ) - break; - v24 = (char *)v114; - v22 = stru_5C6E00; - } - } - ++a2; - v98 += v95; - result = a2; - v101 += 2; - v99 += 640; - if ( a2 > stru_F8A590._viewport_space_w ) - break; - v12 = v101; - result = a2; - v11 = v98; - } - } - } - } - } - } - } - } - return result; -} -// 4AE491: using guessed type int __fastcall sub_4AE491(int, int); - -//----- (004ADD1D) -------------------------------------------------------- -void __fastcall sub_4ADD1D(int uFaceID) -{ - int v1; // edi@1 - BLVFace *v2; // esi@3 - signed int v3; // ebx@4 - Texture *v4; // edi@9 - signed int v5; // eax@9 - char *v6; // edi@12 - signed int v7; // eax@15 - unsigned int v8; // eax@16 - __int16 v9; // cx@19 - unsigned __int8 *v10; // eax@19 - unsigned __int16 *v11; // eax@19 - int v12; // edi@19 - int v13; // ebx@20 - stru352 *v14; // esi@20 - DWORD v15; // eax@22 - signed int v16; // ecx@22 - signed int v17; // ST68_4@22 - int v18; // eax@22 - int v19; // ecx@22 - unsigned int v20; // esi@23 - int v21; // edi@23 - int v22; // eax@23 - int *v23; // ebx@24 - int v24; // edx@24 - int v25; // ebx@25 - unsigned __int16 v26; // cx@25 - int v27; // edx@26 - unsigned __int16 v28; // cx@26 - unsigned __int8 v29; // sf@27 - unsigned __int8 v30; // of@27 - unsigned int v31; // esi@29 - int v32; // edi@29 - unsigned __int16 *v33; // eax@29 - int *v34; // ebx@30 - int v35; // edx@30 - int v36; // ebx@31 - unsigned __int16 v37; // cx@31 - int v38; // edx@32 - unsigned __int16 v39; // cx@32 - Texture *v40; // [sp-10h] [bp-6Ch]@16 - int v41; // [sp-Ch] [bp-68h]@15 - unsigned int v42; // [sp+10h] [bp-4Ch]@1 - signed int v43; // [sp+14h] [bp-48h]@12 - signed int v44; // [sp+14h] [bp-48h]@22 - int v45; // [sp+1Ch] [bp-40h]@22 - int v46; // [sp+20h] [bp-3Ch]@22 - int v47; // [sp+24h] [bp-38h]@19 - char v48; // [sp+28h] [bp-34h]@19 - int v49; // [sp+2Ch] [bp-30h]@19 - unsigned __int8 *v50; // [sp+30h] [bp-2Ch]@19 - unsigned __int16 *v51; // [sp+34h] [bp-28h]@19 - int v52; // [sp+38h] [bp-24h]@22 - int v53; // [sp+3Ch] [bp-20h]@22 - signed int v54; // [sp+40h] [bp-1Ch]@12 - int v55; // [sp+40h] [bp-1Ch]@20 - int v56; // [sp+44h] [bp-18h]@20 - stru352 *i; // [sp+48h] [bp-14h]@20 - unsigned __int16 *v58; // [sp+4Ch] [bp-10h]@23 - int v59; // [sp+50h] [bp-Ch]@4 - int v60; // [sp+50h] [bp-Ch]@19 - int v61; // [sp+54h] [bp-8h]@22 - int *v62; // [sp+58h] [bp-4h]@23 - int *v63; // [sp+58h] [bp-4h]@29 - - v1 = uFaceID; - v42 = pRenderer->uTargetSurfacePitch; - if ( uFaceID >= 0 && uFaceID < (signed int)pIndoor->uNumFaces ) - { - v2 = &pIndoor->pFaces[uFaceID]; - if ( pRenderer->pRenderD3D ) - { - v3 = sub_424579(uFaceID, &stru_F8AD28); - v59 = v3; - } - else - { - v59 = GetPortalScreenCoord(uFaceID); - v3 = v59; - } - if ( v3 && (pRenderer->pRenderD3D || sub_424829(v3, &stru_F8A590, pBLVRenderParams->field_7C, v1)) ) - { - v4 = v2->GetTexture(); - v5 = 0; - if ( v4 ) - { - if ( pRenderer->pRenderD3D ) - { - if ( v3 > 0 ) - { - v54 = v3; - v43 = v3; - v6 = (char *)&array_507D30[0].v; - do - { - *((float *)v6 - 1) = (double)((GetTickCount() >> 5) - pBLVRenderParams->vPartyPos.x) + *((float *)v6 - 1); - *(float *)v6 = (double)(pBLVRenderParams->vPartyPos.y + (GetTickCount() >> 5)) + *(float *)v6; - v6 += 48; - --v54; - } - while ( v54 ); - v3 = v59; - v5 = v43; - } - v7 = v5; - v41 = stru_F8AD28.field_0; - array_507D30[v7].u = array_507D30[v7].u * 0.25; - array_507D30[v7].v = array_507D30[v7].v * 0.25; - if ( BYTE1(v2->uAttributes) & 0x40 ) - { - v40 = v2->GetTexture(); - v8 = pTextureFrameTable->GetFrameTexture(v2->uBitmapID, pBLVRenderParams->field_0_timer_); - } - else - { - v40 = v2->GetTexture(); - v8 = v2->uBitmapID; - } - pRenderer->DrawIndoorPolygon(v3, v2, pBitmaps_LOD->pHardwareTextures[v8], v40, v41, -1, 0); - } - else - { - v49 = v4->uWidthMinus1; - v47 = v4->uHeightMinus1 << 16; - v9 = 16 - v4->uWidthLn2; - v10 = v4->pLevelOfDetail0_prolly_alpha_mask; - LOBYTE(v2->uAttributes) |= 0x80u; - v48 = v9; - v50 = v10; - sub_4AF412(); - ++pBLVRenderParams->uNumFacesRenderedThisFrame; - v11 = sr_sub_47C24C_get_palette(v2, v4->palette_id2, 0, 1); - v12 = stru_F8A590._viewport_space_y; - v51 = v11; - v60 = stru_F8A590._viewport_space_y; - if ( stru_F8A590._viewport_space_y <= stru_F8A590._viewport_space_w ) - { - v13 = 2 * stru_F8A590._viewport_space_y; - v14 = &stru_F83B80[stru_F8A590._viewport_space_y]; - v55 = 2 * stru_F8A590._viewport_space_y; - v56 = 640 * stru_F8A590._viewport_space_y; - for ( i = &stru_F83B80[stru_F8A590._viewport_space_y]; ; v14 = i ) - { - sub_4AE1E7(v12, *(__int16 *)((char *)stru_F8A590.viewport_left_side + v13), v12); - v14->field_0 += (GetTickCount() << 11) - (pBLVRenderParams->vPartyPos.x << 16); - v15 = GetTickCount(); - v16 = v14->field_0; - v14->field_4 += (32 * pBLVRenderParams->vPartyPos.y + v15) << 11; - v45 = v14->field_4 >> 3; - v44 = v16 >> 3; - v17 = (signed int)((unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)v14->field_28) >> 16) >> 3; - v52 = (unsigned __int64)(v17 * (signed __int64)-pBLVRenderParams->sSineY) >> 16; - v53 = (unsigned __int64)(v17 * (signed __int64)pBLVRenderParams->sCosineY) >> 16; - v18 = v14->field_28; - v19 = *(__int16 *)((char *)stru_F8A590.viewport_left_side + v13); - LOWORD(v18) = 0; - v46 = stru_F8AD28.field_0 | v18; - v61 = *(__int16 *)((char *)stru_F8A590.viewport_right_side + v13) - v19; - if ( LOBYTE(viewparams->field_20) ) - { - v63 = &pBLVRenderParams->pTargetZBuffer[2 * (v19 + 320 * (v13 - pBLVRenderParams->uViewportY)) - - pBLVRenderParams->uViewportX]; - v31 = v44; - v32 = v45; - v33 = &pBLVRenderParams->pRenderTarget[v42 * (v13 - pBLVRenderParams->uViewportY) - + 2 * v19 - - pBLVRenderParams->uViewportX]; - if ( v61 & 1 ) - { - --v61; - v33 = &pBLVRenderParams->pRenderTarget[v42 * (v13 - pBLVRenderParams->uViewportY) - + 2 * v19 - - pBLVRenderParams->uViewportX - - 2]; - v34 = &pBLVRenderParams->pTargetZBuffer[2 * (v19 + 320 * (v13 - pBLVRenderParams->uViewportY)) - - pBLVRenderParams->uViewportX]; - v35 = v46; - v63 += 2; - goto LABEL_32; - } - while ( 1 ) - { - v30 = __OFSUB__(v61, 2); - v29 = v61 - 2 < 0; - v61 -= 2; - if ( v29 ^ v30 ) - break; - v36 = *(&v50[v49 & (v31 >> 16)] + ((v47 & (unsigned int)v32) >> v48)); - v31 += v52; - v37 = v51[v36]; - v32 += v53; - v34 = v63; - v35 = v46; - *v33 = v37; - v33[1] = v37; - v33[640] = v37; - v33[641] = v37; - v63 += 4; - v34[2] = v46; - v34[3] = v46; - v34[642] = v46; - v34[643] = v46; -LABEL_32: - *v34 = v35; - v34[1] = v35; - v34[640] = v35; - v34[641] = v35; - v38 = v49 & (v31 >> 16); - v33 += 4; - v31 += v52; - v39 = v51[*(&v50[v38] + ((v47 & (unsigned int)v32) >> v48))]; - v32 += v53; - *(v33 - 2) = v39; - *(v33 - 1) = v39; - v33[638] = v39; - v33[639] = v39; - } - } - else - { - v58 = &pBLVRenderParams->pRenderTarget[v19 + v12 * pRenderer->uTargetSurfacePitch]; - v62 = &pBLVRenderParams->pTargetZBuffer[v56 + v19]; - v20 = v44; - v21 = v45; - v22 = (int)v58; - if ( v61 & 1 ) - { - --v61; - v22 = (int)(v58 - 1); - v23 = &pBLVRenderParams->pTargetZBuffer[v56 + v19]; - v24 = v46; - ++v62; - goto LABEL_26; - } - while ( 1 ) - { - v30 = __OFSUB__(v61, 2); - v29 = v61 - 2 < 0; - v61 -= 2; - if ( v29 ^ v30 ) - break; - v25 = *(&v50[v49 & (v20 >> 16)] + ((v47 & (unsigned int)v21) >> v48)); - v20 += v52; - v26 = v51[v25]; - v21 += v53; - v23 = v62; - v24 = v46; - *(short *)v22 = v26; - v62 += 2; - v23[1] = v46; -LABEL_26: - *v23 = v24; - v27 = v49 & (v20 >> 16); - v22 += 4; - v20 += v52; - v28 = v51[*(&v50[v27] + ((v47 & (unsigned int)v21) >> v48))]; - v21 += v53; - *(short *)(v22 - 2) = v28; - } - } - ++v60; - ++i; - v56 += 640; - v55 += 2; - if ( v60 > stru_F8A590._viewport_space_w ) - break; - v13 = v55; - v12 = v60; - } - } - } - } - } - } -} - -//----- (004AE1E7) -------------------------------------------------------- -int __fastcall sub_4AE1E7(int a1, int a2, int a3) -{ - int v3; // ebx@1 - int v4; // edi@1 - int v5; // esi@1 - signed __int64 v6; // qtt@3 - int v7; // esi@3 - int v8; // eax@5 - int result; // eax@5 - int v10; // edx@5 - int v11; // [sp+Ch] [bp-8h]@1 - int v12; // [sp+1Ch] [bp+8h]@2 - - v3 = pBLVRenderParams->uViewportCenterY - a3; - v4 = pBLVRenderParams->uViewportCenterX - a2; - v11 = a1; - v5 = (pBLVRenderParams->uViewportCenterY - a3) * stru_F8AD28.vec_80.y - + stru_F8AD28.field_7C - + (pBLVRenderParams->uViewportCenterX - a2) * stru_F8AD28.vec_80.x; - if ( v5 && (v12 = abs(stru_F8AD28.vec_80.z) >> 14, v12 <= abs(v5)) ) - { - LODWORD(v6) = stru_F8AD28.vec_80.z << 16; - HIDWORD(v6) = stru_F8AD28.vec_80.z >> 16; - v7 = v6 / (v3 * stru_F8AD28.vec_80.y + stru_F8AD28.field_7C + v4 * stru_F8AD28.vec_80.x); - } - else - { - v7 = 1073741824; - } - v8 = stru_F8AD28.vec_9C.z; - stru_F83B80[v11].field_0 = ((unsigned __int64)((v3 * stru_F8AD28.vec_8C.z - + stru_F8AD28.vec_8C.x - + v4 * stru_F8AD28.vec_8C.y) - * (signed __int64)v7) >> 16) - + stru_F8AD28.field_98; - result = (unsigned __int64)((v3 * v8 + stru_F8AD28.vec_9C.x + v4 * stru_F8AD28.vec_9C.y) * (signed __int64)v7) >> 16; - v10 = result + stru_F8AD28.field_A8; - stru_F83B80[v11].field_28 = v7; - stru_F83B80[v11].field_4 = v10; - return result; -} - -//----- (004AE313) -------------------------------------------------------- -int __fastcall sub_4AE313(int viewport_space_x, int viewport_space_y, stru337_stru0 *p) -{ - int _dy; // ebx@1 - int _dx; // edi@1 - int v5; // ecx@1 - int v6; // esi@1 - int v7; // ST18_4@2 - signed __int64 v8; // qtt@3 - unsigned int v9; // ecx@3 - int result; // eax@8 - int v11; // [sp+Ch] [bp-8h]@1 - - _dy = pBLVRenderParams->uViewportCenterY - viewport_space_y; - _dx = pBLVRenderParams->uViewportCenterX - viewport_space_x; - ++pBLVRenderParams->field_88; - v5 = (pBLVRenderParams->uViewportCenterY - viewport_space_y) * stru_F8AD28.vec_80.y + stru_F8AD28.field_7C; - v6 = v5 + _dx * stru_F8AD28.vec_80.x; - v11 = v5 + _dx * stru_F8AD28.vec_80.x; - if ( v5 + _dx * stru_F8AD28.vec_80.x && (v7 = abs(stru_F8AD28.vec_80.z) >> 14, v7 <= abs(v6)) ) - { - LODWORD(v8) = stru_F8AD28.vec_80.z << 16; - HIDWORD(v8) = stru_F8AD28.vec_80.z >> 16; - v9 = v8 / v11; - } - else - { - v9 = 0x40000000u; - } - if ( (signed int)v9 >= stru_F8AD28.field_34 ) - p->field_0 = v9; - else - p->field_0 = stru_F8AD28.field_34; - p->field_4 = ((unsigned __int64)((_dy * stru_F8AD28.vec_8C.z + stru_F8AD28.vec_8C.x + _dx * stru_F8AD28.vec_8C.y) - * (signed __int64)(signed int)v9) >> 16) - + stru_F8AD28.field_98 - + (stru_F8AD28.pDeltaUV[0] << 16); - p->field_8 = ((unsigned __int64)((_dy * stru_F8AD28.vec_9C.z + stru_F8AD28.vec_9C.x + _dx * stru_F8AD28.vec_9C.y) - * (signed __int64)(signed int)v9) >> 16) - + stru_F8AD28.field_A8 - + (stru_F8AD28.pDeltaUV[1] << 16); - result = abs((__int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)(signed int)v9) >> 16); - if ( result < 369620 || bUseLoResSprites ) - { - if ( result < 184810 ) - p->field_10 = result > 92405; - else - p->field_10 = 2; - } - else - { - p->field_10 = 3; - } - return result; -} - -//----- (004AE491) -------------------------------------------------------- -int __fastcall sub_4AE491(signed int a1, signed int a2) -{ - signed int v2; // eax@1 - signed int v3; // edi@1 - int v4; // ecx@1 - int v5; // esi@2 - int v6; // eax@2 - int v7; // ebx@2 - unsigned int v8; // ecx@2 - int v9; // edx@5 - int v10; // edx@7 - unsigned int v11; // eax@8 - int v13; // [sp+4h] [bp-18h]@2 - int v14; // [sp+8h] [bp-14h]@2 - signed int v15; // [sp+Ch] [bp-10h]@1 - int v16; // [sp+14h] [bp-8h]@1 - int v17; // [sp+18h] [bp-4h]@1 - - v2 = a1 >> SLOBYTE(stru_F8AD28.field_38); - v3 = a2 >> SLOBYTE(stru_F8AD28.field_38); - v17 = stru_F8AD28.uCurrentAmbientLightLevel; - v4 = 0; - v15 = v2; - v16 = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 ) - { - do - { - v5 = v16; - v13 = abs(v2 - stru_F8AD28._blv_lights_xs[v16]); - v14 = abs(v3 - stru_F8AD28._blv_lights_ys[v16]); - v6 = stru_F8AD28._blv_lights_light_dot_faces[v16]; - v7 = v13; - v8 = v14; - if ( v6 < v13 ) - { - v6 = v13; - v7 = stru_F8AD28._blv_lights_light_dot_faces[v16]; - } - if ( v6 < v14 ) - { - v9 = v6; - v6 = v14; - v8 = v9; - } - if ( v7 < (signed int)v8 ) - { - v10 = v8; - v8 = v7; - v7 = v10; - } - v11 = ((unsigned int)(11 * v7) >> 5) + (v8 >> 2) + v6; - if ( (signed int)v11 < stru_F8AD28._blv_lights_radii[v5] ) - v17 += 30 * (v11 * stru_F8AD28._blv_lights_inv_radii[v5] - 65536); - ++v16; - v2 = v15; - } - while ( v16 < stru_F8AD28.uNumLightsApplied ); - v4 = 0; - } - if ( stru_F8AD28.field_3E4 != v4 ) - v17 -= stru_F8AD28.field_3E8 * (v2 - stru_F8AD28.field_3F0) + stru_F8AD28.field_3EC * (v3 - stru_F8AD28.field_3F4); - if ( v17 >= v4 ) - { - if ( v17 > 2031616 ) - v17 = 2031616; - } - else - { - v17 = v4; - } - ++pBLVRenderParams->field_8C; - return v17; -} -// 4AE491: using guessed type int __fastcall sub_4AE491(int, int); - -//----- (004AE5F1) -------------------------------------------------------- -void __fastcall sub_4AE5F1(unsigned int uFaceID) -{ - BLVFace *v1; // esi@1 - BLVFaceExtra *v2; // ebx@1 - int v3; // eax@1 - int v4; // edi@1 - Texture *v5; // edi@1 - int v6; // eax@1 - unsigned int v7; // eax@1 - unsigned int v8; // ecx@1 - unsigned int v9; // eax@1 - unsigned int v10; // ecx@5 - int v11; // edi@10 - int v12; // ecx@10 - int v13; // eax@10 - int v14; // edx@10 - int v15; // ebx@12 - double v16; // st7@16 - int v17; // eax@16 - char *v18; // ebx@17 - int v19; // ecx@19 - int v20; // eax@19 - int v21; // edx@21 - int v22; // eax@23 - int v23; // ST04_4@26 - int v24; // edi@26 - double v25; // st6@26 - int v26; // eax@26 - double v27; // st6@26 - int v28; // ecx@26 - char v29; // al@26 - int v30; // edx@28 - int v31; // ecx@28 - BLVLightMM7 *v32; // ecx@32 - int v33; // edi@33 - int v34; // edx@33 - int v35; // eax@33 - int v36; // edi@35 - int v37; // edx@37 - int v38; // ebx@39 - int v39; // edi@42 - int v40; // eax@42 - char *v41; // ebx@45 - signed int v42; // ecx@47 - int v43; // edi@47 - int v44; // eax@49 - int v45; // edx@51 - int v46; // eax@53 - int v47; // ST04_4@55 - int v48; // edi@55 - double v49; // st6@55 - int v50; // eax@55 - double v51; // st6@55 - int v52; // eax@55 - int v53; // ecx@57 - int v54; // ecx@58 - int v55; // ecx@59 - int v56; // edx@62 - int v57; // ecx@62 - int v58; // eax@63 - int v59; // edx@64 - int v60; // ecx@67 - int v61; // edx@67 - int v62; // eax@68 - int v63; // edx@69 - signed int v64; // ecx@72 - double v65; // st7@75 - Vec3_int_ v66; // [sp+Ch] [bp-34h]@9 - Vec3_int_ v67; // [sp+18h] [bp-28h]@9 - BLVFaceExtra *v68; // [sp+24h] [bp-1Ch]@1 - int v69; // [sp+28h] [bp-18h]@10 - int v70; // [sp+2Ch] [bp-14h]@10 - int X; // [sp+30h] [bp-10h]@10 - int v72; // [sp+34h] [bp-Ch]@10 - int v73; // [sp+38h] [bp-8h]@10 - int v74; // [sp+3Ch] [bp-4h]@10 - - v1 = &pIndoor->pFaces[uFaceID]; - v2 = &pIndoor->pFaceExtras[v1->uFaceExtraID]; - v3 = v1->uBitmapID; - v4 = v1->uBitmapID; - v68 = v2; - v5 = (Texture *)(v4 != -1 ? (int)&pBitmaps_LOD->pTextures[v3] : 0); - v6 = 8 * uFaceID; - LOBYTE(v6) = PID(OBJECT_BModel,uFaceID); - stru_F8AD28.field_0 = v6; - stru_F8AD28.plane_4.vNormal.x = v1->pFacePlane_old.vNormal.x; - stru_F8AD28.plane_4.vNormal.y = v1->pFacePlane_old.vNormal.y; - stru_F8AD28.plane_4.vNormal.z = v1->pFacePlane_old.vNormal.z; - stru_F8AD28.plane_4.dist = v1->pFacePlane_old.dist; - stru_F8AD28.pDeltaUV[0] = v2->sTextureDeltaU; - stru_F8AD28.pDeltaUV[1] = v2->sTextureDeltaV; - v7 = GetTickCount(); - v8 = v1->uAttributes; - v9 = v7 >> 3; - if ( v8 & 4 ) - { - stru_F8AD28.pDeltaUV[1] -= v9 & v5->uHeightMinus1; - } - else - { - if ( v8 & 0x20 ) - stru_F8AD28.pDeltaUV[1] += v9 & v5->uHeightMinus1; - } - v10 = v1->uAttributes; - if ( BYTE1(v10) & 8 ) - { - stru_F8AD28.pDeltaUV[0] -= v9 & v5->uWidthMinus1; - } - else - { - if ( v10 & 0x40 ) - stru_F8AD28.pDeltaUV[0] += v9 & v5->uWidthMinus1; - } - v1->_get_normals(&v67, &v66); - stru_F8AD28.vec_14.x = v67.x; - stru_F8AD28.vec_14.y = v67.y; - stru_F8AD28.vec_14.z = v67.z; - stru_F8AD28.vec_20.x = v66.x; - stru_F8AD28.vec_20.y = v66.y; - stru_F8AD28.vec_20.z = v66.z; - stru_F8AD28.uDefaultAmbientLightLevel = v2->field_22; - if ( pBLVRenderParams->sPartyRotX ) - { - v74 = (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; - v74 = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v74; - X = (unsigned __int64)(stru_F8AD28.plane_4.vNormal.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; - stru_F8AD28.rotated_normal.x = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - X; - stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x - * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y - * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - stru_F8AD28.rotated_normal.z = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) - + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z - * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); - v70 = (unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; - v74 = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v70; - v70 = (unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; - stru_F8AD28.vec_60.y = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v70; - stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - stru_F8AD28.field_6C = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); - v70 = (unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; - v74 = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - v70; - X = (unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16; - v72 = (unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16; - v70 = (unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; - stru_F8AD28.vec_70.x = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v70; - stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - stru_F8AD28.vec_70.z = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); - v74 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y - - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x; - v11 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y - + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x); - v73 = -65536 * pBLVRenderParams->vPartyPos.z; - v70 = (unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; - v12 = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - v70; - v69 = (unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16; - v13 = pBLVRenderParams->vPartyPos.y; - v70 = ((unsigned __int64)(v74 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) - + ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); - v14 = pBLVRenderParams->vPartyPos.x; - } - else - { - v70 = (unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; - stru_F8AD28.rotated_normal.x = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x - * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - - v70; - stru_F8AD28.rotated_normal.z = stru_F8AD28.plane_4.vNormal.z; - stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x - * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y - * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - v70 = (unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; - stru_F8AD28.vec_60.y = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - - v70; - stru_F8AD28.field_6C = stru_F8AD28.vec_14.z; - stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - v70 = (unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16; - stru_F8AD28.vec_70.x = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - - v70; - v69 = (unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16; - v14 = pBLVRenderParams->vPartyPos.x; - stru_F8AD28.vec_70.z = stru_F8AD28.vec_20.z; - v13 = pBLVRenderParams->vPartyPos.y; - stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - v12 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y - - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x; - v11 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y - + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x); - v70 = -65536 * pBLVRenderParams->vPartyPos.z; - } - stru_F8AD28.field_7C = stru_F8AD28.rotated_normal.x; - stru_F8AD28.vec_60.x = stru_F8AD28.plane_4.vNormal.z * pBLVRenderParams->vPartyPos.z - + stru_F8AD28.plane_4.dist - + stru_F8AD28.plane_4.vNormal.y * v13 - + stru_F8AD28.plane_4.vNormal.x * v14; - stru_F8AD28.vec_80.x = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) - * (signed __int64)stru_F8AD28.rotated_normal.y) >> 16; - stru_F8AD28.vec_80.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) - * (signed __int64)stru_F8AD28.rotated_normal.z) >> 16; - stru_F8AD28.vec_80.z = -stru_F8AD28.vec_60.x; - stru_F8AD28.vec_8C.x = stru_F8AD28.vec_60.y; - stru_F8AD28.vec_8C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_60.z) >> 16; - stru_F8AD28.vec_8C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.field_6C) >> 16; - X = (unsigned __int64)(stru_F8AD28.vec_60.y * (signed __int64)v12) >> 16; - v15 = v70; - v70 = (unsigned __int64)(stru_F8AD28.field_6C * (signed __int64)v70) >> 16; - stru_F8AD28.vec_9C.x = stru_F8AD28.vec_70.x; - stru_F8AD28.field_98 = -(X + ((unsigned __int64)(stru_F8AD28.vec_60.z * (signed __int64)v11) >> 16) + v70); - stru_F8AD28.vec_9C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.y) >> 16; - stru_F8AD28.vec_9C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.z) >> 16; - X = (unsigned __int64)(stru_F8AD28.vec_70.x * (signed __int64)v12) >> 16; - v69 = (unsigned __int64)(stru_F8AD28.vec_70.y * (signed __int64)v11) >> 16; - v70 = (unsigned __int64)(stru_F8AD28.vec_70.z * (signed __int64)v15) >> 16; - stru_F8AD28.field_38 = 0; - stru_F8AD28.field_A8 = -(X - + ((unsigned __int64)(stru_F8AD28.vec_70.y * (signed __int64)v11) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_70.z * (signed __int64)v15) >> 16)); - if ( *(int *)&v68->field_4 || *(int *)&v68->field_8 ) - { - stru_F8AD28.field_3E4 = 1; - stru_F8AD28.field_3E8 = *(int *)&v68->field_4; - stru_F8AD28.field_3EC = *(int *)&v68->field_8; - stru_F8AD28.field_3F0 = v68->field_1E; - stru_F8AD28.field_3F4 = v68->field_20; - } - else - { - stru_F8AD28.field_3E4 = 0; - } - v16 = 0.0039215689; - v17 = 116 * v1->uSectorID; - v69 = v17; - v74 = 0; - v73 = 0; - stru_F8AD28.uCurrentAmbientLightLevel = (stru_F8AD28.uDefaultAmbientLightLevel + *(__int16 *)((char *)&pIndoor->pSectors->uMinAmbientLightLevel + v17)) << 16; - v70 = pMobileLightsStack->uNumLightsActive; - if ( pMobileLightsStack->uNumLightsActive > 0 ) - { - v18 = (char *)&pMobileLightsStack->pLights[0].vPosition.y; - do - { - if ( v74 >= 20 ) - break; - v19 = *((short *)v18 + 2); - v20 = *((short *)v18 - 1); - if ( v20 > v1->pBounding.x1 - v19 ) - { - if ( v20 < v19 + v1->pBounding.x2 ) - { - v21 = *(short *)v18; - if ( v21 > v1->pBounding.y1 - v19 ) - { - if ( v21 < v19 + v1->pBounding.y2 ) - { - v22 = *((short *)v18 + 1); - if ( v22 > v1->pBounding.z1 - v19 ) - { - if ( v22 < v19 + v1->pBounding.z2 ) - { - X = (v1->pFacePlane_old.dist - + *((short *)v18 + 1) * v1->pFacePlane_old.vNormal.z - + v21 * v1->pFacePlane_old.vNormal.y - + *((short *)v18 - 1) * v1->pFacePlane_old.vNormal.x) >> 16; - if ( X <= v19 ) - { - v23 = X; - v24 = v74; - stru_F8AD28._blv_lights_radii[v74] = v19; - stru_F8AD28._blv_lights_inv_radii[v24] = 65536 / v19; - *(int *)((char *)&stru_F8AD28.field_240 + v24 * 4) = *((short *)v18 + 5) << 16; - stru_F8AD28._blv_lights_xs[v24] = *((short *)v18 - 1); - stru_F8AD28._blv_lights_ys[v24] = *(short *)v18; - stru_F8AD28._blv_lights_zs[v24] = *((short *)v18 + 1); - v68 = (BLVFaceExtra *)(unsigned __int8)v18[6]; - v25 = (double)(signed int)v68 * v16; - v68 = (BLVFaceExtra *)(unsigned __int8)v18[7]; - v26 = (unsigned __int8)v18[8]; - *(float *)(v24 * 4 + 16297992) = v25; - v27 = (double)(signed int)v68; - v68 = (BLVFaceExtra *)v26; - *(float *)(v24 * 4 + 16298072) = v27 * v16; - *(float *)(v24 * 4 + 16298152) = (double)(signed int)v68 * v16; - v16 = 0.0039215689; - stru_F8AD28._blv_lights_light_dot_faces[v24] = abs(v23); - v28 = v74; - v29 = v18[9]; - ++v74; - stru_F8AD28._blv_lights_types[v28] = v29; - } - } - } - } - } - } - } - ++v73; - v18 += 18; - v17 = v69; - } - while ( v73 < v70 ); - } - v30 = 0; - v73 = 0; - v31 = *(__int16 *)((char *)&pIndoor->pSectors->uNumLights + v17); - v70 = *(__int16 *)((char *)&pIndoor->pSectors->uNumLights + v17); - if ( v31 > 0 ) - { - while ( v74 < 20 ) - { - v32 = &pIndoor->pLights[*(&(*(BLVLightMM7 **)((char *)&pIndoor->pSectors->pLights + v17))->vPosition.x + v30)]; - if ( !(v32->uAtributes & 8) ) - { - v33 = v1->pBounding.x1; - v34 = v32->vPosition.x; - X = v32->uBrightness; - v35 = v32->uRadius; - v68 = (BLVFaceExtra *)v32->uRadius; - if ( v34 > v33 - v35 ) - { - if ( v34 < v35 + v1->pBounding.x2 ) - { - v36 = v32->vPosition.y; - if ( v36 > v1->pBounding.y1 - v35 ) - { - if ( v36 < v35 + v1->pBounding.y2 ) - { - v37 = v32->vPosition.z; - if ( v37 > v1->pBounding.z1 - v35 ) - { - if ( v37 < v35 + v1->pBounding.z2 ) - { - v38 = (v1->pFacePlane_old.dist - + v32->vPosition.x * v1->pFacePlane_old.vNormal.x - + v37 * v1->pFacePlane_old.vNormal.z - + v36 * v1->pFacePlane_old.vNormal.y) >> 16; - if ( v38 >= 0 ) - { - if ( v38 <= v35 && v35 ) - { - v39 = v74; - stru_F8AD28._blv_lights_radii[v74] = v35; - stru_F8AD28._blv_lights_inv_radii[v39] = 65536 / (signed int)v68; - *(int *)((char *)&stru_F8AD28.field_240 + v39 * 4) = X << 16; - stru_F8AD28._blv_lights_xs[v39] = v32->vPosition.x; - stru_F8AD28._blv_lights_ys[v39] = v32->vPosition.y; - stru_F8AD28._blv_lights_zs[v39] = v32->vPosition.z; - v68 = (BLVFaceExtra *)v32->uRed; - stru_F8AD28._blv_lights_rs[v39] = (double)(signed int)v68 * v16; - v68 = (BLVFaceExtra *)v32->uGreen; - stru_F8AD28._blv_lights_gs[v39] = (double)(signed int)v68 * v16; - v68 = (BLVFaceExtra *)v32->uBlue; - stru_F8AD28._blv_lights_bs[v39] = (double)(signed int)v68 * v16; - v16 = 0.0039215689; - stru_F8AD28._blv_lights_light_dot_faces[v39] = abs(v38); - v40 = v74++; - stru_F8AD28._blv_lights_types[v40] = 1; - } - } - } - } - } - } - } - } - } - v30 = v73++ + 1; - if ( v73 >= v70 ) - break; - v17 = v69; - } - } - v73 = 0; - if ( pStationaryLightsStack->uNumLightsActive > 0 ) - { - v41 = (char *)&pStationaryLightsStack->pLights[0].vPosition.y; - do - { - if ( v74 >= 20 ) - break; - v42 = *((short *)v41 + 2); - v43 = *((short *)v41 - 1); - if ( v43 > v1->pBounding.x1 - v42 ) - { - if ( v43 < v42 + v1->pBounding.x2 ) - { - v44 = *(short *)v41; - if ( v44 > v1->pBounding.y1 - v42 ) - { - if ( v44 < v42 + v1->pBounding.y2 ) - { - v45 = *((short *)v41 + 1); - if ( v45 > v1->pBounding.z1 - v42 ) - { - if ( v45 < v42 + v1->pBounding.z2 ) - { - v46 = (v1->pFacePlane_old.dist - + *(short *)v41 * v1->pFacePlane_old.vNormal.y - + v43 * v1->pFacePlane_old.vNormal.x - + v45 * v1->pFacePlane_old.vNormal.z) >> 16; - v69 = v46; - if ( v46 >= 0 ) - { - if ( v46 <= v42 ) - { - v47 = v69; - v48 = v74; - stru_F8AD28._blv_lights_radii[v74] = v42; - stru_F8AD28._blv_lights_inv_radii[v48] = 65536 / v42; - stru_F8AD28._blv_lights_xs[v48] = *((short *)v41 - 1); - stru_F8AD28._blv_lights_ys[v48] = *(short *)v41; - stru_F8AD28._blv_lights_zs[v48] = *((short *)v41 + 1); - v68 = (BLVFaceExtra *)(unsigned __int8)v41[6]; - v49 = (double)(signed int)v68 * v16; - v68 = (BLVFaceExtra *)(unsigned __int8)v41[7]; - v50 = (unsigned __int8)v41[8]; - stru_F8AD28._blv_lights_rs[v48] = v49; - v51 = (double)(signed int)v68; - v68 = (BLVFaceExtra *)v50; - stru_F8AD28._blv_lights_gs[v48] = v51 * v16; - stru_F8AD28._blv_lights_bs[v48] = (double)(signed int)v68 * v16; - v16 = 0.0039215689; - stru_F8AD28._blv_lights_light_dot_faces[v48] = abs(v47); - v52 = v74++; - stru_F8AD28._blv_lights_types[v52] = 1; - } - } - } - } - } - } - } - } - ++v73; - v41 += 12; - } - while ( v73 < pStationaryLightsStack->uNumLightsActive ); - } - stru_F8AD28.uNumLightsApplied = v74; - v53 = v1->pBounding.x2; - if ( pBLVRenderParams->vPartyPos.x <= v53 ) - { - v55 = v1->pBounding.x1; - if ( pBLVRenderParams->vPartyPos.x >= v55 ) - v54 = 0; - else - v54 = v55 - pBLVRenderParams->vPartyPos.x; - } - else - { - v54 = pBLVRenderParams->vPartyPos.x - v53; - } - v56 = v1->pBounding.y2; - v57 = v54 * v54; - if ( pBLVRenderParams->vPartyPos.y <= v56 ) - { - v59 = v1->pBounding.y1; - if ( pBLVRenderParams->vPartyPos.y >= v59 ) - v58 = 0; - else - v58 = v59 - pBLVRenderParams->vPartyPos.y; - } - else - { - v58 = pBLVRenderParams->vPartyPos.y - v56; - } - v60 = v58 * v58 + v57; - v61 = v1->pBounding.z2; - if ( pBLVRenderParams->vPartyPos.z <= v61 ) - { - v63 = v1->pBounding.z1; - if ( pBLVRenderParams->vPartyPos.z >= v63 ) - v62 = 0; - else - v62 = v63 - pBLVRenderParams->vPartyPos.z; - } - else - { - v62 = pBLVRenderParams->vPartyPos.z - v61; - } - v64 = v62 * v62 + v60; - if ( v64 ) - stru_F8AD28.field_34 = integer_sqrt(v64) << 16; - else - stru_F8AD28.field_34 = 0; - v68 = (BLVFaceExtra *)abs(stru_F8AD28.rotated_normal.y); - v65 = (double)(signed int)v68; - if ( v65 >= 655.36 ) - { - if ( v65 >= 26214.4 ) - { - if ( v65 >= 45875.2 ) - { - stru_F8AD28.field_44 = 8; - stru_F8AD28.field_48 = 3; - } - else - { - stru_F8AD28.field_44 = 16; - stru_F8AD28.field_48 = 4; - } - } - else - { - stru_F8AD28.field_44 = 32; - stru_F8AD28.field_48 = 5; - } - } - else - { - stru_F8AD28.field_44 = 64; - stru_F8AD28.field_48 = 6; - } -} -// 519AB4: using guessed type int uNumStationaryLightsApplied; - -//----- (004AF412) -------------------------------------------------------- -int __cdecl sub_4AF412() -{ - int v0; // ST20_4@2 - int v1; // ST20_4@2 - int v2; // ST20_4@2 - int v3; // esi@2 - int v4; // ST20_4@2 - int v5; // ecx@2 - int v6; // ebx@2 - int v7; // edi@2 - int v8; // edx@2 - int v9; // eax@2 - int result; // eax@4 - - stru_F8AD28.plane_4.vNormal.z = -65536; - stru_F8AD28.vec_20.y = -65536; - stru_F8AD28.plane_4.vNormal.x = 0; - stru_F8AD28.plane_4.vNormal.y = 0; - stru_F8AD28.plane_4.dist = (pBLVRenderParams->vPartyPos.z + 800) << 16; - stru_F8AD28.vec_14.x = 65536; - stru_F8AD28.vec_14.y = 0; - stru_F8AD28.vec_14.z = 0; - stru_F8AD28.vec_20.x = 0; - stru_F8AD28.vec_20.z = 0; - stru_F8AD28.uDefaultAmbientLightLevel = 0; - if ( pBLVRenderParams->sPartyRotX ) - { - v0 = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y * (signed __int64)pBLVRenderParams->sSineY) >> 16); - stru_F8AD28.rotated_normal.x = ((unsigned __int64)(v0 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z - * (signed __int64)pBLVRenderParams->sSineNegX) >> 16); - stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x - * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y - * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - stru_F8AD28.rotated_normal.z = ((unsigned __int64)(v0 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) - + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.z - * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); - v1 = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - - ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16); - stru_F8AD28.vec_60.y = ((unsigned __int64)(v1 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - - ((unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16); - stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - stru_F8AD28.field_6C = ((unsigned __int64)(v1 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_14.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); - v2 = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - - ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16); - stru_F8AD28.vec_70.x = ((unsigned __int64)(v2 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - - ((unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16); - stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - stru_F8AD28.vec_70.z = ((unsigned __int64)(v2 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_20.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16); - v3 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y - + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x); - v4 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y - - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x; - v5 = ((unsigned __int64)(v4 * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - - ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sSineNegX) >> 16); - v6 = pBLVRenderParams->vPartyPos.z; - v7 = ((unsigned __int64)(-65536 * pBLVRenderParams->vPartyPos.z * (signed __int64)pBLVRenderParams->sCosineNegX) >> 16) - + ((unsigned __int64)(v4 * (signed __int64)pBLVRenderParams->sSineNegX) >> 16); - v8 = pBLVRenderParams->vPartyPos.y; - v9 = pBLVRenderParams->vPartyPos.x; - } - else - { - stru_F8AD28.rotated_normal.x = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x - * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - - ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y - * (signed __int64)pBLVRenderParams->sSineY) >> 16); - stru_F8AD28.rotated_normal.z = stru_F8AD28.plane_4.vNormal.z; - stru_F8AD28.rotated_normal.y = ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.x - * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.plane_4.vNormal.y - * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - stru_F8AD28.vec_60.y = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - - ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sSineY) >> 16); - stru_F8AD28.field_6C = stru_F8AD28.vec_14.z; - stru_F8AD28.vec_60.z = ((unsigned __int64)(stru_F8AD28.vec_14.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_14.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - stru_F8AD28.vec_70.x = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sCosineY) >> 16) - - ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sSineY) >> 16); - v8 = pBLVRenderParams->vPartyPos.y; - stru_F8AD28.vec_70.y = ((unsigned __int64)(stru_F8AD28.vec_20.x * (signed __int64)pBLVRenderParams->sSineY) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_20.y * (signed __int64)pBLVRenderParams->sCosineY) >> 16); - stru_F8AD28.vec_70.z = stru_F8AD28.vec_20.z; - v9 = pBLVRenderParams->vPartyPos.x; - v5 = pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.y - - pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.x; - v6 = pBLVRenderParams->vPartyPos.z; - v3 = -(pBLVRenderParams->sCosineY * pBLVRenderParams->vPartyPos.y - + pBLVRenderParams->sSineY * pBLVRenderParams->vPartyPos.x); - v7 = -65536 * pBLVRenderParams->vPartyPos.z; - } - stru_F8AD28.field_7C = stru_F8AD28.rotated_normal.x; - stru_F8AD28.vec_60.x = stru_F8AD28.plane_4.vNormal.y * v8 - + stru_F8AD28.plane_4.dist - + stru_F8AD28.plane_4.vNormal.x * v9 - + stru_F8AD28.plane_4.vNormal.z * v6; - stru_F8AD28.vec_80.x = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) - * (signed __int64)stru_F8AD28.rotated_normal.y) >> 16; - stru_F8AD28.vec_80.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) - * (signed __int64)stru_F8AD28.rotated_normal.z) >> 16; - stru_F8AD28.vec_80.z = -stru_F8AD28.vec_60.x; - stru_F8AD28.vec_8C.x = stru_F8AD28.vec_60.y; - stru_F8AD28.vec_8C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_60.z) >> 16; - stru_F8AD28.vec_8C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.field_6C) >> 16; - stru_F8AD28.vec_9C.x = stru_F8AD28.vec_70.x; - stru_F8AD28.field_98 = -(((unsigned __int64)(stru_F8AD28.vec_60.y * (signed __int64)v5) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_60.z * (signed __int64)v3) >> 16) - + ((unsigned __int64)(stru_F8AD28.field_6C * (signed __int64)v7) >> 16)); - stru_F8AD28.vec_9C.y = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.y) >> 16; - stru_F8AD28.vec_9C.z = (unsigned __int64)(SLODWORD(pBLVRenderParams->field_44) * (signed __int64)stru_F8AD28.vec_70.z) >> 16; - result = 0; - stru_F8AD28.field_A8 = -(((unsigned __int64)(stru_F8AD28.vec_70.x * (signed __int64)v5) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_70.y * (signed __int64)v3) >> 16) - + ((unsigned __int64)(stru_F8AD28.vec_70.z * (signed __int64)v7) >> 16)); - stru_F8AD28.field_38 = 0; - stru_F8AD28.field_3E4 = 0; - stru_F8AD28.uCurrentAmbientLightLevel = 0; - stru_F8AD28.uNumLightsApplied = 0; - stru_F8AD28.field_34 = 0; - return result; -} //----- (004B1447) -------------------------------------------------------- Player *__fastcall sub_4B1447_party_fine(int a1, int a2, int a3) @@ -5125,50 +3085,10 @@ a1.uFrameZ = a1.uFrameX + 107; a1.uFrameWidth = 108; a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v11 / 4 + 12], 3u); - sprintf(pTmpBuf.data(), "%s\n%d", pGlobalTXT_LocalizationStrings[522], *(&pSpellDatas[0].uNormalLevelMana + 10 * v1)); + sprintfex(pTmpBuf.data(), "%s\n%d", pGlobalTXT_LocalizationStrings[522], *(&pSpellDatas[0].uNormalLevelMana + 10 * v1)); a1.DrawTitleText(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf.data(), 3); } -//----- (004B1784) -------------------------------------------------------- -bool __cdecl sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() -{ - Player *pPlayer; // ebx@1 - bool result; // eax@2 - unsigned __int16 v2; // ST0C_2@3 - int v3; // eax@3 - GUIWindow v4; // [sp+4h] [bp-54h]@3 - - pPlayer = pPlayers[uActiveCharacter]; - if ( pPlayer->CanAct() ) - { - pDialogueWindow->pNumPresenceButton = dword_F8B1E0; - result = 1; - } - else - { - pDialogueWindow->pNumPresenceButton = 0; - memcpy(&v4, pPrimaryWindow, sizeof(v4)); - v4.uFrameX = 483; - v4.uFrameWidth = 148; - v4.uFrameZ = 334; - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427], pPlayer->pName, pGlobalTXT_LocalizationStrings[562]);// - // "%s is in no condition to %s" - // "do anything" - v2 = TargetColor(255, 255, 0x9Bu); - v3 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &v4, 0, 0); - v4.DrawTitleText(pFontArrus, 0, (212 - v3) / 2 + 101, v2, pTmpBuf.data(), 3u); - result = 0; - } - return result; -} -// F8B1E0: using guessed type int dword_F8B1E0; - -// F8B198: using guessed type int dword_F8B198; -// F8B19C: using guessed type int dword_F8B19C; - - -// 507B94: using guessed type int dword_507B94; - //----- (004B1ECE) -------------------------------------------------------- void __cdecl sub_4B1ECE() { @@ -5234,7 +3154,7 @@ v6 = pParty->pPlayers;//[0].pInventoryItems[0].field_1A; do { - v7 = v6->pInventoryItems; + v7 = v6->pInventoryItemList; v8 = 138; do { @@ -5364,14 +3284,17 @@ v11 += 37; } while ( v9 < 4 ); + __debugbreak(); // warning C4700: uninitialized local variable 'v29' used if ( v29 == v14 ) { v25 = pClassNames[v10 + 1]; } else { + __debugbreak(); // warning C4700: uninitialized local variable 'v30' used if ( v30 == v14 )//crash { + __debugbreak(); // warning C4700: uninitialized local variable 'v31' used if ( v31 == v14 ) { sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[634], pClassNames[v10 + 2], pClassNames[v10 + 3]);//Вы должны достичь звания %s или %s для обучения этому уровню навыка. @@ -5642,249 +3565,6 @@ return pTmpBuf2.data(); } -//----- (004B3A72) -------------------------------------------------------- -void sub_4B3A72( int a1 ) - { - int num_buttons; // esi@1 - - num_buttons = 0; - if ( a1 == 21 ) - { - CreateButtonInColumn(0, 0x66u); - num_buttons = 2; - CreateButtonInColumn(1, 0x67u); - if ( pParty->HasItem(651) ) //Arcomage Deck - { - num_buttons = 3; - CreateButtonInColumn(2, 0x68u); - } - } - pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2); - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; -} -// F8B1E0: using guessed type int dword_F8B1E0; - -//----- (004B3AD4) -------------------------------------------------------- -void sub_4B3AD4( signed int a1 ) - { - if ( a1 > 0 ) - { - if ( a1 <= 3 ) - { - CreateButtonInColumn(0, 3u); - CreateButtonInColumn(1, 4u); - CreateButtonInColumn(2, 5u); - pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2); - } - if ( a1 == 4 ) - { - CreateButtonInColumn(0, 3u); - CreateButtonInColumn(1, 4u); - pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2); - } - } - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; -} -// F8B1E0: using guessed type int dword_F8B1E0; - -//----- (004B3B42) -------------------------------------------------------- -void sub_4B3B42( signed int a1 ) - { - int v1; // ecx@18 - int v2; // ecx@19 - int v3; // ecx@20 - signed int v4; // esi@22 - signed int v5; // eax@22 - unsigned int v6; // edx@24 - int v7; // ecx@24 - int result; // eax@43 - int v9; // [sp-10h] [bp-14h]@28 - int v10; // [sp-Ch] [bp-10h]@28 - int v11; // [sp-8h] [bp-Ch]@28 - unsigned int v12; // [sp-4h] [bp-8h]@4 - unsigned int v13; // [sp-4h] [bp-8h]@5 - unsigned int v14; // [sp-4h] [bp-8h]@9 - unsigned int v15; // [sp-4h] [bp-8h]@10 - unsigned int v16; // [sp-4h] [bp-8h]@14 - int v17; // [sp-4h] [bp-8h]@28 - - if ( a1 > 13 ) - { - if ( a1 > 22 ) - { - if ( a1 == 23 ) - { - CreateButtonInColumn(0, 0xAu); - CreateButtonInColumn(1, 0xBu); - v14 = 96; -LABEL_41: - CreateButtonInColumn(2, v14); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 3; - goto LABEL_42; - } - if ( a1 <= 26 ) - goto LABEL_43; - if ( a1 > 28 ) - { - if ( a1 != 30 ) - goto LABEL_43; - CreateButtonInColumn(0, 0x11u); - v16 = 96; - goto LABEL_37; - } - CreateButtonInColumn(0, 0x69u); - CreateButtonInColumn(1, 0x6Au); - CreateButtonInColumn(2, 0x6Bu); - v12 = 108; - } - else - { - if ( a1 == 22 ) - { - CreateButtonInColumn(0, 7u); - v16 = 8; - goto LABEL_37; - } - v1 = a1 - 14; - if ( !v1 ) - { - CreateButtonInColumn(0, 0x12u); - CreateButtonInColumn(1, 0x30u); - CreateButtonInColumn(2, 0x31u); - CreateButtonInColumn(3, 0x32u); - CreateButtonInColumn(4, 0x33u); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 5; - goto LABEL_42; - } - v2 = v1 - 1; - if ( v2 ) - { - v3 = v2 - 2; - if ( v3 ) - { - if ( v3 != 4 ) - goto LABEL_43; - CreateButtonInColumn(0, 0xFu); - CreateButtonInColumn(1, 0x10u); - v4 = 3; - CreateButtonInColumn(2, 0x60u); - v5 = (signed int)window_SpeakInHouse->ptr_1C; - if ( v5 < 108 || v5 > 120 ) - goto LABEL_28; - v4 = 4; - v6 = 101; - v7 = 3; - } - else - { - v4 = 1; - CreateButtonInColumn(0, 0x63u); - if ( !pParty->uFine ) - { -LABEL_28: - v17 = 2; - v11 = 0; - v10 = 1; - v9 = v4; -LABEL_42: - pDialogueWindow->_41D08F_set_keyboard_control_group(v9, v10, v11, v17); - goto LABEL_43; - } - v4 = 2; - v7 = 1; - v6 = 100; - } - CreateButtonInColumn(v7, v6); - goto LABEL_28; - } - CreateButtonInColumn(0, 0x12u); - CreateButtonInColumn(1, 0x34u); - CreateButtonInColumn(2, 0x35u); - v12 = 54; - } -LABEL_39: - CreateButtonInColumn(3, v12); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 4; - goto LABEL_42; - } - if ( a1 == 13 ) - { - CreateButtonInColumn(0, 0x12u); - v16 = 56; -LABEL_37: - CreateButtonInColumn(1, v16); - v17 = 2; - v11 = 0; - v10 = 1; - v9 = 2; - goto LABEL_42; - } - switch ( a1 ) - { - case 1: - case 2: - case 3: - case 4: - CreateButtonInColumn(0, 2u); - CreateButtonInColumn(1, 0x5Fu); - CreateButtonInColumn(2, 0x5Eu); - v12 = 96; - goto LABEL_39; - case 5: - CreateButtonInColumn(0, 0x12u); - v13 = 48; - goto LABEL_9; - case 6: - CreateButtonInColumn(0, 0x12u); - v13 = 49; - goto LABEL_9; - case 7: - CreateButtonInColumn(0, 0x12u); - v13 = 50; - goto LABEL_9; - case 8: - CreateButtonInColumn(0, 0x12u); - v13 = 51; -LABEL_9: - CreateButtonInColumn(1, v13); - v14 = 72; - goto LABEL_41; - case 9: - CreateButtonInColumn(0, 0x12u); - v15 = 52; - goto LABEL_13; - case 10: - CreateButtonInColumn(0, 0x12u); - v15 = 53; - goto LABEL_13; - case 11: - CreateButtonInColumn(0, 0x12u); - v15 = 54; -LABEL_13: - CreateButtonInColumn(1, v15); - v14 = 61; - goto LABEL_41; - case 12: - CreateButtonInColumn(0, 0x12u); - v16 = 55; - goto LABEL_37; - default: - break; - } -LABEL_43: - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; -} -// F8B1E0: using guessed type int dword_F8B1E0; - //----- (004B3E1E) -------------------------------------------------------- void __cdecl sub_4B3E1E() { @@ -5914,7 +3594,8 @@ { int v1; // edi@1 char *v2; // edi@1 - + + __debugbreak(); v1 = a4; uDialogueType = 78; current_npc_text = (char *)pNPCTopics[a4 + 168].pText; @@ -5936,7 +3617,7 @@ //----- (004B46A5) -------------------------------------------------------- void __fastcall DrawTextAtStatusBar( const char *Str, int a5 ) - { +{ int v4; // eax@1 pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar); v4 = pFontLucida->AlignText_Center(450, Str); @@ -6080,19 +3761,17 @@ ArenaFight(); return; } - else if(newDialogueType == DIALOGUE_9) + else if(newDialogueType == DIALOGUE_USE_NPC_ABILITY) { - if ( !sub_4BB756(speakingNPC->uProfession) ) + if (UseNPCSkill((NPCProf)speakingNPC->uProfession) == 0) { - if ( speakingNPC->uProfession != 41 ) + if ( speakingNPC->uProfession != GateMaster ) speakingNPC->bHasUsedTheAbility = 1; pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); } else - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2u); //"Your packs are already full!" - } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2); //"Your packs are already full!" } else if(newDialogueType == DIALOGUE_13) { @@ -6196,22 +3875,22 @@ return 0; switch( p2DEvents[_2da_idx - 1].uType ) { - case BildingType_WeaponShop: + case BuildingType_WeaponShop: { test = pItemsTable->pItems[item->uItemID].uEquipType <= 2; break; } - case BildingType_ArmorShop: + case BuildingType_ArmorShop: { test = pItemsTable->pItems[item->uItemID].uEquipType >= 3; break; } - case BildingType_MagicShop: + case BuildingType_MagicShop: { test = pItemsTable->pItems[item->uItemID].uSkillType == 38 || pItemsTable->pItems[item->uItemID].uEquipType == 16; break; } - case BildingType_AlchemistShop: + case BuildingType_AlchemistShop: { test = pItemsTable->pItems[item->uItemID].uEquipType == 13 || pItemsTable->pItems[item->uItemID].uEquipType == 14 || (pItemsTable->pItems[item->uItemID].uEquipType > 14 && !(pItemsTable->pItems[item->uItemID].uEquipType != 17
--- a/mm7_5.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/mm7_5.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -16,7 +16,6 @@ #include "Mouse.h" #include "Keyboard.h" #include "GammaControl.h" -#include "stru11.h" #include "mm7_data.h" #include "FactionTable.h" #include "Vis.h" @@ -113,10 +112,10 @@ int v56; // edx@432 int v57; // eax@432 Player *pPlayer; // edx@442 - unsigned int v59; // eax@445 + unsigned int pMapNum; // eax@445 signed int v60; // ST64_4@459 - NPCData *pNPCData2; // eax@467 - unsigned __int64 v62; // kr00_8@467 + //NPCData *pNPCData2; // eax@467 + //unsigned __int64 v62; // kr00_8@467 __int16 v63; // dx@479 unsigned int v64; // eax@486 int v65; // ecx@486 @@ -206,7 +205,7 @@ int v155; // [sp-4h] [bp-600h]@165 int v156; // [sp-4h] [bp-600h]@204 //const char *v157; // [sp-4h] [bp-600h]@444 - unsigned int v158; // [sp-4h] [bp-600h]@449 + //unsigned int v158; // [sp-4h] [bp-600h]@449 //__int16 v159; // [sp-4h] [bp-600h]@550 int v160; // [sp-4h] [bp-600h]@599 const char *v161; // [sp-4h] [bp-600h]@637 @@ -233,7 +232,7 @@ signed int thisb; // [sp+14h] [bp-5E8h]@272 Player *pPlayer7; // [sp+14h] [bp-5E8h]@373 Player *pPlayer8; // [sp+14h] [bp-5E8h]@377 - char *thise; // [sp+14h] [bp-5E8h]@445 + char *pMapName; // [sp+14h] [bp-5E8h]@445 Player *pPlayer9; // [sp+14h] [bp-5E8h]@455 int thisg; // [sp+14h] [bp-5E8h]@467 int thish; // [sp+14h] [bp-5E8h]@528 @@ -260,7 +259,7 @@ POINT v209; // [sp+78h] [bp-584h]@777 POINT v210; // [sp+80h] [bp-57Ch]@397 POINT v211; // [sp+88h] [bp-574h]@704 - __int64 v212; // [sp+90h] [bp-56Ch]@467 + //__int64 v212; // [sp+90h] [bp-56Ch]@467 int v213; // [sp+98h] [bp-564h]@385 char pLevelName[32]; // [sp+9Ch] [bp-560h]@380 char pOut[32]; // [sp+BCh] [bp-540h]@370 @@ -391,7 +390,7 @@ if ( dword_6BE138 == 124 || uMessageParam ) { pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pGUIWindow_CurrentMenu->Release(); @@ -409,7 +408,7 @@ continue; case UIMSG_Game_OpenLoadGameDialog: pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pGUIWindow_CurrentMenu->Release(); @@ -420,7 +419,7 @@ if ( dword_6BE138 == 132 || uMessageParam ) { pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); if ( pMessageQueue_50CBD0->uNumMessages ) pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; pGUIWindow_CurrentMenu->Release(); @@ -441,7 +440,7 @@ case UIMSG_80: __debugbreak(); pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); pGUIWindow_CurrentMenu->Release(); pCurrentScreen = SCREEN_OPTIONS; pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_8, 0, 0); @@ -995,7 +994,7 @@ { if ( pCurrentScreen == SCREEN_QUICK_REFERENCE ) { - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); if ( pGUIWindow_Settings ) { if ( pCurrentScreen == SCREEN_CHARACTERS ) @@ -1021,7 +1020,7 @@ pEventTimer->Resume(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; - pIcons_LOD->_4355F7(); + pIcons_LOD->RemoveTexturesFromTextureList(); continue; } } @@ -1032,7 +1031,7 @@ switch ( pCurrentScreen ) { case SCREEN_CASTING: - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); if ( some_active_character ) { uActiveCharacter = some_active_character; @@ -1075,7 +1074,7 @@ pEventTimer->Resume(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; - pIcons_LOD->_4355F7(); + pIcons_LOD->RemoveTexturesFromTextureList(); continue; case SCREEN_BOOKS: pBooksWindow->Release(); @@ -1107,11 +1106,11 @@ pEventTimer->Resume(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; - pIcons_LOD->_4355F7(); + pIcons_LOD->RemoveTexturesFromTextureList(); continue; case SCREEN_SAVEGAME: case SCREEN_LOADGAME: - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); //crt_deconstruct_ptr_6A0118(); stru_506E40.Release(); break; @@ -1121,7 +1120,7 @@ case SCREEN_CHEST: pWindow2 = pChestWindow; pWindow2->Release(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; pEventTimer->Resume(); @@ -1130,7 +1129,7 @@ __debugbreak(); pWindow2 = ptr_507BC8; pWindow2->Release(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; pEventTimer->Resume(); @@ -1168,9 +1167,9 @@ break; case SCREEN_MENU: pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); stru_506E40.Release(); break; case SCREEN_VIDEO_OPTIONS: @@ -1246,7 +1245,7 @@ case SCREEN_REST://close rest screen if ( dword_506F14 ) { - Rest(_506F18_num_hours_to_sleep); + Rest(_506F18_num_minutes_to_sleep); pParty->pPlayers[3].pConditions[2] = 0i64; pParty->pPlayers[2].pConditions[2] = 0i64; pParty->pPlayers[1].pConditions[2] = 0i64; @@ -1257,8 +1256,8 @@ pTexture_RestUI_CurrentHourglassFrame = 0; pTexture_RestUI_CurrentSkyFrame = 0; pIcons_LOD->SyncLoadedFilesCount(); - pIcons_LOD->_4114F2(); - _506F18_num_hours_to_sleep = 0; + pIcons_LOD->RemoveTexturesPackFromTextureList(); + _506F18_num_minutes_to_sleep = 0; dword_506F14 = 0; dword_507B94 = 1; if ( pGUIWindow_Settings ) @@ -1286,13 +1285,13 @@ pEventTimer->Resume(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; - pIcons_LOD->_4355F7(); + pIcons_LOD->RemoveTexturesFromTextureList(); continue; case SCREEN_E: __debugbreak(); pGUIWindow_CurrentMenu->Release(); pCurrentScreen = SCREEN_HOUSE; - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); continue; case SCREEN_HOUSE: if ( uDialogueType ) @@ -1307,7 +1306,7 @@ if ( sub_4BD8B5() ) continue; } - sub_4B1D27(); + GetHouseGoodbyeSpeech(); pAudioPlayer->PlaySound(SOUND_7, 814, 0, -1, 0, 0, 0, 0); pVideoPlayer->Unload(); pGUIWindow_CurrentMenu = window_SpeakInHouse; @@ -1336,7 +1335,7 @@ pEventTimer->Resume(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = true; - pIcons_LOD->_4355F7(); + pIcons_LOD->RemoveTexturesFromTextureList(); continue; case SCREEN_INPUT_BLV://click escape if ( uCurrentHouse_Animation == 153 ) @@ -1394,7 +1393,7 @@ case SCREEN_CHARACTERS: CharacterUI_ReleaseButtons(); sub_419379(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); if ( pGUIWindow_Settings ) { if ( pCurrentScreen == SCREEN_CHARACTERS ) @@ -1420,7 +1419,7 @@ pEventTimer->Resume(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = true; - pIcons_LOD->_4355F7(); + pIcons_LOD->RemoveTexturesFromTextureList(); continue; default: if ( pGUIWindow_Settings ) @@ -1448,7 +1447,7 @@ pEventTimer->Resume(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = 1; - pIcons_LOD->_4355F7(); + pIcons_LOD->RemoveTexturesFromTextureList(); continue; } if ( pGUIWindow_Settings ) @@ -1476,12 +1475,12 @@ pEventTimer->Resume(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = true; - pIcons_LOD->_4355F7(); + pIcons_LOD->RemoveTexturesFromTextureList(); continue; } CharacterUI_ReleaseButtons(); sub_419379(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); } if ( pGUIWindow_Settings ) { @@ -1508,7 +1507,7 @@ pEventTimer->Resume(); pCurrentScreen = SCREEN_GAME; viewparams->bRedrawGameUI = true; - pIcons_LOD->_4355F7(); + pIcons_LOD->RemoveTexturesFromTextureList(); continue; } if ( !pGUIWindow_Settings )//Draw Menu @@ -1667,7 +1666,7 @@ pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; dword_50CDC8 = 1; sub_42FBDD(); - pNPCData4 = (NPCData *)GetTravelTime(); + //pNPCData4 = (NPCData *)GetTravelTime(); strcpy(pOutdoor->pLevelFilename, pCurrentMapName.data()); if ( bUnderwater != 1 && pParty->bFlying || pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pOut, 20) != 1 ) @@ -1696,11 +1695,11 @@ ++pGameLoadingUI_ProgressBar->uProgressMax; SaveGame(1, 0); pGameLoadingUI_ProgressBar->Progress(); - RestAndHeal(1440 * (signed int)pNPCData4); + RestAndHeal(1440 * (signed int)GetTravelTime()); if ( pParty->uNumFoodRations ) { pParty->RestAndHeal(); - if ( ((pParty->uNumFoodRations - (signed int)pNPCData4) & 0x80000000u) != 0 ) + if ( ((pParty->uNumFoodRations - (signed int)GetTravelTime()) & 0x80000000u) != 0 ) { pPlayer7 = pParty->pPlayers; do @@ -1711,7 +1710,7 @@ while ( (signed int)pPlayer7 < (signed int)pParty->pHirelings ); ++pParty->days_played_without_rest; } - Party::TakeFood((unsigned int)pNPCData4); + Party::TakeFood((unsigned int)GetTravelTime()); } else { @@ -1965,26 +1964,25 @@ uNumSeconds = (unsigned int)&pPlayer->pInstalledBeacons[uMessageParam]; if ( bRecallingBeacon ) { - if ( !*((int *)&pSavegameThumbnails.data()->pPixels + 10 * uMessageParam) ) + if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) ) continue; - v173 = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(pPlayer->pInstalledBeacons[uMessageParam].field_18))].pName; + v173 = pMapStats->pInfos[sub_410D99_get_map_index(pPlayer->pInstalledBeacons[uMessageParam].SaveFileID)].pName; sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[474], v173);// "Recall to %s" GameUI_SetFooterString(pTmpBuf.data()); continue; } - v59 = pMapStats->GetMapInfo(pCurrentMapName.data()); - thise = "Not in Map Stats"; - if ( v59 ) - thise = pMapStats->pInfos[v59].pName; - if ( !*((int *)&pSavegameThumbnails.data()->pPixels + 10 * uMessageParam) || !v59 ) + pMapNum = pMapStats->GetMapInfo(pCurrentMapName.data()); + pMapName = "Not in Map Stats"; + if ( pMapNum ) + pMapName = pMapStats->pInfos[pMapNum].pName; + if ( !*((int *)&pSavegameThumbnails[10 * uMessageParam].pPixels ) || !pMapNum ) { - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[476], thise);// "Set to %s" + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[476], pMapName);// "Set to %s" GameUI_SetFooterString(pTmpBuf.data()); continue; } v174 = pMapStats->pInfos[sub_410D99_get_map_index(*(short *)(uNumSeconds + 26))].pName; - v158 = (unsigned int)thise; - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], v158, v174);// "Set %s over %s" + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[475], (unsigned int)pMapName, v174);// "Set %s over %s" GameUI_SetFooterString(pTmpBuf.data()); continue; case UIMSG_CloseAfterInstallBeacon: @@ -1999,8 +1997,7 @@ continue; case UIMSG_InstallBeacon: pPlayer9 = pPlayers[_506348_current_lloyd_playerid + 1]; - pNPCData4 = (NPCData *)&pPlayer9->pInstalledBeacons[uMessageParam]; - if ( !*(_QWORD *)&pNPCData4->pName && bRecallingBeacon ) + if ( !pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime && bRecallingBeacon ) continue; byte_506360 = 1; pPlayer9->CanCastSpell(uRequiredMana); @@ -2018,38 +2015,30 @@ pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[dword_506338], 0, 0, -1, 0, dword_50633C, 0, 0); if ( bRecallingBeacon ) { - if ( _stricmp(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]) ) + if ( _stricmp(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]) ) { SaveGame(1, 0); OnMapLeave(); - strcpy(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[HIWORD(pNPCData4->uProfession)]); + strcpy(pCurrentMapName.data(), (const char *)&pGames_LOD->pSubIndices[pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID]); dword_6BE364_game_settings_1 |= 1; uGameState = GAME_STATE_2; - _5B65A8_npcdata_uflags_or_other = pNPCData4->uFlags; - _5B65AC_npcdata_fame_or_other = pNPCData4->fame; - _5B65B0_npcdata_rep_or_other = pNPCData4->rep; - _5B65B4_npcdata_loword_house_or_other = LOWORD(pNPCData4->Location2D); - _5B65B8_npcdata_hiword_house_or_other = HIWORD(pNPCData4->Location2D); + _5B65A8_npcdata_uflags_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X; + _5B65AC_npcdata_fame_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y; + _5B65B0_npcdata_rep_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z; + _5B65B4_npcdata_loword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X; + _5B65B8_npcdata_hiword_house_or_other = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y; dword_5B65C0 = 1; } else { - pParty->vPosition.x = pNPCData4->uFlags; - pParty->vPosition.y = pNPCData4->fame; - pParty->vPosition.z = pNPCData4->rep; + pParty->vPosition.x = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X; + pParty->vPosition.y = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y; + pParty->vPosition.z = pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z; pParty->uFallStartY = pParty->vPosition.z; - pParty->sRotationY = LOWORD(pNPCData4->Location2D); - pParty->sRotationX = HIWORD(pNPCData4->Location2D); + pParty->sRotationY = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X; + pParty->sRotationX = pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y; } pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v0; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - //crt_deconstruct_ptr_6A0118(); pBooksWindow->Release(); pGUIWindow_CurrentMenu->Release(); pBooksWindow = 0; @@ -2060,28 +2049,19 @@ sprintf(a1, "data\\lloyd%d%d.pcx", _506348_current_lloyd_playerid + 1, uMessageParam + 1); SaveScreenshot(a1); LoadThumbnailLloydTexture(uMessageParam, _506348_current_lloyd_playerid + 1); - v212 = qword_506350 << 7; - pNPCData2 = pNPCData4; - thisg = 0; - v62 = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335); - pNPCData4->pName = (char *)v62; - pNPCData2->uPortraitID = HIDWORD(v62); - pNPCData2->uFlags = pParty->vPosition.x; - pNPCData2->fame = pParty->vPosition.y; - pNPCData2->rep = pParty->vPosition.z; - LOWORD(pNPCData2->Location2D) = LOWORD(pParty->sRotationY); - HIWORD(pNPCData2->Location2D) = LOWORD(pParty->sRotationX); + pPlayer9->pInstalledBeacons[uMessageParam].uBeaconTime = pParty->uTimePlayed + (signed __int64)((double)(qword_506350 << 7) * 0.033333335); + pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_X = pParty->vPosition.x; + pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Y = pParty->vPosition.y; + pPlayer9->pInstalledBeacons[uMessageParam].PartyPos_Z = pParty->vPosition.z; + pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_X = LOWORD(pParty->sRotationY); + pPlayer9->pInstalledBeacons[uMessageParam].PartyRot_Y = LOWORD(pParty->sRotationX); if ( (signed int)pGames_LOD->uNumSubDirs / 2 <= 0 ) continue; - uAction = 0; - while ( _stricmp((const char *)pGames_LOD->pSubIndices + uAction, pCurrentMapName.data()) ) + for ( thisg = 0; thisg < (signed int)pGames_LOD->uNumSubDirs / 2; ++thisg ) { - ++thisg; - uAction += 32; - if ( thisg >= (signed int)pGames_LOD->uNumSubDirs / 2 ) - continue; + if ( !_stricmp((const char *)pGames_LOD->pSubIndices[thisg].pFilename, pCurrentMapName.data()) ) + pPlayer9->pInstalledBeacons[uMessageParam].SaveFileID = thisg; } - HIWORD(pNPCData4->uProfession) = thisg; } continue; case UIMSG_ClickTownInTP: @@ -2199,6 +2179,7 @@ default: if ( uMessageParam != 5 ) { + __debugbreak(); // warning C4700: uninitialized local variable 'v200' used sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[35], v200); GameUI_SetFooterString(pTmpBuf.data()); continue; @@ -2265,7 +2246,7 @@ GameUI_SetFooterString(pTmpBuf.data()); continue; case UIMSG_ShowFinalWindow: - sprintf(pFinalMessage.data(), "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer." + sprintfex(pFinalMessage.data(), "%s\n \n%s\n \n%s", pGlobalTXT_LocalizationStrings[151],// "Congratulations Adventurer." pGlobalTXT_LocalizationStrings[118],// "We hope that you've enjoyed playing Might and Magic VII as much as we did making it. We have saved this screen as MM7_WIN.PCX in your MM7 directory. You can print it out as proof of your accomplishment." pGlobalTXT_LocalizationStrings[167]);// "- The Might and Magic VII Development Team." ModalWindow(pFinalMessage.data(), 196); @@ -2464,7 +2445,7 @@ GUIWindow::Create(pButton_RestUI_Wait5Minutes->uX, pButton_RestUI_Wait5Minutes->uY, 0, 0, WINDOW_PressedButton2, (int)pButton_RestUI_Wait5Minutes, pGlobalTXT_LocalizationStrings[238]);// "Wait 5 Minutes" dword_506F14 = 1; - _506F18_num_hours_to_sleep = 5; + _506F18_num_minutes_to_sleep = 5; continue; case UIMSG_Wait1Hour: if ( dword_506F14 == 2 ) @@ -2476,15 +2457,15 @@ GUIWindow::Create(pButton_RestUI_Wait1Hour->uX, pButton_RestUI_Wait1Hour->uY, 0, 0, WINDOW_PressedButton2, (int)pButton_RestUI_Wait1Hour, pGlobalTXT_LocalizationStrings[239]);// "Wait 1 Hour" dword_506F14 = 1; - _506F18_num_hours_to_sleep = 60; + _506F18_num_minutes_to_sleep = 60; continue; case UIMSG_RentRoom: dword_506F14 = 2; RestUI_Load(); v86 = 60 * (_494820_training_time(pParty->uCurrentHour) + 1) - pParty->uCurrentMinute; - _506F18_num_hours_to_sleep = v86; - if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 ) - _506F18_num_hours_to_sleep = v86 + 720; + _506F18_num_minutes_to_sleep = v86; + if ( uMessageParam == 111 || uMessageParam == 114 || uMessageParam == 116 ) // 107 = Emerald Isle tavern + _506F18_num_minutes_to_sleep = v86 + 12 * 60; dword_506F14 = 2; pParty->RestAndHeal(); pParty->days_played_without_rest = 0; @@ -2569,7 +2550,7 @@ pNPCData4 = (NPCData *)((v93 > v92 + pMapInfo->EncM2percent) + 2); else pNPCData4 = (NPCData *)1; - if ( !sub_45063B(pMapInfo, (int)pNPCData4) ) + if ( !_45063B_spawn_some_monster(pMapInfo, (int)pNPCData4) ) pNPCData4 = 0; if ( pNPCData4 ) { @@ -2578,7 +2559,7 @@ HIDWORD(pParty->pPlayers[pPlayerNum].pConditions[2]) = 0; v95 = rand(); Rest(v95 % 6 + 60); - _506F18_num_hours_to_sleep = 0; + _506F18_num_minutes_to_sleep = 0; dword_506F14 = 0; /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) { @@ -2594,7 +2575,7 @@ } } Party::TakeFood(uRestUI_FoodRequiredToRest); - _506F18_num_hours_to_sleep = 480; + _506F18_num_minutes_to_sleep = 480; dword_506F14 = 2; pParty->RestAndHeal(); pParty->days_played_without_rest = 0; @@ -2615,7 +2596,7 @@ (int)pButton_RestUI_WaitUntilDawn, pGlobalTXT_LocalizationStrings[237]);// "Wait until Dawn" v97 = _494820_training_time(pParty->uCurrentHour); dword_506F14 = 1; - _506F18_num_hours_to_sleep = 60 * v97 - pParty->uCurrentMinute; + _506F18_num_minutes_to_sleep = 60 * v97 - pParty->uCurrentMinute; continue; case UIMSG_HintSelectRemoveQuickSpellBtn: if ( quick_spell_at_page && byte_506550 ) @@ -2667,7 +2648,7 @@ } v99 = quick_spell_at_page + 11 * pPlayers[uActiveCharacter]->lastOpenedSpellbookPage; pPlayers[uActiveCharacter]->uQuickSpell = v99; - stru_A750F8[uActiveCharacter + 3]._494836(v99, uActiveCharacter); + stru_AA1058[uActiveCharacter - 1]._494836(v99, uActiveCharacter); if ( uActiveCharacter ) pPlayer10->PlaySound(SPEECH_12, 0); byte_506550 = 0; @@ -2713,7 +2694,7 @@ if ( uAction >= (signed int)pNPCData4 ) uAction = 0; } - sub_41140B(); + OnCloseSpellBookPage(); pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = LOBYTE(v217[uAction]); pGUIWindow_CurrentMenu->OpenSpellBook(); v127 = rand() % 2 + 204; @@ -2722,7 +2703,7 @@ case UIMSG_OpenSpellbookPage: if ( pTurnEngine->turn_stage == 3 || !uActiveCharacter || uMessageParam == pPlayers[uActiveCharacter]->lastOpenedSpellbookPage ) continue; - sub_41140B(); + OnCloseSpellBookPage(); pPlayers[uActiveCharacter]->lastOpenedSpellbookPage = uMessageParam; pGUIWindow_CurrentMenu->OpenSpellBook(); v127 = rand() % 2 + 204; @@ -2746,7 +2727,7 @@ pEventTimer->Resume(); viewparams->bRedrawGameUI = 1; pCurrentScreen = SCREEN_GAME; - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); v103 = quick_spell_at_page + 11 * player->lastOpenedSpellbookPage; /*if ( dword_50C9E8 < 40 ) { @@ -2862,9 +2843,9 @@ pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); continue; case UIMSG_ClickAwardScrollBar: - dword_50651C = 1; + books_page_number = 1; if ( pMouse->GetCursorPos(&v211)->y > 178 ) - dword_50651C = -1; + books_page_number = -1; continue; case UIMSG_ClickAwardsUpBtn: GUIWindow::Create(pBtn_Up->uX, pBtn_Up->uY, 0, 0, WINDOW_CharactersPressedButton, (int)pBtn_Up, 0); @@ -3017,8 +2998,8 @@ continue; case UIMSG_ShowStatus_Funds: v174 = (char *)pParty->uNumGoldInBank; - v158 = pParty->uNumGold + pParty->uNumGoldInBank; - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[489], v158, v174);// "You have %d total gold, %d in the Bank" + //v158 = pParty->uNumGold + pParty->uNumGoldInBank; + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[489], pParty->uNumGold + pParty->uNumGoldInBank, v174);// "You have %d total gold, %d in the Bank" GameUI_SetFooterString(pTmpBuf.data()); continue; case UIMSG_ShowStatus_DateTime: @@ -3435,7 +3416,7 @@ case UIMSG_ChangeGameState: uGameState = GAME_FINISHED; break; - case UIMSG_11: + case UIMSG_ChangeCursor: pMouse->SetCursorBitmap("MICON2"); break; case UIMSG_3A: @@ -3548,7 +3529,7 @@ } if ( pCurrentScreen == SCREEN_LOADGAME ) { - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); //crt_deconstruct_ptr_6A0118(); pTexture_PCX.Release(); pTexture_PCX.Load("title.pcx", 0); @@ -3583,6 +3564,7 @@ break; case UIMSG_PlayerCreationRemoveDownSkill: uPlayerCreationUI_SelectedCharacter = pParam; + __debugbreak(); pGUIWindow_CurrentMenu->pCurrentPosActiveItem = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) % 7 + pGUIWindow_CurrentMenu->pStartingPosActiveItem + 7 * pParam; pParty->pPlayers[0].pActiveSkills[(&pPlayer[uPlayerCreationUI_SelectedCharacter])->GetSkillIdxByOrder(3) @@ -3599,13 +3581,10 @@ //----- (00436427) -------------------------------------------------------- double __cdecl get_shading_dist_mist() { - double result; // st7@2 - - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - result = (double)pOutdoorCamera->shading_dist_mist; + if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + return (double)pOutdoorCamera->shading_dist_mist; else - result = 16192.0; - return result; + return 16192.0; } //----- (0043648F) -------------------------------------------------------- @@ -3626,444 +3605,8 @@ this->z = (1.0 / sqrt(this->x * this->x + this->y * this->y + this->z * this->z)) * this->z; } -//----- (00438526) -------------------------------------------------------- -stru11::stru11() -{ - stru11 *v1; // esi@1 - signed int v2; // eax@1 - char *v3; // edx@1 - - v1 = this; - v2 = 0; - this->cpuid_00000000_eax_numops = 0; - this->cpuid_00000001_eax = 0; - this->cpuid_00000001_edx = 0; - this->field_38 = 0; - this->field_3C = 0; - this->cpuid_80000000_edx = 0; - this->cpuid_80000001_eax = 0; - this->cpuid_80000001_edx = 0; - this->cpuid_80000005_ebx = 0; - this->cpuid_80000005_ecx = 0; - this->cpuid_80000005_edx = 0; - this->cpuid_80000006_ecx = 0; - this->field_AC = 0; - this->uProcessorManufacturer = 0; - LOBYTE(this->cpuid_80000002_registers2[0]) = 0; - v3 = (char *)&this->cpuid_00000002_eax; - do - { - if ( v2 < 3 ) - *((int *)v3 - 9) = 0; - if ( v2 < 4 ) - *(int *)v3 = 0; - if ( v2 < 12 ) - *((int *)v3 + 17) = 0; - if ( v2 < 13 ) - this->pCPUString[v2] = 0; - if ( v2 < 30 ) - *((char *)this->field_40 + v2) = 0; - *((char *)&this->cpuid_80000002_registers2[0] + v2++ + 1) = 0; - v3 += 4; - } - while ( v2 < 48 ); - CheckCPU(); -} - -//----- (004385B5) -------------------------------------------------------- -void stru11::CheckCPU() -{ - LOG_DECOMPILATION_WARNING(); - /* - int v5; // [sp-4h] [bp-10h]@0 - signed int v6; // [sp+4h] [bp-8h]@1 - signed int v7; // [sp+8h] [bp-4h]@1 - - _CF = 0; - _OF = 0; - _ZF = 1; - _SF = 0; - v7 = 0; - __asm { pushf } - v6 = 3; - if ( v5 != (v5 ^ 0x40000) ) - { - __asm { popf } - v6 = 4; - __asm { pushf } - if ( v5 != (v5 ^ 0x200000) ) - { - v7 = 1; - v6 = 0; - } - } - if ( v6 == 3 ) - { - this->field_AC = 1; - } - else - { - if ( v6 == 4 ) - { - this->field_AC = 2; - } - else - { - if ( v7 ) - { - this->field_AC = 2; - RunCPUID(); - } - else - { - this->field_AC = 0; - } - } - }*/ -} - -//----- (00438659) -------------------------------------------------------- -void stru11::RunCPUID() -{ - __debugbreak(); - /*stru11 *v6; // esi@1 - unsigned int uNumOps; // edi@1 - int uNumExtOps; // edi@16 - char pCyrixString[16]; // [sp+Ch] [bp-60h]@1 - char pCentaurString[16]; // [sp+1Ch] [bp-50h]@1 - char pAMDString[16]; // [sp+2Ch] [bp-40h]@1 - char pIntelString[16]; // [sp+3Ch] [bp-30h]@1 - char pCPUString[16]; // [sp+4Ch] [bp-20h]@1 - stru11 *thisa; // [sp+5Ch] [bp-10h]@1 - char *v35; // [sp+60h] [bp-Ch]@1 - int v36; // [sp+64h] [bp-8h]@1 - int v37; // [sp+68h] [bp-4h]@1 - - thisa = this; - *(int *)pIntelString = *(int *)"GenuineIntel"; - *(int *)&pIntelString[4] = *(int *)"ineIntel"; - *(int *)&pIntelString[8] = *(int *)"ntel"; - pIntelString[12] = aGenuineintel[12]; - *(int *)pAMDString = *(int *)"AuthenticAMD"; - *(int *)&pAMDString[4] = *(int *)"enticAMD"; - *(int *)&pAMDString[8] = *(int *)"cAMD"; - pAMDString[12] = aAuthenticamd[12]; - *(int *)pCyrixString = *(int *)"CyrixInstead"; - *(int *)&pCyrixString[4] = *(int *)"xInstead"; - *(int *)&pCyrixString[8] = *(int *)"tead"; - pCyrixString[12] = aCyrixinstead[12]; - *(int *)pCentaurString = *(int *)"CentaurHauls"; - *(int *)&pCentaurString[4] = *(int *)"aurHauls"; - *(int *)&pCentaurString[8] = *(int *)"auls"; - v37 = 0; - v36 = 0; - pCentaurString[12] = aCentaurhauls[12]; - v35 = pCPUString; - pCPUString[12] = 0; - _EAX = 0; - __asm { cpuid } - v37 = _EAX; - *(int *)pCPUString = _EBX; - *(int *)&pCPUString[4] = _EDX; - *(int *)&pCPUString[8] = _ECX; - v6 = thisa; - uNumOps = _EAX; - thisa->cpuid_00000000_ebx_vendorstr1 = _EBX; - v6->cpuid_00000000_edx_vendorstr2 = *(int *)&pCPUString[4]; - v6->cpuid_00000000_ecx_vendorstr3 = *(int *)&pCPUString[8]; - v6->cpuid_00000000_eax_numops = _EAX; - strcpy(v6->pCPUString, pCPUString); - if ( strcmp(pIntelString, pCPUString) ) - { - if ( strcmp(pAMDString, pCPUString) ) - { - if ( strcmp(pCyrixString, pCPUString) ) - { - if ( strcmp(pCentaurString, pCPUString) ) - v6->uProcessorManufacturer = 0; - else - v6->uProcessorManufacturer = 4; - } - else - { - v6->uProcessorManufacturer = 3; - } - } - else - { - v6->uProcessorManufacturer = 2; - } - } - else - { - v6->uProcessorManufacturer = 1; - } - if ( uNumOps >= 1 ) - RunCPUID_op1(); - if ( uNumOps >= 2 ) - RunCPUID_op2(); - _EAX = 0x80000000u; - __asm { cpuid } - if ( !(_EAX & 0x80000000) ) - _EAX = 0x80000000u; - v36 = _EAX; - v6->cpuid_80000000_edx = _EAX; - uNumExtOps = _EAX ^ 0x80000000; - if ( (_EAX ^ 0x80000000u) >= 1 ) - { - _EAX = 0x80000001u; - __asm { cpuid } - thisa = (stru11 *)_EAX; - v35 = (char *)_EDX; - v6->cpuid_80000001_eax = _EAX; - v6->cpuid_80000001_edx = (int)v35; - } - if ( (unsigned int)uNumExtOps >= 4 ) - RunCPUID_ext2_3_4(); - if ( (unsigned int)uNumExtOps >= 5 ) - { - _EAX = 0x80000005u; - __asm { cpuid } - thisa = (stru11 *)_EBX; - v35 = (char *)_ECX; - v36 = _EDX; - v6->cpuid_80000005_ebx = _EBX; - v6->cpuid_80000005_ecx = (int)v35; - v6->cpuid_80000005_edx = v36; - } - if ( (unsigned int)uNumExtOps >= 6 ) - { - _EAX = 0x80000006u; - __asm { cpuid } - v6->cpuid_80000006_ecx = _ECX; - }*/ -} - -//----- (00438821) -------------------------------------------------------- -void stru11::RunCPUID_op1() -{ - __debugbreak(); - /*stru11 *v1; // esi@1 - unsigned int v7; // ecx@1 - int v8; // eax@3 - int v9; // eax@10 - signed int v10; // eax@11 - int v11; // ecx@11 - int v12; // eax@15 - signed int v13; // eax@19 - int v14; // ecx@19 - signed int v15; // eax@25 - int v16; // ecx@25 - signed int v17; // eax@34 - int v18; // ecx@34 - - v1 = this; - _EAX = 1; - __asm { cpuid } - v7 = _EAX; - v1->cpuid_00000001_edx = _EDX; - v1->cpuid_00000001_eax = _EAX; - if ( (_EAX & 0x3000) == 8192 ) - { - LOBYTE(v1->cpuid_80000002_registers2[0]) = 1; - v7 = 0; - } - v8 = (v7 >> 8) & 0xF; - switch ( v8 ) - { - case 4: - v1->field_AC = 2; - break; - case 5: - v1->field_AC = 15; - break; - case 6: - v1->field_AC = 36; - break; - default: - v1->field_AC = 49; - break; - } - v9 = v1->uProcessorManufacturer; - if ( v9 == 1 ) - { - v10 = 0; - v11 = v7 & 0x3FF0; - while ( v11 != dword_4E4948[2 * v10] ) - { - ++v10; - if ( v10 >= 17 ) - return; - } - v12 = dword_4E494C[2 * v10]; - goto LABEL_39; - } - if ( v9 == 2 ) - { - if ( (v7 & 0xF00) == dword_4E49D0[0] ) - { - v12 = dword_4E49D4[0]; - } - else - { - v13 = 1; - v14 = v7 & 0x3FF0; - while ( v14 != dword_4E49D0[2 * v13] ) - { - ++v13; - if ( v13 >= 9 ) - return; - } - v12 = dword_4E49D4[2 * v13]; - } - goto LABEL_39; - } - if ( v9 != 3 ) - { - if ( v9 != 4 ) - return; - v17 = 0; - v18 = v7 & 0x3FF0; - while ( v18 != dword_4E4A40[2 * v17] ) - { - ++v17; - if ( v17 >= 2 ) - return; - } - v12 = dword_4E4A44[2 * v17]; - goto LABEL_39; - } - v15 = 1; - v16 = v7 & 0x3FF0; - while ( v16 != dword_4E4A18[2 * v15] ) - { - ++v15; - if ( v15 >= 5 ) - goto LABEL_30; - } - v1->field_AC = dword_4E4A1C[2 * v15]; -LABEL_30: - v12 = 24; - if ( v1->field_AC == 24 ) - { - if ( _EDX != 1 ) - v12 = (((_EDX != 261) - 1) & 0xA) + 15; -LABEL_39: - v1->field_AC = v12; - }*/ -} - -//----- (00438992) -------------------------------------------------------- -void stru11::RunCPUID_op2() -{ - __debugbreak(); - /* - stru11 *v1; // edi@1 - int v7; // eax@1 - signed int v8; // ecx@2 - unsigned __int8 v9; // al@3 - signed int v10; // ecx@14 - unsigned __int8 v11; // al@15 - int v12; // [sp+Ch] [bp-14h]@1 - int v13; // [sp+10h] [bp-10h]@1 - int v14; // [sp+14h] [bp-Ch]@1 - int v15; // [sp+18h] [bp-8h]@1 - int *v16; // [sp+1Ch] [bp-4h]@1 - - v1 = this; - v16 = &v12; - _EAX = 2; - __asm { cpuid } - v12 = _EAX; - v13 = _EBX; - v14 = _ECX; - v15 = _EDX; - v1->cpuid_00000002_eax = _EAX; - v1->cpuid_00000002_ebx = v13; - v1->cpuid_00000002_ecx = v14; - v1->cpuid_00000002_edx = v15; - v7 = v1->field_AC; - if ( v7 == 40 ) - { - v8 = 0; - while ( 1 ) - { - v9 = *((char *)&v12 + v8); - if ( v9 == 64 ) - { - v1->field_AC = 43; - return; - } - if ( v9 >= 0x41u && v9 <= 0x43u ) - { - v1->field_AC = 41; - return; - } - if ( v9 >= 0x44u && v9 <= 0x45u ) - break; - ++v8; - if ( v8 >= 16 ) - return; - } - v1->field_AC = 42; - } - else - { - if ( v7 == 45 ) - { - v10 = 0; - while ( 1 ) - { - v11 = *((char *)&v12 + v10); - if ( v11 >= 0x40u && v11 <= 0x43u ) - { - v1->field_AC = 46; - return; - } - if ( v11 >= 0x44u && v11 <= 0x45u ) - break; - ++v10; - if ( v10 >= 16 ) - return; - } - v1->field_AC = 47; - } - }*/ -} - -//----- (00438A67) -------------------------------------------------------- -void stru11::RunCPUID_ext2_3_4() -{ - __debugbreak(); - /*stru11 *v1; // edi@1 - stru11 *v17; // eax@1 - int v18[3][4]; // [sp+Ch] [bp-38h]@1 - stru11 *v19; // [sp+3Ch] [bp-8h]@1 - - v1 = this; - v19 = this; - _EAX = 0x80000002u; - __asm { cpuid } - v18[0][0] = _EAX; - *(_QWORD *)&v18[0][1] = __PAIR__(_ECX, _EBX); - v18[0][3] = _EDX; - _EAX = 0x80000003u; - __asm { cpuid } - v18[1][0] = _EAX; - *(_QWORD *)&v18[1][1] = __PAIR__(_ECX, _EBX); - v18[1][3] = _EDX; - _EAX = 0x80000004u; - __asm { cpuid } - v18[2][0] = _EAX; - *(_QWORD *)&v18[2][1] = __PAIR__(_ECX, _EBX); - v18[2][3] = _EDX; - v17 = v19; - memcpy(v1->cpuid_80000002_registers, v18, 0x30u); - memcpy((char *)&v17->cpuid_80000002_registers2[0] + 1, v18, 0x30u);*/ -} - //----- (00438F8F) -------------------------------------------------------- -void __cdecl area_of_effect__damage_evaluate() +void area_of_effect__damage_evaluate() { int v0; // edx@1 char *v1; // esi@2 @@ -4295,7 +3838,7 @@ //----- (0043A97E) -------------------------------------------------------- void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2) { - if ( PID_TYPE(a2) == OBJECT_BLVDoor) + if (PID_TYPE(a2) == OBJECT_BLVDoor) { layingitem_vel_50FDFC.x = pSpriteObjects[uLayingItemID].vVelocity.x; layingitem_vel_50FDFC.y = pSpriteObjects[uLayingItemID].vVelocity.y; @@ -4552,13 +4095,6 @@ } } -// A750D8: using guessed type __int64 qword_A750D8; - - -// A750D8: using guessed type __int64 qword_A750D8; - - -// A750D8: using guessed type __int64 qword_A750D8; //----- (0043F515) -------------------------------------------------------- void FindBillboardsLightLevels_BLV() @@ -5157,7 +4693,7 @@ v19 = 0; v29 = 0; if ( v17 <= 0 ) - goto LABEL_29; + return 0; do { if ( a3a >= 2 ) @@ -5192,7 +4728,6 @@ while ( v29 < v28 ); result = 1; if ( a3a != 1 ) -LABEL_29: result = 0; return result; } @@ -5292,7 +4827,7 @@ v25 = 0; v16 = dword_4F5B24_ys[1] >= a3; if ( v15 <= 0 ) - goto LABEL_29; + return 0; do { if ( a5a >= 2 ) @@ -5327,7 +4862,6 @@ while ( v25 < v15 ); result = 1; if ( a5a != 1 ) -LABEL_29: result = 0; return result; } @@ -5353,12 +4887,6 @@ return result; } -//----- (0040DEDB) -------------------------------------------------------- -unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor) -{ - return TargetColor((unsigned __int8)uColor, BYTE1(uColor), BYTE2(uColor)); -} - //----- (0040DEF3) -------------------------------------------------------- unsigned short TargetColor( unsigned __int16 r, unsigned __int16 g, unsigned __int16 b ) { @@ -5617,7 +5145,7 @@ if ( pParty->pPickedItem.uItemID == ITEM_POTION_BOTTLE ) { LABEL_116: - GameUI_DrawItemInfo(&v0->pInventoryItems[v10]); + GameUI_DrawItemInfo(&v0->pInventoryItemList[v10]); return; } if ( (signed int)pParty->pPickedItem.uItemID < 200 @@ -5634,7 +5162,7 @@ && pParty->pPickedItem.uItemID != 263 && pParty->pPickedItem.uItemID != 233 ) goto LABEL_116; - v27 = &v0->pInventoryItems[pOut.z]; + v27 = &v0->pInventoryItemList[pOut.z]; v28 = v27->uItemID; v51 = pItemsTable->pItems[v27->uItemID].uEquipType; v29 = (ItemGen *)(1800 * pParty->pPickedItem.uEnchantmentType); @@ -5644,14 +5172,22 @@ { v35 = v27->uAttributes; if ( v35 & 2 || (v51 & 0x80000000u) != 0 || (signed int)v51 > 12 || (signed int)v28 >= 500 ) - goto LABEL_92; + { + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; + } LOWORD(v35) = v35 | 0x210; v27->uAttributes = v35; } else { if ( (signed int)pParty->pPickedItem.uItemID <= 245 ) - goto LABEL_92; + { + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; + } if ( (signed int)pParty->pPickedItem.uItemID <= 250 ) { v27->UpdateTempBonus(pParty->uTimePlayed); @@ -5662,7 +5198,11 @@ || v27->uEnchantmentType || v51 && v51 != 1 && v51 != 2 || (signed int)v33 >= 500 ) - goto LABEL_92; + { + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; + } v34 = *(int *)&aSbwb00[4 * pParty->pPickedItem.uItemID + 4]; a2.y = (int)v29 << 7; v31 = (double)(signed int)((int)v29 << 7); @@ -5678,7 +5218,11 @@ || v27->uEnchantmentType || v51 && v51 != 1 && v51 != 2 || (signed int)v30 >= 500 ) - goto LABEL_92; + { + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; + } a2.y = (int)v29 << 7; v27->uSpecEnchantmentType = 40; v31 = (double)a2.y; @@ -5691,7 +5235,9 @@ v27->uAttributes = v32; } _50C9A8_item_enchantment_timer = 256; - goto LABEL_92; + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; } v36 = (70.0 - (double)pParty->pPickedItem.uEnchantmentType) * 0.01; if ( v36 < 0.0 ) @@ -5705,7 +5251,9 @@ v37 = (signed __int64)((double)a2.y - v36 * (double)a2.y); v27->uMaxCharges = v37; v27->uNumCharges = (unsigned __int8)v37; - goto LABEL_92; + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; } v14 = v13 - 222; v15 = pParty->pPickedItem.uItemID - 222; @@ -5774,7 +5322,7 @@ LABEL_54: pOut.y = 0; pOut.x = v10 + 1; - v17 = (int)v0->pInventoryIndices; + v17 = (int)v0->pInventoryMatrix; while ( *(int *)v17 != pOut.x ) { ++pOut.y; @@ -5836,9 +5384,9 @@ // *(int *)&v0->field_1F5[36 * v19 + 15] = 1; v0->pOwnItems[v19-1].uAttributes=ITEM_IDENTIFIED; v20 = v47 + 50 * v15; - v0->pInventoryItems[pOut.z].uItemID = v51; - v0->pInventoryItems[pOut.z].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType - + v0->pInventoryItems[pOut.z].uEnchantmentType) + v0->pInventoryItemList[pOut.z].uItemID = v51; + v0->pInventoryItemList[pOut.z].uEnchantmentType = (pParty->pPickedItem.uEnchantmentType + + v0->pInventoryItemList[pOut.z].uEnchantmentType) / 2; v0->SetVariable(VAR_AutoNotes, *(short *)&pItemsTable->potion_note[2 * v20 ]);//field_10168 + 388 LABEL_74: @@ -5846,9 +5394,16 @@ if ( !(pItemsTable->pItems[*(int *)(v22 + 532) ].uItemID_Rep_St) ) *(int *)(v22 + 552) |= 1u; if ( !dword_4E455C ) - goto LABEL_92; + { + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; + } v0->PlaySound(SPEECH_16, 0); - goto LABEL_91; + dword_4E455C = 0; + pMouse->RemoveHoldingItem(); + dword_50CDCC = 1; + return; } if ( v45 ) { @@ -5887,10 +5442,8 @@ if ( v0->CanAct() ) v0->PlaySound(SPEECH_17, 0); ShowStatusBarString(pGlobalTXT_LocalizationStrings[444], 2u); -LABEL_91: dword_4E455C = 0; } -LABEL_92: pMouse->RemoveHoldingItem(); dword_50CDCC = 1; return; @@ -5903,28 +5456,28 @@ case 0xCAu: case 0xCBu: case 0xCCu: - v0->pInventoryItems[pOut.z].uItemID = 222; + v0->pInventoryItemList[pOut.z].uItemID = 222; break; case 0xCDu: case 0xCEu: case 0xCFu: case 0xD0u: case 0xD1u: - v0->pInventoryItems[pOut.z].uItemID = 223; + v0->pInventoryItemList[pOut.z].uItemID = 223; break; case 0xD2u: case 0xD3u: case 0xD4u: case 0xD5u: case 0xD6u: - v0->pInventoryItems[pOut.z].uItemID = 224; + v0->pInventoryItemList[pOut.z].uItemID = 224; break; case 0xD7u: case 0xD8u: case 0xD9u: case 0xDAu: case 0xDBu: - v0->pInventoryItems[pOut.z].uItemID = 221; + v0->pInventoryItemList[pOut.z].uItemID = 221; break; default: break; @@ -5938,79 +5491,47 @@ } } -//----- (004179BC) -------------------------------------------------------- -void __fastcall sub_4179BC_draw_tooltip( const char *a1, const char *a2 ) - { - const char *v2; // ebx@1 - const char *v3; // edi@1 - unsigned int v4; // eax@1 - GUIWindow Dst; // [sp+Ch] [bp-5Ch]@1 - POINT v6; // [sp+60h] [bp-8h]@1 - - v2 = a2; - v3 = a1; - memset(&Dst, 0, 0x54u); - Dst.uFrameWidth = 384; - Dst.uFrameHeight = 256; - Dst.uFrameX = 128; - Dst.uFrameY = pMouse->GetCursorPos(&v6)->y + 30; - Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(v2, &Dst, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24; - Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; - Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1; - Dst.DrawMessageBox(0); - Dst.uFrameX += 12; - Dst.uFrameWidth -= 24; - Dst.uFrameY += 12; - Dst.uFrameHeight -= 12; - Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; - Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1; - v4 = TargetColor(0xFFu, 0xFFu, 0x9Bu); - sprintf(pTmpBuf.data(), format_4E2D80, v4, v3); - Dst.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3u); - Dst.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, v2, 0, 0, 0); -} - //----- (00417AD4) -------------------------------------------------------- unsigned int GetSkillColor(unsigned int uPlayerClass, PLAYER_SKILL_TYPE uPlayerSkillType, signed int skill_level) -{ - int v8; // eax@10 - int v12; // eax@14 - unsigned int yellow; // [sp+Ch] [bp-Ch]@1 - unsigned int red; // [sp+10h] [bp-8h]@1 - unsigned int white; // [sp+14h] [bp-4h]@1 - - white = TargetColor(0xFFu, 0xFFu, 0xFFu); - red = TargetColor(0xFFu, 0, 0); - yellow = TargetColor(0xFFu, 0xFFu, 0); - if ( !(uPlayerClass % 4) ) +{ + switch (uPlayerClass % 4) { - if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level ) - return white; - if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level - && byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level ) + case 0: { - v12 = byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 3][uPlayerSkillType]; - if ( v12 < skill_level ) - return red; + if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level) + return ui_character_skillinfo_can_learn; + if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level && + byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level) + { + if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 3][uPlayerSkillType] < skill_level) + return ui_character_skillinfo_cant_learn; + } + return ui_character_skillinfo_can_learn_gm; } - return yellow; - } - if ( (uPlayerClass % 4) == 1 ) - { - if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level ) - return white; - if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level ) + break; + + case 1: { - v8 = byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType]; - if ( v8 < skill_level) - return red; + if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level) + return ui_character_skillinfo_can_learn; + if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 1][uPlayerSkillType] < skill_level) + { + if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass + 2][uPlayerSkillType] < skill_level) + return ui_character_skillinfo_cant_learn; + } + return ui_character_skillinfo_can_learn_gm; } - return yellow; + break; + + case 2: + case 3: + { + if (byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] < skill_level) + return ui_character_skillinfo_cant_learn; + return ui_character_skillinfo_can_learn; + } + break; } - if ( (uPlayerClass % 4) == 2 || (uPlayerClass % 4) == 3 ) - { - if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] < skill_level ) - return red; - } - return white; + assert(false); + return 0; } \ No newline at end of file
--- a/mm7_6.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/mm7_6.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -127,7 +127,20 @@ { v11 = 0; v12 = *(float *)v4 == *((float *)v7 - 5); - goto LABEL_19; + if ( ! (v12 | v11) ) + { + v26 += 48; + ++v24; + v25 += 48; + v27 += 48; + v28 += 48; + v5 += 48; + v4 += 48; + ++v22; + v23 += 48; + v21 = v5; + v20 = v4; + } } } else @@ -136,13 +149,22 @@ { v11 = 0; v12 = *(float *)v4 == *((float *)v7 + 7); -LABEL_19: - if ( v12 | v11 ) - goto LABEL_21; - goto LABEL_20; + if ( !(v12 | v11) ) + { + v26 += 48; + ++v24; + v25 += 48; + v27 += 48; + v28 += 48; + v5 += 48; + v4 += 48; + ++v22; + v23 += 48; + v21 = v5; + v20 = v4; + } } } -LABEL_20: v26 += 48; ++v24; v25 += 48; @@ -155,7 +177,6 @@ v21 = v5; v20 = v4; } -LABEL_21: if ( v19 ) { v13 = v24; @@ -188,899 +209,8 @@ return result; } -//----- (004250FE) -------------------------------------------------------- -signed int __fastcall sr_4250FE(unsigned int uVertexID) -{ - unsigned int v1; // edx@1 - char *v2; // edi@5 - char *v3; // esi@5 - char *v4; // ecx@5 - int v5; // ebx@6 - double v6; // st6@11 - double v7; // st5@11 - double v8; // st6@12 - unsigned __int8 v9; // c2@16 - unsigned __int8 v10; // c3@16 - void *v11; // edi@23 - double v12; // st6@23 - char *v13; // ecx@23 - char v14; // zf@24 - signed int result; // eax@25 - unsigned int v16; // [sp+8h] [bp-28h]@5 - bool v17; // [sp+Ch] [bp-24h]@2 - bool v18; // [sp+10h] [bp-20h]@7 - char *v19; // [sp+14h] [bp-1Ch]@5 - char *v20; // [sp+18h] [bp-18h]@5 - signed int v21; // [sp+1Ch] [bp-14h]@1 - RenderVertexSoft *v22; // [sp+20h] [bp-10h]@5 - char *v23; // [sp+24h] [bp-Ch]@5 - char *v24; // [sp+28h] [bp-8h]@5 - char *v25; // [sp+2Ch] [bp-4h]@5 - - v1 = uVertexID; - memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID])); - v21 = 0; - v17 = array_50AC10[0].vWorldViewPosition.x >= 8.0; - if ( (signed int)(uVertexID + 1) <= 1 ) - return 0; - v2 = (char *)&array_507D30[0].vWorldViewPosition.z; - v3 = (char *)&array_507D30[0].vWorldViewPosition.y; - v24 = (char *)&array_507D30[0]._rhw; - v22 = array_507D30; - v19 = (char *)&array_507D30[0].vWorldViewPosition.z; - v20 = (char *)&array_507D30[0].vWorldViewPosition.y; - v23 = (char *)&array_507D30[0].vWorldViewPosition; - v25 = (char *)&array_507D30[0].flt_2C; - v4 = (char *)&array_50AC10[0].vWorldViewPosition; - v16 = v1; - do - { - v5 = (int)(v4 + 48); - v18 = *((float *)v4 + 12) >= 8.0; - if ( v17 != v18 ) - { - if ( v18 ) - { - v6 = (8.0 - *(float *)v4) / (*(float *)v5 - *(float *)v4); - *(float *)v3 = (*((float *)v4 + 13) - *((float *)v4 + 1)) * v6 + *((float *)v4 + 1); - *(float *)v2 = (*((float *)v4 + 14) - *((float *)v4 + 2)) * v6 + *((float *)v4 + 2); - v7 = (*((float *)v4 + 20) - *((float *)v4 + 8)) * v6 + *((float *)v4 + 8); - } - else - { - v8 = (8.0 - *(float *)v5) / (*(float *)v4 - *(float *)v5); - *(float *)v3 = (*((float *)v4 + 1) - *((float *)v4 + 13)) * v8 + *((float *)v4 + 13); - *(float *)v2 = (*((float *)v4 + 2) - *((float *)v4 + 14)) * v8 + *((float *)v4 + 14); - v7 = (*((float *)v4 + 8) - *((float *)v4 + 20)) * v8 + *((float *)v4 + 20); - } - *(float *)v25 = v7; - *(float *)v23 = 8.0; - *(int *)v24 = 0x3E000000u; - if ( v17 ) - { - if ( 8.0 == *(float *)v4 && *(float *)v3 == *((float *)v4 + 1) ) - { - v9 = 0; - v10 = *(float *)v2 == *((float *)v4 + 2); - goto LABEL_20; - } - } - else - { - if ( 8.0 == *(float *)v5 && *(float *)v3 == *((float *)v4 + 13) ) - { - v9 = 0; - v10 = *(float *)v2 == *((float *)v4 + 14); -LABEL_20: - if ( v10 | v9 ) - goto LABEL_22; - goto LABEL_21; - } - } -LABEL_21: - ++v22; - v23 += 48; - v25 += 48; - v3 += 48; - v2 += 48; - ++v21; - v24 += 48; - v20 = v3; - v19 = v2; - } -LABEL_22: - if ( v18 ) - { - v11 = v22; - v20 += 48; - v19 += 48; - v12 = 1.0 / (*(float *)v5 + 0.0000001); - ++v21; - v25 += 48; - v23 += 48; - ++v22; - memcpy(v11, v4 + 36, 0x30u); - v13 = v24; - v24 += 48; - v3 = v20; - v2 = v19; - *(float *)v13 = v12; - } - v14 = v16-- == 1; - v17 = v18; - v4 = (char *)v5; - } - while ( !v14 ); - result = v21; - if ( v21 < 3 ) - return 0; - return result; -} - -//----- (004252E8) -------------------------------------------------------- -signed int __fastcall sr_4252E8(unsigned int uVertexID) -{ - unsigned int v1; // edx@1 - double v2; // st7@1 - char *v3; // edi@5 - char *v4; // esi@5 - char *v5; // ecx@5 - int v6; // ebx@6 - double v7; // st6@11 - double v8; // st5@11 - double v9; // st6@12 - unsigned __int8 v10; // c2@16 - unsigned __int8 v11; // c3@16 - void *v12; // edi@23 - double v13; // st6@23 - char *v14; // ecx@23 - char v15; // zf@24 - signed int result; // eax@25 - unsigned int v17; // [sp+8h] [bp-28h]@5 - bool v18; // [sp+Ch] [bp-24h]@2 - bool v19; // [sp+10h] [bp-20h]@7 - char *v20; // [sp+14h] [bp-1Ch]@5 - char *v21; // [sp+18h] [bp-18h]@5 - signed int v22; // [sp+1Ch] [bp-14h]@1 - RenderVertexSoft *v23; // [sp+20h] [bp-10h]@5 - char *v24; // [sp+24h] [bp-Ch]@5 - char *v25; // [sp+28h] [bp-8h]@5 - char *v26; // [sp+2Ch] [bp-4h]@5 - - v1 = uVertexID; - v2 = (double)pOutdoorCamera->shading_dist_mist; - memcpy(&array_50AC10[uVertexID], array_50AC10, sizeof(array_50AC10[uVertexID])); - v22 = 0; - v18 = array_50AC10[0].vWorldViewPosition.x <= v2; - if ( (signed int)(uVertexID + 1) <= 1 ) - return 0; - v3 = (char *)&array_507D30[0].vWorldViewPosition.z; - v4 = (char *)&array_507D30[0].vWorldViewPosition.y; - v25 = (char *)&array_507D30[0]._rhw; - v23 = array_507D30; - v20 = (char *)&array_507D30[0].vWorldViewPosition.z; - v21 = (char *)&array_507D30[0].vWorldViewPosition.y; - v24 = (char *)&array_507D30[0].vWorldViewPosition; - v26 = (char *)&array_507D30[0].flt_2C; - v5 = (char *)&array_50AC10[0].vWorldViewPosition; - v17 = v1; - do - { - v6 = (int)(v5 + 48); - v19 = v2 >= *((float *)v5 + 12); - if ( v18 != v19 ) - { - if ( v19 ) - { - v7 = (v2 - *(float *)v5) / (*(float *)v6 - *(float *)v5); - *(float *)v4 = (*((float *)v5 + 13) - *((float *)v5 + 1)) * v7 + *((float *)v5 + 1); - *(float *)v3 = (*((float *)v5 + 14) - *((float *)v5 + 2)) * v7 + *((float *)v5 + 2); - v8 = (*((float *)v5 + 20) - *((float *)v5 + 8)) * v7 + *((float *)v5 + 8); - } - else - { - v9 = (v2 - *(float *)v6) / (*(float *)v5 - *(float *)v6); - *(float *)v4 = (*((float *)v5 + 1) - *((float *)v5 + 13)) * v9 + *((float *)v5 + 13); - *(float *)v3 = (*((float *)v5 + 2) - *((float *)v5 + 14)) * v9 + *((float *)v5 + 14); - v8 = (*((float *)v5 + 8) - *((float *)v5 + 20)) * v9 + *((float *)v5 + 20); - } - *(float *)v26 = v8; - *(float *)v24 = v2; - *(float *)v25 = 1.0 / v2; - if ( v18 ) - { - if ( v2 == *(float *)v5 && *(float *)v4 == *((float *)v5 + 1) ) - { - v10 = 0; - v11 = *(float *)v3 == *((float *)v5 + 2); - goto LABEL_20; - } - } - else - { - if ( v2 == *(float *)v6 && *(float *)v4 == *((float *)v5 + 13) ) - { - v10 = 0; - v11 = *(float *)v3 == *((float *)v5 + 14); -LABEL_20: - if ( v11 | v10 ) - goto LABEL_22; - goto LABEL_21; - } - } -LABEL_21: - ++v23; - v24 += 48; - v26 += 48; - v4 += 48; - v3 += 48; - ++v22; - v25 += 48; - v21 = v4; - v20 = v3; - } -LABEL_22: - if ( v19 ) - { - v12 = v23; - v21 += 48; - v20 += 48; - v13 = 1.0 / (*(float *)v6 + 0.0000001); - ++v22; - v26 += 48; - v24 += 48; - ++v23; - memcpy(v12, v5 + 36, 0x30u); - v14 = v25; - v25 += 48; - v4 = v21; - v3 = v20; - *(float *)v14 = v13; - } - v15 = v17-- == 1; - v18 = v19; - v5 = (char *)v6; - } - while ( !v15 ); - result = v22; - if ( v22 < 3 ) - return 0; - return result; -} - -//----- (004254D2) -------------------------------------------------------- -int __fastcall sr_4254D2(signed int a1) -{ - signed int v1; // ebx@2 - int v2; // ecx@2 - int result; // eax@11 - double v4; // ST74_8@12 - bool v5; // edi@12 - char *v6; // esi@13 - char *v7; // ebx@13 - double v8; // st7@15 - double v9; // st7@16 - double v10; // st6@16 - double v11; // st7@17 - float v12; // eax@18 - double v13; // ST4C_8@19 - double v14; // ST10_8@19 - double v15; // ST28_8@20 - double v16; // ST34_8@20 - char v17; // zf@20 - double v18; // ST18_8@21 - double v19; // ST3C_8@21 - double v20; // ST44_8@22 - double v21; // ST54_8@22 - void *v22; // edi@26 - double v23; // ST54_8@29 - bool v24; // esi@29 - char *v25; // edi@30 - char *v26; // ebx@30 - bool v27; // ecx@32 - double v28; // st7@33 - double v29; // st7@34 - double v30; // st6@34 - double v31; // st7@35 - double v32; // ST44_8@37 - double v33; // ST3C_8@37 - double v34; // ST18_8@38 - double v35; // ST34_8@38 - char v36; // zf@38 - double v37; // ST28_8@39 - double v38; // ST10_8@39 - double v39; // ST20_8@40 - double v40; // ST5C_8@40 - void *v41; // edi@44 - double v42; // ST5C_8@47 - bool v43; // edi@47 - char *v44; // esi@48 - char *v45; // ebx@48 - bool v46; // ecx@49 - double v47; // st6@50 - double v48; // st6@51 - double v49; // st5@51 - double v50; // st6@52 - double v51; // ST20_8@54 - double v52; // ST54_8@54 - double v53; // ST44_8@55 - double v54; // ST3C_8@55 - char v55; // zf@55 - double v56; // ST18_8@56 - double v57; // ST34_8@56 - double v58; // ST28_8@57 - double v59; // ST10_8@57 - void *v60; // edi@61 - double v61; // ST5C_8@64 - bool v62; // edi@64 - char *v63; // esi@65 - char *v64; // ebx@65 - bool v65; // ecx@66 - double v66; // st6@67 - double v67; // st6@68 - double v68; // st5@68 - double v69; // st6@69 - double v70; // ST20_8@71 - double v71; // ST54_8@71 - double v72; // ST44_8@72 - double v73; // ST3C_8@72 - char v74; // zf@72 - double v75; // ST18_8@73 - double v76; // ST34_8@73 - double v77; // ST28_8@74 - double v78; // ST10_8@74 - void *v79; // edi@78 - int v80; // ebx@81 - char *v81; // ecx@82 - signed int v82; // esi@82 - float v83; // ST78_4@83 - double v84; // ST5C_8@83 - float v85; // eax@84 - double v86; // ST20_8@85 - double v87; // ST54_8@88 - float v88; // eax@89 - double v89; // ST44_8@90 - unsigned __int8 v90; // sf@94 - unsigned __int8 v91; // of@94 - int v92; // edx@97 - int v93; // esi@97 - int v94; // edi@97 - int v95; // eax@97 - int v96; // eax@104 - double v97; // [sp+4Ch] [bp-8Ch]@32 - double v98; // [sp+54h] [bp-84h]@49 - double v99; // [sp+54h] [bp-84h]@66 - float v100; // [sp+5Ch] [bp-7Ch]@1 - float v101; // [sp+60h] [bp-78h]@1 - float v102; // [sp+64h] [bp-74h]@1 - double v103; // [sp+6Ch] [bp-6Ch]@14 - float v104; // [sp+A8h] [bp-30h]@1 - signed int v105; // [sp+A8h] [bp-30h]@96 - bool v106; // [sp+ACh] [bp-2Ch]@14 - bool v107; // [sp+ACh] [bp-2Ch]@32 - bool v108; // [sp+ACh] [bp-2Ch]@49 - bool v109; // [sp+ACh] [bp-2Ch]@66 - signed int v110; // [sp+B0h] [bp-28h]@12 - char *v111; // [sp+B8h] [bp-20h]@30 - signed int v112; // [sp+B8h] [bp-20h]@48 - signed int v113; // [sp+B8h] [bp-20h]@65 - char *v114; // [sp+BCh] [bp-1Ch]@13 - signed int v115; // [sp+BCh] [bp-1Ch]@29 - signed int v116; // [sp+BCh] [bp-1Ch]@64 - signed int v117; // [sp+C0h] [bp-18h]@1 - char *v118; // [sp+C0h] [bp-18h]@30 - char *v119; // [sp+C0h] [bp-18h]@48 - char *v120; // [sp+C0h] [bp-18h]@65 - char *v121; // [sp+C4h] [bp-14h]@13 - char *v122; // [sp+C4h] [bp-14h]@30 - signed int v123; // [sp+C4h] [bp-14h]@47 - char *v124; // [sp+C8h] [bp-10h]@30 - char *v125; // [sp+C8h] [bp-10h]@48 - char *v126; // [sp+C8h] [bp-10h]@65 - signed int v127; // [sp+CCh] [bp-Ch]@2 - char *v128; // [sp+CCh] [bp-Ch]@13 - char *v129; // [sp+CCh] [bp-Ch]@30 - RenderVertexSoft *v130; // [sp+CCh] [bp-Ch]@48 - RenderVertexSoft *v131; // [sp+CCh] [bp-Ch]@65 - RenderVertexSoft *v132; // [sp+D0h] [bp-8h]@13 - char *v133; // [sp+D0h] [bp-8h]@30 - char *v134; // [sp+D0h] [bp-8h]@48 - char *v135; // [sp+D0h] [bp-8h]@65 - signed int v136; // [sp+D4h] [bp-4h]@1 - char *v137; // [sp+D4h] [bp-4h]@13 - RenderVertexSoft *v138; // [sp+D4h] [bp-4h]@30 - char *v139; // [sp+D4h] [bp-4h]@48 - char *v140; // [sp+D4h] [bp-4h]@65 - - v101 = (double)(signed int)pViewport->uViewportTL_X; - v100 = (double)(signed int)pViewport->uViewportBR_X; - v117 = a1; - v136 = 1; - v104 = (double)(signed int)pViewport->uViewportTL_Y; - v102 = (double)(pViewport->uViewportBR_Y + 1); - if ( a1 <= 0 ) - return v117; - v127 = a1; - v1 = a1; - memcpy(array_508690, array_50AC10, 4 * ((unsigned int)(48 * a1) >> 2)); - v2 = 0; - do - { - if ( array_50AC10[v2].vWorldViewProjX < (double)v101 || array_50AC10[v2].vWorldViewProjX > (double)v100 ) - v136 = 0; - if ( *(float *)(v2 * 48 + 5286956) < (double)v104 || *(float *)(v2 * 48 + 5286956) > (double)v102 ) - v136 = 0; - ++v2; - --v127; - } - while ( v127 ); - if ( v136 ) - return v117; - v110 = 0; - memcpy(&array_50AC10[v1], array_50AC10, sizeof(array_50AC10[v1])); - v4 = array_50AC10[0].vWorldViewProjX + 6.7553994e15; - v5 = SLODWORD(v4) >= (signed int)pViewport->uViewportTL_X; - if ( v117 < 1 ) - goto LABEL_112; - v6 = (char *)&array_50A2B0[0].vWorldViewProjY; - v132 = array_50A2B0; - v137 = (char *)&array_50A2B0[0].vWorldViewProjX; - v128 = (char *)&array_50A2B0[0].vWorldViewProjY; - v121 = (char *)&array_50A2B0[0].flt_2C; - v114 = (char *)&array_50A2B0[0]._rhw; - v7 = (char *)&array_50AC10[0].flt_2C; - do - { - v103 = *((float *)v7 + 7) + 6.7553994e15; - v106 = SLODWORD(v103) >= (signed int)pViewport->uViewportTL_X; - if ( !(v5 ^ v106) ) - goto LABEL_25; - v8 = v101; - if ( SLODWORD(v103) >= (signed int)pViewport->uViewportTL_X ) - { - v9 = (v8 - *((float *)v7 - 5)) / (*((float *)v7 + 7) - *((float *)v7 - 5)); - *(float *)v6 = (*((float *)v7 + 8) - *((float *)v7 - 4)) * v9 + *((float *)v7 - 4); - *(float *)v114 = (*((float *)v7 + 9) - *((float *)v7 - 3)) * v9 + *((float *)v7 - 3); - v10 = (*((float *)v7 + 12) - *(float *)v7) * v9 + *(float *)v7; - } - else - { - v11 = (v8 - *((float *)v7 + 7)) / (*((float *)v7 - 5) - *((float *)v7 + 7)); - *(float *)v6 = (*((float *)v7 - 4) - *((float *)v7 + 8)) * v11 + *((float *)v7 + 8); - *(float *)v114 = (*((float *)v7 - 3) - *((float *)v7 + 9)) * v11 + *((float *)v7 + 9); - v10 = (*(float *)v7 - *((float *)v7 + 12)) * v11 + *((float *)v7 + 12); - } - *(float *)v121 = v10; - *(int *)v137 = LODWORD(v101); - LODWORD(v12) = *(int *)v6; - if ( v5 ) - { - v13 = v12 + 6.7553994e15; - v14 = *((float *)v7 - 4) + 6.7553994e15; - if ( LODWORD(v13) == LODWORD(v14) ) - { - v15 = *(float *)v137 + 6.7553994e15; - v16 = *((float *)v7 - 5) + 6.7553994e15; - v17 = LODWORD(v15) == LODWORD(v16); - goto LABEL_23; - } - } - else - { - v18 = v12 + 6.7553994e15; - v19 = *((float *)v7 + 8) + 6.7553994e15; - if ( LODWORD(v18) == LODWORD(v19) ) - { - v20 = *(float *)v137 + 6.7553994e15; - v21 = *((float *)v7 + 7) + 6.7553994e15; - v17 = LODWORD(v20) == LODWORD(v21); -LABEL_23: - if ( v17 ) - goto LABEL_25; - goto LABEL_24; - } - } -LABEL_24: - v121 += 48; - v114 += 48; - v6 += 48; - ++v110; - ++v132; - v128 = v6; - v137 += 48; -LABEL_25: - if ( v106 ) - { - v22 = v132; - v128 += 48; - ++v110; - v114 += 48; - v121 += 48; - v137 += 48; - ++v132; - memcpy(v22, v7 + 4, 0x30u); - v6 = v128; - } - v5 = v106; - v7 += 48; - --v117; - } - while ( v117 ); - if ( v110 < 3 - || (v115 = 0, - memcpy(&array_50A2B0[v110], array_50A2B0, sizeof(array_50A2B0[v110])), - v23 = array_50A2B0[0].vWorldViewProjX + 6.7553994e15, - v24 = SLODWORD(v23) <= (signed int)pViewport->uViewportBR_X, - v110 < 1) ) - goto LABEL_112; - v25 = (char *)&array_509950[0]._rhw; - v138 = array_509950; - v129 = (char *)&array_50A2B0[0].vWorldViewProjX; - v118 = (char *)&array_50A2B0[0].vWorldViewProjY; - v133 = (char *)&array_509950[0].vWorldViewProjX; - v122 = (char *)&array_509950[0].vWorldViewProjY; - v124 = (char *)&array_509950[0].flt_2C; - v111 = (char *)&array_509950[0]._rhw; - v26 = (char *)&array_50A2B0[0].flt_2C; - while ( 2 ) - { - v97 = *((float *)v26 + 7) + 6.7553994e15; - v27 = SLODWORD(v97) <= (signed int)pViewport->uViewportBR_X; - v107 = SLODWORD(v97) <= (signed int)pViewport->uViewportBR_X; - if ( v24 != v27 ) - { - v28 = v100; - if ( SLODWORD(v97) <= (signed int)pViewport->uViewportBR_X ) - { - v29 = (v28 - *((float *)v26 - 5)) / (*((float *)v26 + 7) - *((float *)v26 - 5)); - *(float *)v122 = (*((float *)v26 + 8) - *((float *)v26 - 4)) * v29 + *((float *)v26 - 4); - *(float *)v25 = (*((float *)v26 + 9) - *((float *)v26 - 3)) * v29 + *((float *)v26 - 3); - v30 = (*((float *)v26 + 12) - *(float *)v26) * v29 + *(float *)v26; - } - else - { - v31 = (v28 - *((float *)v26 + 7)) / (*((float *)v26 - 5) - *((float *)v26 + 7)); - *(float *)v122 = (*((float *)v26 - 4) - *((float *)v26 + 8)) * v31 + *((float *)v26 + 8); - *(float *)v25 = (*((float *)v26 - 3) - *((float *)v26 + 9)) * v31 + *((float *)v26 + 9); - v30 = (*(float *)v26 - *((float *)v26 + 12)) * v31 + *((float *)v26 + 12); - } - *(float *)v124 = v30; - *(int *)v133 = LODWORD(v100); - if ( v24 ) - { - v32 = *(float *)v122 + 6.7553994e15; - v33 = *((float *)v26 - 4) + 6.7553994e15; - if ( LODWORD(v32) == LODWORD(v33) ) - { - v34 = *(float *)v133 + 6.7553994e15; - v35 = *((float *)v26 - 5) + 6.7553994e15; - v36 = LODWORD(v34) == LODWORD(v35); - goto LABEL_41; - } - goto LABEL_42; - } - v37 = *(float *)v118 + 6.7553994e15; - v38 = *((float *)v26 + 8) + 6.7553994e15; - if ( LODWORD(v37) != LODWORD(v38) ) - goto LABEL_42; - v39 = *(float *)v129 + 6.7553994e15; - v40 = *((float *)v26 + 7) + 6.7553994e15; - v36 = LODWORD(v39) == LODWORD(v40); -LABEL_41: - if ( !v36 ) - { -LABEL_42: - v129 += 48; - v118 += 48; - v133 += 48; - v122 += 48; - v124 += 48; - v111 += 48; - ++v115; - ++v138; - } - } - if ( v27 ) - { - v41 = v138; - ++v115; - v111 += 48; - v124 += 48; - v122 += 48; - v133 += 48; - v118 += 48; - v129 += 48; - ++v138; - memcpy(v41, v26 + 4, 0x30u); - } - v24 = v107; - v26 += 48; - --v110; - if ( v110 ) - { - v25 = v111; - continue; - } - break; - } - if ( v115 < 3 - || (v123 = 0, - memcpy(&array_509950[v115], array_509950, sizeof(array_509950[v115])), - v42 = array_509950[0].vWorldViewProjY + 6.7553994e15, - v43 = SLODWORD(v42) >= (signed int)pViewport->uViewportTL_Y, - v115 < 1) ) - goto LABEL_112; - v44 = (char *)&array_508FF0[0].vWorldViewProjX; - v130 = array_508FF0; - v119 = (char *)&array_508FF0[0].vWorldViewProjX; - v139 = (char *)&array_508FF0[0].vWorldViewProjY; - v125 = (char *)&array_508FF0[0].flt_2C; - v134 = (char *)&array_508FF0[0]._rhw; - v45 = (char *)&array_509950[0].flt_2C; - v112 = v115; - while ( 2 ) - { - v98 = *((float *)v45 + 8) + 6.7553994e15; - v46 = SLODWORD(v98) >= (signed int)pViewport->uViewportTL_Y; - v108 = SLODWORD(v98) >= (signed int)pViewport->uViewportTL_Y; - if ( v43 != v46 ) - { - v47 = v104; - if ( SLODWORD(v98) >= (signed int)pViewport->uViewportTL_Y ) - { - v48 = (v47 - *((float *)v45 - 4)) / (*((float *)v45 + 8) - *((float *)v45 - 4)); - *(float *)v44 = (*((float *)v45 + 7) - *((float *)v45 - 5)) * v48 + *((float *)v45 - 5); - *(float *)v134 = (*((float *)v45 + 9) - *((float *)v45 - 3)) * v48 + *((float *)v45 - 3); - v49 = (*((float *)v45 + 12) - *(float *)v45) * v48 + *(float *)v45; - } - else - { - v50 = (v47 - *((float *)v45 + 8)) / (*((float *)v45 - 4) - *((float *)v45 + 8)); - *(float *)v44 = (*((float *)v45 - 5) - *((float *)v45 + 7)) * v50 + *((float *)v45 + 7); - *(float *)v134 = (*((float *)v45 - 3) - *((float *)v45 + 9)) * v50 + *((float *)v45 + 9); - v49 = (*(float *)v45 - *((float *)v45 + 12)) * v50 + *((float *)v45 + 12); - } - *(float *)v125 = v49; - *(float *)v139 = v104; - if ( v43 ) - { - v51 = v104 + 6.7553994e15; - v52 = *((float *)v45 - 4) + 6.7553994e15; - if ( LODWORD(v51) == LODWORD(v52) ) - { - v53 = *(float *)v44 + 6.7553994e15; - v54 = *((float *)v45 - 5) + 6.7553994e15; - v55 = LODWORD(v53) == LODWORD(v54); - goto LABEL_58; - } - goto LABEL_59; - } - v56 = v104 + 6.7553994e15; - v57 = *((float *)v45 + 8) + 6.7553994e15; - if ( LODWORD(v56) != LODWORD(v57) ) - goto LABEL_59; - v58 = *(float *)v44 + 6.7553994e15; - v59 = *((float *)v45 + 7) + 6.7553994e15; - v55 = LODWORD(v58) == LODWORD(v59); -LABEL_58: - if ( !v55 ) - { -LABEL_59: - v139 += 48; - v125 += 48; - v134 += 48; - v44 += 48; - ++v123; - ++v130; - v119 = v44; - } - } - if ( v46 ) - { - v60 = v130; - v119 += 48; - ++v123; - v134 += 48; - v125 += 48; - v139 += 48; - ++v130; - memcpy(v60, v45 + 4, 0x30u); - v44 = v119; - } - v43 = v108; - v45 += 48; - --v112; - if ( v112 ) - continue; - break; - } - if ( v123 < 3 - || (v116 = 0, - memcpy(&array_508FF0[v123], array_508FF0, sizeof(array_508FF0[v123])), - v61 = array_508FF0[0].vWorldViewProjY + 6.7553994e15, - v62 = SLODWORD(v61) <= (signed int)pViewport->uViewportBR_Y, - v123 < 1) ) - goto LABEL_112; - v63 = (char *)&array_508690[0].vWorldViewProjX; - v131 = array_508690; - v120 = (char *)&array_508690[0].vWorldViewProjX; - v140 = (char *)&array_508690[0].vWorldViewProjY; - v126 = (char *)&array_508690[0].flt_2C; - v135 = (char *)&array_508690[0]._rhw; - v64 = (char *)&array_508FF0[0].flt_2C; - v113 = v123; - while ( 2 ) - { - v99 = *((float *)v64 + 8) + 6.7553994e15; - v65 = SLODWORD(v99) <= (signed int)pViewport->uViewportBR_Y; - v109 = SLODWORD(v99) <= (signed int)pViewport->uViewportBR_Y; - if ( v62 != v65 ) - { - v66 = v102; - if ( SLODWORD(v99) <= (signed int)pViewport->uViewportBR_Y ) - { - v67 = (v66 - *((float *)v64 - 4)) / (*((float *)v64 + 8) - *((float *)v64 - 4)); - *(float *)v63 = (*((float *)v64 + 7) - *((float *)v64 - 5)) * v67 + *((float *)v64 - 5); - *(float *)v135 = (*((float *)v64 + 9) - *((float *)v64 - 3)) * v67 + *((float *)v64 - 3); - v68 = (*((float *)v64 + 12) - *(float *)v64) * v67 + *(float *)v64; - } - else - { - v69 = (v66 - *((float *)v64 + 8)) / (*((float *)v64 - 4) - *((float *)v64 + 8)); - *(float *)v63 = (*((float *)v64 - 5) - *((float *)v64 + 7)) * v69 + *((float *)v64 + 7); - *(float *)v135 = (*((float *)v64 - 3) - *((float *)v64 + 9)) * v69 + *((float *)v64 + 9); - v68 = (*(float *)v64 - *((float *)v64 + 12)) * v69 + *((float *)v64 + 12); - } - *(float *)v126 = v68; - *(float *)v140 = v102; - if ( v62 ) - { - v70 = v102 + 6.7553994e15; - v71 = *((float *)v64 - 4) + 6.7553994e15; - if ( LODWORD(v70) == LODWORD(v71) ) - { - v72 = *(float *)v63 + 6.7553994e15; - v73 = *((float *)v64 - 5) + 6.7553994e15; - v74 = LODWORD(v72) == LODWORD(v73); - goto LABEL_75; - } - goto LABEL_76; - } - v75 = v102 + 6.7553994e15; - v76 = *((float *)v64 + 8) + 6.7553994e15; - if ( LODWORD(v75) != LODWORD(v76) ) - goto LABEL_76; - v77 = *(float *)v63 + 6.7553994e15; - v78 = *((float *)v64 + 7) + 6.7553994e15; - v74 = LODWORD(v77) == LODWORD(v78); -LABEL_75: - if ( !v74 ) - { -LABEL_76: - v140 += 48; - v126 += 48; - v135 += 48; - v63 += 48; - ++v116; - ++v131; - v120 = v63; - } - } - if ( v65 ) - { - v79 = v131; - v120 += 48; - ++v116; - v135 += 48; - v126 += 48; - v140 += 48; - ++v131; - memcpy(v79, v64 + 4, 0x30u); - v63 = v120; - } - v62 = v109; - v64 += 48; - --v113; - if ( v113 ) - continue; - break; - } - if ( v116 < 3 ) - goto LABEL_112; - v80 = v116; - memcpy(&array_508690[v116], array_508690, sizeof(array_508690[v116])); - if ( v116 > 0 ) - { - v81 = (char *)&array_508690[0].vWorldViewProjX; - v82 = v116; - do - { - LODWORD(v83) = *(int *)v81; - *((float *)v81 - 3) = 1.0 / *((float *)v81 + 2); - v84 = v83 + 6.7553994e15; - if ( SLODWORD(v84) <= (signed int)pViewport->uViewportBR_X ) - { - v86 = *(float *)v81 + 6.7553994e15; - if ( SLODWORD(v86) >= (signed int)pViewport->uViewportTL_X ) - goto LABEL_88; - v85 = v101; - } - else - { - v85 = v100; - } - *(int *)v81 = LODWORD(v85); -LABEL_88: - v87 = *((float *)v81 + 1) + 6.7553994e15; - if ( SLODWORD(v87) > (signed int)pViewport->uViewportBR_Y ) - { - v88 = v102; -LABEL_92: - *((int *)v81 + 1) = LODWORD(v88); - goto LABEL_93; - } - v89 = *((float *)v81 + 1) + 6.7553994e15; - if ( SLODWORD(v89) < (signed int)pViewport->uViewportTL_Y ) - { - v88 = v104; - goto LABEL_92; - } -LABEL_93: - v81 += 48; - --v82; - } - while ( v82 ); - } - v91 = __OFSUB__(v116, 3); - v90 = v116 - 3 < 0; - if ( v116 > 3 ) - { - memcpy(&array_508690[v116 + 1], &array_508690[1], sizeof(array_508690[v116 + 1])); - if ( v116 > 0 ) - { - v105 = 1; - do - { - v92 = v105; - v93 = v105 - 1; - v94 = v105 + 1; - v95 = v105 + 1; - if ( v105 - 1 >= v80 ) - v93 -= v80; - if ( v105 >= v80 ) - v92 = v105 - v80; - if ( v94 >= v80 ) - v95 = v94 - v80; - if ( (array_508690[v92].vWorldViewProjX - array_508690[v93].vWorldViewProjX) - * (array_508690[v95].vWorldViewProjY - array_508690[v93].vWorldViewProjY) - - (array_508690[v95].vWorldViewProjX - array_508690[v93].vWorldViewProjX) - * (array_508690[v92].vWorldViewProjY - array_508690[v93].vWorldViewProjY) < 0.0 ) - { - ++v105; - } - else - { - v96 = v105; - if ( v105 < v80 || (v96 = v105 - v80, v105 - v80 < v80) ) - memcpy(&array_508690[v96], &array_508690[v96 + 1], 4 * ((unsigned int)(48 * v80 - 48 * v96) >> 2)); - --v80; - } - } - while ( v105 - 1 < v80 ); - } - v91 = __OFSUB__(v80, 3); - v90 = v80 - 3 < 0; - } - if ( v90 ^ v91 ) -LABEL_112: - result = 0; - else - result = v80; - return result; -} - //----- (0042620A) -------------------------------------------------------- -bool __thiscall sr_42620A(RenderVertexSoft *p) +bool sr_42620A(RenderVertexSoft *p) { __int16 v1; // fps@1 unsigned __int8 v2; // c0@2 @@ -1219,28 +349,34 @@ v14 = 0; if ( v3 ) { - if ( !pActor->pMonsterInfo.uTreasureDiceRolls ) - goto LABEL_9; - do - { - ++v2; - v14 += rand() % pActor->pMonsterInfo.uTreasureDiceSides + 1; - } - while ( v2 < pActor->pMonsterInfo.uTreasureDiceRolls ); + if ( pActor->pMonsterInfo.uTreasureDiceRolls ) + { + do + { + ++v2; + v14 += rand() % pActor->pMonsterInfo.uTreasureDiceSides + 1; + } + while ( v2 < pActor->pMonsterInfo.uTreasureDiceRolls ); + if ( v14 ) + { + party_finds_gold(v14, 0); + viewparams->bRedrawGameUI = 1; + } + } } else { - if ( pItemsTable->pItems[pActor->array_000234[3].uItemID].uEquipType != 18 ) - goto LABEL_9; - v14 = pActor->array_000234[3].uSpecEnchantmentType; - pActor->array_000234[3].Reset(); + if ( pItemsTable->pItems[pActor->array_000234[3].uItemID].uEquipType == 18 ) + { + v14 = pActor->array_000234[3].uSpecEnchantmentType; + pActor->array_000234[3].Reset(); + if ( v14 ) + { + party_finds_gold(v14, 0); + viewparams->bRedrawGameUI = 1; + } + } } - if ( v14 ) - { - party_finds_gold(v14, 0); - viewparams->bRedrawGameUI = 1; - } -LABEL_9: if ( pActor->uCarriedItemID ) { Dst.Reset(); @@ -1285,7 +421,6 @@ } pActor->array_000234[1].Reset(); } -LABEL_55: pActor->Remove(); return; } @@ -1346,7 +481,9 @@ pActor->array_000234[1].Reset(); } if ( !v13 || rand() % 100 < 90 ) - goto LABEL_55; + { + pActor->Remove(); + } } //----- (00426E10) -------------------------------------------------------- @@ -1515,7 +652,7 @@ } while ( v17 ^ v18 ); if ( v2 ) - goto LABEL_61; + return v23[rand() % v2]; } v19 = 0; do @@ -1527,7 +664,6 @@ } while ( v19 < 4 ); if ( v2 ) -LABEL_61: result = v23[rand() % v2]; else result = 0; @@ -1751,6 +887,8 @@ { v14 = a4 + v9; v15 = ((v7 + 15) >> 1) + v7 + 15; + v13 = __OFSUB__(v14, v15); + v12 = v14 - v15 < 0; } else { @@ -1760,14 +898,15 @@ v11 = v7 + 15; v13 = __OFSUB__(v10, v11); v12 = v10 - v11 < 0; - goto LABEL_16; } - v14 = a4 + v9; - v15 = 2 * v7 + 30; + else + { + v14 = a4 + v9; + v15 = 2 * v7 + 30; + v13 = __OFSUB__(v14, v15); + v12 = v14 - v15 < 0; + } } - v13 = __OFSUB__(v14, v15); - v12 = v14 - v15 < 0; -LABEL_16: if ( v12 ^ v13 ) result = 0; else @@ -1872,25 +1011,29 @@ break; case 0: v6 = pActor->pMonsterInfo.uResFire; - goto LABEL_12; + v4 = v5; + break; case 1: v6 = pActor->pMonsterInfo.uResAir; - goto LABEL_12; + v4 = v5; + break; case 2: v6 = pActor->pMonsterInfo.uResWater; - goto LABEL_12; + v4 = v5; + break; case 3: v6 = pActor->pMonsterInfo.uResEarth; - goto LABEL_12; + v4 = v5; + break; case 6: v6 = pActor->pMonsterInfo.uResSpirit; break; case 7: v6 = pActor->pMonsterInfo.uResMind; - goto LABEL_12; + v4 = v5; + break; case 8: v6 = pActor->pMonsterInfo.uResBody; -LABEL_12: v4 = v5; break; case 9: @@ -1941,52 +1084,41 @@ case 0u: v3 = pActor; v4 = pActor->pMonsterInfo.uResFire; - goto LABEL_12; case 1u: v3 = pActor; v4 = pActor->pMonsterInfo.uResAir; - goto LABEL_12; case 2u: v3 = pActor; v4 = pActor->pMonsterInfo.uResWater; - goto LABEL_12; case 3u: v3 = pActor; v4 = pActor->pMonsterInfo.uResEarth; - goto LABEL_12; case 7u: v3 = pActor; v4 = pActor->pMonsterInfo.uResMind; - goto LABEL_12; case 6u: v3 = pActor; v4 = pActor->pMonsterInfo.uResSpirit; - goto LABEL_12; case 8u: v3 = pActor; v4 = pActor->pMonsterInfo.uResBody; - goto LABEL_12; case 9u: v3 = pActor; v4 = pActor->pMonsterInfo.uResLight; - goto LABEL_12; case 0xAu: v3 = pActor; v4 = pActor->pMonsterInfo.uResDark; - goto LABEL_12; case 4u: v3 = pActor; v4 = pActor->pMonsterInfo.uResPhysical; -LABEL_12: - if ( v4 < 200 ) - result = rand() % (signed int)(((unsigned int)v3->pMonsterInfo.uLevel >> 2) + v4 + 30) < 30; - else - result = 0; break; default: - result = 1; - break; + return 1; } + if ( v4 < 200 ) + result = rand() % (signed int)(((unsigned int)v3->pMonsterInfo.uLevel >> 2) + v4 + 30) < 30; + else + result = 0; return result; } @@ -2073,7 +1205,7 @@ //v31 = player->pEquipment.uBow; int bow_idx = player->pEquipment.uBow; - if (bow_idx && player->pInventoryItems[bow_idx - 1].Broken()) + if (bow_idx && player->pInventoryItemList[bow_idx - 1].Broken()) bow_idx = 0; //v32 = 0; @@ -2085,7 +1217,7 @@ int main_hand_idx = player->pEquipment.uMainHand; if (main_hand_idx) { - auto item = &player->pInventoryItems[main_hand_idx - 1]; + auto item = &player->pInventoryItemList[main_hand_idx - 1]; //v5 = (char *)v1 + 36 * v4; if (!item->Broken()) { @@ -2144,9 +1276,9 @@ shooting_wand = true; int main_hand_idx = player->pEquipment.uMainHand; - _42777D_CastSpell_UseWand_ShootArrow(wand_spell_ids[player->pInventoryItems[main_hand_idx - 1].uItemID - ITEM_WAND_FIRE], uActiveCharacter - 1, 8, 0, uActiveCharacter + 8); + _42777D_CastSpell_UseWand_ShootArrow(wand_spell_ids[player->pInventoryItemList[main_hand_idx - 1].uItemID - ITEM_WAND_FIRE], uActiveCharacter - 1, 8, 0, uActiveCharacter + 8); - if (!--player->pInventoryItems[main_hand_idx - 1].uNumCharges) + if (!--player->pInventoryItemList[main_hand_idx - 1].uNumCharges) player->pEquipment.uMainHand = 0; } else if (target_type == OBJECT_Actor && actor_distance <= 407.2) @@ -2201,7 +1333,7 @@ { int main_hand_idx = player->pEquipment.uMainHand; if (player->HasItemEquipped(EQUIP_MAIN_HAND)) - v34 = pItemsTable->pItems[*(int *)&player->pInventoryItems[main_hand_idx - 1]].uSkillType; + v34 = pItemsTable->pItems[*(int *)&player->pInventoryItemList[main_hand_idx - 1]].uSkillType; pTurnEngine->ApplyPlayerAction(); } @@ -2440,7 +1572,6 @@ v13 = 0; if ( (signed int)uNumActors <= 0 ) { -LABEL_20: result = 0; } else @@ -2488,7 +1619,7 @@ ++v13; ++v1; if ( v13 >= (signed int)uNumActors ) - goto LABEL_20; + return 0; } result = 1; } @@ -2498,118 +1629,74 @@ //----- (0042F7EB) -------------------------------------------------------- bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9) { - unsigned int v9; // edi@1 - signed int v10; // edx@3 - char *v11; // ecx@4 - unsigned __int16 v12; // ax@7 - unsigned int v13; // edx@9 - char *v14; // ecx@10 - int v15; // esi@17 - int v16; // eax@18 - int v17; // edi@20 - int v18; // esi@20 - //SpriteObject a1a; // [sp+Ch] [bp-78h]@1 - int v21; // [sp+7Ch] [bp-8h]@1 - unsigned int v22; // [sp+80h] [bp-4h]@1 - - v9 = uSpriteID; - v21 = x; - v22 = uSpriteID; + unsigned __int16 pObjectDescID; // ax@7 + SpriteObject pSpellObject; // [sp+Ch] [bp-78h]@1 - SpriteObject a1a; // [sp+Ch] [bp-78h]@1 - //SpriteObject::SpriteObject(&a1a); - a1a.stru_24.Reset(); - + pSpellObject.stru_24.Reset(); if ( a9 ) - { - memcpy(&a1a.stru_24, a9, sizeof(a1a.stru_24)); - v9 = v22; - } - v10 = 0; - a1a.spell_skill = 0; - a1a.spell_level = 0; - a1a.spell_id = 0; - a1a.field_54 = 0; - a1a.uType = v9; + memcpy(&pSpellObject.stru_24, a9, sizeof(pSpellObject.stru_24)); + pSpellObject.spell_skill = 0; + pSpellObject.spell_level = 0; + pSpellObject.spell_id = 0; + pSpellObject.field_54 = 0; + pSpellObject.uType = uSpriteID; if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_7: - v12 = 0; - } + pObjectDescID = 0; else { - v11 = (char *)&pObjectList->pObjects->uObjectID; - while ( (short)v9 != *(short *)v11 ) + pObjectDescID = 0; + for ( uint i = 0; i < (signed int)pObjectList->uNumObjects; ++i ) { - ++v10; - v11 += 56; - if ( v10 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_7; - } - v12 = v10; - } - a1a.uObjectDescID = v12; - a1a.vPosition.z = z; - a1a.vPosition.x = v21; - a1a.vPosition.y = y; - a1a.uSoundID = 0; - a1a.uAttributes = attributes; - a1a.uSectorID = pIndoor->GetSector(v21, y, z); - a1a.uSpriteFrameID = 0; - a1a.spell_caster_pid = 0; - a1a.spell_target_pid = 0; - if ( !(a1a.uAttributes & 0x10) ) - { - v13 = 0; - if ( (signed int)pItemsTable->uAllItemsCount > 0 ) - { - v14 = (char *)&pItemsTable->pItems[0].uSpriteID; - while ( *(short *)v14 != v9 ) - { - ++v13; - v14 += 48; - if ( (signed int)v13 >= (signed int)pItemsTable->uAllItemsCount ) - goto LABEL_16; - } - a1a.stru_24.uItemID = v13; + if ( (short)uSpriteID == pObjectList->pObjects[i].uObjectID ) + pObjectDescID = i; } } -LABEL_16: + pSpellObject.uObjectDescID = pObjectDescID; + pSpellObject.vPosition.x = x; + pSpellObject.vPosition.y = y; + pSpellObject.vPosition.z = z; + pSpellObject.uSoundID = 0; + pSpellObject.uAttributes = attributes; + pSpellObject.uSectorID = pIndoor->GetSector(x, y, z); + pSpellObject.uSpriteFrameID = 0; + pSpellObject.spell_caster_pid = 0; + pSpellObject.spell_target_pid = 0; + if ( !(pSpellObject.uAttributes & 0x10) ) + { + if ( pItemsTable->uAllItemsCount ) + { + for ( uint i = 0; i < pItemsTable->uAllItemsCount; ++i ) + { + if ( pItemsTable->pItems[i].uSpriteID == uSpriteID ) + pSpellObject.stru_24.uItemID = i; + } + } + } if ( a7 ) { - v15 = count; if ( count > 0 ) { - do + for ( uint i = count; i; --i ) { - a1a.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; - v16 = rand(); - a1a.Create( - (signed __int16)a1a.uFacing, - ((signed int)stru_5C6E00->uIntegerHalfPi >> 1) + (v16 % (signed int)stru_5C6E00->uIntegerHalfPi >> 1), - a4, - 0); - --v15; + pSpellObject.uFacing = rand() % (signed int)stru_5C6E00->uIntegerDoublePi; + pSpellObject.Create((signed __int16)pSpellObject.uFacing, + ((signed int)stru_5C6E00->uIntegerHalfPi / 2) + (rand() % ((signed int)stru_5C6E00->uIntegerHalfPi / 2)), a4, 0); + } - while ( v15 ); } } else { - v17 = count; - v18 = stru_5C6E00->uIntegerHalfPi; - a1a.uFacing = 0; + pSpellObject.uFacing = 0; if ( count > 0 ) { - do + for ( uint i = count; i; --i ) { - a1a.Create((signed __int16)a1a.uFacing, v18, a4, 0); - --v17; + pSpellObject.Create((signed __int16)pSpellObject.uFacing, stru_5C6E00->uIntegerHalfPi, a4, 0); } - while ( v17 ); } } - return 1; + return true; } //----- (0042F960) --------------------------------------------------------
--- a/mm7_data.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/mm7_data.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -58,7 +58,7 @@ std::array<Award, 105> pAwards; std::array<AwardType, 1000> achieved_awards; int num_achieved_awards; -int num_achieved_awards_2; +int full_num_items_in_book; #include "stru160.h" std::array<stru160, 66> array_4EB8B8 = @@ -231,9 +231,6 @@ 0x00000031, 0x00000031, 0x0000002D, 0x00000041 }}; -#include "stru220.h" -std::array<stru220, 16384> stru_76E5C8; - #include "stru176.h" stru176 array_5B5928_timers[100]; @@ -889,7 +886,7 @@ int dword_505890; // weak std::array<unsigned int, 480> pSRZBufferLineOffsets; int areWeLoadingTexture; // weak -std::array<char, 777> byte_506130; // weak +std::array<char, 777> books_num_items_per_page; // weak int dword_506338; // weak int dword_50633C; // idb signed int sRecoveryTime; // idb @@ -901,8 +898,8 @@ //Texture *dword_506404[12]; // weak //Texture *dword_50640C[12]; // weak unsigned int uExitCancelTextureId; -int dword_50651C; // weak -int dword_506528; // weak +int books_page_number; // weak +int books_primary_item_per_page; // weak int Autonotes_Instructors_page_flag; // dword_50652C int Autonotes_Misc_page_flag; //dword_506530 int Book_PageBtn6_flag; //dword_506534 @@ -930,7 +927,7 @@ std::array<int, 777> dword_506F0C; // idb int uRestUI_FoodRequiredToRest; int dword_506F14; // weak -int _506F18_num_hours_to_sleep; // weak +int _506F18_num_minutes_to_sleep; // weak int dword_506F1C; // weak std::array<int, 20> pVisibleWindowsIdxs; // weak int uNumVisibleWindows; @@ -964,7 +961,7 @@ int dword_507CC0_activ_ch; // weak __int64 GameUI_RightPanel_BookFlashTimer; // weak int _507CD4_RestUI_hourglass_anim_controller; // weak -int dword_507CD8; // weak +bool OpenedTelekinesis; std::array<int, 50> dword_50B570; // weak std::array<int, 50> dword_50B638; // weak stru367 PortalFace; @@ -1176,7 +1173,6 @@ int texmapping_terrain_subdivpow2; // weak int texmapping_building_subdivsize; // weak int texmapping_building_subdivpow2; // weak -std::array<int, 2> unnamed_6BE060 = {{0, 1}}; int mipmapping_building_mm1; // weak int mipmapping_building_mm2; // weak int mipmapping_building_mm3; // weak @@ -1318,7 +1314,7 @@ int dword_80AA1C; // weak int dword_80AA20; // weak unsigned int uNumElementsIn80AA28; -std::array<struct stru148 *, 2000> ptr_80AA28; +std::array<struct Polygon *, 2000> ptr_80AA28; struct Edge *pNewEdges; struct Surf *pSurfs; struct Edge *pEdges; @@ -1338,8 +1334,8 @@ std::array< std::array<struct Texture *, 56>, 4> pTextures_PlayerFaces; std::array<struct Player *, 5> pPlayers; __int64 qword_A750D8; // weak -__int16 word_A750E0; // weak -__int16 word_A750E2; // weak +enum PlayerSpeech PlayerSpeechID; +int uSpeakingCharacter; // weak std::array<char *, 36> pClassNames; std::array<char *, 19> aCharacterConditionNames; std::array<char *, 38> pSkillNames;
--- a/mm7_data.h Tue Aug 06 00:52:46 2013 +0400 +++ b/mm7_data.h Tue Aug 06 00:56:33 2013 +0400 @@ -532,7 +532,7 @@ extern int dword_505890; // weak extern std::array<unsigned int, 480> pSRZBufferLineOffsets; extern int areWeLoadingTexture; // weak -extern std::array<char, 777> byte_506130; // weak +extern std::array<char, 777> books_num_items_per_page; // weak extern int dword_506338; // weak extern int dword_50633C; // idb extern signed int sRecoveryTime; // idb @@ -543,8 +543,8 @@ extern int dword_506364; // weak //extern Texture *dword_50640C[]; // weak extern unsigned int uExitCancelTextureId; -extern int dword_50651C; // weak -extern int dword_506528; // weak +extern int books_page_number; // number for page in books(номер страницы в книгах) +extern int books_primary_item_per_page; // number primary item in book page(номер начальной записи на странице) extern int Autonotes_Instructors_page_flag; // dword_50652C extern int Autonotes_Misc_page_flag; //dword_506530 extern int Book_PageBtn6_flag; //dword_506534 @@ -573,7 +573,7 @@ extern std::array<int, 777> dword_506F0C; // idb extern int uRestUI_FoodRequiredToRest; extern int dword_506F14; // weak -extern int _506F18_num_hours_to_sleep; // weak +extern int _506F18_num_minutes_to_sleep; // weak extern int dword_506F1C; // weak extern std::array<int, 20> pVisibleWindowsIdxs; // weak extern int uNumVisibleWindows; @@ -607,7 +607,7 @@ extern int dword_507CC0_activ_ch; // weak extern __int64 GameUI_RightPanel_BookFlashTimer; // weak extern int _507CD4_RestUI_hourglass_anim_controller; // weak -extern int dword_507CD8; // weak +extern bool OpenedTelekinesis; // weak extern std::array<int, 50> dword_50B570; // weak extern std::array<int, 50> dword_50B638; // weak extern struct stru367 PortalFace; @@ -820,7 +820,6 @@ extern int texmapping_terrain_subdivpow2; // weak extern int texmapping_building_subdivsize; // weak extern int texmapping_building_subdivpow2; // weak -extern std::array<int, 2> unnamed_6BE060; extern int mipmapping_building_mm1; // weak extern int mipmapping_building_mm2; // weak extern int mipmapping_building_mm3; // weak @@ -973,7 +972,7 @@ extern int dword_80AA1C; // weak extern int dword_80AA20; // weak extern unsigned int uNumElementsIn80AA28; -extern std::array<struct stru148 *, 2000> ptr_80AA28; +extern std::array<struct Polygon *, 2000> ptr_80AA28; extern struct Edge *pNewEdges; extern struct Surf *pSurfs; extern struct Edge *pEdges; @@ -994,8 +993,8 @@ extern int dword_A75070; // weak extern std::array<struct Player *, 5> pPlayers; extern __int64 qword_A750D8; // weak -extern __int16 word_A750E0; // weak -extern __int16 word_A750E2; // weak +extern enum PlayerSpeech PlayerSpeechID; +extern int uSpeakingCharacter; // weak extern std::array<char *, 36> pClassNames; extern std::array<char *, 19> aCharacterConditionNames; extern std::array<char *, 38> pSkillNames; @@ -1091,8 +1090,6 @@ unsigned int __fastcall SearchActorByID(unsigned int *pTotalActors, unsigned int a2); void PrepareArcomage(); -// int __cdecl crt_retnull_sub(); -unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor); // idb unsigned short TargetColor(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b); // idb void __cdecl CallRenderPresent(); void __thiscall DoBlt_Copy(unsigned __int16 *pPixels); // idb @@ -1120,7 +1117,6 @@ void __thiscall sub_417871(int *pXY); unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2); signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx); // idb -void __fastcall sub_4179BC_draw_tooltip(const char *a1, const char *a2); // idb void FillAwardsData(); void sub_419220(); void sub_419379(); @@ -1134,7 +1130,7 @@ void __cdecl nullsub_3(); // idb void __cdecl LoadActualSkyFrame(); void __cdecl Sleep6Hours(); -void __cdecl sub_42038D(); +void __cdecl ChestUI_WritePointedObjectStatusString(); void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal); // idb void OnChestLeftClick(); @@ -1147,17 +1143,13 @@ bool PauseGameDrawing(); void SetUserInterface(enum PartyAlignment alignment, bool bReplace); void __cdecl reset_some_strus_flt_2Cs(); -void __cdecl j_sub_423B4A(); -void __cdecl sub_423B4A(); int __fastcall GetPortalScreenCoord(unsigned int uFaceID); -signed int __fastcall sub_424579(int uFaceID, struct stru320 *a2); -bool sub_424829(int pNumVertices, struct BspRenderer_stru2 *a2, struct BspRenderer_stru2 *a3, int uFaceID); -signed int __fastcall sr_424CD7(unsigned int uVertexID); // idb +signed int __fastcall sr_424579(int uFaceID, struct stru320 *a2); +bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID); +int sr_424CD7(unsigned int uVertexID); // idb signed int __fastcall sr_424EE0_MakeFanFromTriangle(unsigned int uVertexID); // idb signed int __fastcall sr_4250FE(unsigned int uVertexID); // idb -signed int __fastcall sr_4252E8(unsigned int uVertexID); -int __fastcall sr_4254D2(signed int a1); -bool __thiscall sr_42620A(struct RenderVertexSoft *p); +bool sr_42620A(struct RenderVertexSoft *p); int __fastcall _4268E3_smthn_to_a1r5g5b5(unsigned int uColor); // idb int __fastcall _42690D_colors_cvt(unsigned int a1); void __cdecl sub_426947(); @@ -1206,8 +1198,6 @@ void WetsuitOn(unsigned int uPlayerID); // idb void WetsuitOff(unsigned int uPlayerID); void __fastcall PrepareDrawLists_BLV(struct IndoorLocation_drawstru *_this); -int /*__usercall*/ sr_sub_4D6FB0/*<eax>*/(struct stru315 *a1/*<ebp>*/); -int /*__usercall*/ sr_sub_4D705A/*<eax>*/(struct stru315 *a1/*<ebp>*/); void __cdecl FindBillboardsLightLevels_BLV(); int __fastcall _43F55F_get_billboard_light_level(struct RenderBillboard *a1, int uBaseLightLevel); int __fastcall _43F5C8_get_point_light_level_with_respect_to_lights(unsigned int uBaseLightLevel, int uSectorID, float x, float y, float z); @@ -1227,10 +1217,10 @@ void __cdecl OnMapLeave(); void /*__usercall*/ OnMapLoad(); -void __thiscall Level_LoadEvtAndStr(const char *pLevelName); +void Level_LoadEvtAndStr(const char *pLevelName); const char *__cdecl sub_444564(); char *__thiscall GetEventHintString(unsigned int uEventID); // idb -signed int __cdecl GetTravelTime(); +int GetTravelTime(); void __fastcall sub_4451A8_press_any_key(int a1, int a2, int a4); void __cdecl sub_4452BB(); const char *GetProfessionActionText(int a1); @@ -1266,7 +1256,7 @@ int __fastcall sub_44FA4C_spawn_light_elemental(int a1, int a2, int a3); signed int __fastcall sub_450521_ProllyDropItemAt(int ecx0, signed int a2, int a3, int a4, int a5, unsigned __int16 a6); -int __fastcall sub_45063B(struct MapInfo *a1, int a2); +int __fastcall _45063B_spawn_some_monster(struct MapInfo *a1, int a2); void RespawnGlobalDecorations(); bool __fastcall SpawnActor(unsigned int uMonsterID); int __cdecl GetAlertStatus(); @@ -1275,7 +1265,7 @@ int __fastcall MakeColorMaskFromBitDepth(int a1); void __fastcall fill_pixels_fast(unsigned int a1, unsigned __int16 *pPixels, unsigned int uNumPixels); int __fastcall GetDiceResult(unsigned int uNumDice, unsigned int uDiceSides); // idb -inline int round(float x) { return (floor(x + 0.5)); } +inline int round(float x) { return (int)floor(x + 0.5f); } inline void __fastcall memset32(void *ptr, unsigned __int32 value, int count) { auto p = (unsigned __int32 *)ptr; @@ -1303,7 +1293,7 @@ void __fastcall PrepareToLoadODM(unsigned int bLoading, struct OutdoorCamera *a2); void __cdecl sub_461103(); int __cdecl sub_4613C4(); -int __fastcall int_get_vector_length(signed int a1, signed int a2, signed int a3); +int int_get_vector_length(signed int x, signed int y, signed int z); int __cdecl sub_46224A(); int __cdecl crt_init_globals_462620(); void __cdecl crt_init_globals_462659(); @@ -1353,7 +1343,7 @@ bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2); void __cdecl check_event_triggers(); int BLV_GetFloorLevel(int x, int y, int z, unsigned int uSectorID, unsigned int *pFaceID); -int __fastcall ODM_GetFloorLevel(int X, signed int Y, int Z, int, int *pOnWater, int *a6, int bWaterWalk); +int ODM_GetFloorLevel(int X, signed int Y, int Z, int, int *pOnWater, int *bmodel_pid, int bWaterWalk); int __fastcall sub_46D8E3(int a1, signed int a2, int a3, int a4); void ODM_GetTerrainNormalAt(int pos_x, int pos_z, Vec3_int_ *out); unsigned int __fastcall sub_46DEF2(signed int a2, unsigned int uLayingItemID); @@ -1366,13 +1356,13 @@ void __fastcall _46ED8A_collide_against_sprite_objects(unsigned int _this); int __thiscall _46EF01_collision_chech_player(int a1); // idb signed int __cdecl _46F04E_collide_against_portals(); -void __cdecl BLV_UpdateDoors(); -void __cdecl UpdateActors_BLV(); -void __cdecl UpdateActors_ODM(); -void __cdecl UpdateObjects(); +void BLV_UpdateDoors(); +void UpdateActors_BLV(); +void UpdateActors_ODM(); +void UpdateObjects(); int collide_against_floor_approximate(int x, int y, int z, unsigned int *pSectorID, unsigned int *pFaceID); // idb -void __cdecl BLV_ProcessPartyActions(); -void __cdecl ODM_ProcessPartyActions(); +void BLV_ProcessPartyActions(); +void ODM_ProcessPartyActions(); bool __fastcall sub_47531C(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10); bool __fastcall sub_4754BF(int a1, int *a2, int a3, int a4, int a5, int a6, int a7, int a8, BLVFace *a9, int a10, int a11); signed int __thiscall sub_475665(BLVFace *_this, int a2, __int16 a3); @@ -1385,52 +1375,21 @@ void __cdecl loc_4789D4(); // idb void __cdecl loc_47907F(); // idb bool __fastcall IsBModelVisible(unsigned int uModelID, int *unused); -void __fastcall _479A53_draw_some_blv_poly(unsigned int uNumVertices, unsigned int uFaceID); // idb void __thiscall ODM_LoadAndInitialize(const char *pLevelFilename, struct OutdoorCamera *thisa); -unsigned __int16 *__fastcall GetBillboardPalette(struct RenderBillboard *a1, int a2, signed int a3, int a4); -int __fastcall sr_sub_47BEB1(signed int a1, stru148 *a2, int terrain_gamma, int a4, int *a5, int *a6, int a7, int a8); -void *__fastcall sr_sub_47C178(signed int a1, stru148 *a2, int terrain_gamma, int a4); -void *__fastcall sr_sub_47C1CA(stru148 *a1, char a2, int a3, signed int a4); -unsigned __int16 *__fastcall sr_sub_47C24C_get_palette(BLVFace *a1, int a2, int a3, char a4); -char *__fastcall sr_sub_47C28C_get_palette(stru148 *a1, char a2, signed int a3, signed int a4); -unsigned int __cdecl GetLevelFogColor(); +unsigned int GetLevelFogColor(); int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3); signed int __fastcall GetActorTintColor(int max_dim, int min_dim, float distance, int a4, struct RenderBillboard *a5); -unsigned int __stdcall WorldPosToGridCellX(int); // weak -unsigned int __stdcall WorldPosToGridCellZ(int); // weak +unsigned int WorldPosToGridCellX(int); // weak +unsigned int WorldPosToGridCellZ(int); // weak int __stdcall GridCellToWorldPosX(int); // weak int __stdcall GridCellToWorldPosZ(int); // weak -void __fastcall sub_47F4D3(int band1, int band2, int band3); -void __cdecl loc_481185(); // idb void __cdecl loc_48118F(); // idb void __cdecl loc_481199(); // idb -char __fastcall sr_sub_481DB2(RenderVertexSoft *a1, signed int a2, stru148 *a3); -void __cdecl ResetStru148s(); +void ResetPolygons(); void __cdecl sub_481ED9_MessWithOutdoorCamera(); -bool __fastcall sub_481EFA(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5); -signed int __fastcall sub_481FC9(RenderVertexSoft *_ECX, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4); bool IsTerrainSlopeTooHigh(int pos_x, int pos_y); int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4); -struct stru148 *__fastcall sr_sub_4829B9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4, int a5); signed int __cdecl const_1_0(); -signed int __thiscall sr_sub_482A94(struct Span *_this); -signed int __fastcall sr_sub_482E07(struct Span *a1, unsigned __int16 *pRenderTarget); // idb -signed int __fastcall sr_sub_4839BD(struct Span *a1, unsigned __int16 *pTargetSurface); // idb -signed int __thiscall sr_sub_48408A_prolly_odm_water_no_waves(struct Span *_this); -signed int __thiscall sr_sub_484442(struct Span *_this); -signed int __thiscall sr_sub_4847EB(struct Span *_this); -signed int __fastcall sr_sub_485407_prolly_odm_water_wavy(struct Span *a1); -signed int __fastcall sr_sub_48585C_mb_DrawSpan(struct Span *a1, unsigned __int16 *pRenderTarget, int a3); // idb -struct stru315 *__fastcall sr_sub_485975(struct stru315 *a1, struct stru315 *a2); -struct stru315 *__fastcall sr_sub_485A24(struct stru315 *a1, struct stru315 *a2); -struct stru315 *__fastcall sr_sub_485AFF(struct stru315 *a1, struct stru316 *a2); -struct stru315 *__fastcall sr_sub_485BAE(struct stru315 *a1, struct stru316 *a2); -struct stru315 *__fastcall sr_sub_485C89(struct stru315 *a1, struct stru316 *a2); -struct stru315 *__fastcall sr_sub_485D3E(struct stru315 *a1, struct stru316 *a2); -void *__fastcall sr_sub_485E1F(struct stru316 *a1, Span *a2, int a3, struct stru148 *a4, int a5, unsigned __int8 a6, char a7); -void __thiscall sub_485F53(struct Vec2_int_ *v); // idb -char __fastcall sr_sub_486B4E_push_outdoor_edges(struct RenderVertexSoft *a1, int *a2, int *a3, stru148 *a4); -void __cdecl sr_sub_486F92_MessWithEdgesAndSpans(); void __cdecl sub_487DA9(); double __thiscall GetFogDensityByTime(struct OutdoorLocation *_this); int __stdcall loc_489BB3(struct stru320 *a2, int thisa, unsigned int uNumVertices, RenderVertexSoft *a5, float a6, char uClipFlag); // weak @@ -1449,13 +1408,12 @@ void _494035_timed_effects__water_walking_damage__etc(); unsigned int __fastcall _494820_training_time(unsigned int a1); char *__fastcall sub_495366(unsigned __int8 a1, unsigned __int8 a2); -char * GetReputationString(signed int a1); -char *BuilDialogueString(char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6); +char *GetReputationString(signed int a1); +char *BuildDialogueString(char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6); void PlayerCreationUI_Draw(); void PlayerCreationUI_Initialize(); void DeleteCCharFont(); bool PlayerCreationUI_Loop(); -void loc_49B785(); // idb unsigned int __fastcall GetMaxMipLevels(unsigned int uDim); bool CheckTextureStages(); bool AreRenderSurfacesOk(); @@ -1464,35 +1422,20 @@ int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int z, int a4, unsigned int lightColor); void Present_ColorKey(); void Present_NoColorKey(); -int __thiscall sub_4A7063(unsigned int uDiffuse, float a2); // idb -struct SoundHeader *__fastcall FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName); +unsigned int ModulateColor(unsigned int diffuse, float multiplier); // idb +struct SoundHeader *FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName); struct SoundData *LoadSound(const char *pSoundName, struct SoundData *pOutBuff, unsigned int uID); int __fastcall sub_4AAEA6_transform(RenderVertexSoft *a1); int __fastcall sub_4AB66C(int, int); // weak -int __fastcall GetSoundStrengthByDistanceFromParty(int a1, int a2, int a3); +int GetSoundStrengthByDistanceFromParty(int x, int y, int z); struct _DIG_DRIVER *Audio_GetFirstHardwareDigitalDriver(void); void __cdecl PlayLevelMusic(); -struct Vec4_int_ *__thiscall _4AC277_get_cpu_speed_sub3(unsigned int _this, Vec4_int_ *a2); -int __fastcall sub_4AD504(signed int uFaceID); -void __fastcall sub_4ADD1D(int uFaceID); -int __fastcall sub_4AE1E7(int a1, int a2, int a3); -int __fastcall sub_4AE313(int viewport_space_x, int viewport_space_y, struct stru337_stru0 *p); -int __fastcall sub_4AE491(int, int); // weak -void __fastcall sub_4AE5F1(unsigned int uFaceID); // idb -int __cdecl sub_4AF412(); -//void __cdecl stru170_sub_4B0967_draw_face_outlines(); -void __cdecl loc_4B0DFB(); // idb -void __cdecl nullsub_18(); // idb -void __cdecl nullsub_19(); // idb unsigned int __fastcall sub_4B0E07(unsigned int uFaceID); // idb -void __cdecl nullsub_20(); // idb -void __cdecl nullsub_21(); // idb struct Player *__fastcall sub_4B1447_party_fine(int a1, int a2, int a3); void __thiscall sub_4B1523(int *_this); -bool __cdecl sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); void __cdecl ShowPopupShopItem(); void __stdcall RestAndHeal(__int64 uNumMinutes); // idb -void __cdecl sub_4B1D27(); +void __cdecl GetHouseGoodbyeSpeech(); void __cdecl sub_4B1ECE(); void __fastcall ClickNPCTopic(signed int uMessageParam); @@ -1501,18 +1444,14 @@ void SimpleHouseAndBoatsDialog(); void CreateButtonInColumn(int a1, unsigned int a2); void FillAviableSkillsToTeach(int _this); -void sub_4B3A72(int a1); // idb -void sub_4B3AD4(signed int a1); -void sub_4B3B42(signed int a1); void __cdecl sub_4B3E1E(); void DrawJoinGuildWindow(int pEventCode); void __fastcall sub_4B3FE5(int a4); -void NPCHireableDialogPrepare(); -void _4B4224_UpdateNPCTopics(int _this); +void NPCHireableDialogPrepare(); +void _4B4224_UpdateNPCTopics(int _this); void __fastcall DrawTextAtStatusBar(const char *Str, int a5); int __fastcall sub_4B46F8(int a1); -signed int __fastcall sub_4BB756(signed int a1); const char *sub_4BBA85_bounties(); void __cdecl sub_4BBCDD(); void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z); // idb @@ -1529,23 +1468,6 @@ unsigned int __thiscall GameOverMenu(void *ecx0); bool __thiscall BinkLockBuffer(struct _BINKBUF *_this); void __thiscall BinkUnlockBuffer(struct _BINKBUF *_this); -void __cdecl loc_4C0D27(); // idb -void __cdecl vis_nullsub_22(); // idb -void __cdecl vis_nullsub_23(); // idb -void __cdecl vis_loc_4C19F7(); // idb -int __cdecl sr_sub_4D714C(struct stru315 *a1); -int __cdecl sr_sub_4D71F8(struct stru315 *a1); -void __cdecl sr_sub_4D754B(struct stru315 *a1, struct stru316 *a2); -void __cdecl sr_sub_4D7630(struct stru315 *a1, struct stru316 *a2); -void __cdecl sr_sub_4D76ED(struct stru315 *a1, struct stru316 *a2); -void __cdecl sr_sub_4D77D2(struct stru315 *a1, struct stru316 *a2); -void __cdecl sr_sub_4D789A(struct stru315 *a1, struct stru316 *a2); -int __cdecl sub_4D798C(int a1, int a2, int a3, int a4); -int __cdecl sub_4D79CF(int a1, int a2, int a3, int a4); -int __cdecl sub_4D79FD(int a1, int a2, int a3, int a4); -int __cdecl sub_4D7A10(int a1, int a2, int a3, int a4); -int /*__usercall*/ sr_sub_4D72EC/*<eax>*/(int a1/*<ebp>*/); -int /*__usercall*/ sr_sub_4D73DF/*<eax>*/(int a1/*<ebp>*/); signed int __fastcall SpawnRandomTreasure(struct MapInfo *a1, struct SpawnPointMM7 *a2); void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, struct Vec3_int_ *pVelocity);
--- a/stru11.h Tue Aug 06 00:52:46 2013 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -#pragma once - - -/* 128 */ -#pragma pack(push, 1) -struct stru11 -{ - - stru11(); - - void CheckCPU(); - void RunCPUID(); - void RunCPUID_op1(); - void RunCPUID_op2(); - void RunCPUID_ext2_3_4(); - - int cpuid_00000000_eax_numops; - int cpuid_00000000_ebx_vendorstr1; - int cpuid_00000000_edx_vendorstr2; - int cpuid_00000000_ecx_vendorstr3; - char pCPUString[16]; - int cpuid_00000001_eax; - int cpuid_00000001_edx; - int cpuid_00000002_eax; - int cpuid_00000002_ebx; - int cpuid_00000002_ecx; - int cpuid_00000002_edx; - int field_38; - int field_3C; - int field_40[8]; - int cpuid_80000000_edx; - int cpuid_80000001_eax; - int cpuid_80000001_edx; - int cpuid_80000002_registers[4]; - int cpuid_80000003_registers[4]; - int cpuid_80000004_registers[4]; - int cpuid_80000005_ebx; - int cpuid_80000005_ecx; - int cpuid_80000005_edx; - int cpuid_80000006_ecx; - int field_AC; - int uProcessorManufacturer; - int cpuid_80000002_registers2[4]; - int cpuid_80000003_registers2[4]; - int cpuid_80000004_registers2[4]; - int field_E4; -}; -#pragma pack(pop)
--- a/stru12.h Tue Aug 06 00:52:46 2013 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -#pragma once - - -/* 130 */ -#pragma pack(push, 1) -struct stru12_MemoryBlock -{ - stru12_MemoryBlock(int a2); - ~stru12_MemoryBlock(); - - - void *pAlignedBlock; - void *pBlockBase; -}; -#pragma pack(pop) - -/* 129 */ -#pragma pack(push, 1) -struct stru12 -{ - stru12(stru11 *pStru11); - ~stru12(); - - void _4898E6(); - - void (__thiscall *vdestructor_ptr)(stru12 *); - int field_4[16]; - int field_44; - int field_48; - int field_4C; - int field_50; - int field_54; - int field_58; - stru12_MemoryBlock *pMemBlocks[12]; - int field_8C; -}; -#pragma pack(pop) \ No newline at end of file
--- a/stru159.h Tue Aug 06 00:52:46 2013 +0400 +++ b/stru159.h Tue Aug 06 00:56:33 2013 +0400 @@ -9,7 +9,7 @@ char *video_name; int field_4; int house_npc_id; - unsigned __int8 uBuildingType; + unsigned __int8 uBuildingType; // enum BuildingType unsigned __int8 uRoomSoundId; unsigned __int16 padding_e; };
--- a/stru220.h Tue Aug 06 00:52:46 2013 +0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#pragma once - - - -/* 210 */ -#pragma pack(push, 1) -struct stru220 -{ - __int16 field_0;//char field_0; - //char field_1; - __int16 distance; -}; -#pragma pack(pop) -extern std::array<stru220, 16384> stru_76E5C8; \ No newline at end of file
--- a/stru6.cpp Tue Aug 06 00:52:46 2013 +0400 +++ b/stru6.cpp Tue Aug 06 00:56:33 2013 +0400 @@ -61,40 +61,28 @@ } //----- (0047829F) -------------------------------------------------------- -void stru6_stru1_indoor_sw_billboard::_47829F_fireball_collision(float arg0, float a3, float a4, float a5, int a2) +void stru6_stru1_indoor_sw_billboard::_47829F_sphere_particle(float x_offset, float y_offset, float z_offset, float scale, int diffuse) { - stru6_stru1_indoor_sw_billboard *v6; // esi@1 - int v7; // edi@1 - char *v8; // eax@2 - signed int v9; // ecx@2 - int v10; // edx@3 - signed int i; // [sp+8h] [bp-4h]@1 + int v7 = 0; - auto a1 = this; - - v6 = a1; - v7 = 0; - for ( i = 0; i < (signed int)v6->uNumVec3sInArray2; ++i ) + for (unsigned int i = 0; i < uNumVec3sInArray2; ++i) { - v8 = (char *)&v6->field_14[1]; - v9 = 3; - do + for (unsigned int j = 0; j < 3; ++j) { - *((float *)v8 - 1) = a5 * *(&v6->pArray1->field_0 + 4 * *(int *)((char *)&v6->pArray2->field_0 + v7)) + arg0; - *(float *)v8 = a5 * *(&v6->pArray1->field_4 + 4 * *(int *)((char *)&v6->pArray2->field_0 + v7)) + a3; - v8 += 16; - *((float *)v8 - 3) = a5 * *(&v6->pArray1->field_8 + 4 * *(int *)((char *)&v6->pArray2->field_0 + v7)) + a4; - v10 = *(int *)((char *)&v6->pArray2->field_0 + v7); + field_14[j].x = x_offset + scale * *(&pArray1->field_0 + 4 * *(int *)((char *)&pArray2->field_0 + v7)); + field_14[j].y = y_offset + scale * *(&pArray1->field_4 + 4 * *(int *)((char *)&pArray2->field_0 + v7)); + field_14[j].z = z_offset + scale * *(&pArray1->field_8 + 4 * *(int *)((char *)&pArray2->field_0 + v7)); + int v10 = *(int *)((char *)&pArray2->field_0 + v7); + + field_14[j].diffuse = *((int *)&pArray1[1].field_0 + 4 * v10); v7 += 4; - --v9; - *((int *)v8 - 2) = *((int *)&v6->pArray1[1].field_0 + 4 * v10); } - while ( v9 ); - v6->field_10 = 3; - if ( v6->sub_477C61() && v6->sub_477F63() ) + + uNumVertices = 3; + if ( sub_477C61() && sub_477F63() ) { - if ( v6->sub_47802A() ) - pRenderer->_4A4CC9(v6, a2); + if ( sub_47802A() ) + pRenderer->_4A4CC9_AddSomeBillboard(this, diffuse); } } } @@ -192,9 +180,9 @@ local_0.x = x + 4.0; local_0.y = v8; local_0.z = v9; - local_0.flt_10 = 0.0; - local_0.flt_14 = 0.0; - local_0.flt_18 = 0.0; + local_0.r = 0.0; + local_0.g = 0.0; + local_0.b = 0.0; local_0.timeToLive = (rand() & 0x40) + 96; local_0.uTextureID = uTextureID; local_0.flt_28 = 1.0; @@ -223,9 +211,9 @@ local_0.x = v10 + 4.0; local_0.y = (double)a2->vPosition.y; local_0.z = (double)a2->vPosition.z; - local_0.flt_10 = 0.0; - local_0.flt_14 = 0.0; - local_0.flt_18 = 0.0; + local_0.r = 0.0; + local_0.g = 0.0; + local_0.b = 0.0; local_0.flt_28 = 1.0; local_0.timeToLive = (rand() & 0x7F) + 128; local_0.uTextureID = uTextureID; @@ -255,9 +243,9 @@ local_0.flt_28 = 1.0; do { - local_0.flt_10 = (double)(rand() & 0x1FF) - 255.0; - local_0.flt_14 = (double)(rand() & 0x1FF) - 255.0; - local_0.flt_18 = (double)(rand() & 0x1FF) - 255.0; + local_0.r = (double)(rand() & 0x1FF) - 255.0; + local_0.g = (double)(rand() & 0x1FF) - 255.0; + local_0.b = (double)(rand() & 0x1FF) - 255.0; pGame->pParticleEngine->AddParticle(&local_0); --v5; } @@ -267,98 +255,76 @@ //----- (004A7688) -------------------------------------------------------- void stru6::_4A7688_fireball_collision_particle(SpriteObject *a2) { - SpriteObject *v2; // esi@1 double v3; // st7@1 double v4; // st7@2 - double v5; // st7@4 int v6; // eax@6 float v7; // ST0C_4@6 float v8; // ST08_4@6 float v9; // ST04_4@6 float v10; // ST00_4@6 Particle_sw local_0; // [sp+1Ch] [bp-7Ch]@1 - stru6 *v12; // [sp+84h] [bp-14h]@1 float v13; // [sp+88h] [bp-10h]@1 - double v14; // [sp+8Ch] [bp-Ch]@5 - float v15; // [sp+94h] [bp-4h]@4 - signed int i; // [sp+A0h] [bp+8h]@4 - signed int a2b; // [sp+A0h] [bp+8h]@6 - v12 = this; memset(&local_0, 0, 0x68u); - v2 = a2; + v3 = (double)a2->uSpriteFrameID / (double)pObjectList->pObjects[a2->uObjectDescID].uLifetime; v13 = 512.0 * v3; if ( v3 >= 0.75 ) v4 = (1.0 - v3) * 4.0; else v4 = v3 * 1.333333333333333; - v15 = v4; - v5 = (double)a2->vPosition.x; + local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_1; local_0.uDiffuse = 0xFF3C1E; - local_0.x = v5; + local_0.x = (double)a2->vPosition.x; local_0.y = (double)a2->vPosition.y; local_0.z = (double)a2->vPosition.z; local_0.timeToLive = (rand() & 0x7F) + 128; local_0.uTextureID = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT); - i = 10; local_0.flt_28 = 1.0; - do + + // 10 fireball sparks + for (unsigned int i = 0; i < 10; ++i) { - HIDWORD(v14) = rand() & 0x1FF; - local_0.flt_10 = (double)SHIDWORD(v14) - 255.0; - HIDWORD(v14) = rand() & 0x1FF; - local_0.flt_14 = (double)SHIDWORD(v14) - 255.0; - WORD2(v14) = rand() & 0x1FF; - HIDWORD(v14) = WORD2(v14); - local_0.flt_18 = (double)WORD2(v14) - 255.0; + local_0.r = (rand() & 0x1FF) - 255; + local_0.g = (rand() & 0x1FF) - 255; + local_0.b = (rand() & 0x1FF) - 255; pGame->pParticleEngine->AddParticle(&local_0); - --i; } - while ( i ); - v14 = v13 + 6.7553994e15; - a2b = LODWORD(v14); - v6 = sub_4A7063(0xFF3C1Eu, v15); - v7 = (double)a2b; - v8 = (double)v2->vPosition.z; - v9 = (double)v2->vPosition.y; - v10 = (double)v2->vPosition.x; - v12->pStru1->_47829F_fireball_collision(v10, v9, v8, v7, v6); + + v6 = ModulateColor(0xFF3C1E, v4); + v7 = (double)floorf(0.5f + v13); + v8 = (double)a2->vPosition.z; + v9 = (double)a2->vPosition.y; + v10 = (double)a2->vPosition.x; + pStru1->_47829F_sphere_particle(v10, v9, v8, v7, v6); } //----- (004A77FD) -------------------------------------------------------- -void stru6::_4A77FD_some_stuff_d3d(SpriteObject *a1) +void stru6::_4A77FD_implosion_particle(SpriteObject *a1) { - SpriteObject *v2; // esi@1 - stru6 *v3; // edi@1 double v4; // st7@1 double v5; // st7@2 - double v6; // ST1C_8@4 int v7; // eax@4 float v8; // ST0C_4@4 float v9; // ST08_4@4 float v10; // ST04_4@4 float v11; // ST00_4@4 float v12; // [sp+28h] [bp-4h]@1 - float a1a; // [sp+34h] [bp+8h]@4 - v2 = a1; - v3 = this; v4 = (double)a1->uSpriteFrameID / (double)pObjectList->pObjects[a1->uObjectDescID].uLifetime; v12 = 512.0 - v4 * 512.0; if ( v4 >= 0.75 ) v5 = v4 * 4.0; else v5 = v4 * 1.333333333333333; - a1a = v5; - v6 = v12 + 6.7553994e15; - v7 = sub_4A7063(0x7E7E7Eu, a1a); - v8 = (double)SLODWORD(v6); - v9 = (double)v2->vPosition.z; - v10 = (double)v2->vPosition.y; - v11 = (double)v2->vPosition.x; - v3->pStru1->_47829F_fireball_collision(v11, v10, v9, v8, v7); + + v7 = ModulateColor(0x7E7E7E, v5); + v8 = (double)floorf(0.5f + v12); + v9 = (double)a1->vPosition.z; + v10 = (double)a1->vPosition.y; + v11 = (double)a1->vPosition.x; + pStru1->_47829F_sphere_particle(v11, v10, v9, v8, v7); } //----- (004A78AE) -------------------------------------------------------- @@ -379,9 +345,9 @@ local_0.timeToLive = 1; local_0.y = v4; local_0.z = (double)a1->vPosition.z; - local_0.flt_10 = 0.0; - local_0.flt_14 = 0.0; - local_0.flt_18 = 0.0; + local_0.r = 0.0; + local_0.g = 0.0; + local_0.b = 0.0; local_0.uTextureID = pSpriteFrameTable->GetFrame(v2->uSpriteID, v3)->pHwSpriteIDs[0]; LODWORD(local_0.flt_28) = 0x40000000u; pGame->pParticleEngine->AddParticle(&local_0); @@ -413,9 +379,9 @@ Dst.timeToLive = (v5 & 0x7F) + 128; do { - Dst.flt_10 = (double)(rand() & 0x1FF) - 255.0; - Dst.flt_14 = (double)(rand() & 0x1FF) - 255.0; - Dst.flt_18 = (double)(rand() & 0x1FF) - 255.0; + Dst.r = (double)(rand() & 0x1FF) - 255.0; + Dst.g = (double)(rand() & 0x1FF) - 255.0; + Dst.b = (double)(rand() & 0x1FF) - 255.0; pGame->pParticleEngine->AddParticle(&Dst); --v6; } @@ -466,43 +432,43 @@ local_0.timeToLive = (v6 & 0x7F) + 128; local_0.uTextureID = uTextureID; a1a = v7; - local_0.flt_10 = v7; - local_0.flt_14 = a4; - local_0.flt_18 = a4; + local_0.r = v7; + local_0.g = a4; + local_0.b = a4; pGame->pParticleEngine->AddParticle(&local_0); v8 = 0.70710677 * a4; uDiffusea = v8; - local_0.flt_10 = v8; - local_0.flt_14 = v8; - local_0.flt_18 = a4; + local_0.r = v8; + local_0.g = v8; + local_0.b = a4; pGame->pParticleEngine->AddParticle(&local_0); - local_0.flt_14 = a1a; - local_0.flt_10 = a4; - local_0.flt_18 = a4; + local_0.g = a1a; + local_0.r = a4; + local_0.b = a4; pGame->pParticleEngine->AddParticle(&local_0); - local_0.flt_10 = uDiffusea; - local_0.flt_18 = a4; + local_0.r = uDiffusea; + local_0.b = a4; v9 = -uDiffusea; uTextureIDa = v9; - local_0.flt_14 = v9; + local_0.g = v9; pGame->pParticleEngine->AddParticle(&local_0); v10 = -1.0 * a4; - local_0.flt_10 = a1a; + local_0.r = a1a; v12 = v10; - local_0.flt_14 = v10; - local_0.flt_18 = a4; + local_0.g = v10; + local_0.b = a4; pGame->pParticleEngine->AddParticle(&local_0); - local_0.flt_18 = a4; - local_0.flt_10 = uTextureIDa; - local_0.flt_14 = uTextureIDa; + local_0.b = a4; + local_0.r = uTextureIDa; + local_0.g = uTextureIDa; pGame->pParticleEngine->AddParticle(&local_0); - local_0.flt_10 = v12; - local_0.flt_14 = a1a; - local_0.flt_18 = a4; + local_0.r = v12; + local_0.g = a1a; + local_0.b = a4; pGame->pParticleEngine->AddParticle(&local_0); - local_0.flt_10 = uTextureIDa; - local_0.flt_14 = uDiffusea; - local_0.flt_18 = a4; + local_0.r = uTextureIDa; + local_0.g = uDiffusea; + local_0.b = a4; pGame->pParticleEngine->AddParticle(&local_0); } @@ -540,9 +506,9 @@ local_0.x = v7; local_0.z = a2a; local_0.y = v8; - local_0.flt_10 = 0.0; - local_0.flt_14 = 0.0; - local_0.flt_18 = 0.0; + local_0.r = 0.0; + local_0.g = 0.0; + local_0.b = 0.0; v10 = rand(); LODWORD(local_0.flt_28) = 0x40400000u; local_0.timeToLive = (v10 & 0x3F) + 64; @@ -572,9 +538,9 @@ local_0.x = v12; local_0.y = (double)a2->vPosition.y; local_0.z = (double)a2->vPosition.z; - local_0.flt_10 = 0.0; - local_0.flt_14 = 0.0; - local_0.flt_18 = 0.0; + local_0.r = 0.0; + local_0.g = 0.0; + local_0.b = 0.0; local_0.timeToLive = (rand() & 0x3F) + 64; local_0.uTextureID = pSpriteFrameTable->GetFrame(v5->uSpriteID, a2->uSpriteFrameID)->pHwSpriteIDs[0]; pGame->pParticleEngine->AddParticle(&local_0); @@ -584,32 +550,22 @@ //----- (004A7E05) -------------------------------------------------------- void stru6::AddProjectile(SpriteObject *a2, int a3, unsigned int uTextureID) { - int v4; // edx@1 - float v5; // ST14_4@2 - float v6; // ST10_4@2 - float v7; // ST0C_4@2 - - v4 = a2->field_54; - if ( v4 ) + if (a2->field_54) { - v5 = (double)a2->vPosition.z; - v6 = (double)a2->vPosition.y; - v7 = (double)a2->vPosition.x; - DoAddProjectile( - this->array_4[v4 & 0x1F].flt_0_x, - this->array_4[v4 & 0x1F].flt_4_y, - this->array_4[v4 & 0x1F].flt_8_z, - v7, - v6, - v5, - uTextureID); + DoAddProjectile(array_4[a2->field_54 & 0x1F].flt_0_x, + array_4[a2->field_54 & 0x1F].flt_4_y, + array_4[a2->field_54 & 0x1F].flt_8_z, + a2->vPosition.x, + a2->vPosition.y, + a2->vPosition.z, + uTextureID); } else { - a2->field_54 = this->field_0++; - this->array_4[a2->field_54 & 0x1F].flt_0_x = (double)a2->vPosition.x; - this->array_4[a2->field_54 & 0x1F].flt_4_y = (double)a2->vPosition.y; - this->array_4[a2->field_54 & 0x1F].flt_8_z = (double)a2->vPosition.z; + a2->field_54 = field_0++; + array_4[a2->field_54 & 0x1F].flt_0_x = (double)a2->vPosition.x; + array_4[a2->field_54 & 0x1F].flt_4_y = (double)a2->vPosition.y; + array_4[a2->field_54 & 0x1F].flt_8_z = (double)a2->vPosition.z; } } @@ -687,9 +643,9 @@ z1 = (double)z; local_0.z = z1; local_0.y = v9 * 40.0 - 20.0 + v11; - local_0.flt_10 = pRnd->GetRandom() * 400.0 - 200.0; - local_0.flt_14 = pRnd->GetRandom() * 400.0 - 200.0; - local_0.flt_18 = pRnd->GetRandom() * 150.0 + 50.0; + local_0.r = pRnd->GetRandom() * 400.0 - 200.0; + local_0.g = pRnd->GetRandom() * 400.0 - 200.0; + local_0.b = pRnd->GetRandom() * 150.0 + 50.0; pGame->pParticleEngine->AddParticle(&local_0); --v6; } @@ -731,16 +687,14 @@ //----- (004A80DC) -------------------------------------------------------- void stru6::_4A80DC_some_stuff_sw(SpriteObject *a2) { - stru6 *v2; // esi@1 signed int v3; // ebx@1 Particle_sw local_0; // [sp+Ch] [bp-68h]@1 - v2 = this; memset(&local_0, 0, 0x68u); local_0.type = ParticleType_Bitmap | ParticleType_Rotating | ParticleType_1; local_0.uDiffuse = 0x7E7E7E; local_0.timeToLive = (rand() & 0x7F) + 128; - local_0.uTextureID = v2->uTextureID_effpar1; + local_0.uTextureID = uTextureID_effpar1; v3 = 8; local_0.flt_28 = 1.0; do @@ -748,9 +702,9 @@ local_0.x = pRnd->GetRandom() * 40.0 + (double)a2->vPosition.x - 20.0; local_0.y = pRnd->GetRandom() * 40.0 + (double)a2->vPosition.y - 20.0; local_0.z = (double)a2->vPosition.z; - local_0.flt_10 = pRnd->GetRandom() * 800.0 - 400.0; - local_0.flt_14 = pRnd->GetRandom() * 800.0 - 400.0; - local_0.flt_18 = pRnd->GetRandom() * 350.0 + 50.0; + local_0.r = pRnd->GetRandom() * 800.0 - 400.0; + local_0.g = pRnd->GetRandom() * 800.0 - 400.0; + local_0.b = pRnd->GetRandom() * 350.0 + 50.0; pGame->pParticleEngine->AddParticle(&local_0); --v3; } @@ -892,7 +846,7 @@ { __debugbreak(); // find out what kind of spells are these // when summoned light elemental attacks - + //cast spell from trees in Avlee result -= 500; switch ( result ) { @@ -1048,7 +1002,7 @@ if ( result <= 2081 ) { if ( pRenderer->pRenderD3D ) - _4A77FD_some_stuff_d3d(a2); + _4A77FD_implosion_particle(a2); else _4A80DC_some_stuff_sw(a2); return false; @@ -1399,14 +1353,8 @@ //----- (004A8BFC) -------------------------------------------------------- int stru6::_4A8BFC() { - stru6 *v1; // esi@1 - int result; // eax@1 - - v1 = this; - result = 8 - * pSpriteFrameTable->pSpriteSFrames[pSpriteFrameTable->FastFindSprite("spell84")].uAnimLength; - v1->uAnimLength = result; - return result; + uAnimLength = 8 * pSpriteFrameTable->pSpriteSFrames[pSpriteFrameTable->FastFindSprite("spell84")].uAnimLength; + return uAnimLength; } //----- (004A8C27) -------------------------------------------------------- @@ -1580,162 +1528,60 @@ //----- (004A90A0) -------------------------------------------------------- void stru6::LoadAnimations() { - stru6 *v1; // esi@1 - unsigned int v2; // eax@1 - unsigned int v3; // eax@1 - unsigned int v4; // eax@1 - unsigned int v5; // eax@1 - unsigned int v6; // eax@1 - unsigned int v7; // eax@1 - unsigned int v8; // eax@1 - unsigned int v9; // eax@1 - unsigned int v10; // eax@1 - unsigned int v11; // eax@1 - unsigned int v12; // eax@1 - unsigned int v13; // eax@1 - unsigned int v14; // eax@1 - unsigned int v15; // eax@1 - unsigned int v16; // eax@1 - unsigned int v17; // eax@1 - unsigned int v18; // eax@1 - unsigned int v19; // eax@1 - unsigned int v20; // eax@1 - unsigned int v21; // eax@1 - unsigned int v22; // eax@1 - unsigned int v23; // eax@1 - unsigned int v24; // eax@1 - unsigned int v25; // eax@1 - unsigned int v26; // eax@1 - unsigned int v27; // eax@1 - unsigned int v28; // eax@1 - unsigned int v29; // eax@1 - unsigned int v30; // eax@1 - unsigned int v31; // eax@1 - unsigned int v32; // eax@1 - unsigned int v33; // eax@1 - unsigned int v34; // eax@1 - unsigned int v35; // eax@1 - unsigned int v36; // eax@1 - unsigned int v37; // eax@1 - unsigned int v38; // eax@1 - unsigned int v39; // eax@1 - unsigned int v40; // eax@1 - unsigned int v41; // eax@1 - unsigned int v42; // eax@1 - unsigned int v43; // eax@1 - unsigned int v44; // eax@1 - unsigned int v45; // eax@1 - unsigned int v46; // eax@1 - unsigned int v47; // eax@1 - unsigned int v48; // eax@1 - unsigned int v49; // eax@1 - unsigned int v50; // eax@1 - unsigned int v51; // eax@1 - - v1 = this; uTextureID_effpar1 = pBitmaps_LOD->LoadTexture("effpar01", TEXTURE_DEFAULT); uTextureID_effpar2 = pBitmaps_LOD->LoadTexture("effpar02", TEXTURE_DEFAULT); uTextureID_effpar3 = pBitmaps_LOD->LoadTexture("effpar03", TEXTURE_DEFAULT); uSpriteID_sp57c = pSprites_LOD->LoadSprite("sp57c", 6); - v2 = pIconsFrameTable->FindIcon("zapp"); - pIconsFrameTable->InitializeAnimation(v2); - v3 = pIconsFrameTable->FindIcon("spheal1"); - pIconsFrameTable->InitializeAnimation(v3); - v4 = pIconsFrameTable->FindIcon("spheal2"); - pIconsFrameTable->InitializeAnimation(v4); - v5 = pIconsFrameTable->FindIcon("spheal3"); - pIconsFrameTable->InitializeAnimation(v5); - v6 = pIconsFrameTable->FindIcon("spboost1"); - pIconsFrameTable->InitializeAnimation(v6); - v7 = pIconsFrameTable->FindIcon("spboost2"); - pIconsFrameTable->InitializeAnimation(v7); - v8 = pIconsFrameTable->FindIcon("spboost3"); - pIconsFrameTable->InitializeAnimation(v8); - v9 = pIconsFrameTable->FindIcon("spell03"); - pIconsFrameTable->InitializeAnimation(v9); - v10 = pIconsFrameTable->FindIcon("spell05"); - pIconsFrameTable->InitializeAnimation(v10); - v11 = pIconsFrameTable->FindIcon("spell14"); - pIconsFrameTable->InitializeAnimation(v11); - v12 = pIconsFrameTable->FindIcon("spell17"); - pIconsFrameTable->InitializeAnimation(v12); - v13 = pIconsFrameTable->FindIcon("spell21"); - pIconsFrameTable->InitializeAnimation(v13); - v14 = pIconsFrameTable->FindIcon("spell25"); - pIconsFrameTable->InitializeAnimation(v14); - v15 = pIconsFrameTable->FindIcon("spell27"); - pIconsFrameTable->InitializeAnimation(v15); - v16 = pIconsFrameTable->FindIcon("spell36"); - pIconsFrameTable->InitializeAnimation(v16); - v17 = pIconsFrameTable->FindIcon("spell38"); - pIconsFrameTable->InitializeAnimation(v17); - v18 = pIconsFrameTable->FindIcon("spell46"); - pIconsFrameTable->InitializeAnimation(v18); - v19 = pIconsFrameTable->FindIcon("spell51"); - pIconsFrameTable->InitializeAnimation(v19); - v20 = pIconsFrameTable->FindIcon("spell55"); - pIconsFrameTable->InitializeAnimation(v20); - v21 = pIconsFrameTable->FindIcon("spell58"); - pIconsFrameTable->InitializeAnimation(v21); - v22 = pIconsFrameTable->FindIcon("spell69"); - pIconsFrameTable->InitializeAnimation(v22); - v23 = pIconsFrameTable->FindIcon("spell71"); - pIconsFrameTable->InitializeAnimation(v23); - v24 = pIconsFrameTable->FindIcon("spell73"); - pIconsFrameTable->InitializeAnimation(v24); - v25 = pIconsFrameTable->FindIcon("spell75"); - pIconsFrameTable->InitializeAnimation(v25); - v26 = pIconsFrameTable->FindIcon("spell96"); - pIconsFrameTable->InitializeAnimation(v26); + + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("zapp")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spheal1")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spheal2")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spheal3")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spboost1")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spboost2")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spboost3")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell03")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell05")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell14")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell17")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell21")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell25")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell27")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell36")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell38")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell46")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell51")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell55")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell58")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell69")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell71")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell73")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell75")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("spell96")); - v27 = pSpriteFrameTable->FastFindSprite("spell01"); - pSpriteFrameTable->InitializeSprite(v27); - v28 = pSpriteFrameTable->FastFindSprite("spell02"); - pSpriteFrameTable->InitializeSprite(v28); - v29 = pSpriteFrameTable->FastFindSprite("spell03"); - pSpriteFrameTable->InitializeSprite(v29); - v30 = pSpriteFrameTable->FastFindSprite("spell09"); - pSpriteFrameTable->InitializeSprite(v30); - v31 = pSpriteFrameTable->FastFindSprite("spell11"); - pSpriteFrameTable->InitializeSprite(v31); - v32 = pSpriteFrameTable->FastFindSprite("spell18"); - pSpriteFrameTable->InitializeSprite(v32); - v33 = pSpriteFrameTable->FastFindSprite("spell22"); - pSpriteFrameTable->InitializeSprite(v33); - v34 = pSpriteFrameTable->FastFindSprite("spell26"); - pSpriteFrameTable->InitializeSprite(v34); - v35 = pSpriteFrameTable->FastFindSprite("spell29"); - pSpriteFrameTable->InitializeSprite(v35); - v36 = pSpriteFrameTable->FastFindSprite("spell39"); - pSpriteFrameTable->InitializeSprite(v36); - v37 = pSpriteFrameTable->FastFindSprite("spell39c"); - pSpriteFrameTable->InitializeSprite(v37); - v38 = pSpriteFrameTable->FastFindSprite("spell41"); - pSpriteFrameTable->InitializeSprite(v38); - v39 = pSpriteFrameTable->FastFindSprite("spell57c"); - pSpriteFrameTable->InitializeSprite(v39); - v40 = pSpriteFrameTable->FastFindSprite("spell62"); - pSpriteFrameTable->InitializeSprite(v40); - v41 = pSpriteFrameTable->FastFindSprite("spell65"); - pSpriteFrameTable->InitializeSprite(v41); - v42 = pSpriteFrameTable->FastFindSprite("spell66"); - pSpriteFrameTable->InitializeSprite(v42); - v43 = pSpriteFrameTable->FastFindSprite("spell70"); - pSpriteFrameTable->InitializeSprite(v43); - v44 = pSpriteFrameTable->FastFindSprite("spell76"); - pSpriteFrameTable->InitializeSprite(v44); - v45 = pSpriteFrameTable->FastFindSprite("spell84"); - pSpriteFrameTable->InitializeSprite(v45); - v46 = pSpriteFrameTable->FastFindSprite("spell90"); - pSpriteFrameTable->InitializeSprite(v46); - v47 = pSpriteFrameTable->FastFindSprite("spell92"); - pSpriteFrameTable->InitializeSprite(v47); - v48 = pSpriteFrameTable->FastFindSprite("spell93"); - pSpriteFrameTable->InitializeSprite(v48); - v49 = pSpriteFrameTable->FastFindSprite("spell97"); - pSpriteFrameTable->InitializeSprite(v49); - v50 = pSpriteFrameTable->FastFindSprite("spell97c"); - pSpriteFrameTable->InitializeSprite(v50); - v51 = pSpriteFrameTable->FastFindSprite("spell97c"); - pSpriteFrameTable->InitializeSprite(v51); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell01")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell02")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell03")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell09")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell11")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell18")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell22")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell26")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell29")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell39")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell39c")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell41")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell57c")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell62")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell65")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell66")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell70")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell76")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell84")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell90")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell92")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell93")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell97")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell97c")); + pSpriteFrameTable->InitializeSprite(pSpriteFrameTable->FastFindSprite("spell97c")); }
--- a/stru6.h Tue Aug 06 00:52:46 2013 +0400 +++ b/stru6.h Tue Aug 06 00:56:33 2013 +0400 @@ -8,7 +8,7 @@ //----- (004775B1) -------------------------------------------------------- inline stru6_stru1_indoor_sw_billboard() { - field_10 = 0; + uNumVertices = 0; uNumVec4sInArray1 = 0; uNumVec3sInArray2 = 0; pArray1 = nullptr; @@ -24,16 +24,26 @@ bool sub_477F63(); int sub_47802A(); void Initialize(int a2); - void _47829F_fireball_collision(float arg0, float a3, float a4, float a5, int a2); + void _47829F_sphere_particle(float x_offset, float y_offset, float z_offset, float scale, int diffuse); + + struct local_01 + { + float x; + float y; + float z; + int diffuse; + }; unsigned int uNumVec4sInArray1; struct stru16x *pArray1; unsigned int uNumVec3sInArray2; struct stru160 *pArray2; - int field_10; - int field_14[40]; - float field_B4[40]; + int uNumVertices; + local_01 field_14[5]; + int field_64[20]; + float field_B4[20]; + local_01 field_104[5]; }; #pragma pack(pop) @@ -112,7 +122,7 @@ void _4A73AA_hanging_trace_particles___like_fire_strike_ice_blast_etc(struct SpriteObject *a2, unsigned int uDiffuse, unsigned int uTextureID); void _4A75CC_single_spell_collision_particle(struct SpriteObject *a1, unsigned int uDiffuse, unsigned int uTextureID); void _4A7688_fireball_collision_particle(struct SpriteObject *a2); - void _4A77FD_some_stuff_d3d(struct SpriteObject *a1); + void _4A77FD_implosion_particle(struct SpriteObject *a1); void _4A78AE_sparks_spell(struct SpriteObject *a1); void _4A7948_mind_blast_after_effect(struct SpriteObject *a1); bool AddMobileLight(struct SpriteObject *a1, unsigned int uDiffuse, int uRadius);