How should I save info?
How should I save info?
How should I save info?
How should I save info?
How should I save info?
How should I save info? How should I save info? How should I save info? How should I save info? How should I save info? How should I save info? How should I save info? How should I save info?
How should I save info? How should I save info?
How should I save info?
Go Back  Xtreme Visual Basic Talk > > > How should I save info?


Reply
 
Thread Tools Display Modes
  #1  
Old 06-26-2005, 05:29 AM
Twig Twig is offline
Newcomer
 
Join Date: Jun 2003
Posts: 14
Default How should I save info?


I need to save info like how much "gold/money" the character has, how many potions, etc. I only know of saving to a .ini and to the registry. Im guessing I shouldnt save to a ini because it can be edited, but I dont know how to save to the registry. Could someone explain this please?
Reply With Quote
  #2  
Old 06-26-2005, 05:38 AM
Gruff's Avatar
GruffHow should I save info? Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

To read/Write to the registry look up the GetSetting() and SaveSetting() commands.

~T
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #3  
Old 06-26-2005, 06:23 AM
Twig Twig is offline
Newcomer
 
Join Date: Jun 2003
Posts: 14
Default

ok cool thanks.
Reply With Quote
  #4  
Old 06-29-2005, 01:50 PM
DubbleClick's Avatar
DubbleClick DubbleClick is offline
Contributor
 
Join Date: Mar 2005
Location: Tennessee
Posts: 511
Default

That can be edited easily enough too... if the user were persistant.

If you want to protect from hacking, just encryt the string before hand... and decryt it when you read it back into the game. It doesn't have to be bullet proof encrytion, just enough to frustrate the users out of trying to break it.
Reply With Quote
  #5  
Old 06-29-2005, 01:57 PM
RoofRabbit's Avatar
RoofRabbit RoofRabbit is offline
Contributor
 
Join Date: Sep 2003
Location: Lenoir, NC - USA
Posts: 731
Default

Just save the info to a regular file, you don't need the registery to save game vars. You can find plenty of example code on how to do that from many links in this forum or even on my site.
__________________
Website http://roofrabbit.com/
Reply With Quote
  #6  
Old 07-09-2005, 09:18 PM
Chazz569 Chazz569 is offline
Junior Contributor
 
Join Date: May 2002
Posts: 366
Default

I would personaly say to write the data to a file since the windows registry isn't design to old save data. What I would suggest to prevent people from editing save game is writing the data using Binary instead of Output when writing out your file. A simple search on google.com or planet-source-code.com should find you result, try the keywoards "vb file input output" "vb file binary". By saving as binary, number aren't directly shown as "6000" but in a binary representation which gives wierd characters. To most users, this is enough to stop them from editing the file.

If you want extra protection, run a CRC32 check against the file and save the output possibly somewhere else or even in the registry. Once you load the file, check if the CRC32 matches. If it doesn't match, it mean the file has been edited. A basic CRC32 check will discourage the slightly more experience user who might have figured out how you saved the file. Unless you plan for your game to be really popular, I would leave it at saving as binary and mabey using the CRC32 check if your really concerned about editing. Only knowledge user will know how, and most of them will consider smaller game, not worth the ammount of time of working arround your prorection system (there a few ways to work arround a CRC32 check), generaly speaking of course.
Reply With Quote
  #7  
Old 07-10-2005, 02:22 AM
AdrianDeAngelis's Avatar
AdrianDeAngelis AdrianDeAngelis is offline
Contributor
 
Join Date: May 2005
Location: Australia
Posts: 549
Default

Random access files are an excellent general purpose choice, especially if you intend to save and load lots of data about items and monsters etc... as you can write to the file and read in objects as opposed to property by property...

Any attempt to edit a random access file manually through any windows text editing programs will corrupt the records making the file useless to would-be cheats and to be able to change or load the data you must have an intimate knowledge of the record and file structure else rendering the file useless to would be theives
__________________
Automation error... What do you mean automation error you %#@*&!$ thing!

Star Admiral: 3D tactical space sim *** New Version 0.38 10/01/09 ***
Damage, shields and special weapons systems
Reply With Quote
  #8  
Old 07-14-2005, 03:39 PM
EOB84 EOB84 is offline
Regular
 
Join Date: May 2003
Posts: 76
Default

