summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-19 12:29:09 +0000
committerrubidium <rubidium@openttd.org>2007-05-19 12:29:09 +0000
commit4570a8954aab060a13838b9a932e4c92ea87057d (patch)
treefe7f35a2a523a229003b1ff4d2b5ffd100d5d743 /src
parenta58bd26b746d76e06144130c86cf367afdb3e30b (diff)
downloadopenttd-4570a8954aab060a13838b9a932e4c92ea87057d.tar.xz
(svn r9878) -Fix (9874): some vehicle count's were not properly updated on delete or autoreplace of vehicles.
Diffstat (limited to 'src')
-rw-r--r--src/autoreplace_cmd.cpp3
-rw-r--r--src/vehicle.cpp3
2 files changed, 3 insertions, 3 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 2774f2234..e62dbccda 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -175,7 +175,6 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags, int32 total_cost)
new_v = GetVehicle(_new_vehicle_id);
*w = new_v; //we changed the vehicle, so MaybeReplaceVehicle needs to work on the new one. Now we tell it what the new one is
- new_v->group_id = old_v->group_id;
/* refit if needed */
if (replacement_cargo_type != CT_NO_REFIT) {
if (CmdFailed(DoCommand(0, new_v->index, replacement_cargo_type, DC_EXEC, GetCmdRefitVeh(new_v)))) {
@@ -205,7 +204,7 @@ static int32 ReplaceVehicle(Vehicle **w, byte flags, int32 total_cost)
new_v->profit_this_year = old_v->profit_this_year;
new_v->profit_last_year = old_v->profit_last_year;
new_v->service_interval = old_v->service_interval;
- new_v->group_id = old_v->group_id;
+ DoCommand(0, old_v->group_id, new_v->index, flags, CMD_ADD_VEHICLE_GROUP);
new_front = true;
new_v->unitnumber = old_v->unitnumber; // use the same unit number
new_v->dest_tile = old_v->dest_tile;
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index c102108ae..8ff8d1de8 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -584,7 +584,8 @@ void DestroyVehicle(Vehicle *v)
GetPlayer(v->owner)->num_engines[v->engine_type]--;
if (v->owner == _local_player) InvalidateAutoreplaceWindow(v->engine_type);
- if (!IsDefaultGroupID(v->group_id) && IsValidGroupID(v->group_id)) GetGroup(v->group_id)->num_engines[v->engine_type]--;
+ if (IsValidGroupID(v->group_id)) GetGroup(v->group_id)->num_engines[v->engine_type]--;
+ DecreaseGroupNumVehicle(v->group_id);
}
DeleteVehicleNews(v->index, INVALID_STRING_ID);