Page MenuHomeFeedback Tracker

Subconfigs in mission header don't get initialized with default attribute value
Assigned, NormalPublic

Description

When introducing subconfigs as attributes to a mission header and force the creation of an instance through the server config JSON, their attributes get initialized with null values instead of the specified defaults.

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Windows 11 x64
Category
General
Steps To Reproduce
  1. Create a mod that adds a subconfig to the mission header and prints its values
//------------------------------------------------------------------------------------------------
modded class SCR_MissionHeader : MissionHeader
{
	[Attribute()]
	ref MySubConfig m_MySubConfig;
}

//------------------------------------------------------------------------------------------------
class MySubConfig : ScriptAndConfig
{
	[Attribute(defvalue: "42")]
	int m_iMyInt;
	
	[Attribute(defvalue: "3.1415")]
	float m_fMyFloat;
}

//------------------------------------------------------------------------------------------------
modded class ArmaReforgerScripted : ChimeraGame
{
	//------------------------------------------------------------------------------------------------
	override bool OnGameStart()
	{
		SCR_MissionHeader header = SCR_MissionHeader.Cast(GetGame().GetMissionHeader());
		if (header && header.m_MySubConfig)
		{
			PrintFormat("m_MySubConfig.m_iMyInt = %1", header.m_MySubConfig.m_iMyInt);
			PrintFormat("m_MySubConfig.m_fMyFloat = %1", header.m_MySubConfig.m_fMyFloat);
		}
		
		return super.OnGameStart();
	}
}
  1. Start a dedicated server with said mod and specify the following in the mission header section of the server config JSON:
"missionHeader": {
	"m_MySubConfig": {
		"m_fMyFloat" = 2.718
	}
}
  1. Notice that m_fMyFloat is 2.718 as expected, but m_iMyInt is 0 instead of 42.
Additional Information

A workaround could be to create an instance of the of the subconfig in the config file. The problem, however, is that there's not a common config file all mission headers inherit from, where this could be done.

Event Timeline

ookexoo created this task.Sep 5 2024, 12:00 PM
ookexoo updated the task description. (Show Details)
ookexoo edited Steps To Reproduce. (Show Details)
ookexoo edited Steps To Reproduce. (Show Details)Sep 5 2024, 12:05 PM
ookexoo edited Steps To Reproduce. (Show Details)
Geez changed the task status from New to Assigned.Sep 10 2024, 3:49 PM