|
Thread: ERA3 crashes when loading super large scripts | |
|
Finally

 

Hired Hero
|
posted September 04, 2022 04:52 PM |
|
|
ERA3 crashes when loading super large scripts
The script is all about change terrain, move view, set delay, and function calls. Below are what I found in debugERA directory.
erm memory dump.txt:
> ERA version: 3.0.4
> ERM context in BA.erm:191693:1
!!TR59/39/0:T7/0/0/0/0/0/0/0;
!!TR59/56/0:T9/0/0/0/0/0/0/0;
!!TR59/57/0:T9/0/0/0/0/0/0/0;
!!TR59/58/0:T7/0/0/0/0/0/0/0;
!!TR60/35/0:T3/0/0/0/0/0/0/0;
!!TR60/36/0:T4/0/0/0/0/0/0/0;
!!TR60/57/0:T9/0/0/0/0/0/0/0;
!!TR60/58/0:T9/0/0/0/0/0/0/0;
!!TR60/59/0:T7/0/0/0/0/0/0/0;
!!TR61/34/0:T4/0/0/0/0/0/0/0;
...
event list.txt:
> Format: [Event name] ([Number of handlers], [Fired N times])
$OnBeforeResetErmFunc (1, 1)
$OnEraLoadScripts (2, 0)
$OnEraMapStart (1, 1)
$OnEraSaveScripts (2, 0)
OnAfterCreateWindow (1, 1)
OnAfterLoadLods (0, 1)
OnAfterLoadMedia (0, 1)
OnAfterStructRelocations (2, 1)
OnAfterVfsInit (1, 1)
OnAfterWoG (14, 1)
OnBeforeBattleUniversal (1, 0)
OnBeforeClearErmScripts (1, 1)
OnBeforeErm (0, 1)
OnBeforeErmInstructions (3, 1)
OnBeforeScriptsReload (1, 0)
OnBeforeWoG (5, 1)
OnEraStart (1, 1)
OnEvery2Seconds (0, 2)
OnEvery5Seconds (0, 1)
OnEverySecond (0, 5)
OnGameLeave (1, 0)
OnGenerateDebugInfo (6, 1)
OnGuiStart (0, 1)
OnKeyPressed (0, 4)
OnPandora'sApiReady (2, 1)
OnReportVersion (0, 1)
OnSavegameRead (6, 0)
OnSavegameWrite (5, 0)
OnTrigger 30900 (0, 5)
OnTrigger 30901 (0, 2)
OnTrigger 30902 (0, 1)
OnTrigger 77017 (1, 0)
> Event handlers
$OnBeforeResetErmFunc:
Era.7E4F0 (EraButtons.Finalization in PoTweak.pas on line 118)
$OnEraLoadScripts:
Era.4CD30 (Trans.OnGenerateDebugInfo in Trans.pas on line 208)
Era.3CCF0 (Erm.OnEraLoadScripts in Erm.pas on line 1375)
$OnEraMapStart:
Era.4CCB4 (Trans.OnGenerateDebugInfo in Trans.pas on line 181)
$OnEraSaveScripts:
Era.4CD00 (Trans.OnEraSaveScripts in Trans.pas on line 195)
Era.3CC58 (Erm.OnEraLoadScripts in Erm.pas on line 1354)
OnAfterCreateWindow:
Era.523EC (Rainbow.OnAfterCreateWindow in Rainbow.pas on line 550)
OnAfterStructRelocations:
Era.2BA80 (GameExt.InitWoG in Heroes.pas on line 1605)
Era.4AC48 (Erm.Finalization in Erm.pas on line 7559)
OnAfterVfsInit:
Era.503EC (Tweaks.OnAfterVfsInit in Tweaks.pas on line 1152)
OnAfterWoG:
Era.4BCE4 (Stores.OnAfterWoG in Stores.pas on line 449)
Era.4CC78 (Trans.OnBeforeScriptsReload in Trans.pas on line 164)
Era.32D08 (AdvErm.TSlotReleaser.Destroy in Triggers.pas on line 600)
Era.3103C (SndVid.OnAfterWoG in SndVid.pas on line 435)
Era.31ED8 (Triggers.Hook_StartCalcDamage in Lodman.pas on line 463)
Era.39B94 (AdvErm.OnAfterWoG in AdvErm.pas on line 3096)
Era.4A1D4 (Stores.TRider.Flush in Erm.pas on line 7392)
Era.4FC1C (Tweaks.OnAfterVfsInit in Tweaks.pas on line 986)
Era.5240C (zlibpas:CODE in Rainbow.pas on line 550)
Era.7E4FC (PoTweak.OnAfterWoG in PoTweak.pas on line 122)
Era.7ED18 (EraButtons.Finalization in EraButtons.pas on line 161)
Era.81378 (Dwellings.Finalization in Dwellings.pas on line 1177)
Buttons.4A50 (Buttons.Finalization in Buttons.dpr on line 1317)
Pandora's api.2310
OnBeforeBattleUniversal:
Era.4EC34 (Tweaks.DumpWinPeModuleList in Tweaks.pas on line 795)
OnBeforeClearErmScripts:
Era.4A040 (Erm.OnBeforeWoG in Erm.pas on line 7303)
OnBeforeErmInstructions:
Era.31CCC (Lodman.OnBeforeWoG in Lodman.pas on line 412)
Era.39CC4 (AdvErm.InitHints in AdvErm.pas on line 3123)
Erm_hooker.1D780 (System.dig + 8 in erm_hooker.dpr on line 232 offset 4808)
OnBeforeScriptsReload:
Era.4CC84 (Trans.OnBeforeScriptsReload in Trans.pas on line 181)
OnBeforeWoG:
Era.31E90 (Lodman.OnBeforeWoG in Lodman.pas on line 450)
Era.397C4 (ErmTracking.TEventTracker.Create in AdvErm.pas on line 3066)
Era.4A04C (Erm.OnBeforeWoG in Erm.pas on line 7316)
Era.7E2A4 (Scripts.Finalization in PoTweak.pas on line 45)
Wog patcherizer.1330
OnEraStart:
Era.822D0 (EraSettings.Finalization in EraSettings.pas on line 96)
OnGameLeave:
Erm_hooker.1D780 (System.dig + 8 in erm_hooker.dpr on line 232 offset 4808)
OnGenerateDebugInfo:
Era.4CDA8 (Trans.OnGenerateDebugInfo in Trans.pas on line 222)
Era.39124 (AdvErm.New_ZvsSaveMP3 in AdvErm.pas on line 2893)
Era.49FA0 (Erm.OnGenerateDebugInfo in Erm.pas on line 7294)
Era.4FC00 (Graphics.TFont.Changed in Tweaks.pas on line 986)
Erm_hooker.1D810 (SysUtils.LeadBytes + 8 in erm_hooker.dpr on line 232 offset 4952)
Era.2CAB0 (GameExt.OnGenerateDebugInfo in GameExt.pas on line 371)
OnPandora'sApiReady:
Receiver pa.24A0
Receiver qu.2520
OnSavegameRead:
Era.31DB0 (Lodman.OnBeforeWoG in Lodman.pas on line 441)
Era.37ADC (AdvErm.OnSavegameRead in AdvErm.pas on line 2391)
Era.49F94 (Erm.OnBeforeWoG in Erm.pas on line 7290)
Era.7E4AC (PoTweak.OnSavegameRead in PoTweak.pas on line 110)
Erm_hooker.1D780 (System.dig + 8 in erm_hooker.dpr on line 232 offset 4808)
04BA0000
OnSavegameWrite:
Era.31CE0 (Lodman.OnSavegameWrite in Lodman.pas on line 412)
Era.374F4 (AdvErm.OnSavegameWrite in AdvErm.pas on line 2197)
Era.49F88 (Erm.OnSavegameWrite in Erm.pas on line 7285)
Era.7E46C (PoTweak.OnSavegameRead in PoTweak.pas on line 125)
04BA0000
OnTrigger 77017:
Era.4E97C (Tweaks.OnRemoteMapObjectPlace in Tweaks.pas on line 613)
|
|
Bersy

    
    
