Sponsored By

Feature: 'A Templated C++ Attribute Library for Object Persistence and Export'

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

Eric Caoili, Blogger

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:

  1. It must have minimal impact on the existing code.

  2. 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.

  3. It must have a small memory footprint. (Thankfully, we were only developing for the PC, so there was some wiggle room.)

  4. 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.

  5. 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.

  6. It must provide a way to automate the serialization.

  7. It must support altering the values of these known variables.

  8. 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

Blogger

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.

Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like