- changed all SYNCINPUT #defines into runtime checks so that both parts can be used and consolidated the 4 versions of the SeaSick code.

This commit is contained in:
Christoph Oelckers 2020-07-16 17:59:25 +02:00
parent 2888f29e32
commit 38751d19ac
9 changed files with 256 additions and 266 deletions

View file

@ -230,5 +230,6 @@ void startnewgame(MapRecord* map, int skill);
void setlocalplayerinput(player_struct *pp); void setlocalplayerinput(player_struct *pp);
void PlayerColorChanged(void); void PlayerColorChanged(void);
void nonsharedkeys(void); void nonsharedkeys(void);
void apply_seasick(player_struct* p, double scalefactor);
END_DUKE_NS END_DUKE_NS

View file

@ -85,6 +85,8 @@ enum
MAXLABELLEN = 64 MAXLABELLEN = 64
}; };
G_EXTERN bool synchronized_input;
G_EXTERN char g_loadFromGroupOnly; G_EXTERN char g_loadFromGroupOnly;
G_EXTERN char pus,pub; G_EXTERN char pus,pub;
G_EXTERN char ready2send; G_EXTERN char ready2send;

View file

@ -348,12 +348,14 @@ 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++;
#ifndef SYNCINPUT if (synchronized_input)
g_player[snum].horizSkew = -48; p->addhoriz(-48);
g_player[snum].horizRecenter = true; else
#else {
p->addhoriz(-48); g_player[snum].horizSkew = -48;
#endif g_player[snum].horizRecenter = true;
}
p->return_to_center = 9; p->return_to_center = 9;
if (p->knee_incs > 15) if (p->knee_incs > 15)
{ {
@ -715,12 +717,13 @@ void playerLookLeft(int snum)
OnEvent(EVENT_LOOKLEFT, p->i, snum, -1); OnEvent(EVENT_LOOKLEFT, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{ {
#ifdef SYNCINPUT if (synchronized_input)
p->addlookang(-152); {
p->addrotscrnang(24); p->addlookang(-152);
#else p->addrotscrnang(24);
g_player[snum].lookLeft = true; }
#endif else
g_player[snum].lookLeft = true;
} }
} }
@ -731,12 +734,13 @@ void playerLookRight(int snum)
OnEvent(EVENT_LOOKRIGHT, p->i, snum, -1); OnEvent(EVENT_LOOKRIGHT, p->i, snum, -1);
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{ {
#ifdef SYNCINPUT if (synchronized_input)
p->addlookang(152); {
p->addrotscrnang(24); p->addlookang(152);
#else p->addrotscrnang(24);
g_player[snum].lookRight = true; }
#endif else
g_player[snum].lookRight = true;
} }
} }
@ -748,19 +752,17 @@ void playerCenterView(int snum)
if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0)
{ {
p->return_to_center = 9; p->return_to_center = 9;
#ifndef SYNCINPUT if (!synchronized_input)
g_player[snum].horizRecenter = true; g_player[snum].horizRecenter = true;
#endif
} }
} }
void horizAngleAdjust(int snum, int delta) void horizAngleAdjust(int snum, int delta)
{ {
#ifndef SYNCINPUT // for per-frame input if (synchronized_input)
g_player[snum].horizAngleAdjust = delta; ps[snum].addhoriz(delta);
#else // for synchronous input else
ps[snum].addhoriz(delta); g_player[snum].horizAngleAdjust = delta;
#endif
} }
void playerLookUp(int snum, ESyncBits sb_snum) void playerLookUp(int snum, ESyncBits sb_snum)

View file

