Replace old dated _menus code

Replace old iw4x code in _menus to better detect if players are allowed to change teams and pick classes based on gamemodes.
Back port changes from IW5 to _playerlogic to support new _menus changes.
pull/4/head
efinst0rm 2023-08-17 19:37:09 -05:00
parent 299e5ed625
commit ad2611183b
2 changed files with 76 additions and 37 deletions

View File

@ -123,9 +123,9 @@ onMenuResponse()
{
self endon("disconnect");
for (;;)
for(;;)
{
self waittill( "menuresponse", menu, response );
self waittill("menuresponse", menu, response);
if ( response == "back" )
{
@ -142,21 +142,20 @@ onMenuResponse()
continue;
}
if (response == "changeteam")
if(response == "changeteam")
{
self closepopupMenu();
self closeInGameMenu();
self openpopupMenu(game["menu_team"]);
}
if (response == "changeclass_marines")
if(response == "changeclass_marines" )
{
self closepopupMenu();
self closeInGameMenu();
if ( getDvar( "g_gametype" ) != "oitc" && getDvar( "g_gametype" ) != "gg" && getDvar( "g_gametype" ) != "ss" && !isDefined(level.customClassCB) )
{
if ( allowClassChoice() )
self openpopupMenu( game["menu_changeclass_allies"] );
}
continue;
}
@ -164,18 +163,33 @@ onMenuResponse()
{
self closepopupMenu();
self closeInGameMenu();
if ( getDvar( "g_gametype" ) != "oitc" && getDvar( "g_gametype" ) != "gg" && getDvar( "g_gametype" ) != "ss" && !isDefined(level.customClassCB) )
{
if ( allowClassChoice() )
self openpopupMenu( game["menu_changeclass_axis"] );
}
continue;
}
if (response == "changeclass_marines_splitscreen" )
if(response == "changeclass_marines_splitscreen" )
self openpopupMenu( "changeclass_marines_splitscreen" );
if (response == "changeclass_opfor_splitscreen" )
if(response == "changeclass_opfor_splitscreen" )
self openpopupMenu( "changeclass_opfor_splitscreen" );
if(response == "endgame")
{
if(level.splitscreen)
{
endparty();
if ( !level.gameEnded )
{
level thread maps\mp\gametypes\_gamelogic::forceEnd();
}
}
continue;
}
if ( response == "endround" )
{
@ -186,7 +200,7 @@ onMenuResponse()
if ( !level.gameEnded )
{
setDvar( "sv_dontRotate", 1 );
setDvar("sv_dontrotate", 1);
level thread maps\mp\gametypes\_gamelogic::forceEnd();
}
else
@ -198,9 +212,9 @@ onMenuResponse()
continue;
}
if (menu == game["menu_team"])
if(menu == game["menu_team"])
{
switch (response)
switch(response)
{
case "allies":
self [[level.allies]]();
@ -320,29 +334,30 @@ menuAutoAssign()
beginClassChoice( forceNewChoice )
{
assert( self.pers["team"] == "axis" || self.pers["team"] == "allies" );
if ( getDvar( "g_gametype" ) == "oitc" || getDvar( "g_gametype" ) == "gg" || getDvar( "g_gametype" ) == "ss" || isDefined(level.customClassCB) )
{
if ( !isAlive( self ) )
self thread maps\mp\gametypes\_playerlogic::predictAboutToSpawnPlayerOverTime( 0.1 );
self.selectedClass = true;
self menuClass( "assault_mp,0" );
return;
}
team = self.pers["team"];
// menu_changeclass_team is the one where you choose one of the n classes to play as.
// menu_class_team is where you can choose to change your team, class, controls, or leave game.
self openpopupMenu( game[ "menu_changeclass_" + team ] );
// if game mode allows class choice
if ( allowClassChoice() )
self openpopupMenu( game[ "menu_changeclass_" + team ] );
else
self thread bypassClassChoice();
if ( !isAlive( self ) )
self thread maps\mp\gametypes\_playerlogic::predictAboutToSpawnPlayerOverTime( 0.1 );
}
bypassClassChoice()
{
self.selectedClass = true;
self [[level.class]]("class0");
}
beginTeamChoice()
{
if ( getDvarInt( "scr_player_forceautoassign" ) != 0 )
@ -538,7 +553,7 @@ addToTeam( team, firstConnect )
self.team = team;
// session team is readonly in ranked matches on console
if ( !matchMakingGame() || isDefined( self.pers["isBot"] ) )
if ( !matchMakingGame() || isDefined( self.pers["isBot"] ) || !allowTeamChoice() )
{
if ( level.teamBased )
{

View File

@ -116,6 +116,12 @@ maySpawn()
spawnClient()
{
if ( isDefined( self.addtoteam ) )
{
maps\mp\gametypes\_menus::addToTeam( self.addtoteam );
self.addtoteam = undefined;
}
assert( isDefined( self.team ) );
assert( isValidClass( self.class ) );
@ -684,7 +690,7 @@ spawnPlayer()
prof_end( "spawnPlayer_postUTS" );
self logstring( "S " + self.origin[0] + " " + self.origin[1] + " " + self.origin[2] );
//self logstring( "S " + self.origin[0] + " " + self.origin[1] + " " + self.origin[2] );
// give "connected" handlers a chance to start
// many of these start onPlayerSpawned handlers which rely on the "spawned_player"
@ -1122,7 +1128,7 @@ Callback_PlayerConnect()
logPrint("J;" + self.guid + ";" + self getEntityNumber() + ";" + self.name + "\n");
if ( matchMakingGame() && game["clientid"] <= 24 && game["clientid"] != getMatchData( "playerCount" ) )
if ( game["clientid"] <= 24 && game["clientid"] != getMatchData( "playerCount" ) )
{
setMatchData( "playerCount", game["clientid"] );
setMatchData( "players", self.clientid, "xuid", self getXuid() );
@ -1132,7 +1138,9 @@ Callback_PlayerConnect()
#/
assert( getdvarint( "scr_runlevelandquit" ) == 1 || (level.teamBased && (self.sessionteam == "allies" || self.sessionteam == "axis")) || (!level.teamBased && self.sessionteam == "none" ) );
//assert( (level.teamBased && self.sessionteam == self.team) || (!level.teamBased && self.sessionteam == "none") );
setMatchData( "players", self.clientid, "team", self.sessionteam );
if ( matchMakingGame() && allowTeamChoice() )
setMatchData( "players", self.clientid, "team", self.sessionteam );
}
if ( !level.teamBased )
@ -1236,9 +1244,16 @@ Callback_PlayerConnect()
self thread kickIfDontSpawn();
return;
}
self [[level.spectator]]();
self maps\mp\gametypes\_menus::beginTeamChoice();
else if ( allowTeamChoice() )
{
self [[level.spectator]]();
self maps\mp\gametypes\_menus::beginTeamChoice();
}
else
{
self [[ level.spectator ]]();
self [[level.autoassign]]();
}
}
else
{
@ -1253,9 +1268,18 @@ Callback_PlayerConnect()
self thread spawnSpectator();
if ( self.pers["team"] == "spectator" )
self maps\mp\gametypes\_menus::beginTeamChoice();
else
self maps\mp\gametypes\_menus::beginClassChoice();
{
if ( allowTeamChoice() )
{
self maps\mp\gametypes\_menus::beginTeamChoice();
return;
}
self [[ level.autoassign ]]();
return;
}
self maps\mp\gametypes\_menus::beginClassChoice();
}
/#