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

Method assign

ogsr_engine/xrGame/script_vars_storage.cpp:326–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324}
325
326int CScriptVarsTable::assign(lua_State* L, int index)
327{
328 clear();
329 int save_top = lua_gettop(L);
330 is_array = false;
331
332 int count = lua_objlen(L, index); // сколько в array части таблицы элементов (непрерывный набор ключей от 1 до X)
333 string16 tmp;
334 // предварительное прочесывание как массива выстраивает индексы от 1 до count
335 for (int i = 1; i <= count; i++)
336 {
337 is_array = true;
338 lua_pushinteger(L, i);
339 lua_gettable(L, index);
340 set(L, _itoa(i, tmp, 10), lua_gettop(L), LUA_TNUMBER);
341 lua_pop(L, 1); // извлечь значение из стека
342 }
343 lua_settop(L, save_top);
344 lua_pushnil(L); // начало перебора таблицы
345 while (lua_next(L, index) != 0)
346 {
347 set(L, -2, -1);
348 lua_pop(L, 1); // извлечь значение из стека
349 }
350 lua_settop(L, save_top);
351 return size();
352}
353
354void CScriptVarsTable::get(lua_State* L, LPCSTR k, bool unpack)
355{

Callers 15

InitServerObjectMethod · 0.45
SyncNetStateMethod · 0.45
fillMethod · 0.45
CCartridgeMethod · 0.45
reset_memory_masksMethod · 0.45
update_memory_masksMethod · 0.45
createMethod · 0.45
initMethod · 0.45
destroyMethod · 0.45
state_startMethod · 0.45
setMethod · 0.45
script_vars_assignFunction · 0.45

Calls 10

setFunction · 0.70
clearFunction · 0.50
lua_gettopFunction · 0.50
lua_objlenFunction · 0.50
lua_pushintegerFunction · 0.50
lua_gettableFunction · 0.50
lua_settopFunction · 0.50
lua_pushnilFunction · 0.50
lua_nextFunction · 0.50
sizeFunction · 0.50

Tested by

no test coverage detected