summaryrefslogtreecommitdiff
path: root/engine.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-01-06 22:31:58 +0000
committertruelight <truelight@openttd.org>2005-01-06 22:31:58 +0000
commit63e97754fbf907cfefd277087bfbac5e0d4434e8 (patch)
tree254702245ba43d006f4823111d0c2c592fb701ca /engine.c
parenta4111363c0def2ccec66ef28b5e8169e8a2df2f0 (diff)
downloadopenttd-63e97754fbf907cfefd277087bfbac5e0d4434e8.tar.xz
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
(in prepare of dynamic arrays): - DEREF_XXX is changed into GetXXX - All direct call are directed via GetXXX - struct Industry has now an index-field - ENUM'd some stuff - Replaced home built loops with FOR_ALL_XXX - Added _stations_size, _vehicles_size, ... which gives the length of the array (which will be dynamic in the near future) - Changed lengtof(XXX) to _XXX_size (e.g. _stations_size) - Removed all endof(XXX) (because mostly it was part of a FOR_ALL_XXX) - Made the sort-functions of all 4 dynamic - Made all 4 Initialize functions more of the same - Some minor tab-fixing and stuff (tnx to Tron for proof-reading my 100kb patch ;)) Note for all: please do NOT directly call _stations, _vehicles, _towns and _industries, but use the right wrapper to access them. Thank you. Ps: please also do not use 'v++', where v is of type Vehicle *.
Diffstat (limited to 'engine.c')
-rw-r--r--engine.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/engine.c b/engine.c
index 734f507dc..12d1c7d80 100644
--- a/engine.c
+++ b/engine.c
@@ -737,17 +737,22 @@ static void NewVehicleAvailable(Engine *e)
// prevent that player from getting future intro periods for a while.
if (e->flags&ENGINE_INTRODUCING) {
FOR_ALL_PLAYERS(p) {
+ uint block_preview = p->block_preview;
+
if (!HASBIT(e->player_avail,p->index))
continue;
- for(v=_vehicles;;) {
+ /* We assume the user did NOT build it.. prove me wrong ;) */
+ p->block_preview = 20;
+
+ FOR_ALL_VEHICLES(v) {
if (v->type == VEH_Train || v->type == VEH_Road || v->type == VEH_Ship ||
(v->type == VEH_Aircraft && v->subtype <= 2)) {
- if (v->owner == p->index && v->engine_type == index) break;
- }
- if (++v == endof(_vehicles)) {
- p->block_preview = 20;
- break;
+ if (v->owner == p->index && v->engine_type == index) {
+ /* The user did prove me wrong, so restore old value */
+ p->block_preview = block_preview;
+ break;
+ }
}
}
}