src/misc.cpp
author Tero Marttila <terom@fixme.fi>
Fri, 19 Dec 2008 02:20:26 +0200
changeset 10441 d09735696a9e
parent 10438 51bff16a04c9
permissions -rw-r--r--
don't generate a heightmap for <64 tile maps
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 9087
diff changeset
     3
/** @file misc.cpp Misc functions that shouldn't be here. */
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6091
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
862800791170 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1881
diff changeset
     6
#include "openttd.h"
2308
53435f3570e7 (svn r2832) Missing #include
tron
parents: 2295
diff changeset
     7
#include "currency.h"
6453
226bcddeba32 (svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents: 6350
diff changeset
     8
#include "landscape.h"
8763
81fadd257f67 (svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents: 8434
diff changeset
     9
#include "news_func.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
#include "saveload.h"
1752
d65cd19f7117 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1595
diff changeset
    11
#include "vehicle_gui.h"
2159
f6284cf5fab0 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2112
diff changeset
    12
#include "variables.h"
8965
29a591456a2f (svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents: 8925
diff changeset
    13
#include "cheat_func.h"
2706
fc872b9b17a7 (svn r3250) -Fix: AIs weren't uninitialized when a new game was loaded
truelight
parents: 2685
diff changeset
    14
#include "ai/ai.h"
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    15
#include "newgrf_house.h"
6091
c8827d9ae04a (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 5971
diff changeset
    16
#include "cargotype.h"
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6491
diff changeset
    17
#include "group.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8221
diff changeset
    18
#include "viewport_func.h"
8119
52b48108425a (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 7971
diff changeset
    19
#include "economy_func.h"
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8119
diff changeset
    20
#include "zoom_func.h"
8131
160939e24ed3 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8123
diff changeset
    21
#include "functions.h"
8139
4e91c448c409 (svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents: 8131
diff changeset
    22
#include "map_func.h"
8140
0d0d8c94f84b (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8139
diff changeset
    23
#include "date_func.h"
8144
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8140
diff changeset
    24
#include "vehicle_func.h"
65cec0877b78 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8140
diff changeset
    25
#include "texteff.hpp"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8221
diff changeset
    26
#include "gfx_func.h"
8925
e0d37ce1eba8 (svn r12695) -Codechange: only allocate window structs when needed. Based on a patch by Alberth.
rubidium
parents: 8819
diff changeset
    27
#include "core/alloc_type.hpp"
9457
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9413
diff changeset
    28
#include "gamelog.h"
9005
d6b0e0a54ef2 (svn r12800) -Codechange: move the animated tile related functions out of texteff.cpp (it isn't a text effect after all). Also remove a few more functions from functions.
rubidium
parents: 8987
diff changeset
    29
#include "animated_tile_func.h"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9111
diff changeset
    30
#include "tilehighlight_func.h"
9280
8adb36dcebab (svn r13146) -Codechange: vehicle_base.h doesn't need to be included in vehicle_gui.h.
rubidium
parents: 9174
diff changeset
    31
#include "core/bitmath_func.hpp"
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents: 9659
diff changeset
    32
#include "network/network_func.h"
8224
c5a64d87cc54 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8221
diff changeset
    33
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8258
diff changeset
    34
#include "table/strings.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8258
diff changeset
    35
#include "table/sprites.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
8973
749e572f9378 (svn r12765) -Codechange: move some stuff out of variables.h that required including other headers in variables.h.
rubidium
parents: 8965
diff changeset
    37
extern TileIndex _cur_tileloop_tile;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    39
void InitializeVehicles();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    40
void InitializeWaypoints();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    41
void InitializeDepots();
10127
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents: 9898
diff changeset
    42
void InitializeEngineRenews();
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    43
void InitializeOrders();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    44
void InitializeClearLand();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    45
void InitializeRailGui();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    46
void InitializeRoadGui();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    47
void InitializeAirportGui();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    48
void InitializeDockGui();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    49
void InitializeIndustries();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    50
void InitializeTowns();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    51
void InitializeTrees();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    52
void InitializeSigns();
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    53
void InitializeStations();
7010
6f0d9f03180d (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 6879
diff changeset
    54
void InitializeCargoPackets();
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10127
diff changeset
    55
void InitializeCompanies();
8965
29a591456a2f (svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents: 8925
diff changeset
    56
void InitializeCheats();
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
    57
void InitializeNPF();
8987
80d22b9c2a0c (svn r12782) -Codechange: remove some functions from functions.h and do not statically 'waste' memory when the old name array is not needed anymore.
rubidium
parents: 8975
diff changeset
    58
void InitializeOldNames();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    59
9409
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9359
diff changeset
    60
void InitializeGame(uint size_x, uint size_y, bool reset_date)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    61
{
2051
e369160ce2f3 (svn r2560) Fix: various minor code changes.
ludde
parents: 2050
diff changeset
    62
	AllocateMap(size_x, size_y);
e369160ce2f3 (svn r2560) Fix: various minor code changes.
ludde
parents: 2050
diff changeset
    63
7889
e74ce8853ba7 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 7626
diff changeset
    64
	SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    65
6231
ff7454d35935 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6201
diff changeset
    66
	_pause_game = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	_fast_forward = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
	_tick_counter = 0;
7018
71e174292e42 (svn r10276) -Codechange: made a counter based on milliseconds and independent of the game-state to base double-click and TGP Generation Process on
truelight
parents: 7010
diff changeset
    69
	_realtime_tick = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
	_date_fract = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
	_cur_tileloop_tile = 0;
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9409
diff changeset
    72
	_settings_game = _settings_newgame;
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
    73
9409
a4fc0d50c588 (svn r13320) -Codechange: move some enums from openttd.h to more logical locations.
rubidium
parents: 9359
diff changeset
    74
	if (reset_date) {
9413
7042a8ec3fa8 (svn r13325) -Codechange: split the client-side only settings from the settings stored in the savegame so there is no need to have a duplicate copy of it for new games.
rubidium
parents: 9409
diff changeset
    75
		SetDate(ConvertYMDToDate(_settings_game.game_creation.starting_year, 0, 1));
9087
263ff8feb85a (svn r12946) -Fix: do not allocate the OldNames table when creating a new game as it won't be used anyway.
rubidium
parents: 9005
diff changeset
    76
		InitializeOldNames();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    77
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
10127
4f53c1cfcfe9 (svn r14313) -Codechange: Move functions dealing with the EngineRenew pool to their own file.
frosch
parents: 9898
diff changeset
    79
	InitializeEngineRenews();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	InitializeVehicles();
1542
62a03537ad0b (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1538
diff changeset
    81
	InitializeWaypoints();
4347
38fc1b161e89 (svn r6048) -Codechange: all InitializeXXX are plural, just not Depot
truelight
parents: 4344
diff changeset
    82
	InitializeDepots();
1024
5e446b5b3ec5 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1009
diff changeset
    83
	InitializeOrders();
6643
f81bee57bc09 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6491
diff changeset
    84
	InitializeGroup();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
	InitNewsItemStructs();
2051
e369160ce2f3 (svn r2560) Fix: various minor code changes.
ludde
parents: 2050
diff changeset
    87
	InitializeLandscape();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	InitializeClearLand();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    89
	InitializeRailGui();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	InitializeRoadGui();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    91
	InitializeAirportGui();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	InitializeDockGui();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    93
	InitializeTowns();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    94
	InitializeTrees();
988
4304525d1b8b (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents: 983
diff changeset
    95
	InitializeSigns();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	InitializeStations();
7010
6f0d9f03180d (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 6879
diff changeset
    97
	InitializeCargoPackets();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
	InitializeIndustries();
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
    99
	InitializeBuildingCounts();
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
   100
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   101
	InitializeTrains();
1247
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1245
diff changeset
   102
	InitializeNPF();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10127
diff changeset
   104
	InitializeCompanies();
2706
fc872b9b17a7 (svn r3250) -Fix: AIs weren't uninitialized when a new game was loaded
truelight
parents: 2685
diff changeset
   105
	AI_Initialize();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
	InitializeCheats();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
	InitTextEffects();
9898
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents: 9659
diff changeset
   109
#ifdef ENABLE_NETWORK
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents: 9659
diff changeset
   110
	NetworkInitChatMessage();
75347c78b276 (svn r14047) -Codechange: move chatmessage handling to the network directory as that's the only case chat messages are used. Furthermore remove any trace of chatmessages when compiling without network support.
rubidium
parents: 9659
diff changeset
   111
#endif /* ENABLE_NETWORK */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
	InitializeAnimatedTiles();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
	InitializeLandscapeVariables(false);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
	ResetObjectToPlace();
9457
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9413
diff changeset
   117
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9413
diff changeset
   118
	GamelogReset();
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9413
diff changeset
   119
	GamelogStartAction(GLAT_START);
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9413
diff changeset
   120
	GamelogRevision();
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9413
diff changeset
   121
	GamelogMode();
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9413
diff changeset
   122
	GamelogGRFAddList(_grfconfig);
75f11a6caef8 (svn r13375) -Add: logging of actions that could possibly cause desyncs and crashes to simplify debugging. See readme.txt for details
smatz
parents: 9413
diff changeset
   123
	GamelogStopAction();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
5108
aeaef6fe53b7 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   126
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6091
diff changeset
   127
/* Calculate constants that depend on the landscape type. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
void InitializeLandscapeVariables(bool only_constants)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
{
6091
c8827d9ae04a (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 5971
diff changeset
   130
	if (only_constants) return;
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
   131
6350
04b19f551aec (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents: 6332
diff changeset
   132
	for (CargoID i = 0; i < NUM_CARGO; i++) {
6091
c8827d9ae04a (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 5971
diff changeset
   133
		_cargo_payment_rates[i] = GetCargo(i)->initial_payment;
c8827d9ae04a (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 5971
diff changeset
   134
		_cargo_payment_rates_frac[i] = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
static const SaveLoadGlobVarList _date_desc[] = {
4383
f1e2d6c7527e (svn r6136) -Fix: _cur_year wasn't converting when reading pre-31 savegames, causing nasty desyncs
truelight
parents: 4347
diff changeset
   139
	SLEG_CONDVAR(_date,                   SLE_FILE_U16 | SLE_VAR_I32,  0,  30),
f1e2d6c7527e (svn r6136) -Fix: _cur_year wasn't converting when reading pre-31 savegames, causing nasty desyncs
truelight
parents: 4347
diff changeset
   140
	SLEG_CONDVAR(_date,                   SLE_INT32,                  31, SL_MAX_VERSION),
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   141
	    SLEG_VAR(_date_fract,             SLE_UINT16),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   142
	    SLEG_VAR(_tick_counter,           SLE_UINT16),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   143
	    SLEG_VAR(_vehicle_id_ctr_day,     SLE_UINT16),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   144
	    SLEG_VAR(_age_cargo_skip_counter, SLE_UINT8),
5971
b21fda7c7f1e (svn r8660) -Fix
tron
parents: 5893
diff changeset
   145
	SLE_CONDNULL(1, 0, 45),
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   146
	SLEG_CONDVAR(_cur_tileloop_tile,      SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   147
	SLEG_CONDVAR(_cur_tileloop_tile,      SLE_UINT32,                  6, SL_MAX_VERSION),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   148
	    SLEG_VAR(_disaster_delay,         SLE_UINT16),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   149
	    SLEG_VAR(_station_tick_ctr,       SLE_UINT16),
8434
558c39956ba2 (svn r12004) -Codechange: refactor the random functions to reduce code duplication.
rubidium
parents: 8376
diff changeset
   150
	    SLEG_VAR(_random.state[0],        SLE_UINT32),
558c39956ba2 (svn r12004) -Codechange: refactor the random functions to reduce code duplication.
rubidium
parents: 8376
diff changeset
   151
	    SLEG_VAR(_random.state[1],        SLE_UINT32),
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   152
	SLEG_CONDVAR(_cur_town_ctr,           SLE_FILE_U8  | SLE_VAR_U32,  0, 9),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   153
	SLEG_CONDVAR(_cur_town_ctr,           SLE_UINT32,                 10, SL_MAX_VERSION),
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 10127
diff changeset
   154
	    SLEG_VAR(_cur_company_tick_index, SLE_FILE_U8  | SLE_VAR_U32),
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   155
	    SLEG_VAR(_next_competitor_start,  SLE_FILE_U16 | SLE_VAR_U32),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   156
	    SLEG_VAR(_trees_tick_ctr,         SLE_UINT8),
6231
ff7454d35935 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6201
diff changeset
   157
	SLEG_CONDVAR(_pause_game,             SLE_UINT8,                   4, SL_MAX_VERSION),
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   158
	SLEG_CONDVAR(_cur_town_iter,          SLE_UINT32,                 11, SL_MAX_VERSION),
3046
baa216f9911a (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3033
diff changeset
   159
	    SLEG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   160
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   161
6201
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6091
diff changeset
   162
/* Save load date related variables as well as persistent tick counters
bee01dc45e39 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6091
diff changeset
   163
 * XXX: currently some unrelated stuff is just put here */
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   164
static void SaveLoad_DATE()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   165
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   166
	SlGlobList(_date_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   170
static const SaveLoadGlobVarList _view_desc[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   171
	SLEG_CONDVAR(_saved_scrollpos_x,    SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   172
	SLEG_CONDVAR(_saved_scrollpos_x,    SLE_INT32,                  6, SL_MAX_VERSION),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   173
	SLEG_CONDVAR(_saved_scrollpos_y,    SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   174
	SLEG_CONDVAR(_saved_scrollpos_y,    SLE_INT32,                  6, SL_MAX_VERSION),
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   175
	    SLEG_VAR(_saved_scrollpos_zoom, SLE_UINT8),
3046
baa216f9911a (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3033
diff changeset
   176
	    SLEG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   178
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   179
static void SaveLoad_VIEW()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   180
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   181
	SlGlobList(_view_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   182
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
1218
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   184
static uint32 _map_dim_x;
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   185
static uint32 _map_dim_y;
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   186
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   187
static const SaveLoadGlobVarList _map_dimensions[] = {
3046
baa216f9911a (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3033
diff changeset
   188
	SLEG_CONDVAR(_map_dim_x, SLE_UINT32, 6, SL_MAX_VERSION),
baa216f9911a (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3033
diff changeset
   189
	SLEG_CONDVAR(_map_dim_y, SLE_UINT32, 6, SL_MAX_VERSION),
baa216f9911a (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3033
diff changeset
   190
	    SLEG_END()
1218
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   191
};
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   192
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   193
static void Save_MAPS()
1218
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   194
{
1219
1163c59b8650 (svn r1723) Save the map size in tiles, not number of bits
tron
parents: 1218
diff changeset
   195
	_map_dim_x = MapSizeX();
1163c59b8650 (svn r1723) Save the map size in tiles, not number of bits
tron
parents: 1218
diff changeset
   196
	_map_dim_y = MapSizeY();
1218
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   197
	SlGlobList(_map_dimensions);
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   198
}
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   199
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   200
static void Load_MAPS()
1218
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   201
{
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   202
	SlGlobList(_map_dimensions);
2051
e369160ce2f3 (svn r2560) Fix: various minor code changes.
ludde
parents: 2050
diff changeset
   203
	AllocateMap(_map_dim_x, _map_dim_y);
1218
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   204
}
c6a624956ac6 (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   205
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   206
enum {
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   207
	MAP_SL_BUF_SIZE = 4096
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   208
};
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   209
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   210
static void Load_MAPT()
2050
3b37e813823a (svn r2559) Cleaned up new saveload code for the map
ludde
parents: 2049
diff changeset
   211
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   212
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   213
	TileIndex size = MapSize();
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
   214
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   215
	for (TileIndex i = 0; i != size;) {
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   216
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   217
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; 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
   218
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   219
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   220
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   221
static void Save_MAPT()
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
   222
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   223
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   224
	TileIndex size = MapSize();
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
   225
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
   226
	SlSetLength(size);
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   227
	for (TileIndex i = 0; i != size;) {
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   228
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) buf[j] = _m[i++].type_height;
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   229
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
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
   230
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   231
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   232
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   233
static void Load_MAP1()
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
   234
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   235
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   236
	TileIndex size = MapSize();
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
   237
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   238
	for (TileIndex i = 0; i != size;) {
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   239
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   240
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; 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
   241
	}
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
   242
}
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
   243
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   244
static void Save_MAP1()
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
   245
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   246
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   247
	TileIndex size = MapSize();
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
   248
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
   249
	SlSetLength(size);
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   250
	for (TileIndex i = 0; i != size;) {
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   251
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) buf[j] = _m[i++].m1;
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   252
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
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
   253
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   254
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   255
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   256
static void Load_MAP2()
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
   257
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   258
	SmallStackSafeStackAlloc<uint16, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   259
	TileIndex size = MapSize();
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
   260
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   261
	for (TileIndex i = 0; i != size;) {
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   262
		SlArray(buf, MAP_SL_BUF_SIZE,
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
   263
			/* 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
   264
			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
   265
		);
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   266
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) _m[i++].m2 = buf[j];
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
   267
	}
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
   268
}
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
   269
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   270
static void Save_MAP2()
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
   271
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   272
	SmallStackSafeStackAlloc<uint16, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   273
	TileIndex size = MapSize();
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
   274
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   275
	SlSetLength(size * sizeof(uint16));
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   276
	for (TileIndex i = 0; i != size;) {
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   277
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) buf[j] = _m[i++].m2;
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   278
		SlArray(buf, MAP_SL_BUF_SIZE, 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
   279
	}
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
   280
}
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
   281
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   282
static void Load_MAP3()
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
   283
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   284
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   285
	TileIndex size = MapSize();
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
   286
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   287
	for (TileIndex i = 0; i != size;) {
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   288
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   289
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) _m[i++].m3 = 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
   290
	}
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
   291
}
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
   292
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   293
static void Save_MAP3()
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
   294
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   295
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   296
	TileIndex size = MapSize();
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
   297
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
   298
	SlSetLength(size);
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   299
	for (TileIndex i = 0; i != size;) {
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   300
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) buf[j] = _m[i++].m3;
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   301
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
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
   302
	}
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
   303
}
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
   304
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   305
static void Load_MAP4()
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
   306
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   307
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   308
	TileIndex size = MapSize();
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
   309
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   310
	for (TileIndex i = 0; i != size;) {
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   311
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   312
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) _m[i++].m4 = 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
   313
	}
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
   314
}
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
   315
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   316
static void Save_MAP4()
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
   317
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   318
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   319
	TileIndex size = MapSize();
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
   320
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
   321
	SlSetLength(size);
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   322
	for (TileIndex i = 0; i != size;) {
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   323
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) buf[j] = _m[i++].m4;
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   324
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
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
   325
	}
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
   326
}
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
   327
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   328
static void Load_MAP5()
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
   329
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   330
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   331
	TileIndex size = MapSize();
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
   332
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   333
	for (TileIndex i = 0; i != size;) {
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   334
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   335
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) _m[i++].m5 = 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
   336
	}
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
   337
}
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
   338
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   339
static void Save_MAP5()
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
   340
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   341
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   342
	TileIndex size = MapSize();
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
   343
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
   344
	SlSetLength(size);
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   345
	for (TileIndex i = 0; i != size;) {
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   346
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) buf[j] = _m[i++].m5;
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   347
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
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
   348
	}
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
   349
}
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
   350
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   351
static void Load_MAP6()
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
   352
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   353
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   354
	TileIndex size = MapSize();
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
   355
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5108
diff changeset
   356
	if (CheckSavegameVersion(42)) {
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   357
		for (TileIndex i = 0; i != size;) {
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   358
			/* 1024, otherwise we overflow on 64x64 maps! */
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   359
            /* XXX: fail */
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   360
			SlArray(buf, 1024, SLE_UINT8);
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   361
			for (uint j = 0; j != 1024 && i < size - 4; j++) {
5596
5bf7128140a0 (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5587
diff changeset
   362
				_m[i++].m6 = GB(buf[j], 0, 2);
5bf7128140a0 (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5587
diff changeset
   363
				_m[i++].m6 = GB(buf[j], 2, 2);
5bf7128140a0 (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5587
diff changeset
   364
				_m[i++].m6 = GB(buf[j], 4, 2);
5bf7128140a0 (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5587
diff changeset
   365
				_m[i++].m6 = GB(buf[j], 6, 2);
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5108
diff changeset
   366
			}
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5108
diff changeset
   367
		}
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5108
diff changeset
   368
	} else {
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   369
		for (TileIndex i = 0; i != size;) {
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   370
			SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   371
			for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) _m[i++].m6 = buf[j];
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
   372
		}
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
   373
	}
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
   374
}
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
   375
6247
7d81e3a5d803 (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6231
diff changeset
   376
static void Save_MAP6()
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
   377
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   378
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   379
	TileIndex size = MapSize();
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
   380
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5108
diff changeset
   381
	SlSetLength(size);
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   382
	for (TileIndex i = 0; i != size;) {
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   383
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) buf[j] = _m[i++].m6;
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   384
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
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
   385
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   386
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   387
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   388
static void Load_MAP7()
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   389
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   390
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   391
	TileIndex size = MapSize();
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   392
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   393
	for (TileIndex i = 0; i != size;) {
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   394
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   395
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) _me[i++].m7 = buf[j];
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   396
	}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   397
}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   398
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   399
static void Save_MAP7()
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   400
{
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   401
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   402
	TileIndex size = MapSize();
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   403
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   404
	SlSetLength(size);
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   405
	for (TileIndex i = 0; i != size;) {
10438
51bff16a04c9 initial mini-map stuff
terom@frrb.lan
parents: 10207
diff changeset
   406
		for (uint j = 0; j != MAP_SL_BUF_SIZE && i != size; j++) buf[j] = _me[i++].m7;
8376
aab0b14b96e3 (svn r11943) -Codechange: add and use a simple structure to support small stacks by allocating it on the heap or pushing a few kB of data onto the stack when there is a large stack.
rubidium
parents: 8264
diff changeset
   407
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   408
	}
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   409
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   410
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5584
diff changeset
   411
extern const ChunkHandler _misc_chunk_handlers[] = {
4344
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   412
	{ 'MAPS', Save_MAPS,     Load_MAPS,     CH_RIFF },
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   413
	{ 'MAPT', Save_MAPT,     Load_MAPT,     CH_RIFF },
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   414
	{ 'MAPO', Save_MAP1,     Load_MAP1,     CH_RIFF },
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   415
	{ 'MAP2', Save_MAP2,     Load_MAP2,     CH_RIFF },
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   416
	{ 'M3LO', Save_MAP3,     Load_MAP3,     CH_RIFF },
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   417
	{ 'M3HI', Save_MAP4,     Load_MAP4,     CH_RIFF },
7e123fec5b0b (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   418
	{ 'MAP5', Save_MAP5,     Load_MAP5,     CH_RIFF },
5596
5bf7128140a0 (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5587
diff changeset
   419
	{ 'MAPE', Save_MAP6,     Load_MAP6,     CH_RIFF },
6332
f3f436dcd7d0 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6247
diff changeset
   420
	{ 'MAP7', Save_MAP7,     Load_MAP7,     CH_RIFF },
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   421
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   422
	{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, CH_RIFF},
8965
29a591456a2f (svn r12757) -Codechange: move all cheat related stuff from all over the place to a single location.
rubidium
parents: 8925
diff changeset
   423
	{ 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, CH_RIFF | CH_LAST},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   424
};