~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/saveload/cheat_sl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: cheat_sl.cpp 15903 2009-03-30 23:15:05Z rubidium $ */
 
2
 
 
3
/** @file cheat_sl.cpp Code handling saving and loading of cheats */
 
4
 
 
5
#include "../stdafx.h"
 
6
#include "../cheat_type.h"
 
7
 
 
8
#include "saveload.h"
 
9
 
 
10
static void Save_CHTS()
 
11
{
 
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];
 
16
 
 
17
        SlSetLength(count * 2);
 
18
        for (; cht != cht_last; cht++) {
 
19
                SlWriteByte(cht->been_used);
 
20
                SlWriteByte(cht->value);
 
21
        }
 
22
}
 
23
 
 
24
static void Load_CHTS()
 
25
{
 
26
        Cheat *cht = (Cheat*)&_cheats;
 
27
        size_t count = SlGetFieldLength() / 2;
 
28
 
 
29
        for (uint i = 0; i < count; i++) {
 
30
                cht[i].been_used = (SlReadByte() != 0);
 
31
                cht[i].value     = (SlReadByte() != 0);
 
32
        }
 
33
}
 
34
 
 
35
extern const ChunkHandler _cheat_chunk_handlers[] = {
 
36
        { 'CHTS', Save_CHTS,     Load_CHTS,     CH_RIFF | CH_LAST}
 
37
};