diff --git a/src/g_game.c b/src/g_game.c index 5fdbbd231..00792bf96 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -646,7 +646,7 @@ void G_SetGameModified(boolean silent, boolean major) G_SetSaveGameModified(); if (!silent) - CONS_Alert(CONS_NOTICE, M_GetText("Record Attack data will be saved to seperate save.\n")); + CONS_Alert(CONS_NOTICE, M_GetText("Record Attack data will be saved to a seperate save file.\n")); // If in record attack recording, cancel it. if (modeattacking) @@ -3646,6 +3646,7 @@ void G_SaveGameData(boolean force) UINT8 btemp; savebuffer_t save; (void)force; + char backupfile[MAX_WADPATH+4]; if (!gamedataloaded) return; // If never loaded (-nodata), don't save @@ -3657,6 +3658,23 @@ void G_SaveGameData(boolean force) return; } + // Create backup of the save data + snprintf(backupfile, sizeof(backupfile), "%s.bak", gamedatafilename); + backupfile[sizeof(backupfile) - 1] = '\0'; + + FILE *gamedata = fopen(gamedatafilename, "r"); + + if (gamedata != NULL) + { + fclose(gamedata); + + if (!FIL_CopyFile(gamedatafilename, backupfile)) + { + CONS_Alert(CONS_WARNING,"Failed to create a backup of save data. Will not attempt to write to save data\n"); + return; + } + } + // Version test WRITEUINT32(save.p, 0xFCAFE211); diff --git a/src/m_menu.c b/src/m_menu.c index 6d54e44d8..3024d28d7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6351,7 +6351,7 @@ static boolean M_AddonsRefresh(void) else if (majormods && !prevmajormods) { S_StartSound(NULL, sfx_s221); - message = va("%c%s\x80\nYou've loaded a gameplay-modifying addon.\n\nRecord Attack data will be saved to seperate save.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); + message = va("%c%s\x80\nYou've loaded a gameplay-modifying addon.\n\nRecord Attack data will be saved to a seperate save file.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); prevmajormods = majormods; } diff --git a/src/r_segs.c b/src/r_segs.c index 9a2af70ba..029af7071 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -1181,6 +1181,18 @@ static boolean R_FFloorCanClip(visffloor_t *pfloor) return (cv_ffloorclip.value && !R_IsFFloorTranslucent(pfloor) && !pfloor->polyobj); } +// R_ExpandPlaneY +// +// A simple function to modify a vsplane's top and bottom for a particular column +// Sort of like R_ExpandPlane in r_plane.c, except this is vertical expansion +static inline void R_ExpandPlaneY(visplane_t *pl, INT32 x, INT16 top, INT16 bottom) +{ + // Expand the plane, don't shrink it! + // note: top and bottom default to 0xFFFF and 0x0000 respectively, which is totally compatible with this + if (pl->top[x] > top) pl->top[x] = top; + if (pl->bottom[x] < bottom) pl->bottom[x] = bottom; +} + // // R_RenderSegLoop // Draws zero, one, or two textures (and possibly a masked @@ -1220,15 +1232,11 @@ static void R_RenderSegLoop (void) if (markceiling) { - bottom = yl-1; + bottom = yl > floorclip[rw_x] ? floorclip[rw_x] : yl; - if (bottom >= floorclip[rw_x]) - bottom = floorclip[rw_x]-1; - - if (top <= bottom && ceilingplane) + if (top <= --bottom && ceilingplane) { - ceilingplane->top[rw_x] = (INT16)top; - ceilingplane->bottom[rw_x] = (INT16)bottom; + R_ExpandPlaneY(ceilingplane, rw_x, top, bottom); } } @@ -1245,8 +1253,7 @@ static void R_RenderSegLoop (void) if (++top <= bottom && floorplane) { - floorplane->top[rw_x] = (INT16)top; - floorplane->bottom[rw_x] = (INT16)bottom; + R_ExpandPlaneY(floorplane, rw_x, top, bottom); } } @@ -1266,14 +1273,6 @@ static void R_RenderSegLoop (void) if (ffloor[i].polyobj && (!curline->polyseg || ffloor[i].polyobj != curline->polyseg)) continue; - // FIXME hack to fix planes disappearing when a seg goes behind the camera. This NEEDS to be changed to be done properly. -Red - if (curline->polyseg) { - if (ffloor[i].plane->minx > rw_x) - ffloor[i].plane->minx = rw_x; - else if (ffloor[i].plane->maxx < rw_x) - ffloor[i].plane->maxx = rw_x; - } - if (ffloor[i].height < viewz) { INT32 top_w = (ffloor[i].f_frac >> HEIGHTBITS) + 1; @@ -1286,7 +1285,7 @@ static void R_RenderSegLoop (void) bottom_w = bottom; // Polyobject-specific hack to fix plane leaking -Red - if (curline->polyseg && ffloor[i].polyobj && ffloor[i].polyobj == curline->polyseg && top_w >= bottom_w) { + if (ffloor[i].polyobj && top_w >= bottom_w) { ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; } else @@ -1330,7 +1329,7 @@ static void R_RenderSegLoop (void) bottom_w = bottom; // Polyobject-specific hack to fix plane leaking -Red - if (curline->polyseg && ffloor[i].polyobj && ffloor[i].polyobj == curline->polyseg && top_w >= bottom_w) { + if (ffloor[i].polyobj && top_w >= bottom_w) { ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; } else @@ -2816,6 +2815,22 @@ void R_StoreWallRange(INT32 start, INT32 stop) for (i = 0; i < numffloors; i++) R_ExpandPlane(ffloor[i].plane, rw_x, rw_stopx - 1); } + + // FIXME hack to fix planes disappearing when a seg goes behind the camera. This NEEDS to be changed to be done properly. -Red + if (curline->polyseg) + { + for (i = 0; i < numffloors; i++) + { + if (!ffloor[i].polyobj || ffloor[i].polyobj != curline->polyseg) + continue; + if (ffloor[i].plane->minx > rw_x) + ffloor[i].plane->minx = rw_x; + + if (ffloor[i].plane->maxx < rw_stopx - 1) + ffloor[i].plane->maxx = rw_stopx - 1; + } + } + } rw_silhouette = &(ds_p->silhouette); diff --git a/src/r_things.c b/src/r_things.c index d37107ca7..44720585c 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1245,7 +1245,7 @@ static void R_ProjectSprite(mobj_t *thing) tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance // too far off the side? - if (!papersprite && abs(tx) > FixedMul(tz, fovtan)<<2) // papersprite clipping is handled later + if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later return; // aspect ratio stuff @@ -1522,10 +1522,7 @@ static void R_ProjectSprite(mobj_t *thing) } // Compatibility with MSVC - SSNTails - scalestep = ((yscale2 - yscale) / range); - if (!scalestep) - scalestep = 1; - + scalestep = ((yscale2 - yscale)/range) ?: 1; xscale = FixedDiv(range< FixedMul(tz, fovtan)<<2) + if (abs(tx) > tz<<2) return; // aspect ratio stuff :