From 8a1fc406a3bf9348739dffe63f60cdf056e4293e Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:08:37 -0400 Subject: [PATCH 01/27] Use player angle for respawn --- src/k_kart.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e1078116f..acd8d2c02 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7330,12 +7330,7 @@ waypoint_t *K_GetPlayerNextWaypoint(player_t *player) player->starposttime = player->realtime; player->starpostz = player->mo->z >> FRACBITS; player->starpostflip = (player->mo->eflags & MFE_VERTICALFLIP) ? true : false; - player->starpostangle = R_PointToAngle2( - player->mo->x, - player->mo->y, - bestwaypoint->nextwaypoints[nwp]->mobj->x, - bestwaypoint->nextwaypoints[nwp]->mobj->y - ); + player->starpostangle = player->mo->angle; // Then do x and y player->starpostx = player->mo->x >> FRACBITS; From 3f44a6bb066ee04a18d45ae87d829512979277e2 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:38:57 -0400 Subject: [PATCH 02/27] Raise MAXTEXTCMD --- src/d_clisrv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 45653257e..c35814fa6 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -39,7 +39,7 @@ applications may follow different packet versions. // Networking and tick handling related. #define BACKUPTICS 512 // more than enough for most timeouts.... #define CLIENTBACKUPTICS 32 -#define MAXTEXTCMD 256 +#define MAXTEXTCMD 512 // No. of tics your controls can be delayed by. From 25b32aa9179b6c5c51d646ae15dbafb028013c5a Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 1 Jun 2023 19:59:36 -0700 Subject: [PATCH 03/27] Expand textcmd size byte to 16-bit word Raises hard limit from 255 to 65535 --- src/d_clisrv.c | 68 ++++++++++++++++++++++++++++---------------------- src/d_clisrv.h | 2 +- src/d_net.c | 19 +++++++++++--- 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index eec5ddfa2..7c3fbb4b3 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -266,27 +266,27 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum)) void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam) { - if (localtextcmd[playerid][0]+2+nparam > MAXTEXTCMD) + if (((UINT16*)localtextcmd[playerid])[0]+3+nparam > MAXTEXTCMD) { - // for future reference: if (cv_debug) != debug disabled. - CONS_Alert(CONS_ERROR, M_GetText("NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n"), id, localtextcmd[playerid][0], sizeu1(nparam)); + // for future reference: if (cht_debug) != debug disabled. + CONS_Alert(CONS_ERROR, M_GetText("NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n"), id, ((UINT16*)localtextcmd[playerid])[0], sizeu1(nparam)); return; } - localtextcmd[playerid][0]++; - localtextcmd[playerid][localtextcmd[playerid][0]] = (UINT8)id; + ((UINT16*)localtextcmd[playerid])[0]++; + localtextcmd[playerid][((UINT16*)localtextcmd[playerid])[0] + 1] = (UINT8)id; if (param && nparam) { - M_Memcpy(&localtextcmd[playerid][localtextcmd[playerid][0] + 1], param, nparam); - localtextcmd[playerid][0] = (UINT8)(localtextcmd[playerid][0] + (UINT8)nparam); + M_Memcpy(&localtextcmd[playerid][((UINT16*)localtextcmd[playerid])[0] + 2], param, nparam); + ((UINT16*)localtextcmd[playerid])[0] = ((UINT16*)localtextcmd[playerid])[0] + (UINT8)nparam; } } UINT8 GetFreeXCmdSize(UINT8 playerid) { - // -1 for the size and another -1 for the ID. - return (UINT8)(localtextcmd[playerid][0] - 2); + // -2 for the size and another -1 for the ID. + return (UINT8)(localtextcmd[playerid][0] - 3); } // Frees all textcmd memory for the specified tic @@ -397,9 +397,9 @@ static void ExtraDataTicker(void) if (bufferstart) { UINT8 *curpos = bufferstart; - UINT8 *bufferend = &curpos[curpos[0]+1]; + UINT8 *bufferend = &curpos[((UINT16*)curpos)[0]+2]; - curpos++; + curpos += 2; while (curpos < bufferend) { if (*curpos < MAXNETXCMD && listnetxcmd[*curpos]) @@ -3895,7 +3895,7 @@ void SV_StopServer(void) gamestate = wipegamestate = GS_NULL; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - localtextcmd[i][0] = 0; + ((UINT16*)localtextcmd[i])[0] = 0; for (i = firstticstosend; i < firstticstosend + BACKUPTICS; i++) D_Clearticcmd(i); @@ -3953,7 +3953,7 @@ static size_t TotalTextCmdPerTic(tic_t tic) { UINT8 *textcmd = D_GetExistingTextcmd(tic, i); if ((!i || playeringame[i]) && textcmd) - total += 2 + textcmd[0]; // "+2" for size and playernum + total += 3 + ((UINT16*)textcmd)[0]; // "+2" for size and playernum } return total; @@ -4684,9 +4684,17 @@ static void HandlePacketFromPlayer(SINT8 node) tic_t tic = maketic; UINT8 *textcmd; + UINT16 incoming_size; + + { + UINT8 *incoming = netbuffer->u.textcmd; + + incoming_size = READUINT16(incoming); + } + // ignore if the textcmd has a reported size of zero // this shouldn't be sent at all - if (!netbuffer->u.textcmd[0]) + if (!incoming_size) { DEBFILE(va("GetPacket: Textcmd with size 0 detected! (node %u, player %d)\n", node, netconsole)); @@ -4695,11 +4703,11 @@ static void HandlePacketFromPlayer(SINT8 node) } // ignore if the textcmd size var is actually larger than it should be - // BASEPACKETSIZE + 1 (for size) + textcmd[0] should == datalength - if (netbuffer->u.textcmd[0] > (size_t)doomcom->datalength-BASEPACKETSIZE-1) + // BASEPACKETSIZE + 2 (for size) + textcmd[0] should == datalength + if (incoming_size > (size_t)doomcom->datalength-BASEPACKETSIZE-2) { DEBFILE(va("GetPacket: Bad Textcmd packet size! (expected %d, actual %s, node %u, player %d)\n", - netbuffer->u.textcmd[0], sizeu1((size_t)doomcom->datalength-BASEPACKETSIZE-1), + incoming_size, sizeu1((size_t)doomcom->datalength-BASEPACKETSIZE-2), node, netconsole)); Net_UnAcknowledgePacket(node); break; @@ -4708,12 +4716,12 @@ static void HandlePacketFromPlayer(SINT8 node) // check if tic that we are making isn't too large else we cannot send it :( // doomcom->numslots+1 "+1" since doomcom->numslots can change within this time and sent time j = software_MAXPACKETLENGTH - - (netbuffer->u.textcmd[0]+2+BASESERVERTICSSIZE + - (incoming_size + 3 + BASESERVERTICSSIZE + (doomcom->numslots+1)*sizeof(ticcmd_t)); // search a tic that have enougth space in the ticcmd while ((textcmd = D_GetExistingTextcmd(tic, netconsole)), - (TotalTextCmdPerTic(tic) > j || netbuffer->u.textcmd[0] + (textcmd ? textcmd[0] : 0) > MAXTEXTCMD) + (TotalTextCmdPerTic(tic) > j || incoming_size + (textcmd ? ((UINT16*)textcmd)[0] : 0) > MAXTEXTCMD) && tic < firstticstosend + BACKUPTICS) tic++; @@ -4730,10 +4738,10 @@ static void HandlePacketFromPlayer(SINT8 node) if (!textcmd) textcmd = D_GetTextcmd(tic, netconsole); DEBFILE(va("textcmd put in tic %u at position %d (player %d) ftts %u mk %u\n", - tic, textcmd[0]+1, netconsole, firstticstosend, maketic)); + tic, ((UINT16*)textcmd)[0]+2, netconsole, firstticstosend, maketic)); - M_Memcpy(&textcmd[textcmd[0]+1], netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]); - textcmd[0] += (UINT8)netbuffer->u.textcmd[0]; + M_Memcpy(&textcmd[((UINT16*)textcmd)[0]+2], netbuffer->u.textcmd+2, incoming_size); + ((UINT16*)textcmd)[0] += incoming_size; } break; case PT_LOGIN: @@ -4866,7 +4874,7 @@ static void HandlePacketFromPlayer(SINT8 node) for (j = 0; j < numtxtpak; j++) { INT32 k = *txtpak++; // playernum - const size_t txtsize = txtpak[0]+1; + const size_t txtsize = ((UINT16*)txtpak)[0]+2; if (i >= gametic) // Don't copy old net commands M_Memcpy(D_GetTextcmd(i, k), txtpak, txtsize); @@ -5246,7 +5254,7 @@ static void CL_SendClientCmd(void) // Send extra data if needed for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - if (localtextcmd[i][0]) + if (((UINT16*)localtextcmd[i])[0]) { switch (i) { @@ -5264,10 +5272,10 @@ static void CL_SendClientCmd(void) break; } - M_Memcpy(netbuffer->u.textcmd, localtextcmd[i], localtextcmd[i][0]+1); + M_Memcpy(netbuffer->u.textcmd, localtextcmd[i], ((UINT16*)localtextcmd[i])[0]+2); // All extra data have been sent - if (HSendPacket(servernode, true, 0, localtextcmd[i][0]+1)) // Send can fail... - localtextcmd[i][0] = 0; + if (HSendPacket(servernode, true, 0, ((UINT16*)localtextcmd[i])[0]+2)) // Send can fail... + ((UINT16*)localtextcmd[i])[0] = 0; } } } @@ -5367,14 +5375,14 @@ static void SV_SendTics(void) for (j = 0; j < MAXPLAYERS; j++) { UINT8 *textcmd = D_GetExistingTextcmd(i, j); - INT32 size = textcmd ? textcmd[0] : 0; + INT32 size = textcmd ? ((UINT16*)textcmd)[0] : 0; if ((!j || playeringame[j]) && size) { (*ntextcmd)++; WRITEUINT8(bufpos, j); - M_Memcpy(bufpos, textcmd, size + 1); - bufpos += size + 1; + WRITEUINT16(bufpos, ((UINT16*)textcmd)[0]); + WRITEMEM(bufpos, &textcmd[2], size); } } } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index c35814fa6..3f20c6154 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -357,7 +357,7 @@ typedef struct client4cmd_pak client4pak; // 324 bytes(?) servertics_pak serverpak; // 132495 bytes (more around 360, no?) serverconfig_pak servercfg; // 773 bytes - UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes (wut??? 64k??? More like 257 bytes...) + UINT8 textcmd[MAXTEXTCMD+2]; // 66049 bytes (wut??? 64k??? More like 258 bytes...) char filetxpak[sizeof (filetx_pak)];// 139 bytes char fileack[sizeof (fileack_pak)]; UINT8 filereceived; diff --git a/src/d_net.c b/src/d_net.c index 201920f73..419ef2351 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -29,6 +29,8 @@ #include "z_zone.h" #include "i_tcp.h" #include "d_main.h" // srb2home +#include "stun.h" +#include "byteptr.h" // // NETWORKING @@ -897,11 +899,20 @@ static void DebugPrintpacket(const char *header) case PT_TEXTCMD: case PT_TEXTCMD2: case PT_TEXTCMD3: - case PT_TEXTCMD4: - fprintf(debugfile, " length %d\n ", netbuffer->u.textcmd[0]); - fprintf(debugfile, "[%s]", netxcmdnames[netbuffer->u.textcmd[1] - 1]); - fprintfstringnewline((char *)netbuffer->u.textcmd + 2, netbuffer->u.textcmd[0] - 1); + case PT_TEXTCMD4: { + UINT16 size; + + { + UINT8 *p = netbuffer->u.textcmd; + + size = READUINT16(p); + } + + fprintf(debugfile, " length %d\n", size); + fprintf(debugfile, "[%s]", netxcmdnames[netbuffer->u.textcmd[2] - 1]); + fprintfstringnewline((char *)netbuffer->u.textcmd + 3, size - 2); break; + } case PT_SERVERCFG: fprintf(debugfile, " playerslots %d clientnode %d serverplayer %d " "gametic %u gamestate %d gametype %d modifiedgame %d\n", From e9024f4c91b9c358d153e664dfd0980034a2be56 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 11 Jun 2023 22:06:14 -0700 Subject: [PATCH 04/27] Add FF_REVERSEANIM frame flag - Animate from state frame backwards by var1 --- src/p_mobj.c | 10 ++++++++-- src/p_pspr.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 876bcf03d..6ffc84c66 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -148,11 +148,17 @@ FUNCINLINE static ATTRINLINE void P_CycleStateAnimation(mobj_t *mobj) if (mobj->sprite != SPR_PLAY) { + const UINT8 start = mobj->state->frame & FF_FRAMEMASK; + + UINT8 frame = mobj->frame & FF_FRAMEMASK; + // compare the current sprite frame to the one we started from // if more than var1 away from it, swap back to the original // else just advance by one - if (((++mobj->frame) & FF_FRAMEMASK) - (mobj->state->frame & FF_FRAMEMASK) > (UINT32)mobj->state->var1) - mobj->frame = (mobj->state->frame & FF_FRAMEMASK) | (mobj->frame & ~FF_FRAMEMASK); + if ((mobj->frame & FF_REVERSEANIM ? (start - (--frame)) : ((++frame) - start)) > mobj->state->var1) + frame = start; + + mobj->frame = frame | (mobj->frame & ~FF_FRAMEMASK); return; } diff --git a/src/p_pspr.h b/src/p_pspr.h index ff2ead048..a805bbb40 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -96,6 +96,8 @@ #define FF_GLOBALANIM 0x20000000 /// \brief Frame flags - Animate: Start at a random place in the animation (mutually exclusive with above) #define FF_RANDOMANIM 0x40000000 +/// \brief Frame flags - Animate: Animate in reverse +#define FF_REVERSEANIM 0x80000000 /** \brief translucency tables From ec055e5e36b8c882a44bc7d1ce216720d8256949 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 7 Jun 2023 05:03:24 -0700 Subject: [PATCH 05/27] Fix quake tilt speed scaling varying by map scale --- src/p_user.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index df7d6db62..2f2dd7fb5 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4009,19 +4009,20 @@ Quaketilt (player_t *player) if (sliptiding) { tilt = ANGLE_45; - lowb = 5*FRACUNIT; + lowb = 20*FRACUNIT; } else { tilt = ANGLE_11hh/2; - lowb = 15*FRACUNIT; + lowb = 60*FRACUNIT; } } else { tilt = ANGLE_22h; - lowb = 10*FRACUNIT; + lowb = 40*FRACUNIT; } + lowb = FixedMul(lowb, player->mo->scale); moma = FixedMul(FixedDiv(delta, ANGLE_90), tilt); speed = abs( player->mo->momx + player->mo->momy ); if (speed < lowb) From af2e1f1184fb3e14df0cd12b467a045c91bc7cd5 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 7 Jun 2023 05:04:43 -0700 Subject: [PATCH 06/27] Quaketilt: fix jitter at certain momentum angles --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 2f2dd7fb5..a776771ec 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4024,7 +4024,7 @@ Quaketilt (player_t *player) } lowb = FixedMul(lowb, player->mo->scale); moma = FixedMul(FixedDiv(delta, ANGLE_90), tilt); - speed = abs( player->mo->momx + player->mo->momy ); + speed = player->speed; if (speed < lowb) { // ease out tilt as we slow... From 78f7cadd9b09021eb3cfa76b631da68aa5686505 Mon Sep 17 00:00:00 2001 From: Oni Date: Mon, 15 May 2023 02:58:31 +0000 Subject: [PATCH 07/27] Merge branch 'cull-debugwaypoints' into 'master' debugwaypoints: cull debug mobjs outside of drawdist See merge request KartKrew/Kart!1201 --- src/deh_tables.c | 2 +- src/info.h | 2 +- src/k_waypoint.c | 7 +++++++ src/p_saveg.c | 12 ++++++++++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index f48d76e11..74b60680c 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -5136,7 +5136,7 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_SKYBOX", // Debris - "MT_SPARK", //spark + "MT_SPARK", //spark, only used for debugging, actually "MT_EXPLODE", // Robot Explosion "MT_UWEXPLODE", // Underwater Explosion "MT_DUST", diff --git a/src/info.h b/src/info.h index e2467c0f1..f27bc2923 100644 --- a/src/info.h +++ b/src/info.h @@ -6152,7 +6152,7 @@ typedef enum mobj_type MT_SKYBOX, // Debris - MT_SPARK, //spark + MT_SPARK, //spark, only used for debugging, actually MT_EXPLODE, // Robot Explosion MT_UWEXPLODE, // Underwater Explosion MT_DUST, diff --git a/src/k_waypoint.c b/src/k_waypoint.c index a6a592a6b..c8d3f4e48 100644 --- a/src/k_waypoint.c +++ b/src/k_waypoint.c @@ -620,6 +620,13 @@ void K_DebugWaypointsVisualise(void) // Hunt through the waypointcap so we can show all waypoint mobjs and not just ones that were able to be graphed for (waypointmobj = waypointcap; waypointmobj != NULL; waypointmobj = waypointmobj->tracer) { + // If this waypoint is outside of draw distance, don't spawn all the debug crap because it is SLOW + if (cv_drawdist.value != 0 && + R_PointToDist(waypointmobj->x, waypointmobj->y) > cv_drawdist.value * mapobjectscale) + { + continue; + } + waypoint = K_SearchWaypointHeapForMobj(waypointmobj); debugmobj = P_SpawnMobj(waypointmobj->x, waypointmobj->y, waypointmobj->z, MT_SPARK); diff --git a/src/p_saveg.c b/src/p_saveg.c index 79e87c411..758d917ad 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1665,6 +1665,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) if (mobj->type == MT_HOOPCENTER && mobj->threshold == 4242) return; + // MT_SPARK: used for debug stuff + if (mobj->type == MT_SPARK) + return; + if (mobj->spawnpoint) { // spawnpoint is not modified but we must save it since it is an identifier @@ -4136,7 +4140,9 @@ static void P_RelinkPointers(void) mobj = (mobj_t *)currentthinker; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER + // MT_SPARK: used for debug stuff + || mobj->type == MT_SPARK) continue; if (mobj->tracer) @@ -4769,7 +4775,9 @@ void P_SaveNetGame(boolean resending) continue; mobj = (mobj_t *)th; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER + // MT_SPARK: used for debug stuff + || mobj->type == MT_SPARK) continue; mobj->mobjnum = i++; } From 0a9f3b452a4d3e272ef584fa02d10d529cd222b4 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 30 Apr 2023 10:31:26 -0400 Subject: [PATCH 08/27] Make MAXRADIUS bigger MAXRADIUS was previously an arbitrary value id Software set as whatever their biggest object would be (which they broke that rule anyway). It is now the radius of a blockmap block, which should be a large enough of a nudge value to handle all cases. (Still don't recommend making objects any bigger than a Spider Mastermind though.) --- src/p_local.h | 4 +--- src/p_mobj.c | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 5b3d7f7b2..7ced38f2f 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -46,9 +46,7 @@ #define BMBOUNDFIX(xl, xh, yl, yh) {if (xl > xh) xl = 0; if (yl > yh) yl = 0;} // MAXRADIUS is for precalculated sector block boxes -// the spider demon is larger, -// but we do not have any moving sectors nearby -#define MAXRADIUS (32*FRACUNIT) +#define MAXRADIUS (MAPBLOCKSIZE >> 1) // max Z move up or down without jumping // above this, a height difference is considered as a 'dropoff' diff --git a/src/p_mobj.c b/src/p_mobj.c index 6ffc84c66..6ab24c5d2 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12406,7 +12406,7 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean // Ambush = double size (grounded) / half size (aerial) if (!(mthing->options & MTF_AMBUSH) == !P_IsObjectOnGround(mobj)) { - mobj->extravalue1 = min(mobj->extravalue1 << 1, FixedDiv(64*FRACUNIT, mobj->info->radius)); // don't make them larger than the blockmap can handle + mobj->extravalue1 = min(mobj->extravalue1 << 1, FixedDiv(MAPBLOCKSIZE, mobj->info->radius)); // don't make them larger than the blockmap can handle mobj->scalespeed <<= 1; } break; From 625b77a2992c2f17f48d51dbe2b440c7d6403d45 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 13 Apr 2023 21:18:05 +0100 Subject: [PATCH 09/27] Got_KickCmd: Do not kick players with the server node from the server (this shut down the server previously !?) --- src/d_clisrv.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 7c3fbb4b3..7975891e9 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2915,16 +2915,6 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) pnum = READUINT8(*p); msg = READUINT8(*p); - if (pnum == serverplayer && IsPlayerAdmin(playernum)) - { - CONS_Printf(M_GetText("Server is being shut down remotely. Goodbye!\n")); - - if (server) - COM_BufAddText("quit\n"); - - return; - } - // Is playernum authorized to make this kick? if (playernum != serverplayer && !IsPlayerAdmin(playernum) /*&& !(playernode[playernum] != UINT8_MAX && playerpernode[playernode[playernum]] == 2 @@ -2974,6 +2964,12 @@ static void Got_KickCmd(UINT8 **p, INT32 playernum) READSTRINGN(*p, reason, MAX_REASONLENGTH+1); } + if (playernode[pnum] == servernode) + { + CONS_Printf(M_GetText("Ignoring kick attempt from %s on node %d (it's the server)\n"), player_names[playernum], servernode); + return; + } + //CONS_Printf("\x82%s ", player_names[pnum]); // Save bans here. Used to be split between here and the actual command, depending on From 32119ae72845a8d175eae4db01643cb462f73aad Mon Sep 17 00:00:00 2001 From: Oni Date: Sat, 8 Apr 2023 03:24:05 +0000 Subject: [PATCH 10/27] Merge branch 'optimize-clip-sprites' into 'master' Optimize sprite sorting by excluding sprites that are completely obscured by geometry See merge request KartKrew/Kart!1146 --- src/r_things.c | 61 +++++++++++++++++++++++++++++--------------------- src/r_things.h | 1 + 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index 48ce29bc9..039a80c97 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -2615,39 +2615,41 @@ static boolean R_SortVisSpriteFunc(vissprite_t *ds, fixed_t bestscale, INT32 bes // static void R_SortVisSprites(vissprite_t* vsprsortedhead, UINT32 start, UINT32 end) { - UINT32 i, linkedvissprites = 0; + UINT32 i, count = 0; vissprite_t *ds, *dsprev, *dsnext, *dsfirst; vissprite_t *best = NULL; vissprite_t unsorted; fixed_t bestscale; INT32 bestdispoffset; - unsorted.next = unsorted.prev = &unsorted; + dsfirst = &unsorted; + dsprev = dsfirst; + dsnext = dsfirst; - dsfirst = R_GetVisSprite(start); + I_Assert(start <= end); - // The first's prev and last's next will be set to - // nonsense, but are fixed in a moment - for (i = start, dsnext = dsfirst, ds = NULL; i < end; i++) + for (i = start; i < end; ++i) { - dsprev = ds; - ds = dsnext; - if (i < end - 1) dsnext = R_GetVisSprite(i + 1); + ds = R_GetVisSprite(i); - ds->next = dsnext; - ds->prev = dsprev; - ds->linkdraw = NULL; + // Do not include this sprite, since it is completely obscured + if (ds->cut & SC_CULL) + { + continue; + } + + dsnext = ds; + dsnext->linkdraw = NULL; + + dsprev->next = dsnext; + dsnext->prev = dsprev; + dsprev = dsnext; + + count++; } - // Fix first and last. ds still points to the last one after the loop - dsfirst->prev = &unsorted; - unsorted.next = dsfirst; - if (ds) - { - ds->next = &unsorted; - ds->linkdraw = NULL; - } - unsorted.prev = ds; + dsnext->next = dsfirst; + dsfirst->prev = dsnext; // bundle linkdraw for (ds = unsorted.prev; ds != &unsorted; ds = ds->prev) @@ -2693,7 +2695,7 @@ static void R_SortVisSprites(vissprite_t* vsprsortedhead, UINT32 start, UINT32 e // remove from chain ds->next->prev = ds->prev; ds->prev->next = ds->next; - linkedvissprites++; + count--; if (dsfirst != &unsorted) { @@ -2727,7 +2729,7 @@ static void R_SortVisSprites(vissprite_t* vsprsortedhead, UINT32 start, UINT32 e // pull the vissprites out by scale vsprsortedhead->next = vsprsortedhead->prev = vsprsortedhead; - for (i = start; i < end-linkedvissprites; i++) + for (i = 0; i < count; i++) { bestscale = bestdispoffset = INT32_MAX; for (ds = unsorted.next; ds != &unsorted; ds = ds->next) @@ -3142,6 +3144,7 @@ void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* portal) fixed_t scale; fixed_t lowscale; INT32 silhouette; + INT32 xclip; for (x = x1; x <= x2; x++) { @@ -3314,7 +3317,7 @@ void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* portal) // all clipping has been performed, so store the values - what, did you think we were drawing them NOW? // check for unclipped columns - for (x = x1; x <= x2; x++) + for (xclip = x = x1; x <= x2; x++) { if (spr->clipbot[x] == CLIP_UNDEF) spr->clipbot[x] = (INT16)viewheight; @@ -3322,9 +3325,17 @@ void R_ClipVisSprite(vissprite_t *spr, INT32 x1, INT32 x2, portal_t* portal) if (spr->cliptop[x] == CLIP_UNDEF) //Fab : 26-04-98: was -1, now clips against console bottom spr->cliptop[x] = (INT16)con_clipviewtop; + + // Sprite is completely above or below clip plane + if (spr->szt >= spr->clipbot[x] || spr->sz <= spr->cliptop[x]) + xclip++; } - if (portal) + if (xclip == x) + { + spr->cut |= SC_CULL; // completely skip this sprite going forward + } + else if (portal) { INT32 start_index = max(portal->start, x1); INT32 end_index = min(portal->start + portal->end - portal->start, x2); diff --git a/src/r_things.h b/src/r_things.h index ba44acecd..789e7aab8 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -138,6 +138,7 @@ typedef enum // srb2kart SC_SEMIBRIGHT = 1<<12, SC_BBOX = 1<<13, + SC_CULL = 1<<14, // masks SC_CUTMASK = SC_TOP|SC_BOTTOM, SC_FLAGMASK = ~SC_CUTMASK From 6d02aac2103da321ebf3e7414357e096a613113f Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 31 Mar 2023 14:36:16 +0100 Subject: [PATCH 11/27] Hardcode assist, part 1 - Add read-only `string` field to several info table metatables already available in Lua. - mobjinfo[i].name - states[i].name - sfxinfo[i].string --- src/lua_infolib.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 0b8359065..1982a5af8 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -43,7 +43,8 @@ enum sfxinfo_read { sfxinfor_flags, // "pitch" sfxinfor_volume, sfxinfor_caption, - sfxinfor_skinsound + sfxinfor_skinsound, + sfxinfor_string, }; const char *const sfxinfo_ropt[] = { "name", @@ -53,6 +54,7 @@ const char *const sfxinfo_ropt[] = { "volume", "caption", "skinsound", + "string", NULL}; enum sfxinfo_write { @@ -923,6 +925,24 @@ static int state_get(lua_State *L) number = st->var2; else if (fastcmp(field,"nextstate")) number = st->nextstate; + else if (fastcmp(field,"string")) + { + statenum_t id = st-states; + if (id < S_FIRSTFREESLOT) + { + lua_pushstring(L, STATE_LIST[id]+2); + return 1; + } + + id -= S_FIRSTFREESLOT; + if (id < NUMSTATEFREESLOTS && FREE_STATES[id]) + { + lua_pushstring(L, FREE_STATES[id]); + return 1; + } + + return 0; + } else if (devparm) return luaL_error(L, LUA_QL("state_t") " has no field named " LUA_QS, field); else @@ -1188,6 +1208,23 @@ static int mobjinfo_get(lua_State *L) lua_pushinteger(L, info->flags); else if (fastcmp(field,"raisestate")) lua_pushinteger(L, info->raisestate); + else if (fastcmp(field,"string")) { + mobjtype_t id = info-mobjinfo; + if (id < MT_FIRSTFREESLOT) + { + lua_pushstring(L, MOBJTYPE_LIST[id]+3); + return 1; + } + + id -= MT_FIRSTFREESLOT; + if (id < NUMMOBJFREESLOTS && FREE_MOBJS[id]) + { + lua_pushstring(L, FREE_MOBJS[id]); + return 1; + } + + return 0; + } else { lua_getfield(L, LUA_REGISTRYINDEX, LREG_EXTVARS); I_Assert(lua_istable(L, -1)); @@ -1411,6 +1448,10 @@ static int sfxinfo_get(lua_State *L) case sfxinfor_skinsound: lua_pushinteger(L, sfx->skinsound); return 1; + case sfxinfor_string: { + lua_pushstring(L, sfx->name); + return 1; + } default: return luaL_error(L, "Field does not exist in sfxinfo_t"); } From e1d642f751d752f25ac96e1b9eb7bfbc474e915b Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 1 Apr 2023 05:44:59 -0700 Subject: [PATCH 12/27] Hardcode assist, part J (jartha) - Add read-only `actionname` field to Lua states. - Resolves to function name definition of global Lua functions. - Resolves to all-uppercase name for C actions. - Resolves to "NULL" string if nil. --- src/blua/ldebug.c | 20 ++++++++++++++++++++ src/blua/lfunc.c | 3 +++ src/blua/lobject.h | 3 +++ src/blua/lparser.c | 34 +++++++++++++++++++++++----------- src/lua_infolib.c | 22 ++++++++++++++++++++++ 5 files changed, 71 insertions(+), 11 deletions(-) diff --git a/src/blua/ldebug.c b/src/blua/ldebug.c index 542e209a1..143d5d614 100644 --- a/src/blua/ldebug.c +++ b/src/blua/ldebug.c @@ -31,6 +31,9 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name); +#ifdef DEVELOP +static const char *getcanonicalfuncname (Closure *f, const char **name); +#endif static int currentpc (lua_State *L, CallInfo *ci) { @@ -212,7 +215,11 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, break; } case 'n': { +#ifdef DEVELOP + ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : getcanonicalfuncname(f, &ar->name); +#else ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; +#endif if (ar->namewhat == NULL) { ar->namewhat = ""; /* not found */ ar->name = NULL; @@ -555,6 +562,19 @@ static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) { } +#ifdef DEVELOP +static const char *getcanonicalfuncname (Closure *cl, const char **name) { + if (!cl->c.isC && cl->l.p->canonicalname) + { + *name = cl->l.p->canonicalname; + return "global"; + } + else + return NULL; +} +#endif + + /* only ANSI way to check whether a pointer points to an array */ static int isinstack (CallInfo *ci, const TValue *o) { StkId p; diff --git a/src/blua/lfunc.c b/src/blua/lfunc.c index 22f670e67..a07824c44 100644 --- a/src/blua/lfunc.c +++ b/src/blua/lfunc.c @@ -134,6 +134,9 @@ Proto *luaF_newproto (lua_State *L) { f->linedefined = 0; f->lastlinedefined = 0; f->source = NULL; +#ifdef DEVELOP + f->canonicalname = NULL; +#endif return f; } diff --git a/src/blua/lobject.h b/src/blua/lobject.h index 24309a1ec..6484e0e8c 100644 --- a/src/blua/lobject.h +++ b/src/blua/lobject.h @@ -237,6 +237,9 @@ typedef struct Proto { struct LocVar *locvars; /* information about local variables */ TString **upvalues; /* upvalue names */ TString *source; +#ifdef DEVELOP + const char *canonicalname; /* function name, only for globals right now */ +#endif int sizeupvalues; int sizek; /* size of `k' */ int sizecode; diff --git a/src/blua/lparser.c b/src/blua/lparser.c index 3f392ae7b..aeed307ec 100644 --- a/src/blua/lparser.c +++ b/src/blua/lparser.c @@ -246,8 +246,7 @@ static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int base) { } -static void singlevar (LexState *ls, expdesc *var) { - TString *varname = str_checkname(ls); +static void singlevar (LexState *ls, expdesc *var, TString *varname) { FuncState *fs = ls->fs; if (singlevaraux(fs, varname, var, 1) == VGLOBAL) var->u.s.info = luaK_stringK(fs, varname); /* info points to global name */ @@ -603,11 +602,16 @@ static void body_noparms (LexState *ls, expdesc *e, int line) { close_func(ls); pushclosure(ls, &new_fs, e); } -static void body (LexState *ls, expdesc *e, int needself, int line) { +static void body (LexState *ls, expdesc *e, int needself, int line, const char *name) { /* body -> `(' parlist `)' chunk END */ FuncState new_fs; open_func(ls, &new_fs); new_fs.f->linedefined = line; +#ifdef DEVELOP + new_fs.f->canonicalname = name; +#else + (void)name; +#endif checknext(ls, '('); if (needself) { new_localvarliteral(ls, "self", 0); @@ -706,7 +710,7 @@ static void prefixexp (LexState *ls, expdesc *v) { return; } case TK_NAME: { - singlevar(ls, v); + singlevar(ls, v, str_checkname(ls)); return; } case '$': { @@ -826,7 +830,7 @@ static void simpleexp (LexState *ls, expdesc *v) { } case TK_FUNCTION: { luaX_next(ls); - body(ls, v, 0, ls->linenumber); + body(ls, v, 0, ls->linenumber, NULL); return; } default: { @@ -1315,11 +1319,12 @@ static void ifstat (LexState *ls, int line) { static void localfunc (LexState *ls) { expdesc v, b; FuncState *fs = ls->fs; - new_localvar(ls, str_checkname(ls), 0); + TString *name = str_checkname(ls); + new_localvar(ls, name, 0); init_exp(&v, VLOCAL, fs->freereg); luaK_reserveregs(fs, 1); adjustlocalvars(ls, 1); - body(ls, &b, 0, ls->linenumber); + body(ls, &b, 0, ls->linenumber, NULL); luaK_storevar(fs, &v, &b); /* debug information will only see the variable after this point! */ getlocvar(fs, fs->nactvar - 1).startpc = fs->pc; @@ -1345,10 +1350,10 @@ static void localstat (LexState *ls) { } -static int funcname (LexState *ls, expdesc *v) { +static int funcname (LexState *ls, expdesc *v, TString *varname) { /* funcname -> NAME {field} [`:' NAME] */ int needself = 0; - singlevar(ls, v); + singlevar(ls, v, varname); while (ls->t.token == '.') field(ls, v); if (ls->t.token == ':') { @@ -1363,9 +1368,16 @@ static void funcstat (LexState *ls, int line) { /* funcstat -> FUNCTION funcname body */ int needself; expdesc v, b; + TString *name; luaX_next(ls); /* skip FUNCTION */ - needself = funcname(ls, &v); - body(ls, &b, needself, line); + name = str_checkname(ls); + needself = funcname(ls, &v, name); +#ifdef DEVELOP + /* just strdup this because I couldn't figure out gc */ + body(ls, &b, needself, line, name ? strdup(getstr(name)) : NULL); +#else + body(ls, &b, needself, line, NULL); +#endif luaK_storevar(ls->fs, &v, &b); luaK_fixline(ls->fs, line); /* definition `happens' in the first line */ } diff --git a/src/lua_infolib.c b/src/lua_infolib.c index 1982a5af8..555bf3196 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -919,6 +919,28 @@ static int state_get(lua_State *L) // because the metatable will trigger. lua_getglobal(L, name); // actually gets from LREG_ACTIONS if applicable, and pushes a META_ACTION userdata if not. return 1; // return just the function +#ifdef DEVELOP + } else if (fastcmp(field,"actionname")) { + if (!st->action.acp1) { // Action is NULL. + lua_pushstring(L, "NULL"); + } else if (st->action.acp1 == (actionf_p1)A_Lua) { // This is a Lua function? + lua_Debug ar; + lua_getfield(L, LUA_REGISTRYINDEX, LREG_STATEACTION); + I_Assert(lua_istable(L, -1)); + lua_pushlightuserdata(L, st); // Push the state pointer and + lua_rawget(L, -2); // use it to get the actual Lua function. + lua_remove(L, -2); // pop LREG_STATEACTION + // This normally doesn't get a function's name because the same Lua function can have many names. + // It only works because of a hack called 'canonicalname' in blua/lparser.c, which records the + // name a GLOBAL function was defined with. This does not work for local functions! (Lua actions + // are almost always global functions though.) + lua_getinfo(L, ">n", &ar); + lua_pushstring(L, ar.name); + } else { + lua_pushstring(L, LUA_GetActionName(&st->action)); // find a hardcoded function name + } + return 1; +#endif } else if (fastcmp(field,"var1")) number = st->var1; else if (fastcmp(field,"var2")) From 496fa40d0e2d48850fa2659a170932b88c701513 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 29 Mar 2023 23:29:04 -0700 Subject: [PATCH 13/27] Play a goofy sound when I_Erroring Reorders shutdown in I_Error a little bit so the message box displays before I_ShutdownSound and SDL_Quit (so the sound can continue playing while the message box is open). This should not have any other effects and I_ShutdownGraphics is still done beforehand, which closes the main game window. --- src/sdl/i_system.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 442109da5..f3c5b9fa2 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1960,6 +1960,12 @@ void I_Error(const char *error, ...) exit(-1); // recursive errors detected } } + else + { + // This makes crashes funnier by stimulating the funnicampus of the brain + S_StopSounds(); + S_StartSound(NULL, sfx_etexpl); + } shutdowning = true; @@ -1989,13 +1995,10 @@ void I_Error(const char *error, ...) D_QuitNetGame(); CL_AbortDownloadResume(); M_FreePlayerSetupColors(); + I_ShutdownMusic(); - I_ShutdownSound(); - // use this for 1.28 19990220 by Kin I_ShutdownGraphics(); I_ShutdownInput(); - I_ShutdownSystem(); - SDL_Quit(); // Implement message box with SDL_ShowSimpleMessageBox, // which should fail gracefully if it can't put a message box up @@ -2005,6 +2008,12 @@ void I_Error(const char *error, ...) "SRB2Kart "VERSIONSTRING" Error", buffer, NULL); + // We wait until now to do this so the funny sound can be heard + I_ShutdownSound(); + // use this for 1.28 19990220 by Kin + I_ShutdownSystem(); + SDL_Quit(); + // Note that SDL_ShowSimpleMessageBox does *not* require SDL to be // initialized at the time, so calling it after SDL_Quit() is // perfectly okay! In addition, we do this on purpose so the From 9ba37ea8c3937b0d68da08f2da25beef55cee5e8 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:53:52 -0400 Subject: [PATCH 14/27] Make this sonic death sound --- src/sdl/i_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index f3c5b9fa2..691aaab28 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -1964,7 +1964,7 @@ void I_Error(const char *error, ...) { // This makes crashes funnier by stimulating the funnicampus of the brain S_StopSounds(); - S_StartSound(NULL, sfx_etexpl); + S_StartSound(NULL, sfx_s3k35); } shutdowning = true; From 29cd2daee45aaee1db4a03f85390b6a00d474647 Mon Sep 17 00:00:00 2001 From: Sal Date: Wed, 29 Mar 2023 21:42:42 +0000 Subject: [PATCH 15/27] Merge branch 'no-lua' into 'master' Add -nolua command line parameter See merge request KartKrew/Kart!1117 --- src/lua_script.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/lua_script.c b/src/lua_script.c index c42f568c2..688fb31e3 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -36,6 +36,7 @@ #include "doomstat.h" #include "g_state.h" +#include "m_argv.h" lua_State *gL = NULL; @@ -608,6 +609,12 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump, boolean noresults) MYFILE f; char *name; size_t len; + + if (M_CheckParm("-nolua")) + { + return; + } + f.wad = wad; f.size = W_LumpLengthPwad(wad, lump); f.data = Z_Malloc(f.size, PU_LUA, NULL); From 6c99bd2a9f12a4a445a23893235c231b9fa94156 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Mar 2023 20:44:43 -0700 Subject: [PATCH 16/27] lua_baselib.c: expose P_SpawnMobjFromMobjUnscaled --- src/lua_baselib.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index e190de7e3..7bb7afc4c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -671,6 +671,23 @@ static int lib_pSpawnMobjFromMobj(lua_State *L) return 1; } +static int lib_pSpawnMobjFromMobjUnscaled(lua_State *L) +{ + mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + fixed_t x = luaL_checkfixed(L, 2); + fixed_t y = luaL_checkfixed(L, 3); + fixed_t z = luaL_checkfixed(L, 4); + mobjtype_t type = luaL_checkinteger(L, 5); + NOHUD + INLEVEL + if (!actor) + return LUA_ErrInvalid(L, "mobj_t"); + if (type >= NUMMOBJTYPES) + return luaL_error(L, "mobj type %d out of range (0 - %d)", type, NUMMOBJTYPES-1); + LUA_PushUserdata(L, P_SpawnMobjFromMobjUnscaled(actor, x, y, z, type), META_MOBJ); + return 1; +} + static int lib_pRemoveMobj(lua_State *L) { mobj_t *th = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -3857,6 +3874,7 @@ static luaL_Reg lib[] = { // don't add P_SetMobjState or P_SetPlayerMobjState, use "mobj.state = S_NEWSTATE" instead. {"P_SpawnMobj",lib_pSpawnMobj}, {"P_SpawnMobjFromMobj",lib_pSpawnMobjFromMobj}, + {"P_SpawnMobjFromMobjUnscaled",lib_pSpawnMobjFromMobjUnscaled}, {"P_RemoveMobj",lib_pRemoveMobj}, {"P_IsValidSprite2", lib_pIsValidSprite2}, {"P_SpawnLockOn", lib_pSpawnLockOn}, From c7cad1c14a255c55aecd1e89e620acc9c2604d31 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:59:53 -0400 Subject: [PATCH 17/27] adjust to start at 0 instead of 3 --- src/p_tick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_tick.c b/src/p_tick.c index d300a6635..fbb212113 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -672,7 +672,7 @@ void P_Ticker(boolean run) // Bosses have a punchy start, so no position. if (bossinfo.boss == true) { - if (leveltime == 3) + if (leveltime == 0) { S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); S_ShowMusicCredit(); From a60c683908b2b139d538df6960fd491760321448 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 8 Mar 2023 21:08:02 -0800 Subject: [PATCH 18/27] Call K_TimerReset before spawning map things Fixes DUEL items spawning twice if DUEL mode remains on between maps. Fixes DUEL items spawning the next map after DUEL mode deactivates. --- src/p_setup.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_setup.c b/src/p_setup.c index 0f24b2137..2c9752787 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4193,6 +4193,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) INT32 i, ranspecialwipe = 0; sector_t *ss; + K_TimerReset(); + levelloading = true; // This is needed. Don't touch. From f3f1eecc6241d540e40f7aff609a2aaa47b99c0a Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:05:29 -0400 Subject: [PATCH 19/27] Revert "Call K_TimerReset before spawning map things" This reverts commit a60c683908b2b139d538df6960fd491760321448. --- src/p_setup.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 2c9752787..0f24b2137 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -4193,8 +4193,6 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate) INT32 i, ranspecialwipe = 0; sector_t *ss; - K_TimerReset(); - levelloading = true; // This is needed. Don't touch. From 5bc58aba5951e85c0f197c5d098514d1297d8cd0 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 3 Mar 2023 03:00:03 -0800 Subject: [PATCH 20/27] Do not start dedicated server in GP if -warp is used --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index 600bc04e9..88e98f134 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1661,7 +1661,7 @@ void D_SRB2Main(void) I_Error("Cannot find a map remotely named '%s'\n", word); else { - if (!M_CheckParm("-server")) + if (!M_CheckParm("-server") && !M_CheckParm("-dedicated")) { G_SetGameModified(true, true); From b8cc9020e99587a64f226ffc91d857ef25295517 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 3 Mar 2023 02:59:31 -0800 Subject: [PATCH 21/27] Do not run ST_Ticker if dedicated --- src/st_stuff.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 9a471dcbc..2fef9536d 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -242,7 +242,9 @@ void ST_Start(void) ST_Stop(); ST_InitData(); - st_stopped = false; + + if (!dedicated) + st_stopped = false; } // From 35a181e0db3e08df0aaf1e66911fa63f2b80f784 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 24 Sep 2022 03:05:30 -0700 Subject: [PATCH 22/27] Let Drop Targets collide with other players immediately after being thrown --- src/k_collide.c | 3 --- src/p_local.h | 1 + src/p_mobj.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/k_collide.c b/src/k_collide.c index 61bddb9b3..322ab0cf3 100644 --- a/src/k_collide.c +++ b/src/k_collide.c @@ -514,9 +514,6 @@ boolean K_DropTargetCollide(mobj_t *t1, mobj_t *t2) { mobj_t *draggeddroptarget = (t1->type == MT_DROPTARGET_SHIELD) ? t1->target : NULL; - if ((t1->threshold > 0 && (!draggeddroptarget)) || (t2->threshold > 0)) - return true; - if (((t1->target == t2) || (t1->target == t2->target)) && (t1->threshold > 0 || (t2->type != MT_PLAYER && t2->threshold > 0))) return true; diff --git a/src/p_local.h b/src/p_local.h index 7ced38f2f..953a2c68a 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -324,6 +324,7 @@ boolean P_CheckDeathPitCollide(mobj_t *mo); boolean P_CheckSolidLava(ffloor_t *rover); void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motype); +mobj_t *P_SpawnMobjFromMobjUnscaled(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type); mobj_t *P_SpawnMobjFromMobj(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type); mobj_t *P_SpawnMissile(mobj_t *source, mobj_t *dest, mobjtype_t type); diff --git a/src/p_mobj.c b/src/p_mobj.c index 6ab24c5d2..d32674a0a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -13411,6 +13411,65 @@ fixed_t P_ScaleFromMap(fixed_t n, fixed_t scale) return FixedMul(n, FixedDiv(scale, mapobjectscale)); } +// +// P_SpawnMobjFromMobjUnscaled +// Spawns an object with offsets relative to the position of another object. +// Scale, gravity flip, etc. is taken into account automatically. +// +mobj_t *P_SpawnMobjFromMobjUnscaled(mobj_t *mobj, fixed_t xofs, fixed_t yofs, fixed_t zofs, mobjtype_t type) +{ + mobj_t *newmobj; + + newmobj = P_SpawnMobj(mobj->x + xofs, mobj->y + yofs, mobj->z + zofs, type); + if (!newmobj) + return NULL; + + newmobj->destscale = P_ScaleFromMap(mobj->destscale, newmobj->destscale); + P_SetScale(newmobj, P_ScaleFromMap(mobj->scale, newmobj->scale)); + + if (mobj->eflags & MFE_VERTICALFLIP) + { + newmobj->eflags |= MFE_VERTICALFLIP; + newmobj->flags2 |= MF2_OBJECTFLIP; + newmobj->z = mobj->z + mobj->height - zofs - newmobj->height; + + newmobj->old_z = mobj->old_z + mobj->height - zofs - newmobj->height; + newmobj->old_z2 = mobj->old_z2 + mobj->height - zofs - newmobj->height; + } + else + { + newmobj->old_z = mobj->old_z + zofs; + newmobj->old_z2 = mobj->old_z2 + zofs; + } + + newmobj->old_x2 = mobj->old_x2 + xofs; + newmobj->old_y2 = mobj->old_y2 + yofs; + newmobj->old_x = mobj->old_x + xofs; + newmobj->old_y = mobj->old_y + yofs; + + // This angle hack is needed for Lua scripts that set the angle after + // spawning, to avoid erroneous interpolation. + if (mobj->player) + { + newmobj->old_angle2 = mobj->player->old_drawangle2; + newmobj->old_angle = mobj->player->old_drawangle; + } + else + { + newmobj->old_angle2 = mobj->old_angle2; + newmobj->old_angle = mobj->old_angle; + } + + newmobj->old_scale2 = mobj->old_scale2; + newmobj->old_scale = mobj->old_scale; + newmobj->old_spritexscale = mobj->old_spritexscale; + newmobj->old_spriteyscale = mobj->old_spriteyscale; + newmobj->old_spritexoffset = mobj->old_spritexoffset; + newmobj->old_spriteyoffset = mobj->old_spriteyoffset; + + return newmobj; +} + // // P_SpawnMobjFromMobj // Spawns an object with offsets relative to the position of another object. From fa1ac4efd3d2c25a6cb37707f30a632b5f9be6a1 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 24 Sep 2022 03:05:52 -0700 Subject: [PATCH 23/27] Let Drop Targets collide with other items immediately after being thrown see efc415e5 --- src/k_collide.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_collide.c b/src/k_collide.c index 322ab0cf3..80847fa01 100644 --- a/src/k_collide.c +++ b/src/k_collide.c @@ -514,7 +514,7 @@ boolean K_DropTargetCollide(mobj_t *t1, mobj_t *t2) { mobj_t *draggeddroptarget = (t1->type == MT_DROPTARGET_SHIELD) ? t1->target : NULL; - if (((t1->target == t2) || (t1->target == t2->target)) && (t1->threshold > 0 || (t2->type != MT_PLAYER && t2->threshold > 0))) + if (((t1->target == t2) || (t1->target == t2->target)) && ((t1->threshold > 0 && t2->type == MT_PLAYER) || (t2->type != MT_PLAYER && t2->threshold > 0))) return true; if (t1->health <= 0 || t2->health <= 0) From 9925d4c2380a68b1ad564dc21a396339abfca519 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 1 Mar 2023 16:32:23 +0000 Subject: [PATCH 24/27] Move starting countdown sounds to p_tick.c Fixes an issue where the starting countdown wouldn't play in spectator mode or hitlag --- src/k_kart.c | 12 ------------ src/p_tick.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index acd8d2c02..bcf391952 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8907,18 +8907,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground) { player->pflags &= ~PF_AIRFAILSAFE; } - - // Play the starting countdown sounds - if (!(gametyperules & GTR_FREEROAM) && player == &players[g_localplayers[0]]) // Don't play louder in splitscreen - { - if ((leveltime == starttime-(3*TICRATE)) || (leveltime == starttime-(2*TICRATE)) || (leveltime == starttime-TICRATE)) - S_StartSound(NULL, sfx_s3ka7); - - if (leveltime == starttime-(3*TICRATE)) - S_FadeOutStopMusic(3500); - else if (leveltime == starttime) - S_StartSound(NULL, sfx_s3kad); - } } void K_CheckSpectateStatus(void) diff --git a/src/p_tick.c b/src/p_tick.c index fbb212113..6f7f5ba21 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -681,6 +681,19 @@ void P_Ticker(boolean run) // Plays the music after the starting countdown. else { + if (leveltime == starttime-(3*TICRATE)) + { + S_StartSound(NULL, sfx_s3ka7); // 3, + S_FadeOutStopMusic(3500); + } + else if ((leveltime == starttime-(2*TICRATE)) || (leveltime == starttime-TICRATE)) + { + S_StartSound(NULL, sfx_s3ka7); // 2, 1, + } + else if (leveltime == starttime) + { + S_StartSound(NULL, sfx_s3kad); // GO! + } if (leveltime == (starttime + (TICRATE/2))) { S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); From 8963f81576c832f55ac114a786c154887e05f2e8 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 1 Mar 2023 07:25:54 -0800 Subject: [PATCH 25/27] Don't let death type damage kill respawning player This includes death pits and instakill sectors. Does not affect direct P_KillMobj calls. --- src/p_inter.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_inter.c b/src/p_inter.c index 121a806a4..f22e3a919 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1870,6 +1870,12 @@ static boolean P_KillPlayer(player_t *player, mobj_t *inflictor, mobj_t *source, { (void)source; + if (player->respawn) + { + K_DoInstashield(player); + return false; + } + if (player->exiting) { player->mo->destscale = 1; From 2968a23c8640d8cbfaa3959dddc845f7c77aa9b2 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:43:22 -0400 Subject: [PATCH 26/27] Add missing stuff Ghosts still freeze will look into later --- src/g_demo.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 87e06332b..cf99f8172 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1113,7 +1113,7 @@ void G_GhostTicker(void) for(g = ghosts, p = NULL; g; g = g->next) { // Skip normal demo data. - UINT8 ziptic = READUINT8(g->p); + UINT16 ziptic = READUINT8(g->p); UINT8 xziptic = 0; while (ziptic != DW_END) // Get rid of extradata stuff @@ -1142,12 +1142,16 @@ void G_GhostTicker(void) ziptic = READUINT8(g->p); } - ziptic = READUINT8(g->p); + ziptic = READUINT16(g->p); if (ziptic & ZT_FWD) g->p++; + if (ziptic & ZT_SIDE) + g->p++; if (ziptic & ZT_TURNING) g->p += 2; + if (ziptic & ZT_ANGLE) + g->p += 2; if (ziptic & ZT_THROWDIR) g->p += 2; if (ziptic & ZT_BUTTONS) From 9c8cde27379f05e3e778ac2eb89021ab6c55a38d Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 19 Feb 2023 06:19:29 +0000 Subject: [PATCH 27/27] Merge branch 'fix-perfstats-4' into 'master' Fix perfstats 4 not working properly See merge request KartKrew/Kart!932 --- src/lua_hooklib.c | 4 ++-- src/p_tick.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 5f25a7931..210eb446a 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -672,7 +672,7 @@ void LUA_HookThinkFrame(void) { get_hook(&hook, map->ids, k); - if (cv_perfstats.value == 3) + if (cv_perfstats.value == PS_THINKFRAME) { lua_pushvalue(gL, -1);/* need the function again */ time_taken = I_GetPreciseTime(); @@ -680,7 +680,7 @@ void LUA_HookThinkFrame(void) call_single_hook(&hook); - if (cv_perfstats.value == 3) + if (cv_perfstats.value == PS_THINKFRAME) { lua_Debug ar; time_taken = I_GetPreciseTime() - time_taken; diff --git a/src/p_tick.c b/src/p_tick.c index 6f7f5ba21..5f6c15c18 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -702,7 +702,7 @@ void P_Ticker(boolean run) } ps_lua_thinkframe_time = I_GetPreciseTime(); - LUA_HOOK(ThinkFrame); + LUA_HookThinkFrame(); ps_lua_thinkframe_time = I_GetPreciseTime() - ps_lua_thinkframe_time; }