aboutsummaryrefslogtreecommitdiff
path: root/engines/gob
diff options
context:
space:
mode:
authorSven Hesse2011-01-25 14:20:19 +0000
committerSven Hesse2011-01-25 14:20:19 +0000
commite32c9a10bfdfc9989530be9b4751f1855480b933 (patch)
tree3dd1260006c0394904150c8ce3b1d8d1c3c54254 /engines/gob
parentf01b8b98a4108413333b039bce617803db3965ef (diff)
downloadscummvm-rg350-e32c9a10bfdfc9989530be9b4751f1855480b933.tar.gz
scummvm-rg350-e32c9a10bfdfc9989530be9b4751f1855480b933.tar.bz2
scummvm-rg350-e32c9a10bfdfc9989530be9b4751f1855480b933.zip
GOB: Implement getting/setting values from INI files
Setting is non-permanent for now svn-id: r55534
Diffstat (limited to 'engines/gob')
-rw-r--r--engines/gob/inter.h8
-rw-r--r--engines/gob/inter_v7.cpp100
2 files changed, 64 insertions, 44 deletions
diff --git a/engines/gob/inter.h b/engines/gob/inter.h
index 8ae192b96e..f6bb5980e6 100644
--- a/engines/gob/inter.h
+++ b/engines/gob/inter.h
@@ -31,6 +31,7 @@
#include "gob/goblin.h"
#include "gob/variables.h"
+#include "gob/iniconfig.h"
namespace Gob {
@@ -604,7 +605,7 @@ protected:
void o7_loadLBM();
void o7_draw0x93();
void o7_getINIValue();
- void o7_draw0xA2();
+ void o7_setINIValue();
void o7_draw0xA4();
void o7_opendBase();
void o7_draw0xC5();
@@ -613,8 +614,13 @@ protected:
void o7_oemToANSI(OpGobParams &params);
private:
+ INIConfig _inis;
+
void storeValue(uint16 index, uint16 type, uint32 value);
void storeValue(uint32 value);
+
+ void storeString(uint16 index, uint16 type, const char *value);
+ void storeString(const char *value);
};
} // End of namespace Gob
diff --git a/engines/gob/inter_v7.cpp b/engines/gob/inter_v7.cpp
index d7c23cb4f7..5d0fff81c9 100644
--- a/engines/gob/inter_v7.cpp
+++ b/engines/gob/inter_v7.cpp
@@ -57,7 +57,7 @@ void Inter_v7::setupOpcodesDraw() {
OPCODEDRAW(0x90, o7_loadLBM);
OPCODEDRAW(0x93, o7_draw0x93);
OPCODEDRAW(0xA1, o7_getINIValue);
- OPCODEDRAW(0xA2, o7_draw0xA2);
+ OPCODEDRAW(0xA2, o7_setINIValue);
OPCODEDRAW(0xA4, o7_draw0xA4);
OPCODEDRAW(0xC4, o7_opendBase);
OPCODEDRAW(0xC5, o7_draw0xC5);
@@ -206,7 +206,15 @@ void Inter_v7::o7_draw0x93() {
void Inter_v7::o7_getINIValue() {
_vm->_game->_script->evalExpr(0);
- Common::String file = _vm->_game->_script->getResultStr();
+
+ Common::String file;
+ if (!strncmp(_vm->_game->_script->getResultStr(), "<ME>", 4))
+ file = _vm->_game->_script->getResultStr() + 4;
+ else if (!strncmp(_vm->_game->_script->getResultStr(), "<ALLCD>", 7))
+ file = _vm->_game->_script->getResultStr() + 7;
+ else
+ file = _vm->_game->_script->getResultStr();
+
_vm->_game->_script->evalExpr(0);
Common::String section = _vm->_game->_script->getResultStr();
_vm->_game->_script->evalExpr(0);
@@ -214,53 +222,31 @@ void Inter_v7::o7_getINIValue() {
_vm->_game->_script->evalExpr(0);
Common::String def = _vm->_game->_script->getResultStr();
- uint16 type;
- int16 varIndex = _vm->_game->_script->readVarIndex(0, &type);
-
- warning("Addy Stub: Get INI value, \"%s\":\"%s\":\"%s\" (\"%s\")",
- file.c_str(), section.c_str(), key.c_str(), def.c_str());
-
- if (type == TYPE_VAR_STR) {
- char *str = GET_VARO_STR(varIndex);
-
- strncpy(str, def.c_str(), _vm->_global->_inter_animDataSize);
- str[_vm->_global->_inter_animDataSize - 1] = '\0';
-
- } else if (type == TYPE_IMM_INT8) {
-
- strcpy(GET_VARO_STR(varIndex), def.c_str());
-
- } else if (type == TYPE_VAR_INT32) {
-
- char str[256];
-
- Common::strlcpy(str, def.c_str(), 256);
-
- WRITE_VARO_UINT32(varIndex, atoi(str));
-
- } else if (type == TYPE_VAR_INT16) {
-
- char str[256];
-
- Common::strlcpy(str, def.c_str(), 256);
-
- WRITE_VARO_UINT16(varIndex, atoi(str));
- }
+ Common::String value;
+ _inis.getValue(value, file, section, key, def);
+ storeString(value.c_str());
}
-void Inter_v7::o7_draw0xA2() {
+void Inter_v7::o7_setINIValue() {
_vm->_game->_script->evalExpr(0);
- Common::String str0 = _vm->_game->_script->getResultStr();
+
+ Common::String file;
+ if (!strncmp(_vm->_game->_script->getResultStr(), "<ME>", 4))
+ file = _vm->_game->_script->getResultStr() + 4;
+ else if (!strncmp(_vm->_game->_script->getResultStr(), "<ALLCD>", 7))
+ file = _vm->_game->_script->getResultStr() + 7;
+ else
+ file = _vm->_game->_script->getResultStr();
+
_vm->_game->_script->evalExpr(0);
- Common::String str1 = _vm->_game->_script->getResultStr();
+ Common::String section = _vm->_game->_script->getResultStr();
_vm->_game->_script->evalExpr(0);
- Common::String str2 = _vm->_game->_script->getResultStr();
+ Common::String key = _vm->_game->_script->getResultStr();
_vm->_game->_script->evalExpr(0);
- Common::String str3 = _vm->_game->_script->getResultStr();
+ Common::String value = _vm->_game->_script->getResultStr();
- warning("Addy Stub Draw 0xA2: \"%s\", \"%s\", \"%s\", \"%s\"",
- str0.c_str(), str1.c_str(), str2.c_str(), str3.c_str());
+ _inis.setValue(file, section, key, value);
}
void Inter_v7::o7_draw0xA4() {
@@ -305,6 +291,10 @@ void Inter_v7::o7_draw0xC6() {
str0.c_str(), str1.c_str(), str2.c_str(), str3.c_str(), index0);
}
+void Inter_v7::o7_oemToANSI(OpGobParams &params) {
+ _vm->_game->_script->skip(2);
+}
+
void Inter_v7::storeValue(uint16 index, uint16 type, uint32 value) {
switch (type) {
case OP_ARRAY_INT8:
@@ -330,8 +320,32 @@ void Inter_v7::storeValue(uint32 value) {
storeValue(index, type, value);
}
-void Inter_v7::o7_oemToANSI(OpGobParams &params) {
- _vm->_game->_script->skip(2);
+void Inter_v7::storeString(uint16 index, uint16 type, const char *value) {
+ if (type == TYPE_VAR_STR) {
+ char *str = GET_VARO_STR(index);
+
+ strncpy(str, value, _vm->_global->_inter_animDataSize);
+ str[_vm->_global->_inter_animDataSize - 1] = '\0';
+
+ } else if (type == TYPE_IMM_INT8) {
+
+ strcpy(GET_VARO_STR(index), value);
+
+ } else if (type == TYPE_VAR_INT32) {
+
+ WRITE_VARO_UINT32(index, atoi(value));
+
+ } else if (type == TYPE_VAR_INT16) {
+
+ WRITE_VARO_UINT16(index, atoi(value));
+ }
+}
+
+void Inter_v7::storeString(const char *value) {
+ uint16 type;
+ int16 varIndex = _vm->_game->_script->readVarIndex(0, &type);
+
+ storeString(varIndex, type, value);
}
} // End of namespace Gob