1
/* $Id: cheat_sl.cpp 15903 2009-03-30 23:15:05Z rubidium $ */
3
/** @file cheat_sl.cpp Code handling saving and loading of cheats */
6
#include "../cheat_type.h"
10
static void Save_CHTS()
12
/* Cannot use lengthof because _cheats is of type Cheats, not Cheat */
13
byte count = sizeof(_cheats) / sizeof(Cheat);
14
Cheat *cht = (Cheat*) &_cheats;
15
Cheat *cht_last = &cht[count];
17
SlSetLength(count * 2);
18
for (; cht != cht_last; cht++) {
19
SlWriteByte(cht->been_used);
20
SlWriteByte(cht->value);
24
static void Load_CHTS()
26
Cheat *cht = (Cheat*)&_cheats;
27
size_t count = SlGetFieldLength() / 2;
29
for (uint i = 0; i < count; i++) {
30
cht[i].been_used = (SlReadByte() != 0);
31
cht[i].value = (SlReadByte() != 0);
35
extern const ChunkHandler _cheat_chunk_handlers[] = {
36
{ 'CHTS', Save_CHTS, Load_CHTS, CH_RIFF | CH_LAST}