diff --git a/src/d_clisrv.c b/src/d_clisrv.c index d76e67e88..51abad01d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -6305,7 +6305,8 @@ static void Local_Maketic(INT32 realtics) D_ProcessEvents(); // menu responder, cons responder, // game responder calls HU_Responder, AM_Responder, F_Responder, // and G_MapEventsToControls - if (!dedicated) rendergametic = gametic; + if (!dedicated) + rendergametic = gametic; // translate inputs (keyboard/mouse/joystick) into game controls for (i = 0; i <= splitscreen; i++) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7c096b956..ea424433e 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -2695,7 +2695,8 @@ static tic_t last_map_cmd = 0; // static void Command_Map_f(void) { - if (I_GetTime() - last_map_cmd < 20) { + if (I_GetTime() - last_map_cmd < 20) + { CONS_Alert(CONS_WARNING, "Map command is used too frequently!\n"); return; } @@ -2753,8 +2754,7 @@ static void Command_Map_f(void) { if (!multiplayer) { - CONS_Printf(M_GetText( - "You can't switch gametypes in single player!\n")); + CONS_Printf(M_GetText("You can't switch gametypes in single player!\n")); return; } else if (COM_Argc() < option_gametype + 2)/* no argument after? */ diff --git a/src/d_player.h b/src/d_player.h index a1e4a0b20..af24630c2 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -356,6 +356,16 @@ typedef enum LAP__MAX } laptime_e; +// yes i made a whole struct for this :chonkbuncle: +typedef struct squishdance_s +{ + tic_t countdown; // hold "custom 3" for 2 seconds to engange le dance + tic_t time; + fixed_t work; + fixed_t ang; + fixed_t bounce; // hehe squishy +} squishdance_t; + // ======================================================================== // PLAYER STRUCTURE // ======================================================================== @@ -555,7 +565,7 @@ typedef struct player_s fixed_t spinoutrot; // When a player spins out, this value increments modulus 360. - tic_t dancetime; + squishdance_t squishdance; fixed_t fovadd; // adjust FOV for hw rendering } player_t; diff --git a/src/g_game.c b/src/g_game.c index 18b7f94c0..0712a49e5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -4010,7 +4010,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool unlocktriggers = 0; // clear itemfinder, just in case - if (!dedicated) // except in dedicated servers, where it is not registered and can actually I_Error debug builds + if (!dedicated) // except in dedicated servers, where it is not registered and can actually I_Error debug builds CV_StealthSetValue(&cv_itemfinder, 0); } @@ -4028,7 +4028,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool // gamemap changed; we assume that its map header is always valid, // so make it so - if(!mapheaderinfo[gamemap-1]) + if (!mapheaderinfo[gamemap-1]) P_AllocMapHeader(gamemap-1); maptol = mapheaderinfo[gamemap-1]->typeoflevel; @@ -4833,6 +4833,7 @@ void G_GhostAddThok(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_THOK; } @@ -4840,6 +4841,7 @@ void G_GhostAddSpin(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_SPIN; } @@ -4847,6 +4849,7 @@ void G_GhostAddRev(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags = (ghostext[playernum].flags & ~EZT_THOKMASK) | EZT_REV; } @@ -4854,6 +4857,7 @@ void G_GhostAddFlip(INT32 playernum) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags |= EZT_FLIP; } @@ -4861,11 +4865,13 @@ void G_GhostAddColor(INT32 playernum, ghostcolor_t color) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + if (ghostext[playernum].lastcolor == (UINT8)color) { ghostext[playernum].flags &= ~EZT_COLOR; return; } + ghostext[playernum].flags |= EZT_COLOR; ghostext[playernum].color = (UINT8)color; } @@ -4874,11 +4880,13 @@ void G_GhostAddScale(INT32 playernum, fixed_t scale) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + if (ghostext[playernum].lastscale == scale) { ghostext[playernum].flags &= ~EZT_SCALE; return; } + ghostext[playernum].flags |= EZT_SCALE; ghostext[playernum].scale = scale; } @@ -4887,9 +4895,10 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim) { if (!demo.recording || !(demoflags & DF_GHOST)) return; + ghostext[playernum].flags |= EZT_HIT; ghostext[playernum].hits++; - ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, NULL); + ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, &ghostext[playernum].hitlist); P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim); } @@ -4909,7 +4918,7 @@ void G_WriteAllGhostTics(void) if (!playeringame[i] || players[i].spectator) continue; - if (!players[i].mo) + if (P_MobjWasRemoved(players[i].mo)) continue; counter++; @@ -4993,6 +5002,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) // Store one full byte of movement, plus one byte of fractional movement. INT16 momx = (INT16)((ghost->x-oldghost[playernum].x + (1<<4))>>8); INT16 momy = (INT16)((ghost->y-oldghost[playernum].y + (1<<4))>>8); + if (momx != oldghost[playernum].momx || momy != oldghost[playernum].momy) { @@ -5005,7 +5015,9 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEINT16(demobuf.p,momx); WRITEINT16(demobuf.p,momy); } + momx = (INT16)((ghost->z-oldghost[playernum].z + (1<<4))>>8); + if (momx != oldghost[playernum].momz) { oldghost[playernum].momz = momx; @@ -5077,6 +5089,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) if (ghostext[playernum].color == ghostext[playernum].lastcolor) ghostext[playernum].flags &= ~EZT_COLOR; + if (ghostext[playernum].scale == ghostext[playernum].lastscale) ghostext[playernum].flags &= ~EZT_SCALE; @@ -5091,16 +5104,19 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEUINT8(demobuf.p,ghostext[playernum].color); ghostext[playernum].lastcolor = ghostext[playernum].color; } + if (ghostext[playernum].flags & EZT_SCALE) { CHECKSPACE(sizeof(fixed_t)); WRITEFIXED(demobuf.p,ghostext[playernum].scale); ghostext[playernum].lastscale = ghostext[playernum].scale; } + if (ghostext[playernum].flags & EZT_HIT) { CHECKSPACE(2); WRITEUINT16(demobuf.p,ghostext[playernum].hits); + for (i = 0; i < ghostext[playernum].hits; i++) { mobj_t *mo = ghostext[playernum].hitlist[i]; @@ -5116,23 +5132,24 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEANGLE(demobuf.p,mo->angle); P_SetTarget(ghostext[playernum].hitlist+i, NULL); } - Z_Free(ghostext[playernum].hitlist); + ghostext[playernum].hits = 0; - ghostext[playernum].hitlist = NULL; } + if (ghostext[playernum].flags & EZT_SPRITE) { CHECKSPACE(1); WRITEUINT8(demobuf.p,sprite); } + if (ghostext[playernum].flags & EZT_KART) { CHECKSPACE(12); - WRITEINT32(demobuf.p, ghostext[playernum].kartitem); WRITEINT32(demobuf.p, ghostext[playernum].kartamount); WRITEINT32(demobuf.p, ghostext[playernum].kartbumpers); } + ghostext[playernum].flags = 0; } @@ -5180,6 +5197,7 @@ void G_ConsGhostTic(INT32 playernum) // Grab ghost data. ziptic = READUINT8(demobuf.p); + if (ziptic & GZT_XYZ) { oldghost[playernum].x = READFIXED(demobuf.p); @@ -5194,17 +5212,22 @@ void G_ConsGhostTic(INT32 playernum) oldghost[playernum].momx = READINT16(demobuf.p)<<8; oldghost[playernum].momy = READINT16(demobuf.p)<<8; } + if (ziptic & GZT_MOMZ) oldghost[playernum].momz = READINT16(demobuf.p)<<8; + oldghost[playernum].x += oldghost[playernum].momx; oldghost[playernum].y += oldghost[playernum].momy; oldghost[playernum].z += oldghost[playernum].momz; syncleeway = FRACUNIT; } + if (ziptic & GZT_ANGLE) demobuf.p++; + if (ziptic & GZT_SPRITE) demobuf.p++; + if (ziptic & GZT_NIGHTS) { if (!testmo || !testmo->player || !(testmo->player->pflags & PF_NIGHTSMODE) || !testmo->tracer) @@ -5218,8 +5241,10 @@ void G_ConsGhostTic(INT32 playernum) ziptic = READUINT8(demobuf.p); if (ziptic & EZT_COLOR) demobuf.p++; + if (ziptic & EZT_SCALE) demobuf.p += sizeof(fixed_t); + if (ziptic & EZT_HIT) { // Resync mob damage. UINT16 i, count = READUINT16(demobuf.p); @@ -5252,6 +5277,7 @@ void G_ConsGhostTic(INT32 playernum) break; mobj = NULL; // wasn't this one, keep searching. } + if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { if (demosynced) @@ -5259,13 +5285,16 @@ void G_ConsGhostTic(INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (health)!\n")); CONS_Printf("expected health %d got %d\n", health, mobj->health); } + demosynced = false; P_DamageMobj(mobj, players[0].mo, players[0].mo, 1); } } } + if (ziptic & EZT_SPRITE) demobuf.p++; + if (ziptic & EZT_KART) { ghostext[playernum].kartitem = READINT32(demobuf.p); @@ -5345,7 +5374,8 @@ void G_ConsGhostTic(INT32 playernum) void G_GhostTicker(void) { demoghost *g,*p; - for(g = ghosts, p = NULL; g; g = g->next) + + for (g = ghosts, p = NULL; g; g = g->next) { // Skip normal demo data. UINT8 ziptic = READUINT8(g->p); diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2c736708b..ea5b9f522 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -2360,7 +2360,35 @@ static void HWR_AddLine(seg_t *line) gl_backsector = line->backsector; if (!cv_glportals.value || LIKELY(!gl_maphasportals)) - goto doaddline; + { +doaddline: + if (!line->backsector) + { + gld_clipper_SafeAddClipRange(angle2, angle1); + } + else + { + gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); + + if (CheckClip(gl_frontsector, gl_backsector)) + { + gld_clipper_SafeAddClipRange(angle2, angle1); + checkforemptylines = false; + } + + // Reject empty lines used for triggers and special events. + // Identical floor and ceiling on both sides, + // identical light levels on both sides, + // and no middle texture. + if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector)) + return; + } + + if (LIKELY(gl_portal_state != GLPORTAL_SEARCH && !dont_draw))// no need to do this during the portal check + HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D + + return; + } // do extra checks on the seg when rendering portals: // don't render segs that are behind the portal destination line @@ -2396,34 +2424,7 @@ static void HWR_AddLine(seg_t *line) return;// dont do anything with the other side i guess? } -doaddline: - - if (!line->backsector) - { - gld_clipper_SafeAddClipRange(angle2, angle1); - } - else - { - gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); - - if (CheckClip(gl_frontsector, gl_backsector)) - { - gld_clipper_SafeAddClipRange(angle2, angle1); - checkforemptylines = false; - } - - // Reject empty lines used for triggers and special events. - // Identical floor and ceiling on both sides, - // identical light levels on both sides, - // and no middle texture. - if (checkforemptylines && R_IsEmptyLine(line, gl_frontsector, gl_backsector)) - return; - } - - if (LIKELY(gl_portal_state != GLPORTAL_SEARCH && !dont_draw))// no need to do this during the portal check - HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D - - return; + goto doaddline; } // HWR_CheckBBox @@ -2440,8 +2441,8 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) // Find the corners of the box // that define the edges from current viewpoint. - const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT ] ? 1 : 2) + - (viewy >= bspcoord[BOXTOP ] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); + const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT] ? 1 : 2) + + (viewy >= bspcoord[BOXTOP] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); if (boxpos == 5) return true; @@ -2880,7 +2881,7 @@ static void HWR_Subsector(size_t num) gl_frontsector = R_FakeFlat(gl_frontsector, &tempsec, &floorlightlevel, &ceilinglightlevel, false); - if (gl_portal_state == GLPORTAL_SEARCH) + if (UNLIKELY(gl_portal_state == GLPORTAL_SEARCH)) { goto doaddline; } @@ -3006,37 +3007,37 @@ static void HWR_Subsector(size_t num) { UINT8 alpha; - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < bottomCullHeight)); alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, - &extrasubsectors[num], - false, - *rover->bottomheight, - *gl_frontsector->lightlist[light].lightlevel, - alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, - true, rover->master->frontsector->extra_colormap); + &extrasubsectors[num], + false, + *rover->bottomheight, + *gl_frontsector->lightlist[light].lightlevel, + alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, + true, rover->master->frontsector->extra_colormap); } else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient { - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < bottomCullHeight)); HWR_AddTransparentFloor(levelflats[*rover->bottompic].lumpnum, - &extrasubsectors[num], - false, - *rover->bottomheight, - *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), - false, gl_frontsector->lightlist[light].extra_colormap); + &extrasubsectors[num], + false, + *rover->bottomheight, + *gl_frontsector->lightlist[light].lightlevel, + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), + false, gl_frontsector->lightlist[light].extra_colormap); } else { HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gl_frontsector, false)); - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < bottomCullHeight)); HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, - rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } } @@ -3052,21 +3053,21 @@ static void HWR_Subsector(size_t num) { UINT8 alpha; - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < topCullHeight)); alpha = HWR_FogBlockAlpha(*gl_frontsector->lightlist[light].lightlevel, rover->master->frontsector->extra_colormap); HWR_AddTransparentFloor(0, - &extrasubsectors[num], - true, - *rover->topheight, - *gl_frontsector->lightlist[light].lightlevel, - alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, - true, rover->master->frontsector->extra_colormap); + &extrasubsectors[num], + true, + *rover->topheight, + *gl_frontsector->lightlist[light].lightlevel, + alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, + true, rover->master->frontsector->extra_colormap); } else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < topCullHeight)); HWR_AddTransparentFloor(levelflats[*rover->toppic].lumpnum, &extrasubsectors[num], @@ -3079,10 +3080,10 @@ static void HWR_Subsector(size_t num) else { HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gl_frontsector, true)); - light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); + light = R_GetPlaneLight(gl_frontsector, centerHeight, (viewz < topCullHeight)); HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, - rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); + rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } } } @@ -3462,7 +3463,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t sSurf.PolyColor.s.green = 0x01; // shadow is always half as translucent as the sprite itself - if (!cv_translucency.value) // use default translucency (main sprite won't have any translucency) + if (UNLIKELY(!cv_translucency.value)) // use default translucency (main sprite won't have any translucency) sSurf.PolyColor.s.alpha = 0x80; // default else if (spr->mobj->flags2 & MF2_SHADOW) sSurf.PolyColor.s.alpha = 0x20; @@ -3675,7 +3676,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) else blendmode = spr->mobj->blendmode; - if (!cv_translucency.value) // translucency disabled + if (UNLIKELY(!cv_translucency.value)) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; blend = PF_Translucent|PF_Occlude; @@ -3962,7 +3963,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else blendmode = spr->mobj->blendmode; - if (!cv_translucency.value) // translucency disabled + if (UNLIKELY(!cv_translucency.value)) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; blend = PF_Translucent|PF_Occlude; @@ -5329,6 +5330,7 @@ static void HWR_SetTransformAiming(FTransform *trans) trans->shearing = false; gl_aimingangle = aimingangle; } + trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(FINEDEGREE); } @@ -5464,7 +5466,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl validcount++; - if (cv_glbatching.value) + if (LIKELY(cv_glbatching.value)) HWR_StartBatching(); if (useportals && !rootportal && portallist.base && !skybox) // if portals have been drawn in the main view, then render skywalls differently @@ -5488,7 +5490,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl PS_STOP_TIMING(ps_bsptime); - if (cv_glbatching.value) + if (LIKELY(cv_glbatching.value)) HWR_RenderBatches(); if (skyWallVertexArraySize) // if there are skywalls to draw using the alternate method @@ -5702,7 +5704,7 @@ static void HWR_CheckForHorizonLines(void) } } -void HWR_LoadLevel(void) +void HWR_LoadLevel(boolean reloadinggamestate) { HWR_CreatePlanePolygons((INT32)numnodes - 1); @@ -5710,7 +5712,8 @@ void HWR_LoadLevel(void) HWR_ClearSkyDome(); HWR_BuildSkyDome(); - HWR_CheckForHorizonLines(); + if (!reloadinggamestate) + HWR_CheckForHorizonLines(); if (HWR_ShouldUsePaletteRendering()) HWR_SetMapPalette(); diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index cbdf7def9..0533d3676 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1557,7 +1557,7 @@ void GL_SetBlend(FBITFIELD PolyFlags) { if (PolyFlags & PF_Skydecal) { - pglPolygonOffset(-0.45f, -0.45f); // dont let skywalls draw over actual walls tho + pglPolygonOffset(0.45f, 0.45f); pglEnable(GL_POLYGON_OFFSET_FILL); } else diff --git a/src/m_menu.c b/src/m_menu.c index 550d44f5a..b7e45afc3 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -9290,7 +9290,7 @@ static void M_TimeAttack(INT32 choice) if (M_CountLevelsToShowInList() == 0) { - M_StartMessage(M_GetText("No record-attackable levels found.\n"),NULL,MM_NOTHING); + M_StartMessage(M_GetText("No record-attackable levels found.\n"), NULL, MM_NOTHING); return; } diff --git a/src/p_saveg.c b/src/p_saveg.c index c63887b69..c875272bd 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1009,13 +1009,13 @@ static inline UINT32 SaveMobjnum(const mobj_t *mobj) return 0; } -static UINT32 SaveSector(const sector_t *sector) +static inline UINT32 SaveSector(const sector_t *sector) { if (sector) return (UINT32)(sector - sectors); return 0xFFFFFFFF; } -static UINT32 SaveLine(const line_t *line) +static inline UINT32 SaveLine(const line_t *line) { if (line) return (UINT32)(line - lines); return 0xFFFFFFFF; @@ -1040,11 +1040,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8 UINT16 diff2; // Ignore stationary hoops - these will be respawned from mapthings. - if (mobj->type == MT_HOOP) - return; - - // These are NEVER saved. - if (mobj->type == MT_HOOPCOLLIDE) + if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE) // These are NEVER saved. return; // This hoop has already been collected. @@ -1905,13 +1901,13 @@ static inline mobj_t *LoadMobj(UINT32 mobjnum) return (mobj_t *)(size_t)mobjnum; } -static sector_t *LoadSector(UINT32 sector) +static inline sector_t *LoadSector(UINT32 sector) { if (sector >= numsectors) return NULL; return §ors[sector]; } -static line_t *LoadLine(UINT32 line) +static inline line_t *LoadLine(UINT32 line) { if (line >= numlines) return NULL; return &lines[line]; @@ -3022,7 +3018,7 @@ static void P_RelinkPointers(void) mobj = (mobj_t *)currentthinker; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + if (UNLIKELY(mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER)) continue; #define RELINK(obj, name) if ((obj) && !RelinkMobj(&(obj))) \ @@ -3439,7 +3435,7 @@ void P_SaveNetGame(savebuffer_t *save, boolean resending) mobj = (mobj_t *)th; - if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) + if (UNLIKELY(mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER)) continue; mobj->mobjnum = i++; diff --git a/src/p_setup.c b/src/p_setup.c index b229cabdc..8d62130d0 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -357,6 +357,7 @@ void P_AllocMapHeader(INT16 i) mapheaderinfo[i] = Z_Malloc(sizeof(mapheader_t), PU_STATIC, NULL); mapheaderinfo[i]->grades = NULL; } + P_ClearSingleMapHeaderInfo(i + 1); } @@ -434,8 +435,10 @@ UINT8 P_GetGrade(UINT32 pscore, INT16 map, UINT8 mare) if (pscore >= mapheaderinfo[map-1]->grades[mare].grade[i]) ++pgrade; } + return (UINT8)pgrade; } + return 0; } @@ -443,10 +446,8 @@ UINT8 P_HasGrades(INT16 map, UINT8 mare) { // Determining the grade // Mare 0 is treated as overall and is true if ANY grades exist - if (mapheaderinfo[map-1] && mapheaderinfo[map-1]->grades - && (mare == 0 || mapheaderinfo[map-1]->numGradedMares >= mare)) - return true; - return false; + return (mapheaderinfo[map-1] && mapheaderinfo[map-1]->grades + && (mare == 0 || mapheaderinfo[map-1]->numGradedMares >= mare)); } UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade) @@ -796,7 +797,7 @@ INT32 P_AddLevelFlatRuntime(const char *flatname) // first scan through the already found flats // for (i = 0; i < numlevelflats; i++, levelflat++) - if (strnicmp(levelflat->name,flatname,8)==0) + if (strnicmp(levelflat->name, flatname, 8) == 0) break; // that flat was already found in the level, return the id @@ -837,7 +838,7 @@ INT32 P_CheckLevelFlat(const char *flatname) // scan through the already found flats // for (i = 0; i < numlevelflats; i++, levelflat++) - if (strnicmp(levelflat->name,flatname,8)==0) + if (strnicmp(levelflat->name, flatname, 8) == 0) break; if (i == numlevelflats) @@ -1351,10 +1352,180 @@ static void P_LoadLineDefs2(void) } } +static void P_LoadSideColormaps(mapsidedef_t *msd, side_t *sd, sector_t *sec) +{ + INT32 num; + +#ifdef HWRENDER + if (rendermode == render_opengl) + { + // for now, full support of toptexture only + if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) + || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6])) + { + char *col; + RGBA_t color; + size_t j; + + sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->bottomtexture = 0; +#define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) +#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) + sec->extra_colormap = &extra_colormaps[sec->midmap]; + + if (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) + { + col = msd->toptexture; + + // encore mode colormaps! + // do it like software by aproximating a color to a palette index, and then convert it to its encore variant and then back to a color code. + // do this for both the start and fade colormaps. + + color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); + color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); + color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); + +#ifdef GLENCORE + if (encoremap) + { + j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; + color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below + } +#endif + color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly + sec->extra_colormap->rgba = color.rgba; + + // alpha + if (msd->toptexture[7]) + sec->extra_colormap->rgba += (ALPHA2INT(col[7]) << 24); + else + sec->extra_colormap->rgba += (25 << 24); + } + else + sec->extra_colormap->rgba = 0; + + if (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) + { + col = msd->bottomtexture; + + // do the exact same thing as above here. + + color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); + color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); + color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); + +#ifdef GLENCORE + if (encoremap) + { + j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; + color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below + } +#endif + color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly + sec->extra_colormap->fadergba = color.rgba; + + // alpha + if (msd->bottomtexture[7]) + sec->extra_colormap->fadergba += (ALPHA2INT(col[7]) << 24); + else + sec->extra_colormap->fadergba += (25 << 24); + } + else + sec->extra_colormap->fadergba = 0x19000000; // default alpha, (25 << 24) +#undef ALPHA2INT +#undef HEX2INT + } + else + { + if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) + sd->toptexture = 0; + else + sd->toptexture = num; + + if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) + sd->midtexture = 0; + else + sd->midtexture = num; + + if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) + sd->bottomtexture = 0; + else + sd->bottomtexture = num; + } + } +#endif +#ifdef HWRENDER + else +#endif + { + if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#') + { + sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, + msd->bottomtexture); + sd->toptexture = sd->bottomtexture = 0; + } + else + { + if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) + sd->toptexture = 0; + else + sd->toptexture = num; + if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) + sd->midtexture = 0; + else + sd->midtexture = num; + if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) + sd->bottomtexture = 0; + else + sd->bottomtexture = num; + } + } +} + +static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t *sd) +{ + char process[8+1]; + + sd->toptexture = sd->midtexture = sd->bottomtexture = 0; + + if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') + { + M_Memcpy(process,msd->bottomtexture,8); + process[8] = '\0'; + sd->bottomtexture = get_number(process); + } + + if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0') + { + M_Memcpy(process,msd->midtexture,8); + process[8] = '\0'; + sd->midtexture = get_number(process); + } + + // always process if back sidedef, because we need that - symbol + sd->text = Z_Malloc(7, PU_LEVEL, NULL); + + if (firstside || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') + { + M_Memcpy(process,msd->toptexture,8); + process[8] = '\0'; + + // If they type in O_ or D_ and their music name, just shrug, + // then copy the rest instead. + if ((process[0] == 'O' || process[0] == 'D') && process[7]) + M_Memcpy(sd->text, process+2, 6); + else // Assume it's a proper music name. + M_Memcpy(sd->text, process, 6); + sd->text[6] = 0; + } + else + sd->text[0] = 0; +} + static void P_LoadRawSideDefs2(void *data) { UINT16 i; - INT32 num; for (i = 0; i < numsides; i++) { @@ -1388,186 +1559,11 @@ static void P_LoadRawSideDefs2(void *data) case 606: //SoM: 4/4/2000: Just colormap transfer // SoM: R_CreateColormap will only create a colormap in software mode... // Perhaps we should just call it instead of doing the calculations here. -#ifdef HWRENDER - if (rendermode != render_opengl) -#endif - { - if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#') - { - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; - } -#ifdef HWRENDER - else - { - // for now, full support of toptexture only - if ((msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - || (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6])) - { - char *col; - RGBA_t color; - size_t j; - - sec->midmap = R_CreateColormap(msd->toptexture, msd->midtexture, - msd->bottomtexture); - sd->toptexture = sd->bottomtexture = 0; -#define HEX2INT(x) (x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0) -#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0) - sec->extra_colormap = &extra_colormaps[sec->midmap]; - - if (msd->toptexture[0] == '#' && msd->toptexture[1] && msd->toptexture[2] && msd->toptexture[3] && msd->toptexture[4] && msd->toptexture[5] && msd->toptexture[6]) - { - col = msd->toptexture; - - // encore mode colormaps! - // do it like software by aproximating a color to a palette index, and then convert it to its encore variant and then back to a color code. - // do this for both the start and fade colormaps. - - color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); - color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); - color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); - -#ifdef GLENCORE - if (encoremap) - { - j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; - //CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation - color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below - } -#endif - color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly - sec->extra_colormap->rgba = color.rgba; - - // alpha - if (msd->toptexture[7]) - sec->extra_colormap->rgba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->rgba += (25 << 24); - - /*nearest = NearestColor( - (HEX2INT(col[1]) << 4) + (HEX2INT(col[2]) << 0), - (HEX2INT(col[3]) << 4) + (HEX2INT(col[4]) << 0), - (HEX2INT(col[5]) << 4) + (HEX2INT(col[6]) << 0) - ); - - sec->extra_colormap->rgba = - pLocalPalette[nearest].s.red + - (pLocalPalette[nearest].s.green << 8) + - (pLocalPalette[nearest].s.blue << 16);*/ - } - else - sec->extra_colormap->rgba = 0; - - if (msd->bottomtexture[0] == '#' && msd->bottomtexture[1] && msd->bottomtexture[2] && msd->bottomtexture[3] && msd->bottomtexture[4] && msd->bottomtexture[5] && msd->bottomtexture[6]) - { - col = msd->bottomtexture; - - // do the exact same thing as above here. - - color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); - color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); - color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); - -#ifdef GLENCORE - if (encoremap) - { - j = encoremap[NearestColor(color.s.red, color.s.green, color.s.blue)]; - //CONS_Printf("R_CreateColormap: encoremap[%d] = %d\n", j, encoremap[j]); -- moved encoremap upwards for optimisation - color = pLocalPalette[j]; // note: this sets alpha to 255, we will reset it below - } -#endif - color.s.alpha = 0; // reset/init the alpha, so the addition below will work correctly - sec->extra_colormap->fadergba = color.rgba; - - // alpha - if (msd->bottomtexture[7]) - sec->extra_colormap->fadergba += (ALPHA2INT(col[7]) << 24); - else - sec->extra_colormap->fadergba += (25 << 24); - } - else - sec->extra_colormap->fadergba = 0x19000000; // default alpha, (25 << 24) -#undef ALPHA2INT -#undef HEX2INT - } - else - { - if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1) - sd->toptexture = 0; - else - sd->toptexture = num; - - if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1) - sd->midtexture = 0; - else - sd->midtexture = num; - - if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1) - sd->bottomtexture = 0; - else - sd->bottomtexture = num; - } - break; - } -#endif - + P_LoadSideColormaps(msd, sd, sec); + break; case 413: // Change music - { - char process[8+1]; - - sd->toptexture = sd->midtexture = sd->bottomtexture = 0; - if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') - { - M_Memcpy(process,msd->bottomtexture,8); - process[8] = '\0'; - sd->bottomtexture = get_number(process); - } - - if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0') - { - M_Memcpy(process,msd->midtexture,8); - process[8] = '\0'; - sd->midtexture = get_number(process); - } - - // always process if back sidedef, because we need that - symbol - sd->text = Z_Malloc(7, PU_LEVEL, NULL); - if (i == 1 || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') - { - M_Memcpy(process,msd->toptexture,8); - process[8] = '\0'; - - // If they type in O_ or D_ and their music name, just shrug, - // then copy the rest instead. - if ((process[0] == 'O' || process[0] == 'D') && process[7]) - M_Memcpy(sd->text, process+2, 6); - else // Assume it's a proper music name. - M_Memcpy(sd->text, process, 6); - sd->text[6] = 0; - } - else - sd->text[0] = 0; + P_LoadSideChangeMusic((i == 1), msd, sd); break; - } - case 4: // Speed pad parameters case 414: // Play SFX { @@ -1581,7 +1577,6 @@ static void P_LoadRawSideDefs2(void *data) } break; } - case 9: // Mace parameters case 14: // Bustable block parameters case 15: // Fan particle spawner parameters @@ -1601,9 +1596,9 @@ static void P_LoadRawSideDefs2(void *data) if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') M_Memcpy(process+strlen(process), msd->bottomtexture, 8); sd->toptexture = get_number(process); + break; } - case 443: // Calls a named Lua function { char process[8*3+1]; @@ -1619,9 +1614,9 @@ static void P_LoadRawSideDefs2(void *data) M_Memcpy(process+strlen(process), msd->bottomtexture, 8); sd->text = Z_Malloc(strlen(process)+1, PU_LEVEL, NULL); M_Memcpy(sd->text, process, strlen(process)+1); + break; } - default: // normal cases if (msd->toptexture[0] == '#') { @@ -1641,6 +1636,7 @@ static void P_LoadRawSideDefs2(void *data) break; } } + R_ClearTextureNumCache(true); } @@ -2317,6 +2313,7 @@ static void P_LevelInitStuff(boolean reloadinggamestate) gamespeed = 0; else gamespeed = (UINT8)cv_kartspeed.value; + franticitems = (boolean)cv_kartfrantic.value; comeback = (boolean)cv_kartcomeback.value; } @@ -2325,43 +2322,6 @@ static void P_LevelInitStuff(boolean reloadinggamestate) battlewanted[i] = -1; } -// -// P_LoadThingsOnly -// -// "Reloads" a level, but only reloads all of the mobjs. -// -void P_LoadThingsOnly(void) -{ - // Search through all the thinkers. - mobj_t *mo; - thinker_t *think; - - virtres_t* virt = vres_GetMap(lastloadedmaplumpnum); - virtlump_t* vth = vres_Find(virt, "THINGS"); - - for (think = thinkercap.next; think != &thinkercap; think = think->next) - { - if (think->function.acp1 != (actionf_p1)P_MobjThinker) - continue; // not a mobj thinker - - mo = (mobj_t *)think; - - if (mo) - P_RemoveMobj(mo); - } - - P_LevelInitStuff(false); - - memset(localaiming, 0, sizeof(localaiming)); - - P_PrepareRawThings(vth->data); - P_LoadThings(); - - vres_Free(virt); - - P_SpawnSecretItems(true); -} - /** Compute MD5 message digest for bytes read from memory source * * The resulting message digest number will be written into the 16 bytes @@ -2672,11 +2632,6 @@ static void P_InitCamera(void) displayplayers[0] = consoleplayer; // Start with your OWN view, please! } -static boolean P_CanSave(void) -{ - return false; // SRB2Kart: no SP, no saving. -} - struct minimapinfo minimapinfo; static void P_InitMinimapInfo(void) { @@ -2824,13 +2779,7 @@ static void P_SetupPlayer(void) else // gametype is GT_COOP or GT_RACE { players[i].mo = NULL; - - if (players[i].starposttime) - { - G_SpawnPlayer(i, true); - } - else - G_SpawnPlayer(i, false); + G_SpawnPlayer(i, (players[i].starposttime)); } } } @@ -3133,9 +3082,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) if (rendermode == render_opengl) { HWR_FreeExtraSubsectors(); - // Create plane polygons. - HWR_LoadLevel(); + HWR_LoadLevel(reloadinggamestate); } #endif @@ -3178,9 +3126,6 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) P_RunCachedActions(); - if (P_CanSave()) - G_SaveGame((UINT32)cursaveslot); - if (savedata.lives > 0) { players[consoleplayer].continues = savedata.continues; @@ -3285,7 +3230,8 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) CONS_Printf(M_GetText("Errors occurred while loading %s; not added.\n"), wadfilename); return UINT16_MAX; } - else wadnum = (UINT16)(numwadfiles-1); + + wadnum = (UINT16)(numwadfiles-1); if (wadfiles[wadnum]->important) partadd_important = true; diff --git a/src/p_setup.h b/src/p_setup.h index f0ae13e6c..97209e154 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -60,10 +60,10 @@ extern size_t nummapthings; extern mapthing_t *mapthings; void P_SetupLevelSky(INT32 skynum, boolean global); -void P_LoadThingsOnly(void); boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate); + #ifdef HWRENDER -void HWR_LoadLevel(void); +void HWR_LoadLevel(boolean reloadinggamestate); #endif boolean P_AddWadFile(const char *wadfilename, boolean local); diff --git a/src/p_slopes.c b/src/p_slopes.c index e64cd6f6b..b4ebf0284 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -500,6 +500,7 @@ void P_SpawnSlope_Line(int linenum) P_CalculateSlopeNormal(cslope); } } + if (backfloor || backceil) { line->backsector->hasslope = true; // Tell the software renderer that we're sloped @@ -511,7 +512,7 @@ void P_SpawnSlope_Line(int linenum) extent = P_GetExtent(line->backsector, line); - if(extent < 0) + if (extent < 0) { CONS_Printf("P_SpawnSlope_Line failed to get backsector extent on line number %i\n", linenum); return; @@ -678,8 +679,6 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag return ret; } - - // // P_CopySectorSlope // diff --git a/src/p_user.c b/src/p_user.c index c9712048e..31e6a52ef 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4436,40 +4436,38 @@ DoABarrelRoll (player_t *player) player->tilt = slope; } -#define SPINOUTROTSPEED (24 * FRACUNIT) -#define MAXSPINROT (360 * FRACUNIT) - -static void P_DoFunnyDance (player_t *player) +// mhhm this is definitely not mostly copy pasted code from SRB2s music test (: +// TODO: make this sane lmao +static void P_DoFunnyDance(player_t *player) { - static tic_t time = 0; - fixed_t bounce; - fixed_t work, bpm; - angle_t ang; + static const fixed_t bpm = 983040; // 140bpm ish if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty_jump) // this looks jank as hell during hop return; - bounce = 0; + player->squishdance.bounce = 0; - // bpm = FLOAT_TO_FIXED(mapmusic.bpm) << maybe can get the tempo and beat detection lib to work for bpm autodetection - bpm = FixedDiv((60*TICRATE)<squishdance.work = (player->squishdance.time << FRACBITS) % bpm; - if (time >= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes - time = (work>>FRACBITS); + if (player->squishdance.time >= (FRACUNIT >> 1)) // prevent overflow jump - takes about 15 minutes + player->squishdance.time = (player->squishdance.work >> FRACBITS); - work = FixedDiv(work*180, bpm); + player->squishdance.work = FixedDiv(player->squishdance.work*180, bpm); - ang = (FixedAngle(work)>>ANGLETOFINESHIFT) & FINEMASK; - bounce = (FINESINE(ang) - FRACUNIT/2); + player->squishdance.ang = ((FixedAngle(player->squishdance.work) >> ANGLETOFINESHIFT) & FINEMASK); + player->squishdance.bounce = ((FINESINE(player->squishdance.ang) - FRACUNIT/2) / 2); - player->mo->spritexscale -= bounce/2; - player->mo->spriteyscale += bounce/2; + player->mo->spritexscale -= player->squishdance.bounce; + player->mo->spriteyscale += player->squishdance.bounce; - time++; // bruh + player->squishdance.time++; } +#define SPINOUTROTSPEED (24 * FRACUNIT) +#define MAXSPINROT (360 * FRACUNIT) + // // P_PlayerThink // @@ -5009,13 +5007,16 @@ void P_PlayerThink(player_t *player) if (cv_squishdance.value && (cmd->buttons & BT_CUSTOM3)) { - player->dancetime++; + player->squishdance.countdown++; - if (player->dancetime > TICRATE*2) + if (player->squishdance.countdown > TICRATE*2) P_DoFunnyDance(player); } else - player->dancetime = 0; + { + player->squishdance.countdown = 0; + player->squishdance.time = 0; + } // Flash player after being hit. if (!(player->kartstuff[k_hyudorotimer] // SRB2kart - fixes Hyudoro not flashing when it should. diff --git a/src/tables.c b/src/tables.c index e293842bc..98a2c8a17 100644 --- a/src/tables.c +++ b/src/tables.c @@ -274,7 +274,7 @@ boolean FV2_InsidePolygon(const vector2_t *vIntersection, const vector2_t *Poly, // with floating point numbers. It usually won't always be perfectly 2 * PI, so we need // to use a little twiddling. I use .9999, but you can change this to fit your own desired accuracy. - if(Angle >= ANGLE_MAX) // If the angle is greater than 2 PI, (360 degrees) + if (Angle >= ANGLE_MAX) // If the angle is greater than 2 PI, (360 degrees) return 1; // The point is inside of the polygon return 0; // If you get here, it obviously wasn't inside the polygon.