summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-18 18:21:23 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commite3c75a30bac6837c0a525aa58d2b966eb232650f (patch)
treebab4c09231cfa51544f10b9c0f22f4899993fc86
parentae532008ff3bc4195989e5c0ab2a9733473360ac (diff)
downloadopenttd-e3c75a30bac6837c0a525aa58d2b966eb232650f.tar.xz
Fix: unused variable warnings
-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();
}
/**