From 13f0b6c0cf754184cfef8645e709f10240da5f98 Mon Sep 17 00:00:00 2001 From: tron Date: Wed, 17 Nov 2004 08:52:47 +0000 Subject: (svn r654) Hopefully complete support for randomized variational spritegroups (i.e. the cars transporter in DBSetXL gets different cars each time) (pasky) --- economy.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'economy.c') diff --git a/economy.c b/economy.c index b8f5e50de..86b7082dc 100644 --- a/economy.c +++ b/economy.c @@ -13,6 +13,7 @@ #include "town.h" #include "network.h" #include "sound.h" +#include "engine.h" void UpdatePlayerHouse(Player *p, uint score) { @@ -1210,6 +1211,7 @@ int LoadUnloadVehicle(Vehicle *v) int t; uint count, cap; byte old_player; + bool completely_empty = true; assert((v->next_order&0x1F) == OT_LOADING); @@ -1253,6 +1255,9 @@ int LoadUnloadVehicle(Vehicle *v) result |= 2; v->cargo_count = 0; } + + if (v->cargo_count != 0) + completely_empty = false; } /* don't pick up goods that we unloaded */ @@ -1272,6 +1277,18 @@ int LoadUnloadVehicle(Vehicle *v) // has capacity for it, load it on the vehicle. if ((count=ge->waiting_acceptance & 0xFFF) != 0 && (cap = v->cargo_cap - v->cargo_count) != 0) { + if (v->cargo_count == 0) + TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO); + + /* TODO: Regarding this, when we do gradual loading, we + * should first unload all vehicles and then start + * loading them. Since this will cause + * VEHICLE_TRIGGER_EMPTY to be called at the time when + * the whole vehicle chain is really totally empty, the + * @completely_empty assignment can then be safely + * removed; that's how TTDPatch behaves too. --pasky */ + completely_empty = false; + if (cap > count) cap = count; v->cargo_count += cap; ge->waiting_acceptance -= cap; @@ -1304,6 +1321,10 @@ next_vehicle:; v->load_unload_time_rem = unloading_time; + if (completely_empty) { + TriggerVehicle(v, VEHICLE_TRIGGER_EMPTY); + } + if (result != 0) { InvalidateWindow(WC_VEHICLE_DETAILS, v->index); -- cgit v1.2.3-54-g00ecf