Illegal exception trying to move overlay (SOLVED)

Started by Akumayo, Wed 11/01/2006 00:27:46

Previous topic - Next topic

Akumayo

Quote
An exception 0xC0000094 occured in ACWIN.EXE at EIP = 0x00444F8B ; program pointer is +1004, ACI version 2.71.894, gtags (14,22)

(...)

in Enviornmental Effects (line 155)

I managed to get around this the first time it happened, but I don't know what exactly is making it happen.  I coded:

Code: ags

  Overlay* a_envoverlay;


At the beginning of my module script,  in one function I make a_envoverlay using CreateGraphical:

Code: ags

  a_evnoverlay = Overlay.CreateGraphical(...yadda yadda...);


The error is being generated by this line, which is located in the module's repeatedly_excecute_always() function:

Code: ags

  a_envoverlay.X += Random(speed);


What's happening?

-Regards, Glacies Akumayo
"Power is not a means - it is an end."

Gilbert

Note that if you just put that line in repeatedly_execute_always() it's supposed to be executed EVERY game loop in EVERY room.
If the overlay is not valid and you try to refer to it your game will crash.
So the question is, are you sure the overlay is valid in EVERY game loop in EVERY room?

A safeguard method to do that is to use the following more complicated code instead:
if (a_envoverlay!=null) {
  if (a_envoverlay.Valid) a_envoverlay.X += Random(speed);
}

Akumayo

Code: ags

    if (a_envoverlay != null) { 
      if (a_envoverlay.Valid) a_envoverlay.X += Random(windspeed); 
    }


Now the same error is being generated, but for the line saying:

Code: ags

       if (a_envoverlay.Valid) a_envoverlay.X += Random(windspeed);


I'm very confused now....
"Power is not a means - it is an end."

strazer

I'm not sure if += works with properties correctly, so try
  a_envoverlay.X = a_envoverlay.X + Random(speed);

Pumaman

What is windspeed set to? It's not something silly like -1 is it?

Akumayo

I worked it out after all... it seems windspeed was indeed being set to -2 through a previous randomizer.Ã,  I fixed it up, positive integers only nowÃ,  :)
What a silly mistake eh?

-Thank you, Glacies Akumayo
"Power is not a means - it is an end."

Pumaman

Nevertheless, AGS should handle it better, so I'll look into the erro rhandling for Random.

SMF spam blocked by CleanTalk