From 63e97754fbf907cfefd277087bfbac5e0d4434e8 Mon Sep 17 00:00:00 2001 From: truelight Date: Thu, 6 Jan 2005 22:31:58 +0000 Subject: (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 *. --- engine.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'engine.c') 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; + } } } } -- cgit v1.2.3-54-g00ecf