From 99067f3bd6a2ea59cf0eabf101a0ca6d0d8ebbd8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 23 Jun 2020 21:12:15 +0200 Subject: [PATCH] - a small bit more is gone. --- source/core/gamecontrol.cpp | 2 + source/games/duke/src/actors.cpp | 17 ++++ source/games/duke/src/actors.h | 13 +-- source/games/duke/src/actors_d.cpp | 32 +++++++ source/games/duke/src/actors_r.cpp | 37 ++++++++ source/games/duke/src/dispatch.cpp | 4 + source/games/duke/src/game.h | 1 + source/games/duke/src/player_d.cpp | 3 +- source/games/duke/src/zz_actors.cpp | 129 --------------------------- source/games/duke/src/zz_game.cpp | 2 +- source/games/duke/src/zz_screens.cpp | 4 +- 11 files changed, 105 insertions(+), 139 deletions(-) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index c450ed0df..6baaa0247 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -95,6 +95,8 @@ int connecthead, connectpoint2[MAXMULTIPLAYERS]; int32_t xres = -1, yres = -1, bpp = 0; auto vsnprintfptr = vsnprintf; // This is an inline in Visual Studio but we need an address for it to satisfy the MinGW compiled libraries. +glcycle_t thinktime, actortime; + MapRecord mapList[512]; // Due to how this gets used it needs to be static. EDuke defines 7 episode plus one spare episode with 64 potential levels each and relies on the static array which is freely accessible by scripts. MapRecord *currentLevel; // level that is currently played. (The real level, not what script hacks modfifying the current level index can pretend.) diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index d1e5ea227..5d37a8781 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -42,6 +42,7 @@ This file is a combination of code from the following sources: #include "ns.h" #include "global.h" #include "namesdyn.h" +#include "stats.h" BEGIN_DUKE_NS @@ -5050,4 +5051,20 @@ void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOT } } +int LocateTheLocator(int n, int sn) +{ + int i; + + i = headspritestat[7]; + while (i >= 0) + { + if ((sn == -1 || sn == sprite[i].sectnum) && n == sprite[i].lotag) + return i; + i = nextspritestat[i]; + } + return -1; +} + + + END_DUKE_NS diff --git a/source/games/duke/src/actors.h b/source/games/duke/src/actors.h index 44a2cbc0d..930833e89 100644 --- a/source/games/duke/src/actors.h +++ b/source/games/duke/src/actors.h @@ -25,6 +25,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "player.h" # include "namesdyn.h" +#include "stats.h" + +extern glcycle_t actortime, thinktime; BEGIN_DUKE_NS @@ -239,11 +242,7 @@ extern int32_t otherp; extern int32_t ticrandomseed; extern int g_canSeePlayer; -int A_FindLocator(int const tag, int const sectNum); -inline int LocateTheLocator(int const tag, int const sectNum) -{ - return A_FindLocator(tag, sectNum); -} +int LocateTheLocator(int const tag, int const sectNum); int A_IncurDamage(int spriteNum); void A_DeleteSprite(int spriteNum); @@ -251,12 +250,14 @@ void A_DeleteSprite(int spriteNum); void movecyclers(void); void movedummyplayers(void); void resetlanepics(void); +void moveplayers(); +void doanimations(); +void movefx(); int G_SetInterpolation(int32_t *posptr); void G_ClearCameraView(DukePlayer_t *ps); void clearcamera(player_struct* ps); void G_DoInterpolations(int smoothRatio); -void G_MoveWorld(void); void G_RefreshLights(void); void G_StopInterpolation(const int32_t *posptr); diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 811daacbb..3099438a0 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -4311,4 +4311,36 @@ void checktimetosleep_d(int g_i) } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void think_d(void) +{ + thinktime.Reset(); + thinktime.Clock(); + + movefta_d(); //ST 2 + moveweapons_d(); //ST 4 + movetransports_d(); //ST 9 + moveplayers(); //ST 10 + movefallers_d(); //ST 12 + moveexplosions_d(); //ST 5 + + actortime.Reset(); + actortime.Clock(); + moveactors_d(); //ST 1 + actortime.Unclock(); + + moveeffectors_d(); //ST 3 + movestandables_d(); //ST 6 + doanimations(); + movefx(); //ST 11 + + thinktime.Unclock(); +} + + END_DUKE_NS diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 67f1db7e8..d8835dbef 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -4686,4 +4686,41 @@ void checktimetosleep_r(int g_i) } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void thunder(void); + +void think_r(void) +{ + thinktime.Reset(); + thinktime.Clock(); + + movefta_r(); //ST 2 + moveweapons_r(); //ST 4 + movetransports_r(); //ST 9 + moveplayers(); //ST 10 + movefallers_r(); //ST 12 + moveexplosions_r(); //ST 5 + + actortime.Reset(); + actortime.Clock(); + moveactors_r(); //ST 1 + actortime.Unclock(); + + moveeffectors_r(); //ST 3 + movestandables_r(); //ST 6 + doanimations(); + movefx(); //ST 11 + + if (numplayers < 2 && thunderon) + thunder(); + + thinktime.Unclock(); +} + + END_DUKE_NS diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 8dd35c914..695faecdf 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -109,6 +109,8 @@ void displayweapon_d(int snum); void displayweapon_r(int snum); void displaymasks_d(int snum); void displaymasks_r(int snum); +void think_d(); +void think_r(); @@ -119,6 +121,7 @@ void SetDispatcher() if (!isRR()) { fi = { + think_d, initactorflags_d, isadoorwall_d, animatewalls_d, @@ -165,6 +168,7 @@ void SetDispatcher() else { fi = { + think_r, initactorflags_r, isadoorwall_r, animatewalls_r, diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index 97b82ffde..bcb590a5f 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -486,6 +486,7 @@ void spawneffector(int i); struct Dispatcher { // sectors_?.cpp + void (*think)(); void (*initactorflags)(); bool (*isadoorwall)(int dapic); void (*animatewalls)(); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 919127e55..271bea62b 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2637,7 +2637,8 @@ void processinput_d(int snum) hittype[pi].floorz = fz; hittype[pi].ceilingz = cz; -#if 0 +#pragma message("input stuff begins here") +#if 0 // disabled input p->oq16horiz = p->q16horiz; p->oq16horizoff = p->q16horizoff; #endif diff --git a/source/games/duke/src/zz_actors.cpp b/source/games/duke/src/zz_actors.cpp index 1b67d7a3a..fc77ebb85 100644 --- a/source/games/duke/src/zz_actors.cpp +++ b/source/games/duke/src/zz_actors.cpp @@ -28,11 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_DUKE_NS -#if KRANDDEBUG -# define ACTOR_STATIC -#else -# define ACTOR_STATIC static -#endif #define DELETE_SPRITE_AND_CONTINUE(KX) do { A_DeleteSprite(KX); goto next_sprite; } while (0) @@ -53,11 +48,6 @@ void G_ClearCameraView(DukePlayer_t *ps) // deletesprite() game wrapper void A_DeleteSprite(int spriteNum) { -#ifdef POLYMER - if (actor[spriteNum].lightptr != NULL && videoGetRenderMode() == REND_POLYMER) - A_DeleteLight(spriteNum); -#endif - // AMBIENT_SFX_PLAYING if (sprite[spriteNum].picnum == MUSICANDSFX && actor[spriteNum].t_data[0] == 1) S_StopEnvSound(sprite[spriteNum].lotag, spriteNum); @@ -114,126 +104,7 @@ int G_WakeUp(spritetype *const pSprite, int const playerNum) } -// sleeping monsters, etc - - int A_FindLocator(int const tag, int const sectNum) -{ - for (bssize_t SPRITES_OF(STAT_LOCATOR, spriteNum)) - { - if ((sectNum == -1 || sectNum == SECT(spriteNum)) && tag == SLT(spriteNum)) - return spriteNum; - } - - return -1; -} - - TileInfo tileinfo[MAXTILES]; - -void movefta_d(void); -void movefallers_d(); -void movestandables_d(); -void moveweapons_d(); -void movetransports_d(void); -void moveactors_d(); -void moveexplosions_d(); -void moveeffectors_d(); - -void movefta_r(void); -void moveplayers(); -void movefx(); -void movefallers_r(); -void movestandables_r(); -void moveweapons_r(); -void movetransports_r(void); -void moveactors_r(); -void thunder(); -void moveexplosions_r(); -void moveeffectors_r(); - -void doanimations(void); - -void G_MoveWorld_d(void) -{ - extern double g_moveActorsTime, g_moveWorldTime; - const double worldTime = timerGetHiTicks(); - - movefta_d(); //ST 2 - moveweapons_d(); //ST 4 - movetransports_d(); //ST 9 - - moveplayers(); //ST 10 - movefallers_d(); //ST 12 - moveexplosions_d(); //ST 5 - - const double actorsTime = timerGetHiTicks(); - - moveactors_d(); //ST 1 - - g_moveActorsTime = (1-0.033)*g_moveActorsTime + 0.033*(timerGetHiTicks()-actorsTime); - - // XXX: Has to be before effectors, in particular movers? - // TODO: lights in moving sectors ought to be interpolated - //G_DoEffectorLights(); - moveeffectors_d(); //ST 3 - movestandables_d(); //ST 6 - - //G_RefreshLights(); - doanimations(); - movefx(); //ST 11 - - g_moveWorldTime = (1-0.033)*g_moveWorldTime + 0.033*(timerGetHiTicks()-worldTime); -} - -void G_MoveWorld_r(void) -{ - extern double g_moveActorsTime, g_moveWorldTime; - const double worldTime = timerGetHiTicks(); - - if (!DEER) - { - movefta_r(); //ST 2 - moveweapons_r(); //ST 4 - movetransports_r(); //ST 9 - } - - moveplayers(); //ST 10 - movefallers_r(); //ST 12 - if (!DEER) - moveexplosions_r(); //ST 5 - - const double actorsTime = timerGetHiTicks(); - - moveactors_r(); //ST 1 - - g_moveActorsTime = (1 - 0.033) * g_moveActorsTime + 0.033 * (timerGetHiTicks() - actorsTime); - - // XXX: Has to be before effectors, in particular movers? - // TODO: lights in moving sectors ought to be interpolated - // G_DoEffectorLights(); - if (!DEER) - { - moveeffectors_r(); //ST 3 - movestandables_r(); //ST 6 - } - - //G_RefreshLights(); - doanimations(); - if (!DEER) - movefx(); //ST 11 - - if (numplayers < 2 && thunderon) - thunder(); - - g_moveWorldTime = (1 - 0.033) * g_moveWorldTime + 0.033 * (timerGetHiTicks() - worldTime); -} - -void G_MoveWorld(void) -{ - if (!isRR()) G_MoveWorld_d(); - else G_MoveWorld_r(); -} - END_DUKE_NS diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index 31c7b5137..7518a1795 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -2852,7 +2852,7 @@ int G_DoMoveThings(void) } if (ud.pause_on == 0) - G_MoveWorld(); + fi.think(); Net_CorrectPrediction(); diff --git a/source/games/duke/src/zz_screens.cpp b/source/games/duke/src/zz_screens.cpp index 408930ee7..9f3509f31 100644 --- a/source/games/duke/src/zz_screens.cpp +++ b/source/games/duke/src/zz_screens.cpp @@ -605,8 +605,8 @@ FString GameInterface::statFPS() output.AppendFormat("Game Update: %2.2f ms + draw: %2.2f ms\n", g_gameUpdateTime, g_gameUpdateAndDrawTime - g_gameUpdateTime); output.AppendFormat("GU min/max/avg: %5.2f/%5.2f/%5.2f ms\n", minGameUpdate, maxGameUpdate, g_gameUpdateAvgTime); - output.AppendFormat("G_MoveActors(): %.3f ms\n", g_moveActorsTime); - output.AppendFormat("G_MoveWorld(): %.3f ms\n", g_moveWorldTime); + output.AppendFormat("actor think time: %.3f ms\n", actortime.TimeMS()); + output.AppendFormat("total think timn: %.3f ms\n", thinktime.TimeMS()); } }