mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-12-03 09:32:58 +00:00
game: fix position of dropped objects
This commit is contained in:
parent
dce9415411
commit
be83c229e0
2 changed files with 60 additions and 2 deletions
4
Makefile
4
Makefile
|
@ -150,7 +150,7 @@ endif
|
|||
# Highest supported optimizations are -O2, higher levels
|
||||
# will likely break this crappy code.
|
||||
ifdef DEBUG
|
||||
CFLAGS ?= -O0 -g -Wall -pipe -DDEBUG
|
||||
CFLAGS ?= -O0 -g -Wall -Wpointer-arith -pipe -DDEBUG
|
||||
ifdef ASAN
|
||||
override CFLAGS += -fsanitize=address -DUSE_SANITIZER
|
||||
endif
|
||||
|
@ -158,7 +158,7 @@ ifdef UBSAN
|
|||
override CFLAGS += -fsanitize=undefined -DUSE_SANITIZER
|
||||
endif
|
||||
else
|
||||
CFLAGS ?= -O2 -Wall -pipe -fomit-frame-pointer
|
||||
CFLAGS ?= -O2 -Wall -Wpointer-arith -pipe -fomit-frame-pointer
|
||||
endif
|
||||
|
||||
# Always needed are:
|
||||
|
|
|
@ -1931,6 +1931,57 @@ Use_Item(edict_t *ent, edict_t *other /* unused */, edict_t *activator /* unused
|
|||
|
||||
/* ====================================================================== */
|
||||
|
||||
static void
|
||||
FixObjectPosition(edict_t *ent)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
vec3_t pos;
|
||||
trace_t tr_pos;
|
||||
int k;
|
||||
|
||||
VectorCopy(ent->s.origin, pos);
|
||||
|
||||
/* move by min */
|
||||
for (k = 0; k < i + 1; k++)
|
||||
{
|
||||
int v;
|
||||
|
||||
v = (j + k) % 3;
|
||||
pos[v] = ent->s.origin[v] - ent->mins[v];
|
||||
}
|
||||
|
||||
tr_pos = gi.trace(pos, ent->mins, ent->maxs, ent->s.origin, ent, MASK_SOLID);
|
||||
if (!tr_pos.startsolid)
|
||||
{
|
||||
VectorCopy(tr_pos.endpos, ent->s.origin);
|
||||
return;
|
||||
}
|
||||
|
||||
/* move by max */
|
||||
for (k = 0; k < i + 1; k++)
|
||||
{
|
||||
int v;
|
||||
|
||||
v = (j + k) % 3;
|
||||
pos[v] = ent->s.origin[v] - ent->maxs[v];
|
||||
}
|
||||
tr_pos = gi.trace(pos, ent->mins, ent->maxs, ent->s.origin, ent, MASK_SOLID);
|
||||
if (!tr_pos.startsolid)
|
||||
{
|
||||
VectorCopy(tr_pos.endpos, ent->s.origin);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
droptofloor(edict_t *ent)
|
||||
{
|
||||
|
@ -1966,6 +2017,13 @@ droptofloor(edict_t *ent)
|
|||
|
||||
tr = gi.trace(ent->s.origin, ent->mins, ent->maxs, dest, ent, MASK_SOLID);
|
||||
|
||||
if (tr.startsolid)
|
||||
{
|
||||
FixObjectPosition(ent);
|
||||
|
||||
tr = gi.trace(ent->s.origin, ent->mins, ent->maxs, dest, ent, MASK_SOLID);
|
||||
}
|
||||
|
||||
if (tr.startsolid)
|
||||
{
|
||||
if (strcmp(ent->classname, "foodcube") == 0)
|
||||
|
|
Loading…
Reference in a new issue