From 7a9209d8571e902742ea3f0666c905af77ee364e Mon Sep 17 00:00:00 2001 From: nukeykt Date: Sat, 7 Sep 2019 22:15:39 +0900 Subject: [PATCH] Fix compile error # Conflicts: # source/blood/src/ai.cpp # source/blood/src/aiunicult.cpp # source/blood/src/blood.cpp # source/blood/src/choke.cpp # source/blood/src/credits.cpp # source/blood/src/gamemenu.cpp # source/blood/src/gamemenu.h # source/blood/src/gui.cpp # source/blood/src/mapedit.cpp # source/blood/src/replace.cpp --- source/blood/src/actor.cpp | 22 ++++++------ source/blood/src/ai.cpp | 20 +++++------ source/blood/src/aiunicult.cpp | 16 ++++----- source/blood/src/blood.cpp | 10 +++--- source/blood/src/choke.cpp | 10 +++--- source/blood/src/controls.cpp | 2 +- source/blood/src/credits.cpp | 24 ++++++------- source/blood/src/demo.cpp | 6 ++-- source/blood/src/endgame.cpp | 2 +- source/blood/src/eventq.cpp | 4 +-- source/blood/src/fire.cpp | 6 ++-- source/blood/src/gamemenu.cpp | 64 +++++++++++++++++----------------- source/blood/src/gamemenu.h | 6 ++-- source/blood/src/gameutil.cpp | 4 +-- source/blood/src/globals.cpp | 7 ++-- source/blood/src/globals.h | 8 +++-- source/blood/src/loadsave.cpp | 10 +++--- source/blood/src/messages.cpp | 6 ++-- source/blood/src/messages.h | 8 +++-- source/blood/src/network.cpp | 14 ++++---- source/blood/src/network.h | 4 ++- source/blood/src/player.cpp | 2 +- source/blood/src/player.h | 4 ++- source/blood/src/replace.cpp | 5 +-- source/blood/src/sectorfx.cpp | 2 +- source/blood/src/triggers.cpp | 6 ++-- source/blood/src/view.cpp | 55 ++++++++++++++++------------- source/blood/src/view.h | 7 ++-- source/blood/src/weapon.cpp | 22 ++++++------ 29 files changed, 186 insertions(+), 170 deletions(-) diff --git a/source/blood/src/actor.cpp b/source/blood/src/actor.cpp index 84417f8c1..60fb29dab 100644 --- a/source/blood/src/actor.cpp +++ b/source/blood/src/actor.cpp @@ -3055,7 +3055,7 @@ void actKillDude(int a1, spritetype *pSprite, DAMAGE_TYPE a3, int a4) aiNewState(pSprite, pXSprite, &GDXGenDudeBurnGoto); actHealDude(pXSprite, dudeInfo[55].startHealth, dudeInfo[55].startHealth); if (pXSprite->burnTime <= 0) pXSprite->burnTime = 1200; - gDudeExtra[pSprite->extra].at0 = gFrameClock + 360; + gDudeExtra[pSprite->extra].at0 = (int)gFrameClock + 360; return; } @@ -3675,7 +3675,7 @@ int actDamageSprite(int nSource, spritetype *pSprite, DAMAGE_TYPE a3, int a4) if (a3 == 3 && pSourcePlayer && gFrameClock > pSourcePlayer->at312 && Chance(0x4000)) { sfxPlay3DSound(pSourcePlayer->pSprite, gPlayerGibThingComments[Random(10)], 0, 2); - pSourcePlayer->at312 = gFrameClock+3600; + pSourcePlayer->at312 = (int)gFrameClock+3600; } break; case 413: @@ -4348,7 +4348,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite) { if (pPlayer->at30e > gFrameClock) return; - pPlayer->at30e = gFrameClock+60; + pPlayer->at30e = (int)gFrameClock+60; } actKickObject(pSprite, pSprite2); sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, 357, pSprite->sectnum); @@ -4359,7 +4359,7 @@ void ProcessTouchObjects(spritetype *pSprite, int nXSprite) { if (pPlayer->at30e > gFrameClock) return; - pPlayer->at30e = gFrameClock+60; + pPlayer->at30e = (int)gFrameClock+60; } actKickObject(pSprite, pSprite2); sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, 357, pSprite->sectnum); @@ -4503,9 +4503,9 @@ int MoveThing(spritetype *pSprite) spritetype *pFX = gFX.fxSpawn(FX_27, pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, 0); if (pFX) { - int v34 = (gFrameClock*3)&2047; - int v30 = (gFrameClock*5)&2047; - int vbx = (gFrameClock*11)&2047; + int v34 = ((int)gFrameClock*3)&2047; + int v30 = ((int)gFrameClock*5)&2047; + int vbx = ((int)gFrameClock*11)&2047; int v2c = 0x44444; int v28 = 0; int v24 = 0; @@ -6243,7 +6243,7 @@ spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType) pXThing->data2 = 0; pXThing->data3 = 0; pXThing->data4 = 318; - pXThing->targetX = gFrameClock+180.0; + pXThing->targetX = (int)gFrameClock+180.0; pXThing->locked = 1; pXThing->state = 1; pXThing->triggerOnce = 0; @@ -6258,7 +6258,7 @@ spritetype * actSpawnThing(int nSector, int x, int y, int z, int nThingType) pXThing->data2 = 0; pXThing->data3 = 0; pXThing->data4 = 318; - pXThing->targetX = gFrameClock+180.0; + pXThing->targetX = (int)gFrameClock+180.0; pXThing->locked = 1; pXThing->state = 1; pXThing->triggerOnce = 0; @@ -6833,7 +6833,7 @@ void DudeToGibCallback1(int, int nXSprite) pXSprite->triggerOnce = 0; pXSprite->isTriggered = 0; pXSprite->locked = 0; - pXSprite->targetX = gFrameClock; + pXSprite->targetX = (int)gFrameClock; pXSprite->state = 1; } @@ -6851,7 +6851,7 @@ void DudeToGibCallback2(int, int nXSprite) pXSprite->triggerOnce = 0; pXSprite->isTriggered = 0; pXSprite->locked = 0; - pXSprite->targetX = gFrameClock; + pXSprite->targetX = (int)gFrameClock; pXSprite->state = 1; } diff --git a/source/blood/src/ai.cpp b/source/blood/src/ai.cpp index 6211254da..810ce4bf2 100644 --- a/source/blood/src/ai.cpp +++ b/source/blood/src/ai.cpp @@ -92,12 +92,12 @@ void aiPlay3DSound(spritetype *pSprite, int a2, AI_SFX_PRIORITY a3, int a4) DUDEEXTRA *pDudeExtra = &gDudeExtra[pSprite->extra]; if (a3 == AI_SFX_PRIORITY_0) sfxPlay3DSound(pSprite, a2, a4, 2); - else if (a3 > pDudeExtra->at5 || pDudeExtra->at0 <= gFrameClock) + else if (a3 > pDudeExtra->at5 || pDudeExtra->at0 <= (int)gFrameClock) { sfxKill3DSound(pSprite, -1, -1); sfxPlay3DSound(pSprite, a2, a4, 0); pDudeExtra->at5 = a3; - pDudeExtra->at0 = gFrameClock+120; + pDudeExtra->at0 = (int)gFrameClock+120; } } @@ -986,7 +986,7 @@ int aiDamageSprite(spritetype *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_T aiNewState(pSprite, pXSprite, &cultistBurnGoto); aiPlay3DSound(pSprite, 361, AI_SFX_PRIORITY_0, -1); aiPlay3DSound(pSprite, 1031+Random(2), AI_SFX_PRIORITY_2, -1); - gDudeExtra[pSprite->extra].at0 = gFrameClock+360; + gDudeExtra[pSprite->extra].at0 = (int)gFrameClock+360; actHealDude(pXSprite, dudeInfo[40].startHealth, dudeInfo[40].startHealth); evKill(nSprite, 3, CALLBACK_ID_0); } @@ -997,7 +997,7 @@ int aiDamageSprite(spritetype *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_T pSprite->type = 239; aiNewState(pSprite, pXSprite, &cultistBurnGoto); aiPlay3DSound(pSprite, 361, AI_SFX_PRIORITY_0, -1); - gDudeExtra[pSprite->extra].at0 = gFrameClock+360; + gDudeExtra[pSprite->extra].at0 = (int)gFrameClock+360; actHealDude(pXSprite, dudeInfo[39].startHealth, dudeInfo[39].startHealth); evKill(nSprite, 3, CALLBACK_ID_0); } @@ -1006,7 +1006,7 @@ int aiDamageSprite(spritetype *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_T if (Chance(0x4000) && gDudeExtra[pSprite->extra].at0 < gFrameClock) { aiPlay3DSound(pSprite, 1031+Random(2), AI_SFX_PRIORITY_2, -1); - gDudeExtra[pSprite->extra].at0 = gFrameClock+360; + gDudeExtra[pSprite->extra].at0 = (int)gFrameClock+360; } if (Chance(0x600) && (pXSprite->medium == 1 || pXSprite->medium == 2)) { @@ -1040,18 +1040,18 @@ int aiDamageSprite(spritetype *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_T { pSprite->type = 239; if (!VanillaMode()) - pXSprite->scale = -4; // need to change this to 64 later + pXSprite->scale = 64; aiNewState(pSprite, pXSprite, &cultistBurnGoto); aiPlay3DSound(pSprite, 361, AI_SFX_PRIORITY_0, -1); - gDudeExtra[pSprite->extra].at0 = gFrameClock+360; + gDudeExtra[pSprite->extra].at0 = (int)gFrameClock+360; actHealDude(pXSprite, dudeInfo[39].startHealth, dudeInfo[39].startHealth); evKill(nSprite, 3, CALLBACK_ID_0); } break; case kGDXGenDudeBurning: - if (Chance(0x2000) && gDudeExtra[pSprite->extra].at0 < gFrameClock) { + if (Chance(0x2000) && gDudeExtra[pSprite->extra].at0 < (int)gFrameClock) { sfxPlayGDXGenDudeSound(pSprite, 3, pXSprite->data3); - gDudeExtra[pSprite->extra].at0 = gFrameClock + 360; + gDudeExtra[pSprite->extra].at0 = (int)gFrameClock + 360; } if (pXSprite->burnTime == 0) pXSprite->burnTime = 2400; if (spriteIsUnderwater(pSprite, false)) { @@ -1091,7 +1091,7 @@ int aiDamageSprite(spritetype *pSprite, XSPRITE *pXSprite, int nSource, DAMAGE_T aiNewState(pSprite, pXSprite, &GDXGenDudeBurnGoto); actHealDude(pXSprite, dudeInfo[55].startHealth, dudeInfo[55].startHealth); - gDudeExtra[pSprite->extra].at0 = gFrameClock + 360; + gDudeExtra[pSprite->extra].at0 = (int)gFrameClock + 360; evKill(nSprite, 3, CALLBACK_ID_0); } diff --git a/source/blood/src/aiunicult.cpp b/source/blood/src/aiunicult.cpp index 541299814..7d514c347 100644 --- a/source/blood/src/aiunicult.cpp +++ b/source/blood/src/aiunicult.cpp @@ -470,11 +470,13 @@ static void thinkChase( spritetype* pSprite, XSPRITE* pXSprite ) if ((gFrameClock & 64) == 0 && Chance(0x1000) && !spriteIsUnderwater(pSprite,false)) sfxPlayGDXGenDudeSound(pSprite,6,pXSprite->data3); - if (dist <= 1500) gDudeSlope[sprite[pXSprite->reference].extra] = divscale(pTarget->z - pSprite->z, dist, 13); - else if (dist <= 3000) gDudeSlope[sprite[pXSprite->reference].extra] = divscale(pTarget->z - pSprite->z, dist, 11); - else if (dist > 0) gDudeSlope[sprite[pXSprite->reference].extra] = divscale(pTarget->z - pSprite->z, dist, 10); - - spritetype* pLeech = NULL; + if (pXSprite->target < 0) aiSetTarget(pXSprite, pXSprite->target); + if (((int)gFrameClock & 64) == 0 && Chance(0x3000) && !spriteIsUnderwater(pSprite, false)) + sfxPlayGDXGenDudeSound(pSprite, 6); + + gDudeSlope[sprite[pXSprite->reference].extra] = (int)divscale(pTarget->z - pSprite->z, dist, 10); + + spritetype* pLeech = NULL; VECTORDATA* meleeVector = &gVectorData[22]; if (pXSprite->data1 >= kThingBase && pXSprite->data1 < kThingMax) { if (pXSprite->data1 == 431) pXSprite->data1 = kGDXThingCustomDudeLifeLeech; if (klabs(losAngle) < kAng15) { @@ -677,9 +679,7 @@ static void thinkChase( spritetype* pSprite, XSPRITE* pXSprite ) return; } - vdist = 4200; - if ((gFrameClock & 16) == 0) - vdist += Random(800); + vdist = 4200; if (((int)gFrameClock & 16) == 0) vdist += Random(800); break; } } diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index f12011284..9a2bb2844 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -436,7 +436,7 @@ void PreloadCache(void) sndTryPlaySpecialMusic(MUS_LOADING); gSoundRes.PrecacheSounds(); PreloadTiles(); - int clock = totalclock.Ticks(); + ClockTicks clock = totalclock; int cnt = 0; int percentDisplayed = -1; @@ -656,7 +656,7 @@ void StartLevel(GAMEOPTIONS *gameOptions) if (gGameOptions.nGameType == 3) gGameMessageMgr.SetCoordinates(gViewX0S+1,gViewY0S+15); netWaitForEveryone(0); - gGameClock = 0; + totalclock = 0; gPaused = 0; gGameStarted = 1; ready2send = 1; @@ -908,7 +908,7 @@ void ProcessFrame(void) playerProcess(&gPlayer[i]); } trProcessBusy(); - evProcess(gFrameClock); + evProcess((int)gFrameClock); seqProcess(4); DoSectorPanning(); actProcessSprites(); @@ -1353,7 +1353,7 @@ void ParseOptions(void) void ClockStrobe() { - gGameClock++; + //gGameClock++; } #if defined(_WIN32) && defined(DEBUGGINGAIDS) @@ -1635,7 +1635,7 @@ RESTART: } if (numplayers == 1) gBufferJitter = 0; - while (gGameClock >= gNetFifoClock && ready2send) + while (totalclock >= gNetFifoClock && ready2send) { netGetInput(); gNetFifoClock += 4; diff --git a/source/blood/src/choke.cpp b/source/blood/src/choke.cpp index 2ee56c293..d96550c4e 100644 --- a/source/blood/src/choke.cpp +++ b/source/blood/src/choke.cpp @@ -92,12 +92,12 @@ void CChoke::sub_84110(int x, int y) { if (!at4) return; - int v4 = gFrameClock; - gFrameClock = gGameClock; + ClockTicks v4 = gFrameClock; + gFrameClock = totalclock; at8->x = x; at8->y = y; - int vd = totalclock.Ticks()-at10; - at10 = totalclock.Ticks(); + int vd = (int)totalclock-at10; + at10 = (int)totalclock; atc -= vd; if (atc <= 0 || atc > at8->at10) atc = at8->at10; @@ -121,7 +121,7 @@ void CChoke::sub_84110(int x, int y) void CChoke::sub_84218() { atc = at8->at10; - at10 = totalclock.Ticks(); + at10 = (int)totalclock; } void sub_84230(PLAYER *pPlayer) diff --git a/source/blood/src/controls.cpp b/source/blood/src/controls.cpp index 5f7c073bc..277b99e71 100644 --- a/source/blood/src/controls.cpp +++ b/source/blood/src/controls.cpp @@ -61,7 +61,7 @@ int iTurnCount = 0; int32_t GetTime(void) { - return gGameClock; + return (int32_t)totalclock; } void ctrlInit(void) diff --git a/source/blood/src/credits.cpp b/source/blood/src/credits.cpp index ae7b228cb..96dc68ebd 100644 --- a/source/blood/src/credits.cpp +++ b/source/blood/src/credits.cpp @@ -39,8 +39,8 @@ char exitCredits = 0; char Wait(int nTicks) { - gGameClock = 0; - while (gGameClock < nTicks) + totalclock = 0; + while (totalclock < nTicks) { timerUpdate(); char key = keyGetScan(); @@ -58,16 +58,16 @@ char DoFade(char r, char g, char b, int nTicks) { dassert(nTicks > 0); scrSetupFade(r, g, b); - gGameClock = gFrameClock = 0; + totalclock = gFrameClock = 0; do { - while (gGameClock < gFrameClock) { timerUpdate();}; + while (totalclock < gFrameClock) { timerUpdate();}; gFrameClock += 2; scrNextPage(); - scrFadeAmount(divscale16(ClipHigh(gGameClock, nTicks), nTicks)); + scrFadeAmount(divscale16(ClipHigh((int)totalclock, nTicks), nTicks)); if (keyGetScan()) return 0; - } while (gGameClock <= nTicks); + } while (totalclock <= nTicks); return 1; } @@ -75,15 +75,15 @@ char DoUnFade(int nTicks) { dassert(nTicks > 0); scrSetupUnfade(); - gGameClock = gFrameClock = 0; + totalclock = gFrameClock = 0; do { - while (gGameClock < gFrameClock) { timerUpdate(); }; + while (totalclock < gFrameClock) { timerUpdate(); }; scrNextPage(); - scrFadeAmount(0x10000-divscale16(ClipHigh(gGameClock, nTicks), nTicks)); + scrFadeAmount(0x10000-divscale16(ClipHigh((int)totalclock, nTicks), nTicks)); if (keyGetScan()) return 0; - } while (gGameClock <= nTicks); + } while (totalclock <= nTicks); return 1; } @@ -245,7 +245,7 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav) UpdateDacs(0, true); timerUpdate(); - int32_t nStartTime = totalclock.Ticks(); + ClockTicks nStartTime = totalclock; ctrlClearAllInput(); @@ -253,7 +253,7 @@ void credPlaySmk(const char *_pzSMK, const char *_pzWAV, int nWav) do { G_HandleAsync(); - if (scale(totalclock.Ticks() -nStartTime, nFrameRate, kTicRate) < nFrame) + if (scale((int)(totalclock-nStartTime), nFrameRate, kTicRate) < nFrame) continue; if (ctrlCheckAllInput()) diff --git a/source/blood/src/demo.cpp b/source/blood/src/demo.cpp index ba462bd44..e096b5d0d 100644 --- a/source/blood/src/demo.cpp +++ b/source/blood/src/demo.cpp @@ -328,7 +328,7 @@ void CDemo::Playback(void) gGameMenuMgr.Push(&menuMain, -1); at2 = 1; } - gNetFifoClock = gGameClock; + gNetFifoClock = totalclock; gViewMode = 3; _DEMOPLAYBACK: while (at1 && !gQuitGame) @@ -339,7 +339,7 @@ _DEMOPLAYBACK: quitevent = 0; } MUSIC_Update(); - while (gGameClock >= gNetFifoClock && !gQuitGame) + while (totalclock >= gNetFifoClock && !gQuitGame) { if (!v4) { @@ -390,7 +390,7 @@ _DEMOPLAYBACK: v4 = 0; Close(); NextDemo(); - gNetFifoClock = gGameClock; + gNetFifoClock = totalclock; goto _DEMOPLAYBACK; } else diff --git a/source/blood/src/endgame.cpp b/source/blood/src/endgame.cpp index 07f09e778..a7d6c1f25 100644 --- a/source/blood/src/endgame.cpp +++ b/source/blood/src/endgame.cpp @@ -63,7 +63,7 @@ void CEndGameMgr::Draw(void) viewDrawText(1, "FRAG STATS", 160, nY, -128, 0, 1, 0); gKillMgr.Draw(); } - if (/*dword_28E3D4 != 1 && */(gGameClock&32)) + if (/*dword_28E3D4 != 1 && */((int)totalclock&32)) { viewDrawText(3, "PRESS A KEY TO CONTINUE", 160, 134, -128, 0, 1, 1); } diff --git a/source/blood/src/eventq.cpp b/source/blood/src/eventq.cpp index 4ef146ac2..1801d9397 100644 --- a/source/blood/src/eventq.cpp +++ b/source/blood/src/eventq.cpp @@ -479,7 +479,7 @@ void evPost(int nIndex, int nType, unsigned int nDelta, COMMAND_ID command) evn.type = nType; evn.cmd = command; // Inlined? - eventQ.PQueue->Insert(gFrameClock+nDelta, evn); + eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn); } void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID a4) @@ -489,7 +489,7 @@ void evPost(int nIndex, int nType, unsigned int nDelta, CALLBACK_ID a4) evn.type = nType; evn.cmd = kCommandCallback; evn.funcID = a4; - eventQ.PQueue->Insert(gFrameClock+nDelta, evn); + eventQ.PQueue->Insert((int)gFrameClock+nDelta, evn); } void evProcess(unsigned int nTime) diff --git a/source/blood/src/fire.cpp b/source/blood/src/fire.cpp index a471a34f2..e8782b895 100644 --- a/source/blood/src/fire.cpp +++ b/source/blood/src/fire.cpp @@ -95,11 +95,11 @@ void FireInit(void) void FireProcess(void) { - static int lastUpdate; - if (gGameClock < lastUpdate || lastUpdate + 2 < gGameClock) + static ClockTicks lastUpdate; + if (totalclock < lastUpdate || lastUpdate + 2 < totalclock) { DoFireFrame(); - lastUpdate = gGameClock; + lastUpdate = totalclock; tileInvalidate(2342, -1, -1); } } diff --git a/source/blood/src/gamemenu.cpp b/source/blood/src/gamemenu.cpp index 19163b0fb..468aa8e7a 100644 --- a/source/blood/src/gamemenu.cpp +++ b/source/blood/src/gamemenu.cpp @@ -175,7 +175,7 @@ void CGameMenuMgr::Draw(void) if (MOUSEACTIVECONDITIONAL(mouseAdvanceClickState()) || m_mousepos.x != m_prevmousepos.x || m_mousepos.y != m_prevmousepos.y) { m_prevmousepos = m_mousepos; - m_mouselastactivity = totalclock.Ticks(); + m_mouselastactivity = (int)totalclock; } else m_mousewake_watchpoint = 0; @@ -611,7 +611,7 @@ void CGameMenuItemZBool::Draw(void) int shade = bEnable ? 32 : 48; int pal = bEnable ? 0 : 5; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); if (m_pzText) gMenuTextMgr.DrawText(m_pzText, m_nFont, m_nX, m_nY, shade, pal, false); const char *value = at20 ? at21 : at25; @@ -686,7 +686,7 @@ void CGameMenuItemChain::Draw(void) int shade = bEnable ? 32 : 48; int pal = bEnable ? 0 : 5; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); int width, height; int x = m_nX; int y = m_nY; @@ -772,7 +772,7 @@ void CGameMenuItem7EA1C::Draw(void) int shade = bEnable ? 32 : 48; int pal = bEnable ? 0 : 5; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); int width; int x = m_nX; switch (at20) @@ -887,7 +887,7 @@ void CGameMenuItem7EE34::Draw(void) int shade = bEnable ? 32 : 48; int pal = bEnable ? 0 : 5; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); int width; int x = m_nX; switch (at24) @@ -1011,7 +1011,7 @@ void CGameMenuItemBitmap::Draw(void) int shade = bEnable ? 32 : 48; int pal = bEnable ? 0 : 5; if (bEnable && pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); int x = m_nX; int y = m_nY; if (m_pzText) @@ -1051,7 +1051,7 @@ void CGameMenuItemBitmapLS::Draw(void) int shade = bEnable ? 32 : 48; int pal = bEnable ? 0 : 5; if (bEnable && pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); int x = m_nX; int y = m_nY; if (m_pzText) @@ -1156,10 +1156,10 @@ void CGameMenuItemKeyList::Draw(void) { shade = 32; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); viewDrawText(3, buffer, m_nX, y, shade, 0, 0, false); const char *sVal; - if (bScan && (gGameClock & 32)) + if (bScan && ((int)totalclock & 32)) sVal = "____"; else sVal = buffer2; @@ -1304,13 +1304,13 @@ bool CGameMenuItemKeyList::MouseEvent(CGameMenuEvent &event) event.at0 = kMenuEventNone; if (MOUSEACTIVECONDITIONAL(MOUSE_GetButtons()&WHEELUP_MOUSE)) { - gGameMenuMgr.m_mouselastactivity = totalclock.Ticks(); + gGameMenuMgr.m_mouselastactivity = (int)totalclock; MOUSE_ClearButton(WHEELUP_MOUSE); event.at0 = kMenuEventScrollUp; } else if (MOUSEACTIVECONDITIONAL(MOUSE_GetButtons()&WHEELDOWN_MOUSE)) { - gGameMenuMgr.m_mouselastactivity = totalclock.Ticks(); + gGameMenuMgr.m_mouselastactivity = (int)totalclock; MOUSE_ClearButton(WHEELDOWN_MOUSE); event.at0 = kMenuEventScrollDown; } @@ -1389,7 +1389,7 @@ void CGameMenuItemSlider::Draw(void) int shade2 = bEnable ? 0 : 16; int pal = bEnable ? 0 : 5; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); if (m_pzText) gMenuTextMgr.DrawText(m_pzText, m_nFont, m_nX, m_nY, shade, pal, false); int sliderX = m_nX+m_nWidth-1-tilesiz[nSliderTile].x/2; @@ -1621,7 +1621,7 @@ void CGameMenuItemSliderFloat::Draw(void) int shade2 = bEnable ? 0 : 16; int pal = bEnable ? 0 : 5; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); if (m_pzText) gMenuTextMgr.DrawText(m_pzText, m_nFont, m_nX, m_nY, shade, pal, false); int sliderX = m_nX+m_nWidth-1-tilesiz[nSliderTile].x/2; @@ -1803,7 +1803,7 @@ void CGameMenuItemZEdit::Draw(void) int shade = bEnable ? 32 : 48; int pal = bEnable ? 0 : 5; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); if (at30) shade = -128; if (m_pzText) @@ -1831,7 +1831,7 @@ void CGameMenuItemZEdit::Draw(void) gMenuTextMgr.DrawText(at20, m_nFont, x, m_nY, shade2, pal, false); x += width; } - if (at30 && (gGameClock & 32)) + if (at30 && ((int)totalclock & 32)) gMenuTextMgr.DrawText("_", m_nFont, x, m_nY, shade, 0, false); int mx = m_nX<<16; @@ -1988,7 +1988,7 @@ void CGameMenuItemZEditBitmap::Draw(void) int shade = bEnable ? 32 : 48; int pal = bEnable ? 0 : 5; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); at2c->at24 = -1; if (at34) shade = -128; @@ -2017,7 +2017,7 @@ void CGameMenuItemZEditBitmap::Draw(void) gMenuTextMgr.DrawText(at20, m_nFont, x, m_nY, shade2, 0, false); x += width; } - if (at34 && (gGameClock & 32)) + if (at34 && ((int)totalclock & 32)) gMenuTextMgr.DrawText("_", m_nFont, x, m_nY, shade, pal, false); int mx = m_nX<<16; @@ -2148,10 +2148,10 @@ void CGameMenuItemQAV::Draw(void) videoClearScreen(0); if (at24) { - int backFC = gFrameClock; - gFrameClock = gGameClock; - int nTicks = totalclock.Ticks() - at30; - at30 = totalclock.Ticks(); + ClockTicks backFC = gFrameClock; + gFrameClock = totalclock; + int nTicks = (int)totalclock - at30; + at30 = (int)totalclock; at2c -= nTicks; if (at2c <= 0 || at2c > at28->at10) { @@ -2229,7 +2229,7 @@ bool CGameMenuItemQAV::Event(CGameMenuEvent &event) at28->y = m_nY; at28->Preload(); at2c = at28->at10; - at30 = totalclock.Ticks(); + at30 = (int)totalclock; return false; } gSysRes.Lock(at24); @@ -2250,7 +2250,7 @@ bool CGameMenuItemQAV::Event(CGameMenuEvent &event) void CGameMenuItemQAV::Reset(void) { at2c = at28->at10; - at30 = totalclock.Ticks(); + at30 = (int)totalclock; } CGameMenuItemZCycleSelect::CGameMenuItemZCycleSelect() @@ -2298,7 +2298,7 @@ void CGameMenuItemZCycleSelect::Draw(void) { shade = 32; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); viewDrawText(3, m_pzStrings[k], m_nX, y, shade, 0, 0, false); } else @@ -2396,13 +2396,13 @@ bool CGameMenuItemZCycleSelect::MouseEvent(CGameMenuEvent &event) event.at0 = kMenuEventNone; if (MOUSEACTIVECONDITIONAL(MOUSE_GetButtons()&WHEELUP_MOUSE)) { - gGameMenuMgr.m_mouselastactivity = totalclock.Ticks(); + gGameMenuMgr.m_mouselastactivity = (int)totalclock; MOUSE_ClearButton(WHEELUP_MOUSE); event.at0 = kMenuEventScrollUp; } else if (MOUSEACTIVECONDITIONAL(MOUSE_GetButtons()&WHEELDOWN_MOUSE)) { - gGameMenuMgr.m_mouselastactivity = totalclock.Ticks(); + gGameMenuMgr.m_mouselastactivity = (int)totalclock; MOUSE_ClearButton(WHEELDOWN_MOUSE); event.at0 = kMenuEventScrollDown; } @@ -2464,7 +2464,7 @@ void CGameMenuItemZCycle::Draw(void) int shade = bEnable ? 32 : 48; int pal = bEnable ? 0 : 5; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); int x = m_nX; int y = m_nY; @@ -2666,7 +2666,7 @@ void CGameMenuItemYesNoQuit::Draw(void) if (!m_pzText) return; int shade = 32; if (pMenu->IsFocusItem(this)) - shade = 32-(totalclock.Ticks() &63); + shade = 32-((int)totalclock&63); int width; int x = m_nX; switch (at20) @@ -2859,7 +2859,7 @@ void CGameMenuItemPassword::Draw(void) { bool focus = pMenu->IsFocusItem(this); int shade = 32; - int shadef = 32-(totalclock.Ticks() &63); + int shadef = 32-((int)totalclock&63); int width; switch (at37) { @@ -2886,7 +2886,7 @@ void CGameMenuItemPassword::Draw(void) shadef = 32; break; case 4: - if ((totalclock.Ticks() - at5b) & 32) + if (((int)totalclock - at5b) & 32) { gMenuTextMgr.GetFontInfo(m_nFont, kInvalidPasswordMsg, &width, NULL); gMenuTextMgr.DrawText(kInvalidPasswordMsg, m_nFont, m_nX - width / 2, m_nY + 20, shade, 0, false); @@ -2934,7 +2934,7 @@ bool CGameMenuItemPassword::Event(CGameMenuEvent &event) at37 = 4; if (!at36) { - at5b = totalclock.Ticks(); + at5b = (int)totalclock; pMenu->FocusPrevItem(); } else @@ -2962,7 +2962,7 @@ bool CGameMenuItemPassword::Event(CGameMenuEvent &event) at37 = 0; } else - at5b = totalclock.Ticks(); + at5b = (int)totalclock; return false; case 3: strcpy(at20, at29); diff --git a/source/blood/src/gamemenu.h b/source/blood/src/gamemenu.h index f6a7ff076..275dcca69 100644 --- a/source/blood/src/gamemenu.h +++ b/source/blood/src/gamemenu.h @@ -39,9 +39,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // 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.Ticks() - gGameMenuMgr.m_mouselastactivity - 90)*3, 0, 255) : 0) -#define CURSORALPHA (MOUSEUSEALPHA ? clamp((totalclock.Ticks() - gGameMenuMgr.m_mouselastactivity - 90)*2 + (255/3), (255/3), 255) : 255/3) -#define MOUSEACTIVECONDITION (totalclock - gGameMenuMgr.m_mouselastactivity < M_MOUSETIMEOUT) +#define MOUSEALPHA (MOUSEUSEALPHA ? clamp(((int)totalclock - gGameMenuMgr.m_mouselastactivity - 90)*3, 0, 255) : 0) +#define CURSORALPHA (MOUSEUSEALPHA ? clamp(((int)totalclock - gGameMenuMgr.m_mouselastactivity - 90)*2 + (255/3), (255/3), 255) : 255/3) +#define MOUSEACTIVECONDITION ((int)totalclock - gGameMenuMgr.m_mouselastactivity < M_MOUSETIMEOUT) #define MOUSEACTIVECONDITIONAL(condition) (MOUSEACTIVECONDITION && (condition)) #define MOUSEINACTIVECONDITIONAL(condition) (!MOUSEACTIVECONDITION && (condition)) #define MOUSEWATCHPOINTCONDITIONAL(condition) ((condition) || gGameMenuMgr.m_mousewake_watchpoint || gGameMenuMgr.m_menuchange_watchpoint == 3) diff --git a/source/blood/src/gameutil.cpp b/source/blood/src/gameutil.cpp index 534788e9c..9a14e8e18 100644 --- a/source/blood/src/gameutil.cpp +++ b/source/blood/src/gameutil.cpp @@ -145,8 +145,8 @@ void CalcFrameRate(void) static int index; if (ticks[index] != gFrameClock) { - gFrameRate = (120*64)/(gFrameClock-ticks[index]); - ticks[index] = gFrameClock; + gFrameRate = (120*64)/((int)gFrameClock-ticks[index]); + ticks[index] = (int)gFrameClock; } index = (index+1) & 63; } diff --git a/source/blood/src/globals.cpp b/source/blood/src/globals.cpp index e780df458..bb825302e 100644 --- a/source/blood/src/globals.cpp +++ b/source/blood/src/globals.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include "compat.h" +#include "build.h" #include "common_game.h" #include "globals.h" #include "resource.h" @@ -30,10 +31,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ud_setup_t gSetup; bool bVanilla = false; -int gFrameClock; -int gFrameTicks; +ClockTicks gFrameClock; +ClockTicks gFrameTicks; int gFrame; -int volatile gGameClock; +//int volatile gGameClock; int gFrameRate; int gGamma; diff --git a/source/blood/src/globals.h b/source/blood/src/globals.h index 504df4d59..8aa8cd4b5 100644 --- a/source/blood/src/globals.h +++ b/source/blood/src/globals.h @@ -21,6 +21,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #pragma once +#include "compat.h" +#include "build.h" #include "resource.h" typedef struct { @@ -35,10 +37,10 @@ typedef struct { } ud_setup_t; extern ud_setup_t gSetup; -extern int gFrameClock; -extern int gFrameTicks; +extern ClockTicks gFrameClock; +extern ClockTicks gFrameTicks; extern int gFrame; -extern int volatile gGameClock; +//extern ClockTicks gGameClock; extern int gFrameRate; extern int gGamma; extern bool bVanilla; diff --git a/source/blood/src/loadsave.cpp b/source/blood/src/loadsave.cpp index 31fd9e0bc..39546b7eb 100644 --- a/source/blood/src/loadsave.cpp +++ b/source/blood/src/loadsave.cpp @@ -159,7 +159,7 @@ void LoadSave::LoadGame(char *pzFile) gFrame = 0; gCacheMiss = 0; gFrameRate = 0; - gGameClock = 0; + totalclock = 0; gPaused = 0; gGameStarted = 1; bVanilla = false; @@ -255,9 +255,9 @@ void MyLoadSave::Load(void) Read(&gFrameClock, sizeof(gFrameClock)); Read(&gFrameTicks, sizeof(gFrameTicks)); Read(&gFrame, sizeof(gFrame)); - int nGameClock; - Read(&nGameClock, sizeof(nGameClock)); - gGameClock = nGameClock; + ClockTicks nGameClock; + Read(&totalclock, sizeof(totalclock)); + totalclock = nGameClock; Read(&gLevelTime, sizeof(gLevelTime)); Read(&gPaused, sizeof(gPaused)); Read(&gbAdultContent, sizeof(gbAdultContent)); @@ -363,7 +363,7 @@ void MyLoadSave::Save(void) Write(&gFrameClock, sizeof(gFrameClock)); Write(&gFrameTicks, sizeof(gFrameTicks)); Write(&gFrame, sizeof(gFrame)); - int nGameClock = gGameClock; + ClockTicks nGameClock = totalclock; Write(&nGameClock, sizeof(nGameClock)); Write(&gLevelTime, sizeof(gLevelTime)); Write(&gPaused, sizeof(gPaused)); diff --git a/source/blood/src/messages.cpp b/source/blood/src/messages.cpp index 91d8e001c..fdee4b434 100644 --- a/source/blood/src/messages.cpp +++ b/source/blood/src/messages.cpp @@ -358,7 +358,7 @@ void CGameMessageMgr::Display(void) int v18 = at26; int vc = ClipHigh(v10*8, 48); int v14 = gViewMode == 3 ? gViewX0S : 0; - int v8 = (gViewMode == 3 ? at5 : 0) + at9; + int v8 = (gViewMode == 3 ? at5 : 0) + (int)at9; for (int i = 0; i < v10; i++) { messageStruct *pMessage = &at2e[(v18+i)%16]; @@ -379,7 +379,7 @@ void CGameMessageMgr::Display(void) v8 += at15; vc = ClipLow(vc-64/v10, -128); } - if (at9) + if (at9 != 0) { at9 = at15*at9/120; atd += gFrameTicks; @@ -435,7 +435,7 @@ void CPlayerMsg::Draw(void) { char buffer[44]; strcpy(buffer, at4); - if (gGameClock & 16) + if ((int)totalclock & 16) strcat(buffer, "_"); int x = gViewMode == 3 ? gViewX0S : 0; int y = gViewMode == 3 ? gViewY0S : 0; diff --git a/source/blood/src/messages.h b/source/blood/src/messages.h index 225c1d2ac..2d8f193f5 100644 --- a/source/blood/src/messages.h +++ b/source/blood/src/messages.h @@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //------------------------------------------------------------------------- #pragma once +#include "compat.h" +#include "build.h" #include "player.h" class CGameMessageMgr @@ -29,14 +31,14 @@ class CGameMessageMgr public: struct messageStruct { - int at0; + ClockTicks at0; char at4[81]; }; char at0; int at1; int at5; - int at9; - int atd; + ClockTicks at9; + ClockTicks atd; int at11; int at15; int at19; diff --git a/source/blood/src/network.cpp b/source/blood/src/network.cpp index b64047088..5af5537d2 100644 --- a/source/blood/src/network.cpp +++ b/source/blood/src/network.cpp @@ -40,7 +40,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. char packet[576]; bool gStartNewGame = 0; PACKETMODE gPacketMode = PACKETMODE_1; -int gNetFifoClock = 0; +ClockTicks gNetFifoClock = 0; int gNetFifoTail = 0; int gNetFifoHead[8]; int gPredictTail = 0; @@ -236,7 +236,7 @@ void netSendPacketAll(char *pBuffer, int nSize) void sub_79760(void) { - gNetFifoClock = gFrameClock = gGameClock = 0; + gNetFifoClock = gFrameClock = totalclock = 0; gNetFifoMasterTail = 0; gPredictTail = 0; gNetFifoTail = 0; @@ -664,14 +664,14 @@ void sub_7AC28(const char *pzString) void netSendEmptyPackets(void) { - int nClock = gGameClock; + ClockTicks nClock = totalclock; char *pPacket = packet; PutPacketByte(pPacket, 254); for (int i = 0; i < 8; i++) { - if (nClock <= gGameClock) + if (nClock <= totalclock) { - nClock = gGameClock+4; + nClock = totalclock+4; netSendPacketAll(packet, pPacket-packet); } } @@ -853,7 +853,7 @@ void netGetInput(void) } else t = ksgn(t); - gGameClock -= t<<2; + totalclock -= t<<2; otherMinLag += t; myMinLag[connecthead] -= t; } @@ -935,7 +935,7 @@ void netGetInput(void) } else t = ksgn(t); - gGameClock -= t<<2; + totalclock -= t<<2; otherMinLag += t; myMinLag[connecthead] -= t; } diff --git a/source/blood/src/network.h b/source/blood/src/network.h index a6c8f34b1..c62597582 100644 --- a/source/blood/src/network.h +++ b/source/blood/src/network.h @@ -21,6 +21,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #pragma once +#include "compat.h" +#include "build.h" #include "controls.h" enum PACKETMODE { @@ -41,7 +43,7 @@ enum NETWORKMODE { extern char packet[576]; extern bool gStartNewGame; extern PACKETMODE gPacketMode; -extern int gNetFifoClock; +extern ClockTicks gNetFifoClock; extern int gNetFifoTail; extern int gNetFifoHead[8]; extern int gPredictTail; diff --git a/source/blood/src/player.cpp b/source/blood/src/player.cpp index 9f0680212..e95f8ebce 100644 --- a/source/blood/src/player.cpp +++ b/source/blood/src/player.cpp @@ -1019,7 +1019,7 @@ void playerReset(PLAYER *pPlayer) } int dword_21EFB0[8]; -int dword_21EFD0[8]; +ClockTicks dword_21EFD0[8]; void playerInit(int nPlayer, unsigned int a2) { diff --git a/source/blood/src/player.h b/source/blood/src/player.h index eaac430c4..fe9bc90eb 100644 --- a/source/blood/src/player.h +++ b/source/blood/src/player.h @@ -21,6 +21,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #pragma once +#include "compat.h" +#include "build.h" #include "fix16.h" #include "common_game.h" #include "actor.h" @@ -197,7 +199,7 @@ extern PLAYER *gMe, *gView; extern PROFILE gProfile[kMaxPlayers]; extern int dword_21EFB0[kMaxPlayers]; -extern int dword_21EFD0[kMaxPlayers]; +extern ClockTicks dword_21EFD0[kMaxPlayers]; extern AMMOINFO gAmmoInfo[]; extern POWERUPINFO gPowerUpInfo[kMaxPowerUps]; diff --git a/source/blood/src/replace.cpp b/source/blood/src/replace.cpp index d1b558d1b..f0f0c24dc 100644 --- a/source/blood/src/replace.cpp +++ b/source/blood/src/replace.cpp @@ -36,11 +36,12 @@ int qanimateoffs(int a1, int a2) int frames = picanm[a1].num; if (frames > 0) { + int const frameClock = gFrameClock); int vd; if ((a2&0xc000) == 0x8000) - vd = (Bcrc32(&a2, 2, 0)+gFrameClock)>>(picanm[a1].sf&PICANM_ANIMSPEED_MASK); + vd = (Bcrc32(&a2, 2, 0)+frameClock)>>(picanm[a1].sf&PICANM_ANIMSPEED_MASK); else - vd = gFrameClock>>(picanm[a1].sf&PICANM_ANIMSPEED_MASK); + vd = frameClock>>(picanm[a1].sf&PICANM_ANIMSPEED_MASK); switch (picanm[a1].sf&PICANM_ANIMTYPE_MASK) { case PICANM_ANIMTYPE_OSC: diff --git a/source/blood/src/sectorfx.cpp b/source/blood/src/sectorfx.cpp index 9ac60299a..893edd43e 100644 --- a/source/blood/src/sectorfx.cpp +++ b/source/blood/src/sectorfx.cpp @@ -162,7 +162,7 @@ void DoSectorLighting(void) { t2 = mulscale16(t2, pXSector->busy); } - int v4 = GetWaveValue(t1, pXSector->phase*8+pXSector->freq*gGameClock, t2); + int v4 = GetWaveValue(t1, pXSector->phase*8+pXSector->freq*(int)totalclock, t2); if (pXSector->shadeFloor) { sector[nSector].floorshade = ClipRange(sector[nSector].floorshade+v4, -128, 127); diff --git a/source/blood/src/triggers.cpp b/source/blood/src/triggers.cpp index a644a1a30..eef4c964e 100644 --- a/source/blood/src/triggers.cpp +++ b/source/blood/src/triggers.cpp @@ -2837,7 +2837,7 @@ void pastePropertiesInObj(int type, int nDest, EVENT event) { return; } // lets try to look for target that fits better by distance - else if ((gFrameClock & 256) != 0 && (pXSprite->target < 0 || getTargetDist(pSprite, pDudeInfo, pTarget) >= mDist)) { + else if (((int)gFrameClock & 256) != 0 && (pXSprite->target < 0 || getTargetDist(pSprite, pDudeInfo, pTarget) >= mDist)) { pTarget = getTargetInRange(pSprite, 0, mDist, pXSource->data1, pXSource->data2); if (pTarget != NULL) { pXTarget = &xsprite[pTarget->extra]; @@ -2866,7 +2866,7 @@ void pastePropertiesInObj(int type, int nDest, EVENT event) { } } - if ((pXSprite->target < 0 || pPlayer != NULL) && (gFrameClock & 32) != 0) { + if ((pXSprite->target < 0 || pPlayer != NULL) && ((int)gFrameClock & 32) != 0) { // try find first target that dude can see for (int nSprite = headspritestat[6]; nSprite >= 0; nSprite = nextspritestat[nSprite]) { pTarget = &sprite[nSprite]; pXTarget = &xsprite[pTarget->extra]; @@ -2909,7 +2909,7 @@ void pastePropertiesInObj(int type, int nDest, EVENT event) { } // got no target - let's ask mates if they have targets - if ((pXSprite->target < 0 || pPlayer != NULL) && pXSource->data2 == 1 && (gFrameClock & 64) != 0) { + if ((pXSprite->target < 0 || pPlayer != NULL) && pXSource->data2 == 1 && ((int)gFrameClock & 64) != 0) { spritetype* pMateTarget = NULL; if ((pMateTarget = getMateTargets(pXSprite)) != NULL && pMateTarget->extra > 0) { XSPRITE* pXMateTarget = &xsprite[pMateTarget->extra]; diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index 5b6d69e21..ca1750dbb 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -1217,7 +1217,7 @@ void viewDrawPowerUps(PLAYER* pPlayer) if (powerups[i].remainingDuration) { int remainingSeconds = powerups[i].remainingDuration / 100; - if (remainingSeconds > 5 || (gGameClock & 32)) + if (remainingSeconds > 5 || ((int)totalclock & 32)) { DrawStatMaskedSprite(powerups[i].nTile, x, y + powerups[i].yOffset, 0, 0, 256, (int)(65536 * powerups[i].nScaleRatio)); } @@ -1308,7 +1308,7 @@ void DrawPackItemInStatusBar2(PLAYER *pPlayer, int x, int y, int x2, int y2, int char gTempStr[128]; -void UpdateStatusBar(int arg) +void UpdateStatusBar(ClockTicks arg) { PLAYER *pPlayer = gView; XSPRITE *pXSprite = pPlayer->pXSprite; @@ -1381,7 +1381,7 @@ void UpdateStatusBar(int arg) if (gViewSize == 2) { DrawStatSprite(2201, 34, 187, 16, nPalette, 256); - if (pXSprite->health >= 16 || (gGameClock&16) || pXSprite->health == 0) + if (pXSprite->health >= 16 || ((int)totalclock&16) || pXSprite->health == 0) { DrawStatNumber("%3d", pXSprite->health>>4, 2190, 8, 183, 0, 0, 256); } @@ -1440,7 +1440,7 @@ void UpdateStatusBar(int arg) viewDrawPack(pPlayer, 160, 200-tilesiz[2200].y); DrawStatMaskedSprite(2200, 160, 172, 16, nPalette); DrawPackItemInStatusBar(pPlayer, 265, 186, 260, 172); - if (pXSprite->health >= 16 || (gGameClock&16) || pXSprite->health == 0) + if (pXSprite->health >= 16 || ((int)totalclock&16) || pXSprite->health == 0) { DrawStatNumber("%3d", pXSprite->health>>4, 2190, 86, 183, 0, 0); } @@ -1531,18 +1531,22 @@ void UpdateStatusBar(int arg) if (gGameOptions.nGameType == 3) { int x = 1, y = 1; - if (dword_21EFD0[0] == 0 || (gGameClock & 8)) + if (dword_21EFD0[0] == 0 || ((int)totalclock & 8)) { viewDrawText(0, "BLUE", x, y, -128, 10, 0, 0, 256); - dword_21EFD0[0] = ClipLow(dword_21EFD0[0]-arg, 0); + dword_21EFD0[0] = dword_21EFD0[0]-arg; + if (dword_21EFD0[0] < 0) + dword_21EFD0[0] = 0; sprintf(gTempStr, "%-3d", dword_21EFB0[0]); viewDrawText(0, gTempStr, x, y+10, -128, 10, 0, 0, 256); } x = 319; - if (dword_21EFD0[1] == 0 || (gGameClock & 8)) + if (dword_21EFD0[1] == 0 || ((int)totalclock & 8)) { viewDrawText(0, "RED", x, y, -128, 7, 2, 0, 512); - dword_21EFD0[1] = ClipLow(dword_21EFD0[1]-arg, 0); + dword_21EFD0[1] = dword_21EFD0[1]-arg; + if (dword_21EFD0[1] < 0) + dword_21EFD0[1] = 0; sprintf(gTempStr, "%3d", dword_21EFB0[1]); viewDrawText(0, gTempStr, x, y+10, -128, 7, 2, 0, 512); } @@ -1694,7 +1698,7 @@ void UpdateFrame(void) viewTileSprite(kBackTile, 10, 1, gViewX0-3, gViewY1+1, gViewX1+1, gViewY1+4); } -void viewDrawInterface(int arg) +void viewDrawInterface(ClockTicks arg) { if (gViewMode == 3/* && gViewSize >= 3*/ && (pcBackground != 0 || videoGetRenderMode() >= REND_POLYMOST)) { @@ -1750,7 +1754,7 @@ uspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect) for (int i = 0; i < 16; i++) { uspritetype *pNSprite = viewInsertTSprite(pTSprite->sectnum, 32767, pTSprite); - int ang = (gFrameClock*2048)/120; + int ang = ((int)gFrameClock*2048)/120; int nRand1 = dword_172CE0[i][0]; int nRand2 = dword_172CE0[i][1]; int nRand3 = dword_172CE0[i][2]; @@ -2153,7 +2157,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t qloadvoxel(pTSprite->picnum); if ((picanm[nTile].extra&7) == 7) { - pTSprite->ang = (gGameClock<<3)&2047; + pTSprite->ang = ((int)totalclock<<3)&2047; } } } @@ -2542,8 +2546,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t int othercameradist = 1280; int cameradist = -1; -int othercameraclock; -int cameraclock; +ClockTicks othercameraclock, cameraclock; void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, fix16_t zm) { @@ -2583,8 +2586,8 @@ void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsec *pX += mulscale16(vX, othercameradist); *pY += mulscale16(vY, othercameradist); *pZ += mulscale16(vZ, othercameradist); - othercameradist = ClipHigh(othercameradist+((gGameClock-othercameraclock)<<10), 65536); - othercameraclock = gGameClock; + othercameradist = ClipHigh(othercameradist+(((int)(totalclock-othercameraclock))<<10), 65536); + othercameraclock = totalclock; dassert(*vsectnum >= 0 && *vsectnum < kMaxSectors); FindSector(*pX, *pY, *pZ, vsectnum); pSprite->cstat = bakCstat; @@ -2629,8 +2632,8 @@ void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, *pX += mulscale16(vX, cameradist); *pY += mulscale16(vY, cameradist); *pZ += mulscale16(vZ, cameradist); - cameradist = ClipHigh(cameradist+((gGameClock-cameraclock)<<10), 65536); - cameraclock = gGameClock; + cameradist = ClipHigh(cameradist+(((int)(totalclock-cameraclock))<<10), 65536); + cameraclock = totalclock; dassert(*vsectnum >= 0 && *vsectnum < kMaxSectors); FindSector(*pX, *pY, *pZ, vsectnum); pSprite->cstat = bakCstat; @@ -2845,7 +2848,7 @@ void viewUpdateDelirium(void) if ((powerCount = powerupCheck(gView,28)) != 0) { int tilt1 = 170, tilt2 = 170, pitch = 20; - int timer = gFrameClock*4; + int timer = (int)gFrameClock*4; if (powerCount < 512) { int powerScale = (powerCount<<16) / 512; @@ -2949,7 +2952,7 @@ int32_t g_frameRate; void viewDrawScreen(void) { int nPalette = 0; - static int lastUpdate; + static ClockTicks lastUpdate; int defaultHoriz = gCenterHoriz ? 100 : 90; #ifdef USE_OPENGL @@ -2957,11 +2960,13 @@ void viewDrawScreen(void) #endif timerUpdate(); - int delta = ClipLow(gGameClock - lastUpdate, 0); - lastUpdate = gGameClock; + ClockTicks delta = totalclock - lastUpdate; + if (delta < 0) + delta = 0; + lastUpdate = totalclock; if (!gPaused && (!CGameMenuMgr::m_bActive || gGameOptions.nGameType != 0)) { - gInterpolate = divscale16(gGameClock-gNetFifoClock+4, 4); + gInterpolate = ((totalclock-gNetFifoClock)+4).toScale16()/4; } if (gInterpolate < 0 || gInterpolate > 65536) { @@ -3057,7 +3062,7 @@ void viewDrawScreen(void) } cZ += fix16_to_int(q16horiz*10); cameradist = -1; - cameraclock = gGameClock; + cameraclock = totalclock; } else { @@ -3109,7 +3114,7 @@ void viewDrawScreen(void) } else if (v4 && gNetPlayers > 1) { - int tmp = (gGameClock/240)%(gNetPlayers-1); + int tmp = ((int)totalclock/240)%(gNetPlayers-1); int i = connecthead; while (1) { @@ -3198,7 +3203,7 @@ RORHACKOTHER: } else { - othercameraclock = gGameClock; + othercameraclock = totalclock; } if (!bDelirium) diff --git a/source/blood/src/view.h b/source/blood/src/view.h index 0e6117063..81f98de6b 100644 --- a/source/blood/src/view.h +++ b/source/blood/src/view.h @@ -21,7 +21,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #pragma once - +#include "compat.h" +#include "build.h" #include "palette.h" #include "common_game.h" #include "controls.h" @@ -131,11 +132,11 @@ void DrawStatNumber(const char *pFormat, int nNumber, int nTile, int x, int y, i void TileHGauge(int nTile, int x, int y, int nMult, int nDiv, int nStat = 0, int nScale = 65536); void viewDrawPack(PLAYER *pPlayer, int x, int y); void DrawPackItemInStatusBar(PLAYER *pPlayer, int x, int y, int x2, int y2, int nStat = 0); -void UpdateStatusBar(int arg); +void UpdateStatusBar(ClockTicks arg); void viewInit(void); void viewResizeView(int size); void UpdateFrame(void); -void viewDrawInterface(int arg); +void viewDrawInterface(ClockTicks arg); uspritetype *viewInsertTSprite(int nSector, int nStatnum, uspritetype *pSprite); uspritetype *viewAddEffect(int nTSprite, VIEW_EFFECT nViewEffect); void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t smooth); diff --git a/source/blood/src/weapon.cpp b/source/blood/src/weapon.cpp index cb57638fb..505680dca 100644 --- a/source/blood/src/weapon.cpp +++ b/source/blood/src/weapon.cpp @@ -232,14 +232,14 @@ void WeaponDraw(PLAYER *pPlayer, int a2, int a3, int a4, int a5) QAV *pQAV = weaponQAV[pPlayer->at26]; int v4; if (pPlayer->atbf == 0) - v4 = gGameClock%pQAV->at10; + v4 = (int)totalclock%pQAV->at10; else v4 = pQAV->at10-pPlayer->atbf; pQAV->x = a3; pQAV->y = a4; int flags = 2; int nInv = powerupCheck(pPlayer, 13); - if (nInv >= 120*8 || (nInv != 0 && (gGameClock&32))) + if (nInv >= 120*8 || (nInv != 0 && ((int)totalclock&32))) { a2 = -128; flags |= 1; @@ -1727,12 +1727,12 @@ char sub_4F0E0(PLAYER *pPlayer) { pPlayer->atc3 = 7; pPlayer->at1b2 = 0; - pPlayer->at1b6 = gFrameClock; + pPlayer->at1b6 = (int)gFrameClock; } return 1; case 7: { - pPlayer->at1ba = ClipHigh(divscale16(gFrameClock-pPlayer->at1b6,240), 65536); + pPlayer->at1ba = ClipHigh(divscale16((int)gFrameClock-pPlayer->at1b6,240), 65536); if (!pPlayer->atc.buttonFlags.shoot) { if (!pPlayer->at1b2) @@ -1765,12 +1765,12 @@ char sub_4F200(PLAYER *pPlayer) { pPlayer->atc3 = 6; pPlayer->at1b2 = 0; - pPlayer->at1b6 = gFrameClock; + pPlayer->at1b6 = (int)gFrameClock; } return 1; case 6: { - pPlayer->at1ba = ClipHigh(divscale16(gFrameClock-pPlayer->at1b6,240), 65536); + pPlayer->at1ba = ClipHigh(divscale16((int)gFrameClock-pPlayer->at1b6,240), 65536); if (!pPlayer->atc.buttonFlags.shoot) { if (!pPlayer->at1b2) @@ -1789,7 +1789,7 @@ char sub_4F320(PLAYER *pPlayer) switch (pPlayer->atc3) { case 9: - pPlayer->at1ba = ClipHigh(divscale16(gFrameClock-pPlayer->at1b6,240), 65536); + pPlayer->at1ba = ClipHigh(divscale16((int)gFrameClock-pPlayer->at1b6,240), 65536); pPlayer->atbf = 0; if (!pPlayer->atc.buttonFlags.shoot) { @@ -1806,7 +1806,7 @@ char sub_4F3A0(PLAYER *pPlayer) switch (pPlayer->atc3) { case 13: - pPlayer->at1ba = ClipHigh(divscale16(gFrameClock-pPlayer->at1b6,240), 65536); + pPlayer->at1ba = ClipHigh(divscale16((int)gFrameClock-pPlayer->at1b6,240), 65536); if (!pPlayer->atc.buttonFlags.shoot) { pPlayer->atc3 = 11; @@ -2134,7 +2134,7 @@ void WeaponProcess(PLAYER *pPlayer) case 3: pPlayer->atc3 = 6; pPlayer->at1b2 = -1; - pPlayer->at1b6 = gFrameClock; + pPlayer->at1b6 = (int)gFrameClock; StartQAV(pPlayer, 21, nClientExplodeBundle, 0); return; } @@ -2145,7 +2145,7 @@ void WeaponProcess(PLAYER *pPlayer) case 7: pPlayer->at26 = 27; pPlayer->atc3 = 9; - pPlayer->at1b6 = gFrameClock; + pPlayer->at1b6 = (int)gFrameClock; return; } break; @@ -2155,7 +2155,7 @@ void WeaponProcess(PLAYER *pPlayer) case 10: pPlayer->at26 = 36; pPlayer->atc3 = 13; - pPlayer->at1b6 = gFrameClock; + pPlayer->at1b6 = (int)gFrameClock; return; case 11: pPlayer->atc3 = 12;