Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
669b42c4bb | ||
|
|
2a658a8476 | ||
|
|
8cab07a4b2 | ||
|
|
55c8546d68 | ||
|
|
1762f18116 | ||
|
|
e4dbf1ce11 | ||
|
|
10b9d96259 | ||
|
|
b23154fd93 | ||
|
|
b0ee972178 | ||
|
|
544e1d3b21 | ||
|
|
0ca6947f99 | ||
|
|
3122c08039 | ||
|
|
7a279a6fd9 |
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;
|
||||
|
||||
@@ -1009,6 +1009,9 @@ void D_RegisterClientCommands(void)
|
||||
CV_RegisterVar(&cv_gamepadled[i]);
|
||||
}
|
||||
|
||||
CV_RegisterVar(&cv_gamepadledifunfocused);
|
||||
CV_RegisterVar(&cv_rumbleifunfocused);
|
||||
|
||||
CV_RegisterVar(&cv_usemouse);
|
||||
CV_RegisterVar(&cv_invertmouse);
|
||||
CV_RegisterVar(&cv_mousexsens);
|
||||
|
||||
+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;
|
||||
}
|
||||
|
||||
|
||||
+6
-9
@@ -456,10 +456,10 @@ consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS] = {
|
||||
|
||||
//static CV_PossibleValue_t autoaccelcons_t[] = {{0, "Off"}, {1, "Manual"}, {2, "Automatic"}, {0, NULL}};
|
||||
consvar_t cv_autoaccel[MAXSPLITSCREENPLAYERS] = {
|
||||
{"autoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"autoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"autoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"autoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
|
||||
{"kartautoaccel", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"kartautoaccel2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"kartautoaccel3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"kartautoaccel4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -81,6 +81,9 @@ consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS] = {
|
||||
{"gamepadled4", "Skincolor", CV_SAVE|CV_CALL|CV_NOINIT, gamepadled_cons_t, led_off_handle4, 0, NULL, NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
consvar_t cv_gamepadledifunfocused = {"gamepadledunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_rumbleifunfocused = {"rumbleifunfocused", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static void rumble_off_handle(void)
|
||||
{
|
||||
if (!cv_rumble[0].value)
|
||||
@@ -930,7 +933,7 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT8 color)
|
||||
|
||||
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
|
||||
|
||||
if (cv_gamepadled[playernum].value == 0
|
||||
if (cv_gamepadled[playernum].value == 0 || (window_notinfocus && cv_gamepadledifunfocused.value == 0)
|
||||
|| color >= MAXTRANSLATIONS)
|
||||
{
|
||||
return;
|
||||
@@ -1009,7 +1012,7 @@ void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_stre
|
||||
{
|
||||
I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS);
|
||||
|
||||
if (cv_rumble[playernum].value == 0)
|
||||
if (cv_rumble[playernum].value == 0 || (window_notinfocus && cv_rumbleifunfocused.value == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,9 @@ extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
|
||||
extern consvar_t cv_rumblestrength[MAXSPLITSCREENPLAYERS];
|
||||
extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
|
||||
|
||||
extern consvar_t cv_gamepadledifunfocused;
|
||||
extern consvar_t cv_rumbleifunfocused;
|
||||
|
||||
extern INT32 mousex, mousey;
|
||||
|
||||
extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
|
||||
|
||||
@@ -335,7 +335,7 @@ angle_t gld_FrustumAngle(angle_t tiltangle)
|
||||
floatangle = 2.0 + (45.0 + ((double)tilt / 1.9)) * clipfov / 90.0;
|
||||
if (floatangle >= 180.0)
|
||||
return 0xffffffff;
|
||||
a1 = (angle_t)xs_CRoundToInt(ANG1 * floatangle);
|
||||
a1 = (angle_t)lrint(ANG1 * floatangle);
|
||||
return a1;
|
||||
}
|
||||
|
||||
|
||||
@@ -579,7 +579,7 @@ md2found:
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added after startup
|
||||
void HWR_AddPlayerMD2(INT32 skin, boolean local) // For MD2's that were added after startup
|
||||
{
|
||||
FILE *f;
|
||||
char name[20], filename[32];
|
||||
|
||||
+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())
|
||||
|
||||
+15
-12
@@ -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
|
||||
@@ -1484,6 +1483,7 @@ static char *CHAT_WordWrap(INT32 x, INT32 w, INT32 option, const char *string)
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return newstring;
|
||||
}
|
||||
|
||||
@@ -1522,7 +1522,7 @@ static void HU_drawMiniChat(void)
|
||||
emote_t *emote = NULL;
|
||||
int emotelen = 0;
|
||||
|
||||
while(msg[j]) // iterate through msg
|
||||
while (msg[j]) // iterate through msg
|
||||
{
|
||||
if (msg[j] < HU_FONTSTART) // don't draw
|
||||
{
|
||||
@@ -1554,19 +1554,21 @@ static void HU_drawMiniChat(void)
|
||||
{
|
||||
j++;
|
||||
}
|
||||
|
||||
prev_linereturn = false;
|
||||
dx += charwidth;
|
||||
|
||||
if (dx >= boxw)
|
||||
{
|
||||
dx = 0;
|
||||
linescount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
dy = 0;
|
||||
dx = 0;
|
||||
msglines += linescount+1;
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
y = chaty - charheight*(msglines+1);
|
||||
@@ -1598,7 +1600,7 @@ static void HU_drawMiniChat(void)
|
||||
emote_t *emote = NULL;
|
||||
int emotelen = 0;
|
||||
|
||||
while(msg[j]) // iterate through msg
|
||||
while (msg[j]) // iterate through msg
|
||||
{
|
||||
if (msg[j] < HU_FONTSTART) // don't draw
|
||||
{
|
||||
@@ -1643,16 +1645,17 @@ static void HU_drawMiniChat(void)
|
||||
|
||||
dx += charwidth;
|
||||
prev_linereturn = false;
|
||||
|
||||
if (dx >= boxw)
|
||||
{
|
||||
dx = 0;
|
||||
dy += charheight;
|
||||
}
|
||||
}
|
||||
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
// decrement addy and make that shit smooth:
|
||||
@@ -1704,7 +1707,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||
|
||||
V_DrawFillConsoleMap(chatx, chat_topy, boxw, boxh*charheight +2, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); // log box
|
||||
|
||||
for (i=0; i<chat_nummsg_log; i++) // iterate through our chatlog
|
||||
for (i = 0; i < chat_nummsg_log; i++) // iterate through our chatlog
|
||||
{
|
||||
INT32 clrflag = 0;
|
||||
INT32 j = 0;
|
||||
@@ -1713,7 +1716,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||
emote_t *emote = NULL;
|
||||
int emotelen = 0;
|
||||
|
||||
while(msg[j]) // iterate through msg
|
||||
while (msg[j]) // iterate through msg
|
||||
{
|
||||
if (msg[j] < HU_FONTSTART) // don't draw
|
||||
{
|
||||
@@ -1758,10 +1761,10 @@ static void HU_drawChatLog(INT32 offset)
|
||||
dy += charheight;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -265,35 +265,6 @@ FUNCMATH FUNCINLINE static ATTRINLINE fixed_t FixedRound(fixed_t x)
|
||||
return INT32_MAX;
|
||||
}
|
||||
|
||||
/** \brief The xs_CRoundToInt function
|
||||
|
||||
\param val double number
|
||||
|
||||
\return Round toward nearest, but ties round toward even
|
||||
*/
|
||||
#if defined(SRB2_BIG_ENDIAN)
|
||||
#define _xs_iexp_ 0
|
||||
#define _xs_iman_ 1
|
||||
#else
|
||||
#define _xs_iexp_ 1 //intel is little endian
|
||||
#define _xs_iman_ 0
|
||||
#endif //BigEndian_
|
||||
|
||||
typedef double real64;
|
||||
|
||||
typedef union _xs_doubleints
|
||||
{
|
||||
real64 val;
|
||||
unsigned ival[2];
|
||||
} _xs_doubleints;
|
||||
|
||||
FUNCMATH FUNCINLINE static ATTRINLINE int xs_CRoundToInt(real64 val)
|
||||
{
|
||||
_xs_doubleints uval;
|
||||
uval.val = val + 6755399441055744.0;
|
||||
return uval.ival[_xs_iman_];
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
fixed_t x;
|
||||
|
||||
+11
-7
@@ -4719,7 +4719,7 @@ static void M_DrawReplayHut(void)
|
||||
if (y > scaledviewheight-80)
|
||||
{
|
||||
V_DrawFill(BASEVIDWIDTH-4, 75, 4, scaledviewheight-80, V_SNAPTOTOP|V_SNAPTORIGHT|239);
|
||||
V_DrawFill(BASEVIDWIDTH-3, 76 + (scaledviewheight-80) * replayhutmenuy / y, 2, (((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, V_SNAPTOTOP|V_SNAPTORIGHT|229);
|
||||
V_DrawFill(BASEVIDWIDTH-3, 76 + (scaledviewheight-80) * replayhutmenuy / y, 2, max((((scaledviewheight-80) * (scaledviewheight-80))-1) / y - 1, 1), V_SNAPTOTOP|V_SNAPTORIGHT|229);
|
||||
}
|
||||
|
||||
// Draw the cursor
|
||||
@@ -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.
|
||||
|
||||
@@ -1205,6 +1205,10 @@ static menuitem_t OP_FocusOptionsMenu[] =
|
||||
{IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 100},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Visible Mouse", &cv_mousevisible, 120},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Gamepad LED Color While Unfocused ", &cv_gamepadledifunfocused, 140},
|
||||
{IT_STRING|IT_CVAR, NULL, "Gamepad Rumble While Unfocused", &cv_rumbleifunfocused, 150},
|
||||
|
||||
};
|
||||
|
||||
static const char* OP_FocusOptionsTooltips[] =
|
||||
@@ -1216,6 +1220,8 @@ static const char* OP_FocusOptionsTooltips[] =
|
||||
"Set manual framerate cap while the game is unfocused.",
|
||||
"Should the FOCUS LOST window appear\n while the game is unfocused?",
|
||||
"Displays the mouse cursor while the game is in focus.",
|
||||
"Should gamepad LED indicator change color when unfocused?",
|
||||
"Should gamepad rumble apply when unfocused?",
|
||||
};
|
||||
|
||||
static menuitem_t OP_DataOptionsMenu[] =
|
||||
|
||||
+2
-2
@@ -540,7 +540,7 @@ static boolean M_BackupConfig(const char *filename)
|
||||
void M_SaveConfig(const char *filename)
|
||||
{
|
||||
FILE *f;
|
||||
char *filepath;
|
||||
CLEANUP(Z_Pfree) char *filepath = NULL;
|
||||
|
||||
// make sure not to write back the config until it's been correctly loaded
|
||||
if (!loaded_config)
|
||||
@@ -558,7 +558,7 @@ void M_SaveConfig(const char *filename)
|
||||
// append srb2home to beginning of filename
|
||||
// but check if srb2home isn't already there, first
|
||||
if (!strstr(filename, srb2home))
|
||||
filepath = va(pandf,srb2home, filename);
|
||||
filepath = Z_StrDup(va(pandf, srb2home, filename));
|
||||
else
|
||||
filepath = Z_StrDup(filename);
|
||||
|
||||
|
||||
+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);
|
||||
|
||||
+8
-12
@@ -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));
|
||||
@@ -1018,8 +1014,8 @@ static void R_InitViewMapping(void)
|
||||
|
||||
for (INT32 i = 0; i < j; i++)
|
||||
{
|
||||
fixed_t dy = (i - viewheight*8)<<FRACBITS;
|
||||
dy = FixedMul(abs(dy), fovtan);
|
||||
fixed_t dy = abs(i - viewheight*8) << FRACBITS;
|
||||
dy = FixedMul(dy, fovtan);
|
||||
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
|
||||
}
|
||||
}
|
||||
|
||||
+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)
|
||||
|
||||
+8
-5
@@ -57,8 +57,11 @@ visffloor_t visffloor[MAXFFLOORS] = {};
|
||||
INT32 numffloors = 0;
|
||||
|
||||
//SoM: 3/23/2000: Boom visplane hashing routine.
|
||||
#define visplane_hash(picnum,lightlevel,height) \
|
||||
((unsigned)((picnum)*3+(lightlevel)+(height)*7) & VISPLANEHASHMASK)
|
||||
constexpr unsigned int visplane_hash(const unsigned int picnum, const unsigned int lightlevel,
|
||||
const unsigned int height)
|
||||
{
|
||||
return ((picnum * 3) + lightlevel + (height * 7)) & VISPLANEHASHMASK;
|
||||
}
|
||||
|
||||
//
|
||||
// Clip values are the solid pixel bounding the range.
|
||||
@@ -136,7 +139,7 @@ void R_AllocPlaneMemory(void)
|
||||
}
|
||||
|
||||
yslopetab = static_cast<fixed_t*>(Z_Realloc(yslopetab, sizeof(*yslopetab) * (viewheight * 16), PU_STATIC, NULL));
|
||||
spanstart = static_cast<fixed_t*>(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL));
|
||||
spanstart = static_cast<INT32*>(Z_Realloc(spanstart, sizeof(*spanstart) * viewheight, PU_STATIC, NULL));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -451,7 +454,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
|
||||
}
|
||||
}
|
||||
|
||||
hash = visplane_hash(picnum, lightlevel, height);
|
||||
hash = visplane_hash(picnum, lightlevel, height >> FRACBITS);
|
||||
|
||||
for (check = visplanes[hash]; check; check = check->next)
|
||||
{
|
||||
@@ -562,7 +565,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height);
|
||||
unsigned hash = visplane_hash(pl->picnum, pl->lightlevel, pl->height >> FRACBITS);
|
||||
new_pl = new_visplane(hash);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2880,7 +2880,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
if (markceiling)
|
||||
{
|
||||
if (ceilingplane) //SoM: 3/29/2000: Check for null ceiling planes
|
||||
ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1);
|
||||
ceilingplane = R_CheckPlane(ceilingplane, rw_x, rw_stopx-1);
|
||||
else
|
||||
markceiling = false;
|
||||
|
||||
@@ -2894,7 +2894,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
if (markfloor)
|
||||
{
|
||||
if (floorplane) //SoM: 3/29/2000: Check for null planes
|
||||
floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1);
|
||||
floorplane = R_CheckPlane(floorplane, rw_x, rw_stopx-1);
|
||||
else
|
||||
markfloor = false;
|
||||
|
||||
|
||||
+1
-1
@@ -391,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);
|
||||
|
||||
@@ -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