Honorable
Supreme Hero
|
posted September 05, 2022 06:38 PM |
|
|
|
Finally

 

Hired Hero
|
posted September 06, 2022 02:35 AM |
|
|
Bersy said: Did you try to use more recent Era version like 3.91 or 3.93?
I tried 3.92, result is the same.
|
|
Bersy

    
    
Honorable
Supreme Hero
|
posted September 09, 2022 02:07 AM |
|
|
|
Finally

 

Hired Hero
|
posted September 09, 2022 07:04 AM |
|
|
Bersy said: Usually scripts, altering terrain, like passable terrain, corrupt internal map data and crash occurs because of corruption, not ERM scripts size.
But the scripts aren't running on loading. They have to be triggered in game.
|
|
phe

 
   
Famous Hero
Life and Freedom
|
posted September 09, 2022 07:47 AM |
|
|
Bersy said: Usually scripts, altering terrain, like passable terrain, corrupt internal map data and crash occurs because of corruption, not ERM scripts size.
any chance to make passable terrain working without crashes?
|
|
Bersy

    
    
Honorable
Supreme Hero
|
posted September 09, 2022 08:26 PM |
|
|
|
Finally

 

Hired Hero
|
posted September 10, 2022 04:03 AM |
|
|
Another issue: Is there a limit for lines of receivers following a trigger? When I have a script like:
!?LE...
!!TR... (many many lines)
When ther trigger fires, only the last portion of receivers executed(may be 65535 lines?). Thus I feel there is a limit. If so, how can I remove the limit?
|
|
Bersy

    
    
Honorable
Supreme Hero
|
posted September 11, 2022 04:36 PM |
|
|
|
Finally

 

