feat: change server name when changing mode

This commit is contained in:
GenZmeY 2021-05-03 22:06:02 +03:00
parent f049a999c7
commit 96cf98f46f
2 changed files with 12 additions and 2 deletions

View File

@ -124,6 +124,7 @@ function handleMapVotes(WebAdminQuery q)
class'xVotingHandler'.Default.GameModes[i].Mutators = q.request.getVariable("MM",class'xVotingHandler'.Default.GameModes[i].GameName); class'xVotingHandler'.Default.GameModes[i].Mutators = q.request.getVariable("MM",class'xVotingHandler'.Default.GameModes[i].GameName);
class'xVotingHandler'.Default.GameModes[i].Options = q.request.getVariable("OP",class'xVotingHandler'.Default.GameModes[i].GameName); class'xVotingHandler'.Default.GameModes[i].Options = q.request.getVariable("OP",class'xVotingHandler'.Default.GameModes[i].GameName);
class'xVotingHandler'.Default.GameModes[i].Prefix = q.request.getVariable("PF",class'xVotingHandler'.Default.GameModes[i].GameName); class'xVotingHandler'.Default.GameModes[i].Prefix = q.request.getVariable("PF",class'xVotingHandler'.Default.GameModes[i].GameName);
class'xVotingHandler'.Default.GameModes[i].ServerName = q.request.getVariable("SN",class'xVotingHandler'.Default.GameModes[i].GameName);
class'xVotingHandler'.Static.StaticSaveConfig(); class'xVotingHandler'.Static.StaticSaveConfig();
} }
EditSettingLine = -1; EditSettingLine = -1;
@ -160,7 +161,7 @@ function handleMapVotes(WebAdminQuery q)
q.response.SendText("</tbody></table></form>"); q.response.SendText("</tbody></table></form>");
q.response.SendText("<form method=\"post\" action=\""$webadmin.Path$MapVoterURL$"\"><table id=\"settings\" class=\"grid\">"); q.response.SendText("<form method=\"post\" action=\""$webadmin.Path$MapVoterURL$"\"><table id=\"settings\" class=\"grid\">");
q.response.SendText("<thead><tr><th colspan=7>Mapvote game modes</th></tr></thead><tbody>"); q.response.SendText("<thead><tr><th colspan=7>Mapvote game modes</th></tr></thead><tbody>");
q.response.SendText("<tr><th>Game Name</th><th>Game Short Name</th><th>Game Class</th><th>Mutators</th><th>Options</th><th>Map Prefix</th><th></th></tr>"); q.response.SendText("<tr><th>Game Name</th><th>Game Short Name</th><th>Game Class</th><th>Mutators</th><th>Options</th><th>Map Prefix</th><th>Server Name</th><th></th></tr>");
for (i=0; i<class'xVotingHandler'.Default.GameModes.Length; ++i) for (i=0; i<class'xVotingHandler'.Default.GameModes.Length; ++i)
{ {
if (EditSettingLine==i) if (EditSettingLine==i)
@ -172,6 +173,7 @@ function handleMapVotes(WebAdminQuery q)
AddInLineEditbox(q,class'xVotingHandler'.Default.GameModes[i].Mutators,120,"MM","List of mutators to run along with this game option (separated with commas)"); AddInLineEditbox(q,class'xVotingHandler'.Default.GameModes[i].Mutators,120,"MM","List of mutators to run along with this game option (separated with commas)");
AddInLineEditbox(q,class'xVotingHandler'.Default.GameModes[i].Options,100,"OP","List of options to run along with this game option (separated with question mark)"); AddInLineEditbox(q,class'xVotingHandler'.Default.GameModes[i].Options,100,"OP","List of options to run along with this game option (separated with question mark)");
AddInLineEditbox(q,class'xVotingHandler'.Default.GameModes[i].Prefix,16,"PF","Maps prefix to filter out maps not wanted for this game mode"); AddInLineEditbox(q,class'xVotingHandler'.Default.GameModes[i].Prefix,16,"PF","Maps prefix to filter out maps not wanted for this game mode");
AddInLineEditbox(q,class'xVotingHandler'.Default.GameModes[i].ServerName,16,"SN","Server name that will be set when this mode is selected ");
q.response.SendText("</td><td><input class=\"button\" type=\"submit\" name=\"edit\" value=\"Save\"><input class=\"button\" type=\"submit\" name=\"edit"$i$"\" value=\"Delete\"></td></tr>"); q.response.SendText("</td><td><input class=\"button\" type=\"submit\" name=\"edit\" value=\"Save\"><input class=\"button\" type=\"submit\" name=\"edit"$i$"\" value=\"Delete\"></td></tr>");
} }
else else
@ -182,6 +184,7 @@ function handleMapVotes(WebAdminQuery q)
"</td><td>"$class'xVotingHandler'.Default.GameModes[i].Mutators$ "</td><td>"$class'xVotingHandler'.Default.GameModes[i].Mutators$
"</td><td>"$class'xVotingHandler'.Default.GameModes[i].Options$ "</td><td>"$class'xVotingHandler'.Default.GameModes[i].Options$
"</td><td>"$class'xVotingHandler'.Default.GameModes[i].Prefix$ "</td><td>"$class'xVotingHandler'.Default.GameModes[i].Prefix$
"</td><td>"$class'xVotingHandler'.Default.GameModes[i].ServerName$
"</td><td><input class=\"button\" type=\"submit\" name=\"edit"$i$"\" value=\"Edit\"><input class=\"button\" type=\"submit\" name=\"edit"$i$"\" value=\"Delete\"></td></tr>"); "</td><td><input class=\"button\" type=\"submit\" name=\"edit"$i$"\" value=\"Edit\"><input class=\"button\" type=\"submit\" name=\"edit"$i$"\" value=\"Delete\"></td></tr>");
} }
} }

