summaryrefslogtreecommitdiff
path: root/src/game/g_cmds.c
diff options
context:
space:
mode:
authorBen Millwood <thebenmachine@gmail.com>2009-10-03 12:56:12 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:20 +0000
commit14e2615133a3bb635e9d7fd20a3ac716e57435f2 (patch)
tree86342c81ee0702b35a0bf132a32423a25c7bed95 /src/game/g_cmds.c
parent564fbccd704780f16dd58e03278b11336944fb68 (diff)
Reduce redundancy in Cmd_Build_f
Diffstat (limited to 'src/game/g_cmds.c')
-rw-r--r--src/game/g_cmds.c44
1 files changed, 18 insertions, 26 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 9c670d5a..d2bbf97b 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -2501,8 +2501,11 @@ void Cmd_Build_f( gentity_t *ent )
( ( team == TEAM_ALIENS && BG_BuildableAllowedInStage( buildable, g_alienStage.integer ) ) ||
( team == TEAM_HUMANS && BG_BuildableAllowedInStage( buildable, g_humanStage.integer ) ) ) )
{
+ dynMenu_t err;
dist = BG_Class( ent->client->ps.stats[ STAT_CLASS ] )->buildDist;
+ ent->client->ps.stats[ STAT_BUILDABLE ] = 0;
+
//these are the errors displayed when the builder first selects something to use
switch( G_CanBuild( ent, buildable, dist, origin ) )
{
@@ -2512,7 +2515,9 @@ void Cmd_Build_f( gentity_t *ent )
case IBE_RPTNOREAC:
case IBE_RPTPOWERHERE:
case IBE_SPWNWARN:
- ent->client->ps.stats[ STAT_BUILDABLE ] = ( buildable | SB_VALID_TOGGLEBIT );
+ err = MN_NONE;
+ // we OR-in the selected builable later
+ ent->client->ps.stats[ STAT_BUILDABLE ] = SB_VALID_TOGGLEBIT;
break;
// can't place yet but maybe soon: start with valid togglebit off
@@ -2523,55 +2528,42 @@ void Cmd_Build_f( gentity_t *ent )
case IBE_NOOVERMIND:
case IBE_NOPOWERHERE:
case IBE_RPWCAUSEOVRL:
- ent->client->ps.stats[ STAT_BUILDABLE ] = buildable;
+ err = MN_NONE;
break;
// more serious errors just pop a menu
case IBE_NOALIENBP:
- if( ent->client->pers.disableBlueprintErrors )
- ent->client->ps.stats[ STAT_BUILDABLE ] = buildable;
- else
- G_TriggerMenu( ent->client->ps.clientNum, MN_A_NOBP );
+ err = MN_A_NOBP;
break;
case IBE_ONEOVERMIND:
- if( ent->client->pers.disableBlueprintErrors )
- ent->client->ps.stats[ STAT_BUILDABLE ] = buildable;
- else
- G_TriggerMenu( ent->client->ps.clientNum, MN_A_ONEOVERMIND );
+ err = MN_A_ONEOVERMIND;
break;
case IBE_ONEHOVEL:
- if( ent->client->pers.disableBlueprintErrors )
- ent->client->ps.stats[ STAT_BUILDABLE ] = buildable;
- else
- G_TriggerMenu( ent->client->ps.clientNum, MN_A_ONEHOVEL );
+ err = MN_A_ONEHOVEL;
break;
case IBE_ONEREACTOR:
- if( ent->client->pers.disableBlueprintErrors )
- ent->client->ps.stats[ STAT_BUILDABLE ] = buildable;
- else
- G_TriggerMenu( ent->client->ps.clientNum, MN_H_ONEREACTOR );
+ err = MN_H_ONEREACTOR;
break;
case IBE_NOHUMANBP:
- if( ent->client->pers.disableBlueprintErrors )
- ent->client->ps.stats[ STAT_BUILDABLE ] = buildable;
- else
- G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOBP);
+ err = MN_H_NOBP;
break;
case IBE_NODCC:
- if( ent->client->pers.disableBlueprintErrors )
- ent->client->ps.stats[ STAT_BUILDABLE ] = buildable;
- else
- G_TriggerMenu( ent->client->ps.clientNum, MN_H_NODCC );
+ err = MN_H_NODCC;
break;
default:
break;
}
+
+ if( err == MN_NONE || ent->client->pers.disableBlueprintErrors )
+ ent->client->ps.stats[ STAT_BUILDABLE ] |= buildable;
+ else
+ G_TriggerMenu( ent->client->ps.clientNum, err );
}
else
G_TriggerMenu( ent->client->ps.clientNum, MN_B_CANNOT );