diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 8cb038251..8efc2a1cd 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -3449,7 +3449,7 @@ void CL_ClearPlayer(INT32 playernum) if (players[playernum].mo) { // Don't leave a NiGHTS ghost! - if (UNLIKELY((players[playernum].pflags & PF_NIGHTSMODE) && players[playernum].mo->tracer)) + if (nightsplayer(&players[playernum]) && players[playernum].mo->tracer) P_RemoveMobj(players[playernum].mo->tracer); P_RemoveMobj(players[playernum].mo); } diff --git a/src/d_main.c b/src/d_main.c index 85e1242ac..2150b1e72 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1353,20 +1353,24 @@ static void IdentifyVersion(void) // // search for maps // -static void D_CheckMapReplacements(boolean checkreplaced) +static void D_CheckMapReplacements(boolean pwad) { INT32 i; char *name; UINT16 wadnum; lumpinfo_t *lumpinfo; + size_t numfiles; - for (wadnum = 0; wadnum < mainwads; wadnum++) + wadnum = pwad ? (mainwads+1) : 0; + numfiles = pwad ? numwadfiles : mainwads; + + for (; wadnum < numfiles; wadnum++) { lumpinfo = wadfiles[wadnum]->lumpinfo; for (i = 0; i < wadfiles[wadnum]->numlumps; i++, lumpinfo++) { name = lumpinfo->name; - P_CheckMapReplacements(name, checkreplaced); + P_CheckMapReplacements(name, pwad); } } } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9d7d697cd..fd08830f0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -930,8 +930,6 @@ void D_RegisterClientCommands(void) COM_AddCommand("displayplayer", Command_Displayplayer_f); - CV_RegisterVar(&cv_audbuffersize); - CV_RegisterVar(&cv_palette); CV_RegisterVar(&cv_palettenum); @@ -1032,6 +1030,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_midimusicvolume); #endif CV_RegisterVar(&cv_numChannels); + CV_RegisterVar(&cv_audbuffersize); #ifdef HAVE_OPENMPT CV_RegisterVar(&cv_modfilter); diff --git a/src/g_demo.c b/src/g_demo.c index 1123aed69..17ed25d85 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -716,7 +716,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) if (!(demoflags & DF_GHOST)) return; // No ghost data to write. - if (ghost->player && ghost->player->pflags & PF_NIGHTSMODE && ghost->tracer) + if (ghost->player && nightsplayer(ghost->player) && ghost->tracer) { // We're talking about the NiGHTS thing, not the normal platforming thing! ziptic |= GZT_NIGHTS; @@ -979,7 +979,7 @@ void G_ConsGhostTic(INT32 playernum) if (ziptic & GZT_NIGHTS) { - if (!testmo || !testmo->player || !(testmo->player->pflags & PF_NIGHTSMODE) || !testmo->tracer) + if (!testmo || !testmo->player || !nightsplayer(testmo->player) || !testmo->tracer) nightsfail = true; else testmo = testmo->tracer; diff --git a/src/g_game.h b/src/g_game.h index 4f46ef89d..038bc68df 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -119,6 +119,7 @@ extern consvar_t cv_gravstretch; extern consvar_t cv_sloperoll; extern consvar_t cv_sliptideroll; extern consvar_t cv_stairjank; +extern consvar_t cv_stairjanksfx; extern consvar_t cv_slamsound; extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; @@ -227,10 +228,11 @@ void G_SaveGameData(boolean force); void G_SaveGame(UINT32 slot); -#define G_GametypeHasTeams() (G_IsGameType(GT_TEAMMATCH) || G_IsGameType(GT_CTF)) +#define G_RaceGametype() (G_IsGameType(GT_RACE)) #define G_BattleGametype() (G_IsGameType(GT_MATCH)) -#define G_RaceGametype() (G_IsGameType(GT_RACE)) -#define G_TagGametype() (G_IsGameType(GT_TAG) || G_IsGameType(GT_HIDEANDSEEK)) + +#define G_GametypeHasTeams() (UNLIKELY(G_IsGameType(GT_TEAMMATCH) || G_IsGameType(GT_CTF))) +#define G_TagGametype() (UNLIKELY(G_IsGameType(GT_TAG) || G_IsGameType(GT_HIDEANDSEEK))) FUNCINLINE static ATTRINLINE boolean G_IsGameType(int type) { diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 8bf7f7375..9b1699029 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -183,6 +183,7 @@ static int comparePolygons(const void *p1, const void *p2) UINT32 downloaded1 = poly1->texture ? poly1->texture->downloaded : 0; // there should be a opengl texture name here, usable for comparisons UINT32 downloaded2 = poly2->texture ? poly2->texture->downloaded : 0; + diff64 = downloaded1 - downloaded2; if (diff64 != 0) return diff64; diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 642fdfec7..c01c59afc 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -84,11 +84,6 @@ float gl_viewsin = 0.0f, gl_viewcos = 0.0f; static float gl_viewludsin, gl_viewludcos; static angle_t gl_aimingangle; -static float yaw = 0.0f; -static float inv_yaw = 0.0f; -static float cos_inv_yaw = 0.0f; -static float sin_inv_yaw = 0.0f; - static constexpr float deg2radians = (M_PIf / 180.0f); seg_t *gl_curline = NULL; @@ -4764,9 +4759,9 @@ static void HWR_ProjectSprite(mobj_t *thing) // if the sprite is out of our view, dont need to draw it X) if (!gld_SphereInFrustum( - (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, + (FixedToFloat(interp.x)) + gl_viewsin * (x1 + x2) / 2.0f, FixedToFloat(interp.z) + (y1 + y2) / 2.0f, - FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + FixedToFloat(interp.y) - (-gl_viewcos) * (x1 + x2) / 2.0f, //1.5 == sqrt(2) + small delta for MF_FOREGROUND std::max(FixedToFloat(spr_width) * spritexscale, FixedToFloat(spr_height) * spriteyscale) / 2.0f * 1.5f)) @@ -4984,9 +4979,9 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) y2 *= thing_scale; if (!gld_SphereInFrustum( - (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, + (FixedToFloat(interp.x)) + gl_viewsin * (x1 + x2) / 2.0f, FixedToFloat(interp.z) + (y1 + y2) / 2.0f, - FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + FixedToFloat(interp.y) - (-gl_viewcos) * (x1 + x2) / 2.0f, //1.5 == sqrt(2) + small delta for MF_FOREGROUND std::max(FixedToFloat(spr_width) * thing_scale, FixedToFloat(spr_height) * thing_scale) / 2.0f * 1.5f)) @@ -5116,24 +5111,22 @@ void HWR_BuildSkyDome(void) int c, r; signed char yflip; static constexpr int row_count = 4; - int col_count = 4; + static constexpr int col_count = (4 * 16); float delta; gl_sky_t *sky = &gl_sky; gl_skyvertex_t *vertex_p; const texture_t *texture = textures[texturetranslation[skytexture]]; - col_count *= 16; - if ((sky->columns != col_count) || (sky->rows != row_count)) HWR_ClearSkyDome(); sky->columns = col_count; sky->rows = row_count; - sky->vertex_count = 2 * sky->rows * (sky->columns * 2 + 2) + sky->columns * 2; + sky->vertex_count = 2 * row_count * (col_count * 2 + 2) + col_count * 2; if (!sky->loops) - sky->loops = static_cast(malloc((sky->rows * 2 + 2) * sizeof(sky->loops[0]))); + sky->loops = static_cast(malloc((row_count * 2 + 2) * sizeof(sky->loops[0]))); // create vertex array if (!sky->data) @@ -5397,12 +5390,6 @@ void HWR_SetTransform(float fpov) HWR_SetTransformAiming(&atransform); atransform.angley = static_cast(viewangle >> ANGLETOFINESHIFT)*(FINEDEGREE); - yaw = 270.0f - atransform.angley; - inv_yaw = 180.0f - yaw; - const float inv_yaw_radians = inv_yaw * deg2radians; - cos_inv_yaw = cosf(inv_yaw_radians); - sin_inv_yaw = sinf(inv_yaw_radians); - // only needed for sprite billboarding if (cv_glspritebillboarding.value && !cv_glshearing.value) { @@ -5540,7 +5527,8 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, int stencil_level, bool if constexpr (Type == RenderViewpointType::kPortal) { - gl_collect_skywalls = (allow_portals && !rootportal && portallist.base && (!skyboxmo[0] || !cv_skybox.value)); // if portals have been drawn in the main view, then render skywalls differently + // if portals have been drawn in the main view, then render skywalls differently + gl_collect_skywalls = (allow_portals && !rootportal && portallist.base && (!skyboxmo[0] || !cv_skybox.value)); // HAYA: Save the old portal state, and turn portals off while normally rendering the BSP tree. // This fixes specific effects not working, such as horizon lines. diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 071e67f03..aff722773 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2490,7 +2490,7 @@ void GL_RenderSkyDome(gl_sky_t *sky) GL_Shader_SetUniforms(NULL, NULL, NULL, NULL); // Build the sky dome! Yes! - if (sky->rebuild) + if (sky->rebuild || !sky->vbo) { // delete VBO when already exists if (sky->vbo) @@ -3208,8 +3208,8 @@ void GL_SetTransform(FTransform *stransform) { float dy = stransform->viewaiming * 2; - if (stransform->fliptype == TRANSFORM_FLIP - || stransform->fliptype == TRANSFORM_MIRRORFLIP) + if (stransform->fliptype == TRANSFORM_FLIP || + stransform->fliptype == TRANSFORM_MIRRORFLIP) dy *= -1.0f; pglTranslatef(0.0f, -dy/BASEVIDHEIGHT, 0.0f); diff --git a/src/k_hud.c b/src/k_hud.c index 0deb8f0f5..3dd36c95d 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -4576,7 +4576,11 @@ static void K_drawCheckpointDebugger(void) else V_DrawString(8, 184, 0, va("Checkpoint: %d / %d (Skip: %d)", stplyr->starpostnum, numstarposts, ((numstarposts/2) + stplyr->starpostnum))); - V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", stplyr->kartstuff[k_prevcheck], stplyr->kartstuff[k_nextcheck])); + // really gnarly hack + const INT32 prevcheck = (stprevnextchecks[0] != INT32_MAX) ? stprevnextchecks[0]: stplyr->kartstuff[k_prevcheck]; + const INT32 nextcheck = (stprevnextchecks[1] != INT32_MAX) ? stprevnextchecks[1]: stplyr->kartstuff[k_nextcheck]; + + V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", prevcheck, nextcheck)); } // determines if gametype info (laps/bumpers) should be hidden diff --git a/src/k_kart.c b/src/k_kart.c index eb58a7b62..39961c1a9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -67,7 +67,8 @@ static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2, consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_stairjank = {"stairjank", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_stairjank = {"stairjank", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_stairjanksfx = {"stairjanksfx", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //hardcode saltyhop mhhm static void saltyhop_onchange(void); @@ -4724,11 +4725,7 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(orbit->target) && orbit->target->player) -#else - if (orbit->target && orbit->target->player) -#endif + if (!P_MobjWasRemovedCompat(orbit->target) && orbit->target->player) { INT32 num = 0; @@ -4745,11 +4742,7 @@ void K_RepairOrbitChain(mobj_t *orbit) prev->movedir = num; } -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(orbit->target)) -#else - if (orbit->target) -#endif + if (!P_MobjWasRemovedCompat(orbit->target)) orbit->target->player->kartstuff[k_itemamount] = num; } } @@ -4896,7 +4889,7 @@ static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z // Move the hnext chain! static void K_MoveHeldObjects(player_t *player) { - if (!player->mo) + if (P_MobjWasRemovedCompat(player->mo)) return; if (!player->mo->hnext) @@ -6219,6 +6212,64 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_brakedrift] = 0; } +INT32 stprevnextchecks[2] = {INT32_MAX, INT32_MAX}; // there wont be any map this big, wont there?..... + +// K_KartUpdatePosition has a bug where whatever player comes last in the players array +// gets its distance calculations applied twice +// since we cannot fix this due to compat concerns (kartstuff is exposed after all) +// we gotta do this shit hack to atleast fix the debugcheckpoint display +static void K_KartUpdatePositionDebugHack(player_t *player, player_t *otherplayer) +{ + mobj_t *mo; + fixed_t pmo; + fixed_t ppcd, pncd; + + // dont need this crap + if (!cv_kartdebugcheckpoint.value) + return; + + // not checking against ourselves + if (player != otherplayer) + return; + + // dont care if its not first displayplayer + // since this is only used for the debug display + if (player != &players[displayplayers[0]]) + return; + + ppcd = pncd = 0; + stprevnextchecks[0] = stprevnextchecks[1] = 0; + + // This checks every thing on the map, and looks for MT_BOSS3WAYPOINT (the thing we're using for checkpoint wp's, for now) + for (mo = waypointcap; mo != NULL; mo = mo->tracer) + { + const boolean isprevcheckpointp = mo->health == player->starpostnum; + const boolean isnextcheckpointp = mo->health == (player->starpostnum + 1); + + if ((isprevcheckpointp || isnextcheckpointp) && (!mo->movecount || mo->movecount == player->laps+1)) + { + pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x, + mo->y - player->mo->y), + mo->z - player->mo->z) / FRACUNIT; + + if (isprevcheckpointp) + { + stprevnextchecks[0] += pmo; + ppcd++; + } + + if (isnextcheckpointp) + { + stprevnextchecks[1] += pmo; + pncd++; + } + } + } + + if (ppcd > 1) stprevnextchecks[0] /= ppcd; + if (pncd > 1) stprevnextchecks[1] /= pncd; +} + // // K_KartUpdatePosition // @@ -6230,6 +6281,9 @@ void K_KartUpdatePosition(player_t *player) fixed_t pmo, imo; mobj_t *mo; + // always reset this + stprevnextchecks[0] = stprevnextchecks[1] = INT32_MAX; + if (player->spectator || !player->mo) return; @@ -6242,11 +6296,12 @@ void K_KartUpdatePosition(player_t *player) if (G_RaceGametype()) { - if ((((players[i].starpostnum) + (numstarposts + 1) * players[i].laps) > - ((player->starpostnum) + (numstarposts + 1) * player->laps))) + const INT32 iplayerlaps = (players[i].starpostnum + (numstarposts + 1) * players[i].laps); + const INT32 pplayerlaps = (player->starpostnum + (numstarposts + 1) * player->laps); + + if (iplayerlaps > pplayerlaps) position++; - else if (((players[i].starpostnum) + (numstarposts+1)*players[i].laps) == - ((player->starpostnum) + (numstarposts+1)*player->laps)) + else if (iplayerlaps == pplayerlaps) { ppcd = pncd = ipcd = incd = 0; @@ -6329,6 +6384,9 @@ void K_KartUpdatePosition(player_t *player) if (players[i].starposttime < player->starposttime) position++; } + + // stupid hack + K_KartUpdatePositionDebugHack(player, &players[i]); } } else if (G_BattleGametype()) @@ -6598,7 +6656,7 @@ static void K_PlayerItemThink(player_t *player, boolean onground, boolean oldatt { mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_BANANA_SHIELD); - if (!mo) + if (P_MobjWasRemovedCompat(mo)) { player->kartstuff[k_itemamount] = moloop; break; @@ -6659,7 +6717,7 @@ static void K_PlayerItemThink(player_t *player, boolean onground, boolean oldatt newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_ORBINAUT_SHIELD); - if (!mo) + if (P_MobjWasRemovedCompat(mo)) { player->kartstuff[k_itemamount] = moloop; break; @@ -6702,7 +6760,7 @@ static void K_PlayerItemThink(player_t *player, boolean onground, boolean oldatt newangle = (player->mo->angle + ANGLE_157h) + FixedAngle(((360 / player->kartstuff[k_itemamount]) * moloop) << FRACBITS) + ANGLE_90; mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_JAWZ_SHIELD); - if (!mo) + if (P_MobjWasRemovedCompat(mo)) { player->kartstuff[k_itemamount] = moloop; break; diff --git a/src/k_kart.h b/src/k_kart.h index 9307ce273..4d81375cd 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -32,6 +32,8 @@ extern consvar_t cv_bananajitter; extern consvar_t cv_bananthrowroll; extern consvar_t cv_airsparks; +extern INT32 stprevnextchecks[2]; + boolean K_IsPlayerLosing(player_t *player); boolean K_IsPlayerWanted(player_t *player); INT32 K_KartGetItemOdds(UINT8 pos, SINT8 item, fixed_t mashed, boolean spbrush); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 6294a5ab7..b380945ab 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -65,6 +65,8 @@ static stringhook_t stringHooks[STRING_HOOK(MAX)]; bool hook_important = true; +#define NONMOHOOK ((mobjtype_t)-1) + // This will be indexed by hook id, the value of which fetches the registry. static int * hookRefs; static int nextid; @@ -296,7 +298,7 @@ struct Hook_State { INT32 status; /* return status to calling function */ void * userdata; int hook_type; - mobjtype_t mobj_type; /* < NUMMOBJTYPES if mobj hook */ + mobjtype_t mobj_type; /* != NONMOHOOK if mobj hook */ const char * string; /* used to fetch table, ran first if set */ int top; /* index of last argument passed to hook */ int id; /* id to fetch ref */ @@ -364,7 +366,7 @@ FUNCINLINE static ATTRINLINE boolean prepare_hook int hook_type ){ return init_hook_type(hook, default_status, - hook_type, NUMMOBJTYPES, NULL, + hook_type, NONMOHOOK, NULL, hookIds[hook_type].numHooks); } @@ -391,7 +393,7 @@ FUNCINLINE static ATTRINLINE boolean prepare_string_hook const char * string ){ if (init_hook_type(hook, default_status, - hook_type, NUMMOBJTYPES, string, + hook_type, NONMOHOOK, string, stringHooks[hook_type].ref)) { lua_pushstring(gL, string); @@ -407,7 +409,7 @@ FUNCINLINE static ATTRINLINE boolean prepare_hud_hook int hook_type ){ return init_hook_type(hook, 0, - hook_type, NUMMOBJTYPES, NULL, + hook_type, NONMOHOOK, NULL, hudHookIds[hook_type].numHooks); } @@ -528,10 +530,48 @@ static int call_string_hooks(Hook_State *hook) return calls; } +FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) +{ + static UINT8 seen = 0; // so we dont have to check all this shit constantly + int numCalls = call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); + + if (!seen && numCalls > 0 && mobj_type == MT_NULL && ( + hook->hook_type == MOBJ_HOOK(MobjThinker ) + || hook->hook_type == MOBJ_HOOK(MobjCollide ) + || hook->hook_type == MOBJ_HOOK(MobjMoveCollide) + || hook->hook_type == MOBJ_HOOK(MobjFuse ) + || hook->hook_type == MOBJ_HOOK(MobjThinker ) + || hook->hook_type == MOBJ_HOOK(BossThinker ) + )) + { + seen = 1; + CONS_Alert( + CONS_WARNING, "%s\n", va( + "%s hooks not attached to a specific mobj type may cause performance issues!", + mobjHookNames[hook->hook_type]) + ); + + // print which script triggered it, ty indev <3 + for (int k = 0; k < mobjHookIds[mobj_type][hook->hook_type].numHooks; ++k) + { + lua_getref(gL, hookRefs[mobjHookIds[mobj_type][hook->hook_type].ids[k].id]); + + lua_Debug ar; + lua_getinfo(gL, ">S", &ar); + + CONS_Printf("%s:%d\n", ar.short_src, ar.linedefined); + } + } + + return numCalls; +} + +/* FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) { return call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); } +*/ static int call_hooks ( @@ -547,11 +587,13 @@ static int call_hooks { calls += call_string_hooks(hook); } - else if (hook->mobj_type < NUMMOBJTYPES) + //else if (hook->mobj_type > 0) + else if (hook->mobj_type != NONMOHOOK) { /* call generic mobj hooks first */ calls += call_mobj_type_hooks(hook, MT_NULL); - calls += call_mobj_type_hooks(hook, hook->mobj_type); + if (hook->mobj_type < NUMMOBJTYPES) + calls += call_mobj_type_hooks(hook, hook->mobj_type); ps_lua_mobjhooks.value.i += calls; } else diff --git a/src/m_cheat.c b/src/m_cheat.c index 783ff3bcb..0360ecc56 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -766,7 +766,7 @@ boolean OP_FreezeObjectplace(void) if (!objectplacing) return false; - if ((maptol & TOL_NIGHTS) && (players[consoleplayer].pflags & PF_NIGHTSMODE)) + if (nightsmode && nightsplayer(&players[consoleplayer])) return false; return true; @@ -1049,7 +1049,7 @@ void Command_ObjectPlace_f(void) { objectplacing = true; - if ((players[0].pflags & PF_NIGHTSMODE)) + if (nightsplayer(&players[0])) return; if (!COM_CheckParm("-silent")) @@ -1120,7 +1120,7 @@ void Command_ObjectPlace_f(void) // Don't touch the NiGHTS Objectplace stuff. // ... or if the mo mysteriously vanished. - if (!players[0].mo || (players[0].pflags & PF_NIGHTSMODE)) + if (!players[0].mo || nightsplayer(&players[0])) return; // If still in dummy state, get out of it. diff --git a/src/m_menu.c b/src/m_menu.c index 38b5e2875..bc7c47c42 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4247,6 +4247,14 @@ static boolean M_HandleReplayHutQuery(INT32 choice) char tmp[MAXREPLAYQUERY+1]; memcpy(tmp, replayqueryinput_buffer, MAXREPLAYQUERY+1); + Lock_search_state(); + if (!replaynamesloaded) + { + Unlock_search_state(); + return false; + } + Unlock_search_state(); + if (M_TextInputHandle(&replayqueryinput, choice)) { S_StartSound(NULL, sfx_menu1); diff --git a/src/m_menudefs.c b/src/m_menudefs.c index 7eecdb0f6..4da3c7ea7 100644 --- a/src/m_menudefs.c +++ b/src/m_menudefs.c @@ -1408,25 +1408,25 @@ static menuitem_t OP_ChatOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Chat Mode", &cv_consolechat, 5}, // nonetheless... {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Chat Box Width", &cv_chatwidth, 20}, + NULL, "Chat Box Width", &cv_chatwidth, 10}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Chat Box Height", &cv_chatheight, 30}, - {IT_STRING | IT_CVAR, NULL, "Chat Horizontal Offset", &cv_chat_xoffset, 40}, - {IT_STRING | IT_CVAR, NULL, "Chat Vertical Offset", &cv_chat_yoffset, 50}, + NULL, "Chat Box Height", &cv_chatheight, 15}, + {IT_STRING | IT_CVAR, NULL, "Chat Horizontal Offset", &cv_chat_xoffset, 20}, + {IT_STRING | IT_CVAR, NULL, "Chat Vertical Offset", &cv_chat_yoffset, 25}, - {IT_STRING | IT_CVAR, NULL, "Center Text in Chat", &cv_chatcentertext, 70}, - {IT_STRING | IT_CVAR, NULL, "Chat Background Tint", &cv_chatbacktint, 80}, - {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 90}, - {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 100}, - {IT_STRING | IT_CVAR, NULL, "Max Chat Messages", &cv_chatlogsize, 110}, - {IT_STRING | IT_CVAR, NULL, "Display Character Limit", &cv_chat_showlimit, 120}, + {IT_STRING | IT_CVAR, NULL, "Center Text in Chat", &cv_chatcentertext, 35}, + {IT_STRING | IT_CVAR, NULL, "Chat Background Tint", &cv_chatbacktint, 40}, + {IT_STRING | IT_CVAR, NULL, "Message Fadeout Time", &cv_chattime, 45}, + {IT_STRING | IT_CVAR, NULL, "Spam Protection", &cv_chatspamprotection, 50}, + {IT_STRING | IT_CVAR, NULL, "Max Chat Messages", &cv_chatlogsize, 55}, + {IT_STRING | IT_CVAR, NULL, "Display Character Limit", &cv_chat_showlimit, 60}, - {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 140}, // shows ping above the framerate if we want to. - {IT_STRING | IT_CVAR, NULL, "Ping display style", &cv_pingstyle, 150}, - {IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 160}, - {IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 170}, + {IT_STRING | IT_CVAR, NULL, "Local ping display", &cv_showping, 70}, // shows ping above the framerate if we want to. + {IT_STRING | IT_CVAR, NULL, "Ping display style", &cv_pingstyle, 75}, + {IT_STRING | IT_CVAR, NULL, "Ping measurement", &cv_pingmeasurement, 80}, + {IT_STRING | IT_CVAR, NULL, "Ping icon", &cv_pingicon, 85}, - {IT_STRING | IT_CVAR, NULL, "Show IP address in playerlist", &cv_shownodeip, 180}, + {IT_STRING | IT_CVAR, NULL, "Show IP address in playerlist", &cv_shownodeip, 90}, }; static const char* OP_ChatOptionsTooltips[] = @@ -1791,20 +1791,22 @@ static menuitem_t OP_PlayerDistortMenu[] = {IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 25}, {IT_STRING | IT_CVAR, NULL, "Stair Janking Effect", &cv_stairjank, 30}, - {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 35}, - {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 40}, + {IT_STRING | IT_CVAR, NULL, "Stair Janking Sound Effect", &cv_stairjanksfx, 35}, // idk if that should be here but i dont care atm - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 50}, - {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 55}, + {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 40}, + {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 45}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 65}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 70}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 75}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 80}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 85}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 55}, + {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 60}, - {IT_STRING | IT_CVAR, NULL, "Squishdance", &cv_squishdance, 95}, - {IT_STRING | IT_CVAR, NULL, "Squishdance Speed", &cv_squishdancespeed, 101}, // why is this offset by 6? idk cant remember lulul + {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 70}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 75}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 80}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 85}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 90}, + + {IT_STRING | IT_CVAR, NULL, "Squishdance", &cv_squishdance, 100}, + {IT_STRING | IT_CVAR, NULL, "Squishdance Speed", &cv_squishdancespeed, 106}, // why is this offset by 6? idk cant remember lulul }; static const char* OP_PlayerDistortTooltips[] = @@ -1814,6 +1816,7 @@ static const char* OP_PlayerDistortTooltips[] = "Distance object rotation should be visable.", "Player rotation when sliptiding.", "Slightly tilt the player when driving over stairs or small bumps.", + "Sound effect when driving over stairs or small bumps.", "Rotation of a player's boost trails and drift sparks.", "Should banans rotate when thrown?\nAnd should they stay rotated when on the ground?", "Player squash and stretch.", @@ -1834,6 +1837,7 @@ enum slrotatedist, sliptide, stairjank, + stairjanksfx, sparkrotate, bananrotat, stretchyplayer, @@ -2617,7 +2621,7 @@ menu_t OP_Player2CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player2CamOptionsMenu menu_t OP_Player3CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player3CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips); -menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30, OP_ChatOptionsTooltips); +menu_t OP_ChatOptionsDef = DEFAULTSCROLLSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 25, OP_ChatOptionsTooltips); menu_t OP_SoundAdvancedDef = DEFAULTSCROLLSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30, OP_SoundAdvancedTooltips); @@ -2742,6 +2746,15 @@ void PDistort_menu_Onchange(void) OP_PlayerDistortMenu[slrotatedist].status = IT_GRAYEDOUT; OP_PlayerDistortMenu[saltroll].status = IT_GRAYEDOUT; } + + if (cv_stairjank.value) + { + OP_PlayerDistortMenu[stairjanksfx].status = IT_STRING | IT_CVAR; + } + else + { + OP_PlayerDistortMenu[stairjanksfx].status = IT_GRAYEDOUT; + } } void Bird_menu_Onchange(void) diff --git a/src/p_enemy.c b/src/p_enemy.c index 1502f5ff3..f3fb1761c 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -250,7 +250,8 @@ boolean P_Move(mobj_t *actor, fixed_t speed) I_Assert(movedir < NUMDIRS); tryx = actor->x + FixedMul(speed*xspeed[movedir], actor->scale); - if (UNLIKELY(twodlevel || actor->flags2 & MF2_TWOD)) + + if (twodmo(actor)) tryy = actor->y; else tryy = actor->y + FixedMul(speed*yspeed[movedir], actor->scale); @@ -328,7 +329,7 @@ void P_NewChaseDir(mobj_t *actor) else d[1] = DI_NODIR; - if (UNLIKELY(twodlevel || actor->flags2 & MF2_TWOD)) + if (twodmo(actor)) d[2] = DI_NODIR; if (deltay < -FixedMul(10*FRACUNIT, actor->scale)) d[2] = DI_SOUTH; @@ -2762,10 +2763,10 @@ void A_Invincibility(void *thing) { S_StopMusic(); - if (UNLIKELY(mariomode)) + if (mariomode) G_GhostAddColor((INT32) (player - players), GHC_INVINCIBLE); - S_ChangeMusicInternal((UNLIKELY(mariomode)) ? "minvnc" : "invinc", false); + S_ChangeMusicInternal(mariomode ? "minvnc" : "invinc", false); } } @@ -4359,7 +4360,7 @@ void A_MouseThink(void *thing) || (actor->eflags & MFE_VERTICALFLIP && actor->z + actor->height == actor->ceilingz)) && !actor->reactiontime) { - if (UNLIKELY(twodlevel || actor->flags2 & MF2_TWOD)) + if (twodmo(actor)) { if (P_RandomChance(FRACUNIT/2)) actor->angle += ANGLE_180; diff --git a/src/p_inter.c b/src/p_inter.c index a2948d01b..856050959 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -589,7 +589,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) special->momx = special->momy = special->momz = 0; P_GivePlayerRings(player, 1); - if (UNLIKELY((maptol & TOL_NIGHTS) && special->type != MT_FLINGRING)) + if (nightsmode && special->type != MT_FLINGRING) P_DoNightsScore(player); break; @@ -601,7 +601,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) special->momx = special->momy = 0; P_GivePlayerRings(player, 1); - if (UNLIKELY((maptol & TOL_NIGHTS) && special->type != MT_FLINGCOIN)) + if (nightsmode && special->type != MT_FLINGCOIN) P_DoNightsScore(player); break; case MT_BLUEBALL: @@ -617,7 +617,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) else special->scalespeed = 4*FRACUNIT/5; - if (UNLIKELY(maptol & TOL_NIGHTS)) + if (nightsmode) P_DoNightsScore(player); break; case MT_AUTOPICKUP: @@ -831,7 +831,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) { S_StartSound(toucher, special->info->seesound); - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(player)) { player->bumpertime = TICRATE/2; if (special->threshold > 0) @@ -1131,7 +1131,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) S_StartSound(toucher, special->info->painsound); return; } - else if (UNLIKELY((player->pflags & PF_NIGHTSMODE) && (player->pflags & PF_DRILLING)) || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) + else if ((nightsplayer(player) && (player->pflags & PF_DRILLING)) || (player->pflags & (PF_JUMPED|PF_SPINNING|PF_GLIDING)) || player->powers[pw_invulnerability] || player->powers[pw_super]) // Do you possess the ability to subdue the object? { // Shatter the shield! @@ -1466,11 +1466,7 @@ static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *so { // SRB2kart // I wish I knew a better way to do this -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) -#else - if (target->target && target->target->player && target->target->player->mo) -#endif + if (!P_MobjWasRemovedCompat(target->target) && target->target->player && !P_MobjWasRemovedCompat(target->target->player->mo)) { if (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) target->target->player->kartstuff[k_eggmanheld] = 0; @@ -1483,11 +1479,7 @@ static void P_UpdateRemovedOrbital(mobj_t *target, mobj_t *inflictor, mobj_t *so { if (target->movedir != 0 && target->movedir < (UINT16)target->target->player->kartstuff[k_itemamount]) { -#ifndef COMPAT_VANILLA - if (!P_MobjWasRemoved(target->target->hnext)) -#else - if (target->target->hnext) -#endif + if (!P_MobjWasRemovedCompat(target->target->hnext)) K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; @@ -2245,11 +2237,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // well no clue but this may happen ig -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(target)) -#else - if (!target) -#endif + if (P_MobjWasRemovedCompat(target)) return false; if (target->health <= 0) @@ -2266,7 +2254,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; } - if (source && source->player && source->player->spectator) + if (!P_MobjWasRemovedCompat(source) && source->player && source->player->spectator) return false; } @@ -2360,11 +2348,11 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (player->exiting) return false; - if (UNLIKELY(!(target->player->pflags & (PF_NIGHTSMODE|PF_NIGHTSFALL)) && (maptol & TOL_NIGHTS))) + if (UNLIKELY(!(target->player->pflags & (PF_NIGHTSMODE|PF_NIGHTSFALL)) && nightsmode)) return false; } - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) // NiGHTS damage handling + if (nightsplayer(player)) // NiGHTS damage handling { if (!force) { @@ -2609,7 +2597,7 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) ns = FixedMul(((i*FRACUNIT)/16)+2*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 8*FRACUNIT, false); @@ -2633,7 +2621,7 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings) ns = FixedMul(momxy, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); ns = momz; @@ -2740,7 +2728,7 @@ void P_PlayerWeaponPanelBurst(player_t *player) ns = FixedMul(3*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa),ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 4*FRACUNIT, false); @@ -2824,7 +2812,7 @@ void P_PlayerWeaponAmmoBurst(player_t *player) ns = FixedMul(2*FRACUNIT, mo->scale); mo->momx = FixedMul(FINECOSINE(fa), ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) mo->momy = FixedMul(FINESINE(fa),ns); P_SetObjectMomZ(mo, 3*FRACUNIT, false); @@ -2940,7 +2928,7 @@ void P_PlayerEmeraldBurst(player_t *player, boolean toss) momx = FixedMul(FINECOSINE(fa), ns); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) momy = FixedMul(FINESINE(fa),ns); else momy = 0; @@ -2997,7 +2985,7 @@ void P_PlayerFlagBurst(player_t *player, boolean toss) { angle_t fa = P_RandomByte()*FINEANGLES/256; flag->momx = FixedMul(FINECOSINE(fa), FixedMul(6*FRACUNIT, player->mo->scale)); - if (LIKELY(!(twodlevel || (player->mo->flags2 & MF2_TWOD)))) + if (!twodmo(player->mo)) flag->momy = FixedMul(FINESINE(fa), FixedMul(6*FRACUNIT, player->mo->scale)); } diff --git a/src/p_local.h b/src/p_local.h index 383469bcc..1198335ec 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -59,8 +59,12 @@ extern "C" { #define AIMINGTOSLOPE(aiming) FINESINE((aiming>>ANGLETOFINESHIFT) & FINEMASK) -#define mariomode (maptol & TOL_MARIO) -#define twodlevel (maptol & TOL_2D) +// unused modes, kept for compat +#define nightsmode (UNLIKELY(maptol & TOL_NIGHTS)) +#define nightsplayer(player) (UNLIKELY((player)->pflags & PF_NIGHTSMODE)) +#define mariomode (UNLIKELY(maptol & TOL_MARIO)) +#define twodlevel (UNLIKELY(maptol & TOL_2D)) +#define twodmo(mobj) (UNLIKELY(twodlevel || ((mobj)->flags2 & MF2_TWOD))) // // P_TICK @@ -287,6 +291,17 @@ FUNCINLINE static ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj) return (!mobj || mobj->thinker.function != (actionf_p1)P_MobjThinker); } +// stupid, but kart allows mobjs that are marked to be removed to be accessed and modified in many cases +// so can only check if its not NULL in vanilla compat mode +FUNCINLINE static ATTRINLINE boolean P_MobjWasRemovedCompat(const mobj_t *mobj) +{ +#ifdef COMPAT_VANILLA + return (!mobj); +#else + return P_MobjWasRemoved(mobj); +#endif +} + fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect); fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect); #define P_GetFloorZ(mobj, sector, x, y, line) P_MobjFloorZ(mobj, sector, NULL, x, y, line, false, false) diff --git a/src/p_map.c b/src/p_map.c index ef4997293..ce43c2235 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -136,14 +136,17 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (object->eflags & MFE_SPRUNG) // Object was already sprung this tic return false; - // Spectators don't trigger springs. - if (object->player && object->player->spectator) - return false; - - if (UNLIKELY(object->player && (object->player->pflags & PF_NIGHTSMODE))) + if (object->player) { - /*Someone want to make these work like bumpers?*/ - return false; + // Spectators don't trigger springs. + if (object->player->spectator) + return false; + + if (nightsplayer(object->player)) + { + /*Someone want to make these work like bumpers?*/ + return false; + } } object->standingslope = NULL; // Okay, now we can't return - no launching off at silly angles for you. @@ -160,10 +163,15 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (spring->eflags & MFE_VERTICALFLIP) vertispeed *= -1; + // Vertical springs teleport you on TOP of them. if (vertispeed > 0) + { object->z = spring->z + spring->height + 1; + } else if (vertispeed < 0) + { object->z = spring->z - object->height - 1; + } else { // Horizontal springs teleport you in FRONT of them. @@ -215,7 +223,9 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (object->player) { if (spring->flags & MF_ENEMY) // Spring shells + { P_SetTarget(&spring->target, object); + } if (horizspeed && object->player->cmd.forwardmove == 0 && object->player->cmd.sidemove == 0) { @@ -312,13 +322,13 @@ static boolean PIT_CheckThing(mobj_t *thing) if (thing == tmthing) return true; - // Ignore... things. - if (!tmthing || P_MobjWasRemoved(thing)) - return true; - I_Assert(!P_MobjWasRemoved(tmthing)); I_Assert(!P_MobjWasRemoved(thing)); + // Ignore... things. + if (P_MobjWasRemovedCompat(tmthing) || P_MobjWasRemoved(thing)) + return true; + // Ignore spectators if ((tmthing->player && tmthing->player->spectator) || (thing->player && thing->player->spectator)) @@ -350,12 +360,13 @@ static boolean PIT_CheckThing(mobj_t *thing) } #endif - if (!(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE)) || (thing->flags & MF_NOCLIPTHING)) + if ((thing->flags & MF_NOCLIPTHING) || !(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE))) return true; // Don't collide with your buddies while NiGHTS-flying. - if (UNLIKELY(tmthing->player && thing->player && (maptol & TOL_NIGHTS) - && ((tmthing->player->pflags & PF_NIGHTSMODE) || (thing->player->pflags & PF_NIGHTSMODE)))) + if (nightsmode && + tmthing->player && thing->player && + (nightsplayer(tmthing->player) || nightsplayer(thing->player))) return true; blockdist = thing->radius + tmthing->radius; @@ -2594,20 +2605,41 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { /* use a shorter sound if not two tics have passed * since the last step */ - //S_ReducedVFXSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268), NULL); - //S_StartSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268)); + //S_ReducedVFXSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268), NULL); + //S_StartSound(thing, (thing->player->stairjank >= 16 ? sfx_s23b : sfx_s268)); // sound does not work out all that well for kart maps - // TODO: maybe spawn smol dust effect similar to RR? - /*if (!thing->player->stairjank) + // best i can do... + if (cv_stairjanksfx.value) + S_StartSoundAtVolume(thing, (thing->player->stairjank >= 8 ? sfx_s23b : sfx_s268), 192); // dont blast this at full volume lul + + //if (!thing->player->stairjank) { - mobj_t * spark = P_SpawnMobjFromMobj(thing, 0, 0, 0, MT_JANKSPARK); - spark->fuse = 9; - spark->cusval = K_StairJankFlip(ANGLE_90); + // 90 degrees to direction you're facing + fixed_t dirx = -FINESINE(thing->angle>>ANGLETOFINESHIFT); + fixed_t diry = FINECOSINE(thing->angle>>ANGLETOFINESHIFT); + fixed_t offset = thing->radius; + + if (leveltime % 8 < 4) + { + dirx = -dirx; + diry = -diry; + } + + mobj_t * spark = P_SpawnMobj(thing->x + FixedMul(dirx, offset), thing->y + FixedMul(diry, offset), thing->z, MT_DRIFTDUST); + spark->momx = FixedMul(dirx, FRACUNIT) + (6 + ((int)leveltime % 5))*(thing->momx)/10; + spark->momy = FixedMul(diry, FRACUNIT) + (6 + ((int)leveltime % 5))*(thing->momy)/10; + spark->momz = 5*FRACUNIT; + spark->scale = mapobjectscale/5; + spark->destscale = mapobjectscale/2; + spark->islocal = true; + //spark->fuse = 9; + spark->color = SKINCOLOR_WHITE; + //spark->cusval = K_StairJankFlip(ANGLE_90); P_SetTarget(&spark->target, thing); - P_SetTarget(&spark->owner, thing); - spark->renderflags |= RF_REDUCEVFX; - }*/ + //P_SetTarget(&spark->owner, thing); + //spark->renderflags |= RF_REDUCEVFX; + } thing->player->stairjank = 9; //thing->player->stairjank = 17; @@ -2663,7 +2695,7 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) if (tmfloorz - thing->z > maxstep) return false; // too big a step up } - } while(tryx != x || tryy != y); + } while (tryx != x || tryy != y); // the move is ok, // so link the thing into its new position @@ -3158,6 +3190,9 @@ void P_SlideMove(mobj_t *mo, boolean forceslide) INT16 hitcount = 0; boolean success = false; + if (P_MobjWasRemovedCompat(mo)) + return; + if (tmhitthing && mo->z + mo->height > tmhitthing->z && mo->z < tmhitthing->z + tmhitthing->height) { // Don't mess with your momentum if it's a pushable object. Pushables do their own crazy things already. @@ -3194,6 +3229,9 @@ void P_SlideMove(mobj_t *mo, boolean forceslide) bestslideline = NULL; retry: + if (P_MobjWasRemovedCompat(mo)) + return; + if (++hitcount == 3) goto stairstep; // don't loop forever @@ -3242,7 +3280,13 @@ retry: // the move must have hit the middle, so stairstep stairstep: if (!P_TryMove(mo, mo->x, mo->y + mo->momy, true)) //Allow things to drop off. + { + if (P_MobjWasRemovedCompat(mo)) + return; + P_TryMove(mo, mo->x + mo->momx, mo->y, true); + } + return; } @@ -3254,7 +3298,12 @@ stairstep: newy = FixedMul(mo->momy, bestslidefrac); if (!P_TryMove(mo, mo->x + newx, mo->y + newy, true)) + { goto stairstep; + } + + if (P_MobjWasRemovedCompat(mo)) + return; } // Now continue along the wall. @@ -3273,7 +3322,7 @@ stairstep: if (bestslideline != NULL) P_HitSlideLine(bestslideline); // clip the moves - if (UNLIKELY((twodlevel || (mo->flags2 & MF2_TWOD)) && mo->player)) + if (twodmo(mo) && mo->player) { mo->momx = tmxmove; tmymove = 0; @@ -3325,8 +3374,11 @@ stairstep: goto retry; } + if (P_MobjWasRemovedCompat(mo)) + return; + success = true; - } while(tmxmove || tmymove); + } while (tmxmove || tmymove); } // @@ -3339,12 +3391,18 @@ void P_BouncePlayerMove(mobj_t *mo) { fixed_t leadx, leady; fixed_t trailx, traily; - fixed_t mmomx = 0, mmomy = 0; - fixed_t oldmomx = mo->momx, oldmomy = mo->momy; + fixed_t mmomx, mmomy; + fixed_t oldmomx, oldmomy; - if (!mo->player) + if (P_MobjWasRemovedCompat(mo)) return; + if (mo->player == NULL) + return; + + oldmomx = mo->momx; + oldmomy = mo->momy; + if (mo->player->spectator) { P_SlideMove(mo, true); @@ -3433,6 +3491,9 @@ void P_BouncePlayerMove(mobj_t *mo) if (!P_TryMove(mo, mo->x + tmxmove, mo->y + tmymove, true)) { + if (P_MobjWasRemovedCompat(mo)) + return; + P_TryMove(mo, mo->x - oldmomx, mo->y - oldmomy, true); } } @@ -3450,6 +3511,9 @@ void P_BounceMove(mobj_t *mo) INT32 hitcount; fixed_t mmomx = 0, mmomy = 0; + if (P_MobjWasRemovedCompat(mo)) + return; + if (mo->player) { P_BouncePlayerMove(mo); @@ -3466,6 +3530,9 @@ void P_BounceMove(mobj_t *mo) hitcount = 0; retry: + if (P_MobjWasRemovedCompat(mo)) + return; + if (++hitcount == 3) goto bounceback; // don't loop forever @@ -3524,7 +3591,12 @@ bounceback: newy = FixedMul(mmomy, bestslidefrac); if (!P_TryMove(mo, mo->x + newx, mo->y + newy, true)) + { + if (P_MobjWasRemovedCompat(mo)) + return; + goto bounceback; + } } // Now continue along the wall. @@ -4179,7 +4251,7 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) * Must clear tmthing at tic end, as it might contain a pointer to a removed thinker, or the level might have ended/been ended and we clear the objects it was pointing too. Hopefully we don't need to carry this between tics for sync. */ void P_MapStart(void) { - if (UNLIKELY(tmthing)) + if (tmthing) I_Error("P_MapStart: tmthing set!"); } diff --git a/src/p_mobj.c b/src/p_mobj.c index 49916eb50..02e1e1bc6 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -172,7 +172,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) do { - if (UNLIKELY(state == S_NULL)) + if (state == S_NULL) { // Bad SOC! CONS_Alert(CONS_ERROR, "Cannot remove player mobj by setting its state to S_NULL.\n"); //P_RemoveMobj(mobj); @@ -347,7 +347,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -358,7 +358,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -369,7 +369,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -380,7 +380,7 @@ void P_ExplodeMissile(mobj_t *mo) explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_EXPLODE); - if (explodemo) + if (!P_MobjWasRemovedCompat(explodemo)) { P_SetScale(explodemo, mo->scale); explodemo->destscale = mo->destscale; @@ -905,7 +905,7 @@ static void P_PlayerFlip(mobj_t *mo) G_GhostAddFlip((INT32) (mo->player - players)); // Flip aiming to match! - if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) // NiGHTS doesn't use flipcam + if (nightsplayer(mo->player)) // NiGHTS doesn't use flipcam { if (mo->tracer) mo->tracer->eflags ^= MFE_VERTICALFLIP; @@ -998,7 +998,7 @@ fixed_t P_GetMobjGravity(mobj_t *mo) if (mo->player) { - if (UNLIKELY(mo->player->climbing || (mo->player->pflags & PF_NIGHTSMODE))) + if (UNLIKELY(mo->player->climbing || nightsplayer(mo->player))) return 0; if (!(mo->flags2 & MF2_OBJECTFLIP) != !(mo->player->powers[pw_gravityboots])) // negated to turn numeric into bool - would be double negated, but not needed if both would be @@ -1177,7 +1177,7 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) } else if (abs(player->rmomx) < mo->scale && abs(player->rmomy) < mo->scale - && (!(player->cmd.forwardmove && !(twodlevel || mo->flags2 & MF2_TWOD)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING)) + && (!(player->cmd.forwardmove && !twodmo(mo)) && !player->cmd.sidemove && !(player->pflags & PF_SPINNING)) && !(player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && (abs(player->mo->standingslope->zdelta) >= FRACUNIT/2)) ) { @@ -1619,7 +1619,7 @@ void P_XYMovement(mobj_t *mo) // Check the gravity status. P_CheckGravity(mo, false); - if (UNLIKELY(player && !moved && player->pflags & PF_NIGHTSMODE && mo->target)) + if (player && !moved && nightsplayer(player) && mo->target) { angle_t fa; @@ -1669,11 +1669,14 @@ void P_XYMovement(mobj_t *mo) if (mo->flags & MF_MISSILE || mo->flags2 & MF2_SKULLFLY || mo->type == MT_SHELL || mo->type == MT_VULTURE) return; // no friction for missiles ever - if (player && player->homing) // no friction for homing - return; + if (player) + { + if (player->homing) // no friction for homing + return; - if (UNLIKELY(player && player->pflags & PF_NIGHTSMODE)) - return; // no friction for NiGHTS players + if (nightsplayer(player)) + return; // no friction for NiGHTS players + } if ((mo->type == MT_BIGTUMBLEWEED || mo->type == MT_LITTLETUMBLEWEED) && (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8)) // Special exception for tumbleweeds on slopes @@ -2221,7 +2224,7 @@ static boolean P_ZMovement(mobj_t *mo) || mo->type == MT_CANNONBALLDECOR || mo->type == MT_FALLINGROCK) { - if (UNLIKELY(maptol & TOL_NIGHTS)) + if (nightsmode) mom.z = -FixedDiv(mom.z, 10*FRACUNIT); else mom.z = -FixedMul(mom.z, FixedDiv(17*FRACUNIT,20*FRACUNIT)); @@ -2359,11 +2362,9 @@ static boolean P_ZMovement(mobj_t *mo) { if (mo->flags2 & MF2_SKULLFLY) // the skull slammed into something mo->momz = -mo->momz; - else - // Flags bounce - if (UNLIKELY(mo->type == MT_REDFLAG || mo->type == MT_BLUEFLAG)) + else if (UNLIKELY(mo->type == MT_REDFLAG || mo->type == MT_BLUEFLAG)) // Flags bounce { - if (UNLIKELY(maptol & TOL_NIGHTS)) + if (nightsmode) mo->momz = -FixedDiv(mo->momz, 10*FRACUNIT); else mo->momz = -FixedMul(mo->momz, FixedDiv(17*FRACUNIT,20*FRACUNIT)); @@ -2429,7 +2430,7 @@ static void P_PlayerZMovement(mobj_t *mo) else mo->z = mo->floorz; - if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(mo->player)) { // bounce off floor if you were flying towards it if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 0 && mo->player->flyangle < 180) @@ -2620,7 +2621,7 @@ nightsdone: else mo->z = mo->ceilingz - mo->height; - if (UNLIKELY(mo->player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(mo->player)) { // bounce off ceiling if you were flying towards it if ((mo->eflags & MFE_VERTICALFLIP && mo->player->flyangle > 180 && mo->player->flyangle <= 359) @@ -2665,7 +2666,7 @@ nightsdone: } // hit the ceiling - if (UNLIKELY(mariomode)) + if (mariomode) S_StartSound(mo, sfx_mario1); if (!mo->player->climbing) @@ -3223,7 +3224,7 @@ void P_CalcChasePostImg(player_t *player, camera_t *thiscam) player_flipcam = cv_flipcam[pnum].value; } - const boolean flipcam = (player_flipcam && player->mo->eflags & MFE_VERTICALFLIP && LIKELY(!(player->pflags & PF_NIGHTSMODE))); + const boolean flipcam = (player_flipcam && player->mo->eflags & MFE_VERTICALFLIP && !nightsplayer(player)); UINT8 postimgtype = 0; if (encoremode) @@ -3379,11 +3380,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) I_Assert(mobj->player != NULL); I_Assert(!P_MobjWasRemoved(mobj)); -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; P_MobjCheckWater(mobj); @@ -3406,7 +3403,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) P_CheckPosition(mobj, mobj->x, mobj->y); goto animonly; } - else if (UNLIKELY(mobj->player->pflags & PF_MACESPIN)) + else if (mobj->player->pflags & PF_MACESPIN) { P_CheckPosition(mobj, mobj->x, mobj->y); goto animonly; @@ -3520,7 +3517,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj) } else { - if (LIKELY(!(mobj->player->pflags & PF_NIGHTSMODE))) // "jumping" is used for drilling + if (!nightsplayer(mobj->player)) // "jumping" is used for drilling mobj->player->jumping = 0; mobj->player->pflags &= ~PF_JUMPED; @@ -5633,11 +5630,7 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale) player_t *player; fixed_t oldscale; -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; oldscale = mobj->scale; //keep for adjusting stuff below @@ -8552,7 +8545,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (mobj->tracer && mobj->tracer->player) { - if (LIKELY(!(mobj->tracer->player->pflags & PF_NIGHTSMODE))) + if (!nightsplayer(mobj->tracer->player)) { mobj->flags &= ~MF_NOGRAVITY; mobj->flags2 &= ~MF2_DONTDRAW; @@ -8576,7 +8569,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_SetTarget(&mobj->target, NULL); } - if (UNLIKELY(mobj->tracer->player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(mobj->tracer->player)) { if (mobj->tracer->player->bonustime) { @@ -8988,11 +8981,7 @@ static boolean P_FuseThink(mobj_t *mobj) static boolean P_MobjPushableThink(mobj_t *mobj) { // would be cool if we could use P_MobjWasRemoved Zzz... -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return false; P_MobjCheckWater(mobj); @@ -9078,7 +9067,7 @@ void P_MobjThinker(mobj_t *mobj) const sector_t *sec1 = mobj->subsector ? mobj->subsector->sector : NULL; // 970 allows ANY mobj to trigger a linedef exec - if (UNLIKELY(!mobj->islocal && sec1 && GETSECSPECIAL(sec1->special, 2) == 8)) // BEWARE: islocal does not exist in vanilla + if (!mobj->islocal && sec1 && GETSECSPECIAL(sec1->special, 2) == 8) // BEWARE: islocal does not exist in vanilla { sector_t *sec2; sec2 = P_ThingOnSpecial3DFloor(mobj); @@ -9144,7 +9133,7 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->flags2 & MF2_FIRING && mobj->target && mobj->health > 0) P_FiringThink(mobj); - if (UNLIKELY(mobj->flags & MF_AMBIENT)) + if (mobj->flags & MF_AMBIENT) { if (leveltime % mobj->health) return; @@ -9198,18 +9187,14 @@ void P_MobjThinker(mobj_t *mobj) { P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) // anything that calls checkposition can be lethal -#else - if (!mobj) // anything that calls checkposition can be lethal -#endif + if (P_MobjWasRemovedCompat(mobj)) // anything that calls checkposition can be lethal return; P_ButteredSlope(mobj); } - if (UNLIKELY(mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health - && P_CheckDeathPitCollide(mobj))) // extra pit check in case these didn't have momz + if (mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health + && P_CheckDeathPitCollide(mobj)) // extra pit check in case these didn't have momz { P_KillMobj(mobj, NULL, NULL); return; @@ -9218,10 +9203,7 @@ void P_MobjThinker(mobj_t *mobj) // Crush enemies! if (mobj->ceilingz - mobj->floorz < mobj->height) { - if (UNLIKELY(( - (mobj->flags & (MF_ENEMY|MF_BOSS) - && mobj->flags & MF_SHOOTABLE) - || mobj->type == MT_EGGSHIELD)) + if (((mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->flags & MF_SHOOTABLE) || mobj->type == MT_EGGSHIELD) && !(mobj->flags & MF_NOCLIPHEIGHT) && mobj->health > 0) { @@ -9230,11 +9212,7 @@ void P_MobjThinker(mobj_t *mobj) } } -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; // obligatory paranoia check // Can end up here if a player dies. @@ -9243,7 +9221,7 @@ void P_MobjThinker(mobj_t *mobj) if (P_MobjWasRemoved(mobj)) return; - if (UNLIKELY(P_WeaponOrPanel(mobj->type))) + if (P_WeaponOrPanel(mobj->type)) { if (mobj->health == 0) // Fading tile { @@ -9294,11 +9272,7 @@ void P_PushableThinker(mobj_t *mobj) I_Assert(!P_MobjWasRemoved(mobj)); -#ifndef COMPAT_VANILLA - if (P_MobjWasRemoved(mobj)) -#else - if (!mobj) -#endif + if (P_MobjWasRemovedCompat(mobj)) return; sec = mobj->subsector->sector; @@ -10131,14 +10105,14 @@ void P_RemoveMobj(mobj_t *mobj) } } // Rings only, please! - else if (UNLIKELY(mobj->spawnpoint && + else if (mobj->spawnpoint && !(mobj->flags2 & MF2_DONTRESPAWN) && (mobj->type == MT_RING || mobj->type == MT_COIN || mobj->type == MT_BLUEBALL || mobj->type == MT_REDTEAMRING || mobj->type == MT_BLUETEAMRING - || P_WeaponOrPanel(mobj->type)))) + || P_WeaponOrPanel(mobj->type))) { itemrespawnque[iquehead] = mobj->spawnpoint; itemrespawntime[iquehead] = leveltime; diff --git a/src/p_spec.c b/src/p_spec.c index 9aff26b3c..35efaa857 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3880,7 +3880,7 @@ DoneSection2: player->kartstuff[k_lapanimation] = 80; - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(player)) player->drillmeter += 48*20; if (netgame && player->laps >= (UINT8)cv_numlaps.value) @@ -7126,7 +7126,7 @@ static inline boolean PIT_PushThing(mobj_t *thing) return false; // Allow this to affect pushable objects at some point? - if (thing->player && (!(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)) || UNLIKELY(thing->player->pflags & PF_NIGHTSMODE))) + if (thing->player && (!(thing->flags & (MF_NOGRAVITY | MF_NOCLIP)) || nightsplayer(thing->player))) { INT32 dist; INT32 speed; @@ -7156,7 +7156,7 @@ static inline boolean PIT_PushThing(mobj_t *thing) // Written with bits and pieces of P_HomingAttack if ((speed > 0) && (P_CheckSight(thing, tmpusher->source))) { - if (LIKELY(!(thing->player->pflags & PF_NIGHTSMODE))) + if (!nightsplayer(thing->player)) { // only push wrt Z if health & 1 (mapthing has ambush flag) if (tmpusher->source->health & 1) diff --git a/src/p_user.c b/src/p_user.c index 90bca6cff..8480b0e60 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -74,7 +74,7 @@ void P_Thrust(mobj_t *mo, angle_t angle, fixed_t move) mo->momx += FixedMul(move, FINECOSINE(angle)); - if (LIKELY(!(twodlevel || (mo->flags2 & MF2_TWOD)))) + if (!twodmo(mo)) mo->momy += FixedMul(move, FINESINE(angle)); } @@ -90,7 +90,7 @@ void P_InstaThrust(mobj_t *mo, angle_t angle, fixed_t move) mo->momx = FixedMul(move, FINECOSINE(angle)); - if (LIKELY(!(twodlevel || (mo->flags2 & MF2_TWOD)))) + if (!twodmo(mo)) mo->momy = FixedMul(move,FINESINE(angle)); } @@ -475,7 +475,7 @@ void P_PlayLivesJingle(player_t *player) if (UNLIKELY(use1upSound)) S_StartSound(NULL, sfx_oneup); - else if (UNLIKELY(mariomode)) + else if (mariomode) S_StartSound(NULL, sfx_marioa); else { @@ -503,7 +503,7 @@ void P_PlayRinglossSound(mobj_t *source, mobj_t *damager) S_StartSound(NULL, sfx); } else - S_StartSound(source, UNLIKELY(mariomode) ? sfx_mario8 : sfx_khurt1 + key); + S_StartSound(source, mariomode ? sfx_mario8 : sfx_khurt1 + key); } else S_StartSound(source, sfx_slip); @@ -1725,7 +1725,7 @@ static void P_DoBubbleBreath(player_t *player) else zh = player->mo->z + FixedDiv(player->mo->height,5*(FRACUNIT/4)); - if (!(player->mo->eflags & MFE_UNDERWATER) || player->spectator || ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL && !(player->pflags & PF_NIGHTSMODE))) + if (!(player->mo->eflags & MFE_UNDERWATER) || player->spectator || ((player->powers[pw_shield] & SH_NOSTACK) == SH_ELEMENTAL && !nightsplayer(player))) return; if (P_RandomChance(FRACUNIT/16)) @@ -2298,7 +2298,7 @@ static void P_MovePlayer(player_t *player) P_3dMovement(player); } - if (UNLIKELY(maptol & TOL_2D)) // psure this doesent even work at all + if (twodlevel) // psure this doesent even work at all runspd = FixedMul(runspd, 2*FRACUNIT/3); ///////////////////////// @@ -2748,8 +2748,8 @@ boolean P_LookForEnemies(player_t *player) if (modist > FixedMul(RING_DIST, player->mo->scale)) continue; // out of range - if (UNLIKELY((twodlevel || player->mo->flags2 & MF2_TWOD) - && abs(player->mo->y-mo->y) > player->mo->radius)) + + if (twodmo(player->mo) && abs(player->mo->y-mo->y) > player->mo->radius) continue; // not in your 2d plane if (closestmo && modist > P_AproxDistance(P_AproxDistance(player->mo->x-closestmo->x, @@ -3508,7 +3508,7 @@ static boolean P_CheckNoclipCameraPosition(player_t *player, camera_t *thiscam, boolean cameranoclip; mobj_t *mo = player->mo; - cameranoclip = ((player->pflags & (PF_NOCLIP|PF_NIGHTSMODE)) + cameranoclip = (nightsplayer(player) || (mo->flags & (MF_NOCLIP|MF_NOCLIPHEIGHT)) // Noclipping player camera noclips too!! || (leveltime < introtime)); // Kart intro cam @@ -4097,7 +4097,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall angle -= (angle - thiscam->pitch)/2; } - if (player->playerstate != PST_DEAD && LIKELY(!((player->pflags & PF_NIGHTSMODE) && player->exiting))) + if (player->playerstate != PST_DEAD && !(nightsplayer(player) && player->exiting)) angle += (focusaiming < ANGLE_180 ? focusaiming/2 : InvAngle(InvAngle(focusaiming)/2)); // overcomplicated version of '((signed)focusaiming)/2;' if (!camstill && !timeover) // Keep the view still... @@ -4174,7 +4174,7 @@ boolean P_SpectatorJoinGame(player_t *player) // Team changing in Team Match and CTF // Pressing fire assigns you to a team that needs players if allowed. // Partial code reproduction from p_tick.c autobalance code. - else if (UNLIKELY(G_GametypeHasTeams())) + else if (G_GametypeHasTeams()) { INT32 changeto = 0; INT32 z, numplayersred = 0, numplayersblue = 0; @@ -4871,7 +4871,7 @@ void P_PlayerThink(player_t *player) // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. if (UNLIKELY(!objectplacing && !((netgame || multiplayer) && player->spectator) - && maptol & TOL_NIGHTS && (!(player->pflags & PF_NIGHTSMODE) || player->powers[pw_nights_helper]))) + && nightsmode && (!nightsplayer(player) || player->powers[pw_nights_helper]))) { thinker_t *th; mobj_t *mo2; @@ -4973,7 +4973,7 @@ void P_PlayerThink(player_t *player) #endif // check for use - if (LIKELY(!(player->pflags & PF_NIGHTSMODE))) + if (!nightsplayer(player)) { if (cmd->buttons & BT_BRAKE) player->pflags |= PF_USEDOWN; @@ -5164,7 +5164,7 @@ void P_PlayerAfterThink(player_t *player) } } - if (UNLIKELY(player->pflags & PF_NIGHTSMODE)) + if (nightsplayer(player)) { player->powers[pw_gravityboots] = 0; } diff --git a/src/r_main.cpp b/src/r_main.cpp index c4719e2e5..038fa8a6a 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1601,6 +1601,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_sloperolldist); CV_RegisterVar(&cv_sparkroll); CV_RegisterVar(&cv_stairjank); + CV_RegisterVar(&cv_stairjanksfx); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); diff --git a/src/r_things.cpp b/src/r_things.cpp index d891d40ce..bc01c4cc8 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2941,16 +2941,16 @@ void R_ClipSprites(drawseg_t* dsstart, portal_t* portal) /* Check if thing may be drawn from our current view. */ boolean R_ThingVisible(mobj_t *thing) { - if (UNLIKELY((thing->sprite == SPR_NULL) || (thing->flags2 & MF2_DONTDRAW))) + if ((thing->sprite == SPR_NULL) || (thing->flags2 & MF2_DONTDRAW)) return false; - if (UNLIKELY(splitscreen)) + if (splitscreen) { - if ((viewssnum == 0 && (thing->eflags & MFE_DRAWONLYFORP1)) - || (viewssnum == 1 && (thing->eflags & MFE_DRAWONLYFORP2)) - || (viewssnum == 2 && (thing->eflags & MFE_DRAWONLYFORP2)) - || (viewssnum == 3 && (thing->eflags & MFE_DRAWONLYFORP4))) - return true; + if (((thing->eflags & MFE_DRAWONLYFORP1) && viewssnum != 0) + || ((thing->eflags & MFE_DRAWONLYFORP2) && viewssnum != 1) + || ((thing->eflags & MFE_DRAWONLYFORP3) && viewssnum != 2) + || ((thing->eflags & MFE_DRAWONLYFORP4) && viewssnum != 3)) + return false; } return true; diff --git a/src/v_video.c b/src/v_video.c index 0f4540216..2ac659ba6 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -2718,6 +2718,7 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st INT32 charflags = 0; const UINT8 *colormap = NULL; INT32 spacewidth = 2, charwidth = 0; + INT32 lowercase = (option & V_ALLOWLOWERCASE); option &= ~V_FLIP; // which is also shared with V_ALLOWLOWERCASE... @@ -2738,6 +2739,7 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st scrwidth *= vid.dup; charflags = (option & V_CHARCOLORMASK); + colormap = V_GetStringColormap(charflags); switch (option & V_SPACINGMASK) { @@ -2762,7 +2764,11 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st { // manually set flags override color codes if (!(option & V_CHARCOLORMASK)) + { charflags = ((*ch & 0x7f) << V_CHARCOLORSHIFT) & V_CHARCOLORMASK; + colormap = V_GetStringColormap(charflags); + } + continue; } @@ -2806,7 +2812,6 @@ void V_DrawSmallStringAtFixed(fixed_t x, fixed_t y, INT32 option, const char *st continue; } - colormap = V_GetStringColormap(charflags); V_DrawFixedPatch(cx + (center<name; I_Assert(name != NULL); - if (CHECKMAPMARKER(name)) + if (!name || CHECKMAPMARKER(name)) { numlumps--; // We skip map marker, so 1 of entries becomes empty continue; // This will skip i++ so we will write to same entry @@ -2764,7 +2764,8 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) const char *name = W_CheckNameForNum(lumppos); I_Assert(name != NULL); - if (CHECKMAPMARKER(name)) + // if no name then theres no lump + if (!name || CHECKMAPMARKER(name)) { break; } @@ -2781,7 +2782,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum) const char *name = W_CheckNameForNum(lumpnum); I_Assert(name != NULL); - if (CHECKMAPMARKER(name)) + if (!name || CHECKMAPMARKER(name)) { --i; // Decrement so on next iteration we write on same i, so we don't leave corrupted vlumps entry numlumps--; // Just so we don't try to access the leftover vlumps entry