From 73d926c8d4b7cb327cb1d3484dbecd8303268172 Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 22 Apr 2012 16:27:49 +0000 Subject: (svn r24161) -Add: Method to get a specific NewGRFClass. --- src/newgrf_class.h | 1 + src/newgrf_class_func.h | 13 +++++++++++++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/newgrf_class.h b/src/newgrf_class.h index efbff9746..81ea4f879 100644 --- a/src/newgrf_class.h +++ b/src/newgrf_class.h @@ -34,6 +34,7 @@ struct NewGRFClass { static Tid Allocate(uint32 global_id); static void SetName(Tid cls_id, StringID name); static void Assign(Tspec *spec); + static NewGRFClass *Get(Tid cls_id); static StringID GetName(Tid cls_id); static uint GetCount(); diff --git a/src/newgrf_class_func.h b/src/newgrf_class_func.h index c4e9f7963..15cacd4e2 100644 --- a/src/newgrf_class_func.h +++ b/src/newgrf_class_func.h @@ -92,6 +92,18 @@ DEFINE_NEWGRF_CLASS_METHOD(void)::Assign(Tspec *spec) cls->spec[i] = spec; } +/** + * Get a particular class. + * @param cls_id The id for the class. + * @pre cls_id < Tmax + */ +template +NewGRFClass *NewGRFClass::Get(Tid cls_id) +{ + assert(cls_id < Tmax); + return classes + cls_id; +} + /** * Get the name of a particular class. * @param cls_id The class to get the name of. @@ -176,6 +188,7 @@ DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32 grfid, byte local_id, template Tid name::Allocate(uint32 global_id); \ template void name::SetName(Tid cls_id, StringID name); \ template void name::Assign(Tspec *spec); \ + template NewGRFClass *name::Get(Tid cls_id); \ template StringID name::GetName(Tid cls_id); \ template uint name::GetCount(); \ template uint name::GetCount(Tid cls_id); \ -- cgit v1.2.3-54-g00ecf