mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- collision code cleanup.
# Conflicts: # source/games/sw/src/game.h # source/games/sw/src/sprite.cpp # Conflicts: # source/games/sw/src/game.h
This commit is contained in:
parent
898f56dd86
commit
e12ae040de
7 changed files with 125 additions and 216 deletions
|
@ -590,9 +590,10 @@ void KeepActorOnFloor(DSWActor* actor)
|
|||
}
|
||||
else
|
||||
{
|
||||
int ceilz,ceilhit,florz,florhit;
|
||||
int ceilz, florz;
|
||||
Collision ctrash, ftrash;
|
||||
FAFgetzrangepoint(sp->x, sp->y, sp->z, sp->sectnum,
|
||||
&ceilz, &ceilhit, &florz, &florhit);
|
||||
&ceilz, &ctrash, &florz, &ftrash);
|
||||
|
||||
u->oz = sp->z = florz;
|
||||
sp->backupz();
|
||||
|
|
|
@ -211,7 +211,7 @@ DoShadowFindGroundPoint(tspriteptr_t sp)
|
|||
// USES TSPRITE !!!!!
|
||||
USERp u = swActors[sp->owner].u();
|
||||
SPRITEp hsp;
|
||||
int ceilhit, florhit;
|
||||
Collision ceilhit, florhit;
|
||||
int hiz, loz = u->loz;
|
||||
short save_cstat, bak_cstat;
|
||||
|
||||
|
@ -227,13 +227,11 @@ DoShadowFindGroundPoint(tspriteptr_t sp)
|
|||
FAFgetzrangepoint(sp->x, sp->y, sp->z, sp->sectnum, &hiz, &ceilhit, &loz, &florhit);
|
||||
sp->cstat = save_cstat;
|
||||
|
||||
ASSERT(TEST(florhit, HIT_SPRITE | HIT_SECTOR));
|
||||
|
||||
switch (TEST(florhit, HIT_MASK))
|
||||
switch (florhit.type)
|
||||
{
|
||||
case HIT_SPRITE:
|
||||
case kHitSprite:
|
||||
{
|
||||
hsp = &sprite[NORM_SPRITE(florhit)];
|
||||
hsp = &florhit.actor->s();
|
||||
|
||||
if (TEST(hsp->cstat, CSTAT_SPRITE_ALIGNMENT_FLOOR))
|
||||
{
|
||||
|
@ -252,7 +250,7 @@ DoShadowFindGroundPoint(tspriteptr_t sp)
|
|||
break;
|
||||
}
|
||||
|
||||
case HIT_SECTOR:
|
||||
case kHitSector:
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -67,13 +67,14 @@ struct Collision
|
|||
DSWActor* actor;
|
||||
|
||||
Collision() = default;
|
||||
Collision(int legacyval) { setFromEngine(legacyval); }
|
||||
explicit Collision(int legacyval) { setFromEngine(legacyval); }
|
||||
|
||||
void invalidate() { type = -1; } // something invalid that's not a valid hit type.
|
||||
int setNone();
|
||||
int setSector(int num);
|
||||
int setWall(int num);
|
||||
int setSprite(DSWActor* num);
|
||||
int setSky();
|
||||
int setFromEngine(int value);
|
||||
};
|
||||
|
||||
|
@ -323,13 +324,6 @@ inline int SPRITEp_SIZE_BOS(const spritetype* sp)
|
|||
#define CEILING_DIST (Z(4))
|
||||
#define FLOOR_DIST (Z(4))
|
||||
|
||||
// defines for move_sprite return value
|
||||
#define HIT_MASK (BIT(14)|BIT(15)|BIT(16))
|
||||
#define HIT_SPRITE (BIT(14)|BIT(15))
|
||||
#define HIT_WALL BIT(15)
|
||||
#define HIT_SECTOR BIT(14)
|
||||
#define HIT_PLAX_WALL BIT(16)
|
||||
|
||||
#define NORM_SPRITE(val) ((val) & (kHitIndexMask))
|
||||
|
||||
#define NORM_SECTOR(val) ((val) & (kHitIndexMask))
|
||||
|
@ -1895,7 +1889,7 @@ short AnimSetVelAdj(short anim_ndx, short vel_adj);
|
|||
|
||||
void EnemyDefaults(DSWActor* actor, ACTOR_ACTION_SETp action, PERSONALITYp person);
|
||||
|
||||
void getzrangepoint(int x, int y, int z, short sectnum, int32_t* ceilz, int32_t* ceilhit, int32_t* florz, int32_t* florhit);
|
||||
void getzrangepoint(int x, int y, int z, short sectnum, int32_t* ceilz, Collision* ceilhit, int32_t* florz, Collision* florhit);
|
||||
Collision move_sprite(DSWActor* , int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics);
|
||||
Collision move_missile(DSWActor*, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics);
|
||||
DSWActor* DoPickTarget(DSWActor*, uint32_t max_delta_ang, int skip_targets);
|
||||
|
@ -1913,9 +1907,21 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, i
|
|||
|
||||
#define FAF_PLACE_MIRROR_PIC 341
|
||||
#define FAF_MIRROR_PIC 2356
|
||||
#define FAF_ConnectCeiling(sectnum) (sector[(sectnum)].ceilingpicnum == FAF_MIRROR_PIC)
|
||||
#define FAF_ConnectFloor(sectnum) (sector[(sectnum)].floorpicnum == FAF_MIRROR_PIC)
|
||||
#define FAF_ConnectArea(sectnum) (FAF_ConnectCeiling(sectnum) || FAF_ConnectFloor(sectnum))
|
||||
|
||||
inline bool FAF_ConnectCeiling(int sectnum)
|
||||
{
|
||||
return (sector[(sectnum)].ceilingpicnum == FAF_MIRROR_PIC);
|
||||
}
|
||||
|
||||
inline bool FAF_ConnectFloor(int sectnum)
|
||||
{
|
||||
return (sector[(sectnum)].floorpicnum == FAF_MIRROR_PIC);
|
||||
}
|
||||
|
||||
inline bool FAF_ConnectArea(int sectnum)
|
||||
{
|
||||
return (FAF_ConnectCeiling(sectnum) || FAF_ConnectFloor(sectnum));
|
||||
}
|
||||
|
||||
bool PlayerCeilingHit(PLAYERp pp, int zlimit);
|
||||
bool PlayerFloorHit(PLAYERp pp, int zlimit);
|
||||
|
@ -1932,20 +1938,11 @@ void FAFhitscan(int32_t x, int32_t y, int32_t z, int16_t sectnum,
|
|||
|
||||
bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects, int32_t xe, int32_t ye, int32_t ze, int16_t secte);
|
||||
|
||||
void FAFgetzrange(vec3_t pos, int16_t sectnum,
|
||||
int32_t* hiz, int32_t* ceilhit,
|
||||
int32_t* loz, int32_t* florhit,
|
||||
int32_t clipdist, int32_t clipmask);
|
||||
|
||||
void FAFgetzrange(vec3_t pos, int16_t sectnum,
|
||||
int32_t* hiz, Collision* ceilhit,
|
||||
int32_t* loz, Collision* florhit,
|
||||
int32_t clipdist, int32_t clipmask);
|
||||
|
||||
void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum,
|
||||
int32_t* hiz, int32_t* ceilhit,
|
||||
int32_t* loz, int32_t* florhit);
|
||||
|
||||
void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum,
|
||||
int32_t* hiz, Collision* ceilhit,
|
||||
int32_t* loz, Collision* florhit);
|
||||
|
|
|
@ -1863,7 +1863,7 @@ void UpdatePlayerSprite(PLAYERp pp)
|
|||
|
||||
void DoPlayerZrange(PLAYERp pp)
|
||||
{
|
||||
int ceilhit, florhit;
|
||||
Collision ceilhit, florhit;
|
||||
short bakcstat;
|
||||
|
||||
if (!pp->Actor()) return;
|
||||
|
@ -2687,9 +2687,9 @@ void DoPlayerMoveVehicle(PLAYERp pp)
|
|||
if (FindDistance2D(hitinfo.pos.x - hit_pos.x, hitinfo.pos.y - hit_pos.y) < 800)
|
||||
{
|
||||
if (hitinfo.wall >= 0)
|
||||
SetCollision(u, hitinfo.wall|HIT_WALL);
|
||||
u->coll.setWall(hitinfo.wall);
|
||||
else if (hitinfo.sprite >= 0)
|
||||
SetCollision(u, hitinfo.sprite|HIT_SPRITE);
|
||||
u->coll.setSprite(&swActors[hitinfo.sprite]);
|
||||
else
|
||||
u->coll.setNone();
|
||||
|
||||
|
|
|
@ -370,20 +370,20 @@ int GetZadjustment(short sectnum, short hitag)
|
|||
return 0L;
|
||||
}
|
||||
|
||||
bool SectorZadjust(int ceilhit, int32_t* hiz, short florhit, int32_t* loz)
|
||||
bool SectorZadjust(const Collision& ceilhit, int32_t* hiz, const Collision& florhit, int32_t* loz)
|
||||
{
|
||||
extern int PlaxCeilGlobZadjust, PlaxFloorGlobZadjust;
|
||||
int z_amt = 0;
|
||||
|
||||
bool SkipFAFcheck = false;
|
||||
|
||||
if ((int)florhit != -1)
|
||||
if (florhit.type != -1)
|
||||
{
|
||||
switch (TEST(florhit, HIT_MASK))
|
||||
switch (florhit.type)
|
||||
{
|
||||
case HIT_SECTOR:
|
||||
case kHitSector:
|
||||
{
|
||||
short hit_sector = NORM_SECTOR(florhit);
|
||||
short hit_sector = florhit.index;
|
||||
|
||||
// don't jack with connect sectors
|
||||
if (FAF_ConnectFloor(hit_sector))
|
||||
|
@ -431,13 +431,13 @@ bool SectorZadjust(int ceilhit, int32_t* hiz, short florhit, int32_t* loz)
|
|||
}
|
||||
}
|
||||
|
||||
if ((int)ceilhit != -1)
|
||||
if (ceilhit.type != -1)
|
||||
{
|
||||
switch (TEST(ceilhit, HIT_MASK))
|
||||
switch (ceilhit.type)
|
||||
{
|
||||
case HIT_SECTOR:
|
||||
case kHitSector:
|
||||
{
|
||||
short hit_sector = NORM_SECTOR(ceilhit);
|
||||
short hit_sector = ceilhit.index;
|
||||
|
||||
// don't jack with connect sectors
|
||||
if (FAF_ConnectCeiling(hit_sector))
|
||||
|
@ -484,39 +484,31 @@ bool SectorZadjust(int ceilhit, int32_t* hiz, short florhit, int32_t* loz)
|
|||
return SkipFAFcheck;
|
||||
}
|
||||
|
||||
void WaterAdjust(short florhit, int32_t* loz)
|
||||
void WaterAdjust(const Collision& florhit, int32_t* loz)
|
||||
{
|
||||
switch (TEST(florhit, HIT_MASK))
|
||||
if (florhit.type == kHitSector)
|
||||
{
|
||||
case HIT_SECTOR:
|
||||
{
|
||||
SECT_USERp sectu = SectUser[NORM_SECTOR(florhit)].Data();
|
||||
SECT_USERp sectu = SectUser[florhit.index].Data();
|
||||
|
||||
if (sectu && FixedToInt(sectu->depth_fixed))
|
||||
*loz += Z(FixedToInt(sectu->depth_fixed));
|
||||
}
|
||||
break;
|
||||
case HIT_SPRITE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit, int32_t clipdist, int32_t clipmask)
|
||||
static void getzrange(vec3_t* pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit, int32_t clipdist, int32_t clipmask)
|
||||
{
|
||||
int f, c;
|
||||
FAFgetzrange(pos, sectnum, hiz, &c, loz, &f, clipdist, clipmask);
|
||||
::getzrange(pos, sectnum, hiz, &c, loz, &f, clipdist, clipmask);
|
||||
ceilhit->setFromEngine(c);
|
||||
florhit->setFromEngine(f);
|
||||
}
|
||||
|
||||
void FAFgetzrange(vec3_t pos, int16_t sectnum,
|
||||
int32_t* hiz, int32_t* ceilhit,
|
||||
int32_t* loz, int32_t* florhit,
|
||||
int32_t clipdist, int32_t clipmask)
|
||||
void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit, int32_t clipdist, int32_t clipmask)
|
||||
{
|
||||
int foo1;
|
||||
int foo2;
|
||||
Collision foo2;
|
||||
bool SkipFAFcheck;
|
||||
Collision trash; trash.invalidate();
|
||||
|
||||
// IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
// This will return invalid FAF ceiling and floor heights inside of analyzesprite
|
||||
|
@ -543,11 +535,7 @@ void FAFgetzrange(vec3_t pos, int16_t sectnum,
|
|||
int uppersect = sectnum;
|
||||
int newz = *hiz - Z(2);
|
||||
|
||||
switch (TEST(*ceilhit, HIT_MASK))
|
||||
{
|
||||
case HIT_SPRITE:
|
||||
return;
|
||||
}
|
||||
if (ceilhit->type == kHitSprite) return
|
||||
|
||||
updatesectorz(pos.x, pos.y, newz, &uppersect);
|
||||
if (uppersect < 0)
|
||||
|
@ -555,23 +543,14 @@ void FAFgetzrange(vec3_t pos, int16_t sectnum,
|
|||
vec3_t npos = pos;
|
||||
npos.z = newz;
|
||||
getzrange(&npos, uppersect, hiz, ceilhit, &foo1, &foo2, clipdist, clipmask);
|
||||
SectorZadjust(*ceilhit, hiz, -1, nullptr);
|
||||
SectorZadjust(*ceilhit, hiz, trash, nullptr);
|
||||
}
|
||||
else if (FAF_ConnectFloor(sectnum) && !TEST(sector[sectnum].floorstat, FLOOR_STAT_FAF_BLOCK_HITSCAN))
|
||||
//if (FAF_ConnectFloor(sectnum))
|
||||
{
|
||||
int lowersect = sectnum;
|
||||
int newz = *loz + Z(2);
|
||||
|
||||
switch (TEST(*florhit, HIT_MASK))
|
||||
{
|
||||
case HIT_SECTOR:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case HIT_SPRITE:
|
||||
return;
|
||||
}
|
||||
if (florhit->type == kHitSprite) return
|
||||
|
||||
updatesectorz(pos.x, pos.y, newz, &lowersect);
|
||||
if (lowersect < 0)
|
||||
|
@ -579,26 +558,19 @@ void FAFgetzrange(vec3_t pos, int16_t sectnum,
|
|||
vec3_t npos = pos;
|
||||
npos.z = newz;
|
||||
getzrange(&npos, lowersect, &foo1, &foo2, loz, florhit, clipdist, clipmask);
|
||||
SectorZadjust(-1, nullptr, *florhit, loz);
|
||||
SectorZadjust(trash, nullptr, *florhit, loz);
|
||||
WaterAdjust(*florhit, loz);
|
||||
}
|
||||
}
|
||||
|
||||
void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit)
|
||||
{
|
||||
int f, c;
|
||||
FAFgetzrangepoint(x, y, z, sectnum, hiz, &c, loz, &f);
|
||||
ceilhit->setFromEngine(c);
|
||||
florhit->setFromEngine(f);
|
||||
}
|
||||
|
||||
void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum,
|
||||
int32_t* hiz, int32_t* ceilhit,
|
||||
int32_t* loz, int32_t* florhit)
|
||||
int32_t* hiz, Collision* ceilhit,
|
||||
int32_t* loz, Collision* florhit)
|
||||
{
|
||||
int foo1;
|
||||
int foo2;
|
||||
Collision foo2;
|
||||
bool SkipFAFcheck;
|
||||
Collision trash; trash.invalidate();
|
||||
|
||||
// IMPORTANT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
// This will return invalid FAF ceiling and floor heights inside of analyzesprite
|
||||
|
@ -624,32 +596,27 @@ void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum,
|
|||
{
|
||||
int uppersect = sectnum;
|
||||
int newz = *hiz - Z(2);
|
||||
switch (TEST(*ceilhit, HIT_MASK))
|
||||
{
|
||||
case HIT_SPRITE:
|
||||
if (ceilhit->type == kHitSprite)
|
||||
return;
|
||||
}
|
||||
|
||||
updatesectorz(x, y, newz, &uppersect);
|
||||
if (uppersect < 0)
|
||||
return; // _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d, sectnum %d", x, y, newz, sectnum);
|
||||
getzrangepoint(x, y, newz, uppersect, hiz, ceilhit, &foo1, &foo2);
|
||||
SectorZadjust(*ceilhit, hiz, -1, nullptr);
|
||||
SectorZadjust(*ceilhit, hiz, trash, nullptr);
|
||||
}
|
||||
else if (FAF_ConnectFloor(sectnum) && !TEST(sector[sectnum].floorstat, FLOOR_STAT_FAF_BLOCK_HITSCAN))
|
||||
//if (FAF_ConnectFloor(sectnum))
|
||||
{
|
||||
int lowersect = sectnum;
|
||||
int newz = *loz + Z(2);
|
||||
switch (TEST(*florhit, HIT_MASK))
|
||||
{
|
||||
case HIT_SPRITE:
|
||||
if (florhit->type == kHitSprite)
|
||||
return;
|
||||
}
|
||||
updatesectorz(x, y, newz, &lowersect);
|
||||
if (lowersect < 0)
|
||||
return; // _ErrMsg(ERR_STD_ARG, "Did not find a sector at %d, %d, %d, sectnum %d", x, y, newz, sectnum);
|
||||
getzrangepoint(x, y, newz, lowersect, &foo1, &foo2, loz, florhit);
|
||||
SectorZadjust(-1, nullptr, *florhit, loz);
|
||||
SectorZadjust(trash, nullptr, *florhit, loz);
|
||||
WaterAdjust(*florhit, loz);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,10 @@ int MinEnemySkill;
|
|||
extern STATE s_CarryFlag[];
|
||||
extern STATE s_CarryFlagNoDet[];
|
||||
|
||||
static int globhiz, globloz, globhihit, globlohit;
|
||||
// beware of mess... :(
|
||||
static int globhiz, globloz;
|
||||
static Collision globhihit, globlohit;
|
||||
|
||||
short wait_active_check_offset;
|
||||
int PlaxCeilGlobZadjust, PlaxFloorGlobZadjust;
|
||||
void SetSectorWallBits(short sectnum, int bit_mask, bool set_sectwall, bool set_nextwall);
|
||||
|
@ -2381,7 +2384,8 @@ void SpriteSetup(void)
|
|||
case SECT_SPIKE:
|
||||
{
|
||||
short speed,vel,time,type,start_on,floor_vator;
|
||||
int floorz,ceilingz,trash;
|
||||
int floorz,ceilingz;
|
||||
Collision trash;
|
||||
u = SpawnUser(actor, 0, nullptr);
|
||||
|
||||
SetSectorWallBits(sp->sectnum, WALLFX_DONT_STICK, false, true);
|
||||
|
@ -4571,9 +4575,8 @@ bool SpriteOverlapZ(DSWActor* actor_a, DSWActor* actor_b, int z_overlap)
|
|||
|
||||
}
|
||||
|
||||
void
|
||||
getzrangepoint(int x, int y, int z, short sectnum,
|
||||
int32_t* ceilz, int32_t* ceilhit, int32_t* florz, int32_t* florhit)
|
||||
void getzrangepoint(int x, int y, int z, short sectnum,
|
||||
int32_t* ceilz, Collision* ceilhit, int32_t* florz, Collision* florhit)
|
||||
{
|
||||
spritetype *spr;
|
||||
int j, k, l, dax, day, daz, xspan, yspan, xoff, yoff;
|
||||
|
@ -4584,16 +4587,16 @@ getzrangepoint(int x, int y, int z, short sectnum,
|
|||
if (sectnum < 0)
|
||||
{
|
||||
*ceilz = 0x80000000;
|
||||
*ceilhit = -1;
|
||||
|
||||
*florz = 0x7fffffff;
|
||||
*florhit = -1;
|
||||
florhit->invalidate();
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize z's and hits to the current sector's top&bottom
|
||||
getzsofslope(sectnum, x, y, ceilz, florz);
|
||||
*ceilhit = sectnum + 16384;
|
||||
*florhit = sectnum + 16384;
|
||||
ceilhit->setSector(sectnum);
|
||||
florhit->setSector(sectnum);
|
||||
|
||||
// Go through sprites of only the current sector
|
||||
SWSectIterator it(sectnum);
|
||||
|
@ -4682,7 +4685,7 @@ getzrangepoint(int x, int y, int z, short sectnum,
|
|||
if (daz > *ceilz)
|
||||
{
|
||||
*ceilz = daz;
|
||||
*ceilhit = itActor->GetSpriteIndex() + HIT_SPRITE;
|
||||
ceilhit->setSprite(itActor);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -4690,7 +4693,7 @@ getzrangepoint(int x, int y, int z, short sectnum,
|
|||
if (daz < *florz)
|
||||
{
|
||||
*florz = daz;
|
||||
*florhit = itActor->GetSpriteIndex() + HIT_SPRITE;
|
||||
florhit->setSprite(itActor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4701,7 +4704,7 @@ void DoActorZrange(DSWActor* actor)
|
|||
{
|
||||
USERp u = actor->u(), wu;
|
||||
SPRITEp sp = &actor->s(), wp;
|
||||
int ceilhit, florhit;
|
||||
Collision ceilhit, florhit;
|
||||
short save_cstat;
|
||||
|
||||
save_cstat = TEST(sp->cstat, CSTAT_SPRITE_BLOCK);
|
||||
|
@ -4715,26 +4718,26 @@ void DoActorZrange(DSWActor* actor)
|
|||
u->highActor = nullptr;
|
||||
u->lowActor = nullptr;
|
||||
|
||||
switch (TEST(ceilhit, HIT_MASK))
|
||||
switch (ceilhit.type)
|
||||
{
|
||||
case HIT_SPRITE:
|
||||
u->highActor = &swActors[NORM_SPRITE(ceilhit)];
|
||||
case kHitSprite:
|
||||
u->highActor = ceilhit.actor;
|
||||
break;
|
||||
case HIT_SECTOR:
|
||||
u->hi_sectp = §or[NORM_SECTOR(ceilhit)];
|
||||
case kHitSector:
|
||||
u->hi_sectp = §or[ceilhit.index];
|
||||
break;
|
||||
default:
|
||||
ASSERT(true==false);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (TEST(florhit, HIT_MASK))
|
||||
switch (florhit.type)
|
||||
{
|
||||
case HIT_SPRITE:
|
||||
u->lowActor = &swActors[NORM_SPRITE(florhit)];
|
||||
case kHitSprite:
|
||||
u->lowActor = florhit.actor;
|
||||
break;
|
||||
case HIT_SECTOR:
|
||||
u->lo_sectp = §or[NORM_SECTOR(florhit)];
|
||||
case kHitSector:
|
||||
u->lo_sectp = §or[florhit.index];
|
||||
break;
|
||||
default:
|
||||
ASSERT(true==false);
|
||||
|
@ -4756,23 +4759,23 @@ int DoActorGlobZ(DSWActor* actor)
|
|||
u->highActor = nullptr;
|
||||
u->lowActor = nullptr;
|
||||
|
||||
switch (TEST(globhihit, HIT_MASK))
|
||||
switch (globhihit.type)
|
||||
{
|
||||
case HIT_SPRITE:
|
||||
u->highActor = &swActors[globhihit & 4095];
|
||||
case kHitSprite:
|
||||
u->highActor = globhihit.actor;
|
||||
break;
|
||||
default:
|
||||
u->hi_sectp = §or[globhihit & 4095];
|
||||
u->hi_sectp = §or[globhihit.index];
|
||||
break;
|
||||
}
|
||||
|
||||
switch (TEST(globlohit, HIT_MASK))
|
||||
switch (globlohit.type)
|
||||
{
|
||||
case HIT_SPRITE:
|
||||
u->lowActor = &swActors[globlohit & 4095];
|
||||
case kHitSprite:
|
||||
u->lowActor = globlohit.actor;
|
||||
break;
|
||||
default:
|
||||
u->lo_sectp = §or[globlohit & 4095];
|
||||
u->lo_sectp = §or[globlohit.index];
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -6557,7 +6560,8 @@ void SpriteControl(void)
|
|||
|
||||
Collision move_sprite(DSWActor* actor, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics)
|
||||
{
|
||||
int retval=0, zh;
|
||||
Collision retval(0);
|
||||
int zh;
|
||||
int dasectnum;
|
||||
short tempshort;
|
||||
SPRITEp spr = &actor->s();
|
||||
|
@ -6586,29 +6590,26 @@ Collision move_sprite(DSWActor* actor, int xchange, int ychange, int zchange, in
|
|||
|
||||
// ASSERT(inside(spr->x,spr->y,dasectnum));
|
||||
|
||||
retval = clipmove(&clippos, &dasectnum,
|
||||
int cmret = clipmove(&clippos, &dasectnum,
|
||||
((xchange * numtics) << 11), ((ychange * numtics) << 11),
|
||||
(((int) spr->clipdist) << 2), ceildist, flordist, cliptype, 1);
|
||||
|
||||
spr->pos.vec2 = clippos.vec2;
|
||||
|
||||
if (dasectnum < 0)
|
||||
{
|
||||
retval = HIT_WALL;
|
||||
//ASSERT(true == false);
|
||||
retval.setWall(0); // this is wrong but what the original code did.
|
||||
return retval;
|
||||
}
|
||||
retval.setFromEngine(cmret);
|
||||
|
||||
if ((dasectnum != spr->sectnum) && (dasectnum >= 0))
|
||||
ChangeActorSect(actor, dasectnum);
|
||||
|
||||
// took this out - may not be to relevant anymore
|
||||
//ASSERT(inside(spr->x,spr->y,dasectnum));
|
||||
|
||||
// Set the blocking bit to 0 temporarly so FAFgetzrange doesn't pick
|
||||
// up its own sprite
|
||||
tempshort = spr->cstat;
|
||||
spr->cstat = 0;
|
||||
//RESET(spr->cstat, CSTAT_SPRITE_BLOCK);
|
||||
|
||||
// I subtracted 8 from the clipdist because actors kept going up on
|
||||
// ledges they were not supposed to go up on. Did the same for the
|
||||
|
@ -6630,15 +6631,15 @@ Collision move_sprite(DSWActor* actor, int xchange, int ychange, int zchange, in
|
|||
// test for hitting ceiling or floor
|
||||
if ((clippos.z - zh <= globhiz) || (clippos.z - zh > globloz))
|
||||
{
|
||||
if (retval == 0)
|
||||
if (retval.type == kHitNone)
|
||||
{
|
||||
if (TEST(u->Flags, SPR_CLIMBING))
|
||||
{
|
||||
spr->z = clippos.z;
|
||||
return 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
retval = HIT_SECTOR|dasectnum;
|
||||
retval.setSector(dasectnum);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -6669,7 +6670,7 @@ Collision move_sprite(DSWActor* actor, int xchange, int ychange, int zchange, in
|
|||
}
|
||||
}
|
||||
|
||||
return Collision(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
void MissileWarpUpdatePos(DSWActor* actor, short sectnum)
|
||||
|
@ -6770,7 +6771,8 @@ Collision move_missile(DSWActor* actor, int xchange, int ychange, int zchange, i
|
|||
{
|
||||
USERp u = actor->u();
|
||||
SPRITEp sp = &actor->s();
|
||||
int retval, zh;
|
||||
Collision retval(0);
|
||||
int zh;
|
||||
int dasectnum, tempshort;
|
||||
short lastsectnum;
|
||||
|
||||
|
@ -6793,8 +6795,7 @@ Collision move_missile(DSWActor* actor, int xchange, int ychange, int zchange, i
|
|||
}
|
||||
|
||||
|
||||
// ASSERT(inside(sp->x,sp->y,dasectnum));
|
||||
retval = clipmove(&clippos, &dasectnum,
|
||||
int cmret = clipmove(&clippos, &dasectnum,
|
||||
((xchange * numtics) << 11), ((ychange * numtics) << 11),
|
||||
(((int) sp->clipdist) << 2), ceildist, flordist, cliptype, 1);
|
||||
sp->pos.vec2 = clippos.vec2;
|
||||
|
@ -6802,13 +6803,10 @@ Collision move_missile(DSWActor* actor, int xchange, int ychange, int zchange, i
|
|||
if (dasectnum < 0)
|
||||
{
|
||||
// we've gone beyond a white wall - kill it
|
||||
retval = 0;
|
||||
SET(retval, HIT_PLAX_WALL);
|
||||
retval.setSky();
|
||||
return retval;
|
||||
}
|
||||
|
||||
// took this out - may not be to relevant anymore
|
||||
//ASSERT(inside(sp->x,sp->y,dasectnum));
|
||||
retval.setFromEngine(cmret);
|
||||
|
||||
if ((dasectnum != sp->sectnum) && (dasectnum >= 0))
|
||||
ChangeActorSect(actor, dasectnum);
|
||||
|
@ -6839,14 +6837,14 @@ Collision move_missile(DSWActor* actor, int xchange, int ychange, int zchange, i
|
|||
{
|
||||
// normal code
|
||||
sp->z = u->hiz + zh + ceildist;
|
||||
if (retval == 0)
|
||||
retval = dasectnum|HIT_SECTOR;
|
||||
if (retval.type == kHitNone)
|
||||
retval.setSector(dasectnum);
|
||||
}
|
||||
else if (clippos.z - zh > u->loz - flordist)
|
||||
{
|
||||
sp->z = u->loz + zh - flordist;
|
||||
if (retval == 0)
|
||||
retval = dasectnum|HIT_SECTOR;
|
||||
if (retval.type == kHitNone)
|
||||
retval.setSector(dasectnum);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -6876,25 +6874,23 @@ Collision move_missile(DSWActor* actor, int xchange, int ychange, int zchange, i
|
|||
}
|
||||
}
|
||||
|
||||
if (retval && TEST(sector[sp->sectnum].ceilingstat, CEILING_STAT_PLAX))
|
||||
if (retval.type != kHitNone && TEST(sector[sp->sectnum].ceilingstat, CEILING_STAT_PLAX))
|
||||
{
|
||||
if (sp->z < sector[sp->sectnum].ceilingz)
|
||||
{
|
||||
RESET(retval, HIT_WALL|HIT_SECTOR);
|
||||
SET(retval, HIT_PLAX_WALL);
|
||||
retval.setSky();
|
||||
}
|
||||
}
|
||||
|
||||
if (retval && TEST(sector[sp->sectnum].floorstat, FLOOR_STAT_PLAX))
|
||||
if (retval.type != kHitNone && TEST(sector[sp->sectnum].floorstat, FLOOR_STAT_PLAX))
|
||||
{
|
||||
if (sp->z > sector[sp->sectnum].floorz)
|
||||
{
|
||||
RESET(retval, HIT_WALL|HIT_SECTOR);
|
||||
SET(retval, HIT_PLAX_WALL);
|
||||
retval.setSky();
|
||||
}
|
||||
}
|
||||
|
||||
return Collision(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
|
@ -6903,7 +6899,7 @@ Collision move_ground_missile(DSWActor* actor, int xchange, int ychange, int cei
|
|||
USERp u = actor->u();
|
||||
SPRITEp sp = &actor->s();
|
||||
int daz;
|
||||
int retval=0;
|
||||
Collision retval(0);
|
||||
int dasectnum;
|
||||
short lastsectnum;
|
||||
int ox,oy;
|
||||
|
@ -6948,43 +6944,25 @@ Collision move_ground_missile(DSWActor* actor, int xchange, int ychange, int cei
|
|||
dasectnum = lastsectnum = sp->sectnum;
|
||||
opos = sp->pos;
|
||||
opos.z = daz;
|
||||
retval = clipmove(&opos, &dasectnum,
|
||||
auto cmret = clipmove(&opos, &dasectnum,
|
||||
((xchange * numtics) << 11), ((ychange * numtics) << 11),
|
||||
(((int) sp->clipdist) << 2), ceildist, flordist, cliptype, 1);
|
||||
sp->pos.vec2 = opos.vec2;
|
||||
retval.setFromEngine(cmret);
|
||||
}
|
||||
|
||||
if (dasectnum < 0)
|
||||
{
|
||||
// we've gone beyond a white wall - kill it
|
||||
retval = 0;
|
||||
SET(retval, HIT_PLAX_WALL);
|
||||
retval.setSky();
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
if (retval) // ran into a white wall
|
||||
if (retval.type != kHitNone) // ran into a white wall
|
||||
{
|
||||
//int new_loz,new_hiz;
|
||||
|
||||
// back up and try to clip UP
|
||||
//dasectnum = lastsectnum = sp->sectnum;
|
||||
//sp->x = ox;
|
||||
//sp->y = oy;
|
||||
|
||||
#if 0
|
||||
getzsofslope(dasectnum, sp->x, sp->y, &new_hiz, &new_loz);
|
||||
|
||||
if (labs(sp->z - new_hiz) > Z(40))
|
||||
{
|
||||
u->z_tgt = new_hiz;
|
||||
retval = 0;
|
||||
return retval;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
u->z_tgt = 0;
|
||||
|
@ -6994,39 +6972,6 @@ Collision move_ground_missile(DSWActor* actor, int xchange, int ychange, int cei
|
|||
getzsofslope(dasectnum, sp->x, sp->y, &new_hiz, &new_loz);
|
||||
|
||||
sp->z = new_loz;
|
||||
|
||||
#if 0
|
||||
if (labs(sp->z - new_loz) > Z(40))
|
||||
{
|
||||
if (new_loz > sp->z)
|
||||
{
|
||||
// travelling DOWN
|
||||
u->z_tgt = new_loz;
|
||||
changespritesect(spritenum, dasectnum);
|
||||
|
||||
getzsofslope(sp->sectnum, sp->x, sp->y, &u->hiz, &u->loz);
|
||||
u->hi_sectp = u->lo_sectp = §or[sp->sectnum];
|
||||
u->highActor = u->lowActor = nullptr;
|
||||
return retval;
|
||||
}
|
||||
else
|
||||
{
|
||||
// travelling UP
|
||||
u->z_tgt = new_loz;
|
||||
|
||||
// back up and climb wall
|
||||
dasectnum = lastsectnum = sp->sectnum;
|
||||
sp->x = ox;
|
||||
sp->y = oy;
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u->z_tgt = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
ChangeActorSect(actor, dasectnum);
|
||||
}
|
||||
|
||||
|
@ -7039,8 +6984,7 @@ Collision move_ground_missile(DSWActor* actor, int xchange, int ychange, int cei
|
|||
if (labs(u->hiz - u->loz) < Z(12))
|
||||
{
|
||||
// we've gone into a very small place - kill it
|
||||
retval = 0;
|
||||
SET(retval, HIT_PLAX_WALL);
|
||||
retval.setSky();
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -7064,7 +7008,7 @@ Collision move_ground_missile(DSWActor* actor, int xchange, int ychange, int cei
|
|||
}
|
||||
}
|
||||
|
||||
return Collision(retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
#include "saveable.h"
|
||||
|
|
|
@ -179,6 +179,8 @@ inline int Collision::setSprite(DSWActor* num)
|
|||
return kHitSprite;
|
||||
}
|
||||
|
||||
int Collision::setSky() { setNone(); type = kHitSky; return kHitSky; }
|
||||
|
||||
inline int Collision::setFromEngine(int value)
|
||||
{
|
||||
legacyVal = value;
|
||||
|
|
Loading…
Reference in a new issue