# HG changeset patch # User Ritor1 # Date 1378366275 -21600 # Node ID 863de6ec906bec35266953834d40002caf9b859d # Parent 58d15177edd0404c47a684fa8d36289b4d9e5ad5# Parent f3802824f57664a3356711fa183aa7f3d71c2dad Слияние diff -r 58d15177edd0 -r 863de6ec906b Actor.cpp --- a/Actor.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/Actor.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -294,7 +294,7 @@ } //----- (00404AC7) -------------------------------------------------------- -void __fastcall Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel) +void __fastcall Actor::AI_SpellAttack(unsigned int uActorID, AIDirection *pDir, int uSpellID, int a4, unsigned int uSkillLevel) { Actor *v5; // esi@1 unsigned int v6; // edi@1 @@ -426,25 +426,25 @@ v117 = pDir; v6 = uSkillLevel & 0x3F; v7 = SkillToMastery(uSkillLevel); - if ( spellnum <= 47 ) + if ( uSpellID <= 47 ) { - if ( spellnum != 47 ) + if ( uSpellID != 47 ) { - if ( spellnum <= 18 ) + if ( uSpellID <= 18 ) { - if ( spellnum == 18 || spellnum == 2 ) + if ( uSpellID == 18 || uSpellID == 2 ) goto LABEL_159; - if ( spellnum != 5 ) + if ( uSpellID != 5 ) { - if ( spellnum == 6 ) + if ( uSpellID == 6 ) goto LABEL_159; - if ( spellnum != 9 ) + if ( uSpellID != 9 ) { - if ( spellnum != 11 ) + if ( uSpellID != 11 ) { - if ( spellnum != 15 ) + if ( uSpellID != 15 ) { - if ( spellnum != 17 ) + if ( uSpellID != 17 ) return; if ( (signed int)v7 <= 0 ) goto LABEL_20; @@ -577,7 +577,7 @@ return; } LABEL_159: - a1.uType = stru_4E3ACC[spellnum].uType; + a1.uType = stru_4E3ACC[uSpellID].uType; v119 = 0.0; if ( (signed int)pObjectList->uNumObjects <= 0 ) { @@ -598,7 +598,7 @@ } a1.uObjectDescID = v82; a1.stru_24.Reset(); - a1.spell_id = spellnum; + a1.spell_id = uSpellID; v83 = v5->vPosition.x; v84 = v5->vPosition.y; a1.spell_level = uSkillLevel; @@ -660,7 +660,7 @@ LOBYTE(v92) = v92 | 2; v100 = 0; v99 = v92; - v22 = (SoundID)word_4EE088_sound_ids[spellnum]; + v22 = (SoundID)word_4EE088_sound_ids[uSpellID]; goto LABEL_202; } return; @@ -844,13 +844,13 @@ v39 = 0; goto LABEL_79; } - if ( spellnum == 26 || spellnum == 29 ) + if ( uSpellID == 26 || uSpellID == 29 ) goto LABEL_159; - if ( spellnum != 38 ) + if ( uSpellID != 38 ) { - if ( spellnum == 39 || spellnum == 41 ) + if ( uSpellID == 39 || uSpellID == 41 ) goto LABEL_159; - if ( spellnum != 46 ) + if ( uSpellID != 46 ) return; if ( (signed int)v7 > 0 ) { @@ -971,9 +971,9 @@ LOWORD(v48) = 0; goto LABEL_114; } - if ( spellnum <= 80 ) + if ( uSpellID <= 80 ) { - if ( spellnum == 80 ) + if ( uSpellID == 80 ) { v56 = pParty->pPartyBuffs; do @@ -1019,11 +1019,11 @@ v22 = (SoundID)word_4EE088_sound_ids[80]; goto LABEL_202; } - if ( spellnum != 51 ) + if ( uSpellID != 51 ) { - if ( spellnum == 57 || spellnum == 65 || spellnum == 70 ) + if ( uSpellID == 57 || uSpellID == 65 || uSpellID == 70 ) goto LABEL_159; - if ( spellnum == 73 ) + if ( uSpellID == 73 ) { if ( (signed int)v7 <= 0 || (signed int)v7 > 4 ) v51 = 0; @@ -1048,7 +1048,7 @@ v98 = (SoundID)16060; goto LABEL_222; } - if ( spellnum == 77 ) + if ( uSpellID == 77 ) { v5->sCurrentHP += 5 * v6 + 10; if ( v5->sCurrentHP >= (signed int)v5->pMonsterInfo.uHP ) @@ -1057,7 +1057,7 @@ v47 = 0; goto LABEL_127; } - v49 = spellnum == 78; + v49 = uSpellID == 78; LABEL_158: if ( !v49 ) return; @@ -1104,7 +1104,7 @@ v54 = 0; goto LABEL_142; } - if ( spellnum == 85 ) + if ( uSpellID == 85 ) { if ( (signed int)v7 > 0 ) { @@ -1148,7 +1148,7 @@ v96 = 0; goto LABEL_221; } - if ( spellnum == 86 ) + if ( uSpellID == 86 ) { if ( (signed int)v7 > 0 ) { @@ -1191,13 +1191,13 @@ v94 = 0; goto LABEL_212; } - if ( spellnum == 90 ) + if ( uSpellID == 90 ) goto LABEL_159; - if ( spellnum != 93 ) + if ( uSpellID != 93 ) { - if ( spellnum != 95 ) + if ( uSpellID != 95 ) { - v49 = spellnum == 97; + v49 = uSpellID == 97; goto LABEL_158; } if ( (signed int)v7 > 0 ) @@ -2308,7 +2308,7 @@ result = pPlayer->CanAct(); if ( result ) { - pCastSpellInfo.data()->_427D48(v1); + CastSpellInfoHelpers::_427D48(); v4 = 0; v5 = pMapStats->GetMapInfo(pCurrentMapName); if ( v5 ) diff -r 58d15177edd0 -r 863de6ec906b Actor.h --- a/Actor.h Thu Sep 05 13:12:53 2013 +0600 +++ b/Actor.h Thu Sep 05 13:31:15 2013 +0600 @@ -214,7 +214,7 @@ static struct AIDirection *__fastcall GetDirectionInfo(unsigned int uObj1ID, unsigned int uObj2ID, struct AIDirection *pOut, int a4); static signed int __fastcall Explode(unsigned int uActorID); static char __fastcall AI_RangedAttack(unsigned int uActorID, struct AIDirection *a2, int type, char a4); - static void __fastcall AI_SpellAttack(unsigned int uActorID, struct AIDirection *pDir, int spellnum, int a4, unsigned int uSkillLevel); + static void __fastcall AI_SpellAttack(unsigned int uActorID, struct AIDirection *pDir, int uSpellID, int a4, unsigned int uSkillLevel); static void AggroSurroundingPeasants(unsigned int uActorID, int a2); static bool ArePeasantsOfSameFaction(Actor *a1, Actor *a2); static bool StealFrom(unsigned int uActorID); diff -r 58d15177edd0 -r 863de6ec906b CastSpellInfo.cpp --- a/CastSpellInfo.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/CastSpellInfo.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -25,8 +25,11 @@ #include "texts.h" #include "LOD.h" +const size_t CastSpellInfoCount = 10; +std::array pCastSpellInfo; + //----- (00427E01) -------------------------------------------------------- -void CastSpellInfo::_427E01_cast_spell() +void CastSpellInfoHelpers::_427E01_cast_spell() { int v2; // edi@1 CastSpellInfo *pCastSpell; // ebx@2 @@ -306,20 +309,20 @@ LODWORD(v733) = 0; v723 = 0; v727 = 0.0; - for(n = 0; n < 10; ++n) + for(n = 0; n < CastSpellInfoCount; ++n) { - pCastSpell = &this[n]; + pCastSpell = &pCastSpellInfo[n]; HIDWORD(v733) = (int)pCastSpell; - if ( pCastSpell->spellnum == 0 ) + if ( pCastSpell->uSpellID == 0 ) continue; if (pParty->Invisible()) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); - if ( pCastSpell->field_8 & 0x3CA ) + if ( pCastSpell->uFlags & 0x3CA ) { if ( !pParty->pPlayers[pCastSpell->uPlayerID].CanAct() ) - this->_427D48(1); + _427D48(); continue; } pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID]; @@ -327,9 +330,9 @@ a2 = pCastSpell->spell_target_pid; if (!pCastSpell->spell_target_pid) { - if (pCastSpell->spellnum == SPELL_LIGHT_DESTROY_UNDEAD || - pCastSpell->spellnum == SPELL_SPIRIT_TURN_UNDEAD || - pCastSpell->spellnum == SPELL_DARK_CONTROL_UNDEAD ) + if (pCastSpell->uSpellID == SPELL_LIGHT_DESTROY_UNDEAD || + pCastSpell->uSpellID == SPELL_SPIRIT_TURN_UNDEAD || + pCastSpell->uSpellID == SPELL_DARK_CONTROL_UNDEAD ) v666 = 1; else v666 = 0; @@ -341,7 +344,7 @@ } - pSpellSprite.uType = stru_4E3ACC[pCastSpell->spellnum].uType; + pSpellSprite.uType = stru_4E3ACC[pCastSpell->uSpellID].uType; if (pSpellSprite.uType) { if (PID_TYPE(a2) == OBJECT_Actor) @@ -367,25 +370,25 @@ else { //v667 = PLAYER_SKILL_STAFF; - if (pCastSpell->spellnum < SPELL_AIR_WIZARD_EYE) + if (pCastSpell->uSpellID < SPELL_AIR_WIZARD_EYE) v667 = PLAYER_SKILL_FIRE; - else if (pCastSpell->spellnum < SPELL_WATER_AWAKEN) + else if (pCastSpell->uSpellID < SPELL_WATER_AWAKEN) v667 = PLAYER_SKILL_AIR; - else if (pCastSpell->spellnum < SPELL_EARTH_STUN) + else if (pCastSpell->uSpellID < SPELL_EARTH_STUN) v667 = PLAYER_SKILL_WATER; - else if (pCastSpell->spellnum < SPELL_SPIRIT_DETECT_LIFE) + else if (pCastSpell->uSpellID < SPELL_SPIRIT_DETECT_LIFE) v667 = PLAYER_SKILL_EARTH; - else if (pCastSpell->spellnum < SPELL_MIND_REMOVE_FEAR) + else if (pCastSpell->uSpellID < SPELL_MIND_REMOVE_FEAR) v667 = PLAYER_SKILL_SPIRIT; - else if (pCastSpell->spellnum < SPELL_BODY_CURE_WEAKNESS) + else if (pCastSpell->uSpellID < SPELL_BODY_CURE_WEAKNESS) v667 = PLAYER_SKILL_MIND; - else if (pCastSpell->spellnum < SPELL_LIGHT_LIGHT_BOLT) + else if (pCastSpell->uSpellID < SPELL_LIGHT_LIGHT_BOLT) v667 = PLAYER_SKILL_BODY; - else if (pCastSpell->spellnum < SPELL_DARK_REANIMATE) + else if (pCastSpell->uSpellID < SPELL_DARK_REANIMATE) v667 = PLAYER_SKILL_LIGHT; - else if (pCastSpell->spellnum < SPELL_BOW_ARROW) + else if (pCastSpell->uSpellID < SPELL_BOW_ARROW) v667 = PLAYER_SKILL_DARK; - else if (pCastSpell->spellnum == SPELL_BOW_ARROW) + else if (pCastSpell->uSpellID == SPELL_BOW_ARROW) v667 = PLAYER_SKILL_BOW; else assert(false && "Unknown spell"); @@ -400,21 +403,21 @@ if (pCastSpell->forced_spell_skill_level) uRequiredMana = 0; else - uRequiredMana = pSpellDatas[pCastSpell->spellnum - 1].mana_per_skill[v731 - 1]; - sRecoveryTime = pSpellDatas[pCastSpell->spellnum - 1].recovery_per_skill[v731 - 1]; + uRequiredMana = pSpellDatas[pCastSpell->uSpellID - 1].mana_per_skill[v731 - 1]; + sRecoveryTime = pSpellDatas[pCastSpell->uSpellID - 1].recovery_per_skill[v731 - 1]; if (LODWORD(v725) == PLAYER_SKILL_DARK && pParty->uCurrentHour == 0 && pParty->uCurrentMinute == 0 || LODWORD(v725) == PLAYER_SKILL_LIGHT && pParty->uCurrentHour == 12 && pParty->uCurrentMinute == 0) uRequiredMana = 0; - if (pCastSpell->spellnum < SPELL_BOW_ARROW && pPlayer->sMana < uRequiredMana) + if (pCastSpell->uSpellID < SPELL_BOW_ARROW && pPlayer->sMana < uRequiredMana) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[586], 2u); // "Not enough spell points" - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } - v730 = pCastSpell->spellnum; - if (pPlayer->IsCursed() && pCastSpell->spellnum < SPELL_BOW_ARROW && rand() % 100 < 50) + v730 = pCastSpell->uSpellID; + if (pPlayer->IsCursed() && pCastSpell->uSpellID < SPELL_BOW_ARROW && rand() % 100 < 50) { if (!pParty->bTurnBasedModeOn) { @@ -428,18 +431,18 @@ //v646 = pPlayer; //v648 = sRecoveryTime; //v649 = pPlayer; - pParty->pTurnBasedPlayerRecoveryTimes[this[n].uPlayerID] = 100; + pParty->pTurnBasedPlayerRecoveryTimes[pCastSpellInfo[n].uPlayerID] = 100; pPlayer->SetRecoveryTime(sRecoveryTime); pTurnEngine->ApplyPlayerAction(); } ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); // "Spell failed" pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - this[n].spellnum = 0; + pCastSpellInfo[n].uSpellID = 0; pPlayer->sMana -= uRequiredMana; return; } - switch ( pCastSpell->spellnum ) + switch ( pCastSpell->uSpellID ) { case SPELL_101: assert(false && "Unknown spell effect #101 (prolly flaming bow arrow"); @@ -451,7 +454,7 @@ sRecoveryTime = pPlayer->GetAttackRecoveryTime(true); pSpellSprite.stru_24.Reset(); pSpellSprite.spell_level = v2; - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); if ( pPlayer->WearsItem(ITEM_ARTEFACT_ULLYSES, EQUIP_BOW) ) @@ -486,7 +489,7 @@ { sRecoveryTime = pPlayer->GetAttackRecoveryTime(0); pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v723; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -569,13 +572,13 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -606,7 +609,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if (PID_TYPE(a2) != OBJECT_Actor) @@ -618,7 +621,7 @@ v697.y = 0; v697.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -652,7 +655,7 @@ v704.y = 0; v704.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -682,7 +685,7 @@ v691.y = 0; v691.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -703,7 +706,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v691); @@ -727,7 +730,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -747,7 +750,7 @@ pSpellSprite.uSoundID = LOWORD(pCastSpell->sound_id); if ( pParty->bTurnBasedModeOn == 1 ) LOBYTE(pSpellSprite.uAttributes) |= 4u; - if ( pCastSpell->spellnum == SPELL_AIR_LIGHNING_BOLT ) + if ( pCastSpell->uSpellID == SPELL_AIR_LIGHNING_BOLT ) LOBYTE(pSpellSprite.uAttributes) |= 0x40u; v659 = pObjectList->pObjects[(signed __int16)pSpellSprite.uObjectDescID].uSpeed; if ( pSpellSprite.Create(v715.uYawAngle, v715.uPitchAngle, v659, pCastSpell->uPlayerID + 1) != -1 && pParty->bTurnBasedModeOn == 1 ) @@ -763,7 +766,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -797,13 +800,13 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( pPlayer->CanCastSpell(uRequiredMana) ) { pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_skill = v731; pSpellSprite.spell_level = v2; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -915,7 +918,7 @@ pActors[PID_ID(a2)].pActorBuffs[1].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)(power << 7) * 0.033333335), v731, 0, 0, 0); pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1023,7 +1026,7 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } case SPELL_BODY_REGENERATION: @@ -1040,7 +1043,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_REGENERATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)v733 * 4.2666669), v731, amount, 0, 0); LODWORD(v727) = 1; @@ -1063,7 +1066,7 @@ assert(false); } - switch (pCastSpell->spellnum) + switch (pCastSpell->uSpellID) { case SPELL_FIRE_PROTECTION_FROM_FIRE: LODWORD(v725) = PARTY_BUFF_RESIST_FIRE; @@ -1089,10 +1092,10 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); v90 = (double)(signed int)v733 * 4.2666669; pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0); LODWORD(v727) = 1; @@ -1124,10 +1127,10 @@ { pParty->pPartyBuffs[PARTY_BUFF_HASTE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); } } break; @@ -1149,7 +1152,7 @@ if ( v731 == 1 ) { v108 = pCastSpell->uPlayerID_2; - v109 = pCastSpell->spellnum; + v109 = pCastSpell->uSpellID; v110 = pGame->GetStru6(); pGame->GetStru6()->SetPlayerBuffAnim(v109, v108); v111 = pOtherOverlayList->_4418B1(10000, pCastSpell->uPlayerID_2 + 310, 0, 65536); @@ -1173,7 +1176,7 @@ v730b = pParty->pPlayers;//[0].pPlayerBuffs[1]; do { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, v105); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, v105); v716 = pOtherOverlayList->_4418B1(10000, v105 + 310, 0, 65536); v730b->pPlayerBuffs[1].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0); ++v730b; @@ -1214,13 +1217,13 @@ v114 = v118; } _this = (ItemGen *)(((unsigned int)(11 * v114) >> 5) + (v115 >> 2) + v113); - if ( (double)(signed int)this <= 307.2 ) + if ( (double)(signed int)_this <= 307.2 ) { v701.x = 0; v701.y = 0; v701.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v723; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1243,7 +1246,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; } //pCastSpell = (CastSpellInfo *)HIDWORD(v733); } @@ -1262,7 +1265,7 @@ default: assert(false); } - v127 = pCastSpell->spellnum; + v127 = pCastSpell->uSpellID; if ( v127 == 17 ) { amount = 0; @@ -1285,10 +1288,10 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); v90 = (double)(signed int)((int)v733 << 7) * 0.033333335; //LABEL_304: pParty->pPartyBuffs[LODWORD(v725)].Apply(pParty->uTimePlayed + (signed int)(signed __int64)v90, v731, amount, 0, 0); @@ -1304,10 +1307,10 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); pParty->pPartyBuffs[PARTY_BUFF_IMMOLATION].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0); LODWORD(v727) = 1; @@ -1330,7 +1333,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[491], 2); // Can't cast Meteor Shower indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -1374,7 +1377,7 @@ stru_5C6E00->Atan2(j, k)); } pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1409,7 +1412,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[492], 2); // Can't cast Inferno outdoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -1419,7 +1422,7 @@ v700.y = 0; v700.x = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1486,10 +1489,10 @@ do pOtherOverlayList->_4418B1(2010, v174++ + 100, 0, 65536); while ( v174 < 4 ); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); pParty->pPartyBuffs[PARTY_BUFF_FEATHER_FALL].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); LODWORD(v727) = 1; @@ -1510,7 +1513,7 @@ break; auto _v726 = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1580,15 +1583,15 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[638], 2); // There are hostile creatures nearby! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( pPlayer->CanCastSpell(uRequiredMana) ) { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0); LODWORD(v727) = 1; @@ -1635,7 +1638,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[495], 2); // Can't cast Starburst indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -1690,7 +1693,7 @@ stru_5C6E00->Atan2((signed __int64)v216, (signed __int64)*(float *)&uRequiredMana)); } pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1775,7 +1778,7 @@ if ( amount == 1 ) { pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_skill = v731; pSpellSprite.spell_level = v2; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1804,7 +1807,7 @@ else { pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -1859,10 +1862,10 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; v716 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply( pParty->uTimePlayed + (signed int)(signed __int64)((double)(v229 << 7) * 0.033333335), @@ -1889,7 +1892,7 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( v731 == 1 || v731 == 2 ) @@ -1921,7 +1924,7 @@ dword_50C9D8 = 1; ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; v2 = v723; continue; } @@ -2096,7 +2099,7 @@ ShowStatusBarString(v317, 2u); pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); v318 = &pParty->pPlayers[pCastSpell->uPlayerID_2]; - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; v318->PlaySound(SPEECH_43, 0); } @@ -2111,7 +2114,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } town_portal_caster_id = LOBYTE(pCastSpell->uPlayerID); @@ -2126,7 +2129,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } v319 = uRequiredMana; @@ -2139,8 +2142,8 @@ ::uRequiredMana = v319; ::sRecoveryTime = sRecoveryTime; dword_50633C = pCastSpell->sound_id; - dword_506338 = pCastSpell->spellnum; - LOBYTE(pCastSpell->field_8) |= 0x20u; + dword_506338 = pCastSpell->uSpellID; + pCastSpell->uFlags |= 0x20u; } break; } @@ -2186,7 +2189,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2219,14 +2222,14 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; pSpellSprite.uType = 4090; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2268,10 +2271,10 @@ LODWORD(v733) = v330; if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); LODWORD(v727) = 1; @@ -2294,7 +2297,7 @@ v342 = pCastSpell->spell_target_pid; if ( v342 == 0 ) { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_FATE].Apply(pParty->uTimePlayed + 1280, v731, amount, 0, 0); LODWORD(v727) = 1; @@ -2348,7 +2351,7 @@ break; } } - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); LODWORD(v727) = 1; break; } @@ -2362,7 +2365,7 @@ break; if ( v731 == 1 || v731 == 2 ) { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); LODWORD(v727) = 1; break; @@ -2372,7 +2375,7 @@ v357 = pParty->pPlayers;//[0].pPlayerBuffs[11]; do { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, a2); v357->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].Apply(pParty->uTimePlayed + v717, v731, 0, 0, 0); ++a2; ++v357;// = (SpellBuff *)((char *)v357 + 6972); @@ -2393,7 +2396,7 @@ pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xFFFFFFu, 0xC0u); ++pSpellSprite.uType; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2510,7 +2513,7 @@ } v388 = _v733; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, LOWORD(v682[_v733]) - 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, LOWORD(v682[_v733]) - 1); _v733 = v388 + 1; } while ( v388 + 1 < v730 ); @@ -2561,7 +2564,7 @@ } pParty->pPlayers[pCastSpell->uPlayerID_2].SetCondition(1u, 1); pParty->pPlayers[pCastSpell->uPlayerID_2].sHealth = 1; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); } LODWORD(v727) = 1; break; @@ -2580,7 +2583,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v323 = pCastSpell->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[12]; if ( !pParty->pPlayers[v323].pConditions[12] ) @@ -2617,7 +2620,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v323 = pCastSpell->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[3]; if ( !pParty->pPlayers[v323].pConditions[3] ) @@ -2719,7 +2722,7 @@ } ShowStatusBarString(pTmpBuf2.data(), 2u); pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2772,7 +2775,7 @@ pActors[v426].pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Long; } pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2822,7 +2825,7 @@ v731, 0, 0, 0); } pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2863,7 +2866,7 @@ pGame->GetStru6()->FadeScreen__like_Turn_Undead_and_mb_Armageddon(0xA0A0Au, 0xC0u); ++pSpellSprite.uType; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -2904,7 +2907,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v440 = pCastSpell->uPlayerID_2; if ( HIDWORD(pParty->pPlayers[v440].pConditions[5]) | LODWORD(pParty->pPlayers[v440].pConditions[5]) ) { @@ -2984,7 +2987,7 @@ break; } OpenedTelekinesis = true; - if ( pLevelDecorations[v445].field_16_event_id ) + if ( pLevelDecorations[v445].uEventID ) { EventProcessor(v448, a2, 1); LODWORD(v727) = 1; @@ -3015,7 +3018,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v323 = pCastSpell->uPlayerID_2; v324 = (char *)&pParty->pPlayers[v323].pConditions[1]; if ( !pParty->pPlayers[v323].pConditions[1] ) @@ -3054,7 +3057,7 @@ if (!v460) { pParty->pPlayers[pCastSpell->uPlayerID_2].Heal(amount); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); } else { @@ -3097,7 +3100,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v470 = pCastSpell->uPlayerID_2; if ( !(HIDWORD(pParty->pPlayers[v470].pConditions[6]) | LODWORD(pParty->pPlayers[v470].pConditions[6])) && !(HIDWORD(pParty->pPlayers[v470].pConditions[8]) | LODWORD(pParty->pPlayers[v470].pConditions[8])) @@ -3140,10 +3143,10 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); pParty->pPartyBuffs[PARTY_BUFF_PROTECTION_FROM_MAGIC].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, 0, 0); LODWORD(v727) = 1; @@ -3157,10 +3160,10 @@ break; if ( v731 == 4 ) { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); v732 = (int)v733 << 7; v717 = (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335); pParty->pPlayers[0].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + v717, 4u, v2, v2, 0); @@ -3171,7 +3174,7 @@ LODWORD(v727) = 1; break; } - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, v2, v2, 0); LODWORD(v727) = 1; @@ -3186,7 +3189,7 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); v498 = pCastSpell->uPlayerID_2; if ( !(HIDWORD(pParty->pPlayers[v498].pConditions[7]) | LODWORD(pParty->pPlayers[v498].pConditions[7])) && !(HIDWORD(pParty->pPlayers[v498].pConditions[9]) | LODWORD(pParty->pPlayers[v498].pConditions[9])) @@ -3232,7 +3235,7 @@ int v1 = 0; do { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, v1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, v1); v501->Heal(amount); ++v501; ++v1; @@ -3255,7 +3258,7 @@ v688.y = 0; v688.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3324,7 +3327,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[648], 2); // This character can't summon any more monsters! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -3347,10 +3350,10 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); pParty->pPartyBuffs[PARTY_BUFF_DAY_OF_GODS].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, 0, 0); LODWORD(v727) = 1; @@ -3363,7 +3366,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[497], 2); // Can't cast Prismatic Light outdoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -3374,7 +3377,7 @@ v694.y = 0; v694.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3422,10 +3425,10 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) break; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); v732 = v730 << 7; v549 = (double)(v730 << 7) * 0.033333335; @@ -3468,10 +3471,10 @@ *((float *)&v733) = (double)v732 * 0.033333335; do { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 0); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 1); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 2); - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, 3); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3); //((SpellBuff *)(v553 + 6056))->Apply( v553->pPlayerBuffs[4].Apply((signed __int64)((double)(signed __int64)pParty->uTimePlayed + *((float *)&v733)), v731, v730, 0, 0); @@ -3498,7 +3501,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -3521,11 +3524,11 @@ *(int *)(_this->uItemID + 6460) = v565; v567 = (*v566)->GetMaxMana(); *(int *)(_this->uItemID + 6464) = v567; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, a2); ++a2; _this = (ItemGen *)((char *)_this + 4); } - while ( (signed int)this < (signed int)&qword_A750D8 ); + while ( (signed int)_this < (signed int)&qword_A750D8 ); v571 = pPlayer; v572 = (char *)&pPlayer->sAgeModifier; if ( pPlayer->sAgeModifier + 10 >= 120 ) @@ -3554,7 +3557,7 @@ if (!v576) { v585 = (char *)&pParty->pPlayers[pCastSpell->uPlayerID_2]; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); if ( *((_QWORD *)v585 + 14) ) { ((Player *)v585)->SetCondition(0x11u, 1); @@ -3570,7 +3573,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[496], 2); // No valid target exists! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } v578 = (int)&pActors[(int)v577]; @@ -3579,12 +3582,12 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } ++pSpellSprite.uType; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3653,7 +3656,7 @@ ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } v592 = _v733; @@ -3685,7 +3688,7 @@ break; auto _v726 = ((signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360); pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3751,7 +3754,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } pActor->pActorBuffs[9].Reset(); @@ -3759,7 +3762,7 @@ pActor->pActorBuffs[12].Apply(pParty->uTimePlayed + (signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, 0, 0, 0); pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3835,7 +3838,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } v610 = 76 * v609; @@ -3880,7 +3883,7 @@ break; if ( v731 != 3 && v731 != 4 ) { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, pCastSpell->uPlayerID_2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, pCastSpell->uPlayerID_2); pParty->pPlayers[pCastSpell->uPlayerID_2].pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(signed int)((int)v733 << 7) * 0.033333335), v731, amount, v716, 0); LODWORD(v727) = 1; break; @@ -3890,7 +3893,7 @@ v619 = pParty->pPlayers;//[0].pPlayerBuffs[10]; do { - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, a2); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, a2); v619->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].Apply(pParty->uTimePlayed + v717, v731, amount, v716, 0); ++a2; ++v619; @@ -3910,7 +3913,7 @@ v707.y = 0; v707.z = 0; pSpellSprite.stru_24.Reset(); - pSpellSprite.spell_id = pCastSpell->spellnum; + pSpellSprite.spell_id = pCastSpell->uSpellID; pSpellSprite.spell_level = v2; pSpellSprite.spell_skill = v731; pSpellSprite.uObjectDescID = pObjectList->ObjectIDByItemID(pSpellSprite.uType); @@ -3975,7 +3978,7 @@ v726->sHealth = v726->GetMaxHealth(); v635 = _v733; - pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->spellnum, WORD2(v733)); + pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, WORD2(v733)); _v733 = v635 + 1; } while ( v635 + 1 < v730 ); @@ -3990,7 +3993,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[499], 2); // Can't cast Armageddon indoors! pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( v731 == 4) @@ -4001,7 +4004,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0); - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; continue; } if ( !pPlayer->CanCastSpell(uRequiredMana) ) @@ -4031,10 +4034,10 @@ default: break; } - if ( pCastSpell->field_8 & 0x20 ) + if ( pCastSpell->uFlags & 0x20 ) { if ( v727 != 0.0 ) - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->spellnum], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->uSpellID], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); } else { @@ -4057,63 +4060,52 @@ { pPlayer->PlaySound(SPEECH_49, 0); if ( v727 != 0.0 ) - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->spellnum], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[pCastSpell->uSpellID], 0, 0, -1, 0, pCastSpell->sound_id, 0, 0); } } - pCastSpell->spellnum = 0; + pCastSpell->uSpellID = 0; v2 = v723; continue; } } //----- (00427DA0) -------------------------------------------------------- -unsigned int CastSpellInfo::PushCastSpellInfo(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int spell_sound_id) +size_t PushCastSpellInfo(uint16_t uSpellID, uint16_t uPlayerID, __int16 skill_level, uint16_t uFlags, int spell_sound_id) { - for ( uint i = 0; i < 10; i++ ) + for (size_t i = 0; i < CastSpellInfoCount; i++) { - if ( !this[i].spellnum ) + if (!pCastSpellInfo[i].uSpellID) { - this[i].spellnum = a2; - this[i].uPlayerID = uPlayerID; - if ( a5 & 0x10 ) - this[i].uPlayerID_2 = uPlayerID; - this[i].field_6 = 0; - this[i].spell_target_pid = 0; - this[i].field_8 = a5; - this[i].forced_spell_skill_level = skill_level; - this[i].sound_id = spell_sound_id; + pCastSpellInfo[i].uSpellID = uSpellID; + pCastSpellInfo[i].uPlayerID = uPlayerID; + if (uFlags & 0x10) + pCastSpellInfo[i].uPlayerID_2 = uPlayerID; + pCastSpellInfo[i].field_6 = 0; + pCastSpellInfo[i].spell_target_pid = 0; + pCastSpellInfo[i].uFlags = uFlags; + pCastSpellInfo[i].forced_spell_skill_level = skill_level; + pCastSpellInfo[i].sound_id = spell_sound_id; return i; } } return -1; } //----- (00427D48) -------------------------------------------------------- -void CastSpellInfo::_427D48(unsigned int uPlayerID)//Press S +void CastSpellInfoHelpers::_427D48() { - CastSpellInfo *v2; // esi@1 - signed int v3; // ebx@1 - - v2 = this; - v3 = 10; - do + for (size_t i = 0; i < CastSpellInfoCount; i++) { - if ( v2->spellnum ) + if (pCastSpellInfo[i].uSpellID && pCastSpellInfo[i].uFlags & 0x3CA) { - if ( v2->field_8 & 0x3CA ) - { - v2->spellnum = 0; - pGUIWindow_Settings->Release(); - pGUIWindow_Settings = 0; - pMouse->SetCursorBitmap("MICON1"); - GameUI_Footer_TimeLeft = 0; - unk_50C9A0 = 0; - back_to_game(); - } + pCastSpellInfo[i].uSpellID = 0; + pGUIWindow_Settings->Release(); + pGUIWindow_Settings = 0; + pMouse->SetCursorBitmap("MICON1"); + GameUI_Footer_TimeLeft = 0; + unk_50C9A0 = 0; + back_to_game(); } - ++v2; - --v3; } - while ( v3 ); } //----- (0042777D) -------------------------------------------------------- void _42777D_CastSpell_UseWand_ShootArrow(int a1, unsigned int uPlayerID, unsigned int a4, __int16 a5, int a6) @@ -4316,24 +4308,22 @@ if (a5 & 0x3CA) { - assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo.data()) == 10); - for (uint i = 0; i < 10; ++i) - if (pCastSpellInfo[i].field_8 & 0x3CA) + for (uint i = 0; i < CastSpellInfoCount; ++i) + if (pCastSpellInfo[i].uFlags & 0x3CA) { - pCastSpellInfo[i].spellnum = 0; + pCastSpellInfo[i].uSpellID = 0; break; } } - assert(sizeof(pCastSpellInfo) / sizeof(*pCastSpellInfo.data()) == 10); - for (uint i = 0; i < 10; ++i) + for (uint i = 0; i < CastSpellInfoCount; ++i) { auto spell = &pCastSpellInfo[i]; - if (!spell->spellnum) + if (!spell->uSpellID) continue; - spell->spellnum = 0; - if (spell->field_8 & 0x3CA) + spell->uSpellID = 0; + if (spell->uFlags & 0x3CA) { pGUIWindow_Settings->Release(); pGUIWindow_Settings = nullptr; @@ -4344,7 +4334,7 @@ } } - int result = pCastSpellInfo.data()->PushCastSpellInfo(a1, uPlayerID, a4, a5, a6); + int result = PushCastSpellInfo(a1, uPlayerID, a4, a5, a6); if ( result != -1 ) { if ( a5 & 2 ) @@ -4422,101 +4412,3 @@ } } } - -const wchar_t *UIMessage2String(UIMessageType msg) -{ - #define CASE(xxx) case xxx: swprintf(b, wcslen(L"%03X/%s"), L"%03X/%s", msg, L#xxx); return b; - static wchar_t b[256]; // bad for threads - switch (msg) - { - CASE(UIMSG_SelectSpell) - CASE(UIMSG_ChangeGameState) - CASE(UIMSG_Attack) - CASE(UIMSG_PlayArcomage) - CASE(UIMSG_MainMenu_ShowPartyCreationWnd) - CASE(UIMSG_MainMenu_ShowLoadWindow) - CASE(UIMSG_ShowCredits) - CASE(UIMSG_ExitToWindows) - CASE(UIMSG_PlayerCreationChangeName) - CASE(UIMSG_PlayerCreationClickPlus) - CASE(UIMSG_PlayerCreationClickMinus) - CASE(UIMSG_PlayerCreationSelectActiveSkill) - CASE(UIMSG_PlayerCreationSelectClass) - CASE(UIMSG_PlayerCreationClickOK) - CASE(UIMSG_PlayerCreationClickReset) - CASE(UIMSG_ClickBooksBtn) - CASE(UIMSG_PlayerCreationRemoveUpSkill) - CASE(UIMSG_PlayerCreationRemoveDownSkill) - CASE(UIMSG_SPellbook_ShowHightlightedSpellInfo) - CASE(UIMSG_LoadGame) - CASE(UIMSG_SaveGame) - CASE(UIMSG_ShowStatus_DateTime) - CASE(UIMSG_ShowStatus_ManaHP) - CASE(UIMSG_ShowStatus_Player) - CASE(UIMSG_Wait5Minutes) - CASE(UIMSG_Wait1Hour) - CASE(UIMSG_ShowStatus_Food) - CASE(UIMSG_ShowStatus_Funds) - CASE(UIMSG_QuickReference) - CASE(UIMSG_GameMenuButton) - CASE(UIMSG_AlreadyResting) - CASE(UIMSG_SelectCharacter) - CASE(UIMSG_ChangeSoundVolume) - CASE(UIMSG_ChangeMusicVolume) - CASE(UIMSG_Escape) - CASE(UIMSG_PlayerCreation_SelectAttribute) - CASE(UIMSG_InventoryLeftClick) - CASE(UIMSG_SkillUp) - CASE(UIMSG_GameMenu_ReturnToGame) - CASE(UIMSG_StartNewGame) - CASE(UIMSG_Game_OpenLoadGameDialog) - CASE(UIMSG_Game_OpenSaveGameDialog) - CASE(UIMSG_Game_OpenOptionsDialog) - CASE(UIMSG_SetGraphicsMode) - CASE(UIMSG_Quit) - CASE(UIMSG_StartHireling1Dialogue) - CASE(UIMSG_StartHireling2Dialogue) - CASE(UIMSG_SelectNPCDialogueOption) - CASE(UIMSG_CastSpellFromBook) - CASE(UIMSG_PlayerCreation_VoicePrev) - CASE(UIMSG_PlayerCreation_VoiceNext) - CASE(UIMSG_StartNPCDialogue) - CASE(UIMSG_ArrowUp) - CASE(UIMSG_DownArrow) - CASE(UIMSG_SaveLoadBtn) - CASE(UIMSG_SelectLoadSlot) - CASE(UIMSG_Cancel) - CASE(UIMSG_ExitRest) - CASE(UIMSG_PlayerCreation_FacePrev) - CASE(UIMSG_PlayerCreation_FaceNext) - CASE(UIMSG_CycleCharacters) - CASE(UIMSG_SetTurnSpeed) - CASE(UIMSG_ToggleWalkSound) - CASE(UIMSG_ChangeVoiceVolume) - CASE(UIMSG_ToggleShowDamage) - CASE(UIMSG_ScrollNPCPanel) - CASE(UIMSG_ShowFinalWindow) - CASE(UIMSG_OpenQuestBook) - CASE(UIMSG_OpenAutonotes) - CASE(UIMSG_OpenMapBook) - CASE(UIMSG_OpenCalendar) - CASE(UIMSG_OpenHistoryBook) - CASE(UIMSG_ToggleAlwaysRun) - CASE(UIMSG_ToggleFlipOnExit) - CASE(UIMSG_Game_Action) - CASE(UIMSG_RentRoom) - CASE(UIMSG_TransitionUI_Confirm) - CASE(UIMSG_OpenKeyMappingOptions) - CASE(UIMSG_SelectKeyPage1) - CASE(UIMSG_SelectKeyPage2) - CASE(UIMSG_ResetKeyMapping) - CASE(UIMSG_ChangeKeyButton) - CASE(UIMSG_OpenVideoOptions) - CASE(UIMSG_ToggleBloodsplats) - CASE(UIMSG_ToggleColoredLights) - CASE(UIMSG_ToggleTint) - default: - swprintf(b, wcslen(L"UIMSG_%03X") , L"UIMSG_%03X", msg); return b; - }; - #undef CASE -} \ No newline at end of file diff -r 58d15177edd0 -r 863de6ec906b CastSpellInfo.h --- a/CastSpellInfo.h Thu Sep 05 13:12:53 2013 +0600 +++ b/CastSpellInfo.h Thu Sep 05 13:31:15 2013 +0600 @@ -1,6 +1,14 @@ #pragma once + +#include + #include +namespace CastSpellInfoHelpers +{ + void _427D48(); + void _427E01_cast_spell(); +}; /* 271 */ #pragma pack(push, 1) @@ -9,30 +17,18 @@ //----- (00426987) -------------------------------------------------------- inline CastSpellInfo() { - field_8 = 0; - spellnum = 0; - field_6 = 0; - uPlayerID_2 = 0; - uPlayerID = 0; - sound_id = 0; + memset(this, 0, sizeof(this)); } - void _427D48(unsigned int uPlayerID); - unsigned int PushCastSpellInfo(__int16 a2, __int16 uPlayerID, __int16 skill_level, __int16 a5, int sound_id); struct GUIWindow *GetCastSpellInInventoryWindow(); - void _427E01_cast_spell(); - __int16 spellnum; - unsigned __int16 uPlayerID; - __int16 uPlayerID_2; + uint16_t uSpellID; + uint16_t uPlayerID; + uint16_t uPlayerID_2; __int16 field_6; - __int16 field_8; + uint16_t uFlags; __int16 forced_spell_skill_level; int spell_target_pid; int sound_id; }; #pragma pack(pop) - - -extern std::array pCastSpellInfo; -extern CastSpellInfo stru_50CDB4; // idb diff -r 58d15177edd0 -r 863de6ec906b DecalBuilder.h --- a/DecalBuilder.h Thu Sep 05 13:12:53 2013 +0600 +++ b/DecalBuilder.h Thu Sep 05 13:31:15 2013 +0600 @@ -1,4 +1,7 @@ #pragma once + +#include + #include "Render.h" /* 158 */ @@ -120,7 +123,7 @@ __int16 field_C0A; __int16 field_C0C; __int16 field_C0E; - uint uColorMultiplier; + uint32_t uColorMultiplier; int field_C14; DecalBuilder_stru0 *field_C18; int field_C1C; diff -r 58d15177edd0 -r 863de6ec906b GUIWindow.h --- a/GUIWindow.h Thu Sep 05 13:12:53 2013 +0600 +++ b/GUIWindow.h Thu Sep 05 13:31:15 2013 +0600 @@ -1,10 +1,9 @@ #pragma once -#include "Player.h" + +#include #include - - - +#include "Player.h" enum UIMessageType: unsigned __int32 { @@ -566,7 +565,7 @@ // transition & travel ui -void TransitionUI_Load(uint anim_id, uint exit_pic_id, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName); +void TransitionUI_Load(uint32_t anim_id, uint32_t exit_pic_id, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName); void TransitionUI_Draw(); void TravelUI_Load(); diff -r 58d15177edd0 -r 863de6ec906b Indoor.cpp --- a/Indoor.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/Indoor.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -3897,7 +3897,7 @@ } } - if (!pDecortaion->field_16_event_id) + if (!pDecortaion->uEventID) { if (pDecortaion->IsInteractive()) { @@ -6155,7 +6155,7 @@ case OBJECT_Decoration: v8 = &pLevelDecorations[PID_ID(a1)]; - v9 = v8->field_16_event_id; + v9 = v8->uEventID; if ( v9 ) { EventProcessor(v9, a1, 1); diff -r 58d15177edd0 -r 863de6ec906b Indoor.h --- a/Indoor.h Thu Sep 05 13:12:53 2013 +0600 +++ b/Indoor.h Thu Sep 05 13:31:15 2013 +0600 @@ -1,4 +1,5 @@ #pragma once + #include "Level/Decoration.h" #include "Indoor_stuff.h" diff -r 58d15177edd0 -r 863de6ec906b Indoor_stuff.h --- a/Indoor_stuff.h Thu Sep 05 13:12:53 2013 +0600 +++ b/Indoor_stuff.h Thu Sep 05 13:31:15 2013 +0600 @@ -1,4 +1,7 @@ #pragma once + +#include + #include "Render.h" #include "IndoorCameraD3D.h" diff -r 58d15177edd0 -r 863de6ec906b Level/Decoration.h --- a/Level/Decoration.h Thu Sep 05 13:12:53 2013 +0600 +++ b/Level/Decoration.h Thu Sep 05 13:31:15 2013 +0600 @@ -1,8 +1,10 @@ #pragma once -#include "../mm7_data.h" +#include -enum LEVEL_DECORATION_FLAGS: uint16 +#include "../VectorTypes.h" + +enum LEVEL_DECORATION_FLAGS: uint16_t { LEVEL_DECORATION_TRIGGERED_BY_TOUCH = 0x01, LEVEL_DECORATION_TRIGGERED_BY_MONSTER = 0x02, @@ -22,15 +24,15 @@ bool IsInteractive(); bool IsObeliskChestActive(); - uint16 uDecorationDescID; - uint16 uFlags; + uint16_t uDecorationDescID; + uint16_t uFlags; Vec3_int_ vPosition; - int32 field_10_y_rot; - uint16 uCog; - int16 field_16_event_id; - int16 field_18; - int16 field_1A; - int16 _idx_in_stru123; - int16 field_1E; + int32_t field_10_y_rot; + uint16_t uCog; + uint16_t uEventID; + uint16_t uTriggerRange; + int16_t field_1A; + int16_t _idx_in_stru123; + int16_t field_1E; }; #pragma pack(pop) diff -r 58d15177edd0 -r 863de6ec906b Outdoor.cpp --- a/Outdoor.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/Outdoor.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -2718,7 +2718,7 @@ } if ( v8 && decor->uCog == 20 ) decor->uFlags |= LEVEL_DECORATION_OBELISK_CHEST; - if ( !decor->field_16_event_id ) + if ( !decor->uEventID ) { if ( decor->IsInteractive() ) { diff -r 58d15177edd0 -r 863de6ec906b Party.cpp --- a/Party.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/Party.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -1222,10 +1222,6 @@ { if ( _506F18_num_minutes_to_sleep < 6 ) { - pParty->pPlayers[3].SetAsleep(false); - pParty->pPlayers[2].SetAsleep(false); - pParty->pPlayers[1].SetAsleep(false); - pParty->pPlayers[0].SetAsleep(false); if ( _506F18_num_minutes_to_sleep ) { Rest(_506F18_num_minutes_to_sleep); @@ -1234,25 +1230,8 @@ } 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->RemoveTexturesPackFromTextureList(); - pIcons_LOD->SyncLoadedFilesCount(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) - { - pOutdoor->UpdateSunlightVectors(); - pOutdoor->UpdateFog(); - } + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); } - dword_506F14 = 0; } else { diff -r 58d15177edd0 -r 863de6ec906b Render.cpp --- a/Render.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/Render.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -2103,7 +2103,7 @@ hd_water_current_frame = 0; } -bool Render::Initialize(bool bWindowed, uint uDefaultDevice, bool bColoredLights, uint uDetailLevel, uint bTinting) +bool Render::Initialize(bool bWindowed, uint32_t uDefaultDevice, bool bColoredLights, uint32_t uDetailLevel, bool bTinting) { bUserDirect3D = true;//ReadWindowsRegistryInt("Use D3D", 0); bStartInWindow = bWindowed; diff -r 58d15177edd0 -r 863de6ec906b Render.h --- a/Render.h Thu Sep 05 13:12:53 2013 +0600 +++ b/Render.h Thu Sep 05 13:31:15 2013 +0600 @@ -1,5 +1,7 @@ #pragma once -#include + +#include +#include #include "lib\legacy_dx\d3d.h" #include "OSAPI.h" @@ -169,7 +171,7 @@ HWLTexture *LoadTexture(const char *pName, int bMipMaps); FILE *pFile; - uint uSignature; + uint32_t uSignature; unsigned int uDataOffset; unsigned int uNumItems; char *pSpriteNames[50000]; @@ -267,8 +269,8 @@ static Render *Create() {return new Render;} - bool Initialize(bool bWindowed, uint uDefaultDevice, - bool bColoredLights, uint uDetailLevel, uint bTinting); + bool Initialize(bool bWindowed, uint32_t uDefaultDevice, + bool bColoredLights, uint32_t uDetailLevel, bool bTinting); bool IsColorKeySupported(IDirectDraw4 *); @@ -435,7 +437,7 @@ unsigned int uMinDeviceTextureDim; int field_10365C; unsigned int bUsingSpecular; - uint uFogColor; + uint32_t uFogColor; int field_103668; unsigned int pHDWaterBitmapIDs[7]; char field_103688[32]; @@ -447,7 +449,7 @@ int _gpu_memory_used; void ( *pBeforePresentFunction)(); int field_1036C4; - uint bFogEnabled; + uint32_t bFogEnabled; int field_1036CC; RenderBillboardD3D pBillboardRenderListD3D[1000]; unsigned int uNumBillboardsToDraw; diff -r 58d15177edd0 -r 863de6ec906b Spells.cpp --- a/Spells.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/Spells.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -441,7 +441,7 @@ } //----- (00448DF8) -------------------------------------------------------- -void __fastcall EventCastSpell(int spellnum, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz)//sub_448DF8 +void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz)//sub_448DF8 { int v9; // esi@1 double v10; // st7@4 @@ -509,7 +509,7 @@ v9 = 0; v59 = uSkillLevel + 1; - //spellnum_ = spellnum; + //spellnum_ = uSpellID; v60 = 0; if ( tox || toy || toz ) { @@ -552,12 +552,12 @@ SpriteObject a1; // [sp+38h] [bp-7Ch]@12 //SpriteObject::SpriteObject(&a1); - a1.uType = stru_4E3ACC[spellnum].uType; - if ( spellnum > 58 ) + a1.uType = stru_4E3ACC[uSpellID].uType; + if ( uSpellID > 58 ) { - if ( spellnum == 69 ) + if ( uSpellID == 69 ) goto LABEL_117; - if ( spellnum != 83 ) + if ( uSpellID != 83 ) return; v40 = v15 - 2; if ( v40 ) @@ -604,9 +604,9 @@ v37->Apply(v36, a7b, v43, 0, 0); goto LABEL_139; } - if ( spellnum != 58 ) + if ( uSpellID != 58 ) { - switch ( spellnum ) + switch ( uSpellID ) { case 2: case 6: @@ -618,7 +618,7 @@ case 41: a1.stru_24.Reset(); v16 = 0; - a1.spell_id = spellnum; + a1.spell_id = uSpellID; a1.spell_level = uSkill; a1.spell_skill = v15; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -703,7 +703,7 @@ a8b = a7c / (v60 - 1); a1.stru_24.Reset(); v21 = 0; - a1.spell_id = spellnum; + a1.spell_id = uSpellID; a1.spell_level = uSkill; a1.spell_skill = v15; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -759,7 +759,7 @@ } a1.stru_24.Reset(); v16 = 0; - a1.spell_id = spellnum; + a1.spell_id = uSpellID; a1.spell_level = uSkill; a1.spell_skill = v15; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -849,7 +849,7 @@ a8c = (signed int)(60 * stru_5C6E00->uIntegerDoublePi) / 360 / (v60 - 1); a1.stru_24.Reset(); v25 = 0; - a1.spell_id = spellnum; + a1.spell_id = uSpellID; a1.spell_level = uSkill; a1.spell_skill = v15; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -924,7 +924,7 @@ return; a1.stru_24.Reset(); v29 = 0; - a1.spell_id = spellnum; + a1.spell_id = uSpellID; a1.spell_level = uSkill; a1.spell_skill = v15; if ( (signed int)pObjectList->uNumObjects <= 0 ) @@ -985,10 +985,10 @@ 0, 0); //v33 = spellnum_; - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 3); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); goto LABEL_138; case 17: case 38: @@ -1006,7 +1006,7 @@ v9 = 3600 * (uSkill + 1); break; } - switch ( spellnum ) + switch ( uSpellID ) { case 17: v60 = 0; @@ -1023,10 +1023,10 @@ v60 = v34; break; } - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 3); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); v52 = 0; v50 = 0; v48 = v60; @@ -1040,10 +1040,10 @@ v38 = 60 * uSkill; else v38 = 600 * uSkill; - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 3); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); v52 = 0; v50 = 0; v48 = uSkill; @@ -1131,7 +1131,7 @@ goto LABEL_125; } LABEL_125: - switch ( spellnum ) + switch ( uSpellID ) { case 3: uSkill = 6; @@ -1153,16 +1153,16 @@ break; } //v45 = spellnum_; - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 0); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 1); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 2); - pGame->pStru6Instance->SetPlayerBuffAnim(spellnum, 3); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 1); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 2); + pGame->pStru6Instance->SetPlayerBuffAnim(uSpellID, 3); pParty->pPartyBuffs[uSkill].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)a6_4 * 4.2666669), v15, v60, 0, 0); //levela = 1; LABEL_138: //if ( levela ) LABEL_139: - pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[spellnum], 0, 0, fromx, fromy, 0, 0, 0); + pAudioPlayer->PlaySound((SoundID)word_4EE088_sound_ids[uSpellID], 0, 0, fromx, fromy, 0, 0, 0); } //----- (00427769) -------------------------------------------------------- bool __fastcall sub_427769_spell(unsigned int uSpellID) diff -r 58d15177edd0 -r 863de6ec906b UI/UICharacter.cpp --- a/UI/UICharacter.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/UI/UICharacter.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -1764,7 +1764,7 @@ } } } - memset(byte_5111F6.data(), 0, 16); + memset(byte_5111F6.data(), 0, sizeof(byte_5111F6)); for (uint i = 0; i < 4; ++i) { auto player = pParty->pPlayers + i; diff -r 58d15177edd0 -r 863de6ec906b UI/UiGame.cpp diff -r 58d15177edd0 -r 863de6ec906b VectorTypes.cpp --- a/VectorTypes.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/VectorTypes.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -1,45 +1,43 @@ +#include + #include "mm7_data.h" +//----- (004621DA) -------------------------------------------------------- +uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z) +{ + if (x < y) + { + std::swap(x, y); + } + if (x < z) + { + std::swap(x, z); + } + if (y < z) + { + std::swap(y, z); + } + + return x + (11 * y >> 5) + (z >> 2); +} + //----- (0044C362) -------------------------------------------------------- -void Vec3_int_::Normalize_float() +template +void Vec3::Normalize_float() { - //Vec3_int_ *v1; // esi@1 - double v2; // st6@1 - float v3; // ST20_4@1 - double v4; // st5@1 - float v5; // ST18_4@1 - double v6; // st4@1 - float v7; // ST14_4@1 - float v8; // ST24_4@1 - float v9; // ST20_4@1 - double v10; // ST0C_8@1 - float v11; // ST18_4@1 - double v12; // ST0C_8@1 - float v13; // ST14_4@1 - double v14; // ST0C_8@1 + long double x = this->x; + long double y = this->y; + long double z = this->z; + long double s = sqrtl(x * x + y * y + z * z); - assert(false); - //v1 = this; - v2 = (double)this->x * 0.000015258789; - v3 = v2; - v4 = (double)this->y * 0.000015258789; - v5 = v4; - v6 = (double)this->z * 0.000015258789; - v7 = v6; - v8 = 1.0 / sqrt(v6 * v6 + v4 * v4 + v2 * v2); - v9 = v8 * v3 * 65536.0; - v10 = v9 + 6.7553994e15; - this->x = LODWORD(v10); - v11 = v8 * v5 * 65536.0; - v12 = v11 + 6.7553994e15; - this->y = LODWORD(v12); - v13 = v8 * v7 * 65536.0; - v14 = v13 + 6.7553994e15; - this->z = LODWORD(v14); + this->x = (T)(x / s); + this->y = (T)(y / s); + this->z = (T)(z / s); } //----- (0043AA99) -------------------------------------------------------- -void __fastcall Vec3_int_::Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz) +template +void __fastcall Vec3::Rotate(T sDepth, T sRotY, T sRotX, Vec3 v, T *outx, T *outy, T *outz) { float cosf_x = cosf(3.14159265f * sRotX / 1024.0f), sinf_x = sinf(3.14159265f * sRotX / 1024.0f), @@ -52,9 +50,12 @@ } //----- (0043AB61) -------------------------------------------------------- -void Vec3_int_::Normalize(int *x, int *y, int *z) +template +void Vec3::Normalize(T *x, T *y, T *z) { *x *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); *y *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); *z *= 65536 / (integer_sqrt(*y * *y + *z * *z + *x * *x) | 1); } + +template Vec3; diff -r 58d15177edd0 -r 863de6ec906b VectorTypes.h --- a/VectorTypes.h Thu Sep 05 13:12:53 2013 +0600 +++ b/VectorTypes.h Thu Sep 05 13:31:15 2013 +0600 @@ -1,29 +1,67 @@ #pragma once -typedef unsigned __int32 uint; +#include + +uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z); + +#pragma pack(push, 1) +template +struct Vec2 +{ + T x; + T y; + + inline Vec2(T a = 0, T b = 0): + x(a), y(b) + {} +}; +#pragma pack(pop) + +#define Vec2_int_ Vec2 +#define Vec2_float_ Vec2 #pragma pack(push, 1) -struct Vec2_short_ +template +struct Vec3: public Vec2 { - __int16 x; - __int16 y; + T z; + + inline Vec3(T a = 0, T b = 0, T c = 0): + Vec2(a, b), z(c) + {} + + void Normalize_float(); + template + inline uint32_t GetDistanceTo(Vec3 &o) + { + return int_get_vector_length( + abs(this->x - o.x), + abs(this->y - o.y), + abs(this->z - o.z) + ); + } + + static void __fastcall Rotate(T sDepth, T sRotY, T sRotX, Vec3 v, T *outx, T *outy, T *outz); + static void Normalize(T *x, T *y, T *z); }; #pragma pack(pop) +#define Vec3_short_ Vec3 +#define Vec3_int_ Vec3 + #pragma pack(push, 1) struct Vec3_float_ { void Normalize(); - -//----- (0049B32D) -------------------------------------------------------- -static Vec3_float_ *Vec3_float_::Cross(Vec3_float_ *v1, Vec3_float_ *pOut, float x, float y, float z) -{ - pOut->x = z * v1->y - y * v1->z; - pOut->y = x * v1->z - z * v1->x; - pOut->z = y * v1->x - x * v1->y; - return pOut; -} + //----- (0049B32D) -------------------------------------------------------- + static Vec3_float_ *Vec3_float_::Cross(Vec3_float_ *v1, Vec3_float_ *pOut, float x, float y, float z) + { + pOut->x = z * v1->y - y * v1->z; + pOut->y = x * v1->z - z * v1->x; + pOut->z = y * v1->x - x * v1->y; + return pOut; + } //----- (0049B02E) -------------------------------------------------------- inline static float NegDot(Vec3_float_ *a1, Vec3_float_ *a2, float *a3) @@ -37,54 +75,6 @@ }; #pragma pack(pop) - -#pragma pack(push, 1) -struct Vec2_int_ -{ - int x; - int y; -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct Vec2_float_ -{ - float x; - float y; -}; -#pragma pack(pop) - - -#pragma pack(push, 1) -struct Vec3_short_ -{ - __int16 x; - __int16 y; - __int16 z; -}; -#pragma pack(pop) - -#pragma pack(push, 1) -struct Vec3_int_ -{ - inline Vec3_int_(): - x(0), y(0), z(0) - {} - inline Vec3_int_(int a, int b = 0, int c = 0): - x(a), y(b), z(c) - {} - - void Normalize_float(); - - static void __fastcall Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz); - static void Normalize(int *x, int *y, int *z); - - int x; - int y; - int z; -}; -#pragma pack(pop) - #pragma pack(push, 1) struct Vec4_int_ { @@ -95,11 +85,6 @@ }; #pragma pack(pop) - - - - - /* 82 */ #pragma pack(push, 1) struct Plane_int_ @@ -109,7 +94,6 @@ }; #pragma pack(pop) - #pragma pack(push, 1) struct BBox_short_ { @@ -142,9 +126,6 @@ }; #pragma pack(pop) - - - /* 196 */ #pragma pack(push, 1) struct Matrix3x3_float_ @@ -161,4 +142,3 @@ }; }; #pragma pack(pop) - diff -r 58d15177edd0 -r 863de6ec906b Viewport.cpp --- a/Viewport.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/Viewport.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -533,7 +533,7 @@ pIcons_LOD->SyncLoadedFilesCount(); return; } - if ( !pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].field_16_event_id ) + if ( !pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uEventID ) { if ( pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].IsInteractive() ) { @@ -544,7 +544,7 @@ } return; } - pEventID = pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].field_16_event_id; + pEventID = pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3].uEventID; } if ( PID_TYPE(v0) == OBJECT_BModel && HIWORD(v0) < clickable_distance) { diff -r 58d15177edd0 -r 863de6ec906b Vis.cpp --- a/Vis.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/Vis.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -1433,7 +1433,7 @@ MessageBoxA(nullptr, "Unsupported \"exclusion if no event\" type in CVis::is_part_of_selection", "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Vis.cpp:207", 0); return true; } - if (pLevelDecorations[object_idx].uCog || pLevelDecorations[object_idx].field_16_event_id) + if (pLevelDecorations[object_idx].uCog || pLevelDecorations[object_idx].uEventID) return true; return pLevelDecorations[object_idx].IsInteractive(); } diff -r 58d15177edd0 -r 863de6ec906b _deleted.cpp --- a/_deleted.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/_deleted.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -12276,4 +12276,101 @@ while ( v16 != 1 ); } } +const wchar_t *UIMessage2String(UIMessageType msg) +{ + #define CASE(xxx) case xxx: swprintf(b, wcslen(L"%03X/%s"), L"%03X/%s", msg, L#xxx); return b; + static wchar_t b[256]; // bad for threads + switch (msg) + { + CASE(UIMSG_SelectSpell) + CASE(UIMSG_ChangeGameState) + CASE(UIMSG_Attack) + CASE(UIMSG_PlayArcomage) + CASE(UIMSG_MainMenu_ShowPartyCreationWnd) + CASE(UIMSG_MainMenu_ShowLoadWindow) + CASE(UIMSG_ShowCredits) + CASE(UIMSG_ExitToWindows) + CASE(UIMSG_PlayerCreationChangeName) + CASE(UIMSG_PlayerCreationClickPlus) + CASE(UIMSG_PlayerCreationClickMinus) + CASE(UIMSG_PlayerCreationSelectActiveSkill) + CASE(UIMSG_PlayerCreationSelectClass) + CASE(UIMSG_PlayerCreationClickOK) + CASE(UIMSG_PlayerCreationClickReset) + CASE(UIMSG_ClickBooksBtn) + CASE(UIMSG_PlayerCreationRemoveUpSkill) + CASE(UIMSG_PlayerCreationRemoveDownSkill) + CASE(UIMSG_SPellbook_ShowHightlightedSpellInfo) + CASE(UIMSG_LoadGame) + CASE(UIMSG_SaveGame) + CASE(UIMSG_ShowStatus_DateTime) + CASE(UIMSG_ShowStatus_ManaHP) + CASE(UIMSG_ShowStatus_Player) + CASE(UIMSG_Wait5Minutes) + CASE(UIMSG_Wait1Hour) + CASE(UIMSG_ShowStatus_Food) + CASE(UIMSG_ShowStatus_Funds) + CASE(UIMSG_QuickReference) + CASE(UIMSG_GameMenuButton) + CASE(UIMSG_AlreadyResting) + CASE(UIMSG_SelectCharacter) + CASE(UIMSG_ChangeSoundVolume) + CASE(UIMSG_ChangeMusicVolume) + CASE(UIMSG_Escape) + CASE(UIMSG_PlayerCreation_SelectAttribute) + CASE(UIMSG_InventoryLeftClick) + CASE(UIMSG_SkillUp) + CASE(UIMSG_GameMenu_ReturnToGame) + CASE(UIMSG_StartNewGame) + CASE(UIMSG_Game_OpenLoadGameDialog) + CASE(UIMSG_Game_OpenSaveGameDialog) + CASE(UIMSG_Game_OpenOptionsDialog) + CASE(UIMSG_SetGraphicsMode) + CASE(UIMSG_Quit) + CASE(UIMSG_StartHireling1Dialogue) + CASE(UIMSG_StartHireling2Dialogue) + CASE(UIMSG_SelectNPCDialogueOption) + CASE(UIMSG_CastSpellFromBook) + CASE(UIMSG_PlayerCreation_VoicePrev) + CASE(UIMSG_PlayerCreation_VoiceNext) + CASE(UIMSG_StartNPCDialogue) + CASE(UIMSG_ArrowUp) + CASE(UIMSG_DownArrow) + CASE(UIMSG_SaveLoadBtn) + CASE(UIMSG_SelectLoadSlot) + CASE(UIMSG_Cancel) + CASE(UIMSG_ExitRest) + CASE(UIMSG_PlayerCreation_FacePrev) + CASE(UIMSG_PlayerCreation_FaceNext) + CASE(UIMSG_CycleCharacters) + CASE(UIMSG_SetTurnSpeed) + CASE(UIMSG_ToggleWalkSound) + CASE(UIMSG_ChangeVoiceVolume) + CASE(UIMSG_ToggleShowDamage) + CASE(UIMSG_ScrollNPCPanel) + CASE(UIMSG_ShowFinalWindow) + CASE(UIMSG_OpenQuestBook) + CASE(UIMSG_OpenAutonotes) + CASE(UIMSG_OpenMapBook) + CASE(UIMSG_OpenCalendar) + CASE(UIMSG_OpenHistoryBook) + CASE(UIMSG_ToggleAlwaysRun) + CASE(UIMSG_ToggleFlipOnExit) + CASE(UIMSG_Game_Action) + CASE(UIMSG_RentRoom) + CASE(UIMSG_TransitionUI_Confirm) + CASE(UIMSG_OpenKeyMappingOptions) + CASE(UIMSG_SelectKeyPage1) + CASE(UIMSG_SelectKeyPage2) + CASE(UIMSG_ResetKeyMapping) + CASE(UIMSG_ChangeKeyButton) + CASE(UIMSG_OpenVideoOptions) + CASE(UIMSG_ToggleBloodsplats) + CASE(UIMSG_ToggleColoredLights) + CASE(UIMSG_ToggleTint) + default: + swprintf(b, wcslen(L"UIMSG_%03X") , L"UIMSG_%03X", msg); return b; + }; + #undef CASE +} */ \ No newline at end of file diff -r 58d15177edd0 -r 863de6ec906b mm7_2.cpp --- a/mm7_2.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/mm7_2.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -1786,7 +1786,7 @@ { auto decor = &pLevelDecorations[i]; - if (!decor->field_16_event_id) + if (!decor->uEventID) { if (decor->IsInteractive()) { @@ -3113,32 +3113,6 @@ event_triggers[num_event_triggers++] = i; } -//----- (004621DA) -------------------------------------------------------- -int int_get_vector_length(signed int x, signed int y, signed int z) -{ - signed int v3; // eax@2 - - if ( x < y ) - { - v3 = x; - x = y; - y = v3; - } - if ( x < z ) - { - v3 = x; - x = z; - z = v3; - } - if ( y < z ) - { - v3 = y; - y = z; - z = v3; - } - return (11 * y >> 5) + x + (z >> 2); -} - OPENFILENAMEA ofn; //----- (0046271C) -------------------------------------------------------- void CreateDefaultBLVLevel() @@ -3942,7 +3916,7 @@ pEventTimer->Pause(); pMiscTimer->Pause(); pParty->uFlags = 2; - pCastSpellInfo.data()->_427D48(1); + CastSpellInfoHelpers::_427D48(); ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); DoPrepareWorld(0, (_0_box_loading_1_fullscreen == 0) + 1); pMiscTimer->Resume(); @@ -6182,7 +6156,7 @@ } v25 = &pLevelDecorations[v20]; v26 = v25; - v27 = v25->field_16_event_id; + v27 = v25->uEventID; if ( v27 ) { v23 = GetEventHintString(v27); diff -r 58d15177edd0 -r 863de6ec906b mm7_3.cpp --- a/mm7_3.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/mm7_3.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -7190,40 +7190,25 @@ } //----- (0044882F) -------------------------------------------------------- -void __fastcall SetDecorationSprite(unsigned int uCog, int a2, const char *pFileName) +void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName) { - signed int v3; // ebp@1 - char *v4; // esi@2 - unsigned __int16 v5; // ax@6 - unsigned int v6; // [sp+4h] [bp-8h]@1 - int v7; // [sp+8h] [bp-4h]@1 - - v3 = 0; - v7 = a2; - v6 = uCog; - if ( (signed int)uNumLevelDecorations > 0 ) - { - v4 = (char *)&pLevelDecorations[0].uFlags; - do + for (size_t i = 0; i < uNumLevelDecorations; i++) + { + if (pLevelDecorations[i].uCog == uCog) { - if ( *((_WORD *)v4 + 9) == v6 ) + if (pFileName && strcmp(pFileName, "0")) { - if ( pFileName && _stricmp(pFileName, "0") ) - { - v5 = pDecorationList->GetDecorIdByName(pFileName); - *((_WORD *)v4 - 1) = v5; - pDecorationList->InitializeDecorationSprite((signed __int16)v5); - } - if ( v7 ) - *v4 &= 0xDFu; - else - *v4 |= 0x20u; - pParty->uFlags |= 2u; + pLevelDecorations[i].uDecorationDescID = pDecorationList->GetDecorIdByName(pFileName); + pDecorationList->InitializeDecorationSprite(pLevelDecorations[i].uDecorationDescID); } - ++v3; - v4 += 32; + + if (bHide) + pLevelDecorations[i].uFlags &= ~LEVEL_DECORATION_INVISIBLE; + else + pLevelDecorations[i].uFlags |= LEVEL_DECORATION_INVISIBLE; + + pParty->uFlags |= 2u; } - while ( v3 < (signed int)uNumLevelDecorations ); } } @@ -7580,7 +7565,7 @@ pParty->vPosition.z = _5B65B0_npcdata_rep_or_other; pParty->uFallStartY = _5B65B0_npcdata_rep_or_other; } - if ( _5B65B4_npcdata_loword_house_or_other ) + if ( _5B65B4_npcdata_loword_house_or_other != -1 ) pParty->sRotationY = _5B65B4_npcdata_loword_house_or_other; if ( _5B65B8_npcdata_hiword_house_or_other ) pParty->sRotationX = _5B65B8_npcdata_hiword_house_or_other; diff -r 58d15177edd0 -r 863de6ec906b mm7_4.cpp --- a/mm7_4.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/mm7_4.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -49,165 +49,33 @@ //----- (0046CC4B) -------------------------------------------------------- void check_event_triggers() { - int v0; // eax@1 LevelDecoration *v1; // esi@2 - signed int v2; // edi@2 - int v3; // ebx@2 - int v4; // eax@3 - int v5; // ebx@3 - unsigned int v6; // ecx@3 - unsigned int v7; // edx@6 - unsigned int v8; // edx@8 - Actor *v9; // edi@13 - int v10; // ebx@14 - int v11; // eax@14 - int v12; // ebx@14 - unsigned int v13; // ecx@14 - int v14; // edx@15 - unsigned int v15; // edx@17 - unsigned int v16; // edx@19 - char *v17; // edi@25 - int v18; // ebx@26 - int v19; // eax@26 - int v20; // ebx@26 - unsigned int v21; // ecx@26 - int v22; // edx@27 - unsigned int v23; // edx@29 - unsigned int v24; // edx@31 - int v25; // [sp+0h] [bp-24h]@3 - int v26; // [sp+0h] [bp-24h]@14 - int v27; // [sp+0h] [bp-24h]@26 - int v28; // [sp+4h] [bp-20h]@3 - int v29; // [sp+4h] [bp-20h]@14 - int v30; // [sp+4h] [bp-20h]@26 - signed int v31; // [sp+8h] [bp-1Ch]@2 - int v32; // [sp+Ch] [bp-18h]@2 - int v33; // [sp+10h] [bp-14h]@2 - int i; // [sp+14h] [bp-10h]@1 - int v35; // [sp+18h] [bp-Ch]@2 - int v36; // [sp+1Ch] [bp-8h]@3 - signed int v37; // [sp+1Ch] [bp-8h]@12 - signed int v38; // [sp+20h] [bp-4h]@24 - v0 = 0; - for ( i = 0; i < num_event_triggers; ++i ) + for (size_t i = 0; i < num_event_triggers; i++) { - v1 = &pLevelDecorations[event_triggers[v0]]; - v2 = v1->field_18; - v3 = v1->vPosition.y; - v33 = v1->vPosition.x; - v32 = v1->vPosition.y; - v35 = v1->vPosition.z; - v31 = v1->field_18; - if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_TOUCH) + v1 = &pLevelDecorations[event_triggers[i]]; + + if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_TOUCH + && v1->vPosition.GetDistanceTo(pParty->vPosition) < v1->uTriggerRange) { - v36 = abs(v1->vPosition.x - pParty->vPosition.x); - v25 = abs(v3 - pParty->vPosition.y); - v28 = abs(v35 - pParty->vPosition.z); - v4 = v36; - v5 = v25; - v6 = v28; - if ( v36 < v25 ) - { - v4 = v25; - v5 = v36; - } - if ( v4 < v28 ) - { - v7 = v4; - v4 = v28; - v6 = v7; - } - if ( v5 < (signed int)v6 ) - { - v8 = v6; - v6 = v5; - v5 = v8; - } - if ( (signed int)(((unsigned int)(11 * v5) >> 5) + (v6 >> 2) + v4) < v2 ) - EventProcessor(v1->field_16_event_id, PID(OBJECT_Decoration,i), 1); + EventProcessor(v1->uEventID, PID(OBJECT_Decoration,i), 1); } - if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_MONSTER) + else if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_MONSTER) { - v37 = 0; - if ( (signed int)uNumActors > 0 ) + for (size_t j = 0; j < uNumActors; j++) { - v9 = pActors.data();//[0].vPosition.y; - do - { - v10 = abs(v33 - v9->vPosition.x); - v29 = abs(v32 - v9->vPosition.y); - v26 = abs(v35 - v9->vPosition.z); - v11 = v10; - v12 = v29; - v13 = v26; - if ( v11 < v29 ) - { - v14 = v11; - v11 = v29; - v12 = v14; - } - if ( v11 < v26 ) - { - v15 = v11; - v11 = v26; - v13 = v15; - } - if ( v12 < (signed int)v13 ) - { - v16 = v13; - v13 = v12; - v12 = v16; - } - if ( (signed int)(((unsigned int)(11 * v12) >> 5) + (v13 >> 2) + v11) < v31 ) - EventProcessor(v1->field_16_event_id, 0, 1); - ++v37; - ++v9; - } - while ( v37 < (signed int)uNumActors ); + if (v1->vPosition.GetDistanceTo(pActors[j].vPosition) < v1->uTriggerRange) + EventProcessor(v1->uEventID, 0, 1); } } - if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_OBJECT) + else if (v1->uFlags & LEVEL_DECORATION_TRIGGERED_BY_OBJECT) { - v38 = 0; - if ( (signed int)uNumSpriteObjects > 0 ) + for (size_t j = 0; j < uNumSpriteObjects; j++) { - v17 = (char *)&pSpriteObjects[0].vPosition.y; - do - { - v18 = abs(v33 - *((int *)v17 - 1)); - v30 = abs(v32 - *(int *)v17); - v27 = abs(v35 - *((int *)v17 + 1)); - v19 = v18; - v20 = v30; - v21 = v27; - if ( v19 < v30 ) - { - v22 = v19; - v19 = v30; - v20 = v22; - } - if ( v19 < v27 ) - { - v23 = v19; - v19 = v27; - v21 = v23; - } - if ( v20 < (signed int)v21 ) - { - v24 = v21; - v21 = v20; - v20 = v24; - } - if ( (signed int)(((unsigned int)(11 * v20) >> 5) + (v21 >> 2) + v19) < v31 ) - EventProcessor(v1->field_16_event_id, 0, 1); - ++v38; - v17 += 112; - } - while ( v38 < (signed int)uNumSpriteObjects ); + if (v1->vPosition.GetDistanceTo(pSpriteObjects[j].vPosition) < v1->uTriggerRange) + EventProcessor(v1->uEventID, 0, 1); } } - v0 = i + 1; } } // 6836C8: using guessed type int 6836C8_num_decorations_6807E8; diff -r 58d15177edd0 -r 863de6ec906b mm7_5.cpp --- a/mm7_5.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/mm7_5.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -1246,10 +1246,10 @@ if ( dword_506F14 ) { Rest(_506F18_num_minutes_to_sleep); - pParty->pPlayers[3].pConditions[2] = 0i64; - pParty->pPlayers[2].pConditions[2] = 0i64; - pParty->pPlayers[1].pConditions[2] = 0i64; - pParty->pPlayers[0].pConditions[2] = 0i64; + pParty->pPlayers[3].SetAsleep(false); + pParty->pPlayers[2].SetAsleep(false); + pParty->pPlayers[1].SetAsleep(false); + pParty->pPlayers[0].SetAsleep(false); } pTexture_RestUI_CurrentSkyFrame->Release(); pTexture_RestUI_CurrentHourglassFrame->Release(); @@ -1257,6 +1257,11 @@ pTexture_RestUI_CurrentSkyFrame = 0; pIcons_LOD->SyncLoadedFilesCount(); pIcons_LOD->RemoveTexturesPackFromTextureList(); + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + pOutdoor->UpdateSunlightVectors(); + pOutdoor->UpdateFog(); + } _506F18_num_minutes_to_sleep = 0; dword_506F14 = 0; dword_507B94 = 1; @@ -1275,18 +1280,18 @@ unk_50C9A0 = 0; back_to_game(); } - } - if ( (signed int)uActiveCharacter < 1 || (signed int)uActiveCharacter > 4 ) + } + if ( (signed int)uActiveCharacter < 1 || (signed int)uActiveCharacter > 4 ) uActiveCharacter = pParty->GetNextActiveCharacter(); - pGUIWindow_CurrentMenu->Release(); - if ( pGUIWindow_CurrentMenu == window_SpeakInHouse ) - window_SpeakInHouse = 0; - pGUIWindow_CurrentMenu = 0; - pEventTimer->Resume(); - pCurrentScreen = SCREEN_GAME; - viewparams->bRedrawGameUI = 1; - pIcons_LOD->RemoveTexturesFromTextureList(); - continue; + pGUIWindow_CurrentMenu->Release(); + if ( pGUIWindow_CurrentMenu == window_SpeakInHouse ) + window_SpeakInHouse = 0; + pGUIWindow_CurrentMenu = 0; + pEventTimer->Resume(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = 1; + pIcons_LOD->RemoveTexturesFromTextureList(); + continue; case SCREEN_E: __debugbreak(); pGUIWindow_CurrentMenu->Release(); @@ -1688,7 +1693,7 @@ { pParty->field_6E4 = 0; pParty->field_6E0 = 0; - pCastSpellInfo.data()->_427D48(1); + CastSpellInfoHelpers::_427D48(); DialogueEnding(); pEventTimer->Pause(); pGameLoadingUI_ProgressBar->Initialize(GUIProgressBar::TYPE_Box); @@ -1792,7 +1797,7 @@ if ( !v47 ) continue; pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - LOBYTE(pSpellInfo->field_8) &= 0xBFu; + pSpellInfo->uFlags &= ~0x40u; pSpellInfo->uPlayerID_2 = uMessageParam; pSpellInfo->spell_target_pid = v44; pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); @@ -1810,7 +1815,7 @@ if ( !v47 ) continue; pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - LOBYTE(pSpellInfo->field_8) &= 0xBFu; + pSpellInfo->uFlags &= ~0x40u; pSpellInfo->uPlayerID_2 = uMessageParam; pSpellInfo->spell_target_pid = v44; pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); @@ -1824,7 +1829,7 @@ } if ( v45 == 5 ) { - v48 = pLevelDecorations[v46].field_16_event_id == 0; + v48 = pLevelDecorations[v46].uEventID == 0; } else { @@ -1837,7 +1842,7 @@ continue; v44 = uNumSeconds; pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - LOBYTE(pSpellInfo->field_8) &= 0xBFu; + pSpellInfo->uFlags &= ~0x40u; pSpellInfo->uPlayerID_2 = uMessageParam; pSpellInfo->spell_target_pid = v44; pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); @@ -1857,7 +1862,7 @@ if ( v48 ) continue; pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; - LOBYTE(pSpellInfo->field_8) &= 0xBFu; + pSpellInfo->uFlags &= ~0x40u; pSpellInfo->uPlayerID_2 = uMessageParam; pSpellInfo->spell_target_pid = v44; pParty->pPlayers[pSpellInfo->uPlayerID].SetRecoveryTime(300); @@ -1886,13 +1891,13 @@ switch ( uMessage ) { case UIMSG_CastSpell_Character_Big_Improvement: - LOBYTE(pSpellInfo->field_8) &= 0xFDu; + pSpellInfo->uFlags &= ~0x02u; break; case UIMSG_CastSpell_Character_Small_Improvement: - HIBYTE(pSpellInfo->field_8) &= 0xFEu; + pSpellInfo->uFlags &= ~0x0100u; break; case UIMSG_HiredNPC_CastSpell: - HIBYTE(pSpellInfo->field_8) &= 0xFDu; + pSpellInfo->uFlags &= ~0x0200u; break; } pSpellInfo->uPlayerID_2 = uMessageParam; @@ -2370,14 +2375,14 @@ pSpellInfo = (CastSpellInfo *)pGUIWindow_Settings->ptr_1C; if ( uMessage == UIMSG_CastSpell_Shoot_Monster ) { - LOBYTE(pSpellInfo->field_8) &= 0xF7; + pSpellInfo->uFlags &= ~0x08; } else { if ( uMessage == UIMSG_CastSpell_Monster_Improvement ) - HIBYTE(pSpellInfo->field_8) &= 0xFEu; + pSpellInfo->uFlags &= ~0x0100u; else - HIBYTE(pSpellInfo->field_8) &= 0xFDu; + pSpellInfo->uFlags &= ~0x0200u; } pSpellInfo->uPlayerID_2 = uMessageParam; pSpellInfo->spell_target_pid = v44; @@ -3235,7 +3240,7 @@ } } } - pCastSpellInfo.data()->_427E01_cast_spell(); + CastSpellInfoHelpers::_427E01_cast_spell(); } //----- (004356FF) -------------------------------------------------------- diff -r 58d15177edd0 -r 863de6ec906b mm7_6.cpp --- a/mm7_6.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/mm7_6.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -1110,7 +1110,7 @@ if (!player->CanAct()) return; - pCastSpellInfo.data()->_427D48(uActiveCharacter); + CastSpellInfoHelpers::_427D48(); //v3 = 0; if (pParty->Invisible()) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); @@ -2062,7 +2062,7 @@ v24 = pPlayers[uActiveCharacter]->GetAttackRecoveryTime(false); if ( !pParty->bTurnBasedModeOn ) pPlayers[uActiveCharacter]->SetRecoveryTime((signed __int64)(flt_6BE3A4_debug_recmod1 * (double)v24 * 2.133333333333333)); - pCastSpellInfo.data()->_427D48(uActiveCharacter); + CastSpellInfoHelpers::_427D48(); pTurnEngine->ApplyPlayerAction(); } } diff -r 58d15177edd0 -r 863de6ec906b mm7_data.cpp --- a/mm7_data.cpp Thu Sep 05 13:12:53 2013 +0600 +++ b/mm7_data.cpp Thu Sep 05 13:31:15 2013 +0600 @@ -33,12 +33,6 @@ #include "MapInfo.h" struct MapStats *pMapStats; - - -#include "CastSpellInfo.h" -std::array pCastSpellInfo; -CastSpellInfo stru_50CDB4; // idb - #include "Viewport.h" struct Viewport *pViewport = new Viewport; struct ViewingParams *viewparams = new ViewingParams; @@ -1018,7 +1012,7 @@ char pStartingMapName[32]; // idb std::array IsPlayerWearingWatersuit; std::array party_has_equipment; -std::array byte_5111F6; +std::array byte_5111F6; int _unused000; // weak diff -r 58d15177edd0 -r 863de6ec906b mm7_data.h --- a/mm7_data.h Thu Sep 05 13:12:53 2013 +0600 +++ b/mm7_data.h Thu Sep 05 13:31:15 2013 +0600 @@ -660,7 +660,7 @@ extern char pStartingMapName[32]; // idb extern std::array IsPlayerWearingWatersuit; extern std::array party_has_equipment; -extern std::array byte_5111F6; +extern std::array byte_5111F6; extern std::array papredoll_dbrds; extern int bRingsShownInCharScreen; // weak @@ -1199,7 +1199,6 @@ void PrepareToLoadBLV(unsigned int bLoading); void __fastcall PrepareToLoadODM(unsigned int bLoading, struct OutdoorCamera *a2); void _461103_load_level_sub(); -int int_get_vector_length(signed int x, signed int y, signed int z); void MainMenu_Loop(); char sub_4637E0_is_there_popup_onscreen(); void ResetCursor_Palettes_LODs_Level_Audio_SFT_Windows(); @@ -1361,13 +1360,13 @@ int NPC_EventProcessor(int npc_event_id, int entry_line = 0); void __fastcall sub_448518_npc_set_item(int npc, unsigned int item, int a3); void __fastcall sub_44861E_set_texture(unsigned int uFaceCog, const char *pFilename); -void __fastcall SetDecorationSprite(unsigned int uCog, int a2, const char *pFileName); // idb +void __fastcall SetDecorationSprite(uint16_t uCog, bool bHide, const char *pFileName); // idb void __fastcall sub_44892E_set_faces_bit(int sCogNumber, int bit, int on); void __fastcall ToggleActorGroupFlag(unsigned int uGroupID, unsigned int uFlag, unsigned int bToggle); void GameUI_StatusBar_UpdateTimedString(unsigned int bForceHide); // idb void OnTimer(int); void __fastcall sub_448CF4_spawn_monsters(__int16 typeindex, __int16 level, int count, int x, int y, int z, int group, unsigned int uUniqueName); -void __fastcall EventCastSpell(int spellnum, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz);//sub_448DF8 +void __fastcall EventCastSpell(int uSpellID, int uSkillLevel, int uSkill, int fromx, int fromy, int fromz, int tox, int toy, int toz);//sub_448DF8 __int16 __fastcall sub_449A49_door_switch_animation(unsigned int uDoorID, int a2); // idb bool _449B57_test_bit(unsigned __int8 *a1, __int16 a2); void _449B7E_toggle_bit(unsigned char *pArray, __int16 a2, unsigned __int16 bToggle); // idb