RPGDXThe center of Indie-RPG gaming
Not logged in. [log in] [register]
 
 
Post new topic Reply to topic  
View previous topic - View next topic  
Author Message
DrunkenCoder
Demon Hunter


Joined: 29 May 2002
Posts: 559

PostPosted: Mon Jul 21, 2003 10:07 am    Post subject: Data Format [quote]

Jihgfed Pumpkinhead wrote:

...how do you all store game data? Personally, provided there's not too too much of it, I'm big on storing content in easily-editable text files, so that if the user finds something too difficult, say, or just wants to screw around, he can go in and change it himself. Don't tell me you've never wanted to change the main character's name to something obscene, because I know you have.

The original post can be found here
_________________
If there's life after death there is no death, if there's no death we never live. | ENTP
Back to top  
Bjorn
Demon Hunter


Joined: 29 May 2002
Posts: 1425
Location: Germany

PostPosted: Mon Jul 21, 2003 12:33 pm    Post subject: [quote]

I've prodded our Lua code before and I will do it again. Of course, this is overkill if you just want to store some predefined sprite variables but once you have chosen to use a scripting language to do all the game logic stuff, it doesn't really make sense to use something else for the predefined constants.
Code:
Ladder2 = Decoration:subclass
{
   name = "Ladder2";

   init = function(self)
      self.convTable = lang:getConv("LadderOut")
      Decoration.init(self)
   end;

   defaultproperties = {
      bCenterBitmap = false,
      bCenterOnTile = false,
      offset_y = 0,
      obstacle = 1,
      draw_mode = DM_MASKED,
      bitmap = m_get_bitmap("ladder.bmp"),
   }
}

As we store these scripts uncompressed in a datafile, they can be edited by the end-user in any text editing tool. I hadn't even thought about that until one player reported he had finished the game after making himself walk a lot faster and being invincible.
Back to top  
Rainer Deyke
Demon Hunter


Joined: 05 Jun 2002
Posts: 672

PostPosted: Mon Jul 21, 2003 3:31 pm    Post subject: [quote]

Feyna's Quest has a structure like this:

