1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-09 22:56:53 +02:00

add level file versioning by file extension

This commit is contained in:
XProger
2019-07-07 05:56:13 +03:00
parent 358179475b
commit 098d907a5b

View File

@@ -288,6 +288,16 @@ namespace TR {
{ "STPAUL" , STR_TR3_STPAUL , TRACK_TR3_CAVES },
};
Version getGameVersionByLevel(LevelID id) {
if (id >= LVL_TR1_TITLE && id <= LVL_TR1_END2)
return VER_TR1;
if (id >= LVL_TR2_TITLE && id <= LVL_TR2_HOUSE)
return VER_TR2;
if (id >= LVL_TR3_TITLE && id <= LVL_TR3_STPAUL)
return VER_TR3;
return VER_UNKNOWN;
}
LevelID getLevelID(int size, const char *name, Version &version, bool &isDemoLevel) {
isDemoLevel = false;
switch (size) {
@@ -683,16 +693,30 @@ namespace TR {
// skip file extension
char buf[255];
strcpy(buf, name + start);
char *ext = NULL;
for (int i = 0; i < int(strlen(buf)); i++)
if (buf[i] == '.') {
buf[i] = 0;
ext = buf + i + 1;
break;
}
// compare with standard levels
// TODO: fix TITLE (2-3), HOUSE (3), CUTx (2-3)
for (int i = 0; i < LVL_MAX; i++)
if (!strcmp(buf, LEVEL_INFO[i].name))
return LevelID(i);
if (!strcmp(buf, LEVEL_INFO[i].name)) {
LevelID id = LevelID(i);
if (ext) {
version = getGameVersionByLevel(id);
if (!strcmp("PSX", ext)) {
version = Version(version | VER_PSX);
} else if (!strcmp("SAT", ext)) {
version = Version(version | VER_SAT);
} else {
version = Version(version | VER_PC);
}
}
return id;
}
}
return LVL_CUSTOM;
@@ -778,16 +802,6 @@ namespace TR {
return VER_UNKNOWN;
}
Version getGameVersionByLevel(LevelID id) {
if (id >= LVL_TR1_TITLE && id <= LVL_TR1_END2)
return VER_TR1;
if (id >= LVL_TR2_TITLE && id <= LVL_TR2_HOUSE)
return VER_TR2;
if (id >= LVL_TR3_TITLE && id <= LVL_TR3_STPAUL)
return VER_TR3;
return VER_UNKNOWN;
}
void getGameLevelFile(char *dst, Version version, LevelID id) {
if (useEasyStart) {
switch (version) {