- deal with SW's Warp functions.

This commit is contained in:
Christoph Oelckers 2021-11-26 17:03:00 +01:00
parent 10d0ea29ce
commit f19f656dd9
3 changed files with 34 additions and 32 deletions

View file

@ -18,24 +18,9 @@ void InitCheats();
void MapColors(short num,COLOR_MAP cm,short create);
int32_t CONFIG_ReadSetup(void);
DSWActor* WarpPlane(int32_t* x, int32_t* y, int32_t* z, int* sect);
bool WarpSectorInfo(sectortype* sect, DSWActor** sp_warp);
DSWActor* Warp(int32_t* x, int32_t* y, int32_t* z, int* sect);
inline DSWActor* Warp(int32_t* x, int32_t* y, int32_t* z, sectortype** sect)
{
int sn = sectnum(*sect);
auto res = Warp(x, y, z, &sn);
*sect = sn == -1? nullptr : &sector[sn];
return res;
}
inline DSWActor* WarpPlane(int32_t* x, int32_t* y, int32_t* z, sectortype** sect)
{
int sn = sectnum(*sect);
auto res = WarpPlane(x, y, z, &sn);
*sect = sn == -1 ? nullptr : &sector[sn];
return res;
}
DSWActor* Warp(int32_t* x, int32_t* y, int32_t* z, sectortype** sect);
DSWActor* WarpPlane(int32_t* x, int32_t* y, int32_t* z, sectortype** sect);
void ProcessVisOn(void);

View file

@ -1370,9 +1370,14 @@ void DoPlayerWarpTeleporter(PLAYERp pp)
TAG 5 to 8 = random match locations
#endif
if ((act_warp = Warp(&pp->posx, &pp->posy, &pp->posz, &pp->cursectnum)) == nullptr)
#pragma message(__FILE__ "remove workaround");
auto cursect = pp->cursector();
if ((act_warp = Warp(&pp->posx, &pp->posy, &pp->posz, &cursect)) == nullptr)
{
pp->setcursector(cursect);
return;
}
pp->setcursector(cursect);
sp_warp = &act_warp->s();
switch (SP_TAG3(sp_warp))
@ -2152,8 +2157,14 @@ void DoPlayerMove(PLAYERp pp)
}
// check for warp - probably can remove from CeilingHit
if (WarpPlane(&pp->posx, &pp->posy, &pp->posz, &pp->cursectnum))
#pragma message(__FILE__ "remove workaround");
sectortype* cursect = pp->cursector();
if (WarpPlane(&pp->posx, &pp->posy, &pp->posz, &cursect))
{
pp->setcursector(cursect);
PlayerWarpUpdatePos(pp);
}
pp->setcursector(cursect);
DoPlayerZrange(pp);
@ -2729,6 +2740,8 @@ void DoPlayerMoveVehicle(PLAYERp pp)
#pragma message(__FILE__ "remove workaround");
sectortype* cursect = pp->cursector();
clipmove(clippos, &cursect, pp->xvect, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER, u->coll);
pp->setcursector(cursect);
pp->pos.vec2 = clippos.vec2;
}
else
@ -3384,11 +3397,15 @@ void DoPlayerClimb(PLAYERp pp)
LadderUpdate = true;
}
if (WarpPlane(&pp->posx, &pp->posy, &pp->posz, &pp->cursectnum))
#pragma message(__FILE__ "remove workaround");
sectortype* cursect = pp->cursector();
if (WarpPlane(&pp->posx, &pp->posy, &pp->posz, &cursect))
{
pp->setcursector(cursect);
PlayerWarpUpdatePos(pp);
LadderUpdate = true;
}
pp->setcursector(cursect);
if (LadderUpdate)
{

View file

@ -39,9 +39,9 @@ BEGIN_SW_NS
////////////////////////////////////////////////////////////////////////////////
extern bool Prediction;
DSWActor* WarpToArea(DSWActor* sp_from, int32_t* x, int32_t* y, int32_t* z, int* sect);
DSWActor* WarpToArea(DSWActor* sp_from, int32_t* x, int32_t* y, int32_t* z, sectortype** sect);
bool WarpPlaneSectorInfo(short sectnum, DSWActor** sp_ceiling, DSWActor** sp_floor)
bool WarpPlaneSectorInfo(sectortype* sect, DSWActor** sp_ceiling, DSWActor** sp_floor)
{
*sp_floor = nullptr;
*sp_ceiling = nullptr;
@ -49,7 +49,7 @@ bool WarpPlaneSectorInfo(short sectnum, DSWActor** sp_ceiling, DSWActor** sp_flo
if (Prediction)
return false;
if (sectnum < 0 || !TEST(sector[sectnum].extra, SECTFX_WARP_SECTOR))
if (sect== nullptr || !TEST(sect->extra, SECTFX_WARP_SECTOR))
return false;
SWStatIterator it(STAT_WARP);
@ -57,7 +57,7 @@ bool WarpPlaneSectorInfo(short sectnum, DSWActor** sp_ceiling, DSWActor** sp_flo
{
auto sp = &actor->s();
if (sp->sectnum == sectnum)
if (sp->sector() == sect)
{
// skip - don't teleport
if (SP_TAG10(sp) == 1)
@ -77,7 +77,7 @@ bool WarpPlaneSectorInfo(short sectnum, DSWActor** sp_ceiling, DSWActor** sp_flo
return true;
}
DSWActor* WarpPlane(int32_t* x, int32_t* y, int32_t* z, int* sect)
DSWActor* WarpPlane(int32_t* x, int32_t* y, int32_t* z, sectortype** sect)
{
DSWActor* sp_floor,* sp_ceiling;
@ -106,7 +106,7 @@ DSWActor* WarpPlane(int32_t* x, int32_t* y, int32_t* z, int* sect)
return nullptr;
}
DSWActor* WarpToArea(DSWActor* sp_from, int32_t* x, int32_t* y, int32_t* z, int* sectnum)
DSWActor* WarpToArea(DSWActor* sp_from, int32_t* x, int32_t* y, int32_t* z, sectortype** sect)
{
int xoff;
int yoff;
@ -189,8 +189,8 @@ DSWActor* WarpToArea(DSWActor* sp_from, int32_t* x, int32_t* y, int32_t* z, int*
*z += z_adj;
// get new sector
*sectnum = spi->sectnum;
updatesector(*x, *y, sectnum);
*sect = spi->sector();
updatesector(*x, *y, sect);
return actor;
}
@ -234,19 +234,19 @@ bool WarpSectorInfo(sectortype* sect, DSWActor** sp_warp)
return true;
}
DSWActor* Warp(int32_t* x, int32_t* y, int32_t* z, int* sectnum)
DSWActor* Warp(int32_t* x, int32_t* y, int32_t* z, sectortype** sect)
{
DSWActor* sp_warp;
if (Prediction)
return nullptr;
if (!WarpSectorInfo(&sector[*sectnum], &sp_warp))
if (!WarpSectorInfo(*sect, &sp_warp))
return nullptr;
if (sp_warp)
{
return WarpToArea(sp_warp, x, y, z, sectnum);
return WarpToArea(sp_warp, x, y, z, sect);
}
return nullptr;