- 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); void MapColors(short num,COLOR_MAP cm,short create);
int32_t CONFIG_ReadSetup(void); 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); bool WarpSectorInfo(sectortype* sect, DSWActor** sp_warp);
DSWActor* Warp(int32_t* x, int32_t* y, int32_t* z, int* sect); DSWActor* Warp(int32_t* x, int32_t* y, int32_t* z, sectortype** sect);
inline 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);
{
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;
}
void ProcessVisOn(void); void ProcessVisOn(void);

View file

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

View file

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