diff options
-rw-r--r-- | src/cgame/cg_servercmds.c | 180 | ||||
-rw-r--r-- | src/game/bg_public.h | 25 | ||||
-rw-r--r-- | src/game/g_buildable.c | 15 | ||||
-rw-r--r-- | src/game/g_cmds.c | 40 | ||||
-rw-r--r-- | src/game/g_local.h | 1 | ||||
-rw-r--r-- | src/game/g_utils.c | 16 | ||||
-rw-r--r-- | ui/ingame_options.menu | 3 |
7 files changed, 138 insertions, 142 deletions
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index d875dcc1..afc45780 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -454,13 +454,13 @@ static void CG_RemoveChatEscapeChar( char *text ) CG_Menu ============== */ -void CG_Menu( int menu ) +void CG_Menu( int menu, int arg ) { - const char *cmd = NULL; // command to send - const char *longMsg = NULL; // command parameter - const char *shortMsg = NULL; // non-modal version of message - + const char *cmd; // command to send + const char *longMsg = NULL; // command parameter + const char *shortMsg = NULL; // non-modal version of message const char *dialog; + switch( cg.snap->ps.stats[ STAT_PTEAM ] ) { case PTE_ALIENS: @@ -472,6 +472,7 @@ void CG_Menu( int menu ) default: dialog = "menu tremulous_default_dialog\n"; } + cmd = dialog; switch( menu ) { @@ -503,28 +504,24 @@ void CG_Menu( int menu ) longMsg = "The alien team has too many players. Please wait until slots " "become available or join the human team."; shortMsg = "The alien team has too many players"; - cmd = dialog; break; case MN_H_TEAMFULL: longMsg = "The human team has too many players. Please wait until slots " "become available or join the alien team."; shortMsg = "The human team has too many players"; - cmd = dialog; break; case MN_A_TEAMCHANGEBUILDTIMER: longMsg = "You cannot leave the Alien team until your build timer " "has expired."; shortMsg = "You cannot change teams until your build timer expires."; - cmd = dialog; break; case MN_H_TEAMCHANGEBUILDTIMER: longMsg = "You cannot leave the Human team until your build timer " "has expired."; shortMsg = "You cannot change teams until your build timer expires."; - cmd = dialog; break; //=============================== @@ -533,42 +530,36 @@ void CG_Menu( int menu ) // via console. In light of this, perhaps opening a menu is // counterintuitive case MN_CMD_CHEAT: - longMsg = "This action is considered cheating. It can only be used " - "in cheat mode, which is not enabled on this server."; + //longMsg = "This action is considered cheating. It can only be used " + // "in cheat mode, which is not enabled on this server."; shortMsg = "Cheats are not enabled on this server"; - cmd = dialog; break; case MN_CMD_TEAM: - longMsg = "You must be on a team to perform this action. Join the alien" - "or human team and try again."; + //longMsg = "You must be on a team to perform this action. Join the alien" + // "or human team and try again."; shortMsg = "Join a team first"; - cmd = dialog; break; case MN_CMD_SPEC: - longMsg = "You may not perform this action while on a team. Become a " - "spectator before trying again."; + //longMsg = "You may not perform this action while on a team. Become a " + // "spectator before trying again."; shortMsg = "You can only use this command when spectating"; - cmd = dialog; break; case MN_CMD_ALIEN: - longMsg = "You must be on the alien team to perform this action."; + //longMsg = "You must be on the alien team to perform this action."; shortMsg = "Must be alien to use this command"; - cmd = dialog; break; case MN_CMD_HUMAN: - longMsg = "You must be on the human team to perform this action."; + //longMsg = "You must be on the human team to perform this action."; shortMsg = "Must be human to use this command"; - cmd = dialog; break; case MN_CMD_LIVING: - longMsg = "You must be living to perform this action."; + //longMsg = "You must be living to perform this action."; shortMsg = "Must be living to use this command"; - cmd = dialog; break; @@ -578,7 +569,6 @@ void CG_Menu( int menu ) longMsg = "There is no room to build here. Move until the structure turns " "translucent green indicating a valid build location."; shortMsg = "There is no room to build here"; - cmd = dialog; break; case MN_B_NORMAL: @@ -586,114 +576,105 @@ void CG_Menu( int menu ) "unsuitable to build on. Please choose another site for this " "structure."; shortMsg = "Cannot build on this surface"; - cmd = dialog; + break; + + case MN_B_CANNOT: + longMsg = NULL; + shortMsg = "You cannot build that structure"; + break; + + case MN_B_SUDDENDEATH: + longMsg = "Neither team has prevailed after a certain time and the " + "game has entered Sudden Death. During Sudden Death " + "building is not allowed."; + shortMsg = "Cannot build during Sudden Death"; + break; + + case MN_B_REVOKED: + longMsg = "Your teammates have lost faith in your ability to build " + "for the team. You will not be allowed to build until your " + "team votes to reinstate your building rights."; + shortMsg = "Your building rights have been revoked"; break; //=============================== case MN_H_NOBP: - longMsg = "There is no power remaining. Free up power by destroying " + longMsg = "There is no power remaining. Free up power by deconstructing " "existing buildable objects."; shortMsg = "There is no power remaining"; - cmd = dialog; break; case MN_H_NOTPOWERED: longMsg = "This buildable is not powered. Build a Reactor and/or Repeater " "in order to power it."; shortMsg = "This buildable is not powered"; - cmd = dialog; break; case MN_H_ONEREACTOR: - longMsg = "There can only be one Reactor. Destroy the existing one if you " + longMsg = "There can only be one Reactor. Deconstruct the existing one if you " "wish to move it."; shortMsg = "There can only be one Reactor"; - cmd = dialog; break; case MN_H_NOPOWERHERE: longMsg = "There is no power here. If available, a Repeater may be used to " "transmit power to this location."; shortMsg = "There is no power here"; - cmd = dialog; break; case MN_H_NODCC: longMsg = "There is no Defense Computer. A Defense Computer is needed to " "build this."; shortMsg = "There is no Defense Computer"; - cmd = dialog; - break; - - case MN_H_TNODEWARN: - longMsg = "WARNING: This Telenode will not be powered. Build near a power " - "structure to prevent seeing this message again."; - shortMsg = "This Telenode will not be powered"; - cmd = dialog; - break; - - case MN_H_RPTNOREAC: - longMsg = "WARNING: This Repeater will not be powered as there is no parent " - "Reactor providing power. Build a Reactor."; - shortMsg = "This Repeater will not be powered"; - cmd = dialog; break; case MN_H_RPTPOWERHERE: longMsg = "This area already has power. A Repeater is not required here."; shortMsg = "This area already has power"; - cmd = dialog; break; case MN_H_NOSLOTS: longMsg = "You have no room to carry this. Please sell any conflicting " "upgrades before purchasing this item."; shortMsg = "You have no room to carry this"; - cmd = dialog; break; case MN_H_NOFUNDS: longMsg = "Insufficient funds. You do not have enough credits to perform " "this action."; shortMsg = "Insufficient funds"; - cmd = dialog; break; case MN_H_ITEMHELD: longMsg = "You already hold this item. It is not possible to carry multiple " "items of the same type."; shortMsg = "You already hold this item"; - cmd = dialog; break; case MN_H_NOARMOURYHERE: longMsg = "You must be near a powered Armoury in order to purchase " "weapons, upgrades or non-energy ammunition."; shortMsg = "You must be near a powered Armoury"; - cmd = dialog; break; case MN_H_NOENERGYAMMOHERE: longMsg = "You must be near an Armoury, Reactor or Repeater in order " "to purchase energy ammunition."; shortMsg = "You must be near an Armoury, Reactor or Repeater"; - cmd = dialog; break; case MN_H_NOROOMBSUITON: longMsg = "There is not enough room here to put on a Battle Suit. " "Make sure you have enough head room to climb in."; shortMsg = "Not enough room here to put on a Battle Suit"; - cmd = dialog; break; case MN_H_NOROOMBSUITOFF: longMsg = "There is not enough room here to take off your Battle Suit. " "Make sure you have enough head room to climb out."; shortMsg = "Not enough room here to take off your Battle Suit"; - cmd = dialog; break; case MN_H_ARMOURYBUILDTIMER: @@ -701,9 +682,15 @@ void CG_Menu( int menu ) "build timer has expired."; shortMsg = "You can not buy or sell weapos until your build timer " "expires"; - cmd = dialog; break; + case MN_H_DEADTOCLASS: + shortMsg = "You must be dead to use the class command"; + break; + + case MN_H_UNKNOWNSPAWNITEM: + shortMsg = "Unknown starting item"; + break; //=============================== @@ -711,48 +698,35 @@ void CG_Menu( int menu ) longMsg = "There is no creep here. You must build near existing Eggs or " "the Overmind. Alien structures will not support themselves."; shortMsg = "There is no creep here"; - cmd = dialog; break; case MN_A_NOOVMND: longMsg = "There is no Overmind. An Overmind must be built to control " "the structure you tried to place"; shortMsg = "There is no Overmind"; - cmd = dialog; break; case MN_A_ONEOVERMIND: - longMsg = "There can only be one Overmind. Destroy the existing one if you " + longMsg = "There can only be one Overmind. Deconstruct the existing one if you " "wish to move it."; shortMsg = "There can only be one Overmind"; - cmd = dialog; break; case MN_A_ONEHOVEL: - longMsg = "There can only be one Hovel. Destroy the existing one if you " + longMsg = "There can only be one Hovel. Deconstruct the existing one if you " "wish to move it."; shortMsg = "There can only be one Hovel"; - cmd = dialog; break; case MN_A_NOBP: - longMsg = "The Overmind cannot control any more structures. Destroy existing " + longMsg = "The Overmind cannot control any more structures. Deconstruct existing " "structures to build more."; shortMsg = "The Overmind cannot control any more structures"; - cmd = dialog; - break; - - case MN_A_SPWNWARN: - longMsg = "WARNING: This spawn will not be controlled by an Overmind. " - "Build an Overmind to prevent seeing this message again."; - shortMsg = "This spawn will not be controlled by an Overmind"; - cmd = dialog; break; case MN_A_NOEROOM: longMsg = "There is no room to evolve here. Move away from walls or other " "nearby objects and try again."; - cmd = dialog; shortMsg = "There is no room to evolve here"; break; @@ -761,40 +735,34 @@ void CG_Menu( int menu ) "until you are no longer aware of the enemy's presence and try " "again."; shortMsg = "This location is too close to the enemy to evolve"; - cmd = dialog; break; case MN_A_NOOVMND_EVOLVE: longMsg = "There is no Overmind. An Overmind must be built to allow " "you to upgrade."; shortMsg = "There is no Overmind"; - cmd = dialog; break; case MN_A_EVOLVEBUILDTIMER: longMsg = "You cannot Evolve until your build timer has expired."; shortMsg = "You cannot Evolve until your build timer expires"; - cmd = dialog; break; case MN_A_HOVEL_OCCUPIED: longMsg = "This Hovel is already occupied by another builder."; shortMsg = "This Hovel is already occupied by another builder"; - cmd = dialog; break; case MN_A_HOVEL_BLOCKED: longMsg = "The exit to this Hovel is currently blocked. Please wait until it " "becomes clear then try again."; shortMsg = "The exit to this Hovel is currently blocked"; - cmd = dialog; break; case MN_A_HOVEL_EXIT: longMsg = "The exit to this Hovel would always be blocked. Please choose " "a more suitable location."; shortMsg = "The exit to this Hovel would always be blocked"; - cmd = dialog; break; case MN_A_INFEST: @@ -803,25 +771,50 @@ void CG_Menu( int menu ) cmd = "menu tremulous_alienupgrade\n"; break; + case MN_A_CANTEVOLVE: + shortMsg = va( "You cannot evolve to %s", + BG_FindHumanNameForClassNum( arg ) ); + break; + + case MN_A_EVOLVEWALLWALK: + shortMsg = "You cannot evolve while wallwalking"; + break; + + case MN_A_UNKNOWNCLASS: + shortMsg = "Unknown class"; + break; + + case MN_A_CLASSNOTSPAWN: + shortMsg = va( "You cannot spawn as %s", + BG_FindHumanNameForClassNum( arg ) ); + break; + + case MN_A_CLASSNOTALLOWED: + shortMsg = va( "%s is not allowed", + BG_FindHumanNameForClassNum( arg ) ); + break; + + case MN_A_CLASSNOTATSTAGE: + shortMsg = va( "%s is not allowed at Stage %d", + BG_FindHumanNameForClassNum( arg ), + cgs.alienStage + 1 ); + break; + default: Com_Printf( "cgame: debug: no such menu %d\n", menu ); } - - if( cg_disableWarningDialogs.integer == 0 || - !shortMsg ) + + if( cmd != dialog ) { - // Player either wants dialog window or there's no short message - if( cmd ) - { - if( longMsg ) - trap_Cvar_Set( "ui_dialog", longMsg ); - - trap_SendConsoleCommand( cmd ); - } + trap_SendConsoleCommand( cmd ); + } + else if( longMsg && cg_disableWarningDialogs.integer == 0 ) + { + trap_Cvar_Set( "ui_dialog", longMsg ); + trap_SendConsoleCommand( cmd ); } - else if( cg_disableWarningDialogs.integer == 1 ) + else if( shortMsg && cg_disableWarningDialogs.integer < 2 ) { - // There is short message and player wants it CG_Printf( "%s\n", shortMsg ); } } @@ -932,8 +925,9 @@ static void CG_ServerCommand( void ) if( !strcmp( cmd, "servermenu" ) ) { if( trap_Argc( ) == 2 && !cg.demoPlayback ) - CG_Menu( atoi( CG_Argv( 1 ) ) ); - + CG_Menu( atoi( CG_Argv( 1 ) ), 0 ); + if( trap_Argc( ) == 3 && !cg.demoPlayback ) + CG_Menu( atoi( CG_Argv( 1 ) ), atoi( CG_Argv( 2 ) ) ); return; } diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 3c753092..c645f915 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -592,21 +592,30 @@ typedef enum MN_A_NOEROOM, MN_A_TOOCLOSE, MN_A_NOOVMND_EVOLVE, + MN_A_TEAMCHANGEBUILDTIMER, + MN_A_EVOLVEBUILDTIMER, + MN_A_CANTEVOLVE, + MN_A_EVOLVEWALLWALK, + MN_A_UNKNOWNCLASS, + MN_A_CLASSNOTSPAWN, + MN_A_CLASSNOTALLOWED, + MN_A_CLASSNOTATSTAGE, //shared build MN_B_NOROOM, MN_B_NORMAL, + MN_B_CANNOT, + MN_B_SUDDENDEATH, + MN_B_REVOKED, + MN_B_SURRENDER, //alien build - MN_A_SPWNWARN, // not currently used MN_A_ONEOVERMIND, + MN_A_ONEHOVEL, MN_A_NOBP, MN_A_NOCREEP, MN_A_NOOVMND, - MN_A_ONEHOVEL, MN_A_HOVEL_EXIT, - MN_A_TEAMCHANGEBUILDTIMER, - MN_A_EVOLVEBUILDTIMER, //human stuff MN_H_SPAWN, @@ -615,10 +624,14 @@ typedef enum MN_H_NOSLOTS, MN_H_NOFUNDS, MN_H_ITEMHELD, + MN_H_TEAMCHANGEBUILDTIMER, MN_H_NOENERGYAMMOHERE, MN_H_NOARMOURYHERE, MN_H_NOROOMBSUITON, MN_H_NOROOMBSUITOFF, + MN_H_ARMOURYBUILDTIMER, + MN_H_DEADTOCLASS, + MN_H_UNKNOWNSPAWNITEM, //human build MN_H_NOPOWERHERE, @@ -626,11 +639,7 @@ typedef enum MN_H_NOTPOWERED, MN_H_NODCC, MN_H_ONEREACTOR, - MN_H_TNODEWARN, // not currently used - MN_H_RPTNOREAC, MN_H_RPTPOWERHERE, - MN_H_TEAMCHANGEBUILDTIMER, - MN_H_ARMOURYBUILDTIMER } dynMenu_t; // animations diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index ee5a55ce..911884b0 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -3481,21 +3481,6 @@ qboolean G_BuildIfValid( gentity_t *ent, buildable_t buildable ) G_TriggerMenu( ent->client->ps.clientNum, MN_H_NODCC ); return qfalse; - case IBE_SPWNWARN: - G_TriggerMenu( ent->client->ps.clientNum, MN_A_SPWNWARN ); - G_Build( ent, buildable, origin, ent->s.apos.trBase ); - return qtrue; - - case IBE_TNODEWARN: - G_TriggerMenu( ent->client->ps.clientNum, MN_H_TNODEWARN ); - G_Build( ent, buildable, origin, ent->s.apos.trBase ); - return qtrue; - - case IBE_RPTNOREAC: - G_TriggerMenu( ent->client->ps.clientNum, MN_H_RPTNOREAC ); - G_Build( ent, buildable, origin, ent->s.apos.trBase ); - return qtrue; - case IBE_RPTPOWERHERE: G_TriggerMenu( ent->client->ps.clientNum, MN_H_RPTPOWERHERE ); return qfalse; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index e6bc45f2..0b1857d0 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1534,23 +1534,19 @@ void Cmd_Class_f( gentity_t *ent ) newClass != PCL_ALIEN_BUILDER0_UPG && newClass != PCL_ALIEN_LEVEL0 ) { - trap_SendServerCommand( ent-g_entities, - va( "print \"You cannot spawn with class %s\n\"", s ) ); + G_TriggerMenu2( ent->client->ps.clientNum, MN_A_CLASSNOTSPAWN, newClass ); return; } if( !BG_ClassIsAllowed( newClass ) ) { - trap_SendServerCommand( ent-g_entities, - va( "print \"Class %s is not allowed\n\"", s ) ); + G_TriggerMenu2( ent->client->ps.clientNum, MN_A_CLASSNOTALLOWED, newClass ); return; } if( !BG_FindStagesForClass( newClass, g_alienStage.integer ) ) { - trap_SendServerCommand( ent-g_entities, - va( "print \"Class %s not allowed at stage %d\n\"", - s, g_alienStage.integer + 1 ) ); + G_TriggerMenu2( ent->client->ps.clientNum, MN_A_CLASSNOTATSTAGE, newClass ); return; } @@ -1582,8 +1578,7 @@ void Cmd_Class_f( gentity_t *ent ) } else { - trap_SendServerCommand( ent-g_entities, - "print \"Unknown starting item\n\"" ); + G_TriggerMenu( ent->client->ps.clientNum, MN_H_UNKNOWNSPAWNITEM ); return; } // spawn from a telenode @@ -1605,7 +1600,7 @@ void Cmd_Class_f( gentity_t *ent ) { if( newClass == PCL_NONE ) { - trap_SendServerCommand( ent-g_entities, "print \"Unknown class\n\"" ); + G_TriggerMenu( ent->client->ps.clientNum, MN_A_UNKNOWNCLASS ); return; } @@ -1617,8 +1612,7 @@ void Cmd_Class_f( gentity_t *ent ) if( ( ent->client->ps.stats[ STAT_STATE ] & SS_WALLCLIMBING ) || ( ent->client->ps.stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) ) { - trap_SendServerCommand( ent-g_entities, - "print \"You cannot evolve while wallwalking\n\"" ); + G_TriggerMenu( clientNum, MN_A_EVOLVEWALLWALK ); return; } @@ -1681,8 +1675,7 @@ void Cmd_Class_f( gentity_t *ent ) } else { - trap_SendServerCommand( ent-g_entities, - "print \"You cannot evolve from your current class\n\"" ); + G_TriggerMenu2( clientNum, MN_A_CANTEVOLVE, newClass ); return; } } @@ -1695,9 +1688,7 @@ void Cmd_Class_f( gentity_t *ent ) } else if( ent->client->pers.teamSelection == PTE_HUMANS ) { - //humans cannot use this command whilst alive - trap_SendServerCommand( ent-g_entities, - "print \"You must be dead to use the class command\n\"" ); + G_TriggerMenu( clientNum, MN_H_DEADTOCLASS ); return; } } @@ -2333,15 +2324,13 @@ void Cmd_Build_f( gentity_t *ent ) if( ent->client->pers.denyBuild ) { - trap_SendServerCommand( ent-g_entities, - "print \"Your building rights have been revoked\n\"" ); + G_TriggerMenu( ent->client->ps.clientNum, MN_B_REVOKED ); return; } if( ent->client->pers.teamSelection == level.surrenderTeam ) { - trap_SendServerCommand( ent-g_entities, - "print \"Building has been denied to traitorous cowards\n\"" ); + G_TriggerMenu( ent->client->ps.clientNum, MN_B_SURRENDER ); return; } @@ -2351,8 +2340,7 @@ void Cmd_Build_f( gentity_t *ent ) if( G_TimeTilSuddenDeath( ) <= 0 ) { - trap_SendServerCommand( ent-g_entities, - "print \"Building is not allowed during Sudden Death\n\"" ); + G_TriggerMenu( ent->client->ps.clientNum, MN_B_SUDDENDEATH ); return; } @@ -2399,6 +2387,10 @@ void Cmd_Build_f( gentity_t *ent ) G_TriggerMenu( ent->client->ps.clientNum, MN_A_ONEOVERMIND ); break; + case IBE_ONEHOVEL: + G_TriggerMenu( ent->client->ps.clientNum, MN_A_ONEHOVEL ); + break; + case IBE_ONEREACTOR: G_TriggerMenu( ent->client->ps.clientNum, MN_H_ONEREACTOR ); break; @@ -2416,7 +2408,7 @@ void Cmd_Build_f( gentity_t *ent ) } } else - trap_SendServerCommand( ent-g_entities, va( "print \"Cannot build this item\n\"" ) ); + G_TriggerMenu( ent->client->ps.clientNum, MN_B_CANNOT ); } /* diff --git a/src/game/g_local.h b/src/game/g_local.h index a4a5cd26..bfda00b4 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -804,6 +804,7 @@ const char *BuildShaderStateConfig( void ); qboolean G_ClientIsLagging( gclient_t *client ); void G_TriggerMenu( int clientNum, dynMenu_t menu ); +void G_TriggerMenu2( int clientNum, dynMenu_t menu, int arg ); void G_CloseMenus( int clientNum ); qboolean G_Visible( gentity_t *ent1, gentity_t *ent2 ); diff --git a/src/game/g_utils.c b/src/game/g_utils.c index c03dacf5..926a7cd2 100644 --- a/src/game/g_utils.c +++ b/src/game/g_utils.c @@ -825,10 +825,24 @@ void G_TriggerMenu( int clientNum, dynMenu_t menu ) { char buffer[ 32 ]; - Com_sprintf( buffer, 32, "servermenu %d", menu ); + Com_sprintf( buffer, sizeof( buffer ), "servermenu %d", menu ); trap_SendServerCommand( clientNum, buffer ); } +/* +=============== +G_TriggerMenu2 + +Trigger a menu on some client and passes an argument +=============== +*/ +void G_TriggerMenu2( int clientNum, dynMenu_t menu, int arg ) +{ + char buffer[ 64 ]; + + Com_sprintf( buffer, sizeof( buffer ), "servermenu %d %d", menu, arg ); + trap_SendServerCommand( clientNum, buffer ); +} /* =============== diff --git a/ui/ingame_options.menu b/ui/ingame_options.menu index 00390713..ae3e3325 100644 --- a/ui/ingame_options.menu +++ b/ui/ingame_options.menu @@ -282,9 +282,10 @@ { name game group optionsGrp - type ITEM_TYPE_YESNO + type ITEM_TYPE_MULTI text "Disable Warning Dialogs:" cvar "cg_disableWarningDialogs" + cvarFloatList { "No" 0 "Print to Console" 1 "Yes" 2 } rect CONTENT_X (CONTENT_Y+(7*ELEM_H)) CONTENT_W ELEM_H textalign ALIGN_RIGHT textvalign VALIGN_CENTER |