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

Method save

ogsr_engine/xrGame/script_vars_storage.cpp:166–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166int CScriptVarsTable::save(IWriter& memory_stream)
167{
168 memory_stream.w_u32(m_map.size());
169 int saved = 0;
170 auto it = m_map.begin();
171 auto end = m_map.end();
172 for (; it != end; it++)
173 {
174 saved++;
175 SCRIPT_VAR& sv = it->second;
176 memory_stream.w_stringZ(it->first);
177
178 if (LUA_TTABLE == sv.eff_type())
179 {
180 int type = sv.type;
181 sv.type = LUA_TTABLE;
182 if (sv.T->is_array)
183 sv.type |= SVT_ARRAY_TABLE;
184 if (sv.T->zero_key)
185 sv.type |= SVT_ARRAY_ZEROK;
186 if ((type & SVT_KEY_MASK) == SVT_KEY_BOOLEAN)
187 sv.type |= SVT_KEY_BOOLEAN;
188 else if ((type & SVT_KEY_MASK) == SVT_KEY_NUMERIC)
189 sv.type |= SVT_KEY_NUMERIC;
190
191 memory_stream.w_s32(sv.type);
192 saved += sv.T->save(memory_stream);
193 continue;
194 }
195
196 memory_stream.w_s32(sv.type);
197
198 if (LUA_TNETPACKET == sv.eff_type())
199 {
200 memory_stream.w_u32(sv.P->B.count);
201 memory_stream.w_u32(sv.P->r_tell());
202 memory_stream.w(&sv.P->B.data, sv.P->B.count);
203 continue;
204 }
205 memory_stream.w_u32(sv.size); // sizeof *data
206 if (sv.size > sizeof(sv.s_value))
207 memory_stream.w(sv.data, sv.size);
208 else
209 memory_stream.w(&sv.s_value, sv.size);
210 }
211
212 memory_stream.w_s32(-1);
213 return saved;
214}
215
216void CScriptVarsTable::release()
217{

Callers 1

script_vars_exportFunction · 0.45

Calls 13

MsgFunction · 0.85
w_stringZMethod · 0.80
eff_typeMethod · 0.80
r_tellMethod · 0.80
close_chunkMethod · 0.80
saveFunction · 0.70
w_u32Method · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
w_s32Method · 0.45
wMethod · 0.45

Tested by

no test coverage detected