diff options
author | lolbot-iichan | 2018-08-27 01:03:43 +0300 |
---|---|---|
committer | Filippos Karapetis | 2020-01-11 18:05:39 +0200 |
commit | e3595393c85cbffa4fd604527e747bc701a2d5f4 (patch) | |
tree | 24ab52ba8316943b28492e45f0c50ca2556f0d1e /engines/wintermute/base/scriptables | |
parent | 04d47de5d68cccae617f31b55aebfc4de11252cb (diff) | |
download | scummvm-rg350-e3595393c85cbffa4fd604527e747bc701a2d5f4.tar.gz scummvm-rg350-e3595393c85cbffa4fd604527e747bc701a2d5f4.tar.bz2 scummvm-rg350-e3595393c85cbffa4fd604527e747bc701a2d5f4.zip |
WINTERMUTE: Add FoxTail arrays methods
Game.Split(str,sep) is added to split string into array of substrings with separator
array.Delete(index) is added to delete an array item by index
Diffstat (limited to 'engines/wintermute/base/scriptables')
-rw-r--r-- | engines/wintermute/base/scriptables/script_ext_array.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index 7431029cbf..05effd991e 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -118,8 +118,7 @@ bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// // Pop ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Pop") == 0) { - + else if (strcmp(name, "Pop") == 0) { stack->correctParams(0); if (_length > 0) { @@ -133,7 +132,36 @@ bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } return STATUS_OK; - } else { + } + +#ifdef ENABLE_FOXTAIL + ////////////////////////////////////////////////////////////////////////// + // [FoxTail] Delete + // Removes item from array by index, shifting other elements + // Used to shuffle arrays and delete found items in various scripts + // Return value is never used + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Delete") == 0) { + stack->correctParams(1); + + int shiftPoint = stack->pop()->getInt(0); + char paramNameFrom[20]; + char paramNameTo[20]; + + for (int i = shiftPoint; i < _length - 1 ; i++) { + sprintf(paramNameFrom, "%d", i + 1); + sprintf(paramNameTo, "%d", i); + _values->setProp(paramNameTo, _values->getProp(paramNameFrom), false); + } + _values->deleteProp(paramNameFrom); + _length--; + stack->pushNULL(); + + return STATUS_OK; + } +#endif + + else { return STATUS_FAILED; } } |