@ -1562,9 +1562,8 @@ static void operateJetpack(int snum, ESyncBits sb_snum, int psectlotag, int fz,
p->pycount &= 2047; p->pycount &= 2047;
p->pyoff = sintable[p->pycount] >> 7; p->pyoff = sintable[p->pycount] >> 7;
#ifndef SYNCINPUT if (!synchronized_input)
g_player[snum].horizSkew = 0; g_player[snum].horizSkew = 0;
#endif
if (p->jetpack_on < 11) if (p->jetpack_on < 11)
{ {
@ -2601,10 +2600,11 @@ void processinput_d(int snum)
pi = p->i; pi = p->i;
s = &sprite[pi]; s = &sprite[pi];
#ifndef SYNCINPUT if (!synchronized_input)
g_player[snum].horizAngleAdjust = 0; {
g_player[snum].horizSkew = 0; g_player[snum].horizAngleAdjust = 0;
#endif g_player[snum].horizSkew = 0;
}
sb_snum = PlayerInputBits(snum, SKB_ALL); sb_snum = PlayerInputBits(snum, SKB_ALL);
@ -2641,27 +2641,28 @@ void processinput_d(int snum)
hittype[pi].floorz = fz; hittype[pi].floorz = fz;
hittype[pi].ceilingz = cz; hittype[pi].ceilingz = cz;
#ifdef SYNCINPUT if (synchronized_input)
p->oq16horiz = p->q16horiz;
p->oq16horizoff = p->q16horizoff;
if (p->aim_mode == 0 && p->on_ground && psectlotag != ST_2_UNDERWATER && (sector[psect].floorstat & 2))
{ {
int x = p->posx + (sintable[(p->getang() + 512) & 2047] >> 5); p->oq16horiz = p->q16horiz;
int y = p->posy + (sintable[p->getang() & 2047] >> 5); p->oq16horizoff = p->q16horizoff;
short tempsect = psect;
updatesector(x, y, &tempsect);
if (tempsect >= 0) if (p->aim_mode == 0 && p->on_ground && psectlotag != ST_2_UNDERWATER && (sector[psect].floorstat & 2))
{ {
k = getflorzofslope(psect, x, y); int x = p->posx + (sintable[(p->getang() + 512) & 2047] >> 5);
if (psect == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)) int y = p->posy + (sintable[p->getang() & 2047] >> 5);
p->addhorizoff(mulscale16(j - k, 160)); short tempsect = psect;
updatesector(x, y, &tempsect);
if (tempsect >= 0)
{
k = getflorzofslope(psect, x, y);
if (psect == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))
p->addhorizoff(mulscale16(j - k, 160));
}
} }
if (p->q16horizoff > 0) p->q16horizoff -= ((p->q16horizoff >> 3) + FRACUNIT);
else if (p->q16horizoff < 0) p->q16horizoff += (((-p->q16horizoff) >> 3) + FRACUNIT);
} }
if (p->q16horizoff > 0) p->q16horizoff -= ((p->q16horizoff >> 3) + FRACUNIT);
else if (p->q16horizoff < 0) p->q16horizoff += (((-p->q16horizoff) >> 3) + FRACUNIT);
#endif
if (hz >= 0 && (hz & 49152) == 49152) if (hz >= 0 && (hz & 49152) == 49152)
{ {
@ -2751,10 +2752,11 @@ void processinput_d(int snum)
doubvel = TICSPERFRAME; doubvel = TICSPERFRAME;
#ifdef SYNCINPUT if (synchronized_input)
p->q16rotscrnang -= (p->q16rotscrnang >> 1); if (p->q16rotscrnang < FRACUNIT) p->q16rotscrnang = 0; {
p->q16look_ang -= p->q16look_ang >> 2; if (p->q16look_ang < FRACUNIT) p->q16look_ang = 0; p->q16rotscrnang -= (p->q16rotscrnang >> 1); if (p->q16rotscrnang < FRACUNIT) p->q16rotscrnang = 0;
#endif p->q16look_ang -= p->q16look_ang >> 2; if (p->q16look_ang < FRACUNIT) p->q16look_ang = 0;
}
if (sb_snum & SKB_LOOK_LEFT) if (sb_snum & SKB_LOOK_LEFT)
{ {
@ -2799,15 +2801,16 @@ void processinput_d(int snum)
p->oposz = p->posz; p->oposz = p->posz;
p->opyoff = p->pyoff; p->opyoff = p->pyoff;
#ifdef SYNCINPUT if (synchronized_input)
p->oq16ang = p->q16ang;
if (p->one_eighty_count < 0)
{ {
p->one_eighty_count += 128; p->oq16ang = p->q16ang;
p->addang(128);
if (p->one_eighty_count < 0)
{
p->one_eighty_count += 128;
p->addang(128);
}
} }
#endif
// Shrinking code // Shrinking code
@ -2843,18 +2846,19 @@ void processinput_d(int snum)
} }
else if (sb_avel) //p->ang += syncangvel * constant else if (sb_avel) //p->ang += syncangvel * constant
{ //ENGINE calculates angvel for you { //ENGINE calculates angvel for you
#ifdef SYNCINPUT if (synchronized_input)
// may still be needed later for demo recording {
int tempang; // may still be needed later for demo recording
int tempang;
tempang = sb_avel << 1; tempang = sb_avel << 1; // this is fixed point!
if (psectlotag == 2) p->angvel = (tempang - (tempang >> 3)) * sgn(doubvel); if (psectlotag == 2) p->angvel = (tempang - (tempang >> 3)) * sgn(doubvel);
else p->angvel = tempang * sgn(doubvel); else p->angvel = tempang * sgn(doubvel);
p->addang(p->angvel); p->addang(p->angvel);
p->q16ang &= (2048<<FRACBITS)-1; p->q16ang &= (2048 << FRACBITS) - 1;
#endif }
p->crack_time = 777; p->crack_time = 777;
} }
@ -3063,10 +3067,11 @@ HORIZONLY:
fi.activatebysector(psect, pi); fi.activatebysector(psect, pi);
} }
#ifndef SYNCINPUT if (!synchronized_input)
if (p->return_to_center > 0) {
p->return_to_center--; if (p->return_to_center > 0)
#endif p->return_to_center--;
}
// center_view // center_view
if (sb_snum & SKB_CENTER_VIEW || p->hard_landing) if (sb_snum & SKB_CENTER_VIEW || p->hard_landing)
@ -3089,43 +3094,37 @@ HORIZONLY:
{ // aim_down { // aim_down
playerAimDown(snum, sb_snum); playerAimDown(snum, sb_snum);
} }
#ifdef SYNCINPUT if (synchronized_input)
if (p->return_to_center > 0) {
if ((sb_snum & (SKB_LOOK_UP| SKB_LOOK_DOWN)) == 0) if (p->return_to_center > 0)
{ if ((sb_snum & (SKB_LOOK_UP | SKB_LOOK_DOWN)) == 0)
p->return_to_center--; {
p->q16horiz += 33*FRACUNIT - (p->q16horiz / 3); p->return_to_center--;
} p->q16horiz += 33 * FRACUNIT - (p->q16horiz / 3);
#endif }
}
if (p->hard_landing > 0) if (p->hard_landing > 0)
{ {
#ifndef SYNCINPUT if (!synchronized_input)
g_player[snum].horizSkew = (-(p->hard_landing << 4)) * FRACUNIT; g_player[snum].horizSkew = (-(p->hard_landing << 4)) * FRACUNIT;
#else else
p->addhoriz(-(p->hard_landing << 4)); p->addhoriz(-(p->hard_landing << 4));
#endif
p->hard_landing--; p->hard_landing--;
} }
#if 0 if (synchronized_input)
if (p->aim_mode)
p->horiz += sync[snum].horz >> 1;
else
{ {
if (p->horiz > 95 && p->horiz < 105) p->horiz = 100; if (p->aim_mode)
if (p->horizoff > -5 && p->horizoff < 5) p->horizoff = 0; p->q16horiz += (sync[snum].q16horz >> 1);
else
{
if (p->q16horiz > F16(95) && p->q16horiz < F16(105)) p->sethoriz(100);
if (p->q16horizoff > F16(-5) && p->q16horizoff < F16(5)) p->sethorizoff(0);
}
p->q16horiz = clamp(p->q16horiz, F16(HORIZ_MIN), F16(HORIZ_MAX));
} }
p->horiz = clamp(p->horiz, HORIZ_MIN, HORIZ_MAX);
if (centerHoriz)
{
if (p->gethoriz() > 95 && pPlayer->gethoriz() < 105) pPlayer->sethoriz(100);
if (p->gethorizoff() > -5 && pPlayer->gethorizoff < 5) pPlayer->sethorizoff(0);
}
#endif
//Shooting code/changes //Shooting code/changes
if (p->show_empty_weapon > 0) if (p->show_empty_weapon > 0)

View file

@ -34,6 +34,33 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
BEGIN_DUKE_NS BEGIN_DUKE_NS
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void apply_seasick(player_struct* p, double scalefactor)
{
if (isRRRA() && p->SeaSick)
{
if (p->SeaSick < 250)
{
if (p->SeaSick >= 180)
p->addrotscrnang(24*scalefactor);
else if (p->SeaSick >= 130)
p->addrotscrnang(-24*scalefactor);
else if (p->SeaSick >= 70)
p->addrotscrnang(24*scalefactor);
else if (p->SeaSick >= 20)
p->addrotscrnang(-24*scalefactor);
}
if (p->SeaSick < 250)
p->addlookang(((krand() & 255) - 128) * scalefactor);
}
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// //
// //
@ -3473,27 +3500,28 @@ void processinput_r(int snum)
hittype[pi].floorz = fz; hittype[pi].floorz = fz;
hittype[pi].ceilingz = cz; hittype[pi].ceilingz = cz;
#ifdef SYNCINPUT if (synchronized_input)
p->oq16horiz = p->q16horiz;
p->oq16horizoff = p->q16horizoff;
if (p->aim_mode == 0 && p->on_ground && psectlotag != ST_2_UNDERWATER && (sector[psect].floorstat & 2))
{ {
int x = p->posx + (sintable[(p->getang() + 512) & 2047] >> 5); p->oq16horiz = p->q16horiz;
int y = p->posy + (sintable[p->getang() & 2047] >> 5); p->oq16horizoff = p->q16horizoff;
short tempsect = psect;
updatesector(x, y, &tempsect);
if (tempsect >= 0) if (p->aim_mode == 0 && p->on_ground && psectlotag != ST_2_UNDERWATER && (sector[psect].floorstat & 2))
{ {
k = getflorzofslope(psect, x, y); int x = p->posx + (sintable[(p->getang() + 512) & 2047] >> 5);
if (psect == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)) int y = p->posy + (sintable[p->getang() & 2047] >> 5);
p->addhorizoff(mulscale16(j - k, 160)); short tempsect = psect;
updatesector(x, y, &tempsect);
if (tempsect >= 0)
{
k = getflorzofslope(psect, x, y);
if (psect == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))
p->addhorizoff(mulscale16(j - k, 160));
}
} }
if (p->q16horizoff > 0) p->q16horizoff -= ((p->q16horizoff >> 3) + FRACUNIT);
else if (p->q16horizoff < 0) p->q16horizoff += (((-p->q16horizoff) >> 3) + FRACUNIT);
} }
if (p->q16horizoff > 0) p->q16horizoff -= ((p->q16horizoff >> 3) + FRACUNIT);
else if (p->q16horizoff < 0) p->q16horizoff += (((-p->q16horizoff) >> 3) + FRACUNIT);
#endif
if (hz >= 0 && (hz & 49152) == 49152) if (hz >= 0 && (hz & 49152) == 49152)
{ {
@ -3639,10 +3667,11 @@ void processinput_r(int snum)
doubvel = TICSPERFRAME; doubvel = TICSPERFRAME;
#ifdef SYNCINPUT if (synchronized_input)
p->q16rotscrnang -= (p->q16rotscrnang >> 1); if (p->q16rotscrnang < FRACUNIT) p->q16rotscrnang = 0; {
p->q16look_ang -= p->q16look_ang >> 2; if (p->q16look_ang < FRACUNIT) p->q16look_ang = 0; p->q16rotscrnang -= (p->q16rotscrnang >> 1); if (p->q16rotscrnang < FRACUNIT) p->q16rotscrnang = 0;
#endif p->q16look_ang -= p->q16look_ang >> 2; if (p->q16look_ang < FRACUNIT) p->q16look_ang = 0;
}
if ((sb_snum & SKB_LOOK_LEFT) && !p->OnMotorcycle) if ((sb_snum & SKB_LOOK_LEFT) && !p->OnMotorcycle)
{ {
@ -3654,24 +3683,10 @@ void processinput_r(int snum)
playerLookRight(snum); playerLookRight(snum);
} }
#ifdef SYNCINPUT if (synchronized_input)
if (isRRRA() && p->SeaSick)
{ {
if (p->SeaSick < 250) apply_seasick(p, 1);
{
if (p->SeaSick >= 180)
p->addrotscrnang(24);
else if (p->SeaSick >= 130)
p->addrotscrnang(-24);
else if (p->SeaSick >= 70)
p->addrotscrnang(24);
else if (p->SeaSick >= 20)
p->addrotscrnang(-24);
}
if (p->SeaSick < 250)
p->addlookang((krand() & 255) - 128);
} }
#endif
if (p->on_crane >= 0) if (p->on_crane >= 0)
goto HORIZONLY; goto HORIZONLY;
@ -3706,15 +3721,16 @@ void processinput_r(int snum)
p->oposz = p->posz; p->oposz = p->posz;
p->opyoff = p->pyoff; p->opyoff = p->pyoff;
#ifdef SYNCINPUT if (synchronized_input)
p->oq16ang = p->q16ang;
if (p->one_eighty_count < 0)
{ {
p->one_eighty_count += 128; p->oq16ang = p->q16ang;
p->addang(128);
if (p->one_eighty_count < 0)
{
p->one_eighty_count += 128;
p->addang(128);
}
} }
#endif
// Shrinking code // Shrinking code
@ -3765,18 +3781,19 @@ void processinput_r(int snum)
} }
else if (sb_avel) //p->ang += syncangvel * constant else if (sb_avel) //p->ang += syncangvel * constant
{ //ENGINE calculates angvel for you { //ENGINE calculates angvel for you
#ifdef SYNCINPUT if (synchronized_input)
// may still be needed later for demo recording {
int tempang; // may still be needed later for demo recording
int tempang;
tempang = sync[snum].avel << 1; tempang = sb_avel << 1; // this is fixed point!
if (psectlotag == 2) p->angvel = (tempang - (tempang >> 3)) * sgn(doubvel); if (psectlotag == 2) p->angvel = (tempang - (tempang >> 3)) * sgn(doubvel);
else p->angvel = tempang * sgn(doubvel); else p->angvel = tempang * sgn(doubvel);
p->ang += p->angvel; p->addang(p->angvel);
p->ang &= 2047; p->q16ang &= (2048 << FRACBITS) - 1;
#endif }
p->crack_time = 777; p->crack_time = 777;
} }
@ -4101,10 +4118,8 @@ HORIZONLY:
return; return;
} }
#ifndef SYNCINPUT if (!synchronized_input && p->return_to_center > 0)
if (p->return_to_center > 0)
p->return_to_center--; p->return_to_center--;
#endif
if (sb_snum & SKB_CENTER_VIEW || p->hard_landing) if (sb_snum & SKB_CENTER_VIEW || p->hard_landing)
{ {
@ -4134,43 +4149,37 @@ HORIZONLY:
p->recoil -= d; p->recoil -= d;
p->addhoriz(-d); p->addhoriz(-d);
} }
#ifdef SYNCINPUT if (synchronized_input)
else if (p->return_to_center > 0) {
if ((sb_snum & (SKB_LOOK_UP| SKB_LOOK_DOWN)) == 0) if (p->return_to_center > 0)
{ if ((sb_snum & (SKB_LOOK_UP | SKB_LOOK_DOWN)) == 0)
p->return_to_center--; {
p->q16horiz += 33*FRACUNIT - (p->q16horiz / 3); p->return_to_center--;
} p->q16horiz += 33 * FRACUNIT - (p->q16horiz / 3);
#endif }
}
if (p->hard_landing > 0) if (p->hard_landing > 0)
{ {
#ifndef SYNCINPUT if (!synchronized_input)
g_player[snum].horizSkew = (-(p->hard_landing << 4)) * FRACUNIT; g_player[snum].horizSkew = (-(p->hard_landing << 4)) * FRACUNIT;
#else else
p->addhoriz(-(p->hard_landing << 4)); p->addhoriz(-(p->hard_landing << 4));
#endif
p->hard_landing--; p->hard_landing--;
} }
#ifdef SYNCINPUT if (synchronized_input)
if (p->aim_mode)
p->horiz += sync[snum].horz >> 1;
else if (!p->recoil)
{ {
if (p->horiz > 95 && p->horiz < 105) p->horiz = 100; if (p->aim_mode)
if (p->horizoff > -5 && p->horizoff < 5) p->horizoff = 0; p->q16horiz += (sync[snum].q16horz >> 1);
else
{
if (p->q16horiz > F16(95) && p->q16horiz < F16(105)) p->sethoriz(100);
if (p->q16horizoff > F16(-5) && p->q16horizoff < F16(5)) p->sethorizoff(0);
}
p->q16horiz = clamp(p->q16horiz, F16(HORIZ_MIN), F16(HORIZ_MAX));
} }
p->horiz = clamp(p->horiz, HORIZ_MIN, HORIZ_MAX);
if (centerHoriz && !p->recoil)
{
if (p->gethoriz() > 95 && pPlayer->gethoriz() < 105) pPlayer->sethoriz(100);
if (p->gethorizoff() > -5 && pPlayer->gethorizoff < 5) pPlayer->sethorizoff(0);
}
#endif
//Shooting code/changes //Shooting code/changes
if (p->show_empty_weapon > 0) if (p->show_empty_weapon > 0)

View file

@ -535,25 +535,31 @@ void displayrooms(int snum, int smoothratio)
setdrugmode(p, i); setdrugmode(p, i);
} }
#ifndef SYNCINPUT if (!synchronized_input)
renderSetRollAngle(p->getrotscrnang()); renderSetRollAngle(p->getrotscrnang());
#else else
renderSetRollAngle(p->orotscrnang + mulscale16(((p->rotscrnang - p->orotscrnang + 1024) & 2047) - 1024, smoothratio)); {
p->orotscrnang = p->rotscrnang; // JBF: save it for next time // The fixed point fuckery at play here means we cannot do the interpolation at full precision.
#endif auto oa = p->oq16rotscrnang >> FRACUNIT;
renderSetRollAngle(oa + mulscale16(((p->getrotscrnang() - oa + 1024) & 2047) - 1024, smoothratio));
p->oq16rotscrnang = p->q16rotscrnang; // JBF: save it for next time
}
if ((snum == myconnectindex) && (numplayers > 1)) if ((snum == myconnectindex) && (numplayers > 1))
{ {
cposx = omyx + mulscale16((int)(myx - omyx), smoothratio); cposx = omyx + mulscale16((int)(myx - omyx), smoothratio);
cposy = omyy + mulscale16((int)(myy - omyy), smoothratio); cposy = omyy + mulscale16((int)(myy - omyy), smoothratio);
cposz = omyz + mulscale16((int)(myz - omyz), smoothratio); cposz = omyz + mulscale16((int)(myz - omyz), smoothratio);
#ifdef SYNCINPUT if (synchronized_input)
cang = omyang + mulscale16((int)(((myang + 1024 - omyang) & 2047) - 1024), smoothratio); {
choriz = omyhoriz + omyhorizoff + mulscale16((int)(myhoriz + myhorizoff - omyhoriz - omyhorizoff), smoothratio); cang = omyang + mulscale16((int)(((myang + 1024 - omyang) & 2047) - 1024), smoothratio);
#else choriz = omyhoriz + omyhorizoff + mulscale16((int)(myhoriz + myhorizoff - omyhoriz - omyhorizoff), smoothratio);
cang = myang; }
choriz = (myhoriz + myhorizoff); else
#endif {
cang = myang;
choriz = (myhoriz + myhorizoff);
}
sect = mycursectnum; sect = mycursectnum;
} }
else else
@ -561,15 +567,19 @@ void displayrooms(int snum, int smoothratio)
cposx = p->oposx + mulscale16((int)(p->posx - p->oposx), smoothratio); cposx = p->oposx + mulscale16((int)(p->posx - p->oposx), smoothratio);
cposy = p->oposy + mulscale16((int)(p->posy - p->oposy), smoothratio); cposy = p->oposy + mulscale16((int)(p->posy - p->oposy), smoothratio);
cposz = p->oposz + mulscale16((int)(p->posz - p->oposz), smoothratio); cposz = p->oposz + mulscale16((int)(p->posz - p->oposz), smoothratio);
#ifdef SYNCINPUT if (synchronized_input /*|| smoothcamera*/)
// Original code for when the values are passed through the sync struct {
cang = p->getoang() + mulscale16((int)(((p->getang() + 1024 - p->getoang()) & 2047) - 1024), smoothratio); // Original code for when the values are passed through the sync struct
choriz = p->ohoriz+p->ohorizoff+mulscale16((int)(p->gethorizsum()-p->ohoriz-p->ohorizoff),smoothratio); cang = p->getoang() + mulscale16((int)(((p->getang() + 1024 - p->getoang()) & 2047) - 1024), smoothratio);
#else int ohorz = (p->oq16horiz + p->oq16horizoff) >> FRACBITS;
// This is for real time updating of the view direction. choriz = ohorz + mulscale16((int)(p->gethorizsum() - ohorz), smoothratio);
cang = p->getang(); }
choriz = p->gethorizsum(); else
#endif {
// This is for real time updating of the view direction.
cang = p->getang();
choriz = p->gethorizsum();
}
} }
cang += p->getlookang(); cang += p->getlookang();

