summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/pool_type.hpp4
-rw-r--r--src/network/network.cpp4
-rw-r--r--src/road_cmd.cpp4
3 files changed, 5 insertions, 7 deletions
diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp
index 0dba9a0b4..035607a8f 100644
--- a/src/core/pool_type.hpp
+++ b/src/core/pool_type.hpp
@@ -155,7 +155,8 @@ struct Pool : PoolBase {
this->ValidateIndex();
};
- bool operator!=(const PoolIterator &other) const { return this->index != other.index; }
+ bool operator==(const PoolIterator &other) const { return this->index == other.index; }
+ bool operator!=(const PoolIterator &other) const { return !(*this == other); }
T * operator*() const { return T::Get(this->index); }
PoolIterator & operator++() { this->index++; this->ValidateIndex(); return *this; }
@@ -176,6 +177,7 @@ struct Pool : PoolBase {
IterateWrapper(size_t from = 0, std::function<bool(size_t)> filter = nullptr) : from(from), filter(filter) {}
PoolIterator<T> begin() { return PoolIterator<T>(this->from, this->filter); }
PoolIterator<T> end() { return PoolIterator<T>(T::GetPoolSize()); }
+ bool empty() { return this->begin() == this->end(); }
};
/**
diff --git a/src/network/network.cpp b/src/network/network.cpp
index a27aa224a..fe7e6a855 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -99,9 +99,7 @@ extern void StateGameLoop();
*/
bool HasClients()
{
- for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) return true;
-
- return false;
+ return !NetworkClientSocket::Iterate().empty();
}
/**
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 8126a06d3..ae328a065 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -182,9 +182,7 @@ RoadType AllocateRoadType(RoadTypeLabel label, RoadTramType rtt)
*/
bool RoadVehiclesAreBuilt()
{
- for (const RoadVehicle *rv : RoadVehicle::Iterate()) return true;
-
- return false;
+ return !RoadVehicle::Iterate().empty();
}
/**