Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
669b42c4bb | ||
|
|
2a658a8476 | ||
|
|
8cab07a4b2 | ||
|
|
55c8546d68 | ||
|
|
1762f18116 |
No files matched your search
+70
-24
@@ -653,6 +653,68 @@ static boolean D_Display(void)
|
||||
return ranwipe;
|
||||
}
|
||||
|
||||
static UINT64 precision = 0;
|
||||
static precise_t sleeptime = 0;
|
||||
|
||||
static void D_LimitFps(void)
|
||||
{
|
||||
static precise_t curtime = 0, lasttime = 0;
|
||||
static precise_t start;
|
||||
precise_t elapsed = 0;
|
||||
|
||||
sleeptime = 0;
|
||||
|
||||
// timedemo runs uncapped!
|
||||
if (singletics)
|
||||
return;
|
||||
|
||||
// in the case of "match refresh rate" + vsync, don't sleep at all
|
||||
if (cv_vidwait.value && cv_fpscap.value == 0)
|
||||
return;
|
||||
|
||||
const UINT32 framecap = R_GetFramerateCap();
|
||||
|
||||
// uncapped obviously does not need to be... capped...
|
||||
if (framecap == 0)
|
||||
return;
|
||||
|
||||
start = I_GetPreciseTime();
|
||||
|
||||
// frametarget in precise_t ticks (ex. 60fps = ~16,666,666)
|
||||
const precise_t frametarget = precision / framecap;
|
||||
|
||||
while (1)
|
||||
{
|
||||
// check the current time against the "time of the old frame""
|
||||
curtime = I_GetPreciseTime();
|
||||
elapsed = curtime - lasttime;
|
||||
|
||||
// done waiting!
|
||||
// continue as normal
|
||||
if (elapsed >= frametarget)
|
||||
{
|
||||
lasttime = curtime;
|
||||
|
||||
// time we spent :chaosleep:ing or doing absolutely nothing
|
||||
// for frameskip calculations
|
||||
sleeptime = curtime - start;
|
||||
return;
|
||||
}
|
||||
|
||||
// if we have more than 1ms to wait
|
||||
// sleep for a bit to not trash the cpu lul
|
||||
precise_t remaining = frametarget - elapsed;
|
||||
|
||||
if (remaining > (precise_t)(precision / 1000))
|
||||
{
|
||||
// sleep for 90% of the time we gotta wait for the next frame
|
||||
// since we dont wanna oversleep :chaosleep:
|
||||
I_SleepDuration(9 * remaining / 10);
|
||||
}
|
||||
}
|
||||
// the rest we just be waitin until we meet our frametime target
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
// D_SRB2Loop
|
||||
// =========================================================================
|
||||
@@ -664,7 +726,6 @@ void D_SRB2Loop(void)
|
||||
tic_t entertic = 0, oldentertics = 0, realtics = 0, rendertimeout = INFTICS;
|
||||
double deltatics = 0.0;
|
||||
double deltasecs = 0.0;
|
||||
UINT64 precision = 0;
|
||||
|
||||
boolean interp = false;
|
||||
boolean doDisplay = false;
|
||||
@@ -704,22 +765,16 @@ void D_SRB2Loop(void)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// capbudget is the minimum precise_t duration of a single loop iteration
|
||||
precise_t capbudget;
|
||||
precise_t elapsed;
|
||||
precise_t enterprecise, finishprecise;
|
||||
|
||||
enterprecise = I_GetPreciseTime();
|
||||
|
||||
boolean ranwipe = false;
|
||||
|
||||
memset(&g_dc, 0, sizeof(g_dc));
|
||||
Z_Frame_Reset();
|
||||
|
||||
// Casting the return value of a function is bad practice (apparently)
|
||||
const UINT32 framecap = R_GetFramerateCap();
|
||||
capbudget = (framecap == 0) ? 0 : (precise_t)((double)precision / (double)framecap + 0.5); // + 0.5 instead of round
|
||||
|
||||
boolean ranwipe = false;
|
||||
|
||||
I_UpdateTime(cv_timescale.value);
|
||||
|
||||
if (lastwipetic)
|
||||
@@ -809,6 +864,10 @@ void D_SRB2Loop(void)
|
||||
R_SetTimeFrac(FRACUNIT);
|
||||
}
|
||||
|
||||
// be sure to limit our fps *before* drawing
|
||||
// so we can properly "pace" our frames
|
||||
D_LimitFps();
|
||||
|
||||
if (interp || doDisplay)
|
||||
{
|
||||
if (!frameskip)
|
||||
@@ -843,9 +902,9 @@ void D_SRB2Loop(void)
|
||||
// Fully completed frame made.
|
||||
finishprecise = I_GetPreciseTime();
|
||||
|
||||
// Use the time before sleep for frameskip calculations:
|
||||
// Use the time without sleep for frameskip calculations:
|
||||
// post-sleep time is literally being intentionally wasted
|
||||
elapsed = finishprecise - enterprecise;
|
||||
elapsed = (finishprecise - enterprecise) - sleeptime;
|
||||
deltasecs = (double)elapsed / (double)precision;
|
||||
deltatics = deltasecs * (double)NEWTICRATE;
|
||||
|
||||
@@ -873,19 +932,6 @@ void D_SRB2Loop(void)
|
||||
frameskip = 0;
|
||||
}
|
||||
|
||||
if (!singletics)
|
||||
{
|
||||
// in the case of "match refresh rate" + vsync, don't sleep at all
|
||||
const boolean vsync_with_match_refresh = cv_vidwait.value && cv_fpscap.value == 0;
|
||||
|
||||
if ((elapsed > 0) && (capbudget > elapsed) && !vsync_with_match_refresh)
|
||||
{
|
||||
I_SleepDuration(capbudget - elapsed);
|
||||
}
|
||||
}
|
||||
|
||||
// Capture the time once more to get the real delta time.
|
||||
finishprecise = I_GetPreciseTime();
|
||||
elapsed = finishprecise - enterprecise;
|
||||
deltasecs = (double)elapsed / (double)precision;
|
||||
deltatics = deltasecs * (double)NEWTICRATE;
|
||||
|
||||
+1
-3
@@ -1172,9 +1172,7 @@ void F_StartWaitingPlayers(void)
|
||||
randskin = M_RandomKey(numskins);
|
||||
boolean waithires = skins[randskin].flags && SF_HIRES;
|
||||
|
||||
if (waitcolormap)
|
||||
Z_Free(waitcolormap);
|
||||
|
||||
Z_Free(waitcolormap);
|
||||
waitcolormap = R_GetTranslationColormap(randskin, skins[randskin].prefcolor, 0);
|
||||
|
||||
if (waithires)
|
||||
|
||||
+6
-8
@@ -317,8 +317,7 @@ void closefilemenu(boolean validsize)
|
||||
coredirmenu = NULL;
|
||||
}
|
||||
|
||||
if (refreshdirname)
|
||||
Z_Free(refreshdirname);
|
||||
Z_Free(refreshdirname);
|
||||
refreshdirname = NULL;
|
||||
}
|
||||
|
||||
@@ -346,8 +345,7 @@ void searchfilemenu(char *tempname)
|
||||
|
||||
if (!menusearch.length)
|
||||
{
|
||||
if (dirmenu)
|
||||
Z_Free(dirmenu);
|
||||
Z_Free(dirmenu);
|
||||
dirmenu = coredirmenu;
|
||||
sizedirmenu = sizecoredirmenu;
|
||||
|
||||
@@ -389,8 +387,8 @@ void searchfilemenu(char *tempname)
|
||||
I_Error("searchfilemenu(): could not create \"No results...\".");
|
||||
sizedirmenu = 1;
|
||||
dir_on[menudepthleft] = 0;
|
||||
if (tempname)
|
||||
Z_Free(tempname);
|
||||
Z_Free(tempname);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -505,8 +503,8 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
|
||||
{
|
||||
closedir(dirhandle);
|
||||
closefilemenu(false);
|
||||
if (tempname)
|
||||
Z_Free(tempname);
|
||||
Z_Free(tempname);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+2
-5
@@ -523,11 +523,8 @@ void G_ClearRecords(void)
|
||||
INT16 i;
|
||||
for (i = 0; i < NUMMAPS; ++i)
|
||||
{
|
||||
if (mainrecords[i])
|
||||
{
|
||||
Z_Free(mainrecords[i]);
|
||||
mainrecords[i] = NULL;
|
||||
}
|
||||
Z_Free(mainrecords[i]);
|
||||
mainrecords[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -225,9 +225,10 @@ HMS_connect (const char *format, ...)
|
||||
{
|
||||
cc = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
|
||||
|
||||
#ifdef LOGMESSAGES
|
||||
cc = curl_easy_setopt(curl, CURLOPT_STDERR, logstream);
|
||||
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (M_CheckParm("-bindaddr") && M_IsNextParm())
|
||||
|
||||
+4
-8
@@ -1072,8 +1072,7 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum)
|
||||
|
||||
HU_AddChatText(va(fmt2, prefix, cstart, dispname, textcolor, msg), cv_chatnotifications.value); // add to chat
|
||||
|
||||
if (tempchar)
|
||||
Z_Free(tempchar);
|
||||
Z_Free(tempchar);
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
// I just want to point out while I'm here that because the data is still
|
||||
@@ -1569,8 +1568,7 @@ static void HU_drawMiniChat(void)
|
||||
dy = 0;
|
||||
dx = 0;
|
||||
msglines += linescount+1;
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
y = chaty - charheight*(msglines+1);
|
||||
@@ -1657,8 +1655,7 @@ static void HU_drawMiniChat(void)
|
||||
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
// decrement addy and make that shit smooth:
|
||||
@@ -1767,8 +1764,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
if (((chat_scroll >= chat_maxscroll) || (chat_scrollmedown)) && !(justscrolleddown || justscrolledup || chat_scrolltime)) // was already at the bottom of the page before new maxscroll calculation and was NOT scrolling.
|
||||
|
||||
+4
-10
@@ -1510,11 +1510,8 @@ static boolean SOCK_SetBanUsername(const char *username)
|
||||
username = "Direct IP ban";
|
||||
}
|
||||
|
||||
if (banned[numbans - 1].username)
|
||||
{
|
||||
Z_Free(banned[numbans - 1].username);
|
||||
banned[numbans - 1].username = NULL;
|
||||
}
|
||||
Z_Free(banned[numbans - 1].username);
|
||||
banned[numbans - 1].username = NULL;
|
||||
|
||||
banned[numbans - 1].username = Z_StrDup(username);
|
||||
|
||||
@@ -1528,11 +1525,8 @@ static boolean SOCK_SetBanReason(const char *reason)
|
||||
reason = "No reason given";
|
||||
}
|
||||
|
||||
if (banned[numbans - 1].reason)
|
||||
{
|
||||
Z_Free(banned[numbans - 1].reason);
|
||||
banned[numbans - 1].reason = NULL;
|
||||
}
|
||||
Z_Free(banned[numbans - 1].reason);
|
||||
banned[numbans - 1].reason = NULL;
|
||||
|
||||
banned[numbans - 1].reason = Z_StrDup(reason);
|
||||
|
||||
|
||||
+1
-2
@@ -99,8 +99,7 @@ void K_EraseStats(void)
|
||||
// The only field we want to remember
|
||||
boolean vanilla = kartstats.vanilla;
|
||||
|
||||
if (kartstats.copy)
|
||||
Z_Free(kartstats.copy);
|
||||
Z_Free(kartstats.copy);
|
||||
|
||||
memset(&kartstats, 0, sizeof(kartstats_t));
|
||||
|
||||
|
||||
@@ -136,18 +136,9 @@ void LUA_HUD_DestroyDrawList(huddrawlist_h list)
|
||||
{
|
||||
if (list == NULL) return;
|
||||
|
||||
if (list->items)
|
||||
{
|
||||
Z_Free(list->items);
|
||||
}
|
||||
if (list->olditems)
|
||||
{
|
||||
Z_Free(list->olditems);
|
||||
}
|
||||
if (list->strbuf)
|
||||
{
|
||||
Z_Free(list->strbuf);
|
||||
}
|
||||
Z_Free(list->items);
|
||||
Z_Free(list->olditems);
|
||||
Z_Free(list->strbuf);
|
||||
Z_Free(list);
|
||||
}
|
||||
|
||||
|
||||
+3
-6
@@ -695,16 +695,13 @@ INT32 GIF_close(void)
|
||||
fclose(gif_out);
|
||||
gif_out = NULL;
|
||||
|
||||
if (gifbwr_buf)
|
||||
Z_Free(gifbwr_buf);
|
||||
Z_Free(gifbwr_buf);
|
||||
gifbwr_buf = gifbwr_cur = NULL;
|
||||
|
||||
if (gifframe_data)
|
||||
Z_Free(gifframe_data);
|
||||
Z_Free(gifframe_data);
|
||||
gifframe_data = NULL;
|
||||
|
||||
if (giflzw_hashTable)
|
||||
Z_Free(giflzw_hashTable);
|
||||
Z_Free(giflzw_hashTable);
|
||||
giflzw_hashTable = NULL;
|
||||
|
||||
Z_Free(scrbuf_screens);
|
||||
|
||||
+3
-6
@@ -248,12 +248,9 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1
|
||||
|
||||
void M_ClearConditionSet(UINT8 set)
|
||||
{
|
||||
if (conditionSets[set - 1].numconditions)
|
||||
{
|
||||
Z_Free(conditionSets[set - 1].condition);
|
||||
conditionSets[set - 1].condition = NULL;
|
||||
conditionSets[set - 1].numconditions = 0;
|
||||
}
|
||||
Z_Free(conditionSets[set - 1].condition);
|
||||
conditionSets[set - 1].condition = NULL;
|
||||
conditionSets[set - 1].numconditions = 0;
|
||||
conditionSets[set - 1].achieved = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include "doomtype.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
@@ -72,14 +71,6 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t DoubleToFixed(double f)
|
||||
#define FIXED_TO_FLOAT(x) FixedToFloat(x) // (((float)(x)) / ((float)FRACUNIT))
|
||||
#define FLOAT_TO_FIXED(f) FloatToFixed(f) // (fixed_t)((f) * ((float)FRACUNIT))
|
||||
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedClamp(INT64 val)
|
||||
{
|
||||
// stoopid includes
|
||||
#define FCLAMP(x, y, z) ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x)))
|
||||
return (fixed_t)(FCLAMP(val, (INT64)INT32_MIN, (INT64)INT32_MAX));
|
||||
#undef FCLAMP
|
||||
}
|
||||
|
||||
/** \brief The FixedMul function
|
||||
|
||||
\param a fixed_t number
|
||||
|
||||
+10
-6
@@ -5356,7 +5356,7 @@ void M_PopupMasterServerRules(void)
|
||||
{
|
||||
firstDismissedRulesThisBoot = false;
|
||||
M_StartMessage(va("%s\n(press any key)", rules), NULL, MM_NOTHING);
|
||||
Z_Free(rules);
|
||||
free(rules);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -6560,17 +6560,22 @@ static void M_EraseGuest(INT32 choice)
|
||||
|
||||
static void M_OverwriteGuest(const char *which)
|
||||
{
|
||||
char *rguest = Z_StrDup(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)));
|
||||
char *rguest;
|
||||
UINT8 *buf;
|
||||
size_t len;
|
||||
len = FIL_ReadFile(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), cv_chooseskin.string, which), &buf);
|
||||
if (!len) {
|
||||
|
||||
if (!len)
|
||||
return;
|
||||
}
|
||||
if (FIL_FileExists(rguest)) {
|
||||
|
||||
rguest = Z_StrDup(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)));
|
||||
|
||||
if (FIL_FileExists(rguest))
|
||||
{
|
||||
M_StopMessage(0);
|
||||
remove(rguest);
|
||||
}
|
||||
|
||||
FIL_WriteFile(rguest, buf, len);
|
||||
Z_Free(rguest);
|
||||
|
||||
@@ -7587,7 +7592,6 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
|
||||
|
||||
static void M_DrawServerMenu(void)
|
||||
{
|
||||
|
||||
M_DrawLevelSelectOnly(false, false);
|
||||
#ifdef MASTERSERVER
|
||||
if (currentMenu == &MP_ServerDef && cv_advertise.value) // Remind players where they're hosting.
|
||||
|
||||
+4
-3
@@ -219,8 +219,9 @@ static void Get_masterserver_rules(boolean checkfirst)
|
||||
if (HMS_fetch_rules(rules, sizeof rules))
|
||||
{
|
||||
Lock_state();
|
||||
Z_Free(MSRules);
|
||||
MSRules = Z_StrDup(rules);
|
||||
if (MSRules)
|
||||
free(MSRules);
|
||||
MSRules = strdup(rules);
|
||||
|
||||
if (MSRegistered == true)
|
||||
{
|
||||
@@ -507,7 +508,7 @@ char *GetMasterServerRules(void)
|
||||
char *rules;
|
||||
|
||||
Lock_state();
|
||||
rules = MSRules ? Z_StrDup(MSRules) : NULL;
|
||||
rules = MSRules ? strdup(MSRules) : NULL;
|
||||
Unlock_state();
|
||||
|
||||
return rules;
|
||||
|
||||
+1
-3
@@ -320,9 +320,7 @@ void P_AddGradesForMare(INT16 i, UINT8 mare, char *gtext)
|
||||
*/
|
||||
void P_DeleteGrades(INT16 i)
|
||||
{
|
||||
if (mapheaderinfo[i]->grades)
|
||||
Z_Free(mapheaderinfo[i]->grades);
|
||||
|
||||
Z_Free(mapheaderinfo[i]->grades);
|
||||
mapheaderinfo[i]->grades = NULL;
|
||||
mapheaderinfo[i]->numGradedMares = 0;
|
||||
}
|
||||
|
||||
+1
-2
@@ -6221,8 +6221,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate)
|
||||
|
||||
// Allocate each list
|
||||
for (i = 0; i < numsectors; i++)
|
||||
if(secthinkers[i].thinkers)
|
||||
Z_Free(secthinkers[i].thinkers);
|
||||
Z_Free(secthinkers[i].thinkers);
|
||||
|
||||
Z_Free(secthinkers);
|
||||
|
||||
|
||||
+1
-2
@@ -1720,8 +1720,7 @@ void R_InitData(void)
|
||||
|
||||
void R_ClearTextureNumCache(boolean btell)
|
||||
{
|
||||
if (tidcache)
|
||||
Z_Free(tidcache);
|
||||
Z_Free(tidcache);
|
||||
tidcache = NULL;
|
||||
if (btell)
|
||||
CONS_Debug(DBG_SETUP, "Fun Fact: There are %d textures used in this map.\n", tidcachelen);
|
||||
|
||||
+10
-14
@@ -519,10 +519,10 @@ void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32
|
||||
const fixed_t vyright = viewy + FixedMul(drawdist, FSIN(right));
|
||||
|
||||
// Try to narrow the search to within only the field of view
|
||||
*xl = (unsigned)(FixedClamp((INT64)std::min(viewx, std::min(vxleft, vxright)) - bmaporgx))>>MAPBLOCKSHIFT;
|
||||
*xh = (unsigned)(FixedClamp((INT64)std::max(viewx, std::max(vxleft, vxright)) - bmaporgx))>>MAPBLOCKSHIFT;
|
||||
*yl = (unsigned)(FixedClamp((INT64)std::min(viewy, std::min(vyleft, vyright)) - bmaporgy))>>MAPBLOCKSHIFT;
|
||||
*yh = (unsigned)(FixedClamp((INT64)std::max(viewy, std::max(vyleft, vyright)) - bmaporgy))>>MAPBLOCKSHIFT;
|
||||
*xl = (unsigned)(std::min(viewx, std::min(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
*xh = (unsigned)(std::max(viewx, std::max(vxleft, vxright)) - bmaporgx)>>MAPBLOCKSHIFT;
|
||||
*yl = (unsigned)(std::min(viewy, std::min(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
*yh = (unsigned)(std::max(viewy, std::max(vyleft, vyright)) - bmaporgy)>>MAPBLOCKSHIFT;
|
||||
|
||||
if (*xh >= bmapwidth)
|
||||
*xh = bmapwidth - 1;
|
||||
@@ -925,11 +925,11 @@ void R_ExecuteSetViewSize(void)
|
||||
viewheight = vid.height;
|
||||
|
||||
if (splitscreen)
|
||||
{
|
||||
viewheight >>= 1;
|
||||
|
||||
if (splitscreen > 1)
|
||||
{
|
||||
viewwidth >>= 1;
|
||||
if (splitscreen > 1)
|
||||
viewwidth >>= 1;
|
||||
}
|
||||
|
||||
centerx = viewwidth/2;
|
||||
@@ -956,13 +956,9 @@ void R_ExecuteSetViewSize(void)
|
||||
screenheightarray[i] = (INT16)viewheight;
|
||||
}
|
||||
|
||||
if (ds_su)
|
||||
Z_Free(ds_su);
|
||||
if (ds_sv)
|
||||
Z_Free(ds_sv);
|
||||
if (ds_sz)
|
||||
Z_Free(ds_sz);
|
||||
|
||||
Z_Free(ds_su);
|
||||
Z_Free(ds_sv);
|
||||
Z_Free(ds_sz);
|
||||
ds_su = ds_sv = ds_sz = NULL;
|
||||
|
||||
memset(scalelight, 0xFF, sizeof(scalelight));
|
||||
|
||||
+2
-2
@@ -152,8 +152,8 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y);
|
||||
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE fixed_t R_QuickDist(fixed_t x1, fixed_t y1, fixed_t x, fixed_t y)
|
||||
{
|
||||
const fixed_t absx = FixedClamp(labs((INT64)x - (INT64)x1));
|
||||
const fixed_t absy = FixedClamp(labs((INT64)y - (INT64)y1));
|
||||
const fixed_t absx = abs(x - x1);
|
||||
const fixed_t absy = abs(y - y1);
|
||||
#ifdef __cplusplus
|
||||
return std::max<fixed_t>(absx, absy);
|
||||
#else
|
||||
|
||||
+2
-4
@@ -405,10 +405,8 @@ static void Patch_FreeData(patch_t *patch)
|
||||
}*/
|
||||
#endif
|
||||
|
||||
if (patch->columnofs)
|
||||
Z_Free(patch->columnofs);
|
||||
if (patch->columns)
|
||||
Z_Free(patch->columns);
|
||||
Z_Free(patch->columnofs);
|
||||
Z_Free(patch->columns);
|
||||
}
|
||||
|
||||
void Patch_Free(patch_t *patch)
|
||||
|
||||
+3
-3
@@ -228,8 +228,8 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, INT32
|
||||
// to step from those to the proper texture coordinate to start drawing at.
|
||||
// That way, the texture coordinate is always calculated by its position
|
||||
// on the screen and not by its position relative to the edge of the visplane.
|
||||
ds->xfrac = FixedClamp((INT64)ds->xoffs + (INT64)FixedMul(planecos, distance) + ((INT64)x1 - (INT64)centerx) * (INT64)ds->xstep);
|
||||
ds->yfrac = FixedClamp((INT64)ds->yoffs - (INT64)FixedMul(planesin, distance) + ((INT64)x1 - (INT64)centerx) * (INT64)ds->ystep);
|
||||
ds->xfrac = ds->xoffs + FixedMul(planecos, distance) + (x1 - centerx) * ds->xstep;
|
||||
ds->yfrac = ds->yoffs - FixedMul(planesin, distance) + (x1 - centerx) * ds->ystep;
|
||||
|
||||
if (ds->planeripple.active)
|
||||
{
|
||||
@@ -1012,7 +1012,7 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle
|
||||
levelflat_t *levelflat;
|
||||
void (*mapfunc)(drawspandata_t*, void(*)(drawspandata_t*), INT32, INT32, INT32, boolean) = R_MapPlane;
|
||||
|
||||
if (!(pl->minx <= pl->maxx))
|
||||
if (pl->minx > pl->maxx)
|
||||
return;
|
||||
|
||||
// sky flat
|
||||
|
||||
+2
-2
@@ -312,8 +312,8 @@ void Portal_AddSkybox(const visplane_t* plane)
|
||||
y = (viewy - skyboxmo[1]->y) * -mh->skybox_scaley;
|
||||
|
||||
// Apply transform to account for the skybox viewport angle.
|
||||
portal->viewx += FixedMul(x, FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
|
||||
portal->viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y, FINECOSINE(ang));
|
||||
portal->viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
|
||||
portal->viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
|
||||
}
|
||||
|
||||
if (mh->skybox_scalez > 0)
|
||||
|
||||
+90
-79
@@ -226,11 +226,10 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
leftheight -= viewz;
|
||||
rightheight -= viewz;
|
||||
|
||||
rlight->height = FixedClamp((INT64)centeryfrac - FixedMul(leftheight, drawseg->scale1));
|
||||
rlight->heightstep = FixedClamp((INT64)centeryfrac - FixedMul(rightheight, drawseg->scale2));
|
||||
rlight->heightstep = FixedClamp((INT64)rlight->heightstep - rlight->height)/(range);
|
||||
rlight->startheight = rlight->height; // keep starting value here to reset for each repeat
|
||||
|
||||
rlight->height = (centeryfrac) - FixedMul(leftheight, drawseg->scale1);
|
||||
rlight->heightstep = (centeryfrac) - FixedMul(rightheight, drawseg->scale2);
|
||||
rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
|
||||
rlight->startheight = rlight->height; // keep starting value here to reset for each repeat
|
||||
rlight->lightlevel = *light->lightlevel;
|
||||
rlight->extra_colormap = light->extra_colormap;
|
||||
rlight->flags = static_cast<ffloortype_e>(light->flags);
|
||||
@@ -342,7 +341,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
for (i = 0; i < dc->numlights; i++)
|
||||
{
|
||||
rlight = &dc->lightlist[i];
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
rlight->height += rlight->heightstep;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,9 +355,9 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
lighttable_t **xwalllights;
|
||||
|
||||
sprbotscreen = INT32_MAX;
|
||||
sprtopscreen = windowtop = FixedClamp((INT64)centeryfrac - FixedMul(dc->texturemid, spryscale));
|
||||
sprtopscreen = windowtop = (centeryfrac - FixedMul(dc->texturemid, spryscale));
|
||||
|
||||
realbot = windowbottom = FixedClamp((INT64)FixedMul(textureheight[texnum], spryscale) + sprtopscreen);
|
||||
realbot = windowbottom = FixedMul(textureheight[texnum], spryscale) + sprtopscreen;
|
||||
dc->iscale = 0xffffffffu / (unsigned)spryscale;
|
||||
|
||||
// draw the texture
|
||||
@@ -408,8 +407,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
set_light_vars(i);
|
||||
|
||||
height = rlight->height;
|
||||
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
rlight->height += rlight->heightstep;
|
||||
|
||||
if (height <= windowtop)
|
||||
{
|
||||
@@ -425,7 +423,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
for (i++; i < dc->numlights; i++)
|
||||
{
|
||||
rlight = &dc->lightlist[i];
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
rlight->height += rlight->heightstep;
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -457,7 +455,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
|
||||
if (frontsector->extra_colormap)
|
||||
dc->colormap = frontsector->extra_colormap->colormap + (dc->colormap - colormaps);
|
||||
|
||||
sprtopscreen = FixedClamp((INT64)centeryfrac - FixedMul(dc->texturemid, spryscale));
|
||||
sprtopscreen = centeryfrac - FixedMul(dc->texturemid, spryscale);
|
||||
dc->iscale = 0xffffffffu / (unsigned)spryscale;
|
||||
|
||||
// draw the texture
|
||||
@@ -712,6 +710,17 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
rw_scalestep = drawseg->scalestep;
|
||||
spryscale = drawseg->scale1 + (x1 - drawseg->x1)*rw_scalestep;
|
||||
|
||||
#define CLAMPMAX INT32_MAX
|
||||
#define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out.
|
||||
auto overflow_clamp = [&](INT64 overflow_test)
|
||||
{
|
||||
return (overflow_test > (INT64)CLAMPMAX) ? CLAMPMAX :
|
||||
(overflow_test > (INT64)CLAMPMIN) ? (fixed_t)overflow_test :
|
||||
CLAMPMIN;
|
||||
};
|
||||
#undef CLAMPMAX
|
||||
#undef CLAMPMIN
|
||||
|
||||
dc->numlights = 0;
|
||||
if (frontsector->numlights)
|
||||
{
|
||||
@@ -727,6 +736,7 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
{
|
||||
fixed_t leftheight, rightheight;
|
||||
fixed_t pfloorleft, pfloorright;
|
||||
INT64 overflow_test;
|
||||
light = &frontsector->lightlist[i];
|
||||
rlight = &dc->lightlist[p];
|
||||
|
||||
@@ -750,14 +760,17 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
continue;
|
||||
}
|
||||
|
||||
leftheight -= viewz;
|
||||
leftheight -= viewz;
|
||||
rightheight -= viewz;
|
||||
|
||||
// Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave.
|
||||
rlight->height = FixedClamp((INT64)centeryfrac - (((INT64)leftheight * drawseg->scale1)>>FRACBITS));
|
||||
rlight->heightstep = FixedClamp((INT64)centeryfrac - (((INT64)rightheight * drawseg->scale2)>>FRACBITS));
|
||||
rlight->heightstep = FixedClamp((INT64)rlight->heightstep - rlight->height)/(range);
|
||||
overflow_test = (INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS);
|
||||
rlight->height = overflow_clamp(overflow_test);
|
||||
|
||||
overflow_test = (INT64)centeryfrac - (((INT64)rightheight*drawseg->scale2)>>FRACBITS);
|
||||
rlight->heightstep = overflow_clamp(overflow_test);
|
||||
|
||||
rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
|
||||
rlight->flags = static_cast<ffloortype_e>(light->flags);
|
||||
|
||||
if (light->flags & FF_CUTLEVEL)
|
||||
@@ -768,9 +781,13 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
rightheight -= viewz;
|
||||
|
||||
// Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave.
|
||||
rlight->botheight = FixedClamp((INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS));
|
||||
rlight->botheightstep = FixedClamp(((INT64)centeryfrac - (((INT64)rightheight*drawseg->scale2)>>FRACBITS)));
|
||||
rlight->botheightstep = FixedClamp((INT64)rlight->botheightstep - rlight->botheight)/(range);
|
||||
overflow_test = (INT64)centeryfrac - (((INT64)leftheight*drawseg->scale1)>>FRACBITS);
|
||||
rlight->botheight = overflow_clamp(overflow_test);
|
||||
|
||||
overflow_test = (INT64)centeryfrac - (((INT64)rightheight*drawseg->scale2)>>FRACBITS);
|
||||
rlight->botheightstep = overflow_clamp(overflow_test);
|
||||
|
||||
rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range);
|
||||
}
|
||||
|
||||
rlight->lightlevel = *light->lightlevel;
|
||||
@@ -879,10 +896,10 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
right_bottom = P_GetFFloorBottomZAt(pfloor, drawseg->rightpos.x, drawseg->rightpos.y) - viewz;
|
||||
|
||||
// using INT64 to avoid 32bit overflow
|
||||
top_frac = FixedClamp((INT64)centeryfrac - (((INT64)left_top * drawseg->scale1) >> FRACBITS));
|
||||
top_step = FixedClamp((INT64)centeryfrac - (((INT64)right_top * drawseg->scale2) >> FRACBITS));
|
||||
bottom_frac = FixedClamp((INT64)centeryfrac - (((INT64)left_bottom * drawseg->scale1) >> FRACBITS));
|
||||
bottom_step = FixedClamp((INT64)centeryfrac - (((INT64)right_bottom * drawseg->scale2) >> FRACBITS));
|
||||
top_frac = (INT64)centeryfrac - (((INT64)left_top * drawseg->scale1) >> FRACBITS);
|
||||
bottom_frac = (INT64)centeryfrac - (((INT64)left_bottom * drawseg->scale1) >> FRACBITS);
|
||||
top_step = (INT64)centeryfrac - (((INT64)right_top * drawseg->scale2) >> FRACBITS);
|
||||
bottom_step = (INT64)centeryfrac - (((INT64)right_bottom * drawseg->scale2) >> FRACBITS);
|
||||
|
||||
top_step = (top_step-top_frac)/(range);
|
||||
bottom_step = (bottom_step-bottom_frac)/(range);
|
||||
@@ -904,8 +921,8 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
|
||||
// Calculate bounds
|
||||
// clamp the values if necessary to avoid overflows and rendering glitches caused by them
|
||||
sprtopscreen = windowtop = top_frac;
|
||||
sprbotscreen = windowbottom = bottom_frac;
|
||||
sprtopscreen = windowtop = overflow_clamp(top_frac);
|
||||
sprbotscreen = windowbottom = overflow_clamp(bottom_frac);
|
||||
|
||||
top_frac += top_step;
|
||||
bottom_frac += bottom_step;
|
||||
@@ -918,11 +935,9 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
for (i = 0; i < dc->numlights; i++)
|
||||
{
|
||||
rlight = &dc->lightlist[i];
|
||||
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
|
||||
rlight->height += rlight->heightstep;
|
||||
if (rlight->flags & FF_CUTLEVEL)
|
||||
rlight->botheight = FixedClamp((INT64)rlight->botheight + rlight->botheightstep);
|
||||
rlight->botheight += rlight->botheightstep;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1030,12 +1045,12 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
solid = 0;
|
||||
|
||||
height = rlight->height;
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
rlight->height += rlight->heightstep;
|
||||
|
||||
if (solid)
|
||||
{
|
||||
bheight = FixedClamp((INT64)rlight->botheight - (FRACUNIT >> 1));
|
||||
rlight->botheight = FixedClamp((INT64)rlight->botheight + rlight->botheightstep);
|
||||
bheight = rlight->botheight - (FRACUNIT >> 1);
|
||||
rlight->botheight += rlight->botheightstep;
|
||||
}
|
||||
|
||||
if (height <= windowtop)
|
||||
@@ -1063,7 +1078,7 @@ void R_RenderThickSideRange(drawseg_t *drawseg, INT32 x1, INT32 x2, ffloor_t *pf
|
||||
for (i++; i < dc->numlights; i++)
|
||||
{
|
||||
rlight = &dc->lightlist[i];
|
||||
rlight->height = FixedClamp((INT64)rlight->height + rlight->heightstep);
|
||||
rlight->height += rlight->heightstep;
|
||||
|
||||
if (rlight->flags & FF_CUTLEVEL)
|
||||
rlight->botheight += rlight->botheightstep;
|
||||
@@ -1197,7 +1212,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
for (; rw_x < rw_stopx; rw_x++)
|
||||
{
|
||||
// mark floor / ceiling areas
|
||||
yl = FixedClamp((INT64)topfrac + HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
yh = bottomfrac>>HEIGHTBITS;
|
||||
|
||||
// Mark ceiling
|
||||
@@ -1348,17 +1363,15 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
//SoM: Calculate offsets for Thick fake floors.
|
||||
// calculate texture offset
|
||||
angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT;
|
||||
|
||||
// Mask 4095 to guarantee this index is within bounds
|
||||
texturecolumn = FixedClamp((INT64)rw_offset - FixedMul(FINETANGENT(angle & 4095), rw_distance));
|
||||
texturecolumn = rw_offset-FixedMul(FINETANGENT(angle & 4095), rw_distance);
|
||||
|
||||
if (oldtexturecolumn != -1)
|
||||
{
|
||||
const fixed_t coloff = FixedClamp((INT64)oldtexturecolumn - texturecolumn);
|
||||
rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, coloff);
|
||||
rw_midtexturemid += FixedMul(rw_midtextureslide, coloff);
|
||||
rw_toptexturemid += FixedMul(rw_toptextureslide, coloff);
|
||||
rw_midtextureback += FixedMul(rw_midtexturebackslide, coloff);
|
||||
rw_bottomtexturemid += FixedMul(rw_bottomtextureslide, oldtexturecolumn-texturecolumn);
|
||||
rw_midtexturemid += FixedMul(rw_midtextureslide, oldtexturecolumn-texturecolumn);
|
||||
rw_toptexturemid += FixedMul(rw_toptextureslide, oldtexturecolumn-texturecolumn);
|
||||
rw_midtextureback += FixedMul(rw_midtexturebackslide, oldtexturecolumn-texturecolumn);
|
||||
}
|
||||
oldtexturecolumn = texturecolumn;
|
||||
|
||||
@@ -1368,7 +1381,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
// calculate lighting
|
||||
pindex = FixedMul(rw_scale, LIGHTRESOLUTIONFIX)>>LIGHTSCALESHIFT;
|
||||
|
||||
if (pindex >= MAXLIGHTSCALE)
|
||||
if (pindex >= MAXLIGHTSCALE)
|
||||
pindex = MAXLIGHTSCALE-1;
|
||||
|
||||
dc->colormap = walllights[pindex];
|
||||
@@ -1450,8 +1463,8 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
if (toptexture)
|
||||
{
|
||||
// top wall
|
||||
mid = pixhigh >> HEIGHTBITS;
|
||||
pixhigh = FixedClamp((INT64)pixhigh + pixhighstep);
|
||||
mid = pixhigh>>HEIGHTBITS;
|
||||
pixhigh += pixhighstep;
|
||||
|
||||
if (mid >= floorclip[rw_x])
|
||||
mid = floorclip[rw_x]-1;
|
||||
@@ -1480,8 +1493,8 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
if (bottomtexture)
|
||||
{
|
||||
// bottom wall
|
||||
mid = FixedClamp((INT64)pixlow+HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
pixlow = FixedClamp((INT64)pixlow + pixlowstep);
|
||||
mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
pixlow += pixlowstep;
|
||||
|
||||
// no space above wall?
|
||||
if (mid <= ceilingclip[rw_x])
|
||||
@@ -1532,10 +1545,10 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
{
|
||||
for (i = 0; i < dc->numlights; i++)
|
||||
{
|
||||
dc->lightlist[i].height = FixedClamp((INT64)dc->lightlist[i].height + dc->lightlist[i].heightstep);
|
||||
dc->lightlist[i].height += dc->lightlist[i].heightstep;
|
||||
|
||||
if (dc->lightlist[i].flags & FF_CUTSOLIDS)
|
||||
dc->lightlist[i].botheight = FixedClamp((INT64)dc->lightlist[i].botheight + dc->lightlist[i].botheightstep);;
|
||||
dc->lightlist[i].botheight += dc->lightlist[i].botheightstep;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1556,10 +1569,9 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
|
||||
visffloor[i].b_frac += visffloor[i].b_step;
|
||||
}
|
||||
|
||||
rw_scale = FixedClamp((INT64)rw_scale + rw_scalestep);
|
||||
|
||||
topfrac = FixedClamp((INT64)topfrac + topstep);
|
||||
bottomfrac = FixedClamp((INT64)bottomfrac + bottomstep);
|
||||
rw_scale += rw_scalestep;
|
||||
topfrac += topstep;
|
||||
bottomfrac += bottomstep;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1573,7 +1585,7 @@ static void R_MarkSegBounds(void)
|
||||
for (; rw_x < rw_stopx; rw_x++)
|
||||
{
|
||||
// mark floor / ceiling areas
|
||||
yl = FixedClamp((INT64)topfrac + HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS;
|
||||
yh = bottomfrac>>HEIGHTBITS;
|
||||
|
||||
// Mark ceiling
|
||||
@@ -1810,7 +1822,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
|
||||
// big room fix
|
||||
if (longboi)
|
||||
rw_distance = FixedClamp(R_CalcSegDist(curline, viewx, viewy));
|
||||
rw_distance = (fixed_t)R_CalcSegDist(curline,viewx,viewy);
|
||||
|
||||
ds_p->x1 = rw_x = start;
|
||||
ds_p->x2 = stop;
|
||||
@@ -2193,8 +2205,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
}
|
||||
}
|
||||
|
||||
rw_toptexturemid = FixedClamp((INT64)rw_toptexturemid + sidedef->rowoffset);
|
||||
rw_bottomtexturemid = FixedClamp((INT64)rw_bottomtexturemid + sidedef->rowoffset);
|
||||
rw_toptexturemid += sidedef->rowoffset;
|
||||
rw_bottomtexturemid += sidedef->rowoffset;
|
||||
|
||||
R_AllocTextureColumnTables(rw_stopx - start);
|
||||
|
||||
@@ -2479,9 +2491,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
rw_offset = -rw_offset;
|
||||
|
||||
/// don't use texture offset for splats
|
||||
rw_offset2 = FixedClamp((INT64)rw_offset + curline->offset);
|
||||
rw_offset = FixedClamp((INT64)rw_offset + (INT64)sidedef->textureoffset + curline->offset);
|
||||
|
||||
rw_offset2 = rw_offset + curline->offset;
|
||||
rw_offset += sidedef->textureoffset + curline->offset;
|
||||
rw_centerangle = ANGLE_90 + viewangle - rw_normalangle;
|
||||
|
||||
// calculate light table
|
||||
@@ -2541,8 +2552,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
|
||||
auto set_topstep_normal = [&]
|
||||
{
|
||||
topstep = -FixedMul(rw_scalestep, worldtop);
|
||||
topfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldtop, rw_scale));
|
||||
topstep = -FixedMul (rw_scalestep, worldtop);
|
||||
topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale);
|
||||
};
|
||||
|
||||
// untextured seg
|
||||
@@ -2563,14 +2574,14 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
// this is an attempt to fix issues with textureless single sided lines drawing nothing where they should just draw sky instead
|
||||
if (tophigh && !backsector && frontsector->ceilingpic == skyflatnum)
|
||||
{
|
||||
topstep = -FixedMul(rw_scalestep, worldbottom);
|
||||
topfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottom, rw_scale));
|
||||
topstep = -FixedMul (rw_scalestep, worldbottom);
|
||||
topfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale);
|
||||
|
||||
// account for slopes to try and get rid of sharp edges from the black void
|
||||
if (frontsector->f_slope || (backsector && backsector->f_slope))
|
||||
{
|
||||
topstep = -FixedMul(rw_scalestep, worldbottomslope);
|
||||
topfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottomslope, rw_scale));
|
||||
topstep = -FixedMul (rw_scalestep, worldbottomslope);
|
||||
topfrac = (centeryfrac>>4) - FixedMul (worldbottomslope, rw_scale);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2579,18 +2590,18 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
else
|
||||
set_topstep_normal();
|
||||
|
||||
bottomstep = -FixedMul(rw_scalestep, worldbottom);
|
||||
bottomfrac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottom, rw_scale));
|
||||
bottomstep = -FixedMul (rw_scalestep, worldbottom);
|
||||
bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale);
|
||||
|
||||
if (frontsector->c_slope)
|
||||
{
|
||||
fixed_t topfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldtopslope, ds_p->scale2));
|
||||
fixed_t topfracend = (centeryfrac>>4) - FixedMul (worldtopslope, ds_p->scale2);
|
||||
topstep = (topfracend-topfrac)/(range);
|
||||
}
|
||||
|
||||
if (frontsector->f_slope)
|
||||
{
|
||||
fixed_t bottomfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldbottomslope, ds_p->scale2));
|
||||
fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldbottomslope, ds_p->scale2);
|
||||
bottomstep = (bottomfracend-bottomfrac)/(range);
|
||||
}
|
||||
}
|
||||
@@ -2632,9 +2643,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
continue;
|
||||
}
|
||||
|
||||
rlight->height = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(leftheight, rw_scale));
|
||||
rlight->heightstep = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2));
|
||||
rlight->heightstep = FixedClamp((INT64)rlight->heightstep - rlight->height)/(range);
|
||||
rlight->height = (centeryfrac>>4) - FixedMul(leftheight, rw_scale);
|
||||
rlight->heightstep = (centeryfrac>>4) - FixedMul(rightheight, ds_p->scale2);
|
||||
rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
|
||||
rlight->flags = static_cast<ffloortype_e>(light->flags);
|
||||
|
||||
if (light->caster && light->caster->flags & FF_CUTSOLIDS)
|
||||
@@ -2696,9 +2707,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
|
||||
if (toptexture)
|
||||
{
|
||||
fixed_t topfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldhighslope, ds_p->scale2));
|
||||
fixed_t topfracend = (centeryfrac>>4) - FixedMul(worldhighslope, ds_p->scale2);
|
||||
|
||||
pixhigh = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldhigh, rw_scale));
|
||||
pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale);
|
||||
pixhighstep = (topfracend-pixhigh)/(range);
|
||||
|
||||
// If the lowest part of a ceiling stretching down covers the entire screen
|
||||
@@ -2708,9 +2719,9 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
|
||||
if (bottomtexture)
|
||||
{
|
||||
fixed_t bottomfracend = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldlowslope, ds_p->scale2));
|
||||
fixed_t bottomfracend = (centeryfrac>>4) - FixedMul (worldlowslope, ds_p->scale2);
|
||||
|
||||
pixlow = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(worldlow, rw_scale));
|
||||
pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale);
|
||||
pixlowstep = (bottomfracend-pixlow)/(range);
|
||||
|
||||
// If the highest part of a floor stretching up covers the entire screen
|
||||
@@ -2731,8 +2742,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
visffloor[i].b_pos_slope = roverright;
|
||||
visffloor[i].b_pos >>= 4;
|
||||
visffloor[i].b_pos_slope >>= 4;
|
||||
visffloor[i].b_frac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(visffloor[i].b_pos, rw_scale));
|
||||
visffloor[i].b_step = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(visffloor[i].b_pos_slope, ds_p->scale2));
|
||||
visffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(visffloor[i].b_pos, rw_scale);
|
||||
visffloor[i].b_step = (centeryfrac >> 4) - FixedMul(visffloor[i].b_pos_slope, ds_p->scale2);
|
||||
visffloor[i].b_step = (visffloor[i].b_step-visffloor[i].b_frac)/(range);
|
||||
};
|
||||
|
||||
@@ -2838,7 +2849,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
visffloor[i].b_pos = height;
|
||||
visffloor[i].b_pos = (visffloor[i].b_pos - viewz) >> 4;
|
||||
visffloor[i].b_step = FixedMul(-rw_scalestep, visffloor[i].b_pos);
|
||||
visffloor[i].b_frac = FixedClamp((INT64)(centeryfrac>>4) - FixedMul(visffloor[i].b_pos, rw_scale));
|
||||
visffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(visffloor[i].b_pos, rw_scale);
|
||||
};
|
||||
|
||||
while (i < numffloors && visffloor[i].polyobj != curline->polyseg)
|
||||
|
||||
+5
-7
@@ -11,7 +11,6 @@
|
||||
/// \file r_things.c
|
||||
/// \brief Refresh of things, i.e. objects represented by sprites
|
||||
|
||||
#include "m_fixed.h"
|
||||
#include "r_main.h" // stplyr
|
||||
#include "r_fps.h"
|
||||
#include "r_things.h"
|
||||
@@ -392,7 +391,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
|
||||
|
||||
// allocate space for the frames present and copy sprtemp to it
|
||||
if (spritedef->numframes && // has been allocated
|
||||
spritedef->numframes < maxframe) // more frames are defined ?
|
||||
spritedef->numframes < maxframe) // more frames are defined ?
|
||||
{
|
||||
|
||||
Z_Free(spritedef->spriteframes);
|
||||
@@ -617,11 +616,10 @@ void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column)
|
||||
if (topdelta <= prevdelta)
|
||||
topdelta += prevdelta;
|
||||
prevdelta = topdelta;
|
||||
topscreen = sprtopscreen + spryscale*topdelta;
|
||||
bottomscreen = topscreen + spryscale*column->length;
|
||||
|
||||
topscreen = FixedClamp((INT64)sprtopscreen + (INT64)spryscale * (INT64)topdelta);
|
||||
bottomscreen = FixedClamp((INT64)topscreen + (INT64)spryscale * (INT64)column->length);
|
||||
|
||||
dc->yl = FixedClamp((INT64)topscreen + (FRACUNIT-1))>>FRACBITS;
|
||||
dc->yl = (topscreen+FRACUNIT-1)>>FRACBITS;
|
||||
dc->yh = (bottomscreen-1)>>FRACBITS;
|
||||
|
||||
if (windowtop != INT32_MAX && windowbottom != INT32_MAX)
|
||||
@@ -887,7 +885,7 @@ static void R_DrawVisSprite(vissprite_t *vis)
|
||||
for (dc.x = vis->x1; dc.x <= vis->x2; dc.x++, spryscale += scalestep)
|
||||
{
|
||||
angle_t angle = ((vis->centerangle + xtoviewangle[dc.x]) >> ANGLETOFINESHIFT) & 0xFFF;
|
||||
texturecolumn = FixedClamp((INT64)vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale;
|
||||
texturecolumn = (vis->paperoffset - FixedMul(FINETANGENT(angle), vis->paperdistance)) / horzscale;
|
||||
|
||||
if (texturecolumn < 0 || texturecolumn >= pwidth)
|
||||
continue;
|
||||
|
||||
@@ -1841,18 +1841,15 @@ static void I_Fork(void)
|
||||
I_RegisterChildSignals();
|
||||
break;
|
||||
default:
|
||||
#ifdef LOGMESSAGES
|
||||
if (logstream)
|
||||
fclose(logstream);/* the child has this */
|
||||
|
||||
#endif
|
||||
c = wait(&status);
|
||||
|
||||
#ifdef LOGMESSAGES
|
||||
/* By the way, exit closes files. */
|
||||
logstream = fopen(logfilename, "at");
|
||||
#else
|
||||
logstream = 0;
|
||||
#endif
|
||||
|
||||
if (c == -1)
|
||||
{
|
||||
kill(child, SIGKILL);
|
||||
|
||||
+1
-3
@@ -3716,9 +3716,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
|
||||
// Make sure table is built
|
||||
if (heatshifter == NULL || lastheight != viewheight)
|
||||
{
|
||||
if (heatshifter)
|
||||
Z_Free(heatshifter);
|
||||
|
||||
Z_Free(heatshifter);
|
||||
heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL);
|
||||
|
||||
for (y = 0; y < viewheight; y++)
|
||||
|
||||
+3
-4
@@ -122,7 +122,9 @@ void W_Shutdown(void)
|
||||
|
||||
if (wad->handle)
|
||||
fclose(wad->handle);
|
||||
|
||||
Z_Free(wad->filename);
|
||||
|
||||
while (wad->numlumps--)
|
||||
{
|
||||
Z_Free(wad->lumpinfo[wad->numlumps].longname);
|
||||
@@ -2730,10 +2732,7 @@ void vres_Free(virtres_t* vres)
|
||||
|
||||
while (vres->numlumps--)
|
||||
{
|
||||
if (vres->vlumps[vres->numlumps].data)
|
||||
{
|
||||
Z_Free(vres->vlumps[vres->numlumps].data);
|
||||
}
|
||||
Z_Free(vres->vlumps[vres->numlumps].data);
|
||||
}
|
||||
|
||||
Z_Free(vres->vlumps);
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ void Z_Init(void);
|
||||
|
||||
// Z_Free and alloc with alignment
|
||||
#ifdef ZDEBUG
|
||||
#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__)
|
||||
#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__)
|
||||
#define Z_Malloc(s,t,u) Z_Malloc2(s, t, u, __FILE__, __LINE__)
|
||||
#define Z_Calloc(s,t,u) Z_Calloc2(s, t, u, __FILE__, __LINE__)
|
||||
#define Z_Realloc(p,s,t,u) Z_Realloc2(p,s, t, u, __FILE__, __LINE__)
|
||||
|
||||
Reference in new issue
Block a user