Author Topic: (solved) Illegal exception during animated inv item cursor  (Read 184 times)

arj0n

  • Mittens Vassal
  • art consists in drawing a line somewhere
    • arj0n worked on one or more games that won an AGS Award!
    •  
    • arj0n worked on one or more games that was nominated for an AGS Award!
In my current project I use animated inv item cursors.
But:
After selecting an inv item, the mouse cursor is animated.
When I let the game run idle for a minute or so, it always gives an illegal exception:
(when i disable the 2 relevant code parts (for these 2 parts, see below in this post), the exception doesn't occur)

AGS version info:
AGS Editor .NET (Build 3.4.3.1)
v3.4.3, February 2019

exception:
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x0041F895 ; program pointer is +32, ACI version 3.4.3.1, gtags (10,2)
AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and post the details on the AGS Technical Forum.
Most versions of Windows allow you to press Ctrl+C now to copy this entire message to the clipboard for easy reporting.
An error file CrashInfo.dmp has been created. You may be asked to upload this file when reporting this problem on the AGS Forums. (code 0)


Sometimes the first line in the error message contains another gtags value:
An exception 0xC0000005 occurred in ACWIN.EXE at EIP = 0x0041F895 ; program pointer is +32, ACI version 3.4.3.1, gtags (0,2)

Note: the CrashInfo.dmp error file doesn't seems to have been created, I can't find it.

project info:
there are 18 sprites per GraphicStyle, all sprite occupies consecutive slots.
the game has 5 different GraphicStyles, each one has its own view.
each of the 5 view has 18 frames.

At the top in my global script:
Code: [Select]
#define INV_CUR_FRAMES 18
#define INV_CUR_FIRST_SLOT_ATARI 2568
#define INV_CUR_FIRST_SLOT_C64 2586
#define INV_CUR_FIRST_SLOT_CGA1 2604
#define INV_CUR_FIRST_SLOT_CGA3 2622
#define INV_CUR_FIRST_SLOT_GBM 2640
#define MARKER_OFFSET -1
 
DynamicSprite*inv_cur[INV_CUR_FRAMES];
 
void UpdateInvCurView() {
 
  if (player.ActiveInventory == null) return;
 
  int i, w, h;
  DrawingSurface*ds;
  ViewFrame*vf;
  mouse.ChangeModeView(eModeUseinv, -1);
  while (i < INV_CUR_FRAMES) {
    // if (inv_cur[i] != null) inv_cur[i].Delete();
    inv_cur[i] = DynamicSprite.CreateFromExistingSprite(player.ActiveInventory.Graphic, true);
    w = inv_cur[i].Width;
    h = inv_cur[i].Height;
    // add transparent border to left and top
    inv_cur[i].ChangeCanvasSize(w+MARKER_OFFSET, h+MARKER_OFFSET, MARKER_OFFSET, MARKER_OFFSET);
    ds = inv_cur[i].GetDrawingSurface();
    if (GraphicStyle == 1) ds.DrawImage(0, 0, i + INV_CUR_FIRST_SLOT_ATARI);
    else if (GraphicStyle == 2) ds.DrawImage(0, 0, i + INV_CUR_FIRST_SLOT_C64);
    else if (GraphicStyle == 3) ds.DrawImage(0, 0, i + INV_CUR_FIRST_SLOT_CGA1);
    else if (GraphicStyle == 4) ds.DrawImage(0, 0, i + INV_CUR_FIRST_SLOT_CGA3);
    else if (GraphicStyle == 5) ds.DrawImage(0, 0, i + INV_CUR_FIRST_SLOT_GBM);
    ds.Release();
    if (GraphicStyle == 1) vf = Game.GetViewFrame(INVCURVIEW_ATARI, 0, i);
    else if (GraphicStyle == 2) vf = Game.GetViewFrame(INVCURVIEW_C64, 0, i);
    else if (GraphicStyle == 3) vf = Game.GetViewFrame(INVCURVIEW_CGA1, 0, i);
    else if (GraphicStyle == 4) vf = Game.GetViewFrame(INVCURVIEW_CGA3, 0, i);
    else if (GraphicStyle == 5) vf = Game.GetViewFrame(INVCURVIEW_GBM, 0, i);
    vf.Graphic = inv_cur[i].Graphic;
    i++;
  }
  mouse.ChangeModeGraphic(eModeUseinv, inv_cur[0].Graphic);
  if (GraphicStyle == 1) mouse.ChangeModeView(eModeUseinv, INVCURVIEW_ATARI);
  else if (GraphicStyle == 2) mouse.ChangeModeView(eModeUseinv, INVCURVIEW_C64);
  else if (GraphicStyle == 3) mouse.ChangeModeView(eModeUseinv, INVCURVIEW_CGA1);
  else if (GraphicStyle == 4) mouse.ChangeModeView(eModeUseinv, INVCURVIEW_CGA3);
  else if (GraphicStyle == 5) mouse.ChangeModeView(eModeUseinv, INVCURVIEW_GBM);
}

this runs in the repeatedly_execute_always:
Code: [Select]
  InventoryItem*oldai;
   
  if (player.ActiveInventory != oldai)
  {
    UpdateInvCurView();
    oldai = player.ActiveInventory;
  }

(credit: the original animated-inv-item code is done by Khris)
« Last Edit: 14 Nov 2019, 23:09 by arj0n »

Re: Illegal exception during animated inv item cursor
« Reply #1 on: 14 Nov 2019, 16:08 »
Can you try changing the line
Code: Adventure Game Studio
  1. // if (inv_cur[i] != null) inv_cur[i].Delete();

to

Code: Adventure Game Studio
  1.  if (inv_cur[i] != null) {
  2.     inv_cur[i].Delete();
  3.     inv_cur[i] = null;
  4.   }

Also can you try using the latest acwin.exe to run this game?

Edit: also how big is your code, can you make a small version of your game that reproduces this issue and share it?
« Last Edit: 14 Nov 2019, 16:43 by eri0o »

arj0n

  • Mittens Vassal
  • art consists in drawing a line somewhere
    • arj0n worked on one or more games that won an AGS Award!
    •  
    • arj0n worked on one or more games that was nominated for an AGS Award!
Re: Illegal exception during animated inv item cursor
« Reply #2 on: 14 Nov 2019, 21:12 »
Can you try changing the line to...
That gave the same illegal exception... 

Also can you try using the latest acwin.exe to run this game?
Yeey, using the acwin from the latest AGS version (AGS 3.5.0 - RC 3 Current release number: 3.5.0.19) seem to have solved this issue  :)

Thanx for the help, eri0o!

Hey Arj0n, this is awesome! If you switch to using the newest AGS, just a reminder you can use the compatibility switches if you need an older API. Of course, if you are using newer APIs, than there are cool new functionality to explore.

Also, were you loading a save before the crashes happened?

arj0n

  • Mittens Vassal
  • art consists in drawing a line somewhere
    • arj0n worked on one or more games that won an AGS Award!
    •  
    • arj0n worked on one or more games that was nominated for an AGS Award!
Yes, just switched to the RC3 version, now I need to go through the 'what's new' list  :)
As for your question: nope, the game had no savegame loaded before the crash.