diff options
author | frosch <frosch@openttd.org> | 2012-04-22 16:28:14 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-04-22 16:28:14 +0000 |
commit | 0f0e7e43cf09c0ff82e4119b08956670160aaa58 (patch) | |
tree | 73eac59bde99d2517e2766ada36995fe7952d2d3 /src/newgrf_class_func.h | |
parent | cb434944885d5e5caa857deb3273712c4c223031 (diff) | |
download | openttd-0f0e7e43cf09c0ff82e4119b08956670160aaa58.tar.xz |
(svn r24166) -Codechange: Turn NewGRFClass::Get(Tid, uint) and GetCount(Tid) into non-static members GetSpec(uint) and GetSpecCount().
Diffstat (limited to 'src/newgrf_class_func.h')
-rw-r--r-- | src/newgrf_class_func.h | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/src/newgrf_class_func.h b/src/newgrf_class_func.h index 339e7d7a5..03c82a8d6 100644 --- a/src/newgrf_class_func.h +++ b/src/newgrf_class_func.h @@ -117,31 +117,14 @@ DEFINE_NEWGRF_CLASS_METHOD(uint)::GetCount() } /** - * Get the number of allocated specs within a particular class. - * @param cls_id The class to get the size of. - * @pre cls_id < GetCount() - * @return The size of the class. - */ -DEFINE_NEWGRF_CLASS_METHOD(uint)::GetCount(Tid cls_id) -{ - assert(cls_id < Tmax); - return classes[cls_id].count; -} - -/** - * Get a spec from a particular class at a given index. - * @param cls_id The class to get the spec from. + * Get a spec from the class at a given index. * @param index The index where to find the spec. - * @pre index < GetCount(cls_id) * @return The spec at given location. */ -DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::Get(Tid cls_id, uint index) +DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetSpec(uint index) const { - assert(cls_id < Tmax); - if (index < classes[cls_id].count) return classes[cls_id].spec[index]; - /* If the custom spec isn't defined any more, then the GRF file probably was not loaded. */ - return NULL; + return index < this->GetSpecCount() ? this->spec[index] : NULL; } /** @@ -180,6 +163,5 @@ DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32 grfid, byte local_id, template void name::Assign(Tspec *spec); \ template NewGRFClass<Tspec, Tid, Tmax> *name::Get(Tid cls_id); \ template uint name::GetCount(); \ - template uint name::GetCount(Tid cls_id); \ - template const Tspec *name::Get(Tid cls_id, uint index); \ + template const Tspec *name::GetSpec(uint index) const; \ template const Tspec *name::GetByGrf(uint32 grfid, byte localidx, int *index); |