Page 1 of 1

Crash using v0.20 on creating monsters on demand

Posted: Tue Aug 13, 2002 11:29 am
by Gambit37
So I'm updating the kid dungeon to use relays instead of multiple switches. There's a place where you can create monsters by pressing a button on the wall. After i made the changes, it creates the monsters fine if you press the button steadily, and after the rechargetime has expired. However, if you repeatedly press it very quickly, RTC bombs:

Error:
an access violation exception.

Stack Dump:
RTC.TriggerMonsterGenerator(int 312, int 1);
RTC.EmptyTriggerQueue();
RTC.UpdateDungeon();
RTC.DoFrame(int 50);
RTC.WinMain();

Here's the dungeon code for this structure:

614&nbsp &nbsp &nbsp &nbsp WALLITEM_RELAY&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 1&nbsp &nbsp &nbsp &nbsp 18&nbsp &nbsp &nbsp &nbsp 1&nbsp &nbsp &nbsp &nbsp SOUTH&nbsp &nbsp &nbsp &nbsp ACTION=(ACTIVATE)&nbsp &nbsp &nbsp &nbsp TARGET=(650)
615&nbsp &nbsp &nbsp &nbsp WALLITEM_RELAY&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 1&nbsp &nbsp &nbsp &nbsp 18&nbsp &nbsp &nbsp &nbsp 1&nbsp &nbsp &nbsp &nbsp SOUTH&nbsp &nbsp &nbsp &nbsp ACTION=(ACTIVATE)&nbsp &nbsp &nbsp &nbsp TARGET=(618) &nbsp &nbsp &nbsp &nbsp DELAY=(4)
617&nbsp &nbsp &nbsp &nbsp WALLITEM_SWITCH_GREEN&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 1&nbsp &nbsp &nbsp &nbsp 18&nbsp &nbsp &nbsp &nbsp 1&nbsp &nbsp &nbsp &nbsp EAST&nbsp &nbsp &nbsp &nbsp OPBY=(MOUSE)&nbsp &nbsp &nbsp &nbsp ACTION=(ACTIVATE)&nbsp &nbsp &nbsp &nbsp TARGET=(614,615)
618&nbsp &nbsp &nbsp &nbsp FLOORITEM_GENERATOR_MONSTER&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 0&nbsp &nbsp &nbsp &nbsp 19&nbsp &nbsp &nbsp &nbsp 1&nbsp &nbsp &nbsp &nbsp GENERATES=(MONSTER_ROCKPILE)&nbsp &nbsp &nbsp &nbsp NUMBERS=(1)&nbsp &nbsp &nbsp &nbsp HEALTH=(25)&nbsp &nbsp &nbsp &nbsp OPTIONS=(SOUND:SOUND_STEP_ANIMAL,RECHARGE_TIME:12)
650&nbsp &nbsp &nbsp &nbsp WALLITEM_SHOOTER&nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp 0&nbsp &nbsp &nbsp &nbsp 20&nbsp &nbsp &nbsp &nbsp 1&nbsp &nbsp &nbsp &nbsp NORTH&nbsp &nbsp &nbsp &nbsp TYPE=(SINGLE)&nbsp &nbsp &nbsp &nbsp SHOOTS=(DUNGEON_SPELL_DESEW)&nbsp &nbsp &nbsp &nbsp STRENGTH=(100)

Incidentally, it also crashes using my old method of lots of green switches performing the actions themselves....but only if you very quickly press the button, so it appears to be a problem with RTC keeping up, not the method used to create the effect.

Re: Crash using v0.20 on creating monsters on demand

Posted: Tue Aug 13, 2002 11:46 am
by Gambit37
Addendum:

It only crashes if the monster has not yet appeared by the time the button has been clicked for the second time. Normally, this wouldn't be a problem, but on this set-up, I have a delay of 4 for the relay controlling the generator, which I guess is messing things up.

Also, there's no crash if there is already a monster on the tile -- you can click the button as much as you like and as quickly as you like and everything is fine: no new monsters appear cos the tile is already occupied.

Seems that when the button is pressed for the first time, the relay gets fired which fires the generator 4 ticks later, creating the monster. But if you've already pressed the button again, before the 4 ticks have expired, RTC thinks the tile is still empty and tries to create another monster. Of course, then the original delayed monster appears and everything goes pear shaped... my guess is that RTC is only looking at the contents of the tile itself, and isn't taking into account any of the queued/delayed events for the tile....?

Re: Crash using v0.20 on creating monsters on demand

Posted: Fri Aug 23, 2002 9:35 am
by George Gilbert
I've tried several times to replicate this but with no success. I think there must be something else going on (or else I've "accidently" fixed it whilst fixing something else).

Is there any chance you could please send me your complete file? If you can get it to me later today I'lll have a look over the w/e and get the fix into v0.21...

Re: Crash using v0.20 on creating monsters on demand

Posted: Sun Aug 25, 2002 3:10 pm
by George Gilbert
Fixed for V0.21.

This was obscure as well. The problem was nothing to do with the delay or pressing the button twice, but instead due to the interaction of a monster being generated on the same tile and at the same time as a Des-Ew spell exploding.

The code used to generate the monster, add it to the tile then set its attributes (in particular it's health). When adding to the tile, the collision detection routines (with the des-ew) were activated (but no damage was caused). On exiting the collision detection, the code noticed that the health was zero so deleted the monster from the dungeon. Then when trying to give a non existant monster some health the exception occured.

To fix it all I've done is made sure that the monsters have some health before they're added to the tile!