Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: EnterTheStory (aka tolworthy) on Wed 23/06/2010 22:18:44

Title: Crossfade: buffer is null attempting transition
Post by: EnterTheStory (aka tolworthy) on Wed 23/06/2010 22:18:44
I often get this crash when loading a saved game:
Crossfade: buffer is null attempting transition

This was mentioned a couple of years ago (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=33624.msg437958#msg437958) but I can't find any reference to a solution. I use eTransitionCrossfade as the default screen fade, so I imagine that is the problem?

I've tried calling 'SetNextScreenTransition(eTransitionInstant)' before saving a game but it makes no difference. Any ideas what I should do?
Title: Re: Crossfade: buffer is null attempting transition
Post by: barefoot on Thu 24/06/2010 00:33:44
Do you use the SetNextScreenTransition(eTransitionInstant); just before you put changeroom?

eg

SetNextScreenTransition(eTransitionInstant);
cEgo.ChangeRoom(3);


Including all the code you put would help.

Maybe you have put something in Before Room Loads rather than After Fade in and thats causing the problem...?

barefoot
Title: Re: Crossfade: buffer is null attempting transition
Post by: EnterTheStory (aka tolworthy) on Thu 24/06/2010 08:15:00
Edit: that's a good idea. But rather than spending more time bug tracking I replaced the built in fade code with custom fade code (that I wrote for the other games) and it all works perfectly now.
Title: Re: Crossfade: buffer is null attempting transition
Post by: Pumaman on Fri 25/06/2010 14:01:57
I was never able to reproduce this problem. Do you have a way of reliably reproducing the crash?
Title: Re: Crossfade: buffer is null attempting transition
Post by: EnterTheStory (aka tolworthy) on Fri 25/06/2010 18:40:22
Quote from: Pumaman on Fri 25/06/2010 14:01:57
I was never able to reproduce this problem. Do you have a way of reliably reproducing the crash?

I can upload the previous build of my game if you like - but it would be several hundred MB. In the latest build I don't use crossfade, so it's not really urgent for me any more. But if it would help anyone else I'd happily upload everything, code and all.
Title: Re: Crossfade: buffer is null attempting transition
Post by: Pumaman on Mon 12/07/2010 21:05:49
Don't worry about it, if it's that big. I'll try to find another way of reproducing it.
Title: Re: Crossfade: buffer is null attempting transition
Post by: bbalint85 on Fri 11/02/2011 10:13:45
I think I isolated the problem. I'm drawing multiple dynamic sprites on the background, implementing a dirty footprint. So at any point the background is covered with some dynamic sprite-graphics. As I save in this state, then restart the game and loading, I get the Crossfade: buffer is null attempting transition error, altough I'm using Instant transitions.

The core of the code is the following:

function repeatedly_execute_always()
{
    int loop = character[0].Loop;
    ViewFrame *vf = Game.GetViewFrame(VFOOTPRINT, loop, character[0].Frame);
    DynamicSprite* dsf  = DynamicSprite.CreateFromExistingSprite(vf.Graphic, true);

    int w = (character[0].Scaling*dsf.Width)/100;
    int h = (character[0].Scaling*dsf.Height)/100;
   
    DrawingSurface *bgSurf = Room.GetDrawingSurfaceForBackground();
    bgSurf.DrawImage(character[0].x - w/2, (character[0].y - character[0].z), dsf.Graphic, Ego.Transparency, w, h);
    dsf.Delete();
    bgSurf.Release();
}


I also tried using a global variable dynamic sprite, but the result was the same. I think the restoring problem is with the dynamic sprites, the background can't be restored without the sprites in the memory.

Any suggestions keeping the background or at least avoiding errors at loading?
Title: Re: Crossfade: buffer is null attempting transition
Post by: Pumaman on Sun 13/02/2011 18:06:39
Interesting, thanks for the detail. I'll investigate it further.
Title: Re: Crossfade: buffer is null attempting transition
Post by: bbalint85 on Tue 15/02/2011 09:41:40
I tried to reproduce it in a blank game, and had the following conclusion: the problem only occurs on the following:
-the default transition must be set to something other then crossfade (instant for example)
-the transition should be set during the game (SetNextScreenTransition or SetScreenTransition)
-dynamic sprites on the background should be involved.
-saving/loading

The most basic code I can think of producing the error message:

function oTest_AnyClick()
{
SetScreenTransition(eTransitionCrossfade);
}
function room_AfterFadeIn()
{
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.Clear(14);
surface.DrawingColor = 13;
surface.DrawCircle(160,100,50);
surface.Release();
}


after clicking on the test object, saving, restarting the game and loading the error occurs.

After I realized this, I changed all the crossfades, and there are good workarounds, but I think it's good to know this anyway...
Title: Re: Crossfade: buffer is null attempting transition
Post by: Pumaman on Sun 20/02/2011 19:51:20
Thanks for the info!

I've found the problem -- it happens if the current screen transition is Normal/Instant, and you try to restore a save game that was saved when the transition was Crossfade/Dissolve.

In this situation it does a Normal/Instant fade-out, and tries to Crossfade/Dissolve for the fade-in, which gets confused and crashes.

I'll get it fixed.
Title: Re: Crossfade: buffer is null attempting transition
Post by: Iliya on Mon 09/01/2012 11:46:55
Yesterday this bug appears in my game. I upgraded AGS to 3.2.1. Problem is solved now.