mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-23 12:32:09 +00:00
f7c3276fe8
There are various issues caused by not knowing the initial team for the local client and bots when they connect. This is can be reproduced by starting a team game from the main menu. When g_teamAutoJoin is enabled, bots and local client join a random team at connect and then execute their team command a few frames later. This may result in the player being killed if they specify a different team. In Team Arena's Harvester mode this causes harvester skulls to be spawned at the beginning of the game. When g_teamForceBalance is enabled, the local client and bots may not be able to join their desired team. This may result in them being spectators. If g_teamAutoJoin is also enabled they may be left on the opposite (red/blue) team they were meant to join. There is a hack for including bot's team in their player info string (used by cgame for which team skin to use) before the bot joins their desired team. Bots aren't guaranteed to join their desired team (as may happen when both g_teamAutoJoin and g_teamForceBalance are enabled) so clients may see them as being on the wrong team! ---- Add teampref userinfo option for team preference. If teampref is set it will be used for attempting to join the team immediately at connect. Bots now join team at connect using teampref userinfo. So remove the hack for setting bot's team in player info string before the bot joins the team. To avoid the client sending teampref userinfo to all network servers, the local client uses a g_localTeamPref cvar. The g_localTeamPref cvar is cleared after it's used so it doesn't get used when starting another server later. Another reason not to use a teampref userinfo cvar is there isn't a reliable way to clear it in CGame/UI which are likely loaded from baseq3 pk3. Make it so g_teamAutoJoin doesn't affect clients who specify teampref. If teampref is invalid, the client will join a random team like g_teamAutoJoin. Don't apply g_teamForceBalance to the local client or bots. Otherwise they may be left as spectators when starting team game from menu. The start server menus use team command and g_localTeamPref to set the human player's team. This way it's compatible with vanilla Q3 game VMs and the new setting team at connect feature.
254 lines
6.8 KiB
C
254 lines
6.8 KiB
C
/*
|
|
===========================================================================
|
|
Copyright (C) 1999-2005 Id Software, Inc.
|
|
|
|
This file is part of Quake III Arena source code.
|
|
|
|
Quake III Arena source code is free software; you can redistribute it
|
|
and/or modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation; either version 2 of the License,
|
|
or (at your option) any later version.
|
|
|
|
Quake III Arena source code is distributed in the hope that it will be
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with Quake III Arena source code; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
===========================================================================
|
|
*/
|
|
//
|
|
/*
|
|
=======================================================================
|
|
|
|
USER INTERFACE MAIN
|
|
|
|
=======================================================================
|
|
*/
|
|
|
|
|
|
#include "ui_local.h"
|
|
|
|
|
|
/*
|
|
================
|
|
vmMain
|
|
|
|
This is the only way control passes into the module.
|
|
This must be the very first function compiled into the .qvm file
|
|
================
|
|
*/
|
|
Q_EXPORT intptr_t vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) {
|
|
switch ( command ) {
|
|
case UI_GETAPIVERSION:
|
|
return UI_API_VERSION;
|
|
|
|
case UI_INIT:
|
|
UI_Init();
|
|
return 0;
|
|
|
|
case UI_SHUTDOWN:
|
|
UI_Shutdown();
|
|
return 0;
|
|
|
|
case UI_KEY_EVENT:
|
|
UI_KeyEvent( arg0, arg1 );
|
|
return 0;
|
|
|
|
case UI_MOUSE_EVENT:
|
|
UI_MouseEvent( arg0, arg1 );
|
|
return 0;
|
|
|
|
case UI_REFRESH:
|
|
UI_Refresh( arg0 );
|
|
return 0;
|
|
|
|
case UI_IS_FULLSCREEN:
|
|
return UI_IsFullscreen();
|
|
|
|
case UI_SET_ACTIVE_MENU:
|
|
UI_SetActiveMenu( arg0 );
|
|
return 0;
|
|
|
|
case UI_CONSOLE_COMMAND:
|
|
return UI_ConsoleCommand(arg0);
|
|
|
|
case UI_DRAW_CONNECT_SCREEN:
|
|
UI_DrawConnectScreen( arg0 );
|
|
return 0;
|
|
case UI_HASUNIQUECDKEY: // mod authors need to observe this
|
|
return qtrue; // change this to qfalse for mods!
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
|
|
/*
|
|
================
|
|
cvars
|
|
================
|
|
*/
|
|
|
|
typedef struct {
|
|
vmCvar_t *vmCvar;
|
|
char *cvarName;
|
|
char *defaultString;
|
|
int cvarFlags;
|
|
} cvarTable_t;
|
|
|
|
vmCvar_t ui_ffa_fraglimit;
|
|
vmCvar_t ui_ffa_timelimit;
|
|
|
|
vmCvar_t ui_tourney_fraglimit;
|
|
vmCvar_t ui_tourney_timelimit;
|
|
|
|
vmCvar_t ui_team_fraglimit;
|
|
vmCvar_t ui_team_timelimit;
|
|
vmCvar_t ui_team_friendly;
|
|
|
|
vmCvar_t ui_ctf_capturelimit;
|
|
vmCvar_t ui_ctf_timelimit;
|
|
vmCvar_t ui_ctf_friendly;
|
|
|
|
vmCvar_t ui_arenasFile;
|
|
vmCvar_t ui_botsFile;
|
|
vmCvar_t ui_spScores1;
|
|
vmCvar_t ui_spScores2;
|
|
vmCvar_t ui_spScores3;
|
|
vmCvar_t ui_spScores4;
|
|
vmCvar_t ui_spScores5;
|
|
vmCvar_t ui_spAwards;
|
|
vmCvar_t ui_spVideos;
|
|
vmCvar_t ui_spSkill;
|
|
|
|
vmCvar_t ui_spSelection;
|
|
|
|
vmCvar_t ui_browserMaster;
|
|
vmCvar_t ui_browserGameType;
|
|
vmCvar_t ui_browserSortKey;
|
|
vmCvar_t ui_browserShowFull;
|
|
vmCvar_t ui_browserShowEmpty;
|
|
|
|
vmCvar_t ui_brassTime;
|
|
vmCvar_t ui_drawCrosshair;
|
|
vmCvar_t ui_drawCrosshairNames;
|
|
vmCvar_t ui_marks;
|
|
|
|
vmCvar_t ui_server1;
|
|
vmCvar_t ui_server2;
|
|
vmCvar_t ui_server3;
|
|
vmCvar_t ui_server4;
|
|
vmCvar_t ui_server5;
|
|
vmCvar_t ui_server6;
|
|
vmCvar_t ui_server7;
|
|
vmCvar_t ui_server8;
|
|
vmCvar_t ui_server9;
|
|
vmCvar_t ui_server10;
|
|
vmCvar_t ui_server11;
|
|
vmCvar_t ui_server12;
|
|
vmCvar_t ui_server13;
|
|
vmCvar_t ui_server14;
|
|
vmCvar_t ui_server15;
|
|
vmCvar_t ui_server16;
|
|
|
|
vmCvar_t ui_cdkeychecked;
|
|
vmCvar_t ui_ioq3;
|
|
|
|
static cvarTable_t cvarTable[] = {
|
|
{ &ui_ffa_fraglimit, "ui_ffa_fraglimit", "20", CVAR_ARCHIVE },
|
|
{ &ui_ffa_timelimit, "ui_ffa_timelimit", "0", CVAR_ARCHIVE },
|
|
|
|
{ &ui_tourney_fraglimit, "ui_tourney_fraglimit", "0", CVAR_ARCHIVE },
|
|
{ &ui_tourney_timelimit, "ui_tourney_timelimit", "15", CVAR_ARCHIVE },
|
|
|
|
{ &ui_team_fraglimit, "ui_team_fraglimit", "0", CVAR_ARCHIVE },
|
|
{ &ui_team_timelimit, "ui_team_timelimit", "20", CVAR_ARCHIVE },
|
|
{ &ui_team_friendly, "ui_team_friendly", "1", CVAR_ARCHIVE },
|
|
|
|
{ &ui_ctf_capturelimit, "ui_ctf_capturelimit", "8", CVAR_ARCHIVE },
|
|
{ &ui_ctf_timelimit, "ui_ctf_timelimit", "30", CVAR_ARCHIVE },
|
|
{ &ui_ctf_friendly, "ui_ctf_friendly", "0", CVAR_ARCHIVE },
|
|
|
|
{ &ui_arenasFile, "g_arenasFile", "", CVAR_INIT|CVAR_ROM },
|
|
{ &ui_botsFile, "g_botsFile", "", CVAR_INIT|CVAR_ROM },
|
|
{ &ui_spScores1, "g_spScores1", "", CVAR_ARCHIVE },
|
|
{ &ui_spScores2, "g_spScores2", "", CVAR_ARCHIVE },
|
|
{ &ui_spScores3, "g_spScores3", "", CVAR_ARCHIVE },
|
|
{ &ui_spScores4, "g_spScores4", "", CVAR_ARCHIVE },
|
|
{ &ui_spScores5, "g_spScores5", "", CVAR_ARCHIVE },
|
|
{ &ui_spAwards, "g_spAwards", "", CVAR_ARCHIVE },
|
|
{ &ui_spVideos, "g_spVideos", "", CVAR_ARCHIVE },
|
|
{ &ui_spSkill, "g_spSkill", "2", CVAR_ARCHIVE | CVAR_LATCH },
|
|
|
|
{ &ui_spSelection, "ui_spSelection", "", CVAR_ROM },
|
|
|
|
{ &ui_browserMaster, "ui_browserMaster", "1", CVAR_ARCHIVE },
|
|
{ &ui_browserGameType, "ui_browserGameType", "0", CVAR_ARCHIVE },
|
|
{ &ui_browserSortKey, "ui_browserSortKey", "4", CVAR_ARCHIVE },
|
|
{ &ui_browserShowFull, "ui_browserShowFull", "1", CVAR_ARCHIVE },
|
|
{ &ui_browserShowEmpty, "ui_browserShowEmpty", "1", CVAR_ARCHIVE },
|
|
|
|
{ &ui_brassTime, "cg_brassTime", "2500", CVAR_ARCHIVE },
|
|
{ &ui_drawCrosshair, "cg_drawCrosshair", "4", CVAR_ARCHIVE },
|
|
{ &ui_drawCrosshairNames, "cg_drawCrosshairNames", "1", CVAR_ARCHIVE },
|
|
{ &ui_marks, "cg_marks", "1", CVAR_ARCHIVE },
|
|
|
|
{ &ui_server1, "server1", "", CVAR_ARCHIVE },
|
|
{ &ui_server2, "server2", "", CVAR_ARCHIVE },
|
|
{ &ui_server3, "server3", "", CVAR_ARCHIVE },
|
|
{ &ui_server4, "server4", "", CVAR_ARCHIVE },
|
|
{ &ui_server5, "server5", "", CVAR_ARCHIVE },
|
|
{ &ui_server6, "server6", "", CVAR_ARCHIVE },
|
|
{ &ui_server7, "server7", "", CVAR_ARCHIVE },
|
|
{ &ui_server8, "server8", "", CVAR_ARCHIVE },
|
|
{ &ui_server9, "server9", "", CVAR_ARCHIVE },
|
|
{ &ui_server10, "server10", "", CVAR_ARCHIVE },
|
|
{ &ui_server11, "server11", "", CVAR_ARCHIVE },
|
|
{ &ui_server12, "server12", "", CVAR_ARCHIVE },
|
|
{ &ui_server13, "server13", "", CVAR_ARCHIVE },
|
|
{ &ui_server14, "server14", "", CVAR_ARCHIVE },
|
|
{ &ui_server15, "server15", "", CVAR_ARCHIVE },
|
|
{ &ui_server16, "server16", "", CVAR_ARCHIVE },
|
|
|
|
{ &ui_cdkeychecked, "ui_cdkeychecked", "0", CVAR_ROM },
|
|
{ &ui_ioq3, "ui_ioq3", "1", CVAR_ROM },
|
|
{ NULL, "g_localTeamPref", "", 0 }
|
|
};
|
|
|
|
static int cvarTableSize = ARRAY_LEN( cvarTable );
|
|
|
|
|
|
/*
|
|
=================
|
|
UI_RegisterCvars
|
|
=================
|
|
*/
|
|
void UI_RegisterCvars( void ) {
|
|
int i;
|
|
cvarTable_t *cv;
|
|
|
|
for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
|
|
trap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags );
|
|
}
|
|
}
|
|
|
|
/*
|
|
=================
|
|
UI_UpdateCvars
|
|
=================
|
|
*/
|
|
void UI_UpdateCvars( void ) {
|
|
int i;
|
|
cvarTable_t *cv;
|
|
|
|
for ( i = 0, cv = cvarTable ; i < cvarTableSize ; i++, cv++ ) {
|
|
if ( !cv->vmCvar ) {
|
|
continue;
|
|
}
|
|
|
|
trap_Cvar_Update( cv->vmCvar );
|
|
}
|
|
}
|