Files
@ r20718:cc912091a170
Branch filter:
Location: cpp/openttd-patchpack/source/src/saveload/misc_sl.cpp - annotation
r20718:cc912091a170
5.9 KiB
text/x-c
(svn r25756) -Update from WebTranslator v3.0:
indonesian - 2 changes by UseYourIllusion
indonesian - 2 changes by UseYourIllusion
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | r10571:99cb9a95b4cf r10571:99cb9a95b4cf r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r14248:a9050881acd7 r15326:d5a6f99c5425 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r15515:db92a54a178e r15515:db92a54a178e r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r13815:8cc0cdaaf624 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r13845:254363615d19 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r18462:a1ba75a7f741 r18462:a1ba75a7f741 r18462:a1ba75a7f741 r18462:a1ba75a7f741 r18462:a1ba75a7f741 r18462:a1ba75a7f741 r18460:1ec843d3a5ae r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r17899:92aaab03ad72 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r17055:2989afdad450 r17899:92aaab03ad72 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r11920:e51276f97f18 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r11921:e51a930f3ca0 r11921:e51a930f3ca0 r10571:99cb9a95b4cf r10742:299e6d78c5f4 r10742:299e6d78c5f4 r10571:99cb9a95b4cf r11847:235c011992a8 r11922:cc192b50b8f5 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r17055:2989afdad450 r17899:92aaab03ad72 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r16546:a3376e2d6467 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r15326:d5a6f99c5425 r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r10571:99cb9a95b4cf r15326:d5a6f99c5425 r15326:d5a6f99c5425 r10571:99cb9a95b4cf | /* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file misc_sl.cpp Saving and loading of things that didn't fit anywhere else */
#include "../stdafx.h"
#include "../date_func.h"
#include "../zoom_func.h"
#include "../window_gui.h"
#include "../window_func.h"
#include "../viewport_func.h"
#include "../gfx_func.h"
#include "../core/random_func.hpp"
#include "../fios.h"
#include "saveload.h"
extern TileIndex _cur_tileloop_tile;
extern uint16 _disaster_delay;
extern byte _trees_tick_ctr;
/* Keep track of current game position */
int _saved_scrollpos_x;
int _saved_scrollpos_y;
ZoomLevelByte _saved_scrollpos_zoom;
void SaveViewportBeforeSaveGame()
{
const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
if (w != NULL) {
_saved_scrollpos_x = w->viewport->scrollpos_x;
_saved_scrollpos_y = w->viewport->scrollpos_y;
_saved_scrollpos_zoom = w->viewport->zoom;
}
}
void ResetViewportAfterLoadGame()
{
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
w->viewport->scrollpos_x = _saved_scrollpos_x;
w->viewport->scrollpos_y = _saved_scrollpos_y;
w->viewport->dest_scrollpos_x = _saved_scrollpos_x;
w->viewport->dest_scrollpos_y = _saved_scrollpos_y;
ViewPort *vp = w->viewport;
vp->zoom = (ZoomLevel)min(_saved_scrollpos_zoom, ZOOM_LVL_MAX);
vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
/* If zoom_max is ZOOM_LVL_MIN then the setting has not been loaded yet, therefore all levels are allowed. */
if (_settings_client.gui.zoom_max != ZOOM_LVL_MIN) {
/* Ensure zoom level is allowed */
while (vp->zoom < _settings_client.gui.zoom_min) DoZoomInOutWindow(ZOOM_OUT, w);
while (vp->zoom > _settings_client.gui.zoom_max) DoZoomInOutWindow(ZOOM_IN, w);
}
DoZoomInOutWindow(ZOOM_NONE, w); // update button status
MarkWholeScreenDirty();
}
byte _age_cargo_skip_counter; ///< Skip aging of cargo? Used before savegame version 162.
static const SaveLoadGlobVarList _date_desc[] = {
SLEG_CONDVAR(_date, SLE_FILE_U16 | SLE_VAR_I32, 0, 30),
SLEG_CONDVAR(_date, SLE_INT32, 31, SL_MAX_VERSION),
SLEG_VAR(_date_fract, SLE_UINT16),
SLEG_VAR(_tick_counter, SLE_UINT16),
SLE_CONDNULL(2, 0, 156), // _vehicle_id_ctr_day
SLEG_CONDVAR(_age_cargo_skip_counter, SLE_UINT8, 0, 161),
SLE_CONDNULL(1, 0, 45),
SLEG_CONDVAR(_cur_tileloop_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLEG_CONDVAR(_cur_tileloop_tile, SLE_UINT32, 6, SL_MAX_VERSION),
SLEG_VAR(_disaster_delay, SLE_UINT16),
SLE_CONDNULL(2, 0, 119),
SLEG_VAR(_random.state[0], SLE_UINT32),
SLEG_VAR(_random.state[1], SLE_UINT32),
SLE_CONDNULL(1, 0, 9),
SLE_CONDNULL(4, 10, 119),
SLEG_VAR(_cur_company_tick_index, SLE_FILE_U8 | SLE_VAR_U32),
SLEG_CONDVAR(_next_competitor_start, SLE_FILE_U16 | SLE_VAR_U32, 0, 108),
SLEG_CONDVAR(_next_competitor_start, SLE_UINT32, 109, SL_MAX_VERSION),
SLEG_VAR(_trees_tick_ctr, SLE_UINT8),
SLEG_CONDVAR(_pause_mode, SLE_UINT8, 4, SL_MAX_VERSION),
SLE_CONDNULL(4, 11, 119),
SLEG_END()
};
static const SaveLoadGlobVarList _date_check_desc[] = {
SLEG_CONDVAR(_load_check_data.current_date, SLE_FILE_U16 | SLE_VAR_I32, 0, 30),
SLEG_CONDVAR(_load_check_data.current_date, SLE_INT32, 31, SL_MAX_VERSION),
SLE_NULL(2), // _date_fract
SLE_NULL(2), // _tick_counter
SLE_CONDNULL(2, 0, 156), // _vehicle_id_ctr_day
SLE_CONDNULL(1, 0, 161), // _age_cargo_skip_counter
SLE_CONDNULL(1, 0, 45),
SLE_CONDNULL(2, 0, 5), // _cur_tileloop_tile
SLE_CONDNULL(4, 6, SL_MAX_VERSION), // _cur_tileloop_tile
SLE_NULL(2), // _disaster_delay
SLE_CONDNULL(2, 0, 119),
SLE_NULL(4), // _random.state[0]
SLE_NULL(4), // _random.state[1]
SLE_CONDNULL(1, 0, 9),
SLE_CONDNULL(4, 10, 119),
SLE_NULL(1), // _cur_company_tick_index
SLE_CONDNULL(2, 0, 108), // _next_competitor_start
SLE_CONDNULL(4, 109, SL_MAX_VERSION), // _next_competitor_start
SLE_NULL(1), // _trees_tick_ctr
SLE_CONDNULL(1, 4, SL_MAX_VERSION), // _pause_mode
SLE_CONDNULL(4, 11, 119),
SLEG_END()
};
/* Save load date related variables as well as persistent tick counters
* XXX: currently some unrelated stuff is just put here */
static void SaveLoad_DATE()
{
SlGlobList(_date_desc);
}
static void Check_DATE()
{
SlGlobList(_date_check_desc);
if (IsSavegameVersionBefore(31)) {
_load_check_data.current_date += DAYS_TILL_ORIGINAL_BASE_YEAR;
}
}
static const SaveLoadGlobVarList _view_desc[] = {
SLEG_CONDVAR(_saved_scrollpos_x, SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
SLEG_CONDVAR(_saved_scrollpos_x, SLE_INT32, 6, SL_MAX_VERSION),
SLEG_CONDVAR(_saved_scrollpos_y, SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
SLEG_CONDVAR(_saved_scrollpos_y, SLE_INT32, 6, SL_MAX_VERSION),
SLEG_VAR(_saved_scrollpos_zoom, SLE_UINT8),
SLEG_END()
};
static void SaveLoad_VIEW()
{
SlGlobList(_view_desc);
}
extern const ChunkHandler _misc_chunk_handlers[] = {
{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, NULL, Check_DATE, CH_RIFF},
{ 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, NULL, NULL, CH_RIFF | CH_LAST},
};
|