comparison Player.cpp @ 1259:d6e5b6b76612

Player::SetVariable cleanup - removing unused variables and function calls with them, some case shuffling
author Grumpy7
date Wed, 12 Jun 2013 04:14:33 +0200
parents eb1a22f7dfef
children dd70fc7eaf08
comparison
equal deleted inserted replaced
1258:eb1a22f7dfef 1259:d6e5b6b76612
7895 signed int v25; // eax@172 7895 signed int v25; // eax@172
7896 int v26; // [sp-8h] [bp-3Ch]@84 7896 int v26; // [sp-8h] [bp-3Ch]@84
7897 signed int unused27; // [sp-4h] [bp-38h]@4 7897 signed int unused27; // [sp-4h] [bp-38h]@4
7898 int v28; // [sp-4h] [bp-38h]@84 7898 int v28; // [sp-4h] [bp-38h]@84
7899 ItemGen item; // [sp+Ch] [bp-28h]@52 7899 ItemGen item; // [sp+Ch] [bp-28h]@52
7900 char v30_drawanim; // [sp+32h] [bp-2h]@1 7900 char v30_unused; // [sp+32h] [bp-2h]@1
7901 char v31_playsound; // [sp+33h] [bp-1h]@1 7901 char v31_unused; // [sp+33h] [bp-1h]@1
7902 7902
7903 v30_drawanim = 0;
7904 v31_playsound = 0;
7905
7906 currPlayerId = -1; 7903 currPlayerId = -1;
7907 for (int i = 1; i <= 4; i++) //TODO: add a member variable for playerid in the future 7904 for (int i = 1; i <= 4; i++) //TODO: add a member variable for playerid in the future
7908 { 7905 {
7909 if ( this == pPlayers[i] ) 7906 if ( this == pPlayers[i] )
7910 { 7907 {
7981 v25 = 8 * currPlayerId + 400; 7978 v25 = 8 * currPlayerId + 400;
7982 LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112); 7979 LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112);
7983 pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0); 7980 pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0);
7984 return; 7981 return;
7985 } 7982 }
7986 if ( var_type != VAR_NumDeaths ) 7983 switch ( var_type )
7987 { 7984 {
7988 switch ( var_type ) 7985 case VAR_NumDeaths:
7989 {
7990 case VAR_NumBounties:
7991 pParty->uNumBountiesCollected = var_value;
7992 break;
7993 case VAR_PrisonTerms:
7994 pParty->uNumPrisonTerms = var_value;
7995 break;
7996 case VAR_ArenaWinsPage:
7997 pParty->uNumArenaPageWins = var_value;
7998 break;
7999 case VAR_ArenaWinsSquire:
8000 pParty->uNumArenaSquireWins = var_value;
8001 break;
8002 case VAR_ArenaWinsKnight:
8003 pParty->uNumArenaKnightWins = var_value;
8004 break;
8005 case VAR_ArenaWinsLord:
8006 pParty->uNumArenaLordWins = var_value;
8007 break;
8008 }
8009 return;
8010 }
8011 else
8012 {
8013 pParty->uNumDeaths = var_value; 7986 pParty->uNumDeaths = var_value;
8014 DrawPlayerBuffAnimBasedOnCondition(v30_drawanim == 1, currPlayerId); 7987 break;
8015 PlaySoundBasedOnCondition(v31_playsound == 1, currPlayerId); 7988 case VAR_NumBounties:
8016 return; 7989 pParty->uNumBountiesCollected = var_value;
8017 } 7990 break;
7991 case VAR_PrisonTerms:
7992 pParty->uNumPrisonTerms = var_value;
7993 break;
7994 case VAR_ArenaWinsPage:
7995 pParty->uNumArenaPageWins = var_value;
7996 break;
7997 case VAR_ArenaWinsSquire:
7998 pParty->uNumArenaSquireWins = var_value;
7999 break;
8000 case VAR_ArenaWinsKnight:
8001 pParty->uNumArenaKnightWins = var_value;
8002 break;
8003 case VAR_ArenaWinsLord:
8004 pParty->uNumArenaLordWins = var_value;
8005 break;
8006 }
8007 return;
8018 } 8008 }
8019 if ( var_type == VAR_AutoNotes ) 8009 if ( var_type == VAR_AutoNotes )
8020 { 8010 {
8021 if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_autonote_bits[((signed __int16)var_value - 1) >> 3]) 8011 if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & pParty->_autonote_bits[((signed __int16)var_value - 1) >> 3])
8022 //&& (&dword_723718_autonote_related)[8 * a3] ) 8012 //&& (&dword_723718_autonote_related)[8 * a3] )
8023 && pAutonoteTxt[var_value-1].pText ) 8013 && pAutonoteTxt[var_value-1].pText )
8024 { 8014 {
8025 v20 = pPlayers[currPlayerId + 1]; 8015 v20 = pPlayers[currPlayerId + 1];
8026 v30_drawanim = 1;
8027 v20->PlaySound(SPEECH_96, 0); 8016 v20->PlaySound(SPEECH_96, 0);
8028 v21 = pAutonoteTxt[var_value-1].eType;// dword_72371C[2 * a3]; 8017 v21 = pAutonoteTxt[var_value-1].eType;// dword_72371C[2 * a3];
8029 bFlashAutonotesBook = 1; 8018 bFlashAutonotesBook = 1;
8030 _506568_autonote_type = v21; 8019 _506568_autonote_type = v21;
8020 DrawPlayerBuffAnimBasedOnCondition(currPlayerId);
8031 } 8021 }
8032 _449B7E_toggle_bit(pParty->_autonote_bits, var_value, 1u); 8022 _449B7E_toggle_bit(pParty->_autonote_bits, var_value, 1u);
8033 v31_playsound = 1; 8023 PlaySoundBasedOnCondition(currPlayerId);
8034 DrawPlayerBuffAnimBasedOnCondition(v30_drawanim == 1, currPlayerId);
8035 PlaySoundBasedOnCondition(v31_playsound == 1, currPlayerId);
8036 return; 8024 return;
8037 } 8025 }
8038 if ( var_type <= VAR_BaseLuck ) 8026 if ( var_type <= VAR_BaseLuck )
8039 { 8027 {
8040 switch ( var_type ) 8028 switch ( var_type )
8113 if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) & 8101 if ( !((unsigned __int8)(0x80u >> ((signed __int16)var_value - 1) % 8) &
8114 pPlayers[currPlayerId + 1]->_guilds_member_bits[((signed __int16)var_value - 1)/ 8]) 8102 pPlayers[currPlayerId + 1]->_guilds_member_bits[((signed __int16)var_value - 1)/ 8])
8115 //&& dword_723E80_award_related[2 * a3] ) 8103 //&& dword_723E80_award_related[2 * a3] )
8116 && pAwards[var_value].pText ) 8104 && pAwards[var_value].pText )
8117 { 8105 {
8118 v30_drawanim = 1;
8119 v31_playsound = 1;
8120 pPlayers[currPlayerId + 1]->PlaySound(SPEECH_96, 0); 8106 pPlayers[currPlayerId + 1]->PlaySound(SPEECH_96, 0);
8107 DrawPlayerBuffAnimBasedOnCondition(currPlayerId);
8108 PlaySoundBasedOnCondition(currPlayerId);
8121 } 8109 }
8122 _449B7E_toggle_bit((unsigned char *)this->_guilds_member_bits, var_value, 1u); 8110 _449B7E_toggle_bit((unsigned char *)this->_guilds_member_bits, var_value, 1u);
8123 DrawPlayerBuffAnimBasedOnCondition(v30_drawanim == 1, currPlayerId);
8124 PlaySoundBasedOnCondition(v31_playsound == 1, currPlayerId);
8125 return; 8111 return;
8126 case VAR_Experience: 8112 case VAR_Experience:
8127 this->uExperience = var_value; 8113 this->uExperience = var_value;
8128 goto LABEL_124; 8114 goto LABEL_124;
8129 case VAR_QBits_QuestsDone: 8115 case VAR_QBits_QuestsDone:
8131 // && (&dword_722F10)[4 * a3] ) 8117 // && (&dword_722F10)[4 * a3] )
8132 && pQuestTable[var_value-1] ) 8118 && pQuestTable[var_value-1] )
8133 { 8119 {
8134 v14 = pPlayers[currPlayerId + 1]; 8120 v14 = pPlayers[currPlayerId + 1];
8135 bFlashQuestBook = 1; 8121 bFlashQuestBook = 1;
8136 v30_drawanim = 1;
8137 v31_playsound = 1;
8138 v14->PlaySound(SPEECH_93, 0); 8122 v14->PlaySound(SPEECH_93, 0);
8123 DrawPlayerBuffAnimBasedOnCondition(currPlayerId);
8124 PlaySoundBasedOnCondition(currPlayerId);
8139 } 8125 }
8140 v13 = (char *)pParty->_quest_bits; 8126 v13 = (char *)pParty->_quest_bits;
8141 LABEL_51:
8142 _449B7E_toggle_bit((unsigned char *)v13, var_value, 1u); 8127 _449B7E_toggle_bit((unsigned char *)v13, var_value, 1u);
8143 DrawPlayerBuffAnimBasedOnCondition(v30_drawanim == 1, currPlayerId);
8144 PlaySoundBasedOnCondition(v31_playsound == 1, currPlayerId);
8145 return; 8128 return;
8146 case VAR_PlayerItemInHands: 8129 case VAR_PlayerItemInHands:
8147 item.Reset(); 8130 item.Reset();
8148 item.Reset(); 8131 item.Reset();
8149 item.uItemID = var_value; 8132 item.uItemID = var_value;
8227 LABEL_111: 8210 LABEL_111:
8228 v28 = 0; 8211 v28 = 0;
8229 v26 = SPEECH_91; 8212 v26 = SPEECH_91;
8230 LABEL_112: 8213 LABEL_112:
8231 v19 = pPlayers[currPlayerId + 1]; 8214 v19 = pPlayers[currPlayerId + 1];
8232 v31_playsound = 1;
8233 v19->PlaySound((PlayerSpeech)v26, v28); 8215 v19->PlaySound((PlayerSpeech)v26, v28);
8234 DrawPlayerBuffAnimBasedOnCondition(true, currPlayerId); 8216 DrawPlayerBuffAnimBasedOnCondition(currPlayerId);
8235 PlaySoundBasedOnCondition(v31_playsound == 1, currPlayerId); 8217 PlaySoundBasedOnCondition(currPlayerId);
8236 return; 8218 return;
8237 } 8219 }
8238 if ( var_type <= VAR_MagicResistance ) 8220 if ( var_type <= VAR_MagicResistance )
8239 { 8221 {
8240 switch ( var_type ) 8222 switch ( var_type )
8342 return; 8324 return;
8343 } 8325 }
8344 memset(this, 0, 0xA0u); 8326 memset(this, 0, 0xA0u);
8345 } 8327 }
8346 LABEL_124: 8328 LABEL_124:
8347 v31_playsound = 1; 8329 DrawPlayerBuffAnimBasedOnCondition(currPlayerId);
8348 DrawPlayerBuffAnimBasedOnCondition(true, currPlayerId); 8330 PlaySoundBasedOnCondition(currPlayerId);
8349 PlaySoundBasedOnCondition(v31_playsound = 1, currPlayerId);
8350 return; 8331 return;
8351 } 8332 }
8352 LABEL_106:
8353 v16 = (int)((char *)&this->pConditions[16] + 2 * var_type); 8333 v16 = (int)((char *)&this->pConditions[16] + 2 * var_type);
8354 v17 = *(char *)v16; 8334 v17 = *(char *)v16;
8355 if ( var_value <= VAR_BodyResistanceBonus ) 8335 if ( var_value <= VAR_BodyResistanceBonus )
8356 { 8336 {
8357 LOWORD(v15) = (unsigned __int8)var_value; 8337 LOWORD(v15) = (unsigned __int8)var_value;
8362 LOWORD(v18) = (unsigned __int8)(var_value | v17 & 0xC0); 8342 LOWORD(v18) = (unsigned __int8)(var_value | v17 & 0xC0);
8363 } 8343 }
8364 *(short *)v16 = v18; 8344 *(short *)v16 = v18;
8365 goto LABEL_124; 8345 goto LABEL_124;
8366 } 8346 }
8367 if ( var_type == VAR_DisarmTrapSkill )
8368 PlaySoundBasedOnCondition(v31_playsound == 1, currPlayerId);
8369 DrawPlayerBuffAnimBasedOnCondition(v30_drawanim == 1, currPlayerId);
8370 return;
8371 if ( var_type <= VAR_MagicResistanceBonus ) 8347 if ( var_type <= VAR_MagicResistanceBonus )
8372 { 8348 {
8373 switch ( var_type ) 8349 switch ( var_type )
8374 { 8350 {
8375 case VAR_FireResistanceBonus: 8351 case VAR_FireResistanceBonus:
8411 return; 8387 return;
8412 break; 8388 break;
8413 } 8389 }
8414 goto LABEL_111; 8390 goto LABEL_111;
8415 } 8391 }
8416 if ( var_type > VAR_MagicResistanceBonus && var_type <= VAR_DiplomacySkill ) 8392 if ( var_type > VAR_MagicResistanceBonus && var_type <= VAR_DiplomacySkill || var_type == VAR_DisarmTrapSkill) //VAR_ThieverySkill wasn't present in the original function
8417 { 8393 {
8418 PlaySoundBasedOnCondition(v31_playsound == 1, currPlayerId);
8419 DrawPlayerBuffAnimBasedOnCondition(v30_drawanim == 1, currPlayerId);
8420 return; 8394 return;
8421 } 8395 }
8422 } 8396 }
8423 8397
8424 8398
8425 //----- (new function) -------------------------------------------------------- 8399 //----- (new function) --------------------------------------------------------
8426 void Player::PlaySoundBasedOnCondition(bool condition, int currPlayerId) 8400 void Player::PlaySoundBasedOnCondition(int currPlayerId)
8427 { 8401 {
8428 if (condition) 8402 signed int v25 = 8 * currPlayerId + 400;
8429 { 8403 LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112);
8430 signed int v25 = 8 * currPlayerId + 400; 8404 pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0);
8431 LOBYTE(v25) = PID(OBJECT_Player,currPlayerId - 112);
8432 pAudioPlayer->PlaySound(SOUND_20001, v25, 0, -1, 0, 0, 0, 0);
8433 }
8434 } 8405 }
8435 8406
8436 //----- (new function) -------------------------------------------------------- 8407 //----- (new function) --------------------------------------------------------
8437 void Player::DrawPlayerBuffAnimBasedOnCondition(bool condition, int currPlayerId) 8408 void Player::DrawPlayerBuffAnimBasedOnCondition(int currPlayerId)
8438 { 8409 {
8439 if (condition) 8410 pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId);
8440 {
8441 pGame->pStru6Instance->SetPlayerBuffAnim(0x96u, currPlayerId);
8442 }
8443 } 8411 }
8444 8412
8445 //----- (0044AFFB) -------------------------------------------------------- 8413 //----- (0044AFFB) --------------------------------------------------------
8446 void Player::AddVariable(enum VariableType var_type, signed int val) 8414 void Player::AddVariable(enum VariableType var_type, signed int val)
8447 { 8415 {