From 7967e30c731bdc21342ef10271578e2ac5b4e9bc Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 17 Feb 2006 00:22:53 +0000 Subject: Added global toGameSettings() template function for convenience; simplified GameSettings usage in some engines svn-id: r20739 --- base/gameDetector.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'base/gameDetector.h') diff --git a/base/gameDetector.h b/base/gameDetector.h index f8268f8bdf..0d7ceb2b33 100644 --- a/base/gameDetector.h +++ b/base/gameDetector.h @@ -43,10 +43,26 @@ enum { struct GameSettings { const char *gameid; - const char *description; - uint32 features; + const char *description; // TODO: Rename this to "title" or so + uint32 features; // TODO: Probably should get rid of this field }; +/** + * This template function allows to easily convert structs that mimic GameSettings + * to a GameSettings instance. + * + * Normally, one would just subclass GameSettings to get this effect much easier. + * However, subclassing a struct turns it into a non-POD type. One of the + * consequences is that you can't have inline intialized arrays of that type. + * But we heavily rely on those, hence we can't subclass GameSettings... + */ +template +GameSettings toGameSettings(const T &g) { + GameSettings dummy = { g.gameid, g.description, g.features }; + return dummy; +} + + class GameDetector { typedef Common::String String; -- cgit v1.2.3