diff options
author | Tim Angus <tim@ngus.net> | 2003-03-23 04:17:29 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2003-03-23 04:17:29 +0000 |
commit | 6e71d986e00470bcff1e5aba64339fac592b9669 (patch) | |
tree | 8489a84741268d43b49b9e5c696a33dbb5925dee /src/cgame/cg_servercmds.c | |
parent | 62a23c3088d9766003a2df61c374b8e7af5a7fdb (diff) |
* Serverside menu triggering now uses server commands for increased reliability
* Finished code support for new armoury menu
Diffstat (limited to 'src/cgame/cg_servercmds.c')
-rw-r--r-- | src/cgame/cg_servercmds.c | 199 |
1 files changed, 199 insertions, 0 deletions
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index 13059813..b469d0f1 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -500,6 +500,195 @@ static void CG_RemoveChatEscapeChar( char *text ) } /* +=============== +CG_SetUIVars + +Set some cvars used by the UI +=============== +*/ +static void CG_SetUIVars( void ) +{ + int i; + char carriageCvar[ MAX_TOKEN_CHARS ]; + + *carriageCvar = 0; + + //determine what the player is carrying + for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) + { + if( BG_gotWeapon( i, cg.snap->ps.stats ) ) + strcat( carriageCvar, va( "W%d ", i ) ); + } + for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ ) + { + if( BG_gotItem( i, cg.snap->ps.stats ) ) + strcat( carriageCvar, va( "U%d ", i ) ); + } + strcat( carriageCvar, "$" ); + + trap_Cvar_Set( "ui_carriage", carriageCvar ); + + trap_Cvar_Set( "ui_stages", va( "%d %d", cgs.alienStage, cgs.humanStage ) ); +} + + +/* +============== +CG_Menu +============== +*/ +void CG_Menu( int menu ) +{ + CG_SetUIVars( ); + + switch( menu ) + { + case MN_TEAM: trap_SendConsoleCommand( "menu tremulous_teamselect\n" ); break; + case MN_A_CLASS: trap_SendConsoleCommand( "menu tremulous_alienclass\n" ); break; + case MN_H_SPAWN: trap_SendConsoleCommand( "menu tremulous_humanitem\n" ); break; + case MN_A_BUILD: trap_SendConsoleCommand( "menu tremulous_alienbuild\n" ); break; + case MN_H_BUILD: trap_SendConsoleCommand( "menu tremulous_humanbuild\n" ); break; + case MN_H_ARMOURY: trap_SendConsoleCommand( "menu tremulous_humanarmoury\n" ); break; + case MN_H_BANK: trap_SendConsoleCommand( "menu tremulous_humanbank\n" ); break; + case MN_A_OBANK: trap_SendConsoleCommand( "menu tremulous_alienbank\n" ); break; + + case MN_H_NOROOM: + trap_Cvar_Set( "ui_dialog", "There is no room to build here. Move until the buildable turns " + "translucent green indicating a valid build location." ); + trap_SendConsoleCommand( "menu tremulous_human_dialog\n" ); + break; + + case MN_H_NOPOWER: + trap_Cvar_Set( "ui_dialog", "There is no power remaining. Free up power by destroying existing " + "buildable objects." ); + trap_SendConsoleCommand( "menu tremulous_human_dialog\n" ); + break; + + case MN_H_REACTOR: + trap_Cvar_Set( "ui_dialog", "There can only be one reactor. Destroy the existing one if you " + "wish to move it." ); + trap_SendConsoleCommand( "menu tremulous_human_dialog\n" ); + break; + + case MN_H_REPEATER: + trap_Cvar_Set( "ui_dialog", "There is no power here. If available, a Repeater may be used to " + "transmit power to this location." ); + trap_SendConsoleCommand( "menu tremulous_human_dialog\n" ); + break; + + case MN_H_NODCC: + trap_Cvar_Set( "ui_dialog", "There is no Defense Computer. A Defense Computer is needed to build " + "this." ); + trap_SendConsoleCommand( "menu tremulous_human_dialog\n" ); + break; + + case MN_H_RPLWARN: + trap_Cvar_Set( "ui_dialog", "WARNING: This replicator will not be powered. Build a reactor to " + "prevent seeing this message again." ); + trap_SendConsoleCommand( "menu tremulous_human_dialog\n" ); + break; + + case MN_H_RPTWARN: + trap_Cvar_Set( "ui_dialog", "WARNING: This repeater will not be powered as there is no parent " + "reactor providing power. Build a reactor." ); + trap_SendConsoleCommand( "menu tremulous_human_dialog\n" ); + break; + + case MN_H_NOSLOTS: + trap_Cvar_Set( "ui_dialog", "You have no room to carry this. Please sell any conflicting " + "upgrades before purchasing this item." ); + trap_SendConsoleCommand( "menu tremulous_human_dialog\n" ); + break; + + case MN_H_NOFUNDS: + trap_Cvar_Set( "ui_dialog", "Insufficient funds. You do not have enough credits to perform this " + "action." ); + trap_SendConsoleCommand( "menu tremulous_human_dialog\n" ); + break; + + case MN_H_ITEMHELD: + trap_Cvar_Set( "ui_dialog", "You already hold this item. It is not possible to carry multiple items " + "of the same type." ); + trap_SendConsoleCommand( "menu tremulous_human_dialog\n" ); + break; + + case MN_A_NOROOM: + trap_Cvar_Set( "ui_dialog", "There is no room to build here. Move until the structure turns " + "translucent green indicating a valid build location." ); + trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" ); + break; + + case MN_A_NOCREEP: + trap_Cvar_Set( "ui_dialog", "There is no creep here. You must build near existing Eggs or " + "the Overmind. Alien structures will not support themselves." ); + trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" ); + break; + + case MN_A_NOHVMND: + trap_Cvar_Set( "ui_dialog", "There is no Overmind. An Overmind must be built to control " + "the structure you tried to place" ); + trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" ); + break; + + case MN_A_NOEROOM: + trap_Cvar_Set( "ui_dialog", "There is no room to evolve here. Move away from walls or other " + "nearby objects and try again." ); + trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" ); + break; + + case MN_A_HIVEMIND: + trap_Cvar_Set( "ui_dialog", "There can only be one Overmind. Destroy the existing one if you " + "wish to move it." ); + trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" ); + break; + + case MN_A_NOASSERT: + trap_Cvar_Set( "ui_dialog", "The Overmind cannot control anymore structures. Destroy existing " + "structures to build more." ); + trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" ); + break; + + case MN_A_SPWNWARN: + trap_Cvar_Set( "ui_dialog", "WARNING: This spawn will not be controlled by an Overmind. " + "Build an Overmind to prevent seeing this message again." ); + trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" ); + break; + + case MN_A_NORMAL: + trap_Cvar_Set( "ui_dialog", "Cannot build on this surface. This surface is too steep or unsuitable " + "to build on. Please choose another site for this structure." ); + trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" ); + break; + + case MN_A_NOFUNDS: + trap_Cvar_Set( "ui_dialog", "You do not possess sufficient organs to perform this action." ); + trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" ); + break; + + case MN_A_HOVEL_OCCUPIED: + trap_Cvar_Set( "ui_dialog", "This Hovel is occupied by another builder. Please find or build " + "another." ); + trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" ); + break; + + case MN_A_HOVEL_BLOCKED: + trap_Cvar_Set( "ui_dialog", "The exit to this Hovel is currently blocked. Please wait until it " + "becomes clear then try again." ); + trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" ); + break; + + case MN_A_INFEST: + trap_Cvar_Set( "ui_currentClass", va( "%d %d", cg.snap->ps.stats[ STAT_PCLASS ], + cg.snap->ps.persistant[ PERS_CREDIT ] ) ); + trap_SendConsoleCommand( "menu tremulous_alienupgrade\n" ); + break; + + default: + Com_Printf( "cgame: debug: no such menu %d\n", menu ); + } +} + +/* ================= CG_ServerCommand @@ -610,6 +799,16 @@ static void CG_ServerCommand( void ) } } + //the server has triggered a menu + if( !strcmp( cmd, "servermenu" ) ) + { + if( trap_Argc( ) == 2 ) + { + CG_Menu( atoi( CG_Argv( 1 ) ) ); + return; + } + } + CG_Printf( "Unknown client game command: %s\n", cmd ); } |