- functionalise significant portions of 0ee3ab4df8.

This commit is contained in:
Mitchell Richters 2020-08-05 19:24:32 +10:00
parent 0142449d95
commit 03bccb3a06
8 changed files with 88 additions and 252 deletions

View file

@ -466,15 +466,7 @@ void moveplayers(void) //Players
if (p->actorsqu >= 0) if (p->actorsqu >= 0)
{ {
int ang = getincangle(p->getang(), getangle(sprite[p->actorsqu].x - p->posx, sprite[p->actorsqu].y - p->posy)) >> 2; playerAddAngle(p, getincangle(p->getang(), getangle(sprite[p->actorsqu].x - p->posx, sprite[p->actorsqu].y - p->posy)) >> 2);
if (!cl_syncinput)
{
p->angAdjust += ang;
}
else
{
p->addang(ang);
}
} }
if (s->extra > 0) if (s->extra > 0)
@ -497,15 +489,7 @@ void moveplayers(void) //Players
if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS) if (p->wackedbyactor >= 0 && sprite[p->wackedbyactor].statnum < MAXSTATUS)
{ {
int ang = getincangle(p->getang(), getangle(sprite[p->wackedbyactor].x - p->posx, sprite[p->wackedbyactor].y - p->posy)) >> 1; playerAddAngle(p, getincangle(p->getang(), getangle(sprite[p->wackedbyactor].x - p->posx, sprite[p->wackedbyactor].y - p->posy)) >> 1);
if (!cl_syncinput)
{
p->angAdjust += ang;
}
else
{
p->addang(ang);
}
} }
} }
s->ang = p->getang(); s->ang = p->getang();
@ -762,15 +746,7 @@ void movecrane(int i, int crane)
s->owner = -2; s->owner = -2;
ps[p].on_crane = i; ps[p].on_crane = i;
S_PlayActorSound(isRR() ? 390 : DUKE_GRUNT, ps[p].i); S_PlayActorSound(isRR() ? 390 : DUKE_GRUNT, ps[p].i);
int ang = s->ang + 1024; playerSetAngle(&ps[p], s->ang + 1024);
if (!cl_syncinput)
{
ps[p].angAdjust += ps[p].getang() + ang;
}
else
{
ps[p].setang(ang);
}
} }
else else
{ {
@ -2693,15 +2669,7 @@ void handle_se00(int i, int LASERLINE)
{ {
if (ps[p].cursectnum == s->sectnum && ps[p].on_ground == 1) if (ps[p].cursectnum == s->sectnum && ps[p].on_ground == 1)
{ {
int ang = l * q; playerAddAngle(&ps[p], l * q);
if (!cl_syncinput)
{
ps[p].angAdjust += ang;
}
else
{
ps[p].addang(ang);
}
ps[p].posz += zchange; ps[p].posz += zchange;
@ -2893,14 +2861,7 @@ void handle_se14(int i, bool checkstat, int RPG, int JIBS6)
ps[p].bobposx += m; ps[p].bobposx += m;
ps[p].bobposy += x; ps[p].bobposy += x;
if (!cl_syncinput) playerAddAngle(&ps[p], q);
{
ps[p].angAdjust += q;
}
else
{
ps[p].addang(q);
}
if (numplayers > 1) if (numplayers > 1)
{ {

View file

@ -1852,15 +1852,7 @@ void moveweapons_d(void)
if (s->picnum == SPIT) if (s->picnum == SPIT)
{ {
int horiz = 32; playerAddHoriz(&ps[p], 32);
if (!cl_syncinput)
{
ps[p].horizAdjust += horiz;
}
else
{
ps[p].addhoriz(horiz);
}
ps[p].return_to_center = 8; ps[p].return_to_center = 8;
if (ps[p].loogcnt == 0) if (ps[p].loogcnt == 0)

View file

@ -1399,15 +1399,7 @@ void moveweapons_r(void)
guts_r(s, RABBITJIBC, 2, myconnectindex); guts_r(s, RABBITJIBC, 2, myconnectindex);
} }
int horiz = 32; playerAddHoriz(&ps[p], 32);
if (!cl_syncinput)
{
ps[p].horizAdjust += horiz;
}
else
{
ps[p].addhoriz(horiz);
}
ps[p].return_to_center = 8; ps[p].return_to_center = 8;
if (ps[p].loogcnt == 0) if (ps[p].loogcnt == 0)

View file

@ -251,4 +251,9 @@ void backupweapon(player_struct* p);
void resetinputhelpers(player_struct* p); void resetinputhelpers(player_struct* p);
void checkhardlanding(player_struct* p); void checkhardlanding(player_struct* p);
void playerAddAngle(player_struct* p, int ang);
void playerSetAngle(player_struct* p, int ang);
void playerAddHoriz(player_struct* p, int horiz);
void playerSetHoriz(player_struct* p, int horiz);
END_DUKE_NS END_DUKE_NS

View file

@ -163,15 +163,7 @@ void forceplayerangle(struct player_struct* p)
n = 128 - (krand() & 255); n = 128 - (krand() & 255);
int horiz = 64; playerAddHoriz(p, 64);
if (!cl_syncinput)
{
p->horizAdjust += horiz;
}
else
{
p->addhoriz(horiz);
}
p->return_to_center = 9; p->return_to_center = 9;
p->setlookang(n >> 1); p->setlookang(n >> 1);
p->setrotscrnang(n >> 1); p->setrotscrnang(n >> 1);
@ -413,15 +405,7 @@ void dokneeattack(int snum, int pi, const std::initializer_list<int> & respawnli
if (p->knee_incs > 0) if (p->knee_incs > 0)
{ {
p->knee_incs++; p->knee_incs++;
int horiz = -48; playerAddHoriz(p, -48);
if (!cl_syncinput)
{
p->horizAdjust += horiz;
}
else
{
p->addhoriz(horiz);
}
p->return_to_center = 9; p->return_to_center = 9;
if (p->knee_incs > 15) if (p->knee_incs > 15)
{ {
@ -938,15 +922,7 @@ void checkhardlanding(player_struct* p)
{ {
if (p->hard_landing > 0) if (p->hard_landing > 0)
{ {
int horiz = p->hard_landing << 4; playerAddHoriz(p, -(p->hard_landing << 4));
if (!cl_syncinput)
{
p->horizAdjust -= horiz;
}
else
{
p->addhoriz(-horiz);
}
p->hard_landing--; p->hard_landing--;
} }
} }
@ -1085,6 +1061,60 @@ void playerAimDown(int snum, ESyncBits sb_snum)
} }
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void playerAddAngle(player_struct* p, int ang)
{
if (!cl_syncinput)
{
p->angAdjust += ang;
}
else
{
p->addang(ang);
}
}
void playerSetAngle(player_struct* p, int ang)
{
if (!cl_syncinput)
{
p->angAdjust += -1. * ((p->q16ang / 65536.) - ang);
}
else
{
p->setang(ang);
}
}
void playerAddHoriz(player_struct* p, int horiz)
{
if (!cl_syncinput)
{
p->horizAdjust += horiz;
}
else
{
p->addhoriz(horiz);
}
}
void playerSetHoriz(player_struct* p, int horiz)
{
if (!cl_syncinput)
{
p->horizAdjust += -1. * ((p->q16horiz / 65536.) - horiz);
}
else
{
p->sethoriz(horiz);
}
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// split out so that the weapon check can be done right. // split out so that the weapon check can be done right.

View file

@ -3033,19 +3033,7 @@ HORIZONLY:
sethorizon(snum, sb_snum, 1, sync[snum].q16horz); sethorizon(snum, sb_snum, 1, sync[snum].q16horz);
} }
if (p->hard_landing > 0) checkhardlanding(p);
{
int horiz = p->hard_landing << 4;
if (!cl_syncinput)
{
p->horizAdjust -= horiz;
}
else
{
p->addhoriz(-horiz);
}
p->hard_landing--;
}
//Shooting code/changes //Shooting code/changes

View file

@ -1503,18 +1503,6 @@ void checkweapons_r(struct player_struct* p)
} }
} }
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
static inline double calcVehicleHorizAdjust(fixed_t q16horiz, int adjustment)
{
return -1. * ((q16horiz / 65536.) - adjustment);
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //
@ -1706,14 +1694,7 @@ static void onMotorcycle(int snum, ESyncBits &sb_snum)
p->TurbCount--; p->TurbCount--;
p->moto_drink = (krand() & 3) - 2; p->moto_drink = (krand() & 3) - 2;
} }
if (!cl_syncinput) playerSetHoriz(p, horiz);
{
p->horizAdjust += calcVehicleHorizAdjust(p->q16horiz, horiz);
}
else
{
p->sethoriz(horiz);
}
} }
else if (p->VBumpTarget > p->VBumpNow) else if (p->VBumpTarget > p->VBumpNow)
{ {
@ -1723,14 +1704,7 @@ static void onMotorcycle(int snum, ESyncBits &sb_snum)
p->VBumpNow++; p->VBumpNow++;
if (p->VBumpTarget < p->VBumpNow) if (p->VBumpTarget < p->VBumpNow)
p->VBumpNow = p->VBumpTarget; p->VBumpNow = p->VBumpTarget;
if (!cl_syncinput) playerSetHoriz(p, 100 + p->VBumpNow / 3);
{
p->horizAdjust += calcVehicleHorizAdjust(p->q16horiz, 100 + p->VBumpNow / 3);
}
else
{
p->sethoriz(100 + p->VBumpNow / 3);
}
} }
else if (p->VBumpTarget < p->VBumpNow) else if (p->VBumpTarget < p->VBumpNow)
{ {
@ -1740,14 +1714,7 @@ static void onMotorcycle(int snum, ESyncBits &sb_snum)
p->VBumpNow--; p->VBumpNow--;
if (p->VBumpTarget > p->VBumpNow) if (p->VBumpTarget > p->VBumpNow)
p->VBumpNow = p->VBumpTarget; p->VBumpNow = p->VBumpTarget;
if (!cl_syncinput) playerSetHoriz(p, 100 + p->VBumpNow / 3);
{
p->horizAdjust += calcVehicleHorizAdjust(p->q16horiz, 100 + p->VBumpNow / 3);
}
else
{
p->sethoriz(100 + p->VBumpNow / 3);
}
} }
else else
{ {
@ -1806,14 +1773,7 @@ static void onMotorcycle(int snum, ESyncBits &sb_snum)
ang = var98 >> 7; ang = var98 >> 7;
} }
} }
if (!cl_syncinput) playerSetAngle(p, (var90 - ang) & 2047);
{
p->angAdjust -= ang;
}
else
{
p->setang((var90 - ang) & 2047);
}
} }
else if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->moto_on_mud || p->moto_on_oil)) else if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->moto_on_mud || p->moto_on_oil))
{ {
@ -2058,14 +2018,7 @@ static void onBoat(int snum, ESyncBits& sb_snum)
p->TurbCount--; p->TurbCount--;
p->moto_drink = (krand() & 3) - 2; p->moto_drink = (krand() & 3) - 2;
} }
if (!cl_syncinput) playerSetHoriz(p, horiz);
{
p->horizAdjust += calcVehicleHorizAdjust(p->q16horiz, horiz);
}
else
{
p->sethoriz(horiz);
}
} }
else if (p->VBumpTarget > p->VBumpNow) else if (p->VBumpTarget > p->VBumpNow)
{ {
@ -2075,14 +2028,7 @@ static void onBoat(int snum, ESyncBits& sb_snum)
p->VBumpNow++; p->VBumpNow++;
if (p->VBumpTarget < p->VBumpNow) if (p->VBumpTarget < p->VBumpNow)
p->VBumpNow = p->VBumpTarget; p->VBumpNow = p->VBumpTarget;
if (!cl_syncinput) playerSetHoriz(p, 100 + p->VBumpNow / 3);
{
p->horizAdjust += calcVehicleHorizAdjust(p->q16horiz, 100 + p->VBumpNow / 3);
}
else
{
p->sethoriz(100 + p->VBumpNow / 3);
}
} }
else if (p->VBumpTarget < p->VBumpNow) else if (p->VBumpTarget < p->VBumpNow)
{ {
@ -2092,14 +2038,7 @@ static void onBoat(int snum, ESyncBits& sb_snum)
p->VBumpNow--; p->VBumpNow--;
if (p->VBumpTarget > p->VBumpNow) if (p->VBumpTarget > p->VBumpNow)
p->VBumpNow = p->VBumpTarget; p->VBumpNow = p->VBumpTarget;
if (!cl_syncinput) playerSetHoriz(p, 100 + p->VBumpNow / 3);
{
p->horizAdjust += calcVehicleHorizAdjust(p->q16horiz, 100 + p->VBumpNow / 3);
}
else
{
p->sethoriz(100 + p->VBumpNow / 3);
}
} }
else else
{ {
@ -2133,14 +2072,7 @@ static void onBoat(int snum, ESyncBits& sb_snum)
p->posyv += (vard4 >> 7) * (sintable[(vardc * -51 + vard8) & 2047] << 4); p->posyv += (vard4 >> 7) * (sintable[(vardc * -51 + vard8) & 2047] << 4);
ang = vare0 >> 6; ang = vare0 >> 6;
} }
if (!cl_syncinput) playerSetAngle(p, (vard8 - ang) & 2047);
{
p->angAdjust -= ang;
}
else
{
p->setang((vard8 - ang) & 2047);
}
} }
if (p->NotOnWater) if (p->NotOnWater)
if (p->MotoSpeed > 50) if (p->MotoSpeed > 50)
@ -2482,14 +2414,7 @@ void onMotorcycleMove(int snum, int psect, int j)
ang = -(p->MotoSpeed >> 1); ang = -(p->MotoSpeed >> 1);
break; break;
} }
if (!cl_syncinput) playerAddAngle(p, ang);
{
p->angAdjust += ang;
}
else
{
p->addang(ang);
}
if (var10c >= 441 && var10c <= 581) if (var10c >= 441 && var10c <= 581)
{ {
var104 = (p->MotoSpeed * p->MotoSpeed) >> 8; var104 = (p->MotoSpeed * p->MotoSpeed) >> 8;
@ -2556,14 +2481,7 @@ void onBoatMove(int snum, int psect, int j)
ang = -(p->MotoSpeed >> 2); ang = -(p->MotoSpeed >> 2);
break; break;
} }
if (!cl_syncinput) playerAddAngle(p, ang);
{
p->angAdjust += ang;
}
else
{
p->addang(ang);
}
if (var118 >= 441 && var118 <= 581) if (var118 >= 441 && var118 <= 581)
{ {
p->MotoSpeed = ((p->MotoSpeed >> 1) + (p->MotoSpeed >> 2)) >> 2; p->MotoSpeed = ((p->MotoSpeed >> 1) + (p->MotoSpeed >> 2)) >> 2;
@ -3097,14 +3015,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
case RIFLEGUN_WEAPON: case RIFLEGUN_WEAPON:
p->kickback_pic++; p->kickback_pic++;
if (!cl_syncinput) playerAddHoriz(p, 1);
{
p->horizAdjust += 1;
}
else
{
p->addhoriz(1);
}
p->recoil++; p->recoil++;
if (p->kickback_pic <= 12) if (p->kickback_pic <= 12)
@ -3194,25 +3105,11 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
} }
if (p->kickback_pic == 2) if (p->kickback_pic == 2)
{ {
if (!cl_syncinput) playerAddAngle(p, 16);
{
p->angAdjust += 16;
}
else
{
p->addang(16);
}
} }
else if (p->kickback_pic == 4) else if (p->kickback_pic == 4)
{ {
if (!cl_syncinput) playerAddAngle(p, -16);
{
p->angAdjust -= 16;
}
else
{
p->addang(-16);
}
} }
if (p->kickback_pic > 4) if (p->kickback_pic > 4)
p->kickback_pic = 1; p->kickback_pic = 1;
@ -3238,26 +3135,11 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
} }
if (p->kickback_pic == 2) if (p->kickback_pic == 2)
{ {
int ang = 4; playerAddAngle(p, 4);
if (!cl_syncinput)
{
p->angAdjust += 4;
}
else
{
p->addang(4);
}
} }
else if (p->kickback_pic == 4) else if (p->kickback_pic == 4)
{ {
if (!cl_syncinput) playerAddAngle(p, -4);
{
p->angAdjust -= -4;
}
else
{
p->addang(-4);
}
} }
if (p->kickback_pic > 4) if (p->kickback_pic > 4)
p->kickback_pic = 1; p->kickback_pic = 1;
@ -3305,14 +3187,7 @@ static void operateweapon(int snum, ESyncBits sb_snum, int psect)
{ {
p->posxv -= sintable[(p->getang() + 512) & 2047] << 4; p->posxv -= sintable[(p->getang() + 512) & 2047] << 4;
p->posyv -= sintable[p->getang() & 2047] << 4; p->posyv -= sintable[p->getang() & 2047] << 4;
if (!cl_syncinput) playerAddHoriz(p, 20);
{
p->horizAdjust += 20;
}
else
{
p->addhoriz(20);
}
p->recoil += 20; p->recoil += 20;
} }
if (p->kickback_pic > 20) if (p->kickback_pic > 20)
@ -4196,15 +4071,7 @@ HORIZONLY:
if (!d) if (!d)
d = 1; d = 1;
p->recoil -= d; p->recoil -= d;
playerAddHoriz(p, -d);
if (!cl_syncinput)
{
p->horizAdjust -= d;
}
else
{
p->addhoriz(-d);
}
} }
if (cl_syncinput) if (cl_syncinput)

View file

@ -59,6 +59,7 @@ void pickrandomspot(int snum)
p->bobposy = p->oposy = p->posy = po[i].oy; p->bobposy = p->oposy = p->posy = po[i].oy;
p->oposz = p->posz = po[i].oz; p->oposz = p->posz = po[i].oz;
p->setang(po[i].oa); p->setang(po[i].oa);
p->setoang(po[i].oa);
p->cursectnum = po[i].os; p->cursectnum = po[i].os;
} }