[Scummvm-git-logs] scummvm rvanlaar/getAt -> 445b95170d2308d25281ca9df86bbc670ea15998
rvanlaar
roland at rolandvanlaar.nl
Sun Apr 5 20:59:24 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
445b95170d DIRECTOR:LINGO: Implement getAt
Commit: 445b95170d2308d25281ca9df86bbc670ea15998
https://github.com/scummvm/scummvm/commit/445b95170d2308d25281ca9df86bbc670ea15998
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2020-04-05T22:58:03+02:00
Commit Message:
DIRECTOR:LINGO: Implement getAt
Builtin getAt gets the nth item in a 1 indexed list.
Changed paths:
engines/director/lingo/lingo-builtins.cpp
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 747022febb..8bf16a2376 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -649,8 +649,23 @@ void LB::b_getaProp(int nargs) {
}
void LB::b_getAt(int nargs) {
- g_lingo->printSTUBWithArglist("b_getAt", nargs);
- g_lingo->dropStack(nargs);
+ if (nargs != 2) {
+ warning("b_getAt: expected 2 args, not %d", nargs);
+ g_lingo->dropStack(nargs);
+ return;
+ }
+ Datum index = g_lingo->pop();
+ Datum list = g_lingo->pop();
+ if (index.type != INT) {
+ warning("b_getAt: index arg should be of type INT, not %s", index.type2str());
+ return;
+ }
+ if (list.type != ARRAY) {
+ warning("b_getAt: list arg should be of type ARRAY, not %s", list.type2str());
+ return;
+ }
+ Datum result = list.u.farr->operator[](index.u.i-1);
+ g_lingo->push(result);
}
void LB::b_getLast(int nargs) {
More information about the Scummvm-git-logs
mailing list