MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / LoadObject

Method LoadObject

src/script/api/script_list.cpp:351–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351bool ScriptList::LoadObject(HSQUIRRELVM vm)
352{
353 if (sq_gettype(vm, -1) != OT_ARRAY) return false;
354 sq_pushnull(vm);
355 if (SQ_FAILED(sq_next(vm, -2))) return false;
356 if (sq_gettype(vm, -1) != OT_INTEGER) return false;
357 SQInteger type;
358 sq_getinteger(vm, -1, &type);
359 sq_pop(vm, 2);
360 if (SQ_FAILED(sq_next(vm, -2))) return false;
361 if (sq_gettype(vm, -1) != OT_BOOL) return false;
362 SQBool order;
363 sq_getbool(vm, -1, &order);
364 sq_pop(vm, 2);
365 if (SQ_FAILED(sq_next(vm, -2))) return false;
366 if (sq_gettype(vm, -1) != OT_TABLE) return false;
367 sq_pushnull(vm);
368 while (SQ_SUCCEEDED(sq_next(vm, -2))) {
369 if (sq_gettype(vm, -2) != OT_INTEGER && sq_gettype(vm, -1) != OT_INTEGER) return false;
370 SQInteger key, value;
371 sq_getinteger(vm, -2, &key);
372 sq_getinteger(vm, -1, &value);
373 this->AddItem(key, value);
374 sq_pop(vm, 2);
375 }
376 sq_pop(vm, 3);
377 if (SQ_SUCCEEDED(sq_next(vm, -2))) return false;
378 sq_pop(vm, 1);
379 this->Sort(static_cast<SorterType>(type), order == SQTrue);
380 return true;
381}
382
383ScriptObject *ScriptList::CloneObject()
384{

Callers 1

operator()Method · 0.45

Calls 8

AddItemMethod · 0.95
SortMethod · 0.95
sq_gettypeFunction · 0.85
sq_pushnullFunction · 0.85
sq_nextFunction · 0.85
sq_getintegerFunction · 0.85
sq_popFunction · 0.85
sq_getboolFunction · 0.85

Tested by

no test coverage detected