mirror of
https://github.com/yquake2/rogue.git
synced 2024-11-24 21:21:38 +00:00
Fix architecture detection on Windows in Makefile, bump SAVEGAMEVER
$PROCESSOR_ARCHITECTURE seems to contain the architecture of the host, but we need the architecture the current MinGW shell is targeting. $MINGW_CHOST seems to be just that, and on my system it's either i686-w64-mingw32 (mingw32.exe) or x86_64-w64-mingw32 (mingw64.exe) (No idea what it looks like for Windows on ARM...) As fixing this would otherwise break existing savegames, I bumped the SAVEGAMEVER to "YQ2-5" and added a quirk for older savegameversions: On Windows i386 savegames that contain "AMD64" instead of "i386" as architecture are also accepted. (For YQ2-2 this didn't seem necessary, apparently "i386" was hardcoded)
This commit is contained in:
parent
e8f8a1309c
commit
b92383eff9
2 changed files with 69 additions and 60 deletions
19
Makefile
19
Makefile
|
@ -31,6 +31,13 @@ endif
|
|||
|
||||
# Detect the architecture
|
||||
ifeq ($(YQ2_OSTYPE), Windows)
|
||||
ifdef MINGW_CHOST
|
||||
ifeq ($(MINGW_CHOST), x86_64-w64-mingw32)
|
||||
YQ2_ARCH ?= x86_64
|
||||
else # i686-w64-mingw32
|
||||
YQ2_ARCH ?= i386
|
||||
endif
|
||||
else # windows, but MINGW_CHOST not defined
|
||||
ifdef PROCESSOR_ARCHITEW6432
|
||||
# 64 bit Windows
|
||||
YQ2_ARCH ?= $(PROCESSOR_ARCHITEW6432)
|
||||
|
@ -38,6 +45,7 @@ else
|
|||
# 32 bit Windows
|
||||
YQ2_ARCH ?= $(PROCESSOR_ARCHITECTURE)
|
||||
endif
|
||||
endif # windows but MINGW_CHOST not defined
|
||||
else
|
||||
# Normalize some abiguous YQ2_ARCH strings
|
||||
YQ2_ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/')
|
||||
|
@ -120,13 +128,12 @@ endif
|
|||
|
||||
# ----------
|
||||
|
||||
# If we're building with gcc for i386 let's define -ffloat-store.
|
||||
# This helps the old and crappy x87 FPU to produce correct values.
|
||||
# Would be nice if Clang had something comparable.
|
||||
# Using the default x87 float math on 32bit x86 causes rounding trouble
|
||||
# -ffloat-store could work around that, but the better solution is to
|
||||
# just enforce SSE - every x86 CPU since Pentium3 supports that
|
||||
# and this should even improve the performance on old CPUs
|
||||
ifeq ($(YQ2_ARCH), i386)
|
||||
ifeq ($(COMPILER), gcc)
|
||||
override CFLAGS += -ffloat-store
|
||||
endif
|
||||
override CFLAGS += -msse -mfpmath=sse
|
||||
endif
|
||||
|
||||
# Force SSE math on x86_64. All sane compilers should do this
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
* load older savegames. This should be bumped if the files
|
||||
* in tables/ are changed, otherwise strange things may happen.
|
||||
*/
|
||||
#define SAVEGAMEVER "YQ2-4"
|
||||
#define SAVEGAMEVER "YQ2-5"
|
||||
|
||||
/*
|
||||
* This macros are used to prohibit loading of savegames
|
||||
|
@ -844,50 +844,33 @@ ReadGame(const char *filename)
|
|||
fread(str_os, sizeof(str_os), 1, f);
|
||||
fread(str_arch, sizeof(str_arch), 1, f);
|
||||
|
||||
if (!strcmp(str_ver, SAVEGAMEVER))
|
||||
{
|
||||
save_ver = 4;
|
||||
static const struct {
|
||||
const char* verstr;
|
||||
int vernum;
|
||||
} version_mappings[] = {
|
||||
{"YQ2-1", 1},
|
||||
{"YQ2-2", 2},
|
||||
{"YQ2-3", 3},
|
||||
{"YQ2-4", 4},
|
||||
{"YQ2-5", 5},
|
||||
};
|
||||
|
||||
if (strcmp(str_game, GAMEVERSION))
|
||||
for (i=0; i < sizeof(version_mappings)/sizeof(version_mappings[0]); ++i)
|
||||
{
|
||||
if (strcmp(version_mappings[i].verstr, str_ver) == 0)
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from an other game.so.\n");
|
||||
}
|
||||
else if (strcmp(str_os, YQ2OSTYPE))
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from an other os.\n");
|
||||
}
|
||||
else if (strcmp(str_arch, YQ2ARCH))
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from an other architecure.\n");
|
||||
save_ver = version_mappings[i].vernum;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!strcmp(str_ver, "YQ2-3"))
|
||||
{
|
||||
save_ver = 3;
|
||||
|
||||
if (strcmp(str_game, GAMEVERSION))
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from an other game.so.\n");
|
||||
}
|
||||
else if (strcmp(str_os, YQ2OSTYPE))
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from an other os.\n");
|
||||
}
|
||||
else if (strcmp(str_arch, YQ2ARCH))
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from an other architecure.\n");
|
||||
}
|
||||
if(save_ver < 2)
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from an incompatible version.\n");
|
||||
}
|
||||
else if (!strcmp(str_ver, "YQ2-2"))
|
||||
else if (save_ver == 2)
|
||||
{
|
||||
save_ver = 2;
|
||||
|
||||
if (strcmp(str_game, GAMEVERSION))
|
||||
{
|
||||
fclose(f);
|
||||
|
@ -899,28 +882,47 @@ ReadGame(const char *filename)
|
|||
gi.error("Savegame from an other os.\n");
|
||||
}
|
||||
|
||||
if (!strcmp(str_os, "Windows"))
|
||||
#ifdef _WIN32
|
||||
/* Windows was forced to i386 */
|
||||
if (strcmp(str_arch, "i386") != 0)
|
||||
{
|
||||
/* Windows was forced to i386 */
|
||||
if (strcmp(str_arch, "i386"))
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from an other architecure.\n");
|
||||
}
|
||||
fclose(f);
|
||||
gi.error("Savegame from another architecture.\n");
|
||||
}
|
||||
else
|
||||
#else
|
||||
if (strcmp(str_arch, YQ2ARCH_1) != 0)
|
||||
{
|
||||
if (strcmp(str_arch, YQ2ARCH_1))
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from an other architecure.\n");
|
||||
}
|
||||
fclose(f);
|
||||
gi.error("Savegame from another architecture.\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
else // all newer savegame versions
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from an incompatible version.\n");
|
||||
if (strcmp(str_game, GAMEVERSION) != 0)
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from another game.so.\n");
|
||||
}
|
||||
else if (strcmp(str_os, YQ2OSTYPE) != 0)
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from another os.\n");
|
||||
}
|
||||
else if (strcmp(str_arch, YQ2ARCH) != 0)
|
||||
{
|
||||
#if defined(_WIN32) && (defined(__i386__) || defined(_M_IX86))
|
||||
// before savegame version "YQ2-5" (and after version 2),
|
||||
// the official Win32 binaries accidentally had the YQ2ARCH "AMD64"
|
||||
// instead of "i386" set due to a bug in the Makefile.
|
||||
// This quirk allows loading those savegames anyway
|
||||
if (save_ver >= 5 || strcmp(str_arch, "AMD64") != 0)
|
||||
#endif
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from another architecture.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_edicts = gi.TagMalloc(game.maxentities * sizeof(g_edicts[0]), TAG_GAME);
|
||||
|
|
Loading…
Reference in a new issue