From 222e593437c20f70cc725c07a38f49b3d9a72d67 Mon Sep 17 00:00:00 2001 From: pogokeen Date: Tue, 27 Aug 2019 13:39:54 +0000 Subject: [PATCH] Change some clocks to support sub-tick precision using a new class, ClockTicks. Using that higher precision, interpolate at a higher granularity. Further, truncate the target interpolation time to vertical blank boundaries to avoid producing temporal artifacts. Fix issues caused by interpolation calculations being handled differently in multiple places (and fix cases where smoothratios were being thrown away only to be redone without checking all proper conditions). Ensure ClockTicks changes do not break other targets (EKenBuild, VoidSW), but note any interpolation there is not similarly updated. git-svn-id: https://svn.eduke32.com/eduke32@8050 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/build/src/build.cpp # source/build/src/sdlayer.cpp --- source/build/include/baselayer.h | 2 +- source/build/include/build.h | 4 +- source/build/include/clockticks.hpp | 153 ++++++++++++++++++++++++++++ source/build/include/compat.h | 1 + source/build/include/editor.h | 4 +- source/build/src/2d.cpp | 2 +- source/build/src/engine.cpp | 2 +- source/build/src/osd.cpp | 4 +- source/build/src/sdlayer.cpp | 8 +- source/build/src/timer.cpp | 5 +- source/build/src/winlayer.cpp | 5 +- source/duke3d/src/actors.cpp | 8 +- source/duke3d/src/anim.cpp | 2 +- source/duke3d/src/astub.cpp | 34 +++---- source/duke3d/src/cheats.cpp | 2 +- source/duke3d/src/demo.cpp | 6 +- source/duke3d/src/game.cpp | 33 +++--- source/duke3d/src/game.h | 24 ++++- source/duke3d/src/gameexec.cpp | 2 +- source/duke3d/src/global.h | 6 +- source/duke3d/src/m32common.cpp | 2 +- source/duke3d/src/menus.cpp | 36 +++---- source/duke3d/src/menus.h | 4 +- source/duke3d/src/network.cpp | 6 +- source/duke3d/src/player.cpp | 6 +- source/duke3d/src/premap.cpp | 6 +- source/duke3d/src/savegame.cpp | 8 +- source/duke3d/src/sbar.cpp | 6 +- source/duke3d/src/screens.cpp | 24 ++--- source/duke3d/src/sector.cpp | 6 +- source/kenbuild/src/game.cpp | 30 +++--- source/sw/src/anim.cpp | 2 +- source/sw/src/draw.cpp | 12 +-- source/sw/src/game.cpp | 4 +- source/sw/src/jnstub.cpp | 4 +- source/sw/src/jplayer.cpp | 4 +- source/sw/src/jsector.cpp | 2 +- source/sw/src/menus.cpp | 20 ++-- source/sw/src/network.cpp | 4 +- source/sw/src/setup.cpp | 2 +- source/sw/src/weapon.cpp | 6 +- 41 files changed, 339 insertions(+), 162 deletions(-) create mode 100644 source/build/include/clockticks.hpp diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index 2d0da3fbd..0296e4298 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -44,7 +44,7 @@ extern int32_t r_usenewaspect, newaspect_enable; extern int32_t r_fpgrouscan; extern int32_t setaspect_new_use_dimen; extern uint32_t r_screenxy; -extern int32_t xres, yres, bpp, fullscreen, bytesperline; +extern int32_t xres, yres, bpp, fullscreen, bytesperline, refreshfreq; extern intptr_t frameplace; extern char offscreenrendering; extern int32_t nofog; diff --git a/source/build/include/build.h b/source/build/include/build.h index 99faf95f0..af1e16e84 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -723,8 +723,8 @@ EXTERN int16_t numsectors, numwalls; EXTERN int32_t display_mirror; // totalclocklock: the totalclock value that is backed up once on each // drawrooms() and is used for animateoffs(). -EXTERN int32_t totalclock, totalclocklock; -static inline int32_t BGetTime(void) { return totalclock; } +EXTERN ClockTicks totalclock, totalclocklock; +static inline int32_t BGetTime(void) { return (int32_t) totalclock; } EXTERN int32_t numframes, randomseed; EXTERN int16_t sintable[2048]; diff --git a/source/build/include/clockticks.hpp b/source/build/include/clockticks.hpp new file mode 100644 index 000000000..c8f478121 --- /dev/null +++ b/source/build/include/clockticks.hpp @@ -0,0 +1,153 @@ +/* + * clockticks.hpp + * ClockTicks is a class that tracks signed ticks & fractional ticks for + * high granularity game clocks that are backwards-compatible with + * Build integer timing + * + * Copyright © 2019, Alex Dawson. All rights reserved. + */ + +#ifndef CLOCKTICKS_HPP_ +#define CLOCKTICKS_HPP_ + +#include + +int timerGetRate(void); + +//POGO: BUILD/EDuke32 uses right shifts on signed variables expecting arithmetic shifts. +// This was already non-portable, and we carry that assumption forth here +// (so we might as well check it). +EDUKE32_STATIC_ASSERT(-1 >> 1 == -1); + +class ClockTicks +{ +public: + ClockTicks() : ClockTicks(0, 0) {}; + ClockTicks(int32_t ticks) : ClockTicks(ticks, 0) {}; + ClockTicks(int32_t ticks, uint32_t fraction) { set(ticks, fraction); }; + ClockTicks(const ClockTicks&) = default; + + int64_t getFraction() const + { + return (ticksS32 & FRACTION_MASK) >> 16 | ((ticksS32 < 0) ? VALUE_MASK : 0); + } + int64_t setFraction(uint16_t fraction) + { + return ticksS32 = (ticksS32 & WHOLE_MASK) | ((ticksS32 < 0) ? ((int64_t) 0 - fraction) & FRACTION_16_MASK : fraction) << 16; + } + int64_t set(int32_t ticks, uint16_t fraction) + { + ticksS32 = ((uint64_t) ticks) << 32 | ((ticks < 0) ? ((int64_t) 0 - fraction) & FRACTION_16_MASK : fraction) << 16; + update(); + return ticksS32; + } + + int64_t toScale16() const + { + return ticksS32 >> 16; + } + ClockTicks& setFromScale16(int64_t ticksScale16) + { + ticksS32 = ticksScale16 << 16; + update(); + return *this; + } + static ClockTicks fromScale16(int64_t ticksScale16) + { + ClockTicks ct; + ct.setFromScale16(ticksScale16); + return ct; + } + + ClockTicks& operator=(const ClockTicks& rhs) + { + ticksS32 = rhs.ticksS32; + update(); + return *this; + }; + ClockTicks& operator+=(const ClockTicks& rhs) + { + ticksS32 += rhs.ticksS32; + update(); + return *this; + }; + ClockTicks& operator-=(const ClockTicks& rhs) + { + ticksS32 -= rhs.ticksS32; + update(); + return *this; + }; + ClockTicks& operator*=(const ClockTicks& rhs) + { + ticksS32 = (ticksS32>>16)*(rhs.ticksS32>>16) >> 16; + update(); + return *this; + }; + ClockTicks& operator/=(const ClockTicks& rhs) + { + ticksS32 = ticksS32/rhs.ticksS32 << 32; + update(); + return *this; + }; + ClockTicks& operator%=(const ClockTicks& rhs) + { + ticksS32 %= rhs.ticksS32; + update(); + return *this; + }; + ClockTicks& operator<<=(int32_t rhs) + { + ticksS32 = ticksS32 << rhs; + update(); + return *this; + }; + ClockTicks& operator>>=(int32_t rhs) + { + ticksS32 = ticksS32 >> rhs; + update(); + return *this; + }; + + friend ClockTicks operator+(ClockTicks lhs, const ClockTicks& rhs) { return lhs += rhs; } + friend ClockTicks operator-(ClockTicks lhs, const ClockTicks& rhs) { return lhs -= rhs; } + friend ClockTicks operator-(ClockTicks val) { return (ClockTicks) 0 -= val; } + friend ClockTicks operator*(ClockTicks lhs, const ClockTicks& rhs) { return lhs *= rhs; } + friend ClockTicks operator/(ClockTicks lhs, const ClockTicks& rhs) { return lhs /= rhs; } + friend ClockTicks operator%(ClockTicks lhs, const ClockTicks& rhs) { return lhs %= rhs; } + friend ClockTicks operator<<(ClockTicks lhs, int32_t rhs) { return lhs >>= rhs; } + friend ClockTicks operator>>(ClockTicks lhs, int32_t rhs) { return lhs <<= rhs; } + + friend inline bool operator==(const ClockTicks& lhs, const ClockTicks& rhs) { return lhs.ticksS32 == rhs.ticksS32; } + friend inline bool operator!=(const ClockTicks& lhs, const ClockTicks& rhs) { return !(lhs == rhs); } + friend inline bool operator<(const ClockTicks& lhs, const ClockTicks& rhs) { return lhs.ticksS32 < rhs.ticksS32; } + friend inline bool operator>(const ClockTicks& lhs, const ClockTicks& rhs) { return rhs < lhs; } + friend inline bool operator<=(const ClockTicks& lhs, const ClockTicks& rhs) { return !(lhs > rhs); } + friend inline bool operator>=(const ClockTicks& lhs, const ClockTicks& rhs) { return !(lhs < rhs); } + + explicit operator uint32_t() const { return wholeTicks; }; + explicit operator int32_t() const { return wholeTicks; }; + +private: + //POGO: wholeTicks must be first in member-order to ensure the address of + // ClockTicks can be treated as a pointer to int32_t. + int32_t wholeTicks; + //POGO: Organize our bits as if we're scaled to have an additional 32-bits + // of fractional precision so that we can handle overflows in a + // way that is accurate to the original BUILD int32_t expectation. + // Multiplication overflows best with 16-bits of fractional precision, + // so only promise that much publicly. + int64_t ticksS32; + + static const uint64_t VALUE_MASK = 0xFFFFFFFFFFFF0000ull; + static const uint64_t WHOLE_MASK = 0xFFFFFFFF00000000ull; + static const uint64_t FRACTION_MASK = 0x00000000FFFF0000ull; + static const uint64_t FRACTION_16_MASK = 0x000000000000FFFFull; + + inline void update() + { + wholeTicks = ticksS32 >> 32; + ticksS32 &= VALUE_MASK; + } +}; + +#endif /* CLOCKTICKS_HPP_ */ diff --git a/source/build/include/compat.h b/source/build/include/compat.h index 2e5d43e0b..1171eca06 100644 --- a/source/build/include/compat.h +++ b/source/build/include/compat.h @@ -1378,6 +1378,7 @@ static inline void maybe_grow_buffer(char ** const buffer, int32_t * const buffe #define LIBDIVIDE_NOINLINE #include "fix16.h" #include "libdivide.h" +#include "clockticks.hpp" /* End dependence on compat.o object. */ diff --git a/source/build/include/editor.h b/source/build/include/editor.h index 0f51f2f31..2bda2cda8 100644 --- a/source/build/include/editor.h +++ b/source/build/include/editor.h @@ -316,7 +316,7 @@ const char* getstring_simple(const char *querystr, const char *defaultstr, int32 //int32_t snfillprintf(char *outbuf, size_t bufsiz, int32_t fill, const char *fmt, ...); void _printmessage16(const char *fmt, ...) ATTRIBUTE((format(printf,1,2))); -#define printmessage16(fmt, ...) lastpm16time = totalclock, _printmessage16(fmt, ## __VA_ARGS__) +#define printmessage16(fmt, ...) lastpm16time = (int32_t) totalclock, _printmessage16(fmt, ## __VA_ARGS__) extern char lastpm16buf[156]; @@ -464,7 +464,7 @@ static FORCE_INLINE void inpclamp(int32_t *x, int32_t mi, int32_t ma) // Timed offset for Mapster32 color index cycling. // Range: 0 .. 16 -#define M32_THROB klabs(sintable[((totalclock << 4) & 2047)] >> 10) +#define M32_THROB klabs(sintable[(((int32_t) totalclock << 4) & 2047)] >> 10) #ifdef __cplusplus } diff --git a/source/build/src/2d.cpp b/source/build/src/2d.cpp index 8f4096989..c9bf1d2be 100644 --- a/source/build/src/2d.cpp +++ b/source/build/src/2d.cpp @@ -966,7 +966,7 @@ static void editorDraw2dWall(int32_t i, int32_t posxe, int32_t posye, int32_t po { col = editorcolors[15] - (M32_THROB>>1); - if (totalclock & 16) + if ((int32_t) totalclock & 16) pointsize++; } diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 5e5ac99a6..73277047b 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -2345,7 +2345,7 @@ int32_t animateoffs(int const tilenum, int fakevar) if (animnum <= 0) return 0; - int const i = totalclocklock >> (picanm[tilenum].sf & PICANM_ANIMSPEED_MASK); + int const i = (int) totalclocklock >> (picanm[tilenum].sf & PICANM_ANIMSPEED_MASK); int offs = 0; switch (picanm[tilenum].sf & PICANM_ANIMTYPE_MASK) diff --git a/source/build/src/osd.cpp b/source/build/src/osd.cpp index fc8a7393b..b3cff1381 100644 --- a/source/build/src/osd.cpp +++ b/source/build/src/osd.cpp @@ -1543,7 +1543,7 @@ void OSD_Draw(void) } int offset = ((osd->flags & (OSD_CAPS | OSD_SHIFT)) == (OSD_CAPS | OSD_SHIFT) && osd->draw.head > 0); - int const shade = osd->draw.promptshade ? osd->draw.promptshade : (sintable[(totalclock<<4)&2047]>>11); + int const shade = osd->draw.promptshade ? osd->draw.promptshade : (sintable[((int32_t) totalclock<<4)&2047]>>11); if (osd->draw.head == osd->text.lines-1) drawosdchar(0, osdrowscur, '~', shade, osd->draw.promptpal); @@ -1569,7 +1569,7 @@ void OSD_Draw(void) if (osd->version.buf) drawosdstr(osd->draw.cols - osd->version.len, osdrowscur - (offset >= osd->draw.cols - osd->version.len), - osd->version.buf, osd->version.len, (sintable[(totalclock<<4)&2047]>>11), osd->version.pal); + osd->version.buf, osd->version.len, (sintable[((int32_t) totalclock<<4)&2047]>>11), osd->version.pal); videoEndDrawing(); } diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index 41ca3c728..3302c05e6 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -76,7 +76,7 @@ static SDL_Window *sdl_window=NULL; static SDL_GLContext sdl_context=NULL; #endif -int32_t xres=-1, yres=-1, bpp=0, fullscreen=0, bytesperline; +int32_t xres=-1, yres=-1, bpp=0, fullscreen=0, bytesperline, refreshfreq=-1; intptr_t frameplace=0; int32_t lockcount=0; char modechange=1; @@ -1554,14 +1554,18 @@ void setrefreshrate(void) SDL_DisplayMode newmode; SDL_GetClosestDisplayMode(0, &dispmode, &newmode); + char error = 0; + if (dispmode.refresh_rate != newmode.refresh_rate) { initprintf("Refresh rate: %dHz\n", newmode.refresh_rate); - SDL_SetWindowDisplayMode(sdl_window, &newmode); + error = SDL_SetWindowDisplayMode(sdl_window, &newmode); } if (!newmode.refresh_rate) newmode.refresh_rate = 60; + + refreshfreq = error ? -1 : newmode.refresh_rate; } int32_t videoSetMode(int32_t x, int32_t y, int32_t c, int32_t fs) diff --git a/source/build/src/timer.cpp b/source/build/src/timer.cpp index f56e32b74..643b93062 100644 --- a/source/build/src/timer.cpp +++ b/source/build/src/timer.cpp @@ -38,7 +38,10 @@ ATTRIBUTE((flatten)) void timerUpdate(void) { auto time = steady_clock::now(); auto elapsedTime = time - timerlastsample; - int n = (elapsedTime.count() * (uint64_t) timerticspersec * steady_clock::period::num) / timerGetFreqU64(); + + uint64_t numerator = (elapsedTime.count() * (uint64_t) timerticspersec * steady_clock::period::num); + int n = numerator / timerGetFreqU64(); + totalclock.setFraction(((numerator - n*timerGetFreqU64()) * 65536) / timerGetFreqU64()); if (n <= 0) return; diff --git a/source/build/src/winlayer.cpp b/source/build/src/winlayer.cpp index 074e66061..1d04a1a7a 100644 --- a/source/build/src/winlayer.cpp +++ b/source/build/src/winlayer.cpp @@ -96,6 +96,7 @@ int32_t yres=-1; int32_t fullscreen=0; int32_t bpp=0; int32_t bytesperline=0; +int32_t refreshfreq=-1; int32_t lockcount=0; int32_t glcolourdepth=32; static int32_t vsync_renderlayer; @@ -2866,7 +2867,7 @@ static BOOL CreateAppWindow(int32_t modenum) { RECT rect; int32_t w, h, x, y, stylebits = 0, stylebitsex = 0; - int32_t width, height, fs, bitspp; + int32_t width, height, fs, bitspp, rfreq = -1; HRESULT result; @@ -2883,6 +2884,7 @@ static BOOL CreateAppWindow(int32_t modenum) height = validmode[modenum].ydim; fs = validmode[modenum].fs; bitspp = validmode[modenum].bpp; + rfreq = validmode[modenum].extra; } if (width == xres && height == yres && fs == fullscreen && bitspp == bpp && !videomodereset) return FALSE; @@ -3096,6 +3098,7 @@ static BOOL CreateAppWindow(int32_t modenum) xres = width; yres = height; bpp = bitspp; + refreshfreq = rfreq; fullscreen = fs; curvidmode = modenum; diff --git a/source/duke3d/src/actors.cpp b/source/duke3d/src/actors.cpp index 4248df2da..42ff6bbf5 100644 --- a/source/duke3d/src/actors.cpp +++ b/source/duke3d/src/actors.cpp @@ -326,13 +326,13 @@ next_sprite: // : below->above change? static int32_t Proj_MaybeDoTransport(int32_t spriteNum, uspriteptr_t const pSEffector, int32_t fromunderp, int32_t daz) { - if ((totalclock & UINT8_MAX) == actor[spriteNum].lasttransport) + if (((int32_t) totalclock & UINT8_MAX) == actor[spriteNum].lasttransport) return 0; auto const pSprite = &sprite[spriteNum]; auto const otherse = (uspriteptr_t)&sprite[pSEffector->owner]; - actor[spriteNum].lasttransport = (totalclock & UINT8_MAX); + actor[spriteNum].lasttransport = ((int32_t) totalclock & UINT8_MAX); pSprite->x += (otherse->x - pSEffector->x); pSprite->y += (otherse->y - pSEffector->y); @@ -3623,7 +3623,7 @@ ACTOR_STATIC void G_MoveTransports(void) case STAT_FALLER: case STAT_DUMMYPLAYER: { - if ((totalclock & UINT8_MAX) != actor[sectSprite].lasttransport) + if (((int32_t) totalclock & UINT8_MAX) != actor[sectSprite].lasttransport) { int const zvel = sprite[sectSprite].zvel; int const absZvel = klabs(zvel); @@ -3699,7 +3699,7 @@ ACTOR_STATIC void G_MoveTransports(void) A_SetSprite(newSprite, CLIPMASK0); } #endif - actor[sectSprite].lasttransport = (totalclock & UINT8_MAX); + actor[sectSprite].lasttransport = ((int32_t) totalclock & UINT8_MAX); sprite[sectSprite].x += sprite[OW(spriteNum)].x - SX(spriteNum); sprite[sectSprite].y += sprite[OW(spriteNum)].y - SY(spriteNum); diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index a7fe08905..82392b825 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -512,7 +512,7 @@ int32_t Anim_Play(const char *fn) g_restorePalette = 0; } - frametime = totalclock; + frametime = (int32_t) totalclock; videoClearScreen(0); diff --git a/source/duke3d/src/astub.cpp b/source/duke3d/src/astub.cpp index 824275d47..3407a8bb3 100644 --- a/source/duke3d/src/astub.cpp +++ b/source/duke3d/src/astub.cpp @@ -1549,7 +1549,7 @@ static void IntegratedHelp(void) highlighthp = i; highlightline = j; - lasthighlighttime = totalclock; + lasthighlighttime = (int32_t) totalclock; goto ENDFOR1; } } @@ -2763,7 +2763,7 @@ static int32_t m32gettile(int32_t idInitialTile) } // These two lines are so obvious I don't need to comment them ...;-) - synctics = totalclock-lockclock; + synctics = (int32_t) totalclock-lockclock; lockclock += synctics; // Zoom in / out using numeric key pad's / and * keys @@ -3837,7 +3837,7 @@ static void getnumberptr256(const char *namestart, void *num, int32_t bytes, int ExtCheckKeys(); Bsprintf(buffer,"%s%d",namestart,danum); - if (totalclock & 32) Bstrcat(buffer,"_ "); + if ((int32_t) totalclock & 32) Bstrcat(buffer,"_ "); printmessage256(0, 0, buffer); if (func != NULL) { @@ -3874,7 +3874,7 @@ static void getnumberptr256(const char *namestart, void *num, int32_t bytes, int clearkeys(); - lockclock = totalclock; //Reset timing + lockclock = (int32_t) totalclock; //Reset timing switch (bytes) { @@ -4170,7 +4170,7 @@ ERROR_TOOMANYSPRITES: clearkeys(); - lockclock = totalclock; //Reset timing + lockclock = (int32_t) totalclock; //Reset timing } static void mouseaction_movesprites(int32_t *sumxvect, int32_t *sumyvect, int32_t yangofs, int32_t mousexory) @@ -8915,7 +8915,7 @@ static int osdcmd_vars_pk(osdcmdptr_t parm) if (isdigit(parm->parms[0][0])) { autocorruptcheck = clamp(atoi_safe(parm->parms[0]), 0, 3600); - corruptchecktimer = totalclock + 120*autocorruptcheck; + corruptchecktimer = (int32_t) totalclock + 120*autocorruptcheck; } return OSDCMD_OK; @@ -10045,7 +10045,7 @@ int32_t ExtInit(void) getmessagetimeoff = 0; Bsprintf(apptitle, "Mapster32 %s", s_buildRev); - autosavetimer = totalclock+120*autosave; + autosavetimer = (int32_t) totalclock+120*autosave; registerosdcommands(); @@ -10424,9 +10424,9 @@ void ExtPreCheckKeys(void) // just before drawrooms if (graphicsmode == 2) { - if (frames==2) picnum+=((((4-(totalclock>>5)))&1)*5); - if (frames==4) picnum+=((((4-(totalclock>>5)))&3)*5); - if (frames==5) picnum+=(((totalclock>>5)%5))*5; + if (frames==2) picnum+=((((4-((int32_t) totalclock>>5)))&1)*5); + if (frames==4) picnum+=((((4-((int32_t) totalclock>>5)))&3)*5); + if (frames==5) picnum+=((((int32_t) totalclock>>5)%5))*5; } if (tilesiz[picnum].x == 0) @@ -10658,9 +10658,9 @@ void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothr } } - if (frames==2) tspr->picnum += (((4-(totalclock>>5)))&1)*5; - if (frames==4) tspr->picnum += (((4-(totalclock>>5)))&3)*5; - if (frames==5) tspr->picnum += ((totalclock>>5)%5)*5; + if (frames==2) tspr->picnum += (((4-((int32_t) totalclock>>5)))&1)*5; + if (frames==4) tspr->picnum += (((4-((int32_t) totalclock>>5)))&3)*5; + if (frames==5) tspr->picnum += (((int32_t) totalclock>>5)%5)*5; if (tilesiz[tspr->picnum].x == 0) tspr->picnum -= 5; //Hack, for actors @@ -10798,7 +10798,7 @@ static void Keys2d3d(void) { message("Board saved to %s", levelname); asksave = 0; - lastsave=totalclock; + lastsave=(int32_t) totalclock; } } } @@ -10813,7 +10813,7 @@ static void Keys2d3d(void) int32_t sposx=pos.x,sposy=pos.y,sposz=pos.z,sang=ang; const char *f = GetSaveBoardFilename(levelname); - lastsave=totalclock; + lastsave=(int32_t) totalclock; // sectorhighlightstat = -1; // newnumwalls = -1; // joinsector[0] = -1; @@ -10951,7 +10951,7 @@ void ExtCheckKeys(void) { if (CheckMapCorruption(3, 0)>=3) printmessage16("Corruption detected. See OSD for details."); - corruptchecktimer = totalclock + 120*autocorruptcheck; + corruptchecktimer = (int32_t) totalclock + 120*autocorruptcheck; } } @@ -10999,7 +10999,7 @@ void ExtCheckKeys(void) asksave++; } - autosavetimer = totalclock+120*autosave; + autosavetimer = (int32_t) totalclock+120*autosave; } if (PRESSED_KEYSC(F12)) //F12 diff --git a/source/duke3d/src/cheats.cpp b/source/duke3d/src/cheats.cpp index 873fc1e8e..76d1374d3 100644 --- a/source/duke3d/src/cheats.cpp +++ b/source/duke3d/src/cheats.cpp @@ -596,7 +596,7 @@ void G_DoCheats(void) case CHEAT_VIEW: pPlayer->over_shoulder_on ^= 1; CAMERADIST = 0; - CAMERACLOCK = totalclock; + CAMERACLOCK = (int32_t) totalclock; // P_DoQuote(QUOTE_CHEATS_DISABLED,pPlayer); end_cheat(pPlayer); return; diff --git a/source/duke3d/src/demo.cpp b/source/duke3d/src/demo.cpp index e7d5b9a80..dfe57ecf8 100644 --- a/source/duke3d/src/demo.cpp +++ b/source/duke3d/src/demo.cpp @@ -551,7 +551,7 @@ RECHECK: lastsyncofs = ktell(g_demo_recFilePtr); initsyncofs = lastsyncofs; lastsynctic = g_demo_cnt; - lastsyncclock = totalclock; + lastsyncclock = (int32_t) totalclock; outofsync = 0; #if KRANDDEBUG krd_enable(2); @@ -678,7 +678,7 @@ RECHECK: { lastsyncofs = ktell(g_demo_recFilePtr); lastsynctic = g_demo_cnt; - lastsyncclock = totalclock; + lastsyncclock = (int32_t) totalclock; if (kread(g_demo_recFilePtr, tmpbuf, 4) != 4) CORRUPT(7); @@ -844,7 +844,7 @@ nextdemo_nomenu: } else { - j = calc_smoothratio(totalclock, ototalclock); + j = calc_smoothratio_demo(totalclock, ototalclock); if (g_demo_paused && g_demo_rewind) j = 65536-j; diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 17b6ed5dc..7926e9400 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -255,7 +255,7 @@ void G_GameQuit(void) if (g_gameQuit == 0) { g_gameQuit = 1; - g_quitDeadline = totalclock+120; + g_quitDeadline = (int32_t) totalclock+120; g_netDisconnect = 1; } @@ -416,8 +416,8 @@ static int32_t G_DoThirdPerson(const DukePlayer_t *pp, vec3_t *vect, int16_t *vs vect->y += mulscale16(n.y,CAMERADIST); vect->z += mulscale16(n.z,CAMERADIST); - CAMERADIST = min(CAMERADIST+((totalclock-CAMERACLOCK)<<10),65536); - CAMERACLOCK = totalclock; + CAMERADIST = min(CAMERADIST+(((int32_t) totalclock-CAMERACLOCK)<<10),65536); + CAMERACLOCK = (int32_t) totalclock; updatesectorz(vect->x,vect->y,vect->z,vsectnum); @@ -781,10 +781,8 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) videoSetCorrectedAspect(); } - if (ud.pause_on || pPlayer->on_crane > -1) + if (pPlayer->on_crane > -1) smoothRatio = 65536; - else - smoothRatio = calc_smoothratio(totalclock, ototalclock); int const playerVis = pPlayer->visibility; g_visibility = (playerVis <= 0) ? 0 : (int32_t)(playerVis * (numplayers > 1 ? 1.f : r_ambientlightrecip)); @@ -1192,7 +1190,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio) } pPlayer->visibility += visinc; - lastvist = totalclock; + lastvist = (int32_t) totalclock; } } @@ -3633,7 +3631,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo if (t->lotag == SE_27_DEMO_CAM && ud.recstat == 1) { - t->picnum = 11+((totalclock>>3)&1); + t->picnum = 11+(((int) totalclock>>3)&1); t->cstat |= 128; } else @@ -3854,7 +3852,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo t->z -= ZOFFSET6; break; case CRYSTALAMMO__STATIC: - t->shade = (sintable[(totalclock<<4)&2047]>>10); + t->shade = (sintable[((int32_t) totalclock<<4)&2047]>>10); continue; #endif case VIEWSCREEN__STATIC: @@ -3897,10 +3895,10 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo } #ifndef EDUKE32_STANDALONE case SHRINKSPARK__STATIC: - t->picnum = SHRINKSPARK+((totalclock>>4)&3); + t->picnum = SHRINKSPARK+(((int32_t) totalclock>>4)&3); break; case GROWSPARK__STATIC: - t->picnum = GROWSPARK+((totalclock>>4)&3); + t->picnum = GROWSPARK+(((int32_t) totalclock>>4)&3); break; case RPG__STATIC: if (tilehasmodelorvoxel(t->picnum,t->pal) && !(spriteext[i].flags & SPREXT_NOTMD)) @@ -4965,7 +4963,7 @@ FAKE_F3: myplayer.over_shoulder_on = !myplayer.over_shoulder_on; CAMERADIST = 0; - CAMERACLOCK = totalclock; + CAMERACLOCK = (int32_t) totalclock; P_DoQuote(QUOTE_VIEW_MODE_OFF + myplayer.over_shoulder_on, &myplayer); } @@ -5030,7 +5028,7 @@ FAKE_F3: if (ud.overhead_on != 0) { - int const timerOffset = (totalclock - nonsharedtimer); + int const timerOffset = ((int) totalclock - nonsharedtimer); nonsharedtimer += timerOffset; if (BUTTON(gamefunc_Enlarge_Screen)) @@ -6960,7 +6958,7 @@ MAIN_LOOP_RESTART: ototalclock += TICSPERFRAME; - int const moveClock = totalclock; + int const moveClock = (int) totalclock; if (((ud.show_help == 0 && (myplayer.gm & MODE_MENU) != MODE_MENU) || ud.recstat == 2 || (g_netServer || ud.multimode > 1)) && (myplayer.gm & MODE_GAME)) @@ -7010,12 +7008,7 @@ MAIN_LOOP_RESTART: } else if (G_FPSLimit() || g_saveRequested) { - int const smoothRatio - = ((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && ((myplayer.gm & MODE_MENU) == 0)) - || (g_netServer || ud.multimode > 1) - || ud.recstat == 2) - ? calc_smoothratio(totalclock, ototalclock) - : 65536; + int const smoothRatio = calc_smoothratio(totalclock, ototalclock); G_DrawRooms(screenpeek, smoothRatio); if (videoGetRenderMode() >= REND_POLYMOST) diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index 8b0d20036..406015474 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -448,9 +448,29 @@ static inline void G_HandleAsync(void) Net_GetPackets(); } -static inline int32_t calc_smoothratio(int32_t totalclk, int32_t ototalclk) +static inline int32_t calc_smoothratio_demo(ClockTicks totalclk, ClockTicks ototalclk) { - return clamp((totalclk-ototalclk)*(65536/TICSPERFRAME), 0, 65536); + int32_t rfreq = (refreshfreq != -1 ? refreshfreq : 60); + uint64_t elapsedFrames = tabledivide64(((uint64_t) (totalclk - ototalclk).toScale16()) * rfreq, 65536*TICRATE); +#if 0 + //POGO: additional debug info for testing purposes + OSD_Printf("Elapsed frames: %" PRIu64 ", smoothratio: %" PRIu64 "\n", elapsedFrames, tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq)); +#endif + return clamp(tabledivide64(65536*elapsedFrames*REALGAMETICSPERSEC, rfreq), 0, 65536); +} + +extern int myconnectindex; +static inline int32_t calc_smoothratio(ClockTicks totalclk, ClockTicks ototalclk) +{ + if (!((ud.show_help == 0 && (!g_netServer && ud.multimode < 2) && ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0)) || + (g_netServer || ud.multimode > 1) || + ud.recstat == 2) || + ud.pause_on) + { + return 65536; + } + + return calc_smoothratio_demo(totalclk, ototalclk); } // sector effector lotags diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index a8cc64645..b3581cd4c 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -1098,7 +1098,7 @@ static int32_t VM_ResetPlayer(int const playerNum, int32_t vmFlags, int32_t cons if (playerNum == myconnectindex) { CAMERADIST = 0; - CAMERACLOCK = totalclock; + CAMERACLOCK = (int32_t) totalclock; } if (g_fakeMultiMode) diff --git a/source/duke3d/src/global.h b/source/duke3d/src/global.h index 4cb773c5c..6df195e71 100644 --- a/source/duke3d/src/global.h +++ b/source/duke3d/src/global.h @@ -120,7 +120,7 @@ G_EXTERN int32_t g_animateVel[MAXANIMATES]; G_EXTERN int16_t g_cloudSect[256]; G_EXTERN int16_t g_cloudX; G_EXTERN int16_t g_cloudY; -G_EXTERN int32_t g_cloudClock; +G_EXTERN ClockTicks g_cloudClock; G_EXTERN int16_t SpriteDeletionQueue[1024]; G_EXTERN int16_t g_cyclers[MAXCYCLERS][6]; @@ -128,8 +128,8 @@ G_EXTERN int16_t g_mirrorSector[64]; G_EXTERN int16_t g_mirrorWall[64]; G_EXTERN int32_t *labelcode; G_EXTERN int32_t *labeltype; -G_EXTERN int32_t lockclock; -G_EXTERN int32_t ototalclock; +G_EXTERN ClockTicks lockclock; +G_EXTERN ClockTicks ototalclock; G_EXTERN intptr_t *apScript; G_EXTERN intptr_t *g_scriptPtr; diff --git a/source/duke3d/src/m32common.cpp b/source/duke3d/src/m32common.cpp index 1dbdf6095..f421c52e7 100644 --- a/source/duke3d/src/m32common.cpp +++ b/source/duke3d/src/m32common.cpp @@ -79,7 +79,7 @@ static void message_common1(const char *tmpstr) Bstrncpyz(getmessage, tmpstr, sizeof(getmessage)); getmessageleng = Bstrlen(getmessage); - getmessagetimeoff = totalclock + 120*2 + getmessageleng*(120/30); + getmessagetimeoff = (int32_t) totalclock + 120*2 + getmessageleng*(120/30); // lastmessagetime = totalclock; } diff --git a/source/duke3d/src/menus.cpp b/source/duke3d/src/menus.cpp index d9d6aade1..eb4b90155 100644 --- a/source/duke3d/src/menus.cpp +++ b/source/duke3d/src/menus.cpp @@ -140,7 +140,7 @@ static void Menu_DrawTopBarCaption(const char *caption, const vec2_t origin) static FORCE_INLINE int32_t Menu_CursorShade(void) { - return VM_OnEventWithReturn(EVENT_MENUCURSORSHADE, -1, myconnectindex, 4-(sintable[(totalclock<<4)&2047]>>11)); + return VM_OnEventWithReturn(EVENT_MENUCURSORSHADE, -1, myconnectindex, 4-(sintable[((int32_t) totalclock<<4)&2047]>>11)); } static void Menu_DrawCursorCommon(int32_t x, int32_t y, int32_t z, int32_t picnum, int32_t ydim_upper = 0, int32_t ydim_lower = ydim-1) { @@ -149,12 +149,12 @@ static void Menu_DrawCursorCommon(int32_t x, int32_t y, int32_t z, int32_t picnu static void Menu_DrawCursorLeft(int32_t x, int32_t y, int32_t z) { if (FURY) return; - Menu_DrawCursorCommon(x, y, z, VM_OnEventWithReturn(EVENT_MENUCURSORLEFT, -1, myconnectindex, SPINNINGNUKEICON+((totalclock>>3)%7))); + Menu_DrawCursorCommon(x, y, z, VM_OnEventWithReturn(EVENT_MENUCURSORLEFT, -1, myconnectindex, SPINNINGNUKEICON+(((int32_t) totalclock>>3)%7))); } static void Menu_DrawCursorRight(int32_t x, int32_t y, int32_t z) { if (FURY) return; - Menu_DrawCursorCommon(x, y, z, VM_OnEventWithReturn(EVENT_MENUCURSORRIGHT, -1, myconnectindex, SPINNINGNUKEICON+6-((6+(totalclock>>3))%7))); + Menu_DrawCursorCommon(x, y, z, VM_OnEventWithReturn(EVENT_MENUCURSORRIGHT, -1, myconnectindex, SPINNINGNUKEICON+6-((6+((int32_t) totalclock>>3))%7))); } static void Menu_DrawCursorTextTile(int32_t x, int32_t y, int32_t h, int32_t picnum, vec2_16_t const & siz, int32_t ydim_upper = 0, int32_t ydim_lower = ydim-1) { @@ -171,7 +171,7 @@ static void Menu_DrawCursorText(int32_t x, int32_t y, int32_t h, int32_t ydim_up return; } - Menu_DrawCursorTextTile(x, y, h, SPINNINGNUKEICON+((totalclock>>3)%7), siz, ydim_upper, ydim_lower); + Menu_DrawCursorTextTile(x, y, h, SPINNINGNUKEICON+(((int32_t) totalclock>>3)%7), siz, ydim_upper, ydim_lower); } @@ -2329,12 +2329,12 @@ static void Menu_PreDraw(MenuID_t cm, MenuEntry_t *entry, const vec2_t origin) { rotatesprite_fs(origin.x + (MENU_MARGIN_CENTER<<16), origin.y + ((28+l)<<16), 65536L,0,INGAMEDUKETHREEDEE,0,0,10); if (PLUTOPAK) // JBF 20030804 - rotatesprite_fs(origin.x + ((MENU_MARGIN_CENTER+100)<<16), origin.y + (36<<16), 65536L,0,PLUTOPAKSPRITE+2,(sintable[(totalclock<<4)&2047]>>11),0,2+8); + rotatesprite_fs(origin.x + ((MENU_MARGIN_CENTER+100)<<16), origin.y + (36<<16), 65536L,0,PLUTOPAKSPRITE+2,(sintable[((int32_t) totalclock<<4)&2047]>>11),0,2+8); } break; case MENU_PLAYER: - rotatesprite_fs(origin.x + (260<<16), origin.y + ((24+(tilesiz[APLAYER].y>>1))<<16), 49152L,0,1441-((((4-(totalclock>>4)))&3)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(ud.team) : ud.color,10); + rotatesprite_fs(origin.x + (260<<16), origin.y + ((24+(tilesiz[APLAYER].y>>1))<<16), 49152L,0,1441-((((4-((int32_t) totalclock>>4)))&3)*5),0,entry == &ME_PLAYER_TEAM ? G_GetTeamPalette(ud.team) : ud.color,10); break; case MENU_MACROS: @@ -4072,19 +4072,19 @@ MenuAnimation_t m_animation; int32_t Menu_Anim_SinOutRight(MenuAnimation_t *animdata) { - return sintable[divscale10(totalclock - animdata->start, animdata->length) + 512] - 16384; + return sintable[divscale10((int32_t) totalclock - animdata->start, animdata->length) + 512] - 16384; } int32_t Menu_Anim_SinInRight(MenuAnimation_t *animdata) { - return sintable[divscale10(totalclock - animdata->start, animdata->length) + 512] + 16384; + return sintable[divscale10((int32_t) totalclock - animdata->start, animdata->length) + 512] + 16384; } int32_t Menu_Anim_SinOutLeft(MenuAnimation_t *animdata) { - return -sintable[divscale10(totalclock - animdata->start, animdata->length) + 512] + 16384; + return -sintable[divscale10((int32_t) totalclock - animdata->start, animdata->length) + 512] + 16384; } int32_t Menu_Anim_SinInLeft(MenuAnimation_t *animdata) { - return -sintable[divscale10(totalclock - animdata->start, animdata->length) + 512] - 16384; + return -sintable[divscale10((int32_t) totalclock - animdata->start, animdata->length) + 512] - 16384; } void Menu_AnimateChange(int32_t cm, MenuAnimationType_t animtype) @@ -4107,7 +4107,7 @@ void Menu_AnimateChange(int32_t cm, MenuAnimationType_t animtype) { m_animation.out = Menu_Anim_SinOutRight; m_animation.in = Menu_Anim_SinInRight; - m_animation.start = totalclock; + m_animation.start = (int32_t) totalclock; m_animation.length = 30; m_animation.previous = previousMenu; @@ -4124,7 +4124,7 @@ void Menu_AnimateChange(int32_t cm, MenuAnimationType_t animtype) { m_animation.out = Menu_Anim_SinOutLeft; m_animation.in = Menu_Anim_SinInLeft; - m_animation.start = totalclock; + m_animation.start = (int32_t) totalclock; m_animation.length = 30; m_animation.previous = previousMenu; @@ -4568,7 +4568,7 @@ void Menu_Close(uint8_t playerID) { ready2send = 1; totalclock = ototalclock; - CAMERACLOCK = totalclock; + CAMERACLOCK = (int32_t) totalclock; CAMERADIST = 65536; m_animation.start = 0; m_animation.length = 0; @@ -4576,7 +4576,7 @@ void Menu_Close(uint8_t playerID) // Reset next-viewscreen-redraw counter. // XXX: are there any other cases like that in need of handling? if (g_curViewscreen >= 0) - actor[g_curViewscreen].t_data[0] = totalclock; + actor[g_curViewscreen].t_data[0] = (int32_t) totalclock; } walock[TILE_SAVESHOT] = 1; @@ -4622,7 +4622,7 @@ enum MenuTextFlags_t static void Menu_GetFmt(const MenuFont_t *font, uint8_t const status, int32_t *s, int32_t *z) { if (status & MT_Selected) - *s = VM_OnEventWithReturn(EVENT_MENUSHADESELECTED, -1, myconnectindex, sintable[(totalclock<<5)&2047]>>12); + *s = VM_OnEventWithReturn(EVENT_MENUSHADESELECTED, -1, myconnectindex, sintable[((int32_t) totalclock<<5)&2047]>>12); else *s = font->shade_deselected; // sum shade values @@ -5605,7 +5605,7 @@ static void Menu_Run_MouseReturn(Menu_t *cm, const vec2_t origin) uint32_t const posx = tilesiz[SELECTDIR].y * SELECTDIR_z; rotatesprite_(origin.x + posx, 0, SELECTDIR_z, 512, SELECTDIR, - Menu_RunInput_MouseReturn_status ? 4 - (sintable[(totalclock << 4) & 2047] >> 11) : 6, 0, + Menu_RunInput_MouseReturn_status ? 4 - (sintable[((int32_t) totalclock << 4) & 2047] >> 11) : 6, 0, 2 | 8 | 16 | RS_ALIGN_L, MOUSEALPHA, 0, xdim_from_320_16(origin.x + x_widescreen_left()), 0, xdim_from_320_16(origin.x + x_widescreen_left() + ((posx>>17)<<16)), ydim - 1); } @@ -7198,7 +7198,7 @@ void M_DisplayMenus(void) if (MOUSEACTIVECONDITIONAL(mouseAdvanceClickState()) || m_mousepos.x != m_prevmousepos.x || m_mousepos.y != m_prevmousepos.y) { m_prevmousepos = m_mousepos; - m_mouselastactivity = totalclock; + m_mouselastactivity = (int32_t) totalclock; } #if !defined EDUKE32_TOUCH_DEVICES else @@ -7265,7 +7265,7 @@ void M_DisplayMenus(void) if ((g_player[myconnectindex].ps->gm&MODE_MENU) != MODE_MENU) { G_UpdateScreenArea(); - CAMERACLOCK = totalclock; + CAMERACLOCK = (int32_t) totalclock; CAMERADIST = 65536; } } diff --git a/source/duke3d/src/menus.h b/source/duke3d/src/menus.h index 12b48377e..081bbc614 100644 --- a/source/duke3d/src/menus.h +++ b/source/duke3d/src/menus.h @@ -491,8 +491,8 @@ extern int32_t m_mousewake_watchpoint, m_menuchange_watchpoint; // alpha increments of 3 --> 255 / 3 = 85 --> round up to power of 2 --> 128 --> divide by 2 --> 64 alphatabs required // use 16 anyway :P # define MOUSEUSEALPHA (videoGetRenderMode() != REND_CLASSIC || numalphatabs >= 15) -# define MOUSEALPHA (MOUSEUSEALPHA ? clamp((totalclock - m_mouselastactivity - 90)*3, 0, 255) : 0) -# define CURSORALPHA (MOUSEUSEALPHA ? clamp((totalclock - m_mouselastactivity - 90)*2 + (255/3), (255/3), 255) : 255/3) +# define MOUSEALPHA (MOUSEUSEALPHA ? clamp(((int32_t) totalclock - m_mouselastactivity - 90)*3, 0, 255) : 0) +# define CURSORALPHA (MOUSEUSEALPHA ? clamp(((int32_t) totalclock - m_mouselastactivity - 90)*2 + (255/3), (255/3), 255) : 255/3) # define MOUSEACTIVECONDITION (totalclock - m_mouselastactivity < M_MOUSETIMEOUT) # define MOUSEACTIVECONDITIONAL(condition) (MOUSEACTIVECONDITION && (condition)) # define MOUSEINACTIVECONDITIONAL(condition) ((!(g_player[myconnectindex].ps->gm & MODE_MENU) || !MOUSEACTIVECONDITION) && (condition)) diff --git a/source/duke3d/src/network.cpp b/source/duke3d/src/network.cpp index 464a41662..bf7e9742f 100644 --- a/source/duke3d/src/network.cpp +++ b/source/duke3d/src/network.cpp @@ -1596,7 +1596,7 @@ static void Net_SyncPlayer(ENetEvent *event) NET_75_CHECK++; // is it necessary to se event->peer->data to the new player index in Net_SyncPlayer? event->peer->data = (void *)(intptr_t)newPlayerIndex; - g_player[newPlayerIndex].netsynctime = totalclock; + g_player[newPlayerIndex].netsynctime = (int32_t) totalclock; g_player[newPlayerIndex].playerquitflag = 1; NET_75_CHECK++; // Need to think of something better when finding a remaining slot for players. @@ -5146,8 +5146,8 @@ void Net_SendMessage(void) int32_t const text_x = fullwidth >= (320 << 16) ? (320 << 16) - fullwidth : mpgametext_x; mpgametext(text_x, y, typebuf, 1, 2 | 8 | 16 | ROTATESPRITE_FULL16, 0, TEXT_YCENTER | TEXT_LITERALESCAPE); int32_t const cursor_x = text_x + width + textsc((tilesiz[SPINNINGNUKEICON].x << 14) + (1 << 16)); - rotatesprite_fs(cursor_x, y, textsc(32768), 0, SPINNINGNUKEICON + ((totalclock >> 3) % 7), - 4 - (sintable[(totalclock << 4) & 2047] >> 11), 0, 2 | 8); + rotatesprite_fs(cursor_x, y, textsc(32768), 0, SPINNINGNUKEICON + (((int32_t) totalclock >> 3) % 7), + 4 - (sintable[((int32_t) totalclock << 4) & 2047] >> 11), 0, 2 | 8); if (hitstate == 1) { diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index ab09cf15d..6c2838a1f 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -2986,9 +2986,9 @@ void P_GetInput(int const playerNum) { static int32_t turnHeldTime = 0; static int32_t lastInputClock = 0; // MED - int32_t const elapsedTics = totalclock - lastInputClock; + int32_t const elapsedTics = (int32_t) totalclock - lastInputClock; - lastInputClock = totalclock; + lastInputClock = (int32_t) totalclock; if (BUTTON(gamefunc_Turn_Left)) { @@ -4175,7 +4175,7 @@ static void P_ProcessWeapon(int playerNum) { if (!(PWEAPON(playerNum, pPlayer->curr_weapon, Flags) & WEAPON_NOVISIBLE)) { - lastvisinc = totalclock+32; + lastvisinc = (int32_t) totalclock+32; pPlayer->visibility = 0; } diff --git a/source/duke3d/src/premap.cpp b/source/duke3d/src/premap.cpp index 96fecf3ac..99a2cf2e5 100644 --- a/source/duke3d/src/premap.cpp +++ b/source/duke3d/src/premap.cpp @@ -491,7 +491,7 @@ void G_CacheMapData(void) } } - int clock = totalclock; + int clock = (int) totalclock; int cnt = 0; int percentDisplayed = -1; @@ -530,12 +530,12 @@ void G_CacheMapData(void) if (totalclock - clock >= 1) { - clock = totalclock; + clock = (int) totalclock; percentDisplayed++; } } - clock = totalclock; + clock = (int) totalclock; } } diff --git a/source/duke3d/src/savegame.cpp b/source/duke3d/src/savegame.cpp index b40040f4d..152e7cf66 100644 --- a/source/duke3d/src/savegame.cpp +++ b/source/duke3d/src/savegame.cpp @@ -699,10 +699,10 @@ static struct { static void G_SaveTimers(void) { - g_timers.totalclock = totalclock; - g_timers.totalclocklock = totalclocklock; - g_timers.ototalclock = ototalclock; - g_timers.lockclock = lockclock; + g_timers.totalclock = (int32_t) totalclock; + g_timers.totalclocklock = (int32_t) totalclocklock; + g_timers.ototalclock = (int32_t) ototalclock; + g_timers.lockclock = (int32_t) lockclock; } static void G_RestoreTimers(void) diff --git a/source/duke3d/src/sbar.cpp b/source/duke3d/src/sbar.cpp index b17afe69c..1f15a5e88 100644 --- a/source/duke3d/src/sbar.cpp +++ b/source/duke3d/src/sbar.cpp @@ -631,11 +631,11 @@ void G_DrawStatusBar(int32_t snum) if (sprite[p->i].pal == 1 && p->last_extra < 2) G_DrawAltDigiNum(40, -(hudoffset-22), 1, -16, 10+16+256); - else if (!althud_flashing || p->last_extra >(p->max_player_health>>2) || totalclock&32) + else if (!althud_flashing || p->last_extra >(p->max_player_health>>2) || (int32_t) totalclock&32) { int32_t s = -8; if (althud_flashing && p->last_extra > p->max_player_health) - s += (sintable[(totalclock<<5)&2047]>>10); + s += (sintable[((int32_t) totalclock<<5)&2047]>>10); G_DrawAltDigiNum(40, -(hudoffset-22), p->last_extra, s, 10+16+256); } @@ -658,7 +658,7 @@ void G_DrawStatusBar(int32_t snum) else i = p->curr_weapon; if (PWEAPON(snum, p->curr_weapon, WorksLike) != KNEE_WEAPON && - (!althud_flashing || totalclock&32 || p->ammo_amount[i] > (p->max_ammo_amount[i]/10))) + (!althud_flashing || (int32_t) totalclock&32 || p->ammo_amount[i] > (p->max_ammo_amount[i]/10))) G_DrawAltDigiNum(-20, -(hudoffset-22), p->ammo_amount[i], -16, 10+16+512); o = 102; diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 10324af0e..32fcdd2eb 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -282,12 +282,12 @@ static void G_DrawCameraText(int16_t i) rotatesprite_win(22<<16, 163<<16, 65536L, 512, CAMCORNER+1, 0, 0, 2+4); rotatesprite_win((310-10)<<16, 163<<16, 65536L, 512, CAMCORNER+1, 0, 0, 2); - if (totalclock&16) + if ((int32_t) totalclock&16) rotatesprite_win(46<<16, 32<<16, 65536L, 0, CAMLIGHT, 0, 0, 2); } else { - int32_t flipbits = (totalclock<<1)&48; + int32_t flipbits = ((int32_t) totalclock<<1)&48; for (bssize_t x=-64; x<394; x+=64) for (bssize_t y=0; y<200; y+=64) @@ -589,7 +589,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 if (p == screenpeek || GTFLAGS(GAMETYPE_OTHERPLAYERSINMAP)) { if (pSprite->xvel > 16 && pPlayer->on_ground) - i = APLAYERTOP+((totalclock>>4)&3); + i = APLAYERTOP+(((int32_t) totalclock>>4)&3); else i = APLAYERTOP; @@ -660,7 +660,7 @@ static void G_PrintCoords(int32_t snum) y += 7; Bsprintf(tempbuf, "THOLD= %d", ps->transporter_hold); printext256(x, y+54, COLOR_WHITE, -1, tempbuf, 0); - Bsprintf(tempbuf, "GAMETIC= %u, TOTALCLOCK=%d", g_moveThingsCount, totalclock); + Bsprintf(tempbuf, "GAMETIC= %u, TOTALCLOCK=%d", g_moveThingsCount, (int32_t) totalclock); printext256(x, y+63, COLOR_WHITE, -1, tempbuf, 0); #ifdef DEBUGGINGAIDS Bsprintf(tempbuf, "NUMSPRITES= %d", Numsprites); @@ -1397,7 +1397,7 @@ void G_FadePalette(int32_t r, int32_t g, int32_t b, int32_t e) videoFadePalette(r, g, b, e); videoNextPage(); - int32_t tc = totalclock; + int32_t tc = (int32_t) totalclock; while (totalclock < tc + 4) G_HandleAsync(); } @@ -1616,7 +1616,7 @@ void gameDisplayTitleScreen(void) titlesound++; S_PlaySound(PIPEBOMB_EXPLODE); } - rotatesprite_fs(160 << 16, 104 << 16, (totalclock - 120) << 10, 0, DUKENUKEM, 0, 0, 2 + 8); + rotatesprite_fs(160 << 16, 104 << 16, ((int32_t) totalclock - 120) << 10, 0, DUKENUKEM, 0, 0, 2 + 8); } else if (totalclock >= (120 + 60)) rotatesprite_fs(160 << 16, (104) << 16, 60 << 10, 0, DUKENUKEM, 0, 0, 2 + 8); @@ -1635,7 +1635,7 @@ void gameDisplayTitleScreen(void) } rotatesprite_fs(160 << 16, (104) << 16, 60 << 10, 0, DUKENUKEM, 0, 0, 2 + 8); - rotatesprite_fs(160 << 16, (129) << 16, (totalclock - 220) << 11, 0, THREEDEE, 0, 0, 2 + 8); + rotatesprite_fs(160 << 16, (129) << 16, ((int32_t) totalclock - 220) << 11, 0, THREEDEE, 0, 0, 2 + 8); } else if (totalclock >= (220 + 30)) rotatesprite_fs(160 << 16, (129) << 16, 30 << 11, 0, THREEDEE, 0, 0, 2 + 8); @@ -1648,8 +1648,8 @@ void gameDisplayTitleScreen(void) // JBF 20030804 if (totalclock >= 280 && totalclock < 395) { - rotatesprite_fs(160 << 16, (151) << 16, (410 - totalclock) << 12, 0, PLUTOPAKSPRITE + 1, - (sintable[(totalclock << 4) & 2047] >> 11), 0, 2 + 8); + rotatesprite_fs(160 << 16, (151) << 16, (410 - (int32_t) totalclock) << 12, 0, PLUTOPAKSPRITE + 1, + (sintable[((int32_t) totalclock << 4) & 2047] >> 11), 0, 2 + 8); if (titlesound == 2) { titlesound++; @@ -1663,7 +1663,7 @@ void gameDisplayTitleScreen(void) titlesound++; S_PlaySound(PIPEBOMB_EXPLODE); } - rotatesprite_fs(160 << 16, (151) << 16, 30 << 11, 0, PLUTOPAKSPRITE + 1, (sintable[(totalclock << 4) & 2047] >> 11), 0, + rotatesprite_fs(160 << 16, (151) << 16, 30 << 11, 0, PLUTOPAKSPRITE + 1, (sintable[((int32_t) totalclock << 4) & 2047] >> 11), 0, 2 + 8); } } @@ -2361,7 +2361,7 @@ void G_BonusScreen(int32_t bonusonly) if (totalclock >= 1000000000 && totalclock < 1000000320) { - switch ((totalclock>>4)%15) + switch (((int32_t) totalclock>>4)%15) { case 0: if (bonuscnt == 6) @@ -2399,7 +2399,7 @@ void G_BonusScreen(int32_t bonusonly) else if (totalclock > (10240+120L)) break; else { - switch ((totalclock>>5)&3) + switch (((int32_t) totalclock>>5)&3) { case 1: case 3: diff --git a/source/duke3d/src/sector.cpp b/source/duke3d/src/sector.cpp index 92d70b4bf..84adb3e23 100644 --- a/source/duke3d/src/sector.cpp +++ b/source/duke3d/src/sector.cpp @@ -445,7 +445,7 @@ void G_AnimateCamSprite(int smoothRatio) #endif } - T1(spriteNum) = totalclock; + T1(spriteNum) = (int32_t) totalclock; } } @@ -1210,10 +1210,10 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType) if (switchType == SWITCH_SPRITE) // A wall sprite { - if (actor[wallOrSprite].lasttransport == (totalclock & UINT8_MAX)) + if (actor[wallOrSprite].lasttransport == ((int32_t) totalclock & UINT8_MAX)) return 0; - actor[wallOrSprite].lasttransport = (totalclock & UINT8_MAX); + actor[wallOrSprite].lasttransport = ((int32_t) totalclock & UINT8_MAX); if (sprite[wallOrSprite].lotag == 0) return 0; diff --git a/source/kenbuild/src/game.cpp b/source/kenbuild/src/game.cpp index 95212d58b..8b5c0da72 100644 --- a/source/kenbuild/src/game.cpp +++ b/source/kenbuild/src/game.cpp @@ -742,7 +742,7 @@ int32_t app_main(int32_t argc, char const * const * argv) domovethings(); } } - i = (totalclock-gotlastpacketclock)*(65536/(TIMERINTSPERSECOND/MOVESPERSECOND)); + i = ((int32_t) totalclock-gotlastpacketclock)*(65536/(TIMERINTSPERSECOND/MOVESPERSECOND)); drawscreen(screenpeek,i); } @@ -3974,8 +3974,8 @@ void drawscreen(short snum, int dasmoothratio) ptr4 = palookup[18]; ptr4 += (min(klabs(y2-l)>>2,31)<<8); - j = sintable[((y2+totalclock)<<6)&2047]; - j += sintable[((y2-totalclock)<<7)&2047]; + j = sintable[((y2+(int32_t) totalclock)<<6)&2047]; + j += sintable[((y2-(int32_t) totalclock)<<7)&2047]; j >>= 14; //ptr2 += j; @@ -4251,7 +4251,7 @@ void drawscreen(short snum, int dasmoothratio) Bsprintf(getmessage,"Video mode: %d x %d",xdim,ydim); getmessageleng = Bstrlen(getmessage); - getmessagetimeoff = totalclock+120*5; + getmessagetimeoff = (int32_t) totalclock+120*5; } if (keystatus[0x57]) //F11 - brightness { @@ -4317,7 +4317,7 @@ void movethings(void) { int i; - gotlastpacketclock = totalclock; + gotlastpacketclock = (int32_t) totalclock; for (i=connecthead; i>=0; i=connectpoint2[i]) { copybufbyte(&ffsync[i],&baksync[movefifoend[i]][i],sizeof(input)); @@ -4525,12 +4525,12 @@ void domovethings(void) if (cameradist >= 0) { - cameradist = min(cameradist+((totalclock-cameraclock)<<10),65536); + cameradist = min(cameradist+(((int32_t) totalclock-cameraclock)<<10),65536); if (keystatus[0x52]) //0 - cameraang -= ((totalclock-cameraclock)<<(2+(keystatus[0x2a]|keystatus[0x36]))); + cameraang -= (((int32_t) totalclock-cameraclock)<<(2+(keystatus[0x2a]|keystatus[0x36]))); if (keystatus[0x53]) //. - cameraang += ((totalclock-cameraclock)<<(2+(keystatus[0x2a]|keystatus[0x36]))); - cameraclock = totalclock; + cameraang += (((int32_t) totalclock-cameraclock)<<(2+(keystatus[0x2a]|keystatus[0x36]))); + cameraclock = (int32_t) totalclock; } for (i=connecthead; i>=0; i=connectpoint2[i]) @@ -4806,7 +4806,7 @@ void playback(void) movethings(); domovethings(); i++; } - drawscreen(screenpeek,(totalclock-gotlastpacketclock)*(65536/(TIMERINTSPERSECOND/MOVESPERSECOND))); + drawscreen(screenpeek,((int32_t) totalclock-gotlastpacketclock)*(65536/(TIMERINTSPERSECOND/MOVESPERSECOND))); if (keystatus[keys[15]]) { @@ -5263,7 +5263,7 @@ void checkmasterslaveswitch(void) else Bsprintf(getmessage,"Player %d (Slave)",j); getmessageleng = Bstrlen(getmessage); - getmessagetimeoff = totalclock+120; + getmessagetimeoff = (int32_t) totalclock+120; return; } @@ -5477,7 +5477,7 @@ int loadgame(void) Bstrcpy(getmessage,"Game loaded."); getmessageleng = Bstrlen(getmessage); - getmessagetimeoff = totalclock+360+(getmessageleng<<4); + getmessagetimeoff = (int32_t) totalclock+360+(getmessageleng<<4); return 0; } @@ -5651,7 +5651,7 @@ int savegame(void) Bstrcpy(getmessage,"Game saved."); getmessageleng = Bstrlen(getmessage); - getmessagetimeoff = totalclock+360+(getmessageleng<<4); + getmessagetimeoff = (int32_t) totalclock+360+(getmessageleng<<4); return 0; } @@ -5717,7 +5717,7 @@ void faketimerhandler(void) j = k; } - gotlastpacketclock = totalclock; + gotlastpacketclock = (int32_t) totalclock; return; } @@ -5858,7 +5858,7 @@ void getpackets(void) case 2: getmessageleng = packbufleng-1; for (j=getmessageleng-1; j>=0; j--) getmessage[j] = packbuf[j+1]; - getmessagetimeoff = totalclock+360+(getmessageleng<<4); + getmessagetimeoff = (int32_t) totalclock+360+(getmessageleng<<4); wsay("getstuff.wav",8192L,63L,63L); //Added 12/2004 break; case 3: diff --git a/source/sw/src/anim.cpp b/source/sw/src/anim.cpp index d1572e3f7..8aecf3cbb 100644 --- a/source/sw/src/anim.cpp +++ b/source/sw/src/anim.cpp @@ -319,7 +319,7 @@ playanm(short anim_num) SoundState = 0; //ototalclock = totalclock + 120*2; - ototalclock = totalclock; + ototalclock = (int32_t) totalclock; for (i = 1; i < numframes; i++) { diff --git a/source/sw/src/draw.cpp b/source/sw/src/draw.cpp index a58e4408a..930dac3f9 100644 --- a/source/sw/src/draw.cpp +++ b/source/sw/src/draw.cpp @@ -1383,7 +1383,7 @@ void PrintLocationInfo(PLAYERp pp) if (LocationInfo) { - i = totalclock; + i = (int32_t) totalclock; if (i != frameval[framecnt]) { sprintf(buffer, "FPS: %d", ((120 * AVERAGEFRAMES) / (i - frameval[framecnt])) + f_c); @@ -1744,7 +1744,7 @@ void DrawMessageInput(PLAYERp pp) short c; // Used to make cursor fade in and out - c = 4-(sintable[(totalclock<<4)&2047]>>11); + c = 4-(sintable[((int32_t) totalclock<<4)&2047]>>11); if (MessageInputMode) { @@ -1754,12 +1754,12 @@ void DrawMessageInput(PLAYERp pp) if (cur_show) { minigametext(TEXT_XCENTER(w), MESSAGE_LINE, MessageInputString,0,ROTATE_SPRITE_SCREEN_CLIP); - rotatesprite((TEXT_XCENTER(w)+w+2)<<16,(MESSAGE_LINE+1)<<16,20000,0,COINCURSOR+((totalclock>>3)%7),c,0,ROTATE_SPRITE_SCREEN_CLIP,0,0,xdim-1,ydim-1); + rotatesprite((TEXT_XCENTER(w)+w+2)<<16,(MESSAGE_LINE+1)<<16,20000,0,COINCURSOR+(((int32_t) totalclock>>3)%7),c,0,ROTATE_SPRITE_SCREEN_CLIP,0,0,xdim-1,ydim-1); } else { minigametext(TEXT_XCENTER(w), MESSAGE_LINE, MessageInputString,0,ROTATE_SPRITE_SCREEN_CLIP); - rotatesprite((TEXT_XCENTER(w)+w+2)<<16,(MESSAGE_LINE+1)<<16,20000,0,COINCURSOR+((totalclock>>3)%7),c,0,ROTATE_SPRITE_SCREEN_CLIP,0,0,xdim-1,ydim-1); + rotatesprite((TEXT_XCENTER(w)+w+2)<<16,(MESSAGE_LINE+1)<<16,20000,0,COINCURSOR+(((int32_t) totalclock>>3)%7),c,0,ROTATE_SPRITE_SCREEN_CLIP,0,0,xdim-1,ydim-1); } } } @@ -1774,7 +1774,7 @@ void DrawConInput(PLAYERp pp) short c; // Used to make cursor fade in and out - c = 4-(sintable[(totalclock<<4)&2047]>>11); + c = 4-(sintable[((int32_t) totalclock<<4)&2047]>>11); if (ConInputMode) { @@ -2309,7 +2309,7 @@ drawscreen(PLAYERp pp) PreUpdatePanel(); - smoothratio = min(max((totalclock - ototalclock) * (65536 / synctics),0),65536); + smoothratio = min(max(((int32_t) totalclock - ototalclock) * (65536 / synctics),0),65536); if (!ScreenSavePic) { diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index ef8e063d9..c2bfdccbc 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -2100,7 +2100,7 @@ MenuLevel(void) SWBOOL MNU_StartNetGame(void); char called; int fin; - extern int totalclocklock; + extern ClockTicks totalclocklock; short w,h; DSPRINTF(ds,"MenuLevel..."); @@ -5602,7 +5602,7 @@ void drawoverheadmap(int cposx, int cposy, int czoom, short cang) if (Player[p].PlayerSprite == j) { if (sprite[Player[p].PlayerSprite].xvel > 16) - pspr_ndx[myconnectindex] = ((totalclock>>4)&3); + pspr_ndx[myconnectindex] = (((int32_t) totalclock>>4)&3); sprisplayer = TRUE; goto SHOWSPRITE; diff --git a/source/sw/src/jnstub.cpp b/source/sw/src/jnstub.cpp index dd24b7236..65337211d 100644 --- a/source/sw/src/jnstub.cpp +++ b/source/sw/src/jnstub.cpp @@ -1430,7 +1430,7 @@ static void sw_printmessage256(const char *text) } static void sw_printmessage16(const char *text) { - lastpm16time = totalclock; + lastpm16time = (int32_t) totalclock; _printmessage16("%s", text); } @@ -2166,7 +2166,7 @@ ExtCheckKeys(void) static int frameval[AVERAGEFRAMES], framecnt = 0; int i; - i = totalclock; + i = (int32_t) totalclock; if (i != frameval[framecnt]) { sprintf(tempbuf, "%d", ((120 * AVERAGEFRAMES) / (i - frameval[framecnt])) + f_c); diff --git a/source/sw/src/jplayer.cpp b/source/sw/src/jplayer.cpp index d781d9d3a..4167114f7 100644 --- a/source/sw/src/jplayer.cpp +++ b/source/sw/src/jplayer.cpp @@ -622,7 +622,7 @@ void computergetinput(int snum, SW_PACKET *syn) //Strafe attack if (fightdist) { - j = totalclock+snum*13468; + j = (int32_t) totalclock+snum*13468; i = sintable[(j<<6)&2047]; i += sintable[((j+4245)<<5)&2047]; i += sintable[((j+6745)<<4)&2047]; @@ -843,7 +843,7 @@ void computergetinput(int snum, SW_PACKET *syn) daang = getangle(x2-x1,y2-y1); if ((i&0xc000) == 32768) daang = getangle(wall[wall[i&(MAXWALLS-1)].point2].x-wall[i&(MAXWALLS-1)].x,wall[wall[i&(MAXWALLS-1)].point2].y-wall[i&(MAXWALLS-1)].y); - j = totalclock+snum*13468; + j = (int32_t) totalclock+snum*13468; i = sintable[(j<<6)&2047]; i += sintable[((j+4245)<<5)&2047]; i += sintable[((j+6745)<<4)&2047]; diff --git a/source/sw/src/jsector.cpp b/source/sw/src/jsector.cpp index 1a337e2ef..5c89d2977 100644 --- a/source/sw/src/jsector.cpp +++ b/source/sw/src/jsector.cpp @@ -657,7 +657,7 @@ JS_DrawMirrors(PLAYERp pp, int tx, int ty, int tz, short tpang, int tphoriz) MirrorMoveSkip16 = (MirrorMoveSkip16 + 1) & 15; - camloopcnt += (totalclock - ototalclock); + camloopcnt += (int32_t) (totalclock - ototalclock); if (camloopcnt > (60 * 5)) // 5 seconds per player view { camloopcnt = 0; diff --git a/source/sw/src/menus.cpp b/source/sw/src/menus.cpp index d874df037..7dd3a1604 100644 --- a/source/sw/src/menus.cpp +++ b/source/sw/src/menus.cpp @@ -714,12 +714,12 @@ MNU_DoParentalPassword(UserCall call, MenuItem_p item) if (cur_show) { MNU_DrawString(TEXT_XCENTER(w), MESSAGE_LINE, MessageInputString,1,16); - rotatesprite((TEXT_XCENTER(w)+w+7)<<16,(MESSAGE_LINE+3)<<16,64<<9,0,COINCURSOR+((totalclock>>3)%7),0,0,MenuDrawFlags,0,0,xdim-1,ydim-1); + rotatesprite((TEXT_XCENTER(w)+w+7)<<16,(MESSAGE_LINE+3)<<16,64<<9,0,COINCURSOR+(((int32_t) totalclock>>3)%7),0,0,MenuDrawFlags,0,0,xdim-1,ydim-1); } else { MNU_DrawString(TEXT_XCENTER(w), MESSAGE_LINE, MessageInputString,1,16); - rotatesprite((TEXT_XCENTER(w)+w+7)<<16,(MESSAGE_LINE+3)<<16,64<<9,0,COINCURSOR+((totalclock>>3)%7),0,0,MenuDrawFlags,0,0,xdim-1,ydim-1); + rotatesprite((TEXT_XCENTER(w)+w+7)<<16,(MESSAGE_LINE+3)<<16,64<<9,0,COINCURSOR+(((int32_t) totalclock>>3)%7),0,0,MenuDrawFlags,0,0,xdim-1,ydim-1); } } @@ -1695,7 +1695,7 @@ MNU_OrderCustom(UserCall call, MenuItem *item) } else { - if (labs(totalclock - limitmove) > 7) + if (labs((int32_t) totalclock - limitmove) > 7) { order_input.button0 = order_input_buffered.button0; order_input.button1 = order_input_buffered.button1; @@ -1705,7 +1705,7 @@ MNU_OrderCustom(UserCall call, MenuItem *item) order_input_buffered.button1 = tst_input.button1; order_input_buffered.dir = tst_input.dir; - limitmove = totalclock; + limitmove = (int32_t) totalclock; } } } @@ -1847,7 +1847,7 @@ MNU_OrderCustom(UserCall call, MenuItem *item) } int m,i; - for (m=0, i=(totalclock/104)%numscrollerlines; m<4; m++,i++) + for (m=0, i=((int32_t) totalclock/104)%numscrollerlines; m<4; m++,i++) { if (i == numscrollerlines) i=0; @@ -2998,7 +2998,7 @@ MNU_LoadSaveDraw(UserCall call, MenuItem_p item) char tmp[sizeof(SaveGameDescr[0])*2]; //cur_show ^= 1; - cur_show = (totalclock & 32); + cur_show = ((int32_t) totalclock & 32); if (cur_show) { // add a cursor to the end @@ -4610,7 +4610,7 @@ void MNU_DoMenu(CTLType type, PLAYERp pp) mnu_input.dir = dir_None; // should not get input if you are editing a save game slot - if (totalclock < limitmove) limitmove = totalclock; + if (totalclock < limitmove) limitmove = (int32_t) totalclock; if (!MenuInputMode) { UserInput tst_input; @@ -4658,7 +4658,7 @@ void MNU_DoMenu(CTLType type, PLAYERp pp) if (!FX_SoundActive(handle2)) handle2 = PlaySound(DIGI_STAR,&zero,&zero,&zero,v3df_dontpan); - limitmove = totalclock; + limitmove = (int32_t) totalclock; mnu_input_buffered.dir = dir_None; } } @@ -4885,9 +4885,9 @@ Fade_Timer(int clicks) // unsigned int now; int now; - now = totalclock; + now = (int32_t) totalclock; - while (abs(totalclock - now) < clicks) handleevents(); + while (abs((int32_t) totalclock - now) < clicks) handleevents(); } void diff --git a/source/sw/src/network.cpp b/source/sw/src/network.cpp index b92d6c452..df75e37d1 100644 --- a/source/sw/src/network.cpp +++ b/source/sw/src/network.cpp @@ -423,7 +423,7 @@ void PauseAction(void) { ready2send = 0; - save_totalclock = totalclock; + save_totalclock = (int32_t) totalclock; } void @@ -842,7 +842,7 @@ void ErrorCorrectionQuit(void) { for (j = 0; j < MAX_SW_PLAYERS; j++) { - oldtotalclock = totalclock; + oldtotalclock = (int32_t) totalclock; while (totalclock < oldtotalclock + synctics) { handleevents(); diff --git a/source/sw/src/setup.cpp b/source/sw/src/setup.cpp index 7b1d93d5f..af44d3637 100644 --- a/source/sw/src/setup.cpp +++ b/source/sw/src/setup.cpp @@ -100,7 +100,7 @@ static int32_t timert; int32_t GetTime(void) { - return totalclock; + return (int32_t) totalclock; //return timert++; } diff --git a/source/sw/src/weapon.cpp b/source/sw/src/weapon.cpp index c410cdd95..3224e8c35 100644 --- a/source/sw/src/weapon.cpp +++ b/source/sw/src/weapon.cpp @@ -17900,14 +17900,14 @@ InitUzi(PLAYERp pp) if (uziclock > totalclock) { - uziclock = totalclock; + uziclock = (int32_t) totalclock; FireSnd = TRUE; } - clockdiff = totalclock - uziclock; + clockdiff = (int32_t) totalclock - uziclock; if (clockdiff > UZIFIRE_WAIT) { - uziclock = totalclock; + uziclock = (int32_t) totalclock; FireSnd = TRUE; }