diff options
author | rubidium <rubidium@openttd.org> | 2007-10-21 16:45:00 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-10-21 16:45:00 +0000 |
commit | 4bb210614bd00b7a422fa4faec7974da6375a82c (patch) | |
tree | cd686f6450772b50dedda10abfb06673a2a35a26 | |
parent | af9521ff141848685c80e6d535b25965cb7bfb0f (diff) | |
download | openttd-4bb210614bd00b7a422fa4faec7974da6375a82c.tar.xz |
(svn r11332) -Fix: vehicles getting a value of 0 on construction.
-Fix: assertion when selling vehicles.
-rw-r--r-- | src/aircraft_cmd.cpp | 6 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 2 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 6 | ||||
-rw-r--r-- | src/train_cmd.cpp | 2 |
4 files changed, 10 insertions, 6 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index a879554ed..fa33bb2c0 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -299,9 +299,9 @@ CommandCost CmdBuildAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) Vehicle *v = vl[0]; // aircraft Vehicle *u = vl[1]; // shadow - v->unitnumber = unit_num; v = new (v) Aircraft(); u = new (u) Aircraft(); + v->unitnumber = unit_num; v->direction = DIR_SE; v->owner = u->owner = _current_player; @@ -491,13 +491,15 @@ CommandCost CmdSellAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); + CommandCost ret(-v->value); + if (flags & DC_EXEC) { // Invalidate depot InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); DoDeleteAircraft(v); } - return CommandCost(-v->value); + return ret; } /** Start/Stop an aircraft. diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index f24a990e6..edb2c222a 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -202,6 +202,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) const RoadVehicleInfo *rvi = RoadVehInfo(p1); + v = new (v) RoadVehicle(); v->unitnumber = unit_num; v->direction = DiagDirToDir(GetRoadDepotDirection(tile)); v->owner = _current_player; @@ -247,7 +248,6 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) v->date_of_last_service = _date; v->build_year = _cur_year; - v = new (v) RoadVehicle(); v->cur_image = 0xC15; v->random_bits = VehicleRandomBits(); SetRoadVehFront(v); 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. diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 5f9a253cf..fd6aee27b 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -540,6 +540,7 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 fla } } + v = new (v) Train(); v->engine_type = engine; DiagDirection dir = GetRailDepotDirection(tile); @@ -557,7 +558,6 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 fla v->u.rail.track = TRACK_BIT_DEPOT; v->vehstatus = VS_HIDDEN | VS_DEFPAL; - v = new (v) Train(); v->subtype = 0; SetTrainWagon(v); |