Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3238 closed defect (fixed)

[PATCH] Don't load trigger scripts twice

Reported by: Stan Owned by: trompetin17
Priority: Nice to Have Milestone: Alpha 19
Component: Core engine Keywords:
Cc: Patch:

Description (last modified by Itms)

When loading gallic fields I get this error

ERROR: JavaScript error: maps/scripts/TriggerHelper.js line 165 Error: SetGlobal "TriggerHelper" called multiple times


r16713 fixed the problem above but broke the serialization test mode.

Attachments (1)

trigger-STmode.patch (2.4 KB ) - added by Itms 9 years ago.

Download all attachments as: .zip

Change History (10)

comment:1 by Stan, 9 years ago

Summary: Trigger Js ErrorTrigger Helper Js Error

comment:2 by mimo, 9 years ago

I also have this error, but not on belgian bog (which has no error), but on gallic fields.

comment:3 by Stan, 9 years ago

Description: modified (diff)

Sorry mistook the map

comment:4 by sanderd17, 9 years ago

It's bacause the new conquest also needs the TriggerHelper functions, and thus the script is loaded twice. Once as part of the victory-scripts, and once as part of the trigger scripts.

Removing it from the trigger scripts list is no option either, since the player can choose the victory type, and f.e. prefer the Wonder or Endless game mode, which doesn't load the TriggerHelper.

Apparently, the TriggerHelper in the conquest scripts is only used to check some classes of entities, which can be done via an extra line of code too.

Another option is to make the list unique in the gamesetup.

Last edited 9 years ago by sanderd17 (previous) (diff)

comment:5 by trompetin17, 9 years ago

Owner: set to trompetin17
Resolution: fixed
Status: newclosed

In 16713:

Fixes #3238, SetGlobal 'TriggerHelper' called multiple times

comment:6 by Itms, 9 years ago

Component: UI & SimulationCore engine
Description: modified (diff)
Keywords: patch review added
Milestone: BacklogAlpha 19
Priority: Should HaveNice to Have
Resolution: fixed
Status: closedreopened
Summary: Trigger Helper Js Error[PATCH] Don't load trigger scripts twice

The fix above breaks the serialization test mode.

For instance, on Greek Acropolis (2), on the second play of the first turn, ConquestStartGameCount (defined in ConquestCommon.js) is called by DoAfterDelay (requested in Conquest.js) but doesn't exist, probably because the script was not reloaded.

Attached patch is a fix proposal, but maybe there is a less hacky way to do that (e.g. by properly checking that the script has been loaded in the good simulation instance).

by Itms, 9 years ago

Attachment: trigger-STmode.patch added

comment:7 by Itms, 9 years ago

In 16924:

Fix r16713, refs #3238

comment:8 by Itms, 9 years ago

Resolution: fixed
Status: reopenedclosed

In 16925:

Properly check loaded scripts in the second simulation instance of a serialization test. Fixes #3238

comment:9 by Itms, 9 years ago

Keywords: patch review removed
Note: See TracTickets for help on using tickets.