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

« back to all changes in this revision

Viewing changes to src/saveload/misc_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: misc_sl.cpp 15903 2009-03-30 23:15:05Z rubidium $ */
 
2
 
 
3
/** @file misc_sl.cpp Saving and loading of things that didn't fit anywhere else */
 
4
 
 
5
#include "../stdafx.h"
 
6
#include "../date_func.h"
 
7
#include "../variables.h"
 
8
#include "../core/random_func.hpp"
 
9
#include "../openttd.h"
 
10
#include "../zoom_func.h"
 
11
#include "../vehicle_func.h"
 
12
#include "../window_gui.h"
 
13
#include "../window_func.h"
 
14
#include "../viewport_func.h"
 
15
#include "../gfx_func.h"
 
16
#include "../company_base.h"
 
17
#include "../town.h"
 
18
 
 
19
#include "saveload.h"
 
20
 
 
21
extern TileIndex _cur_tileloop_tile;
 
22
 
 
23
/* Keep track of current game position */
 
24
int _saved_scrollpos_x;
 
25
int _saved_scrollpos_y;
 
26
 
 
27
void SaveViewportBeforeSaveGame()
 
28
{
 
29
        const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
 
30
 
 
31
        if (w != NULL) {
 
32
                _saved_scrollpos_x = w->viewport->scrollpos_x;
 
33
                _saved_scrollpos_y = w->viewport->scrollpos_y;
 
34
                _saved_scrollpos_zoom = w->viewport->zoom;
 
35
        }
 
36
}
 
37
 
 
38
void ResetViewportAfterLoadGame()
 
39
{
 
40
        Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
 
41
 
 
42
        w->viewport->scrollpos_x = _saved_scrollpos_x;
 
43
        w->viewport->scrollpos_y = _saved_scrollpos_y;
 
44
        w->viewport->dest_scrollpos_x = _saved_scrollpos_x;
 
45
        w->viewport->dest_scrollpos_y = _saved_scrollpos_y;
 
46
 
 
47
        ViewPort *vp = w->viewport;
 
48
        vp->zoom = min(_saved_scrollpos_zoom, ZOOM_LVL_MAX);
 
49
        vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
 
50
        vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
 
51
 
 
52
        DoZoomInOutWindow(ZOOM_NONE, w); // update button status
 
53
        MarkWholeScreenDirty();
 
54
}
 
55
 
 
56
 
 
57
static const SaveLoadGlobVarList _date_desc[] = {
 
58
        SLEG_CONDVAR(_date,                   SLE_FILE_U16 | SLE_VAR_I32,  0,  30),
 
59
        SLEG_CONDVAR(_date,                   SLE_INT32,                  31, SL_MAX_VERSION),
 
60
            SLEG_VAR(_date_fract,             SLE_UINT16),
 
61
            SLEG_VAR(_tick_counter,           SLE_UINT16),
 
62
            SLEG_VAR(_vehicle_id_ctr_day,     SLE_UINT16),
 
63
            SLEG_VAR(_age_cargo_skip_counter, SLE_UINT8),
 
64
        SLE_CONDNULL(1, 0, 45),
 
65
        SLEG_CONDVAR(_cur_tileloop_tile,      SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
 
66
        SLEG_CONDVAR(_cur_tileloop_tile,      SLE_UINT32,                  6, SL_MAX_VERSION),
 
67
            SLEG_VAR(_disaster_delay,         SLE_UINT16),
 
68
            SLEG_VAR(_station_tick_ctr,       SLE_UINT16),
 
69
            SLEG_VAR(_random.state[0],        SLE_UINT32),
 
70
            SLEG_VAR(_random.state[1],        SLE_UINT32),
 
71
        SLEG_CONDVAR(_cur_town_ctr,           SLE_FILE_U8  | SLE_VAR_U32,  0, 9),
 
72
        SLEG_CONDVAR(_cur_town_ctr,           SLE_UINT32,                 10, SL_MAX_VERSION),
 
73
            SLEG_VAR(_cur_company_tick_index, SLE_FILE_U8  | SLE_VAR_U32),
 
74
        SLEG_CONDVAR(_next_competitor_start,  SLE_FILE_U16 | SLE_VAR_U32,  0, 108),
 
75
        SLEG_CONDVAR(_next_competitor_start,  SLE_UINT32,                109, SL_MAX_VERSION),
 
76
            SLEG_VAR(_trees_tick_ctr,         SLE_UINT8),
 
77
        SLEG_CONDVAR(_pause_game,             SLE_UINT8,                   4, SL_MAX_VERSION),
 
78
        SLEG_CONDVAR(_cur_town_iter,          SLE_UINT32,                 11, SL_MAX_VERSION),
 
79
            SLEG_END()
 
80
};
 
81
 
 
82
/* Save load date related variables as well as persistent tick counters
 
83
 * XXX: currently some unrelated stuff is just put here */
 
84
static void SaveLoad_DATE()
 
85
{
 
86
        SlGlobList(_date_desc);
 
87
}
 
88
 
 
89
 
 
90
static const SaveLoadGlobVarList _view_desc[] = {
 
91
        SLEG_CONDVAR(_saved_scrollpos_x,    SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
 
92
        SLEG_CONDVAR(_saved_scrollpos_x,    SLE_INT32,                  6, SL_MAX_VERSION),
 
93
        SLEG_CONDVAR(_saved_scrollpos_y,    SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
 
94
        SLEG_CONDVAR(_saved_scrollpos_y,    SLE_INT32,                  6, SL_MAX_VERSION),
 
95
            SLEG_VAR(_saved_scrollpos_zoom, SLE_UINT8),
 
96
            SLEG_END()
 
97
};
 
98
 
 
99
static void SaveLoad_VIEW()
 
100
{
 
101
        SlGlobList(_view_desc);
 
102
}
 
103
 
 
104
extern const ChunkHandler _misc_chunk_handlers[] = {
 
105
        { 'DATE', SaveLoad_DATE, SaveLoad_DATE, CH_RIFF},
 
106
        { 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, CH_RIFF | CH_LAST},
 
107
};