Thread: Saving the game - help plz!

  1. #16
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    Just create a game_state struct and write it to disk when the save is done. Most of your game state variables should be grouped together anyways so writing them to disk is as simple as using block writes to disk. The encryption comes from the fact that you open the file in binary mode so you won't be able to read what the value of a float is or certain values are in a text reader. You will be able to open the file in C but I see no harm in that.

  2. #17
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You might also want to have a checksum in there some place, if you're really worried about someone editing it. Just sum up all the values of everything you write, and write that out along with it. It can be more complex than that, but that's a simple way. Then when you read everything in, sum them up again and compare it with said checksum. If they're different, someone's edited something. It's a very simple method, not really good, but simple enough.

    You're not really going to stop anyone who really really wants to edit your save files.

    Quzah.
    Hope is the first step on the road to disappointment.

  3. #18
    Registered User
    Join Date
    Jan 2005
    Location
    Copenhagen, Denmark.
    Posts
    16
    Hmm...I've just encountered another problem...how do I delete the old save/load txt file, so I can overwrite?

  4. #19
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Just opening for writing will delete any contents of any existing file.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #20
    Registered User
    Join Date
    Jan 2005
    Location
    Copenhagen, Denmark.
    Posts
    16
    oh nice - thx

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. PC Game project requires c++ programmers
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 02-22-2006, 12:23 AM
  2. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-26-2006, 12:14 AM
  3. Game Programmer's AIM Circle: Join Today
    By KingZoolerius66 in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 12-20-2003, 12:12 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM
  5. I got everything worked out now. Try my game plz
    By frenchfry164 in forum C++ Programming
    Replies: 4
    Last Post: 03-31-2002, 04:05 PM