[Scummvm-cvs-logs] CVS: scummvm/common util.h,1.26,1.27 util.cpp,1.21,1.22
Max Horn
fingolfin at users.sourceforge.net
Fri Oct 17 17:52:09 CEST 2003
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv30034/common
Modified Files:
util.h util.cpp
Log Message:
moved platform/language constants to common/util.*
Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/util.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- util.h 14 Oct 2003 10:24:27 -0000 1.26
+++ util.h 17 Oct 2003 15:35:45 -0000 1.27
@@ -37,6 +37,8 @@
namespace Common {
+class String;
+
/**
* Print a hexdump of the data passed in. The number of bytes per line is
* customizable.
@@ -44,7 +46,7 @@
* @param len the lenght of that data
* @param bytes_per_line number of bytes to print per line (default: 16)
*/
-void hexdump(const byte * data, int len, int bytesPerLine = 16);
+extern void hexdump(const byte * data, int len, int bytesPerLine = 16);
/**
* Simple random number generator. Although it is definitely not suitable for
@@ -85,6 +87,54 @@
StackLock(OSystem::MutexRef mutex, OSystem *syst = 0);
~StackLock();
};
+
+/**
+ * List of language ids.
+ * @note The order and mappings of the values 0..8 are *required* to stay the
+ * way they are now, as scripts in COMI rely on them. So don't touch them.
+ * I am working on removing this restriction.
+ */
+enum Language {
+ UNK_LANG = -1, // Use default language (i.e. none specified)
+ EN_USA = 0,
+ DE_DEU = 1,
+ FR_FRA = 2,
+ IT_ITA = 3,
+ PT_BRA = 4,
+ ES_ESP = 5,
+ JA_JPN = 6,
+ ZH_TWN = 7,
+ KO_KOR = 8,
+ SE_SWE = 9,
+ EN_GRB = 10,
+ HB_HEB = 20
+};
+
+/** Convert a string containing a language name into a Language enum value. */
+extern Language parseLanguage(const String &str);
+
+/**
+ * List of game platforms. Specifying a platform for a target can be used to
+ * give the game engines a hint for which platform the game data file are.
+ * This may be optional or required, depending on the game engine and the
+ * game in question.
+ */
+enum Platform {
+ kPlatformUnknown = -1,
+ kPlatformPC = 0,
+ kPlatformAmiga = 1,
+ kPlatformAtariST = 2,
+ kPlatformMacintosh = 3
+/*
+ kPlatformNES,
+ kPlatformSEGA,
+ kPlatformFMTowns,
+ kPlatformPCEngine
+*/
+};
+
+/** Convert a string containing a platform name into a Platform enum value. */
+extern Platform parsePlatform(const String &str);
} // End of namespace Common
Index: util.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/util.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- util.cpp 14 Oct 2003 10:24:27 -0000 1.21
+++ util.cpp 17 Oct 2003 15:35:45 -0000 1.22
@@ -75,6 +75,9 @@
printf("|\n");
}
+#pragma mark -
+
+
RandomSource::RandomSource() {
// Use system time as RNG seed. Normally not a good idea, if you are using
// a RNG for security purposes, but good enough for our purposes.
@@ -96,6 +99,9 @@
return getRandomNumber(max - min) + min;
}
+#pragma mark -
+
+
StackLock::StackLock(OSystem::MutexRef mutex, OSystem *syst)
: _mutex(mutex), _syst(syst) {
if (syst == 0)
@@ -116,5 +122,68 @@
assert(_syst);
_syst->unlock_mutex(_mutex);
}
+
+
+#pragma mark -
+
+
+struct LanguageDescription {
+ const char *name;
+ const char *description;
+ Common::Language id;
+};
+
+static const struct LanguageDescription languages[] = {
+ {"en", "English", EN_USA},
+ {"de", "German", DE_DEU},
+ {"fr", "French", FR_FRA},
+ {"it", "Italian", IT_ITA},
+ {"pt", "Portuguese", PT_BRA},
+ {"es", "Spanish", ES_ESP},
+ {"jp", "Japanese", JA_JPN},
+ {"zh", "Chinese (Taiwan)", ZH_TWN},
+ {"kr", "Korean", KO_KOR},
+ {"gb", "English", EN_GRB},
+ {"se", "Swedish", SE_SWE},
+ {"hb", "Hebrew", HB_HEB},
+ {0, 0, UNK_LANG}
+};
+
+Language parseLanguage(const String &str) {
+ if (str.isEmpty())
+ return UNK_LANG;
+
+ const char *s = str.c_str();
+ const LanguageDescription *l = languages;
+ while (l->name) {
+ if (!scumm_stricmp(l->name, s))
+ return l->id;
+ l++;
+ }
+
+ return UNK_LANG;
+}
+
+
+#pragma mark -
+
+
+Platform parsePlatform(const String &str) {
+ if (str.isEmpty())
+ return kPlatformUnknown;
+
+ const char *s = str.c_str();
+ if (!scumm_stricmp(s, "pc"))
+ return kPlatformPC;
+ else if (!scumm_stricmp(s, "amiga") || !scumm_stricmp(s, "1"))
+ return kPlatformAmiga;
+ else if (!scumm_stricmp(s, "atari-st") || !scumm_stricmp(s, "atari") || !scumm_stricmp(s, "2"))
+ return kPlatformAtariST;
+ else if (!scumm_stricmp(s, "macintosh") || !scumm_stricmp(s, "mac") || !scumm_stricmp(s, "3"))
+ return kPlatformMacintosh;
+ else
+ return kPlatformUnknown;
+}
+
} // End of namespace Common
More information about the Scummvm-git-logs
mailing list