From ecfa973e6bc62189a4fabba372ec7680286fe452 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Nov 2025 19:19:17 +0100 Subject: [PATCH 01/11] move M_ResetDemoList hack to G_InitNew --- src/g_game.c | 6 ++++++ src/p_setup.c | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index a02320f66..8960fc055 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4007,6 +4007,12 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool automapactive = false; imcontinuing = false; + // HACK: this doesent reset if you change the map from within a replay and may cause crashes or the replayhut to be non functional + if (!demo.playback && demo.inreplayhut) + { + M_ResetDemoList(); + } + if (!skipprecutscene && mapheaderinfo[gamemap-1]->precutscenenum && !modeattacking) // Start a custom cutscene. F_StartCustomCutscene(mapheaderinfo[gamemap-1]->precutscenenum-1, true, resetplayer); else diff --git a/src/p_setup.c b/src/p_setup.c index 91a41abd2..75d8049f0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2743,11 +2743,6 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) lumpnum_t encoreLump = LUMPERROR; UINT8 levelfadecol; - // HACK: this doesent reset if you change the map from within a replay and may cause crashes or the replayhut to be non functional - if (!demo.playback && demo.inreplayhut) - { - M_ResetDemoList(); - } midgamejoin = fromnetsave; // makes dynslopes run in P_Ticker to avoid synch issues and other stuff From 951b880acb7758a0d8c1447d833d25b64de50bb6 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Nov 2025 19:18:53 +0100 Subject: [PATCH 02/11] d_netcmd: use cleanup macro for map and localskin command did Command_Map_f really leak memory all the time? lul --- src/d_netcmd.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index df832d9a3..883003262 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2663,8 +2663,8 @@ static void Command_Map_f(void) INT32 newmapnum; - char * mapname; - char *realmapname = NULL; + CLEANUP(Z_Pfree) char * mapname = NULL; + CLEANUP(Z_Pfree) char *realmapname = NULL; INT32 newgametype = gametype; boolean newencoremode = cv_kartencore.value; @@ -2733,7 +2733,6 @@ static void Command_Map_f(void) if (newmapnum == 0) { CONS_Alert(CONS_ERROR, M_GetText("Could not find any map described as '%s'.\n"), mapname); - Z_Free(mapname); return; } @@ -2765,8 +2764,6 @@ static void Command_Map_f(void) " 0 and %d inclusive. ...Or just use the name. :v\n", d, NUMGAMETYPES-1); - Z_Free(realmapname); - Z_Free(mapname); return; } } @@ -2775,8 +2772,6 @@ static void Command_Map_f(void) CONS_Alert(CONS_ERROR, "'%s' is not a gametype.\n", gametypename); - Z_Free(realmapname); - Z_Free(mapname); return; } } @@ -2794,8 +2789,6 @@ static void Command_Map_f(void) if (!mapheaderinfo[newmapnum-1]) { CONS_Alert(CONS_WARNING, M_GetText("Invalid mapheaderinfo for Course %s (%s)\n"), realmapname, G_BuildMapName(newmapnum)); - Z_Free(realmapname); - Z_Free(mapname); return; } @@ -2803,8 +2796,6 @@ static void Command_Map_f(void) { CONS_Alert(CONS_WARNING, M_GetText("Course %s (%s) doesn't support %s mode!\n(Use -force to override)\n"), realmapname, G_BuildMapName(newmapnum), (multiplayer ? gametype_cons_t[newgametype].strvalue : "Single Player")); - Z_Free(realmapname); - Z_Free(mapname); return; } } @@ -2816,8 +2807,6 @@ static void Command_Map_f(void) if (!dedicated && M_MapLocked(newmapnum)) { CONS_Alert(CONS_NOTICE, M_GetText("You need to unlock this level before you can warp to it!\n")); - Z_Free(realmapname); - Z_Free(mapname); return; } @@ -2843,8 +2832,6 @@ static void Command_Map_f(void) fromlevelselect = false; D_MapChange(newmapnum, newgametype, newencoremode, newresetplayers, 0, false, false); - - Z_Free(realmapname); } /** Receives a map command and changes the map. @@ -4509,7 +4496,7 @@ static void Command_Addskins(void) CONS_Printf("addskins has been deprecated\nuse addfilelocal instead!\n"); } -static void Command_GLocalSkin (void) +static void Command_GLocalSkin(void) { size_t first_option; size_t option_display; @@ -4520,7 +4507,7 @@ static void Command_GLocalSkin (void) option_display = COM_CheckPartialParm("-d"); option_all = COM_CheckPartialParm("-a"); - char* fuck; // local skin name + CLEANUP(Z_Pfree) char* fuck = NULL; // local skin name if (!(first_option = COM_FirstOption())) first_option = COM_Argc(); @@ -4561,7 +4548,6 @@ static void Command_GLocalSkin (void) CONS_Printf("Successfully applied localskin to displayed player.\n"); - Z_Free(fuck); return; } else if (option_all) // -all @@ -4576,7 +4562,6 @@ static void Command_GLocalSkin (void) } CONS_Printf("Successfully applied localskin to all players.\n"); - Z_Free(fuck); return; } else // -player or no other arguments @@ -4593,7 +4578,6 @@ static void Command_GLocalSkin (void) } CONS_Printf("Successfully applied localskin to specified player.\n"); - Z_Free(fuck); return; } else @@ -4601,13 +4585,11 @@ static void Command_GLocalSkin (void) SetLocalPlayerSkin(consoleplayer, fuck, &cv_localskin); CONS_Printf("Successfully applied localskin.\n"); - Z_Free(fuck); return; } CONS_Printf("Could not apply localskin.\n"); - Z_Free(fuck); return; } } From 2c2ffe36d7341b88e0401ce88c18bea5db38073d Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Nov 2025 20:15:27 +0100 Subject: [PATCH 03/11] init a few more globals that were missed i love globals that are in the middle of files..... --- src/d_netcmd.c | 7 +++---- src/m_menu.c | 9 +++++---- src/p_maputl.cpp | 6 +++--- src/p_mobj.c | 10 +++++----- src/p_setup.c | 10 +++++----- src/p_user.c | 3 +-- 6 files changed, 22 insertions(+), 23 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 883003262..eca887ef8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -274,7 +274,7 @@ consvar_t cv_showlocalskinmenus = {"showlocalskinmenus", "Yes", CV_SAVE, CV_YesN consvar_t cv_skipmapcheck = {"skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -INT32 cv_debug; +INT32 cv_debug = 0; static void UseMouse_OnChange(void); consvar_t cv_usemouse = {"use_mouse", "Off", CV_SAVE|CV_CALL, usemouse_cons_t, UseMouse_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -531,7 +531,7 @@ boolean forceresetplayers = false; boolean deferencoremode = false; UINT8 splitscreen = 0; boolean circuitmap = true; // SRB2kart -INT32 adminplayers[MAXPLAYERS]; +INT32 adminplayers[MAXPLAYERS] = {}; /// \warning Keep this up-to-date if you add/remove/rename net text commands const char *netxcmdnames[MAXNETXCMD - 1] = @@ -2589,8 +2589,7 @@ void D_PickVote(void) SendNetXCmd(XD_PICKVOTE, &buf, 2); } -static char * -ConcatCommandArgv (int start, int end) +static char *ConcatCommandArgv(int start, int end) { char *final; diff --git a/src/m_menu.c b/src/m_menu.c index 7718c294a..a4bf51f3d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2995,6 +2995,7 @@ static void M_StopMessage(INT32 choice) static void M_DrawImageDef(void) { patch_t *patch = (patch_t *)W_CachePatchName(currentMenu->menuitems[itemOn].text, PU_PATCH); + if (patch->width <= BASEVIDWIDTH) V_DrawScaledPatch(0,0,0,patch); else @@ -3769,10 +3770,10 @@ static void M_HandleAddons(INT32 choice) } // ---- REPLAY HUT ----- -menudemo_t *demolist; // Replays that that have been checked to match with query +menudemo_t *demolist = NULL; // Replays that that have been checked to match with query // Locked behind Lock_search_state -menudemo_t *demolist_all; // All replays +menudemo_t *demolist_all = NULL; // All replays boolean replaynamesloaded = false; #ifdef HAVE_THREADS @@ -5104,7 +5105,7 @@ void M_PopupMasterServerRules(void) UINT16 ccvaralphakey = 4; INT16 ccvarlaststheader = 0; -INT32 CVARSETUP; +INT32 CVARSETUP = 0; void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* name) { @@ -5149,7 +5150,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na // SKY ROOM // ======== -UINT8 skyRoomMenuTranslations[MAXUNLOCKABLES]; +UINT8 skyRoomMenuTranslations[MAXUNLOCKABLES] = {}; static char *M_GetConditionString(condition_t cond) { diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 3209f6f51..37b31c4ac 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -230,8 +230,8 @@ PUREFUNC fixed_t P_InterceptVector(divline_t *v2, divline_t *v1) // Sets opentop and openbottom to the window through a two sided line. // OPTIMIZE: keep this precalculated // -fixed_t opentop, openbottom, openrange, lowfloor, highceiling; -pslope_t *opentopslope, *openbottomslope; +fixed_t opentop = 0, openbottom = 0, openrange = 0, lowfloor = 0, highceiling = 0; +pslope_t *opentopslope = NULL, *openbottomslope = NULL; // P_CameraLineOpening // P_LineOpening, but for camera @@ -985,7 +985,7 @@ boolean P_BlockThingsIterator(INT32 x, INT32 y, boolean (*func)(mobj_t *)) static intercept_t *intercepts = NULL; static intercept_t *intercept_p = NULL; -divline_t trace; +divline_t trace = {}; static boolean earlyout; //SoM: 4/6/2000: Remove limit on intercepts. diff --git a/src/p_mobj.c b/src/p_mobj.c index 143415ea2..14aa6af8d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10063,9 +10063,9 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype // // P_RemoveMobj // -mapthing_t *itemrespawnque[ITEMQUESIZE]; -tic_t itemrespawntime[ITEMQUESIZE]; -size_t iquehead, iquetail; +mapthing_t *itemrespawnque[ITEMQUESIZE] = {}; +tic_t itemrespawntime[ITEMQUESIZE] = {}; +size_t iquehead = 0, iquetail = 0; #ifdef PARANOIA #define SCRAMBLE_REMOVED // Force debug build to crash when Removed mobj is accessed @@ -10949,8 +10949,8 @@ void P_MovePlayerToStarpost(INT32 playernum) } #define MAXHUNTEMERALDS 64 -mapthing_t *huntemeralds[MAXHUNTEMERALDS]; -INT32 numhuntemeralds; +mapthing_t *huntemeralds[MAXHUNTEMERALDS] = {}; +INT32 numhuntemeralds = 0; // // P_SpawnMapThing diff --git a/src/p_setup.c b/src/p_setup.c index 75d8049f0..887a74bb5 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -597,8 +597,8 @@ FUNCINLINE static ATTRINLINE void P_LoadSubsectors(void *data) // #define MAXLEVELFLATS 256 -size_t numlevelflats; -levelflat_t *levelflats; +size_t numlevelflats = 0; +levelflat_t *levelflats = NULL; //SoM: Other files want this info. size_t P_PrecacheLevelFlats(void) @@ -2030,8 +2030,8 @@ void P_SetupLevelSky(INT32 skynum, boolean global) R_SetupSkyDraw(); } -static const char *maplumpname; -lumpnum_t lastloadedmaplumpnum; // for comparative savegame +static const char *maplumpname = NULL; +lumpnum_t lastloadedmaplumpnum = LUMPERROR; // for comparative savegame // // P_LevelInitStuff @@ -2415,7 +2415,7 @@ static void P_InitCamera(void) displayplayers[0] = consoleplayer; // Start with your OWN view, please! } -struct minimapinfo minimapinfo; +struct minimapinfo minimapinfo = {}; static void P_InitMinimapInfo(void) { lumpnum_t lumpnum; diff --git a/src/p_user.c b/src/p_user.c index 0b743dcd1..943523244 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1863,7 +1863,6 @@ boolean P_AnalogMove(player_t *player) return player->pflags & PF_ANALOGMODE; } - //#define OLD_MOVEMENT_CODE 1 static void P_3dMovement(player_t *player) { @@ -2931,7 +2930,7 @@ notrealplayer: // P_MoveCamera: make sure the camera is not outside the world and looks at the player avatar // -camera_t camera[MAXSPLITSCREENPLAYERS]; // Four cameras, three for splitscreen +camera_t camera[MAXSPLITSCREENPLAYERS] = {}; // Four cameras, three for splitscreen static void CV_CamRotate_OnChange(void) { From f2a7f9ccaa541fbf074d022fe029c81999016716 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Nov 2025 20:21:15 +0100 Subject: [PATCH 04/11] fix compile with HAVE_DISCORDRPC --- src/m_menudefs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index f0d436e95..03973effc 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -2297,6 +2297,7 @@ menu_t MISC_DiscordRequestsDef = { &MPauseDef, MISC_DiscordRequestsMenu, M_DrawDiscordRequests, + NULL, 0, 0, 0, NULL, From cd32270ec00f491c6f13cb55292ab343219fcab6 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Nov 2025 20:25:07 +0100 Subject: [PATCH 05/11] . W :mompie: --- src/m_menudefs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 03973effc..a57141b7c 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1874,7 +1874,7 @@ static const char* OP_SaturnHudTooltips[] = "Disable the animation of the Positionnumber\nwhen overtaking someone.", "Flash current Lap Time when doing a Lap on the Timer.", "Use extra graphics for multiple sneakers, bananas and jawz.", - "Change when the item amount is to be displayed\nMultiple will always display the number.\nwhen you have multiple of the same Item.\nAlways will always display the number regardless of Item amount.", + "Change when the item amount is to be displayed.\nMultiple will always display the number.\nWhen you have multiple of the same Item.\nAlways will always display the number regardless of Item amount.", "Enables an animation while the roulette is active.", "Show the big 'LAP' text on a lap change.", "Show the big Cecho Messages.", From 0f59e0e270adea690235c1eefa072c805c0a3613 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Nov 2025 21:18:26 +0100 Subject: [PATCH 06/11] some mobj interp fixes copy pasted from RR thx --- src/k_kart.c | 26 ++++++++++++++++++-------- src/p_mobj.c | 9 ++++++++- src/p_saveg.c | 14 +++++++------- src/p_telept.c | 1 + src/p_user.c | 11 +++++++---- 5 files changed, 41 insertions(+), 20 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 0cbd11a9b..141af3481 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3978,15 +3978,19 @@ void K_PuntMine(mobj_t *thismine, mobj_t *punter) mine->floorz = thismine->floorz; mine->ceilingz = thismine->ceilingz; - //Since we aren't using P_KillMobj, we need to clean up the hnext reference - { - P_SetTarget(&thismine->target->hnext, NULL); //target is the player who owns the mine - thismine->target->player->kartstuff[k_bananadrag] = 0; - thismine->target->player->kartstuff[k_itemheld] = 0; + // Copy interp data + mine->old_angle = thismine->old_angle; + mine->old_x = thismine->old_x; + mine->old_y = thismine->old_y; + mine->old_z = thismine->old_z; - if (--thismine->target->player->kartstuff[k_itemamount] <= 0) - thismine->target->player->kartstuff[k_itemtype] = KITEM_NONE; - } + // Since we aren't using P_KillMobj, we need to clean up the hnext reference + P_SetTarget(&thismine->target->hnext, NULL); // target is the player who owns the mine + thismine->target->player->kartstuff[k_bananadrag] = 0; + thismine->target->player->kartstuff[k_itemheld] = 0; + + if (--thismine->target->player->kartstuff[k_itemamount] <= 0) + thismine->target->player->kartstuff[k_itemtype] = KITEM_NONE; P_RemoveMobj(thismine); @@ -4422,6 +4426,12 @@ void K_DropHnextList(player_t *player) dropwork->floorz = work->floorz; dropwork->ceilingz = work->ceilingz; + // Copy interp data + dropwork->old_angle = work->old_angle; + dropwork->old_x = work->old_x; + dropwork->old_y = work->old_y; + dropwork->old_z = work->old_z; + if (ponground) { // floorz and ceilingz aren't properly set to account for FOFs and Polyobjects on spawn diff --git a/src/p_mobj.c b/src/p_mobj.c index 14aa6af8d..78a440c6f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10668,8 +10668,9 @@ void P_SpawnPlayer(INT32 playernum) mobj = P_SpawnMobj(0, 0, 0, MT_PLAYER); I_Assert(mobj != NULL); (mobj->player = p)->mo = mobj; + //P_SetTarget(&p->mo, mobj); - mobj->angle = 0; + mobj->angle = mobj->old_angle = 0; // set color translations for player sprites mobj->color = p->skincolor; @@ -10776,6 +10777,12 @@ void P_AfterPlayerSpawn(INT32 playernum) mobj_t *mobj = p->mo; UINT8 i; + // Update interpolation + mobj->old_x = mobj->x; + mobj->old_y = mobj->y; + mobj->old_z = mobj->z; + mobj->old_angle = mobj->angle; + for (i = 0; i <= splitscreen; i++) { if (playernum == P_GetLocalPlayerNumForNum(i)) diff --git a/src/p_saveg.c b/src/p_saveg.c index b01556413..1fb6c5aa8 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -339,7 +339,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save, boolean reloading) for (j = 0; j < NUMKARTSTUFF; j++) player->kartstuff[j] = READINT32(save->p); - player->frameangle = READANGLE(save->p); + player->frameangle = player->old_frameangle = READANGLE(save->p); player->playerstate = READUINT8(save->p); player->pflags = READUINT32(save->p); @@ -2052,15 +2052,15 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) if (diff & MD_POS) { - mobj->x = READFIXED(save->p); - mobj->y = READFIXED(save->p); - mobj->angle = READANGLE(save->p); + mobj->x = mobj->old_x = READFIXED(save->p); + mobj->y = mobj->old_y = READFIXED(save->p); + mobj->angle = mobj->old_angle = READANGLE(save->p); } else { - mobj->x = mobj->spawnpoint->x << FRACBITS; - mobj->y = mobj->spawnpoint->y << FRACBITS; - mobj->angle = FixedAngle(mobj->spawnpoint->angle*FRACUNIT); + mobj->x = mobj->old_x = mobj->spawnpoint->x << FRACBITS; + mobj->y = mobj->old_y = mobj->spawnpoint->y << FRACBITS; + mobj->angle = mobj->old_angle = FixedAngle(mobj->spawnpoint->angle*FRACUNIT); } if (diff & MD_MOM) diff --git a/src/p_telept.c b/src/p_telept.c index 539e0050b..b7bdb0346 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -106,6 +106,7 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, P_FlashPal(thing->player, PAL_MIXUP, 10); } + thing->old_angle += (angle-thing->angle); thing->angle = angle; thing->momx = thing->momy = thing->momz = 0; diff --git a/src/p_user.c b/src/p_user.c index 943523244..e42411160 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1162,6 +1162,9 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_GHOST); + // not sure if this is safe to do........... + //P_SetTarget(&ghost->target, mobj); + P_SetScale(ghost, mobj->scale); ghost->scalespeed = mobj->scalespeed; ghost->destscale = mobj->scale; @@ -1175,10 +1178,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->color = mobj->color; ghost->colorized = mobj->colorized; // Kart: they should also be colorized if their origin is - if (mobj->player) - ghost->angle = mobj->player->frameangle; - else - ghost->angle = mobj->angle; + ghost->angle = (mobj->player ? mobj->player->frameangle : mobj->angle); ghost->sprite = mobj->sprite; ghost->frame = mobj->frame; @@ -1191,6 +1191,9 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->localskin = mobj->localskin; ghost->skinlocal = mobj->skinlocal; + // same deal... + //ghost->standingslope = mobj->standingslope; + ghost->spritexscale = mobj->spritexscale; ghost->spriteyscale = mobj->spriteyscale; ghost->spritexoffset = mobj->spritexoffset; From 86ac11f87747066539666c0233b0927d3635d02b Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 25 Nov 2025 22:49:16 +0100 Subject: [PATCH 07/11] replace localangle assignments with P_ForceLocalAngle just a little neater, there also was a function to force the player angle, but this most likely wouldve changed behavior --- src/d_clisrv.c | 4 ++- src/g_demo.c | 1 + src/g_game.h | 2 +- src/lua_mobjlib.c | 10 ++----- src/p_inter.c | 9 +----- src/p_local.h | 5 +++- src/p_map.c | 9 +----- src/p_mobj.c | 9 +----- src/p_polyobj.c | 9 ++---- src/p_saveg.c | 10 ------- src/p_spec.c | 27 +++++------------- src/p_telept.c | 13 ++------- src/p_user.c | 73 +++++++++++++++++++++++++++++++---------------- 13 files changed, 75 insertions(+), 106 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index e7010a08f..628fdefc2 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2152,7 +2152,7 @@ static void CL_ReloadReceivedSavegame(void) // we dont have P_ForceLocalAngle so were setting it manually here for (i = 0; i <= splitscreen; i++) { - localangle[i] = (angle_t)(players[displayplayers[i]].cmd.angleturn << 16); + P_ForceLocalAngle(&players[displayplayers[i]], (angle_t)(players[displayplayers[i]].cmd.angleturn << 16)); } for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) @@ -4525,6 +4525,8 @@ static void Got_AddPlayer(const UINT8 **p, INT32 playernum) DEBFILE("spawning me\n"); } + P_ForceLocalAngle(&players[newplayernum], (angle_t)(players[newplayernum].cmd.angleturn << 16)); + D_SendPlayerConfig(); addedtogame = true; } diff --git a/src/g_demo.c b/src/g_demo.c index c670f69cd..7fff0e928 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -484,6 +484,7 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) G_CopyTiccmd(cmd, &oldcmd[playernum], 1); + // what in the actual fuck is this??? // SRB2kart: Copy-pasted from ticcmd building, removes that crappy demo cam if (((players[displayplayers[0]].mo && players[displayplayers[0]].speed > 0) // Moving || (leveltime > starttime && (cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE)) // Rubber-burn turn diff --git a/src/g_game.h b/src/g_game.h index 249ecbff1..c16d02d4a 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -160,7 +160,7 @@ typedef enum const char *G_BuildMapName(INT32 map); void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer); -// copy ticcmd_t to and fro the normal way +// copy ticcmd_t to and from the normal way ticcmd_t *G_CopyTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n); // copy ticcmd_t to and fro network packets ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n); diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index fef27f563..45c3a9f19 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -251,14 +251,8 @@ int mobj_angle_setter(lua_State *L) mobj_t *mo = GETMO(); mo->angle = luaL_checkangle(L, 2); - for (UINT8 i = 0; i <= splitscreen; i++) - { - if (mo->player == P_GetLocalPlayerForNum(i)) - { - localangle[i] = mo->angle; - break; - } - } + if (mo->player) + P_ForceLocalAngle(mo->player, mo->angle); return 0; } diff --git a/src/p_inter.c b/src/p_inter.c index 876ffa4b5..3518684e3 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -869,14 +869,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) toucher->angle = special->angle; - for (i = 0; i <= splitscreen; i++) - { - if (player == P_GetLocalPlayerForNum(i)) - { - localangle[i] = toucher->angle; - break; - } - } + P_ForceLocalAngle(player, toucher->angle); P_ResetPlayer(player); diff --git a/src/p_local.h b/src/p_local.h index 6977cc4b1..4d8e8032d 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -192,6 +192,7 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); void P_ResetPlayer(player_t *player); player_t *P_GetLocalPlayerForNum(UINT8 pnum); INT32 P_GetLocalPlayerNumForNum(UINT8 pnum); +INT32 P_GetLocalPlayerNumForPlayer(const player_t *player); boolean P_IsLocalPlayer(const player_t *player); boolean P_IsLocalPlayerNum(UINT8 pnum); boolean P_IsDisplayPlayer(const player_t *player); @@ -226,7 +227,9 @@ void P_PlayerThink(player_t *player); void P_PlayerAfterThink(player_t *player); void P_DoPlayerExit(player_t *player); void P_DoTimeOver(player_t *player); -//void P_NightserizePlayer(player_t *player, INT32 ptime); + +angle_t P_GetLocalAngle(player_t *player); +void P_ForceLocalAngle(player_t *player, angle_t angle); void P_InstaThrust(mobj_t *mo, angle_t angle, fixed_t move); fixed_t P_ReturnThrustX(mobj_t *mo, angle_t angle, fixed_t move); diff --git a/src/p_map.c b/src/p_map.c index f9d828b98..e51930bef 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -223,14 +223,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (!demo.playback || P_AnalogMove(object->player)) { - for (UINT8 j = 0; j <= splitscreen; ++j) - { - if (object->player == P_GetLocalPlayerForNum(j)) - { - localangle[j] = spring->angle; - break; - } - } + P_ForceLocalAngle(object->player, spring->angle); } } diff --git a/src/p_mobj.c b/src/p_mobj.c index 78a440c6f..fcc70ec8b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10783,14 +10783,7 @@ void P_AfterPlayerSpawn(INT32 playernum) mobj->old_z = mobj->z; mobj->old_angle = mobj->angle; - for (i = 0; i <= splitscreen; i++) - { - if (playernum == P_GetLocalPlayerNumForNum(i)) - { - localangle[i] = mobj->angle; - break; - } - } + P_ForceLocalAngle(p, mobj->angle); p->viewheight = 32<angle += delta; - for (UINT8 i = 0; i <= splitscreen; i++) + if (mo->player) { - if (mo->player == P_GetLocalPlayerForNum(i)) - { - localangle[i] += delta; - break; - } + angle_t localangle = P_GetLocalAngle(mo->player); + P_ForceLocalAngle(mo->player, localangle + delta); } } } diff --git a/src/p_saveg.c b/src/p_saveg.c index 1fb6c5aa8..0dcac2083 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2122,16 +2122,6 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) i = READUINT8(save->p); mobj->player = &players[i]; mobj->player->mo = mobj; - - // added for angle prediction - if (consoleplayer == i) - localangle[0] = mobj->angle; - else if (displayplayers[1] == i) - localangle[1] = mobj->angle; - else if (displayplayers[2] == i) - localangle[2] = mobj->angle; - else if (displayplayers[3] == i) - localangle[3] = mobj->angle; } if (diff & MD_MOVEDIR) mobj->movedir = READANGLE(save->p); diff --git a/src/p_spec.c b/src/p_spec.c index 424e07043..c8e36176a 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3559,14 +3559,7 @@ DoneSection2: if (!demo.playback || P_AnalogMove(player)) { - for (UINT8 j = 0; j <= splitscreen; ++j) - { - if (player == P_GetLocalPlayerForNum(j)) - { - localangle[j] = player->mo->angle; - break; - } - } + P_ForceLocalAngle(player, player->mo->angle); } if (!(lines[i].flags & ML_EFFECT4)) @@ -7517,22 +7510,16 @@ void T_Pusher(pusher_t *p) thing->player->pflags |= PF_JUMPED; thing->player->pflags |= PF_SLIDING; - thing->angle = R_PointToAngle2 (0, 0, xspeed<<(FRACBITS-PUSH_FACTOR), yspeed<<(FRACBITS-PUSH_FACTOR)); + thing->angle = R_PointToAngle2(0, 0, xspeed<<(FRACBITS-PUSH_FACTOR), yspeed<<(FRACBITS-PUSH_FACTOR)); if (!demo.playback || P_AnalogMove(thing->player)) { - for (UINT8 i = 0; i <= splitscreen; ++i) - { - if (thing->player == P_GetLocalPlayerForNum(i)) - { - if (thing->angle - localangle[i] > ANGLE_180) - localangle[i] -= (localangle[i] - thing->angle) / 8; - else - localangle[i] += (thing->angle - localangle[i]) / 8; + angle_t angle = P_GetLocalAngle(thing->player); - break; - } - } + if (thing->angle - angle > ANGLE_180) + P_ForceLocalAngle(thing->player, angle - (angle - thing->angle) / 8); + else + P_ForceLocalAngle(thing->player, angle + (thing->angle - angle) / 8); } } diff --git a/src/p_telept.c b/src/p_telept.c index b7bdb0346..20f53d396 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -65,14 +65,7 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, thing->reactiontime = TICRATE/2; // don't move for about half a second // absolute angle position - for (i = 0; i <= splitscreen; i++) - { - if (thing == P_GetLocalPlayerForNum(i)->mo) - { - localangle[i] = angle; - break; - } - } + P_ForceLocalAngle(thing->player, angle); // move chasecam at new player location for (i = 0; i <= splitscreen; i++) @@ -151,18 +144,18 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle thing->reactiontime = TICRATE/2; // don't move for about half a second // absolute angle position + P_ForceLocalAngle(thing->player, angle); + // move chasecam at new player location for (i = 0; i <= splitscreen; i++) { if (thing->player != &players[displayplayers[i]]) continue; - localangle[i] = angle; if (camera[i].chase) P_ResetCamera(thing->player, &camera[i]); R_ResetViewInterpolation(i + 1); - break; } // don't run in place after a teleport diff --git a/src/p_user.c b/src/p_user.c index e42411160..ffe4d0e67 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -996,6 +996,19 @@ INT32 P_GetLocalPlayerNumForNum(UINT8 pnum) return (pnum == 0 ? consoleplayer : displayplayers[pnum]); } +INT32 P_GetLocalPlayerNumForPlayer(const player_t *player) +{ + for (UINT8 i = 0; i <= splitscreen; i++) + { + if (player == P_GetLocalPlayerForNum(i)) + { + return i; + } + } + + return -1; +} + // // P_IsLocalPlayer // @@ -2603,15 +2616,7 @@ static void P_DoZoomTube(player_t *player) if (player->mo->tracer) { player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, player->mo->tracer->x, player->mo->tracer->y); - - for (UINT8 i = 0; i <= splitscreen; i++) - { - if (player == P_GetLocalPlayerForNum(i)) - { - localangle[i] = player->mo->angle; - break; - } - } + P_ForceLocalAngle(player, player->mo->angle); } } @@ -2797,14 +2802,7 @@ void P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target if (source->player) { - for (UINT8 i = 0; i <= splitscreen; i++) - { - if (source->player == P_GetLocalPlayerForNum(i)) - { - localangle[i] = source->angle; - break; - } - } + P_ForceLocalAngle(source->player, source->angle); } // change slope @@ -5200,14 +5198,8 @@ void P_PlayerAfterThink(player_t *player) player->mo->tracer->target->health += cmd->sidemove; player->mo->angle += cmd->sidemove << ANGLETOFINESHIFT; // 2048 --> ANGLE_MAX - for (i = 0; i <= splitscreen; i++) - { - if (player == P_GetLocalPlayerForNum(i)) - { - localangle[i] = player->mo->angle; // Adjust the local control angle. - break; - } - } + // Adjust the local control angle. + P_ForceLocalAngle(player, player->mo->angle); } } @@ -5246,3 +5238,34 @@ void P_PlayerAfterThink(player_t *player) K_KartPlayerAfterThink(player); } + +angle_t P_GetLocalAngle(player_t *player) +{ + // this function is from vanilla srb2. can you tell? + // (hint: they have separate variables for all of this shit instead of arrays) + UINT8 i; + + for (i = 0; i <= splitscreen; i++) + { + if (player == &players[displayplayers[i]]) + return localangle[i]; + } + + return 0; +} + +void P_ForceLocalAngle(player_t *player, angle_t angle) +{ + UINT8 i; + + angle = angle & ~UINT16_MAX; + + for (i = 0; i <= splitscreen; i++) + { + if (player == &players[displayplayers[i]]) + { + localangle[i] = angle; + } + } +} + From d188839d0bf55d57bbde138b9e9fbf5cfb4f6380 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Nov 2025 10:08:20 +0100 Subject: [PATCH 08/11] move R_QuickCamDist to r_main also mark it with PUREFUNC and R_QuickDist with FUNCMATH, so compiler may optimze it more agressively --- src/r_main.h | 20 ++++++++++++++++++++ src/r_things.h | 20 -------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/r_main.h b/src/r_main.h index 04c996365..36c8756f8 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -150,6 +150,26 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); #define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y) #define R_PointToDist2(px2, py2, px1, py1) FixedHypot((px1) - (px2), (py1) - (py2)) +FUNCMATH FUNCINLINE static ATTRINLINE fixed_t R_QuickDist(fixed_t x1, fixed_t y1, fixed_t x, fixed_t y) +{ + const fixed_t absx = abs(x - x1); + const fixed_t absy = abs(y - y1); +#ifdef __cplusplus + return std::max(absx, absy); +#else + return max(absx, absy); +#endif +} + +// Takes 2 fixed-point coordinates, returns "distance" between them and camera, +// as an fixed-point integer. +// It is very rough, tho it is used only for optimizing out unnecessary +// interpolation, so it is kinda ok on big distances. +FUNCINLINE static ATTRINLINE PUREFUNC fixed_t R_QuickCamDist(fixed_t x, fixed_t y) +{ + return R_QuickDist(viewx, viewy, x, y); +} + line_t *R_GetFFloorLine(const line_t *line, const ffloor_t *pfloor, const sector_t *sector); side_t *R_GetFFloorSide(const line_t *line, const ffloor_t *pfloor, const sector_t *sector); diff --git a/src/r_things.h b/src/r_things.h index b9c012b79..c8195891a 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -35,26 +35,6 @@ extern "C" { #define FEETADJUST (4<(absx, absy); -#else - return max(absx, absy); -#endif -} - -// Takes 2 fixed-point coordinates, returns "distance" between them and camera, -// as an fixed-point integer. -// It is very rough, tho it is used only for optimizing out unnecessary -// interpolation, so it is kinda ok on big distances. -FUNCINLINE static ATTRINLINE fixed_t R_QuickCamDist(fixed_t x, fixed_t y) -{ - return R_QuickDist(viewx, viewy, x, y); -} - // Constant arrays used for psprite clipping // and initializing clipping. extern INT16 *negonearray; From 04379520276ebdcf1af61a7f5091fb91c84d03d3 Mon Sep 17 00:00:00 2001 From: Alug Date: Wed, 26 Nov 2025 10:08:53 +0100 Subject: [PATCH 09/11] mark checkcoord as const --- src/r_bsp.cpp | 2 +- src/r_bsp.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 5a0a21d76..e680783dd 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -500,7 +500,7 @@ clipsolid: // 0 | 0 | 1 | 2 // 1 | 4 | 5 | 6 // 2 | 8 | 9 | A -INT32 checkcoord[12][4] = +const INT32 checkcoord[12][4] = { {3, 0, 2, 1}, {3, 0, 2, 0}, diff --git a/src/r_bsp.h b/src/r_bsp.h index b9e4e291d..1d00704f7 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -34,7 +34,7 @@ extern portal_t *g_portal; // is curline a portal seg? // drawsegs are allocated on the fly... see r_segs.c -extern INT32 checkcoord[12][4]; +extern const INT32 checkcoord[12][4]; extern drawseg_t *curdrawsegs; extern drawseg_t *drawsegs; From 4d9c345202ef01eec0f3ca6040d9418f4d36f46a Mon Sep 17 00:00:00 2001 From: Indev Date: Wed, 26 Nov 2025 22:44:57 +0300 Subject: [PATCH 10/11] Add support for emotes in console chat mode (and support for emotes in console in general) --- src/console.c | 27 ++++++++++++++++++++++++++- src/hu_stuff.c | 24 ++++++++++++++++-------- src/m_emotes.cpp | 9 ++------- src/m_emotes.h | 4 +++- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/src/console.c b/src/console.c index 6f9579bef..e9f4c80ff 100644 --- a/src/console.c +++ b/src/console.c @@ -33,6 +33,8 @@ #include "d_main.h" #include "m_menu.h" #include "m_textinput.h" +#include "m_emotes.h" +#include "i_time.h" #include "filesrch.h" #ifdef HWRENDER @@ -1453,7 +1455,18 @@ static void CON_DrawHudlines(void) } if (c >= con_width) break; - if (*p < HU_FONTSTART) + + int emotelen; + emote_t *emote; + + if ((emote = M_VerifyEmote((const char *)p, &emotelen))) + { + M_DrawScaledEmote(x<= con_width) break; + + int emotelen; + emote_t *emote; + + if ((emote = M_VerifyEmote((const char *)p, &emotelen))) + { + M_DrawScaledEmote(x<= HU_FONTSTART) + if ((emote = M_VerifyEmote(w_chat_buf+i, &emotelen))) + { + HU_DrawScaledEmote((HU_INPUTX + c)<= HU_FONTSTART) //Hurdler: isn't it better like that? { //charwidth = hu_font[w_chat[i]-HU_FONTSTART]->width * con_scalefactor; V_DrawCharacter(HU_INPUTX + c, y, w_chat_buf[i] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value); @@ -2119,6 +2120,13 @@ static void HU_DrawChat_Old(void) ++i; + if (w_chat.cursor == i && hu_tick < 4) + { + INT32 cursorx = (HU_INPUTX+c+charwidth < vid.width) ? (HU_INPUTX + c + charwidth) : (HU_INPUTX); // we may have to go down. + INT32 cursory = (cursorx != HU_INPUTX) ? (y) : (y+charheight); + V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value); + } + c += charwidth; if (c >= vid.width) { diff --git a/src/m_emotes.cpp b/src/m_emotes.cpp index c4dc05ba1..3e55ef788 100644 --- a/src/m_emotes.cpp +++ b/src/m_emotes.cpp @@ -248,7 +248,7 @@ emote_t *M_VerifyEmote(const char *name, int *emotelen) return match; } -void M_DrawEmote(INT32 x, INT32 y, emote_t *emote, tic_t anim, INT32 flags) +void M_DrawScaledEmote(fixed_t x, fixed_t y, fixed_t scale, emote_t *emote, tic_t anim, INT32 flags) { if (emote->numframes == 0) return; @@ -258,13 +258,8 @@ void M_DrawEmote(INT32 x, INT32 y, emote_t *emote, tic_t anim, INT32 flags) const int CHARHEIGHT = 6; - fixed_t scale = FRACUNIT; - - x *= FRACUNIT; - y *= FRACUNIT; - if (emotepatch->width > EMOTEWIDTH) - scale = (FRACUNIT/emotepatch->width)*EMOTEWIDTH; + scale = FixedMul(scale, (FRACUNIT/emotepatch->width)*EMOTEWIDTH); else if (emotepatch->width < EMOTEWIDTH) x += (EMOTEWIDTH-emotepatch->width)*FRACUNIT/2; diff --git a/src/m_emotes.h b/src/m_emotes.h index 9921e4444..efe3d69a2 100644 --- a/src/m_emotes.h +++ b/src/m_emotes.h @@ -17,6 +17,7 @@ extern "C" { #endif #include "doomdef.h" +#include "m_fixed.h" #include "command.h" extern consvar_t cv_emotes; @@ -50,7 +51,8 @@ emote_t *M_VerifyEmote(const char *name, int *emotelen); // Draw the emote, anim should be some kind of timer ticking every game tic // for animated emotes -void M_DrawEmote(INT32 x, INT32 y, emote_t *emote, tic_t anim, INT32 flags); +#define M_DrawEmote(x, y, emote, anim, flags) M_DrawScaledEmote((x)< Date: Wed, 26 Nov 2025 22:56:04 +0300 Subject: [PATCH 11/11] Discordify emotes a bit more :chonkbunckle: - When autocompleting emote with enter, don't send it immediately - Don't autocomplete after typing 1 character after : (allows text emotes like ":c") --- src/hu_stuff.c | 8 ++++---- src/m_textinput.c | 15 +++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4e55a0630..4fce662ab 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1380,9 +1380,9 @@ boolean HU_Responder(event_t *ev) && ev->data1 != gamecontrol[0][gc_talkkey][1])) return false; - M_TextInputHandleEmotes(&w_chat, c, &emote_autocomplete); - - if (c == KEY_ENTER) + if (M_TextInputHandleEmotes(&w_chat, c, &emote_autocomplete)) + ; // Do nothing + else if (c == KEY_ENTER) { chat_on = false; chat_scrollmedown = true; // you hit enter, so you might wanna autoscroll to see what you just sent. :) @@ -1911,7 +1911,7 @@ static void HU_DrawChat(void) } } - if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 0)) + if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 1)) { emote_t *suggest; int skip = 0; diff --git a/src/m_textinput.c b/src/m_textinput.c index 2e88948a6..7d050dfc7 100644 --- a/src/m_textinput.c +++ b/src/m_textinput.c @@ -435,10 +435,10 @@ static int M_TextInputEmoteStart(textinput_t *input) return emotestart; } -static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *autocomplete) +static boolean M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *autocomplete) { if (input->cursor == 0) - return; + return false; // If we're in "autocomplete" state, delete ':' for latest autocompleted emote if (autocomplete->complete[0]) @@ -457,8 +457,8 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a int emotestart = autocomplete->emotestart; // No emote - no autocomplete - if (emotestart == -1 || (size_t)emotestart == input->cursor) - return; + if (emotestart == -1 || input->cursor - emotestart < 2) + return false; strlcpy(autocomplete->complete, &input->buffer[emotestart], input->cursor-emotestart+1); } @@ -476,7 +476,7 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a { // Clear autocompletion state autocomplete->complete[0] = 0; - return; + return false; } } @@ -488,6 +488,8 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a M_TextInputAddString(input, completed->name); M_TextInputAddChar(input, ':'); + + return true; } boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplete_t *autocomplete) @@ -503,7 +505,8 @@ boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplet if (key == '\t' || (autocomplete->complete[0] == 0 && key == KEY_ENTER)) { - M_TextInputCompleteEmote(input, autocomplete); + if (M_TextInputCompleteEmote(input, autocomplete) && key == KEY_ENTER) // Don't send message if we've autocompleted an emote + ret = true; } else {