Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Akumayo on Wed 11/01/2006 00:27:46

Title: Illegal exception trying to move overlay (SOLVED)
Post by: Akumayo on Wed 11/01/2006 00:27:46
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:


  Overlay* a_envoverlay;


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


  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:


  a_envoverlay.X += Random(speed);


What's happening?

-Regards, Glacies Akumayo
Title: Re: Error generating using overlays...
Post by: Gilbert on Wed 11/01/2006 01:49:45
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);
}
Title: Re: Error generating using overlays...
Post by: Akumayo on Wed 11/01/2006 17:18:34

    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:


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


I'm very confused now....
Title: Re: Error generating using overlays...
Post by: strazer on Wed 11/01/2006 17:48:12
I'm not sure if += works with properties correctly, so try
  a_envoverlay.X = a_envoverlay.X + Random(speed);
Title: Re: Error generating using overlays...
Post by: Pumaman on Wed 11/01/2006 19:10:48
What is windspeed set to? It's not something silly like -1 is it?
Title: Re: Error generating using overlays...
Post by: Akumayo on Wed 11/01/2006 22:13:20
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
Title: Re: Illegal exception trying to move overlay (SOLVED)
Post by: Pumaman on Wed 11/01/2006 22:44:50
Nevertheless, AGS should handle it better, so I'll look into the erro rhandling for Random.