Skip to content
Permalink
Browse files

Change order of buy validation logic for weapons and upgrades

Now it checks whether the player has the item in inventory first rather than 2nd to last.
This allows you to sell weapons/upgrades you already bought even if you don't have money
to buy them again.
Fixes #518
  • Loading branch information...
DolceTriade committed Jan 24, 2015
1 parent f80af98 commit a7a803ff685ed01ea87661bd180f4716e52b7e02
Showing with 16 additions and 14 deletions.
  1. +16 −14 src/gamelogic/cgame/cg_rocket_dataformatter.c
@@ -138,24 +138,25 @@ static void CG_Rocket_DFCMArmouryBuyWeapon( int handle, const char *data )
weapon_t currentweapon = BG_PrimaryWeapon( ps->stats );
credits += BG_Weapon( currentweapon )->price;

if ( !BG_WeaponUnlocked( weapon ) || BG_WeaponDisabled( weapon ) )
if( BG_InventoryContainsWeapon( weapon, cg.predictedPlayerState.stats ) ){
Class = "active";
action = va( "onClick='exec \"sell %s\"'", BG_Weapon( weapon )->name );
//Check mark icon. UTF-8 encoding of \uf00c
Icon = "<icon class=\"current\">\xEF\x80\x8C</icon>";
}
else if ( !BG_WeaponUnlocked( weapon ) || BG_WeaponDisabled( weapon ) )
{
Class = "locked";
//Padlock icon. UTF-8 encoding of \uf023
Icon = "<icon>\xEF\x80\xA3</icon>";
}

else if(BG_Weapon( weapon )->price > credits){

Class = "expensive";
//$1 bill icon. UTF-8 encoding of \uf0d6
Icon = "<icon>\xEF\x83\x96</icon>";
}
else if( BG_InventoryContainsWeapon( weapon, cg.predictedPlayerState.stats ) ){
Class = "active";
action = va( "onClick='exec \"sell %s\"'", BG_Weapon( weapon )->name );
//Check mark icon. UTF-8 encoding of \uf00c
Icon = "<icon class=\"current\">\xEF\x80\x8C</icon>";
}
else
{
Class = "available";
@@ -174,7 +175,14 @@ static void CG_Rocket_DFCMArmouryBuyUpgrade( int handle, const char *data )
playerState_t *ps = &cg.snap->ps;
int credits = ps->persistant[ PERS_CREDIT ];

if ( !BG_UpgradeUnlocked( upgrade ) || BG_UpgradeDisabled( upgrade ) )
if( BG_InventoryContainsUpgrade( upgrade, cg.predictedPlayerState.stats ) ){
Class = "active";
action = va( "onClick='exec \"sell %s\"'", BG_Upgrade( upgrade )->name );
//Check mark icon. UTF-8 encoding of \uf00c
Icon = "<icon class=\"current\">\xEF\x80\x8C</icon>";
}

else if ( !BG_UpgradeUnlocked( upgrade ) || BG_UpgradeDisabled( upgrade ) )
{
Class = "locked";
//Padlock icon. UTF-8 encoding of \uf023
@@ -186,12 +194,6 @@ static void CG_Rocket_DFCMArmouryBuyUpgrade( int handle, const char *data )
//$1 bill icon. UTF-8 encoding of \uf0d6
Icon = "<icon>\xEF\x83\x96</icon>";
}
else if( BG_InventoryContainsUpgrade( upgrade, cg.predictedPlayerState.stats ) ){
Class = "active";
action = va( "onClick='exec \"sell %s\"'", BG_Upgrade( upgrade )->name );
//Check mark icon. UTF-8 encoding of \uf00c
Icon = "<icon class=\"current\">\xEF\x80\x8C</icon>";
}
else
{
Class = "available";

0 comments on commit a7a803f

Please sign in to comment.
You can’t perform that action at this time.