summaryrefslogtreecommitdiff
path: root/src/oldpool.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-10-14 12:07:14 +0000
committerrubidium <rubidium@openttd.org>2008-10-14 12:07:14 +0000
commit6e397dd3f0b4999c65f0ad5d35fa9007bc6bc9d8 (patch)
treed4d5851792beaab1e19c2a4398a024d44769acf1 /src/oldpool.h
parentdc3ce6bbe721426e3f25323812e89501b845840c (diff)
downloadopenttd-6e397dd3f0b4999c65f0ad5d35fa9007bc6bc9d8.tar.xz
(svn r14463) -Fix [FS#2348]: small possible chance of desync due to sorting on pointer instead of by (station) index (PhilSophus)
Diffstat (limited to 'src/oldpool.h')
-rw-r--r--src/oldpool.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/oldpool.h b/src/oldpool.h
index d66a3a576..457e5327d 100644
--- a/src/oldpool.h
+++ b/src/oldpool.h
@@ -155,6 +155,23 @@ static void PoolCleanBlock(uint start_item, uint end_item)
}
}
+/**
+ * Template providing a predicate to allow STL containers of
+ * pointers to pool items to be sorted by index.
+ */
+template <typename T>
+struct PoolItemIndexLess {
+ /**
+ * The actual comparator.
+ * @param lhs the left hand side of the comparison.
+ * @param rhs the right hand side of the comparison.
+ * @return true if lhs' index is less than rhs' index.
+ */
+ bool operator()(const T *lhs, const T *rhs) const
+ {
+ return lhs->index < rhs->index;
+ }
+};
/**
* Generalization for all pool items that are saved in the savegame.