Merge branch 'Saturn-Next' into vres-skip-map-marker
This commit is contained in:
commit
818e6046b7
62 files changed
+2689
-2340
No files matched your search
@@ -28,6 +28,7 @@ LOCAL_SRC_FILES := am_map.c \
|
||||
m_cheat.c \
|
||||
m_fixed.c \
|
||||
m_menu.c \
|
||||
m_textinput.c \
|
||||
m_misc.c \
|
||||
m_queue.c \
|
||||
m_random.c \
|
||||
|
||||
+553
-551
File diff suppressed because it is too large.
Load diff
@@ -529,6 +529,7 @@ OBJS:=$(i_main_o) \
|
||||
$(OBJDIR)/m_fixed.o \
|
||||
$(OBJDIR)/m_menu.o \
|
||||
$(OBJDIR)/m_misc.o \
|
||||
$(OBJDIR)/m_textinput.o \
|
||||
$(OBJDIR)/m_perfstats.o \
|
||||
$(OBJDIR)/m_random.o \
|
||||
$(OBJDIR)/m_queue.o \
|
||||
|
||||
+48
-348
@@ -32,6 +32,7 @@
|
||||
#include "i_threads.h"
|
||||
#include "d_main.h"
|
||||
#include "m_menu.h"
|
||||
#include "m_textinput.h"
|
||||
#include "filesrch.h"
|
||||
|
||||
#ifdef HWRENDER
|
||||
@@ -97,9 +98,7 @@ static char inputlines[32][CON_MAXPROMPTCHARS]; // hold last 32 prompt lines
|
||||
|
||||
static INT32 inputline; // current input line number
|
||||
static INT32 inputhist; // line number of history input line to restore
|
||||
static size_t input_cur; // position of cursor in line
|
||||
static size_t input_sel; // position of selection marker (I.E.: anything between this and input_cur is "selected")
|
||||
static size_t input_len; // length of current line, used to bound cursor and such
|
||||
static textinput_t input;
|
||||
// notice: input does NOT include the "$" at the start of the line. - 11/3/16
|
||||
|
||||
// protos.
|
||||
@@ -458,7 +457,8 @@ static void CON_InputInit(void)
|
||||
// prepare the first prompt line
|
||||
memset(inputlines, 0, sizeof (inputlines));
|
||||
inputline = 0;
|
||||
input_cur = input_sel = input_len = 0;
|
||||
|
||||
M_TextInputInit(&input, inputlines[inputline], CON_MAXPROMPTCHARS);
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
@@ -802,178 +802,6 @@ void CON_Ticker(void)
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
//
|
||||
// ----
|
||||
//
|
||||
// Shortcuts for adding and deleting characters, strings, and sections
|
||||
// Necessary due to moving cursor
|
||||
//
|
||||
|
||||
static void CON_InputClear(void)
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
|
||||
input_cur = input_sel = input_len = 0;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_InputSetString(const char *c)
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
memset(inputlines[inputline], 0, CON_MAXPROMPTCHARS);
|
||||
strcpy(inputlines[inputline], c);
|
||||
input_cur = input_sel = input_len = strlen(c);
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_InputAddString(const char *c)
|
||||
{
|
||||
size_t csize = strlen(c);
|
||||
|
||||
Lock_state();
|
||||
|
||||
if (input_len + csize > CON_MAXPROMPTCHARS-1)
|
||||
{
|
||||
Unlock_state();
|
||||
return;
|
||||
}
|
||||
if (input_cur != input_len)
|
||||
memmove(&inputlines[inputline][input_cur+csize], &inputlines[inputline][input_cur], input_len-input_cur);
|
||||
memcpy(&inputlines[inputline][input_cur], c, csize);
|
||||
input_len += csize;
|
||||
input_sel = (input_cur += csize);
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_InputDel(size_t start, size_t end)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
Lock_state();
|
||||
|
||||
len = (end - start);
|
||||
|
||||
if (end != input_len)
|
||||
memmove(&inputlines[inputline][start], &inputlines[inputline][end], input_len-end);
|
||||
memset(&inputlines[inputline][input_len - len], 0, len);
|
||||
|
||||
input_len -= len;
|
||||
|
||||
if (input_sel >= end)
|
||||
input_sel -= len;
|
||||
else if (input_sel > start)
|
||||
input_sel = start;
|
||||
|
||||
if (input_cur >= end)
|
||||
input_cur -= len;
|
||||
else if (input_cur > start)
|
||||
input_cur = start;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_InputDelSelection(void)
|
||||
{
|
||||
size_t start, end;
|
||||
|
||||
Lock_state();
|
||||
|
||||
if (input_cur > input_sel)
|
||||
{
|
||||
start = input_sel;
|
||||
end = input_cur;
|
||||
}
|
||||
else
|
||||
{
|
||||
start = input_cur;
|
||||
end = input_sel;
|
||||
}
|
||||
|
||||
CON_InputDel(start, end);
|
||||
|
||||
input_sel = input_cur = start;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_ToWordEnd(boolean move_sel)
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
// Skip spaces
|
||||
while (input_cur < input_len && isspace(inputlines[inputline][input_cur]))
|
||||
++input_cur;
|
||||
|
||||
// Skip word
|
||||
while (input_cur < input_len && !isspace(inputlines[inputline][input_cur]))
|
||||
++input_cur;
|
||||
|
||||
if (move_sel) input_sel = input_cur;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_ToWordBegin(boolean move_sel)
|
||||
{
|
||||
Lock_state();
|
||||
|
||||
// Hack, always move back 1 character if possible so if we press ctrl-left at a word beginning
|
||||
// we move to previous word
|
||||
if (input_cur) --input_cur;
|
||||
|
||||
// Skip spaces
|
||||
while (input_cur && isspace(inputlines[inputline][input_cur]))
|
||||
--input_cur;
|
||||
|
||||
// Skip word
|
||||
while (input_cur && !isspace(inputlines[inputline][input_cur]))
|
||||
--input_cur;
|
||||
|
||||
// Unless we reached beginning of line, we're pointing at a space before word, so move cursor
|
||||
// forward to fix that
|
||||
if (input_cur) ++input_cur;
|
||||
|
||||
if (move_sel) input_sel = input_cur;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_InputAddChar(char c)
|
||||
{
|
||||
if (input_len >= CON_MAXPROMPTCHARS-1)
|
||||
return;
|
||||
|
||||
Lock_state();
|
||||
|
||||
if (input_cur != input_len)
|
||||
memmove(&inputlines[inputline][input_cur+1], &inputlines[inputline][input_cur], input_len-input_cur);
|
||||
inputlines[inputline][input_cur++] = c;
|
||||
inputlines[inputline][++input_len] = 0;
|
||||
input_sel = input_cur;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
static void CON_InputDelChar(void)
|
||||
{
|
||||
if (!input_cur)
|
||||
return;
|
||||
|
||||
Lock_state();
|
||||
|
||||
if (input_cur != input_len)
|
||||
memmove(&inputlines[inputline][input_cur-1], &inputlines[inputline][input_cur], input_len-input_cur);
|
||||
inputlines[inputline][--input_len] = 0;
|
||||
input_sel = --input_cur;
|
||||
|
||||
Unlock_state();
|
||||
}
|
||||
|
||||
//
|
||||
// ----
|
||||
//
|
||||
@@ -1054,6 +882,10 @@ boolean CON_Responder(event_t *ev)
|
||||
}
|
||||
}
|
||||
|
||||
Lock_state();
|
||||
M_TextInputHandle(&input, key);
|
||||
Unlock_state();
|
||||
|
||||
// Always eat ctrl/shift/alt if console open, so the menu doesn't get ideas
|
||||
if (key == KEY_LSHIFT || key == KEY_RSHIFT
|
||||
|| key == KEY_LCTRL || key == KEY_RCTRL
|
||||
@@ -1066,12 +898,11 @@ boolean CON_Responder(event_t *ev)
|
||||
// show all cvars/commands that match what we have inputted
|
||||
if (key == KEY_TAB)
|
||||
{
|
||||
|
||||
if (!completion[0])
|
||||
{
|
||||
if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' '))
|
||||
if (!input.length || input.length >= 40 || strchr(input.buffer, ' '))
|
||||
return true;
|
||||
strcpy(completion, inputlines[inputline]);
|
||||
strcpy(completion, input.buffer);
|
||||
comskips = varskips = 0;
|
||||
}
|
||||
|
||||
@@ -1092,74 +923,9 @@ boolean CON_Responder(event_t *ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key == 'x' || key == 'X')
|
||||
{
|
||||
if (input_sel > input_cur)
|
||||
I_ClipboardCopy(&inputlines[inputline][input_cur], input_sel-input_cur);
|
||||
else
|
||||
I_ClipboardCopy(&inputlines[inputline][input_sel], input_cur-input_sel);
|
||||
CON_InputDelSelection();
|
||||
// Those are already handled in M_TextInputHandle, but they do extra logic... Maybe textinput_t should have some sort of callbacks?
|
||||
if (key == 'x' || key == 'X' || key == 'v' || key == 'V')
|
||||
completion[0] = 0;
|
||||
return true;
|
||||
}
|
||||
else if (key == 'c' || key == 'C')
|
||||
{
|
||||
if (input_sel > input_cur)
|
||||
I_ClipboardCopy(&inputlines[inputline][input_cur], input_sel-input_cur);
|
||||
else
|
||||
I_ClipboardCopy(&inputlines[inputline][input_sel], input_cur-input_sel);
|
||||
return true;
|
||||
}
|
||||
else if (key == 'v' || key == 'V')
|
||||
{
|
||||
const char *paste = I_ClipboardPaste();
|
||||
if (input_sel != input_cur)
|
||||
CON_InputDelSelection();
|
||||
if (paste != NULL)
|
||||
CON_InputAddString(paste);
|
||||
completion[0] = 0;
|
||||
return true;
|
||||
}
|
||||
else if (key == 'w' || key == 'W')
|
||||
{
|
||||
size_t word_start, word_end, i;
|
||||
word_end = i = input_cur;
|
||||
|
||||
// Unless we're pointing at the beginning of line, decrement i so we only start
|
||||
// removing symbols that come before the cursor
|
||||
if (i) --i;
|
||||
|
||||
// We might be pointing to spaces, skip them first
|
||||
while (i && isspace(inputlines[inputline][i]))
|
||||
--i;
|
||||
|
||||
// Now skip the "word"
|
||||
while (i && !isspace(inputlines[inputline][i]))
|
||||
--i;
|
||||
|
||||
// Unless we reached beginning of line, i is pointing at first space that was found
|
||||
// before word start, and we don't want to remove it
|
||||
if (i) ++i;
|
||||
|
||||
word_start = i;
|
||||
|
||||
if (word_start != word_end)
|
||||
CON_InputDel(word_start, word_end);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (key == KEY_RIGHTARROW)
|
||||
CON_ToWordEnd(!shiftdown);
|
||||
else if (key == KEY_LEFTARROW)
|
||||
CON_ToWordBegin(!shiftdown);
|
||||
|
||||
// Select all
|
||||
if (key == 'a' || key == 'A')
|
||||
{
|
||||
input_sel = 0;
|
||||
input_cur = input_len;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ...why shouldn't it eat the key? if it doesn't, it just means you
|
||||
// can control Sonic from the console, which is silly
|
||||
@@ -1174,9 +940,9 @@ boolean CON_Responder(event_t *ev)
|
||||
// remember typing for several completions (a-la-4dos)
|
||||
if (!completion[0])
|
||||
{
|
||||
if (!input_len || input_len >= 40 || strchr(inputlines[inputline], ' '))
|
||||
if (!input.length || input.length >= 40 || strchr(input.buffer, ' '))
|
||||
return true;
|
||||
strcpy(completion, inputlines[inputline]);
|
||||
strcpy(completion, input.buffer);
|
||||
comskips = varskips = 0;
|
||||
}
|
||||
else
|
||||
@@ -1207,7 +973,11 @@ boolean CON_Responder(event_t *ev)
|
||||
cmd = CV_CompleteVar(completion, varskips);
|
||||
|
||||
if (cmd)
|
||||
CON_InputSetString(va("%s ", cmd));
|
||||
{
|
||||
Lock_state();
|
||||
M_TextInputSetString(&input, va("%s ", cmd));
|
||||
Unlock_state();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (comskips > 0)
|
||||
@@ -1233,37 +1003,6 @@ boolean CON_Responder(event_t *ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key == KEY_LEFTARROW)
|
||||
{
|
||||
if (input_cur != 0)
|
||||
--input_cur;
|
||||
if (!shiftdown)
|
||||
input_sel = input_cur;
|
||||
return true;
|
||||
}
|
||||
else if (key == KEY_RIGHTARROW)
|
||||
{
|
||||
if (input_cur < input_len)
|
||||
++input_cur;
|
||||
if (!shiftdown)
|
||||
input_sel = input_cur;
|
||||
return true;
|
||||
}
|
||||
else if (key == KEY_HOME)
|
||||
{
|
||||
input_cur = 0;
|
||||
if (!shiftdown)
|
||||
input_sel = input_cur;
|
||||
return true;
|
||||
}
|
||||
else if (key == KEY_END)
|
||||
{
|
||||
input_cur = input_len;
|
||||
if (!shiftdown)
|
||||
input_sel = input_cur;
|
||||
return true;
|
||||
}
|
||||
|
||||
// At this point we're messing with input
|
||||
// Clear completion
|
||||
completion[0] = 0;
|
||||
@@ -1271,45 +1010,29 @@ boolean CON_Responder(event_t *ev)
|
||||
// command enter
|
||||
if (key == KEY_ENTER)
|
||||
{
|
||||
if (!input_len)
|
||||
if (!input.length)
|
||||
return true;
|
||||
|
||||
// push the command
|
||||
COM_BufAddText(inputlines[inputline]);
|
||||
COM_BufAddText(input.buffer);
|
||||
COM_BufAddText("\n");
|
||||
|
||||
CONS_Printf("\x86""%c""\x80""%s\n", CON_PROMPTCHAR, inputlines[inputline]);
|
||||
|
||||
Lock_state();
|
||||
|
||||
// Only add command to history if it differs from previous one
|
||||
if (strcmp(inputlines[inputline], inputlines[(inputline-1) & 31]))
|
||||
if (strcmp(input.buffer, inputlines[(inputline-1) & 31]))
|
||||
{
|
||||
inputline = (inputline+1) & 31;
|
||||
M_TextInputInit(&input, inputlines[inputline], CON_MAXPROMPTCHARS);
|
||||
}
|
||||
|
||||
inputhist = inputline;
|
||||
CON_InputClear();
|
||||
M_TextInputClear(&input);
|
||||
|
||||
return true;
|
||||
}
|
||||
Unlock_state();
|
||||
|
||||
// backspace and delete command prompt
|
||||
if (input_sel != input_cur)
|
||||
{
|
||||
if (key == KEY_BACKSPACE || key == KEY_DEL)
|
||||
{
|
||||
CON_InputDelSelection();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (key == KEY_BACKSPACE)
|
||||
{
|
||||
CON_InputDelChar();
|
||||
return true;
|
||||
}
|
||||
else if (key == KEY_DEL)
|
||||
{
|
||||
if (input_cur == input_len)
|
||||
return true;
|
||||
++input_cur;
|
||||
CON_InputDelChar();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1326,7 +1049,9 @@ boolean CON_Responder(event_t *ev)
|
||||
if (inputhist == inputline)
|
||||
inputhist = (inputline + 1) & 31;
|
||||
|
||||
CON_InputSetString(inputlines[inputhist]);
|
||||
Lock_state();
|
||||
M_TextInputSetString(&input, inputlines[inputhist]);
|
||||
Unlock_state();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1340,41 +1065,16 @@ boolean CON_Responder(event_t *ev)
|
||||
while (inputhist != inputline && !inputlines[inputhist][0]);
|
||||
|
||||
// back to currentline
|
||||
Lock_state();
|
||||
if (inputhist == inputline)
|
||||
CON_InputClear();
|
||||
M_TextInputClear(&input);
|
||||
else
|
||||
CON_InputSetString(inputlines[inputhist]);
|
||||
M_TextInputSetString(&input, inputlines[inputhist]);
|
||||
Unlock_state();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// allow people to use keypad in console (good for typing IP addresses) - Calum
|
||||
if (key >= KEY_KEYPAD7 && key <= KEY_KPADDEL)
|
||||
{
|
||||
char keypad_translation[] = {'7','8','9','-',
|
||||
'4','5','6','+',
|
||||
'1','2','3',
|
||||
'0','.'};
|
||||
|
||||
key = keypad_translation[key - KEY_KEYPAD7];
|
||||
}
|
||||
else if (key == KEY_KPADSLASH)
|
||||
key = '/';
|
||||
|
||||
// same capslock code as hu_stuff.c's HU_responder. Check there for details.
|
||||
key = CON_ShiftChar(key);
|
||||
|
||||
// enter a char into the command prompt
|
||||
if (key < 32 || key > 127)
|
||||
return true;
|
||||
|
||||
// add key to cmd line here
|
||||
if (key >= 'A' && key <= 'Z' && !(shiftdown ^ capslock)) //this is only really necessary for dedicated servers
|
||||
key = key + 'a' - 'A';
|
||||
|
||||
if (input_sel != input_cur)
|
||||
CON_InputDelSelection();
|
||||
CON_InputAddChar(key);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1656,16 +1356,16 @@ static void CON_DrawInput(void)
|
||||
|
||||
clen = con_width-13;
|
||||
|
||||
if (input_len <= clen)
|
||||
if (input.length <= clen)
|
||||
{
|
||||
c = 0;
|
||||
clen = input_len;
|
||||
clen = input.length;
|
||||
}
|
||||
else // input line scrolls left if it gets too long
|
||||
{
|
||||
clen -= 2; // There will always be some extra truncation -- but where is what we'll find out
|
||||
|
||||
if (input_cur <= clen/2)
|
||||
if (input.cursor <= clen/2)
|
||||
{
|
||||
// Close enough to right edge to show all
|
||||
c = 0;
|
||||
@@ -1676,15 +1376,15 @@ static void CON_DrawInput(void)
|
||||
{
|
||||
// Cursor in the middle (or right side) of input
|
||||
// Move over for the ellipsis
|
||||
c = input_cur - (clen/2) + 2;
|
||||
c = input.cursor - (clen/2) + 2;
|
||||
x += charwidth*2;
|
||||
lellip = 1;
|
||||
|
||||
if (c + clen >= input_len)
|
||||
if (c + clen >= input.length)
|
||||
{
|
||||
// Cursor in the right side of input
|
||||
// We were too far over, so move back
|
||||
c = input_len - clen;
|
||||
c = input.length - clen;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1698,7 +1398,7 @@ static void CON_DrawInput(void)
|
||||
if (lellip)
|
||||
{
|
||||
x -= charwidth*3;
|
||||
if (input_sel < c)
|
||||
if (input.select < c)
|
||||
V_DrawFill(x, y, charwidth*3, (10 * con_scalefactor), 107 | V_NOSCALESTART);
|
||||
for (i = 0; i < 3; ++i, x += charwidth)
|
||||
V_DrawCharacter(x, y, '.' | cv_constextsize.value | V_GRAYMAP | V_NOSCALESTART, !cv_allcaps.value);
|
||||
@@ -1708,7 +1408,7 @@ static void CON_DrawInput(void)
|
||||
|
||||
for (cend = c + clen; c < cend; ++c, x += charwidth)
|
||||
{
|
||||
if ((input_sel > c && input_cur <= c) || (input_sel <= c && input_cur > c))
|
||||
if ((input.select > c && input.cursor <= c) || (input.select <= c && input.cursor > c))
|
||||
{
|
||||
V_DrawFill(x, y, charwidth, (10 * con_scalefactor), 107 | V_NOSCALESTART);
|
||||
V_DrawCharacter(x, y, p[c] | cv_constextsize.value | V_YELLOWMAP | V_NOSCALESTART, !cv_allcaps.value);
|
||||
@@ -1716,14 +1416,14 @@ static void CON_DrawInput(void)
|
||||
else
|
||||
V_DrawCharacter(x, y, p[c] | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
|
||||
|
||||
if (c == input_cur && con_tick >= 4)
|
||||
if (c == input.cursor && con_tick >= 4)
|
||||
V_DrawCharacter(x, y + (con_scalefactor*2), '_' | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
|
||||
}
|
||||
if (cend == input_cur && con_tick >= 4)
|
||||
if (cend == input.cursor && con_tick >= 4)
|
||||
V_DrawCharacter(x, y + (con_scalefactor*2), '_' | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
|
||||
if (rellip)
|
||||
{
|
||||
if (input_sel > cend)
|
||||
if (input.select > cend)
|
||||
V_DrawFill(x, y, charwidth*3, (10 * con_scalefactor), 107 | V_NOSCALESTART);
|
||||
for (i = 0; i < 3; ++i, x += charwidth)
|
||||
V_DrawCharacter(x, y, '.' | cv_constextsize.value | V_GRAYMAP | V_NOSCALESTART, !cv_allcaps.value);
|
||||
|
||||
+6
-2
@@ -136,7 +136,7 @@ static UINT8 gamestate_resend_counter[MAXNETNODES];
|
||||
#endif
|
||||
|
||||
// kart, true when a player is connecting or disconnecting so that the gameplay has stopped in its tracks
|
||||
UINT8 hu_stopped = 0;
|
||||
boolean hu_stopped = false;
|
||||
|
||||
// Client specific
|
||||
static ticcmd_t localcmds;
|
||||
@@ -3394,6 +3394,7 @@ void CL_Reset(void)
|
||||
curl_running = false;
|
||||
http_source[0] = '\0';
|
||||
#endif
|
||||
G_ResetAllDeviceRumbles();
|
||||
|
||||
// D_StartTitle should get done now, but the calling function will handle it
|
||||
}
|
||||
@@ -4246,6 +4247,7 @@ static void ResetNode(INT32 node)
|
||||
resendingsavegame[node] = false;
|
||||
can_receive_gamestate[node] = false;
|
||||
savegameresendcooldown[node] = 0;
|
||||
gamestate_resend_counter[node] = 0;
|
||||
#endif
|
||||
//
|
||||
}
|
||||
@@ -5381,6 +5383,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||
}
|
||||
|
||||
#ifdef SATURNSYNCH
|
||||
// this decreases by one point at twice the cooldown time (ex cooldown of 2 seconds means, this counter decreases by one every 4 seconds), pretty much there to prevent a resynch loop
|
||||
if ((gamestate_resend_counter[node] != 0) && (I_GetTime() % ((max(cv_resynchcooldown.value, 1) * TICRATE) *2) == 0))
|
||||
gamestate_resend_counter[node]--;
|
||||
|
||||
@@ -5431,6 +5434,7 @@ static void HandlePacketFromPlayer(SINT8 node)
|
||||
DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n",
|
||||
netconsole, realstart, consistancy[realstart%TICQUEUE],
|
||||
SHORT(netbuffer->u.clientpak.consistancy)));
|
||||
gamestate_resend_counter[node] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -6381,7 +6385,7 @@ boolean TryRunTics(tic_t realtics)
|
||||
|
||||
if (demo.playback)
|
||||
{
|
||||
neededtic = gametic + realtics * (gamestate == GS_LEVEL ? cv_playbackspeed.value : 1);
|
||||
neededtic = gametic + realtics;
|
||||
// start a game after a demo
|
||||
maketic += realtics;
|
||||
firstticstosend = maketic;
|
||||
|
||||
+1
-1
@@ -656,7 +656,7 @@ extern UINT8 hu_resynching;
|
||||
#ifdef SATURNSYNCH
|
||||
extern UINT8 hu_redownloadinggamestate;
|
||||
#endif
|
||||
extern UINT8 hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player
|
||||
extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player
|
||||
|
||||
typedef struct rewind_s {
|
||||
UINT8 savebuffer[(768*1024)];
|
||||
|
||||
+36
-42
@@ -654,7 +654,7 @@ static boolean D_Display(void)
|
||||
// =========================================================================
|
||||
|
||||
tic_t rendergametic;
|
||||
static int menuInputDelayTimer = 0;
|
||||
static SINT8 menuInputDelayTimer = 0;
|
||||
|
||||
void D_SRB2Loop(void)
|
||||
{
|
||||
@@ -780,6 +780,38 @@ void D_SRB2Loop(void)
|
||||
|
||||
doDisplay = true;
|
||||
}
|
||||
|
||||
#define DPADSCROLLINPUT(INPUT)\
|
||||
{\
|
||||
myev.data1 = INPUT;\
|
||||
M_Responder(&myev);\
|
||||
}
|
||||
// this is absolutely awful and i hate it lmao
|
||||
if (menuactive && (DPADUPSCROLL || DPADDOWNSCROLL || DPADLEFTSCROLL || DPADRIGHTSCROLL))
|
||||
{
|
||||
event_t myev;
|
||||
myev.type = ev_keydown;
|
||||
|
||||
if (menuInputDelayTimer < 19)
|
||||
menuInputDelayTimer++;
|
||||
|
||||
if (menuInputDelayTimer == 19) // TICRATE * ( (k+2) (1 - [wz + h + j - q]^2 - [(gk + 2g + k + 1)(h + j) + h - z]^2 - [16(k + 1)^3(k + 2)(n + 1)^2 + 1 - f^2]^2 calculated by my butt
|
||||
{
|
||||
if (DPADUPSCROLL)
|
||||
DPADSCROLLINPUT(KEY_UPARROW)
|
||||
else if (DPADDOWNSCROLL)
|
||||
DPADSCROLLINPUT(KEY_DOWNARROW)
|
||||
else if (DPADLEFTSCROLL)
|
||||
DPADSCROLLINPUT(KEY_LEFTARROW)
|
||||
else if (DPADRIGHTSCROLL)
|
||||
DPADSCROLLINPUT(KEY_RIGHTARROW)
|
||||
}
|
||||
}
|
||||
else
|
||||
menuInputDelayTimer = 0;
|
||||
#undef DPADSCROLLINPUT
|
||||
|
||||
D_DeviceLEDTick();
|
||||
}
|
||||
|
||||
if (interp)
|
||||
@@ -794,11 +826,14 @@ void D_SRB2Loop(void)
|
||||
{
|
||||
rendertimefrac = FRACUNIT;
|
||||
}
|
||||
|
||||
rendertimefrac_unpaused = g_time.timefrac;
|
||||
}
|
||||
else
|
||||
{
|
||||
renderdeltatics = realtics * FRACUNIT;
|
||||
rendertimefrac = FRACUNIT;
|
||||
rendertimefrac_unpaused = FRACUNIT;
|
||||
}
|
||||
|
||||
if ((interp || doDisplay) && !frameskip)
|
||||
@@ -828,47 +863,6 @@ void D_SRB2Loop(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
// this is absolutely awful and i hate it lmao
|
||||
if (menuactive && (DPADUPSCROLL || DPADDOWNSCROLL || DPADLEFTSCROLL || DPADRIGHTSCROLL))
|
||||
{
|
||||
event_t myev;
|
||||
myev.type = ev_keydown;
|
||||
|
||||
if (renderisnewtic)
|
||||
{
|
||||
menuInputDelayTimer++;
|
||||
|
||||
if (menuInputDelayTimer >= 19) // TICRATE * ( (k+2) (1 - [wz + h + j - q]^2 - [(gk + 2g + k + 1)(h + j) + h - z]^2 - [16(k + 1)^3(k + 2)(n + 1)^2 + 1 - f^2]^2 calculated by my butt
|
||||
{
|
||||
if (DPADUPSCROLL)
|
||||
{
|
||||
myev.data1 = KEY_UPARROW;
|
||||
M_Responder(&myev);
|
||||
}
|
||||
else if (DPADDOWNSCROLL)
|
||||
{
|
||||
myev.data1 = KEY_DOWNARROW;
|
||||
M_Responder(&myev);
|
||||
}
|
||||
else if (DPADLEFTSCROLL)
|
||||
{
|
||||
myev.data1 = KEY_LEFTARROW;
|
||||
M_Responder(&myev);
|
||||
}
|
||||
else if (DPADRIGHTSCROLL)
|
||||
{
|
||||
myev.data1 = KEY_RIGHTARROW;
|
||||
M_Responder(&myev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
menuInputDelayTimer = 0;
|
||||
|
||||
if (!dedicated && renderisnewtic) // idk does this need dedi check??
|
||||
D_DeviceLEDTick();
|
||||
|
||||
// Fully completed frame made.
|
||||
finishprecise = I_GetPreciseTime();
|
||||
|
||||
|
||||
+4
-4
@@ -1446,13 +1446,13 @@ void Command_Ping_f(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (f_width < 10) f_width = 1;
|
||||
if (f_width < 10) f_width = 1;
|
||||
else if (f_width < 100) f_width = 2;
|
||||
else f_width = 3;
|
||||
else f_width = 3;
|
||||
|
||||
if (ms_width < 10) ms_width = 1;
|
||||
if (ms_width < 10) ms_width = 1;
|
||||
else if (ms_width < 100) ms_width = 2;
|
||||
else ms_width = 3;
|
||||
else ms_width = 3;
|
||||
|
||||
qsort(pingv, pingc, sizeof (struct pingcell), &pingcellcmp);
|
||||
|
||||
|
||||
+7
-2
@@ -569,7 +569,7 @@ consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_
|
||||
|
||||
consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_kartdebugdirector = {"debugdirector", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_showdirectorhud = {"showdirectorhud", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_showdirectorhud = {"showdirectorhud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_showtrackaddon = {"showtrackaddon", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
@@ -3228,6 +3228,8 @@ static void Got_Pause(UINT8 **cp, INT32 playernum)
|
||||
else
|
||||
S_ResumeAudio();
|
||||
}
|
||||
|
||||
G_ResetAllDeviceRumbles();
|
||||
}
|
||||
|
||||
static void Command_ReplayMarker(void)
|
||||
@@ -3245,7 +3247,10 @@ static void Command_ReplayMarker(void)
|
||||
demo.savemode = DSM_WILLAUTOSAVE;
|
||||
if (adjustedleveltime < 0)
|
||||
adjustedleveltime = 0;
|
||||
snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", G_BuildMapTitle(gamemap), G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername);
|
||||
char *title = G_BuildMapTitle(gamemap);
|
||||
snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername);
|
||||
if (title)
|
||||
Z_Free(title);
|
||||
CONS_Printf("Replay will be saved!\n");
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -65,10 +65,10 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid);
|
||||
#ifdef HAVE_CURL
|
||||
size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
#if defined(CURL_AT_LEAST_VERSION) && CURL_AT_LEAST_VERSION(7, 35, 0)
|
||||
int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
|
||||
static int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow);
|
||||
#define XFERINFOFUNCTION
|
||||
#else
|
||||
int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
static int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1203,7 +1203,7 @@ size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
}
|
||||
|
||||
#ifdef XFERINFOFUNCTION
|
||||
int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
|
||||
static int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow)
|
||||
{
|
||||
time_t curtime;
|
||||
|
||||
@@ -1228,7 +1228,7 @@ int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow,
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||
static int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||
{
|
||||
time_t curtime;
|
||||
|
||||
|
||||
@@ -9216,6 +9216,11 @@ int LUA_EnumLib(lua_State *L)
|
||||
lua_glib_push_bool_getter(L, &demo.playback);
|
||||
lua_call(L, 2, 0);
|
||||
|
||||
lua_pushcfunction(L, lua_glib_new_getter);
|
||||
lua_pushliteral(L, "replayfreecam");
|
||||
lua_glib_push_bool_getter(L, &demo.freecam);
|
||||
lua_call(L, 2, 0);
|
||||
|
||||
if (!mathlib)
|
||||
{
|
||||
lua_pushcfunction(L, lua_glib_new_getter);
|
||||
|
||||
+6
-1
@@ -474,7 +474,12 @@ void M_StartupLocale(void);
|
||||
// M_GetText function that just returns the string.
|
||||
#define M_GetText(x) (x)
|
||||
#endif
|
||||
void *M_Memcpy(void* dest, const void* src, size_t n);
|
||||
|
||||
FUNCINLINE static ATTRINLINE void *M_Memcpy(void *dest, const void *src, size_t n)
|
||||
{
|
||||
return memcpy(dest, src, n);
|
||||
}
|
||||
|
||||
char *va(const char *format, ...) FUNCPRINTF;
|
||||
char *M_GetToken(const char *inputString);
|
||||
char *sizeu1(size_t num);
|
||||
|
||||
+1
-1
@@ -192,7 +192,7 @@ extern struct quake
|
||||
// camera offsets and duration
|
||||
fixed_t x,y,z;
|
||||
angle_t roll;
|
||||
UINT16 time;
|
||||
tic_t time;
|
||||
|
||||
// location, radius, and intensity...
|
||||
mappoint_t *epicenter;
|
||||
|
||||
+5
-5
@@ -170,8 +170,8 @@ static void F_SkyScroll(INT32 scrollspeed)
|
||||
w = (vid.width / vid.dupx)<<FRACBITS;
|
||||
|
||||
// The scroll offset MUST be clamped before shifting by FRACBITS, or else it'll overflow in about 3 minutes
|
||||
animtimer = ((((finalecount * scrollspeed) % (SHORT(pat->width)*16))<<FRACBITS) + (R_GetHudUncap() * scrollspeed))/16;
|
||||
anim2 = (SHORT(pat2->width)<<FRACBITS) - ((((finalecount * scrollspeed) % (SHORT(pat2->width)*16))<<FRACBITS) + (R_GetHudUncap() * scrollspeed))/16;
|
||||
animtimer = ((((finalecount * scrollspeed) % (SHORT(pat->width)*16))<<FRACBITS) + (R_GetMenuUncap() * scrollspeed))/16;
|
||||
anim2 = (SHORT(pat2->width)<<FRACBITS) - ((((finalecount * scrollspeed) % (SHORT(pat2->width)*16))<<FRACBITS) + (R_GetMenuUncap() * scrollspeed))/16;
|
||||
|
||||
// SRB2Kart: F_DrawPatchCol is over-engineered; recoded to be less shitty and error-prone
|
||||
if (rendermode != render_none)
|
||||
@@ -996,7 +996,7 @@ void F_TitleScreenDrawer(void)
|
||||
if (finalecount >= 20)
|
||||
V_DrawSmallScaledPatch(84, 87, 0, ttkart);
|
||||
else if (finalecount >= 10)
|
||||
V_DrawSciencePatch((84<<FRACBITS) - 18*(((20 - finalecount)<<FRACBITS) - R_GetHudUncap()), 87<<FRACBITS, 0, ttkart, FRACUNIT/2);
|
||||
V_DrawSciencePatch((84<<FRACBITS) - 18*(((20 - finalecount)<<FRACBITS) - R_GetMenuUncap()), 87<<FRACBITS, 0, ttkart, FRACUNIT/2);
|
||||
}
|
||||
else if (finalecount < 52)
|
||||
{
|
||||
@@ -1012,8 +1012,8 @@ void F_TitleScreenDrawer(void)
|
||||
|
||||
F_SkyScroll(titlescrollspeed);
|
||||
|
||||
V_DrawSciencePatch(0, -40*FixedDiv(((finalecount % 70)<<FRACBITS) + R_GetHudUncap(), 70<<FRACBITS), V_SNAPTOTOP|V_SNAPTOLEFT, ttcheckers, FRACUNIT);
|
||||
V_DrawSciencePatch(280<<FRACBITS, -(40<<FRACBITS) + 40*FixedDiv(((finalecount % 70)<<FRACBITS) + R_GetHudUncap(), 70<<FRACBITS), V_SNAPTOTOP|V_SNAPTORIGHT, ttcheckers, FRACUNIT);
|
||||
V_DrawSciencePatch(0, -40*FixedDiv(((finalecount % 70)<<FRACBITS) + R_GetMenuUncap(), 70<<FRACBITS), V_SNAPTOTOP|V_SNAPTOLEFT, ttcheckers, FRACUNIT);
|
||||
V_DrawSciencePatch(280<<FRACBITS, -(40<<FRACBITS) + 40*FixedDiv(((finalecount % 70)<<FRACBITS) + R_GetMenuUncap(), 70<<FRACBITS), V_SNAPTOTOP|V_SNAPTORIGHT, ttcheckers, FRACUNIT);
|
||||
|
||||
if (transval)
|
||||
V_DrawFadeScreen(120, 10 - transval);
|
||||
|
||||
+51
-46
@@ -1600,6 +1600,8 @@ void G_DoLoadLevel(boolean resetplayer)
|
||||
|
||||
// clear hud messages remains (usually from game startup)
|
||||
CON_ClearHUD();
|
||||
|
||||
G_ResetAllDeviceRumbles();
|
||||
}
|
||||
|
||||
static INT32 pausedelay = 0;
|
||||
@@ -1858,7 +1860,6 @@ boolean G_Responder(event_t *ev)
|
||||
|| ev->data1 == gamecontrol[gc_director][1])
|
||||
{
|
||||
K_ToggleDirector();
|
||||
directortoggletimer = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -1990,6 +1991,29 @@ INT32 G_CountPlayersPotentiallyViewable(boolean active)
|
||||
return total;
|
||||
}
|
||||
|
||||
//
|
||||
// G_FixCamera
|
||||
// Reset camera position, angle and interpolation on a view
|
||||
// after changing state.
|
||||
//
|
||||
static void G_FixCamera(UINT8 view)
|
||||
{
|
||||
player_t *player = &players[displayplayers[view - 1]];
|
||||
|
||||
// The order of displayplayers can change, which would
|
||||
// invalidate localangle.
|
||||
localangle[view - 1] = player->cmd.angleturn;
|
||||
|
||||
P_ResetCamera(player, &camera[view - 1]);
|
||||
|
||||
// Make sure the viewport doesn't interpolate at all into
|
||||
// its new position -- just snap instantly into place.
|
||||
|
||||
// Why does it need to be done twice?
|
||||
R_ResetViewInterpolation(view);
|
||||
R_ResetViewInterpolation(view);
|
||||
}
|
||||
|
||||
//
|
||||
// G_ResetView
|
||||
// Correct a viewpoint to playernum or the next available, wraps forward.
|
||||
@@ -2002,7 +2026,6 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
|
||||
UINT8 viewd;
|
||||
|
||||
INT32 *displayplayerp;
|
||||
camera_t *camerap;
|
||||
|
||||
INT32 olddisplayplayer;
|
||||
INT32 playersviewable;
|
||||
@@ -2039,30 +2062,20 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive)
|
||||
|
||||
/* Focus our target view first so that we don't take its player. */
|
||||
(*displayplayerp) = playernum;
|
||||
if ((*displayplayerp) != olddisplayplayer)
|
||||
{
|
||||
camerap = &camera[viewnum-1];
|
||||
P_ResetCamera(&players[(*displayplayerp)], camerap);
|
||||
|
||||
// Make sure the viewport doesn't interpolate at all into
|
||||
// its new position -- just snap instantly into place.
|
||||
R_ResetViewInterpolation(viewnum);
|
||||
}
|
||||
|
||||
/* If a viewpoint changes, reset the camera to clear uninitialized memory. */
|
||||
if (viewnum > splits)
|
||||
{
|
||||
for (viewd = splits+1; viewd < viewnum; ++viewd)
|
||||
for (viewd = splits+1; viewd <= viewnum; ++viewd)
|
||||
{
|
||||
displayplayerp = (&displayplayers[viewd-1]);
|
||||
camerap = &camera[viewd];
|
||||
|
||||
(*displayplayerp) = G_FindView(0, viewd, onlyactive, false);
|
||||
|
||||
P_ResetCamera(&players[(*displayplayerp)], camerap);
|
||||
|
||||
// Make sure the viewport doesn't interpolate at all into
|
||||
// its new position -- just snap instantly into place.
|
||||
R_ResetViewInterpolation(viewd);
|
||||
G_FixCamera(viewd);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((*displayplayerp) != olddisplayplayer)
|
||||
{
|
||||
G_FixCamera(viewnum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3032,6 +3045,8 @@ void G_AddPlayer(INT32 playernum)
|
||||
|
||||
void G_ExitLevel(void)
|
||||
{
|
||||
G_ResetAllDeviceRumbles();
|
||||
|
||||
if (gamestate == GS_LEVEL)
|
||||
{
|
||||
gameaction = ga_completed;
|
||||
@@ -4618,6 +4633,8 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep)
|
||||
{
|
||||
if (mapname[0] == '*') // current map
|
||||
return gamemap;
|
||||
else if (mapname[0] == '?')
|
||||
return G_RandMap(G_TOLFlag(gametype), prevmap, false, 0, false, NULL);
|
||||
else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map
|
||||
{
|
||||
newmapnum = mapheaderinfo[gamemap-1]->nextlevel;
|
||||
@@ -6369,8 +6386,18 @@ void G_BeginRecording(void)
|
||||
// Full replay title
|
||||
demo_p += 64;
|
||||
{
|
||||
char demotitlename[65];
|
||||
char *title = G_BuildMapTitle(gamemap);
|
||||
snprintf(demo.titlename, 64, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername);
|
||||
|
||||
// Print to a separate temp buffer instead of demo.titlename, so we can use it in M_TextInputSetString
|
||||
snprintf(demotitlename, 64, "%s - %s", title, modeattacking ? "Time Attack" : connectedservername);
|
||||
|
||||
// Init just in case it isn't initialized already
|
||||
M_TextInputInit(&demo.titlenameinput, demo.titlename, sizeof(demo.titlename));
|
||||
|
||||
// This will indirectly assign to demo.titlename too
|
||||
M_TextInputSetString(&demo.titlenameinput, demotitlename);
|
||||
|
||||
Z_Free(title);
|
||||
}
|
||||
|
||||
@@ -8360,7 +8387,6 @@ void G_SaveDemo(void)
|
||||
|
||||
boolean G_DemoTitleResponder(event_t *ev)
|
||||
{
|
||||
size_t len;
|
||||
INT32 ch;
|
||||
|
||||
if (ev->type != ev_keydown)
|
||||
@@ -8381,28 +8407,7 @@ boolean G_DemoTitleResponder(event_t *ev)
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && hu_font[ch-HU_FONTSTART])
|
||||
|| ch == ' ') // Allow spaces, of course
|
||||
{
|
||||
len = strlen(demo.titlename);
|
||||
if (len < 64)
|
||||
{
|
||||
demo.titlename[len+1] = 0;
|
||||
demo.titlename[len] = cv_keyboardlayout.value == 3 ? CON_ShitAndAltGrChar(ch) : CON_ShiftChar(ch);
|
||||
}
|
||||
}
|
||||
else if (ch == KEY_BACKSPACE)
|
||||
{
|
||||
if (shiftdown)
|
||||
memset(demo.titlename, 0, sizeof(demo.titlename));
|
||||
else
|
||||
{
|
||||
len = strlen(demo.titlename);
|
||||
|
||||
if (len > 0)
|
||||
demo.titlename[len-1] = 0;
|
||||
}
|
||||
}
|
||||
M_TextInputHandle(&demo.titlenameinput, ch);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "doomdef.h"
|
||||
#include "doomstat.h"
|
||||
#include "d_event.h"
|
||||
#include "m_textinput.h"
|
||||
|
||||
extern char gamedatafilename[64];
|
||||
extern char timeattackfolder[64];
|
||||
@@ -44,6 +45,7 @@ extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosiz
|
||||
// Publicly-accessible demo vars
|
||||
struct demovars_s {
|
||||
char titlename[65];
|
||||
textinput_t titlenameinput;
|
||||
boolean recording, playback, timing;
|
||||
UINT16 version; // Current file format of the demo being played
|
||||
boolean title; // Title Screen demo can be cancelled by any key
|
||||
|
||||
@@ -1013,6 +1013,21 @@ static void G_ResetPlayerDeviceRumble(INT32 player)
|
||||
I_GamepadRumble(device_id, 0, 0, 0);
|
||||
}
|
||||
|
||||
void G_ResetAllDeviceRumbles(void)
|
||||
{
|
||||
int i;
|
||||
int devices;
|
||||
|
||||
devices = I_NumJoys();
|
||||
|
||||
for (i = 0; i < devices; i++)
|
||||
{
|
||||
INT32 device_id = G_GetDeviceForPlayer(i);
|
||||
|
||||
I_GamepadRumble(device_id, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength, UINT32 duration)
|
||||
{
|
||||
INT32 device_id;
|
||||
|
||||
@@ -138,6 +138,7 @@ UINT16 G_GetSkinColor(INT32 player);
|
||||
INT32 G_GetDeviceForPlayer(INT32 player);
|
||||
void G_SetPlayerGamepadIndicatorColor(INT32 player, UINT16 color);
|
||||
void G_PlayerDeviceRumble(INT32 player, UINT16 low_strength, UINT16 high_strength, UINT32 duration);
|
||||
void G_ResetAllDeviceRumbles(void);
|
||||
|
||||
// remaps the input event to a game control.
|
||||
void G_MapEventsToControls(event_t *ev);
|
||||
|
||||
+65
-71
@@ -12,7 +12,6 @@
|
||||
/// \brief hardware renderer, using the standard HardWareRender driver DLL for SRB2
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h> // qsort
|
||||
|
||||
#include "../doomstat.h"
|
||||
|
||||
@@ -195,7 +194,7 @@ static void CV_grshaders_OnChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
HWR_SetShaderState();
|
||||
if ((cv_grpaletterendering.value))
|
||||
if (cv_grpaletterendering.value)
|
||||
{
|
||||
// can't do palette rendering without shaders, so update the state if needed
|
||||
HWR_TogglePaletteRendering();
|
||||
@@ -205,7 +204,6 @@ 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");
|
||||
|
||||
@@ -573,11 +571,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
|
||||
Surface->LightInfo.light_level = light_level;
|
||||
Surface->LightInfo.fade_start = (colormap != NULL) ? colormap->fadestart : 0;
|
||||
Surface->LightInfo.fade_end = (colormap != NULL) ? colormap->fadeend : 31;
|
||||
|
||||
if (HWR_ShouldUsePaletteRendering())
|
||||
Surface->LightTableId = HWR_GetLightTableID(colormap);
|
||||
else
|
||||
Surface->LightTableId = 0;
|
||||
Surface->LightTableId = HWR_ShouldUsePaletteRendering() ? HWR_GetLightTableID(colormap) : 0;
|
||||
}
|
||||
|
||||
UINT8 HWR_FogBlockAlpha(INT32 light, extracolormap_t *colormap) // Let's see if this can work
|
||||
@@ -846,7 +840,7 @@ void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isc
|
||||
{
|
||||
if (PolyFlags & PF_Fog)
|
||||
shader = SHADER_FOG;
|
||||
else if (PolyFlags & PF_Ripple)
|
||||
else if (cv_ripplewater.value && (PolyFlags & PF_Ripple))
|
||||
shader = SHADER_WATER;
|
||||
else
|
||||
shader = SHADER_FLOOR;
|
||||
@@ -3382,13 +3376,13 @@ static gr_vissprite_t gr_overflowsprite;
|
||||
|
||||
static gr_vissprite_t *HWR_GetVisSprite(UINT32 num)
|
||||
{
|
||||
UINT32 chunk = num >> VISSPRITECHUNKBITS;
|
||||
UINT32 chunk = num >> VISSPRITECHUNKBITS;
|
||||
|
||||
// Allocate chunk if necessary
|
||||
if (!gr_visspritechunks[chunk])
|
||||
Z_Malloc(sizeof(gr_vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &gr_visspritechunks[chunk]);
|
||||
// Allocate chunk if necessary
|
||||
if (!gr_visspritechunks[chunk])
|
||||
Z_Malloc(sizeof(gr_vissprite_t) * VISSPRITESPERCHUNK, PU_LEVEL, &gr_visspritechunks[chunk]);
|
||||
|
||||
return gr_visspritechunks[chunk] + (num & VISSPRITEINDEXMASK);
|
||||
return gr_visspritechunks[chunk] + (num & VISSPRITEINDEXMASK);
|
||||
}
|
||||
|
||||
static gr_vissprite_t *HWR_NewVisSprite(void)
|
||||
@@ -3764,15 +3758,13 @@ static void HWR_SplitSprite(gr_vissprite_t *spr)
|
||||
HWR_RotateSpritePolyToAim(spr, baseWallVerts, false);
|
||||
|
||||
// push it toward the camera to mitigate floor-clipping sprites
|
||||
float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->gzt - gr_viewz)*(spr->gzt - gr_viewz));
|
||||
float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->gzt - gr_viewz)*(spr->gzt - gr_viewz));
|
||||
float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
baseWallVerts[i].x += (gr_viewx - baseWallVerts[i].x)*distfact;
|
||||
baseWallVerts[i].z += (gr_viewy - baseWallVerts[i].z)*distfact;
|
||||
baseWallVerts[i].y += (gr_viewz - baseWallVerts[i].y)*distfact;
|
||||
}
|
||||
baseWallVerts[i].x += (gr_viewx - baseWallVerts[i].x)*distfact;
|
||||
baseWallVerts[i].z += (gr_viewy - baseWallVerts[i].z)*distfact;
|
||||
baseWallVerts[i].y += (gr_viewz - baseWallVerts[i].y)*distfact;
|
||||
}
|
||||
|
||||
realtop = top = baseWallVerts[3].y;
|
||||
@@ -3957,6 +3949,7 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
|
||||
FOutVector wallVerts[4];
|
||||
GLPatch_t *gpatch; // sprite patch converted to hardware
|
||||
FSurfaceInfo Surf;
|
||||
FBITFIELD blend = 0;
|
||||
|
||||
INT32 shader = SHADER_NONE;
|
||||
|
||||
@@ -4039,16 +4032,14 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
|
||||
HWR_RotateSpritePolyToAim(spr, wallVerts, false);
|
||||
|
||||
// push it toward the camera to mitigate floor-clipping sprites
|
||||
float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->gzt - gr_viewz)*(spr->gzt - gr_viewz));
|
||||
float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist;
|
||||
size_t i;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
float sprdist = sqrtf((spr->x1 - gr_viewx)*(spr->x1 - gr_viewx) + (spr->z1 - gr_viewy)*(spr->z1 - gr_viewy) + (spr->gzt - gr_viewz)*(spr->gzt - gr_viewz));
|
||||
float distfact = ((2.0f*spr->dispoffset) + 20.0f) / sprdist;
|
||||
size_t i;
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
wallVerts[i].x += (gr_viewx - wallVerts[i].x)*distfact;
|
||||
wallVerts[i].z += (gr_viewy - wallVerts[i].z)*distfact;
|
||||
wallVerts[i].y += (gr_viewz - wallVerts[i].y)*distfact;
|
||||
}
|
||||
wallVerts[i].x += (gr_viewx - wallVerts[i].x)*distfact;
|
||||
wallVerts[i].z += (gr_viewy - wallVerts[i].z)*distfact;
|
||||
wallVerts[i].y += (gr_viewz - wallVerts[i].y)*distfact;
|
||||
}
|
||||
|
||||
// This needs to be AFTER the shadows so that the regular sprites aren't drawn completely black.
|
||||
@@ -4065,38 +4056,35 @@ static void HWR_DrawSprite(gr_vissprite_t *spr)
|
||||
|
||||
HWR_Lighting(&Surf, lightlevel, colormap);
|
||||
|
||||
if (!cv_translucency.value) // translucency disabled
|
||||
{
|
||||
FBITFIELD blend = 0;
|
||||
if (!cv_translucency.value) // translucency disabled
|
||||
{
|
||||
Surf.PolyColor.s.alpha = 0xFF;
|
||||
blend = PF_Translucent|PF_Occlude;
|
||||
}
|
||||
else if (spr->mobj->flags2 & MF2_SHADOW)
|
||||
{
|
||||
Surf.PolyColor.s.alpha = 0x40;
|
||||
blend = PF_Translucent;
|
||||
}
|
||||
else if (spr->mobj->frame & FF_TRANSMASK)
|
||||
blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf);
|
||||
else
|
||||
{
|
||||
// BP: i agree that is little better in environement but it don't
|
||||
// work properly under glide nor with fogcolor to ffffff :(
|
||||
// Hurdler: PF_Environement would be cool, but we need to fix
|
||||
// the issue with the fog before
|
||||
Surf.PolyColor.s.alpha = 0xFF;
|
||||
blend = PF_Translucent|PF_Occlude;
|
||||
}
|
||||
|
||||
if (HWR_UseShader())
|
||||
{
|
||||
shader = SHADER_SPRITE;
|
||||
blend |= PF_ColorMapped;
|
||||
}
|
||||
|
||||
HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false);
|
||||
Surf.PolyColor.s.alpha = 0xFF;
|
||||
blend = PF_Translucent|PF_Occlude;
|
||||
}
|
||||
else if (spr->mobj->flags2 & MF2_SHADOW)
|
||||
{
|
||||
Surf.PolyColor.s.alpha = 0x40;
|
||||
blend = PF_Translucent;
|
||||
}
|
||||
else if (spr->mobj->frame & FF_TRANSMASK)
|
||||
blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf);
|
||||
else
|
||||
{
|
||||
// BP: i agree that is little better in environement but it don't
|
||||
// work properly under glide nor with fogcolor to ffffff :(
|
||||
// Hurdler: PF_Environement would be cool, but we need to fix
|
||||
// the issue with the fog before
|
||||
Surf.PolyColor.s.alpha = 0xFF;
|
||||
blend = PF_Translucent|PF_Occlude;
|
||||
}
|
||||
|
||||
if (HWR_UseShader())
|
||||
{
|
||||
shader = SHADER_SPRITE;
|
||||
blend |= PF_ColorMapped;
|
||||
}
|
||||
|
||||
HWR_ProcessPolygon(&Surf, wallVerts, 4, blend|PF_Modulated, shader, false);
|
||||
}
|
||||
|
||||
// Sprite drawer for precipitation
|
||||
@@ -4238,7 +4226,7 @@ static void HWR_SortVisSprites(void)
|
||||
gr_vsprorder[i] = HWR_GetVisSprite(i);
|
||||
}
|
||||
|
||||
qsort(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites);
|
||||
qs22j(gr_vsprorder, gr_visspritecount, sizeof(gr_vissprite_t*), CompareVisSprites);
|
||||
}
|
||||
|
||||
// A drawnode is something that points to a 3D floor, 3D side, or masked
|
||||
@@ -4467,8 +4455,9 @@ static void HWR_RenderDrawNodes(void)
|
||||
|
||||
if (!(plane->blend & PF_NoTexture))
|
||||
HWR_GetFlat(plane->lumpnum, R_NoEncore(plane->FOFSector, plane->isceiling));
|
||||
|
||||
HWR_RenderPlane(NULL, plane->xsub, plane->isceiling, plane->fixedheight, plane->blend, plane->lightlevel,
|
||||
plane->lumpnum, plane->FOFSector, plane->alpha, plane->planecolormap);
|
||||
plane->lumpnum, plane->FOFSector, plane->alpha, plane->planecolormap);
|
||||
}
|
||||
else if (drawnode->type == DRAWNODE_POLYOBJECT_PLANE)
|
||||
{
|
||||
@@ -4479,8 +4468,9 @@ static void HWR_RenderDrawNodes(void)
|
||||
|
||||
if (!(polyplane->blend & PF_NoTexture))
|
||||
HWR_GetFlat(polyplane->lumpnum, R_NoEncore(polyplane->FOFSector, polyplane->isceiling));
|
||||
|
||||
HWR_RenderPolyObjectPlane(polyplane->polysector, polyplane->isceiling, polyplane->fixedheight, polyplane->blend, polyplane->lightlevel,
|
||||
polyplane->lumpnum, polyplane->FOFSector, polyplane->alpha, polyplane->planecolormap);
|
||||
polyplane->lumpnum, polyplane->FOFSector, polyplane->alpha, polyplane->planecolormap);
|
||||
}
|
||||
else if (drawnode->type == DRAWNODE_WALL)
|
||||
{
|
||||
@@ -4488,8 +4478,9 @@ static void HWR_RenderDrawNodes(void)
|
||||
|
||||
if (!(wall->blend & PF_NoTexture))
|
||||
HWR_GetTexture(wall->texnum, wall->noencore);
|
||||
|
||||
HWR_RenderWall(wall->wallVerts, &wall->Surf, wall->blend, wall->fogwall,
|
||||
wall->lightlevel, wall->wallcolormap);
|
||||
wall->lightlevel, wall->wallcolormap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4610,7 +4601,7 @@ static void HWR_AddPrecipitationSprites(void)
|
||||
drawdist = (fixed_t)(cv_drawdist_precip.value) * precipscale;
|
||||
|
||||
// No to infinite precipitation draw distance.
|
||||
if (drawdist == 0)
|
||||
if (drawdist == 0 || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -4799,8 +4790,8 @@ void HWR_ProjectSprite(mobj_t *thing)
|
||||
flip ^= (1<<rot);
|
||||
}
|
||||
|
||||
if (thing->skin && ((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->flags & SF_HIRES)
|
||||
this_scale *= FIXED_TO_FLOAT(((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->highresscale);
|
||||
if (thing->skin && ((skin_t *)(thing->localskin ? thing->localskin : thing->skin))->flags & SF_HIRES)
|
||||
this_scale *= FIXED_TO_FLOAT(((skin_t *)(thing->localskin ? thing->localskin : thing->skin))->highresscale);
|
||||
|
||||
spr_width = spritecachedinfo[lumpoff].width;
|
||||
spr_height = spritecachedinfo[lumpoff].height;
|
||||
@@ -4921,6 +4912,7 @@ void HWR_ProjectSprite(mobj_t *thing)
|
||||
FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) :
|
||||
gzt < FIXED_TO_FLOAT(sectors[heightsec].floorheight))
|
||||
return;
|
||||
|
||||
if (gr_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ?
|
||||
gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gr_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) :
|
||||
FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight))
|
||||
@@ -5377,9 +5369,10 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe
|
||||
gl_portallist_t portallist;
|
||||
gl_portal_t *portal;
|
||||
gl_portal_t *gl_portal_temp;
|
||||
portallist.base = portallist.cap = NULL;
|
||||
const boolean skybox = (skyboxmo[0] && cv_skybox.value);
|
||||
boolean useportals = gr_maphasportals && cv_grportals.value && allow_portals;
|
||||
const boolean useportals = cv_grportals.value && gr_maphasportals && allow_portals;
|
||||
|
||||
portallist.base = portallist.cap = NULL;
|
||||
|
||||
if (useportals && stencil_level < cv_maxportals.value) // if recursion limit is not reached
|
||||
{
|
||||
@@ -5388,6 +5381,7 @@ static void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, playe
|
||||
gr_portal = GRPORTAL_SEARCH;
|
||||
|
||||
HWR_ClearClipper();
|
||||
|
||||
if (!rootportal)
|
||||
portalclipline = NULL;
|
||||
else
|
||||
@@ -5845,7 +5839,7 @@ void HWR_DoPostProcessor(player_t *player)
|
||||
|
||||
// Armageddon Blast Flash!
|
||||
// Could this even be considered postprocessor?
|
||||
if ((player->flashcount) && (!HWR_PalRenderFlashpal()))
|
||||
if (!HWR_PalRenderFlashpal() && player->flashcount)
|
||||
{
|
||||
FOutVector v[4];
|
||||
FSurfaceInfo Surf;
|
||||
|
||||
+146
-257
@@ -49,6 +49,8 @@
|
||||
#include "s_sound.h" // song credits
|
||||
#include "k_kart.h"
|
||||
|
||||
#include "m_textinput.h"
|
||||
|
||||
#ifdef HWRENDER
|
||||
#include "hardware/hw_main.h"
|
||||
#endif
|
||||
@@ -86,8 +88,8 @@ patch_t *frameslash; // framerate stuff. Used in screen.c
|
||||
|
||||
static player_t *plr;
|
||||
boolean chat_on; // entering a chat message?
|
||||
static char w_chat[HU_MAXMSGLEN + 1];
|
||||
static size_t c_input = 0; // let's try to make the chat input less shitty.
|
||||
static char w_chat_buf[HU_MAXMSGLEN + 1];
|
||||
static textinput_t w_chat;
|
||||
static boolean headsupactive = false;
|
||||
boolean hu_showscores; // draw rankings
|
||||
static char hu_tick;
|
||||
@@ -1143,71 +1145,6 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
|
||||
#endif
|
||||
}
|
||||
|
||||
// Handles key input and string input
|
||||
//
|
||||
static inline boolean HU_keyInChatString(char *s, char ch)
|
||||
{
|
||||
size_t l;
|
||||
|
||||
if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && hu_font[ch-HU_FONTSTART])
|
||||
|| ch == ' ') // Allow spaces, of course
|
||||
{
|
||||
l = strlen(s);
|
||||
if (l < HU_MAXMSGLEN - 1)
|
||||
{
|
||||
if (c_input >= strlen(s)) // don't do anything complicated
|
||||
{
|
||||
s[l++] = ch;
|
||||
s[l]=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// move everything past c_input for new characters:
|
||||
size_t m = HU_MAXMSGLEN-1;
|
||||
while (m>=c_input)
|
||||
{
|
||||
if (s[m])
|
||||
s[m+1] = (s[m]);
|
||||
if (m == 0) // prevent overflow
|
||||
break;
|
||||
m--;
|
||||
}
|
||||
s[c_input] = ch; // and replace this.
|
||||
}
|
||||
c_input++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if (ch == KEY_BACKSPACE)
|
||||
{
|
||||
size_t i = c_input;
|
||||
|
||||
if (c_input <= 0)
|
||||
return false;
|
||||
|
||||
if (!s[i-1])
|
||||
return false;
|
||||
|
||||
if (i >= strlen(s)-1)
|
||||
{
|
||||
s[strlen(s)-1] = 0;
|
||||
c_input--;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (; (i < HU_MAXMSGLEN); i++)
|
||||
{
|
||||
s[i-1] = s[i];
|
||||
}
|
||||
c_input--;
|
||||
}
|
||||
else if (ch != KEY_ENTER)
|
||||
return false; // did not eat key
|
||||
|
||||
return true; // ate the key
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -1280,9 +1217,9 @@ static boolean HU_clearChatSpaces(void)
|
||||
char c; // current character we're iterating.
|
||||
boolean nothingbutspaces = true;
|
||||
|
||||
for (; i < strlen(w_chat); i++) // iterate through message and eradicate all spaces that don't belong.
|
||||
for (; i < strlen(w_chat_buf); i++) // iterate through message and eradicate all spaces that don't belong.
|
||||
{
|
||||
c = w_chat[i];
|
||||
c = w_chat_buf[i];
|
||||
if (!c)
|
||||
break; // if there's nothing, it's safe to assume our message has ended, so let's not waste any more time here.
|
||||
|
||||
@@ -1294,128 +1231,110 @@ static boolean HU_clearChatSpaces(void)
|
||||
return nothingbutspaces;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
static void HU_queueChatChar(INT32 c)
|
||||
static void HU_SendChatMessage(void)
|
||||
{
|
||||
// send automaticly the message (no more chat char)
|
||||
if (c == KEY_ENTER)
|
||||
char buf[2 + HU_MAXMSGLEN + 1];
|
||||
char *msg = &buf[2];
|
||||
size_t ci = 2;
|
||||
INT32 target = 0;
|
||||
char c;
|
||||
|
||||
if (HU_clearChatSpaces()) // Avoids being able to send empty messages, or something.
|
||||
return; // If this returns true, that means our message was NOTHING but spaces, so don't send it period.
|
||||
|
||||
do {
|
||||
c = w_chat_buf[-2+ci++];
|
||||
if (!c || (c >= ' ' && !(c & 0x80))) // copy printable characters and terminating '\0' only.
|
||||
buf[ci-1]=c;
|
||||
} while (c);
|
||||
|
||||
M_TextInputClear(&w_chat);
|
||||
|
||||
// last minute mute check
|
||||
if (CHAT_MUTE)
|
||||
{
|
||||
char buf[2 + HU_MAXMSGLEN + 1];
|
||||
char *msg = &buf[2];
|
||||
size_t i;
|
||||
size_t ci = 2;
|
||||
INT32 target = 0;
|
||||
HU_AddChatText(va("%s>ERROR: The chat is muted. You can't say anything.", "\x85"), false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (HU_clearChatSpaces()) // Avoids being able to send empty messages, or something.
|
||||
return; // If this returns true, that means our message was NOTHING but spaces, so don't send it period.
|
||||
if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
|
||||
{
|
||||
INT32 spc = 1; // used if nodenum[1] is a space.
|
||||
char *nodenum = (char*) malloc(3);
|
||||
const char *newmsg;
|
||||
|
||||
do {
|
||||
c = w_chat[-2+ci++];
|
||||
if (!c || (c >= ' ' && !(c & 0x80))) // copy printable characters and terminating '\0' only.
|
||||
buf[ci-1]=c;
|
||||
} while (c);
|
||||
i = 0;
|
||||
for (;(i<HU_MAXMSGLEN);i++)
|
||||
w_chat[i] = 0; // reset this.
|
||||
// what we're gonna do now is check if the node exists
|
||||
// with that logic, characters 4 and 5 are our numbers:
|
||||
|
||||
c_input = 0;
|
||||
|
||||
for (;(i<HU_MAXMSGLEN);i++)
|
||||
w_chat[i] = 0; // reset this.
|
||||
|
||||
c_input = 0;
|
||||
|
||||
// last minute mute check
|
||||
if (CHAT_MUTE)
|
||||
// teamtalk can't send PMs, just don't send it, else everyone would be able to see it, and no one wants to see your sex RP sicko.
|
||||
if (teamtalk)
|
||||
{
|
||||
HU_AddChatText(va("%s>ERROR: The chat is muted. You can't say anything.", "\x85"), false);
|
||||
HU_AddChatText(va("%sCannot send sayto in Say-Team.", "\x85"), false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
|
||||
memcpy(nodenum, msg+3, 2);
|
||||
nodenum[2] = '\0';
|
||||
|
||||
// check for undesirable characters in our "number"
|
||||
if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9')))
|
||||
{
|
||||
INT32 spc = 1; // used if nodenum[1] is a space.
|
||||
char *nodenum = (char*) malloc(3);
|
||||
const char *newmsg;
|
||||
|
||||
// what we're gonna do now is check if the node exists
|
||||
// with that logic, characters 4 and 5 are our numbers:
|
||||
|
||||
// teamtalk can't send PMs, just don't send it, else everyone would be able to see it, and no one wants to see your sex RP sicko.
|
||||
if (teamtalk)
|
||||
{
|
||||
HU_AddChatText(va("%sCannot send sayto in Say-Team.", "\x85"), false);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(nodenum, msg+3, 2);
|
||||
nodenum[2] = '\0';
|
||||
|
||||
// check for undesirable characters in our "number"
|
||||
if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9')))
|
||||
{
|
||||
// check if nodenum[1] is a space
|
||||
if (nodenum[1] == ' ')
|
||||
spc = 0;
|
||||
// let it slide
|
||||
else
|
||||
{
|
||||
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<node> \'.", false);
|
||||
free(nodenum);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// I'm very bad at C, I swear I am, additional checks eww!
|
||||
if (spc != 0)
|
||||
{
|
||||
if (msg[5] != ' ')
|
||||
{
|
||||
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<node> \'.", false);
|
||||
free(nodenum);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
target = atoi((const char*) nodenum); // turn that into a number
|
||||
free(nodenum);
|
||||
//CONS_Printf("%d\n", target);
|
||||
|
||||
// check for target player, if it doesn't exist then we can't send the message!
|
||||
if (target < MAXPLAYERS && playeringame[target]) // player exists
|
||||
target++; // even though playernums are from 0 to 31, target is 1 to 32, so up that by 1 to have it work!
|
||||
// check if nodenum[1] is a space
|
||||
if (nodenum[1] == ' ')
|
||||
spc = 0;
|
||||
// let it slide
|
||||
else
|
||||
{
|
||||
HU_AddChatText(va("\x82NOTICE: \x80Player %d does not exist.", target), false); // same
|
||||
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<node> \'.", false);
|
||||
free(nodenum);
|
||||
return;
|
||||
}
|
||||
|
||||
// we need to get rid of the /pm<node>
|
||||
newmsg = msg+5+spc;
|
||||
strlcpy(msg, newmsg, HU_MAXMSGLEN + 1);
|
||||
}
|
||||
if (ci > 3) // don't send target+flags+empty message.
|
||||
// I'm very bad at C, I swear I am, additional checks eww!
|
||||
if (spc != 0)
|
||||
{
|
||||
if (teamtalk)
|
||||
buf[0] = -1; // target
|
||||
else
|
||||
buf[0] = target;
|
||||
|
||||
buf[1] = 0; // flags
|
||||
SendNetXCmd(XD_SAY, buf, 2 + strlen(&buf[2]) + 1);
|
||||
if (msg[5] != ' ')
|
||||
{
|
||||
HU_AddChatText("\x82NOTICE: \x80Invalid command format. Correct format is \'/pm<node> \'.", false);
|
||||
free(nodenum);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
target = atoi((const char*) nodenum); // turn that into a number
|
||||
free(nodenum);
|
||||
//CONS_Printf("%d\n", target);
|
||||
|
||||
// check for target player, if it doesn't exist then we can't send the message!
|
||||
if (target < MAXPLAYERS && playeringame[target]) // player exists
|
||||
target++; // even though playernums are from 0 to 31, target is 1 to 32, so up that by 1 to have it work!
|
||||
else
|
||||
{
|
||||
HU_AddChatText(va("\x82NOTICE: \x80Player %d does not exist.", target), false); // same
|
||||
return;
|
||||
}
|
||||
|
||||
// we need to get rid of the /pm<node>
|
||||
newmsg = msg+5+spc;
|
||||
strlcpy(msg, newmsg, HU_MAXMSGLEN + 1);
|
||||
}
|
||||
if (ci > 3) // don't send target+flags+empty message.
|
||||
{
|
||||
if (teamtalk)
|
||||
buf[0] = -1; // target
|
||||
else
|
||||
buf[0] = target;
|
||||
|
||||
buf[1] = 0; // flags
|
||||
SendNetXCmd(XD_SAY, buf, 2 + strlen(&buf[2]) + 1);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void HU_clearChatChars(void)
|
||||
{
|
||||
size_t i = 0;
|
||||
for (;i<HU_MAXMSGLEN;i++)
|
||||
w_chat[i] = 0; // reset this.
|
||||
M_TextInputClear(&w_chat);
|
||||
chat_on = false;
|
||||
c_input = 0;
|
||||
}
|
||||
|
||||
#ifndef NONET
|
||||
@@ -1463,7 +1382,8 @@ boolean HU_Responder(event_t *ev)
|
||||
&& netgame && !OLD_MUTE) // check for old chat mute, still let the players open the chat incase they want to scroll otherwise.
|
||||
{
|
||||
chat_on = true;
|
||||
w_chat[0] = 0;
|
||||
w_chat_buf[0] = 0;
|
||||
M_TextInputInit(&w_chat, w_chat_buf, sizeof w_chat_buf);
|
||||
teamtalk = false;
|
||||
chat_scrollmedown = true;
|
||||
typelines = 1;
|
||||
@@ -1473,7 +1393,8 @@ boolean HU_Responder(event_t *ev)
|
||||
&& netgame && !OLD_MUTE)
|
||||
{
|
||||
chat_on = true;
|
||||
w_chat[0] = 0;
|
||||
w_chat_buf[0] = 0;
|
||||
M_TextInputInit(&w_chat, w_chat_buf, sizeof w_chat_buf);
|
||||
teamtalk = G_GametypeHasTeams(); // Don't teamtalk if we don't have teams.
|
||||
chat_scrollmedown = true;
|
||||
typelines = 1;
|
||||
@@ -1498,62 +1419,13 @@ boolean HU_Responder(event_t *ev)
|
||||
&& ev->data1 != gamecontrol[gc_talkkey][1]))
|
||||
return false;
|
||||
|
||||
c = cv_keyboardlayout.value == 3 ? CON_ShitAndAltGrChar(c) : CON_ShiftChar(c);
|
||||
M_TextInputHandle(&w_chat, c);
|
||||
|
||||
// pasting. pasting is cool. chat is a bit limited, though :(
|
||||
if (((c == 'v' || c == 'V') && ctrldown) && !CHAT_MUTE)
|
||||
{
|
||||
const char *paste = I_ClipboardPaste();
|
||||
size_t chatlen;
|
||||
size_t pastelen;
|
||||
|
||||
// create a dummy string real quickly
|
||||
|
||||
if (paste == NULL)
|
||||
return true;
|
||||
|
||||
chatlen = strlen(w_chat);
|
||||
pastelen = strlen(paste);
|
||||
if (chatlen+pastelen > HU_MAXMSGLEN)
|
||||
return true; // we can't paste this!!
|
||||
|
||||
if (c_input >= strlen(w_chat)) // add it at the end of the string.
|
||||
{
|
||||
memcpy(&w_chat[chatlen], paste, pastelen); // copy all of that.
|
||||
c_input += pastelen;
|
||||
/*size_t i = 0;
|
||||
for (;i<pastelen;i++)
|
||||
{
|
||||
HU_queueChatChar(paste[i]); // queue it so that it's actually sent. (this chat write thing is REALLY messy.)
|
||||
}*/
|
||||
return true;
|
||||
}
|
||||
else // otherwise, we need to shift everything and make space, etc etc
|
||||
{
|
||||
size_t i = HU_MAXMSGLEN-1;
|
||||
while (i >= c_input)
|
||||
{
|
||||
if (w_chat[i])
|
||||
w_chat[i+pastelen] = w_chat[i];
|
||||
if (i == 0) // prevent overflow
|
||||
break;
|
||||
i--;
|
||||
}
|
||||
memcpy(&w_chat[c_input], paste, pastelen); // copy all of that.
|
||||
c_input += pastelen;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!CHAT_MUTE && HU_keyInChatString(w_chat,c))
|
||||
{
|
||||
HU_queueChatChar(c);
|
||||
}
|
||||
if (c == KEY_ENTER)
|
||||
{
|
||||
chat_on = false;
|
||||
c_input = 0; // reset input cursor
|
||||
chat_scrollmedown = true; // you hit enter, so you might wanna autoscroll to see what you just sent. :)
|
||||
HU_SendChatMessage();
|
||||
}
|
||||
else if (c == KEY_ESCAPE
|
||||
|| ((c == gamecontrol[gc_talkkey][0] || c == gamecontrol[gc_talkkey][1]
|
||||
@@ -1561,7 +1433,6 @@ boolean HU_Responder(event_t *ev)
|
||||
&& c >= KEY_MOUSE1)) // If it's not a keyboard key, then the chat button is used as a toggle.
|
||||
{
|
||||
chat_on = false;
|
||||
c_input = 0; // reset input cursor
|
||||
}
|
||||
else if ((c == KEY_UPARROW || c == KEY_MOUSEWHEELUP) && chat_scroll > 0 && !OLDCHAT) // CHAT SCROLLING YAYS!
|
||||
{
|
||||
@@ -1575,10 +1446,6 @@ boolean HU_Responder(event_t *ev)
|
||||
justscrolleddown = true;
|
||||
chat_scrolltime = 4;
|
||||
}
|
||||
else if (c == KEY_LEFTARROW && c_input != 0 && !OLDCHAT) // i said go back
|
||||
c_input--;
|
||||
else if (c == KEY_RIGHTARROW && c_input < strlen(w_chat) && !OLDCHAT) // don't need to check for admin or w/e here since the chat won't ever contain anything if it's muted.
|
||||
c_input++;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
@@ -1932,8 +1799,9 @@ static void HU_DrawChat(void)
|
||||
INT32 charwidth = 4, charheight = 6;
|
||||
INT32 boxw = cv_chatwidth.value;
|
||||
INT32 t = 0, c = 0, y = chaty - (typelines*charheight);
|
||||
UINT32 i = 0, saylen = strlen(w_chat); // You learn new things everyday!
|
||||
UINT32 i = 0, saylen = strlen(w_chat_buf); // You learn new things everyday!
|
||||
INT32 cflag = 0;
|
||||
size_t select_start = 0, select_end = 0;
|
||||
const char *ntalk = "Say: ", *ttalk = "Team: ";
|
||||
const char *talk = ntalk;
|
||||
const char *mute = "Chat has been muted.";
|
||||
@@ -1995,13 +1863,19 @@ static void HU_DrawChat(void)
|
||||
i = 0;
|
||||
typelines = 1;
|
||||
|
||||
if ((strlen(w_chat) == 0 || c_input == 0) && hu_tick < 4)
|
||||
V_DrawChatCharacter(chatx + 2 + c, y+1, '_' |V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, !cv_allcaps.value, NULL);
|
||||
if ((w_chat.cursor == 0 || w_chat.length == 0) && hu_tick < 4)
|
||||
V_DrawChatCharacter(chatx+2+c+charwidth*w_chat.cursor, y+1, '_'|V_SNAPTOBOTTOM|V_SNAPTOLEFT|t, !cv_allcaps.value, NULL);
|
||||
|
||||
while (w_chat[i])
|
||||
if (w_chat.select != w_chat.cursor)
|
||||
{
|
||||
select_start = min(w_chat.select, w_chat.cursor);
|
||||
select_end = max(w_chat.select, w_chat.cursor);
|
||||
}
|
||||
|
||||
while (w_chat_buf[i])
|
||||
{
|
||||
boolean skippedline = false;
|
||||
if (c_input == (i+1))
|
||||
if (w_chat.cursor == (i+1))
|
||||
{
|
||||
INT32 cursorx = (c+charwidth < boxw-charwidth) ? (chatx + 2 + c+charwidth) : (chatx+1); // we may have to go down.
|
||||
INT32 cursory = (cursorx != chatx+1) ? (y) : (y+charheight);
|
||||
@@ -2016,10 +1890,14 @@ static void HU_DrawChat(void)
|
||||
}
|
||||
|
||||
//Hurdler: isn't it better like that?
|
||||
if (w_chat[i] < HU_FONTSTART)
|
||||
++i;
|
||||
else
|
||||
V_DrawChatCharacter(chatx + c + 2, y, w_chat[i++] | V_SNAPTOBOTTOM|V_SNAPTOLEFT | t, !cv_allcaps.value, NULL);
|
||||
if (w_chat_buf[i] >= HU_FONTSTART)
|
||||
V_DrawChatCharacter(chatx + c + 2, y, w_chat_buf[i] | V_SNAPTOBOTTOM|V_SNAPTOLEFT | t, !cv_allcaps.value, NULL);
|
||||
|
||||
// Draw selection
|
||||
if (i >= select_start && i < select_end)
|
||||
V_DrawFill(chatx + c + 2, y-1, charwidth, charheight, 103|V_TRANSLUCENT|V_SNAPTOBOTTOM|V_SNAPTOLEFT|t);
|
||||
|
||||
++i;
|
||||
|
||||
c += charwidth;
|
||||
if (c > boxw-(charwidth*2) && !skippedline)
|
||||
@@ -2031,7 +1909,7 @@ static void HU_DrawChat(void)
|
||||
}
|
||||
|
||||
// handle /pm list. It's messy, horrible and I don't care.
|
||||
if (strnicmp(w_chat, "/pm", 3) == 0 && vid.width >= 400 && !teamtalk) // 320x200 unsupported kthxbai
|
||||
if (strnicmp(w_chat_buf, "/pm", 3) == 0 && vid.width >= 400 && !teamtalk) // 320x200 unsupported kthxbai
|
||||
{
|
||||
INT32 count = 0;
|
||||
INT32 p_dispy = chaty - charheight -1;
|
||||
@@ -2051,38 +1929,38 @@ static void HU_DrawChat(void)
|
||||
{
|
||||
|
||||
// filter: (code needs optimization pls help I'm bad with C)
|
||||
if (w_chat[3])
|
||||
if (w_chat_buf[3])
|
||||
{
|
||||
char *nodenum;
|
||||
UINT32 n;
|
||||
// right, that's half important: (w_chat[4] may be a space since /pm0 msg is perfectly acceptable!)
|
||||
if ( ( ((w_chat[3] != 0) && ((w_chat[3] < '0') || (w_chat[3] > '9'))) || ((w_chat[4] != 0) && (((w_chat[4] < '0') || (w_chat[4] > '9'))))) && (w_chat[4] != ' '))
|
||||
// right, that's half important: (w_chat_buf[4] may be a space since /pm0 msg is perfectly acceptable!)
|
||||
if ( ( ((w_chat_buf[3] != 0) && ((w_chat_buf[3] < '0') || (w_chat_buf[3] > '9'))) || ((w_chat_buf[4] != 0) && (((w_chat_buf[4] < '0') || (w_chat_buf[4] > '9'))))) && (w_chat_buf[4] != ' '))
|
||||
break;
|
||||
|
||||
|
||||
nodenum = (char*) malloc(3);
|
||||
memcpy(nodenum, w_chat+3, 2);
|
||||
memcpy(nodenum, w_chat_buf+3, 2);
|
||||
nodenum[2] = '\0';
|
||||
n = atoi((const char*) nodenum); // turn that into a number
|
||||
free(nodenum);
|
||||
// special cases:
|
||||
|
||||
if ((n == 0) && !(w_chat[4] == '0'))
|
||||
if ((n == 0) && !(w_chat_buf[4] == '0'))
|
||||
{
|
||||
if (!(i<10))
|
||||
continue;
|
||||
}
|
||||
else if ((n == 1) && !(w_chat[3] == '0'))
|
||||
else if ((n == 1) && !(w_chat_buf[3] == '0'))
|
||||
{
|
||||
if (!((i == 1) || ((i >= 10) && (i <= 19))))
|
||||
continue;
|
||||
}
|
||||
else if ((n == 2) && !(w_chat[3] == '0'))
|
||||
else if ((n == 2) && !(w_chat_buf[3] == '0'))
|
||||
{
|
||||
if (!((i == 2) || ((i >= 20) && (i <= 29))))
|
||||
continue;
|
||||
}
|
||||
else if ((n == 3) && !(w_chat[3] == '0'))
|
||||
else if ((n == 3) && !(w_chat_buf[3] == '0'))
|
||||
{
|
||||
if (!((i == 3) || ((i >= 30) && (i <= 31))))
|
||||
continue;
|
||||
@@ -2121,6 +1999,7 @@ static void HU_DrawChat_Old(void)
|
||||
size_t i = 0;
|
||||
const char *ntalk = "Say: ", *ttalk = "Say-Team: ";
|
||||
const char *talk = ntalk;
|
||||
size_t select_start = 0, select_end = 0;
|
||||
INT32 charwidth = 8 * con_scalefactor; //SHORT(hu_font['A'-HU_FONTSTART]->width) * con_scalefactor;
|
||||
INT32 charheight = 8 * con_scalefactor; //SHORT(hu_font['A'-HU_FONTSTART]->height) * con_scalefactor;
|
||||
if (teamtalk)
|
||||
@@ -2149,14 +2028,19 @@ static void HU_DrawChat_Old(void)
|
||||
c += charwidth;
|
||||
}
|
||||
|
||||
if ((strlen(w_chat) == 0 || c_input == 0) && hu_tick < 4)
|
||||
V_DrawCharacter(HU_INPUTX+c, y+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value);
|
||||
if ((w_chat.cursor == 0 || w_chat.length == 0) && hu_tick < 4)
|
||||
V_DrawCharacter(HU_INPUTX+c+charwidth*w_chat.cursor, y+2*con_scalefactor, '_'|cv_constextsize.value|V_NOSCALESTART|t, !cv_allcaps.value);
|
||||
|
||||
if (w_chat.select != w_chat.cursor)
|
||||
{
|
||||
select_start = min(w_chat.select, w_chat.cursor);
|
||||
select_end = max(w_chat.select, w_chat.cursor);
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (w_chat[i])
|
||||
while (w_chat_buf[i])
|
||||
{
|
||||
|
||||
if (c_input == (i+1) && hu_tick < 4)
|
||||
if (w_chat.cursor == (i+1) && hu_tick < 4)
|
||||
{
|
||||
INT32 cursorx = (HU_INPUTX+c+charwidth < vid.width) ? (HU_INPUTX + c + charwidth) : (HU_INPUTX); // we may have to go down.
|
||||
INT32 cursory = (cursorx != HU_INPUTX) ? (y) : (y+charheight);
|
||||
@@ -2164,17 +2048,18 @@ static void HU_DrawChat_Old(void)
|
||||
}
|
||||
|
||||
//Hurdler: isn't it better like that?
|
||||
if (w_chat[i] < HU_FONTSTART)
|
||||
{
|
||||
++i;
|
||||
//charwidth = 4 * con_scalefactor;
|
||||
}
|
||||
else
|
||||
if (w_chat_buf[i] >= HU_FONTSTART)
|
||||
{
|
||||
//charwidth = SHORT(hu_font[w_chat[i]-HU_FONTSTART]->width) * con_scalefactor;
|
||||
V_DrawCharacter(HU_INPUTX + c, y, w_chat[i++] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value);
|
||||
V_DrawCharacter(HU_INPUTX + c, y, w_chat_buf[i] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value);
|
||||
}
|
||||
|
||||
// Draw selection
|
||||
if (i >= select_start && i < select_end)
|
||||
V_DrawFill(HU_INPUTX + c, y, charwidth, charheight, 103|V_TRANSLUCENT|cv_constextsize.value|V_NOSCALESTART|t);
|
||||
|
||||
++i;
|
||||
|
||||
c += charwidth;
|
||||
if (c >= vid.width)
|
||||
{
|
||||
@@ -2748,10 +2633,14 @@ static void HU_DrawRankings(void)
|
||||
//V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, gametype_cons_t[gametype].strvalue);
|
||||
|
||||
// draw the current map in the lower right if theres none just say its unknown
|
||||
if (!G_BuildMapTitle(gamemap))
|
||||
char *maptitle = G_BuildMapTitle(gamemap);
|
||||
if (!maptitle)
|
||||
V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, "UNKNOWN");
|
||||
else
|
||||
V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, G_BuildMapTitle(gamemap));
|
||||
{
|
||||
V_DrawString(4, 188, hilicol|V_SNAPTOBOTTOM|V_SNAPTOLEFT, maptitle);
|
||||
Z_Free(maptitle);
|
||||
}
|
||||
|
||||
if (G_GametypeHasTeams())
|
||||
{
|
||||
|
||||
+14
-2
@@ -17,12 +17,13 @@
|
||||
#include "k_director.h"
|
||||
#include "d_netcmd.h"
|
||||
#include "p_local.h"
|
||||
#include "st_stuff.h"
|
||||
|
||||
#define SWITCHTIME TICRATE * 5 // cooldown between unforced switches
|
||||
#define BOREDOMTIME 3 * TICRATE / 2 // how long until players considered far apart?
|
||||
#define TRANSFERTIME TICRATE // how long to delay reaction shots?
|
||||
#define BREAKAWAYDIST 2000 // how *far* until players considered far apart?
|
||||
#define WALKBACKDIST 600 // how close should a trailing player be before we switch?
|
||||
#define WALKBACKDIST 400 // how close should a trailing player be before we switch?
|
||||
#define PINCHDIST 20000 // how close should the leader be to be considered "end of race"?
|
||||
|
||||
struct directorinfo
|
||||
@@ -49,7 +50,7 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale)
|
||||
|
||||
static boolean K_DirectorIsEnabled(void)
|
||||
{
|
||||
return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (!playeringame[consoleplayer] || players[consoleplayer].spectator || (demo.playback && (!demo.title || !modeattacking))));
|
||||
return cv_director.value && !splitscreen && (gamestate == GS_LEVEL && (((stplyr && !stplyr->spectator) && (!playeringame[consoleplayer] || players[consoleplayer].spectator)) || (demo.playback && !demo.freecam && (!demo.title || !modeattacking))));
|
||||
}
|
||||
|
||||
void K_InitDirector(void)
|
||||
@@ -376,6 +377,12 @@ void K_UpdateDirector(void)
|
||||
break;
|
||||
}
|
||||
|
||||
// if this is a splitscreen player, try next pair
|
||||
if (P_IsDisplayPlayer(&players[target]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// if we're certain the back half of the pair is actually in this position, try to switch
|
||||
if (!players[target].kartstuff[k_positiondelay])
|
||||
{
|
||||
@@ -394,10 +401,15 @@ void K_UpdateDirector(void)
|
||||
|
||||
void K_ToggleDirector(void)
|
||||
{
|
||||
if (!directortextactive)
|
||||
return;
|
||||
|
||||
if (!K_DirectorIsEnabled())
|
||||
{
|
||||
directorinfo.cooldown = 0; // switch immediately
|
||||
}
|
||||
|
||||
directortoggletimer = 0;
|
||||
|
||||
COM_ImmedExecute("add director 1");
|
||||
}
|
||||
+5
-3
@@ -2686,8 +2686,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b
|
||||
|
||||
if (P_IsLocalPlayer(player))
|
||||
{
|
||||
quake.intensity = 64*FRACUNIT;
|
||||
quake.time = 5;
|
||||
P_StartQuake(5, 64<<FRACBITS, 0);
|
||||
}
|
||||
|
||||
player->kartstuff[k_instashield] = 15;
|
||||
@@ -9370,6 +9369,9 @@ static void K_drawDriftGauge(void)
|
||||
0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247
|
||||
};
|
||||
|
||||
if (demo.playback && demo.freecam)
|
||||
return;
|
||||
|
||||
if (!stplyr->mo || (!splitscreen && !camera->chase))
|
||||
return;
|
||||
|
||||
@@ -9728,7 +9730,7 @@ static void K_drawKartMinimap(void)
|
||||
splitflags |= minimaptrans;
|
||||
|
||||
if (encoremode)
|
||||
V_DrawScaledPatch(x+SHORT(minimapinfo.minimap_pic->width), y, minimaptrans|V_FLIP, minimapinfo.minimap_pic);
|
||||
V_DrawScaledPatch(x+SHORT(minimapinfo.minimap_pic->width), y, splitflags|V_FLIP, minimapinfo.minimap_pic);
|
||||
else
|
||||
V_DrawScaledPatch(x, y, splitflags, minimapinfo.minimap_pic);
|
||||
|
||||
|
||||
+3
-5
@@ -1553,8 +1553,9 @@ static int lib_pSetSkyboxMobj(lua_State *L)
|
||||
// Shhh, neither does P_StartQuake.
|
||||
static int lib_pStartQuake(lua_State *L)
|
||||
{
|
||||
tic_t q_time = (tic_t)luaL_checkinteger(L, 2);
|
||||
fixed_t q_intensity = luaL_checkinteger(L, 1);
|
||||
UINT16 q_time = (UINT16)luaL_checkinteger(L, 2);
|
||||
fixed_t q_radius = luaL_optinteger(L, 4, 512<<FRACBITS);
|
||||
static mappoint_t q_epicenter = {0,0,0};
|
||||
|
||||
NOHUD
|
||||
@@ -1606,11 +1607,8 @@ static int lib_pStartQuake(lua_State *L)
|
||||
}
|
||||
else
|
||||
quake.epicenter = NULL;
|
||||
quake.radius = luaL_optinteger(L, 4, 512*FRACUNIT);
|
||||
|
||||
// These things are actually used in 2.1.
|
||||
quake.intensity = q_intensity;
|
||||
quake.time = q_time;
|
||||
P_StartQuake(q_time, q_intensity, q_radius);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -632,12 +632,18 @@ void LUA_HUD_DrawList(huddrawlist_h list)
|
||||
switch (item->type)
|
||||
{
|
||||
case DI_Draw:
|
||||
if (!item->patch || item->patch == NULL)
|
||||
return;
|
||||
V_DrawFixedPatch(LERPS(x), LERPS(y), FRACUNIT, item->flags, item->patch, item->colormap);
|
||||
break;
|
||||
case DI_DrawScaled:
|
||||
if (!item->patch || item->patch == NULL)
|
||||
return;
|
||||
V_DrawFixedPatch(LERPS(x), LERPS(y), LERP(scale), item->flags, item->patch, item->colormap);
|
||||
break;
|
||||
case DI_DrawStretched:
|
||||
if (!item->patch || item->patch == NULL)
|
||||
return;
|
||||
V_DrawStretchyFixedPatch(LERPS(x), LERPS(y), LERP(hscale), LERP(vscale), item->flags, item->patch, item->colormap);
|
||||
break;
|
||||
case DI_DrawNum:
|
||||
|
||||
+40
-4
@@ -22,6 +22,8 @@
|
||||
#include "p_saveg.h"
|
||||
#include "p_local.h"
|
||||
#include "p_slopes.h" // for P_SlopeById
|
||||
#include "s_sound.h"
|
||||
#include "m_menu.h"
|
||||
#ifdef LUA_ALLOW_BYTECODE
|
||||
#include "d_netfil.h" // for LUA_DumpFile
|
||||
#endif
|
||||
@@ -1333,6 +1335,12 @@ static UINT8 UnArchiveValue(int TABLESINDEX)
|
||||
break;
|
||||
case ARCH_TEND:
|
||||
return 1;
|
||||
default:
|
||||
CONS_Alert(CONS_ERROR, "Unknown value type unarchived, save is corrupted!\n");
|
||||
G_SetExitGameFlag();
|
||||
S_StartSound(NULL, sfx_syfail); // he he he
|
||||
M_StartMessage(M_GetText("Corrupted save received\nPress ESC\n"), NULL, MM_NOTHING);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1460,7 +1468,13 @@ static void UnArchiveExtVars(void *pointer)
|
||||
for (i = 0; i < field_count; i++)
|
||||
{
|
||||
READSTRING(save_p, field);
|
||||
UnArchiveValue(TABLESINDEX);
|
||||
|
||||
if (UnArchiveValue(TABLESINDEX) == 1)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Unexpected end marker when reading ExtVars (field '%s')\n", field);
|
||||
break;
|
||||
}
|
||||
|
||||
lua_setfield(gL, -2, field);
|
||||
}
|
||||
|
||||
@@ -1524,12 +1538,29 @@ static void UnArchiveTables(void)
|
||||
for (i = 1; i <= n; i++)
|
||||
{
|
||||
lua_rawgeti(gL, TABLESINDEX, i);
|
||||
|
||||
if (!lua_istable(gL, -1))
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Value in tables list #%d is not a table! (corrupted save?)\n", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (UnArchiveValue(TABLESINDEX) == 1) // read key
|
||||
break;
|
||||
if (UnArchiveValue(TABLESINDEX) == 2) // read value
|
||||
|
||||
UINT8 ret = UnArchiveValue(TABLESINDEX);
|
||||
|
||||
if (ret == 1)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "Unexpected end of save reached (Corrupted save?)\n");
|
||||
lua_pop(gL, 1); // Pop key
|
||||
break;
|
||||
}
|
||||
else if (ret == 2) // read value
|
||||
n++;
|
||||
|
||||
if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved)
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, "A nil key in table %d was found! (Invalid key type or corrupted save?)\n", i);
|
||||
@@ -1589,8 +1620,13 @@ void LUA_Step(void)
|
||||
{
|
||||
if (!gL)
|
||||
return;
|
||||
lua_settop(gL, 0);
|
||||
lua_gc(gL, LUA_GCSTEP, 1);
|
||||
|
||||
if (lua_gettop(gL) != 0)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "Eek, there is garbage on lua stack!\n");
|
||||
lua_settop(gL, 0);
|
||||
lua_gc(gL, LUA_GCSTEP, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void LUA_Archive(void)
|
||||
|
||||
@@ -37,9 +37,8 @@
|
||||
/*
|
||||
* Sacrifice very little compression quality in favour of compression speed.
|
||||
* This gives almost the same compression as the default code, and is
|
||||
* (very roughly) 15% faster. This is the preferable mode of operation.
|
||||
* (very roughly) 15% faster. This is the preferred mode of operation.
|
||||
*/
|
||||
|
||||
#ifndef VERY_FAST
|
||||
# define VERY_FAST 1
|
||||
#endif
|
||||
@@ -48,7 +47,7 @@
|
||||
* Sacrifice some more compression quality in favour of compression speed.
|
||||
* (roughly 1-2% worse compression for large blocks and
|
||||
* 9-10% for small, redundant, blocks and >>20% better speed in both cases)
|
||||
* In INT16: when in need for speed, enable this for binary data,
|
||||
* In short: when in need for speed, enable this for binary data,
|
||||
* possibly disable this for text data.
|
||||
*/
|
||||
#ifndef ULTRA_FAST
|
||||
@@ -66,21 +65,10 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use string functions to copy memory.
|
||||
* this is usually a loss, even with glibc's optimized memcpy
|
||||
*/
|
||||
#ifndef USE_MEMCPY
|
||||
#ifdef _MSC_VER
|
||||
# define USE_MEMCPY 0
|
||||
#else
|
||||
# define USE_MEMCPY 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* You may choose to pre-set the hash table (might be faster on some
|
||||
* modern cpus and large (>>64k) blocks)
|
||||
* modern cpus and large (>>64k) blocks, and also makes compression
|
||||
* deterministic/repeatable when the configuration otherwise is the same).
|
||||
*/
|
||||
#ifndef INIT_HTAB
|
||||
# define INIT_HTAB 1
|
||||
@@ -88,15 +76,15 @@
|
||||
|
||||
/*
|
||||
* Avoid assigning values to errno variable? for some embedding purposes
|
||||
* (linux kernel for example), this is neccessary. NOTE: this breaks
|
||||
* the documentation in lzf.h.
|
||||
* (linux kernel for example), this is necessary. NOTE: this breaks
|
||||
* the documentation in lzf.h. Avoiding errno has no speed impact.
|
||||
*/
|
||||
#ifndef AVOID_ERRNO
|
||||
# define AVOID_ERRNO 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Wether to pass the LZF_STATE variable as argument, or allocate it
|
||||
* Whether to pass the LZF_STATE variable as argument, or allocate it
|
||||
* on the stack. For small-stack environments, define this to 1.
|
||||
* NOTE: this breaks the prototype in lzf.h.
|
||||
*/
|
||||
@@ -105,51 +93,109 @@
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Wether to add extra checks for input validity in lzf_decompress
|
||||
* Whether to add extra checks for input validity in lzf_decompress
|
||||
* and return EINVAL if the input stream has been corrupted. This
|
||||
* only shields against overflowing the input buffer and will not
|
||||
* detect most corrupted streams.
|
||||
* This check is not normally noticable on modern hardware
|
||||
* This check is not normally noticeable on modern hardware
|
||||
* (<1% slowdown), but might slow down older cpus considerably.
|
||||
*/
|
||||
#ifndef CHECK_INPUT
|
||||
# define CHECK_INPUT 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Whether the target CPU has a slow multiplication. This affects
|
||||
* the default hash function for the compressor, and enables a slightly
|
||||
* worse hash function that needs only shifts.
|
||||
*/
|
||||
#ifndef MULTIPLICATION_IS_SLOW
|
||||
# define MULTIPLICATION_IS_SLOW 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If defined, then this data type will be used for storing offsets.
|
||||
* This can be useful if you want to use a huge hashtable, want to
|
||||
* conserve memory, or both, and your data fits into e.g. 64kb.
|
||||
* If instead you want to compress data > 4GB, then it's better to
|
||||
* to "#define LZF_USE_OFFSETS 0" instead.
|
||||
*/
|
||||
/*#define LZF_HSLOT unsigned short*/
|
||||
|
||||
/*
|
||||
* Whether to store pointers or offsets inside the hash table. On
|
||||
* 64 bit architetcures, pointers take up twice as much space,
|
||||
* and might also be slower. Default is to autodetect.
|
||||
*/
|
||||
/*#define LZF_USE_OFFSETS autodetect */
|
||||
|
||||
/*
|
||||
* Whether to optimise code for size, at the expense of speed. Use
|
||||
* this when you are extremely tight on memory, perhaps in combination
|
||||
* with AVOID_ERRNO 1 and CHECK_INPUT 0.
|
||||
*/
|
||||
#ifndef OPTIMISE_SIZE
|
||||
# ifdef __OPTIMIZE_SIZE__
|
||||
# define OPTIMISE_SIZE 1
|
||||
# else
|
||||
# define OPTIMISE_SIZE 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* nothing should be changed below */
|
||||
|
||||
typedef unsigned char u8;
|
||||
|
||||
typedef const u8 *LZF_STATE[1 << (HLOG)];
|
||||
|
||||
#if !STRICT_ALIGN
|
||||
/* for unaligned accesses we need a 16 bit datatype. */
|
||||
# include <string.h>
|
||||
# include <limits.h>
|
||||
# if USHRT_MAX == 65535
|
||||
typedef unsigned short u16;
|
||||
# elif UINT_MAX == 65535
|
||||
typedef unsigned int u16;
|
||||
# else
|
||||
# undef STRICT_ALIGN
|
||||
# define STRICT_ALIGN 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if ULTRA_FAST
|
||||
# if defined(VERY_FAST)
|
||||
# undef VERY_FAST
|
||||
# undef VERY_FAST
|
||||
#endif
|
||||
|
||||
#ifndef LZF_USE_OFFSETS
|
||||
# ifdef _WIN32
|
||||
# define LZF_USE_OFFSETS defined(_M_X64)
|
||||
# else
|
||||
# include <stdint.h>
|
||||
# define LZF_USE_OFFSETS (UINTPTR_MAX > 0xffffffffU)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if USE_MEMCPY || INIT_HTAB
|
||||
# ifdef __cplusplus
|
||||
# include <cstring>
|
||||
typedef unsigned char u8;
|
||||
|
||||
#ifdef LZF_HSLOT
|
||||
# define LZF_HSLOT_BIAS ((const u8 *)in_data)
|
||||
#else
|
||||
# ifdef LZF_USE_OFFSETS
|
||||
# define LZF_HSLOT_BIAS ((const u8 *)in_data)
|
||||
typedef unsigned int LZF_HSLOT;
|
||||
# else
|
||||
# include <string.h>
|
||||
# define LZF_HSLOT_BIAS 0
|
||||
typedef const u8 *LZF_HSLOT;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if USHRT_MAX == 65535
|
||||
typedef unsigned short u16;
|
||||
#elif UINT_MAX == 65535
|
||||
typedef unsigned int u16;
|
||||
#else
|
||||
# undef STRICT_ALIGN
|
||||
# define STRICT_ALIGN 1
|
||||
#endif
|
||||
|
||||
#define LZF_MAX_LIT (1 << 5)
|
||||
#define LZF_MAX_OFF (1 << 13)
|
||||
#define LZF_MAX_REF ((1 << 8) + (1 << 3))
|
||||
|
||||
typedef LZF_HSLOT LZF_STATE[1 << (HLOG)];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const u8 *first [1 << (6+8)]; /* most recent occurance of a match */
|
||||
u16 prev [LZF_MAX_OFF]; /* how many bytes to go backwards for the next match */
|
||||
} LZF_STATE_BEST[1];
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -164,14 +210,31 @@ typedef const u8 *LZF_STATE[1 << (HLOG)];
|
||||
# define SET_ERRNO(n) errno = (n)
|
||||
#endif
|
||||
|
||||
#ifndef USE_REP_MOVSB
|
||||
#if (defined (__i386) || defined (__amd64)) && __GNUC__ >= 3
|
||||
#define USE_REP_MOVSB 1
|
||||
#else
|
||||
#define USE_REP_MOVSB 0 // Default to 0 if not defined elsewhere
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if USE_REP_MOVSB /* small win on amd, big loss on intel */
|
||||
#if (defined (__i386) || defined (__amd64)) && __GNUC__ >= 3
|
||||
# define lzf_movsb(dst, src, len) \
|
||||
asm ("rep movsb" \
|
||||
: "=D" (dst), "=S" (src), "=c" (len) \
|
||||
: "0" (dst), "1" (src), "2" (len));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
size_t
|
||||
lzf_decompress (const void *const in_data, size_t in_len,
|
||||
void *out_data, size_t out_len)
|
||||
void *out_data, size_t out_len)
|
||||
{
|
||||
u8 const *ip = (const u8 *)in_data;
|
||||
u8 *op = (u8 *)out_data;
|
||||
u8 *op = (u8 *)out_data;
|
||||
u8 const *const in_end = ip + in_len;
|
||||
u8 *const out_end = op + out_len;
|
||||
u8 *const out_end = op + out_len;
|
||||
|
||||
do
|
||||
{
|
||||
@@ -195,14 +258,23 @@ lzf_decompress (const void *const in_data, size_t in_len,
|
||||
}
|
||||
#endif
|
||||
|
||||
#if USE_MEMCPY
|
||||
M_Memcpy (op, ip, ctrl);
|
||||
op += ctrl;
|
||||
ip += ctrl;
|
||||
#else
|
||||
do
|
||||
#ifdef lzf_movsb
|
||||
lzf_movsb (op, ip, ctrl);
|
||||
#elif OPTIMISE_SIZE
|
||||
while (ctrl--)
|
||||
*op++ = *ip++;
|
||||
while (--ctrl);
|
||||
#else
|
||||
switch (ctrl)
|
||||
{
|
||||
case 32: *op++ = *ip++; case 31: *op++ = *ip++; case 30: *op++ = *ip++; case 29: *op++ = *ip++;
|
||||
case 28: *op++ = *ip++; case 27: *op++ = *ip++; case 26: *op++ = *ip++; case 25: *op++ = *ip++;
|
||||
case 24: *op++ = *ip++; case 23: *op++ = *ip++; case 22: *op++ = *ip++; case 21: *op++ = *ip++;
|
||||
case 20: *op++ = *ip++; case 19: *op++ = *ip++; case 18: *op++ = *ip++; case 17: *op++ = *ip++;
|
||||
case 16: *op++ = *ip++; case 15: *op++ = *ip++; case 14: *op++ = *ip++; case 13: *op++ = *ip++;
|
||||
case 12: *op++ = *ip++; case 11: *op++ = *ip++; case 10: *op++ = *ip++; case 9: *op++ = *ip++;
|
||||
case 8: *op++ = *ip++; case 7: *op++ = *ip++; case 6: *op++ = *ip++; case 5: *op++ = *ip++;
|
||||
case 4: *op++ = *ip++; case 3: *op++ = *ip++; case 2: *op++ = *ip++; case 1: *op++ = *ip++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else /* back reference */
|
||||
@@ -244,12 +316,49 @@ lzf_decompress (const void *const in_data, size_t in_len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
*op++ = *ref++;
|
||||
*op++ = *ref++;
|
||||
#ifdef lzf_movsb
|
||||
len += 2;
|
||||
lzf_movsb (op, ref, len);
|
||||
#elif OPTIMISE_SIZE
|
||||
len += 2;
|
||||
|
||||
do
|
||||
*op++ = *ref++;
|
||||
while (--len);
|
||||
#else
|
||||
switch (len)
|
||||
{
|
||||
default:
|
||||
len += 2;
|
||||
|
||||
if (op >= ref + len)
|
||||
{
|
||||
/* disjunct areas */
|
||||
memcpy (op, ref, len);
|
||||
op += len;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* overlapping, use octet by octet copying */
|
||||
do
|
||||
*op++ = *ref++;
|
||||
while (--len);
|
||||
}
|
||||
break;
|
||||
|
||||
case 9: *op++ = *ref++;
|
||||
case 8: *op++ = *ref++;
|
||||
case 7: *op++ = *ref++;
|
||||
case 6: *op++ = *ref++;
|
||||
case 5: *op++ = *ref++;
|
||||
case 4: *op++ = *ref++;
|
||||
case 3: *op++ = *ref++;
|
||||
case 2: *op++ = *ref++;
|
||||
case 1: *op++ = *ref++;
|
||||
case 0: *op++ = *ref++; /* two octets more */
|
||||
*op++ = *ref++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
while (ip < in_end);
|
||||
@@ -266,23 +375,29 @@ lzf_decompress (const void *const in_data, size_t in_len,
|
||||
|
||||
/*
|
||||
* don't play with this unless you benchmark!
|
||||
* decompression is not dependent on the hash function
|
||||
* the hashing function might seem strange, just believe me
|
||||
* the data format is not dependent on the hash function.
|
||||
* the hash function might seem strange, just believe me,
|
||||
* it works ;)
|
||||
*/
|
||||
#ifndef FRST
|
||||
# define FRST(p) (((p[0]) << 8) | p[1])
|
||||
# define NEXT(v,p) (((v) << 8) | p[2])
|
||||
# define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
|
||||
#endif
|
||||
/*
|
||||
* IDX works because it is very similar to a multiplicative hash, e.g.
|
||||
* ((h * 57321 >> (3*8 - HLOG)) & (HSIZE - 1))
|
||||
* the latter is also quite fast on newer CPUs, and sligthly better
|
||||
*
|
||||
* the next one is also quite good, albeit slow ;)
|
||||
* (int)(cos(h & 0xffffff) * 1e6)
|
||||
# if MULTIPLICATION_IS_SLOW
|
||||
# if ULTRA_FAST
|
||||
# define IDX(h) ((( h >> (3*8 - HLOG)) - h ) & (HSIZE - 1))
|
||||
# elif VERY_FAST
|
||||
# define IDX(h) ((( h >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
|
||||
# else
|
||||
# define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
|
||||
# endif
|
||||
# else
|
||||
/* this one was developed with sesse,
|
||||
* and is very similar to the one in snappy.
|
||||
* it does need a modern enough cpu with a fast multiplication.
|
||||
*/
|
||||
# define IDX(h) (((h * 0x1e35a7bdU) >> (32 - HLOG - 8)) & (HSIZE - 1))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
/* original lzv-like hash function, much worse and thus slower */
|
||||
@@ -291,177 +406,214 @@ lzf_decompress (const void *const in_data, size_t in_len,
|
||||
# define IDX(h) ((h) & (HSIZE - 1))
|
||||
#endif
|
||||
|
||||
#define MAX_LIT (1 << 5)
|
||||
#define MAX_OFF (1 << 13)
|
||||
#define MAX_REF ((1 << 8) + (1 << 3))
|
||||
#if __GNUC__ >= 3
|
||||
# define expect(expr,value) __builtin_expect ((expr),(value))
|
||||
# define inline inline
|
||||
#else
|
||||
# define expect(expr,value) (expr)
|
||||
# define inline static
|
||||
#endif
|
||||
|
||||
#define expect_false(expr) expect ((expr) != 0, 0)
|
||||
#define expect_true(expr) expect ((expr) != 0, 1)
|
||||
|
||||
/*
|
||||
* compressed format
|
||||
*
|
||||
* 000LLLLL <L+1> ; literal
|
||||
* LLLooooo oooooooo ; backref L
|
||||
* 111ooooo LLLLLLLL oooooooo ; backref L+7
|
||||
* 000LLLLL <L+1> ; literal, L+1=1..33 octets
|
||||
* LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset
|
||||
* 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset
|
||||
*
|
||||
*/
|
||||
|
||||
size_t
|
||||
lzf_compress (const void *const in_data,size_t in_len,
|
||||
void *out_data, size_t out_len
|
||||
lzf_compress (const void *const in_data, size_t in_len,
|
||||
void *out_data, size_t out_len
|
||||
#if LZF_STATE_ARG
|
||||
, LZF_STATE *htab
|
||||
, LZF_STATE htab
|
||||
#endif
|
||||
)
|
||||
)
|
||||
{
|
||||
#if !LZF_STATE_ARG
|
||||
LZF_STATE htab;
|
||||
#endif
|
||||
const u8 **hslot;
|
||||
const u8 *ip = (const u8 *)in_data;
|
||||
u8 *op = (u8 *)out_data;
|
||||
u8 *op = (u8 *)out_data;
|
||||
const u8 *in_end = ip + in_len;
|
||||
u8 *out_end = op + out_len;
|
||||
const u8 *ref = NULL;
|
||||
u8 *out_end = op + out_len;
|
||||
const u8 *ref;
|
||||
|
||||
/*
|
||||
* off requires a type wide enough to hold a general pointer difference.
|
||||
* ISO C doesn't have that (size_t might not be enough and ptrdiff_t only
|
||||
* works for differences within a single object). We also assume that
|
||||
* no bit pattern traps. Since the only platform that is both non-POSIX
|
||||
* and fails to support both assumptions is windows 64 bit, we make a
|
||||
* special workaround for it.
|
||||
*/
|
||||
|
||||
unsigned int hval = FRST (ip);
|
||||
size_t off;
|
||||
int lit = 0;
|
||||
unsigned int hval;
|
||||
int lit;
|
||||
|
||||
if (!in_len || !out_len)
|
||||
return 0;
|
||||
|
||||
#if INIT_HTAB
|
||||
# if USE_MEMCPY
|
||||
memset (htab, 0, sizeof (htab));
|
||||
# else
|
||||
for (hslot = htab; hslot < htab + HSIZE; hslot++)
|
||||
*hslot++ = ip;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
for (;;)
|
||||
lit = 0; op++; /* start run */
|
||||
|
||||
hval = FRST (ip);
|
||||
while (ip < in_end - 2)
|
||||
{
|
||||
if (ip < in_end - 2)
|
||||
{
|
||||
hval = NEXT (hval, ip);
|
||||
hslot = htab + IDX (hval);
|
||||
ref = *hslot; *hslot = ip;
|
||||
LZF_HSLOT *hslot;
|
||||
|
||||
if (
|
||||
#if INIT_HTAB && !USE_MEMCPY
|
||||
ref < ip /* the next test will actually take care of this, but this is faster */
|
||||
&&
|
||||
hval = NEXT (hval, ip);
|
||||
hslot = htab + IDX (hval);
|
||||
ref = *hslot + LZF_HSLOT_BIAS; *hslot = ip - LZF_HSLOT_BIAS;
|
||||
|
||||
if (1
|
||||
#if INIT_HTAB
|
||||
&& ref < ip /* the next test will actually take care of this, but this is faster */
|
||||
#endif
|
||||
(off = ip - ref - 1) < MAX_OFF
|
||||
&& ip + 4 < in_end
|
||||
&& ref > (const u8 *)in_data
|
||||
&& (off = ip - ref - 1) < LZF_MAX_OFF
|
||||
&& ref > (const u8 *)in_data
|
||||
&& ref[2] == ip[2]
|
||||
#if STRICT_ALIGN
|
||||
&& ref[0] == ip[0]
|
||||
&& ref[1] == ip[1]
|
||||
&& ref[2] == ip[2]
|
||||
&& ((ref[1] << 8) | ref[0]) == ((ip[1] << 8) | ip[0])
|
||||
#else
|
||||
&& *(const u16 *)ref == *(const u16 *)ip
|
||||
&& ref[2] == ip[2]
|
||||
&& *(const u16 *)ref == *(const u16 *)ip
|
||||
#endif
|
||||
)
|
||||
{
|
||||
/* match found at *ref++ */
|
||||
unsigned int len = 2;
|
||||
size_t maxlen = in_end - ip - len;
|
||||
maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;
|
||||
)
|
||||
{
|
||||
/* match found at *ref++ */
|
||||
unsigned int len = 2;
|
||||
size_t maxlen = in_end - ip - len;
|
||||
maxlen = maxlen > LZF_MAX_REF ? LZF_MAX_REF : maxlen;
|
||||
|
||||
if (op + lit + 1 + 3 >= out_end)
|
||||
if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */
|
||||
if (op - !lit + 3 + 1 >= out_end) /* second the exact but rare test */
|
||||
return 0;
|
||||
|
||||
op [- lit - 1] = lit - 1; /* stop run */
|
||||
op -= !lit; /* undo run if length is zero */
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if (expect_true (maxlen > 16))
|
||||
{
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
len++; if (ref [len] != ip [len]) break;
|
||||
}
|
||||
|
||||
do
|
||||
len++;
|
||||
while (len < maxlen && ref[len] == ip[len]);
|
||||
|
||||
if (lit)
|
||||
{
|
||||
*op++ = (u8)(lit - 1);
|
||||
lit = -lit;
|
||||
do
|
||||
*op++ = ip[lit];
|
||||
while (++lit);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
len -= 2;
|
||||
ip++;
|
||||
len -= 2; /* len is now #octets - 1 */
|
||||
ip++;
|
||||
|
||||
if (len < 7)
|
||||
{
|
||||
*op++ = (u8)((off >> 8) + (len << 5));
|
||||
}
|
||||
else
|
||||
{
|
||||
*op++ = (u8)((off >> 8) + ( 7 << 5));
|
||||
*op++ = (u8)(len - 7);
|
||||
}
|
||||
if (len < 7)
|
||||
{
|
||||
*op++ = (off >> 8) + (len << 5);
|
||||
}
|
||||
else
|
||||
{
|
||||
*op++ = (off >> 8) + ( 7 << 5);
|
||||
*op++ = len - 7;
|
||||
}
|
||||
|
||||
*op++ = (u8)off;
|
||||
*op++ = off;
|
||||
|
||||
lit = 0; op++; /* start run */
|
||||
|
||||
ip += len + 1;
|
||||
|
||||
if (expect_false (ip >= in_end - 2))
|
||||
break;
|
||||
|
||||
#if ULTRA_FAST || VERY_FAST
|
||||
ip += len;
|
||||
#if VERY_FAST && !ULTRA_FAST
|
||||
--ip;
|
||||
#endif
|
||||
hval = FRST (ip);
|
||||
--ip;
|
||||
# if VERY_FAST && !ULTRA_FAST
|
||||
--ip;
|
||||
# endif
|
||||
hval = FRST (ip);
|
||||
|
||||
hval = NEXT (hval, ip);
|
||||
htab[IDX (hval)] = ip;
|
||||
ip++;
|
||||
hval = NEXT (hval, ip);
|
||||
htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
|
||||
ip++;
|
||||
|
||||
#if VERY_FAST && !ULTRA_FAST
|
||||
hval = NEXT (hval, ip);
|
||||
htab[IDX (hval)] = ip;
|
||||
ip++;
|
||||
#endif
|
||||
# if VERY_FAST && !ULTRA_FAST
|
||||
hval = NEXT (hval, ip);
|
||||
htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
|
||||
ip++;
|
||||
# endif
|
||||
#else
|
||||
do
|
||||
{
|
||||
hval = NEXT (hval, ip);
|
||||
htab[IDX (hval)] = ip;
|
||||
ip++;
|
||||
}
|
||||
while (len--);
|
||||
#endif
|
||||
continue;
|
||||
ip -= len + 1;
|
||||
|
||||
do
|
||||
{
|
||||
hval = NEXT (hval, ip);
|
||||
htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
|
||||
ip++;
|
||||
}
|
||||
while (len--);
|
||||
#endif
|
||||
}
|
||||
else if (ip == in_end)
|
||||
break;
|
||||
|
||||
/* one more literal byte we must copy */
|
||||
lit++;
|
||||
ip++;
|
||||
|
||||
if (lit == MAX_LIT)
|
||||
else
|
||||
{
|
||||
if (op + 1 + MAX_LIT >= out_end)
|
||||
/* one more literal byte we must copy */
|
||||
if (expect_false (op >= out_end))
|
||||
return 0;
|
||||
|
||||
*op++ = MAX_LIT - 1;
|
||||
#if USE_MEMCPY
|
||||
M_Memcpy (op, ip - MAX_LIT, MAX_LIT);
|
||||
op += MAX_LIT;
|
||||
lit = 0;
|
||||
#else
|
||||
lit = -lit;
|
||||
do
|
||||
*op++ = ip[lit];
|
||||
while (++lit);
|
||||
#endif
|
||||
lit++; *op++ = *ip++;
|
||||
|
||||
if (expect_false (lit == LZF_MAX_LIT))
|
||||
{
|
||||
op [- lit - 1] = lit - 1; /* stop run */
|
||||
lit = 0; op++; /* start run */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (lit)
|
||||
{
|
||||
if (op + lit + 1 >= out_end)
|
||||
return 0;
|
||||
if (op + 3 > out_end) /* at most 3 bytes can be missing here */
|
||||
return 0;
|
||||
|
||||
*op++ = (u8)(lit - 1);
|
||||
lit = -lit;
|
||||
do
|
||||
*op++ = ip[lit];
|
||||
while (++lit);
|
||||
while (ip < in_end)
|
||||
{
|
||||
lit++; *op++ = *ip++;
|
||||
|
||||
if (expect_false (lit == LZF_MAX_LIT))
|
||||
{
|
||||
op [- lit - 1] = lit - 1; /* stop run */
|
||||
lit = 0; op++; /* start run */
|
||||
}
|
||||
}
|
||||
|
||||
return op - (u8 *) out_data;
|
||||
op [- lit - 1] = lit - 1; /* end run */
|
||||
op -= !lit; /* undo run if length is zero */
|
||||
|
||||
return op - (u8 *)out_data;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2000-2005 by Marc Alexander Lehmann <schmorp@schmorp.de>
|
||||
// Copyright (c) 2000-2010 Marc Alexander Lehmann <schmorp@schmorp.de>
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
@@ -22,7 +22,7 @@
|
||||
**
|
||||
***********************************************************************/
|
||||
|
||||
#define LZF_VERSION 0x0105 /* 1.5 */
|
||||
#define LZF_VERSION 0x0106 /* 1.6 */
|
||||
|
||||
/*
|
||||
* Compress in_len bytes stored at the memory block starting at
|
||||
|
||||
+191
-187
@@ -30,6 +30,7 @@
|
||||
#include "g_game.h"
|
||||
#include "g_input.h"
|
||||
#include "m_argv.h"
|
||||
#include "m_textinput.h"
|
||||
|
||||
// Data.
|
||||
#include "sounds.h"
|
||||
@@ -159,6 +160,9 @@ boolean fromlevelselect = false;
|
||||
|
||||
boolean menu_text_input = false;
|
||||
|
||||
char menu_text_input_buf[MAXSTRINGLENGTH];
|
||||
static textinput_t menuinput;
|
||||
|
||||
static INT32 coolalphatimer = 9;
|
||||
|
||||
typedef enum
|
||||
@@ -245,6 +249,7 @@ menu_t SR_MainDef, SR_UnlockChecklistDef;
|
||||
|
||||
// Misc. Main Menu
|
||||
static void M_Options(INT32 choice);
|
||||
static void M_Multiplayer(INT32 choice);
|
||||
static void M_LocalSkinMenu(INT32 choice);
|
||||
static void M_LocalSkinChange(INT32 choice);
|
||||
static void M_Manual(INT32 choice);
|
||||
@@ -591,7 +596,7 @@ static menuitem_t MainMenu[] =
|
||||
{
|
||||
{IT_SUBMENU|IT_STRING, NULL, "Extras", &SR_MainDef, 76},
|
||||
{IT_CALL |IT_STRING, NULL, "Time Attack", M_TimeAttack, 84},
|
||||
{IT_SUBMENU|IT_STRING, NULL, "Multiplayer", &MP_MainDef, 92},
|
||||
{IT_CALL |IT_STRING, NULL, "Multiplayer", M_Multiplayer, 92},
|
||||
{IT_CALL |IT_STRING, NULL, "Options", M_Options, 100},
|
||||
{IT_CALL |IT_STRING, NULL, "Addons", M_Addons, 108},
|
||||
{IT_CALL |IT_STRING, NULL, "Quit Game", M_QuitSRB2, 116},
|
||||
@@ -1598,7 +1603,20 @@ static menuitem_t OP_SoundOptionsMenu[] =
|
||||
//{IT_STRING|IT_CALL, NULL, "Restart Audio System", M_RestartAudio, 50},
|
||||
#ifdef NO_MIDI
|
||||
{IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 50},
|
||||
{IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 60},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 65},
|
||||
{IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 75},
|
||||
{IT_STRING|IT_CVAR, NULL, "Hit Em Delay", &cv_karthitemdialog, 85},
|
||||
{IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 95},
|
||||
|
||||
{IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105},
|
||||
{IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125},
|
||||
{IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135},
|
||||
{IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 145}
|
||||
#else
|
||||
{IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 75},
|
||||
{IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 85},
|
||||
@@ -1611,21 +1629,6 @@ static menuitem_t OP_SoundOptionsMenu[] =
|
||||
{IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 135},
|
||||
{IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 145},
|
||||
{IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155}
|
||||
#else
|
||||
{IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60},
|
||||
{IT_STRING|IT_CVAR, NULL, "Surround Sound", &surround, 70},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Chat Notifications", &cv_chatnotifications, 85},
|
||||
{IT_STRING|IT_CVAR, NULL, "Character voices", &cv_kartvoices, 95},
|
||||
{IT_STRING|IT_CVAR, NULL, "Hit Em Delay", &cv_karthitemdialog, 105},
|
||||
{IT_STRING|IT_CVAR, NULL, "Powerup Warning", &cv_kartinvinsfx, 115},
|
||||
|
||||
{IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 125},
|
||||
{IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 135},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 145},
|
||||
{IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 155},
|
||||
{IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 165}
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -1640,7 +1643,6 @@ static const char* OP_SoundTooltips[] =
|
||||
"Volume of Midi Music.",
|
||||
#endif
|
||||
"Reverse left and right channels of audio.",
|
||||
"Surround Sound.",
|
||||
"Chat notification sound.",
|
||||
"Frequency of character voice lines.",
|
||||
"Play 'Hit Em' character line after other player's hurt line.",
|
||||
@@ -2580,6 +2582,7 @@ static menuitem_t OP_AdvancedBirdMenu[] =
|
||||
{IT_STRING | IT_CVAR, NULL, "Fade Back In While Respawning", &cv_respawnfademusicback, 40},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Resync Threshold", &cv_music_resync_threshold, 60},
|
||||
{IT_STRING | IT_CVAR, NULL, "Resync Special Music Only", &cv_music_resync_powerups_only, 70},
|
||||
};
|
||||
|
||||
static const char* OP_AdvancedBirdTooltips[] =
|
||||
@@ -3502,46 +3505,15 @@ static void M_ChangeCvar(INT32 choice)
|
||||
static boolean M_ChangeStringCvar(INT32 choice)
|
||||
{
|
||||
consvar_t *cv = (consvar_t *)currentMenu->menuitems[itemOn].itemaction;
|
||||
char buf[MAXSTRINGLENGTH];
|
||||
size_t len;
|
||||
|
||||
choice = M_ShiftChar(choice);
|
||||
|
||||
switch (choice)
|
||||
if (M_TextInputHandle(&menuinput, choice))
|
||||
{
|
||||
case KEY_BACKSPACE:
|
||||
len = strlen(cv->string);
|
||||
if (len > 0)
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
M_Memcpy(buf, cv->string, len);
|
||||
buf[len-1] = 0;
|
||||
CV_Set(cv, buf);
|
||||
}
|
||||
return true;
|
||||
case KEY_DEL:
|
||||
if (cv->string[0])
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
CV_Set(cv, "");
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
if ((cv_keyboardlayout.value != 3 && choice >= 32 && choice <= 127) || (cv_keyboardlayout.value == 3 && choice >= 32 && choice <= 141))
|
||||
{
|
||||
len = strlen(cv->string);
|
||||
if (len < MAXSTRINGLENGTH - 1)
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
M_Memcpy(buf, cv->string, len);
|
||||
buf[len++] = (char)choice;
|
||||
buf[len] = 0;
|
||||
CV_Set(cv, buf);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
CV_Set(cv, menuinput.buffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3558,6 +3530,21 @@ static void M_ResetCvars(void)
|
||||
}
|
||||
}
|
||||
|
||||
// If current menu item is IT_CV_STRING, setup menuinput
|
||||
static void M_CheckStringItem(void)
|
||||
{
|
||||
if (itemOn < currentMenu->numitems && (currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING)
|
||||
{
|
||||
consvar_t *cv = (consvar_t *)currentMenu->menuitems[itemOn].itemaction;
|
||||
|
||||
// Just in case
|
||||
memset(menu_text_input_buf, 0, sizeof menu_text_input_buf);
|
||||
M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf);
|
||||
|
||||
M_TextInputSetString(&menuinput, cv->string);
|
||||
}
|
||||
}
|
||||
|
||||
static void M_NextOpt(void)
|
||||
{
|
||||
INT16 oldItemOn = itemOn; // prevent infinite loop
|
||||
@@ -3569,6 +3556,8 @@ static void M_NextOpt(void)
|
||||
else
|
||||
itemOn++;
|
||||
} while (oldItemOn != itemOn && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_SPACE);
|
||||
|
||||
M_CheckStringItem();
|
||||
}
|
||||
|
||||
static void M_PrevOpt(void)
|
||||
@@ -3582,6 +3571,8 @@ static void M_PrevOpt(void)
|
||||
else
|
||||
itemOn--;
|
||||
} while (oldItemOn != itemOn && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_SPACE);
|
||||
|
||||
M_CheckStringItem();
|
||||
}
|
||||
|
||||
// lock out further input in a tic when important buttons are pressed
|
||||
@@ -3942,7 +3933,6 @@ boolean M_Responder(event_t *ev)
|
||||
if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING)
|
||||
{
|
||||
menu_text_input = true;
|
||||
ch = M_ShiftChar(ch);
|
||||
if (M_ChangeStringCvar(ch))
|
||||
return true;
|
||||
else
|
||||
@@ -4603,6 +4593,8 @@ void M_SetupNextMenu(menu_t *menudef)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
M_CheckStringItem();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -4942,6 +4934,33 @@ void M_DrawTextBoxFlags(INT32 x, INT32 y, INT32 width, INT32 boxlines, INT32 fla
|
||||
V_DrawFill(x+5, y+5, width*8+6, boxlines*8+6, 239|flags);
|
||||
}
|
||||
|
||||
void M_DrawTextInput(INT32 x, INT32 y, textinput_t *input, INT32 flags)
|
||||
{
|
||||
INT32 skullx = x;
|
||||
|
||||
V_DrawString(x, y, V_ALLOWLOWERCASE|flags, input->buffer);
|
||||
|
||||
// draw text cursor for name
|
||||
if (input->length)
|
||||
skullx = x+V_SubStringWidth(input->buffer, input->cursor, V_ALLOWLOWERCASE);
|
||||
|
||||
if (skullAnimCounter < 4) // blink cursor
|
||||
V_DrawCharacter(skullx, y+3, '_'|flags, false);
|
||||
|
||||
// draw selection
|
||||
if (input->select != input->cursor)
|
||||
{
|
||||
size_t start = min(input->select, input->cursor);
|
||||
size_t end = max(input->select, input->cursor);
|
||||
|
||||
size_t len = end - start;
|
||||
|
||||
INT32 startx = V_SubStringWidth(input->buffer, start, V_ALLOWLOWERCASE);
|
||||
|
||||
V_DrawFill(x+startx, y, V_SubStringWidth(input->buffer+start, len, V_ALLOWLOWERCASE), 8, 103|V_TRANSLUCENT|flags);
|
||||
}
|
||||
}
|
||||
|
||||
// horizontally centered text
|
||||
static void M_CentreText(INT32 y, const char *string)
|
||||
{
|
||||
@@ -5143,10 +5162,12 @@ static void M_DrawGenericMenu(void)
|
||||
break;
|
||||
case IT_CV_STRING:
|
||||
M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1);
|
||||
V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, cv->string);
|
||||
if (skullAnimCounter < 4 && i == itemOn)
|
||||
V_DrawCharacter(x + 8 + V_StringWidth(cv->string, 0), y + 12,
|
||||
'_' | 0x80, false);
|
||||
|
||||
if (itemOn == i)
|
||||
M_DrawTextInput(x + 8, y + 12, &menuinput, 0);
|
||||
else
|
||||
V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, cv->string);
|
||||
|
||||
y += 16;
|
||||
break;
|
||||
default:
|
||||
@@ -5330,10 +5351,12 @@ static void M_DrawGenericScrollMenu(void)
|
||||
if (y + 12 > (currentMenu->y + 2*scrollareaheight))
|
||||
break;
|
||||
M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1);
|
||||
V_DrawString(x + 8, y + 12, lowercase, cv->string);
|
||||
if (skullAnimCounter < 4 && i == itemOn)
|
||||
V_DrawCharacter(x + 8 + V_StringWidth(cv->string, 0), y + 12,
|
||||
'_' | 0x80, false);
|
||||
|
||||
if (itemOn == i)
|
||||
M_DrawTextInput(x + 8, y + 12, &menuinput, 0);
|
||||
else
|
||||
V_DrawString(x + 8, y + 12, lowercase, cv->string);
|
||||
|
||||
break;
|
||||
default:
|
||||
V_DrawRightAlignedString(BASEVIDWIDTH - x, y,
|
||||
@@ -5469,10 +5492,12 @@ static void M_DrawCenteredMenu(void)
|
||||
break;
|
||||
case IT_CV_STRING:
|
||||
M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1);
|
||||
V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, cv->string);
|
||||
if (skullAnimCounter < 4 && i == itemOn)
|
||||
V_DrawCharacter(x + 8 + V_StringWidth(cv->string, 0), y + 12,
|
||||
'_' | 0x80, false);
|
||||
|
||||
if (itemOn == i)
|
||||
M_DrawTextInput(x + 8, y + 12, &menuinput, 0);
|
||||
else
|
||||
V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, cv->string);
|
||||
|
||||
y += 16;
|
||||
break;
|
||||
default:
|
||||
@@ -6648,11 +6673,11 @@ I_mutex replayquerymutex;
|
||||
|
||||
|
||||
#define MAXREPLAYQUERY 40
|
||||
char replayqueryinput[MAXREPLAYQUERY+1]; // The input typed
|
||||
size_t replayquerypos = 0; // Position in input window
|
||||
static char replayqueryinput_buffer[MAXREPLAYQUERY+1]; // The input typed
|
||||
static textinput_t replayqueryinput;
|
||||
|
||||
size_t replayqueryfound = 0; // Number of checked replay entries
|
||||
size_t replayquerycheck = 0; // Index of next replay entry to check in demolist_all
|
||||
static size_t replayqueryfound = 0; // Number of checked replay entries
|
||||
static size_t replayquerycheck = 0; // Index of next replay entry to check in demolist_all
|
||||
|
||||
#define DF_ENCORE 0x40
|
||||
static INT16 replayScrollTitle = 0;
|
||||
@@ -6707,8 +6732,8 @@ static void LoadReplayNames(void)
|
||||
|
||||
static void ResetReplayQuery(void)
|
||||
{
|
||||
memset(replayqueryinput, 0, MAXREPLAYQUERY);
|
||||
replayquerypos = 0;
|
||||
memset(replayqueryinput_buffer, 0, MAXREPLAYQUERY);
|
||||
M_TextInputInit(&replayqueryinput, replayqueryinput_buffer, MAXREPLAYQUERY);
|
||||
|
||||
replayqueryfound = 0;
|
||||
replayquerycheck = 0;
|
||||
@@ -6732,7 +6757,7 @@ static void M_HutCheckReplays(size_t maxnum)
|
||||
return;
|
||||
|
||||
// If we don't have any query, just copy all demos and consider them checked
|
||||
if (replayquerypos == 0)
|
||||
if (replayqueryinput.length == 0)
|
||||
{
|
||||
// Mark as done
|
||||
replayqueryfound = replayquerycheck = sizedirmenu;
|
||||
@@ -6756,7 +6781,7 @@ static void M_HutCheckReplays(size_t maxnum)
|
||||
case MD_NOTLOADED:
|
||||
case MD_OUTDATED:
|
||||
case MD_LOADED:
|
||||
if (demolist_all[replayquerycheck].title[0] && strcasestr(demolist_all[replayquerycheck].title, replayqueryinput) != NULL)
|
||||
if (demolist_all[replayquerycheck].title[0] && strcasestr(demolist_all[replayquerycheck].title, replayqueryinput.buffer) != NULL)
|
||||
AddCheckedReplay(); // It matches, add it!
|
||||
else
|
||||
replayquerycheck++; // Doesn't match, moving on...
|
||||
@@ -6855,41 +6880,23 @@ void M_ReplayHut(INT32 choice)
|
||||
|
||||
static boolean M_HandleReplayHutQuery(INT32 choice)
|
||||
{
|
||||
switch (choice)
|
||||
// Yea gonna copy buffer and check if it changed, thats better than checking for specific keys i think
|
||||
char tmp[MAXREPLAYQUERY+1];
|
||||
memcpy(tmp, replayqueryinput_buffer, MAXREPLAYQUERY+1);
|
||||
|
||||
if (M_TextInputHandle(&replayqueryinput, choice))
|
||||
{
|
||||
case KEY_BACKSPACE:
|
||||
if (replayquerypos == 0)
|
||||
break;
|
||||
|
||||
S_StartSound(NULL,sfx_menu1);
|
||||
|
||||
replayquerypos--;
|
||||
replayqueryinput[replayquerypos] = 0;
|
||||
S_StartSound(NULL,sfx_menu1);
|
||||
|
||||
// Restart search only if we actually modified input and not just moved in it
|
||||
if (memcmp(tmp, replayqueryinput_buffer, MAXREPLAYQUERY+1))
|
||||
{
|
||||
preparefilemenu(false, true);
|
||||
dir_on[menudepthleft] = 0;
|
||||
PrepReplayList(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
default:
|
||||
if (choice < 32 || choice > 127)
|
||||
break;
|
||||
|
||||
if (replayquerypos < MAXREPLAYQUERY)
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1);
|
||||
|
||||
replayqueryinput[replayquerypos] = choice;
|
||||
replayqueryinput[replayquerypos+1] = 0;
|
||||
++replayquerypos;
|
||||
|
||||
preparefilemenu(false, true);
|
||||
dir_on[menudepthleft] = 0;
|
||||
PrepReplayList(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -7320,15 +7327,11 @@ static void M_DrawReplayHut(void)
|
||||
// Draw search query
|
||||
M_DrawTextBoxFlags(x, 200 - 22, MAXREPLAYQUERY, 1, V_SNAPTOBOTTOM);
|
||||
|
||||
if (replayquerypos)
|
||||
V_DrawString(x + 8, 200 - 14, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, replayqueryinput);
|
||||
if (replayqueryinput.length)
|
||||
M_DrawTextInput(x + 8, 200 - 14, &replayqueryinput, V_SNAPTOBOTTOM);
|
||||
else
|
||||
V_DrawString(x + 8, 200 - 14, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, "\x86Type to search...");
|
||||
|
||||
// draw text cursor for name
|
||||
if (replayquerypos && skullAnimCounter < 4) // blink cursor
|
||||
V_DrawCharacter(x + 8 + V_StringWidth(replayqueryinput, V_ALLOWLOWERCASE), 200 - 14, '_'|V_SNAPTOBOTTOM, false);
|
||||
|
||||
if (replaynamesloaded && replayquerycheck < sizedirmenu)
|
||||
V_DrawString(x + 8, 200 - 30, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, va("Searching %u/%u...", (unsigned)replayquerycheck, (unsigned)sizedirmenu));
|
||||
}
|
||||
@@ -8906,9 +8909,11 @@ void M_DrawTimeAttackMenu(void)
|
||||
if (currentMenu->menuitems[i].status & IT_CV_STRING)
|
||||
{
|
||||
M_DrawTextBox(x + 32, y - 8, MAXPLAYERNAME, 1);
|
||||
V_DrawString(x + 40, y, V_ALLOWLOWERCASE, cv->string);
|
||||
if (itemOn == i && skullAnimCounter < 4) // blink cursor
|
||||
V_DrawCharacter(x + 40 + V_StringWidth(cv->string, V_ALLOWLOWERCASE), y, '_',false);
|
||||
|
||||
if (itemOn != i)
|
||||
V_DrawString(x + 40, y, V_ALLOWLOWERCASE, cv->string);
|
||||
else
|
||||
M_DrawTextInput(x + 40, y, &menuinput, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -10185,7 +10190,19 @@ static void M_StartServerMenu(INT32 choice)
|
||||
// ==============
|
||||
|
||||
static char setupm_ip[28];
|
||||
static textinput_t setupm_input_ip;
|
||||
#endif
|
||||
|
||||
void M_Multiplayer(INT32 choice)
|
||||
{
|
||||
(void)choice;
|
||||
#ifndef NONET
|
||||
memset(setupm_ip, 0, 28);
|
||||
M_TextInputInit(&setupm_input_ip, setupm_ip, 28);
|
||||
#endif
|
||||
M_SetupNextMenu(&MP_MainDef);
|
||||
}
|
||||
|
||||
static UINT8 setupm_pselect = 1;
|
||||
|
||||
// Draw the funky Connect IP menu. Tails 11-19-2002
|
||||
@@ -10219,12 +10236,10 @@ Update the maxplayers label...
|
||||
V_DrawFill(x+5, y+4+5, /*16*8 + 6,*/ BASEVIDWIDTH - 2*(x+5), 8+6, 239);
|
||||
|
||||
// draw name string
|
||||
V_DrawString(x+8,y+12, V_ALLOWLOWERCASE, setupm_ip);
|
||||
|
||||
// draw text cursor for name
|
||||
if (itemOn == 9
|
||||
&& skullAnimCounter < 4) //blink cursor
|
||||
V_DrawCharacter(x+8+V_StringWidth(setupm_ip, V_ALLOWLOWERCASE),y+12,'_',false);
|
||||
if (itemOn != 9)
|
||||
V_DrawString(x+8,y+12, V_ALLOWLOWERCASE, setupm_ip);
|
||||
else
|
||||
M_DrawTextInput(x+8, y+12, &setupm_input_ip, 0);
|
||||
#endif
|
||||
|
||||
// character bar, ripped off the color bar :V
|
||||
@@ -10412,7 +10427,6 @@ static void M_ConnectLastServer(INT32 choice)
|
||||
// Tails 11-19-2002
|
||||
static void M_HandleConnectIP(INT32 choice)
|
||||
{
|
||||
size_t l;
|
||||
boolean exitmenu = false; // exit to previous menu and send name change
|
||||
|
||||
switch (choice)
|
||||
@@ -10437,41 +10451,21 @@ static void M_HandleConnectIP(INT32 choice)
|
||||
exitmenu = true;
|
||||
break;
|
||||
|
||||
case KEY_LEFTARROW:
|
||||
case KEY_RIGHTARROW:
|
||||
case KEY_BACKSPACE:
|
||||
if ((l = strlen(setupm_ip)) != 0)
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
setupm_ip[l-1] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case KEY_DEL:
|
||||
if (setupm_ip[0])
|
||||
{
|
||||
if (M_TextInputHandle(&setupm_input_ip, choice))
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
setupm_ip[0] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
l = strlen(setupm_ip);
|
||||
if (l >= 28-1)
|
||||
break;
|
||||
|
||||
// Rudimentary number and period enforcing - also allows letters so hostnames can be used instead
|
||||
if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z'))
|
||||
if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z')
|
||||
|| (choice >= 199 && choice <= 211 && choice != 202 && choice != 206)) //numpad too!
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
setupm_ip[l] = (char)choice;
|
||||
setupm_ip[l+1] = 0;
|
||||
}
|
||||
else if (choice >= 199 && choice <= 211 && choice != 202 && choice != 206) //numpad too!
|
||||
{
|
||||
char keypad_translation[] = {'7','8','9','-','4','5','6','+','1','2','3','0','.'};
|
||||
choice = keypad_translation[choice - 199];
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
setupm_ip[l] = (char)choice;
|
||||
setupm_ip[l+1] = 0;
|
||||
if (M_TextInputHandle(&setupm_input_ip, choice))
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -10496,14 +10490,15 @@ static state_t *multi_state;
|
||||
|
||||
// this is set before entering the MultiPlayer setup menu,
|
||||
// for either player 1 or 2
|
||||
static char setupm_name[MAXPLAYERNAME+1];
|
||||
static player_t *setupm_player;
|
||||
static consvar_t *setupm_cvskin;
|
||||
static consvar_t *setupm_cvcolor;
|
||||
static consvar_t *setupm_cvname;
|
||||
static UINT8 setupm_skinxpos;
|
||||
static INT32 setupm_fakeskin;
|
||||
static INT32 setupm_fakecolor;
|
||||
static char setupm_name[MAXPLAYERNAME+1];
|
||||
static textinput_t setupm_input;
|
||||
static player_t *setupm_player;
|
||||
static consvar_t *setupm_cvskin;
|
||||
static consvar_t *setupm_cvcolor;
|
||||
static consvar_t *setupm_cvname;
|
||||
static UINT8 setupm_skinxpos;
|
||||
static INT32 setupm_fakeskin;
|
||||
static INT32 setupm_fakecolor;
|
||||
|
||||
//variables used for other skin select menus
|
||||
static UINT8 setupm_skinypos;
|
||||
@@ -10579,11 +10574,11 @@ static void M_DrawSetupMultiPlayerMenu(void)
|
||||
}
|
||||
|
||||
M_DrawTextBox(mx + 32, my - 8 + nameboxaddy, MAXPLAYERNAME, 1);
|
||||
V_DrawString(mx + 40, my + nameboxaddy, V_ALLOWLOWERCASE, setupm_name);
|
||||
|
||||
// draw text cursor for name
|
||||
if (!itemOn && skullAnimCounter < 4) // blink cursor
|
||||
V_DrawCharacter(mx + 40 + V_StringWidth(setupm_name, V_ALLOWLOWERCASE), my + nameboxaddy, '_', false);
|
||||
if (itemOn != 0)
|
||||
V_DrawString(mx + 40, my + nameboxaddy, V_ALLOWLOWERCASE, setupm_input.buffer);
|
||||
else
|
||||
M_DrawTextInput(mx + 40, my + nameboxaddy, &setupm_input, 0);
|
||||
|
||||
// draw skin string
|
||||
st = V_StringWidth(skins[setupm_fakeskin].realname, 0);
|
||||
@@ -11182,7 +11177,6 @@ static void M_DrawSetupMultiPlayerMenu(void)
|
||||
// Handle 1P/2P MP Setup
|
||||
static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
{
|
||||
size_t l;
|
||||
boolean exitmenu = false; // exit to previous menu and send name change
|
||||
|
||||
if ((choice == gamecontrol[gc_fire][0] || choice == gamecontrol[gc_fire][1]) && itemOn == 2)
|
||||
@@ -11304,7 +11298,12 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
break;
|
||||
|
||||
case KEY_LEFTARROW:
|
||||
if (cv_skinselectmenu.value == SKINMENUTYPE_2D && itemOn == 1)
|
||||
if (itemOn == 0)
|
||||
{
|
||||
M_TextInputHandle(&setupm_input, choice);
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
}
|
||||
else if (cv_skinselectmenu.value == SKINMENUTYPE_2D && itemOn == 1)
|
||||
{
|
||||
if (setupm_skinlockedselect)
|
||||
{
|
||||
@@ -11358,7 +11357,12 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
break;
|
||||
|
||||
case KEY_RIGHTARROW:
|
||||
if (cv_skinselectmenu.value == SKINMENUTYPE_2D && itemOn == 1)
|
||||
if (itemOn == 0)
|
||||
{
|
||||
M_TextInputHandle(&setupm_input, choice);
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
}
|
||||
else if (cv_skinselectmenu.value == SKINMENUTYPE_2D && itemOn == 1)
|
||||
{
|
||||
if (setupm_skinlockedselect)
|
||||
{
|
||||
@@ -11389,7 +11393,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
}
|
||||
else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED){
|
||||
if (setupm_skinselect >= ((setupm_skinypos-1)+SKINGRIDHEIGHT)*8+24 && setupm_skinypos < (ROUNDSKINSUPTO8/8)-SKINGRIDHEIGHT+24)
|
||||
setupm_skinypos++;
|
||||
setupm_skinypos++;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -11427,11 +11431,8 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
BREAKWHENLOCKED
|
||||
if (itemOn == 0)
|
||||
{
|
||||
if ((l = strlen(setupm_name))!=0)
|
||||
{
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
setupm_name[l-1] =0;
|
||||
}
|
||||
M_TextInputHandle(&setupm_input, choice);
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
}
|
||||
else if ((cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) && itemOn == 1)
|
||||
{
|
||||
@@ -11456,10 +11457,10 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
case KEY_DEL:
|
||||
if (cv_skinselectmenu.value)
|
||||
BREAKWHENLOCKED
|
||||
if (itemOn == 0 && (l = strlen(setupm_name))!=0)
|
||||
if (itemOn == 0)
|
||||
{
|
||||
M_TextInputHandle(&setupm_input, choice);
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
setupm_name[0] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -11496,17 +11497,10 @@ static void M_HandleSetupMultiPlayer(INT32 choice)
|
||||
break;
|
||||
|
||||
default:
|
||||
if (choice < 32 || choice > 127)
|
||||
break;
|
||||
if (itemOn == 0)
|
||||
{
|
||||
l = strlen(setupm_name);
|
||||
if (l < MAXPLAYERNAME)
|
||||
{
|
||||
if (M_TextInputHandle(&setupm_input, choice))
|
||||
S_StartSound(NULL,sfx_menu1); // Tails
|
||||
setupm_name[l] =(char)choice;
|
||||
setupm_name[l+1] =0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -11571,7 +11565,9 @@ static void M_SetupMultiPlayer(INT32 choice)
|
||||
|
||||
multi_state = cv_skinselectspin.value == SKINSELECTSPIN_PAIN ? &states[S_KART_PAIN] : &states[mobjinfo[MT_PLAYER].seestate];
|
||||
multi_tics = multi_state->tics*FRACUNIT;
|
||||
strcpy(setupm_name, cv_playername.string);
|
||||
|
||||
M_TextInputInit(&setupm_input, setupm_name, sizeof(setupm_name));
|
||||
M_TextInputSetString(&setupm_input, cv_playername.string);
|
||||
|
||||
// set for player 1
|
||||
setupm_player = &players[consoleplayer];
|
||||
@@ -11613,7 +11609,9 @@ static void M_SetupMultiPlayer2(INT32 choice)
|
||||
|
||||
multi_state = cv_skinselectspin.value == SKINSELECTSPIN_PAIN ? &states[S_KART_PAIN] : &states[mobjinfo[MT_PLAYER].seestate];
|
||||
multi_tics = multi_state->tics*FRACUNIT;
|
||||
strcpy (setupm_name, cv_playername2.string);
|
||||
|
||||
M_TextInputInit(&setupm_input, setupm_name, sizeof(setupm_name));
|
||||
M_TextInputSetString(&setupm_input, cv_playername2.string);
|
||||
|
||||
// set for splitscreen secondary player
|
||||
setupm_player = &players[displayplayers[1]];
|
||||
@@ -11654,7 +11652,9 @@ static void M_SetupMultiPlayer3(INT32 choice)
|
||||
|
||||
multi_state = cv_skinselectspin.value == SKINSELECTSPIN_PAIN ? &states[S_KART_PAIN] : &states[mobjinfo[MT_PLAYER].seestate];
|
||||
multi_tics = multi_state->tics;
|
||||
strcpy(setupm_name, cv_playername3.string);
|
||||
|
||||
M_TextInputInit(&setupm_input, setupm_name, sizeof(setupm_name));
|
||||
M_TextInputSetString(&setupm_input, cv_playername3.string);
|
||||
|
||||
// set for splitscreen third player
|
||||
setupm_player = &players[displayplayers[2]];
|
||||
@@ -11695,7 +11695,9 @@ static void M_SetupMultiPlayer4(INT32 choice)
|
||||
|
||||
multi_state = cv_skinselectspin.value == SKINSELECTSPIN_PAIN ? &states[S_KART_PAIN] : &states[mobjinfo[MT_PLAYER].seestate];
|
||||
multi_tics = multi_state->tics;
|
||||
strcpy(setupm_name, cv_playername4.string);
|
||||
|
||||
M_TextInputInit(&setupm_input, setupm_name, sizeof(setupm_name));
|
||||
M_TextInputSetString(&setupm_input, cv_playername4.string);
|
||||
|
||||
// set for splitscreen fourth player
|
||||
setupm_player = &players[displayplayers[3]];
|
||||
@@ -12879,10 +12881,12 @@ static void M_DrawColorMenu(void)
|
||||
if (y + 12 > (currentMenu->y + 2*scrollareaheight))
|
||||
break;
|
||||
M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1);
|
||||
V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, cv->string);
|
||||
if (skullAnimCounter < 4 && i == itemOn)
|
||||
V_DrawCharacter(x + 8 + V_StringWidth(cv->string, 0), y + 12,
|
||||
'_' | 0x80, false);
|
||||
|
||||
if (itemOn == i)
|
||||
M_DrawTextInput(x + 8, y + 12, &menuinput, 0);
|
||||
else
|
||||
V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, cv->string);
|
||||
|
||||
y += 16;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -64,6 +64,10 @@ void M_DrawTextBox(INT32 x, INT32 y, INT32 width, INT32 boxlines);
|
||||
// Same but with extra flags applied
|
||||
void M_DrawTextBoxFlags(INT32 x, INT32 y, INT32 width, INT32 boxlines, INT32 flags);
|
||||
|
||||
// Draw text input
|
||||
typedef struct textinput_s textinput_t;
|
||||
void M_DrawTextInput(INT32 x, INT32 y, textinput_t *input, INT32 flags);
|
||||
|
||||
// Used in d_netcmd to restart time attack
|
||||
void M_ModeAttackRetry(INT32 choice);
|
||||
|
||||
|
||||
@@ -1987,11 +1987,6 @@ char *sizeu5(size_t num)
|
||||
return sizeu5_buf;
|
||||
}
|
||||
|
||||
FUNCINLINE ATTRINLINE void *M_Memcpy(void *dest, const void *src, size_t n)
|
||||
{
|
||||
return memcpy(dest, src, n);
|
||||
}
|
||||
|
||||
/** Return the appropriate message for a file error or end of file.
|
||||
*/
|
||||
const char *M_FileError(FILE *fp)
|
||||
|
||||
@@ -0,0 +1,303 @@
|
||||
#include "m_textinput.h"
|
||||
#include "i_system.h"
|
||||
#include "keys.h"
|
||||
#include "console.h"
|
||||
|
||||
static void M_TextInputDel(textinput_t *input, size_t start, size_t end)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
len = (end - start);
|
||||
|
||||
if (end != input->length)
|
||||
memmove(&input->buffer[start], &input->buffer[end], input->length-end);
|
||||
memset(&input->buffer[input->length - len], 0, len);
|
||||
|
||||
input->length -= len;
|
||||
|
||||
if (input->select >= end)
|
||||
input->select -= len;
|
||||
else if (input->select > start)
|
||||
input->select = start;
|
||||
|
||||
if (input->cursor >= end)
|
||||
input->cursor -= len;
|
||||
else if (input->cursor > start)
|
||||
input->cursor = start;
|
||||
}
|
||||
|
||||
static void M_TextInputDelSelection(textinput_t *input)
|
||||
{
|
||||
size_t start, end;
|
||||
|
||||
if (input->cursor > input->select)
|
||||
{
|
||||
start = input->select;
|
||||
end = input->cursor;
|
||||
}
|
||||
else
|
||||
{
|
||||
start = input->cursor;
|
||||
end = input->select;
|
||||
}
|
||||
|
||||
M_TextInputDel(input, start, end);
|
||||
|
||||
input->select = input->cursor = start;
|
||||
}
|
||||
|
||||
static void M_TextInputAddString(textinput_t *input, const char *c)
|
||||
{
|
||||
size_t csize = strlen(c);
|
||||
|
||||
if (input->length + csize > input->buffer_size-1)
|
||||
return;
|
||||
|
||||
if (input->cursor != input->length)
|
||||
memmove(&input->buffer[input->cursor+csize], &input->buffer[input->cursor], input->length-input->cursor);
|
||||
memcpy(&input->buffer[input->cursor], c, csize);
|
||||
input->length += csize;
|
||||
input->select = (input->cursor += csize);
|
||||
input->buffer[input->length] = 0;
|
||||
}
|
||||
|
||||
static void M_TextInputAddChar(textinput_t *input, char c)
|
||||
{
|
||||
if (input->length >= input->buffer_size-1)
|
||||
return;
|
||||
|
||||
if (input->cursor != input->length)
|
||||
memmove(&input->buffer[input->cursor+1], &input->buffer[input->cursor], input->length-input->cursor);
|
||||
input->buffer[input->cursor++] = c;
|
||||
input->buffer[++input->length] = 0;
|
||||
input->select = input->cursor;
|
||||
}
|
||||
|
||||
static void M_TextInputDelChar(textinput_t *input)
|
||||
{
|
||||
if (!input->cursor)
|
||||
return;
|
||||
|
||||
if (input->cursor != input->length)
|
||||
memmove(&input->buffer[input->cursor-1], &input->buffer[input->cursor], input->length-input->cursor);
|
||||
input->buffer[--input->length] = 0;
|
||||
input->select = --input->cursor;
|
||||
}
|
||||
|
||||
static void M_TextInputToWordEnd(textinput_t *input, boolean move_sel)
|
||||
{
|
||||
// Skip spaces
|
||||
while (input->cursor < input->length && isspace(input->buffer[input->cursor]))
|
||||
++input->cursor;
|
||||
|
||||
// Skip word
|
||||
while (input->cursor < input->length && !isspace(input->buffer[input->cursor]))
|
||||
++input->cursor;
|
||||
|
||||
if (move_sel) input->select = input->cursor;
|
||||
}
|
||||
|
||||
static void M_TextInputToWordBegin(textinput_t *input, boolean move_sel)
|
||||
{
|
||||
// Hack, always move back 1 character if possible so if we press ctrl-left at a word beginning
|
||||
// we move to previous word
|
||||
if (input->cursor) --input->cursor;
|
||||
|
||||
// Skip spaces
|
||||
while (input->cursor && isspace(input->buffer[input->cursor]))
|
||||
--input->cursor;
|
||||
|
||||
// Skip word
|
||||
while (input->cursor && !isspace(input->buffer[input->cursor]))
|
||||
--input->cursor;
|
||||
|
||||
// Unless we reached beginning of line, we're pointing at a space before word, so move cursor
|
||||
// forward to fix that
|
||||
if (input->cursor) ++input->cursor;
|
||||
|
||||
if (move_sel) input->select = input->cursor;
|
||||
}
|
||||
|
||||
void M_TextInputInit(textinput_t *input, char *buffer, size_t buffer_size)
|
||||
{
|
||||
input->buffer = buffer;
|
||||
input->buffer_size = buffer_size;
|
||||
|
||||
M_TextInputClear(input);
|
||||
}
|
||||
|
||||
void M_TextInputClear(textinput_t *input)
|
||||
{
|
||||
input->cursor = 0;
|
||||
input->select = 0;
|
||||
input->length = 0;
|
||||
}
|
||||
|
||||
void M_TextInputSetString(textinput_t *input, const char *c)
|
||||
{
|
||||
memset(input->buffer, 0, input->buffer_size);
|
||||
strcpy(input->buffer, c);
|
||||
input->cursor = input->select = input->length = strlen(c);
|
||||
}
|
||||
|
||||
boolean M_TextInputHandle(textinput_t *input, INT32 key)
|
||||
{
|
||||
if (key == KEY_LSHIFT || key == KEY_RSHIFT
|
||||
|| key == KEY_LCTRL || key == KEY_RCTRL
|
||||
|| key == KEY_LALT || key == KEY_RALT)
|
||||
return false;
|
||||
|
||||
if ((cv_keyboardlayout.value != 3 && ctrldown) || (cv_keyboardlayout.value == 3 && ctrldown && !altdown))
|
||||
{
|
||||
if (key == 'x' || key == 'X')
|
||||
{
|
||||
if (input->select > input->cursor)
|
||||
I_ClipboardCopy(&input->buffer[input->cursor], input->select-input->cursor);
|
||||
else
|
||||
I_ClipboardCopy(&input->buffer[input->select], input->cursor-input->select);
|
||||
M_TextInputDelSelection(input);
|
||||
return true;
|
||||
}
|
||||
else if (key == 'c' || key == 'C')
|
||||
{
|
||||
if (input->select > input->cursor)
|
||||
I_ClipboardCopy(&input->buffer[input->cursor], input->select-input->cursor);
|
||||
else
|
||||
I_ClipboardCopy(&input->buffer[input->select], input->cursor-input->select);
|
||||
return true;
|
||||
}
|
||||
else if (key == 'v' || key == 'V')
|
||||
{
|
||||
const char *paste = I_ClipboardPaste();
|
||||
if (input->select != input->cursor)
|
||||
M_TextInputDelSelection(input);
|
||||
if (paste != NULL)
|
||||
M_TextInputAddString(input, paste);
|
||||
return true;
|
||||
}
|
||||
else if (key == 'w' || key == 'W')
|
||||
{
|
||||
size_t word_start, word_end, i;
|
||||
word_end = i = input->cursor;
|
||||
|
||||
// Unless we're pointing at the beginning of line, decrement i so we only start
|
||||
// removing symbols that come before the cursor
|
||||
if (i) --i;
|
||||
|
||||
// We might be pointing to spaces, skip them first
|
||||
while (i && isspace(input->buffer[i]))
|
||||
--i;
|
||||
|
||||
// Now skip the "word"
|
||||
while (i && !isspace(input->buffer[i]))
|
||||
--i;
|
||||
|
||||
// Unless we reached beginning of line, i is pointing at first space that was found
|
||||
// before word start, and we don't want to remove it
|
||||
if (i) ++i;
|
||||
|
||||
word_start = i;
|
||||
|
||||
if (word_start != word_end)
|
||||
M_TextInputDel(input, word_start, word_end);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (key == KEY_RIGHTARROW)
|
||||
M_TextInputToWordEnd(input, !shiftdown);
|
||||
else if (key == KEY_LEFTARROW)
|
||||
M_TextInputToWordBegin(input, !shiftdown);
|
||||
|
||||
// Select all
|
||||
if (key == 'a' || key == 'A')
|
||||
{
|
||||
input->select = 0;
|
||||
input->cursor = input->length;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ...why shouldn't it eat the key? if it doesn't, it just means you
|
||||
// can control Sonic from the console, which is silly
|
||||
return true;
|
||||
}
|
||||
|
||||
if (key == KEY_LEFTARROW)
|
||||
{
|
||||
if (input->cursor != 0)
|
||||
--input->cursor;
|
||||
if (!shiftdown)
|
||||
input->select = input->cursor;
|
||||
return true;
|
||||
}
|
||||
else if (key == KEY_RIGHTARROW)
|
||||
{
|
||||
if (input->cursor < input->length)
|
||||
++input->cursor;
|
||||
if (!shiftdown)
|
||||
input->select = input->cursor;
|
||||
return true;
|
||||
}
|
||||
else if (key == KEY_HOME)
|
||||
{
|
||||
input->cursor = 0;
|
||||
if (!shiftdown)
|
||||
input->select = input->cursor;
|
||||
return true;
|
||||
}
|
||||
else if (key == KEY_END)
|
||||
{
|
||||
input->cursor = input->length;
|
||||
if (!shiftdown)
|
||||
input->select = input->cursor;
|
||||
return true;
|
||||
}
|
||||
|
||||
// backspace and delete command prompt
|
||||
if (input->select != input->cursor)
|
||||
{
|
||||
if (key == KEY_BACKSPACE || key == KEY_DEL)
|
||||
{
|
||||
M_TextInputDelSelection(input);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (key == KEY_BACKSPACE)
|
||||
{
|
||||
M_TextInputDelChar(input);
|
||||
return true;
|
||||
}
|
||||
else if (key == KEY_DEL)
|
||||
{
|
||||
if (input->cursor == input->length)
|
||||
return true;
|
||||
++input->cursor;
|
||||
M_TextInputDelChar(input);
|
||||
return true;
|
||||
}
|
||||
|
||||
// allow people to use keypad in console (good for typing IP addresses) - Calum
|
||||
if (key >= KEY_KEYPAD7 && key <= KEY_KPADDEL)
|
||||
{
|
||||
char keypad_translation[] = {'7','8','9','-',
|
||||
'4','5','6','+',
|
||||
'1','2','3',
|
||||
'0','.'};
|
||||
|
||||
key = keypad_translation[key - KEY_KEYPAD7];
|
||||
}
|
||||
else if (key == KEY_KPADSLASH)
|
||||
key = '/';
|
||||
|
||||
// same capslock code as hu_stuff.c's HU_responder. Check there for details.
|
||||
key = cv_keyboardlayout.value == 3 ? CON_ShitAndAltGrChar(key) : CON_ShiftChar(key);
|
||||
|
||||
// enter a char into the command prompt
|
||||
if (key < 32 || key > 127)
|
||||
return false;
|
||||
|
||||
if (input->select != input->cursor)
|
||||
M_TextInputDelSelection(input);
|
||||
M_TextInputAddChar(input, key);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef __M_TEXTINPUT__
|
||||
#define __M_TEXTINPUT__
|
||||
|
||||
#include "doomtype.h"
|
||||
|
||||
typedef struct textinput_s {
|
||||
size_t cursor;
|
||||
size_t select;
|
||||
size_t length;
|
||||
|
||||
char *buffer;
|
||||
size_t buffer_size;
|
||||
} textinput_t;
|
||||
|
||||
void M_TextInputInit(textinput_t *input, char *buffer, size_t buffer_size);
|
||||
|
||||
void M_TextInputClear(textinput_t *input);
|
||||
|
||||
void M_TextInputSetString(textinput_t *input, const char *c);
|
||||
|
||||
boolean M_TextInputHandle(textinput_t *input, INT32 key);
|
||||
|
||||
#endif
|
||||
+1
-2
@@ -2564,8 +2564,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||
P_PlayerRingBurst(player, 5);
|
||||
if (P_IsLocalPlayer(player))
|
||||
{
|
||||
quake.intensity = 32*FRACUNIT;
|
||||
quake.time = 5;
|
||||
P_StartQuake(5, 32<<FRACBITS, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
+10
-3
@@ -164,8 +164,9 @@ void P_InitCameraCmd(void);
|
||||
boolean P_PlayerInPain(player_t *player);
|
||||
void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor);
|
||||
void P_ResetPlayer(player_t *player);
|
||||
boolean P_IsLocalPlayer(player_t *player);
|
||||
boolean P_IsDisplayPlayer(player_t *player);
|
||||
boolean P_IsLocalPlayer(const player_t *player);
|
||||
boolean P_IsDisplayPlayer(const player_t *player);
|
||||
|
||||
boolean P_SpectatorJoinGame(player_t *player);
|
||||
|
||||
boolean P_IsObjectInGoop(mobj_t *mo);
|
||||
@@ -248,7 +249,7 @@ void P_RecalcPrecipInSector(sector_t *sector);
|
||||
void P_PrecipitationEffects(void);
|
||||
|
||||
void P_RemoveMobj(mobj_t *th);
|
||||
boolean P_MobjWasRemoved(const mobj_t *th);
|
||||
|
||||
void P_RemoveSavegameMobj(mobj_t *th);
|
||||
boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state);
|
||||
boolean P_SetMobjState(mobj_t *mobj, statenum_t state);
|
||||
@@ -260,6 +261,12 @@ boolean P_RailThinker(mobj_t *mobj);
|
||||
void P_PushableThinker(mobj_t *mobj);
|
||||
void P_SceneryThinker(mobj_t *mobj);
|
||||
|
||||
// This does not need to be added to Lua.
|
||||
// To test it in Lua, check mobj.valid
|
||||
FUNCINLINE static ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj)
|
||||
{
|
||||
return !(mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker);
|
||||
}
|
||||
|
||||
fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect);
|
||||
fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t x, fixed_t y, line_t *line, boolean lowest, boolean perfect);
|
||||
|
||||
+40
-45
@@ -592,7 +592,8 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t
|
||||
{
|
||||
I_Assert(mobj != NULL);
|
||||
I_Assert(sector != NULL);
|
||||
if (sector->f_slope) {
|
||||
if (sector->f_slope)
|
||||
{
|
||||
fixed_t testx, testy;
|
||||
pslope_t *slope = sector->f_slope;
|
||||
|
||||
@@ -607,7 +608,8 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t
|
||||
else
|
||||
testy = -mobj->radius;
|
||||
|
||||
if ((slope->zdelta > 0) ^ !!(lowest)) {
|
||||
if ((slope->zdelta > 0) ^ !!(lowest))
|
||||
{
|
||||
testx = -testx;
|
||||
testy = -testy;
|
||||
}
|
||||
@@ -620,22 +622,21 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t
|
||||
return P_GetZAt(slope, testx, testy);
|
||||
|
||||
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
|
||||
if (perfect) {
|
||||
if (perfect)
|
||||
{
|
||||
size_t i;
|
||||
line_t *ld;
|
||||
fixed_t bbox[4];
|
||||
fixed_t finalheight;
|
||||
|
||||
if (lowest)
|
||||
finalheight = INT32_MAX;
|
||||
else
|
||||
finalheight = INT32_MIN;
|
||||
finalheight = lowest ? INT32_MAX : INT32_MIN;
|
||||
|
||||
bbox[BOXLEFT] = x-mobj->radius;
|
||||
bbox[BOXRIGHT] = x+mobj->radius;
|
||||
bbox[BOXTOP] = y+mobj->radius;
|
||||
bbox[BOXBOTTOM] = y-mobj->radius;
|
||||
for (i = 0; i < boundsec->linecount; i++) {
|
||||
for (i = 0; i < boundsec->linecount; i++)
|
||||
{
|
||||
ld = boundsec->lines[i];
|
||||
|
||||
if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT]
|
||||
@@ -668,7 +669,8 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed
|
||||
{
|
||||
I_Assert(mobj != NULL);
|
||||
I_Assert(sector != NULL);
|
||||
if (sector->c_slope) {
|
||||
if (sector->c_slope)
|
||||
{
|
||||
fixed_t testx, testy;
|
||||
pslope_t *slope = sector->c_slope;
|
||||
|
||||
@@ -683,7 +685,8 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed
|
||||
else
|
||||
testy = -mobj->radius;
|
||||
|
||||
if ((slope->zdelta > 0) ^ !!(lowest)) {
|
||||
if ((slope->zdelta > 0) ^ !!(lowest))
|
||||
{
|
||||
testx = -testx;
|
||||
testy = -testy;
|
||||
}
|
||||
@@ -696,22 +699,21 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed
|
||||
return P_GetZAt(slope, testx, testy);
|
||||
|
||||
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
|
||||
if (perfect) {
|
||||
if (perfect)
|
||||
{
|
||||
size_t i;
|
||||
line_t *ld;
|
||||
fixed_t bbox[4];
|
||||
fixed_t finalheight;
|
||||
|
||||
if (lowest)
|
||||
finalheight = INT32_MAX;
|
||||
else
|
||||
finalheight = INT32_MIN;
|
||||
finalheight = lowest ? INT32_MAX : INT32_MIN;
|
||||
|
||||
bbox[BOXLEFT] = x-mobj->radius;
|
||||
bbox[BOXRIGHT] = x+mobj->radius;
|
||||
bbox[BOXTOP] = y+mobj->radius;
|
||||
bbox[BOXBOTTOM] = y-mobj->radius;
|
||||
for (i = 0; i < boundsec->linecount; i++) {
|
||||
for (i = 0; i < boundsec->linecount; i++)
|
||||
{
|
||||
ld = boundsec->lines[i];
|
||||
|
||||
if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT]
|
||||
@@ -746,7 +748,8 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix
|
||||
I_Assert(mobj != NULL);
|
||||
I_Assert(sector != NULL);
|
||||
|
||||
if (sector->f_slope) {
|
||||
if (sector->f_slope)
|
||||
{
|
||||
fixed_t testx, testy;
|
||||
pslope_t *slope = sector->f_slope;
|
||||
|
||||
@@ -761,7 +764,8 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix
|
||||
else
|
||||
testy = -mobj->radius;
|
||||
|
||||
if ((slope->zdelta > 0) ^ !!(lowest)) {
|
||||
if ((slope->zdelta > 0) ^ !!(lowest))
|
||||
{
|
||||
testx = -testx;
|
||||
testy = -testy;
|
||||
}
|
||||
@@ -774,22 +778,21 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix
|
||||
return P_GetZAt(slope, testx, testy);
|
||||
|
||||
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
|
||||
if (perfect) {
|
||||
if (perfect)
|
||||
{
|
||||
size_t i;
|
||||
line_t *ld;
|
||||
fixed_t bbox[4];
|
||||
fixed_t finalheight;
|
||||
|
||||
if (lowest)
|
||||
finalheight = INT32_MAX;
|
||||
else
|
||||
finalheight = INT32_MIN;
|
||||
finalheight = lowest ? INT32_MAX : INT32_MIN;
|
||||
|
||||
bbox[BOXLEFT] = x-mobj->radius;
|
||||
bbox[BOXRIGHT] = x+mobj->radius;
|
||||
bbox[BOXTOP] = y+mobj->radius;
|
||||
bbox[BOXBOTTOM] = y-mobj->radius;
|
||||
for (i = 0; i < boundsec->linecount; i++) {
|
||||
for (i = 0; i < boundsec->linecount; i++)
|
||||
{
|
||||
ld = boundsec->lines[i];
|
||||
|
||||
if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT]
|
||||
@@ -823,7 +826,8 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f
|
||||
I_Assert(mobj != NULL);
|
||||
I_Assert(sector != NULL);
|
||||
|
||||
if (sector->c_slope) {
|
||||
if (sector->c_slope)
|
||||
{
|
||||
fixed_t testx, testy;
|
||||
pslope_t *slope = sector->c_slope;
|
||||
|
||||
@@ -838,7 +842,8 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f
|
||||
else
|
||||
testy = -mobj->radius;
|
||||
|
||||
if ((slope->zdelta > 0) ^ !!(lowest)) {
|
||||
if ((slope->zdelta > 0) ^ !!(lowest))
|
||||
{
|
||||
testx = -testx;
|
||||
testy = -testy;
|
||||
}
|
||||
@@ -851,22 +856,21 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f
|
||||
return P_GetZAt(slope, testx, testy);
|
||||
|
||||
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
|
||||
if (perfect) {
|
||||
if (perfect)
|
||||
{
|
||||
size_t i;
|
||||
line_t *ld;
|
||||
fixed_t bbox[4];
|
||||
fixed_t finalheight;
|
||||
|
||||
if (lowest)
|
||||
finalheight = INT32_MAX;
|
||||
else
|
||||
finalheight = INT32_MIN;
|
||||
finalheight = lowest ? INT32_MAX : INT32_MIN;
|
||||
|
||||
bbox[BOXLEFT] = x-mobj->radius;
|
||||
bbox[BOXRIGHT] = x+mobj->radius;
|
||||
bbox[BOXTOP] = y+mobj->radius;
|
||||
bbox[BOXBOTTOM] = y-mobj->radius;
|
||||
for (i = 0; i < boundsec->linecount; i++) {
|
||||
for (i = 0; i < boundsec->linecount; i++)
|
||||
{
|
||||
ld = boundsec->lines[i];
|
||||
|
||||
if (bbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || bbox[BOXLEFT] >= ld->bbox[BOXRIGHT]
|
||||
@@ -6034,7 +6038,7 @@ void P_RollPitchMobj(mobj_t* mobj)
|
||||
if (cv_sloperolldist.value > 0)
|
||||
usedist = true;
|
||||
|
||||
if ((cv_spriteroll.value) && (cv_sloperoll.value == 2))
|
||||
if (cv_spriteroll.value && cv_sloperoll.value == 2)
|
||||
{
|
||||
K_RollMobjBySlopes(mobj, usedist);
|
||||
}
|
||||
@@ -6260,7 +6264,7 @@ void P_MobjThinker(mobj_t *mobj)
|
||||
return;
|
||||
}
|
||||
|
||||
if (mobj->state == &states[S_SHADOW] && cv_sloperoll.value == 2)
|
||||
if (cv_sloperoll.value == 2 && mobj->state == &states[S_SHADOW])
|
||||
{
|
||||
mobj->slopepitch = mobj->target->slopepitch;
|
||||
mobj->sloperoll = mobj->target->sloperoll;
|
||||
@@ -10136,13 +10140,6 @@ void P_RemoveMobj(mobj_t *mobj)
|
||||
}
|
||||
}
|
||||
|
||||
// This does not need to be added to Lua.
|
||||
// To test it in Lua, check mobj.valid
|
||||
FUNCINLINE ATTRINLINE boolean P_MobjWasRemoved(const mobj_t *mobj)
|
||||
{
|
||||
return !(mobj && mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker);
|
||||
}
|
||||
|
||||
void P_FreePrecipMobj(precipmobj_t *mobj)
|
||||
{
|
||||
// unlink from sector and block lists
|
||||
@@ -10237,6 +10234,7 @@ void P_SpawnPrecipitation(void)
|
||||
// Not in a sector with visible sky?
|
||||
if (precipsector->sector->ceilingpic != skyflatnum)
|
||||
continue;
|
||||
|
||||
// Exists, but is too small for reasonable precipitation.
|
||||
if (!(precipsector->sector->floorheight <= precipsector->sector->ceilingheight - (32<<FRACBITS)))
|
||||
continue;
|
||||
@@ -10382,10 +10380,7 @@ void P_PrecipitationEffects(void)
|
||||
volume = 255 - (closedist>>(FRACBITS+2));
|
||||
}
|
||||
|
||||
if (volume < 0)
|
||||
volume = 0;
|
||||
else if (volume > 255)
|
||||
volume = 255;
|
||||
volume = CLAMP(volume, 0, 255);
|
||||
|
||||
if (sounds_rain && (!leveltime || leveltime % 80 == 1))
|
||||
S_StartSoundAtVolume(players[displayplayers[0]].mo, sfx_rainin, volume);
|
||||
|
||||
+2
-1
@@ -28,6 +28,7 @@
|
||||
#include "r_main.h"
|
||||
#include "r_state.h"
|
||||
#include "r_defs.h"
|
||||
#include "qs22j.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -580,7 +581,7 @@ static void Polyobj_findExplicit(polyobj_t *po)
|
||||
|
||||
// sort the array if necessary
|
||||
if (numSegItems >= 2)
|
||||
qsort(segitems, numSegItems, sizeof(segitem_t), Polyobj_segCompare);
|
||||
qs22j(segitems, numSegItems, sizeof(segitem_t), Polyobj_segCompare);
|
||||
|
||||
// second loop: put the sorted segs into the polyobject
|
||||
for (i = 0; i < numSegItems; ++i)
|
||||
|
||||
+15
-25
@@ -3031,11 +3031,17 @@ static inline void P_FinishMobjs(void)
|
||||
}
|
||||
}
|
||||
|
||||
static inline mobj_t *RelinkMobj(mobj_t **ptr)
|
||||
{
|
||||
UINT32 temp = (UINT32)(size_t)*ptr;
|
||||
*ptr = NULL;
|
||||
return P_SetTarget(ptr, P_FindNewPosition(temp));
|
||||
}
|
||||
|
||||
static void P_RelinkPointers(void)
|
||||
{
|
||||
thinker_t *currentthinker;
|
||||
mobj_t *mobj;
|
||||
UINT32 temp;
|
||||
|
||||
// use info field (value = oldposition) to relink mobjs
|
||||
for (currentthinker = thinkercap.next; currentthinker != &thinkercap;
|
||||
@@ -3051,58 +3057,42 @@ static void P_RelinkPointers(void)
|
||||
|
||||
if (mobj->tracer)
|
||||
{
|
||||
temp = (UINT32)(size_t)mobj->tracer;
|
||||
mobj->tracer = NULL;
|
||||
if (!P_SetTarget(&mobj->tracer, P_FindNewPosition(temp)))
|
||||
if (!RelinkMobj(&mobj->tracer))
|
||||
CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type);
|
||||
}
|
||||
if (mobj->target)
|
||||
{
|
||||
temp = (UINT32)(size_t)mobj->target;
|
||||
mobj->target = NULL;
|
||||
if (!P_SetTarget(&mobj->target, P_FindNewPosition(temp)))
|
||||
if (!RelinkMobj(&mobj->target))
|
||||
CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type);
|
||||
}
|
||||
if (mobj->hnext)
|
||||
{
|
||||
temp = (UINT32)(size_t)mobj->hnext;
|
||||
mobj->hnext = NULL;
|
||||
if (!P_SetTarget(&mobj->hnext, P_FindNewPosition(temp)))
|
||||
if (!RelinkMobj(&mobj->hnext))
|
||||
CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type);
|
||||
}
|
||||
if (mobj->hprev)
|
||||
{
|
||||
temp = (UINT32)(size_t)mobj->hprev;
|
||||
mobj->hprev = NULL;
|
||||
if (!P_SetTarget(&mobj->hprev, P_FindNewPosition(temp)))
|
||||
if (!RelinkMobj(&mobj->hprev))
|
||||
CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type);
|
||||
}
|
||||
if (mobj->player && mobj->player->capsule)
|
||||
{
|
||||
temp = (UINT32)(size_t)mobj->player->capsule;
|
||||
mobj->player->capsule = NULL;
|
||||
if (!P_SetTarget(&mobj->player->capsule, P_FindNewPosition(temp)))
|
||||
if (!RelinkMobj(&mobj->player->capsule))
|
||||
CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type);
|
||||
}
|
||||
if (mobj->player && mobj->player->axis1)
|
||||
{
|
||||
temp = (UINT32)(size_t)mobj->player->axis1;
|
||||
mobj->player->axis1 = NULL;
|
||||
if (!P_SetTarget(&mobj->player->axis1, P_FindNewPosition(temp)))
|
||||
if (!RelinkMobj(&mobj->player->axis1))
|
||||
CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type);
|
||||
}
|
||||
if (mobj->player && mobj->player->axis2)
|
||||
{
|
||||
temp = (UINT32)(size_t)mobj->player->axis2;
|
||||
mobj->player->axis2 = NULL;
|
||||
if (!P_SetTarget(&mobj->player->axis2, P_FindNewPosition(temp)))
|
||||
if (!RelinkMobj(&mobj->player->axis2))
|
||||
CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type);
|
||||
}
|
||||
if (mobj->player && mobj->player->awayviewmobj)
|
||||
{
|
||||
temp = (UINT32)(size_t)mobj->player->awayviewmobj;
|
||||
mobj->player->awayviewmobj = NULL;
|
||||
if (!P_SetTarget(&mobj->player->awayviewmobj, P_FindNewPosition(temp)))
|
||||
if (!RelinkMobj(&mobj->player->awayviewmobj))
|
||||
CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type);
|
||||
}
|
||||
}
|
||||
|
||||
+42
-10
@@ -2179,9 +2179,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
||||
mapmusflags |= MUSIC_FORCERESET;
|
||||
|
||||
mapmusposition = position;
|
||||
|
||||
if (cv_birdmusic.value)
|
||||
mapmusresume = 0;
|
||||
mapmusresume = 0;
|
||||
|
||||
S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position,
|
||||
!(line->flags & ML_EFFECT2) ? prefadems : 0,
|
||||
@@ -2485,6 +2483,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
||||
case 422: // Cut away to another view
|
||||
{
|
||||
mobj_t *altview;
|
||||
INT32 i;
|
||||
|
||||
if (!mo || !mo->player) // only players have views
|
||||
return;
|
||||
@@ -2499,6 +2498,18 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
||||
P_SetTarget(&mo->player->awayviewmobj, altview);
|
||||
mo->player->awayviewtics = P_AproxDistance(line->dx, line->dy)>>FRACBITS;
|
||||
|
||||
if (gamestate == GS_LEVEL)
|
||||
{
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
if (displayplayers[i] == (mo->player - players))
|
||||
{
|
||||
R_ResetViewInterpolation(i + 1);
|
||||
R_ResetViewInterpolation(i + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (line->flags & ML_NOCLIMB) // lets you specify a vertical angle
|
||||
{
|
||||
INT32 aim;
|
||||
@@ -2836,17 +2847,19 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
||||
|
||||
case 444: // Earthquake camera
|
||||
{
|
||||
quake.intensity = sides[line->sidenum[0]].textureoffset;
|
||||
quake.radius = sides[line->sidenum[0]].rowoffset;
|
||||
quake.time = P_AproxDistance(line->dx, line->dy)>>FRACBITS;
|
||||
fixed_t intensity = sides[line->sidenum[0]].textureoffset;
|
||||
fixed_t radius = sides[line->sidenum[0]].rowoffset;
|
||||
tic_t time = P_AproxDistance(line->dx, line->dy)>>FRACBITS;
|
||||
|
||||
quake.epicenter = NULL; /// \todo
|
||||
|
||||
// reasonable defaults.
|
||||
if (!quake.intensity)
|
||||
quake.intensity = 8<<FRACBITS;
|
||||
if (!quake.radius)
|
||||
quake.radius = 512<<FRACBITS;
|
||||
if (intensity <= 0)
|
||||
intensity = 8<<FRACBITS;
|
||||
if (radius <= 0)
|
||||
radius = 512<<FRACBITS;
|
||||
|
||||
P_StartQuake(time, intensity, radius);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5308,6 +5321,8 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate)
|
||||
curWeather = PRECIP_STORM_NORAIN;
|
||||
else if (mapheaderinfo[gamemap-1]->weather == 6) // storm w/o lightning
|
||||
curWeather = PRECIP_STORM_NOSTRIKES;
|
||||
else if (mapheaderinfo[gamemap-1]->weather == 4) // blank
|
||||
curWeather = PRECIP_BLANK;
|
||||
else
|
||||
curWeather = PRECIP_NONE;
|
||||
|
||||
@@ -7544,6 +7559,23 @@ static void P_SpawnPushers(void)
|
||||
}
|
||||
}
|
||||
|
||||
void P_StartQuake(tic_t time, fixed_t intensity, fixed_t radius)
|
||||
{
|
||||
if (time <= 0 || intensity <= 0)
|
||||
{
|
||||
// Invalid parameters
|
||||
return;
|
||||
}
|
||||
|
||||
quake.time = time;
|
||||
quake.intensity = FixedMul(intensity, mapobjectscale);
|
||||
|
||||
if (radius > 0)
|
||||
{
|
||||
quake.radius = FixedMul(radius, mapobjectscale);
|
||||
}
|
||||
}
|
||||
|
||||
static void P_SearchForDisableLinedefs(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@@ -454,4 +454,6 @@ void P_CalcHeight(player_t *player);
|
||||
|
||||
sector_t *P_ThingOnSpecial3DFloor(mobj_t *mo);
|
||||
|
||||
void P_StartQuake(tic_t time, fixed_t intensity, fixed_t radius);
|
||||
|
||||
#endif
|
||||
@@ -166,6 +166,7 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle
|
||||
P_ResetCamera(thing->player, &camera[i]);
|
||||
|
||||
R_ResetViewInterpolation(i + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
// don't run in place after a teleport
|
||||
|
||||
+35
-20
@@ -397,6 +397,36 @@ void P_RunChaseCameras(void)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void P_RunQuakes(void)
|
||||
{
|
||||
fixed_t ir;
|
||||
|
||||
if (quake.time <= 0)
|
||||
{
|
||||
quake.x = quake.y = quake.z = quake.roll = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
ir = quake.intensity>>1;
|
||||
|
||||
/// \todo Calculate distance from epicenter if set and modulate the intensity accordingly based on radius.
|
||||
quake.x = M_RandomRange(-ir,ir);
|
||||
quake.y = M_RandomRange(-ir,ir);
|
||||
quake.z = M_RandomRange(-ir,ir);
|
||||
|
||||
ir >>= 2;
|
||||
ir = M_RandomRange(-ir,ir);
|
||||
|
||||
if (ir < 0)
|
||||
ir = ANGLE_MAX - FixedAngle(-ir);
|
||||
else
|
||||
ir = FixedAngle(ir);
|
||||
|
||||
quake.roll = ir;
|
||||
|
||||
--quake.time;
|
||||
}
|
||||
|
||||
//
|
||||
// P_Ticker
|
||||
//
|
||||
@@ -429,6 +459,8 @@ void P_Ticker(boolean run)
|
||||
if (demo.rewinding && leveltime > 0)
|
||||
{
|
||||
leveltime = (leveltime-1) & ~3;
|
||||
if (timeinmap > 0)
|
||||
timeinmap = (timeinmap-1) & ~3;
|
||||
G_PreviewRewind(leveltime);
|
||||
}
|
||||
else if (demo.freecam && democam.cam) // special case: allow freecam to MOVE during pause!
|
||||
@@ -587,24 +619,7 @@ void P_Ticker(boolean run)
|
||||
K_CalculateBattleWanted();
|
||||
}
|
||||
|
||||
if (quake.time)
|
||||
{
|
||||
fixed_t ir = quake.intensity>>1;
|
||||
/// \todo Calculate distance from epicenter if set and modulate the intensity accordingly based on radius.
|
||||
quake.x = M_RandomRange(-ir,ir);
|
||||
quake.y = M_RandomRange(-ir,ir);
|
||||
quake.z = M_RandomRange(-ir,ir);
|
||||
ir >>= 2;
|
||||
ir = M_RandomRange(-ir,ir);
|
||||
if (ir < 0)
|
||||
ir = ANGLE_MAX - FixedAngle(-ir);
|
||||
else
|
||||
ir = FixedAngle(ir);
|
||||
quake.roll = ir;
|
||||
--quake.time;
|
||||
}
|
||||
else
|
||||
quake.x = quake.y = quake.z = quake.roll = 0;
|
||||
P_RunQuakes();
|
||||
|
||||
if (metalplayback)
|
||||
G_ReadMetalTic(metalplayback);
|
||||
@@ -668,8 +683,10 @@ void P_Ticker(boolean run)
|
||||
{
|
||||
player_t *player = &players[displayplayers[i]];
|
||||
boolean isSkyVisibleForPlayer = skyVisiblePerPlayer[i];
|
||||
|
||||
if (!player->mo)
|
||||
continue;
|
||||
|
||||
if (isSkyVisibleForPlayer && skyboxmo[0] && cv_skybox.value)
|
||||
{
|
||||
R_SkyboxFrame(player);
|
||||
@@ -683,8 +700,6 @@ void P_Ticker(boolean run)
|
||||
|
||||
if (demo.playback)
|
||||
G_StoreRewindInfo();
|
||||
|
||||
// Z_CheckMemCleanup();
|
||||
}
|
||||
|
||||
// Abbreviated ticker for pre-loading, calls thinkers and assorted things
|
||||
|
||||
+9
-13
@@ -800,19 +800,13 @@ void P_RestoreMusic(player_t *player)
|
||||
if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1))
|
||||
S_SpeedMusic(1.2f);
|
||||
#endif
|
||||
if (cv_birdmusic.value)
|
||||
{
|
||||
if (mapmusresume && cv_resume.value)
|
||||
position = mapmusresume;
|
||||
else
|
||||
position = mapmusposition;
|
||||
|
||||
S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn());
|
||||
S_ClearRestoreMusicFadeInCvar();
|
||||
}
|
||||
if (mapmusresume && cv_resume.value) // mapmusresume will be 0 anyways when birdmusic stuff is disabled
|
||||
position = mapmusresume;
|
||||
else
|
||||
S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0);
|
||||
position = mapmusposition;
|
||||
|
||||
S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn());
|
||||
S_ClearRestoreMusicFadeInCvar();
|
||||
mapmusresume = 0;
|
||||
}
|
||||
}
|
||||
@@ -1041,7 +1035,7 @@ fixed_t P_GetPlayerSpinHeight(player_t *player)
|
||||
// Returns true if player is
|
||||
// on the local machine.
|
||||
//
|
||||
boolean P_IsLocalPlayer(player_t *player)
|
||||
boolean P_IsLocalPlayer(const player_t *player)
|
||||
{
|
||||
UINT8 i;
|
||||
|
||||
@@ -1065,7 +1059,7 @@ boolean P_IsLocalPlayer(player_t *player)
|
||||
// Returns true if player is
|
||||
// currently being watched.
|
||||
//
|
||||
boolean P_IsDisplayPlayer(player_t *player)
|
||||
boolean P_IsDisplayPlayer(const player_t *player)
|
||||
{
|
||||
UINT8 i;
|
||||
|
||||
@@ -1179,6 +1173,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj)
|
||||
ghost = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_GHOST);
|
||||
|
||||
P_SetScale(ghost, mobj->scale);
|
||||
ghost->scalespeed = mobj->scalespeed;
|
||||
ghost->destscale = mobj->scale;
|
||||
|
||||
if (mobj->eflags & MFE_VERTICALFLIP)
|
||||
@@ -1230,6 +1225,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj)
|
||||
ghost->old_roll = mobj->old_roll2;
|
||||
ghost->old_sloperoll = mobj->old_sloperoll2;
|
||||
ghost->old_slopepitch = mobj->old_slopepitch2;
|
||||
ghost->old_scale = mobj->old_scale2;
|
||||
|
||||
return ghost;
|
||||
}
|
||||
|
||||
+138
-138
@@ -18,13 +18,15 @@
|
||||
#include <stdint.h>
|
||||
#include "qs22j.h"
|
||||
|
||||
#define INSORTTHRESH 5 // if n < this use insertion sort
|
||||
// MUST be >= 2
|
||||
#define MIDTHRESH 20 // < this use middle as pivot
|
||||
#define MEDOF3THRESH 50 // < this use median-of-3 as pivot
|
||||
// larger subfiles use med-of-3-medians
|
||||
#define INSORTTHRESH 5 // if n < this use insertion sort
|
||||
// MUST be >= 2
|
||||
#define MIDTHRESH 20 // < this use middle as pivot
|
||||
#define MEDOF3THRESH 50 // < this use median-of-3 as pivot
|
||||
// larger subfiles use med-of-3-medians
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
typedef int32_t WORD;
|
||||
typedef int64_t DWORD;
|
||||
@@ -37,242 +39,240 @@ typedef void *pref_typ;
|
||||
#define ASWAP(a, b, t) ((void)(t = a, a = b, b = t))
|
||||
|
||||
#define SWAP(a, b) if (swap_type) swapf(a, b, size);\
|
||||
else do {pref_typ t; ASWAP(*(pref_typ*)(a), *(pref_typ*)(b), t);} while (0)
|
||||
else do {pref_typ t; ASWAP(*(pref_typ*)(a), *(pref_typ*)(b), t);} while (0)
|
||||
|
||||
#define COMP(a, b) ((*compar)((void *)(a), (void *)(b)))
|
||||
#define COMP(a, b) ((*compar)((void *)(a), (void *)(b)))
|
||||
|
||||
static inline void swapbytes(void *a0, void *b0, size_t n)
|
||||
{
|
||||
char *a = a0, *b = b0, t;
|
||||
do {ASWAP(*a, *b, t); a++; b++;} while (--n);
|
||||
char *a = a0, *b = b0, t;
|
||||
do {ASWAP(*a, *b, t); a++; b++;} while (--n);
|
||||
}
|
||||
|
||||
static inline void swapdword(void *a0, void *b0, size_t n)
|
||||
{
|
||||
DWORD *a = a0, *b = b0, t;
|
||||
ASWAP(*a, *b, t);
|
||||
(void)n;
|
||||
(void)n;
|
||||
DWORD *a = a0, *b = b0, t;
|
||||
ASWAP(*a, *b, t);
|
||||
}
|
||||
|
||||
static inline void swapdwords(void *a0, void *b0, size_t n)
|
||||
{
|
||||
DWORD *a = a0, *b = b0, t;
|
||||
do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(DWORD));
|
||||
DWORD *a = a0, *b = b0, t;
|
||||
do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(DWORD));
|
||||
}
|
||||
|
||||
static inline void swapword(void *a0, void *b0, size_t n)
|
||||
{
|
||||
WORD *a = a0, *b = b0, t;
|
||||
ASWAP(*a, *b, t);
|
||||
(void)n;
|
||||
(void)n;
|
||||
WORD *a = a0, *b = b0, t;
|
||||
ASWAP(*a, *b, t);
|
||||
}
|
||||
|
||||
static inline void swapwords(void *a0, void *b0, size_t n)
|
||||
{
|
||||
WORD *a = a0, *b = b0, t;
|
||||
do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(WORD));
|
||||
WORD *a = a0, *b = b0, t;
|
||||
do {ASWAP(*a, *b, t); a++; b++;} while (n -= sizeof(WORD));
|
||||
}
|
||||
|
||||
typedef void (*swapf_typ)(void *, void *, size_t);
|
||||
|
||||
static inline char *med3(char *a, char *b, char *c, int (*compar)(const void *, const void *))
|
||||
{
|
||||
return COMP(a, b) < 0 ?
|
||||
(COMP(b, c) < 0 ? b : COMP(a, c) < 0 ? c : a) :
|
||||
(COMP(b, c) > 0 ? b : COMP(a, c) > 0 ? c : a);
|
||||
return COMP(a, b) < 0 ?
|
||||
(COMP(b, c) < 0 ? b : COMP(a, c) < 0 ? c : a) :
|
||||
(COMP(b, c) > 0 ? b : COMP(a, c) > 0 ? c : a);
|
||||
}
|
||||
|
||||
void qs22j(void *base, size_t nmemb, size_t size,
|
||||
int (*compar)(const void *, const void *))
|
||||
{
|
||||
char *stack[2*8*sizeof(size_t)], **sp = stack; // stack and stack pointer
|
||||
char *left = base; // set up char * base pointer
|
||||
char *limit = left + nmemb * size; // pointer past end of array
|
||||
char *i, *ii, *j, *jj; // scan pointers
|
||||
int ki = 0, kj = 0;
|
||||
int swap_type = 1;
|
||||
swapf_typ swapf, vecswapf;
|
||||
char *stack[2*8*sizeof(size_t)], **sp = stack; // stack and stack pointer
|
||||
char *left = base; // set up char * base pointer
|
||||
char *limit = left + nmemb * size; // pointer past end of array
|
||||
char *i, *ii, *j, *jj; // scan pointers
|
||||
int ki = 0, kj = 0;
|
||||
int swap_type = 1;
|
||||
swapf_typ swapf, vecswapf;
|
||||
|
||||
vecswapf = swapf = swapbytes;
|
||||
if ((ptr_to_int(left) | size) % sizeof(WORD))
|
||||
vecswapf = swapf = swapbytes;
|
||||
if ((ptr_to_int(left) | size) % sizeof(WORD))
|
||||
{
|
||||
; // unaligned or not multple of WORD size; swap bytes
|
||||
}
|
||||
; // unaligned or not multple of WORD size; swap bytes
|
||||
}
|
||||
else if (size == sizeof(DWORD))
|
||||
{
|
||||
swapf = swapdword;
|
||||
vecswapf = swapdwords;
|
||||
if (size == sizeof(pref_typ))
|
||||
swap_type = 0;
|
||||
}
|
||||
swapf = swapdword;
|
||||
vecswapf = swapdwords;
|
||||
if (size == sizeof(pref_typ))
|
||||
swap_type = 0;
|
||||
}
|
||||
else if (size == sizeof(WORD))
|
||||
{
|
||||
swapf = swapword;
|
||||
vecswapf = swapwords;
|
||||
if (size == sizeof(pref_typ))
|
||||
swap_type = 0;
|
||||
swapf = swapword;
|
||||
vecswapf = swapwords;
|
||||
if (size == sizeof(pref_typ))
|
||||
swap_type = 0;
|
||||
}
|
||||
else if ((size % sizeof(DWORD)) == 0)
|
||||
{
|
||||
swapf = vecswapf = swapdwords;
|
||||
}
|
||||
swapf = vecswapf = swapdwords;
|
||||
}
|
||||
else if ((size % sizeof(WORD)) == 0)
|
||||
{
|
||||
swapf = vecswapf = swapwords;
|
||||
}
|
||||
for (;;)
|
||||
swapf = vecswapf = swapwords;
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
nmemb = (limit - left) / size;
|
||||
for (i = left + size; i < limit && COMP(i - size, i) <= 0; i += size)
|
||||
;
|
||||
nmemb = (limit - left) / size;
|
||||
for (i = left + size; i < limit && COMP(i - size, i) <= 0; i += size)
|
||||
;
|
||||
|
||||
if (i == limit) // if already in order
|
||||
goto pop;
|
||||
if (i == limit) // if already in order
|
||||
goto pop;
|
||||
|
||||
if (nmemb >= INSORTTHRESH) // otherwise use insertion sort
|
||||
if (nmemb >= INSORTTHRESH) // otherwise use insertion sort
|
||||
{
|
||||
char *right = limit - size;
|
||||
// best so far? fewer compares, a few more swaps
|
||||
char *p = left + (nmemb / 2) * size;
|
||||
if (nmemb >= MIDTHRESH)
|
||||
char *right = limit - size;
|
||||
// best so far? fewer compares, a few more swaps
|
||||
char *p = left + (nmemb / 2) * size;
|
||||
if (nmemb >= MIDTHRESH)
|
||||
{
|
||||
char *pleft = left + size;
|
||||
char *pright = right - size;
|
||||
char *pleft = left + size;
|
||||
char *pright = right - size;
|
||||
|
||||
if (nmemb >= MEDOF3THRESH)
|
||||
if (nmemb >= MEDOF3THRESH)
|
||||
{
|
||||
size_t k = (nmemb / 8) * size;
|
||||
pleft = med3(pleft, left + k, left + k * 2, compar);
|
||||
p = med3(p - k, p, p + k, compar);
|
||||
pright = med3(right - k * 2, right - k, pright, compar);
|
||||
}
|
||||
size_t k = (nmemb / 8) * size;
|
||||
pleft = med3(pleft, left + k, left + k * 2, compar);
|
||||
p = med3(p - k, p, p + k, compar);
|
||||
pright = med3(right - k * 2, right - k, pright, compar);
|
||||
}
|
||||
|
||||
p = med3(pleft, p, pright, compar);
|
||||
}
|
||||
p = med3(pleft, p, pright, compar);
|
||||
}
|
||||
|
||||
i = ii = left; // i scans left to right
|
||||
j = jj = right; // j scans right to left
|
||||
i = ii = left; // i scans left to right
|
||||
j = jj = right; // j scans right to left
|
||||
for (;;)
|
||||
{
|
||||
|
||||
while (i <= j)
|
||||
{
|
||||
if (i != p && ((ki = COMP(i, p)) >= 0))
|
||||
{
|
||||
if (ki)
|
||||
break;
|
||||
if (ki)
|
||||
break;
|
||||
|
||||
if (ii == p)
|
||||
{
|
||||
p = i;
|
||||
p = i;
|
||||
}
|
||||
else if (i != ii)
|
||||
{
|
||||
SWAP(i, ii);
|
||||
SWAP(i, ii);
|
||||
}
|
||||
|
||||
ii += size;
|
||||
}
|
||||
i += size;
|
||||
}
|
||||
ii += size;
|
||||
}
|
||||
i += size;
|
||||
}
|
||||
|
||||
while (i < j)
|
||||
while (i < j)
|
||||
{
|
||||
if (j != p && ((kj = COMP(j, p)) <= 0))
|
||||
if (j != p && ((kj = COMP(j, p)) <= 0))
|
||||
{
|
||||
if (kj)
|
||||
break;
|
||||
if (kj)
|
||||
break;
|
||||
|
||||
if (jj == p)
|
||||
if (jj == p)
|
||||
{
|
||||
p = j;
|
||||
p = j;
|
||||
}
|
||||
else if (j != jj)
|
||||
else if (j != jj)
|
||||
{
|
||||
SWAP(j, jj);
|
||||
SWAP(j, jj);
|
||||
}
|
||||
|
||||
jj -= size;
|
||||
}
|
||||
j -= size;
|
||||
}
|
||||
jj -= size;
|
||||
}
|
||||
j -= size;
|
||||
}
|
||||
|
||||
if (i >= j)
|
||||
break;
|
||||
if (i >= j)
|
||||
break;
|
||||
|
||||
SWAP(i, j);
|
||||
i += size;
|
||||
j -= size;
|
||||
}
|
||||
SWAP(i, j);
|
||||
i += size;
|
||||
j -= size;
|
||||
}
|
||||
|
||||
if (p < i)
|
||||
i -= size;
|
||||
if (p < i)
|
||||
i -= size;
|
||||
|
||||
if (p != i)
|
||||
{
|
||||
SWAP(p, i);
|
||||
}
|
||||
|
||||
ptrdiff_t lessthan = i - ii;
|
||||
size_t k = min(lessthan, ii - left);
|
||||
ptrdiff_t lessthan = i - ii;
|
||||
size_t k = min(lessthan, ii - left);
|
||||
|
||||
if (k)
|
||||
vecswapf(left, i - k, k);
|
||||
if (k)
|
||||
vecswapf(left, i - k, k);
|
||||
|
||||
ptrdiff_t morethan = jj - i;
|
||||
k = min(morethan, right - jj);
|
||||
ptrdiff_t morethan = jj - i;
|
||||
k = min(morethan, right - jj);
|
||||
|
||||
if (k)
|
||||
vecswapf(i + size, limit - k, k);
|
||||
if (k)
|
||||
vecswapf(i + size, limit - k, k);
|
||||
|
||||
if (lessthan > morethan)
|
||||
if (lessthan > morethan)
|
||||
{
|
||||
if (lessthan > 1)
|
||||
if (lessthan > 1)
|
||||
{
|
||||
sp[0] = left;
|
||||
sp[1] = left + lessthan;
|
||||
sp += 2; // increment stack pointer
|
||||
}
|
||||
sp[0] = left;
|
||||
sp[1] = left + lessthan;
|
||||
sp += 2; // increment stack pointer
|
||||
}
|
||||
|
||||
if (morethan <= 1)
|
||||
goto pop;
|
||||
if (morethan <= 1)
|
||||
goto pop;
|
||||
|
||||
left = limit - morethan;
|
||||
left = limit - morethan;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (morethan > 1)
|
||||
if (morethan > 1)
|
||||
{
|
||||
sp[0] = limit - morethan;
|
||||
sp[1] = limit;
|
||||
sp += 2; // increment stack pointer
|
||||
}
|
||||
sp[0] = limit - morethan;
|
||||
sp[1] = limit;
|
||||
sp += 2; // increment stack pointer
|
||||
}
|
||||
|
||||
if (lessthan <= 1)
|
||||
goto pop;
|
||||
if (lessthan <= 1)
|
||||
goto pop;
|
||||
|
||||
limit = left + lessthan;
|
||||
}
|
||||
|
||||
}
|
||||
limit = left + lessthan;
|
||||
}
|
||||
}
|
||||
else // else subfile is small, use insertion sort
|
||||
{
|
||||
for (i = left + size; i < limit; i += size)
|
||||
for (i = left + size; i < limit; i += size)
|
||||
{
|
||||
for (j = i; j != left && COMP(j - size, j) > 0; j -= size)
|
||||
for (j = i; j != left && COMP(j - size, j) > 0; j -= size)
|
||||
{
|
||||
SWAP(j - size, j);
|
||||
}
|
||||
}
|
||||
SWAP(j - size, j);
|
||||
}
|
||||
}
|
||||
pop:
|
||||
if (sp != stack) // if any entries on stack
|
||||
if (sp != stack) // if any entries on stack
|
||||
{
|
||||
sp -= 2; // pop the left and limit
|
||||
left = sp[0];
|
||||
limit = sp[1];
|
||||
}
|
||||
else // else stack empty, done
|
||||
break;
|
||||
sp -= 2; // pop the left and limit
|
||||
left = sp[0];
|
||||
limit = sp[1];
|
||||
}
|
||||
else // else stack empty, done
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-2
@@ -1,7 +1,21 @@
|
||||
// License: 0BSD
|
||||
//
|
||||
// Copyright 2022 Raymond Gardner
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
// SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
// IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
//
|
||||
|
||||
#ifndef __QS22J__
|
||||
#define __QS22J__
|
||||
|
||||
void qs22j(void *base, size_t nmemb, size_t size,
|
||||
int (*compar)(const void *, const void *));
|
||||
|
||||
#endif
|
||||
+3
-4
@@ -28,7 +28,7 @@ side_t *sidedef;
|
||||
line_t *linedef;
|
||||
sector_t *frontsector;
|
||||
sector_t *backsector;
|
||||
boolean portalline; // is curline a portal seg?
|
||||
portal_pair *g_portal; // is curline a portal seg?
|
||||
|
||||
// very ugly realloc() of drawsegs at run-time, I upped it to 512
|
||||
// instead of 256.. and someone managed to send me a level with
|
||||
@@ -417,7 +417,7 @@ static void R_AddLine(seg_t *line)
|
||||
angle_t angle1, angle2, span, tspan;
|
||||
static sector_t tempsec;
|
||||
|
||||
portalline = false;
|
||||
g_portal = NULL;
|
||||
|
||||
if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES))
|
||||
return;
|
||||
@@ -1333,8 +1333,7 @@ void R_RenderBSPNode(INT32 bspnum)
|
||||
// PORTAL CULLING
|
||||
if (portalcullsector)
|
||||
{
|
||||
sector_t *sect = subsectors[bspnum & ~NF_SUBSECTOR].sector;
|
||||
if (sect != portalcullsector)
|
||||
if (subsectors[bspnum & ~NF_SUBSECTOR].sector != portalcullsector)
|
||||
return;
|
||||
portalcullsector = NULL;
|
||||
}
|
||||
|
||||
+3
-1
@@ -18,12 +18,14 @@
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "r_main.h"
|
||||
|
||||
extern seg_t *curline;
|
||||
extern side_t *sidedef;
|
||||
extern line_t *linedef;
|
||||
extern sector_t *frontsector;
|
||||
extern sector_t *backsector;
|
||||
extern boolean portalline; // is curline a portal seg?
|
||||
extern portal_pair *g_portal; // is curline a portal seg?
|
||||
|
||||
// drawsegs are allocated on the fly... see r_segs.c
|
||||
|
||||
|
||||
+97
-120
@@ -70,29 +70,12 @@ player_t *viewplayer;
|
||||
// You can thank and/or curse JTE for these.
|
||||
UINT8 portalrender;
|
||||
sector_t *portalcullsector;
|
||||
typedef struct portal_pair
|
||||
{
|
||||
INT32 line1;
|
||||
INT32 line2;
|
||||
UINT8 pass;
|
||||
struct portal_pair *next;
|
||||
|
||||
fixed_t viewx;
|
||||
fixed_t viewy;
|
||||
fixed_t viewz;
|
||||
angle_t viewangle;
|
||||
|
||||
INT32 start;
|
||||
INT32 end;
|
||||
INT16 *ceilingclip;
|
||||
INT16 *floorclip;
|
||||
fixed_t *frontscale;
|
||||
} portal_pair;
|
||||
portal_pair *portal_base, *portal_cap;
|
||||
line_t *portalclipline;
|
||||
INT32 portalclipstart, portalclipend;
|
||||
|
||||
fixed_t rendertimefrac;
|
||||
fixed_t rendertimefrac_unpaused;
|
||||
fixed_t renderdeltatics;
|
||||
boolean renderisnewtic;
|
||||
|
||||
@@ -213,6 +196,8 @@ consvar_t cv_mobjscaleprecip = {"scaleprecipmobjscale", "Off", CV_SAVE|CV_CALL|C
|
||||
|
||||
consvar_t cv_grmaxinterpdist = {"gr_maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_ripplewater = {"waterripples", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// cap fov, fov too high tears software apart.
|
||||
consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL|CV_SAVE, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
@@ -474,6 +459,11 @@ INT32 R_GetHudUncap(void)
|
||||
return cv_uncappedhud.value ? rendertimefrac & FRACMASK : 0;
|
||||
}
|
||||
|
||||
INT32 R_GetMenuUncap(void)
|
||||
{
|
||||
return cv_uncappedhud.value ? rendertimefrac_unpaused & FRACMASK : 0;
|
||||
}
|
||||
|
||||
//
|
||||
// R_ScaleFromGlobalAngle
|
||||
// Returns the texture mapping scale for the current line (horizontal span)
|
||||
@@ -995,6 +985,16 @@ void R_ExecuteSetViewSize(void)
|
||||
|
||||
R_InitTextureMapping();
|
||||
|
||||
// why did we calc all the software crap?
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
HWR_SetViewSize();
|
||||
am_recalc = true;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
// thing clipping
|
||||
for (i = 0; i < viewwidth; i++)
|
||||
screenheightarray[i] = (INT16)viewheight;
|
||||
@@ -1003,27 +1003,24 @@ void R_ExecuteSetViewSize(void)
|
||||
R_SetSkyScale();
|
||||
|
||||
// planes
|
||||
if (rendermode == render_soft)
|
||||
// this is only used for planes rendering in software mode
|
||||
j = viewheight*16;
|
||||
for (i = 0; i < j; i++)
|
||||
{
|
||||
// this is only used for planes rendering in software mode
|
||||
j = viewheight*16;
|
||||
for (i = 0; i < j; i++)
|
||||
{
|
||||
dy = (i - viewheight*8)<<FRACBITS;
|
||||
dy = FixedMul(abs(dy), fovtan);
|
||||
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
|
||||
}
|
||||
|
||||
if (ds_su)
|
||||
Z_Free(ds_su);
|
||||
if (ds_sv)
|
||||
Z_Free(ds_sv);
|
||||
if (ds_sz)
|
||||
Z_Free(ds_sz);
|
||||
|
||||
ds_su = ds_sv = ds_sz = NULL;
|
||||
ds_sup = ds_svp = ds_szp = NULL;
|
||||
dy = (i - viewheight*8)<<FRACBITS;
|
||||
dy = FixedMul(abs(dy), fovtan);
|
||||
yslopetab[i] = FixedDiv(centerx*FRACUNIT, dy);
|
||||
}
|
||||
|
||||
if (ds_su)
|
||||
Z_Free(ds_su);
|
||||
if (ds_sv)
|
||||
Z_Free(ds_sv);
|
||||
if (ds_sz)
|
||||
Z_Free(ds_sz);
|
||||
|
||||
ds_su = ds_sv = ds_sz = NULL;
|
||||
ds_sup = ds_svp = ds_szp = NULL;
|
||||
|
||||
memset(scalelight, 0xFF, sizeof(scalelight));
|
||||
|
||||
@@ -1045,12 +1042,6 @@ void R_ExecuteSetViewSize(void)
|
||||
}
|
||||
}
|
||||
|
||||
// continue to do the software setviewsize as long as we use the reference software view
|
||||
#ifdef HWRENDER
|
||||
if (rendermode != render_soft)
|
||||
HWR_SetViewSize();
|
||||
#endif
|
||||
|
||||
am_recalc = true;
|
||||
}
|
||||
|
||||
@@ -1368,7 +1359,28 @@ void R_SkyboxFrame(player_t *player)
|
||||
// newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT);
|
||||
// newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT);
|
||||
|
||||
R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT, false);
|
||||
R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false);
|
||||
}
|
||||
|
||||
static void
|
||||
R_SetupCommonFrame
|
||||
( player_t * player,
|
||||
subsector_t * subsector)
|
||||
{
|
||||
newview->player = player;
|
||||
|
||||
newview->x += quake.x;
|
||||
newview->y += quake.y;
|
||||
newview->z += quake.z;
|
||||
|
||||
newview->roll = R_ViewRollAngle(player);
|
||||
|
||||
if (subsector)
|
||||
newview->sector = subsector->sector;
|
||||
else
|
||||
newview->sector = R_PointInSubsector(newview->x, newview->y)->sector;
|
||||
|
||||
R_InterpolateView(R_UsingFrameInterpolation() ? demo.playback ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false);
|
||||
}
|
||||
|
||||
void R_SetupFrame(player_t *player, boolean skybox)
|
||||
@@ -1376,50 +1388,33 @@ void R_SetupFrame(player_t *player, boolean skybox)
|
||||
camera_t *thiscam;
|
||||
boolean chasecam = false;
|
||||
|
||||
#define SETUPCAM(num, var, context)\
|
||||
thiscam = &camera[num];\
|
||||
chasecam = (var.value != 0);\
|
||||
R_SetViewContext(context);\
|
||||
if (thiscam->reset)\
|
||||
{\
|
||||
R_ResetViewInterpolation(num+1);\
|
||||
thiscam->reset = false;\
|
||||
}
|
||||
|
||||
if (splitscreen > 2 && player == &players[displayplayers[3]])
|
||||
{
|
||||
thiscam = &camera[3];
|
||||
chasecam = (cv_chasecam4.value != 0);
|
||||
R_SetViewContext(VIEWCONTEXT_PLAYER4);
|
||||
if (thiscam->reset)
|
||||
{
|
||||
R_ResetViewInterpolation(4);
|
||||
thiscam->reset = false;
|
||||
}
|
||||
SETUPCAM(3, cv_chasecam4, VIEWCONTEXT_PLAYER4)
|
||||
}
|
||||
else if (splitscreen > 1 && player == &players[displayplayers[2]])
|
||||
{
|
||||
thiscam = &camera[2];
|
||||
chasecam = (cv_chasecam3.value != 0);
|
||||
R_SetViewContext(VIEWCONTEXT_PLAYER3);
|
||||
if (thiscam->reset)
|
||||
{
|
||||
R_ResetViewInterpolation(3);
|
||||
thiscam->reset = false;
|
||||
}
|
||||
SETUPCAM(2, cv_chasecam3, VIEWCONTEXT_PLAYER3)
|
||||
}
|
||||
else if (splitscreen && player == &players[displayplayers[1]])
|
||||
{
|
||||
thiscam = &camera[1];
|
||||
chasecam = (cv_chasecam2.value != 0);
|
||||
R_SetViewContext(VIEWCONTEXT_PLAYER2);
|
||||
if (thiscam->reset)
|
||||
{
|
||||
R_ResetViewInterpolation(2);
|
||||
thiscam->reset = false;
|
||||
}
|
||||
SETUPCAM(1, cv_chasecam2, VIEWCONTEXT_PLAYER2)
|
||||
}
|
||||
else
|
||||
{
|
||||
thiscam = &camera[0];
|
||||
chasecam = (cv_chasecam.value != 0);
|
||||
R_SetViewContext(VIEWCONTEXT_PLAYER1);
|
||||
if (thiscam->reset)
|
||||
{
|
||||
R_ResetViewInterpolation(1);
|
||||
thiscam->reset = false;
|
||||
}
|
||||
SETUPCAM(0, cv_chasecam, VIEWCONTEXT_PLAYER1)
|
||||
}
|
||||
#undef SETUPCAM
|
||||
|
||||
if (player->spectator) // no spectator chasecam
|
||||
chasecam = false; // force chasecam off
|
||||
@@ -1435,31 +1430,43 @@ void R_SetupFrame(player_t *player, boolean skybox)
|
||||
thiscam->chase = false;
|
||||
|
||||
newview->sky = !skybox;
|
||||
if (player->awayviewtics)
|
||||
|
||||
if (player->awayviewtics) // cut-away view stuff
|
||||
{
|
||||
// cut-away view stuff
|
||||
viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN
|
||||
I_Assert(viewmobj != NULL);
|
||||
|
||||
newview->x = viewmobj->x;
|
||||
newview->y = viewmobj->y;
|
||||
newview->z = viewmobj->z + 20*FRACUNIT;
|
||||
|
||||
newview->aim = player->awayviewaiming;
|
||||
newview->angle = viewmobj->angle;
|
||||
|
||||
R_SetupCommonFrame(player, viewmobj->subsector);
|
||||
}
|
||||
else if (!player->spectator && (thiscam && chasecam))
|
||||
// use outside cam view
|
||||
else if (!player->spectator && (thiscam && chasecam)) // use outside cam view
|
||||
{
|
||||
viewmobj = NULL;
|
||||
|
||||
newview->x = thiscam->x;
|
||||
newview->y = thiscam->y;
|
||||
newview->z = thiscam->z + (thiscam->height>>1);
|
||||
|
||||
newview->aim = thiscam->aiming;
|
||||
newview->angle = thiscam->angle;
|
||||
}
|
||||
else
|
||||
// use the player's eyes view
|
||||
{
|
||||
newview->z = player->viewz;
|
||||
|
||||
R_SetupCommonFrame(player, thiscam->subsector);
|
||||
}
|
||||
else // use the player's eyes view
|
||||
{
|
||||
viewmobj = player->mo;
|
||||
I_Assert(viewmobj != NULL);
|
||||
|
||||
newview->x = viewmobj->x;
|
||||
newview->y = viewmobj->y;
|
||||
newview->z = player->viewz;
|
||||
|
||||
newview->aim = player->aiming;
|
||||
newview->angle = viewmobj->angle;
|
||||
|
||||
@@ -1484,41 +1491,9 @@ void R_SetupFrame(player_t *player, boolean skybox)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
R_SetupCommonFrame(player, viewmobj->subsector);
|
||||
}
|
||||
newview->roll = R_ViewRollAngle(player);
|
||||
newview->z += quake.z;
|
||||
|
||||
newview->player = player;
|
||||
|
||||
if ((thiscam && chasecam) && !player->awayviewtics && !player->spectator)
|
||||
{
|
||||
newview->x = thiscam->x;
|
||||
newview->y = thiscam->y;
|
||||
newview->x += quake.x;
|
||||
newview->y += quake.y;
|
||||
|
||||
if (thiscam->subsector && thiscam->subsector->sector)
|
||||
newview->sector = thiscam->subsector->sector;
|
||||
else
|
||||
newview->sector = R_PointInSubsector(newview->x, newview->y)->sector;
|
||||
}
|
||||
else
|
||||
{
|
||||
newview->x = viewmobj->x;
|
||||
newview->y = viewmobj->y;
|
||||
newview->x += quake.x;
|
||||
newview->y += quake.y;
|
||||
|
||||
if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && thiscam && thiscam->subsector->sector)
|
||||
newview->sector = viewmobj->subsector->sector;
|
||||
else
|
||||
newview->sector = R_PointInSubsector(newview->x, newview->y)->sector;
|
||||
}
|
||||
|
||||
// newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT);
|
||||
// newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT);
|
||||
|
||||
R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT, false);
|
||||
}
|
||||
|
||||
#define ANGLED_PORTALS
|
||||
@@ -1611,7 +1586,7 @@ void R_AddPortal(INT32 line1, INT32 line2, INT32 x1, INT32 x2)
|
||||
portal->start = x1;
|
||||
portal->end = x2;
|
||||
|
||||
portalline = true; // this tells R_StoreWallRange that curline is a portal seg
|
||||
g_portal = portal; // this tells R_StoreWallRange that curline is a portal seg
|
||||
|
||||
portal->viewx = viewx;
|
||||
portal->viewy = viewy;
|
||||
@@ -1889,6 +1864,8 @@ void R_RegisterEngineStuff(void)
|
||||
|
||||
CV_RegisterVar(&cv_grmaxinterpdist);
|
||||
|
||||
CV_RegisterVar(&cv_ripplewater);
|
||||
|
||||
// Default viewheight is changeable,
|
||||
// initialized to standard viewheight
|
||||
//CV_RegisterVar(&cv_viewheight);
|
||||
|
||||
@@ -33,6 +33,8 @@ extern size_t validcount, linecount, loopcount, framecount;
|
||||
|
||||
// The fraction of a tic being drawn (for interpolation between two tics)
|
||||
extern fixed_t rendertimefrac;
|
||||
// Same as rendertimefrac but not suspended when the game is paused
|
||||
extern fixed_t rendertimefrac_unpaused;
|
||||
// Evaluated delta tics for this frame (how many tics since the last frame)
|
||||
extern fixed_t renderdeltatics;
|
||||
// The current render is a new logical tic
|
||||
@@ -88,6 +90,27 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y);
|
||||
boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixed_t bottomh, fixed_t toph);
|
||||
void R_GetRenderBlockMapDimensions(fixed_t drawdist, INT32 *xl, INT32 *xh, INT32 *yl, INT32 *yh);
|
||||
|
||||
|
||||
typedef struct portal_pair
|
||||
{
|
||||
INT32 line1;
|
||||
INT32 line2;
|
||||
UINT8 pass;
|
||||
struct portal_pair *next;
|
||||
|
||||
fixed_t viewx;
|
||||
fixed_t viewy;
|
||||
fixed_t viewz;
|
||||
angle_t viewangle;
|
||||
|
||||
INT32 start;
|
||||
INT32 end;
|
||||
INT16 *ceilingclip;
|
||||
INT16 *floorclip;
|
||||
fixed_t *frontscale;
|
||||
} portal_pair;
|
||||
|
||||
|
||||
// Performance stats
|
||||
extern precise_t ps_prevframetime;// time when previous frame was rendered
|
||||
extern ps_metric_t ps_rendercalltime;
|
||||
@@ -124,6 +147,7 @@ extern consvar_t cv_fov;
|
||||
extern consvar_t cv_skybox;
|
||||
extern consvar_t cv_tailspickup;
|
||||
extern consvar_t cv_grmaxinterpdist;
|
||||
extern consvar_t cv_ripplewater;
|
||||
|
||||
// Called by startup code.
|
||||
void R_Init(void);
|
||||
@@ -150,4 +174,6 @@ void R_RegisterEngineStuff(void);
|
||||
|
||||
// return multiplier for HUD uncap
|
||||
INT32 R_GetHudUncap(void);
|
||||
// same as above but keeps interpolation during pause
|
||||
INT32 R_GetMenuUncap(void);
|
||||
#endif
|
||||
+30
-23
@@ -910,34 +910,41 @@ void R_DrawSinglePlane(visplane_t *pl)
|
||||
INT32 top, bottom;
|
||||
UINT8 *scr;
|
||||
|
||||
planeripple.active = true;
|
||||
|
||||
if (spanfunc == R_DrawTranslucentSpan_8)
|
||||
if (cv_ripplewater.value)
|
||||
{
|
||||
spanfunc = R_DrawTranslucentWaterSpan_8;
|
||||
planeripple.active = true;
|
||||
|
||||
// Copy the current scene, ugh
|
||||
top = pl->high-8;
|
||||
bottom = pl->low+8;
|
||||
if (spanfunc == R_DrawTranslucentSpan_8)
|
||||
{
|
||||
spanfunc = R_DrawTranslucentWaterSpan_8;
|
||||
|
||||
if (top < 0)
|
||||
top = 0;
|
||||
if (bottom > vid.height)
|
||||
bottom = vid.height;
|
||||
// Copy the current scene, ugh
|
||||
top = pl->high-8;
|
||||
bottom = pl->low+8;
|
||||
|
||||
if (splitscreen > 2 && viewplayer == &players[displayplayers[3]]) // Only copy the part of the screen we need
|
||||
scr = (screens[0] + (top+(viewheight))*vid.width + viewwidth);
|
||||
else if ((splitscreen == 1 && viewplayer == &players[displayplayers[1]])
|
||||
|| (splitscreen > 1 && viewplayer == &players[displayplayers[2]]))
|
||||
scr = (screens[0] + (top+(viewheight))*vid.width);
|
||||
else if (splitscreen > 1 && viewplayer == &players[displayplayers[1]])
|
||||
scr = (screens[0] + ((top)*vid.width) + viewwidth);
|
||||
else
|
||||
scr = (screens[0] + ((top)*vid.width));
|
||||
if (top < 0)
|
||||
top = 0;
|
||||
if (bottom > vid.height)
|
||||
bottom = vid.height;
|
||||
|
||||
VID_BlitLinearScreen(scr, screens[1]+((top)*vid.width),
|
||||
vid.width, bottom-top,
|
||||
vid.width, vid.width);
|
||||
if (splitscreen > 2 && viewplayer == &players[displayplayers[3]]) // Only copy the part of the screen we need
|
||||
scr = (screens[0] + (top+(viewheight))*vid.width + viewwidth);
|
||||
else if ((splitscreen == 1 && viewplayer == &players[displayplayers[1]])
|
||||
|| (splitscreen > 1 && viewplayer == &players[displayplayers[2]]))
|
||||
scr = (screens[0] + (top+(viewheight))*vid.width);
|
||||
else if (splitscreen > 1 && viewplayer == &players[displayplayers[1]])
|
||||
scr = (screens[0] + ((top)*vid.width) + viewwidth);
|
||||
else
|
||||
scr = (screens[0] + ((top)*vid.width));
|
||||
|
||||
VID_BlitLinearScreen(scr, screens[1]+((top)*vid.width),
|
||||
vid.width, bottom-top,
|
||||
vid.width, vid.width);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
planeripple.active = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -2840,7 +2840,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
|
||||
R_RenderSegLoop();
|
||||
colfunc = wallcolfunc;
|
||||
|
||||
if (portalline) // if curline is a portal, set portalrender for drawseg
|
||||
if (g_portal) // if curline is a portal, set portalrender for drawseg
|
||||
ds_p->portalpass = portalrender+1;
|
||||
else
|
||||
ds_p->portalpass = 0;
|
||||
|
||||
+3
-3
@@ -614,7 +614,7 @@ void R_DrawMaskedColumn(column_t *column)
|
||||
if (dc_yh >= vid.height)
|
||||
dc_yh = vid.height - 1;
|
||||
|
||||
if (dc_yl <= dc_yh && dc_yh > 0)
|
||||
if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0)
|
||||
{
|
||||
dc_source = (UINT8 *)column + 3;
|
||||
dc_texturemid = basetexturemid - (topdelta<<FRACBITS);
|
||||
@@ -674,7 +674,7 @@ static void R_DrawFlippedMaskedColumn(column_t *column)
|
||||
if (dc_yh >= vid.height)
|
||||
dc_yh = vid.height - 1;
|
||||
|
||||
if (dc_yl <= dc_yh && dc_yh > 0)
|
||||
if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0)
|
||||
{
|
||||
dc_source = ZZ_Alloc(column->length);
|
||||
for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s)
|
||||
@@ -1987,7 +1987,7 @@ void R_AddPrecipitationSprites(void)
|
||||
precipmobj_t *th, *next;
|
||||
|
||||
// no, no infinite draw distance for precipitation. this option at zero is supposed to turn it off
|
||||
if (drawdist == 0)
|
||||
if (drawdist == 0 || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
+19
-41
@@ -85,7 +85,6 @@ consvar_t cv_midimusicvolume = {"midimusicvolume", "18", CV_SAVE, soundvolume_co
|
||||
// number of channels available
|
||||
consvar_t cv_numChannels = {"snd_channels", "64", CV_SAVE|CV_CALL, CV_Unsigned, SetChannelsNum, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t surround = {"surround", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
//consvar_t cv_resetmusic = {"resetmusic", "No", CV_SAVE|CV_NOSHOWHELP, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// Sound system toggles, saved into the config
|
||||
@@ -108,6 +107,7 @@ static CV_PossibleValue_t music_resync_threshold_cons_t[] = {
|
||||
{0}
|
||||
};
|
||||
consvar_t cv_music_resync_threshold = {"music_resync_threshold", "0", CV_SAVE|CV_CALL, music_resync_threshold_cons_t, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_music_resync_powerups_only = {"music_resync_powerups_only", "No", CV_SAVE|CV_CALL, CV_YesNo, I_UpdateSongLagThreshold, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
@@ -163,10 +163,6 @@ consvar_t cv_amigatype = {"amigatype", "0", CV_SAVE|CV_CALL|CV_NOINIT, amigatype
|
||||
#define S_PITCH_PERTURB 1
|
||||
#define S_STEREO_SWING (96*0x10000)
|
||||
|
||||
#ifdef SURROUND
|
||||
#define SURROUND_SEP -128
|
||||
#endif
|
||||
|
||||
// percent attenuation from front to back
|
||||
#define S_IFRACVOL 30
|
||||
|
||||
@@ -272,7 +268,6 @@ void S_RegisterSoundStuff(void)
|
||||
|
||||
CV_RegisterVar(&stereoreverse);
|
||||
CV_RegisterVar(&precachesound);
|
||||
CV_RegisterVar(&surround);
|
||||
CV_RegisterVar(&cv_samplerate);
|
||||
//CV_RegisterVar(&cv_resetmusic);
|
||||
CV_RegisterVar(&cv_gamesounds);
|
||||
@@ -281,13 +276,14 @@ void S_RegisterSoundStuff(void)
|
||||
CV_RegisterVar(&cv_gamemidimusic);
|
||||
#endif
|
||||
|
||||
//bird music stuff
|
||||
// bird music stuff
|
||||
CV_RegisterVar(&cv_playmusicifunfocused);
|
||||
CV_RegisterVar(&cv_playsoundifunfocused);
|
||||
CV_RegisterVar(&cv_pausemusic);
|
||||
|
||||
CV_RegisterVar(&cv_music_resync_threshold);
|
||||
|
||||
CV_RegisterVar(&cv_music_resync_powerups_only);
|
||||
|
||||
CV_RegisterVar(&cv_invincmusicfade);
|
||||
CV_RegisterVar(&cv_growmusicfade);
|
||||
|
||||
@@ -299,6 +295,7 @@ void S_RegisterSoundStuff(void)
|
||||
CV_RegisterVar(&cv_resume);
|
||||
CV_RegisterVar(&cv_fading);
|
||||
CV_RegisterVar(&cv_birdmusic);
|
||||
// bird music stuff end
|
||||
|
||||
COM_AddCommand("tunes", Command_Tunes_f);
|
||||
COM_AddCommand("restartaudio", Command_RestartAudio_f);
|
||||
@@ -616,11 +613,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
|
||||
}
|
||||
|
||||
// Avoid channel reverse if surround
|
||||
if (reverse
|
||||
#ifdef SURROUND
|
||||
&& sep != SURROUND_SEP
|
||||
#endif
|
||||
)
|
||||
if (reverse)
|
||||
{
|
||||
sep = (~sep) & 255;
|
||||
}
|
||||
@@ -1102,18 +1095,10 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32
|
||||
if (reverse)
|
||||
angle = InvAngle(angle);
|
||||
|
||||
#ifdef SURROUND
|
||||
// Produce a surround sound for angle from 105 till 255
|
||||
if (surround.value == 1 && (angle > ANG105 && angle < ANG255 ))
|
||||
*sep = SURROUND_SEP;
|
||||
else
|
||||
#endif
|
||||
{
|
||||
angle >>= ANGLETOFINESHIFT;
|
||||
angle >>= ANGLETOFINESHIFT;
|
||||
|
||||
// stereo separation
|
||||
*sep = 128 - (FixedMul(S_STEREO_SWING, FINESINE(angle))>>FRACBITS);
|
||||
}
|
||||
// stereo separation
|
||||
*sep = 128 - (FixedMul(S_STEREO_SWING, FINESINE(angle))>>FRACBITS);
|
||||
}
|
||||
|
||||
// volume calculation
|
||||
@@ -1260,7 +1245,7 @@ void S_InitSfxChannels(INT32 sfxVolume)
|
||||
if (S_PrecacheSound())
|
||||
{
|
||||
// Initialize external data (all sounds) at start, keep static.
|
||||
CONS_Printf(M_GetText("Loading sounds... "));
|
||||
CONS_Printf(M_GetText("Pre-caching sounds..."));
|
||||
|
||||
for (i = 1; i < sfx_freeslot0; i++)
|
||||
if (S_sfx[i].name && !S_sfx[i].data)
|
||||
@@ -1270,7 +1255,7 @@ void S_InitSfxChannels(INT32 sfxVolume)
|
||||
if (S_sfx[i].priority && !S_sfx[i].data)
|
||||
S_sfx[i].data = I_GetSfx(&S_sfx[i]);
|
||||
|
||||
CONS_Printf(M_GetText(" pre-cached all sound data\n"));
|
||||
CONS_Printf(M_GetText("...pre-cached all sound data\n"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1786,9 +1771,7 @@ boolean S_MusicPaused(void)
|
||||
|
||||
boolean S_MusicNotInFocus(void)
|
||||
{
|
||||
return (
|
||||
( window_notinfocus && ! cv_playmusicifunfocused.value )
|
||||
);
|
||||
return (window_notinfocus && !cv_playmusicifunfocused.value);
|
||||
}
|
||||
|
||||
musictype_t S_MusicType(void)
|
||||
@@ -1816,10 +1799,8 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping)
|
||||
|
||||
boolean S_MusicExists(const char *mname, boolean checkMIDI, boolean checkDigi)
|
||||
{
|
||||
return (
|
||||
(checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false)
|
||||
|| (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false)
|
||||
);
|
||||
return (checkDigi ? W_CheckNumForName(va("O_%s", mname)) != LUMPERROR : false)
|
||||
|| (checkMIDI ? W_CheckNumForName(va("D_%s", mname)) != LUMPERROR : false);
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
@@ -2052,8 +2033,10 @@ void S_StopMusic(void)
|
||||
|| demo.title) // SRB2Kart: Demos don't interrupt title screen music
|
||||
return;
|
||||
|
||||
if ((cv_birdmusic.value) && (strcasecmp(music_name, mapmusname) == 0))
|
||||
if (cv_birdmusic.value && (strcasecmp(music_name, mapmusname) == 0))
|
||||
mapmusresume = I_GetSongPosition();
|
||||
else
|
||||
mapmusresume = 0;
|
||||
|
||||
if (I_SongPaused())
|
||||
I_ResumeSong();
|
||||
@@ -2126,10 +2109,7 @@ void S_SetMusicVolume(INT32 digvolume, INT32 seqvolume)
|
||||
|
||||
void S_SetRestoreMusicFadeInCvar (consvar_t *cv)
|
||||
{
|
||||
if (!cv_birdmusic.value)
|
||||
return;
|
||||
|
||||
music_refade_cv = cv;
|
||||
music_refade_cv = cv_birdmusic.value ? cv : 0;
|
||||
}
|
||||
|
||||
int S_GetRestoreMusicFadeIn (void)
|
||||
@@ -2388,7 +2368,7 @@ static void GameDigiMusic_OnChange(void)
|
||||
digital_disabled = false;
|
||||
I_StartupSound(); // will return early if initialised
|
||||
I_InitMusic();
|
||||
|
||||
|
||||
if (Playing())
|
||||
P_RestoreMusic(&players[consoleplayer]);
|
||||
else
|
||||
@@ -2425,14 +2405,12 @@ static void ModFilter_OnChange(void)
|
||||
{
|
||||
if (openmpt_mhandle)
|
||||
openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_INTERPOLATIONFILTER_LENGTH, cv_modfilter.value);
|
||||
|
||||
}
|
||||
|
||||
static void StereoSep_OnChange(void)
|
||||
{
|
||||
if (openmpt_mhandle)
|
||||
openmpt_module_set_render_param(openmpt_mhandle, OPENMPT_MODULE_RENDER_STEREOSEPARATION_PERCENT, cv_stereosep.value);
|
||||
|
||||
}
|
||||
|
||||
static void AmigaFilter_OnChange(void)
|
||||
|
||||
+1
-1
@@ -32,7 +32,6 @@ extern consvar_t stereoreverse;
|
||||
extern consvar_t cv_soundvolume, cv_digmusicvolume;//, cv_midimusicvolume;
|
||||
extern consvar_t cv_numChannels;
|
||||
|
||||
extern consvar_t surround;
|
||||
extern consvar_t cv_audbuffersize;
|
||||
//extern consvar_t cv_resetmusic;
|
||||
extern consvar_t cv_gamedigimusic;
|
||||
@@ -55,6 +54,7 @@ extern consvar_t cv_amigatype;
|
||||
|
||||
//bird music stuff
|
||||
extern consvar_t cv_music_resync_threshold;
|
||||
extern consvar_t cv_music_resync_powerups_only;
|
||||
|
||||
extern consvar_t cv_invincmusicfade;
|
||||
extern consvar_t cv_growmusicfade;
|
||||
|
||||
+29
-12
@@ -366,15 +366,13 @@ double averageFPS = 0.0f;
|
||||
#define USE_FPS_SAMPLES
|
||||
|
||||
#ifdef USE_FPS_SAMPLES
|
||||
#define MAX_FRAME_TIME 0.05
|
||||
#define MAX_FRAME_TIME (0.05)
|
||||
#define NUM_FPS_SAMPLES (16) // Number of samples to store
|
||||
#define NUM_FPS_SAMPLES2 (32) // Number of samples to store for inaccurate counter
|
||||
|
||||
static double total_frame_time = 0.0;
|
||||
static int frame_index;
|
||||
|
||||
static double fps_samples[NUM_FPS_SAMPLES2];
|
||||
static int fps_index;
|
||||
static double fps_samples[NUM_FPS_SAMPLES];
|
||||
#endif
|
||||
|
||||
static boolean fps_init = false;
|
||||
@@ -383,7 +381,6 @@ static precise_t fps_enter = 0;
|
||||
void SCR_CalculateFPS(void)
|
||||
{
|
||||
precise_t fps_finish = 0;
|
||||
int i;
|
||||
|
||||
double frameElapsed = 0.0;
|
||||
|
||||
@@ -398,10 +395,10 @@ void SCR_CalculateFPS(void)
|
||||
fps_enter = fps_finish;
|
||||
|
||||
#ifdef USE_FPS_SAMPLES
|
||||
total_frame_time += frameElapsed;
|
||||
|
||||
if (cv_accuratefps.value)
|
||||
{
|
||||
total_frame_time += frameElapsed;
|
||||
if (frame_index++ >= NUM_FPS_SAMPLES || total_frame_time >= MAX_FRAME_TIME)
|
||||
{
|
||||
averageFPS = 1.0 / (total_frame_time / frame_index);
|
||||
@@ -411,13 +408,33 @@ void SCR_CalculateFPS(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
fps_samples[fps_index] = frameElapsed / NUM_FPS_SAMPLES2;
|
||||
fps_index = (fps_index + 1) % NUM_FPS_SAMPLES2;
|
||||
if (total_frame_time >= MAX_FRAME_TIME)
|
||||
{
|
||||
static int sampleIndex = 0;
|
||||
int i;
|
||||
|
||||
averageFPS = 0.0;
|
||||
for (i = 0; i < NUM_FPS_SAMPLES2; i++)
|
||||
averageFPS += fps_samples[i];
|
||||
averageFPS = 1.0 / averageFPS;
|
||||
fps_samples[sampleIndex] = frameElapsed;
|
||||
|
||||
sampleIndex++;
|
||||
if (sampleIndex >= NUM_FPS_SAMPLES)
|
||||
sampleIndex = 0;
|
||||
|
||||
averageFPS = 0.0;
|
||||
for (i = 0; i < NUM_FPS_SAMPLES; i++)
|
||||
{
|
||||
averageFPS += fps_samples[i];
|
||||
}
|
||||
|
||||
if (averageFPS > 0.0)
|
||||
{
|
||||
averageFPS = 1.0 / (averageFPS / NUM_FPS_SAMPLES);
|
||||
}
|
||||
}
|
||||
|
||||
while (total_frame_time >= MAX_FRAME_TIME)
|
||||
{
|
||||
total_frame_time -= MAX_FRAME_TIME;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// Direct, unsampled counter.
|
||||
|
||||
+3
-3
@@ -39,12 +39,12 @@
|
||||
// we try to re-allocate a minimum of buffers for stability of the memory,
|
||||
// so all the small-enough tables based on screen size, are allocated once
|
||||
// and for all at the maximum size.
|
||||
#define MAXVIDWIDTH 2560 // don't set this too high because actually
|
||||
#define MAXVIDHEIGHT 1440 // lots of tables are allocated with the MAX size.
|
||||
#define MAXVIDWIDTH 5120 // don't set this too high because actually
|
||||
#define MAXVIDHEIGHT 2880 // lots of tables are allocated with the MAX size.
|
||||
#define BASEVIDWIDTH 320 // NEVER CHANGE THIS! This is the original
|
||||
#define BASEVIDHEIGHT 200 // resolution of the graphics.
|
||||
|
||||
// max res for png capture; seperated it so both MAXVID values can be lower for software performance reasons; OpenGL does not care about those anyways
|
||||
// max res for png capture; just here to prevent some crashes on very high resoltions; tho you should never go this high cause ogl allocs certain things with MAXVIDWIDTH and MAXVIDHEIGHT too Zzz...
|
||||
#define MAXPNGWIDTH 7680
|
||||
#define MAXPNGHEIGHT 4320
|
||||
|
||||
|
||||
+93
-88
@@ -111,6 +111,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T);
|
||||
#endif
|
||||
|
||||
#if defined (__unix__) || (defined (UNIXCOMMON) && !defined (__APPLE__))
|
||||
#include <poll.h>
|
||||
#include <errno.h>
|
||||
#include <sys/wait.h>
|
||||
#define NEWSIGNALHANDLER
|
||||
@@ -544,10 +545,9 @@ typedef struct
|
||||
|
||||
feild_t tty_con;
|
||||
|
||||
// when printing general stuff to stdout stderr (Sys_Printf)
|
||||
// we need to disable the tty console stuff
|
||||
// this increments so we can recursively disable
|
||||
static INT32 ttycon_hide = 0;
|
||||
// lock to prevent clearing partial lines, since not everything
|
||||
// printed ends on a newline.
|
||||
static boolean ttycon_ateol = true;
|
||||
// some key codes that the terminal may be using
|
||||
// TTimo NOTE: I'm not sure how relevant this is
|
||||
static INT32 tty_erase;
|
||||
@@ -575,63 +575,31 @@ static inline void tty_FlushIn(void)
|
||||
// TTimo NOTE: it seems on some terminals just sending '\b' is not enough
|
||||
// so for now, in any case we send "\b \b" .. yeah well ..
|
||||
// (there may be a way to find out if '\b' alone would work though)
|
||||
// Hanicef NOTE: using \b this way is unreliable because of terminal state,
|
||||
// it's better to use \r to reset the cursor to the beginning of the
|
||||
// line and clear from there.
|
||||
static void tty_Back(void)
|
||||
{
|
||||
char key;
|
||||
ssize_t d;
|
||||
key = '\b';
|
||||
d = write(STDOUT_FILENO, &key, 1);
|
||||
key = ' ';
|
||||
d = write(STDOUT_FILENO, &key, 1);
|
||||
key = '\b';
|
||||
d = write(STDOUT_FILENO, &key, 1);
|
||||
(void)d;
|
||||
write(STDOUT_FILENO, "\r", 1);
|
||||
if (tty_con.cursor>0)
|
||||
{
|
||||
write(STDOUT_FILENO, tty_con.buffer, tty_con.cursor);
|
||||
}
|
||||
write(STDOUT_FILENO, " \b", 2);
|
||||
}
|
||||
|
||||
static void tty_Clear(void)
|
||||
{
|
||||
size_t i;
|
||||
write(STDOUT_FILENO, "\r", 1);
|
||||
if (tty_con.cursor>0)
|
||||
{
|
||||
for (i=0; i<tty_con.cursor; i++)
|
||||
{
|
||||
tty_Back();
|
||||
write(STDOUT_FILENO, " ", 1);
|
||||
}
|
||||
write(STDOUT_FILENO, "\r", 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// clear the display of the line currently edited
|
||||
// bring cursor back to beginning of line
|
||||
static inline void tty_Hide(void)
|
||||
{
|
||||
//I_Assert(consolevent);
|
||||
if (ttycon_hide)
|
||||
{
|
||||
ttycon_hide++;
|
||||
return;
|
||||
}
|
||||
tty_Clear();
|
||||
ttycon_hide++;
|
||||
}
|
||||
|
||||
// show the current line
|
||||
// FIXME TTimo need to position the cursor if needed??
|
||||
static inline void tty_Show(void)
|
||||
{
|
||||
size_t i;
|
||||
ssize_t d;
|
||||
//I_Assert(consolevent);
|
||||
I_Assert(ttycon_hide>0);
|
||||
ttycon_hide--;
|
||||
if (ttycon_hide == 0 && tty_con.cursor)
|
||||
{
|
||||
for (i=0; i<tty_con.cursor; i++)
|
||||
{
|
||||
d = write(STDOUT_FILENO, tty_con.buffer+i, 1);
|
||||
}
|
||||
}
|
||||
(void)d;
|
||||
}
|
||||
|
||||
// never exit without calling this, or your terminal will be left in a pretty bad state
|
||||
@@ -698,50 +666,65 @@ void I_GetConsoleEvents(void)
|
||||
// we use this when sending back commands
|
||||
event_t ev = {0,0,0,0};
|
||||
char key = 0;
|
||||
ssize_t d;
|
||||
struct pollfd pfd =
|
||||
{
|
||||
.fd = STDIN_FILENO,
|
||||
.events = POLLIN,
|
||||
.revents = 0,
|
||||
};
|
||||
|
||||
if (!consolevent)
|
||||
return;
|
||||
|
||||
ev.type = ev_console;
|
||||
ev.data1 = 0;
|
||||
if (read(STDIN_FILENO, &key, 1) == -1 || !key)
|
||||
return;
|
||||
for (;;)
|
||||
{
|
||||
if (poll(&pfd, 1, 0) < 1 || !(pfd.revents & POLLIN))
|
||||
return;
|
||||
|
||||
// we have something
|
||||
// backspace?
|
||||
// NOTE TTimo testing a lot of values .. seems it's the only way to get it to work everywhere
|
||||
if ((key == tty_erase) || (key == 127) || (key == 8))
|
||||
{
|
||||
if (tty_con.cursor > 0)
|
||||
ev.type = ev_console;
|
||||
ev.data1 = 0;
|
||||
if (read(STDIN_FILENO, &key, 1) == -1 || !key)
|
||||
return;
|
||||
|
||||
// we have something
|
||||
// backspace?
|
||||
// NOTE TTimo testing a lot of values .. seems it's the only way to get it to work everywhere
|
||||
if ((key == tty_erase) || (key == 127) || (key == 8))
|
||||
{
|
||||
tty_con.cursor--;
|
||||
tty_con.buffer[tty_con.cursor] = '\0';
|
||||
tty_Back();
|
||||
if (tty_con.cursor > 0)
|
||||
{
|
||||
tty_con.cursor--;
|
||||
tty_con.buffer[tty_con.cursor] = '\0';
|
||||
tty_Back();
|
||||
}
|
||||
ev.data1 = KEY_BACKSPACE;
|
||||
}
|
||||
ev.data1 = KEY_BACKSPACE;
|
||||
}
|
||||
else if (key < ' ') // check if this is a control char
|
||||
{
|
||||
if (key == '\n')
|
||||
else if (key < ' ') // check if this is a control char
|
||||
{
|
||||
tty_Clear();
|
||||
tty_con.cursor = 0;
|
||||
ev.data1 = KEY_ENTER;
|
||||
if (key == '\n')
|
||||
{
|
||||
tty_Clear();
|
||||
tty_con.cursor = 0;
|
||||
ev.data1 = KEY_ENTER;
|
||||
}
|
||||
else if (key == 0x4) // ^D, aka EOF
|
||||
{
|
||||
// shut down, most unix programs behave this way
|
||||
I_Quit();
|
||||
}
|
||||
else continue;
|
||||
}
|
||||
else return;
|
||||
else if (tty_con.cursor < sizeof(tty_con.buffer))
|
||||
{
|
||||
// push regular character
|
||||
ev.data1 = tty_con.buffer[tty_con.cursor] = key;
|
||||
tty_con.cursor++;
|
||||
// print the current line (this is differential)
|
||||
write(STDOUT_FILENO, &key, 1);
|
||||
}
|
||||
if (ev.data1) D_PostEvent(&ev);
|
||||
//tty_FlushIn();
|
||||
}
|
||||
else if (tty_con.cursor < sizeof (tty_con.buffer))
|
||||
{
|
||||
// push regular character
|
||||
ev.data1 = tty_con.buffer[tty_con.cursor] = key;
|
||||
tty_con.cursor++;
|
||||
// print the current line (this is differential)
|
||||
d = write(STDOUT_FILENO, &key, 1);
|
||||
}
|
||||
if (ev.data1) D_PostEvent(&ev);
|
||||
//tty_FlushIn();
|
||||
(void)d;
|
||||
}
|
||||
|
||||
#elif defined (_WIN32)
|
||||
@@ -937,9 +920,16 @@ static void I_RegisterChildSignals(void)
|
||||
void I_OutputMsg(const char *fmt, ...)
|
||||
{
|
||||
size_t len;
|
||||
char txt[8192];
|
||||
char *txt;
|
||||
va_list argptr;
|
||||
|
||||
va_start(argptr,fmt);
|
||||
len = vsnprintf(NULL, 0, fmt, argptr);
|
||||
va_end(argptr);
|
||||
if (len == 0)
|
||||
return;
|
||||
|
||||
txt = malloc(len+1);
|
||||
va_start(argptr,fmt);
|
||||
vsprintf(txt, fmt, argptr);
|
||||
va_end(argptr);
|
||||
@@ -973,7 +963,10 @@ void I_OutputMsg(const char *fmt, ...)
|
||||
DWORD bytesWritten;
|
||||
|
||||
if (co == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
free(txt);
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetFileType(co) == FILE_TYPE_CHAR && GetConsoleMode(co, &bytesWritten))
|
||||
{
|
||||
@@ -989,11 +982,16 @@ void I_OutputMsg(const char *fmt, ...)
|
||||
if (oldLength > 0)
|
||||
{
|
||||
LPVOID blank = malloc(oldLength);
|
||||
if (!blank) return;
|
||||
if (!blank)
|
||||
{
|
||||
free(txt);
|
||||
return;
|
||||
}
|
||||
memset(blank, ' ', oldLength); // Blank out.
|
||||
oldLines = malloc(oldLength*sizeof(TCHAR));
|
||||
if (!oldLines)
|
||||
{
|
||||
free(txt);
|
||||
free(blank);
|
||||
return;
|
||||
}
|
||||
@@ -1028,18 +1026,20 @@ void I_OutputMsg(const char *fmt, ...)
|
||||
}
|
||||
#else
|
||||
#ifdef HAVE_TERMIOS
|
||||
if (consolevent)
|
||||
if (consolevent && ttycon_ateol)
|
||||
{
|
||||
tty_Hide();
|
||||
tty_Clear();
|
||||
ttycon_ateol = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!framebuffer)
|
||||
fprintf(stderr, "%s", txt);
|
||||
#ifdef HAVE_TERMIOS
|
||||
if (consolevent)
|
||||
if (consolevent && txt[len-1] == '\n')
|
||||
{
|
||||
tty_Show();
|
||||
write(STDOUT_FILENO, tty_con.buffer, tty_con.cursor);
|
||||
ttycon_ateol = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1048,6 +1048,7 @@ void I_OutputMsg(const char *fmt, ...)
|
||||
fflush(stderr);
|
||||
|
||||
#endif
|
||||
free(txt);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2668,6 +2669,7 @@ void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength,
|
||||
(void)device_id;
|
||||
(void)low_strength;
|
||||
(void)high_strength;
|
||||
(void)duration;
|
||||
#else
|
||||
I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher
|
||||
|
||||
@@ -2685,6 +2687,9 @@ void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 b
|
||||
{
|
||||
#if !(SDL_VERSION_ATLEAST(2,0,14))
|
||||
(void)device_id;
|
||||
(void)red;
|
||||
(void)green;
|
||||
(void)blue;
|
||||
#else
|
||||
I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher
|
||||
|
||||
|
||||
@@ -93,6 +93,7 @@ static UINT16 SAMPLERATE = 44100;
|
||||
/// ------------------------
|
||||
|
||||
UINT8 sound_started = false;
|
||||
|
||||
static UINT32 stutter_threshold;
|
||||
|
||||
static Mix_Music *music;
|
||||
@@ -592,6 +593,9 @@ Countstutter (int len)
|
||||
{
|
||||
UINT32 bytes;
|
||||
|
||||
if (!cv_birdmusic.value || gamestate != GS_LEVEL)
|
||||
return;
|
||||
|
||||
if (hu_stopped)
|
||||
{
|
||||
music_stutter_bytes += len;
|
||||
@@ -627,8 +631,7 @@ static void count_music_bytes(int chan, void *stream, int len, void *udata)
|
||||
|
||||
music_bytes += len;
|
||||
|
||||
if (cv_birdmusic.value && gamestate == GS_LEVEL)
|
||||
Countstutter(len);
|
||||
Countstutter(len);
|
||||
}
|
||||
|
||||
static void music_loop(void)
|
||||
@@ -1041,12 +1044,9 @@ UINT32 I_GetSongPosition(void)
|
||||
// 8M: 1 | 8S: 2 | 16M: 2 | 16S: 4
|
||||
}
|
||||
|
||||
void I_UpdateSongLagThreshold (void)
|
||||
void I_UpdateSongLagThreshold(void)
|
||||
{
|
||||
if (!cv_birdmusic.value)
|
||||
return;
|
||||
|
||||
stutter_threshold = cv_music_resync_threshold.value/1000.0*(4*44100);
|
||||
stutter_threshold = cv_music_resync_powerups_only.value ? 0 : (cv_music_resync_threshold.value/1000.0*(4*44100));
|
||||
}
|
||||
|
||||
/// ------------------------
|
||||
|
||||
+82
-16
@@ -155,6 +155,8 @@ static patch_t *envelope;
|
||||
player_t *stplyr;
|
||||
UINT8 stplyrnum;
|
||||
|
||||
boolean directortextactive = false;
|
||||
|
||||
// SRB2kart
|
||||
|
||||
hudinfo_t hudinfo[NUMHUDITEMS] =
|
||||
@@ -662,23 +664,30 @@ static void ST_overlayDrawer(void)
|
||||
|
||||
if (!hu_showscores) // hide the following if TAB is held
|
||||
{
|
||||
if (cv_showdirectorhud.value && ((demo.playback && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !splitscreen)
|
||||
if (cv_showdirectorhud.value && ((demo.playback && !demo.freecam && (!demo.title || !modeattacking)) || !P_IsLocalPlayer(stplyr)) && !splitscreen)
|
||||
{
|
||||
char directortext[20] = {0};
|
||||
|
||||
snprintf(directortext, 20, "Director: %s", cv_director.value ? "On" : "Off");
|
||||
|
||||
if (directortoggletimer < 4*TICRATE)
|
||||
directortextactive = true;
|
||||
|
||||
if ((!demo.playback && directortoggletimer < 13*TICRATE) || (demo.playback && directortoggletimer < 4*TICRATE))
|
||||
{
|
||||
V_DrawString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANSHALF|V_ALLOWLOWERCASE, directortext);
|
||||
if (renderisnewtic)
|
||||
directortoggletimer++;
|
||||
|
||||
if (directortoggletimer < 4*TICRATE)
|
||||
V_DrawString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_HUDTRANSHALF|V_ALLOWLOWERCASE, directortext);
|
||||
else if (cv_translucenthud.value != 0)
|
||||
V_DrawString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_80TRANS|V_ALLOWLOWERCASE, directortext); // idk if V_80TRANS is good?
|
||||
}
|
||||
else if (cv_translucenthud.value != 0)
|
||||
V_DrawString(1, BASEVIDHEIGHT-8-1, V_SNAPTOLEFT|V_SNAPTOBOTTOM|V_80TRANS|V_ALLOWLOWERCASE, directortext); // idk if V_80TRANS is good?
|
||||
}
|
||||
else
|
||||
{
|
||||
directortoggletimer = 0;
|
||||
directortextactive = false;
|
||||
}
|
||||
|
||||
if (cv_showviewpointtext.value)
|
||||
{
|
||||
@@ -695,7 +704,7 @@ static void ST_overlayDrawer(void)
|
||||
V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_SNAPTOBOTTOM|V_HUDTRANS|V_ALLOWLOWERCASE, player_names[stplyr-players]);
|
||||
}
|
||||
}
|
||||
else if (!demo.title)
|
||||
else if (!demo.title && !demo.freecam)
|
||||
{
|
||||
if (!splitscreen)
|
||||
{
|
||||
@@ -799,25 +808,82 @@ static void ST_overlayDrawer(void)
|
||||
}
|
||||
}
|
||||
|
||||
void ST_DrawDemoTitleEntry(void)
|
||||
static void ST_DrawTextInput(INT32 x, INT32 y, textinput_t *input, INT32 flags)
|
||||
{
|
||||
static UINT8 skullAnimCounter = 0;
|
||||
char *nametodraw;
|
||||
static const INT32 MAXINPUTWIDTH = (MAXSTRINGLENGTH-1)*8;
|
||||
|
||||
skullAnimCounter++;
|
||||
if (renderisnewtic)
|
||||
skullAnimCounter++;
|
||||
skullAnimCounter %= 8;
|
||||
|
||||
nametodraw = demo.titlename;
|
||||
while (V_StringWidth(nametodraw, 0) > MAXSTRINGLENGTH*8 - 8)
|
||||
nametodraw++;
|
||||
char nametodraw[MAXSTRINGLENGTH*2+1] = {0};
|
||||
|
||||
size_t drawstart = 0;
|
||||
size_t drawend = 0; // Only used for selection
|
||||
|
||||
INT32 skullx = x;
|
||||
|
||||
while (V_SubStringWidth(input->buffer+drawstart, input->cursor-drawstart, V_ALLOWLOWERCASE) > MAXINPUTWIDTH)
|
||||
++drawstart;
|
||||
|
||||
size_t drawlength = V_SubStringLengthToFit(input->buffer+drawstart, MAXINPUTWIDTH+8, V_ALLOWLOWERCASE)+1;
|
||||
drawend = drawstart + drawlength;
|
||||
|
||||
memcpy(nametodraw, input->buffer+drawstart, drawlength);
|
||||
|
||||
if (input->length)
|
||||
skullx += V_SubStringWidth(nametodraw, input->cursor-drawstart, V_ALLOWLOWERCASE);
|
||||
|
||||
V_DrawString(x, y, V_ALLOWLOWERCASE|flags, nametodraw);
|
||||
|
||||
// draw text cursor for name
|
||||
if (skullAnimCounter < 4) // blink cursor
|
||||
V_DrawCharacter(skullx, y+3, '_'|flags, false);
|
||||
|
||||
// draw selection
|
||||
if (input->select != input->cursor)
|
||||
{
|
||||
size_t start = min(input->select, input->cursor);
|
||||
size_t end = max(input->select, input->cursor);
|
||||
|
||||
INT32 startx = 0;
|
||||
INT32 width = 0;
|
||||
|
||||
// I couldn't figure out one formula so here's bunch of separate cases
|
||||
if (start < drawstart && end > drawend) // Selection covers whole visible portion of demo name
|
||||
{
|
||||
startx = -2;
|
||||
width = V_StringWidth(nametodraw, V_ALLOWLOWERCASE)+4;
|
||||
}
|
||||
else if (start < drawstart) // Only left side of selection is off visible part
|
||||
{
|
||||
startx = -2;
|
||||
size_t len = (end - start) - (drawstart - start);
|
||||
width = V_SubStringWidth(nametodraw, len, V_ALLOWLOWERCASE)+2;
|
||||
}
|
||||
else if (end > drawend) // Only right side of selection is off visible part
|
||||
{
|
||||
startx = V_SubStringWidth(nametodraw, start-drawstart, V_ALLOWLOWERCASE);
|
||||
width = V_StringWidth(nametodraw+(start-drawstart), V_ALLOWLOWERCASE)+2;
|
||||
}
|
||||
else // All selection is on visible part
|
||||
{
|
||||
startx = V_SubStringWidth(nametodraw, start-drawstart, V_ALLOWLOWERCASE);
|
||||
width = V_SubStringWidth(nametodraw+(start-drawstart), end-start, V_ALLOWLOWERCASE);
|
||||
}
|
||||
|
||||
V_DrawFill(x+startx, y, width, 8, 103|V_TRANSLUCENT|flags);
|
||||
}
|
||||
}
|
||||
|
||||
void ST_DrawDemoTitleEntry(void)
|
||||
{
|
||||
#define x (BASEVIDWIDTH/2 - 139)
|
||||
#define y (BASEVIDHEIGHT/2)
|
||||
M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1);
|
||||
V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, nametodraw);
|
||||
if (skullAnimCounter < 4)
|
||||
V_DrawCharacter(x + 8 + V_StringWidth(nametodraw, 0), y + 12,
|
||||
'_' | 0x80, false);
|
||||
|
||||
ST_DrawTextInput(x + 8, y + 12, &demo.titlenameinput, 0);
|
||||
|
||||
M_DrawTextBox(x + 30, y - 24, 26, 1);
|
||||
V_DrawString(x + 38, y - 16, V_ALLOWLOWERCASE, "Enter the name of the replay.");
|
||||
|
||||
@@ -146,4 +146,6 @@ extern UINT16 objectsdrawn;
|
||||
extern consvar_t cv_lessflicker;
|
||||
extern consvar_t cv_stagetitle;
|
||||
|
||||
extern boolean directortextactive;
|
||||
|
||||
#endif
|
||||
+70
-24
@@ -1611,21 +1611,19 @@ void V_DrawFadeScreen(UINT16 color, UINT8 strength)
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
const UINT8 *fadetable =
|
||||
(color > 0xFFF0) // Grab a specific colormap palette?
|
||||
? R_GetTranslationColormap(color | 0xFFFF0000, strength, GTC_CACHE)
|
||||
: ((color & 0xFF00) // Color is not palette index?
|
||||
? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade.
|
||||
: ((UINT8 *)transtables + ((9-strength)<<FF_TRANSSHIFT) + color*256)); // Else, do TRANSMAP** fade.
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
UINT8 *buf = screens[0];
|
||||
const UINT8 *fadetable =
|
||||
(color > 0xFFF0) // Grab a specific colormap palette?
|
||||
? R_GetTranslationColormap(color | 0xFFFF0000, strength, GTC_CACHE)
|
||||
: ((color & 0xFF00) // Color is not palette index?
|
||||
? ((UINT8 *)colormaps + strength*256) // Do COLORMAP fade.
|
||||
: ((UINT8 *)transtables + ((9-strength)<<FF_TRANSSHIFT) + color*256)); // Else, do TRANSMAP** fade.
|
||||
const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height;
|
||||
UINT8 *buf = screens[0];
|
||||
|
||||
// heavily simplified -- we don't need to know x or y
|
||||
// position when we're doing a full screen fade
|
||||
for (; buf < deststop; ++buf)
|
||||
*buf = fadetable[*buf];
|
||||
}
|
||||
// heavily simplified -- we don't need to know x or y
|
||||
// position when we're doing a full screen fade
|
||||
for (; buf < deststop; ++buf)
|
||||
*buf = fadetable[*buf];
|
||||
}
|
||||
|
||||
// Simple translucency with one color, over a set number of lines starting from the top.
|
||||
@@ -2845,11 +2843,14 @@ INT32 V_LevelNameHeight(const char *string)
|
||||
//
|
||||
// Find string width from hu_font chars
|
||||
//
|
||||
INT32 V_StringWidth(const char *string, INT32 option)
|
||||
INT32 V_SubStringWidth(const char *string, INT32 length, INT32 option)
|
||||
{
|
||||
INT32 c, w = 0;
|
||||
INT32 spacewidth = 4, charwidth = 0;
|
||||
size_t i;
|
||||
ssize_t i;
|
||||
|
||||
if (length < 0)
|
||||
length = strlen(string);
|
||||
|
||||
switch (option & V_SPACINGMASK)
|
||||
{
|
||||
@@ -2865,7 +2866,7 @@ INT32 V_StringWidth(const char *string, INT32 option)
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < strlen(string); i++)
|
||||
for (i = 0; string[i] && i < length; i++)
|
||||
{
|
||||
c = string[i];
|
||||
if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09
|
||||
@@ -2884,11 +2885,14 @@ INT32 V_StringWidth(const char *string, INT32 option)
|
||||
//
|
||||
// Find string width from hu_font chars, 0.5x scale
|
||||
//
|
||||
INT32 V_SmallStringWidth(const char *string, INT32 option)
|
||||
INT32 V_SmallSubStringWidth(const char *string, INT32 length, INT32 option)
|
||||
{
|
||||
INT32 c, w = 0;
|
||||
INT32 spacewidth = 2, charwidth = 0;
|
||||
size_t i;
|
||||
ssize_t i;
|
||||
|
||||
if (length < 0)
|
||||
length = strlen(string);
|
||||
|
||||
switch (option & V_SPACINGMASK)
|
||||
{
|
||||
@@ -2904,7 +2908,7 @@ INT32 V_SmallStringWidth(const char *string, INT32 option)
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < strlen(string); i++)
|
||||
for (i = 0; string[i] && i < length; i++)
|
||||
{
|
||||
c = string[i];
|
||||
if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09
|
||||
@@ -2923,12 +2927,15 @@ INT32 V_SmallStringWidth(const char *string, INT32 option)
|
||||
//
|
||||
// Find string width from tny_font chars
|
||||
//
|
||||
INT32 V_ThinStringWidth(const char *string, INT32 option)
|
||||
INT32 V_ThinSubStringWidth(const char *string, INT32 length, INT32 option)
|
||||
{
|
||||
INT32 c, w = 0;
|
||||
INT32 spacewidth = 2, charwidth = 0;
|
||||
boolean lowercase = (option & V_ALLOWLOWERCASE);
|
||||
size_t i;
|
||||
ssize_t i;
|
||||
|
||||
if (length < 0)
|
||||
length = strlen(string);
|
||||
|
||||
switch (option & V_SPACINGMASK)
|
||||
{
|
||||
@@ -2945,7 +2952,7 @@ INT32 V_ThinStringWidth(const char *string, INT32 option)
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < strlen(string); i++)
|
||||
for (i = 0; string[i] && i < length; i++)
|
||||
{
|
||||
c = string[i];
|
||||
if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09
|
||||
@@ -2963,7 +2970,7 @@ INT32 V_ThinStringWidth(const char *string, INT32 option)
|
||||
else
|
||||
{
|
||||
w += (charwidth ? charwidth
|
||||
: ((option & V_6WIDTHSPACE && i < strlen(string)-1) ? max(1, SHORT(tny_font[c]->width)-1) // Reuse this flag for the alternate bunched-up spacing
|
||||
: ((option & V_6WIDTHSPACE && i < length-1) ? max(1, SHORT(tny_font[c]->width)-1) // Reuse this flag for the alternate bunched-up spacing
|
||||
: SHORT(tny_font[c]->width)));
|
||||
}
|
||||
}
|
||||
@@ -2972,6 +2979,45 @@ INT32 V_ThinStringWidth(const char *string, INT32 option)
|
||||
return w;
|
||||
}
|
||||
|
||||
//
|
||||
// Find maximum length for substring taken from current string to fit into given width
|
||||
//
|
||||
INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option)
|
||||
{
|
||||
INT32 c, w = 0;
|
||||
INT32 spacewidth = 4, charwidth = 0;
|
||||
INT32 i;
|
||||
|
||||
switch (option & V_SPACINGMASK)
|
||||
{
|
||||
case V_MONOSPACE:
|
||||
spacewidth = 8;
|
||||
/* FALLTHRU */
|
||||
case V_OLDSPACING:
|
||||
charwidth = 8;
|
||||
break;
|
||||
case V_6WIDTHSPACE:
|
||||
spacewidth = 6;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; string[i] && w < width; i++)
|
||||
{
|
||||
c = string[i];
|
||||
if ((UINT8)c >= 0x80 && (UINT8)c <= 0x8F) //color parsing! -Inuyasha 2.16.09
|
||||
continue;
|
||||
|
||||
c = toupper(c) - HU_FONTSTART;
|
||||
if (c < 0 || c >= HU_FONTSIZE || !hu_font[c])
|
||||
w += spacewidth;
|
||||
else
|
||||
w += (charwidth ? charwidth : SHORT(hu_font[c]->width));
|
||||
}
|
||||
|
||||
return max(i-1, 0);
|
||||
}
|
||||
|
||||
char V_GetSkincolorChar(INT32 color)
|
||||
{
|
||||
char cstart = 0x80;
|
||||
|
||||
+9
-3
@@ -237,11 +237,17 @@ void V_DrawCreditString(fixed_t x, fixed_t y, INT32 option, const char *string);
|
||||
INT32 V_CreditStringWidth(const char *string);
|
||||
|
||||
// Find string width from hu_font chars
|
||||
INT32 V_StringWidth(const char *string, INT32 option);
|
||||
INT32 V_SubStringWidth(const char *string, INT32 length, INT32 option);
|
||||
#define V_StringWidth(string, option) V_SubStringWidth(string, -1, option)
|
||||
// Find string width from hu_font chars, 0.5x scale
|
||||
INT32 V_SmallStringWidth(const char *string, INT32 option);
|
||||
INT32 V_SmallSubStringWidth(const char *string, INT32 length, INT32 option);
|
||||
#define V_SmallStringWidth(string, option) V_SmallSubStringWidth(string, -1, option)
|
||||
// Find string width from tny_font chars
|
||||
INT32 V_ThinStringWidth(const char *string, INT32 option);
|
||||
INT32 V_ThinSubStringWidth(const char *string, INT32 length, INT32 option);
|
||||
#define V_ThinStringWidth(string, option) V_ThinSubStringWidth(string, -1, option)
|
||||
|
||||
// Find maximum length for substring taken from current string to fit into given width
|
||||
INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option);
|
||||
|
||||
char V_GetSkincolorChar(INT32 color);
|
||||
|
||||
|
||||
+16
-8
@@ -2145,11 +2145,11 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
size_t *vsizecache;
|
||||
|
||||
// Remember that we're assuming that the WAD will have a specific set of lumps in a specific order.
|
||||
UINT8 *wadData = W_CacheLumpNum(lumpnum, PU_LEVEL);
|
||||
UINT8 *wadData = (UINT8*)(W_CacheLumpNum(lumpnum, PU_LEVEL));
|
||||
filelump_t *fileinfo = (filelump_t *)(wadData + LONG(((wadinfo_t *)wadData)->infotableofs));
|
||||
|
||||
i = LONG(((wadinfo_t *)wadData)->numlumps);
|
||||
vsizecache = Z_Malloc(sizeof(size_t)*i, PU_LEVEL, NULL);
|
||||
vsizecache = (size_t*)(Z_Malloc(sizeof(size_t)*i, PU_LEVEL, NULL));
|
||||
|
||||
for (realentry = 0; realentry < i; realentry++)
|
||||
{
|
||||
@@ -2161,7 +2161,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
numlumps++;
|
||||
}
|
||||
|
||||
vlumps = Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL);
|
||||
vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
|
||||
|
||||
// Build the lumps, skipping over empty entries.
|
||||
for (i = 0, realentry = 0; i < numlumps; realentry++)
|
||||
@@ -2180,7 +2180,9 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
// Play it safe with the name in this case.
|
||||
memcpy(vlumps[i].name, name, 8);
|
||||
vlumps[i].name[8] = '\0';
|
||||
vlumps[i].data = Z_Malloc(vlumps[i].size, PU_LEVEL, NULL); // This is memory inefficient, sorry about that.
|
||||
vlumps[i].data = (UINT8*)(
|
||||
Z_Malloc(vlumps[i].size, PU_LEVEL, NULL) // This is memory inefficient, sorry about that.
|
||||
);
|
||||
memcpy(vlumps[i].data, wadData + LONG((fileinfo + realentry)->filepos), vlumps[i].size);
|
||||
i++;
|
||||
}
|
||||
@@ -2201,7 +2203,7 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
}
|
||||
numlumps++;
|
||||
|
||||
vlumps = Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL);
|
||||
vlumps = (virtlump_t*)(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
|
||||
for (i = 0; i < numlumps; i++, lumpnum++)
|
||||
{
|
||||
// Check if it is map marker. It is not always first lump sadly, so we need to expect it anywhere
|
||||
@@ -2216,10 +2218,10 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
vlumps[i].size = W_LumpLength(lumpnum);
|
||||
memcpy(vlumps[i].name, name, 8);
|
||||
vlumps[i].name[8] = '\0';
|
||||
vlumps[i].data = W_CacheLumpNum(lumpnum, PU_LEVEL);
|
||||
vlumps[i].data = (UINT8*)(W_CacheLumpNum(lumpnum, PU_LEVEL));
|
||||
}
|
||||
}
|
||||
vres = Z_Malloc(sizeof(virtres_t), PU_LEVEL, NULL);
|
||||
vres = (virtres_t*)(Z_Malloc(sizeof(virtres_t), PU_LEVEL, NULL));
|
||||
vres->vlumps = vlumps;
|
||||
vres->numlumps = numlumps;
|
||||
|
||||
@@ -2239,7 +2241,13 @@ void vres_Free(virtres_t* vres)
|
||||
}
|
||||
|
||||
while (vres->numlumps--)
|
||||
Z_Free(vres->vlumps[vres->numlumps].data);
|
||||
{
|
||||
if (vres->vlumps[vres->numlumps].data)
|
||||
{
|
||||
Z_Free(vres->vlumps[vres->numlumps].data);
|
||||
}
|
||||
}
|
||||
|
||||
Z_Free(vres->vlumps);
|
||||
Z_Free(vres);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user