author | rubidium |
Thu, 01 Feb 2007 15:49:12 +0000 | |
changeset 5893 | 7e431a4abebb |
parent 5868 | 94430141c189 |
child 5944 | 6d059cc8662b |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
0 | 3 |
#include "stdafx.h" |
1891
862800791170
(svn r2397) - CodeChange: rename all "ttd" files to "openttd" files.
Darkvater
parents:
1883
diff
changeset
|
4 |
#include "openttd.h" |
1299
39c06aba09aa
(svn r1803) Move debugging stuff into files of it's own
tron
parents:
1197
diff
changeset
|
5 |
#include "debug.h" |
2163
b17b313113a0
(svn r2673) Include functions.h directly, not globally via openttd.h
tron
parents:
2159
diff
changeset
|
6 |
#include "functions.h" |
507
04b5403aaf6b
(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
75140dc68759
(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
f6284cf5fab0
(svn r2669) Shuffle some more stuff around to reduce dependencies
tron
parents:
2147
diff
changeset
|
15 |
#include "variables.h" |
2708
48714bad9499
(svn r3252) - NewGRF: Map new train subtypes to old types for rail vehicles.
peter1138
parents:
2639
diff
changeset
|
16 |
#include "train.h" |
5854
9eee280920f0
(svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents:
5840
diff
changeset
|
17 |
#include "aircraft.h" |
3866
b13553406a0a
(svn r4902) Newgrf : Introduction of the newgrf_cargo files.
belugas
parents:
3865
diff
changeset
|
18 |
#include "newgrf_cargo.h" |
4261
28670f743746
(svn r5887) -Cleanup: move date related functions, defines and variables to date.[ch]
rubidium
parents:
4171
diff
changeset
|
19 |
#include "date.h" |
4322
f40bbdf476b3
(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
|
20 |
#include "table/engines.h" |
0 | 21 |
|
2763 | 22 |
EngineInfo _engine_info[TOTAL_NUM_ENGINES]; |
23 |
RailVehicleInfo _rail_vehicle_info[NUM_TRAIN_ENGINES]; |
|
24 |
ShipVehicleInfo _ship_vehicle_info[NUM_SHIP_ENGINES]; |
|
25 |
AircraftVehicleInfo _aircraft_vehicle_info[NUM_AIRCRAFT_ENGINES]; |
|
26 |
RoadVehicleInfo _road_vehicle_info[NUM_ROAD_ENGINES]; |
|
27 |
||
0 | 28 |
enum { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
29 |
ENGINE_AVAILABLE = 1, |
0 | 30 |
ENGINE_INTRODUCING = 2, |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
31 |
ENGINE_PREVIEWING = 4, |
0 | 32 |
}; |
33 |
||
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
34 |
enum { |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
35 |
YEAR_ENGINE_AGING_STOPS = 2050, |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
36 |
}; |
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
37 |
|
0 | 38 |
|
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
39 |
void ShowEnginePreviewWindow(EngineID engine); |
0 | 40 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
41 |
void DeleteCustomEngineNames(void) |
0 | 42 |
{ |
43 |
uint i; |
|
44 |
StringID old; |
|
45 |
||
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1329
diff
changeset
|
46 |
for (i = 0; i != TOTAL_NUM_ENGINES; i++) { |
0 | 47 |
old = _engine_name_strings[i]; |
48 |
_engine_name_strings[i] = i + STR_8000_KIRBY_PAUL_TANK_STEAM; |
|
49 |
DeleteName(old); |
|
50 |
} |
|
51 |
||
52 |
_vehicle_design_names &= ~1; |
|
53 |
} |
|
54 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
55 |
void LoadCustomEngineNames(void) |
0 | 56 |
{ |
4432
372316ca7924
(svn r6195) -Codechange: do not use '//' in '/* ... */' style comments and '/*' or '*/' in '//' style comments.
rubidium
parents:
4384
diff
changeset
|
57 |
/* XXX: not done */ |
5380
8ea58542b6e0
(svn r7565) -Codechange: Rework DEBUG functionality. Look for appropiate debugging levels to
Darkvater
parents:
5216
diff
changeset
|
58 |
DEBUG(misc, 1, "LoadCustomEngineNames: not done"); |
0 | 59 |
} |
60 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
61 |
static void SetupEngineNames(void) |
0 | 62 |
{ |
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1329
diff
changeset
|
63 |
StringID *name; |
0 | 64 |
|
1474
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1329
diff
changeset
|
65 |
for (name = _engine_name_strings; name != endof(_engine_name_strings); name++) |
a26a21fa10ef
(svn r1978) - Fix: Plug some memleaks; thanks Valgrind
Darkvater
parents:
1329
diff
changeset
|
66 |
*name = STR_SV_EMPTY; |
0 | 67 |
|
68 |
DeleteCustomEngineNames(); |
|
69 |
LoadCustomEngineNames(); |
|
70 |
} |
|
71 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
72 |
static void AdjustAvailAircraft(void) |
0 | 73 |
{ |
74 |
byte avail = 0; |
|
4297
d0311b62255c
(svn r5934) -Cleanup: forgot some conversions to Year and to Date
rubidium
parents:
4293
diff
changeset
|
75 |
if (_cur_year >= 1955) avail |= 2; // big airport |
d0311b62255c
(svn r5934) -Cleanup: forgot some conversions to Year and to Date
rubidium
parents:
4293
diff
changeset
|
76 |
if (_cur_year < 1960 || _patches.always_small_airport) avail |= 1; // small airport |
d0311b62255c
(svn r5934) -Cleanup: forgot some conversions to Year and to Date
rubidium
parents:
4293
diff
changeset
|
77 |
if (_cur_year >= 1963) avail |= 4; // enable heliport |
0 | 78 |
|
79 |
if (avail != _avail_aircraft) { |
|
80 |
_avail_aircraft = avail; |
|
81 |
InvalidateWindow(WC_BUILD_STATION, 0); |
|
82 |
} |
|
83 |
} |
|
84 |
||
85 |
static void CalcEngineReliability(Engine *e) |
|
86 |
{ |
|
87 |
uint age = e->age; |
|
88 |
||
89 |
if (age < e->duration_phase_1) { |
|
90 |
uint start = e->reliability_start; |
|
91 |
e->reliability = age * (e->reliability_max - start) / e->duration_phase_1 + start; |
|
4767
df84b7f59e5b
(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 |
} else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _patches.never_expire_vehicles) { |
df84b7f59e5b
(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 |
/* We are at the peak of this engines life. It will have max reliability. |
df84b7f59e5b
(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
|
94 |
* This is also true if the engines never expire. They will not go bad over time */ |
0 | 95 |
e->reliability = e->reliability_max; |
96 |
} else if ((age -= e->duration_phase_2) < e->duration_phase_3) { |
|
97 |
uint max = e->reliability_max; |
|
98 |
e->reliability = (int)age * (int)(e->reliability_final - max) / e->duration_phase_3 + max; |
|
99 |
} else { |
|
4767
df84b7f59e5b
(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 |
/* time's up for this engine. |
df84b7f59e5b
(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 |
* We will now completely retire this design */ |
df84b7f59e5b
(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
|
102 |
e->player_avail = 0; |
0 | 103 |
e->reliability = e->reliability_final; |
4767
df84b7f59e5b
(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
|
104 |
InvalidateWindowClassesData(WC_BUILD_VEHICLE); // Kick this engine out of the lists |
0 | 105 |
} |
4767
df84b7f59e5b
(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
|
106 |
InvalidateWindowClasses(WC_BUILD_VEHICLE); // Update to show the new reliability |
0 | 107 |
} |
108 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
109 |
void AddTypeToEngines(void) |
842 | 110 |
{ |
2242
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
111 |
Engine* e = _engines; |
842 | 112 |
|
2242
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
113 |
do e->type = VEH_Train; while (++e < &_engines[ROAD_ENGINES_INDEX]); |
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
114 |
do e->type = VEH_Road; while (++e < &_engines[SHIP_ENGINES_INDEX]); |
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
115 |
do e->type = VEH_Ship; while (++e < &_engines[AIRCRAFT_ENGINES_INDEX]); |
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
116 |
do e->type = VEH_Aircraft; while (++e < &_engines[TOTAL_NUM_ENGINES]); |
842 | 117 |
} |
118 |
||
1093
4fdc46eaf423
(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
c7e43c47a2b9
(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
f40bbdf476b3
(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
512eae2cf006
(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++) { |
512eae2cf006
(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; |
|
132 |
e->flags = 0; |
|
133 |
e->player_avail = 0; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
114
diff
changeset
|
134 |
|
2875
8d939bcf7784
(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
|
135 |
// The magic value of 729 days below comes from the NewGRF spec. If the |
8d939bcf7784
(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 |
// base intro date is before 1922 then the random number of days is not |
8d939bcf7784
(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 |
// added. |
0 | 138 |
r = Random(); |
4297
d0311b62255c
(svn r5934) -Cleanup: forgot some conversions to Year and to Date
rubidium
parents:
4293
diff
changeset
|
139 |
e->intro_date = ei->base_intro <= ConvertYMDToDate(1922, 0, 1) ? ei->base_intro : (Date)GB(r, 0, 9) + ei->base_intro; |
0 | 140 |
if (e->intro_date <= _date) { |
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
141 |
e->age = (aging_date - e->intro_date) >> 5; |
0 | 142 |
e->player_avail = (byte)-1; |
143 |
e->flags |= ENGINE_AVAILABLE; |
|
144 |
} |
|
145 |
||
2140
a04d0142ad65
(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
|
146 |
e->reliability_start = GB(r, 16, 14) + 0x7AE0; |
0 | 147 |
r = Random(); |
2140
a04d0142ad65
(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
|
148 |
e->reliability_max = GB(r, 0, 14) + 0xBFFF; |
a04d0142ad65
(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_final = GB(r, 16, 14) + 0x3FFF; |
0 | 150 |
|
151 |
r = Random(); |
|
2140
a04d0142ad65
(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
|
152 |
e->duration_phase_1 = GB(r, 0, 5) + 7; |
a04d0142ad65
(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_2 = GB(r, 5, 4) + ei->base_life * 12 - 96; |
a04d0142ad65
(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_3 = GB(r, 9, 7) + 120; |
0 | 155 |
|
156 |
e->reliability_spd_dec = (ei->unk2&0x7F) << 2; |
|
157 |
||
158 |
/* my invented flag for something that is a wagon */ |
|
159 |
if (ei->unk2 & 0x80) { |
|
160 |
e->age = 0xFFFF; |
|
161 |
} else { |
|
162 |
CalcEngineReliability(e); |
|
163 |
} |
|
164 |
||
165 |
e->lifelength = ei->lifelength + _patches.extend_vehicle_life; |
|
166 |
||
167 |
// prevent certain engines from ever appearing. |
|
2530
df14798edc40
(svn r3059) Use bitfields to encode railtype and climates of engines instead of manual shifting/anding
tron
parents:
2491
diff
changeset
|
168 |
if (!HASBIT(ei->climates, _opt.landscape)) { |
0 | 169 |
e->flags |= ENGINE_AVAILABLE; |
170 |
e->player_avail = 0; |
|
171 |
} |
|
915 | 172 |
|
819
c425b7e22f6a
(svn r1290) Added type to typedef struct Engine and filled in the same data as in type in vehicle
bjarni
parents:
740
diff
changeset
|
173 |
/* This sets up type for the engine |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4432
diff
changeset
|
174 |
* It is needed if you want to ask the engine what type it is |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4432
diff
changeset
|
175 |
* It should hopefully be the same as when you ask a vehicle what it is |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4432
diff
changeset
|
176 |
* but using this, you can ask what type an engine number is |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4432
diff
changeset
|
177 |
* even if it is not a vehicle (yet)*/ |
0 | 178 |
} |
179 |
||
180 |
AdjustAvailAircraft(); |
|
181 |
} |
|
182 |
||
5823 | 183 |
static void AcceptEnginePreview(EngineID eid, PlayerID player) |
0 | 184 |
{ |
5823 | 185 |
Engine *e = GetEngine(eid); |
0 | 186 |
|
187 |
SETBIT(e->player_avail, player); |
|
5823 | 188 |
if (e->type == VEH_Train) { |
189 |
const RailVehicleInfo *rvi = RailVehInfo(eid); |
|
190 |
Player *p = GetPlayer(player); |
|
191 |
||
192 |
assert(rvi->railtype < RAILTYPE_END); |
|
193 |
SETBIT(p->avail_railtypes, rvi->railtype); |
|
194 |
} |
|
0 | 195 |
|
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
196 |
e->preview_player = INVALID_PLAYER; |
4766
aa276d0ec2eb
(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
|
197 |
if (player == _local_player) { |
aa276d0ec2eb
(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
|
198 |
InvalidateWindowClassesData(WC_BUILD_VEHICLE); |
aa276d0ec2eb
(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
|
199 |
InvalidateWindowClasses(WC_REPLACE_VEHICLE); |
aa276d0ec2eb
(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
|
200 |
} |
0 | 201 |
} |
202 |
||
1786
7cfd46c3fcc4
(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 |
static PlayerID GetBestPlayer(PlayerID pp) |
7cfd46c3fcc4
(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 |
{ |
7cfd46c3fcc4
(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 |
const Player *p; |
7cfd46c3fcc4
(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 |
int32 best_hist; |
7cfd46c3fcc4
(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 |
PlayerID best_player; |
7cfd46c3fcc4
(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
|
208 |
uint mask = 0; |
7cfd46c3fcc4
(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 |
|
7cfd46c3fcc4
(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 |
do { |
7cfd46c3fcc4
(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 |
best_hist = -1; |
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4845
diff
changeset
|
212 |
best_player = PLAYER_SPECTATOR; |
1786
7cfd46c3fcc4
(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 |
FOR_ALL_PLAYERS(p) { |
7cfd46c3fcc4
(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 |
if (p->is_active && p->block_preview == 0 && !HASBIT(mask, p->index) && |
7cfd46c3fcc4
(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 |
p->old_economy[0].performance_history > best_hist) { |
7cfd46c3fcc4
(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 |
best_hist = p->old_economy[0].performance_history; |
7cfd46c3fcc4
(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
|
217 |
best_player = p->index; |
7cfd46c3fcc4
(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 |
} |
7cfd46c3fcc4
(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 |
} |
7cfd46c3fcc4
(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 |
|
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4845
diff
changeset
|
221 |
if (best_player == PLAYER_SPECTATOR) return PLAYER_SPECTATOR; |
1786
7cfd46c3fcc4
(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 |
|
7cfd46c3fcc4
(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 |
SETBIT(mask, best_player); |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
224 |
} while (pp--, pp != 0); |
1786
7cfd46c3fcc4
(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
|
225 |
|
7cfd46c3fcc4
(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
|
226 |
return best_player; |
7cfd46c3fcc4
(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
|
227 |
} |
7cfd46c3fcc4
(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
|
228 |
|
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
229 |
void EnginesDailyLoop(void) |
0 | 230 |
{ |
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
231 |
EngineID i; |
0 | 232 |
|
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
233 |
if (_cur_year >= YEAR_ENGINE_AGING_STOPS) return; |
0 | 234 |
|
2242
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
235 |
for (i = 0; i != lengthof(_engines); i++) { |
4171 | 236 |
Engine *e = &_engines[i]; |
2242
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
237 |
|
0 | 238 |
if (e->flags & ENGINE_INTRODUCING) { |
239 |
if (e->flags & ENGINE_PREVIEWING) { |
|
740
ab84ecdf86a2
(svn r1196) -Fix: Preview Vehicle had a small glitch. Fixed now.
truelight
parents:
555
diff
changeset
|
240 |
if (e->preview_player != 0xFF && !--e->preview_wait) { |
0 | 241 |
e->flags &= ~ENGINE_PREVIEWING; |
242 |
DeleteWindowById(WC_ENGINE_PREVIEW, i); |
|
243 |
e->preview_player++; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
114
diff
changeset
|
244 |
} |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
3866
diff
changeset
|
245 |
} else if (e->preview_player != 0xFF) { |
1786
7cfd46c3fcc4
(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 |
PlayerID best_player = GetBestPlayer(e->preview_player); |
7cfd46c3fcc4
(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 |
|
4848
45f848b46222
(svn r6774) -Codechange: Rename the badly named OWNER_SPECTATOR to PLAYER_SPECTATOR and
Darkvater
parents:
4845
diff
changeset
|
248 |
if (best_player == PLAYER_SPECTATOR) { |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
249 |
e->preview_player = INVALID_PLAYER; |
1786
7cfd46c3fcc4
(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 |
continue; |
7cfd46c3fcc4
(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
|
251 |
} |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
114
diff
changeset
|
252 |
|
4845
72bbb6e2694e
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4792
diff
changeset
|
253 |
if (!IsHumanPlayer(best_player)) { |
1786
7cfd46c3fcc4
(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
|
254 |
/* XXX - TTDBUG: TTD has a bug here ???? */ |
5823 | 255 |
AcceptEnginePreview(i, best_player); |
0 | 256 |
} else { |
257 |
e->flags |= ENGINE_PREVIEWING; |
|
258 |
e->preview_wait = 20; |
|
4845
72bbb6e2694e
(svn r6771) -Codechange: Replace two macros with functions. IS_HUMAN_PLAYER and
Darkvater
parents:
4792
diff
changeset
|
259 |
if (IsInteractivePlayer(best_player)) ShowEnginePreviewWindow(i); |
0 | 260 |
} |
261 |
} |
|
262 |
} |
|
263 |
} |
|
264 |
} |
|
265 |
||
1786
7cfd46c3fcc4
(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 |
/** Accept an engine prototype. XXX - it is possible that the top-player |
7cfd46c3fcc4
(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 |
* changes while you are waiting to accept the offer? Then it becomes invalid |
3491
35d747bb5e82
(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 |
* @param tile unused |
1786
7cfd46c3fcc4
(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
|
269 |
* @param p1 engine-prototype offered |
7cfd46c3fcc4
(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 |
* @param p2 unused |
7cfd46c3fcc4
(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
|
271 |
*/ |
3491
35d747bb5e82
(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
|
272 |
int32 CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 273 |
{ |
1786
7cfd46c3fcc4
(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 |
Engine *e; |
2951 | 275 |
|
1786
7cfd46c3fcc4
(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
|
276 |
if (!IsEngineIndex(p1)) return CMD_ERROR; |
1926
530480d14685
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1908
diff
changeset
|
277 |
e = GetEngine(p1); |
1786
7cfd46c3fcc4
(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
|
278 |
if (GetBestPlayer(e->preview_player) != _current_player) return CMD_ERROR; |
7cfd46c3fcc4
(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
|
279 |
|
5823 | 280 |
if (flags & DC_EXEC) AcceptEnginePreview(p1, _current_player); |
1786
7cfd46c3fcc4
(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
|
281 |
|
0 | 282 |
return 0; |
283 |
} |
|
284 |
||
257
0ff8a2e60a0d
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
285 |
// Determine if an engine type is a wagon (and not a loco) |
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
286 |
static bool IsWagon(EngineID index) |
257
0ff8a2e60a0d
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
287 |
{ |
5868
94430141c189
(svn r8455) -Codechange: Give a more meaningful name (railveh_type)to member flags of RailVehInfo, as well as changing the code to reflect the fact that it was not a flag but rather a one value only variable. Doing so, some evaluations have been simplified.
belugas
parents:
5854
diff
changeset
|
288 |
return index < NUM_TRAIN_ENGINES && RailVehInfo(index)->railveh_type == RAILVEH_WAGON; |
257
0ff8a2e60a0d
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
289 |
} |
0ff8a2e60a0d
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
290 |
|
410 | 291 |
static void NewVehicleAvailable(Engine *e) |
0 | 292 |
{ |
293 |
Vehicle *v; |
|
294 |
Player *p; |
|
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
295 |
EngineID index = e - _engines; |
0 | 296 |
|
297 |
// In case the player didn't build the vehicle during the intro period, |
|
298 |
// prevent that player from getting future intro periods for a while. |
|
2639 | 299 |
if (e->flags & ENGINE_INTRODUCING) { |
0 | 300 |
FOR_ALL_PLAYERS(p) { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
301 |
uint block_preview = p->block_preview; |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
302 |
|
2639 | 303 |
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
|
304 |
|
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
305 |
/* We assume the user did NOT build it.. prove me wrong ;) */ |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
306 |
p->block_preview = 20; |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
307 |
|
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
308 |
FOR_ALL_VEHICLES(v) { |
0 | 309 |
if (v->type == VEH_Train || v->type == VEH_Road || v->type == VEH_Ship || |
5854
9eee280920f0
(svn r8428) -Codechange: Add proper names to aircraft subtypes instead of magic numbers and add a function IsNormalAircraft() which tells us whether the aircraft is in fact some flying device or a rotor/shadow.
Darkvater
parents:
5840
diff
changeset
|
310 |
(v->type == VEH_Aircraft && IsNormalAircraft(v))) { |
919
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
311 |
if (v->owner == p->index && v->engine_type == index) { |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
312 |
/* The user did prove me wrong, so restore old value */ |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
313 |
p->block_preview = block_preview; |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
314 |
break; |
544f374ee392
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents:
915
diff
changeset
|
315 |
} |
0 | 316 |
} |
317 |
} |
|
318 |
} |
|
319 |
} |
|
320 |
||
114
6a2af0c2d0db
(svn r115) Fix: monorail/maglev became available around 1927
dominik
parents:
0
diff
changeset
|
321 |
e->flags = (e->flags & ~ENGINE_INTRODUCING) | ENGINE_AVAILABLE; |
4766
aa276d0ec2eb
(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
|
322 |
InvalidateWindowClassesData(WC_BUILD_VEHICLE); |
1096
87415b0c6fdb
(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
|
323 |
InvalidateWindowClasses(WC_REPLACE_VEHICLE); |
114
6a2af0c2d0db
(svn r115) Fix: monorail/maglev became available around 1927
dominik
parents:
0
diff
changeset
|
324 |
|
0 | 325 |
// Now available for all players |
326 |
e->player_avail = (byte)-1; |
|
114
6a2af0c2d0db
(svn r115) Fix: monorail/maglev became available around 1927
dominik
parents:
0
diff
changeset
|
327 |
|
6a2af0c2d0db
(svn r115) Fix: monorail/maglev became available around 1927
dominik
parents:
0
diff
changeset
|
328 |
// Do not introduce new rail wagons |
2639 | 329 |
if (IsWagon(index)) return; |
114
6a2af0c2d0db
(svn r115) Fix: monorail/maglev became available around 1927
dominik
parents:
0
diff
changeset
|
330 |
|
5823 | 331 |
if (index < NUM_TRAIN_ENGINES) { |
332 |
// maybe make another rail type available |
|
333 |
RailType railtype = RailVehInfo(index)->railtype; |
|
334 |
assert(railtype < RAILTYPE_END); |
|
335 |
FOR_ALL_PLAYERS(p) { |
|
336 |
if (p->is_active) SETBIT(p->avail_railtypes, railtype); |
|
2147
eb6ba42fd216
(svn r2657) -Codechange: The available railtypes per player are now a bitmask, so
celestar
parents:
2140
diff
changeset
|
337 |
} |
0 | 338 |
|
339 |
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_TRAINAVAIL), 0, 0); |
|
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
340 |
} else if (index < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES) { |
0 | 341 |
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_ROADAVAIL), 0, 0); |
2477
225b2916fe2a
(svn r3003) Change int, uint, uin16 and byte to EngineID where appropriate, plus some related changes (mostly casts)
tron
parents:
2469
diff
changeset
|
342 |
} else if (index < NUM_TRAIN_ENGINES + NUM_ROAD_ENGINES + NUM_SHIP_ENGINES) { |
0 | 343 |
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_SHIPAVAIL), 0, 0); |
344 |
} else { |
|
345 |
AddNewsItem(index, NEWS_FLAGS(NM_CALLBACK, 0, NT_NEW_VEHICLES, DNC_AIRCRAFTAVAIL), 0, 0); |
|
346 |
} |
|
347 |
} |
|
348 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
349 |
void EnginesMonthlyLoop(void) |
0 | 350 |
{ |
351 |
Engine *e; |
|
352 |
||
4300
c7e43c47a2b9
(svn r5946) -Add: merged the TGP branch to mainline. TGP adds:
truelight
parents:
4297
diff
changeset
|
353 |
if (_cur_year < YEAR_ENGINE_AGING_STOPS) { |
2242
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
354 |
for (e = _engines; e != endof(_engines); e++) { |
0 | 355 |
// Age the vehicle |
2242
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
356 |
if (e->flags & ENGINE_AVAILABLE && e->age != 0xFFFF) { |
0 | 357 |
e->age++; |
358 |
CalcEngineReliability(e); |
|
359 |
} |
|
360 |
||
2990
2bbe7769ebd4
(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
|
361 |
if (!(e->flags & ENGINE_AVAILABLE) && _date >= (e->intro_date + 365)) { |
0 | 362 |
// Introduce it to all players |
363 |
NewVehicleAvailable(e); |
|
364 |
} else if (!(e->flags & (ENGINE_AVAILABLE|ENGINE_INTRODUCING)) && _date >= e->intro_date) { |
|
365 |
// Introduction date has passed.. show introducing dialog to one player. |
|
366 |
e->flags |= ENGINE_INTRODUCING; |
|
257
0ff8a2e60a0d
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
367 |
|
0ff8a2e60a0d
(svn r262) Fix: [ 1028234 ] Monorail and MagLev infrastructure not available in 1920s any more
dominik
parents:
220
diff
changeset
|
368 |
// Do not introduce new rail wagons |
964
fe9e7b220b9f
(svn r1456) Simplify isWagon(), make it static and give it a canonical name (IsWagon)
tron
parents:
938
diff
changeset
|
369 |
if (!IsWagon(e - _engines)) |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
370 |
e->preview_player = (PlayerID)1; // Give to the player with the highest rating. |
0 | 371 |
} |
372 |
} |
|
373 |
} |
|
374 |
AdjustAvailAircraft(); |
|
375 |
} |
|
376 |
||
1786
7cfd46c3fcc4
(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 |
/** Rename an engine. |
3491
35d747bb5e82
(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
|
378 |
* @param tile unused |
1786
7cfd46c3fcc4
(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
|
379 |
* @param p1 engine ID to rename |
7cfd46c3fcc4
(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
|
380 |
* @param p2 unused |
7cfd46c3fcc4
(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
|
381 |
*/ |
3491
35d747bb5e82
(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
|
382 |
int32 CmdRenameEngine(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
0 | 383 |
{ |
384 |
StringID str; |
|
385 |
||
1840
ce40137a6ab4
(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
|
386 |
if (!IsEngineIndex(p1) || _cmd_text[0] == '\0') return CMD_ERROR; |
1786
7cfd46c3fcc4
(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
|
387 |
|
1820
d03c56850dc2
(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
|
388 |
str = AllocateNameUnique(_cmd_text, 0); |
1786
7cfd46c3fcc4
(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
|
389 |
if (str == 0) return CMD_ERROR; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
114
diff
changeset
|
390 |
|
0 | 391 |
if (flags & DC_EXEC) { |
392 |
StringID old_str = _engine_name_strings[p1]; |
|
393 |
_engine_name_strings[p1] = str; |
|
394 |
DeleteName(old_str); |
|
395 |
_vehicle_design_names |= 3; |
|
396 |
MarkWholeScreenDirty(); |
|
397 |
} else { |
|
398 |
DeleteName(str); |
|
399 |
} |
|
400 |
||
401 |
return 0; |
|
402 |
} |
|
403 |
||
404 |
||
2848 | 405 |
/* |
406 |
* returns true if an engine is valid, of the specified type, and buildable by |
|
5215
b8fb685df4c5
(svn r7330) -Fix (r7304): Data invalidation doesn't always happen as the local
peter1138
parents:
5037
diff
changeset
|
407 |
* the given player, false otherwise |
2848 | 408 |
* |
409 |
* engine = index of the engine to check |
|
410 |
* type = the type the engine should be of (VEH_xxx) |
|
5215
b8fb685df4c5
(svn r7330) -Fix (r7304): Data invalidation doesn't always happen as the local
peter1138
parents:
5037
diff
changeset
|
411 |
* player = index of the player |
2848 | 412 |
*/ |
5215
b8fb685df4c5
(svn r7330) -Fix (r7304): Data invalidation doesn't always happen as the local
peter1138
parents:
5037
diff
changeset
|
413 |
bool IsEngineBuildable(EngineID engine, byte type, PlayerID player) |
2848 | 414 |
{ |
415 |
const Engine *e; |
|
416 |
||
417 |
// check if it's an engine that is in the engine array |
|
418 |
if (!IsEngineIndex(engine)) return false; |
|
419 |
||
420 |
e = GetEngine(engine); |
|
421 |
||
422 |
// check if it's an engine of specified type |
|
423 |
if (e->type != type) return false; |
|
424 |
||
425 |
// check if it's available |
|
5215
b8fb685df4c5
(svn r7330) -Fix (r7304): Data invalidation doesn't always happen as the local
peter1138
parents:
5037
diff
changeset
|
426 |
if (!HASBIT(e->player_avail, player)) return false; |
2848 | 427 |
|
428 |
return true; |
|
429 |
} |
|
430 |
||
431 |
/************************************************************************ |
|
432 |
* Engine Replacement stuff |
|
433 |
************************************************************************/ |
|
434 |
||
4974
2b7c9ba5604c
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
435 |
static void EngineRenewPoolNewBlock(uint start_item); |
2848 | 436 |
|
5216
8bd14ee39af2
(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
|
437 |
DEFINE_OLD_POOL(EngineRenew, EngineRenew, EngineRenewPoolNewBlock, NULL) |
2848 | 438 |
|
439 |
static void EngineRenewPoolNewBlock(uint start_item) |
|
440 |
{ |
|
441 |
EngineRenew *er; |
|
442 |
||
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
443 |
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
444 |
* TODO - This is just a temporary stage, this will be removed. */ |
4974
2b7c9ba5604c
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
445 |
for (er = GetEngineRenew(start_item); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) { |
2848 | 446 |
er->index = start_item++; |
447 |
er->from = INVALID_ENGINE; |
|
448 |
} |
|
449 |
} |
|
450 |
||
451 |
||
452 |
static EngineRenew *AllocateEngineRenew(void) |
|
453 |
{ |
|
454 |
EngineRenew *er; |
|
455 |
||
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
456 |
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items. |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
457 |
* TODO - This is just a temporary stage, this will be removed. */ |
4974
2b7c9ba5604c
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
458 |
for (er = GetEngineRenew(0); er != NULL; er = (er->index + 1U < GetEngineRenewPoolSize()) ? GetEngineRenew(er->index + 1U) : NULL) { |
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
459 |
if (IsValidEngineRenew(er)) continue; |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
460 |
|
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
461 |
er->to = INVALID_ENGINE; |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
462 |
er->next = NULL; |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
463 |
return er; |
2848 | 464 |
} |
465 |
||
466 |
/* Check if we can add a block to the pool */ |
|
4974
2b7c9ba5604c
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
467 |
if (AddBlockToPool(&_EngineRenew_pool)) return AllocateEngineRenew(); |
2848 | 468 |
|
469 |
return NULL; |
|
470 |
} |
|
471 |
||
472 |
/** |
|
473 |
* Retrieves the EngineRenew that specifies the replacement of the given |
|
474 |
* engine type from the given renewlist */ |
|
475 |
static EngineRenew *GetEngineReplacement(EngineRenewList erl, EngineID engine) |
|
476 |
{ |
|
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
477 |
EngineRenew *er = (EngineRenew *)erl; |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
478 |
|
2848 | 479 |
while (er) { |
480 |
if (er->from == engine) return er; |
|
481 |
er = er->next; |
|
482 |
} |
|
483 |
return NULL; |
|
484 |
} |
|
485 |
||
4171 | 486 |
void RemoveAllEngineReplacement(EngineRenewList *erl) |
2848 | 487 |
{ |
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
488 |
EngineRenew *er = (EngineRenew *)(*erl); |
4384
7e0d3ed719d9
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4358
diff
changeset
|
489 |
EngineRenew *next; |
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
490 |
|
2848 | 491 |
while (er) { |
4384
7e0d3ed719d9
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4358
diff
changeset
|
492 |
next = er->next; |
7e0d3ed719d9
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4358
diff
changeset
|
493 |
DeleteEngineRenew(er); |
7e0d3ed719d9
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4358
diff
changeset
|
494 |
er = next; |
2848 | 495 |
} |
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
496 |
*erl = NULL; // Empty list |
2848 | 497 |
} |
498 |
||
499 |
EngineID EngineReplacement(EngineRenewList erl, EngineID engine) |
|
500 |
{ |
|
501 |
const EngineRenew *er = GetEngineReplacement(erl, engine); |
|
502 |
return er == NULL ? INVALID_ENGINE : er->to; |
|
503 |
} |
|
504 |
||
4171 | 505 |
int32 AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, uint32 flags) |
2848 | 506 |
{ |
507 |
EngineRenew *er; |
|
508 |
||
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
509 |
/* Check if the old vehicle is already in the list */ |
2848 | 510 |
er = GetEngineReplacement(*erl, old_engine); |
511 |
if (er != NULL) { |
|
512 |
if (flags & DC_EXEC) er->to = new_engine; |
|
513 |
return 0; |
|
514 |
} |
|
515 |
||
516 |
er = AllocateEngineRenew(); |
|
517 |
if (er == NULL) return CMD_ERROR; |
|
518 |
||
519 |
if (flags & DC_EXEC) { |
|
520 |
er->from = old_engine; |
|
521 |
er->to = new_engine; |
|
522 |
||
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
523 |
/* Insert before the first element */ |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
524 |
er->next = (EngineRenew *)(*erl); |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
525 |
*erl = (EngineRenewList)er; |
2848 | 526 |
} |
527 |
||
528 |
return 0; |
|
529 |
} |
|
530 |
||
4171 | 531 |
int32 RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, uint32 flags) |
2848 | 532 |
{ |
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
533 |
EngineRenew *er = (EngineRenew *)(*erl); |
4171 | 534 |
EngineRenew *prev = NULL; |
2848 | 535 |
|
536 |
while (er) |
|
537 |
{ |
|
538 |
if (er->from == engine) { |
|
539 |
if (flags & DC_EXEC) { |
|
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
540 |
if (prev == NULL) { // First element |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
541 |
/* The second becomes the new first element */ |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
542 |
*erl = (EngineRenewList)er->next; |
2848 | 543 |
} else { |
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
544 |
/* Cut this element out */ |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
545 |
prev->next = er->next; |
2848 | 546 |
} |
4384
7e0d3ed719d9
(svn r6137) -Codechange: some very minor cleanups:
truelight
parents:
4358
diff
changeset
|
547 |
DeleteEngineRenew(er); |
2848 | 548 |
} |
549 |
return 0; |
|
550 |
} |
|
551 |
prev = er; |
|
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
552 |
er = er->next; |
2848 | 553 |
} |
554 |
||
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
555 |
return CMD_ERROR; |
2848 | 556 |
} |
557 |
||
558 |
static const SaveLoad _engine_renew_desc[] = { |
|
559 |
SLE_VAR(EngineRenew, from, SLE_UINT16), |
|
560 |
SLE_VAR(EngineRenew, to, SLE_UINT16), |
|
561 |
||
562 |
SLE_REF(EngineRenew, next, REF_ENGINE_RENEWS), |
|
563 |
||
564 |
SLE_END() |
|
565 |
}; |
|
566 |
||
567 |
static void Save_ERNW(void) |
|
568 |
{ |
|
569 |
EngineRenew *er; |
|
570 |
||
571 |
FOR_ALL_ENGINE_RENEWS(er) { |
|
4348
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
572 |
SlSetArrayIndex(er->index); |
d9ddb0558a48
(svn r6049) -Codechange: forgot EngineRenew in r6047
truelight
parents:
4346
diff
changeset
|
573 |
SlObject(er, _engine_renew_desc); |
2848 | 574 |
} |
575 |
} |
|
576 |
||
577 |
static void Load_ERNW(void) |
|
578 |
{ |
|
579 |
int index; |
|
580 |
||
581 |
while ((index = SlIterateArray()) != -1) { |
|
582 |
EngineRenew *er; |
|
583 |
||
4974
2b7c9ba5604c
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
584 |
if (!AddBlockIfNeeded(&_EngineRenew_pool, index)) |
2848 | 585 |
error("EngineRenews: failed loading savegame: too many EngineRenews"); |
586 |
||
587 |
er = GetEngineRenew(index); |
|
588 |
SlObject(er, _engine_renew_desc); |
|
589 |
} |
|
590 |
} |
|
591 |
||
1881
435d39bd6ee0
(svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents:
1855
diff
changeset
|
592 |
static const SaveLoad _engine_desc[] = { |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
593 |
SLE_CONDVAR(Engine, intro_date, SLE_FILE_U16 | SLE_VAR_I32, 0, 30), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
594 |
SLE_CONDVAR(Engine, intro_date, SLE_INT32, 31, SL_MAX_VERSION), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
595 |
SLE_CONDVAR(Engine, age, SLE_FILE_U16 | SLE_VAR_I32, 0, 30), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
596 |
SLE_CONDVAR(Engine, age, SLE_INT32, 31, SL_MAX_VERSION), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
597 |
SLE_VAR(Engine, reliability, SLE_UINT16), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
598 |
SLE_VAR(Engine, reliability_spd_dec, SLE_UINT16), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
599 |
SLE_VAR(Engine, reliability_start, SLE_UINT16), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
600 |
SLE_VAR(Engine, reliability_max, SLE_UINT16), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
601 |
SLE_VAR(Engine, reliability_final, SLE_UINT16), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
602 |
SLE_VAR(Engine, duration_phase_1, SLE_UINT16), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
603 |
SLE_VAR(Engine, duration_phase_2, SLE_UINT16), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
604 |
SLE_VAR(Engine, duration_phase_3, SLE_UINT16), |
0 | 605 |
|
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
606 |
SLE_VAR(Engine, lifelength, SLE_UINT8), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
607 |
SLE_VAR(Engine, flags, SLE_UINT8), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
608 |
SLE_VAR(Engine, preview_player, SLE_UINT8), |
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
609 |
SLE_VAR(Engine, preview_wait, SLE_UINT8), |
5823 | 610 |
SLE_CONDNULL(1, 0, 44), |
4344
7e123fec5b0b
(svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents:
4326
diff
changeset
|
611 |
SLE_VAR(Engine, player_avail, SLE_UINT8), |
0 | 612 |
|
613 |
// reserve extra space in savegame here. (currently 16 bytes) |
|
3222
6de22e06a1e9
(svn r3895) - Add proper SLE(G)_CONDNULL macros for the empty space reservation in savegames and update where used
Darkvater
parents:
3047
diff
changeset
|
614 |
SLE_CONDNULL(16, 2, SL_MAX_VERSION), |
0 | 615 |
|
616 |
SLE_END() |
|
617 |
}; |
|
618 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
619 |
static void Save_ENGN(void) |
0 | 620 |
{ |
2242
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
621 |
uint i; |
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
622 |
|
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
623 |
for (i = 0; i != lengthof(_engines); i++) { |
0 | 624 |
SlSetArrayIndex(i); |
2242
512eae2cf006
(svn r2762) Simplify a loop, remove an unused variable and add many consts
tron
parents:
2204
diff
changeset
|
625 |
SlObject(&_engines[i], _engine_desc); |
0 | 626 |
} |
627 |
} |
|
628 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
629 |
static void Load_ENGN(void) |
0 | 630 |
{ |
631 |
int index; |
|
632 |
while ((index = SlIterateArray()) != -1) { |
|
1926
530480d14685
(svn r2432) Use GetEngine() instead of DEREF_ENGINE() or even _engines[]
tron
parents:
1908
diff
changeset
|
633 |
SlObject(GetEngine(index), _engine_desc); |
0 | 634 |
} |
635 |
} |
|
636 |
||
1093
4fdc46eaf423
(svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents:
1009
diff
changeset
|
637 |
static void LoadSave_ENGS(void) |
0 | 638 |
{ |
639 |
SlArray(_engine_name_strings, lengthof(_engine_name_strings), SLE_STRINGID); |
|
640 |
} |
|
641 |
||
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
642 |
extern const ChunkHandler _engine_chunk_handlers[] = { |
2848 | 643 |
{ 'ENGN', Save_ENGN, Load_ENGN, CH_ARRAY }, |
644 |
{ 'ENGS', LoadSave_ENGS, LoadSave_ENGS, CH_RIFF }, |
|
645 |
{ 'ERNW', Save_ERNW, Load_ERNW, CH_ARRAY | CH_LAST}, |
|
0 | 646 |
}; |
647 |
||
2848 | 648 |
void InitializeEngines(void) |
1197 | 649 |
{ |
2848 | 650 |
/* Clean the engine renew pool and create 1 block in it */ |
4974
2b7c9ba5604c
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
651 |
CleanPool(&_EngineRenew_pool); |
2b7c9ba5604c
(svn r6977) Use the pool macros for the EngineRenew pool
tron
parents:
4848
diff
changeset
|
652 |
AddBlockToPool(&_EngineRenew_pool); |
1196
67f7f3017d99
(svn r1700) - Fix: Hacked clients can no longer be used to build vehicles that are not available yet (Hackykid)
bjarni
parents:
1096
diff
changeset
|
653 |
} |