Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 16,707 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
problems when loading a save game #394134
02/10/12 13:47
02/10/12 13:47
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Hi all,

Before reading futher, I managed to fix most of the errors, only the gamesave images/screenshots/bmaps still get messed up.

For my game Quake Planes (on this site), I have some save/load bugs.

When I save and I load the save before I have loaded a new map or restarted the game, I have no problems.

However, when I load the savegame after a level load (with this I mean e.g. loading a savegame from map 2 when I am playing map 1) or when I save, quit the game, start the game again and load the savegame I get either a gamecrash or (and now it gets really strange) enemies will still detect me but not attack and move towards me. Instead they will move to the player starting point and keep looking down and run around (I you have spare time you should try it, it is hilarious :D).
And finally the image of the savegame (a screenshot to show where the save was made) is screwed (weird vertical stripes through the image).

Anyone?

Here is the save and load script:

Code:
// Displays the save panel
function Save_show()
{
	// No slot is selected by default
	SELECTED_SLOT = 0;
	
	// Freeze the game
	freeze_mode = 1;
		
	// Display it
	set(mainmenu_save_pan,SHOW);
	
	// Close other menu panels
reset(mainmenu_load_pan,SHOW);
reset(mainmenu_quit_pan,SHOW);
reset(mainmenu_options_pan,SHOW);
reset(mainmenu_options_txt1,SHOW);
reset(mainmenu_options_txt2,SHOW);
reset(mainmenu_options_txt3,SHOW);
reset(mainmenu_options_txt4,SHOW);
reset(mainmenu_options_txt5,SHOW);
reset(mainmenu_options_digit1,SHOW);
reset(mainmenu_options_digit2,SHOW);
reset(mainmenu_options_digit3,SHOW);
reset(mainmenu_options_digit4,SHOW);
reset(mainmenu_credits_pan,SHOW);
reset(mainmenu_credits_txt,SHOW);
reset(mainmenu_newgame_pan,SHOW);
reset(mainmenu_pan,SHOW);
}

// Displays the load panel
function Load_show()
{
	// No slot is selected by default
	SELECTED_SLOT = 0;
	
	// Freeze the game
	freeze_mode = 1;
		
	// Display it
	set(mainmenu_load_pan,SHOW);
	
	// Close other menu panels
reset(mainmenu_save_pan,SHOW);
reset(mainmenu_quit_pan,SHOW);
reset(mainmenu_options_pan,SHOW);
reset(mainmenu_options_txt1,SHOW);
reset(mainmenu_options_txt2,SHOW);
reset(mainmenu_options_txt3,SHOW);
reset(mainmenu_options_txt4,SHOW);
reset(mainmenu_options_txt5,SHOW);
reset(mainmenu_options_digit1,SHOW);
reset(mainmenu_options_digit2,SHOW);
reset(mainmenu_options_digit3,SHOW);
reset(mainmenu_options_digit4,SHOW);
reset(mainmenu_credits_pan,SHOW);
reset(mainmenu_credits_txt,SHOW);
reset(mainmenu_newgame_pan,SHOW);
reset(mainmenu_pan,SHOW);
}

// Select a save/load slot
function SELECT_SLOT(but,pan)
{
	// There are 2 other buttons defined first
	but -= 2;
	
	// Select slot
	SELECTED_SLOT = but;
}
/////////////////////////////////////////////////////
// Puts the save/load slot bmap handles into an array
// Also loads the bmaps already at the slots
function init_slots()
{
	// Set bmap handles
	SAVESLOT_BMAPS[0] = handle(saveloadslot_1);
	SAVESLOT_BMAPS[1] = handle(saveloadslot_2);
	SAVESLOT_BMAPS[2] = handle(saveloadslot_3);
	SAVESLOT_BMAPS[3] = handle(saveloadslot_4);
	SAVESLOT_BMAPS[4] = handle(saveloadslot_5);
	SAVESLOT_BMAPS[5] = handle(saveloadslot_6);
	
	// Bmaps initialized
	SAVESLOT_BMAPS_INIT = true;
	
	// Load bmaps
	game_load(savedPicturesFile,0);
}

