MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / script_vars_dump

Function script_vars_dump

ogsr_engine/xrGame/script_vars_storage.cpp:267–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267int script_vars_dump(lua_State* L, CScriptVarsTable* svt, bool unpack) // дамп имен и значений переменных в таблицу
268{
269 if (svt)
270 {
271 lua_createtable(L, 0, svt->size());
272 int tidx = lua_gettop(L);
273 if (tidx > 100)
274 {
275 Msg("script_vars_dump: to many nested tables in dump");
276 return 1;
277 }
278
279 auto it = svt->map().begin();
280 for (; it != svt->map().end(); it++)
281 {
282 LPCSTR key = *it->first;
283 SCRIPT_VAR& sv = it->second;
284 if (sv.is_key_boolean())
285 lua_pushboolean(L, 0 == strcmp(key, "true"));
286 else if (sv.is_key_numeric())
287 lua_pushinteger(L, atoi(key));
288 else
289 lua_pushstring(L, key);
290
291 svt->get(L, key, unpack);
292 lua_settable(L, tidx);
293 }
294 }
295 else
296 lua_pushnil(L);
297
298 return 1;
299}
300int script_vars_dump(lua_State* L) // дамп имен и значений переменных в таблицу
301{
302 CScriptVarsTable* svt = lua_tosvt(L, 1);

Callers 1

getMethod · 0.85

Calls 15

MsgFunction · 0.85
lua_tosvtFunction · 0.85
mapMethod · 0.80
is_key_booleanMethod · 0.80
is_key_numericMethod · 0.80
lua_createtableFunction · 0.50
lua_gettopFunction · 0.50
lua_pushbooleanFunction · 0.50
lua_pushintegerFunction · 0.50
lua_pushstringFunction · 0.50
lua_settableFunction · 0.50
lua_pushnilFunction · 0.50

Tested by

no test coverage detected