diff options
author | Alexander Tkachev | 2016-08-15 18:58:09 +0600 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-30 23:26:29 +0200 |
commit | d7377c43edb818580213b7da1e78b68647065e45 (patch) | |
tree | 0d371ff157a5aea6feb13d335ca5cb402460c393 | |
parent | aafc1ba145149b063c3c4f96c0f666eb98b522d5 (diff) | |
download | scummvm-rg350-d7377c43edb818580213b7da1e78b68647065e45.tar.gz scummvm-rg350-d7377c43edb818580213b7da1e78b68647065e45.tar.bz2 scummvm-rg350-d7377c43edb818580213b7da1e78b68647065e45.zip |
HE: Add getStringFromArray()
It's ARRAY_GetStringFromArray(), which was used in Moonbase networking
code as SPUTM_CStringArrayFromScummString().
-rw-r--r-- | engines/scumm/he/intern_he.h | 1 | ||||
-rw-r--r-- | engines/scumm/he/logic/moonbase_logic.cpp | 12 | ||||
-rw-r--r-- | engines/scumm/he/script_v72he.cpp | 20 |
3 files changed, 27 insertions, 6 deletions
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h index c6abac3ecc..95f6f2cf8d 100644 --- a/engines/scumm/he/intern_he.h +++ b/engines/scumm/he/intern_he.h @@ -288,6 +288,7 @@ public: virtual byte *getStringAddress(ResId idx); virtual int setupStringArray(int size); + void getStringFromArray(int arrayNumber, char *buffer, int maxLength); protected: virtual void setupOpcodes(); diff --git a/engines/scumm/he/logic/moonbase_logic.cpp b/engines/scumm/he/logic/moonbase_logic.cpp index 328d288bfc..9f86147ac1 100644 --- a/engines/scumm/he/logic/moonbase_logic.cpp +++ b/engines/scumm/he/logic/moonbase_logic.cpp @@ -509,23 +509,23 @@ int LogicHEmoonbase::op_net_get_ip_from_name(int op, int numArgs, int32 *args) { warning("STUB: op_net_get_ip_from_name()"); return 1; } + int LogicHEmoonbase::op_net_host_tcpip_game(int op, int numArgs, int32 *args) { char sessionName[MAX_SESSION_NAME]; char userName[MAX_PLAYER_NAME]; - // TODO: - //SPUTM_CStringArrayFromScummString(args[0], sessionName, sizeof(sessionName)); - //SPUTM_CStringArrayFromScummString(args[1], userName, sizeof(userName)); + _vm1->getStringFromArray(args[0], sessionName, sizeof(sessionName)); + _vm1->getStringFromArray(args[1], userName, sizeof(userName)); return _vm1->_moonbase->_net->hostGame(sessionName, userName); } + int LogicHEmoonbase::op_net_join_tcpip_game(int op, int numArgs, int32 *args) { char szIP[MAX_IP_SIZE]; char userName[MAX_PLAYER_NAME]; - // TODO: - //SPUTM_CStringArrayFromScummString(args[0], szIP, sizeof(szIP)); - //SPUTM_CStringArrayFromScummString(args[1], userName, sizeof(userName)); + _vm1->getStringFromArray(args[0], szIP, sizeof(szIP)); + _vm1->getStringFromArray(args[1], userName, sizeof(userName)); return _vm1->_moonbase->_net->joinGame(szIP, userName); } diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp index d32eb766cb..192675190c 100644 --- a/engines/scumm/he/script_v72he.cpp +++ b/engines/scumm/he/script_v72he.cpp @@ -1484,6 +1484,26 @@ void ScummEngine_v72he::writeFileFromArray(int slot, int32 resID) { } } +void ScummEngine_v72he::getStringFromArray(int arrayNumber, char *buffer, int maxLength) { + // I'm not really sure it belongs here and not some other version + // this is ARRAY_GetStringFromArray() from ARRAYS.cpp of SPUTM + + // this function makes a C-string out of <arrayNumber> contents + + VAR(0) = arrayNumber; // it was 0 in original code, but I've seen ScummVM Moonbase code which uses VAR_U32_ARRAY_UNK + + int i, ch; + for (i = 0; i < maxLength; ++i) { + if (!(ch = readArray(0, 0, i))) { + break; + } + + buffer[i] = ch; + } + + buffer[i] = 0; +} + void ScummEngine_v72he::o72_writeFile() { int32 resID = pop(); int slot = pop(); |