// Saves the game
function GameSave(slot,pan)
{
	// Get the saving slot
	slot = SELECTED_SLOT - 1;
	
	// Load the handles, if not done yet
	if(!SAVESLOT_BMAPS_INIT) {init_slots();}
	
	// Hide visible panels
	reset(mainmenu_save_pan,SHOW);
	reset(saveload_selected_pan,SHOW);
	
	// Take the screenshot
	bmap_for_screen(ptr_for_handle(SAVESLOT_BMAPS[slot]),1,0);
	wait(3);
	
	// Save the screen shot, return if it fails
	if(!game_save(savedPicturesFile,0,SV_INFO + SV_BMAPS)) {return;}
	wait(1);
	
	// And now save the game
	if(game_save(saveSlot_name,slot,SV_ALL - SV_INFO))
	{
		// Play a "beep" sound, if successfull
		snd_play(beep_snd,75,10);
	}
	
	// Show main game menu
	set(mainmenu_pan,SHOW);
}
/////////////////////////////////////////////////////
// Load a game
function GameLoad(slot,pan)
{
	// Get the loading slot
	slot = SELECTED_SLOT - 1;
	
	// Load the handles, if not done yet
	if(!SAVESLOT_BMAPS_INIT) {init_slots();}
	
	// Load the game
	if(game_load(saveSlot_name,slot))
	{
		// Play a "beep" sound, if successfull
		snd_play(beep_snd,75,10);
		reset(defeat_pan,SHOW);
		reset(victory_pan,SHOW);
		media_stop(0);
		if (map == 1) media_loop("X-COM UFO Defense PSX - 02 - Geoscape2.mp3",NULL,MUSICVOLUME_i);
		if (map == 2) media_loop("X-COM UFO Defense PSX - 01 - Geoscape1.mp3",NULL,MUSICVOLUME_i);
	}
	
	wait(1);	
	// Hide the main menu
	reset(mainmenu_pan,SHOW);
	reset(defeat_pan,SHOW);	
	freeze_mode = 0;
}



and here is the loadmap script:

Code:
//////////////////////////////// Level loading  ///////////////////

function Load_Map2()
{
player.x = 100;
player.y = -100;
player.z = 130;	
camera.pan = 180;
level_load("QuakePlanesmap2.wmb");
map = 2;
snd_play(R_TELE5,SOUNDVOLUME_i,0);	
media_stop(0);
media_loop("X-COM UFO Defense PSX - 01 - Geoscape1.mp3",NULL,MUSICVOLUME_i);
sky_color.red = 0;
sky_color.green = 0;
sky_color.blue = 0;
my_sky = ent_createlayer("Skybox+6.tga", SKY | CUBE | VISIBLE, 0);
camera.clip_far  = 11500; // reduce clip_far for preventing sorting errors 	
camera.fog_start = 0.2 * camera.clip_far; // fog starts at 80% of clip range
camera.fog_end = 0.9 * camera.clip_far; // total foggy at 90% of clip range
d3d_fogcolor1.red = 10;
d3d_fogcolor1.green = 10;
d3d_fogcolor1.blue = 30; // gray fog  
fog_color = 1;
GoldKey = 0;		
}



Last edited by Reconnoiter; 02/16/12 14:37.
Re: problems when loading a save game [Re: Reconnoiter] #394780
02/16/12 14:34
02/16/12 14:34
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
I managed to solve the crash problem, I created sky layers even after the first game_save or game_load. I also think that I can fix the weird targeting bug by enemies by using ptr_for_handle (handle); to correctly save their pointers. Still I dont know why the savegame images/screenshots become so messed up...

Re: problems when loading a save game [Re: Reconnoiter] #412688
12/01/12 13:47
12/01/12 13:47
Joined: Jun 2012
Posts: 16
T
theblueassasin Offline
Newbie
theblueassasin  Offline
Newbie
T

Joined: Jun 2012
Posts: 16
Did you ever fix that screenshot problem? I have the same exact problem.

Re: problems when loading a save game [Re: theblueassasin] #412737
12/02/12 06:07
12/02/12 06:07
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
bmap_for_screen (screen_shot_map, 1, 0);
wait (1); // wait 1 frame until the bitmap can be saved
//perhaps you need only one frame?

game_save (app_name, 0, SV_INFO + SV_BMAPS);

//perhaps this is the issue ?
Unlike a pointer, a handle to an engine object
survives saving/loading
and contains the same value at every run of the application.


Compulsive compiler
Re: problems when loading a save game [Re: Wjbender] #420833
04/04/13 12:10
04/04/13 12:10
Joined: Jun 2012
Posts: 16
T
theblueassasin Offline
Newbie
theblueassasin  Offline
Newbie
T

Joined: Jun 2012
Posts: 16
I don't know if you ever solved that problem, but I had the same issue. The problem is taht bmaps are saved in a 32 bit format, and then loaded as 24bit bmaps. What I did was to use bmap_save and bmap_load instead.

Re: problems when loading a save game [Re: theblueassasin] #421185
04/12/13 17:38
04/12/13 17:38
Joined: Dec 2011
Posts: 1,823
Netherlands
Reconnoiter Offline OP
Serious User
Reconnoiter  Offline OP
Serious User

Joined: Dec 2011
Posts: 1,823
Netherlands
Never tried it anymore actually, but good to know. Thanks theblueassasin!


Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1