FANDOM


Doom incorporates the ability to integrate with an external statistics driver: in this setup, the Doom engine is invoked by an external statistics program. At the end of each level, Doom passes statistics about the level back to the statistics program.

Functional statistics drivers compatible with Doom did not actually exist until late 2007, when Simon "Fraggle" Howard finally created one.

Technical

The system works using the statcopy Command line arguments. The statistics program passes the address in memory of a structure in which to place statistics. For example, the following would instruct Doom to place statistics in the memory location "1234567":

doom -statcopy 1234567

The structures used (in C, taken from Chocolate Doom's d_player.h file) for the data is in the following format:

//
// INTERMISSION
// Structure passed e.g. to WI_Start(wb)
//
typedef struct
{
 booleanin;// whether the player is in game
 
 // Player stats, kills, collected items etc.
 intskills;
 intsitems;
 intssecret;
 intstime; 
 intfrags[4];
 intscore;// current score on entry, modified on return
 
} wbplayerstruct_t;

typedef struct
{
 intepsd;// episode # (0-2)

 // if true, splash the secret level
 booleandidsecret;
 
 // previous and next levels, origin 0
 intlast;
 intnext;
 
 intmaxkills;
 intmaxitems;
 intmaxsecret;
 intmaxfrags;

 // the par time
 intpartime;
 
 // index of this player in game
 intpnum;

 wbplayerstruct_tplyr[MAXPLAYERS];

} wbstartstruct_t;

At the start of each level, statistics are then copied into this buffer. There is no trigger activated to inform the statistics driver that this has occurred. The statistics driver would have to set up its own timer to periodically check the buffer for new information.

This system is only possible because of DOS's lack of memory protection: this kind of sharing of memory is not so easily possible in modern operating systems.

External Links

Community content is available under CC-BY-SA unless otherwise noted.