Page MenuHomeFeedback Tracker

Improve parser for mission header
Assigned, NormalPublic

Description

The parser for the mission header section of the server config seems rather limited:

  • Cannot parse numbers without periods for float attributes
  • Cannot parse true and false for boolean attributes

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Linux x64
Category
General
Steps To Reproduce

I created and published a test mod with the ID 5EAC510A8E6EC623, which contains the following code and in essence defines a float and boolean attribute for the mission header and prints their values in the chat for all clients:

//------------------------------------------------------------------------------------------------
modded class SCR_MissionHeader : MissionHeader
{
	[Attribute(defvalue: "11.0", desc: "My mission header float variable")]
	float m_fMHT_myFloatVariable;
	
	[Attribute(defvalue: "false", desc: "My mission header boolean variable")]
	bool m_bMHT_myBooleanVariable;
}

//------------------------------------------------------------------------------------------------
modded class SCR_BaseGameMode : BaseGameMode
{
	//------------------------------------------------------------------------------------------------
	//! Schedule printing of my header variable
	override protected void OnGameStart()
	{
		super.OnGameStart();
		
		if (!Replication.IsServer())
			return;

		GetGame().GetCallqueue().CallLater(MHT_PrintMyVariable, 1000, true);
	}
	
	//------------------------------------------------------------------------------------------------
	//! Broadcast and print my variable to all clients
	protected void MHT_PrintMyVariable()
	{
		SCR_MissionHeader header = SCR_MissionHeader.Cast(GetGame().GetMissionHeader());
		if (!header)
			return;
		
		Rpc(MHT_PrintInChatBroadcast, string.Format("m_fMHT_myFloatVariable = %1\nm_bMHT_myBooleanVariable = %2", header.m_fMHT_myFloatVariable, header.m_bMHT_myBooleanVariable));
	}
	
	//------------------------------------------------------------------------------------------------
	//! Print chat message for all clients
	[RplRpc(RplChannel.Unreliable, RplRcver.Broadcast)]
	protected void MHT_PrintInChatBroadcast(string message)
	{
		PlayerController ctrl = GetGame().GetPlayerController();
		if (!ctrl)
			return;
		
		SCR_ChatComponent.Cast(ctrl.FindComponent(SCR_ChatComponent)).ShowMessage(message);
	}
}
  1. Start dedicated server with the following server config:
{
    "bindAddress": "",
    "bindPort": 2401,
    "publicAddress": "",
    "publicPort": 2401,
    "game": {
        "name": "Kex's Mission Header Test",
        "passwordAdmin": "pw",
        "scenarioId": "{83D06A42096F671C}Missions/MpTest/10_MpTest.conf",
        "maxPlayers": 10,
        "gameProperties": {
            "missionHeader": {
                "m_fMHT_myFloatVariable": 7,
                "m_bMHT_myBooleanVariable": true
            }
        },
        "mods": [
            {
                "modId": "5EAC510A8E6EC623",
                "name": "Mission Header Test"
            }
        ]
    }
}
  1. Check the values that are printed in chat. The expected behavior is that you should see m_fMHT_myFloatVariable = 7 and m_bMHT_myBooleanVariable = 1 printed in the chat, which are the values set in the server config. However, the parser fails for both and the default values are printed instead: m_fMHT_myFloatVariable = 11 and m_bMHT_myBooleanVariable = 0.

Event Timeline

ookexoo created this task.Mon, Jun 2, 2:51 AM
Geez changed the task status from New to Assigned.Tue, Jun 3, 2:56 PM