summaryrefslogtreecommitdiff
path: root/src/ship_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-10-21 16:45:00 +0000
committerrubidium <rubidium@openttd.org>2007-10-21 16:45:00 +0000
commitb4e7203b0a2c287d1cfbdfe9b59b3eeb09c07d4f (patch)
treecd686f6450772b50dedda10abfb06673a2a35a26 /src/ship_cmd.cpp
parent9a0d2de5cf48b36d027fade715507e5ef7726fd5 (diff)
downloadopenttd-b4e7203b0a2c287d1cfbdfe9b59b3eeb09c07d4f.tar.xz
(svn r11332) -Fix: vehicles getting a value of 0 on construction.
-Fix: assertion when selling vehicles.
Diffstat (limited to 'src/ship_cmd.cpp')
-rw-r--r--src/ship_cmd.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index 8c17ccf20..249a319c5 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -835,6 +835,7 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
const ShipVehicleInfo *svi = ShipVehInfo(p1);
+ v = new (v) Ship();
v->unitnumber = unit_num;
v->owner = _current_player;
@@ -871,7 +872,6 @@ CommandCost CmdBuildShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->date_of_last_service = _date;
v->build_year = _cur_year;
v->cur_image = 0x0E5E;
- v = new (v) Ship();
v->random_bits = VehicleRandomBits();
v->vehicle_flags = 0;
@@ -919,6 +919,8 @@ CommandCost CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
return_cmd_error(STR_980B_SHIP_MUST_BE_STOPPED_IN);
}
+ CommandCost ret(-v->value);
+
if (flags & DC_EXEC) {
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
RebuildVehicleLists();
@@ -928,7 +930,7 @@ CommandCost CmdSellShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
delete v;
}
- return CommandCost(-v->value);
+ return ret;
}
/** Start/Stop a ship.