Illegal Exception when Changeroom

Started by homelightgames, Wed 31/01/2007 21:10:59

Previous topic - Next topic

homelightgames

Hey All,

I get this fatal error when previewing my program.  It happens when I ChangeRoom in debug mode (CTRL-X), with the only significant issue is that I have a ResetRoom command for all the other rooms (you can't change the current room) in the When Player Leaves Room interaction.

I've been able replicate it twice, or rather, it's happened twice.

Quote
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x0043CE2D ; program pointer is +6, ACI version 2.72.920NMP, gtags (1,2)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and notify CJ on the Tech forum.

in Global script (line 560)
from Room 1 script (line 282)


Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.
---------------------------
OK   
---------------------------

The Room script only calls the function (Change_Mood (7,0)) which is in the global script:

Code: ags

function Change_Mood(int patient_object, int person_object) {
  if ((object[patient_object].Frame>2) && (object[patient_object].Frame<4)) {
	person_view=object[person_object].View;
	object[person_object].SetView(person_view, 2, 0);
  }
  if (object[patient_object].Frame>4) {
	person_view=object[person_object].View;
	object[person_object].SetView(person_view, 3, 0);
  }
}


I don't see any problems within that.

Is there any known weaknesses or warnings concerning reset room?  Or does anyone know what this error is?

Thanks,

visionmind

Pumaman

Which one of those lines is line 560?

Are the parent_object and person_object variables referring to object ID's that definitely exist in the current room? You need to be careful when using the object[] array from the global script.

homelightgames

The line is the one marked.

Code: ags

  function Change_Mood(int patient_object, int person_object) {
      if ((object[patient_object].Frame>2) && (object[patient_object].Frame<4)) {
        person_view=object[person_object].View;
        object[person_object].SetView(person_view, 2, 0);
      }
      if (object[patient_object].Frame>4) {
             person_view=object[person_object].View;
560 >> object[person_object].SetView(person_view, 3, 0);
          }
      }


The only 'if' is that maybe the object might be invisible, but I believe I have checks against that.  Would that cause the problem?  What care should be taken?

Thanks for your attention.

visionmind

Kweepa

Try adding this debugging code to the top of Change_Mood:

Code: ags

  function Change_Mood(int patient_object, int person_object) {

   // DEBUG CODE STARTS HERE
   if (object[patient_object] == null) Display("There is no object %d in this room!", patient_object);
   if (object[person_object] == null) Display("There is no object %d in this room!", person_object);
   // DEBUG CODE ENDS HERE

      if ((object[patient_object].Frame>2) && (object[patient_object].Frame<4)) {
        person_view=object[person_object].View;
        object[person_object].SetView(person_view, 2, 0);
      }
      if (object[patient_object].Frame>4) {
             person_view=object[person_object].View;
             object[person_object].SetView(person_view, 3, 0);
          }
      }
Still waiting for Purity of the Surf II

Pumaman

The problem with the object[] array is that it can appear to be valid but if you try to access an object that doesn't exist the engine can crash.
What is person_object set to, and does that object number definitely exist in the room?

SMF spam blocked by CleanTalk