Miscellaneous code

Path iterator

Although classed as 'miscellaneous', the path iterator is an important part of the engine, as it controls most of the resource loading performed by the engine. The code recognises several different file types; each type has its own list of paths to search, as specified by the gameconfig script. The engine can then request a specific named file to be found, or for all files within a path set to be iterated and have a function called on them. Paths are searched in reverse to the order they were specified by the gameconfig script.

Safe entity deletion

Although not a distinct code unit, it's worth discussing the method of safe entity deletion used by the game. To ensure that list processing is not disrupted by the deletion of peds, cars or objects, most entity deletion is performed at designated points throughout the code (i.e. at the start of peds_do(), cars_do(), and objects_do().) In particular this is used by the mission script code, as mission script routines can be executed from almost any part of the game loop. Thus, any entities that the mission script wants to remove from the game will be flagged with a 'remove' flag. These entities will continue to have regular processing performed, and will continue to be referenced by the mission script, until the start of the next ped/car/object processing loop at which point they will be detected and removed. Not all entity deletion occurs this way, however - if the deletion comes from a pure C function stack then the entity can be deleted immediately (assuming any surrounding list processing code is able to cope correctly!).

Utility code

util.c contains a couple of functions for use with decoding sprite names. These functions are used both by most of the sprite loaders in the game engine and in ddconvert, to ensure that sprite names are processed in a consistent way.

Orient code

orient.c/orient.h contains a structure definition and a few functions for dealing with 'orientations' - the misnomoner given to the location and rotation of an object. Currently, this is only used by the car movement code. But its usage makes the code clearer and easier to follow.

TODO:
CODE: MED: Expand file handling to allow support for zip files/squash files/etc.? Would require some global rewriting if FILE *'s can't be used (just generic func to load file into memory and return size+ptr?)
???
Profit!