Game Development Reference
In-Depth Information
error-proof system only adds complexity. Features like extensibility, standards com-
pliance, and readability, which are common features of general-purpose serialization
systems, are useless and only increase load times. At the end of the day, all that
matters is that the data is loaded, not the standards that were used.
Finally, the solutions are often not built with a focus on the complexity of game
data. Formats based on XML or other plain-text representations are overly verbose
for describing many forms of data. In many cases, these serialization techniques will
rely on binary blobs to avoid these issues. These binary blobs are simply another
file format, which defeats the entire purpose of a generic and mutable file format.
7.3 Object Databases
Although most existing technologies do not fit game development directly, their
core concepts are sound. Most games are written in an object-oriented language,
so storing game objects directly is very appealing. A serialization system should
only have two methods:
Object *LoadData(string filename);
void SaveData(string filename, Object *value);
When loading data from a file, the file needs to completely describe the data.
When saving to a file, the data needs to completely describe itself. With high-level
languages like Java and .NET, their frameworks facilitate this work automatically.
With lower-level languages like C++, this job is left to the programmer.
Writing a metadata system 1 is highly dependent on programming language and
platform, but most conform to an API similar to the following code:
class MetaObject
{
static MetaObject *getMetaObject(string name);
void setByString(Object *object, string field, string value);
string getByString(Object *object, string field);
vector<string> getFields();
};
class Object
{
MetaObject *getMeta();
}
1 A metadata system allows programmatic access to information about the layouts of objects.
By having this information, runtime code can inspect objects without a direct connection to the
object's code.
Search WWH ::




Custom Search