- 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; ps[myconnectindex].over_shoulder_on = 1;
cameradist = 0; cameradist = 0;
cameraclock = gameclock; cameraclock = INT_MIN;
} }
FTA(QUOTE_VIEW_MODE_OFF + ps[myconnectindex].over_shoulder_on, &ps[myconnectindex]); 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; ps[myconnectindex].over_shoulder_on = 1;
cameradist = 0; cameradist = 0;
cameraclock = gameclock; cameraclock = INT_MIN;
} }
//FTA(22,&ps[myconnectindex]); this message makes no sense. //FTA(22,&ps[myconnectindex]); this message makes no sense.
} }

View file

@ -258,12 +258,10 @@ void GameInterface::MenuClosed()
auto& gm = ps[myconnectindex].gm; auto& gm = ps[myconnectindex].gm;
if (gm & MODE_GAME) 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) if (ud.multimode < 2 && ud.recstat != 2)
{ {
ready2send = 1; ready2send = 1;
cameraclock = gameclock; cameraclock = INT_MIN;
cameradist = 65536; cameradist = 65536;
} }
} }

View file

@ -116,7 +116,7 @@ void playerLookUp(int snum, ESyncBits actions);
void playerLookDown(int snum, ESyncBits actions); void playerLookDown(int snum, ESyncBits actions);
void playerAimUp(int snum, ESyncBits actions); void playerAimUp(int snum, ESyncBits actions);
void playerAimDown(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); void tracers(int x1, int y1, int z1, int x2, int y2, int z2, int n);
int hits(int i); int hits(int i);
int hitasprite(int i, short* hitsp); int hitasprite(int i, short* hitsp);

View file

@ -274,7 +274,7 @@ void drawoverlays(double smoothratio)
fi.displaymasks(screenpeek, smoothratio); fi.displaymasks(screenpeek, smoothratio);
} }
if (!isRR()) if (!isRR())
moveclouds(); moveclouds(smoothratio);
} }
if (automapMode != am_off) 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; spritetype* sp;
int i, nx, ny, nz, hx, hy, hitx, hity, hitz; int i, nx, ny, nz, hx, hy, hitx, hity, hitz;
@ -1265,8 +1265,11 @@ bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum,
*vy = (*vy) + mulscale16(ny, cameradist); *vy = (*vy) + mulscale16(ny, cameradist);
*vz = (*vz) + mulscale16(nz, cameradist); *vz = (*vz) + mulscale16(nz, cameradist);
cameradist = min(cameradist + ((gameclock - cameraclock) << 10), 65536); int myclock = ud.levelclock + int(TICSPERFRAME/65536. * smoothratio);
cameraclock = gameclock; if (cameraclock == INT_MIN) cameraclock = myclock; // third person view was just started.
cameradist = min(cameradist + ((myclock - cameraclock) << 10), 65536);
cameraclock = myclock;
updatesectorz(*vx, *vy, *vz, vsectnum); 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)); 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; cz = hittype[p->i].ceilingz;
fz = hittype[p->i].floorz; fz = hittype[p->i].floorz;