Compare commits

..
Author SHA1 Message Date
Alug 24163a7c92 Merge branch 'Saturn-Next' into controllerfixes 2025-11-11 14:53:40 +01:00
Alug d934197246 git merge pls 2025-11-11 14:49:11 +01:00
Alug bcd54110d5 only call netkeepalive between calls during gl precache
this caused some crashes in blankart, hopefully this is fine though
2025-11-11 14:19:11 +01:00
Alug 83d538b16a gl_viewludsin/viewludcos is only needed for sprite billboarding
which is not needed with shearing
2025-11-11 14:19:08 +01:00
Alug 2a6a7e1d2b smol optimization R_NoEncore
reuse secspecial for invertencore check
2025-11-11 14:19:06 +01:00
Alug c977c4fc45 initialize most of our global variables
just to be safe, not really trusting the game at this point, maybe this helps with some obscure bugs or smth lel
2025-11-11 14:19:02 +01:00
Alug 87e0b55f01 fix windowmoved never resetting 2025-11-09 19:13:49 +01:00
Alug 54f5b5ebfb enable software cyan pixel "cutting" for flats by default 2025-11-08 12:30:58 +01:00
Alug b421893646 call NetKeepAlive during ogl precache
should prevent timeouts on slower systems (*cough* *cough* windoze *cough*) hopefully
thx neppy for the idea!
2025-11-07 21:28:45 +01:00
Alug 237aeb7834 use early returns for "I_Finish" stuff
i like that more, less checks for stuff
2025-11-07 21:28:42 +01:00
Alug 7dbd95d556 Merge pull request #208 from Indev450/deletglseg
Remove OpenGL adjusted "segs"
2025-11-06 21:03:38 +01:00
Alug 1e4ba39691 Merge pull request #209 from Indev450/gammastuff
Port RR´s gamma correction + split gamma and brightness
2025-11-06 21:02:37 +01:00
Alug a7805ae3f0 Merge branch 'Saturn-Next' into gammastuff 2025-11-06 21:01:49 +01:00
Alug 325338bfbf sound precache: add option to keep sounds cached but not precache them
ugh i suck so much at explaining
this is the default now pretty much
2025-11-06 20:41:07 +01:00
Alug 01a54e4d0b delete remaining M_Memcpy that were missed
those werent there in lugstuff branch oops lel
2025-11-06 19:15:59 +01:00
Alug e2df018e38 simplify srb2::floattofixed
my tired ass didnt think about just reusing shit kek
ty indev <3
2025-11-06 19:01:25 +01:00
indev 33b62cba33 Push empty string instead of null if len == 0 in lua_pushlstring 2025-11-06 20:44:29 +03:00
Alug 29b4f78b64 lib_concat: fix zero lenght string case
continue the loop, not return, it might just be an empty line, so returning might break some luas
0 lenght would make realloc allocate nothing at all, so just skip it
2025-11-06 18:44:36 +01:00
Alug bce18e3d61 delet M_Memcpy
was just a wrapper for memcpy eitherway
so should make no difference other than avoid any confusion
figured i could just use "sed" command lel
2025-11-06 17:37:19 +01:00
Alug e9c2b982c6 smol cleanup JoyAxis stuff & g_game 2025-11-06 17:37:15 +01:00
Alug 67e1793f49 software renderer: handle some float type related issues with slope drawers
there were a bunch of cases where inf and nan float results were casted and used with integer things, which is undefined in c

yes i did use ceepeepee for that crap, cause this wouldve been really annoying without templating
if someone really wants that crap to use outside ceepeepee, feel free to make a bunch of wrappers cause im too lazy for that stuff
2025-11-05 23:41:56 +01:00
Alug 80613a8a49 R_AllocClippingTables & R_AllocTextureColumnTables: fix nullptr arithmetic 2025-11-05 23:04:21 +01:00
Alug b017a72026 R_DrawPlanes: dont increment garbage ptr
does not need to be there at all eitherways
2025-11-05 23:04:18 +01:00
Alug a7c5254a32 set "-Wno-cast-qual" for clang
see comment
2025-11-05 23:04:15 +01:00
Alug 9dd1a47969 fix SINT8 write macro, fix big endian READUINT32 macro 2025-11-05 23:04:13 +01:00
Alug bbbd42e653 use "offsetof" for skydome vbo offsets
silences UBSAN complaining about accessing struct members through null ptr
2025-11-05 23:04:10 +01:00
Alug 2b7f2da5ee Mipmaps: fix translucent textures turning black
i.e. since we allow texture filtering on translucent textures now, the min filter may specifcy one of the mipmap filters, this means we NEED to call GL_GENERATE_MIPMAP and set the LODs for them, otherwise no texture will be generated
alternatively we could do a bunch of special cases for the mipmap filters, but this is simpler
2025-11-02 14:36:08 +01:00
Blue Staggo 23ba827726 Give midtextures filtering without ugly borders + Clean up padding code
Couldn't do proper translucent blending on midtextures because of wrapping.
2025-11-02 14:36:04 +01:00
Blue Staggo 326a28ec36 Oops, forgot to disable padding for nearest texture mode 2025-11-02 14:36:00 +01:00
Blue Staggo 19d6a1600e Optimise padding algorithm 2025-11-02 14:35:56 +01:00
Alug 3095303a4b Revert "simplify vhs effect interpolation"
This reverts commit e26fb91350.
2025-11-02 14:35:28 +01:00
Alug 2a1807422c Merge branch 'fastcmpstuff' into Saturn-Next 2025-11-01 23:45:22 +01:00
Alug 4676885521 fixup: replace stricmp with fasticmp
actually replace everything correctly
my dumbass forgor about the fast both strcmp and stricmp matter in sort stuff so we cannot use the fastcmp stuff there, which means we should not redifine stricmp as fasticmp in case something relies on that behaviour ugh
2025-11-01 23:45:06 +01:00
Alug 30cea37248 use npow2 screen textures if GL_ARB_texture_non_power_of_two is supported
apparently some gl drivers may use a slower path for streamed textures that only get partly updated, this tricks them into thinking this did a "full update" and resulting in using a faster renderpath
2025-11-01 23:42:35 +01:00
Alug 080d3c6b18 Merge branch 'luacvarfixes' into Saturn-Next 2025-11-01 23:38:39 +01:00
Alug df10855483 fix oopsie that broke name change 2025-11-01 23:15:38 +01:00
Alug dc6bf05f35 experiment: replace every strcasecmp with fasticmp
same as before, tho this is not twice as fast but atleast 1/3 faster
2025-11-01 23:15:26 +01:00
Alug 871545024d experiment: replace every strcmp with fastcmp
did some profiling and in basically every single test fastcmp was twice as fast as strcmp
maybe this speeds up some things
2025-11-01 23:15:21 +01:00
Alug aeb172f2ab do some smol cleanup r_skins
mostly style fixes, some minor caching for some things
2025-11-01 22:35:34 +01:00
Alug 95d8864faa fix software hiding the wrong thing in video options 2025-10-26 02:19:35 +01:00
Alug da67f6feb8 rename most "gamma" vars to "brightness"
lots of confusion
but it does more brightness adjustment than gamma adjustments, yes this does some gamma correction but not user changable global gamma adjustments like globalgamma
uhhh
2025-10-25 22:21:37 +02:00
Alug 8cc73bc482 Port RR´s gamma correction + split gamma and brightness
port of https://gitlab.com/kart-krew-dev/ring-racers/-/commit/e27506c660933e19dbcfe9ec776caf7819952e30
not cherry picked since it differs too much it would be hellish to untangle (sry!)
Gamma is split from brightness since both do somewhat different things in the context here
2025-10-25 22:21:19 +02:00
Alug d4a130f1dc remove those memsets
not needed anymore now
2025-10-24 18:40:29 +02:00
Alug 8ccf4eb9ba this can be alot smoler 2025-10-24 18:40:25 +02:00
Alug cdb7b6fede initialize input events to something 2025-10-24 18:40:21 +02:00
Alug fcae072625 refactor controller dpad menu repeat handling
dont hack around manually checking for state checks
just use sdl provided stuff and poll if a dpad button currently is being held
2025-10-24 18:40:18 +02:00
Alug 1d3dae01e9 set SDL_HINT_AUTO_UPDATE_SENSORS hint to 0
we dont need any of that so disable it
2025-10-23 20:58:01 +02:00
Alug 736a626ccf init joyinfo in I_InitJoystick 2025-10-23 20:57:58 +02:00
Alug a4cc8b0585 keep track of joystick instance index
means we dont constantly need to refetch it
needs testing on windoze
2025-10-23 20:57:55 +02:00
Alug 333c94be52 clean up controller dpad input handling
just treat them as "normal" buttons instead of manually polling for them
alot cleaner and gets rid of yet another polling loop
also clean up some other stuff
needs to be tested with multiple controllers in splitscreen but cba to do that atm
2025-10-23 20:57:52 +02:00
Alug 21920112ee a thousand curses upon you polyobjects! 2025-10-02 18:37:18 +02:00
Alug 9b7bf5e7d8 Merge remote-tracking branch 'origin/Saturn-Next' into deletglseg 2025-10-02 18:00:59 +02:00
Alug 524168b20b experiment: remove opengl adjusted segs
in theory this should improve levelload times and reduce memory usage?
gotta see if it really does, visually so far there seems to be no difference at all
2025-10-02 17:57:52 +02:00
90 changed files with 1848 additions and 1766 deletions

No files matched your search

+4 -2
View File
@@ -144,8 +144,10 @@ ifdef GCC81
WFLAGS+=-Wno-error=multistatement-macros WFLAGS+=-Wno-error=multistatement-macros
endif endif
ifeq ($(CC),clang) ifneq (,$(filter $(CC) $(CXX),clang clang++))
WFLAGS+= -Wno-unknown-pragmas -Wno-cast-align WFLAGS+= -Wno-unknown-pragmas
WFLAGS+= -Wno-cast-align
WFLAGS+= -Wno-cast-qual # not a fan, but clang really hates our read macros
endif endif
ifdef NONX86 ifdef NONX86
+1 -1
View File
@@ -434,7 +434,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) { LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
lua_lock(L); lua_lock(L);
luaC_checkGC(L); luaC_checkGC(L);
setsvalue2s(L, L->top, luaS_newlstr(L, s, len)); setsvalue2s(L, L->top, (len == 0) ? luaS_new(L, "") : luaS_newlstr(L, s, len));
api_incr_top(L); api_incr_top(L);
lua_unlock(L); lua_unlock(L);
} }
+4 -2
View File
@@ -24,6 +24,8 @@
#include "lauxlib.h" #include "lauxlib.h"
#include "../doomdef.h"
#define FREELIST_REF 0 /* free list of references */ #define FREELIST_REF 0 /* free list of references */
@@ -40,7 +42,7 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
if (!lua_getstack(L, 0, &ar)) /* no stack frame? */ if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
return luaL_error(L, "bad argument #%d (%s)", narg, extramsg); return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
lua_getinfo(L, "n", &ar); lua_getinfo(L, "n", &ar);
if (strcmp(ar.namewhat, "method") == 0) { if (fastcmp(ar.namewhat, "method")) {
narg--; /* do not count `self' */ narg--; /* do not count `self' */
if (narg == 0) /* error is in the self argument itself? */ if (narg == 0) /* error is in the self argument itself? */
return luaL_error(L, "calling " LUA_QS " on bad self (%s)", return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
@@ -97,7 +99,7 @@ LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
luaL_checkstring(L, narg); luaL_checkstring(L, narg);
int i; int i;
for (i=0; lst[i]; i++) for (i=0; lst[i]; i++)
if (strcmp(lst[i], name) == 0) if (fastcmp(lst[i], name))
return i; return i;
return luaL_argerror(L, narg, return luaL_argerror(L, narg,
lua_pushfstring(L, "invalid option " LUA_QS, name)); lua_pushfstring(L, "invalid option " LUA_QS, name));
+5 -3
View File
@@ -161,12 +161,13 @@ static int io_tostring (lua_State *L) {
static int StartsWith(const char *a, const char *b) // this is wolfs being lazy yet again static int StartsWith(const char *a, const char *b) // this is wolfs being lazy yet again
{ {
if(strncmp(a, b, strlen(b)) == 0) return 1; if (strncmp(a, b, strlen(b)) == 0) return 1;
return 0; return 0;
} }
static int io_open (lua_State *L) { static int io_open(lua_State *L)
{
FILE **pf; FILE **pf;
const char *filename = luaL_checkstring(L, 1); const char *filename = luaL_checkstring(L, 1);
int pass = 0; int pass = 0;
@@ -178,12 +179,13 @@ static int io_open (lua_State *L) {
for (i = 0; i < (sizeof (whitelist) / sizeof(const char *)); i++) for (i = 0; i < (sizeof (whitelist) / sizeof(const char *)); i++)
{ {
if (!stricmp(&filename[length - strlen(whitelist[i])], whitelist[i])) if (fasticmp(&filename[length - strlen(whitelist[i])], whitelist[i]))
{ {
pass = 1; pass = 1;
break; break;
} }
} }
if (l_unlikely(strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\") if (l_unlikely(strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\")
|| StartsWith(filename, "/") || !pass)) || StartsWith(filename, "/") || !pass))
{ {
+2 -2
View File
@@ -27,7 +27,7 @@ extern "C" {
// //
#define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) #define WRITEUINT8(p,b) do { UINT8 *p_tmp = ( UINT8 *)p; const UINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0)
#define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; const SINT8 tv = ( UINT8)(b); memcpy(p, &tv, sizeof( UINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) #define WRITESINT8(p,b) do { SINT8 *p_tmp = ( SINT8 *)p; const SINT8 tv = ( SINT8)(b); memcpy(p, &tv, sizeof( SINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0)
#define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) #define WRITEINT16(p,b) do { INT16 *p_tmp = ( INT16 *)p; const INT16 tv = ( INT16)(b); memcpy(p, &tv, sizeof( INT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0)
#define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; const UINT16 tv = ( UINT16)(b); memcpy(p, &tv, sizeof( UINT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) #define WRITEUINT16(p,b) do { UINT16 *p_tmp = ( UINT16 *)p; const UINT16 tv = ( UINT16)(b); memcpy(p, &tv, sizeof( UINT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0)
#define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; const INT32 tv = ( INT32)(b); memcpy(p, &tv, sizeof( INT32)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0) #define WRITEINT32(p,b) do { INT32 *p_tmp = ( INT32 *)p; const INT32 tv = ( INT32)(b); memcpy(p, &tv, sizeof( INT32)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; } while (0)
@@ -124,7 +124,7 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
#define READINT16(p) readshort(&((const INT16*)(p = (const void*)&((const INT16*)p)[1]))[-1]) #define READINT16(p) readshort(&((const INT16*)(p = (const void*)&((const INT16*)p)[1]))[-1])
#define READUINT16(p) readushort(&((const UINT16*)(p = (const void*)&((const UINT16*)p)[1]))[-1]) #define READUINT16(p) readushort(&((const UINT16*)(p = (const void*)&((const UINT16*)p)[1]))[-1])
#define READINT32(p) readlong(&((const INT32*)(p = (const void*)&((const INT32*)p)[1]))[-1]) #define READINT32(p) readlong(&((const INT32*)(p = (const void*)&((const INT32*)p)[1]))[-1])
#define READUINT32(p) readulong(&((const UINT32*)(p = (const void*)&((const UINT32*)p)[1])) #define READUINT32(p) readulong(&((const UINT32*)(p = (const void*)&((const UINT32*)p)[1]))[-1])
#define READCHAR(p) ((const char*)(p = (const void*)&((const char*)p)[1]))[-1] #define READCHAR(p) ((const char*)(p = (const void*)&((const char*)p)[1]))[-1]
#define READFIXED(p) readlong(&((const fixed_t*)(p = (const void*)&((const fixed_t*)p)[1]))[-1]) #define READFIXED(p) readlong(&((const fixed_t*)(p = (const void*)&((const fixed_t*)p)[1]))[-1])
#define READANGLE(p) readulong(&((const angle_t*)(p = (const void*)&((const angle_t*)p)[1]))[-1]) #define READANGLE(p) readulong(&((const angle_t*)(p = (const void*)&((const angle_t*)p)[1]))[-1])
+47 -47
View File
@@ -142,7 +142,7 @@ void COM_BufInsertText(const char *ptext)
templen = com_text.cursize; templen = com_text.cursize;
if (templen) if (templen)
{ {
temp = M_Memcpy(ZZ_Alloc(templen), com_text.data, templen); temp = memcpy(ZZ_Alloc(templen), com_text.data, templen);
VS_Clear(&com_text); VS_Clear(&com_text);
} }
@@ -199,7 +199,7 @@ void COM_BufExecute(void)
break; break;
} }
M_Memcpy(line, ptext, i); memcpy(line, ptext, i);
line[i] = 0; line[i] = 0;
// flush the command text from the command buffer, _BEFORE_ // flush the command text from the command buffer, _BEFORE_
@@ -359,7 +359,7 @@ size_t COM_CheckParm(const char *check)
size_t i; size_t i;
for (i = 1; i < com_argc; i++) for (i = 1; i < com_argc; i++)
if (!strcasecmp(check, com_argv[i])) if (fasticmp(check, com_argv[i]))
return i; return i;
return 0; return 0;
} }
@@ -456,7 +456,7 @@ void COM_AddCommand(const char *name, com_func_t func)
// fail if the command already exists // fail if the command already exists
for (cmd = com_commands; cmd; cmd = cmd->next) for (cmd = com_commands; cmd; cmd = cmd->next)
{ {
if (!stricmp(name, cmd->name)) //case insensitive now that we have lower and uppercase! if (fasticmp(name, cmd->name)) //case insensitive now that we have lower and uppercase!
{ {
// don't I_Error for Lua commands // don't I_Error for Lua commands
// Lua commands can replace game commands, and they have priority. // Lua commands can replace game commands, and they have priority.
@@ -492,7 +492,7 @@ int COM_AddLuaCommand(const char *name)
// command already exists // command already exists
for (cmd = com_commands; cmd; cmd = cmd->next) for (cmd = com_commands; cmd; cmd = cmd->next)
{ {
if (!stricmp(name, cmd->name)) //case insensitive now that we have lower and uppercase! if (fasticmp(name, cmd->name)) //case insensitive now that we have lower and uppercase!
{ {
// replace the built in command. // replace the built in command.
cmd->function = COM_Lua_f; cmd->function = COM_Lua_f;
@@ -519,7 +519,7 @@ static boolean COM_Exists(const char *com_name)
xcommand_t *cmd; xcommand_t *cmd;
for (cmd = com_commands; cmd; cmd = cmd->next) for (cmd = com_commands; cmd; cmd = cmd->next)
if (!stricmp(com_name, cmd->name)) if (fasticmp(com_name, cmd->name))
return true; return true;
return false; return false;
@@ -571,7 +571,7 @@ static void COM_ExecuteString(char *ptext)
// check functions // check functions
for (cmd = com_commands; cmd; cmd = cmd->next) for (cmd = com_commands; cmd; cmd = cmd->next)
{ {
if (!stricmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase! if (fasticmp(com_argv[0], cmd->name)) //case insensitive now that we have lower and uppercase!
{ {
cmd->function(); cmd->function();
return; return;
@@ -581,7 +581,7 @@ static void COM_ExecuteString(char *ptext)
// check aliases // check aliases
for (a = com_alias; a; a = a->next) for (a = com_alias; a; a = a->next)
{ {
if (!stricmp(com_argv[0], a->name)) if (fasticmp(com_argv[0], a->name))
{ {
if (recursion > MAX_ALIAS_RECURSION) if (recursion > MAX_ALIAS_RECURSION)
CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n")); CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n"));
@@ -836,7 +836,7 @@ static void COM_Help_f(void)
if (cvar->PossibleValue) if (cvar->PossibleValue)
{ {
{ {
if (!stricmp(cvar->PossibleValue[0].strvalue, "MIN") && !stricmp(cvar->PossibleValue[1].strvalue, "MAX")) if (fasticmp(cvar->PossibleValue[0].strvalue, "MIN") && fasticmp(cvar->PossibleValue[1].strvalue, "MAX"))
{ {
if (floatmode) if (floatmode)
{ {
@@ -879,7 +879,7 @@ static void COM_Help_f(void)
{ {
for (cmd = com_commands; cmd; cmd = cmd->next) for (cmd = com_commands; cmd; cmd = cmd->next)
{ {
if (strcmp(cmd->name, help)) if (!fastcmp(cmd->name, help))
continue; continue;
CONS_Printf("\x82""Command %s:\n", cmd->name); CONS_Printf("\x82""Command %s:\n", cmd->name);
@@ -1129,7 +1129,7 @@ void *VS_GetSpace(vsbuf_t *buf, size_t length)
*/ */
void VS_Write(vsbuf_t *buf, const void *data, size_t length) void VS_Write(vsbuf_t *buf, const void *data, size_t length)
{ {
M_Memcpy(VS_GetSpace(buf, length), data, length); memcpy(VS_GetSpace(buf, length), data, length);
} }
/** Prints text in a variable buffer. Like VS_Write() plus a /** Prints text in a variable buffer. Like VS_Write() plus a
@@ -1146,9 +1146,9 @@ void VS_Print(vsbuf_t *buf, const char *data)
len = strlen(data) + 1; len = strlen(data) + 1;
if (buf->data[buf->cursize-1]) if (buf->data[buf->cursize-1])
M_Memcpy((UINT8 *)VS_GetSpace(buf, len), data, len); // no trailing 0 memcpy((UINT8 *)VS_GetSpace(buf, len), data, len); // no trailing 0
else else
M_Memcpy((UINT8 *)VS_GetSpace(buf, len-1) - 1, data, len); // write over trailing 0 memcpy((UINT8 *)VS_GetSpace(buf, len-1) - 1, data, len); // write over trailing 0
} }
// ========================================================================= // =========================================================================
@@ -1176,7 +1176,7 @@ consvar_t *CV_FindVar(const char *name)
consvar_t *cvar; consvar_t *cvar;
for (cvar = consvar_vars; cvar; cvar = cvar->next) for (cvar = consvar_vars; cvar; cvar = cvar->next)
if (!stricmp(name,cvar->name)) if (fasticmp(name,cvar->name))
return cvar; return cvar;
return NULL; return NULL;
@@ -1366,7 +1366,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
v = INT32_MIN; // Invalid integer trigger v = INT32_MIN; // Invalid integer trigger
} }
if (var->PossibleValue[0].strvalue && !stricmp(var->PossibleValue[0].strvalue, "MIN")) // bounded cvar if (var->PossibleValue[0].strvalue && fasticmp(var->PossibleValue[0].strvalue, "MIN")) // bounded cvar
{ {
#define MINVAL 0 #define MINVAL 0
#define MAXVAL 1 #define MAXVAL 1
@@ -1379,21 +1379,21 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
// search for other // search for other
for (i = MAXVAL+1; var->PossibleValue[i].strvalue; i++) for (i = MAXVAL+1; var->PossibleValue[i].strvalue; i++)
if (v == var->PossibleValue[i].value || !stricmp(var->PossibleValue[i].strvalue, valstr)) if (v == var->PossibleValue[i].value || fasticmp(var->PossibleValue[i].strvalue, valstr))
{ {
var->value = var->PossibleValue[i].value; var->value = var->PossibleValue[i].value;
var->string = var->PossibleValue[i].strvalue; var->string = var->PossibleValue[i].strvalue;
goto finish; goto finish;
} }
if ((v != INT32_MIN && v < var->PossibleValue[MINVAL].value) || !stricmp(valstr, "MIN")) if ((v != INT32_MIN && v < var->PossibleValue[MINVAL].value) || fasticmp(valstr, "MIN"))
{ {
v = var->PossibleValue[MINVAL].value; v = var->PossibleValue[MINVAL].value;
valstr = var->PossibleValue[MINVAL].strvalue; valstr = var->PossibleValue[MINVAL].strvalue;
override = true; override = true;
overrideval = v; overrideval = v;
} }
else if ((v != INT32_MIN && v > var->PossibleValue[MAXVAL].value) || !stricmp(valstr, "MAX")) else if ((v != INT32_MIN && v > var->PossibleValue[MAXVAL].value) || fasticmp(valstr, "MAX"))
{ {
v = var->PossibleValue[MAXVAL].value; v = var->PossibleValue[MAXVAL].value;
valstr = var->PossibleValue[MAXVAL].strvalue; valstr = var->PossibleValue[MAXVAL].strvalue;
@@ -1411,7 +1411,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
// check first strings // check first strings
for (i = 0; var->PossibleValue[i].strvalue; i++) for (i = 0; var->PossibleValue[i].strvalue; i++)
if (!stricmp(var->PossibleValue[i].strvalue, valstr)) if (fasticmp(var->PossibleValue[i].strvalue, valstr))
goto found; goto found;
if (v != INT32_MIN) if (v != INT32_MIN)
{ {
@@ -1424,9 +1424,9 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
if (var->PossibleValue == CV_OnOff || var->PossibleValue == CV_YesNo) if (var->PossibleValue == CV_OnOff || var->PossibleValue == CV_YesNo)
{ {
overrideval = -1; overrideval = -1;
if (!stricmp(valstr, "on") || !stricmp(valstr, "yes")) if (fasticmp(valstr, "on") || fasticmp(valstr, "yes"))
overrideval = 1; overrideval = 1;
else if (!stricmp(valstr, "off") || !stricmp(valstr, "no")) else if (fasticmp(valstr, "off") || fasticmp(valstr, "no"))
overrideval = 0; overrideval = 0;
if (overrideval != -1) if (overrideval != -1)
@@ -1614,7 +1614,7 @@ void CV_ResetCheatNetVars(void)
// Returns true if the variable's current value is its default value // Returns true if the variable's current value is its default value
boolean CV_IsSetToDefault(consvar_t *v) boolean CV_IsSetToDefault(consvar_t *v)
{ {
return (!(strcmp(v->defaultvalue, v->string))); return (fastcmp(v->defaultvalue, v->string));
} }
// If any cheats CVars are not at their default settings, return true. // If any cheats CVars are not at their default settings, return true.
@@ -1626,7 +1626,7 @@ UINT8 CV_CheatsEnabled(void)
consvar_t *cvar; consvar_t *cvar;
for (cvar = consvar_vars; cvar; cvar = cvar->next) for (cvar = consvar_vars; cvar; cvar = cvar->next)
if ((cvar->flags & CV_CHEAT) && strcmp(cvar->defaultvalue, cvar->string)) if ((cvar->flags & CV_CHEAT) && !fastcmp(cvar->defaultvalue, cvar->string))
return 1; return 1;
return 0; return 0;
} }
@@ -1647,7 +1647,7 @@ static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth)
if (!var->string) if (!var->string)
I_Error("CV_Set: %s no string set!\n", var->name); I_Error("CV_Set: %s no string set!\n", var->name);
#endif #endif
if (!var || !var->string || !value || !stricmp(var->string, value)) if (!var || !var->string || !value || fasticmp(var->string, value))
return; // no changes return; // no changes
if (var->flags & CV_NETVAR) if (var->flags & CV_NETVAR)
@@ -1669,7 +1669,7 @@ static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth)
if (var == &cv_kartspeed && !M_SecretUnlocked(SECRET_HARDSPEED)) if (var == &cv_kartspeed && !M_SecretUnlocked(SECRET_HARDSPEED))
{ {
if (!stricmp(value, "Hard") || atoi(value) == 2) if (fasticmp(value, "Hard") || atoi(value) == 2)
{ {
CONS_Alert(CONS_NOTICE, "You haven't unlocked this yet!\n"); CONS_Alert(CONS_NOTICE, "You haven't unlocked this yet!\n");
return; return;
@@ -1803,7 +1803,7 @@ void CV_AddValue(consvar_t *var, INT32 increment)
} }
#define MINVAL 0 #define MINVAL 0
#define MAXVAL 1 #define MAXVAL 1
else if (var->PossibleValue[MINVAL].strvalue && !strcmp(var->PossibleValue[MINVAL].strvalue, "MIN")) else if (var->PossibleValue[MINVAL].strvalue && fastcmp(var->PossibleValue[MINVAL].strvalue, "MIN"))
{ // SRB2Kart { // SRB2Kart
#ifdef PARANOIA #ifdef PARANOIA
if (!var->PossibleValue[MAXVAL].strvalue) if (!var->PossibleValue[MAXVAL].strvalue)
@@ -1975,12 +1975,12 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr)
{ {
if (joyaxis_default[i]) if (joyaxis_default[i])
{ {
if (!stricmp(v->name, "joyaxis_fire")) if (fasticmp(v->name, "joyaxis_fire"))
{ {
if (joyaxis_count[i] > 7) return false; if (joyaxis_count[i] > 7) return false;
else if (joyaxis_count[i] == 7) return true; else if (joyaxis_count[i] == 7) return true;
if (!stricmp(valstr, "None")) joyaxis_count[i]++; if (fasticmp(valstr, "None")) joyaxis_count[i]++;
else joyaxis_default[i] = false; else joyaxis_default[i] = false;
} }
// reset all axis settings to defaults // reset all axis settings to defaults
@@ -2012,37 +2012,37 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr)
// Block the Xbox DInput default axes and reset to the current defaults // Block the Xbox DInput default axes and reset to the current defaults
static boolean CV_FilterJoyAxisVars2(consvar_t *v, const char *valstr) static boolean CV_FilterJoyAxisVars2(consvar_t *v, const char *valstr)
{ {
if (!stricmp(v->name, "joyaxis_turn") && !stricmp(valstr, "X-Axis")) if (fasticmp(v->name, "joyaxis_turn") && fasticmp(valstr, "X-Axis"))
return false; return false;
if (!stricmp(v->name, "joyaxis2_turn") && !stricmp(valstr, "X-Axis")) if (fasticmp(v->name, "joyaxis2_turn") && fasticmp(valstr, "X-Axis"))
return false; return false;
if (!stricmp(v->name, "joyaxis3_turn") && !stricmp(valstr, "X-Axis")) if (fasticmp(v->name, "joyaxis3_turn") && fasticmp(valstr, "X-Axis"))
return false; return false;
if (!stricmp(v->name, "joyaxis4_turn") && !stricmp(valstr, "X-Axis")) if (fasticmp(v->name, "joyaxis4_turn") && fasticmp(valstr, "X-Axis"))
return false; return false;
if (!stricmp(v->name, "joyaxis_aim") && !stricmp(valstr, "Y-Axis")) if (fasticmp(v->name, "joyaxis_aim") && fasticmp(valstr, "Y-Axis"))
return false; return false;
if (!stricmp(v->name, "joyaxis2_aim") && !stricmp(valstr, "Y-Axis")) if (fasticmp(v->name, "joyaxis2_aim") && fasticmp(valstr, "Y-Axis"))
return false; return false;
if (!stricmp(v->name, "joyaxis3_aim") && !stricmp(valstr, "Y-Axis")) if (fasticmp(v->name, "joyaxis3_aim") && fasticmp(valstr, "Y-Axis"))
return false; return false;
if (!stricmp(v->name, "joyaxis4_aim") && !stricmp(valstr, "Y-Axis")) if (fasticmp(v->name, "joyaxis4_aim") && fasticmp(valstr, "Y-Axis"))
return false; return false;
if (!stricmp(v->name, "joyaxis_fire") && !stricmp(valstr, "None")) if (fasticmp(v->name, "joyaxis_fire") && fasticmp(valstr, "None"))
return false; return false;
if (!stricmp(v->name, "joyaxis2_fire") && !stricmp(valstr, "None")) if (fasticmp(v->name, "joyaxis2_fire") && fasticmp(valstr, "None"))
return false; return false;
if (!stricmp(v->name, "joyaxis3_fire") && !stricmp(valstr, "None")) if (fasticmp(v->name, "joyaxis3_fire") && fasticmp(valstr, "None"))
return false; return false;
if (!stricmp(v->name, "joyaxis4_fire") && !stricmp(valstr, "None")) if (fasticmp(v->name, "joyaxis4_fire") && fasticmp(valstr, "None"))
return false; return false;
if (!stricmp(v->name, "joyaxis_drift") && !stricmp(valstr, "None")) if (fasticmp(v->name, "joyaxis_drift") && fasticmp(valstr, "None"))
return false; return false;
if (!stricmp(v->name, "joyaxis2_drift") && !stricmp(valstr, "None")) if (fasticmp(v->name, "joyaxis2_drift") && fasticmp(valstr, "None"))
return false; return false;
if (!stricmp(v->name, "joyaxis3_drift") && !stricmp(valstr, "None")) if (fasticmp(v->name, "joyaxis3_drift") && fasticmp(valstr, "None"))
return false; return false;
if (!stricmp(v->name, "joyaxis4_drift") && !stricmp(valstr, "None")) if (fasticmp(v->name, "joyaxis4_drift") && fasticmp(valstr, "None"))
return false; return false;
return true; return true;
@@ -2059,8 +2059,8 @@ static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr)
if (GETMAJOREXECVERSION(cv_execversion.value) < 8) // 8 = 1.4 if (GETMAJOREXECVERSION(cv_execversion.value) < 8) // 8 = 1.4
{ {
if (!stricmp(v->name, "masterserver") // Replaces a hack in MasterServer_OnChange for the original SRB2 MS. if (fasticmp(v->name, "masterserver") // Replaces a hack in MasterServer_OnChange for the original SRB2 MS.
|| !stricmp(v->name, "gamma")) // Too easy to accidentially change in prior versions. || fasticmp(v->name, "gamma")) // Too easy to accidentially change in prior versions.
return false; return false;
} }
@@ -2143,7 +2143,7 @@ void CV_SaveVariables(FILE *f)
char stringtowrite[MAXTEXTCMD+1]; char stringtowrite[MAXTEXTCMD+1];
// Silly hack for Min/Max vars // Silly hack for Min/Max vars
if (!strcmp(cvar->string, "MAX") || !strcmp(cvar->string, "MIN")) if (fastcmp(cvar->string, "MAX") || fastcmp(cvar->string, "MIN"))
{ {
if (cvar->flags & CV_FLOAT) if (cvar->flags & CV_FLOAT)
sprintf(stringtowrite, "%f", FixedToFloat(cvar->value)); sprintf(stringtowrite, "%f", FixedToFloat(cvar->value));
+3 -3
View File
@@ -521,7 +521,7 @@ static void CON_RecalcSize(void)
oldcon_width = con_width; oldcon_width = con_width;
oldnumlines = con_totallines; oldnumlines = con_totallines;
oldcon_cy = con_cy; oldcon_cy = con_cy;
M_Memcpy(tmp_buffer, con_buffer, CON_BUFFERSIZE); memcpy(tmp_buffer, con_buffer, CON_BUFFERSIZE);
if (conw < 1) if (conw < 1)
con_width = (BASEVIDWIDTH>>3) - 2; con_width = (BASEVIDWIDTH>>3) - 2;
@@ -547,7 +547,7 @@ static void CON_RecalcSize(void)
{ {
if (tmp_buffer[(i%oldnumlines)*oldcon_width]) if (tmp_buffer[(i%oldnumlines)*oldcon_width])
{ {
M_Memcpy(string, &tmp_buffer[(i%oldnumlines)*oldcon_width], oldcon_width); memcpy(string, &tmp_buffer[(i%oldnumlines)*oldcon_width], oldcon_width);
conw = oldcon_width - 1; conw = oldcon_width - 1;
while (string[conw] == ' ' && conw) while (string[conw] == ' ' && conw)
conw--; conw--;
@@ -1010,7 +1010,7 @@ boolean CON_Responder(event_t *ev)
Lock_state(); Lock_state();
// Only add command to history if it differs from previous one // Only add command to history if it differs from previous one
if (strcmp(input.buffer, inputlines[(inputline-1) & 31])) if (!fastcmp(input.buffer, inputlines[(inputline-1) & 31]))
{ {
inputline = (inputline+1) & 31; inputline = (inputline+1) & 31;
M_TextInputInit(&input, inputlines[inputline], CON_MAXPROMPTCHARS); M_TextInputInit(&input, inputlines[inputline], CON_MAXPROMPTCHARS);
+45
View File
@@ -147,6 +147,51 @@ public:
template <class T> template <class T>
NotNull(T) -> NotNull<T>; NotNull(T) -> NotNull<T>;
// does a super safe cast from floating point to interger types
// this prob could be better since i suck at ceepeepee
// but atleast we can just template shit to our desired types
template <typename FloatT, typename IntT>
static inline IntT floattoint(FloatT val)
{
// :chaosleep:
static_assert(std::is_floating_point_v<FloatT>, "Input must be a floating-point type");
static_assert(std::is_integral_v<IntT>, "Output must be a integer type");
if (std::fpclassify(val) == FP_NAN)
return 0; // if stuffs not a number we sure screwed up lmao
// treat inifinity as "int min/max"
if (std::fpclassify(val) == FP_INFINITE)
{
// yes infinity can be signed kek
if (std::signbit(val))
return std::numeric_limits<IntT>::min(); // negative infinity, so return min
else
return std::numeric_limits<IntT>::max();
}
// make sure we fit into our targettype uwu
if (val > static_cast<FloatT>(std::numeric_limits<IntT>::max()))
return std::numeric_limits<IntT>::max();
else if (val < static_cast<FloatT>(std::numeric_limits<IntT>::min()))
return std::numeric_limits<IntT>::min();
return static_cast<IntT>(val);
}
// safe float to fixed
// which handles nan and inf
// pretty much the same stuff as the above, but uh, idk how id use the above with this
template <typename FloatT> // can use both float and doubles yay
static inline int32_t floattofixed(FloatT val)
{
// :chaosleep:
static_assert(std::is_floating_point_v<FloatT>, "Input must be a floating-point type");
// fixed_t is just an int32_t, i dont wanna include doomtype here if it can be avoided
return floattoint<FloatT, int32_t>(val * 65535.);
}
} // namespace srb2 } // namespace srb2
#endif // __SRB2_CXXUTIL_HPP__ #endif // __SRB2_CXXUTIL_HPP__
+35 -33
View File
@@ -78,14 +78,14 @@
#define MAX_REASONLENGTH 30 #define MAX_REASONLENGTH 30
#define FORCECLOSE 0x8000 #define FORCECLOSE 0x8000
static long long unsigned packetstat[NUMPACKETTYPE+1] = {0}; static long long unsigned packetstat[NUMPACKETTYPE+1] = {};
boolean server = true; // true or false but !server == client boolean server = true; // true or false but !server == client
#define client (!server) #define client (!server)
boolean nodownload = false; boolean nodownload = false;
boolean serverrunning = false; boolean serverrunning = false;
INT32 serverplayer = 0; INT32 serverplayer = 0;
char motd[254], server_context[8]; // Message of the Day, Unique Context (even without Mumble support) char motd[254] = {}, server_context[8] = {}; // Message of the Day, Unique Context (even without Mumble support)
#define MAP_ICON_REQUEST_FREQUENCY 8 #define MAP_ICON_REQUEST_FREQUENCY 8
@@ -98,14 +98,13 @@ static int map_icon_request_count; // current count of icon requests sent
static UINT8 *map_icon_data; static UINT8 *map_icon_data;
static patch_t *map_icon; static patch_t *map_icon;
plrinfo playerinfo[MAXPLAYERS]; plrinfo playerinfo[MAXPLAYERS] = {};
SINT8 joinnode = 0; // used for CL_VIEWSERVER SINT8 joinnode = 0; // used for CL_VIEWSERVER
boolean player_muted[MAXPLAYERS] = {0}; boolean player_muted[MAXPLAYERS] = {};
// Server specific vars // Server specific vars
UINT8 playernode[MAXPLAYERS]; UINT8 playernode[MAXPLAYERS] = {};
// Minimum timeout for sending the savegame // Minimum timeout for sending the savegame
// The actual timeout will be longer depending on the savegame length // The actual timeout will be longer depending on the savegame length
@@ -118,15 +117,15 @@ static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can rese
static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout? static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the server before getting a timeout?
UINT16 pingmeasurecount = 1; UINT16 pingmeasurecount = 1;
UINT32 realpingtable[MAXPLAYERS]; //the base table of ping where an average will be sent to everyone. UINT32 realpingtable[MAXPLAYERS] = {}; //the base table of ping where an average will be sent to everyone.
UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values. UINT32 playerpingtable[MAXPLAYERS] = {}; //table of player latency values.
#define GENTLEMANSMOOTHING (TICRATE) #define GENTLEMANSMOOTHING (TICRATE)
static tic_t reference_lag; static tic_t reference_lag;
static UINT8 spike_time; static UINT8 spike_time;
tic_t lowest_lag; tic_t lowest_lag = 0;
tic_t simulated_lag; tic_t simulated_lag = 0;
boolean server_lagless; boolean server_lagless = true;
static void Lagless_OnChange(void) static void Lagless_OnChange(void)
{ {
@@ -144,12 +143,12 @@ static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL
consvar_t cv_mindelay = {"mindelay", "0", CV_SAVE, mindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mindelay = {"mindelay", "0", CV_SAVE, mindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_gentlemens = {"gentlemensdelay", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Lagless_OnChange, 0, NULL, NULL, 0, 0, NULL}; // this should be a netvar Zzz... consvar_t cv_gentlemens = {"gentlemensdelay", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Lagless_OnChange, 0, NULL, NULL, 0, 0, NULL}; // this should be a netvar Zzz...
SINT8 nodetoplayer[MAXNETNODES]; SINT8 nodetoplayer[MAXNETNODES] = {};
SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) SINT8 nodetoplayer2[MAXNETNODES] = {}; // say the numplayer for this node if any (splitscreen)
SINT8 nodetoplayer3[MAXNETNODES]; // say the numplayer for this node if any (splitscreen == 2) SINT8 nodetoplayer3[MAXNETNODES] = {}; // say the numplayer for this node if any (splitscreen == 2)
SINT8 nodetoplayer4[MAXNETNODES]; // say the numplayer for this node if any (splitscreen == 3) SINT8 nodetoplayer4[MAXNETNODES] = {}; // say the numplayer for this node if any (splitscreen == 3)
UINT8 playerpernode[MAXNETNODES]; // used specialy for splitscreen UINT8 playerpernode[MAXNETNODES] = {}; // used specialy for splitscreen
boolean nodeingame[MAXNETNODES]; // set false as nodes leave game boolean nodeingame[MAXNETNODES] = {}; // set false as nodes leave game
tic_t servermaxping = 20; // server's max delay, in frames. Defaults to 20 tic_t servermaxping = 20; // server's max delay, in frames. Defaults to 20
static tic_t nettics[MAXNETNODES]; // what tic the client have received static tic_t nettics[MAXNETNODES]; // what tic the client have received
@@ -196,7 +195,7 @@ boolean is_client_saturn[MAXNETNODES];
static UINT8 localtextcmd[MAXSPLITSCREENPLAYERS][MAXTEXTCMD]; static UINT8 localtextcmd[MAXSPLITSCREENPLAYERS][MAXTEXTCMD];
static tic_t neededtic; static tic_t neededtic;
SINT8 servernode = 0; // the number of the server node SINT8 servernode = 0; // the number of the server node
char connectedservername[MAXSERVERNAME+1]; char connectedservername[MAXSERVERNAME+1] = {};
/// \brief do we accept new players? /// \brief do we accept new players?
/// \todo WORK! /// \todo WORK!
boolean acceptnewnode = true; boolean acceptnewnode = true;
@@ -227,7 +226,7 @@ struct textcmdbuf_s
static textcmdbuf_t *textcmdbuf[MAXSPLITSCREENPLAYERS] = {NULL}; static textcmdbuf_t *textcmdbuf[MAXSPLITSCREENPLAYERS] = {NULL};
static ticcmd_t playercmds[MAXPLAYERS]; static ticcmd_t playercmds[MAXPLAYERS];
ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS]; ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS] = {};
static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL}; static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL};
consvar_t cv_showjoinaddress = {"showjoinaddress", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showjoinaddress = {"showjoinaddress", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -285,7 +284,7 @@ static inline void *G_ScpyTiccmd(ticcmd_t* dest, void* src, const size_t n)
// Some software don't support largest packet // Some software don't support largest packet
// (original sersetup, not exactely, but the probability of sending a packet // (original sersetup, not exactely, but the probability of sending a packet
// of 512 bytes is like 0.1) // of 512 bytes is like 0.1)
UINT16 software_MAXPACKETLENGTH; UINT16 software_MAXPACKETLENGTH = 0;
/** Guesses the value of a tic from its lowest byte and from maketic /** Guesses the value of a tic from its lowest byte and from maketic
* *
@@ -331,7 +330,7 @@ static void WriteNetXCmd(UINT8 *cmd, netxcmd_t id, const void *param, size_t npa
cmd[cmd[0]] = (UINT8)id; cmd[cmd[0]] = (UINT8)id;
if (param && nparam) if (param && nparam)
{ {
M_Memcpy(&cmd[cmd[0]+1], param, nparam); memcpy(&cmd[cmd[0]+1], param, nparam);
cmd[0] = (UINT8)(cmd[0] + (UINT8)nparam); cmd[0] = (UINT8)(cmd[0] + (UINT8)nparam);
} }
} }
@@ -1585,7 +1584,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
MAXSERVERNAME); MAXSERVERNAME);
strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), sizeof(netbuffer->u.serverinfo.mapname)-1); strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), sizeof(netbuffer->u.serverinfo.mapname)-1);
M_Memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, sizeof(netbuffer->u.serverinfo.mapmd5)); memcpy(netbuffer->u.serverinfo.mapmd5, mapmd5, sizeof(netbuffer->u.serverinfo.mapmd5));
netbuffer->u.serverinfo.iszone = 0; netbuffer->u.serverinfo.iszone = 0;
@@ -2174,7 +2173,7 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
if (info->subversion != SUBVERSION) if (info->subversion != SUBVERSION)
return; // Close, but no cigar. return; // Close, but no cigar.
if (strcmp(info->application, SRB2APPLICATION)) if (!fastcmp(info->application, SRB2APPLICATION))
return;/* that's a different mod */ return;/* that's a different mod */
i = serverlistcount++; i = serverlistcount++;
@@ -2219,7 +2218,7 @@ void CL_QueryServerList (msg_server_t *server_list)
// thwart nefarious servers who lie to the MS. // thwart nefarious servers who lie to the MS.
/* lol bruh, that version COMES from the servers */ /* lol bruh, that version COMES from the servers */
//if (strcmp(version, server_list[i].version) == 0) //if (fastcmp(version, server_list[i].version))
{ {
INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port); INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port);
if (node == -1) if (node == -1)
@@ -3215,7 +3214,7 @@ static void Command_connect(void)
server = false; server = false;
if (!stricmp(COM_Argv(1), "self")) if (fasticmp(COM_Argv(1), "self"))
{ {
servernode = 0; servernode = 0;
server = true; server = true;
@@ -3225,7 +3224,7 @@ static void Command_connect(void)
else else
{ {
// used in menu to connect to a server in the list // used in menu to connect to a server in the list
if (netgame && !stricmp(COM_Argv(1), "node")) if (netgame && fasticmp(COM_Argv(1), "node"))
{ {
servernode = (SINT8)atoi(COM_Argv(2)); servernode = (SINT8)atoi(COM_Argv(2));
} }
@@ -3240,7 +3239,7 @@ static void Command_connect(void)
netgame = true; netgame = true;
multiplayer = true; multiplayer = true;
if (!stricmp(COM_Argv(1), "any")) if (fasticmp(COM_Argv(1), "any"))
servernode = BROADCASTADDR; servernode = BROADCASTADDR;
else if (I_NetMakeNodewPort && COM_Argc() >= 3) else if (I_NetMakeNodewPort && COM_Argc() >= 3)
servernode = I_NetMakeNodewPort(COM_Argv(1), COM_Argv(2)); servernode = I_NetMakeNodewPort(COM_Argv(1), COM_Argv(2));
@@ -3264,6 +3263,7 @@ static void Command_connect(void)
splitscreen = cv_splitplayers.value-1; splitscreen = cv_splitplayers.value-1;
SplitScreen_OnChange(); SplitScreen_OnChange();
} }
botingame = false; botingame = false;
botskin = 0; botskin = 0;
CL_ConnectToServer(); CL_ConnectToServer();
@@ -4647,7 +4647,7 @@ void SV_StopServer(void)
if (gamestate == GS_INTERMISSION) if (gamestate == GS_INTERMISSION)
Y_EndIntermission(); Y_EndIntermission();
if (gamestate == GS_VOTING) else if (gamestate == GS_VOTING)
Y_EndVote(); Y_EndVote();
G_SetGamestate(GS_NULL); G_SetGamestate(GS_NULL);
@@ -4663,6 +4663,8 @@ void SV_StopServer(void)
textcmdbuf[i] = textcmdbuf[i]->next; textcmdbuf[i] = textcmdbuf[i]->next;
Z_Free(buf); Z_Free(buf);
} }
textcmdbuf[i] = NULL;
} }
for (i = firstticstosend; i < firstticstosend + BACKUPTICS; i++) for (i = firstticstosend; i < firstticstosend + BACKUPTICS; i++)
@@ -5686,7 +5688,7 @@ static void PT_TextCmd(INT32 netconsole, SINT8 node)
DEBFILE(va("textcmd put in tic %u at position %d (player %d) ftts %u mk %u\n", DEBFILE(va("textcmd put in tic %u at position %d (player %d) ftts %u mk %u\n",
tic, textcmd[0]+1, netconsole, firstticstosend, maketic)); tic, textcmd[0]+1, netconsole, firstticstosend, maketic));
M_Memcpy(&textcmd[textcmd[0]+1], netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]); memcpy(&textcmd[textcmd[0]+1], netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]);
textcmd[0] += (UINT8)netbuffer->u.textcmd[0]; textcmd[0] += (UINT8)netbuffer->u.textcmd[0];
} }
} }
@@ -5793,7 +5795,7 @@ static void PT_ServerTics(SINT8 node)
} }
if (i >= gametic) // Don't copy old net commands if (i >= gametic) // Don't copy old net commands
M_Memcpy(D_GetTextcmd(i, playernum), txtpak, txtsize); memcpy(D_GetTextcmd(i, playernum), txtpak, txtsize);
txtpak += txtsize; txtpak += txtsize;
} }
} }
@@ -6331,7 +6333,7 @@ static void CL_SendClientCmd(void)
break; break;
} }
M_Memcpy(netbuffer->u.textcmd, localtextcmd[i], localtextcmd[i][0]+1); memcpy(netbuffer->u.textcmd, localtextcmd[i], localtextcmd[i][0]+1);
// All extra data have been sent // All extra data have been sent
if (HSendPacket(servernode, true, 0, localtextcmd[i][0]+1)) // Send can fail... if (HSendPacket(servernode, true, 0, localtextcmd[i][0]+1)) // Send can fail...
@@ -6341,7 +6343,7 @@ static void CL_SendClientCmd(void)
if (textcmdbuf[i] != NULL) if (textcmdbuf[i] != NULL)
{ {
textcmdbuf_t *buf = textcmdbuf[i]; textcmdbuf_t *buf = textcmdbuf[i];
M_Memcpy(localtextcmd[i], textcmdbuf[i]->cmd, textcmdbuf[i]->cmd[0]+1); memcpy(localtextcmd[i], textcmdbuf[i]->cmd, textcmdbuf[i]->cmd[0]+1);
textcmdbuf[i] = textcmdbuf[i]->next; textcmdbuf[i] = textcmdbuf[i]->next;
Z_Free(buf); Z_Free(buf);
} }
@@ -6454,7 +6456,7 @@ static void SV_SendTics(void)
{ {
(*ntextcmd)++; (*ntextcmd)++;
WRITEUINT8(bufpos, j); WRITEUINT8(bufpos, j);
M_Memcpy(bufpos, textcmd, size + 1); memcpy(bufpos, textcmd, size + 1);
bufpos += size + 1; bufpos += size + 1;
} }
} }
+22 -76
View File
@@ -142,8 +142,8 @@ static char addonsdir[MAX_WADPATH];
// Events can be discarded if no responder claims them // Events can be discarded if no responder claims them
// referenced from i_system.c for I_GetKey() // referenced from i_system.c for I_GetKey()
event_t events[MAXEVENTS]; event_t events[MAXEVENTS] = {};
INT32 eventhead, eventtail; INT32 eventhead = 0, eventtail = 0;
boolean dedicated = false; boolean dedicated = false;
@@ -161,68 +161,17 @@ void D_PostEvent(const event_t *ev)
// modifier keys // modifier keys
// Now handled in I_OsPolling // Now handled in I_OsPolling
UINT8 shiftdown = 0; // 0x1 left, 0x2 right UINT8 shiftdown = 0; // 0x1 left, 0x2 right
UINT8 ctrldown = 0; // 0x1 left, 0x2 right UINT8 ctrldown = 0; // 0x1 left, 0x2 right
UINT8 altdown = 0; // 0x1 left, 0x2 right UINT8 altdown = 0; // 0x1 left, 0x2 right
boolean capslock = 0; // gee i wonder what this does. boolean capslock = 0; // gee i wonder what this does.
static void D_PadMenuScrollInput(UINT8 input) static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {};
{
event_t dpadev;
memset(&dpadev, 0, sizeof(event_t));
dpadev.type = ev_keydown;
switch (input)
{
case DPAD_UP:
dpadev.data1 = KEY_UPARROW;
break;
case DPAD_DOWN:
dpadev.data1 = KEY_DOWNARROW;
break;
case DPAD_LEFT:
dpadev.data1 = KEY_LEFTARROW;
break;
case DPAD_RIGHT:
dpadev.data1 = KEY_RIGHTARROW;
break;
}
D_PostEvent(&dpadev); // put into eventlist
}
#define SCROLLDELAY 19
// Check if any dpad button is held
// and pass it to the eventlist
static void D_GamePadMenuScrollTicker(void)
{
UINT8 i;
static UINT8 menuInputDelayTimer = 0;
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
if (dpadscrollstate[i])
{
if (menuInputDelayTimer < SCROLLDELAY)
menuInputDelayTimer++;
else if (menuInputDelayTimer == SCROLLDELAY)
D_PadMenuScrollInput(i);
return;
}
}
menuInputDelayTimer = 0;
}
#undef SCROLLDELAY
static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {0};
static void D_DeviceLEDTick(void) static void D_DeviceLEDTick(void)
{ {
UINT8 i; UINT8 i;
static UINT16 color[MAXSPLITSCREENPLAYERS] = {0}; static UINT16 color[MAXSPLITSCREENPLAYERS] = {};
if (numcontrollers == 0) if (numcontrollers == 0)
{ {
@@ -390,8 +339,7 @@ static void D_Renderview(void)
} }
else if (rendermode == render_soft) else if (rendermode == render_soft)
#endif #endif
R_RenderPlayerView(&players[displayplayers[i]]);
R_RenderPlayerView(&players[displayplayers[i]]);
} }
if (rendermode == render_soft) if (rendermode == render_soft)
@@ -720,7 +668,7 @@ static boolean D_Display(void)
// D_SRB2Loop // D_SRB2Loop
// ========================================================================= // =========================================================================
tic_t rendergametic; tic_t rendergametic = 0;
void D_SRB2Loop(void) void D_SRB2Loop(void)
{ {
@@ -845,11 +793,6 @@ void D_SRB2Loop(void)
if (!dedicated) if (!dedicated)
{ {
if (menuactive)
{
D_GamePadMenuScrollTicker();
}
D_DeviceLEDTick(); D_DeviceLEDTick();
} }
} }
@@ -1078,19 +1021,19 @@ static INT32 D_DetectFileType(const char* filename)
const size_t len = strlen(filename); const size_t len = strlen(filename);
if (!stricmp(&filename[len - 4], ".wad")) if (fasticmp(&filename[len - 4], ".wad"))
return 2; return 2;
else if (!stricmp(&filename[len - 4], ".pk3")) else if (fasticmp(&filename[len - 4], ".pk3"))
return 3; return 3;
else if (!stricmp(&filename[len - 5], ".kart")) else if (fasticmp(&filename[len - 5], ".kart"))
return 4; return 4;
else if (!stricmp(&filename[len - 4], ".lua")) else if (fasticmp(&filename[len - 4], ".lua"))
return 5; return 5;
else if (!stricmp(&filename[len - 4], ".soc")) else if (fasticmp(&filename[len - 4], ".soc"))
return 6; return 6;
else if (!stricmp(&filename[len - 4], ".cfg")) else if (fasticmp(&filename[len - 4], ".cfg"))
return 7; return 7;
else if (!stricmp(&filename[len - 4], ".txt")) else if (fasticmp(&filename[len - 4], ".txt"))
return 8; return 8;
return 0; return 0;
@@ -1288,7 +1231,7 @@ static void IdentifyVersion(void)
} }
#if (1) // reduce the amount of findfile by only using full cwd in this func #if (1) // reduce the amount of findfile by only using full cwd in this func
if (strcmp(tempsrb2path, srb2waddir)) if (!fastcmp(tempsrb2path, srb2waddir))
#endif #endif
{ {
strlcpy(srb2path, srb2waddir, sizeof (srb2path)); strlcpy(srb2path, srb2waddir, sizeof (srb2path));
@@ -2156,11 +2099,14 @@ void D_SRB2Main(void)
const char *sskill = M_GetNextParm(); const char *sskill = M_GetNextParm();
for (j = 0; kartspeed_cons_t[j].strvalue; j++) for (j = 0; kartspeed_cons_t[j].strvalue; j++)
if (!strcasecmp(kartspeed_cons_t[j].strvalue, sskill)) {
if (fasticmp(kartspeed_cons_t[j].strvalue, sskill))
{ {
newskill = (INT16)kartspeed_cons_t[j].value; newskill = (INT16)kartspeed_cons_t[j].value;
break; break;
} }
}
if (!kartspeed_cons_t[j].strvalue) // reached end of the list with no match if (!kartspeed_cons_t[j].strvalue) // reached end of the list with no match
{ {
j = atoi(sskill); // assume they gave us a skill number, which is okay too j = atoi(sskill); // assume they gave us a skill number, which is okay too
+8 -8
View File
@@ -95,9 +95,9 @@ static INT32 sendackpacket = 0, getackpacket = 0;
INT32 ticruned = 0, ticmiss = 0; INT32 ticruned = 0, ticmiss = 0;
// globals // globals
INT32 getbps, sendbps; INT32 getbps = 0, sendbps = 0;
float lostpercent, duppercent, gamelostpercent; float lostpercent = 0, duppercent = 0, gamelostpercent = 0;
INT32 packetheaderlength; INT32 packetheaderlength = 0;
boolean Net_GetNetStat(void) boolean Net_GetNetStat(void)
{ {
@@ -243,7 +243,7 @@ static boolean GetFreeAcknum(UINT8 *freeack)
ackpak[i].length = doomcom->datalength; ackpak[i].length = doomcom->datalength;
ackpak[i].senttime = I_GetTime(); ackpak[i].senttime = I_GetTime();
ackpak[i].resentnum = 0; ackpak[i].resentnum = 0;
M_Memcpy(ackpak[i].pak.raw, netbuffer, ackpak[i].length); memcpy(ackpak[i].pak.raw, netbuffer, ackpak[i].length);
*freeack = ackpak[i].acknum; *freeack = ackpak[i].acknum;
@@ -412,7 +412,7 @@ void Net_SendAcks(INT32 node)
{ {
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom); doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
netbuffer->packettype = PT_NOTHING; netbuffer->packettype = PT_NOTHING;
M_Memcpy(netbuffer->u.textcmd, nodes[node].acktosend, MAXACKTOSEND); memcpy(netbuffer->u.textcmd, nodes[node].acktosend, MAXACKTOSEND);
HSendPacket(node, false, 0, MAXACKTOSEND); HSendPacket(node, false, 0, MAXACKTOSEND);
} }
@@ -494,7 +494,7 @@ void Net_AckTicker(void)
} }
DEBFILE(va("Resend ack %d, %u<%d at %u\n", ackpak[i].acknum, ackpak[i].senttime, DEBFILE(va("Resend ack %d, %u<%d at %u\n", ackpak[i].acknum, ackpak[i].senttime,
NODETIMEOUT, I_GetTime())); NODETIMEOUT, I_GetTime()));
M_Memcpy(netbuffer, ackpak[i].pak.raw, ackpak[i].length); memcpy(netbuffer, ackpak[i].pak.raw, ackpak[i].length);
ackpak[i].senttime = I_GetTime(); ackpak[i].senttime = I_GetTime();
ackpak[i].resentnum++; ackpak[i].resentnum++;
ackpak[i].nextacknum = node->nextacknum; ackpak[i].nextacknum = node->nextacknum;
@@ -1021,7 +1021,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
return false; return false;
} }
netbuffer->ack = netbuffer->ackreturn = 0; // don't hold over values from last packet sent/received netbuffer->ack = netbuffer->ackreturn = 0; // don't hold over values from last packet sent/received
M_Memcpy(&reboundstore[rebound_head], netbuffer, memcpy(&reboundstore[rebound_head], netbuffer,
doomcom->datalength); doomcom->datalength);
reboundsize[rebound_head] = doomcom->datalength; reboundsize[rebound_head] = doomcom->datalength;
rebound_head = (rebound_head+1) % MAXREBOUND; rebound_head = (rebound_head+1) % MAXREBOUND;
@@ -1107,7 +1107,7 @@ boolean HGetPacket(void)
// Get a packet from self // Get a packet from self
if (rebound_tail != rebound_head) if (rebound_tail != rebound_head)
{ {
M_Memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]); memcpy(netbuffer, &reboundstore[rebound_tail], reboundsize[rebound_tail]);
doomcom->datalength = reboundsize[rebound_tail]; doomcom->datalength = reboundsize[rebound_tail];
if (netbuffer->packettype == PT_NODETIMEOUT) if (netbuffer->packettype == PT_NODETIMEOUT)
doomcom->remotenode = netbuffer->u.textcmd[0]; doomcom->remotenode = netbuffer->u.textcmd[0];
+39 -39
View File
@@ -1219,7 +1219,7 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum)
for (ix = 0; ix < MAXPLAYERS; ix++) for (ix = 0; ix < MAXPLAYERS; ix++)
{ {
if (ix != playernum && playeringame[ix] if (ix != playernum && playeringame[ix]
&& strcasecmp(name, player_names[ix]) == 0) && fasticmp(name, player_names[ix]))
{ {
// We shouldn't kick people out just because // We shouldn't kick people out just because
// they joined the game with the same name // they joined the game with the same name
@@ -1336,7 +1336,7 @@ static void CleanupPlayerName(INT32 playernum, const char *newname)
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{ {
if (i != playernum && playeringame[i] if (i != playernum && playeringame[i]
&& strcasecmp(tmpname, player_names[i]) == 0) && fasticmp(tmpname, player_names[i]))
{ {
break; break;
} }
@@ -1386,7 +1386,7 @@ static void SetPlayerName(INT32 playernum, char *newname)
{ {
if (EnsurePlayerNameIsGood(newname, playernum)) if (EnsurePlayerNameIsGood(newname, playernum))
{ {
if (strcasecmp(newname, player_names[playernum]) != 0) if (!fasticmp(newname, player_names[playernum]))
{ {
if (netgame) if (netgame)
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false); HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
@@ -1508,9 +1508,9 @@ static void SendNameAndColor(void)
CV_StealthSet(&cv_playercolor, cv_playercolor.defaultvalue); CV_StealthSet(&cv_playercolor, cv_playercolor.defaultvalue);
} }
if (!strcmp(cv_playername.string, player_names[consoleplayer]) if (fastcmp(cv_playername.string, player_names[consoleplayer])
&& cv_playercolor.value == players[consoleplayer].skincolor && cv_playercolor.value == players[consoleplayer].skincolor
&& !strcmp(cv_skin.string, skins[players[consoleplayer].skin].name)) && fastcmp(cv_skin.string, skins[players[consoleplayer].skin].name))
return; return;
// We'll handle it later if we're not playing. // We'll handle it later if we're not playing.
@@ -1945,7 +1945,7 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
// set name // set name
if (player_name_changes[playernum] < MAXNAMECHANGES) if (player_name_changes[playernum] < MAXNAMECHANGES)
{ {
if (strcasecmp(player_names[playernum], name) != 0) if (!fasticmp(player_names[playernum], name))
SetPlayerName(playernum, name); SetPlayerName(playernum, name);
} }
@@ -2324,8 +2324,8 @@ static void Command_Playdemo_f(void)
CONS_Printf(M_GetText("Playing back demo '%s'.\n"), name); CONS_Printf(M_GetText("Playing back demo '%s'.\n"), name);
demo.loadfiles = strcmp(COM_Argv(2), "-addfiles") == 0; demo.loadfiles = fastcmp(COM_Argv(2), "-addfiles");
demo.ignorefiles = strcmp(COM_Argv(2), "-force") == 0; demo.ignorefiles = fastcmp(COM_Argv(2), "-force");
// Internal if no extension, external if one exists // Internal if no extension, external if one exists
// If external, convert the file name to a path in SRB2's home directory // If external, convert the file name to a path in SRB2's home directory
@@ -3196,20 +3196,20 @@ static void Command_Teamchange_f(void)
if (G_GametypeHasTeams()) if (G_GametypeHasTeams())
{ {
if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) if (fasticmp(COM_Argv(1), "red") || fasticmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) else if (fasticmp(COM_Argv(1), "blue") || fasticmp(COM_Argv(1), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) else if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasSpectators()) else if (G_GametypeHasSpectators())
{ {
if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1")) else if (fasticmp(COM_Argv(1), "playing") || fasticmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else else
error = true; error = true;
@@ -3286,20 +3286,20 @@ static void Command_Teamchange2_f(void)
if (G_GametypeHasTeams()) if (G_GametypeHasTeams())
{ {
if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) if (fasticmp(COM_Argv(1), "red") || fasticmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) else if (fasticmp(COM_Argv(1), "blue") || fasticmp(COM_Argv(1), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) else if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasSpectators()) else if (G_GametypeHasSpectators())
{ {
if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1")) else if (fasticmp(COM_Argv(1), "playing") || fasticmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else else
error = true; error = true;
@@ -3377,20 +3377,20 @@ static void Command_Teamchange3_f(void)
if (G_GametypeHasTeams()) if (G_GametypeHasTeams())
{ {
if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) if (fasticmp(COM_Argv(1), "red") || fasticmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) else if (fasticmp(COM_Argv(1), "blue") || fasticmp(COM_Argv(1), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) else if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasSpectators()) else if (G_GametypeHasSpectators())
{ {
if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1")) else if (fasticmp(COM_Argv(1), "playing") || fasticmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else else
error = true; error = true;
@@ -3468,20 +3468,20 @@ static void Command_Teamchange4_f(void)
if (G_GametypeHasTeams()) if (G_GametypeHasTeams())
{ {
if (!strcasecmp(COM_Argv(1), "red") || !strcasecmp(COM_Argv(1), "1")) if (fasticmp(COM_Argv(1), "red") || fasticmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (!strcasecmp(COM_Argv(1), "blue") || !strcasecmp(COM_Argv(1), "2")) else if (fasticmp(COM_Argv(1), "blue") || fasticmp(COM_Argv(1), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) else if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasSpectators()) else if (G_GametypeHasSpectators())
{ {
if (!strcasecmp(COM_Argv(1), "spectator") || !strcasecmp(COM_Argv(1), "0")) if (fasticmp(COM_Argv(1), "spectator") || fasticmp(COM_Argv(1), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else if (!strcasecmp(COM_Argv(1), "playing") || !strcasecmp(COM_Argv(1), "1")) else if (fasticmp(COM_Argv(1), "playing") || fasticmp(COM_Argv(1), "1"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else else
error = true; error = true;
@@ -3567,33 +3567,33 @@ static void Command_ServerTeamChange_f(void)
if (G_TagGametype()) if (G_TagGametype())
{ {
if (!strcasecmp(COM_Argv(2), "it") || !strcasecmp(COM_Argv(2), "1")) if (fasticmp(COM_Argv(2), "it") || fasticmp(COM_Argv(2), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (!strcasecmp(COM_Argv(2), "notit") || !strcasecmp(COM_Argv(2), "2")) else if (fasticmp(COM_Argv(2), "notit") || fasticmp(COM_Argv(2), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (!strcasecmp(COM_Argv(2), "playing") || !strcasecmp(COM_Argv(2), "3")) else if (fasticmp(COM_Argv(2), "playing") || fasticmp(COM_Argv(2), "3"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else if (!strcasecmp(COM_Argv(2), "spectator") || !strcasecmp(COM_Argv(2), "0")) else if (fasticmp(COM_Argv(2), "spectator") || fasticmp(COM_Argv(2), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasTeams()) else if (G_GametypeHasTeams())
{ {
if (!strcasecmp(COM_Argv(2), "red") || !strcasecmp(COM_Argv(2), "1")) if (fasticmp(COM_Argv(2), "red") || fasticmp(COM_Argv(2), "1"))
NetPacket.packet.newteam = 1; NetPacket.packet.newteam = 1;
else if (!strcasecmp(COM_Argv(2), "blue") || !strcasecmp(COM_Argv(2), "2")) else if (fasticmp(COM_Argv(2), "blue") || fasticmp(COM_Argv(2), "2"))
NetPacket.packet.newteam = 2; NetPacket.packet.newteam = 2;
else if (!strcasecmp(COM_Argv(2), "spectator") || !strcasecmp(COM_Argv(2), "0")) else if (fasticmp(COM_Argv(2), "spectator") || fasticmp(COM_Argv(2), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else else
error = true; error = true;
} }
else if (G_GametypeHasSpectators()) else if (G_GametypeHasSpectators())
{ {
if (!strcasecmp(COM_Argv(2), "spectator") || !strcasecmp(COM_Argv(2), "0")) if (fasticmp(COM_Argv(2), "spectator") || fasticmp(COM_Argv(2), "0"))
NetPacket.packet.newteam = 0; NetPacket.packet.newteam = 0;
else if (!strcasecmp(COM_Argv(2), "playing") || !strcasecmp(COM_Argv(2), "1")) else if (fasticmp(COM_Argv(2), "playing") || fasticmp(COM_Argv(2), "1"))
NetPacket.packet.newteam = 3; NetPacket.packet.newteam = 3;
else else
error = true; error = true;
@@ -5211,14 +5211,14 @@ static void Ringslinger_OnChange(void)
static void Gravity_OnChange(void) static void Gravity_OnChange(void)
{ {
if (!M_SecretUnlocked(SECRET_PANDORA) && !netgame && !cv_debug if (!M_SecretUnlocked(SECRET_PANDORA) && !netgame && !cv_debug
&& strcmp(cv_gravity.string, cv_gravity.defaultvalue)) && !fastcmp(cv_gravity.string, cv_gravity.defaultvalue))
{ {
CONS_Printf(M_GetText("You haven't earned this yet.\n")); CONS_Printf(M_GetText("You haven't earned this yet.\n"));
CV_StealthSet(&cv_gravity, cv_gravity.defaultvalue); CV_StealthSet(&cv_gravity, cv_gravity.defaultvalue);
return; return;
} }
#ifndef NETGAME_GRAVITY #ifndef NETGAME_GRAVITY
if(netgame) if (netgame)
{ {
CV_StealthSet(&cv_gravity, cv_gravity.defaultvalue); CV_StealthSet(&cv_gravity, cv_gravity.defaultvalue);
return; return;
+23 -22
View File
@@ -110,14 +110,14 @@ static fileused_t transferFiles[UINT8_MAX + 1];
// Write time of file: utime // Write time of file: utime
// Receiver structure // Receiver structure
INT32 fileneedednum; // Number of files needed to join the server INT32 fileneedednum = 0; // Number of files needed to join the server
fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files fileneeded_t fileneeded[MAX_WADFILES] = {}; // List of needed files
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
static I_mutex downloadmutex; static I_mutex downloadmutex;
#endif #endif
char downloaddir[512] = "DOWNLOAD"; char downloaddir[512] = "DOWNLOAD";
file_download_t filedownload; file_download_t filedownload = {};
#ifdef HAVE_CURL #ifdef HAVE_CURL
static CURL *http_handle; static CURL *http_handle;
@@ -131,7 +131,7 @@ static UINT32 curl_origfilesize;
static UINT32 curl_origtotalfilesize; static UINT32 curl_origtotalfilesize;
static char *curl_realname = NULL; static char *curl_realname = NULL;
fileneeded_t *curl_curfile = NULL; fileneeded_t *curl_curfile = NULL;
HTTP_login *curl_logins; HTTP_login *curl_logins = NULL;
#endif #endif
/** Fills a serverinfo packet with information about wad files loaded. /** Fills a serverinfo packet with information about wad files loaded.
@@ -550,7 +550,8 @@ INT32 CL_CheckFiles(void)
for (j = mainwads+1; j < numwadfiles; j++) for (j = mainwads+1; j < numwadfiles; j++)
{ {
nameonly(strcpy(wadfilename, wadfiles[j]->filename)); nameonly(strcpy(wadfilename, wadfiles[j]->filename));
if (!stricmp(wadfilename, fileneeded[i].filename) &&
if (fasticmp(wadfilename, fileneeded[i].filename) &&
!memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16)) !memcmp(wadfiles[j]->md5sum, fileneeded[i].md5sum, 16))
{ {
CONS_Debug(DBG_NETPLAY, "already loaded\n"); CONS_Debug(DBG_NETPLAY, "already loaded\n");
@@ -665,7 +666,7 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid)
strlcpy(wadfilename, wadfiles[wadnum]->filename, MAX_WADPATH); strlcpy(wadfilename, wadfiles[wadnum]->filename, MAX_WADPATH);
nameonly(wadfilename); nameonly(wadfilename);
if (!stricmp(wadfilename, p->id.filename)) if (fasticmp(wadfilename, p->id.filename))
{ {
// Copy file name with full path // Copy file name with full path
strlcpy(p->id.filename, wadfiles[wadnum]->filename, MAX_WADPATH); strlcpy(p->id.filename, wadfiles[wadnum]->filename, MAX_WADPATH);
@@ -901,7 +902,7 @@ void SV_FileSendTicker(void)
if (ram) if (ram)
{ {
M_Memcpy(p->data, &f->id.ram[transfer[i].position], size); memcpy(p->data, &f->id.ram[transfer[i].position], size);
} }
else if (fread(p->data, 1, size, transferFiles[f->fileid].file) != size) else if (fread(p->data, 1, size, transferFiles[f->fileid].file) != size)
{ {
@@ -946,17 +947,17 @@ void Got_Filetxpak(void)
char *filename = file->filename; char *filename = file->filename;
static INT32 filetime = 0; static INT32 filetime = 0;
if (!(strcmp(filename, "srb2.srb") if ((fastcmp(filename, "srb2.srb")
//&& strcmp(filename, "srb2.wad") //|| fastcmp(filename, "srb2.wad")
//&& strcmp(filename, "patch.dta") //|| fastcmp(filename, "patch.dta")
//&& strcmp(filename, "music.dta") //|| fastcmp(filename, "music.dta")
&& strcmp(filename, "gfx.kart") || fastcmp(filename, "gfx.kart")
&& strcmp(filename, "textures.kart") || fastcmp(filename, "textures.kart")
&& strcmp(filename, "chars.kart") || fastcmp(filename, "chars.kart")
&& strcmp(filename, "maps.kart") || fastcmp(filename, "maps.kart")
&& strcmp(filename, "sounds.kart") || fastcmp(filename, "sounds.kart")
&& strcmp(filename, "music.kart") || fastcmp(filename, "music.kart")
&& strcmp(filename, "patch.kart") || fastcmp(filename, "patch.kart")
)) ))
I_Error("Tried to download \"%s\"", filename); I_Error("Tried to download \"%s\"", filename);
@@ -1103,7 +1104,7 @@ void nameonly(char *s)
ns = &(s[j+1]); ns = &(s[j+1]);
len = strlen(ns); len = strlen(ns);
#if 0 #if 0
M_Memcpy(s, ns, len+1); memcpy(s, ns, len+1);
#else #else
memmove(s, ns, len+1); memmove(s, ns, len+1);
#endif #endif
@@ -1197,7 +1198,7 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet
} }
// next, check SRB2's "home" directory (if non-'.') // next, check SRB2's "home" directory (if non-'.')
if (strcmp(srb2home, ".")) if (!fastcmp(srb2home, "."))
{ {
homecheck = filesearch(filename, srb2home, wantedmd5sum, completepath, 10); homecheck = filesearch(filename, srb2home, wantedmd5sum, completepath, 10);
@@ -1209,7 +1210,7 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet
} }
// next, check SRB2's "path" directory (also if non-'.') // next, check SRB2's "path" directory (also if non-'.')
if (strcmp(srb2path, ".")) if (!fastcmp(srb2path, "."))
{ {
homecheck = filesearch(filename, srb2path, wantedmd5sum, completepath, 10); homecheck = filesearch(filename, srb2path, wantedmd5sum, completepath, 10);
@@ -1554,7 +1555,7 @@ CURLGetLogin (const char *url, HTTP_login ***return_prev_next)
( login = (*prev_next)); ( login = (*prev_next));
prev_next = &login->next prev_next = &login->next
){ ){
if (strcmp(login->url, url) == 0) if (fastcmp(login->url, url) != 0)
{ {
if (return_prev_next) if (return_prev_next)
(*return_prev_next) = prev_next; (*return_prev_next) = prev_next;
+2 -2
View File
@@ -211,12 +211,12 @@ void D_SetupProtocol(void)
if (result) if (result)
{ {
if (strcmp(buffer, "no") == 0) if (!fastcmp(buffer, "no"))
{ {
fclose(fp); fclose(fp);
return; return;
} }
else if (strcmp(buffer, exe_path) != 0) else if (fastcmp(buffer, exe_path))
{ {
// overwrite // overwrite
fclose(fp); fclose(fp);
+2 -2
View File
@@ -1709,9 +1709,9 @@ char *I_GetUserName(void)
strncpy(username, p, MAXPLAYERNAME); strncpy(username, p, MAXPLAYERNAME);
} }
if (!fastcmp(username, ""))
if (strcmp(username, "") != 0)
return username; return username;
return NULL; // dummy for platform independent version return NULL; // dummy for platform independent version
} }
+3 -3
View File
@@ -277,7 +277,7 @@ static void DRPC_HandleJoinRequest(const DiscordUser *requestUser)
while (append != NULL) while (append != NULL)
{ {
// CHECK FOR DUPES!! Ignore any that already exist from the same user. // CHECK FOR DUPES!! Ignore any that already exist from the same user.
if (!strcmp(newRequest->userID, append->userID)) if (fastcmp(newRequest->userID, append->userID))
{ {
Discord_Respond(newRequest->userID, DISCORD_REPLY_IGNORE); Discord_Respond(newRequest->userID, DISCORD_REPLY_IGNORE);
DRPC_RemoveRequest(newRequest); DRPC_RemoveRequest(newRequest);
@@ -419,7 +419,7 @@ static const char *DRPC_GetServerIP(void)
// If you're connected // If you're connected
if (I_GetNodeAddress && (address = I_GetNodeAddress(servernode)) != NULL) if (I_GetNodeAddress && (address = I_GetNodeAddress(servernode)) != NULL)
{ {
if (strcmp(address, "self")) if (!fastcmp(address, "self"))
{ {
// We're not the server, so we could successfully get the IP! // We're not the server, so we could successfully get the IP!
// No need to do anything else :) // No need to do anything else :)
@@ -684,7 +684,7 @@ void DRPC_UpdatePresence(void)
// Character image // Character image
while (supportedSkins[checkSkin] != NULL) while (supportedSkins[checkSkin] != NULL)
{ {
if (!strcmp(skins[players[consoleplayer].skin].name, supportedSkins[checkSkin])) if (fastcmp(skins[players[consoleplayer].skin].name, supportedSkins[checkSkin]))
{ {
snprintf(charimg, 21, "char%s", supportedSkins[checkSkin]); snprintf(charimg, 21, "char%s", supportedSkins[checkSkin]);
discordPresence.smallImageKey = charimg; discordPresence.smallImageKey = charimg;
+2 -5
View File
@@ -69,6 +69,8 @@ extern "C" {
#include <sys/stat.h> #include <sys/stat.h>
#include <ctype.h> #include <ctype.h>
#include "fastcmp.h"
#ifdef _WIN32 #ifdef _WIN32
#include <io.h> #include <io.h>
#endif #endif
@@ -451,11 +453,6 @@ extern char savegamename[256];
//TODO: delet this //TODO: delet this
#define M_GetText(x) (x) #define M_GetText(x) (x)
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 *va(const char *format, ...) FUNCPRINTF;
char *M_GetToken(const char *inputString); char *M_GetToken(const char *inputString);
char *sizeu1(size_t num); char *sizeu1(size_t num);
+2 -2
View File
@@ -257,7 +257,7 @@ static void F_DoWipe(fademask_t *fademask)
// shortcut - memcpy source to work // shortcut - memcpy source to work
while (draw_linestogo--) while (draw_linestogo--)
{ {
M_Memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart); memcpy(w_base+relativepos, s_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width; relativepos += vid.width;
} }
} }
@@ -266,7 +266,7 @@ static void F_DoWipe(fademask_t *fademask)
// shortcut - memcpy target to work // shortcut - memcpy target to work
while (draw_linestogo--) while (draw_linestogo--)
{ {
M_Memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart); memcpy(w_base+relativepos, e_base+relativepos, draw_rowend-draw_rowstart);
relativepos += vid.width; relativepos += vid.width;
} }
} }
+12 -12
View File
@@ -198,7 +198,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
for (; *path != NULL; path++) for (; *path != NULL; path++)
{ {
if (strcasecmp(*path, dent->d_name) == 0) if (fasticmp(*path, dent->d_name))
{ {
skipfolder = true; skipfolder = true;
break; break;
@@ -212,7 +212,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
} }
} }
if (strcasecmp(".git", dent->d_name) // sanity if you're weird like me if (!fasticmp(".git", dent->d_name) // sanity if you're weird like me
&& (dirhandle[depthleft-1] = opendir(searchpath)) != NULL) && (dirhandle[depthleft-1] = opendir(searchpath)) != NULL)
{ {
// Got read permissions! // Got read permissions!
@@ -227,7 +227,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
// I am a file! // I am a file!
if (strcasecmp(searchname, dent->d_name)) if (!fasticmp(searchname, dent->d_name))
continue; // Not what we're looking for! continue; // Not what we're looking for!
switch (checkfilemd5(searchpath, wantedmd5sum)) switch (checkfilemd5(searchpath, wantedmd5sum))
@@ -353,7 +353,7 @@ void searchfilemenu(char *tempname)
{ {
for (i = first; i < sizedirmenu; i++) for (i = first; i < sizedirmenu; i++)
{ {
if (!strcmp(dirmenu[i]+DIR_STRING, tempname)) if (fastcmp(dirmenu[i]+DIR_STRING, tempname))
{ {
dir_on[menudepthleft] = i; dir_on[menudepthleft] = i;
break; break;
@@ -400,7 +400,7 @@ void searchfilemenu(char *tempname)
{ {
if (filemenucmp(coredirmenu[i]+DIR_STRING, localmenusearch)) if (filemenucmp(coredirmenu[i]+DIR_STRING, localmenusearch))
{ {
if (tempname && !strcmp(coredirmenu[i]+DIR_STRING, tempname)) if (tempname && fastcmp(coredirmenu[i]+DIR_STRING, tempname))
{ {
dir_on[menudepthleft] = sizedirmenu; dir_on[menudepthleft] = sizedirmenu;
Z_Free(tempname); Z_Free(tempname);
@@ -478,14 +478,14 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
if (replayhut) if (replayhut)
{ {
if (strcasecmp(".lmp", dent->d_name+len-5)) if (!fasticmp(".lmp", dent->d_name+len-5))
continue; // Not a replay continue; // Not a replay
} }
else if (!cv_addons_showall.value) else if (!cv_addons_showall.value)
{ {
UINT8 ext; UINT8 ext;
for (ext = 0; ext < NUM_EXT_TABLE; ext++) for (ext = 0; ext < NUM_EXT_TABLE; ext++)
if (!strcasecmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0]))) if (fasticmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0])))
break; // extension comparison break; // extension comparison
if (ext == NUM_EXT_TABLE) if (ext == NUM_EXT_TABLE)
@@ -559,7 +559,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
if (replayhut) if (replayhut)
{ {
if (strcasecmp(".lmp", dent->d_name+len-5)) if (!fasticmp(".lmp", dent->d_name+len-5))
continue; // Not a replay continue; // Not a replay
ext = EXT_TXT; // This isn't used anywhere but better safe than sorry for messing with this... ext = EXT_TXT; // This isn't used anywhere but better safe than sorry for messing with this...
@@ -567,7 +567,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
else else
{ {
for (; ext < NUM_EXT_TABLE; ext++) for (; ext < NUM_EXT_TABLE; ext++)
if (!strcasecmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0]))) if (fasticmp(exttable[ext]+1, dent->d_name+len-(exttable[ext][0])))
break; // extension comparison break; // extension comparison
if (ext == NUM_EXT_TABLE && !cv_addons_showall.value) if (ext == NUM_EXT_TABLE && !cv_addons_showall.value)
@@ -587,7 +587,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
nameonly(filenamebuf[i]); nameonly(filenamebuf[i]);
} }
if (strcmp(dent->d_name, filenamebuf[i])) if (!fastcmp(dent->d_name, filenamebuf[i]))
continue; continue;
if (cv_addons_md5.value && !checkfilemd5(menupath, wadfiles[i]->md5sum)) if (cv_addons_md5.value && !checkfilemd5(menupath, wadfiles[i]->md5sum))
@@ -598,11 +598,11 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
} }
else if (ext == EXT_TXT) else if (ext == EXT_TXT)
{ {
if (!strncmp(dent->d_name, "log-", 4) || !strcmp(dent->d_name, "errorlog.txt")) if (!strncmp(dent->d_name, "log-", 4) || fastcmp(dent->d_name, "errorlog.txt"))
ext |= EXT_LOADED; ext |= EXT_LOADED;
} }
if (!strcmp(dent->d_name, configfile)) if (fastcmp(dent->d_name, configfile))
ext |= EXT_LOADED; ext |= EXT_LOADED;
} }
+51 -51
View File
@@ -68,8 +68,8 @@ UINT8 numDemos = 0; //3; -- i'm FED UP of losing my skincolour to a broken
UINT32 demoDelayTime = 15*TICRATE; UINT32 demoDelayTime = 15*TICRATE;
UINT32 demoIdleTime = 3*TICRATE; UINT32 demoIdleTime = 3*TICRATE;
boolean nodrawers; // for comparative timing purposes boolean nodrawers = false; // for comparative timing purposes
boolean noblit; // for comparative timing purposes boolean noblit = false; // for comparative timing purposes
static tic_t demostarttime; // for comparative timing purposes static tic_t demostarttime; // for comparative timing purposes
//@TODO put these all in a struct for namespacing purposes? //@TODO put these all in a struct for namespacing purposes?
@@ -80,7 +80,7 @@ static UINT8 *demoend;
static UINT8 demoflags; static UINT8 demoflags;
static boolean demosynced = true; // console warning message static boolean demosynced = true; // console warning message
struct demovars_s demo; struct demovars_s demo = {};
consvar_t cv_resyncdemo = {"resyncdemo", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_resyncdemo = {"resyncdemo", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -257,14 +257,14 @@ void G_ReadDemoExtraData(void)
UINT8 kartspeed, kartweight; UINT8 kartspeed, kartweight;
// Skin // Skin
M_Memcpy(name, demobuf.p, 16); memcpy(name, demobuf.p, 16);
demobuf.p += 16; demobuf.p += 16;
SetPlayerSkin(p, name); SetPlayerSkin(p, name);
kartspeed = READUINT8(demobuf.p); kartspeed = READUINT8(demobuf.p);
kartweight = READUINT8(demobuf.p); kartweight = READUINT8(demobuf.p);
if (stricmp(skins[players[p].skin].name, name) != 0) if (!fasticmp(skins[players[p].skin].name, name))
FindClosestSkinForStats(p, kartspeed, kartweight); FindClosestSkinForStats(p, kartspeed, kartweight);
players[p].kartspeed = kartspeed; players[p].kartspeed = kartspeed;
@@ -274,10 +274,10 @@ void G_ReadDemoExtraData(void)
if (extradata & DXD_COLOR) if (extradata & DXD_COLOR)
{ {
// Color // Color
M_Memcpy(name, demobuf.p, 16); memcpy(name, demobuf.p, 16);
demobuf.p += 16; demobuf.p += 16;
for (i = 0; i < MAXSKINCOLORS; i++) for (i = 0; i < MAXSKINCOLORS; i++)
if (!stricmp(KartColor_Names[i], name)) // SRB2kart if (fasticmp(KartColor_Names[i], name)) // SRB2kart
{ {
players[p].skincolor = i; players[p].skincolor = i;
if (players[p].mo) if (players[p].mo)
@@ -289,7 +289,7 @@ void G_ReadDemoExtraData(void)
if (extradata & DXD_NAME) if (extradata & DXD_NAME)
{ {
// Name // Name
M_Memcpy(player_names[p],demobuf.p,16); memcpy(player_names[p],demobuf.p,16);
demobuf.p += 16; demobuf.p += 16;
} }
@@ -395,7 +395,7 @@ void G_WriteDemoExtraData(void)
// Skin // Skin
memset(name, 0, 16); memset(name, 0, 16);
strncpy(name, skins[players[i].skin].name, 16); strncpy(name, skins[players[i].skin].name, 16);
M_Memcpy(demobuf.p,name,16); memcpy(demobuf.p, name, 16);
demobuf.p += 16; demobuf.p += 16;
WRITEUINT8(demobuf.p, skins[players[i].skin].kartspeed); WRITEUINT8(demobuf.p, skins[players[i].skin].kartspeed);
@@ -407,7 +407,7 @@ void G_WriteDemoExtraData(void)
// Color // Color
memset(name, 0, 16); memset(name, 0, 16);
strncpy(name, KartColor_Names[players[i].skincolor], 16); strncpy(name, KartColor_Names[players[i].skincolor], 16);
M_Memcpy(demobuf.p,name,16); memcpy(demobuf.p, name, 16);
demobuf.p += 16; demobuf.p += 16;
} }
@@ -416,7 +416,7 @@ void G_WriteDemoExtraData(void)
// Name // Name
memset(name, 0, 16); memset(name, 0, 16);
memcpy(name, player_names[i], 15); // Keeping 1 null byte for safety, sorry players with name containing more than 15 characters memcpy(name, player_names[i], 15); // Keeping 1 null byte for safety, sorry players with name containing more than 15 characters
M_Memcpy(demobuf.p,name,16); memcpy(demobuf.p, name, 16);
demobuf.p += 16; demobuf.p += 16;
} }
@@ -1670,7 +1670,7 @@ void G_BeginRecording(void)
demoflags |= DF_LUAVARS; demoflags |= DF_LUAVARS;
// Setup header. // Setup header.
M_Memcpy(demobuf.p, DEMOHEADER, 12); demobuf.p += 12; memcpy(demobuf.p, DEMOHEADER, 12); demobuf.p += 12;
WRITEUINT8(demobuf.p,VERSION); WRITEUINT8(demobuf.p,VERSION);
WRITEUINT8(demobuf.p,SUBVERSION); WRITEUINT8(demobuf.p,SUBVERSION);
WRITEUINT16(demobuf.p,DEMOVERSION); WRITEUINT16(demobuf.p,DEMOVERSION);
@@ -1701,9 +1701,9 @@ void G_BeginRecording(void)
demobuf.p += 16; demobuf.p += 16;
// game data // game data
M_Memcpy(demobuf.p, "PLAY", 4); demobuf.p += 4; memcpy(demobuf.p, "PLAY", 4); demobuf.p += 4;
WRITEINT16(demobuf.p,gamemap); WRITEINT16(demobuf.p,gamemap);
M_Memcpy(demobuf.p, mapmd5, 16); demobuf.p += 16; memcpy(demobuf.p, mapmd5, 16); demobuf.p += 16;
WRITEUINT8(demobuf.p, demoflags); WRITEUINT8(demobuf.p, demoflags);
WRITEUINT8(demobuf.p, gametype & 0xFF); WRITEUINT8(demobuf.p, gametype & 0xFF);
@@ -1763,19 +1763,19 @@ void G_BeginRecording(void)
// Name // Name
memset(name, 0, 16); memset(name, 0, 16);
memcpy(name, player_names[p], 15); memcpy(name, player_names[p], 15);
M_Memcpy(demobuf.p,name,16); memcpy(demobuf.p, name, 16);
demobuf.p += 16; demobuf.p += 16;
// Skin // Skin
memset(name, 0, 16); memset(name, 0, 16);
strncpy(name, skins[player->skin].name, 16); strncpy(name, skins[player->skin].name, 16);
M_Memcpy(demobuf.p,name,16); memcpy(demobuf.p, name, 16);
demobuf.p += 16; demobuf.p += 16;
// Color // Color
memset(name, 0, 16); memset(name, 0, 16);
strncpy(name, KartColor_Names[player->skincolor], 16); strncpy(name, KartColor_Names[player->skincolor], 16);
M_Memcpy(demobuf.p,name,16); memcpy(demobuf.p, name, 16);
demobuf.p += 16; demobuf.p += 16;
// Score, since Kart uses this to determine where you start on the map // Score, since Kart uses this to determine where you start on the map
@@ -1834,19 +1834,19 @@ void G_WriteStanding(UINT8 ranking, char *name, INT32 skinnum, UINT8 color, UINT
// Name // Name
memset(temp, 0, 16); memset(temp, 0, 16);
strncpy(temp, name, 16); strncpy(temp, name, 16);
M_Memcpy(demobuf.p,temp,16); memcpy(demobuf.p,temp,16);
demobuf.p += 16; demobuf.p += 16;
// Skin // Skin
memset(temp, 0, 16); memset(temp, 0, 16);
strncpy(temp, skins[skinnum].name, 16); strncpy(temp, skins[skinnum].name, 16);
M_Memcpy(demobuf.p,temp,16); memcpy(demobuf.p,temp,16);
demobuf.p += 16; demobuf.p += 16;
// Color // Color
memset(temp, 0, 16); memset(temp, 0, 16);
strncpy(temp, KartColor_Names[color], 16); strncpy(temp, KartColor_Names[color], 16);
M_Memcpy(demobuf.p,temp,16); memcpy(demobuf.p,temp,16);
demobuf.p += 16; demobuf.p += 16;
// Score/time/whatever // Score/time/whatever
@@ -2212,7 +2212,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
{ {
case DEMOVERSION: // latest always supported case DEMOVERSION: // latest always supported
// demo title // demo title
M_Memcpy(pdemo->title, info_p, 64); memcpy(pdemo->title, info_p, 64);
info_p += 64; info_p += 64;
break; break;
#ifdef DEMO_COMPAT_100 #ifdef DEMO_COMPAT_100
@@ -2289,7 +2289,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
{ {
for (UINT8 j = 0; kartspeed_cons_t[j].strvalue; j++) for (UINT8 j = 0; kartspeed_cons_t[j].strvalue; j++)
{ {
if (!stricmp(kartspeed_cons_t[j].strvalue, svalue)) if (fasticmp(kartspeed_cons_t[j].strvalue, svalue))
pdemo->kartspeed = kartspeed_cons_t[j].value; pdemo->kartspeed = kartspeed_cons_t[j].value;
} }
} }
@@ -2311,17 +2311,17 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
pdemo->standings[count].ranking = READUINT8(extrainfo_p); pdemo->standings[count].ranking = READUINT8(extrainfo_p);
// Name // Name
M_Memcpy(pdemo->standings[count].name, extrainfo_p, 16); memcpy(pdemo->standings[count].name, extrainfo_p, 16);
extrainfo_p += 16; extrainfo_p += 16;
// Skin // Skin
M_Memcpy(temp,extrainfo_p,16); memcpy(temp,extrainfo_p,16);
extrainfo_p += 16; extrainfo_p += 16;
pdemo->standings[count].skin = UINT8_MAX; pdemo->standings[count].skin = UINT8_MAX;
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
if (stricmp(skins[i].name, temp) == 0) if (fasticmp(skins[i].name, temp))
{ {
pdemo->standings[count].skin = i; pdemo->standings[count].skin = i;
break; break;
@@ -2329,12 +2329,12 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
} }
// Color // Color
M_Memcpy(temp,extrainfo_p,16); memcpy(temp,extrainfo_p,16);
extrainfo_p += 16; extrainfo_p += 16;
for (i = 0; i < MAXSKINCOLORS; i++) for (i = 0; i < MAXSKINCOLORS; i++)
{ {
if (!stricmp(KartColor_Names[i],temp)) // SRB2kart if (fasticmp(KartColor_Names[i],temp)) // SRB2kart
{ {
pdemo->standings[count].color = i; pdemo->standings[count].color = i;
break; break;
@@ -2494,7 +2494,7 @@ void G_LoadDemoTitle(menudemo_t *pdemo)
{ {
case DEMOVERSION: // latest always supported case DEMOVERSION: // latest always supported
// demo title // demo title
M_Memcpy(pdemo->title, info_p, 64); memcpy(pdemo->title, info_p, 64);
// demo date // demo date
char *demodate; char *demodate;
@@ -2627,7 +2627,7 @@ void G_DoPlayDemo(char *defdemoname)
{ {
case DEMOVERSION: // latest always supported case DEMOVERSION: // latest always supported
// demo title // demo title
M_Memcpy(demo.titlename, demobuf.p, 64); memcpy(demo.titlename, demobuf.p, 64);
demobuf.p += 64; demobuf.p += 64;
break; break;
#ifdef DEMO_COMPAT_100 #ifdef DEMO_COMPAT_100
@@ -2766,15 +2766,15 @@ void G_DoPlayDemo(char *defdemoname)
if (demo.version == 0x0001) if (demo.version == 0x0001)
{ {
// Player name // Player name
M_Memcpy(player_names[0],demobuf.p,16); memcpy(player_names[0],demobuf.p,16);
demobuf.p += 16; demobuf.p += 16;
// Skin // Skin
M_Memcpy(skin,demobuf.p,16); memcpy(skin,demobuf.p,16);
demobuf.p += 16; demobuf.p += 16;
// Color // Color
M_Memcpy(color,demobuf.p,16); memcpy(color,demobuf.p,16);
demobuf.p += 16; demobuf.p += 16;
demobuf.p += 5; // Backwards compat - some stats demobuf.p += 5; // Backwards compat - some stats
@@ -2807,7 +2807,7 @@ void G_DoPlayDemo(char *defdemoname)
// Set color // Set color
for (i = 0; i < MAXSKINCOLORS; i++) for (i = 0; i < MAXSKINCOLORS; i++)
{ {
if (!stricmp(KartColor_Names[i],color)) // SRB2kart if (fasticmp(KartColor_Names[i],color)) // SRB2kart
{ {
players[0].skincolor = i; players[0].skincolor = i;
break; break;
@@ -2933,21 +2933,21 @@ void G_DoPlayDemo(char *defdemoname)
players[p].spectator = spectator; players[p].spectator = spectator;
// Name // Name
M_Memcpy(player_names[p],demobuf.p,16); memcpy(player_names[p],demobuf.p,16);
demobuf.p += 16; demobuf.p += 16;
// Skin // Skin
M_Memcpy(skin,demobuf.p,16); memcpy(skin,demobuf.p,16);
demobuf.p += 16; demobuf.p += 16;
SetPlayerSkin(p, skin); SetPlayerSkin(p, skin);
// Color // Color
M_Memcpy(color,demobuf.p,16); memcpy(color,demobuf.p,16);
demobuf.p += 16; demobuf.p += 16;
for (i = 0; i < MAXSKINCOLORS; i++) for (i = 0; i < MAXSKINCOLORS; i++)
{ {
if (!stricmp(KartColor_Names[i],color)) // SRB2kart if (fasticmp(KartColor_Names[i],color)) // SRB2kart
{ {
players[p].skincolor = i; players[p].skincolor = i;
break; break;
@@ -2961,7 +2961,7 @@ void G_DoPlayDemo(char *defdemoname)
kartspeed[p] = READUINT8(demobuf.p); kartspeed[p] = READUINT8(demobuf.p);
kartweight[p] = READUINT8(demobuf.p); kartweight[p] = READUINT8(demobuf.p);
if (stricmp(skins[players[p].skin].name, skin) != 0) if (!fasticmp(skins[players[p].skin].name, skin))
FindClosestSkinForStats(p, kartspeed[p], kartweight[p]); FindClosestSkinForStats(p, kartspeed[p], kartweight[p]);
// Look for the next player // Look for the next player
@@ -3101,7 +3101,7 @@ void G_AddGhost(char *defdemoname)
return; return;
} }
M_Memcpy(md5, p, 16); p += 16; // demo checksum memcpy(md5, p, 16); p += 16; // demo checksum
for (gh = ghosts; gh; gh = gh->next) for (gh = ghosts; gh; gh = gh->next)
{ {
@@ -3157,15 +3157,15 @@ void G_AddGhost(char *defdemoname)
if (ghostversion == 0x0001) if (ghostversion == 0x0001)
{ {
// Player name (TODO: Display this somehow if it doesn't match cv_playername!) // Player name (TODO: Display this somehow if it doesn't match cv_playername!)
M_Memcpy(name, p,16); memcpy(name, p,16);
p += 16; p += 16;
// Skin // Skin
M_Memcpy(skin, p,16); memcpy(skin, p,16);
p += 16; p += 16;
// Color // Color
M_Memcpy(color, p,16); memcpy(color, p,16);
p += 16; p += 16;
// Ghosts do not have a player structure to put this in. // Ghosts do not have a player structure to put this in.
@@ -3215,15 +3215,15 @@ void G_AddGhost(char *defdemoname)
} }
// Player name (TODO: Display this somehow if it doesn't match cv_playername!) // Player name (TODO: Display this somehow if it doesn't match cv_playername!)
M_Memcpy(name, p, 16); memcpy(name, p, 16);
p += 16; p += 16;
// Skin // Skin
M_Memcpy(skin, p, 16); memcpy(skin, p, 16);
p += 16; p += 16;
// Color // Color
M_Memcpy(color, p, 16); memcpy(color, p, 16);
p += 16; p += 16;
p += 4; // score p += 4; // score
@@ -3242,7 +3242,7 @@ void G_AddGhost(char *defdemoname)
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
if (!stricmp(skins[i].name,skin)) if (fasticmp(skins[i].name, skin))
{ {
ghskin = &skins[i]; ghskin = &skins[i];
break; break;
@@ -3260,7 +3260,7 @@ void G_AddGhost(char *defdemoname)
gh = Z_Calloc(sizeof(demoghost), PU_LEVEL, NULL); gh = Z_Calloc(sizeof(demoghost), PU_LEVEL, NULL);
gh->next = ghosts; gh->next = ghosts;
gh->buffer = buffer; gh->buffer = buffer;
M_Memcpy(gh->checksum, md5, 16); memcpy(gh->checksum, md5, 16);
gh->p = p; gh->p = p;
buffer = NULL; // buffer can't be freed now! buffer = NULL; // buffer can't be freed now!
@@ -3317,7 +3317,7 @@ void G_AddGhost(char *defdemoname)
for (i = 0; i < MAXSKINCOLORS; i++) for (i = 0; i < MAXSKINCOLORS; i++)
{ {
if (!stricmp(KartColor_Names[i],color)) // SRB2kart if (fasticmp(KartColor_Names[i],color)) // SRB2kart
{ {
gh->mo->color = (UINT8)i; gh->mo->color = (UINT8)i;
break; break;
@@ -3409,7 +3409,7 @@ void G_UpdateStaffGhostName(lumpnum_t l)
if (ghostversion == 0x0001) if (ghostversion == 0x0001)
{ {
// Player name // Player name
M_Memcpy(dummystaffname, p,16); memcpy(dummystaffname, p,16);
dummystaffname[16] = '\0'; dummystaffname[16] = '\0';
return; // Not really a failure but whatever return; // Not really a failure but whatever
} }
@@ -3431,7 +3431,7 @@ void G_UpdateStaffGhostName(lumpnum_t l)
if (READUINT8(p) != 0) if (READUINT8(p) != 0)
return; return;
M_Memcpy(dummystaffname, p, 16); memcpy(dummystaffname, p, 16);
dummystaffname[16] = '\0'; dummystaffname[16] = '\0';
// Ok, no longer any reason to care, bye // Ok, no longer any reason to care, bye
@@ -3625,7 +3625,7 @@ void G_SaveDemo(void)
} }
WRITEUINT8(demobuf.p, DW_END); // Mark end of demo extra data. WRITEUINT8(demobuf.p, DW_END); // Mark end of demo extra data.
M_Memcpy(p, demo.titlename, 64); // Write demo title here memcpy(p, demo.titlename, 64); // Write demo title here
p += 64; p += 64;
if (multiplayer) if (multiplayer)
+182 -171
View File
@@ -59,15 +59,15 @@
#include "discord.h" #include "discord.h"
#endif #endif
gameaction_t gameaction; gameaction_t gameaction = 0;
gamestate_t gamestate = GS_NULL; gamestate_t gamestate = GS_NULL;
UINT8 ultimatemode = false; UINT8 ultimatemode = false;
boolean botingame; boolean botingame = false;
UINT8 botskin; UINT8 botskin = 0;
UINT8 botcolor; UINT8 botcolor = 0;
JoyType_t Joystick[MAXSPLITSCREENPLAYERS]; JoyType_t Joystick[MAXSPLITSCREENPLAYERS] = {};
// 1024 bytes is plenty for a savegame // 1024 bytes is plenty for a savegame
#define SAVEGAMESIZE (1024) #define SAVEGAMESIZE (1024)
@@ -83,10 +83,10 @@ static void G_DoContinued(void);
static void G_DoWorldDone(void); static void G_DoWorldDone(void);
static void G_DoStartVote(void); static void G_DoStartVote(void);
music_t mapmusic; music_t mapmusic = {};
INT16 gamemap = 1; INT16 gamemap = 1;
INT16 maptol; INT16 maptol = 0;
UINT8 globalweather = 0; UINT8 globalweather = 0;
INT32 curWeather = PRECIP_NONE; INT32 curWeather = PRECIP_NONE;
INT32 cursaveslot = -1; // Auto-save 1p savegame slot INT32 cursaveslot = -1; // Auto-save 1p savegame slot
@@ -97,29 +97,29 @@ UINT16 mainwads = 0;
boolean modifiedgame = false; // Set if homebrew PWAD stuff has been added. boolean modifiedgame = false; // Set if homebrew PWAD stuff has been added.
boolean majormods = false; // Set if Lua/Gameplay SOC/replacement map has been added. boolean majormods = false; // Set if Lua/Gameplay SOC/replacement map has been added.
boolean savemoddata = false; boolean savemoddata = false;
UINT8 paused; UINT8 paused = 0;
UINT8 modeattacking = ATTACKING_NONE; UINT8 modeattacking = ATTACKING_NONE;
boolean imcontinuing = false; boolean imcontinuing = false;
boolean runemeraldmanager = false; boolean runemeraldmanager = false;
boolean netgame; // only true if packets are broadcast boolean netgame = false; // only true if packets are broadcast
boolean multiplayer; boolean multiplayer = false;
boolean playeringame[MAXPLAYERS]; boolean playeringame[MAXPLAYERS] = {};
boolean addedtogame; boolean addedtogame = false;
player_t players[MAXPLAYERS]; player_t players[MAXPLAYERS] = {};
INT32 consoleplayer; // player taking events and displaying INT32 consoleplayer = 0; // player taking events and displaying
INT32 displayplayers[MAXSPLITSCREENPLAYERS] = {0}; // view being displayed INT32 displayplayers[MAXSPLITSCREENPLAYERS] = {}; // view being displayed
tic_t gametic; tic_t gametic = 0;
tic_t levelstarttic; // gametic at level start tic_t levelstarttic = 0; // gametic at level start
UINT32 totalrings; // for intermission UINT32 totalrings = 0; // for intermission
INT16 lastmap; // last level you were at (returning from special stages) INT16 lastmap = 0; // last level you were at (returning from special stages)
tic_t timeinmap; // Ticker for time spent in level (used for levelcard display) tic_t timeinmap = 0; // Ticker for time spent in level (used for levelcard display)
INT16 spstage_start; INT16 spstage_start = 0;
INT16 sstage_start; INT16 sstage_start = 0;
INT16 sstage_end; INT16 sstage_end = 0;
boolean looptitle = true; boolean looptitle = true;
boolean useNightsSS = false; boolean useNightsSS = false;
@@ -134,42 +134,42 @@ boolean countdowntimeup = false;
cutscene_t *cutscenes[128]; cutscene_t *cutscenes[128];
INT16 nextmapoverride; INT16 nextmapoverride = 0;
boolean skipstats; boolean skipstats = false;
// Pointers to each CTF flag // Pointers to each CTF flag
mobj_t *redflag; mobj_t *redflag = NULL;
mobj_t *blueflag; mobj_t *blueflag = NULL;
// Pointers to CTF spawn location // Pointers to CTF spawn location
mapthing_t *rflagpoint; mapthing_t *rflagpoint = NULL;
mapthing_t *bflagpoint; mapthing_t *bflagpoint = NULL;
struct quake quake; struct quake quake;
// Map Header Information // Map Header Information
mapheader_t* mapheaderinfo[NUMMAPS] = {NULL}; mapheader_t* mapheaderinfo[NUMMAPS] = {};
static boolean exitgame = false; static boolean exitgame = false;
static boolean retrying = false; static boolean retrying = false;
UINT8 stagefailed; // Used for GEMS BONUS? Also to see if you beat the stage. UINT8 stagefailed = 0; // Used for GEMS BONUS? Also to see if you beat the stage.
UINT16 emeralds; UINT16 emeralds = 0;
UINT32 token; // Number of tokens collected in a level UINT32 token = 0; // Number of tokens collected in a level
UINT32 tokenlist; // List of tokens collected UINT32 tokenlist = 0; // List of tokens collected
INT32 tokenbits; // Used for setting token bits INT32 tokenbits = 0; // Used for setting token bits
// Old Special Stage // Old Special Stage
INT32 sstimer; // Time allotted in the special stage INT32 sstimer = 0; // Time allotted in the special stage
boolean gamedataloaded = false; boolean gamedataloaded = false;
// Time attack data for levels // Time attack data for levels
// These are dynamically allocated for space reasons now // These are dynamically allocated for space reasons now
recorddata_t *mainrecords[NUMMAPS] = {NULL}; recorddata_t *mainrecords[NUMMAPS] = {};
UINT8 mapvisited[NUMMAPS]; UINT8 mapvisited[NUMMAPS] = {};
UINT32 bluescore, redscore; // CTF and Team Match team scores UINT32 bluescore = 0, redscore = 0; // CTF and Team Match team scores
// ring count... for PERFECT! // ring count... for PERFECT!
INT32 nummaprings = 0; INT32 nummaprings = 0;
@@ -179,12 +179,12 @@ INT32 nummapboxes = 0;
INT32 numgotboxes = 0; INT32 numgotboxes = 0;
// Elminates unnecessary searching. // Elminates unnecessary searching.
boolean CheckForBustableBlocks; boolean CheckForBustableBlocks = false;
boolean CheckForBouncySector; boolean CheckForBouncySector = false;
boolean CheckForQuicksand; boolean CheckForQuicksand = false;
boolean CheckForMarioBlocks; boolean CheckForMarioBlocks = false;
boolean CheckForFloatBob; boolean CheckForFloatBob = false;
boolean CheckForReverseGravity; boolean CheckForReverseGravity = false;
// Powerup durations // Powerup durations
UINT16 invulntics = 20*TICRATE; UINT16 invulntics = 20*TICRATE;
@@ -215,67 +215,66 @@ INT32 gameovertics = 15*TICRATE;
UINT8 use1upSound = 0; UINT8 use1upSound = 0;
UINT8 maxXtraLife = 2; // Max extra lives from rings UINT8 maxXtraLife = 2; // Max extra lives from rings
UINT8 introtoplay; UINT8 introtoplay = 0;
UINT8 creditscutscene; UINT8 creditscutscene = 0;
// Emerald locations // Emerald locations
mobj_t *hunt1; mobj_t *hunt1 = NULL;
mobj_t *hunt2; mobj_t *hunt2 = NULL;
mobj_t *hunt3; mobj_t *hunt3 = NULL;
tic_t racecountdown, exitcountdown; // for racing tic_t racecountdown = 0, exitcountdown = 0; // for racing
fixed_t gravity; fixed_t gravity = 0;
fixed_t mapobjectscale; fixed_t mapobjectscale = FRACUNIT;
struct maplighting maplighting; struct maplighting maplighting;
INT16 autobalance; //for CTF team balance INT16 autobalance = 0; //for CTF team balance
INT16 teamscramble; //for CTF team scramble INT16 teamscramble = 0; //for CTF team scramble
INT16 scrambleplayers[MAXPLAYERS]; //for CTF team scramble INT16 scrambleplayers[MAXPLAYERS] = {}; //for CTF team scramble
INT16 scrambleteams[MAXPLAYERS]; //for CTF team scramble INT16 scrambleteams[MAXPLAYERS] = {}; //for CTF team scramble
INT16 scrambletotal; //for CTF team scramble INT16 scrambletotal = 0; //for CTF team scramble
INT16 scramblecount; //for CTF team scramble INT16 scramblecount = 0; //for CTF team scramble
INT32 cheats; //for multiplayer cheat commands INT32 cheats = 0; //for multiplayer cheat commands
// SRB2Kart // SRB2Kart
// Cvars that we don't want changed mid-game // Cvars that we don't want changed mid-game
UINT8 gamespeed; // Game's current speed (or difficulty, or cc, or etc); 0 for easy, 1 for normal, 2 for hard UINT8 gamespeed = 0; // Game's current speed (or difficulty, or cc, or etc); 0 for easy, 1 for normal, 2 for hard
boolean encoremode = false; // Encore Mode currently enabled? boolean encoremode = false; // Encore Mode currently enabled?
boolean prevencoremode; boolean prevencoremode = 0;
boolean franticitems; // Frantic items currently enabled? boolean franticitems = 0; // Frantic items currently enabled?
boolean comeback; // Battle Mode's karma comeback is on/off boolean comeback = 0; // Battle Mode's karma comeback is on/off
// Voting system // Voting system
INT16 votelevels[4][2]; // Levels that were rolled by the host INT16 votelevels[4][2] = {}; // Levels that were rolled by the host
SINT8 votes[MAXPLAYERS]; // Each player's vote SINT8 votes[MAXPLAYERS] = {}; // Each player's vote
SINT8 pickedvote; // What vote the host rolls SINT8 pickedvote = 0; // What vote the host rolls
// Server-sided, synched variables // Server-sided, synched variables
SINT8 battlewanted[4]; // WANTED players in battle, worth x2 points SINT8 battlewanted[4] = {}; // WANTED players in battle, worth x2 points
tic_t wantedcalcdelay; // Time before it recalculates WANTED tic_t wantedcalcdelay = 0; // Time before it recalculates WANTED
tic_t indirectitemcooldown; // Cooldown before any more Shrink, SPB, or any other item that works indirectly is awarded tic_t indirectitemcooldown = 0; // Cooldown before any more Shrink, SPB, or any other item that works indirectly is awarded
tic_t hyubgone; // Cooldown before hyudoro is allowed to be rerolled tic_t hyubgone = 0; // Cooldown before hyudoro is allowed to be rerolled
tic_t mapreset; // Map reset delay when enough players have joined an empty game tic_t mapreset = 0; // Map reset delay when enough players have joined an empty game
UINT8 nospectategrief; // How many players need to be in-game to eliminate last; for preventing spectate griefing UINT8 nospectategrief = 0; // How many players need to be in-game to eliminate last; for preventing spectate griefing
boolean thwompsactive; // Thwomps activate on lap 2 boolean thwompsactive = 0; // Thwomps activate on lap 2
SINT8 spbplace; // SPB exists, give the person behind better items SINT8 spbplace = 0; // SPB exists, give the person behind better items
boolean startedInFreePlay; // Map was started in free play boolean startedInFreePlay = false; // Map was started in free play
// Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players) // Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players)
boolean legitimateexit; // Did this client actually finish the match? boolean legitimateexit = 0; // Did this client actually finish the match?
boolean comebackshowninfo; // Have you already seen the "ATTACK OR PROTECT" message? boolean comebackshowninfo = 0; // Have you already seen the "ATTACK OR PROTECT" message?
static INT16 randmapbuffer[NUMMAPS+1]; // Buffer for maps RandMap is allowed to roll static INT16 randmapbuffer[NUMMAPS+1] = {}; // Buffer for maps RandMap is allowed to roll
tic_t hidetime; tic_t hidetime = 0;
// Grading // Grading
UINT32 timesBeaten; UINT32 timesBeaten = 0;
UINT32 timesBeatenWithEmeralds; UINT32 timesBeatenWithEmeralds = 0;
//UINT32 timesBeatenUltimate;
INT16 prevmap, nextmap; INT16 prevmap = 0, nextmap = 0;
// Analog Control // Analog Control
void SendWeaponPref(void); void SendWeaponPref(void);
@@ -470,7 +469,7 @@ consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, cechotoggle_t, NULL, 0,
#endif #endif
#ifdef SEENAMES #ifdef SEENAMES
player_t *seenplayer; // player we're aiming at right now player_t *seenplayer = NULL; // player we're aiming at right now
#endif #endif
char player_names[MAXPLAYERS][MAXPLAYERNAME+1] = char player_names[MAXPLAYERS][MAXPLAYERNAME+1] =
@@ -493,7 +492,7 @@ char player_names[MAXPLAYERS][MAXPLAYERNAME+1] =
"Player 16" "Player 16"
}; // SRB2kart - removed Players 17 through 32 }; // SRB2kart - removed Players 17 through 32
INT32 player_name_changes[MAXPLAYERS]; INT32 player_name_changes[MAXPLAYERS] = {};
INT16 rw_maximums[NUM_WEAPONS] = INT16 rw_maximums[NUM_WEAPONS] =
{ {
@@ -570,6 +569,7 @@ static void G_SetSaveGameModified(void)
{ {
if (!unlockables[i].conditionset) if (!unlockables[i].conditionset)
continue; continue;
if (!unlockables[i].unlocked) if (!unlockables[i].unlocked)
{ {
unlockables[i].unlocked = true; unlockables[i].unlocked = true;
@@ -595,7 +595,7 @@ void G_SetGameModified(boolean silent, boolean major)
G_SetSaveGameModified(); G_SetSaveGameModified();
if (!silent) if (!silent)
CONS_Alert(CONS_NOTICE, M_GetText("Record Attack data will be saved to a seperate save file.\n")); CONS_Alert(CONS_NOTICE, "Record Attack data will be saved to a seperate save file.\n");
// If in record attack recording, cancel it. // If in record attack recording, cancel it.
if (modeattacking) if (modeattacking)
@@ -634,6 +634,7 @@ const char *G_BuildMapName(INT32 map)
map = gamemap-1; map = gamemap-1;
else else
map = prevmap; map = prevmap;
map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, 0, false, NULL)+1; map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, 0, false, NULL)+1;
} }
@@ -687,11 +688,12 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player)
{ {
INT32 retaxis; INT32 retaxis;
INT32 axisval; INT32 axisval;
INT32 deadzone;
boolean flp = false; boolean flp = false;
UINT8 pnum = player-1; UINT8 pnum = player-1;
//find what axis to get // find what axis to get
switch (axissel) switch (axissel)
{ {
case AXISTURN: case AXISTURN:
@@ -750,45 +752,33 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player)
{ {
axisval /= 2; axisval /= 2;
retaxis = joyxmove[pnum][axisval]; retaxis = joyxmove[pnum][axisval];
deadzone = cv_xdeadzone[pnum].value;
if (retaxis < (-JOYAXISRANGE))
retaxis = -JOYAXISRANGE;
if (retaxis > (+JOYAXISRANGE))
retaxis = +JOYAXISRANGE;
if (!Joystick[pnum].bGamepadStyle && axissel < AXISDEAD)
{
const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_xdeadzone[pnum].value) >> FRACBITS;
if (abs(retaxis) <= jdeadzone)
return 0;
}
if (flp)
retaxis = -retaxis; // flip it around
return retaxis;
} }
else else
{ {
axisval--; axisval--;
axisval /= 2; axisval /= 2;
retaxis = joyymove[pnum][axisval]; retaxis = joyymove[pnum][axisval];
deadzone = cv_ydeadzone[pnum].value;
if (retaxis < (-JOYAXISRANGE))
retaxis = -JOYAXISRANGE;
if (retaxis > (+JOYAXISRANGE))
retaxis = +JOYAXISRANGE;
if (!Joystick[pnum].bGamepadStyle && axissel < AXISDEAD)
{
const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_ydeadzone[pnum].value) >> FRACBITS;
if (abs(retaxis) <= jdeadzone)
return 0;
}
if (flp)
retaxis = -retaxis; // flip it around
return retaxis;
} }
if (retaxis < (-JOYAXISRANGE))
retaxis = -JOYAXISRANGE;
if (retaxis > (+JOYAXISRANGE))
retaxis = +JOYAXISRANGE;
if (!Joystick[pnum].bGamepadStyle && axissel < AXISDEAD)
{
const INT32 jdeadzone = ((JOYAXISRANGE-1) * deadzone) >> FRACBITS;
if (abs(retaxis) <= jdeadzone)
return 0;
}
if (flp)
retaxis = -retaxis; // flip it around
return retaxis;
} }
boolean InputDown(INT32 gc, UINT8 p) boolean InputDown(INT32 gc, UINT8 p)
@@ -806,9 +796,9 @@ boolean InputDown(INT32 gc, UINT8 p)
} }
} }
INT32 localaiming[MAXSPLITSCREENPLAYERS]; INT32 localaiming[MAXSPLITSCREENPLAYERS] = {};
angle_t localangle[MAXSPLITSCREENPLAYERS]; angle_t localangle[MAXSPLITSCREENPLAYERS] = {};
boolean camspin[MAXSPLITSCREENPLAYERS]; boolean camspin[MAXSPLITSCREENPLAYERS] = {};
static fixed_t forwardmove[2] = {25<<FRACBITS>>16, 50<<FRACBITS>>16}; static fixed_t forwardmove[2] = {25<<FRACBITS>>16, 50<<FRACBITS>>16};
static fixed_t sidemove[2] = {2<<FRACBITS>>16, 4<<FRACBITS>>16}; static fixed_t sidemove[2] = {2<<FRACBITS>>16, 4<<FRACBITS>>16};
@@ -1210,7 +1200,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
if (gamestate == GS_LEVEL) if (gamestate == GS_LEVEL)
LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd));
//Reset away view if a command is given. // Reset away view if a command is given.
if (displayplayers[0] != consoleplayer && ssplayer == 1 if (displayplayers[0] != consoleplayer && ssplayer == 1
&& (cmd->forwardmove || cmd->sidemove || cmd->buttons)) && (cmd->forwardmove || cmd->sidemove || cmd->buttons))
{ {
@@ -1219,12 +1209,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
} }
} }
ticcmd_t *G_CopyTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) ticcmd_t *G_CopyTiccmd(ticcmd_t* restrict dest, const ticcmd_t* restrict src, const size_t n)
{ {
return M_Memcpy(dest, src, n*sizeof(*src)); return memcpy(dest, src, n*sizeof(*src));
} }
ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) ticcmd_t *G_MoveTiccmd(ticcmd_t* restrict dest, const ticcmd_t* restrict src, const size_t n)
{ {
size_t i; size_t i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
@@ -1261,7 +1251,7 @@ static void G_DoLoadLevel(boolean resetplayer)
if (gamestate == GS_INTERMISSION) if (gamestate == GS_INTERMISSION)
Y_EndIntermission(); Y_EndIntermission();
if (gamestate == GS_VOTING) else if (gamestate == GS_VOTING)
Y_EndVote(); Y_EndVote();
G_SetGamestate(GS_LEVEL); G_SetGamestate(GS_LEVEL);
@@ -2329,12 +2319,6 @@ void G_PlayerReborn(INT32 player)
if (gametype == GT_COOP) if (gametype == GT_COOP)
P_FindEmerald(); // scan for emeralds to hunt for P_FindEmerald(); // scan for emeralds to hunt for
// Reset Nights score and max link to 0 on death
p->maxlink = 0;
// If NiGHTS, find lowest mare to start with.
p->mare = 0;
} }
// //
@@ -2353,22 +2337,25 @@ static boolean G_CheckSpot(INT32 playernum, mapthing_t *mthing)
if (!mthing) if (!mthing)
return false; return false;
x = mthing->x << FRACBITS;
y = mthing->y << FRACBITS;
if (!players[playernum].mo) if (!players[playernum].mo)
{ {
// first spawn of level // first spawn of level
for (i = 0; i < playernum; i++) for (i = 0; i < playernum; i++)
{
if (playeringame[i] && players[i].mo if (playeringame[i] && players[i].mo
&& players[i].mo->x == mthing->x << FRACBITS && players[i].mo->x == x
&& players[i].mo->y == mthing->y << FRACBITS) && players[i].mo->y == y)
{ {
return false; return false;
} }
}
return true; return true;
} }
x = mthing->x << FRACBITS;
y = mthing->y << FRACBITS;
if (!K_CheckPlayersRespawnColliding(playernum, x, y)) if (!K_CheckPlayersRespawnColliding(playernum, x, y))
return false; return false;
@@ -2768,7 +2755,7 @@ INT32 G_GetGametypeByName(const char *gametypestr)
INT32 i; INT32 i;
for (i = 0; i < NUMGAMETYPES; i++) for (i = 0; i < NUMGAMETYPES; i++)
if (!stricmp(gametypestr, Gametype_Names[i])) if (fasticmp(gametypestr, Gametype_Names[i]))
return i; return i;
return -1; // unknown gametype return -1; // unknown gametype
@@ -2870,17 +2857,23 @@ UINT8 G_GetGametypeColor(INT16 gt)
*/ */
INT16 G_TOLFlag(INT32 pgametype) INT16 G_TOLFlag(INT32 pgametype)
{ {
if (!multiplayer) return TOL_SP; if (!multiplayer) return TOL_SP;
if (pgametype == GT_COOP) return TOL_RACE; // SRB2kart
if (pgametype == GT_COMPETITION) return TOL_COMPETITION; switch (pgametype)
if (pgametype == GT_RACE) return TOL_RACE; {
if (pgametype == GT_MATCH) return TOL_MATCH; case GT_COOP: return TOL_RACE; // SRB2kart
if (pgametype == GT_TEAMMATCH) return TOL_MATCH; case GT_COMPETITION: return TOL_COMPETITION;
if (pgametype == GT_TAG) return TOL_TAG; case GT_RACE: return TOL_RACE;
if (pgametype == GT_HIDEANDSEEK) return TOL_TAG; case GT_MATCH: return TOL_MATCH;
if (pgametype == GT_CTF) return TOL_CTF; case GT_TEAMMATCH: return TOL_MATCH;
case GT_TAG: return TOL_TAG;
case GT_HIDEANDSEEK: return TOL_TAG;
case GT_CTF: return TOL_CTF;
default:
CONS_Alert(CONS_ERROR, "Unknown gametype! %d\n", pgametype);
break;
}
CONS_Alert(CONS_ERROR, M_GetText("Unknown gametype! %d\n"), pgametype);
return INT16_MAX; return INT16_MAX;
} }
@@ -3063,6 +3056,7 @@ static void G_DoCompleted(void)
K_StatRound(); K_StatRound();
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i]) if (playeringame[i])
{ {
// SRB2Kart: exitlevel shouldn't get you the points // SRB2Kart: exitlevel shouldn't get you the points
@@ -3072,8 +3066,10 @@ static void G_DoCompleted(void)
if (P_IsLocalPlayer(&players[i])) if (P_IsLocalPlayer(&players[i]))
j++; j++;
} }
G_PlayerFinishLevel(i); // take away cards and stuff G_PlayerFinishLevel(i); // take away cards and stuff
} }
}
// play some generic music if there's no win/cool/lose music going on (for exitlevel commands) // play some generic music if there's no win/cool/lose music going on (for exitlevel commands)
if (G_RaceGametype() && ((multiplayer && demo.playback) || j == splitscreen+1) && (cv_inttime.value > 0)) if (G_RaceGametype() && ((multiplayer && demo.playback) || j == splitscreen+1) && (cv_inttime.value > 0))
@@ -3217,10 +3213,14 @@ void G_AfterIntermission(void)
return; return;
} }
else if (demo.recording && (modeattacking || demo.savemode != DSM_NOTSAVING))
G_SaveDemo(); if (demo.recording)
else if (demo.recording) {
G_ResetDemoRecording(); if (modeattacking || demo.savemode != DSM_NOTSAVING)
G_SaveDemo();
else
G_ResetDemoRecording();
}
if (modeattacking) // End the run. if (modeattacking) // End the run.
{ {
@@ -3229,7 +3229,9 @@ void G_AfterIntermission(void)
} }
if (mapheaderinfo[gamemap-1]->cutscenenum) // Start a custom cutscene. if (mapheaderinfo[gamemap-1]->cutscenenum) // Start a custom cutscene.
{
F_StartCustomCutscene(mapheaderinfo[gamemap-1]->cutscenenum-1, false, false); F_StartCustomCutscene(mapheaderinfo[gamemap-1]->cutscenenum-1, false, false);
}
else else
{ {
if (nextmap < 1100-1) if (nextmap < 1100-1)
@@ -3366,10 +3368,13 @@ static void G_DoContinued(void)
// when something new is added. // when something new is added.
void G_EndGame(void) void G_EndGame(void)
{ {
if (demo.recording && (modeattacking || demo.savemode != DSM_NOTSAVING)) if (demo.recording)
G_SaveDemo(); {
else if (demo.recording) if (modeattacking || demo.savemode != DSM_NOTSAVING)
G_ResetDemoRecording(); G_SaveDemo();
else
G_ResetDemoRecording();
}
// Only do evaluation and credits in coop games. // Only do evaluation and credits in coop games.
if (gametype == GT_COOP) if (gametype == GT_COOP)
@@ -3379,6 +3384,7 @@ void G_EndGame(void)
F_StartCredits(); F_StartCredits();
return; return;
} }
if (nextmap == 1101-1) // end game with evaluation if (nextmap == 1101-1) // end game with evaluation
{ {
F_StartGameEvaluation(); F_StartGameEvaluation();
@@ -3463,7 +3469,8 @@ void G_LoadGameData(void)
if (READUINT32(save.p) != 0xFCAFE211) if (READUINT32(save.p) != 0xFCAFE211)
{ {
const char *gdfolder = "the SRB2Kart folder"; const char *gdfolder = "the SRB2Kart folder";
if (strcmp(srb2home,"."))
if (!fastcmp(srb2home,"."))
gdfolder = srb2home; gdfolder = srb2home;
Z_Free(save.buffer); Z_Free(save.buffer);
@@ -3477,9 +3484,8 @@ void G_LoadGameData(void)
modded = READUINT8(save.p); modded = READUINT8(save.p);
// Aha! Someone's been screwing with the save file! // Aha! Someone's been screwing with the save file!
if ((modded && !savemoddata)) if ((modded && !savemoddata) ||
goto datacorrupt; (modded != true && modded != false))
else if (modded != true && modded != false)
goto datacorrupt; goto datacorrupt;
// TODO put another cipher on these things? meh, I don't care... // TODO put another cipher on these things? meh, I don't care...
@@ -3544,10 +3550,11 @@ void G_LoadGameData(void)
return; return;
// Landing point for corrupt gamedata // Landing point for corrupt gamedata
datacorrupt: datacorrupt:
{ {
const char *gdfolder = "the SRB2Kart folder"; const char *gdfolder = "the SRB2Kart folder";
if (strcmp(srb2home,"."))
if (!fastcmp(srb2home,"."))
gdfolder = srb2home; gdfolder = srb2home;
Z_Free(save.buffer); Z_Free(save.buffer);
@@ -3758,7 +3765,8 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride)
memset(vcheck, 0, sizeof (vcheck)); memset(vcheck, 0, sizeof (vcheck));
sprintf(vcheck, "version %d", VERSION); sprintf(vcheck, "version %d", VERSION);
if (strcmp((const char *)save.p, (const char *)vcheck))
if (!fastcmp((const char *)save.p, (const char *)vcheck))
{ {
#ifdef SAVEGAME_OTHERVERSIONS #ifdef SAVEGAME_OTHERVERSIONS
M_StartMessage(M_GetText("Save game from different version.\nYou can load this savegame, but\nsaving afterwards will be disabled.\n\nDo you want to continue anyway?\n\n(Press 'Y' to confirm)\n"), M_StartMessage(M_GetText("Save game from different version.\nYou can load this savegame, but\nsaving afterwards will be disabled.\n\nDo you want to continue anyway?\n\n(Press 'Y' to confirm)\n"),
@@ -4036,7 +4044,7 @@ char *G_BuildMapTitle(INT32 mapnum)
if (!mapheaderinfo[mapnum-1]) if (!mapheaderinfo[mapnum-1])
P_AllocMapHeader(mapnum-1); P_AllocMapHeader(mapnum-1);
if (strcmp(mapheaderinfo[mapnum-1]->lvlttl, "")) if (!fastcmp(mapheaderinfo[mapnum-1]->lvlttl, ""))
{ {
size_t len = 1; size_t len = 1;
const char *zonetext = NULL; const char *zonetext = NULL;
@@ -4263,18 +4271,21 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep)
{ {
if (mapname[0] == '*') // current map if (mapname[0] == '*') // current map
return gamemap; return gamemap;
else if (mapname[0] == '?' && mapheaderinfo[gamemap-1])
if (mapname[0] == '?' && mapheaderinfo[gamemap-1])
return G_RandMap(G_TOLFlag(gametype), gamemap-1, false, 0, false, NULL)+1; return G_RandMap(G_TOLFlag(gametype), gamemap-1, false, 0, false, NULL)+1;
else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map
if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map
{ {
newmapnum = mapheaderinfo[gamemap-1]->nextlevel; newmapnum = mapheaderinfo[gamemap-1]->nextlevel;
if (newmapnum < 1 || newmapnum > NUMMAPS) if (newmapnum < 1 || newmapnum > NUMMAPS)
{ {
CONS_Alert(CONS_ERROR, M_GetText("NextLevel (%d) is not a valid map.\n"), newmapnum); CONS_Alert(CONS_ERROR, "NextLevel (%d) is not a valid map.\n", newmapnum);
return 0; return 0;
} }
else
return newmapnum; return newmapnum;
} }
} }
else if (mapnamelen == 2)/* maybe two digit code */ else if (mapnamelen == 2)/* maybe two digit code */
+4 -6
View File
@@ -262,9 +262,6 @@ void G_ResetControls(void)
memset(joyxmove, 0, sizeof(joyxmove)); memset(joyxmove, 0, sizeof(joyxmove));
memset(joyymove, 0, sizeof(joyymove)); memset(joyymove, 0, sizeof(joyymove));
// reset those just in case the game missed the keyup event
memset(dpadscrollstate, false, sizeof(dpadscrollstate));
} }
// //
@@ -1033,7 +1030,7 @@ INT32 G_KeyStringtoNum(const char *keystr)
return atoi(&keystr[3]); return atoi(&keystr[3]);
for (j = 0; j < NUMKEYNAMES; j++) for (j = 0; j < NUMKEYNAMES; j++)
if (!stricmp(keynames[j].name, keystr)) if (fasticmp(keynames[j].name, keystr))
return keynames[j].keynum; return keynames[j].keynum;
return 0; return 0;
@@ -1333,14 +1330,15 @@ static void setcontrol(INT32 (*gc)[2])
player = 0; player = 0;
namectrl = COM_Argv(1); namectrl = COM_Argv(1);
for (numctrl = 0; numctrl < num_gamecontrols && stricmp(namectrl, gamecontrolname[numctrl]); for (numctrl = 0; numctrl < num_gamecontrols && !fasticmp(namectrl, gamecontrolname[numctrl]); numctrl++)
numctrl++)
; ;
if (numctrl == num_gamecontrols) if (numctrl == num_gamecontrols)
{ {
CONS_Printf(M_GetText("Control '%s' unknown\n"), namectrl); CONS_Printf(M_GetText("Control '%s' unknown\n"), namectrl);
return; return;
} }
keynum1 = G_KeyStringtoNum(COM_Argv(2)); keynum1 = G_KeyStringtoNum(COM_Argv(2));
keynum2 = G_KeyStringtoNum(COM_Argv(3)); keynum2 = G_KeyStringtoNum(COM_Argv(3));
keynum = G_FilterKeyByVersion(numctrl, 0, player, &keynum1, &keynum2, &nestedoverride); keynum = G_FilterKeyByVersion(numctrl, 0, player, &keynum1, &keynum2, &nestedoverride);
+1 -1
View File
@@ -37,7 +37,7 @@ typedef enum
KEY_JOY1 = KEY_MOUSE1 + MOUSEBUTTONS, KEY_JOY1 = KEY_MOUSE1 + MOUSEBUTTONS,
KEY_HAT1 = KEY_JOY1 + JOYBUTTONS, KEY_HAT1 = KEY_JOY1 + JOYBUTTONS,
KEY_DBLMOUSE1 =KEY_HAT1 + JOYHATS*4, // double clicks KEY_DBLMOUSE1 = KEY_HAT1 + JOYHATS*4, // double clicks
KEY_DBLJOY1 = KEY_DBLMOUSE1 + MOUSEBUTTONS, KEY_DBLJOY1 = KEY_DBLMOUSE1 + MOUSEBUTTONS,
KEY_DBLHAT1 = KEY_DBLJOY1 + JOYBUTTONS, KEY_DBLHAT1 = KEY_DBLJOY1 + JOYBUTTONS,
+1 -104
View File
@@ -80,14 +80,6 @@ static poly_t *HWR_AllocPoly(INT32 numpts)
return p; return p;
} }
static polyvertex_t *HWR_AllocVertex(void)
{
polyvertex_t *p;
size_t size = sizeof(polyvertex_t);
p = Z_Malloc(size, PU_HWRPLANE, NULL);
return p;
}
/// \todo polygons should be freed in reverse order for efficiency, /// \todo polygons should be freed in reverse order for efficiency,
/// for now don't free because it doesn't free in reverse order /// for now don't free because it doesn't free in reverse order
static void HWR_FreePoly(poly_t *poly) static void HWR_FreePoly(poly_t *poly)
@@ -637,7 +629,7 @@ static void WalkBSPNode(INT32 bspnum, poly_t *poly, UINT16 *leafnode, fixed_t *b
WalkBSPNode(bsp->children[0], frontpoly, &bsp->children[0],bsp->bbox[0]); WalkBSPNode(bsp->children[0], frontpoly, &bsp->children[0],bsp->bbox[0]);
// copy child bbox // copy child bbox
M_Memcpy(bbox, bsp->bbox[0], 4*sizeof (fixed_t)); memcpy(bbox, bsp->bbox[0], 4*sizeof (fixed_t));
} }
else else
I_Error("WalkBSPNode: no front poly?"); I_Error("WalkBSPNode: no front poly?");
@@ -855,100 +847,6 @@ static INT32 SolveTProblem(void)
return numsplitpoly; return numsplitpoly;
} }
#define NEARDIST (0.75f)
#define MYMAX (10000000000000.0f)
/* Adjust true segs (from the segs lump) to be exactely the same as
* plane polygone segs
* This also convert fixed_t point of segs in float (in moste case
* it share the same vertice
*/
static void AdjustSegs(void)
{
size_t i, count;
INT32 j;
seg_t *lseg;
poly_t *p;
INT32 v1found = 0, v2found = 0;
float nearv1, nearv2;
for (i = 0; i < numsubsectors; i++)
{
count = subsectors[i].numlines;
lseg = &segs[subsectors[i].firstline];
p = extrasubsectors[i].planepoly;
if (!p)
continue;
for (; count--; lseg++)
{
float distv1,distv2,tmp;
nearv1 = nearv2 = MYMAX;
// Don't touch polyobject segs. We'll compensate
// for this when we go about drawing them.
if (lseg->polyseg)
continue;
for (j = 0; j < p->numpts; j++)
{
distv1 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v1->x);
tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v1->y);
distv1 = distv1*distv1+tmp*tmp;
if (distv1 <= nearv1)
{
v1found = j;
nearv1 = distv1;
}
// the same with v2
distv2 = p->pts[j].x - FIXED_TO_FLOAT(lseg->v2->x);
tmp = p->pts[j].y - FIXED_TO_FLOAT(lseg->v2->y);
distv2 = distv2*distv2+tmp*tmp;
if (distv2 <= nearv2)
{
v2found = j;
nearv2 = distv2;
}
}
if (nearv1 <= NEARDIST*NEARDIST)
// share vertice with segs
lseg->pv1 = &(p->pts[v1found]);
else
{
// BP: here we can do better, using PointInSeg and compute
// the right point position also split a polygone side to
// solve a T-intersection, but too mush work
// convert fixed vertex to float vertex
polyvertex_t *pv = HWR_AllocVertex();
pv->x = FIXED_TO_FLOAT(lseg->v1->x);
pv->y = FIXED_TO_FLOAT(lseg->v1->y);
lseg->pv1 = pv;
}
if (nearv2 <= NEARDIST*NEARDIST)
lseg->pv2 = &(p->pts[v2found]);
else
{
polyvertex_t *pv = HWR_AllocVertex();
pv->x = FIXED_TO_FLOAT(lseg->v2->x);
pv->y = FIXED_TO_FLOAT(lseg->v2->y);
lseg->pv2 = pv;
}
lseg->pv1->x2 = FloatToFixed(lseg->pv1->x);
lseg->pv1->y2 = FloatToFixed(lseg->pv1->y);
lseg->pv2->x2 = FloatToFixed(lseg->pv2->x);
lseg->pv2->y2 = FloatToFixed(lseg->pv2->y);
}
}
}
// call this routine after the BSP of a Doom wad file is loaded, // call this routine after the BSP of a Doom wad file is loaded,
// and it will generate all the convex polys for the hardware renderer // and it will generate all the convex polys for the hardware renderer
@@ -1017,7 +915,6 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
#else #else
SolveTProblem(); SolveTProblem();
#endif #endif
AdjustSegs();
#ifdef DEBUG_HWBSP #ifdef DEBUG_HWBSP
//debug debug.. //debug debug..
+13 -4
View File
@@ -346,7 +346,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe
gltex->mipmap.colormap = Z_Calloc(sizeof(*gltex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL); gltex->mipmap.colormap = Z_Calloc(sizeof(*gltex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL);
gltex->mipmap.colormap->source = colormap; gltex->mipmap.colormap->source = colormap;
M_Memcpy(gltex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8)); memcpy(gltex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8));
blockwidth = texture->width; blockwidth = texture->width;
blockheight = texture->height; blockheight = texture->height;
@@ -818,11 +818,20 @@ void HWR_PrecacheLevel(void)
// Precache flats. // Precache flats.
HWR_PrecacheLevelFlats(); HWR_PrecacheLevelFlats();
// prevent timeouts
NetKeepAlive();
// Precache textures. // Precache textures.
HWR_PrecacheLevelTextures(); HWR_PrecacheLevelTextures();
// prevent timeouts
NetKeepAlive();
// Precache sprites. // Precache sprites.
//HWR_PrecacheLevelSprites(); //HWR_PrecacheLevelSprites();
// prevent timeouts
//NetKeepAlive();
} }
void HWR_LoadMapTextures(size_t pnumtextures) void HWR_LoadMapTextures(size_t pnumtextures)
@@ -970,7 +979,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
#endif #endif
glMipmap->colormap = Z_Calloc(sizeof(*glMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); glMipmap->colormap = Z_Calloc(sizeof(*glMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
glMipmap->colormap->source = colormap; glMipmap->colormap->source = colormap;
M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
} }
if (!glMipmap->downloaded) if (!glMipmap->downloaded)
@@ -1068,7 +1077,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
{ {
if (memcmp(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8))) if (memcmp(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)))
{ {
M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
HWR_UpdatePatchMipmap(patch, glMipmap); HWR_UpdatePatchMipmap(patch, glMipmap);
} }
else else
@@ -1091,7 +1100,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
newMipmap->colormap->source = colormap; newMipmap->colormap->source = colormap;
M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
HWR_LoadPatchMipmap(patch, newMipmap); HWR_LoadPatchMipmap(patch, newMipmap);
} }
+6 -7
View File
@@ -80,14 +80,13 @@
typedef struct clipnode_s typedef struct clipnode_s
{ {
struct clipnode_s *prev, *next; struct clipnode_s *prev, *next;
angle_t start, end; angle_t start, end;
} clipnode_t; } clipnode_t;
clipnode_t *freelist; static clipnode_t *freelist;
clipnode_t *clipnodes; static clipnode_t *cliphead;
clipnode_t *cliphead;
static clipnode_t * gld_clipnode_GetNew(void); static clipnode_t * gld_clipnode_GetNew(void);
static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end); static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end);
+1 -1
View File
@@ -117,7 +117,7 @@ typedef struct
typedef struct typedef struct
{ {
FLOAT x,y,z; // position FLOAT x, y, z; // position
FLOAT anglex, angley, anglez; // aimingangle / viewangle FLOAT anglex, angley, anglez; // aimingangle / viewangle
FLOAT scalex, scaley, scalez; FLOAT scalex, scaley, scalez;
FLOAT fovangle; FLOAT fovangle;
+55 -108
View File
@@ -75,19 +75,19 @@ boolean gl_drawing_stencil = false;
static INT32 current_bsp_culling_distance = 0; static INT32 current_bsp_culling_distance = 0;
FTransform atransform; FTransform atransform = {};
// Float variants of viewx, viewy, viewz, etc. // Float variants of viewx, viewy, viewz, etc.
static float gl_viewx, gl_viewy, gl_viewz; static float gl_viewx, gl_viewy, gl_viewz;
float gl_viewsin, gl_viewcos; float gl_viewsin = 0.0f, gl_viewcos = 0.0f;
static float gl_viewludsin, gl_viewludcos; static float gl_viewludsin, gl_viewludcos;
static angle_t gl_aimingangle; static angle_t gl_aimingangle;
seg_t *gl_curline; seg_t *gl_curline = NULL;
side_t *gl_sidedef; side_t *gl_sidedef = NULL;
line_t *gl_linedef; line_t *gl_linedef = NULL;
sector_t *gl_frontsector; sector_t *gl_frontsector = NULL;
sector_t *gl_backsector; sector_t *gl_backsector = NULL;
// values for the far clipping plane // values for the far clipping plane
static constexpr float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; static constexpr float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f};
@@ -458,8 +458,8 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col
// in palette rendering mode, this is not needed since it properly takes the changes to the palette itself // in palette rendering mode, this is not needed since it properly takes the changes to the palette itself
if (!HWR_ShouldUsePaletteRendering()) if (!HWR_ShouldUsePaletteRendering())
{ {
V_CubeApply(&tint_color.s.red, &tint_color.s.green, &tint_color.s.blue); V_CubeApply(&tint_color);
V_CubeApply(&fade_color.s.red, &fade_color.s.green, &fade_color.s.blue); V_CubeApply(&fade_color);
} }
Surface->PolyColor.rgba = poly_color.rgba; Surface->PolyColor.rgba = poly_color.rgba;
@@ -728,6 +728,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
for (i = 0; i < subsector->numlines; i++, line++) for (i = 0; i < subsector->numlines; i++, line++)
{ {
if (line->polyseg)
continue;
line_t* ld = line->linedef; line_t* ld = line->linedef;
// this check sucks and is a hotspot lel // this check sucks and is a hotspot lel
@@ -740,27 +743,11 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
P_ClosestPointOnLine(viewx, viewy, ld, &v); P_ClosestPointOnLine(viewx, viewy, ld, &v);
dist = FixedToFloat(R_PointToDist(v.x, v.y)); dist = FixedToFloat(R_PointToDist(v.x, v.y));
if (line->pv1) x1 = (line->fv1.x);
{ y1 = (line->fv1.y);
x1 = line->pv1->x;
y1 = line->pv1->y;
}
else
{
x1 = FixedToFloat(line->v1->x);
y1 = FixedToFloat(line->v1->y);
}
if (line->pv2) xd = (line->fv2.x) - x1;
{ yd = (line->fv2.y) - y1;
xd = line->pv2->x - x1;
yd = line->pv2->y - y1;
}
else
{
xd = FixedToFloat(line->v2->x) - x1;
yd = FixedToFloat(line->v2->y) - y1;
}
// Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion // Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion
dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f; dist = sqrtf((xd*xd) + (yd*yd)) / dist / 16.0f;
@@ -824,11 +811,11 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
M_ClearBox(segbbox); M_ClearBox(segbbox);
M_AddToBox(segbbox, M_AddToBox(segbbox,
FloatToFixed(gl_curline->pv1->x), FloatToFixed(gl_curline->fv1.x),
FloatToFixed(gl_curline->pv1->y)); FloatToFixed(gl_curline->fv1.y));
M_AddToBox(segbbox, M_AddToBox(segbbox,
FloatToFixed(gl_curline->pv2->x), FloatToFixed(gl_curline->fv2.x),
FloatToFixed(gl_curline->pv2->y)); FloatToFixed(gl_curline->fv2.y));
splat = (wallsplat_t *)gl_curline->linedef->splats; splat = (wallsplat_t *)gl_curline->linedef->splats;
for (; splat; splat = splat->next) for (; splat; splat = splat->next)
@@ -1237,7 +1224,7 @@ static void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf)
// Returns true if the midtexture is visible, and false if... it isn't... // Returns true if the midtexture is visible, and false if... it isn't...
static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf)
{ {
FUINT blendmode = PF_Masked; FUINT blendmode = PF_Masked | PF_Translucent;
pSurf->PolyColor.s.alpha = 0xFF; pSurf->PolyColor.s.alpha = 0xFF;
@@ -1259,8 +1246,6 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf)
case 256: case 256:
if (gl_linedef->blendmode) if (gl_linedef->blendmode)
blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf); blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf);
else
blendmode = PF_Translucent;
break; break;
default: default:
if (gl_linedef->blendmode) if (gl_linedef->blendmode)
@@ -1272,8 +1257,6 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf)
} }
else if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) else if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT)
blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), pSurf); blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), pSurf);
else
blendmode = PF_Masked;
break; break;
} }
} }
@@ -1323,34 +1306,24 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
const boolean noencore = (gl_linedef->flags & ML_TFERLINE); const boolean noencore = (gl_linedef->flags & ML_TFERLINE);
if (LIKELY(gl_curline->pv1)) v1x = gl_curline->v1->x;
{ v1y = gl_curline->v1->y;
vs.x = gl_curline->pv1->x; v2x = gl_curline->v2->x;
vs.y = gl_curline->pv1->y; v2y = gl_curline->v2->y;
v1x = gl_curline->pv1->x2;
v1y = gl_curline->pv1->y2;
}
else
{
vs.x = FixedToFloat(gl_curline->v1->x);
vs.y = FixedToFloat(gl_curline->v1->y);
v1x = gl_curline->v1->x;
v1y = gl_curline->v1->y;
}
if (LIKELY(gl_curline->pv2)) if (gl_curline->polyseg)
{ {
ve.x = gl_curline->pv2->x; vs.x = FixedToFloat(v1x);
ve.y = gl_curline->pv2->y; vs.y = FixedToFloat(v1y);
v2x = gl_curline->pv2->x2; ve.x = FixedToFloat(v2x);
v2y = gl_curline->pv2->y2; ve.y = FixedToFloat(v2y);
} }
else else
{ {
ve.x = FixedToFloat(gl_curline->v2->x); vs.x = gl_curline->fv1.x;
ve.y = FixedToFloat(gl_curline->v2->y); vs.y = gl_curline->fv1.y;
v2x = gl_curline->v2->x; ve.x = gl_curline->fv2.x;
v2y = gl_curline->v2->y; ve.y = gl_curline->fv2.y;
} }
#define SLOPEPARAMS(slope, end1, end2, normalheight) \ #define SLOPEPARAMS(slope, end1, end2, normalheight) \
@@ -2202,27 +2175,11 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector)
{ {
fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t
if (LIKELY(gl_curline->pv1)) v1x = gl_curline->v1->x;
{ v1y = gl_curline->v1->y;
v1x = gl_curline->pv1->x2;
v1y = gl_curline->pv1->y2;
}
else
{
v1x = gl_curline->v1->x;
v1y = gl_curline->v1->y;
}
if (LIKELY(gl_curline->pv2)) v2x = gl_curline->v2->x;
{ v2y = gl_curline->v2->y;
v2x = gl_curline->pv2->x2;
v2y = gl_curline->pv2->y2;
}
else
{
v2x = gl_curline->v2->x;
v2y = gl_curline->v2->y;
}
#define SLOPEPARAMS(slope, end1, end2, normalheight) \ #define SLOPEPARAMS(slope, end1, end2, normalheight) \
end1 = P_GetZAt(slope, v1x, v1y, normalheight); \ end1 = P_GetZAt(slope, v1x, v1y, normalheight); \
@@ -2427,27 +2384,11 @@ static void HWR_AddLine(seg_t *line)
gl_curline = line; gl_curline = line;
if (LIKELY(gl_curline->pv1)) v1x = gl_curline->v1->x;
{ v1y = gl_curline->v1->y;
v1x = gl_curline->pv1->x2;
v1y = gl_curline->pv1->y2;
}
else
{
v1x = gl_curline->v1->x;
v1y = gl_curline->v1->y;
}
if (LIKELY(gl_curline->pv2)) v2x = gl_curline->v2->x;
{ v2y = gl_curline->v2->y;
v2x = gl_curline->pv2->x2;
v2y = gl_curline->pv2->y2;
}
else
{
v2x = gl_curline->v2->x;
v2y = gl_curline->v2->y;
}
// OPTIMIZE: quickly reject orthogonal back sides. // OPTIMIZE: quickly reject orthogonal back sides.
angle1 = R_PointToAngle64(v1x, v1y); angle1 = R_PointToAngle64(v1x, v1y);
@@ -3533,7 +3474,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
// This is expecting a pointer to an array containing 4 wallVerts for a sprite // This is expecting a pointer to an array containing 4 wallVerts for a sprite
static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts, const boolean precip, const boolean papersprite) static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts, const boolean precip, const boolean papersprite)
{ {
if (!cv_glspritebillboarding.value || papersprite) if (!cv_glspritebillboarding.value || cv_glshearing.value || papersprite)
{ {
return; return;
} }
@@ -4280,8 +4221,8 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I
{ {
wallinfo_t *wallinfo = static_cast<wallinfo_t*>(HWR_CreateDrawNode(DRAWNODE_WALL)); wallinfo_t *wallinfo = static_cast<wallinfo_t*>(HWR_CreateDrawNode(DRAWNODE_WALL));
M_Memcpy(wallinfo->wallVerts, wallVerts, sizeof (wallinfo->wallVerts)); memcpy(wallinfo->wallVerts, wallVerts, sizeof (wallinfo->wallVerts));
M_Memcpy(&wallinfo->Surf, pSurf, sizeof (FSurfaceInfo)); memcpy(&wallinfo->Surf, pSurf, sizeof (FSurfaceInfo));
wallinfo->texnum = texnum; wallinfo->texnum = texnum;
wallinfo->noencore = noencore; wallinfo->noencore = noencore;
wallinfo->blend = blend; wallinfo->blend = blend;
@@ -5369,8 +5310,12 @@ void HWR_SetTransform(float fpov)
HWR_SetTransformAiming(&atransform); HWR_SetTransformAiming(&atransform);
atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(FINEDEGREE); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(FINEDEGREE);
gl_viewludsin = FixedToFloat(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT)); // only needed for sprite billboarding
gl_viewludcos = FixedToFloat(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT)); if (cv_glspritebillboarding.value && !cv_glshearing.value)
{
gl_viewludsin = FixedToFloat(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT));
gl_viewludcos = FixedToFloat(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT));
}
atransform.fovangle = fpov; // Tails atransform.fovangle = fpov; // Tails
HWR_RollTransform(&atransform, viewroll); HWR_RollTransform(&atransform, viewroll);
@@ -5386,7 +5331,9 @@ void HWR_SetTransform(float fpov)
atransform.fliptype = TRANSFORM_FLIP; atransform.fliptype = TRANSFORM_FLIP;
} }
else if (postimg & POSTIMG_MIRROR) else if (postimg & POSTIMG_MIRROR)
{
atransform.fliptype = TRANSFORM_MIRROR; atransform.fliptype = TRANSFORM_MIRROR;
}
// Set transform. // Set transform.
GL_SetTransform(&atransform); GL_SetTransform(&atransform);
@@ -5840,7 +5787,7 @@ static void COM_HWR_glinfo(void)
{ {
argv = COM_Argv(i); argv = COM_Argv(i);
if (strcmp(argv, "--list-extensions") == 0 || strcmp(argv, "-l") == 0) if (fastcmp(argv, "--list-extensions")|| fastcmp(argv, "-l"))
{ {
list_extensions = 1; list_extensions = 1;
} }
@@ -5962,7 +5909,7 @@ static void HWR_DoPostProcessor(player_t *player)
Surf.PolyColor.s.alpha = 0xc0; // match software mode Surf.PolyColor.s.alpha = 0xc0; // match software mode
V_CubeApply(&Surf.PolyColor.s.red, &Surf.PolyColor.s.green, &Surf.PolyColor.s.blue); V_CubeApply(&Surf.PolyColor);
GL_DrawPolygon(&Surf, v, 4, PF_Modulated|PF_Translucent|PF_NoTexture|PF_NoDepthTest); GL_DrawPolygon(&Surf, v, 4, PF_Modulated|PF_Translucent|PF_NoTexture|PF_NoDepthTest);
} }
+13 -12
View File
@@ -72,10 +72,9 @@
#include <errno.h> #include <errno.h>
#endif #endif
md2_t md2_models[NUMSPRITES]; md2_t md2_models[NUMSPRITES] = {};
md2_t md2_playermodels[MAXSKINS]; md2_t md2_playermodels[MAXSKINS] = {};
md2_t md2_localplayermodels[MAXLOCALSKINS]; md2_t md2_localplayermodels[MAXLOCALSKINS] = {};
/* /*
* free model * free model
@@ -417,7 +416,7 @@ static void md2_loadTexture(md2_t *model)
size = w*h; size = w*h;
while (size--) while (size--)
{ {
V_CubeApply(&image->s.red, &image->s.green, &image->s.blue); V_CubeApply(image);
image++; image++;
} }
} }
@@ -549,7 +548,7 @@ void HWR_InitMD2(void)
{ {
for (i = 0; i < NUMSPRITES; i++) for (i = 0; i < NUMSPRITES; i++)
{ {
if (stricmp(name, sprnames[i]) == 0) if (fasticmp(name, sprnames[i]))
{ {
md2_models[i].scale = scale; md2_models[i].scale = scale;
md2_models[i].offset = offset; md2_models[i].offset = offset;
@@ -561,7 +560,7 @@ void HWR_InitMD2(void)
for (s = 0; s < MAXSKINS; s++) for (s = 0; s < MAXSKINS; s++)
{ {
if (stricmp(name, skins[s].name) == 0) if (fasticmp(name, skins[s].name))
{ {
md2_playermodels[s].skin = s; md2_playermodels[s].skin = s;
md2_playermodels[s].scale = scale; md2_playermodels[s].scale = scale;
@@ -607,11 +606,12 @@ void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added afte
} }
} }
md2s = ( (local) ? md2_localplayermodels : md2_playermodels ); md2s = (local ? md2_localplayermodels : md2_playermodels);
// Check for any MD2s that match the names of player skins! // Check for any MD2s that match the names of player skins!
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
{ {
if (stricmp(name, K_GetSkinArray(local)[skin].name) == 0) if (fasticmp(name, K_GetSkinArray(local)[skin].name))
{ {
md2s[skin].skin = skin; md2s[skin].skin = skin;
md2s[skin].scale = scale; md2s[skin].scale = scale;
@@ -650,6 +650,7 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu
if (!f) if (!f)
{ {
f = fopen(va("%s"PATHSEP"%s", srb2path, "mdls.dat"), "rt"); f = fopen(va("%s"PATHSEP"%s", srb2path, "mdls.dat"), "rt");
if (!f) if (!f)
{ {
CONS_Printf("%s %s\n", M_GetText("Error while loading mdls.dat:"), strerror(errno)); CONS_Printf("%s %s\n", M_GetText("Error while loading mdls.dat:"), strerror(errno));
@@ -661,7 +662,7 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu
// Check for any MD2s that match the names of sprite names! // Check for any MD2s that match the names of sprite names!
while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4)
{ {
if (stricmp(name, sprnames[spritenum]) == 0) if (fasticmp(name, sprnames[spritenum]))
{ {
md2_models[spritenum].scale = scale; md2_models[spritenum].scale = scale;
md2_models[spritenum].offset = offset; md2_models[spritenum].offset = offset;
@@ -1056,7 +1057,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk
{ {
if (memcmp(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8))) if (memcmp(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)))
{ {
M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
HWR_CreateBlendedTexture(patch, blendgpatch, glMipmap, skinnum, color); HWR_CreateBlendedTexture(patch, blendgpatch, glMipmap, skinnum, color);
GL_UpdateTexture(glMipmap); GL_UpdateTexture(glMipmap);
} }
@@ -1083,7 +1084,7 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk
newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL); newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
newMipmap->colormap->source = colormap; newMipmap->colormap->source = colormap;
M_Memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8)); memcpy(newMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
HWR_CreateBlendedTexture(patch, blendgpatch, newMipmap, skinnum, color); HWR_CreateBlendedTexture(patch, blendgpatch, newMipmap, skinnum, color);
+10 -10
View File
@@ -126,7 +126,7 @@ tag_t *GetTagByName(model_t *model, char *name, int frame)
int i; int i;
for (i = 0; i < model->numTags; i++) for (i = 0; i < model->numTags; i++)
{ {
if (!stricmp(iterator[i].name, name)) if (fasticmp(iterator[i].name, name))
return &iterator[i]; return &iterator[i];
} }
} }
@@ -163,22 +163,22 @@ model_t *LoadModel(const char *filename, int ztag)
return NULL; return NULL;
} }
if (!strcmp(extension, ".md3")) if (fastcmp(extension, ".md3"))
{ {
if (!(model = MD3_LoadModel(filename, ztag, false))) if (!(model = MD3_LoadModel(filename, ztag, false)))
return NULL; return NULL;
} }
else if (!strcmp(extension, ".md3s")) // MD3 that will be converted in memory to use full floats else if (fastcmp(extension, ".md3s")) // MD3 that will be converted in memory to use full floats
{ {
if (!(model = MD3_LoadModel(filename, ztag, true))) if (!(model = MD3_LoadModel(filename, ztag, true)))
return NULL; return NULL;
} }
else if (!strcmp(extension, ".md2")) else if (fastcmp(extension, ".md2"))
{ {
if (!(model = MD2_LoadModel(filename, ztag, false))) if (!(model = MD2_LoadModel(filename, ztag, false)))
return NULL; return NULL;
} }
else if (!strcmp(extension, ".md2s")) else if (fastcmp(extension, ".md2s"))
{ {
if (!(model = MD2_LoadModel(filename, ztag, true))) if (!(model = MD2_LoadModel(filename, ztag, true)))
return NULL; return NULL;
@@ -242,7 +242,7 @@ void GenerateVertexNormals(model_t *model)
float *vertPtr = frame->vertices; float *vertPtr = frame->vertices;
float *oldNormals; float *oldNormals;
M_Memcpy(newNormals, frame->normals, sizeof(float)*3*mesh->numTriangles*3); memcpy(newNormals, frame->normals, sizeof(float)*3*mesh->numTriangles*3);
for (k = 0; k < mesh->numVertices; k++) for (k = 0; k < mesh->numVertices; k++)
{ {
@@ -402,7 +402,7 @@ void Optimize(model_t *model)
char *destByte; char *destByte;
char *srcByte; char *srcByte;
M_Memcpy(&newMesh->uvs[uvCount], memcpy(&newMesh->uvs[uvCount],
curMesh->uvs, curMesh->uvs,
sizeof(float)*2*curMesh->numTriangles*3); sizeof(float)*2*curMesh->numTriangles*3);
@@ -410,13 +410,13 @@ void Optimize(model_t *model)
dest = (float*)newMesh->frames[0].vertices; dest = (float*)newMesh->frames[0].vertices;
src = (float*)curMesh->frames[0].vertices; src = (float*)curMesh->frames[0].vertices;
M_Memcpy(&dest[vertCount], memcpy(&dest[vertCount],
src, src,
sizeof(float)*3*curMesh->numTriangles*3); sizeof(float)*3*curMesh->numTriangles*3);
dest = (float*)newMesh->frames[0].normals; dest = (float*)newMesh->frames[0].normals;
src = (float*)curMesh->frames[0].normals; src = (float*)curMesh->frames[0].normals;
M_Memcpy(&dest[vertCount], memcpy(&dest[vertCount],
src, src,
sizeof(float)*3*curMesh->numTriangles*3); sizeof(float)*3*curMesh->numTriangles*3);
@@ -427,7 +427,7 @@ void Optimize(model_t *model)
if (srcByte) if (srcByte)
{ {
M_Memcpy(&destByte[colorCount], memcpy(&destByte[colorCount],
srcByte, srcByte,
sizeof(char)*4*curMesh->numTriangles*3); sizeof(char)*4*curMesh->numTriangles*3);
} }
+3 -1
View File
@@ -30,7 +30,7 @@
SINT8 gl_portal_state = GLPORTAL_OFF; SINT8 gl_portal_state = GLPORTAL_OFF;
gl_portallist_t *currentportallist; gl_portallist_t *currentportallist = NULL;
// clip the area outside the portal destination window // clip the area outside the portal destination window
void HWR_PortalClipping(gl_portal_t *portal) void HWR_PortalClipping(gl_portal_t *portal)
@@ -168,8 +168,10 @@ void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float
// go to portal frame lmao // go to portal frame lmao
HWR_PortalFrame(portal); HWR_PortalFrame(portal);
// call HWR_RenderViewpoint // call HWR_RenderViewpoint
HWR_RenderPortalViewpoint(portal, player, stencil_level + 1, true); HWR_RenderPortalViewpoint(portal, player, stencil_level + 1, true);
// return to current frame // return to current frame
if (rootportal) if (rootportal)
HWR_PortalFrame(rootportal); HWR_PortalFrame(rootportal);
+8 -8
View File
@@ -201,7 +201,7 @@ static char *HWR_PreprocessShader(char *original)
CONS_Alert(CONS_ERROR, "HWR_PreprocessShader: Syntax error in #version. Expected version with 3 digits, but got %d digits.\n", version_number_len); CONS_Alert(CONS_ERROR, "HWR_PreprocessShader: Syntax error in #version. Expected version with 3 digits, but got %d digits.\n", version_number_len);
return NULL; return NULL;
} }
M_Memcpy(shader_glsl_version, read_pos, 3); memcpy(shader_glsl_version, read_pos, 3);
ADVANCE(version_number_len) ADVANCE(version_number_len)
version_len = (read_pos - original) - version_pos; version_len = (read_pos - original) - version_pos;
whitespace_len = strspn(read_pos, WHITESPACE_CHARS); whitespace_len = strspn(read_pos, WHITESPACE_CHARS);
@@ -304,7 +304,7 @@ static char *HWR_PreprocessShader(char *original)
{ {
strcpy(write_pos, VERSION_PART); strcpy(write_pos, VERSION_PART);
write_pos += sizeof(VERSION_PART) - 1; write_pos += sizeof(VERSION_PART) - 1;
M_Memcpy(write_pos, shader_glsl_version, 3); memcpy(write_pos, shader_glsl_version, 3);
write_pos += 3; write_pos += 3;
strcpy(write_pos, line_ending); strcpy(write_pos, line_ending);
write_pos += line_ending_len; write_pos += line_ending_len;
@@ -344,7 +344,7 @@ static char *HWR_PreprocessShader(char *original)
} }
// Copy the original shader. // Copy the original shader.
M_Memcpy(write_pos, read_pos, original_len); memcpy(write_pos, read_pos, original_len);
// Erase the original #version directive, if it exists and was copied. // Erase the original #version directive, if it exists and was copied.
if (new_len != original_len && version_pos != -1) if (new_len != original_len && version_pos != -1)
@@ -573,7 +573,7 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
size = W_LumpLengthPwad(wadnum, lump); size = W_LumpLengthPwad(wadnum, lump);
line = Z_Malloc(size+1, PU_STATIC, NULL); line = Z_Malloc(size+1, PU_STATIC, NULL);
M_Memcpy(line, shaderdef, size); memcpy(line, shaderdef, size);
line[size] = '\0'; line[size] = '\0';
stoken = strtok(line, "\r\n "); stoken = strtok(line, "\r\n ");
@@ -586,7 +586,7 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
goto skip_field; goto skip_field;
} }
if (!stricmp(stoken, "GLSL")) if (fasticmp(stoken, "GLSL"))
{ {
value = strtok(NULL, "\r\n "); value = strtok(NULL, "\r\n ");
if (!value) if (!value)
@@ -596,9 +596,9 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
goto skip_lump; goto skip_lump;
} }
if (!stricmp(value, "VERTEX")) if (fasticmp(value, "VERTEX"))
shadertype = 1; shadertype = 1;
else if (!stricmp(value, "FRAGMENT")) else if (fasticmp(value, "FRAGMENT"))
shadertype = 2; shadertype = 2;
skip_lump: skip_lump:
@@ -624,7 +624,7 @@ skip_lump:
for (i = 0; shaderxlat[i].type; i++) for (i = 0; shaderxlat[i].type; i++)
{ {
if (!stricmp(shaderxlat[i].type, stoken)) if (fasticmp(shaderxlat[i].type, stoken))
{ {
size_t shader_string_length; size_t shader_string_length;
char *shader_source; char *shader_source;
+102 -83
View File
@@ -110,6 +110,7 @@ GLint screen_texsizew = 512; // Power-of-two screen texture render resolution
GLint screen_texsizeh = 512; // Power-of-two screen texture render resolution GLint screen_texsizeh = 512; // Power-of-two screen texture render resolution
GLbyte screen_depth = 0; GLbyte screen_depth = 0;
GLint maximumAnisotropy = 0; GLint maximumAnisotropy = 0;
boolean supportNPO2tex = false;
static GLboolean MipMap = GL_FALSE; static GLboolean MipMap = GL_FALSE;
static GLint min_filter = GL_LINEAR; static GLint min_filter = GL_LINEAR;
static GLint mag_filter = GL_LINEAR; static GLint mag_filter = GL_LINEAR;
@@ -1176,12 +1177,20 @@ void GL_SetModelView(GLint w, GLint h)
screen_texsizew = screen_texsizeh = 512; screen_texsizew = screen_texsizeh = 512;
// look for power of two that is large enough for the screen if (supportNPO2tex)
while (screen_texsizew < w) {
screen_texsizew <<= 1; screen_texsizew = screen_width;
screen_texsizeh = screen_height;
}
else
{
// look for power of two that is large enough for the screen
while (screen_texsizew < w)
screen_texsizew <<= 1;
while (screen_texsizeh < h) while (screen_texsizeh < h)
screen_texsizeh <<= 1; screen_texsizeh <<= 1;
}
pglGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtexsize); // Get the maximum supported texture size pglGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtexsize); // Get the maximum supported texture size
if ((screen_texsizew > maxtexsize || screen_texsizeh > maxtexsize) && maxtexsize > 0) if ((screen_texsizew > maxtexsize || screen_texsizeh > maxtexsize) && maxtexsize > 0)
@@ -1814,47 +1823,72 @@ static void GL_AllocTextureBuffer(GLMipmap_t *pTexInfo)
} }
} }
#define PADDING_CHECK(offset, alphaCheck) { from = to + (offset); if ((alphaCheck)) from = NULL; else goto foundFrom; } static void PadRGBABitmap(RGBA_t *tex, UINT16 w, UINT16 h, UINT32 flags)
static void PadRGBABitmap(RGBA_t *tex, UINT16 w, UINT16 h)
{ {
INT32 i; INT32 i, c1, c2, idxAdd;
boolean notLeft, notRight, notTop, notBottom; UINT16 c1size, c2size;
RGBA_t *to = tex - 1, *from; RGBA_t *current, *prev, *next, *first;
boolean ignorePrev, wrap;
for (i = 0; i < w * h; i++) for (i = 0; i < 2; i++)
{ {
to++; c1size = i ? h : w;
if (to->rgba != 0) c2size = i ? w : h;
continue; idxAdd = i ? 1 : w;
from = NULL; wrap = i ? flags & TF_WRAPX : flags & TF_WRAPY;
notLeft = i % w != 0; for (c1 = 0; c1 < c1size; c1++)
notRight = i % w != w - 1;
notTop = i / w != 0;
notBottom = i / w != h - 1;
if (notRight) PADDING_CHECK(1, from->s.alpha == 0) // Check +X
if (notBottom) PADDING_CHECK(w, from->s.alpha == 0) // Check +Y
if (notLeft) PADDING_CHECK(-1, from->s.alpha == 0) // Check -X
if (notTop) PADDING_CHECK(-w, from->s.alpha == 0) // Check -Y
if (notRight && notBottom) PADDING_CHECK(1 + w, from->s.alpha == 0) // Check +X+Y
if (notLeft && notBottom) PADDING_CHECK(-1 + w, from->s.alpha == 0) // Check -X+Y
if (notLeft && notTop) PADDING_CHECK(-1 - w, from->s.alpha == 0) // Check -X-Y
if (notRight && notTop) PADDING_CHECK(1 - w, from->s.alpha == 0) // Check +X-Y
foundFrom:
if (from != NULL)
{ {
*to = *from; if (i)
to->s.alpha = 0; {
first = current = tex + (c1 * w);
prev = wrap ? tex + (w - 1 + c1 * w) : current;
next = tex + (1 + c1 * w);
}
else
{
first = current = tex + c1;
prev = wrap ? tex + (c1 + (h - 1) * w) : current;
next = tex + (c1 + w);
}
ignorePrev = false;
for (c2 = 0; c2 < c2size; c2++)
{
if (c2 == c2size - 1)
next = wrap ? first : current;
if (current->rgba)
{
ignorePrev = false;
}
else if (prev->rgba && !ignorePrev)
{
*current = *prev;
current->s.alpha = 0;
ignorePrev = true;
}
else if (next->rgba)
{
*current = *next;
current->s.alpha = 0;
ignorePrev = false;
}
else
{
ignorePrev = false;
}
prev = current;
current = next;
next += idxAdd;
}
} }
} }
} }
#undef PADDING_CHECK static void GenerateMipmaps(INT32 w, INT32 h, RGBA_t *tex, INT32 maxLOD, UINT32 flags)
static void GenerateMipmaps(INT32 w, INT32 h, RGBA_t *tex, INT32 maxLOD)
{ {
if (tex == NULL) if (tex == NULL)
{ {
@@ -1916,7 +1950,7 @@ static void GenerateMipmaps(INT32 w, INT32 h, RGBA_t *tex, INT32 maxLOD)
h /= 2; h /= 2;
if (padTexture) if (padTexture)
PadRGBABitmap(tex, w, h); PadRGBABitmap(tex, w, h, flags);
pglTexSubImage2D(GL_TEXTURE_2D, m + 1, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, tex); pglTexSubImage2D(GL_TEXTURE_2D, m + 1, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, tex);
} }
@@ -1991,7 +2025,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
} }
if (applyPadding) if (applyPadding)
PadRGBABitmap(tex, w, h); PadRGBABitmap(tex, w, h, pTexInfo->flags);
break; break;
case GL_TEXFMT_RGBA: case GL_TEXFMT_RGBA:
@@ -2007,7 +2041,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
ptex = tex; ptex = tex;
if (applyPadding) if (applyPadding)
PadRGBABitmap(tex, w, h); PadRGBABitmap(tex, w, h, pTexInfo->flags);
} }
break; break;
@@ -2052,21 +2086,10 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
pglBindTexture(GL_TEXTURE_2D, num); pglBindTexture(GL_TEXTURE_2D, num);
tex_downloaded = num; tex_downloaded = num;
const int transparent = (pTexInfo->flags & TF_TRANSPARENT); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
// disable texture filtering on any texture that has holes so there's no dumb borders or blending issues if (MipMap)
if (transparent)
{
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
else
{
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
}
if (MipMap && !transparent) // No mipmaps on transparent stuff
{ {
pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
@@ -2077,8 +2100,16 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
// Control the mipmap level of detail // Control the mipmap level of detail
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 5);
GenerateMipmaps(w, h, tex, 5); if (pTexInfo->flags & TF_TRANSPARENT)
{
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 0); // No mipmaps on transparent stuff
}
else
{
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4);
GenerateMipmaps(w, h, tex, 4, pTexInfo->flags);
}
} }
else else
{ {
@@ -2459,12 +2490,10 @@ void GL_DrawIndexedTriangles(FSurfaceInfo *pSurf, FOutVector *pOutVerts, FUINT i
// the DrawPolygon variant of this has some code about polyflags and wrapping here but havent noticed any problems from omitting it? // the DrawPolygon variant of this has some code about polyflags and wrapping here but havent noticed any problems from omitting it?
} }
static const boolean gl_ext_arb_vertex_buffer_object = true; //#define NULL_VBO_VERTEX ((gl_skyvertex_t*)NULL)
#define sky_vbo_x ((void*)offsetof(gl_skyvertex_t, x))
#define NULL_VBO_VERTEX ((gl_skyvertex_t*)NULL) #define sky_vbo_u ((void*)offsetof(gl_skyvertex_t, u))
#define sky_vbo_x (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->x : &sky->data[0].x) #define sky_vbo_r ((void*)offsetof(gl_skyvertex_t, r))
#define sky_vbo_u (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->u : &sky->data[0].u)
#define sky_vbo_r (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->r : &sky->data[0].r)
void GL_RenderSkyDome(gl_sky_t *sky) void GL_RenderSkyDome(gl_sky_t *sky)
{ {
@@ -2476,30 +2505,23 @@ void GL_RenderSkyDome(gl_sky_t *sky)
if (sky->rebuild) if (sky->rebuild)
{ {
// delete VBO when already exists // delete VBO when already exists
if (gl_ext_arb_vertex_buffer_object) if (sky->vbo)
{ pglDeleteBuffers(1, &sky->vbo);
if (sky->vbo)
pglDeleteBuffers(1, &sky->vbo);
}
if (gl_ext_arb_vertex_buffer_object) // generate a new VBO and get the associated ID
{ pglGenBuffers(1, &sky->vbo);
// generate a new VBO and get the associated ID
pglGenBuffers(1, &sky->vbo);
// bind VBO in order to use // bind VBO in order to use
pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo); pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo);
// upload data to VBO // upload data to VBO
pglBufferData(GL_ARRAY_BUFFER, sky->vertex_count * sizeof(sky->data[0]), sky->data, GL_STATIC_DRAW); pglBufferData(GL_ARRAY_BUFFER, sky->vertex_count * sizeof(sky->data[0]), sky->data, GL_STATIC_DRAW);
}
sky->rebuild = false; sky->rebuild = false;
} }
// bind VBO in order to use // bind VBO in order to use
if (gl_ext_arb_vertex_buffer_object) pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo);
pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo);
// activate and specify pointers to arrays // activate and specify pointers to arrays
pglVertexPointer(3, GL_FLOAT, sizeof(sky->data[0]), sky_vbo_x); pglVertexPointer(3, GL_FLOAT, sizeof(sky->data[0]), sky_vbo_x);
@@ -2543,8 +2565,7 @@ void GL_RenderSkyDome(gl_sky_t *sky)
pglColor4ubv(white); pglColor4ubv(white);
// bind with 0, so, switch back to normal pointer operation // bind with 0, so, switch back to normal pointer operation
if (gl_ext_arb_vertex_buffer_object) pglBindBuffer(GL_ARRAY_BUFFER, 0);
pglBindBuffer(GL_ARRAY_BUFFER, 0);
// deactivate color array // deactivate color array
pglDisableClientState(GL_COLOR_ARRAY); pglDisableClientState(GL_COLOR_ARRAY);
@@ -3692,7 +3713,6 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
float xfix, yfix; float xfix, yfix;
float origaspect, newaspect; float origaspect, newaspect;
float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen
FRGBAFloat clearColour;
static float off[12]; static float off[12];
static float fix[8]; static float fix[8];
@@ -3743,8 +3763,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
pglViewport(0, 0, width, height); pglViewport(0, 0, width, height);
clearColour.red = clearColour.green = clearColour.blue = 0; FRGBAFloat clearColour = {0, 0, 0, 1};
clearColour.alpha = 1;
GL_ClearBuffer(true, false, false, &clearColour); GL_ClearBuffer(true, false, false, &clearColour);
GL_SetBlend(PF_NoDepthTest); GL_SetBlend(PF_NoDepthTest);
+1
View File
@@ -124,6 +124,7 @@ extern GLint screen_width;
extern GLint screen_height; extern GLint screen_height;
extern GLbyte screen_depth; extern GLbyte screen_depth;
extern GLint maximumAnisotropy; extern GLint maximumAnisotropy;
extern boolean supportNPO2tex;
extern boolean supportMipMap; extern boolean supportMipMap;
/** \brief OpenGL flags for video driver /** \brief OpenGL flags for video driver
-4
View File
@@ -221,10 +221,6 @@ INT32 I_mkdir(const char *dirname, INT32 unixright);
*/ */
const char *I_LocateWad(void); const char *I_LocateWad(void);
/** \brief Joystick events
*/
void I_GetJoystickEvents(UINT8 index);
char *I_GetEnv(const char *name); char *I_GetEnv(const char *name);
INT32 I_PutEnv(char *variable); INT32 I_PutEnv(char *variable);
+2 -2
View File
@@ -670,7 +670,7 @@ static boolean SOCK_Get(void)
{ {
const time_t curTime = time(NULL); const time_t curTime = time(NULL);
M_Memcpy(&clientaddress[j], &fromaddress, fromlen); memcpy(&clientaddress[j], &fromaddress, fromlen);
nodesocket[j] = mysockets[n]; nodesocket[j] = mysockets[n];
DEBFILE(va("New node detected: node:%d address:%s\n", j, DEBFILE(va("New node detected: node:%d address:%s\n", j,
SOCK_GetNodeAddress(j))); SOCK_GetNodeAddress(j)));
@@ -1485,7 +1485,7 @@ static boolean SOCK_Ban(INT32 node)
ban = numbans; ban = numbans;
AddBannedIndex(); AddBannedIndex();
M_Memcpy(&banned[ban].address, &clientaddress[node], sizeof (mysockaddr_t)); memcpy(&banned[ban].address, &clientaddress[node], sizeof (mysockaddr_t));
if (banned[ban].address.any.sa_family == AF_INET) if (banned[ban].address.any.sa_family == AF_INET)
{ {
+2
View File
@@ -143,6 +143,8 @@ boolean I_CheckNativeRes(void);
void I_SetBorderlessWindow(void); void I_SetBorderlessWindow(void);
void I_HandleControllerHatRepeat(void);
#ifdef USE_FBO_OGL #ifdef USE_FBO_OGL
void RefreshOGLSDLSurface(void); void RefreshOGLSDLSurface(void);
+6 -3
View File
@@ -637,11 +637,14 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, bo
UINT8 K_GetKartColorByName(const char *name) UINT8 K_GetKartColorByName(const char *name)
{ {
UINT8 color = (UINT8)atoi(name); UINT8 color = (UINT8)atoi(name);
if (color > 0 && color < MAXSKINCOLORS) if (color > 0 && color < MAXSKINCOLORS)
return color; return color;
for (color = 1; color < MAXSKINCOLORS; color++) for (color = 1; color < MAXSKINCOLORS; color++)
if (!stricmp(KartColor_Names[color], name)) if (fasticmp(KartColor_Names[color], name))
return color; return color;
return 0; return 0;
} }
@@ -2857,9 +2860,9 @@ void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32
v[3] = FRACUNIT; v[3] = FRACUNIT;
res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle)); res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
finalx = x + v[0]; finalx = x + v[0];
finaly = y + v[1]; finaly = y + v[1];
+43 -36
View File
@@ -45,27 +45,33 @@ boolean luaL_checkboolean(lua_State *L, int narg) {
// String concatination // String concatination
static int lib_concat(lua_State *L) static int lib_concat(lua_State *L)
{ {
int n = lua_gettop(L); /* number of arguments */ int n = lua_gettop(L); /* number of arguments */
int i; int i;
char *r = NULL; char *r = NULL;
size_t rl = 0,sl; size_t rl = 0, sl;
lua_getglobal(L, "tostring"); lua_getglobal(L, "tostring");
for (i=1; i<=n; i++) { for (i=1; i<=n; i++) {
const char *s; const char *s;
lua_pushvalue(L, -1); /* function to be called */ lua_pushvalue(L, -1); /* function to be called */
lua_pushvalue(L, i); /* value to print */ lua_pushvalue(L, i); /* value to print */
lua_call(L, 1, 1); lua_call(L, 1, 1);
s = lua_tolstring(L, -1, &sl); /* get result */ s = lua_tolstring(L, -1, &sl); /* get result */
if (s == NULL)
return luaL_error(L, LUA_QL("tostring") " must return a string to " if (sl == 0) {
LUA_QL("__add")); lua_pop(L, 1); /* pop result */
continue;
}
if (s == NULL)
return luaL_error(L, LUA_QL("tostring") " must return a string to "
LUA_QL("__add"));
r = Z_Realloc(r, rl+sl, PU_STATIC, NULL); r = Z_Realloc(r, rl+sl, PU_STATIC, NULL);
M_Memcpy(r+rl, s, sl); memcpy(r+rl, s, sl);
rl += sl; rl += sl;
lua_pop(L, 1); /* pop result */ lua_pop(L, 1); /* pop result */
} }
lua_pushlstring(L, r, rl); lua_pushlstring(L, r, rl);
Z_Free(r); Z_Free(r);
return 1; return 1;
} }
@@ -73,23 +79,24 @@ static int lib_concat(lua_State *L)
// Copied from base Lua code // Copied from base Lua code
static int lib_print(lua_State *L) static int lib_print(lua_State *L)
{ {
int n = lua_gettop(L); /* number of arguments */ int n = lua_gettop(L); /* number of arguments */
int i; int i;
//HUDSAFE //HUDSAFE
lua_getglobal(L, "tostring"); lua_getglobal(L, "tostring");
for (i=1; i<=n; i++) { for (i=1; i<=n; i++) {
const char *s; const char *s;
lua_pushvalue(L, -1); /* function to be called */ lua_pushvalue(L, -1); /* function to be called */
lua_pushvalue(L, i); /* value to print */ lua_pushvalue(L, i); /* value to print */
lua_call(L, 1, 1); lua_call(L, 1, 1);
s = lua_tostring(L, -1); /* get result */ s = lua_tostring(L, -1); /* get result */
if (s == NULL)
return luaL_error(L, LUA_QL("tostring") " must return a string to " if (s == NULL)
LUA_QL("print")); return luaL_error(L, LUA_QL("tostring") " must return a string to "
if (i>1) CONS_Printf("\n"); LUA_QL("print"));
CONS_Printf("%s", s); if (i>1) CONS_Printf("\n");
lua_pop(L, 1); /* pop result */ CONS_Printf("%s", s);
} lua_pop(L, 1); /* pop result */
}
CONS_Printf("\n"); CONS_Printf("\n");
return 0; return 0;
} }
+1 -1
View File
@@ -469,7 +469,7 @@ static int lib_cvRegisterVar(lua_State *L)
if (cvar->flags & CV_MODIFIED) if (cvar->flags & CV_MODIFIED)
return luaL_error(L, "failed to register cvar (probable conflict with internal variable/command names)"); return luaL_error(L, "failed to register cvar (probable conflict with internal variable/command names)");
if (!(((cvar->flags & CV_HIDEN)) || (cvar->flags & CV_NOSHOWHELP)) && (cvar->PossibleValue || !(cvar->value == 0 && stricmp(cvar->string, "0")))) if (!(((cvar->flags & CV_HIDEN)) || (cvar->flags & CV_NOSHOWHELP)) && (cvar->PossibleValue || !(cvar->value == 0 && !fasticmp(cvar->string, "0"))))
{ {
if (!category) if (!category)
{ {
+3 -3
View File
@@ -83,7 +83,7 @@ FUNCINLINE static ATTRINLINE unsigned hook_in_list
for (type = 0; list[type] != NULL; ++type) for (type = 0; list[type] != NULL; ++type)
{ {
if (strcmp(name, list[type]) == 0) if (fastcmp(name, list[type]))
break; break;
} }
@@ -240,7 +240,7 @@ static int lib_addHook(lua_State *L)
{ {
add_hook(&hookIds[type]); add_hook(&hookIds[type]);
} }
/*else if (strcmp(name, "HUD") == 0) // ehh this is cool and all, but i dont want modders potentially breaking vanilla clients lol /*else if (fastcmp(name, "HUD")) // ehh this is cool and all, but i dont want modders potentially breaking vanilla clients lol
{ {
add_hud_hook(L, 3); add_hud_hook(L, 3);
}*/ }*/
@@ -818,7 +818,7 @@ typedef struct {
FUNCINLINE static ATTRINLINE boolean checkbotkey(const char *field) FUNCINLINE static ATTRINLINE boolean checkbotkey(const char *field)
{ {
return lua_toboolean(gL, -1) && strcmp(lua_tostring(gL, -2), field) == 0; return lua_toboolean(gL, -1) && fastcmp(lua_tostring(gL, -2), field);
} }
static void res_botai(Hook_State *hook) static void res_botai(Hook_State *hook)
+3 -3
View File
@@ -455,12 +455,12 @@ int mobj_localskin_setter(lua_State *L)
strlcpy(skin, luaL_optstring(L, 2, "none"), sizeof skin); strlcpy(skin, luaL_optstring(L, 2, "none"), sizeof skin);
strlwr(skin); // all skin names are lowercase strlwr(skin); // all skin names are lowercase
if (stricmp(skin, "none")) if (!fasticmp(skin, "none"))
{ {
// Try localskins // Try localskins
for (i = 0; i < numlocalskins; i++) for (i = 0; i < numlocalskins; i++)
{ {
if (stricmp(localskins[i].name, skin) == 0) if (fasticmp(localskins[i].name, skin))
{ {
mo->localskin = &localskins[i]; mo->localskin = &localskins[i];
mo->skinlocal = true; mo->skinlocal = true;
@@ -471,7 +471,7 @@ int mobj_localskin_setter(lua_State *L)
// Try other skins // Try other skins
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
if (stricmp(skins[i].name, skin) == 0) if (fasticmp(skins[i].name, skin))
{ {
mo->localskin = &skins[i]; mo->localskin = &skins[i];
mo->skinlocal = false; mo->skinlocal = false;
+2 -2
View File
@@ -192,7 +192,7 @@ lzf_decompress (const void *const in_data, size_t in_len,
#endif #endif
#if USE_MEMCPY #if USE_MEMCPY
M_Memcpy (op, ip, ctrl); memcpy(op, ip, ctrl);
op += ctrl; op += ctrl;
ip += ctrl; ip += ctrl;
#else #else
@@ -435,7 +435,7 @@ lzf_compress (const void *const in_data,size_t in_len,
*op++ = MAX_LIT - 1; *op++ = MAX_LIT - 1;
#if USE_MEMCPY #if USE_MEMCPY
M_Memcpy (op, ip - MAX_LIT, MAX_LIT); memcpy(op, ip - MAX_LIT, MAX_LIT);
op += MAX_LIT; op += MAX_LIT;
lit = 0; lit = 0;
#else #else
+2 -2
View File
@@ -183,7 +183,7 @@ static aatree_node_t *M_AATreeSetString_Node(aatree_node_t *node, UINT32 flags,
else else
{ {
aatree_entry_t *entry = node->value; aatree_entry_t *entry = node->value;
if (entry != NULL && strcmp(entry->key, key) != 0) if (entry != NULL && !fastcmp(entry->key, key))
entry = entry->next; entry = entry->next;
if (entry != NULL) if (entry != NULL)
{ {
@@ -252,7 +252,7 @@ void *M_AATreeGetString(aatree_t *aatree, const char *key)
I_Assert((aatree->flags & AATREE_STRING) == AATREE_STRING); I_Assert((aatree->flags & AATREE_STRING) == AATREE_STRING);
UINT32 hash = FNV1a_HashString(key); UINT32 hash = FNV1a_HashString(key);
aatree_entry_t *entry = M_AATreeGet_Node(aatree->root, hash); aatree_entry_t *entry = M_AATreeGet_Node(aatree->root, hash);
while (entry != NULL && strcmp(entry->key, key) != 0) while (entry != NULL && !fastcmp(entry->key, key))
entry = entry->next; entry = entry->next;
return entry != NULL ? entry->value : NULL; return entry != NULL ? entry->value : NULL;
} }
+1 -1
View File
@@ -49,7 +49,7 @@ INT32 M_CheckParm(const char *check)
for (i = 1; i < myargc; i++) for (i = 1; i < myargc; i++)
{ {
if (!strcasecmp(check, myargv[i])) if (fasticmp(check, myargv[i]))
{ {
found = i; found = i;
return i; return i;
+2 -2
View File
@@ -112,7 +112,7 @@ void M_LoadEmotes(UINT16 wadnum)
trim(field); trim(field);
trim(value); trim(value);
if (stricmp(field.c_str(), "frames") == 0) if (fasticmp(field.c_str(), "frames"))
{ {
UINT8 numframes = 0; UINT8 numframes = 0;
@@ -158,7 +158,7 @@ void M_LoadEmotes(UINT16 wadnum)
emote->numframes = numframes; emote->numframes = numframes;
} }
else if (stricmp(field.c_str(), "timeperframe") == 0) else if (fasticmp(field.c_str(), "timeperframe"))
{ {
emote->timeperframe = std::stoi(value); emote->timeperframe = std::stoi(value);
+3 -3
View File
@@ -101,7 +101,7 @@ vector2_t *FV2_UnLoad(vector2_t *vec, fixed_t *x, fixed_t *y)
vector2_t *FV2_Copy(vector2_t *a_o, const vector2_t *a_i) vector2_t *FV2_Copy(vector2_t *a_o, const vector2_t *a_i)
{ {
return M_Memcpy(a_o, a_i, sizeof(vector2_t)); return memcpy(a_o, a_i, sizeof(vector2_t));
} }
vector2_t *FV2_AddEx(const vector2_t *a_i, const vector2_t *a_c, vector2_t *a_o) vector2_t *FV2_AddEx(const vector2_t *a_i, const vector2_t *a_c, vector2_t *a_o)
@@ -250,7 +250,7 @@ vector3_t *FV3_UnLoad(vector3_t *vec, fixed_t *x, fixed_t *y, fixed_t *z)
vector3_t *FV3_Copy(vector3_t *a_o, const vector3_t *a_i) vector3_t *FV3_Copy(vector3_t *a_o, const vector3_t *a_i)
{ {
return M_Memcpy(a_o, a_i, sizeof(vector3_t)); return memcpy(a_o, a_i, sizeof(vector3_t));
} }
vector3_t *FV3_AddEx(const vector3_t *a_i, const vector3_t *a_c, vector3_t *a_o) vector3_t *FV3_AddEx(const vector3_t *a_i, const vector3_t *a_c, vector3_t *a_o)
@@ -813,7 +813,7 @@ void FM_MultMatrix(matrix_t *dest, const matrix_t *multme)
R(i, j) = FixedMul(D(i, 0), M(0, j)) + FixedMul(D(i, 1), M(1, j)) + FixedMul(D(i, 2), M(2, j)) + FixedMul(D(i, 3), M(3, j)); R(i, j) = FixedMul(D(i, 0), M(0, j)) + FixedMul(D(i, 1), M(1, j)) + FixedMul(D(i, 2), M(2, j)) + FixedMul(D(i, 3), M(3, j));
} }
M_Memcpy(dest, &result, sizeof(matrix_t)); memcpy(dest, &result, sizeof(matrix_t));
#undef R #undef R
#undef D #undef D
+10 -31
View File
@@ -759,8 +759,6 @@ static void Command_Manual_f(void)
itemOn = 0; itemOn = 0;
} }
boolean dpadscrollstate[4] = {false, false, false, false};
// //
// M_Responder // M_Responder
// //
@@ -807,19 +805,15 @@ boolean M_Responder(event_t *ev)
break; break;
case KEY_HAT1: case KEY_HAT1:
ch = KEY_UPARROW; ch = KEY_UPARROW;
dpadscrollstate[DPAD_UP] = true;
break; break;
case KEY_HAT1 + 1: case KEY_HAT1 + 1:
ch = KEY_DOWNARROW; ch = KEY_DOWNARROW;
dpadscrollstate[DPAD_DOWN] = true;
break; break;
case KEY_HAT1 + 2: case KEY_HAT1 + 2:
ch = KEY_LEFTARROW; ch = KEY_LEFTARROW;
dpadscrollstate[DPAD_LEFT] = true;
break; break;
case KEY_HAT1 + 3: case KEY_HAT1 + 3:
ch = KEY_RIGHTARROW; ch = KEY_RIGHTARROW;
dpadscrollstate[DPAD_RIGHT] = true;
break; break;
} }
@@ -835,24 +829,6 @@ boolean M_Responder(event_t *ev)
} }
} }
} }
else if (ev->type == ev_keyup)
{
switch (ev->data1) // if you let go of those set those to false
{
case KEY_HAT1:
dpadscrollstate[DPAD_UP] = false;
break;
case KEY_HAT1 + 1:
dpadscrollstate[DPAD_DOWN] = false;
break;
case KEY_HAT1 + 2:
dpadscrollstate[DPAD_LEFT] = false;
break;
case KEY_HAT1 + 3:
dpadscrollstate[DPAD_RIGHT] = false;
break;
}
}
else if (menuactive) else if (menuactive)
{ {
tic_t thistime = I_GetTime(); tic_t thistime = I_GetTime();
@@ -1731,6 +1707,9 @@ void M_Ticker(void)
if (dedicated) if (dedicated)
return; return;
if (menuactive)
I_HandleControllerHatRepeat();
if (--skullAnimCounter <= 0) if (--skullAnimCounter <= 0)
skullAnimCounter = 8; skullAnimCounter = 8;
@@ -3719,10 +3698,10 @@ static void M_HandleAddons(INT32 choice)
break; break;
case EXT_TXT: case EXT_TXT:
case EXT_CFG: case EXT_CFG:
if ((strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, CONFIGFILENAME) == 0) if (fastcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, CONFIGFILENAME)
|| (strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, AUTOLOADCONFIGFILENAME) == 0) || fastcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, AUTOLOADCONFIGFILENAME)
|| (strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, "kartserv.cfg") == 0) || fastcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, "kartserv.cfg")
|| (strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, "kartexec.cfg") == 0)) || fastcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, "kartexec.cfg"))
{ {
M_StartMessage(va("%c%s\x80\nYou can't autoload this builds' base console scripts, silly!\n They're already autoloaded on startup! \n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); M_StartMessage(va("%c%s\x80\nYou can't autoload this builds' base console scripts, silly!\n They're already autoloaded on startup! \n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING);
S_StartSound(NULL, sfx_s26d); S_StartSound(NULL, sfx_s26d);
@@ -3830,7 +3809,7 @@ static void ReplayNamesLoadThread(void* userdata)
Lock_search_state(); Lock_search_state();
if (strcmp(menupath, replaydirpath) == 0) if (fastcmp(menupath, replaydirpath))
{ {
memcpy(demolist_all, demolist_all_local, sizeof(menudemo_t)*sizedirmenu); memcpy(demolist_all, demolist_all_local, sizeof(menudemo_t)*sizedirmenu);
replaynamesloaded = true; replaynamesloaded = true;
@@ -8808,7 +8787,7 @@ static boolean M_QuitMultiPlayerMenu(void)
size_t l; size_t l;
// send name if changed // send name if changed
if (strcmp(setupm_name, setupm_cvname->string)) if (!fastcmp(setupm_name, setupm_cvname->string))
{ {
// remove trailing whitespaces // remove trailing whitespaces
for (l= strlen(setupm_name)-1; for (l= strlen(setupm_name)-1;
@@ -9469,7 +9448,7 @@ static void M_VideoModeMenu(INT32 choice)
// VESA mode, which is always a higher modenum // VESA mode, which is always a higher modenum
for (j = 0; j < vidm_nummodes; j++) for (j = 0; j < vidm_nummodes; j++)
{ {
if (!strcmp(modedescs[j].desc, desc)) if (fastcmp(modedescs[j].desc, desc))
{ {
// mode(0): 320x200 is always standard VGA, not vesa // mode(0): 320x200 is always standard VGA, not vesa
if (modedescs[j].modenum) if (modedescs[j].modenum)
-10
View File
@@ -38,16 +38,6 @@ extern boolean forceshowhud;
// Does all the real work of the menu interaction. // Does all the real work of the menu interaction.
boolean M_Responder(event_t *ev); boolean M_Responder(event_t *ev);
// for scrolling through menus with controllers
extern boolean dpadscrollstate[4];
enum
{
DPAD_UP,
DPAD_DOWN,
DPAD_LEFT,
DPAD_RIGHT
};
// Called by main loop, runs for demo playback. If this returns true, nullify any further user input. // Called by main loop, runs for demo playback. If this returns true, nullify any further user input.
boolean M_DemoResponder(event_t *ev); boolean M_DemoResponder(event_t *ev);
+44 -30
View File
@@ -818,26 +818,31 @@ static menuitem_t OP_VideoOptionsMenu[] =
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) #if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
{IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 20}, {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 20},
#endif #endif
#ifdef BACKWARDSCOMPATCORRECTION
{IT_STRING | IT_CVAR | IT_CV_SLIDER, {IT_STRING | IT_CVAR | IT_CV_SLIDER,
NULL, "Brightness", &cv_globalgamma, 30}, NULL, "Gamma", &cv_globalgamma, 30},
{IT_STRING | IT_CVAR | IT_CV_SLIDER,
NULL, "Saturation", &cv_globalsaturation , 40},
{IT_SUBMENU|IT_STRING, NULL, "Advanced Color Settings...", &OP_ColorOptionsDef, 50},
{IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 65},
{IT_STRING | IT_CVAR, NULL, "Weather Draw Distance", &cv_drawdist_precip, 75},
{IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 95},
{IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 105},
{IT_STRING | IT_CVAR, NULL, "FPS Cap", &cv_fpscap, 115},
{IT_STRING | IT_CVAR, NULL, "Drift spark pulse size", &cv_driftsparkpulse, 125},
{IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 135},
#ifdef HWRENDER
{IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 145},
#endif #endif
{IT_SUBMENU|IT_STRING, NULL, "Advanced Video Options...", &OP_ExpOptionsDef, 155},
{IT_STRING | IT_CVAR | IT_CV_SLIDER,
NULL, "Brightness", &cv_globalbrightness, 40},
{IT_STRING | IT_CVAR | IT_CV_SLIDER,
NULL, "Saturation", &cv_globalsaturation , 50},
{IT_SUBMENU|IT_STRING, NULL, "Advanced Color Settings...", &OP_ColorOptionsDef, 60},
{IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 75},
{IT_STRING | IT_CVAR, NULL, "Weather Draw Distance", &cv_drawdist_precip, 85},
{IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 105},
{IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 115},
{IT_STRING | IT_CVAR, NULL, "FPS Cap", &cv_fpscap, 125},
{IT_STRING | IT_CVAR, NULL, "Drift spark pulse size", &cv_driftsparkpulse, 135},
{IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 145},
#ifdef HWRENDER
{IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 155},
#endif
{IT_SUBMENU|IT_STRING, NULL, "Advanced Video Options...", &OP_ExpOptionsDef, 165},
}; };
static const char* OP_VideoTooltips[] = static const char* OP_VideoTooltips[] =
@@ -846,11 +851,12 @@ static const char* OP_VideoTooltips[] =
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) #if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
"Enable fullscreen.", "Enable fullscreen.",
#endif #endif
"Gamma (brightness) of the game.", "Increase the gamma of the displayed image.",
"Saturation of the game.", "Increase or decrease the brightness of the displayed image.",
"Reduce the saturation of the displayed image.",
"Advanced color settings of the game.", "Advanced color settings of the game.",
"How far away objects are drawn.", "How far objects can be drawn.",
"How far away weather is drawn.", "Affects how far weather visuals can be drawn.",
"Show current game framerate and select the style.", "Show current game framerate and select the style.",
"Sync game framerate to refresh rate of monitor.", "Sync game framerate to refresh rate of monitor.",
"Set manual framerate cap.", "Set manual framerate cap.",
@@ -869,7 +875,10 @@ enum
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) #if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
op_video_fullscreen, op_video_fullscreen,
#endif #endif
#ifdef BACKWARDSCOMPATCORRECTION
op_video_gamma, op_video_gamma,
#endif
op_video_bright,
op_video_sat, op_video_sat,
op_video_color, op_video_color,
op_video_dd, op_video_dd,
@@ -898,37 +907,37 @@ static menuitem_t OP_ColorOptionsMenu[] =
{IT_DISABLED, NULL, NULL, NULL, 35}, {IT_DISABLED, NULL, NULL, NULL, 35},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_rhue, 15}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_rhue, 15},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_rsaturation, 20}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_rsaturation, 20},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_rgamma, 25}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_rbrightness, 25},
{IT_HEADER, NULL, "Yellow", NULL, 34}, {IT_HEADER, NULL, "Yellow", NULL, 34},
{IT_DISABLED, NULL, NULL, NULL, 73}, {IT_DISABLED, NULL, NULL, NULL, 73},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_yhue, 40}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_yhue, 40},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_ysaturation, 45}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_ysaturation, 45},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_ygamma, 50}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_ybrightness, 50},
{IT_HEADER, NULL, "Green", NULL, 59}, {IT_HEADER, NULL, "Green", NULL, 59},
{IT_DISABLED, NULL, NULL, NULL, 112}, {IT_DISABLED, NULL, NULL, NULL, 112},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_ghue, 65}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_ghue, 65},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_gsaturation, 70}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_gsaturation, 70},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_ggamma, 75}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_gbrightness, 75},
{IT_HEADER, NULL, "Cyan", NULL, 84}, {IT_HEADER, NULL, "Cyan", NULL, 84},
{IT_DISABLED, NULL, NULL, NULL, 255}, {IT_DISABLED, NULL, NULL, NULL, 255},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_chue, 90}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_chue, 90},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_csaturation, 95}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_csaturation, 95},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_cgamma, 100}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_cbrightness, 100},
{IT_HEADER, NULL, "Blue", NULL, 109}, {IT_HEADER, NULL, "Blue", NULL, 109},
{IT_DISABLED, NULL, NULL, NULL, 152}, {IT_DISABLED, NULL, NULL, NULL, 152},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_bhue, 115}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_bhue, 115},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_bsaturation, 120}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_bsaturation, 120},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_bgamma, 125}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_bbrightness, 125},
{IT_HEADER, NULL, "Magenta", NULL, 134}, {IT_HEADER, NULL, "Magenta", NULL, 134},
{IT_DISABLED, NULL, NULL, NULL, 181}, {IT_DISABLED, NULL, NULL, NULL, 181},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_mhue, 140}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Hue", &cv_mhue, 140},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_msaturation, 145}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saturation", &cv_msaturation, 145},
{IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_mgamma, 150}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Brightness", &cv_mbrightness, 150},
}; };
static menuitem_t OP_ExpOptionsMenu[] = static menuitem_t OP_ExpOptionsMenu[] =
@@ -1153,8 +1162,10 @@ static menuitem_t OP_SoundAdvancedMenu[] =
{IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 80}, {IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 80},
{IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 85}, {IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 85},
{IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 90}, {IT_STRING | IT_CVAR, NULL, "Cache Sound", &cv_cachesound, 90},
{IT_DISABLED, NULL, "", NULL, 100}, // dummy text
{IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 95},
{IT_DISABLED, NULL, "", NULL, 105}, // dummy text
}; };
static const char* OP_SoundAdvancedTooltips[] = static const char* OP_SoundAdvancedTooltips[] =
@@ -1175,7 +1186,10 @@ static const char* OP_SoundAdvancedTooltips[] =
"Should the Invulnerability music be on or off?", "Should the Invulnerability music be on or off?",
"Should music be kept when restarting the map?", "Should music be kept when restarting the map?",
"Should the Intro fanfare be skipped\nand map music be played on map start?", "Should the Intro fanfare be skipped\nand map music be played on map start?",
"Controls Sound effects caching.\nKeep will retain previously played sound effects in cache." // man idk how to describe this in a non awful way lmao
"\nOn will preload all sound effects.\nEliminates sound-related lag and stutters but increases memory usage.",
"Size of the Audio Buffer\nreducing it will result in less sound latency\nbut may cause issues such as crackling or distorted Sound.", "Size of the Audio Buffer\nreducing it will result in less sound latency\nbut may cause issues such as crackling or distorted Sound.",
NULL,
}; };
static menuitem_t OP_FocusOptionsMenu[] = static menuitem_t OP_FocusOptionsMenu[] =
+2 -2
View File
@@ -423,7 +423,7 @@ void Command_SaveConfig_f(void)
FIL_ForceExtension(tmpstr, ".cfg"); FIL_ForceExtension(tmpstr, ".cfg");
M_SaveConfig(tmpstr); M_SaveConfig(tmpstr);
if (stricmp(COM_Argv(2), "-silent")) if (!fasticmp(COM_Argv(2), "-silent"))
CONS_Printf(M_GetText("config saved as %s\n"), configfile); CONS_Printf(M_GetText("config saved as %s\n"), configfile);
} }
@@ -1686,7 +1686,7 @@ char *M_GetToken(const char *inputString)
// Assign the memory. Don't forget an extra byte for the end of the string! // Assign the memory. Don't forget an extra byte for the end of the string!
texturesToken = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL); texturesToken = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL);
// Copy the string. // Copy the string.
M_Memcpy(texturesToken, stringToUse+startPos, (size_t)texturesTokenLength); memcpy(texturesToken, stringToUse+startPos, (size_t)texturesTokenLength);
// Make the final character NUL. // Make the final character NUL.
texturesToken[texturesTokenLength] = '\0'; texturesToken[texturesTokenLength] = '\0';
return texturesToken; return texturesToken;
+1 -1
View File
@@ -916,7 +916,7 @@ static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook)
int len = (int)strlen(str); int len = (int)strlen(str);
char* str_ptr; char* str_ptr;
if (strcmp(".lua", str + len - 4) == 0) if (fastcmp(".lua", str + len - 4))
{ {
str[len-4] = '\0'; // remove .lua at end str[len-4] = '\0'; // remove .lua at end
} }
+8 -8
View File
@@ -28,8 +28,8 @@
boolean LUA_CallAction(enum actionnum actionnum, void *thing); boolean LUA_CallAction(enum actionnum actionnum, void *thing);
INT32 var1; INT32 var1 = 0;
INT32 var2; INT32 var2 = 0;
// //
// P_NewChaseDir related LUT. // P_NewChaseDir related LUT.
@@ -945,9 +945,9 @@ void A_PointyThink(void *thing)
v[3] = FRACUNIT; v[3] = FRACUNIT;
res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(actor->lastlook+i))); res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(actor->lastlook+i)));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
res = VectorMatrixMultiply(v, *RotateZMatrix(actor->angle+ANGLE_180)); res = VectorMatrixMultiply(v, *RotateZMatrix(actor->angle+ANGLE_180));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
P_UnsetThingPosition(ball); P_UnsetThingPosition(ball);
ball->x = actor->x + v[0]; ball->x = actor->x + v[0];
@@ -4929,9 +4929,9 @@ void A_MaceRotate(void *thing)
// Calculate the angle matrixes for the link. // Calculate the angle matrixes for the link.
res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(actor->threshold))); res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(actor->threshold)));
M_Memcpy(&v, res, sizeof(v)); memcpy(&v, res, sizeof(v));
res = VectorMatrixMultiply(v, *RotateZMatrix(actor->target->health << ANGLETOFINESHIFT)); res = VectorMatrixMultiply(v, *RotateZMatrix(actor->target->health << ANGLETOFINESHIFT));
M_Memcpy(&v, res, sizeof(v)); memcpy(&v, res, sizeof(v));
} }
// Rotating Chain. // Rotating Chain.
else else
@@ -4950,9 +4950,9 @@ void A_MaceRotate(void *thing)
// Calculate the angle matrixes for the link. // Calculate the angle matrixes for the link.
res = VectorMatrixMultiply(v, *RotateXMatrix(actor->target->threshold << ANGLETOFINESHIFT)); res = VectorMatrixMultiply(v, *RotateXMatrix(actor->target->threshold << ANGLETOFINESHIFT));
M_Memcpy(&v, res, sizeof(v)); memcpy(&v, res, sizeof(v));
res = VectorMatrixMultiply(v, *RotateZMatrix(actor->target->health << ANGLETOFINESHIFT)); res = VectorMatrixMultiply(v, *RotateZMatrix(actor->target->health << ANGLETOFINESHIFT));
M_Memcpy(&v, res, sizeof(v)); memcpy(&v, res, sizeof(v));
} }
// Add on the appropriate distances to the actor's co-ordinates. // Add on the appropriate distances to the actor's co-ordinates.
+13 -13
View File
@@ -41,32 +41,32 @@
#include "m_perfstats.h" // ps_checkposition_calls #include "m_perfstats.h" // ps_checkposition_calls
fixed_t tmbbox[4]; fixed_t tmbbox[4] = {};
mobj_t *tmthing; mobj_t *tmthing = NULL;
static INT32 tmflags; static INT32 tmflags;
fixed_t tmx; fixed_t tmx = 0;
fixed_t tmy; fixed_t tmy = 0;
// If "floatok" true, move would be ok // If "floatok" true, move would be ok
// if within "tmfloorz - tmceilingz". // if within "tmfloorz - tmceilingz".
boolean floatok; boolean floatok = false;
fixed_t tmfloorz, tmceilingz; fixed_t tmfloorz = 0, tmceilingz = 0;
static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights static fixed_t tmdropoffz = 0, tmdrpoffceilz = 0; // drop-off floor/ceiling heights
mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector mobj_t *tmfloorthing = NULL; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector
mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) mobj_t *tmhitthing = NULL; // the solid thing you bumped into (for collisions)
pslope_t *tmfloorslope, *tmceilingslope; pslope_t *tmfloorslope = NULL, *tmceilingslope = NULL;
// keep track of the line that lowers the ceiling, // keep track of the line that lowers the ceiling,
// so missiles don't explode against sky hack walls // so missiles don't explode against sky hack walls
line_t *ceilingline; line_t *ceilingline = NULL;
// set by PIT_CheckLine() for any line that stopped the PIT_CheckLine() // set by PIT_CheckLine() for any line that stopped the PIT_CheckLine()
// that is, for any line which is 'solid' // that is, for any line which is 'solid'
line_t *blockingline; line_t *blockingline = NULL;
msecnode_t *sector_list = NULL; msecnode_t *sector_list = NULL;
camera_t *mapcampointer; camera_t *mapcampointer = NULL;
// //
// TELEPORT MOVE // TELEPORT MOVE
+9 -9
View File
@@ -43,7 +43,7 @@
consvar_t cv_splats = {"splats", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_splats = {"splats", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
#endif #endif
actioncache_t actioncachehead; actioncache_t actioncachehead = {};
static mobj_t *overlaycap = NULL; static mobj_t *overlaycap = NULL;
static mobj_t *shadowcap = NULL; static mobj_t *shadowcap = NULL;
@@ -5459,9 +5459,9 @@ static void P_MoveHoop(mobj_t *mobj)
v[3] = FRACUNIT; v[3] = FRACUNIT;
res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(mobj->target->movedir*FRACUNIT))); res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(mobj->target->movedir*FRACUNIT)));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
res = VectorMatrixMultiply(v, *RotateZMatrix(FixedAngle(mobj->target->movecount*FRACUNIT))); res = VectorMatrixMultiply(v, *RotateZMatrix(FixedAngle(mobj->target->movecount*FRACUNIT)));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
finalx = x + v[0]; finalx = x + v[0];
finaly = y + v[1]; finaly = y + v[1];
@@ -5527,9 +5527,9 @@ void P_SpawnHoopOfSomething(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT
v[3] = FRACUNIT; v[3] = FRACUNIT;
res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle)); res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
finalx = x + v[0]; finalx = x + v[0];
finaly = y + v[1]; finaly = y + v[1];
@@ -5566,9 +5566,9 @@ void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 numb
v[3] = FRACUNIT; v[3] = FRACUNIT;
res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle)); res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
finalx = x + v[0]; finalx = x + v[0];
finaly = y + v[1]; finaly = y + v[1];
@@ -11815,9 +11815,9 @@ static void P_SpawnNiGHTSHoop(fixed_t x, fixed_t y, fixed_t z, fixed_t hoopsize,
v[3] = FRACUNIT; v[3] = FRACUNIT;
res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(spewangle))); res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(spewangle)));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle)); res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle));
M_Memcpy(&v, res, sizeof (v)); memcpy(&v, res, sizeof (v));
mobj = P_SpawnMobj(x + v[0], y + v[1], z + v[2], type); mobj = P_SpawnMobj(x + v[0], y + v[1], z + v[2], type);
+2 -2
View File
@@ -35,7 +35,7 @@
#include "lua_script.h" #include "lua_script.h"
#include "p_slopes.h" #include "p_slopes.h"
savedata_t savedata; savedata_t savedata = {};
// Block UINT32s to attempt to ensure that the correct data is // Block UINT32s to attempt to ensure that the correct data is
// being sent and received // being sent and received
@@ -3370,7 +3370,7 @@ FUNCINLINE static ATTRINLINE void P_UnArchiveSPGame(savebuffer_t *save, INT16 ma
READSTRINGN(save->p, testname, sizeof(testname)); READSTRINGN(save->p, testname, sizeof(testname));
if (strcmp(testname, timeattackfolder)) if (!fastcmp(testname, timeattackfolder))
{ {
if (modifiedgame) if (modifiedgame)
I_Error("Save game not for this modification."); I_Error("Save game not for this modification.");
+60 -48
View File
@@ -92,7 +92,7 @@
// Map MD5, calculated on level load. // Map MD5, calculated on level load.
// Sent to clients in PT_SERVERINFO. // Sent to clients in PT_SERVERINFO.
// //
unsigned char mapmd5[16]; unsigned char mapmd5[16] = {};
// true when level was loaded from netsave // true when level was loaded from netsave
boolean midgamejoin = false; boolean midgamejoin = false;
@@ -102,22 +102,22 @@ boolean midgamejoin = false;
// Store VERTEXES, LINEDEFS, SIDEDEFS, etc. // Store VERTEXES, LINEDEFS, SIDEDEFS, etc.
// //
size_t numvertexes, numsegs, numsectors, numsubsectors, numnodes, numlines, numsides, nummapthings; size_t numvertexes = 0, numsegs = 0, numsectors = 0, numsubsectors = 0, numnodes = 0, numlines = 0, numsides = 0, nummapthings = 0;
vertex_t *vertexes; vertex_t *vertexes = NULL;
seg_t *segs; seg_t *segs = NULL;
sector_t *sectors; sector_t *sectors = NULL;
subsector_t *subsectors; subsector_t *subsectors = NULL;
node_t *nodes; node_t *nodes = NULL;
line_t *lines; line_t *lines = NULL;
side_t *sides; side_t *sides = NULL;
mapthing_t *mapthings; mapthing_t *mapthings = NULL;
sector_t *spawnsectors; sector_t *spawnsectors = NULL;
line_t *spawnlines; line_t *spawnlines = NULL;
side_t *spawnsides; side_t *spawnsides = NULL;
INT32 numstarposts; INT32 numstarposts = 0;
boolean levelloading; boolean levelloading = false;
virtres_t *curmapvirt; virtres_t *curmapvirt = NULL;
// BLOCKMAP // BLOCKMAP
// Created from axis aligned bounding box // Created from axis aligned bounding box
@@ -127,32 +127,32 @@ virtres_t *curmapvirt;
// by spatial subdivision in 2D. // by spatial subdivision in 2D.
// //
// Blockmap size. // Blockmap size.
INT32 bmapwidth, bmapheight; // size in mapblocks INT32 bmapwidth = 0, bmapheight = 0; // size in mapblocks
INT32 *blockmap; // INT32 for large maps INT32 *blockmap = NULL; // INT32 for large maps
// offsets in blockmap are from here // offsets in blockmap are from here
INT32 *blockmaplump; // Big blockmap INT32 *blockmaplump = NULL; // Big blockmap
// origin of block map // origin of block map
fixed_t bmaporgx, bmaporgy; fixed_t bmaporgx = 0, bmaporgy = 0;
// for thing chains // for thing chains
mobj_t **blocklinks; mobj_t **blocklinks = NULL;
precipmobj_t **precipblocklinks; precipmobj_t **precipblocklinks = NULL;
// REJECT // REJECT
// For fast sight rejection. // For fast sight rejection.
// Speeds up enemy AI by skipping detailed LineOf Sight calculation. // Speeds up enemy AI by skipping detailed LineOf Sight calculation.
// Without special effect, this could be used as a PVS lookup as well. // Without special effect, this could be used as a PVS lookup as well.
// //
UINT8 *rejectmatrix; UINT8 *rejectmatrix = NULL;
// Maintain single and multi player starting spots. // Maintain single and multi player starting spots.
INT32 numdmstarts, numcoopstarts, numredctfstarts, numbluectfstarts; INT32 numdmstarts = 0, numcoopstarts = 0, numredctfstarts = 0, numbluectfstarts = 0;
mapthing_t *deathmatchstarts[MAX_DM_STARTS]; mapthing_t *deathmatchstarts[MAX_DM_STARTS] = {};
mapthing_t *playerstarts[MAXPLAYERS]; mapthing_t *playerstarts[MAXPLAYERS] = {};
mapthing_t *bluectfstarts[MAXPLAYERS]; mapthing_t *bluectfstarts[MAXPLAYERS] = {};
mapthing_t *redctfstarts[MAXPLAYERS]; mapthing_t *redctfstarts[MAXPLAYERS] = {};
// Global state for PartialAddWadFile/MultiSetupWadFiles // Global state for PartialAddWadFile/MultiSetupWadFiles
// Might be replacable with parameters, but non-trivial when the functions are called on separate tics // Might be replacable with parameters, but non-trivial when the functions are called on separate tics
@@ -544,7 +544,18 @@ static void P_LoadSegs(UINT8 *data)
{ {
li->v1 = &vertexes[SHORT(ml->v1)]; li->v1 = &vertexes[SHORT(ml->v1)];
li->v2 = &vertexes[SHORT(ml->v2)]; li->v2 = &vertexes[SHORT(ml->v2)];
#ifdef HWRENDER
if (rendermode == render_opengl)
{
li->fv1.x = FixedToFloat(li->v1->x);
li->fv1.y = FixedToFloat(li->v1->y);
//li->fv1.z = FixedToFloat(li->v1->z); // z is unused in gl
li->fv2.x = FixedToFloat(li->v2->x);
li->fv2.y = FixedToFloat(li->v2->y);
//li->fv2.z = FixedToFloat(li->v2->z);
}
#endif
li->length = P_SegLength(li); li->length = P_SegLength(li);
li->angle = (SHORT(ml->angle))<<FRACBITS; li->angle = (SHORT(ml->angle))<<FRACBITS;
li->offset = (SHORT(ml->offset))<<FRACBITS; li->offset = (SHORT(ml->offset))<<FRACBITS;
@@ -806,7 +817,7 @@ static void P_LoadSectors(UINT8 *data)
skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats); skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats);
// copy table for global usage // copy table for global usage
levelflats = M_Memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t)); levelflats = memcpy(Z_Calloc(numlevelflats * sizeof (*levelflats), PU_LEVEL, NULL), foundflats, numlevelflats * sizeof (levelflat_t));
free(foundflats); free(foundflats);
// search for animated flats and set up // search for animated flats and set up
@@ -1177,10 +1188,10 @@ static void P_LoadLineDefs2(void)
len += strlen(sides[ld->sidenum[1]].text); len += strlen(sides[ld->sidenum[1]].text);
ld->text = Z_Malloc(len, PU_LEVEL, NULL); ld->text = Z_Malloc(len, PU_LEVEL, NULL);
M_Memcpy(ld->text, sides[ld->sidenum[0]].text, strlen(sides[ld->sidenum[0]].text)+1); memcpy(ld->text, sides[ld->sidenum[0]].text, strlen(sides[ld->sidenum[0]].text)+1);
if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text) if (ld->sidenum[1] != 0xffff && sides[ld->sidenum[1]].text)
M_Memcpy(ld->text+strlen(ld->text)+1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text)+1); memcpy(ld->text+strlen(ld->text)+1, sides[ld->sidenum[1]].text, strlen(sides[ld->sidenum[1]].text)+1);
} }
break; break;
@@ -1309,14 +1320,14 @@ static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t *
if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0')
{ {
M_Memcpy(process,msd->bottomtexture,8); memcpy(process,msd->bottomtexture,8);
process[8] = '\0'; process[8] = '\0';
sd->bottomtexture = get_number(process); sd->bottomtexture = get_number(process);
} }
if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0') if (!(msd->midtexture[0] == '-' && msd->midtexture[1] == '\0') || msd->midtexture[1] != '\0')
{ {
M_Memcpy(process,msd->midtexture,8); memcpy(process,msd->midtexture,8);
process[8] = '\0'; process[8] = '\0';
sd->midtexture = get_number(process); sd->midtexture = get_number(process);
} }
@@ -1326,15 +1337,15 @@ static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t *
if (firstside || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') if (firstside || msd->toptexture[0] != '-' || msd->toptexture[1] != '\0')
{ {
M_Memcpy(process,msd->toptexture,8); memcpy(process,msd->toptexture,8);
process[8] = '\0'; process[8] = '\0';
// If they type in O_ or D_ and their music name, just shrug, // If they type in O_ or D_ and their music name, just shrug,
// then copy the rest instead. // then copy the rest instead.
if ((process[0] == 'O' || process[0] == 'D') && process[7]) if ((process[0] == 'O' || process[0] == 'D') && process[7])
M_Memcpy(sd->text, process+2, 6); memcpy(sd->text, process+2, 6);
else // Assume it's a proper music name. else // Assume it's a proper music name.
M_Memcpy(sd->text, process, 6); memcpy(sd->text, process, 6);
sd->text[6] = 0; sd->text[6] = 0;
} }
else else
@@ -1382,7 +1393,7 @@ static void P_LoadSidedefs(void *data)
if (msd->toptexture[0] != '-' || msd->toptexture[1] != '\0') if (msd->toptexture[0] != '-' || msd->toptexture[1] != '\0')
{ {
char process[8+1]; char process[8+1];
M_Memcpy(process,msd->toptexture,8); memcpy(process,msd->toptexture,8);
process[8] = '\0'; process[8] = '\0';
sd->toptexture = get_number(process); sd->toptexture = get_number(process);
} }
@@ -1401,11 +1412,11 @@ static void P_LoadSidedefs(void *data)
if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0')
break; break;
else else
M_Memcpy(process,msd->toptexture,8); memcpy(process,msd->toptexture,8);
if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0') if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0')
M_Memcpy(process+strlen(process), msd->midtexture, 8); memcpy(process+strlen(process), msd->midtexture, 8);
if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0')
M_Memcpy(process+strlen(process), msd->bottomtexture, 8); memcpy(process+strlen(process), msd->bottomtexture, 8);
sd->toptexture = get_number(process); sd->toptexture = get_number(process);
break; break;
@@ -1418,13 +1429,13 @@ static void P_LoadSidedefs(void *data)
if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0') if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0')
break; break;
else else
M_Memcpy(process,msd->toptexture,8); memcpy(process,msd->toptexture,8);
if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0') if (msd->midtexture[0] != '-' || msd->midtexture[1] != '\0')
M_Memcpy(process+strlen(process), msd->midtexture, 8); memcpy(process+strlen(process), msd->midtexture, 8);
if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0') if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0')
M_Memcpy(process+strlen(process), msd->bottomtexture, 8); memcpy(process+strlen(process), msd->bottomtexture, 8);
sd->text = Z_Malloc(strlen(process)+1, PU_LEVEL, NULL); sd->text = Z_Malloc(strlen(process)+1, PU_LEVEL, NULL);
M_Memcpy(sd->text, process, strlen(process)+1); memcpy(sd->text, process, strlen(process)+1);
break; break;
} }
@@ -1887,7 +1898,7 @@ static void P_LoadReject(UINT8 *data, size_t count)
else else
{ {
rejectmatrix = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix rejectmatrix = Z_Malloc(count, PU_LEVEL, NULL); // allocate memory for the reject matrix
M_Memcpy(rejectmatrix, data, count); // copy the data into it memcpy(rejectmatrix, data, count); // copy the data into it
} }
} }
@@ -2201,7 +2212,7 @@ static void P_MakeMapMD5(virtres_t *virt, void *dest)
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
resmd5[i] = (linemd5[i] + sectormd5[i] + thingmd5[i] + sidedefmd5[i]) & 0xFF; resmd5[i] = (linemd5[i] + sectormd5[i] + thingmd5[i] + sidedefmd5[i]) & 0xFF;
M_Memcpy(dest, &resmd5, 16); memcpy(dest, &resmd5, 16);
} }
static void P_LoadMapFromFile(void) static void P_LoadMapFromFile(void)
@@ -2766,7 +2777,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate)
// Make sure all sounds are stopped before Z_FreeTags. // Make sure all sounds are stopped before Z_FreeTags.
S_StopSounds(); S_StopSounds();
if (!S_PrecacheSound()) // if we dont intend to cache our sound effects, wipe them
if (S_CacheSound() == SOUNDCACHE_OFF)
S_ClearSfx(); S_ClearSfx();
// As oddly named as this is, this handles music only. // As oddly named as this is, this handles music only.
@@ -3034,7 +3046,7 @@ static boolean P_CheckSoundReplacements(UINT16 wadnum, char *name, size_t i)
I_FreeSfx(&S_sfx[j]); I_FreeSfx(&S_sfx[j]);
// Re-cache it // Re-cache it
if (S_PrecacheSound()) if (S_CacheSound() == SOUNDCACHE_PRECACHE)
S_sfx[j].data = I_GetSfx(&S_sfx[j]); S_sfx[j].data = I_GetSfx(&S_sfx[j]);
sreplaces++; sreplaces++;
+44 -20
View File
@@ -44,7 +44,7 @@
// Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog // Not sure if this is necessary, but it was in w_wad.c, so I'm putting it here too -Shadow Hog
#include <errno.h> #include <errno.h>
mobj_t *skyboxmo[2]; mobj_t *skyboxmo[2] = {};
// Amount (dx, dy) vector linedef is shifted right to get scroll amount // Amount (dx, dy) vector linedef is shifted right to get scroll amount
#define SCROLL_SHIFT 5 #define SCROLL_SHIFT 5
@@ -93,7 +93,7 @@ static void P_AddSpikeThinker(sector_t *sec, INT32 referrer);
//SoM: 3/7/2000: New sturcture without limits. //SoM: 3/7/2000: New sturcture without limits.
anim_t *lastanim; anim_t *lastanim = NULL;
anim_t *anims = NULL; /// \todo free leak anim_t *anims = NULL; /// \todo free leak
static size_t maxanims; static size_t maxanims;
@@ -252,10 +252,10 @@ void P_InitPicAnims(void)
// Populate the new array // Populate the new array
for (currentPos = animatedLump; *currentPos != UINT8_MAX; i++, currentPos+=23) for (currentPos = animatedLump; *currentPos != UINT8_MAX; i++, currentPos+=23)
{ {
M_Memcpy(&(animdefs[i].istexture), currentPos, 1); // istexture, 1 byte memcpy(&(animdefs[i].istexture), currentPos, 1); // istexture, 1 byte
M_Memcpy(animdefs[i].endname, (currentPos + 1), 9); // endname, 9 bytes memcpy(animdefs[i].endname, (currentPos + 1), 9); // endname, 9 bytes
M_Memcpy(animdefs[i].startname, (currentPos + 10), 9); // startname, 9 bytes memcpy(animdefs[i].startname, (currentPos + 10), 9); // startname, 9 bytes
M_Memcpy(&(animdefs[i].speed), (currentPos + 19), 4); // speed, 4 bytes memcpy(&(animdefs[i].speed), (currentPos + 19), 4); // speed, 4 bytes
} }
Z_Free(animatedLump); Z_Free(animatedLump);
@@ -324,6 +324,7 @@ void P_InitPicAnims(void)
lastanim->speed = LONG(animdefs[i].speed); lastanim->speed = LONG(animdefs[i].speed);
lastanim++; lastanim++;
} }
lastanim->istexture = -1; lastanim->istexture = -1;
R_ClearTextureNumCache(false); R_ClearTextureNumCache(false);
@@ -331,6 +332,7 @@ void P_InitPicAnims(void)
// We'll only be using anims from now on. // We'll only be using anims from now on.
if (animdefs != harddefs) if (animdefs != harddefs)
Z_Free(animdefs); Z_Free(animdefs);
animdefs = NULL; animdefs = NULL;
} }
@@ -361,20 +363,21 @@ void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum)
// Now, let's start parsing this thing // Now, let's start parsing this thing
p = animdefsText; p = animdefsText;
animdefsToken = M_GetToken(p); animdefsToken = M_GetToken(p);
while (animdefsToken != NULL) while (animdefsToken != NULL)
{ {
if (stricmp(animdefsToken, "TEXTURE") == 0) if (fasticmp(animdefsToken, "TEXTURE"))
{ {
Z_Free(animdefsToken); Z_Free(animdefsToken);
P_ParseAnimationDefintion(1); P_ParseAnimationDefintion(1);
} }
else if (stricmp(animdefsToken, "FLAT") == 0) else if (fasticmp(animdefsToken, "FLAT"))
{ {
Z_Free(animdefsToken); Z_Free(animdefsToken);
P_ParseAnimationDefintion(0); P_ParseAnimationDefintion(0);
} }
else if (stricmp(animdefsToken, "OSCILLATE") == 0) else if (fasticmp(animdefsToken, "OSCILLATE"))
{ {
// This probably came off the tail of an earlier definition. It's technically legal syntax, but we don't support it. // This probably came off the tail of an earlier definition. It's technically legal syntax, but we don't support it.
I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"OSCILLATE\" (the animation plays in reverse when it reaches the end) are not supported by SRB2"); I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"OSCILLATE\" (the animation plays in reverse when it reaches the end) are not supported by SRB2");
@@ -383,11 +386,17 @@ void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum)
{ {
I_Error("Error parsing ANIMDEFS lump: Expected \"TEXTURE\" or \"FLAT\", got \"%s\"",animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected \"TEXTURE\" or \"FLAT\", got \"%s\"",animdefsToken);
} }
// parse next line // parse next line
while (*p != '\0' && *p != '\n') ++p; while (*p != '\0' && *p != '\n')
if (*p == '\n') ++p; ++p;
if (*p == '\n')
++p;
animdefsToken = M_GetToken(p); animdefsToken = M_GetToken(p);
} }
Z_Free(animdefsToken); Z_Free(animdefsToken);
Z_Free((void *)animdefsText); Z_Free((void *)animdefsText);
} }
@@ -406,7 +415,8 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where start texture/flat name should be"); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where start texture/flat name should be");
} }
if (stricmp(animdefsToken, "OPTIONAL") == 0)
if (fasticmp(animdefsToken, "OPTIONAL"))
{ {
// This is meaningful to ZDoom - it tells the program NOT to bomb out // This is meaningful to ZDoom - it tells the program NOT to bomb out
// if the textures can't be found - but it's useless in SRB2, so we'll // if the textures can't be found - but it's useless in SRB2, so we'll
@@ -418,7 +428,7 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where start texture/flat name should be"); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where start texture/flat name should be");
} }
else if (stricmp(animdefsToken, "RANGE") == 0) else if (fasticmp(animdefsToken, "RANGE"))
{ {
// Oh. Um. Apparently "OPTIONAL" is a texture name. Naughty. // Oh. Um. Apparently "OPTIONAL" is a texture name. Naughty.
// I should probably handle this more gracefully, but right now // I should probably handle this more gracefully, but right now
@@ -427,15 +437,17 @@ void P_ParseAnimationDefintion(SINT8 istexture)
I_Error("Error parsing ANIMDEFS lump: \"OPTIONAL\" is a keyword; you cannot use it as the startname of an animation"); I_Error("Error parsing ANIMDEFS lump: \"OPTIONAL\" is a keyword; you cannot use it as the startname of an animation");
} }
} }
animdefsTokenLength = strlen(animdefsToken); animdefsTokenLength = strlen(animdefsToken);
if (animdefsTokenLength>8) if (animdefsTokenLength > 8)
{ {
I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken); I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken);
} }
// Search for existing animdef // Search for existing animdef
for (i = 0; i < maxanims; i++) for (i = 0; i < maxanims; i++)
if (stricmp(animdefsToken, animdefs[i].startname) == 0) {
if (fasticmp(animdefsToken, animdefs[i].startname))
{ {
//CONS_Alert(CONS_NOTICE, "Duplicate animation: %s\n", animdefsToken); //CONS_Alert(CONS_NOTICE, "Duplicate animation: %s\n", animdefsToken);
@@ -444,6 +456,7 @@ void P_ParseAnimationDefintion(SINT8 istexture)
Z_Free(animdefsToken); Z_Free(animdefsToken);
return; return;
} }
}
// Not found // Not found
if (i == maxanims) if (i == maxanims)
@@ -467,21 +480,25 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"RANGE\" after \"%s\"'s startname should be", animdefs[i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"RANGE\" after \"%s\"'s startname should be", animdefs[i].startname);
} }
if (stricmp(animdefsToken, "ALLOWDECALS") == 0)
if (fasticmp(animdefsToken, "ALLOWDECALS"))
{ {
// Another ZDoom keyword, ho-hum. Skip it, move on to the next token. // Another ZDoom keyword, ho-hum. Skip it, move on to the next token.
Z_Free(animdefsToken); Z_Free(animdefsToken);
animdefsToken = M_GetToken(NULL); animdefsToken = M_GetToken(NULL);
} }
if (stricmp(animdefsToken, "PIC") == 0)
if (fasticmp(animdefsToken, "PIC"))
{ {
// This is technically legitimate ANIMDEFS syntax, but SRB2 doesn't support it. // This is technically legitimate ANIMDEFS syntax, but SRB2 doesn't support it.
I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"PIC\" (specific frames instead of a consecutive range) are not supported by SRB2"); I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"PIC\" (specific frames instead of a consecutive range) are not supported by SRB2");
} }
if (stricmp(animdefsToken, "RANGE") != 0)
if (!fasticmp(animdefsToken, "RANGE"))
{ {
I_Error("Error parsing ANIMDEFS lump: Expected \"RANGE\" after \"%s\"'s startname, got \"%s\"", animdefs[i].startname, animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected \"RANGE\" after \"%s\"'s startname, got \"%s\"", animdefs[i].startname, animdefsToken);
} }
Z_Free(animdefsToken); Z_Free(animdefsToken);
// Endname // Endname
@@ -490,11 +507,13 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s end texture/flat name should be", animdefs[i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s end texture/flat name should be", animdefs[i].startname);
} }
animdefsTokenLength = strlen(animdefsToken); animdefsTokenLength = strlen(animdefsToken);
if (animdefsTokenLength>8) if (animdefsTokenLength>8)
{ {
I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken); I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken);
} }
strncpy(animdefs[i].endname, animdefsToken, 9); strncpy(animdefs[i].endname, animdefsToken, 9);
Z_Free(animdefsToken); Z_Free(animdefsToken);
@@ -504,15 +523,18 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s \"TICS\" should be", animdefs[i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s \"TICS\" should be", animdefs[i].startname);
} }
if (stricmp(animdefsToken, "RAND") == 0)
if (fasticmp(animdefsToken, "RAND"))
{ {
// This is technically legitimate ANIMDEFS syntax, but SRB2 doesn't support it. // This is technically legitimate ANIMDEFS syntax, but SRB2 doesn't support it.
I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"RAND\" (random duration per frame) are not supported by SRB2"); I_Error("Error parsing ANIMDEFS lump: Animation definitions utilizing \"RAND\" (random duration per frame) are not supported by SRB2");
} }
if (stricmp(animdefsToken, "TICS") != 0)
if (!fasticmp(animdefsToken, "TICS"))
{ {
I_Error("Error parsing ANIMDEFS lump: Expected \"TICS\" in animation definition for \"%s\", got \"%s\"", animdefs[i].startname, animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected \"TICS\" in animation definition for \"%s\", got \"%s\"", animdefs[i].startname, animdefsToken);
} }
Z_Free(animdefsToken); Z_Free(animdefsToken);
// Speed // Speed
@@ -521,6 +543,7 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s animation speed should be", animdefs[i].startname); I_Error("Error parsing ANIMDEFS lump: Unexpected end of file where \"%s\"'s animation speed should be", animdefs[i].startname);
} }
endPos = NULL; endPos = NULL;
#ifndef AVOID_ERRNO #ifndef AVOID_ERRNO
errno = 0; errno = 0;
@@ -535,6 +558,7 @@ void P_ParseAnimationDefintion(SINT8 istexture)
{ {
I_Error("Error parsing ANIMDEFS lump: Expected a positive integer for \"%s\"'s animation speed, got \"%s\"", animdefs[i].startname, animdefsToken); I_Error("Error parsing ANIMDEFS lump: Expected a positive integer for \"%s\"'s animation speed, got \"%s\"", animdefs[i].startname, animdefsToken);
} }
animdefs[i].speed = animSpeed; animdefs[i].speed = animSpeed;
Z_Free(animdefsToken); Z_Free(animdefsToken);
} }
+3 -3
View File
@@ -44,7 +44,7 @@
// Dynamic slopes // Dynamic slopes
#include "p_slopes.h" #include "p_slopes.h"
tic_t leveltime; tic_t leveltime = 0;
// //
// THINKERS // THINKERS
@@ -55,8 +55,8 @@ tic_t leveltime;
// //
// Both the head and tail of the thinker list. // Both the head and tail of the thinker list.
thinker_t thinkercap; thinker_t thinkercap = {};
thinker_t precipcap; thinker_t precipcap = {};
void Command_Numthinkers_f(void) void Command_Numthinkers_f(void)
{ {
+20 -11
View File
@@ -26,11 +26,11 @@
#include "qs22j.h" #include "qs22j.h"
seg_t *curline; seg_t *curline = NULL;
side_t *sidedef; side_t *sidedef = NULL;
line_t *linedef; line_t *linedef = NULL;
sector_t *frontsector; sector_t *frontsector = NULL;
sector_t *backsector; sector_t *backsector = NULL;
// very ugly realloc() of drawsegs at run-time, I upped it to 512 // 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 // instead of 256.. and someone managed to send me a level with
@@ -40,29 +40,38 @@ drawseg_t *drawsegs = NULL;
drawseg_t *ds_p = NULL; drawseg_t *ds_p = NULL;
// indicates doors closed wrt automap bugfix: // indicates doors closed wrt automap bugfix:
INT32 doorclosed; INT32 doorclosed = 0;
// A wall was drawn covering the whole screen, which means we // A wall was drawn covering the whole screen, which means we
// can block off the BSP across that seg. // can block off the BSP across that seg.
boolean g_walloffscreen; boolean g_walloffscreen = false;
boolean R_NoEncore(sector_t *sector, boolean ceiling) boolean R_NoEncore(sector_t *sector, boolean ceiling)
{ {
boolean invertencore = (GETSECSPECIAL(sector->special, 2) == 12 || GETSECSPECIAL(sector->special, 2) == 15); // keeping this incase its used const INT32 invspecial = GETSECSPECIAL(sector->special, 2);
boolean invertencore = (invspecial == 12 || invspecial == 15); // keeping this incase its used
#if 0 // perfect implementation #if 0 // perfect implementation
INT32 val = GETSECSPECIAL(sector->special, 3); const INT32 sprnspecial = GETSECSPECIAL(sector->special, 3);
if (val != 1 && val != 3 // spring panel if (sprnspecial != 1 && sprnspecial != 3 // spring panel
#else // optimised, see #define GETSECSPECIAL(i,j) ((i >> ((j-1)*4))&15) #else // optimised, see #define GETSECSPECIAL(i,j) ((i >> ((j-1)*4))&15)
if ((!(sector->special & (1<<8)) || (sector->special & ((4|8)<<8))) // spring panel if ((!(sector->special & (1<<8)) || (sector->special & ((4|8)<<8))) // spring panel
#endif #endif
&& GETSECSPECIAL(sector->special, 4) != 6) // sneaker panel && GETSECSPECIAL(sector->special, 4) != 6) // sneaker panel
return invertencore; {
return invertencore;
}
if (invertencore) if (invertencore)
{
return false; return false;
}
if (ceiling) if (ceiling)
{
return ((boolean)(sector->flags & SF_FLIPSPECIAL_CEILING)); return ((boolean)(sector->flags & SF_FLIPSPECIAL_CEILING));
}
return ((boolean)(sector->flags & SF_FLIPSPECIAL_FLOOR)); return ((boolean)(sector->flags & SF_FLIPSPECIAL_FLOOR));
} }
+39 -22
View File
@@ -83,7 +83,7 @@ typedef struct
// a patch or sprite is composed of zero or more columns. // a patch or sprite is composed of zero or more columns.
// //
size_t numspritelumps, max_spritelumps; size_t numspritelumps = 0, max_spritelumps = 0;
// textures // textures
INT32 numtextures = 0; // total number of textures found, INT32 numtextures = 0; // total number of textures found,
@@ -110,7 +110,7 @@ UINT8 invertmap[256];
#endif #endif
// for debugging/info purposes // for debugging/info purposes
size_t flatmemory, spritememory, texturememory; // gotta play by 2.2 rules to get this to work static size_t flatmemory = 0, spritememory = 0, texturememory = 0; // gotta play by 2.2 rules to get this to work
// Blends two pixels together, using the equation // Blends two pixels together, using the equation
// that matches the specified alpha style. // that matches the specified alpha style.
@@ -269,7 +269,7 @@ static inline void R_DrawColumnInCache(column_t *patch, UINT8 *cache, texpatch_t
count = cacheheight - position; count = cacheheight - position;
if (count > 0) if (count > 0)
M_Memcpy(cache + position, source, count); memcpy(cache + position, source, count);
patch = (column_t *)((UINT8 *)patch + patch->length + 4); patch = (column_t *)((UINT8 *)patch + patch->length + 4);
} }
@@ -412,7 +412,7 @@ UINT8 *R_GenerateTexture(size_t texnum)
texture->holes = true; texture->holes = true;
blocksize = lumplength; blocksize = lumplength;
block = Z_Calloc(blocksize, PU_LEVEL, &texturecache[texnum]); // will change tag at end of this function block = Z_Calloc(blocksize, PU_LEVEL, &texturecache[texnum]); // will change tag at end of this function
M_Memcpy(block, realpatch, blocksize); memcpy(block, realpatch, blocksize);
texturememory += blocksize; texturememory += blocksize;
// use the patch's column lookup // use the patch's column lookup
@@ -621,7 +621,7 @@ Rloadtextures (INT32 i, INT32 w)
texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL); texture = textures[i] = Z_Calloc(sizeof(texture_t) + sizeof(texpatch_t), PU_STATIC, NULL);
// Set texture properties. // Set texture properties.
M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name));
texture->hash = quickncasehash(texture->name, 8); texture->hash = quickncasehash(texture->name, 8);
texture->width = SHORT(patchlump.width); texture->width = SHORT(patchlump.width);
@@ -854,7 +854,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
Z_Free(patchName); Z_Free(patchName);
} }
patchName = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL); patchName = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL);
M_Memcpy(patchName,texturesToken,texturesTokenLength*sizeof(char)); memcpy(patchName,texturesToken,texturesTokenLength*sizeof(char));
patchName[texturesTokenLength] = '\0'; patchName[texturesTokenLength] = '\0';
} }
@@ -867,7 +867,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after \"%s\"'s patch name should be",patchName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after \"%s\"'s patch name should be",patchName);
} }
if (strcmp(texturesToken,",")!=0) if (!fastcmp(texturesToken,","))
{ {
I_Error("Error parsing TEXTURES lump: Expected \",\" after %s's patch name, got \"%s\"",patchName,texturesToken); I_Error("Error parsing TEXTURES lump: Expected \",\" after %s's patch name, got \"%s\"",patchName,texturesToken);
} }
@@ -907,7 +907,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after patch \"%s\"'s x coordinate should be",patchName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after patch \"%s\"'s x coordinate should be",patchName);
} }
if (strcmp(texturesToken,",")!=0) if (!fastcmp(texturesToken,","))
{ {
I_Error("Error parsing TEXTURES lump: Expected \",\" after patch \"%s\"'s x coordinate, got \"%s\"",patchName,texturesToken); I_Error("Error parsing TEXTURES lump: Expected \",\" after patch \"%s\"'s x coordinate, got \"%s\"",patchName,texturesToken);
} }
@@ -976,18 +976,20 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
{ {
I_Error("Error parsing TEXTURES lump: Unexpected end of file where texture name should be"); I_Error("Error parsing TEXTURES lump: Unexpected end of file where texture name should be");
} }
texturesTokenLength = strlen(texturesToken); texturesTokenLength = strlen(texturesToken);
if (texturesTokenLength>8) if (texturesTokenLength > 8)
{ {
I_Error("Error parsing TEXTURES lump: Texture name \"%s\" exceeds 8 characters",texturesToken); I_Error("Error parsing TEXTURES lump: Texture name \"%s\" exceeds 8 characters",texturesToken);
} }
else else
{ {
memset(&newTextureName, 0, 9); memset(&newTextureName, 0, 9);
M_Memcpy(newTextureName, texturesToken, texturesTokenLength); memcpy(newTextureName, texturesToken, texturesTokenLength);
// ^^ we've confirmed that the token is <= 8 characters so it will never overflow a 9 byte char buffer // ^^ we've confirmed that the token is <= 8 characters so it will never overflow a 9 byte char buffer
strupr(newTextureName); // Just do this now so we don't have to worry about it strupr(newTextureName); // Just do this now so we don't have to worry about it
} }
Z_Free(texturesToken); Z_Free(texturesToken);
// Comma 1 // Comma 1
@@ -996,10 +998,11 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
{ {
I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after texture \"%s\"'s name should be",newTextureName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after texture \"%s\"'s name should be",newTextureName);
} }
else if (strcmp(texturesToken,",")!=0) else if (!fastcmp(texturesToken, ","))
{ {
I_Error("Error parsing TEXTURES lump: Expected \",\" after texture \"%s\"'s name, got \"%s\"",newTextureName,texturesToken); I_Error("Error parsing TEXTURES lump: Expected \",\" after texture \"%s\"'s name, got \"%s\"",newTextureName,texturesToken);
} }
Z_Free(texturesToken); Z_Free(texturesToken);
// Width // Width
@@ -1030,10 +1033,12 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
{ {
I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after texture \"%s\"'s width should be",newTextureName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where comma after texture \"%s\"'s width should be",newTextureName);
} }
if (strcmp(texturesToken,",")!=0)
if (!fastcmp(texturesToken, ","))
{ {
I_Error("Error parsing TEXTURES lump: Expected \",\" after texture \"%s\"'s width, got \"%s\"",newTextureName,texturesToken); I_Error("Error parsing TEXTURES lump: Expected \",\" after texture \"%s\"'s width, got \"%s\"",newTextureName,texturesToken);
} }
Z_Free(texturesToken); Z_Free(texturesToken);
// Height // Height
@@ -1066,27 +1071,30 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
I_Error("Error parsing TEXTURES lump: Unexpected end of file where open curly brace for texture \"%s\" should be",newTextureName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where open curly brace for texture \"%s\" should be",newTextureName);
} }
if (strcmp(texturesToken,"{")==0) if (fastcmp(texturesToken, "{"))
{ {
if (actuallyLoadTexture) if (actuallyLoadTexture)
{ {
// Allocate memory for a zero-patch texture. Obviously, we'll be adding patches momentarily. // Allocate memory for a zero-patch texture. Obviously, we'll be adding patches momentarily.
resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t), PU_STATIC, NULL); resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t), PU_STATIC, NULL);
M_Memcpy(resultTexture->name, newTextureName, 8); memcpy(resultTexture->name, newTextureName, 8);
resultTexture->hash = quickncasehash(newTextureName, 8); resultTexture->hash = quickncasehash(newTextureName, 8);
resultTexture->width = newTextureWidth; resultTexture->width = newTextureWidth;
resultTexture->height = newTextureHeight; resultTexture->height = newTextureHeight;
resultTexture->type = TEXTURETYPE_COMPOSITE; resultTexture->type = TEXTURETYPE_COMPOSITE;
} }
Z_Free(texturesToken); Z_Free(texturesToken);
texturesToken = M_GetToken(NULL); texturesToken = M_GetToken(NULL);
if (texturesToken == NULL) if (texturesToken == NULL)
{ {
I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch definition for texture \"%s\" should be",newTextureName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch definition for texture \"%s\" should be",newTextureName);
} }
while (strcmp(texturesToken,"}")!=0)
while (!fastcmp(texturesToken, "}"))
{ {
if (stricmp(texturesToken, "PATCH")==0) if (fasticmp(texturesToken, "PATCH"))
{ {
Z_Free(texturesToken); Z_Free(texturesToken);
if (resultTexture) if (resultTexture)
@@ -1096,7 +1104,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
// Make room for the new patch // Make room for the new patch
resultTexture = Z_Realloc(resultTexture, sizeof(texture_t) + (resultTexture->patchcount+1)*sizeof(texpatch_t), PU_STATIC, NULL); resultTexture = Z_Realloc(resultTexture, sizeof(texture_t) + (resultTexture->patchcount+1)*sizeof(texpatch_t), PU_STATIC, NULL);
// Populate the uninitialized values in the new patch entry of our array // Populate the uninitialized values in the new patch entry of our array
M_Memcpy(&resultTexture->patches[resultTexture->patchcount], newPatch, sizeof(texpatch_t)); memcpy(&resultTexture->patches[resultTexture->patchcount], newPatch, sizeof(texpatch_t));
// Account for the new number of patches in the texture // Account for the new number of patches in the texture
resultTexture->patchcount++; resultTexture->patchcount++;
// Then free up the memory assigned to R_ParsePatch, as it's unneeded now // Then free up the memory assigned to R_ParsePatch, as it's unneeded now
@@ -1118,6 +1126,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch declaration or right curly brace for texture \"%s\" should be",newTextureName); I_Error("Error parsing TEXTURES lump: Unexpected end of file where patch declaration or right curly brace for texture \"%s\" should be",newTextureName);
} }
} }
if (resultTexture && resultTexture->patchcount == 0) if (resultTexture && resultTexture->patchcount == 0)
{ {
I_Error("Error parsing TEXTURES lump: Texture \"%s\" must have at least one patch",newTextureName); I_Error("Error parsing TEXTURES lump: Texture \"%s\" must have at least one patch",newTextureName);
@@ -1127,10 +1136,13 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
{ {
I_Error("Error parsing TEXTURES lump: Expected \"{\" for texture \"%s\", got \"%s\"",newTextureName,texturesToken); I_Error("Error parsing TEXTURES lump: Expected \"{\" for texture \"%s\", got \"%s\"",newTextureName,texturesToken);
} }
Z_Free(texturesToken); Z_Free(texturesToken);
if (actuallyLoadTexture) return resultTexture; if (actuallyLoadTexture)
else return NULL; return resultTexture;
return NULL;
} }
// Parses the TEXTURES lump... but just to count the number of textures. // Parses the TEXTURES lump... but just to count the number of textures.
@@ -1162,7 +1174,7 @@ int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum)
texturesToken = M_GetToken(texturesText); texturesToken = M_GetToken(texturesText);
while (texturesToken != NULL) while (texturesToken != NULL)
{ {
if (stricmp(texturesToken, "WALLTEXTURE")==0) if (fasticmp(texturesToken, "WALLTEXTURE"))
{ {
numTexturesInLump++; numTexturesInLump++;
Z_Free(texturesToken); Z_Free(texturesToken);
@@ -1172,8 +1184,10 @@ int R_CountTexturesInTEXTURESLump(UINT16 wadNum, UINT16 lumpNum)
{ {
I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\", got \"%s\"",texturesToken); I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\", got \"%s\"",texturesToken);
} }
texturesToken = M_GetToken(NULL); texturesToken = M_GetToken(NULL);
} }
Z_Free(texturesToken); Z_Free(texturesToken);
Z_Free((void *)texturesText); Z_Free((void *)texturesText);
@@ -1211,7 +1225,7 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex)
texturesToken = M_GetToken(texturesText); texturesToken = M_GetToken(texturesText);
while (texturesToken != NULL) while (texturesToken != NULL)
{ {
if (stricmp(texturesToken, "WALLTEXTURE")==0) if (fasticmp(texturesToken, "WALLTEXTURE"))
{ {
Z_Free(texturesToken); Z_Free(texturesToken);
// Get the new texture // Get the new texture
@@ -1227,8 +1241,10 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex)
{ {
I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\", got \"%s\"",texturesToken); I_Error("Error parsing TEXTURES lump: Expected \"WALLTEXTURE\", got \"%s\"",texturesToken);
} }
texturesToken = M_GetToken(NULL); texturesToken = M_GetToken(NULL);
} }
Z_Free(texturesToken); Z_Free(texturesToken);
Z_Free((void *)texturesText); Z_Free((void *)texturesText);
} }
@@ -1334,8 +1350,9 @@ lumpnum_t R_GetFlatNumForName(const char *name)
if (lump == LUMPERROR) if (lump == LUMPERROR)
{ {
if (strcmp(name, SKYFLATNAME)) if (!fastcmp(name, SKYFLATNAME))
CONS_Debug(DBG_SETUP, "R_GetFlatNumForName: Could not find flat %.8s\n", name); CONS_Debug(DBG_SETUP, "R_GetFlatNumForName: Could not find flat %.8s\n", name);
lump = W_CheckNumForName("REDFLR"); lump = W_CheckNumForName("REDFLR");
} }
-2
View File
@@ -91,8 +91,6 @@ UINT8 *R_GetFlat(lumpnum_t flatnum);
void R_InitData(void); void R_InitData(void);
void R_PrecacheLevel(void); void R_PrecacheLevel(void);
extern size_t flatmemory, spritememory, texturememory;
// Retrieval. // Retrieval.
// Floor/ceiling opaque texture tiles, // Floor/ceiling opaque texture tiles,
// lookup by name. For animation? // lookup by name. For animation?
+8 -4
View File
@@ -114,6 +114,11 @@ typedef struct
fixed_t x, y, z; fixed_t x, y, z;
} vertex_t; } vertex_t;
typedef struct
{
float x, y/*, z*/;
} floatvertex_t;
// Forward of linedefs, for sectors. // Forward of linedefs, for sectors.
struct line_s; struct line_s;
@@ -543,12 +548,11 @@ typedef struct seg_s
sector_t *frontsector; sector_t *frontsector;
sector_t *backsector; sector_t *backsector;
fixed_t length; // precalculated seg length fixed_t length; // precalculated seg length
#ifdef HWRENDER #ifdef HWRENDER
// new pointers so that AdjustSegs doesn't mess with v1/v2 floatvertex_t fv1;
polyvertex_t *pv1; floatvertex_t fv2;
polyvertex_t *pv2;
#endif #endif
polyobj_t *polyseg; polyobj_t *polyseg;
+33 -22
View File
@@ -41,40 +41,40 @@
/** \brief view info /** \brief view info
*/ */
INT32 viewwidth, viewheight, viewwindowx, viewwindowy; INT32 viewwidth = 0, viewheight = 0, viewwindowx = 0, viewwindowy = 0;
// ========================================================================= // =========================================================================
// COLUMN DRAWING CODE STUFF // COLUMN DRAWING CODE STUFF
// ========================================================================= // =========================================================================
drawcolumndata_t g_dc; drawcolumndata_t g_dc = {};
// ----------------------- // -----------------------
// translucency stuff here // translucency stuff here
// ----------------------- // -----------------------
#define NUMTRANSTABLES 9 // how many translucency tables are used #define NUMTRANSTABLES 9 // how many translucency tables are used
UINT8 *transtables; // translucency tables UINT8 *transtables = NULL; // translucency tables
UINT8 *blendtables[NUMBLENDMAPS]; UINT8 *blendtables[NUMBLENDMAPS] = {};
// -------------------------------------------- // --------------------------------------------
// c drawer routines // c drawer routines
// -------------------------------------------- // --------------------------------------------
coldrawfunc_t *colfunc; coldrawfunc_t *colfunc = NULL;
coldrawfunc_t *colfuncs[COLDRAWFUNC_MAX]; coldrawfunc_t *colfuncs[COLDRAWFUNC_MAX] = {};
int colfunctype; int colfunctype = 0;
// ========================================================================= // =========================================================================
// SPAN DRAWING CODE STUFF // SPAN DRAWING CODE STUFF
// ========================================================================= // =========================================================================
drawspandata_t g_ds; drawspandata_t g_ds = {};
// Vectors for Software's tilted slope drawers // Vectors for Software's tilted slope drawers
floatv3_t *ds_su, *ds_sv, *ds_sz; floatv3_t *ds_su = NULL, *ds_sv = NULL, *ds_sz = NULL;
float focallengthf; float focallengthf = 0.0f;
// For, uh, tilted lighting, duh. // For, uh, tilted lighting, duh.
//static INT32 *tiltlighting; //static INT32 *tiltlighting;
@@ -83,8 +83,8 @@ float focallengthf;
// c drawer routines // c drawer routines
// -------------------------------------------- // --------------------------------------------
spandrawfunc_t *spanfunc; spandrawfunc_t *spanfunc = NULL;
spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX]; spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX] = {};
// ========================================================================== // ==========================================================================
// OLD DOOM FUZZY EFFECT // OLD DOOM FUZZY EFFECT
@@ -105,14 +105,15 @@ spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX];
#define DEFAULT_STARTTRANSCOLOR 160 #define DEFAULT_STARTTRANSCOLOR 160
#define NUM_PALETTE_ENTRIES 256 #define NUM_PALETTE_ENTRIES 256
static UINT8 **translationtablecache[TT_CACHE_SIZE] = {NULL}; static UINT8 **translationtablecache[TT_CACHE_SIZE] = {};
static UINT8 **localtranslationtablecache[MAXLOCALSKINS] = {NULL}; static UINT8 **localtranslationtablecache[MAXLOCALSKINS] = {};
CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1] = {};
struct GenerateBlendTables_State struct GenerateBlendTables_State
{ {
RGBA_t *LocalPalette; RGBA_t *LocalPalette;
RGBA_t *gammaCorrectedPalette;
}; };
static void R_GenerateBlendTables_Core(struct GenerateBlendTables_State *state); static void R_GenerateBlendTables_Core(struct GenerateBlendTables_State *state);
@@ -126,6 +127,7 @@ static void R_GenerateBlendTables_Thread(void *userdata)
R_GenerateBlendTables_Core(state); R_GenerateBlendTables_Core(state);
free(state->LocalPalette); free(state->LocalPalette);
free(state->gammaCorrectedPalette);
free(state); free(state);
} }
#endif #endif
@@ -154,26 +156,33 @@ void R_InitTranslucencyTables(void)
} }
static colorlookup_t transtab_lut; static colorlookup_t transtab_lut;
static colorlookup_t transtab_lut_corrected;
static void BlendTab_Translucent(UINT8 *table, int style, UINT8 blendamt) static void BlendTab_Translucent(UINT8 *table, int style, UINT8 blendamt)
{ {
INT16 bg, fg; INT16 bg, fg;
RGBA_t backrgba, frontrgba, result;
if (table == NULL) if (table == NULL)
I_Error("BlendTab_Translucent: input table was NULL!"); I_Error("BlendTab_Translucent: input table was NULL!");
for (bg = 0; bg < 0x100; bg++) for (bg = 0; bg < 0x100; bg++)
{ {
backrgba = pGammaCorrectedPalette[bg];
for (fg = 0; fg < 0x100; fg++) for (fg = 0; fg < 0x100; fg++)
{ {
RGBA_t backrgba = V_GetColor(bg); frontrgba = pGammaCorrectedPalette[fg];
RGBA_t frontrgba = V_GetColor(fg);
RGBA_t result;
#if 0 // perfect implementation
result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF);
result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt); result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt);
table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue);
#else // performance scrabbler
result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF);
result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt);
table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut_corrected, result.s.red, result.s.green, result.s.blue); // pGammaCorrectedPalette
#endif
} }
} }
} }
@@ -224,7 +233,7 @@ static void BlendTab_Modulative(UINT8 *table)
RGBA_t frontrgba = V_GetColor(fg); RGBA_t frontrgba = V_GetColor(fg);
RGBA_t result; RGBA_t result;
result.rgba = ASTBlendPixel(backrgba, frontrgba, AST_MODULATE, 0); result.rgba = ASTBlendPixel(backrgba, frontrgba, AST_MODULATE, 0);
table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut_corrected, result.s.red, result.s.green, result.s.blue);
} }
} }
} }
@@ -278,11 +287,12 @@ void R_GenerateBlendTables(void)
size_t palsize = 256 * sizeof(RGBA_t); size_t palsize = 256 * sizeof(RGBA_t);
state->LocalPalette = static_cast<RGBA_t *>(memcpy(malloc(palsize), pLocalPalette, palsize)); state->LocalPalette = static_cast<RGBA_t *>(memcpy(malloc(palsize), pLocalPalette, palsize));
state->gammaCorrectedPalette = static_cast<RGBA_t *>(memcpy(malloc(palsize), pGammaCorrectedPalette, palsize));
I_spawn_thread("blend-tables", I_spawn_thread("blend-tables",
R_GenerateBlendTables_Thread, state); R_GenerateBlendTables_Thread, state);
#else #else
struct GenerateBlendTables_State state = {pLocalPalette}; struct GenerateBlendTables_State state = {pLocalPalette, pGammaCorrectedPalette};
R_GenerateBlendTables_Core(&state); R_GenerateBlendTables_Core(&state);
#endif #endif
} }
@@ -290,6 +300,7 @@ void R_GenerateBlendTables(void)
static void R_GenerateBlendTables_Core(struct GenerateBlendTables_State *state) static void R_GenerateBlendTables_Core(struct GenerateBlendTables_State *state)
{ {
InitColorLUT(&transtab_lut, state->LocalPalette, false); InitColorLUT(&transtab_lut, state->LocalPalette, false);
InitColorLUT(&transtab_lut_corrected, state->gammaCorrectedPalette, false);
// Additive // Additive
BlendTab_GenerateMaps(blendtab_add, AST_ADD, BlendTab_Translucent); BlendTab_GenerateMaps(blendtab_add, AST_ADD, BlendTab_Translucent);
@@ -655,7 +666,7 @@ void R_VideoErase(size_t ofs, INT32 count)
// is not optimal, e.g. byte by byte on // is not optimal, e.g. byte by byte on
// a 32bit CPU, as GNU GCC/Linux libc did // a 32bit CPU, as GNU GCC/Linux libc did
// at one point. // at one point.
M_Memcpy(vid.screens[0] + ofs, vid.screens[1] + ofs, count); memcpy(vid.screens[0] + ofs, vid.screens[1] + ofs, count);
} }
// ========================================================================== // ==========================================================================
+12 -10
View File
@@ -28,6 +28,8 @@
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
#include "cxxutil.hpp"
// ========================================================================== // ==========================================================================
// SPANS // SPANS
// ========================================================================== // ==========================================================================
@@ -315,10 +317,10 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
endz = 1.f/iz; endz = 1.f/iz;
endu = uz*endz; endu = uz*endz;
endv = vz*endz; endv = vz*endz;
stepu = (INT64)((endu - startu) * INVSPAN); stepu = srb2::floattoint<float, INT64>((endu - startu) * INVSPAN);
stepv = (INT64)((endv - startv) * INVSPAN); stepv = srb2::floattoint<float, INT64>((endv - startv) * INVSPAN);
u = (INT64)(startu); u = srb2::floattoint<float, INT64>(startu);
v = (INT64)(startv); v = srb2::floattoint<float, INT64>(startv);
const INT32 x1 = ds->x1; const INT32 x1 = ds->x1;
@@ -345,8 +347,8 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
{ {
if (width == 1) if (width == 1)
{ {
u = (INT64)(startu); u = srb2::floattoint<float, INT64>(startu);
v = (INT64)(startv); v = srb2::floattoint<float, INT64>(startv);
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
colormap = planezlight[tiltlight[ds->x1]] + colormap_diff; colormap = planezlight[tiltlight[ds->x1]] + colormap_diff;
if constexpr (Type & DS_RIPPLE) if constexpr (Type & DS_RIPPLE)
@@ -366,10 +368,10 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
endu = uz*endz; endu = uz*endz;
endv = vz*endz; endv = vz*endz;
left = 1.f/left; left = 1.f/left;
stepu = (INT64)((endu - startu) * left); stepu = srb2::floattoint<float, INT64>((endu - startu) * left);
stepv = (INT64)((endv - startv) * left); stepv = srb2::floattoint<float, INT64>((endv - startv) * left);
u = (INT64)(startu); u = srb2::floattoint<float, INT64>(startu);
v = (INT64)(startv); v = srb2::floattoint<float, INT64>(startv);
for (; width != 0; width--) for (; width != 0; width--)
{ {
+25 -25
View File
@@ -49,54 +49,54 @@
// increment every time a check is made // increment every time a check is made
size_t validcount = 1; size_t validcount = 1;
INT32 centerx, centery; INT32 centerx = 0, centery = 0;
fixed_t centerxfrac, centeryfrac; fixed_t centerxfrac = 0, centeryfrac = 0;
fixed_t projection; fixed_t projection = 0;
fixed_t projectiony; // aspect ratio fixed_t projectiony = 0; // aspect ratio
fixed_t fovtan; // field of view fixed_t fovtan = 0; // field of view
// just for profiling purposes // just for profiling purposes
size_t framecount; size_t framecount = 0;
size_t loopcount; size_t loopcount = 0;
fixed_t viewx, viewy, viewz; fixed_t viewx = 0, viewy = 0, viewz = 0;
angle_t viewangle, aimingangle, viewroll; angle_t viewangle = 0, aimingangle = 0, viewroll = 0;
UINT8 viewssnum = 0; UINT8 viewssnum = 0;
fixed_t viewcos, viewsin; fixed_t viewcos = 0, viewsin = 0;
boolean skyVisible; boolean skyVisible = 0;
boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible for each splitscreen player boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS] = {}; // saved values of skyVisible for each splitscreen player
sector_t *viewsector; sector_t *viewsector = NULL;
player_t *viewplayer; player_t *viewplayer = NULL;
fixed_t renderdeltatics; fixed_t renderdeltatics = 0;
boolean renderisnewtic; boolean renderisnewtic = true;
// //
// precalculated math tables // precalculated math tables
// //
angle_t clipangle; angle_t clipangle = 0;
angle_t doubleclipangle; angle_t doubleclipangle = 0;
// The viewangletox[viewangle + FINEANGLES/4] lookup // The viewangletox[viewangle + FINEANGLES/4] lookup
// maps the visible view angles to screen X coordinates, // maps the visible view angles to screen X coordinates,
// flattening the arc to a flat projection plane. // flattening the arc to a flat projection plane.
// There will be many angles mapped to the same X. // There will be many angles mapped to the same X.
INT32 viewangletox[FINEANGLES/2]; INT32 viewangletox[FINEANGLES/2] = {};
// The xtoviewangleangle[] table maps a screen pixel // The xtoviewangleangle[] table maps a screen pixel
// to the lowest viewangle that maps back to x ranges // to the lowest viewangle that maps back to x ranges
// from clipangle to -clipangle. // from clipangle to -clipangle.
angle_t *xtoviewangle = NULL; angle_t *xtoviewangle = NULL;
lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE] = {};
lighttable_t *scalelightfixed[MAXLIGHTSCALE]; lighttable_t *scalelightfixed[MAXLIGHTSCALE] = {};
lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ] = {};
// Hack to support extra boom colormaps. // Hack to support extra boom colormaps.
size_t num_extra_colormaps; size_t num_extra_colormaps = 0;
extracolormap_t extra_colormaps[MAXCOLORMAPS]; extracolormap_t extra_colormaps[MAXCOLORMAPS] = {};
// Performance stats // Performance stats
precise_t ps_prevframetime = 0; precise_t ps_prevframetime = 0;
@@ -187,7 +187,7 @@ consvar_t cv_shadowoffs = {"offsetshadows", "Off", CV_SAVE, CV_OnOff, NULL,
consvar_t cv_skybox = {"skybox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_skybox = {"skybox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_ffloorclip = {"r_ffloorclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_ffloorclip = {"r_ffloorclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_spriteclip = {"r_spriteclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_spriteclip = {"r_spriteclip", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_softcyancut = {"softwarecyancut", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_softcyancut = {"softwarecyancut", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_translucency = {"translucency", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist = {"drawdist", "Infinite", CV_SAVE, drawdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE|CV_CALL|CV_NOINIT, drawdist_precip_cons_t, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE|CV_CALL|CV_NOINIT, drawdist_precip_cons_t, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL};
+63 -51
View File
@@ -46,13 +46,14 @@ static void R_ParseSpriteInfoFrame(spriteinfo_t *info)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite frame should be"); I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite frame should be");
} }
sprinfoTokenLength = strlen(sprinfoToken); sprinfoTokenLength = strlen(sprinfoToken);
if (sprinfoTokenLength != 1) if (sprinfoTokenLength != 1)
{ {
I_Error("Error parsing SPRTINFO lump: Invalid frame \"%s\"",sprinfoToken); I_Error("Error parsing SPRTINFO lump: Invalid frame \"%s\"",sprinfoToken);
} }
else
frameChar = sprinfoToken; frameChar = sprinfoToken;
frameFrame = R_Char2Frame(frameChar[0]); frameFrame = R_Char2Frame(frameChar[0]);
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
@@ -61,53 +62,53 @@ static void R_ParseSpriteInfoFrame(spriteinfo_t *info)
sprinfoToken = M_GetToken(NULL); sprinfoToken = M_GetToken(NULL);
if (sprinfoToken == NULL) if (sprinfoToken == NULL)
I_Error("Error parsing SPRTINFO lump: Missing sprite info"); I_Error("Error parsing SPRTINFO lump: Missing sprite info");
else
if (fastcmp(sprinfoToken, "{"))
{ {
if (strcmp(sprinfoToken,"{")==0) Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
if (sprinfoToken == NULL)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite info should be");
}
while (!fastcmp(sprinfoToken, "}"))
{
if (fasticmp(sprinfoToken, "XPIVOT"))
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
frameXPivot = atoi(sprinfoToken);
}
else if (fasticmp(sprinfoToken, "YPIVOT"))
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
frameYPivot = atoi(sprinfoToken);
}
else if (fasticmp(sprinfoToken, "ROTAXIS"))
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
if (fasticmp(sprinfoToken, "X") || fasticmp(sprinfoToken, "XAXIS") || fasticmp(sprinfoToken, "ROLL"))
frameRotAxis = ROTAXIS_X;
else if (fasticmp(sprinfoToken, "Y") || fasticmp(sprinfoToken, "YAXIS") || fasticmp(sprinfoToken, "PITCH"))
frameRotAxis = ROTAXIS_Y;
else if (fasticmp(sprinfoToken, "Z") || fasticmp(sprinfoToken, "ZAXIS") || fasticmp(sprinfoToken, "YAW"))
frameRotAxis = ROTAXIS_Z;
}
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL); sprinfoToken = M_GetToken(NULL);
if (sprinfoToken == NULL) if (sprinfoToken == NULL)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite info should be"); I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite info or right curly brace should be");
}
while (strcmp(sprinfoToken,"}")!=0)
{
if (stricmp(sprinfoToken, "XPIVOT")==0)
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
frameXPivot = atoi(sprinfoToken);
}
else if (stricmp(sprinfoToken, "YPIVOT")==0)
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
frameYPivot = atoi(sprinfoToken);
}
else if (stricmp(sprinfoToken, "ROTAXIS")==0)
{
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
if ((stricmp(sprinfoToken, "X")==0) || (stricmp(sprinfoToken, "XAXIS")==0) || (stricmp(sprinfoToken, "ROLL")==0))
frameRotAxis = ROTAXIS_X;
else if ((stricmp(sprinfoToken, "Y")==0) || (stricmp(sprinfoToken, "YAXIS")==0) || (stricmp(sprinfoToken, "PITCH")==0))
frameRotAxis = ROTAXIS_Y;
else if ((stricmp(sprinfoToken, "Z")==0) || (stricmp(sprinfoToken, "ZAXIS")==0) || (stricmp(sprinfoToken, "YAW")==0))
frameRotAxis = ROTAXIS_Z;
}
Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL);
if (sprinfoToken == NULL)
{
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite info or right curly brace should be");
}
} }
} }
Z_Free(sprinfoToken);
} }
Z_Free(sprinfoToken);
// set fields // set fields
info->pivot[frameFrame].x = frameXPivot; info->pivot[frameFrame].x = frameXPivot;
info->pivot[frameFrame].y = frameYPivot; info->pivot[frameFrame].y = frameYPivot;
@@ -137,6 +138,7 @@ static void R_ParseSpriteInfo(boolean spr2)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite name should be"); I_Error("Error parsing SPRTINFO lump: Unexpected end of file where sprite name should be");
} }
sprinfoTokenLength = strlen(sprinfoToken); sprinfoTokenLength = strlen(sprinfoToken);
if (sprinfoTokenLength != 4) if (sprinfoTokenLength != 4)
{ {
@@ -145,10 +147,11 @@ static void R_ParseSpriteInfo(boolean spr2)
else else
{ {
memset(&newSpriteName, 0, 5); memset(&newSpriteName, 0, 5);
M_Memcpy(newSpriteName, sprinfoToken, sprinfoTokenLength); memcpy(newSpriteName, sprinfoToken, sprinfoTokenLength);
// ^^ we've confirmed that the token is == 4 characters so it will never overflow a 5 byte char buffer // ^^ we've confirmed that the token is == 4 characters so it will never overflow a 5 byte char buffer
strupr(newSpriteName); // Just do this now so we don't have to worry about it strupr(newSpriteName); // Just do this now so we don't have to worry about it
} }
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
if (!spr2) if (!spr2)
@@ -157,7 +160,8 @@ static void R_ParseSpriteInfo(boolean spr2)
{ {
if (i == NUMSPRITES) if (i == NUMSPRITES)
I_Error("Error parsing SPRTINFO lump: Unknown sprite name \"%s\"", newSpriteName); I_Error("Error parsing SPRTINFO lump: Unknown sprite name \"%s\"", newSpriteName);
if (!memcmp(newSpriteName,sprnames[i],4))
if (!memcmp(newSpriteName,sprnames[i], 4))
{ {
sprnum = static_cast<spritenum_t>(i); sprnum = static_cast<spritenum_t>(i);
break; break;
@@ -175,17 +179,20 @@ static void R_ParseSpriteInfo(boolean spr2)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where open curly brace for sprite \"%s\" should be",newSpriteName); I_Error("Error parsing SPRTINFO lump: Unexpected end of file where open curly brace for sprite \"%s\" should be",newSpriteName);
} }
if (strcmp(sprinfoToken,"{")==0)
if (fastcmp(sprinfoToken, "{"))
{ {
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL); sprinfoToken = M_GetToken(NULL);
if (sprinfoToken == NULL) if (sprinfoToken == NULL)
{ {
I_Error("Error parsing SPRTINFO lump: Unexpected end of file where definition for sprite \"%s\" should be",newSpriteName); I_Error("Error parsing SPRTINFO lump: Unexpected end of file where definition for sprite \"%s\" should be",newSpriteName);
} }
while (strcmp(sprinfoToken,"}")!=0)
while (!fastcmp(sprinfoToken, "}"))
{ {
if (stricmp(sprinfoToken, "SKIN")==0) if (fasticmp(sprinfoToken, "SKIN"))
{ {
INT32 skinnum; INT32 skinnum;
char *skinName = NULL; char *skinName = NULL;
@@ -204,7 +211,7 @@ static void R_ParseSpriteInfo(boolean spr2)
// copy skin name yada yada // copy skin name yada yada
sprinfoTokenLength = strlen(sprinfoToken); sprinfoTokenLength = strlen(sprinfoToken);
skinName = (char *)Z_Malloc((sprinfoTokenLength+1)*sizeof(char),PU_STATIC,NULL); skinName = (char *)Z_Malloc((sprinfoTokenLength+1)*sizeof(char),PU_STATIC,NULL);
M_Memcpy(skinName,sprinfoToken,sprinfoTokenLength*sizeof(char)); memcpy(skinName,sprinfoToken,sprinfoTokenLength*sizeof(char));
skinName[sprinfoTokenLength] = '\0'; skinName[sprinfoTokenLength] = '\0';
strlwr(skinName); strlwr(skinName);
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
@@ -216,10 +223,11 @@ static void R_ParseSpriteInfo(boolean spr2)
skinnumbers[foundskins] = skinnum; skinnumbers[foundskins] = skinnum;
foundskins++; foundskins++;
} }
else if (stricmp(sprinfoToken, "FRAME")==0) else if (fasticmp(sprinfoToken, "FRAME"))
{ {
R_ParseSpriteInfoFrame(info); R_ParseSpriteInfoFrame(info);
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
if (spr2) if (spr2)
{ {
if (!foundskins) if (!foundskins)
@@ -232,11 +240,11 @@ static void R_ParseSpriteInfo(boolean spr2)
skin = &localskins[allskins[skinnum].localnum]; skin = &localskins[allskins[skinnum].localnum];
else else
skin = &skins[allskins[skinnum].localnum]; skin = &skins[allskins[skinnum].localnum];
M_Memcpy(&skin->sprinfo, info, sizeof(spriteinfo_t)); memcpy(&skin->sprinfo, info, sizeof(spriteinfo_t));
} }
} }
else else
M_Memcpy(&spriteinfo[sprnum], info, sizeof(spriteinfo_t)); memcpy(&spriteinfo[sprnum], info, sizeof(spriteinfo_t));
} }
else else
{ {
@@ -254,6 +262,7 @@ static void R_ParseSpriteInfo(boolean spr2)
{ {
I_Error("Error parsing SPRTINFO lump: Expected \"{\" for sprite \"%s\", got \"%s\"",newSpriteName,sprinfoToken); I_Error("Error parsing SPRTINFO lump: Expected \"{\" for sprite \"%s\", got \"%s\"",newSpriteName,sprinfoToken);
} }
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
Z_Free(info); Z_Free(info);
} }
@@ -291,15 +300,18 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum)
while (sprinfoToken != NULL) while (sprinfoToken != NULL)
{ {
CONS_Printf("Attempting to parse le SPRTINFO lump for ya..\n"); CONS_Printf("Attempting to parse le SPRTINFO lump for ya..\n");
if (!stricmp(sprinfoToken, "SPRITE"))
if (fasticmp(sprinfoToken, "SPRITE"))
R_ParseSpriteInfo(false); R_ParseSpriteInfo(false);
else if (!stricmp(sprinfoToken, "SPRITE2")) else if (fasticmp(sprinfoToken, "SPRITE2"))
R_ParseSpriteInfo(true); R_ParseSpriteInfo(true);
else else
I_Error("Error parsing SPRTINFO lump: Unknown keyword \"%s\"", sprinfoToken); I_Error("Error parsing SPRTINFO lump: Unknown keyword \"%s\"", sprinfoToken);
Z_Free(sprinfoToken); Z_Free(sprinfoToken);
sprinfoToken = M_GetToken(NULL); sprinfoToken = M_GetToken(NULL);
} }
Z_Free((void *)sprinfoText); Z_Free((void *)sprinfoText);
} }
@@ -359,7 +371,7 @@ patch_t *Patch_Create(softwarepatch_t *source, size_t srcsize, void *dest)
I_Error("Patch_Create: no column data!"); I_Error("Patch_Create: no column data!");
patch->columns = static_cast<UINT8*>(Z_Calloc(colsize, PU_PATCH_DATA, NULL)); patch->columns = static_cast<UINT8*>(Z_Calloc(colsize, PU_PATCH_DATA, NULL));
M_Memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize); memcpy(patch->columns, ((UINT8 *)source + LONG(source->columnofs[0])), colsize);
} }
return patch; return patch;
+3 -3
View File
@@ -23,8 +23,8 @@
// //
// Angles precalculated in R_InitSprites. // Angles precalculated in R_InitSprites.
// //
fixed_t rollcosang[ROTANGLES]; fixed_t rollcosang[ROTANGLES] = {};
fixed_t rollsinang[ROTANGLES]; fixed_t rollsinang[ROTANGLES] = {};
INT32 R_GetRollAngle(angle_t rollangle) INT32 R_GetRollAngle(angle_t rollangle)
{ {
@@ -241,7 +241,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
while (dy--) while (dy--)
{ {
M_Memcpy(dest, src, width * sizeof(UINT16)); memcpy(dest, src, width * sizeof(UINT16));
dest += width; dest += width;
src += newwidth; src += newwidth;
} }
+2 -2
View File
@@ -720,7 +720,7 @@ void R_DrawPlanes(void)
srb2::ThreadPool::Sema tp_sema; srb2::ThreadPool::Sema tp_sema;
srb2::g_main_threadpool->begin_sema(); srb2::g_main_threadpool->begin_sema();
#endif #endif
for (i = 0; i < MAXVISPLANES; i++, pl++) for (i = 0; i < MAXVISPLANES; i++)
{ {
for (pl = visplanes[i]; pl; pl = pl->next) for (pl = visplanes[i]; pl; pl = pl->next)
{ {
@@ -755,7 +755,7 @@ void R_DrawSkyPlanes(void)
srb2::ThreadPool::Sema tp_sema; srb2::ThreadPool::Sema tp_sema;
srb2::g_main_threadpool->begin_sema(); srb2::g_main_threadpool->begin_sema();
#endif #endif
for (i = 0; i < MAXVISPLANES; i++, pl++) for (i = 0; i < MAXVISPLANES; i++)
{ {
for (pl = visplanes[i]; pl; pl = pl->next) for (pl = visplanes[i]; pl; pl = pl->next)
{ {
+6 -6
View File
@@ -21,16 +21,16 @@
#include "r_things.h" #include "r_things.h"
#include "r_sky.h" #include "r_sky.h"
UINT8 portalrender; /**< When rendering a portal, it establishes the depth of the current BSP traversal. */ UINT8 portalrender = 0; /**< When rendering a portal, it establishes the depth of the current BSP traversal. */
// Linked list for portals. // Linked list for portals.
portal_t *portal_base, *portal_cap; portal_t *portal_base = NULL, *portal_cap = NULL;
line_t *portalclipline; line_t *portalclipline = NULL;
sector_t *portalcullsector; sector_t *portalcullsector = NULL;
INT32 portalclipstart, portalclipend; INT32 portalclipstart = 0, portalclipend = 0;
portal_t *g_portal; // is curline a portal seg? portal_t *g_portal = NULL; // is curline a portal seg?
void Portal_InitList (void) void Portal_InitList (void)
{ {
+13 -11
View File
@@ -30,6 +30,8 @@
#include "core/memory.h" #include "core/memory.h"
#include "cxxutil.hpp"
#define HEIGHTBITS 12 #define HEIGHTBITS 12
#define HEIGHTUNIT (1<<HEIGHTBITS) #define HEIGHTUNIT (1<<HEIGHTBITS)
@@ -45,10 +47,10 @@ static INT32 toptexture, bottomtexture, midtexture;
static bool topremap, bottomremap, midremap; static bool topremap, bottomremap, midremap;
static INT32 numthicksides, numbackffloors; static INT32 numthicksides, numbackffloors;
angle_t rw_normalangle; angle_t rw_normalangle = 0;
// angle to line origin // angle to line origin
angle_t rw_angle1; angle_t rw_angle1 = 0;
fixed_t rw_distance; fixed_t rw_distance = 0;
// //
// regular wall // regular wall
@@ -1718,7 +1720,7 @@ static void R_AllocClippingTables(size_t range)
{ {
// Check if it's in range of the openings // Check if it's in range of the openings
#define CHECK(which) \ #define CHECK(which) \
if (which + drawseg->x1 >= oldopenings && which + drawseg->x1 <= oldlast) \ if (which != NULL && which + drawseg->x1 >= oldopenings && which + drawseg->x1 <= oldlast) \
which = (which - oldopenings) + openings which = (which - oldopenings) + openings
CHECK(drawseg->sprtopclip); CHECK(drawseg->sprtopclip);
CHECK(drawseg->sprbottomclip); CHECK(drawseg->sprbottomclip);
@@ -1752,7 +1754,7 @@ static void R_AllocTextureColumnTables(size_t range)
{ {
// Check if it's in range of the tables // Check if it's in range of the tables
#define CHECK(which) \ #define CHECK(which) \
if (which + drawseg->x1 >= oldtable && which + drawseg->x1 <= oldlast) \ if (which != NULL && which + drawseg->x1 >= oldtable && which + drawseg->x1 <= oldlast) \
which = (which - oldtable) + texturecolumntable which = (which - oldtable) + texturecolumntable
CHECK(drawseg->maskedtexturecol); CHECK(drawseg->maskedtexturecol);
CHECK(drawseg->thicksidecol); CHECK(drawseg->thicksidecol);
@@ -1890,8 +1892,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
det = a1*b2 - a2*b1; det = a1*b2 - a2*b1;
ds_p->leftpos.x = segleft.x = DoubleToFixed((b2*c1 - b1*c2)/det); ds_p->leftpos.x = segleft.x = srb2::floattofixed<double>((b2*c1 - b1*c2)/det);
ds_p->leftpos.y = segleft.y = DoubleToFixed((a1*c2 - a2*c1)/det); ds_p->leftpos.y = segleft.y = srb2::floattofixed<double>((a1*c2 - a2*c1)/det);
// right // right
temp = xtoviewangle[stop]+viewangle; temp = xtoviewangle[stop]+viewangle;
@@ -1902,8 +1904,8 @@ void R_StoreWallRange(INT32 start, INT32 stop)
det = a1*b2 - a2*b1; det = a1*b2 - a2*b1;
ds_p->rightpos.x = segright.x = DoubleToFixed((b2*c1 - b1*c2)/det); ds_p->rightpos.x = segright.x = srb2::floattofixed<double>((b2*c1 - b1*c2)/det);
ds_p->rightpos.y = segright.y = DoubleToFixed((a1*c2 - a2*c1)/det); ds_p->rightpos.y = segright.y = srb2::floattofixed<double>((a1*c2 - a2*c1)/det);
} }
#define SLOPEPARAMS(slope, end1, end2, normalheight) \ #define SLOPEPARAMS(slope, end1, end2, normalheight) \
@@ -3001,14 +3003,14 @@ void R_StoreWallRange(INT32 start, INT32 stop)
if (((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip) if (((ds_p->silhouette & SIL_TOP) || maskedtexture) && !ds_p->sprtopclip)
{ {
M_Memcpy(lastopening, ceilingclip + start, 2*(rw_stopx - start)); memcpy(lastopening, ceilingclip + start, 2*(rw_stopx - start));
ds_p->sprtopclip = lastopening - start; ds_p->sprtopclip = lastopening - start;
lastopening += rw_stopx - start; lastopening += rw_stopx - start;
} }
if (((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) && !ds_p->sprbottomclip) if (((ds_p->silhouette & SIL_BOTTOM) || maskedtexture) && !ds_p->sprbottomclip)
{ {
M_Memcpy(lastopening, floorclip + start, 2*(rw_stopx - start)); memcpy(lastopening, floorclip + start, 2*(rw_stopx - start));
ds_p->sprbottomclip = lastopening - start; ds_p->sprbottomclip = lastopening - start;
lastopening += rw_stopx - start; lastopening += rw_stopx - start;
} }
+149 -129
View File
@@ -33,7 +33,7 @@
#include "qs22j.h" #include "qs22j.h"
CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2]; CV_PossibleValue_t Forceskin_cons_t[MAXSKINS+2] = {}; // huehuehuehuehue
#include "discord.h" #include "discord.h"
@@ -41,6 +41,7 @@ INT32 numskins = 0;
INT32 numallskins = 0; INT32 numallskins = 0;
INT32 numlocalskins = 0; INT32 numlocalskins = 0;
skin_t skins[MAXSKINS]; skin_t skins[MAXSKINS];
UINT8 skinstats[9][9][MAXSKINS]; UINT8 skinstats[9][9][MAXSKINS];
UINT8 skinstatscount[9][9] = { UINT8 skinstatscount[9][9] = {
{0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0},
@@ -53,15 +54,16 @@ UINT8 skinstatscount[9][9] = {
{0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0} {0, 0, 0, 0, 0, 0, 0, 0, 0}
}; };
UINT8 skinsorted[MAXSKINS];
skin_t localskins[MAXLOCALSKINS]; UINT8 skinsorted[MAXSKINS] = {};
skin_t allskins[MAXSKINS+MAXLOCALSKINS]; skin_t localskins[MAXLOCALSKINS] = {};
skin_t allskins[MAXSKINS+MAXLOCALSKINS] = {};
// FIXTHIS: don't work because it must be inistilised before the config load // FIXTHIS: don't work because it must be inistilised before the config load
//#define SKINVALUES //#define SKINVALUES
#ifdef SKINVALUES #ifdef SKINVALUES
CV_PossibleValue_t skin_cons_t[MAXSKINS+1]; CV_PossibleValue_t skin_cons_t[MAXSKINS+1] = {};
CV_PossibleValue_t localskin_cons_t[MAXLOCALSKINS+1]; CV_PossibleValue_t localskin_cons_t[MAXLOCALSKINS+1] = {};
#endif #endif
static void Sk_SetDefaultValue(skin_t *skin, boolean local) static void Sk_SetDefaultValue(skin_t *skin, boolean local)
@@ -70,13 +72,14 @@ static void Sk_SetDefaultValue(skin_t *skin, boolean local)
// //
// set default skin values // set default skin values
// //
memset(skin, 0, sizeof (skin_t)); memset(skin, 0, sizeof(skin_t));
snprintf(skin->name, sizeof skin->name, "skin %u", K_GetMobjSkinNum(skin, local)); snprintf(skin->name, sizeof skin->name, "skin %u", K_GetMobjSkinNum(skin, local));
skin->name[sizeof skin->name - 1] = '\0'; skin->name[sizeof skin->name - 1] = '\0';
skin->wadnum = INT16_MAX;
strcpy(skin->sprite, "");
skin->flags = 0; skin->wadnum = INT16_MAX;
strcpy(skin->sprite, "");
strcpy(skin->realname, "Someone"); strcpy(skin->realname, "Someone");
strcpy(skin->hudname, "???"); strcpy(skin->hudname, "???");
@@ -95,8 +98,12 @@ static void Sk_SetDefaultValue(skin_t *skin, boolean local)
skin->highresscale = FRACUNIT>>1; skin->highresscale = FRACUNIT>>1;
for (i = 0; i < sfx_skinsoundslot0; i++) for (i = 0; i < sfx_skinsoundslot0; i++)
if (S_sfx[i].skinsound != -1) {
skin->soundsid[S_sfx[i].skinsound] = i; const INT32 skinsound = S_sfx[i].skinsound;
if (skinsound != -1)
skin->soundsid[skinsound] = i;
}
} }
// //
@@ -124,6 +131,7 @@ void R_InitSkins(void)
skin = &skins[0]; skin = &skins[0];
numskins = 1; numskins = 1;
Sk_SetDefaultValue(skin, false); Sk_SetDefaultValue(skin, false);
memset(skinstats, 0, sizeof(skinstats)); memset(skinstats, 0, sizeof(skinstats));
memset(skinsorted, 0, sizeof(skinsorted)); memset(skinsorted, 0, sizeof(skinsorted));
@@ -132,13 +140,16 @@ void R_InitSkins(void)
#ifdef SKINVALUES #ifdef SKINVALUES
skin_cons_t[0].strvalue = skins[0].name; skin_cons_t[0].strvalue = skins[0].name;
#endif #endif
skin->flags = 0;
strcpy(skin->realname, "Sonic"); strcpy(skin->realname, "Sonic");
strcpy(skin->hudname, "SONIC"); strcpy(skin->hudname, "SONIC");
strncpy(skin->facerank, "PLAYRANK", 9); strncpy(skin->facerank, "PLAYRANK", 9);
strncpy(skin->facewant, "PLAYWANT", 9); strncpy(skin->facewant, "PLAYWANT", 9);
strncpy(skin->facemmap, "PLAYMMAP", 9); strncpy(skin->facemmap, "PLAYMMAP", 9);
skin->flags = 0;
skin->wadnum = 0; // god what have you brought to this world skin->wadnum = 0; // god what have you brought to this world
skin->prefcolor = SKINCOLOR_BLUE; skin->prefcolor = SKINCOLOR_BLUE;
skin->localskin = false; skin->localskin = false;
@@ -177,9 +188,10 @@ INT32 R_SkinAvailable(const char *name)
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
if (stricmp(skins[i].name,name) == 0) if (fasticmp(skins[i].name, name))
return i; return i;
} }
return -1; return -1;
} }
@@ -191,9 +203,10 @@ INT32 R_AnySkinAvailable(const char *name)
for (i = 0; i < numallskins; i++) for (i = 0; i < numallskins; i++)
{ {
if (stricmp(allskins[i].name,name) == 0) if (fasticmp(allskins[i].name, name))
return i; return i;
} }
return -1; return -1;
} }
@@ -205,32 +218,32 @@ INT32 R_LocalSkinAvailable(const char *name, boolean local)
{ {
for (i = 0; i < numlocalskins; i++) for (i = 0; i < numlocalskins; i++)
{ {
if (stricmp(localskins[i].name,name) == 0) if (fasticmp(localskins[i].name, name))
return i; return i;
} }
return -1; return -1;
} }
else
return R_SkinAvailable(name); return R_SkinAvailable(name);
} }
// network code calls this when a 'skin change' is received // network code calls this when a 'skin change' is received
boolean SetPlayerSkin(INT32 playernum, const char *skinname) boolean SetPlayerSkin(INT32 playernum, const char *skinname)
{ {
INT32 i; INT32 i;
player_t *player = &players[playernum];
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
// search in the skin list // search in the skin list
if (stricmp(skins[i].name, skinname) == 0) if (fasticmp(skins[i].name, skinname))
{ {
SetPlayerSkinByNum(playernum, i); SetPlayerSkinByNum(playernum, i);
return true; return true;
} }
} }
if (P_IsLocalPlayer(player)) if (P_IsLocalPlayer(&players[playernum]))
CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname); CONS_Alert(CONS_WARNING, M_GetText("Skin '%s' not found.\n"), skinname);
else if (server || IsPlayerAdmin(consoleplayer)) else if (server || IsPlayerAdmin(consoleplayer))
CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname); CONS_Alert(CONS_WARNING, M_GetText("Player %d (%s) skin '%s' not found\n"), playernum, player_names[playernum], skinname);
@@ -244,15 +257,16 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar)
INT32 i; INT32 i;
player_t *player = &players[playernum]; player_t *player = &players[playernum];
if (stricmp(skinname, "none")) if (!fasticmp(skinname, "none"))
{ {
for (i = 0; i < numlocalskins; i++) for (i = 0; i < numlocalskins; i++)
{ {
// search in the localskin list // search in the localskin list
if (stricmp(localskins[i].name, skinname) == 0) if (fasticmp(localskins[i].name, skinname))
{ {
player->localskin = 1 + i; player->localskin = 1 + i;
player->skinlocal = true; player->skinlocal = true;
if (player->mo) if (player->mo)
{ {
player->mo->localskin = &localskins[i]; player->mo->localskin = &localskins[i];
@@ -266,10 +280,11 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar)
for (i = 0; i < numskins; i++) for (i = 0; i < numskins; i++)
{ {
// search in the skin list // search in the skin list
if (stricmp(skins[i].name, skinname) == 0) if (fasticmp(skins[i].name, skinname))
{ {
player->localskin = 1 + i; player->localskin = 1 + i;
player->skinlocal = false; player->skinlocal = false;
if (player->mo) if (player->mo)
{ {
player->mo->localskin = &skins[i]; player->mo->localskin = &skins[i];
@@ -284,6 +299,7 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar)
{ {
player->localskin = 0; player->localskin = 0;
player->skinlocal = false; player->skinlocal = false;
if (player->mo) if (player->mo)
{ {
player->mo->localskin = 0; player->mo->localskin = 0;
@@ -318,6 +334,7 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
if (skinnum >= 0 && skinnum < numskins) // Make sure it exists! if (skinnum >= 0 && skinnum < numskins) // Make sure it exists!
{ {
player->skin = skinnum; player->skin = skinnum;
if (player->mo) if (player->mo)
player->mo->skin = skin; player->mo->skin = skin;
@@ -360,117 +377,97 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum)
static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump) static UINT16 W_CheckForSkinMarkerInPwad(UINT16 wadid, UINT16 startlump)
{ {
UINT16 i; UINT16 i;
const char *S_SKIN = "S_SKIN";
lumpinfo_t *lump_p; lumpinfo_t *lump_p;
// scan forward, start at <startlump> // scan forward, start at <startlump>
if (startlump < wadfiles[wadid]->numlumps) if (startlump < wadfiles[wadid]->numlumps)
{ {
lump_p = wadfiles[wadid]->lumpinfo + startlump; lump_p = wadfiles[wadid]->lumpinfo + startlump;
for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++) for (i = startlump; i < wadfiles[wadid]->numlumps; i++, lump_p++)
if (memcmp(lump_p->name,S_SKIN,6)==0) {
if (memcmp(lump_p->name, "S_SKIN", 6) == 0)
return i; return i;
}
} }
return INT16_MAX; // not found return INT16_MAX; // not found
} }
//sort function for sorting skin names //sort function for sorting skin names
static int skinSortFunc(const void *a, const void *b) //tbh i have no clue what the naming conventions for local functions are static int skinSortFunc(const void *a, const void *b) // tbh i have no clue what the naming conventions for local functions are
{ {
const skin_t *in1 = &skins[*(const UINT8 *)a]; int diff = 0;
const skin_t *in2 = &skins[*(const UINT8 *)b]; const UINT8 val_a = *(const UINT8 *)a;
INT32 temp = 0; const UINT8 val_b = *(const UINT8 *)b;
const UINT8 val_a = *((const UINT8 *)a); const skin_t *in1 = &skins[val_a];
const UINT8 val_b = *((const UINT8 *)b); const skin_t *in2 = &skins[val_b];
//return (strcmp(in1->realname, in2->realname) < 0) || (strcmp(in1->realname, in2->realname) ==); // return (strcmp(in1->realname, in2->realname) < 0) || (strcmp(in1->realname, in2->realname) ==);
switch (cv_skinselectgridsort.value) switch (cv_skinselectgridsort.value)
{ {
case SKINMENUSORT_REALNAME: case SKINMENUSORT_REALNAME:
//CONS_Printf("Sorting by realname\n"); // CONS_Printf("Sorting by realname\n");
// check name // check name
if ((temp = strcmp(in1->realname, in2->realname))) diff = strcmp(in1->realname, in2->realname);
return temp; if (diff != 0) return diff;
// sort by internal name
return strcmp(in1->name, in2->name);
break;
case SKINMENUSORT_NAME:
//CONS_Printf("Sorting by name\n");
return strcmp(in1->name, in2->name);
break; break;
case SKINMENUSORT_SPEED: case SKINMENUSORT_SPEED:
//CONS_Printf("Sorting by speed\n"); // CONS_Printf("Sorting by speed\n");
// check speed // check speed
if (in1->kartspeed < in2->kartspeed) diff = in1->kartspeed - in2->kartspeed;
return -1; if (diff != 0) return diff;
else if (in2->kartspeed < in1->kartspeed)
return 1;
// then check weight // then check weight
if (in1->kartweight < in2->kartweight) diff = in1->kartweight - in2->kartweight;
return -1; if (diff != 0) return diff;
else if (in2->kartweight < in1->kartweight)
return 1;
// then check name
if ((temp = strcmp(in1->realname, in2->realname)))
return temp;
// sort by internal name
return strcmp(in1->name, in2->name);
break;
// then check name
diff = strcmp(in1->realname, in2->realname);
if (diff != 0) return diff;
break;
case SKINMENUSORT_WEIGHT: case SKINMENUSORT_WEIGHT:
//CONS_Printf("Sorting by weight\n"); // CONS_Printf("Sorting by weight\n");
// check weight // check weight
if (in1->kartweight < in2->kartweight) diff = in1->kartweight - in2->kartweight;
return -1; if (diff != 0) return diff;
else if (in2->kartweight < in1->kartweight)
return 1;
// then check speed // then check speed
if (in1->kartspeed < in2->kartspeed) diff = in1->kartspeed - in2->kartspeed;
return -1; if (diff != 0) return diff;
else if (in2->kartspeed < in1->kartspeed)
return 1;
// then check name
if ((temp = strcmp(in1->realname, in2->realname)))
return temp;
// sort by internal name
return strcmp(in1->name, in2->name);
break;
// then check name
diff = strcmp(in1->realname, in2->realname);
if (diff != 0) return diff;
break;
case SKINMENUSORT_PREFCOLOR: case SKINMENUSORT_PREFCOLOR:
//CONS_Printf("Sorting by prefcolor\n"); // CONS_Printf("Sorting by prefcolor\n");
// check prefcolor // check prefcolor
if (in1->prefcolor < in2->prefcolor) diff = in1->prefcolor - in2->prefcolor;
return -1; if (diff != 0) return diff;
else if (in2->prefcolor < in1->prefcolor)
return 1;
// then check name // then check name
if ((temp = strcmp(in1->realname, in2->realname))) diff = strcmp(in1->realname, in2->realname);
return temp; if (diff != 0) return diff;
// sort by internal name
return strcmp(in1->name, in2->name);
break; break;
case SKINMENUSORT_ID: case SKINMENUSORT_ID:
//CONS_Printf("Sorting by id\n"); // CONS_Printf("Sorting by id\n");
//how do i do by ID????? // how do i do by ID?????
//wait why dont i just convert the inputs to UINT32s // wait why dont i just convert the inputs to UINT32s
//please tell me im allowed to define variables in here since its a block // please tell me im allowed to define variables in here since its a block
return (int)val_a - (int)val_b;
if (val_a == val_b) case SKINMENUSORT_NAME:
return 0;
else if (val_a < val_b)
return -1;
else
return 1;
default: default:
return strcmp(in1->name, in2->name);
break; break;
} }
//im scared this somehow will sometimes end up here so im gonna add this here just to be safe
// im scared this somehow will sometimes end up here so im gonna add this here just to be safe
// now it will often end up here >:3
return strcmp(in1->name, in2->name); return strcmp(in1->name, in2->name);
} }
@@ -523,7 +520,7 @@ void R_AddSkins(UINT16 wadnum, boolean local)
buf2 = malloc(size+1); buf2 = malloc(size+1);
if (!buf2) if (!buf2)
I_Error("R_AddSkins: No more free memory\n"); I_Error("R_AddSkins: No more free memory\n");
M_Memcpy(buf2,buf,size); memcpy(buf2,buf,size);
buf2[size] = '\0'; buf2[size] = '\0';
// set defaults // set defaults
@@ -531,8 +528,9 @@ void R_AddSkins(UINT16 wadnum, boolean local)
Sk_SetDefaultValue(skin, local); Sk_SetDefaultValue(skin, local);
skin->wadnum = wadnum; skin->wadnum = wadnum;
hudname = realname = false; hudname = realname = false;
// parse // parse
stoken = strtok (buf2, "\r\n= "); stoken = strtok(buf2, "\r\n= ");
while (stoken) while (stoken)
{ {
if ((stoken[0] == '/' && stoken[1] == '/') if ((stoken[0] == '/' && stoken[1] == '/')
@@ -548,7 +546,7 @@ void R_AddSkins(UINT16 wadnum, boolean local)
if (!value) if (!value)
I_Error("R_AddSkins: syntax error in S_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename); I_Error("R_AddSkins: syntax error in S_SKIN lump# %d(%s) in WAD %s\n", lump, W_CheckNameForNumPwad(wadnum,lump), wadfiles[wadnum]->filename);
if (!stricmp(stoken, "name")) if (fasticmp(stoken, "name"))
{ {
// the skin name must uniquely identify a single skin // the skin name must uniquely identify a single skin
// I'm lazy so if name is already used I leave the 'skin x' // I'm lazy so if name is already used I leave the 'skin x'
@@ -562,18 +560,18 @@ void R_AddSkins(UINT16 wadnum, boolean local)
// using the default skin name's number set above // using the default skin name's number set above
else else
{ {
const size_t stringspace = const size_t stringspace = strlen(value) + sizeof lnumskins + 1;
strlen(value) + sizeof lnumskins + 1;
char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL); char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL);
snprintf(value2, stringspace,
"%s%d", value, lnumskins); snprintf(value2, stringspace, "%s%d", value, lnumskins);
value2[stringspace - 1] = '\0'; value2[stringspace - 1] = '\0';
if (R_LocalSkinAvailable(value2, local) == -1) if (R_LocalSkinAvailable(value2, local) == -1)
{ {
STRBUFCPY(skin->name, STRBUFCPY(skin->name, value2);
value2);
strlwr(skin->name); strlwr(skin->name);
} }
Z_Free(value2); Z_Free(value2);
} }
@@ -589,115 +587,134 @@ void R_AddSkins(UINT16 wadnum, boolean local)
{ {
STRBUFCPY(skin->hudname, skin->name); STRBUFCPY(skin->hudname, skin->name);
strupr(skin->hudname); strupr(skin->hudname);
for (value = skin->hudname; *value; value++) for (value = skin->hudname; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces. if (*value == '_') *value = ' '; // turn _ into spaces.
} }
} }
else if (!stricmp(stoken, "realname")) else if (fasticmp(stoken, "realname"))
{ // Display name (eg. "Knuckles") { // Display name (eg. "Knuckles")
realname = true; realname = true;
STRBUFCPY(skin->realname, value); STRBUFCPY(skin->realname, value);
for (value = skin->realname; *value; value++) for (value = skin->realname; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces. if (*value == '_') *value = ' '; // turn _ into spaces.
if (!hudname) if (!hudname)
STRBUFCPY(skin->hudname, skin->realname); STRBUFCPY(skin->hudname, skin->realname);
} }
else if (!stricmp(stoken, "hudname")) else if (fasticmp(stoken, "hudname"))
{ // Life icon name (eg. "K.T.E") { // Life icon name (eg. "K.T.E")
hudname = true; hudname = true;
STRBUFCPY(skin->hudname, value); STRBUFCPY(skin->hudname, value);
for (value = skin->hudname; *value; value++) for (value = skin->hudname; *value; value++)
if (*value == '_') *value = ' '; // turn _ into spaces. if (*value == '_') *value = ' '; // turn _ into spaces.
if (!realname) if (!realname)
STRBUFCPY(skin->realname, skin->hudname); STRBUFCPY(skin->realname, skin->hudname);
} }
else if (fasticmp(stoken, "sprite"))
else if (!stricmp(stoken, "sprite"))
{ {
strupr(value); strupr(value);
memcpy(skin->sprite, value, sizeof skin->sprite); memcpy(skin->sprite, value, sizeof skin->sprite);
} }
else if (!stricmp(stoken, "facerank")) else if (fasticmp(stoken, "facerank"))
{ {
strupr(value); strupr(value);
memcpy(skin->facerank, value, sizeof(skin->facerank)-1); memcpy(skin->facerank, value, sizeof(skin->facerank)-1);
skin->facerank[sizeof(skin->facerank)-1] = '\0'; skin->facerank[sizeof(skin->facerank)-1] = '\0';
} }
else if (!stricmp(stoken, "facewant")) else if (fasticmp(stoken, "facewant"))
{ {
strupr(value); strupr(value);
memcpy(skin->facewant, value, sizeof(skin->facewant)-1); memcpy(skin->facewant, value, sizeof(skin->facewant)-1);
skin->facewant[sizeof(skin->facewant)-1] = '\0'; skin->facewant[sizeof(skin->facewant)-1] = '\0';
} }
else if (!stricmp(stoken, "facemmap")) else if (fasticmp(stoken, "facemmap"))
{ {
strupr(value); strupr(value);
strncpy(skin->facemmap, value, sizeof(skin->facemmap)-1); strncpy(skin->facemmap, value, sizeof(skin->facemmap)-1);
skin->facemmap[sizeof(skin->facemmap)-1] = '\0'; skin->facemmap[sizeof(skin->facemmap)-1] = '\0';
} }
else if (!stricmp(stoken, "flags")) // character type identification else if (fasticmp(stoken, "flags")) // character type identification
{ {
skin->flags = get_number(value); skin->flags = get_number(value);
} }
else if (!stricmp(stoken, "kartspeed")) else if (fasticmp(stoken, "kartspeed"))
{ {
skin->kartspeed = atoi(value); skin->kartspeed = atoi(value);
if (skin->kartspeed < 1) if (skin->kartspeed < 1)
skin->kartspeed = 1; skin->kartspeed = 1;
if (skin->kartspeed > 9) if (skin->kartspeed > 9)
skin->kartspeed = 9; skin->kartspeed = 9;
} }
else if (!stricmp(stoken, "kartweight")) else if (fasticmp(stoken, "kartweight"))
{ {
skin->kartweight = atoi(value); skin->kartweight = atoi(value);
if (skin->kartweight < 1) if (skin->kartweight < 1)
skin->kartweight = 1; skin->kartweight = 1;
if (skin->kartweight > 9) if (skin->kartweight > 9)
skin->kartweight = 9; skin->kartweight = 9;
} }
// custom translation table // custom translation table
else if (!stricmp(stoken, "startcolor")) else if (fasticmp(stoken, "startcolor"))
{
skin->starttranscolor = atoi(value); skin->starttranscolor = atoi(value);
else if (!stricmp(stoken, "prefcolor")) }
else if (fasticmp(stoken, "prefcolor"))
{
skin->prefcolor = K_GetKartColorByName(value); skin->prefcolor = K_GetKartColorByName(value);
else if (!stricmp(stoken, "highresscale")) }
else if (fasticmp(stoken, "highresscale"))
{
skin->highresscale = FLOAT_TO_FIXED(atof(value)); skin->highresscale = FLOAT_TO_FIXED(atof(value));
}
else else
{ {
INT32 found = false; INT32 found = false;
sfxenum_t i; sfxenum_t i;
// copy name of sounds that are remapped // copy name of sounds that are remapped
// for this skin // for this skin
for (i = 0; i < sfx_skinsoundslot0; i++) for (i = 0; i < sfx_skinsoundslot0; i++)
{ {
if (!S_sfx[i].name) const sfxinfo_t *sfx = &S_sfx[i];
if (!sfx->name)
continue; continue;
if (S_sfx[i].skinsound != -1
&& !stricmp(S_sfx[i].name, if (sfx->skinsound != -1
stoken + 2)) && fasticmp(sfx->name, stoken + 2))
{ {
skin->soundsid[S_sfx[i].skinsound] = skin->soundsid[sfx->skinsound] = S_AddSoundFx(value+2, sfx->singularity, sfx->pitch, true);
S_AddSoundFx(value+2, S_sfx[i].singularity, S_sfx[i].pitch, true);
found = true; found = true;
} }
} }
if (!found) if (!found)
CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump# %d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename); CONS_Debug(DBG_SETUP, "R_AddSkins: Unknown keyword '%s' in S_SKIN lump# %d (WAD %s)\n", stoken, lump, wadfiles[wadnum]->filename);
} }
stoken = strtok(NULL, "\r\n= "); stoken = strtok(NULL, "\r\n= ");
} }
free(buf2); free(buf2);
lump++; // if no sprite defined use spirte just after this one lump++; // if no sprite defined use spirte just after this one
if (skin->sprite[0] == '\0') if (skin->sprite[0] == '\0')
{ {
const char *csprname = W_CheckNameForNumPwad(wadnum, lump); const char *csprname = W_CheckNameForNumPwad(wadnum, lump);
// skip to end of this skin's frames // skip to end of this skin's frames
lastlump = lump; lastlump = lump;
while (W_CheckNameForNumPwad(wadnum, lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump), csprname,4)==0) while (W_CheckNameForNumPwad(wadnum, lastlump) && memcmp(W_CheckNameForNumPwad(wadnum, lastlump), csprname,4)==0)
lastlump++; lastlump++;
// allocate (or replace) sprite frames, and set spritedef // allocate (or replace) sprite frames, and set spritedef
R_AddSingleSpriteDef(csprname, &skin->spritedef, wadnum, lump, lastlump); R_AddSingleSpriteDef(csprname, &skin->spritedef, wadnum, lump, lastlump);
} }
@@ -707,12 +724,15 @@ void R_AddSkins(UINT16 wadnum, boolean local)
size_t name; size_t name;
boolean found = false; boolean found = false;
const char *sprname = skin->sprite; const char *sprname = skin->sprite;
for (name = 0;sprnames[name][0] != '\0';name++)
for (name = 0; sprnames[name][0] != '\0'; name++)
{
if (strncmp(sprnames[name], sprname, 4) == 0) if (strncmp(sprnames[name], sprname, 4) == 0)
{ {
found = true;
skin->spritedef = sprites[name]; skin->spritedef = sprites[name];
found = true;
} }
}
// not found so make a new one // not found so make a new one
// go through the entire current wad looking for our sprite // go through the entire current wad looking for our sprite
@@ -726,7 +746,7 @@ void R_AddSkins(UINT16 wadnum, boolean local)
while ((lname = W_CheckNameForNumPwad(wadnum, localllump))) while ((lname = W_CheckNameForNumPwad(wadnum, localllump)))
{ {
// If this is a valid sprite... // If this is a valid sprite...
if (!memcmp(lname, sprname,4) && lname[4] && lname[5] && lname[5] >= '0' && lname[5] <= '8') if (!memcmp(lname, sprname, 4) && lname[4] && lname[5] && lname[5] >= '0' && lname[5] <= '8')
{ {
if (lstart == UINT16_MAX) if (lstart == UINT16_MAX)
lstart = localllump; lstart = localllump;
@@ -741,6 +761,7 @@ void R_AddSkins(UINT16 wadnum, boolean local)
} }
// If not already set do nothing // If not already set do nothing
} }
++localllump; ++localllump;
} }
@@ -760,7 +781,6 @@ void R_AddSkins(UINT16 wadnum, boolean local)
(local ? localskin_cons_t : skin_cons_t)[lnumskins].value = lnumskins; (local ? localskin_cons_t : skin_cons_t)[lnumskins].value = lnumskins;
(local ? localskin_cons_t : skin_cons_t)[lnumskins].strvalue = skin->name; (local ? localskin_cons_t : skin_cons_t)[lnumskins].strvalue = skin->name;
#endif #endif
if (!local) if (!local)
{ {
// Update the forceskin possiblevalues // Update the forceskin possiblevalues
+7 -9
View File
@@ -22,8 +22,6 @@
#include "w_wad.h" #include "w_wad.h"
#include "z_zone.h" #include "z_zone.h"
#include "p_maputl.h" // P_PointOnLineSide
// //
// sky mapping // sky mapping
// //
@@ -31,28 +29,28 @@
/** \brief Needed to store the number of the dummy sky flat. /** \brief Needed to store the number of the dummy sky flat.
Used for rendering, as well as tracking projectiles etc. Used for rendering, as well as tracking projectiles etc.
*/ */
INT32 skyflatnum; INT32 skyflatnum = 0;
/** \brief the lump number of the sky texture /** \brief the lump number of the sky texture
*/ */
INT32 skytexture; INT32 skytexture = 0;
/** \brief the horizon line in a 256x128 sky texture /** \brief the horizon line in a 256x128 sky texture
*/ */
INT32 skytexturemid; INT32 skytexturemid = 0;
/** \brief the x offset of the sky texture /** \brief the x offset of the sky texture
*/ */
INT32 skytextureoffset; INT32 skytextureoffset = 0;
/** \brief the scale of the sky /** \brief the scale of the sky
*/ */
fixed_t skyscale; fixed_t skyscale = 0;
/** \brief used for keeping track of the current sky /** \brief used for keeping track of the current sky
*/ */
INT32 levelskynum; INT32 levelskynum = 0;
INT32 globallevelskynum; INT32 globallevelskynum = 0;
/** \brief The R_SetupSkyDraw function /** \brief The R_SetupSkyDraw function
+7 -7
View File
@@ -95,15 +95,15 @@ static INT32 drawsegs_xrange_count = 0;
// There was a lot of stuff grabbed wrong, so I changed it... // There was a lot of stuff grabbed wrong, so I changed it...
// //
spriteinfo_t spriteinfo[NUMSPRITES]; spriteinfo_t spriteinfo[NUMSPRITES] = {};
// //
// INITIALIZATION FUNCTIONS // INITIALIZATION FUNCTIONS
// //
// variables used to look up and range check thing_t sprites patches // variables used to look up and range check thing_t sprites patches
spritedef_t *sprites; spritedef_t *sprites = NULL;
size_t numsprites; size_t numsprites = 0;
static spriteframe_t sprtemp[64]; static spriteframe_t sprtemp[64];
static size_t maxframe; static size_t maxframe;
@@ -112,7 +112,7 @@ static const char *spritename;
// //
// GAME FUNCTIONS // GAME FUNCTIONS
// //
UINT32 visspritecount, numvisiblesprites; UINT32 visspritecount = 0, numvisiblesprites = 0;
static UINT32 clippedvissprites; static UINT32 clippedvissprites;
static vissprite_t *visspritechunks[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {NULL}; static vissprite_t *visspritechunks[MAXVISSPRITES >> VISSPRITECHUNKBITS] = {NULL};
@@ -267,7 +267,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
if (spritedef->numframes) // (then spriteframes is not null) if (spritedef->numframes) // (then spriteframes is not null)
{ {
// copy the already defined sprite frames // copy the already defined sprite frames
M_Memcpy(sprtemp, spritedef->spriteframes, memcpy(sprtemp, spritedef->spriteframes,
spritedef->numframes * sizeof (spriteframe_t)); spritedef->numframes * sizeof (spriteframe_t));
maxframe = spritedef->numframes - 1; maxframe = spritedef->numframes - 1;
} }
@@ -403,7 +403,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
spritedef->spriteframes = static_cast<spriteframe_t*>(Z_Malloc(maxframe * sizeof (*spritedef->spriteframes), PU_STATIC, NULL)); spritedef->spriteframes = static_cast<spriteframe_t*>(Z_Malloc(maxframe * sizeof (*spritedef->spriteframes), PU_STATIC, NULL));
spritedef->numframes = maxframe; spritedef->numframes = maxframe;
M_Memcpy(spritedef->spriteframes, sprtemp, maxframe*sizeof (spriteframe_t)); memcpy(spritedef->spriteframes, sprtemp, maxframe*sizeof (spriteframe_t));
return true; return true;
} }
@@ -1019,7 +1019,7 @@ static void R_SplitSprite(vissprite_t *sprite)
INT16 *cliptop = newsprite->cliptop; INT16 *cliptop = newsprite->cliptop;
INT16 *clipbot = newsprite->clipbot; INT16 *clipbot = newsprite->clipbot;
M_Memcpy(newsprite, sprite, sizeof (vissprite_t)); memcpy(newsprite, sprite, sizeof (vissprite_t));
newsprite->cliptop = cliptop; newsprite->cliptop = cliptop;
newsprite->clipbot = clipbot; newsprite->clipbot = clipbot;
+60 -41
View File
@@ -45,7 +45,7 @@ static void Command_ShowMusicCredit_f(void);
static void GameSounds_OnChange(void); static void GameSounds_OnChange(void);
static void GameMusic_OnChange(void); static void GameMusic_OnChange(void);
static void SoundPrecache_OnChange(void); static void SoundCache_OnChange(void);
static void BufferSize_OnChange(void); static void BufferSize_OnChange(void);
#ifdef HAVE_OPENMPT #ifdef HAVE_OPENMPT
@@ -68,7 +68,8 @@ consvar_t cv_audbuffersize = {"audiobuffersize", "2048", CV_SAVE|CV_CALL, audbuf
consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t stereoreverse = {"stereoreverse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
// if true, all sounds are loaded at game startup // if true, all sounds are loaded at game startup
consvar_t precachesound = {"precachesound", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, SoundPrecache_OnChange, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t cachesounds_cons_t[] = {{0, "Off"}, {1, "Keep"}, {2, "On"}, {0, NULL}};
consvar_t cv_cachesound = {"cachesound", "1", CV_SAVE|CV_CALL|CV_NOINIT, cachesounds_cons_t, SoundCache_OnChange, 0, NULL, NULL, 0, 0, NULL};
// actual general (maximum) sound & music volume, saved into the config // actual general (maximum) sound & music volume, saved into the config
static CV_PossibleValue_t soundvolume_cons_t[] = {{0, "MIN"}, {31, "MAX"}, {0, NULL}}; static CV_PossibleValue_t soundvolume_cons_t[] = {{0, "MIN"}, {31, "MAX"}, {0, NULL}};
@@ -274,7 +275,7 @@ void S_RegisterSoundStuff(void)
} }
CV_RegisterVar(&stereoreverse); CV_RegisterVar(&stereoreverse);
CV_RegisterVar(&precachesound); CV_RegisterVar(&cv_cachesound);
#if defined(HAVE_SDL) && SOUND==SOUND_SDL #if defined(HAVE_SDL) && SOUND==SOUND_SDL
CV_RegisterVar(&cv_samplerate); CV_RegisterVar(&cv_samplerate);
#endif #endif
@@ -362,9 +363,15 @@ boolean S_SoundDisabled(void)
return (sound_disabled || (window_notinfocus && !cv_playsoundifunfocused.value)); return (sound_disabled || (window_notinfocus && !cv_playsoundifunfocused.value));
} }
boolean S_PrecacheSound(void) int S_CacheSound(void)
{ {
return (!sound_disabled && (M_CheckParm("-precachesound") || precachesound.value)); if (sound_disabled)
return SOUNDCACHE_OFF;
if (M_CheckParm("-precachesound"))
return SOUNDCACHE_PRECACHE;
return cv_cachesound.value;
} }
// Stop all sounds, load level info, THEN start sounds. // Stop all sounds, load level info, THEN start sounds.
@@ -1095,9 +1102,12 @@ void S_StartSoundName(void *mo, const char *soundname)
// Search existing sounds... // Search existing sounds...
for (i = sfx_None + 1; i < NUMSFX; i++) for (i = sfx_None + 1; i < NUMSFX; i++)
{ {
if (!S_sfx[i].name) const sfxinfo_t *sfx = &S_sfx[i];
if (!sfx->name)
continue; continue;
if (!stricmp(S_sfx[i].name, soundname))
if (fasticmp(sfx->name, soundname))
{ {
soundnum = i; soundnum = i;
break; break;
@@ -1110,6 +1120,7 @@ void S_StartSoundName(void *mo, const char *soundname)
{ {
if (newsounds[i] == 0) if (newsounds[i] == 0)
break; break;
if (!S_IdPlaying(newsounds[i])) if (!S_IdPlaying(newsounds[i]))
{ {
S_RemoveSoundFx(newsounds[i]); S_RemoveSoundFx(newsounds[i]);
@@ -1146,28 +1157,35 @@ void S_InitSfxChannels(INT32 sfxVolume)
SetChannelsNum(); SetChannelsNum();
// Note that sounds have not been cached (yet).
for (i = 1; i < NUMSFX; i++)
{
S_sfx[i].lumpnum = LUMPERROR;
}
// Precache sounds if requested // Precache sounds if requested
if (S_PrecacheSound()) if (S_CacheSound() == SOUNDCACHE_PRECACHE)
{ {
// Initialize external data (all sounds) at start, keep static. // Initialize external data (all sounds) at start, keep static.
CONS_Printf(M_GetText("Pre-caching sounds...")); CONS_Printf(M_GetText("Pre-caching sounds..."));
for (i = 1; i < sfx_freeslot0; i++) // NUMSFX is a big number, so merge the loops
if (S_sfx[i].name && !S_sfx[i].data) for (i = 1; i < NUMSFX; i++)
S_sfx[i].data = I_GetSfx(&S_sfx[i]); {
S_sfx[i].lumpnum = LUMPERROR;
for (i = sfx_freeslot0; i < NUMSFX; i++) if (S_sfx[i].data)
if (S_sfx[i].priority && !S_sfx[i].data) continue;
S_sfx[i].data = I_GetSfx(&S_sfx[i]);
if ((i < sfx_freeslot0 && S_sfx[i].name) ||
(i >= sfx_freeslot0 && S_sfx[i].priority))
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"));
} }
else
{
// Note that sounds have not been cached (yet).
for (i = 1; i < NUMSFX; i++)
{
S_sfx[i].lumpnum = LUMPERROR;
}
}
} }
/// ------------------------ /// ------------------------
@@ -1266,7 +1284,7 @@ ReadMusicDefFields (UINT16 wadnum, int line, char *stoken, musicdef_t **defp)
char *value; char *value;
char *textline; char *textline;
if (!stricmp(stoken, "lump")) if (fasticmp(stoken, "lump"))
{ {
value = strtok(NULL, " "); value = strtok(NULL, " ");
@@ -1341,24 +1359,24 @@ skip_lump:
for (textline = def->field; *textline; textline++)\ for (textline = def->field; *textline; textline++)\
if (*textline == '_') *textline = ' '; if (*textline == '_') *textline = ' ';
if (!stricmp(stoken, "usage")) if (fasticmp(stoken, "usage"))
{ {
ADDDEF(usage); ADDDEF(usage);
} }
else if (!stricmp(stoken, "source")) else if (fasticmp(stoken, "source"))
{ {
ADDDEF(source); ADDDEF(source);
} }
else if (!stricmp(stoken, "title")) else if (fasticmp(stoken, "title"))
{ {
def->use_info = true; def->use_info = true;
ADDDEF(title); ADDDEF(title);
} }
else if (!stricmp(stoken, "alttitle")) else if (fasticmp(stoken, "alttitle"))
{ {
ADDDEF(alttitle); ADDDEF(alttitle);
} }
else if (!stricmp(stoken, "authors")) else if (fasticmp(stoken, "authors"))
{ {
ADDDEF(authors); ADDDEF(authors);
} }
@@ -1405,7 +1423,7 @@ void S_LoadMusicDefs(UINT16 wadnum)
musdeftext = malloc(size+1); musdeftext = malloc(size+1);
if (!musdeftext) if (!musdeftext)
I_Error("S_LoadMusicDefs: No more free memory for the parser\n"); I_Error("S_LoadMusicDefs: No more free memory for the parser\n");
M_Memcpy(musdeftext, lump, size); memcpy(musdeftext, lump, size);
musdeftext[size] = '\0'; musdeftext[size] = '\0';
// Find music def // Find music def
@@ -1479,7 +1497,8 @@ musicdef_t *S_FindMusicCredit(const char *musname)
if (hash != def->hash) if (hash != def->hash)
continue; continue;
if (stricmp(def->name, musname))
if (!fasticmp(def->name, musname))
continue; continue;
return def; return def;
@@ -1813,7 +1832,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
} }
} }
void S_ChangeMusicSpecial (const char *mmusic) void S_ChangeMusicSpecial(const char *mmusic)
{ {
if (cv_resetspecialmusic.value) if (cv_resetspecialmusic.value)
S_ChangeMusic(mmusic, MUSIC_FORCERESET, true); S_ChangeMusic(mmusic, MUSIC_FORCERESET, true);
@@ -1828,7 +1847,7 @@ void S_StopMusic(void)
|| demo.title) // SRB2Kart: Demos don't interrupt title screen music || demo.title) // SRB2Kart: Demos don't interrupt title screen music
return; return;
mapmusic.resume = (cv_birdmusic.value && (strcasecmp(music.name, mapmusic.name) == 0)) ? I_GetSongPosition() : 0; mapmusic.resume = (cv_birdmusic.value && fasticmp(music.name, mapmusic.name)) ? I_GetSongPosition() : 0;
S_SetKeepMusResume(); S_SetKeepMusResume();
@@ -1934,7 +1953,7 @@ static const char *musicexception_list[] = {
// check if the current music is smth we dont want to keep (vote music, etc) // check if the current music is smth we dont want to keep (vote music, etc)
static boolean S_CheckMusicException(void) static boolean S_CheckMusicException(void)
{ {
if (stricmp(music.name, mapmusic.name)) if (!fasticmp(music.name, mapmusic.name))
return true; return true;
// dumb hack but dont keepmusic music that is supposed to reset // dumb hack but dont keepmusic music that is supposed to reset
@@ -1944,7 +1963,7 @@ static boolean S_CheckMusicException(void)
// in case somehow the mapmusic was replaced with smth we dont want to keep // in case somehow the mapmusic was replaced with smth we dont want to keep
for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++)
{ {
if (!stricmp(music.name, musicexception_list[i]) || !stricmp(checkmusic, musicexception_list[i])) if (fasticmp(music.name, musicexception_list[i]) || fasticmp(checkmusic, musicexception_list[i]))
{ {
return true; return true;
} }
@@ -1964,7 +1983,7 @@ static void S_SetKeepMusResume(void)
{ {
keepmusic.resume = 0; keepmusic.resume = 0;
if (strcasecmp(music.name, mapmusic.name) == 0) if (fasticmp(music.name, mapmusic.name))
{ {
keepmusic.resume = I_GetSongPosition(); keepmusic.resume = I_GetSongPosition();
} }
@@ -2030,12 +2049,12 @@ static boolean S_SkipIntroMusic(void)
return false; return false;
// check if menu music is playing, otherwise it may continue playing // check if menu music is playing, otherwise it may continue playing
if (!stricmp(music.name, "titles")) if (fasticmp(music.name, "titles"))
return false; return false;
char *maptitle = G_BuildMapTitle(gamemap); // Zzz... char *maptitle = G_BuildMapTitle(gamemap); // Zzz...
if (maptitle && !stricmp(maptitle, "Wandering Falls")) // wandering balls changes its song when the race starts Zzz... if (maptitle && fasticmp(maptitle, "Wandering Falls")) // wandering balls changes its song when the race starts Zzz...
{ {
Z_Free(maptitle); Z_Free(maptitle);
return false; return false;
@@ -2148,19 +2167,19 @@ static void Command_Tunes_f(void)
tunenum = (UINT16)atoi(tunearg); tunenum = (UINT16)atoi(tunearg);
track = 0; track = 0;
if (!strcasecmp(tunearg, "-show")) if (fasticmp(tunearg, "-show"))
{ {
CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"), CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"),
mapmusic.name, (mapmusic.flags & MUSIC_TRACKMASK)); mapmusic.name, (mapmusic.flags & MUSIC_TRACKMASK));
return; return;
} }
if (!strcasecmp(tunearg, "-none")) if (fasticmp(tunearg, "-none"))
{ {
S_StopMusic(); S_StopMusic();
return; return;
} }
else if (!strcasecmp(tunearg, "-default")) else if (fasticmp(tunearg, "-default"))
{ {
tunearg = mapheaderinfo[gamemap-1]->musname; tunearg = mapheaderinfo[gamemap-1]->musname;
track = mapheaderinfo[gamemap-1]->mustrack; track = mapheaderinfo[gamemap-1]->mustrack;
@@ -2272,13 +2291,13 @@ static void GameSounds_OnChange(void)
} }
} }
static void SoundPrecache_OnChange(void) static void SoundCache_OnChange(void)
{ {
if (S_PrecacheSound()) if (S_CacheSound() != SOUNDCACHE_OFF)
{ {
S_InitSfxChannels(cv_soundvolume.value); S_InitSfxChannels(cv_soundvolume.value);
} }
else if (!S_PrecacheSound()) else
{ {
S_ClearSfx(); S_ClearSfx();
+10 -2
View File
@@ -75,9 +75,10 @@ extern consvar_t cv_skipintromusic;
//extern consvar_t cv_ignoremusicchanges; //extern consvar_t cv_ignoremusicchanges;
extern boolean keepmapmusic; extern boolean keepmapmusic;
extern boolean skipintromus; extern boolean skipintromus;
#define MUSICSTARTTIME (starttime + (TICRATE/2)) #define MUSICSTARTTIME (starttime + (TICRATE/2))
extern consvar_t precachesound; extern consvar_t cv_cachesound;
typedef enum typedef enum
{ {
@@ -148,11 +149,18 @@ void S_StopSound(void *origin);
// Music Status // Music Status
// //
enum
{
SOUNDCACHE_OFF,
SOUNDCACHE_KEEP,
SOUNDCACHE_PRECACHE
};
boolean S_MusicDisabled(void); boolean S_MusicDisabled(void);
boolean S_MusicPlaying(void); boolean S_MusicPlaying(void);
boolean S_MusicPaused(void); boolean S_MusicPaused(void);
boolean S_MusicNotInFocus(void); boolean S_MusicNotInFocus(void);
boolean S_PrecacheSound(void); int S_CacheSound(void);
musictype_t S_MusicType(void); musictype_t S_MusicType(void);
const char *S_MusicName(void); const char *S_MusicName(void);
boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping); boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping);
+11 -8
View File
@@ -36,8 +36,8 @@
// ------------------ // ------------------
// global video state // global video state
// ------------------ // ------------------
viddef_t vid; viddef_t vid = {};
INT32 setmodeneeded; // video mode change needed if > 0 (the mode number to set + 1) INT32 setmodeneeded = 0; // video mode change needed if > 0 (the mode number to set + 1)
static CV_PossibleValue_t shittyscreen_cons_t[] = {{0, "Okay"}, {1, "Shitty"}, {2, "Extra Shitty"}, {0, NULL}}; static CV_PossibleValue_t shittyscreen_cons_t[] = {{0, "Okay"}, {1, "Shitty"}, {2, "Extra Shitty"}, {0, NULL}};
@@ -215,7 +215,10 @@ void SCR_Startup(void)
CV_RegisterVar(&cv_menucaps); CV_RegisterVar(&cv_menucaps);
CV_RegisterVar(&cv_constextsize); CV_RegisterVar(&cv_constextsize);
#ifdef BACKWARDSCOMPATCORRECTION
CV_RegisterVar(&cv_globalgamma); CV_RegisterVar(&cv_globalgamma);
#endif
CV_RegisterVar(&cv_globalbrightness);
CV_RegisterVar(&cv_globalsaturation); CV_RegisterVar(&cv_globalsaturation);
CV_RegisterVar(&cv_rhue); CV_RegisterVar(&cv_rhue);
@@ -225,12 +228,12 @@ void SCR_Startup(void)
CV_RegisterVar(&cv_bhue); CV_RegisterVar(&cv_bhue);
CV_RegisterVar(&cv_mhue); CV_RegisterVar(&cv_mhue);
CV_RegisterVar(&cv_rgamma); CV_RegisterVar(&cv_rbrightness);
CV_RegisterVar(&cv_ygamma); CV_RegisterVar(&cv_ybrightness);
CV_RegisterVar(&cv_ggamma); CV_RegisterVar(&cv_gbrightness);
CV_RegisterVar(&cv_cgamma); CV_RegisterVar(&cv_cbrightness);
CV_RegisterVar(&cv_bgamma); CV_RegisterVar(&cv_bbrightness);
CV_RegisterVar(&cv_mgamma); CV_RegisterVar(&cv_mbrightness);
CV_RegisterVar(&cv_rsaturation); CV_RegisterVar(&cv_rsaturation);
CV_RegisterVar(&cv_ysaturation); CV_RegisterVar(&cv_ysaturation);
-3
View File
@@ -35,9 +35,6 @@
#define _CREATE_DLL_ // necessary for Unix AND Windows #define _CREATE_DLL_ // necessary for Unix AND Windows
#define GETFUNC(func) \
else if (0 == strcmp(#func, funcName)) \
funcPointer = &func \
// //
// //
/** \brief The *hwSym function /** \brief The *hwSym function
+3 -3
View File
@@ -107,7 +107,7 @@ static void NET_Get(void)
{ {
size_t i; size_t i;
newnode++; newnode++;
M_Memcpy(&clientaddress[newnode], &mypacket.address, sizeof (IPaddress)); memcpy(&clientaddress[newnode], &mypacket.address, sizeof (IPaddress));
DEBFILE(va("New node detected: node:%d address:%s\n", newnode, DEBFILE(va("New node detected: node:%d address:%s\n", newnode,
NET_GetNodeAddress(newnode))); NET_GetNodeAddress(newnode)));
doomcom->remotenode = newnode; // good packet from a game player doomcom->remotenode = newnode; // good packet from a game player
@@ -257,7 +257,7 @@ static SINT8 NET_NetMakeNodewPort(const char *hostname, const char *port)
return newnode; return newnode;
} }
newnode++; newnode++;
M_Memcpy(&clientaddress[newnode],&hostnameIP,sizeof (IPaddress)); memcpy(&clientaddress[newnode],&hostnameIP,sizeof (IPaddress));
return (SINT8)newnode; return (SINT8)newnode;
} }
@@ -303,7 +303,7 @@ static boolean NET_Ban(INT32 node)
if (numbans == MAXBANS) if (numbans == MAXBANS)
return false; return false;
M_Memcpy(&banned[numbans], &clientaddress[node], sizeof (IPaddress)); memcpy(&banned[numbans], &clientaddress[node], sizeof (IPaddress));
banned[numbans].port = 0; banned[numbans].port = 0;
numbans++; numbans++;
return true; return true;
+34 -64
View File
@@ -719,16 +719,13 @@ static void JoyReset(SDLJoyInfo_t *JoySet)
{ {
SDL_GameControllerClose(JoySet->dev); SDL_GameControllerClose(JoySet->dev);
} }
JoySet->dev = NULL; JoySet->dev = NULL;
JoySet->oldjoy = -1; JoySet->oldjoy = -1;
JoySet->id = -1;
JoySet->axises = JoySet->buttons = JoySet->hats = JoySet->balls = 0; JoySet->axises = JoySet->buttons = JoySet->hats = JoySet->balls = 0;
//JoySet->scale
} }
/** \brief joystick up and running
*/
static INT32 joystick_started[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0};
/** \brief SDL info about joystick /** \brief SDL info about joystick
*/ */
SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS]; SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS];
@@ -783,22 +780,26 @@ void I_UpdateJoystickDeviceIndex(UINT8 player)
/////////////////////////////////////////////// ///////////////////////////////////////////////
if (JoyInfo[player].dev) if (JoyInfo[player].dev)
{ {
cv_usejoystick[player].value = I_GetJoystickDeviceIndex(JoyInfo[player].dev) + 1; cv_usejoystick[player].value = JoyInfo[player].id + 1;
} }
else else
{ {
UINT8 joystickID, compareJoystick; UINT8 joystickID, compareJoystick;
for (joystickID = 0; joystickID < MAXSPLITSCREENPLAYERS; joystickID++) for (joystickID = 0; joystickID < MAXSPLITSCREENPLAYERS; joystickID++)
{ {
// is this cv_usejoystick used? // is this cv_usejoystick used?
const INT32 value = atoi(cv_usejoystick[joystickID].string); const INT32 value = atoi(cv_usejoystick[joystickID].string);
for (compareJoystick = 0; compareJoystick < MAXSPLITSCREENPLAYERS; compareJoystick++) for (compareJoystick = 0; compareJoystick < MAXSPLITSCREENPLAYERS; compareJoystick++)
{ {
if (compareJoystick == player) if (compareJoystick == player)
continue; continue;
if (value == JoyInfo[compareJoystick].oldjoy || value == cv_usejoystick[compareJoystick].value) if (value == JoyInfo[compareJoystick].oldjoy || value == cv_usejoystick[compareJoystick].value)
break; break;
} }
if (compareJoystick == MAXSPLITSCREENPLAYERS) if (compareJoystick == MAXSPLITSCREENPLAYERS)
{ {
// We DID make it through the whole loop, so we can use this one! // We DID make it through the whole loop, so we can use this one!
@@ -806,6 +807,7 @@ void I_UpdateJoystickDeviceIndex(UINT8 player)
break; break;
} }
} }
if (joystickID == MAXSPLITSCREENPLAYERS) if (joystickID == MAXSPLITSCREENPLAYERS)
{ {
// We DID NOT make it through the whole loop, so we can't assign this joystick to anything. // We DID NOT make it through the whole loop, so we can't assign this joystick to anything.
@@ -828,14 +830,6 @@ void I_UpdateJoystickDeviceIndices(UINT8 excludePlayer)
} }
} }
/** \brief Joystick buttons states
*/
static UINT64 lastjoybuttons[MAXSPLITSCREENPLAYERS] = {0,0,0,0};
/** \brief Joystick hats state
*/
static UINT64 lastjoyhats[MAXSPLITSCREENPLAYERS] = {0,0,0,0};
/** \brief Shuts down joystick /** \brief Shuts down joystick
\return void \return void
*/ */
@@ -847,74 +841,34 @@ void I_ShutdownJoystick(UINT8 index)
event.data2 = 0; event.data2 = 0;
event.data3 = 0; event.data3 = 0;
lastjoybuttons[index] = lastjoyhats[index] = 0;
// emulate the up of all joystick buttons // emulate the up of all joystick buttons
for (i = 0; i < JOYBUTTONS; i++) for (i = 0; i < JOYBUTTONS; i++)
{ {
event.data1=KEY_JOY1 + i; event.data1 = KEY_JOY1 + i;
D_PostEvent(&event); D_PostEvent(&event);
} }
// emulate the up of all joystick hats // emulate the up of all joystick hats
for (i = 0; i < JOYHATS*4; i++) for (i = 0; i < JOYHATS*4; i++)
{ {
event.data1=KEY_HAT1+i; event.data1 = KEY_HAT1+i;
D_PostEvent(&event); D_PostEvent(&event);
} }
// reset joystick position // reset joystick position
event.type = ev_joystick; event.type = ev_joystick;
for (i = 0; i < JOYAXISSET; i++) for (i = 0; i < JOYAXISSET; i++)
{ {
event.data1 = i; event.data1 = i;
D_PostEvent(&event); D_PostEvent(&event);
} }
joystick_started[index] = 0;
JoyReset(&JoyInfo[index]); JoyReset(&JoyInfo[index]);
// don't shut down the subsystem here, because hotplugging // don't shut down the subsystem here, because hotplugging
} }
void I_GetJoystickEvents(UINT8 index)
{
static event_t event = {};
INT32 i = 0;
UINT64 joyhats = 0;
if (!joystick_started[index])
return;
if (!JoyInfo[index].dev) //I_ShutdownJoystick();
return;
joyhats |= SDL_GameControllerGetButton(JoyInfo[index].dev, SDL_CONTROLLER_BUTTON_DPAD_UP);
joyhats |= SDL_GameControllerGetButton(JoyInfo[index].dev, SDL_CONTROLLER_BUTTON_DPAD_DOWN) << 1;
joyhats |= SDL_GameControllerGetButton(JoyInfo[index].dev, SDL_CONTROLLER_BUTTON_DPAD_LEFT) << 2;
joyhats |= SDL_GameControllerGetButton(JoyInfo[index].dev, SDL_CONTROLLER_BUTTON_DPAD_RIGHT) << 3;
if (joyhats != lastjoyhats[index])
{
INT64 j = 1; // keep only bits that changed since last time
INT64 newhats = joyhats ^ lastjoyhats[index];
lastjoyhats[index] = joyhats;
for (i = 0; i < JOYHATS*4; i++, j <<= 1)
{
if (newhats & j) // hat changed state?
{
if (joyhats & j)
event.type = ev_keydown;
else
event.type = ev_keyup;
event.data1 = KEY_HAT1 + i;
D_PostEvent(&event);
}
}
}
}
/** \brief Open joystick handle /** \brief Open joystick handle
\param fname name of joystick \param fname name of joystick
@@ -931,6 +885,7 @@ static int joy_open(int playerIndex, int joyIndex)
CONS_Printf(M_GetText("Joystick subsystem not started\n")); CONS_Printf(M_GetText("Joystick subsystem not started\n"));
return -1; return -1;
} }
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0) if (SDL_WasInit(SDL_INIT_GAMECONTROLLER) == 0)
{ {
CONS_Printf(M_GetText("Game Controller subsystem not started\n")); CONS_Printf(M_GetText("Game Controller subsystem not started\n"));
@@ -965,12 +920,14 @@ static int joy_open(int playerIndex, int joyIndex)
if (JoyInfo[playerIndex].dev == newdev // same device, nothing to do if (JoyInfo[playerIndex].dev == newdev // same device, nothing to do
|| (newdev == NULL && SDL_GameControllerGetAttached(JoyInfo[playerIndex].dev))) // we failed, but already have a working device || (newdev == NULL && SDL_GameControllerGetAttached(JoyInfo[playerIndex].dev))) // we failed, but already have a working device
return SDL_CONTROLLER_AXIS_MAX; return SDL_CONTROLLER_AXIS_MAX;
// Else, we're changing devices, so send neutral joy events // Else, we're changing devices, so send neutral joy events
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n"); CONS_Debug(DBG_GAMELOGIC, "Joystick1 device is changing; resetting events...\n");
I_ShutdownJoystick(playerIndex); I_ShutdownJoystick(playerIndex);
} }
JoyInfo[playerIndex].dev = newdev; JoyInfo[playerIndex].dev = newdev;
JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev);
if (JoyInfo[playerIndex].dev == NULL) if (JoyInfo[playerIndex].dev == NULL)
{ {
@@ -1007,8 +964,9 @@ void I_InitJoystick(UINT8 index)
UINT8 i; UINT8 i;
SDL_GameController *newcontroller = NULL; SDL_GameController *newcontroller = NULL;
//I_ShutdownJoystick(); // not sure if this is the best place to put this
//SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE); SDL_SetHint(SDL_HINT_AUTO_UPDATE_SENSORS, "0");
if (M_CheckParm("-nojoy")) if (M_CheckParm("-nojoy"))
return; return;
@@ -1037,6 +995,11 @@ void I_InitJoystick(UINT8 index)
} }
} }
JoyInfo[index].dev = NULL;
JoyInfo[index].oldjoy = -1;
JoyInfo[index].id = -1;
JoyInfo[index].axises = JoyInfo[index].buttons = JoyInfo[index].hats = JoyInfo[index].balls = 0;
if (cv_usejoystick[index].value) if (cv_usejoystick[index].value)
newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1); newcontroller = SDL_GameControllerOpen(cv_usejoystick[index].value-1);
@@ -1049,23 +1012,24 @@ void I_InitJoystick(UINT8 index)
break; break;
} }
JoyInfo[index].id = I_GetJoystickDeviceIndex(JoyInfo[index].dev);
if (newcontroller && i < MAXSPLITSCREENPLAYERS) // don't override an active device if (newcontroller && i < MAXSPLITSCREENPLAYERS) // don't override an active device
{ {
cv_usejoystick[index].value = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1; cv_usejoystick[index].value = JoyInfo[index].id + 1;
} }
else if (newcontroller && joy_open(index, cv_usejoystick[index].value) != -1) else if (newcontroller && joy_open(index, cv_usejoystick[index].value) != -1)
{ {
// SDL's device indexes are unstable, so cv_usejoystick may not match // SDL's device indexes are unstable, so cv_usejoystick may not match
// the actual device index. So let's cheat a bit and find the device's current index. // the actual device index. So let's cheat a bit and find the device's current index.
JoyInfo[index].oldjoy = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1; JoyInfo[index].oldjoy = JoyInfo[index].id + 1;
joystick_started[index] = 1;
} }
else else
{ {
if (JoyInfo[index].oldjoy) if (JoyInfo[index].oldjoy)
I_ShutdownJoystick(index); I_ShutdownJoystick(index);
cv_usejoystick[index].value = 0; cv_usejoystick[index].value = 0;
joystick_started[index] = 0;
} }
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
@@ -1130,8 +1094,10 @@ static void I_ShutdownInput(void)
INT32 I_NumJoys(void) INT32 I_NumJoys(void)
{ {
INT32 numjoy = 0; INT32 numjoy = 0;
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
numjoy = SDL_NumJoysticks(); numjoy = SDL_NumJoysticks();
return numjoy; return numjoy;
} }
@@ -1142,15 +1108,18 @@ const char *I_GetJoyName(INT32 joyindex)
const char *tempname = NULL; const char *tempname = NULL;
joyname[0] = 0; joyname[0] = 0;
joyindex--; //SDL's Joystick System starts at 0, not 1 joyindex--; //SDL's Joystick System starts at 0, not 1
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK) if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
{ {
tempname = SDL_JoystickNameForIndex(joyindex); tempname = SDL_JoystickNameForIndex(joyindex);
if (tempname) if (tempname)
{ {
memcpy(joyname, tempname, 255); memcpy(joyname, tempname, 255);
joyname[255] = '\0'; joyname[255] = '\0';
} }
} }
return joyname; return joyname;
} }
@@ -2288,8 +2257,9 @@ char *I_GetUserName(void)
} }
if (strcmp(username, "") != 0) if (!fastcmp(username, ""))
return username; return username;
return NULL; // dummy for platform independent version return NULL; // dummy for platform independent version
} }
+162 -78
View File
@@ -523,6 +523,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
#ifdef USE_FBO_OGL #ifdef USE_FBO_OGL
I_DownSample(); I_DownSample();
#endif #endif
windowmoved = SDL_FALSE;
} }
if (mousefocus && kbfocus) if (mousefocus && kbfocus)
@@ -557,7 +558,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt)
static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
{ {
event_t event; event_t event = {0};
switch (type) switch (type)
{ {
@@ -585,7 +586,9 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
} }
if (event.data1) if (event.data1)
{
D_PostEvent(&event); D_PostEvent(&event);
}
} }
static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
@@ -637,7 +640,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt)
static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
{ {
event_t event; event_t event = {0};
// Ignore the event if the mouse is not actually focused on the window. // Ignore the event if the mouse is not actually focused on the window.
// This can happen if you used the mouse to restore keyboard focus; // This can happen if you used the mouse to restore keyboard focus;
@@ -650,8 +653,6 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
/// \todo inputEvent.button.which /// \todo inputEvent.button.which
if (USE_MOUSEINPUT) if (USE_MOUSEINPUT)
{ {
SDL_memset(&event, 0, sizeof(event_t));
switch (type) switch (type)
{ {
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
@@ -692,27 +693,28 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type)
static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt) static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
{ {
event_t event; event_t event = {0};
if (USE_MOUSEINPUT) if (USE_MOUSEINPUT)
{ {
SDL_memset(&event, 0, sizeof(event_t));
if (evt.y > 0) if (evt.y > 0)
{ {
event.data1 = KEY_MOUSEWHEELUP; event.data1 = KEY_MOUSEWHEELUP;
event.type = ev_keydown; event.type = ev_keydown;
} }
if (evt.y < 0) if (evt.y < 0)
{ {
event.data1 = KEY_MOUSEWHEELDOWN; event.data1 = KEY_MOUSEWHEELDOWN;
event.type = ev_keydown; event.type = ev_keydown;
} }
if (evt.y == 0) if (evt.y == 0)
{ {
event.data1 = 0; event.data1 = 0;
event.type = ev_keyup; event.type = ev_keyup;
} }
if (event.type == ev_keyup || event.type == ev_keydown) if (event.type == ev_keyup || event.type == ev_keydown)
{ {
D_PostEvent(&event); D_PostEvent(&event);
@@ -720,40 +722,78 @@ static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
} }
} }
static UINT8 hatrepeattimer[MAXSPLITSCREENPLAYERS];
#define HATREPEATDELAY 19
void I_HandleControllerHatRepeat(void)
{
// why bother if theres no controllers?
if (numcontrollers == 0)
return;
event_t event = {ev_keydown, 0, 0, 0};
static const SDL_GameControllerButton hatbutt[4] =
{
SDL_CONTROLLER_BUTTON_DPAD_UP,
SDL_CONTROLLER_BUTTON_DPAD_DOWN,
SDL_CONTROLLER_BUTTON_DPAD_LEFT,
SDL_CONTROLLER_BUTTON_DPAD_RIGHT
};
for (int i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
if (!cv_usejoystick[i].value)
continue;
SDL_GameController *controller = JoyInfo[i].dev;
if (!controller)
continue;
for (UINT8 h = 0; h < JOYHATS; h++)
{
if (SDL_GameControllerGetButton(controller, hatbutt[h]))
{
if (hatrepeattimer[i] < HATREPEATDELAY)
{
hatrepeattimer[i]++;
}
else if (hatrepeattimer[i] == HATREPEATDELAY)
{
event.data1 = KEY_HAT1 + (i * JOYHATS) + h;
D_PostEvent(&event);
}
return;
}
}
hatrepeattimer[i] = 0;
}
}
static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt) static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
{ {
event_t event; event_t event;
SDL_JoystickID joyid[4];
INT32 value; INT32 value;
UINT8 i; UINT8 i;
// Determine the Joystick IDs for each current open joystick // Determine the Joystick IDs for each current open joystick
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
joyid[i] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)); if (evt.which == JoyInfo[i].id)
{
event.type = ev_joystick + i;
break;
}
} }
if (i == MAXSPLITSCREENPLAYERS)
return;
event.data1 = event.data2 = event.data3 = INT32_MAX; event.data1 = event.data2 = event.data3 = INT32_MAX;
if (evt.which == joyid[0])
{
event.type = ev_joystick;
}
else if (evt.which == joyid[1])
{
event.type = ev_joystick2;
}
else if (evt.which == joyid[2])
{
event.type = ev_joystick3;
}
else if (evt.which == joyid[3])
{
event.type = ev_joystick4;
}
else
return;
//axis //axis
if (evt.axis > JOYAXISSET*2) if (evt.axis > JOYAXISSET*2)
return; return;
@@ -789,47 +829,89 @@ static void Impl_HandleControllerAxisEvent(SDL_ControllerAxisEvent evt)
default: default:
return; return;
} }
D_PostEvent(&event); D_PostEvent(&event);
} }
static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint32 type) static void Impl_HandleControllerHatEvent(SDL_ControllerButtonEvent evt, Uint32 type)
{ {
event_t event; event_t event = {0};
SDL_JoystickID joyid[4];
UINT8 i; UINT8 i;
static const int hat_buttons_base[] = {KEY_HAT1, KEY_2HAT1, KEY_3HAT1, KEY_4HAT1};
// Determine the Joystick IDs for each current open joystick // Determine the Joystick IDs for each current open joystick
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
joyid[i] = SDL_JoystickInstanceID(SDL_GameControllerGetJoystick(JoyInfo[i].dev)); if (evt.which == JoyInfo[i].id)
{
event.data1 = hat_buttons_base[i];
break;
}
} }
if ( evt.button == SDL_CONTROLLER_BUTTON_DPAD_UP if (i == MAXSPLITSCREENPLAYERS)
|| evt.button == SDL_CONTROLLER_BUTTON_DPAD_DOWN return;
|| evt.button == SDL_CONTROLLER_BUTTON_DPAD_LEFT
|| evt.button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT) switch (type)
{ {
// dpad buttons are mapped as the hat instead case SDL_CONTROLLERBUTTONUP:
event.type = ev_keyup;
break;
case SDL_CONTROLLERBUTTONDOWN:
event.type = ev_keydown;
break;
default:
return;
}
switch (evt.button)
{
case SDL_CONTROLLER_BUTTON_DPAD_UP:
break;
case SDL_CONTROLLER_BUTTON_DPAD_DOWN:
event.data1 += 1;
break;
case SDL_CONTROLLER_BUTTON_DPAD_LEFT:
event.data1 += 2;
break;
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT:
event.data1 += 3;
break;
default:
return;
}
if (event.type != ev_console)
{
D_PostEvent(&event);
}
}
static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint32 type)
{
event_t event = {0};
UINT8 i;
static const int buttons_base[] = {KEY_JOY1, KEY_2JOY1, KEY_3JOY1, KEY_4JOY1};
// dpad special case handling
if (evt.button >= SDL_CONTROLLER_BUTTON_DPAD_UP &&
evt.button <= SDL_CONTROLLER_BUTTON_DPAD_RIGHT)
{
Impl_HandleControllerHatEvent(evt, type);
return; return;
} }
if (evt.which == joyid[0]) // Determine the Joystick IDs for each current open joystick
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
event.data1 = KEY_JOY1; if (evt.which == JoyInfo[i].id)
{
event.data1 = buttons_base[i];
break;
}
} }
else if (evt.which == joyid[1])
{ if (i == MAXSPLITSCREENPLAYERS)
event.data1 = KEY_2JOY1;
}
else if (evt.which == joyid[2])
{
event.data1 = KEY_3JOY1;
}
else if (evt.which == joyid[3])
{
event.data1 = KEY_4JOY1;
}
else
return; return;
switch (type) switch (type)
@@ -852,7 +934,9 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint
return; return;
if (event.type != ev_console) if (event.type != ev_console)
{
D_PostEvent(&event); D_PostEvent(&event);
}
} }
static void Impl_HandleControllerAddedEvent(SDL_Event evt) static void Impl_HandleControllerAddedEvent(SDL_Event evt)
@@ -905,7 +989,7 @@ static void Impl_HandleControllerAddedEvent(SDL_Event evt)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
if (!strcmp(cv_usejoystick[i].string, "0") || !cv_usejoystick[i].value) if (fastcmp(cv_usejoystick[i].string, "0") || !cv_usejoystick[i].value)
cv_usejoystick[i].value = 0; cv_usejoystick[i].value = 0;
else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
&& cv_usejoystick[i].value) // update the cvar ONLY if a device exists && cv_usejoystick[i].value) // update the cvar ONLY if a device exists
@@ -977,7 +1061,7 @@ static void Impl_HandleControllerRemovedEvent(void)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{ {
if (!strcmp(cv_usejoystick[i].string, "0")) if (fastcmp(cv_usejoystick[i].string, "0"))
{ {
cv_usejoystick[i].value = 0; cv_usejoystick[i].value = 0;
} }
@@ -1096,7 +1180,6 @@ void I_StartupMouse(void)
void I_OsPolling(void) void I_OsPolling(void)
{ {
SDL_Keymod mod; SDL_Keymod mod;
INT32 i;
if (consolevent) if (consolevent)
I_GetConsoleEvents(); I_GetConsoleEvents();
@@ -1104,9 +1187,6 @@ void I_OsPolling(void)
if (SDL_WasInit(SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER) == (SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER)) if (SDL_WasInit(SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER) == (SDL_INIT_JOYSTICK|SDL_INIT_GAMECONTROLLER))
{ {
SDL_GameControllerUpdate(); SDL_GameControllerUpdate();
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
I_GetJoystickEvents(i);
} }
I_GetEvent(); I_GetEvent();
@@ -1329,14 +1409,12 @@ void I_UpdateNoBlit(void)
if (rendermode == render_opengl) if (rendermode == render_opengl)
{ {
OglSdlFinishUpdate(cv_vidwait.value); OglSdlFinishUpdate(cv_vidwait.value);
return;
} }
else
#endif #endif
if (rendermode == render_soft) SDL_RenderCopy(renderer, texture, NULL, NULL);
{ SDL_RenderPresent(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_RenderPresent(renderer);
}
} }
exposevideo = SDL_FALSE; exposevideo = SDL_FALSE;
@@ -1371,7 +1449,15 @@ void I_FinishUpdate(void)
ST_AskToJoinEnvelope(); ST_AskToJoinEnvelope();
#endif #endif
if (rendermode == render_soft && vid.screens[0]) #ifdef HWRENDER
if (rendermode == render_opengl)
{
OglSdlFinishUpdate(cv_vidwait.value);
return;
}
#endif
if (vid.screens[0])
{ {
void *pixels; void *pixels;
int pitch; int pitch;
@@ -1393,12 +1479,6 @@ void I_FinishUpdate(void)
SDL_RenderCopy(renderer, texture, &src_rect, NULL); SDL_RenderCopy(renderer, texture, &src_rect, NULL);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }
#ifdef HWRENDER
else if (rendermode == render_opengl)
{
OglSdlFinishUpdate(cv_vidwait.value);
}
#endif
exposevideo = SDL_FALSE; exposevideo = SDL_FALSE;
} }
@@ -1421,7 +1501,8 @@ void I_ReadScreen(UINT8 * restrict scr, INT32 scale)
{ {
if (rendermode != render_soft) if (rendermode != render_soft)
I_Error("I_ReadScreen: called while in non-software mode"); I_Error("I_ReadScreen: called while in non-software mode");
else if (scale == 1)
if (scale == 1)
VID_BlitLinearScreen(vid.screens[0], scr, vid.width, vid.height, vid.width, vid.width); VID_BlitLinearScreen(vid.screens[0], scr, vid.width, vid.height, vid.width, vid.width);
else else
{ {
@@ -1596,8 +1677,9 @@ static SDL_bool Impl_CreateContext(void)
} }
SDL_GL_MakeCurrent(window, sdlglcontext); SDL_GL_MakeCurrent(window, sdlglcontext);
return SDL_TRUE;
} }
else
#endif #endif
if (rendermode == render_soft) if (rendermode == render_soft)
{ {
@@ -1637,9 +1719,11 @@ static SDL_bool Impl_CreateContext(void)
} }
SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT); SDL_RenderSetLogicalSize(renderer, BASEVIDWIDTH, BASEVIDHEIGHT);
return SDL_TRUE;
} }
return SDL_TRUE; return SDL_FALSE;
} }
static SDL_bool Impl_CreateWindow(SDL_bool fullscreen) static SDL_bool Impl_CreateWindow(SDL_bool fullscreen)
@@ -1785,11 +1869,11 @@ void I_StartupGraphics(void)
if (rendermode == render_none) if (rendermode == render_none)
{ {
if (strcasecmp(word, "software") == 0) if (fasticmp(word, "software"))
{ {
rendermode = render_soft; rendermode = render_soft;
} }
else if (strcasecmp(word, "opengl") == 0) else if (fasticmp(word, "opengl"))
{ {
rendermode = render_opengl; rendermode = render_opengl;
} }
@@ -1802,7 +1886,7 @@ void I_StartupGraphics(void)
if (!msaa_set) if (!msaa_set)
{ {
if (strcasecmp(word, "msaa") == 0) if (fasticmp(word, "msaa"))
{ {
const char *nextword = strtok(NULL, " \n"); const char *nextword = strtok(NULL, " \n");
@@ -1819,7 +1903,7 @@ void I_StartupGraphics(void)
if (!a2c_set) if (!a2c_set)
{ {
if (strcasecmp(word, "a2c") == 0) if (fasticmp(word, "a2c"))
{ {
a2c = true; a2c = true;
CONS_Printf("Using a2c because it was specified to be used earlier\n"); CONS_Printf("Using a2c because it was specified to be used earlier\n");
+1 -1
View File
@@ -73,7 +73,7 @@ write netcode into the sound code, OKAY?
//static UINT16 BUFFERSIZE = 2048; //static UINT16 BUFFERSIZE = 2048;
static UINT16 SAMPLERATE = 44100; static const UINT16 SAMPLERATE = 44100;
#ifdef HAVE_OPENMPT #ifdef HAVE_OPENMPT
#include "libopenmpt/libopenmpt.h" #include "libopenmpt/libopenmpt.h"
+5 -2
View File
@@ -170,8 +170,8 @@ boolean OglSdlSurface(INT32 w, INT32 h)
} }
} }
if (strcmp((const char*)gl_renderer, "GDI Generic") == 0 && if (fastcmp((const char*)gl_renderer, "GDI Generic") &&
strcmp((const char*)gl_version, "1.1.0") == 0) fastcmp((const char*)gl_version, "1.1.0"))
{ {
// Oh no... Windows gave us the GDI Generic rasterizer, so something is wrong... // Oh no... Windows gave us the GDI Generic rasterizer, so something is wrong...
// The game will crash later on when unsupported OpenGL commands are encountered. // The game will crash later on when unsupported OpenGL commands are encountered.
@@ -197,6 +197,9 @@ boolean OglSdlSurface(INT32 w, INT32 h)
else else
maximumAnisotropy = 1; maximumAnisotropy = 1;
if (GL_isExtAvailable("GL_ARB_texture_non_power_of_two", gl_extensions))
supportNPO2tex = true;
glanisotropicmode_cons_t[1].value = maximumAnisotropy; glanisotropicmode_cons_t[1].value = maximumAnisotropy;
#if defined (__unix__) #if defined (__unix__)
+5 -5
View File
@@ -244,7 +244,7 @@ static void *getsfx(lumpnum_t sfxlump, size_t *len)
sfxcvt.len = (INT32)size-8; //Alam: Chop off the header sfxcvt.len = (INT32)size-8; //Alam: Chop off the header
sfxcvt.buf = malloc(sfxcvt.len * sfxcvt.len_mult); //Alam: make room sfxcvt.buf = malloc(sfxcvt.len * sfxcvt.len_mult); //Alam: make room
if (sfxcvt.buf) M_Memcpy(sfxcvt.buf, &(sfx->data), sfxcvt.len); //Alam: copy the sfx sample if (sfxcvt.buf) memcpy(sfxcvt.buf, &(sfx->data), sfxcvt.len); //Alam: copy the sfx sample
if (sfxcvt.buf && SDL_ConvertAudio(&sfxcvt) == 0) //Alam: let convert it! if (sfxcvt.buf && SDL_ConvertAudio(&sfxcvt) == 0) //Alam: let convert it!
{ {
@@ -255,9 +255,9 @@ static void *getsfx(lumpnum_t sfxlump, size_t *len)
paddedsfx = (dssfx_t *) Z_Malloc(size, PU_SOUND, NULL); paddedsfx = (dssfx_t *) Z_Malloc(size, PU_SOUND, NULL);
// Now copy and pad. // Now copy and pad.
M_Memcpy(paddedsfx->data, sfxcvt.buf, sfxcvt.len_cvt); memcpy(paddedsfx->data, sfxcvt.buf, sfxcvt.len_cvt);
free(sfxcvt.buf); free(sfxcvt.buf);
M_Memcpy(paddedsfx,sfx,8); memcpy(paddedsfx,sfx,8);
paddedsfx->samplerate = SHORT(csr); // new freq paddedsfx->samplerate = SHORT(csr); // new freq
} }
else //Alam: the convert failed, not needed or I couldn't malloc the buf else //Alam: the convert failed, not needed or I couldn't malloc the buf
@@ -266,7 +266,7 @@ static void *getsfx(lumpnum_t sfxlump, size_t *len)
*len = size - 8; *len = size - 8;
// Allocate from zone memory then copy and pad // Allocate from zone memory then copy and pad
paddedsfx = (dssfx_t *)M_Memcpy(Z_Malloc(size, PU_SOUND, NULL), sfx, size); paddedsfx = (dssfx_t *)memcpy(Z_Malloc(size, PU_SOUND, NULL), sfx, size);
} }
} }
else else
@@ -276,7 +276,7 @@ static void *getsfx(lumpnum_t sfxlump, size_t *len)
*len = size - 8; *len = size - 8;
// Allocate from zone memory then copy and pad // Allocate from zone memory then copy and pad
paddedsfx = (dssfx_t *)M_Memcpy(Z_Malloc(size, PU_SOUND, NULL), sfx, size); paddedsfx = (dssfx_t *)memcpy(Z_Malloc(size, PU_SOUND, NULL), sfx, size);
} }
// Remove the cached lump. // Remove the cached lump.
+2
View File
@@ -42,6 +42,8 @@ typedef struct SDLJoyInfo_s
{ {
/// Controller handle /// Controller handle
SDL_GameController *dev; SDL_GameController *dev;
/// Controller index
INT32 id;
/// number of old joystick /// number of old joystick
int oldjoy; int oldjoy;
/// number of axies /// number of axies
+3 -1
View File
@@ -1018,6 +1018,8 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean
else else
slot = sfx_freeslot0; slot = sfx_freeslot0;
const int precache = S_CacheSound();
for (i = slot; i < NUMSFX; i++) for (i = slot; i < NUMSFX; i++)
{ {
if (!S_sfx[i].priority) if (!S_sfx[i].priority)
@@ -1030,7 +1032,7 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean
S_sfx[i].length = 0; S_sfx[i].length = 0;
S_sfx[i].skinsound = -1; S_sfx[i].skinsound = -1;
if (S_PrecacheSound()) if (precache == SOUNDCACHE_PRECACHE)
S_sfx[i].data = I_GetSfx(&S_sfx[i]); S_sfx[i].data = I_GetSfx(&S_sfx[i]);
else else
S_sfx[i].data = NULL; S_sfx[i].data = NULL;
+168 -162
View File
@@ -23,7 +23,6 @@
#include "r_main.h" #include "r_main.h"
#include "r_fps.h" #include "r_fps.h"
#include "console.h" #include "console.h"
#include "i_video.h" // rendermode #include "i_video.h" // rendermode
#include "z_zone.h" #include "z_zone.h"
#include "m_misc.h" #include "m_misc.h"
@@ -43,8 +42,13 @@ static void CV_palette_OnChange(void);
consvar_t cv_palette = {"palette", "", CV_CALL|CV_NOINIT, NULL, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_palette = {"palette", "", CV_CALL|CV_NOINIT, NULL, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_palettenum = {"palettenum", "0", CV_CALL|CV_NOINIT, CV_Unsigned, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_palettenum = {"palettenum", "0", CV_CALL|CV_NOINIT, CV_Unsigned, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t gamma_cons_t[] = {{-15, "MIN"}, {4, "MAX"}, {0, NULL}}; #ifdef BACKWARDSCOMPATCORRECTION
static CV_PossibleValue_t gamma_cons_t[] = {{0, "MIN"}, {4, "MAX"}, {0, NULL}};
consvar_t cv_globalgamma = {"gamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_globalgamma = {"gamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
#endif
static CV_PossibleValue_t brightness_cons_t[] = {{-15, "MIN"}, {5, "MAX"}, {0, NULL}};
consvar_t cv_globalbrightness = {"brightness", "0", CV_SAVE|CV_CALL, brightness_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t saturation_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; static CV_PossibleValue_t saturation_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}};
consvar_t cv_globalsaturation = {"saturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_globalsaturation = {"saturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
@@ -59,12 +63,12 @@ consvar_t cv_chue = {"chue", "12", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnCha
consvar_t cv_bhue = {"bhue", "16", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_bhue = {"bhue", "16", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mhue = {"mhue", "20", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mhue = {"mhue", "20", CV_SAVE|CV_CALL, hue_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_rgamma = {"rgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_rbrightness = {"rbrightness", "0", CV_SAVE|CV_CALL, brightness_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_ygamma = {"ygamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_ybrightness = {"ybrightness", "0", CV_SAVE|CV_CALL, brightness_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_ggamma = {"ggamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_gbrightness = {"gbrightness", "0", CV_SAVE|CV_CALL, brightness_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_cgamma = {"cgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cbrightness = {"cbrightness", "0", CV_SAVE|CV_CALL, brightness_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_bgamma = {"bgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_bbrightness = {"bbrightness", "0", CV_SAVE|CV_CALL, brightness_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mgamma = {"mgamma", "0", CV_SAVE|CV_CALL, gamma_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mbrightness = {"mbrightness", "0", CV_SAVE|CV_CALL, brightness_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_rsaturation = {"rsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_rsaturation = {"rsaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_ysaturation = {"ysaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_ysaturation = {"ysaturation", "10", CV_SAVE|CV_CALL, saturation_cons_t, CV_palette_OnChange, 0, NULL, NULL, 0, 0, NULL};
@@ -85,6 +89,7 @@ consvar_t cv_menucaps = {"menucaps", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NUL
// local copy of the palette for V_GetColor() // local copy of the palette for V_GetColor()
RGBA_t *pLocalPalette = NULL; RGBA_t *pLocalPalette = NULL;
RGBA_t *pGammaCorrectedPalette = NULL;
static size_t currentPaletteSize; static size_t currentPaletteSize;
@@ -95,7 +100,7 @@ Please check it out if you're trying to maintain this.
toast 18/04/17 toast 18/04/17
*/ */
float Cubepal[2][2][2][3]; float Cubepal[2][2][2][3] = {};
boolean Cubeapply = false; boolean Cubeapply = false;
// returns whether to apply cube, selectively avoiding expensive operations // returns whether to apply cube, selectively avoiding expensive operations
@@ -128,100 +133,97 @@ static boolean InitCube(void)
}; };
float desatur[3]; // grey float desatur[3]; // grey
float globalgammamul, globalgammaoffs; float globalbrightnessmul, globalbrightnessoffs;
boolean doinggamma; boolean doingbrightness;
if (!loaded_config) if (!loaded_config)
return false; return false;
#define diffcons(cv) (strcmp(cv.string, cv.defaultvalue)) #define diffcons(cv) (!fastcmp(cv.string, cv.defaultvalue))
#define diffconsgamma(cv) (cv.value != 0) #define diffconsbrightness(cv) (cv.value != 0)
#define diffconssat(cv) (cv.value != 10) #define diffconssat(cv) (cv.value != 10)
#ifdef BACKWARDSCOMPATCORRECTION doingbrightness = diffcons(cv_globalbrightness);
doinggamma = (cv_globalgamma.value < 0); //dont mess up gamma when raising brightness pls
#else
doinggamma = diffcons(cv_globalgamma);
#endif
#define gammascale 8 #define brightnessscale 8
globalgammamul = (cv_globalgamma.value ? ((255.0f - (gammascale*abs(cv_globalgamma.value))) / 255.0f) : 1.0f); globalbrightnessmul = (cv_globalbrightness.value ? ((255.0f - (brightnessscale*abs(cv_globalbrightness.value))) / 255.0f) : 1.0f);
globalgammaoffs = ((cv_globalgamma.value > 0) ? ((gammascale*cv_globalgamma.value) / 255.0f) : 0.0f); globalbrightnessoffs = ((cv_globalbrightness.value > 0) ? ((brightnessscale*cv_globalbrightness.value) / 255.0f) : 0.0f);
desatur[0] = desatur[1] = desatur[2] = globalgammaoffs + (0.33f * globalgammamul); desatur[0] = desatur[1] = desatur[2] = globalbrightnessoffs + (0.33f * globalbrightnessmul);
if (doinggamma if (doingbrightness
|| diffcons(cv_rhue) || diffcons(cv_rhue)
|| diffcons(cv_yhue) || diffcons(cv_yhue)
|| diffcons(cv_ghue) || diffcons(cv_ghue)
|| diffcons(cv_chue) || diffcons(cv_chue)
|| diffcons(cv_bhue) || diffcons(cv_bhue)
|| diffcons(cv_mhue) || diffcons(cv_mhue)
|| diffconsgamma(cv_rgamma) || diffconsbrightness(cv_rbrightness)
|| diffconsgamma(cv_ygamma) || diffconsbrightness(cv_ybrightness)
|| diffconsgamma(cv_ggamma) || diffconsbrightness(cv_gbrightness)
|| diffconsgamma(cv_cgamma) || diffconsbrightness(cv_cbrightness)
|| diffconsgamma(cv_bgamma) || diffconsbrightness(cv_bbrightness)
|| diffconsgamma(cv_mgamma)) // set the gamma'd/hued positions (saturation is done later) || diffconsbrightness(cv_mbrightness)) // set the brightness'd/hued positions (saturation is done later)
{ {
float mod, tempgammamul, tempgammaoffs; float mod, tempbrightnessmul, tempbrightnessoffs;
apply = true; apply = true;
working[0][0][0][0] = working[0][0][0][1] = working[0][0][0][2] = globalgammaoffs; working[0][0][0][0] = working[0][0][0][1] = working[0][0][0][2] = globalbrightnessoffs;
working[1][1][1][0] = working[1][1][1][1] = working[1][1][1][2] = globalgammaoffs+globalgammamul; working[1][1][1][0] = working[1][1][1][1] = working[1][1][1][2] = globalbrightnessoffs+globalbrightnessmul;
#define dohue(hue, gamma, loc) \ #define dohue(hue, brightness, loc) \
tempgammamul = (gamma ? ((255.0f - (gammascale*abs(gamma)))/255.0f)*globalgammamul : globalgammamul);\ tempbrightnessmul = (brightness ? ((255.0f - (brightnessscale*abs(brightness)))/255.0f)*globalbrightnessmul : globalbrightnessmul);\
tempgammaoffs = ((gamma > 0) ? ((gammascale*gamma)/255.0f) + globalgammaoffs : globalgammaoffs);\ tempbrightnessoffs = ((brightness > 0) ? ((brightnessscale*brightness)/255.0f) + globalbrightnessoffs : globalbrightnessoffs);\
mod = ((hue % huecoloursteps)*(tempgammamul)/huecoloursteps);\ mod = ((hue % huecoloursteps)*(tempbrightnessmul)/huecoloursteps);\
switch (hue/huecoloursteps)\ switch (hue/huecoloursteps)\
{\ {\
case 0:\ case 0:\
default:\ default:\
loc[0] = tempgammaoffs+tempgammamul;\ loc[0] = tempbrightnessoffs+tempbrightnessmul;\
loc[1] = tempgammaoffs+mod;\ loc[1] = tempbrightnessoffs+mod;\
loc[2] = tempgammaoffs;\ loc[2] = tempbrightnessoffs;\
break;\ break;\
case 1:\ case 1:\
loc[0] = tempgammaoffs+tempgammamul-mod;\ loc[0] = tempbrightnessoffs+tempbrightnessmul-mod;\
loc[1] = tempgammaoffs+tempgammamul;\ loc[1] = tempbrightnessoffs+tempbrightnessmul;\
loc[2] = tempgammaoffs;\ loc[2] = tempbrightnessoffs;\
break;\ break;\
case 2:\ case 2:\
loc[0] = tempgammaoffs;\ loc[0] = tempbrightnessoffs;\
loc[1] = tempgammaoffs+tempgammamul;\ loc[1] = tempbrightnessoffs+tempbrightnessmul;\
loc[2] = tempgammaoffs+mod;\ loc[2] = tempbrightnessoffs+mod;\
break;\ break;\
case 3:\ case 3:\
loc[0] = tempgammaoffs;\ loc[0] = tempbrightnessoffs;\
loc[1] = tempgammaoffs+tempgammamul-mod;\ loc[1] = tempbrightnessoffs+tempbrightnessmul-mod;\
loc[2] = tempgammaoffs+tempgammamul;\ loc[2] = tempbrightnessoffs+tempbrightnessmul;\
break;\ break;\
case 4:\ case 4:\
loc[0] = tempgammaoffs+mod;\ loc[0] = tempbrightnessoffs+mod;\
loc[1] = tempgammaoffs;\ loc[1] = tempbrightnessoffs;\
loc[2] = tempgammaoffs+tempgammamul;\ loc[2] = tempbrightnessoffs+tempbrightnessmul;\
break;\ break;\
case 5:\ case 5:\
loc[0] = tempgammaoffs+tempgammamul;\ loc[0] = tempbrightnessoffs+tempbrightnessmul;\
loc[1] = tempgammaoffs;\ loc[1] = tempbrightnessoffs;\
loc[2] = tempgammaoffs+tempgammamul-mod;\ loc[2] = tempbrightnessoffs+tempbrightnessmul-mod;\
break;\ break;\
} }
dohue(cv_rhue.value, cv_rgamma.value, working[1][0][0]); dohue(cv_rhue.value, cv_rbrightness.value, working[1][0][0]);
dohue(cv_yhue.value, cv_ygamma.value, working[1][1][0]); dohue(cv_yhue.value, cv_ybrightness.value, working[1][1][0]);
dohue(cv_ghue.value, cv_ggamma.value, working[0][1][0]); dohue(cv_ghue.value, cv_gbrightness.value, working[0][1][0]);
dohue(cv_chue.value, cv_cgamma.value, working[0][1][1]); dohue(cv_chue.value, cv_cbrightness.value, working[0][1][1]);
dohue(cv_bhue.value, cv_bgamma.value, working[0][0][1]); dohue(cv_bhue.value, cv_bbrightness.value, working[0][0][1]);
dohue(cv_mhue.value, cv_mgamma.value, working[1][0][1]); dohue(cv_mhue.value, cv_mbrightness.value, working[1][0][1]);
#undef dohue #undef dohue
} }
#define dosaturation(a, e) a = ((1 - work)*e + work*a) #define dosaturation(a, e) a = ((1 - work)*e + work*a)
#define docvsat(cv_sat, hue, gamma, r, g, b) \ #define docvsat(cv_sat, hue, brightness, r, g, b) \
if diffconssat(cv_sat)\ if diffconssat(cv_sat)\
{\ {\
float work, mod, tempgammamul, tempgammaoffs;\ float work, mod, tempbrightnessmul, tempbrightnessoffs;\
apply = true;\ apply = true;\
work = (cv_sat.value/10.0f);\ work = (cv_sat.value/10.0f);\
mod = ((hue % huecoloursteps)*(1.0f)/huecoloursteps);\ mod = ((hue % huecoloursteps)*(1.0f)/huecoloursteps);\
@@ -229,20 +231,20 @@ static boolean InitCube(void)
mod = 2-mod;\ mod = 2-mod;\
else\ else\
mod += 1;\ mod += 1;\
tempgammamul = (gamma ? ((255.0f - (gammascale*abs(gamma)))/255.0f)*globalgammamul : globalgammamul);\ tempbrightnessmul = (brightness ? ((255.0f - (brightnessscale*abs(brightness)))/255.0f)*globalbrightnessmul : globalbrightnessmul);\
tempgammaoffs = ((gamma > 0) ? ((gammascale*gamma)/255.0f) + globalgammaoffs : globalgammaoffs);\ tempbrightnessoffs = ((brightness > 0) ? ((brightnessscale*brightness)/255.0f) + globalbrightnessoffs : globalbrightnessoffs);\
for (q = 0; q < 3; q++)\ for (q = 0; q < 3; q++)\
dosaturation(working[r][g][b][q], (tempgammaoffs+(desatur[q]*mod*tempgammamul)));\ dosaturation(working[r][g][b][q], (tempbrightnessoffs+(desatur[q]*mod*tempbrightnessmul)));\
} }
docvsat(cv_rsaturation, cv_rhue.value, cv_rgamma.value, 1, 0, 0); docvsat(cv_rsaturation, cv_rhue.value, cv_rbrightness.value, 1, 0, 0);
docvsat(cv_ysaturation, cv_yhue.value, cv_ygamma.value, 1, 1, 0); docvsat(cv_ysaturation, cv_yhue.value, cv_ybrightness.value, 1, 1, 0);
docvsat(cv_gsaturation, cv_ghue.value, cv_ggamma.value, 0, 1, 0); docvsat(cv_gsaturation, cv_ghue.value, cv_gbrightness.value, 0, 1, 0);
docvsat(cv_csaturation, cv_chue.value, cv_cgamma.value, 0, 1, 1); docvsat(cv_csaturation, cv_chue.value, cv_cbrightness.value, 0, 1, 1);
docvsat(cv_bsaturation, cv_bhue.value, cv_bgamma.value, 0, 0, 1); docvsat(cv_bsaturation, cv_bhue.value, cv_bbrightness.value, 0, 0, 1);
docvsat(cv_msaturation, cv_mhue.value, cv_mgamma.value, 1, 0, 1); docvsat(cv_msaturation, cv_mhue.value, cv_mbrightness.value, 1, 0, 1);
#undef gammascale #undef brightnessscale
if diffconssat(cv_globalsaturation) if diffconssat(cv_globalsaturation)
{ {
@@ -265,7 +267,7 @@ static boolean InitCube(void)
#undef dosaturation #undef dosaturation
#undef diffcons #undef diffcons
#undef diffconsgamma #undef diffconsbrightness
#undef diffconssat #undef diffconssat
if (!apply) if (!apply)
@@ -302,24 +304,6 @@ same, I'm not gonna be the one to remove this base modification.
toast 20/04/17 toast 20/04/17
... welp yes i am (27/07/19, see the ifdef around it) ... welp yes i am (27/07/19, see the ifdef around it)
*/ */
const UINT8 correctiontable[256] =
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,
33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,
49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,
65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,
81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,
97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,
113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,
128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255};
const UINT8 gammatable[5][256] = const UINT8 gammatable[5][256] =
{ {
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16, {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
@@ -405,6 +389,26 @@ const UINT8 gammatable[5][256] =
}; };
#endif #endif
UINT32 V_GammaCorrect(UINT32 input, double power)
{
RGBA_t result;
double linear;
result.rgba = input;
linear = ((double)result.s.red)/255.0f;
linear = pow(linear, power)*255.0f;
result.s.red = (UINT8)(linear);
linear = ((double)result.s.green)/255.0f;
linear = pow(linear, power)*255.0f;
result.s.green = (UINT8)(linear);
linear = ((double)result.s.blue)/255.0f;
linear = pow(linear, power)*255.0f;
result.s.blue = (UINT8)(linear);
return result.rgba;
}
// keep a copy of the palette so that we can get the RGB value for a color index at any time. // keep a copy of the palette so that we can get the RGB value for a color index at any time.
static void LoadPalette(const char *lumpname) static void LoadPalette(const char *lumpname)
{ {
@@ -413,7 +417,7 @@ static void LoadPalette(const char *lumpname)
lumpnum_t lumpnum; lumpnum_t lumpnum;
#ifdef BACKWARDSCOMPATCORRECTION #ifdef BACKWARDSCOMPATCORRECTION
const UINT8 *usegamma = gammatable[min(max(cv_globalgamma.value, 0), 4)]; const UINT8 *usegamma = gammatable[cv_globalgamma.value];
#endif #endif
Cubeapply = InitCube(); Cubeapply = InitCube();
@@ -423,25 +427,18 @@ static void LoadPalette(const char *lumpname)
palsize = currentPaletteSize / 3; palsize = currentPaletteSize / 3;
Z_Free(pLocalPalette); Z_Free(pLocalPalette);
Z_Free(pGammaCorrectedPalette);
pLocalPalette = Z_Malloc(sizeof (*pLocalPalette)*palsize, PU_STATIC, NULL); pLocalPalette = Z_Malloc(sizeof (*pLocalPalette)*palsize, PU_STATIC, NULL);
pGammaCorrectedPalette = Z_Malloc(sizeof (*pGammaCorrectedPalette)*palsize, PU_STATIC, NULL);
pal = W_CacheLumpNum(lumpnum, PU_CACHE); pal = W_CacheLumpNum(lumpnum, PU_CACHE);
for (i = 0; i < palsize; i++) for (i = 0; i < palsize; i++)
{ {
#ifdef BACKWARDSCOMPATCORRECTION #ifdef BACKWARDSCOMPATCORRECTION
if (cv_globalgamma.value >= 0 && cv_globalgamma.value <= 4) pLocalPalette[i].s.red = usegamma[*pal++];
{ pLocalPalette[i].s.green = usegamma[*pal++];
pLocalPalette[i].s.red = usegamma[*pal++]; pLocalPalette[i].s.blue = usegamma[*pal++];
pLocalPalette[i].s.green = usegamma[*pal++];
pLocalPalette[i].s.blue = usegamma[*pal++];
}
else
{
pLocalPalette[i].s.red = correctiontable[*pal++];
pLocalPalette[i].s.green = correctiontable[*pal++];
pLocalPalette[i].s.blue = correctiontable[*pal++];
}
#else #else
pLocalPalette[i].s.red = *pal++; pLocalPalette[i].s.red = *pal++;
pLocalPalette[i].s.green = *pal++; pLocalPalette[i].s.green = *pal++;
@@ -449,15 +446,17 @@ static void LoadPalette(const char *lumpname)
#endif #endif
pLocalPalette[i].s.alpha = 0xFF; pLocalPalette[i].s.alpha = 0xFF;
pGammaCorrectedPalette[i].rgba = V_GammaDecode(pLocalPalette[i].rgba);
if (!Cubeapply) if (!Cubeapply)
continue; continue;
// lerp of colour cubing! if you want, make it smoother yourself V_CubeApply(&pGammaCorrectedPalette[i]);
V_CubeApply(&pLocalPalette[i].s.red, &pLocalPalette[i].s.green, &pLocalPalette[i].s.blue); pLocalPalette[i].rgba = V_GammaEncode(pGammaCorrectedPalette[i].rgba);
} }
} }
void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue) void V_CubeApply(RGBA_t *input)
{ {
float working[4][3]; float working[4][3];
float linear; float linear;
@@ -466,7 +465,7 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue)
if (!Cubeapply) if (!Cubeapply)
return; return;
linear = (*red/255.0f); linear = ((*input).s.red/255.0);
#define dolerp(e1, e2) ((1 - linear)*e1 + linear*e2) #define dolerp(e1, e2) ((1 - linear)*e1 + linear*e2)
for (q = 0; q < 3; q++) for (q = 0; q < 3; q++)
{ {
@@ -475,13 +474,15 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue)
working[2][q] = dolerp(Cubepal[0][0][1][q], Cubepal[1][0][1][q]); working[2][q] = dolerp(Cubepal[0][0][1][q], Cubepal[1][0][1][q]);
working[3][q] = dolerp(Cubepal[0][1][1][q], Cubepal[1][1][1][q]); working[3][q] = dolerp(Cubepal[0][1][1][q], Cubepal[1][1][1][q]);
} }
linear = (*green/255.0f);
linear = ((*input).s.green/255.0);
for (q = 0; q < 3; q++) for (q = 0; q < 3; q++)
{ {
working[0][q] = dolerp(working[0][q], working[1][q]); working[0][q] = dolerp(working[0][q], working[1][q]);
working[1][q] = dolerp(working[2][q], working[3][q]); working[1][q] = dolerp(working[2][q], working[3][q]);
} }
linear = (*blue/255.0f);
linear = ((*input).s.blue/255.0);
for (q = 0; q < 3; q++) for (q = 0; q < 3; q++)
{ {
working[0][q] = 255*dolerp(working[0][q], working[1][q]); working[0][q] = 255*dolerp(working[0][q], working[1][q]);
@@ -492,9 +493,9 @@ void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue)
} }
#undef dolerp #undef dolerp
*red = (UINT8)(working[0][0]); (*input).s.red = (UINT8)(working[0][0]);
*green = (UINT8)(working[0][1]); (*input).s.green = (UINT8)(working[0][1]);
*blue = (UINT8)(working[0][2]); (*input).s.blue = (UINT8)(working[0][2]);
} }
const char *R_GetPalname(UINT16 num) const char *R_GetPalname(UINT16 num)
@@ -596,7 +597,7 @@ void V_ResetPaletteCVars(void)
if (!loaded_config) if (!loaded_config)
return; return;
#define diffcons(cv) (strcmp(cv.string, cv.defaultvalue)) #define diffcons(cv) (!fastcmp(cv.string, cv.defaultvalue))
if diffcons(cv_palette) if diffcons(cv_palette)
CV_StealthSetValue(&cv_palette, atoi(cv_palette.defaultvalue)); CV_StealthSetValue(&cv_palette, atoi(cv_palette.defaultvalue));
if diffcons(cv_palettenum) if diffcons(cv_palettenum)
@@ -627,13 +628,13 @@ void VID_BlitLinearScreen(const UINT8 *restrict srcptr, UINT8 *restrict destptr,
i -= 16; i -= 16;
} }
#endif #endif
M_Memcpy(destptr, srcptr, i); memcpy(destptr, srcptr, i);
} }
else else
{ {
while (height--) while (height--)
{ {
M_Memcpy(destptr, srcptr, width); memcpy(destptr, srcptr, width);
destptr += destrowbytes; destptr += destrowbytes;
srcptr += srcrowbytes; srcptr += srcrowbytes;
@@ -1194,7 +1195,7 @@ void V_DrawBlock(INT32 x, INT32 y, INT32 scrn, INT32 width, INT32 height, const
while (height--) while (height--)
{ {
M_Memcpy(dest, src, width); memcpy(dest, src, width);
src += width; src += width;
dest += vid.width; dest += vid.width;
@@ -1329,37 +1330,37 @@ void V_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 c)
// This is now a function since it's otherwise repeated 2 times and honestly looks retarded: // This is now a function since it's otherwise repeated 2 times and honestly looks retarded:
static UINT32 V_GetHWConsBackColor(void) static UINT32 V_GetHWConsBackColor(void)
{ {
UINT8 r, g, b; RGBA_t output;
switch (cons_backcolor.value) switch (cons_backcolor.value)
{ {
case 0: r = 0xff; g = 0xff; b = 0xff; break; // White case 0: output.s.red = 0xff; output.s.green = 0xff; output.s.blue = 0xff; break; // White
case 1: r = 0x80; g = 0x80; b = 0x80; break; // Black case 1: output.s.red = 0x80; output.s.green = 0x80; output.s.blue = 0x80; break; // Black
case 2: r = 0xde; g = 0xb8; b = 0x87; break; // Sepia case 2: output.s.red = 0xde; output.s.green = 0xb8; output.s.blue = 0x87; break; // Sepia
case 3: r = 0x40; g = 0x20; b = 0x10; break; // Brown case 3: output.s.red = 0x40; output.s.green = 0x20; output.s.blue = 0x10; break; // Brown
case 4: r = 0xfa; g = 0x80; b = 0x72; break; // Pink case 4: output.s.red = 0xfa; output.s.green = 0x80; output.s.blue = 0x72; break; // Pink
case 5: r = 0xff; g = 0x69; b = 0xb4; break; // Raspberry case 5: output.s.red = 0xff; output.s.green = 0x69; output.s.blue = 0xb4; break; // Raspberry
case 6: r = 0xff; g = 0x00; b = 0x00; break; // Red case 6: output.s.red = 0xff; output.s.green = 0x00; output.s.blue = 0x00; break; // Red
case 7: r = 0xff; g = 0xd6; b = 0x83; break; // Creamsicle case 7: output.s.red = 0xff; output.s.green = 0xd6; output.s.blue = 0x83; break; // Creamsicle
case 8: r = 0xff; g = 0x80; b = 0x00; break; // Orange case 8: output.s.red = 0xff; output.s.green = 0x80; output.s.blue = 0x00; break; // Orange
case 9: r = 0xda; g = 0xa5; b = 0x20; break; // Gold case 9: output.s.red = 0xda; output.s.green = 0xa5; output.s.blue = 0x20; break; // Gold
case 10: r = 0x80; g = 0x80; b = 0x00; break; // Yellow case 10: output.s.red = 0x80; output.s.green = 0x80; output.s.blue = 0x00; break; // Yellow
case 11: r = 0x00; g = 0xff; b = 0x00; break; // Emerald case 11: output.s.red = 0x00; output.s.green = 0xff; output.s.blue = 0x00; break; // Emerald
case 12: r = 0x00; g = 0x80; b = 0x00; break; // Green case 12: output.s.red = 0x00; output.s.green = 0x80; output.s.blue = 0x00; break; // Green
case 13: r = 0x40; g = 0x80; b = 0xff; break; // Cyan case 13: output.s.red = 0x40; output.s.green = 0x80; output.s.blue = 0xff; break; // Cyan
case 14: r = 0x46; g = 0x82; b = 0xb4; break; // Steel case 14: output.s.red = 0x46; output.s.green = 0x82; output.s.blue = 0xb4; break; // Steel
case 15: r = 0x1e; g = 0x90; b = 0xff; break; // Periwinkle case 15: output.s.red = 0x1e; output.s.green = 0x90; output.s.blue = 0xff; break; // Periwinkle
case 16: r = 0x00; g = 0x00; b = 0xff; break; // Blue case 16: output.s.red = 0x00; output.s.green = 0x00; output.s.blue = 0xff; break; // Blue
case 17: r = 0xff; g = 0x00; b = 0xff; break; // Purple case 17: output.s.red = 0xff; output.s.green = 0x00; output.s.blue = 0xff; break; // Purple
case 18: r = 0xee; g = 0x82; b = 0xee; break; // Lavender case 18: output.s.red = 0xee; output.s.green = 0x82; output.s.blue = 0xee; break; // Lavender
// Default green // Default green
default: r = 0x00; g = 0x80; b = 0x00; break; default: output.s.red = 0x00; output.s.green = 0x80; output.s.blue = 0x00; break;
} }
if (!HWR_ShouldUsePaletteRendering()) if (!HWR_ShouldUsePaletteRendering())
V_CubeApply(&r, &g, &b); V_CubeApply(&output);
return (r << 24) | (g << 16) | (b << 8); return (output.s.red << 24) | (output.s.green << 16) | (output.s.blue << 8);
} }
#endif #endif
@@ -1739,7 +1740,8 @@ void V_DrawHorizontallyScaledFullScreenPatch(patch_t *patch)
void V_DrawVhsEffect(boolean rewind) void V_DrawVhsEffect(boolean rewind)
{ {
static fixed_t upbary = 100, downbary = 150; fixed_t uby, dby;
static fixed_t upbary = 100*FRACUNIT, downbary = 150*FRACUNIT;
UINT8 barsize, updistort, downdistort; UINT8 barsize, updistort, downdistort;
@@ -1760,19 +1762,21 @@ void V_DrawVhsEffect(boolean rewind)
if (rewind) if (rewind)
V_DrawVhsEffect(false); // experimentation V_DrawVhsEffect(false); // experimentation
upbary -= FixedMul(vid.dup * (rewind ? 3 : 1.8f), renderdeltatics); upbary -= renderdeltatics * (vid.dup * (rewind ? 3 : 1.8f));
downbary += FixedMul(vid.dup * (rewind ? 2 : 1), renderdeltatics); downbary += renderdeltatics * (vid.dup * (rewind ? 2 : 1));
if (upbary < -barsize) if (upbary < -barsize*FRACUNIT)
upbary = vid.height; upbary = vid.height << FRACBITS;
if (downbary > vid.height << FRACBITS)
downbary = -barsize*FRACUNIT;
if (downbary > vid.height) uby = upbary >> FRACBITS;
downbary = -barsize; dby = downbary >> FRACBITS;
#ifdef HWRENDER #ifdef HWRENDER
if (rendermode == render_opengl) if (rendermode == render_opengl)
{ {
HWR_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); HWR_RenderVhsEffect(uby, dby, updistort, downdistort, barsize);
return; return;
} }
#endif #endif
@@ -1792,16 +1796,16 @@ void V_DrawVhsEffect(boolean rewind)
thismapstart = normalmapstart; thismapstart = normalmapstart;
offs = 0; offs = 0;
if (y >= upbary && y < upbary+barsize) if (y >= uby && y < uby+barsize)
{ {
thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8); thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8);
offs += updistort * 2.0f * min(y-upbary, upbary+barsize-y) / barsize; offs += updistort * 2.0f * min(y-uby, uby+barsize-y) / barsize;
} }
if (y >= downbary && y < downbary+barsize) if (y >= dby && y < dby+barsize)
{ {
thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8); thismapstart -= (2<<FF_TRANSSHIFT) - (5<<8);
offs -= downdistort * 2.0f * min(y-downbary, downbary+barsize-y) / barsize; offs -= downdistort * 2.0f * min(y-dby, dby+barsize-y) / barsize;
} }
offs += M_RandomKey(vid.dup<<1); offs += M_RandomKey(vid.dup<<1);
@@ -3645,7 +3649,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
if (sine < 0) if (sine < 0)
{ {
M_Memcpy(&tmpscr[(y*vid.width)+xoffset+newpix], &srcscr[(y*vid.width)+xoffset], viewwidth-newpix); memcpy(&tmpscr[(y*vid.width)+xoffset+newpix], &srcscr[(y*vid.width)+xoffset], viewwidth-newpix);
// Cleanup edge // Cleanup edge
while (newpix) while (newpix)
@@ -3656,7 +3660,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
} }
else else
{ {
M_Memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix); memcpy(&tmpscr[(y*vid.width)+xoffset+0], &srcscr[(y*vid.width)+xoffset+sine], viewwidth-newpix);
// Cleanup edge // Cleanup edge
while (newpix) while (newpix)
@@ -3716,10 +3720,10 @@ void V_DoPostProcessor(INT32 view, INT32 param)
{ {
// Shift this row of pixels to the right by 2 // Shift this row of pixels to the right by 2
tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset]; tmpscr[(y*vid.width)+xoffset] = srcscr[(y*vid.width)+xoffset];
M_Memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup); memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset+vid.dup], viewwidth-vid.dup);
} }
else else
M_Memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); memcpy(&tmpscr[(y*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
heatindex[view] %= viewheight; heatindex[view] %= viewheight;
} }
@@ -3756,7 +3760,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
INT32 y, y2; INT32 y, y2;
for (y = yoffset, y2 = yoffset+viewheight - 1; y < yoffset+viewheight; y++, y2--) for (y = yoffset, y2 = yoffset+viewheight - 1; y < yoffset+viewheight; y++, y2--)
M_Memcpy(&tmpscr[(y2*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth); memcpy(&tmpscr[(y2*vid.width)+xoffset], &srcscr[(y*vid.width)+xoffset], viewwidth);
UINT8 *tmp = tmpscr; UINT8 *tmp = tmpscr;
tmpscr = srcscr; tmpscr = srcscr;
@@ -3812,12 +3816,14 @@ void InitColorLUT(colorlookup_t *lut, RGBA_t *palette, boolean makecolors)
UINT8 r, g, b; UINT8 r, g, b;
for (r = 0; r < 0xFF; r++) for (r = 0; r < 0xFF; r++)
for (g = 0; g < 0xFF; g++)
for (b = 0; b < 0xFF; b++)
{ {
i = CLUTINDEX(r, g, b); for (g = 0; g < 0xFF; g++)
if (lut->table[i] == 0xFFFF) {
lut->table[i] = NearestPaletteColor(r, g, b, palette); for (b = 0; b < 0xFF; b++)
{
lut->table[i] = GetColorLUT(lut, r, g, b);
}
}
} }
} }
} }
+11 -3
View File
@@ -40,9 +40,12 @@ extern "C" {
// //
extern consvar_t cv_ticrate, cv_accuratefps, cv_allcaps, cv_constextsize, cv_menucaps, extern consvar_t cv_ticrate, cv_accuratefps, cv_allcaps, cv_constextsize, cv_menucaps,
cv_globalgamma, cv_globalsaturation, #ifdef BACKWARDSCOMPATCORRECTION
cv_globalgamma,
#endif
cv_globalbrightness, cv_globalsaturation,
cv_rhue, cv_yhue, cv_ghue, cv_chue, cv_bhue, cv_mhue, cv_rhue, cv_yhue, cv_ghue, cv_chue, cv_bhue, cv_mhue,
cv_rgamma, cv_ygamma, cv_ggamma, cv_cgamma, cv_bgamma, cv_mgamma, cv_rbrightness, cv_ybrightness, cv_gbrightness, cv_cbrightness, cv_bbrightness, cv_mbrightness,
cv_rsaturation, cv_ysaturation, cv_gsaturation, cv_csaturation, cv_bsaturation, cv_msaturation, cv_rsaturation, cv_ysaturation, cv_gsaturation, cv_csaturation, cv_bsaturation, cv_msaturation,
cv_palette, cv_palettenum; cv_palette, cv_palettenum;
@@ -78,10 +81,15 @@ const char *R_GetPalname(UINT16 num);
const char *GetPalette(void); const char *GetPalette(void);
extern RGBA_t *pLocalPalette; extern RGBA_t *pLocalPalette;
extern RGBA_t *pGammaCorrectedPalette;
extern UINT8 hudtrans; extern UINT8 hudtrans;
void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue); UINT32 V_GammaCorrect(UINT32 input, double power);
#define V_GammaDecode(input) V_GammaCorrect(input, 2.2f)
#define V_GammaEncode(input) V_GammaCorrect(input, (1/2.2f))
void V_CubeApply(RGBA_t *input);
// Retrieve the ARGB value from a palette color index // Retrieve the ARGB value from a palette color index
#define V_GetColor(color) (pLocalPalette[color&0xFF]) #define V_GetColor(color) (pLocalPalette[color&0xFF])
+7 -7
View File
@@ -375,11 +375,11 @@ static restype_t ResourceFileDetect(const char* filename)
{ {
size_t len = strlen(filename) - 4; size_t len = strlen(filename) - 4;
if (!stricmp(&filename[len], ".pk3")) if (fasticmp(&filename[len], ".pk3"))
return RET_PK3; return RET_PK3;
if (!stricmp(&filename[len], ".soc")) if (fasticmp(&filename[len], ".soc"))
return RET_SOC; return RET_SOC;
if (!stricmp(&filename[len], ".lua")) if (fasticmp(&filename[len], ".lua"))
return RET_LUA; return RET_LUA;
return RET_WAD; return RET_WAD;
@@ -906,7 +906,7 @@ UINT16 W_InitFile(const char *filename, boolean local, boolean startup)
wadfile->endfolders = M_AATreeAlloc(AATREE_STRING); wadfile->endfolders = M_AATreeAlloc(AATREE_STRING);
// already generated, just copy it over // already generated, just copy it over
M_Memcpy(&wadfile->md5sum, &md5sum, 16); memcpy(&wadfile->md5sum, &md5sum, 16);
// //
// set up caching // set up caching
@@ -1130,7 +1130,7 @@ UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump)
{ {
if (lump_p->longnamelength == namelen if (lump_p->longnamelength == namelen
&& lump_p->hash.longname == hash && lump_p->hash.longname == hash
&& !stricmp(lump_p->longname, name)) && fasticmp(lump_p->longname, name))
return i; return i;
} }
} }
@@ -1230,7 +1230,7 @@ static lumpnum_t CheckLumpInCache(const char *name, boolean longname)
for (INT32 i = lumpnumcacheindex + LUMPNUMCACHESIZE; i > lumpnumcacheindex; i--) for (INT32 i = lumpnumcacheindex + LUMPNUMCACHESIZE; i > lumpnumcacheindex; i--)
{ {
if (lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].hash == hash if (lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].hash == hash
&& stricmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name) == 0) && fasticmp(lumpnumcache[i & (LUMPNUMCACHESIZE - 1)].lumpname, name))
{ {
lumpnumcacheindex = i & (LUMPNUMCACHESIZE - 1); lumpnumcacheindex = i & (LUMPNUMCACHESIZE - 1);
return lumpnumcache[lumpnumcacheindex].lumpnum; return lumpnumcache[lumpnumcacheindex].lumpnum;
@@ -1637,7 +1637,7 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si
if (!decData) // Did we get no data at all? if (!decData) // Did we get no data at all?
return 0; return 0;
M_Memcpy(dest, decData + offset, size); memcpy(dest, decData + offset, size);
Z_Free(rawData); Z_Free(rawData);
Z_Free(decData); Z_Free(decData);
#ifdef NO_PNG_LUMPS #ifdef NO_PNG_LUMPS
+1 -2
View File
@@ -35,7 +35,6 @@
#include "i_system.h" // I_GetFreeMem #include "i_system.h" // I_GetFreeMem
#include "i_video.h" // rendermode #include "i_video.h" // rendermode
#include "z_zone.h" #include "z_zone.h"
#include "m_misc.h" // M_Memcpy
#include "lua_script.h" #include "lua_script.h"
#ifdef HWRENDER #ifdef HWRENDER
@@ -383,7 +382,7 @@ void *Z_Realloc(void *ptr, size_t size, INT32 tag, void *user)
else else
copysize = block->size; copysize = block->size;
M_Memcpy(rez, ptr, copysize); memcpy(rez, ptr, copysize);
#ifdef ZDEBUG #ifdef ZDEBUG
Z_Free2(ptr, file, line); Z_Free2(ptr, file, line);