data/areas/*: Area (i.e. level) description files (with embedded scripts).
data/cutscenes/*: Cutscene scripts (in special cutscene scripting language)
data/fonts/*: Fonts
data/map/*: Map files
data/monsters/*: Scripts for objects. All scripted objects are considered monsters by the engine.
data/music/*: Music files
data/sounds/*: Sound effects
data/tile_sets/*: Tile set bitmaps and description files.
data/area.txt: Global list of areas.
data/cutscenes.txt: Global list of cutscenes
... other global lists ...

These data files are all compressed with zlib and collected into two huge archive files by a custom utility. I have found that this not only decreases the amount of disk space used, it also increases performance by reducing the number of disk accesses.

All the description files are in different custom file formats. For example, here's an area description file:

Code:
room main:
  layer guild_main primary
  door 0 room0 0 pic 0
  door 1 stairs0 1 pic 0
  door 2 room2 0 pic 0
  door 3 room3 0 pic 0
  door 4 room1 0 pic 0
  door 5 stairs0 2 pic 0
  music tunnels


room room0:
  layer guild_room0 primary
  exit left main 0
  entry 1 left
  entry 0 right
  music tunnels

  on entry:
    if $chapter < 1:
      play_cutscene("chapter1")
      $chapter = 1


room room1:
  layer guild_room1 primary
  exit left main 4
  music tunnels


room room2:
  layer guild_room2 primary
  exit right main 2
  entry 0 left
  music tunnels


room room3:
  layer guild_room3 primary
  exit right main 3
  entry 0 left
  music tunnels


room stairs0:
  layer guild_stairs0 primary
  door 0 basement0 0 key 10 pic 1
  door 1 main 1 pic 0
  door 2 main 5 pic 0
  door 3 tower0 0 pic 0
  door 4 tower3 0 pic 0
  music tunnels


room tower0:
  layer guild_tower2 primary
  door 0 stairs0 3 pic 0
  door 1 tower1 0 pic 0
  door 2 tower3 1 pic 0
  door 3 tower3 2 pic 0
  door 4 tower3 3 pic 0
  door 5 tower3 4 pic 0
  door 6 tower3 5 pic 0
  door 7 tower3 6 pic 0
  door 8 tower3 7 pic 0
  door 9 tower3 8 pic 0
  music tunnels


room tower1:
  layer guild_tower1 primary
  door 0 tower0 1 pic 0
  music tunnels


room tower3:
  layer guild_tower3 primary
  door 0 stairs0 4 pic 0
  door 1 tower0 2 pic 0
  door 2 tower0 3 pic 0
  door 3 tower0 4 pic 0
  door 4 tower0 5 pic 0
  door 5 tower0 6 pic 0
  door 6 tower0 7 pic 0
  door 7 tower0 8 pic 0
  door 8 tower0 9 pic 0
  music tunnels


room basement0:
  layer guild_basement0 primary
  door 0 stairs0 0 entry right pic 1
  door 1 lab1 0 entry right pic 0
  door 2 lab1 1 entry right pic 0
  door 3 library 0 pic 0
  door 4 storage0 1 pic 0
  music rats


room lab1:
  layer guild_basement3 primary
  entry 2 right
  door 0 basement0 1 entry left pic 0
  door 1 basement0 2 entry left pic 0
  exit left rat_room 0
  music rats


room rat_room:
  layer guild_rat_room primary
  entry 0 left
  exit right lab1 2
  exit down storage0 0
  music rats


room storage0:
  layer basement4 primary
  entry 0 right
  door 1 basement0 4 entry right pic 0
  music rats


room library:
  layer guild_library primary
  door 0 basement0 3 entry right pic 0
  door 1 basement2a 0 entry left pic 0
  door 2 secret 0 pic 9
  music rats


room secret:
  layer guild_secret primary
  door 0 library 2 entry right pic 0
  music rats


room basement2a:
  layer guild_basement2 primary
  door 0 library 1 entry right pic 0
  entry 1 left
  exit right portal_room 0
  music rats


room portal_room:
  layer guild_portal_room primary
  door 0 basement2a 1 entry right pic 0
  door 1 shroom/house0 0 key 11 pic 2 no_open
  music rats
Back to top  
Mandrake
elementry school minded asshole


Joined: 28 May 2002
Posts: 1341
Location: GNARR!

PostPosted: Mon Jul 21, 2003 5:52 pm    Post subject: [quote]

I basically use compressed XML. This way, it's all human-readable and easy to change. And when I want to use it, I just compress and encrypt it and away I go.

I have a base XML class object that any object that needs to save/load inherits from. Then, I have a stack of save-objects, the que is basically a stl vector of pointers to XML class objects. Since the objects inherit from the base class, I just shove them onto the stack, and then it iterates through saving them. Pretty nifty and painless if you ask me.
_________________
"Well, last time I flicked on a lighter, I'm pretty sure I didn't create a black hole."-
Xmark

http://pauljessup.com
Back to top  
janus
Mage


Joined: 29 Jun 2002
Posts: 464
Location: Issaquah, WA

PostPosted: Mon Jul 28, 2003 10:26 am    Post subject: [quote]

Well, I hate to bump this post but I figure I might as well chime in since my method seems to be different from all of yours.

I use a hierarchical binary file storage system for all my data, that basically works like this:
Each 'object' (or distinct chunk of data) in my system implements a 'Saveable' interface, and then when I wish to save any of those objects, I create a File object, and call its Save method and pass in the object I wish to save. Then, the File is passed into the object's Save method (part of the Saveable interface), and it uses the File to save its own data. Because of the way my data is structured, I end up with data structures like this: (this example is a map file)
Code:

Header
Layer Count
  Layer
    Tiles
    Obstructions
    Properties
  Layer
    Tiles
    Obstructions
    Properties
  Layer
    Tiles
    Obstructions
    Properties

Now, the useful part of this is that it's hierarchical... each 'section' of the hierarchy has a length header stored before it, which enables me to skip over unrecognized sections and avoid running off the end of a section. This means that I could, say, add a new piece of data to the end of Layers:
Code:

Header
Layer Count
  Layer
    Tiles
    Obstructions
    Properties
    Porn
  Layer
    Tiles
    Obstructions
    Properties
    Porn
  Layer
    Tiles
    Obstructions
    Properties
    Porn

Any code that is designed to load the older definition of Layer will still work, it will simply ignore the extra data at the end of each section. And if you load an old file in new code that wants the Porn data, it will still work - it just won't get that data (an error will be raised when it attempts to read the data).

Dumb example, really, but this system works great for me. It's easy to write the code for, and now that I've gotten most of the bugs worked out it's pretty solid and effective. The performance isn't bad either. I've been able to move almost all of my file code over to it... The VB Open/Close/Get/Put statements only show up like 3 times in my entire engine now.

Of course, the format isn't self-documenting - to the uninformed it looks like a stream of binary data - but all you really need to know is how the hierarchy is organized, and you can load a file in this format, you don't even need to know what data it contains. It's sort of like how the PNG format's chunks work, but it's more simplistic.
Back to top  
Mandrake
elementry school minded asshole


Joined: 28 May 2002
Posts: 1341
Location: GNARR!

PostPosted: Mon Jul 28, 2003 5:15 pm    Post subject: [quote]

heh, I've used a similiar idea before, except i used binary addresing and a table of contents as the header, the table containitng binary address for chunks of binary data, and then the size of that data.

It worked pretty well...
_________________
"Well, last time I flicked on a lighter, I'm pretty sure I didn't create a black hole."-
Xmark

http://pauljessup.com
Back to top  
Raiko
I wanna be a ballerina!


Joined: 22 Jul 2003
Posts: 24

PostPosted: Wed Jul 30, 2003 5:32 am    Post subject: [quote]

Ive done that also

my header was like


filename|beginning address|size of data

repeating for every file in the binary file, then all the file data jammed together after the header.

So when I wanted to load a file, Id just loop through the header using strtok and check file names until I found the one I wanted.. then read the next two tokens.

Was easy to do
Back to top  
Post new topic Reply to topic Page 1 of 1 All times are GMT
 



Display posts from previous:   
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum