summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2001-06-16 19:19:42 +0000
committerTim Angus <tim@ngus.net>2001-06-16 19:19:42 +0000
commitba6e8c35bf5ffcdca53eb2345319c402ba50a86d (patch)
tree6bf0d270bfa93980cc6bc8a36373848dc1789a74 /src
parent96c0b0481787295d3cce286429b97d1432b5ee95 (diff)
Restructured dynamic menu handling
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_consolecmds.c56
-rw-r--r--src/cgame/cg_event.c16
-rw-r--r--src/game/bg_misc.c2
-rw-r--r--src/game/bg_public.h3
-rw-r--r--src/game/g_active.c2
-rw-r--r--src/game/g_client.c1
-rw-r--r--src/game/g_cmds.c16
-rw-r--r--src/game/g_local.h1
8 files changed, 79 insertions, 18 deletions
diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c
index 7df6f751..8d88c0a8 100644
--- a/src/cgame/cg_consolecmds.c
+++ b/src/cgame/cg_consolecmds.c
@@ -189,6 +189,52 @@ static void CG_StartOrbit_f( void ) {
}
}
+/*
+==================
+CG_ClientMenu
+==================
+*/
+static void CG_ClientMenu( const char *menuname )
+{
+ char menuDef[ MAX_STRING_CHARS ];
+ int i;
+
+ if( !Q_stricmp( menuname, "dinfest" ) )
+ {
+ strcpy( menuDef, "5,5|Infest|0.976,0.957,0.0,1.0|0.933,0.612,0.0,1.0|0.976,0.957,0.0,1.0|1|16|" );
+ for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ )
+ {
+ if( BG_ClassCanEvolveFromTo( cg.snap->ps.stats[ STAT_PCLASS ], i ) )
+ strcat( menuDef, va( "%s, class %s|", BG_FindNameForClassNum( i ), BG_FindNameForClassNum( i ) ) );
+ }
+ strcat( menuDef, "|Choose a class|to evolve to" );
+
+ trap_SendConsoleCommand( va( "defmenu infest \"%s\"\n", menuDef ) );
+ trap_SendConsoleCommand( "menu infest\n" );
+ trap_SendConsoleCommand( "undefmenu infest\n" );
+ }
+ else if( !Q_stricmp( menuname, "hmcusell" ) )
+ {
+ strcpy( menuDef, "5,5|Sell|1,1,1,1|0.000,0.412,0.702,1|1,1,1,1|2|32||" );
+ for( i = WP_NONE +1; i < WP_NUM_WEAPONS; i++ )
+ {
+ if( BG_gotWeapon( i, cg.snap->ps.stats ) )
+ strcat( menuDef, va( "%s, sell %s|", BG_FindHumanNameForWeapon( i ), BG_FindNameForWeapon( i ) ) );
+ }
+ for( i = UP_NONE +1; i < UP_NUM_UPGRADES; i++ )
+ {
+ if( BG_gotItem( i, cg.snap->ps.stats ) )
+ strcat( menuDef, va( "%s, sell %s|", BG_FindHumanNameForUpgrade( i ), BG_FindNameForUpgrade( i ) ) );
+ }
+ strcat( menuDef, "Previous, menu hmcumenu||Choose an item|to sell" );
+
+ trap_SendConsoleCommand( va( "defmenu mcusell \"%s\"\n", menuDef ) );
+ trap_SendConsoleCommand( "menu mcusell\n" );
+ trap_SendConsoleCommand( "undefmenu mcusell\n" );
+ }
+ else
+ trap_SendConsoleCommand( va( "%s not defined", menuname ) );
+}
typedef struct {
char *cmd;
@@ -232,10 +278,19 @@ Cmd_Argc() / Cmd_Argv()
*/
qboolean CG_ConsoleCommand( void ) {
const char *cmd;
+ const char *arg1;
int i;
cmd = CG_Argv(0);
+ //TA: ugly hacky special case
+ if( !Q_stricmp( cmd, "cmenu" ) )
+ {
+ arg1 = CG_Argv( 1 );
+ CG_ClientMenu( arg1 );
+ return qtrue;
+ }
+
for ( i = 0 ; i < sizeof( commands ) / sizeof( commands[0] ) ; i++ ) {
if ( !Q_stricmp( cmd, commands[i].cmd ) ) {
commands[i].function();
@@ -304,5 +359,6 @@ void CG_InitConsoleCommands( void ) {
trap_AddCommand ("menu");
trap_AddCommand ("defmenu");
trap_AddCommand ("undefmenu");
+ trap_AddCommand ("cmenu");
trap_AddCommand ("loaddefered"); // spelled wrong, but not changing for demo
}
diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c
index 0e62f75d..822b8d1e 100644
--- a/src/cgame/cg_event.c
+++ b/src/cgame/cg_event.c
@@ -502,18 +502,12 @@ void CG_Menu( int eventParm )
trap_SendConsoleCommand( "menu hrptwarn\n" );
break;
+ case MN_H_NOSLOTS:
+ trap_SendConsoleCommand( "menu hnoslots\n" );
+ break;
+
case MN_D_INFEST:
- strcpy( menuDef, "5,5|Infest|0.976,0.957,0.0,1.0|0.933,0.612,0.0,1.0|0.976,0.957,0.0,1.0|1|16|" );
- for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ )
- {
- if( BG_ClassCanEvolveFromTo( cg.snap->ps.stats[ STAT_PCLASS ], i ) )
- strcat( menuDef, va( "%s, class %s|", BG_FindNameForClassNum( i ), BG_FindNameForClassNum( i ) ) );
- }
- strcat( menuDef, "|Choose a class|to evolve to" );
-
- trap_SendConsoleCommand( va( "defmenu infest \"%s\"\n", menuDef ) );
- trap_SendConsoleCommand( "menu infest\n" );
- trap_SendConsoleCommand( "undefmenu infest\n" );
+ trap_SendConsoleCommand( "menu dinfest\n" );
break;
default:
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index 5884055e..4cfcfc70 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -2063,7 +2063,7 @@ upgradeAttributes_t bg_upgrades[ ] =
100,
SLOT_HEAD,
"nvg",
- "nvg"
+ "NVG"
},
{
UP_CHESTARMOUR,
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index cd01d87f..07353455 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -546,7 +546,8 @@ typedef enum
MN_H_REPEATER,
MN_H_RPLWARN,
MN_H_RPTWARN,
- MN_H_MCUPOWER
+ MN_H_MCUPOWER,
+ MN_H_NOSLOTS
} dynMenu_t;
// animations
diff --git a/src/game/g_active.c b/src/game/g_active.c
index 18da18d7..e0a3654a 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -752,7 +752,7 @@ void ClientThink_real( gentity_t *ent ) {
client->ps.gravity = g_gravity.value;
// set speed
- client->ps.speed = g_speed.value * client->classSpeed;
+ client->ps.speed = g_speed.value * BG_FindSpeedForClass( client->ps.stats[ STAT_PCLASS ] );
//TA: slow player if standing in creep
for ( i = 1, creepNode = g_entities + i; i < level.num_entities; i++, creepNode++ )
diff --git a/src/game/g_client.c b/src/game/g_client.c
index e81a3ab2..810ad6d6 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -1314,7 +1314,6 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn ) {
client->pers.maxHealth = client->ps.stats[ STAT_MAX_HEALTH ] = BG_FindHealthForClass( ent->client->pers.pclass );
client->ps.stats[ STAT_ARMOR ] = BG_FindArmorForClass( ent->client->pers.pclass );
- client->classSpeed = BG_FindSpeedForClass( ent->client->pers.pclass );
// clear entity values
switch( ent->client->pers.pclass )
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 5372f037..9f0d4c6a 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -1846,9 +1846,15 @@ void Cmd_Buy_f( gentity_t *ent )
weapon = BG_FindWeaponNumForName( s );
upgrade = BG_FindUpgradeNumForName( s );
-
+
if( weapon != WP_NONE )
{
+ if( BG_FindSlotsForWeapon( weapon ) & ent->client->ps.stats[ STAT_SLOTS ] )
+ {
+ G_AddPredictableEvent( ent, EV_MENU, MN_H_NOSLOTS );
+ return;
+ }
+
BG_packWeapon( weapon, ent->client->ps.stats );
BG_FindAmmoForWeapon( weapon, &quan, &clips, &maxClips );
BG_packAmmoArray( weapon, ent->client->ps.ammo, ent->client->ps.powerups,
@@ -1857,6 +1863,12 @@ void Cmd_Buy_f( gentity_t *ent )
}
else if( upgrade != UP_NONE )
{
+ if( BG_FindSlotsForUpgrade( upgrade ) & ent->client->ps.stats[ STAT_SLOTS ] )
+ {
+ G_AddPredictableEvent( ent, EV_MENU, MN_H_NOSLOTS );
+ return;
+ }
+
BG_packItem( upgrade, ent->client->ps.stats );
}
else
@@ -1914,7 +1926,7 @@ void Cmd_Sell_f( gentity_t *ent )
}
else if( upgrade != UP_NONE )
{
- if( BG_gotItem( weapon, ent->client->ps.stats ) )
+ if( BG_gotItem( upgrade, ent->client->ps.stats ) )
BG_removeItem( upgrade, ent->client->ps.stats );
}
else
diff --git a/src/game/g_local.h b/src/game/g_local.h
index b635b880..1a1dbfa0 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -324,7 +324,6 @@ struct gclient_s {
char *areabits;
- float classSpeed; //TA: here to save STAT_ space
int lastInfestTime; //TA: to keep track of how long infests take
gentity_t *infestBody; //TA: body that is being infested. must be persistant
};