| 1317 | } |
| 1318 | |
| 1319 | static bool _load_map_index(const string& cache, const string &base, |
| 1320 | time_t mtime) |
| 1321 | { |
| 1322 | // If there's a global prelude, load that first. |
| 1323 | if (FILE *fp = fopen_u((base + ".lux").c_str(), "rb")) |
| 1324 | { |
| 1325 | reader inf(fp, TAG_MINOR_VERSION); |
| 1326 | const auto version = get_save_version(inf); |
| 1327 | const auto major = version.major, minor = version.minor; |
| 1328 | int8_t word = unmarshallByte(inf); |
| 1329 | int64_t t = unmarshallSigned(inf); |
| 1330 | if (major != TAG_MAJOR_VERSION || minor > TAG_MINOR_VERSION |
| 1331 | || word != WORD_LEN || t != mtime) |
| 1332 | { |
| 1333 | return false; |
| 1334 | } |
| 1335 | |
| 1336 | #if TAG_MAJOR_VERSION == 34 |
| 1337 | // Throw out des cache with bytecode generated under Lua 5.1. |
| 1338 | if (minor < TAG_MINOR_LUA_5_4) |
| 1339 | return false; |
| 1340 | |
| 1341 | #endif |
| 1342 | lc_global_prelude.read(inf); |
| 1343 | fclose(fp); |
| 1344 | |
| 1345 | global_preludes.push_back(lc_global_prelude); |
| 1346 | } |
| 1347 | |
| 1348 | FILE* fp = fopen_u((base + ".idx").c_str(), "rb"); |
| 1349 | if (!fp) |
| 1350 | end(1, true, "Unable to read %s", (base + ".idx").c_str()); |
| 1351 | |
| 1352 | reader inf(fp, TAG_MINOR_VERSION); |
| 1353 | // Re-check version, might have been modified in the meantime. |
| 1354 | const auto version = get_save_version(inf); |
| 1355 | const auto major = version.major, minor = version.minor; |
| 1356 | int8_t word = unmarshallByte(inf); |
| 1357 | int64_t t = unmarshallSigned(inf); |
| 1358 | if (major != TAG_MAJOR_VERSION || minor > TAG_MINOR_VERSION |
| 1359 | || word != WORD_LEN || t != mtime) |
| 1360 | { |
| 1361 | return false; |
| 1362 | } |
| 1363 | |
| 1364 | #if TAG_MAJOR_VERSION == 34 |
| 1365 | // Throw out des cache with bytecode generated under Lua 5.1. |
| 1366 | if (minor < TAG_MINOR_LUA_5_4) |
| 1367 | return false; |
| 1368 | |
| 1369 | #endif |
| 1370 | const int nmaps = unmarshallShort(inf); |
| 1371 | const int nexist = vdefs.size(); |
| 1372 | vdefs.resize(nexist + nmaps, map_def()); |
| 1373 | for (int i = 0; i < nmaps; ++i) |
| 1374 | { |
| 1375 | map_def &vdef(vdefs[nexist + i]); |
| 1376 | vdef.read_index(inf); |
no test coverage detected