View file

@ -195,9 +195,11 @@ struct player_struct
int getlookang() { return q16look_ang >> FRACBITS; } int getlookang() { return q16look_ang >> FRACBITS; }
void setlookang(int b) { q16look_ang = b << FRACBITS; } void setlookang(int b) { q16look_ang = b << FRACBITS; }
void addlookang(int b) { q16look_ang += b << FRACBITS; } void addlookang(int b) { q16look_ang += b << FRACBITS; }
void addlookang(double b) { q16look_ang += int(b *65536.); }
int getrotscrnang() { return q16rotscrnang >> FRACBITS; } int getrotscrnang() { return q16rotscrnang >> FRACBITS; }
void setrotscrnang(int b) { q16rotscrnang = b << FRACBITS; } void setrotscrnang(int b) { q16rotscrnang = b << FRACBITS; }
void addrotscrnang(int b) { q16rotscrnang += b << FRACBITS; } void addrotscrnang(int b) { q16rotscrnang += b << FRACBITS; }
void addrotscrnang(double b) { q16rotscrnang += int(b *65536.); }
int getang() { return q16ang >> FRACBITS; } int getang() { return q16ang >> FRACBITS; }
int getoang() { return oq16ang >> FRACBITS; } int getoang() { return oq16ang >> FRACBITS; }
void setang(int v, bool smooth = false) { q16ang = v << FRACBITS; } void setang(int v, bool smooth = false) { q16ang = v << FRACBITS; }

