aboutsummaryrefslogtreecommitdiff
path: root/common/util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/util.cpp')
-rw-r--r--common/util.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/common/util.cpp b/common/util.cpp
index cdb9bf9c60..05deda925b 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -75,6 +75,9 @@ void hexdump(const byte * data, int len, int bytesPerLine) {
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 @@ uint RandomSource::getRandomNumberRng(uint min, uint max) {
return getRandomNumber(max - min) + min;
}
+#pragma mark -
+
+
StackLock::StackLock(OSystem::MutexRef mutex, OSystem *syst)
: _mutex(mutex), _syst(syst) {
if (syst == 0)
@@ -117,4 +123,67 @@ void StackLock::unlock() {
_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