royitaqi / HollowKnight.BossAttacks

4 stars 1 forks source link

Bug: weirdness in AbsRad level change and module load/unload #13

Closed royitaqi closed 1 year ago

royitaqi commented 1 year ago

E.g. Why didn't the level change to 1 cause the unloading of [transit 0->1 | 0/0]? E.g. there isn't message "Level is now 0"

These are caused by three process calling into each other together, so some of their assumptions are broken.

  1. Change level, during which modules can be loaded according to the current _level
  2. Module loading, which can cause level to change (AutoLevelChanger)
    • Should it be changed to event based for AbsRad 0->1?
  3. Level change then can cause the same module to be unloaded while still in its OnLoad() method.

One way to solve this problem is to use the message bus, so that each function can complete before another starts.

Repro: b65609f27231729caebec9e8e27010c65e430044

[INFO]:[BossAttacks] - 07:49:08.010 [I] [ModuleManager] Load
[INFO]:[BossAttacks] - 07:49:08.012 [I] [ModuleManager] Unload
[INFO]:[BossAttacks] - 07:49:08.027 [D] [ModuleManager] Modules: (10) AutoLevelChanger, AutoLevelChanger, AutoLevelChanger, AutoLevelChanger, AutoLevelChanger, GenericAttackSelector, GenericAttackSelector, PrintStates, PrintStates, PrintStates
[INFO]:[BossAttacks] - 07:49:08.028 [D] [ModuleManager] Changing level from 0 to 0
[INFO]:[BossAttacks] - 07:49:08.033 [I] [transit 0->1 | 0/0] Loading
[INFO]:[BossAttacks] - 07:49:08.036 [D] [transit 0->1 | 0/0] GO = Absolute Radiance  (156110)
[INFO]:[BossAttacks] - 07:49:08.036 [D] [transit 0->1 | 0/0] FSM = Phase Control (161916)
[INFO]:[BossAttacks] - 07:49:08.037 [D] [ModuleManager] Changing level from 0 to 1
[INFO]:[BossAttacks] - 07:49:08.037 [I] [transit 1->2 | 0/1] Loading
[INFO]:[BossAttacks] - 07:49:08.037 [D] [transit 1->2 | 0/1] GO = Absolute Radiance  (156110)
[INFO]:[BossAttacks] - 07:49:08.038 [D] [transit 1->2 | 0/1] FSM = Phase Control (161916)
[INFO]:[BossAttacks] - 07:49:08.038 [I] [transit 2->3 | 0/2] Loading
[INFO]:[BossAttacks] - 07:49:08.039 [D] [transit 2->3 | 0/2] GO = Absolute Radiance  (156110)
[INFO]:[BossAttacks] - 07:49:08.039 [D] [transit 2->3 | 0/2] FSM = Phase Control (161916)
[INFO]:[BossAttacks] - 07:49:08.039 [I] [transit 3->4 | 0/3] Loading
[INFO]:[BossAttacks] - 07:49:08.040 [D] [transit 3->4 | 0/3] GO = Absolute Radiance  (156110)
[INFO]:[BossAttacks] - 07:49:08.040 [D] [transit 3->4 | 0/3] FSM = Control (161786)
[INFO]:[BossAttacks] - 07:49:08.040 [I] [transit 4->5 | 0/4] Loading
[INFO]:[BossAttacks] - 07:49:08.041 [D] [transit 4->5 | 0/4] GO = Absolute Radiance  (156110)
[INFO]:[BossAttacks] - 07:49:08.041 [D] [transit 4->5 | 0/4] FSM = Phase Control (161916)
[INFO]:[BossAttacks] - 07:49:08.042 [I] [AS in 1 and 2 | 1/2] Loading for scene GG_Radiance
[INFO]:[BossAttacks] - 07:49:08.044 [D] [AS in 1 and 2 | 1/2] GO = Absolute Radiance  (156110)
[INFO]:[BossAttacks] - 07:49:08.044 [D] [AS in 1 and 2 | 1/2] FSM = Attack Choices (161796)
[INFO]:[BossAttacks] - 07:49:08.044 [D] [AS in 1 and 2 | 1/2] State = A1 Choice
[INFO]:[BossAttacks] - 07:49:08.048 [I] [PrintStates #0 | 0/4] Loading for scene GG_Radiance
[INFO]:[BossAttacks] - 07:49:08.049 [D] [PrintStates #0 | 0/4] GO = Absolute Radiance  (156110)
[INFO]:[BossAttacks] - 07:49:08.049 [D] [PrintStates #0 | 0/4] FSM = Phase Control (161916)
[INFO]:[BossAttacks] - 07:49:08.049 [I] [PrintStates #1 | 0/4] Loading for scene GG_Radiance
[INFO]:[BossAttacks] - 07:49:08.050 [D] [PrintStates #1 | 0/4] GO = Absolute Radiance  (156110)
[INFO]:[BossAttacks] - 07:49:08.051 [D] [PrintStates #1 | 0/4] FSM = Control (161786)
[INFO]:[BossAttacks] - 07:49:08.051 [I] [PrintStates #2 | 0/4] Loading for scene GG_Radiance
[INFO]:[BossAttacks] - 07:49:08.052 [D] [PrintStates #2 | 0/4] GO = Absolute Radiance  (156110)
[INFO]:[BossAttacks] - 07:49:08.052 [D] [PrintStates #2 | 0/4] FSM = Attack Choices (161796)
[INFO]:[BossAttacks] - 07:49:08.053 [D] [BossAttacks] "1" - [ ✓ ] - BEAM SWEEP L
[INFO]:[BossAttacks] - "2" - [ ✓ ] - BEAM SWEEP R
[INFO]:[BossAttacks] - "3" - [ ✓ ] - EYE BEAMS
[INFO]:[BossAttacks] - "4" - [ ✓ ] - NAIL FAN
[INFO]:[BossAttacks] - "5" - [ ✓ ] - NAIL L SWEEP
[INFO]:[BossAttacks] - "6" - [ ✓ ] - NAIL R SWEEP
[INFO]:[BossAttacks] - "7" - [ ✓ ] - NAIL TOP SWEEP
[INFO]:[BossAttacks] - "8" - [ ✓ ] - ORBS
[INFO]:[BossAttacks] - 
[INFO]:[BossAttacks] - 07:49:08.053 [D] [ModuleManager] Level is now 1
royitaqi commented 1 year ago

No longer repro or bother.