From bc0392babcde224fc02f2026dfee6f049b16aa8a Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 28 May 2025 18:10:41 +0200 Subject: [PATCH] poep --- src/am_map.c | 2 ++ src/d_clisrv.c | 14 ++++++------- src/d_netcmd.c | 8 +++++-- src/g_game.c | 57 +++++++++++++++++++++++++------------------------- src/p_enemy.c | 17 +++++++-------- src/p_mobj.c | 4 ++-- src/p_spec.c | 5 +++-- src/p_tick.c | 8 +++++-- src/p_user.c | 10 ++++++--- 9 files changed, 69 insertions(+), 56 deletions(-) diff --git a/src/am_map.c b/src/am_map.c index f91273e8b..1478b37f9 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -318,11 +318,13 @@ static void AM_initVariables(void) break; plr = &players[pnum]; + if (plr != NULL && plr->mo != NULL) { m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2; m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2; } + AM_changeWindowLoc(); // for saving & restoring diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 9625934fc..98b4b1e55 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1693,7 +1693,7 @@ static void SV_SendPlayerInfo(INT32 node) continue; } - if (playeringame[i] == UINT8_MAX || !playeringame[i]) + if (playernode[i] == UINT8_MAX || !playeringame[i]) { netbuffer->u.playerinfo[i].node = 255; // This slot is empty. continue; @@ -5324,18 +5324,18 @@ static void HandlePacketFromPlayer(SINT8 node) /// \todo Use a separate cvar for that kind of timeout? freezetimeout[node] = I_GetTime() + connectiontimeout; - // If we've alredy received a ticcmd for this tic, just submit it for the next one. - tic_t faketic = maketic; - if ((!!(netcmds[maketic % TICQUEUE][netconsole].angleturn & TICCMD_RECEIVED)) - && (maketic - firstticstosend < TICQUEUE - 1)) - faketic++; - // Don't do anything for packets of type NODEKEEPALIVE? // Sryder 2018/07/01: Update the freezetimeout still! if (netbuffer->packettype == PT_NODEKEEPALIVE || netbuffer->packettype == PT_NODEKEEPALIVEMIS) break; + // If we've alredy received a ticcmd for this tic, just submit it for the next one. + tic_t faketic = maketic; + if ((!!(netcmds[maketic % TICQUEUE][netconsole].angleturn & TICCMD_RECEIVED)) + && (maketic - firstticstosend < TICQUEUE - 1)) + faketic++; + // Copy ticcmd G_MoveTiccmd(&netcmds[faketic%TICQUEUE][netconsole], &netbuffer->u.clientpak.cmd, 1); diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ceb2c2e3c..b36436def 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2114,14 +2114,18 @@ static INT32 LookupPlayer(const char *s) static INT32 FindPlayerByPlace(INT32 place) { INT32 playernum; + for (playernum = 0; playernum < MAXPLAYERS; ++playernum) - if (playeringame[playernum]) { + if (!playeringame[playernum]) + continue; + if (players[playernum].kartstuff[k_position] == place) { return playernum; } } + return -1; } @@ -5673,7 +5677,7 @@ static void Command_Archivetest_f(void) // assign mobjnum i = 1; for (th = thinkercap.next; th != &thinkercap; th = th->next) - if (th->function.acp1 == (actionf_p1)P_MobjThinker) + if (th->function == (actionf_p1)P_MobjThinker) ((mobj_t *)th)->mobjnum = i++; // allocate buffer diff --git a/src/g_game.c b/src/g_game.c index 695b4f371..9e991fff5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -6130,38 +6130,39 @@ void G_BeginRecording(void) CV_SaveNetVars(&demobuf.p, true); // Now store some info for each in-game player - for (p = 0; p < MAXPLAYERS; p++) { - if (playeringame[p]) { - player = &players[p]; + for (p = 0; p < MAXPLAYERS; p++) + { + if (!playeringame[p]) + continue; - WRITEUINT8(demobuf.p, p | (player->spectator ? DEMO_SPECTATOR : 0)); + player = &players[p]; - // Name - memset(name, 0, 16); - memcpy(name, player_names[p], 15); - M_Memcpy(demobuf.p,name,16); - demobuf.p += 16; + WRITEUINT8(demobuf.p, p | (player->spectator ? DEMO_SPECTATOR : 0)); - // Skin - memset(name, 0, 16); - strncpy(name, skins[player->skin].name, 16); - M_Memcpy(demobuf.p,name,16); - demobuf.p += 16; + // Name + memset(name, 0, 16); + memcpy(name, player_names[p], 15); + M_Memcpy(demobuf.p,name,16); + demobuf.p += 16; - // Color - memset(name, 0, 16); - strncpy(name, KartColor_Names[player->skincolor], 16); - M_Memcpy(demobuf.p,name,16); - demobuf.p += 16; + // Skin + memset(name, 0, 16); + strncpy(name, skins[player->skin].name, 16); + M_Memcpy(demobuf.p,name,16); + demobuf.p += 16; - // Score, since Kart uses this to determine where you start on the map - WRITEUINT32(demobuf.p, player->score); + // Color + memset(name, 0, 16); + strncpy(name, KartColor_Names[player->skincolor], 16); + M_Memcpy(demobuf.p,name,16); + demobuf.p += 16; - // Kart speed and weight - WRITEUINT8(demobuf.p, skins[player->skin].kartspeed); - WRITEUINT8(demobuf.p, skins[player->skin].kartweight); + // Score, since Kart uses this to determine where you start on the map + WRITEUINT32(demobuf.p, player->score); - } + // Kart speed and weight + WRITEUINT8(demobuf.p, skins[player->skin].kartspeed); + WRITEUINT8(demobuf.p, skins[player->skin].kartweight); } WRITEUINT8(demobuf.p, 0xFF); // Denote the end of the player listing @@ -7274,9 +7275,9 @@ void G_DoPlayDemo(char *defdemoname) //LUA_HookInt(gamemap, HOOK(MapChange)); consoleplayer = 0; - memset(playeringame,0,sizeof(playeringame)); - memset(displayplayers,0,sizeof(displayplayers)); - memset(camera,0,sizeof(camera)); // reset freecam + memset(playeringame, 0, sizeof(playeringame)); + memset(displayplayers, 0, sizeof(displayplayers)); + memset(camera, 0, sizeof(camera)); // reset freecam // Load players that were in-game when the map started p = READUINT8(demobuf.p); diff --git a/src/p_enemy.c b/src/p_enemy.c index f509385c1..042e0cec3 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -887,10 +887,7 @@ void A_PointyThink(void *thing) if (!playeringame[i] || players[i].spectator) continue; - if (!players[i].mo) - continue; - - if (!players[i].mo->health) + if (!players[i].mo || !players[i].mo->health) continue; if (!P_CheckSight(actor, players[i].mo)) @@ -2236,7 +2233,7 @@ void A_1upThinker(void *thing) for (i = 0; i < MAXPLAYERS; i++) { - if (!players[i].ingame || players[i].bot || players[i].spectator) + if (!playeringame[i] || players[i].bot || players[i].spectator) continue; if (!players[i].mo) @@ -2435,7 +2432,7 @@ void A_BossDeath(void *thing) // if all bosses are dead for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function != (actionf_p1)P_MobjThinker) continue; mo2 = (mobj_t *)th; @@ -3569,7 +3566,7 @@ void A_ThrownRing(void *thing) if (actor->lastlook == stop) return; - if (!players[actor->lastlook].ingame) + if (!playeringame[actor->lastlook]) continue; if (c++ == 2) @@ -6623,7 +6620,7 @@ void A_EggShield(void *thing) // Search for players to push for (i = 0; i < MAXPLAYERS; i++) { - if (!players[i].ingame || players[i].spectator) + if (!playeringame[i] || players[i].spectator) continue; player = &players[i]; @@ -8738,7 +8735,7 @@ void A_ReaperThinker(void *thing) for (i = 0; ihealth) diff --git a/src/p_mobj.c b/src/p_mobj.c index de0822daa..59ad7f1d2 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4044,7 +4044,7 @@ static void P_Boss3Thinker(mobj_t *mobj) // this can happen if the boss was hurt earlier than expected for (th = thinkercap.next; th != &thinkercap; th = th->next) { - if (th->function.acp1 != (actionf_p1)P_MobjThinker) + if (th->function != (actionf_p1)P_MobjThinker) continue; mo2 = (mobj_t *)th; @@ -9718,7 +9718,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) for (i = 0; i < MAXPLAYERS; i++) { - if (!players[i].ingame) + if (!playeringame[i]) continue; pnum[pcount] = i; diff --git a/src/p_spec.c b/src/p_spec.c index 9cb9d2805..1661117b8 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1343,7 +1343,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller { for (i = 0; i < MAXPLAYERS; i++) { - if (!players[i].ingame || players[i].spectator) + if (!playeringame[i] || players[i].spectator) continue; if (!players[i].mo || players[i].mo->health < 1) @@ -3887,8 +3887,9 @@ DoneSection2: for (i = 0; i < MAXPLAYERS; i++) { - if (!players[i].ingame || players[i].spectator) + if (!playeringame[i] || players[i].spectator) continue; + nump++; } diff --git a/src/p_tick.c b/src/p_tick.c index 1bb87e4dc..2119439e5 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -733,8 +733,10 @@ void P_Ticker(boolean run) PS_START_TIMING(ps_playerthink_time); for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) + { + if (playeringame[i] && !P_MobjWasRemoved(players[i].mo)) P_PlayerThink(&players[i]); + } PS_STOP_TIMING(ps_playerthink_time); } @@ -753,8 +755,10 @@ void P_Ticker(boolean run) // Run any "after all the other thinkers" stuff for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) + { + if (playeringame[i] && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); + } // Apply rumble to local players if (!demo.playback) diff --git a/src/p_user.c b/src/p_user.c index cb1435ef5..b48fe0f26 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -552,9 +552,13 @@ static UINT8 getPlayerPos(player_t *player) { UINT8 pos = 1; - for (int i = 0; i < MAXPLAYERS; ++i) { - if (!playeringame[i] || players[i].spectator) continue; - if (players[i].marescore > player->marescore) ++pos; + for (UINT8 i = 0; i < MAXPLAYERS; ++i) + { + if (!playeringame[i] || players[i].spectator) + continue; + + if (players[i].marescore > player->marescore) + ++pos; } return pos;