File Format Implementation

This is a discussion on File Format Implementation within the C Programming forums, part of the General Programming Boards category; Ok. Here goes. I am writting an RPG engine. :-P I want the map format to be a single file. ...

  1. #1
    Professional Chef leeor_net's Avatar
    Join Date
    Apr 2004
    Location
    Charles Town, WV
    Posts
    147

    Unhappy File Format Implementation

    Ok. Here goes.

    I am writting an RPG engine. :-P

    I want the map format to be a single file. It will include all the data for all the effects (scripts and whatnot), the map's name, NPC lists, width/height, yadda yadda.

    Here's the question.

    I have almost no experience with file i/o with C/C++. How would I implement such a thing to read/write these types of files?

    And as an added question, the NPC's that walk around. I figure their behavior could be done using a script. How would I save a script to a file that I could later call up? Naturally, the NPC's would some sort of struct or class or something (yet to be determined).

    Any help would be much appreciaited. I really don't have much knowledge in writting these kinds of things in C/C++.

    Thanks!

    Leeor...
    - Leeor

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    A standard method is to have multiple files. One for the players, one for the npcs, etc.

    As far as how to work with the files I give you:
    FAQ for C
    FAQ for C++

  3. #3
    Professional Chef leeor_net's Avatar
    Join Date
    Apr 2004
    Location
    Charles Town, WV
    Posts
    147
    Yeah. I know that's the standard way of doing things. I figured if I could get it all stuck into one file it might be able to help keep dir's and whatnot cleaner. Ah well. Maybe not! :-)

    Thanks, though.

    Leeor...
    - Leeor

  4. #4
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    It will be less work on you and provide a more logical enviroment to use multiple files. If you are worried about clutter in the directories just setup a good tree and stick to it. So you might have a subdirectory for everything dealing with the players, another dealing with everything for the npcs, etc.

    I would recommend you checkout the game programming forum on this board.

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Jump over to The Mud Connector, or something like Game.org (specificly the ftp section), and take a look at some of the area files. It's quite easy to do, if you really want everything in one file. MUDs do it all the time:
    Code:
    #room
    <roomnumber>
    <descriptionstring>~
    <shortdescriptionstring>~
    ... etc etc
    
    #end
    
    #mobile
    <vnum>
    <description>~
    <shortdescription>~
    ~
    <bunch of stat numbers> <stat number> <stat number> 
    ...etc...
    
    <vnum>
    ...etc...
    #end
    
    #room
    <vnum>
    ...etc...
    #end
    $
    It's been a while since I've actually looked at a Merc .are file, but it's something like that. Basicly, it's easy to make your own text file that stores all your stuff. Just figure out what you want stored, and store it.

    Personally, I prefer the "tag (or keyword)" "value" method, which I used at one time:
    Code:
    roomnumber    100
    roomdescription A maze of twisty passages, all alike.
    roombrightness 0
    room...whateve something
    Basicly, you set up keyword / value pairs. You read first the keyword, and then based on whatever keyword is read, you then read what should be the appropriate following value. I used this before, it works quite well. When I did it however, I made it so it didn't matter what order any of the tags were, and if any tag wasn't provided, it would provide default values for the non-read ones. This was a long while ago, but it works quite nicely.

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

  6. #6
    Professional Chef leeor_net's Avatar
    Join Date
    Apr 2004
    Location
    Charles Town, WV
    Posts
    147
    Well, I guess multiple files isn't too horrible. I've done it plenty of times when I was doing stuff in QB.

    Besides, I can stick them all into a Q2 pak file or something in the end! :-)

    Anyway, thanks for the responses, guys. Appreciate it.

    Leeor...
    - Leeor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Formatting the contents of a text file
    By dagorsul in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2008, 12:36 PM
  2. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Simple File encryption
    By caroundw5h in forum C Programming
    Replies: 2
    Last Post: 10-13-2004, 10:51 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM

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