Daily news, dev blogs, and stories from Game Developer straight to your inbox
June 4, 2008
2 Min Read
In this in-depth technical piece, coding veteran McNickle explains how experience on the Deer Hunter series led him to create a library for managing and exporting important variables. During Deer Hunter 2003's development, McNickle found himself having to explain a reoccurring bug and the process needed to correct it whenever a new programmer would come across it: "Essentially, any time a new variable was added to the base actor class or one of its derived classes, the programmer had to manually add support in the archiving routines to persist this data. The problem was further complicated because it was not desirable to serialize all variables during a saved game, and the logic determining which variables should be serialized when was poorly understood. Questions such as 'Should the variable be saved during a saved game?', 'Should it be serialized to the network stream?' and 'Is the variable state managed by the server, or is it client authoritative?' had to be answered. They were typically understood at the time the variable was added, but when being reviewed by another programmer, the answers to these questions had to be re-discovered." Frustrated with having to repeatedly fix the problem and seeking to develop an elegant, automated, and less error-prone solution, McNickle envisioned a system fulfilling a list of specific requirements:
It must have minimal impact on the existing code.
It must be simple to expand without changing the code of the management system. In other words, it has to be generic, and it has to support complex types.
It must have a small memory footprint. (Thankfully, we were only developing for the PC, so there was some wiggle room.)
It must provide a simple, easily discernable means for the programmer who implemented the variable to state how the system and the user should interact with it, if at all. Ideally, this means could be adjusted dynamically.
It must provide a way to query an object for all of its attributes that are to be exposed or serialized and, if possible, how and when it should be serialized.
It must provide a way to automate the serialization.
It must support altering the values of these known variables.
And finally, it must not require that the value of the variable be changed through any particular mechanism, or be notified of any such change, while always being aware of the exact value of a known attribute at any time.
You can now read the full feature including source code on McNickle's solution for " A Templated C++ Attribute Library for Object Persistence and Export." (no registration required, please feel free to link to this feature from other websites).
About the Author(s)
Eric Caoili currently serves as a news editor for Gamasutra, and has helmed numerous other UBM Techweb Game Network sites all now long-dead, including GameSetWatch. He is also co-editor for beloved handheld gaming blog Tiny Cartridge, and has contributed to Joystiq, Winamp, GamePro, and 4 Color Rebellion.
You May Also Like
Exploring the 2024 State of the Game Industry report - Game Developer Podcast ep. 39Feb 2, 2024
Phantom inspiration and the ethical auteur with Xalavier Nelson Jr.Dec 8, 2023
Designing Killer Queen: from playground experiment to modern arcade sensationOct 18, 2023
Rod Humble and King Choi illustrate the ambition of Life By YouSep 22, 2023
Get daily news, dev blogs, and stories from Game Developer straight to your inbox
Subscribe to Game Developer Newsletters to stay caught up with the latest news, design insights, marketing tips, and more