summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-23 22:16:41 +0000
committerrubidium <rubidium@openttd.org>2008-04-23 22:16:41 +0000
commitdce1b331965c660a80996230503149b28221f34c (patch)
tree3c648d4bd6e453e588d664c0eabe3c948a556f7c /src
parent10ab24a5f149955f3af71ba152609a4be676b795 (diff)
downloadopenttd-dce1b331965c660a80996230503149b28221f34c.tar.xz
(svn r12857) -Fix [FS#1948]: remove the last uses of AutoPtr in the station code.
Diffstat (limited to 'src')
-rw-r--r--src/misc/autocopyptr.hpp85
-rw-r--r--src/misc/autoptr.hpp106
-rw-r--r--src/newgrf_station.cpp2
-rw-r--r--src/oldpool.h11
-rw-r--r--src/oldpool_func.h21
-rw-r--r--src/rail_cmd.cpp1
-rw-r--r--src/road_cmd.cpp1
-rw-r--r--src/station_cmd.cpp144
-rw-r--r--src/water_cmd.cpp1
9 files changed, 74 insertions, 298 deletions
diff --git a/src/misc/autocopyptr.hpp b/src/misc/autocopyptr.hpp
deleted file mode 100644
index 0c684aac2..000000000
--- a/src/misc/autocopyptr.hpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/* $Id$ */
-
-/** @file autocopyptr.hpp */
-
-#ifndef AUTOCOPYPTR_HPP
-#define AUTOCOPYPTR_HPP
-
-#if 0 // reenable when needed
-/** CAutoCopyPtrT - kind of CoW (Copy on Write) pointer.
- * It is non-invasive smart pointer (reference counter is held outside
- * of Tdata).
- * When copied, its new copy shares the same underlaying structure Tdata.
- * When dereferenced, its behaviour depends on 2 factors:
- * - whether the data is shared (used by more than one pointer)
- * - type of access (read/write)
- * When shared pointer is dereferenced for write, new clone of Tdata
- * is made first.
- * Can't be used for polymorphic data types (interfaces).
- */
-template <class Tdata_>
-class CAutoCopyPtrT {
-protected:
- typedef Tdata_ Tdata;
-
- struct CItem {
- int m_ref_cnt; ///< reference counter
- Tdata m_data; ///< custom data itself
-
- FORCEINLINE CItem() : m_ref_cnt(1) {};
- FORCEINLINE CItem(const Tdata& data) : m_ref_cnt(1), m_data(data) {};
- FORCEINLINE CItem(const CItem& src) : m_ref_cnt(1), m_data(src.m_data) {};
- };
-
- mutable CItem* m_pI; ///< points to the ref-counted data
-
-public:
- FORCEINLINE CAutoCopyPtrT() : m_pI(NULL) {};
- FORCEINLINE CAutoCopyPtrT(const Tdata& data) : m_pI(new CItem(data)) {};
- FORCEINLINE CAutoCopyPtrT(const CAutoCopyPtrT& src) : m_pI(src.m_pI) {if (m_pI != NULL) m_pI->m_ref_cnt++;}
- FORCEINLINE ~CAutoCopyPtrT() {if (m_pI == NULL || (--m_pI->m_ref_cnt) > 0) return; delete m_pI; m_pI = NULL;}
-
- /** data accessor (read only) */
- FORCEINLINE const Tdata& GetDataRO() const {if (m_pI == NULL) m_pI = new CItem(); return m_pI->m_data;}
- /** data accessor (read / write) */
- FORCEINLINE Tdata& GetDataRW() {CloneIfShared(); if (m_pI == NULL) m_pI = new CItem(); return m_pI->m_data;}
-
- /** clone data if it is shared */
- FORCEINLINE void CloneIfShared()
- {
- if (m_pI != NULL && m_pI->m_ref_cnt > 1) {
- // we share data item with somebody, clone it to become an exclusive owner
- CItem* pNewI = new CItem(*m_pI);
- m_pI->m_ref_cnt--;
- m_pI = pNewI;
- }
- }
-
- /** assign pointer from the other one (maintaining ref counts) */
- FORCEINLINE void Assign(const CAutoCopyPtrT& src)
- {
- if (m_pI == src.m_pI) return;
- if (m_pI != NULL && (--m_pI->m_ref_cnt) <= 0) delete m_pI;
- m_pI = src.m_pI;
- if (m_pI != NULL) m_pI->m_ref_cnt++;
- }
-
- /** dereference operator (read only) */
- FORCEINLINE const Tdata* operator -> () const {return &GetDataRO();}
- /** dereference operator (read / write) */
- FORCEINLINE Tdata* operator -> () {return &GetDataRW();}
-
- /** assignment operator */
- FORCEINLINE CAutoCopyPtrT& operator = (const CAutoCopyPtrT& src) {Assign(src); return *this;}
-
- /** forwarding 'lower then' operator to the underlaying items */
- FORCEINLINE bool operator < (const CAutoCopyPtrT& other) const
- {
- assert(m_pI != NULL);
- assert(other.m_pI != NULL);
- return (m_pI->m_data) < (other.m_pI->m_data);
- }
-};
-
-#endif /* 0 */
-#endif /* AUTOCOPYPTR_HPP */
diff --git a/src/misc/autoptr.hpp b/src/misc/autoptr.hpp
deleted file mode 100644
index 8b0d920f5..000000000
--- a/src/misc/autoptr.hpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/* $Id$ */
-
-/** @file autoptr.hpp */
-
-#ifndef AUTOPTR_HPP
-#define AUTOPTR_HPP
-
-/** AutoPtrT - kind of smart pointer that ensures the owned object gets
- * deleted when its pointer goes out of scope.
- * It is non-invasive smart pointer (no reference counter).
- * When copied, the copy takes ownership of underlying object
- * and original becomes NULL!
- * Can be used also for polymorphic data types (interfaces).
- */
-template <class T>
-class AutoPtrT {
-public:
- typedef T obj_t;
-
-protected:
- mutable T* m_p; ///< points to the data
-
-public:
- FORCEINLINE AutoPtrT()
- : m_p(NULL)
- {};
-
- FORCEINLINE AutoPtrT(const AutoPtrT<T>& src)
- : m_p(src.m_p)
- {
- if (m_p != NULL) src.m_p = NULL;
- };
-
- FORCEINLINE AutoPtrT(T *p)
- : m_p(p)
- {}
-
- FORCEINLINE ~AutoPtrT()
- {
- if (m_p != NULL) {
- T *p = m_p;
- m_p = NULL;
- delete p;
- }
- }
-
- /** give-up ownership and NULLify the raw pointer */
- FORCEINLINE T* Detach()
- {
- T* p = m_p;
- m_p = NULL;
- return p;
- }
-
- /** raw-pointer cast operator (read only) */
- FORCEINLINE operator const T* () const
- {
- return m_p;
- }
-
- /** raw-pointer cast operator */
- FORCEINLINE operator T* ()
- {
- return m_p;
- }
-
- /** dereference operator (read only) */
- FORCEINLINE const T* operator -> () const
- {
- assert(m_p != NULL);
- return m_p;
- }
-
- /** dereference operator (read / write) */
- FORCEINLINE T* operator -> ()
- {
- assert(m_p != NULL);
- return m_p;
- }
-
- /** assignment operator */
- FORCEINLINE AutoPtrT& operator = (const AutoPtrT& src)
- {
- /* Save original pointer and replace it with the given one to avoid recursive calls. */
- T* p = m_p;
- m_p = src.m_p;
-
- if (m_p != NULL) src.m_p = NULL;
-
- if (p != NULL) {
- /* Now we can safely delete the old one. */
- delete p;
- }
- return *this;
- }
-
- /** forwarding 'lower than' operator to the underlaying items */
- FORCEINLINE bool operator < (const AutoPtrT& other) const
- {
- assert(m_p != NULL);
- assert(other.m_p != NULL);
- return (*m_p) < (*other.m_p);
- }
-};
-
-#endif /* AUTOPTR_HPP */
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index edb49515f..4f57699ab 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -676,7 +676,7 @@ int AllocateSpecToStation(const StationSpec *statspec, Station *st, bool exec)
{
uint i;
- if (statspec == NULL) return 0;
+ if (statspec == NULL || st == NULL) return 0;
/* Check if this spec has already been allocated */
for (i = 1; i < st->num_specs && i < MAX_SPECLIST; i++) {
diff --git a/src/oldpool.h b/src/oldpool.h
index e8081fa82..1581cfc98 100644
--- a/src/oldpool.h
+++ b/src/oldpool.h
@@ -294,16 +294,7 @@ protected:
}
public:
- /**
- * Check whether we can allocate an item in this pool. This to prevent the
- * need to actually construct the object and then destructing it again,
- * which could be *very* costly.
- * @return true if and only if at least ONE item can be allocated.
- */
- static inline bool CanAllocateItem()
- {
- return AllocateRaw() != NULL;
- }
+ static bool CanAllocateItem();
};
diff --git a/src/oldpool_func.h b/src/oldpool_func.h
index e4d1c47d5..2c9801354 100644
--- a/src/oldpool_func.h
+++ b/src/oldpool_func.h
@@ -31,4 +31,25 @@ template<typename T, typename Tid, OldMemoryPool<T> *Tpool> T *PoolItem<T, Tid,
return NULL;
}
+/**
+ * Check whether we can allocate an item in this pool. This to prevent the
+ * need to actually construct the object and then destructing it again,
+ * which could be *very* costly.
+ * @return true if and only if at least ONE item can be allocated.
+ */
+template<typename T, typename Tid, OldMemoryPool<T> *Tpool> bool PoolItem<T, Tid, Tpool>::CanAllocateItem()
+{
+ uint last_minus_one = Tpool->GetSize() - 1;
+
+ for (T *t = Tpool->Get(Tpool->first_free_index); t != NULL; t = (t->index < last_minus_one) ? Tpool->Get(t->index + 1U) : NULL) {
+ if (!t->IsValid()) return true;
+ Tpool->first_free_index = t->index;
+ }
+
+ /* Check if we can add a block to the pool */
+ if (Tpool->AddBlockToPool()) return CanAllocateItem();
+
+ return false;
+}
+
#endif /* OLDPOOL_FUNC_H */
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index c08014d12..4bdc8dd09 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -43,6 +43,7 @@
#include "station_map.h"
#include "water_map.h"
#include "functions.h"
+#include "oldpool_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index c95506a72..7c610bcd6 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -37,6 +37,7 @@
#include "cheat_func.h"
#include "functions.h"
#include "effectvehicle_func.h"
+#include "oldpool_func.h"
#include "table/sprites.h"
#include "table/strings.h"
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index f615ac0a9..a57e0a1e5 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -25,7 +25,6 @@
#include "newgrf_callbacks.h"
#include "newgrf_station.h"
#include "yapf/yapf.h"
-#include "misc/autoptr.hpp"
#include "road_type.h"
#include "road_internal.h" /* For drawing catenary/checking road removal */
#include "cargotype.h"
@@ -239,7 +238,7 @@ enum StationNaming {
STATIONNAMING_HELIPORT,
};
-static bool GenerateStationName(Station *st, TileIndex tile, int flag)
+static void GenerateStationName(Station *st, TileIndex tile, int flag)
{
static const uint32 _gen_station_name_bits[] = {
0, /* 0 */
@@ -344,7 +343,6 @@ static bool GenerateStationName(Station *st, TileIndex tile, int flag)
done:
st->string_id = found + STR_SV_STNAME;
- return true;
}
#undef M
@@ -962,10 +960,6 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1,
/* See if there is a deleted station close to us. */
if (st == NULL) st = GetClosestStationFromTile(tile_org);
- /* In case of new station if DC_EXEC is NOT set we still need to create the station
- * to test if everything is OK. In this case we need to delete it before return. */
- AutoPtrT<Station> st_auto_delete;
-
if (st != NULL) {
/* Reuse an existing station. */
if (st->owner != _current_player)
@@ -983,17 +977,17 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1,
if (!st->rect.BeforeAddRect(tile_org, w_org, h_org, StationRect::ADD_TEST)) return CMD_ERROR;
} else {
/* allocate and initialize new station */
- st = new Station(tile_org);
- if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
+ if (!Station::CanAllocateItem()) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
- /* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */
- st_auto_delete = st;
+ if (flags & DC_EXEC) {
+ st = new Station();
- st->town = ClosestTownFromTile(tile_org, (uint)-1);
- if (!GenerateStationName(st, tile_org, STATIONNAMING_RAIL)) return CMD_ERROR;
+ st->town = ClosestTownFromTile(tile_org, (uint)-1);
+ GenerateStationName(st, tile_org, STATIONNAMING_RAIL);
- if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) {
- SetBit(st->town->have_ratings, _current_player);
+ if (IsValidPlayer(_current_player)) {
+ SetBit(st->town->have_ratings, _current_player);
+ }
}
}
@@ -1088,8 +1082,6 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1,
RebuildStationLists();
InvalidateWindow(WC_STATION_LIST, st->owner);
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS);
- /* success, so don't delete the new station */
- st_auto_delete.Detach();
}
return cost;
@@ -1394,23 +1386,13 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (st == NULL) st = GetClosestStationFromTile(tile);
/* give us a road stop in the list, and check if something went wrong */
- RoadStop *road_stop = new RoadStop(tile);
- if (road_stop == NULL) {
- return_cmd_error(type ? STR_TOO_MANY_TRUCK_STOPS : STR_TOO_MANY_BUS_STOPS);
- }
-
- /* ensure that in case of error (or no DC_EXEC) the new road stop gets deleted upon return */
- AutoPtrT<RoadStop> rs_auto_delete(road_stop);
+ if (!RoadStop::CanAllocateItem()) return_cmd_error(type ? STR_TOO_MANY_TRUCK_STOPS : STR_TOO_MANY_BUS_STOPS);
if (st != NULL &&
GetNumRoadStopsInStation(st, ROADSTOP_BUS) + GetNumRoadStopsInStation(st, ROADSTOP_TRUCK) >= RoadStop::LIMIT) {
return_cmd_error(type ? STR_TOO_MANY_TRUCK_STOPS : STR_TOO_MANY_BUS_STOPS);
}
- /* In case of new station if DC_EXEC is NOT set we still need to create the station
- * to test if everything is OK. In this case we need to delete it before return. */
- AutoPtrT<Station> st_auto_delete;
-
if (st != NULL) {
if (st->owner != _current_player) {
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
@@ -1419,26 +1401,25 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (!st->rect.BeforeAddTile(tile, StationRect::ADD_TEST)) return CMD_ERROR;
} else {
/* allocate and initialize new station */
- st = new Station(tile);
- if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
-
- /* ensure that in case of error (or no DC_EXEC) the new station gets deleted upon return */
- st_auto_delete = st;
+ if (!Station::CanAllocateItem()) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
+ if (flags & DC_EXEC) {
+ st = new Station();
- Town *t = st->town = ClosestTownFromTile(tile, (uint)-1);
- if (!GenerateStationName(st, tile, STATIONNAMING_ROAD)) return CMD_ERROR;
+ st->town = ClosestTownFromTile(tile, (uint)-1);
+ GenerateStationName(st, tile, STATIONNAMING_ROAD);
- if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) {
- SetBit(t->have_ratings, _current_player);
+ if (IsValidPlayer(_current_player)) {
+ SetBit(st->town->have_ratings, _current_player);
+ }
+ st->sign.width_1 = 0;
}
-
- st->sign.width_1 = 0;
}
cost.AddCost((type) ? _price.build_truck_station : _price.build_bus_station);
if (flags & DC_EXEC) {
+ RoadStop *road_stop = new RoadStop(tile);
/* Insert into linked list of RoadStops */
RoadStop **currstop = FindRoadStopSpot(type, st);
*currstop = road_stop;
@@ -1460,9 +1441,6 @@ CommandCost CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
RebuildStationLists();
InvalidateWindow(WC_STATION_LIST, st->owner);
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_ROADVEHS);
- /* success, so don't delete the new station and the new road stop */
- st_auto_delete.Detach();
- rs_auto_delete.Detach();
}
return cost;
}
@@ -1717,10 +1695,6 @@ CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
return CMD_ERROR;
}
- /* In case of new station if DC_EXEC is NOT set we still need to create the station
- * to test if everything is OK. In this case we need to delete it before return. */
- AutoPtrT<Station> st_auto_delete;
-
if (st != NULL) {
if (st->owner != _current_player) {
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
@@ -1735,24 +1709,18 @@ CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
airport_upgrade = false;
/* allocate and initialize new station */
- st = new Station(tile);
- if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
+ if (!Station::CanAllocateItem()) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
- /* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */
- st_auto_delete = st;
-
- st->town = t;
-
- if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) {
- SetBit(t->have_ratings, _current_player);
- }
+ if (flags & DC_EXEC) {
+ st = new Station();
- st->sign.width_1 = 0;
+ st->town = ClosestTownFromTile(tile, (uint)-1);
+ GenerateStationName(st, tile, !(afc->flags & AirportFTAClass::AIRPLANES) ? STATIONNAMING_HELIPORT : STATIONNAMING_AIRPORT);
- /* If only helicopters may use the airport generate a helicopter related (5)
- * station name, otherwise generate a normal airport name (1) */
- if (!GenerateStationName(st, tile, !(afc->flags & AirportFTAClass::AIRPLANES) ? STATIONNAMING_HELIPORT : STATIONNAMING_AIRPORT)) {
- return CMD_ERROR;
+ if (IsValidPlayer(_current_player)) {
+ SetBit(st->town->have_ratings, _current_player);
+ }
+ st->sign.width_1 = 0;
}
}
@@ -1789,8 +1757,6 @@ CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
RebuildStationLists();
InvalidateWindow(WC_STATION_LIST, st->owner);
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_PLANES);
- /* success, so don't delete the new station */
- st_auto_delete.Detach();
}
return cost;
@@ -1860,18 +1826,18 @@ CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (GetTileSlope(tile, NULL) != SLOPE_FLAT) return_cmd_error(STR_304B_SITE_UNSUITABLE);
/* allocate and initialize new station */
- Station *st = new Station(tile);
- if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
-
- /* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */
- AutoPtrT<Station> st_auto_delete(st);
+ if (!Station::CanAllocateItem()) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
- st->town = ClosestTownFromTile(tile, (uint)-1);
- st->sign.width_1 = 0;
+ if (flags & DC_EXEC) {
+ Station *st = new Station();
- if (!GenerateStationName(st, tile, STATIONNAMING_BUOY)) return CMD_ERROR;
+ st->town = ClosestTownFromTile(tile, (uint)-1);
+ GenerateStationName(st, tile, STATIONNAMING_BUOY);
- if (flags & DC_EXEC) {
+ if (IsValidPlayer(_current_player)) {
+ SetBit(st->town->have_ratings, _current_player);
+ }
+ st->sign.width_1 = 0;
st->dock_tile = tile;
st->facilities |= FACIL_DOCK;
/* Buoys are marked in the Station struct by this flag. Yes, it is this
@@ -1888,8 +1854,6 @@ CommandCost CmdBuildBuoy(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
RebuildStationLists();
InvalidateWindow(WC_STATION_LIST, st->owner);
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
- /* success, so don't delete the new station */
- st_auto_delete.Detach();
}
return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock);
@@ -2011,10 +1975,6 @@ CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/* Find a station close to us */
if (st == NULL) st = GetClosestStationFromTile(tile);
- /* In case of new station if DC_EXEC is NOT set we still need to create the station
- * to test if everything is OK. In this case we need to delete it before return. */
- AutoPtrT<Station> st_auto_delete;
-
if (st != NULL) {
if (st->owner != _current_player) {
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
@@ -2025,21 +1985,19 @@ CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (st->dock_tile != 0) return_cmd_error(STR_304C_TOO_CLOSE_TO_ANOTHER_DOCK);
} else {
/* allocate and initialize new station */
- st = new Station(tile);
- if (st == NULL) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
+ /* allocate and initialize new station */
+ if (!Station::CanAllocateItem()) return_cmd_error(STR_3008_TOO_MANY_STATIONS_LOADING);
- /* ensure that in case of error (or no DC_EXEC) the station gets deleted upon return */
- st_auto_delete = st;
+ if (flags & DC_EXEC) {
+ st = new Station();
- Town *t = st->town = ClosestTownFromTile(tile, (uint)-1);
+ st->town = ClosestTownFromTile(tile, (uint)-1);
+ GenerateStationName(st, tile, STATIONNAMING_DOCK);
- if (IsValidPlayer(_current_player) && (flags & DC_EXEC) != 0) {
- SetBit(t->have_ratings, _current_player);
+ if (IsValidPlayer(_current_player)) {
+ SetBit(st->town->have_ratings, _current_player);
+ }
}
-
- st->sign.width_1 = 0;
-
- if (!GenerateStationName(st, tile, STATIONNAMING_DOCK)) return CMD_ERROR;
}
if (flags & DC_EXEC) {
@@ -2055,8 +2013,6 @@ CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
RebuildStationLists();
InvalidateWindow(WC_STATION_LIST, st->owner);
InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS);
- /* success, so don't delete the new station */
- st_auto_delete.Detach();
}
return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock);
@@ -2877,11 +2833,7 @@ void BuildOilRig(TileIndex tile)
st->town = ClosestTownFromTile(tile, (uint)-1);
st->sign.width_1 = 0;
- if (!GenerateStationName(st, tile, STATIONNAMING_OILRIG)) {
- DEBUG(misc, 0, "Can't allocate station-name for oilrig at 0x%X, reverting to oilrig only", tile);
- delete st;
- return;
- }
+ GenerateStationName(st, tile, STATIONNAMING_OILRIG);
MakeOilrig(tile, st->index);
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index 6412a82b2..912b7c99b 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -39,6 +39,7 @@
#include "airport.h"
#include "newgrf_cargo.h"
#include "effectvehicle_func.h"
+#include "oldpool_func.h"
#include "table/sprites.h"
#include "table/strings.h"