Opened 6 years ago

Last modified 5 years ago

#4836 new defect

Trigger scripts in Atlas not unloaded after changing the map

Reported by: elexis Owned by: elexis
Priority: Should Have Milestone: Backlog
Component: Atlas editor Keywords:
Cc: historic_bruno Patch:

Description

Reproduce:

  1. Start atlas
  2. Select the random map Danubius and generate
  3. Select a different random map and generate

Result:

WARNING: JavaScript warning: maps/scripts/TriggerHelper.js line 36
Script value conversion check failed: v.isNumber() (got type undefined)
WARNING: JavaScript warning: maps/scripts/TriggerHelper.js line 37
Script value conversion check failed: v.isNumber() (got type undefined)
ERROR: tried to create entity from a source without position
WARNING: JavaScript warning: maps/random/danubius_triggers.js line 402
reference to undefined property TriggerHelper.SpawnUnits(...)[0]
WARNING: JavaScript warning: maps/scripts/TriggerHelper.js line 36
Script value conversion check failed: v.isNumber() (got type undefined)
WARNING: JavaScript warning: maps/scripts/TriggerHelper.js line 37
Script value conversion check failed: v.isNumber() (got type undefined)
ERROR: tried to create entity from a source without position
WARNING: JavaScript warning: maps/random/danubius_triggers.js line 467
Script value conversion check failed: v.isNumber() (got type undefined)
WARNING: JavaScript warning: maps/random/danubius_triggers.js line 467
Script value conversion check failed: v.isNumber() (got type undefined)
  • Survival of the fittest does not throw warnings.
  • Danubius shouldn't spawn units when loading the file, but OnInitGame, as these spawned units are deleted right after deserializing a savegame.
  • wiki:Triggers#Datainitialisation should add the braces around init code and have a recommendation to do every action in OnInitGame.
  • After improving the TriggerScripts, Atlas is still bugged because it still executes the TriggerScript file of a different map

Change History (4)

comment:1 by elexis, 6 years ago

Owner: set to elexis

The random map generation button in Atlas calls MapSidebar::OnRandomGenerate of Map.cpp.

It contains this TODO from r9566:

	// TODO: this settings thing seems a bit of a mess,
	// since it's mixing data from three different sources

The three data sources are (1) the existing settings (2) the GUI and (3) the map JSON data.

Hence the TriggerScript array of the map settings array is persisted when changing the map. This problem holds some similarity to the gamesetup persist-match-settings issues (that exists in between gamesetup restarts and when switching the selected random map script).

In selectMap of gamesetup.js, we still have a whitelist of properties that must be deleted:

	// Reset some map specific properties which are not necessarily redefined on each map
	for (let prop of ["TriggerScripts", "CircularMap", "Garrison", "DisabledTemplates", "Biome", "SupportedBiomes"])
		...

	// Reset victory conditions
	if (g_GameAttributes.mapType != "random")
		...

	if (g_GameAttributes.mapType == "scenario")
	{
		delete g_GameAttributes.settings.RelicDuration;
		...

Deleting the existing settings is would fix the issue for any arbitrary setting that we don't want to persist. I expect that the Atlas GUI values are never replaced with the ranom map settings, so deleting them wouldn't imply loss of the chosen settings in the GUI.

in reply to:  1 comment:2 by Vladislav Belov, 6 years ago

Replying to elexis:

In selectMap of gamesetup.js, we still have a whitelist of properties that must be deleted:

Deleting the existing settings is would fix the issue for any arbitrary setting that we don't want to persist. I expect that the Atlas GUI values are never replaced with the ranom map settings, so deleting them wouldn't imply loss of the chosen settings in the GUI.

Do you suggest to add the removing logic from gamesetup.js to the Atlas?

comment:3 by historic_bruno, 5 years ago

Cc: historic_bruno added

trompetin17 and I discussed a solution at some length on IRC (starting at 03:09)

comment:4 by trompetin17, 5 years ago

Adding more information about the solution, JSON Schema

map_optionalsettings.json: { random: [ "" , "" , ""], scenario: [ "", "", "" ] }
Note: See TracTickets for help on using tickets.