Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (VoroneTZ, monk12, Quad), 829 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Load/Save system #456450
11/23/15 14:09
11/23/15 14:09
Joined: Oct 2008
Posts: 341
R
ratz Offline OP
Senior Member
ratz  Offline OP
Senior Member
R

Joined: Oct 2008
Posts: 341
You want Save and Load your GameState ?

Code:
function load_me()
{
 game_load("test.sav",0);  
}

function save_me()
{
 game_save("test.sav",0,SV_ALL-SV_INFO-SV_STRINGS-SV_BMAPS-SV_PANELS);
}



i hope this helps

Re: Load/Save system [Re: ratz] #456454
11/23/15 16:29
11/23/15 16:29

M
Malice
Unregistered
Malice
Unregistered
M



@ratz that's not a function, it's just a single manual command. It doesn't add functionality at all.

Is this meant as a joke or a mock , perhaps?

Mal

Re: Load/Save system [Re: ] #456468
11/24/15 07:43
11/24/15 07:43
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
A much better contribution would be a manual save/load system. I made one for my game, but its not suitable for a contribution, because it is messy and defined for my game only...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Load/Save system [Re: EpsiloN] #456469
11/24/15 08:25
11/24/15 08:25
Joined: Apr 2015
Posts: 20
Vietnam
F
Florastamine Offline
Newbie
Florastamine  Offline
Newbie
F

Joined: Apr 2015
Posts: 20
Vietnam
To be honest, I wouldn't rely on the built-in game_save() and game_load(). I remembered some time ago when I was still working with A7 when I made a fairly large game with lots of structs and variables, but had to scrap that game simply because game_load() just crashes the whole engine whenever loading a saved game (the saving/loading stuff was vital - the game was actually a world editor), and I couldn't implement custom saving/loading routines, because of deadline, and because it's a tedious task. So for my current game I wrote a custom module for that, where variables (player pos, ang, weapon id, bullets, game state,... everything) are grouped into structs and instanced as singletons, and whenever I need to save the game, just serialize everything from the singleton to an archive struct, and from the archive struct to the disk, and apply a simple encryption layer over it. Everything else (levels, skycubes...) are easy, just level_load() and ent_createlayer(). And when loading is needed, the save games' data are de-serialized back from disk to the archive, and from the archive I simply fetch the data I want and pass it back to the singleton.

Last edited by Florastamine; 11/24/15 08:27.
Re: Load/Save system [Re: Florastamine] #456472
11/24/15 10:14
11/24/15 10:14
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Well, its getting off-topic, but here's how my save/load system worked:
Every object in the game had a type (not an ID!, a type) and based on that type the game knew what it does and how...

With that information, I run through all the existing objects and write to a file in the form "model name, object type, position, orientation, 5 general purpose parameters(which depend on the object type)"

When I want to load, I run a function that reads in term the model, type, pos, etc. and ent_creates it and sets the parameters...

Guess what? laugh Level with 200 objects becomes kbytes... I think it was around 15kb.
Loads fast enough, saves fast enough and it can be modified by hand in Notepad, because it looks good (its not encoded or anything).

Downside - its specific to my game's level system and not very backwards-compatable. If I modify a future version, ex. add a parameter, the old versions wont work with it.
But even if I add a new object in the game, it will work for any model and type... If the type is not found, a static general object is assumed...

I needed a lot of time to develop this system, but simply because I was young and inexperienced. If I had to do it now, I'd make it more generalized, using function pointers and other things, to make it reusable. Also, save/load the number of parameters and achieve backwards compatibility...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: Load/Save system [Re: EpsiloN] #456483
11/24/15 13:36
11/24/15 13:36
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
EpsiloN described exactly how I solved save/load in MapBuilder laugh
simple but works. I kept a small amount of parameters as reserves for future additions that worked in most cases, other times it is good to add a version ID then you can make branches... by the way, in my editor I preferred text files to easily debug them, but for a game a binary stuff is probably better/safer/faster...


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: Load/Save system [Re: sivan] #456484
11/24/15 14:05
11/24/15 14:05
Joined: Apr 2015
Posts: 20
Vietnam
F
Florastamine Offline
Newbie
Florastamine  Offline
Newbie
F

Joined: Apr 2015
Posts: 20
Vietnam
Originally Posted By: sivan
by the way, in my editor I preferred text files to easily debug them, but for a game a binary stuff is probably better/safer/faster...


Actually in my game I defined a macro switch (ENABLE_ENCRYPTION) that is turned on in published builds, so files can be written out encrypted. In development builds, this macro is commented out so nothing gets encrypted (for easier viewing/modifying).

Re: Load/Save system [Re: sivan] #456485
11/24/15 14:30
11/24/15 14:30
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
I meant I don't use encryption, because I intended maximum mod-ability. If you want custom models for all objects, just create a mdl file and edit the level in Notepad... laugh

But, if I wasn't aiming for this, I would have definitely used some encryption or something to obscure the original definitions... Hackers are everywhere grin

Originally Posted By: sivan
I kept a small amount of parameters as reserves for future additions that worked in most cases, other times it is good to add a version ID then you can make branches...

And I thought about all this after I finished the whole game grin
My best solution so far is to add a definition at the start of the file that tells how long an object definition is (how many parameters except the defaults(model,pos,angle)) and if you want to save space, you could add this "parameters" definition for each object separately, so that you can minimize the parameters for objects that don't have that many...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | 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