View File

@ -3,7 +3,7 @@ Class xVotingHandler extends xVotingHandlerBase
struct FGameModeOption struct FGameModeOption
{ {
var config string GameName,GameShortName,GameClass,Mutators,Options,Prefix; var config string GameName,GameShortName,GameClass,Mutators,Options,Prefix,ServerName;
}; };
var config array<FGameModeOption> GameModes; var config array<FGameModeOption> GameModes;
var config int LastVotedGameInfo,VoteTime,MaxMapsOnList,VoteNumForOrgy; var config int LastVotedGameInfo,VoteTime,MaxMapsOnList,VoteNumForOrgy;
@ -52,6 +52,7 @@ function PostBeginPlay()
GameModes[0].GameClass = PathName(WorldInfo.Game.Class); GameModes[0].GameClass = PathName(WorldInfo.Game.Class);
GameModes[0].Mutators = ""; GameModes[0].Mutators = "";
GameModes[0].Prefix = ""; GameModes[0].Prefix = "";
GameModes[0].ServerName = "";
MidGameVotePct = 0.51; MidGameVotePct = 0.51;
MapWinPct = 0.75; MapWinPct = 0.75;
VoteTime = 35; VoteTime = 35;
@ -498,6 +499,12 @@ final function SwitchToLevel(int GameIndex, int MapIndex, bool bAdminForce)
if (GameModes[GameIndex].Options!="") if (GameModes[GameIndex].Options!="")
PendingMapURL $= "?"$GameModes[GameIndex].Options; PendingMapURL $= "?"$GameModes[GameIndex].Options;
`Log("MapVote: Switch map to "$PendingMapURL); `Log("MapVote: Switch map to "$PendingMapURL);
if (GameModes[GameIndex].ServerName != "")
{
WorldInfo.GRI.ServerName = GameModes[GameIndex].ServerName;
WorldInfo.GRI.SaveConfig();
`Log("MapVote: Next ServerName: "$WorldInfo.GRI.ServerName);
}
SetTimer(FMax(MapChangeDelay,0.1),false,'PendingSwitch'); SetTimer(FMax(MapChangeDelay,0.1),false,'PendingSwitch');
} }