Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#13246 closed defect (fixed)

AGS - Mage's Initiation - crashes while entering the Palace on Lone Island

Reported by: menschel Owned by: criezy
Priority: normal Component: Engine: AGS
Version: Keywords: mage-fallback
Cc: menschel Game:



I'd like to place a bug report for Mage's Initiation - Reign of the Elements, GOG Version "".

I experience a crash of ScummVM V2.5.1 on Ubuntu 18.4.6 LTS when entering the Palace on Lone Island. The console output is:

User picked target 'mage-fallback' (engine ID 'ags', game ID 'mage')...

Looking for a plugin supporting this target... Adventure Game Studio

WARNING: TODO: SetCurrentDirectory: /opt/GOG/Mages_Initiation_Reign_of_the_Elements/game!
Initializing backend libs
Initializing game data
Opened game data file: game28.dta
Game data version: 49
Compiled with:
Startup directory: ./
Data directory: ./
Setting up game configuration
Logging to ags.log
Voice pack found and initialized.
audio.vox found and initialized.
Initializing TTF renderer
Initializing mouse: number of buttons reported is 3
Install timer
Initialize legacy path finder library
Game title: 'Mage's Initiation'
Game GUI version: 118
Requested script API: v3.4.1 (5), compat level: v3.2.1 (0)
Plugin 'agsgalaxy' loaded as 'agsgalaxy.dll', resolving imports...
Checking for disk space
Game native resolution: 640 x 400 (32 bit)
Graphic settings: driver: OGL, windowed: yes, screen def: scaling, screen size: 0 x 0, match device ratio: ignore, game scale: max_round
Requested graphics driver 'OGL' not found, will try existing drivers instead
WARNING: movement control not supported, mouse control can't be enabled!
Mouse speed control: disabled, unit: 1.000000, user value: 1.000000
Setting up window
WARNING: File::open: '/opt/GOG/Mages_Initiation_Reign_of_the_Elements/game/preload.pcx' does not exist!
Initialize sprites
Engine initialization complete
Starting game
WARNING: Audio stream did not support seeking!
WARNING: TODO: SoundClipWaveBase::set_speed!
WARNING: Audio stream did not support seeking!
WARNING: TODO: SoundClipWaveBase::set_speed!
WARNING: Audio stream did not support seeking!
WARNING: Audio stream did not support seeking!
scummvm: engines/ags/lib/allegro/color.cpp:526: void AGS3::hsv_to_rgb(float, float, float, int*, int*, int*): Assertion `v >= 0 && v <= 1' failed.

What is my job in this ticket?

Attachments (2)

mage-fallback_pre_crash.tar.xz (972.8 KB ) - added by menschel 2 years ago.
agssave.005.tar.xz (832.4 KB ) - added by criezy 2 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by criezy, 2 years ago

Do you have a savegame before the crash happens that you could attach to this ticket? This would help us investigate the bug.

by menschel, 2 years ago

comment:2 by menschel, 2 years ago

Attached a savegame, just enter the castle...

Anything else I can be of assistance?
If you paste a patch or anything I can compile and retrieve debug info if necessary.

comment:3 by criezy, 2 years ago

Thank you.
The good news is that I can reproduce the crash with my development version of ScummVM. So I should be able to investigate this without further inputs.

I took a very quick look and the issue is that we have a spurious light_amount value or -26335 when calling Bitmap::LitBlendBlt to light the character sprite. The issue seems to be when computing the light_level and tint_light in get_local_tint() called from prepare_characters_for_drawing().

I (or another developer) will need to spend more time debugging this and comparing with what happens in the original. I may not have time to do this before this weekend, so don't worry if you don't get update in the next few days.

comment:4 by menschel, 2 years ago

Thank you very much for your effort.

I don't know if it will help, but the original GOG release does not run, due to the fact that they packed it with an old and incompatible version of AGS.

There is a detailed post in forum about it.

by criezy, 2 years ago

Attachment: agssave.005.tar.xz added

comment:5 by criezy, 2 years ago

I have played through the start of the game with the standalone AGS interpreter (current master - d0cb8667) and confirmed that with that one there is no crash. I have attached a save on Lone Island before entering the palace. Now what remains to be done is compare in the debugger the difference between ScummVM and the standalone ags to try to understand what is incorrect in ScummVM. I will try to get to that in the next few days.

comment:6 by criezy, 2 years ago

I have now checked how it behaves in the debugger with the standalone AGS executable. And I found that:

  • It has the same issue with a light level of -26335 in the data.
  • But by default it uses an accelerated driver (OGL in my case on macOS, and probably D3D9 on Windows). And that driver has a sanity check on the light level in OGLGraphicsDriver::_renderSprite to not do light if the light level is negative.
  • If we force the use of the Software driver then it crashes in the same way as ScummVM.

So this looks like a bug in the game data file that is not noticeable with the original executable due to it being ignored with the default driver used (and nobody tried using the software renderer since it has little benefit over the accelerated ones).

I think the way to go will be to add a sanity check in the software rendering path to ignore negative light levels.

comment:7 by criezy, 2 years ago

Owner: set to criezy
Resolution: fixed
Status: newclosed

A fix has now been applied, so the next daily builds should no longer crash.
The software rendering code now does the same as the OGL driver and uses a luminance of 1.0 if the luminance is negative when tinting a sprite.

comment:8 by menschel, 2 years ago

Thanks for fixing.

comment:9 by menschel, 2 years ago

I confirm that it is fixed. I built from git.
Thanks again.

Note: See TracTickets for help on using tickets.