[Scummvm-cvs-logs] SF.net SVN: scummvm:[55534] scummvm/trunk/engines/gob
drmccoy at users.sourceforge.net
drmccoy at users.sourceforge.net
Tue Jan 25 15:20:19 CET 2011
Revision: 55534
http://scummvm.svn.sourceforge.net/scummvm/?rev=55534&view=rev
Author: drmccoy
Date: 2011-01-25 14:20:19 +0000 (Tue, 25 Jan 2011)
Log Message:
-----------
GOB: Implement getting/setting values from INI files
Setting is non-permanent for now
Modified Paths:
--------------
scummvm/trunk/engines/gob/inter.h
scummvm/trunk/engines/gob/inter_v7.cpp
Modified: scummvm/trunk/engines/gob/inter.h
===================================================================
--- scummvm/trunk/engines/gob/inter.h 2011-01-25 14:19:52 UTC (rev 55533)
+++ scummvm/trunk/engines/gob/inter.h 2011-01-25 14:20:19 UTC (rev 55534)
@@ -31,6 +31,7 @@
#include "gob/goblin.h"
#include "gob/variables.h"
+#include "gob/iniconfig.h"
namespace Gob {
@@ -604,7 +605,7 @@
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 @@
void o7_oemToANSI(OpGobParams ¶ms);
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
Modified: scummvm/trunk/engines/gob/inter_v7.cpp
===================================================================
--- scummvm/trunk/engines/gob/inter_v7.cpp 2011-01-25 14:19:52 UTC (rev 55533)
+++ scummvm/trunk/engines/gob/inter_v7.cpp 2011-01-25 14:20:19 UTC (rev 55534)
@@ -57,7 +57,7 @@
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_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 @@
_vm->_game->_script->evalExpr(0);
Common::String def = _vm->_game->_script->getResultStr();
- uint16 type;
- int16 varIndex = _vm->_game->_script->readVarIndex(0, &type);
+ Common::String value;
+ _inis.getValue(value, file, section, key, def);
- warning("Addy Stub: Get INI value, \"%s\":\"%s\":\"%s\" (\"%s\")",
- file.c_str(), section.c_str(), key.c_str(), def.c_str());
+ storeString(value.c_str());
+}
- if (type == TYPE_VAR_STR) {
- char *str = GET_VARO_STR(varIndex);
+void Inter_v7::o7_setINIValue() {
+ _vm->_game->_script->evalExpr(0);
- strncpy(str, def.c_str(), _vm->_global->_inter_animDataSize);
- str[_vm->_global->_inter_animDataSize - 1] = '\0';
+ 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();
- } 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));
- }
-
-}
-
-void Inter_v7::o7_draw0xA2() {
_vm->_game->_script->evalExpr(0);
- Common::String str0 = _vm->_game->_script->getResultStr();
+ Common::String section = _vm->_game->_script->getResultStr();
_vm->_game->_script->evalExpr(0);
- Common::String str1 = _vm->_game->_script->getResultStr();
+ Common::String key = _vm->_game->_script->getResultStr();
_vm->_game->_script->evalExpr(0);
- Common::String str2 = _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 @@
str0.c_str(), str1.c_str(), str2.c_str(), str3.c_str(), index0);
}
+void Inter_v7::o7_oemToANSI(OpGobParams ¶ms) {
+ _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 @@
storeValue(index, type, value);
}
-void Inter_v7::o7_oemToANSI(OpGobParams ¶ms) {
- _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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list