Rusty Axe Games, home of Real E$tate Empire and Battle Castles

News
Casual Arcade
Shooters
Time Management
Seek And Find
Strategy
RPG
Toons Online
Rusty Blog
About Rusty Axe

Real E$tate Empire, a real estate simulation game
Shadow Armies fiction Domain of Heroes
Your ad here!
Share
<--! style: inset; border-color: black black black black; border-width: 3px; background-color: #000000">
The Data Lump, Part 2 - Data definitions
December 4th, 2008


Well, that was a long day.. my apologies to those of you who have been waiting patiently for this second installment. Feel free to insert your own programmer scheduling joke here. Anyhow, I think a quick summation of why we are here is in order. I am in the process of evolving my game data maintenance system from one that allows flexibly structured, commented data to flow into my games to a new system that would also allow that data, with comments, to flow back out again to the text file it came from. In other words, to allow game data that is modified by an in game editor or in the debugger to be automatically pushed back to a source text file.

So what exactly is the data lump? From a data definition point of view it is two things - it is a data structure description file and another file that is the actual data description. The data structure description file is a fixed entity that won't be rewritten by this API. In fact, since our program will need to match the data structure definition file we will format that file like a C/C++ header file so that it can also be compiled into our program if we like. We will support C structures, enumerated lists and macro definitions of constants.

For example:

houseGameStructs.h


typedef struct
{
	S32	sign_offsetx;
	S32	sign_offsety;
	S32	x;
	S32	y;
	U32	neighbourhood;
	U8	*street_addr;
	U8	*spr;
}House;


enum
{
	EVERGREEN_HEIGHTS,
	OAKTOWN_CENTRAL,
	LAKE_DRIVE,
};

The actual data file will be parsed after the data description file as that will define what the data is to look like. Every structure will have a default that gets copied into every new instance so that undefined fields are initialized by the previous instance. All defaults are initialized to zero at startup. For example:

houseGameData.txt



//This comment will attach to the House below
default House
	sign_offsetx:	-13	//this comment will attach to this field
	sign_offsety:	-13
	spr:			"RedBrickHouse.png"
	neighbourhood:	EVERGREEN_HEIGHTS
End House

House
	x:	500
	y:	300
End House

House
	x:	255
	y:	475
End House


House
	x:	610
	y:	505
	neighbourhood:	OAKTOWN_CENTRAL
End House

Since the red brick house sprite will usually have a for sale sign sprouted at the same place relative to it's hotspot it is handy to setup a default house of that type and then the three house instances that follow will inherit those fields from it so that only their unique data needs to be added.

Part 3, the data lump API, coming soon,
L

No comments have been provided.





Your Name:

Your Location:

Country (flag):

Article Rating:

Your Comments:

Security check *