From b450603437d1eae96e109058ab1c59b86be8a216 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 *. --- roadveh_gui.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'roadveh_gui.c') diff --git a/roadveh_gui.c b/roadveh_gui.c index 58c6abe86..f55e1fef5 100644 --- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -45,7 +45,7 @@ static void DrawRoadVehImage(Vehicle *v, int x, int y, VehicleID selection) static void RoadVehDetailsWndProc(Window *w, WindowEvent *e) { - Vehicle *v = &_vehicles[w->window_number]; + Vehicle *v = GetVehicle(w->window_number); StringID str; int mod; @@ -204,7 +204,7 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e) { switch(e->event) { case WE_PAINT: { - Vehicle *v = &_vehicles[w->window_number]; + Vehicle *v = GetVehicle(w->window_number); StringID str; w->disabled_state = (v->owner != _local_player) ? (1<<8 | 1<<7) : 0; @@ -258,7 +258,7 @@ static void RoadVehViewWndProc(Window *w, WindowEvent *e) } break; case WE_CLICK: { - Vehicle *v = &_vehicles[w->window_number]; + Vehicle *v = GetVehicle(w->window_number); switch(e->click.widget) { case 5: /* start stop */ @@ -380,7 +380,7 @@ void CcBuildRoadVeh(bool success, uint tile, uint32 p1, uint32 p2) if (!success) return; - v = &_vehicles[_new_roadveh_id]; + v = GetVehicle(_new_roadveh_id); if (v->tile == _backup_orders_tile) { _backup_orders_tile = 0; RestoreVehicleOrders(v, _backup_orders_data); @@ -665,7 +665,7 @@ static void RoadDepotWndProc(Window *w, WindowEvent *e) HandleButtonClick(w, 5); - v = &_vehicles[WP(w,traindepot_d).sel]; + v = GetVehicle(WP(w,traindepot_d).sel); WP(w,traindepot_d).sel = INVALID_VEHICLE; _backup_orders_tile = v->tile; @@ -800,7 +800,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e) w->widget[1].unkA = STR_9001_ROAD_VEHICLES; } else { /* Station Name -- (###) Road vehicles */ - SetDParam(0, DEREF_STATION(station)->index); + SetDParam(0, GetStation(station)->index); SetDParam(1, w->vscroll.count); w->widget[1].unkA = STR_SCHEDULED_ROAD_VEHICLES; } @@ -814,7 +814,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e) max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length); for (i = w->vscroll.pos; i < max; ++i) { - Vehicle *v = DEREF_VEHICLE(vl->sort_list[i].index); + Vehicle *v = GetVehicle(vl->sort_list[i].index); StringID str; assert(v->type == VEH_Road && v->owner == owner); @@ -865,7 +865,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e) if (id_v >= vl->list_length) return; // click out of list bound - v = DEREF_VEHICLE(vl->sort_list[id_v].index); + v = GetVehicle(vl->sort_list[id_v].index); assert(v->type == VEH_Road && v->owner == owner); -- cgit v1.2.3-54-g00ecf