Skip to content

Commit

Permalink
- pushmove wrapper and a few other replacements.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Aug 9, 2022
1 parent a8a3493 commit bd531ac
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 17 deletions.
10 changes: 4 additions & 6 deletions source/games/duke/src/actors.cpp
Expand Up @@ -455,9 +455,7 @@ void moveplayers(void)
}
else
{
p->__int_pos.X = act->int_pos().X;
p->__int_pos.Y = act->int_pos().Y;
p->__int_pos.Z = act->int_pos().Z - (20 << 8);
p->getposfromactor(act, -20);

p->newOwner = nullptr;

Expand Down Expand Up @@ -794,7 +792,7 @@ void movecrane(DDukeActor *actor, int crane)
ps[p].__int_pos.X = actor->int_pos().X - bcos(ang, -6);
ps[p].__int_pos.Y = actor->int_pos().Y - bsin(ang, -6);
ps[p].__int_pos.Z = actor->int_pos().Z + (2 << 8);
SetActor(ps[p].GetActor(), ps[p].__int_pos);
SetActor(ps[p].GetActor(), ps[p].player_int_pos());
ps[p].setCursector(ps[p].GetActor()->sector());
}
}
Expand Down Expand Up @@ -2685,7 +2683,7 @@ void handle_se00(DDukeActor* actor)
ps[p].__int_pos.Z += zchange;

vec2_t res;
rotatepoint(Owner->int_pos().vec2, ps[p].__int_pos.vec2, (q * l), &res);
rotatepoint(Owner->int_pos().vec2, ps[p].player_int_pos().vec2, (q * l), &res);

ps[p].bobpos.X += res.X - ps[p].player_int_pos().X;
ps[p].bobpos.Y += res.Y - ps[p].player_int_pos().Y;
Expand Down Expand Up @@ -2859,7 +2857,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6)

if (actor->sector() == psp->sector())
{
rotatepoint(actor->int_pos().vec2, ps[p].__int_pos.vec2, q, &ps[p].__int_pos.vec2);
rotatepoint(actor->int_pos().vec2, ps[p].player_int_pos().vec2, q, &ps[p].__int_pos.vec2);

ps[p].__int_pos.X += m;
ps[p].__int_pos.Y +=x;
Expand Down
6 changes: 6 additions & 0 deletions source/games/duke/src/inlines.h
Expand Up @@ -247,4 +247,10 @@ inline ESpriteFlags randomXFlip()
return CSTAT_SPRITE_XFLIP;
}

inline int pushmove_p(player_struct* actor, sectortype** const sect, int32_t const walldist, int32_t const ceildist, int32_t const flordist,
uint32_t const cliptype, bool clear = true)
{
return ::pushmove(&actor->__int_pos, sect, walldist, ceildist, flordist, cliptype, clear);
}

END_DUKE_NS
2 changes: 1 addition & 1 deletion source/games/duke/src/player.cpp
Expand Up @@ -627,7 +627,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)

updatesector(p->player_int_pos().X, p->player_int_pos().Y, &p->cursector);

pushmove(&p->__int_pos, &p->cursector, 128L, (4 << 8), (20 << 8), CLIPMASK0);
pushmove_p(p, &p->cursector, 128L, (4 << 8), (20 << 8), CLIPMASK0);

if (fz > cz + (16 << 8) && actor->spr.pal != 1)
p->angle.rotscrnang = buildang(p->dead_flag + ((fz + p->player_int_pos().Z) >> 7));
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/player_d.cpp
Expand Up @@ -2009,7 +2009,7 @@ int operateTripbomb(int snum)
auto p = &ps[snum];
HitInfo hit{};

hitscan(p->__int_pos, p->cursector, { p->angle.ang.bcos(), p->angle.ang.bsin(), -p->horizon.sum().asq16() >> 11 }, hit, CLIPMASK1);
hitscan(p->player_int_pos(), p->cursector, { p->angle.ang.bcos(), p->angle.ang.bsin(), -p->horizon.sum().asq16() >> 11 }, hit, CLIPMASK1);

if (hit.hitSector == nullptr || hit.actor())
return 0;
Expand Down Expand Up @@ -3083,7 +3083,7 @@ void processinput_d(int snum)
while (ud.clipping == 0)
{
int blocked;
blocked = (pushmove(&p->__int_pos, &p->cursector, 164, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
blocked = (pushmove_p(p, &p->cursector, 164, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);

if (fabs(pact->floorz - pact->ceilingz) < 48 || blocked)
{
Expand Down
14 changes: 6 additions & 8 deletions source/games/duke/src/player_r.cpp
Expand Up @@ -3830,10 +3830,10 @@ void processinput_r(int snum)
if (wal->lotag < 44)
{
dofurniture(clip.hitWall, p->cursector, snum);
pushmove(&p->__int_pos, &p->cursector, 172L, (4L << 8), (4L << 8), CLIPMASK0);
pushmove_p(p, &p->cursector, 172L, (4L << 8), (4L << 8), CLIPMASK0);
}
else
pushmove(&p->__int_pos, &p->cursector, 172L, (4L << 8), (4L << 8), CLIPMASK0);
pushmove_p(p, &p->cursector, 172L, (4L << 8), (4L << 8), CLIPMASK0);
}
}
}
Expand Down Expand Up @@ -3934,9 +3934,9 @@ void processinput_r(int snum)
{
int blocked;
if (pact->spr.clipdist == 64)
blocked = (pushmove(&p->__int_pos, &p->cursector, 128, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
blocked = (pushmove_p(p, &p->cursector, 128, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
else
blocked = (pushmove(&p->__int_pos, &p->cursector, 16, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);
blocked = (pushmove_p(p, &p->cursector, 16, (4 << 8), (4 << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512);

if (fabs(pact->floorz - pact->ceilingz) < 48 || blocked)
{
Expand Down Expand Up @@ -4048,8 +4048,7 @@ void OnMotorcycle(struct player_struct *p, DDukeActor* motosprite)
{
if (motosprite)
{
p->__int_pos.X = motosprite->int_pos().X;
p->__int_pos.Y = motosprite->int_pos().Y;
p->getxyfromactor(motosprite);
p->angle.ang = buildang(motosprite->spr.ang);
p->ammo_amount[MOTORCYCLE_WEAPON] = motosprite->saved_ammo;
deletesprite(motosprite);
Expand Down Expand Up @@ -4128,8 +4127,7 @@ void OnBoat(struct player_struct *p, DDukeActor* boat)
{
if (boat)
{
p->__int_pos.X = boat->int_pos().X;
p->__int_pos.Y = boat->int_pos().Y;
p->getxyfromactor(boat);
p->angle.ang = buildang(boat->spr.ang);
p->ammo_amount[BOAT_WEAPON] = boat->saved_ammo;
deletesprite(boat);
Expand Down
10 changes: 10 additions & 0 deletions source/games/duke/src/types.h
Expand Up @@ -418,6 +418,16 @@ struct player_struct
return __int_opos;
}

void player_add_int_z(int z)
{
__int_pos.Z += z;
}

void player_set_int_z(int z)
{
__int_pos.Z = z;
}

};

struct Cycler
Expand Down

0 comments on commit bd531ac

Please sign in to comment.