Source-1-Games icon indicating copy to clipboard operation
Source-1-Games copied to clipboard

[TF2] [Linux] Changing m_iszMannVsMachineWaveClassNames crashes Linux servers

Open Brain-dawg opened this issue 1 year ago • 1 comments

This netprop is responsible for the MvM wavebar and is used to change icons in real-time or make icons that otherwise aren't possible (such as tanks with crit outlines). It can be modified without issue on Windows.

I've been told the reason is "there's an unusual way the netprop is stored, the compiler layed out the structure differently than what the netprop manager expects".

I am using PopExtensions for this report, the function that touches this netprop is pasted below though. PopExtensions can be found here

Steps To Reproduce:

  1. install both popextensions .nut files
  2. load this test popfile on mvm_bigrock
WaveSchedule
{
	Wave
	{
		// Add or replace existing InitWaveOutput with code below
		InitWaveOutput
		{
			Target gamerules
			Action RunScriptCode
			Param "
				IncludeScript(`popextensions`)

				// crashes linux
				AddCustomTankIcon(`scout_bat`, 3, true, false, false, false)
			"
		}

		WaveSpawn
		{
			Name "test"
			TotalCount 1
			Tank
			{
				Health 100
				Name "abc"
				StartingPathTrackNode "boss_path_a1"

				OnBombDroppedOutput
				{
					Target boss_deploy_relay
					Action Trigger
				}
			}
		}
	}
}

The function responsible for changing the netprop is this:

::SetWaveIconSpawnCount <- function(name, flags, count, changeMaxEnemyCount = true)
{
	local sizeArray = NetProps.GetPropArraySize(resource, "m_nMannVsMachineWaveClassCounts");

	for (local a = 0; a < 2; a++) {
		local suffix = a == 0 ? "" : "2";
		for (local i = 0; i < sizeArray; i++) {
			local nameSlot = NetProps.GetPropStringArray(resource, "m_iszMannVsMachineWaveClassNames" + suffix, i);
			if (nameSlot == "" && count > 0) {
				NetProps.SetPropStringArray(resource, "m_iszMannVsMachineWaveClassNames" + suffix, name, i);
				NetProps.SetPropIntArray(resource, "m_nMannVsMachineWaveClassCounts" + suffix, count, i);
				NetProps.SetPropIntArray(resource, "m_nMannVsMachineWaveClassFlags" + suffix, flags, i);
				if (changeMaxEnemyCount && (flags & (MVM_CLASS_FLAG_NORMAL | MVM_CLASS_FLAG_MINIBOSS))) {
					NetProps.SetPropInt(resource, "m_nMannVsMachineWaveEnemyCount", NetProps.GetPropInt(resource, "m_nMannVsMachineWaveEnemyCount") + count);
				}
				return;
			}
			if (nameSlot == name && (flags == 0 || NetProps.GetPropIntArray(resource, "m_nMannVsMachineWaveClassFlags" + suffix, i) == flags)) {
				local preCount = NetProps.GetPropIntArray(resource, "m_nMannVsMachineWaveClassCounts" + suffix, i)
				NetProps.SetPropIntArray(resource, "m_nMannVsMachineWaveClassCounts" + suffix, count, i);
				if (changeMaxEnemyCount && (flags & (MVM_CLASS_FLAG_NORMAL | MVM_CLASS_FLAG_MINIBOSS))) {
					NetProps.SetPropInt(resource, "m_nMannVsMachineWaveEnemyCount", NetProps.GetPropInt(resource, "m_nMannVsMachineWaveEnemyCount") + count - preCount);
				}
				if (count <= 0) {
					NetProps.SetPropStringArray(resource, "m_iszMannVsMachineWaveClassNames" + suffix, "", i);
					NetProps.SetPropIntArray(resource, "m_nMannVsMachineWaveClassFlags" + suffix, 0, i);
					NetProps.SetPropBoolArray(resource, "m_bMannVsMachineWaveClassActive" + suffix, false, i);
				}
				return;
			}
		}
	}
}

Brain-dawg avatar Jan 30 '24 06:01 Brain-dawg

Should be fixed next update.

misyltoad avatar Feb 08 '24 18:02 misyltoad