Author Topic: Found very old error related to dynamic arrays of DynamicSprite or Overlay  (Read 690 times)

In the past years I've seen a number of reports about crashes related to dynamic sprites that acted as if they suddenly dissapeared.
Not 100% sure if this is the same one, but recently I've found an error in AGS that can with certain chance lead to DynamicSprite or Overlay getting destroyed after loading a savegame.

The technical details are explained here:
but I warn that these won't be very useful to most people.

In more general terms, the error has a chance to occur if -
1. You have a dynamic array of DynamicSprites or Overlays, in other words something like this:
Code: Adventure Game Studio
  1. DynamicSprite *LotsOfSprites[];
  3. function game_start()
  4. {
  5.     LotsOfSprites = new DynamicSprite[100];
  6.     LotsOfSprites[0] = DynamicSprite.Create();
  7.     <... and so on ...>
  8. }

2. You save the game while it has this array and sprites created.
3. You restore that game during same game session.
4. If the slot numbers of dynamic sprites you had in your game just before loading the save match any slot numbers of dynamic sprites restored from the save, then there is a pretty high chance that these sprites will get deleted and your game crashes when trying to draw these sprites or do anything else with them.

I say "chance" because in practice there is a bit of random involved here. The larger is the array the higher the chance is.

This bug exists at least since AGS 3.2.1, did not see reason to test earlier versions.

I think we know actual reasons now, so hopefully next version will have a fix. But keep this in mind if you continue to work with older versions.
« Last Edit: 04 Sep 2018, 14:55 by Crimson Wizard »

Monsieur OUXX

  • Mittens Half Initiate
    • I can help with proof reading
    • I can help with translating
    • I can help with voice acting
    • Monsieur OUXX worked on one or more games that won an AGS Award!
    • Monsieur OUXX worked on one or more games that was nominated for an AGS Award!
Legacy bugs bad.
Stability good.

thanks CW!