From c54cc2013c3f1adab9c021cecd5baf11a67f2a7f Mon Sep 17 00:00:00 2001 From: Anders Jenbo Date: Thu, 29 Oct 2020 20:39:42 +0100 Subject: [PATCH] Calculate tick related values based on current game speed --- Source/diablo.cpp | 2 +- Source/mainmenu.cpp | 1 - Source/nthread.cpp | 2 +- Source/tmsg.cpp | 2 +- Source/track.cpp | 4 ++-- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index e2a757fad..3459f00fd 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -1811,7 +1811,7 @@ void game_loop(BOOL bStartup) { int i; - i = bStartup ? 60 : 3; + i = bStartup ? ticks_per_sec * 3 : 3; while (i--) { if (!multi_handle_delta()) { diff --git a/Source/mainmenu.cpp b/Source/mainmenu.cpp index 0fa36679f..a9f962e95 100644 --- a/Source/mainmenu.cpp +++ b/Source/mainmenu.cpp @@ -154,7 +154,6 @@ BOOL mainmenu_single_player() if (!SRegLoadValue("devilutionx", "game speed", 0, &ticks_per_sec)) { SRegSaveValue("devilutionx", "game speed", 0, ticks_per_sec); } - tick_delay = 1000 / ticks_per_sec; return mainmenu_init_menu(SELHERO_NEW_DUNGEON); } diff --git a/Source/nthread.cpp b/Source/nthread.cpp index f31cfbef1..3256f3e47 100644 --- a/Source/nthread.cpp +++ b/Source/nthread.cpp @@ -227,7 +227,7 @@ BOOL nthread_has_500ms_passed(BOOL unused) currentTickCount = SDL_GetTicks(); ticksElapsed = currentTickCount - last_tick; - if (gbMaxPlayers == 1 && ticksElapsed > 500) { + if (gbMaxPlayers == 1 && ticksElapsed > tick_delay * 10) { last_tick = currentTickCount; ticksElapsed = 0; } diff --git a/Source/tmsg.cpp b/Source/tmsg.cpp index 3b557c939..c8d30c0a6 100644 --- a/Source/tmsg.cpp +++ b/Source/tmsg.cpp @@ -34,7 +34,7 @@ void tmsg_add(BYTE *pbMsg, BYTE bLen) TMsg *msg = (TMsg *)DiabloAllocPtr(bLen + sizeof(*msg)); msg->hdr.pNext = NULL; - msg->hdr.dwTime = SDL_GetTicks() + 500; + msg->hdr.dwTime = SDL_GetTicks() + tick_delay * 10; msg->hdr.bLen = bLen; memcpy(msg->body, pbMsg, bLen); for (tail = &sgpTimedMsgHead; *tail; tail = &(*tail)->hdr.pNext) { diff --git a/Source/track.cpp b/Source/track.cpp index 8bb6b3d37..6eed27e9a 100644 --- a/Source/track.cpp +++ b/Source/track.cpp @@ -24,7 +24,7 @@ void track_process() if (cursmx != plr[myplr]._ptargx || cursmy != plr[myplr]._ptargy) { DWORD tick = SDL_GetTicks(); - if ((int)(tick - sgdwLastWalk) >= 300) { + if ((int)(tick - sgdwLastWalk) >= tick_delay * 6) { sgdwLastWalk = tick; NetSendCmdLoc(TRUE, CMD_WALKXY, cursmx, cursmy); if (!sgbIsScrolling) @@ -41,7 +41,7 @@ void track_repeat_walk(BOOL rep) sgbIsWalking = rep; if (rep) { sgbIsScrolling = FALSE; - sgdwLastWalk = SDL_GetTicks() - 50; + sgdwLastWalk = SDL_GetTicks() - tick_delay; NetSendCmdLoc(TRUE, CMD_WALKXY, cursmx, cursmy); } else if (sgbIsScrolling) { sgbIsScrolling = FALSE;