saves part of the Lua stack (at the given index) into a record and does NOT pop anything
| 1248 | |
| 1249 | // saves part of the Lua stack (at the given index) into a record and does NOT pop anything |
| 1250 | void LuaSaveData::SaveRecordPartial(struct lua_State* L, unsigned int key, int idx) |
| 1251 | { |
| 1252 | if(!L) |
| 1253 | return; |
| 1254 | |
| 1255 | if(idx < 0) |
| 1256 | idx += lua_gettop(L)+1; |
| 1257 | |
| 1258 | Record* cur = new Record(); |
| 1259 | cur->key = key; |
| 1260 | cur->next = NULL; |
| 1261 | |
| 1262 | if(idx <= lua_gettop(L)) |
| 1263 | { |
| 1264 | std::vector<unsigned char> output; |
| 1265 | output.push_back(luaBinaryMajorVersion); |
| 1266 | output.push_back(luaBinaryMinorVersion); |
| 1267 | |
| 1268 | LuaStackToBinaryConverter(L, idx, output); |
| 1269 | |
| 1270 | unsigned char* rv = new unsigned char [output.size()]; |
| 1271 | memcpy(rv, &output.front(), output.size()); |
| 1272 | cur->size = output.size(); |
| 1273 | cur->data = rv; |
| 1274 | } |
| 1275 | |
| 1276 | if(cur->size <= 0) |
| 1277 | { |
| 1278 | delete cur; |
| 1279 | return; |
| 1280 | } |
| 1281 | |
| 1282 | Record* last = recordList; |
| 1283 | while(last && last->next) |
| 1284 | last = last->next; |
| 1285 | if(last) |
| 1286 | last->next = cur; |
| 1287 | else |
| 1288 | recordList = cur; |
| 1289 | } |
| 1290 | |
| 1291 | void fwriteint(unsigned int value, FILE* file) |
| 1292 | { |
nothing calls this directly
no test coverage detected