diff options
author | truelight <truelight@openttd.org> | 2005-01-15 19:06:22 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2005-01-15 19:06:22 +0000 |
commit | 7cafdf3b0bc441586929be57ace0e9510f454381 (patch) | |
tree | 86e7a6e69dee1414ae1e88cfceffd93f1b28ded2 /oldloader.c | |
parent | 0e651d9702ff028b75ad5834b614a25b4f119257 (diff) | |
download | openttd-7cafdf3b0bc441586929be57ace0e9510f454381.tar.xz |
(svn r1525) -Codechange: rewrote the _order_array, now it can be made dynamic.
-Codechange: renamed all 'schedule' stuff to 'order(list)'
-Codechange: moved all order-stuff to order_cmd.c / order.h
-Codechange: vehicles that share orders are now linked to eachother
with next_shared/prev_shared in Vehicle
Developers: please use AssignOrder to assign data to an order. If not,
you _WILL_ make the save-routine to assert!
Diffstat (limited to 'oldloader.c')
-rw-r--r-- | oldloader.c | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/oldloader.c b/oldloader.c index cdeafa622..16c08d744 100644 --- a/oldloader.c +++ b/oldloader.c @@ -752,6 +752,22 @@ static void FixDepot(Depot *n, OldDepot *o, int num) } while (n++,o++,--num); } +static void FixOrder(uint16 *o, int num) +{ + Order *order; + int i; + + for (i = 0; i < num; ++i) { + order = GetOrder(i); + AssignOrder(order, UnpackOldOrder(*o)); + /* Recover the next list */ + if (i > 0 && order->type != OT_NOTHING) + GetOrder(i - 1)->next = order; + + o++; + } +} + static void FixVehicle(OldVehicle *o, int num) { Vehicle *n; @@ -767,10 +783,9 @@ static void FixVehicle(OldVehicle *o, int num) n->subtype = o->subtype; if (o->schedule_ptr == 0xFFFFFFFF || o->schedule_ptr == 0) { - n->schedule_ptr = NULL; + n->orders = NULL; } else { - n->schedule_ptr = _order_array + REMAP_ORDER_IDX(o->schedule_ptr); - assert(n->schedule_ptr >= _order_array && n->schedule_ptr < _ptr_to_next_order); + n->orders = GetOrder(REMAP_ORDER_IDX(o->schedule_ptr)); } n->current_order.type = o->next_order & 0x0f; @@ -870,6 +885,31 @@ static void FixVehicle(OldVehicle *o, int num) break; } } while (i++,o++,--num); + + /* Check for shared orders, and link them correctly */ + { + Vehicle *v; + + FOR_ALL_VEHICLES(v) { + Vehicle *u; + + if (v->type == 0) + continue; + + FOR_ALL_VEHICLES_FROM(u, v->index + 1) { + if (u->type == 0) + continue; + + /* If a vehicle has the same orders, add the link to eachother + in both vehicles */ + if (v->orders == u->orders) { + v->next_shared = u; + u->prev_shared = v; + break; + } + } + } + } } static void FixSubsidy(Subsidy *n, OldSubsidy *o, int num) @@ -1447,15 +1487,12 @@ bool LoadOldSaveGame(const char *file) } } - for (i = 0; i < lengthof(m->order_list); ++i) - _order_array[i] = UnpackOldOrder(m->order_list[i]); - _ptr_to_next_order = _order_array + REMAP_ORDER_IDX(m->ptr_to_next_order); - FixTown(m->town_list, lengthof(m->town_list), m->town_name_type); FixIndustry(m->industries, lengthof(m->industries)); FixStation(m->stations, lengthof(m->stations)); FixDepot(_depots, m->depots, lengthof(m->depots)); + FixOrder(m->order_list, lengthof(m->order_list)); FixVehicle(m->vehicles, lengthof(m->vehicles)); FixSubsidy(_subsidies, m->subsidies, lengthof(m->subsidies)); |