src/misc.cpp
author convert-repo
Mon, 07 Apr 2008 16:21:55 +0000
changeset 10076 dfd70e42c4ae
parent 9315 336e6518acb3
child 10164 3ff9e65f3d49
permissions -rw-r--r--
update tags
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2163
diff changeset
     2
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6417
diff changeset
     3
/** @file misc.cpp */
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6417
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#include "stdafx.h"
1891
92a3b0aa0946 (svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents: 1881
diff changeset
     6
#include "openttd.h"
2308
4ed48829d8e8 (svn r2832) Missing #include
tron
parents: 2295
diff changeset
     7
#include "currency.h"
6949
72d11a1e1e60 (svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents: 6676
diff changeset
     8
#include "landscape.h"
9259
088d3649dd4f (svn r12459) -Codechange: split news.h into news_type.h and news_func.h.
rubidium
parents: 8930
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
cdbfb2f23e72 (svn r2256) - Fix: Trains cannot find a depot when they are in a tunnel. (glx)
matthijs
parents: 1595
diff changeset
    11
#include "vehicle_gui.h"
2159
3b634157c3b2 (svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents: 2112
diff changeset
    12
#include "variables.h"
2706
d31bd0aa0096 (svn r3250) -Fix: AIs weren't uninitialized when a new game was loaded
truelight
parents: 2685
diff changeset
    13
#include "ai/ai.h"
6658
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
    14
#include "newgrf_house.h"
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 6222
diff changeset
    15
#include "cargotype.h"
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6987
diff changeset
    16
#include "group.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8717
diff changeset
    17
#include "viewport_func.h"
8615
6b91ca653bad (svn r11680) -Codechange: refactor more out of openttd.h and functions.h.
rubidium
parents: 8467
diff changeset
    18
#include "economy_func.h"
8619
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8615
diff changeset
    19
#include "zoom_func.h"
8627
448ebf3a8291 (svn r11692) -Codechange: move some functions from 'functions.h' to a more logical place and remove about 50% of the includes of 'functions.h'
rubidium
parents: 8619
diff changeset
    20
#include "functions.h"
8635
3bbb6f87fced (svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents: 8627
diff changeset
    21
#include "map_func.h"
8636
2b158acb649c (svn r11702) -Codechange: move all date related stuff to date*.
rubidium
parents: 8635
diff changeset
    22
#include "date_func.h"
8640
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    23
#include "vehicle_func.h"
1e93b81e96d2 (svn r11706) -Codechange: split vehicle.h and remove another bunch of useless includes.
rubidium
parents: 8636
diff changeset
    24
#include "texteff.hpp"
8710
52015340050c (svn r11777) -Codechange: split the string header and make do not include it when it's not necessary.
rubidium
parents: 8640
diff changeset
    25
#include "string_func.h"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8717
diff changeset
    26
#include "gfx_func.h"
8872
dd23eb1922b6 (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: 8760
diff changeset
    27
#include "core/alloc_func.hpp"
8720
4e60c30e2006 (svn r11787) -Codechange: more header rewrites. This time related to viewport.h.
rubidium
parents: 8717
diff changeset
    28
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8754
diff changeset
    29
#include "table/strings.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8754
diff changeset
    30
#include "table/sprites.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
1328
e069d2db0e4c (svn r1832) Next byte -> char iteration: custom names
tron
parents: 1313
diff changeset
    32
char _name_array[512][32];
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    34
void InitializeVehicles();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    35
void InitializeWaypoints();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    36
void InitializeDepots();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    37
void InitializeEngines();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    38
void InitializeOrders();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    39
void InitializeClearLand();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    40
void InitializeRailGui();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    41
void InitializeRoadGui();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    42
void InitializeAirportGui();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    43
void InitializeDockGui();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    44
void InitializeIndustries();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    45
void InitializeMainGui();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    46
void InitializeTowns();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    47
void InitializeTrees();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    48
void InitializeSigns();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    49
void InitializeStations();
7506
e52d89f5c7c1 (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 7375
diff changeset
    50
void InitializeCargoPackets();
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    51
static void InitializeNameMgr();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    52
void InitializePlayers();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    53
static void InitializeCheats();
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
    54
void InitializeNPF();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    55
2828
996de8e891c7 (svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents: 2706
diff changeset
    56
void InitializeGame(int mode, uint size_x, uint size_y)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    57
{
2051
44b6b091beb3 (svn r2560) Fix: various minor code changes.
ludde
parents: 2050
diff changeset
    58
	AllocateMap(size_x, size_y);
44b6b091beb3 (svn r2560) Fix: various minor code changes.
ludde
parents: 2050
diff changeset
    59
8385
aedd7656cfd1 (svn r11440) -Codechange: replace magic numbers with enumified WindowHighlightMode constants. Patch by SmatZ.
rubidium
parents: 8122
diff changeset
    60
	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
    61
6557
8381016f71f3 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6527
diff changeset
    62
	_pause_game = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    63
	_fast_forward = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    64
	_tick_counter = 0;
7514
98a024616010 (svn r10276) -Codechange: made a counter based on milliseconds and independent of the game-state to base double-click and TGP Generation Process on
truelight
parents: 7506
diff changeset
    65
	_realtime_tick = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
	_date_fract = 0;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
	_cur_tileloop_tile = 0;
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
    68
2828
996de8e891c7 (svn r3376) -Codechange: made enums for GenerateWorld and InitializeGame 'mode'
truelight
parents: 2706
diff changeset
    69
	if ((mode & IG_DATE_RESET) == IG_DATE_RESET) {
4295
66d2c96579a6 (svn r5928) -Cleanup: remove ConvertIntDate and use ConvertYMDToDate as ConvertIntDate was only called with Years.
rubidium
parents: 4285
diff changeset
    70
		SetDate(ConvertYMDToDate(_patches.starting_year, 0, 1));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
2848
cb4b1cc0bf65 (svn r3396) - Autoreplace changes:
peter1138
parents: 2828
diff changeset
    73
	InitializeEngines();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
	InitializeVehicles();
1542
2ca6d1624e6d (svn r2046) -Codechange: moved all waypoint code to waypoint.c/waypoint.h
truelight
parents: 1538
diff changeset
    75
	InitializeWaypoints();
4347
79b04c2cef95 (svn r6048) -Codechange: all InitializeXXX are plural, just not Depot
truelight
parents: 4344
diff changeset
    76
	InitializeDepots();
1024
9b06b01490a4 (svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
truelight
parents: 1009
diff changeset
    77
	InitializeOrders();
7139
4ae3ab180d05 (svn r9874) -Feature: advanced vehicle lists a.k.a. group interface. Now you can make groups of vehicles and perform all kinds of tasks on that given group. Original code by nycom and graphics by skidd13.
rubidium
parents: 6987
diff changeset
    78
	InitializeGroup();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    80
	InitNewsItemStructs();
2051
44b6b091beb3 (svn r2560) Fix: various minor code changes.
ludde
parents: 2050
diff changeset
    81
	InitializeLandscape();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
	InitializeClearLand();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
	InitializeRailGui();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    84
	InitializeRoadGui();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
	InitializeAirportGui();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    86
	InitializeDockGui();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    87
	InitializeTowns();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    88
	InitializeTrees();
988
2482369a61ff (svn r1486) -Codechange: moved all 'signs' stuff to signs.c/h and prepared it for
truelight
parents: 983
diff changeset
    89
	InitializeSigns();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    90
	InitializeStations();
7506
e52d89f5c7c1 (svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
rubidium
parents: 7375
diff changeset
    91
	InitializeCargoPackets();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    92
	InitializeIndustries();
6658
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
    93
	InitializeBuildingCounts();
3622
e1c16777dacb (svn r4520) -Fix: Did last commit in the wrong branch. Repair and shame on me.
celestar
parents: 3617
diff changeset
    94
	InitializeMainGui();
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
    95
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    96
	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
    97
	InitializeVehiclesGuiList();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    98
	InitializeTrains();
1247
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1245
diff changeset
    99
	InitializeNPF();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
2706
d31bd0aa0096 (svn r3250) -Fix: AIs weren't uninitialized when a new game was loaded
truelight
parents: 2685
diff changeset
   101
	AI_Initialize();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   102
	InitializePlayers();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   103
	InitializeCheats();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   104
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   105
	InitTextEffects();
7950
3d3ed007127a (svn r10932) -Codechange: replace "text" with "chat" for the chat related function and variables.
rubidium
parents: 7514
diff changeset
   106
	InitChatMessage();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   107
	InitializeAnimatedTiles();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   108
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
	InitializeLandscapeVariables(false);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
	ResetObjectToPlace();
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
4862
b45c1e638e7f (svn r6788) - Codechange: Add and use a function to test if a string ID is a custom name.
peter1138
parents: 4383
diff changeset
   114
bool IsCustomName(StringID id)
b45c1e638e7f (svn r6788) - Codechange: Add and use a function to test if a string ID is a custom name.
peter1138
parents: 4383
diff changeset
   115
{
b45c1e638e7f (svn r6788) - Codechange: Add and use a function to test if a string ID is a custom name.
peter1138
parents: 4383
diff changeset
   116
	return GB(id, 11, 5) == 15;
b45c1e638e7f (svn r6788) - Codechange: Add and use a function to test if a string ID is a custom name.
peter1138
parents: 4383
diff changeset
   117
}
b45c1e638e7f (svn r6788) - Codechange: Add and use a function to test if a string ID is a custom name.
peter1138
parents: 4383
diff changeset
   118
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   120
static void InitializeCheats()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
{
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
   122
	memset(&_cheats, 0, sizeof(Cheats));
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
}
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
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   126
static void InitializeNameMgr()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	memset(_name_array, 0, sizeof(_name_array));
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   129
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   130
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   131
/* Copy and convert old custom names to UTF-8 */
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   132
char *CopyFromOldName(StringID id)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
{
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   134
	if (!IsCustomName(id)) return NULL;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   136
	if (CheckSavegameVersion(37)) {
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   137
		/* Old names were 32 characters long, so 128 characters should be
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   138
		 * plenty to allow for expansion when converted to UTF-8. */
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   139
		char tmp[128];
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   140
		const char *strfrom = _name_array[GB(id, 0, 9)];
5108
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   141
		char *strto = tmp;
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   142
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   143
		for (; *strfrom != '\0'; strfrom++) {
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   144
			WChar c = (byte)*strfrom;
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   145
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   146
			/* Map from non-ISO8859-15 characters to UTF-8. */
5108
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   147
			switch (c) {
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   148
				case 0xA4: c = 0x20AC; break; // Euro
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   149
				case 0xA6: c = 0x0160; break; // S with caron
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   150
				case 0xA8: c = 0x0161; break; // s with caron
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   151
				case 0xB4: c = 0x017D; break; // Z with caron
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   152
				case 0xB8: c = 0x017E; break; // z with caron
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   153
				case 0xBC: c = 0x0152; break; // OE ligature
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   154
				case 0xBD: c = 0x0153; break; // oe ligature
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   155
				case 0xBE: c = 0x0178; break; // Y with diaresis
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   156
				default: break;
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   157
			}
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   158
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   159
			/* Check character will fit into our buffer. */
5108
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   160
			if (strto + Utf8CharLen(c) > lastof(tmp)) break;
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   161
5108
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   162
			strto += Utf8Encode(strto, c);
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   163
		}
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   164
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   165
		/* Terminate the new string and copy it back to the name array */
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   166
		*strto = '\0';
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   167
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   168
		return strdup(tmp);
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   169
	} else {
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   170
		/* Name will already be in UTF-8. */
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   171
		return strdup(_name_array[GB(id, 0, 9)]);
5108
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   172
	}
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   173
}
dc67d70b5a45 (svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
peter1138
parents: 5016
diff changeset
   174
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6417
diff changeset
   175
/* Calculate constants that depend on the landscape type. */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
void InitializeLandscapeVariables(bool only_constants)
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
{
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 6222
diff changeset
   178
	if (only_constants) return;
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
   179
6676
30aea9ac89bc (svn r9388) -Codechange: variable scope and type, and standardify all CargoID loops.
peter1138
parents: 6658
diff changeset
   180
	for (CargoID i = 0; i < NUM_CARGO; i++) {
6417
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 6222
diff changeset
   181
		_cargo_payment_rates[i] = GetCargo(i)->initial_payment;
26acff62d001 (svn r8826) -Codechange: Replace _cargoc's separate arrays with a regular struct array (with accessor) and implement new initialization method using cargo labels.
peter1138
parents: 6222
diff changeset
   182
		_cargo_payment_rates_frac[i] = 0;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   183
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   184
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   185
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   186
static void Load_NAME()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
	int index;
201
c40d343115f8 (svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents: 179
diff changeset
   189
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   190
	while ((index = SlIterateArray()) != -1) {
6987
b0f13039bda2 (svn r9672) -Cleanup: lots of coding style fixes around operands.
rubidium
parents: 6949
diff changeset
   191
		SlArray(_name_array[index], SlGetFieldLength(), SLE_UINT8);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
static const SaveLoadGlobVarList _date_desc[] = {
4383
3dcf52b1efd9 (svn r6136) -Fix: _cur_year wasn't converting when reading pre-31 savegames, causing nasty desyncs
truelight
parents: 4347
diff changeset
   196
	SLEG_CONDVAR(_date,                   SLE_FILE_U16 | SLE_VAR_I32,  0,  30),
3dcf52b1efd9 (svn r6136) -Fix: _cur_year wasn't converting when reading pre-31 savegames, causing nasty desyncs
truelight
parents: 4347
diff changeset
   197
	SLEG_CONDVAR(_date,                   SLE_INT32,                  31, SL_MAX_VERSION),
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   198
	    SLEG_VAR(_date_fract,             SLE_UINT16),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   199
	    SLEG_VAR(_tick_counter,           SLE_UINT16),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   200
	    SLEG_VAR(_vehicle_id_ctr_day,     SLE_UINT16),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   201
	    SLEG_VAR(_age_cargo_skip_counter, SLE_UINT8),
6222
50e47f803549 (svn r8660) -Fix
tron
parents: 6144
diff changeset
   202
	SLE_CONDNULL(1, 0, 45),
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   203
	SLEG_CONDVAR(_cur_tileloop_tile,      SLE_FILE_U16 | SLE_VAR_U32,  0, 5),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   204
	SLEG_CONDVAR(_cur_tileloop_tile,      SLE_UINT32,                  6, SL_MAX_VERSION),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   205
	    SLEG_VAR(_disaster_delay,         SLE_UINT16),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   206
	    SLEG_VAR(_station_tick_ctr,       SLE_UINT16),
8930
361433723616 (svn r12004) -Codechange: refactor the random functions to reduce code duplication.
rubidium
parents: 8872
diff changeset
   207
	    SLEG_VAR(_random.state[0],        SLE_UINT32),
361433723616 (svn r12004) -Codechange: refactor the random functions to reduce code duplication.
rubidium
parents: 8872
diff changeset
   208
	    SLEG_VAR(_random.state[1],        SLE_UINT32),
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   209
	SLEG_CONDVAR(_cur_town_ctr,           SLE_FILE_U8  | SLE_VAR_U32,  0, 9),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   210
	SLEG_CONDVAR(_cur_town_ctr,           SLE_UINT32,                 10, SL_MAX_VERSION),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   211
	    SLEG_VAR(_cur_player_tick_index,  SLE_FILE_U8  | SLE_VAR_U32),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   212
	    SLEG_VAR(_next_competitor_start,  SLE_FILE_U16 | SLE_VAR_U32),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   213
	    SLEG_VAR(_trees_tick_ctr,         SLE_UINT8),
6557
8381016f71f3 (svn r9034) -Codechange: renamed _pause to _pause_game, as some targets already have
truelight
parents: 6527
diff changeset
   214
	SLEG_CONDVAR(_pause_game,             SLE_UINT8,                   4, SL_MAX_VERSION),
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   215
	SLEG_CONDVAR(_cur_town_iter,          SLE_UINT32,                 11, SL_MAX_VERSION),
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3033
diff changeset
   216
	    SLEG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   218
6527
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6417
diff changeset
   219
/* Save load date related variables as well as persistent tick counters
f584ab6d87f8 (svn r8987) -Cleanup: doxygen changes. Again. Mostly (still) @files missing tags and (more than just) a few comments style.
belugas
parents: 6417
diff changeset
   220
 * XXX: currently some unrelated stuff is just put here */
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   221
static void SaveLoad_DATE()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   222
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   223
	SlGlobList(_date_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   225
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   226
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
static const SaveLoadGlobVarList _view_desc[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   228
	SLEG_CONDVAR(_saved_scrollpos_x,    SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   229
	SLEG_CONDVAR(_saved_scrollpos_x,    SLE_INT32,                  6, SL_MAX_VERSION),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   230
	SLEG_CONDVAR(_saved_scrollpos_y,    SLE_FILE_I16 | SLE_VAR_I32, 0, 5),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   231
	SLEG_CONDVAR(_saved_scrollpos_y,    SLE_INT32,                  6, SL_MAX_VERSION),
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   232
	    SLEG_VAR(_saved_scrollpos_zoom, SLE_UINT8),
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3033
diff changeset
   233
	    SLEG_END()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   234
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   236
static void SaveLoad_VIEW()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   237
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   238
	SlGlobList(_view_desc);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   239
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
1218
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   241
static uint32 _map_dim_x;
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   242
static uint32 _map_dim_y;
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   243
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   244
static const SaveLoadGlobVarList _map_dimensions[] = {
3046
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3033
diff changeset
   245
	SLEG_CONDVAR(_map_dim_x, SLE_UINT32, 6, SL_MAX_VERSION),
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3033
diff changeset
   246
	SLEG_CONDVAR(_map_dim_y, SLE_UINT32, 6, SL_MAX_VERSION),
f81bee40701f (svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
Darkvater
parents: 3033
diff changeset
   247
	    SLEG_END()
1218
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   248
};
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   249
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   250
static void Save_MAPS()
1218
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   251
{
1219
6a1f8d818d58 (svn r1723) Save the map size in tiles, not number of bits
tron
parents: 1218
diff changeset
   252
	_map_dim_x = MapSizeX();
6a1f8d818d58 (svn r1723) Save the map size in tiles, not number of bits
tron
parents: 1218
diff changeset
   253
	_map_dim_y = MapSizeY();
1218
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   254
	SlGlobList(_map_dimensions);
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   255
}
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   256
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   257
static void Load_MAPS()
1218
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   258
{
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   259
	SlGlobList(_map_dimensions);
2051
44b6b091beb3 (svn r2560) Fix: various minor code changes.
ludde
parents: 2050
diff changeset
   260
	AllocateMap(_map_dim_x, _map_dim_y);
1218
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   261
}
353a7773bc3c (svn r1722) -Feature: Bigger maps - anyone?
tron
parents: 1217
diff changeset
   262
8872
dd23eb1922b6 (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: 8760
diff changeset
   263
enum {
dd23eb1922b6 (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: 8760
diff changeset
   264
	MAP_SL_BUF_SIZE = 4096
dd23eb1922b6 (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: 8760
diff changeset
   265
};
dd23eb1922b6 (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: 8760
diff changeset
   266
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   267
static void Load_MAPT()
2050
947934d248c5 (svn r2559) Cleaned up new saveload code for the map
ludde
parents: 2049
diff changeset
   268
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   269
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   270
	TileIndex size = MapSize();
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   271
8872
dd23eb1922b6 (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: 8760
diff changeset
   272
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   273
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
dd23eb1922b6 (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: 8760
diff changeset
   274
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].type_height = buf[j];
817
4f9377b7fd2b (svn r1288) -Codechange: changed _map2 to an uint16. It is still saved and loaded as
truelight
parents: 785
diff changeset
   275
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   276
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   277
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   278
static void Save_MAPT()
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1024
diff changeset
   279
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   280
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   281
	TileIndex size = MapSize();
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   282
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   283
	SlSetLength(size);
8872
dd23eb1922b6 (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: 8760
diff changeset
   284
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   285
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].type_height;
dd23eb1922b6 (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: 8760
diff changeset
   286
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   287
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   288
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   289
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   290
static void Load_MAP1()
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1024
diff changeset
   291
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   292
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   293
	TileIndex size = MapSize();
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   294
8872
dd23eb1922b6 (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: 8760
diff changeset
   295
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   296
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
dd23eb1922b6 (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: 8760
diff changeset
   297
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m1 = buf[j];
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   298
	}
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   299
}
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   300
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   301
static void Save_MAP1()
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   302
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   303
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   304
	TileIndex size = MapSize();
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   305
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   306
	SlSetLength(size);
8872
dd23eb1922b6 (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: 8760
diff changeset
   307
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   308
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m1;
dd23eb1922b6 (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: 8760
diff changeset
   309
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   310
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   311
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   313
static void Load_MAP2()
1093
e8d26c7dc42f (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1024
diff changeset
   314
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   315
	SmallStackSafeStackAlloc<uint16, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   316
	TileIndex size = MapSize();
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   317
8872
dd23eb1922b6 (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: 8760
diff changeset
   318
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   319
		SlArray(buf, MAP_SL_BUF_SIZE,
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   320
			/* In those versions the m2 was 8 bits */
2685
00111d5ca47f (svn r3227) -Codechange: [Savegame] removed 'minor' version, and renamed 'major' version to just: version.
truelight
parents: 2548
diff changeset
   321
			CheckSavegameVersion(5) ? SLE_FILE_U8 | SLE_VAR_U16 : SLE_UINT16
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   322
		);
8872
dd23eb1922b6 (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: 8760
diff changeset
   323
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m2 = buf[j];
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   324
	}
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   325
}
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   326
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   327
static void Save_MAP2()
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   328
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   329
	SmallStackSafeStackAlloc<uint16, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   330
	TileIndex size = MapSize();
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   331
8872
dd23eb1922b6 (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: 8760
diff changeset
   332
	SlSetLength(size * sizeof(uint16));
dd23eb1922b6 (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: 8760
diff changeset
   333
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   334
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m2;
dd23eb1922b6 (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: 8760
diff changeset
   335
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT16);
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   336
	}
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   337
}
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   338
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   339
static void Load_MAP3()
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   340
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   341
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   342
	TileIndex size = MapSize();
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   343
8872
dd23eb1922b6 (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: 8760
diff changeset
   344
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   345
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
dd23eb1922b6 (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: 8760
diff changeset
   346
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m3 = buf[j];
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   347
	}
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   348
}
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   349
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   350
static void Save_MAP3()
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   351
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   352
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   353
	TileIndex size = MapSize();
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   354
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   355
	SlSetLength(size);
8872
dd23eb1922b6 (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: 8760
diff changeset
   356
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   357
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m3;
dd23eb1922b6 (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: 8760
diff changeset
   358
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   359
	}
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   360
}
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   361
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   362
static void Load_MAP4()
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   363
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   364
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   365
	TileIndex size = MapSize();
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   366
8872
dd23eb1922b6 (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: 8760
diff changeset
   367
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   368
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
dd23eb1922b6 (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: 8760
diff changeset
   369
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m4 = buf[j];
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   370
	}
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   371
}
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   372
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   373
static void Save_MAP4()
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   374
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   375
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   376
	TileIndex size = MapSize();
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   377
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   378
	SlSetLength(size);
8872
dd23eb1922b6 (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: 8760
diff changeset
   379
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   380
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m4;
dd23eb1922b6 (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: 8760
diff changeset
   381
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   382
	}
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   383
}
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   384
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   385
static void Load_MAP5()
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   386
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   387
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   388
	TileIndex size = MapSize();
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   389
8872
dd23eb1922b6 (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: 8760
diff changeset
   390
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   391
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
dd23eb1922b6 (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: 8760
diff changeset
   392
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m5 = buf[j];
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   393
	}
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   394
}
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   395
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   396
static void Save_MAP5()
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   397
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   398
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   399
	TileIndex size = MapSize();
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   400
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   401
	SlSetLength(size);
8872
dd23eb1922b6 (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: 8760
diff changeset
   402
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   403
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m5;
dd23eb1922b6 (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: 8760
diff changeset
   404
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
2295
af67e1ea8687 (svn r2819) Make variables, which are exclusive for internal use of the save/load code, static in saveload.c
tron
parents: 2293
diff changeset
   405
	}
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   406
}
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   407
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   408
static void Load_MAP6()
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   409
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   410
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   411
	TileIndex size = MapSize();
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   412
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5108
diff changeset
   413
	if (CheckSavegameVersion(42)) {
8872
dd23eb1922b6 (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: 8760
diff changeset
   414
		for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   415
			/* 1024, otherwise we overflow on 64x64 maps! */
dd23eb1922b6 (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: 8760
diff changeset
   416
			SlArray(buf, 1024, SLE_UINT8);
dd23eb1922b6 (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: 8760
diff changeset
   417
			for (uint j = 0; j != 1024; j++) {
5847
9ce114e1d90d (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5838
diff changeset
   418
				_m[i++].m6 = GB(buf[j], 0, 2);
9ce114e1d90d (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5838
diff changeset
   419
				_m[i++].m6 = GB(buf[j], 2, 2);
9ce114e1d90d (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5838
diff changeset
   420
				_m[i++].m6 = GB(buf[j], 4, 2);
9ce114e1d90d (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5838
diff changeset
   421
				_m[i++].m6 = GB(buf[j], 6, 2);
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5108
diff changeset
   422
			}
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5108
diff changeset
   423
		}
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5108
diff changeset
   424
	} else {
8872
dd23eb1922b6 (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: 8760
diff changeset
   425
		for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   426
			SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
dd23eb1922b6 (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: 8760
diff changeset
   427
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m6 = buf[j];
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   428
		}
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   429
	}
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   430
}
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   431
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   432
static void Save_MAP6()
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   433
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   434
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   435
	TileIndex size = MapSize();
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   436
5573
afa6f92a71fd (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 5108
diff changeset
   437
	SlSetLength(size);
8872
dd23eb1922b6 (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: 8760
diff changeset
   438
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   439
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m6;
dd23eb1922b6 (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: 8760
diff changeset
   440
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
2049
ad0d49c916d4 (svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents: 1999
diff changeset
   441
	}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   442
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   443
6658
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   444
static void Load_MAP7()
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   445
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   446
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   447
	TileIndex size = MapSize();
6658
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   448
8872
dd23eb1922b6 (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: 8760
diff changeset
   449
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   450
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
dd23eb1922b6 (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: 8760
diff changeset
   451
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _me[i++].m7 = buf[j];
6658
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   452
	}
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   453
}
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   454
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   455
static void Save_MAP7()
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   456
{
8872
dd23eb1922b6 (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: 8760
diff changeset
   457
	SmallStackSafeStackAlloc<byte, MAP_SL_BUF_SIZE> buf;
dd23eb1922b6 (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: 8760
diff changeset
   458
	TileIndex size = MapSize();
6658
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   459
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   460
	SlSetLength(size);
8872
dd23eb1922b6 (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: 8760
diff changeset
   461
	for (TileIndex i = 0; i != size;) {
dd23eb1922b6 (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: 8760
diff changeset
   462
		for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _me[i++].m7;
dd23eb1922b6 (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: 8760
diff changeset
   463
		SlArray(buf, MAP_SL_BUF_SIZE, SLE_UINT8);
6658
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   464
	}
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   465
}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   466
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   467
static void Save_CHTS()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   468
{
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   469
	byte count = sizeof(_cheats)/sizeof(Cheat);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   470
	Cheat* cht = (Cheat*) &_cheats;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   471
	Cheat* cht_last = &cht[count];
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   472
2951
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2861
diff changeset
   473
	SlSetLength(count * 2);
2db3adee7736 (svn r3510) Fiddle with whitespace and parentheses
tron
parents: 2861
diff changeset
   474
	for (; cht != cht_last; cht++) {
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   475
		SlWriteByte(cht->been_used);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   476
		SlWriteByte(cht->value);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   477
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   478
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   479
6573
7624f942237f (svn r9050) -Codechange: Foo(void) -> Foo()
rubidium
parents: 6557
diff changeset
   480
static void Load_CHTS()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   481
{
2989
99c95a3ebcaa (svn r3564) Several smaller changes:
tron
parents: 2952
diff changeset
   482
	Cheat* cht = (Cheat*)&_cheats;
99c95a3ebcaa (svn r3564) Several smaller changes:
tron
parents: 2952
diff changeset
   483
	uint count = SlGetFieldLength() / 2;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   484
9315
336e6518acb3 (svn r12565) -Cleanup: variable scope in misc\*.cpp
smatz
parents: 9282
diff changeset
   485
	for (uint i = 0; i < count; i++) {
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   486
		cht[i].been_used = (SlReadByte() != 0);
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   487
		cht[i].value     = (SlReadByte() != 0);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   488
	}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   489
}
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   490
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   491
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5835
diff changeset
   492
extern const ChunkHandler _misc_chunk_handlers[] = {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   493
	{ 'MAPS', Save_MAPS,     Load_MAPS,     CH_RIFF },
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   494
	{ 'MAPT', Save_MAPT,     Load_MAPT,     CH_RIFF },
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   495
	{ 'MAPO', Save_MAP1,     Load_MAP1,     CH_RIFF },
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   496
	{ 'MAP2', Save_MAP2,     Load_MAP2,     CH_RIFF },
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   497
	{ 'M3LO', Save_MAP3,     Load_MAP3,     CH_RIFF },
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   498
	{ 'M3HI', Save_MAP4,     Load_MAP4,     CH_RIFF },
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   499
	{ 'MAP5', Save_MAP5,     Load_MAP5,     CH_RIFF },
5847
9ce114e1d90d (svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents: 5838
diff changeset
   500
	{ 'MAPE', Save_MAP6,     Load_MAP6,     CH_RIFF },
6658
59048224be55 (svn r9315) -Merge: The newhouses branch. With this merge comes almost complete support for
maedhros
parents: 6573
diff changeset
   501
	{ 'MAP7', Save_MAP7,     Load_MAP7,     CH_RIFF },
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   502
8754
5dae65402806 (svn r11822) -Codechange: Replaced fixed size custom name array. Names are now attached to their object directly and there is
peter1138
parents: 8750
diff changeset
   503
	{ 'NAME', NULL,          Load_NAME,     CH_ARRAY},
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   504
	{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, CH_RIFF},
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   505
	{ 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, CH_RIFF},
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4326
diff changeset
   506
	{ 'CHTS', Save_CHTS,     Load_CHTS,     CH_RIFF | CH_LAST}
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   507
};