Advertisement

file i/o error and more

Started by July 24, 2000 10:04 PM
12 comments, last by Joker2000 24 years, 4 months ago
quote: Original post by Joker2000

You do realize that the whole point is to write the file in a format the user CANNOT read to prevent him from changing values and such, right? Will >> and << still "encrypt" them if I'm using ios::binary?


---
Joker2000
Stevie Ray Vaughan - The Legend



The user, for the time being, is you. Thus being able to edit,
and more importantly read save games is a good thing. Simply
writing your save games as binaries provides no difficulty
whatsoever to those who wish to cheat. It saves disk space and
is often faster, but provides no security. If you want to
prevent people from editing your files, use a checksum that's
difficult to guess, or, even better, use some form of
error-correcting code. This will confuse most kids with hex
editors and even add safety. Then, if you are still paranoid use
legal strength DES/TwoFish and obsfucate the key.

It might take a month or two before some determined kid has a
save game editor up. The thing is, get it working first, and
make it easy to work with.


Edited by - Grib on July 25, 2000 5:56:50 PM
Ok, let's say I had the following code written for SavePlayer and LoadPlayer. SavePlayer works, but I'm having trouble writing a search algorithm for LoadPlayer. I've gone ahead and used Grib's ASCII method to see exactly what I'm doing.

void CPlayer::SavePlayer(){    ofstream savePlayer("Players.dat", ios::out | ios::app);    savePlayer << "\"" << playerName << "\"" << " ";    savePlayer << hasWeapon << " ";    savePlayer << health << " ";    savePlayer << armor << " ";    savePlayer << pocketMoney << " ";    savePlayer << bankMoney << " ";    savePlayer << experience << " ";    savePlayer << skillLevel << endl << endl;    savePlayer.close();}CPlayer * CPlayer::LoadSavedPlayer(string loadName){    string pName;    bool hWeapon;    unsigned short health, armor, pMoney, bMoney, experience, skill;    ifstream loadPlayer("Players.dat");    while(loadName != playerName)    {        if (loadPlayer.eof())        {            cout << endl << "That player name could not be found.";            getch();            return 0;        }    // THIS IS WHERE I NEED THE FILE SEARCH COMMAND    }    THIS IS WHERE I LOAD THE DATA IF MATCH IS FOUND}CPlayer * PromptNewPlayer(void){    string loadPlayer;    CPlayer * pTempPlayer;    cout << "Name of player you would like to load.";    cout << endl;    cin >> loadPlayer;    pTempPlayer = pTempPlayer->LoadSavedPlayer(loadPlayer);}  

Notice on SavePlayer, the field delimiter is a blank space and quotes are around the player name.


---
Joker2000
Stevie Ray Vaughan - The Legend


Edited by - Joker2000 on July 25, 2000 12:49:50 AM
Advertisement
quote:
Notice on SavePlayer, the field delimiter is a blank space and quotes are around the player name.


Only one little thing that I can see: you don''t need to put the spaces yourself. When I tried and then edited my Text File, the space delimiter was there. I didn''t have to do it manually...



Cyberdrek
Headhunter Soft
DLC Multimedia
[Cyberdrek | ]
Perhaps you are using VC++. (Yes?) I''m using Borland and I tried it and it doesn''t put any delimiters.


---
Joker2000
Stevie Ray Vaughan - The Legend

This topic is closed to new replies.

Advertisement