text-based rpg help

This is a discussion on text-based rpg help within the C++ Programming forums, part of the General Programming Boards category; I'm making a text-based rpg. The program loads map and character data from .txt files. But that makes it easy ...

  1. #1
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369

    text-based rpg help

    I'm making a text-based rpg. The program loads map and character data from .txt files. But that makes it easy for the user to go into the .txt file and, for example, change their amount of gold. How can I make my save files a little more sophisticated and harder to edit?
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,806
    Do some simple encryption and/or compression on the text files.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    How do I compress the files?
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,823
    Search the board?
    Or the web?
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    You could also just use binary output/input.

  6. #6
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    can't you do a .dat file? that's what one of my C books does.
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  7. #7
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,806
    Quote Originally Posted by jlou
    You could also just use binary output/input.
    Simply writing data to a file in binary mode won't help in and of itself. Write a program that opens a file in binary mode and writes "hello" to it. Now open that file up in notepad or something and look at it. What does it say? It says "hello", no wierd encyption has taken place.

    Quote Originally Posted by MMD_Lynx
    can't you do a .dat file? that's what one of my C books does.
    The extension used in a file has no magical effects on what format the data contained within takes. You can create an .EXE file that has the complete text of "War and Peace" in it if you want. You won't be able to execute it but you would be able to open it up in a text editor and read it. It's all about writing the data to those files in a particular way.

    Quote Originally Posted by abrege
    How do I compress the files?
    There are libraries out there that you can download source/dlls/libs for that you can link or add to your programs to do this. I haven't had to use any of these before so I couldn't help you out there. I have done some simple xor encryption before however and that would be very easy to implement.

    One of my posts in this thread has a simple program that opens an input file, encrypts the data and writes to an output file; can also decrypt. Something along the lines of that can be adapted by you to suit your needs.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  8. #8
    Registered User jlou's Avatar
    Join Date
    Jul 2003
    Posts
    1,088
    Quote Originally Posted by hk_mp5kpdw
    Simply writing data to a file in binary mode won't help in and of itself. Write a program that opens a file in binary mode and writes "hello" to it. Now open that file up in notepad or something and look at it. What does it say? It says "hello", no wierd encyption has taken place.
    If you write it as binary data, then it would be harder for the user to manipulate it. Instead of seeing 345 for the amount of gold, they'd see: Y☺. That is just a little more sophisticated and a little harder to edit.

    Of course, I would suggest trying the full on encryption - it's more robust and provides more opportunity to learn.

  9. #9
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>You can create an .EXE file that has the complete text of "War and Peace" in it if you want.

    New idea for obfuscated code competitions: Write a program which, when compiled and then opened in a text editor, is a fully readable novel...

    There's also simpler methods of encryption... like... hardcoded character replacement
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  10. #10
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    A simple encryption function wouldnt be that hard at all...

    You could just loop and write one byte at a time. And do something a simple as add a number to it... then subtract that number when you decrypt it.

    It would be a good Idea to check if the resulting value is 255 or under if your going byte by byte.

  11. #11
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    >>It would be a good Idea to check if the resulting value is 255 or under
    No. Values wrap around in C/C++. Using an unsigned char, if you have say 254 originally and you add 2, it ends up as 0. I don't recall the exact boundaries of signed char, but it too will wrap around after 127 or 128 and start back in the negatives. The same occurs when you go below zero or -127.
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  12. #12
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200
    Wow, didn't know that.

  13. #13
    Teenage Mutant Ninja Nerd MMD_Lynx's Avatar
    Join Date
    Aug 2004
    Posts
    65
    heh...that's useful. that's kinda how i was gonna encrypt it. but i was gonna reverse it too
    like "Hello, world!" would be "!dlrow ,olleH"
    Stupid people are useful. You can make them do all the mindless tasks you are too lazy to do yourself.

    Sphynx cats are just bald and wrinkly, like old people, and we don't reject them.

  14. #14
    They Call me Mister Sako
    Join Date
    Jul 2004
    Posts
    169
    Quote Originally Posted by Vicious
    A simple encryption function wouldnt be that hard at all...

    You could just loop and write one byte at a time. And do something a simple as add a number to it... then subtract that number when you decrypt it.

    It would be a good Idea to check if the resulting value is 255 or under if your going byte by byte.

    i beleive a long time ago there was a coding competition for compressing TXT files program. atleast i remeber reading someones idea about it
    AIM: MisterSako | MSN: sakotheinsane@hotmail.com | E-mail: klinerr1@nc.rr.com
    The goal of computer science is to be lazy

  15. #15
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Hunter2
    >>It would be a good Idea to check if the resulting value is 255 or under
    No. Values wrap around in C/C++. Using an unsigned char, if you have say 254 originally and you add 2, it ends up as 0. I don't recall the exact boundaries of signed char, but it too will wrap around after 127 or 128 and start back in the negatives. The same occurs when you go below zero or -127.
    Unsigned wrapping is defined, signed wrapping is undefined behavior and may or may not work the way you expect it to. There is no guarintee that it will.

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

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A bunch of Linker Errors...
    By Junior89 in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2006, 02:59 PM
  2. text rpg help
    By xxwerdxx in forum Game Programming
    Replies: 1
    Last Post: 11-26-2005, 08:16 PM
  3. Check out My Text Rpg Game
    By knight543 in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2002, 11:40 PM
  4. Text based GUI?
    By jon_nc17 in forum C++ Programming
    Replies: 1
    Last Post: 05-16-2002, 12:45 PM
  5. Text Based Game
    By drdroid in forum C++ Programming
    Replies: 2
    Last Post: 02-18-2002, 06:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21