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

« back to all changes in this revision

Viewing changes to src/saveload/signs_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: signs_sl.cpp 15903 2009-03-30 23:15:05Z rubidium $ */
 
2
 
 
3
/** @file signs_sl.cpp Code handling saving and loading of economy data */
 
4
 
 
5
#include "../stdafx.h"
 
6
#include "../company_func.h"
 
7
#include "../signs_base.h"
 
8
 
 
9
#include "saveload.h"
 
10
 
 
11
static const SaveLoad _sign_desc[] = {
 
12
  SLE_CONDVAR(Sign, name,  SLE_NAME,                   0, 83),
 
13
  SLE_CONDSTR(Sign, name,  SLE_STR, 0,                84, SL_MAX_VERSION),
 
14
  SLE_CONDVAR(Sign, x,     SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
 
15
  SLE_CONDVAR(Sign, y,     SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
 
16
  SLE_CONDVAR(Sign, x,     SLE_INT32,                  5, SL_MAX_VERSION),
 
17
  SLE_CONDVAR(Sign, y,     SLE_INT32,                  5, SL_MAX_VERSION),
 
18
  SLE_CONDVAR(Sign, owner, SLE_UINT8,                  6, SL_MAX_VERSION),
 
19
      SLE_VAR(Sign, z,     SLE_UINT8),
 
20
        SLE_END()
 
21
};
 
22
 
 
23
/** Save all signs */
 
24
static void Save_SIGN()
 
25
{
 
26
        Sign *si;
 
27
 
 
28
        FOR_ALL_SIGNS(si) {
 
29
                SlSetArrayIndex(si->index);
 
30
                SlObject(si, _sign_desc);
 
31
        }
 
32
}
 
33
 
 
34
/** Load all signs */
 
35
static void Load_SIGN()
 
36
{
 
37
        int index;
 
38
        while ((index = SlIterateArray()) != -1) {
 
39
                Sign *si = new (index) Sign();
 
40
                SlObject(si, _sign_desc);
 
41
                /* Before version 6.1, signs didn't have owner.
 
42
                 * Before version 83, invalid signs were determined by si->str == 0.
 
43
                 * Before version 103, owner could be a bankrupted company.
 
44
                 *  - we can't use IsValidCompany() now, so this is fixed in AfterLoadGame()
 
45
                 * All signs that were saved are valid (including those with just 'Sign' and INVALID_OWNER).
 
46
                 *  - so set owner to OWNER_NONE if needed (signs from pre-version 6.1 would be lost) */
 
47
                if (CheckSavegameVersionOldStyle(6, 1) || (CheckSavegameVersion(83) && si->owner == INVALID_OWNER)) {
 
48
                        si->owner = OWNER_NONE;
 
49
                }
 
50
        }
 
51
}
 
52
 
 
53
extern const ChunkHandler _sign_chunk_handlers[] = {
 
54
        { 'SIGN', Save_SIGN, Load_SIGN, CH_ARRAY | CH_LAST},
 
55
};