problem with audio variable on restored game

Started by elentgirl, Fri 01/02/2013 15:46:12

Previous topic - Next topic

elentgirl

I have browsed the last few pages of this forum but can see no posts relating directly to my problem, though I notice there seem to be one or two issues with the handling of sound in AGS.  I am using AGS 3.2.1.  I have some ambient sounds linked to a particular location in a room (eg a river) where the volume increases or decreases as the player moves.  To achieve this I have set up a global audio variable: soundfx.

I set up the sound with the command: soundfx=aSFXwater.Play(); soundfx.SetRoomLocation(312, 50); and stop it when the player goes to another room with: soundfx.Stop();

This works perfectly when I play the game and does just what I want it to do.  However, if I save the game when one of these sound effects is playing, when I restore the game, the sound has often lost its location and plays at maximum volume wherever the player moves.  Even worse, sometimes it will not stop playing when the player goes to another room.  This does not always happen, but happens often enough to be very annoying.

Can anyone offer any helpful suggestions about how to avoid this happening?

Yeppoh

This is a bug that is deep inside the engine code. When you save, it doesn't store the location variables of the audio. I've corrected that bug in my personal beta build of the engine.

In the folder of the AGS Editor make a back-up copy of 'acwin.exe' and replace it with this one. There are other tweaks I coded, therefore tell me if if works fine for you.

elentgirl

Thank you for you attempt to solve my problem.  I downloaded your alternative acwin.exe and tried it.  The game compiled OK, but when I tried to run it I kept getting an error message:

Script link failed: Runtime error: unresolved import 'Character::ChangeRoom^3'

I'm afraid it's beyond my knowledge to translate what that means, so I've no idea how I can correct it.  I replced your acwin.exe with the original and the game runs again.

Can you offer any assistance?

Yeppoh

#3
You have to rebuild all files in the 'Build' menu. Doing so it recompiles all your room scripts and the game should run properly with the new 'acwin.exe'.

Crimson Wizard

Quote from: Nefasto on Mon 04/02/2013 11:35:25
You have to rebuild all files in the 'Build' menu. Doing so it recompiles all your room scripts and the game should run properly with the new 'acwin.exe'.
If you changed any script functions in your engine, these declarations should be fixed in the editor too. In other words, elentgirl would need your version of editor as well.

Yeppoh

#5
Ah! Good point. I totally forgot about that.

elentgirl has to download this one and dezip it to another folder.

elentgirl

I downloaded the suggested editor and managed to get it to run my game.  Unfortunately it did not solve the problems with the sound, particularly the failure of the 'soundfx.Stop();' command to turn off unwanted sound effects in restored games.  It has now given me another problem.  When I tested the save and restore in the new editor, the thumbnail screen shots were all distorted in odd colours.  I therefore decided to return to the old version of the editor for the time being.  I now find, however, that it will not save a screenshot but just presents a black rectangle.  How can I get my screen shots back?

Crimson Wizard

#7
Quote from: elentgirl on Mon 04/02/2013 22:12:15When I tested the save and restore in the new editor, the thumbnail screen shots were all distorted in odd colours.  I therefore decided to return to the old version of the editor for the time being.  I now find, however, that it will not save a screenshot but just presents a black rectangle.  How can I get my screen shots back?
Have you changed to old Editor and old acwin.exe? They must match.
I understand that Nefasto has changed something in savegame format? That could spoil screenshots (and other things) if done incorrectly. Did not try his version myself, so only speculating. But, anyway, if the save format was changed, this means you can't use savegames made with Nefasto's version with original AGS, and vice-versa.

Yeppoh

#8
Quote from: Crimson Wizard on Tue 05/02/2013 07:48:51
I understand that Nefasto has changed something in savegame format? That could spoil screenshots (and other things) if done incorrectly. Did not try his version myself, so only speculating. But, anyway, if the save format was changed, this means you can't use savegames made with Nefasto's version with original AGS, and vice-versa.

As far as I could understand the saving system which saves the variables in a binary array, I only added the variables involving the audio locations and radius, which then are retrieved by the restore function. Unless I read it wrong, the data of the screenshot is appended after the binary of the save file. I have no recollection of touching that part.
I'm also using the Draconian code as base which had the screengrab rewritten in DirectX 9 - DirectDraw stayed the same. So right now, for the black screenshot, I can't say if it comes from the save files or the way how the screenshot is saved from the backbuffer.
Does it return a black screenshot in DirectDraw too?

Also as Crimson said, the old save files don't work anymore with this build hence the strange thumbnail screen, which is normal.

QuoteUnfortunately it did not solve the problems with the sound, particularly the failure of the 'soundfx.Stop();' command to turn off unwanted sound effects in restored games.

I don't think I quite understand. Do you mean the 'Stop()' function doesn't work anymore? Did you make a check that the 'soundfx' pointer isn't NULL?
The actual build only fix the location variable of a playing audio for not being saved.

Crimson Wizard

Quote from: Nefasto on Tue 05/02/2013 16:28:49Unless I read it wrong, the data of the screenshot is appended after the binary of the save file.
No, its at the file's beginning, before actual game data. But, probably that does not matter in this case.

elentgirl

I think the black screenshot thumbnails was a temporary glitch.  When I rebooted my computer, the save screenshot fucntion worked again OK.

The sound variable problem is more persistent.  I'll explain exactly what happens.  I have initiated an audio channel global variable called 'soundfx'.  I have a room with a river in it and I allocate the sound to 'soundfx', and then set a location.  As this is a repeating loop I stop it when the character moves to another room with the 'soundfx.Stop()' command.  This all works just as it should when I play the game for the first time.

The trouble starts if I save and restore the game.  If I save the game when the river sound is playing and then restore the saved game, the river sound plays but has lost its location and plays at full volume the whole time.  When I move the character to another room the sound continues playing and ignores the 'Stop()' command.  It seems as if the sound is played on another channel and not that stored in the variable 'soundfx'.  I have checked that the variable is not null when the game is restored.

Yeppoh

Unfortunately I can't manage to reproduce the bug on my machines. I also used a global sound channel pointer. Assuming the modified build and editor are both used the sound channel location, radius and volume return correctly once the game is restored.

Is there an on_event with a 'eEventRestoreGame' somewhere?

MurrayL


selmiak

You can't fool me MurrayL, I see that you posted there! :shocked:

Crimson Wizard

Quote from: Nefasto on Mon 11/02/2013 14:44:30
Is there an on_event with a 'eEventRestoreGame' somewhere?

Yes. You can catch it 'on_event' script function:
http://www.adventuregamestudio.co.uk/wiki/Predefined_global_script_functions#on_event
Quote
eEventRestoreGame
      tells your game that it has just been restored from a save game
      DATA = save slot number

Khris

I'm pretty sure Nefasto is asking elentgirl if she uses this, not if AGS has it.


Yeppoh

Quote from: MurrayL on Tue 12/02/2013 00:40:38
Edit: Ignore me. This post isn't here.
The GhostPoster.

Quote from: Khris on Tue 12/02/2013 15:21:08
I'm pretty sure Nefasto is asking elentgirl if she uses this, not if AGS has it.
My mistake too. I should've pointed the question to elentgirl.

elentgirl

Hello again

I have not knowingly used any on_event handling in my game.  I have reverted to the original AGS program as the modified one did not solve the problem for me and caused some other problems with saving screenshots.  I have found a way to bypass the problem by stopping the sound effect in the function that calls the save game command. This also sets a global variable that the game looks for and re-starts the sound effect when it finds it.  It works OK.

Thank you all for your suggestions.

SMF spam blocked by CleanTalk