- adapted several clipmove calls in SW.

This commit is contained in:
Christoph Oelckers 2021-11-26 16:08:12 +01:00
parent c0b0b00f96
commit afd05add96
6 changed files with 41 additions and 44 deletions

View file

@ -2216,12 +2216,6 @@ inline int Facing(DSWActor* actor1, DSWActor* actor2)
return (abs(getincangle(getangle((sp1)->x - (sp2)->x, (sp1)->y - (sp2)->y), (sp2)->ang)) < 512);
}
// temporary helper.
inline void SetCollision(USER* u, int coll)
{
u->coll.setFromEngine(coll);
}
// just determine if the player is moving
inline bool PLAYER_MOVING(PLAYERp pp)
{

View file

@ -38,7 +38,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
BEGIN_SW_NS
int MultiClipMove(PLAYERp pp, int z, int floor_dist)
Collision MultiClipMove(PLAYERp pp, int z, int floor_dist)
{
int i;
vec3_t opos[MAX_CLIPBOX], pos[MAX_CLIPBOX];
@ -48,9 +48,8 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist)
int min_dist = 999999;
int dist;
int ret_start;
int ret;
int min_ret=0;
Collision min_ret{};
int xvect,yvect;
@ -64,9 +63,13 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist)
xvect = sop->clipbox_vdist[i] * bcos(ang);
yvect = sop->clipbox_vdist[i] * bsin(ang);
ret_start = clipmove(&spos, &pp->cursectnum, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, 1);
Collision coll;
#pragma message(__FILE__ "remove workaround");
sectortype* cursect = pp->cursector();
clipmove(spos, &cursect, xvect, yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, coll, 1);
pp->setcursector(cursect);
if (ret_start)
if (coll.type != kHitNone)
{
// hit something moving into start position
min_dist = 0;
@ -87,7 +90,7 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist)
{
min_dist = dist;
min_ndx = i;
min_ret = ret_start;
min_ret = coll;
}
}
else
@ -97,20 +100,19 @@ int MultiClipMove(PLAYERp pp, int z, int floor_dist)
pos[i].z = z;
// move the box
ret = clipmove(&pos[i], &pp->cursectnum, pp->xvect, pp->yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER);
#pragma message(__FILE__ "remove workaround");
sectortype* cursect = pp->cursector();
clipmove(pos[i], &cursect, pp->xvect, pp->yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, coll);
pp->setcursector(cursect);
// save the dist moved
dist = ksqrt(SQ(pos[i].x - opos[i].x) + SQ(pos[i].y - opos[i].y));
if (ret)
{
}
if (dist < min_dist)
{
min_dist = dist;
min_ndx = i;
min_ret = ret;
min_ret = coll;
}
}
}

View file

@ -27,7 +27,7 @@ BEGIN_SW_NS
#define RECT_CLIP 1
int MultiClipMove(PLAYERp pp, int z, int floor_dist);
Collision MultiClipMove(PLAYERp pp, int z, int floor_dist);
short MultiClipTurn(PLAYERp pp, short new_ang, int z, int floor_dist);
int RectClipMove(PLAYERp pp, int *qx, int *qy);
int testpointinquad(int x, int y, int *qx, int *qy);

View file

