Changes

Jump to navigation Jump to search
911 bytes added ,  14:24, 19 September 2007
Describe common function wrappers, types and random sources
TODO: give descriptions for other commonly used header files.
 
=== Common portability issues ===
There are wrapper around number of non-portable functions. These are:
 
max() -> MAX()
min() -> MIN()
rand() -> use Common::RandomSource class
stricmp() -> scumm_stricmp()
strnicmp() -> scumm_strnicmp()
strrev() -> scumm_strrev()
 
Also we have predefined common integer types. Please, use them instead of rolling your own:
 
byte
int8
uint8
int16
uint16
int32
uint32
 
Additionally ScummVM offers way of recording all events and then playing them back on request. That could be used for "demoplay" mode. But to ensure that it will work for your engine, you have to register your RandomSource class instance. See example engine below.
=== Example: engines/quux/quux.h ===
private:
Console *_console;
 
// We need random numbers
Common::RandomSource _rnd;
};
<pre>
#include "common/scummsys.h"
#include "common/events.h" // for getEventManager()
#include "backends/fs/fs.h"
Common::addSpecialDebugLevel(kQuuxDebugExample, "example", "this is just an example for a engine specific debug level");
Common::addSpecialDebugLevel(kQuuxDebugExample2, "example2", "also an example");
 
// Don't forget to register your random source
syst->getEventManager()->registerRandomSource(_rnd, "quux");
printf("QuuxEngine::QuuxEngine\n");

Navigation menu