diff options
author | frosch <frosch@openttd.org> | 2012-04-22 16:28:27 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2012-04-22 16:28:27 +0000 |
commit | 34969178db5433cbe8e198d420976c899e72ae2a (patch) | |
tree | bbc47721773f360007e03639a9ebc8e8042d2e19 /src/newgrf_class_func.h | |
parent | 6d9a0ff72396fc99151878e551fd0756ef71ce64 (diff) | |
download | openttd-34969178db5433cbe8e198d420976c899e72ae2a.tar.xz |
(svn r24169) -Add: Make NewGRFClass distinguish between defined specs and specs visible for the user.
Diffstat (limited to 'src/newgrf_class_func.h')
-rw-r--r-- | src/newgrf_class_func.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/newgrf_class_func.h b/src/newgrf_class_func.h index 9bcb6b3c9..b5af35fdb 100644 --- a/src/newgrf_class_func.h +++ b/src/newgrf_class_func.h @@ -31,6 +31,7 @@ DEFINE_NEWGRF_CLASS_METHOD(void)::ResetClass() this->global_id = 0; this->name = STR_EMPTY; this->count = 0; + this->ui_count = 0; free(this->spec); this->spec = NULL; @@ -80,6 +81,8 @@ DEFINE_NEWGRF_CLASS_METHOD(void)::Insert(Tspec *spec) this->spec = ReallocT(this->spec, this->count); this->spec[i] = spec; + + if (this->IsUIAvailable(i)) this->ui_count++; } /** @@ -117,6 +120,19 @@ DEFINE_NEWGRF_CLASS_METHOD(uint)::GetClassCount() } /** + * Get the number of classes available to the user. + * @return The number of classes. + */ +DEFINE_NEWGRF_CLASS_METHOD(uint)::GetUIClassCount() +{ + uint cnt = 0; + for (uint i = 0; i < Tmax && classes[i].global_id != 0; i++) { + if (classes[i].GetUISpecCount() > 0) cnt++; + } + return cnt; +} + +/** * Get a spec from the class at a given index. * @param index The index where to find the spec. * @return The spec at given location. @@ -163,5 +179,6 @@ 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::GetClassCount(); \ + template uint name::GetUIClassCount(); \ template const Tspec *name::GetSpec(uint index) const; \ template const Tspec *name::GetByGrf(uint32 grfid, byte localidx, int *index); |