aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorAlexander Tkachev2016-08-15 19:43:01 +0600
committerEugene Sandulenko2016-08-30 23:26:29 +0200
commit6cfcf1f1796c9d3125596666362ce5162fd406ae (patch)
treef918ee85812111ee03dfc116f9921477b16e6105 /engines
parent75c48fd195e510167d02fdc603411fcee4343b00 (diff)
downloadscummvm-rg350-6cfcf1f1796c9d3125596666362ce5162fd406ae.tar.gz
scummvm-rg350-6cfcf1f1796c9d3125596666362ce5162fd406ae.tar.bz2
scummvm-rg350-6cfcf1f1796c9d3125596666362ce5162fd406ae.zip
HE: Add setupStringArrayFromString()
It's based on PUI_ScummStringArrayFromCString(), which is used as SPUTM_ScummStringArrayFromCString() in Moonbase networking code.
Diffstat (limited to 'engines')
-rw-r--r--engines/scumm/he/intern_he.h3
-rw-r--r--engines/scumm/he/script_v72he.cpp17
2 files changed, 19 insertions, 1 deletions
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 95f6f2cf8d..8d7ed81dd8 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -288,7 +288,8 @@ public:
virtual byte *getStringAddress(ResId idx);
virtual int setupStringArray(int size);
- void getStringFromArray(int arrayNumber, char *buffer, int maxLength);
+ virtual int setupStringArrayFromString(char *cStr);
+ virtual void getStringFromArray(int arrayNumber, char *buffer, int maxLength);
protected:
virtual void setupOpcodes();
diff --git a/engines/scumm/he/script_v72he.cpp b/engines/scumm/he/script_v72he.cpp
index 192675190c..4385475a30 100644
--- a/engines/scumm/he/script_v72he.cpp
+++ b/engines/scumm/he/script_v72he.cpp
@@ -230,6 +230,23 @@ int ScummEngine_v72he::setupStringArray(int size) {
return readVar(0);
}
+int ScummEngine_v72he::setupStringArrayFromString(char *cStr) {
+ // this is PUI_ScummStringArrayFromCString() found in PUSERMAC.cpp
+ // I can see how its done up there in setupStringArray()
+ // yet I'd note that 'SCUMMVAR_user_reserved' var was used instead of 0
+ // and strlen(), not strlen() + 1 was used
+ // plus, this function actually copies the string, not just 'sets up' the array
+
+ writeVar(0, 0);
+
+ int len = strlen(cStr);
+ byte *ptr = defineArray(0, kStringArray, 0, 0, 0, len);
+ if (ptr != nullptr)
+ strcpy((char*)ptr, cStr);
+
+ return readVar(0);
+}
+
void ScummEngine_v72he::readArrayFromIndexFile() {
int num;
int a, b, c;