View file

@ -113,6 +113,7 @@ void P_GetInput(int const playerNum)
auto const currentHiTicks = timerGetHiTicks(); auto const currentHiTicks = timerGetHiTicks();
elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks; elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks;
thisPlayer.lastInputTicks = currentHiTicks; thisPlayer.lastInputTicks = currentHiTicks;
double scaleAdjust = elapsedInputTicks * REALGAMETICSPERSEC / 1000.0;
if (paused) if (paused)
@ -384,20 +385,26 @@ void P_GetInput(int const playerNum)
if (!(movementLocked & IL_NOANGLE)) if (!(movementLocked & IL_NOANGLE))
{ {
localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel); localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel);
pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF; if (!synchronized_input)
if (input.q16avel)
{ {
pPlayer->one_eighty_count = 0; pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF;
if (input.q16avel)
{
pPlayer->one_eighty_count = 0;
}
} }
} }
if (!(movementLocked & IL_NOHORIZ)) if (!(movementLocked & IL_NOHORIZ))
{ {
localInput.q16horz = fix16_clamp(fix16_sadd(localInput.q16horz, input.q16horz), F16(-MAXHORIZVEL), F16(MAXHORIZVEL)); localInput.q16horz = fix16_clamp(fix16_sadd(localInput.q16horz, input.q16horz), F16(-MAXHORIZVEL), F16(MAXHORIZVEL));
pPlayer->q16horiz = fix16_clamp(fix16_sadd(pPlayer->q16horiz, input.q16horz), F16(HORIZ_MIN), F16(HORIZ_MAX)); if (!synchronized_input)
pPlayer->q16horiz = fix16_clamp(fix16_sadd(pPlayer->q16horiz, input.q16horz), F16(HORIZ_MIN), F16(HORIZ_MAX));
} }
} }
if (synchronized_input) return;
// don't adjust rotscrnang and look_ang if dead. // don't adjust rotscrnang and look_ang if dead.
if (pSprite->extra > 0) if (pSprite->extra > 0)
{ {
@ -428,22 +435,7 @@ void P_GetInput(int const playerNum)
pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, fix16_max(fix16_one, fix16_from_dbl(scaleAdjustmentToInterval(-pPlayer->one_eighty_count / ONEEIGHTYSCALE)))) & 0x7FFFFFF; pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, fix16_max(fix16_one, fix16_from_dbl(scaleAdjustmentToInterval(-pPlayer->one_eighty_count / ONEEIGHTYSCALE)))) & 0x7FFFFFF;
} }
if (isRRRA() && pPlayer->SeaSick) apply_seasick(pPlayer, scaleAdjust);
{
if (pPlayer->SeaSick < 250)
{
if (pPlayer->SeaSick >= 180)
pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
else if (pPlayer->SeaSick >= 130)
pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
else if (pPlayer->SeaSick >= 70)
pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
else if (pPlayer->SeaSick >= 20)
pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
}
if (pPlayer->SeaSick < 250)
pPlayer->q16look_ang = fix16_sadd(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval((krand2()&255)-128)));
}
} }
// A horiz diff of 128 equal 45 degrees, so we convert horiz to 1024 angle units // A horiz diff of 128 equal 45 degrees, so we convert horiz to 1024 angle units
@ -512,6 +504,7 @@ void P_GetInputMotorcycle(int playerNum)
auto const currentHiTicks = timerGetHiTicks(); auto const currentHiTicks = timerGetHiTicks();
elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks; elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks;
thisPlayer.lastInputTicks = currentHiTicks; thisPlayer.lastInputTicks = currentHiTicks;
double scaleAdjust = elapsedInputTicks * REALGAMETICSPERSEC / 1000.0;
if (paused) if (paused)
{ {
@ -708,29 +701,14 @@ void P_GetInputMotorcycle(int playerNum)
if (!(movementLocked & IL_NOANGLE)) if (!(movementLocked & IL_NOANGLE))
{ {
localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel); localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel);
pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF; if (!synchronized_input) pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF;
} }
} }
// don't adjust rotscrnang and look_ang if dead. // don't adjust rotscrnang and look_ang if dead.
if (pSprite->extra > 0) if (pSprite->extra > 0 && !synchronized_input)
{ {
if (isRRRA() && pPlayer->SeaSick) apply_seasick(pPlayer, scaleAdjust);
{
if (pPlayer->SeaSick < 250)
{
if (pPlayer->SeaSick >= 180)
pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
else if (pPlayer->SeaSick >= 130)
pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
else if (pPlayer->SeaSick >= 70)
pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
else if (pPlayer->SeaSick >= 20)
pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
}
if (pPlayer->SeaSick < 250)
pPlayer->q16look_ang = fix16_sadd(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval((krand2()&255)-128)));
}
} }
} }
@ -744,6 +722,8 @@ void P_GetInputBoat(int playerNum)
auto const currentHiTicks = timerGetHiTicks(); auto const currentHiTicks = timerGetHiTicks();
elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks; elapsedInputTicks = currentHiTicks - thisPlayer.lastInputTicks;
thisPlayer.lastInputTicks = currentHiTicks; thisPlayer.lastInputTicks = currentHiTicks;
double scaleAdjust = elapsedInputTicks * REALGAMETICSPERSEC / 1000.0;
if (paused) if (paused)
{ {
if (!(pPlayer->gm&MODE_MENU)) if (!(pPlayer->gm&MODE_MENU))
@ -922,29 +902,14 @@ void P_GetInputBoat(int playerNum)
if (!(movementLocked & IL_NOANGLE)) if (!(movementLocked & IL_NOANGLE))
{ {
localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel); localInput.q16avel = fix16_sadd(localInput.q16avel, input.q16avel);
pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF; if (!synchronized_input) pPlayer->q16ang = fix16_sadd(pPlayer->q16ang, input.q16avel) & 0x7FFFFFF;
} }
} }
// don't adjust rotscrnang and look_ang if dead. // don't adjust rotscrnang and look_ang if dead.
if (pSprite->extra > 0) if (pSprite->extra > 0 && !synchronized_input)
{ {
if (isRRRA() && pPlayer->SeaSick) apply_seasick(pPlayer, scaleAdjust);
{
if (pPlayer->SeaSick < 250)
{
if (pPlayer->SeaSick >= 180)
pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
else if (pPlayer->SeaSick >= 130)
pPlayer->q16rotscrnang = fix16_ssub(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
else if (pPlayer->SeaSick >= 70)
pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
else if (pPlayer->SeaSick >= 20)
pPlayer->q16rotscrnang = fix16_sadd(pPlayer->q16rotscrnang, fix16_from_dbl(scaleAdjustmentToInterval(24)));
}
if (pPlayer->SeaSick < 250)
pPlayer->q16look_ang = fix16_sadd(pPlayer->q16look_ang, fix16_from_dbl(scaleAdjustmentToInterval((krand2()&255)-128)));
}
} }
} }

View file

@ -199,7 +199,7 @@ struct Screen native
native static vararg void DrawText(Font font, int normalcolor, double x, double y, String text, ...); native static vararg void DrawText(Font font, int normalcolor, double x, double y, String text, ...);
native static void DrawLine(int x0, int y0, int x1, int y1, Color color, int alpha = 255); native static void DrawLine(int x0, int y0, int x1, int y1, Color color, int alpha = 255);
native static void DrawThickLine(int x0, int y0, int x1, int y1, double thickness, Color color, int alpha = 255); native static void DrawThickLine(int x0, int y0, int x1, int y1, double thickness, Color color, int alpha = 255);
native static Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom=false, bool handleaspect=true); native static Vector2, Vector2 VirtualToRealCoords(Vector2 pos, Vector2 size, Vector2 vsize, bool vbottom=false, int handleaspect=0);
native static double GetAspectRatio(); native static double GetAspectRatio();
native static void SetClipRect(int x, int y, int w, int h); native static void SetClipRect(int x, int y, int w, int h);
native static void ClearClipRect(); native static void ClearClipRect();