author | miham |
Tue, 19 Dec 2006 06:14:29 +0000 | |
changeset 5342 | 006d4639558f |
parent 5216 | d581e4db95b6 |
child 5461 | 03285c9589f9 |
child 5568 | 75f13d7bfaed |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
92a3b0aa0946
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1883
diff
changeset
|
4 |
#include "openttd.h" |
1299
0a6510cc889b
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1197
diff
changeset
|
5 |
#include "debug.h" |
2163
637ec3c361f5
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
485
diff
changeset
|
7 |
#include "table/strings.h" |
0 | 8 |
#include "engine.h" |
1009
a7ccb8e39cbc
(svn r1508) Remove duplicate declarations and include proper headers where necessary
tron
parents:
964
diff
changeset
|
9 |
#include "gfx.h" |
0 | 10 |
#include "player.h" |
11 |
#include "command.h" |
|
12 |
#include "vehicle.h" |
|
13 |
#include "news.h" |
|
14 |
#include "saveload.h" |
|
2159
3b634157c3b2
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2147
diff
changeset
|
15 |
#include "variables.h" |
2708
9d1a8d5dc3ea
(svn r3252) - NewGRF: Map new train subtypes to old types for rail vehicles.
peter1138
parents:
2639
diff
changeset
|
16 |
#include "train.h" |
3866
113de2b20059
(svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
3865
diff
changeset
|
17 |
#include "newgrf_cargo.h" |
4261
2ec8f5a9747b
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4171
diff
changeset
|
18 |
#include "date.h" |
4322
0bee6d9bc452
(svn r5975) -Cleanup: use ORIGINAL_BASE_YEAR & ORIGINAL_MAX_YEAR where the functions really depend on the original date format.
rubidium
parents:
4300
diff
changeset
|
19 |
#include "table/engines.h" |
0 | 20 |
|
2763 | 21 |
EngineInfo _engine_info[TOTAL_NUM_ENGINES]; |
22 |
RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES]; |
|
23 |
ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES]; |
|
24 |
AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES]; |
|
25 |
RoadVehicleInfo _road_vehicle_info[NUM_ROAD_ENGINES]; |
|
26 |
||
0 | 27 |
enum { |
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
|
28 |
ENGINE_AVAILABLE = 1, |
0 | 29 |
ENGINE_INTRODUCING = 2, |
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
|
30 |
ENGINE_PREVIEWING = 4, |
0 | 31 |
}; |
32 |
||
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
33 |
enum { |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
34 |
YEAR_ENGINE_AGING_STOPS = 2050, |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
35 |
}; |
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
36 |
|
0 | 37 |
|
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
38 |
void ShowEnginePreviewWindow(EngineID engine); |
0 | 39 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
40 |
void DeleteCustomEngineNames(void) |
0 | 41 |
{ |
42 |
uint i; |
|
43 |
StringID old; |
|
44 |
||
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1329
diff
changeset
|
45 |
for (i = 0; i != TOTAL_NUM_ENGINES; i++) { |
0 | 46 |
old = _engine_name_strings[i]; |
47 |
_engine_name_strings[i] = i + STR_8000_KIRBY_PAUL_TANK_STEAM; |
|
48 |
DeleteName(old); |
|
49 |
} |
|
50 |
||
51 |
_vehicle_design_names &= ~1; |
|
52 |
} |
|
53 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
54 |
void LoadCustomEngineNames(void) |
0 | 55 |
{ |
4432
33631ac88c40
(svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents:
4384
diff
changeset
|
56 |
/* XXX: not done */ |
0 | 57 |
DEBUG(misc, 1) ("LoadCustomEngineNames: not done"); |
58 |
} |
|
59 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
60 |
static void SetupEngineNames(void) |
0 | 61 |
{ |
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1329
diff
changeset
|
62 |
StringID *name; |
0 | 63 |
|
1474
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1329
diff
changeset
|
64 |
for (name = _engine_name_strings; name != endof(_engine_name_strings); name++) |
d83520edcda6
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1329
diff
changeset
|
65 |
*name = STR_SV_EMPTY; |
0 | 66 |
|
67 |
DeleteCustomEngineNames(); |
|
68 |
LoadCustomEngineNames(); |
|
69 |
} |
|
70 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
71 |
static void AdjustAvailAircraft(void) |
0 | 72 |
{ |
73 |
byte avail = 0; |
|
4297
47ce9665b4af
(svn r5934) -Cleanup: forgot some conversions to Year and to Date
rubidium
parents:
4293
diff
changeset
|
74 |
if (_cur_year >= 1955) avail |= 2; // big airport |
47ce9665b4af
(svn r5934) -Cleanup: forgot some conversions to Year and to Date
rubidium
parents:
4293
diff
changeset
|
75 |
if (_cur_year < 1960 || _patches.always_small_airport) avail |= 1; // small airport |
47ce9665b4af
(svn r5934) -Cleanup: forgot some conversions to Year and to Date
rubidium
parents:
4293
diff
changeset
|
76 |
if (_cur_year >= 1963) avail |= 4; // enable heliport |
0 | 77 |
|
78 |
if (avail != _avail_aircraft) { |
|
79 |
_avail_aircraft = avail; |
|
80 |
InvalidateWindow(WC_BUILD_STATION, 0); |
|
81 |
} |
|
82 |
} |
|
83 |
||
84 |
static void CalcEngineReliability(Engine *e) |
|
85 |
{ |
|
86 |
uint age = e->age; |
|
87 |
||
88 |
if (age < e->duration_phase_1) { |
|
89 |
uint start = e->reliability_start; |
|
90 |
e->reliability = age * (e->reliability_max - start) / e->duration_phase_1 + start; |
|
4767
7621bec94f99
(svn r6681) -Fix: when vehicles never expire they will stay at peak reliability instead of the lowest to make them useful even when old
bjarni
parents:
4766
diff
changeset
|
91 |
} else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _patches.never_expire_vehicles) { |
7621bec94f99
(svn r6681) -Fix: when vehicles never expire they will stay at peak reliability instead of the lowest to make them useful even when old
bjarni
parents:
4766
diff
changeset
|
92 |
/* We are at the peak of this engines life. It will have max reliability. |
7621bec94f99
(svn r6681) -Fix: when vehicles never expire they will stay at peak reliability instead of the lowest to make them useful even when old
bjarni
parents:
4766
diff
changeset
|
93 |
* This is also true if the engines never expire. They will not go bad over time */ |
0 | 94 |
e->reliability = e->reliability_max; |
95 |
} else if ((age -= e->duration_phase_2) < e->duration_phase_3) { |
|
96 |
uint max = e->reliability_max; |
|
97 |
e->reliability = (int)age * (int)(e->reliability_final - max) / e->duration_phase_3 + max; |
|
98 |
} else { |
|
4767
7621bec94f99
(svn r6681) -Fix: when vehicles never expire they will stay at peak reliability instead of the lowest to make them useful even when old
bjarni
parents:
4766
diff
changeset
|
99 |
/* time's up for this engine. |
7621bec94f99
(svn r6681) -Fix: when vehicles never expire they will stay at peak reliability instead of the lowest to make them useful even when old
bjarni
parents:
4766
diff
changeset
|
100 |
* We will now completely retire this design */ |
7621bec94f99
(svn r6681) -Fix: when vehicles never expire they will stay at peak reliability instead of the lowest to make them useful even when old
bjarni
parents:
4766
diff
changeset
|
101 |
e->player_avail = 0; |
0 | 102 |
e->reliability = e->reliability_final; |
4767
7621bec94f99
(svn r6681) -Fix: when vehicles never expire they will stay at peak reliability instead of the lowest to make them useful even when old
bjarni
parents:
4766
diff
changeset
|
103 |
InvalidateWindowClassesData(WC_BUILD_VEHICLE); // Kick this engine out of the lists |
0 | 104 |
} |
4767
7621bec94f99
(svn r6681) -Fix: when vehicles never expire they will stay at peak reliability instead of the lowest to make them useful even when old
bjarni
parents:
4766
diff
changeset
|
105 |
InvalidateWindowClasses(WC_BUILD_VEHICLE); // Update to show the new reliability |
0 | 106 |
} |
107 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
108 |
void AddTypeToEngines(void) |
842 | 109 |
{ |
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
110 |
Engine* e = _engines; |
842 | 111 |
|
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
112 |
do e->type = VEH_Train; while (++e < &_engines[ROAD_ENGINES_INDEX]); |
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
113 |
do e->type = VEH_Road; while (++e < &_engines[SHIP_ENGINES_INDEX]); |
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
114 |
do e->type = VEH_Ship; while (++e < &_engines[AIRCRAFT_ENGINES_INDEX]); |
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
115 |
do e->type = VEH_Aircraft; while (++e < &_engines[TOTAL_NUM_ENGINES]); |
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
116 |
do e->type = VEH_Special; while (++e < endof(_engines)); |
842 | 117 |
} |
118 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
119 |
void StartupEngines(void) |
0 | 120 |
{ |
121 |
Engine *e; |
|
122 |
const EngineInfo *ei; |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
123 |
/* Aging of vehicles stops, so account for that when starting late */ |
4322
0bee6d9bc452
(svn r5975) -Cleanup: use ORIGINAL_BASE_YEAR & ORIGINAL_MAX_YEAR where the functions really depend on the original date format.
rubidium
parents:
4300
diff
changeset
|
124 |
const Date aging_date = min(_date, ConvertYMDToDate(YEAR_ENGINE_AGING_STOPS, 0, 1)); |
0 | 125 |
|
126 |
SetupEngineNames(); |
|
127 |
||
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
128 |
for (e = _engines, ei = _engine_info; e != endof(_engines); e++, ei++) { |
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
129 |
uint32 r; |
0 | 130 |
|
131 |
e->age = 0; |
|
2530
b8d5a5284024
(svn r3059) Use bitfields to encode railtype and climates of engines instead of manual shifting/anding
tron
parents:
2491
diff
changeset
|
132 |
e->railtype = ei->railtype; |
0 | 133 |
e->flags = 0; |
134 |
e->player_avail = 0; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
114
diff
changeset
|
135 |
|
2875
905a06cc99c3
(svn r3423) - NewGRF: Update the base_intro age at which an engine will have a randomized intro date, as per (the now updated) spec.
peter1138
parents:
2862
diff
changeset
|
136 |
// The magic value of 729 days below comes from the NewGRF spec. If the |
905a06cc99c3
(svn r3423) - NewGRF: Update the base_intro age at which an engine will have a randomized intro date, as per (the now updated) spec.
peter1138
parents:
2862
diff
changeset
|
137 |
// base intro date is before 1922 then the random number of days is not |
905a06cc99c3
(svn r3423) - NewGRF: Update the base_intro age at which an engine will have a randomized intro date, as per (the now updated) spec.
peter1138
parents:
2862
diff
changeset
|
138 |
// added. |
0 | 139 |
r = Random(); |
4297
47ce9665b4af
(svn r5934) -Cleanup: forgot some conversions to Year and to Date
rubidium
parents:
4293
diff
changeset
|
140 |
e->intro_date = ei->base_intro <= ConvertYMDToDate(1922, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro; |
0 | 141 |
if (e->intro_date <= _date) { |
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
142 |
e->age = (aging_date - e->intro_date) >> 5; |
0 | 143 |
e->player_avail = (byte)-1; |
144 |
e->flags |= ENGINE_AVAILABLE; |
|
145 |
} |
|
146 |
||
2140
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
1988
diff
changeset
|
147 |
e->reliability_start = GB(r, 16, 14) + 0x7AE0; |
0 | 148 |
r = Random(); |
2140
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
1988
diff
changeset
|
149 |
e->reliability_max = GB(r, 0, 14) + 0xBFFF; |
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
1988
diff
changeset
|
150 |
e->reliability_final = GB(r, 16, 14) + 0x3FFF; |
0 | 151 |
|
152 |
r = Random(); |
|
2140
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
1988
diff
changeset
|
153 |
e->duration_phase_1 = GB(r, 0, 5) + 7; |
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
1988
diff
changeset
|
154 |
e->duration_phase_2 = GB(r, 5, 4) + ei->base_life * 12 - 96; |
d708eb80ab8b
(svn r2650) Convert many explicit shifts+ands to extract bits to invocations of GB - should be a bit nicer to read
tron
parents:
1988
diff
changeset
|
155 |
e->duration_phase_3 = GB(r, 9, 7) + 120; |
0 | 156 |
|
157 |
e->reliability_spd_dec = (ei->unk2&0x7F) << 2; |
|
158 |
||
159 |
/* my invented flag for something that is a wagon */ |
|
160 |
if (ei->unk2 & 0x80) { |
|
161 |
e->age = 0xFFFF; |
|
162 |
} else { |
|
163 |
CalcEngineReliability(e); |
|
164 |
} |
|
165 |
||
166 |
e->lifelength = ei->lifelength + _patches.extend_vehicle_life; |
|
167 |
||
168 |
// prevent certain engines from ever appearing. |
|
2530
b8d5a5284024
(svn r3059) Use bitfields to encode railtype and climates of engines instead of manual shifting/anding
tron
parents:
2491
diff
changeset
|
169 |
if (!HASBIT(ei->climates, _opt.landscape)) { |
0 | 170 |
e->flags |= ENGINE_AVAILABLE; |
171 |
e->player_avail = 0; |
|
172 |
} |
|
915 | 173 |
|
819
02e9296ccdca
(svn r1290) Added type to typedef struct Engine and filled in the same data as in type in vehicle
bjarni
parents:
740
diff
changeset
|
174 |
/* This sets up type for the engine |
4549
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4432
diff
changeset
|
175 |
* It is needed if you want to ask the engine what type it is |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4432
diff
changeset
|
176 |
* It should hopefully be the same as when you ask a vehicle what it is |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4432
diff
changeset
|
177 |
* but using this, you can ask what type an engine number is |
60410aa1aa88
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4432
diff
changeset
|
178 |
* even if it is not a vehicle (yet)*/ |
0 | 179 |
} |
180 |
||
181 |
AdjustAvailAircraft(); |
|
182 |
} |
|
183 |
||
2817 | 184 |
static void AcceptEnginePreview(Engine *e, PlayerID player) |
0 | 185 |
{ |
1962
51ee4f459268
(svn r2468) -Codechange: Got rid of DEREF_PLAYER and replaced it by GetPlayer
celestar
parents:
1926
diff
changeset
|
186 |
Player *p = GetPlayer(player); |
0 | 187 |
|
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2140
diff
changeset
|
188 |
assert(e->railtype < RAILTYPE_END); |
0 | 189 |
SETBIT(e->player_avail, player); |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2140
diff
changeset
|
190 |
SETBIT(p->avail_railtypes, e->railtype); |
0 | 191 |
|
192 |
e->preview_player = 0xFF; |
|
4766
a23183d868d1
(svn r6680) -Codechange r6679: [train build window] only generate the list when the window data is invalidated or the window is generated, not on each redraw
bjarni
parents:
4549
diff
changeset
|
193 |
if (player == _local_player) { |
a23183d868d1
(svn r6680) -Codechange r6679: [train build window] only generate the list when the window data is invalidated or the window is generated, not on each redraw
bjarni
parents:
4549
diff
changeset
|
194 |
InvalidateWindowClassesData(WC_BUILD_VEHICLE); |
a23183d868d1
(svn r6680) -Codechange r6679: [train build window] only generate the list when the window data is invalidated or the window is generated, not on each redraw
bjarni
parents:
4549
diff
changeset
|
195 |
InvalidateWindowClasses(WC_REPLACE_VEHICLE); |
a23183d868d1
(svn r6680) -Codechange r6679: [train build window] only generate the list when the window data is invalidated or the window is generated, not on each redraw
bjarni
parents:
4549
diff
changeset
|
196 |
} |
0 | 197 |
} |
198 |
||
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
199 |
static PlayerID GetBestPlayer(PlayerID pp) |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
200 |
{ |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
201 |
const Player *p; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
202 |
int32 best_hist; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
203 |
PlayerID best_player; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
204 |
uint mask = 0; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
205 |
|
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
206 |
do { |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
207 |
best_hist = -1; |
4848
56549aa3e234
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4845
diff
changeset
|
208 |
best_player = PLAYER_SPECTATOR; |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
209 |
FOR_ALL_PLAYERS(p) { |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
210 |
if (p->is_active && p->block_preview == 0 && !HASBIT(mask, p->index) && |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
211 |
p->old_economy[0].performance_history > best_hist) { |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
212 |
best_hist = p->old_economy[0].performance_history; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
213 |
best_player = p->index; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
214 |
} |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
215 |
} |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
216 |
|
4848
56549aa3e234
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4845
diff
changeset
|
217 |
if (best_player == PLAYER_SPECTATOR) return PLAYER_SPECTATOR; |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
218 |
|
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
219 |
SETBIT(mask, best_player); |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
220 |
} while (--pp != 0); |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
221 |
|
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
222 |
return best_player; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
223 |
} |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
224 |
|
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
225 |
void EnginesDailyLoop(void) |
0 | 226 |
{ |
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
227 |
EngineID i; |
0 | 228 |
|
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
229 |
if (_cur_year >= YEAR_ENGINE_AGING_STOPS) return; |
0 | 230 |
|
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
231 |
for (i = 0; i != lengthof(_engines); i++) { |
4171 | 232 |
Engine *e = &_engines[i]; |
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
233 |
|
0 | 234 |
if (e->flags & ENGINE_INTRODUCING) { |
235 |
if (e->flags & ENGINE_PREVIEWING) { |
|
740
c1d06749846b
(svn r1196) -Fix: Preview Vehicle had a small glitch. Fixed now.
truelight
parents:
555
diff
changeset
|
236 |
if (e->preview_player != 0xFF && !--e->preview_wait) { |
0 | 237 |
e->flags &= ~ENGINE_PREVIEWING; |
238 |
DeleteWindowById(WC_ENGINE_PREVIEW, i); |
|
239 |
e->preview_player++; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
114
diff
changeset
|
240 |
} |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3866
diff
changeset
|
241 |
} else if (e->preview_player != 0xFF) { |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
242 |
PlayerID best_player = GetBestPlayer(e->preview_player); |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
243 |
|
4848
56549aa3e234
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4845
diff
changeset
|
244 |
if (best_player == PLAYER_SPECTATOR) { |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
245 |
e->preview_player = 0xFF; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
246 |
continue; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
247 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
114
diff
changeset
|
248 |
|
4845
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4792
diff
changeset
|
249 |
if (!IsHumanPlayer(best_player)) { |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
250 |
/* XXX - TTDBUG: TTD has a bug here ???? */ |
0 | 251 |
AcceptEnginePreview(e, best_player); |
252 |
} else { |
|
253 |
e->flags |= ENGINE_PREVIEWING; |
|
254 |
e->preview_wait = 20; |
|
4845
49105d3b5a9a
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4792
diff
changeset
|
255 |
if (IsInteractivePlayer(best_player)) ShowEnginePreviewWindow(i); |
0 | 256 |
} |
257 |
} |
|
258 |
} |
|
259 |
} |
|
260 |
} |
|
261 |
||
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
262 |
/** Accept an engine prototype. XXX - it is possible that the top-player |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
263 |
* changes while you are waiting to accept the offer? Then it becomes invalid |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3222
diff
changeset
|
264 |
* @param tile unused |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
265 |
* @param p1 engine-prototype offered |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
266 |
* @param p2 unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
267 |
*/ |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3222
diff
changeset
|
268 |
int32 CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 269 |
{ |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
270 |
Engine *e; |
2951 | 271 |
|
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
272 |
if (!IsEngineIndex(p1)) return CMD_ERROR; |
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1908
diff
changeset
|
273 |
e = GetEngine(p1); |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
274 |
if (GetBestPlayer(e->preview_player) != _current_player) return CMD_ERROR; |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
275 |
|
2951 | 276 |
if (flags & DC_EXEC) AcceptEnginePreview(e, _current_player); |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
277 |
|
0 | 278 |
return 0; |
279 |
} |
|
280 |
||
257
8d83db6716ea
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
281 |
// Determine if an engine type is a wagon (and not a loco) |
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
282 |
static bool IsWagon(EngineID index) |
257
8d83db6716ea
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
283 |
{ |
964
4bd472539a4e
(svn r1456) Simplify isWagon(), make it static and give it a canonical name (IsWagon)
tron
parents:
938
diff
changeset
|
284 |
return index < NUM_TRAIN_ENGINES && RailVehInfo(index)->flags & RVI_WAGON; |
257
8d83db6716ea
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
285 |
} |
8d83db6716ea
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
286 |
|
410 | 287 |
static void NewVehicleAvailable(Engine *e) |
0 | 288 |
{ |
289 |
Vehicle *v; |
|
290 |
Player *p; |
|
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
291 |
EngineID index = e - _engines; |
0 | 292 |
|
293 |
// In case the player didn't build the vehicle during the intro period, |
|
294 |
// prevent that player from getting future intro periods for a while. |
|
2639 | 295 |
if (e->flags & ENGINE_INTRODUCING) { |
0 | 296 |
FOR_ALL_PLAYERS(p) { |
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
297 |
uint block_preview = p->block_preview; |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
298 |
|
2639 | 299 |
if (!HASBIT(e->player_avail, p->index)) continue; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
114
diff
changeset
|
300 |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
301 |
/* We assume the user did NOT build it.. prove me wrong ;) */ |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
302 |
p->block_preview = 20; |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
303 |
|
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
304 |
FOR_ALL_VEHICLES(v) { |
0 | 305 |
if (v->type == VEH_Train || v->type == VEH_Road || v->type == VEH_Ship || |
306 |
(v->type == VEH_Aircraft && v->subtype <= 2)) { |
|
919
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
307 |
if (v->owner == p->index && v->engine_type == index) { |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
308 |
/* The user did prove me wrong, so restore old value */ |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
309 |
p->block_preview = block_preview; |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
310 |
break; |
b0d6c7642f99
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
311 |
} |
0 | 312 |
} |
313 |
} |
|
314 |
} |
|
315 |
} |
|
316 |
||
114
6a2af0c2d0db
(svn r115) Fix: monorail/maglev became available around 1927
dominik
parents:
0
diff
changeset
|
317 |
e->flags = (e->flags & ~ENGINE_INTRODUCING) | ENGINE_AVAILABLE; |
4766
a23183d868d1
(svn r6680) -Codechange r6679: [train build window] only generate the list when the window data is invalidated or the window is generated, not on each redraw
bjarni
parents:
4549
diff
changeset
|
318 |
InvalidateWindowClassesData(WC_BUILD_VEHICLE); |
1096
ce698f7e4621
(svn r1597) fix: autoreplace vehicle lists are now redrawn when a new vehicle becomes available (thanks LordOfThePigs for pointing this one out)
bjarni
parents:
1093
diff
changeset
|
319 |
InvalidateWindowClasses(WC_REPLACE_VEHICLE); |
114
6a2af0c2d0db
(svn r115) Fix: monorail/maglev became available around 1927
dominik
parents:
0
diff
changeset
|
320 |
|
0 | 321 |
// Now available for all players |
322 |
e->player_avail = (byte)-1; |
|
114
6a2af0c2d0db
(svn r115) Fix: monorail/maglev became available around 1927
dominik
parents:
0
diff
changeset
|
323 |
|
6a2af0c2d0db
(svn r115) Fix: monorail/maglev became available around 1927
dominik
parents:
0
diff
changeset
|
324 |
// Do not introduce new rail wagons |
2639 | 325 |
if (IsWagon(index)) return; |
114
6a2af0c2d0db
(svn r115) Fix: monorail/maglev became available around 1927
dominik
parents:
0
diff
changeset
|
326 |
|
6a2af0c2d0db
(svn r115) Fix: monorail/maglev became available around 1927
dominik
parents:
0
diff
changeset
|
327 |
// make maglev / monorail available |
0 | 328 |
FOR_ALL_PLAYERS(p) { |
2147
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2140
diff
changeset
|
329 |
if (p->is_active) { |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2140
diff
changeset
|
330 |
assert(e->railtype < RAILTYPE_END); |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2140
diff
changeset
|
331 |
SETBIT(p->avail_railtypes, e->railtype); |
42efdf5020d1
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2140
diff
changeset
|
332 |
} |
0 | 333 |
} |
334 |
||
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
335 |
if (index < NUM_TRAIN_ENGINES) { |
0 | 336 |
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_TRAINAVAIL), 0, 0); |
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
337 |
} else if (index < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) { |
0 | 338 |
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_ROADAVAIL), 0, 0); |
2477
d454d5152386
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
339 |
} else if (index < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) { |
0 | 340 |
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_SHIPAVAIL), 0, 0); |
341 |
} else { |
|
342 |
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_AIRCRAFTAVAIL), 0, 0); |
|
343 |
} |
|
344 |
} |
|
345 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
346 |
void EnginesMonthlyLoop(void) |
0 | 347 |
{ |
348 |
Engine *e; |
|
349 |
||
4300
687a17c9c557
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
350 |
if (_cur_year < YEAR_ENGINE_AGING_STOPS) { |
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
351 |
for (e = _engines; e != endof(_engines); e++) { |
0 | 352 |
// Age the vehicle |
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
353 |
if (e->flags & ENGINE_AVAILABLE && e->age != 0xFFFF) { |
0 | 354 |
e->age++; |
355 |
CalcEngineReliability(e); |
|
356 |
} |
|
357 |
||
2990
352b4590ee1c
(svn r3565) - Fix: On loading a game, GetPlayerRailtypes() didn't account for the fact that vehicles are introduced a year after their introduction date. This will also relieve possible (rare) network desyncs.
peter1138
parents:
2962
diff
changeset
|
358 |
if (!(e->flags & ENGINE_AVAILABLE) && _date >= (e->intro_date + 365)) { |
0 | 359 |
// Introduce it to all players |
360 |
NewVehicleAvailable(e); |
|
361 |
} else if (!(e->flags & (ENGINE_AVAILABLE|ENGINE_INTRODUCING)) && _date >= e->intro_date) { |
|
362 |
// Introduction date has passed.. show introducing dialog to one player. |
|
363 |
e->flags |= ENGINE_INTRODUCING; |
|
257
8d83db6716ea
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
364 |
|
8d83db6716ea
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
365 |
// Do not introduce new rail wagons |
964
4bd472539a4e
(svn r1456) Simplify isWagon(), make it static and give it a canonical name (IsWagon)
tron
parents:
938
diff
changeset
|
366 |
if (!IsWagon(e - _engines)) |
257
8d83db6716ea
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
367 |
e->preview_player = 1; // Give to the player with the highest rating. |
0 | 368 |
} |
369 |
} |
|
370 |
} |
|
371 |
AdjustAvailAircraft(); |
|
372 |
} |
|
373 |
||
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
374 |
/** Rename an engine. |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3222
diff
changeset
|
375 |
* @param tile unused |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
376 |
* @param p1 engine ID to rename |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
377 |
* @param p2 unused |
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
378 |
*/ |
3491
4c8427796c64
(svn r4342) Change the first two parameters of commands - virtual pixel coordinates of the tile to operate on - to a TileIndex
tron
parents:
3222
diff
changeset
|
379 |
int32 CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 380 |
{ |
381 |
StringID str; |
|
382 |
||
1840
c181d5cb4ffe
(svn r2345) - Fix: Don't allow stuff to be renamed to nothing if we don't support it. Only valid ones are signs (delete) and waypoints (rename to default).
Darkvater
parents:
1820
diff
changeset
|
383 |
if (!IsEngineIndex(p1) || _cmd_text[0] == '\0') return CMD_ERROR; |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
384 |
|
1820
9b6458526480
(svn r2324) Introduce _cmd_text for passing strings with a command instead of abusing _decode_parameters as text buffer. This should prevent several possible buffer overruns and is a bit cleaner to use. As bonus it reduces the size of most command packets by 79 bytes.
tron
parents:
1802
diff
changeset
|
385 |
str = AllocateNameUnique(_cmd_text, 0); |
1786
a54634efeb98
(svn r2290) - CodeChange: protect the next batch of commands. This brings us to a total of 61, which is 53% :)
Darkvater
parents:
1560
diff
changeset
|
386 |
if (str == 0) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
114
diff
changeset
|
387 |
|
0 | 388 |
if (flags & DC_EXEC) { |
389 |
StringID old_str = _engine_name_strings[p1]; |
|
390 |
_engine_name_strings[p1] = str; |
|
391 |
DeleteName(old_str); |
|
392 |
_vehicle_design_names |= 3; |
|
393 |
MarkWholeScreenDirty(); |
|
394 |
} else { |
|
395 |
DeleteName(str); |
|
396 |
} |
|
397 |
||
398 |
return 0; |
|
399 |
} |
|
400 |
||
401 |
||
2848 | 402 |
/* |
403 |
* returns true if an engine is valid, of the specified type, and buildable by |
|
5215
439d5ca71311
(svn r7330) -Fix (r7304): Data invalidation doesn't always happen as the local
peter1138
parents:
5037
diff
changeset
|
404 |
* the given player, false otherwise |
2848 | 405 |
* |
406 |
* engine = index of the engine to check |
|
407 |
* type = the type the engine should be of (VEH_xxx) |
|
5215
439d5ca71311
(svn r7330) -Fix (r7304): Data invalidation doesn't always happen as the local
peter1138
parents:
5037
diff
changeset
|
408 |
* player = index of the player |
2848 | 409 |
*/ |
5215
439d5ca71311
(svn r7330) -Fix (r7304): Data invalidation doesn't always happen as the local
peter1138
parents:
5037
diff
changeset
|
410 |
bool IsEngineBuildable(EngineID engine, byte type, PlayerID player) |
2848 | 411 |
{ |
412 |
const Engine *e; |
|
413 |
||
414 |
// check if it's an engine that is in the engine array |
|
415 |
if (!IsEngineIndex(engine)) return false; |
|
416 |
||
417 |
e = GetEngine(engine); |
|
418 |
||
419 |
// check if it's an engine of specified type |
|
420 |
if (e->type != type) return false; |
|
421 |
||
422 |
// check if it's available |
|
5215
439d5ca71311
(svn r7330) -Fix (r7304): Data invalidation doesn't always happen as the local
peter1138
parents:
5037
diff
changeset
|
423 |
if (!HASBIT(e->player_avail, player)) return false; |
2848 | 424 |
|
425 |
return true; |
|
426 |
} |
|
427 |
||
428 |
/************************************************************************ |
|
429 |
* Engine Replacement stuff |
|
430 |
************************************************************************/ |
|
431 |
||
4974
c962d0622bc1
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
432 |
static void EngineRenewPoolNewBlock(uint start_item); |
2848 | 433 |
|
5216
d581e4db95b6
(svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents:
5215
diff
changeset
|
434 |
DEFINE_OLD_POOL(EngineRenew, EngineRenew, EngineRenewPoolNewBlock, NULL) |
2848 | 435 |
|
436 |
static void EngineRenewPoolNewBlock(uint start_item) |
|
437 |
{ |
|
438 |
EngineRenew *er; |
|
439 |
||
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
440 |
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
441 |
* TODO - This is just a temporary stage, this will be removed. */ |
4974
c962d0622bc1
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
442 |
for (er = GetEngineRenew(start_item); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) { |
2848 | 443 |
er->index = start_item++; |
444 |
er->from = INVALID_ENGINE; |
|
445 |
} |
|
446 |
} |
|
447 |
||
448 |
||
449 |
static EngineRenew *AllocateEngineRenew(void) |
|
450 |
{ |
|
451 |
EngineRenew *er; |
|
452 |
||
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
453 |
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
454 |
* TODO - This is just a temporary stage, this will be removed. */ |
4974
c962d0622bc1
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
455 |
for (er = GetEngineRenew(0); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) { |
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
456 |
if (IsValidEngineRenew(er)) continue; |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
457 |
|
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
458 |
er->to = INVALID_ENGINE; |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
459 |
er->next = NULL; |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
460 |
return er; |
2848 | 461 |
} |
462 |
||
463 |
/* Check if we can add a block to the pool */ |
|
4974
c962d0622bc1
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
464 |
if (AddBlockToPool(&_EngineRenew_pool)) return AllocateEngineRenew(); |
2848 | 465 |
|
466 |
return NULL; |
|
467 |
} |
|
468 |
||
469 |
/** |
|
470 |
* Retrieves the EngineRenew that specifies the replacement of the given |
|
471 |
* engine type from the given renewlist */ |
|
472 |
static EngineRenew *GetEngineReplacement(EngineRenewList erl, EngineID engine) |
|
473 |
{ |
|
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
474 |
EngineRenew *er = (EngineRenew *)erl; |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
475 |
|
2848 | 476 |
while (er) { |
477 |
if (er->from == engine) return er; |
|
478 |
er = er->next; |
|
479 |
} |
|
480 |
return NULL; |
|
481 |
} |
|
482 |
||
4171 | 483 |
void RemoveAllEngineReplacement(EngineRenewList *erl) |
2848 | 484 |
{ |
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
485 |
EngineRenew *er = (EngineRenew *)(*erl); |
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4358
diff
changeset
|
486 |
EngineRenew *next; |
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
487 |
|
2848 | 488 |
while (er) { |
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4358
diff
changeset
|
489 |
next = er->next; |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4358
diff
changeset
|
490 |
DeleteEngineRenew(er); |
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4358
diff
changeset
|
491 |
er = next; |
2848 | 492 |
} |
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
493 |
*erl = NULL; // Empty list |
2848 | 494 |
} |
495 |
||
496 |
EngineID EngineReplacement(EngineRenewList erl, EngineID engine) |
|
497 |
{ |
|
498 |
const EngineRenew *er = GetEngineReplacement(erl, engine); |
|
499 |
return er == NULL ? INVALID_ENGINE : er->to; |
|
500 |
} |
|
501 |
||
4171 | 502 |
int32 AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, uint32 flags) |
2848 | 503 |
{ |
504 |
EngineRenew *er; |
|
505 |
||
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
506 |
/* Check if the old vehicle is already in the list */ |
2848 | 507 |
er = GetEngineReplacement(*erl, old_engine); |
508 |
if (er != NULL) { |
|
509 |
if (flags & DC_EXEC) er->to = new_engine; |
|
510 |
return 0; |
|
511 |
} |
|
512 |
||
513 |
er = AllocateEngineRenew(); |
|
514 |
if (er == NULL) return CMD_ERROR; |
|
515 |
||
516 |
if (flags & DC_EXEC) { |
|
517 |
er->from = old_engine; |
|
518 |
er->to = new_engine; |
|
519 |
||
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
520 |
/* Insert before the first element */ |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
521 |
er->next = (EngineRenew *)(*erl); |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
522 |
*erl = (EngineRenewList)er; |
2848 | 523 |
} |
524 |
||
525 |
return 0; |
|
526 |
} |
|
527 |
||
4171 | 528 |
int32 RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, uint32 flags) |
2848 | 529 |
{ |
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
530 |
EngineRenew *er = (EngineRenew *)(*erl); |
4171 | 531 |
EngineRenew *prev = NULL; |
2848 | 532 |
|
533 |
while (er) |
|
534 |
{ |
|
535 |
if (er->from == engine) { |
|
536 |
if (flags & DC_EXEC) { |
|
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
537 |
if (prev == NULL) { // First element |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
538 |
/* The second becomes the new first element */ |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
539 |
*erl = (EngineRenewList)er->next; |
2848 | 540 |
} else { |
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
541 |
/* Cut this element out */ |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
542 |
prev->next = er->next; |
2848 | 543 |
} |
4384
293c0d26294c
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4358
diff
changeset
|
544 |
DeleteEngineRenew(er); |
2848 | 545 |
} |
546 |
return 0; |
|
547 |
} |
|
548 |
prev = er; |
|
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
549 |
er = er->next; |
2848 | 550 |
} |
551 |
||
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
552 |
return CMD_ERROR; |
2848 | 553 |
} |
554 |
||
555 |
static const SaveLoad _engine_renew_desc[] = { |
|
556 |
SLE_VAR(EngineRenew, from, SLE_UINT16), |
|
557 |
SLE_VAR(EngineRenew, to, SLE_UINT16), |
|
558 |
||
559 |
SLE_REF(EngineRenew, next, REF_ENGINE_RENEWS), |
|
560 |
||
561 |
SLE_END() |
|
562 |
}; |
|
563 |
||
564 |
static void Save_ERNW(void) |
|
565 |
{ |
|
566 |
EngineRenew *er; |
|
567 |
||
568 |
FOR_ALL_ENGINE_RENEWS(er) { |
|
4348
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
569 |
SlSetArrayIndex(er->index); |
95ba9ff1612e
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
570 |
SlObject(er, _engine_renew_desc); |
2848 | 571 |
} |
572 |
} |
|
573 |
||
574 |
static void Load_ERNW(void) |
|
575 |
{ |
|
576 |
int index; |
|
577 |
||
578 |
while ((index = SlIterateArray()) != -1) { |
|
579 |
EngineRenew *er; |
|
580 |
||
4974
c962d0622bc1
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
581 |
if (!AddBlockIfNeeded(&_EngineRenew_pool, index)) |
2848 | 582 |
error("EngineRenews: failed loading savegame: too many EngineRenews"); |
583 |
||
584 |
er = GetEngineRenew(index); |
|
585 |
SlObject(er, _engine_renew_desc); |
|
586 |
} |
|
587 |
} |
|
588 |
||
1881
023a134a4b12
(svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents:
1855
diff
changeset
|
589 |
static const SaveLoad _engine_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
|
590 |
SLE_CONDVAR(Engine, intro_date, SLE_FILE_U16 | SLE_VAR_I32, 0, 30), |
5d0e40cd67b9
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
591 |
SLE_CONDVAR(Engine, intro_date, SLE_INT32, 31, 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
|
592 |
SLE_CONDVAR(Engine, age, SLE_FILE_U16 | SLE_VAR_I32, 0, 30), |
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
|
593 |
SLE_CONDVAR(Engine, age, SLE_INT32, 31, 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
|
594 |
SLE_VAR(Engine, reliability, 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
|
595 |
SLE_VAR(Engine, reliability_spd_dec, 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
|
596 |
SLE_VAR(Engine, reliability_start, 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
|
597 |
SLE_VAR(Engine, reliability_max, 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
|
598 |
SLE_VAR(Engine, reliability_final, 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
|
599 |
SLE_VAR(Engine, duration_phase_1, 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
|
600 |
SLE_VAR(Engine, duration_phase_2, 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
|
601 |
SLE_VAR(Engine, duration_phase_3, SLE_UINT16), |
0 | 602 |
|
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
|
603 |
SLE_VAR(Engine, lifelength, SLE_UINT8), |
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
|
604 |
SLE_VAR(Engine, flags, SLE_UINT8), |
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
|
605 |
SLE_VAR(Engine, preview_player, SLE_UINT8), |
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
|
606 |
SLE_VAR(Engine, preview_wait, SLE_UINT8), |
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
|
607 |
SLE_VAR(Engine, railtype, SLE_UINT8), |
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
|
608 |
SLE_VAR(Engine, player_avail, SLE_UINT8), |
0 | 609 |
|
610 |
// reserve extra space in savegame here. (currently 16 bytes) |
|
3222
8bfed4267cba
(svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents:
3047
diff
changeset
|
611 |
SLE_CONDNULL(16, 2, SL_MAX_VERSION), |
0 | 612 |
|
613 |
SLE_END() |
|
614 |
}; |
|
615 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
616 |
static void Save_ENGN(void) |
0 | 617 |
{ |
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
618 |
uint i; |
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
619 |
|
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
620 |
for (i = 0; i != lengthof(_engines); i++) { |
0 | 621 |
SlSetArrayIndex(i); |
2242
27fa4807cd61
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
622 |
SlObject(&_engines[i], _engine_desc); |
0 | 623 |
} |
624 |
} |
|
625 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
626 |
static void Load_ENGN(void) |
0 | 627 |
{ |
628 |
int index; |
|
629 |
while ((index = SlIterateArray()) != -1) { |
|
1926
68d60188a22f
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1908
diff
changeset
|
630 |
SlObject(GetEngine(index), _engine_desc); |
0 | 631 |
} |
632 |
} |
|
633 |
||
1093
e8d26c7dc42f
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
634 |
static void LoadSave_ENGS(void) |
0 | 635 |
{ |
636 |
SlArray(_engine_name_strings, lengthof(_engine_name_strings), SLE_STRINGID); |
|
637 |
} |
|
638 |
||
639 |
const ChunkHandler _engine_chunk_handlers[] = { |
|
2848 | 640 |
{ 'ENGN', Save_ENGN, Load_ENGN, CH_ARRAY }, |
641 |
{ 'ENGS', LoadSave_ENGS, LoadSave_ENGS, CH_RIFF }, |
|
642 |
{ 'ERNW', Save_ERNW, Load_ERNW, CH_ARRAY | CH_LAST}, |
|
0 | 643 |
}; |
644 |
||
2848 | 645 |
void InitializeEngines(void) |
1197 | 646 |
{ |
2848 | 647 |
/* Clean the engine renew pool and create 1 block in it */ |
4974
c962d0622bc1
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
648 |
CleanPool(&_EngineRenew_pool); |
c962d0622bc1
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
649 |
AddBlockToPool(&_EngineRenew_pool); |
1196
115f46e3807d
(svn r1700) - Fix: Hacked clients can no longer be used to build vehicles that are not available yet (Hackykid)
bjarni
parents:
1096
diff
changeset
|
650 |
} |