MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / AS_GetArray

Function AS_GetArray

Source/Game/savefile_script.cpp:35–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33static ASContext* local_ctx = NULL;
34
35static CScriptArray* AS_GetArray(SavedLevel* save_file, const std::string& key) {
36 asIScriptContext* ctx = local_ctx->ctx;
37 asIScriptEngine* engine = ctx->GetEngine();
38 asITypeInfo* arrayType = engine->GetTypeInfoById(engine->GetTypeIdByDecl("array<string>"));
39 CScriptArray* array = CScriptArray::Create(arrayType, (asUINT)0);
40
41 std::vector<std::string> source_arr = save_file->GetArray(key);
42
43 array->Reserve(source_arr.size());
44
45 std::vector<std::string>::iterator layerit = source_arr.begin();
46
47 for (; layerit != source_arr.end(); layerit++) {
48 array->InsertLast((void*)&(*layerit));
49 }
50
51 return array;
52}
53
54void AttachSaveFile(ASContext* ctx, SaveFile* save_file) {
55 local_ctx = ctx;

Callers

nothing calls this directly

Calls 10

GetTypeInfoByIdMethod · 0.80
GetArrayMethod · 0.80
CreateFunction · 0.50
GetEngineMethod · 0.45
GetTypeIdByDeclMethod · 0.45
ReserveMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
InsertLastMethod · 0.45

Tested by

no test coverage detected