summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-04-22 16:28:04 +0000
committerfrosch <frosch@openttd.org>2012-04-22 16:28:04 +0000
commit48c44a8d213d65fcd9459fc85e6d7c30427e9d54 (patch)
tree9a822d9ed891a3e370be4ca587fa688473e61edb /src
parentb3c84fcbbd1983676eb0eae2079042580f4c78e6 (diff)
downloadopenttd-48c44a8d213d65fcd9459fc85e6d7c30427e9d54.tar.xz
(svn r24164) -Codechange: Split parts of static NewGRFClass::Reset() into non-static ResetClass().
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_class.h2
-rw-r--r--src/newgrf_class_func.h19
2 files changed, 15 insertions, 6 deletions
diff --git a/src/newgrf_class.h b/src/newgrf_class.h
index a7b8099ad..e1edefae6 100644
--- a/src/newgrf_class.h
+++ b/src/newgrf_class.h
@@ -30,6 +30,8 @@ private:
*/
static NewGRFClass<Tspec, Tid, Tmax> classes[Tmax];
+ void ResetClass();
+
/** Initialise the defaults. */
static void InsertDefaults();
diff --git a/src/newgrf_class_func.h b/src/newgrf_class_func.h
index 0165b518c..0421258ec 100644
--- a/src/newgrf_class_func.h
+++ b/src/newgrf_class_func.h
@@ -25,16 +25,22 @@
template <typename Tspec, typename Tid, Tid Tmax>
NewGRFClass<Tspec, Tid, Tmax> NewGRFClass<Tspec, Tid, Tmax>::classes[Tmax];
+/** Reset the class, i.e. clear everything. */
+DEFINE_NEWGRF_CLASS_METHOD(void)::ResetClass()
+{
+ this->global_id = 0;
+ this->name = STR_EMPTY;
+ this->count = 0;
+
+ free(this->spec);
+ this->spec = NULL;
+}
+
/** Reset the classes, i.e. clear everything. */
DEFINE_NEWGRF_CLASS_METHOD(void)::Reset()
{
for (Tid i = (Tid)0; i < Tmax; i++) {
- classes[i].global_id = 0;
- classes[i].name = STR_EMPTY;
- classes[i].count = 0;
-
- free(classes[i].spec);
- classes[i].spec = NULL;
+ classes[i].ResetClass();
}
InsertDefaults();
@@ -160,6 +166,7 @@ DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32 grfid, byte local_id,
/** Force instantiation of the methods so we don't get linker errors. */
#define INSTANTIATE_NEWGRF_CLASS_METHODS(name, Tspec, Tid, Tmax) \
+ template void name::ResetClass(); \
template void name::Reset(); \
template Tid name::Allocate(uint32 global_id); \
template void name::Assign(Tspec *spec); \