diff --git a/bin/Linux64/Release/.gitignore b/bin/Linux64/Release/.gitignore index 56dee6f95..c63fd53bc 100644 --- a/bin/Linux64/Release/.gitignore +++ b/bin/Linux64/Release/.gitignore @@ -1 +1 @@ -/lsdlsrb2 +/lsdl2srb2kart diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 3e791f7ab..c03584043 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1913,15 +1913,6 @@ static void CL_LoadReceivedSavegame(void) demo.title = false; automapactive = false; - if (!postautoloaded) - { - CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); - if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) - CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfilespost); - postautoloaded = true; - } - // load a base level if (P_LoadNetGame()) { @@ -4308,6 +4299,8 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) if (server && multiplayer && motd[0] != '\0') COM_BufAddText(va("sayto %d %s\n", newplayernum, motd)); + D_AddAutoloadFiles(); + LUAh_PlayerJoin(newplayernum); if (newplayernum == consoleplayer) diff --git a/src/d_main.c b/src/d_main.c index e53cdfb6b..f23e64566 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -103,11 +103,12 @@ static char *startupwadfiles[MAX_WADFILES]; static char *startuppwads[MAX_WADFILES]; // autoloading -static char *autoloadwadfiles[MAX_WADFILES]; +char *autoloadwadfiles[MAX_WADFILES]; char *autoloadwadfilespost[MAX_WADFILES]; boolean autoloading; boolean autoloaded; -boolean postautoloaded; +boolean postautoloaded = false; +boolean wasautoloaded = false; boolean devparm = false; // started game with -devparm @@ -263,7 +264,10 @@ static boolean D_Display(void) SCR_Recalc(); // NOTE! setsizeneeded is set by SCR_Recalc() if (rendermode == render_soft && !splitscreen) + { + R_InterpolateViewRollAngle(rendertimefrac); R_CheckViewMorph(); + } // change the view size if needed if (setsizeneeded) @@ -1035,7 +1039,10 @@ static void D_FindAddonsToAutoload(void) // If the file is found, run our shit if (!autoloadconfigfile) // nope outta here + { + wasautoloaded = postautoloaded = true; // so D_AddAutoloadFiles can skip everything since nothings there to autoload return; + } while (fgets(wadsToAutoload, sizeof wadsToAutoload, autoloadconfigfile) != NULL) { @@ -1102,6 +1109,32 @@ static void D_FindAddonsToAutoload(void) fclose(autoloadconfigfile); } +void D_AddAutoloadFiles(void) +{ + if (wasautoloaded && postautoloaded) + return; + + if (!wasautoloaded && !modeattacking) + { + CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); + if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) + CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); + D_CleanFile(autoloadwadfiles); + + wasautoloaded = true; + } + + if ((!postautoloaded) && netgame) + { + CONS_Printf("D_AutoloadFile(): Loading postloaded addons...\n"); + if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0) + CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); + D_CleanFile(autoloadwadfilespost); + + postautoloaded = true; + } +} + void D_CleanFile(char **filearray) { size_t pnumwadfiles; @@ -1788,11 +1821,6 @@ void D_SRB2Main(void) CONS_Printf("ST_Init(): Init status bar.\n"); ST_Init(); - CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n"); - if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0) - CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n"); - D_CleanFile(autoloadwadfiles); - // Set up splitscreen players before joining! if (!dedicated && (M_CheckParm("-splitscreen") && M_IsNextParm())) { diff --git a/src/d_main.h b/src/d_main.h index 23fb31619..d4d3e6e95 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -43,12 +43,15 @@ extern boolean statdp; // stat display for extended player setup extern boolean nametaggfx; // Nametag stuffs extern boolean driftgaugegfx; +void D_AddAutoloadFiles(void); extern boolean autoloading; extern boolean autoloaded; extern boolean postautoloaded; +extern boolean wasautoloaded; extern char *autoloadwadfilespost[MAX_WADFILES]; +extern char *autoloadwadfiles[MAX_WADFILES]; // the infinite loop of D_SRB2Loop() called from win_main for windows version void D_SRB2Loop(void) FUNCNORETURN; diff --git a/src/d_player.h b/src/d_player.h index 4d61474fb..28ab11286 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -347,6 +347,14 @@ typedef enum RW_RAIL = 32 } ringweapons_t; +// enum for saved lap times +typedef enum +{ + LAP_CUR, + LAP_LAST, + LAP__MAX +} laptime_e; + // ======================================================================== // PLAYER STRUCTURE // ======================================================================== @@ -465,6 +473,7 @@ typedef struct player_s INT16 numboxes; // Number of item boxes obtained for Race Mode INT16 totalring; // Total number of rings obtained for Race Mode tic_t realtime; // integer replacement for leveltime + tic_t laptime[LAP__MAX]; UINT8 laps; // Number of laps (optional) //////////////////// @@ -541,11 +550,6 @@ typedef struct player_s #ifdef HWRENDER fixed_t fovadd; // adjust FOV for hw rendering #endif - - struct { - angle_t aiming, awayviewaiming, frameangle; - angle_t viewrollangle; - } lerp; } player_t; #endif diff --git a/src/g_game.c b/src/g_game.c index 552cedfd7..22b051024 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2500,6 +2500,10 @@ void G_PlayerReborn(INT32 player) boolean fade; boolean playing; + tic_t laptime[LAP__MAX]; + + INT32 i; + score = players[player].score; marescore = players[player].marescore; lives = players[player].lives; @@ -2541,6 +2545,21 @@ void G_PlayerReborn(INT32 player) bot = players[player].bot; pity = players[player].pity; + if (leveltime <= starttime) // man i really hope this crap works kek but need to reset this somehow at mapstart + { + for (i = 0; i < LAP__MAX; i++) + { + laptime[i] = 0; + } + } + else + { + for (i = 0; i < LAP__MAX; i++) + { + laptime[i] = players[player].laptime[i]; + } + } + // SRB2kart if (leveltime <= starttime || spectator == true) { @@ -2632,6 +2651,11 @@ void G_PlayerReborn(INT32 player) p->laps = laps; p->totalring = totalring; + for (i = 0; i < LAP__MAX; i++) + { + p->laptime[i] = laptime[i]; + } + p->mare = mare; if (bot) p->bot = 1; // reset to AI-controlled diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index dddb895b2..676c018d1 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -67,6 +67,8 @@ static boolean gr_palette_rendering_state = false; // Commands and console variables // ========================================================================== +static void HWR_RollTransform(FTransform *tr, angle_t roll); + #ifdef USE_FBO_OGL static void CV_grframebuffer_OnChange(void); #endif @@ -204,6 +206,10 @@ static void CV_grshaders_OnChange(void) static void CV_grpaletterendering_OnChange(void) { ONLY_IF_GL_LOADED + + if (cv_grscreentextures.value != 2) // can't do palette rendering without screen textures + CV_Set(&cv_grpaletterendering, "Off"); + if (gr_shadersavailable) { HWR_CompileShaders(); @@ -231,6 +237,12 @@ static void CV_grpalettedepth_OnChange(void) static void CV_grframebuffer_OnChange(void) { ONLY_IF_GL_LOADED + if (cv_grscreentextures.value != 2) + { // screen FBO needs screen textures +#ifdef USE_FBO_OGL + CV_Set(&cv_grframebuffer, "Off"); +#endif + } HWD.pfnSetSpecialState(HWD_SET_FRAMEBUFFER, cv_grframebuffer.value); I_DownSample(); RefreshOGLSDLSurface(); @@ -2860,41 +2872,45 @@ void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, blendmode, shader, false); } -void HWR_AddPolyObjectPlanes(void) +static void HWR_AddPolyObjectPlanes(void) { size_t i; sector_t *polyobjsector; + INT32 light = 0; // Polyobject Planes need their own function for drawing because they don't have extrasubsectors by themselves // It should be okay because polyobjects should always be convex anyway for (i = 0; i < numpolys; i++) { + polyobjsector = po_ptrs[i]->lines[0]->backsector; // the in-level polyobject sector + if (!(po_ptrs[i]->flags & POF_RENDERPLANES)) // Only render planes when you should continue; if (po_ptrs[i]->translucency >= NUMTRANSMAPS) continue; - - polyobjsector = po_ptrs[i]->lines[0]->backsector; // the in-level polyobject sector if (polyobjsector->floorheight <= gr_frontsector->ceilingheight && polyobjsector->floorheight >= gr_frontsector->floorheight && (viewz < polyobjsector->floorheight)) { + light = R_GetPlaneLight(gr_frontsector, polyobjsector->floorheight, true); if (po_ptrs[i]->translucency > 0) { FSurfaceInfo Surf; - FBITFIELD blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); + FBITFIELD blendmode; + memset(&Surf, 0x00, sizeof(Surf)); + blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight, - polyobjsector->lightlevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : gr_frontsector->lightlist[light].extra_colormap)); } else { HWR_GetFlat(levelflats[polyobjsector->floorpic].lumpnum, R_NoEncore(polyobjsector, false)); HWR_RenderPolyObjectPlane(po_ptrs[i], false, polyobjsector->floorheight, PF_Occlude, - polyobjsector->lightlevel, levelflats[polyobjsector->floorpic].lumpnum, - polyobjsector, 255, NULL); + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), levelflats[polyobjsector->floorpic].lumpnum, + polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : gr_frontsector->lightlist[light].extra_colormap)); } } @@ -2902,6 +2918,7 @@ void HWR_AddPolyObjectPlanes(void) && polyobjsector->ceilingheight <= gr_frontsector->ceilingheight && (viewz > polyobjsector->ceilingheight)) { + light = R_GetPlaneLight(gr_frontsector, polyobjsector->ceilingheight, true); if (po_ptrs[i]->translucency > 0) { FSurfaceInfo Surf; @@ -2909,14 +2926,14 @@ void HWR_AddPolyObjectPlanes(void) memset(&Surf, 0x00, sizeof(Surf)); blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf); HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight, - polyobjsector->lightlevel, Surf.PolyColor.s.alpha, polyobjsector, blendmode, NULL); + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gr_frontsector->extra_colormap : gr_frontsector->lightlist[light].extra_colormap)); } else { HWR_GetFlat(levelflats[polyobjsector->ceilingpic].lumpnum, R_NoEncore(polyobjsector, true)); HWR_RenderPolyObjectPlane(po_ptrs[i], true, polyobjsector->ceilingheight, PF_Occlude, - polyobjsector->lightlevel, levelflats[polyobjsector->ceilingpic].lumpnum, - polyobjsector, 255, NULL); + (light == -1 ? gr_frontsector->lightlevel : *gr_frontsector->lightlist[light].lightlevel), levelflats[polyobjsector->ceilingpic].lumpnum, + polyobjsector, 255, (light == -1 ? gr_frontsector->extra_colormap : gr_frontsector->lightlist[light].extra_colormap)); } } } @@ -3661,7 +3678,7 @@ static void HWR_RotateSpritePolyToAim(gr_vissprite_t *spr, FOutVector *wallVerts } } - if (P_MobjFlip(spr->mobj) == -1) + if (!precip && P_MobjFlip(spr->mobj) == -1) // precip doesn't have eflags so they can't flip { basey = FIXED_TO_FLOAT(interp.z + spr->mobj->height); } @@ -5024,7 +5041,7 @@ void HWR_ProjectSprite(mobj_t *thing) } heightsec = thing->subsector->sector->heightsec; - if (viewplayer->mo && viewplayer->mo->subsector) + if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; else phs = -1; @@ -5273,8 +5290,7 @@ void HWR_DrawSkyBackground(float fpov) dometransform.scalez = 1; dometransform.fovxangle = fpov; // Tails dometransform.fovyangle = fpov; // Tails - dometransform.rollangle = atransform.rollangle; - dometransform.roll = atransform.roll; + HWR_RollTransform(&dometransform, viewroll); dometransform.splitscreen = splitscreen; HWR_GetTexture(texturetranslation[skytexture], false); @@ -5369,12 +5385,7 @@ void HWR_SetTransform(float fpov, player_t *player) atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails - if (player->viewrollangle != 0) - { - fixed_t rol = AngleFixed(player->viewrollangle); - atransform.rollangle = FIXED_TO_FLOAT(rol); - atransform.roll = true; - } + HWR_RollTransform(&atransform, viewroll); atransform.splitscreen = splitscreen; for (i = 0; i <= splitscreen; i++) @@ -5707,6 +5718,16 @@ void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) // ========================================================================== // Render the player view. // ========================================================================== + +static void HWR_RollTransform(FTransform *tr, angle_t roll) +{ + if (roll != 0) + { + tr->rollangle = roll / (float)ANG1; + tr->roll = true; + } +} + void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) { const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on @@ -5746,6 +5767,17 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) void HWR_LoadLevel(void) { + // Lactozilla (December 8, 2019) + // Level setup used to free EVERY mipmap from memory. + // Even mipmaps that aren't related to level textures. + // Presumably, the hardware render code used to store textures as level data. + // Meaning, they had memory allocated and marked with the PU_LEVEL tag. + // Level textures are only reloaded after R_LoadTextures, which is + // when the texture list is loaded. + + // Sal: Unfortunately, NOT freeing them causes the dreaded Color Bug. + HWR_FreeMipmapCache(); + HWR_CreatePlanePolygons((INT32)numnodes - 1); if (HWR_ShouldUsePaletteRendering()) diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 5c99a77f4..dc87ee986 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -120,7 +120,6 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc void HWR_AddTransparentFloor(lumpnum_t lumpnum, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, boolean fogplane, extracolormap_t *planecolormap); void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, FBITFIELD blendmode, UINT8 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap); -void HWR_AddPolyObjectPlanes(void); void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *polysector, boolean isceiling, fixed_t fixedheight, INT32 lightlevel, INT32 alpha, sector_t *FOFSector, FBITFIELD blend, extracolormap_t *planecolormap); // hw_main.c: Segs diff --git a/src/k_kart.c b/src/k_kart.c index fb955cde2..3f134ef33 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -16,6 +16,7 @@ #include "m_random.h" #include "m_menu.h" // ffdhidshfuisduifigergho9igj89dgodhfih AAAAAAAAAA #include "p_local.h" +#include "p_setup.h" #include "p_slopes.h" #include "r_defs.h" #include "r_draw.h" @@ -38,6 +39,7 @@ #include "lua_hook.h" // For MobjDamage and ShouldDamage #include "d_main.h" // found_extra_kart + #include "i_video.h" #ifdef HWRENDER @@ -75,6 +77,7 @@ IMPL_HUD_OFFSET(stat); // Stats //extra hud things consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; consvar_t cv_newspeedometer = {"newspeedometer", "Default", CV_SAVE, speedo_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -721,6 +724,7 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_showstats); CV_RegisterVar(&cv_showinput); + CV_RegisterVar(&cv_showlaptimes); CV_RegisterVar(&cv_newspeedometer); CV_RegisterVar(&cv_battlespeedo); @@ -4092,6 +4096,9 @@ void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source) mobj_t *cachenext; killnext: + if (P_MobjWasRemoved(banana)) + return; + cachenext = banana->hnext; if (banana->health) @@ -4132,6 +4139,13 @@ void K_UpdateHnextList(player_t *player, boolean clean) P_RemoveMobj(work); } + + if (player->mo->hnext == NULL || P_MobjWasRemoved(player->mo->hnext)) + { + // Like below, try to clean up the pointer if it's NULL. + // Maybe this was a cause of the shrink/eggbox fails? + P_SetTarget(&player->mo->hnext, NULL); + } } // For getting hit! @@ -4379,10 +4393,8 @@ void K_RepairOrbitChain(mobj_t *orbit) } // Then recount to make sure item amount is correct - if (orbit->target && orbit->target->player) + if (orbit->target && orbit->target->player && !P_MobjWasRemoved(orbit->target)) { - player_t *player = orbit->target->player; - INT32 num = 0; mobj_t *cur = orbit->target->hnext; @@ -4392,14 +4404,14 @@ void K_RepairOrbitChain(mobj_t *orbit) { prev = cur; cur = cur->hnext; - if (++num > player->kartstuff[k_itemamount]) + if (++num > orbit->target->player->kartstuff[k_itemamount]) P_RemoveMobj(prev); else prev->movedir = num; } - if (player->kartstuff[k_itemamount] != num) - player->kartstuff[k_itemamount] = num; + if (orbit->target && !P_MobjWasRemoved(orbit->target) && orbit->target->player->kartstuff[k_itemamount] != num) + orbit->target->player->kartstuff[k_itemamount] = num; } } @@ -4412,6 +4424,7 @@ static void K_MoveHeldObjects(player_t *player) if (!player->mo->hnext) { player->kartstuff[k_bananadrag] = 0; + if (player->kartstuff[k_eggmanheld]) player->kartstuff[k_eggmanheld] = 0; else if (player->kartstuff[k_itemheld]) @@ -4427,6 +4440,7 @@ static void K_MoveHeldObjects(player_t *player) // we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic... P_SetTarget(&player->mo->hnext, NULL); player->kartstuff[k_bananadrag] = 0; + if (player->kartstuff[k_eggmanheld]) player->kartstuff[k_eggmanheld] = 0; else if (player->kartstuff[k_itemheld]) @@ -8117,8 +8131,6 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI { // TIME_X = BASEVIDWIDTH-124; // 196 // TIME_Y = 6; // 6 - - tic_t worktime; INT32 splitflags = 0; if (!mode) @@ -8143,63 +8155,54 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI TX += 33; - worktime = drawtime/(60*TICRATE); - - if (mode && !drawtime) - V_DrawKartString(TX, TY+3, splitflags, va("--'--\"--")); - else if (worktime < 100) // 99:99:99 only + if (drawtime == UINT32_MAX) + ; + else if (mode && !drawtime) { + // apostrophe location _'__ __ + V_DrawKartString(TX+24, TY+3, splitflags, va("'")); + + // quotation mark location _ __"__ + V_DrawKartString(TX+60, TY+3, splitflags, va("\"")); + } + else + { + tic_t worktime = drawtime/(60*TICRATE); + + if (worktime >= 100) + { + worktime = 99; + drawtime = (100*(60*TICRATE))-1; + } + if ((cv_timelimit.value && G_BattleGametype()) && (!players[consoleplayer].exiting && (leveltime > (timelimitintics + starttime + TICRATE/2)) && cv_overtime.value)) // i hate this so much { V_DrawKartString(TX, TY+3, splitflags, va("OVERTIME")); - return; + return; } - - // zero minute - if (worktime < 10) - { - V_DrawKartString(TX, TY+3, splitflags, va("0")); - // minutes time 0 __ __ - V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime)); - } - // minutes time 0 __ __ - else - V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime)); + + // minutes time 00 __ __ + V_DrawKartString(TX, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+12, TY+3, splitflags, va("%d", worktime%10)); // apostrophe location _'__ __ V_DrawKartString(TX+24, TY+3, splitflags, va("'")); worktime = (drawtime/TICRATE % 60); - // zero second _ 0_ __ - if (worktime < 10) - { - V_DrawKartString(TX+36, TY+3, splitflags, va("0")); - // seconds time _ _0 __ - V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime)); - } - // zero second _ 00 __ - else - V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime)); + // seconds time _ 00 __ + V_DrawKartString(TX+36, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+48, TY+3, splitflags, va("%d", worktime%10)); // quotation mark location _ __"__ V_DrawKartString(TX+60, TY+3, splitflags, va("\"")); worktime = G_TicsToCentiseconds(drawtime); - // zero tick _ __ 0_ - if (worktime < 10) - { - V_DrawKartString(TX+72, TY+3, splitflags, va("0")); - // tics _ __ _0 - V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime)); - } - // zero tick _ __ 00 - else - V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime)); + // tics _ __ 00 + V_DrawKartString(TX+72, TY+3, splitflags, va("%d", worktime/10)); + V_DrawKartString(TX+84, TY+3, splitflags, va("%d", worktime%10)); } - else if ((drawtime/TICRATE) & 1) - V_DrawKartString(TX, TY+3, splitflags, va("99'59\"99")); if (emblemmap && (modeattacking || (mode == 1)) && !demo.playback) // emblem time! { @@ -10498,9 +10501,27 @@ void K_drawKartHUD(void) // If not splitscreen, draw... if (!splitscreen && !demo.title) { + tic_t realtime = stplyr->realtime; + + if (cv_showlaptimes.value + && stplyr->kartstuff[k_lapanimation] + && !stplyr->exiting + && stplyr->laptime[LAP_LAST] != 0 + && !midgamejoin) + { + if ((stplyr->kartstuff[k_lapanimation] / 5) & 1) + { + realtime = stplyr->laptime[LAP_LAST]; + } + else + { + realtime = UINT32_MAX; + } + } + // Draw the timestamp if (LUA_HudEnabled(hud_time)) - K_drawKartTimestamp(stplyr->realtime, TIME_X, TIME_Y, gamemap, 0); + K_drawKartTimestamp(realtime, TIME_X, TIME_Y, gamemap, 0); if (!modeattacking) { diff --git a/src/k_kart.h b/src/k_kart.h index 06195280d..1f95aefe2 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -31,6 +31,7 @@ extern consvar_t cv_highresportrait; extern consvar_t cv_stat_xoffset; extern consvar_t cv_stat_yoffset; extern consvar_t cv_showstats; +extern consvar_t cv_showlaptimes; extern consvar_t cv_battlespeedo; #define NUMSPEEDOSTUFF 6 diff --git a/src/lua_script.c b/src/lua_script.c index 160c92180..6528a515e 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -1432,7 +1432,12 @@ static void UnArchiveExtVars(void *pointer) if (field_count == 0) return; - I_Assert(gL != NULL); + + // Technically possible new, since server may have local lua scripts but no "public" ones, so + // field_count would be non zero (there is no way to tell local field from non-local, so + // everything gets archived) + if (!gL) + return; TABLESINDEX = lua_gettop(gL); lua_createtable(gL, 0, field_count); // pointer's ext vars subtable diff --git a/src/m_menu.c b/src/m_menu.c index f824f379b..321125e5e 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2020,31 +2020,32 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 25}, {IT_STRING | IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 30}, {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 35}, - {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 40}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 45}, - {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 50}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 55}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 60}, - {IT_STRING | IT_CVAR, NULL, "Show Minimap Names", &cv_showminimapnames, 65}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 70}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Times", &cv_showlaptimes, 40}, + {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 45}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 50}, + {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 55}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 60}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 65}, + {IT_STRING | IT_CVAR, NULL, "Show Minimap Names", &cv_showminimapnames, 70}, + {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 75}, - {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 80}, + {IT_STRING | IT_CVAR, NULL, "Uncapped HUD", &cv_uncappedhud, 85}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 85}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 90}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 95}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 90}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 95}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 100}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 105}, + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 110}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 115}, + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 120}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 125}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 130}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 130}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 135}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 140}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 150}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 155}, // uwu + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 160}, // uwu }; static const char* OP_SaturnTooltips[] = @@ -2055,6 +2056,7 @@ static const char* OP_SaturnTooltips[] = "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", "Change what style the speedometer is.", "Enable the stat display.", + "Show Lap Time when doing a Lap on the Timer.", "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "Enable colourized hud.", "Enable the colourized itembox when colourized hud is enabled.", @@ -2083,6 +2085,7 @@ enum sm_input, sm_speedometer, sm_statdisplay, + sm_laptime, sm_highresport, sm_colorhud, sm_coloritem, diff --git a/src/m_misc.c b/src/m_misc.c index c40848ecd..b8c88abb5 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -334,6 +334,38 @@ boolean FIL_FileOK(char const *name) return access(name,6)+1; //R_OK|W_OK } +/** Copies contents of one file to another + * + * \param src File to copy from + * \param dst File to write into + * \return true if copy was succesful, false if it doesn't. + */ +boolean FIL_CopyFile(const char *src, const char *dst) +{ + FILE *srcFile = fopen(src, "rb"); + + if (srcFile == NULL) + return false; + + FILE *dstFile = fopen(dst, "wb"); + + if (dstFile == NULL) + { + fclose(srcFile); + return false; + } + + char buffer[1024]; + size_t n; + + while ((n = fread(buffer, 1, sizeof(buffer), srcFile)) > 0) + fwrite(buffer, 1, n, dstFile); + + fclose(srcFile); + fclose(dstFile); + + return true; +} /** Checks if a pathname has a file extension and adds the extension provided * if not. @@ -525,11 +557,28 @@ void M_SaveConfig(const char *filename) { FILE *f; char *filepath; + char backupfile[MAX_WADPATH+4]; // make sure not to write back the config until it's been correctly loaded if (!gameconfig_loaded) return; + // Create backup of the config file + snprintf(backupfile, sizeof backupfile, "%s.bak", configfile); + backupfile[sizeof backupfile - 1] = '\0'; + + FILE *config = fopen(configfile, "r"); + + if (config != NULL) + { + fclose(config); + if (FIL_CopyFile(configfile, backupfile) == false) + { + CONS_Alert(CONS_WARNING,"Failed to create a backup of the configuration file. Will not attempt to write to file\n"); + return; + } + } + // can change the file name if (filename) { diff --git a/src/m_misc.h b/src/m_misc.h index 103b1d88a..333398161 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -54,6 +54,7 @@ boolean FIL_FileExists(const char *name); boolean FIL_WriteFileOK(char const *name); boolean FIL_ReadFileOK(char const *name); boolean FIL_FileOK(char const *name); +boolean FIL_CopyFile(const char *src, const char *dst); void FIL_DefaultExtension (char *path, const char *extension); void FIL_ForceExtension(char *path, const char *extension); diff --git a/src/p_inter.c b/src/p_inter.c index 90bb3f8da..c23bfe286 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -254,26 +254,21 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (heightcheck) { - /*if (special->type == MT_FLINGEMERALD) // little hack here... - { // flingemerald sprites are low to the ground, so extend collision radius down some. - if (toucher->z > (special->z + special->height)) - return; - if (special->z - special->height > (toucher->z + toucher->height)) - return; - } - else*/ + if (toucher->momz < 0) { - if (toucher->momz < 0) { - if (toucher->z + toucher->momz > special->z + special->height) - return; - } else if (toucher->z > special->z + special->height) - return; - if (toucher->momz > 0) { - if (toucher->z + toucher->height + toucher->momz < special->z) - return; - } else if (toucher->z + toucher->height < special->z) + if (toucher->z + toucher->momz > special->z + special->height) return; } + else if (toucher->z > special->z + special->height) + return; + + if (toucher->momz > 0) + { + if (toucher->z + toucher->height + toucher->momz < special->z) + return; + } + else if (toucher->z + toucher->height < special->z) + return; } if (special->health <= 0) @@ -384,16 +379,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) player->kartstuff[k_roulettetype] = 2; } -#if 0 - // Eggbox snipe! - if (special->type == MT_EGGMANITEM && special->health > 1) - S_StartSound(toucher, sfx_bsnipe); -#endif - - { - mobj_t *poof = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); - S_StartSound(poof, special->info->deathsound); - } + mobj_t *poof = P_SpawnMobj(special->x, special->y, special->z, MT_EXPLODE); + S_StartSound(poof, special->info->deathsound); if (special->target && special->target->player) { @@ -584,10 +571,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) else K_SpinPlayer(player, special->target, 0, special, false); return; - /*case MT_EERIEFOG: - special->frame &= ~FF_TRANS80; - special->frame |= FF_TRANS90; - return;*/ case MT_SMK_MOLE: if (special->target && !P_MobjWasRemoved(special->target)) return; @@ -936,12 +919,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) player->flyangle = special->threshold; player->speed = FixedMul(special->info->speed, special->scale); - // Potentially causes axis transfer failures. - // Also rarely worked properly anyway. - //P_UnsetThingPosition(player->mo); - //player->mo->x = special->x; - //player->mo->y = special->y; - //P_SetThingPosition(player->mo); toucher->z = special->z+(special->height/4); } else // More like a spring @@ -986,140 +963,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } } return; - /*case MT_NIGHTSSUPERLOOP: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - player->powers[pw_nights_superloop] = (UINT16)special->info->speed; - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - players[i].powers[pw_nights_superloop] = (UINT16)special->info->speed; - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Super Paraloop")); - } - break; - case MT_NIGHTSDRILLREFILL: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - player->drillmeter = special->info->speed; - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - players[i].drillmeter = special->info->speed; - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Drill Refill")); - } - break; - case MT_NIGHTSHELPER: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - { - // A flicky orbits us now - mobj_t *flickyobj = P_SpawnMobj(toucher->x, toucher->y, toucher->z + toucher->info->height, MT_NIGHTOPIANHELPER); - P_SetTarget(&flickyobj->target, toucher); - - player->powers[pw_nights_helper] = (UINT16)special->info->speed; - } - else - { - mobj_t *flickyobj; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && players[i].pflags & PF_NIGHTSMODE) { - players[i].powers[pw_nights_helper] = (UINT16)special->info->speed; - flickyobj = P_SpawnMobj(players[i].mo->x, players[i].mo->y, players[i].mo->z + players[i].mo->info->height, MT_NIGHTOPIANHELPER); - P_SetTarget(&flickyobj->target, players[i].mo); - } - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Nightopian Helper")); - } - break; - case MT_NIGHTSEXTRATIME: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - { - player->nightstime += special->info->speed; - player->startedtime += special->info->speed; - P_RestoreMusic(player); - } - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - { - players[i].nightstime += special->info->speed; - players[i].startedtime += special->info->speed; - P_RestoreMusic(&players[i]); - } - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Extra Time")); - } - break; - case MT_NIGHTSLINKFREEZE: - if (player->bot || !(player->pflags & PF_NIGHTSMODE)) - return; - if (!G_IsSpecialStage(gamemap)) - { - player->powers[pw_nights_linkfreeze] = (UINT16)special->info->speed; - player->linktimer = 2*TICRATE; - } - else - { - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].pflags & PF_NIGHTSMODE) - { - players[i].powers[pw_nights_linkfreeze] += (UINT16)special->info->speed; - players[i].linktimer = 2*TICRATE; - } - if (special->info->deathsound != sfx_None) - S_StartSound(NULL, special->info->deathsound); - } - - // CECHO showing you what this item is - if (player == &players[displayplayers[0]] || G_IsSpecialStage(gamemap)) - { - HU_SetCEchoFlags(V_AUTOFADEOUT); - HU_SetCEchoDuration(4); - HU_DoCEcho(M_GetText("\\\\\\\\\\\\\\\\Link Freeze")); - } - break;*/ case MT_NIGHTSWING: if (G_IsSpecialStage(gamemap) && useNightsSS) { // Pseudo-ring. @@ -1515,23 +1358,6 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) || special->z > toucher->z + (toucher->height*2/3)) return; // Only go in the mouth - /* // SRB2kart - Can't drown. - // Eaten by player! - if (player->powers[pw_underwater] && player->powers[pw_underwater] <= 12*TICRATE + 1) - P_RestoreMusic(player); - - if (player->powers[pw_underwater] < underwatertics + 1) - player->powers[pw_underwater] = underwatertics + 1; - */ - - /* - if (!player->climbing) - { - P_SetPlayerMobjState(toucher, S_PLAY_GASP); - P_ResetPlayer(player); - } - */ - toucher->momx = toucher->momy = toucher->momz = 0; break; @@ -1588,26 +1414,7 @@ void P_CheckTimeLimit(void) if (gameaction == ga_completed) return; - //Tagmode round end but only on the tic before the - //XD_EXITLEVEL packet is received by all players. - /*if (G_TagGametype()) - { - if (leveltime == (timelimitintics + 1)) - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator - || (players[i].pflags & PF_TAGGED) || (players[i].pflags & PF_TAGIT)) - continue; - - CONS_Printf(M_GetText("%s received double points for surviving the round.\n"), player_names[i]); - P_AddPlayerScore(&players[i], players[i].score); - } - } - } - - //Optional tie-breaker for Match/CTF - else*/ if (cv_overtime.value) + if (cv_overtime.value) { INT32 playerarray[MAXPLAYERS]; INT32 tempplayer = 0; @@ -1680,9 +1487,6 @@ void P_CheckTimeLimit(void) return; P_DoPlayerExit(&players[i]); } - - /*if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0);*/ } /** Checks if a player's score is over the pointlimit and the round should end. @@ -1704,127 +1508,27 @@ void P_CheckPointLimit(void) if (G_RaceGametype()) return; - // pointlimit is nonzero, check if it's been reached by this player - /*if (G_GametypeHasTeams()) + for (i = 0; i < MAXPLAYERS; i++) { - // Just check both teams - if ((UINT32)cv_pointlimit.value <= redscore || (UINT32)cv_pointlimit.value <= bluescore) - { - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } - } - else*/ - { - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; + if (!playeringame[i] || players[i].spectator) + continue; - if ((UINT32)cv_pointlimit.value <= players[i].marescore) + if ((UINT32)cv_pointlimit.value <= players[i].marescore) + { + for (i = 0; i < MAXPLAYERS; i++) // AAAAA nested loop using the same iteration variable ;; { - for (i = 0; i < MAXPLAYERS; i++) // AAAAA nested loop using the same iteration variable ;; - { - if (!playeringame[i] || players[i].spectator) - continue; - if (players[i].exiting) - return; - P_DoPlayerExit(&players[i]); - } - - /*if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0);*/ - return; // good thing we're leaving the function immediately instead of letting the loop get mangled! + if (!playeringame[i] || players[i].spectator) + continue; + if (players[i].exiting) + return; + P_DoPlayerExit(&players[i]); } + + return; // good thing we're leaving the function immediately instead of letting the loop get mangled! } } } -/*Checks for untagged remaining players in both tag derivitave modes. - *If no untagged players remain, end the round. - *Also serves as error checking if the only IT player leaves.*/ -/*void P_CheckSurvivors(void) -{ - INT32 i; - INT32 survivors = 0; - INT32 taggers = 0; - INT32 spectators = 0; - INT32 survivorarray[MAXPLAYERS]; - - if (!D_NumPlayers()) //no players in the game, no check performed. - return; - - for (i=0; i < MAXPLAYERS; i++) //figure out counts of taggers, survivors and spectators. - { - if (playeringame[i]) - { - if (players[i].spectator) - spectators++; - else if (players[i].pflags & PF_TAGIT) - taggers++; - else if (!(players[i].pflags & PF_TAGGED)) - { - survivorarray[survivors] = i; - survivors++; - } - } - } - - if (!taggers) //If there are no taggers, pick a survivor at random to be it. - { - // Exception for hide and seek. If a round has started and the IT player leaves, end the round. - if (gametype == GT_HIDEANDSEEK && (leveltime >= (hidetime * TICRATE))) - { - CONS_Printf(M_GetText("The IT player has left the game.\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - - return; - } - - if (survivors) - { - INT32 newtagger = survivorarray[P_RandomKey(survivors)]; - - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[newtagger]); // Tell everyone who is it! - players[newtagger].pflags |= PF_TAGIT; - - survivors--; //Get rid of the guy we just made IT. - - //Yeah, we have an eligible tagger, but we may not have anybody for him to tag! - //If there is only one guy waiting on the game to fill or spectators to enter game, don't bother. - if (!survivors && (D_NumPlayers() - spectators) > 1) - { - CONS_Printf(M_GetText("All players have been tagged!\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } - - return; - } - - //If we reach this point, no player can replace the one that was IT. - //Unless it is one player waiting on a game, end the round. - if ((D_NumPlayers() - spectators) > 1) - { - CONS_Printf(M_GetText("There are no players able to become IT.\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } - - return; - } - - //If there are taggers, but no survivors, end the round. - //Except when the tagger is by himself and the rest of the game are spectators. - if (!survivors && (D_NumPlayers() - spectators) > 1) - { - CONS_Printf(M_GetText("All players have been tagged!\n")); - if (server) - SendNetXCmd(XD_EXITLEVEL, NULL, 0); - } -}*/ - // Checks whether or not to end a race netgame. boolean P_CheckRacers(void) { @@ -1944,7 +1648,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) // SRB2kart // I wish I knew a better way to do this - if (target->target && target->target->player && target->target->player->mo) + if (!P_MobjWasRemoved(target->target) && target->target->player && !P_MobjWasRemoved(target->target->player->mo)) { if (target->target->player->kartstuff[k_eggmanheld] && target->type == MT_EGGMANITEM_SHIELD) target->target->player->kartstuff[k_eggmanheld] = 0; @@ -1961,7 +1665,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) K_KillBananaChain(target->target->hnext, inflictor, source); target->target->player->kartstuff[k_itemamount] = 0; } - else + else if (target->target->player->kartstuff[k_itemamount]) target->target->player->kartstuff[k_itemamount]--; } else if ((target->type == MT_ORBINAUT_SHIELD && target->target->player->kartstuff[k_itemtype] == KITEM_ORBINAUT) // orbit items @@ -1993,14 +1697,6 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { if (metalrecording) // Ack! Metal Sonic shouldn't die! Cut the tape, end recording! G_StopMetalRecording(); - /*if (gametype == GT_MATCH && cv_match_scoring.value == 0 // note, no team match suicide penalty - && ((target == source) || (source == NULL && inflictor == NULL) || (source && !source->player))) - { // Suicide penalty - Not in Kart - if (target->player->score >= 50) - target->player->score -= 50; - else - target->player->score = 0; - }*/ target->flags2 &= ~MF2_DONTDRAW; } @@ -2017,85 +1713,6 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) target->fuse = cv_itemrespawntime.value*TICRATE + 2; // Random box generation } } - - // Award Score Tails - /*{ // Enemies shouldn't award points in Kart - INT32 score = 0; - - if (maptol & TOL_NIGHTS) // Enemies always worth 200, bosses don't do anything. - { - if ((target->flags & MF_ENEMY) && !(target->flags & (MF_MISSILE|MF_BOSS))) - { - score = 200; - - if (source->player->bonustime) - score *= 2; - - // Also, add to the link. - // I don't know if NiGHTS did this, but - // Sonic Time Attacked did and it seems like a good enough incentive - // to make people want to actually dash towards/paraloop enemies - if (++source->player->linkcount > source->player->maxlink) - source->player->maxlink = source->player->linkcount; - source->player->linktimer = 2*TICRATE; - } - } - else - { - if (target->flags & MF_BOSS) - score = 1000; - else if ((target->flags & MF_ENEMY) && !(target->flags & MF_MISSILE)) - { - mobj_t *scoremobj; - UINT32 scorestate = mobjinfo[MT_SCORE].spawnstate; - - scoremobj = P_SpawnMobj(target->x, target->y, target->z + (target->height / 2), MT_SCORE); - - // On ground? No chain starts. - if (!source->player->powers[pw_invulnerability] && P_IsObjectOnGround(source)) - { - source->player->scoreadd = 0; - score = 100; - } - // Mario Mode has Mario-like chain point values - else if (mariomode) switch (++source->player->scoreadd) - { - case 1: score = 100; break; - case 2: score = 200; scorestate += 1; break; - case 3: score = 400; scorestate += 5; break; - case 4: score = 800; scorestate += 6; break; - case 5: score = 1000; scorestate += 3; break; - case 6: score = 2000; scorestate += 7; break; - case 7: score = 4000; scorestate += 8; break; - case 8: score = 8000; scorestate += 9; break; - default: // 1up for a chain this long - if (modeattacking) // but 1ups don't exist in record attack! - { // So we just go back to 10k points. - score = 10000; scorestate += 4; break; - } - P_GivePlayerLives(source->player, 1); - P_PlayLivesJingle(source->player); - scorestate += 10; - break; - } - // More Sonic-like point system - else switch (++source->player->scoreadd) - { - case 1: score = 100; break; - case 2: score = 200; scorestate += 1; break; - case 3: score = 500; scorestate += 2; break; - case 4: case 5: case 6: case 7: case 8: case 9: - case 10: case 11: case 12: case 13: case 14: - score = 1000; scorestate += 3; break; - default: score = 10000; scorestate += 4; break; - } - - P_SetMobjState(scoremobj, scorestate); - } - } - - P_AddPlayerScore(source->player, score); - }*/ } // if a player avatar dies... @@ -2159,42 +1776,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) if (target->player == &players[displayplayers[3]]) localaiming[3] = 0; - //tag deaths handled differently in suicide cases. Don't count spectators! - /*if (G_TagGametype() - && !(target->player->pflags & PF_TAGIT) && (!source || !source->player) && !(target->player->spectator)) - { - // if you accidentally die before you run out of time to hide, ignore it. - // allow them to try again, rather than sitting the whole thing out. - if (leveltime >= hidetime * TICRATE) - { - if (gametype == GT_TAG)//suiciding in survivor makes you IT. - { - target->player->pflags |= PF_TAGIT; - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[target->player-players]); // Tell everyone who is it! - P_CheckSurvivors(); - } - else - { - if (!(target->player->pflags & PF_TAGGED)) - { - //otherwise, increment the tagger's score. - //in hide and seek, suiciding players are counted as found. - INT32 w; - - for (w=0; w < MAXPLAYERS; w++) - { - if (players[w].pflags & PF_TAGIT) - P_AddPlayerScore(&players[w], 1); - } - - target->player->pflags |= PF_TAGGED; - CONS_Printf(M_GetText("%s was found!\n"), player_names[target->player-players]); - P_CheckSurvivors(); - } - } - } - } - else*/ if (G_BattleGametype()) + if (G_BattleGametype()) K_CheckBumpers(); target->player->kartstuff[k_pogospring] = 0; @@ -2611,26 +2193,6 @@ static inline boolean P_TagDamage(mobj_t *target, mobj_t *inflictor, mobj_t *sou return false; } - // The tag occurs so long as you aren't shooting another tagger with friendlyfire on. - /*if (source->player->pflags & PF_TAGIT && !(player->pflags & PF_TAGIT)) - { - P_AddPlayerScore(source->player, 1); //award points to tagger. - - if (gametype == GT_TAG) //survivor - { - player->pflags |= PF_TAGIT; //in survivor, the player becomes IT and helps hunt down the survivors. - CONS_Printf(M_GetText("%s is now IT!\n"), player_names[player-players]); // Tell everyone who is it! - } - else - { - player->pflags |= PF_TAGGED; //in hide and seek, the player is tagged and stays stationary. - CONS_Printf(M_GetText("%s was found!\n"), player_names[player-players]); // Tell everyone who is it! - } - - //checks if tagger has tagged all players, if so, end round early. - P_CheckSurvivors(); - }*/ - P_DoPlayerPain(player, source, inflictor); // Check for a shield @@ -2669,15 +2231,6 @@ static inline boolean P_PlayerHitsPlayer(mobj_t *target, mobj_t *inflictor, mobj { player_t *player = target->player; - // You can't kill yourself, idiot... // Unless it's Mario kart. Which it is. In this mod. All the time. - //if (source == target) - // return false; - - // In COOP/RACE/CHAOS, you can't hurt other players unless cv_friendlyfire is on - // ...But in SRB2kart, you can! - //if (!cv_friendlyfire.value && (G_RaceGametype())) - // return false; - // Tag handling if (G_TagGametype()) return P_TagDamage(target, inflictor, source, damage); @@ -2729,32 +2282,6 @@ static void P_KillPlayer(player_t *player, mobj_t *source, INT32 damage) P_SetPlayerMobjState(player->mo, player->mo->info->deathstate); - /*if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - { - P_PlayerFlagBurst(player, false); - if (source && source->player) - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, 1); - } - } - if (source && source->player && !player->powers[pw_super]) //don't score points against super players - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, 1); - } - - // If the player was super, tell them he/she ain't so super nomore. - if (gametype != GT_COOP && player->powers[pw_super]) - { - S_StartSound(NULL, sfx_s3k66); //let all players hear it. - HU_SetCEchoFlags(0); - HU_SetCEchoDuration(5); - HU_DoCEcho(va("%s\\is no longer super.\\\\\\\\", player_names[player-players])); - }*/ - if (player->pflags & PF_TIMEOVER) { mobj_t *boom; @@ -2815,44 +2342,8 @@ void P_RemoveShield(player_t *player) player->powers[pw_shield] = player->powers[pw_shield] & SH_STACK; } -/* -static void P_ShieldDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) // SRB2kart - unused. -{ - // Must do pain first to set flashing -- P_RemoveShield can cause damage - P_DoPlayerPain(player, source, inflictor); - - P_RemoveShield(player); - - P_ForceFeed(player, 40, 10, TICRATE, 40 + min(damage, 100)*2); - - if (source && (source->type == MT_SPIKE || (source->type == MT_NULL && source->threshold == 43))) // spikes - S_StartSound(player->mo, sfx_spkdth); - else - S_StartSound (player->mo, sfx_shldls); // Ba-Dum! Shield loss. - - if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - { - P_PlayerFlagBurst(player, false); - if (source && source->player) - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, 25); - } - } - if (source && source->player && !player->powers[pw_super]) //don't score points against super players - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, cv_match_scoring.value == 1 ? 25 : 50); - } -} -*/ - static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 damage) { - //const UINT8 scoremultiply = ((K_IsWantedPlayer(player) && !trapitem) : 2 ? 1); - if (!(inflictor && ((inflictor->flags & MF_MISSILE) || inflictor->player) && player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds]))) { P_DoPlayerPain(player, source, inflictor); @@ -2863,24 +2354,6 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN S_StartSound(player->mo, sfx_spkdth); } - /*if (source && source->player && !player->powers[pw_super]) //don't score points against super players - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, scoremultiply); - } - - if (gametype == GT_CTF && (player->gotflag & (GF_REDFLAG|GF_BLUEFLAG))) - { - P_PlayerFlagBurst(player, false); - if (source && source->player) - { - // Award no points when players shoot each other when cv_friendlyfire is on. - if (!G_GametypeHasTeams() || !(source->player->ctfteam == player->ctfteam && source != player->mo)) - P_AddPlayerScore(source->player, scoremultiply); - } - }*/ - // Ring loss sound plays despite hitting spikes P_PlayRinglossSound(player->mo); // Ringledingle! } @@ -3680,32 +3153,30 @@ void P_PlayerFlagBurst(player_t *player, boolean toss) P_SetTarget(&flag->target, player->mo); // Flag text + char plname[MAXPLAYERNAME+4]; + const char *flagtext; + char flagcolor; + + snprintf(plname, sizeof(plname), "%s%s%s", + CTFTEAMCODE(player), + player_names[player - players], + CTFTEAMENDCODE(player)); + + if (type == MT_REDFLAG) { - char plname[MAXPLAYERNAME+4]; - const char *flagtext; - char flagcolor; - - snprintf(plname, sizeof(plname), "%s%s%s", - CTFTEAMCODE(player), - player_names[player - players], - CTFTEAMENDCODE(player)); - - if (type == MT_REDFLAG) - { - flagtext = M_GetText("Red flag"); - flagcolor = '\x85'; - } - else - { - flagtext = M_GetText("Blue flag"); - flagcolor = '\x84'; - } - - if (toss) - CONS_Printf(M_GetText("%s tossed the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); - else - CONS_Printf(M_GetText("%s dropped the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); + flagtext = M_GetText("Red flag"); + flagcolor = '\x85'; } + else + { + flagtext = M_GetText("Blue flag"); + flagcolor = '\x84'; + } + + if (toss) + CONS_Printf(M_GetText("%s tossed the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); + else + CONS_Printf(M_GetText("%s dropped the %c%s%c.\n"), plname, flagcolor, flagtext, 0x80); player->gotflag = 0; diff --git a/src/p_mobj.c b/src/p_mobj.c index b25a30065..5e5b9924b 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3144,7 +3144,12 @@ static void P_SceneryCheckWater(mobj_t *mobj) static boolean P_CameraCheckHeat(camera_t *thiscam) { sector_t *sector; - fixed_t halfheight = thiscam->z + (thiscam->height >> 1); + fixed_t halfheight; + + if (!thiscam) + return false; + + halfheight = thiscam->z + (thiscam->height >> 1); // see if we are in water sector = thiscam->subsector->sector; @@ -3177,7 +3182,12 @@ static boolean P_CameraCheckHeat(camera_t *thiscam) static boolean P_CameraCheckWater(camera_t *thiscam) { sector_t *sector; - fixed_t halfheight = thiscam->z + (thiscam->height >> 1); + fixed_t halfheight; + + if (!thiscam) + return false; + + halfheight = thiscam->z + (thiscam->height >> 1); // see if we are in water sector = thiscam->subsector->sector; @@ -4978,13 +4988,15 @@ static void P_Boss9Thinker(mobj_t *mobj) else mobj->momz = (mobj->watertop-mobj->z)/40; // Float to your desired position - if (mobj->movecount == 2) { + if (mobj->movecount == 2) + { mobj_t *spawner; fixed_t dist = 0; angle = 0x06000000*leveltime; // Alter your energy bubble's size/position - if (mobj->health > 3) { + if (mobj->health > 3) + { mobj->tracer->destscale = FRACUNIT + (4*TICRATE - mobj->fuse)*(FRACUNIT/2)/TICRATE + FixedMul(FINECOSINE(angle>>ANGLETOFINESHIFT),FRACUNIT/2); P_SetScale(mobj->tracer, mobj->tracer->destscale); P_SetOrigin(mobj->tracer, mobj->x, mobj->y, mobj->z + mobj->height/2 - mobj->tracer->height/2); @@ -5020,8 +5032,10 @@ static void P_Boss9Thinker(mobj_t *mobj) } // Pre-threshold reactiontime stuff for attack phases - if (mobj->reactiontime && mobj->movecount == 3) { - if (mobj->movedir == 0 || mobj->movedir == 2) { // Pausing between bounces in the pinball phase + if (mobj->reactiontime && mobj->movecount == 3) + { + if (mobj->movedir == 0 || mobj->movedir == 2) // Pausing between bounces in the pinball phase + { if (mobj->target->player->powers[pw_tailsfly]) // Trying to escape, eh? mobj->watertop = mobj->target->z + mobj->target->momz*6; // Readjust your aim. >:3 else @@ -5035,13 +5049,16 @@ static void P_Boss9Thinker(mobj_t *mobj) } // threshold is used for attacks/maneuvers. - if (mobj->threshold) { + if (mobj->threshold) + { fixed_t speed = 20*FRACUNIT + FixedMul(40*FRACUNIT, FixedDiv((mobj->info->spawnhealth - mobj->health)<info->spawnhealth<movecount == 3 && mobj->movedir == 1) { - if (!(mobj->threshold&1)) { + if (mobj->movecount == 3 && mobj->movedir == 1) + { + if (!(mobj->threshold&1)) + { mobj_t *missile; if (mobj->info->seesound) S_StartSound(mobj, mobj->info->seesound); @@ -5053,18 +5070,21 @@ static void P_Boss9Thinker(mobj_t *mobj) A_FaceTarget(mobj); missile = P_SpawnMissile(mobj, mobj->target, mobj->info->speed); - if (mobj->extravalue1 == 2 || mobj->extravalue1 == 3) { + if (mobj->extravalue1 == 2 || mobj->extravalue1 == 3) + { missile->destscale = FRACUNIT>>1; P_SetScale(missile, missile->destscale); } missile->fuse = 3*TICRATE; missile->z -= missile->height/2; - if (mobj->extravalue1 == 2) { + if (mobj->extravalue1 == 2) + { int i; mobj_t *spread; missile->flags |= MF_MISSILE; - for (i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) + { if (i == 2) continue; spread = P_SpawnMobj(missile->x, missile->y, missile->z, missile->type); @@ -5077,7 +5097,9 @@ static void P_Boss9Thinker(mobj_t *mobj) } missile->flags &= ~MF_MISSILE; } - } else { + } + else + { P_SetMobjState(mobj, mobj->state->nextstate); if (mobj->extravalue1 == 3) mobj->reactiontime = TICRATE/8; @@ -5091,7 +5113,8 @@ static void P_Boss9Thinker(mobj_t *mobj) P_SpawnGhostMobj(mobj); // Pinball attack! - if (mobj->movecount == 3 && (mobj->movedir == 0 || mobj->movedir == 2)) { + if (mobj->movecount == 3 && (mobj->movedir == 0 || mobj->movedir == 2)) + { if ((statenum_t)(mobj->state-states) != mobj->info->seestate) P_SetMobjState(mobj, mobj->info->seestate); if (mobj->movedir == 0) // mobj health == 1 @@ -5100,16 +5123,22 @@ static void P_Boss9Thinker(mobj_t *mobj) P_InstaThrust(mobj, mobj->angle, 22*FRACUNIT); else // mobj health == 2 P_InstaThrust(mobj, mobj->angle, 30*FRACUNIT); - if (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true)) { // Hit a wall? Find a direction to bounce + + if (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true)) // Hit a wall? Find a direction to bounce + { mobj->threshold--; - if (mobj->threshold) { + if (mobj->threshold) + { P_SetMobjState(mobj, mobj->state->nextstate); if (mobj->info->mass) S_StartSound(mobj, mobj->info->mass); - if (!(mobj->threshold%4)) { // We've decided to lock onto the player this bounce. + if (!(mobj->threshold%4)) // We've decided to lock onto the player this bounce. + { mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x + mobj->target->momx*4, mobj->target->y + mobj->target->momy*4); mobj->reactiontime = TICRATE; // targetting time - } else { // No homing, just use P_BounceMove + } + else // No homing, just use P_BounceMove + { P_BounceMove(mobj); mobj->angle = R_PointToAngle2(0,0,mobj->momx,mobj->momy); mobj->reactiontime = TICRATE/4; // just a pause before you bounce away @@ -5123,7 +5152,8 @@ static void P_Boss9Thinker(mobj_t *mobj) // Vector form dodge! mobj->angle += mobj->movedir; P_InstaThrust(mobj, mobj->angle, -speed); - while (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true) && tries++ < 16) { + while (!P_TryMove(mobj, mobj->x+mobj->momx, mobj->y+mobj->momy, true) && tries++ < 16) + { mobj->angle += mobj->movedir; P_InstaThrust(mobj, mobj->angle, -speed); } @@ -5179,9 +5209,10 @@ static void P_Boss9Thinker(mobj_t *mobj) if (mobj->flags2 & MF2_FRET) return; - if (mobj->state == &states[mobj->info->raisestate]) - { // Charging energy - if (mobj->momx != 0 || mobj->momy != 0) { // Apply the air breaks + if (mobj->state == &states[mobj->info->raisestate]) // Charging energy + { + if (mobj->momx != 0 || mobj->momy != 0) // Apply the air breaks + { if (abs(mobj->momx)+abs(mobj->momy) < FRACUNIT) mobj->momx = mobj->momy = 0; else @@ -5206,7 +5237,8 @@ static void P_Boss9Thinker(mobj_t *mobj) mobj->watertop = mobj->target->floorz + 256*FRACUNIT; break; - case 1: { + case 1: + { // Okay, we're up? Good, time to gather energy... if (mobj->health > mobj->info->damage) { // No more bubble if we're broken (pinch phase) @@ -5232,7 +5264,8 @@ static void P_Boss9Thinker(mobj_t *mobj) P_SetTarget(&mobj->tracer, mobj->hnext); P_RemoveMobj(removemobj); } - if (mobj->health <= mobj->info->damage) { + if (mobj->health <= mobj->info->damage) + { // Attack 1: Pinball dash! if (mobj->health == 1) mobj->movedir = 0; @@ -5247,7 +5280,9 @@ static void P_Boss9Thinker(mobj_t *mobj) mobj->threshold = 32; // bounce 32 times mobj->watertop = mobj->target->floorz + 16*FRACUNIT; P_LinedefExecute(LE_PINCHPHASE, mobj, NULL); - } else { + } + else + { // Attack 2: Energy shot! mobj->movedir = 1; @@ -5260,7 +5295,8 @@ static void P_Boss9Thinker(mobj_t *mobj) else mobj->extravalue1 = 3; - switch(mobj->extravalue1) { + switch(mobj->extravalue1) + { case 0: // shoot once case 2: // spread-shot default: @@ -5324,7 +5360,8 @@ static void P_Boss9Thinker(mobj_t *mobj) danger = false; if (mobj->target->z+mobj->target->momz*2 > mobj->z+mobj->height) danger = false; - if (danger) { + if (danger) + { // An incoming attack is detected! What should we do?! // Go into vector form! mobj->movedir = ANGLE_11hh - FixedAngle(FixedMul(AngleFixed(ANGLE_11hh), FixedDiv((mobj->info->spawnhealth - mobj->health)<info->spawnhealth-1)<hnext; mo = mo->hnext) ; @@ -5871,7 +5909,8 @@ static void P_AddShadow(mobj_t *thing) if (shadowcap == NULL) P_SetTarget(&shadowcap, thing); - else { + else + { mobj_t *mo; for (mo = shadowcap; mo && mo->hnext; mo = mo->hnext) ; diff --git a/src/p_setup.c b/src/p_setup.c index f27816c07..2f17d6d24 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -801,69 +801,6 @@ void P_ReloadRings(void) } } -#ifdef SCANTHINGS -void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum) -{ - size_t i, n; - UINT8 *data, *datastart; - UINT16 type, maprings; - INT16 tol; - UINT32 flags; - - tol = mapheaderinfo[mapnum-1]->typeoflevel; - if (!(tol & TOL_SP)) - return; - flags = mapheaderinfo[mapnum-1]->levelflags; - - n = W_LumpLengthPwad(wadnum, lumpnum) / (5 * sizeof (INT16)); - //CONS_Printf("%u map things found!\n", n); - - maprings = 0; - data = datastart = W_CacheLumpNumPwad(wadnum, lumpnum, PU_STATIC); - for (i = 0; i < n; i++) - { - data += 3 * sizeof (INT16); // skip x y position, angle - type = READUINT16(data) & 4095; - data += sizeof (INT16); // skip options - - switch (type) - { - case 300: // MT_RING - case 1800: // MT_COIN - case 308: // red team ring - case 309: // blue team ring - maprings++; - break; - case 400: // MT_SUPERRINGBOX - case 414: // red ring box - case 415: // blue ring box - case 603: // 10 diagonal rings - maprings += 10; - break; - case 600: // 5 vertical rings - case 601: // 5 vertical rings - case 602: // 5 diagonal rings - maprings += 5; - break; - case 604: // 8 circle rings - case 609: // 16 circle rings & wings - maprings += 8; - break; - case 605: // 16 circle rings - maprings += 16; - break; - case 608: // 8 circle rings & wings - maprings += 4; - break; - } - } - Z_Free(datastart); - - if (maprings) - CONS_Printf("%s has %u rings\n", G_BuildMapName(mapnum), maprings); -} -#endif - // // P_LoadThings // @@ -2777,12 +2714,6 @@ boolean P_SetupLevel(boolean skipprecip) // Clear pointers that would be left dangling by the purge R_FlushTranslationColormapCache(); -#ifdef HWRENDER - // Free GPU textures before freeing patches. - if (rendermode == render_opengl && (vid.glstate == VID_GL_LIBRARY_LOADED)) - HWR_FreeMipmapCache(); -#endif - Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); #if defined (WALLSPLATS) || defined (FLOORSPLATS) diff --git a/src/p_setup.h b/src/p_setup.h index 5df0f0b68..8a77c690b 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -59,9 +59,6 @@ extern size_t nummapthings; extern mapthing_t *mapthings; void P_SetupLevelSky(INT32 skynum, boolean global); -#ifdef SCANTHINGS -void P_ScanThings(INT16 mapnum, INT16 wadnum, INT16 lumpnum); -#endif void P_LoadThingsOnly(void); boolean P_SetupLevel(boolean skipprecip); #ifdef HWRENDER diff --git a/src/p_spec.c b/src/p_spec.c index 1bde9a72e..4fa7a5275 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -29,6 +29,7 @@ #include "z_zone.h" #include "r_main.h" //Two extra includes. #include "r_sky.h" +#include "st_stuff.h" #include "p_polyobj.h" #include "p_slopes.h" #include "hu_stuff.h" @@ -622,48 +623,6 @@ void P_SetupLevelFlatAnims(void) // UTILITIES // -#if 0 -/** Gets a side from a sector line. - * - * \param currentSector Sector the line is in. - * \param line Index of the line within the sector. - * \param side 0 for front, 1 for back. - * \return Pointer to the side_t of the side you want. - * \sa getSector, twoSided, getNextSector - */ -static inline side_t *getSide(INT32 currentSector, INT32 line, INT32 side) -{ - return &sides[(sectors[currentSector].lines[line])->sidenum[side]]; -} - -/** Gets a sector from a sector line. - * - * \param currentSector Sector the line is in. - * \param line Index of the line within the sector. - * \param side 0 for front, 1 for back. - * \return Pointer to the ::sector_t of the sector on that side. - * \sa getSide, twoSided, getNextSector - */ -static inline sector_t *getSector(INT32 currentSector, INT32 line, INT32 side) -{ - return sides[(sectors[currentSector].lines[line])->sidenum[side]].sector; -} - -/** Determines whether a sector line is two-sided. - * Uses the Boom method, checking if the line's back side is set to -1, rather - * than looking for ::ML_TWOSIDED. - * - * \param sector The sector. - * \param line Line index within the sector. - * \return 1 if the sector is two-sided, 0 otherwise. - * \sa getSide, getSector, getNextSector - */ -static inline boolean twoSided(INT32 sector, INT32 line) -{ - return (sectors[sector].lines[line])->sidenum[1] != 0xffff; -} -#endif - /** Finds sector next to current. * * \param line Pointer to the line to cross. @@ -822,77 +781,6 @@ fixed_t P_FindNextLowestFloor(sector_t *sec, fixed_t currentheight) return currentheight; } -#if 0 -/** Finds next lowest ceiling in adjacent sectors. - * - * \param sec Sector to start in. - * \param currentheight Height to start at. - * \return Next lowest ceiling height in an adjacent sector, or currentheight - * if there are none lower. - * \sa P_FindLowestCeilingSurrounding, P_FindNextHighestCeiling, - * P_FindNextLowestFloor - * \author Lee Killough - */ -static fixed_t P_FindNextLowestCeiling(sector_t *sec, fixed_t currentheight) -{ - sector_t *other; - size_t i; - fixed_t height; - - for (i = 0; i < sec->linecount; i++) - { - other = getNextSector(sec->lines[i],sec); - if (other && other->ceilingheight < currentheight) - { - height = other->ceilingheight; - while (++i < sec->linecount) - { - other = getNextSector(sec->lines[i],sec); - if (other && other->ceilingheight > height - && other->ceilingheight < currentheight) - height = other->ceilingheight; - } - return height; - } - } - return currentheight; -} - -/** Finds next highest ceiling in adjacent sectors. - * - * \param sec Sector to start in. - * \param currentheight Height to start at. - * \return Next highest ceiling height in an adjacent sector, or currentheight - * if there are none higher. - * \sa P_FindHighestCeilingSurrounding, P_FindNextLowestCeiling, - * P_FindNextHighestFloor - * \author Lee Killough - */ -static fixed_t P_FindNextHighestCeiling(sector_t *sec, fixed_t currentheight) -{ - sector_t *other; - size_t i; - fixed_t height; - - for (i = 0; i < sec->linecount; i++) - { - other = getNextSector(sec->lines[i], sec); - if (other && other->ceilingheight > currentheight) - { - height = other->ceilingheight; - while (++i < sec->linecount) - { - other = getNextSector(sec->lines[i],sec); - if (other && other->ceilingheight < height - && other->ceilingheight > currentheight) - height = other->ceilingheight; - } - return height; - } - } - return currentheight; -} -#endif //////////////////////////// // End New Boom functions @@ -962,133 +850,6 @@ fixed_t P_FindHighestCeilingSurrounding(sector_t *sec) return height; } -#if 0 -//SoM: 3/7/2000: UTILS..... -// -// P_FindShortestTextureAround() -// -// Passed a sector number, returns the shortest lower texture on a -// linedef bounding the sector. -// -// -static fixed_t P_FindShortestTextureAround(INT32 secnum) -{ - fixed_t minsize = 32000<linecount; i++) - { - if (twoSided(secnum, i)) - { - side = getSide(secnum,i,0); - if (side->bottomtexture > 0) - if (textureheight[side->bottomtexture] < minsize) - minsize = textureheight[side->bottomtexture]; - side = getSide(secnum,i,1); - if (side->bottomtexture > 0) - if (textureheight[side->bottomtexture] < minsize) - minsize = textureheight[side->bottomtexture]; - } - } - return minsize; -} - -//SoM: 3/7/2000: Stuff.... (can you tell I'm getting tired? It's 12 : 30!) -// -// P_FindShortestUpperAround() -// -// Passed a sector number, returns the shortest upper texture on a -// linedef bounding the sector. -// -// -static fixed_t P_FindShortestUpperAround(INT32 secnum) -{ - fixed_t minsize = 32000<linecount; i++) - { - if (twoSided(secnum, i)) - { - side = getSide(secnum,i,0); - if (side->toptexture > 0) - if (textureheight[side->toptexture] < minsize) - minsize = textureheight[side->toptexture]; - side = getSide(secnum,i,1); - if (side->toptexture > 0) - if (textureheight[side->toptexture] < minsize) - minsize = textureheight[side->toptexture]; - } - } - return minsize; -} - -//SoM: 3/7/2000 -// -// P_FindModelFloorSector() -// -// Passed a floor height and a sector number, return a pointer to a -// a sector with that floor height across the lowest numbered two sided -// line surrounding the sector. -// -// Note: If no sector at that height bounds the sector passed, return NULL -// -// -static sector_t *P_FindModelFloorSector(fixed_t floordestheight, INT32 secnum) -{ - size_t i; - sector_t *sec = §ors[secnum]; - - for (i = 0; i < sec->linecount; i++) - { - if (twoSided(secnum, i)) - { - if (getSide(secnum,i,0)->sector-sectors == secnum) - sec = getSector(secnum,i,1); - else - sec = getSector(secnum,i,0); - - if (sec->floorheight == floordestheight) - return sec; - } - } - return NULL; -} - -// -// P_FindModelCeilingSector() -// -// Passed a ceiling height and a sector number, return a pointer to a -// a sector with that ceiling height across the lowest numbered two sided -// line surrounding the sector. -// -// Note: If no sector at that height bounds the sector passed, return NULL -// -static sector_t *P_FindModelCeilingSector(fixed_t ceildestheight, INT32 secnum) -{ - size_t i; - sector_t *sec = §ors[secnum]; - - for (i = 0; i < sec->linecount; i++) - { - if (twoSided(secnum, i)) - { - if (getSide(secnum, i, 0)->sector - sectors == secnum) - sec = getSector(secnum, i, 1); - else - sec = getSector(secnum, i, 0); - - if (sec->ceilingheight == ceildestheight) - return sec; - } - } - return NULL; -} -#endif /** Searches the tag lists for the next sector tagged to a line. * @@ -1176,37 +937,8 @@ static INT32 P_FindLineFromLineTag(const line_t *line, INT32 start) return start; } } -#if 0 -/** Searches the tag lists for the next line with a given tag and special. - * - * \param tag Tag number. - * \param start -1 to start anew, or the result of a previous call to keep - * searching. - * \return Number of next suitable line found. - * \sa P_FindLineFromLineTag - * \author Graue - */ -static INT32 P_FindLineFromTag(INT32 tag, INT32 start) -{ - if (tag == -1) - { - start++; - if (start >= numlines) - return -1; - return start; - } - else - { - start = start >= 0 ? lines[start].nexttag : - lines[(unsigned)tag % numlines].firsttag; - while (start >= 0 && lines[start].tag != tag) - start = lines[start].nexttag; - return start; - } -} -#endif // // P_FindSpecialLineFromTag // @@ -1707,17 +1439,11 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller if (actor && actor->player && triggerline->flags & ML_EFFECT4) { - /*if (maptol & TOL_NIGHTS) - lap = actor->player->mare; - else*/ - lap = actor->player->laps; + lap = actor->player->laps; } else { - /*if (maptol & TOL_NIGHTS) - lap = P_FindLowestMare(); - else*/ - lap = P_FindLowestLap(); + lap = P_FindLowestLap(); } if (triggerline->flags & ML_NOCLIMB) // Need higher than or equal to @@ -1754,12 +1480,6 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller switch (specialtype) { - /*case 305: // continuous - case 306: // each time - case 307: // once - if (!(actor && actor->player && actor->player->charability == dist/10)) - return false; - break;*/ case 309: // continuous case 310: // each time // Only red team members can activate this. @@ -1930,9 +1650,8 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller // "Trigger on X calls" linedefs reset if noclimb is set if ((specialtype == 321 || specialtype == 322) && triggerline->flags & ML_NOCLIMB) triggerline->callcount = sides[triggerline->sidenum[0]].textureoffset>>FRACBITS; - else // These special types work only once - if (specialtype == 302 // Once + else if (specialtype == 302 // Once || specialtype == 304 // Ring count - Once || specialtype == 307 // Character ability - Once || specialtype == 308 // Race only - Once @@ -2300,22 +2019,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) EV_DoCeiling(line, moveCeilingByFrontTexture); break; -/* case 405: // Lower floor by line, dx = speed, dy = amount to lower - EV_DoFloor(line, lowerFloorByLine); - break; - - case 406: // Raise floor by line, dx = speed, dy = amount to raise - EV_DoFloor(line, raiseFloorByLine); - break; - - case 407: // Lower ceiling by line, dx = speed, dy = amount to lower - EV_DoCeiling(line, lowerCeilingByLine); - break; - - case 408: // Raise ceiling by line, dx = speed, dy = amount to raise - EV_DoCeiling(line, raiseCeilingByLine); - break;*/ - case 409: // Change tagged sectors' tag // (formerly "Change calling sectors' tag", but behavior was changed) { @@ -2901,7 +2604,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Copy effect to bot if necessary // (Teleport them to you so they don't break it.) - if (bot && (bot->flags2 & MF2_TWOD) != (mo->flags2 & MF2_TWOD)) { + if (bot && (bot->flags2 & MF2_TWOD) != (mo->flags2 & MF2_TWOD)) + { bot->flags2 = (bot->flags2 & ~MF2_TWOD) | (mo->flags2 & MF2_TWOD); P_SetOrigin(bot, mo->x, mo->y, mo->z); } @@ -2934,7 +2638,8 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) P_SetTarget(&dummy->target, mo); A_CustomPower(dummy); - if (bot) { + if (bot) + { P_SetTarget(&dummy->target, bot); A_CustomPower(dummy); } @@ -3528,10 +3233,6 @@ static boolean P_ThingIsOnThe3DFloor(mobj_t *mo, sector_t *sector, sector_t *tar if (rover->master->frontsector != sector) continue; - // we're assuming the FOF existed when the first player touched it - //if (!(rover->flags & FF_EXISTS)) - // return false; - top = P_GetSpecialTopZ(mo, sector, targetsec); bottom = P_GetSpecialBottomZ(mo, sector, targetsec); @@ -4067,8 +3768,6 @@ DoneSection2: player->mo->momz = mobjinfo[MT_FAN].mass; P_ResetPlayer(player); - //if (player->panim != PA_FALL) // SRB2kart - // P_SetPlayerMobjState(player->mo, S_PLAY_FALL1); break; case 6: // SRB2kart 190117 - Sneaker Panel @@ -4240,12 +3939,6 @@ DoneSection2: if (!(player->mo->state >= &states[S_KART_RUN1] && player->mo->state <= &states[S_KART_RUN2])) P_SetPlayerMobjState(player->mo, S_KART_RUN1); - - //if (!(player->mo->state >= &states[S_PLAY_ATK1] && player->mo->state <= &states[S_PLAY_ATK4])) // SRB2kart - //{ - // P_SetPlayerMobjState(player->mo, S_PLAY_ATK1); - // S_StartSound(player->mo, sfx_spin); - //} } break; @@ -4301,6 +3994,11 @@ DoneSection2: curlap = 0; } + // ONLY FOR HUD + player->laptime[LAP_LAST] = player->laptime[LAP_CUR]; + player->laptime[LAP_CUR] = 0; + // + player->starposttime = player->realtime; player->starpostnum = 0; @@ -4900,12 +4598,6 @@ static void P_RunSpecialSectorCheck(player_t *player, sector_t *sector) break; } - // Check Section 3 -/* switch(GETSECSPECIAL(sector->special, 3)) - { - - }*/ - // Check Section 4 switch(GETSECSPECIAL(sector->special, 4)) { @@ -5319,42 +5011,6 @@ static void P_AddFloatThinker(sector_t *sec, INT32 tag, line_t *sourceline) R_CreateInterpolator_SectorPlane(&floater->thinker, sec, true); } -/** Adds a bridge thinker. - * Bridge thinkers cause a group of FOFs to behave like - * a bridge made up of pieces, that bows under weight. - * - * \param sec Control sector. - * \sa P_SpawnSpecials, T_BridgeThinker - * \author SSNTails - */ -/* -static inline void P_AddBridgeThinker(line_t *sourceline, sector_t *sec) -{ - levelspecthink_t *bridge; - - // create an initialize new thinker - bridge = Z_Calloc(sizeof (*bridge), PU_LEVSPEC, NULL); - P_AddThinker(&bridge->thinker); - - bridge->thinker.function.acp1 = (actionf_p1)T_BridgeThinker; - - bridge->sector = sec; - bridge->vars[0] = sourceline->frontsector->floorheight; - bridge->vars[1] = sourceline->frontsector->ceilingheight; - bridge->vars[2] = P_AproxDistance(sourceline->dx, sourceline->dy); // Speed - bridge->vars[2] = FixedDiv(bridge->vars[2], 16*FRACUNIT); - bridge->vars[3] = bridge->vars[2]; - - // Start tag and end tag are TARGET SECTORS, not CONTROL SECTORS - // Control sector tags should be End_Tag + (End_Tag - Start_Tag) - bridge->vars[4] = sourceline->tag; // Start tag - bridge->vars[5] = (sides[sourceline->sidenum[0]].textureoffset>>FRACBITS); // End tag - - // interpolation - R_CreateInterpolator_SectorPlane(&bridge->thinker, §ors[affectee], false); -} -*/ - /** Adds a Mario block thinker, which changes the block's texture between blank * and ? depending on whether it has contents. * Needed in case objects respawn inside. @@ -5772,12 +5428,6 @@ void P_SpawnSpecials(INT32 fromnetsave) break; } - // Process Section 3 -/* switch(GETSECSPECIAL(player->specialsector, 3)) - { - - }*/ - // Process Section 4 switch(GETSECSPECIAL(sector->special, 4)) { @@ -5863,16 +5513,6 @@ void P_SpawnSpecials(INT32 fromnetsave) lines[i].special = 0; continue; } - /*else -- commented out because irrelevant to kart. keeping here because we can use these flags for something else now - { - if ((players[consoleplayer].charability == CA_THOK && (lines[i].flags & ML_NOSONIC)) - || (players[consoleplayer].charability == CA_FLY && (lines[i].flags & ML_NOTAILS)) - || (players[consoleplayer].charability == CA_GLIDEANDCLIMB && (lines[i].flags & ML_NOKNUX))) - { - lines[i].special = 0; - continue; - } - }*/ } switch (lines[i].special) @@ -6053,12 +5693,14 @@ void P_SpawnSpecials(INT32 fromnetsave) break; case 64: // Appearing/Disappearing FOF option - if (lines[i].flags & ML_BLOCKMONSTERS) { // Find FOFs by control sector tag + if (lines[i].flags & ML_BLOCKMONSTERS) // Find FOFs by control sector tag + { for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) for (j = 0; (unsigned)j < sectors[s].linecount; j++) if (sectors[s].lines[j]->special >= 100 && sectors[s].lines[j]->special < 300) Add_MasterDisappearer(abs(lines[i].dx>>FRACBITS), abs(lines[i].dy>>FRACBITS), abs(sides[lines[i].sidenum[0]].sector->floorheight>>FRACBITS), (INT32)(sectors[s].lines[j]-lines), (INT32)i); - } else // Find FOFs by effect sector tag + } + else // Find FOFs by effect sector tag for (s = -1; (s = P_FindLineFromLineTag(lines + i, s)) >= 0 ;) { if ((size_t)s == i) @@ -6069,10 +5711,6 @@ void P_SpawnSpecials(INT32 fromnetsave) break; case 65: // Bridge Thinker - /* - // Disable this until it's working right! - for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;) - P_AddBridgeThinker(&lines[i], §ors[s]);*/ break; case 100: // FOF (solid, opaque, shadows) @@ -7301,7 +6939,7 @@ void T_Disappear(disappear_t *d) if (*rover->t_slope) sectors[s].soundorg.z = P_GetZAt(*rover->t_slope, sectors[s].soundorg.x, sectors[s].soundorg.y); else - sectors[s].soundorg.z = *rover->topheight; + sectors[s].soundorg.z = *rover->topheight; S_StartSound(§ors[s].soundorg, sfx_appear); } } @@ -7375,17 +7013,6 @@ void T_Friction(friction_t *f) //{ referrer = sectors + f->referrer; - /* if (!(GETSECSPECIAL(referrer->special, 3) == 1 - || GETSECSPECIAL(referrer->special, 3) == 3)) - return; - } - else - { - if (!(GETSECSPECIAL(sec->special, 3) == 1 - || GETSECSPECIAL(sec->special, 3) == 3)) - return; - }*/ - // Assign the friction value to players on the floor, non-floating, // and clipped. Normally the object's friction value is kept at // ORIG_FRICTION and this thinker changes it for icy or muddy floors. @@ -7725,14 +7352,11 @@ void T_Pusher(pusher_t *p) { referrer = §ors[p->referrer]; - //if (!(GETSECSPECIAL(referrer->special, 3) == 2 - // || GETSECSPECIAL(referrer->special, 3) == 3)) if (GETSECSPECIAL(referrer->special, 3) != 2) return; } - //else if (!(GETSECSPECIAL(sec->special, 3) == 2 - // || GETSECSPECIAL(sec->special, 3) == 3)) else if (GETSECSPECIAL(sec->special, 3) != 2) + // For constant pushers (wind/current) there are 3 situations: // // 1) Affected Thing is above the floor. @@ -7970,14 +7594,6 @@ void T_Pusher(pusher_t *p) else localangle[3] += (thing->angle - localangle[3]) / 8; } - /*if (thing->player == &players[consoleplayer]) - localangle[0] = thing->angle; - else if (thing->player == &players[displayplayers[1]]) - localangle[1] = thing->angle; - else if (thing->player == &players[displayplayers[2]]) - localangle[2] = thing->angle; - else if (thing->player == &players[displayplayers[3]]) - localangle[3] = thing->angle;*/ } } @@ -8089,13 +7705,6 @@ static void P_SearchForDisableLinedefs(void) } else if ((lines[i].flags & ML_NETONLY) == ML_NETONLY) continue; // Net-only never triggers in single player - // commented out because irrelevant to kart. keeping here because we can use these flags for something else now - /*else if (players[consoleplayer].charability == CA_THOK && (lines[i].flags & ML_NOSONIC)) - continue; - else if (players[consoleplayer].charability == CA_FLY && (lines[i].flags & ML_NOTAILS)) - continue; - else if (players[consoleplayer].charability == CA_GLIDEANDCLIMB && (lines[i].flags & ML_NOKNUX)) - continue;*/ // Disable any linedef specials with our tag. for (j = -1; (j = P_FindLineFromLineTag(&lines[i], j)) >= 0;) diff --git a/src/p_user.c b/src/p_user.c index 1219414df..c14a4c541 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3002,12 +3002,19 @@ static void P_DeathThink(player_t *player) else curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V } + + if (player->spectator) + player->laptime[LAP_CUR] = 0; + else + player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V } else { player->realtime = 0; if (player == &players[consoleplayer]) curlap = 0; + + player->laptime[LAP_CUR] = 0; } } @@ -4221,11 +4228,7 @@ Quaketilt (player_t *player) INT32 delta = (INT32)( player->mo->angle - moma ); fixed_t speed; - boolean sliptiding = - ( - player->kartstuff[k_aizdriftstrat] != 0 && - player->kartstuff[k_drift] == 0 - ); + boolean sliptiding = player->kartstuff[k_drift] ? 0 : player->kartstuff[k_aizdriftstrat]; if (delta == (INT32)ANGLE_180)/* FUCK YOU HAVE A HACK */ { @@ -4253,6 +4256,7 @@ Quaketilt (player_t *player) tilt = ANGLE_22h; lowb = 10*FRACUNIT; } + lowb = FixedMul(lowb, player->mo->scale); moma = FixedMul(FixedDiv(delta, ANGLE_90), tilt); speed = abs( player->mo->momx + player->mo->momy ); if (speed < lowb) @@ -4269,6 +4273,19 @@ DoABarrelRoll (player_t *player) angle_t slope; angle_t delta; + fixed_t smoothing; + + if (player->exiting) + { + return; + } + + if (player->kartstuff[k_respawn]) + { + player->tilt = 0; + return; + } + if (player->mo->standingslope) { slope = player->mo->standingslope->real_zangle; @@ -4293,26 +4310,16 @@ DoABarrelRoll (player_t *player) slope -= Quaketilt(player); } - delta = (INT32)( slope - player->tilt )/ cv_tiltsmoothing.value; + delta = slope - player->tilt; + smoothing = FixedDiv(AbsAngle(slope), ANGLE_45); + + delta = FixedDiv(delta, cv_tiltsmoothing.value * + FixedDiv(FRACUNIT, FRACUNIT + smoothing)); if (delta) player->tilt += delta; else - player->tilt = slope; - - if (cv_tilting.value) - { - player->viewrollangle = player->tilt; - - if (cv_actionmovie.value) - { - player->viewrollangle += quake.roll; - } - } - else - { - player->viewrollangle = 0; - } + player->tilt = slope; } // @@ -4324,11 +4331,6 @@ void P_PlayerThink(player_t *player) ticcmd_t *cmd; const size_t playeri = (size_t)(player - players); - player->lerp.aiming = player->aiming; - player->lerp.awayviewaiming = player->awayviewaiming; - player->lerp.frameangle = player->frameangle; - player->lerp.viewrollangle = player->viewrollangle; - #ifdef PARANOIA if (!player->mo) I_Error("p_playerthink: players[%s].mo == NULL", sizeu1(playeri)); @@ -4554,12 +4556,19 @@ void P_PlayerThink(player_t *player) else curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V } + + if (player->spectator) + player->laptime[LAP_CUR] = 0; + else + player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V } else { player->realtime = 0; if (player == &players[consoleplayer]) curlap = 0; + + player->laptime[LAP_CUR] = 0; } } diff --git a/src/r_bsp.c b/src/r_bsp.c index fbb2ea35a..58573eb99 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -1071,10 +1071,10 @@ static void R_Subsector(size_t num) { light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight); ffloor[numffloors].plane = R_FindPlane(polysec->floorheight, polysec->floorpic, - polysec->lightlevel, polysec->floor_xoffs, polysec->floor_yoffs, - polysec->floorpic_angle-po->angle, - NULL, NULL, po - , NULL // will ffloors be slopable eventually? + (light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->floor_xoffs, polysec->floor_yoffs, + polysec->floorpic_angle-po->angle, + (light == -1 ? frontsector->extra_colormap : frontsector->lightlist[light].extra_colormap), NULL, po + ,NULL // will ffloors be slopable eventually? , R_NoEncore(polysec, false)); ffloor[numffloors].height = polysec->floorheight; @@ -1094,12 +1094,11 @@ static void R_Subsector(size_t num) && polysec->ceilingheight <= ceilingcenterz && (viewz > polysec->ceilingheight)) { - light = R_GetPlaneLight(frontsector, polysec->ceilingheight, viewz < polysec->ceilingheight); + light = R_GetPlaneLight(frontsector, polysec->floorheight, viewz < polysec->floorheight); ffloor[numffloors].plane = R_FindPlane(polysec->ceilingheight, polysec->ceilingpic, - polysec->lightlevel, polysec->ceiling_xoffs, polysec->ceiling_yoffs, - polysec->ceilingpic_angle-po->angle, - NULL, NULL, po - , NULL // will ffloors be slopable eventually? + (light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->ceiling_xoffs, polysec->ceiling_yoffs, polysec->ceilingpic_angle-po->angle, + (light == -1 ? frontsector->extra_colormap : frontsector->lightlist[light].extra_colormap), NULL, po + ,NULL // will ffloors be slopable eventually? , R_NoEncore(polysec, true)); ffloor[numffloors].polyobj = po; @@ -1143,7 +1142,7 @@ static void R_Subsector(size_t num) { // CONS_Debug(DBG_GAMELOGIC, "Adding normal line %d...(%d)\n", line->linedef-lines, leveltime); if (!line->polyseg) // ignore segs that belong to polyobjects - R_AddLine(line); + R_AddLine(line); line++; curline = NULL; /* cph 2001/11/18 - must clear curline now we're done with it, so stuff doesn't try using it for other things */ } @@ -1205,7 +1204,7 @@ void R_Prep3DFloors(sector_t *sector) rover->lastlight = 0; if (!(rover->flags & FF_EXISTS) || (rover->flags & FF_NOSHADE && !(rover->flags & FF_CUTLEVEL) && !(rover->flags & FF_CUTSPRITES))) - continue; + continue; heighttest = *rover->t_slope ? P_GetZAt(*rover->t_slope, sector->soundorg.x, sector->soundorg.y) : *rover->topheight; diff --git a/src/r_fps.c b/src/r_fps.c index a5e40ee97..17e357a16 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -145,6 +145,11 @@ static void R_SetupFreelook(void) #undef AIMINGTODY +void R_InterpolateViewRollAngle(fixed_t frac) +{ + viewroll = oldview->roll + R_LerpAngle(oldview->roll, newview->roll, frac); +} + void R_InterpolateView(fixed_t frac, boolean forceinvalid) { viewvars_t* prevview = oldview; @@ -176,12 +181,11 @@ void R_InterpolateView(fixed_t frac, boolean forceinvalid) viewangle = R_LerpAngle(prevview->angle, newview->angle, frac); aimingangle = R_LerpAngle(prevview->aim, newview->aim, frac); + viewroll = R_LerpAngle(prevview->roll, newview->roll, frac); viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - // this is gonna create some interesting visual errors for long distance teleports... - // might want to recalculate the view sector every frame instead... viewplayer = newview->player; viewsector = R_PointInSubsector(viewx, viewy)->sector; diff --git a/src/r_fps.h b/src/r_fps.h index 1b7b02cac..a4aef71cd 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -47,6 +47,7 @@ typedef struct { angle_t angle; angle_t aim; + angle_t roll; fixed_t cos; fixed_t sin; mobj_t *mobj; @@ -118,6 +119,8 @@ typedef struct levelinterpolator_s { // Interpolates the current view variables (r_state.h) against the selected view context in R_SetViewContext void R_InterpolateView(fixed_t frac, boolean forceinvalid); +// Special function just for software +void R_InterpolateViewRollAngle(fixed_t frac); // Buffer the current new views into the old views. Call once after each real tic. void R_UpdateViewInterpolation(void); // Reset the view states (e.g. after level load) so R_InterpolateView doesn't interpolate invalid data diff --git a/src/r_main.c b/src/r_main.c index 58810c37b..6ea1433a8 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -57,7 +57,7 @@ size_t framecount; size_t loopcount; fixed_t viewx, viewy, viewz; -angle_t viewangle, aimingangle; +angle_t viewangle, aimingangle, viewroll; UINT8 viewssnum; fixed_t viewcos, viewsin; boolean skyVisible; @@ -140,18 +140,25 @@ ps_metric_t ps_numsprites = {0}; ps_metric_t ps_numdrawnodes = {0}; ps_metric_t ps_numpolyobjects = {0}; +#if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) +static CV_PossibleValue_t drawdist_cons_t[] = { + /*{256, "256"},*/ {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, + {8192, "8192"}, {12288, "12288"}, {20480, "20480"}, + {24576, "24576"},{0, "Infinite"}, {0, NULL}}; + +static CV_PossibleValue_t drawdist_precip_cons_t[] = { + {256, "256"}, {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {0, "None"}, {0, NULL}}; +#else static CV_PossibleValue_t drawdist_cons_t[] = { /*{256, "256"},*/ {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; -#if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) -static CV_PossibleValue_t drawdist_precip_cons_t[] = { - {256, "256"}, {512, "512"}, {768, "768"}, - {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {0, "None"}, {0, NULL}}; -#else static CV_PossibleValue_t drawdist_precip_cons_t[] = { {256, "256"}, {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, @@ -159,10 +166,10 @@ static CV_PossibleValue_t drawdist_precip_cons_t[] = { #endif static CV_PossibleValue_t maxinterpdist_cons_t[] = { - /*{256, "256"},*/ {512, "512"}, {768, "768"}, + /*{256, "256"},*/ {512, "512"}, {768, "768"}, {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, - {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; + {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; static CV_PossibleValue_t fov_cons_t[] = {{5*FRACUNIT, "MIN"}, {178*FRACUNIT, "MAX"}, {0, NULL}}; @@ -733,7 +740,7 @@ void R_CheckViewMorph(void) INT32 end, vx, vy, pos, usedpos; INT32 usedx, usedy, halfwidth = vid.width/2, halfheight = vid.height/2; - angle_t rollangle = players[displayplayers[0]].viewrollangle; + angle_t rollangle = viewroll; rollangle >>= ANGLETOFINESHIFT; rollangle = ((rollangle+2) & ~3) & FINEMASK; // Limit the distinct number of angles to reduce recalcs from angles changing a lot. @@ -917,6 +924,45 @@ void R_ApplyViewMorph(void) vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.width); } +static inline int intsign(int n) { + return n < 0 ? -1 : n > 0 ? 1 : 0; +} + +angle_t R_ViewRollAngle(const player_t *player) +{ + angle_t roll = 0; + + if (gamestate != GS_LEVEL) + { + // FIXME: The way this is implemented is totally + // incompatible with cameras that aren't directly + // tied to the player. (podium, titlemap, + // MT_ALTVIEWMAN in general) + + // All of these player variables should affect their + // camera_t in P_MoveChaseCamera, and then this + // just returns that variable instead. + return 0; + } + + roll = player->viewrollangle; + + if (cv_tilting.value) + { + if (!player->spectator && !demo.freecam) + roll += player->tilt; + + if (cv_actionmovie.value) + { + int xs = intsign(quake.x), + ys = intsign(quake.y), + zs = intsign(quake.z); + roll += (xs ^ ys ^ zs) * ANG1; + } + } + + return roll; +} // // R_SetViewSize @@ -1188,6 +1234,7 @@ void R_SkyboxFrame(player_t *player) } } newview->angle += viewmobj->angle; + newview->roll = R_ViewRollAngle(player); newview->player = player; @@ -1471,6 +1518,7 @@ void R_SetupFrame(player_t *player, boolean skybox) } } } + newview->roll = R_ViewRollAngle(player); newview->z += quake.z; newview->player = player; diff --git a/src/r_main.h b/src/r_main.h index 1a589088d..6c59d9961 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -126,6 +126,7 @@ void R_Init(void); void R_CheckViewMorph(void); void R_ApplyViewMorph(void); +angle_t R_ViewRollAngle(const player_t *player); // just sets setsizeneeded true extern boolean setsizeneeded; diff --git a/src/r_state.h b/src/r_state.h index 670f800d1..5234d1d62 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -88,7 +88,7 @@ extern side_t *sides; // POV data. // extern fixed_t viewx, viewy, viewz; -extern angle_t viewangle, aimingangle; +extern angle_t viewangle, aimingangle, viewroll; extern UINT8 viewssnum; // splitscreen view number extern boolean viewsky, skyVisible; extern boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible of each splitscreen player diff --git a/src/r_things.c b/src/r_things.c index 068358802..0f5da1873 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1581,7 +1581,7 @@ static void R_ProjectSprite(mobj_t *thing) } heightsec = thing->subsector->sector->heightsec; - if (viewplayer->mo && viewplayer->mo->subsector) + if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; else phs = -1; @@ -2202,13 +2202,15 @@ static void R_CreateDrawNodes(void) } } // Check for a polyobject plane, but only if this is a front line - if (ds->curline->polyseg && ds->curline->polyseg->visplane && !ds->curline->side) { + if (ds->curline->polyseg && ds->curline->polyseg->visplane && !ds->curline->side) + { plane = ds->curline->polyseg->visplane; R_PlaneBounds(plane); if (plane->low < 0 || plane->high > vid.height || plane->high > plane->low) ; - else { + else + { // Put it in! entry = R_CreateDrawNode(&nodehead); entry->plane = plane; @@ -2231,6 +2233,7 @@ static void R_CreateDrawNodes(void) { if (!ds->ffloorplanes[p]) continue; + plane = ds->ffloorplanes[p]; R_PlaneBounds(plane); @@ -2303,10 +2306,12 @@ static void R_CreateDrawNodes(void) continue; // Effective height may be different for each comparison in the case of slopes - if (r2->plane->slope) { + if (r2->plane->slope) + { planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy); planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy); - } else + } + else planeobjectz = planecameraz = r2->plane->height; if (rover->mobjflags & MF_NOCLIPHEIGHT) @@ -2365,16 +2370,20 @@ static void R_CreateDrawNodes(void) if (scale <= rover->sortscale) continue; - if (*r2->ffloor->t_slope) { + if (*r2->ffloor->t_slope) + { topplaneobjectz = P_GetZAt(*r2->ffloor->t_slope, rover->gx, rover->gy); topplanecameraz = P_GetZAt(*r2->ffloor->t_slope, viewx, viewy); - } else + } + else topplaneobjectz = topplanecameraz = *r2->ffloor->topheight; - if (*r2->ffloor->b_slope) { + if (*r2->ffloor->b_slope) + { botplaneobjectz = P_GetZAt(*r2->ffloor->b_slope, rover->gx, rover->gy); botplanecameraz = P_GetZAt(*r2->ffloor->b_slope, viewx, viewy); - } else + } + else botplaneobjectz = botplanecameraz = *r2->ffloor->bottomheight; if ((topplanecameraz > viewz && botplanecameraz < viewz) || diff --git a/src/r_things.h b/src/r_things.h index 3e2414da1..f78766862 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -25,7 +25,7 @@ // number of sprite lumps for spritewidth,offset,topoffset lookup tables // Fab: this is a hack : should allocate the lookup tables per sprite #if defined(__x86_64__) || defined(__amd64__) || defined(__aarch64__) || defined(__arm64__) // only for 64bit (idk how else to proper check lmao) -#define MAXVISSPRITES 4096 +#define MAXVISSPRITES 6140 #else #define MAXVISSPRITES 2048 // added 2-2-98 was 128 #endif diff --git a/src/s_sound.c b/src/s_sound.c index ae036a3db..e6f2af24a 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1375,17 +1375,7 @@ void S_LoadMusicDefs(UINT16 wadnum) // Find music def while (stoken) { - /*if ((stoken[0] == '/' && stoken[1] == '/') - || (stoken[0] == '#')) // skip comments - { - stoken = strtok(NULL, "\r\n"); // skip end of line - if (def) - stoken = strtok(NULL, "\r\n= "); - else - stoken = strtok(NULL, "\r\n "); - line++; - } - else*/ if (!stricmp(stoken, "lump")) + if (!stricmp(stoken, "lump")) { value = strtok(NULL, "\r\n "); @@ -1460,35 +1450,44 @@ skip_lump: return; } - if (!stricmp(stoken, "usage")) { + if (!stricmp(stoken, "usage")) + { STRBUFCPY(def->usage, value); for (value = def->usage; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set usage to '%s'\n", def->usage); - } else if (!stricmp(stoken, "source")) { + } + else if (!stricmp(stoken, "source")) + { STRBUFCPY(def->source, value); for (value = def->source; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "title")) { + } + else if (!stricmp(stoken, "title")) + { def->use_info = true; STRBUFCPY(def->title, value); for (value = def->title; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "alttitle")) { + } + else if (!stricmp(stoken, "alttitle")) + { STRBUFCPY(def->alttitle, value); for (value = def->alttitle; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "authors")) { + } + else if (!stricmp(stoken, "authors")) + { STRBUFCPY(def->authors, value); for (value = def->authors; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else { - CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); } + else + CONS_Alert(CONS_WARNING, "MUSICDEF: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); skip_field: stoken = strtok(NULL, "\r\n= "); @@ -1559,17 +1558,7 @@ void S_LoadMTDefs(UINT16 wadnum) // Find music def while (stoken) { - /*if ((stoken[0] == '/' && stoken[1] == '/') - || (stoken[0] == '#')) // skip comments - { - stoken = strtok(NULL, "\r\n"); // skip end of line - if (def) - stoken = strtok(NULL, "\r\n= "); - else - stoken = strtok(NULL, "\r\n "); - line++; - } - else*/ if (!stricmp(stoken, "lump")) + if (!stricmp(stoken, "lump")) { value = strtok(NULL, "\r\n "); @@ -1638,25 +1627,30 @@ skip_lump: return; } - if (!stricmp(stoken, "title")) { + if (!stricmp(stoken, "title")) + { def->use_info = true; STRBUFCPY(def->title, value); for (value = def->title; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "alttitle")) { + } + else if (!stricmp(stoken, "alttitle")) + { STRBUFCPY(def->alttitle, value); for (value = def->alttitle; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else if (!stricmp(stoken, "authors")) { + } + else if (!stricmp(stoken, "authors")) + { STRBUFCPY(def->authors, value); for (value = def->authors; *value; value++) if (*value == '_') *value = ' '; // turn _ into spaces. //CONS_Printf("S_LoadMusicDefs: Set source to '%s'\n", def->source); - } else { - CONS_Alert(CONS_WARNING, "MUSCINFO: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); } + else + CONS_Alert(CONS_WARNING, "MUSCINFO: Invalid field '%s'. (file %s, line %d)\n", stoken, wadfiles[wadnum]->filename, line); skip_field: stoken = strtok(NULL, "\r\n= "); @@ -2363,9 +2357,8 @@ static void Command_ShowMusicCredit_f(void) musicdef_t *def = S_FindMusicCredit(musname); - if (def) { + if (def) CONS_Printf("%.6s - %.255s\n", musname, def->source); - } } static void GameSounds_OnChange(void) @@ -2396,6 +2389,7 @@ static void SoundPrecache_OnChange(void) else if (!S_PrecacheSound()) { S_ClearSfx(); + if (!sound_disabled) S_InitSfxChannels(cv_soundvolume.value); } diff --git a/src/st_stuff.c b/src/st_stuff.c index 715ba53ae..7e28edfc8 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -526,17 +526,7 @@ static void ST_drawDebugInfo(void) if (cv_debug & DBG_DETAILED) { - //V_DrawRightAlignedString(320, height - 104, V_MONOSPACE, va("SHIELD: %5x", stplyr->powers[pw_shield])); V_DrawRightAlignedString(320, height - 96, V_MONOSPACE, va("SCALE: %5d%%", (stplyr->mo->scale*100)/FRACUNIT)); - //V_DrawRightAlignedString(320, height - 88, V_MONOSPACE, va("DASH: %3d/%3d", stplyr->dashspeed>>FRACBITS, FixedMul(stplyr->maxdash,stplyr->mo->scale)>>FRACBITS)); - //V_DrawRightAlignedString(320, height - 80, V_MONOSPACE, va("AIR: %4d, %3d", stplyr->powers[pw_underwater], stplyr->powers[pw_spacetime])); - - // Flags - //V_DrawRightAlignedString(304-64, height - 72, V_MONOSPACE, "Flags:"); - //V_DrawString(304-60, height - 72, (stplyr->jumping) ? V_GREENMAP : V_REDMAP, "JM"); - //V_DrawString(304-40, height - 72, (stplyr->pflags & PF_JUMPED) ? V_GREENMAP : V_REDMAP, "JD"); - //V_DrawString(304-20, height - 72, (stplyr->pflags & PF_SPINNING) ? V_GREENMAP : V_REDMAP, "SP"); - //V_DrawString(304, height - 72, (stplyr->pflags & PF_STARTDASH) ? V_GREENMAP : V_REDMAP, "ST"); V_DrawRightAlignedString(320, height - 64, V_MONOSPACE, va("CEILZ: %6d", stplyr->mo->ceilingz>>FRACBITS)); V_DrawRightAlignedString(320, height - 56, V_MONOSPACE, va("FLOORZ: %6d", stplyr->mo->floorz>>FRACBITS)); @@ -570,132 +560,6 @@ static void ST_drawDebugInfo(void) V_DrawRightAlignedString(320, height, V_MONOSPACE, va("Heap used: %7sKB", sizeu1(Z_TagsUsage(0, INT32_MAX)>>10))); } -/* -static void ST_drawScore(void) -{ - // SCORE: - ST_DrawPatchFromHud(HUD_SCORE, sboscore); - if (objectplacing) - { - if (op_displayflags > UINT16_MAX) - ST_DrawOverlayPatch(SCX(hudinfo[HUD_SCORENUM].x-tallminus->width), SCY(hudinfo[HUD_SCORENUM].y), tallminus); - else - ST_DrawNumFromHud(HUD_SCORENUM, op_displayflags); - } - else - ST_DrawNumFromHud(HUD_SCORENUM, stplyr->score); -} -*/ - -/* -static void ST_drawTime(void) -{ - INT32 seconds, minutes, tictrn, tics; - - // TIME: - ST_DrawPatchFromHudWS(HUD_TIME, sbotime); - - if (objectplacing) - { - tics = objectsdrawn; - seconds = objectsdrawn%100; - minutes = objectsdrawn/100; - tictrn = 0; - } - else - { - tics = stplyr->realtime; - seconds = G_TicsToSeconds(tics); - minutes = G_TicsToMinutes(tics, true); - tictrn = G_TicsToCentiseconds(tics); - } - - if (cv_timetic.value == 1) // Tics only -- how simple is this? - ST_DrawNumFromHudWS(HUD_SECONDS, tics); - else - { - ST_DrawNumFromHudWS(HUD_MINUTES, minutes); // Minutes - ST_DrawPatchFromHudWS(HUD_TIMECOLON, sbocolon); // Colon - ST_DrawPadNumFromHudWS(HUD_SECONDS, seconds, 2); // Seconds - - if (!splitscreen && (cv_timetic.value == 2 || modeattacking)) // there's not enough room for tics in splitscreen, don't even bother trying! - { - ST_DrawPatchFromHud(HUD_TIMETICCOLON, sboperiod); // Period - ST_DrawPadNumFromHud(HUD_TICS, tictrn, 2); // Tics - } - } -} -*/ - -/* -static inline void ST_drawRings(void) // SRB2kart - unused. -{ - INT32 ringnum = max(stplyr->health-1, 0); - - ST_DrawPatchFromHudWS(HUD_RINGS, ((stplyr->health <= 1 && leveltime/5 & 1) ? rrings : sborings)); - - if (objectplacing) - ringnum = op_currentdoomednum; - else if (!useNightsSS && G_IsSpecialStage(gamemap)) - { - INT32 i; - ringnum = 0; - for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && players[i].mo && players[i].mo->health > 1) - ringnum += players[i].mo->health - 1; - } - - ST_DrawNumFromHudWS(HUD_RINGSNUM, ringnum); -} -*/ - -/* -static void ST_drawLives(void) // SRB2kart - unused. -{ - const INT32 v_splitflag = (splitscreen && stplyr == &players[displayplayers[0]] ? V_SPLITSCREEN : 0); - - if (!stplyr->skincolor) - return; // Just joined a server, skin isn't loaded yet! - - // face background - V_DrawSmallScaledPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, livesback); - - // face - if (stplyr->mo && stplyr->mo->color) - { - // skincolor face/super - UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->mo->color, GTC_CACHE); - patch_t *face = facerankprefix[stplyr->skin]; - if (stplyr->powers[pw_super] || stplyr->pflags & PF_NIGHTSMODE) - face = facewantprefix[stplyr->skin]; - V_DrawSmallMappedPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,face, colormap); - } - else if (stplyr->skincolor) - { - // skincolor face - UINT8 *colormap = R_GetTranslationColormap(stplyr->skin, stplyr->skincolor, GTC_CACHE); - V_DrawSmallMappedPatch(hudinfo[HUD_LIVESPIC].x, hudinfo[HUD_LIVESPIC].y + (v_splitflag ? -12 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag,facerankprefix[stplyr->skin], colormap); - } - - // name - if (strlen(skins[stplyr->skin].hudname) > 8) - V_DrawThinString(hudinfo[HUD_LIVESNAME].x, hudinfo[HUD_LIVESNAME].y + (v_splitflag ? -12 : 0), - V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_MONOSPACE|V_YELLOWMAP|v_splitflag, skins[stplyr->skin].hudname); - else - V_DrawString(hudinfo[HUD_LIVESNAME].x, hudinfo[HUD_LIVESNAME].y + (v_splitflag ? -12 : 0), - V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_MONOSPACE|V_YELLOWMAP|v_splitflag, skins[stplyr->skin].hudname); - // x - V_DrawScaledPatch(hudinfo[HUD_LIVESX].x, hudinfo[HUD_LIVESX].y + (v_splitflag ? -4 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, stlivex); - // lives - V_DrawRightAlignedString(hudinfo[HUD_LIVESNUM].x, hudinfo[HUD_LIVESNUM].y + (v_splitflag ? -4 : 0), - V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANS|v_splitflag, va("%d",stplyr->lives)); -} -*/ - static void ST_drawLevelTitle(void) { char *lvlttl = mapheaderinfo[gamemap-1]->lvlttl; @@ -841,15 +705,6 @@ static void ST_overlayDrawer(void) } } } - - // This is where we draw all the fun cheese if you have the chasecam off! - /*if ((stplyr == &players[displayplayers[0]] && !camera[0].chase) - || ((splitscreen && stplyr == &players[displayplayers[1]]) && !camera[1].chase) - || ((splitscreen > 1 && stplyr == &players[displayplayers[2]]) && !camera[2].chase) - || ((splitscreen > 2 && stplyr == &players[displayplayers[3]]) && !camera[3].chase)) - { - ST_drawFirstPersonHUD(); - }*/ } if (!(netgame || multiplayer) || !hu_showscores) diff --git a/src/tables.h b/src/tables.h index 0ea09caf6..f643895a5 100644 --- a/src/tables.h +++ b/src/tables.h @@ -94,6 +94,12 @@ FUNCMATH FUNCINLINE static ATTRINLINE angle_t InvAngle(angle_t a) { return (ANGLE_MAX-a)+1; } + +// 315 = 45 +FUNCMATH FUNCINLINE static ATTRINLINE angle_t AbsAngle(angle_t a) +{ + return a & ANGLE_180 ? InvAngle(a) : a; +} // angle_t to fixed_t f(ANGLE_45) = 45*FRACUNIT FUNCMATH fixed_t AngleFixed(angle_t af); // fixed_t to angle_t f(45*FRACUNIT) = ANGLE_45 diff --git a/src/v_video.c b/src/v_video.c index bc1dd4159..4c5e1cfd3 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -15,6 +15,7 @@ #include "doomdef.h" #include "r_local.h" +#include "p_local.h" #include "v_video.h" #include "hu_stuff.h" #include "r_draw.h" @@ -3135,7 +3136,7 @@ INT32 heatindex[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; // // Perform a particular image postprocessing function. // -#include "p_local.h" + void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) { #if NUMSCREENS < 5 @@ -3203,8 +3204,8 @@ void V_DoPostProcessor(INT32 view, postimg_t type, INT32 param) } } -/* -Unoptimized version + /* + Unoptimized version for (x = 0; x < vid.width*vid.bpp; x++) { newpix = (x + sine); diff --git a/src/w_wad.c b/src/w_wad.c index 04015d614..762cdc417 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -62,9 +62,6 @@ #include "md5.h" #include "lua_script.h" #include "st_stuff.h" -#ifdef SCANTHINGS -#include "p_setup.h" // P_ScanThings -#endif #include "m_misc.h" // M_MapNumber #include "p_setup.h" // P_PartialAddFile mayb @@ -117,7 +114,8 @@ void W_Shutdown(void) if (wad->handle) fclose(wad->handle); Z_Free(wad->filename); - while (wad->numlumps--) { + while (wad->numlumps--) + { Z_Free(wad->lumpinfo[wad->numlumps].longname); Z_Free(wad->lumpinfo[wad->numlumps].fullname); } @@ -287,22 +285,6 @@ static inline void W_LoadDehackedLumps(UINT16 wadnum) DEH_LoadDehackedLumpPwad(wadnum, lump); } } - -#ifdef SCANTHINGS - // Scan maps for emblems 'n shit - { - lumpinfo_t *lump_p = wadfiles[wadnum]->lumpinfo; - for (lump = 0; lump < wadfiles[wadnum]->numlumps; lump++, lump_p++) - { - const char *name = lump_p->name; - if (name[0] == 'M' && name[1] == 'A' && name[2] == 'P' && name[5]=='\0') - { - INT16 mapnum = (INT16)M_MapNumber(name[3], name[4]); - P_ScanThings(mapnum, wadnum, lump + ML_THINGS); - } - } - } -#endif } /** Compute MD5 message digest for bytes read from STREAM of this filname.