Mercurial > mm7
changeset 1788:ebde8e43839c
Player::AddVariable starting refactoring
author | Grumpy7 |
---|---|
date | Thu, 03 Oct 2013 07:35:20 +0200 |
parents | a3e86ec5d3ce |
children | 4d70df78baca |
files | Player.cpp |
diffstat | 1 files changed, 148 insertions(+), 142 deletions(-) [+] |
line wrap: on
line diff
--- a/Player.cpp Thu Oct 03 06:38:20 2013 +0200 +++ b/Player.cpp Thu Oct 03 07:35:20 2013 +0200 @@ -6018,7 +6018,6 @@ void Player::AddVariable(enum VariableType var_type, signed int val) { char v3; // bl@1 - Player *v4; // esi@1 signed int uPlayerIdx; // edi@1 int v6; // eax@15 unsigned int v7; // esi@18 @@ -6027,17 +6026,13 @@ signed int v10; // eax@24 int v11; // eax@27 __int16 *v12; // esi@28 - Player *v13; // ecx@34 - Player *v14; // ecx@36 char *v15; // ecx@37 unsigned __int8 v16; // cf@38 - Player *v17; // ecx@42 __int16 *v18; // esi@53 __int16 *v19; // esi@62 char *v20; // esi@107 __int16 v21; // dx@107 int v22; // ecx@107 - Player *v23; // ecx@132 int v24; // eax@132 int v25; // eax@150 char v26; // zf@151 @@ -6050,16 +6045,14 @@ unsigned int v33; // [sp+30h] [bp-8h]@34 char v34; // [sp+37h] [bp-1h]@1 - auto Dst = this; v3 = 0; v34 = 0; - v4 = Dst; uPlayerIdx = 0; - if ( Dst == pPlayers[2] ) + if ( this == pPlayers[2] ) uPlayerIdx = 1; - else if ( Dst == pPlayers[3] ) + else if ( this == pPlayers[3] ) uPlayerIdx = 2; - else if ( Dst == pPlayers[4] ) + else if ( this == pPlayers[4] ) uPlayerIdx = 3; if ( var_type <= VAR_AutoNotes ) @@ -6087,122 +6080,134 @@ sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[502], v7);// You find %lu food ShowStatusBarString(pTmpBuf.data(), 2u); GameUI_DrawFoodAndGold(); - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; case VAR_Sex: - Dst->uSex = (PLAYER_SEX)val; + this->uSex = (PLAYER_SEX)val; pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; case VAR_Class: - Dst->classType = (PLAYER_CLASS_TYPE)val; + this->classType = (PLAYER_CLASS_TYPE)val; pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; case VAR_CurrentHP: - v8 = &Dst->sHealth; + v8 = &this->sHealth; *v8 += val; - if ( Dst->sHealth <= Dst->GetMaxHealth() ) + if ( this->sHealth <= this->GetMaxHealth() ) { pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; } - v9 = v4->GetMaxHealth(); - goto LABEL_23; + v9 = this->GetMaxHealth(); + *v8 = v9; + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + PlayAwardSound(uPlayerIdx); + return; case VAR_MaxHP: - v10 = Dst->GetMaxHealth(); - v4->_health_related = 0; - v4->uFullHealthBonus = 0; - v4->sHealth = v10; + v10 = this->GetMaxHealth(); + this->_health_related = 0; + this->uFullHealthBonus = 0; + this->sHealth = v10; return; case VAR_CurrentSP: - v8 = &Dst->sMana; + v8 = &this->sMana; *v8 += val; - if ( Dst->sMana > GetMaxMana() ) + if ( this->sMana > GetMaxMana() ) { - v9 = v4->GetMaxMana(); -LABEL_23: + v9 = this->GetMaxMana(); *v8 = v9; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; case VAR_MaxSP: v11 = GetMaxMana(); - v4->_mana_related = 0; - v4->uFullManaBonus = 0; - v4->sMana = v11; + this->_mana_related = 0; + this->uFullManaBonus = 0; + this->sMana = v11; return; case VAR_ACModifier: - v12 = &Dst->sACModifier; - goto LABEL_29; - case VAR_BaseLevel: - v12 = (__int16 *)&Dst->uLevel; - goto LABEL_29; - case VAR_LevelModifier: - v12 = &Dst->sLevelModifier; -LABEL_29: + v12 = &this->sACModifier; *v12 += val; if ( *v12 > 255 ) *v12 = 255; pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; + case VAR_BaseLevel: + v12 = (__int16 *)&this->uLevel; + *v12 += val; + if ( *v12 > 255 ) + *v12 = 255; + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + PlayAwardSound(uPlayerIdx); + return; + case VAR_LevelModifier: + v12 = &this->sLevelModifier; + *v12 += val; + if ( *v12 > 255 ) + *v12 = 255; + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + PlayAwardSound(uPlayerIdx); + return; case VAR_Age: - Dst->sAgeModifier += val; + this->sAgeModifier += val; return; case VAR_Award: - v13 = pPlayers[uPlayerIdx + 1]; - if (_449B57_test_bit((unsigned __int8 *)pPlayers[uPlayerIdx + 1]->_achieved_awards_bits, val) - - && pAwards[val].pText ) + if (_449B57_test_bit(this->_achieved_awards_bits, val) && pAwards[val].pText ) { - v14 = pPlayers[uPlayerIdx + 1]; v34 = 1; v3 = 1; - v14->PlaySound(SPEECH_96, 0); + this->PlaySound(SPEECH_96, 0); } - v15 = (char *)v4->_achieved_awards_bits; + v15 = (char *)this->_achieved_awards_bits; _449B7E_toggle_bit((unsigned char *)v15, val, 1); if ( v34 != 1 ) { if ( v3 != 1 ) return; - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); if ( v3 != 1 ) return; - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; case VAR_Experience: - v16 = __CFADD__(val, LODWORD(Dst->uExperience)); - LODWORD(Dst->uExperience) += val; - HIDWORD(Dst->uExperience) += ((unsigned __int64)val >> 32) + v16; - if ( (signed __int64)Dst->uExperience > 4000000000i64 ) - Dst->uExperience = 4000000000i64; + this->uExperience += val; + if ( this->uExperience > 4000000000i64 ) + this->uExperience = 4000000000i64; pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; case VAR_QBits_QuestsDone: - if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_quest_bits[((signed __int16)val - 1) >> 3]) - //&& (&dword_722F10)[4 * val] ) - && pQuestTable[val] ) + if ( !_449B57_test_bit(pParty->_quest_bits, val) && pQuestTable[val] ) { //v17 = pPlayers[uPlayerIdx + 1]; bFlashQuestBook = 1; v34 = 1; v3 = 1; - pPlayers[uPlayerIdx + 1]->PlaySound(SPEECH_93, 0); + this->PlaySound(SPEECH_93, 0); } - v15 = (char *)pParty->_quest_bits; - _449B7E_toggle_bit((unsigned char *)v15, val, 1); + _449B7E_toggle_bit(pParty->_quest_bits, val, 1); if ( v34 != 1 ) { if ( v3 != 1 ) return; - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); if ( v3 != 1 ) return; - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; case VAR_PlayerItemInHands: item.Reset(); - item.Reset(); item.uAttributes = 1; item.uItemID = val; if ( val >= ITEM_ARTIFACT_PUCK && val <= ITEM_RELIC_MEKORIGS_HAMMER ) @@ -6218,25 +6223,25 @@ party_finds_gold(val, 1); return; case VAR_BaseMight: - v18 = (__int16 *)&Dst->uMight; + v18 = (__int16 *)&this->uMight; goto LABEL_82; case VAR_BaseIntellect: - v18 = (__int16 *)&Dst->uIntelligence; + v18 = (__int16 *)&this->uIntelligence; goto LABEL_82; case VAR_BasePersonality: - v18 = (__int16 *)&Dst->uWillpower; + v18 = (__int16 *)&this->uWillpower; goto LABEL_82; case VAR_BaseEndurance: - v18 = (__int16 *)&Dst->uEndurance; + v18 = (__int16 *)&this->uEndurance; goto LABEL_82; case VAR_BaseSpeed: - v18 = (__int16 *)&Dst->uSpeed; + v18 = (__int16 *)&this->uSpeed; goto LABEL_82; case VAR_BaseAccuracy: - v18 = (__int16 *)&Dst->uAccuracy; + v18 = (__int16 *)&this->uAccuracy; goto LABEL_82; case VAR_BaseLuck: - v18 = (__int16 *)&Dst->uLuck; + v18 = (__int16 *)&this->uLuck; goto LABEL_82; case VAR_FixedFood: Party::GiveFood(val); @@ -6244,7 +6249,8 @@ ShowStatusBarString(pTmpBuf.data(), 2u); if ( pParty->uNumFoodRations > 0xFFFF ) Party::SetFood(0xFFFFu); - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; case VAR_MightBonus: goto LABEL_62; case VAR_IntellectBonus: @@ -6265,7 +6271,7 @@ return; } LABEL_62: - v19 = (__int16 *)&Dst->uMightBonus; + v19 = (__int16 *)&this->uMightBonus; goto LABEL_113; } if ( var_type <= VAR_FireResistanceBonus ) @@ -6276,79 +6282,80 @@ { case VAR_ActualIntellect: LABEL_66: - v19 = (__int16 *)&Dst->uIntelligenceBonus; + v19 = (__int16 *)&this->uIntelligenceBonus; goto LABEL_113; case VAR_ActualPersonality: LABEL_67: - v19 = (__int16 *)&Dst->uWillpowerBonus; + v19 = (__int16 *)&this->uWillpowerBonus; goto LABEL_113; case VAR_ActualEndurance: LABEL_68: - v19 = (__int16 *)&Dst->uEnduranceBonus; + v19 = (__int16 *)&this->uEnduranceBonus; goto LABEL_113; case VAR_ActualSpeed: LABEL_69: - v19 = (__int16 *)&Dst->uSpeedBonus; + v19 = (__int16 *)&this->uSpeedBonus; goto LABEL_113; case VAR_ActualAccuracy: LABEL_70: - v19 = (__int16 *)&Dst->uAccuracyBonus; + v19 = (__int16 *)&this->uAccuracyBonus; goto LABEL_113; case VAR_ActualLuck: LABEL_71: - v19 = (__int16 *)&Dst->uLuckBonus; + v19 = (__int16 *)&this->uLuckBonus; goto LABEL_113; case VAR_FireResistance: - v18 = &Dst->sResFireBase; + v18 = &this->sResFireBase; goto LABEL_82; case VAR_AirResistance: - v18 = &Dst->sResAirBase; + v18 = &this->sResAirBase; goto LABEL_82; case VAR_WaterResistance: - v18 = &Dst->sResWaterBase; + v18 = &this->sResWaterBase; goto LABEL_82; case VAR_EarthResistance: - v18 = &Dst->sResEarthBase; + v18 = &this->sResEarthBase; goto LABEL_82; case VAR_SpiritResistance: - v18 = &Dst->sResSpiritBase; + v18 = &this->sResSpiritBase; goto LABEL_82; case VAR_MindResistance: - v18 = &Dst->sResMindBase; + v18 = &this->sResMindBase; goto LABEL_82; case VAR_BodyResistance: - v18 = &Dst->sResBodyBase; + v18 = &this->sResBodyBase; goto LABEL_82; case VAR_LightResistance: - v18 = &Dst->sResLightBase; + v18 = &this->sResLightBase; goto LABEL_82; case VAR_DarkResistance: - v18 = &Dst->sResDarkBase; + v18 = &this->sResDarkBase; goto LABEL_82; case VAR_MagicResistance: - v18 = &Dst->sResMagicBase; + v18 = &this->sResMagicBase; LABEL_82: *v18 += val; if ( *v18 > 255 ) *v18 = 255; - pPlayers[uPlayerIdx + 1]->PlaySound(SPEECH_92, 0); + this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; default: return; } return; } - v19 = &Dst->sResFireBonus; + v19 = &this->sResFireBonus; LABEL_113: *v19 += val; if ( *v19 > 255 ) *v19 = 255; v31 = 0; - v29 = SPEECH_91; - pPlayers[uPlayerIdx + 1]->PlaySound((PlayerSpeech)v29, v31); + this->PlaySound(SPEECH_91, v31); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; } if ( var_type <= VAR_DisarmTrapSkill ) { @@ -6359,41 +6366,41 @@ switch ( var_type ) { case VAR_BodyResistanceBonus: - v19 = &Dst->sResBodyBonus; + v19 = &this->sResBodyBonus; break; case VAR_AirResistanceBonus: - v19 = &Dst->sResAirBonus; + v19 = &this->sResAirBonus; break; case VAR_WaterResistanceBonus: - v19 = &Dst->sResWaterBonus; + v19 = &this->sResWaterBonus; break; case VAR_EarthResistanceBonus: - v19 = &Dst->sResEarthBonus; + v19 = &this->sResEarthBonus; break; case VAR_SpiritResistanceBonus: - v19 = &Dst->sResSpiritBonus; + v19 = &this->sResSpiritBonus; break; default: if ( var_type != 62 ) return; - v19 = &Dst->sResMindBonus; + v19 = &this->sResMindBonus; break; } goto LABEL_113; } if ( var_type == VAR_LightResistanceBonus ) { - v19 = &Dst->sResLightBonus; + v19 = &this->sResLightBonus; goto LABEL_113; } if ( var_type == VAR_DarkResistanceBonus ) { - v19 = &Dst->sResDarkBonus; + v19 = &this->sResDarkBonus; goto LABEL_113; } if ( var_type == VAR_MagicResistanceBonus ) { - v19 = &Dst->sResMagicBonus; + v19 = &this->sResMagicBonus; goto LABEL_113; } if ( var_type <= VAR_MagicResistanceBonus || var_type > VAR_DiplomacySkill ) @@ -6404,34 +6411,35 @@ if ( var_type == VAR_LearningSkill ) { LABEL_106: - if ( val <= VAR_BodyResistanceBonus ) + if ( val <= 63 ) { - *((short *)&Dst->pConditions[16] + var_type) = (unsigned __int8)val | *((char *)&Dst->pConditions[16] + 2 * var_type) & VAR_BodyResistanceBonus; + *((short *)&this->pConditions[16] + var_type) = (unsigned __int8)val | *((char *)&this->pConditions[16] + 2 * var_type) & 63; } else { - v20 = (char *)&Dst->pConditions[16] + 2 * var_type; + v20 = (char *)&this->pConditions[16] + 2 * var_type; v21 = *(short *)v20; - v22 = (unsigned __int8)val + (v21 & VAR_BodyResistanceBonus); + v22 = (unsigned __int8)val + (v21 & 63); if ( v22 > 60 ) LOWORD(v22) = 60; LOBYTE(v21) = v21 & 0xC0; *(short *)v20 = v22 | v21; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; } if ( var_type <= VAR_LearningSkill ) return; if ( var_type <= VAR_Eradicated ) { - Dst->SetCondition(var_type - 105, 0); + this->SetCondition(var_type - 105, 0); } else { if ( var_type != VAR_MajorCondition ) { - if ( var_type > VAR_MajorCondition && var_type <= VAR_MapPersistentVariable_99 ) + if ( var_type >= VAR_MapPersistentVariable_0 && var_type <= VAR_MapPersistentVariable_99 ) { if ( (unsigned __int8)val + (unsigned __int8)byte_5E4C15[var_type] <= 255 ) byte_5E4C15[var_type] += val; @@ -6440,18 +6448,16 @@ } return; } - memset(Dst, 0, 0xA0u); + memset(this, 0, 0xA0u); } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - goto _play_sound; - } - if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_autonote_bits[((signed __int16)val - 1) >> 3]) - //&& (&dword_723718_autonote_related)[8 * val] ) - && pAutonoteTxt[val].pText ) - { - v23 = pPlayers[uPlayerIdx + 1]; + PlayAwardSound(uPlayerIdx); + return; + } + if ( !_449B57_test_bit(pParty->_autonote_bits, val) && pAutonoteTxt[val].pText ) + { v34 = 1; - v23->PlaySound(SPEECH_96, 0); + this->PlaySound(SPEECH_96, 0); //v24 = pAutonoteTxt[val].eType;//dword_72371C[2 * val]; bFlashAutonotesBook = 1; _506568_autonote_type = pAutonoteTxt[val].eType; @@ -6462,12 +6468,14 @@ { if ( v3 != 1 ) return; - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); if ( v3 != 1 ) return; - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; } if ( var_type > VAR_GoldInBank ) { @@ -6478,12 +6486,14 @@ { if ( v3 != 1 ) return; - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; } pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); if ( v3 != 1 ) return; - goto _play_sound; + PlayAwardSound(uPlayerIdx); + return; } switch ( var_type ) { @@ -6514,19 +6524,18 @@ pParty->uNumGoldInBank += val; return; } - if ( var_type <= VAR_Counter8 ) + if ( var_type <= VAR_Counter10 ) { if ( (signed int)var_type >= 245 ) { - *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44300] = LODWORD(pParty->uTimePlayed); - *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44304] = HIDWORD(pParty->uTimePlayed); + pParty->PartyTimes.CounterEventValues[var_type - VAR_Counter1] = pParty->uTimePlayed; } else { switch ( var_type ) { case VAR_PlayerBits: - _449B7E_toggle_bit((unsigned char *)Dst->field_1A50, val, 1u); + _449B7E_toggle_bit((unsigned char *)this->field_1A50, val, 1u); break; case VAR_NPCs2: pParty->field_709 = 0; @@ -6535,19 +6544,19 @@ viewparams->bRedrawGameUI = true; break; case VAR_NumSkillPoints: - Dst->uSkillPoints += val; + this->uSkillPoints += val; break; } } return; } - if ( var_type < VAR_Counter9 ) - return; - if ( (signed int)var_type <= 274 ) - { - *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44532] = LODWORD(pParty->uTimePlayed); - *(int *)&stru_AA1058[3].pSounds[8 * var_type + 44536] = HIDWORD(pParty->uTimePlayed); - goto _play_sound; + if ( var_type <= VAR_Counter10 ) + return; + if ( var_type <= VAR_UnknownTimeEvent19 ) + { + pParty->PartyTimes._s_times[var_type - VAR_UnknownTimeEvent0] = pParty->uTimePlayed; + PlayAwardSound(uPlayerIdx); + return; } if ( var_type != VAR_ReputationInCurrentLocation ) { @@ -6559,10 +6568,7 @@ v26) ) return; bFlashHistoryBook = 1; -_play_sound: - v28 = 8 * uPlayerIdx + 400; - LOBYTE(v28) = PID(OBJECT_Player,uPlayerIdx - 112); - pAudioPlayer->PlaySound(SOUND_20001, v28, 0, -1, 0, 0, 0, 0); + PlayAwardSound(uPlayerIdx); return; } v27 = &pOutdoor->ddm;