author | rubidium |
Sun, 06 Apr 2008 23:07:42 +0000 | |
branch | noai |
changeset 9869 | 6404afe43575 |
parent 9837 | c9ec4f82e0d0 |
child 10181 | 54df587fef5d |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6417
diff
changeset
|
3 |
/** @file misc.cpp */ |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6417
diff
changeset
|
4 |
|
0 | 5 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1881
diff
changeset
|
6 |
#include "openttd.h" |
2308 | 7 |
#include "currency.h" |
9599 | 8 |
#include "landscape.h" |
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9724
diff
changeset
|
9 |
#include "news_func.h" |
0 | 10 |
#include "saveload.h" |
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1595
diff
changeset
|
11 |
#include "vehicle_gui.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2112
diff
changeset
|
12 |
#include "variables.h" |
9429
25b7d020a3a9
(svn r9232) [NoAI] -Fix r9230: incode update about file/dir moving
truelight
parents:
9360
diff
changeset
|
13 |
#include "ai/ai.h" |
9476 | 14 |
#include "newgrf_house.h" |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6222
diff
changeset
|
15 |
#include "cargotype.h" |
9624 | 16 |
#include "group.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
17 |
#include "viewport_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
18 |
#include "economy_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
19 |
#include "zoom_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
20 |
#include "functions.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
21 |
#include "map_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
22 |
#include "date_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
23 |
#include "vehicle_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
24 |
#include "texteff.hpp" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
25 |
#include "string_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
26 |
#include "gfx_func.h" |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
27 |
#include "core/alloc_func.hpp" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
28 |
#include "settings_type.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
29 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
30 |
#include "table/strings.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
31 |
#include "table/sprites.h" |
0 | 32 |
|
1328
e069d2db0e4c
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1313
diff
changeset
|
33 |
char _name_array[512][32]; |
0 | 34 |
|
6573 | 35 |
void InitializeVehicles(); |
36 |
void InitializeWaypoints(); |
|
37 |
void InitializeDepots(); |
|
38 |
void InitializeEngines(); |
|
39 |
void InitializeOrders(); |
|
40 |
void InitializeClearLand(); |
|
41 |
void InitializeRailGui(); |
|
42 |
void InitializeRoadGui(); |
|
43 |
void InitializeAirportGui(); |
|
44 |
void InitializeDockGui(); |
|
45 |
void InitializeIndustries(); |
|
46 |
void InitializeMainGui(); |
|
47 |
void InitializeTowns(); |
|
48 |
void InitializeTrees(); |
|
49 |
void InitializeSigns(); |
|
50 |
void InitializeStations(); |
|
9629 | 51 |
void InitializeCargoPackets(); |
6573 | 52 |
static void InitializeNameMgr(); |
53 |
void InitializePlayers(); |
|
54 |
static void InitializeCheats(); |
|
55 |
void InitializeNPF(); |
|
0 | 56 |
|
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2706
diff
changeset
|
57 |
void InitializeGame(int mode, uint size_x, uint size_y) |
0 | 58 |
{ |
2051 | 59 |
AllocateMap(size_x, size_y); |
60 |
||
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9704
diff
changeset
|
61 |
SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0); |
0 | 62 |
|
6557
8381016f71f3
(svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents:
6527
diff
changeset
|
63 |
_pause_game = 0; |
0 | 64 |
_fast_forward = 0; |
65 |
_tick_counter = 0; |
|
9629 | 66 |
_realtime_tick = 0; |
0 | 67 |
_date_fract = 0; |
68 |
_cur_tileloop_tile = 0; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
69 |
|
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2706
diff
changeset
|
70 |
if ((mode & IG_DATE_RESET) == IG_DATE_RESET) { |
4295
66d2c96579a6
(svn r5928) -Cleanup: remove ConvertIntDate and use ConvertYMDToDate as ConvertIntDate was only called with Years.
rubidium
parents:
4285
diff
changeset
|
71 |
SetDate(ConvertYMDToDate(_patches.starting_year, 0, 1)); |
0 | 72 |
} |
73 |
||
2848 | 74 |
InitializeEngines(); |
0 | 75 |
InitializeVehicles(); |
1542
2ca6d1624e6d
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1538
diff
changeset
|
76 |
InitializeWaypoints(); |
4347
79b04c2cef95
(svn r6048) -Codechange: all InitializeXXX are plural, just not Depot
truelight
parents:
4344
diff
changeset
|
77 |
InitializeDepots(); |
1024
9b06b01490a4
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1009
diff
changeset
|
78 |
InitializeOrders(); |
9624 | 79 |
InitializeGroup(); |
0 | 80 |
|
81 |
InitNewsItemStructs(); |
|
2051 | 82 |
InitializeLandscape(); |
0 | 83 |
InitializeClearLand(); |
84 |
InitializeRailGui(); |
|
85 |
InitializeRoadGui(); |
|
86 |
InitializeAirportGui(); |
|
87 |
InitializeDockGui(); |
|
88 |
InitializeTowns(); |
|
89 |
InitializeTrees(); |
|
988
2482369a61ff
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
90 |
InitializeSigns(); |
0 | 91 |
InitializeStations(); |
9629 | 92 |
InitializeCargoPackets(); |
0 | 93 |
InitializeIndustries(); |
9476 | 94 |
InitializeBuildingCounts(); |
3622
e1c16777dacb
(svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents:
3617
diff
changeset
|
95 |
InitializeMainGui(); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
96 |
|
0 | 97 |
InitializeNameMgr(); |
164
0cbdf3c9bde1
(svn r165) -Feature: Option to sort vehicles in vehicle-list window by different criteria. Total independent sort for all types and players. Periodic resort of list every 10 TTD days. Thank you for your graphical inspiration follow and buxo (since none of you provided any code).
darkvater
parents:
116
diff
changeset
|
98 |
InitializeVehiclesGuiList(); |
0 | 99 |
InitializeTrains(); |
1247 | 100 |
InitializeNPF(); |
0 | 101 |
|
2706
d31bd0aa0096
(svn r3250) -Fix: AIs weren't uninitialized when a new game was loaded
truelight
parents:
2685
diff
changeset
|
102 |
AI_Initialize(); |
0 | 103 |
InitializePlayers(); |
104 |
InitializeCheats(); |
|
105 |
||
106 |
InitTextEffects(); |
|
9701
d1ac22c62f64
(svn r11036) [NoAI] -Sync: with trunk r10774:11035.
rubidium
parents:
9629
diff
changeset
|
107 |
InitChatMessage(); |
0 | 108 |
InitializeAnimatedTiles(); |
109 |
||
110 |
InitializeLandscapeVariables(false); |
|
111 |
||
112 |
ResetObjectToPlace(); |
|
113 |
} |
|
114 |
||
4862
b45c1e638e7f
(svn r6788) - Codechange: Add and use a function to test if a string ID is a custom name.
peter1138
parents:
4383
diff
changeset
|
115 |
bool IsCustomName(StringID id) |
b45c1e638e7f
(svn r6788) - Codechange: Add and use a function to test if a string ID is a custom name.
peter1138
parents:
4383
diff
changeset
|
116 |
{ |
b45c1e638e7f
(svn r6788) - Codechange: Add and use a function to test if a string ID is a custom name.
peter1138
parents:
4383
diff
changeset
|
117 |
return GB(id, 11, 5) == 15; |
b45c1e638e7f
(svn r6788) - Codechange: Add and use a function to test if a string ID is a custom name.
peter1138
parents:
4383
diff
changeset
|
118 |
} |
b45c1e638e7f
(svn r6788) - Codechange: Add and use a function to test if a string ID is a custom name.
peter1138
parents:
4383
diff
changeset
|
119 |
|
0 | 120 |
|
6573 | 121 |
static void InitializeCheats() |
0 | 122 |
{ |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
123 |
memset(&_cheats, 0, sizeof(Cheats)); |
0 | 124 |
} |
125 |
||
126 |
||
6573 | 127 |
static void InitializeNameMgr() |
0 | 128 |
{ |
129 |
memset(_name_array, 0, sizeof(_name_array)); |
|
130 |
} |
|
131 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
132 |
/* Copy and convert old custom names to UTF-8 */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
133 |
char *CopyFromOldName(StringID id) |
0 | 134 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
135 |
if (!IsCustomName(id)) return NULL; |
0 | 136 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
137 |
if (CheckSavegameVersion(37)) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
138 |
/* Old names were 32 characters long, so 128 characters should be |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
139 |
* plenty to allow for expansion when converted to UTF-8. */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
140 |
char tmp[128]; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
141 |
const char *strfrom = _name_array[GB(id, 0, 9)]; |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
142 |
char *strto = tmp; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
143 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
144 |
for (; *strfrom != '\0'; strfrom++) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
145 |
WChar c = (byte)*strfrom; |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
146 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
147 |
/* Map from non-ISO8859-15 characters to UTF-8. */ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
148 |
switch (c) { |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
149 |
case 0xA4: c = 0x20AC; break; // Euro |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
150 |
case 0xA6: c = 0x0160; break; // S with caron |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
151 |
case 0xA8: c = 0x0161; break; // s with caron |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
152 |
case 0xB4: c = 0x017D; break; // Z with caron |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
153 |
case 0xB8: c = 0x017E; break; // z with caron |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
154 |
case 0xBC: c = 0x0152; break; // OE ligature |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
155 |
case 0xBD: c = 0x0153; break; // oe ligature |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
156 |
case 0xBE: c = 0x0178; break; // Y with diaresis |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
157 |
default: break; |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
158 |
} |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
159 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
160 |
/* Check character will fit into our buffer. */ |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
161 |
if (strto + Utf8CharLen(c) > lastof(tmp)) break; |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
162 |
|
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
163 |
strto += Utf8Encode(strto, c); |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
164 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
165 |
|
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
166 |
/* Terminate the new string and copy it back to the name array */ |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
167 |
*strto = '\0'; |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
168 |
|
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
169 |
return strdup(tmp); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
170 |
} else { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
171 |
/* Name will already be in UTF-8. */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
172 |
return strdup(_name_array[GB(id, 0, 9)]); |
5108
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
173 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
174 |
} |
dc67d70b5a45
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents:
5016
diff
changeset
|
175 |
|
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6417
diff
changeset
|
176 |
/* Calculate constants that depend on the landscape type. */ |
0 | 177 |
void InitializeLandscapeVariables(bool only_constants) |
178 |
{ |
|
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6222
diff
changeset
|
179 |
if (only_constants) return; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
180 |
|
9505 | 181 |
for (CargoID i = 0; i < NUM_CARGO; i++) { |
6417
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6222
diff
changeset
|
182 |
_cargo_payment_rates[i] = GetCargo(i)->initial_payment; |
26acff62d001
(svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents:
6222
diff
changeset
|
183 |
_cargo_payment_rates_frac[i] = 0; |
0 | 184 |
} |
185 |
} |
|
186 |
||
6573 | 187 |
static void Load_NAME() |
0 | 188 |
{ |
189 |
int index; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
190 |
|
0 | 191 |
while ((index = SlIterateArray()) != -1) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9599
diff
changeset
|
192 |
SlArray(_name_array[index], SlGetFieldLength(), SLE_UINT8); |
0 | 193 |
} |
194 |
} |
|
195 |
||
196 |
static const SaveLoadGlobVarList _date_desc[] = { |
|
4383
3dcf52b1efd9
(svn r6136) -Fix: _cur_year wasn't converting when reading pre-31 savegames, causing nasty desyncs
truelight
parents:
4347
diff
changeset
|
197 |
SLEG_CONDVAR(_date, SLE_FILE_U16 | SLE_VAR_I32, 0, 30), |
3dcf52b1efd9
(svn r6136) -Fix: _cur_year wasn't converting when reading pre-31 savegames, causing nasty desyncs
truelight
parents:
4347
diff
changeset
|
198 |
SLEG_CONDVAR(_date, SLE_INT32, 31, SL_MAX_VERSION), |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
199 |
SLEG_VAR(_date_fract, SLE_UINT16), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
200 |
SLEG_VAR(_tick_counter, SLE_UINT16), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
201 |
SLEG_VAR(_vehicle_id_ctr_day, SLE_UINT16), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
202 |
SLEG_VAR(_age_cargo_skip_counter, SLE_UINT8), |
6222 | 203 |
SLE_CONDNULL(1, 0, 45), |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
204 |
SLEG_CONDVAR(_cur_tileloop_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
205 |
SLEG_CONDVAR(_cur_tileloop_tile, SLE_UINT32, 6, SL_MAX_VERSION), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
206 |
SLEG_VAR(_disaster_delay, SLE_UINT16), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
207 |
SLEG_VAR(_station_tick_ctr, SLE_UINT16), |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
208 |
SLEG_VAR(_random.state[0], SLE_UINT32), |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
209 |
SLEG_VAR(_random.state[1], SLE_UINT32), |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
210 |
SLEG_CONDVAR(_cur_town_ctr, SLE_FILE_U8 | SLE_VAR_U32, 0, 9), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
211 |
SLEG_CONDVAR(_cur_town_ctr, SLE_UINT32, 10, SL_MAX_VERSION), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
212 |
SLEG_VAR(_cur_player_tick_index, SLE_FILE_U8 | SLE_VAR_U32), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
213 |
SLEG_VAR(_next_competitor_start, SLE_FILE_U16 | SLE_VAR_U32), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
214 |
SLEG_VAR(_trees_tick_ctr, SLE_UINT8), |
6557
8381016f71f3
(svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents:
6527
diff
changeset
|
215 |
SLEG_CONDVAR(_pause_game, SLE_UINT8, 4, SL_MAX_VERSION), |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
216 |
SLEG_CONDVAR(_cur_town_iter, SLE_UINT32, 11, SL_MAX_VERSION), |
3046
f81bee40701f
(svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents:
3033
diff
changeset
|
217 |
SLEG_END() |
0 | 218 |
}; |
219 |
||
6527
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6417
diff
changeset
|
220 |
/* Save load date related variables as well as persistent tick counters |
f584ab6d87f8
(svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents:
6417
diff
changeset
|
221 |
* XXX: currently some unrelated stuff is just put here */ |
6573 | 222 |
static void SaveLoad_DATE() |
0 | 223 |
{ |
224 |
SlGlobList(_date_desc); |
|
225 |
} |
|
226 |
||
227 |
||
228 |
static const SaveLoadGlobVarList _view_desc[] = { |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
229 |
SLEG_CONDVAR(_saved_scrollpos_x, SLE_FILE_I16 | SLE_VAR_I32, 0, 5), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
230 |
SLEG_CONDVAR(_saved_scrollpos_x, SLE_INT32, 6, SL_MAX_VERSION), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
231 |
SLEG_CONDVAR(_saved_scrollpos_y, SLE_FILE_I16 | SLE_VAR_I32, 0, 5), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
232 |
SLEG_CONDVAR(_saved_scrollpos_y, SLE_INT32, 6, SL_MAX_VERSION), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
233 |
SLEG_VAR(_saved_scrollpos_zoom, SLE_UINT8), |
3046
f81bee40701f
(svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents:
3033
diff
changeset
|
234 |
SLEG_END() |
0 | 235 |
}; |
236 |
||
6573 | 237 |
static void SaveLoad_VIEW() |
0 | 238 |
{ |
239 |
SlGlobList(_view_desc); |
|
240 |
} |
|
241 |
||
1218 | 242 |
static uint32 _map_dim_x; |
243 |
static uint32 _map_dim_y; |
|
244 |
||
245 |
static const SaveLoadGlobVarList _map_dimensions[] = { |
|
3046
f81bee40701f
(svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents:
3033
diff
changeset
|
246 |
SLEG_CONDVAR(_map_dim_x, SLE_UINT32, 6, SL_MAX_VERSION), |
f81bee40701f
(svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents:
3033
diff
changeset
|
247 |
SLEG_CONDVAR(_map_dim_y, SLE_UINT32, 6, SL_MAX_VERSION), |
f81bee40701f
(svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents:
3033
diff
changeset
|
248 |
SLEG_END() |
1218 | 249 |
}; |
250 |
||
6573 | 251 |
static void Save_MAPS() |
1218 | 252 |
{ |
1219
6a1f8d818d58
(svn r1723) Save the map size in tiles, not number of bits
tron
parents:
1218
diff
changeset
|
253 |
_map_dim_x = MapSizeX(); |
6a1f8d818d58
(svn r1723) Save the map size in tiles, not number of bits
tron
parents:
1218
diff
changeset
|
254 |
_map_dim_y = MapSizeY(); |
1218 | 255 |
SlGlobList(_map_dimensions); |
256 |
} |
|
257 |
||
6573 | 258 |
static void Load_MAPS() |
1218 | 259 |
{ |
260 |
SlGlobList(_map_dimensions); |
|
2051 | 261 |
AllocateMap(_map_dim_x, _map_dim_y); |
1218 | 262 |
} |
263 |
||
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
264 |
enum { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
265 |
MAP_SL_BUF_SIZE = 4096 |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
266 |
}; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
267 |
|
6573 | 268 |
static void Load_MAPT() |
2050
947934d248c5
(svn r2559) Cleaned up new saveload code for the map
ludde
parents:
2049
diff
changeset
|
269 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
270 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
271 |
TileIndex size = MapSize(); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
272 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
273 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
274 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
275 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].type_height = buf[j]; |
817
4f9377b7fd2b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
785
diff
changeset
|
276 |
} |
0 | 277 |
} |
278 |
||
6573 | 279 |
static void Save_MAPT() |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
280 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
281 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
282 |
TileIndex size = MapSize(); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
283 |
|
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
284 |
SlSetLength(size); |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
285 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
286 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].type_height; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
287 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
288 |
} |
0 | 289 |
} |
290 |
||
6573 | 291 |
static void Load_MAP1() |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
292 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
293 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
294 |
TileIndex size = MapSize(); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
295 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
296 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
297 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
298 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m1 = buf[j]; |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
299 |
} |
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
300 |
} |
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
301 |
|
6573 | 302 |
static void Save_MAP1() |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
303 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
304 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
305 |
TileIndex size = MapSize(); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
306 |
|
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
307 |
SlSetLength(size); |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
308 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
309 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m1; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
310 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
311 |
} |
0 | 312 |
} |
313 |
||
6573 | 314 |
static void Load_MAP2() |
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
315 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
316 |
SmallStackSafeStackAlloc<uint16, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
317 |
TileIndex size = MapSize(); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
318 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
319 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
320 |
SlArray(buf, MAP_SL_BUF_SIZE, |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
321 |
/* In those versions the m2 was 8 bits */ |
2685
00111d5ca47f
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2548
diff
changeset
|
322 |
CheckSavegameVersion(5) ? SLE_FILE_U8 | SLE_VAR_U16 : SLE_UINT16 |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
323 |
); |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
324 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m2 = buf[j]; |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
325 |
} |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
326 |
} |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
327 |
|
6573 | 328 |
static void Save_MAP2() |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
329 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
330 |
SmallStackSafeStackAlloc<uint16, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
331 |
TileIndex size = MapSize(); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
332 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
333 |
SlSetLength(size * sizeof(uint16)); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
334 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
335 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m2; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
336 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT16); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
337 |
} |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
338 |
} |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
339 |
|
6573 | 340 |
static void Load_MAP3() |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
341 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
342 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
343 |
TileIndex size = MapSize(); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
344 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
345 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
346 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
347 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m3 = buf[j]; |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
348 |
} |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
349 |
} |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
350 |
|
6573 | 351 |
static void Save_MAP3() |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
352 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
353 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
354 |
TileIndex size = MapSize(); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
355 |
|
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
356 |
SlSetLength(size); |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
357 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
358 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m3; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
359 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
360 |
} |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
361 |
} |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
362 |
|
6573 | 363 |
static void Load_MAP4() |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
364 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
365 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
366 |
TileIndex size = MapSize(); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
367 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
368 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
369 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
370 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m4 = buf[j]; |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
371 |
} |
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
372 |
} |
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
373 |
|
6573 | 374 |
static void Save_MAP4() |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
375 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
376 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
377 |
TileIndex size = MapSize(); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
378 |
|
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
379 |
SlSetLength(size); |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
380 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
381 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m4; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
382 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
383 |
} |
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
384 |
} |
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
385 |
|
6573 | 386 |
static void Load_MAP5() |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
387 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
388 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
389 |
TileIndex size = MapSize(); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
390 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
391 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
392 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
393 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m5 = buf[j]; |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
394 |
} |
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
395 |
} |
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
396 |
|
6573 | 397 |
static void Save_MAP5() |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
398 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
399 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
400 |
TileIndex size = MapSize(); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
401 |
|
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
402 |
SlSetLength(size); |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
403 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
404 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m5; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
405 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
2295
af67e1ea8687
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
406 |
} |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
407 |
} |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
408 |
|
6573 | 409 |
static void Load_MAP6() |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
410 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
411 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
412 |
TileIndex size = MapSize(); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
413 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
414 |
if (CheckSavegameVersion(42)) { |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
415 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
416 |
/* 1024, otherwise we overflow on 64x64 maps! */ |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
417 |
SlArray(buf, 1024, SLE_UINT8); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
418 |
for (uint j = 0; j != 1024; j++) { |
5847
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
419 |
_m[i++].m6 = GB(buf[j], 0, 2); |
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
420 |
_m[i++].m6 = GB(buf[j], 2, 2); |
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
421 |
_m[i++].m6 = GB(buf[j], 4, 2); |
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
422 |
_m[i++].m6 = GB(buf[j], 6, 2); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
423 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
424 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
425 |
} else { |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
426 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
427 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
428 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m6 = buf[j]; |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
429 |
} |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
430 |
} |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
431 |
} |
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
432 |
|
6573 | 433 |
static void Save_MAP6() |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
434 |
{ |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
435 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
436 |
TileIndex size = MapSize(); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
437 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
438 |
SlSetLength(size); |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
439 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
440 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m6; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
441 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1999
diff
changeset
|
442 |
} |
0 | 443 |
} |
444 |
||
9476 | 445 |
static void Load_MAP7() |
446 |
{ |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
447 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
448 |
TileIndex size = MapSize(); |
9476 | 449 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
450 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
451 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
452 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _me[i++].m7 = buf[j]; |
9476 | 453 |
} |
454 |
} |
|
455 |
||
456 |
static void Save_MAP7() |
|
457 |
{ |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
458 |
SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
459 |
TileIndex size = MapSize(); |
9476 | 460 |
|
461 |
SlSetLength(size); |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
462 |
for (TileIndex i = 0; i != size;) { |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
463 |
for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _me[i++].m7; |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
464 |
SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8); |
9476 | 465 |
} |
466 |
} |
|
0 | 467 |
|
6573 | 468 |
static void Save_CHTS() |
0 | 469 |
{ |
470 |
byte count = sizeof(_cheats)/sizeof(Cheat); |
|
471 |
Cheat* cht = (Cheat*) &_cheats; |
|
472 |
Cheat* cht_last = &cht[count]; |
|
473 |
||
2951 | 474 |
SlSetLength(count * 2); |
475 |
for (; cht != cht_last; cht++) { |
|
0 | 476 |
SlWriteByte(cht->been_used); |
477 |
SlWriteByte(cht->value); |
|
478 |
} |
|
479 |
} |
|
480 |
||
6573 | 481 |
static void Load_CHTS() |
0 | 482 |
{ |
2989 | 483 |
Cheat* cht = (Cheat*)&_cheats; |
484 |
uint count = SlGetFieldLength() / 2; |
|
0 | 485 |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9837
diff
changeset
|
486 |
for (uint i = 0; i < count; i++) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
487 |
cht[i].been_used = (SlReadByte() != 0); |
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
488 |
cht[i].value = (SlReadByte() != 0); |
0 | 489 |
} |
490 |
} |
|
491 |
||
492 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
493 |
extern const ChunkHandler _misc_chunk_handlers[] = { |
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
494 |
{ 'MAPS', Save_MAPS, Load_MAPS, CH_RIFF }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
495 |
{ 'MAPT', Save_MAPT, Load_MAPT, CH_RIFF }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
496 |
{ 'MAPO', Save_MAP1, Load_MAP1, CH_RIFF }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
497 |
{ 'MAP2', Save_MAP2, Load_MAP2, CH_RIFF }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
498 |
{ 'M3LO', Save_MAP3, Load_MAP3, CH_RIFF }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
499 |
{ 'M3HI', Save_MAP4, Load_MAP4, CH_RIFF }, |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
500 |
{ 'MAP5', Save_MAP5, Load_MAP5, CH_RIFF }, |
5847
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
501 |
{ 'MAPE', Save_MAP6, Load_MAP6, CH_RIFF }, |
9476 | 502 |
{ 'MAP7', Save_MAP7, Load_MAP7, CH_RIFF }, |
0 | 503 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
504 |
{ 'NAME', NULL, Load_NAME, CH_ARRAY}, |
0 | 505 |
{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, CH_RIFF}, |
506 |
{ 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, CH_RIFF}, |
|
4344
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
507 |
{ 'CHTS', Save_CHTS, Load_CHTS, CH_RIFF | CH_LAST} |
0 | 508 |
}; |