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

Method get

ogsr_engine/xrGame/script_vars_storage.cpp:354–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352}
353
354void CScriptVarsTable::get(lua_State* L, LPCSTR k, bool unpack)
355{
356 auto it = map().find(k);
357
358 if (it != map().end())
359 {
360 SCRIPT_VAR& sv = it->second;
361
362 switch (sv.eff_type())
363 {
364 case LUA_TBOOLEAN: lua_pushboolean(L, sv.b_value); break;
365 case LUA_TNUMBER: lua_pushnumber(L, sv.n_value); break;
366 case LUA_TSTRING:
367 if (sv.size <= sizeof(sv.s_value))
368 lua_pushstring(L, sv.s_value);
369 else
370 lua_pushstring(L, (char*)sv.data);
371 break;
372 case LUA_TTABLE:
373 if (unpack)
374 script_vars_dump(L, sv.T, unpack);
375 else
376 lua_pushsvt(L, sv.T);
377 break;
378 case LUA_TFUNCTION:
379 if (luaL_loadbuffer(L, (LPCSTR)sv.data, sv.size, k) != 0)
380 lua_pushnil(L);
381 break;
382 case LUA_TUSERDATA: {
383 void* p = lua_newuserdata(L, sv.size);
384 memcpy(p, sv.data, sv.size);
385 break;
386 }
387 case LUA_TNETPACKET: convert_to_lua<NET_Packet*>(L, sv.P); break;
388 };
389 }
390 else
391 lua_pushnil(L);
392}
393
394void CScriptVarsTable::set(lua_State* L, int key_index, int value_index)
395{

Callers 2

script_vars_dumpFunction · 0.45
script_vars_indexFunction · 0.45

Calls 11

script_vars_dumpFunction · 0.85
lua_pushsvtFunction · 0.85
eff_typeMethod · 0.80
lua_pushbooleanFunction · 0.50
lua_pushnumberFunction · 0.50
lua_pushstringFunction · 0.50
luaL_loadbufferFunction · 0.50
lua_pushnilFunction · 0.50
lua_newuserdataFunction · 0.50
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected