diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 2358e7b6f..a40659e36 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -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) { diff --git a/source/games/sw/src/mclip.cpp b/source/games/sw/src/mclip.cpp index 192475b8f..ac12a6d16 100644 --- a/source/games/sw/src/mclip.cpp +++ b/source/games/sw/src/mclip.cpp @@ -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; } } } diff --git a/source/games/sw/src/mclip.h b/source/games/sw/src/mclip.h index 5124f74a8..8274e5ade 100644 --- a/source/games/sw/src/mclip.h +++ b/source/games/sw/src/mclip.h @@ -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); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index b9766228c..afa1c8f02 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -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, §num); if (sectnum < 0) { diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 8b84ab03a..38cc24e45 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -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); } diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 1cd82830d..fc7f3f7c4 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -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,§num); + auto sect = sp->sector(); + updatesector(sp->x, sp->y, §); // 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, §num, 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, §, 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, §num, nx, ny, 0L, 0L, 0L, CLIPMASK_MISSILE, 1); + Collision coll; + clipmove(sp->pos, §, 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, §num, nx, ny, 0L, 0L, 0L, CLIPMASK_MISSILE, 1); + Collision coll; + clipmove(sp->pos, §, 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; }