author | tron |
Wed, 01 Feb 2006 07:36:15 +0000 | |
changeset 2952 | 58522ed8f0f1 |
parent 2951 | 2de6d3a59743 |
child 2989 | 916f9443345f |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1881
diff
changeset
|
4 |
#include "openttd.h" |
2308 | 5 |
#include "currency.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
2548
49c8a096033f
(svn r3077) static, const, bracing, indentation, 0 -> '\0'/NULL, typos in comments, excess empty lines, minor other changes
tron
parents:
2484
diff
changeset
|
7 |
#include "news.h" |
2191 | 8 |
#include "player.h" |
1375
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
9 |
#include "string.h" |
507
04b5403aaf6b
(svn r815) Include strings.h only in the files which need it.
tron
parents:
500
diff
changeset
|
10 |
#include "table/strings.h" |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
11 |
#include "table/sprites.h" |
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
543
diff
changeset
|
12 |
#include "map.h" |
0 | 13 |
#include "vehicle.h" |
14 |
#include "saveload.h" |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
15 |
#include "network.h" |
690
3afcad69d4f7
(svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents:
679
diff
changeset
|
16 |
#include "network_data.h" |
3afcad69d4f7
(svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents:
679
diff
changeset
|
17 |
#include "network_server.h" |
842 | 18 |
#include "engine.h" |
1752
d65cd19f7117
(svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents:
1595
diff
changeset
|
19 |
#include "vehicle_gui.h" |
2159
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2112
diff
changeset
|
20 |
#include "variables.h" |
2706
fc872b9b17a7
(svn r3250) -Fix: AIs weren't uninitialized when a new game was loaded
truelight
parents:
2685
diff
changeset
|
21 |
#include "ai/ai.h" |
0 | 22 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
23 |
extern void StartupEconomy(void); |
0 | 24 |
|
1328
eacd8225ed42
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1313
diff
changeset
|
25 |
char _name_array[512][32]; |
0 | 26 |
|
2073 | 27 |
#ifndef MERSENNE_TWISTER |
28 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
29 |
#ifdef RANDOM_DEBUG |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
30 |
#include "network_data.h" |
1120
047e8b16a954
(svn r1621) -Fix: fixed some compiler warnings for the random-debug-switch
truelight
parents:
1095
diff
changeset
|
31 |
uint32 DoRandom(int line, const char *file) |
2073 | 32 |
#else // RANDOM_DEBUG |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
33 |
uint32 Random(void) |
2073 | 34 |
#endif // RANDOM_DEBUG |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
35 |
{ |
1121
8a7e7ace154f
(svn r1622) -Fix: variables can't be defined after a statement.. (Igor2Code)
truelight
parents:
1120
diff
changeset
|
36 |
|
8a7e7ace154f
(svn r1622) -Fix: variables can't be defined after a statement.. (Igor2Code)
truelight
parents:
1120
diff
changeset
|
37 |
uint32 s; |
8a7e7ace154f
(svn r1622) -Fix: variables can't be defined after a statement.. (Igor2Code)
truelight
parents:
1120
diff
changeset
|
38 |
uint32 t; |
8a7e7ace154f
(svn r1622) -Fix: variables can't be defined after a statement.. (Igor2Code)
truelight
parents:
1120
diff
changeset
|
39 |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
40 |
#ifdef RANDOM_DEBUG |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
41 |
if (_networking && (DEREF_CLIENT(0)->status != STATUS_INACTIVE || !_network_server)) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
42 |
printf("Random [%d/%d] %s:%d\n",_frame_counter, _current_player, file, line); |
260
4819bcce8389
(svn r266) -Fix: hopefully fixed the desync problem nicely (and reverted the
truelight
parents:
256
diff
changeset
|
43 |
#endif |
4819bcce8389
(svn r266) -Fix: hopefully fixed the desync problem nicely (and reverted the
truelight
parents:
256
diff
changeset
|
44 |
|
1121
8a7e7ace154f
(svn r1622) -Fix: variables can't be defined after a statement.. (Igor2Code)
truelight
parents:
1120
diff
changeset
|
45 |
s = _random_seeds[0][0]; |
8a7e7ace154f
(svn r1622) -Fix: variables can't be defined after a statement.. (Igor2Code)
truelight
parents:
1120
diff
changeset
|
46 |
t = _random_seeds[0][1]; |
1446
c95d3cb58985
(svn r1950) Fix: A slight adjustment in the DoRandom() function which however causes dramatic improvement in the distribution of random numbers.
pasky
parents:
1375
diff
changeset
|
47 |
_random_seeds[0][0] = s + ROR(t ^ 0x1234567F, 7) + 1; |
c95d3cb58985
(svn r1950) Fix: A slight adjustment in the DoRandom() function which however causes dramatic improvement in the distribution of random numbers.
pasky
parents:
1375
diff
changeset
|
48 |
return _random_seeds[0][1] = ROR(s, 3) - 1; |
0 | 49 |
} |
2073 | 50 |
#endif // MERSENNE_TWISTER |
0 | 51 |
|
2073 | 52 |
#if defined(RANDOM_DEBUG) && !defined(MERSENNE_TWISTER) |
1120
047e8b16a954
(svn r1621) -Fix: fixed some compiler warnings for the random-debug-switch
truelight
parents:
1095
diff
changeset
|
53 |
uint DoRandomRange(uint max, int line, const char *file) |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
54 |
{ |
2484
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
tron
parents:
2430
diff
changeset
|
55 |
return GB(DoRandom(line, file), 0, 16) * max >> 16; |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
56 |
} |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
57 |
#else |
0 | 58 |
uint RandomRange(uint max) |
59 |
{ |
|
2484
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
tron
parents:
2430
diff
changeset
|
60 |
return GB(Random(), 0, 16) * max >> 16; |
0 | 61 |
} |
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
62 |
#endif |
0 | 63 |
|
2073 | 64 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
65 |
uint32 InteractiveRandom(void) |
0 | 66 |
{ |
206 | 67 |
uint32 t = _random_seeds[1][1]; |
68 |
uint32 s = _random_seeds[1][0]; |
|
1446
c95d3cb58985
(svn r1950) Fix: A slight adjustment in the DoRandom() function which however causes dramatic improvement in the distribution of random numbers.
pasky
parents:
1375
diff
changeset
|
69 |
_random_seeds[1][0] = s + ROR(t ^ 0x1234567F, 7) + 1; |
c95d3cb58985
(svn r1950) Fix: A slight adjustment in the DoRandom() function which however causes dramatic improvement in the distribution of random numbers.
pasky
parents:
1375
diff
changeset
|
70 |
return _random_seeds[1][1] = ROR(s, 3) - 1; |
206 | 71 |
} |
72 |
||
239 | 73 |
uint InteractiveRandomRange(uint max) |
74 |
{ |
|
2484
0e45d70ae908
(svn r3010) Get rid of quite some dubious casts, either by using GB(), proper types or just removing them
tron
parents:
2430
diff
changeset
|
75 |
return GB(InteractiveRandom(), 0, 16) * max >> 16; |
239 | 76 |
} |
77 |
||
0 | 78 |
void SetDate(uint date) |
79 |
{ |
|
80 |
YearMonthDay ymd; |
|
81 |
ConvertDayToYMD(&ymd, _date = date); |
|
82 |
_cur_year = ymd.year; |
|
83 |
_cur_month = ymd.month; |
|
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
695
diff
changeset
|
84 |
#ifdef ENABLE_NETWORK |
2861
e42d249af3cb
(svn r3409) - Change the server advertisement interval to use the frame counter instead
peter1138
parents:
2848
diff
changeset
|
85 |
_network_last_advertise_frame = 0; |
e42d249af3cb
(svn r3409) - Change the server advertisement interval to use the frame counter instead
peter1138
parents:
2848
diff
changeset
|
86 |
_network_need_advertise = true; |
764
7e1e17b7c7d4
(svn r1227) -Add: Ingame Server-list (select Internet, then Find Servers)
truelight
parents:
695
diff
changeset
|
87 |
#endif /* ENABLE_NETWORK */ |
0 | 88 |
} |
89 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
90 |
void InitializeVehicles(void); |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1538
diff
changeset
|
91 |
void InitializeWaypoints(void); |
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1309
diff
changeset
|
92 |
void InitializeDepot(void); |
2848 | 93 |
void InitializeEngines(void); |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
94 |
void InitializeOrders(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
95 |
void InitializeClearLand(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
96 |
void InitializeRail(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
97 |
void InitializeRailGui(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
98 |
void InitializeRoad(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
99 |
void InitializeRoadGui(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
100 |
void InitializeAirportGui(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
101 |
void InitializeDock(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
102 |
void InitializeDockGui(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
103 |
void InitializeIndustries(void); |
2051 | 104 |
void InitializeLandscape(void); |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
105 |
void InitializeTowns(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
106 |
void InitializeTrees(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
107 |
void InitializeSigns(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
108 |
void InitializeStations(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
109 |
static void InitializeNameMgr(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
110 |
void InitializePlayers(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
111 |
static void InitializeCheats(void); |
1247 | 112 |
void InitializeNPF(void); |
0 | 113 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
114 |
void GenerateLandscape(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
115 |
void GenerateClearTile(void); |
0 | 116 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
117 |
void GenerateIndustries(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
118 |
void GenerateUnmovables(void); |
2430
b8bb9d74253b
(svn r2956) - Fix: [ 1253736 ] creating many town crash to desktop. Now it 'dies' with an ingame error message informing the gamer if it couldn't generate any towns in user-space. Still if it happens during new-game generation it crashes since we don't yet have actions to do in such a circumstance.
Darkvater
parents:
2360
diff
changeset
|
119 |
bool GenerateTowns(void); |
0 | 120 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
121 |
void StartupPlayers(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
122 |
void StartupDisasters(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
123 |
void GenerateTrees(void); |
0 | 124 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
125 |
void ConvertGroundTilesIntoWaterTiles(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
126 |
|
2828
342f02f7c0d4
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2706
diff
changeset
|
127 |
void InitializeGame(int mode, uint size_x, uint size_y) |
0 | 128 |
{ |
2051 | 129 |
AllocateMap(size_x, size_y); |
130 |
||
842 | 131 |
AddTypeToEngines(); // make sure all engines have a type |
915 | 132 |
|
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
133 |
SetObjectToPlace(SPR_CURSOR_ZZZ, 0, 0, 0); |
0 | 134 |
|
135 |
_pause = 0; |
|
136 |
_fast_forward = 0; |
|
137 |
_tick_counter = 0; |
|
138 |
_date_fract = 0; |
|
139 |
_cur_tileloop_tile = 0; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
140 |
|
2828
342f02f7c0d4
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2706
diff
changeset
|
141 |
if ((mode & IG_DATE_RESET) == IG_DATE_RESET) { |
0 | 142 |
uint starting = ConvertIntDate(_patches.starting_date); |
2951 | 143 |
if (starting == (uint)-1) starting = 10958; |
0 | 144 |
SetDate(starting); |
145 |
} |
|
146 |
||
2848 | 147 |
InitializeEngines(); |
0 | 148 |
InitializeVehicles(); |
1542
62a03537ad0b
(svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents:
1538
diff
changeset
|
149 |
InitializeWaypoints(); |
1313
f1013ec3d318
(svn r1817) -Codechange: Moved depot-functions to depot.c
truelight
parents:
1309
diff
changeset
|
150 |
InitializeDepot(); |
1024
5e446b5b3ec5
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents:
1009
diff
changeset
|
151 |
InitializeOrders(); |
0 | 152 |
|
153 |
InitNewsItemStructs(); |
|
2051 | 154 |
InitializeLandscape(); |
0 | 155 |
InitializeClearLand(); |
156 |
InitializeRail(); |
|
157 |
InitializeRailGui(); |
|
158 |
InitializeRoad(); |
|
159 |
InitializeRoadGui(); |
|
160 |
InitializeAirportGui(); |
|
161 |
InitializeDock(); |
|
162 |
InitializeDockGui(); |
|
163 |
InitializeTowns(); |
|
164 |
InitializeTrees(); |
|
988
4304525d1b8b
(svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents:
983
diff
changeset
|
165 |
InitializeSigns(); |
0 | 166 |
InitializeStations(); |
167 |
InitializeIndustries(); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
168 |
|
0 | 169 |
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
|
170 |
InitializeVehiclesGuiList(); |
0 | 171 |
InitializeTrains(); |
1247 | 172 |
InitializeNPF(); |
0 | 173 |
|
2706
fc872b9b17a7
(svn r3250) -Fix: AIs weren't uninitialized when a new game was loaded
truelight
parents:
2685
diff
changeset
|
174 |
AI_Initialize(); |
0 | 175 |
InitializePlayers(); |
176 |
InitializeCheats(); |
|
177 |
||
178 |
InitTextEffects(); |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
179 |
InitTextMessage(); |
0 | 180 |
InitializeAnimatedTiles(); |
181 |
||
182 |
InitializeLandscapeVariables(false); |
|
183 |
||
184 |
ResetObjectToPlace(); |
|
185 |
} |
|
186 |
||
2051 | 187 |
void GenerateWorld(int mode, uint size_x, uint size_y) |
0 | 188 |
{ |
189 |
int i; |
|
190 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
191 |
// Make sure everything is done via OWNER_NONE |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
192 |
_current_player = OWNER_NONE; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
193 |
|
0 | 194 |
_generating_world = true; |
2828
342f02f7c0d4
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2706
diff
changeset
|
195 |
InitializeGame(mode == GW_RANDOM ? 0 : IG_DATE_RESET, size_x, size_y); |
1914
2b4b3c3a95b4
(svn r2420) - Codechange: magic number elminitation of cursorsprites.
Darkvater
parents:
1891
diff
changeset
|
196 |
SetObjectToPlace(SPR_CURSOR_ZZZ, 0, 0, 0); |
0 | 197 |
|
198 |
// Must start economy early because of the costs. |
|
199 |
StartupEconomy(); |
|
200 |
||
201 |
// Don't generate landscape items when in the scenario editor. |
|
2828
342f02f7c0d4
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2706
diff
changeset
|
202 |
if (mode == GW_EMPTY) { |
0 | 203 |
// empty world in scenario editor |
204 |
ConvertGroundTilesIntoWaterTiles(); |
|
205 |
} else { |
|
206 |
GenerateLandscape(); |
|
207 |
GenerateClearTile(); |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
208 |
|
0 | 209 |
// only generate towns, tree and industries in newgame mode. |
2828
342f02f7c0d4
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2706
diff
changeset
|
210 |
if (mode == GW_NEWGAME) { |
0 | 211 |
GenerateTowns(); |
212 |
GenerateTrees(); |
|
213 |
GenerateIndustries(); |
|
214 |
GenerateUnmovables(); |
|
215 |
} |
|
216 |
} |
|
217 |
||
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
218 |
// These are probably pointless when inside the scenario editor. |
0 | 219 |
StartupPlayers(); |
220 |
StartupEngines(); |
|
221 |
StartupDisasters(); |
|
222 |
_generating_world = false; |
|
223 |
||
224 |
// No need to run the tile loop in the scenario editor. |
|
2828
342f02f7c0d4
(svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents:
2706
diff
changeset
|
225 |
if (mode != GW_EMPTY) { |
2952 | 226 |
for (i = 0x500; i != 0; i--) RunTileLoop(); |
0 | 227 |
} |
228 |
||
229 |
ResetObjectToPlace(); |
|
230 |
} |
|
231 |
||
232 |
void DeleteName(StringID id) |
|
233 |
{ |
|
234 |
if ((id & 0xF800) == 0x7800) { |
|
235 |
memset(_name_array[id & 0x1FF], 0, sizeof(_name_array[id & 0x1FF])); |
|
236 |
} |
|
237 |
} |
|
238 |
||
1328
eacd8225ed42
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1313
diff
changeset
|
239 |
char *GetName(int id, char *buff) |
0 | 240 |
{ |
1375
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
241 |
return strecpy(buff, _name_array[id & ~0x600], NULL); |
0 | 242 |
} |
243 |
||
244 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
245 |
static void InitializeCheats(void) |
0 | 246 |
{ |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
247 |
memset(&_cheats, 0, sizeof(Cheats)); |
0 | 248 |
} |
249 |
||
250 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
251 |
static void InitializeNameMgr(void) |
0 | 252 |
{ |
253 |
memset(_name_array, 0, sizeof(_name_array)); |
|
254 |
} |
|
255 |
||
1328
eacd8225ed42
(svn r1832) Next byte -> char iteration: custom names
tron
parents:
1313
diff
changeset
|
256 |
StringID RealAllocateName(const char *name, byte skip, bool check_double) |
0 | 257 |
{ |
1375
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
258 |
char (*free_item)[lengthof(*_name_array)] = NULL; |
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
259 |
char (*i)[lengthof(*_name_array)]; |
0 | 260 |
|
1375
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
261 |
for (i = _name_array; i != endof(_name_array); ++i) { |
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
262 |
if ((*i)[0] == '\0') { |
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
263 |
if (free_item == NULL) free_item = i; |
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
264 |
} else if (check_double && strncmp(*i, name, lengthof(*i) - 1) == 0) { |
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
265 |
_error_message = STR_0132_CHOSEN_NAME_IN_USE_ALREADY; |
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
266 |
return 0; |
0 | 267 |
} |
268 |
} |
|
269 |
||
1375
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
270 |
if (free_item != NULL) { |
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
271 |
ttd_strlcpy(*free_item, name, lengthof(*free_item)); |
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
272 |
return (free_item - _name_array) | 0x7800 | (skip << 8); |
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
273 |
} else { |
0 | 274 |
_error_message = STR_0131_TOO_MANY_NAMES_DEFINED; |
275 |
return 0; |
|
276 |
} |
|
277 |
} |
|
278 |
||
279 |
||
280 |
#define M(a,b) ((a<<5)|b) |
|
281 |
static const uint16 _month_date_from_year_day[] = { |
|
282 |
M(0,1),M(0,2),M(0,3),M(0,4),M(0,5),M(0,6),M(0,7),M(0,8),M(0,9),M(0,10),M(0,11),M(0,12),M(0,13),M(0,14),M(0,15),M(0,16),M(0,17),M(0,18),M(0,19),M(0,20),M(0,21),M(0,22),M(0,23),M(0,24),M(0,25),M(0,26),M(0,27),M(0,28),M(0,29),M(0,30),M(0,31), |
|
283 |
M(1,1),M(1,2),M(1,3),M(1,4),M(1,5),M(1,6),M(1,7),M(1,8),M(1,9),M(1,10),M(1,11),M(1,12),M(1,13),M(1,14),M(1,15),M(1,16),M(1,17),M(1,18),M(1,19),M(1,20),M(1,21),M(1,22),M(1,23),M(1,24),M(1,25),M(1,26),M(1,27),M(1,28),M(1,29), |
|
284 |
M(2,1),M(2,2),M(2,3),M(2,4),M(2,5),M(2,6),M(2,7),M(2,8),M(2,9),M(2,10),M(2,11),M(2,12),M(2,13),M(2,14),M(2,15),M(2,16),M(2,17),M(2,18),M(2,19),M(2,20),M(2,21),M(2,22),M(2,23),M(2,24),M(2,25),M(2,26),M(2,27),M(2,28),M(2,29),M(2,30),M(2,31), |
|
285 |
M(3,1),M(3,2),M(3,3),M(3,4),M(3,5),M(3,6),M(3,7),M(3,8),M(3,9),M(3,10),M(3,11),M(3,12),M(3,13),M(3,14),M(3,15),M(3,16),M(3,17),M(3,18),M(3,19),M(3,20),M(3,21),M(3,22),M(3,23),M(3,24),M(3,25),M(3,26),M(3,27),M(3,28),M(3,29),M(3,30), |
|
286 |
M(4,1),M(4,2),M(4,3),M(4,4),M(4,5),M(4,6),M(4,7),M(4,8),M(4,9),M(4,10),M(4,11),M(4,12),M(4,13),M(4,14),M(4,15),M(4,16),M(4,17),M(4,18),M(4,19),M(4,20),M(4,21),M(4,22),M(4,23),M(4,24),M(4,25),M(4,26),M(4,27),M(4,28),M(4,29),M(4,30),M(4,31), |
|
287 |
M(5,1),M(5,2),M(5,3),M(5,4),M(5,5),M(5,6),M(5,7),M(5,8),M(5,9),M(5,10),M(5,11),M(5,12),M(5,13),M(5,14),M(5,15),M(5,16),M(5,17),M(5,18),M(5,19),M(5,20),M(5,21),M(5,22),M(5,23),M(5,24),M(5,25),M(5,26),M(5,27),M(5,28),M(5,29),M(5,30), |
|
288 |
M(6,1),M(6,2),M(6,3),M(6,4),M(6,5),M(6,6),M(6,7),M(6,8),M(6,9),M(6,10),M(6,11),M(6,12),M(6,13),M(6,14),M(6,15),M(6,16),M(6,17),M(6,18),M(6,19),M(6,20),M(6,21),M(6,22),M(6,23),M(6,24),M(6,25),M(6,26),M(6,27),M(6,28),M(6,29),M(6,30),M(6,31), |
|
289 |
M(7,1),M(7,2),M(7,3),M(7,4),M(7,5),M(7,6),M(7,7),M(7,8),M(7,9),M(7,10),M(7,11),M(7,12),M(7,13),M(7,14),M(7,15),M(7,16),M(7,17),M(7,18),M(7,19),M(7,20),M(7,21),M(7,22),M(7,23),M(7,24),M(7,25),M(7,26),M(7,27),M(7,28),M(7,29),M(7,30),M(7,31), |
|
290 |
M(8,1),M(8,2),M(8,3),M(8,4),M(8,5),M(8,6),M(8,7),M(8,8),M(8,9),M(8,10),M(8,11),M(8,12),M(8,13),M(8,14),M(8,15),M(8,16),M(8,17),M(8,18),M(8,19),M(8,20),M(8,21),M(8,22),M(8,23),M(8,24),M(8,25),M(8,26),M(8,27),M(8,28),M(8,29),M(8,30), |
|
291 |
M(9,1),M(9,2),M(9,3),M(9,4),M(9,5),M(9,6),M(9,7),M(9,8),M(9,9),M(9,10),M(9,11),M(9,12),M(9,13),M(9,14),M(9,15),M(9,16),M(9,17),M(9,18),M(9,19),M(9,20),M(9,21),M(9,22),M(9,23),M(9,24),M(9,25),M(9,26),M(9,27),M(9,28),M(9,29),M(9,30),M(9,31), |
|
292 |
M(10,1),M(10,2),M(10,3),M(10,4),M(10,5),M(10,6),M(10,7),M(10,8),M(10,9),M(10,10),M(10,11),M(10,12),M(10,13),M(10,14),M(10,15),M(10,16),M(10,17),M(10,18),M(10,19),M(10,20),M(10,21),M(10,22),M(10,23),M(10,24),M(10,25),M(10,26),M(10,27),M(10,28),M(10,29),M(10,30), |
|
293 |
M(11,1),M(11,2),M(11,3),M(11,4),M(11,5),M(11,6),M(11,7),M(11,8),M(11,9),M(11,10),M(11,11),M(11,12),M(11,13),M(11,14),M(11,15),M(11,16),M(11,17),M(11,18),M(11,19),M(11,20),M(11,21),M(11,22),M(11,23),M(11,24),M(11,25),M(11,26),M(11,27),M(11,28),M(11,29),M(11,30),M(11,31), |
|
294 |
}; |
|
295 |
#undef M |
|
296 |
||
297 |
enum { |
|
298 |
ACCUM_JAN = 0, |
|
299 |
ACCUM_FEB = ACCUM_JAN + 31, |
|
300 |
ACCUM_MAR = ACCUM_FEB + 29, |
|
301 |
ACCUM_APR = ACCUM_MAR + 31, |
|
302 |
ACCUM_MAY = ACCUM_APR + 30, |
|
303 |
ACCUM_JUN = ACCUM_MAY + 31, |
|
304 |
ACCUM_JUL = ACCUM_JUN + 30, |
|
305 |
ACCUM_AUG = ACCUM_JUL + 31, |
|
306 |
ACCUM_SEP = ACCUM_AUG + 31, |
|
307 |
ACCUM_OCT = ACCUM_SEP + 30, |
|
308 |
ACCUM_NOV = ACCUM_OCT + 31, |
|
309 |
ACCUM_DEC = ACCUM_NOV + 30, |
|
310 |
}; |
|
311 |
||
312 |
static const uint16 _accum_days_for_month[] = { |
|
313 |
ACCUM_JAN,ACCUM_FEB,ACCUM_MAR,ACCUM_APR, |
|
314 |
ACCUM_MAY,ACCUM_JUN,ACCUM_JUL,ACCUM_AUG, |
|
315 |
ACCUM_SEP,ACCUM_OCT,ACCUM_NOV,ACCUM_DEC, |
|
316 |
}; |
|
317 |
||
318 |
||
319 |
void ConvertDayToYMD(YearMonthDay *ymd, uint16 date) |
|
320 |
{ |
|
321 |
uint yr = date / (365+365+365+366); |
|
322 |
uint rem = date % (365+365+365+366); |
|
323 |
uint x; |
|
324 |
||
325 |
yr *= 4; |
|
326 |
||
327 |
if (rem >= 366) { |
|
328 |
rem--; |
|
329 |
do { |
|
330 |
rem -= 365; |
|
331 |
yr++; |
|
332 |
} while (rem >= 365); |
|
333 |
if (rem >= 31+28) rem++; |
|
334 |
} |
|
335 |
||
336 |
ymd->year = yr; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
337 |
|
0 | 338 |
x = _month_date_from_year_day[rem]; |
339 |
ymd->month = x >> 5; |
|
340 |
ymd->day = x & 0x1F; |
|
341 |
} |
|
342 |
||
343 |
// year is a number between 0..? |
|
344 |
// month is a number between 0..11 |
|
345 |
// day is a number between 1..31 |
|
346 |
uint ConvertYMDToDay(uint year, uint month, uint day) |
|
347 |
{ |
|
348 |
uint rem; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
349 |
|
0 | 350 |
// day in the year |
351 |
rem = _accum_days_for_month[month] + day - 1; |
|
352 |
||
353 |
// remove feb 29 from year 1,2,3 |
|
354 |
if (year & 3) rem += (year & 3) * 365 + (rem < 31+29); |
|
355 |
||
356 |
// base date. |
|
357 |
return (year >> 2) * (365+365+365+366) + rem; |
|
358 |
} |
|
359 |
||
360 |
// convert a date on the form |
|
970
24abd02b1092
(svn r1465) -Fix: [1099101] starting year patch goes out of range. Clamped year between 1920-2090 as wel as adding defines for it.
darkvater
parents:
959
diff
changeset
|
361 |
// 1920 - 2090 (MAX_YEAR_END_REAL) |
0 | 362 |
// 192001 - 209012 |
363 |
// 19200101 - 20901231 |
|
364 |
// or if > 2090 and below 65536, treat it as a daycount |
|
365 |
// returns -1 if no conversion was possible |
|
366 |
uint ConvertIntDate(uint date) |
|
367 |
{ |
|
368 |
uint year, month = 0, day = 1; |
|
369 |
||
970
24abd02b1092
(svn r1465) -Fix: [1099101] starting year patch goes out of range. Clamped year between 1920-2090 as wel as adding defines for it.
darkvater
parents:
959
diff
changeset
|
370 |
if (IS_INT_INSIDE(date, 1920, MAX_YEAR_END_REAL + 1)) { |
0 | 371 |
year = date - 1920; |
372 |
} else if (IS_INT_INSIDE(date, 192001, 209012+1)) { |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
373 |
month = date % 100 - 1; |
0 | 374 |
year = date / 100 - 1920; |
375 |
} else if (IS_INT_INSIDE(date, 19200101, 20901231+1)) { |
|
376 |
day = date % 100; date /= 100; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
377 |
month = date % 100 - 1; |
0 | 378 |
year = date / 100 - 1920; |
2951 | 379 |
} else if (IS_INT_INSIDE(date, 2091, 65536)) { |
0 | 380 |
return date; |
2951 | 381 |
} else { |
0 | 382 |
return (uint)-1; |
2951 | 383 |
} |
0 | 384 |
|
385 |
// invalid ranges? |
|
386 |
if (month >= 12 || !IS_INT_INSIDE(day, 1, 31+1)) return (uint)-1; |
|
387 |
||
388 |
return ConvertYMDToDay(year, month, day); |
|
389 |
} |
|
390 |
||
391 |
typedef struct LandscapePredefVar { |
|
392 |
StringID names[NUM_CARGO]; |
|
393 |
byte weights[NUM_CARGO]; |
|
394 |
StringID sprites[NUM_CARGO]; |
|
395 |
||
396 |
uint16 initial_cargo_payment[NUM_CARGO]; |
|
397 |
byte transit_days_table_1[NUM_CARGO]; |
|
398 |
byte transit_days_table_2[NUM_CARGO]; |
|
399 |
||
400 |
byte railwagon_by_cargo[3][NUM_CARGO]; |
|
401 |
||
402 |
byte road_veh_by_cargo_start[NUM_CARGO]; |
|
403 |
byte road_veh_by_cargo_count[NUM_CARGO]; |
|
404 |
} LandscapePredefVar; |
|
405 |
||
406 |
#include "table/landscape_const.h" |
|
407 |
||
408 |
||
409 |
// Calculate constants that depend on the landscape type. |
|
410 |
void InitializeLandscapeVariables(bool only_constants) |
|
411 |
{ |
|
412 |
const LandscapePredefVar *lpd; |
|
413 |
int i; |
|
414 |
StringID str; |
|
415 |
||
416 |
lpd = &_landscape_predef_var[_opt.landscape]; |
|
417 |
||
418 |
memcpy(_cargoc.ai_railwagon, lpd->railwagon_by_cargo, sizeof(lpd->railwagon_by_cargo)); |
|
419 |
memcpy(_cargoc.ai_roadveh_start, lpd->road_veh_by_cargo_start,sizeof(lpd->road_veh_by_cargo_start)); |
|
420 |
memcpy(_cargoc.ai_roadveh_count, lpd->road_veh_by_cargo_count,sizeof(lpd->road_veh_by_cargo_count)); |
|
421 |
||
2951 | 422 |
for (i = 0; i != NUM_CARGO; i++) { |
0 | 423 |
_cargoc.sprites[i] = lpd->sprites[i]; |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
424 |
|
0 | 425 |
str = lpd->names[i]; |
426 |
_cargoc.names_s[i] = str; |
|
2112
280beaa78c66
(svn r2622) Fix: remove _cargoc.names_p, it was never used.
ludde
parents:
2090
diff
changeset
|
427 |
_cargoc.names_long[i] = (str += 0x40); |
0 | 428 |
_cargoc.names_short[i] = (str += 0x20); |
429 |
_cargoc.weights[i] = lpd->weights[i]; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
430 |
|
0 | 431 |
if (!only_constants) { |
432 |
_cargo_payment_rates[i] = lpd->initial_cargo_payment[i]; |
|
433 |
_cargo_payment_rates_frac[i] = 0; |
|
434 |
} |
|
435 |
||
436 |
_cargoc.transit_days_1[i] = lpd->transit_days_table_1[i]; |
|
437 |
_cargoc.transit_days_2[i] = lpd->transit_days_table_2[i]; |
|
438 |
} |
|
439 |
} |
|
440 |
||
441 |
||
442 |
void OnNewDay_Train(Vehicle *v); |
|
443 |
void OnNewDay_RoadVeh(Vehicle *v); |
|
444 |
void OnNewDay_Aircraft(Vehicle *v); |
|
445 |
void OnNewDay_Ship(Vehicle *v); |
|
1095 | 446 |
static void OnNewDay_EffectVehicle(Vehicle *v) { /* empty */ } |
0 | 447 |
void OnNewDay_DisasterVehicle(Vehicle *v); |
448 |
||
449 |
typedef void OnNewVehicleDayProc(Vehicle *v); |
|
450 |
||
451 |
static OnNewVehicleDayProc * _on_new_vehicle_day_proc[] = { |
|
452 |
OnNewDay_Train, |
|
453 |
OnNewDay_RoadVeh, |
|
454 |
OnNewDay_Ship, |
|
455 |
OnNewDay_Aircraft, |
|
456 |
OnNewDay_EffectVehicle, |
|
457 |
OnNewDay_DisasterVehicle, |
|
458 |
}; |
|
459 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
460 |
void EnginesDailyLoop(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
461 |
void DisasterDailyLoop(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
462 |
void PlayersMonthlyLoop(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
463 |
void EnginesMonthlyLoop(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
464 |
void TownsMonthlyLoop(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
465 |
void IndustryMonthlyLoop(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
466 |
void StationMonthlyLoop(void); |
0 | 467 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
468 |
void PlayersYearlyLoop(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
469 |
void TrainsYearlyLoop(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
470 |
void RoadVehiclesYearlyLoop(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
471 |
void AircraftYearlyLoop(void); |
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
472 |
void ShipsYearlyLoop(void); |
0 | 473 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
474 |
void WaypointsDailyLoop(void); |
0 | 475 |
|
476 |
||
477 |
static const uint16 _autosave_months[] = { |
|
478 |
0, // never |
|
479 |
0xFFF, // every month |
|
480 |
0x249, // every 3 months |
|
481 |
0x041, // every 6 months |
|
482 |
0x001, // every 12 months |
|
483 |
}; |
|
484 |
||
1537
517b9b9cfaa0
(svn r2041) -Fix: not all vehicles did get a day_proc call (because of rounding errors)
truelight
parents:
1529
diff
changeset
|
485 |
/** |
2090
66677ed50f3c
(svn r2600) Fix: [vehicles] Fix problem with vehicle loop not distributing the calls evenly over the day.
ludde
parents:
2086
diff
changeset
|
486 |
* Runs the day_proc for every DAY_TICKS vehicle starting at daytick. |
1537
517b9b9cfaa0
(svn r2041) -Fix: not all vehicles did get a day_proc call (because of rounding errors)
truelight
parents:
1529
diff
changeset
|
487 |
*/ |
2090
66677ed50f3c
(svn r2600) Fix: [vehicles] Fix problem with vehicle loop not distributing the calls evenly over the day.
ludde
parents:
2086
diff
changeset
|
488 |
static void RunVehicleDayProc(uint daytick) |
1537
517b9b9cfaa0
(svn r2041) -Fix: not all vehicles did get a day_proc call (because of rounding errors)
truelight
parents:
1529
diff
changeset
|
489 |
{ |
2090
66677ed50f3c
(svn r2600) Fix: [vehicles] Fix problem with vehicle loop not distributing the calls evenly over the day.
ludde
parents:
2086
diff
changeset
|
490 |
uint i, total = _vehicle_pool.total_items; |
1537
517b9b9cfaa0
(svn r2041) -Fix: not all vehicles did get a day_proc call (because of rounding errors)
truelight
parents:
1529
diff
changeset
|
491 |
|
2090
66677ed50f3c
(svn r2600) Fix: [vehicles] Fix problem with vehicle loop not distributing the calls evenly over the day.
ludde
parents:
2086
diff
changeset
|
492 |
for (i = daytick; i < total; i += DAY_TICKS) { |
2951 | 493 |
Vehicle* v = GetVehicle(i); |
494 |
||
495 |
if (v->type != 0) _on_new_vehicle_day_proc[v->type - 0x10](v); |
|
1537
517b9b9cfaa0
(svn r2041) -Fix: not all vehicles did get a day_proc call (because of rounding errors)
truelight
parents:
1529
diff
changeset
|
496 |
} |
517b9b9cfaa0
(svn r2041) -Fix: not all vehicles did get a day_proc call (because of rounding errors)
truelight
parents:
1529
diff
changeset
|
497 |
} |
517b9b9cfaa0
(svn r2041) -Fix: not all vehicles did get a day_proc call (because of rounding errors)
truelight
parents:
1529
diff
changeset
|
498 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
499 |
void IncreaseDate(void) |
0 | 500 |
{ |
501 |
YearMonthDay ymd; |
|
502 |
||
503 |
if (_game_mode == GM_MENU) { |
|
504 |
_tick_counter++; |
|
505 |
return; |
|
506 |
} |
|
507 |
||
2090
66677ed50f3c
(svn r2600) Fix: [vehicles] Fix problem with vehicle loop not distributing the calls evenly over the day.
ludde
parents:
2086
diff
changeset
|
508 |
RunVehicleDayProc(_date_fract); |
0 | 509 |
|
510 |
/* increase day, and check if a new day is there? */ |
|
511 |
_tick_counter++; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
512 |
|
1537
517b9b9cfaa0
(svn r2041) -Fix: not all vehicles did get a day_proc call (because of rounding errors)
truelight
parents:
1529
diff
changeset
|
513 |
_date_fract++; |
2951 | 514 |
if (_date_fract < DAY_TICKS) return; |
1537
517b9b9cfaa0
(svn r2041) -Fix: not all vehicles did get a day_proc call (because of rounding errors)
truelight
parents:
1529
diff
changeset
|
515 |
_date_fract = 0; |
517b9b9cfaa0
(svn r2041) -Fix: not all vehicles did get a day_proc call (because of rounding errors)
truelight
parents:
1529
diff
changeset
|
516 |
|
0 | 517 |
/* yeah, increse day counter and call various daily loops */ |
518 |
_date++; |
|
519 |
||
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
507
diff
changeset
|
520 |
TextMessageDailyLoop(); |
0 | 521 |
|
522 |
DisasterDailyLoop(); |
|
395
788a9bba0889
(svn r587) -newgrf: Rename all /Checkpoint/i tokens to 'Waypoint's. The name actually makes some sense and is also compatible with TTDPatch (pasky).
darkvater
parents:
387
diff
changeset
|
523 |
WaypointsDailyLoop(); |
0 | 524 |
|
525 |
if (_game_mode != GM_MENU) { |
|
526 |
InvalidateWindowWidget(WC_STATUS_BAR, 0, 0); |
|
527 |
EnginesDailyLoop(); |
|
528 |
} |
|
529 |
||
530 |
/* check if we entered a new month? */ |
|
531 |
ConvertDayToYMD(&ymd, _date); |
|
532 |
if ((byte)ymd.month == _cur_month) |
|
533 |
return; |
|
534 |
_cur_month = ymd.month; |
|
535 |
||
536 |
/* yes, call various monthly loops */ |
|
537 |
if (_game_mode != GM_MENU) { |
|
538 |
if (HASBIT(_autosave_months[_opt.autosave], _cur_month)) { |
|
539 |
_do_autosave = true; |
|
540 |
RedrawAutosave(); |
|
541 |
} |
|
542 |
||
543 |
PlayersMonthlyLoop(); |
|
544 |
EnginesMonthlyLoop(); |
|
545 |
TownsMonthlyLoop(); |
|
546 |
IndustryMonthlyLoop(); |
|
547 |
StationMonthlyLoop(); |
|
690
3afcad69d4f7
(svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents:
679
diff
changeset
|
548 |
#ifdef ENABLE_NETWORK |
2951 | 549 |
if (_network_server) NetworkServerMonthlyLoop(); |
690
3afcad69d4f7
(svn r1131) -Add: [Network] Autoclean_companies (set it with 'set autoclean_companies on/off').
truelight
parents:
679
diff
changeset
|
550 |
#endif /* ENABLE_NETWORK */ |
0 | 551 |
} |
552 |
||
553 |
/* check if we entered a new year? */ |
|
554 |
if ((byte)ymd.year == _cur_year) |
|
555 |
return; |
|
556 |
_cur_year = ymd.year; |
|
557 |
||
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
558 |
/* yes, call various yearly loops */ |
0 | 559 |
|
560 |
PlayersYearlyLoop(); |
|
561 |
TrainsYearlyLoop(); |
|
562 |
RoadVehiclesYearlyLoop(); |
|
563 |
AircraftYearlyLoop(); |
|
564 |
ShipsYearlyLoop(); |
|
785
bba7b3b35dec
(svn r1252) -Add: [Network] With 'set restart_game_date' you can set the date for in
truelight
parents:
770
diff
changeset
|
565 |
#ifdef ENABLE_NETWORK |
2951 | 566 |
if (_network_server) NetworkServerYearlyLoop(); |
785
bba7b3b35dec
(svn r1252) -Add: [Network] With 'set restart_game_date' you can set the date for in
truelight
parents:
770
diff
changeset
|
567 |
#endif /* ENABLE_NETWORK */ |
0 | 568 |
|
998
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
988
diff
changeset
|
569 |
/* check if we reached end of the game (31 dec 2050) */ |
c90459c24842
(svn r1496) -Fix: highscore no longer crashes in network games with a dedicated server. At the end of the game (can only be set by the server) the highscore is shown for the top5 companies of that game
darkvater
parents:
988
diff
changeset
|
570 |
if (_cur_year == _patches.ending_date - MAX_YEAR_BEGIN_REAL) { |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
571 |
ShowEndGameChart(); |
970
24abd02b1092
(svn r1465) -Fix: [1099101] starting year patch goes out of range. Clamped year between 1920-2090 as wel as adding defines for it.
darkvater
parents:
959
diff
changeset
|
572 |
/* check if we reached 2090 (MAX_YEAR_END_REAL), that's the maximum year. */ |
983
4765bf636f6b
(svn r1479) -Added highscore chart (accessible from the difficulty window) with top5 companies for a given difficulty (select the difficulty in the menu)
darkvater
parents:
970
diff
changeset
|
573 |
} else if (_cur_year == (MAX_YEAR_END + 1)) { |
2951 | 574 |
Vehicle* v; |
575 |
||
970
24abd02b1092
(svn r1465) -Fix: [1099101] starting year patch goes out of range. Clamped year between 1920-2090 as wel as adding defines for it.
darkvater
parents:
959
diff
changeset
|
576 |
_cur_year = MAX_YEAR_END; |
0 | 577 |
_date = 62093; |
286
b22e852634e4
(svn r292) -Fix: [1030275] 'Service at' orders ignored after 2090. After 2090 year is reset to 1. Jan 2090, so most of the time, last service was in the future and no service ensured.
darkvater
parents:
271
diff
changeset
|
578 |
FOR_ALL_VEHICLES(v) { |
b22e852634e4
(svn r292) -Fix: [1030275] 'Service at' orders ignored after 2090. After 2090 year is reset to 1. Jan 2090, so most of the time, last service was in the future and no service ensured.
darkvater
parents:
271
diff
changeset
|
579 |
v->date_of_last_service -= 365; // 1 year is 365 days long |
b22e852634e4
(svn r292) -Fix: [1030275] 'Service at' orders ignored after 2090. After 2090 year is reset to 1. Jan 2090, so most of the time, last service was in the future and no service ensured.
darkvater
parents:
271
diff
changeset
|
580 |
} |
1595
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1542
diff
changeset
|
581 |
|
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1542
diff
changeset
|
582 |
/* Because the _date wraps here, and text-messages expire by game-days, we have to clean out |
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1542
diff
changeset
|
583 |
* all of them if the date is set back, else those messages will hang for ever */ |
fda318dddab5
(svn r2099) -Fix: no longer chat-messages hang when the game wraps around 2090
truelight
parents:
1542
diff
changeset
|
584 |
InitTextMessage(); |
0 | 585 |
} |
586 |
||
2951 | 587 |
if (_patches.auto_euro) CheckSwitchToEuro(); |
0 | 588 |
|
589 |
/* XXX: check if year 2050 was reached */ |
|
590 |
} |
|
591 |
||
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
105
diff
changeset
|
592 |
int FindFirstBit(uint32 value) |
0 | 593 |
{ |
826 | 594 |
// This is much faster than the one that was before here. |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
105
diff
changeset
|
595 |
// Created by Darkvater.. blame him if it is wrong ;) |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
105
diff
changeset
|
596 |
// Btw, the macro FINDFIRSTBIT is better to use when your value is |
826 | 597 |
// not more than 128. |
116
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
105
diff
changeset
|
598 |
byte i = 0; |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
105
diff
changeset
|
599 |
if (value & 0xffff0000) { value >>= 16; i += 16; } |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
105
diff
changeset
|
600 |
if (value & 0x0000ff00) { value >>= 8; i += 8; } |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
105
diff
changeset
|
601 |
if (value & 0x000000f0) { value >>= 4; i += 4; } |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
105
diff
changeset
|
602 |
if (value & 0x0000000c) { value >>= 2; i += 2; } |
ca4332a9ec1d
(svn r117) Feature: Performance details window in company league menu (TrueLight)
dominik
parents:
105
diff
changeset
|
603 |
if (value & 0x00000002) { i += 1; } |
0 | 604 |
return i; |
605 |
} |
|
606 |
||
1217
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
607 |
//!We're writing an own sort algorithm here, as |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
608 |
//!qsort isn't stable |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
609 |
//!Since the number of elements will be low, a |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
610 |
//!simple bubble sort will have to do :) |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
611 |
|
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
612 |
void bubblesort(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *)) |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
613 |
{ |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
614 |
uint i,k; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
615 |
void *buffer = malloc(size); |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
616 |
char *start = base; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
617 |
|
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
618 |
nmemb--; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
619 |
|
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
620 |
for (i = 0; i < nmemb; i++) { |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
621 |
for (k = 0; k < nmemb; k++) { |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
622 |
void *a, *b; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
623 |
a = start + size * k; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
624 |
b = start + size * (k + 1); |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
625 |
if (compar(a, b) > 0) { |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
626 |
memcpy(buffer, a, size); |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
627 |
memcpy(a, b, size); |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
628 |
memcpy(b, buffer, size); |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
629 |
} |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
630 |
} |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
631 |
} |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
632 |
|
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
633 |
free(buffer); |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
634 |
buffer = NULL; |
59c024cfaf54
(svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents:
1178
diff
changeset
|
635 |
} |
0 | 636 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
637 |
static void Save_NAME(void) |
0 | 638 |
{ |
639 |
int i; |
|
640 |
||
1375
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
641 |
for (i = 0; i != lengthof(_name_array); ++i) { |
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
642 |
if (_name_array[i][0] != '\0') { |
0 | 643 |
SlSetArrayIndex(i); |
1375
00a24560f025
(svn r1879) Revise name handling, no functional changes
tron
parents:
1328
diff
changeset
|
644 |
SlArray(_name_array[i], 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
|
645 |
} |
0 | 646 |
} |
647 |
} |
|
648 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
649 |
static void Load_NAME(void) |
0 | 650 |
{ |
651 |
int index; |
|
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
652 |
|
0 | 653 |
while ((index = SlIterateArray()) != -1) { |
654 |
SlArray(_name_array[index],SlGetFieldLength(),SLE_UINT8); |
|
655 |
} |
|
656 |
} |
|
657 |
||
1881
435d39bd6ee0
(svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents:
1812
diff
changeset
|
658 |
static const SaveLoad _game_opt_desc[] = { |
0 | 659 |
// added a new difficulty option (town attitude) in version 4 |
660 |
SLE_CONDARR(GameOptions,diff, SLE_FILE_I16 | SLE_VAR_I32, 17, 0, 3), |
|
661 |
SLE_CONDARR(GameOptions,diff, SLE_FILE_I16 | SLE_VAR_I32, 18, 4, 255), |
|
662 |
SLE_VAR(GameOptions,diff_level, SLE_UINT8), |
|
663 |
SLE_VAR(GameOptions,currency, SLE_UINT8), |
|
664 |
SLE_VAR(GameOptions,kilometers, SLE_UINT8), |
|
665 |
SLE_VAR(GameOptions,town_name, SLE_UINT8), |
|
666 |
SLE_VAR(GameOptions,landscape, SLE_UINT8), |
|
667 |
SLE_VAR(GameOptions,snow_line, SLE_UINT8), |
|
668 |
SLE_VAR(GameOptions,autosave, SLE_UINT8), |
|
669 |
SLE_VAR(GameOptions,road_side, SLE_UINT8), |
|
670 |
SLE_END() |
|
671 |
}; |
|
672 |
||
673 |
// Save load game options |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
674 |
static void SaveLoad_OPTS(void) |
0 | 675 |
{ |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
179
diff
changeset
|
676 |
SlObject(&_opt, _game_opt_desc); |
0 | 677 |
} |
678 |
||
679 |
||
680 |
static const SaveLoadGlobVarList _date_desc[] = { |
|
681 |
{&_date, SLE_UINT16, 0, 255}, |
|
682 |
{&_date_fract, SLE_UINT16, 0, 255}, |
|
683 |
{&_tick_counter, SLE_UINT16, 0, 255}, |
|
684 |
{&_vehicle_id_ctr_day, SLE_UINT16, 0, 255}, |
|
685 |
{&_age_cargo_skip_counter, SLE_UINT8, 0, 255}, |
|
686 |
{&_avail_aircraft, SLE_UINT8, 0, 255}, |
|
1175
a4bdf4c26d32
(svn r1677) Forgot to change the save/load size for 3 variables
tron
parents:
1121
diff
changeset
|
687 |
{&_cur_tileloop_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5}, |
a4bdf4c26d32
(svn r1677) Forgot to change the save/load size for 3 variables
tron
parents:
1121
diff
changeset
|
688 |
{&_cur_tileloop_tile, SLE_UINT32, 6, 255}, |
0 | 689 |
{&_disaster_delay, SLE_UINT16, 0, 255}, |
690 |
{&_station_tick_ctr, SLE_UINT16, 0, 255}, |
|
206 | 691 |
{&_random_seeds[0][0], SLE_UINT32, 0, 255}, |
692 |
{&_random_seeds[0][1], SLE_UINT32, 0, 255}, |
|
1526
2b5571c8c32f
(svn r2030) -Fix: Save _cur_town_ctr with all its bits to prevent desyncs
celestar
parents:
1517
diff
changeset
|
693 |
{&_cur_town_ctr, SLE_FILE_U8 | SLE_VAR_U32, 0, 9}, |
2b5571c8c32f
(svn r2030) -Fix: Save _cur_town_ctr with all its bits to prevent desyncs
celestar
parents:
1517
diff
changeset
|
694 |
{&_cur_town_ctr, SLE_UINT32, 10, 255}, |
0 | 695 |
{&_cur_player_tick_index, SLE_FILE_U8 | SLE_VAR_UINT, 0, 255}, |
696 |
{&_next_competitor_start, SLE_FILE_U16 | SLE_VAR_UINT, 0, 255}, |
|
697 |
{&_trees_tick_ctr, SLE_UINT8, 0, 255}, |
|
698 |
{&_pause, SLE_UINT8, 4, 255}, |
|
1529
3a8196d15b01
(svn r2033) - Fix: Fix some more desync by saving the town growth frequency iterator _cur_town_iter. Needed to bump a svg revision for that thanks to the braindead SlGlob thing, or at least I don't know how to do it without bumping it.
pasky
parents:
1526
diff
changeset
|
699 |
{&_cur_town_iter, SLE_UINT32, 11, 255}, |
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
164
diff
changeset
|
700 |
{NULL, 0, 0, 0} |
0 | 701 |
}; |
702 |
||
703 |
// Save load date related variables as well as persistent tick counters |
|
704 |
// XXX: currently some unrelated stuff is just put here |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
705 |
static void SaveLoad_DATE(void) |
0 | 706 |
{ |
707 |
SlGlobList(_date_desc); |
|
708 |
} |
|
709 |
||
710 |
||
711 |
static const SaveLoadGlobVarList _view_desc[] = { |
|
1175
a4bdf4c26d32
(svn r1677) Forgot to change the save/load size for 3 variables
tron
parents:
1121
diff
changeset
|
712 |
{&_saved_scrollpos_x, SLE_FILE_I16 | SLE_VAR_INT, 0, 5}, |
a4bdf4c26d32
(svn r1677) Forgot to change the save/load size for 3 variables
tron
parents:
1121
diff
changeset
|
713 |
{&_saved_scrollpos_x, SLE_INT32, 6, 255}, |
a4bdf4c26d32
(svn r1677) Forgot to change the save/load size for 3 variables
tron
parents:
1121
diff
changeset
|
714 |
{&_saved_scrollpos_y, SLE_FILE_I16 | SLE_VAR_INT, 0, 5}, |
a4bdf4c26d32
(svn r1677) Forgot to change the save/load size for 3 variables
tron
parents:
1121
diff
changeset
|
715 |
{&_saved_scrollpos_y, SLE_INT32, 6, 255}, |
179
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
164
diff
changeset
|
716 |
{&_saved_scrollpos_zoom, SLE_UINT8, 0, 255}, |
003096efeb9d
(svn r180) -Fix: some more warning fixes for C99 (Tron)
darkvater
parents:
164
diff
changeset
|
717 |
{NULL, 0, 0, 0} |
0 | 718 |
}; |
719 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
720 |
static void SaveLoad_VIEW(void) |
0 | 721 |
{ |
722 |
SlGlobList(_view_desc); |
|
723 |
} |
|
724 |
||
1218 | 725 |
static uint32 _map_dim_x; |
726 |
static uint32 _map_dim_y; |
|
727 |
||
728 |
static const SaveLoadGlobVarList _map_dimensions[] = { |
|
729 |
{&_map_dim_x, SLE_UINT32, 6, 255}, |
|
730 |
{&_map_dim_y, SLE_UINT32, 6, 255}, |
|
731 |
{NULL, 0, 0, 0} |
|
732 |
}; |
|
733 |
||
2049
538e73c53f54
(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
|
734 |
static void Save_MAPS(void) |
1218 | 735 |
{ |
1219
1163c59b8650
(svn r1723) Save the map size in tiles, not number of bits
tron
parents:
1218
diff
changeset
|
736 |
_map_dim_x = MapSizeX(); |
1163c59b8650
(svn r1723) Save the map size in tiles, not number of bits
tron
parents:
1218
diff
changeset
|
737 |
_map_dim_y = MapSizeY(); |
1218 | 738 |
SlGlobList(_map_dimensions); |
739 |
} |
|
740 |
||
2049
538e73c53f54
(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
|
741 |
static void Load_MAPS(void) |
1218 | 742 |
{ |
743 |
SlGlobList(_map_dimensions); |
|
2051 | 744 |
AllocateMap(_map_dim_x, _map_dim_y); |
1218 | 745 |
} |
746 |
||
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
747 |
static void Load_MAPT(void) |
2050
3b37e813823a
(svn r2559) Cleaned up new saveload code for the map
ludde
parents:
2049
diff
changeset
|
748 |
{ |
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
749 |
uint size = MapSize(); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
750 |
uint i; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
751 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
752 |
for (i = 0; i != size;) { |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
753 |
byte buf[4096]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
754 |
uint j; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
755 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
756 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
757 |
for (j = 0; j != lengthof(buf); j++) _m[i++].type_height = buf[j]; |
817
238bbdaa228b
(svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents:
785
diff
changeset
|
758 |
} |
0 | 759 |
} |
760 |
||
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
761 |
static void Save_MAPT(void) |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
762 |
{ |
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
763 |
uint size = MapSize(); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
764 |
uint i; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
765 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
766 |
SlSetLength(size); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
767 |
for (i = 0; i != size;) { |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
768 |
byte buf[4096]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
769 |
uint j; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
770 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
771 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].type_height; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
772 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
773 |
} |
0 | 774 |
} |
775 |
||
2360
4e4ebe18e448
(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
|
776 |
static void Load_MAP1(void) |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
777 |
{ |
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
778 |
uint size = MapSize(); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
779 |
uint i; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
780 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
781 |
for (i = 0; i != size;) { |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
782 |
byte buf[4096]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
783 |
uint j; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
784 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
785 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
2360
4e4ebe18e448
(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
|
786 |
for (j = 0; j != lengthof(buf); j++) _m[i++].m1 = buf[j]; |
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
787 |
} |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
788 |
} |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
789 |
|
2360
4e4ebe18e448
(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
|
790 |
static void Save_MAP1(void) |
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
791 |
{ |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
792 |
uint size = MapSize(); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
793 |
uint i; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
794 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
795 |
SlSetLength(size); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
796 |
for (i = 0; i != size;) { |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
797 |
byte buf[4096]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
798 |
uint j; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
799 |
|
2360
4e4ebe18e448
(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
|
800 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m1; |
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
801 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
802 |
} |
0 | 803 |
} |
804 |
||
2049
538e73c53f54
(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
|
805 |
static void Load_MAP2(void) |
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
806 |
{ |
2049
538e73c53f54
(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
|
807 |
uint size = MapSize(); |
538e73c53f54
(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
|
808 |
uint i; |
538e73c53f54
(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
|
809 |
|
538e73c53f54
(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
|
810 |
for (i = 0; i != size;) { |
538e73c53f54
(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
|
811 |
uint16 buf[4096]; |
538e73c53f54
(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
|
812 |
uint j; |
538e73c53f54
(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
|
813 |
|
538e73c53f54
(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
|
814 |
SlArray(buf, lengthof(buf), |
538e73c53f54
(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
|
815 |
/* In those versions the m2 was 8 bits */ |
2685
805a28b7c3b7
(svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents:
2548
diff
changeset
|
816 |
CheckSavegameVersion(5) ? SLE_FILE_U8 | SLE_VAR_U16 : SLE_UINT16 |
2049
538e73c53f54
(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
|
817 |
); |
538e73c53f54
(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
|
818 |
for (j = 0; j != lengthof(buf); j++) _m[i++].m2 = buf[j]; |
538e73c53f54
(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
|
819 |
} |
538e73c53f54
(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
|
820 |
} |
538e73c53f54
(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
|
821 |
|
538e73c53f54
(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
|
822 |
static void Save_MAP2(void) |
538e73c53f54
(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
|
823 |
{ |
538e73c53f54
(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
|
824 |
uint size = MapSize(); |
538e73c53f54
(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
|
825 |
uint i; |
538e73c53f54
(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
|
826 |
|
538e73c53f54
(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
|
827 |
SlSetLength(size * sizeof(_m[0].m2)); |
538e73c53f54
(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
|
828 |
for (i = 0; i != size;) { |
538e73c53f54
(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
|
829 |
uint16 buf[4096]; |
538e73c53f54
(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
|
830 |
uint j; |
538e73c53f54
(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
|
831 |
|
538e73c53f54
(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
|
832 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m2; |
538e73c53f54
(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
|
833 |
SlArray(buf, lengthof(buf), SLE_UINT16); |
538e73c53f54
(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
|
834 |
} |
538e73c53f54
(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
|
835 |
} |
538e73c53f54
(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
|
836 |
|
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
837 |
static void Load_MAP3(void) |
2049
538e73c53f54
(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
|
838 |
{ |
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
839 |
uint size = MapSize(); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
840 |
uint i; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
841 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
842 |
for (i = 0; i != size;) { |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
843 |
byte buf[4096]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
844 |
uint j; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
845 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
846 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
847 |
for (j = 0; j != lengthof(buf); j++) _m[i++].m3 = buf[j]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
848 |
} |
2049
538e73c53f54
(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
|
849 |
} |
538e73c53f54
(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
|
850 |
|
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
851 |
static void Save_MAP3(void) |
2049
538e73c53f54
(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
|
852 |
{ |
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
853 |
uint size = MapSize(); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
854 |
uint i; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
855 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
856 |
SlSetLength(size); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
857 |
for (i = 0; i != size;) { |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
858 |
byte buf[4096]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
859 |
uint j; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
860 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
861 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m3; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
862 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
863 |
} |
2049
538e73c53f54
(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
|
864 |
} |
538e73c53f54
(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
|
865 |
|
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
866 |
static void Load_MAP4(void) |
2049
538e73c53f54
(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
|
867 |
{ |
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
868 |
uint size = MapSize(); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
869 |
uint i; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
870 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
871 |
for (i = 0; i != size;) { |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
872 |
byte buf[4096]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
873 |
uint j; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
874 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
875 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
876 |
for (j = 0; j != lengthof(buf); j++) _m[i++].m4 = buf[j]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
877 |
} |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
878 |
} |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
879 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
880 |
static void Save_MAP4(void) |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
881 |
{ |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
882 |
uint size = MapSize(); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
883 |
uint i; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
884 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
885 |
SlSetLength(size); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
886 |
for (i = 0; i != size;) { |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
887 |
byte buf[4096]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
888 |
uint j; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
889 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
890 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m4; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
891 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
892 |
} |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
893 |
} |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
894 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
895 |
static void Load_MAP5(void) |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
896 |
{ |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
897 |
uint size = MapSize(); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
898 |
uint i; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
899 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
900 |
for (i = 0; i != size;) { |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
901 |
byte buf[4096]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
902 |
uint j; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
903 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
904 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
905 |
for (j = 0; j != lengthof(buf); j++) _m[i++].m5 = buf[j]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
906 |
} |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
907 |
} |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
908 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
909 |
static void Save_MAP5(void) |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
910 |
{ |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
911 |
uint size = MapSize(); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
912 |
uint i; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
913 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
914 |
SlSetLength(size); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
915 |
for (i = 0; i != size;) { |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
916 |
byte buf[4096]; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
917 |
uint j; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
918 |
|
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
919 |
for (j = 0; j != lengthof(buf); j++) buf[j] = _m[i++].m5; |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
920 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
921 |
} |
2049
538e73c53f54
(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
|
922 |
} |
538e73c53f54
(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
|
923 |
|
538e73c53f54
(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
|
924 |
static void Load_MAPE(void) |
538e73c53f54
(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
|
925 |
{ |
538e73c53f54
(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
|
926 |
uint size = MapSize(); |
538e73c53f54
(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
|
927 |
uint i; |
538e73c53f54
(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
|
928 |
|
538e73c53f54
(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
|
929 |
for (i = 0; i != size;) { |
538e73c53f54
(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
|
930 |
uint8 buf[1024]; |
538e73c53f54
(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
|
931 |
uint j; |
538e73c53f54
(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
|
932 |
|
538e73c53f54
(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
|
933 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
538e73c53f54
(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
|
934 |
for (j = 0; j != lengthof(buf); j++) { |
538e73c53f54
(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
|
935 |
_m[i++].extra = GB(buf[j], 0, 2); |
538e73c53f54
(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
|
936 |
_m[i++].extra = GB(buf[j], 2, 2); |
538e73c53f54
(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
|
937 |
_m[i++].extra = GB(buf[j], 4, 2); |
538e73c53f54
(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
|
938 |
_m[i++].extra = GB(buf[j], 6, 2); |
538e73c53f54
(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
|
939 |
} |
538e73c53f54
(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
|
940 |
} |
538e73c53f54
(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
|
941 |
} |
538e73c53f54
(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
|
942 |
|
538e73c53f54
(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
|
943 |
static void Save_MAPE(void) |
538e73c53f54
(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
|
944 |
{ |
538e73c53f54
(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
|
945 |
uint size = MapSize(); |
538e73c53f54
(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
|
946 |
uint i; |
538e73c53f54
(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
|
947 |
|
538e73c53f54
(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
|
948 |
SlSetLength(size / 4); |
538e73c53f54
(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
|
949 |
for (i = 0; i != size;) { |
538e73c53f54
(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
|
950 |
uint8 buf[1024]; |
538e73c53f54
(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
|
951 |
uint j; |
538e73c53f54
(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
|
952 |
|
538e73c53f54
(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
|
953 |
for (j = 0; j != lengthof(buf); j++) { |
538e73c53f54
(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
|
954 |
buf[j] = _m[i++].extra << 0; |
538e73c53f54
(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
|
955 |
buf[j] |= _m[i++].extra << 2; |
538e73c53f54
(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
|
956 |
buf[j] |= _m[i++].extra << 4; |
538e73c53f54
(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
|
957 |
buf[j] |= _m[i++].extra << 6; |
538e73c53f54
(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
|
958 |
} |
538e73c53f54
(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
|
959 |
SlArray(buf, lengthof(buf), SLE_UINT8); |
538e73c53f54
(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
|
960 |
} |
0 | 961 |
} |
962 |
||
963 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
964 |
static void Save_CHTS(void) |
0 | 965 |
{ |
966 |
byte count = sizeof(_cheats)/sizeof(Cheat); |
|
967 |
Cheat* cht = (Cheat*) &_cheats; |
|
968 |
Cheat* cht_last = &cht[count]; |
|
969 |
||
2951 | 970 |
SlSetLength(count * 2); |
971 |
for (; cht != cht_last; cht++) { |
|
0 | 972 |
SlWriteByte(cht->been_used); |
973 |
SlWriteByte(cht->value); |
|
974 |
} |
|
975 |
} |
|
976 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1024
diff
changeset
|
977 |
static void Load_CHTS(void) |
0 | 978 |
{ |
979 |
Cheat* cht = (Cheat*) &_cheats; |
|
980 |
||
981 |
uint count = SlGetFieldLength()/2; |
|
2952 | 982 |
for (; count; count--, cht++) |
0 | 983 |
{ |
984 |
cht->been_used = (byte)SlReadByte(); |
|
985 |
cht->value = (byte)SlReadByte(); |
|
986 |
} |
|
987 |
} |
|
988 |
||
989 |
||
990 |
const ChunkHandler _misc_chunk_handlers[] = { |
|
2049
538e73c53f54
(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
|
991 |
{ 'MAPS', Save_MAPS, Load_MAPS, CH_RIFF }, |
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
992 |
{ 'MAPT', Save_MAPT, Load_MAPT, CH_RIFF }, |
2360
4e4ebe18e448
(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
|
993 |
{ 'MAPO', Save_MAP1, Load_MAP1, CH_RIFF }, |
2049
538e73c53f54
(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
|
994 |
{ 'MAP2', Save_MAP2, Load_MAP2, CH_RIFF }, |
2295
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
995 |
{ 'M3LO', Save_MAP3, Load_MAP3, CH_RIFF }, |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
996 |
{ 'M3HI', Save_MAP4, Load_MAP4, CH_RIFF }, |
95e8858e9938
(svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents:
2293
diff
changeset
|
997 |
{ 'MAP5', Save_MAP5, Load_MAP5, CH_RIFF }, |
2049
538e73c53f54
(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
|
998 |
{ 'MAPE', Save_MAPE, Load_MAPE, CH_RIFF }, |
0 | 999 |
|
1000 |
{ 'NAME', Save_NAME, Load_NAME, CH_ARRAY}, |
|
1001 |
{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, CH_RIFF}, |
|
1002 |
{ 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, CH_RIFF}, |
|
1003 |
{ 'OPTS', SaveLoad_OPTS, SaveLoad_OPTS, CH_RIFF}, |
|
1004 |
{ 'CHTS', Save_CHTS, Load_CHTS, CH_RIFF | CH_LAST} |
|
1005 |
}; |