# HG changeset patch # User Ritor1 # Date 1371640018 -21600 # Node ID 5450af4f57ef004407cb613057fb1da471f93e16 # Parent c423f946dc99381a1c7caea24ecac3a36ecd2402 moving files mm7_x ending diff -r c423f946dc99 -r 5450af4f57ef Actor.cpp --- a/Actor.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Actor.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -34,7 +34,9 @@ #include "MM7.h" #include "SpriteObject.h" #include "stru298.h" - +#include "Log.h" +#include "Texts.h" +#include "Allocator.h" @@ -4796,4 +4798,737 @@ else LOBYTE(v5) = uTotalActors == uAliveActors; return v5; +} +//----- (00408B54) -------------------------------------------------------- +unsigned int __fastcall SearchActorByID(unsigned int *pTotalActors, unsigned int a2) +{ + unsigned int v2; // edi@1 + unsigned int *v3; // esi@1 + int v4; // eax@1 + unsigned int v5; // ebx@1 + unsigned int v6; // edx@1 + + v2 = a2; + v3 = pTotalActors; + v4 = GetAlertStatus(); + v5 = 0; + *v3 = 0; + v6 = pActors[v2].uAttributes; + if ( (v6 & 0x100000) == v4 ) + { + *v3 = 1; + if ( pActors[v2].IsNotAlive() == 1 ) + v5 = 1; + } + return v5; +} +//----- (00408AE7) -------------------------------------------------------- +unsigned int __fastcall SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup) +{ + unsigned int *v2; // esi@1 + signed int v3; // ebx@1 + Actor *v4; // edi@2 + int v5; // eax@3 + unsigned int v7; // [sp+8h] [bp-Ch]@1 + int v8; // [sp+Ch] [bp-8h]@1 + unsigned int v9; // [sp+10h] [bp-4h]@1 + + v7 = uGroup; + v2 = pTotalActors; + v3 = 0; + v8 = GetAlertStatus(); + *v2 = 0; + v9 = 0; + if ( (signed int)uNumActors > 0 ) + { + v4 = pActors.data();//[0].uGroup; + do + { + v5 = v4->uAttributes; + if ( (v5 & 0x100000) == v8 ) + { + if ( v4->uGroup == v7 ) + { + ++*v2; + if ( v4->IsNotAlive() == 1 ) + ++v9; + } + } + ++v3; + ++v4; + } + while ( v3 < (signed int)uNumActors ); + } + return v9; +} +//----- (00408A7E) -------------------------------------------------------- +unsigned int __fastcall SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID) +{ + unsigned int *v2; // esi@1 + signed int v3; // ebx@1 + Actor *v4; // edi@2 + int v5; // eax@3 + int v7; // [sp+8h] [bp-Ch]@1 + int v8; // [sp+Ch] [bp-8h]@1 + unsigned int v9; // [sp+10h] [bp-4h]@1 + + v7 = uMonsterID; + v2 = pTotalActors; + v3 = 0; + v8 = GetAlertStatus(); + *v2 = 0; + v9 = 0; + if ( (signed int)uNumActors > 0 ) + { + v4 = pActors.data();//[0].pMonsterInfo.uID; + do + { + v5 = v4->uAttributes; // actor::attributes + if ( (v5 & 0x100000) == v8 ) + { + if ( v4->pMonsterInfo.field_33 == v7 ) + { + ++*v2; + if ( v4->IsNotAlive() == 1 ) + ++v9; + } + } + ++v3; + ++v4; + } + while ( v3 < (signed int)uNumActors ); + } + return v9; +} +//----- (00408A27) -------------------------------------------------------- +unsigned int __thiscall SearchAliveActors(unsigned int *pTotalActors) +{ + unsigned int *v1; // esi@1 + int v2; // eax@1 + unsigned int v3; // ebp@1 + signed int v4; // ebx@1 + Actor *v5; // edi@2 + unsigned int v6; // eax@3 + int v8; // [sp+Ch] [bp-4h]@1 + + v1 = pTotalActors; + v2 = GetAlertStatus(); + v3 = 0; + v4 = 0; + *v1 = 0; + v8 = v2; + if ( (signed int)uNumActors > 0 ) + { + v5 = pActors.data(); + do + { + v6 = v5->uAttributes; + if ( (v6 & 0x100000) == v8 ) + { + ++*v1; + if ( v5->IsNotAlive() == 1 ) + ++v3; + } + ++v4; + ++v5; + } + while ( v4 < (signed int)uNumActors ); + } + return v3; +} +//----- (00408768) -------------------------------------------------------- +void InitializeActors() +{ + signed int v5; // [sp+Ch] [bp-10h]@1 + signed int v6; // [sp+10h] [bp-Ch]@1 + signed int v7; // [sp+14h] [bp-8h]@1 + signed int v8; // [sp+18h] [bp-4h]@1 + + v8 = 0; + v6 = 0; + v7 = 0; + v5 = 0; + if ( !_stricmp(pCurrentMapName.data(), "d25.blv") ) + v8 = 1; + if ( !_stricmp(pCurrentMapName.data(), "d26.blv") ) + v6 = 1; + if (_449B57_test_bit(pParty->_quest_bits, 99)) + v7 = 1; + if (_449B57_test_bit(pParty->_quest_bits, 100)) + 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 + for (uint i = 0; i < uNumActors; ++i) + { + auto actor = &pActors[i]; + + if (actor->CanAct() || actor->uAIState == Disabled) + { + actor->vPosition.x = actor->vInitialPosition.x; + actor->vPosition.y = actor->vInitialPosition.y; + actor->vPosition.z = actor->vInitialPosition.z; + actor->sCurrentHP = actor->pMonsterInfo.uHP; + if (actor->uAIState != Disabled) + { + Actor::AI_Stand(i, ai_near_actors_targets_pid[i], actor->pMonsterInfo.uRecoveryTime, 0); + } + } + + actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; + + if (!v8 || v7) + if (!v6 || v5) + if (actor->IsPeasant()) + BYTE2(actor->uAttributes) &= 0xF7u; + + BYTE2(actor->uAttributes) &= 0x7Fu; + if (BYTE2(actor->uAttributes) & 0x40) + Actor::_4031C1_update_job(i, pParty->uCurrentHour, 1); + } +} +//----- (00439474) -------------------------------------------------------- +void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity) +{ + //signed int v3; // eax@1 + SpriteObject *v4; // ebx@1 + //int v5; // edx@3 + //bool uPlayerID; // eax@3 + //Player *pPlayer; // edi@4 + Actor *pMonster; // esi@7 + //SpriteObject *v9; // ebx@12 + int v10; // eax@12 + int v11; // ebx@12 + unsigned int v12; // ecx@12 + int v13; // edx@15 + int v14; // edx@17 + int v15; // eax@24 + unsigned __int16 v16; // cx@25 + int v17; // eax@29 + int v18; // eax@38 + unsigned __int8 v19; // zf@38 + unsigned __int8 v20; // sf@38 + int v21; // edx@44 + int v22; // eax@44 + unsigned __int8 v23; // zf@44 + unsigned __int8 v24; // sf@44 + int v25; // edx@51 + int v26; // ecx@51 + //signed int v27; // eax@51 + //int v28; // eax@53 + signed int v29; // eax@76 + signed int v30; // eax@84 + signed int v31; // eax@92 + int v32; // eax@94 + int v33; // eax@100 + int v34; // eax@104 + signed int v35; // eax@104 + double v36; // st7@104 + float v37; // ST08_4@104 + float v38; // ST04_4@104 + float v39; // ST00_4@104 + int v40; // ebx@107 + unsigned int v41; // ebx@109 + signed __int64 v42; // qax@125 + unsigned __int16 v43; // ax@132 + char v44; // bl@132 + unsigned __int16 v45; // ax@132 + unsigned __int64 v46; // [sp+Ch] [bp-60h]@6 + const char *v47; // [sp+14h] [bp-58h]@104 + char *pPlayerName; // [sp+18h] [bp-54h]@12 + char *pMonsterName; // [sp+1Ch] [bp-50h]@6 + int v50; // [sp+20h] [bp-4Ch]@6 + //unsigned __int64 *v51; // [sp+30h] [bp-3Ch]@6 + int v52; // [sp+34h] [bp-38h]@12 + //int v53; // [sp+38h] [bp-34h]@10 + //int v54; // [sp+3Ch] [bp-30h]@1 + //int v55; // [sp+40h] [bp-2Ch]@12 + signed int a4; // [sp+44h] [bp-28h]@1 + PlayerEquipment *v57; // [sp+48h] [bp-24h]@10 + //int v58; // [sp+4Ch] [bp-20h]@10 + int v59; // [sp+50h] [bp-1Ch]@1 + unsigned int uActorID_Monster_; // [sp+54h] [bp-18h]@1 + int v61; // [sp+58h] [bp-14h]@1 + bool v62; // [sp+5Ch] [bp-10h]@1 + int uDamageAmount; // [sp+60h] [bp-Ch]@1 + int a2; // [sp+64h] [bp-8h]@27 + int a3; // [sp+6Bh] [bp-1h]@6 + + //v3 = a1; + v4 = 0; + uActorID_Monster_ = uActorID_Monster; + //v54 = a1; + uDamageAmount = 0; + a4 = 0; + v61 = 0; + v59 = 0; + v62 = 0; + if ( PID_TYPE(a1) == OBJECT_Item) + { + v4 = &pSpriteObjects[PID_ID(a1)]; + //uDamageAmount = (int)v4; + v61 = v4->field_60_distance_related_prolly_lod; + a1 = v4->spell_caster_pid; + //v54 = v4->field_58_pid; + } + //v5 = a1 & 7; + //uPlayerID = a1 >> 3; + if (PID_TYPE(a1) != OBJECT_Player) + return; + + assert(PID_ID(abs(a1)) < 4); + auto player = &pParty->pPlayers[PID_ID(a1)]; + pMonster = &pActors[uActorID_Monster_]; + //uPlayerID = pMonster->IsAlive(); + if (pMonster->IsNotAlive()) + return; + + BYTE1(pMonster->uAttributes) |= 0xC0u; + if ( pMonster->uAIState == Fleeing ) + pMonster->uAttributes |= 0x20000u; + //v57 = 0; + //v53 = 0; + //v58 = 0; + bool hit_will_stun = false, + hit_will_paralyze = false; + if ( !v4 ) + { + //v51 = (unsigned __int64 *)player->pEquipment.uMainHand; + int main_hand_idx = player->pEquipment.uMainHand; + v59 = 1; + if ( player->HasItemEquipped(EQUIP_MAIN_HAND) ) + { + auto main_hand_skill = pItemsTable->pItems[player->pInventoryItems[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]); + //uDamageAmount = v28; + switch (main_hand_skill) + { + case PLAYER_SKILL_STAFF: + if (main_hand_mastery >= 3) + { + if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_STAFF) & 0x3F)) // stun chance when mastery >= 3 + hit_will_stun = true; + } + break; + + case PLAYER_SKILL_MACE: + if (main_hand_mastery >= 3) + { + if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)) + hit_will_stun = true; + } + if (main_hand_mastery >= 4) + { + if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)) + hit_will_paralyze = true; + } + break; + } + } + v50 = pMonster->pMonsterInfo.uID; + a2 = 4; + //v27 = player->CalculateMeleeDamageTo(0, 0, v50); + uDamageAmount = player->CalculateMeleeDamageTo(0, 0, v50); + //if ( !v57 ) + goto LABEL_67; + //goto LABEL_69; + } + + + v19 = v4->spell_id == SPELL_DARK_SOULDRINKER; + v61 = v4->field_60_distance_related_prolly_lod; + if ( !v19 ) + { + //v9 = (SpriteObject *)uDamageAmount; + v50 = pParty->vPosition.x - v4->vPosition.x; + //v55 = abs(v50); + pMonsterName = (char *)(pParty->vPosition.y - v4->vPosition.y); + //v51 = (unsigned __int64 *)abs((int)pMonsterName); + pPlayerName = (char *)(pParty->vPosition.z - v4->vPosition.z); + v52 = abs((int)pPlayerName); + v61 = abs(v50); + v10 = abs(v50); + v11 = (int)abs((int)pMonsterName); + v12 = v52; + if ( v10 < v11) + { + v10 = (int)v11; + v11 = v10; + } + if ( v10 < v52 ) + { + v13 = v10; + v10 = v52; + v12 = v13; + } + if ( v11 < (signed int)v12 ) + { + v14 = v12; + v12 = v11; + v11 = v14; + } + //uPlayerID = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10; + v61 = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10; + if ( v61 >= 2560 ) + { + if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) ) + return; + v61 = 2; + } + else + { + v61 = 1; + } + //v4 = (SpriteObject *)uDamageAmount; + } + + v15 = v4->spell_id; + if ( v15 == SPELL_LASER_PROJECTILE ) + { + v16 = player->pActiveSkills[7]; + v61 = 1; + if ( (signed int)SkillToMastery(v16) >= 3 ) + a4 = player->pActiveSkills[7] & 0x3F; + a2 = 4; + uDamageAmount = player->CalculateMeleeDamageTo(1, 1, 0); + goto LABEL_67; + } + if ( v15 != SPELL_BOW_ARROW ) + { + if ( v15 == SPELL_101 ) + { + a2 = 0; + v18 = player->CalculateRangedDamageTo(0); + v19 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0; + v20 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0; + uDamageAmount = v18; + if ( !v20 && (!(v20 | v19) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) ) + uDamageAmount >>= 1; + v59 = 1; + goto LABEL_67; + } + if ( v15 == SPELL_EARTH_BLADES ) + { + a4 = 5 * v4->spell_level; + a2 = player->GetSpellSchool(0x27u); + v21 = v4->spell_level; + v50 = pMonster->sCurrentHP; + pMonsterName = (char *)v4->spell_skill; + v22 = _43AFE3_calc_spell_damage(39, v21, v4->spell_skill, v50); + v23 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0; + v24 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0; + uDamageAmount = v22; + if ( !v24 && (!(v24 | v23) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) ) + uDamageAmount >>= 1; + v59 = 0; +LABEL_67: + if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) + { +//LABEL_68: + player->PlaySound(SPEECH_52, 0); + return; + } + goto LABEL_69; + } + if ( v15 == SPELL_EARTH_STUN ) + { + uDamageAmount = 0; + a2 = 4; + hit_will_stun = 1; + goto LABEL_67; + } + a2 = player->GetSpellSchool(v4->spell_id); + v25 = v4->spell_level; + v26 = v4->spell_id; + v50 = pMonster->sCurrentHP; + pMonsterName = (char *)v4->spell_skill; + //v27 = _43AFE3_calc_spell_damage(v26, v25, (signed int)pMonsterName, v50); + v59 = 0; + //v57 = (PlayerEquipment *)1; +//LABEL_65: + uDamageAmount = _43AFE3_calc_spell_damage(v26, v25, v4->spell_skill, v50); + //if ( !v57 ) + // goto LABEL_67; + goto LABEL_69; + } + v50 = pMonster->word_000086_some_monster_id; + a2 = 4; + v17 = player->CalculateRangedDamageTo(v50); + v19 = v4->stru_24.uItemID == 0; + uDamageAmount = v17; + v57 = 0; + if ( !v19 && v4->stru_24.uSpecEnchantmentType == 3 ) + { + a2 = 0; + v57 = (PlayerEquipment *)1; + } + if ( SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) >= 0 + && (SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) > 0 || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) ) + uDamageAmount >>= 1; + v59 = 1; +//LABEL_66: + if ( !v57 ) + goto LABEL_67; +LABEL_69: + if (player->Weak()) + uDamageAmount /= 1; + if ( (signed __int64)pMonster->pActorBuffs[5].uExpireTime > 0 ) + uDamageAmount = 0; + v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, uDamageAmount); + if ( !v4 && player->IsUnarmed() && (signed __int64)player->pPlayerBuffs[6].uExpireTime > 0 ) + { + v50 = player->pPlayerBuffs[6].uPower; + v29 = stru_50C198.CalcMagicalDamageToActor(pMonster, 8, v50); + v61 += v29; + } + uDamageAmount = v61; + if ( v59 ) + { + if ( v4 ) + { + a4 = v4->stru_24._439DF3_get_additional_damage(&a2, &v62); + if ( v62 && pMonster->sCurrentHP > 0 ) + { + player->sHealth += v61 / 5; + if ( player->sHealth > player->GetMaxHealth() ) + player->sHealth = player->GetMaxHealth(); + v62 = 0; + } + v30 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4); + uDamageAmount = v61 + v30; + } + else + { + v59 = 0; + v57 = &player->pEquipment; + do + { + if ( player->HasItemEquipped((ITEM_EQUIP_TYPE)v59) ) + { + auto _s = (ItemGen *)&player->pInventoryItems[v57->uShield - 1]; + a4 = _s->_439DF3_get_additional_damage(&a2, &v62); + if ( v62 && pMonster->sCurrentHP > 0 ) + { + player->sHealth += v61 / 5; + if ( player->sHealth > player->GetMaxHealth() ) + player->sHealth = player->GetMaxHealth(); + v62 = 0; + } + v31 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4); + uDamageAmount += v31; + } + ++v59; + v57 = (PlayerEquipment *)((char *)v57 + 4); + } + while ( v59 <= 1 ); + } + } + v32 = uDamageAmount; + pMonster->sCurrentHP -= uDamageAmount; + if ( !v32 && !hit_will_stun ) + { + player->PlaySound(SPEECH_52, 0); + return; + } + if ( pMonster->sCurrentHP > 0 ) + { + Actor::AI_Stun(uActorID_Monster_, a1, 0); + Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); + if ( bShowDamage ) + { + v50 = uDamageAmount; + pMonsterName = (char *)pMonster; + pPlayerName = player->pName; + if ( v4 ) + v47 = pGlobalTXT_LocalizationStrings[189];// "%s shoots %s for %lu points" + else + v47 = pGlobalTXT_LocalizationStrings[164];// "%s hits %s for %lu damage" + sprintfex(pTmpBuf.data(), v47, pPlayerName, pMonsterName, v50); + ShowStatusBarString(pTmpBuf.data(), 2u); + } + v41 = 0; + } + else + { + if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 ) + { + v33 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius; + //v55 = v33; + if ( pRenderer->pRenderD3D ) + { + if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) + { + v50 = 0; + pMonsterName = 0; + v34 = pMonster->vPosition.z; + *(float *)&pPlayerName = (double)v33; + //v51 = (unsigned __int64 *)v34; + *(float *)&v47 = 0.0; + v35 = pMonster->vPosition.y; + *((float *)&v46 + 1) = 0.0; + *(float *)&v46 = 1.0; + v36 = (double)(signed int)pMonster->vPosition.z; + //v51 = (unsigned __int64 *)v35; + v37 = v36; + //v51 = (unsigned __int64 *)pMonster->vPosition.x; + v38 = (double)v35; + v39 = (double)(signed int)pMonster->vPosition.x; + pDecalBuilder->AddBloodsplat(v39, v38, v37, 1.0, 0.0, 0.0, *(float *)&pPlayerName, 0, 0); + } + } + } + Actor::Die(uActorID_Monster_); + Actor::ApplyFineForKillingPeasant(uActorID_Monster_); + Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); + if ( pMonster->pMonsterInfo.uExp ) + GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp); + v40 = SPEECH_51; + if ( rand() % 100 < 20 ) + v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1; + player->PlaySound((PlayerSpeech)v40, 0); + v41 = 0; + if ( bShowDamage ) + { + v50 = (int)pMonster; + pMonsterName = (char *)uDamageAmount; + pPlayerName = player->pName; // "%s inflicts %lu points killing %s" + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[175], player->pName, uDamageAmount, pMonster); + ShowStatusBarString(pTmpBuf.data(), 2u); + } + } + if ( SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) >= (signed int)v41 + && (SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) > (signed int)v41 + || LODWORD(pMonster->pActorBuffs[20].uExpireTime) > v41) + && uDamageAmount != v41 ) + player->ReceiveDamage(uDamageAmount, (DAMAGE_TYPE)a2); + v50 = 24; + v59 = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP; + if ( (player->_48EA46_calc_special_bonus_by_items(24) || hit_will_stun != v41) + && stru_50C198.GetMagicalResistance(pMonster, 3u) ) + { + LODWORD(v42) = 20; + v59 = 10; + if ( pParty->bTurnBasedModeOn == v41 ) + v42 = (signed __int64)(flt_6BE3A8_debug_recmod2 * 42.66666666666666); + pMonster->pMonsterInfo.uRecoveryTime += v42; + if ( bShowDamage != v41 ) + { + v50 = (int)pMonster; + pMonsterName = player->pName; // "%s stuns %s" + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[635], player->pName, pMonster); + ShowStatusBarString(pTmpBuf.data(), 2u); + } + } + if ( hit_will_paralyze != v41 ) + { + if ( pMonster->CanAct() ) + { + if ( stru_50C198.GetMagicalResistance(pMonster, 3) ) + { + LOBYTE(v43) = player->GetActualSkillLevel(PLAYER_SKILL_MACE); + v44 = v43; + v45 = SkillToMastery(v43); + //v51 = (unsigned __int64 *)(7680 * (v44 & 0x3F)); + v46 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(7680 * (v44 & 0x3F)) * 0.033333335); + pMonster->pActorBuffs[6].Apply(v46, v45, 0, 0, 0); + if ( bShowDamage ) + { + v50 = (int)pMonster; + pMonsterName = player->pName; // "%s paralyzes %s" + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[636], player->pName, pMonster); + ShowStatusBarString(pTmpBuf.data(), 2u); + } + } + } + } + if ( v59 > 10 ) + v59 = 10; + if ( !MonsterStats::BelongsToSupertype(pMonster->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) + { + pVelocity->x = (unsigned __int64)(v59 * (signed __int64)pVelocity->x) >> 16; + pVelocity->y = (unsigned __int64)(v59 * (signed __int64)pVelocity->y) >> 16; + pVelocity->z = (unsigned __int64)(v59 * (signed __int64)pVelocity->z) >> 16; + pMonster->vVelocity.x = 50 * LOWORD(pVelocity->x); + pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y); + pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z); + } + Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61); +} +//----- (004BBF61) -------------------------------------------------------- +void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z) +{ + size_t v4; // esi@1 + int monster_id; // edi@1 + __int16 v6; // ax@4 + Actor *v7; // esi@5 + int v8; // eax@5 + MonsterInfo *v9; // edi@5 + MonsterDesc *v10; // ebx@5 + unsigned __int16 *v11; // ebx@5 + int v12; // ebx@7 + int v13; // eax@8 + __int16 x_; // [sp+8h] [bp-Ch]@1 + __int16 v15; // [sp+Ch] [bp-8h]@1 + __int16 v16; // [sp+10h] [bp-4h]@3 + signed int ya; // [sp+1Ch] [bp+8h]@5 + + v4 = uNumActors; + monster_id = a1; + x_ = x; + v15 = a1; + if ( (signed int)uNumActors < 500 + && ((signed int)pAllocator->uBigBufferSizeAligned >> 10) - ((signed int)pAllocator->uNextFreeOffsetInBigBuffer >> 10) >= 2000 ) + { + v16 = 0; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + v6 = pIndoor->GetSector(x, y, z); + v4 = uNumActors; + v16 = v6; + } + v7 = &pActors[v4]; + v7->Reset(); + v8 = monster_id; + v9 = &pMonsterStats->pInfos[monster_id]; + v10 = &pMonsterList->pMonsters[v8 - 1]; + strcpy(v7->pActorName, v9->pName); + v7->sCurrentHP = LOWORD(v9->uHP); + memcpy(&v7->pMonsterInfo, v9, 0x58u); + v7->word_000086_some_monster_id = v15; + v7->uActorRadius = v10->uMonsterRadius; + v7->uActorHeight = v10->uMonsterHeight; + v7->uMovementSpeed = v10->uMovementSpeed; + v7->vInitialPosition.x = x_; + v7->vPosition.x = x_; + BYTE2(v7->uAttributes) |= 8u; + v7->pMonsterInfo.uTreasureType = 0; + v7->pMonsterInfo.uTreasureLevel = 0; + v7->pMonsterInfo.uTreasureDiceSides = 0; + v7->pMonsterInfo.uTreasureDiceRolls = 0; + v7->pMonsterInfo.uTreasureDropChance = 0; + v7->vInitialPosition.y = y; + v7->vPosition.y = y; + v7->vInitialPosition.z = z; + v7->vPosition.z = z; + v7->uTetherDistance = 256; + v7->uSectorID = v16; + v7->uGroup = 1; + v7->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; + v7->PrepareSprites(0); + v11 = v10->pSoundSampleIDs; + ya = 4; + do + { + pSoundList->LoadSound((signed __int16)*v11, 0); + ++v11; + --ya; + } + while ( ya ); + v12 = 0; + do + LOWORD(v13) = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[v9->uSpell1ID], 1u); + while ( v13 ); + ++uNumActors; + } } \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef Chest.cpp --- a/Chest.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Chest.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -26,8 +26,8 @@ #include "mm7_data.h" #include "MM7.h" #include "SpriteObject.h" - - +#include "Mouse.h" +#include "Viewport.h" size_t uNumChests; // idb struct ChestList *pChestList; @@ -825,3 +825,49 @@ v3->Reset(); } // 506128: using guessed type int areWeLoadingTexture; +//----- (00420E01) -------------------------------------------------------- +void __cdecl OnChestLeftClick() +{ + int chest_id; // edi@1 + POINT *v1; // esi@2 + int v2; // eax@2 + int v3; // ebx@4 + int v4; // esi@6 + int v5; // ecx@6 + //SpriteObject v6; // [sp+Ch] [bp-80h]@1 + POINT v7; // [sp+7Ch] [bp-10h]@2 + POINT a2; // [sp+84h] [bp-8h]@2 + + SpriteObject v6; // [sp+Ch] [bp-80h]@1 + //SpriteObject::SpriteObject(&v6); + + chest_id = pGUIWindow_CurrentMenu->par1C; + if ( pParty->pPickedItem.uItemID ) + { + if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) ) + pMouse->RemoveHoldingItem(); + } + else + { + v1 = pMouse->GetCursorPos(&a2); + v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v7)->y]] & 0xFFFF; + if ( v2 ) + { + if ( v2 ) + v3 = v2 - 1; + else + v3 = -1; + v4 = pChests[chest_id].pInventoryIndices[v3] - 1; + if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == EQUIP_GOLD ) + { + party_finds_gold(pChests[chest_id].igChestItems[v4].uSpecEnchantmentType, 0); + viewparams->bRedrawGameUI = 1; + } + else + { + pParty->SetHoldingItem(&pChests[chest_id].igChestItems[v4]); + } + sub_420B13(v4, v3); + } + } +} \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef DecorationList.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DecorationList.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -0,0 +1,277 @@ +#include "Sprites.h" +#include "DecorationList.h" +#include "Allocator.h" +#include "MM7.h" +#include "FrameTableInc.h" +#include "mm7_data.h" +#include "Indoor.h" + +//----- (0045864C) -------------------------------------------------------- +void DecorationList::FromFile(void *pSerialized) +{ + uNumDecorations = *(int *)pSerialized; + pDecorations = (DecorationDesc *)pAllocator->AllocNamedChunk(pDecorations, + 84 * uNumDecorations, "Dec Descrip"); + memcpy(pDecorations, (char *)pSerialized + 4, 84 * uNumDecorations); +} + +//----- (00458693) -------------------------------------------------------- +void DecorationList::InitializeDecorationSprite(unsigned int uDecID) +{ + pSpriteFrameTable->InitializeSprite(this->pDecorations[uDecID].uSpriteID); +} + +//----- (004586B0) -------------------------------------------------------- +bool DecorationList::FromFileTxt(const char *Args) +{ + DecorationList *v2; // ebx@1 + FILE *v3; // eax@1 + unsigned int v4; // esi@3 + void *v5; // eax@10 + FILE *v6; // ST18_4@12 + char *i; // eax@12 + unsigned __int16 v8; // ax@16 + const char *v9; // ST20_4@16 + const char *v10; // ST18_4@16 + __int16 v11; // ax@16 + const char *v12; // ST14_4@16 + unsigned __int16 v13; // ax@16 + const char *v14; // ST10_4@16 + __int16 v15; // ax@16 + const char *v16; // ST0C_4@16 + unsigned __int8 v17; // al@16 + const char *v18; // ST08_4@16 + unsigned __int8 v19; // al@16 + const char *v20; // ST04_4@16 + unsigned __int8 v21; // al@16 + const char *v22; // ST00_4@16 + unsigned __int8 v23; // zf@16 + char v24; // sf@16 + unsigned __int8 v25; // of@16 + int j; // edi@17 + const char *v27; // esi@18 + int v28; // eax@19 + int v29; // eax@21 + int v30; // eax@23 + int v31; // eax@25 + int v32; // eax@27 + int v33; // eax@29 + int v34; // eax@31 + int v35; // eax@33 + FrameTableTxtLine v37; // [sp+Ch] [bp-460h]@17 + FrameTableTxtLine v38; // [sp+88h] [bp-3E4h]@13 + char Dest; // [sp+104h] [bp-368h]@17 + char Buf; // [sp+17Ch] [bp-2F0h]@3 + FrameTableTxtLine v41; // [sp+370h] [bp-FCh]@4 + FrameTableTxtLine v42; // [sp+3ECh] [bp-80h]@4 + FILE *File; // [sp+468h] [bp-4h]@1 + unsigned int Argsa; // [sp+474h] [bp+8h]@3 + + v2 = this; + v3 = fopen(Args, "r"); + File = v3; + if ( !v3 ) + Abortf("DecorationDescriptionList::load - Unable to open file: %s."); + v4 = 0; + Argsa = 0; + if ( fgets(&Buf, 490, v3) ) + { + do + { + *strchr(&Buf, 10) = 0; + memcpy(&v42, frame_table_txt_parser(&Buf, &v41), sizeof(v42)); + if ( v42.uPropCount && *v42.pProperties[0] != 47 && v42.uPropCount >= 3 ) + ++Argsa; + } + while ( fgets(&Buf, 490, File) ); + v4 = Argsa; + } + v2->uNumDecorations = v4; + v5 = pAllocator->AllocNamedChunk(v2->pDecorations, 84 * v4, "Dec Descrip"); + v2->pDecorations = (DecorationDesc *)v5; + if ( !v5 ) + Abortf("DecorationDescriptionList::load - Out of Memory!"); + v6 = File; + v2->uNumDecorations = 0; + fseek(v6, 0, 0); + for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) + { + *strchr(&Buf, 10) = 0; + memcpy(&v42, frame_table_txt_parser(&Buf, &v38), sizeof(v42)); + if ( v42.uPropCount && *v42.pProperties[0] != 47 && v42.uPropCount >= 3 ) + { + strcpy(v2->pDecorations[v2->uNumDecorations].pName, v42.pProperties[1]); + v8 = pSpriteFrameTable->FastFindSprite(v2->pDecorations[v2->uNumDecorations].pName); + v9 = v42.pProperties[2]; + v2->pDecorations[v2->uNumDecorations].uSpriteID = v8; + strcpy(v2->pDecorations[v2->uNumDecorations].field_20, v9); + v10 = v42.pProperties[3]; + v2->pDecorations[v2->uNumDecorations].uType = 0; + v11 = atoi(v10); + v12 = v42.pProperties[4]; + v2->pDecorations[v2->uNumDecorations].uRadius = v11; + v13 = atoi(v12); + v14 = v42.pProperties[5]; + v2->pDecorations[v2->uNumDecorations].uDecorationHeight = v13; + v15 = atoi(v14); + v16 = v42.pProperties[6]; + v2->pDecorations[v2->uNumDecorations].uLightRadius = v15; + v17 = atoi(v16); + v18 = v42.pProperties[7]; + v2->pDecorations[v2->uNumDecorations].uColoredLightRed = v17; + v19 = atoi(v18); + v20 = v42.pProperties[8]; + v2->pDecorations[v2->uNumDecorations].uColoredLightGreen = v19; + v21 = atoi(v20); + v22 = v42.pProperties[9]; + v2->pDecorations[v2->uNumDecorations].uColoredLightBlue = v21; + v2->pDecorations[v2->uNumDecorations].uSoundID = atoi(v22); + v25 = __OFSUB__(v42.uPropCount, 10); + v23 = v42.uPropCount == 10; + v24 = v42.uPropCount - 10 < 0; + v2->pDecorations[v2->uNumDecorations].uFlags = 0; + if ( !((unsigned __int8)(v24 ^ v25) | v23) ) + { + strcpy(&Dest, v42.pProperties[10]); + memcpy(&v41, frame_table_txt_parser(&Dest, &v37), sizeof(v41)); + for ( j = 0; j < v41.uPropCount; ++j ) + { + v27 = v41.pProperties[j]; + if ( _stricmp(v41.pProperties[j], "NBM") ) + { + if ( _stricmp(v27, "Invisible") ) + { + if ( _stricmp(v27, "FS") ) + { + if ( _stricmp(v27, "FM") ) + { + if ( _stricmp(v27, "FF") ) + { + if ( _stricmp(v27, "Marker") ) + { + if ( _stricmp(v27, "LoopSlow") ) + { + if ( _stricmp(v27, "EmitFire") ) + { + if ( _stricmp(v27, "Dawn") ) + { + if ( !_stricmp(v27, "Dusk") ) + HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 2u; + } + else + { + HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 1u; + } + } + else + { + v35 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; + *(char *)v35 |= 0x80u; + } + } + else + { + v34 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; + *(char *)v34 |= 0x40u; + } + } + else + { + v33 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; + *(char *)v33 |= 0x20u; + } + } + else + { + v32 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; + *(char *)v32 |= 0x10u; + } + } + else + { + v31 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; + *(char *)v31 |= 8u; + } + } + else + { + v30 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; + *(char *)v30 |= 4u; + } + } + else + { + v29 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; + *(char *)v29 |= 2u; + } + } + else + { + v28 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; + *(char *)v28 |= 1u; + } + } + } + ++v2->uNumDecorations; + } + } + fclose(File); + return 1; +} +//----- (00458600) -------------------------------------------------------- +void DecorationList::ToFile() +{ + DecorationList *v1; // esi@1 + FILE *v2; // eax@1 + FILE *v3; // edi@1 + + v1 = this; + v2 = fopen("data\\ddeclist.bin", "wb"); + v3 = v2; + if ( !v2 ) + Abortf("Unable to save ddeclist.bin!"); + fwrite(v1, 4u, 1u, v2); + fwrite(v1->pDecorations, 0x54u, v1->uNumDecorations, v3); + fclose(v3); +} +//----- (004583B0) -------------------------------------------------------- +LevelDecoration::LevelDecoration() +{ + this->field_1A = 0; + this->field_18 = 0; + this->vPosition.z = 0; + this->vPosition.y = 0; + this->vPosition.x = 0; + this->uDecorationDescID = 0; + this->field_2 = 0; + this->field_16_event_id = 0; + this->uCog = 0; +} +//----- (004488B6) -------------------------------------------------------- +unsigned __int16 DecorationList::GetDecorIdByName(const char *pName) +{ + DecorationList *v2; // esi@1 + signed int uID; // edi@2 + signed int v4; // ebx@3 + unsigned __int16 result; // ax@6 + + v2 = this; + if ( pName && (uID = 1, (signed int)this->uNumDecorations > 1) ) + { + v4 = 1; + while ( _stricmp(pName, v2->pDecorations[v4].pName) ) + { + ++uID; + ++v4; + if ( uID >= (signed int)v2->uNumDecorations ) + goto LABEL_6; + } + result = uID; + } + else + { +LABEL_6: + result = 0; + } + return result; +} \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef GUIButton.cpp --- a/GUIButton.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/GUIButton.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -3,7 +3,7 @@ #include "mm7_data.h" #include "LOD.h" - +#include "Texts.h" @@ -243,4 +243,14 @@ pIcons_LOD->GetTexture(uTextureID_ar_dn_dn), 0); ptr_507BA4 = pGUIWindow_CurrentMenu->CreateButton(440, 62, 16, 232, 1, 0, UIMSG_ClickAwardScrollBar, 0, 0, "", 0); } +} +//----- (004BCA33) -------------------------------------------------------- +void UI_CreateEndConversationButton() +{ + pDialogueWindow->Release(); + pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0); + pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, + pGlobalTXT_LocalizationStrings[74], //"End Conversation" + pIcons_LOD->GetTexture(uExitCancelTextureId), 0); + pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); } \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef GUIFont.cpp --- a/GUIFont.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/GUIFont.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -653,3 +653,14 @@ } return &temp_string[0]; } +//----- (00414162) -------------------------------------------------------- +void uGameUIFontMain_initialize() +{ + uGameUIFontMain = TargetColor(0xAu, 0, 0); +} + +//----- (00414174) -------------------------------------------------------- +void uGameUIFontShadow_initialize() +{ + uGameUIFontShadow = TargetColor(0xE6u, 214u, 193u); +} \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef GUIWindow.cpp --- a/GUIWindow.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/GUIWindow.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -25,6 +25,7 @@ #include "texts.h" #include "Autonotes.h" #include "Awards.h" +#include "Chest.h" #include "mm7_data.h" @@ -1883,4 +1884,702 @@ pDialogueWindow = 0; pMiscTimer->Resume(); pEventTimer->Resume(); +} +//----- (004156F0) -------------------------------------------------------- +void GUI_UpdateWindows() +{ + GUIWindow *pWindow; // esi@4 + //unsigned int pWindowType; // eax@4 + const char *pHint; // edx@66 + GUIButton *pButtonPtr_1C; // ebp@79 + char *pHint1; // edx@80 + int v26; // eax@98 + unsigned int v27; // ebp@106 + GUIWindow *pGUIWindow2; // ecx@109 + GUIFont *pGUIFont; // ST1C_4@115 + int v31; // eax@115 + GUIButton *pButton; // ebp@118 + int v39; // eax@129 + unsigned int pNumMessages; // eax@142 + GUIButton *pGUIButton; // ebp@146 + //unsigned int pX; // [sp-1Ch] [bp-124h]@17 + //unsigned int pY; // [sp-18h] [bp-120h]@17 + //Texture *pTexture; // [sp-14h] [bp-11Ch]@17 + //Texture *pTexture2; // [sp-14h] [bp-11Ch]@86 + int i; // [sp+0h] [bp-108h]@3 + ItemGen pItemGen; // [sp+4h] [bp-104h]@98 + GUIButton GUIButton2; // [sp+28h] [bp-E0h]@133 + ItemGen ItemGen2; // [sp+E4h] [bp-24h]@129 + + if (GetCurrentMenuID() != MENU_CREATEPARTY) + UI_OnKeyDown(VK_NEXT); + + for ( i = 1; i <= uNumVisibleWindows; ++i ) + { + pWindow = &pWindowList[pVisibleWindowsIdxs[i] - 1]; + switch (pWindow->eWindowType) + { + case WINDOW_OptionsButtons: + { + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_Y, + pViewport->uViewportTL_X, pIcons_LOD->GetTexture(uTextureID_Options)); + viewparams->bRedrawGameUI = 1; + continue; + } + case WINDOW_CharacterRecord: + { + CharacterUI_CharacterScreen_Draw(pPlayers[uActiveCharacter]); + continue; + } + case WINDOW_Options: + { + GameMenuUI_Options_Draw(); + continue; + } + case WINDOW_Book: + { + BookUI_Draw((WindowType)(int)pWindow->ptr_1C); + continue; + } + case WINDOW_Dialogue: + { + GameUI_DrawDialogue(); + continue; + } + case WINDOW_QuickReference: + { + GameUI_QuickRef_Draw(); + continue; + } + case WINDOW_Rest: + { + RestUI_Draw(); + continue; + } + case WINDOW_ChangeLocation: + { + TravelUI_Draw(); + continue; + } + case WINDOW_SpellBook: + { + DrawSpellBookContent(pPlayers[uActiveCharacter]); + continue; + } + case WINDOW_GreetingNPC: + { + GameUI_DrawBranchlessDialogue(); + continue; + } + case WINDOW_Chest: + { + if ( pCurrentScreen == SCREEN_CHEST ) + { + Chest::DrawChestUI((unsigned int)pWindow->ptr_1C); + } + else if ( pCurrentScreen == SCREEN_CHEST_INVENTORY ) + { + pRenderer->ClearZBuffer(0, 479); + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId)); + } + continue; + } + case WINDOW_SaveLoadButtons: + { + SaveUI_Draw(); + continue; + } + case WINDOW_MainMenu_Load: + { + LoadUI_Draw(); + continue; + } + case WINDOW_HouseInterior: + { + pWindowList[pVisibleWindowsIdxs[i] - 1].HouseDialogManager(); + if ( !window_SpeakInHouse ) + continue; + if ( (signed int)window_SpeakInHouse->ptr_1C >= 53 ) + continue; + if ( pParty->field_3C._shop_ban_times[(signed int)window_SpeakInHouse->ptr_1C] <=pParty->uTimePlayed ) + { + if ( (signed int)window_SpeakInHouse->ptr_1C < 53 ) + { + pParty->field_3C._shop_ban_times[(signed int)window_SpeakInHouse->ptr_1C] = 0; + } + continue; + } + pNumMessages = pMessageQueue_50CBD0->uNumMessages; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + continue; + } + case WINDOW_Transition: + { + TransitionUI_Draw(); + continue; + } + case WINDOW_Scroll: + { + CreateScrollWindow(); + continue; + } + case WINDOW_CastSpell_InInventory: + { + pRenderer->ClearZBuffer(0, 479); + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + CharacterUI_DrawPaperdoll(pPlayers[uActiveCharacter]); + pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uTextureID_x_x_u)); + continue; + } + case WINDOW_FinalWindow: + { + sub_41420D_press_esc(); + continue; + } + case WINDOW_50: + { + v27 = TargetColor(255, 255, 255); + if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) + { + ptr_507BD0->DrawMessageBox(0); + ptr_507BD0->DrawText(pFontCreate, 30, 40, v27, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0); + v31 = pFontCreate->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); + ptr_507BD0->DrawFlashingInputCursor(v31 + 30, 40, pFontCreate); + continue; + } + if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) + { + pWindow->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BD0->ptr_1C, 0, 0); + pEventTimer->Resume(); + ptr_507BD0->Release(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = true; + continue; + } + if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED) + { + pWindow->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + pEventTimer->Resume(); + ptr_507BD0->Release(); + continue; + } + } + case WINDOW_59: + { + pWindow->DrawMessageBox(0); + pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0); + pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0); + if ( !pKeyActionMap->field_204 ) + { + ItemGen2.Reset(); + pWindow->Release(); + pEventTimer->Resume(); + pCurrentScreen = 0; + viewparams->bRedrawGameUI = true; + v26 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); + if ( v26 > 0 ) + { + if ( v26 < 800 ) + { + ItemGen2.uAttributes |= 1u; + ItemGen2.uItemID = v26; + if ( pItemsTable->pItems[v26].uEquipType == 12 ) + { + ItemGen2.uNumCharges = rand() % 6 + pItemsTable->pItems[ItemGen2.uItemID].uDamageMod + 1; + ItemGen2.uMaxCharges = LOBYTE(ItemGen2.uNumCharges); + } + else + { + if ( v26 >= 221 && v26 < 271 ) + ItemGen2.uEnchantmentType = rand() % 10 + 1; + } + pItemsTable->SetSpecialBonus(&ItemGen2); + pParty->SetHoldingItem(&ItemGen2); + } + } + } + continue; + } + case WINDOW_PressedButton2: + { + if ( pWindow->Hint != (char *)1 ) + pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pButton = (GUIButton *)pWindow->ptr_1C; + if ( pButton->uX >= 0 && pButton->uX <= 640 ) + { + if ( pButton->uY >= 0 && pButton->uY <= 480 ) + { + pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]); + viewparams->bRedrawGameUI = 1; + if ( pWindow->Hint ) + { + if ( pWindow->Hint != (char *)1 ) + pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0); + } + pWindow->Release(); + continue; + } + } + viewparams->bRedrawGameUI = 1; + if ( pWindow->Hint ) + { + if ( pWindow->Hint != (char *)1 ) + pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0); + } + pWindow->Release(); + continue; + } + case WINDOW_CharactersPressedButton: + { + if ( pWindow->Hint != (char *)1 ) + pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pButton = (GUIButton *)pWindow->ptr_1C; + pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]); + viewparams->bRedrawGameUI = 1; + if ( pWindow->Hint ) + { + if ( pWindow->Hint != (char *)1 ) + pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0); + } + pWindow->Release(); + continue; + } + case WINDOW_PressedButton: + { + if ( pWindow->Hint != (char *)1 ) + pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pButton = (GUIButton *)pWindow->ptr_1C; + pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]); + viewparams->bRedrawGameUI = 1; + if ( pWindow->Hint ) + { + if ( pWindow->Hint != (char *)1 ) + pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0); + } + pWindow->Release(); + continue; + } + case WINDOW_5D: + { + if ( pWindow->Hint != (char *)1 ) + pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pButton = (GUIButton *)pWindow->ptr_1C; + pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]); + viewparams->bRedrawGameUI = 1; + pWindow->Release(); + continue; + } + case WINDOW_SaveLoadBtn: + { + if (pWindow->Hint != (char *)1) + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + pButton = (GUIButton *)pWindow->ptr_1C; + pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]); + pHint = pWindow->Hint; + viewparams->bRedrawGameUI = 1; + if ( pHint && pHint != (char *)1 ) + pButton->DrawLabel(pHint, pFontCreate, 0, 0); + pWindow->Release(); + if (pCurrentScreen == SCREEN_SAVEGAME) + pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0); + else + pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0); + continue; + } + case WINDOW_LoadGame_CancelBtn: + { + if ( pWindow->Hint != (char *)1 ) + pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); + pButton = (GUIButton *)pWindow->ptr_1C; + pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]); + viewparams->bRedrawGameUI = 1; + if ( pWindow->Hint && pWindow->Hint != (char *)1 ) + pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0); + pWindow->Release(); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + continue; + } + case WINDOW_CloseRestWindowBtn: + { + if ( pWindow->Hint != (char *)1 ) + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + pGUIButton = (GUIButton *)pWindow->ptr_1C; + pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton->pTextures[0]); + pHint = pWindow->Hint; + viewparams->bRedrawGameUI = 1; + if ( pHint && pHint != (char *)1 ) + pGUIButton->DrawLabel(pHint, pFontCreate, 0, 0); + pWindow->Release(); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + continue; + } + case WINDOW_ExitCharacterWindow: + { + if ( pWindow->Hint != (char *)1 ) + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + pButton = (GUIButton *)pWindow->ptr_1C; + pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]); + pHint = pWindow->Hint; + viewparams->bRedrawGameUI = 1; + if ( pHint && pHint != (char *)1 ) + pButton->DrawLabel(pHint, pFontCreate, 0, 0); + pWindow->Release(); + pNumMessages = pMessageQueue_50CBD0->uNumMessages; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + continue; + } + case WINDOW_RestWindow: + { + memset(&GUIButton2, 0, 0xBCu); + GUIButton2.uZ = 197; + GUIButton2.uW = 197; + GUIButton2.uX = 27; + GUIButton2.uY = 161; + GUIButton2.uWidth = 171; + GUIButton2.uHeight = 37; + GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 15)); + viewparams->bRedrawGameUI = 1; + GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0);//Отдых и лечение 8 часов + GUIButton2.pParent = 0; + pGUIWindow2 = pWindow; + pGUIWindow2->Release(); + continue; + } + case WINDOW_BooksWindow: + { + pButton = (GUIButton *)pWindow->ptr_1C; + pRenderer->DrawTextureIndexed(pWindow->uFrameY, + pWindow->uFrameX, pButton->pTextures[0]); + viewparams->bRedrawGameUI = true; + continue; + } + case WINDOW_CharacterWindow_Inventory: + { + pWindow->DrawMessageBox(0); + pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0); + pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0); + if ( !pKeyActionMap->field_204 ) + { + ItemGen2.Reset(); + pWindow->Release(); + pEventTimer->Resume(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + v39 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); + if ( v39 > 0 ) + { + if ( v39 < 800 ) + SpawnActor(v39); + } + } + continue; + } + case WINDOW_KeyMappingOptions: + { + GameMenuUI_DrawKeyBindings(); + continue; + } + case WINDOW_VideoOptions: + { + GameMenuUI_DrawVideoOptions(); + continue; + } + default: + { + continue; + } + } + } + if ( GetCurrentMenuID() == -1 ) + GameUI_DrawFoodAndGold(); + if ( sub_4637E0_is_there_popup_onscreen() ) + sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0); +} +//----- (00415485) -------------------------------------------------------- +void DrawCopyrightWindow() +{ + GUIWindow Dst; // [sp+8h] [bp-54h]@1 + + memset(&Dst, 0, 0x54u); + Dst.uFrameWidth = 624; + Dst.uFrameHeight = 256; + Dst.uFrameX = 8; + Dst.uFrameY = 30; // c 1999 The 3DO Company. + Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(pGlobalTXT_LocalizationStrings[157], &Dst, 24, 0) + + 2 * LOBYTE(pFontSmallnum->uFontHeight) + + 24; + Dst.uFrameY = 470 - Dst.uFrameHeight; + Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; + Dst.uFrameW = 469; + //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef"; + Dst.DrawMessageBox(0); + + Dst.uFrameWidth -= 24; + Dst.uFrameX += 12; + Dst.uFrameY += 12; + Dst.uFrameHeight -= 12; + Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; + Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1; + Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, pGlobalTXT_LocalizationStrings[157], 3); +} +//----- (0041420D) -------------------------------------------------------- +void __cdecl sub_41420D_press_esc() +{ + GUIWindow pWindow; // [sp+4h] [bp-54h]@1 + + sprintf(pTmpBuf2.data(), "%s\n \n%s", ptr_507BDC->Hint, pGlobalTXT_LocalizationStrings[61]);// Press Escape + pWindow.Hint = pTmpBuf2.data(); + pWindow.uFrameWidth = 400; + pWindow.uFrameHeight = 100; + pWindow.uFrameX = 120; + pWindow.uFrameY = 140; + pWindow.uFrameZ = 519; + pWindow.uFrameW = 239; + pWindow.DrawMessageBox(0); +} + +//----- (0041426F) -------------------------------------------------------- +void __cdecl sub_41426F() +{ + GUIWindow *pWindow; // ecx@1 + + pWindow = ptr_507BDC; + pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BDC->ptr_1C, 0, 0); + + pWindow->Release(); + ptr_507BDC = 0; + pCurrentScreen = dword_506F0C[0]; + pEventTimer->Resume(); +} +//----- (00410DEC) -------------------------------------------------------- +unsigned int __cdecl DrawLloydBeaconsScreen() +{ + Player *pPlayer; // esi@1 + char *v1; // eax@1 + unsigned __int16 v2; // ax@6 + unsigned int result; // eax@11 + unsigned int v4; // esi@13 + unsigned int v5; // ecx@13 + char v6; // zf@13 + LloydBeacon *v7; // esi@14 + int v8; // eax@14 + unsigned __int64 v9; // kr08_8@14 + unsigned int v10; // esi@14 + unsigned int v11; // eax@14 + char *v12; // eax@19 + char *v13; // ecx@22 + int v14; // eax@27 + Texture *v19; // [sp-4h] [bp-8Ch]@4 + GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1 + unsigned int v23; // [sp+64h] [bp-24h]@14 + __int64 v24; // [sp+68h] [bp-20h]@14 + unsigned int v25; // [sp+70h] [bp-18h]@13 + char *Str; // [sp+74h] [bp-14h]@14 + int v27; // [sp+78h] [bp-10h]@11 + LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12 + RGBTexture *v29; // [sp+80h] [bp-8h]@12 + int uNumMaxBeacons; // [sp+84h] [bp-4h]@6 + + pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid]; + pRenderer->DrawTextureIndexed(8u, 8u, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]); + v1 = pGlobalTXT_LocalizationStrings[523]; // Recall Beacon + pWindow.uFrameX = game_viewport_x; + pWindow.uFrameY = game_viewport_y; + pWindow.uFrameWidth = 428; + pWindow.uFrameHeight = game_viewport_height; + pWindow.uFrameZ = 435; + pWindow.uFrameW = game_viewport_w; + if ( !bRecallingBeacon ) + v1 = pGlobalTXT_LocalizationStrings[375]; // Set Beacon + sprintf(pTmpBuf.data(), "%s", v1); + pWindow.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf.data(), 3u); + if ( bRecallingBeacon ) + { + pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on); + v19 = pTex_tab_an_6a__zoom_off; + } + else + { + pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6a__zoom_off); + v19 = pTex_tab_an_6b__zoom_on; + } + pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19); + v2 = pPlayer->pActiveSkills[14]; + uNumMaxBeacons = 1; + if ( HIBYTE(v2) & 1 || (v2 & 0x80u) != 0 ) + { + uNumMaxBeacons = 5; + } + else + { + if ( v2 & 0x40 ) + uNumMaxBeacons = 3; + } + result = 0; + v27 = 0; + if ( uNumMaxBeacons > 0 ) + { + v29 = pSavegameThumbnails.data(); + v28 = pPlayer->pInstalledBeacons; + while ( 1 ) + { + pWindow.uFrameWidth = 92; + v4 = result; + pWindow.uFrameHeight = 68; + v5 = pLloydsBeaconsPreviewXs[result]; + pWindow.uFrameY = pLloydsBeaconsPreviewYs[result]; + v25 = pWindow.uFrameY; + pWindow.uFrameX = v5; + pWindow.uFrameW = pWindow.uFrameY + 67; + v6 = v29->pPixels == 0; + pWindow.uFrameZ = v5 + 91; + if ( !v6 ) + break; + if ( !bRecallingBeacon ) + { + pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook); + v14 = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0); + pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - v14 / 2, 1, pGlobalTXT_LocalizationStrings[19], 3); + } +LABEL_29: + ++v29; + ++v28; + result = v27++ + 1; + if ( v27 >= uNumMaxBeacons ) + goto LABEL_30; + } + pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook); + pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[v4], pLloydsBeaconsPreviewYs[v4], v29); + v7 = v28; + Str = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v28->field_18))].pName; + v8 = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0); + pWindow.uFrameY += -6 - v8; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1u, Str, 3u); + v9 = v7->uBeaconTime - pParty->uTimePlayed; + LODWORD(v24) = LODWORD(v7->uBeaconTime) - LODWORD(pParty->uTimePlayed); + HIDWORD(v24) = HIDWORD(v9); + v23 = (unsigned __int64)((signed __int64)((double)v24 * 0.234375) / 60 / 60) >> 32; + v10 = (signed __int64)((double)v24 * 0.234375) / 60 / 60; + v11 = v10 / 0x18; + if ( (unsigned int)((signed __int64)((double)v24 * 0.234375) / 60 / 60) / 0x18 ) + { + v13 = pGlobalTXT_LocalizationStrings[57]; // Days + if ( v11 > 1 ) + { + sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13); + pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); + goto LABEL_29; + } + } + else + { + if ( (signed __int64)(__PAIR__(v23, v10) + 1) <= 23 ) + { + if ( (v23 & 0x80000000u) != 0 || (signed int)v23 <= 0 && v10 <= 1 ) + v12 = pGlobalTXT_LocalizationStrings[109];// Hour + else + v12 = pGlobalTXT_LocalizationStrings[110];// Hours + sprintf(pTmpBuf.data(), "%lu %s", v10 + 1, v12); + pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); + goto LABEL_29; + } + } + v13 = pGlobalTXT_LocalizationStrings[56]; // Day + sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13); + pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; + pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); + goto LABEL_29; + } +LABEL_30: + if ( byte_506360 ) + { + /*result = pMessageQueue_50CBD0->uNumMessages; + if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CloseAfterInstallBeacon; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; + result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; + *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_CloseAfterInstallBeacon, 0, 0); + } + return result; +} +//----- (00467FB6) -------------------------------------------------------- +void CreateScrollWindow() + { + unsigned int v0; // eax@1 + char *v1; // ST18_4@3 + unsigned int v2; // eax@3 + GUIWindow a1; // [sp+Ch] [bp-54h]@1 + + memcpy(&a1, pGUIWindow_ScrollWindow, sizeof(a1)); + a1.Hint = 0; + a1.uFrameX = 1; + a1.uFrameY = 1; + a1.uFrameWidth = 468; + v0 = pFontSmallnum->CalcTextHeight(pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C], &a1, 0, 0) + + 2 * LOBYTE(pFontCreate->uFontHeight) + + 24; + a1.uFrameHeight = v0; + if ( (signed int)(v0 + a1.uFrameY) > 479 ) + { + v0 = 479 - a1.uFrameY; + a1.uFrameHeight = 479 - a1.uFrameY; + } + a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1; + a1.uFrameW = v0 + a1.uFrameY - 1; + a1.DrawMessageBox(0); + a1.uFrameX += 12; + a1.uFrameWidth -= 24; + a1.uFrameY += 12; + a1.uFrameHeight -= 12; + a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1; + a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1; + v1 = pItemsTable->pItems[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C + 700].pName; + v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + sprintf(pTmpBuf.data(), format_4E2D80, v2, v1); + a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3u); + a1.DrawText( + pFontSmallnum, + 1, + LOBYTE(pFontCreate->uFontHeight) - 3, + 0, + pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C], + 0, + 0, + 0); +} +//----- (00467F48) -------------------------------------------------------- +void CreateMsgScrollWindow( signed int mscroll_id ) + { + signed int v1; // esi@1 + + v1 = mscroll_id; + if ( !pGUIWindow_ScrollWindow && mscroll_id >= 700 ) + { + if ( mscroll_id <= 782 ) + { + uTextureID_720980 = pIcons_LOD->LoadTexture("leather", TEXTURE_16BIT_PALETTE); + pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Scroll, v1 - 700, 0); + } + } +} +//----- (00467F9F) -------------------------------------------------------- +void __cdecl free_book_subwindow() +{ + if ( pGUIWindow_ScrollWindow ) + { + pGUIWindow_ScrollWindow->Release(); + pGUIWindow_ScrollWindow = 0; + } } \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef Indoor.cpp --- a/Indoor.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Indoor.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -42,8 +42,8 @@ #include "stru6.h" #include "ParticleEngine.h" #include "Outdoor_stuff.h" - - +#include "texts.h" +#include "GUIWindow.h" @@ -5886,4 +5886,1806 @@ result = (unsigned __int64)(v7->field_1C * (signed __int64)v7->field_4_party_dir_y) >> 16; v7->field_28 = v31 + result + ((unsigned __int64)(v7->field_20 * (signed __int64)v7->field_8) >> 16); return result; +} +//----- (00407A1C) -------------------------------------------------------- +bool __fastcall sub_407A1C(int x, int z, int y, Vec3_int_ v) +{ + unsigned int v4; // esi@1 + Vec3_int_ v5; // ST08_12@2 + int v6; // edi@2 + int v7; // ebx@2 + int v8; // esi@2 + signed int v9; // ecx@2 + int v10; // eax@2 + int v11; // ecx@4 + int v12; // eax@4 + int v13; // ebx@4 + int v14; // edx@6 + char *v15; // edi@16 + ODMFace *v16; // esi@19 + int v17; // ST34_4@25 + int v18; // ST38_4@25 + int v19; // eax@25 + char v20; // zf@25 + int v21; // ebx@25 + int v22; // eax@26 + signed int v23; // edi@26 + int v24; // ST34_4@30 + signed __int64 v25; // qtt@31 + int v26; // eax@31 + Vec3_int_ v27; // ST08_12@37 + Vec3_int_ v28; // ST08_12@37 + int v29; // edi@37 + int v30; // ebx@37 + int v31; // esi@37 + signed int v32; // ecx@37 + int v33; // eax@37 + int v34; // ecx@39 + int v35; // eax@39 + int v36; // ebx@39 + int v37; // edx@41 + char *v38; // edi@51 + ODMFace *v39; // esi@54 + int v40; // ebx@60 + int v41; // eax@61 + signed int v42; // edi@61 + signed __int64 v43; // qtt@66 + int v44; // eax@66 + Vec3_int_ v45; // ST08_12@73 + int v46; // edi@73 + int v47; // ebx@73 + int v48; // esi@73 + signed int v49; // ecx@73 + int v50; // eax@73 + int v51; // edx@75 + int v52; // ecx@75 + int v53; // eax@75 + int v54; // ebx@75 + int v55; // edi@77 + int v56; // ecx@77 + int v57; // eax@81 + int v58; // esi@81 + int v59; // eax@90 + BLVSector *v60; // edx@90 + int v61; // ecx@90 + BLVFace *v62; // esi@91 + int v63; // ST34_4@98 + int v64; // ST30_4@98 + int v65; // eax@98 + int v66; // ebx@98 + int v67; // eax@99 + signed int v68; // edi@99 + int v69; // ST2C_4@103 + signed __int64 v70; // qtt@104 + int v71; // eax@104 + Vec3_int_ v72; // ST08_12@111 + Vec3_int_ v73; // ST08_12@111 + int v74; // edi@111 + int v75; // ebx@111 + int v76; // esi@111 + signed int v77; // ecx@111 + int v78; // eax@111 + int v79; // edx@113 + int v80; // ecx@113 + int v81; // eax@113 + int v82; // ebx@113 + int v83; // edi@115 + int v84; // ecx@115 + int v85; // eax@119 + int v86; // esi@119 + int v87; // ecx@128 + BLVSector *v88; // eax@128 + int v89; // ecx@128 + BLVFace *v90; // esi@129 + int v91; // ebx@136 + int v92; // eax@137 + signed int v93; // edi@137 + signed __int64 v94; // qtt@142 + int v95; // eax@142 + Vec3_int_ v97; // [sp-18h] [bp-94h]@1 + int v98; // [sp-Ch] [bp-88h]@88 + int v99; // [sp-Ch] [bp-88h]@126 + int v100; // [sp-8h] [bp-84h]@88 + int v101; // [sp-8h] [bp-84h]@126 + int v102; // [sp-4h] [bp-80h]@88 + int v103; // [sp-4h] [bp-80h]@126 + int v104; // [sp+Ch] [bp-70h]@13 + int v105; // [sp+Ch] [bp-70h]@48 + int v106; // [sp+10h] [bp-6Ch]@18 + int v107; // [sp+10h] [bp-6Ch]@98 + int v108; // [sp+10h] [bp-6Ch]@104 + int v109; // [sp+18h] [bp-64h]@25 + int v110; // [sp+18h] [bp-64h]@31 + int i; // [sp+18h] [bp-64h]@90 + int v112; // [sp+18h] [bp-64h]@128 + signed int v113; // [sp+20h] [bp-5Ch]@1 + signed int v114; // [sp+24h] [bp-58h]@1 + unsigned __int64 a4; // [sp+28h] [bp-54h]@1 + unsigned int a4_8; // [sp+30h] [bp-4Ch]@1 + int v117; // [sp+34h] [bp-48h]@4 + int v118; // [sp+34h] [bp-48h]@39 + int v119; // [sp+34h] [bp-48h]@75 + int v120; // [sp+34h] [bp-48h]@113 + int v121; // [sp+38h] [bp-44h]@4 + int v122; // [sp+38h] [bp-44h]@39 + int v123; // [sp+38h] [bp-44h]@76 + int v124; // [sp+38h] [bp-44h]@114 + int v125; // [sp+3Ch] [bp-40h]@4 + int v126; // [sp+3Ch] [bp-40h]@39 + int v127; // [sp+3Ch] [bp-40h]@77 + int v128; // [sp+3Ch] [bp-40h]@115 + int v129; // [sp+40h] [bp-3Ch]@11 + int v130; // [sp+40h] [bp-3Ch]@46 + int v131; // [sp+40h] [bp-3Ch]@78 + int v132; // [sp+40h] [bp-3Ch]@116 + int v133; // [sp+44h] [bp-38h]@10 + int v134; // [sp+44h] [bp-38h]@45 + int v135; // [sp+44h] [bp-38h]@81 + int v136; // [sp+44h] [bp-38h]@119 + int v137; // [sp+48h] [bp-34h]@7 + int v138; // [sp+48h] [bp-34h]@42 + int v139; // [sp+48h] [bp-34h]@82 + int v140; // [sp+48h] [bp-34h]@120 + int v141; // [sp+4Ch] [bp-30h]@6 + int v142; // [sp+4Ch] [bp-30h]@41 + int v143; // [sp+4Ch] [bp-30h]@75 + int v144; // [sp+4Ch] [bp-30h]@113 + int v145; // [sp+50h] [bp-2Ch]@5 + int v146; // [sp+50h] [bp-2Ch]@40 + int v147; // [sp+50h] [bp-2Ch]@75 + int v148; // [sp+50h] [bp-2Ch]@113 + int v149; // [sp+54h] [bp-28h]@4 + int v150; // [sp+54h] [bp-28h]@39 + int v151; // [sp+54h] [bp-28h]@75 + int v152; // [sp+54h] [bp-28h]@113 + int sDepth; // [sp+58h] [bp-24h]@17 + int sDeptha; // [sp+58h] [bp-24h]@52 + int sDepthb; // [sp+58h] [bp-24h]@90 + char *a5; // [sp+5Ch] [bp-20h]@16 + char *a5a; // [sp+5Ch] [bp-20h]@51 + signed int a5b; // [sp+5Ch] [bp-20h]@83 + signed int a5c; // [sp+5Ch] [bp-20h]@121 + signed int v160; // [sp+60h] [bp-1Ch]@12 + signed int v161; // [sp+60h] [bp-1Ch]@47 + int v162; // [sp+60h] [bp-1Ch]@128 + int v163; // [sp+64h] [bp-18h]@2 + int outx; // [sp+68h] [bp-14h]@2 + int outy; // [sp+6Ch] [bp-10h]@2 + int outz; // [sp+70h] [bp-Ch]@2 + Vec3_int_ pOut; // [sp+74h] [bp-8h]@2 + int ya; // [sp+84h] [bp+8h]@60 + int yb; // [sp+84h] [bp+8h]@136 + int ve; // [sp+88h] [bp+Ch]@60 + int va; // [sp+88h] [bp+Ch]@60 + int vb; // [sp+88h] [bp+Ch]@66 + int vf; // [sp+88h] [bp+Ch]@136 + int vc; // [sp+88h] [bp+Ch]@136 + int vd; // [sp+88h] [bp+Ch]@142 + int v_4; // [sp+8Ch] [bp+10h]@60 + int v_4a; // [sp+8Ch] [bp+10h]@65 + int v_4b; // [sp+8Ch] [bp+10h]@136 + int v_4c; // [sp+8Ch] [bp+10h]@141 + int v_8; // [sp+90h] [bp+14h]@53 + + a4 = __PAIR__(z, x); + v4 = stru_5C6E00->Atan2(v.x - x, v.y - z); + v114 = 0; + v97.z = y; + v113 = 0; + a4_8 = v4; + *(_QWORD *)&v97.x = a4; + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) + { + Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz); + v45.z = v.z; + *(_QWORD *)&v45.x = *(_QWORD *)&v; + Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v45, &outx, &outy, &v163); + v46 = outy - pOut.y; + v47 = v163 - outz; + v48 = outx - pOut.x; + v49 = integer_sqrt(v48 * v48 + v46 * v46 + v47 * v47); + v50 = 65536; + if ( v49 ) + v50 = 65536 / v49; + v51 = outx; + v143 = v48 * v50; + v52 = v46 * v50; + v53 = v47 * v50; + v54 = pOut.x; + v147 = v52; + v151 = v53; + v119 = pOut.x; + if ( pOut.x < outx ) + { + v123 = outx; + } + else + { + v119 = outx; + v123 = pOut.x; + } + v55 = pOut.y; + v56 = outy; + v127 = pOut.y; + if ( pOut.y < outy ) + { + v131 = outy; + } + else + { + v127 = outy; + v131 = pOut.y; + } + v57 = v163; + v58 = outz; + v135 = outz; + if ( outz < v163 ) + { + v139 = v163; + } + else + { + v135 = v163; + v139 = outz; + } + a5b = 0; + while ( !v114 ) + { + if ( a5b ) + { + v102 = v58; + v100 = v55; + v98 = v54; + } + else + { + v102 = v57; + v100 = v56; + v98 = v51; + } + v59 = pIndoor->GetSector(v98, v100, v102); + v60 = pIndoor->pSectors; + v61 = 116 * v59; + sDepthb = 0; + for ( i = 116 * v59; + sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v61) + + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61); + ++sDepthb ) + { + v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]]; + if ( v62->Portal() + || v119 > v62->pBounding.x2 + || v123 < v62->pBounding.x1 + || v127 > v62->pBounding.y2 + || v131 < v62->pBounding.y1 + || v135 > v62->pBounding.z2 + || v139 < v62->pBounding.z1 + || (v63 = (unsigned __int64)(v143 * (signed __int64)v62->pFacePlane_old.vNormal.x) >> 16, + v64 = (unsigned __int64)(v151 * (signed __int64)v62->pFacePlane_old.vNormal.z) >> 16, + v65 = (unsigned __int64)(v147 * (signed __int64)v62->pFacePlane_old.vNormal.y) >> 16, + v20 = v63 + v64 + v65 == 0, + v66 = v63 + v64 + v65, + v107 = v63 + v64 + v65, + v20) ) + goto LABEL_107; + v67 = outz * v62->pFacePlane_old.vNormal.z; + v68 = -(v62->pFacePlane_old.dist + + v67 + + pOut.y * v62->pFacePlane_old.vNormal.y + + pOut.x * v62->pFacePlane_old.vNormal.x); + if ( v66 <= 0 ) + { + if ( v62->pFacePlane_old.dist + + v67 + + pOut.y * v62->pFacePlane_old.vNormal.y + + pOut.x * v62->pFacePlane_old.vNormal.x < 0 ) + goto LABEL_107; + } + else + { + if ( v62->pFacePlane_old.dist + + v67 + + pOut.y * v62->pFacePlane_old.vNormal.y + + pOut.x * v62->pFacePlane_old.vNormal.x > 0 ) + goto LABEL_107; + } + v69 = abs(-(v62->pFacePlane_old.dist + + v67 + + pOut.y * v62->pFacePlane_old.vNormal.y + + pOut.x * v62->pFacePlane_old.vNormal.x)) >> 14; + if ( v69 <= abs(v66) ) + { + LODWORD(v70) = v68 << 16; + HIDWORD(v70) = v68 >> 16; + v71 = v70 / v107; + v108 = v70 / v107; + if ( v71 >= 0 ) + { + if ( sub_4075DB( + pOut.x + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v143) >> 16) + 32768) >> 16), + pOut.y + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v147) >> 16) + 32768) >> 16), + outz + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v151) >> 16) + 32768) >> 16), + v62) ) + { + v114 = 1; + break; + } + } + } + v61 = i; +LABEL_107: + v60 = pIndoor->pSectors; + } + ++a5b; + if ( a5b >= 2 ) + break; + v57 = v163; + v56 = outy; + v51 = outx; + v58 = outz; + v55 = pOut.y; + v54 = pOut.x; + } + v72.z = y; + *(_QWORD *)&v72.x = a4; + Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &pOut.x, &pOut.y, &outz); + v73.z = v.z; + *(_QWORD *)&v73.x = *(_QWORD *)&v; + Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v73, &outx, &outy, &v163); + v74 = outy - pOut.y; + v75 = v163 - outz; + v76 = outx - pOut.x; + v77 = integer_sqrt(v76 * v76 + v74 * v74 + v75 * v75); + v78 = 65536; + if ( v77 ) + v78 = 65536 / v77; + v79 = outx; + v144 = v76 * v78; + v80 = v74 * v78; + v81 = v75 * v78; + v82 = pOut.x; + v148 = v80; + v152 = v81; + v120 = pOut.x; + if ( pOut.x < outx ) + { + v124 = outx; + } + else + { + v120 = outx; + v124 = pOut.x; + } + v83 = pOut.y; + v84 = outy; + v128 = pOut.y; + if ( pOut.y < outy ) + { + v132 = outy; + } + else + { + v128 = outy; + v132 = pOut.y; + } + v85 = v163; + v86 = outz; + v136 = outz; + if ( outz < v163 ) + { + v140 = v163; + } + else + { + v136 = v163; + v140 = outz; + } + a5c = 0; + while ( 1 ) + { + if ( v113 ) + return !v114 || !v113; + if ( a5c ) + { + v103 = v86; + v101 = v83; + v99 = v82; + } + else + { + v103 = v85; + v101 = v84; + v99 = v79; + } + v87 = pIndoor->GetSector(v99, v101, v103); + v88 = pIndoor->pSectors; + v89 = 116 * v87; + v162 = 0; + v112 = v89; + if ( *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89) + + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 ) + break; +LABEL_148: + ++a5c; + if ( a5c >= 2 ) + return !v114 || !v113; + v85 = v163; + v84 = outy; + v79 = outx; + v86 = outz; + v83 = pOut.y; + v82 = pOut.x; + } + while ( 1 ) + { + v90 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v88->pWalls + v89))[v162]]; + if ( v90->Portal() + || v120 > v90->pBounding.x2 + || v124 < v90->pBounding.x1 + || v128 > v90->pBounding.y2 + || v132 < v90->pBounding.y1 + || v136 > v90->pBounding.z2 + || v140 < v90->pBounding.z1 + || (yb = (unsigned __int64)(v144 * (signed __int64)v90->pFacePlane_old.vNormal.x) >> 16, + v_4b = (unsigned __int64)(v148 * (signed __int64)v90->pFacePlane_old.vNormal.y) >> 16, + vf = (unsigned __int64)(v152 * (signed __int64)v90->pFacePlane_old.vNormal.z) >> 16, + v20 = yb + vf + v_4b == 0, + v91 = yb + vf + v_4b, + vc = yb + vf + v_4b, + v20) ) + goto LABEL_145; + v92 = outz * v90->pFacePlane_old.vNormal.z; + v93 = -(v90->pFacePlane_old.dist + + v92 + + pOut.y * v90->pFacePlane_old.vNormal.y + + pOut.x * v90->pFacePlane_old.vNormal.x); + if ( v91 <= 0 ) + { + if ( v90->pFacePlane_old.dist + + v92 + + pOut.y * v90->pFacePlane_old.vNormal.y + + pOut.x * v90->pFacePlane_old.vNormal.x < 0 ) + goto LABEL_145; + } + else + { + if ( v90->pFacePlane_old.dist + + v92 + + pOut.y * v90->pFacePlane_old.vNormal.y + + pOut.x * v90->pFacePlane_old.vNormal.x > 0 ) + goto LABEL_145; + } + v_4c = abs(-(v90->pFacePlane_old.dist + + v92 + + pOut.y * v90->pFacePlane_old.vNormal.y + + pOut.x * v90->pFacePlane_old.vNormal.x)) >> 14; + if ( v_4c <= abs(v91) ) + { + LODWORD(v94) = v93 << 16; + HIDWORD(v94) = v93 >> 16; + v95 = v94 / vc; + vd = v94 / vc; + if ( v95 >= 0 ) + { + if ( sub_4075DB( + pOut.x + ((signed int)(((unsigned __int64)(vd * (signed __int64)v144) >> 16) + 32768) >> 16), + pOut.y + ((signed int)(((unsigned __int64)(vd * (signed __int64)v148) >> 16) + 32768) >> 16), + outz + ((signed int)(((unsigned __int64)(vd * (signed __int64)v152) >> 16) + 32768) >> 16), + v90) ) + { + v113 = 1; + goto LABEL_148; + } + } + } + v89 = v112; +LABEL_145: + v88 = pIndoor->pSectors; + ++v162; + if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89) + + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) ) + goto LABEL_148; + } + } + Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz); + v5.z = v.z; + *(_QWORD *)&v5.x = *(_QWORD *)&v; + Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v5, &outx, &outy, &v163); + v6 = outy - pOut.y; + v7 = v163 - outz; + v8 = outx - pOut.x; + v9 = integer_sqrt(v8 * v8 + v6 * v6 + v7 * v7); + v10 = 65536; + if ( v9 ) + v10 = 65536 / v9; + v125 = v8 * v10; + v11 = v10; + v12 = v7 * v10; + v13 = pOut.x; + v117 = v12; + v121 = v6 * v11; + v149 = pOut.x; + if ( pOut.x < outx ) + { + v145 = outx; + } + else + { + v149 = outx; + v145 = pOut.x; + } + v14 = outy; + v141 = pOut.y; + if ( pOut.y < outy ) + { + v137 = outy; + } + else + { + v141 = outy; + v137 = pOut.y; + } + v133 = outz; + if ( outz < v163 ) + { + v129 = v163; + } + else + { + v133 = v163; + v129 = outz; + } + v160 = 0; + if ( (signed int)pOutdoor->uNumBModels > 0 ) + { + v104 = 0; + while ( 1 ) + { + v15 = (char *)&pOutdoor->pBModels[v104].pVertices; + a5 = (char *)&pOutdoor->pBModels[v104].pVertices; + if ( sub_4088E9(v13, pOut.y, outx, v14, pOutdoor->pBModels[v104].vPosition.x, pOutdoor->pBModels[v104].vPosition.y) <= pOutdoor->pBModels[v104].sBoundingRadius + 128 ) + { + sDepth = 0; + if ( *((int *)v15 + 2) > 0 ) + break; + } +LABEL_36: + ++v160; + ++v104; + if ( v160 >= (signed int)pOutdoor->uNumBModels ) + goto LABEL_37; + v14 = outy; + v13 = pOut.x; + } + v106 = 0; + while ( 1 ) + { + v16 = (ODMFace *)(v106 + *((int *)a5 + 4)); + if ( v149 > v16->pBoundingBox.x2 + || v145 < v16->pBoundingBox.x1 + || v141 > v16->pBoundingBox.y2 + || v137 < v16->pBoundingBox.y1 + || v133 > v16->pBoundingBox.z2 + || v129 < v16->pBoundingBox.z1 + || (v17 = (unsigned __int64)(v125 * (signed __int64)v16->pFacePlane.vNormal.x) >> 16, + v18 = (unsigned __int64)(v121 * (signed __int64)v16->pFacePlane.vNormal.y) >> 16, + v19 = (unsigned __int64)(v117 * (signed __int64)v16->pFacePlane.vNormal.z) >> 16, + v20 = v17 + v18 + v19 == 0, + v21 = v17 + v18 + v19, + v109 = v17 + v18 + v19, + v20) ) + goto LABEL_33; + v22 = pOut.y * v16->pFacePlane.vNormal.y; + v23 = -(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x); + if ( v21 <= 0 ) + { + if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x < 0 ) + goto LABEL_33; + } + else + { + if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x > 0 ) + goto LABEL_33; + } + v24 = abs(-(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x)) >> 14; + if ( v24 <= abs(v21) ) + { + LODWORD(v25) = v23 << 16; + HIDWORD(v25) = v23 >> 16; + v26 = v25 / v109; + v110 = v25 / v109; + if ( v26 >= 0 ) + { + if ( sub_4077F1( + pOut.x + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v125) >> 16) + 32768) >> 16), + pOut.y + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v121) >> 16) + 32768) >> 16), + outz + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v117) >> 16) + 32768) >> 16), + v16, + (BSPVertexBuffer *)a5) ) + { + v114 = 1; + goto LABEL_36; + } + } + } +LABEL_33: + ++sDepth; + v106 += 308; + if ( sDepth >= *((int *)a5 + 2) ) + goto LABEL_36; + } + } +LABEL_37: + v27.z = y; + *(_QWORD *)&v27.x = a4; + Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &pOut.x, &pOut.y, &outz); + v28.z = v.z; + *(_QWORD *)&v28.x = *(_QWORD *)&v; + Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v28, &outx, &outy, &v163); + v29 = outy - pOut.y; + v30 = v163 - outz; + v31 = outx - pOut.x; + v32 = integer_sqrt(v31 * v31 + v29 * v29 + v30 * v30); + v33 = 65536; + if ( v32 ) + v33 = 65536 / v32; + v126 = v31 * v33; + v34 = v33; + v35 = v30 * v33; + v36 = pOut.x; + v118 = v35; + v122 = v29 * v34; + v150 = pOut.x; + if ( pOut.x < outx ) + { + v146 = outx; + } + else + { + v150 = outx; + v146 = pOut.x; + } + v37 = outy; + v142 = pOut.y; + if ( pOut.y < outy ) + { + v138 = outy; + } + else + { + v142 = outy; + v138 = pOut.y; + } + v134 = outz; + if ( outz < v163 ) + { + v130 = v163; + } + else + { + v134 = v163; + v130 = outz; + } + v161 = 0; + if ( (signed int)pOutdoor->uNumBModels > 0 ) + { + v105 = 0; + while ( 1 ) + { + v38 = (char *)&pOutdoor->pBModels[v105].pVertices; + a5a = (char *)&pOutdoor->pBModels[v105].pVertices; + if ( sub_4088E9(v36, pOut.y, outx, v37, pOutdoor->pBModels[v105].vPosition.x, pOutdoor->pBModels[v105].vPosition.y) <= pOutdoor->pBModels[v105].sBoundingRadius + 128 ) + { + sDeptha = 0; + if ( *((int *)v38 + 2) > 0 ) + break; + } +LABEL_71: + ++v161; + ++v105; + if ( v161 >= (signed int)pOutdoor->uNumBModels ) + return !v114 || !v113; + v37 = outy; + v36 = pOut.x; + } + v_8 = 0; + while ( 1 ) + { + v39 = (ODMFace *)(v_8 + *((int *)a5a + 4)); + if ( v150 > v39->pBoundingBox.x2 + || v146 < v39->pBoundingBox.x1 + || v142 > v39->pBoundingBox.y2 + || v138 < v39->pBoundingBox.y1 + || v134 > v39->pBoundingBox.z2 + || v130 < v39->pBoundingBox.z1 + || (ya = (unsigned __int64)(v126 * (signed __int64)v39->pFacePlane.vNormal.x) >> 16, + ve = (unsigned __int64)(v122 * (signed __int64)v39->pFacePlane.vNormal.y) >> 16, + v_4 = (unsigned __int64)(v118 * (signed __int64)v39->pFacePlane.vNormal.z) >> 16, + v20 = ya + ve + v_4 == 0, + v40 = ya + ve + v_4, + va = ya + ve + v_4, + v20) ) + goto LABEL_68; + v41 = pOut.y * v39->pFacePlane.vNormal.y; + v42 = -(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x); + if ( v40 <= 0 ) + { + if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x < 0 ) + goto LABEL_68; + } + else + { + if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x > 0 ) + goto LABEL_68; + } + v_4a = abs(-(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x)) >> 14; + if ( v_4a <= abs(v40) ) + { + LODWORD(v43) = v42 << 16; + HIDWORD(v43) = v42 >> 16; + v44 = v43 / va; + vb = v43 / va; + if ( v44 >= 0 ) + { + if ( sub_4077F1( + pOut.x + ((signed int)(((unsigned __int64)(vb * (signed __int64)v126) >> 16) + 32768) >> 16), + pOut.y + ((signed int)(((unsigned __int64)(vb * (signed __int64)v122) >> 16) + 32768) >> 16), + outz + ((signed int)(((unsigned __int64)(vb * (signed __int64)v118) >> 16) + 32768) >> 16), + v39, + (BSPVertexBuffer *)a5a) ) + { + v113 = 1; + goto LABEL_71; + } + } + } +LABEL_68: + ++sDeptha; + v_8 += 308; + if ( sDeptha >= *((int *)a5a + 2) ) + goto LABEL_71; + } + } + return !v114 || !v113; +} +//----- (0043F333) -------------------------------------------------------- +void BspRenderer::MakeVisibleSectorList() +{ + int v6; // ebx@3 + + uNumVisibleNotEmptySectors = 0; + for (uint i = 0; i < num_nodes; ++i) + { + if (!uNumVisibleNotEmptySectors) + { + pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID; + continue; + } + + v6 = 0; + while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != nodes[i].uSectorID ) + { + ++v6; + if ( v6 >= uNumVisibleNotEmptySectors) + { + pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID; + } + } + + } +} +//----- (0046A334) -------------------------------------------------------- +char __fastcall DoInteractionWithTopmostZObject(int a1, int a2) +{ + int v2; // edx@1 + BLVFace *v4; // eax@9 + unsigned int v5; // ecx@9 + unsigned __int16 v6; // ax@11 + //ODMFace *v7; // eax@16 + LevelDecoration *v8; // esi@19 + __int16 v9; // ax@19 + int v10; // eax@22 + int v11; // ecx@22 + int v12; // edi@23 + Actor *v13; // esi@23 + unsigned __int16 v14; // ax@23 + unsigned __int16 v15; // ax@33 + const char *v16; // eax@34 + int v17; // edi@36 + int v18; // eax@36 + ItemGen *v19; // esi@39 + unsigned int v20; // eax@39 + int v21; // ecx@40 + std::string v22; // [sp-18h] [bp-2Ch]@5 + const char *v23; // [sp-8h] [bp-1Ch]@5 + int v24; // [sp-4h] [bp-18h]@5 + char v25; // [sp+8h] [bp-Ch]@5 + int v26; // [sp+Ch] [bp-8h]@1 + int a3; // [sp+13h] [bp-1h]@5 + + v26 = a2; + v2 = a1; + switch ( PID_TYPE(a1) ) + { + case OBJECT_Item: // take the item + v17 = PID_ID(a1); + v26 = PID_ID(a1); + v18 = PID_ID(a1); + if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10 + || v17 >= 1000 + || !pSpriteObjects[v18].uObjectDescID ) + return 1; + v19 = &pSpriteObjects[v18].stru_24; + v20 = pSpriteObjects[v18].stru_24.uItemID; + if ( pItemsTable->pItems[v20].uEquipType == EQUIP_GOLD) + { + party_finds_gold(v19->uSpecEnchantmentType, 0); + viewparams->bRedrawGameUI = 1; + v21 = v17; + } + else + { + if ( pParty->pPickedItem.uItemID ) + return 1; + v24 = (int)pItemsTable->pItems[v20].pUnidentifiedName; + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v24); + ShowStatusBarString(pTmpBuf2.data(), 2u); + if ( v19->uItemID == 506 ) + _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); + if ( v19->uItemID == 455 ) + _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); + if ( !pParty->AddItem(v19) ) + pParty->SetHoldingItem(v19); + v21 = v26; + } + SpriteObject::OnInteraction(v21); + break; + + case OBJECT_Actor: + v12 = PID_ID(a1); + v13 = &pActors[PID_ID(a1)]; + v14 = v13->uAIState; + if ( v14 == 4 || v14 == 17 ) + return 1; + if ( v14 == 5 ) + { + stru_50C198.LootActor(&pActors[PID_ID(a1)]); + } + else + { + if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() ) + { + Actor::AI_FaceObject(v12, 4u, 0, 0); + if ( v13->sNPC_ID ) + { + pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0); + } + else + { + v15 = pNPCStats->pGroups_copy[v13->uGroup]; + if ( v15 ) + { + v16 = pNPCStats->pCatchPhrases[v15]; + if ( v16 ) + { + pParty->uFlags |= 2u; + strcpy(byte_5B0938.data(), v16); + sub_4451A8_press_any_key(0, 0, 0); + } + } + } + } + } + break; + + case OBJECT_Decoration: + v8 = &pLevelDecorations[PID_ID(a1)]; + v9 = v8->field_16_event_id; + if ( v9 ) + { + EventProcessor(v9, a1, 1); + LOBYTE(v8->field_2) |= 8u; + } + else + { + if ( !pLevelDecorations[PID_ID(a1)].IsInteractive() ) + return 1; + v10 = v8->_idx_in_stru123; + v24 = 1; + v11 = stru_5E4C90._decor_events[v10 - 75] + 380; + activeLevelDecoration = v8; + EventProcessor(v11, 0, 1); + activeLevelDecoration = NULL; + } + break; + + default: + MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); + return 1; + + case OBJECT_BModel: + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) + { + int bmodel_id = a1 >> 9, + face_id = PID_ID(a1) & 0x3F; + if (bmodel_id >= pOutdoor->uNumBModels) + return 1; + auto face = &pOutdoor->pBModels[bmodel_id].pFaces[face_id]; + if (face->uAttributes & 0x100000 || face->sCogTriggeredID == 0 ) + return 1; + EventProcessor((signed __int16)face->sCogTriggeredID, v2, 1); + } + else + { + v4 = &pIndoor->pFaces[PID_ID(a1)]; + v5 = v4->uAttributes; + if ( !(v5 & 0x2000000) ) + { + ShowNothingHereStatus(); + return 1; + } + if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 ) + return 1; + if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) + EventProcessor((signed __int16)v6, v2, 1); + } + return 0; + break; + } + return 0; +} +//----- (0046BDF1) -------------------------------------------------------- +void __cdecl BLV_UpdateUserInputAndOther() +{ + UpdateObjects(); + BLV_ProcessPartyActions(); + UpdateActors_BLV(); + BLV_UpdateDoors(); + check_event_triggers(); +} +//----- (00424829) -------------------------------------------------------- +bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, 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 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 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 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 + 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 ) + { + v63 = 1; + v64 = -1; + } + else + { + v63 = -1; + v64 = 1; + } + + for ( v6 = 1; v6 < pNumVertices; ++v6 ) + { + if ( stru_50B700._screen_space_y[v6] >= min_y ) + { + if ( stru_50B700._screen_space_y[v6] > max_y ) + max_y = stru_50B700._screen_space_y[v6]; + } + if ( stru_50B700._screen_space_y[v6] < min_y ) + { + v65 = v6; + min_y = stru_50B700._screen_space_y[v6]; + } + } + 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 ) + { + v10 += v64; + if ( v10 < pNumVertices ) + { + if ( v10 < 0 ) + v10 += pNumVertices; + } + else + v10 -= pNumVertices; + if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v65] ) + { + v55 = v10; + v65 = v10; + } + if ( stru_50B700._screen_space_y[v10] == max_y ) + break; + } + v13 = v55 + v64; + if ( v13 < pNumVertices ) + { + if ( v13 < 0 ) + v13 += pNumVertices; + } + else + v13 -= pNumVertices; + if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] ) + { + 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]); + } + v15 = v65; + v61 = v65; + + for ( v69 = 0; v69 < pNumVertices; ++v69 ) + { + v15 += v63; + if ( v15 < pNumVertices ) + { + if ( v15 < 0 ) + v15 += pNumVertices; + } + else + v15 -= pNumVertices; + if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v65] ) + { + v61 = v15; + v65 = v15; + } + if ( stru_50B700._screen_space_y[v15] == max_y ) + break; + } + v18 = v63 + v61; + if ( v18 < pNumVertices ) + { + if ( v18 < 0 ) + v18 += pNumVertices; + } + else + v18 -= pNumVertices; + v19 = v18; + v20 = v61; + if ( stru_50B700._screen_space_y[v19] != stru_50B700._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]); + } + 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 ) + { + v13 = v64 + v13; + if ( v13 < pNumVertices ) + { + if ( v13 < 0 ) + v13 += pNumVertices; + } + 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 ) + { + 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; + } + } + v29 = v18; + if ( v70 >= stru_50B700._screen_space_y[v18] && v70 != max_y ) + { + v18 += v63; + if ( v18 < pNumVertices ) + { + if ( v18 < 0 ) + v18 += pNumVertices; + } + 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 ) + { + 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; + } + } + //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] ) + { + 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; + } + //++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 ) + 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 <= 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 ) + { + if ( a2->viewport_left_side[v71] >= a3->viewport_left_side[v71] && a2->viewport_left_side[v71] <= a3->viewport_right_side[v71] ) + 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 ) + { + if ( a2->viewport_right_side[v72] >= a3->viewport_left_side[v72] && a2->viewport_left_side[v72] <= a3->viewport_right_side[v72] ) + 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]; + ++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]; + 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 ) + { + a2->field_8 = a2->viewport_left_side[v49]; + a2->field_10 = v49; + } + if ( a2->viewport_right_side[v49] > a2->field_C ) + { + a2->field_C = a2->viewport_right_side[v49]; + a2->field_14 = v49; + } + //++v50; + } + } + return true; +} +//----- (00423B5D) -------------------------------------------------------- +int __fastcall sub_423B5D(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 v8; // eax@5 + signed int v9; // ecx@10 + int v10; // eax@10 + int v11; // edx@11 + int v12; // ST28_4@12 + 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 + 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 thisa; // [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 v79; // [sp+1Ch] [bp-Ch]@9 + int v80; // [sp+1Ch] [bp-Ch]@76 + bool v81; // [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]; + _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; + 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; + } + else + { + stru_50B700.field_0 = 0; + if ( !(pFace->uAttributes & 1) ) + return 0; + } + v66 = pFace->uNumVertices; + if ( (signed int)pFace->uNumVertices > 0 ) + { + do + { + //v6 = &pIndoor->pVertices[pFace->pVertexIDs[v5]]; + pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible( + pIndoor->pVertices[pFace->pVertexIDs[v5]].x, + pIndoor->pVertices[pFace->pVertexIDs[v5]].y, + pIndoor->pVertices[pFace->pVertexIDs[v5]].z, + &stru_50B700._view_transformed_xs[v5 + 3], + &stru_50B700._view_transformed_zs[v5 + 3], + &stru_50B700._view_transformed_ys[v5 + 3], + 0); + ++v5; + } + while ( v5 < v66 ); + } + v7 = v66; + v8 = 0; + if ( v66 <= 0 ) + return 0; + do + { + if ( stru_50B700._view_transformed_xs[v8 + 3] >= 524288 ) + break; + ++v8; + } + while ( v8 < v66 ); + if ( v8 >= v66 ) + return 0; + v79 = 0; + stru_50B700._view_transformed_xs[v66 + 3] = stru_50B700._view_transformed_xs[3]; + stru_50B700._view_transformed_zs[v66 + 3] = stru_50B700._view_transformed_zs[3]; + stru_50B700._view_transformed_ys[v66 + 3] = stru_50B700._view_transformed_ys[3]; + thisa = stru_50B700._view_transformed_xs[3] >= 524288; + v86 = 1; + if ( v66 >= 1 ) + { + do + { + v9 = v86; + v10 = stru_50B700._view_transformed_xs[v86 + 3]; + v81 = v10 >= 524288; + if ( thisa ^ v81 ) + { + v11 = stru_50B700._view_transformed_xs[v9 + 2]; + if ( v10 >= 524288 ) + { + v12 = v10 - v11; + v13 = 524288 - v11; + LODWORD(v14) = v13 << 16; + HIDWORD(v14) = v13 >> 16; + v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 2]; + stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 3] + - stru_50B700._view_transformed_zs[v9 + 2]) + * v14 + / v12) >> 16) + + stru_50B700._view_transformed_zs[v9 + 2]; + thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 3] - stru_50B700._view_transformed_ys[v9 + 2]) + * v14 + / v12) >> 16; + } + else + { + v16 = v11 - v10; + v17 = 524288 - v10; + LODWORD(v18) = v17 << 16; + HIDWORD(v18) = v17 >> 16; + v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 3]; + stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 2] + - stru_50B700._view_transformed_zs[v9 + 3]) + * v18 + / v16) >> 16) + + stru_50B700._view_transformed_zs[v9 + 3]; + thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 2] - stru_50B700._view_transformed_ys[v9 + 3]) + * v18 + / v16) >> 16; + } + v19 = v79++; + v7 = v66; + stru_50B700._view_transformed_ys[v19] = thisb + *(_DWORD *)v15; + stru_50B700._view_transformed_xs[v19] = 524288; + } + if ( v81 ) + { + v20 = v79++; + stru_50B700._view_transformed_xs[v20] = stru_50B700._view_transformed_xs[v9 + 3]; + stru_50B700._view_transformed_zs[v20] = stru_50B700._view_transformed_zs[v9 + 3]; + stru_50B700._view_transformed_ys[v20] = stru_50B700._view_transformed_ys[v9 + 3]; + } + ++v86; + thisa = v81; + } + while ( v86 <= v7 ); + } + v87 = 0; + v21 = v79; + stru_50B700._view_transformed_xs[v79] = stru_50B700._view_transformed_xs[0]; + stru_50B700._view_transformed_zs[v79] = stru_50B700._view_transformed_zs[0]; + for ( stru_50B700._view_transformed_ys[v79] = stru_50B700._view_transformed_ys[0]; + v87 < v79; + stru_50B700._screen_space_y[v22 + 12] = pBLVRenderParams->uViewportCenterY - v35 ) + { + 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; + } + else + { + v23 = 0; + v24 = 0; + if ( stru_50B700._view_transformed_zs[v22] >= 0 ) + { + LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; + v26 = ((v24 - 1) & 0xFF800000) + 4194304; + } + else + { + LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; + v25 = v24 - 1; + v26 = (v25 & 0x800000) - 4194304; + } + } + 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]; + } + else + { + v30 = 0; + if ( stru_50B700._view_transformed_ys[v22] >= v23 ) + { + LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; + v32 = ((v30 - 1) & 0xFF800000) + 4194304; + } + else + { + LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; + v31 = v30 - 1; + v32 = (v31 & 0x800000) - 4194304; + } + } + 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]; + ++v87; + } + 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; + if ( v79 < 1 ) + return 0; + do + { + v40 = v39; + v41 = stru_50B700._screen_space_x[v40 + 12]; + v82 = v41 >= (signed int)v37; + if ( v38 ^ v82 ) + { + if ( v41 >= (signed int)v37 ) + { + 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]; + } + 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]; + } + ++v36; + stru_50B700._screen_space_y[v36 + 8] = v67 + v42; + v37 = pBLVRenderParams->uViewportX; + stru_50B700._screen_space_x[v36 + 8] = pBLVRenderParams->uViewportX; + } + v38 = v82; + if ( v82 ) + { + 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]; + } + v39 = v88++ + 1; + } + while ( v88 <= v79 ); + 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) ) + return 0; + do + { + v45 = v89; + v46 = stru_50B700._screen_space_x[v89 + 9]; + v83 = v46 <= (signed int)v44; + if ( thisd ^ v83 ) + { + if ( v46 <= (signed int)v44 ) + { + 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]; + } + 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]; + } + ++v43; + stru_50B700._screen_space_y[v43 + 5] = v68 + v47; + v44 = pBLVRenderParams->uViewportZ; + stru_50B700._screen_space_x[v43 + 5] = pBLVRenderParams->uViewportZ; + } + if ( v83 ) + { + 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]; + } + ++v89; + thisd = v83; + } + 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) ) + return 0; + do + { + v52 = v51; + v53 = stru_50B700._screen_space_y[v52 + 6]; + v84 = v53 >= (signed int)v49; + if ( v50 ^ v84 ) + { + if ( v53 >= (signed int)v49 ) + { + 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]; + } + 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]; + } + ++v48; + stru_50B700._screen_space_x[v48 + 2] = v69 + v54; + v49 = pBLVRenderParams->uViewportY; + stru_50B700._screen_space_y[v48 + 2] = pBLVRenderParams->uViewportY; + } + v50 = v84; + if ( v84 ) + { + 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]; + } + 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) ) + return 0; + do + { + v57 = v91; + v58 = stru_50B700._screen_space_y[v91 + 3]; + v85 = v58 <= (signed int)v56; + if ( thise ^ v85 ) + { + if ( v58 <= (signed int)v56 ) + { + 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]; + } + 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]; + } + ++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; + } + if ( v85 ) + { + 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]; + } + ++v91; + thise = v85; + } + while ( v91 <= v48 ); + if ( !v55 ) + 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 ) + { + 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 ) + { + v62 = 1; + v71 = 1; + do + { + 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 ) + { + v62 = v80; + v71 = v80; + } + else + { + v62 = v71; + v65 = v71; + if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) ) + { + 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)); + } + --v55; + } + } + while ( v62 - 1 < v55 ); + } + stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0]; + stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0]; + } + return v55; } \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef Items.cpp --- a/Items.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Items.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -2348,5 +2348,178 @@ return a4; } } +//----- (0043C91D) -------------------------------------------------------- +int __fastcall GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder) +{ + int result; // eax@2 + char v5; // zf@3 + const char *v6; // [sp-Ch] [bp-18h]@88 + signed int v7; // [sp-8h] [bp-14h]@61 + int v8; // [sp-4h] [bp-10h]@61 + signed int v9; // [sp-4h] [bp-10h]@69 + result = 0; //BUG fn is void + if ( item_id <= 500 ) + { + //v5 = *((char *)&pBloodsplatContainer->std__vector_pBloodsplats[62].field_20 + a2 + 2) == 0; + v5 = party_has_equipment[(item_id - 100) + 32 + 2] == 0; + switch ( item_id ) + { + case 516: + v5 = byte_5111F6[2] == 0; + break; + case 505: + v5 = byte_5111F6[1] == 0; + break; + case 504: + v5 = byte_5111F6[0] == 0; + break; + case 533: + v5 = byte_5111F6[16] == 0; + break; + case 512: + v5 = byte_5111F6[3] == 0; + break; + case 521: + v5 = byte_5111F6[4] == 0; + break; + case 522: + v5 = byte_5111F6[5] == 0; + break; + case 523: + v5 = byte_5111F6[6] == 0; + break; + case 532: + v5 = byte_5111F6[7] == 0; + break; + case 544: + v5 = byte_5111F6[8] == 0; + break; + case 524: + v5 = byte_5111F6[9] == 0; + break; + case 535: + v5 = byte_5111F6[10] == 0; + break; + case 525: + v5 = byte_5111F6[11] == 0; + break; + case 530: + v5 = byte_5111F6[12] == 0; + break; + case 547: + v5 = byte_5111F6[13] == 0; + break; + case 548: + v5 = byte_5111F6[14] == 0; + break; + case 550: + v5 = byte_5111F6[15] == 0; + break; + default: + break; + } + if ( v5 ) + return result; + result = 516; + if ( item_id < 66 || item_id > 78 ) + { + if ( item_id == 516 ) + { + if ( !shoulder ) + return sprintf(pOut, "item%3.3dv%d", 234, index); + if ( shoulder == 1 ) + return sprintf(pOut, "item%3.3dv%da1", 234, index); + if ( shoulder == 2 ) + return sprintf(pOut, "item%3.3dv%da2", 234, index); + } + if ( item_id != 504 && item_id != 505 && item_id != 533 ) + { + if ( (item_id < 100 || item_id > 104) && item_id != 524 && item_id != 535 ) + { + if ( item_id >= 115 && item_id <= 119 || item_id == 512 ) + { + if ( item_id == 512 ) + item_id = 312; + return sprintf(pOut, "item%3.3dv%d", item_id, index); + } + if ( (item_id < 89 || item_id > 99) && item_id != 521 && item_id != 522 && item_id != 523 && item_id != 532 && item_id != 544 ) + { + result = 525; + if ( (item_id < 105 || item_id > 109) && item_id != 525 && item_id != 530 && item_id != 547 && item_id != 548 && item_id != 550 ) + return result; + switch ( item_id ) + { + case 525: + item_id = 325; + break; + case 530: + item_id = 330; + break; + case 547: + item_id = 347; + break; + case 548: + item_id = 348; + break; + case 550: + item_id = 350; + break; + } + if ( !shoulder ) + return sprintf(pOut, "item%3.3dv%d", item_id, index); + return sprintf(pOut, "item%3.3dv%da1", item_id, index); + } + if ( item_id == 521 ) + return sprintf(pOut, "item%3.3dv%d", 239, index); + if ( item_id == 522 ) + return sprintf(pOut, "item%3.3dv%d", 240, index); + if ( item_id == 523 ) + return sprintf(pOut, "item%3.3dv%d", 241, index); + if ( item_id != 532 ) + { + if ( item_id == 544 ) + item_id = 344; + return sprintf(pOut, "item%3.3dv%d", item_id, index); + } + return sprintf(pOut, "item%3.3dv%d", 93, index); + } + if ( item_id == 524 ) + return sprintf(pOut, "item%3.3dv%d", 324, index); + if ( item_id == 535 ) + item_id = 104; + return sprintf(pOut, "item%3.3dv%d", item_id, index); + } + } + if ( item_id != 516 ) + { + switch ( item_id ) + { + case 504: + item_id = 235; + break; + case 505: + item_id = 236; + break; + case 533: + item_id = 73; + break; + } + if ( !shoulder ) + return sprintf(pOut, "item%3.3dv%d", item_id, index); + if ( shoulder == 1 ) + return sprintf(pOut, "item%3.3dv%da1", item_id, index); + if ( shoulder == 2 ) + return sprintf(pOut, "item%3.3dv%da2", item_id, index); + } + if ( !shoulder ) + return sprintf(pOut, "item%3.3dv%d", 234, index); + if ( shoulder == 1 ) + return sprintf(pOut, "item%3.3dv%da1", 234, index); + if ( shoulder == 2 ) + return sprintf(pOut, "item%3.3dv%da2", 234, index); + } + result = item_id - 504; + return result; +} diff -r c423f946dc99 -r 5450af4f57ef Keyboard.cpp --- a/Keyboard.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Keyboard.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -9,10 +9,13 @@ #include "OSInfo.h" #include "mm7_data.h" - - - - +#include "Vis.h" +#include "MM7.h" +#include "Actor.h" +#include "DecorationList.h" +#include "Indoor.h" +#include "viewport.h" +#include "AudioPlayer.h" struct KeyboardActionMapping *pKeyActionMap; @@ -958,3 +961,144 @@ { return GetAsyncKeyState(vKey) & 1; } +//----- (0046A14B) -------------------------------------------------------- +void OnPressSpace() +{ + //SHORT v0; // ax@2 + int *v1; // eax@2 + char *v2; // ebx@5 + unsigned int v3; // esi@5 + signed int v4; // edi@7 + unsigned int v5; // edx@7 + int v6; // ecx@8 + int v7; // eax@8 + int v8; // ecx@17 + int *v9; // esi@22 + signed int v10; // ebx@22 + int i; // edi@23 + int v12; // edx@24 + int v13; // ecx@24 + int j; // esi@28 + int v16; // [sp+4h] [bp-1Ch]@0 + char *v17; // [sp+8h] [bp-18h]@5 + unsigned int v18; // [sp+Ch] [bp-14h]@5 + int v19; // [sp+10h] [bp-10h]@8 + int *v20; // [sp+14h] [bp-Ch]@5 + int *v21; // [sp+18h] [bp-8h]@7 + int v22; // [sp+1Ch] [bp-4h]@4 + + if ( pRenderer->pRenderD3D ) + { + pGame->PickKeyboard(GetAsyncKeyState(VK_CONTROL) & 0x8001, &vis_sprite_filter_3, &vis_door_filter); + auto pid = pGame->pVisInstance->get_picked_object_zbuf_val(); + if ( pid != -1 ) + DoInteractionWithTopmostZObject(pid & 0xFFFF, PID_ID(pid)); + return; + } + + + // software render stuff following + + static int dword_720660[100]; // 720660 + static int dword_7207F0[100]; // 7207F0 + + v22 = 0; + v1 = (int *)((signed int)(viewparams->uScreen_BttmR_X + viewparams->uScreen_topL_X) >> 1);//wrong pointer + if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) + { + v2 = (char *)v1 - 50; + v1 = (int *)((char *)v1 + 50); + v3 = 640 * viewparams->uScreen_topL_Y; + v17 = v2; + v20 = v1; + v18 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1; + do + { + if ( (signed int)v2 < (signed int)v20 ) + { + v1 = &pRenderer->pActiveZBuffer[(int)&v2[v3]]; + v21 = &pRenderer->pActiveZBuffer[(int)&v2[v3]]; + v4 = v22; + v5 = (((char *)v20 - v2 - 1) >> 1) + 1; + do + { + v6 = 0; + v7 = *v1 & 0xFFFF; + v19 = 0; + if ( v4 > 0 ) + { + do + { + if ( dword_7207F0[v6] == v7 ) + break; + ++v6; + v19 = v6; + } + while ( v6 < v22 ); + } + if ( PID_TYPE(v7) == OBJECT_Decoration) + { + v16 = (unsigned int)PID_ID(v7); + if ( (signed int)(((unsigned int)*v21 >> 16) + - pDecorationList->pDecorations[pLevelDecorations[(unsigned int)PID_ID(v7)].uDecorationDescID].uRadius) <= 512 ) + if ( v19 == v22 && v4 < 100 ) + { + ++v22; + ++v4; + v8 = *v21; + dword_7207F0[v4 - 1] = v7; + dword_720660[v4 - 1] = v8; + } + } + else if ( (unsigned int)*v21 <= 0x2000000 ) + { + if ( v19 == v22 && v4 < 100 ) + { + ++v22; + ++v4; + v8 = *v21; + dword_7207F0[v4 - 1] = v7; + dword_720660[v4 - 1] = v8; + } + } + v1 = v21 + 2; + --v5; + v21 += 2; + } + while ( v5 ); + v2 = v17; + } + v3 += 1280; + --v18; + } + while ( v18 ); + } + if ( v22 > 0 ) + { + v9 = dword_720660; + v10 = 1; + do + { + for ( i = v10; i < v22; ++i ) + { + v12 = *v9; + v13 = dword_720660[i]; + if ( v13 < *v9 ) + { + *v9 = v13; + dword_720660[i] = v12; + } + } + ++v10; + ++v9; + LOBYTE(v1) = v10 - 1; + } + while ( v10 - 1 < v22 ); + } + for ( j = 0; j < v22; ++j ) + { + LOBYTE(v1) = DoInteractionWithTopmostZObject(dword_720660[j] & 0xFFFF, v16); + if ( !(char)v1 ) + break; + } +} diff -r c423f946dc99 -r 5450af4f57ef LOD.cpp --- a/LOD.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/LOD.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -2947,3 +2947,57 @@ // } // return v4; } +//----- (0046082C) -------------------------------------------------------- +bool Initialize_GamesLOD_NewLOD() +{ + pGames_LOD = new LODWriteableFile; + pGames_LOD->AllocSubIndicesAndIO(300, 0); + if (pGames_LOD->LoadFile("data\\games.lod", 1)) + { + pNew_LOD = new LODWriteableFile; + pNew_LOD->AllocSubIndicesAndIO(300, 100000); + return true; + } + return false; +} +//----- (00460706) -------------------------------------------------------- +void TryLoadLevelFromLOD() +{ + FILE *v0; // eax@1 + FILE *v1; // esi@1 + __int32 v2; // edi@2 + char Ext[256]; // [sp+4h] [bp-40Ch]@1 + char Dir[256]; // [sp+104h] [bp-30Ch]@1 + char Filename[256]; // [sp+204h] [bp-20Ch]@1 + char a1[260]; // [sp+304h] [bp-10Ch]@1 + char Drive[4]; // [sp+408h] [bp-8h]@1 + int DstBuf; // [sp+40Ch] [bp-4h]@2 + + strcpy(a1, pCurrentMapName.data()); + _splitpath(a1, Drive, Dir, Filename, Ext); + sprintf(a1, "levels\\%s%s", Filename, ".lod"); + v0 = fopen(a1, "rb"); + v1 = v0; + if ( v0 ) + { + fseek(v0, 0, 2); + v2 = ftell(v1); + rewind(v1); + ptr_6A0D08 = pAllocator->AllocNamedChunk(ptr_6A0D08, v2, "LevelLod"); + fread(ptr_6A0D08, v2, 1u, v1); + fseek(v1, v2 - 6, 0); + DstBuf = 0; + fread(&DstBuf, 4u, 1u, v1); + fread(&_6A0D10_txt_lod_loading__unused, 2u, 1u, v1); + _6A0D0C_txt_lod_loading = (int)((char *)ptr_6A0D08 + DstBuf); + fclose(v1); + } +} + +//----- (0046080D) -------------------------------------------------------- +void __cdecl sub_46080D() +{ + pAllocator->FreeChunk(ptr_6A0D08); + ptr_6A0D08 = 0; + _6A0D0C_txt_lod_loading = 0; +} diff -r c423f946dc99 -r 5450af4f57ef Log.cpp --- a/Log.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Log.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -32,3 +32,20 @@ WriteConsole(hStdOut, L"\r\n", 2, &w, nullptr); } +//----- (004BE386) -------------------------------------------------------- +void __fastcall log_error(const char *pMessage) +{ + const char *v1; // edi@1 + FILE *f; // eax@1 + FILE *v3; // esi@1 + + v1 = pMessage; + f = fopen("errorlog.txt", "a"); + v3 = f; + if ( f ) + { + fprintf(f, "%s\n", v1); + fclose(v3); + fflush(v3); + } +} \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef Monsters.cpp --- a/Monsters.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Monsters.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -1173,3 +1173,85 @@ } assert(false && "Monster not found!"); } +//----- (00438BDF) -------------------------------------------------------- +bool MonsterStats::BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype) +{ + unsigned __int8 v2; // zf@15 + char v3; // sf@15 + unsigned __int8 v4; // of@15 + bool result; // eax@33 + + switch ( eSupertype ) + { + case MONSTER_SUPERTYPE_UNDEAD: + if ( (signed int)uMonsterInfoID >= MONSTER_GHOST_1 && (signed int)uMonsterInfoID <= MONSTER_GHOST_3 + || (signed int)uMonsterInfoID >= MONSTER_LICH_1 && (signed int)uMonsterInfoID <= MONSTER_LICH_3 + || (signed int)uMonsterInfoID >= MONSTER_SKELETON_1 && (signed int)uMonsterInfoID <= MONSTER_SKELETON_3 + || (signed int)uMonsterInfoID >= MONSTER_VAMPIRE_1 && (signed int)uMonsterInfoID <= MONSTER_VAMPIRE_3 + || (signed int)uMonsterInfoID >= MONSTER_WIGHT_1 && (signed int)uMonsterInfoID <= MONSTER_WIGHT_3 + || (signed int)uMonsterInfoID >= MONSTER_ZOMBIE_1 && (signed int)uMonsterInfoID <= MONSTER_ZOMBIE_3 ) + goto ret_true; + if ( (signed int)uMonsterInfoID < MONSTER_GHOUL_1 ) + goto ret_false; + v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_GHOUL_3); + v2 = uMonsterInfoID == MONSTER_GHOUL_3; + v3 = ((uMonsterInfoID - MONSTER_GHOUL_3) & 0x80000000u) != 0; + goto false_if_outside; + case MONSTER_SUPERTYPE_KREEGAN: + if ( (signed int)uMonsterInfoID < MONSTER_DEVIL_1 ) + goto ret_false; + v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DEVIL_3); + v2 = uMonsterInfoID == MONSTER_DEVIL_3; + v3 = ((uMonsterInfoID - MONSTER_DEVIL_3) & 0x80000000u) != 0; + goto false_if_outside; + case MONSTER_SUPERTYPE_ELF: + if ( (signed int)uMonsterInfoID >= MONSTER_PEASANT_ELF_FEMALE_1_1 + && (signed int)uMonsterInfoID <= MONSTER_PEASANT_ELF_MALE_3_3 + || (signed int)uMonsterInfoID >= MONSTER_ELF_ARCHER_1 && (signed int)uMonsterInfoID <= MONSTER_ELF_ARCHER_3 ) + goto ret_true; + if ( (signed int)uMonsterInfoID < MONSTER_ELF_SPEARMAN_1 ) + goto ret_false; + v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELF_SPEARMAN_3); + v2 = uMonsterInfoID == MONSTER_ELF_SPEARMAN_3; + v3 = ((uMonsterInfoID - MONSTER_ELF_SPEARMAN_3) & 0x80000000u) != 0; + goto false_if_outside; + case MONSTER_SUPERTYPE_DRAGON: + if ( (signed int)uMonsterInfoID < MONSTER_DRAGON_1 ) + goto ret_false; + v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DRAGON_3); + v2 = uMonsterInfoID == MONSTER_DRAGON_3; + v3 = ((uMonsterInfoID - MONSTER_DRAGON_3) & 0x80000000u) != 0; + goto false_if_outside; + case MONSTER_SUPERTYPE_WATER_ELEMENTAL: + if ( (signed int)uMonsterInfoID < MONSTER_ELEMENTAL_WATER_1 ) + goto ret_false; + v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELEMENTAL_WATER_3); + v2 = uMonsterInfoID == MONSTER_ELEMENTAL_WATER_3; + v3 = ((uMonsterInfoID - MONSTER_ELEMENTAL_WATER_3) & 0x80000000u) != 0; + goto false_if_outside; + case MONSTER_SUPERTYPE_TREANT: + if ( (signed int)uMonsterInfoID < MONSTER_TREANT_1 ) + goto ret_false; + v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TREANT_3); + v2 = uMonsterInfoID == MONSTER_TREANT_3; + v3 = ((uMonsterInfoID - MONSTER_TREANT_3) & 0x80000000u) != 0; + goto false_if_outside; + case MONSTER_SUPERTYPE_TITAN: + if ( (signed int)uMonsterInfoID < MONSTER_TITAN_1 ) + goto ret_false; + v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TITAN_3); + v2 = uMonsterInfoID == MONSTER_TITAN_3; + v3 = ((uMonsterInfoID - MONSTER_TITAN_3) & 0x80000000u) != 0; +false_if_outside: + if ( !((unsigned __int8)(v3 ^ v4) | v2) ) + goto ret_false; +ret_true: + result = 1; + break; + default: +ret_false: + result = 0; + break; + } + return result; +} \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef Mouse.cpp --- a/Mouse.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Mouse.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -19,6 +19,7 @@ #include "Vis.h" #include "Actor.h" #include "MM7.h" +#include "AudioPlayer.h" Mouse *pMouse; @@ -660,3 +661,258 @@ pMouse->GetCursorPos(&v1); } } +//----- (0041CD4F) -------------------------------------------------------- +bool UI_OnKeyDown(unsigned int vkKey) +{ + //unsigned int v1; // edi@1 + //unsigned int v2; // eax@2 + int v3; // esi@3 + int v4; // ecx@10 + GUIButton *pButton; // eax@11 + int v6; // edx@12 + int v7; // ecx@20 + char v8; // zf@21 + //GUIButton *v9; // ecx@24 + int v10; // esi@24 + //int v11; // edx@26 + int v12; // edx@28 + int v13; // esi@32 + //GUIButton *v14; // eax@37 + int v15; // edx@38 + int v17; // ecx@50 + int v18; // edx@50 + //GUIButton *v19; // ecx@54 + int v20; // esi@54 + //int v21; // edx@56 + int v22; // ecx@59 + int v23; // edx@59 + int v24; // ecx@60 + int v25; // esi@63 + //unsigned int v26; // [sp+Ch] [bp-14h]@1 + //int v27; // [sp+10h] [bp-10h]@1 + int v28; // [sp+14h] [bp-Ch]@10 + int v29; // [sp+14h] [bp-Ch]@36 + unsigned int uClickX; // [sp+18h] [bp-8h]@10 + unsigned int uClickY; // [sp+1Ch] [bp-4h]@10 + + //v1 = 0; + //v27 = uNumVisibleWindows; + if ( uNumVisibleWindows < 0 ) + return false; + //v2 = pMessageQueue_50CBD0->uNumMessages; + for (int i = uNumVisibleWindows; i >= 0; --i) + //while ( 1 ) + { + v3 = pVisibleWindowsIdxs[i] - 1; + if (!pWindowList[v3].receives_keyboard_input) + continue; + + switch (vkKey) + { + case VK_LEFT: + { + v12 = pWindowList[v3].field_34; + if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 ) + { + v8 = pCurrentScreen == SCREEN_PARTY_CREATION; + pWindowList[v3].pCurrentPosActiveItem -= v12; + if ( v8 ) + { + pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); + //v2 = pMessageQueue_50CBD0->uNumMessages; + } + } + if ( pWindowList[v3].field_30 != 0 ) + { + break; + } + pButton = pWindowList[v3].pControlsHead; + v13 = pWindowList[v3].pCurrentPosActiveItem; + if ( v13 > 0) + { + do + { + pButton = pButton->pNext; + --v13; + } + while ( v13 ); + } + pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); + break; + } + case VK_RIGHT: + { + v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34; + if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem ) + { + v8 = pCurrentScreen == SCREEN_PARTY_CREATION; + pWindowList[v3].pCurrentPosActiveItem = v7; + if ( v8 ) + { + pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); + //v2 = pMessageQueue_50CBD0->uNumMessages; + } + } + if ( pWindowList[v3].field_30 != 0 ) + { + break; + } + pButton = pWindowList[v3].pControlsHead; + v10 = pWindowList[v3].pCurrentPosActiveItem; + if ( v10 > 0) + { + do + { + pButton = pButton->pNext; + --v10; + } + while ( v10 ); + } + pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); + break; + } + case VK_DOWN: + { + v17 = pWindowList[v3].pStartingPosActiveItem; + v18 = pWindowList[v3].pCurrentPosActiveItem; + if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 ) + pWindowList[v3].pCurrentPosActiveItem = v17; + else + pWindowList[v3].pCurrentPosActiveItem = v18 + 1; + if ( pWindowList[v3].field_30 != 0 ) + return true; + pButton = pWindowList[v3].pControlsHead; + v20 = pWindowList[v3].pCurrentPosActiveItem; + if ( v20 > 0) + { + do + { + pButton = pButton->pNext; + --v20; + } + while ( v20 ); + } + pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); + return true; + } + case VK_SELECT: + { + pMouse->GetClickPos(&uClickX, &uClickY); + v4 = pWindowList[v3].pStartingPosActiveItem; + v28 = v4 + pWindowList[v3].pNumPresenceButton; + if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) + { + while ( 1 ) + { + pButton = pWindowList[v3].pControlsHead; + if ( v4 > 0 ) + { + v6 = v4; + do + { + pButton = pButton->pNext; + --v6; + } + while ( v6 ); + } + if ( (signed int)uClickX >= (signed int)pButton->uX//test for StatsTab in PlayerCreation Window + && (signed int)uClickX <= (signed int)pButton->uZ + && (signed int)uClickY >= (signed int)pButton->uY + && (signed int)uClickY <= (signed int)pButton->uW ) + break; + ++v4; + if ( v4 >= v28 ) + { + //v1 = 0; + //v2 = pMessageQueue_50CBD0->uNumMessages; + //--i; + //if ( i < 0 ) + return false; + //continue; + } + } + pWindowList[v3].pCurrentPosActiveItem = v4; + return true; + } + //v2 = pMessageQueue_50CBD0->uNumMessages; + break; + } + case VK_UP: + { + v22 = pWindowList[v3].pCurrentPosActiveItem; + v23 = pWindowList[v3].pStartingPosActiveItem; + if ( v22 <= v23 ) + v24 = pWindowList[v3].pNumPresenceButton + v23 - 1; + else + v24 = v22 - 1; + v8 = pWindowList[v3].field_30 == 0; + pWindowList[v3].pCurrentPosActiveItem = v24; + if ( !v8 ) + return true; + pButton = pWindowList[v3].pControlsHead; + v25 = pWindowList[v3].pCurrentPosActiveItem; + if ( v25 > 0) + { + do + { + pButton = pButton->pNext; + --v25; + } + while ( v25 ); + } + pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); + return true; + } + case VK_NEXT: + { + //if ( pWindowList[v3].field_30 != 0 ) //crashed at skill draw + //{ + // pMouse->GetClickPos(&uClickX, &uClickY); + // v4 = pWindowList[v3].pStartingPosActiveItem; + // v29 = v4 + pWindowList[v3].pNumPresenceButton; //num buttons more than buttons + // if ( v4 < v29 ) + // { + // while ( 1 ) + // { + // pButton = pWindowList[v3].pControlsHead; + // if ( v4 > 0 ) + // { + // v15 = v4; + // do + // { + // pButton = pButton->pNext; + // --v15; + // } + // while ( v15 ); + // } + // if ( (signed int)uClickX >= (signed int)pButton->uX + // && (signed int)uClickX <= (signed int)pButton->uZ + // && (signed int)uClickY >= (signed int)pButton->uY + // && (signed int)uClickY <= (signed int)pButton->uW ) + // { + // pWindowList[v3].pCurrentPosActiveItem = v4; + // return true; + // } + // ++v4; + // if ( v4 >= v29 ) + // { + // //v1 = 0; + // //v2 = pMessageQueue_50CBD0->uNumMessages; + // break; + // } + // } + // } + // else + // { + // //v2 = pMessageQueue_50CBD0->uNumMessages; + // } + //} + break; + } + default: + { + break; + } + } + } +} \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef Outdoor.cpp --- a/Outdoor.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Outdoor.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -37,6 +37,7 @@ #include "MapInfo.h" #include "OutdoorCamera.h" #include "BSPModel.h" +#include "GUIWindow.h" MapStartPoint uLevel_StartingPointType; // weak @@ -3547,4 +3548,50 @@ for (uint i = 0; i < ai_arrays_size; ++i) pActors[ai_near_actors_ids[i]].uAttributes |= 0x0400; +} +//----- (0046BE0A) -------------------------------------------------------- +void __cdecl ODM_UpdateUserInputAndOther() +{ + bool v0; // eax@5 + char pOut[32]; // [sp+8h] [bp-20h]@5 + + UpdateObjects(); + ODM_ProcessPartyActions(); + if ( pParty->vPosition.x < -22528 + || pParty->vPosition.x > 22528 + || pParty->vPosition.y < -22528 + || pParty->vPosition.y > 22528 ) + { + strcpy(pOutdoor->pLevelFilename, pCurrentMapName.data()); + v0 = pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pOut, 32); + if ( !bUnderwater && (pParty->uFlags & (PARTY_FLAGS_1_STANDING_ON_WATER | PARTY_FLAGS_1_FALLING | 0x04) || pParty->uFlags & 0x0200 || pParty->bFlying) || !v0 ) + { + if ( pParty->vPosition.x < -22528 ) + pParty->vPosition.x = -22528; + if ( pParty->vPosition.x > 22528 ) + pParty->vPosition.x = 22528; + if ( pParty->vPosition.y < -22528 ) + pParty->vPosition.y = -22528; + if ( pParty->vPosition.y > 22528 ) + pParty->vPosition.y = 22528; + } + else + { + pAudioPlayer->StopChannels(-1, -1); + TravelUI_Load(); + } + } + UpdateActors_ODM(); + check_event_triggers(); +} +//----- (0041F54A) -------------------------------------------------------- +void __cdecl LoadActualSkyFrame() +{ + if ( pTexture_RestUI_CurrentSkyFrame ) + pTexture_RestUI_CurrentSkyFrame->Release(); + if ( pTexture_RestUI_CurrentHourglassFrame ) + pTexture_RestUI_CurrentHourglassFrame->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + sprintf(pTmpBuf.data(), "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour); + pTexture_RestUI_CurrentSkyFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); } \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef Party.cpp --- a/Party.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Party.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -21,11 +21,11 @@ #include "MM7.h" #include "Outdoor.h" #include "Indoor.h" - - - - - +#include "Texture.h" +#include "LOD.h" +#include "Sprites.h" +#include "SpriteObject.h" +#include "ObjectList.h" Party *pParty; // idb @@ -1211,6 +1211,52 @@ while ( v6 <= &pParty->pPlayers[3] ); pParty->UpdatePlayersAndHirelingsEmotions(); } +//----- (0041F5BE) -------------------------------------------------------- +void __cdecl Sleep6Hours() +{ + if ( _506F18_num_hours_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 ) + { + Rest(_506F18_num_hours_to_sleep); + _506F18_num_hours_to_sleep = 0; + LoadActualSkyFrame(); + } + if ( dword_506F14 == 2 ) + { + pGUIWindow_CurrentMenu->Release(); + pEventTimer->Resume(); + if ( pTexture_RestUI_CurrentSkyFrame ) + pTexture_RestUI_CurrentSkyFrame->Release(); + if ( pTexture_RestUI_CurrentHourglassFrame ) + pTexture_RestUI_CurrentHourglassFrame->Release(); + pTexture_RestUI_CurrentHourglassFrame = 0; + pTexture_RestUI_CurrentSkyFrame = 0; + pIcons_LOD->_4114F2(); + pIcons_LOD->SyncLoadedFilesCount(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + pOutdoor->UpdateSunlightVectors(); + pOutdoor->UpdateFog(); + } + } + dword_506F14 = 0; + } + else + { + Rest(6u); + _506F18_num_hours_to_sleep -= 6; + LoadActualSkyFrame(); + } + viewparams->bRedrawGameUI = 1; +} + //----- (0047752B) -------------------------------------------------------- int __cdecl GetPartyReputation() { @@ -1266,3 +1312,205 @@ } } } +//----- (00420C05) -------------------------------------------------------- +void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) +{ + unsigned int v2; // edi@1 + int v3; // ebp@1 + unsigned int v4; // esi@1 + int v5; // ecx@6 + NPCData *v6; // eax@6 + signed int v7; // edx@8 + signed int v8; // ebx@10 + char *v9; // edi@11 + signed int v10; // ecx@17 + int v11; // eax@21 + NPCData *v12; // ecx@21 + unsigned int v13; // ecx@23 + signed int v14; // [sp+Ch] [bp-4h]@6 + + v2 = 0; + v3 = 0; + v4 = uNumGold; + if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal ) + { + if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 ) + { + sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold! + } + else + { + if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 ) + pTmpBuf2[0] = 0; + } + } + else + { + v14 = 0; + v5 = 0; + v6 = pParty->pHirelings; + do + { + if ( v6->pName ) + { + v7 = v14++; + pTmpBuf[v7] = v5; + } + ++v6; + ++v5; + } + while ( (signed int)v6 < (signed int)&pParty->pPickedItem ); + v8 = 0; + if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) + { + v9 = (char *)pNPCStats->pNewNPCData; + do + { + if ( v9[8] & 0x80 + && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v9, pParty->pHirelings[0].pName)) + && (!pParty->pHirelings[1].pName || strcmp(*(const char **)v9, pParty->pHirelings[1].pName)) ) + { + v10 = v14++; + pTmpBuf[v10] = v8 + 2; + } + ++v8; + v9 += 76; + } + while ( v8 < (signed int)pNPCStats->uNumNewNPCs ); + v2 = 0; + } + if ( v14 > 0 ) + { + do + { + v11 = (unsigned __int8)pTmpBuf[v2]; + v12 = &pNPCStats->pNPCData[v11 + 499]; + if ( (unsigned __int8)pTmpBuf[v2] < 2 ) + v12 = &pParty->pHirelings[v11]; + v13 = v12->uProfession; + if ( v13 ) + v3 += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13); + ++v2; + } + while ( (signed int)v2 < v14 ); + } + if ( CheckHiredNPCSpeciality(Factor) ) + v4 += (signed int)(10 * v4) / 100; + if ( CheckHiredNPCSpeciality(Banker) ) + v4 += (signed int)(20 * v4) / 100; + if ( CheckHiredNPCSpeciality(Pirate) ) + v4 += (signed int)(10 * v4) / 100; + if ( v3 ) + { + v3 = (signed int)(v4 * v3 / 100) / 100; + if ( v3 < 1 ) + v3 = 1; + sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], v4, v3);// You found %lu gold (followers take %lu)! + } + else + { + sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], v4);// You found %lu gold! + } + v2 = 0; + } + pParty->uNumGold += v4 - v3; + pUIAnim_Gold->uAnimTime = v2; + pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; + if ( pTmpBuf2[0] ) + ShowStatusBarString(pTmpBuf2.data(), 2u); + pAudioPlayer->PlaySound(SOUND_GoldReceived, v2, v2, -1, v2, v2, v2, v2); +} +//----- (00421B2C) -------------------------------------------------------- +bool __cdecl sub_421B2C_PlaceInInventory_or_DropPickedItem() +{ + unsigned int v0; // eax@2 + Texture *v1; // ebx@2 + int v2; // eax@3 + Player *v3; // esi@5 + int v4; // eax@6 + unsigned __int16 v5; // dx@11 + signed int v6; // eax@11 + char *v7; // edi@12 + __int16 v8; // ax@16 + SpriteObject a1; // [sp+4h] [bp-78h]@11 + int v11; // [sp+74h] [bp-8h]@2 + int v12; // [sp+78h] [bp-4h]@5 + + if ( !pParty->pPickedItem.uItemID ) + return 1; + v0 = pIcons_LOD->LoadTexture( + pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, + TEXTURE_16BIT_PALETTE); + v1 = pIcons_LOD->GetTexture(v0); + v11 = areWeLoadingTexture; + if ( uActiveCharacter + && (v2 = pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) + { + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v2-1], &pParty->pPickedItem, 0x24u); + pMouse->RemoveHoldingItem(); + } + else + { + v12 = 0; + v3 = pParty->pPlayers; + while ( v3 <= &pParty->pPlayers[3] ) + { + v4 = v3->AddItem(-1, pParty->pPickedItem.uItemID); + if ( v4 ) + { + memcpy(&pParty->pPlayers[v12].pInventoryItems[v4], &pParty->pPickedItem, 0x24u); + pMouse->RemoveHoldingItem(); + break; + } + ++v12; + ++v3; + } + if ( v12 == 4 ) + { + v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + v6 = 0; + a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + { + LOWORD(v6) = 0; + } + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( v5 != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.spell_caster_pid = OBJECT_Player; + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + v8 = pIndoor->GetSector( + pParty->vPosition.x, + pParty->vPosition.y, + pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + a1.uSectorID = v8; + memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24)); + a1.Create(pParty->sRotationY, 184, 200, 0); + pMouse->RemoveHoldingItem(); + } + } + if ( !v11 ) + { + v1->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return 1; +} \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef Player.cpp --- a/Player.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Player.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -29,7 +29,8 @@ #include "mm7_data.h" #include "MM7.h" - +#include "SpriteObject.h" +#include "DecalBuilder.h" @@ -9561,4 +9562,767 @@ } } return result; +} +//----- (0043EE77) -------------------------------------------------------- +bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1) +{ + bool result; // eax@0 + Player *v2; // edx@3 + int v3; // ecx@3 + Player **pPlayers; // esi@8 + unsigned int v5; // ecx@8 + Player *v6; // edx@9 + + if ( a1 < 1 || a1 > 4 ) + { + if ( !a1 ) + { + pPlayers = &::pPlayers[1]; + v5 = 604; + while ( 1 ) + { + result = Player_has_item(v5, *pPlayers, 0); + if ( !result ) + break; + result = v6->pEquipment.uArmor; + if ( !result ) + break; + result *= 9; + if ( *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v5 ) + break; + ++pPlayers; + if ( (signed int)pPlayers >= (signed int)&qword_A750D8 ) + goto LABEL_13; + } + } + goto LABEL_6; + } + result = Player_has_item(604u, ::pPlayers[a1], 0); + if ( !result + || (result = v2->pEquipment.uArmor) == 0 + || (result *= 9, *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v3) ) + { +LABEL_6: + LOBYTE(result) = 0; + return result; + } +LABEL_13: + LOBYTE(result) = 1; + return result; +} +//----- (0043EE15) -------------------------------------------------------- +bool __fastcall Player_has_item(unsigned int uItemID, Player *pPlayer, char a3) +{ + if ( !a3 || pParty->pPickedItem.uItemID != uItemID ) + { + for ( uint i = 0; i < 126; ++i ) + { + if ( pPlayer->pInventoryIndices[i] > 0 ) + { + if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pInventoryIndices[i] - 1].uItemID == uItemID ) + return true; + } + } + for ( uint i = 0; i < 16; ++i ) + { + if ( pPlayer->pEquipment.pIndices[i] ) + { + if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pEquipment.pIndices[i] - 1].uItemID == uItemID ) + return true; + } + } + } + return false; +} +//----- (0043EDB9) -------------------------------------------------------- +bool __thiscall sub_43EDB9_get_some_race_sex_relation_2(unsigned int a1) +{ + unsigned int pNum; // ebp@1 + Player **pPlayer; // ebx@1 + Player *pPlayer2; // esi@2 + enum CHARACTER_RACE pRace; // edi@2 + bool pSex; // eax@2 + char v6; // zf@7 + +//pPlayer = &pPlayers[1]; + /*pNum = a1; + + while ( 1 ) + { + pPlayer2 = *pPlayer; + pRace = pPlayer2->GetRace(); + pSex = pPlayer2->GetSexByVoice(); + if ( !pRace ) + break; + if ( pRace == 1 || pRace == 2 ) + break; + if ( !pSex && pNum == 2 )// + //goto LABEL_15; + { + pSex = 1; + return pSex; + } + v6 = pNum == 3;// +LABEL_11: + if ( v6 ) + //goto LABEL_15; + { + pSex = 1; + return pSex; + } + ++pPlayer; + if ( (signed int)pPlayer >= (signed int)&qword_A750D8 )// + { + pSex = 0; + return pSex; + } + } + if ( pSex || pNum ) + { + v6 = pNum == 1; + goto LABEL_11; + } +//LABEL_15: + pSex = 1; + return pSex;*/ + for (uint i = 1; i <= 4; ++i) + { + pRace = pPlayers[i]->GetRace(); + pSex = pPlayers[i]->GetSexByVoice(); + if (pRace == 0 || pRace == 1 || pRace == 2 || pSex == 0 ) + return 1; + } + return 0; +} +//----- (0043ED6F) -------------------------------------------------------- +bool _43ED6F_check_party_races(bool a1) +{ + bool v6; // zf@5 + + for (uint i = 0; i < 4; ++i) + { + auto player = pParty->pPlayers + i; + auto race = player->GetRace(); + + if (race != CHARACTER_RACE_HUMAN && + race != CHARACTER_RACE_ELF && + race != CHARACTER_RACE_GOBLIN) + v6 = a1 == 1; + else + v6 = !a1; + + if (v6) + return true; + } + return false; +} +//----- (00439FCB) -------------------------------------------------------- +void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int a2, Vec3_int_ *pPos, unsigned int a4) +{ + signed int v4; // esi@1 + unsigned int v5; // ecx@1 + Player *v6; // ebx@3 + Actor *v7; // esi@3 + unsigned int v8; // eax@4 + char *v9; // eax@5 + signed int v10; // eax@6 + int v11; // edx@8 + int v12; // edx@9 + int v13; // edx@10 + int v14; // edx@16 + int v15; // edx@17 + int v16; // edx@18 + enum SoundID v17; // eax@24 + int v18; // eax@26 + unsigned __int8 v19; // zf@26 + unsigned __int8 v20; // sf@26 + unsigned __int16 v21; // ax@29 + signed int v22; // edi@36 + int v23; // eax@38 + signed int v24; // eax@44 + unsigned __int16 v25; // cx@47 + signed int v26; // eax@49 + int v27; // eax@54 + float v28; // ST18_4@58 + double v29; // st7@58 + float v30; // ST08_4@58 + double v31; // st7@58 + float v32; // ST04_4@58 + float v33; // ST00_4@58 + int v34; // edi@61 + int v35; // eax@70 + double v36; // st7@70 + SpriteObject *v37; // ebx@77 + int v38; // edi@77 + int v39; // esi@77 + int v40; // eax@77 + int v41; // eax@77 + int v42; // eax@78 + Player *v43; // eax@81 + Actor *v44; // esi@82 + Player *v45; // edi@84 + unsigned __int16 v46; // ax@84 + int v47; // ebx@105 + int v48; // eax@107 + unsigned __int16 v49; // ax@116 + int v50; // ebx@123 + unsigned __int16 v51; // ax@124 + char v52; // bl@124 + int v53; // eax@128 + signed int v54; // eax@134 + unsigned __int16 v55; // cx@137 + signed int v56; // eax@139 + int v57; // eax@144 + float v58; // ST18_4@148 + double v59; // st7@148 + float v60; // ST08_4@148 + double v61; // st7@148 + float v62; // ST04_4@148 + float v63; // ST00_4@148 + int v64; // ebx@151 + int v65; // eax@161 + double v66; // st7@161 + signed int v67; // ecx@164 + signed int v68; // eax@170 + int v69; // ecx@170 + int v70; // eax@171 + enum SoundID v71; // [sp+20h] [bp-34h]@12 + int v72; // [sp+30h] [bp-24h]@164 + double v73; // [sp+40h] [bp-14h]@72 + signed int v74; // [sp+44h] [bp-10h]@1 + unsigned int v75; // [sp+48h] [bp-Ch]@3 + unsigned int uActorID; // [sp+4Ch] [bp-8h]@1 + int v77; // [sp+50h] [bp-4h]@26 + signed int a4a; // [sp+60h] [bp+Ch]@162 + Player *a4b; // [sp+60h] [bp+Ch]@168 + + v4 = PID_ID(uObjID); + v5 = PID_TYPE(uObjID) - 2; + v74 = a2; + uActorID = v4; + if ( v5 ) + { + if ( v5 != 1 + || (v6 = &pParty->pPlayers[a4], v7 = &pActors[v4], + v75 = v6->sHealth, + !stru_50C198.ActorHitOrMiss(v7, v6)) ) + return; + v8 = v6->pEquipment.uArmor; + if ( !v8 + || (v9 = (char *)v6 + 36 * v8, v9[516] & 2) + || (v10 = pItemsTable->pItems[*((int *)v9 + 124)].uSkillType, v10 < 10) + || v10 > 11 ) + { + v14 = rand() % 4; + if ( !v14 ) + { + v71 = (SoundID)108; + goto LABEL_24; + } + v15 = v14 - 1; + if ( !v15 ) + { + v71 = (SoundID)109; + goto LABEL_24; + } + v16 = v15 - 1; + if ( !v16 ) + { + v71 = (SoundID)110; + goto LABEL_24; + } + if ( v16 == 1 ) + { + v71 = (SoundID)44; + goto LABEL_24; + } + } + else + { + v11 = rand() % 4; + if ( !v11 ) + { + v71 = (SoundID)105; + goto LABEL_24; + } + v12 = v11 - 1; + if ( !v12 ) + { + v71 = (SoundID)106; + goto LABEL_24; + } + v13 = v12 - 1; + if ( !v13 ) + { + v71 = (SoundID)107; + goto LABEL_24; + } + if ( v13 == 1 ) + { + v71 = (SoundID)45; +LABEL_24: + v17 = v71; + goto LABEL_26; + } + } + v17 = (SoundID)a4; +LABEL_26: + pAudioPlayer->PlaySound(v17, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0); + v18 = Actor::_43B3E0_CalcDamage(v7, v74); + v19 = HIDWORD(v7->pActorBuffs[3].uExpireTime) == 0; + v20 = SHIDWORD(v7->pActorBuffs[3].uExpireTime) < 0; + v77 = v18; + if ( !v20 && (!(v20 | v19) || LODWORD(v7->pActorBuffs[3].uExpireTime) > 0) ) + { + v21 = v7->pActorBuffs[3].uPower; + if ( v21 ) + v77 /= (signed int)v21; + } + if ( v74 ) + { + if ( v74 == 1 ) + { + v22 = v7->pMonsterInfo.uAttack2Type; + } + else + { + if ( v74 == 2 ) + { + v23 = v7->pMonsterInfo.uSpell1ID; + } + else + { + if ( v74 != 3 ) + { + if ( v74 == 4 ) + v22 = v7->pMonsterInfo.field_3C_some_special_attack; + else + v22 = 4; + goto LABEL_43; + } + v23 = v7->pMonsterInfo.uSpell2ID; + } + v22 = LOBYTE(pSpellStats->pInfos[v23].uSchool); + } + } + else + { + v22 = v7->pMonsterInfo.uAttack1Type; + } +LABEL_43: + if ( !(dword_6BE368_debug_settings_2 & 0x10) ) + { + v24 = v6->ReceiveDamage(v77, (DAMAGE_TYPE)v22); + if ( SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) >= 0 + && (SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v6->pPlayerBuffs[10].uExpireTime)) ) + { + v25 = v7->uAIState; + if ( v25 != 5 ) + { + if ( v25 != 4 ) + { + v26 = stru_50C198.CalcMagicalDamageToActor(v7, v22, v24); + v7->sCurrentHP -= v26; + if ( v26 ) + { + if ( v7->sCurrentHP >= 1 ) + { + Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); + Actor::AggroSurroundingPeasants(uActorID, 1); + } + else + { + if ( pMonsterStats->pInfos[v7->pMonsterInfo.uID].bQuestMonster & 1 ) + { + v27 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v7->uActorRadius : v7->uActorRadius; + v74 = v27; + if ( pRenderer->pRenderD3D ) + { + if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) + { + v28 = (double)v74; + v74 = v7->vPosition.z; + v29 = (double)v74; + v74 = v7->vPosition.y; + v30 = v29; + v31 = (double)v74; + v74 = v7->vPosition.x; + v32 = v31; + v33 = (double)v74; + pDecalBuilder->AddBloodsplat(v33, v32, v30, 1.0, 0.0, 0.0, v28, 0, 0); + } + } + } + Actor::Die(uActorID); + Actor::ApplyFineForKillingPeasant(uActorID); + Actor::AggroSurroundingPeasants(uActorID, 1); + if ( v7->pMonsterInfo.uExp ) + GivePartyExp(pMonsterStats->pInfos[v7->pMonsterInfo.uID].uExp); + v34 = SPEECH_51; + if ( rand() % 100 < 20 ) + v34 = ((signed int)v7->pMonsterInfo.uHP >= 100) + 1; + v6->PlaySound((PlayerSpeech)v34, 0); + } + } + } + } + } + if ( !(dword_6BE368_debug_settings_2 & 0x10) + && v7->pMonsterInfo.uSpecialAttack + && rand() % 100 < v7->pMonsterInfo.uLevel * v7->pMonsterInfo.uSpecialAttackType ) + v6->_48DCF6(v7->pMonsterInfo.uSpecialAttack, v7); + } + if ( !pParty->bTurnBasedModeOn ) + { + v35 = v6->GetActualEndurance(); + v36 = (double)(20 - v6->GetParameterBonus(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; + v6->SetRecoveryTime((signed __int64)v36); + } + if ( v77 ) + { + v73 = (double)(signed int)v75; + if ( (double)v6->GetMaxHealth() * 0.25 < v73 ) + { + if ( v6->sHealth > 0 ) + { + if ( (double)v6->GetMaxHealth() * 0.25 >= (double)v6->sHealth ) + v6->PlaySound(SPEECH_48, 0); + } + } + } + viewparams->bRedrawGameUI = 1; + return; + } + v37 = &pSpriteObjects[uActorID]; + v38 = PID_TYPE(v37->spell_caster_pid); + v39 = PID_ID(v37->spell_caster_pid); + v40 = PID_TYPE(v37->spell_caster_pid); + uActorID = PID_ID(v37->spell_caster_pid); + v41 = v40 - 2; + if ( !v41 ) + goto LABEL_80; + v42 = v41 - 1; + if ( !v42 ) + { + v44 = &pActors[v39]; + if ( a4 == -1 ) + a4 = stru_50C198.which_player_would_attack(v44); + v45 = &pParty->pPlayers[a4]; + v77 = Actor::_43B3E0_CalcDamage(v44, v74); + v46 = v37->uType; + if ( v37->uType == 545 ) + { + LOBYTE(v51) = v45->GetActualSkillLevel(PLAYER_SKILL_UNARMED); + v52 = v51; + if ( (signed int)SkillToMastery(v51) >= 4 && rand() % 100 < (v52 & 0x3F) ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[637], v45->pName); + ShowStatusBarString(pTmpBuf.data(), 2u); + v45->PlaySound(SPEECH_6, 0); + return; + } + } + else + { + if ( v46 != 555 + && v46 != 510 + && v46 != 500 + && v46 != 515 + && v46 != 505 + && v46 != 530 + && v46 != 525 + && v46 != 520 + && v46 != 535 + && v46 != 540 ) + goto LABEL_115; + } + if ( !stru_50C198.ActorHitOrMiss(v44, v45) ) + return; + if ( (signed __int64)v45->pPlayerBuffs[13].uExpireTime > 0 ) + v77 >>= 1; + if ( v45->HasEnchantedItemEquipped(36) ) + v77 >>= 1; + if ( v45->HasEnchantedItemEquipped(69) ) + v77 >>= 1; + if ( v45->HasItemEquipped(EQUIP_ARMOUR) + && *(_DWORD *)&v45->pInventoryItems[v45->pEquipment.uArmor-1] == 504 ) + v77 >>= 1; + v75 = 0; + v47 = (int)&v45->pEquipment; + do + { + if ( v45->HasItemEquipped((ITEM_EQUIP_TYPE)v75) ) + { + v48 = *(int *)&v45[36 * *(int *)v47 + 496]; + if ( v48 == 520 ) + v77 >>= 1; + if ( v48 == 531 ) + v77 >>= 1; + if ( v45->GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v75) == EQUIP_SHIELD && SkillToMastery(v45->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4 ) + v77 >>= 1; + } + ++v75; + v47 += 4; + } + while ( (signed int)v75 <= 1 ); +LABEL_115: + if ( (signed __int64)v44->pActorBuffs[3].uExpireTime > 0 ) + { + v49 = v44->pActorBuffs[3].uPower; + if ( v49 ) + v77 /= (signed int)v49; + } + if ( !v74 ) + { + v50 = v44->pMonsterInfo.uAttack1Type; + goto LABEL_133; + } + if ( v74 == 1 ) + { + v50 = v44->pMonsterInfo.uAttack2Type; + goto LABEL_133; + } + if ( v74 == 2 ) + { + v53 = v44->pMonsterInfo.uSpell1ID; + } + else + { + if ( v74 != 3 ) + { + if ( v74 == 4 ) + v50 = v44->pMonsterInfo.field_3C_some_special_attack; + else + v50 = 4; +LABEL_133: + if ( !(dword_6BE368_debug_settings_2 & 0x10) ) + { + v54 = v45->ReceiveDamage(v77, (DAMAGE_TYPE)v50); + if ( SHIDWORD(v45->pPlayerBuffs[10].uExpireTime) >= 0 ) + { + if ( SHIDWORD(v45->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v45->pPlayerBuffs[10].uExpireTime) ) + { + v55 = v44->uAIState; + if ( v55 != 5 ) + { + if ( v55 != 4 ) + { + v56 = stru_50C198.CalcMagicalDamageToActor(v44, v50, v54); + v44->sCurrentHP -= v56; + if ( v56 ) + { + if ( v44->sCurrentHP >= 1 ) + { + Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); + Actor::AggroSurroundingPeasants(uActorID, 1); + } + else + { + if ( pMonsterStats->pInfos[v44->pMonsterInfo.uID].bQuestMonster & 1 ) + { + v57 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v44->uActorRadius : v44->uActorRadius; + v75 = v57; + if ( pRenderer->pRenderD3D ) + { + if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) + { + v58 = (double)(signed int)v75; + v75 = v44->vPosition.z; + v59 = (double)(signed int)v75; + v75 = v44->vPosition.y; + v60 = v59; + v61 = (double)(signed int)v75; + v75 = v44->vPosition.x; + v62 = v61; + v63 = (double)(signed int)v75; + pDecalBuilder->AddBloodsplat(v63, v62, v60, 1.0, 0.0, 0.0, v58, 0, 0); + } + } + } + Actor::Die(uActorID); + Actor::ApplyFineForKillingPeasant(uActorID); + Actor::AggroSurroundingPeasants(uActorID, 1); + if ( v44->pMonsterInfo.uExp ) + GivePartyExp(pMonsterStats->pInfos[v44->pMonsterInfo.uID].uExp); + v64 = SPEECH_51; + if ( rand() % 100 < 20 ) + v64 = ((signed int)v44->pMonsterInfo.uHP >= 100) + 1; + v45->PlaySound((PlayerSpeech)v64, 0); + } + } + } + } + } + } + } + if ( !v74 + && !(dword_6BE368_debug_settings_2 & 0x10) + && v44->pMonsterInfo.uSpecialAttack + && rand() % 100 < v44->pMonsterInfo.uLevel * v44->pMonsterInfo.uSpecialAttackType ) + v45->_48DCF6(v44->pMonsterInfo.uSpecialAttack, v44); + if ( !pParty->bTurnBasedModeOn ) + { + v65 = v45->GetActualEndurance(); + v66 = (double)(20 - v45->GetParameterBonus(v65)) + * flt_6BE3A4_debug_recmod1 + * 2.133333333333333; + v45->SetRecoveryTime((signed __int64)v66); + } + return; + } + v53 = v44->pMonsterInfo.uSpell2ID; + } + v50 = LOBYTE(pSpellStats->pInfos[v53].uSchool); + goto LABEL_133; + } + if ( v42 != 1 ) + return; +LABEL_80: + if ( a4 != -1 ) + { + v43 = &pParty->pPlayers[a4]; +LABEL_168: + a4b = v43; + if ( v38 != OBJECT_Player || v37->spell_id != SPELL_BOW_ARROW) + { + v70 = v43->GetMaxHealth(); + v68 = _43AFE3_calc_spell_damage(v37->spell_id, v37->spell_level, v37->spell_skill, v70); + v69 = LOBYTE(pSpellStats->pInfos[v37->spell_id].uSchool); + } + else + { + v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0); + v69 = 0; + } + a4b->ReceiveDamage(v68, (DAMAGE_TYPE)v69); + if ( v38 == OBJECT_Player && !qword_A750D8 ) + { + qword_A750D8 = 256i64; + word_A750E0 = 44; + word_A750E2 = uActorID + 1; + } + return; + } + v74 = 0; + a4a = 1; + do + { + if ( pPlayers[a4a]->CanAct() ) + { + v67 = v74++; + *(&v72 + v67) = a4a; + } + ++a4a; + } + while ( a4a <= 4 ); + if ( v74 ) + { + v43 = &pParty->pPlayers[*(&v72+rand()%v74)-1];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552]; + goto LABEL_168; + } +} +//----- (00421EA6) -------------------------------------------------------- +void __cdecl OnInventoryLeftClick() +{ + Player *v0; // ebx@1 + signed int v1; // eax@2 + signed int v2; // ecx@2 + int v3; // eax@2 + char v4; // sf@2 + int v5; // eax@2 + unsigned int v6; // eax@7 + unsigned int v7; // esi@12 + unsigned int v8; // eax@12 + unsigned int v9; // eax@16 + unsigned int v10; // eax@18 + ItemGen this_; // [sp+Ch] [bp-3Ch]@1 + POINT a2; // [sp+30h] [bp-18h]@4 + unsigned int v13; // [sp+38h] [bp-10h]@13 + unsigned int pY; // [sp+3Ch] [bp-Ch]@2 + unsigned int pX; // [sp+40h] [bp-8h]@2 + int a4; // [sp+44h] [bp-4h]@2 + + v0 = pPlayers[uActiveCharacter]; + if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 ) + { + pMouse->GetClickPos(&pX, &pY); + pY = pY - 17; + v2 =pX - 14; + pX = v2; + v3 = 14 * (pY >> 5); + v2 >>= 5; + v4 = v2 + v3 < 0; + v5 = v2 + v3; + a4 = v5; + if ( !v4 ) + { + if ( v5 <= 126 && pMouse->GetCursorPos(&a2)->x < 462 + && pMouse->GetCursorPos(&a2)->x >= 14 ) + { + if ( unk_50C9A0 ) + { + v6 = v0->GetItemIDAtInventoryIndex(&a4); + if ( v6 ) + { + *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; + *((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]; + unk_50C9A0 = 0; + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pMouse->SetCursorBitmap("MICON1"); + dword_50C9D0 = 113; + dword_50C9D4 = 0; + dword_50C9D8 = 256; + } + return; + } + if ( ptr_50C9A4 ) + return; + v7 = pParty->pPickedItem.uItemID; + v8 = v0->GetItemIDAtInventoryIndex(&a4); + if ( !v7 ) + { + if ( !v8 ) + return; + memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem)); + v0->RemoveItemAtInventoryIndex(a4); + v9 = pParty->pPickedItem.uItemID; + pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); + return; + } + v13 = v8; + if ( v8 ) + { + a2.y = (LONG)&v0->pInventoryItems[v8-1]; + memcpy(&this_, (const void *)a2.y, sizeof(this_)); + v0->RemoveItemAtInventoryIndex(a4); + pX = v0->AddItem2(a4, &pParty->pPickedItem); + if ( !pX ) + { + pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem); + if ( !pX ) + { + v0->PutItemArInventoryIndex(&this_, v13 - 1, a4); + memcpy((void *)a2.y, &this_, sizeof(ItemGen)); + return; + } + } + v9 = this_.uItemID; + memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem)); + pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); + return; + } + v10 = v0->AddItem(a4, v7); + pX = v10; + if ( v10 || (v10 = v0->AddItem(-1, pParty->pPickedItem.uItemID), (pX = v10) != 0) ) + { + memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u); + pMouse->RemoveHoldingItem(); + } + } + } + } } \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef Render.cpp --- a/Render.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Render.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -11016,4 +11016,8 @@ break; } } - +//----- (0040DF3D) -------------------------------------------------------- +void __cdecl CallRenderPresent() +{ + pRenderer->Present(); +} diff -r c423f946dc99 -r 5450af4f57ef SaveLoad.cpp --- a/SaveLoad.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/SaveLoad.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -23,6 +23,8 @@ #include "stru123.h" #include "texts.h" #include "Log.h" +#include "Allocator.h" +#include "VideoPlayer.h" #include "mm7_data.h" @@ -610,4 +612,246 @@ } } _chdir(".."); +} +//----- (0046086A) -------------------------------------------------------- +void SaveNewGame() +{ + FILE *v3; // eax@7 + void *pSave; // [sp+170h] [bp-8h]@3 + + if ( pVideoPlayer->AnyMovieLoaded() ) + pVideoPlayer->Unload(); + pSave = pAllocator->AllocNamedChunk(0, 1000000, 0); + pNew_LOD->CloseWriteFile(); + remove("data\\new.lod"); + + LOD::FileHeader this_; // [sp+Ch] [bp-16Ch]@3 + strcpy(this_.LodVersion, "MMVII"); + strcpy(this_.LodDescription, "newmaps for MMVII"); + this_.LODSize = 100; + this_.dword_0000A8 = 0; + + LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3 + a3.dword_000018 = 0; + a3.word_00001E = 0; + strcpy(a3.pFilename, "current"); + pNew_LOD->CreateNewLod(&this_, &a3, "data\\new.lod"); + if (pNew_LOD->LoadFile("data\\new.lod", false)) + { + pNew_LOD->CreateTempFile(); + pNew_LOD->uNumSubDirs = 0; + + LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4 + for (int i = pGames_LOD->uNumSubDirs / 2; i < pGames_LOD->uNumSubDirs; ++i) + { + memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir)); + v3 = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1); + fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, v3); + pNew_LOD->AppendDirectory(&pDir, pSave); + } + + LOD::Directory save_game_dir; // [sp+12Ch] [bp-4Ch]@9 + strcpy(pSavegameHeader[0].pLocationName, "out01.odm"); + strcpy(save_game_dir.pFilename, "header.bin"); + save_game_dir.uDataSize = sizeof(SavegameHeader); + pNew_LOD->AppendDirectory(&save_game_dir, &pSavegameHeader[0]); + + pNew_LOD->FixDirectoryOffsets(); + pParty->vPrevPosition.y = 0; + pParty->vPrevPosition.x = 12552; + pParty->vPosition.x = 12552; + pParty->vPosition.z = 0; + pParty->uFallStartY = 0; + pParty->sPrevRotationX = 0; + pParty->sRotationX = 0; + pParty->vPrevPosition.z = 1816; + pParty->vPosition.y = 1816; + pParty->sPrevRotationY = 512; + pParty->sRotationY = 512; + SaveGame(1, 1); + } + pAllocator->FreeChunk(pSave); +} +//----- (0045E03A) -------------------------------------------------------- +unsigned short * MakeScreenshot( signed int width, signed int height ) +{ + //signed int v2; // edi@1 + unsigned __int16 *v3; // ebx@1 + int v4; // edx@7 + unsigned __int8 v5; // cf@9 + unsigned int v6; // ecx@9 + unsigned __int16 *v7; // edi@9 + int j; // ecx@9 + //unsigned __int16 *v9; // edi@15 + //int v10; // ecx@15 + //LONG v11; // esi@15 + //signed __int64 v12; // qax@18 + //unsigned int v13; // ST10_4@21 + HRESULT v14; // eax@21 + int v15; // edi@29 + signed __int64 v16; // qax@30 + signed int v17; // edx@34 + unsigned __int16 *v18; // edi@36 + int k; // ecx@36 + DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 + unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 + float v23; // [sp+84h] [bp-20h]@1 + unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 + float v25; // [sp+8Ch] [bp-18h]@1 + unsigned int v26; // [sp+90h] [bp-14h]@17 + //int v27; // [sp+94h] [bp-10h]@1 + int v28; // [sp+98h] [bp-Ch]@16 + int v29; // [sp+9Ch] [bp-8h]@15 + //int v30; // [sp+A0h] [bp-4h]@1 + + //v30 = width; + //v2 = height; + //v27 = height; + v23 = game_viewport_width / (double)width; + v25 = game_viewport_height / (double)height; + + pPixels = (unsigned __int16 *)malloc(2 * height * width); + memset(pPixels, 0 , 2 * height * width); + + v3 = pPixels; + if ( pRenderer->pRenderD3D ) + { + pRenderer->BeginSceneD3D(); + + if (uCurrentlyLoadedLevelType == LEVEL_Indoor) + pIndoor->Draw(); + else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) + pOutdoor->Draw(); + + pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); + memset(&Dst, 0, 0x7Cu); + Dst.dwSize = sizeof(Dst); + + if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) + { + auto src = (unsigned __int16 *)Dst.lpSurface; + auto src_width = (Dst.lPitch / sizeof(short)); + auto src_height = Dst.dwHeight; + auto dst = pPixels; + for (uint y = 0; y < height; ++y) + { + //uint src_y = (game_viewport_y + y * v25) * (Dst.lPitch / sizeof(short)); + uint src_y = game_viewport_y + y * v25; + assert(game_viewport_y + y * v25 < src_height); + assert(y < height); + + for (uint x = 0; x < width; ++x) + { + //uint src_x = game_viewport_x + x * v23; + uint src_x = game_viewport_x + x * v23; + assert(src_x < src_width); + assert(x < width); + + dst[y * width + x] = (((63*y)/117) << 5) | 31*x/155;//31*y/117;//src[src_y * src_width + src_x]; + } + } + ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); + } + else + { + __debugbreak(); // unrefactored + v4 = height; + if ( height > 0 ) + { + do + { + if ( width > 0 ) + { + v5 = width & 1; + v6 = (unsigned int)width >> 1; + memset(v3, 0, 4 * ((unsigned int)width >> 1)); + v7 = &v3[2 * v6]; + for ( j = v5; j; --j ) + { + *v7 = 0; + ++v7; + } + v3 += width; + } + --v4; + } + while ( v4 ); + } + } + } + else + { + pRenderer->BeginScene(); + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) + { + pIndoor->Draw(); + } + else + { + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) + pOutdoor->Draw(); + } + _this = pRenderer->pTargetSurface; + v26 = pRenderer->uTargetSurfacePitch; + if ( pRenderer->pTargetSurface ) + { + v29 = 0; + if ( height > 0 ) + { + do + { + v28 = 0; + if ( width > 0 ) + { + v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0); + do + { + v16 = (signed __int64)((double)v28++ * v23 + 8.0); + *v3 = _this[v15 + (int)v16]; + ++v3; + } + while ( v28 < width ); + } + ++v29; + } + while ( v29 < height ); + } + } + else + { + if ( height > 0 ) + { + v17 = height; + do + { + if ( width > 0 ) + { + memset(v3, 0, 4 * ((unsigned int)width >> 1)); + v18 = &v3[2 * ((unsigned int)width >> 1)]; + for ( k = width & 1; k; --k ) + { + *v18 = 0; + ++v18; + } + v3 += width; + } + --v17; + } + while ( v17 ); + } + } + pRenderer->EndScene(); + } + return pPixels; +} +//----- (0045E26C) -------------------------------------------------------- +void __thiscall SaveScreenshot(const char *pFilename) +{ + const char *v1; // edi@1 + unsigned __int16 *v2; // esi@1 + + v1 = pFilename; + v2 = MakeScreenshot(92, 68); + pRenderer->SavePCXImage(v1, (char *)v2, 92, 68); + free(v2); } \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef Spells.cpp --- a/Spells.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Spells.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -1175,4 +1175,44 @@ else result = 0; return result; +} +//----- (0043AFE3) -------------------------------------------------------- +int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4) +{ + int result; // eax@1 + unsigned int v5; // [sp-4h] [bp-8h]@9 + + result = 0; + if ( a1 == 7 ) + { + if ( a3 <= 0 ) + return result; + if ( a3 <= 2 ) + { + v5 = 6; + } + else + { + if ( a3 == 3 ) + { + v5 = 8; + } + else + { + if ( a3 != 4 ) + return result; + v5 = 10; + } + } + result = GetDiceResult(a2, v5); + } + else + { + if ( a1 == 44 ) + result = a4 * (LOBYTE(pSpellDatas[40].field_10) + 2 * a2) / 100; + else + result = *((char *)&pSpellDatas[0].field_10 + 20 * a1) + + GetDiceResult(a2, *((char *)&pSpellDatas[0].field_10 + 20 * a1 + 1)); + } + return result; } \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef SpriteObject.cpp --- a/SpriteObject.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/SpriteObject.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -1087,4 +1087,133 @@ memcpy(&pSpriteObjects[new_obj_pos++], &pSpriteObjects[i],sizeof(SpriteObject)); } uNumSpriteObjects = new_obj_pos; - } \ No newline at end of file + } +//----- (00408896) -------------------------------------------------------- +void InitializeSpriteObjects() +{ + for (uint i = 0; i < uNumSpriteObjects; ++i) + { + auto item = &pSpriteObjects[i]; + + if (item->uType && + (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & 0x10)) + SpriteObject::OnInteraction(i); + } + + for (uint i = 0; i < 100; ++i) + array_5118E8.pElements[i].field_C_time_left = 0; +} +//----- (0046BEF1) -------------------------------------------------------- +void SpriteObject::_46BEF1_apply_spells_aoe() +{ + SpriteObject *v1; // edi@1 + Actor *v2; // esi@2 + __int16 v3; // fps@4 + unsigned __int8 v4; // c0@4 + unsigned __int8 v5; // c3@4 + signed int v6; // [sp+8h] [bp-4h]@1 + + int v7,v8,v9,v10,v11; + + v6 = 0; + v1 = this; + if ( (signed int)uNumActors > 0 ) + { + v2 = pActors.data();//[0].vPosition.y; + do + { + if ( v2->CanAct() ) + { + //UNDEF(v3); + //.text:0046BF26 movsx eax, word ptr [esi-2] + //.text:0046BF2A sub eax, [edi+4] + //.text:0046BF31 mov [ebp+var_8], eax + //.text:0046BF37 fild [ebp+var_8] + // v7 pushed to stack + v7 = v2->vPosition.x - this->vPosition.x; + + //.text:0046BF2D movsx ecx, word ptr [esi+2] + v8 = v2->vPosition.z; + + //.text:0046BF34 movsx eax, word ptr [esi] + //.text:0046BF3A sub eax, [edi+8] + //.text:0046BF3D mov [ebp+var_8], eax + //.text:0046BF44 fild [ebp+var_8] + // v9 pushed to stack + v9 = v2->vPosition.y - this->vPosition.y; + + //.text:0046BF40 movsx eax, word ptr [esi-6] + //.text:0046BF47 sar eax, 1 + //.text:0046BF49 add eax, ecx + //.text:0046BF4B sub eax, [edi+0Ch] + //.text:0046BF4E mov [ebp+var_8], eax + //.text:0046BF51 fild [ebp+var_8] + //.text:0046BF58 fld st + // v10 pushed to stack, two times + v10 = v2->uActorHeight / 2 + v8 - this->vVelocity.y; + + //.text:0046BF54 movsx eax, word ptr [esi-8] + //.text:0046BF5A add eax, 100h + //.text:0046BF63 mov ecx, eax + v11 = this->vVelocity.x; + + //.text:0046BF5F fmul st, st(1) + // stack: v10*v10, v10, v9, v7 + //.text:0046BF61 fld st(2) + // stack: v7, v10*v10, v10, v9, v7 + + + //.text:0046BF65 fmul st, st(3) + // stack: v7*v9, v10*v10, v10, v9, v7 + + //.text:0046BF67 imul ecx, eax + v11 = v11 * v11; + + //.text:0046BF6A faddp st(1), st + // stack: v10*v10+v7*v9, v10, v9, v7 + //.text:0046BF6C fld st(3) + // stack: v7, v10*v10+v7*v9, v10, v9, v7 + //.text:0046BF6E fmul st, st(4) + // stack: v7*v7, v10*v10+v7*v9, v10, v9, v7 + //.text:0046BF70 faddp st(1), st + // stack: v10*v10+v7*v9+v7*v7, v10, v9, v7 + + //.text:0046BF72 mov [ebp+var_8], ecx + //.text:0046BF75 fild [ebp+var_8] + // v11 pushed to stack + + //.text:0046BF78 fcompp + // if ( v11 > v10*v10+v7*v9+v7*v7 ) + // stack: v10, v9, v7 + + //.text:0046BF7A fstp st + // stack: v9, v7 + + //.text:0046BF7C fnstsw ax + //.text:0046BF7E fstp st + // stack: v7 + + //.text:0046BF80 test ah, 41h + //.text:0046BF83 fstp st + //.text:0046BF85 jnz short loc_46BFDD + + if ( v11 >= v10*v10+v7*v9+v7*v7 ) + { + if ( stru_50C198.GetMagicalResistance(v2, 0xAu) ) + { + v2->pActorBuffs[v1->spell_id].Apply( + pParty->uTimePlayed + (signed int)(signed __int64)((double)(v1->spell_level << 7) * 0.033333335), + v1->spell_skill, + 4u, + 0, + 0); + HIWORD(v2->uAttributes) |= 8u; + } + } + } + ++v6; + ++v2; + } + while ( v6 < (signed int)uNumActors ); + } +} \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef Texture.cpp --- a/Texture.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Texture.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -1636,4 +1636,121 @@ field_18 = 0; field_20 = 0; field_22 = 0; -} \ No newline at end of file +} +//----- (0044E1EC) -------------------------------------------------------- +int TextureFrameTable::FromFileTxt(const char *Args) +{ + TextureFrameTable *v2; // ebx@1 + FILE *v3; // eax@1 + int v4; // esi@3 + const void *v5; // ST0C_4@10 + void *v6; // eax@10 + FILE *v7; // ST0C_4@12 + char *i; // eax@12 + signed int v9; // esi@15 + int v10; // eax@17 + int v11; // edx@22 + int v12; // ecx@23 + int v13; // eax@24 + signed int j; // eax@27 + TextureFrame *v15; // edx@28 + int v16; // esi@28 + int k; // ecx@29 + char Buf; // [sp+Ch] [bp-2F8h]@3 + FrameTableTxtLine v20; // [sp+200h] [bp-104h]@4 + int v21; // [sp+27Ch] [bp-88h]@4 + char *Str1; // [sp+280h] [bp-84h]@5 + char *Str; // [sp+284h] [bp-80h]@15 + int v24; // [sp+2F8h] [bp-Ch]@3 + int v25; // [sp+2FCh] [bp-8h]@3 + FILE *File; // [sp+300h] [bp-4h]@1 + int Argsa; // [sp+30Ch] [bp+8h]@28 + + v2 = this; + v3 = fopen(Args, "r"); + File = v3; + if ( !v3 ) + Abortf("CTextureFrameTable::load - Unable to open file: %s.", Args); + v4 = 0; + v24 = 0; + v25 = 1; + if ( fgets(&Buf, 490, v3) ) + { + do + { + *strchr(&Buf, 10) = 0; + memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); + if ( v21 && *Str1 != 47 ) + { + if ( v21 < 2 ) + Abortf("CTextureFrameTable::load, too few arguments, %s line %i.", Args, v25); + ++v24; + } + ++v25; + } + while ( fgets(&Buf, 490, File) ); + v4 = v24; + } + v5 = v2->pTextures; + v2->sNumTextures = v4; + v6 = pAllocator->AllocNamedChunk(v5, 20 * v4, "Txt Frames"); + v2->pTextures = (TextureFrame *)v6; + if ( !v6 ) + Abortf("CTextureFrameTable::load - Out of Memory!"); + v7 = File; + v2->sNumTextures = 0; + fseek(v7, 0, 0); + for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) + { + *strchr(&Buf, 10) = 0; + memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); + if ( v21 && *Str1 != 47 ) + { + strcpy(v2->pTextures[v2->sNumTextures].pTextureName, Str1); + v2->pTextures[v2->sNumTextures].uAnimTime = atoi(Str); + v9 = 2; + for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 ) + { + if ( !_stricmp((&Str1)[4 * v9], "New") ) + { + v10 = (int)&v2->pTextures[v2->sNumTextures].uFlags; + *(char *)v10 |= 2u; + } + } + ++v2->sNumTextures; + } + } + fclose(File); + v11 = 0; + if ( (signed int)(v2->sNumTextures - 1) > 0 ) + { + v12 = 0; + do + { + v13 = (int)&v2->pTextures[v12]; + if ( !(*(char *)(v13 + 38) & 2) ) + *(char *)(v13 + 18) |= 1u; + ++v11; + ++v12; + } + while ( v11 < (signed int)(v2->sNumTextures - 1) ); + } + for ( j = 0; j < (signed int)v2->sNumTextures; *(short *)(Argsa + 16) = v16 ) + { + v15 = v2->pTextures; + Argsa = (int)&v15[j]; + v16 = *(short *)(Argsa + 14); + if ( *(char *)(Argsa + 18) & 1 ) + { + ++j; + for ( k = (int)&v15[j]; *(char *)(k + 18) & 1; k += 20 ) + { + v16 += *(short *)(k + 14); + ++j; + } + LOWORD(v16) = v15[j].uAnimTime + v16; + } + ++j; + } + return 1; +} diff -r c423f946dc99 -r 5450af4f57ef UICharacter.cpp --- a/UICharacter.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/UICharacter.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -25,8 +25,8 @@ #include "texts.h" #include "mm7_data.h" - - +#include "Mouse.h" +#include "Allocator.h" int bRingsShownInCharScreen; // 5118E0 @@ -2630,3 +2630,496 @@ IsPlayerWearingWatersuit[uPlayerID] = 0; } } +//----- (00468F8A) -------------------------------------------------------- +void __cdecl OnPaperdollLeftClick() +{ + int v1; // ecx@1 + unsigned int v2; // edi@1 + unsigned int v3; // edx@4 + unsigned int pSkillType; // esi@5 + unsigned __int16 v5; // ax@7 + unsigned int v6; // edi@19 + int v7; // esi@27 + unsigned int v8; // eax@29 + int v9; // edx@32 + int v10; // esi@34 + int v11; // eax@34 + int v12; // esi@38 + int v13; // eax@38 + char v14; // zf@38 + int v15; // esi@42 + int v16; // eax@42 + int v17; // eax@44 + unsigned int v18; // ecx@55 + unsigned int v19; // eax@55 + int v20; // esi@60 + int v21; // eax@60 + unsigned int v22; // eax@61 + unsigned int v23; // eax@62 + int v24; // esi@65 + int v25; // eax@65 + unsigned int v26; // eax@69 + int v27; // esi@81 + int v28; // eax@81 + int v29; // esi@84 + int v30; // eax@84 + int v31; // eax@85 + unsigned int v32; // ecx@88 + unsigned int v33; // eax@88 + int v34; // esi@90 + unsigned int v35; // eax@91 + int v36; // esi@93 + int v37; // edi@93 + ItemGen *v38; // edi@93 + __int16 v39; // dx@99 + ItemGen _this; // [sp+Ch] [bp-40h]@1 + unsigned int v48; // [sp+30h] [bp-1Ch]@88 + 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 v53; // [sp+44h] [bp-8h]@1 + //unsigned int v54; // [sp+48h] [bp-4h]@1 + + v51 = 0; + _this.Reset(); + //v0 = pPlayers[uActiveCharacter]; + v1 = pPlayers[uActiveCharacter]->pEquipment.uMainHand; + v2 = pPlayers[uActiveCharacter]->pEquipment.uShield; + //v54 = pPlayers[uActiveCharacter]->pEquipment.uShield; + //v53 = v1; + if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1 - 1]].uEquipType == 1 ) + v51 = v1; + v3 = pParty->pPickedItem.uItemID; + if ( pParty->pPickedItem.uItemID ) + { + v52 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType; + pSkillType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSkillType; + if ( pSkillType == 4 ) + { + if ( v2 ) + { + LOBYTE(v5) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_SPEAR); + if ( (signed int)SkillToMastery(v5) < 3 ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + v3 = pParty->pPickedItem.uItemID; + } + } + else + { + if ( (pSkillType == 8 || pSkillType == 1 || pSkillType == 2) + && v1 + && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1-1]].uSkillType == 4 ) + { + LOBYTE(v5) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_SPEAR); + if ( (signed int)SkillToMastery(v5) < 3 ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + } + } + if ( !pPlayers[uActiveCharacter]->CanEquip_RaceAndAlignmentCheck(v3) ) + { + + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + if ( pParty->pPickedItem.uItemID == 604 ) + { + pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)3); + WetsuitOn(uActiveCharacter); + return; + } + v6 = v52; + switch ( v52 ) + { + case 2u: + case 3u: + case 5u: + case 6u: + case 7u: + case 8u: + case 9u: + case 0xBu: + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) && (v6 != 3 || bUnderwater) ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)v6); + if ( pParty->pPickedItem.uItemID == 604 ) + WetsuitOff(uActiveCharacter); + return; + case 0xAu: + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + v52 = 10; + v7 = (int)&pPlayers[uActiveCharacter]->pEquipment.uRings; + while ( 1 ) + { + if ( !*(int *)v7 ) + { + v8 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + if ( (v8 & 0x80000000u) == 0 ) + { + v9 = v52; + pParty->pPickedItem.uBodyAnchor = v52 + 1; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v8], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v8])); + *(&pPlayers[uActiveCharacter]->pEquipment.uShield + v9) = v8 + 1; + pMouse->RemoveHoldingItem(); + break; + } + } + ++v52; + v7 += 4; + if ( (signed int)v52 > 15 ) + break; + } + if ( v52 == 16 ) + { + v52 = pPlayers[uActiveCharacter]->pEquipment.uRings[6] - 1; + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v10 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v52); + *(char *)(v10 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v10 + 532)); + _this.uBodyAnchor = 16; + v11 = v52 + 1; + memcpy((void *)(v10 + 532), &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uRings[6] = v11; + } + return; + case 4u: + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + if ( v2 ) + { + --v2; + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); + *(char *)(v12 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v12 + 532)); + _this.uBodyAnchor = 1; + v13 = v2 + 1; + v14 = v51 == 0; + memcpy((void *)(v12 + 532), &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uShield = v13; + if ( v14 ) + return; + } + else + { + v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + if ( (v52 & 0x80000000u) != 0 ) + return; + if ( !v51 ) + { + pParty->pPickedItem.uBodyAnchor = 1; + v17 = v52 + 1; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + pPlayers[uActiveCharacter]->pEquipment.uShield = v17; + pMouse->RemoveHoldingItem(); + return; + } + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v1 - 1)); + *(char *)(v15 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v15 + 532)); + _this.uBodyAnchor = 1; + v16 = v52 + 1; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + pPlayers[uActiveCharacter]->pEquipment.uShield = v16; + } + pPlayers[uActiveCharacter]->pEquipment.uMainHand = 0; + return; + case 0u: + case 0xCu: + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) + && pParty->pPickedItem.uItemID != 64 + && pParty->pPickedItem.uItemID != 65 ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + v50 = 0; + if ( pSkillType == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[2] & 0xFFC0) + || pSkillType == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[1]) >= 3 ) + { + + v18 = pMouse->uMouseClickX; + v19 = pMouse->uMouseClickY; + + v49 = v19; + if ( (signed int)v18 >= 560 ) + { + if ( !v51 ) + { + if ( v2 ) + { + --v2; + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); + *(char *)(v20 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v20 + 532)); + _this.uBodyAnchor = 1; + v21 = v2 + 1; + v14 = v52 == 12; + memcpy((void *)(v20 + 532), &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uShield = v21; + if ( !v14 ) + return; + v22 = _this.uItemID; + v50 = v22; + if ( v50 ) + { + __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); + } + break; + } + v23 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + if ( (v23 & 0x80000000u) != 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])); + pPlayers[uActiveCharacter]->pEquipment.uShield = v23 + 1; + pMouse->RemoveHoldingItem(); + if ( v52 != 12 ) + return; + v22 = *(int *)v50; + v50 = v22; + if ( v50 ) + { + __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); + } + break; + } + } + } + if ( !v1 ) + { + v26 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + if ( (v26 & 0x80000000u) != 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])); + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v26 + 1; + pMouse->RemoveHoldingItem(); + if ( v52 != 12 ) + return; + v22 = *(int *)v50; + v50 = v22; + if ( v50 ) + { + __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); + } + break; + } + --v1; + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); + *(char *)(v24 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v24 + 532)); + _this.uBodyAnchor = 2; + v25 = v1 + 1; + v14 = v52 == 12; + memcpy((void *)(v24 + 532), &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v25; + if ( v14 ) + v50 = _this.uItemID; + if ( v51 ) + pPlayers[uActiveCharacter]->pEquipment.uShield = 0; + if ( v50 ) + { + __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 + stru_A750F8[uActiveCharacter - 1]._494836( *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); + } + break; + case 1u: + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + if ( v1 ) + { + if ( v2 ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + --v1; + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); + *(char *)(v27 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v27 + 532)); + _this.uBodyAnchor = 2; + v28 = v1 + 1; + memcpy((void *)(v27 + 532), &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v28; + } + else + { + v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + if ( (v52 & 0x80000000u) == 0 ) + { + if ( v2 ) + { + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v2 - 1)); + *(char *)(v29 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v29 + 532)); + _this.uBodyAnchor = 2; + v30 = v52 + 1; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + pPlayers[uActiveCharacter]->pEquipment.uShield = 0; + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v30; + } + else + { + pParty->pPickedItem.uBodyAnchor = 2; + v31 = v52 + 1; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v31; + pMouse->RemoveHoldingItem(); + } + } + } + return; + default: + pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(uActiveCharacter, 0); + return; + } + return; + } + + v32 = pMouse->uMouseClickX; + v33 = pMouse->uMouseClickY; + + v34 = pRenderer->pActiveZBuffer[v32 + pSRZBufferLineOffsets[v33]] & 0xFFFF; + if ( v34 ) + { + v36 = v34 - 1; + v37 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v36); + v50 = v37; + v38 = (ItemGen *)(v37 + 532); + v14 = v38->uItemID == 604; + v52 = pItemsTable->pItems[v38->uItemID].uEquipType; + if ( v14 ) + { + if ( bUnderwater ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + WetsuitOff(uActiveCharacter); + } + if ( unk_50C9A0 ) + { + *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; + *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; + v39 = v52; + *((int *)pGUIWindow_Settings->ptr_1C + 3) = v36; + *((short *)pGUIWindow_Settings->ptr_1C + 3) = v39; + ptr_50C9A4 = v38; + unk_50C9A0 = 0; + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pMouse->SetCursorBitmap("MICON1"); + dword_50C9D4 = 0; + dword_50C9D0 = 113; + dword_50C9D8 = 256; + } + else + { + if ( !ptr_50C9A4 ) + { + pParty->SetHoldingItem(v38); + *(&pPlayers[uActiveCharacter]->uBirthYear + *(char *)(v50 + 556)) = 0; + v38->Reset(); + } + } + } + else + { + v35 = pPlayers[uActiveCharacter]->pEquipment.uBow; + if ( v35 ) + { + auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v35 - 1]; + pParty->SetHoldingItem(_a); + _a->Reset(); + pPlayers[uActiveCharacter]->pEquipment.uBow = 0; + } + } +} +//----- (004196A0) -------------------------------------------------------- +void CharacterUI_ReleaseButtons() +{ + GUIButton *i; // esi@2 + GUIButton *j; // esi@7 + + if ( dword_507CC0_activ_ch ) + { + dword_507CC0_activ_ch = 0; + for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = j ) + { + j=i->pNext; + if ( BYTE1(i->field_1C) & 0x80 ) + { + i->Release(); + pAllocator->FreeChunk(i); + } + } + for ( j = pGUIWindow_CurrentMenu->pControlsHead; j; j = j->pNext ) + { + if ( j->msg == UIMSG_InventoryLeftClick) + { + j->uX = dword_50698C_uX; + j->uY = dword_506988_uY; + j->uZ = dword_506984_uZ; + j->uW = dword_506980_uW; + pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(1, 0, 0, 0); + } + } + } +} \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef UIHouses.cpp --- a/UIHouses.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/UIHouses.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -6730,3 +6730,329 @@ a1.DrawText(v47, 13, 354 - v48, 0, v49, 0, 0, 0); } } +//----- (004BDB56) -------------------------------------------------------- +void __cdecl UIShop_Buy_Identify_Repair() +{ + int v8; // eax@15 + unsigned int pItemID; // esi@20 + ItemGen *item; // esi@21 + unsigned int v15; // eax@33 + POINT *pCursorPos; // esi@37 + int v18; // ecx@37 + float pPriceMultiplier; // ST1C_4@38 + int taken_item; // eax@40 + ItemGen *bought_item; // esi@51 + int party_reputation; // eax@55 + int v39; // eax@63 + int v42; // esi@74 + signed int v43; // ebx@74 + unsigned __int16 *pSkill; // esi@77 + int v55; // [sp+0h] [bp-B4h]@26 + POINT cursor; // [sp+40h] [bp-74h]@37 + int a6; // [sp+98h] [bp-1Ch]@57 + int a3; // [sp+9Ch] [bp-18h]@53 + unsigned int uNumSeconds; // [sp+A4h] [bp-10h]@53 + unsigned int v79; // [sp+A8h] [bp-Ch]@9 + int uPriceItemService; // [sp+ACh] [bp-8h]@12 + + if ( pCurrentScreen == SCREEN_E ) + { + OnInventoryLeftClick(); + return; + } + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + + switch(dialog_menu_id) + { + case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: + { + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; + OnInventoryLeftClick(); + break; + } + case HOUSE_DIALOGUE_GUILD_BUY_BOOKS: + { + pCursorPos = pMouse->GetCursorPos(&cursor); + v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&cursor)->y]] & 0xFFFF; + if ( !v18 ) + return; + bought_item = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C)); + pPriceMultiplier = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; + uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), pPriceMultiplier); + GetAsyncKeyState(VK_CONTROL); + if ( pParty->uNumGold < uPriceItemService ) + { + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); + return; + } + taken_item = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID); + if ( taken_item ) + { + bought_item->SetIdentified(); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[taken_item - 1], bought_item, 0x24u); + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); + pRenderer->ClearZBuffer(0, 479); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); + return; + } + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 5); // "Pack is Full!" + break; + } + case HOUSE_DIALOGUE_SHOP_SELL: + { + v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); + if ( pMouse->GetCursorPos(&cursor)->x <= 13 + || 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) ) + { + dword_F8B1E4 = 1; + pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)window_SpeakInHouse->ptr_1C); + viewparams->bRedrawGameUI = 1; + pRenderer->ClearZBuffer(0, 479); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)77, 0); + return; + } + pPlayers[uActiveCharacter]->PlaySound(SPEECH_79, 0); + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + break; + } + case HOUSE_DIALOGUE_SHOP_IDENTIFY: + { + pMouse->GetCursorPos(&cursor); + v79 = ((cursor.x - 14) >> 5) + 14 * ((cursor.y - 17) >> 5); + if (cursor.x > 13 && cursor.x < 462) + { + pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); + if ( pItemID ) + { + uPriceItemService = pPlayers[uActiveCharacter]->GetPriceIdentification(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); + item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + if ( !(item->uAttributes & 1) ) + { + if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) + { + if ( pParty->uNumGold >= uPriceItemService ) + { + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + item->uAttributes |= 1; + pPlayers[uActiveCharacter]->PlaySound(SPEECH_73, 0); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[569], 2); + return; + } + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); + return; + } + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0); + return; + } + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0); + return; + } + } + break; + } + case HOUSE_DIALOGUE_SHOP_REPAIR: + { + v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); + if ( pMouse->GetCursorPos(&cursor)->x > 13 ) + { + if ( pMouse->GetCursorPos(&cursor)->x < 462 ) + { + pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); + if ( pItemID ) + { + item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + pPriceMultiplier = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; + auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + uPriceItemService = pPlayers[uActiveCharacter]->GetPriceRepair(_v->GetValue(), pPriceMultiplier); + if ( item->uAttributes & 2 ) + { + if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) + { + if ( pParty->uNumGold >= uPriceItemService ) + { + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + v8 = item->uAttributes; + LOBYTE(v8) = v8 & 0xFD; + item->uAttributes = v8 | 1; + pPlayers[uActiveCharacter]->PlaySound(SPEECH_74, 0); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[570], 2); + return; + } + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); + return; + } + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0); + return; + } + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0); + return; + } + } + } + break; + } + case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: + case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: + { + pCursorPos = pMouse->GetCursorPos(&cursor); + v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pCursorPos->y]] & 0xFFFF; + if ( !v18 ) + return; + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + bought_item = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1]; + else + bought_item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];//(ItemGen *)&pParty->field_C59C[v31 + 724]; + uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); + uNumSeconds = 0; + a3 = 0; + if ( pMapStats->GetMapInfo(pCurrentMapName.data()) ) + a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName.data())]._steal_perm; + party_reputation = GetPartyReputation(); + if (pPlayers[uActiveCharacter]->CanSteal()) + { + if ( GetAsyncKeyState(VK_CONTROL) ) + { + uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(bought_item, a3, party_reputation, 0, &a6); + if ( !uNumSeconds ) + { + sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6); + return; + } + } + } + if ( pParty->uNumGold < uPriceItemService ) + { + if ( uNumSeconds != 2 ) + { + if ( uNumSeconds != 1 ) + { + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" + return; + } + } + } + v39 = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID); + if ( v39 ) + { + bought_item->SetIdentified(); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[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(); + sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); + pRenderer->ClearZBuffer(0, 479); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); + return; + } + } + } + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); + pRenderer->ClearZBuffer(0, 479); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); + return; + } + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 2); // "Pack is Full!" + break; + } + default:// if click video screen in shop + { + __debugbreak(); // please do record these dialogue ids to the HOUSE_DIALOGUE_MENU enum + if( dialog_menu_id >= 36 && dialog_menu_id <= 72 ) + { + v42 = dialog_menu_id - 36; + //v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0); + v43 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); + uPriceItemService = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( uPriceItemService < v43 / 3 ) + uPriceItemService = v43 / 3; + if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v42] ) + { + pSkill = &pPlayers[uActiveCharacter]->pActiveSkills[v42]; + if ( !*pSkill ) + { + if ( pParty->uNumGold < uPriceItemService ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" + if ( in_current_building_type == BildingType_Training ) + v55 = 4; + else + v55 = 2; + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v55); + return; + } + Party::TakeGold(uPriceItemService); + dword_F8B1E4 = 1; + *pSkill = 1; + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)78, 0); + return; + } + } + } + break; + } + } +} +//----- (004BC8D5) -------------------------------------------------------- +void SpellBookGenerator()//for GuildDialogs +{ + int pItemNum; // esi@1 + int v4; // esi@7 + + for( int i = 0; i < 12; ++i ) + { + if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType >= 5 ) + { + if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 13 ) + pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType + 345; + else + { + if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 14 ) + v4 = rand() % 4; + else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 15 ) + v4 = rand() % 3 + 4; + else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 16 ) + v4 = rand() % 2 + 7; + if( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 16 ) + pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * v4 + 400; + } + } + if ( pItemNum == 487 ) + { + if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) ) + pItemNum = 486; + } + ItemGen * item_spellbook = &pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i]; + item_spellbook->Reset(); + pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID = pItemNum; + pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].Identified(); + ItemsInShopTexture[i] = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE); + } + return; +} \ No newline at end of file diff -r c423f946dc99 -r 5450af4f57ef UiGame.cpp --- a/UiGame.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/UiGame.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -2897,3 +2897,81 @@ } // 6BE3C5: using guessed type char bNoNPCHiring; +//----- (004178FE) -------------------------------------------------------- +unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2) +{ + unsigned __int16 v2; // dx@2 + unsigned __int16 v3; // cx@2 + int v5; // eax@5 + unsigned __int16 v6; // [sp-4h] [bp-8h]@2 + + if ( a1 <= a2 ) + { + if ( a1 == a2 ) + return 0; + v5 = 100 * a1 / a2; + v3 = 255; + if ( v5 >= 25 ) + { + v6 = 100; + v2 = 255; + } + else + { + v6 = 0; + v2 = 0; + } + } + else + { + v6 = 0; + v2 = 255; + v3 = 0; + } + return TargetColor(v3, v2, v6); +} + +//----- (00417939) -------------------------------------------------------- +signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx) +{ + unsigned int v1; // ebx@1 + signed int v2; // edi@1 + unsigned int v3; // esi@1 + unsigned int v4; // eax@1 + unsigned int v6; // [sp+Ch] [bp-4h]@1 + + v1 = uConditionIdx; + v2 = 65535; + v3 = TargetColor(0xE1u, 0xCDu, 0x23u); + v6 = TargetColor(0xFFu, 0x23u, 0); + v4 = TargetColor(0, 0xFFu, 0); + switch ( v1 ) + { + case 0u: + case 1u: + case 3u: + case 4u: + case 5u: + case 6u: + case 7u: + v2 = v4; + break; + case 2u: + case 8u: + case 9u: + case 0xCu: + case 0xDu: + v2 = v3; + break; + case 0xAu: + case 0xBu: + case 0xEu: + case 0xFu: + case 0x10u: + v2 = v6; + break; + default: + return v2; + } + return v2; +} diff -r c423f946dc99 -r 5450af4f57ef Viewport.cpp --- a/Viewport.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/Viewport.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -4,6 +4,22 @@ #include "Indoor.h" #include "Math.h" #include "mm7_data.h" +#include "Actor.h" +#include "Outdoor.h" +#include "Events.h" +#include "BSPModel.h" +#include "Mouse.h" +#include "SpriteObject.h" +#include "ObjectList.h" +#include "DecorationList.h" +#include "texts.h" +#include "Game.h" +#include "Vis.h" +#include "LOD.h" +#include "GUIWindow.h" +#include "TurnEngine.h" +#include "stru123.h" +#include "MM7.h" //----- (004C0262) -------------------------------------------------------- @@ -233,4 +249,268 @@ field_28 = dword_576E28; } field_2C = 384; -} \ No newline at end of file +} +//----- (0042213C) -------------------------------------------------------- +void OnGameViewportClick() +{ + signed int v0; // ebx@2 + POINT *v1; // esi@3 + signed int v2; // eax@9 + BLVFace *v3; // eax@10 + unsigned int v4; // eax@11 + unsigned __int16 v5; // dx@14 + signed int v6; // eax@14 + char *v7; // esi@15 + //int *v8; // eax@19 + int v9; // eax@19 + unsigned int v10; // eax@19 + int v11; // ecx@21 + ODMFace *v12; // eax@22 + LevelDecoration *v13; // esi@24 + __int16 v14; // ax@25 + int v15; // ecx@29 + signed int v16; // edx@30 + Actor *v17; // esi@30 + int v18; // ebx@47 + unsigned __int16 v19; // ax@50 + const char *v20; // eax@51 + signed int v21; // eax@58 + ItemGen *v22; // esi@62 + unsigned int v23; // eax@62 + SpriteObject a1; // [sp+Ch] [bp-80h]@1 + //POINT v25; // [sp+7Ch] [bp-10h]@3 + POINT a2; // [sp+84h] [bp-8h]@3 + + v1 = pMouse->GetCursorPos(&a2); + if ( pRenderer->pRenderD3D ) + v0 = pGame->pVisInstance->get_picked_object_zbuf_val(); + else + { + v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]]; + } + + if ( PID_TYPE(v0) == OBJECT_Item) + { + a2.y = (signed int)(unsigned __int16)v0 >> 3; + v21 = (signed int)(unsigned __int16)v0 >> 3; + if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) && a2.y < 1000 && pSpriteObjects[v21].uObjectDescID + && (unsigned int)v0 < 0x2000000 ) + { + v22 = &pSpriteObjects[v21].stru_24; + v23 = pSpriteObjects[v21].stru_24.uItemID; + if ( pItemsTable->pItems[v23].uEquipType == 18 ) + { + party_finds_gold(v22->uSpecEnchantmentType, 0); + viewparams->bRedrawGameUI = 1; + } + else + { + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v23].pUnidentifiedName); + ShowStatusBarString(pTmpBuf2.data(), 2u); + if ( v22->uItemID == 506 ) + _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); + if ( v22->uItemID == 455 ) + _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); + if ( !pParty->AddItem(v22) ) + pParty->SetHoldingItem(v22); + } + SpriteObject::OnInteraction(a2.y); + return; + } + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; + } + if ( PID_TYPE(v0) != OBJECT_Actor) + { + if ( PID_TYPE(v0) == OBJECT_Decoration) + { + v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; + if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 ) + { + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; + } + v14 = v13->field_16_event_id; + if ( !v14 ) + { + if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) + { + v15 = stru_5E4C90._decor_events[v13->_idx_in_stru123 - 75] + 380; + activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; + EventProcessor(v15, 0, 1); + activeLevelDecoration = NULL; + } + return; + } + v11 = v14; + } + else + { + if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= 512 ) + { + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; + } + v2 = PID_ID(v0); + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + { + v3 = &pIndoor->pFaces[v2]; + if ( !(v3->uAttributes & 0x2000000) ) + { +LABEL_11: + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + { + ShowNothingHereStatus(); + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + } +LABEL_14: + v5 = pItemsTable->pItems[v4].uSpriteID; + v6 = 0; + a1.uType = v5; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + LOWORD(v6) = 0; + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( v5 != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.spell_caster_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + + extern int UnprojectX(int); + v9 = UnprojectX(v1->x); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + v10 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if (v10 != -1) + pIcons_LOD->pTextures[v10].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->SyncLoadedFilesCount(); + return; + } + v11 = pIndoor->pFaceExtras[v3->uFaceExtraID].uEventID; + } + else + { + v12 = &pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[v2 & 0x3F]; + if ( !v12->Clickable()) + goto LABEL_11; + v11 = v12->sCogTriggeredID; + } + } + EventProcessor(v11, (unsigned __int16)v0, 1); + return; + } + v16 = (signed int)(unsigned __int16)v0 >> 3; + a2.y = v16; + v17 = &pActors[v16]; + if ( v17->uAIState == 5 ) + { + if ( (unsigned int)v0 < 0x2000000 ) + { + stru_50C198.LootActor(&pActors[v16]); + return; + } + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; + } + if ( GetAsyncKeyState(VK_SHIFT) >= 0 ) + { + if ( !v17->GetActorsRelation(0) && !(BYTE2(v17->uAttributes) & 8) ) + { + if ( HIWORD(v0) >= 512) + { + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; + } + if ( !v17->CanAct() ) + return; + v18 = a2.y; + Actor::AI_FaceObject(a2.y, 4u, 0, 0); + if ( !v17->sNPC_ID ) + { + v19 = pNPCStats->pGroups_copy[v17->uGroup]; + if ( v19 ) + { + v20 = pNPCStats->pCatchPhrases[v19]; + if ( v20 ) + { + pParty->uFlags |= 2u; + strcpy(byte_5B0938.data(), v20); + sub_4451A8_press_any_key(0, 0, 0); + } + } + return; + } + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) + return; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_StartNPCDialogue; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v18; +LABEL_42: + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + return;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0); + return; + } + if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) + { + pTurnEngine->field_18 |= 8u; + return; + } + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Attack; + goto LABEL_41; + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); + } + else + { + if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) + { + pParty->uFlags |= PARTY_FLAGS_1_FALLING; + return; + } + if ( uActiveCharacter + && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell)) + { + pMessageQueue_50CBD0->AddMessage(UIMSG_CastQuickSpell, 0, 0); + /*&& (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CastQuickSpell; +LABEL_41: + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; + goto LABEL_42;*/ + } + } +} diff -r c423f946dc99 -r 5450af4f57ef mm7_1.cpp --- a/mm7_1.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/mm7_1.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -66,294 +66,6 @@ return ((__int64)a1 * (__int64)a2) >> 16; } -//----- (004196A0) -------------------------------------------------------- -void CharacterUI_ReleaseButtons() -{ - GUIButton *i; // esi@2 - GUIButton *j; // esi@7 - - if ( dword_507CC0_activ_ch ) - { - dword_507CC0_activ_ch = 0; - for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = j ) - { - j=i->pNext; - if ( BYTE1(i->field_1C) & 0x80 ) - { - i->Release(); - pAllocator->FreeChunk(i); - } - } - for ( j = pGUIWindow_CurrentMenu->pControlsHead; j; j = j->pNext ) - { - if ( j->msg == UIMSG_InventoryLeftClick) - { - j->uX = dword_50698C_uX; - j->uY = dword_506988_uY; - j->uZ = dword_506984_uZ; - j->uW = dword_506980_uW; - pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(1, 0, 0, 0); - } - } - } -} - -//----- (0041CD4F) -------------------------------------------------------- -bool UI_OnKeyDown(unsigned int vkKey) -{ - //unsigned int v1; // edi@1 - //unsigned int v2; // eax@2 - int v3; // esi@3 - int v4; // ecx@10 - GUIButton *pButton; // eax@11 - int v6; // edx@12 - int v7; // ecx@20 - char v8; // zf@21 - //GUIButton *v9; // ecx@24 - int v10; // esi@24 - //int v11; // edx@26 - int v12; // edx@28 - int v13; // esi@32 - //GUIButton *v14; // eax@37 - int v15; // edx@38 - int v17; // ecx@50 - int v18; // edx@50 - //GUIButton *v19; // ecx@54 - int v20; // esi@54 - //int v21; // edx@56 - int v22; // ecx@59 - int v23; // edx@59 - int v24; // ecx@60 - int v25; // esi@63 - //unsigned int v26; // [sp+Ch] [bp-14h]@1 - //int v27; // [sp+10h] [bp-10h]@1 - int v28; // [sp+14h] [bp-Ch]@10 - int v29; // [sp+14h] [bp-Ch]@36 - unsigned int uClickX; // [sp+18h] [bp-8h]@10 - unsigned int uClickY; // [sp+1Ch] [bp-4h]@10 - - //v1 = 0; - //v27 = uNumVisibleWindows; - if ( uNumVisibleWindows < 0 ) - return false; - //v2 = pMessageQueue_50CBD0->uNumMessages; - for (int i = uNumVisibleWindows; i >= 0; --i) - //while ( 1 ) - { - v3 = pVisibleWindowsIdxs[i] - 1; - if (!pWindowList[v3].receives_keyboard_input) - continue; - - switch (vkKey) - { - case VK_LEFT: - { - v12 = pWindowList[v3].field_34; - if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 ) - { - v8 = pCurrentScreen == SCREEN_PARTY_CREATION; - pWindowList[v3].pCurrentPosActiveItem -= v12; - if ( v8 ) - { - pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); - //v2 = pMessageQueue_50CBD0->uNumMessages; - } - } - if ( pWindowList[v3].field_30 != 0 ) - { - break; - } - pButton = pWindowList[v3].pControlsHead; - v13 = pWindowList[v3].pCurrentPosActiveItem; - if ( v13 > 0) - { - do - { - pButton = pButton->pNext; - --v13; - } - while ( v13 ); - } - pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); - break; - } - case VK_RIGHT: - { - v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34; - if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem ) - { - v8 = pCurrentScreen == SCREEN_PARTY_CREATION; - pWindowList[v3].pCurrentPosActiveItem = v7; - if ( v8 ) - { - pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); - //v2 = pMessageQueue_50CBD0->uNumMessages; - } - } - if ( pWindowList[v3].field_30 != 0 ) - { - break; - } - pButton = pWindowList[v3].pControlsHead; - v10 = pWindowList[v3].pCurrentPosActiveItem; - if ( v10 > 0) - { - do - { - pButton = pButton->pNext; - --v10; - } - while ( v10 ); - } - pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); - break; - } - case VK_DOWN: - { - v17 = pWindowList[v3].pStartingPosActiveItem; - v18 = pWindowList[v3].pCurrentPosActiveItem; - if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 ) - pWindowList[v3].pCurrentPosActiveItem = v17; - else - pWindowList[v3].pCurrentPosActiveItem = v18 + 1; - if ( pWindowList[v3].field_30 != 0 ) - return true; - pButton = pWindowList[v3].pControlsHead; - v20 = pWindowList[v3].pCurrentPosActiveItem; - if ( v20 > 0) - { - do - { - pButton = pButton->pNext; - --v20; - } - while ( v20 ); - } - pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); - return true; - } - case VK_SELECT: - { - pMouse->GetClickPos(&uClickX, &uClickY); - v4 = pWindowList[v3].pStartingPosActiveItem; - v28 = v4 + pWindowList[v3].pNumPresenceButton; - if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) - { - while ( 1 ) - { - pButton = pWindowList[v3].pControlsHead; - if ( v4 > 0 ) - { - v6 = v4; - do - { - pButton = pButton->pNext; - --v6; - } - while ( v6 ); - } - if ( (signed int)uClickX >= (signed int)pButton->uX//test for StatsTab in PlayerCreation Window - && (signed int)uClickX <= (signed int)pButton->uZ - && (signed int)uClickY >= (signed int)pButton->uY - && (signed int)uClickY <= (signed int)pButton->uW ) - break; - ++v4; - if ( v4 >= v28 ) - { - //v1 = 0; - //v2 = pMessageQueue_50CBD0->uNumMessages; - //--i; - //if ( i < 0 ) - return false; - //continue; - } - } - pWindowList[v3].pCurrentPosActiveItem = v4; - return true; - } - //v2 = pMessageQueue_50CBD0->uNumMessages; - break; - } - case VK_UP: - { - v22 = pWindowList[v3].pCurrentPosActiveItem; - v23 = pWindowList[v3].pStartingPosActiveItem; - if ( v22 <= v23 ) - v24 = pWindowList[v3].pNumPresenceButton + v23 - 1; - else - v24 = v22 - 1; - v8 = pWindowList[v3].field_30 == 0; - pWindowList[v3].pCurrentPosActiveItem = v24; - if ( !v8 ) - return true; - pButton = pWindowList[v3].pControlsHead; - v25 = pWindowList[v3].pCurrentPosActiveItem; - if ( v25 > 0) - { - do - { - pButton = pButton->pNext; - --v25; - } - while ( v25 ); - } - pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); - return true; - } - case VK_NEXT: - { - //if ( pWindowList[v3].field_30 != 0 ) //crashed at skill draw - //{ - // pMouse->GetClickPos(&uClickX, &uClickY); - // v4 = pWindowList[v3].pStartingPosActiveItem; - // v29 = v4 + pWindowList[v3].pNumPresenceButton; //num buttons more than buttons - // if ( v4 < v29 ) - // { - // while ( 1 ) - // { - // pButton = pWindowList[v3].pControlsHead; - // if ( v4 > 0 ) - // { - // v15 = v4; - // do - // { - // pButton = pButton->pNext; - // --v15; - // } - // while ( v15 ); - // } - // if ( (signed int)uClickX >= (signed int)pButton->uX - // && (signed int)uClickX <= (signed int)pButton->uZ - // && (signed int)uClickY >= (signed int)pButton->uY - // && (signed int)uClickY <= (signed int)pButton->uW ) - // { - // pWindowList[v3].pCurrentPosActiveItem = v4; - // return true; - // } - // ++v4; - // if ( v4 >= v29 ) - // { - // //v1 = 0; - // //v2 = pMessageQueue_50CBD0->uNumMessages; - // break; - // } - // } - // } - // else - // { - // //v2 = pMessageQueue_50CBD0->uNumMessages; - // } - //} - break; - } - default: - { - break; - } - } - } -} - //----- (0041D20D) -------------------------------------------------------- void __fastcall sub_41D20D_buff_remaining_time_string( int ecx0, struct GUIWindow *edx0, __int64 a3, struct GUIFont *a2 ) { @@ -423,64 +135,6 @@ a1->DrawText(a2, 32, uY, 0, pTmpBuf.data(), 0, 0, 0); } -//----- (0041F54A) -------------------------------------------------------- -void __cdecl LoadActualSkyFrame() -{ - if ( pTexture_RestUI_CurrentSkyFrame ) - pTexture_RestUI_CurrentSkyFrame->Release(); - if ( pTexture_RestUI_CurrentHourglassFrame ) - pTexture_RestUI_CurrentHourglassFrame->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - sprintf(pTmpBuf.data(), "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour); - pTexture_RestUI_CurrentSkyFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); -} - -//----- (0041F5BE) -------------------------------------------------------- -void __cdecl Sleep6Hours() -{ - if ( _506F18_num_hours_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 ) - { - Rest(_506F18_num_hours_to_sleep); - _506F18_num_hours_to_sleep = 0; - LoadActualSkyFrame(); - } - if ( dword_506F14 == 2 ) - { - pGUIWindow_CurrentMenu->Release(); - pEventTimer->Resume(); - if ( pTexture_RestUI_CurrentSkyFrame ) - pTexture_RestUI_CurrentSkyFrame->Release(); - if ( pTexture_RestUI_CurrentHourglassFrame ) - pTexture_RestUI_CurrentHourglassFrame->Release(); - pTexture_RestUI_CurrentHourglassFrame = 0; - pTexture_RestUI_CurrentSkyFrame = 0; - pIcons_LOD->_4114F2(); - pIcons_LOD->SyncLoadedFilesCount(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - pOutdoor->UpdateSunlightVectors(); - pOutdoor->UpdateFog(); - } - } - dword_506F14 = 0; - } - else - { - Rest(6u); - _506F18_num_hours_to_sleep -= 6; - LoadActualSkyFrame(); - } - viewparams->bRedrawGameUI = 1; -} - //----- (0042038D) -------------------------------------------------------- void __cdecl sub_42038D() { @@ -509,631 +163,6 @@ } } -//----- (00420C05) -------------------------------------------------------- -void __fastcall party_finds_gold(unsigned int uNumGold, int _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal) -{ - unsigned int v2; // edi@1 - int v3; // ebp@1 - unsigned int v4; // esi@1 - int v5; // ecx@6 - NPCData *v6; // eax@6 - signed int v7; // edx@8 - signed int v8; // ebx@10 - char *v9; // edi@11 - signed int v10; // ecx@17 - int v11; // eax@21 - NPCData *v12; // ecx@21 - unsigned int v13; // ecx@23 - signed int v14; // [sp+Ch] [bp-4h]@6 - - v2 = 0; - v3 = 0; - v4 = uNumGold; - if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal ) - { - if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 1 ) - { - sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], uNumGold);// You found %lu gold! - } - else - { - if ( _1_dont_share_with_followers___2_the_same_but_without_a_message__else_normal == 2 ) - pTmpBuf2[0] = 0; - } - } - else - { - v14 = 0; - v5 = 0; - v6 = pParty->pHirelings; - do - { - if ( v6->pName ) - { - v7 = v14++; - pTmpBuf[v7] = v5; - } - ++v6; - ++v5; - } - while ( (signed int)v6 < (signed int)&pParty->pPickedItem ); - v8 = 0; - if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) - { - v9 = (char *)pNPCStats->pNewNPCData; - do - { - if ( v9[8] & 0x80 - && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v9, pParty->pHirelings[0].pName)) - && (!pParty->pHirelings[1].pName || strcmp(*(const char **)v9, pParty->pHirelings[1].pName)) ) - { - v10 = v14++; - pTmpBuf[v10] = v8 + 2; - } - ++v8; - v9 += 76; - } - while ( v8 < (signed int)pNPCStats->uNumNewNPCs ); - v2 = 0; - } - if ( v14 > 0 ) - { - do - { - v11 = (unsigned __int8)pTmpBuf[v2]; - v12 = &pNPCStats->pNPCData[v11 + 499]; - if ( (unsigned __int8)pTmpBuf[v2] < 2 ) - v12 = &pParty->pHirelings[v11]; - v13 = v12->uProfession; - if ( v13 ) - v3 += pNPCStats->pProfessions[v13].uHirePrice;//*(&pNPCStats->field_13A58 + 5 * v13); - ++v2; - } - while ( (signed int)v2 < v14 ); - } - if ( CheckHiredNPCSpeciality(Factor) ) - v4 += (signed int)(10 * v4) / 100; - if ( CheckHiredNPCSpeciality(Banker) ) - v4 += (signed int)(20 * v4) / 100; - if ( CheckHiredNPCSpeciality(Pirate) ) - v4 += (signed int)(10 * v4) / 100; - if ( v3 ) - { - v3 = (signed int)(v4 * v3 / 100) / 100; - if ( v3 < 1 ) - v3 = 1; - sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[466], v4, v3);// You found %lu gold (followers take %lu)! - } - else - { - sprintf(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[467], v4);// You found %lu gold! - } - v2 = 0; - } - pParty->uNumGold += v4 - v3; - pUIAnim_Gold->uAnimTime = v2; - pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; - if ( pTmpBuf2[0] ) - ShowStatusBarString(pTmpBuf2.data(), 2u); - pAudioPlayer->PlaySound(SOUND_GoldReceived, v2, v2, -1, v2, v2, v2, v2); -} - -//----- (00420E01) -------------------------------------------------------- -void __cdecl OnChestLeftClick() -{ - int chest_id; // edi@1 - POINT *v1; // esi@2 - int v2; // eax@2 - int v3; // ebx@4 - int v4; // esi@6 - int v5; // ecx@6 - //SpriteObject v6; // [sp+Ch] [bp-80h]@1 - POINT v7; // [sp+7Ch] [bp-10h]@2 - POINT a2; // [sp+84h] [bp-8h]@2 - - SpriteObject v6; // [sp+Ch] [bp-80h]@1 - //SpriteObject::SpriteObject(&v6); - - chest_id = pGUIWindow_CurrentMenu->par1C; - if ( pParty->pPickedItem.uItemID ) - { - if ( Chest::PutItemInChest(-1, &pParty->pPickedItem, pGUIWindow_CurrentMenu->par1C) ) - pMouse->RemoveHoldingItem(); - } - else - { - v1 = pMouse->GetCursorPos(&a2); - v2 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v7)->y]] & 0xFFFF; - if ( v2 ) - { - if ( v2 ) - v3 = v2 - 1; - else - v3 = -1; - v4 = pChests[chest_id].pInventoryIndices[v3] - 1; - if ( pItemsTable->pItems[pChests[chest_id].igChestItems[v4].uItemID].uEquipType == EQUIP_GOLD ) - { - party_finds_gold(pChests[chest_id].igChestItems[v4].uSpecEnchantmentType, 0); - viewparams->bRedrawGameUI = 1; - } - else - { - pParty->SetHoldingItem(&pChests[chest_id].igChestItems[v4]); - } - sub_420B13(v4, v3); - } - } -} - - - -//----- (00421B2C) -------------------------------------------------------- -bool __cdecl sub_421B2C_PlaceInInventory_or_DropPickedItem() -{ - unsigned int v0; // eax@2 - Texture *v1; // ebx@2 - int v2; // eax@3 - Player *v3; // esi@5 - int v4; // eax@6 - unsigned __int16 v5; // dx@11 - signed int v6; // eax@11 - char *v7; // edi@12 - __int16 v8; // ax@16 - SpriteObject a1; // [sp+4h] [bp-78h]@11 - int v11; // [sp+74h] [bp-8h]@2 - int v12; // [sp+78h] [bp-4h]@5 - - if ( !pParty->pPickedItem.uItemID ) - return 1; - v0 = pIcons_LOD->LoadTexture( - pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, - TEXTURE_16BIT_PALETTE); - v1 = pIcons_LOD->GetTexture(v0); - v11 = areWeLoadingTexture; - if ( uActiveCharacter - && (v2 = pPlayers[uActiveCharacter]->AddItem(-1, pParty->pPickedItem.uItemID)) != 0 ) - { - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v2-1], &pParty->pPickedItem, 0x24u); - pMouse->RemoveHoldingItem(); - } - else - { - v12 = 0; - v3 = pParty->pPlayers; - while ( v3 <= &pParty->pPlayers[3] ) - { - v4 = v3->AddItem(-1, pParty->pPickedItem.uItemID); - if ( v4 ) - { - memcpy(&pParty->pPlayers[v12].pInventoryItems[v4], &pParty->pPickedItem, 0x24u); - pMouse->RemoveHoldingItem(); - break; - } - ++v12; - ++v3; - } - if ( v12 == 4 ) - { - v5 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; - v6 = 0; - a1.uType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSpriteID; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { - LOWORD(v6) = 0; - } - else - { - v7 = (char *)&pObjectList->pObjects->uObjectID; - while ( v5 != *(short *)v7 ) - { - ++v6; - v7 += 56; - if ( v6 >= (signed int)pObjectList->uNumObjects ) - { - LOWORD(v6) = 0; - break; - } - } - } - a1.spell_caster_pid = OBJECT_Player; - a1.uObjectDescID = v6; - a1.vPosition.y = pParty->vPosition.y; - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; - a1.uSoundID = 0; - a1.uFacing = 0; - a1.uAttributes = 8; - v8 = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->sEyelevel + pParty->vPosition.z); - a1.uSpriteFrameID = 0; - a1.uSectorID = v8; - memcpy(&a1.stru_24, &pParty->pPickedItem, sizeof(a1.stru_24)); - a1.Create(pParty->sRotationY, 184, 200, 0); - pMouse->RemoveHoldingItem(); - } - } - if ( !v11 ) - { - v1->Release(); - pIcons_LOD->SyncLoadedFilesCount(); - } - return 1; -} - - -//----- (00421EA6) -------------------------------------------------------- -void __cdecl OnInventoryLeftClick() -{ - Player *v0; // ebx@1 - signed int v1; // eax@2 - signed int v2; // ecx@2 - int v3; // eax@2 - char v4; // sf@2 - int v5; // eax@2 - unsigned int v6; // eax@7 - unsigned int v7; // esi@12 - unsigned int v8; // eax@12 - unsigned int v9; // eax@16 - unsigned int v10; // eax@18 - ItemGen this_; // [sp+Ch] [bp-3Ch]@1 - POINT a2; // [sp+30h] [bp-18h]@4 - unsigned int v13; // [sp+38h] [bp-10h]@13 - unsigned int pY; // [sp+3Ch] [bp-Ch]@2 - unsigned int pX; // [sp+40h] [bp-8h]@2 - int a4; // [sp+44h] [bp-4h]@2 - - v0 = pPlayers[uActiveCharacter]; - if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 ) - { - pMouse->GetClickPos(&pX, &pY); - pY = pY - 17; - v2 =pX - 14; - pX = v2; - v3 = 14 * (pY >> 5); - v2 >>= 5; - v4 = v2 + v3 < 0; - v5 = v2 + v3; - a4 = v5; - if ( !v4 ) - { - if ( v5 <= 126 && pMouse->GetCursorPos(&a2)->x < 462 - && pMouse->GetCursorPos(&a2)->x >= 14 ) - { - if ( unk_50C9A0 ) - { - v6 = v0->GetItemIDAtInventoryIndex(&a4); - if ( v6 ) - { - *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; - *((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]; - unk_50C9A0 = 0; - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pMouse->SetCursorBitmap("MICON1"); - dword_50C9D0 = 113; - dword_50C9D4 = 0; - dword_50C9D8 = 256; - } - return; - } - if ( ptr_50C9A4 ) - return; - v7 = pParty->pPickedItem.uItemID; - v8 = v0->GetItemIDAtInventoryIndex(&a4); - if ( !v7 ) - { - if ( !v8 ) - return; - memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem)); - v0->RemoveItemAtInventoryIndex(a4); - v9 = pParty->pPickedItem.uItemID; - pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); - return; - } - v13 = v8; - if ( v8 ) - { - a2.y = (LONG)&v0->pInventoryItems[v8-1]; - memcpy(&this_, (const void *)a2.y, sizeof(this_)); - v0->RemoveItemAtInventoryIndex(a4); - pX = v0->AddItem2(a4, &pParty->pPickedItem); - if ( !pX ) - { - pX = v0->AddItem2(0xFFFFFFFFu, &pParty->pPickedItem); - if ( !pX ) - { - v0->PutItemArInventoryIndex(&this_, v13 - 1, a4); - memcpy((void *)a2.y, &this_, sizeof(ItemGen)); - return; - } - } - v9 = this_.uItemID; - memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem)); - pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); - return; - } - v10 = v0->AddItem(a4, v7); - pX = v10; - if ( v10 || (v10 = v0->AddItem(-1, pParty->pPickedItem.uItemID), (pX = v10) != 0) ) - { - memcpy(&v0->pInventoryItems[v10-1], &pParty->pPickedItem, 0x24u); - pMouse->RemoveHoldingItem(); - } - } - } - } -} - -//----- (0042213C) -------------------------------------------------------- -void OnGameViewportClick() -{ - signed int v0; // ebx@2 - POINT *v1; // esi@3 - signed int v2; // eax@9 - BLVFace *v3; // eax@10 - unsigned int v4; // eax@11 - unsigned __int16 v5; // dx@14 - signed int v6; // eax@14 - char *v7; // esi@15 - //int *v8; // eax@19 - int v9; // eax@19 - unsigned int v10; // eax@19 - int v11; // ecx@21 - ODMFace *v12; // eax@22 - LevelDecoration *v13; // esi@24 - __int16 v14; // ax@25 - int v15; // ecx@29 - signed int v16; // edx@30 - Actor *v17; // esi@30 - int v18; // ebx@47 - unsigned __int16 v19; // ax@50 - const char *v20; // eax@51 - signed int v21; // eax@58 - ItemGen *v22; // esi@62 - unsigned int v23; // eax@62 - SpriteObject a1; // [sp+Ch] [bp-80h]@1 - //POINT v25; // [sp+7Ch] [bp-10h]@3 - POINT a2; // [sp+84h] [bp-8h]@3 - - v1 = pMouse->GetCursorPos(&a2); - if ( pRenderer->pRenderD3D ) - v0 = pGame->pVisInstance->get_picked_object_zbuf_val(); - else - { - v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[v1->y]]; - } - - if ( PID_TYPE(v0) == OBJECT_Item) - { - a2.y = (signed int)(unsigned __int16)v0 >> 3; - v21 = (signed int)(unsigned __int16)v0 >> 3; - if ( !(pObjectList->pObjects[pSpriteObjects[v21].uObjectDescID].uFlags & 0x10) && a2.y < 1000 && pSpriteObjects[v21].uObjectDescID - && (unsigned int)v0 < 0x2000000 ) - { - v22 = &pSpriteObjects[v21].stru_24; - v23 = pSpriteObjects[v21].stru_24.uItemID; - if ( pItemsTable->pItems[v23].uEquipType == 18 ) - { - party_finds_gold(v22->uSpecEnchantmentType, 0); - viewparams->bRedrawGameUI = 1; - } - else - { - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], pItemsTable->pItems[v23].pUnidentifiedName); - ShowStatusBarString(pTmpBuf2.data(), 2u); - if ( v22->uItemID == 506 ) - _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); - if ( v22->uItemID == 455 ) - _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); - if ( !pParty->AddItem(v22) ) - pParty->SetHoldingItem(v22); - } - SpriteObject::OnInteraction(a2.y); - return; - } - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; - } - if ( PID_TYPE(v0) != OBJECT_Actor) - { - if ( PID_TYPE(v0) == OBJECT_Decoration) - { - v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; - if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 ) - { - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; - } - v14 = v13->field_16_event_id; - if ( !v14 ) - { - if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) - { - v15 = stru_5E4C90._decor_events[v13->_idx_in_stru123 - 75] + 380; - activeLevelDecoration = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; - EventProcessor(v15, 0, 1); - activeLevelDecoration = NULL; - } - return; - } - v11 = v14; - } - else - { - if ( PID_TYPE(v0) != OBJECT_BModel || HIWORD(v0) >= 512 ) - { - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; - } - v2 = PID_ID(v0); - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) - { - v3 = &pIndoor->pFaces[v2]; - if ( !(v3->uAttributes & 0x2000000) ) - { -LABEL_11: - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - { - ShowNothingHereStatus(); - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - } -LABEL_14: - v5 = pItemsTable->pItems[v4].uSpriteID; - v6 = 0; - a1.uType = v5; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - LOWORD(v6) = 0; - else - { - v7 = (char *)&pObjectList->pObjects->uObjectID; - while ( v5 != *(short *)v7 ) - { - ++v6; - v7 += 56; - if ( v6 >= (signed int)pObjectList->uNumObjects ) - { - LOWORD(v6) = 0; - break; - } - } - } - a1.uObjectDescID = v6; - a1.vPosition.y = pParty->vPosition.y; - a1.spell_caster_pid = OBJECT_Player; - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; - a1.uSoundID = 0; - a1.uFacing = 0; - a1.uAttributes = 8; - a1.uSectorID = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->sEyelevel + pParty->vPosition.z); - a1.uSpriteFrameID = 0; - memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); - - extern int UnprojectX(int); - v9 = UnprojectX(v1->x); - a1.Create(pParty->sRotationY + v9, 184, 200, 0); - v10 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); - if (v10 != -1) - pIcons_LOD->pTextures[v10].Release(); - pMouse->RemoveHoldingItem(); - pIcons_LOD->SyncLoadedFilesCount(); - return; - } - v11 = pIndoor->pFaceExtras[v3->uFaceExtraID].uEventID; - } - else - { - v12 = &pOutdoor->pBModels[(signed int)(v0 & 0xFFFF) >> 9].pFaces[v2 & 0x3F]; - if ( !v12->Clickable()) - goto LABEL_11; - v11 = v12->sCogTriggeredID; - } - } - EventProcessor(v11, (unsigned __int16)v0, 1); - return; - } - v16 = (signed int)(unsigned __int16)v0 >> 3; - a2.y = v16; - v17 = &pActors[v16]; - if ( v17->uAIState == 5 ) - { - if ( (unsigned int)v0 < 0x2000000 ) - { - stru_50C198.LootActor(&pActors[v16]); - return; - } - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; - } - if ( GetAsyncKeyState(VK_SHIFT) >= 0 ) - { - if ( !v17->GetActorsRelation(0) && !(BYTE2(v17->uAttributes) & 8) ) - { - if ( HIWORD(v0) >= 512) - { - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; - } - if ( !v17->CanAct() ) - return; - v18 = a2.y; - Actor::AI_FaceObject(a2.y, 4u, 0, 0); - if ( !v17->sNPC_ID ) - { - v19 = pNPCStats->pGroups_copy[v17->uGroup]; - if ( v19 ) - { - v20 = pNPCStats->pCatchPhrases[v19]; - if ( v20 ) - { - pParty->uFlags |= 2u; - strcpy(byte_5B0938.data(), v20); - sub_4451A8_press_any_key(0, 0, 0); - } - } - return; - } - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages >= 40 ) - return; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_StartNPCDialogue; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v18; -LABEL_42: - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - return;*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v18, 0); - return; - } - if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) - { - pTurnEngine->field_18 |= 8u; - return; - } - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Attack; - goto LABEL_41; - }*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_Attack, 0, 0); - } - else - { - if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->field_4 == 3 ) - { - pParty->uFlags |= PARTY_FLAGS_1_FALLING; - return; - } - if ( uActiveCharacter - && sub_427769_spell(pPlayers[uActiveCharacter]->uQuickSpell)) - { - pMessageQueue_50CBD0->AddMessage(UIMSG_CastQuickSpell, 0, 0); - /*&& (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CastQuickSpell; -LABEL_41: - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - goto LABEL_42;*/ - } - } -} - //----- (004226C2) -------------------------------------------------------- bool PauseGameDrawing() { @@ -1485,519 +514,6 @@ while ( v1 ); } -//----- (00423B5D) -------------------------------------------------------- -int __fastcall sub_423B5D(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 v8; // eax@5 - signed int v9; // ecx@10 - int v10; // eax@10 - int v11; // edx@11 - int v12; // ST28_4@12 - 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 - 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 thisa; // [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 v79; // [sp+1Ch] [bp-Ch]@9 - int v80; // [sp+1Ch] [bp-Ch]@76 - bool v81; // [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]; - _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; - 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; - } - else - { - stru_50B700.field_0 = 0; - if ( !(pFace->uAttributes & 1) ) - return 0; - } - v66 = pFace->uNumVertices; - if ( (signed int)pFace->uNumVertices > 0 ) - { - do - { - //v6 = &pIndoor->pVertices[pFace->pVertexIDs[v5]]; - pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible( - pIndoor->pVertices[pFace->pVertexIDs[v5]].x, - pIndoor->pVertices[pFace->pVertexIDs[v5]].y, - pIndoor->pVertices[pFace->pVertexIDs[v5]].z, - &stru_50B700._view_transformed_xs[v5 + 3], - &stru_50B700._view_transformed_zs[v5 + 3], - &stru_50B700._view_transformed_ys[v5 + 3], - 0); - ++v5; - } - while ( v5 < v66 ); - } - v7 = v66; - v8 = 0; - if ( v66 <= 0 ) - return 0; - do - { - if ( stru_50B700._view_transformed_xs[v8 + 3] >= 524288 ) - break; - ++v8; - } - while ( v8 < v66 ); - if ( v8 >= v66 ) - return 0; - v79 = 0; - stru_50B700._view_transformed_xs[v66 + 3] = stru_50B700._view_transformed_xs[3]; - stru_50B700._view_transformed_zs[v66 + 3] = stru_50B700._view_transformed_zs[3]; - stru_50B700._view_transformed_ys[v66 + 3] = stru_50B700._view_transformed_ys[3]; - thisa = stru_50B700._view_transformed_xs[3] >= 524288; - v86 = 1; - if ( v66 >= 1 ) - { - do - { - v9 = v86; - v10 = stru_50B700._view_transformed_xs[v86 + 3]; - v81 = v10 >= 524288; - if ( thisa ^ v81 ) - { - v11 = stru_50B700._view_transformed_xs[v9 + 2]; - if ( v10 >= 524288 ) - { - v12 = v10 - v11; - v13 = 524288 - v11; - LODWORD(v14) = v13 << 16; - HIDWORD(v14) = v13 >> 16; - v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 2]; - stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 3] - - stru_50B700._view_transformed_zs[v9 + 2]) - * v14 - / v12) >> 16) - + stru_50B700._view_transformed_zs[v9 + 2]; - thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 3] - stru_50B700._view_transformed_ys[v9 + 2]) - * v14 - / v12) >> 16; - } - else - { - v16 = v11 - v10; - v17 = 524288 - v10; - LODWORD(v18) = v17 << 16; - HIDWORD(v18) = v17 >> 16; - v15 = (char *)&stru_50B700._view_transformed_ys[v9 + 3]; - stru_50B700._view_transformed_zs[v79] = ((unsigned __int64)((stru_50B700._view_transformed_zs[v9 + 2] - - stru_50B700._view_transformed_zs[v9 + 3]) - * v18 - / v16) >> 16) - + stru_50B700._view_transformed_zs[v9 + 3]; - thisb = (unsigned __int64)((stru_50B700._view_transformed_ys[v9 + 2] - stru_50B700._view_transformed_ys[v9 + 3]) - * v18 - / v16) >> 16; - } - v19 = v79++; - v7 = v66; - stru_50B700._view_transformed_ys[v19] = thisb + *(_DWORD *)v15; - stru_50B700._view_transformed_xs[v19] = 524288; - } - if ( v81 ) - { - v20 = v79++; - stru_50B700._view_transformed_xs[v20] = stru_50B700._view_transformed_xs[v9 + 3]; - stru_50B700._view_transformed_zs[v20] = stru_50B700._view_transformed_zs[v9 + 3]; - stru_50B700._view_transformed_ys[v20] = stru_50B700._view_transformed_ys[v9 + 3]; - } - ++v86; - thisa = v81; - } - while ( v86 <= v7 ); - } - v87 = 0; - v21 = v79; - stru_50B700._view_transformed_xs[v79] = stru_50B700._view_transformed_xs[0]; - stru_50B700._view_transformed_zs[v79] = stru_50B700._view_transformed_zs[0]; - for ( stru_50B700._view_transformed_ys[v79] = stru_50B700._view_transformed_ys[0]; - v87 < v79; - stru_50B700._screen_space_y[v22 + 12] = pBLVRenderParams->uViewportCenterY - v35 ) - { - 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; - } - else - { - v23 = 0; - v24 = 0; - if ( stru_50B700._view_transformed_zs[v22] >= 0 ) - { - LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; - v26 = ((v24 - 1) & 0xFF800000) + 4194304; - } - else - { - LOBYTE(v24) = stru_50B700._view_transformed_xs[v22] >= 0; - v25 = v24 - 1; - v26 = (v25 & 0x800000) - 4194304; - } - } - 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]; - } - else - { - v30 = 0; - if ( stru_50B700._view_transformed_ys[v22] >= v23 ) - { - LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; - v32 = ((v30 - 1) & 0xFF800000) + 4194304; - } - else - { - LOBYTE(v30) = stru_50B700._view_transformed_xs[v22] >= v23; - v31 = v30 - 1; - v32 = (v31 & 0x800000) - 4194304; - } - } - 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]; - ++v87; - } - 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; - if ( v79 < 1 ) - return 0; - do - { - v40 = v39; - v41 = stru_50B700._screen_space_x[v40 + 12]; - v82 = v41 >= (signed int)v37; - if ( v38 ^ v82 ) - { - if ( v41 >= (signed int)v37 ) - { - 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]; - } - 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]; - } - ++v36; - stru_50B700._screen_space_y[v36 + 8] = v67 + v42; - v37 = pBLVRenderParams->uViewportX; - stru_50B700._screen_space_x[v36 + 8] = pBLVRenderParams->uViewportX; - } - v38 = v82; - if ( v82 ) - { - 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]; - } - v39 = v88++ + 1; - } - while ( v88 <= v79 ); - 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) ) - return 0; - do - { - v45 = v89; - v46 = stru_50B700._screen_space_x[v89 + 9]; - v83 = v46 <= (signed int)v44; - if ( thisd ^ v83 ) - { - if ( v46 <= (signed int)v44 ) - { - 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]; - } - 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]; - } - ++v43; - stru_50B700._screen_space_y[v43 + 5] = v68 + v47; - v44 = pBLVRenderParams->uViewportZ; - stru_50B700._screen_space_x[v43 + 5] = pBLVRenderParams->uViewportZ; - } - if ( v83 ) - { - 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]; - } - ++v89; - thisd = v83; - } - 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) ) - return 0; - do - { - v52 = v51; - v53 = stru_50B700._screen_space_y[v52 + 6]; - v84 = v53 >= (signed int)v49; - if ( v50 ^ v84 ) - { - if ( v53 >= (signed int)v49 ) - { - 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]; - } - 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]; - } - ++v48; - stru_50B700._screen_space_x[v48 + 2] = v69 + v54; - v49 = pBLVRenderParams->uViewportY; - stru_50B700._screen_space_y[v48 + 2] = pBLVRenderParams->uViewportY; - } - v50 = v84; - if ( v84 ) - { - 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]; - } - 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) ) - return 0; - do - { - v57 = v91; - v58 = stru_50B700._screen_space_y[v91 + 3]; - v85 = v58 <= (signed int)v56; - if ( thise ^ v85 ) - { - if ( v58 <= (signed int)v56 ) - { - 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]; - } - 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]; - } - ++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; - } - if ( v85 ) - { - 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]; - } - ++v91; - thise = v85; - } - while ( v91 <= v48 ); - if ( !v55 ) - 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 ) - { - 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 ) - { - v62 = 1; - v71 = 1; - do - { - 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 ) - { - v62 = v80; - v71 = v80; - } - else - { - v62 = v71; - v65 = v71; - if ( v71 < v55 || (v65 = v71 - v55, v71 - v55 < v55) ) - { - 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)); - } - --v55; - } - } - while ( v62 - 1 < v55 ); - } - stru_50B700._screen_space_x[v55] = stru_50B700._screen_space_x[0]; - stru_50B700._screen_space_y[v55] = stru_50B700._screen_space_y[0]; - } - return v55; -} //----- (00424579) -------------------------------------------------------- int __fastcall sub_424579(int uFaceID, stru320 *a2) { @@ -2270,339 +786,6 @@ return result;*/ } -//----- (00424829) -------------------------------------------------------- -bool sub_424829(int pNumVertices, BspRenderer_stru2 *a2, BspRenderer_stru2 *a3, 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 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 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 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 - 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 ) - { - v63 = 1; - v64 = -1; - } - else - { - v63 = -1; - v64 = 1; - } - - for ( v6 = 1; v6 < pNumVertices; ++v6 ) - { - if ( stru_50B700._screen_space_y[v6] >= min_y ) - { - if ( stru_50B700._screen_space_y[v6] > max_y ) - max_y = stru_50B700._screen_space_y[v6]; - } - if ( stru_50B700._screen_space_y[v6] < min_y ) - { - v65 = v6; - min_y = stru_50B700._screen_space_y[v6]; - } - } - 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 ) - { - v10 += v64; - if ( v10 < pNumVertices ) - { - if ( v10 < 0 ) - v10 += pNumVertices; - } - else - v10 -= pNumVertices; - if ( stru_50B700._screen_space_y[v10] <= stru_50B700._screen_space_y[v65] ) - { - v55 = v10; - v65 = v10; - } - if ( stru_50B700._screen_space_y[v10] == max_y ) - break; - } - v13 = v55 + v64; - if ( v13 < pNumVertices ) - { - if ( v13 < 0 ) - v13 += pNumVertices; - } - else - v13 -= pNumVertices; - if ( stru_50B700._screen_space_y[v13] != stru_50B700._screen_space_y[v55] ) - { - 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]); - } - v15 = v65; - v61 = v65; - - for ( v69 = 0; v69 < pNumVertices; ++v69 ) - { - v15 += v63; - if ( v15 < pNumVertices ) - { - if ( v15 < 0 ) - v15 += pNumVertices; - } - else - v15 -= pNumVertices; - if ( stru_50B700._screen_space_y[v15] <= stru_50B700._screen_space_y[v65] ) - { - v61 = v15; - v65 = v15; - } - if ( stru_50B700._screen_space_y[v15] == max_y ) - break; - } - v18 = v63 + v61; - if ( v18 < pNumVertices ) - { - if ( v18 < 0 ) - v18 += pNumVertices; - } - else - v18 -= pNumVertices; - v19 = v18; - v20 = v61; - if ( stru_50B700._screen_space_y[v19] != stru_50B700._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]); - } - 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 ) - { - v13 = v64 + v13; - if ( v13 < pNumVertices ) - { - if ( v13 < 0 ) - v13 += pNumVertices; - } - 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 ) - { - 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; - } - } - v29 = v18; - if ( v70 >= stru_50B700._screen_space_y[v18] && v70 != max_y ) - { - v18 += v63; - if ( v18 < pNumVertices ) - { - if ( v18 < 0 ) - v18 += pNumVertices; - } - 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 ) - { - 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; - } - } - //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] ) - { - 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; - } - //++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 ) - 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 <= 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 ) - { - if ( a2->viewport_left_side[v71] >= a3->viewport_left_side[v71] && a2->viewport_left_side[v71] <= a3->viewport_right_side[v71] ) - 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 ) - { - if ( a2->viewport_right_side[v72] >= a3->viewport_left_side[v72] && a2->viewport_left_side[v72] <= a3->viewport_right_side[v72] ) - 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]; - ++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]; - 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 ) - { - a2->field_8 = a2->viewport_left_side[v49]; - a2->field_10 = v49; - } - if ( a2->viewport_right_side[v49] > a2->field_C ) - { - a2->field_C = a2->viewport_right_side[v49]; - a2->field_14 = v49; - } - //++v50; - } - } - return true; -} // 50B700: using guessed type int stru_50B700.field_0; //----- (00424CD7) -------------------------------------------------------- diff -r c423f946dc99 -r 5450af4f57ef mm7_2.cpp --- a/mm7_2.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/mm7_2.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -459,83 +459,6 @@ } // F8B1B4: using guessed type int dword_F8B1B4; -//----- (004BBF61) -------------------------------------------------------- -void __fastcall _4BBF61_summon_actor(int a1, __int16 x, int y, int z) -{ - size_t v4; // esi@1 - int monster_id; // edi@1 - __int16 v6; // ax@4 - Actor *v7; // esi@5 - int v8; // eax@5 - MonsterInfo *v9; // edi@5 - MonsterDesc *v10; // ebx@5 - unsigned __int16 *v11; // ebx@5 - int v12; // ebx@7 - int v13; // eax@8 - __int16 x_; // [sp+8h] [bp-Ch]@1 - __int16 v15; // [sp+Ch] [bp-8h]@1 - __int16 v16; // [sp+10h] [bp-4h]@3 - signed int ya; // [sp+1Ch] [bp+8h]@5 - - v4 = uNumActors; - monster_id = a1; - x_ = x; - v15 = a1; - if ( (signed int)uNumActors < 500 - && ((signed int)pAllocator->uBigBufferSizeAligned >> 10) - ((signed int)pAllocator->uNextFreeOffsetInBigBuffer >> 10) >= 2000 ) - { - v16 = 0; - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - v6 = pIndoor->GetSector(x, y, z); - v4 = uNumActors; - v16 = v6; - } - v7 = &pActors[v4]; - v7->Reset(); - v8 = monster_id; - v9 = &pMonsterStats->pInfos[monster_id]; - v10 = &pMonsterList->pMonsters[v8 - 1]; - strcpy(v7->pActorName, v9->pName); - v7->sCurrentHP = LOWORD(v9->uHP); - memcpy(&v7->pMonsterInfo, v9, 0x58u); - v7->word_000086_some_monster_id = v15; - v7->uActorRadius = v10->uMonsterRadius; - v7->uActorHeight = v10->uMonsterHeight; - v7->uMovementSpeed = v10->uMovementSpeed; - v7->vInitialPosition.x = x_; - v7->vPosition.x = x_; - BYTE2(v7->uAttributes) |= 8u; - v7->pMonsterInfo.uTreasureType = 0; - v7->pMonsterInfo.uTreasureLevel = 0; - v7->pMonsterInfo.uTreasureDiceSides = 0; - v7->pMonsterInfo.uTreasureDiceRolls = 0; - v7->pMonsterInfo.uTreasureDropChance = 0; - v7->vInitialPosition.y = y; - v7->vPosition.y = y; - v7->vInitialPosition.z = z; - v7->vPosition.z = z; - v7->uTetherDistance = 256; - v7->uSectorID = v16; - v7->uGroup = 1; - v7->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; - v7->PrepareSprites(0); - v11 = v10->pSoundSampleIDs; - ya = 4; - do - { - pSoundList->LoadSound((signed __int16)*v11, 0); - ++v11; - --ya; - } - while ( ya ); - v12 = 0; - do - LOWORD(v13) = pSoundList->LoadSound(v12++ + word_4EE088_sound_ids[v9->uSpell1ID], 1u); - while ( v13 ); - ++uNumActors; - } -} // 4EE088: using guessed type __int16 word_4EE088_sound_ids[]; //----- (004BC109) -------------------------------------------------------- @@ -749,55 +672,6 @@ pAudioPlayer->PlaySound((SoundID)14060, 0, 0, -1, 0, 0, 0, 0); } -//----- (004BC8D5) -------------------------------------------------------- -void SpellBookGenerator()//for GuildDialogs -{ - int pItemNum; // esi@1 - int v4; // esi@7 - - for( int i = 0; i < 12; ++i ) - { - if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType >= 5 ) - { - if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 13 ) - pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType + 345; - else - { - if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 14 ) - v4 = rand() % 4; - else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 15 ) - v4 = rand() % 3 + 4; - else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 16 ) - v4 = rand() % 2 + 7; - if( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 16 ) - pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * v4 + 400; - } - } - if ( pItemNum == 487 ) - { - if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) ) - pItemNum = 486; - } - ItemGen * item_spellbook = &pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i]; - item_spellbook->Reset(); - pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID = pItemNum; - pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].Identified(); - ItemsInShopTexture[i] = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE); - } - return; -} - -//----- (004BCA33) -------------------------------------------------------- -void UI_CreateEndConversationButton() -{ - pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 345, WINDOW_MainMenu, 0, 0); - pBtn_ExitCancel = pDialogueWindow->CreateButton( 471, 445, 169, 35, 1, 0, UIMSG_Escape, 0, 0, - pGlobalTXT_LocalizationStrings[74], //"End Conversation" - pIcons_LOD->GetTexture(uExitCancelTextureId), 0); - pDialogueWindow->CreateButton(8, 8, 450, 320, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0); -} - //----- (004BD8B5) -------------------------------------------------------- signed int __cdecl sub_4BD8B5() { @@ -896,313 +770,6 @@ return 0; } -//----- (004BDB56) -------------------------------------------------------- -void __cdecl UIShop_Buy_Identify_Repair() -{ - int v8; // eax@15 - unsigned int pItemID; // esi@20 - ItemGen *item; // esi@21 - unsigned int v15; // eax@33 - POINT *pCursorPos; // esi@37 - int v18; // ecx@37 - float pPriceMultiplier; // ST1C_4@38 - int taken_item; // eax@40 - ItemGen *bought_item; // esi@51 - int party_reputation; // eax@55 - int v39; // eax@63 - int v42; // esi@74 - signed int v43; // ebx@74 - unsigned __int16 *pSkill; // esi@77 - int v55; // [sp+0h] [bp-B4h]@26 - POINT cursor; // [sp+40h] [bp-74h]@37 - int a6; // [sp+98h] [bp-1Ch]@57 - int a3; // [sp+9Ch] [bp-18h]@53 - unsigned int uNumSeconds; // [sp+A4h] [bp-10h]@53 - unsigned int v79; // [sp+A8h] [bp-Ch]@9 - int uPriceItemService; // [sp+ACh] [bp-8h]@12 - - if ( pCurrentScreen == SCREEN_E ) - { - OnInventoryLeftClick(); - return; - } - if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - - switch(dialog_menu_id) - { - case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: - { - pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; - OnInventoryLeftClick(); - break; - } - case HOUSE_DIALOGUE_GUILD_BUY_BOOKS: - { - pCursorPos = pMouse->GetCursorPos(&cursor); - v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&cursor)->y]] & 0xFFFF; - if ( !v18 ) - return; - bought_item = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C)); - pPriceMultiplier = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; - uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), pPriceMultiplier); - GetAsyncKeyState(VK_CONTROL); - if ( pParty->uNumGold < uPriceItemService ) - { - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); - return; - } - taken_item = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID); - if ( taken_item ) - { - bought_item->SetIdentified(); - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[taken_item - 1], bought_item, 0x24u); - dword_F8B1E4 = 1; - Party::TakeGold(uPriceItemService); - viewparams->bRedrawGameUI = 1; - bought_item->Reset(); - pRenderer->ClearZBuffer(0, 479); - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); - return; - } - pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); - ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 5); // "Pack is Full!" - break; - } - case HOUSE_DIALOGUE_SHOP_SELL: - { - v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); - if ( pMouse->GetCursorPos(&cursor)->x <= 13 - || 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) ) - { - dword_F8B1E4 = 1; - pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)window_SpeakInHouse->ptr_1C); - viewparams->bRedrawGameUI = 1; - pRenderer->ClearZBuffer(0, 479); - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)77, 0); - return; - } - pPlayers[uActiveCharacter]->PlaySound(SPEECH_79, 0); - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - break; - } - case HOUSE_DIALOGUE_SHOP_IDENTIFY: - { - pMouse->GetCursorPos(&cursor); - v79 = ((cursor.x - 14) >> 5) + 14 * ((cursor.y - 17) >> 5); - if (cursor.x > 13 && cursor.x < 462) - { - pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); - if ( pItemID ) - { - uPriceItemService = pPlayers[uActiveCharacter]->GetPriceIdentification(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); - item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; - if ( !(item->uAttributes & 1) ) - { - if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) - { - if ( pParty->uNumGold >= uPriceItemService ) - { - dword_F8B1E4 = 1; - Party::TakeGold(uPriceItemService); - item->uAttributes |= 1; - pPlayers[uActiveCharacter]->PlaySound(SPEECH_73, 0); - ShowStatusBarString(pGlobalTXT_LocalizationStrings[569], 2); - return; - } - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); - return; - } - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0); - return; - } - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0); - return; - } - } - break; - } - case HOUSE_DIALOGUE_SHOP_REPAIR: - { - v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); - if ( pMouse->GetCursorPos(&cursor)->x > 13 ) - { - if ( pMouse->GetCursorPos(&cursor)->x < 462 ) - { - pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); - if ( pItemID ) - { - item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; - pPriceMultiplier = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; - auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; - uPriceItemService = pPlayers[uActiveCharacter]->GetPriceRepair(_v->GetValue(), pPriceMultiplier); - if ( item->uAttributes & 2 ) - { - if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) - { - if ( pParty->uNumGold >= uPriceItemService ) - { - dword_F8B1E4 = 1; - Party::TakeGold(uPriceItemService); - v8 = item->uAttributes; - LOBYTE(v8) = v8 & 0xFD; - item->uAttributes = v8 | 1; - pPlayers[uActiveCharacter]->PlaySound(SPEECH_74, 0); - ShowStatusBarString(pGlobalTXT_LocalizationStrings[570], 2); - return; - } - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); - return; - } - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0); - return; - } - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0); - return; - } - } - } - break; - } - case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: - case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: - { - pCursorPos = pMouse->GetCursorPos(&cursor); - v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pCursorPos->y]] & 0xFFFF; - if ( !v18 ) - return; - if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) - bought_item = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1]; - else - bought_item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];//(ItemGen *)&pParty->field_C59C[v31 + 724]; - uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); - uNumSeconds = 0; - a3 = 0; - if ( pMapStats->GetMapInfo(pCurrentMapName.data()) ) - a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName.data())]._steal_perm; - party_reputation = GetPartyReputation(); - if (pPlayers[uActiveCharacter]->CanSteal()) - { - if ( GetAsyncKeyState(VK_CONTROL) ) - { - uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(bought_item, a3, party_reputation, 0, &a6); - if ( !uNumSeconds ) - { - sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6); - return; - } - } - } - if ( pParty->uNumGold < uPriceItemService ) - { - if ( uNumSeconds != 2 ) - { - if ( uNumSeconds != 1 ) - { - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" - return; - } - } - } - v39 = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID); - if ( v39 ) - { - bought_item->SetIdentified(); - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[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(); - sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6); - viewparams->bRedrawGameUI = 1; - bought_item->Reset(); - pRenderer->ClearZBuffer(0, 479); - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); - return; - } - } - } - dword_F8B1E4 = 1; - Party::TakeGold(uPriceItemService); - viewparams->bRedrawGameUI = 1; - bought_item->Reset(); - pRenderer->ClearZBuffer(0, 479); - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); - return; - } - pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); - ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 2); // "Pack is Full!" - break; - } - default:// if click video screen in shop - { - __debugbreak(); // please do record these dialogue ids to the HOUSE_DIALOGUE_MENU enum - if( dialog_menu_id >= 36 && dialog_menu_id <= 72 ) - { - v42 = dialog_menu_id - 36; - //v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0); - v43 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); - uPriceItemService = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; - if ( uPriceItemService < v43 / 3 ) - uPriceItemService = v43 / 3; - if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v42] ) - { - pSkill = &pPlayers[uActiveCharacter]->pActiveSkills[v42]; - if ( !*pSkill ) - { - if ( pParty->uNumGold < uPriceItemService ) - { - ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" - if ( in_current_building_type == BildingType_Training ) - v55 = 4; - else - v55 = 2; - PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v55); - return; - } - Party::TakeGold(uPriceItemService); - dword_F8B1E4 = 1; - *pSkill = 1; - pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)78, 0); - return; - } - } - } - break; - } - } -} -//----- (004BE386) -------------------------------------------------------- -void __fastcall log_error(const char *pMessage) -{ - const char *v1; // edi@1 - FILE *f; // eax@1 - FILE *v3; // esi@1 - - v1 = pMessage; - f = fopen("errorlog.txt", "a"); - v3 = f; - if ( f ) - { - fprintf(f, "%s\n", v1); - fclose(v3); - fflush(v3); - } -} - //----- (004BF91E) -------------------------------------------------------- unsigned int __thiscall GameOverMenu(void *ecx0) { @@ -2290,124 +1857,6 @@ return result; } -//----- (0044E1EC) -------------------------------------------------------- -int TextureFrameTable::FromFileTxt(const char *Args) -{ - TextureFrameTable *v2; // ebx@1 - FILE *v3; // eax@1 - int v4; // esi@3 - const void *v5; // ST0C_4@10 - void *v6; // eax@10 - FILE *v7; // ST0C_4@12 - char *i; // eax@12 - signed int v9; // esi@15 - int v10; // eax@17 - int v11; // edx@22 - int v12; // ecx@23 - int v13; // eax@24 - signed int j; // eax@27 - TextureFrame *v15; // edx@28 - int v16; // esi@28 - int k; // ecx@29 - char Buf; // [sp+Ch] [bp-2F8h]@3 - FrameTableTxtLine v20; // [sp+200h] [bp-104h]@4 - int v21; // [sp+27Ch] [bp-88h]@4 - char *Str1; // [sp+280h] [bp-84h]@5 - char *Str; // [sp+284h] [bp-80h]@15 - int v24; // [sp+2F8h] [bp-Ch]@3 - int v25; // [sp+2FCh] [bp-8h]@3 - FILE *File; // [sp+300h] [bp-4h]@1 - int Argsa; // [sp+30Ch] [bp+8h]@28 - - v2 = this; - v3 = fopen(Args, "r"); - File = v3; - if ( !v3 ) - Abortf("CTextureFrameTable::load - Unable to open file: %s.", Args); - v4 = 0; - v24 = 0; - v25 = 1; - if ( fgets(&Buf, 490, v3) ) - { - do - { - *strchr(&Buf, 10) = 0; - memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); - if ( v21 && *Str1 != 47 ) - { - if ( v21 < 2 ) - Abortf("CTextureFrameTable::load, too few arguments, %s line %i.", Args, v25); - ++v24; - } - ++v25; - } - while ( fgets(&Buf, 490, File) ); - v4 = v24; - } - v5 = v2->pTextures; - v2->sNumTextures = v4; - v6 = pAllocator->AllocNamedChunk(v5, 20 * v4, "Txt Frames"); - v2->pTextures = (TextureFrame *)v6; - if ( !v6 ) - Abortf("CTextureFrameTable::load - Out of Memory!"); - v7 = File; - v2->sNumTextures = 0; - fseek(v7, 0, 0); - for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) - { - *strchr(&Buf, 10) = 0; - memcpy(&v21, txt_file_frametable_parser(&Buf, &v20), 0x7Cu); - if ( v21 && *Str1 != 47 ) - { - strcpy(v2->pTextures[v2->sNumTextures].pTextureName, Str1); - v2->pTextures[v2->sNumTextures].uAnimTime = atoi(Str); - v9 = 2; - for ( v2->pTextures[v2->sNumTextures].uFlags = 0; v9 < v21; ++v9 ) - { - if ( !_stricmp((&Str1)[4 * v9], "New") ) - { - v10 = (int)&v2->pTextures[v2->sNumTextures].uFlags; - *(char *)v10 |= 2u; - } - } - ++v2->sNumTextures; - } - } - fclose(File); - v11 = 0; - if ( (signed int)(v2->sNumTextures - 1) > 0 ) - { - v12 = 0; - do - { - v13 = (int)&v2->pTextures[v12]; - if ( !(*(char *)(v13 + 38) & 2) ) - *(char *)(v13 + 18) |= 1u; - ++v11; - ++v12; - } - while ( v11 < (signed int)(v2->sNumTextures - 1) ); - } - for ( j = 0; j < (signed int)v2->sNumTextures; *(short *)(Argsa + 16) = v16 ) - { - v15 = v2->pTextures; - Argsa = (int)&v15[j]; - v16 = *(short *)(Argsa + 14); - if ( *(char *)(Argsa + 18) & 1 ) - { - ++j; - for ( k = (int)&v15[j]; *(char *)(k + 18) & 1; k += 20 ) - { - v16 += *(short *)(k + 14); - ++j; - } - LOWORD(v16) = v15[j].uAnimTime + v16; - } - ++j; - } - return 1; -} - //----- (0044F57C) -------------------------------------------------------- void SpawnEncounter(MapInfo *pMapInfo, SpawnPointMM7 *spawn, int a3, int a4, int a5) { @@ -4427,551 +3876,6 @@ return TargetColor(v2, v1, v4); } -//----- (004583B0) -------------------------------------------------------- -LevelDecoration::LevelDecoration() -{ - this->field_1A = 0; - this->field_18 = 0; - this->vPosition.z = 0; - this->vPosition.y = 0; - this->vPosition.x = 0; - this->uDecorationDescID = 0; - this->field_2 = 0; - this->field_16_event_id = 0; - this->uCog = 0; -} - -//----- (00458600) -------------------------------------------------------- -void DecorationList::ToFile() -{ - DecorationList *v1; // esi@1 - FILE *v2; // eax@1 - FILE *v3; // edi@1 - - v1 = this; - v2 = fopen("data\\ddeclist.bin", "wb"); - v3 = v2; - if ( !v2 ) - Abortf("Unable to save ddeclist.bin!"); - fwrite(v1, 4u, 1u, v2); - fwrite(v1->pDecorations, 0x54u, v1->uNumDecorations, v3); - fclose(v3); -} - -//----- (0045864C) -------------------------------------------------------- -void DecorationList::FromFile(void *pSerialized) -{ - uNumDecorations = *(int *)pSerialized; - pDecorations = (DecorationDesc *)pAllocator->AllocNamedChunk(pDecorations, - 84 * uNumDecorations, "Dec Descrip"); - memcpy(pDecorations, (char *)pSerialized + 4, 84 * uNumDecorations); -} - -//----- (00458693) -------------------------------------------------------- -void DecorationList::InitializeDecorationSprite(unsigned int uDecID) -{ - pSpriteFrameTable->InitializeSprite(this->pDecorations[uDecID].uSpriteID); -} - -//----- (004586B0) -------------------------------------------------------- -bool DecorationList::FromFileTxt(const char *Args) -{ - DecorationList *v2; // ebx@1 - FILE *v3; // eax@1 - unsigned int v4; // esi@3 - void *v5; // eax@10 - FILE *v6; // ST18_4@12 - char *i; // eax@12 - unsigned __int16 v8; // ax@16 - const char *v9; // ST20_4@16 - const char *v10; // ST18_4@16 - __int16 v11; // ax@16 - const char *v12; // ST14_4@16 - unsigned __int16 v13; // ax@16 - const char *v14; // ST10_4@16 - __int16 v15; // ax@16 - const char *v16; // ST0C_4@16 - unsigned __int8 v17; // al@16 - const char *v18; // ST08_4@16 - unsigned __int8 v19; // al@16 - const char *v20; // ST04_4@16 - unsigned __int8 v21; // al@16 - const char *v22; // ST00_4@16 - unsigned __int8 v23; // zf@16 - char v24; // sf@16 - unsigned __int8 v25; // of@16 - int j; // edi@17 - const char *v27; // esi@18 - int v28; // eax@19 - int v29; // eax@21 - int v30; // eax@23 - int v31; // eax@25 - int v32; // eax@27 - int v33; // eax@29 - int v34; // eax@31 - int v35; // eax@33 - FrameTableTxtLine v37; // [sp+Ch] [bp-460h]@17 - FrameTableTxtLine v38; // [sp+88h] [bp-3E4h]@13 - char Dest; // [sp+104h] [bp-368h]@17 - char Buf; // [sp+17Ch] [bp-2F0h]@3 - FrameTableTxtLine v41; // [sp+370h] [bp-FCh]@4 - FrameTableTxtLine v42; // [sp+3ECh] [bp-80h]@4 - FILE *File; // [sp+468h] [bp-4h]@1 - unsigned int Argsa; // [sp+474h] [bp+8h]@3 - - v2 = this; - v3 = fopen(Args, "r"); - File = v3; - if ( !v3 ) - Abortf("DecorationDescriptionList::load - Unable to open file: %s."); - v4 = 0; - Argsa = 0; - if ( fgets(&Buf, 490, v3) ) - { - do - { - *strchr(&Buf, 10) = 0; - memcpy(&v42, frame_table_txt_parser(&Buf, &v41), sizeof(v42)); - if ( v42.uPropCount && *v42.pProperties[0] != 47 && v42.uPropCount >= 3 ) - ++Argsa; - } - while ( fgets(&Buf, 490, File) ); - v4 = Argsa; - } - v2->uNumDecorations = v4; - v5 = pAllocator->AllocNamedChunk(v2->pDecorations, 84 * v4, "Dec Descrip"); - v2->pDecorations = (DecorationDesc *)v5; - if ( !v5 ) - Abortf("DecorationDescriptionList::load - Out of Memory!"); - v6 = File; - v2->uNumDecorations = 0; - fseek(v6, 0, 0); - for ( i = fgets(&Buf, 490, File); i; i = fgets(&Buf, 490, File) ) - { - *strchr(&Buf, 10) = 0; - memcpy(&v42, frame_table_txt_parser(&Buf, &v38), sizeof(v42)); - if ( v42.uPropCount && *v42.pProperties[0] != 47 && v42.uPropCount >= 3 ) - { - strcpy(v2->pDecorations[v2->uNumDecorations].pName, v42.pProperties[1]); - v8 = pSpriteFrameTable->FastFindSprite(v2->pDecorations[v2->uNumDecorations].pName); - v9 = v42.pProperties[2]; - v2->pDecorations[v2->uNumDecorations].uSpriteID = v8; - strcpy(v2->pDecorations[v2->uNumDecorations].field_20, v9); - v10 = v42.pProperties[3]; - v2->pDecorations[v2->uNumDecorations].uType = 0; - v11 = atoi(v10); - v12 = v42.pProperties[4]; - v2->pDecorations[v2->uNumDecorations].uRadius = v11; - v13 = atoi(v12); - v14 = v42.pProperties[5]; - v2->pDecorations[v2->uNumDecorations].uDecorationHeight = v13; - v15 = atoi(v14); - v16 = v42.pProperties[6]; - v2->pDecorations[v2->uNumDecorations].uLightRadius = v15; - v17 = atoi(v16); - v18 = v42.pProperties[7]; - v2->pDecorations[v2->uNumDecorations].uColoredLightRed = v17; - v19 = atoi(v18); - v20 = v42.pProperties[8]; - v2->pDecorations[v2->uNumDecorations].uColoredLightGreen = v19; - v21 = atoi(v20); - v22 = v42.pProperties[9]; - v2->pDecorations[v2->uNumDecorations].uColoredLightBlue = v21; - v2->pDecorations[v2->uNumDecorations].uSoundID = atoi(v22); - v25 = __OFSUB__(v42.uPropCount, 10); - v23 = v42.uPropCount == 10; - v24 = v42.uPropCount - 10 < 0; - v2->pDecorations[v2->uNumDecorations].uFlags = 0; - if ( !((unsigned __int8)(v24 ^ v25) | v23) ) - { - strcpy(&Dest, v42.pProperties[10]); - memcpy(&v41, frame_table_txt_parser(&Dest, &v37), sizeof(v41)); - for ( j = 0; j < v41.uPropCount; ++j ) - { - v27 = v41.pProperties[j]; - if ( _stricmp(v41.pProperties[j], "NBM") ) - { - if ( _stricmp(v27, "Invisible") ) - { - if ( _stricmp(v27, "FS") ) - { - if ( _stricmp(v27, "FM") ) - { - if ( _stricmp(v27, "FF") ) - { - if ( _stricmp(v27, "Marker") ) - { - if ( _stricmp(v27, "LoopSlow") ) - { - if ( _stricmp(v27, "EmitFire") ) - { - if ( _stricmp(v27, "Dawn") ) - { - if ( !_stricmp(v27, "Dusk") ) - HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 2u; - } - else - { - HIBYTE(v2->pDecorations[v2->uNumDecorations].uFlags) |= 1u; - } - } - else - { - v35 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; - *(char *)v35 |= 0x80u; - } - } - else - { - v34 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; - *(char *)v34 |= 0x40u; - } - } - else - { - v33 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; - *(char *)v33 |= 0x20u; - } - } - else - { - v32 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; - *(char *)v32 |= 0x10u; - } - } - else - { - v31 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; - *(char *)v31 |= 8u; - } - } - else - { - v30 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; - *(char *)v30 |= 4u; - } - } - else - { - v29 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; - *(char *)v29 |= 2u; - } - } - else - { - v28 = (int)&v2->pDecorations[v2->uNumDecorations].uFlags; - *(char *)v28 |= 1u; - } - } - } - ++v2->uNumDecorations; - } - } - fclose(File); - return 1; -} - -//----- (0045E03A) -------------------------------------------------------- -unsigned short * MakeScreenshot( signed int width, signed int height ) -{ - //signed int v2; // edi@1 - unsigned __int16 *v3; // ebx@1 - int v4; // edx@7 - unsigned __int8 v5; // cf@9 - unsigned int v6; // ecx@9 - unsigned __int16 *v7; // edi@9 - int j; // ecx@9 - //unsigned __int16 *v9; // edi@15 - //int v10; // ecx@15 - //LONG v11; // esi@15 - //signed __int64 v12; // qax@18 - //unsigned int v13; // ST10_4@21 - HRESULT v14; // eax@21 - int v15; // edi@29 - signed __int64 v16; // qax@30 - signed int v17; // edx@34 - unsigned __int16 *v18; // edi@36 - int k; // ecx@36 - DDSURFACEDESC2 Dst; // [sp+4h] [bp-A0h]@6 - unsigned __int16 *pPixels; // [sp+80h] [bp-24h]@1 - float v23; // [sp+84h] [bp-20h]@1 - unsigned __int16 *_this; // [sp+88h] [bp-1Ch]@21 - float v25; // [sp+8Ch] [bp-18h]@1 - unsigned int v26; // [sp+90h] [bp-14h]@17 - //int v27; // [sp+94h] [bp-10h]@1 - int v28; // [sp+98h] [bp-Ch]@16 - int v29; // [sp+9Ch] [bp-8h]@15 - //int v30; // [sp+A0h] [bp-4h]@1 - - //v30 = width; - //v2 = height; - //v27 = height; - v23 = game_viewport_width / (double)width; - v25 = game_viewport_height / (double)height; - - pPixels = (unsigned __int16 *)malloc(2 * height * width); - memset(pPixels, 0 , 2 * height * width); - - v3 = pPixels; - if ( pRenderer->pRenderD3D ) - { - pRenderer->BeginSceneD3D(); - - if (uCurrentlyLoadedLevelType == LEVEL_Indoor) - pIndoor->Draw(); - else if (uCurrentlyLoadedLevelType == LEVEL_Outdoor) - pOutdoor->Draw(); - - pRenderer->DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); - memset(&Dst, 0, 0x7Cu); - Dst.dwSize = sizeof(Dst); - - if ( pRenderer->LockSurface_DDraw4(pRenderer->pBackBuffer4, &Dst, DDLOCK_WAIT) ) - { - auto src = (unsigned __int16 *)Dst.lpSurface; - auto src_width = (Dst.lPitch / sizeof(short)); - auto src_height = Dst.dwHeight; - auto dst = pPixels; - for (uint y = 0; y < height; ++y) - { - //uint src_y = (game_viewport_y + y * v25) * (Dst.lPitch / sizeof(short)); - uint src_y = game_viewport_y + y * v25; - assert(game_viewport_y + y * v25 < src_height); - assert(y < height); - - for (uint x = 0; x < width; ++x) - { - //uint src_x = game_viewport_x + x * v23; - uint src_x = game_viewport_x + x * v23; - assert(src_x < src_width); - assert(x < width); - - dst[y * width + x] = (((63*y)/117) << 5) | 31*x/155;//31*y/117;//src[src_y * src_width + src_x]; - } - } - ErrD3D(pRenderer->pBackBuffer4->Unlock(0)); - } - else - { - __debugbreak(); // unrefactored - v4 = height; - if ( height > 0 ) - { - do - { - if ( width > 0 ) - { - v5 = width & 1; - v6 = (unsigned int)width >> 1; - memset(v3, 0, 4 * ((unsigned int)width >> 1)); - v7 = &v3[2 * v6]; - for ( j = v5; j; --j ) - { - *v7 = 0; - ++v7; - } - v3 += width; - } - --v4; - } - while ( v4 ); - } - } - } - else - { - pRenderer->BeginScene(); - if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) - { - pIndoor->Draw(); - } - else - { - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - pOutdoor->Draw(); - } - _this = pRenderer->pTargetSurface; - v26 = pRenderer->uTargetSurfacePitch; - if ( pRenderer->pTargetSurface ) - { - v29 = 0; - if ( height > 0 ) - { - do - { - v28 = 0; - if ( width > 0 ) - { - v15 = v26 * (unsigned __int64)(signed __int64)((double)v29 * v25 + 8.0); - do - { - v16 = (signed __int64)((double)v28++ * v23 + 8.0); - *v3 = _this[v15 + (int)v16]; - ++v3; - } - while ( v28 < width ); - } - ++v29; - } - while ( v29 < height ); - } - } - else - { - if ( height > 0 ) - { - v17 = height; - do - { - if ( width > 0 ) - { - memset(v3, 0, 4 * ((unsigned int)width >> 1)); - v18 = &v3[2 * ((unsigned int)width >> 1)]; - for ( k = width & 1; k; --k ) - { - *v18 = 0; - ++v18; - } - v3 += width; - } - --v17; - } - while ( v17 ); - } - } - pRenderer->EndScene(); - } - return pPixels; -} - -//----- (0045E26C) -------------------------------------------------------- -void __thiscall SaveScreenshot(const char *pFilename) -{ - const char *v1; // edi@1 - unsigned __int16 *v2; // esi@1 - - v1 = pFilename; - v2 = MakeScreenshot(92, 68); - pRenderer->SavePCXImage(v1, (char *)v2, 92, 68); - free(v2); -} - -//----- (00460706) -------------------------------------------------------- -void TryLoadLevelFromLOD() -{ - FILE *v0; // eax@1 - FILE *v1; // esi@1 - __int32 v2; // edi@2 - char Ext[256]; // [sp+4h] [bp-40Ch]@1 - char Dir[256]; // [sp+104h] [bp-30Ch]@1 - char Filename[256]; // [sp+204h] [bp-20Ch]@1 - char a1[260]; // [sp+304h] [bp-10Ch]@1 - char Drive[4]; // [sp+408h] [bp-8h]@1 - int DstBuf; // [sp+40Ch] [bp-4h]@2 - - strcpy(a1, pCurrentMapName.data()); - _splitpath(a1, Drive, Dir, Filename, Ext); - sprintf(a1, "levels\\%s%s", Filename, ".lod"); - v0 = fopen(a1, "rb"); - v1 = v0; - if ( v0 ) - { - fseek(v0, 0, 2); - v2 = ftell(v1); - rewind(v1); - ptr_6A0D08 = pAllocator->AllocNamedChunk(ptr_6A0D08, v2, "LevelLod"); - fread(ptr_6A0D08, v2, 1u, v1); - fseek(v1, v2 - 6, 0); - DstBuf = 0; - fread(&DstBuf, 4u, 1u, v1); - fread(&_6A0D10_txt_lod_loading__unused, 2u, 1u, v1); - _6A0D0C_txt_lod_loading = (int)((char *)ptr_6A0D08 + DstBuf); - fclose(v1); - } -} - -//----- (0046080D) -------------------------------------------------------- -void __cdecl sub_46080D() -{ - pAllocator->FreeChunk(ptr_6A0D08); - ptr_6A0D08 = 0; - _6A0D0C_txt_lod_loading = 0; -} - -//----- (0046082C) -------------------------------------------------------- -bool Initialize_GamesLOD_NewLOD() -{ - pGames_LOD = new LODWriteableFile; - pGames_LOD->AllocSubIndicesAndIO(300, 0); - if (pGames_LOD->LoadFile("data\\games.lod", 1)) - { - pNew_LOD = new LODWriteableFile; - pNew_LOD->AllocSubIndicesAndIO(300, 100000); - return true; - } - return false; -} - -//----- (0046086A) -------------------------------------------------------- -void SaveNewGame() -{ - FILE *v3; // eax@7 - void *pSave; // [sp+170h] [bp-8h]@3 - - if ( pVideoPlayer->AnyMovieLoaded() ) - pVideoPlayer->Unload(); - pSave = pAllocator->AllocNamedChunk(0, 1000000, 0); - pNew_LOD->CloseWriteFile(); - remove("data\\new.lod"); - - LOD::FileHeader this_; // [sp+Ch] [bp-16Ch]@3 - strcpy(this_.LodVersion, "MMVII"); - strcpy(this_.LodDescription, "newmaps for MMVII"); - this_.LODSize = 100; - this_.dword_0000A8 = 0; - - LOD::Directory a3; // [sp+14Ch] [bp-2Ch]@3 - a3.dword_000018 = 0; - a3.word_00001E = 0; - strcpy(a3.pFilename, "current"); - pNew_LOD->CreateNewLod(&this_, &a3, "data\\new.lod"); - if (pNew_LOD->LoadFile("data\\new.lod", false)) - { - pNew_LOD->CreateTempFile(); - pNew_LOD->uNumSubDirs = 0; - - LOD::Directory pDir; // [sp+10Ch] [bp-6Ch]@4 - for (int i = pGames_LOD->uNumSubDirs / 2; i < pGames_LOD->uNumSubDirs; ++i) - { - memcpy(&pDir, &pGames_LOD->pSubIndices[i], sizeof(pDir)); - v3 = pGames_LOD->FindContainer(pGames_LOD->pSubIndices[i].pFilename, 1); - fread(pSave, pGames_LOD->pSubIndices[i].uDataSize, 1, v3); - pNew_LOD->AppendDirectory(&pDir, pSave); - } - - LOD::Directory save_game_dir; // [sp+12Ch] [bp-4Ch]@9 - strcpy(pSavegameHeader[0].pLocationName, "out01.odm"); - strcpy(save_game_dir.pFilename, "header.bin"); - save_game_dir.uDataSize = sizeof(SavegameHeader); - pNew_LOD->AppendDirectory(&save_game_dir, &pSavegameHeader[0]); - - pNew_LOD->FixDirectoryOffsets(); - pParty->vPrevPosition.y = 0; - pParty->vPrevPosition.x = 12552; - pParty->vPosition.x = 12552; - pParty->vPosition.z = 0; - pParty->uFallStartY = 0; - pParty->sPrevRotationX = 0; - pParty->sRotationX = 0; - pParty->vPrevPosition.z = 1816; - pParty->vPosition.y = 1816; - pParty->sPrevRotationY = 512; - pParty->sRotationY = 512; - SaveGame(1, 1); - } - pAllocator->FreeChunk(pSave); -} - //----- (004610AA) -------------------------------------------------------- void __fastcall PrepareToLoadODM(unsigned int bLoading, OutdoorCamera *a2) { @@ -7772,845 +6676,8 @@ return uCurrentMenuID; } -//----- (00467F48) -------------------------------------------------------- -void CreateMsgScrollWindow( signed int mscroll_id ) - { - signed int v1; // esi@1 - - v1 = mscroll_id; - if ( !pGUIWindow_ScrollWindow && mscroll_id >= 700 ) - { - if ( mscroll_id <= 782 ) - { - uTextureID_720980 = pIcons_LOD->LoadTexture("leather", TEXTURE_16BIT_PALETTE); - pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Scroll, v1 - 700, 0); - } - } -} // 720980: using guessed type int uTextureID_720980; -//----- (00467F9F) -------------------------------------------------------- -void __cdecl free_book_subwindow() -{ - if ( pGUIWindow_ScrollWindow ) - { - pGUIWindow_ScrollWindow->Release(); - pGUIWindow_ScrollWindow = 0; - } -} - -//----- (00467FB6) -------------------------------------------------------- -void CreateScrollWindow() - { - unsigned int v0; // eax@1 - char *v1; // ST18_4@3 - unsigned int v2; // eax@3 - GUIWindow a1; // [sp+Ch] [bp-54h]@1 - - memcpy(&a1, pGUIWindow_ScrollWindow, sizeof(a1)); - a1.Hint = 0; - a1.uFrameX = 1; - a1.uFrameY = 1; - a1.uFrameWidth = 468; - v0 = pFontSmallnum->CalcTextHeight(pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C], &a1, 0, 0) - + 2 * LOBYTE(pFontCreate->uFontHeight) - + 24; - a1.uFrameHeight = v0; - if ( (signed int)(v0 + a1.uFrameY) > 479 ) - { - v0 = 479 - a1.uFrameY; - a1.uFrameHeight = 479 - a1.uFrameY; - } - a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1; - a1.uFrameW = v0 + a1.uFrameY - 1; - a1.DrawMessageBox(0); - a1.uFrameX += 12; - a1.uFrameWidth -= 24; - a1.uFrameY += 12; - a1.uFrameHeight -= 12; - a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1; - a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1; - v1 = pItemsTable->pItems[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C + 700].pName; - v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu); - sprintf(pTmpBuf.data(), format_4E2D80, v2, v1); - a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3u); - a1.DrawText( - pFontSmallnum, - 1, - LOBYTE(pFontCreate->uFontHeight) - 3, - 0, - pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C], - 0, - 0, - 0); -} - -//----- (00468F8A) -------------------------------------------------------- -void __cdecl OnPaperdollLeftClick() -{ - int v1; // ecx@1 - unsigned int v2; // edi@1 - unsigned int v3; // edx@4 - unsigned int pSkillType; // esi@5 - unsigned __int16 v5; // ax@7 - unsigned int v6; // edi@19 - int v7; // esi@27 - unsigned int v8; // eax@29 - int v9; // edx@32 - int v10; // esi@34 - int v11; // eax@34 - int v12; // esi@38 - int v13; // eax@38 - char v14; // zf@38 - int v15; // esi@42 - int v16; // eax@42 - int v17; // eax@44 - unsigned int v18; // ecx@55 - unsigned int v19; // eax@55 - int v20; // esi@60 - int v21; // eax@60 - unsigned int v22; // eax@61 - unsigned int v23; // eax@62 - int v24; // esi@65 - int v25; // eax@65 - unsigned int v26; // eax@69 - int v27; // esi@81 - int v28; // eax@81 - int v29; // esi@84 - int v30; // eax@84 - int v31; // eax@85 - unsigned int v32; // ecx@88 - unsigned int v33; // eax@88 - int v34; // esi@90 - unsigned int v35; // eax@91 - int v36; // esi@93 - int v37; // edi@93 - ItemGen *v38; // edi@93 - __int16 v39; // dx@99 - ItemGen _this; // [sp+Ch] [bp-40h]@1 - unsigned int v48; // [sp+30h] [bp-1Ch]@88 - 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 v53; // [sp+44h] [bp-8h]@1 - //unsigned int v54; // [sp+48h] [bp-4h]@1 - - v51 = 0; - _this.Reset(); - //v0 = pPlayers[uActiveCharacter]; - v1 = pPlayers[uActiveCharacter]->pEquipment.uMainHand; - v2 = pPlayers[uActiveCharacter]->pEquipment.uShield; - //v54 = pPlayers[uActiveCharacter]->pEquipment.uShield; - //v53 = v1; - if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1 - 1]].uEquipType == 1 ) - v51 = v1; - v3 = pParty->pPickedItem.uItemID; - if ( pParty->pPickedItem.uItemID ) - { - v52 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType; - pSkillType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSkillType; - if ( pSkillType == 4 ) - { - if ( v2 ) - { - LOBYTE(v5) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_SPEAR); - if ( (signed int)SkillToMastery(v5) < 3 ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - v3 = pParty->pPickedItem.uItemID; - } - } - else - { - if ( (pSkillType == 8 || pSkillType == 1 || pSkillType == 2) - && v1 - && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1-1]].uSkillType == 4 ) - { - LOBYTE(v5) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_SPEAR); - if ( (signed int)SkillToMastery(v5) < 3 ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - } - } - if ( !pPlayers[uActiveCharacter]->CanEquip_RaceAndAlignmentCheck(v3) ) - { - - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - if ( pParty->pPickedItem.uItemID == 604 ) - { - pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)3); - WetsuitOn(uActiveCharacter); - return; - } - v6 = v52; - switch ( v52 ) - { - case 2u: - case 3u: - case 5u: - case 6u: - case 7u: - case 8u: - case 9u: - case 0xBu: - if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) && (v6 != 3 || bUnderwater) ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)v6); - if ( pParty->pPickedItem.uItemID == 604 ) - WetsuitOff(uActiveCharacter); - return; - case 0xAu: - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - v52 = 10; - v7 = (int)&pPlayers[uActiveCharacter]->pEquipment.uRings; - while ( 1 ) - { - if ( !*(int *)v7 ) - { - v8 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v8 & 0x80000000u) == 0 ) - { - v9 = v52; - pParty->pPickedItem.uBodyAnchor = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v8], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v8])); - *(&pPlayers[uActiveCharacter]->pEquipment.uShield + v9) = v8 + 1; - pMouse->RemoveHoldingItem(); - break; - } - } - ++v52; - v7 += 4; - if ( (signed int)v52 > 15 ) - break; - } - if ( v52 == 16 ) - { - v52 = pPlayers[uActiveCharacter]->pEquipment.uRings[6] - 1; - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v10 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v52); - *(char *)(v10 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v10 + 532)); - _this.uBodyAnchor = 16; - v11 = v52 + 1; - memcpy((void *)(v10 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uRings[6] = v11; - } - return; - case 4u: - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - if ( v2 ) - { - --v2; - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); - *(char *)(v12 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v12 + 532)); - _this.uBodyAnchor = 1; - v13 = v2 + 1; - v14 = v51 == 0; - memcpy((void *)(v12 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uShield = v13; - if ( v14 ) - return; - } - else - { - v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v52 & 0x80000000u) != 0 ) - return; - if ( !v51 ) - { - pParty->pPickedItem.uBodyAnchor = 1; - v17 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); - pPlayers[uActiveCharacter]->pEquipment.uShield = v17; - pMouse->RemoveHoldingItem(); - return; - } - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v1 - 1)); - *(char *)(v15 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v15 + 532)); - _this.uBodyAnchor = 1; - v16 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); - pPlayers[uActiveCharacter]->pEquipment.uShield = v16; - } - pPlayers[uActiveCharacter]->pEquipment.uMainHand = 0; - return; - case 0u: - case 0xCu: - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) - && pParty->pPickedItem.uItemID != 64 - && pParty->pPickedItem.uItemID != 65 ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - v50 = 0; - if ( pSkillType == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[2] & 0xFFC0) - || pSkillType == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[1]) >= 3 ) - { - - v18 = pMouse->uMouseClickX; - v19 = pMouse->uMouseClickY; - - v49 = v19; - if ( (signed int)v18 >= 560 ) - { - if ( !v51 ) - { - if ( v2 ) - { - --v2; - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); - *(char *)(v20 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v20 + 532)); - _this.uBodyAnchor = 1; - v21 = v2 + 1; - v14 = v52 == 12; - memcpy((void *)(v20 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uShield = v21; - if ( !v14 ) - return; - v22 = _this.uItemID; - v50 = v22; - if ( v50 ) - { - __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); - } - break; - } - v23 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v23 & 0x80000000u) != 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])); - pPlayers[uActiveCharacter]->pEquipment.uShield = v23 + 1; - pMouse->RemoveHoldingItem(); - if ( v52 != 12 ) - return; - v22 = *(int *)v50; - v50 = v22; - if ( v50 ) - { - __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); - } - break; - } - } - } - if ( !v1 ) - { - v26 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v26 & 0x80000000u) != 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])); - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v26 + 1; - pMouse->RemoveHoldingItem(); - if ( v52 != 12 ) - return; - v22 = *(int *)v50; - v50 = v22; - if ( v50 ) - { - __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); - } - break; - } - --v1; - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); - *(char *)(v24 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v24 + 532)); - _this.uBodyAnchor = 2; - v25 = v1 + 1; - v14 = v52 == 12; - memcpy((void *)(v24 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v25; - if ( v14 ) - v50 = _this.uItemID; - if ( v51 ) - pPlayers[uActiveCharacter]->pEquipment.uShield = 0; - if ( v50 ) - { - __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 - stru_A750F8[uActiveCharacter - 1]._494836( *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); - } - break; - case 1u: - if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) - { - pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); - return; - } - if ( v1 ) - { - if ( v2 ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - --v1; - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); - *(char *)(v27 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v27 + 532)); - _this.uBodyAnchor = 2; - v28 = v1 + 1; - memcpy((void *)(v27 + 532), &_this, 0x24u); - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v28; - } - else - { - v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); - if ( (v52 & 0x80000000u) == 0 ) - { - if ( v2 ) - { - memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); - v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v2 - 1)); - *(char *)(v29 + 556) = 0; - pParty->pPickedItem.Reset(); - pParty->SetHoldingItem((ItemGen *)(v29 + 532)); - _this.uBodyAnchor = 2; - v30 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); - pPlayers[uActiveCharacter]->pEquipment.uShield = 0; - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v30; - } - else - { - pParty->pPickedItem.uBodyAnchor = 2; - v31 = v52 + 1; - memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); - pPlayers[uActiveCharacter]->pEquipment.uMainHand = v31; - pMouse->RemoveHoldingItem(); - } - } - } - return; - default: - pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(uActiveCharacter, 0); - return; - } - return; - } - - v32 = pMouse->uMouseClickX; - v33 = pMouse->uMouseClickY; - - v34 = pRenderer->pActiveZBuffer[v32 + pSRZBufferLineOffsets[v33]] & 0xFFFF; - if ( v34 ) - { - v36 = v34 - 1; - v37 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v36); - v50 = v37; - v38 = (ItemGen *)(v37 + 532); - v14 = v38->uItemID == 604; - v52 = pItemsTable->pItems[v38->uItemID].uEquipType; - if ( v14 ) - { - if ( bUnderwater ) - { - pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); - return; - } - WetsuitOff(uActiveCharacter); - } - if ( unk_50C9A0 ) - { - *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; - *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; - v39 = v52; - *((int *)pGUIWindow_Settings->ptr_1C + 3) = v36; - *((short *)pGUIWindow_Settings->ptr_1C + 3) = v39; - ptr_50C9A4 = v38; - unk_50C9A0 = 0; - if ( pMessageQueue_50CBD0->uNumMessages ) - pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; - pMouse->SetCursorBitmap("MICON1"); - dword_50C9D4 = 0; - dword_50C9D0 = 113; - dword_50C9D8 = 256; - } - else - { - if ( !ptr_50C9A4 ) - { - pParty->SetHoldingItem(v38); - *(&pPlayers[uActiveCharacter]->uBirthYear + *(char *)(v50 + 556)) = 0; - v38->Reset(); - } - } - } - else - { - v35 = pPlayers[uActiveCharacter]->pEquipment.uBow; - if ( v35 ) - { - auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v35 - 1]; - pParty->SetHoldingItem(_a); - _a->Reset(); - pPlayers[uActiveCharacter]->pEquipment.uBow = 0; - } - } -} - - -//----- (0046A14B) -------------------------------------------------------- -void OnPressSpace() -{ - //SHORT v0; // ax@2 - int *v1; // eax@2 - char *v2; // ebx@5 - unsigned int v3; // esi@5 - signed int v4; // edi@7 - unsigned int v5; // edx@7 - int v6; // ecx@8 - int v7; // eax@8 - int v8; // ecx@17 - int *v9; // esi@22 - signed int v10; // ebx@22 - int i; // edi@23 - int v12; // edx@24 - int v13; // ecx@24 - int j; // esi@28 - int v16; // [sp+4h] [bp-1Ch]@0 - char *v17; // [sp+8h] [bp-18h]@5 - unsigned int v18; // [sp+Ch] [bp-14h]@5 - int v19; // [sp+10h] [bp-10h]@8 - int *v20; // [sp+14h] [bp-Ch]@5 - int *v21; // [sp+18h] [bp-8h]@7 - int v22; // [sp+1Ch] [bp-4h]@4 - - if ( pRenderer->pRenderD3D ) - { - pGame->PickKeyboard(GetAsyncKeyState(VK_CONTROL) & 0x8001, &vis_sprite_filter_3, &vis_door_filter); - auto pid = pGame->pVisInstance->get_picked_object_zbuf_val(); - if ( pid != -1 ) - DoInteractionWithTopmostZObject(pid & 0xFFFF, PID_ID(pid)); - return; - } - - - // software render stuff following - - static int dword_720660[100]; // 720660 - static int dword_7207F0[100]; // 7207F0 - - v22 = 0; - v1 = (int *)((signed int)(viewparams->uScreen_BttmR_X + viewparams->uScreen_topL_X) >> 1);//wrong pointer - if ( (signed int)viewparams->uScreen_topL_Y < (signed int)viewparams->uScreen_BttmR_Y ) - { - v2 = (char *)v1 - 50; - v1 = (int *)((char *)v1 + 50); - v3 = 640 * viewparams->uScreen_topL_Y; - v17 = v2; - v20 = v1; - v18 = ((viewparams->uScreen_BttmR_Y - viewparams->uScreen_topL_Y - 1) >> 1) + 1; - do - { - if ( (signed int)v2 < (signed int)v20 ) - { - v1 = &pRenderer->pActiveZBuffer[(int)&v2[v3]]; - v21 = &pRenderer->pActiveZBuffer[(int)&v2[v3]]; - v4 = v22; - v5 = (((char *)v20 - v2 - 1) >> 1) + 1; - do - { - v6 = 0; - v7 = *v1 & 0xFFFF; - v19 = 0; - if ( v4 > 0 ) - { - do - { - if ( dword_7207F0[v6] == v7 ) - break; - ++v6; - v19 = v6; - } - while ( v6 < v22 ); - } - if ( PID_TYPE(v7) == OBJECT_Decoration) - { - v16 = (unsigned int)PID_ID(v7); - if ( (signed int)(((unsigned int)*v21 >> 16) - - pDecorationList->pDecorations[pLevelDecorations[(unsigned int)PID_ID(v7)].uDecorationDescID].uRadius) <= 512 ) - if ( v19 == v22 && v4 < 100 ) - { - ++v22; - ++v4; - v8 = *v21; - dword_7207F0[v4 - 1] = v7; - dword_720660[v4 - 1] = v8; - } - } - else if ( (unsigned int)*v21 <= 0x2000000 ) - { - if ( v19 == v22 && v4 < 100 ) - { - ++v22; - ++v4; - v8 = *v21; - dword_7207F0[v4 - 1] = v7; - dword_720660[v4 - 1] = v8; - } - } - v1 = v21 + 2; - --v5; - v21 += 2; - } - while ( v5 ); - v2 = v17; - } - v3 += 1280; - --v18; - } - while ( v18 ); - } - if ( v22 > 0 ) - { - v9 = dword_720660; - v10 = 1; - do - { - for ( i = v10; i < v22; ++i ) - { - v12 = *v9; - v13 = dword_720660[i]; - if ( v13 < *v9 ) - { - *v9 = v13; - dword_720660[i] = v12; - } - } - ++v10; - ++v9; - LOBYTE(v1) = v10 - 1; - } - while ( v10 - 1 < v22 ); - } - for ( j = 0; j < v22; ++j ) - { - LOBYTE(v1) = DoInteractionWithTopmostZObject(dword_720660[j] & 0xFFFF, v16); - if ( !(char)v1 ) - break; - } -} - -//----- (0046A334) -------------------------------------------------------- -char __fastcall DoInteractionWithTopmostZObject(int a1, int a2) -{ - int v2; // edx@1 - BLVFace *v4; // eax@9 - unsigned int v5; // ecx@9 - unsigned __int16 v6; // ax@11 - //ODMFace *v7; // eax@16 - LevelDecoration *v8; // esi@19 - __int16 v9; // ax@19 - int v10; // eax@22 - int v11; // ecx@22 - int v12; // edi@23 - Actor *v13; // esi@23 - unsigned __int16 v14; // ax@23 - unsigned __int16 v15; // ax@33 - const char *v16; // eax@34 - int v17; // edi@36 - int v18; // eax@36 - ItemGen *v19; // esi@39 - unsigned int v20; // eax@39 - int v21; // ecx@40 - std::string v22; // [sp-18h] [bp-2Ch]@5 - const char *v23; // [sp-8h] [bp-1Ch]@5 - int v24; // [sp-4h] [bp-18h]@5 - char v25; // [sp+8h] [bp-Ch]@5 - int v26; // [sp+Ch] [bp-8h]@1 - int a3; // [sp+13h] [bp-1h]@5 - - v26 = a2; - v2 = a1; - switch ( PID_TYPE(a1) ) - { - case OBJECT_Item: // take the item - v17 = PID_ID(a1); - v26 = PID_ID(a1); - v18 = PID_ID(a1); - if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10 - || v17 >= 1000 - || !pSpriteObjects[v18].uObjectDescID ) - return 1; - v19 = &pSpriteObjects[v18].stru_24; - v20 = pSpriteObjects[v18].stru_24.uItemID; - if ( pItemsTable->pItems[v20].uEquipType == EQUIP_GOLD) - { - party_finds_gold(v19->uSpecEnchantmentType, 0); - viewparams->bRedrawGameUI = 1; - v21 = v17; - } - else - { - if ( pParty->pPickedItem.uItemID ) - return 1; - v24 = (int)pItemsTable->pItems[v20].pUnidentifiedName; - sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[471], v24); - ShowStatusBarString(pTmpBuf2.data(), 2u); - if ( v19->uItemID == 506 ) - _449B7E_toggle_bit(pParty->_quest_bits, 184, 1u); - if ( v19->uItemID == 455 ) - _449B7E_toggle_bit(pParty->_quest_bits, 185, 1u); - if ( !pParty->AddItem(v19) ) - pParty->SetHoldingItem(v19); - v21 = v26; - } - SpriteObject::OnInteraction(v21); - break; - - case OBJECT_Actor: - v12 = PID_ID(a1); - v13 = &pActors[PID_ID(a1)]; - v14 = v13->uAIState; - if ( v14 == 4 || v14 == 17 ) - return 1; - if ( v14 == 5 ) - { - stru_50C198.LootActor(&pActors[PID_ID(a1)]); - } - else - { - if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() ) - { - Actor::AI_FaceObject(v12, 4u, 0, 0); - if ( v13->sNPC_ID ) - { - pMessageQueue_50CBD0->AddMessage(UIMSG_StartNPCDialogue, v12, 0); - } - else - { - v15 = pNPCStats->pGroups_copy[v13->uGroup]; - if ( v15 ) - { - v16 = pNPCStats->pCatchPhrases[v15]; - if ( v16 ) - { - pParty->uFlags |= 2u; - strcpy(byte_5B0938.data(), v16); - sub_4451A8_press_any_key(0, 0, 0); - } - } - } - } - } - break; - - case OBJECT_Decoration: - v8 = &pLevelDecorations[PID_ID(a1)]; - v9 = v8->field_16_event_id; - if ( v9 ) - { - EventProcessor(v9, a1, 1); - LOBYTE(v8->field_2) |= 8u; - } - else - { - if ( !pLevelDecorations[PID_ID(a1)].IsInteractive() ) - return 1; - v10 = v8->_idx_in_stru123; - v24 = 1; - v11 = stru_5E4C90._decor_events[v10 - 75] + 380; - activeLevelDecoration = v8; - EventProcessor(v11, 0, 1); - activeLevelDecoration = NULL; - } - break; - - default: - MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); - return 1; - - case OBJECT_BModel: - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) - { - int bmodel_id = a1 >> 9, - face_id = PID_ID(a1) & 0x3F; - if (bmodel_id >= pOutdoor->uNumBModels) - return 1; - auto face = &pOutdoor->pBModels[bmodel_id].pFaces[face_id]; - if (face->uAttributes & 0x100000 || face->sCogTriggeredID == 0 ) - return 1; - EventProcessor((signed __int16)face->sCogTriggeredID, v2, 1); - } - else - { - v4 = &pIndoor->pFaces[PID_ID(a1)]; - v5 = v4->uAttributes; - if ( !(v5 & 0x2000000) ) - { - ShowNothingHereStatus(); - return 1; - } - if ( v5 & 0x100000 || (v6 = pIndoor->pFaceExtras[v4->uFaceExtraID].uEventID) == 0 ) - return 1; - if ( pCurrentScreen != SCREEN_BRANCHLESS_NPC_DIALOG ) - EventProcessor((signed __int16)v6, v2, 1); - } - return 0; - break; - } - return 0; -} // 4E28F8: using guessed type int pCurrentScreen; //----- (0046A6AC) -------------------------------------------------------- @@ -9080,167 +7147,6 @@ } } -//----- (0046BDF1) -------------------------------------------------------- -void __cdecl BLV_UpdateUserInputAndOther() -{ - UpdateObjects(); - BLV_ProcessPartyActions(); - UpdateActors_BLV(); - BLV_UpdateDoors(); - check_event_triggers(); -} - -//----- (0046BE0A) -------------------------------------------------------- -void __cdecl ODM_UpdateUserInputAndOther() -{ - bool v0; // eax@5 - char pOut[32]; // [sp+8h] [bp-20h]@5 - - UpdateObjects(); - ODM_ProcessPartyActions(); - if ( pParty->vPosition.x < -22528 - || pParty->vPosition.x > 22528 - || pParty->vPosition.y < -22528 - || pParty->vPosition.y > 22528 ) - { - strcpy(pOutdoor->pLevelFilename, pCurrentMapName.data()); - v0 = pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pOut, 32); - if ( !bUnderwater && (pParty->uFlags & (PARTY_FLAGS_1_STANDING_ON_WATER | PARTY_FLAGS_1_FALLING | 0x04) || pParty->uFlags & 0x0200 || pParty->bFlying) || !v0 ) - { - if ( pParty->vPosition.x < -22528 ) - pParty->vPosition.x = -22528; - if ( pParty->vPosition.x > 22528 ) - pParty->vPosition.x = 22528; - if ( pParty->vPosition.y < -22528 ) - pParty->vPosition.y = -22528; - if ( pParty->vPosition.y > 22528 ) - pParty->vPosition.y = 22528; - } - else - { - pAudioPlayer->StopChannels(-1, -1); - TravelUI_Load(); - } - } - UpdateActors_ODM(); - check_event_triggers(); -} - -//----- (0046BEF1) -------------------------------------------------------- -void SpriteObject::_46BEF1_apply_spells_aoe() -{ - SpriteObject *v1; // edi@1 - Actor *v2; // esi@2 - __int16 v3; // fps@4 - unsigned __int8 v4; // c0@4 - unsigned __int8 v5; // c3@4 - signed int v6; // [sp+8h] [bp-4h]@1 - - int v7,v8,v9,v10,v11; - - v6 = 0; - v1 = this; - if ( (signed int)uNumActors > 0 ) - { - v2 = pActors.data();//[0].vPosition.y; - do - { - if ( v2->CanAct() ) - { - //UNDEF(v3); - //.text:0046BF26 movsx eax, word ptr [esi-2] - //.text:0046BF2A sub eax, [edi+4] - //.text:0046BF31 mov [ebp+var_8], eax - //.text:0046BF37 fild [ebp+var_8] - // v7 pushed to stack - v7 = v2->vPosition.x - this->vPosition.x; - - //.text:0046BF2D movsx ecx, word ptr [esi+2] - v8 = v2->vPosition.z; - - //.text:0046BF34 movsx eax, word ptr [esi] - //.text:0046BF3A sub eax, [edi+8] - //.text:0046BF3D mov [ebp+var_8], eax - //.text:0046BF44 fild [ebp+var_8] - // v9 pushed to stack - v9 = v2->vPosition.y - this->vPosition.y; - - //.text:0046BF40 movsx eax, word ptr [esi-6] - //.text:0046BF47 sar eax, 1 - //.text:0046BF49 add eax, ecx - //.text:0046BF4B sub eax, [edi+0Ch] - //.text:0046BF4E mov [ebp+var_8], eax - //.text:0046BF51 fild [ebp+var_8] - //.text:0046BF58 fld st - // v10 pushed to stack, two times - v10 = v2->uActorHeight / 2 + v8 - this->vVelocity.y; - - //.text:0046BF54 movsx eax, word ptr [esi-8] - //.text:0046BF5A add eax, 100h - //.text:0046BF63 mov ecx, eax - v11 = this->vVelocity.x; - - //.text:0046BF5F fmul st, st(1) - // stack: v10*v10, v10, v9, v7 - //.text:0046BF61 fld st(2) - // stack: v7, v10*v10, v10, v9, v7 - - - //.text:0046BF65 fmul st, st(3) - // stack: v7*v9, v10*v10, v10, v9, v7 - - //.text:0046BF67 imul ecx, eax - v11 = v11 * v11; - - //.text:0046BF6A faddp st(1), st - // stack: v10*v10+v7*v9, v10, v9, v7 - //.text:0046BF6C fld st(3) - // stack: v7, v10*v10+v7*v9, v10, v9, v7 - //.text:0046BF6E fmul st, st(4) - // stack: v7*v7, v10*v10+v7*v9, v10, v9, v7 - //.text:0046BF70 faddp st(1), st - // stack: v10*v10+v7*v9+v7*v7, v10, v9, v7 - - //.text:0046BF72 mov [ebp+var_8], ecx - //.text:0046BF75 fild [ebp+var_8] - // v11 pushed to stack - - //.text:0046BF78 fcompp - // if ( v11 > v10*v10+v7*v9+v7*v7 ) - // stack: v10, v9, v7 - - //.text:0046BF7A fstp st - // stack: v9, v7 - - //.text:0046BF7C fnstsw ax - //.text:0046BF7E fstp st - // stack: v7 - - //.text:0046BF80 test ah, 41h - //.text:0046BF83 fstp st - //.text:0046BF85 jnz short loc_46BFDD - - if ( v11 >= v10*v10+v7*v9+v7*v7 ) - { - if ( stru_50C198.GetMagicalResistance(v2, 0xAu) ) - { - v2->pActorBuffs[v1->spell_id].Apply( - pParty->uTimePlayed + (signed int)(signed __int64)((double)(v1->spell_level << 7) * 0.033333335), - v1->spell_skill, - 4u, - 0, - 0); - HIWORD(v2->uAttributes) |= 8u; - } - } - } - ++v6; - ++v2; - } - while ( v6 < (signed int)uNumActors ); - } -} - //----- (0046BFFA) -------------------------------------------------------- bool __fastcall _46BFFA_check_object_intercept(unsigned int uLayingItemID, signed int a2) { diff -r c423f946dc99 -r 5450af4f57ef mm7_3.cpp --- a/mm7_3.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/mm7_3.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -11756,35 +11756,6 @@ } } -//----- (004488B6) -------------------------------------------------------- -unsigned __int16 DecorationList::GetDecorIdByName(const char *pName) -{ - DecorationList *v2; // esi@1 - signed int uID; // edi@2 - signed int v4; // ebx@3 - unsigned __int16 result; // ax@6 - - v2 = this; - if ( pName && (uID = 1, (signed int)this->uNumDecorations > 1) ) - { - v4 = 1; - while ( _stricmp(pName, v2->pDecorations[v4].pName) ) - { - ++uID; - ++v4; - if ( uID >= (signed int)v2->uNumDecorations ) - goto LABEL_6; - } - result = uID; - } - else - { -LABEL_6: - result = 0; - } - return result; -} - //----- (0044892E) -------------------------------------------------------- void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on) { diff -r c423f946dc99 -r 5450af4f57ef mm7_5.cpp --- a/mm7_5.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/mm7_5.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -4065,89 +4065,6 @@ memcpy((char *)&v17->cpuid_80000002_registers2[0] + 1, v18, 0x30u);*/ } -//----- (00438BDF) -------------------------------------------------------- -bool MonsterStats::BelongsToSupertype(unsigned int uMonsterInfoID, enum MONSTER_SUPERTYPE eSupertype) -{ - unsigned __int8 v2; // zf@15 - char v3; // sf@15 - unsigned __int8 v4; // of@15 - bool result; // eax@33 - - switch ( eSupertype ) - { - case MONSTER_SUPERTYPE_UNDEAD: - if ( (signed int)uMonsterInfoID >= MONSTER_GHOST_1 && (signed int)uMonsterInfoID <= MONSTER_GHOST_3 - || (signed int)uMonsterInfoID >= MONSTER_LICH_1 && (signed int)uMonsterInfoID <= MONSTER_LICH_3 - || (signed int)uMonsterInfoID >= MONSTER_SKELETON_1 && (signed int)uMonsterInfoID <= MONSTER_SKELETON_3 - || (signed int)uMonsterInfoID >= MONSTER_VAMPIRE_1 && (signed int)uMonsterInfoID <= MONSTER_VAMPIRE_3 - || (signed int)uMonsterInfoID >= MONSTER_WIGHT_1 && (signed int)uMonsterInfoID <= MONSTER_WIGHT_3 - || (signed int)uMonsterInfoID >= MONSTER_ZOMBIE_1 && (signed int)uMonsterInfoID <= MONSTER_ZOMBIE_3 ) - goto ret_true; - if ( (signed int)uMonsterInfoID < MONSTER_GHOUL_1 ) - goto ret_false; - v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_GHOUL_3); - v2 = uMonsterInfoID == MONSTER_GHOUL_3; - v3 = ((uMonsterInfoID - MONSTER_GHOUL_3) & 0x80000000u) != 0; - goto false_if_outside; - case MONSTER_SUPERTYPE_KREEGAN: - if ( (signed int)uMonsterInfoID < MONSTER_DEVIL_1 ) - goto ret_false; - v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DEVIL_3); - v2 = uMonsterInfoID == MONSTER_DEVIL_3; - v3 = ((uMonsterInfoID - MONSTER_DEVIL_3) & 0x80000000u) != 0; - goto false_if_outside; - case MONSTER_SUPERTYPE_ELF: - if ( (signed int)uMonsterInfoID >= MONSTER_PEASANT_ELF_FEMALE_1_1 - && (signed int)uMonsterInfoID <= MONSTER_PEASANT_ELF_MALE_3_3 - || (signed int)uMonsterInfoID >= MONSTER_ELF_ARCHER_1 && (signed int)uMonsterInfoID <= MONSTER_ELF_ARCHER_3 ) - goto ret_true; - if ( (signed int)uMonsterInfoID < MONSTER_ELF_SPEARMAN_1 ) - goto ret_false; - v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELF_SPEARMAN_3); - v2 = uMonsterInfoID == MONSTER_ELF_SPEARMAN_3; - v3 = ((uMonsterInfoID - MONSTER_ELF_SPEARMAN_3) & 0x80000000u) != 0; - goto false_if_outside; - case MONSTER_SUPERTYPE_DRAGON: - if ( (signed int)uMonsterInfoID < MONSTER_DRAGON_1 ) - goto ret_false; - v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_DRAGON_3); - v2 = uMonsterInfoID == MONSTER_DRAGON_3; - v3 = ((uMonsterInfoID - MONSTER_DRAGON_3) & 0x80000000u) != 0; - goto false_if_outside; - case MONSTER_SUPERTYPE_WATER_ELEMENTAL: - if ( (signed int)uMonsterInfoID < MONSTER_ELEMENTAL_WATER_1 ) - goto ret_false; - v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_ELEMENTAL_WATER_3); - v2 = uMonsterInfoID == MONSTER_ELEMENTAL_WATER_3; - v3 = ((uMonsterInfoID - MONSTER_ELEMENTAL_WATER_3) & 0x80000000u) != 0; - goto false_if_outside; - case MONSTER_SUPERTYPE_TREANT: - if ( (signed int)uMonsterInfoID < MONSTER_TREANT_1 ) - goto ret_false; - v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TREANT_3); - v2 = uMonsterInfoID == MONSTER_TREANT_3; - v3 = ((uMonsterInfoID - MONSTER_TREANT_3) & 0x80000000u) != 0; - goto false_if_outside; - case MONSTER_SUPERTYPE_TITAN: - if ( (signed int)uMonsterInfoID < MONSTER_TITAN_1 ) - goto ret_false; - v4 = __OFSUB__(uMonsterInfoID, (int)MONSTER_TITAN_3); - v2 = uMonsterInfoID == MONSTER_TITAN_3; - v3 = ((uMonsterInfoID - MONSTER_TITAN_3) & 0x80000000u) != 0; -false_if_outside: - if ( !((unsigned __int8)(v3 ^ v4) | v2) ) - goto ret_false; -ret_true: - result = 1; - break; - default: -ret_false: - result = 0; - break; - } - return result; -} - //----- (00438F8F) -------------------------------------------------------- void __cdecl area_of_effect__damage_evaluate() { @@ -4376,983 +4293,8 @@ } // 50FE08: using guessed type stru298 stru_50FE08; -//----- (00439474) -------------------------------------------------------- -void DamageMonsterFromParty(signed int a1, unsigned int uActorID_Monster, Vec3_int_ *pVelocity) -{ - //signed int v3; // eax@1 - SpriteObject *v4; // ebx@1 - //int v5; // edx@3 - //bool uPlayerID; // eax@3 - //Player *pPlayer; // edi@4 - Actor *pMonster; // esi@7 - //SpriteObject *v9; // ebx@12 - int v10; // eax@12 - int v11; // ebx@12 - unsigned int v12; // ecx@12 - int v13; // edx@15 - int v14; // edx@17 - int v15; // eax@24 - unsigned __int16 v16; // cx@25 - int v17; // eax@29 - int v18; // eax@38 - unsigned __int8 v19; // zf@38 - unsigned __int8 v20; // sf@38 - int v21; // edx@44 - int v22; // eax@44 - unsigned __int8 v23; // zf@44 - unsigned __int8 v24; // sf@44 - int v25; // edx@51 - int v26; // ecx@51 - //signed int v27; // eax@51 - //int v28; // eax@53 - signed int v29; // eax@76 - signed int v30; // eax@84 - signed int v31; // eax@92 - int v32; // eax@94 - int v33; // eax@100 - int v34; // eax@104 - signed int v35; // eax@104 - double v36; // st7@104 - float v37; // ST08_4@104 - float v38; // ST04_4@104 - float v39; // ST00_4@104 - int v40; // ebx@107 - unsigned int v41; // ebx@109 - signed __int64 v42; // qax@125 - unsigned __int16 v43; // ax@132 - char v44; // bl@132 - unsigned __int16 v45; // ax@132 - unsigned __int64 v46; // [sp+Ch] [bp-60h]@6 - const char *v47; // [sp+14h] [bp-58h]@104 - char *pPlayerName; // [sp+18h] [bp-54h]@12 - char *pMonsterName; // [sp+1Ch] [bp-50h]@6 - int v50; // [sp+20h] [bp-4Ch]@6 - //unsigned __int64 *v51; // [sp+30h] [bp-3Ch]@6 - int v52; // [sp+34h] [bp-38h]@12 - //int v53; // [sp+38h] [bp-34h]@10 - //int v54; // [sp+3Ch] [bp-30h]@1 - //int v55; // [sp+40h] [bp-2Ch]@12 - signed int a4; // [sp+44h] [bp-28h]@1 - PlayerEquipment *v57; // [sp+48h] [bp-24h]@10 - //int v58; // [sp+4Ch] [bp-20h]@10 - int v59; // [sp+50h] [bp-1Ch]@1 - unsigned int uActorID_Monster_; // [sp+54h] [bp-18h]@1 - int v61; // [sp+58h] [bp-14h]@1 - bool v62; // [sp+5Ch] [bp-10h]@1 - int uDamageAmount; // [sp+60h] [bp-Ch]@1 - int a2; // [sp+64h] [bp-8h]@27 - int a3; // [sp+6Bh] [bp-1h]@6 - - //v3 = a1; - v4 = 0; - uActorID_Monster_ = uActorID_Monster; - //v54 = a1; - uDamageAmount = 0; - a4 = 0; - v61 = 0; - v59 = 0; - v62 = 0; - if ( PID_TYPE(a1) == OBJECT_Item) - { - v4 = &pSpriteObjects[PID_ID(a1)]; - //uDamageAmount = (int)v4; - v61 = v4->field_60_distance_related_prolly_lod; - a1 = v4->spell_caster_pid; - //v54 = v4->field_58_pid; - } - //v5 = a1 & 7; - //uPlayerID = a1 >> 3; - if (PID_TYPE(a1) != OBJECT_Player) - return; - - assert(PID_ID(abs(a1)) < 4); - auto player = &pParty->pPlayers[PID_ID(a1)]; - pMonster = &pActors[uActorID_Monster_]; - //uPlayerID = pMonster->IsAlive(); - if (pMonster->IsNotAlive()) - return; - - BYTE1(pMonster->uAttributes) |= 0xC0u; - if ( pMonster->uAIState == Fleeing ) - pMonster->uAttributes |= 0x20000u; - //v57 = 0; - //v53 = 0; - //v58 = 0; - bool hit_will_stun = false, - hit_will_paralyze = false; - if ( !v4 ) - { - //v51 = (unsigned __int64 *)player->pEquipment.uMainHand; - int main_hand_idx = player->pEquipment.uMainHand; - v59 = 1; - if ( player->HasItemEquipped(EQUIP_MAIN_HAND) ) - { - auto main_hand_skill = pItemsTable->pItems[player->pInventoryItems[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]); - //uDamageAmount = v28; - switch (main_hand_skill) - { - case PLAYER_SKILL_STAFF: - if (main_hand_mastery >= 3) - { - if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_STAFF) & 0x3F)) // stun chance when mastery >= 3 - hit_will_stun = true; - } - break; - - case PLAYER_SKILL_MACE: - if (main_hand_mastery >= 3) - { - if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)) - hit_will_stun = true; - } - if (main_hand_mastery >= 4) - { - if (rand() % 100 < (player->GetActualSkillLevel(PLAYER_SKILL_MACE) & 0x3F)) - hit_will_paralyze = true; - } - break; - } - } - v50 = pMonster->pMonsterInfo.uID; - a2 = 4; - //v27 = player->CalculateMeleeDamageTo(0, 0, v50); - uDamageAmount = player->CalculateMeleeDamageTo(0, 0, v50); - //if ( !v57 ) - goto LABEL_67; - //goto LABEL_69; - } - - - v19 = v4->spell_id == SPELL_DARK_SOULDRINKER; - v61 = v4->field_60_distance_related_prolly_lod; - if ( !v19 ) - { - //v9 = (SpriteObject *)uDamageAmount; - v50 = pParty->vPosition.x - v4->vPosition.x; - //v55 = abs(v50); - pMonsterName = (char *)(pParty->vPosition.y - v4->vPosition.y); - //v51 = (unsigned __int64 *)abs((int)pMonsterName); - pPlayerName = (char *)(pParty->vPosition.z - v4->vPosition.z); - v52 = abs((int)pPlayerName); - v61 = abs(v50); - v10 = abs(v50); - v11 = (int)abs((int)pMonsterName); - v12 = v52; - if ( v10 < v11) - { - v10 = (int)v11; - v11 = v10; - } - if ( v10 < v52 ) - { - v13 = v10; - v10 = v52; - v12 = v13; - } - if ( v11 < (signed int)v12 ) - { - v14 = v12; - v12 = v11; - v11 = v14; - } - //uPlayerID = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10; - v61 = ((unsigned int)(11 * v11) >> 5) + (v12 >> 2) + v10; - if ( v61 >= 2560 ) - { - if ( v61 >= 5120 && !(BYTE1(pMonster->uAttributes) & 4) ) - return; - v61 = 2; - } - else - { - v61 = 1; - } - //v4 = (SpriteObject *)uDamageAmount; - } - - v15 = v4->spell_id; - if ( v15 == SPELL_LASER_PROJECTILE ) - { - v16 = player->pActiveSkills[7]; - v61 = 1; - if ( (signed int)SkillToMastery(v16) >= 3 ) - a4 = player->pActiveSkills[7] & 0x3F; - a2 = 4; - uDamageAmount = player->CalculateMeleeDamageTo(1, 1, 0); - goto LABEL_67; - } - if ( v15 != SPELL_BOW_ARROW ) - { - if ( v15 == SPELL_101 ) - { - a2 = 0; - v18 = player->CalculateRangedDamageTo(0); - v19 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0; - v20 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0; - uDamageAmount = v18; - if ( !v20 && (!(v20 | v19) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) ) - uDamageAmount >>= 1; - v59 = 1; - goto LABEL_67; - } - if ( v15 == SPELL_EARTH_BLADES ) - { - a4 = 5 * v4->spell_level; - a2 = player->GetSpellSchool(0x27u); - v21 = v4->spell_level; - v50 = pMonster->sCurrentHP; - pMonsterName = (char *)v4->spell_skill; - v22 = _43AFE3_calc_spell_damage(39, v21, v4->spell_skill, v50); - v23 = HIDWORD(pMonster->pActorBuffs[15].uExpireTime) == 0; - v24 = SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) < 0; - uDamageAmount = v22; - if ( !v24 && (!(v24 | v23) || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) ) - uDamageAmount >>= 1; - v59 = 0; -LABEL_67: - if ( !stru_50C198.PlayerHitOrMiss(player, pMonster, v61, a4) ) - { -//LABEL_68: - player->PlaySound(SPEECH_52, 0); - return; - } - goto LABEL_69; - } - if ( v15 == SPELL_EARTH_STUN ) - { - uDamageAmount = 0; - a2 = 4; - hit_will_stun = 1; - goto LABEL_67; - } - a2 = player->GetSpellSchool(v4->spell_id); - v25 = v4->spell_level; - v26 = v4->spell_id; - v50 = pMonster->sCurrentHP; - pMonsterName = (char *)v4->spell_skill; - //v27 = _43AFE3_calc_spell_damage(v26, v25, (signed int)pMonsterName, v50); - v59 = 0; - //v57 = (PlayerEquipment *)1; -//LABEL_65: - uDamageAmount = _43AFE3_calc_spell_damage(v26, v25, v4->spell_skill, v50); - //if ( !v57 ) - // goto LABEL_67; - goto LABEL_69; - } - v50 = pMonster->word_000086_some_monster_id; - a2 = 4; - v17 = player->CalculateRangedDamageTo(v50); - v19 = v4->stru_24.uItemID == 0; - uDamageAmount = v17; - v57 = 0; - if ( !v19 && v4->stru_24.uSpecEnchantmentType == 3 ) - { - a2 = 0; - v57 = (PlayerEquipment *)1; - } - if ( SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) >= 0 - && (SHIDWORD(pMonster->pActorBuffs[15].uExpireTime) > 0 || LODWORD(pMonster->pActorBuffs[15].uExpireTime)) ) - uDamageAmount >>= 1; - v59 = 1; -//LABEL_66: - if ( !v57 ) - goto LABEL_67; -LABEL_69: - if (player->Weak()) - uDamageAmount /= 1; - if ( (signed __int64)pMonster->pActorBuffs[5].uExpireTime > 0 ) - uDamageAmount = 0; - v61 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, uDamageAmount); - if ( !v4 && player->IsUnarmed() && (signed __int64)player->pPlayerBuffs[6].uExpireTime > 0 ) - { - v50 = player->pPlayerBuffs[6].uPower; - v29 = stru_50C198.CalcMagicalDamageToActor(pMonster, 8, v50); - v61 += v29; - } - uDamageAmount = v61; - if ( v59 ) - { - if ( v4 ) - { - a4 = v4->stru_24._439DF3_get_additional_damage(&a2, &v62); - if ( v62 && pMonster->sCurrentHP > 0 ) - { - player->sHealth += v61 / 5; - if ( player->sHealth > player->GetMaxHealth() ) - player->sHealth = player->GetMaxHealth(); - v62 = 0; - } - v30 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4); - uDamageAmount = v61 + v30; - } - else - { - v59 = 0; - v57 = &player->pEquipment; - do - { - if ( player->HasItemEquipped((ITEM_EQUIP_TYPE)v59) ) - { - auto _s = (ItemGen *)&player->pInventoryItems[v57->uShield - 1]; - a4 = _s->_439DF3_get_additional_damage(&a2, &v62); - if ( v62 && pMonster->sCurrentHP > 0 ) - { - player->sHealth += v61 / 5; - if ( player->sHealth > player->GetMaxHealth() ) - player->sHealth = player->GetMaxHealth(); - v62 = 0; - } - v31 = stru_50C198.CalcMagicalDamageToActor(pMonster, a2, a4); - uDamageAmount += v31; - } - ++v59; - v57 = (PlayerEquipment *)((char *)v57 + 4); - } - while ( v59 <= 1 ); - } - } - v32 = uDamageAmount; - pMonster->sCurrentHP -= uDamageAmount; - if ( !v32 && !hit_will_stun ) - { - player->PlaySound(SPEECH_52, 0); - return; - } - if ( pMonster->sCurrentHP > 0 ) - { - Actor::AI_Stun(uActorID_Monster_, a1, 0); - Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); - if ( bShowDamage ) - { - v50 = uDamageAmount; - pMonsterName = (char *)pMonster; - pPlayerName = player->pName; - if ( v4 ) - v47 = pGlobalTXT_LocalizationStrings[189];// "%s shoots %s for %lu points" - else - v47 = pGlobalTXT_LocalizationStrings[164];// "%s hits %s for %lu damage" - sprintfex(pTmpBuf.data(), v47, pPlayerName, pMonsterName, v50); - ShowStatusBarString(pTmpBuf.data(), 2u); - } - v41 = 0; - } - else - { - if ( pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].bQuestMonster & 1 ) - { - v33 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * pMonster->uActorRadius : pMonster->uActorRadius; - //v55 = v33; - if ( pRenderer->pRenderD3D ) - { - if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) - { - v50 = 0; - pMonsterName = 0; - v34 = pMonster->vPosition.z; - *(float *)&pPlayerName = (double)v33; - //v51 = (unsigned __int64 *)v34; - *(float *)&v47 = 0.0; - v35 = pMonster->vPosition.y; - *((float *)&v46 + 1) = 0.0; - *(float *)&v46 = 1.0; - v36 = (double)(signed int)pMonster->vPosition.z; - //v51 = (unsigned __int64 *)v35; - v37 = v36; - //v51 = (unsigned __int64 *)pMonster->vPosition.x; - v38 = (double)v35; - v39 = (double)(signed int)pMonster->vPosition.x; - pDecalBuilder->AddBloodsplat(v39, v38, v37, 1.0, 0.0, 0.0, *(float *)&pPlayerName, 0, 0); - } - } - } - Actor::Die(uActorID_Monster_); - Actor::ApplyFineForKillingPeasant(uActorID_Monster_); - Actor::AggroSurroundingPeasants(uActorID_Monster_, 1); - if ( pMonster->pMonsterInfo.uExp ) - GivePartyExp(pMonsterStats->pInfos[pMonster->pMonsterInfo.uID].uExp); - v40 = SPEECH_51; - if ( rand() % 100 < 20 ) - v40 = ((signed int)pMonster->pMonsterInfo.uHP >= 100) + 1; - player->PlaySound((PlayerSpeech)v40, 0); - v41 = 0; - if ( bShowDamage ) - { - v50 = (int)pMonster; - pMonsterName = (char *)uDamageAmount; - pPlayerName = player->pName; // "%s inflicts %lu points killing %s" - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[175], player->pName, uDamageAmount, pMonster); - ShowStatusBarString(pTmpBuf.data(), 2u); - } - } - if ( SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) >= (signed int)v41 - && (SHIDWORD(pMonster->pActorBuffs[20].uExpireTime) > (signed int)v41 - || LODWORD(pMonster->pActorBuffs[20].uExpireTime) > v41) - && uDamageAmount != v41 ) - player->ReceiveDamage(uDamageAmount, (DAMAGE_TYPE)a2); - v50 = 24; - v59 = 20 * v61 / (signed int)pMonster->pMonsterInfo.uHP; - if ( (player->_48EA46_calc_special_bonus_by_items(24) || hit_will_stun != v41) - && stru_50C198.GetMagicalResistance(pMonster, 3u) ) - { - LODWORD(v42) = 20; - v59 = 10; - if ( pParty->bTurnBasedModeOn == v41 ) - v42 = (signed __int64)(flt_6BE3A8_debug_recmod2 * 42.66666666666666); - pMonster->pMonsterInfo.uRecoveryTime += v42; - if ( bShowDamage != v41 ) - { - v50 = (int)pMonster; - pMonsterName = player->pName; // "%s stuns %s" - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[635], player->pName, pMonster); - ShowStatusBarString(pTmpBuf.data(), 2u); - } - } - if ( hit_will_paralyze != v41 ) - { - if ( pMonster->CanAct() ) - { - if ( stru_50C198.GetMagicalResistance(pMonster, 3) ) - { - LOBYTE(v43) = player->GetActualSkillLevel(PLAYER_SKILL_MACE); - v44 = v43; - v45 = SkillToMastery(v43); - //v51 = (unsigned __int64 *)(7680 * (v44 & 0x3F)); - v46 = pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(7680 * (v44 & 0x3F)) * 0.033333335); - pMonster->pActorBuffs[6].Apply(v46, v45, 0, 0, 0); - if ( bShowDamage ) - { - v50 = (int)pMonster; - pMonsterName = player->pName; // "%s paralyzes %s" - sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[636], player->pName, pMonster); - ShowStatusBarString(pTmpBuf.data(), 2u); - } - } - } - } - if ( v59 > 10 ) - v59 = 10; - if ( !MonsterStats::BelongsToSupertype(pMonster->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) - { - pVelocity->x = (unsigned __int64)(v59 * (signed __int64)pVelocity->x) >> 16; - pVelocity->y = (unsigned __int64)(v59 * (signed __int64)pVelocity->y) >> 16; - pVelocity->z = (unsigned __int64)(v59 * (signed __int64)pVelocity->z) >> 16; - pMonster->vVelocity.x = 50 * LOWORD(pVelocity->x); - pMonster->vVelocity.y = 50 * LOWORD(pVelocity->y); - pMonster->vVelocity.z = 50 * LOWORD(pVelocity->z); - } - Actor::AddBloodsplatOnDamageOverlay(uActorID_Monster_, 1, v61); -} // 4D864C: using guessed type char byte_4D864C; -//----- (00439FCB) -------------------------------------------------------- -void __fastcall DamagePlayerFromMonster(unsigned int uObjID, int a2, Vec3_int_ *pPos, unsigned int a4) -{ - signed int v4; // esi@1 - unsigned int v5; // ecx@1 - Player *v6; // ebx@3 - Actor *v7; // esi@3 - unsigned int v8; // eax@4 - char *v9; // eax@5 - signed int v10; // eax@6 - int v11; // edx@8 - int v12; // edx@9 - int v13; // edx@10 - int v14; // edx@16 - int v15; // edx@17 - int v16; // edx@18 - enum SoundID v17; // eax@24 - int v18; // eax@26 - unsigned __int8 v19; // zf@26 - unsigned __int8 v20; // sf@26 - unsigned __int16 v21; // ax@29 - signed int v22; // edi@36 - int v23; // eax@38 - signed int v24; // eax@44 - unsigned __int16 v25; // cx@47 - signed int v26; // eax@49 - int v27; // eax@54 - float v28; // ST18_4@58 - double v29; // st7@58 - float v30; // ST08_4@58 - double v31; // st7@58 - float v32; // ST04_4@58 - float v33; // ST00_4@58 - int v34; // edi@61 - int v35; // eax@70 - double v36; // st7@70 - SpriteObject *v37; // ebx@77 - int v38; // edi@77 - int v39; // esi@77 - int v40; // eax@77 - int v41; // eax@77 - int v42; // eax@78 - Player *v43; // eax@81 - Actor *v44; // esi@82 - Player *v45; // edi@84 - unsigned __int16 v46; // ax@84 - int v47; // ebx@105 - int v48; // eax@107 - unsigned __int16 v49; // ax@116 - int v50; // ebx@123 - unsigned __int16 v51; // ax@124 - char v52; // bl@124 - int v53; // eax@128 - signed int v54; // eax@134 - unsigned __int16 v55; // cx@137 - signed int v56; // eax@139 - int v57; // eax@144 - float v58; // ST18_4@148 - double v59; // st7@148 - float v60; // ST08_4@148 - double v61; // st7@148 - float v62; // ST04_4@148 - float v63; // ST00_4@148 - int v64; // ebx@151 - int v65; // eax@161 - double v66; // st7@161 - signed int v67; // ecx@164 - signed int v68; // eax@170 - int v69; // ecx@170 - int v70; // eax@171 - enum SoundID v71; // [sp+20h] [bp-34h]@12 - int v72; // [sp+30h] [bp-24h]@164 - double v73; // [sp+40h] [bp-14h]@72 - signed int v74; // [sp+44h] [bp-10h]@1 - unsigned int v75; // [sp+48h] [bp-Ch]@3 - unsigned int uActorID; // [sp+4Ch] [bp-8h]@1 - int v77; // [sp+50h] [bp-4h]@26 - signed int a4a; // [sp+60h] [bp+Ch]@162 - Player *a4b; // [sp+60h] [bp+Ch]@168 - - v4 = PID_ID(uObjID); - v5 = PID_TYPE(uObjID) - 2; - v74 = a2; - uActorID = v4; - if ( v5 ) - { - if ( v5 != 1 - || (v6 = &pParty->pPlayers[a4], v7 = &pActors[v4], - v75 = v6->sHealth, - !stru_50C198.ActorHitOrMiss(v7, v6)) ) - return; - v8 = v6->pEquipment.uArmor; - if ( !v8 - || (v9 = (char *)v6 + 36 * v8, v9[516] & 2) - || (v10 = pItemsTable->pItems[*((int *)v9 + 124)].uSkillType, v10 < 10) - || v10 > 11 ) - { - v14 = rand() % 4; - if ( !v14 ) - { - v71 = (SoundID)108; - goto LABEL_24; - } - v15 = v14 - 1; - if ( !v15 ) - { - v71 = (SoundID)109; - goto LABEL_24; - } - v16 = v15 - 1; - if ( !v16 ) - { - v71 = (SoundID)110; - goto LABEL_24; - } - if ( v16 == 1 ) - { - v71 = (SoundID)44; - goto LABEL_24; - } - } - else - { - v11 = rand() % 4; - if ( !v11 ) - { - v71 = (SoundID)105; - goto LABEL_24; - } - v12 = v11 - 1; - if ( !v12 ) - { - v71 = (SoundID)106; - goto LABEL_24; - } - v13 = v12 - 1; - if ( !v13 ) - { - v71 = (SoundID)107; - goto LABEL_24; - } - if ( v13 == 1 ) - { - v71 = (SoundID)45; -LABEL_24: - v17 = v71; - goto LABEL_26; - } - } - v17 = (SoundID)a4; -LABEL_26: - pAudioPlayer->PlaySound(v17, PID(OBJECT_Player,a4 + 80), 0, -1, 0, 0, 0, 0); - v18 = Actor::_43B3E0_CalcDamage(v7, v74); - v19 = HIDWORD(v7->pActorBuffs[3].uExpireTime) == 0; - v20 = SHIDWORD(v7->pActorBuffs[3].uExpireTime) < 0; - v77 = v18; - if ( !v20 && (!(v20 | v19) || LODWORD(v7->pActorBuffs[3].uExpireTime) > 0) ) - { - v21 = v7->pActorBuffs[3].uPower; - if ( v21 ) - v77 /= (signed int)v21; - } - if ( v74 ) - { - if ( v74 == 1 ) - { - v22 = v7->pMonsterInfo.uAttack2Type; - } - else - { - if ( v74 == 2 ) - { - v23 = v7->pMonsterInfo.uSpell1ID; - } - else - { - if ( v74 != 3 ) - { - if ( v74 == 4 ) - v22 = v7->pMonsterInfo.field_3C_some_special_attack; - else - v22 = 4; - goto LABEL_43; - } - v23 = v7->pMonsterInfo.uSpell2ID; - } - v22 = LOBYTE(pSpellStats->pInfos[v23].uSchool); - } - } - else - { - v22 = v7->pMonsterInfo.uAttack1Type; - } -LABEL_43: - if ( !(dword_6BE368_debug_settings_2 & 0x10) ) - { - v24 = v6->ReceiveDamage(v77, (DAMAGE_TYPE)v22); - if ( SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) >= 0 - && (SHIDWORD(v6->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v6->pPlayerBuffs[10].uExpireTime)) ) - { - v25 = v7->uAIState; - if ( v25 != 5 ) - { - if ( v25 != 4 ) - { - v26 = stru_50C198.CalcMagicalDamageToActor(v7, v22, v24); - v7->sCurrentHP -= v26; - if ( v26 ) - { - if ( v7->sCurrentHP >= 1 ) - { - Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); - Actor::AggroSurroundingPeasants(uActorID, 1); - } - else - { - if ( pMonsterStats->pInfos[v7->pMonsterInfo.uID].bQuestMonster & 1 ) - { - v27 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v7->uActorRadius : v7->uActorRadius; - v74 = v27; - if ( pRenderer->pRenderD3D ) - { - if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) - { - v28 = (double)v74; - v74 = v7->vPosition.z; - v29 = (double)v74; - v74 = v7->vPosition.y; - v30 = v29; - v31 = (double)v74; - v74 = v7->vPosition.x; - v32 = v31; - v33 = (double)v74; - pDecalBuilder->AddBloodsplat(v33, v32, v30, 1.0, 0.0, 0.0, v28, 0, 0); - } - } - } - Actor::Die(uActorID); - Actor::ApplyFineForKillingPeasant(uActorID); - Actor::AggroSurroundingPeasants(uActorID, 1); - if ( v7->pMonsterInfo.uExp ) - GivePartyExp(pMonsterStats->pInfos[v7->pMonsterInfo.uID].uExp); - v34 = SPEECH_51; - if ( rand() % 100 < 20 ) - v34 = ((signed int)v7->pMonsterInfo.uHP >= 100) + 1; - v6->PlaySound((PlayerSpeech)v34, 0); - } - } - } - } - } - if ( !(dword_6BE368_debug_settings_2 & 0x10) - && v7->pMonsterInfo.uSpecialAttack - && rand() % 100 < v7->pMonsterInfo.uLevel * v7->pMonsterInfo.uSpecialAttackType ) - v6->_48DCF6(v7->pMonsterInfo.uSpecialAttack, v7); - } - if ( !pParty->bTurnBasedModeOn ) - { - v35 = v6->GetActualEndurance(); - v36 = (double)(20 - v6->GetParameterBonus(v35)) * flt_6BE3A4_debug_recmod1 * 2.133333333333333; - v6->SetRecoveryTime((signed __int64)v36); - } - if ( v77 ) - { - v73 = (double)(signed int)v75; - if ( (double)v6->GetMaxHealth() * 0.25 < v73 ) - { - if ( v6->sHealth > 0 ) - { - if ( (double)v6->GetMaxHealth() * 0.25 >= (double)v6->sHealth ) - v6->PlaySound(SPEECH_48, 0); - } - } - } - viewparams->bRedrawGameUI = 1; - return; - } - v37 = &pSpriteObjects[uActorID]; - v38 = PID_TYPE(v37->spell_caster_pid); - v39 = PID_ID(v37->spell_caster_pid); - v40 = PID_TYPE(v37->spell_caster_pid); - uActorID = PID_ID(v37->spell_caster_pid); - v41 = v40 - 2; - if ( !v41 ) - goto LABEL_80; - v42 = v41 - 1; - if ( !v42 ) - { - v44 = &pActors[v39]; - if ( a4 == -1 ) - a4 = stru_50C198.which_player_would_attack(v44); - v45 = &pParty->pPlayers[a4]; - v77 = Actor::_43B3E0_CalcDamage(v44, v74); - v46 = v37->uType; - if ( v37->uType == 545 ) - { - LOBYTE(v51) = v45->GetActualSkillLevel(PLAYER_SKILL_UNARMED); - v52 = v51; - if ( (signed int)SkillToMastery(v51) >= 4 && rand() % 100 < (v52 & 0x3F) ) - { - sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[637], v45->pName); - ShowStatusBarString(pTmpBuf.data(), 2u); - v45->PlaySound(SPEECH_6, 0); - return; - } - } - else - { - if ( v46 != 555 - && v46 != 510 - && v46 != 500 - && v46 != 515 - && v46 != 505 - && v46 != 530 - && v46 != 525 - && v46 != 520 - && v46 != 535 - && v46 != 540 ) - goto LABEL_115; - } - if ( !stru_50C198.ActorHitOrMiss(v44, v45) ) - return; - if ( (signed __int64)v45->pPlayerBuffs[13].uExpireTime > 0 ) - v77 >>= 1; - if ( v45->HasEnchantedItemEquipped(36) ) - v77 >>= 1; - if ( v45->HasEnchantedItemEquipped(69) ) - v77 >>= 1; - if ( v45->HasItemEquipped(EQUIP_ARMOUR) - && *(_DWORD *)&v45->pInventoryItems[v45->pEquipment.uArmor-1] == 504 ) - v77 >>= 1; - v75 = 0; - v47 = (int)&v45->pEquipment; - do - { - if ( v45->HasItemEquipped((ITEM_EQUIP_TYPE)v75) ) - { - v48 = *(int *)&v45[36 * *(int *)v47 + 496]; - if ( v48 == 520 ) - v77 >>= 1; - if ( v48 == 531 ) - v77 >>= 1; - if ( v45->GetEquippedItemEquipType((ITEM_EQUIP_TYPE)v75) == EQUIP_SHIELD && SkillToMastery(v45->pActiveSkills[PLAYER_SKILL_SHIELD]) == 4 ) - v77 >>= 1; - } - ++v75; - v47 += 4; - } - while ( (signed int)v75 <= 1 ); -LABEL_115: - if ( (signed __int64)v44->pActorBuffs[3].uExpireTime > 0 ) - { - v49 = v44->pActorBuffs[3].uPower; - if ( v49 ) - v77 /= (signed int)v49; - } - if ( !v74 ) - { - v50 = v44->pMonsterInfo.uAttack1Type; - goto LABEL_133; - } - if ( v74 == 1 ) - { - v50 = v44->pMonsterInfo.uAttack2Type; - goto LABEL_133; - } - if ( v74 == 2 ) - { - v53 = v44->pMonsterInfo.uSpell1ID; - } - else - { - if ( v74 != 3 ) - { - if ( v74 == 4 ) - v50 = v44->pMonsterInfo.field_3C_some_special_attack; - else - v50 = 4; -LABEL_133: - if ( !(dword_6BE368_debug_settings_2 & 0x10) ) - { - v54 = v45->ReceiveDamage(v77, (DAMAGE_TYPE)v50); - if ( SHIDWORD(v45->pPlayerBuffs[10].uExpireTime) >= 0 ) - { - if ( SHIDWORD(v45->pPlayerBuffs[10].uExpireTime) > 0 || LODWORD(v45->pPlayerBuffs[10].uExpireTime) ) - { - v55 = v44->uAIState; - if ( v55 != 5 ) - { - if ( v55 != 4 ) - { - v56 = stru_50C198.CalcMagicalDamageToActor(v44, v50, v54); - v44->sCurrentHP -= v56; - if ( v56 ) - { - if ( v44->sCurrentHP >= 1 ) - { - Actor::AI_Stun(uActorID, PID(OBJECT_Player,a4), 0); - Actor::AggroSurroundingPeasants(uActorID, 1); - } - else - { - if ( pMonsterStats->pInfos[v44->pMonsterInfo.uID].bQuestMonster & 1 ) - { - v57 = byte_4D864C && BYTE2(pGame->uFlags) & 8 ? 10 * v44->uActorRadius : v44->uActorRadius; - v75 = v57; - if ( pRenderer->pRenderD3D ) - { - if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS ) - { - v58 = (double)(signed int)v75; - v75 = v44->vPosition.z; - v59 = (double)(signed int)v75; - v75 = v44->vPosition.y; - v60 = v59; - v61 = (double)(signed int)v75; - v75 = v44->vPosition.x; - v62 = v61; - v63 = (double)(signed int)v75; - pDecalBuilder->AddBloodsplat(v63, v62, v60, 1.0, 0.0, 0.0, v58, 0, 0); - } - } - } - Actor::Die(uActorID); - Actor::ApplyFineForKillingPeasant(uActorID); - Actor::AggroSurroundingPeasants(uActorID, 1); - if ( v44->pMonsterInfo.uExp ) - GivePartyExp(pMonsterStats->pInfos[v44->pMonsterInfo.uID].uExp); - v64 = SPEECH_51; - if ( rand() % 100 < 20 ) - v64 = ((signed int)v44->pMonsterInfo.uHP >= 100) + 1; - v45->PlaySound((PlayerSpeech)v64, 0); - } - } - } - } - } - } - } - if ( !v74 - && !(dword_6BE368_debug_settings_2 & 0x10) - && v44->pMonsterInfo.uSpecialAttack - && rand() % 100 < v44->pMonsterInfo.uLevel * v44->pMonsterInfo.uSpecialAttackType ) - v45->_48DCF6(v44->pMonsterInfo.uSpecialAttack, v44); - if ( !pParty->bTurnBasedModeOn ) - { - v65 = v45->GetActualEndurance(); - v66 = (double)(20 - v45->GetParameterBonus(v65)) - * flt_6BE3A4_debug_recmod1 - * 2.133333333333333; - v45->SetRecoveryTime((signed __int64)v66); - } - return; - } - v53 = v44->pMonsterInfo.uSpell2ID; - } - v50 = LOBYTE(pSpellStats->pInfos[v53].uSchool); - goto LABEL_133; - } - if ( v42 != 1 ) - return; -LABEL_80: - if ( a4 != -1 ) - { - v43 = &pParty->pPlayers[a4]; -LABEL_168: - a4b = v43; - if ( v38 != OBJECT_Player || v37->spell_id != SPELL_BOW_ARROW) - { - v70 = v43->GetMaxHealth(); - v68 = _43AFE3_calc_spell_damage(v37->spell_id, v37->spell_level, v37->spell_skill, v70); - v69 = LOBYTE(pSpellStats->pInfos[v37->spell_id].uSchool); - } - else - { - v68 = pParty->pPlayers[uActorID].CalculateRangedDamageTo(0); - v69 = 0; - } - a4b->ReceiveDamage(v68, (DAMAGE_TYPE)v69); - if ( v38 == OBJECT_Player && !qword_A750D8 ) - { - qword_A750D8 = 256i64; - word_A750E0 = 44; - word_A750E2 = uActorID + 1; - } - return; - } - v74 = 0; - a4a = 1; - do - { - if ( pPlayers[a4a]->CanAct() ) - { - v67 = v74++; - *(&v72 + v67) = a4a; - } - ++a4a; - } - while ( a4a <= 4 ); - if ( v74 ) - { - v43 = &pParty->pPlayers[*(&v72+rand()%v74)-1];//&stru_AA1058[3].pSounds[6972 * *(&v72 + rand() % v74) + 40552]; - goto LABEL_168; - } -} - //----- (0043A97E) -------------------------------------------------------- void __fastcall sub_43A97E(unsigned int uLayingItemID, signed int a2) { @@ -5440,47 +4382,6 @@ return result; } -//----- (0043AFE3) -------------------------------------------------------- -int __fastcall _43AFE3_calc_spell_damage(int a1, int a2, signed int a3, int a4) -{ - int result; // eax@1 - unsigned int v5; // [sp-4h] [bp-8h]@9 - - result = 0; - if ( a1 == 7 ) - { - if ( a3 <= 0 ) - return result; - if ( a3 <= 2 ) - { - v5 = 6; - } - else - { - if ( a3 == 3 ) - { - v5 = 8; - } - else - { - if ( a3 != 4 ) - return result; - v5 = 10; - } - } - result = GetDiceResult(a2, v5); - } - else - { - if ( a1 == 44 ) - result = a4 * (LOBYTE(pSpellDatas[40].field_10) + 2 * a2) / 100; - else - result = *((char *)&pSpellDatas[0].field_10 + 20 * a1) - + GetDiceResult(a2, *((char *)&pSpellDatas[0].field_10 + 20 * a1 + 1)); - } - return result; -} - //----- (0043B057) -------------------------------------------------------- void __fastcall sub_43B057(unsigned int uObjID, unsigned int uActorID, Vec3_int_ *pVelocity) { @@ -5654,369 +4555,14 @@ } } -//----- (0043C91D) -------------------------------------------------------- -int __fastcall GetItemTextureFilename(char *pOut, signed int item_id, int index, int shoulder) -{ - int result; // eax@2 - char v5; // zf@3 - const char *v6; // [sp-Ch] [bp-18h]@88 - signed int v7; // [sp-8h] [bp-14h]@61 - int v8; // [sp-4h] [bp-10h]@61 - signed int v9; // [sp-4h] [bp-10h]@69 - - result = 0; //BUG fn is void - if ( item_id <= 500 ) - { - //v5 = *((char *)&pBloodsplatContainer->std__vector_pBloodsplats[62].field_20 + a2 + 2) == 0; - v5 = party_has_equipment[(item_id - 100) + 32 + 2] == 0; - switch ( item_id ) - { - case 516: - v5 = byte_5111F6[2] == 0; - break; - case 505: - v5 = byte_5111F6[1] == 0; - break; - case 504: - v5 = byte_5111F6[0] == 0; - break; - case 533: - v5 = byte_5111F6[16] == 0; - break; - case 512: - v5 = byte_5111F6[3] == 0; - break; - case 521: - v5 = byte_5111F6[4] == 0; - break; - case 522: - v5 = byte_5111F6[5] == 0; - break; - case 523: - v5 = byte_5111F6[6] == 0; - break; - case 532: - v5 = byte_5111F6[7] == 0; - break; - case 544: - v5 = byte_5111F6[8] == 0; - break; - case 524: - v5 = byte_5111F6[9] == 0; - break; - case 535: - v5 = byte_5111F6[10] == 0; - break; - case 525: - v5 = byte_5111F6[11] == 0; - break; - case 530: - v5 = byte_5111F6[12] == 0; - break; - case 547: - v5 = byte_5111F6[13] == 0; - break; - case 548: - v5 = byte_5111F6[14] == 0; - break; - case 550: - v5 = byte_5111F6[15] == 0; - break; - default: - break; - } - if ( v5 ) - return result; - result = 516; - if ( item_id < 66 || item_id > 78 ) - { - if ( item_id == 516 ) - { - if ( !shoulder ) - return sprintf(pOut, "item%3.3dv%d", 234, index); - if ( shoulder == 1 ) - return sprintf(pOut, "item%3.3dv%da1", 234, index); - if ( shoulder == 2 ) - return sprintf(pOut, "item%3.3dv%da2", 234, index); - } - if ( item_id != 504 && item_id != 505 && item_id != 533 ) - { - if ( (item_id < 100 || item_id > 104) && item_id != 524 && item_id != 535 ) - { - if ( item_id >= 115 && item_id <= 119 || item_id == 512 ) - { - if ( item_id == 512 ) - item_id = 312; - return sprintf(pOut, "item%3.3dv%d", item_id, index); - } - if ( (item_id < 89 || item_id > 99) && item_id != 521 && item_id != 522 && item_id != 523 && item_id != 532 && item_id != 544 ) - { - result = 525; - if ( (item_id < 105 || item_id > 109) && item_id != 525 && item_id != 530 && item_id != 547 && item_id != 548 && item_id != 550 ) - return result; - switch ( item_id ) - { - case 525: - item_id = 325; - break; - case 530: - item_id = 330; - break; - case 547: - item_id = 347; - break; - case 548: - item_id = 348; - break; - case 550: - item_id = 350; - break; - } - if ( !shoulder ) - return sprintf(pOut, "item%3.3dv%d", item_id, index); - return sprintf(pOut, "item%3.3dv%da1", item_id, index); - } - if ( item_id == 521 ) - return sprintf(pOut, "item%3.3dv%d", 239, index); - if ( item_id == 522 ) - return sprintf(pOut, "item%3.3dv%d", 240, index); - if ( item_id == 523 ) - return sprintf(pOut, "item%3.3dv%d", 241, index); - if ( item_id != 532 ) - { - if ( item_id == 544 ) - item_id = 344; - return sprintf(pOut, "item%3.3dv%d", item_id, index); - } - return sprintf(pOut, "item%3.3dv%d", 93, index); - } - if ( item_id == 524 ) - return sprintf(pOut, "item%3.3dv%d", 324, index); - if ( item_id == 535 ) - item_id = 104; - return sprintf(pOut, "item%3.3dv%d", item_id, index); - } - } - if ( item_id != 516 ) - { - switch ( item_id ) - { - case 504: - item_id = 235; - break; - case 505: - item_id = 236; - break; - case 533: - item_id = 73; - break; - } - if ( !shoulder ) - return sprintf(pOut, "item%3.3dv%d", item_id, index); - if ( shoulder == 1 ) - return sprintf(pOut, "item%3.3dv%da1", item_id, index); - if ( shoulder == 2 ) - return sprintf(pOut, "item%3.3dv%da2", item_id, index); - } - if ( !shoulder ) - return sprintf(pOut, "item%3.3dv%d", 234, index); - if ( shoulder == 1 ) - return sprintf(pOut, "item%3.3dv%da1", 234, index); - if ( shoulder == 2 ) - return sprintf(pOut, "item%3.3dv%da2", 234, index); - } - result = item_id - 504; - return result; -} - -//----- (0043ED6F) -------------------------------------------------------- -bool _43ED6F_check_party_races(bool a1) -{ - bool v6; // zf@5 - - for (uint i = 0; i < 4; ++i) - { - auto player = pParty->pPlayers + i; - auto race = player->GetRace(); - - if (race != CHARACTER_RACE_HUMAN && - race != CHARACTER_RACE_ELF && - race != CHARACTER_RACE_GOBLIN) - v6 = a1 == 1; - else - v6 = !a1; - - if (v6) - return true; - } - return false; -} +// A750D8: using guessed type __int64 qword_A750D8; + + // A750D8: using guessed type __int64 qword_A750D8; -//----- (0043EDB9) -------------------------------------------------------- -bool __thiscall sub_43EDB9_get_some_race_sex_relation_2(unsigned int a1) -{ - unsigned int pNum; // ebp@1 - Player **pPlayer; // ebx@1 - Player *pPlayer2; // esi@2 - enum CHARACTER_RACE pRace; // edi@2 - bool pSex; // eax@2 - char v6; // zf@7 - -//pPlayer = &pPlayers[1]; - /*pNum = a1; - - while ( 1 ) - { - pPlayer2 = *pPlayer; - pRace = pPlayer2->GetRace(); - pSex = pPlayer2->GetSexByVoice(); - if ( !pRace ) - break; - if ( pRace == 1 || pRace == 2 ) - break; - if ( !pSex && pNum == 2 )// - //goto LABEL_15; - { - pSex = 1; - return pSex; - } - v6 = pNum == 3;// -LABEL_11: - if ( v6 ) - //goto LABEL_15; - { - pSex = 1; - return pSex; - } - ++pPlayer; - if ( (signed int)pPlayer >= (signed int)&qword_A750D8 )// - { - pSex = 0; - return pSex; - } - } - if ( pSex || pNum ) - { - v6 = pNum == 1; - goto LABEL_11; - } -//LABEL_15: - pSex = 1; - return pSex;*/ - for (uint i = 1; i <= 4; ++i) - { - pRace = pPlayers[i]->GetRace(); - pSex = pPlayers[i]->GetSexByVoice(); - if (pRace == 0 || pRace == 1 || pRace == 2 || pSex == 0 ) - return 1; - } - return 0; -} + // A750D8: using guessed type __int64 qword_A750D8; -//----- (0043EE15) -------------------------------------------------------- -bool __fastcall Player_has_item(unsigned int uItemID, Player *pPlayer, char a3) -{ - if ( !a3 || pParty->pPickedItem.uItemID != uItemID ) - { - for ( uint i = 0; i < 126; ++i ) - { - if ( pPlayer->pInventoryIndices[i] > 0 ) - { - if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pInventoryIndices[i] - 1].uItemID == uItemID ) - return true; - } - } - for ( uint i = 0; i < 16; ++i ) - { - if ( pPlayer->pEquipment.pIndices[i] ) - { - if ( (unsigned int)pPlayer->pInventoryItems[pPlayer->pEquipment.pIndices[i] - 1].uItemID == uItemID ) - return true; - } - } - } - return false; -} - -//----- (0043EE77) -------------------------------------------------------- -bool __fastcall sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(signed int a1) -{ - bool result; // eax@0 - Player *v2; // edx@3 - int v3; // ecx@3 - Player **pPlayers; // esi@8 - unsigned int v5; // ecx@8 - Player *v6; // edx@9 - - if ( a1 < 1 || a1 > 4 ) - { - if ( !a1 ) - { - pPlayers = &::pPlayers[1]; - v5 = 604; - while ( 1 ) - { - result = Player_has_item(v5, *pPlayers, 0); - if ( !result ) - break; - result = v6->pEquipment.uArmor; - if ( !result ) - break; - result *= 9; - if ( *(int *)&v6->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v5 ) - break; - ++pPlayers; - if ( (signed int)pPlayers >= (signed int)&qword_A750D8 ) - goto LABEL_13; - } - } - goto LABEL_6; - } - result = Player_has_item(604u, ::pPlayers[a1], 0); - if ( !result - || (result = v2->pEquipment.uArmor) == 0 - || (result *= 9, *(int *)&v2->spellbook.pDarkSpellbook.bIsSpellAvailable[4 * result + 5] != v3) ) - { -LABEL_6: - LOBYTE(result) = 0; - return result; - } -LABEL_13: - LOBYTE(result) = 1; - return result; -} -// A750D8: using guessed type __int64 qword_A750D8; - - -//----- (0043F333) -------------------------------------------------------- -void BspRenderer::MakeVisibleSectorList() -{ - int v6; // ebx@3 - - uNumVisibleNotEmptySectors = 0; - for (uint i = 0; i < num_nodes; ++i) - { - if (!uNumVisibleNotEmptySectors) - { - pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID; - continue; - } - - v6 = 0; - while (pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[v6] != nodes[i].uSectorID ) - { - ++v6; - if ( v6 >= uNumVisibleNotEmptySectors) - { - pVisibleSectorIDs_toDrawDecorsActorsEtcFrom[uNumVisibleNotEmptySectors++] = nodes[i].uSectorID; - } - } - - } -} - //----- (0043F515) -------------------------------------------------------- void FindBillboardsLightLevels_BLV() { @@ -8061,835 +6607,6 @@ return result; } -//----- (00407A1C) -------------------------------------------------------- -bool __fastcall sub_407A1C(int x, int z, int y, Vec3_int_ v) -{ - unsigned int v4; // esi@1 - Vec3_int_ v5; // ST08_12@2 - int v6; // edi@2 - int v7; // ebx@2 - int v8; // esi@2 - signed int v9; // ecx@2 - int v10; // eax@2 - int v11; // ecx@4 - int v12; // eax@4 - int v13; // ebx@4 - int v14; // edx@6 - char *v15; // edi@16 - ODMFace *v16; // esi@19 - int v17; // ST34_4@25 - int v18; // ST38_4@25 - int v19; // eax@25 - char v20; // zf@25 - int v21; // ebx@25 - int v22; // eax@26 - signed int v23; // edi@26 - int v24; // ST34_4@30 - signed __int64 v25; // qtt@31 - int v26; // eax@31 - Vec3_int_ v27; // ST08_12@37 - Vec3_int_ v28; // ST08_12@37 - int v29; // edi@37 - int v30; // ebx@37 - int v31; // esi@37 - signed int v32; // ecx@37 - int v33; // eax@37 - int v34; // ecx@39 - int v35; // eax@39 - int v36; // ebx@39 - int v37; // edx@41 - char *v38; // edi@51 - ODMFace *v39; // esi@54 - int v40; // ebx@60 - int v41; // eax@61 - signed int v42; // edi@61 - signed __int64 v43; // qtt@66 - int v44; // eax@66 - Vec3_int_ v45; // ST08_12@73 - int v46; // edi@73 - int v47; // ebx@73 - int v48; // esi@73 - signed int v49; // ecx@73 - int v50; // eax@73 - int v51; // edx@75 - int v52; // ecx@75 - int v53; // eax@75 - int v54; // ebx@75 - int v55; // edi@77 - int v56; // ecx@77 - int v57; // eax@81 - int v58; // esi@81 - int v59; // eax@90 - BLVSector *v60; // edx@90 - int v61; // ecx@90 - BLVFace *v62; // esi@91 - int v63; // ST34_4@98 - int v64; // ST30_4@98 - int v65; // eax@98 - int v66; // ebx@98 - int v67; // eax@99 - signed int v68; // edi@99 - int v69; // ST2C_4@103 - signed __int64 v70; // qtt@104 - int v71; // eax@104 - Vec3_int_ v72; // ST08_12@111 - Vec3_int_ v73; // ST08_12@111 - int v74; // edi@111 - int v75; // ebx@111 - int v76; // esi@111 - signed int v77; // ecx@111 - int v78; // eax@111 - int v79; // edx@113 - int v80; // ecx@113 - int v81; // eax@113 - int v82; // ebx@113 - int v83; // edi@115 - int v84; // ecx@115 - int v85; // eax@119 - int v86; // esi@119 - int v87; // ecx@128 - BLVSector *v88; // eax@128 - int v89; // ecx@128 - BLVFace *v90; // esi@129 - int v91; // ebx@136 - int v92; // eax@137 - signed int v93; // edi@137 - signed __int64 v94; // qtt@142 - int v95; // eax@142 - Vec3_int_ v97; // [sp-18h] [bp-94h]@1 - int v98; // [sp-Ch] [bp-88h]@88 - int v99; // [sp-Ch] [bp-88h]@126 - int v100; // [sp-8h] [bp-84h]@88 - int v101; // [sp-8h] [bp-84h]@126 - int v102; // [sp-4h] [bp-80h]@88 - int v103; // [sp-4h] [bp-80h]@126 - int v104; // [sp+Ch] [bp-70h]@13 - int v105; // [sp+Ch] [bp-70h]@48 - int v106; // [sp+10h] [bp-6Ch]@18 - int v107; // [sp+10h] [bp-6Ch]@98 - int v108; // [sp+10h] [bp-6Ch]@104 - int v109; // [sp+18h] [bp-64h]@25 - int v110; // [sp+18h] [bp-64h]@31 - int i; // [sp+18h] [bp-64h]@90 - int v112; // [sp+18h] [bp-64h]@128 - signed int v113; // [sp+20h] [bp-5Ch]@1 - signed int v114; // [sp+24h] [bp-58h]@1 - unsigned __int64 a4; // [sp+28h] [bp-54h]@1 - unsigned int a4_8; // [sp+30h] [bp-4Ch]@1 - int v117; // [sp+34h] [bp-48h]@4 - int v118; // [sp+34h] [bp-48h]@39 - int v119; // [sp+34h] [bp-48h]@75 - int v120; // [sp+34h] [bp-48h]@113 - int v121; // [sp+38h] [bp-44h]@4 - int v122; // [sp+38h] [bp-44h]@39 - int v123; // [sp+38h] [bp-44h]@76 - int v124; // [sp+38h] [bp-44h]@114 - int v125; // [sp+3Ch] [bp-40h]@4 - int v126; // [sp+3Ch] [bp-40h]@39 - int v127; // [sp+3Ch] [bp-40h]@77 - int v128; // [sp+3Ch] [bp-40h]@115 - int v129; // [sp+40h] [bp-3Ch]@11 - int v130; // [sp+40h] [bp-3Ch]@46 - int v131; // [sp+40h] [bp-3Ch]@78 - int v132; // [sp+40h] [bp-3Ch]@116 - int v133; // [sp+44h] [bp-38h]@10 - int v134; // [sp+44h] [bp-38h]@45 - int v135; // [sp+44h] [bp-38h]@81 - int v136; // [sp+44h] [bp-38h]@119 - int v137; // [sp+48h] [bp-34h]@7 - int v138; // [sp+48h] [bp-34h]@42 - int v139; // [sp+48h] [bp-34h]@82 - int v140; // [sp+48h] [bp-34h]@120 - int v141; // [sp+4Ch] [bp-30h]@6 - int v142; // [sp+4Ch] [bp-30h]@41 - int v143; // [sp+4Ch] [bp-30h]@75 - int v144; // [sp+4Ch] [bp-30h]@113 - int v145; // [sp+50h] [bp-2Ch]@5 - int v146; // [sp+50h] [bp-2Ch]@40 - int v147; // [sp+50h] [bp-2Ch]@75 - int v148; // [sp+50h] [bp-2Ch]@113 - int v149; // [sp+54h] [bp-28h]@4 - int v150; // [sp+54h] [bp-28h]@39 - int v151; // [sp+54h] [bp-28h]@75 - int v152; // [sp+54h] [bp-28h]@113 - int sDepth; // [sp+58h] [bp-24h]@17 - int sDeptha; // [sp+58h] [bp-24h]@52 - int sDepthb; // [sp+58h] [bp-24h]@90 - char *a5; // [sp+5Ch] [bp-20h]@16 - char *a5a; // [sp+5Ch] [bp-20h]@51 - signed int a5b; // [sp+5Ch] [bp-20h]@83 - signed int a5c; // [sp+5Ch] [bp-20h]@121 - signed int v160; // [sp+60h] [bp-1Ch]@12 - signed int v161; // [sp+60h] [bp-1Ch]@47 - int v162; // [sp+60h] [bp-1Ch]@128 - int v163; // [sp+64h] [bp-18h]@2 - int outx; // [sp+68h] [bp-14h]@2 - int outy; // [sp+6Ch] [bp-10h]@2 - int outz; // [sp+70h] [bp-Ch]@2 - Vec3_int_ pOut; // [sp+74h] [bp-8h]@2 - int ya; // [sp+84h] [bp+8h]@60 - int yb; // [sp+84h] [bp+8h]@136 - int ve; // [sp+88h] [bp+Ch]@60 - int va; // [sp+88h] [bp+Ch]@60 - int vb; // [sp+88h] [bp+Ch]@66 - int vf; // [sp+88h] [bp+Ch]@136 - int vc; // [sp+88h] [bp+Ch]@136 - int vd; // [sp+88h] [bp+Ch]@142 - int v_4; // [sp+8Ch] [bp+10h]@60 - int v_4a; // [sp+8Ch] [bp+10h]@65 - int v_4b; // [sp+8Ch] [bp+10h]@136 - int v_4c; // [sp+8Ch] [bp+10h]@141 - int v_8; // [sp+90h] [bp+14h]@53 - - a4 = __PAIR__(z, x); - v4 = stru_5C6E00->Atan2(v.x - x, v.y - z); - v114 = 0; - v97.z = y; - v113 = 0; - a4_8 = v4; - *(_QWORD *)&v97.x = a4; - if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor) - { - Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz); - v45.z = v.z; - *(_QWORD *)&v45.x = *(_QWORD *)&v; - Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v45, &outx, &outy, &v163); - v46 = outy - pOut.y; - v47 = v163 - outz; - v48 = outx - pOut.x; - v49 = integer_sqrt(v48 * v48 + v46 * v46 + v47 * v47); - v50 = 65536; - if ( v49 ) - v50 = 65536 / v49; - v51 = outx; - v143 = v48 * v50; - v52 = v46 * v50; - v53 = v47 * v50; - v54 = pOut.x; - v147 = v52; - v151 = v53; - v119 = pOut.x; - if ( pOut.x < outx ) - { - v123 = outx; - } - else - { - v119 = outx; - v123 = pOut.x; - } - v55 = pOut.y; - v56 = outy; - v127 = pOut.y; - if ( pOut.y < outy ) - { - v131 = outy; - } - else - { - v127 = outy; - v131 = pOut.y; - } - v57 = v163; - v58 = outz; - v135 = outz; - if ( outz < v163 ) - { - v139 = v163; - } - else - { - v135 = v163; - v139 = outz; - } - a5b = 0; - while ( !v114 ) - { - if ( a5b ) - { - v102 = v58; - v100 = v55; - v98 = v54; - } - else - { - v102 = v57; - v100 = v56; - v98 = v51; - } - v59 = pIndoor->GetSector(v98, v100, v102); - v60 = pIndoor->pSectors; - v61 = 116 * v59; - sDepthb = 0; - for ( i = 116 * v59; - sDepthb < *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v61) - + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v61); - ++sDepthb ) - { - v62 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v60->pWalls + v61))[sDepthb]]; - if ( v62->Portal() - || v119 > v62->pBounding.x2 - || v123 < v62->pBounding.x1 - || v127 > v62->pBounding.y2 - || v131 < v62->pBounding.y1 - || v135 > v62->pBounding.z2 - || v139 < v62->pBounding.z1 - || (v63 = (unsigned __int64)(v143 * (signed __int64)v62->pFacePlane_old.vNormal.x) >> 16, - v64 = (unsigned __int64)(v151 * (signed __int64)v62->pFacePlane_old.vNormal.z) >> 16, - v65 = (unsigned __int64)(v147 * (signed __int64)v62->pFacePlane_old.vNormal.y) >> 16, - v20 = v63 + v64 + v65 == 0, - v66 = v63 + v64 + v65, - v107 = v63 + v64 + v65, - v20) ) - goto LABEL_107; - v67 = outz * v62->pFacePlane_old.vNormal.z; - v68 = -(v62->pFacePlane_old.dist - + v67 - + pOut.y * v62->pFacePlane_old.vNormal.y - + pOut.x * v62->pFacePlane_old.vNormal.x); - if ( v66 <= 0 ) - { - if ( v62->pFacePlane_old.dist - + v67 - + pOut.y * v62->pFacePlane_old.vNormal.y - + pOut.x * v62->pFacePlane_old.vNormal.x < 0 ) - goto LABEL_107; - } - else - { - if ( v62->pFacePlane_old.dist - + v67 - + pOut.y * v62->pFacePlane_old.vNormal.y - + pOut.x * v62->pFacePlane_old.vNormal.x > 0 ) - goto LABEL_107; - } - v69 = abs(-(v62->pFacePlane_old.dist - + v67 - + pOut.y * v62->pFacePlane_old.vNormal.y - + pOut.x * v62->pFacePlane_old.vNormal.x)) >> 14; - if ( v69 <= abs(v66) ) - { - LODWORD(v70) = v68 << 16; - HIDWORD(v70) = v68 >> 16; - v71 = v70 / v107; - v108 = v70 / v107; - if ( v71 >= 0 ) - { - if ( sub_4075DB( - pOut.x + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v143) >> 16) + 32768) >> 16), - pOut.y + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v147) >> 16) + 32768) >> 16), - outz + ((signed int)(((unsigned __int64)(v108 * (signed __int64)v151) >> 16) + 32768) >> 16), - v62) ) - { - v114 = 1; - break; - } - } - } - v61 = i; -LABEL_107: - v60 = pIndoor->pSectors; - } - ++a5b; - if ( a5b >= 2 ) - break; - v57 = v163; - v56 = outy; - v51 = outx; - v58 = outz; - v55 = pOut.y; - v54 = pOut.x; - } - v72.z = y; - *(_QWORD *)&v72.x = a4; - Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v72, &pOut.x, &pOut.y, &outz); - v73.z = v.z; - *(_QWORD *)&v73.x = *(_QWORD *)&v; - Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v73, &outx, &outy, &v163); - v74 = outy - pOut.y; - v75 = v163 - outz; - v76 = outx - pOut.x; - v77 = integer_sqrt(v76 * v76 + v74 * v74 + v75 * v75); - v78 = 65536; - if ( v77 ) - v78 = 65536 / v77; - v79 = outx; - v144 = v76 * v78; - v80 = v74 * v78; - v81 = v75 * v78; - v82 = pOut.x; - v148 = v80; - v152 = v81; - v120 = pOut.x; - if ( pOut.x < outx ) - { - v124 = outx; - } - else - { - v120 = outx; - v124 = pOut.x; - } - v83 = pOut.y; - v84 = outy; - v128 = pOut.y; - if ( pOut.y < outy ) - { - v132 = outy; - } - else - { - v128 = outy; - v132 = pOut.y; - } - v85 = v163; - v86 = outz; - v136 = outz; - if ( outz < v163 ) - { - v140 = v163; - } - else - { - v136 = v163; - v140 = outz; - } - a5c = 0; - while ( 1 ) - { - if ( v113 ) - return !v114 || !v113; - if ( a5c ) - { - v103 = v86; - v101 = v83; - v99 = v82; - } - else - { - v103 = v85; - v101 = v84; - v99 = v79; - } - v87 = pIndoor->GetSector(v99, v101, v103); - v88 = pIndoor->pSectors; - v89 = 116 * v87; - v162 = 0; - v112 = v89; - if ( *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89) - + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) > 0 ) - break; -LABEL_148: - ++a5c; - if ( a5c >= 2 ) - return !v114 || !v113; - v85 = v163; - v84 = outy; - v79 = outx; - v86 = outz; - v83 = pOut.y; - v82 = pOut.x; - } - while ( 1 ) - { - v90 = &pIndoor->pFaces[(*(unsigned __int16 **)((char *)&v88->pWalls + v89))[v162]]; - if ( v90->Portal() - || v120 > v90->pBounding.x2 - || v124 < v90->pBounding.x1 - || v128 > v90->pBounding.y2 - || v132 < v90->pBounding.y1 - || v136 > v90->pBounding.z2 - || v140 < v90->pBounding.z1 - || (yb = (unsigned __int64)(v144 * (signed __int64)v90->pFacePlane_old.vNormal.x) >> 16, - v_4b = (unsigned __int64)(v148 * (signed __int64)v90->pFacePlane_old.vNormal.y) >> 16, - vf = (unsigned __int64)(v152 * (signed __int64)v90->pFacePlane_old.vNormal.z) >> 16, - v20 = yb + vf + v_4b == 0, - v91 = yb + vf + v_4b, - vc = yb + vf + v_4b, - v20) ) - goto LABEL_145; - v92 = outz * v90->pFacePlane_old.vNormal.z; - v93 = -(v90->pFacePlane_old.dist - + v92 - + pOut.y * v90->pFacePlane_old.vNormal.y - + pOut.x * v90->pFacePlane_old.vNormal.x); - if ( v91 <= 0 ) - { - if ( v90->pFacePlane_old.dist - + v92 - + pOut.y * v90->pFacePlane_old.vNormal.y - + pOut.x * v90->pFacePlane_old.vNormal.x < 0 ) - goto LABEL_145; - } - else - { - if ( v90->pFacePlane_old.dist - + v92 - + pOut.y * v90->pFacePlane_old.vNormal.y - + pOut.x * v90->pFacePlane_old.vNormal.x > 0 ) - goto LABEL_145; - } - v_4c = abs(-(v90->pFacePlane_old.dist - + v92 - + pOut.y * v90->pFacePlane_old.vNormal.y - + pOut.x * v90->pFacePlane_old.vNormal.x)) >> 14; - if ( v_4c <= abs(v91) ) - { - LODWORD(v94) = v93 << 16; - HIDWORD(v94) = v93 >> 16; - v95 = v94 / vc; - vd = v94 / vc; - if ( v95 >= 0 ) - { - if ( sub_4075DB( - pOut.x + ((signed int)(((unsigned __int64)(vd * (signed __int64)v144) >> 16) + 32768) >> 16), - pOut.y + ((signed int)(((unsigned __int64)(vd * (signed __int64)v148) >> 16) + 32768) >> 16), - outz + ((signed int)(((unsigned __int64)(vd * (signed __int64)v152) >> 16) + 32768) >> 16), - v90) ) - { - v113 = 1; - goto LABEL_148; - } - } - } - v89 = v112; -LABEL_145: - v88 = pIndoor->pSectors; - ++v162; - if ( v162 >= *(__int16 *)((char *)&pIndoor->pSectors->uNumWalls + v89) - + 2 * *(__int16 *)((char *)&pIndoor->pSectors->uNumFloors + v89) ) - goto LABEL_148; - } - } - Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v97, &pOut.x, &pOut.y, &outz); - v5.z = v.z; - *(_QWORD *)&v5.x = *(_QWORD *)&v; - Vec3_int_::Rotate(32, stru_5C6E00->uIntegerHalfPi + v4, 0, v5, &outx, &outy, &v163); - v6 = outy - pOut.y; - v7 = v163 - outz; - v8 = outx - pOut.x; - v9 = integer_sqrt(v8 * v8 + v6 * v6 + v7 * v7); - v10 = 65536; - if ( v9 ) - v10 = 65536 / v9; - v125 = v8 * v10; - v11 = v10; - v12 = v7 * v10; - v13 = pOut.x; - v117 = v12; - v121 = v6 * v11; - v149 = pOut.x; - if ( pOut.x < outx ) - { - v145 = outx; - } - else - { - v149 = outx; - v145 = pOut.x; - } - v14 = outy; - v141 = pOut.y; - if ( pOut.y < outy ) - { - v137 = outy; - } - else - { - v141 = outy; - v137 = pOut.y; - } - v133 = outz; - if ( outz < v163 ) - { - v129 = v163; - } - else - { - v133 = v163; - v129 = outz; - } - v160 = 0; - if ( (signed int)pOutdoor->uNumBModels > 0 ) - { - v104 = 0; - while ( 1 ) - { - v15 = (char *)&pOutdoor->pBModels[v104].pVertices; - a5 = (char *)&pOutdoor->pBModels[v104].pVertices; - if ( sub_4088E9(v13, pOut.y, outx, v14, pOutdoor->pBModels[v104].vPosition.x, pOutdoor->pBModels[v104].vPosition.y) <= pOutdoor->pBModels[v104].sBoundingRadius + 128 ) - { - sDepth = 0; - if ( *((int *)v15 + 2) > 0 ) - break; - } -LABEL_36: - ++v160; - ++v104; - if ( v160 >= (signed int)pOutdoor->uNumBModels ) - goto LABEL_37; - v14 = outy; - v13 = pOut.x; - } - v106 = 0; - while ( 1 ) - { - v16 = (ODMFace *)(v106 + *((int *)a5 + 4)); - if ( v149 > v16->pBoundingBox.x2 - || v145 < v16->pBoundingBox.x1 - || v141 > v16->pBoundingBox.y2 - || v137 < v16->pBoundingBox.y1 - || v133 > v16->pBoundingBox.z2 - || v129 < v16->pBoundingBox.z1 - || (v17 = (unsigned __int64)(v125 * (signed __int64)v16->pFacePlane.vNormal.x) >> 16, - v18 = (unsigned __int64)(v121 * (signed __int64)v16->pFacePlane.vNormal.y) >> 16, - v19 = (unsigned __int64)(v117 * (signed __int64)v16->pFacePlane.vNormal.z) >> 16, - v20 = v17 + v18 + v19 == 0, - v21 = v17 + v18 + v19, - v109 = v17 + v18 + v19, - v20) ) - goto LABEL_33; - v22 = pOut.y * v16->pFacePlane.vNormal.y; - v23 = -(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x); - if ( v21 <= 0 ) - { - if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x < 0 ) - goto LABEL_33; - } - else - { - if ( v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x > 0 ) - goto LABEL_33; - } - v24 = abs(-(v16->pFacePlane.dist + v22 + outz * v16->pFacePlane.vNormal.z + pOut.x * v16->pFacePlane.vNormal.x)) >> 14; - if ( v24 <= abs(v21) ) - { - LODWORD(v25) = v23 << 16; - HIDWORD(v25) = v23 >> 16; - v26 = v25 / v109; - v110 = v25 / v109; - if ( v26 >= 0 ) - { - if ( sub_4077F1( - pOut.x + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v125) >> 16) + 32768) >> 16), - pOut.y + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v121) >> 16) + 32768) >> 16), - outz + ((signed int)(((unsigned __int64)(v110 * (signed __int64)v117) >> 16) + 32768) >> 16), - v16, - (BSPVertexBuffer *)a5) ) - { - v114 = 1; - goto LABEL_36; - } - } - } -LABEL_33: - ++sDepth; - v106 += 308; - if ( sDepth >= *((int *)a5 + 2) ) - goto LABEL_36; - } - } -LABEL_37: - v27.z = y; - *(_QWORD *)&v27.x = a4; - Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v27, &pOut.x, &pOut.y, &outz); - v28.z = v.z; - *(_QWORD *)&v28.x = *(_QWORD *)&v; - Vec3_int_::Rotate(32, a4_8 - stru_5C6E00->uIntegerHalfPi, 0, v28, &outx, &outy, &v163); - v29 = outy - pOut.y; - v30 = v163 - outz; - v31 = outx - pOut.x; - v32 = integer_sqrt(v31 * v31 + v29 * v29 + v30 * v30); - v33 = 65536; - if ( v32 ) - v33 = 65536 / v32; - v126 = v31 * v33; - v34 = v33; - v35 = v30 * v33; - v36 = pOut.x; - v118 = v35; - v122 = v29 * v34; - v150 = pOut.x; - if ( pOut.x < outx ) - { - v146 = outx; - } - else - { - v150 = outx; - v146 = pOut.x; - } - v37 = outy; - v142 = pOut.y; - if ( pOut.y < outy ) - { - v138 = outy; - } - else - { - v142 = outy; - v138 = pOut.y; - } - v134 = outz; - if ( outz < v163 ) - { - v130 = v163; - } - else - { - v134 = v163; - v130 = outz; - } - v161 = 0; - if ( (signed int)pOutdoor->uNumBModels > 0 ) - { - v105 = 0; - while ( 1 ) - { - v38 = (char *)&pOutdoor->pBModels[v105].pVertices; - a5a = (char *)&pOutdoor->pBModels[v105].pVertices; - if ( sub_4088E9(v36, pOut.y, outx, v37, pOutdoor->pBModels[v105].vPosition.x, pOutdoor->pBModels[v105].vPosition.y) <= pOutdoor->pBModels[v105].sBoundingRadius + 128 ) - { - sDeptha = 0; - if ( *((int *)v38 + 2) > 0 ) - break; - } -LABEL_71: - ++v161; - ++v105; - if ( v161 >= (signed int)pOutdoor->uNumBModels ) - return !v114 || !v113; - v37 = outy; - v36 = pOut.x; - } - v_8 = 0; - while ( 1 ) - { - v39 = (ODMFace *)(v_8 + *((int *)a5a + 4)); - if ( v150 > v39->pBoundingBox.x2 - || v146 < v39->pBoundingBox.x1 - || v142 > v39->pBoundingBox.y2 - || v138 < v39->pBoundingBox.y1 - || v134 > v39->pBoundingBox.z2 - || v130 < v39->pBoundingBox.z1 - || (ya = (unsigned __int64)(v126 * (signed __int64)v39->pFacePlane.vNormal.x) >> 16, - ve = (unsigned __int64)(v122 * (signed __int64)v39->pFacePlane.vNormal.y) >> 16, - v_4 = (unsigned __int64)(v118 * (signed __int64)v39->pFacePlane.vNormal.z) >> 16, - v20 = ya + ve + v_4 == 0, - v40 = ya + ve + v_4, - va = ya + ve + v_4, - v20) ) - goto LABEL_68; - v41 = pOut.y * v39->pFacePlane.vNormal.y; - v42 = -(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x); - if ( v40 <= 0 ) - { - if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x < 0 ) - goto LABEL_68; - } - else - { - if ( v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x > 0 ) - goto LABEL_68; - } - v_4a = abs(-(v39->pFacePlane.dist + v41 + outz * v39->pFacePlane.vNormal.z + pOut.x * v39->pFacePlane.vNormal.x)) >> 14; - if ( v_4a <= abs(v40) ) - { - LODWORD(v43) = v42 << 16; - HIDWORD(v43) = v42 >> 16; - v44 = v43 / va; - vb = v43 / va; - if ( v44 >= 0 ) - { - if ( sub_4077F1( - pOut.x + ((signed int)(((unsigned __int64)(vb * (signed __int64)v126) >> 16) + 32768) >> 16), - pOut.y + ((signed int)(((unsigned __int64)(vb * (signed __int64)v122) >> 16) + 32768) >> 16), - outz + ((signed int)(((unsigned __int64)(vb * (signed __int64)v118) >> 16) + 32768) >> 16), - v39, - (BSPVertexBuffer *)a5a) ) - { - v113 = 1; - goto LABEL_71; - } - } - } -LABEL_68: - ++sDeptha; - v_8 += 308; - if ( sDeptha >= *((int *)a5a + 2) ) - goto LABEL_71; - } - } - return !v114 || !v113; -} - -//----- (00408768) -------------------------------------------------------- -void InitializeActors() -{ - signed int v5; // [sp+Ch] [bp-10h]@1 - signed int v6; // [sp+10h] [bp-Ch]@1 - signed int v7; // [sp+14h] [bp-8h]@1 - signed int v8; // [sp+18h] [bp-4h]@1 - - v8 = 0; - v6 = 0; - v7 = 0; - v5 = 0; - if ( !_stricmp(pCurrentMapName.data(), "d25.blv") ) - v8 = 1; - if ( !_stricmp(pCurrentMapName.data(), "d26.blv") ) - v6 = 1; - if (_449B57_test_bit(pParty->_quest_bits, 99)) - v7 = 1; - if (_449B57_test_bit(pParty->_quest_bits, 100)) - 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 - for (uint i = 0; i < uNumActors; ++i) - { - auto actor = &pActors[i]; - - if (actor->CanAct() || actor->uAIState == Disabled) - { - actor->vPosition.x = actor->vInitialPosition.x; - actor->vPosition.y = actor->vInitialPosition.y; - actor->vPosition.z = actor->vInitialPosition.z; - actor->sCurrentHP = actor->pMonsterInfo.uHP; - if (actor->uAIState != Disabled) - { - Actor::AI_Stand(i, ai_near_actors_targets_pid[i], actor->pMonsterInfo.uRecoveryTime, 0); - } - } - - actor->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - - if (!v8 || v7) - if (!v6 || v5) - if (actor->IsPeasant()) - BYTE2(actor->uAttributes) &= 0xF7u; - - BYTE2(actor->uAttributes) &= 0x7Fu; - if (BYTE2(actor->uAttributes) & 0x40) - Actor::_4031C1_update_job(i, pParty->uCurrentHour, 1); - } -} - -//----- (00408896) -------------------------------------------------------- -void InitializeSpriteObjects() -{ - for (uint i = 0; i < uNumSpriteObjects; ++i) - { - auto item = &pSpriteObjects[i]; - - if (item->uType && - (item->uSoundID & 8 || pObjectList->pObjects[item->uType].uFlags & 0x10)) - SpriteObject::OnInteraction(i); - } - - for (uint i = 0; i < 100; ++i) - array_5118E8.pElements[i].field_C_time_left = 0; -} - //----- (004088E9) -------------------------------------------------------- signed int __fastcall sub_4088E9(int a1, int a2, int a3, int a4, int a5, int a6) { @@ -8911,151 +6628,6 @@ return result; } -//----- (00408A27) -------------------------------------------------------- -unsigned int __thiscall SearchAliveActors(unsigned int *pTotalActors) -{ - unsigned int *v1; // esi@1 - int v2; // eax@1 - unsigned int v3; // ebp@1 - signed int v4; // ebx@1 - Actor *v5; // edi@2 - unsigned int v6; // eax@3 - int v8; // [sp+Ch] [bp-4h]@1 - - v1 = pTotalActors; - v2 = GetAlertStatus(); - v3 = 0; - v4 = 0; - *v1 = 0; - v8 = v2; - if ( (signed int)uNumActors > 0 ) - { - v5 = pActors.data(); - do - { - v6 = v5->uAttributes; - if ( (v6 & 0x100000) == v8 ) - { - ++*v1; - if ( v5->IsNotAlive() == 1 ) - ++v3; - } - ++v4; - ++v5; - } - while ( v4 < (signed int)uNumActors ); - } - return v3; -} - -//----- (00408A7E) -------------------------------------------------------- -unsigned int __fastcall SearchActorByMonsterID(unsigned int *pTotalActors, int uMonsterID) -{ - unsigned int *v2; // esi@1 - signed int v3; // ebx@1 - Actor *v4; // edi@2 - int v5; // eax@3 - int v7; // [sp+8h] [bp-Ch]@1 - int v8; // [sp+Ch] [bp-8h]@1 - unsigned int v9; // [sp+10h] [bp-4h]@1 - - v7 = uMonsterID; - v2 = pTotalActors; - v3 = 0; - v8 = GetAlertStatus(); - *v2 = 0; - v9 = 0; - if ( (signed int)uNumActors > 0 ) - { - v4 = pActors.data();//[0].pMonsterInfo.uID; - do - { - v5 = v4->uAttributes; // actor::attributes - if ( (v5 & 0x100000) == v8 ) - { - if ( v4->pMonsterInfo.field_33 == v7 ) - { - ++*v2; - if ( v4->IsNotAlive() == 1 ) - ++v9; - } - } - ++v3; - ++v4; - } - while ( v3 < (signed int)uNumActors ); - } - return v9; -} - -//----- (00408AE7) -------------------------------------------------------- -unsigned int __fastcall SearchActorByGroup(unsigned int *pTotalActors, unsigned int uGroup) -{ - unsigned int *v2; // esi@1 - signed int v3; // ebx@1 - Actor *v4; // edi@2 - int v5; // eax@3 - unsigned int v7; // [sp+8h] [bp-Ch]@1 - int v8; // [sp+Ch] [bp-8h]@1 - unsigned int v9; // [sp+10h] [bp-4h]@1 - - v7 = uGroup; - v2 = pTotalActors; - v3 = 0; - v8 = GetAlertStatus(); - *v2 = 0; - v9 = 0; - if ( (signed int)uNumActors > 0 ) - { - v4 = pActors.data();//[0].uGroup; - do - { - v5 = v4->uAttributes; - if ( (v5 & 0x100000) == v8 ) - { - if ( v4->uGroup == v7 ) - { - ++*v2; - if ( v4->IsNotAlive() == 1 ) - ++v9; - } - } - ++v3; - ++v4; - } - while ( v3 < (signed int)uNumActors ); - } - return v9; -} - -//----- (00408B54) -------------------------------------------------------- -unsigned int __fastcall SearchActorByID(unsigned int *pTotalActors, unsigned int a2) -{ - unsigned int v2; // edi@1 - unsigned int *v3; // esi@1 - int v4; // eax@1 - unsigned int v5; // ebx@1 - unsigned int v6; // edx@1 - - v2 = a2; - v3 = pTotalActors; - v4 = GetAlertStatus(); - v5 = 0; - *v3 = 0; - v6 = pActors[v2].uAttributes; - if ( (v6 & 0x100000) == v4 ) - { - *v3 = 1; - if ( pActors[v2].IsNotAlive() == 1 ) - v5 = 1; - } - return v5; -} - - - - - //----- (0040DEDB) -------------------------------------------------------- unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor) { @@ -9070,12 +6642,6 @@ LOBYTE(pRenderer->uTargetRBits) + LOBYTE(pRenderer->uTargetBBits) - 8)); } -//----- (0040DF3D) -------------------------------------------------------- -void __cdecl CallRenderPresent() -{ - pRenderer->Present(); -} - //----- (0040DFA7) -------------------------------------------------------- int __stdcall retzero_sub_40DFA7(int a1) { @@ -9185,30 +6751,6 @@ } } - - - - - - - - - - - - - -//----- (00410AF5) -------------------------------------------------------- -void __cdecl SetMoonPhaseNames() -{ - aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150]; - aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171]; - aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102]; - aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169]; - aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92]; -} - - //----- (00410D99) -------------------------------------------------------- signed int __fastcall sub_410D99_get_map_index(int a1) { @@ -9236,720 +6778,14 @@ return v2; } -//----- (00410DEC) -------------------------------------------------------- -unsigned int __cdecl DrawLloydBeaconsScreen() -{ - Player *pPlayer; // esi@1 - char *v1; // eax@1 - unsigned __int16 v2; // ax@6 - unsigned int result; // eax@11 - unsigned int v4; // esi@13 - unsigned int v5; // ecx@13 - char v6; // zf@13 - LloydBeacon *v7; // esi@14 - int v8; // eax@14 - unsigned __int64 v9; // kr08_8@14 - unsigned int v10; // esi@14 - unsigned int v11; // eax@14 - char *v12; // eax@19 - char *v13; // ecx@22 - int v14; // eax@27 - Texture *v19; // [sp-4h] [bp-8Ch]@4 - GUIWindow pWindow; // [sp+Ch] [bp-7Ch]@1 - unsigned int v23; // [sp+64h] [bp-24h]@14 - __int64 v24; // [sp+68h] [bp-20h]@14 - unsigned int v25; // [sp+70h] [bp-18h]@13 - char *Str; // [sp+74h] [bp-14h]@14 - int v27; // [sp+78h] [bp-10h]@11 - LloydBeacon *v28; // [sp+7Ch] [bp-Ch]@12 - RGBTexture *v29; // [sp+80h] [bp-8h]@12 - int uNumMaxBeacons; // [sp+84h] [bp-4h]@6 - - pPlayer = &pParty->pPlayers[_506348_current_lloyd_playerid]; - pRenderer->DrawTextureIndexed(8u, 8u, pTexture_LloydBeacons[(unsigned __int8)bRecallingBeacon]); - v1 = pGlobalTXT_LocalizationStrings[523]; // Recall Beacon - pWindow.uFrameX = game_viewport_x; - pWindow.uFrameY = game_viewport_y; - pWindow.uFrameWidth = 428; - pWindow.uFrameHeight = game_viewport_height; - pWindow.uFrameZ = 435; - pWindow.uFrameW = game_viewport_w; - if ( !bRecallingBeacon ) - v1 = pGlobalTXT_LocalizationStrings[375]; // Set Beacon - sprintf(pTmpBuf.data(), "%s", v1); - pWindow.DrawTitleText(pBook2Font, 0, 22u, 0, pTmpBuf.data(), 3u); - if ( bRecallingBeacon ) - { - pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6b__zoom_on); - v19 = pTex_tab_an_6a__zoom_off; - } - else - { - pRenderer->DrawTextureTransparent(pBtn_Book_1->uX, pBtn_Book_1->uY, pTex_tab_an_6a__zoom_off); - v19 = pTex_tab_an_6b__zoom_on; - } - pRenderer->DrawTextureTransparent(pBtn_Book_2->uX, pBtn_Book_2->uY, v19); - v2 = pPlayer->pActiveSkills[14]; - uNumMaxBeacons = 1; - if ( HIBYTE(v2) & 1 || (v2 & 0x80u) != 0 ) - { - uNumMaxBeacons = 5; - } - else - { - if ( v2 & 0x40 ) - uNumMaxBeacons = 3; - } - result = 0; - v27 = 0; - if ( uNumMaxBeacons > 0 ) - { - v29 = pSavegameThumbnails.data(); - v28 = pPlayer->pInstalledBeacons; - while ( 1 ) - { - pWindow.uFrameWidth = 92; - v4 = result; - pWindow.uFrameHeight = 68; - v5 = pLloydsBeaconsPreviewXs[result]; - pWindow.uFrameY = pLloydsBeaconsPreviewYs[result]; - v25 = pWindow.uFrameY; - pWindow.uFrameX = v5; - pWindow.uFrameW = pWindow.uFrameY + 67; - v6 = v29->pPixels == 0; - pWindow.uFrameZ = v5 + 91; - if ( !v6 ) - break; - if ( !bRecallingBeacon ) - { - pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook); - v14 = pSpellFont->CalcTextHeight(pGlobalTXT_LocalizationStrings[19], &pWindow, 0, 0); - pWindow.DrawTitleText(pSpellFont, 0, (signed int)pWindow.uFrameHeight / 2 - v14 / 2, 1, pGlobalTXT_LocalizationStrings[19], 3); - } -LABEL_29: - ++v29; - ++v28; - result = v27++ + 1; - if ( v27 >= uNumMaxBeacons ) - goto LABEL_30; - } - pRenderer->DrawTextureTransparent(pLloydsBeacons_SomeXs[v4], pLloydsBeacons_SomeYs[v4], pTexture_CurrentBook); - pRenderer->DrawTextureRGB(pLloydsBeaconsPreviewXs[v4], pLloydsBeaconsPreviewYs[v4], v29); - v7 = v28; - Str = pMapStats->pInfos[sub_410D99_get_map_index(HIWORD(v28->field_18))].pName; - v8 = pSpellFont->CalcTextHeight(Str, &pWindow, 0, 0); - pWindow.uFrameY += -6 - v8; - pWindow.DrawTitleText(pSpellFont, 0, 0, 1u, Str, 3u); - v9 = v7->uBeaconTime - pParty->uTimePlayed; - LODWORD(v24) = LODWORD(v7->uBeaconTime) - LODWORD(pParty->uTimePlayed); - HIDWORD(v24) = HIDWORD(v9); - v23 = (unsigned __int64)((signed __int64)((double)v24 * 0.234375) / 60 / 60) >> 32; - v10 = (signed __int64)((double)v24 * 0.234375) / 60 / 60; - v11 = v10 / 0x18; - if ( (unsigned int)((signed __int64)((double)v24 * 0.234375) / 60 / 60) / 0x18 ) - { - v13 = pGlobalTXT_LocalizationStrings[57]; // Days - if ( v11 > 1 ) - { - sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13); - pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; - pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); - goto LABEL_29; - } - } - else - { - if ( (signed __int64)(__PAIR__(v23, v10) + 1) <= 23 ) - { - if ( (v23 & 0x80000000u) != 0 || (signed int)v23 <= 0 && v10 <= 1 ) - v12 = pGlobalTXT_LocalizationStrings[109];// Hour - else - v12 = pGlobalTXT_LocalizationStrings[110];// Hours - sprintf(pTmpBuf.data(), "%lu %s", v10 + 1, v12); - pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; - pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); - goto LABEL_29; - } - } - v13 = pGlobalTXT_LocalizationStrings[56]; // Day - sprintf(pTmpBuf.data(), "%lu %s", v11 + 1, v13); - pWindow.uFrameY = v25 + pWindow.uFrameHeight + 4; - pWindow.DrawTitleText(pSpellFont, 0, 0, 1, pTmpBuf.data(), 3); - goto LABEL_29; - } -LABEL_30: - if ( byte_506360 ) - { - /*result = pMessageQueue_50CBD0->uNumMessages; - if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_CloseAfterInstallBeacon; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 0; - result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; - *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - pMessageQueue_50CBD0->AddMessage(UIMSG_CloseAfterInstallBeacon, 0, 0); - } - return result; -} - - -//----- (00413FF1) -------------------------------------------------------- -void SetMonthNames() -{ - aMonthNames[0] = pGlobalTXT_LocalizationStrings[415]; - aMonthNames[1] = pGlobalTXT_LocalizationStrings[416]; - aMonthNames[2] = pGlobalTXT_LocalizationStrings[417]; - aMonthNames[3] = pGlobalTXT_LocalizationStrings[418]; - aMonthNames[4] = pGlobalTXT_LocalizationStrings[419]; - aMonthNames[5] = pGlobalTXT_LocalizationStrings[420]; - aMonthNames[6] = pGlobalTXT_LocalizationStrings[421]; - aMonthNames[7] = pGlobalTXT_LocalizationStrings[422]; - aMonthNames[8] = pGlobalTXT_LocalizationStrings[423]; - aMonthNames[9] = pGlobalTXT_LocalizationStrings[424]; - aMonthNames[10] = pGlobalTXT_LocalizationStrings[425]; - aMonthNames[11] = pGlobalTXT_LocalizationStrings[426]; -} - -//----- (0041406F) -------------------------------------------------------- -void SetDayNames() -{ - aDayNames[0] = pGlobalTXT_LocalizationStrings[145]; - aDayNames[1] = pGlobalTXT_LocalizationStrings[230]; - aDayNames[2] = pGlobalTXT_LocalizationStrings[243]; - aDayNames[3] = pGlobalTXT_LocalizationStrings[227]; - aDayNames[4] = pGlobalTXT_LocalizationStrings[91]; - aDayNames[5] = pGlobalTXT_LocalizationStrings[188]; - aDayNames[6] = pGlobalTXT_LocalizationStrings[222]; -} - -//----- (004140BB) -------------------------------------------------------- -void SetSpellSchoolNames() -{ - aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87]; - aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6]; - aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240]; - aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70]; - aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214]; - aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142]; - aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29]; - aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133]; - aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54]; -} - -//----- (0041411B) -------------------------------------------------------- -void SetAttributeNames() -{ - aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144]; - aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116]; - aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163]; - aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75]; - aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1]; - aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211]; - aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136]; -} - -//----- (00414162) -------------------------------------------------------- -void uGameUIFontMain_initialize() -{ - uGameUIFontMain = TargetColor(0xAu, 0, 0); -} - -//----- (00414174) -------------------------------------------------------- -void uGameUIFontShadow_initialize() -{ - uGameUIFontShadow = TargetColor(0xE6u, 214u, 193u); -} - - - - -//----- (0041420D) -------------------------------------------------------- -void __cdecl sub_41420D_press_esc() -{ - GUIWindow v0; // [sp+4h] [bp-54h]@1 - - sprintf(pTmpBuf2.data(), "%s\n \n%s", ptr_507BDC->Hint, pGlobalTXT_LocalizationStrings[61]);// Press Escape - v0.Hint = pTmpBuf2.data(); - v0.uFrameWidth = 400; - v0.uFrameHeight = 100; - v0.uFrameX = 120; - v0.uFrameY = 140; - v0.uFrameZ = 519; - v0.uFrameW = 239; - v0.DrawMessageBox(0); -} - -//----- (0041426F) -------------------------------------------------------- -void __cdecl sub_41426F() -{ - GUIWindow *v0; // ecx@1 - - v0 = ptr_507BDC; - pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BDC->ptr_1C, 0, 0); - - v0->Release(); - ptr_507BDC = 0; - pCurrentScreen = dword_506F0C[0]; - pEventTimer->Resume(); -} // 4E28F8: using guessed type int pCurrentScreen; - - void LoadFonts_and_DrawCopyrightWindow() { MainMenuUI_LoadFontsAndSomeStuff(); DrawCopyrightWindow(); } -//----- (00415485) -------------------------------------------------------- -void DrawCopyrightWindow() -{ - GUIWindow Dst; // [sp+8h] [bp-54h]@1 - - memset(&Dst, 0, 0x54u); - Dst.uFrameWidth = 624; - Dst.uFrameHeight = 256; - Dst.uFrameX = 8; - Dst.uFrameY = 30; // c 1999 The 3DO Company. - Dst.uFrameHeight = pFontSmallnum->CalcTextHeight(pGlobalTXT_LocalizationStrings[157], &Dst, 24, 0) - + 2 * LOBYTE(pFontSmallnum->uFontHeight) - + 24; - Dst.uFrameY = 470 - Dst.uFrameHeight; - Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; - Dst.uFrameW = 469; - //Dst.Hint = "abcagfdsgsg ljsrengvlkjesnfkjwnef"; - Dst.DrawMessageBox(0); - - Dst.uFrameWidth -= 24; - Dst.uFrameX += 12; - Dst.uFrameY += 12; - Dst.uFrameHeight -= 12; - Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1; - Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1; - Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, pGlobalTXT_LocalizationStrings[157], 3); -} - - - -//----- (004156F0) -------------------------------------------------------- -void GUI_UpdateWindows() -{ - GUIWindow *pWindow; // esi@4 - //unsigned int pWindowType; // eax@4 - const char *pHint; // edx@66 - GUIButton *pButtonPtr_1C; // ebp@79 - char *pHint1; // edx@80 - int v26; // eax@98 - unsigned int v27; // ebp@106 - GUIWindow *pGUIWindow2; // ecx@109 - GUIFont *pGUIFont; // ST1C_4@115 - int v31; // eax@115 - GUIButton *pButton; // ebp@118 - int v39; // eax@129 - unsigned int pNumMessages; // eax@142 - GUIButton *pGUIButton; // ebp@146 - //unsigned int pX; // [sp-1Ch] [bp-124h]@17 - //unsigned int pY; // [sp-18h] [bp-120h]@17 - //Texture *pTexture; // [sp-14h] [bp-11Ch]@17 - //Texture *pTexture2; // [sp-14h] [bp-11Ch]@86 - int i; // [sp+0h] [bp-108h]@3 - ItemGen pItemGen; // [sp+4h] [bp-104h]@98 - GUIButton GUIButton2; // [sp+28h] [bp-E0h]@133 - ItemGen ItemGen2; // [sp+E4h] [bp-24h]@129 - - if (GetCurrentMenuID() != MENU_CREATEPARTY) - UI_OnKeyDown(VK_NEXT); - - for ( i = 1; i <= uNumVisibleWindows; ++i ) - { - pWindow = &pWindowList[pVisibleWindowsIdxs[i] - 1]; - switch (pWindow->eWindowType) - { - case WINDOW_OptionsButtons: - { - pRenderer->DrawTextureIndexed(pViewport->uViewportTL_Y, - pViewport->uViewportTL_X, pIcons_LOD->GetTexture(uTextureID_Options)); - viewparams->bRedrawGameUI = 1; - continue; - } - case WINDOW_CharacterRecord: - { - CharacterUI_CharacterScreen_Draw(pPlayers[uActiveCharacter]); - continue; - } - case WINDOW_Options: - { - GameMenuUI_Options_Draw(); - continue; - } - case WINDOW_Book: - { - BookUI_Draw((WindowType)(int)pWindow->ptr_1C); - continue; - } - case WINDOW_Dialogue: - { - GameUI_DrawDialogue(); - continue; - } - case WINDOW_QuickReference: - { - GameUI_QuickRef_Draw(); - continue; - } - case WINDOW_Rest: - { - RestUI_Draw(); - continue; - } - case WINDOW_ChangeLocation: - { - TravelUI_Draw(); - continue; - } - case WINDOW_SpellBook: - { - DrawSpellBookContent(pPlayers[uActiveCharacter]); - continue; - } - case WINDOW_GreetingNPC: - { - GameUI_DrawBranchlessDialogue(); - continue; - } - case WINDOW_Chest: - { - if ( pCurrentScreen == SCREEN_CHEST ) - { - Chest::DrawChestUI((unsigned int)pWindow->ptr_1C); - } - else if ( pCurrentScreen == SCREEN_CHEST_INVENTORY ) - { - pRenderer->ClearZBuffer(0, 479); - draw_leather(); - CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); - pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId)); - } - continue; - } - case WINDOW_SaveLoadButtons: - { - SaveUI_Draw(); - continue; - } - case WINDOW_MainMenu_Load: - { - LoadUI_Draw(); - continue; - } - case WINDOW_HouseInterior: - { - pWindowList[pVisibleWindowsIdxs[i] - 1].HouseDialogManager(); - if ( !window_SpeakInHouse ) - continue; - if ( (signed int)window_SpeakInHouse->ptr_1C >= 53 ) - continue; - if ( pParty->field_3C._shop_ban_times[(signed int)window_SpeakInHouse->ptr_1C] <=pParty->uTimePlayed ) - { - if ( (signed int)window_SpeakInHouse->ptr_1C < 53 ) - { - pParty->field_3C._shop_ban_times[(signed int)window_SpeakInHouse->ptr_1C] = 0; - } - continue; - } - pNumMessages = pMessageQueue_50CBD0->uNumMessages; - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - continue; - } - case WINDOW_Transition: - { - TransitionUI_Draw(); - continue; - } - case WINDOW_Scroll: - { - CreateScrollWindow(); - continue; - } - case WINDOW_CastSpell_InInventory: - { - pRenderer->ClearZBuffer(0, 479); - draw_leather(); - CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); - CharacterUI_DrawPaperdoll(pPlayers[uActiveCharacter]); - pRenderer->DrawTextureTransparent(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uTextureID_x_x_u)); - continue; - } - case WINDOW_FinalWindow: - { - sub_41420D_press_esc(); - continue; - } - case WINDOW_50: - { - v27 = TargetColor(255, 255, 255); - if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) - { - ptr_507BD0->DrawMessageBox(0); - ptr_507BD0->DrawText(pFontCreate, 30, 40, v27, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0); - v31 = pFontCreate->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); - ptr_507BD0->DrawFlashingInputCursor(v31 + 30, 40, pFontCreate); - continue; - } - if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) - { - pWindow->receives_keyboard_input_2 = WINDOW_INPUT_NONE; - pMessageQueue_50CBD0->AddMessage((UIMessageType)(int)ptr_507BD0->ptr_1C, 0, 0); - pEventTimer->Resume(); - ptr_507BD0->Release(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = true; - continue; - } - if ( ptr_507BD0->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED) - { - pWindow->receives_keyboard_input_2 = WINDOW_INPUT_NONE; - pEventTimer->Resume(); - ptr_507BD0->Release(); - continue; - } - } - case WINDOW_59: - { - pWindow->DrawMessageBox(0); - pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0); - pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0); - if ( !pKeyActionMap->field_204 ) - { - ItemGen2.Reset(); - pWindow->Release(); - pEventTimer->Resume(); - pCurrentScreen = 0; - viewparams->bRedrawGameUI = true; - v26 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); - if ( v26 > 0 ) - { - if ( v26 < 800 ) - { - ItemGen2.uAttributes |= 1u; - ItemGen2.uItemID = v26; - if ( pItemsTable->pItems[v26].uEquipType == 12 ) - { - ItemGen2.uNumCharges = rand() % 6 + pItemsTable->pItems[ItemGen2.uItemID].uDamageMod + 1; - ItemGen2.uMaxCharges = LOBYTE(ItemGen2.uNumCharges); - } - else - { - if ( v26 >= 221 && v26 < 271 ) - ItemGen2.uEnchantmentType = rand() % 10 + 1; - } - pItemsTable->SetSpecialBonus(&ItemGen2); - pParty->SetHoldingItem(&ItemGen2); - } - } - } - continue; - } - case WINDOW_PressedButton2: - { - if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); - pButton = (GUIButton *)pWindow->ptr_1C; - if ( pButton->uX >= 0 && pButton->uX <= 640 ) - { - if ( pButton->uY >= 0 && pButton->uY <= 480 ) - { - pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]); - viewparams->bRedrawGameUI = 1; - if ( pWindow->Hint ) - { - if ( pWindow->Hint != (char *)1 ) - pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0); - } - pWindow->Release(); - continue; - } - } - viewparams->bRedrawGameUI = 1; - if ( pWindow->Hint ) - { - if ( pWindow->Hint != (char *)1 ) - pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0); - } - pWindow->Release(); - continue; - } - case WINDOW_CharactersPressedButton: - { - if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); - pButton = (GUIButton *)pWindow->ptr_1C; - pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]); - viewparams->bRedrawGameUI = 1; - if ( pWindow->Hint ) - { - if ( pWindow->Hint != (char *)1 ) - pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0); - } - pWindow->Release(); - continue; - } - case WINDOW_PressedButton: - { - if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); - pButton = (GUIButton *)pWindow->ptr_1C; - pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]); - viewparams->bRedrawGameUI = 1; - if ( pWindow->Hint ) - { - if ( pWindow->Hint != (char *)1 ) - pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0); - } - pWindow->Release(); - continue; - } - case WINDOW_5D: - { - if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); - pButton = (GUIButton *)pWindow->ptr_1C; - pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]); - viewparams->bRedrawGameUI = 1; - pWindow->Release(); - continue; - } - case WINDOW_SaveLoadBtn: - { - if (pWindow->Hint != (char *)1) - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); - pButton = (GUIButton *)pWindow->ptr_1C; - pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]); - pHint = pWindow->Hint; - viewparams->bRedrawGameUI = 1; - if ( pHint && pHint != (char *)1 ) - pButton->DrawLabel(pHint, pFontCreate, 0, 0); - pWindow->Release(); - if (pCurrentScreen == SCREEN_SAVEGAME) - pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0); - else - pMessageQueue_50CBD0->AddMessage(UIMSG_LoadGame, 0, 0); - continue; - } - case WINDOW_LoadGame_CancelBtn: - { - if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound((SoundID)75, 0, 0, -1, 0, 0, 0, 0); - pButton = (GUIButton *)pWindow->ptr_1C; - pRenderer->DrawTextureTransparent(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[0]); - viewparams->bRedrawGameUI = 1; - if ( pWindow->Hint && pWindow->Hint != (char *)1 ) - pButton->DrawLabel(pWindow->Hint, pFontCreate, 0, 0); - pWindow->Release(); - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - continue; - } - case WINDOW_CloseRestWindowBtn: - { - if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); - pGUIButton = (GUIButton *)pWindow->ptr_1C; - pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pGUIButton->pTextures[0]); - pHint = pWindow->Hint; - viewparams->bRedrawGameUI = 1; - if ( pHint && pHint != (char *)1 ) - pGUIButton->DrawLabel(pHint, pFontCreate, 0, 0); - pWindow->Release(); - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - continue; - } - case WINDOW_ExitCharacterWindow: - { - if ( pWindow->Hint != (char *)1 ) - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); - pButton = (GUIButton *)pWindow->ptr_1C; - pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, pButton->pTextures[1]); - pHint = pWindow->Hint; - viewparams->bRedrawGameUI = 1; - if ( pHint && pHint != (char *)1 ) - pButton->DrawLabel(pHint, pFontCreate, 0, 0); - pWindow->Release(); - pNumMessages = pMessageQueue_50CBD0->uNumMessages; - pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); - continue; - } - case WINDOW_RestWindow: - { - memset(&GUIButton2, 0, 0xBCu); - GUIButton2.uZ = 197; - GUIButton2.uW = 197; - GUIButton2.uX = 27; - GUIButton2.uY = 161; - GUIButton2.uWidth = 171; - GUIButton2.uHeight = 37; - GUIButton2.pParent = pButton_RestUI_WaitUntilDawn->pParent; - pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); - pRenderer->DrawTextureIndexed(pWindow->uFrameX, pWindow->uFrameY, *((Texture **)pWindow->ptr_1C + 15)); - viewparams->bRedrawGameUI = 1; - GUIButton2.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, 0, 0);//Отдых и лечение 8 часов - GUIButton2.pParent = 0; - pGUIWindow2 = pWindow; - pGUIWindow2->Release(); - continue; - } - case WINDOW_BooksWindow: - { - pButton = (GUIButton *)pWindow->ptr_1C; - pRenderer->DrawTextureIndexed(pWindow->uFrameY, - pWindow->uFrameX, pButton->pTextures[0]); - viewparams->bRedrawGameUI = true; - continue; - } - case WINDOW_CharacterWindow_Inventory: - { - pWindow->DrawMessageBox(0); - pWindow->DrawText(pFontLucida, 10, 20, 0, "Making item number", 0, 0, 0); - pWindow->DrawText(pFontLucida, 10, 40, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 0, 0, 0); - if ( !pKeyActionMap->field_204 ) - { - ItemGen2.Reset(); - pWindow->Release(); - pEventTimer->Resume(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - v39 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); - if ( v39 > 0 ) - { - if ( v39 < 800 ) - SpawnActor(v39); - } - } - continue; - } - case WINDOW_KeyMappingOptions: - { - GameMenuUI_DrawKeyBindings(); - continue; - } - case WINDOW_VideoOptions: - { - GameMenuUI_DrawVideoOptions(); - continue; - } - default: - { - continue; - } - } - } - if ( GetCurrentMenuID() == -1 ) - GameUI_DrawFoodAndGold(); - if ( sub_4637E0_is_there_popup_onscreen() ) - sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(0); -} //----- (00416196) -------------------------------------------------------- void identify_item() @@ -10377,85 +7213,6 @@ } } -//----- (004178FE) -------------------------------------------------------- -unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2) -{ - unsigned __int16 v2; // dx@2 - unsigned __int16 v3; // cx@2 - int v5; // eax@5 - unsigned __int16 v6; // [sp-4h] [bp-8h]@2 - - if ( a1 <= a2 ) - { - if ( a1 == a2 ) - return 0; - v5 = 100 * a1 / a2; - v3 = 255; - if ( v5 >= 25 ) - { - v6 = 100; - v2 = 255; - } - else - { - v6 = 0; - v2 = 0; - } - } - else - { - v6 = 0; - v2 = 255; - v3 = 0; - } - return TargetColor(v3, v2, v6); -} - -//----- (00417939) -------------------------------------------------------- -signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx) -{ - unsigned int v1; // ebx@1 - signed int v2; // edi@1 - unsigned int v3; // esi@1 - unsigned int v4; // eax@1 - unsigned int v6; // [sp+Ch] [bp-4h]@1 - - v1 = uConditionIdx; - v2 = 65535; - v3 = TargetColor(0xE1u, 0xCDu, 0x23u); - v6 = TargetColor(0xFFu, 0x23u, 0); - v4 = TargetColor(0, 0xFFu, 0); - switch ( v1 ) - { - case 0u: - case 1u: - case 3u: - case 4u: - case 5u: - case 6u: - case 7u: - v2 = v4; - break; - case 2u: - case 8u: - case 9u: - case 0xCu: - case 0xDu: - v2 = v3; - break; - case 0xAu: - case 0xBu: - case 0xEu: - case 0xFu: - case 0x10u: - v2 = v6; - break; - default: - return v2; - } - return v2; -} - //----- (004179BC) -------------------------------------------------------- void __fastcall sub_4179BC_draw_tooltip( const char *a1, const char *a2 ) { diff -r c423f946dc99 -r 5450af4f57ef texts.cpp --- a/texts.cpp Tue Jun 18 17:28:11 2013 +0600 +++ b/texts.cpp Wed Jun 19 17:06:58 2013 +0600 @@ -387,6 +387,68 @@ aSpellNames[42] = pGlobalTXT_LocalizationStrings[194]; aSpellNames[43] = pGlobalTXT_LocalizationStrings[657]; } +//----- (00413FF1) -------------------------------------------------------- +void SetMonthNames() +{ + aMonthNames[0] = pGlobalTXT_LocalizationStrings[415]; + aMonthNames[1] = pGlobalTXT_LocalizationStrings[416]; + aMonthNames[2] = pGlobalTXT_LocalizationStrings[417]; + aMonthNames[3] = pGlobalTXT_LocalizationStrings[418]; + aMonthNames[4] = pGlobalTXT_LocalizationStrings[419]; + aMonthNames[5] = pGlobalTXT_LocalizationStrings[420]; + aMonthNames[6] = pGlobalTXT_LocalizationStrings[421]; + aMonthNames[7] = pGlobalTXT_LocalizationStrings[422]; + aMonthNames[8] = pGlobalTXT_LocalizationStrings[423]; + aMonthNames[9] = pGlobalTXT_LocalizationStrings[424]; + aMonthNames[10] = pGlobalTXT_LocalizationStrings[425]; + aMonthNames[11] = pGlobalTXT_LocalizationStrings[426]; +} + +//----- (0041406F) -------------------------------------------------------- +void SetDayNames() +{ + aDayNames[0] = pGlobalTXT_LocalizationStrings[145]; + aDayNames[1] = pGlobalTXT_LocalizationStrings[230]; + aDayNames[2] = pGlobalTXT_LocalizationStrings[243]; + aDayNames[3] = pGlobalTXT_LocalizationStrings[227]; + aDayNames[4] = pGlobalTXT_LocalizationStrings[91]; + aDayNames[5] = pGlobalTXT_LocalizationStrings[188]; + aDayNames[6] = pGlobalTXT_LocalizationStrings[222]; +} + +//----- (004140BB) -------------------------------------------------------- +void SetSpellSchoolNames() +{ + aSpellSchoolNames[0] = pGlobalTXT_LocalizationStrings[87]; + aSpellSchoolNames[1] = pGlobalTXT_LocalizationStrings[6]; + aSpellSchoolNames[2] = pGlobalTXT_LocalizationStrings[240]; + aSpellSchoolNames[3] = pGlobalTXT_LocalizationStrings[70]; + aSpellSchoolNames[4] = pGlobalTXT_LocalizationStrings[214]; + aSpellSchoolNames[5] = pGlobalTXT_LocalizationStrings[142]; + aSpellSchoolNames[6] = pGlobalTXT_LocalizationStrings[29]; + aSpellSchoolNames[7] = pGlobalTXT_LocalizationStrings[133]; + aSpellSchoolNames[8] = pGlobalTXT_LocalizationStrings[54]; +} + +//----- (0041411B) -------------------------------------------------------- +void SetAttributeNames() +{ + aAttributeNames[0] = pGlobalTXT_LocalizationStrings[144]; + aAttributeNames[1] = pGlobalTXT_LocalizationStrings[116]; + aAttributeNames[2] = pGlobalTXT_LocalizationStrings[163]; + aAttributeNames[3] = pGlobalTXT_LocalizationStrings[75]; + aAttributeNames[4] = pGlobalTXT_LocalizationStrings[1]; + aAttributeNames[5] = pGlobalTXT_LocalizationStrings[211]; + aAttributeNames[6] = pGlobalTXT_LocalizationStrings[136]; +} +//----- (00410AF5) -------------------------------------------------------- +void __cdecl SetMoonPhaseNames() +{ + aMoonPhaseNames[0] = pGlobalTXT_LocalizationStrings[150]; + aMoonPhaseNames[1] = pGlobalTXT_LocalizationStrings[171]; + aMoonPhaseNames[2] = pGlobalTXT_LocalizationStrings[102]; + aMoonPhaseNames[3] = pGlobalTXT_LocalizationStrings[169]; + aMoonPhaseNames[4] = pGlobalTXT_LocalizationStrings[92]; +} -