(solved) Illegal exception during animated inv item cursor

Started by arj0n, Thu 14/11/2019 15:19:50

Previous topic - Next topic

arj0n

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: ags

#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: ags

  InventoryItem*oldai;
   
  if (player.ActiveInventory != oldai) 
  {
    UpdateInvCurView();
    oldai = player.ActiveInventory;
  }


(credit: the original animated-inv-item code is done by Khris)

eri0o

Can you try changing the line
Code: ags
// if (inv_cur[i] != null) inv_cur[i].Delete();


to

Code: ags
 if (inv_cur[i] != null) {
    inv_cur[i].Delete();
    inv_cur[i] = null;
  }


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?

arj0n

Quote from: eri0o on Thu 14/11/2019 16:08:31
Can you try changing the line to...
That gave the same illegal exception... 

Quote from: eri0o on Thu 14/11/2019 16:08:31
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!

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

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.

SMF spam blocked by CleanTalk