Mercurial > mm7
changeset 1439:468f434a8d8a
Слияние
author | Ritor1 |
---|---|
date | Mon, 22 Jul 2013 18:00:58 +0600 |
parents | bc99e1a48bea (current diff) c0b273d33338 (diff) |
children | a72236d60edc |
files | Indoor.cpp Outdoor_stuff.h Render.cpp UI/UIHouses.cpp mm7_2.cpp mm7_3.cpp stru11.h stru12.h |
diffstat | 82 files changed, 14747 insertions(+), 16188 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Actor.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -2046,17 +2046,17 @@ { if ( v1 == 6 || v1 == 7 ) { - _449B57_test_bit(pParty->_quest_bits, 99); - if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 100) ) + pParty->IsPartyGood(); //the binary file contains this call. if someone finds out whether it's supposed to be here or not, feel free to apply the appropriate change + if ( pParty->IsPartyEvil() ) return; goto LABEL_12; } if ( v1 != 8 ) goto LABEL_12; } - if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 99) ) + if ( pParty->IsPartyGood() ) v3 = 0; - if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 100) ) + if ( pParty->IsPartyEvil() ) v3 = 1; if ( v3 ) { @@ -4906,9 +4906,9 @@ v8 = 1; if ( !_stricmp(pCurrentMapName.data(), "d26.blv") ) v6 = 1; - if (_449B57_test_bit(pParty->_quest_bits, 99)) + if (pParty->IsPartyGood()) v7 = 1; - if (_449B57_test_bit(pParty->_quest_bits, 100)) + if (pParty->IsPartyEvil()) v5 = 1; Log::Warning(L"%S %S %u", __FILE__, __FUNCTION__, __LINE__); // ai_near_actors_targets_pid[i] for AI_Stand seems always 0; original code behaviour is identical @@ -5051,7 +5051,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]); @@ -5225,7 +5225,7 @@ if ( !v57 ) goto LABEL_67; LABEL_69: - if (player->Weak()) + if (player->IsWeak()) uDamageAmount /= 1; if ( (signed __int64)pMonster->pActorBuffs[5].uExpireTime > 0 ) uDamageAmount = 0; @@ -5260,7 +5260,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 Mon Jul 22 18:00:34 2013 +0600 +++ b/Arcomage.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/AudioPlayer.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -5,8 +5,6 @@ #include <string> #include <assert.h> -#include "stru11.h" - #include "mm7_data.h" #include "VideoPlayer.h" #include "AudioPlayer.h"
--- a/CShow.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/CShow.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/CShow.h Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/CastSpellInfo.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -414,7 +414,7 @@ continue; } v730 = pCastSpell->spellnum; - if (pPlayer->Cursed() && pCastSpell->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50) + if (pPlayer->IsCursed() && pCastSpell->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50) { if (!pParty->bTurnBasedModeOn) { @@ -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 || @@ -2503,7 +2503,7 @@ v726->sHealth = v726->GetMaxHealth(); if ( v726->sHealth > 0 ) { - v726->pConditions[Player::Condition_Unconcious] = 0; + v726->SetUnconcious(0); } v388 = _v733; @@ -3639,7 +3639,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
--- a/Chest.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Chest.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -228,7 +228,7 @@ word_A750E0 = 5; word_A750E2 = uActiveCharacter; } - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); dword_507CD8 = 0; return 0; } @@ -285,18 +285,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; @@ -522,7 +522,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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Conditions.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -0,0 +1,63 @@ +#pragma once +#include "Conditions.h" +#include "Party.h" +std::array<ConditionProcessor, 18> conditionArray = +{ + // hint: condname, protfrommagic, gmprot, enchantment, ... + ConditionProcessor(Condition_Cursed, false, false, 0), + ConditionProcessor(Condition_Weak, true, false, 0), + ConditionProcessor(Condition_Sleep, false, false, 22, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR), + ConditionProcessor(Condition_Fear, false, false, 0), + ConditionProcessor(Condition_Drunk, false, false, 0), + ConditionProcessor(Condition_Insane, false, false, 19, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Poison1, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Disease1, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Poison2, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Disease2, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Poison3, true, false, 21, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Disease3, true, false, 18, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK), + ConditionProcessor(Condition_Paralyzed, false, false, 20, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK, ITEM_ARTIFACT_GHOULSBANE, EQIUP_ANY), + ConditionProcessor(Condition_Unconcious,false, false, 0), + ConditionProcessor(Condition_Dead, true, true, 0), + ConditionProcessor(Condition_Pertified, true, false, 23, ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK, ITEM_RELIC_KELEBRIM, EQIUP_ANY), + ConditionProcessor(Condition_Eradicated, true, true, 0), + ConditionProcessor(Condition_Zombie, false, false, 0) +}; + +bool ConditionProcessor::IsPlayerAffected( Player* inPlayer, int condToCheck, int blockable) +{ + if ( !blockable ) + { + return true; + } + ConditionProcessor* thisProc = &conditionArray[condToCheck]; + if (thisProc->m_IsBlockedByProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0) + { + if (!(thisProc->m_DoesNeedGmProtFromMagic && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill < 4)) + { + --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; + if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) + pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); + return false; + } + } + if (thisProc->m_WorkingEnchantment != 0) + { + if (inPlayer->HasEnchantedItemEquipped(thisProc->m_WorkingEnchantment)) + return false; + } + for (unsigned int i = 0; i < thisProc->m_equipmentPairs.size() / 2; i++) + { + if (thisProc->m_equipmentPairs[i * 2].m_ItemId == (ITEM_TYPE)0) + { + return true; + } + ITEM_TYPE itemId = thisProc->m_equipmentPairs[i * 2].m_ItemId; + ITEM_EQUIP_TYPE slot = thisProc->m_equipmentPairs[i * 2 + 1].m_EquipSlot; + if (inPlayer->WearsItem(itemId, slot)) + { + return false; + } + } + return true; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Conditions.h Mon Jul 22 18:00:58 2013 +0600 @@ -0,0 +1,73 @@ +#pragma once +#include "Items.h" +#include <array> +enum Condition: unsigned __int32 +{ + Condition_Cursed = 0, + Condition_Weak = 1, + Condition_Sleep = 2, + Condition_Fear = 3, + Condition_Drunk = 4, + Condition_Insane = 5, + Condition_Poison1 = 6, + Condition_Disease1 = 7, + Condition_Poison2 = 8, + Condition_Disease2 = 9, + Condition_Poison3 = 10, + Condition_Disease3 = 11, + Condition_Paralyzed = 12, + Condition_Unconcious = 13, + Condition_Dead = 14, + Condition_Pertified = 15, + Condition_Eradicated = 16, + Condition_Zombie = 17, + Condition_Good = 18 +}; + + +class EquipemntPair +{ +public: + ITEM_TYPE m_ItemId; + ITEM_EQUIP_TYPE m_EquipSlot; + EquipemntPair(ITEM_TYPE type, ITEM_EQUIP_TYPE slot) + { + m_ItemId = type; + m_EquipSlot = slot; + } + EquipemntPair() + { + m_ItemId = (ITEM_TYPE)0; + m_EquipSlot = (ITEM_EQUIP_TYPE)0; + } +}; + +struct Player; + +class ConditionProcessor +{ +public: + bool m_IsBlockedByProtFromMagic; + bool m_DoesNeedGmProtFromMagic; + int m_WorkingEnchantment; + std::array<EquipemntPair, 3> m_equipmentPairs; + ConditionProcessor(int, bool isblocked, bool needsGm, int enchantment, + ITEM_TYPE itemtype1 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot1 = (ITEM_EQUIP_TYPE)0, + ITEM_TYPE itemtype2 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot2 = (ITEM_EQUIP_TYPE)0, + ITEM_TYPE itemtype3 = (ITEM_TYPE)0, ITEM_EQUIP_TYPE itemslot3 = (ITEM_EQUIP_TYPE)0) + { + m_IsBlockedByProtFromMagic = isblocked; + m_DoesNeedGmProtFromMagic = needsGm; + m_WorkingEnchantment = enchantment; + m_equipmentPairs[0].m_ItemId = itemtype1; + m_equipmentPairs[0].m_EquipSlot = itemslot1; + m_equipmentPairs[1].m_ItemId = itemtype2; + m_equipmentPairs[1].m_EquipSlot = itemslot2; + m_equipmentPairs[2].m_ItemId = itemtype3; + m_equipmentPairs[2].m_EquipSlot = itemslot3; + } + + static bool IsPlayerAffected(Player*, int, int); +}; + +extern std::array<ConditionProcessor, 18> conditionArray; \ No newline at end of file
--- a/DecalBuilder.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/DecalBuilder.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -522,7 +522,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 Mon Jul 22 18:00:34 2013 +0600 +++ b/DecalBuilder.h Mon Jul 22 18:00:58 2013 +0600 @@ -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/Events.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Events.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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/GUIWindow.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/GUIWindow.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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(); @@ -492,7 +492,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); @@ -872,8 +874,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 +896,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[]; @@ -1154,7 +1156,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 +1165,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 +1174,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 +1183,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 Mon Jul 22 18:00:34 2013 +0600 +++ b/GUIWindow.h Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/Game.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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" @@ -132,7 +130,7 @@ if (pRenderer->pRenderD3D) { pDecalBuilder->DrawBloodsplats(); - pGame->pLightmapBuilder->DrawLightmaps(2); + pGame->pLightmapBuilder->DrawLightmapsType(2); } } } @@ -787,7 +785,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 +941,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 +951,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 +978,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 +1000,8 @@ delete pMouseInstance; if (pParticleEngine) delete pParticleEngine; - if (pThreadWardInstance) - delete pThreadWardInstance; + //if (pThreadWardInstance) + // delete pThreadWardInstance; } //----- (0044E904) --------------------------------------------------------
--- a/Game.h Mon Jul 22 18:00:34 2013 +0600 +++ b/Game.h Mon Jul 22 18:00:58 2013 +0600 @@ -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.h Mon Jul 22 18:00:34 2013 +0600 +++ b/GammaControl.h Mon Jul 22 18:00:58 2013 +0600 @@ -1,5 +1,6 @@ #pragma once #include "lib\legacy_dx\d3d.h" +#include "OSAPI.h" #pragma pack(push, 1) class GammaController
--- a/Indoor.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Indoor.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -63,7 +63,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 +314,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 +348,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 ); } } } @@ -583,13 +584,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 +599,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 = sub_423B5D(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 +725,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; @@ -1352,25 +740,25 @@ if (v9 >= 0) return; - auto num_vertices = sub_423B5D(uFaceID); + auto num_vertices = GetPortalScreenCoord(uFaceID); if (num_vertices < 2) return; - auto face_min_screenspace_x = stru_50B700._screen_space_x[0], - face_max_screenspace_x = stru_50B700._screen_space_x[0]; - auto face_min_screenspace_y = stru_50B700._screen_space_y[0], - face_max_screenspace_y = stru_50B700._screen_space_y[0]; + auto face_min_screenspace_x = PortalFace._screen_space_x[0], + face_max_screenspace_x = PortalFace._screen_space_x[0]; + auto face_min_screenspace_y = PortalFace._screen_space_y[0], + face_max_screenspace_y = PortalFace._screen_space_y[0]; for (uint i = 1; i < num_vertices; ++i) { - if (face_min_screenspace_x > stru_50B700._screen_space_x[i]) - face_min_screenspace_x = stru_50B700._screen_space_x[i]; - if (face_max_screenspace_x < stru_50B700._screen_space_x[i]) - face_max_screenspace_x = stru_50B700._screen_space_x[i]; - - if (face_min_screenspace_y > stru_50B700._screen_space_y[i]) - face_min_screenspace_y = stru_50B700._screen_space_y[i]; - if (face_max_screenspace_y < stru_50B700._screen_space_y[i]) - face_max_screenspace_y = stru_50B700._screen_space_y[i]; + if (face_min_screenspace_x > PortalFace._screen_space_x[i]) + face_min_screenspace_x = PortalFace._screen_space_x[i]; + if (face_max_screenspace_x < PortalFace._screen_space_x[i]) + face_max_screenspace_x = PortalFace._screen_space_x[i]; + + if (face_min_screenspace_y > PortalFace._screen_space_y[i]) + face_min_screenspace_y = PortalFace._screen_space_y[i]; + if (face_max_screenspace_y < PortalFace._screen_space_y[i]) + face_max_screenspace_y = PortalFace._screen_space_y[i]; } //_screen_space_x = 719, 568, 493 //savegame: qw , 0Bh and 0x1D4h @@ -1379,7 +767,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 +869,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), @@ -1500,29 +888,29 @@ v9 = -v9; if ( v9 < 0 ) { - v10 = sub_423B5D(uFaceID); + v10 = GetPortalScreenCoord(uFaceID); v19 = v10; if ( v10 ) { - v11 = stru_50B700._screen_space_x[0]; - v12 = stru_50B700._screen_space_y[0]; - v23 = stru_50B700._screen_space_x[0]; + v11 = PortalFace._screen_space_x[0]; + v12 = PortalFace._screen_space_y[0]; + v23 = PortalFace._screen_space_x[0]; v13 = 1; - v22 = stru_50B700._screen_space_y[0]; + v22 = PortalFace._screen_space_y[0]; if ( v10 > 1 ) { do { - v14 = stru_50B700._screen_space_x[v13]; + v14 = PortalFace._screen_space_x[v13]; if ( v14 < v23 ) - v23 = stru_50B700._screen_space_x[v13]; + v23 = PortalFace._screen_space_x[v13]; if ( v14 > v11 ) - v11 = stru_50B700._screen_space_x[v13]; - v15 = stru_50B700._screen_space_y[v13]; + v11 = PortalFace._screen_space_x[v13]; + v15 = PortalFace._screen_space_y[v13]; if ( v15 < v22 ) - v22 = stru_50B700._screen_space_y[v13]; + v22 = PortalFace._screen_space_y[v13]; if ( v15 > v12 ) - v12 = stru_50B700._screen_space_y[v13]; + v12 = PortalFace._screen_space_y[v13]; v10 = v19; ++v13; } @@ -1532,7 +920,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 +975,11 @@ if ( v1 < (signed int)pIndoor->uNumFaces ) { v2 = pBspRenderer->faces[i].uFaceID; - pBLVRenderParams->field_7C = &pBspRenderer->nodes[pBspRenderer->faces[i].uNodeID].field_C; - v3 = sub_423B5D(v2); + 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; @@ -5612,9 +5000,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 +5122,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 +5134,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 +6219,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 = stru_50B700._screen_space_y[0]; - v65 = 0; - max_y = stru_50B700._screen_space_y[0]; - if ( !stru_50B700.field_0 ) + min_y = PortalFace._screen_space_y[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 ( stru_50B700._screen_space_y[v6] >= min_y ) + if (PortalFace._screen_space_y[i] < min_y) { - if ( stru_50B700._screen_space_y[v6] > max_y ) - max_y = stru_50B700._screen_space_y[v6]; + min_y_ID = i; + min_y = PortalFace._screen_space_y[i]; } - if ( stru_50B700._screen_space_y[v6] < min_y ) + else if (PortalFace._screen_space_y[i] > max_y) { - v65 = v6; - min_y = stru_50B700._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 ( stru_50B700._screen_space_y[v10] <= stru_50B700._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 ( stru_50B700._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 +6322,20 @@ } else v13 -= pNumVertices; - if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] ) + if ( PortalFace._screen_space_y[v13] != PortalFace._screen_space_y[min_y_ID2] ) { - v62 = stru_50B700._screen_space_x[v55] << 16; - v54 = ((stru_50B700._screen_space_x[v13] - stru_50B700._screen_space_x[v55]) << 16) / (stru_50B700._screen_space_y[v13] - stru_50B700._screen_space_y[v55]); - a2->viewport_left_side[min_y] = LOWORD(stru_50B700._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 +6343,15 @@ } else v15 -= pNumVertices; - if ( stru_50B700._screen_space_y[v15] <= stru_50B700._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 ( stru_50B700._screen_space_y[v15] == max_y ) + if ( PortalFace._screen_space_y[v15] == max_y ) break; } - v18 = v63 + v61; + v18 = direction1 + v61; if ( v18 < pNumVertices ) { if ( v18 < 0 ) @@ -7008,23 +6361,23 @@ v18 -= pNumVertices; v19 = v18; v20 = v61; - if ( stru_50B700._screen_space_y[v19] != stru_50B700._screen_space_y[v61] ) + if ( PortalFace._screen_space_y[v19] != PortalFace._screen_space_y[v61] ) { - v61 = stru_50B700._screen_space_x[v20] << 16; - v53 = ((stru_50B700._screen_space_x[v19] - stru_50B700._screen_space_x[v20]) << 16) / stru_50B700._screen_space_y[v19] - stru_50B700._screen_space_y[v20]; - a2->viewport_right_side[max_y] = LOWORD(stru_50B700._screen_space_x[v20]); + 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]); + 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 >= stru_50B700._screen_space_y[v13] && v22 != max_y ) + if ( v22 >= PortalFace._screen_space_y[v13] && v22 != max_y ) { - v13 = v64 + v13; + v13 = direction2 + v13; if ( v13 < pNumVertices ) { if ( v13 < 0 ) @@ -7033,17 +6386,16 @@ else v13 -= pNumVertices; v26 = v13; - //v27 = stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24]; - if ( stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24] > 0 ) + if ( PortalFace._screen_space_y[v26] - PortalFace._screen_space_y[v24] > 0 ) { - v54 = ((stru_50B700._screen_space_x[v26] - stru_50B700._screen_space_x[v24]) << 16) / stru_50B700._screen_space_y[v26] - stru_50B700._screen_space_y[v24]; - v62 = stru_50B700._screen_space_x[v24] << 16; + 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 >= stru_50B700._screen_space_y[v18] && v70 != max_y ) + if ( v70 >= PortalFace._screen_space_y[v18] && v70 != max_y ) { - v18 += v63; + v18 += direction1; if ( v18 < pNumVertices ) { if ( v18 < 0 ) @@ -7052,253 +6404,168 @@ else v18 -= pNumVertices; v31 = v18; - //v32 = stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29]; - if ( stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29] > 0 ) + if ( PortalFace._screen_space_y[v31] - PortalFace._screen_space_y[v29] > 0 ) { - v53 = ((stru_50B700._screen_space_x[v31] - stru_50B700._screen_space_x[v29]) << 16) / stru_50B700._screen_space_y[v31] - stru_50B700._screen_space_y[v29]; - v61 = stru_50B700._screen_space_x[v29] << 16; + 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; } //----- (00423B5D) -------------------------------------------------------- -int __fastcall sub_423B5D(unsigned int uFaceID) +int __fastcall GetPortalScreenCoord(unsigned int uFaceID) { BLVFace *pFace; // ebx@1 - //Vec3_short_ *v2; // esi@1 - //int v3; // ST28_4@1 - //__int16 v4; // ST2C_2@1 - //signed int v5; // esi@1 - //Vec3_short_ *v6; // eax@4 - //signed int v7; // edi@5 - //signed int bFound; // eax@5 - //signed int v9; // ecx@10 - //int v10; // eax@10 - //int v11; // edx@11 - int t; - //signed int v13; // edx@12 - //signed __int64 v14; // qtt@12 - //char *v15; // ebx@12 - //int v16; // ST28_4@14 - //signed int v17; // eax@14 - //signed __int64 v18; // qtt@14 - signed int v19; // edx@15 - signed int v20; // edx@17 - signed int v21; // ebx@19 - signed int v22; // esi@20 - int v23; // edi@21 - int v24; // eax@21 - int v25; // eax@22 - int v26; // eax@22 - signed int v27; // ST30_4@24 - signed __int64 v28; // qtt@24 - int v29; // ST18_4@25 - int v30; // eax@26 - int v31; // eax@27 - int v32; // eax@27 - signed int v33; // ST30_4@29 - signed __int64 v34; // qtt@29 - int v35; // ST30_4@30 - signed int v36; // edi@31 - unsigned int v37; // eax@31 - bool v38; // edx@31 - int v39; // ecx@31 - int v40; // ecx@32 - int v41; // esi@32 - int v42; // eax@34 - signed int v43; // ebx@41 - unsigned int v44; // eax@41 - signed int v45; // ecx@42 - int v46; // esi@42 - int v47; // eax@44 - signed int v48; // edi@51 - unsigned int v49; // eax@51 - bool v50; // edx@51 - int v51; // ecx@51 - int v52; // ecx@52 - int v53; // esi@52 - int v54; // eax@54 - int v55; // ebx@61 - unsigned int v56; // eax@61 - signed int v57; // ecx@62 - int v58; // esi@62 - int v59; // eax@64 - char v61; // zf@72 + int pNextVertices; // edx@11 + int t; // ST28_4@12 + int pScreenX; // eax@22 + int pScreenY; // eax@27 + signed int left_num_vertices; // edi@31 + signed int right_num_vertices; // ebx@41 + signed int top_num_vertices; // edi@51 + int bottom_num_vertices; // ebx@61 signed int v62; // edx@75 int v63; // ecx@76 int v64; // esi@76 int v65; // ecx@83 - //signed int v66; // [sp+14h] [bp-14h]@3 - int v67; // [sp+14h] [bp-14h]@34 - int v68; // [sp+14h] [bp-14h]@44 - int v69; // [sp+14h] [bp-14h]@54 - int v70; // [sp+14h] [bp-14h]@64 signed int v71; // [sp+14h] [bp-14h]@75 - //IndoorCameraD3D *_this; // [sp+18h] [bp-10h]@1 bool current_vertices_flag; // [sp+18h] [bp-10h]@9 - int thisb; // [sp+18h] [bp-10h]@12 - int thisc; // [sp+18h] [bp-10h]@20 - bool thisd; // [sp+18h] [bp-10h]@41 - bool thise; // [sp+18h] [bp-10h]@61 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 - bool v82; // [sp+20h] [bp-8h]@32 - bool v83; // [sp+20h] [bp-8h]@42 - bool v84; // [sp+20h] [bp-8h]@52 - bool v85; // [sp+20h] [bp-8h]@62 - //signed int v86; // [sp+24h] [bp-4h]@9 - signed int v87; // [sp+24h] [bp-4h]@19 - signed int v88; // [sp+24h] [bp-4h]@31 - signed int v89; // [sp+24h] [bp-4h]@41 - signed int v90; // [sp+24h] [bp-4h]@51 - signed int v91; // [sp+24h] [bp-4h]@61 pFace = &pIndoor->pFaces[uFaceID]; - memset(&stru_50B700, 0, sizeof(stru367)); - //_this = pGame->pIndoorCameraD3D; - //v2 = &pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]]; - //v3 = *(_DWORD *)pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].x; - //v4 = pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].z; - //v5 = 0; + memset(&PortalFace, 0, sizeof(stru367)); + + //get direction the face( )********************************************************************************* if ( pFace->pFacePlane_old.vNormal.x * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].x - pBLVRenderParams->vPartyPos.x) + pFace->pFacePlane_old.vNormal.y * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].y - pBLVRenderParams->vPartyPos.y) + pFace->pFacePlane_old.vNormal.z * (pIndoor->pVertices[pIndoor->pFaces[uFaceID].pVertexIDs[0]].z - pBLVRenderParams->vPartyPos.z) < 0 ) { - stru_50B700.field_0 = 1; + PortalFace.direction = true; } else { - stru_50B700.field_0 = 0; + PortalFace.direction = false; if ( !(pFace->Portal()) ) return 0; } - //v66 = pFace->uNumVertices; + //***************************************************************************************************************************************** + //generate/cinvertetion in camera location coordinates(/ ) + + //for new coordinates: + //int x = 0x AAAA BBBB; + //AAAA - integer( ), BBBB - fractional() + //float v = HIWORD(x) + LOWORD(x) / 65535.0f; + //0x0351A281 849(351 ) A281 ( BBBB ) + //if in HIWORD: FFFF = -1 + //FFFE = -2 + //FFFD = -3 + //.... + //8000 = -32767 + //7FFF = 32767 + //7FFE = 32766 + // LOWORD FFFF , + // hiword loword FFFF FFFF , + // 7FFF /Nomad/ + if ( (signed int)pFace->uNumVertices > 0 ) { for (uint i = 0; i < pFace->uNumVertices; ++i) { - //v6 = &pIndoor->pVertices[pFace->pVertexIDs[v5]]; - pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible( - pIndoor->pVertices[pFace->pVertexIDs[i]].x, - pIndoor->pVertices[pFace->pVertexIDs[i]].y, - pIndoor->pVertices[pFace->pVertexIDs[i]].z, - &stru_50B700._view_transformed_xs[i + 3], - &stru_50B700._view_transformed_zs[i + 3], - &stru_50B700._view_transformed_ys[i + 3], - 0); + pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(pIndoor->pVertices[pFace->pVertexIDs[i]].x, + pIndoor->pVertices[pFace->pVertexIDs[i]].y, + pIndoor->pVertices[pFace->pVertexIDs[i]].z, + &PortalFace._view_transformed_z[i + 3], &PortalFace._view_transformed_x[i + 3], &PortalFace._view_transformed_y[i + 3], 0); } } - //v7 = pFace->uNumVertices; + //***************************************************************************************************************************************** + //check vertices for the nearest plane( ) if ( pFace->uNumVertices <= 0 ) return 0; bool bFound = false; for (uint i = 0; i < pFace->uNumVertices; ++i) { - if ( stru_50B700._view_transformed_xs[i + 3] >= 524288 ) + if ( PortalFace._view_transformed_z[i + 3] >= 524288 )// 8.0(0x80000) { bFound = true; break; @@ -7306,338 +6573,299 @@ } if ( !bFound ) return 0; - + //***************************************************************************************************************************************** + //check for near clip plane( ) + // + // v0 v1 + // ._________________. + // / \ + // / \ + // v5. . v2 + // | | + // | | + // | | + // ---------------------------- 8.0(near_clip) + // | | + // ._______________________. + // v4 v3 depth_num_vertices = 0; - stru_50B700._view_transformed_xs[pFace->uNumVertices + 3] = stru_50B700._view_transformed_xs[3]; - stru_50B700._view_transformed_zs[pFace->uNumVertices + 3] = stru_50B700._view_transformed_zs[3]; - stru_50B700._view_transformed_ys[pFace->uNumVertices + 3] = stru_50B700._view_transformed_ys[3]; - current_vertices_flag = stru_50B700._view_transformed_xs[3] >= 524288; - //v86 = 1; + PortalFace._view_transformed_z[pFace->uNumVertices + 3] = PortalFace._view_transformed_z[3]; + PortalFace._view_transformed_x[pFace->uNumVertices + 3] = PortalFace._view_transformed_x[3]; + PortalFace._view_transformed_y[pFace->uNumVertices + 3] = PortalFace._view_transformed_y[3]; + current_vertices_flag = PortalFace._view_transformed_z[3] >= 524288;// 8.0(0x80000) if ( pFace->uNumVertices >= 1 ) { for ( uint i = 1; i <= pFace->uNumVertices; ++i) { - //v9 = v86; - //v10 = stru_50B700._view_transformed_xs[v86 + 3]; - next_vertices_flag = stru_50B700._view_transformed_xs[i + 3] >= 524288; - if ( current_vertices_flag ^ next_vertices_flag ) + next_vertices_flag = PortalFace._view_transformed_z[i + 3] >= 524288;// 8.0(0x80000) + if ( current_vertices_flag ^ next_vertices_flag )// { - //v11 = stru_50B700._view_transformed_xs[i + 2]; - if ( next_vertices_flag ) + if ( next_vertices_flag )// { - //t = near_clip - v0.z/v1.z - v0.z - // near_clip = 8.0(524288) - t = 524288 - stru_50B700._view_transformed_xs[i + 2] / stru_50B700._view_transformed_xs[i + 3] - stru_50B700._view_transformed_xs[i + 2]; - // new_x = (v1.x - v0.x) * t + v0.x - stru_50B700._view_transformed_zs[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_zs[i + 3] - - stru_50B700._view_transformed_zs[i + 2]) * t + stru_50B700._view_transformed_zs[i + 2]; - //new_y = (v1.y - v0.y)*t + v0.y - stru_50B700._view_transformed_ys[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_ys[i + 3] - stru_50B700._view_transformed_ys[i + 2]) - * t + stru_50B700._view_transformed_ys[i + 2]; - stru_50B700._view_transformed_xs[depth_num_vertices] = 524288; + //t = near_clip - v0.z / v1.z - v0.z + 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]; + //New_y = (v1.y - v0.y)*t + v0.y + PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 3] - PortalFace._view_transformed_y[i + 2]) + * t) >> 16) + PortalFace._view_transformed_y[i + 2]; + //New_z = 8.0(0x80000) + PortalFace._view_transformed_z[depth_num_vertices] = 524288; } - else + else// { - //t = near_clip - v1.z/v0.z - v1.z - t = 524288 - stru_50B700._view_transformed_xs[i + 3] / stru_50B700._view_transformed_xs[i + 2] - stru_50B700._view_transformed_xs[i + 3]; - // new_x = (v0.x - v1.x) * t + v1.x - stru_50B700._view_transformed_zs[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_zs[i + 2] - - stru_50B700._view_transformed_zs[i + 3]) * t + stru_50B700._view_transformed_zs[i + 3]; - //new_y = (v0.y - v1.y)*t + v1.y - stru_50B700._view_transformed_ys[depth_num_vertices] = (unsigned __int64)(stru_50B700._view_transformed_ys[i + 2] - stru_50B700._view_transformed_ys[i + 3]) - * t + stru_50B700._view_transformed_ys[i + 3]; - stru_50B700._view_transformed_xs[depth_num_vertices] = 524288; + //t = near_clip - v1.z / v0.z - v1.z + 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]; + //New_y = (v0.x - v1.y)*t + v1.y + PortalFace._view_transformed_y[depth_num_vertices] = ((unsigned __int64)((PortalFace._view_transformed_y[i + 2] - PortalFace._view_transformed_y[i + 3]) + * t) >> 16) + PortalFace._view_transformed_y[i + 3]; + //New_z = 8.0(0x80000) + PortalFace._view_transformed_z[depth_num_vertices] = 524288; } - v19 = depth_num_vertices++; - //v7 = pFace->uNumVertices; - //stru_50B700._view_transformed_ys[v19] = thisb + *(_DWORD *)v15; - //stru_50B700._view_transformed_xs[v19] = 524288; + depth_num_vertices++; } - if ( next_vertices_flag ) + if ( next_vertices_flag )// { - v20 = depth_num_vertices++; - stru_50B700._view_transformed_xs[v20] = stru_50B700._view_transformed_xs[i + 3]; - stru_50B700._view_transformed_zs[v20] = stru_50B700._view_transformed_zs[i + 3]; - stru_50B700._view_transformed_ys[v20] = stru_50B700._view_transformed_ys[i + 3]; + pNextVertices = depth_num_vertices++; + PortalFace._view_transformed_z[pNextVertices] = PortalFace._view_transformed_z[i + 3]; + PortalFace._view_transformed_x[pNextVertices] = PortalFace._view_transformed_x[i + 3]; + PortalFace._view_transformed_y[pNextVertices] = PortalFace._view_transformed_y[i + 3]; } current_vertices_flag = next_vertices_flag; } } - - - v21 = depth_num_vertices; - stru_50B700._view_transformed_xs[depth_num_vertices] = stru_50B700._view_transformed_xs[0]; - stru_50B700._view_transformed_zs[depth_num_vertices] = stru_50B700._view_transformed_zs[0]; - stru_50B700._view_transformed_ys[depth_num_vertices] = stru_50B700._view_transformed_ys[0]; - for ( v87 = 0; v87 < depth_num_vertices; ++v87 ) + //: ( ) + //************************************************************************************************************************************ + //convertion in screen coordinates( ) + PortalFace._view_transformed_z[depth_num_vertices] = PortalFace._view_transformed_z[0]; + PortalFace._view_transformed_x[depth_num_vertices] = PortalFace._view_transformed_x[0]; + PortalFace._view_transformed_y[depth_num_vertices] = PortalFace._view_transformed_y[0]; + for ( uint i = 0; i < depth_num_vertices; ++i ) { - v22 = v87; - thisc = abs(stru_50B700._view_transformed_xs[v87]); - if ( (abs(stru_50B700._view_transformed_zs[v87]) >> 13) <= thisc ) - { - v27 = stru_50B700._view_transformed_zs[v22]; - LODWORD(v28) = v27 << 16; - HIDWORD(v28) = v27 >> 16; - v26 = v28 / stru_50B700._view_transformed_xs[v22]; - v23 = 0; - } + if ( (abs(PortalFace._view_transformed_x[i]) >> 13) <= abs(PortalFace._view_transformed_z[i]) ) + pScreenX = fixpoint_div(PortalFace._view_transformed_x[i], PortalFace._view_transformed_z[i]); else { - v23 = 0; - v24 = 0; - if ( stru_50B700._view_transformed_zs[v22] >= 0 ) + if ( PortalFace._view_transformed_x[i] >= 0 ) { - //LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; - //v26 = ((v24 - 1) & 0xFF800000) + 4194304; - if (stru_50B700._view_transformed_xs[v22] >= 0) - v26 = 0x400000; // 64.0 + if (PortalFace._view_transformed_z[i] >= 0) + pScreenX = 0x400000; // 64.0 else - v26 = 0xFFC00000; + pScreenX = 0xFFC00000; // -63.0 } else { - //LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; - //v25 = v24 - 1; - //v26 = (v25 & 0x800000) - 4194304; - if (stru_50B700._view_transformed_xs[v22] >= 0) - v26 = 0xFFC00000; // -63.0 + if (PortalFace._view_transformed_z[i] >= 0) + pScreenX = 0xFFC00000; // -63.0 else - v26 = 0x400000; + pScreenX = 0x400000; // 64.0 } } - v29 = stru_50B700._view_transformed_ys[v22]; - stru_50B700._screen_space_x[v22 + 12] = v26; - if ( (abs(v29) >> 13) <= thisc ) - { - v33 = stru_50B700._view_transformed_ys[v22]; - LODWORD(v34) = v33 << 16; - HIDWORD(v34) = v33 >> 16; - v32 = v34 / stru_50B700._view_transformed_xs[v22]; - } + if ( (abs(PortalFace._view_transformed_y[i]) >> 13) <= abs(PortalFace._view_transformed_z[i]) ) + pScreenY = fixpoint_div(PortalFace._view_transformed_y[i], PortalFace._view_transformed_z[i]); else { - v30 = 0; - if ( stru_50B700._view_transformed_ys[v22] >= v23 ) + if ( PortalFace._view_transformed_y[i] >= 0 ) { - //LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; - //v32 = ((v30 - 1) & 0xFF800000) + 4194304; - if (stru_50B700._view_transformed_xs[v22] >= v23) - v32 = 0x400000; // 64.0 + if (PortalFace._view_transformed_z[i] >= 0) + pScreenY = 0x400000; // 64.0 else - v32 = 0xFFC00000; + pScreenY = 0xFFC00000; // -63.0 } else { - //LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; - //v31 = v30 - 1; - //v32 = (v31 & 0x800000) - 4194304; - if (stru_50B700._view_transformed_xs[v22] >= v23) - v32 = 0xFFC00000; // -63.0 + if (PortalFace._view_transformed_z[i] >= 0) + pScreenY = 0xFFC00000; // -63.0 else - v32 = 0x400000; + pScreenY = 0x400000; // 64.0 } } - stru_50B700._screen_space_y[v22 + 12] = v32; - stru_50B700._screen_space_x[v22 + 12] = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) - * (signed __int64)stru_50B700._screen_space_x[v22 + 12]) >> 16; - v35 = (unsigned __int64)(SHIWORD(pBLVRenderParams->field_40) * (signed __int64)stru_50B700._screen_space_y[v22 + 12]) >> 16; - stru_50B700._screen_space_x[v22 + 12] = pBLVRenderParams->uViewportCenterX - stru_50B700._screen_space_x[v22 + 12]; - stru_50B700._screen_space_y[v22 + 12] = pBLVRenderParams->uViewportCenterY - v35; - //++v87; + 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); } - v36 = 0; - stru_50B700._screen_space_x[v21 + 12] = stru_50B700._screen_space_x[12]; - stru_50B700._screen_space_y[v21 + 12] = stru_50B700._screen_space_y[12]; - v37 = pBLVRenderParams->uViewportX; - v38 = stru_50B700._screen_space_x[12] < (signed int)pBLVRenderParams->uViewportX; - LOBYTE(v38) = stru_50B700._screen_space_x[12] >= (signed int)pBLVRenderParams->uViewportX; - v39 = 1; - v88 = 1; + // : , , () + //****************************************************************************************************************************************** + // - ,.. + // . , 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;//8.0 if ( depth_num_vertices < 1 ) return 0; - do + for ( uint i = 1; i <= depth_num_vertices; ++i ) { - v40 = v39; - v41 = stru_50B700._screen_space_x[v40 + 12]; - v82 = v41 >= (signed int)v37; - if ( v38 ^ v82 ) + next_vertices_flag = PortalFace._screen_space_x[i + 12] >= (signed int)pBLVRenderParams->uViewportX; + if ( current_vertices_flag ^ next_vertices_flag ) { - if ( v41 >= (signed int)v37 ) + if ( next_vertices_flag ) { - v67 = (signed int)(v37 - stru_50B700._screen_space_x[v40 + 11]) - * (signed __int64)(stru_50B700._screen_space_y[v40 + 12] - stru_50B700._screen_space_y[v40 + 11]) - / (v41 - stru_50B700._screen_space_x[v40 + 11]); - v42 = stru_50B700._screen_space_y[v40 + 11]; + //t = left_clip - v0.x / v1.x - v0.x + 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) >> 16) + PortalFace._screen_space_y[i + 11]; + //New_x = left_clip + PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; } else { - v67 = (signed int)(v37 - v41) - * (signed __int64)(stru_50B700._screen_space_y[v40 + 11] - stru_50B700._screen_space_y[v40 + 12]) - / (stru_50B700._screen_space_x[v40 + 11] - v41); - v42 = stru_50B700._screen_space_y[v40 + 12]; + //t = left_clip - v1.x / v0.x - v1.x + 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) >> 16) + PortalFace._screen_space_y[i + 12]; + //New_x = left_clip + PortalFace._screen_space_x[left_num_vertices + 9] = pBLVRenderParams->uViewportX; } - ++v36; - stru_50B700._screen_space_y[v36 + 8] = v67 + v42; - v37 = pBLVRenderParams->uViewportX; - stru_50B700._screen_space_x[v36 + 8] = pBLVRenderParams->uViewportX; + left_num_vertices++; } - v38 = v82; - if ( v82 ) + if ( next_vertices_flag ) { - stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[v40 + 12]; - stru_50B700._screen_space_y[v36++ + 9] = stru_50B700._screen_space_y[v40 + 12]; + pNextVertices = left_num_vertices++; + PortalFace._screen_space_x[pNextVertices + 9] = PortalFace._screen_space_x[i + 12]; + PortalFace._screen_space_y[pNextVertices + 9] = PortalFace._screen_space_y[i + 12]; } - v39 = v88++ + 1; + current_vertices_flag = next_vertices_flag; } - while ( v88 <= depth_num_vertices ); - if ( !v36 - || (v43 = 0, - stru_50B700._screen_space_x[v36 + 9] = stru_50B700._screen_space_x[9], - stru_50B700._screen_space_y[v36 + 9] = stru_50B700._screen_space_y[9], - v44 = pBLVRenderParams->uViewportZ, - thisd = stru_50B700._screen_space_x[9] <= (signed int)pBLVRenderParams->uViewportZ, - v89 = 1, - v36 < 1) ) +//********************************************************************************************************************************* +//for right_clip plane( ) + 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;//468.0 + if (left_num_vertices < 1) return 0; - do + for ( uint i = 1; i <= left_num_vertices; ++i ) { - v45 = v89; - v46 = stru_50B700._screen_space_x[v89 + 9]; - v83 = v46 <= (signed int)v44; - if ( thisd ^ v83 ) + next_vertices_flag = PortalFace._screen_space_x[i + 9] <= (signed int)pBLVRenderParams->uViewportZ; + if ( current_vertices_flag ^ next_vertices_flag ) { - if ( v46 <= (signed int)v44 ) + if ( next_vertices_flag ) { - v68 = (signed int)(v44 - stru_50B700._screen_space_x[v45 + 8]) - * (signed __int64)(stru_50B700._screen_space_y[v45 + 9] - stru_50B700._screen_space_y[v45 + 8]) - / (v46 - stru_50B700._screen_space_x[v45 + 8]); - v47 = stru_50B700._screen_space_y[v45 + 8]; + //t = right_clip - v1.x / v0.x - v1.x + 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 + 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 { - v68 = (signed int)(v44 - v46) - * (signed __int64)(stru_50B700._screen_space_y[v45 + 8] - stru_50B700._screen_space_y[v45 + 9]) - / (stru_50B700._screen_space_x[v45 + 8] - v46); - v47 = stru_50B700._screen_space_y[v45 + 9]; + //t = right_clip - v0.x / v1.x - v0.x + 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 + 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; } - ++v43; - stru_50B700._screen_space_y[v43 + 5] = v68 + v47; - v44 = pBLVRenderParams->uViewportZ; - stru_50B700._screen_space_x[v43 + 5] = pBLVRenderParams->uViewportZ; + right_num_vertices++; } - if ( v83 ) + if ( next_vertices_flag ) { - stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[v45 + 9]; - stru_50B700._screen_space_y[v43++ + 6] = stru_50B700._screen_space_y[v45 + 9]; + pNextVertices = right_num_vertices++; + PortalFace._screen_space_x[pNextVertices + 6] = PortalFace._screen_space_x[i + 9]; + PortalFace._screen_space_y[pNextVertices + 6] = PortalFace._screen_space_y[i + 9]; } - ++v89; - thisd = v83; + current_vertices_flag = next_vertices_flag; } - while ( v89 <= v36 ); - if ( !v43 - || (v48 = 0, - stru_50B700._screen_space_x[v43 + 6] = stru_50B700._screen_space_x[6], - stru_50B700._screen_space_y[v43 + 6] = stru_50B700._screen_space_y[6], - v49 = pBLVRenderParams->uViewportY, - v50 = stru_50B700._screen_space_y[6] < (signed int)pBLVRenderParams->uViewportY, - LOBYTE(v50) = stru_50B700._screen_space_y[6] >= (signed int)pBLVRenderParams->uViewportY, - v51 = 1, - v90 = 1, - v43 < 1) ) + //************************************************************************************************************************************ + // for top clip plane + top_num_vertices = 0; + 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;//8.0 + if ( right_num_vertices < 1 ) return 0; - do + for ( uint i = 1; i <= right_num_vertices; ++i ) { - v52 = v51; - v53 = stru_50B700._screen_space_y[v52 + 6]; - v84 = v53 >= (signed int)v49; - if ( v50 ^ v84 ) + next_vertices_flag = PortalFace._screen_space_y[i + 6] >= (signed int)pBLVRenderParams->uViewportY; + if ( current_vertices_flag ^ next_vertices_flag ) { - if ( v53 >= (signed int)v49 ) + if ( next_vertices_flag ) { - v69 = (signed int)(v49 - stru_50B700._screen_space_y[v52 + 5]) - * (signed __int64)(stru_50B700._screen_space_x[v52 + 6] - stru_50B700._screen_space_x[v52 + 5]) - / (v53 - stru_50B700._screen_space_y[v52 + 5]); - v54 = stru_50B700._screen_space_x[v52 + 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 { - v69 = (signed int)(v49 - v53) - * (signed __int64)(stru_50B700._screen_space_x[v52 + 5] - stru_50B700._screen_space_x[v52 + 6]) - / (stru_50B700._screen_space_y[v52 + 5] - v53); - v54 = stru_50B700._screen_space_x[v52 + 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; } - ++v48; - stru_50B700._screen_space_x[v48 + 2] = v69 + v54; - v49 = pBLVRenderParams->uViewportY; - stru_50B700._screen_space_y[v48 + 2] = pBLVRenderParams->uViewportY; + top_num_vertices++; } - v50 = v84; - if ( v84 ) + current_vertices_flag = next_vertices_flag; + if ( next_vertices_flag ) { - stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[v52 + 6]; - stru_50B700._screen_space_y[v48++ + 3] = stru_50B700._screen_space_y[v52 + 6]; + pNextVertices = top_num_vertices++; + PortalFace._screen_space_x[pNextVertices + 3] = PortalFace._screen_space_x[i + 6]; + PortalFace._screen_space_y[pNextVertices + 3] = PortalFace._screen_space_y[i + 6]; } - v51 = v90++ + 1; } - while ( v90 <= v43 ); - if ( !v48 - || (v55 = 0, - stru_50B700._screen_space_x[v48 + 3] = stru_50B700._screen_space_x[3], - stru_50B700._screen_space_y[v48 + 3] = stru_50B700._screen_space_y[3], - v56 = pBLVRenderParams->uViewportW, - thise = stru_50B700._screen_space_y[3] <= (signed int)pBLVRenderParams->uViewportW, - v91 = 1, - v48 < 1) ) +//********************************************************************************************************************************** +//for bottom_clip plane( ) + 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;//351.0 + if ( top_num_vertices < 1 ) return 0; - do + for ( uint i =1; i <= top_num_vertices; ++i ) { - v57 = v91; - v58 = stru_50B700._screen_space_y[v91 + 3]; - v85 = v58 <= (signed int)v56; - if ( thise ^ v85 ) + next_vertices_flag = PortalFace._screen_space_y[i + 3] <= (signed int)pBLVRenderParams->uViewportW; + if ( current_vertices_flag ^ next_vertices_flag ) { - if ( v58 <= (signed int)v56 ) + if ( next_vertices_flag ) { - v70 = (signed int)(v56 - stru_50B700._screen_space_y[v57 + 2]) - * (signed __int64)(stru_50B700._screen_space_x[v57 + 3] - stru_50B700._screen_space_x[v57 + 2]) - / (v58 - stru_50B700._screen_space_y[v57 + 2]); - v59 = stru_50B700._screen_space_x[v57 + 2]; + 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 { - v70 = (signed int)(v56 - v58) - * (signed __int64)(stru_50B700._screen_space_x[v57 + 2] - stru_50B700._screen_space_x[v57 + 3]) - / (stru_50B700._screen_space_y[v57 + 2] - v58); - v59 = stru_50B700._screen_space_x[v57 + 3]; + 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; } - ++v55; - //stru_50B700._screen_space_y[v55 + 59] = v70 + v59; - stru_50B700._screen_space_x[v55 - 1] = v70 + v59; - v56 = pBLVRenderParams->uViewportW; - //stru_50B700._view_transformed_xs[v55 + 47] = pBLVRenderParams->uViewportW; - stru_50B700._screen_space_y[v55 - 1] = pBLVRenderParams->uViewportW; + bottom_num_vertices++; } - if ( v85 ) + if ( next_vertices_flag ) { - stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[v57 + 3]; - stru_50B700._screen_space_y[v55++] = stru_50B700._screen_space_y[v57 + 3]; + pNextVertices = bottom_num_vertices++; + PortalFace._screen_space_x[pNextVertices] = PortalFace._screen_space_x[i + 3]; + PortalFace._screen_space_y[pNextVertices] = PortalFace._screen_space_y[i + 3]; } - ++v91; - thise = v85; + current_vertices_flag = next_vertices_flag; } - while ( v91 <= v48 ); - if ( !v55 ) +//*************************************************************************************************************************************** + + if ( !bottom_num_vertices ) return 0; - v61 = pRenderer->pRenderD3D == 0; - stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0]; - stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0]; - if ( v61 && v55 > 3 ) + PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0]; + PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; +//check for software( ) + if ( !pRenderer->pRenderD3D && bottom_num_vertices > 3 ) { - stru_50B700._screen_space_x[v55 + 1] = stru_50B700._screen_space_x[1]; - stru_50B700._screen_space_y[v55 + 1] = stru_50B700._screen_space_y[1]; - thisf = 2 * (stru_50B700.field_0 != 0) - 1; - if ( v55 > 0 ) + PortalFace._screen_space_x[bottom_num_vertices + 1] = PortalFace._screen_space_x[1]; + PortalFace._screen_space_y[bottom_num_vertices + 1] = PortalFace._screen_space_y[1]; + thisf = PortalFace.direction == true ? 1 : - 1; + if ( bottom_num_vertices > 0 ) { v62 = 1; v71 = 1; @@ -7646,17 +6874,16 @@ v63 = v62 - 1; v64 = v62 + 1; v80 = v62 + 1; - if ( v62 - 1 >= v55 ) - v63 -= v55; - if ( v62 >= v55 ) - v62 -= v55; - if ( v64 >= v55 ) - v64 -= v55; - if ( thisf - * ((stru_50B700._screen_space_y[v64] - stru_50B700._screen_space_y[v63]) - * (stru_50B700._screen_space_x[v62] - stru_50B700._screen_space_x[v63]) - - (stru_50B700._screen_space_y[v62] - stru_50B700._screen_space_y[v63]) - * (stru_50B700._screen_space_x[v64] - stru_50B700._screen_space_x[v63])) < 0 ) + if ( v62 - 1 >= bottom_num_vertices ) + v63 -= bottom_num_vertices; + if ( v62 >= bottom_num_vertices ) + v62 -= bottom_num_vertices; + if ( v64 >= bottom_num_vertices ) + v64 -= bottom_num_vertices; + if ( thisf * ((PortalFace._screen_space_y[v64] - PortalFace._screen_space_y[v63]) + * (PortalFace._screen_space_x[v62] - PortalFace._screen_space_x[v63]) + - (PortalFace._screen_space_y[v62] - PortalFace._screen_space_y[v63]) + * (PortalFace._screen_space_x[v64] - PortalFace._screen_space_x[v63])) < 0 ) { v62 = v80; v71 = v80; @@ -7665,24 +6892,20 @@ { v62 = v71; v65 = v71; - if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) ) + if ( v71 < bottom_num_vertices || (v65 = v71 - bottom_num_vertices, v71 - bottom_num_vertices < bottom_num_vertices) ) { - memcpy( - &stru_50B700._screen_space_y[v65], - &stru_50B700._screen_space_y[v65 + 1], - 4 * ((unsigned int)(4 * (v55 - v65)) >> 2)); - memcpy( - &stru_50B700._screen_space_x[v65], - &stru_50B700._screen_space_x[v65 + 1], - 4 * ((unsigned int)(4 * (v55 - v65)) >> 2)); + memcpy(&PortalFace._screen_space_y[v65], &PortalFace._screen_space_y[v65 + 1], + 4 * ((unsigned int)(4 * (bottom_num_vertices - v65)) >> 2)); + memcpy(&PortalFace._screen_space_x[v65], &PortalFace._screen_space_x[v65 + 1], + 4 * ((unsigned int)(4 * (bottom_num_vertices - v65)) >> 2)); } - --v55; + --bottom_num_vertices; } } - while ( v62 - 1 < v55 ); + while ( v62 - 1 < bottom_num_vertices ); } - stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0]; - stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0]; + PortalFace._screen_space_x[bottom_num_vertices] = PortalFace._screen_space_x[0]; + PortalFace._screen_space_y[bottom_num_vertices] = PortalFace._screen_space_y[0]; } - return v55; + return bottom_num_vertices; } \ No newline at end of file
--- a/Indoor.h Mon Jul 22 18:00:34 2013 +0600 +++ b/Indoor.h Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/IndoorCameraD3D.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/IndoorCameraD3D.h Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/Indoor_stuff.h Mon Jul 22 18:00:58 2013 +0600 @@ -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
--- a/Items.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Items.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -1481,7 +1481,7 @@ return item__getname_buffer.data(); } sprintf(item__getname_buffer.data(), "%s", pItemsTable->pItems[uItemID].pName); - if ( uItemID == ITEM_LICH_JAR ) //Lich Jar + if ( uItemID == ITEM_LICH_JAR_FULL ) //Lich Jar { if ( (uHolderPlayer >0 )&& (uHolderPlayer <= 4) ) {
--- a/Items.h Mon Jul 22 18:00:34 2013 +0600 +++ b/Items.h Mon Jul 22 18:00:58 2013 +0600 @@ -86,25 +86,34 @@ ITEM_ARTIFACT_GHOULSBANE = 507,//1FA ITEM_ARTEFACT_ULLYSES =510, ITEM_ARTIFACT_LEAGUE_BOOTS = 512,//200 + ITEM_RELIC_ETHRICS_STAFF = 515,//204 ITEM_RELIC_HARECS_LEATHER = 516,//204 + ITEM_RELIC_OLD_NICK = 517,//204 ITEM_RELIC_KELEBRIM = 520,//208 ITEM_RELIC_TALEDONS_HELM = 521,//209 ITEM_RELIC_SCHOLARS_CAP = 522,//20A ITEM_RELIC_PHYNAXIAN_CROWN = 523,//20B ITEM_RILIC_TITANS_BELT = 524,//20C ITEM_RELIC_TWILIGHT = 525,//20D - ITEM_RELIC_MEKORIGS_HAMMER = 0x210, + ITEM_RELIC_JUSTICE = 527, + ITEM_RELIC_MEKORIGS_HAMMER = 528, ITEM_ARTIFACT_HERMES_SANDALS = 529, ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP = 530,//212 + ITEM_ARTIFACT_ELFBANE = 531,//212 ITEM_ARTIFACT_MINDS_EYE = 532,//214 ITEM_ELVEN_CHAINMAIL = 533,//215 + ITEM_FORGE_GAUNTLETS = 534, ITEM_ARTIFACT_HEROS_BELT = 535,//217 ITEM_ARTIFACT_LADYS_ESCORT = 536, ITEM_RARE_SHADOWS_MASK = 544,//220 ITEM_RARE_SUN_CLOAK = 547,//223 ITEM_RARE_MOON_CLOAK = 548,//224 ITEM_RARE_VAMPIRES_CAPE = 550,//226 - ITEM_LICH_JAR = 601 + 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 Mon Jul 22 18:00:34 2013 +0600 +++ b/LOD.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/LOD.h Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/LightmapBuilder.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -1,3 +1,5 @@ +#include <assert.h> + #include "LightmapBuilder.h" #include "Game.h" #include "stru314.h" @@ -1311,22 +1313,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, @@ -1575,16 +1577,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 +1596,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 +1613,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 +1686,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 +1777,7 @@ } //----- (0045DCA9) -------------------------------------------------------- -void LightmapBuilder::DoDrawLightmaps() +void LightmapBuilder::Draw_183808_Lightmaps() { if (!std__vector_183808_size) return; @@ -1815,7 +1796,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 Mon Jul 22 18:00:34 2013 +0600 +++ b/LightmapBuilder.h Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/Mouse.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -12,7 +12,6 @@ #include "LOD.h" #include "Game.h" -#include "stru11.h" #include "TurnEngine.h" #include "Viewport.h" #include "GUIWindow.h"
--- a/Mouse.h Mon Jul 22 18:00:34 2013 +0600 +++ b/Mouse.h Mon Jul 22 18:00:58 2013 +0600 @@ -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/OSAPI.h Mon Jul 22 18:00:34 2013 +0600 +++ b/OSAPI.h Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/Outdoor.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -36,6 +36,7 @@ #include "MapInfo.h" #include "OutdoorCamera.h" +#include "Outdoor_stuff.h" #include "BSPModel.h" #include "GUIWindow.h" @@ -46,7 +47,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 +107,7 @@ pIndoorCamera->pos.z = pParty->vPosition.z + pParty->sEyelevel; if (bRedraw || pRenderer->pRenderD3D) { - ResetStru148s(); + ResetPolygons(); pOutdoorCamera->RotationToInts(); sub_481ED9_MessWithOutdoorCamera(); } @@ -125,43 +126,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 +181,7 @@ pRenderer->DrawSpriteObjects_ODM(); pRenderer->TransformBillboardsAndSetPalettesODM(); - sub_485F53((Vec2_int_ *)unnamed_6BE060.data()); + //sr_485F53((Vec2_int_ *)sr_6BE060.data()); } @@ -695,9 +689,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
--- a/Outdoor.h Mon Jul 22 18:00:34 2013 +0600 +++ b/Outdoor.h Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/OutdoorCamera.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/OutdoorCamera.h Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/Outdoor_stuff.h Mon Jul 22 18:00:58 2013 +0600 @@ -6,17 +6,18 @@ /* 141 */ +// stru148 #pragma pack(push, 1) -struct stru148 +struct Polygon { - inline stru148() + inline Polygon() { uNumVertices = 0; } int _479295(); void DrawBorderTiles(); - void _48276F_sr(); + //void _48276F_sr(); void _486089_normalize_v_18(); void _48607B(struct stru149 *a2); @@ -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); - void sky_48694B(); + int 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 Mon Jul 22 18:00:34 2013 +0600 +++ b/ParticleEngine.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -65,9 +65,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 Mon Jul 22 18:00:34 2013 +0600 +++ b/ParticleEngine.h Mon Jul 22 18:00:58 2013 +0600 @@ -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;
--- a/Party.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Party.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -26,6 +26,7 @@ #include "Sprites.h" #include "SpriteObject.h" #include "ObjectList.h" +#include "Conditions.h" Party *pParty; // idb @@ -251,7 +252,7 @@ while ( v2 <= &pParty->pPlayers[3] ) { v3 = 0; - v4 = v2->pInventoryItems; + v4 = v2->pInventoryItemList; do { if ( v4->uItemID == uItemID ) @@ -561,7 +562,7 @@ //v10 = uSkillIdx - 35 < 0; } //while (uSkillIdx < 36); - pItems = pCharacter->pInventoryItems; + pItems = pCharacter->pInventoryItemList; //v13 = 138; for (int i = 0; i < 138; i++) { @@ -949,7 +950,7 @@ auto condition = player->GetMajorConditionIdx(); - if (condition == Player::Condition_Good || condition == Player::Condition_Zombie) + if (condition == Condition_Good || condition == Condition_Zombie) { if (player->uExpressionTimePassed < player->uExpressionTimeLength) continue; @@ -999,23 +1000,23 @@ switch (condition) { - case Player::Condition_Dead: player->expression = CHARACTER_EXPRESSION_DEAD; break; - case Player::Condition_Pertified: player->expression = CHARACTER_EXPRESSION_PERTIFIED; break; - case Player::Condition_Eradicated: player->expression = CHARACTER_EXPRESSION_ERADICATED; break; - case Player::Condition_Cursed: player->expression = CHARACTER_EXPRESSION_CURSED; break; - case Player::Condition_Weak: player->expression = CHARACTER_EXPRESSION_WEAK; break; - case Player::Condition_Sleep: player->expression = CHARACTER_EXPRESSION_SLEEP; break; - case Player::Condition_Fear: player->expression = CHARACTER_EXPRESSION_FEAR; break; - case Player::Condition_Drunk: player->expression = CHARACTER_EXPRESSION_DRUNK; break; - case Player::Condition_Insane: player->expression = CHARACTER_EXPRESSION_INSANE; break; - case Player::Condition_Poison1: - case Player::Condition_Poison2: - case Player::Condition_Poison3: player->expression = CHARACTER_EXPRESSION_POISONED; break; - case Player::Condition_Disease1: - case Player::Condition_Disease2: - case Player::Condition_Disease3: player->expression = CHARACTER_EXPRESSION_DISEASED; break; - case Player::Condition_Paralyzed: player->expression = CHARACTER_EXPRESSION_PARALYZED; break; - case Player::Condition_Unconcious: player->expression = CHARACTER_EXPRESSION_UNCONCIOUS; break; + case Condition_Dead: player->expression = CHARACTER_EXPRESSION_DEAD; break; + case Condition_Pertified: player->expression = CHARACTER_EXPRESSION_PERTIFIED; break; + case Condition_Eradicated: player->expression = CHARACTER_EXPRESSION_ERADICATED; break; + case Condition_Cursed: player->expression = CHARACTER_EXPRESSION_CURSED; break; + case Condition_Weak: player->expression = CHARACTER_EXPRESSION_WEAK; break; + case Condition_Sleep: player->expression = CHARACTER_EXPRESSION_SLEEP; break; + case Condition_Fear: player->expression = CHARACTER_EXPRESSION_FEAR; break; + case Condition_Drunk: player->expression = CHARACTER_EXPRESSION_DRUNK; break; + case Condition_Insane: player->expression = CHARACTER_EXPRESSION_INSANE; break; + case Condition_Poison1: + case Condition_Poison2: + case Condition_Poison3: player->expression = CHARACTER_EXPRESSION_POISONED; break; + case Condition_Disease1: + case Condition_Disease2: + case Condition_Disease3: player->expression = CHARACTER_EXPRESSION_DISEASED; break; + case Condition_Paralyzed: player->expression = CHARACTER_EXPRESSION_PARALYZED; break; + case Condition_Unconcious: player->expression = CHARACTER_EXPRESSION_UNCONCIOUS; break; default: assert(false); } @@ -1097,7 +1098,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 ) @@ -1153,6 +1154,7 @@ } pParty->days_played_without_rest = 0; } + //----- (004938D1) -------------------------------------------------------- void __fastcall Rest(unsigned int uHoursToSleep) { @@ -1214,16 +1216,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 ) @@ -1236,7 +1238,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; @@ -1251,7 +1253,7 @@ else { Rest(6u); - _506F18_num_hours_to_sleep -= 6; + _506F18_num_minutes_to_sleep -= 6; LoadActualSkyFrame(); } viewparams->bRedrawGameUI = 1; @@ -1446,7 +1448,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 @@ -1458,7 +1460,7 @@ v4 = v3->AddItem(-1, pParty->pPickedItem.uItemID); if ( v4 ) { - memcpy(&pParty->pPlayers[v12].pInventoryItems[v4], &pParty->pPickedItem, 0x24u); + memcpy(&pParty->pPlayers[v12].pInventoryItemList[v4 - 1], &pParty->pPickedItem, 0x24u); pMouse->RemoveHoldingItem(); break; } @@ -1513,4 +1515,15 @@ pIcons_LOD->SyncLoadedFilesCount(); } return 1; +} + + +bool Party::IsPartyEvil() +{ + return _449B57_test_bit(_quest_bits, 100); +} + +bool Party::IsPartyGood() +{ + return _449B57_test_bit(_quest_bits, 99); } \ No newline at end of file
--- a/Party.h Mon Jul 22 18:00:34 2013 +0600 +++ b/Party.h Mon Jul 22 18:00:58 2013 +0600 @@ -194,6 +194,8 @@ inline bool GetYellowAlert() {return (uFlags & PARTY_FLAGS_1_ALERT_YELLOW) != 0;} inline void SetYellowAlert() {uFlags |= PARTY_FLAGS_1_ALERT_YELLOW;} + bool IsPartyEvil(); + bool IsPartyGood(); int field_0; unsigned int uPartyHeight;
--- a/Player.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Player.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 @@ -235,22 +256,22 @@ //----- (0043EEF3) -------------------------------------------------------- -bool Player::_43EEF3() +bool Player::NothingOrJustBlastersEquipped() { signed int item_idx; // esi@1 signed int item_id; // esi@1 - for (int i=0; i<16;++i) - { - item_idx=pEquipment.pIndices[i]; - if (item_idx) - { - item_id=pOwnItems[item_idx-1].uItemID; - if (item_id!=64 && item_id!= 65 ) //blaster& blaster rifle - return false; - } - } - return true; - } + for (int i = 0; i < 16; ++i) + { + item_idx = pEquipment.pIndices[i]; + if (item_idx) + { + item_id = pOwnItems[item_idx - 1].uItemID; + if ( item_id != 64 && item_id != 65 ) //blaster& blaster rifle + return false; + } + } + return true; +} @@ -283,22 +304,19 @@ } conditionTimeMultiplier = GetConditionDayOfWeek(conditionIdx); } - else if (conditionIdx < 14) - { - baseConditionMultiplier = 1; - conditionTimeMultiplier = 0; - for (int i = 0; i <= 13; i++) - { - v6 = GetConditionDayOfWeek(i); - if ( v6 > conditionTimeMultiplier ) - conditionTimeMultiplier = v6; - } - if ( !conditionTimeMultiplier ) - conditionTimeMultiplier = 1; - } - else{ + else + { conditionTimeMultiplier = 1; baseConditionMultiplier = 1; + if (conditionIdx < 14) + { + for (int i = 0; i <= 13; i++) + { + v6 = GetConditionDayOfWeek(i); + if ( v6 > conditionTimeMultiplier ) + conditionTimeMultiplier = v6; + } + } } result = (int)((double)conditionTimeMultiplier * (double)baseConditionMultiplier * a2); if ( result < 1 ) @@ -415,26 +433,31 @@ //----- (004B6FF9) -------------------------------------------------------- -int Player::IsPlayerHealableByTemple() +bool Player::IsPlayerHealableByTemple() { signed int v2; // eax@1 v2 = (signed int)window_SpeakInHouse->ptr_1C; - - if ( this->sHealth < GetMaxHealth() || this->sMana < GetMaxMana() ) - { - return 1; - } - else if (GetMajorConditionIdx() == Condition_Good) - { - return 0; - } - else if (GetMajorConditionIdx() == Condition_Zombie && (v2 == 78 || v2 == 81 || v2 == 82)) - { - return 0; + if (this->sHealth >= GetMaxHealth() && this->sMana >= GetMaxMana() && GetMajorConditionIdx() == Condition_Good) + { + return false; } else { - return 1; + if (GetMajorConditionIdx() == Condition_Zombie) + { + if ((v2 == 78 || v2 == 81 || v2 == 82)) + { + return false; + } + else + { + return true; + } + } + else + { + return true; + } } } @@ -446,17 +469,18 @@ int item_idx; // eax@1 int inv_index; // eax@3 + item_idx = *pitem_index; if ( item_idx >125 || item_idx < 0 ) { 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; @@ -474,61 +498,48 @@ avalible_items = 0; memset (item_index_tabl,0,sizeof(item_index_tabl)); - for (i=0; i<138; ++i) - { - if (( pOwnItems[i].uItemID>0)&&(pOwnItems[i].uItemID<= 134)) - item_index_tabl[avalible_items++] = i; - } + for (i = 0; i < 138; ++i) + { + if (( pOwnItems[i].uItemID>0)&&(pOwnItems[i].uItemID <= 134)) + item_index_tabl[avalible_items++] = i; + } if ( avalible_items ) { if ( enchant_count ) { - 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; - } - + for ( i = 0; i < enchant_count; ++i ) + { + 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 ) { - if (!(pInventoryItems[item_index_tabl[i]].uAttributes&ITEM_ENCHANTED)) - pInventoryItems[item_index_tabl[i]].uAttributes|=ITEM_ENCHANTED; - } - } - } - ; + pInventoryItemList[item_index_tabl[i]].uAttributes |= ITEM_ENCHANTED; + } + } + } } //----- (004948B1) -------------------------------------------------------- void Player::PlaySound(PlayerSpeech speech, int a3) { - //Player *pPlayer; // edi@1 - //int v4; // eax@4 - signed int v5; // esi@4 - unsigned char *v6; // ebx@4 - signed int v7; // ecx@5 + signed int speechCount = 0; // esi@4 + signed int expressionCount = 0; // esi@4 unsigned __int8 v8; // al@6 - int v9; // eax@10 - //unsigned int pVoiceID; // ecx@10 - int v11; // esi@10 - //signed int v12; // eax@11 - signed int v13; // esi@12 + int pickedVariant; // esi@10 int v14; // eax@12 - //int v15; // eax@17 CHARACTER_EXPRESSION_ID expression; // ebx@17 signed int v17; // ecx@19 - char *pSoundID; // edi@20 - int v20[5]; // [sp+Ch] [bp-1Ch]@7 - //Player *pPlayer2; // [sp+20h] [bp-8h]@1 + unsigned int pSoundID; // edi@20 + int speechVariantArray[5]; // [sp+Ch] [bp-1Ch]@7 + int expressionVariantArray[5]; int pPlayerNum; // [sp+24h] [bp-4h]@1 - int pSoundId; // [sp+30h] [bp+8h]@4 - - //pPlayer = this; - //pPlayer2 = this; + unsigned int pickedSoundID; // [sp+30h] [bp+8h]@4 + unsigned int expressionDuration = 0; pPlayerNum = 1; for (int i = 0; i < 4; ++i) @@ -538,862 +549,351 @@ break; } - //v4 = a2;//102 - v5 = 0; - pSoundId = 0; - v6 = SoundSetAction[speech].data();//byte_4ED280 &byte_4ED3D8[4 * v4] ??? + pickedSoundID = 0; if (uVoicesVolumeMultiplier) { - v7 = 0; - do - { - v8 = v6[v7]; + for (int i = 0; i < 2; i++) + { + v8 = SoundSetAction[speech][i]; if ( v8 ) - v20[v5++] = v8; - ++v7; - } - while ( v7 < 2 ); - if ( v5 ) - { - v9 = rand(); - //pVoiceID = uVoiceID; - v11 = v20[v9 % v5]; - - if (int _v1 = byte_4ECF08[v11 - 1][uVoiceID]) - { - pSoundId = rand() % _v1 + 2 * (v11 + 50 * uVoiceID) + 4998; - pAudioPlayer->PlaySound((SoundID)pSoundId, PID(OBJECT_Player, pPlayerNum + 39), 0, -1, 0, 0, pSoundVolumeLevels[uVoicesVolumeMultiplier] * 128.0f, 0); - } - } - } - - v13 = 0; - v14 = (int)(v6 + 3); - do - { - if ( *(char *)v14 ) - v20[v13++] = *(char *)v14; - ++v14; - } - while ( -3 - (signed int)v6 + v14 < 5 ); - if ( v13 ) - { - pPlayerNum = 0; - expression = (CHARACTER_EXPRESSION_ID)v20[rand() % v13]; - if (expression == CHARACTER_EXPRESSION_21 && pSoundId ) - { - v17 = 0; + { + speechVariantArray[speechCount] = v8; + speechCount++; + } + } + if ( speechCount ) + { + pickedVariant = speechVariantArray[rand() % speechCount]; + int numberOfSubvariants = byte_4ECF08[pickedVariant - 1][uVoiceID]; + 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); + } + } + } + + for (int i = 0; i < 5; i++) + { + v14 = SoundSetAction[speech][i + 3]; + if ( v14 ) + { + expressionVariantArray[expressionCount] = v14; + expressionCount++; + } + } + if ( expressionCount ) + { + expression = (CHARACTER_EXPRESSION_ID)expressionVariantArray[rand() % expressionCount]; + if (expression == CHARACTER_EXPRESSION_21 && pickedSoundID ) + { if ( (signed int)pSoundList->sNumSounds <= 0 ) { -LABEL_23: v17 = 0; } else { - pSoundID = (char *)&pSoundList->pSounds->uSoundID; - while ( *(int *)pSoundID != pSoundId ) + pSoundID = pSoundList->pSounds[0].uSoundID; + v17 = 0; + for (int i = 0; i < pSoundList->sNumSounds; i++) { - ++v17; + v17 = i; + if (pSoundID == pickedSoundID) + { + break; + } pSoundID += 120; - if ( v17 >= (signed int)pSoundList->sNumSounds ) - goto LABEL_23; } } if ( pSoundList->pSounds[v17].pSoundData[0] ) - pPlayerNum = (sLastTrackLengthMS << 7) / 1000; - } - /*LOWORD(v14) = */PlayEmotion(expression, pPlayerNum); - } - //return v14; + expressionDuration = (sLastTrackLengthMS << 7) / 1000; + } + PlayEmotion(expression, expressionDuration); + } } // 4948B1: using guessed type int var_1C[5]; //----- (00494A25) -------------------------------------------------------- void Player::PlayEmotion(CHARACTER_EXPRESSION_ID new_expression, int a3) { - //signed int v3; // eax@1 - //CHARACTER_EXPRESSION_ID v4; // dx@1 - signed int v5; // edi@15 - PlayerFrame *v6; // esi@17 - signed int v7; // eax@20 - - //LOWORD(v3) = this->expression; - //v4 = expr; - if (expression != CHARACTER_EXPRESSION_SLEEP && - expression != CHARACTER_EXPRESSION_PERTIFIED || new_expression != CHARACTER_EXPRESSION_58) - { - int v3 = (unsigned)expression; - if ( (signed int)(unsigned __int16)v3 >= 2 ) - { - if ( v3 <= 7 ) - goto LABEL_12; - if ( v3 > 8 ) - { - if ( v3 > 11 ) - { - if ( v3 == CHARACTER_EXPRESSION_PERTIFIED ||( v3 > 97 && v3 <= 99) ) - return; - goto LABEL_15; - } -LABEL_12: - if (new_expression != CHARACTER_EXPRESSION_34 && new_expression != CHARACTER_EXPRESSION_35 && new_expression != CHARACTER_EXPRESSION_36) - return; - goto LABEL_15; - } - } - } -LABEL_15: - //LOWORD(v3) = a3; - v5 = 0; - this->uExpressionTimeLength = a3; + unsigned int v3 = expression; + if (expression == CHARACTER_EXPRESSION_DEAD || expression == CHARACTER_EXPRESSION_ERADICATED) + { + return; + } + else if (expression == CHARACTER_EXPRESSION_PERTIFIED && new_expression != CHARACTER_EXPRESSION_FALLING) + { + return; + } + else + { + if (expression != CHARACTER_EXPRESSION_SLEEP || new_expression != CHARACTER_EXPRESSION_FALLING) + { + if (v3 >= 2 && v3 <= 11 && v3 != 8 && !(new_expression == CHARACTER_EXPRESSION_DMGRECVD_MINOR || new_expression == CHARACTER_EXPRESSION_DMGRECVD_MODERATE || new_expression == CHARACTER_EXPRESSION_DMGRECVD_MAJOR)) + { + return; + } + } + } this->uExpressionTimePassed = 0; if ( !a3 ) { - if ( (signed int)pPlayerFrameTable->uNumFrames <= 0 ) - { -LABEL_20: - v7 = 0; - } - else - { - v6 = pPlayerFrameTable->pFrames; - while ( v6->expression != new_expression ) - { - ++v5; - ++v6; - if ( v5 >= (signed int)pPlayerFrameTable->uNumFrames ) - goto LABEL_20; - } - v7 = v5; - } - //v4 = expr; this->uExpressionTimeLength = 8 * pPlayerFrameTable->pFrames[a3].uAnimLength; } + else + { + this->uExpressionTimeLength = 0; + } expression = new_expression; viewparams->bRedrawGameUI = 1; } //----- (0049327B) -------------------------------------------------------- -int Player::_49327B(unsigned int uClass, int a3) -{ - Player *v3; // esi@1 - char v4; // zf@4 - __int16 v5; // dx@9 - signed int result; // eax@84 - unsigned int v7; // [sp-8h] [bp-10h]@3 - int v8; // [sp-4h] [bp-Ch]@3 - - v3 = this; +bool Player::ProfessionOrGuildFlagsCorrect( unsigned int uClass, int a3 ) +{ if ( this->classType == uClass ) { -LABEL_84: - result = 1; + return true; } else { + if (!a3) + { + return false; + } switch ( uClass ) { - case 0u: - v8 = a3; - v7 = 1; - goto LABEL_4; - case 1u: - if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 17) - || _49327B(2u, a3) ) - goto LABEL_84; - v8 = a3; - v7 = 3; - goto LABEL_4; - case 2u: - v5 = 19; - goto LABEL_82; - case 3u: - v5 = 21; - goto LABEL_82; - case 4u: - v8 = a3; - v7 = 5; - goto LABEL_4; - case 5u: - if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 11) - || _49327B(6u, a3) ) - goto LABEL_84; - v8 = a3; - v7 = 7; - goto LABEL_4; - case 6u: - if ( !a3 ) - break; - v5 = 13; - goto LABEL_82; - case 7u: - if ( !a3 ) - break; - v5 = 15; - goto LABEL_82; - case 8u: - v8 = a3; - v7 = 9; - goto LABEL_4; - case 9u: - if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 23) - || _49327B(0xAu, a3) ) - goto LABEL_84; - v8 = a3; - v7 = 11; - goto LABEL_4; - case 0xAu: - if ( !a3 ) - break; - v5 = 25; - goto LABEL_82; - case 0xBu: - if ( !a3 ) - break; - v5 = 27; - goto LABEL_82; - case 0xCu: - v8 = a3; - v7 = 13; - goto LABEL_4; - case 0xDu: - if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 41) - || _49327B(0xEu, a3) ) - goto LABEL_84; - v8 = a3; - v7 = 15; - goto LABEL_4; - case 0xEu: - if ( !a3 ) - break; - v5 = 43; - goto LABEL_82; - case 0xFu: - if ( !a3 ) - break; - v5 = 45; - goto LABEL_82; - case 0x10u: - v8 = a3; - v7 = 17; - goto LABEL_4; - case 0x11u: - if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 35) - || _49327B(0x12u, a3) ) - goto LABEL_84; - v8 = a3; - v7 = 19; - goto LABEL_4; - case 0x12u: - if ( !a3 ) - break; - v5 = 37; - goto LABEL_82; - case 0x13u: - v5 = 39; - goto LABEL_82; - case 0x14u: - v8 = a3; - v7 = 21; - goto LABEL_4; - case 0x15u: - if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 29) - || _49327B(0x16u, a3) ) - goto LABEL_84; - v8 = a3; - v7 = 23; - goto LABEL_4; - case 0x16u: - if ( !a3 ) - break; - v5 = 31; - goto LABEL_82; - case 0x17u: - if ( !a3 ) - break; - v5 = 33; - goto LABEL_82; - case 0x18u: - if ( !_49327B(0x19u, a3) ) - goto LABEL_56; - break; - case 0x19u: -LABEL_56: - if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)v3->_guilds_member_bits, 63) - || _49327B(0x1Au, a3) ) - goto LABEL_84; - v8 = a3; - v7 = 27; - goto LABEL_4; case 0x1Au: - if ( !a3 ) - break; - v5 = 65; - goto LABEL_82; + return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 65)); case 0x1Bu: - if ( !a3 ) - break; - v5 = 67; - goto LABEL_82; - case 0x1Cu: - v8 = a3; - v7 = 29; - goto LABEL_4; - case 0x1Du: - if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 69) - || _49327B(0x1Eu, a3) ) - goto LABEL_84; - v8 = a3; - v7 = 31; - goto LABEL_4; - case 0x1Eu: - if ( !a3 ) - break; - v5 = 71; - goto LABEL_82; - case 0x1Fu: - if ( !a3 ) - break; - v5 = 73; - goto LABEL_82; - case 0x20u: - v8 = a3; - v7 = 33; - goto LABEL_4; - case 0x21u: - if ( a3 && (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 73) - || _49327B(0x22u, a3) ) - goto LABEL_84; - v8 = a3; - v7 = 35; -LABEL_4: - v4 = _49327B(v7, v8) == 0; - goto LABEL_83; + return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 67)); case 0x22u: - if ( !a3 ) - break; - v5 = 77; - goto LABEL_82; + return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 77)); case 0x23u: - if ( a3 ) - { - v5 = 79; -LABEL_82: - v4 = (unsigned __int16)_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, v5) == 0; -LABEL_83: - if ( !v4 ) - goto LABEL_84; - } + return(_449B57_test_bit((unsigned __int8 *)this->_guilds_member_bits, 79)); break; default: + assert("Should not be able to get here" && false); break; } - result = 0; - } - return result; + return false; + } } //----- (00492C0B) -------------------------------------------------------- bool Player::CanAct() { - bool result; // eax@2 - - if ( this->pConditions[Condition_Sleep] || this->pConditions[Condition_Paralyzed] || - this->pConditions[Condition_Unconcious] || this->pConditions[Condition_Dead] || - this->pConditions[Condition_Pertified] || this->pConditions[Condition_Eradicated] ) - result = false; + if ( this->IsAsleep() || this->IsParalyzed() || + this->IsUnconcious() || this->IsDead() || + this->IsPertified() || this->IsEradicated() ) + return false; else - result = true; - return result; + return true; } //----- (00492C40) -------------------------------------------------------- bool Player::CanSteal() { - int v1; // eax@1 - - LOBYTE(v1) = GetActualSkillLevel(PLAYER_SKILL_STEALING); - return v1 != 0; + return GetActualSkillLevel(PLAYER_SKILL_STEALING) != 0; } //----- (00492C4E) -------------------------------------------------------- bool Player::CanEquip_RaceAndAlignmentCheck(unsigned int uItemID) { - char v2; // zf@9 - __int16 v4; // dx@13 - char v5; // zf@15 - - if ( (signed int)uItemID > 532 ) // if (uItemID == 514 || // item233 ਪ 䠪, - // uItemID == 516 || // item221 䠪, - // uItemID == 524) // item325 ࠪ ५, - { - if ( uItemID == 533 ) - { - v2 = GetRace() == 1; - } - else - { - if ( uItemID != 534 ) - { - if ( uItemID == 535 ) // - // if (uItemID == 530) // item093 䠪, - { - switch ( this->uVoiceID ) - { - default: - return 1; - case 4u: - case 5u: - case 6u: - case 7u: - case 0xAu: - case 0xBu: - case 0xEu: // - // if (uItemID == 535) // item129 䠪, 騭 - case 0xFu: - case 0x12u: - case 0x13u: - case 0x15u: - case 0x18u: - return 0; - } - return 0; - } - if ( uItemID == 536 ) // - // if (uItemID == 531) // item093 䠪, 祫 - { - switch ( this->uVoiceID ) - { - case 4u: - case 5u: - case 6u: - case 7u: - case 0xAu: - case 0xBu: - case 0xEu: - case 0xFu: - case 0x12u: - case 0x13u: - case 0x15u: - case 0x18u: - return 1; - default: - return 0; - } - return 0; - } - if ( uItemID != 604 ) // - // if (uItemID == 532) // item073 䨩᪠ 㣠 䠪, - return 1; - v5 = _43EEF3() == 0; - goto LABEL_23; - } - v2 = GetRace() == 3; // - // if (uItemID == 533) // item113 㪠 䠪, - } - } - else - { - if ( uItemID != 532 ) - { - if ( uItemID != 515 && uItemID != 517 ) // - // if (uItemID == 534) // item104 䠪, 稭 - { - if ( uItemID == 521 ) // if (uItemID == 521 || // item239 䠪, - // uItemID == 526) // item230 ࠢ ५, - { -LABEL_13: - v4 = 99; -LABEL_15: - v5 = (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v4) == 0; -LABEL_23: - if ( !v5 ) - return 1; - return 0; - } - if ( uItemID != 525 ) - { - if ( uItemID != 527 ) - { - if ( uItemID != 531 ) - return 1; - v2 = GetRace() == 2; - goto LABEL_10; - } - goto LABEL_13; - } - } - v4 = 100; - goto LABEL_15; - } - v2 = GetRace() == 0; - } -LABEL_10: - if ( v2 ) - return 1; - return 0; + switch (uItemID) + { + case ITEM_RELIC_ETHRICS_STAFF: + case ITEM_RELIC_OLD_NICK: + case ITEM_RELIC_TWILIGHT: return pParty->IsPartyEvil(); break; + case ITEM_RELIC_TALEDONS_HELM: + case ITEM_RELIC_JUSTICE: return pParty->IsPartyGood(); break; + case ITEM_ARTIFACT_ELFBANE: return IsRaceGoblin(); break; + case ITEM_ARTIFACT_MINDS_EYE: return IsRaceHuman(); break; + case ITEM_ELVEN_CHAINMAIL: return IsRaceElf(); break; + case ITEM_FORGE_GAUNTLETS: return IsRaceDwarf(); break; + case ITEM_ARTIFACT_HEROS_BELT: return IsMale(); break; + case ITEM_ARTIFACT_LADYS_ESCORT: return IsFemale(); break; + case ITEM_WETSUIT: return NothingOrJustBlastersEquipped(); break; + default: return 1; break; + } } //----- (00492D65) -------------------------------------------------------- -int Player::SetCondition(unsigned int uConditionIdx, int a3) - { - - signed int player_sex; // ecx@77 - char zombi_face; // al@80 - signed int remainig_player; // ebx@82 - int players_before; // [sp+10h] [bp-4h]@2 - int players_after; // [sp+20h] [bp+Ch]@82 - - if ( pConditions[uConditionIdx] ) - return 0; - players_before = 0; - for (int i=1;i<5;++i) - if ( pPlayers[i]->CanAct() ) - ++players_before; - - switch ( uConditionIdx ) - { - case Condition_Cursed: - PlaySound((PlayerSpeech)30, 0); - break; - case Condition_Weak: - if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0 ) - {--pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; - if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) - pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); - return 0; - } - - PlaySound((PlayerSpeech)25, 0); - break; - case Condition_Sleep: - if ( a3 == 1 &&(HasEnchantedItemEquipped(22)|| - WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR))) - return 0; - break; - - case Condition_Fear: - PlaySound((PlayerSpeech)26, 0); - break; - case Condition_Drunk: - PlaySound((PlayerSpeech)31, 0); - break; - - case Condition_Insane: - if ( a3 == 1 - && (HasEnchantedItemEquipped(19) || - WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || - WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK)) ) - return 0; - - PlaySound((PlayerSpeech)29, 0); - break; +void Player::SetCondition( unsigned int uConditionIdx, int a3 ) +{ + signed int player_sex; // ecx@77 + signed int remainig_player; // ebx@82 + int players_before; // [sp+10h] [bp-4h]@2 + int players_after; // [sp+20h] [bp+Ch]@82 + + if ( pConditions[uConditionIdx] ) + return; + + if (!ConditionProcessor::IsPlayerAffected(this, uConditionIdx, a3)) + { + return; + } + + switch ( uConditionIdx ) + { + case Condition_Cursed: PlaySound(SPEECH_30, 0); break; + case Condition_Weak: PlaySound(SPEECH_25, 0); break; + case Condition_Sleep: break; //nosound + case Condition_Fear: PlaySound(SPEECH_26, 0); break; + case Condition_Drunk: PlaySound(SPEECH_31, 0); break; + case Condition_Insane: PlaySound(SPEECH_29, 0); break; case Condition_Poison1: case Condition_Poison2: - case Condition_Poison3: - if ( a3 == 1 ) - { - if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 ) - { - --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; - if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) - pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); - } - if ( HasEnchantedItemEquipped(21) - || WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) - || WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK) ) - //goto LABEL_76; - return 0; - } - - //v23 = 27; - PlaySound((PlayerSpeech)27, 0); - break; - + case Condition_Poison3: PlaySound(SPEECH_27, 0); break; case Condition_Disease1: case Condition_Disease2: - case Condition_Disease3: - if ( a3 == 1 ) - { - if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 ) - { - --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; - if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) - pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); - return 0; - } - - if ( HasEnchantedItemEquipped(18) || - WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || - WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK) ) - return 0; - } - PlaySound((PlayerSpeech)28, 0); - break; - case Condition_Paralyzed: - if ( a3 == 1 ) - { - if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 ) - { - --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; - if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) - pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); - return 0; - } - - if ( HasEnchantedItemEquipped(20)|| - WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR)|| - WearsItem(ITEM_ARTIFACT_GHOULSBANE, EQIUP_ANY)|| - WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK)) - return 0; - } - break; + case Condition_Disease3: PlaySound(SPEECH_28, 0);break; + case Condition_Paralyzed: break; //nosound case Condition_Unconcious: - PlaySound(SPEECH_32, 0); - if ( sHealth > 0 ) - sHealth = 0; - break; + PlaySound(SPEECH_32, 0); + if ( sHealth > 0 ) + sHealth = 0; + break; case Condition_Dead: - if ( a3 == 1 && (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64 && pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill >= 4u ) - { - --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; - if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) - pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); - } - - PlaySound((PlayerSpeech)33, 0); - if ( sHealth > 0 ) - sHealth = 0; - if ( sMana > 0 ) - sMana = 0; - break; + PlaySound(SPEECH_33, 0); + if ( sHealth > 0 ) + sHealth = 0; + if ( sMana > 0 ) + sMana = 0; + break; case Condition_Pertified: - if ( a3 == 1 - &&((pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0i64) - || HasEnchantedItemEquipped(23)|| - WearsItem(ITEM_RELIC_KELEBRIM, EQIUP_ANY) || - WearsItem(ITEM_ARTIFACT_YORUBA, EQUIP_ARMOUR) || - WearsItem(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, EQUIP_CLOAK)) ) - - return 0; - PlaySound((PlayerSpeech)34, 0); - break; + PlaySound(SPEECH_34, 0); + break; case Condition_Eradicated: - if ( a3 == 1 && ((signed __int64)pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uExpireTime > 0 )&&( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uSkill >= 4u )) - { - --pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower; - if ( pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].uPower < 1u ) - pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Reset(); - return 0; - } - PlaySound(SPEECH_35, 0); - if (sHealth > 0 ) - sHealth = 0; - if ( sMana > 0 ) - sMana = 0; - break; - case Condition_Zombie: - if ( classType == PLAYER_CLASS_LICH || Eradicated() ||Zombie() || !Dead()) - return 0; - memset(&pConditions[0], 0, sizeof(pConditions)); - sHealth = GetMaxHealth(); + PlaySound(SPEECH_35, 0); + if (sHealth > 0 ) + sHealth = 0; + if ( sMana > 0 ) sMana = 0; - player_sex = 0; - uPrevFace = uCurrentFace; - uPrevVoiceID = uVoiceID; - switch ( uVoiceID ) - { - case 0: - case 1: - case 2: - case 3: - case 8: - case 9: - case 12: - case 13: - case 16: - case 17: - case 20: - case 23: - player_sex = 0; - break; - case 4: - case 5: - case 6: - case 7: - case 10: - case 11: - case 14: - case 15: - case 18: - case 19: - case 21: - case 24: - player_sex = 1; - break; - default: - break; - } - - zombi_face = (player_sex != 0) + 23; - uCurrentFace = zombi_face; - uVoiceID = zombi_face; - PlaySound((PlayerSpeech)SPEECH_99, 0); - break; - } - - remainig_player = 0; - pConditions[uConditionIdx] = pParty->uTimePlayed; - players_after = 0; - for (int i=1;i<5;++i) - { - - - if ( pPlayers[i]->CanAct() ) - { - remainig_player=i; - ++players_after; - } - } - if (( players_before == 2 )&&( players_after == 1 )) - { - pPlayers[remainig_player]->PlaySound(SPEECH_107, 0); - } - return 1; - } + break; + case Condition_Zombie: + if ( classType == PLAYER_CLASS_LICH || IsEradicated() || IsZombie() || !IsDead()) + return; + memset(&pConditions[0], 0, sizeof(pConditions)); + sHealth = GetMaxHealth(); + sMana = 0; + player_sex = 0; + uPrevFace = uCurrentFace; + uPrevVoiceID = uVoiceID; + if (IsMale()) + { + uCurrentFace = 23; + uVoiceID = 23; + } + else + { + uCurrentFace = 24; + uVoiceID = 24; + } + PlaySound(SPEECH_99, 0); + break; + } + + players_before = 0; + for (int i = 1; i < 5; ++i) + { + if ( pPlayers[i]->CanAct() ) + ++players_before; + } + + pConditions[uConditionIdx] = 1; + + remainig_player = 0; + players_after = 0; + for (int i = 1; i < 5; ++i) + { + if ( pPlayers[i]->CanAct() ) + { + remainig_player = i; + ++players_after; + } + } + if (( players_before == 2 ) && ( players_after == 1 )) + { + pPlayers[remainig_player]->PlaySound(SPEECH_107, 0); + } + return; +} //----- (00492528) -------------------------------------------------------- bool Player::CanFitItem(unsigned int uSlot, unsigned int uItemID) { - //unsigned int v3; // eax@1 - Texture *v4; // esi@1 - unsigned int v5; // ebx@1 - signed int v6; // edi@5 - int *v7; // ecx@6 - signed int v8; // edx@7 - int *v9; // eax@8 - //Player *v11; // [sp+Ch] [bp-4h]@1 - unsigned int uItemIDa; // [sp+1Ch] [bp+Ch]@1 - - v4 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); - v5 = GetSizeInInventorySlots(v4->uTextureWidth); - uItemIDa = GetSizeInInventorySlots(v4->uTextureHeight); + Texture *texture; // esi@1 + unsigned int slotWidth; // ebx@1 + unsigned int slotHeight; // [sp+1Ch] [bp+Ch]@1 + + texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); + slotWidth = GetSizeInInventorySlots(texture->uTextureWidth); + slotHeight = GetSizeInInventorySlots(texture->uTextureHeight); if ( !areWeLoadingTexture ) { - v4->Release(); + texture->Release(); pIcons_LOD->SyncLoadedFilesCount(); } - if ( (signed int)(v5 + (signed int)uSlot % 14) <= 14 && (signed int)(uItemIDa + (signed int)uSlot / 14) <= 9 ) - { - v6 = 0; - if ( (signed int)uItemIDa <= 0 ) - return 1; - v7 = &pInventoryIndices[uSlot]; - while ( 1 ) - { - v8 = 0; - if ( (signed int)v5 > 0 ) - break; -LABEL_11: - ++v6; - v7 += 14; - if ( v6 >= (signed int)uItemIDa ) - return 1; - } - v9 = v7; - while ( !*v9 ) - { - ++v8; - ++v9; - if ( v8 >= (signed int)v5 ) - goto LABEL_11; - } - } - return 0; + if ( slotHeight == 0 || slotWidth == 0) + { + assert("Items should have nonzero dimensions"); + return 1; + } + if ( (slotWidth + uSlot % INVETORYSLOTSWIDTH) <= INVETORYSLOTSWIDTH && (slotHeight + uSlot / INVETORYSLOTSWIDTH) <= INVETORYSLOTSHEIGHT ) + { + int startOfInnerLoop = uSlot; + for (unsigned int y = 0; y < slotHeight; y++) + { + int innerLoopPos = startOfInnerLoop; + for (unsigned int x = 0; x < slotWidth; x++) + { + if (pInventoryMatrix[innerLoopPos] != 0) + { + return false; + } + innerLoopPos++; + } + startOfInnerLoop += INVETORYSLOTSWIDTH; + } + return true; + } + return false; } // 506128: using guessed type int areWeLoadingTexture; //----- (004925E6) -------------------------------------------------------- -unsigned int Player::FindFreeInventorySlot() -{ - unsigned int result; // eax@1 - ItemGen *v2; // ecx@1 - - result = 0; - v2 = this->pInventoryItems; - while ( v2->uItemID ) - { - ++result; - ++v2; - if ( (signed int)result >= 126 ) - return -1; - } - return result; +int Player::FindFreeInventoryListSlot() +{ + for (int i = 0; i < 126; i++ ) + { + if (pInventoryItemList[i].uItemID == 0) + { + return i; + } + } + return -1; } //----- (00492600) -------------------------------------------------------- int Player::CreateItemInInventory(unsigned int uSlot, unsigned int uItemID) { - signed int v3; // edx@1 - ItemGen *v4; // eax@1 int result; // eax@8 - unsigned int v6; // ebx@10 - //unsigned int v7; // eax@10 - Texture *v8; // esi@10 - void *v9; // esi@13 - unsigned int v10; // [sp+0h] [bp-Ch]@10 - Player *v11; // [sp+4h] [bp-8h]@1 - signed int v12; // [sp+8h] [bp-4h]@4 - unsigned int uItemIDa; // [sp+18h] [bp+Ch]@10 - - v11 = this; - v3 = 0; - v4 = this->pInventoryItems; - while ( v4->uItemID ) - { - ++v3; - ++v4; - if ( v3 >= 126 ) - { - v12 = -1; - goto LABEL_5; - } - } - v12 = v3; -LABEL_5: - if ( v12 == -1 ) + signed int freeSlot; // [sp+8h] [bp-4h]@4 + + freeSlot = FindFreeInventoryListSlot(); + if ( freeSlot == -1 ) { if ( uActiveCharacter ) pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); - result = 0; + return 0; } else { - v6 = uItemID; - v8 = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE); - v10 = GetSizeInInventorySlots(v8->uTextureWidth); - uItemIDa = GetSizeInInventorySlots(v8->uTextureHeight); - if ( !areWeLoadingTexture ) - { - v8->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - if ( (signed int)uItemIDa > 0 ) - { - v9 = &v11->pInventoryIndices[uSlot]; - do - { - if ( (signed int)v10 > 0 ) - memset32(v9, -1 - uSlot, v10); - v9 = (char *)v9 + 56; - --uItemIDa; - } - while ( uItemIDa ); - } - result = v12 + 1; - v11->pInventoryIndices[uSlot] = v12 + 1; - v11->pInventoryItems[v12].uItemID = v6; + PutItemArInventoryIndex(uItemID, freeSlot, uSlot); + result = freeSlot + 1; + this->pInventoryItemList[freeSlot].uItemID = uItemID; } return result; } @@ -1402,212 +902,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 ) @@ -1615,35 +1027,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); @@ -1653,201 +1060,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 BildingType_WeaponShop: + if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) + return 5; + if (equipType > EQUIP_BOW) + return 4; + break; + case BildingType_ArmorShop: + if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) + return 5; + if ( equipType < EQUIP_ARMOUR || equipType > EQUIP_BOOTS) + return 4; + break; + case BildingType_MagicShop: + if (idemId >= ITEM_ARTIFACT_HERMES_SANDALS) + return 5; + if ( pItemsTable->pItems[idemId].uSkillType != PLAYER_SKILL_MISC ) + return 4; + break; + case BildingType_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) -------------------------------------------------------- @@ -1914,7 +1223,7 @@ signed int v6; // ebp@7 char *v7; // esi@7 signed int uSkillMultiplier; // [sp-4h] [bp-14h]@2 - + if (CheckHiredNPCSpeciality(Scholar)) return true; @@ -2150,9 +1459,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(); @@ -2183,6 +1492,7 @@ uLuck = uLuckBonus = 0; uLevel = sLevelModifier = 0; sAgeModifier = 0; + sACModifier = 0; // memset(field_1F5, 0, 30); pure_luck_used=0; @@ -2326,7 +1636,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); @@ -2626,7 +1936,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; @@ -2698,7 +2008,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 ) @@ -2791,7 +2101,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(); @@ -2881,7 +2191,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; @@ -3131,13 +2441,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) -------------------------------------------------------- @@ -3180,7 +2490,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 ) @@ -3188,7 +2498,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; } @@ -3565,7 +2875,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()) @@ -3608,17 +2918,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 ) @@ -3791,7 +3101,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; @@ -3845,7 +3155,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; @@ -3861,7 +3171,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) { @@ -3875,11 +3185,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]; } @@ -3889,7 +3199,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]; @@ -3932,7 +3242,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]; @@ -4365,12 +3675,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; } } @@ -4532,7 +3842,7 @@ { if ( v32 <= 11 ) { - v33 = v6->pInventoryItems[v31].uItemID; + v33 = v6->pInventoryItemList[v31].uItemID; v5 += pItemsTable->pItems[v33].uDamageDice + pItemsTable->pItems[v33].uDamageMod; } } @@ -5832,7 +5142,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); @@ -5890,7 +5200,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; } @@ -6443,17 +5753,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; @@ -6465,12 +5767,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) -------------------------------------------------------- @@ -6478,7 +5780,7 @@ { if ( pConditions[uCondition] && (uTime < pConditions[uCondition]) ) { - pConditions[uCondition]=0i64; + pConditions[uCondition] = 0i64; return true; } else @@ -6896,7 +6198,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); @@ -7262,7 +6564,7 @@ v23 = pParty->pPlayers;//[0].pInventoryItems; do { - v24 = v23->pInventoryItems; + v24 = v23->pInventoryItemList; v25 = 138; do { @@ -7351,7 +6653,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; @@ -7448,7 +6750,7 @@ return false; case VAR_PlayerItemInHands: v15 = 0; - v16 = v3->pInventoryItems; + v16 = v3->pInventoryItemList; break; case VAR_FixedGold: v4 = pParty->uNumGold; @@ -7833,11 +7135,11 @@ v9 = NULL; for (int i = 0; i < 138; i++) { - v9 = &this->pInventoryItems[i]; - if (v9->uItemID == 615) + v9 = &this->pInventoryItemList[i]; + if (v9->uItemID == ITEM_LICH_JAR_EMPTY) break; } - if (v9 != NULL && v9->uItemID != 615) + if (v9 != NULL && v9->uItemID != ITEM_LICH_JAR_EMPTY) { v10 = (int)((char *)this + 36 * 138); //originally 36 * v8. the code got to this condition only if v8 was equal to 138 *(int *)(v10 + 532) = 601; @@ -8978,7 +8280,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 ) @@ -9339,7 +8641,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; @@ -9367,48 +8669,15 @@ int v4; // edx@1 int v5; // esi@2 //int v6; // eax@2 - unsigned int v7; // eax@3 + int v7; // eax@3 ItemGen _this; // [sp+Ch] [bp-30h]@1 //Player *v9; // [sp+30h] [bp-Ch]@1 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; @@ -9426,16 +8695,18 @@ } 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(); } } } + + //----- (0049387A) -------------------------------------------------------- int CycleCharacter(unsigned int _this) { @@ -9530,9 +8801,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; } } @@ -9540,7 +8811,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; } } @@ -9958,7 +9229,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; @@ -10181,7 +9452,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; @@ -10200,7 +9471,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); @@ -10209,7 +9480,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); @@ -10218,7 +9489,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; } @@ -10232,10 +9503,161 @@ 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(); } } } } -} \ No newline at end of file +} + + +bool Player::IsWeak() +{ + return pConditions[Condition_Weak] != 0; +} + +bool Player::IsDead() +{ + return pConditions[Condition_Dead] != 0; +} + +bool Player::IsEradicated() +{ + return pConditions[Condition_Eradicated] != 0; +} + +bool Player::IsZombie() +{ + return pConditions[Condition_Zombie] != 0; +} + +bool Player::IsCursed() +{ + return pConditions[Condition_Cursed] != 0; +} + +bool Player::IsPertified() +{ + return pConditions[Condition_Pertified] != 0; +} + +bool Player::IsUnconcious() +{ + return pConditions[Condition_Unconcious] != 0; +} + +bool Player::IsAsleep() +{ + return pConditions[Condition_Sleep] != 0; +} + +bool Player::IsParalyzed() +{ + return pConditions[Condition_Paralyzed] != 0; +} + +void Player::SetCursed( bool state ) +{ + pConditions[Condition_Cursed] = state; +} + +void Player::SetWeak( bool state ) +{ + pConditions[Condition_Weak] = state; +} + +void Player::SetAsleep( bool state ) +{ + pConditions[Condition_Sleep] = state; +} + +void Player::SetAfraid( bool state ) +{ + pConditions[Condition_Fear] = state; +} + +void Player::SetDrunk( bool state ) +{ + pConditions[Condition_Drunk] = state; +} + +void Player::SetInsane( bool state ) +{ + pConditions[Condition_Insane] = state; +} + +void Player::SetPoison1( bool state ) +{ + pConditions[Condition_Poison1] = state; +} + +void Player::SetDisease1( bool state ) +{ + pConditions[Condition_Disease1] = state; +} + +void Player::SetPoison2( bool state ) +{ + pConditions[Condition_Poison2] = state; +} + +void Player::SetDisease2( bool state ) +{ + pConditions[Condition_Disease2] = state; +} + +void Player::SetPoison3( bool state ) +{ + pConditions[Condition_Poison3] = state; +} + +void Player::SetDisease3( bool state ) +{ + pConditions[Condition_Disease3] = state; +} + +void Player::SetParalyzed( bool state ) +{ + pConditions[Condition_Paralyzed] = state; +} + +void Player::SetUnconcious( bool state ) +{ + pConditions[Condition_Unconcious] = state; +} + +void Player::SetDead( bool state ) +{ + pConditions[Condition_Dead] = state; +} + +void Player::SetPertified( bool state ) +{ + pConditions[Condition_Pertified] = state; +} + +void Player::SetEradicated( bool state ) +{ + pConditions[Condition_Eradicated] = state; +} + +void Player::SetZombie( bool state ) +{ + pConditions[Condition_Zombie] = state; +} + +void Player::SetCondWeakWithBlockCheck( int blockable ) +{ + SetCondition(Condition_Weak, blockable); +} + +void Player::SetCondInsaneWithBlockCheck( int blockable ) +{ + SetCondition(Condition_Insane, blockable); +} + +void Player::SetCondDeadWithBlockCheck( int blockable ) +{ + SetCondition(Condition_Dead, blockable); +}
--- a/Player.h Mon Jul 22 18:00:34 2013 +0600 +++ b/Player.h Mon Jul 22 18:00:58 2013 +0600 @@ -1,6 +1,7 @@ #pragma once #include "Items.h" #include "Spells.h" +#include "Conditions.h" @@ -413,9 +414,9 @@ CHARACTER_EXPRESSION_31 = 31, CHARACTER_EXPRESSION_32 = 32, CHARACTER_EXPRESSION_33 = 33, - CHARACTER_EXPRESSION_34 = 34, - CHARACTER_EXPRESSION_35 = 35, - CHARACTER_EXPRESSION_36 = 36, + CHARACTER_EXPRESSION_DMGRECVD_MINOR = 34, + CHARACTER_EXPRESSION_DMGRECVD_MODERATE = 35, + CHARACTER_EXPRESSION_DMGRECVD_MAJOR = 36, CHARACTER_EXPRESSION_37 = 37, CHARACTER_EXPRESSION_38 = 38, CHARACTER_EXPRESSION_39 = 39, @@ -428,7 +429,7 @@ CHARACTER_EXPRESSION_55 = 55, CHARACTER_EXPRESSION_56 = 56, CHARACTER_EXPRESSION_57 = 57, - CHARACTER_EXPRESSION_58 = 58, + CHARACTER_EXPRESSION_FALLING = 58, // ? @@ -446,28 +447,9 @@ #pragma pack(push, 1) struct Player { -enum Condition: unsigned __int32 - { - Condition_Cursed = 0, - Condition_Weak = 1, - Condition_Sleep = 2, - Condition_Fear = 3, - Condition_Drunk = 4, - Condition_Insane = 5, - Condition_Poison1 = 6, - Condition_Disease1 = 7, - Condition_Poison2 = 8, - Condition_Disease2 = 9, - Condition_Poison3 = 10, - Condition_Disease3 = 11, - Condition_Paralyzed = 12, - Condition_Unconcious = 13, - Condition_Dead = 14, - Condition_Pertified = 15, - Condition_Eradicated = 16, - Condition_Zombie = 17, - Condition_Good = 18 - }; + static const unsigned int INVETORYSLOTSWIDTH = 14; + static const unsigned int INVETORYSLOTSHEIGHT = 9; + Player(); @@ -558,25 +540,25 @@ int GetDisarmTrap(); char GetLearningPercent(); bool CanFitItem(unsigned int uSlot, unsigned int uItemID); - unsigned 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(); bool CanEquip_RaceAndAlignmentCheck(unsigned int uItemID); - int SetCondition(unsigned int uConditionIdx, int a3); - int _49327B(unsigned int uClass, int a3); + void SetCondition(unsigned int uConditionIdx, int a3); + bool ProfessionOrGuildFlagsCorrect(unsigned int uClass, int a3); void PlaySound(PlayerSpeech speech, int a3); void PlayEmotion(CHARACTER_EXPRESSION_ID expression, int a3); void ItemsEnchant(int enchant_count); unsigned int GetItemIDAtInventoryIndex(int *a2); - int IsPlayerHealableByTemple(); + bool IsPlayerHealableByTemple(); int GetBaseIdentifyPrice(float a2); int GetBaseRepairPrice(int a2, float a3); int GetBaseBuyingPrice(int a2, float a3); @@ -587,7 +569,7 @@ int GetPriceSell(int uRealValue, float price_multiplier); int GetTempleHealCostModifier(float a2); int GetConditionDayOfWeek(unsigned int uCondition); - bool _43EEF3(); + bool NothingOrJustBlastersEquipped(); void SalesProcess(unsigned int inventory_idnx, int item_index, int _2devent_idx);//0x4BE2DD bool Recover(signed int a2); bool CanCastSpell(unsigned int uRequiredMana); @@ -595,33 +577,46 @@ void DrawPlayerBuffAnimBasedOnCondition(int currPlayerId); void EquipBody(ITEM_EQUIP_TYPE uEquipType); - inline bool Weak() {return pConditions[Condition_Weak] != 0;} - inline bool Dead() {return pConditions[Condition_Dead] != 0;} - inline bool Eradicated() {return pConditions[Condition_Eradicated] != 0;} - inline bool Zombie() {return pConditions[Condition_Zombie] != 0;} - inline bool Cursed() {return pConditions[Condition_Cursed] != 0;} - inline bool Pertified() {return pConditions[Condition_Pertified] != 0;} + bool IsWeak(); + bool IsDead(); + bool IsEradicated(); + bool IsZombie(); + bool IsCursed(); + bool IsPertified(); + bool IsUnconcious(); + bool IsAsleep(); + bool IsParalyzed(); - inline void SetCursed(bool state) {pConditions[Condition_Cursed] = state;} - inline void SetWeak(bool state) {pConditions[Condition_Weak] = state;} - inline void SetAsleep(bool state) {pConditions[Condition_Sleep] = state;} - inline void SetAfraid(bool state) {pConditions[Condition_Fear] = state;} - inline void SetDrunk(bool state) {pConditions[Condition_Drunk] = state;} - inline void SetInsane(bool state) {pConditions[Condition_Insane] = state;} - inline void SetPoison1(bool state) {pConditions[Condition_Poison1] = state;} - inline void SetDisease1(bool state) {pConditions[Condition_Disease1] = state;} - inline void SetPoison2(bool state) {pConditions[Condition_Poison2] = state;} - inline void SetDisease2(bool state) {pConditions[Condition_Disease2] = state;} - inline void SetPoison3(bool state) {pConditions[Condition_Poison3] = state;} - inline void SetDisease3(bool state) {pConditions[Condition_Disease3] = state;} - inline void SetParalyzed(bool state) {pConditions[Condition_Paralyzed] = state;} - inline void SetUnconcious(bool state) {pConditions[Condition_Unconcious] = state;} - inline void SetDead(bool state) {pConditions[Condition_Dead] = state;} - inline void SetPertified(bool state) {pConditions[Condition_Pertified] = state;} - inline void SetEradicated(bool state) {pConditions[Condition_Eradicated] = state;} - inline void SetZombie(bool state) {pConditions[Condition_Zombie] = state;} + void SetCursed(bool state); + void SetWeak(bool state); + void SetAsleep(bool state); + void SetAfraid(bool state); + void SetDrunk(bool state); + void SetInsane(bool state); + void SetPoison1(bool state); + void SetDisease1(bool state); + void SetPoison2(bool state); + void SetDisease2(bool state); + void SetPoison3(bool state); + void SetDisease3(bool state); + void SetParalyzed(bool state); + void SetUnconcious(bool state); + void SetDead(bool state); + void SetPertified(bool state); + void SetEradicated(bool state); + void SetZombie(bool state); + void SetCondWeakWithBlockCheck (int blockable); + void SetCondInsaneWithBlockCheck (int blockable); + void SetCondDeadWithBlockCheck (int blockable); + inline bool IsRaceHuman() {return GetRace() == CHARACTER_RACE_HUMAN;} + inline bool IsRaceDwarf() {return GetRace() == CHARACTER_RACE_DWARF;} + inline bool IsRaceElf() {return GetRace() == CHARACTER_RACE_ELF;} + inline bool IsRaceGoblin() {return GetRace() == CHARACTER_RACE_GOBLIN;} + + inline bool IsMale() { return GetSexByVoice() == SEX_MALE;} + inline bool IsFemale() { return !IsMale();} __int64 pConditions[20]; unsigned __int64 uExperience; char pName[16]; @@ -715,13 +710,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 Mon Jul 22 18:00:34 2013 +0600 +++ b/Render.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -221,1459 +221,27 @@ 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 { - int pTextureID; // ecx@8 - struct stru148 *pTile; // ebx@8 + char result; // al@3 + int v6; // ecx@8 + struct Polygon *pTile; // ebx@8 + struct Polygon *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; //warning: the game uses CW culling by default, ccw is incosistent pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_CCW); @@ -1711,11 +279,11 @@ //-------------------------------------------------------------------------------------------------------------------- // - for (unsigned int z = 0; z < 128; ++z) - { - for (unsigned int x = 0; x < 128; ++x) - { - pTile = &array_77EC08[pOutdoorCamera->numStru148s]; + for (unsigned int z = 0; z < 127; ++z) + { + for (unsigned int x = 0; x < 127; ++x) + { + pTile = &array_77EC08[pOutdoorCamera->uNumPolygons]; pTile->flags = 0; pTile->field_32 = 0; pTile->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); @@ -1769,9 +337,9 @@ pTile->dimming_level = 20.0 - floorf(20.0 * _f + 0.5f); //----------------------------------------------------------------------------------------------- - ++pOutdoorCamera->numStru148s; + ++pOutdoorCamera->uNumPolygons; ++pOutdoorCamera->field_44; - assert(pOutdoorCamera->numStru148s < 20000);// numStru148s - (numFaces) + assert(pOutdoorCamera->uNumPolygons < 20000); pTile->uBModelID = 0; pTile->uBModelFaceID = 0; @@ -1789,28 +357,28 @@ if ( pTile->flags & 2 && pTile->uTileBitmapID == pRenderer->hd_water_tile_id) { //transparent = false; - pTextureID = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; + v6 = pRenderer->pHDWaterBitmapIDs[pRenderer->hd_water_current_frame]; } else { - pTextureID = pTile->uTileBitmapID; + v6 = pTile->uTileBitmapID; if ( !_strnicmp(pBitmaps_LOD->pTextures[pTile->uTileBitmapID].pName, "wtrdr", 5) ) transparent = true; } - assert(pTextureID < 1000); // many random crashes here + 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[pTextureID], transparent, true); + pRenderer->DrawTerrainPolygon(pTile->uNumVertices, pTile, pBitmaps_LOD->pHardwareTextures[v6], transparent, true); } //else // //pTile->DrawBorderTiles(); //-------------------------------------------------------------------------------------------------------------------------------- - --pOutdoorCamera->numStru148s; + --pOutdoorCamera->uNumPolygons; --pOutdoorCamera->field_44; } } @@ -1832,7 +400,7 @@ double v13; // ST2C_8@6 int v14; // eax@6 double v15; // st7@6 - stru148 *pTile; // ebx@12 + struct Polygon *pTile; // ebx@12 unsigned __int16 v17; // ax@12 int v18; // eax@13 signed int v22; // eax@13 @@ -1852,9 +420,9 @@ char v35; // zf@47 unsigned int v36; // eax@50 int v37; // eax@54 - //stru148 *v38; // ecx@55 + //Polygon *v38; // ecx@55 unsigned int v39; // eax@59 - stru148 *v40; // ebx@62 + struct Polygon *v40; // ebx@62 unsigned __int16 pTileBitmapsID; // ax@62 int v42; // eax@63 LightmapBuilder *v43; // ecx@63 @@ -1873,7 +441,7 @@ unsigned int v56; // eax@101 int v57; // eax@105 unsigned int v58; // eax@109 - stru148 *v59; // esi@112 + struct Polygon *v59; // esi@112 unsigned __int16 v60; // ax@112 int v61; // eax@113 signed int v62; // eax@113 @@ -1885,7 +453,7 @@ double v68; // st5@120 double v69; // st7@133 int v70; // edi@138 - stru148 *v71; // esi@147 + struct Polygon *v71; // esi@147 unsigned int v72; // ecx@147 unsigned int v73; // eax@150 int v74; // eax@154 @@ -1996,7 +564,7 @@ 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 = &array_77EC08[pOutdoorCamera->uNumPolygons]; pTile->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); if ( pTile->uTileBitmapID != -1 ) { @@ -2015,16 +583,16 @@ (((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; + //v27 = pOutdoorCamera->uNumPolygons > 1999; + //v26 = pOutdoorCamera->uNumPolygons - 1999 < 0; pTile->dimming_level = floorf(thisf + 0.5f); - if ( pOutdoorCamera->numStru148s >= 1999 ) + if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; - ++pOutdoorCamera->numStru148s; + ++pOutdoorCamera->uNumPolygons; //if ( !sub_481FC9(v8, pVertices, v101, v16) )//Ritor1: It's temporary //goto LABEL_126; //{ - //--pOutdoorCamera->numStru148s; + //--pOutdoorCamera->uNumPolygons; //goto LABEL_162; //} memcpy(&array_50AC10[0], v102, 0x30u); @@ -2129,7 +697,7 @@ if ( ++v88 >= v84 ) return; } - /* v40 = &array_77EC08[pOutdoorCamera->numStru148s]; + /* v40 = &array_77EC08[pOutdoorCamera->uNumPolygons]; v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); if ( v40->uTileBitmapID == -1 ) goto LABEL_162; @@ -2157,13 +725,13 @@ v40->dimming_level = LOBYTE(v50); if ( LOBYTE(v50) < 0 ) v40->dimming_level = 0; - if ( pOutdoorCamera->numStru148s >= 1999 ) + if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; - ++pOutdoorCamera->numStru148s; + ++pOutdoorCamera->uNumPolygons; /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary //goto LABEL_77; { - --pOutdoorCamera->numStru148s; + --pOutdoorCamera->uNumPolygons; goto LABEL_112; }*/ /*memcpy(&array_50AC10[0], v102, 0x30u); @@ -2188,7 +756,7 @@ /*if ( !(byte_76D5C0 & 2) ) { byte_76D5C0 |= 2; - stru148(stru_76D590); + Polygon(stru_76D590); atexit(loc_48118F); }*/ /*v96 = pGame->pLightmapBuilder; @@ -2201,7 +769,7 @@ if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) { //LABEL_77: - --pOutdoorCamera->numStru148s; + --pOutdoorCamera->uNumPolygons; goto LABEL_112; } thisb->ViewTransform(array_50AC10, uNumVertices); @@ -2264,8 +832,8 @@ 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 = &array_77EC08[pOutdoorCamera->uNumPolygons]; + //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->uNumPolygons]; v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); if ( v59->uTileBitmapID == -1 ) goto LABEL_162; @@ -2286,13 +854,13 @@ v59->dimming_level = floorf(thish + 0.5f); if ( v59->dimming_level < 0 ) v59->dimming_level = 0; - if ( pOutdoorCamera->numStru148s >= 1999 ) + if ( pOutdoorCamera->uNumPolygons >= 1999 ) return; - ++pOutdoorCamera->numStru148s; + ++pOutdoorCamera->uNumPolygons; if ( !sub_481FC9(v101, v102, pVertices2, v59) ) { //LABEL_126: - --pOutdoorCamera->numStru148s; + --pOutdoorCamera->uNumPolygons; goto LABEL_162; } memcpy(&array_50AC10[0], v102, 0x30u); @@ -2324,7 +892,7 @@ if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) //goto LABEL_126; { - --pOutdoorCamera->numStru148s; + --pOutdoorCamera->uNumPolygons; goto LABEL_162; } thisc->ViewTransform(array_50AC10, v100); @@ -2382,10 +950,10 @@ //v77 = (int)v71; //v76 = v71->uNumVertices; //goto LABEL_161; - pRenderer->DrawTerrainPolygon(v71->uNumVertices, (stru148 *)v71, v78, 0, v80); + pRenderer->DrawTerrainPolygon(v71->uNumVertices, (Polygon *)v71, v78, 0, v80); goto LABEL_162; } - v38 = (stru148 *)v71; + v38 = (Polygon *)v71; goto LABEL_56; } v73 = sr_424EE0_MakeFanFromTriangle(v72); @@ -2395,508 +963,7 @@ 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() @@ -3699,9 +1766,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"); @@ -4339,7 +2406,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 @@ -4406,10 +2473,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 { @@ -4501,7 +2568,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; @@ -7063,10 +5130,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 @@ -7121,7 +5185,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 @@ -7236,7 +5300,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 @@ -7314,10 +5378,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 { @@ -7411,7 +5475,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; @@ -7468,7 +5532,7 @@ // 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 *a3, IDirect3DTexture2 *pTexture) { int v7; // eax@7 float v13; // ST3C_4@8 @@ -7510,7 +5574,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 @@ -7553,6 +5617,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._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) { @@ -7612,7 +6103,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)); @@ -7637,7 +6128,7 @@ d3d_vertex_buffer, uNumVertices, 28)); - pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); + pGame->pLightmapBuilder->DrawLightmaps(/*-1, 0*/); } else { @@ -7717,7 +6208,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; @@ -7825,54 +6316,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; @@ -7951,7 +6442,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 @@ -7963,20 +6454,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 @@ -7988,47 +6479,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 @@ -8040,17 +6531,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; } } } @@ -8125,7 +6616,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 @@ -8137,22 +6628,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 @@ -8164,20 +6655,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 @@ -8189,20 +6680,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 @@ -8214,16 +6705,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; } } @@ -8271,53 +6762,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; @@ -8493,79 +6984,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; } } @@ -8838,6 +7304,8 @@ double v39; // [sp+94h] [bp-Ch]@6 float v40; // [sp+9Ch] [bp-4h]@6 + __debugbreak(); + auto ecx0 = this; v3 = 0; if ( ecx0->pRenderD3D ) @@ -10633,12 +9101,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) @@ -10865,20 +9327,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); @@ -10886,7 +9348,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)); }*/ @@ -10901,7 +9363,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)); } @@ -10971,3 +9433,11 @@ { pRenderer->Present(); } + + + +//----- (0044EC20) -------------------------------------------------------- +/*bool RenderD3D::DoesRaiseExceptions() +{ + return true; +}*/ \ No newline at end of file
--- a/Render.h Mon Jul 22 18:00:34 2013 +0600 +++ b/Render.h Mon Jul 22 18:00:58 2013 +0600 @@ -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 *a3, 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();
--- a/SaveLoad.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/SaveLoad.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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;
--- a/Spells.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Spells.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -974,7 +974,7 @@ //v32 = pParty->pPlayers;//[0].pConditions[1]; //do for (uint i = 0; i < 4; ++i) - if (pParty->pPlayers[i].pConditions[Player::Condition_Weak]) + if (pParty->pPlayers[i].IsWeak()) return; //while ( v32 <= &pParty->pPlayers[3] ); //if ( !levela )
--- a/SpriteObject.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/SpriteObject.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -331,9 +331,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 +455,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 +738,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 +928,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;
--- a/Texture.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Texture.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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
--- a/Texture.h Mon Jul 22 18:00:34 2013 +0600 +++ b/Texture.h Mon Jul 22 18:00:58 2013 +0600 @@ -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/TurnEngine.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/TurnEngine.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -60,7 +60,6 @@ //sort if (uActorQueueSize>0) { - for( i=0; i<uActorQueueSize-1; ++i) { v7=&pQueue[i]; @@ -83,9 +82,7 @@ } } } - uActorQueueSize = active_actors; - if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) { uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1; @@ -96,7 +93,6 @@ uActiveCharacter = 0; field_18 &= ~TE_PLAYER_TURN; } - for(i=0; i<uActorQueueSize; ++i) { if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) @@ -119,51 +115,25 @@ //----- (004059DB) -------------------------------------------------------- void stru262_TurnBased::Start() { - //stru262_TurnBased *v1; // ebx@1 + int v3; // esi@1 - int v4; // eax@5 unsigned int actor_id; // esi@7 Actor *pActor; // edi@7 - unsigned int v7; // eax@9 unsigned int v8; // edx@10 - //unsigned __int8 v9; // zf@14 - //unsigned __int8 v10; // sf@14 - //unsigned __int8 v11; // of@14 - //char *v12; // esi@15 - //int v13; // ecx@16 - //unsigned __int16 v14; // ax@17 - int v15; // ecx@18 - signed __int64 v16; // qax@19 + signed int v16; // qax@19 int v17; // edx@22 - unsigned int v18; // esi@27 - char *v19; // esi@32 - int v20; // edx@33 - char *v21; // eax@33 - int v22; // ecx@33 - int v23; // eax@34 - char *v24; // eax@34 - char *v25; // ecx@34 - int v26; // edx@34 - int v27; // eax@38 - int v28; // ecx@38 AIDirection v30; // [sp+Ch] [bp-68h]@10 AIDirection v31; // [sp+28h] [bp-4Ch]@10 AIDirection a3; // [sp+44h] [bp-30h]@10 - //int v33; // [sp+60h] [bp-14h]@10 - int *v34; // [sp+64h] [bp-10h]@6 - int v35; // [sp+68h] [bp-Ch]@5 Player *pPlayer; // [sp+6Ch] [bp-8h]@1 int v40b; - unsigned int v37; // [sp+70h] [bp-4h]@7 int activ_players[4]; int players_recovery_time[4]; int a_players_count; int i,j; int temp; - pTurnEngine->field_18 &= ~TE_FLAG_2; - //v1 = this; pEventTimer->TrackGameTime(); pAudioPlayer->StopChannels(-1, -1); pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0); @@ -244,7 +214,6 @@ this->pQueue[v40b].field_4 += 16; } - if ( a_players_count > 0 ) { for (i=0; i<a_players_count; ++i) @@ -362,14 +331,14 @@ memcpy(&v15, v6, sizeof(AIDirection)); memcpy(&v14, &v15, sizeof(AIDirection)); v7 = curr_actor->uAIState; - if(v7==Dying) + if(v7==AIState::Dying) { curr_actor->uCurrentActionTime = 0; curr_actor->uCurrentActionLength = 0; curr_actor->uAIState = Dead; curr_actor->UpdateAnimation(); } - else if ( (v7 > Removed)&&(v7 < Disabled)) + else if ( (v7 > AIState::Removed)&&(v7 < AIState::Disabled)) { Actor::AI_StandOrBored(i, target_pid, 32, &v14); } @@ -393,7 +362,6 @@ field_10 = 100; } field_8 -= pEventTimer->uTimeElapsed; - } else if ( turn_stage == 2 ) { @@ -412,7 +380,6 @@ } else NextTurn(); - } else if ( turn_stage == 3 ) { @@ -431,360 +398,207 @@ //----- (00406051) -------------------------------------------------------- -__int16 stru262_TurnBased::StartTurn() + void stru262_TurnBased::StartTurn() { - stru262_TurnBased *v1; // esi@1 - int v2; // ecx@1 - int v3; // ebx@1 - char *v4; // edi@1 - int v5; // eax@4 - int v6; // eax@12 - char *v7; // eax@15 - TurnBased_QueueElem *v8; // edi@17 - unsigned int v9; // edx@23 - char *v10; // eax@26 - int v11; // eax@30 - int v12; // ebx@30 - char *v13; // edi@31 - int v15; // [sp+Ch] [bp-10h]@5 - TurnBased_QueueElem *v16; // [sp+10h] [bp-Ch]@3 - int v17; // [sp+14h] [bp-8h]@2 - int v18; // [sp+14h] [bp-8h]@16 - signed int v19; // [sp+18h] [bp-4h]@1 - int v20; // [sp+18h] [bp-4h]@14 + int player_num, actor_num, i, j; - v1 = this; - v2 = 0; - v19 = 0; - v3 = v1->uActorQueueSize; - v1->field_1C = 0; - v4 = (char *)&v1->pQueue[v3].field_4; - do + field_1C = 0; + for(player_num=0; player_num<4; ++player_num) { - v17 = v2; - if ( v1->uActorQueueSize <= v2 ) - goto LABEL_11; - v16 = v1->pQueue; - while ( 1 ) - { - v5 = v16->uPackedID; - if ( PID_TYPE(v16->uPackedID) == OBJECT_Player) - break; -LABEL_8: - ++v17; - ++v16; - if ( v17 >= v1->uActorQueueSize ) - goto LABEL_11; - } - v15 = PID_ID(v5); - if ( !pPlayers[(PID_ID(v5)) + 1]->CanAct() || v19 != v15 ) + for(j=0; j<uActorQueueSize; ++j) { - v2 = 0; - goto LABEL_8; + if (PID_TYPE(pQueue[j].uPackedID)== OBJECT_Player) + { + if (pPlayers[PID_ID(pQueue[j].uPackedID) + 1]->CanAct() && (player_num != PID_ID(pQueue[j].uPackedID)) ) + break; + } } - v2 = 0; -LABEL_11: - if ( v17 == v1->uActorQueueSize ) - { - *(int *)v4 = 100; - v6 = 8 * v19; - LOBYTE(v6) = PID(OBJECT_Player,v19); - *((int *)v4 + 2) = v2; - *((int *)v4 - 1) = v6; - *((int *)v4 + 1) = v2; - ++v3; - v4 += 16; - } - ++v19; + if (j==uActorQueueSize ) + { + pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Player,player_num); + pQueue[uActorQueueSize].field_4 = 100; + pQueue[uActorQueueSize].uActionLength = 0; + pQueue[uActorQueueSize].field_C = 0; + ++uActorQueueSize; + } } - while ( v19 < 4 ); - v1->uActorQueueSize = v3; - v20 = v2; - if ( ai_arrays_size > v2 ) + + for(actor_num=0; actor_num<ai_arrays_size; ++actor_num) + { + for(j=0; j<uActorQueueSize; ++j) + { + if ((PID_TYPE(pQueue[j].uPackedID)== OBJECT_Actor)&& + ai_near_actors_ids[actor_num] == PID_ID(pQueue[j].uPackedID)) + break; + } + if (j==uActorQueueSize ) { - v7 = (char *)&v1->pQueue[v3].field_4; - do - { - v18 = v2; - if ( v1->uActorQueueSize > v2 ) - { - v8 = v1->pQueue; - do - { - if ( PID_TYPE(v8->uPackedID) == OBJECT_Actor && ai_near_actors_ids[v20] == PID_ID(v8->uPackedID) ) - break; - ++v18; - ++v8; - } - while ( v18 < v1->uActorQueueSize ); - v2 = 0; - } - if ( v18 == v1->uActorQueueSize ) - { - v9 = ai_near_actors_ids[v20]; - *(int *)v7 = 1; - *((int *)v7 + 2) = v2; - *((int *)v7 - 1) = PID(OBJECT_Actor,v9); - *((int *)v7 + 1) = v2; - ++v3; - v7 += 16; - } - ++v20; - } - while ( v20 < ai_arrays_size ); + pQueue[uActorQueueSize].uPackedID = PID(OBJECT_Actor,ai_near_actors_ids[actor_num]); + pQueue[uActorQueueSize].field_4 = 1; + pQueue[uActorQueueSize].uActionLength = 0; + pQueue[uActorQueueSize].field_C = 0; + ++uActorQueueSize; } - ++v1->field_0; - v1->uActorQueueSize = v3; - v1->field_10 = 100; - if ( v3 > 0 ) + } + + ++field_0; + field_10 = 100; + + for(i=0; i<uActorQueueSize; ++i) { - v10 = (char *)&v1->pQueue[0].field_4; - do - { - if ( *(int *)v10 <= 0 ) - *(int *)v10 = 100; - ++v2; - v10 += 16; - } - while ( v2 < v1->uActorQueueSize ); + if (pQueue[i].field_4 == 0 ) + pQueue[i].field_4 = 100; } - LOWORD(v11) = v1->_4063A1(); - v12 = 0; - if ( v1->uActorQueueSize > 0 ) + + _4063A1(); + for(i=0; i<uActorQueueSize; ++i) { - v13 = (char *)&v1->pQueue[0].field_4; - do - { - v11 = PID_TYPE(*((int *)v13 - 1)); - if ( (char)v11 == 4 ) - break; - if ( *(int *)v13 > 0 ) - break; - LOWORD(v11) = v1->_40680F(v12++); - v13 += 16; - } - while ( v12 < v1->uActorQueueSize ); + if ((PID_TYPE(pQueue[i].uPackedID)==OBJECT_Player)||(pQueue[i].field_4 > 0)) + break; + _40680F(i); } - return v11; } // 4F75D8: using guessed type int ai_arrays_size; -//----- (004061CA) -------------------------------------------------------- -void stru262_TurnBased::NextTurn() - { - stru262_TurnBased *v1; // esi@1 - TurnBased_QueueElem *v2; // ebp@1 - int v3; // ebx@1 - int v4; // edi@7 - Actor *v5; // eax@9 - int v6; // ecx@9 - signed int v7; // ebx@17 - int v8; // ebp@27 - TurnBased_QueueElem *v9; // edi@28 - int v10; // ecx@30 - unsigned __int16 v11; // ax@30 - signed int v12; // edx@35 - signed int v13; // [sp+10h] [bp-4h]@7 + //----- (004061CA) -------------------------------------------------------- + void stru262_TurnBased::NextTurn() + { + Actor *curr_actor; // eax@9 + int ai_state; // ecx@9 + int v13; // [sp+10h] [bp-4h]@7 + int i; + int monster_ai_state; + int monster; // eax@5 + + SortTurnQueue(); + if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) + uActiveCharacter = PID_ID(pQueue[0].uPackedID) + 1; + else + uActiveCharacter = 0; + viewparams->bRedrawGameUI = 1; + + if ( field_1C ) + { + pTurnEngine->field_18 |= TE_FLAG_2; + return; + } + pTurnEngine->field_18 &= ~TE_FLAG_2; + if ( pQueue[0].field_4 <= 0 ) + return; + + v13 = 0; + if (uActorQueueSize > 0 ) + { - v1 = this; - SortTurnQueue(); - v2 = v1->pQueue; - v3 = 0; - if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) - uActiveCharacter = PID_ID(v1->pQueue[0].uPackedID) + 1; - else - uActiveCharacter = 0; - viewparams->bRedrawGameUI = 1; - if ( v1->field_1C ) - { - pTurnEngine->field_18 |= TE_FLAG_2; - return; - } - pTurnEngine->field_18 &= ~TE_FLAG_2; - if ( v1->pQueue[0].field_4 <= 0 ) - return; - v4 = 0; - v13 = 0; - if ( v1->uActorQueueSize <= 0 ) - goto LABEL_27; - do - { - if (PID_TYPE(v2->uPackedID) != OBJECT_Player) - { - v5 = &pActors[PID_ID(v2->uPackedID)]; - LOWORD(v6) = v5->uAIState; - if ( (short)v6 == 4 - || (short)v6 == 8 - || (short)v6 == 2 - || (short)v6 == 3 - || (short)v6 == 12 - || (short)v6 == 13 - || (short)v6 == 18 - || (short)v6 == 17 ) - { - v7 = v5->uCurrentActionLength; - v5->uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( (signed int)v5->uCurrentActionTime < v7 ) - { - v13 = 1; -LABEL_19: - v3 = 0; - goto LABEL_20; - } - v6 = (signed __int16)v6; - if ( (signed __int16)v6 == 4 ) - { - v3 = 0; - v5->uAIState = Dead; - v5->uCurrentActionTime = 0; - v5->uCurrentActionLength = 0; - v5->UpdateAnimation(); - } - else - { - if ( v6 != 8 ) - goto LABEL_19; - v3 = 0; - Actor::AI_StandOrBored(PID_ID(v2->uPackedID), ai_near_actors_targets_pid[PID_ID(v2->uPackedID)], 32, 0); - } - } - } -LABEL_20: - ++v4; - ++v2; - } - while ( v4 < v1->uActorQueueSize ); + for (i=0; i<uActorQueueSize; ++i ) + { + if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) + { + curr_actor = &pActors[PID_ID(pQueue[i].uPackedID)]; + ai_state = curr_actor->uAIState; + if ( (ai_state == AIState::Dying) || (ai_state == AIState::Stunned) || (ai_state == AIState::AttackingMelee) || + (ai_state == AIState::AttackingRanged1) || (ai_state == AIState::AttackingRanged2) || + (ai_state == AIState::AttackingRanged3) || (ai_state == AIState::AttackingRanged4) || (ai_state ==AIState::Summoned)) + { + curr_actor->uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( curr_actor->uCurrentActionTime < curr_actor->uCurrentActionLength ) + { + v13 = 1; + } + else if ( ai_state == 4 )// Dying + { + curr_actor->uAIState = AIState::Dead; + curr_actor->uCurrentActionTime = 0; + curr_actor->uCurrentActionLength = 0; + curr_actor->UpdateAnimation(); + } + else + { + if ( ai_state == 8 ) //Stunned + Actor::AI_StandOrBored(PID_ID(pQueue[i].uPackedID), ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)], 32, 0); + } + } + } + } + if ( v13 != 0 ) + { + field_18 |= TE_FLAG_1; + return; + } + } - if ( v13 != v3 ) - { - v1->field_18 |= TE_FLAG_1; - return; - } -LABEL_27: - v1->field_18 &= ~TE_FLAG_1; - v8 = 0; - if ( v1->uActorQueueSize > v3 ) - { - v9 = v1->pQueue; - do - { - if (PID_TYPE(v9->uPackedID) != OBJECT_Player) - { - v10 = PID_ID(v9->uPackedID); - v11 = pActors[v10].uAIState; - if ( v11 != 5 ) - { - if ( v11 != 4 && v11 != 11 && v11 != 19 ) - { - if ( v11 != 17 ) - { - v12 = ai_near_actors_targets_pid[v10]; - v9->uActionLength = v3; - Actor::AI_StandOrBored(v10, v12, 32, (AIDirection *)v3); - } - } - } - } - ++v8; - ++v9; - } - while ( v8 < v1->uActorQueueSize ); - } - v1->turn_stage = 3; - pParty->uTimePlayed += __PAIR__(v3, 213); - _494035_timed_effects__water_walking_damage__etc(); - v1->uActionPointsLeft = 130; - } + field_18 &= ~TE_FLAG_1; + for (i=0; i<uActorQueueSize; ++i ) + { + if(PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) + { + monster=PID_ID(pQueue[i].uPackedID); + monster_ai_state=pActors[monster].uAIState; + if ((monster_ai_state != AIState::Dead) && + (monster_ai_state != AIState::Dying) && + (monster_ai_state != AIState::Removed) && + (monster_ai_state != AIState::Summoned) && + (monster_ai_state != AIState::Disabled)) + { + pQueue[i].uActionLength = 0; + Actor::AI_StandOrBored(monster, ai_near_actors_targets_pid[monster], 32, nullptr); + } + } + } + turn_stage = 3; + pParty->uTimePlayed += 213i64; + _494035_timed_effects__water_walking_damage__etc(); + uActionPointsLeft = 130; + } -//----- (004063A1) -------------------------------------------------------- -int stru262_TurnBased::_4063A1() - { - stru262_TurnBased *v1; // esi@1 - int v2; // ebp@1 - signed int result; // eax@1 - int v4; // edx@1 - int v5; // edx@3 - int v6; // edi@4 - int v7; // ecx@5 - Actor *v8; // ecx@11 - unsigned __int16 v9; // dx@12 - int v10; // edi@16 - int v11; // edx@17 - char v12; // zf@18 + //----- (004063A1) -------------------------------------------------------- + int stru262_TurnBased::_4063A1() + { + int v9; // dx@12 + int j; - v1 = this; - SortTurnQueue(); - v2 = (int)&v1->pQueue[0].field_4; - result = 1; - viewparams->bRedrawGameUI = 1; - v4 = v1->pQueue[0].field_4; - if ( v4 ) - { - if (PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) - { - v5 = v1->uActorQueueSize; - while ( 1 ) - { - v6 = 0; - if ( v5 > 0 ) - { - v7 = (int)&v1->pQueue[0].field_4; - do - { - --*(int *)v7; - v5 = v1->uActorQueueSize; - ++v6; - v7 += 16; - } - while ( v6 < v5 ); - } - --v1->field_10; - if ( v1->field_10 <= 0 ) - break; - if ( !*(int *)v2 ) - goto LABEL_9; - } -LABEL_24: - result = 1; - } - else - { - v8 = &pActors[PID_ID(v1->pQueue[0].uPackedID)]; - if ( v4 > 0 ) - { - do - { - v9 = v8->uAIState; - if ( v9 == 5 ) - break; - if ( v9 == 4 || v9 == 19 || v9 == 11 ) - break; - v10 = 0; - if ( v1->uActorQueueSize > 0 ) - { - v11 = (int)&v1->pQueue[0].field_4; - do - { - v12 = (*(int *)v11)-- == 1; - if ( v12 ) - *(int *)(v11 + 4) = 0; - ++v10; - v11 += 16; - } - while ( v10 < v1->uActorQueueSize ); - } - --v1->field_10; - if ( v1->field_10 <= 0 ) - goto LABEL_24; - } - while ( *(int *)v2 > 0 ); - } -LABEL_9: - result = 0; - } - } - return result; - } + SortTurnQueue(); + viewparams->bRedrawGameUI = 1; + if ( pQueue[0].field_4 ) + { + if (PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) + { + do + { + for (j=0; j<uActorQueueSize; ++j ) + { + --pQueue[j].field_4; + } + --field_10; + if (field_10 == 0) + return 1; + } + while (pQueue[0].field_4 > 0); + } + else + { + v9 = pActors[PID_ID(pQueue[0].uPackedID)].uAIState; + if (!(v9 == AIState::Dying || v9 == AIState::Dead || + v9 == AIState::Disabled || v9 == AIState::Removed)) + { + do + { + for (j=0; j<uActorQueueSize; ++j ) + { + --pQueue[j].field_4; + if (pQueue[j].field_4 == 1) + pQueue[j].uActionLength = 0; + } + --field_10; + if (field_10 == 0) + return 1; + } + while (pQueue[0].field_4 > 0); + } + } + } + return 0; + } //----- (00406457) -------------------------------------------------------- void stru262_TurnBased::_406457( int a2 ) @@ -852,11 +666,11 @@ break; monster=&pActors[PID_ID(pQueue[i].uPackedID)]; monster_ai_state=monster->uAIState; - if (monster_ai_state == Standing || - monster_ai_state == Fleeing || - monster_ai_state == Fidgeting) + if (monster_ai_state == AIState::Standing || + monster_ai_state == AIState::Fleeing || + monster_ai_state == AIState::Fidgeting) { - pQueue[i].field_4 == pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime; + pQueue[i].field_4 = pMonsterStats->pInfos[monster->pMonsterInfo.uID].uRecoveryTime; if (monster->pActorBuffs[7].uExpireTime > 0) pQueue[i].field_4*=2; } @@ -891,11 +705,11 @@ } for (i=0; i<uActorQueueSize; ++i ) - _406648(i); + AIRangedAttacks(i); } //----- (00406648) -------------------------------------------------------- -void stru262_TurnBased::_406648(unsigned int a2) +void stru262_TurnBased::AIRangedAttacks( unsigned int queue_index ) { TurnBased_QueueElem *v1; // ecx@1 int v3; // eax@1 @@ -925,129 +739,79 @@ TurnBased_QueueElem *v28; // [sp+44h] [bp-4h]@1 unsigned int a2a; // [sp+50h] [bp+8h]@2 - v1 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2)); + v1 = &pQueue[queue_index]; v28 = v1; v3 = v1->uPackedID; - if (PID_TYPE(v1->uPackedID) != OBJECT_Player) + if (PID_TYPE(pQueue[queue_index].uPackedID) == OBJECT_Actor) { v4 = PID_ID(v3); - a2a = ai_near_actors_targets_pid[PID_ID(v3)]; + a2a = ai_near_actors_targets_pid[PID_ID(pQueue[queue_index].uPackedID)]; memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3)); memcpy(&a4, &a3, sizeof(a4)); v5 = &pActors[PID_ID(v3)]; LOWORD(v3) = v5->uAIState; - if ( (short)v3 != Dead ) - { - if ( (short)v3 != Disabled ) - { - if ( (short)v3 != Removed ) + if (( (short)v3 != AIState::Dead )&& ( (short)v3 != AIState::Disabled )&&( (short)v3 != AIState::Removed )) { - v6 = v5->uCurrentActionLength; v5->uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( (signed int)v5->uCurrentActionTime >= v6 ) + if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength ) { - v7 = (signed __int16)v3; - v8 = (signed __int16)v3 - 2; - if ( !v8 ) - { - v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4); - stru_50FE08.Add( - v28->uPackedID, - 5120, - v5->vPosition.x, - v5->vPosition.y, - v5->vPosition.z + ((signed int)v5->uActorHeight >> 1), - v19, - 1); - goto LABEL_25; - } - v9 = v8 - 1; - if ( v9 ) - { - v10 = v9 - 1; - if ( !v10 ) - goto LABEL_21; - v11 = v10 - 4; - if ( !v11 ) - goto LABEL_25; - v12 = v11 - 4; - if ( v12 ) - { - v13 = v12 - 1; - if ( v13 ) - { - if ( v13 != Dead ) - { - if ( v7 != 4 ) - { - v14 = rand(); - v15 = v4; - v23 = &a4; - v16 = a2a; - if ( !(v14 % 2) ) - { - Actor::AI_Bored(v4, a2a, &a4); - return; - } - v21 = 64; -LABEL_26: - Actor::AI_Stand(v15, v16, v21, v23); - return; - } -LABEL_21: - v5->uCurrentActionTime = 0; - v5->uCurrentActionLength = 0; - v5->uAIState = Dead; - pActors[v4].UpdateAnimation(); - return; - } - v24 = v5->pMonsterInfo.uSpellSkillAndMastery2; - v22 = 3; - v17 = v5->pMonsterInfo.uSpell2ID; - } - else - { - v24 = v5->pMonsterInfo.uSpellSkillAndMastery1; - v22 = 2; - v17 = v5->pMonsterInfo.uSpell1ID; - } - Actor::AI_SpellAttack(v4, &a4, v17, v22, v24); -LABEL_25: - v16 = a2a; - v23 = &a4; - v21 = 0; - v15 = v4; - goto LABEL_26; - } - v18 = v5->pMonsterInfo.uMissleAttack2Type; - v25 = 1; - } - else - { - v18 = v5->pMonsterInfo.uMissleAttack1Type; - v25 = 0; - } - Actor::AI_RangedAttack(v4, &a4, v18, v25); - goto LABEL_25; - } + switch (v3) + { + case AIState::AttackingMelee: + v19 = stru_50C198.special_ability_use_check(&pActors[v4], v4); + stru_50FE08.Add( v28->uPackedID, 5120, v5->vPosition.x, v5->vPosition.y, v5->vPosition.z + ((signed int)v5->uActorHeight >> 1), v19, 1); + Actor::AI_Stand(v4, a2a, 0, &a4); + break; + case AIState::AttackingRanged1: + Actor::AI_RangedAttack(v4, &a4, v5->pMonsterInfo.uMissleAttack1Type, 0); + Actor::AI_Stand(v4, a2a, 0,&a4); + break; + case AIState::Dying: + v5->uCurrentActionTime = 0; + v5->uCurrentActionLength = 0; + v5->uAIState = Dead; + pActors[v4].UpdateAnimation(); + break; + case AIState::Stunned: + Actor::AI_Stand(v4, a2a, 0,&a4); + break; + case AIState::AttackingRanged2: + Actor::AI_RangedAttack(v4, &a4, v5->pMonsterInfo.uMissleAttack2Type, 1); + Actor::AI_Stand(v4, a2a, 0,&a4); + break; + case AIState::AttackingRanged3: + Actor::AI_SpellAttack(v4, &a4, v5->pMonsterInfo.uSpell1ID, 2, v5->pMonsterInfo.uSpellSkillAndMastery1); + Actor::AI_Stand(v4, a2a, 0, &a4); + break; + case AIState::AttackingRanged4: + Actor::AI_SpellAttack(v4, &a4, v5->pMonsterInfo.uSpell2ID, 3, v5->pMonsterInfo.uSpellSkillAndMastery2); + Actor::AI_Stand(v4, a2a, 0, &a4); + break; + default: + if ( !(rand() % 2) ) + Actor::AI_Bored(v4, a2a, &a4); + else + Actor::AI_Stand(v4, a2a, 64,&a4); + } } - } - } } + + } + } // 50FE08: using guessed type stru298 stru_50FE08; //----- (0040680F) -------------------------------------------------------- -__int16 stru262_TurnBased::_40680F(int a2) +void stru262_TurnBased::_40680F( int queue_index ) { TurnBased_QueueElem *v2; // eax@1 unsigned int v3; // eax@1 - unsigned int v4; // edi@2 + unsigned int actor_id; // edi@2 Actor *v5; // ebx@2 unsigned int *v6; // esi@7 AIDirection *v7; // esi@10 int v8; // eax@10 - unsigned int v9; // ecx@10 + int v9; // ecx@10 signed int v10; // eax@13 unsigned __int8 v11; // sf@19 unsigned __int8 v12; // of@19 @@ -1057,143 +821,122 @@ AIDirection a3; // [sp+Ch] [bp-44h]@10 AIDirection v18; // [sp+28h] [bp-28h]@10 int a2a; // [sp+44h] [bp-Ch]@2 - unsigned int v20; // [sp+48h] [bp-8h]@10 + int v20; // [sp+48h] [bp-8h]@10 TurnBased_QueueElem *v21; // [sp+4Ch] [bp-4h]@1 signed int v22; // [sp+58h] [bp+8h]@10 - v2 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2)); + v2 = &pQueue[queue_index]; v21 = v2; v2->uActionLength = 0; v3 = v2->uPackedID; - if ( (unsigned __int8)v3 & 3 ) + if (PID_TYPE(pQueue[queue_index].uPackedID) == OBJECT_Actor) { - v3 = PID_ID(v3); - v4 = v3; + + actor_id = PID_ID(pQueue[queue_index].uPackedID); a2a = v3; - v5 = &pActors[v3]; - LOWORD(v3) = v5->uAIState; - if ( (short)v3 != 5 ) + v5 = &pActors[actor_id]; + v3 = v5->uAIState; + if (!(v3 == AIState::Dying || v3 == AIState::Dead || v3 == AIState::Summoned || + v3 == AIState::Disabled || v3 == AIState::Removed)) { - if ( (short)v3 != 4 && (short)v3 != 11 && (short)v3 != 19 && (short)v3 != 17 ) - { - v6 = (unsigned int *)&ai_near_actors_targets_pid[(int)v4]; - Actor::_SelectTarget((unsigned int)v4, &ai_near_actors_targets_pid[(int)v4], true); - if ( v5->pMonsterInfo.uHostilityType && !*v6 ) + + Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); + v22 = ai_near_actors_targets_pid[actor_id]; + if ( v5->pMonsterInfo.uHostilityType && !v22) v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - v22 = *v6; - v7 = Actor::GetDirectionInfo(PID(OBJECT_Actor,(int)v4), *v6, &a3, 0); + v7 = Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), v22, &a3, 0); v8 = v5->uActorRadius; - memcpy(&a3, v7, sizeof(a3)); - memcpy(&v18, &a3, sizeof(v18)); + memcpy(&a3, v7, sizeof(AIDirection)); + memcpy(&v18, &a3, sizeof(AIDirection)); v9 = a3.uDistance - v8; v20 = a3.uDistance - v8; - if ( ((a3.uDistance - v8) & 0x80000000u) != 0 ) + if ( v20 < 0 ) { v9 = 0; v20 = 0; } + if (PID_TYPE(v22) == OBJECT_Actor) //v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3); v10 = pFactionTable->relations[(pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID) / 3 + 1][(v5->pMonsterInfo.uID - 1) / 3 + 1]; else v10 = 4; - if ( v10 == 1 ) - { + + switch (v10) + { + case 1: if ( (double)(signed int)v20 < 307.2 ) - goto LABEL_25; - } - else + v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + case 2: + if ( v20 < 1024 ) + v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + case 3: + if ( v20 < 2560 ) + v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + case 4: + if ( v20 < 5120 ) + v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + break; + } + + if ( v5->pMonsterInfo.uHostilityType == 4 && v22 && (signed int)v9 < 5120 ) { - if ( v10 == 2 ) + v14 = stru_50C198.special_ability_use_check(v5, actor_id); + v21->field_C = 0; + switch (v14) { - v12 = __OFSUB__(v9, 1024); - v11 = ((v9 - 1024) & 0x80000000u) != 0; + case 1: + if ( v5->pMonsterInfo.uMissleAttack2Type ) + { + Actor::AI_MissileAttack2(actor_id, v22, &v18); + v21->field_C = 1; + } + break; + case 2: + if(v5->pMonsterInfo.uSpell1ID) + { + Actor::AI_SpellAttack1(actor_id, v22, &v18); + v21->field_C = 1; + } + break; + case 3: + if(v5->pMonsterInfo.uSpell2ID) + { + Actor::AI_SpellAttack2(actor_id, v22, &v18); + v21->field_C = 1; + } + + break; + default: + if ( v5->pMonsterInfo.uMissleAttack1Type ) + { + Actor::AI_MissileAttack1(actor_id, v22, &v18); + v21->field_C = 1; + } } - else - { - if ( v10 == 3 ) + if (!v21->field_C) + if ( (double)v20 < 307.2) { - v12 = __OFSUB__(v9, 2560); - v11 = ((v9 - 2560) & 0x80000000u) != 0; + Actor::AI_MeleeAttack(actor_id, v22, &v18); + v21->field_C = 3; } else { - if ( v10 != 4 ) - goto LABEL_26; - v12 = __OFSUB__(v9, 5120); - v11 = ((v9 - 5120) & 0x80000000u) != 0; - } - } - if ( v11 ^ v12 ) - { -LABEL_25: - v5->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - goto LABEL_26; - } - } -LABEL_26: - if ( v5->pMonsterInfo.uHostilityType != 4 || !v22 || (signed int)v9 >= 5120 ) - { - v13 = a2a; - goto LABEL_47; - } - v13 = a2a; - v14 = stru_50C198.special_ability_use_check(v5, a2a); - if ( v14 == 1 ) - { - if ( v5->pMonsterInfo.uMissleAttack2Type ) - { - Actor::AI_MissileAttack2(v13, v22, &v18); - goto LABEL_43; - } - } + Actor::AI_Stand(actor_id, v22, 64, &v18); + v21->field_C = 0; + } + } else { - if ( v14 > 1 && v14 <= 3 ) - { - if ( v14 == 2 ) - v15 = v5->pMonsterInfo.uSpell1ID; - else - v15 = v5->pMonsterInfo.uSpell2ID; - if ( v15 ) - { - if ( v14 == 2 ) - Actor::AI_SpellAttack1(v13, v22, &v18); - else - Actor::AI_SpellAttack2(v13, v22, &v18); - goto LABEL_43; - } - goto LABEL_44; - } - if ( v5->pMonsterInfo.uMissleAttack1Type ) - { - Actor::AI_MissileAttack1(v13, v22, &v18); -LABEL_43: - //v3 = v21; - v21->field_C = 1; -LABEL_48: - v21->uActionLength = v5->uCurrentActionLength; - //return (signed __int16)v3; - return (signed __int16)&v21; - } + Actor::AI_Stand(actor_id, v22, 64, &v18); + v21->field_C = 0; } -LABEL_44: - if ( (double)(signed int)v20 < 307.2 ) - { - Actor::AI_MeleeAttack(v13, v22, &v18); - //v3 = v21; - v21->field_C = 3; - goto LABEL_48; - } -LABEL_47: - Actor::AI_Stand(v13, v22, 0x40u, &v18); - //v3 = v21; - v21->field_C = 0; - goto LABEL_48; - } - } + v21->uActionLength = v5->uCurrentActionLength; } - return (signed __int16)v3; + } } //----- (00406A63) -------------------------------------------------------- @@ -1246,84 +989,48 @@ } //----- (00406B9F) -------------------------------------------------------- -int stru262_TurnBased::_406B9F() +void stru262_TurnBased::_406B9F() { - signed int result; // eax@1 - unsigned __int8 v2; // zf@1 - unsigned __int8 v3; // sf@1 - int v4; // esi@4 - unsigned int v5; // esi@5 Actor *v6; // ebx@5 - unsigned __int16 v7; // cx@15 AIDirection a3; // [sp+0h] [bp-50h]@15 AIDirection v9; // [sp+1Ch] [bp-34h]@15 - signed int a1; // [sp+38h] [bp-18h]@4 - stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1 - unsigned int v12; // [sp+40h] [bp-10h]@5 unsigned int v13; // [sp+44h] [bp-Ch]@8 - TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2 - signed int a2; // [sp+4Ch] [bp-4h]@1 + int i; - result = 0; - thisa = this; - v2 = this->uActorQueueSize == 0; - v3 = this->uActorQueueSize < 0; - a2 = 0; - if ( !(v3 | v2) ) + for (i=0; i<uActorQueueSize; ++i ) { - v14 = this->pQueue; - while ( 1 ) + if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) { - v4 = v14->uPackedID; - a1 = v14->uPackedID; - if (PID_TYPE(a1) != OBJECT_Player) + v6 = &pActors[PID_ID(pQueue[i].uPackedID)]; + if ( !(v6->pActorBuffs[5].uExpireTime > 0|| (v6->pActorBuffs[6].uExpireTime > 0) || + v6->uAIState == AIState::Dead || v6->uAIState == AIState::Removed || v6->uAIState == AIState::Disabled) ) { - v5 = PID_ID(v4); - v12 = v5; - v6 = &pActors[v5]; - if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result - || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result ) - v13 = result; - else - v13 = 1; - if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result - && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) ) - result = 1; - if ( !(v13 != 0 || result || v6->uAIState == 5 || v6->uAIState == 11 || v6->uAIState == 19) ) + v13 = ai_near_actors_targets_pid[PID_ID(pQueue[i].uPackedID)]; + memcpy(&v9, Actor::GetDirectionInfo(pQueue[i].uPackedID, v13, &a3, 0), sizeof(AIDirection)); + if ( v6->uAIState == AIState::Pursuing || v6->uAIState == AIState::Tethered ) { - v13 = ai_near_actors_targets_pid[v5]; - memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9)); - v7 = v6->uAIState; - if ( v7 == 6 || v7 == 1 ) + if ( (double)(signed int)v9.uDistance < 307.2 ) + Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9); + } + else + { + v6->uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( v6->uCurrentActionTime > v6->uCurrentActionLength ) { - if ( (double)(signed int)v9.uDistance < 307.2 ) - goto LABEL_26; - } - v6->uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength ) - { - if ( v7 == 4 ) + if ( v6->uAIState == AIState::Dying ) { v6->uCurrentActionTime = 0; v6->uCurrentActionLength = 0; - v6->uAIState = Dead; + v6->uAIState = AIState::Dead; v6->UpdateAnimation(); } - if ( !thisa->ActorTurn(a2) ) -LABEL_26: - Actor::AI_Stand(v12, v13, 32, &v9); + if ( !ActorTurn(i) ) + Actor::AI_Stand(PID_ID(pQueue[i].uPackedID), v13, 32, &v9); } } } - ++a2; - result = (signed int)thisa; - ++v14; - if ( a2 >= thisa->uActorQueueSize ) - break; - result = 0; } } - return result; } //----- (00406D10) -------------------------------------------------------- @@ -1356,7 +1063,7 @@ unsigned int a2a; // [sp+5Ch] [bp+8h]@7 // __debugbreak();// - v2 = *(&this->field_0 + 4 * (a2 + 2)); + v2 = pQueue[a2].uPackedID; if (PID_TYPE(v2) == OBJECT_Player) return 0; uActorID = PID_ID(v2); @@ -1536,87 +1243,48 @@ return 1; } -//----- (00406FA8) -------------------------------------------------------- + //----- (00406FA8) -------------------------------------------------------- void stru262_TurnBased::_406FA8() { - unsigned __int8 v1; // zf@1 - unsigned __int8 v2; // sf@1 - TurnBased_QueueElem *v3; // edi@2 - int v4; // eax@4 - Actor *v5; // ebx@4 - unsigned __int16 v6; // cx@4 - unsigned int *v7; // edx@8 - unsigned int v8; // esi@8 - unsigned __int8 v9; // of@13 + Actor *curr_acror; // ebx@4 AIDirection a3; // [sp+Ch] [bp-6Ch]@8 - AIDirection v11; // [sp+28h] [bp-50h]@8 + AIDirection v9; // [sp+28h] [bp-50h]@8 AIDirection a4; // [sp+44h] [bp-34h]@8 - stru262_TurnBased *v13; // [sp+60h] [bp-18h]@1 - TurnBased_QueueElem *v14; // [sp+64h] [bp-14h]@2 + unsigned int target_pid; // [sp+60h] [bp-18h]@1 int uActorID; // [sp+68h] [bp-10h]@4 - unsigned int a2; // [sp+6Ch] [bp-Ch]@8 - int v17; // [sp+70h] [bp-8h]@1 - unsigned int v18; // [sp+74h] [bp-4h]@2 + int i; - v17 = 0; - v1 = this->uActorQueueSize == 0; - v2 = this->uActorQueueSize < 0; - v13 = this; - if ( !(v2 | v1) ) + for (i=0; i<uActorQueueSize; ++i ) { - v3 = this->pQueue; - v18 = (char *)&pTurnEngine - (char *)this; - v14 = this->pQueue; - do + if (PID_TYPE(pQueue[i].uPackedID) == OBJECT_Actor) { - if (PID_TYPE(v3->uPackedID) != OBJECT_Player) - { - v4 = PID_ID(v3->uPackedID); - uActorID = v4; - v5 = &pActors[v4]; - v6 = v5->uAIState; - if ( v6 != 5 ) // Dead + uActorID=PID_ID(pQueue[i].uPackedID); + curr_acror = &pActors[uActorID]; + if ( !( curr_acror->uAIState == AIState::Summoned|| curr_acror->uAIState == AIState::Dead || + curr_acror->uAIState == AIState::Removed || curr_acror->uAIState == AIState::Disabled) ) + { + target_pid = ai_near_actors_targets_pid[uActorID]; + Actor::_SelectTarget(uActorID, &ai_near_actors_targets_pid[uActorID], true); + memcpy(&v9, Actor::GetDirectionInfo(pQueue[i].uPackedID, target_pid, &a3, 0), sizeof(AIDirection)); + memcpy(&a4, &v9, sizeof(AIDirection)); + curr_acror->uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( curr_acror->uCurrentActionTime > curr_acror->uCurrentActionLength ) { - if ( v6 != 11 )// Removed + if ( curr_acror->uAIState == AIState::Dying ) { - if ( v6 != 19 ) //Disabled - { - if ( v6 != 17 ) //Summoned - { - v7 = (unsigned int *)&ai_near_actors_targets_pid[v4]; - a2 = *v7; - v8 = a2; - Actor::_SelectTarget(v4, (int *)v7, true); - memcpy(&v11, Actor::GetDirectionInfo(*(int *)((char *)&v3->uPackedID + v18), v8, &a3, 0), sizeof(AIDirection)); - memcpy(&a4, &v11, sizeof(AIDirection)); - v5->uCurrentActionTime += pMiscTimer->uTimeElapsed; - if ( (signed int)v5->uCurrentActionTime >= v5->uCurrentActionLength ) - { - if (v5->uAIState == Dying) - { - v5->uCurrentActionTime = 0; - v5->uCurrentActionLength = 0; - v5->uAIState = Dead; - v5->UpdateAnimation(); - return; - } - if ( rand() % 2 ) - Actor::AI_Stand(uActorID, a2, 64, &a4); - else - Actor::AI_Bored(uActorID, a2, &a4); - } - } - } + curr_acror->uCurrentActionTime = 0; + curr_acror->uCurrentActionLength = 0; + curr_acror->uAIState = AIState::Dead; + curr_acror->UpdateAnimation(); + break; } + if ( rand() % 2 ) + Actor::AI_Stand(uActorID, target_pid, 64, &a4); + else + Actor::AI_Bored(uActorID, target_pid, &a4); } } - ++v17; - v3 = v14 + 1; - v9 = __OFSUB__(v17, v13->uActorQueueSize); - v2 = v17 - v13->uActorQueueSize < 0; - ++v14; } - while ( v2 ^ v9 ); } }
--- a/TurnEngine.h Mon Jul 22 18:00:34 2013 +0600 +++ b/TurnEngine.h Mon Jul 22 18:00:58 2013 +0600 @@ -49,17 +49,17 @@ void Start(); void End(bool bPlaySound); void _405E14(); - __int16 StartTurn(); + void StartTurn(); void NextTurn(); int _4063A1(); void _406457(int a2); void _40652A(); void _4065B0(); - void _406648(unsigned int a2); - __int16 _40680F(int a2); + void AIRangedAttacks(unsigned int queue_index); + void _40680F(int queue_index); void _406A63(); void _406AFE(); - int _406B9F(); + void _406B9F(); bool ActorTurn(signed int a2); void _406FA8();
--- a/UI/Books/UIMapBook.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/Books/UIMapBook.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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}}; @@ -61,7 +57,7 @@ v6.uFrameHeight = game_viewport_height; v6.uFrameZ = game_viewport_z; v6.uFrameW = game_viewport_w; - + const uint fountain_bits_lut[] = {PARTY_QUEST_FOUNTAIN_HARMONDALE, PARTY_QUEST_FOUNTAIN_PIERPONT, PARTY_QUEST_FOUNTAIN_NIGHON, @@ -77,55 +73,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) @@ -134,52 +82,7 @@ pRenderer->DrawTextureIndexed(pTownPortalBook_xs[v3 - 1], pTownPortalBook_ys[v3 - 1], pTexture_TownPortalIcons[v3 - 1]); } v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); - - -/* if ( !v3 ) // Town Portal - { - v6.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3); // "Town Portal" - return; - } - if ( v3 == 1 ) - { - v4 = 206; -LABEL_30: - if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v4) ) - goto LABEL_31; - v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); // "Town Portal" - return; - } - if ( v3 == 2 ) - { - v4 = 208; - goto LABEL_30; - } - if ( v3 == 3 ) - { - v4 = 207; - goto LABEL_30; - } - if ( v3 == 4 ) - { - v4 = 211; - goto LABEL_30; - } - if ( v3 == 5 ) - { - v4 = 209; - goto LABEL_30; - } - if ( v3 == 6 ) - { - v4 = 210; - goto LABEL_30; - } -LABEL_31: - pRenderer->DrawTextureIndexed(word_4E1D3A[v3], pTownPortalBook_xs[v3 + 5], *(&pTex_tab_an_6b__zoom_on + v3)); - v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);*/ } -// 4E1D3A: using guessed type __int16 word_4E1D3A[]; //----- (00410DEC) -------------------------------------------------------- unsigned int __cdecl DrawLloydBeaconsScreen()
--- a/UI/Books/UISpellBook.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/Books/UISpellBook.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UIBooks.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UIBooks.h Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UICharacter.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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) { @@ -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); } } @@ -2640,7 +2673,7 @@ unsigned __int16 v5; // ax@7 unsigned int v6; // edi@19 int v7; // esi@27 - unsigned int v8; // eax@29 + int v8; // eax@29 int v9; // edx@32 int v10; // esi@34 int v11; // eax@34 @@ -2655,10 +2688,10 @@ int v20; // esi@60 int v21; // eax@60 unsigned int v22; // eax@61 - unsigned int v23; // eax@62 + int v23; // eax@62 int v24; // esi@65 int v25; // eax@65 - unsigned int v26; // eax@69 + int v26; // eax@69 int v27; // esi@81 int v28; // eax@81 int v29; // esi@84 @@ -2677,7 +2710,7 @@ unsigned int v49; // [sp+34h] [bp-18h]@57 unsigned int v50; // [sp+38h] [bp-14h]@50 int v51; // [sp+3Ch] [bp-10h]@1 - unsigned int v52; // [sp+40h] [bp-Ch]@5 + int v52; // [sp+40h] [bp-Ch]@5 //int v53; // [sp+44h] [bp-8h]@1 //unsigned int v54; // [sp+48h] [bp-4h]@1 @@ -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 ) @@ -2728,7 +2761,7 @@ pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); return; } - if ( pParty->pPickedItem.uItemID == 604 ) + if ( pParty->pPickedItem.uItemID == ITEM_WETSUIT ) { pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)3); WetsuitOn(uActiveCharacter); @@ -2756,7 +2789,7 @@ return; } pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)v6); - if ( pParty->pPickedItem.uItemID == 604 ) + if ( pParty->pPickedItem.uItemID == ITEM_WETSUIT ) WetsuitOff(uActiveCharacter); return; case 0xAu: @@ -2771,12 +2804,12 @@ { if ( !*(int *)v7 ) { - v8 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v8 & 0x80000000u) == 0 ) + 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(); - if ( (v52 & 0x80000000u) != 0 ) + 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(); - if ( (v23 & 0x80000000u) != 0 ) + 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(); - if ( (v26 & 0x80000000u) != 0 ) + 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,8 +3032,8 @@ } else { - v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v52 & 0x80000000u) == 0 ) + 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(); } @@ -3043,7 +3076,7 @@ v37 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v36); v50 = v37; v38 = (ItemGen *)(v37 + 532); - v14 = v38->uItemID == 604; + v14 = v38->uItemID == ITEM_WETSUIT; v52 = pItemsTable->pItems[v38->uItemID].uEquipType; if ( v14 ) { @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UIGuilds.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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; @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UIHouses.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -314,6 +314,38 @@ {"Player Castle Bad", 0x24, 0, 25, 0, 0} }}; + +//----- (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) { @@ -1679,7 +1711,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 +2395,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 +2468,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); } } @@ -2526,7 +2558,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 +2659,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 +2796,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 +3203,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 +3211,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 +3300,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 +3393,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 +3525,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 +3584,7 @@ return ; } - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + if ( !HouseUI_CheckIfPlayerCanInteract() ) return; v8 = pDialogueWindow; v33 = 0;
--- a/UI/UIHouses.h Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UIHouses.h Mon Jul 22 18:00:58 2013 +0600 @@ -116,6 +116,7 @@ HouseSound_Goodbye = 4 // farewells when bought something }; +bool HouseUI_CheckIfPlayerCanInteract(); void TrainingDialog(); void JailDialog(); void MagicShopDialog();
--- a/UI/UIMainMenu.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UIMainMenu.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UIPartyCreation.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UIPopup.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UIRest.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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) @@ -105,7 +105,7 @@ text_color = TargetColor(10, 0, 0); shadow_color = TargetColor(230, 214, 193); for(int i=1; i<5; ++i) - if ( !pPlayers[i]->pConditions[Player::Condition_Dead] && !pPlayers[i]->pConditions[Player::Condition_Eradicated] && pPlayers[i]->sHealth > 0 ) + if ( !pPlayers[i]->IsDead() && !pPlayers[i]->IsEradicated() && pPlayers[i]->sHealth > 0 ) ++live_characters; if ( live_characters )
--- a/UI/UIShops.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UIShops.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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; @@ -260,13 +260,13 @@ 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]; + v79 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; v13 = pPlayer->SelectPhrasesTransaction(v79, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3); v7 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); @@ -279,13 +279,13 @@ 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); @@ -307,14 +307,14 @@ 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]; + v4 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); v7 = BuilDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0); pTextHeight = (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138; @@ -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; @@ -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; @@ -678,7 +678,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 +737,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 ) @@ -803,7 +803,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; @@ -886,13 +886,13 @@ 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]; + v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItemList[v10 - 1]; v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3); v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3)]; v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0); @@ -906,7 +906,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,7 +917,7 @@ 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 @@ -940,7 +940,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,8 +949,8 @@ || (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); + v116 = &pPlayers[uActiveCharacter]->pInventoryItemList[v33 - 1]; + v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[v32 - 1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 5); v15 = (char *)pMerchantsRepairPhrases[v35]; v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0); v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; @@ -962,7 +962,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 ) @@ -1020,7 +1020,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 +1219,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 +1318,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; @@ -1380,13 +1380,13 @@ 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]; + v87 = (ItemGen *)&pPlayer->pInventoryItemList[pNumActiveItem - 1]; v45 = pPlayer->SelectPhrasesTransaction(v87, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3); v21 = BuilDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0); pTextHeight = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); @@ -1398,13 +1398,13 @@ 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); @@ -1520,7 +1520,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; @@ -1580,7 +1580,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 +1790,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 +1888,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; @@ -2019,7 +2019,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; @@ -2129,7 +2129,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,7 +2137,7 @@ || (result = (int)pMouse->GetCursorPos(&v101), *(int *)result >= 462) || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) ) return; - item = &pPlayers[uActiveCharacter]->pInventoryItems[result - 1]; + item = &pPlayers[uActiveCharacter]->pInventoryItemList[result - 1]; v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3); v30 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; @@ -2149,7 +2149,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,7 +2162,7 @@ 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); @@ -2186,7 +2186,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,8 +2196,8 @@ // || (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); + item = &pPlayers[uActiveCharacter]->pInventoryItemList[result - 1]; + v29 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItemList[result - 1], BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5); v30 = BuilDialogueString((char *)pMerchantsRepairPhrases[v29], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); @@ -2205,7 +2205,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() ) { v3 = 0; all_text_height = 0; @@ -2318,7 +2318,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 +2352,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 +2372,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 +2395,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 +2432,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 +2510,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(); @@ -2614,7 +2614,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 )
--- a/UI/UiGame.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/UI/UiGame.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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; @@ -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,7 +474,7 @@ 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; @@ -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; @@ -968,9 +966,9 @@ window->uFrameW = v9 + window->uFrameY - 1; window->DrawMessageBox(0); - if (player->Eradicated()) + if (player->IsEradicated()) v13 = pTexture_PlayerFaceEradicated; - else if (player->Dead()) + else if (player->IsDead()) v13 = pTexture_PlayerFaceDead; else { @@ -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); } @@ -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); @@ -2210,9 +2208,9 @@ for (uint i = 0; i < 4; ++i) { - auto pPlayer = pParty->pPlayers + i; + Player* pPlayer = pParty->pPlayers + i; - if (pPlayer->Eradicated()) + if (pPlayer->IsEradicated()) { pFace = pTexture_PlayerFaceEradicated; pPortrait = pFace; @@ -2232,7 +2230,7 @@ sub_441A4E(i); continue; } - if (pPlayer->Dead()) + if (pPlayer->IsDead()) { pFace = pTexture_PlayerFaceDead; pPortrait = pFace;
--- a/VideoPlayer.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/VideoPlayer.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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); } } } @@ -1170,7 +1174,8 @@ { bStopBeforeSchedule = 0; pResetflag = 0; - pGame->pCShow->PlayMovie(MOVIE_Death, 1); + PlayFullscreenMovie(MOVIE_Death, true); + //pGame->pCShow->PlayMovie(MOVIE_Death, 1); } //----- (004BE6F5) --------------------------------------------------------
--- a/Viewport.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Viewport.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -291,7 +291,7 @@ { sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[pSpriteObjects[v21].stru_24.uItemID].pUnidentifiedName); ShowStatusBarString(pTmpBuf2.data(), 2u); - if ( pSpriteObjects[v21].stru_24.uItemID == 506 ) + if ( pSpriteObjects[v21].stru_24.uItemID == ITEM_ARTIFACT_SPLITTER ) _449B7E_toggle_bit(pParty->_quest_bits, 184, 1); if ( pSpriteObjects[v21].stru_24.uItemID == 455 ) _449B7E_toggle_bit(pParty->_quest_bits, 185, 1);
--- a/Vis.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/Vis.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/_deleted.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -1,5 +1,10235 @@ - /* + + +// 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 *)&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) -------------------------------------------------------- +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 *)&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; +} + +//----- (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 *)&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; +} + +//----- (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]._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 = (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; +} + +//----- (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 = &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->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 ( !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->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 ( !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->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 ( !sub_481FC9(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(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->uNumPolygons; + goto LABEL_75; + } +} + +//----- (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(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; +} + + +//----- (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 +10721,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 Mon Jul 22 18:00:34 2013 +0600 +++ b/mm7_1.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -497,296 +497,6 @@ 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) -{ - __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 ) - { - stru_50B700.field_0 = 1; - } - else - { - stru_50B700.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 stru_50B700.field_0; //----- (00424CD7) -------------------------------------------------------- signed int __fastcall sr_424CD7(unsigned int uVertexID)
--- a/mm7_2.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/mm7_2.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -825,13 +825,13 @@ pWindow.uFrameZ = 543; pWindow.uFrameW = 397; pFont = LoadFont("endgame.fnt", "FONTPAL", NULL); - if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 99) ) + if ( pParty->IsPartyGood() ) { v1 = pGlobalTXT_LocalizationStrings[675]; } else { - result = _449B57_test_bit(pParty->_quest_bits, 100); + result = pParty->IsPartyEvil(); if ( !(short)result ) return result; v1 = pGlobalTXT_LocalizationStrings[676]; @@ -969,771 +969,9 @@ 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 @@ -4237,7 +3475,7 @@ { if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) { - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); pGUIWindow_CurrentMenu->Release(); pGUIWindow_CurrentMenu = 0; pCurrentScreen = SCREEN_GAME; @@ -4296,7 +3534,7 @@ pGUIWindow2 = 0; } pWindow_MainMenu->Release(); - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); } //----- (004637EB) -------------------------------------------------------- @@ -6247,20 +5485,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); @@ -6302,7 +5530,8 @@ } DeleteCCharFont(); bFlashQuestBook = true; - pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); + PlayFullscreenMovie(MOVIE_Emerald); + //pGame->pCShow->PlayMovie(MOVIE_Emerald, 0); SaveNewGame(); if (bNoMargareth)
--- a/mm7_3.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/mm7_3.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -2098,7 +2098,7 @@ } //----- (00473893) -------------------------------------------------------- -void __cdecl ODM_ProcessPartyActions() +void ODM_ProcessPartyActions() { //int _zero; // esi@1 int v1; // edi@1 @@ -2283,8 +2283,7 @@ 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); @@ -3040,24 +3039,14 @@ if ( !v107 && !(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((SoundID)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); + v87 = pOutdoor->GetSoundIdByPosition(v64, v63, 1); + pAudioPlayer->PlaySound((SoundID)v87, 804, 1, -1, 0, 0, 0, 0); } } else @@ -3067,29 +3056,16 @@ if ( v107 || 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); + v87 = pOutdoor->GetSoundIdByPosition(v64, v63, 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((SoundID)103, 804, 1, -1, 0, 0, 0, 0); } else { - //LABEL_344: pAudioPlayer->_4AA258(804); pParty->walk_sound_timer = 64; } @@ -3152,8 +3128,7 @@ do { v110 = (*v74)->GetMaxHealth(); - (*v74)->ReceiveDamage( - (signed int)((pParty->uFallStartY - v70) * (unsigned __int64)(signed __int64)((double)v110 * 0.1)) / 256, + (*v74)->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); @@ -3854,7 +3829,6 @@ return result; } -// 47730C: using guessed type int __stdcall const_1(int); //----- (004775ED) -------------------------------------------------------- int stru6_stru1_indoor_sw_billboard::_4775ED(float a2) @@ -3899,20 +3873,20 @@ 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 ) { @@ -3998,9 +3972,7 @@ goto LABEL_10; } LABEL_12: - result = v38; - this->field_10 = v38; - return result; + return this->uNumVertices = v38; } //----- (00477927) -------------------------------------------------------- @@ -4046,20 +4018,20 @@ 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 ) { @@ -4145,9 +4117,7 @@ goto LABEL_10; } LABEL_12: - result = v38; - this->field_10 = v38; - return result; + return this->uNumVertices = v38; } //----- (00477C61) -------------------------------------------------------- @@ -4199,7 +4169,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 +4222,7 @@ *(float *)(v3 + 80) = v11; v3 += 16; } - while ( v2 < this->field_10 ); + while ( v2 < this->uNumVertices ); } } else @@ -4298,7 +4268,7 @@ } while ( v31 ); } - this->field_10 = 3; + this->uNumVertices = 3; return 1; } @@ -4330,7 +4300,7 @@ v10 = (double)pOutdoorCamera->shading_dist_mist; v3 = 8.0; } - v4 = a1->field_10; + v4 = a1->uNumVertices; if ( v4 <= 0 ) goto LABEL_16; v5 = (char *)&a1->field_14[20]; @@ -4353,15 +4323,15 @@ 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 +4348,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 +4379,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 +4416,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 +4447,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 +4457,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 +4482,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 +4522,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 +4665,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 +4675,7 @@ } else { - v47->Project(v23, 1u, 0); + pGame->pIndoorCameraD3D->Project(v23, 1u, 0); } ++v23;// += 48; --v51; @@ -4735,9 +4705,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 +4720,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 +4741,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 +4767,7 @@ } } if ( stru_F8AD28.uNumLightsApplied > 0 ) - pLightmapBuilder->ApplyLights( + pGame->pLightmapBuilder->ApplyLights( &stru_F8AD28, &static_RenderBuildingsD3D_stru_73C834, uNumVertices, @@ -4845,7 +4806,7 @@ } goto LABEL_85; } - --pOutdoorCamera->numStru148s; + --pOutdoorCamera->uNumPolygons; --pOutdoorCamera->field_44; LABEL_85: v54 = (Vec3_int_ *)((char *)v54 + 1); @@ -4860,414 +4821,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 +4892,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,7 +4904,6 @@ 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 ) { @@ -5379,105 +4930,14 @@ v5 = -65536; LABEL_5: 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) { @@ -5969,7 +5429,7 @@ int v16; // eax@12 signed __int64 v17; // qtt@13 signed int pShading; // ecx@13 - stru148 pSky; // [sp+14h] [bp-150h]@1 + struct Polygon pSky; // [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 @@ -6032,7 +5492,7 @@ //-------------------------------------------------------------------------- //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; @@ -6142,431 +5602,6 @@ //} } -//----- (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) { @@ -6811,322 +5846,6 @@ 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() @@ -7445,7 +6164,7 @@ } //----- (004811A3) -------------------------------------------------------- -void stru148::DrawBorderTiles() +void Polygon::DrawBorderTiles() { //__debugbreak(); @@ -7457,52 +6176,15 @@ //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 __cdecl ResetPolygons() { int v0; // ecx@1 char *v1; // eax@2 - v0 = pOutdoorCamera->numStru148s; - if ( pOutdoorCamera->numStru148s > 0 ) + v0 = pOutdoorCamera->uNumPolygons; + if ( pOutdoorCamera->uNumPolygons > 0 ) { v1 = (char *)&array_77EC08[0].prolly_tail; do @@ -7521,7 +6203,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; @@ -7561,7 +6243,7 @@ } //----- (00481FC9) -------------------------------------------------------- -int __fastcall sub_481FC9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, stru148 *a4)//Rotate camera +int __fastcall sub_481FC9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4)//Rotate camera { float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14; @@ -7761,2602 +6443,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,16 +6462,16 @@ } //----- (0048607B) -------------------------------------------------------- -void stru148::_48607B(stru149 *a2) +void Polygon::_48607B(stru149 *a2) { this->pTexture = 0; this->ptr_38 = a2; } //----- (00486089) -------------------------------------------------------- -void stru148::_486089_normalize_v_18() +void Polygon::_486089_normalize_v_18() { - //stru148 *v1; // esi@1 + //Polygon *v1; // esi@1 double v2; // st7@1 double v3; // st6@1 float v4; // ST18_4@2 @@ -10528,236 +6626,31 @@ } //----- (0048694B) -------------------------------------------------------- -void stru149::sky_48694B() +int stru149::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; - this->field_24 = (unsigned __int64)(this->field_C * (signed __int64)this->field_0_party_dir_x) >> 16 + 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 + ((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); - 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); + 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)
--- a/mm7_4.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/mm7_4.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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" @@ -529,252 +527,6 @@ } } -//----- (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() { @@ -814,170 +566,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) @@ -1302,7 +890,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 +909,7 @@ } else { - v25 = v21->pInventoryItems[_idx].uSpecEnchantmentType; + v25 = v21->pInventoryItemList[_idx].uSpecEnchantmentType; if ( v25 <= 50 ) { if ( v25 != 50 ) @@ -1369,7 +957,7 @@ if ( v48 ) { v31 = 0; - v32 = (char *)v21->pInventoryItems; + v32 = (char *)v21->pInventoryItemList; while ( *(int *)v32 != 601 || (unsigned __int8)v32[26] != v49 + 1 ) { ++v31; @@ -1606,7 +1194,7 @@ if (pParty->days_played_without_rest > 1) { for (uint i = 0; i < 4; ++i) - pParty->pPlayers[i].SetCondition(Player::Condition_Weak, 0); + pParty->pPlayers[i].SetCondWeakWithBlockCheck(0); if (pParty->uNumFoodRations) Party::TakeFood(1); @@ -1617,16 +1205,16 @@ if (pParty->days_played_without_rest > 3) for (uint i = 0; i < 4; ++i) { - auto player = pParty->pPlayers + i; + Player* player = pParty->pPlayers + i; player->Zero(); - if (!player->Pertified() && !player->Eradicated() && !player->Dead()) + if (!player->IsPertified() && !player->IsEradicated() && !player->IsDead()) { if (rand() % 100 < 5 * pParty->days_played_without_rest) - player->SetCondition(Player::Condition_Dead, 0); + player->SetCondDeadWithBlockCheck(0); if (rand() % 100 < 10 * pParty->days_played_without_rest) - player->SetCondition(Player::Condition_Insane, 0); + player->SetCondInsaneWithBlockCheck(0); } } } @@ -2609,7 +2197,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 +2271,7 @@ } } _continue_sprintf: - sprintf(a1, "%lu", v29); + sprintfex(a1, "%lu", v29); v11 = a1; goto _continue_strcat; } @@ -2718,7 +2306,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 +2330,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 +2898,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 = sub_423B5D(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 = sub_423B5D(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 +3059,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,11 +3128,11 @@ v6 = pParty->pPlayers;//[0].pInventoryItems[0].field_1A; do { - v7 = v6->pInventoryItems; + v7 = v6->pInventoryItemList; v8 = 138; do { - if ( v7->uItemID == 601 ) + if ( v7->uItemID == ITEM_LICH_JAR_FULL ) { if ( !v7->uHolderPlayer ) v9 = v7; @@ -5497,13 +3391,13 @@ switch ( dword_F8B1AC_award_bit_number ) { case 19: - if ( pPlayers[uActiveCharacter]->_49327B(0x22u, 1) == 1 ) + if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x22u, 1) == 1 ) { if ( !gold_transaction_amount ) goto LABEL_79; goto LABEL_42; } - if ( pPlayers[uActiveCharacter]->_49327B(26, 1) == 1 ) + if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x1Au, 1) == 1 ) { if ( !gold_transaction_amount ) goto LABEL_79; @@ -5511,13 +3405,13 @@ } return v35; case 20: - if ( pPlayers[uActiveCharacter]->_49327B(0x23u, 1) == 1 ) + if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x23u, 1) == 1 ) { if ( !gold_transaction_amount ) goto LABEL_79; goto LABEL_42; } - if ( pPlayers[uActiveCharacter]->_49327B(27, 1) == 1 ) + if ( pPlayers[uActiveCharacter]->ProfessionOrGuildFlagsCorrect(0x1Bu, 1) == 1 ) { if ( !gold_transaction_amount ) goto LABEL_79;
--- a/mm7_5.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/mm7_5.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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" @@ -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 ) @@ -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 @@ -2464,7 +2463,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,22 +2475,22 @@ 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; - pParty->pPlayers[3].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; - pParty->pPlayers[2].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; - pParty->pPlayers[1].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; - pParty->pPlayers[0].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; + pParty->pPlayers[3].SetAsleep(1); + pParty->pPlayers[2].SetAsleep(1); + pParty->pPlayers[1].SetAsleep(1); + pParty->pPlayers[0].SetAsleep(1); continue; case UIMSG_RestWindow: if ( pMessageQueue_50CBD0->uNumMessages ) @@ -2578,7 +2577,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,14 +2593,14 @@ } } 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; - pParty->pPlayers[3].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; - pParty->pPlayers[2].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; - pParty->pPlayers[1].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; - pParty->pPlayers[0].pConditions[Player::Condition_Sleep] = pParty->uTimePlayed; + pParty->pPlayers[3].SetAsleep(1); + pParty->pPlayers[2].SetAsleep(1); + pParty->pPlayers[1].SetAsleep(1); + pParty->pPlayers[0].SetAsleep(1); } continue; case UIMSG_AlreadyResting: @@ -2615,7 +2614,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 +2666,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 +2712,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 +2721,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 +2745,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 ) { @@ -3548,7 +3547,7 @@ } if ( pCurrentScreen == SCREEN_LOADGAME ) { - pIcons_LOD->_4114F2(); + pIcons_LOD->RemoveTexturesPackFromTextureList(); //crt_deconstruct_ptr_6A0118(); pTexture_PCX.Release(); pTexture_PCX.Load("title.pcx", 0); @@ -3626,444 +3625,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 +3858,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 +4115,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() @@ -5353,12 +4909,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 ) { @@ -5614,10 +5164,10 @@ v45 = v8 & 0x3F; pOut.y = SkillToMastery(v8); v10 = pOut.z; - if ( pParty->pPickedItem.uItemID == 220 ) + 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 +5184,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); @@ -5774,7 +5324,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 +5386,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: @@ -5903,28 +5453,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 +5488,46 @@ } } -//----- (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); } \ No newline at end of file
--- a/mm7_6.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/mm7_6.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -188,899 +188,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 @@ -2073,7 +1182,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 +1194,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 +1253,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 +1310,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->_40471C(); }
--- a/mm7_data.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/mm7_data.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -930,7 +930,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; @@ -967,25 +967,25 @@ int dword_507CD8; // weak std::array<int, 50> dword_50B570; // weak std::array<int, 50> dword_50B638; // weak -stru367 stru_50B700; -/*int stru_50B700.field_0; // weak -int stru_50B700.field_38[777]; // idb -int stru_50B700._view_transformed_ys[45]; -int stru_50B700.field_128[777]; -int stru_50B700._view_transformed_zs[45]; -int stru_50B700.field_218[777]; -int stru_50B700._view_transformed_xs[45]; -int stru_50B700._screen_space_y[777]; -int stru_50B700.field_3E4[777]; -int stru_50B700.field_2F0[2]; // idb -int stru_50B700._ys[3 + 45]; -int stru_50B700._ys2[48]; // idb -int stru_50B700._screen_space_x[777]; // idb -int stru_50B700.field_3D4[777]; // weak -int stru_50B700._xs[777]; // weak +stru367 PortalFace; +/*int PortalFace.field_0; // weak +int PortalFace.field_38[777]; // idb +int PortalFace._view_transformed_ys[45]; +int PortalFace.field_128[777]; +int PortalFace._view_transformed_zs[45]; +int PortalFace.field_218[777]; +int PortalFace._view_transformed_xs[45]; +int PortalFace._screen_space_y[777]; +int PortalFace.field_3E4[777]; +int PortalFace.field_2F0[2]; // idb +int PortalFace._ys[3 + 45]; +int PortalFace._ys2[48]; // idb +int PortalFace._screen_space_x[777]; // idb +int PortalFace.field_3D4[777]; // weak +int PortalFace._xs[777]; // weak int dword_50BAE8[777]; // weak -int stru_50B700._xs2[3 + 45]; // weak -int stru_50B700._xs3[48]; // weak*/ +int PortalFace._xs2[3 + 45]; // weak +int PortalFace._xs3[48]; // weak*/ std::array<int, 100> dword_50BC10; // weak std::array<int, 100> dword_50BDA0; // weak std::array<int, 100> dword_50BF30; // weak @@ -1176,7 +1176,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 +1317,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;
--- a/mm7_data.h Mon Jul 22 18:00:34 2013 +0600 +++ b/mm7_data.h Mon Jul 22 18:00:58 2013 +0600 @@ -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; @@ -610,25 +610,25 @@ extern int dword_507CD8; // weak extern std::array<int, 50> dword_50B570; // weak extern std::array<int, 50> dword_50B638; // weak -extern struct stru367 stru_50B700; -/*extern int stru_50B700.field_0; // weak -extern int stru_50B700.field_38[]; // idb -extern int stru_50B700._view_transformed_ys[]; -extern int stru_50B700.field_128[]; -extern int stru_50B700._view_transformed_zs[]; -extern int stru_50B700.field_218[]; -extern int stru_50B700._view_transformed_xs[]; -extern int stru_50B700._screen_space_y[]; -extern int stru_50B700.field_3E4[]; -extern int stru_50B700.field_2F0[]; // idb -extern int stru_50B700._ys[]; -extern int stru_50B700._ys2[]; // idb -extern int stru_50B700._screen_space_x[]; // idb -extern int stru_50B700.field_3D4[]; // weak -extern int stru_50B700._xs[]; // weak +extern struct stru367 PortalFace; +/*extern int PortalFace.field_0; // weak +extern int PortalFace.field_38[]; // idb +extern int PortalFace._view_transformed_ys[]; +extern int PortalFace.field_128[]; +extern int PortalFace._view_transformed_zs[]; +extern int PortalFace.field_218[]; +extern int PortalFace._view_transformed_xs[]; +extern int PortalFace._screen_space_y[]; +extern int PortalFace.field_3E4[]; +extern int PortalFace.field_2F0[]; // idb +extern int PortalFace._ys[]; +extern int PortalFace._ys2[]; // idb +extern int PortalFace._screen_space_x[]; // idb +extern int PortalFace.field_3D4[]; // weak +extern int PortalFace._xs[]; // weak extern int dword_50BAE8[]; // weak -extern int stru_50B700._xs2[]; // weak -extern int stru_50B700._xs3[]; // weak*/ +extern int PortalFace._xs2[]; // weak +extern int PortalFace._xs3[]; // weak*/ extern std::array<int, 100> dword_50BC10; // weak extern std::array<int, 100> dword_50BDA0; // weak extern std::array<int, 100> dword_50BF30; // weak @@ -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; @@ -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(); @@ -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 sub_423B5D(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); +int __fastcall GetPortalScreenCoord(unsigned int uFaceID); +signed int __fastcall sr_424579(int uFaceID, struct stru320 *a2); +bool PortalFrustrum(int pNumVertices, struct BspRenderer_PortalViewportData *a2, struct BspRenderer_PortalViewportData *near_portal, int uFaceID); signed int __fastcall sr_424CD7(unsigned int uVertexID); // idb 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); @@ -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; @@ -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,14 +1375,8 @@ 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(); 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); @@ -1401,36 +1385,15 @@ 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 __cdecl 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); +signed int __fastcall sub_481FC9(RenderVertexSoft *_ECX, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4); bool IsTerrainSlopeTooHigh(int pos_x, int pos_y); int __fastcall GetTerrainHeightsAroundParty2(int a1, int a2, int *a3, int a4); -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 +1412,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 *GetReputationString(signed int a1); char *BuilDialogueString(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,7 +1426,7 @@ 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 +unsigned int ModulateColor(unsigned int diffuse, float multiplier); // idb struct SoundHeader *__fastcall 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); @@ -1472,24 +1434,9 @@ int __fastcall GetSoundStrengthByDistanceFromParty(int a1, int a2, int a3); 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(); @@ -1507,8 +1454,8 @@ 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); @@ -1529,23 +1476,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 Mon Jul 22 18:00:34 2013 +0600 +++ /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 Mon Jul 22 18:00:34 2013 +0600 +++ /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/stru367.h Mon Jul 22 18:00:34 2013 +0600 +++ b/stru367.h Mon Jul 22 18:00:58 2013 +0600 @@ -6,11 +6,11 @@ #pragma pack(push, 1) struct stru367 { - int field_0; + bool direction; std::array<int, 13> field_4; - std::array<int, 60> _view_transformed_ys; - std::array<int, 60> _view_transformed_zs; - std::array<int, 48> _view_transformed_xs; + std::array<int, 60> _view_transformed_x; + std::array<int, 60> _view_transformed_y; + std::array<int, 48> _view_transformed_z; std::array<int, 60> _screen_space_y; std::array<int, 60> _screen_space_x; };
--- a/stru6.cpp Mon Jul 22 18:00:34 2013 +0600 +++ b/stru6.cpp Mon Jul 22 18:00:58 2013 +0600 @@ -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; } @@ -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 Mon Jul 22 18:00:34 2013 +0600 +++ b/stru6.h Mon Jul 22 18:00:58 2013 +0600 @@ -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);