Hired Hero
|
posted September 12, 2022 12:43 AM |
|
|
Bersy said: There is no limit. And why don't you use loops?
!!re i/0/15/1/-1;
do something 15 times, i will count from 0 to 14
!!en;
The codes are generated, can't loop unless load from file which is too slow.
And I never seen "!!re" and "!!en" in ERM Help, they must be ERM3. Where can I find ERM3 Help?
|
|
avatar

  
    
Promising
Supreme Hero
|
posted September 12, 2022 07:17 AM |
|
|
For now, only in Era/Help/era iii changelog.txt
____________
|
|
Finally

 

Hired Hero
|
posted September 24, 2022 05:54 AM |
|
|
Bersy said: There is no limit
The limit definitely exists.
I tried the codes below:
ZVSE2
!?LE143/142/0;
!!IF:M^0^;
!!IF:M^1^;
...
!!IF:M^65534^;
it works correctly.
But if I add
!!IF:M^65535^;
at the end, then NO message pops up.
And then I add
!!IF:M^65536^;
at the end, only 65536 pop up.
Seperate these codes into different functions solves the problem, but when there are about 190k lines of codes, the game crashes on load. No terrain changes this time, just messages.
|
|
gamemaster

 
 
Adventuring Hero
|
posted September 25, 2022 02:03 PM |
|
|
I can confirm that function has 65536 line limit (including !?FU line).
Can not find where limit is defined.
I check it by script with 260k+ lines (~4Mb).
Problem Finally describe occurs when long function code "fall out" of function after 65536 lines. That code is treated as regular code (not in function) and probably cause crash when game execute script.
@Finally
This is limitation at this moment. All you can do is separate code in functions with less then 65536 lines.
@Bersy
Any idea where to put brakepoint in code to see what lines of script belong to which function?
|
|
Finally

 

Hired Hero
|
posted September 25, 2022 03:35 PM |
|
|
gamemaster said:
Problem Finally describe occurs when long function code "fall out" of function after 65536 lines. That code is treated as regular code (not in function) and probably cause crash when game execute script.
But the game crashes when loading, not when the codes executing.
And it's not the number of lines in the function matters, but the total lines matters. I tried 500 functions and 400 lines each function, or 250 functions and 800 lines each function, both crashes.
|
|
gamemaster

 
 
Adventuring Hero
|
posted September 25, 2022 05:42 PM |
|
|
Can you share script so I can try it locally? I can throw quick look on it.
Or
Try to narrow down problem and find what line fail.
|
|
Finally

 

Hired Hero
|
posted September 25, 2022 06:19 PM |
|
Edited by Finally at 18:24, 25 Sep 2022.
|
gamemaster said: Can you share script so I can try it locally? I can throw quick look on it.
Or
Try to narrow down problem and find what line fail.
The codes below works.
ZVSE2
!?LE143/142/0;
!!FU1:P;
!!FU2:P;
!!FU3:P;
!?FU1;
!!IF:M^1^;
!!IF:M^2^;
...
!!IF:M^63869^;
!?FU2;
!!IF:M^1^;
!!IF:M^2^;
...
!!IF:M^63869^;
!?FU3;
!!IF:M^1^;
!!IF:M^2^;
...
!!IF:M^63869^;
And if I add
!!IF:M^63870^;
to the end of each function, a message pops up:
no_memory_for_erm_optimization
and no crash this time, but the trigger won't work.
if I then add
!!IF:M^63871^;
to the end of each function, then it crashes like before.
|
|
Salamandre

     
       
Admirable
Omnipresent Hero
Wog refugee
|
posted September 25, 2022 08:58 PM |
|
|
Uh, why use 60 000 lines for a function that can be done as loop in 3 lines?
|
|
Finally

 

Hired Hero
|
posted September 26, 2022 12:42 AM |
|
|
Salamandre said: Uh, why use 60 000 lines for a function that can be done as loop in 3 lines?
It's just an example. the actual codes can't loop efficiently.
|
|
Dead16

 
Tavern Dweller
|
posted December 11, 2022 12:15 AM |
|
Edited by Dead16 at 00:41, 11 Dec 2022.
|
Finally said:
Bersy said: There is no limit
The limit definitely exists.
I tried the codes below:
ZVSE2
!?LE143/142/0;
!!IF:M^0^;
!!IF:M^1^;
...
!!IF:M^65534^;
it works correctly.
But if I add
!!IF:M^65535^;
at the end, then NO message pops up.
And then I add
!!IF:M^65536^;
at the end, only 65536 pop up.
Seperate these codes into different functions solves the problem, but when there are about 190k lines of codes, the game crashes on load. No terrain changes this time, just messages.
google number 65535,that have hint for this problem, some information from wikipedia, 65535 is the integer after 65534 and before 65536.
It is the maximum value of an unsigned 16-bit integer.[1], it,s cannot be coincidence 
https://en.wikipedia.org/wiki/65,535 For more information.
____________
|
|
|