author | belugas |
Tue, 01 Jan 2008 14:20:48 +0000 | |
changeset 8667 | c916a5375166 |
parent 8640 | 1e93b81e96d2 |
child 8710 | 52015340050c |
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" |
6949
72d11a1e1e60
(svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents:
6676
diff
changeset
|
8 |
#include "landscape.h" |
2548
97ada3bd2702
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2484
diff
changeset
|
9 |
#include "news.h" |
2191 | 10 |
#include "player.h" |
1375
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
11 |
#include "string.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
500
diff
changeset
|
12 |
#include "table/strings.h" |
1914
5ede46fd496f
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
13 |
#include "table/sprites.h" |
0 | 14 |
#include "saveload.h" |
842 | 15 |
#include "engine.h" |
1752
cdbfb2f23e72
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1595
diff
changeset
|
16 |
#include "vehicle_gui.h" |
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2112
diff
changeset
|
17 |
#include "variables.h" |
2706
d31bd0aa0096
(svn r3250) -Fix: AIs weren't uninitialized when a new game was loaded
truelight
parents:
2685
diff
changeset
|
18 |
#include "ai/ai.h" |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
19 |
#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
|
20 |
#include "cargotype.h" |
7139
4ae3ab180d05
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
6987
diff
changeset
|
21 |
#include "group.h" |
8385
aedd7656cfd1
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
8122
diff
changeset
|
22 |
#include "viewport.h" |
8615
6b91ca653bad
(svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents:
8467
diff
changeset
|
23 |
#include "economy_func.h" |
8619
c2434269c3eb
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
8615
diff
changeset
|
24 |
#include "zoom_func.h" |
8627
448ebf3a8291
(svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents:
8619
diff
changeset
|
25 |
#include "functions.h" |
8635
3bbb6f87fced
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents:
8627
diff
changeset
|
26 |
#include "map_func.h" |
8636
2b158acb649c
(svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents:
8635
diff
changeset
|
27 |
#include "date_func.h" |
8640
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8636
diff
changeset
|
28 |
#include "vehicle_func.h" |
1e93b81e96d2
(svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents:
8636
diff
changeset
|
29 |
#include "texteff.hpp" |
0 | 30 |
|
1328
e069d2db0e4c
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1313
diff
changeset
|
31 |
char _name_array[512][32]; |
0 | 32 |
|
6573 | 33 |
void InitializeVehicles(); |
34 |
void InitializeWaypoints(); |
|
35 |
void InitializeDepots(); |
|
36 |
void InitializeEngines(); |
|
37 |
void InitializeOrders(); |
|
38 |
void InitializeClearLand(); |
|
39 |
void InitializeRailGui(); |
|
40 |
void InitializeRoadGui(); |
|
41 |
void InitializeAirportGui(); |
|
42 |
void InitializeDockGui(); |
|
43 |
void InitializeIndustries(); |
|
44 |
void InitializeMainGui(); |
|
45 |
void InitializeTowns(); |
|
46 |
void InitializeTrees(); |
|
47 |
void InitializeSigns(); |
|
48 |
void InitializeStations(); |
|
7506
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7375
diff
changeset
|
49 |
void InitializeCargoPackets(); |
6573 | 50 |
static void InitializeNameMgr(); |
51 |
void InitializePlayers(); |
|
52 |
static void InitializeCheats(); |
|
53 |
void InitializeNPF(); |
|
0 | 54 |
|
2828
996de8e891c7
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2706
diff
changeset
|
55 |
void InitializeGame(int mode, uint size_x, uint size_y) |
0 | 56 |
{ |
2051 | 57 |
AllocateMap(size_x, size_y); |
58 |
||
842 | 59 |
AddTypeToEngines(); // make sure all engines have a type |
915 | 60 |
|
8385
aedd7656cfd1
(svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents:
8122
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; |
|
7514
98a024616010
(svn r10276) -Codechange: made a counter based on milliseconds and independent of the game-state to base double-click and TGP Generation Process on
truelight
parents:
7506
diff
changeset
|
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(); |
7139
4ae3ab180d05
(svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents:
6987
diff
changeset
|
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(); |
7506
e52d89f5c7c1
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents:
7375
diff
changeset
|
92 |
InitializeCargoPackets(); |
0 | 93 |
InitializeIndustries(); |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
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(); |
|
7950
3d3ed007127a
(svn r10932) -Codechange: replace "text" with "chat" for the chat related function and variables.
rubidium
parents:
7514
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 |
void DeleteName(StringID id) |
121 |
{ |
|
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
|
122 |
if (IsCustomName(id)) { |
0 | 123 |
memset(_name_array[id & 0x1FF], 0, sizeof(_name_array[id & 0x1FF])); |
124 |
} |
|
125 |
} |
|
126 |
||
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4862
diff
changeset
|
127 |
char *GetName(char *buff, StringID id, const char* last) |
0 | 128 |
{ |
4912
d04b3f2bca70
(svn r6884) -Codechange: Add strict bounds checking in string formatting system.
Darkvater
parents:
4862
diff
changeset
|
129 |
return strecpy(buff, _name_array[id & ~0x600], last); |
0 | 130 |
} |
131 |
||
132 |
||
6573 | 133 |
static void InitializeCheats() |
0 | 134 |
{ |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
135 |
memset(&_cheats, 0, sizeof(Cheats)); |
0 | 136 |
} |
137 |
||
138 |
||
6573 | 139 |
static void InitializeNameMgr() |
0 | 140 |
{ |
141 |
memset(_name_array, 0, sizeof(_name_array)); |
|
142 |
} |
|
143 |
||
1328
e069d2db0e4c
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1313
diff
changeset
|
144 |
StringID RealAllocateName(const char *name, byte skip, bool check_double) |
0 | 145 |
{ |
1375
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
146 |
char (*free_item)[lengthof(*_name_array)] = NULL; |
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
147 |
char (*i)[lengthof(*_name_array)]; |
0 | 148 |
|
1375
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
149 |
for (i = _name_array; i != endof(_name_array); ++i) { |
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
150 |
if ((*i)[0] == '\0') { |
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
151 |
if (free_item == NULL) free_item = i; |
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
152 |
} else if (check_double && strncmp(*i, name, lengthof(*i) - 1) == 0) { |
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
153 |
_error_message = STR_0132_CHOSEN_NAME_IN_USE_ALREADY; |
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
154 |
return 0; |
0 | 155 |
} |
156 |
} |
|
157 |
||
1375
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
158 |
if (free_item != NULL) { |
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
159 |
ttd_strlcpy(*free_item, name, lengthof(*free_item)); |
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
160 |
return (free_item - _name_array) | 0x7800 | (skip << 8); |
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
161 |
} else { |
0 | 162 |
_error_message = STR_0131_TOO_MANY_NAMES_DEFINED; |
163 |
return 0; |
|
164 |
} |
|
165 |
} |
|
166 |
||
6573 | 167 |
void ConvertNameArray() |
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
|
168 |
{ |
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
|
169 |
uint i; |
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
|
170 |
|
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
|
171 |
for (i = 0; i < lengthof(_name_array); i++) { |
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
|
172 |
const char *strfrom = _name_array[i]; |
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 |
char tmp[sizeof(*_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
|
174 |
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
|
175 |
|
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
|
176 |
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
|
177 |
WChar c = (byte)*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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
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
|
184 |
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
|
185 |
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
|
186 |
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
|
187 |
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
|
188 |
} |
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
|
189 |
if (strto + Utf8CharLen(c) > lastof(tmp)) 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
|
190 |
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
|
191 |
} |
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
|
192 |
|
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
|
193 |
/* 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
|
194 |
*strto = '\0'; |
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
|
195 |
memcpy(_name_array[i], tmp, sizeof(*_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
|
196 |
} |
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
|
197 |
} |
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
|
198 |
|
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
|
199 |
/* Calculate constants that depend on the landscape type. */ |
0 | 200 |
void InitializeLandscapeVariables(bool only_constants) |
201 |
{ |
|
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
|
202 |
if (only_constants) return; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
203 |
|
6676
30aea9ac89bc
(svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents:
6658
diff
changeset
|
204 |
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
|
205 |
_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
|
206 |
_cargo_payment_rates_frac[i] = 0; |
0 | 207 |
} |
208 |
} |
|
209 |
||
210 |
||
6573 | 211 |
static void Save_NAME() |
0 | 212 |
{ |
213 |
int i; |
|
214 |
||
1375
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
215 |
for (i = 0; i != lengthof(_name_array); ++i) { |
f13d8247928c
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
216 |
if (_name_array[i][0] != '\0') { |
0 | 217 |
SlSetArrayIndex(i); |
4321
b763b7007162
(svn r5974) -Codechange: added casts all around the place to make Windows 64bit happy (michi_cc)
truelight
parents:
4300
diff
changeset
|
218 |
SlArray(_name_array[i], (uint)strlen(_name_array[i]), SLE_UINT8); |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
219 |
} |
0 | 220 |
} |
221 |
} |
|
222 |
||
6573 | 223 |
static void Load_NAME() |
0 | 224 |
{ |
225 |
int index; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
226 |
|
0 | 227 |
while ((index = SlIterateArray()) != -1) { |
6987
b0f13039bda2
(svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents:
6949
diff
changeset
|
228 |
SlArray(_name_array[index], SlGetFieldLength(), SLE_UINT8); |
0 | 229 |
} |
230 |
} |
|
231 |
||
232 |
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
|
233 |
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
|
234 |
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
|
235 |
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
|
236 |
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
|
237 |
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
|
238 |
SLEG_VAR(_age_cargo_skip_counter, SLE_UINT8), |
6222 | 239 |
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
|
240 |
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
|
241 |
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
|
242 |
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
|
243 |
SLEG_VAR(_station_tick_ctr, 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
|
244 |
SLEG_VAR(_random_seeds[0][0], SLE_UINT32), |
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
|
245 |
SLEG_VAR(_random_seeds[0][1], SLE_UINT32), |
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
|
246 |
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
|
247 |
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
|
248 |
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
|
249 |
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
|
250 |
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
|
251 |
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
|
252 |
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
|
253 |
SLEG_END() |
0 | 254 |
}; |
255 |
||
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
|
256 |
/* 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
|
257 |
* XXX: currently some unrelated stuff is just put here */ |
6573 | 258 |
static void SaveLoad_DATE() |
0 | 259 |
{ |
260 |
SlGlobList(_date_desc); |
|
261 |
} |
|
262 |
||
263 |
||
264 |
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
|
265 |
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
|
266 |
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
|
267 |
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
|
268 |
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
|
269 |
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
|
270 |
SLEG_END() |
0 | 271 |
}; |
272 |
||
6573 | 273 |
static void SaveLoad_VIEW() |
0 | 274 |
{ |
275 |
SlGlobList(_view_desc); |
|
276 |
} |
|
277 |
||
1218 | 278 |
static uint32 _map_dim_x; |
279 |
static uint32 _map_dim_y; |
|
280 |
||
281 |
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
|
282 |
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
|
283 |
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
|
284 |
SLEG_END() |
1218 | 285 |
}; |
286 |
||
6573 | 287 |
static void Save_MAPS() |
1218 | 288 |
{ |
1219
6a1f8d818d58
(svn r1723) Save the map size in tiles, not number of bits
tron
parents:
1218
diff
changeset
|
289 |
_map_dim_x = MapSizeX(); |
6a1f8d818d58
(svn r1723) Save the map size in tiles, not number of bits
tron
parents:
1218
diff
changeset
|
290 |
_map_dim_y = MapSizeY(); |
1218 | 291 |
SlGlobList(_map_dimensions); |
292 |
} |
|
293 |
||
6573 | 294 |
static void Load_MAPS() |
1218 | 295 |
{ |
296 |
SlGlobList(_map_dimensions); |
|
2051 | 297 |
AllocateMap(_map_dim_x, _map_dim_y); |
1218 | 298 |
} |
299 |
||
6573 | 300 |
static void Load_MAPT() |
2050
947934d248c5
(svn r2559) Cleaned up new saveload code for the map
ludde
parents:
2049
diff
changeset
|
301 |
{ |
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
|
302 |
uint size = MapSize(); |
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 |
uint i; |
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
|
304 |
|
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
|
305 |
for (i = 0; i != size;) { |
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 |
byte buf[4096]; |
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 |
uint j; |
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
|
308 |
|
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
|
309 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
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
|
310 |
for (j = 0; j != lengthof(buf); 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
|
311 |
} |
0 | 312 |
} |
313 |
||
6573 | 314 |
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
|
315 |
{ |
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
|
316 |
uint size = MapSize(); |
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
|
317 |
uint i; |
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
|
318 |
|
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
|
319 |
SlSetLength(size); |
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
|
320 |
for (i = 0; i != size;) { |
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
|
321 |
byte buf[4096]; |
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
|
322 |
uint j; |
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
|
323 |
|
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
|
324 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].type_height; |
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
|
325 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
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
|
326 |
} |
0 | 327 |
} |
328 |
||
6573 | 329 |
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
|
330 |
{ |
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
|
331 |
uint size = MapSize(); |
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
|
332 |
uint i; |
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
|
333 |
|
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
|
334 |
for (i = 0; i != size;) { |
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
|
335 |
byte buf[4096]; |
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
|
336 |
uint j; |
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
|
337 |
|
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
|
338 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
2360
09e42e4ee139
(svn r2886) Rename the "owner" attribute to "m1", because when it stores an owner it is accessed by [GS]etOwner anyway and when it doesn't store an owner, but arbitrary data, accessing a field called "owner" is confusing.
tron
parents:
2308
diff
changeset
|
339 |
for (j = 0; j != lengthof(buf); 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
|
340 |
} |
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
|
341 |
} |
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
|
342 |
|
6573 | 343 |
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
|
344 |
{ |
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
|
345 |
uint size = MapSize(); |
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
|
346 |
uint i; |
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
|
347 |
|
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 |
SlSetLength(size); |
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
|
349 |
for (i = 0; i != size;) { |
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
|
350 |
byte buf[4096]; |
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
|
351 |
uint j; |
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
|
352 |
|
2360
09e42e4ee139
(svn r2886) Rename the "owner" attribute to "m1", because when it stores an owner it is accessed by [GS]etOwner anyway and when it doesn't store an owner, but arbitrary data, accessing a field called "owner" is confusing.
tron
parents:
2308
diff
changeset
|
353 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m1; |
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
|
354 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
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 |
} |
0 | 356 |
} |
357 |
||
6573 | 358 |
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
|
359 |
{ |
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
|
360 |
uint size = MapSize(); |
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 |
uint i; |
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 |
|
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
|
363 |
for (i = 0; i != size;) { |
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 |
uint16 buf[4096]; |
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
|
365 |
uint j; |
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
|
366 |
|
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
|
367 |
SlArray(buf, lengthof(buf), |
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
|
368 |
/* 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
|
369 |
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
|
370 |
); |
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
|
371 |
for (j = 0; j != lengthof(buf); j++) _m[i++].m2 = buf[j]; |
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
|
372 |
} |
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
|
373 |
} |
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
|
374 |
|
6573 | 375 |
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
|
376 |
{ |
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
|
377 |
uint size = MapSize(); |
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
|
378 |
uint i; |
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
|
379 |
|
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
|
380 |
SlSetLength(size * sizeof(_m[0].m2)); |
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
|
381 |
for (i = 0; i != size;) { |
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
|
382 |
uint16 buf[4096]; |
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
|
383 |
uint j; |
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
|
384 |
|
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
|
385 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m2; |
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
|
386 |
SlArray(buf, lengthof(buf), SLE_UINT16); |
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
|
387 |
} |
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
|
388 |
} |
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
|
389 |
|
6573 | 390 |
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
|
391 |
{ |
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
|
392 |
uint size = MapSize(); |
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
|
393 |
uint i; |
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 |
for (i = 0; i != size;) { |
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 |
byte buf[4096]; |
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
|
397 |
uint j; |
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 |
|
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
|
399 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
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
|
400 |
for (j = 0; j != lengthof(buf); j++) _m[i++].m3 = buf[j]; |
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 |
} |
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
|
402 |
} |
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
|
403 |
|
6573 | 404 |
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
|
405 |
{ |
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 |
uint size = MapSize(); |
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
|
407 |
uint i; |
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
|
408 |
|
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
|
409 |
SlSetLength(size); |
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
|
410 |
for (i = 0; i != size;) { |
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
|
411 |
byte buf[4096]; |
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
|
412 |
uint j; |
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
|
413 |
|
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
|
414 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m3; |
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
|
415 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
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
|
416 |
} |
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
|
417 |
} |
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
|
418 |
|
6573 | 419 |
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
|
420 |
{ |
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
|
421 |
uint size = MapSize(); |
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
|
422 |
uint i; |
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
|
423 |
|
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
|
424 |
for (i = 0; i != size;) { |
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
|
425 |
byte buf[4096]; |
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
|
426 |
uint j; |
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
|
427 |
|
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
|
428 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
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
|
429 |
for (j = 0; j != lengthof(buf); j++) _m[i++].m4 = buf[j]; |
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
|
430 |
} |
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
|
431 |
} |
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
|
432 |
|
6573 | 433 |
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
|
434 |
{ |
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
|
435 |
uint size = MapSize(); |
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
|
436 |
uint i; |
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
|
437 |
|
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
|
438 |
SlSetLength(size); |
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
|
439 |
for (i = 0; i != size;) { |
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
|
440 |
byte buf[4096]; |
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
|
441 |
uint j; |
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
|
442 |
|
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
|
443 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m4; |
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
|
444 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
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
|
445 |
} |
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
|
446 |
} |
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
|
447 |
|
6573 | 448 |
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
|
449 |
{ |
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
|
450 |
uint size = MapSize(); |
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
|
451 |
uint i; |
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
|
452 |
|
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
|
453 |
for (i = 0; i != size;) { |
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
|
454 |
byte buf[4096]; |
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
|
455 |
uint j; |
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
|
456 |
|
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
|
457 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
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
|
458 |
for (j = 0; j != lengthof(buf); j++) _m[i++].m5 = buf[j]; |
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
|
459 |
} |
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
|
460 |
} |
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
|
461 |
|
6573 | 462 |
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
|
463 |
{ |
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
|
464 |
uint size = MapSize(); |
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
|
465 |
uint i; |
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
|
466 |
|
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
|
467 |
SlSetLength(size); |
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
|
468 |
for (i = 0; i != size;) { |
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
|
469 |
byte buf[4096]; |
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
|
470 |
uint j; |
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
|
471 |
|
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
|
472 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m5; |
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
|
473 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
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
|
474 |
} |
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
|
475 |
} |
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
|
476 |
|
6573 | 477 |
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
|
478 |
{ |
5847
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
479 |
/* Still available for loading old games */ |
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
|
480 |
uint size = MapSize(); |
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
|
481 |
uint i; |
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
|
482 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
483 |
if (CheckSavegameVersion(42)) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
484 |
for (i = 0; i != size;) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
485 |
uint8 buf[1024]; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
486 |
uint 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
|
487 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
488 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
489 |
for (j = 0; j != lengthof(buf); j++) { |
5847
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
490 |
_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
|
491 |
_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
|
492 |
_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
|
493 |
_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
|
494 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
495 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
496 |
} else { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
497 |
for (i = 0; i != size;) { |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
498 |
byte buf[4096]; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
499 |
uint j; |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
500 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
501 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
5847
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
502 |
for (j = 0; j != lengthof(buf); 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
|
503 |
} |
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
|
504 |
} |
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
|
505 |
} |
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
|
506 |
|
6573 | 507 |
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
|
508 |
{ |
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
|
509 |
uint size = MapSize(); |
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
|
510 |
uint i; |
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
|
511 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
512 |
SlSetLength(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
|
513 |
for (i = 0; i != size;) { |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
5108
diff
changeset
|
514 |
uint8 buf[4096]; |
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
|
515 |
uint j; |
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
|
516 |
|
5847
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
517 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m6; |
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
|
518 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
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
|
519 |
} |
0 | 520 |
} |
521 |
||
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
522 |
static void Load_MAP7() |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
523 |
{ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
524 |
uint size = MapSize(); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
525 |
uint i; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
526 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
527 |
for (i = 0; i != size;) { |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
528 |
uint8 buf[4096]; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
529 |
uint j; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
530 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
531 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
532 |
for (j = 0; j != lengthof(buf); j++) _me[i++].m7 = buf[j]; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
533 |
} |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
534 |
} |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
535 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
536 |
static void Save_MAP7() |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
537 |
{ |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
538 |
uint size = MapSize(); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
539 |
uint i; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
540 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
541 |
SlSetLength(size); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
542 |
for (i = 0; i != size;) { |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
543 |
uint8 buf[4096]; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
544 |
uint j; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
545 |
|
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
546 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _me[i++].m7; |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
547 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
548 |
} |
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
549 |
} |
0 | 550 |
|
6573 | 551 |
static void Save_CHTS() |
0 | 552 |
{ |
553 |
byte count = sizeof(_cheats)/sizeof(Cheat); |
|
554 |
Cheat* cht = (Cheat*) &_cheats; |
|
555 |
Cheat* cht_last = &cht[count]; |
|
556 |
||
2951 | 557 |
SlSetLength(count * 2); |
558 |
for (; cht != cht_last; cht++) { |
|
0 | 559 |
SlWriteByte(cht->been_used); |
560 |
SlWriteByte(cht->value); |
|
561 |
} |
|
562 |
} |
|
563 |
||
6573 | 564 |
static void Load_CHTS() |
0 | 565 |
{ |
2989 | 566 |
Cheat* cht = (Cheat*)&_cheats; |
567 |
uint count = SlGetFieldLength() / 2; |
|
568 |
uint i; |
|
0 | 569 |
|
2989 | 570 |
for (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
|
571 |
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
|
572 |
cht[i].value = (SlReadByte() != 0); |
0 | 573 |
} |
574 |
} |
|
575 |
||
576 |
||
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
577 |
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
|
578 |
{ '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
|
579 |
{ '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
|
580 |
{ '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
|
581 |
{ '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
|
582 |
{ '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
|
583 |
{ '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
|
584 |
{ '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
|
585 |
{ 'MAPE', Save_MAP6, Load_MAP6, CH_RIFF }, |
6658
59048224be55
(svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents:
6573
diff
changeset
|
586 |
{ 'MAP7', Save_MAP7, Load_MAP7, CH_RIFF }, |
0 | 587 |
|
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
|
588 |
{ 'NAME', Save_NAME, Load_NAME, CH_ARRAY}, |
0 | 589 |
{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, CH_RIFF}, |
590 |
{ '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
|
591 |
{ 'CHTS', Save_CHTS, Load_CHTS, CH_RIFF | CH_LAST} |
0 | 592 |
}; |