summaryrefslogtreecommitdiff
path: root/src/newgrf_class_func.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-04-22 16:28:09 +0000
committerfrosch <frosch@openttd.org>2012-04-22 16:28:09 +0000
commitcb434944885d5e5caa857deb3273712c4c223031 (patch)
treefdf35b4e6c26e0b53b6b9aad8548dd2753a0b9dd /src/newgrf_class_func.h
parent48c44a8d213d65fcd9459fc85e6d7c30427e9d54 (diff)
downloadopenttd-cb434944885d5e5caa857deb3273712c4c223031.tar.xz
(svn r24165) -Codechange: Split parts of static NewGRFClass::Assign() into non-static Insert().
Diffstat (limited to 'src/newgrf_class_func.h')
-rw-r--r--src/newgrf_class_func.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/newgrf_class_func.h b/src/newgrf_class_func.h
index 0421258ec..339e7d7a5 100644
--- a/src/newgrf_class_func.h
+++ b/src/newgrf_class_func.h
@@ -71,6 +71,18 @@ DEFINE_NEWGRF_CLASS_METHOD(Tid)::Allocate(uint32 global_id)
}
/**
+ * Insert a spec into the class.
+ * @param spec The spec to insert.
+ */
+DEFINE_NEWGRF_CLASS_METHOD(void)::Insert(Tspec *spec)
+{
+ uint i = this->count++;
+ this->spec = ReallocT(this->spec, this->count);
+
+ this->spec[i] = spec;
+}
+
+/**
* Assign a spec to one of the classes.
* @param spec The spec to assign.
* @note The spec must have a valid class id set.
@@ -78,12 +90,7 @@ DEFINE_NEWGRF_CLASS_METHOD(Tid)::Allocate(uint32 global_id)
DEFINE_NEWGRF_CLASS_METHOD(void)::Assign(Tspec *spec)
{
assert(spec->cls_id < Tmax);
- NewGRFClass<Tspec, Tid, Tmax> *cls = &classes[spec->cls_id];
-
- uint i = cls->count++;
- cls->spec = ReallocT(cls->spec, cls->count);
-
- cls->spec[i] = spec;
+ Get(spec->cls_id)->Insert(spec);
}
/**
@@ -169,6 +176,7 @@ DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32 grfid, byte local_id,
template void name::ResetClass(); \
template void name::Reset(); \
template Tid name::Allocate(uint32 global_id); \
+ template void name::Insert(Tspec *spec); \
template void name::Assign(Tspec *spec); \
template NewGRFClass<Tspec, Tid, Tmax> *name::Get(Tid cls_id); \
template uint name::GetCount(); \