diff --git a/projects/openttd_vs80.vcproj b/projects/openttd_vs80.vcproj
index 14e40af4b4..98684df069 100644
--- a/projects/openttd_vs80.vcproj
+++ b/projects/openttd_vs80.vcproj
@@ -1707,6 +1707,10 @@
RelativePath=".\..\src\core\random_func.hpp"
>
+
+
diff --git a/projects/openttd_vs90.vcproj b/projects/openttd_vs90.vcproj
index af6498bd15..b4b2e13ba9 100644
--- a/projects/openttd_vs90.vcproj
+++ b/projects/openttd_vs90.vcproj
@@ -1704,6 +1704,10 @@
RelativePath=".\..\src\core\random_func.hpp"
>
+
+
diff --git a/source.list b/source.list
index fa0ba0c56a..8bb08a039c 100644
--- a/source.list
+++ b/source.list
@@ -374,6 +374,7 @@ core/mem_func.hpp
core/overflowsafe_type.hpp
core/random_func.cpp
core/random_func.hpp
+core/smallmap_type.hpp
core/smallvec_type.hpp
core/sort_func.hpp
diff --git a/src/core/smallmap_type.hpp b/src/core/smallmap_type.hpp
new file mode 100644
index 0000000000..681cacdff6
--- /dev/null
+++ b/src/core/smallmap_type.hpp
@@ -0,0 +1,101 @@
+/* $Id$ */
+
+/** @file smallmap_type.hpp Simple mapping class targeted for small sets of data. Stored data shall be POD ("Plain Old Data")! */
+
+#ifndef SMALLMAP_TYPE_HPP
+#define SMALLMAP_TYPE_HPP
+
+#include "smallvec_type.hpp"
+
+/** Simple pair of data. Both types have to be POD ("Plain Old Data")! */
+template
+struct SmallPair {
+ T first;
+ U second;
+
+ /** Initializes this Pair with data */
+ FORCEINLINE SmallPair(const T &first, const U &second) : first(first), second(second) { }
+};
+
+/** Implementation of simple mapping class. Both types have to be POD ("Plain Old Data")!
+ * It has inherited accessors from SmallVector().
+ * @see SmallVector
+ */
+template
+struct SmallMap : SmallVector, S> {
+ typedef ::SmallPair Pair;
+ typedef Pair *iterator;
+
+ /** Creates new SmallMap. Data are initialized in SmallVector constructor */
+ FORCEINLINE SmallMap() { }
+ /** Data are freed in SmallVector destructor */
+ FORCEINLINE ~SmallMap() { }
+
+ /** Finds given key in this map
+ * @param key key to find
+ * @return &Pair(key, data) if found, this->End() if not
+ */
+ FORCEINLINE Pair *Find(const T &key)
+ {
+ for (uint i = 0; i < this->items; i++) {
+ if (key == this->data[i].first) return &this->data[i];
+ }
+ return this->End();
+ }
+
+ /** Removes given pair from this map
+ * @param pair pair to remove
+ * @return true iff key was found
+ * @note it has to be pointer to pair in this map. It is overwritten by the last item.
+ */
+ FORCEINLINE void Erase(Pair *pair)
+ {
+ assert(pair >= this->Begin() && pair < this->End());
+ *pair = this->data[--this->items];
+ }
+
+ /** Removes given key from this map
+ * @param key key to remove
+ * @return true iff key was found
+ * @note last item is moved to its place, so don't increase your iterator if true is returned!
+ */
+ FORCEINLINE bool Erase(const T &key)
+ {
+ for (uint i = 0; i < this->items; i++) {
+ if (key == this->data[i].first) {
+ this->data[i] = this->data[--this->items];
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /** Adds new item to this map.
+ * @param key key
+ * @param data data
+ * @return true iff the kay wasn't already present
+ */
+ FORCEINLINE bool Insert(const T &key, const U &data)
+ {
+ if (this->Find(key) != this->End()) return false;
+ new (this->Append()) Pair(key, data);
+ return true;
+ }
+
+ /** Returns data belonging to this key
+ * @param key key
+ * @return data belonging to this key
+ * @note if this key wasn't present, new entry is created
+ */
+ FORCEINLINE U &operator[](const T &key)
+ {
+ for (uint i = 0; i < this->items; i++) {
+ if (key == this->data[i].first) return this->data[i].second;
+ }
+ Pair *n = this->Append();
+ n->first = key;
+ return n->second;
+ }
+};
+
+#endif /* SMALLMAP_TYPE_HPP */
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 1f07ab6631..3b950dc8ad 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -28,8 +28,7 @@
#include "rail.h"
#include "settings_type.h"
#include "aircraft.h"
-#include "core/smallvec_type.hpp"
-#include