- re-factor interpolation backups into discrete functions for calling from multiple places.

Fixes #66.
This commit is contained in:
Mitchell Richters 2020-07-30 08:24:27 +10:00
parent 5ed624a48d
commit 2260c2353d
6 changed files with 71 additions and 33 deletions

View file

@ -244,4 +244,8 @@ void dointerpolations(int smoothratio);
int* animateptr(int i);
void updateviewport(void);
void backuppos(player_struct* p, bool clipping = true);
void backuplook(player_struct* p);
void backupview(player_struct* p);
END_DUKE_NS

View file

@ -178,6 +178,13 @@ inline int calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk)
return CalcSmoothRatio(totalclk, ototalclk, REALGAMETICSPERSEC);
}
inline void backupplayer(player_struct* p)
{
backuppos(p);
backuplook(p);
backupview(p);
}
// These should be the only places converting between level numbers and volume/map pairs
constexpr inline int levelnum(int vol, int map)

View file

@ -652,11 +652,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz)
// p->bobcounter += 32;
}
p->oposx = p->posx;
p->oposy = p->posy;
p->oposz = p->posz;
p->oq16ang = p->q16ang;
p->opyoff = p->pyoff;
backupplayer(p);
p->sethoriz(100);
p->q16horizoff = 0;
@ -854,6 +850,56 @@ void applylook(int snum, double factor)
//
//---------------------------------------------------------------------------
void backuppos(player_struct* p, bool clipping)
{
if (clipping)
{
p->oposx = p->posx;
p->oposy = p->posy;
}
else
{
p->posx = p->oposx;
p->posy = p->oposy;
}
p->oposz = p->posz;
p->bobposx = p->posx;
p->bobposy = p->posy;
p->opyoff = p->pyoff;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void backuplook(player_struct* p)
{
p->oq16ang = p->q16ang;
p->oq16look_ang = p->q16look_ang;
p->oq16rotscrnang = p->q16rotscrnang;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void backupview(player_struct* p)
{
p->oq16horiz = p->q16horiz;
p->oq16horizoff = p->q16horizoff;
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void checklook(int snum, int sb_snum)
{
auto p = &ps[snum];
@ -879,9 +925,7 @@ void checklook(int snum, int sb_snum)
p->lookRight = true;
}
}
p->oq16ang = p->q16ang;
p->oq16look_ang = p->q16look_ang;
p->oq16rotscrnang = p->q16rotscrnang;
backuplook(p);
if (cl_syncinput)
applylook(snum, 1);

View file

@ -2634,8 +2634,7 @@ void processinput_d(int snum)
if (cl_syncinput)
{
p->oq16horiz = p->q16horiz;
p->oq16horizoff = p->q16horizoff;
backupview(p);
calcviewpitch(p, 1);
}
@ -2749,21 +2748,13 @@ void processinput_d(int snum)
if (ud.clipping == 0 && (sector[p->cursectnum].floorpicnum == MIRROR || p->cursectnum < 0 || p->cursectnum >= MAXSECTORS))
{
p->posx = p->oposx;
p->posy = p->oposy;
backuppos(p, false);
}
else
{
p->oposx = p->posx;
p->oposy = p->posy;
backuppos(p);
}
p->bobposx = p->posx;
p->bobposy = p->posy;
p->oposz = p->posz;
p->opyoff = p->pyoff;
// Shrinking code
i = 40;

View file

@ -3643,21 +3643,13 @@ void processinput_r(int snum)
if (ud.clipping == 0 && (sector[p->cursectnum].floorpicnum == MIRROR || p->cursectnum < 0 || p->cursectnum >= MAXSECTORS))
{
p->posx = p->oposx;
p->posy = p->oposy;
backuppos(p, false);
}
else
{
p->oposx = p->posx;
p->oposy = p->posy;
backuppos(p);
}
p->bobposx = p->posx;
p->bobposy = p->posy;
p->oposz = p->posz;
p->opyoff = p->pyoff;
// Shrinking code
i = 40;

View file

@ -111,7 +111,7 @@ void resetplayerstats(int snum)
p->footprintshade = 0;
p->jumping_toggle = 0;
p->sethoriz(140); //!!
//p->oq16horiz = p->q16horiz;
p->oq16horiz = p->q16horiz;
p->sethorizoff(0);
p->bobcounter = 0;
p->on_ground = 0;
@ -140,8 +140,8 @@ void resetplayerstats(int snum)
p->setlookang(512 - ((currentLevel->levelNumber & 1) << 10));
p->q16rotscrnang = 0;
//p->orotscrnang = 1; // JBF 20031220
p->setrotscrnang(0);
p->oq16rotscrnang = p->q16rotscrnang;
p->newowner =-1;
p->jumping_counter = 0;
p->hard_landing = 0;