When loading older save games, we will use the old unpack method (with truncated c strings)
| 280 | |
| 281 | // When loading older save games, we will use the old unpack method (with truncated c strings) |
| 282 | static uint32_t LoadOldTSTRING(lua_State* L, const char* buffer, const char* buffer_end, uint32_t count, PushTableLogger& logger) |
| 283 | { |
| 284 | uint32_t total_size = strlen(buffer) + 1; |
| 285 | if (buffer_end - buffer < (intptr_t)total_size) |
| 286 | { |
| 287 | char log_str[PUSH_TABLE_LOGGER_STR_SIZE]; |
| 288 | PushTableLogPrint(logger, log_str); |
| 289 | luaL_error(L, "Reading outside of buffer at element #%d (string): wanted to read: %d bytes left: %d [BufStart: %p, BufSize: %lu]\n'%s'", count, total_size, (int)(buffer_end - buffer), logger.m_BufferStart, logger.m_BufferSize, log_str); |
| 290 | } |
| 291 | |
| 292 | lua_pushstring(L, buffer); |
| 293 | return total_size; |
| 294 | } |
| 295 | |
| 296 | // When loading/unpacking messages/save games, we use pascal strings, and the Lua binary string api |
| 297 | static uint32_t LoadTSTRING(lua_State* L, const char* buffer, const char* buffer_end, uint32_t count, PushTableLogger& logger) |
no test coverage detected