mirror of
https://github.com/yquake2/zaero.git
synced 2024-11-22 12:01:30 +00:00
Fix bug with high velocities in vents in 32bit builds, fix MingW build
See https://github.com/yquake2/yquake2/issues/71 and https://github.com/yquake2/xatrix/issues/4 In ClientThink(), the float value ent->velocity[i]*8 is saved into a short and if the value is too big for a short, in 32bit gcc builds the short is set to SHRT_MIN, resulting in the player being pressed down instead of up. Now we put the result in a 32bit int first (which should be big enough) and assign the int to the short. This still overflows, but with -fwrapv at least in a defined way (most probably the same way the original binaries did). The Makefile now sets $CC to gcc for MingW builds, this should fix https://github.com/yquake2/xatrix/issues/3 And while I was at it, when the game lib is loaded, it prints the date it was built, this is especially interesting for our Win32 binaries.
This commit is contained in:
parent
398aeff770
commit
aa5ccc1770
4 changed files with 10 additions and 4 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/build/
|
6
Makefile
6
Makefile
|
@ -25,6 +25,8 @@ endif
|
||||||
ifeq ($(OSTYPE), Windows)
|
ifeq ($(OSTYPE), Windows)
|
||||||
# At this time only i386 is supported on Windows
|
# At this time only i386 is supported on Windows
|
||||||
ARCH := i386
|
ARCH := i386
|
||||||
|
# seems like mingw doesn't set CC by default
|
||||||
|
CC := gcc
|
||||||
else
|
else
|
||||||
# Some platforms call it "amd64" and some "x86_64"
|
# Some platforms call it "amd64" and some "x86_64"
|
||||||
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/amd64/x86_64/)
|
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/amd64/x86_64/)
|
||||||
|
@ -58,10 +60,10 @@ endif
|
||||||
# -MMD to generate header dependencies.
|
# -MMD to generate header dependencies.
|
||||||
ifeq ($(OSTYPE), Darwin)
|
ifeq ($(OSTYPE), Darwin)
|
||||||
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
|
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
|
||||||
-Wall -pipe -g -arch i386 -arch x86_64
|
-Wall -pipe -g -fwrapv -arch i386 -arch x86_64
|
||||||
else
|
else
|
||||||
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
|
CFLAGS := -O2 -fno-strict-aliasing -fomit-frame-pointer \
|
||||||
-Wall -pipe -g -MMD
|
-Wall -pipe -g -MMD -fwrapv
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# ----------
|
# ----------
|
||||||
|
|
|
@ -1560,7 +1560,10 @@ void ClientThink (edict_t *ent, usercmd_t *ucmd)
|
||||||
for (i=0 ; i<3 ; i++)
|
for (i=0 ; i<3 ; i++)
|
||||||
{
|
{
|
||||||
pm.s.origin[i] = ent->s.origin[i]*8;
|
pm.s.origin[i] = ent->s.origin[i]*8;
|
||||||
pm.s.velocity[i] = ent->velocity[i]*8;
|
/* save to an int first, in case the short overflows
|
||||||
|
* so we get defined behavior (at least with -fwrapv) */
|
||||||
|
int tmpVel = ent->velocity[i] * 8;
|
||||||
|
pm.s.velocity[i] = tmpVel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(&client->old_pmove, &pm.s, sizeof(pm.s)))
|
if (memcmp(&client->old_pmove, &pm.s, sizeof(pm.s)))
|
||||||
|
|
|
@ -171,7 +171,7 @@ void
|
||||||
InitGame(void)
|
InitGame(void)
|
||||||
{
|
{
|
||||||
gi.dprintf("Game is starting up.\n");
|
gi.dprintf("Game is starting up.\n");
|
||||||
gi.dprintf("Game is %s.\n", GAMEVERSION);
|
gi.dprintf("Game is %s built on %s.\n", GAMEVERSION, __DATE__);
|
||||||
|
|
||||||
gun_x = gi.cvar ("gun_x", "0", 0);
|
gun_x = gi.cvar ("gun_x", "0", 0);
|
||||||
gun_y = gi.cvar ("gun_y", "0", 0);
|
gun_y = gi.cvar ("gun_y", "0", 0);
|
||||||
|
|
Loading…
Reference in a new issue