fix JSON formating

This commit is contained in:
chacha 2023-04-20 16:02:48 +02:00
parent 1a4e17a724
commit f8af6afe79
2 changed files with 33 additions and 12 deletions

View File

@ -139,6 +139,23 @@ function string EncloseJSON(String _input)
return "{"$_input$"}";
}
function string RenderJSONBool(string KeyName, bool KeyValue)
{
if( KeyValue )
{
return "\""$KeyName$"\":\"true\"";
}
else
{
return "\""$KeyName$"\":\"false\"";
}
}
function string RenderJSONBoolString(string KeyName, string KeyValue)
{
return RenderJSONBool(KeyName,KeyValue ~= "true");
}
function string QueryDefaultsServer()
{
local String tmp;
@ -150,8 +167,7 @@ function string QueryDefaultsServer()
tmp$="\"MOTDLine2\":\""$class'Engine.GameReplicationInfo'.default.MOTDLine2$"\",";
tmp$="\"MOTDLine3\":\""$class'Engine.GameReplicationInfo'.default.MOTDLine3$"\",";
tmp$="\"MOTDLine4\":\""$class'Engine.GameReplicationInfo'.default.MOTDLine4$"\",";
tmp$="\"bWorldLog\":"$Level.Game.Default.bWorldLog;
tmp$=RenderJSONBool("bWorldLog",Level.Game.Default.bWorldLog);
return tmp;
}
@ -166,17 +182,21 @@ function string QueryDefaultsRules()
tmp$="\"MaxPlayers\":"$class<DeathMatchPlus>(GameClass).Default.MaxPlayers$",";
tmp$="\"MaxSpectators\":"$class<DeathMatchPlus>(GameClass).Default.MaxSpectators$",";
tmp$="\"bMultiWeaponStay\":"$class<DeathMatchPlus>(GameClass).Default.bMultiWeaponStay$",";
tmp$="\"bTournament\":"$class<DeathMatchPlus>(GameClass).Default.bTournament;
//tmp$="\"bMultiWeaponStay\":"$class<DeathMatchPlus>(GameClass).Default.bMultiWeaponStay$",";
tmp$=RenderJSONBool("bMultiWeaponStay",class<DeathMatchPlus>(GameClass).Default.bMultiWeaponStay)$",";
//tmp$="\"bTournament\":"$class<DeathMatchPlus>(GameClass).Default.bTournament;
tmp$=RenderJSONBool("bTournament",class<DeathMatchPlus>(GameClass).Default.bTournament);
if( class<TeamGamePlus>(GameClass) != None )
{
tmp$=",\"bPlayersBalanceTeams\":"$class<TeamGamePlus>(GameClass).Default.bPlayersBalanceTeams;
//tmp$=",\"bPlayersBalanceTeams\":"$class<TeamGamePlus>(GameClass).Default.bPlayersBalanceTeams;
tmp$=","$RenderJSONBool("bPlayersBalanceTeams",class<TeamGamePlus>(GameClass).Default.bPlayersBalanceTeams);
}
if( class<LastManStanding>(GameClass) == None )
{
tmp$=",\"bForceRespawn\":"$class<DeathMatchPlus>(GameClass).Default.bForceRespawn;
//tmp$=",\"bForceRespawn\":"$class<DeathMatchPlus>(GameClass).Default.bForceRespawn;
tmp$=","$RenderJSONBool("bForceRespawn",class<DeathMatchPlus>(GameClass).Default.bForceRespawn);
}
if (class<DeathMatchPlus>(GameClass) != None && class<Assault>(GameClass) == None)
@ -247,7 +267,8 @@ function string QueryDefaultsSettings()
AirControl = class<DeathMatchPlus>(GameClass).Default.AirControl * 100.0;
tmp$="\"AirControl\":"$AirControl$",";
tmp$="\"UseTranslocator\":"$class<DeathMatchPlus>(GameClass).Default.bUseTranslocator;
//tmp$="\"UseTranslocator\":"$class<DeathMatchPlus>(GameClass).Default.bUseTranslocator;
tmp$=RenderJSONBool("bUseTranslocator",class<DeathMatchPlus>(GameClass).Default.bUseTranslocator);
return tmp;
}
@ -311,19 +332,19 @@ function string QueryCurrentPlayers()
tmp$="\"Score\":"$P.PlayerReplicationInfo.Score$",";
if (P.PlayerReplicationInfo.bIsABot)
{
tmp$="\"bIsABot\":True,";
tmp$="\"bIsSpectator\":False,";
tmp$="\"bIsABot\":true,";
tmp$="\"bIsSpectator\":false,";
}
else
{
tmp$="\"bIsABot\":False,";
tmp$="\"bIsABot\":false,";
if (P.PlayerReplicationInfo.bIsSpectator)
{
tmp$="\"bIsSpectator\":True,";
tmp$="\"bIsSpectator\":true,";
}
else
{
tmp$="\"bIsSpectator\":False,";
tmp$="\"bIsSpectator\":false,";
}
}
IP = "";

Binary file not shown.