DIRECTOR: LINGO: Fix b_count for RECT and POINT

This commit is contained in:
Scott Percival 2024-05-17 18:23:20 +08:00 committed by Eugene Sandulenko
parent 9a822aa057
commit f673761135
3 changed files with 11 additions and 2 deletions

View File

@ -682,6 +682,8 @@ void LB::b_count(int nargs) {
switch (list.type) {
case ARRAY:
case RECT:
case POINT:
result.u.i = list.u.farr->arr.size();
break;
case PARRAY:

View File

@ -1596,7 +1596,8 @@ void LC::call(const Common::String &name, int nargs, bool allowRetVal) {
// If the first argument is an ARRAY or PARRAY, it will use the builtin.
// Otherwise, it will fall back to whatever handler is defined globally.
Datum firstArg = g_lingo->peek(nargs - 1);
if (firstArg.type == ARRAY || firstArg.type == PARRAY) {
if (firstArg.type == ARRAY || firstArg.type == PARRAY ||
firstArg.type == POINT || firstArg.type == RECT) {
funcSym = g_lingo->_builtinListHandlers[name];
}
}

View File

@ -13,6 +13,12 @@ scummvmAssertEqual(result, 3)
set result = count([1: 2, 3: 4, 5: 6])
scummvmAssertEqual(result, 3)
set result = count(rect(1, 2, 3, 4))
scummvmAssertEqual(result, 4)
set result = count(point(1, 2))
scummvmAssertEqual(result, 2)
set result = count("not an array")
scummvmAssertEqual(result, "what is this")
@ -22,7 +28,7 @@ scummvmAssertEqual(result, "this is the worst")
set result = add("even less of an array", 8)
scummvmAssertEqual(result, "this is the worst")
set target = [1, 2, 3]
set target = [1, 2, 3]
add(target, 4)
scummvmAssertEqual(count(target), 4)