TerryCavanagh / diceydungeons.com

Dicey Dungeons
50 stars 7 forks source link

Crash when status tries to remove itself entirely within its "on any equipment use" script #1938

Open ncrecc opened 4 years ago

ncrecc commented 4 years ago

I have a status named ncr_paralysis whose "on any equipment use" script is this: inflictself(SHOCK); self.applyequipmentcurses(); removestatusself(~ncr_paralysis~); When an enemy with only 1 point of that status uses a card (thus activating the above removestatusself), this error occurs:

CrashDumper.hx:248: CRASH session.id = dicey_dungeons_2020-09-14_14'24'26
CrashDumper.hx:249: MESSAGE = --------------------------------------
filename:       diceydungeons
package:        com.terrycavanaghgames.diceydungeons
version:        v1.9 / 1.0 (mod API)
sess. ID:       dicey_dungeons_2020-09-14_14'24'26
started:        2020-09-14 14:24:26
--------------------------------------
crashed:        2020-09-14 14:24:48
duration:       00:00:21
error:          Null Object Reference
stack:
elements.StatusApply.applyonanyequipmentuse (elements/StatusApply.hx line 161)
Script.callechoscripts_equipment (Script.hx line 443)
elements.Equipment.doequipmentaction (elements/Equipment.hx line 2678)
Reflect.callMethod (C:\coding\haxe\openfl\std/cpp/_std/Reflect.hx line 55)
motion.actuators.GenericActuator.complete (motion/actuators/GenericActuator.hx line 155)
motion.actuators.SimpleActuator.update (motion/actuators/SimpleActuator.hx line 529)
motion.actuators.SimpleActuator.stage_onEnterFrame (motion/actuators/SimpleActuator.hx line 608)
openfl.events.EventDispatcher.__dispatchEvent (openfl/events/EventDispatcher.hx line 443)
openfl.display.DisplayObject.__dispatch (openfl/display/DisplayObject.hx line 1236)

CrashDumper.hx:142: onError(EOF)
Called from sys.net.Socket::connect C:\coding\haxe\openfl\std/cpp/_std/sys/net/Socket.hx line 179

This also happens if I attempt the more direct inflictself(SHOCK); self.applyequipmentcurses(); status._displayvalue--; status.value--; if(status.value <= 0) status.removenow();

TerryCavanagh commented 4 years ago

Ah, hmm. I thought I'd fixed this, oh well.

I think I'm going to need to implement a more extreme fix here, where things are "marked" as no longer active internally, and cleaned up in the background when it's safe. Unfortunately I don't think I can risk adding something like that to v1.9 now, so this might take a while.

racknae commented 3 years ago

In particular this crash appears to occur when an enemy receives a status at the same time the old one is being removed. For example, if the enemy uses Flight (gain dodge) and the status is completely removed by that equipment use, the game will crash.