My two cents, depending on the needs of the specific app you may want to use a binary file. With random access files I believe each record has to be the same size. You basically have to know how big the data is before you save to it's own record. With binary files each record can be of any size. As long as you have a efficient parsing method to allow the file to be read from. The most common misconception with these functions is that it will encrypt your data or protect it. The reality is when you write a string to the file using the random or binary method it is still readable text. Possibly the user can get a way with changing a letter or number here or there. Maybe the user can read mission text and figure out where to obtain rare items or something of that nature. You will still need to encrypt the data no matter how it is saved. My suggestion is to use XOR. Randomly generate a number and xor the data against the randomly generated number. Save the generated number inside the data of the file. Basically just reverse the steps used "encrypting" the string to decrypt it. You can be creative when you save the encryption key. So when a user tries to view the file he will see garbled non-sense and not be able to tell the key apart from the other saved data. This will not fool a experienced "cheater" but face it. If they want to crack your file they will find a way. So don't go to crazy with it. Just something simple so when the average user looks at it they won't know what to make of it.
Reply With Quote
  #9  
Old 07-15-2005, 04:11 AM
AdrianDeAngelis's Avatar
AdrianDeAngelis AdrianDeAngelis is offline
Contributor
 
Join Date: May 2005
Location: Australia
Posts: 549
Default

Quote:
With random access files I believe each record has to be the same size. You basically have to know how big the data is before you save to it's own record. With binary files each record can be of any size.
Not necessarily... for small records that are all the same you don't have to bother setting the record length for records over about 256 bytes you must set the record length... A good idea is to build in some redundancy so that you load all records of one type at, say, 500 bytes. Windows will fill in the rest of the file with random junk but that is usually OK as it usually does not affect the data stored in the file, the only problem I have ever had with that is when saving records whose length changed with every record and were stored to adjacent places in the file. The solution was simply to space the records apart a bit...

Being able to store objects in a position in a file is a big plus for random access allowing very easy access to lots of data without parsing... the big disadvantage being that editing the file requires you to make tools for editing as they cannot be edited manually.
__________________
Automation error... What do you mean automation error you %#@*&!$ thing!

Star Admiral: 3D tactical space sim *** New Version 0.38 10/01/09 ***
Damage, shields and special weapons systems
Reply With Quote
  #10  
Old 07-16-2005, 03:12 PM
EOB84 EOB84 is offline
Regular
 
Join Date: May 2003
Posts: 76
Default

I didn't mean to say each record entry had to be the same size. More that each record structure had to be the same size. You can not go over that size limit. You must basically know what your maximum size for each string must be ahead of time. Usually when storing data I like to split the files up. Not one file for all data but maybe strings in one file and integers in another. It may seem rather needless but with all data split up like this it is very frustrating to decrypt. So if you insist on the random method keep this in mind. Set the string length then just parse one string into several "string records". The data will be so chopped and incomplete that even advanced user may give up (doubt it though). Then you will have the ease of random access files.
Reply With Quote
  #11  
Old 07-16-2005, 10:14 PM
AdrianDeAngelis's Avatar
AdrianDeAngelis AdrianDeAngelis is offline
Contributor
 
Join Date: May 2005
Location: Australia
Posts: 549
Default Agreement

Actually I agree with you when it comes to chopping data up... for big objects or maps etc... I like to chop up into individual units too. Haven't tried the splitting strings across multiple files though... I usually store each string paragraph into the file (created in an editor which gives exact lines and width dimensions) and recall the paragraph and then reassemble into individual lines.

Maybe storing each line into a separate file is the way to go? perhaps even with a different record offset for each line so that if someone is reading all files concurrently the paragraphs are jumping around and the information is not immediately obvious?
__________________
Automation error... What do you mean automation error you %#@*&!$ thing!

Star Admiral: 3D tactical space sim *** New Version 0.38 10/01/09 ***
Damage, shields and special weapons systems
Reply With Quote
  #12  
Old 07-27-2005, 06:41 AM
Leade's Avatar
Leade Leade is offline
Junior Contributor
 
Join Date: Jul 2005
Location: Wherever i fall over
Posts: 222
Post File I/O Driver (Leade SDK)

I wrote a driver file which handles file reading and writing and use constantly in my game engine to make save files. however since i wrote it at the begining of the project the original code is gone so i have zipped the version i used and have attached it. it can read and write all data types and even save buffers as well.

1) unzip it into your project folder then add a reference to it in your app.
Click Projects -> References -> Browse -> Then Locate The Driver File

2) To create the object just use the following command
Dim FileIO as New Leade_SDK_IO.FileDiskBlock

3) when finishing call or the file will still be open and other apps may not be able to use it.
FileIO.CloseFile

4) then finally this will delete the object from memory
Set FileIO = Nothing

feel free to use it, all i ask is for a little credit when you game or app is completed.


Leade

Last edited by reboot; 11-30-2005 at 08:13 AM. Reason: No binaries in attachments
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How should I save info?
How should I save info?
How should I save info? How should I save info?
How should I save info?
How should I save info?
How should I save info? How should I save info? How should I save info? How should I save info? How should I save info? How should I save info? How should I save info?
How should I save info?
How should I save info?
 
How should I save info?
How should I save info?
 
-->