armoha / euddraft

System for pluginizing eudplib codes.
Other
29 stars 4 forks source link

Flaky behavior on trigger manipulation #11

Closed mighty1231 closed 4 years ago

mighty1231 commented 4 years ago

Problem

This short plugin behaves as wrong way. Moreover, the project has flakiness. For each case euddraft compiles without any changes of project, the result map changes in many ways.

Expected behavior

Observation

For each trial of euddraft compilation, the result map shows various behaviors.

  1. No battlecruiser is observed. It generates EUD is not supported error after 2-3 seconds
  2. No battlecruiser is observed. Trigger is stopped. The effect of killing ghost is not observed.
  3. Battlecruisers are observed. However the ghost effect is not observed.

Files

issue.zip

It contains project, and three result map files with their own unique behaviors

Codes

project.edd

[main]
input: base.scx
output: result.scx

[test.py]

[freeze]
freeze: 0

test.py

from eudplib import *

trig_raw = Forward()
trig_inner = Forward()

@EUDFunc
def function():
    v = EUDVariable(1)
    if EUDIf()(v == 0):
        # Trigger 1 would not be executed
        trig_raw << RawTrigger(
            conditions = Always(),
            actions = [
                DisplayText("raw trigger"),
            ]
        )
        # Trigger 2 would not be executed
        trig_inner << RawTrigger(
            conditions = [
                Always(),
            ],
            actions = [
                CreateUnit(1, "Terran Marine", "Anywhere", P1)
            ]
        )
    EUDEndIf()

@EUDFunc
def main():
    function()
    f_repmovsd_epd(EPD(trig_inner)+2, EPD(trig_raw)+2, 2400//4)

    # Flaky behavior
    DoActions([RemoveUnit("(any unit)", P1),
               CreateUnit(100, "Terran Battlecruiser", "Anywhere", P1)])

def beforeTriggerExec():
    if EUDExecuteOnce()():
        main()
    EUDEndExecuteOnce()
mighty1231 commented 4 years ago

@armoha reminded me that f_repmovsd_epd over trigger objects should be used carefully.

Although its GetDataSize returns 2408, it does not own all 2408 bytes. This is because of the compression on the allocation phase. It compresses trigger objects, allowing overlapping. RawTrigger is the only object that uses WriteSpace on allocation phase, and it determines overlap-able regions.