@ -2715,12 +2715,13 @@ void DoPlayerMoveVehicle(PLAYERp pp)
if (pp->sop->clipdist)
{
vec3_t clippos = { pp->posx, pp->posy, z };
SetCollision(u, clipmove(&clippos, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER));
int cm= clipmove(&clippos, &pp->cursectnum, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER);
u->coll.setFromEngine(cm);
pp->pos.vec2 = clippos.vec2;
}
else
{
SetCollision(u, MultiClipMove(pp, z, floor_dist));
u->coll = MultiClipMove(pp, z, floor_dist);
}
psp->cstat = save_cstat;
@ -5976,7 +5977,6 @@ void DoPlayerDeathMoveHead(PLAYERp pp)
SPRITEp sp = &pp->Actor()->s();
USERp u = pp->Actor()->u();
int dax,day;
int sectnum;
dax = MOVEx(u->slide_vel, u->slide_ang);
day = MOVEy(u->slide_vel, u->slide_ang);
@ -6024,7 +6024,7 @@ void DoPlayerDeathMoveHead(PLAYERp pp)
pp->setcursector(sp->sector());
// try to stay in valid area - death sometimes throws you out of the map
sectnum = pp->cursectnum;
int sectnum = pp->cursectnum;
updatesector(pp->posx, pp->posy, &sectnum);
if (sectnum < 0)
{

View file

@ -2823,9 +2823,10 @@ void DoTornadoObject(SECTOR_OBJECTp sop)
pos.z = floor_dist;
PlaceSectorObject(sop, MAXSO, MAXSO);
ret = clipmove(&pos, &cursect, xvect, yvect, (int)sop->clipdist, Z(0), floor_dist, CLIPMASK_ACTOR);
Collision coll;
clipmove(pos, &cursect, xvect, yvect, (int)sop->clipdist, Z(0), floor_dist, CLIPMASK_ACTOR, coll);
if (ret)
if (coll.type != kHitNone)
{
*ang = NORM_ANGLE(*ang + 1024 + RANDOM_P2(512) - 256);
}

View file

@ -11951,11 +11951,11 @@ int DoSerpRing(DSWActor* actor)
// if ((dist ok and random ok) OR very few skulls left)
if ((dist < 18000 && (RANDOM_P2(2048<<5)>>5) < 16) || ou->Counter < 4)
{
int sectnum = sp->sectnum;
updatesector(sp->x,sp->y,&sectnum);
auto sect = sp->sector();
updatesector(sp->x, sp->y, &sect);
// if (valid sector and can see target)
if (sectnum != -1 && CanSeePlayer(actor))
if (sect != nullptr && CanSeePlayer(actor))
{
extern STATEp sg_SkullJump[];
u->ID = SKULL_R0;
@ -16100,7 +16100,6 @@ bool HitscanSpriteAdjust(DSWActor* actor, walltype* hit_wall)
SPRITEp sp = &actor->s();
int16_t ang;
int xvect,yvect;
int sectnum;
if (hit_wall)
{
@ -16114,11 +16113,13 @@ bool HitscanSpriteAdjust(DSWActor* actor, walltype* hit_wall)
yvect = bsin(ang, 4);
// must have this
sectnum = sp->sectnum;
clipmove(&sp->pos, &sectnum, xvect, yvect, 4, 4<<8, 4L<<8, CLIPMASK_MISSILE);
auto sect = sp->sector();
if (sp->sectnum != sectnum)
ChangeActorSect(actor, sectnum);
Collision coll;
clipmove(sp->pos, &sect, xvect, yvect, 4, 4 << 8, 4 << 8, CLIPMASK_MISSILE, coll);
if (sp->sector() != sect)
ChangeActorSect(actor, sect);
return true;
}
@ -18597,8 +18598,6 @@ void QueueHole(sectortype* hit_sect, walltype* hit_wall, int hit_x, int hit_y, i
DSWActor* spawnedActor;
int nx,ny;
SPRITEp sp;
int sectnum;
if (TestDontStick(nullptr, hit_wall))
return;
@ -18637,12 +18636,13 @@ void QueueHole(sectortype* hit_sect, walltype* hit_wall, int hit_x, int hit_y, i
nx = bcos(sp->ang, 4);
ny = bsin(sp->ang, 4);
sectnum = sp->sectnum;
auto sect = sp->sector();
clipmove(&sp->pos, &sectnum, nx, ny, 0L, 0L, 0L, CLIPMASK_MISSILE, 1);
Collision coll;
clipmove(sp->pos, &sect, nx, ny, 0, 0, 0, CLIPMASK_MISSILE, coll, 1);
if (sp->sectnum != sectnum)
ChangeActorSect(spawnedActor, sectnum);
if (sp->sector() != sect)
ChangeActorSect(spawnedActor, sect);
}
@ -18873,7 +18873,6 @@ DSWActor* QueueWallBlood(DSWActor* actor, short ang)
DSWActor* spawnedActor;
int nx,ny;
SPRITEp sp;
int sectnum;
short rndnum;
int daz;
HitInfo hit;
@ -18968,12 +18967,13 @@ DSWActor* QueueWallBlood(DSWActor* actor, short ang)
nx = bcos(sp->ang, 4);
ny = bsin(sp->ang, 4);
sectnum = sp->sectnum;
auto sect = sp->sector();
clipmove(&sp->pos, &sectnum, nx, ny, 0L, 0L, 0L, CLIPMASK_MISSILE, 1);
Collision coll;
clipmove(sp->pos, &sect, nx, ny, 0, 0, 0, CLIPMASK_MISSILE, coll, 1);
if (sp->sectnum != sectnum)
ChangeActorSect(spawnedActor, sectnum);
if (sp->sector() != sect)
ChangeActorSect(spawnedActor, sect);
return spawnedActor;
}