comparison Player.cpp @ 1545:c4ab816fcc5e

assert, Abortf, AbortWithError -> Assert, Error refactors here and there
author Nomad
date Sat, 07 Sep 2013 20:05:20 +0200
parents 5cf28ec7322d
children e303d8a9bcdc
comparison
equal deleted inserted replaced
1544:499761153844 1545:c4ab816fcc5e
1 #ifdef _MSC_VER 1 #ifdef _MSC_VER
2 #define _CRT_SECURE_NO_WARNINGS 2 #define _CRT_SECURE_NO_WARNINGS
3 #endif 3 #endif
4 4
5 #include <assert.h>
6
7 #include "stru6.h" 5 #include "stru6.h"
8
9 6
10 #include "Player.h" 7 #include "Player.h"
11 #include "PlayerFrameTable.h" 8 #include "PlayerFrameTable.h"
12 #include "AudioPlayer.h" 9 #include "AudioPlayer.h"
13 #include "Party.h" 10 #include "Party.h"
341 338
342 //----- (004B8142) -------------------------------------------------------- 339 //----- (004B8142) --------------------------------------------------------
343 int Player::GetBuyingPrice(unsigned int uRealValue, float price_multiplier) 340 int Player::GetBuyingPrice(unsigned int uRealValue, float price_multiplier)
344 { 341 {
345 uint price = (uint)(((100 - GetMerchant()) * (uRealValue * price_multiplier)) / 100); 342 uint price = (uint)(((100 - GetMerchant()) * (uRealValue * price_multiplier)) / 100);
346 assert (price > 0); 343 Assert (price > 0);
347 344
348 if (price < uRealValue) 345 if (price < uRealValue)
349 price = uRealValue; 346 price = uRealValue;
350 return price; 347 return price;
351 } 348 }
648 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 77)); 645 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 77));
649 case 0x23u: 646 case 0x23u:
650 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 79)); 647 return(_449B57_test_bit((unsigned __int8 *)this->_achieved_awards_bits, 79));
651 break; 648 break;
652 default: 649 default:
653 assert("Should not be able to get here" && false); 650 Error("Should not be able to get here (%u)", uClass);
654 break; 651 break;
655 } 652 }
656 return false; 653 return false;
657 } 654 }
658 } 655 }
811 if ( !areWeLoadingTexture ) 808 if ( !areWeLoadingTexture )
812 { 809 {
813 texture->Release(); 810 texture->Release();
814 pIcons_LOD->SyncLoadedFilesCount(); 811 pIcons_LOD->SyncLoadedFilesCount();
815 } 812 }
816 if ( slotHeight == 0 || slotWidth == 0) 813
817 { 814 Assert(slotHeight && slotWidth, "Items should have nonzero dimensions");
818 assert("Items should have nonzero dimensions");
819 return 1;
820 }
821 if ( (slotWidth + uSlot % INVETORYSLOTSWIDTH) <= INVETORYSLOTSWIDTH && (slotHeight + uSlot / INVETORYSLOTSWIDTH) <= INVETORYSLOTSHEIGHT ) 815 if ( (slotWidth + uSlot % INVETORYSLOTSWIDTH) <= INVETORYSLOTSWIDTH && (slotHeight + uSlot / INVETORYSLOTSWIDTH) <= INVETORYSLOTSHEIGHT )
822 { 816 {
823 int startOfInnerLoop = uSlot; 817 int startOfInnerLoop = uSlot;
824 for (unsigned int y = 0; y < slotHeight; y++) 818 for (unsigned int y = 0; y < slotHeight; y++)
825 { 819 {
1089 return 5; 1083 return 5;
1090 if ( !(equipType == EQUIP_REAGENT || equipType == EQUIP_POTION || equipType == EQUIP_MESSAGE_SCROLL)) 1084 if ( !(equipType == EQUIP_REAGENT || equipType == EQUIP_POTION || equipType == EQUIP_MESSAGE_SCROLL))
1091 return 4; 1085 return 4;
1092 break; 1086 break;
1093 default: 1087 default:
1094 assert(false); 1088 Error("(%u)", building_type);
1095 break; 1089 break;
1096 } 1090 }
1097 if (pItem->Stolen()) 1091 if (pItem->Stolen())
1098 return 6; 1092 return 6;
1099 1093
1114 break; 1108 break;
1115 case 5: 1109 case 5:
1116 price = this->GetPriceRepair(itemValue, multiplier); 1110 price = this->GetPriceRepair(itemValue, multiplier);
1117 break; 1111 break;
1118 default: 1112 default:
1119 assert(false); 1113 Assert("(%u)", ShopMenuType);
1120 break; 1114 break;
1121 } 1115 }
1122 if ( merchantLevel ) 1116 if ( merchantLevel )
1123 { 1117 {
1124 if (price == itemValue) 1118 if (price == itemValue)
3197 armour_recovery_multipliers[2] = 0.5f; 3191 armour_recovery_multipliers[2] = 0.5f;
3198 armour_recovery_multipliers[3] = 0; 3192 armour_recovery_multipliers[3] = 0;
3199 } 3193 }
3200 else 3194 else
3201 { 3195 {
3202 assert(false && "Unknown armour type"); // what kind of armour is that? 3196 Error("Unknown armour type"); // what kind of armour is that?
3203 armour_recovery_multipliers[0] = 1.0f; 3197 armour_recovery_multipliers[0] = 1.0f;
3204 armour_recovery_multipliers[1] = 1.0f; 3198 armour_recovery_multipliers[1] = 1.0f;
3205 armour_recovery_multipliers[2] = 1.0f; 3199 armour_recovery_multipliers[2] = 1.0f;
3206 armour_recovery_multipliers[3] = 1.0f; 3200 armour_recovery_multipliers[3] = 1.0f;
3207 } 3201 }
3591 } 3585 }
3592 3586
3593 //----- (0048E96A) -------------------------------------------------------- 3587 //----- (0048E96A) --------------------------------------------------------
3594 void Player::SetRecoveryTime(signed int rec) 3588 void Player::SetRecoveryTime(signed int rec)
3595 { 3589 {
3596 assert(rec >= 0); 3590 Assert(rec >= 0);
3597 3591
3598 if (rec > uTimeToRecovery) 3592 if (rec > uTimeToRecovery)
3599 uTimeToRecovery = rec; 3593 uTimeToRecovery = rec;
3600 3594
3601 if (pPlayers[uActiveCharacter] == this && !some_active_character) 3595 if (pPlayers[uActiveCharacter] == this && !some_active_character)
5038 case 1: return mult1; 5032 case 1: return mult1;
5039 case 2: return mult2; 5033 case 2: return mult2;
5040 case 3: return mult3; 5034 case 3: return mult3;
5041 case 4: return mult4; 5035 case 4: return mult4;
5042 } 5036 }
5043 assert(false); 5037 Error("(%u)", masteryLvl);
5044 return 0; 5038 return 0;
5045 } 5039 }
5046 //----- (00490109) -------------------------------------------------------- 5040 //----- (00490109) --------------------------------------------------------
5047 // faces are: 0 1 2 3 human males 5041 // faces are: 0 1 2 3 human males
5048 // 4 5 6 7 human females 5042 // 4 5 6 7 human females
5121 case 0x13u: 5115 case 0x13u:
5122 case 0x15u: 5116 case 0x15u:
5123 case 0x18u: 5117 case 0x18u:
5124 return SEX_FEMALE; 5118 return SEX_FEMALE;
5125 } 5119 }
5126 assert(false); 5120 Error("(%u)", this->uVoiceID);
5127 return SEX_MALE; 5121 return SEX_MALE;
5128 } 5122 }
5129 5123
5130 //----- (00490188) -------------------------------------------------------- 5124 //----- (00490188) --------------------------------------------------------
5131 void Player::SetInitialStats() 5125 void Player::SetInitialStats()
5371 return (PLAYER_SKILL_TYPE)i; 5365 return (PLAYER_SKILL_TYPE)i;
5372 ++counter; 5366 ++counter;
5373 } 5367 }
5374 } 5368 }
5375 5369
5376 assert(false); 5370 Error("(%u)", order);
5377 } 5371 }
5378 5372
5379 5373
5380 5374
5381 //----- (0049048D) -------------------------------------------------------- 5375 //----- (0049048D) --------------------------------------------------------
5465 statToChange = &this->uSpeed; 5459 statToChange = &this->uSpeed;
5466 break; 5460 break;
5467 case 6: 5461 case 6:
5468 statToChange = &this->uLuck; 5462 statToChange = &this->uLuck;
5469 default: 5463 default:
5470 assert(false); 5464 Error("(%u)", eAttribute);
5471 return;
5472 break;
5473 } 5465 }
5474 if ( *statToChange < baseValue ) 5466 if ( *statToChange < baseValue )
5475 { 5467 {
5476 tmp = baseStep; 5468 tmp = baseStep;
5477 baseStep = droppedStep; 5469 baseStep = droppedStep;
6775 { 6767 {
6776 currPlayerId = i - 1; 6768 currPlayerId = i - 1;
6777 break; 6769 break;
6778 } 6770 }
6779 } 6771 }
6780 assert(currPlayerId != -1); 6772
6773 Assert(currPlayerId != -1);
6781 if ( var_type > VAR_AutoNotes ) 6774 if ( var_type > VAR_AutoNotes )
6782 { 6775 {
6783 if ( var_type <= VAR_GoldInBank ) 6776 if ( var_type <= VAR_GoldInBank )
6784 { 6777 {
6785 if ( var_type == VAR_GoldInBank ) 6778 if ( var_type == VAR_GoldInBank )
7226 break; 7219 break;
7227 case VAR_DarkResistanceBonus: 7220 case VAR_DarkResistanceBonus:
7228 this->sResDarkBonus = (unsigned __int8)var_value; 7221 this->sResDarkBonus = (unsigned __int8)var_value;
7229 break; 7222 break;
7230 case VAR_PhysicalResistanceBonus: 7223 case VAR_PhysicalResistanceBonus:
7231 assert("VAR_PhysicalResistanceBonus variable unsupported" && false); 7224 Assert("VAR_PhysicalResistanceBonus variable unsupported" && false);
7232 return; 7225 return;
7233 break; 7226 break;
7234 case VAR_MagicResistanceBonus: 7227 case VAR_MagicResistanceBonus:
7235 this->sResMagicBonus = (unsigned __int8)var_value; 7228 this->sResMagicBonus = (unsigned __int8)var_value;
7236 break; 7229 break;
7237 default: 7230 default:
7238 assert("Unexpected var_type" && false); 7231 Assert("Unexpected var_type: %u", var_type);
7239 return; 7232 return;
7240 break; 7233 break;
7241 } 7234 }
7242 goto LABEL_111; 7235 goto LABEL_111;
7243 } 7236 }
7980 case 313: 7973 case 313:
7981 result = (bool)pValue; 7974 result = (bool)pValue;
7982 pParty->uNumArenaLordWins -= (char)pValue; 7975 pParty->uNumArenaLordWins -= (char)pValue;
7983 break; 7976 break;
7984 } 7977 }
7985 assert(false && "Function not returning any value!"); 7978 Error("Function not returning any value! (%u)", VarNum);
7986 } 7979 }
7987 else 7980 else
7988 { 7981 {
7989 if ( (signed int)VarNum >= 123 ) 7982 if ( (signed int)VarNum >= 123 )
7990 { 7983 {
8562 //if ( !a1 ) 8555 //if ( !a1 )
8563 //{ 8556 //{
8564 //pPlayers = &::pPlayers[1]; 8557 //pPlayers = &::pPlayers[1];
8565 //v5 = 604; 8558 //v5 = 604;
8566 //while ( 1 ) 8559 //while ( 1 )
8567 assert ( a1 > 0 && a1 < 5 ); 8560 Assert ( a1 > 0 && a1 < 5 );
8568 for ( uint i = 1; i < 5; ++i ) 8561 for ( uint i = 1; i < 5; ++i )
8569 { 8562 {
8570 //item_flag = Player_has_item(604, *pPlayers, 0); 8563 //item_flag = Player_has_item(604, *pPlayers, 0);
8571 if ( !Player_has_item(604, ::pPlayers[i], 0) ) 8564 if ( !Player_has_item(604, ::pPlayers[i], 0) )
8572 return false; 8565 return false;