Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: xil on Mon 23/03/2015 18:24:53

Title: Audio Channel Issues - NullPointerReferenced - Emulating in Wine
Post by: xil on Mon 23/03/2015 18:24:53
Hi guys,

I've got this piece of code in room1.asc:

Code (ags) Select

function room_Load(){
  interface_toggle(false);
  achM = aM1.Play();
}


It's then followed up in room14.asc with this:

Code (ags) Select

function room_Load(){
  interface_toggle(false);
  achM.Stop();
}


A user emulating in Wine is saying they get the following error:

Quoteroom14.asc, line 3
NullPointerReferenced.

So in summary, I've got a global value 'achM' set to an audio channel and I play some music in it in the first room, then for the outro I stop the music. I have no issues with this on a PC so does anyone have any ideas as to why it doesn't work in Wine or how I can possibly stop it from crashing?
Title: Re: Audio Channel Issues - NullPointerReferenced - Emulating in Wine
Post by: Gurok on Mon 23/03/2015 23:19:50
Not sure from your description whether the music plays for the person emulating in Wine. But anyway, I don't think you're guaranteed to get a non-null pointer from aM1.Play(). Check for a null pointer before you stop the music:

if(achM != null)
    achM.Stop();


That would be the easiest way to stop it from crashing.
Title: Re: Audio Channel Issues - NullPointerReferenced - Emulating in Wine
Post by: xil on Mon 23/03/2015 23:23:40
Thanks Gurok, seems logical, I'll patch that in now!