diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_event.c | 195 | ||||
-rw-r--r-- | src/cgame/cg_servercmds.c | 199 | ||||
-rw-r--r-- | src/game/bg_misc.c | 1 | ||||
-rw-r--r-- | src/game/bg_public.h | 1 | ||||
-rw-r--r-- | src/game/g_active.c | 19 | ||||
-rw-r--r-- | src/game/g_buildable.c | 36 | ||||
-rw-r--r-- | src/game/g_client.c | 4 | ||||
-rw-r--r-- | src/game/g_cmds.c | 40 | ||||
-rw-r--r-- | src/game/g_local.h | 8 | ||||
-rw-r--r-- | src/game/g_main.c | 6 | ||||
-rw-r--r-- | src/game/g_utils.c | 14 | ||||
-rw-r--r-- | src/game/g_weapon.c | 2 |
12 files changed, 278 insertions, 247 deletions
diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c index 1d30e416..857de9d8 100644 --- a/src/cgame/cg_event.c +++ b/src/cgame/cg_event.c @@ -293,195 +293,6 @@ void CG_PainEvent( centity_t *cent, int health ) } /* -=============== -CG_SetUIVars - -Set some cvars used by the UI -=============== -*/ -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 eventParm ) -{ - CG_SetUIVars( ); - - switch( eventParm ) - { - 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", eventParm ); - } -} - -/* ============== CG_EntityEvent @@ -960,12 +771,6 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) CG_Beam( cent ); break; - case EV_MENU: - DEBUGNAME( "EV_MENU" ); - if( es->number == cg.clientNum ) - CG_Menu( es->eventParm ); - break; - case EV_BUILD_DELAY: DEBUGNAME( "EV_BUILD_DELAY" ); //FIXME: change to "negative" sound 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 ); } diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 9451a52a..7bb663f7 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -3574,7 +3574,6 @@ char *eventnames[ ] = "EV_STOPLOOPINGSOUND", "EV_TAUNT", - "EV_MENU", //TA: menu event "EV_BUILD_DELAY", //TA: can't build yet "EV_POISONCLOUD", //TA: client poisoned "EV_KNOCKOVER", //TA: client knocked over diff --git a/src/game/bg_public.h b/src/game/bg_public.h index d86f01f1..e14e1448 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -527,7 +527,6 @@ typedef enum EV_STOPLOOPINGSOUND, EV_TAUNT, - EV_MENU, //TA: menu event EV_BUILD_DELAY, //TA: can't build yet EV_POISONCLOUD, //TA: client poisoned EV_KNOCKOVER, //TA: client knocked over diff --git a/src/game/g_active.c b/src/game/g_active.c index f5470e43..28c03a9c 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -344,11 +344,11 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) if( ( client->buttons & BUTTON_ATTACK ) && !( client->oldbuttons & BUTTON_ATTACK ) ) { if( client->pers.pteam == PTE_NONE ) - G_AddPredictableEvent( ent, EV_MENU, MN_TEAM ); + G_TriggerMenu( ent->client->ps.clientNum, MN_TEAM ); else if( client->pers.pteam == PTE_ALIENS ) - G_AddPredictableEvent( ent, EV_MENU, MN_A_CLASS ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_CLASS ); else if( client->pers.pteam == PTE_HUMANS ) - G_AddPredictableEvent( ent, EV_MENU, MN_H_SPAWN ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_SPAWN ); } // attack button cycles through spectators @@ -1113,7 +1113,7 @@ void ClientThink_real( gentity_t *ent ) else { //exit is blocked - G_AddPredictableEvent( ent, EV_MENU, MN_A_HOVEL_BLOCKED ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_HOVEL_BLOCKED ); } } else @@ -1158,7 +1158,7 @@ void ClientThink_real( gentity_t *ent ) if( client->ps.persistant[ PERS_CREDIT ] > 0 ) { //no nearby objects and alien - show class menu - G_AddPredictableEvent( ent, EV_MENU, MN_A_INFEST ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_INFEST ); } } } @@ -1174,7 +1174,7 @@ void ClientThink_real( gentity_t *ent ) // forcerespawn is to prevent users from waiting out powerups if( g_forcerespawn.integer > 0 && ( level.time - client->respawnTime ) > 0 ) - { //g_forcerespawn.integer * 1000 ) { + { respawn( ent ); return; } @@ -1196,6 +1196,13 @@ void ClientThink_real( gentity_t *ent ) ClientSpawn( ent, client->infestBody ); } + if( level.framenum > client->retriggerArmouryMenu && client->retriggerArmouryMenu ) + { + G_TriggerMenu( client->ps.clientNum, MN_H_ARMOURY ); + + client->retriggerArmouryMenu = 0; + } + // perform once-a-second actions ClientTimerActions( ent, msec ); } diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index f83faefe..b3a7e5b4 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -709,7 +709,7 @@ void AHovel_Use( gentity_t *self, gentity_t *other, gentity_t *activator ) if( self->active ) { //this hovel is in use - G_AddPredictableEvent( activator, EV_MENU, MN_A_HOVEL_OCCUPIED ); + G_TriggerMenu( activator->client->ps.clientNum, MN_A_HOVEL_OCCUPIED ); } else if( ( activator->client->ps.stats[ STAT_PCLASS ] == PCL_A_B_BASE ) || ( activator->client->ps.stats[ STAT_PCLASS ] == PCL_A_B_LEV1 ) ) @@ -1099,9 +1099,9 @@ void HArmoury_Activate( gentity_t *self, gentity_t *other, gentity_t *activator //if this is powered then call the armoury menu if( self->powered ) - G_AddPredictableEvent( activator, EV_MENU, MN_H_ARMOURY ); + G_TriggerMenu( activator->client->ps.clientNum, MN_H_ARMOURY ); else - G_AddPredictableEvent( activator, EV_MENU, MN_H_NOPOWER ); + G_TriggerMenu( activator->client->ps.clientNum, MN_H_NOPOWER ); } /* @@ -1140,9 +1140,9 @@ void HBank_Activate( gentity_t *self, gentity_t *other, gentity_t *activator ) //if this is powered then call the bank menu if( self->powered ) - G_AddPredictableEvent( activator, EV_MENU, MN_H_BANK ); + G_TriggerMenu( activator->client->ps.clientNum, MN_H_BANK ); else - G_AddPredictableEvent( activator, EV_MENU, MN_H_NOPOWER ); + G_TriggerMenu( activator->client->ps.clientNum, MN_H_NOPOWER ); } /* @@ -2070,56 +2070,56 @@ qboolean G_ValidateBuild( gentity_t *ent, buildable_t buildable ) return qtrue; case IBE_NOASSERT: - G_AddPredictableEvent( ent, EV_MENU, MN_A_NOASSERT ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_NOASSERT ); return qfalse; case IBE_NOHIVEMIND: - G_AddPredictableEvent( ent, EV_MENU, MN_A_NOHVMND ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_NOHVMND ); return qfalse; case IBE_HIVEMIND: - G_AddPredictableEvent( ent, EV_MENU, MN_A_HIVEMIND ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_HIVEMIND ); return qfalse; case IBE_NORMAL: - G_AddPredictableEvent( ent, EV_MENU, MN_A_NORMAL ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_NORMAL ); return qfalse; case IBE_REACTOR: - G_AddPredictableEvent( ent, EV_MENU, MN_H_REACTOR ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_REACTOR ); return qfalse; case IBE_REPEATER: - G_AddPredictableEvent( ent, EV_MENU, MN_H_REPEATER ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_REPEATER ); return qfalse; case IBE_NOROOM: if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) - G_AddPredictableEvent( ent, EV_MENU, MN_H_NOROOM ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOROOM ); else - G_AddPredictableEvent( ent, EV_MENU, MN_A_NOROOM ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_NOROOM ); return qfalse; case IBE_NOPOWER: - G_AddPredictableEvent( ent, EV_MENU, MN_H_NOPOWER ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOPOWER ); return qfalse; case IBE_NODCC: - G_AddPredictableEvent( ent, EV_MENU, MN_H_NODCC ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NODCC ); return qfalse; case IBE_SPWNWARN: - G_AddPredictableEvent( ent, EV_MENU, MN_A_SPWNWARN ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_SPWNWARN ); G_buildItem( ent, buildable, origin, ent->s.apos.trBase ); return qtrue; case IBE_RPLWARN: - G_AddPredictableEvent( ent, EV_MENU, MN_H_RPLWARN ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_RPLWARN ); G_buildItem( ent, buildable, origin, ent->s.apos.trBase ); return qtrue; case IBE_RPTWARN: - G_AddPredictableEvent( ent, EV_MENU, MN_H_RPTWARN ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_RPTWARN ); G_buildItem( ent, buildable, origin, ent->s.apos.trBase ); return qtrue; } diff --git a/src/game/g_client.c b/src/game/g_client.c index 65bc992c..a77cf96b 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1348,9 +1348,9 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn ) if( client->sess.sessionTeam == TEAM_SPECTATOR ) { if( teamLocal == PTE_ALIENS ) - G_AddPredictableEvent( ent, EV_MENU, MN_A_CLASS ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_CLASS ); else if( teamLocal == PTE_HUMANS ) - G_AddPredictableEvent( ent, EV_MENU, MN_H_SPAWN ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_SPAWN ); } // increment the spawncount so the client will detect the respawn diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index c197bdaa..4deac46a 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1024,7 +1024,7 @@ void Cmd_Class_f( gentity_t *ent ) else { ent->client->pers.pclass = PCL_NONE; - G_AddPredictableEvent( ent, EV_MENU, MN_A_NOEROOM ); + G_TriggerMenu( clientNum, MN_A_NOEROOM ); return; } } @@ -1279,7 +1279,7 @@ void Cmd_Buy_f( gentity_t *ent ) //already got this? if( BG_gotWeapon( weapon, ent->client->ps.stats ) ) { - G_AddPredictableEvent( ent, EV_MENU, MN_H_ITEMHELD ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_ITEMHELD ); return; } @@ -1292,14 +1292,14 @@ void Cmd_Buy_f( gentity_t *ent ) BG_FindPriceForWeapon( weapon ), (short)ent->client->ps.persistant[ PERS_CREDIT ] ); - G_AddPredictableEvent( ent, EV_MENU, MN_H_NOFUNDS ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS ); return; } //have space to carry this? if( BG_FindSlotsForWeapon( weapon ) & ent->client->ps.stats[ STAT_SLOTS ] ) { - G_AddPredictableEvent( ent, EV_MENU, MN_H_NOSLOTS ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOSLOTS ); return; } @@ -1350,14 +1350,14 @@ void Cmd_Buy_f( gentity_t *ent ) //already got this? if( BG_gotItem( upgrade, ent->client->ps.stats ) ) { - G_AddPredictableEvent( ent, EV_MENU, MN_H_ITEMHELD ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_ITEMHELD ); return; } //can afford this? if( BG_FindPriceForUpgrade( upgrade ) > (short)ent->client->ps.persistant[ PERS_CREDIT ] ) { - G_AddPredictableEvent( ent, EV_MENU, MN_H_NOFUNDS ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS ); G_LogPrintf( "Client %d buying upgrade %d, value %d, credit %d\n", ent->client->ps.clientNum, weapon, @@ -1370,7 +1370,7 @@ void Cmd_Buy_f( gentity_t *ent ) //have space to carry this? if( BG_FindSlotsForUpgrade( upgrade ) & ent->client->ps.stats[ STAT_SLOTS ] ) { - G_AddPredictableEvent( ent, EV_MENU, MN_H_NOSLOTS ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOSLOTS ); return; } @@ -1403,7 +1403,7 @@ void Cmd_Buy_f( gentity_t *ent ) if( clips + newClips > maxClips ) { //FIXME: different dialog? - G_AddPredictableEvent( ent, EV_MENU, MN_H_NOSLOTS ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOSLOTS ); return; } else @@ -1437,7 +1437,7 @@ void Cmd_Buy_f( gentity_t *ent ) G_AddPredictableEvent( ent, EV_NEXT_WEAPON, 0 ); //retrigger the armoury menu - G_AddPredictableEvent( ent, EV_MENU, MN_H_ARMOURY ); + ent->client->retriggerArmouryMenu = level.framenum + RAM_FRAMES; //update ClientInfo ClientUserinfoChanged( ent->client->ps.clientNum ); @@ -1522,7 +1522,7 @@ void Cmd_Sell_f( gentity_t *ent ) trap_SendServerCommand( ent-g_entities, va( "print \"Unknown item\n\"" ) ); //retrigger the armoury menu - G_AddPredictableEvent( ent, EV_MENU, MN_H_ARMOURY ); + ent->client->retriggerArmouryMenu = level.framenum + RAM_FRAMES; //update ClientInfo ClientUserinfoChanged( ent->client->ps.clientNum ); @@ -1583,7 +1583,7 @@ void Cmd_Deposit_f( gentity_t *ent ) level.bankCredits[ ent->client->ps.clientNum ] += amount; } else - G_AddPredictableEvent( ent, EV_MENU, MN_H_NOFUNDS ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS ); } else trap_SendServerCommand( ent-g_entities, va( "print \"Aliens have no bank\n\"" ) ); @@ -1645,7 +1645,7 @@ void Cmd_Withdraw_f( gentity_t *ent ) level.bankCredits[ ent->client->ps.clientNum ] -= amount; } else - G_AddPredictableEvent( ent, EV_MENU, MN_H_NOFUNDS ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS ); } else trap_SendServerCommand( ent-g_entities, va( "print \"Aliens have no bank\n\"" ) ); @@ -1693,35 +1693,35 @@ void Cmd_Build_f( gentity_t *ent ) break; case IBE_NOASSERT: - G_AddPredictableEvent( ent, EV_MENU, MN_A_NOASSERT ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_NOASSERT ); break; case IBE_NOHIVEMIND: - G_AddPredictableEvent( ent, EV_MENU, MN_A_NOHVMND ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_NOHVMND ); break; case IBE_HIVEMIND: - G_AddPredictableEvent( ent, EV_MENU, MN_A_HIVEMIND ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_HIVEMIND ); break; case IBE_REACTOR: - G_AddPredictableEvent( ent, EV_MENU, MN_H_REACTOR ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_REACTOR ); break; case IBE_REPEATER: - G_AddPredictableEvent( ent, EV_MENU, MN_H_REPEATER ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_REPEATER ); break; case IBE_NOPOWER: - G_AddPredictableEvent( ent, EV_MENU, MN_H_NOPOWER ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOPOWER ); break; case IBE_NOCREEP: - G_AddPredictableEvent( ent, EV_MENU, MN_A_NOCREEP ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_NOCREEP ); break; case IBE_NODCC: - G_AddPredictableEvent( ent, EV_MENU, MN_H_NODCC ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NODCC ); break; } } diff --git a/src/game/g_local.h b/src/game/g_local.h index 7a6c5521..c0fd6981 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -185,11 +185,10 @@ struct gentity_s int killedBy; //TA: clientNum of killer gentity_t *targeted; //TA: true if the player is currently a valid target of a turret + vec3_t turretAim; //TA: aim vector for turrets vec4_t animation; //TA: animated map objects - vec3_t turretAim; //TA: aim vector for turrets - gentity_t *builder; //TA: occupant of this hovel qboolean nonSegModel; //TA: this entity uses a nonsegmented player model @@ -363,6 +362,9 @@ struct gclient_s int lastFlameBall; //TA: s.number of the last flame ball fired int lastRefilTime; //TA: last time human got a refil from rpt/rctr + +#define RAM_FRAMES 1 //TA: number of frames to wait before retriggering + int retriggerArmouryMenu; //TA: frame number to retrigger the armoury menu }; #define MAX_LOCDAMAGE_TEXT 8192 @@ -588,6 +590,8 @@ void G_SetOrigin( gentity_t *ent, vec3_t origin ); void AddRemap(const char *oldShader, const char *newShader, float timeOffset); const char *BuildShaderStateConfig(); +void G_TriggerMenu( int clientNum, dynMenu_t menu ); + // // g_combat.c // diff --git a/src/game/g_main.c b/src/game/g_main.c index 584fe4b4..5e472b44 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -236,13 +236,17 @@ void QDECL G_Printf( const char *fmt, ... ) { va_list argptr; char text[ 1024 ]; + char clientText[ 1048 ]; va_start( argptr, fmt ); vsprintf( text, fmt, argptr ); va_end( argptr ); if( !g_dedicated.integer ) - trap_SendServerCommand( -1, va( "gprintf \"%s\"", text ) ); + { + Com_sprintf( clientText, 1048, "gprintf \"%s\"", text ); + trap_SendServerCommand( -1, clientText ); + } trap_Printf( text ); } diff --git a/src/game/g_utils.c b/src/game/g_utils.c index 708c3799..3c5ef2e2 100644 --- a/src/game/g_utils.c +++ b/src/game/g_utils.c @@ -726,6 +726,20 @@ qboolean G_Visible( gentity_t *ent1, gentity_t *ent2 ) return qtrue; } +/* +=============== +G_TriggerMenu + +Trigger a menu on some client +=============== +*/ +void G_TriggerMenu( int clientNum, dynMenu_t menu ) +{ + char buffer[ 32 ]; + + Com_sprintf( buffer, 32, "servermenu %d", menu ); + trap_SendServerCommand( clientNum, buffer ); +} /* ================ diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index 11eb3b0c..968b2149 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -482,7 +482,7 @@ void buildFire( gentity_t *ent, dynMenu_t menu ) return; } - G_AddPredictableEvent( ent, EV_MENU, menu ); + G_TriggerMenu( ent->client->ps.clientNum, menu ); } |