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 4 - Preserving User Comments
December 30th, 2008


In this installment of the Data Lump I will talk about preserving user comments in the data lump as the lump is written back out after a dlWrite command has been issued to the Data Lump SDK.

There are two parts to solving this problem. When the Data Lump is initially read we need to accumulate and tag comments for later use. Comments can be tagged to a data structure or they can be tagged to a field within a data structure. When parsing the data lump the SDK will need to track whether the last element added was a data field within a structure or not. If a comment is encountered then it can either be tagged back to the last data field or, if not currently parsing a structure then comments can be accumulated and tied to the next structure that is encountered.

I'm kind of old school about my coding practices and I don't like to use a lot of extra memory when it isn't needed. In the case of tracking comment tags the lightweight solution is to not have every element carry a tag to a comment field but to have all of the comments that are encountered carry a memory pointer back to the element they belong to. When the API is writing the data lump back out to disk then when each element is written - where an element is defined as either a structure or a field within a structure - we will see if that elements memory address matches the memory tag on a comment. If so then write the comment field out as appropriate. Appropriate for a structure is before the structure begins and for a field it means a tab after the data record is written followed by the comment. All comments are written C++ style with a two forward slash, //, preface. Comments that exceed a reasonable line length will be continued after a newline is written with record comments that exceed a single line being prefaced by multiple tabs on the newline.

Part 5, the last section, entitled writing the Data Lump API, is coming soon,
L

No comments have been provided.





Your Name:

Your Location:

Country (flag):

Article Rating:

Your Comments:

Security check *