- refactored third person view to only access the clock in its worker function

Timer values in interface code are undefined, these should not access anything that changes at real time.
Also use smoothratio to do the calculation in frame time, not tic time.
This commit is contained in:
Christoph Oelckers 2020-08-31 19:27:22 +02:00
parent a8bb6ba515
commit e5d963c515
7 changed files with 12 additions and 11 deletions

View file

@ -297,7 +297,7 @@ static int osdcmd_third_person_view(CCmdFuncPtr parm)
{
ps[myconnectindex].over_shoulder_on = 1;
cameradist = 0;
cameraclock = gameclock;
cameraclock = INT_MIN;
}
FTA(QUOTE_VIEW_MODE_OFF + ps[myconnectindex].over_shoulder_on, &ps[myconnectindex]);
}

View file

@ -228,7 +228,7 @@ static bool cheatView(cheatseq_t *)
{
ps[myconnectindex].over_shoulder_on = 1;
cameradist = 0;
cameraclock = gameclock;
cameraclock = INT_MIN;
}
//FTA(22,&ps[myconnectindex]); this message makes no sense.
}

View file

@ -258,12 +258,10 @@ void GameInterface::MenuClosed()
auto& gm = ps[myconnectindex].gm;
if (gm & MODE_GAME)
{
// The following lines are here so that you cannot close the menu when no game is running.
if (ud.multimode < 2 && ud.recstat != 2)
{
ready2send = 1;
cameraclock = gameclock;
cameraclock = INT_MIN;
cameradist = 65536;
}
}

View file

@ -116,7 +116,7 @@ void playerLookUp(int snum, ESyncBits actions);
void playerLookDown(int snum, ESyncBits actions);
void playerAimUp(int snum, ESyncBits actions);
void playerAimDown(int snum, ESyncBits actions);
bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum, int ang, int horiz);
bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum, int ang, int horiz, double smoothratio);
void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n);
int hits(int i);
int hitasprite(int i, short* hitsp);

View file

@ -274,7 +274,7 @@ void drawoverlays(double smoothratio)
fi.displaymasks(screenpeek, smoothratio);
}
if (!isRR())
moveclouds();
moveclouds(smoothratio);
}
if (automapMode != am_off)

View file

@ -1215,7 +1215,7 @@ int haskey(int sect, int snum)
//
//---------------------------------------------------------------------------
bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum, int ang, int horiz)
bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum, int ang, int horiz, double smoothratio)
{
spritetype* sp;
int i, nx, ny, nz, hx, hy, hitx, hity, hitz;
@ -1264,9 +1264,12 @@ bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum,
*vx = (*vx) + mulscale16(nx, cameradist);
*vy = (*vy) + mulscale16(ny, cameradist);
*vz = (*vz) + mulscale16(nz, cameradist);
int myclock = ud.levelclock + int(TICSPERFRAME/65536. * smoothratio);
if (cameraclock == INT_MIN) cameraclock = myclock; // third person view was just started.
cameradist = min(cameradist + ((gameclock - cameraclock) << 10), 65536);
cameraclock = gameclock;
cameradist = min(cameradist + ((myclock - cameraclock) << 10), 65536);
cameraclock = myclock;
updatesectorz(*vx, *vy, *vz, vsectnum);

View file

@ -593,7 +593,7 @@ void displayrooms(int snum, double smoothratio)
{
if (cl_viewbob) cposz += p->opyoff + xs_CRoundToInt(fmulscale16(p->pyoff - p->opyoff, smoothratio));
}
else view(p, &cposx, &cposy, &cposz, &sect, cang.asbuild(), choriz.asbuild());
else view(p, &cposx, &cposy, &cposz, &sect, cang.asbuild(), choriz.asbuild(), smoothratio);
cz = hittype[p->i].ceilingz;
fz = hittype[p->i].floorz;