• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Senith89

SQL save game

3 posts in this topic

Hi all,

 

I am currently using a sqlite database file that I load up, access and modify during the process of the game running, which I realize is just not going to work for me overall. I've currently got to the point where I'm doing modifications to the database that's just not going to allow me to refresh this for a new-game, or really support the idea of being able to change the in-game database for updates etc, whilst still allowing the saved games to not be destoryed. wacko.png

 

The idea I've thought of to get around this issue is to still load the database up from a file, but instead to copy the contents of this (or attach? I'm not sure) into an "in-memory" database which the game will use during execution. Then, when I need to save the game, I was thinking of doing a comparion between the in-memory database and the stored one on-disk, fashioning a shiny new "saved game" database which just stores the changes between the two. In this way, upon loading up a saved game, it would load up the "template" database from the disk as normal (into the "in-memory" database) and then basically "patch-in" the changes from the saved game into this too.

 

My question though, is what would be the easiest/best way to actually detect the differences between two databases like this so that I am able to create a save-file with only the changes? (and be able to load it again in the same way).

 

Just to note: I'm not the world's greatest expert with SQL, so please be patient in explaining anything etc. Also, I'm completely willing to any suggestions if you think I've gone crazy and this just isn't possible or a good idea to begin with!

 

Thanks in advance for any support on this! smile.png

Edited by Senith89
0

Share this post


Link to post
Share on other sites
My recommendation is to do what is the easiest. That save file comparison seems complicated and would likely be buggy. Is there any reason you are using SQL?

What has worked really well for me in doing save files is JSON. It will let you expand your save files between updates with no problem and you can simply use a separate file per save game. When saving the game you simply rebuild the entire file from the game state rather then trying to determine what is different. Doing a complete rebuild may sound inefficient but it should be fast enough for any reasonably sized game.

There are libraries for JSON in almost any language.

If you are set on SQL, or it is too entrenched in your project for you to want to scrape it out then I would recommend adding a column in each table. The column would be an integer specifying the save file id. Then you could read and modify the tables with that added parameter to only effect the save file of interest. And you in memory database is a good suggestion.

Another thing you could do is have a database checker that runs when you game starts. What you would do there is have the checker determine what format the tables are in. If they are outdated then have it convert the database format. That way once your game has be started it can assume the database is in the correct format.
0

Share this post


Link to post
Share on other sites

I understand where you are going with your question, but I think its a bit over-done. Unless your are developing a Civilization like strategy game or a game with thousands of automatic entities, its just not going to be efficient. In general, save games should only be called when loading or saving games. Once the data from the save game file is copied to the "standard" game memory, the save game file is closed. During saving, if you want to overwrite an existing save game, you simply clear the contents of the save game file and copy all the data from memory to the file.

 

What I just described above is essentially what you described and has been used to years. In your design though you talk about using a template database and "patch" database. Its a good concept, but having to load two files and copy data twice is going to take much long compared to a single file.

 

I recommend you re-think your save game concept. Your idea isn't bad, its just that SQL is designed for large datasets, not small game saves. Possible replacements that are easily integratable are JSON (as mentioned by HappyCoder) and XML. My prefered method is using XML but compressing and encoding it with a passphrase in binary. With my current system, I'm able to load 1000 separate game entities (equal to approx 500KB) into a structure in memory in about 10-15 seconds or so.

Edited by Josh Vega
0

Share this post


Link to post
Share on other sites

SQL is the wrong tool for savegame data. You want a state dump, not a relational database. Don't try to shoehorn state data into a relational model, it's pointless.

 

Just write a gamestate serialization system like everyone else ;-)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0