Compare commits
227
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24163a7c92 | ||
|
|
d934197246 | ||
|
|
bcd54110d5 | ||
|
|
83d538b16a | ||
|
|
2a6a7e1d2b | ||
|
|
c977c4fc45 | ||
|
|
87e0b55f01 | ||
|
|
54f5b5ebfb | ||
|
|
b421893646 | ||
|
|
237aeb7834 | ||
|
|
7dbd95d556 | ||
|
|
1e4ba39691 | ||
|
|
a7805ae3f0 | ||
|
|
325338bfbf | ||
|
|
01a54e4d0b | ||
|
|
e2df018e38 | ||
|
|
33b62cba33 | ||
|
|
29b4f78b64 | ||
|
|
bce18e3d61 | ||
|
|
e9c2b982c6 | ||
|
|
67e1793f49 | ||
|
|
80613a8a49 | ||
|
|
b017a72026 | ||
|
|
a7c5254a32 | ||
|
|
9dd1a47969 | ||
|
|
bbbd42e653 | ||
|
|
2b7f2da5ee | ||
|
|
23ba827726 | ||
|
|
326a28ec36 | ||
|
|
19d6a1600e | ||
|
|
3095303a4b | ||
|
|
2a1807422c | ||
|
|
4676885521 | ||
|
|
30cea37248 | ||
|
|
080d3c6b18 | ||
|
|
df10855483 | ||
|
|
dc6bf05f35 | ||
|
|
871545024d | ||
|
|
aeb172f2ab | ||
|
|
ec757ceb2c | ||
|
|
e00783da82 | ||
|
|
52a9486974 | ||
|
|
26b26b8f25 | ||
|
|
81f7335b05 | ||
|
|
f603106ac8 | ||
|
|
5675eefeb2 | ||
|
|
1d0fb17da4 | ||
|
|
f53d37052a | ||
|
|
cae5e73d7d | ||
|
|
4fccb48d2a | ||
|
|
3e0150d4f3 | ||
|
|
7c1f17bb8d | ||
|
|
c8ae4a89d9 | ||
|
|
42b1f849c0 | ||
|
|
c0f24ebbbc | ||
|
|
de73c53665 | ||
|
|
908e073628 | ||
|
|
eaee95a026 | ||
|
|
456a380e3a | ||
|
|
c428472c6f | ||
|
|
feff5a7c17 | ||
|
|
ae306351ba | ||
|
|
03de30df3e | ||
|
|
e45c72f525 | ||
|
|
36c43d89e6 | ||
|
|
f34a47c50d | ||
|
|
24895874ed | ||
|
|
129f88b6a7 | ||
|
|
cb5c4e482e | ||
|
|
db2062ed1d | ||
|
|
45ee50b47d | ||
|
|
694a8eeb69 | ||
|
|
908bba2c8a | ||
|
|
88363cf45d | ||
|
|
509e7140e3 | ||
|
|
056f919bbe | ||
|
|
548cad76b2 | ||
|
|
95d8864faa | ||
|
|
e26fb91350 | ||
|
|
da67f6feb8 | ||
|
|
8cc73bc482 | ||
|
|
28685ea658 | ||
|
|
a69df8807d | ||
|
|
d4a130f1dc | ||
|
|
8ccf4eb9ba | ||
|
|
cdb7b6fede | ||
|
|
fcae072625 | ||
|
|
26fc417555 | ||
|
|
bb3dd435f0 | ||
|
|
16a531272f | ||
|
|
ba5b79e48a | ||
|
|
59470ddbd4 | ||
|
|
82c4191516 | ||
|
|
8a305d3c79 | ||
|
|
7c507c7b3b | ||
|
|
ca27dad6c1 | ||
|
|
383d55cac6 | ||
|
|
0e2ffdeb1d | ||
|
|
b84d101337 | ||
|
|
852aa74d62 | ||
|
|
aa06459c09 | ||
|
|
1d3dae01e9 | ||
|
|
736a626ccf | ||
|
|
a4cc8b0585 | ||
|
|
333c94be52 | ||
|
|
c07502bf5a | ||
|
|
f751161693 | ||
|
|
ed16c4fd9f | ||
|
|
41407538d4 | ||
|
|
5f394cd938 | ||
|
|
e5bae89d0f | ||
|
|
f749800276 | ||
|
|
5289027272 | ||
|
|
77f4d4ef3b | ||
|
|
a94740f5e9 | ||
|
|
ab27090ecf | ||
|
|
93d0106c28 | ||
|
|
27433f6fb5 | ||
|
|
f8e5049d76 | ||
|
|
2009cdeaeb | ||
|
|
0f43f19b71 | ||
|
|
1ac7852bd2 | ||
|
|
f5e7b65ae0 | ||
|
|
4c5d34e82c | ||
|
|
0dad927c05 | ||
|
|
f231417465 | ||
|
|
51b8dc9101 | ||
|
|
71e9c4f5af | ||
|
|
1acae3e4af | ||
|
|
4c04d09d18 | ||
|
|
b99cd88947 | ||
|
|
4a786449c4 | ||
|
|
aef6dcdbc9 | ||
|
|
0e9ec096c2 | ||
|
|
50ce3c4431 | ||
|
|
c6c1dbd066 | ||
|
|
ece8d9e80c | ||
|
|
fdcbd276e9 | ||
|
|
6d77672ee3 | ||
|
|
28aec6cad5 | ||
|
|
1f028f523e | ||
|
|
349bf06e4b | ||
|
|
e044db73f5 | ||
|
|
7555d689db | ||
|
|
a6438da531 | ||
|
|
8c6893cff6 | ||
|
|
af03b51191 | ||
|
|
178d8b7b53 | ||
|
|
de99a3036d | ||
|
|
5c613f6c8f | ||
|
|
59628377fa | ||
|
|
278f3c3ef6 | ||
|
|
3ba1596976 | ||
|
|
02f6fa0665 | ||
|
|
f4aec1d591 | ||
|
|
5c2a87dea6 | ||
|
|
d5aa9ae0f1 | ||
|
|
6096822cbb | ||
|
|
0030367649 | ||
|
|
66f67c91e8 | ||
|
|
c73c1af2d5 | ||
|
|
638e95325a | ||
|
|
66ce745e91 | ||
|
|
2b39d137b4 | ||
|
|
1ed616dcef | ||
|
|
24ef2819b0 | ||
|
|
a9732e9564 | ||
|
|
c262d3f532 | ||
|
|
ae456fee31 | ||
|
|
68f69049d4 | ||
|
|
e180918e48 | ||
|
|
951c090b35 | ||
|
|
a87e07155a | ||
|
|
da16ce3a23 | ||
|
|
64bdae5e5d | ||
|
|
4f91a0b234 | ||
|
|
bb0a59540f | ||
|
|
dd9d6de0d6 | ||
|
|
3de4c7cbad | ||
|
|
0eeacaf51e | ||
|
|
a4684b3004 | ||
|
|
9c014eb2ea | ||
|
|
37579187cc | ||
|
|
af8ce028ba | ||
|
|
9310a68cff | ||
|
|
89b8121282 | ||
|
|
b2260bbebb | ||
|
|
6a9aea4dd1 | ||
|
|
6f4dfb35fa | ||
|
|
459b2e62ce | ||
|
|
5765f3df5a | ||
|
|
8488da4b1a | ||
|
|
c82495f48b | ||
|
|
f55b8793ec | ||
|
|
b0b048c703 | ||
|
|
38c96d5ec2 | ||
|
|
90c3d02dbf | ||
|
|
48dc5461cd | ||
|
|
0843a586f8 | ||
|
|
8c8f96cf49 | ||
|
|
55afe9be7e | ||
|
|
fe54f2fba2 | ||
|
|
b12989f51c | ||
|
|
57990100c5 | ||
|
|
32504b9e8e | ||
|
|
ba3404d823 | ||
|
|
c9f50ca0c8 | ||
|
|
b6943ce92e | ||
|
|
41b78feef5 | ||
|
|
c9b6276a02 | ||
|
|
39a5165d91 | ||
|
|
e5a03dc3bb | ||
|
|
4deebf8912 | ||
|
|
fa8901f6b0 | ||
|
|
23512f0a6c | ||
|
|
b44548b7ac | ||
|
|
955812bd8d | ||
|
|
e4ac394d29 | ||
|
|
2b6185d7d6 | ||
|
|
2753052ee7 | ||
|
|
3c9292c137 | ||
|
|
e68136de3e | ||
|
|
e852c23441 | ||
|
|
031e8ee477 | ||
|
|
21920112ee | ||
|
|
9b7bf5e7d8 | ||
|
|
524168b20b |
No files matched your search
+22
-13
@@ -49,6 +49,7 @@
|
||||
# Already enabled by default for 32-bit
|
||||
# Windows.
|
||||
# NOCURL=1 - Disable libcurl--HTTP capability.
|
||||
# NOHOLEPUNCH=1 - Disable holepunch capability.
|
||||
# NOLIBGME=1 - Disable game music emu, retro VGM support.
|
||||
# NOOPENMPT=1 - Disable module (tracker) music support.
|
||||
# NOMIXER=1 - Disable SDL Mixer (audio playback).
|
||||
@@ -69,6 +70,7 @@
|
||||
# VALGRIND=1 - Enable Valgrind memory debugging support.
|
||||
# PROFILEMODE=1 - Enable performance profiling (gprof).
|
||||
# USEASAN=1 - Enable building with Address Sanitizer.
|
||||
# USEUBSAN=1 - Enable building with Undefined Behavior Sanitizer.
|
||||
# NOLIBBACKTRACE=1 - Disable using Libbacktrace for crashlog traces.
|
||||
#
|
||||
# General flags for building:
|
||||
@@ -243,10 +245,14 @@ ifdef STATIC
|
||||
libs+=-static
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(CC) $(CXX),gcc g++))
|
||||
opts+=-mno-ms-bitfields
|
||||
endif
|
||||
|
||||
# build with profiling information
|
||||
ifdef PROFILEMODE
|
||||
opts+=-pg
|
||||
LDFLAGS+=-pg
|
||||
libs+=-pg
|
||||
endif
|
||||
|
||||
ifdef DEBUGMODE
|
||||
@@ -256,29 +262,32 @@ debug_opts=-DNDEBUG
|
||||
opts+=-O3
|
||||
ifdef USELTO
|
||||
# compile with LTO
|
||||
ifdef MINGW
|
||||
opts+=-flto=auto -g
|
||||
LDFLAGS+=-flto=auto -g
|
||||
else
|
||||
opts+=-flto=auto
|
||||
LDFLAGS+=-flto=auto
|
||||
endif
|
||||
libs+=-flto=auto
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef USEASAN
|
||||
# compile with asan
|
||||
ifdef MINGW
|
||||
opts+=-fsanitize=address -g
|
||||
libs+=-fsanitize=address -g
|
||||
else
|
||||
opts+=-fsanitize=address
|
||||
libs+=-fsanitize=address
|
||||
endif
|
||||
|
||||
ifdef USEUBSAN
|
||||
# compile with asan
|
||||
opts+=-fsanitize=undefined
|
||||
libs+=-fsanitize=undefined
|
||||
endif
|
||||
|
||||
ifeq ($(CC),clang)
|
||||
LDFLAGS+= -fuse-ld=lld
|
||||
ifneq (,$(filter $(CC) $(CXX),clang clang++))
|
||||
libs+=-fuse-ld=lld
|
||||
endif
|
||||
|
||||
ifdef MINGW
|
||||
# mingw needs this passed AFTER lto and the likes were passed
|
||||
# otherwise libbacktrace may break
|
||||
opts+=-g
|
||||
libs+=-g
|
||||
endif
|
||||
|
||||
# debug_opts also get passed to windres
|
||||
|
||||
@@ -6,7 +6,8 @@ passthru_opts+=\
|
||||
NOHW NOMD5 NOPOSTPROCESSING\
|
||||
MOBJCONSISTANCY PACKETDROP ZDEBUG\
|
||||
HAVE_MINIUPNPC\
|
||||
HAVE_DISCORDRPC DEVELOP
|
||||
HAVE_DISCORDRPC DEVELOP\
|
||||
NOHOLEPUNCH\
|
||||
|
||||
# build with debugging information
|
||||
ifdef DEBUGMODE
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
makedir:=$(makedir)/SDL
|
||||
|
||||
opts+=-DDIRECTFULLSCREEN -DHAVE_SDL
|
||||
opts+=-DHAVE_SDL
|
||||
sources+=$(call List,sdl/Sourcefile)
|
||||
|
||||
NOUPNP=1
|
||||
|
||||
@@ -144,8 +144,10 @@ ifdef GCC81
|
||||
WFLAGS+=-Wno-error=multistatement-macros
|
||||
endif
|
||||
|
||||
ifeq ($(CC),clang)
|
||||
WFLAGS+= -Wno-unknown-pragmas -Wno-cast-align
|
||||
ifneq (,$(filter $(CC) $(CXX),clang clang++))
|
||||
WFLAGS+= -Wno-unknown-pragmas
|
||||
WFLAGS+= -Wno-cast-align
|
||||
WFLAGS+= -Wno-cast-qual # not a fan, but clang really hates our read macros
|
||||
endif
|
||||
|
||||
ifdef NONX86
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
# Mingw, if you don't know, that's Win32/Win64
|
||||
#
|
||||
|
||||
sources+=$(call List,win32/Sourcefile)
|
||||
|
||||
ifndef MINGW64
|
||||
EXENAME?=srb2kart-saturn_32bit.exe
|
||||
else
|
||||
@@ -95,7 +97,7 @@ LIBBACKTRACE_libs:=-L$(lib)/lib/x86_64 -lbacktrace
|
||||
$(eval $(call _set,LIBBACKTRACE))
|
||||
else
|
||||
lib:=../libs/drmingw
|
||||
opts+=-I$(lib)/include
|
||||
opts+=-I$(lib)/include -DHAVE_DRMINGW
|
||||
libs+=-L$(lib)/lib/win32 -lmgwhelp -lexchndl
|
||||
endif
|
||||
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ r_data.c
|
||||
r_draw.c
|
||||
r_fps.cpp
|
||||
r_main.cpp
|
||||
r_patch.c
|
||||
r_patch.cpp
|
||||
r_patchrotation.c
|
||||
r_plane.cpp
|
||||
r_segs.cpp
|
||||
|
||||
+1
-1
@@ -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_lock(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);
|
||||
lua_unlock(L);
|
||||
}
|
||||
|
||||
+4
-2
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "lauxlib.h"
|
||||
|
||||
#include "../doomdef.h"
|
||||
|
||||
|
||||
#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? */
|
||||
return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
|
||||
lua_getinfo(L, "n", &ar);
|
||||
if (strcmp(ar.namewhat, "method") == 0) {
|
||||
if (fastcmp(ar.namewhat, "method")) {
|
||||
narg--; /* do not count `self' */
|
||||
if (narg == 0) /* error is in the self argument itself? */
|
||||
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);
|
||||
int i;
|
||||
for (i=0; lst[i]; i++)
|
||||
if (strcmp(lst[i], name) == 0)
|
||||
if (fastcmp(lst[i], name))
|
||||
return i;
|
||||
return luaL_argerror(L, narg,
|
||||
lua_pushfstring(L, "invalid option " LUA_QS, name));
|
||||
|
||||
+5
-3
@@ -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
|
||||
{
|
||||
if(strncmp(a, b, strlen(b)) == 0) return 1;
|
||||
if (strncmp(a, b, strlen(b)) == 0) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int io_open (lua_State *L) {
|
||||
static int io_open(lua_State *L)
|
||||
{
|
||||
FILE **pf;
|
||||
const char *filename = luaL_checkstring(L, 1);
|
||||
int pass = 0;
|
||||
@@ -178,12 +179,13 @@ static int io_open (lua_State *L) {
|
||||
|
||||
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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (l_unlikely(strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\")
|
||||
|| StartsWith(filename, "/") || !pass))
|
||||
{
|
||||
|
||||
+33
-31
@@ -1,7 +1,8 @@
|
||||
// SONIC ROBO BLAST 2
|
||||
// SONIC ROBO BLAST 2 KART
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1999-2025 by Sonic Team Junior.
|
||||
// Copyright (C) 2025 by Kart Krew.
|
||||
// Copyright (C) 2020 by Sonic Team Junior.
|
||||
// Copyright (C) 2000 by DooM Legacy Team.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
@@ -24,8 +25,9 @@ extern "C" {
|
||||
//
|
||||
// Little-endian machines
|
||||
//
|
||||
|
||||
#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 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)
|
||||
@@ -36,25 +38,25 @@ extern "C" {
|
||||
|
||||
// what is this?
|
||||
#if defined (__GNUC__)
|
||||
#define READUINT8(p) ({ UINT8 *p_tmp = (UINT8 *)p; UINT8 b; memcpy(&b, p, sizeof( UINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; })
|
||||
#define READSINT8(p) ({ SINT8 *p_tmp = (SINT8 *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; })
|
||||
#define READINT16(p) ({ INT16 *p_tmp = (INT16 *)p; INT16 b; memcpy(&b, p, sizeof( INT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; })
|
||||
#define READUINT16(p) ({ UINT16 *p_tmp = (UINT16 *)p; UINT16 b; memcpy(&b, p, sizeof( UINT16)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; })
|
||||
#define READINT32(p) ({ INT32 *p_tmp = (INT32 *)p; INT32 b; memcpy(&b, p, sizeof( INT32)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; })
|
||||
#define READUINT32(p) ({ UINT32 *p_tmp = (UINT32 *)p; UINT32 b; memcpy(&b, p, sizeof( UINT32)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; })
|
||||
#define READCHAR(p) ({ char *p_tmp = (char *)p; char b; memcpy(&b, p, sizeof( char)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; })
|
||||
#define READFIXED(p) ({ fixed_t *p_tmp = (fixed_t *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; })
|
||||
#define READANGLE(p) ({ angle_t *p_tmp = (angle_t *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; *(void**)(&(p)) = (void *)p_tmp; b; })
|
||||
#define READUINT8(p) ({ const UINT8 *p_tmp = (const UINT8 *)p; UINT8 b; memcpy(&b, p, sizeof( UINT8)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
|
||||
#define READSINT8(p) ({ const SINT8 *p_tmp = (const SINT8 *)p; SINT8 b; memcpy(&b, p, sizeof( SINT8)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
|
||||
#define READINT16(p) ({ const INT16 *p_tmp = (const INT16 *)p; INT16 b; memcpy(&b, p, sizeof( INT16)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
|
||||
#define READUINT16(p) ({ const UINT16 *p_tmp = (const UINT16 *)p; UINT16 b; memcpy(&b, p, sizeof( UINT16)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
|
||||
#define READINT32(p) ({ const INT32 *p_tmp = (const INT32 *)p; INT32 b; memcpy(&b, p, sizeof( INT32)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
|
||||
#define READUINT32(p) ({ const UINT32 *p_tmp = (const UINT32 *)p; UINT32 b; memcpy(&b, p, sizeof( UINT32)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
|
||||
#define READCHAR(p) ({ const char *p_tmp = (const char *)p; char b; memcpy(&b, p, sizeof( char)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
|
||||
#define READFIXED(p) ({ const fixed_t *p_tmp = (const fixed_t *)p; fixed_t b; memcpy(&b, p, sizeof(fixed_t)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
|
||||
#define READANGLE(p) ({ const angle_t *p_tmp = (const angle_t *)p; angle_t b; memcpy(&b, p, sizeof(angle_t)); p_tmp++; *(const void**)(&(p)) = (const void *)p_tmp; b; })
|
||||
#else
|
||||
#define READUINT8(p) ((UINT8*)(*(void**)(&(p)) = (void*)&((UINT8*)(p))[1]))[-1]
|
||||
#define READSINT8(p) ((SINT8*)(*(void**)(&(p)) = (void*)&((SINT8*)(p))[1]))[-1]
|
||||
#define READINT16(p) ((INT16*)(*(void**)(&(p)) = (void*)&((INT16*)(p))[1]))[-1]
|
||||
#define READUINT16(p) ((UINT16*)(*(void**)(&(p)) = (void*)&((UINT16*)(p))[1]))[-1]
|
||||
#define READINT32(p) ((INT32*)(*(void**)(&(p)) = (void*)&((INT32*)(p))[1]))[-1]
|
||||
#define READUINT32(p) ((UINT32*)(*(void**)(&(p)) = (void*)&((UINT32*)(p))[1]))[-1]
|
||||
#define READCHAR(p) ((char*)(*(void**)(&(p)) = (void*)&((char*)(p))[1]))[-1]
|
||||
#define READFIXED(p) ((fixed_t*)(*(void**)(&(p)) = (void*)&((fixed_t*)(p))[1]))[-1]
|
||||
#define READANGLE(p) ((angle_t*)(*(void**)(&(p)) = (void*)&((angle_t*)(p))[1]))[-1]
|
||||
#define READUINT8(p) ((const UINT8*) (*(const void**)(&(p)) = (const void*)&((const UINT8*) (p))[1]))[-1]
|
||||
#define READSINT8(p) ((const SINT8*) (*(const void**)(&(p)) = (const void*)&((const SINT8*) (p))[1]))[-1]
|
||||
#define READINT16(p) ((const INT16*) (*(const void**)(&(p)) = (const void*)&((const INT16*) (p))[1]))[-1]
|
||||
#define READUINT16(p) ((const UINT16*) (*(const void**)(&(p)) = (const void*)&((const UINT16*) (p))[1]))[-1]
|
||||
#define READINT32(p) ((const INT32*) (*(const void**)(&(p)) = (const void*)&((const INT32*) (p))[1]))[-1]
|
||||
#define READUINT32(p) ((const UINT32*) (*(const void**)(&(p)) = (const void*)&((const UINT32*) (p))[1]))[-1]
|
||||
#define READCHAR(p) ((const char*) (*(const void**)(&(p)) = (const void*)&((const char*) (p))[1]))[-1]
|
||||
#define READFIXED(p) ((const fixed_t*)(*(const void**)(&(p)) = (const void*)&((const fixed_t*)(p))[1]))[-1]
|
||||
#define READANGLE(p) ((const angle_t*)(*(const void**)(&(p)) = (const void*)&((const angle_t*)(p))[1]))[-1]
|
||||
#endif
|
||||
|
||||
#else //SRB2_BIG_ENDIAN
|
||||
@@ -117,15 +119,15 @@ FUNCINLINE static ATTRINLINE UINT32 readulong(void *ptr)
|
||||
return (ucp[3] << 24) | (ucp[2] << 16) | (ucp[1] << 8) | ucp[0];
|
||||
}
|
||||
|
||||
#define READUINT8(p) ((UINT8*)(p = (void*)&((UINT8*)p)[1]))[-1]
|
||||
#define READSINT8(p) ((SINT8*)(p = (void*)&((SINT8*)p)[1]))[-1]
|
||||
#define READINT16(p) readshort(&((INT16*)(p = (void*)&((INT16*)p)[1]))[-1])
|
||||
#define READUINT16(p) readushort(&((UINT16*)(p = (void*)&((UINT16*)p)[1]))[-1])
|
||||
#define READINT32(p) readlong(&((INT32*)(p = (void*)&((INT32*)p)[1]))[-1])
|
||||
#define READUINT32(p) readulong(&((UINT32*)(p = (void*)&((UINT32*)p)[1]))
|
||||
#define READCHAR(p) ((char*)(p = (void*)&((char*)p)[1]))[-1]
|
||||
#define READFIXED(p) readlong(&((fixed_t*)(p = (void*)&((fixed_t*)p)[1]))[-1])
|
||||
#define READANGLE(p) readulong(&((angle_t*)(p = (void*)&((angle_t*)p)[1]))[-1])
|
||||
#define READUINT8(p) ((const UINT8*)(p = (const void*)&((const UINT8*)p)[1]))[-1]
|
||||
#define READSINT8(p) ((const SINT8*)(p = (const void*)&((const SINT8*)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 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]))[-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 READANGLE(p) readulong(&((const angle_t*)(p = (const void*)&((const angle_t*)p)[1]))[-1])
|
||||
#endif //SRB2_BIG_ENDIAN
|
||||
|
||||
#define WRITESTRINGN(p, s, n) do { \
|
||||
|
||||
+71
-63
@@ -142,7 +142,7 @@ void COM_BufInsertText(const char *ptext)
|
||||
templen = com_text.cursize;
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ void COM_BufExecute(void)
|
||||
break;
|
||||
}
|
||||
|
||||
M_Memcpy(line, ptext, i);
|
||||
memcpy(line, ptext, i);
|
||||
line[i] = 0;
|
||||
|
||||
// flush the command text from the command buffer, _BEFORE_
|
||||
@@ -281,7 +281,7 @@ char *com_argv[MAX_ARGS];
|
||||
static const char *com_null_string = "";
|
||||
static char *com_args = NULL; // current command args or NULL
|
||||
|
||||
static void Got_NetVar(UINT8 **p, INT32 playernum);
|
||||
static void Got_NetVar(const UINT8 **p, INT32 playernum);
|
||||
|
||||
/** Initializes command buffer and adds basic commands.
|
||||
*/
|
||||
@@ -359,7 +359,7 @@ size_t COM_CheckParm(const char *check)
|
||||
size_t i;
|
||||
|
||||
for (i = 1; i < com_argc; i++)
|
||||
if (!strcasecmp(check, com_argv[i]))
|
||||
if (fasticmp(check, com_argv[i]))
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
@@ -456,7 +456,7 @@ void COM_AddCommand(const char *name, com_func_t func)
|
||||
// fail if the command already exists
|
||||
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
|
||||
// Lua commands can replace game commands, and they have priority.
|
||||
@@ -492,7 +492,7 @@ int COM_AddLuaCommand(const char *name)
|
||||
// command already exists
|
||||
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.
|
||||
cmd->function = COM_Lua_f;
|
||||
@@ -519,7 +519,7 @@ static boolean COM_Exists(const char *com_name)
|
||||
xcommand_t *cmd;
|
||||
|
||||
for (cmd = com_commands; cmd; cmd = cmd->next)
|
||||
if (!stricmp(com_name, cmd->name))
|
||||
if (fasticmp(com_name, cmd->name))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -571,7 +571,7 @@ static void COM_ExecuteString(char *ptext)
|
||||
// check functions
|
||||
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();
|
||||
return;
|
||||
@@ -581,7 +581,7 @@ static void COM_ExecuteString(char *ptext)
|
||||
// check aliases
|
||||
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)
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Alias recursion cycle detected!\n"));
|
||||
@@ -700,6 +700,7 @@ static void COM_Echo_f(void)
|
||||
|
||||
for (i = 1; i < COM_Argc(); i++)
|
||||
CONS_Printf("%s ", COM_Argv(i));
|
||||
|
||||
CONS_Printf("\n");
|
||||
}
|
||||
|
||||
@@ -708,11 +709,11 @@ static void COM_Echo_f(void)
|
||||
static void COM_CEcho_f(void)
|
||||
{
|
||||
size_t i;
|
||||
char cechotext[1024] = "";
|
||||
char cechotext[1024] = {0};
|
||||
|
||||
for (i = 1; i < COM_Argc(); i++)
|
||||
{
|
||||
strlcpy(cechotext, COM_Argv(i), sizeof(cechotext)-1);
|
||||
strlcat(cechotext, COM_Argv(i), sizeof(cechotext)-1);
|
||||
strlcat(cechotext, " ", sizeof(cechotext)-1);
|
||||
}
|
||||
|
||||
@@ -835,7 +836,7 @@ static void COM_Help_f(void)
|
||||
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)
|
||||
{
|
||||
@@ -878,7 +879,7 @@ static void COM_Help_f(void)
|
||||
{
|
||||
for (cmd = com_commands; cmd; cmd = cmd->next)
|
||||
{
|
||||
if (strcmp(cmd->name, help))
|
||||
if (!fastcmp(cmd->name, help))
|
||||
continue;
|
||||
|
||||
CONS_Printf("\x82""Command %s:\n", cmd->name);
|
||||
@@ -938,6 +939,8 @@ static void COM_Find_f(void)
|
||||
}
|
||||
|
||||
help = COM_Argv(1);
|
||||
if (!help)
|
||||
return;
|
||||
helplen = strlen(help);
|
||||
CONS_Printf("\x82""Variables:\n");
|
||||
matchesany = false;
|
||||
@@ -1126,7 +1129,7 @@ void *VS_GetSpace(vsbuf_t *buf, 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
|
||||
@@ -1143,9 +1146,9 @@ void VS_Print(vsbuf_t *buf, const char *data)
|
||||
len = strlen(data) + 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
|
||||
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
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
@@ -1173,7 +1176,7 @@ consvar_t *CV_FindVar(const char *name)
|
||||
consvar_t *cvar;
|
||||
|
||||
for (cvar = consvar_vars; cvar; cvar = cvar->next)
|
||||
if (!stricmp(name,cvar->name))
|
||||
if (fasticmp(name,cvar->name))
|
||||
return cvar;
|
||||
|
||||
return NULL;
|
||||
@@ -1363,7 +1366,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
|
||||
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 MAXVAL 1
|
||||
@@ -1376,21 +1379,21 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
|
||||
|
||||
// search for other
|
||||
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->string = var->PossibleValue[i].strvalue;
|
||||
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;
|
||||
valstr = var->PossibleValue[MINVAL].strvalue;
|
||||
override = true;
|
||||
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;
|
||||
valstr = var->PossibleValue[MAXVAL].strvalue;
|
||||
@@ -1408,7 +1411,7 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
|
||||
|
||||
// check first strings
|
||||
for (i = 0; var->PossibleValue[i].strvalue; i++)
|
||||
if (!stricmp(var->PossibleValue[i].strvalue, valstr))
|
||||
if (fasticmp(var->PossibleValue[i].strvalue, valstr))
|
||||
goto found;
|
||||
if (v != INT32_MIN)
|
||||
{
|
||||
@@ -1421,9 +1424,9 @@ static void Setvalue(consvar_t *var, const char *valstr, boolean stealth)
|
||||
if (var->PossibleValue == CV_OnOff || var->PossibleValue == CV_YesNo)
|
||||
{
|
||||
overrideval = -1;
|
||||
if (!stricmp(valstr, "on") || !stricmp(valstr, "yes"))
|
||||
if (fasticmp(valstr, "on") || fasticmp(valstr, "yes"))
|
||||
overrideval = 1;
|
||||
else if (!stricmp(valstr, "off") || !stricmp(valstr, "no"))
|
||||
else if (fasticmp(valstr, "off") || fasticmp(valstr, "no"))
|
||||
overrideval = 0;
|
||||
|
||||
if (overrideval != -1)
|
||||
@@ -1471,7 +1474,7 @@ finish:
|
||||
var->flags |= CV_MODIFIED;
|
||||
|
||||
// raise 'on change' code
|
||||
LUA_CVarChanged(var->name); // let consolelib know what cvar this is.
|
||||
LUA_CVarChanged(var); // let consolelib know what cvar this is.
|
||||
|
||||
if (var->flags & CV_CALL && !stealth)
|
||||
var->func();
|
||||
@@ -1497,11 +1500,11 @@ badinput:
|
||||
|
||||
static boolean serverloading = false;
|
||||
|
||||
static void Got_NetVar(UINT8 **p, INT32 playernum)
|
||||
static void Got_NetVar(const UINT8 **p, INT32 playernum)
|
||||
{
|
||||
consvar_t *cvar;
|
||||
UINT16 netid;
|
||||
char *svalue;
|
||||
const char *svalue;
|
||||
UINT8 stealth = false;
|
||||
|
||||
if (playernum != serverplayer && !IsPlayerAdmin(playernum) && !serverloading)
|
||||
@@ -1515,9 +1518,10 @@ static void Got_NetVar(UINT8 **p, INT32 playernum)
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
netid = READUINT16(*p);
|
||||
cvar = CV_FindNetVar(netid);
|
||||
svalue = (char *)*p;
|
||||
svalue = (const char *)*p;
|
||||
SKIPSTRING(*p);
|
||||
stealth = READUINT8(*p);
|
||||
|
||||
@@ -1573,8 +1577,9 @@ void CV_SaveNetVars(UINT8 **p, boolean isdemorecording)
|
||||
WRITEUINT16(count_p, count);
|
||||
}
|
||||
|
||||
void CV_LoadNetVars(UINT8 **p)
|
||||
size_t CV_LoadNetVars(const UINT8 *bufstart)
|
||||
{
|
||||
const UINT8 *p = bufstart;
|
||||
consvar_t *cvar;
|
||||
UINT16 count;
|
||||
|
||||
@@ -1585,11 +1590,13 @@ void CV_LoadNetVars(UINT8 **p)
|
||||
if (cvar->flags & CV_NETVAR)
|
||||
Setvalue(cvar, cvar->defaultvalue, true);
|
||||
|
||||
count = READUINT16(*p);
|
||||
count = READUINT16(p);
|
||||
while (count--)
|
||||
Got_NetVar(p, 0);
|
||||
Got_NetVar(&p, 0);
|
||||
|
||||
serverloading = false;
|
||||
|
||||
return p - bufstart;
|
||||
}
|
||||
|
||||
static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth);
|
||||
@@ -1607,7 +1614,7 @@ void CV_ResetCheatNetVars(void)
|
||||
// Returns true if the variable's current value is its default value
|
||||
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.
|
||||
@@ -1619,7 +1626,7 @@ UINT8 CV_CheatsEnabled(void)
|
||||
consvar_t *cvar;
|
||||
|
||||
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 0;
|
||||
}
|
||||
@@ -1640,7 +1647,7 @@ static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth)
|
||||
if (!var->string)
|
||||
I_Error("CV_Set: %s no string set!\n", var->name);
|
||||
#endif
|
||||
if (!var || !var->string || !value || !stricmp(var->string, value))
|
||||
if (!var || !var->string || !value || fasticmp(var->string, value))
|
||||
return; // no changes
|
||||
|
||||
if (var->flags & CV_NETVAR)
|
||||
@@ -1662,7 +1669,7 @@ static void CV_SetCVar(consvar_t *var, const char *value, boolean stealth)
|
||||
|
||||
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");
|
||||
return;
|
||||
@@ -1796,7 +1803,7 @@ void CV_AddValue(consvar_t *var, INT32 increment)
|
||||
}
|
||||
#define MINVAL 0
|
||||
#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
|
||||
#ifdef PARANOIA
|
||||
if (!var->PossibleValue[MAXVAL].strvalue)
|
||||
@@ -1913,13 +1920,14 @@ void CV_AddValue(consvar_t *var, INT32 increment)
|
||||
max = (M_SecretUnlocked(SECRET_HARDSPEED) ? 3 : 2);
|
||||
}
|
||||
#ifdef PARANOIA
|
||||
if (currentindice == -1)
|
||||
I_Error("CV_AddValue: current value %d not found in possible value\n",
|
||||
var->value);
|
||||
if (currentindice == -1 || max == 0)
|
||||
I_Error("CV_AddValue: current value %d not found in possible value\n", var->value);
|
||||
#endif
|
||||
|
||||
newindice = (currentindice + increment + max) % max;
|
||||
CV_Set(var, var->PossibleValue[newindice].strvalue);
|
||||
if (max > 0)
|
||||
{
|
||||
newindice = (currentindice + increment + max) % max;
|
||||
CV_Set(var, var->PossibleValue[newindice].strvalue);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1967,12 +1975,12 @@ static boolean CV_FilterJoyAxisVars(consvar_t *v, const char *valstr)
|
||||
{
|
||||
if (joyaxis_default[i])
|
||||
{
|
||||
if (!stricmp(v->name, "joyaxis_fire"))
|
||||
if (fasticmp(v->name, "joyaxis_fire"))
|
||||
{
|
||||
if (joyaxis_count[i] > 7) return false;
|
||||
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;
|
||||
}
|
||||
// reset all axis settings to defaults
|
||||
@@ -2004,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
|
||||
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;
|
||||
if (!stricmp(v->name, "joyaxis2_turn") && !stricmp(valstr, "X-Axis"))
|
||||
if (fasticmp(v->name, "joyaxis2_turn") && fasticmp(valstr, "X-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis3_turn") && !stricmp(valstr, "X-Axis"))
|
||||
if (fasticmp(v->name, "joyaxis3_turn") && fasticmp(valstr, "X-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis4_turn") && !stricmp(valstr, "X-Axis"))
|
||||
if (fasticmp(v->name, "joyaxis4_turn") && fasticmp(valstr, "X-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis_aim") && !stricmp(valstr, "Y-Axis"))
|
||||
if (fasticmp(v->name, "joyaxis_aim") && fasticmp(valstr, "Y-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis2_aim") && !stricmp(valstr, "Y-Axis"))
|
||||
if (fasticmp(v->name, "joyaxis2_aim") && fasticmp(valstr, "Y-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis3_aim") && !stricmp(valstr, "Y-Axis"))
|
||||
if (fasticmp(v->name, "joyaxis3_aim") && fasticmp(valstr, "Y-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis4_aim") && !stricmp(valstr, "Y-Axis"))
|
||||
if (fasticmp(v->name, "joyaxis4_aim") && fasticmp(valstr, "Y-Axis"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis_fire") && !stricmp(valstr, "None"))
|
||||
if (fasticmp(v->name, "joyaxis_fire") && fasticmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis2_fire") && !stricmp(valstr, "None"))
|
||||
if (fasticmp(v->name, "joyaxis2_fire") && fasticmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis3_fire") && !stricmp(valstr, "None"))
|
||||
if (fasticmp(v->name, "joyaxis3_fire") && fasticmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis4_fire") && !stricmp(valstr, "None"))
|
||||
if (fasticmp(v->name, "joyaxis4_fire") && fasticmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis_drift") && !stricmp(valstr, "None"))
|
||||
if (fasticmp(v->name, "joyaxis_drift") && fasticmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis2_drift") && !stricmp(valstr, "None"))
|
||||
if (fasticmp(v->name, "joyaxis2_drift") && fasticmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis3_drift") && !stricmp(valstr, "None"))
|
||||
if (fasticmp(v->name, "joyaxis3_drift") && fasticmp(valstr, "None"))
|
||||
return false;
|
||||
if (!stricmp(v->name, "joyaxis4_drift") && !stricmp(valstr, "None"))
|
||||
if (fasticmp(v->name, "joyaxis4_drift") && fasticmp(valstr, "None"))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -2051,8 +2059,8 @@ static boolean CV_FilterVarByVersion(consvar_t *v, const char *valstr)
|
||||
|
||||
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.
|
||||
|| !stricmp(v->name, "gamma")) // Too easy to accidentially change in prior versions.
|
||||
if (fasticmp(v->name, "masterserver") // Replaces a hack in MasterServer_OnChange for the original SRB2 MS.
|
||||
|| fasticmp(v->name, "gamma")) // Too easy to accidentially change in prior versions.
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2135,7 +2143,7 @@ void CV_SaveVariables(FILE *f)
|
||||
char stringtowrite[MAXTEXTCMD+1];
|
||||
|
||||
// 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)
|
||||
sprintf(stringtowrite, "%f", FixedToFloat(cvar->value));
|
||||
|
||||
+1
-1
@@ -182,7 +182,7 @@ void CV_SaveVariables(FILE *f);
|
||||
|
||||
// load/save gamesate (load and save option and for network join in game)
|
||||
void CV_SaveNetVars(UINT8 **p, boolean isdemorecording);
|
||||
void CV_LoadNetVars(UINT8 **p);
|
||||
size_t CV_LoadNetVars(const UINT8 *p);
|
||||
|
||||
// reset cheat netvars after cheats is deactivated
|
||||
void CV_ResetCheatNetVars(void);
|
||||
|
||||
+3
-34
@@ -69,14 +69,9 @@ static boolean consoleready; // console prompt is ready
|
||||
INT32 con_destlines; // vid lines used by console at final position
|
||||
static INT32 con_curlines; // vid lines currently used by console
|
||||
|
||||
INT32 con_clipviewtop; // (useless)
|
||||
|
||||
static UINT8 con_hudlines; // number of console heads up message lines
|
||||
static UINT32 con_hudtime[MAXHUDLINES]; // remaining time of display for hud msg lines
|
||||
|
||||
INT32 con_clearlines; // top screen lines to refresh when view reduced
|
||||
boolean con_hudupdate; // when messages scroll, we need a backgrnd refresh
|
||||
|
||||
// console text output
|
||||
static char *con_line; // console text output current line
|
||||
static size_t con_cx; // cursor position in current line
|
||||
@@ -393,9 +388,6 @@ void CON_Init(void)
|
||||
|
||||
Lock_state();
|
||||
|
||||
//note: CON_Ticker should always execute at least once before D_Display()
|
||||
con_clipviewtop = -1; // -1 does not clip
|
||||
|
||||
con_hudlines = atoi(cons_hudlines.defaultvalue);
|
||||
|
||||
Unlock_state();
|
||||
@@ -529,7 +521,7 @@ static void CON_RecalcSize(void)
|
||||
oldcon_width = con_width;
|
||||
oldnumlines = con_totallines;
|
||||
oldcon_cy = con_cy;
|
||||
M_Memcpy(tmp_buffer, con_buffer, CON_BUFFERSIZE);
|
||||
memcpy(tmp_buffer, con_buffer, CON_BUFFERSIZE);
|
||||
|
||||
if (conw < 1)
|
||||
con_width = (BASEVIDWIDTH>>3) - 2;
|
||||
@@ -555,7 +547,7 @@ static void CON_RecalcSize(void)
|
||||
{
|
||||
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;
|
||||
while (string[conw] == ' ' && conw)
|
||||
conw--;
|
||||
@@ -727,7 +719,6 @@ void CON_ToggleOff(void)
|
||||
con_curlines = 0;
|
||||
CON_ClearHUD();
|
||||
con_forcepic = 0;
|
||||
con_clipviewtop = -1; // remove console clipping of view
|
||||
|
||||
I_SetTextInput(false);
|
||||
|
||||
@@ -779,18 +770,6 @@ void CON_Ticker(void)
|
||||
}
|
||||
}
|
||||
|
||||
// clip the view, so that the part under the console is not drawn
|
||||
con_clipviewtop = -1;
|
||||
if (cons_backpic.value) // clip only when using an opaque background
|
||||
{
|
||||
if (con_curlines > 0)
|
||||
con_clipviewtop = con_curlines - viewwindowy - 1 - 10;
|
||||
// NOTE: BIG HACK::SUBTRACT 10, SO THAT WATER DON'T COPY LINES OF THE CONSOLE
|
||||
// WINDOW!!! (draw some more lines behind the bottom of the console)
|
||||
if (con_clipviewtop < 0)
|
||||
con_clipviewtop = -1; // maybe not necessary, provided it's < 0
|
||||
}
|
||||
|
||||
// check if console ready for prompt
|
||||
if (con_destlines >= minheight)
|
||||
{
|
||||
@@ -1031,7 +1010,7 @@ boolean CON_Responder(event_t *ev)
|
||||
Lock_state();
|
||||
|
||||
// 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;
|
||||
M_TextInputInit(&input, inputlines[inputline], CON_MAXPROMPTCHARS);
|
||||
@@ -1100,9 +1079,6 @@ static void CON_Linefeed(void)
|
||||
|
||||
con_line = &con_buffer[(con_cy%con_totallines)*con_width];
|
||||
memset(con_line, ' ', con_width);
|
||||
|
||||
// make sure the view borders are refreshed if hud messages scroll
|
||||
con_hudupdate = true; // see HU_Erase()
|
||||
}
|
||||
|
||||
// Outputs text into the console text buffer
|
||||
@@ -1489,9 +1465,6 @@ static void CON_DrawHudlines(void)
|
||||
//V_DrawCharacter(x, y, (p[c]&0xff) | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value);
|
||||
y += charheight;
|
||||
}
|
||||
|
||||
// top screen lines that might need clearing when view is reduced
|
||||
con_clearlines = y; // this is handled by HU_Erase();
|
||||
}
|
||||
|
||||
// draw the console background, text, and prompt if enough place
|
||||
@@ -1509,10 +1482,6 @@ static void CON_DrawConsole(void)
|
||||
if (con_curlines <= 0)
|
||||
return;
|
||||
|
||||
//FIXME: refresh borders only when console bg is translucent
|
||||
con_clearlines = con_curlines; // clear console draw from view borders
|
||||
con_hudupdate = true; // always refresh while console is on
|
||||
|
||||
// draw console background
|
||||
if (cons_backpic.value || con_forcepic)
|
||||
{
|
||||
|
||||
@@ -30,14 +30,9 @@ extern boolean con_recalc;
|
||||
|
||||
extern boolean con_startup;
|
||||
|
||||
// top clip value for view render: do not draw part of view hidden by console
|
||||
extern INT32 con_clipviewtop;
|
||||
|
||||
// 0 means console if off, or moving out
|
||||
extern INT32 con_destlines;
|
||||
|
||||
extern INT32 con_clearlines; // lines of top of screen to refresh
|
||||
extern boolean con_hudupdate; // hud messages have changed, need refresh
|
||||
extern UINT32 con_scalefactor; // console text scale factor
|
||||
|
||||
extern consvar_t cons_backcolor, cons_menuhighlight;
|
||||
|
||||
@@ -147,6 +147,51 @@ public:
|
||||
template <class 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
|
||||
|
||||
#endif // __SRB2_CXXUTIL_HPP__
|
||||
+61
-53
@@ -78,14 +78,14 @@
|
||||
#define MAX_REASONLENGTH 30
|
||||
#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
|
||||
#define client (!server)
|
||||
boolean nodownload = false;
|
||||
boolean serverrunning = false;
|
||||
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
|
||||
|
||||
@@ -98,14 +98,13 @@ static int map_icon_request_count; // current count of icon requests sent
|
||||
static UINT8 *map_icon_data;
|
||||
static patch_t *map_icon;
|
||||
|
||||
plrinfo playerinfo[MAXPLAYERS];
|
||||
plrinfo playerinfo[MAXPLAYERS] = {};
|
||||
SINT8 joinnode = 0; // used for CL_VIEWSERVER
|
||||
|
||||
boolean player_muted[MAXPLAYERS] = {0};
|
||||
boolean player_muted[MAXPLAYERS] = {};
|
||||
|
||||
// Server specific vars
|
||||
UINT8 playernode[MAXPLAYERS];
|
||||
|
||||
UINT8 playernode[MAXPLAYERS] = {};
|
||||
|
||||
// Minimum timeout for sending the savegame
|
||||
// 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?
|
||||
|
||||
UINT16 pingmeasurecount = 1;
|
||||
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 realpingtable[MAXPLAYERS] = {}; //the base table of ping where an average will be sent to everyone.
|
||||
UINT32 playerpingtable[MAXPLAYERS] = {}; //table of player latency values.
|
||||
|
||||
#define GENTLEMANSMOOTHING (TICRATE)
|
||||
static tic_t reference_lag;
|
||||
static UINT8 spike_time;
|
||||
tic_t lowest_lag;
|
||||
tic_t simulated_lag;
|
||||
boolean server_lagless;
|
||||
tic_t lowest_lag = 0;
|
||||
tic_t simulated_lag = 0;
|
||||
boolean server_lagless = true;
|
||||
|
||||
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_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 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 nodetoplayer4[MAXNETNODES]; // say the numplayer for this node if any (splitscreen == 3)
|
||||
UINT8 playerpernode[MAXNETNODES]; // used specialy for splitscreen
|
||||
boolean nodeingame[MAXNETNODES]; // set false as nodes leave game
|
||||
SINT8 nodetoplayer[MAXNETNODES] = {};
|
||||
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 nodetoplayer4[MAXNETNODES] = {}; // say the numplayer for this node if any (splitscreen == 3)
|
||||
UINT8 playerpernode[MAXNETNODES] = {}; // used specialy for splitscreen
|
||||
boolean nodeingame[MAXNETNODES] = {}; // set false as nodes leave game
|
||||
|
||||
tic_t servermaxping = 20; // server's max delay, in frames. Defaults to 20
|
||||
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 tic_t neededtic;
|
||||
SINT8 servernode = 0; // the number of the server node
|
||||
char connectedservername[MAXSERVERNAME+1];
|
||||
char connectedservername[MAXSERVERNAME+1] = {};
|
||||
/// \brief do we accept new players?
|
||||
/// \todo WORK!
|
||||
boolean acceptnewnode = true;
|
||||
@@ -227,7 +226,7 @@ struct textcmdbuf_s
|
||||
static textcmdbuf_t *textcmdbuf[MAXSPLITSCREENPLAYERS] = {NULL};
|
||||
|
||||
static ticcmd_t playercmds[MAXPLAYERS];
|
||||
ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS];
|
||||
ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS] = {};
|
||||
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};
|
||||
@@ -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
|
||||
// (original sersetup, not exactely, but the probability of sending a packet
|
||||
// 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
|
||||
*
|
||||
@@ -312,9 +311,9 @@ static inline tic_t ExpandTics(INT32 low, tic_t basetic)
|
||||
// Some extra data function for handle textcmd buffer
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
static void (*listnetxcmd[MAXNETXCMD])(UINT8 **p, INT32 playernum);
|
||||
static void (*listnetxcmd[MAXNETXCMD])(const UINT8 **p, INT32 playernum);
|
||||
|
||||
void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum))
|
||||
void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(const UINT8 **p, INT32 playernum))
|
||||
{
|
||||
#ifdef PARANOIA
|
||||
if (id >= MAXNETXCMD)
|
||||
@@ -331,7 +330,7 @@ static void WriteNetXCmd(UINT8 *cmd, netxcmd_t id, const void *param, size_t npa
|
||||
cmd[cmd[0]] = (UINT8)id;
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -460,12 +459,12 @@ static void ExtraDataTicker(void)
|
||||
{
|
||||
if (playeringame[i] || i == 0)
|
||||
{
|
||||
UINT8 *bufferstart = D_GetExistingTextcmd(gametic, i);
|
||||
const UINT8 *bufferstart = D_GetExistingTextcmd(gametic, i);
|
||||
|
||||
if (bufferstart)
|
||||
{
|
||||
UINT8 *curpos = bufferstart;
|
||||
UINT8 *bufferend = &curpos[curpos[0]+1];
|
||||
const UINT8 *curpos = bufferstart;
|
||||
const UINT8 *bufferend = &curpos[curpos[0]+1];
|
||||
|
||||
curpos++;
|
||||
while (curpos < bufferend)
|
||||
@@ -823,7 +822,7 @@ static void resynch_read_player(resynch_pak *rsp)
|
||||
P_SetThingPosition(players[i].mo);
|
||||
}
|
||||
|
||||
static inline void resynch_write_ctf(resynchend_pak *rst)
|
||||
static void resynch_write_ctf(resynchend_pak *rst)
|
||||
{
|
||||
mobj_t *mflag;
|
||||
UINT8 i, j;
|
||||
@@ -863,7 +862,7 @@ static inline void resynch_write_ctf(resynchend_pak *rst)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void resynch_read_ctf(resynchend_pak *p)
|
||||
static void resynch_read_ctf(resynchend_pak *p)
|
||||
{
|
||||
UINT8 i;
|
||||
|
||||
@@ -1585,7 +1584,7 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime)
|
||||
MAXSERVERNAME);
|
||||
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;
|
||||
|
||||
@@ -1656,12 +1655,7 @@ static void SV_SendPlayerInfo(INT32 node)
|
||||
|
||||
netbuffer->u.playerinfo[i].node = i;
|
||||
|
||||
// Can't really change this because net compatibility, but the warning is annoying
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstringop-truncation"
|
||||
strncpy(netbuffer->u.playerinfo[i].name, (const char *)&player_names[i], MAXPLAYERNAME+1);
|
||||
#pragma GCC diagnostic pop
|
||||
netbuffer->u.playerinfo[i].name[MAXPLAYERNAME] = '\0';
|
||||
strlcpy(netbuffer->u.playerinfo[i].name, (const char *)&player_names[i], MAXPLAYERNAME+1);
|
||||
|
||||
//fetch IP address
|
||||
//No, don't do that, you fuckface.
|
||||
@@ -2179,7 +2173,7 @@ static void SL_InsertServer(serverinfo_pak* info, SINT8 node)
|
||||
if (info->subversion != SUBVERSION)
|
||||
return; // Close, but no cigar.
|
||||
|
||||
if (strcmp(info->application, SRB2APPLICATION))
|
||||
if (!fastcmp(info->application, SRB2APPLICATION))
|
||||
return;/* that's a different mod */
|
||||
|
||||
i = serverlistcount++;
|
||||
@@ -2224,7 +2218,7 @@ void CL_QueryServerList (msg_server_t *server_list)
|
||||
// thwart nefarious servers who lie to the MS.
|
||||
|
||||
/* 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);
|
||||
if (node == -1)
|
||||
@@ -3220,7 +3214,7 @@ static void Command_connect(void)
|
||||
|
||||
server = false;
|
||||
|
||||
if (!stricmp(COM_Argv(1), "self"))
|
||||
if (fasticmp(COM_Argv(1), "self"))
|
||||
{
|
||||
servernode = 0;
|
||||
server = true;
|
||||
@@ -3230,7 +3224,7 @@ static void Command_connect(void)
|
||||
else
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
@@ -3245,7 +3239,7 @@ static void Command_connect(void)
|
||||
netgame = true;
|
||||
multiplayer = true;
|
||||
|
||||
if (!stricmp(COM_Argv(1), "any"))
|
||||
if (fasticmp(COM_Argv(1), "any"))
|
||||
servernode = BROADCASTADDR;
|
||||
else if (I_NetMakeNodewPort && COM_Argc() >= 3)
|
||||
servernode = I_NetMakeNodewPort(COM_Argv(1), COM_Argv(2));
|
||||
@@ -3269,6 +3263,7 @@ static void Command_connect(void)
|
||||
splitscreen = cv_splitplayers.value-1;
|
||||
SplitScreen_OnChange();
|
||||
}
|
||||
|
||||
botingame = false;
|
||||
botskin = 0;
|
||||
CL_ConnectToServer();
|
||||
@@ -3761,7 +3756,7 @@ static void Command_Kick(void)
|
||||
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
|
||||
}
|
||||
|
||||
static void Got_KickCmd(UINT8 **p, INT32 playernum)
|
||||
static void Got_KickCmd(const UINT8 **p, INT32 playernum)
|
||||
{
|
||||
INT32 pnum, msg;
|
||||
char buf[3 + MAX_REASONLENGTH];
|
||||
@@ -4151,8 +4146,8 @@ consvar_t cv_connectawaittime = {"connectawaittime", "5", CV_SAVE, connectawaitt
|
||||
|
||||
consvar_t cv_serverinfoscreen = {"serverinfoscreen", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static void Got_AddPlayer(UINT8 **p, INT32 playernum);
|
||||
static void Got_RemovePlayer(UINT8 **p, INT32 playernum);
|
||||
static void Got_AddPlayer(const UINT8 **p, INT32 playernum);
|
||||
static void Got_RemovePlayer(const UINT8 **p, INT32 playernum);
|
||||
|
||||
static void Joinable_OnChange(void)
|
||||
{
|
||||
@@ -4404,7 +4399,7 @@ static inline void SV_AddNode(INT32 node)
|
||||
}
|
||||
|
||||
// Xcmd XD_ADDPLAYER
|
||||
static void Got_AddPlayer(UINT8 **p, INT32 playernum)
|
||||
static void Got_AddPlayer(const UINT8 **p, INT32 playernum)
|
||||
{
|
||||
INT16 node, newplayernum;
|
||||
UINT8 splitscreenplayer = 0;
|
||||
@@ -4491,7 +4486,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum)
|
||||
}
|
||||
|
||||
// Xcmd XD_REMOVEPLAYER
|
||||
static void Got_RemovePlayer(UINT8 **p, INT32 playernum)
|
||||
static void Got_RemovePlayer(const UINT8 **p, INT32 playernum)
|
||||
{
|
||||
SINT8 pnum, reason;
|
||||
|
||||
@@ -4652,13 +4647,26 @@ void SV_StopServer(void)
|
||||
|
||||
if (gamestate == GS_INTERMISSION)
|
||||
Y_EndIntermission();
|
||||
if (gamestate == GS_VOTING)
|
||||
else if (gamestate == GS_VOTING)
|
||||
Y_EndVote();
|
||||
gamestate = wipegamestate = GS_NULL;
|
||||
|
||||
G_SetGamestate(GS_NULL);
|
||||
wipegamestate = GS_NULL;
|
||||
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
localtextcmd[i][0] = 0;
|
||||
|
||||
while (textcmdbuf[i] != NULL)
|
||||
{
|
||||
textcmdbuf_t *buf = textcmdbuf[i];
|
||||
textcmdbuf[i] = textcmdbuf[i]->next;
|
||||
Z_Free(buf);
|
||||
}
|
||||
|
||||
textcmdbuf[i] = NULL;
|
||||
}
|
||||
|
||||
for (i = firstticstosend; i < firstticstosend + BACKUPTICS; i++)
|
||||
D_Clearticcmd(i);
|
||||
|
||||
@@ -5220,7 +5228,7 @@ static void PT_ServerCFG(SINT8 node)
|
||||
|
||||
scp = netbuffer->u.servercfg.varlengthinputs;
|
||||
CV_LoadPlayerNames(&scp);
|
||||
CV_LoadNetVars(&scp);
|
||||
scp += CV_LoadNetVars(scp);
|
||||
|
||||
/// \note Wait. What if a Lua script uses some global custom variables synched with the NetVars hook?
|
||||
/// Shouldn't them be downloaded even at intermission time?
|
||||
@@ -5680,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",
|
||||
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];
|
||||
}
|
||||
}
|
||||
@@ -5787,7 +5795,7 @@ static void PT_ServerTics(SINT8 node)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -6325,7 +6333,7 @@ static void CL_SendClientCmd(void)
|
||||
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
|
||||
if (HSendPacket(servernode, true, 0, localtextcmd[i][0]+1)) // Send can fail...
|
||||
@@ -6335,7 +6343,7 @@ static void CL_SendClientCmd(void)
|
||||
if (textcmdbuf[i] != NULL)
|
||||
{
|
||||
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;
|
||||
Z_Free(buf);
|
||||
}
|
||||
@@ -6448,7 +6456,7 @@ static void SV_SendTics(void)
|
||||
{
|
||||
(*ntextcmd)++;
|
||||
WRITEUINT8(bufpos, j);
|
||||
M_Memcpy(bufpos, textcmd, size + 1);
|
||||
memcpy(bufpos, textcmd, size + 1);
|
||||
bufpos += size + 1;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -604,7 +604,7 @@ extern consvar_t cv_serverinfoscreen;
|
||||
void D_ClientServerInit(void);
|
||||
|
||||
// Initialise the other field
|
||||
void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum));
|
||||
void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(const UINT8 **p, INT32 playernum));
|
||||
void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam);
|
||||
#define SendNetXCmd(id, param, nparam) SendNetXCmdForPlayer(0, id, param, nparam) // Shortcut for P1
|
||||
void SendKick(UINT8 playernum, UINT8 msg);
|
||||
|
||||
+200
-245
@@ -97,15 +97,15 @@
|
||||
UINT8 window_notinfocus = false;
|
||||
|
||||
static char *startupiwadfiles[MAX_WADFILES];
|
||||
static size_t startupiwadcount = 0;
|
||||
static char *startuppwads[MAX_WADFILES];
|
||||
static size_t startuppwadcount = 0;
|
||||
|
||||
// autoloading
|
||||
static char *autoloadwadfiles[MAX_WADFILES];
|
||||
static char *autoloadwadfilespost[MAX_WADFILES];
|
||||
boolean autoloading;
|
||||
boolean autoloaded;
|
||||
boolean postautoloaded = false;
|
||||
boolean wasautoloaded = false;
|
||||
static size_t autoloadcount = 0;
|
||||
static size_t postloadcount = 0;
|
||||
//
|
||||
|
||||
boolean devparm = false; // started game with -devparm
|
||||
@@ -113,7 +113,9 @@ boolean devparm = false; // started game with -devparm
|
||||
boolean singletics = false; // timedemo
|
||||
boolean lastdraw = false;
|
||||
|
||||
#ifdef MOTIONBLUR
|
||||
INT32 postimgparam[MAXSPLITSCREENPLAYERS];
|
||||
#endif
|
||||
|
||||
// These variables are only true if
|
||||
// whether the respective sound system is disabled
|
||||
@@ -140,8 +142,8 @@ static char addonsdir[MAX_WADPATH];
|
||||
// Events can be discarded if no responder claims them
|
||||
// referenced from i_system.c for I_GetKey()
|
||||
|
||||
event_t events[MAXEVENTS];
|
||||
INT32 eventhead, eventtail;
|
||||
event_t events[MAXEVENTS] = {};
|
||||
INT32 eventhead = 0, eventtail = 0;
|
||||
|
||||
boolean dedicated = false;
|
||||
|
||||
@@ -159,68 +161,17 @@ void D_PostEvent(const event_t *ev)
|
||||
|
||||
// modifier keys
|
||||
// Now handled in I_OsPolling
|
||||
UINT8 shiftdown = 0; // 0x1 left, 0x2 right
|
||||
UINT8 ctrldown = 0; // 0x1 left, 0x2 right
|
||||
UINT8 altdown = 0; // 0x1 left, 0x2 right
|
||||
boolean capslock = 0; // gee i wonder what this does.
|
||||
UINT8 shiftdown = 0; // 0x1 left, 0x2 right
|
||||
UINT8 ctrldown = 0; // 0x1 left, 0x2 right
|
||||
UINT8 altdown = 0; // 0x1 left, 0x2 right
|
||||
boolean capslock = 0; // gee i wonder what this does.
|
||||
|
||||
static void D_PadMenuScrollInput(UINT8 input)
|
||||
{
|
||||
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 UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {};
|
||||
|
||||
static void D_DeviceLEDTick(void)
|
||||
{
|
||||
UINT8 i;
|
||||
static UINT16 color[MAXSPLITSCREENPLAYERS] = {0};
|
||||
static UINT16 color[MAXSPLITSCREENPLAYERS] = {};
|
||||
|
||||
if (numcontrollers == 0)
|
||||
{
|
||||
@@ -347,11 +298,68 @@ static void D_Renderview(void)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD)
|
||||
{
|
||||
viewssnum = i;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 1:
|
||||
if (splitscreen > 1)
|
||||
{
|
||||
viewwindowx = viewwidth;
|
||||
viewwindowy = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
viewwindowx = 0;
|
||||
viewwindowy = viewheight;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
viewwindowx = 0;
|
||||
viewwindowy = viewheight;
|
||||
break;
|
||||
case 3:
|
||||
viewwindowx = viewwidth;
|
||||
viewwindowy = viewheight;
|
||||
break;
|
||||
default: // Initialize for P1
|
||||
viewwindowy = viewwindowx = 0;
|
||||
objectsdrawn = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
HWR_RenderPlayerView();
|
||||
}
|
||||
else if (rendermode == render_soft)
|
||||
#endif
|
||||
R_RenderPlayerView(&players[displayplayers[i]]);
|
||||
}
|
||||
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
if (i == 0)
|
||||
R_ApplyViewMorph();
|
||||
|
||||
#ifdef MOTIONBLUR
|
||||
V_DoPostProcessor(i, postimgparam[i]);
|
||||
#else
|
||||
V_DoPostProcessor(i, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Draw over the fourth screen so you don't have to stare at a HOM :V
|
||||
if (splitscreen == 2)
|
||||
{
|
||||
// V_DrawPatchFill, but for the fourth screen only
|
||||
patch_t *pat = W_CachePatchName("SRB2BACK", PU_CACHE);
|
||||
patch_t *pat = W_CachePatchName("SRB2BACK", PU_PATCH);
|
||||
INT32 x, y, pw = SHORT(pat->width) * vid.dup, ph = SHORT(pat->height) * vid.dup;
|
||||
|
||||
for (x = vid.width>>1; x < vid.width; x += pw)
|
||||
@@ -361,65 +369,6 @@ static void D_Renderview(void)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
const boolean issplitscreen = (i > 0);
|
||||
|
||||
if (!P_MobjWasRemoved(players[displayplayers[i]].mo) || players[displayplayers[i]].playerstate == PST_DEAD)
|
||||
{
|
||||
viewssnum = i;
|
||||
|
||||
if (!issplitscreen) // Initialize for P1
|
||||
{
|
||||
viewwindowy = viewwindowx = 0;
|
||||
objectsdrawn = 0;
|
||||
}
|
||||
|
||||
#ifdef HWRENDER
|
||||
if (rendermode == render_opengl)
|
||||
{
|
||||
HWR_RenderPlayerView();
|
||||
R_RestoreLevelInterpolators();
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (issplitscreen) // Splitscreen-specific
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 1:
|
||||
if (splitscreen > 1)
|
||||
{
|
||||
viewwindowx = viewwidth;
|
||||
viewwindowy = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
viewwindowx = 0;
|
||||
viewwindowy = viewheight;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
viewwindowx = 0;
|
||||
viewwindowy = viewheight;
|
||||
break;
|
||||
case 3:
|
||||
viewwindowx = viewwidth;
|
||||
viewwindowy = viewheight;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
R_RenderPlayerView(&players[displayplayers[i]]);
|
||||
}
|
||||
|
||||
if (!issplitscreen)
|
||||
R_ApplyViewMorph();
|
||||
|
||||
V_DoPostProcessor(i, postimgparam[i]);
|
||||
}
|
||||
|
||||
R_RestoreLevelInterpolators();
|
||||
}
|
||||
|
||||
@@ -522,19 +471,16 @@ static boolean D_Display(void)
|
||||
case GS_LEVEL:
|
||||
if (!gametic)
|
||||
break;
|
||||
HU_Erase();
|
||||
AM_Drawer();
|
||||
break;
|
||||
|
||||
case GS_INTERMISSION:
|
||||
Y_IntermissionDrawer();
|
||||
HU_Erase();
|
||||
HU_Drawer();
|
||||
break;
|
||||
|
||||
case GS_VOTING:
|
||||
Y_VoteDrawer();
|
||||
HU_Erase();
|
||||
HU_Drawer();
|
||||
break;
|
||||
|
||||
@@ -549,7 +495,6 @@ static boolean D_Display(void)
|
||||
|
||||
case GS_CUTSCENE:
|
||||
F_CutsceneDrawer();
|
||||
HU_Erase();
|
||||
HU_Drawer();
|
||||
break;
|
||||
|
||||
@@ -559,7 +504,6 @@ static boolean D_Display(void)
|
||||
|
||||
case GS_EVALUATION:
|
||||
F_GameEvaluationDrawer();
|
||||
HU_Erase();
|
||||
HU_Drawer();
|
||||
break;
|
||||
|
||||
@@ -569,7 +513,6 @@ static boolean D_Display(void)
|
||||
|
||||
case GS_CREDITS:
|
||||
F_CreditDrawer();
|
||||
HU_Erase();
|
||||
HU_Drawer();
|
||||
break;
|
||||
|
||||
@@ -586,7 +529,6 @@ static boolean D_Display(void)
|
||||
{
|
||||
// I don't think HOM from nothing drawing is independent...
|
||||
F_WaitingPlayersDrawer();
|
||||
HU_Erase();
|
||||
HU_Drawer();
|
||||
}
|
||||
case GS_TIMEATTACK:
|
||||
@@ -726,7 +668,7 @@ static boolean D_Display(void)
|
||||
// D_SRB2Loop
|
||||
// =========================================================================
|
||||
|
||||
tic_t rendergametic;
|
||||
tic_t rendergametic = 0;
|
||||
|
||||
void D_SRB2Loop(void)
|
||||
{
|
||||
@@ -851,11 +793,6 @@ void D_SRB2Loop(void)
|
||||
|
||||
if (!dedicated)
|
||||
{
|
||||
if (menuactive)
|
||||
{
|
||||
D_GamePadMenuScrollTicker();
|
||||
}
|
||||
|
||||
D_DeviceLEDTick();
|
||||
}
|
||||
}
|
||||
@@ -973,8 +910,11 @@ void D_ClearState(void)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
demo.title = false;
|
||||
|
||||
// okay, stop now
|
||||
// (otherwise the game still thinks we're playing!)
|
||||
CURLAbortFile();
|
||||
SV_StopServer();
|
||||
SV_ResetServer();
|
||||
serverlistultimatecount = 0;
|
||||
@@ -983,7 +923,10 @@ void D_ClearState(void)
|
||||
CL_ClearPlayer(i);
|
||||
|
||||
splitscreen = 0;
|
||||
SplitScreen_OnChange();
|
||||
|
||||
// recompute screen size
|
||||
R_ExecuteSetViewSize();
|
||||
|
||||
botingame = false;
|
||||
botskin = 0;
|
||||
cv_debug = 0;
|
||||
@@ -1002,7 +945,6 @@ void D_ClearState(void)
|
||||
gameaction = ga_nothing;
|
||||
memset(displayplayers, 0, sizeof(displayplayers));
|
||||
consoleplayer = 0;
|
||||
//demosequence = -1;
|
||||
gametype = GT_RACE; // SRB2kart
|
||||
paused = false;
|
||||
|
||||
@@ -1025,6 +967,11 @@ void D_ClearState(void)
|
||||
|
||||
G_SetGamestate(GS_NULL);
|
||||
wipegamestate = GS_NULL;
|
||||
|
||||
M_ClearMenus(true);
|
||||
|
||||
// map palettes affect this
|
||||
D_ResetDeviceLED();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1032,25 +979,18 @@ void D_ClearState(void)
|
||||
//
|
||||
void D_StartTitle(void)
|
||||
{
|
||||
demo.title = false;
|
||||
D_ClearState();
|
||||
netgame = false; // title menu shouldnt be a netgame lmao
|
||||
M_ClearMenus(true);
|
||||
multiplayer = netgame = false; // title menu shouldnt be a netgame or multiplayer lmao
|
||||
F_StartTitleScreen();
|
||||
D_ResetDeviceLED();
|
||||
}
|
||||
|
||||
//
|
||||
// D_AddFile
|
||||
//
|
||||
static void D_AddFile(const char *file, char **filearray)
|
||||
static void D_AddFile(const char *file, char **filearray, size_t index)
|
||||
{
|
||||
size_t pnumwadfiles;
|
||||
char *newfile;
|
||||
|
||||
for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++)
|
||||
;
|
||||
|
||||
newfile = malloc(strlen(file) + 1);
|
||||
if (!newfile)
|
||||
{
|
||||
@@ -1058,16 +998,17 @@ static void D_AddFile(const char *file, char **filearray)
|
||||
}
|
||||
strcpy(newfile, file);
|
||||
|
||||
filearray[pnumwadfiles] = newfile;
|
||||
filearray[index] = newfile;
|
||||
}
|
||||
|
||||
static void D_CleanFile(char **filearray)
|
||||
static void D_CleanFile(char **filearray, size_t count)
|
||||
{
|
||||
size_t pnumwadfiles;
|
||||
for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++)
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
free(filearray[pnumwadfiles]);
|
||||
filearray[pnumwadfiles] = NULL;
|
||||
free(filearray[i]);
|
||||
filearray[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1080,28 +1021,27 @@ static INT32 D_DetectFileType(const char* filename)
|
||||
|
||||
const size_t len = strlen(filename);
|
||||
|
||||
if (!stricmp(&filename[len - 4], ".wad"))
|
||||
if (fasticmp(&filename[len - 4], ".wad"))
|
||||
return 2;
|
||||
else if (!stricmp(&filename[len - 4], ".pk3"))
|
||||
else if (fasticmp(&filename[len - 4], ".pk3"))
|
||||
return 3;
|
||||
else if (!stricmp(&filename[len - 5], ".kart"))
|
||||
else if (fasticmp(&filename[len - 5], ".kart"))
|
||||
return 4;
|
||||
else if (!stricmp(&filename[len - 4], ".lua"))
|
||||
else if (fasticmp(&filename[len - 4], ".lua"))
|
||||
return 5;
|
||||
else if (!stricmp(&filename[len - 4], ".soc"))
|
||||
else if (fasticmp(&filename[len - 4], ".soc"))
|
||||
return 6;
|
||||
else if (!stricmp(&filename[len - 4], ".cfg"))
|
||||
else if (fasticmp(&filename[len - 4], ".cfg"))
|
||||
return 7;
|
||||
else if (!stricmp(&filename[len - 4], ".txt"))
|
||||
else if (fasticmp(&filename[len - 4], ".txt"))
|
||||
return 8;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// autoload that shit
|
||||
static void D_AutoloadFile(const char *file, char **filearray)
|
||||
static void D_AutoloadFile(const char *file, char **filearray, size_t index)
|
||||
{
|
||||
size_t pnumwadfiles;
|
||||
char *newfile;
|
||||
INT32 fileType = D_DetectFileType(file);
|
||||
|
||||
@@ -1111,9 +1051,6 @@ static void D_AutoloadFile(const char *file, char **filearray)
|
||||
return;
|
||||
}
|
||||
|
||||
for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++)
|
||||
;
|
||||
|
||||
if (fileType <= 6)
|
||||
{
|
||||
newfile = malloc(strlen(file) + 1);
|
||||
@@ -1121,7 +1058,7 @@ static void D_AutoloadFile(const char *file, char **filearray)
|
||||
I_Error("No more free memory to AutoloadFile %s",file);
|
||||
|
||||
strcpy(newfile, file);
|
||||
filearray[pnumwadfiles] = newfile;
|
||||
filearray[index] = newfile;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1151,42 +1088,44 @@ static void D_FindAddonsToAutoload(void)
|
||||
{
|
||||
FILE *autoloadconfigfile;
|
||||
const char *autoloadpath;
|
||||
char *newline;
|
||||
|
||||
boolean postload;
|
||||
|
||||
INT32 i;
|
||||
char wadsToAutoload[256] = "";
|
||||
|
||||
// does it exist tho
|
||||
autoloadpath = va("%s"PATHSEP"%s",srb2home,AUTOLOADCONFIGFILENAME);
|
||||
autoloadpath = va("%s"PATHSEP"%s", srb2home, AUTOLOADCONFIGFILENAME);
|
||||
autoloadconfigfile = fopen(autoloadpath, "r");
|
||||
|
||||
// If the file is found, run our shit
|
||||
if (!autoloadconfigfile) // nope outta here
|
||||
{
|
||||
wasautoloaded = postautoloaded = true; // so D_AddAutoloadFiles can skip everything since nothings there to autoload
|
||||
autoloadcount = postloadcount = 0; // so D_AddAutoloadFiles can skip everything since nothings there to autoload
|
||||
return;
|
||||
}
|
||||
|
||||
while (fgets(wadsToAutoload, sizeof wadsToAutoload, autoloadconfigfile) != NULL)
|
||||
while (fgets(wadsToAutoload, sizeof(wadsToAutoload), autoloadconfigfile) != NULL)
|
||||
{
|
||||
postload = false;
|
||||
|
||||
// skip if commented or empty
|
||||
if ((wadsToAutoload[1] == '\0' || wadsToAutoload[1] == '\n')
|
||||
|| (wadsToAutoload[0] == '#'))
|
||||
if (wadsToAutoload[0] == '\n' ||
|
||||
wadsToAutoload[0] == '#' ||
|
||||
wadsToAutoload[0] == '\0')
|
||||
continue;
|
||||
|
||||
// this marks it so that it loads after loading server addons
|
||||
else if (fastncmp(wadsToAutoload, "postload ", 9))
|
||||
if (fastncmp(wadsToAutoload, "postload ", 9))
|
||||
{
|
||||
strremove(wadsToAutoload, "postload ");
|
||||
postload = true;
|
||||
}
|
||||
|
||||
// Remove Any Empty or Skipped Lines
|
||||
for (i = 0; wadsToAutoload[i] != '\0'; i++)
|
||||
{
|
||||
if (wadsToAutoload[i] == '\n')
|
||||
wadsToAutoload[i] = '\0';
|
||||
}
|
||||
newline = strchr(wadsToAutoload, '\n');
|
||||
if (newline)
|
||||
*newline = '\0';
|
||||
|
||||
if (!postload && W_CheckPostLoadList(wadsToAutoload))
|
||||
{
|
||||
@@ -1196,56 +1135,67 @@ static void D_FindAddonsToAutoload(void)
|
||||
|
||||
// LOAD IT
|
||||
if (!postload)
|
||||
D_AutoloadFile(wadsToAutoload, autoloadwadfiles);
|
||||
{
|
||||
D_AutoloadFile(wadsToAutoload, autoloadwadfiles, autoloadcount);
|
||||
autoloadcount++;
|
||||
}
|
||||
else
|
||||
D_AutoloadFile(wadsToAutoload, autoloadwadfilespost);
|
||||
|
||||
// end it here
|
||||
for (i = 0; wadsToAutoload[i] != '\0'; i++)
|
||||
wadsToAutoload[i] = '\0';
|
||||
{
|
||||
D_AutoloadFile(wadsToAutoload, autoloadwadfilespost, postloadcount);
|
||||
postloadcount++;
|
||||
}
|
||||
}
|
||||
|
||||
autoloadwadfiles[autoloadcount] = NULL;
|
||||
autoloadwadfilespost[postloadcount] = NULL;
|
||||
|
||||
// we dont want memory leaks around here do we?
|
||||
fclose(autoloadconfigfile);
|
||||
}
|
||||
|
||||
static void D_AddAutoloadFiles(void)
|
||||
{
|
||||
if (wasautoloaded)
|
||||
// nothing to autoload
|
||||
if (autoloadcount == 0)
|
||||
return;
|
||||
|
||||
CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n");
|
||||
|
||||
if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0)
|
||||
CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
|
||||
D_CleanFile(autoloadwadfiles);
|
||||
|
||||
wasautoloaded = true;
|
||||
D_CleanFile(autoloadwadfiles, autoloadcount);
|
||||
|
||||
autoloadcount = 0;
|
||||
}
|
||||
|
||||
void D_AddPostloadFiles(void)
|
||||
{
|
||||
if (postautoloaded || !netgame)
|
||||
// nothing to postload
|
||||
if (postloadcount == 0 || !netgame)
|
||||
return;
|
||||
|
||||
CONS_Printf("D_AddPostloadFiles(): Loading postloaded addons...\n");
|
||||
|
||||
if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0)
|
||||
CONS_Printf("D_AddPostloadFiles(): Are you sure you put in valid files or what?\n");
|
||||
D_CleanFile(autoloadwadfilespost);
|
||||
|
||||
postautoloaded = true;
|
||||
D_CleanFile(autoloadwadfilespost, postloadcount);
|
||||
|
||||
postloadcount = 0;
|
||||
}
|
||||
|
||||
// ==========================================================================
|
||||
// Identify the SRB2 version, and IWAD file to use.
|
||||
// ==========================================================================
|
||||
|
||||
static boolean AddIWAD(void)
|
||||
static boolean AddIWAD(const char * file, const char *dir)
|
||||
{
|
||||
char * path = va(pandf, srb2path, "srb2.srb");
|
||||
char * path = va(pandf, dir, file);
|
||||
|
||||
if (FIL_ReadFileOK(path))
|
||||
{
|
||||
D_AddFile(path, startupiwadfiles);
|
||||
D_AddFile(path, startupiwadfiles, startupiwadcount++);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1281,14 +1231,14 @@ static void IdentifyVersion(void)
|
||||
}
|
||||
|
||||
#if (1) // reduce the amount of findfile by only using full cwd in this func
|
||||
if (strcmp(tempsrb2path, srb2waddir))
|
||||
if (!fastcmp(tempsrb2path, srb2waddir))
|
||||
#endif
|
||||
{
|
||||
strlcpy(srb2path, srb2waddir, sizeof (srb2path));
|
||||
}
|
||||
|
||||
// Load the IWAD
|
||||
if (!AddIWAD())
|
||||
if (!AddIWAD("srb2.srb", srb2path)) // not sure why this uses srb2path and not srb2waddir?
|
||||
{
|
||||
I_Error("SRB2.SRB not found! Expected in %s\n", srb2waddir);
|
||||
}
|
||||
@@ -1302,57 +1252,60 @@ static void IdentifyVersion(void)
|
||||
|
||||
#ifdef USE_PATCH_DTA
|
||||
// Add our crappy patches to fix our bugs
|
||||
D_AddFile(va(pandf,srb2waddir,"patch.dta"));
|
||||
if (!AddIWAD("patch.dta", srb2waddir))
|
||||
{
|
||||
I_Error("patch.dta not found! Expected in %s\n", srb2waddir);
|
||||
}
|
||||
#endif
|
||||
if (!AddIWAD("gfx.kart", srb2waddir))
|
||||
{
|
||||
I_Error("gfx.kart not found! Expected in %s\n", srb2waddir);
|
||||
}
|
||||
|
||||
D_AddFile(va(pandf, srb2waddir, "gfx.kart"), startupiwadfiles);
|
||||
D_AddFile(va(pandf, srb2waddir, "textures.kart"), startupiwadfiles);
|
||||
D_AddFile(va(pandf, srb2waddir, "chars.kart"), startupiwadfiles);
|
||||
D_AddFile(va(pandf, srb2waddir, "maps.kart"), startupiwadfiles);
|
||||
if (!AddIWAD("textures.kart", srb2waddir))
|
||||
{
|
||||
I_Error("textures.kart not found! Expected in %s\n", srb2waddir);
|
||||
}
|
||||
|
||||
if (!AddIWAD("chars.kart", srb2waddir))
|
||||
{
|
||||
I_Error("chars.kart not found! Expected in %s\n", srb2waddir);
|
||||
}
|
||||
|
||||
if (!AddIWAD("maps.kart", srb2waddir))
|
||||
{
|
||||
I_Error("maps.kart not found! Expected in %s\n", srb2waddir);
|
||||
}
|
||||
#ifdef USE_PATCH_KART
|
||||
D_AddFile(va(pandf,srb2waddir,"patch.kart"), startupiwadfiles);
|
||||
if (!AddIWAD("patch.kart", srb2waddir))
|
||||
{
|
||||
I_Error("patch.kart not found! Expected in %s\n", srb2waddir);
|
||||
}
|
||||
#endif
|
||||
|
||||
const char *path = NULL;
|
||||
|
||||
path = va(pandf, srb2waddir, "extra.kart");
|
||||
|
||||
// completely optional
|
||||
if (FIL_ReadFileOK(path))
|
||||
{
|
||||
D_AddFile(path, startupiwadfiles);
|
||||
if (AddIWAD("extra.kart", srb2waddir))
|
||||
found_extra_kart = true;
|
||||
}
|
||||
|
||||
path = va(pandf, srb2waddir, "extra2.kart");
|
||||
|
||||
// completely optional 2: Back with a vengence
|
||||
if (FIL_ReadFileOK(path))
|
||||
{
|
||||
D_AddFile(path, startupiwadfiles);
|
||||
if (AddIWAD("extra2.kart", srb2waddir))
|
||||
found_extra2_kart = true;
|
||||
}
|
||||
|
||||
path = va(pandf, srb2waddir, "extra3.kart");
|
||||
|
||||
if (FIL_ReadFileOK(path))
|
||||
{
|
||||
D_AddFile(path, startupiwadfiles);
|
||||
if (AddIWAD("extra3.kart", srb2waddir))
|
||||
found_extra3_kart = true;
|
||||
}
|
||||
|
||||
#if !defined (HAVE_SDL) || defined (HAVE_MIXER)
|
||||
#define MUSICTEST(str) \
|
||||
musicpath = va(pandf,srb2waddir,str);\
|
||||
musicpath = va(pandf, srb2waddir, str);\
|
||||
handle = W_OpenWadFile(&musicpath, false); \
|
||||
if (handle) \
|
||||
{\
|
||||
{ \
|
||||
int ms = W_VerifyNMUSlumps(musicpath, handle, false); \
|
||||
fclose(handle); \
|
||||
if (ms == 0) \
|
||||
I_Error("File " str " has been modified with non-music/sound lumps"); \
|
||||
if (ms == 1) \
|
||||
D_AddFile(musicpath, startupiwadfiles); \
|
||||
D_AddFile(musicpath, startupiwadfiles, startupiwadcount++); \
|
||||
}
|
||||
{
|
||||
const char *musicpath;
|
||||
@@ -1726,8 +1679,14 @@ void D_SRB2Main(void)
|
||||
else
|
||||
{
|
||||
// use user specific config file
|
||||
if (M_CheckParm("-workdir") && M_IsNextParm())
|
||||
snprintf(srb2home, sizeof srb2home, "%s", M_GetNextParm());
|
||||
else
|
||||
#ifdef DEFAULTDIR
|
||||
snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome);
|
||||
snprintf(srb2home, sizeof srb2home, "%s" PATHSEP DEFAULTDIR, userhome);
|
||||
#else // DEFAULTDIR
|
||||
snprintf(srb2home, sizeof srb2home, "%s", userhome);
|
||||
#endif // DEFAULTDIR
|
||||
snprintf(downloaddir, sizeof downloaddir, "%s" PATHSEP "DOWNLOAD", srb2home);
|
||||
if (dedicated)
|
||||
snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, srb2home);
|
||||
@@ -1736,17 +1695,6 @@ void D_SRB2Main(void)
|
||||
|
||||
// can't use sprintf since there is %u in savegamename
|
||||
strcatbf(savegamename, srb2home, PATHSEP);
|
||||
#else
|
||||
snprintf(srb2home, sizeof srb2home, "%s", userhome);
|
||||
snprintf(downloaddir, sizeof downloaddir, "%s", userhome);
|
||||
if (dedicated)
|
||||
snprintf(configfile, sizeof configfile, "%s" PATHSEP "d"CONFIGFILENAME, userhome);
|
||||
else
|
||||
snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, userhome);
|
||||
|
||||
// can't use sprintf since there is %u in savegamename
|
||||
strcatbf(savegamename, userhome, PATHSEP);
|
||||
#endif
|
||||
}
|
||||
|
||||
configfile[sizeof configfile - 1] = '\0';
|
||||
@@ -1772,6 +1720,9 @@ void D_SRB2Main(void)
|
||||
}
|
||||
}
|
||||
|
||||
// make sure workdir exists
|
||||
I_mkdir(srb2home, 0755);
|
||||
|
||||
// Create addons dir
|
||||
snprintf(addonsdir, sizeof addonsdir, "%s%s%s", srb2home, PATHSEP, "addons");
|
||||
I_mkdir(addonsdir, 0755);
|
||||
@@ -1800,7 +1751,7 @@ void D_SRB2Main(void)
|
||||
const char *s = M_GetNextParm();
|
||||
|
||||
if (s) // Check for NULL?
|
||||
D_AddFile(s, startuppwads);
|
||||
D_AddFile(s, startuppwads, startuppwadcount++);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1833,8 +1784,10 @@ void D_SRB2Main(void)
|
||||
// load wad, including the main wad file
|
||||
CONS_Printf("W_InitMultipleFiles(): Adding IWAD and main PWADs.\n");
|
||||
|
||||
W_InitMultipleFiles(startupiwadfiles, false);
|
||||
D_CleanFile(startupiwadfiles);
|
||||
W_InitMultipleFiles(startupiwadfiles, startupiwadcount, false);
|
||||
//mainwads = startupiwadcount - musicwads;
|
||||
D_CleanFile(startupiwadfiles, startupiwadcount);
|
||||
startupiwadcount = 0;
|
||||
mainwads = 0;
|
||||
|
||||
#ifndef DEVELOP
|
||||
@@ -1873,15 +1826,16 @@ void D_SRB2Main(void)
|
||||
|
||||
D_CheckMaps(false);
|
||||
|
||||
W_InitMultipleFiles(startuppwads, true);
|
||||
W_InitMultipleFiles(startuppwads, startuppwadcount, true);
|
||||
|
||||
// Only search for pwad maps if we actually have a pwad added
|
||||
if (startuppwads[0] != NULL)
|
||||
if (startuppwadcount > 0)
|
||||
{
|
||||
D_CheckMaps(true);
|
||||
}
|
||||
|
||||
D_CleanFile(startuppwads);
|
||||
D_CleanFile(startuppwads, startuppwadcount);
|
||||
startuppwadcount = 0;
|
||||
|
||||
cht_Init();
|
||||
|
||||
@@ -1925,9 +1879,7 @@ void D_SRB2Main(void)
|
||||
|
||||
G_LoadGameData();
|
||||
|
||||
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
VID_PrepareModeList(); // Regenerate Modelist according to cv_fullscreen
|
||||
#endif
|
||||
|
||||
// set user default mode or mode set at cmdline
|
||||
SCR_CheckDefaultMode();
|
||||
@@ -2147,11 +2099,14 @@ void D_SRB2Main(void)
|
||||
const char *sskill = M_GetNextParm();
|
||||
|
||||
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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -61,9 +61,6 @@ extern boolean minilighticon; // mkwii-style minimap headlight
|
||||
//
|
||||
|
||||
// autoload stuff
|
||||
extern boolean autoloading;
|
||||
extern boolean autoloaded;
|
||||
extern boolean postautoloaded;
|
||||
void D_AddPostloadFiles(void);
|
||||
|
||||
// the infinite loop of D_SRB2Loop() called from win_main for windows version
|
||||
|
||||
+10
-11
@@ -95,9 +95,9 @@ static INT32 sendackpacket = 0, getackpacket = 0;
|
||||
INT32 ticruned = 0, ticmiss = 0;
|
||||
|
||||
// globals
|
||||
INT32 getbps, sendbps;
|
||||
float lostpercent, duppercent, gamelostpercent;
|
||||
INT32 packetheaderlength;
|
||||
INT32 getbps = 0, sendbps = 0;
|
||||
float lostpercent = 0, duppercent = 0, gamelostpercent = 0;
|
||||
INT32 packetheaderlength = 0;
|
||||
|
||||
boolean Net_GetNetStat(void)
|
||||
{
|
||||
@@ -243,7 +243,7 @@ static boolean GetFreeAcknum(UINT8 *freeack)
|
||||
ackpak[i].length = doomcom->datalength;
|
||||
ackpak[i].senttime = I_GetTime();
|
||||
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;
|
||||
|
||||
@@ -412,7 +412,7 @@ void Net_SendAcks(INT32 node)
|
||||
{
|
||||
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -494,7 +494,7 @@ void Net_AckTicker(void)
|
||||
}
|
||||
DEBFILE(va("Resend ack %d, %u<%d at %u\n", ackpak[i].acknum, ackpak[i].senttime,
|
||||
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].resentnum++;
|
||||
ackpak[i].nextacknum = node->nextacknum;
|
||||
@@ -1021,7 +1021,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
|
||||
return false;
|
||||
}
|
||||
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);
|
||||
reboundsize[rebound_head] = doomcom->datalength;
|
||||
rebound_head = (rebound_head+1) % MAXREBOUND;
|
||||
@@ -1107,7 +1107,7 @@ boolean HGetPacket(void)
|
||||
// Get a packet from self
|
||||
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];
|
||||
if (netbuffer->packettype == PT_NODETIMEOUT)
|
||||
doomcom->remotenode = netbuffer->u.textcmd[0];
|
||||
@@ -1127,9 +1127,7 @@ boolean HGetPacket(void)
|
||||
|
||||
while (true)
|
||||
{
|
||||
I_NetGet();
|
||||
|
||||
if (doomcom->remotenode == -1) // No packet received
|
||||
if (!I_NetGet()) // No packets received
|
||||
return false;
|
||||
|
||||
getbytes += packetheaderlength + doomcom->datalength; // For stat
|
||||
@@ -1165,6 +1163,7 @@ boolean HGetPacket(void)
|
||||
GotAcks();
|
||||
continue;
|
||||
}
|
||||
|
||||
doomcom->datalength -= BASEPACKETSIZE;
|
||||
break;
|
||||
}
|
||||
|
||||
+120
-99
@@ -68,22 +68,22 @@
|
||||
// protos
|
||||
// ------
|
||||
|
||||
static void Got_NameAndColor(UINT8 **cp, INT32 playernum);
|
||||
static void Got_WeaponPref(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Mapcmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_PickVotecmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Addfilecmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Pause(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Respawn(UINT8 **cp, INT32 playernum);
|
||||
static void Got_RandomSeed(UINT8 **cp, INT32 playernum);
|
||||
static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Teamchange(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Clearscores(UINT8 **cp, INT32 playernum);
|
||||
static void Got_DiscordInfo(UINT8 **cp, INT32 playernum);
|
||||
static void Got_NameAndColor(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_WeaponPref(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_Mapcmd(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_ExitLevelcmd(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_SetupVotecmd(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_ModifyVotecmd(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_PickVotecmd(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_RequestAddfilecmd(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_Addfilecmd(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_Pause(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_Respawn(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_RandomSeed(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_RunSOCcmd(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_Teamchange(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_Clearscores(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_DiscordInfo(const UINT8 **cp, INT32 playernum);
|
||||
|
||||
static void PointLimit_OnChange(void);
|
||||
static void TimeLimit_OnChange(void);
|
||||
@@ -178,13 +178,13 @@ static void Command_Clearscores_f(void);
|
||||
// Remote Administration
|
||||
static void Command_Changepassword_f(void);
|
||||
static void Command_Login_f(void);
|
||||
static void Got_Login(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Verification(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Removal(UINT8 **cp, INT32 playernum);
|
||||
static void Got_Login(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_Verification(const UINT8 **cp, INT32 playernum);
|
||||
static void Got_Removal(const UINT8 **cp, INT32 playernum);
|
||||
static void Command_Verify_f(void);
|
||||
static void Command_RemoveAdmin_f(void);
|
||||
static void Command_MotD_f(void);
|
||||
static void Got_MotD_f(UINT8 **cp, INT32 playernum);
|
||||
static void Got_MotD_f(const UINT8 **cp, INT32 playernum);
|
||||
|
||||
static void Command_ShowScores_f(void);
|
||||
static void Command_ShowTime_f(void);
|
||||
@@ -292,6 +292,10 @@ consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL,
|
||||
// Lagless camera! Yay!
|
||||
consvar_t cv_laglesscam = {"lagless_camera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
// makes the camera use the saved angleturn in replays instead of the players angle
|
||||
// more accurate to how the recording player seen things in game, but may be jittery if they encountered net issues
|
||||
consvar_t cv_demoangturn = {"useangleturninreplays", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_verticallook[MAXSPLITSCREENPLAYERS] = {
|
||||
{"verticallook", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"verticallook2", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
@@ -964,10 +968,11 @@ void D_RegisterClientCommands(void)
|
||||
|
||||
// g_input.c
|
||||
CV_RegisterVar(&cv_controlperkey);
|
||||
CV_RegisterVar(&cv_turnsmooth);
|
||||
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
CV_RegisterVar(&cv_turnsmooth[i]);
|
||||
|
||||
CV_RegisterVar(&cv_turnaxis[i]);
|
||||
CV_RegisterVar(&cv_moveaxis[i]);
|
||||
CV_RegisterVar(&cv_camturnaxis[i]);
|
||||
@@ -984,6 +989,8 @@ void D_RegisterClientCommands(void)
|
||||
CV_RegisterVar(&cv_xdeadzone[i]);
|
||||
CV_RegisterVar(&cv_ydeadzone[i]);
|
||||
|
||||
CV_RegisterVar(&cv_litesteer[i]);
|
||||
|
||||
CV_RegisterVar(&cv_usejoystick[i]);
|
||||
CV_RegisterVar(&cv_joyscale[i]);
|
||||
CV_RegisterVar(&cv_rumble[i]);
|
||||
@@ -1040,6 +1047,7 @@ void D_RegisterClientCommands(void)
|
||||
CV_RegisterVar(&cv_betainterscreen);
|
||||
|
||||
CV_RegisterVar(&cv_laglesscam);
|
||||
CV_RegisterVar(&cv_demoangturn);
|
||||
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
@@ -1211,7 +1219,7 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum)
|
||||
for (ix = 0; ix < MAXPLAYERS; 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
|
||||
// they joined the game with the same name
|
||||
@@ -1328,7 +1336,7 @@ static void CleanupPlayerName(INT32 playernum, const char *newname)
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (i != playernum && playeringame[i]
|
||||
&& strcasecmp(tmpname, player_names[i]) == 0)
|
||||
&& fasticmp(tmpname, player_names[i]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -1378,7 +1386,7 @@ static void SetPlayerName(INT32 playernum, char *newname)
|
||||
{
|
||||
if (EnsurePlayerNameIsGood(newname, playernum))
|
||||
{
|
||||
if (strcasecmp(newname, player_names[playernum]) != 0)
|
||||
if (!fasticmp(newname, player_names[playernum]))
|
||||
{
|
||||
if (netgame)
|
||||
HU_AddChatText(va("\x82*%s renamed to %s", player_names[playernum], newname), false);
|
||||
@@ -1500,9 +1508,9 @@ static void SendNameAndColor(void)
|
||||
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
|
||||
&& !strcmp(cv_skin.string, skins[players[consoleplayer].skin].name))
|
||||
&& fastcmp(cv_skin.string, skins[players[consoleplayer].skin].name))
|
||||
return;
|
||||
|
||||
// We'll handle it later if we're not playing.
|
||||
@@ -1905,7 +1913,7 @@ static void SendNameAndColor4(void)
|
||||
SendNetXCmdForPlayer(3, XD_NAMEANDCOLOR, buf, p - buf);
|
||||
}
|
||||
|
||||
static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
||||
static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
player_t *p = &players[playernum];
|
||||
char name[MAXPLAYERNAME+1];
|
||||
@@ -1937,7 +1945,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
||||
// set name
|
||||
if (player_name_changes[playernum] < MAXNAMECHANGES)
|
||||
{
|
||||
if (strcasecmp(player_names[playernum], name) != 0)
|
||||
if (!fasticmp(player_names[playernum], name))
|
||||
SetPlayerName(playernum, name);
|
||||
}
|
||||
|
||||
@@ -1991,11 +1999,6 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
|
||||
}
|
||||
else
|
||||
SetPlayerSkinByNum(playernum, skin);
|
||||
|
||||
#ifdef HAVE_DISCORDRPC
|
||||
if (playernum == consoleplayer)
|
||||
DRPC_UpdatePresence();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SendWeaponPref(void)
|
||||
@@ -2038,15 +2041,17 @@ void SendWeaponPref4(void)
|
||||
SendNetXCmdForPlayer(3, XD_WEAPONPREF, buf, 1);
|
||||
}
|
||||
|
||||
static void Got_WeaponPref(UINT8 **cp,INT32 playernum)
|
||||
static void Got_WeaponPref(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
player_t *player = &players[playernum];
|
||||
|
||||
UINT8 prefs = READUINT8(*cp);
|
||||
|
||||
players[playernum].pflags &= ~(PF_FLIPCAM|PF_ANALOGMODE);
|
||||
player->pflags &= ~(PF_FLIPCAM|PF_ANALOGMODE);
|
||||
if (prefs & 1)
|
||||
players[playernum].pflags |= PF_FLIPCAM;
|
||||
player->pflags |= PF_FLIPCAM;
|
||||
if (prefs & 2)
|
||||
players[playernum].pflags |= PF_ANALOGMODE;
|
||||
player->pflags |= PF_ANALOGMODE;
|
||||
}
|
||||
|
||||
void D_SendPlayerConfig(void)
|
||||
@@ -2319,8 +2324,8 @@ static void Command_Playdemo_f(void)
|
||||
|
||||
CONS_Printf(M_GetText("Playing back demo '%s'.\n"), name);
|
||||
|
||||
demo.loadfiles = strcmp(COM_Argv(2), "-addfiles") == 0;
|
||||
demo.ignorefiles = strcmp(COM_Argv(2), "-force") == 0;
|
||||
demo.loadfiles = fastcmp(COM_Argv(2), "-addfiles");
|
||||
demo.ignorefiles = fastcmp(COM_Argv(2), "-force");
|
||||
|
||||
// Internal if no extension, external if one exists
|
||||
// If external, convert the file name to a path in SRB2's home directory
|
||||
@@ -2489,15 +2494,18 @@ void D_SetupVote(void)
|
||||
INT32 i;
|
||||
UINT8 gt = (cv_kartgametypepreference.value == -1) ? gametype : cv_kartgametypepreference.value;
|
||||
UINT8 secondgt = G_SometimesGetDifferentGametype(gt);
|
||||
INT16 votebuffer[4] = {-1,-1,-1,0};
|
||||
INT16 votebuffer[4] = {-1,-1,-1, 0};
|
||||
INT16 luamaps[4] = {0, 0, 0, 0};
|
||||
|
||||
LUA_HookSetupVote(luamaps, sizeof(luamaps)/sizeof(luamaps[0]), gt, secondgt);
|
||||
|
||||
// Correct secondgt if needed
|
||||
UINT8 typeoflevel = mapheaderinfo[luamaps[2]-1]->typeoflevel;
|
||||
if (luamaps[2] && (typeoflevel & G_TOLFlag(secondgt&(~0x80))) == 0)
|
||||
secondgt = ((typeoflevel & TOL_RACE) ? GT_RACE : GT_MATCH)|(secondgt&0x80);
|
||||
if (luamaps[2])
|
||||
{
|
||||
UINT8 typeoflevel = mapheaderinfo[luamaps[2]-1]->typeoflevel;
|
||||
if ((typeoflevel & G_TOLFlag(secondgt&(~0x80))) == 0)
|
||||
secondgt = ((typeoflevel & TOL_RACE) ? GT_RACE : GT_MATCH)|(secondgt&0x80);
|
||||
}
|
||||
|
||||
if (cv_kartencore.value && gt == GT_RACE)
|
||||
WRITEUINT8(p, (gt|0x80));
|
||||
@@ -2598,14 +2606,18 @@ ConcatCommandArgv (int start, int end)
|
||||
size += strlen(COM_Argv(i)) + 1;
|
||||
}
|
||||
|
||||
final = ZZ_Alloc(size);
|
||||
p = final;
|
||||
p = final = ZZ_Alloc(size);
|
||||
|
||||
if (!p)
|
||||
I_Error("ConcatCommandArgv: Out of memory!\n");
|
||||
|
||||
--end;/* handle the final argument separately */
|
||||
|
||||
for (i = start; i < end; ++i)
|
||||
{
|
||||
p += sprintf(p, "%s ", COM_Argv(i));
|
||||
}
|
||||
|
||||
/* at this point "end" is actually the last argument's position */
|
||||
strcpy(p, COM_Argv(end));
|
||||
|
||||
@@ -2838,7 +2850,7 @@ static void Command_Map_f(void)
|
||||
* ::serverplayer or ::adminplayer.
|
||||
* \sa D_MapChange
|
||||
*/
|
||||
static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
||||
static void Got_Mapcmd(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
char mapname[MAX_WADPATH+1];
|
||||
UINT8 flags;
|
||||
@@ -2957,7 +2969,7 @@ static void Command_Pause(void)
|
||||
CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n"));
|
||||
}
|
||||
|
||||
static void Got_Pause(UINT8 **cp, INT32 playernum)
|
||||
static void Got_Pause(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
UINT8 dedicatedpause = false;
|
||||
const char *playername;
|
||||
@@ -3069,7 +3081,7 @@ static void Command_Respawn(void)
|
||||
SendNetXCmd(XD_RESPAWN, &buf, 4);
|
||||
}
|
||||
|
||||
static void Got_Respawn(UINT8 **cp, INT32 playernum)
|
||||
static void Got_Respawn(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
INT32 respawnplayer = READINT32(*cp);
|
||||
|
||||
@@ -3104,7 +3116,7 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum)
|
||||
* \param playernum Player responsible for the message. Must be ::serverplayer.
|
||||
* \author Graue <graue@oceanbase.org>
|
||||
*/
|
||||
static void Got_RandomSeed(UINT8 **cp, INT32 playernum)
|
||||
static void Got_RandomSeed(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
UINT32 seed;
|
||||
|
||||
@@ -3139,7 +3151,7 @@ static void Command_Clearscores_f(void)
|
||||
* \sa XD_CLEARSCORES, Command_Clearscores_f
|
||||
* \author SSNTails <http://www.ssntails.org>
|
||||
*/
|
||||
static void Got_Clearscores(UINT8 **cp, INT32 playernum)
|
||||
static void Got_Clearscores(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
@@ -3184,20 +3196,20 @@ static void Command_Teamchange_f(void)
|
||||
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
else
|
||||
error = true;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
else
|
||||
error = true;
|
||||
@@ -3274,20 +3286,20 @@ static void Command_Teamchange2_f(void)
|
||||
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
else
|
||||
error = true;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
else
|
||||
error = true;
|
||||
@@ -3365,20 +3377,20 @@ static void Command_Teamchange3_f(void)
|
||||
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
else
|
||||
error = true;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
else
|
||||
error = true;
|
||||
@@ -3456,20 +3468,20 @@ static void Command_Teamchange4_f(void)
|
||||
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
else
|
||||
error = true;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
else
|
||||
error = true;
|
||||
@@ -3555,33 +3567,33 @@ static void Command_ServerTeamChange_f(void)
|
||||
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
else
|
||||
error = true;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
else
|
||||
error = true;
|
||||
}
|
||||
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;
|
||||
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;
|
||||
else
|
||||
error = true;
|
||||
@@ -3656,7 +3668,7 @@ static void Command_ServerTeamChange_f(void)
|
||||
}
|
||||
|
||||
//todo: This and the other teamchange functions are getting too long and messy. Needs cleaning.
|
||||
static void Got_Teamchange(UINT8 **cp, INT32 playernum)
|
||||
static void Got_Teamchange(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
changeteam_union NetPacket;
|
||||
boolean error = false, wasspectator = false;
|
||||
@@ -4013,7 +4025,7 @@ static void Command_Login_f(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void Got_Login(UINT8 **cp, INT32 playernum)
|
||||
static void Got_Login(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
#ifdef NOMD5
|
||||
// If we have no MD5 support then completely disable XD_LOGIN responses for security.
|
||||
@@ -4123,7 +4135,7 @@ static void Command_Verify_f(void)
|
||||
SendNetXCmd(XD_VERIFIED, buf, 1);
|
||||
}
|
||||
|
||||
static void Got_Verification(UINT8 **cp, INT32 playernum)
|
||||
static void Got_Verification(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
INT16 num = READUINT8(*cp);
|
||||
|
||||
@@ -4175,7 +4187,7 @@ static void Command_RemoveAdmin_f(void)
|
||||
SendNetXCmd(XD_DEMOTED, buf, 1);
|
||||
}
|
||||
|
||||
static void Got_Removal(UINT8 **cp, INT32 playernum)
|
||||
static void Got_Removal(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
INT16 num = READUINT8(*cp);
|
||||
|
||||
@@ -4216,23 +4228,32 @@ static void Command_MotD_f(void)
|
||||
|
||||
mymotd = Z_Malloc(sizeof(motd), PU_STATIC, NULL);
|
||||
|
||||
strlcpy(mymotd, COM_Argv(1), sizeof motd);
|
||||
if (!mymotd)
|
||||
return;
|
||||
//I_Error("Command_MotD_f: Out of memory!\n"); // idk if this aint a bit too much lel
|
||||
|
||||
strlcpy(mymotd, COM_Argv(1), sizeof(motd));
|
||||
|
||||
for (i = 2; i < j; i++)
|
||||
{
|
||||
strlcat(mymotd, " ", sizeof motd);
|
||||
strlcat(mymotd, COM_Argv(i), sizeof motd);
|
||||
strlcat(mymotd, " ", sizeof(motd));
|
||||
strlcat(mymotd, COM_Argv(i), sizeof(motd));
|
||||
}
|
||||
|
||||
// Disallow non-printing characters and semicolons.
|
||||
for (i = 0; mymotd[i] != '\0'; i++)
|
||||
{
|
||||
if (!isprint(mymotd[i]) || mymotd[i] == ';')
|
||||
{
|
||||
Z_Free(mymotd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((netgame || multiplayer) && client)
|
||||
{
|
||||
SendNetXCmd(XD_SETMOTD, mymotd, i); // send the actual size of the motd string, not the full buffer's size
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(motd, mymotd);
|
||||
@@ -4242,7 +4263,7 @@ static void Command_MotD_f(void)
|
||||
Z_Free(mymotd);
|
||||
}
|
||||
|
||||
static void Got_MotD_f(UINT8 **cp, INT32 playernum)
|
||||
static void Got_MotD_f(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
char *mymotd = Z_Malloc(sizeof(motd), PU_STATIC, NULL);
|
||||
INT32 i;
|
||||
@@ -4309,7 +4330,7 @@ static void Command_RunSOC(void)
|
||||
SendNetXCmd(XD_RUNSOC, buf, length);
|
||||
}
|
||||
|
||||
static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum)
|
||||
static void Got_RunSOCcmd(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
char filename[256];
|
||||
filestatus_t ncs = FS_NOTCHECKED;
|
||||
@@ -4431,7 +4452,7 @@ static void Command_Addfile(void)
|
||||
}
|
||||
|
||||
// Add file on your client directly if it is trivial, or you aren't in a netgame.
|
||||
if (!(netgame || multiplayer) || musiconly)
|
||||
if (!netgame || musiconly)
|
||||
{
|
||||
P_AddWadFile(fn, false);
|
||||
return;
|
||||
@@ -4474,7 +4495,7 @@ static void Command_Addfile(void)
|
||||
if (IsPlayerAdmin(consoleplayer) && (!server)) // Request to add file
|
||||
SendNetXCmd(XD_REQADDFILE, buf, buf_p - buf);
|
||||
else
|
||||
SendNetXCmd(XD_ADDFILE, buf, buf_p - buf);;
|
||||
SendNetXCmd(XD_ADDFILE, buf, buf_p - buf);
|
||||
}
|
||||
|
||||
/** Adds something at runtime.
|
||||
@@ -4587,7 +4608,7 @@ static void Command_GLocalSkin (void)
|
||||
}
|
||||
}
|
||||
|
||||
static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
|
||||
static void Got_RequestAddfilecmd(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
char filename[241];
|
||||
filestatus_t ncs = FS_NOTCHECKED;
|
||||
@@ -4646,7 +4667,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
|
||||
COM_BufAddText(va("addfile %s\n", filename));
|
||||
}
|
||||
|
||||
static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
|
||||
static void Got_Addfilecmd(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
char filename[241];
|
||||
filestatus_t ncs = FS_NOTCHECKED;
|
||||
@@ -5190,14 +5211,14 @@ static void Ringslinger_OnChange(void)
|
||||
static void Gravity_OnChange(void)
|
||||
{
|
||||
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"));
|
||||
CV_StealthSet(&cv_gravity, cv_gravity.defaultvalue);
|
||||
return;
|
||||
}
|
||||
#ifndef NETGAME_GRAVITY
|
||||
if(netgame)
|
||||
if (netgame)
|
||||
{
|
||||
CV_StealthSet(&cv_gravity, cv_gravity.defaultvalue);
|
||||
return;
|
||||
@@ -5446,7 +5467,7 @@ static void Command_ExitLevel_f(void)
|
||||
SendNetXCmd(XD_EXITLEVEL, NULL, 0);
|
||||
}
|
||||
|
||||
static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum)
|
||||
static void Got_ExitLevelcmd(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
(void)cp;
|
||||
|
||||
@@ -5467,7 +5488,7 @@ static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum)
|
||||
G_ExitLevel();
|
||||
}
|
||||
|
||||
static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum)
|
||||
static void Got_SetupVotecmd(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
INT32 i;
|
||||
UINT8 gt, secondgt;
|
||||
@@ -5519,7 +5540,7 @@ static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum)
|
||||
Y_StartVote();
|
||||
}
|
||||
|
||||
static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum)
|
||||
static void Got_ModifyVotecmd(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
SINT8 voted = READSINT8(*cp);
|
||||
UINT8 p = READUINT8(*cp);
|
||||
@@ -5528,7 +5549,7 @@ static void Got_ModifyVotecmd(UINT8 **cp, INT32 playernum)
|
||||
votes[p] = voted;
|
||||
}
|
||||
|
||||
static void Got_PickVotecmd(UINT8 **cp, INT32 playernum)
|
||||
static void Got_PickVotecmd(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
SINT8 pick = READSINT8(*cp);
|
||||
SINT8 level = READSINT8(*cp);
|
||||
@@ -6168,7 +6189,7 @@ static void KartEliminateLast_OnChange(void)
|
||||
P_CheckRacers();
|
||||
}
|
||||
|
||||
void Got_DiscordInfo(UINT8 **p, INT32 playernum)
|
||||
void Got_DiscordInfo(const UINT8 **p, INT32 playernum)
|
||||
{
|
||||
if (playernum != serverplayer /*&& !IsPlayerAdmin(playernum)*/)
|
||||
{
|
||||
|
||||
@@ -209,6 +209,8 @@ extern consvar_t cv_betainterscreen;
|
||||
|
||||
extern consvar_t cv_laglesscam;
|
||||
|
||||
extern consvar_t cv_demoangturn;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SKINMENUTYPE_SCROLL = 0,
|
||||
|
||||
+23
-22
@@ -110,14 +110,14 @@ static fileused_t transferFiles[UINT8_MAX + 1];
|
||||
// Write time of file: utime
|
||||
|
||||
// Receiver structure
|
||||
INT32 fileneedednum; // Number of files needed to join the server
|
||||
fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files
|
||||
INT32 fileneedednum = 0; // Number of files needed to join the server
|
||||
fileneeded_t fileneeded[MAX_WADFILES] = {}; // List of needed files
|
||||
#ifdef HAVE_THREADS
|
||||
static I_mutex downloadmutex;
|
||||
#endif
|
||||
char downloaddir[512] = "DOWNLOAD";
|
||||
|
||||
file_download_t filedownload;
|
||||
file_download_t filedownload = {};
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
static CURL *http_handle;
|
||||
@@ -131,7 +131,7 @@ static UINT32 curl_origfilesize;
|
||||
static UINT32 curl_origtotalfilesize;
|
||||
static char *curl_realname = NULL;
|
||||
fileneeded_t *curl_curfile = NULL;
|
||||
HTTP_login *curl_logins;
|
||||
HTTP_login *curl_logins = NULL;
|
||||
#endif
|
||||
|
||||
/** 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++)
|
||||
{
|
||||
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))
|
||||
{
|
||||
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);
|
||||
nameonly(wadfilename);
|
||||
|
||||
if (!stricmp(wadfilename, p->id.filename))
|
||||
if (fasticmp(wadfilename, p->id.filename))
|
||||
{
|
||||
// Copy file name with full path
|
||||
strlcpy(p->id.filename, wadfiles[wadnum]->filename, MAX_WADPATH);
|
||||
@@ -901,7 +902,7 @@ void SV_FileSendTicker(void)
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -946,17 +947,17 @@ void Got_Filetxpak(void)
|
||||
char *filename = file->filename;
|
||||
static INT32 filetime = 0;
|
||||
|
||||
if (!(strcmp(filename, "srb2.srb")
|
||||
//&& strcmp(filename, "srb2.wad")
|
||||
//&& strcmp(filename, "patch.dta")
|
||||
//&& strcmp(filename, "music.dta")
|
||||
&& strcmp(filename, "gfx.kart")
|
||||
&& strcmp(filename, "textures.kart")
|
||||
&& strcmp(filename, "chars.kart")
|
||||
&& strcmp(filename, "maps.kart")
|
||||
&& strcmp(filename, "sounds.kart")
|
||||
&& strcmp(filename, "music.kart")
|
||||
&& strcmp(filename, "patch.kart")
|
||||
if ((fastcmp(filename, "srb2.srb")
|
||||
//|| fastcmp(filename, "srb2.wad")
|
||||
//|| fastcmp(filename, "patch.dta")
|
||||
//|| fastcmp(filename, "music.dta")
|
||||
|| fastcmp(filename, "gfx.kart")
|
||||
|| fastcmp(filename, "textures.kart")
|
||||
|| fastcmp(filename, "chars.kart")
|
||||
|| fastcmp(filename, "maps.kart")
|
||||
|| fastcmp(filename, "sounds.kart")
|
||||
|| fastcmp(filename, "music.kart")
|
||||
|| fastcmp(filename, "patch.kart")
|
||||
))
|
||||
I_Error("Tried to download \"%s\"", filename);
|
||||
|
||||
@@ -1103,7 +1104,7 @@ void nameonly(char *s)
|
||||
ns = &(s[j+1]);
|
||||
len = strlen(ns);
|
||||
#if 0
|
||||
M_Memcpy(s, ns, len+1);
|
||||
memcpy(s, ns, len+1);
|
||||
#else
|
||||
memmove(s, ns, len+1);
|
||||
#endif
|
||||
@@ -1197,7 +1198,7 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet
|
||||
}
|
||||
|
||||
// next, check SRB2's "home" directory (if non-'.')
|
||||
if (strcmp(srb2home, "."))
|
||||
if (!fastcmp(srb2home, "."))
|
||||
{
|
||||
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-'.')
|
||||
if (strcmp(srb2path, "."))
|
||||
if (!fastcmp(srb2path, "."))
|
||||
{
|
||||
homecheck = filesearch(filename, srb2path, wantedmd5sum, completepath, 10);
|
||||
|
||||
@@ -1554,7 +1555,7 @@ CURLGetLogin (const char *url, HTTP_login ***return_prev_next)
|
||||
( login = (*prev_next));
|
||||
prev_next = &login->next
|
||||
){
|
||||
if (strcmp(login->url, url) == 0)
|
||||
if (fastcmp(login->url, url) != 0)
|
||||
{
|
||||
if (return_prev_next)
|
||||
(*return_prev_next) = prev_next;
|
||||
|
||||
+2
-2
@@ -211,12 +211,12 @@ void D_SetupProtocol(void)
|
||||
|
||||
if (result)
|
||||
{
|
||||
if (strcmp(buffer, "no") == 0)
|
||||
if (!fastcmp(buffer, "no"))
|
||||
{
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
else if (strcmp(buffer, exe_path) != 0)
|
||||
else if (fastcmp(buffer, exe_path))
|
||||
{
|
||||
// overwrite
|
||||
fclose(fp);
|
||||
|
||||
@@ -1442,7 +1442,7 @@ static INT32 errorcount = 0;
|
||||
*/
|
||||
static boolean shutdowning = false;
|
||||
|
||||
void I_Error(const char *error, ...)
|
||||
FUNCIERROR void ATTRNORETURN I_Error(const char *error, ...)
|
||||
{
|
||||
va_list argptr;
|
||||
char buffer[8192];
|
||||
@@ -1709,9 +1709,9 @@ char *I_GetUserName(void)
|
||||
strncpy(username, p, MAXPLAYERNAME);
|
||||
}
|
||||
|
||||
|
||||
if (strcmp(username, "") != 0)
|
||||
if (!fastcmp(username, ""))
|
||||
return username;
|
||||
|
||||
return NULL; // dummy for platform independent version
|
||||
}
|
||||
|
||||
|
||||
+30
-4
@@ -49,6 +49,27 @@ discordRequest_t *discordRequestList = NULL;
|
||||
|
||||
static char self_ip[IP_SIZE+1];
|
||||
|
||||
/*--------------------------------------------------
|
||||
* const char *DRPC_HideUsername(const char *input)
|
||||
*
|
||||
* See header file for description.
|
||||
* --------------------------------------------------*/
|
||||
const char *DRPC_HideUsername(const char *input)
|
||||
{
|
||||
static char buffer[5];
|
||||
int i;
|
||||
|
||||
buffer[0] = input[0];
|
||||
|
||||
for (i = 1; i < 4; ++i)
|
||||
{
|
||||
buffer[i] = '.';
|
||||
}
|
||||
|
||||
buffer[4] = '\0';
|
||||
return buffer;
|
||||
}
|
||||
|
||||
boolean drpc_init = false;
|
||||
|
||||
/*--------------------------------------------------
|
||||
@@ -105,7 +126,7 @@ static void DRPC_HandleReady(const DiscordUser *user)
|
||||
}
|
||||
else
|
||||
{
|
||||
CONS_Printf("Discord: connected to %s#%s (%s)\n", user->username, user->discriminator, user->userId);
|
||||
CONS_Printf("Discord: connected to %s (%s)\n", user->username, user->userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,8 +262,10 @@ static void DRPC_HandleJoinRequest(const DiscordUser *requestUser)
|
||||
newRequest->username = Z_Calloc(344, PU_STATIC, NULL);
|
||||
snprintf(newRequest->username, 344, "%s", requestUser->username);
|
||||
|
||||
#if 0
|
||||
newRequest->discriminator = Z_Calloc(8, PU_STATIC, NULL);
|
||||
snprintf(newRequest->discriminator, 8, "%s", requestUser->discriminator);
|
||||
#endif
|
||||
|
||||
newRequest->userID = Z_Calloc(32, PU_STATIC, NULL);
|
||||
snprintf(newRequest->userID, 32, "%s", requestUser->userId);
|
||||
@@ -254,7 +277,7 @@ static void DRPC_HandleJoinRequest(const DiscordUser *requestUser)
|
||||
while (append != NULL)
|
||||
{
|
||||
// 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);
|
||||
DRPC_RemoveRequest(newRequest);
|
||||
@@ -308,6 +331,9 @@ void DRPC_RemoveRequest(discordRequest_t *removeRequest)
|
||||
}
|
||||
|
||||
Z_Free(removeRequest->username);
|
||||
#if 0
|
||||
Z_Free(removeRequest->discriminator);
|
||||
#endif
|
||||
Z_Free(removeRequest->userID);
|
||||
Z_Free(removeRequest);
|
||||
}
|
||||
@@ -393,7 +419,7 @@ static const char *DRPC_GetServerIP(void)
|
||||
// If you're connected
|
||||
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!
|
||||
// No need to do anything else :)
|
||||
@@ -658,7 +684,7 @@ void DRPC_UpdatePresence(void)
|
||||
// Character image
|
||||
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]);
|
||||
discordPresence.smallImageKey = charimg;
|
||||
|
||||
@@ -29,7 +29,9 @@ extern struct discordInfo_s {
|
||||
|
||||
typedef struct discordRequest_s {
|
||||
char *username; // Discord user name.
|
||||
#if 0 // Good night, sweet prince...
|
||||
char *discriminator; // Discord discriminator (The little hashtag thing after the username). Separated for a "hide discriminators" cvar.
|
||||
#endif
|
||||
char *userID; // The ID of the Discord user, gets used with Discord_Respond()
|
||||
|
||||
// HAHAHA, no.
|
||||
@@ -44,6 +46,15 @@ typedef struct discordRequest_s {
|
||||
|
||||
extern discordRequest_t *discordRequestList;
|
||||
|
||||
/*--------------------------------------------------
|
||||
* const char *DRPC_HideUsername(const char *input);
|
||||
*
|
||||
* Handle usernames while cv_discordstreamer is activated.
|
||||
* (The loss of discriminators is still a dumbass regression
|
||||
* that I will never forgive the Discord developers for.)
|
||||
* --------------------------------------------------*/
|
||||
|
||||
const char *DRPC_HideUsername(const char *input);
|
||||
|
||||
/*--------------------------------------------------
|
||||
void DRPC_RemoveRequest(void);
|
||||
|
||||
+4
-11
@@ -69,6 +69,8 @@ extern "C" {
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "fastcmp.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
@@ -90,12 +92,6 @@ extern FILE *logstream;
|
||||
extern char logfilename[1024];
|
||||
#endif
|
||||
|
||||
// not sure if this belongs here lul
|
||||
// TODO: figure out whats preventing 32bit windows from working with libbacktrace
|
||||
#if defined(_WIN32) && !defined(__MINGW64__)
|
||||
#define HAVE_DRMINGW
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_LIBBACKTRACE)
|
||||
#define CRASH_LOGFILE_NAME "srb2kart-crash-log.txt"
|
||||
#elif defined (HAVE_DRMINGW)
|
||||
@@ -457,11 +453,6 @@ extern char savegamename[256];
|
||||
//TODO: delet this
|
||||
#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 *M_GetToken(const char *inputString);
|
||||
char *sizeu1(size_t num);
|
||||
@@ -657,7 +648,9 @@ extern const char *compdate, *comptime, *comprevision, *compbranch;
|
||||
|
||||
#if defined (HAVE_CURL)
|
||||
#define MASTERSERVER
|
||||
#ifndef NOHOLEPUNCH
|
||||
#define HOLEPUNCH
|
||||
#endif
|
||||
#else
|
||||
#undef UPDATE_ALERT
|
||||
#endif
|
||||
|
||||
@@ -116,7 +116,10 @@ extern UINT8 window_notinfocus; // are we in focus? (backend independant -- hand
|
||||
extern boolean nodrawers;
|
||||
extern boolean noblit;
|
||||
extern boolean lastdraw;
|
||||
|
||||
#ifdef MOTIONBLUR
|
||||
extern INT32 postimgparam[MAXSPLITSCREENPLAYERS];
|
||||
#endif
|
||||
|
||||
extern INT32 viewwindowx, viewwindowy;
|
||||
extern INT32 viewwidth;
|
||||
|
||||
@@ -43,7 +43,6 @@ extern "C" {
|
||||
#define UINT64 uint64_t
|
||||
|
||||
#ifdef __APPLE_CC__
|
||||
#define DIRECTFULLSCREEN 1
|
||||
#define DEBUG_LOG
|
||||
#define NOIPX
|
||||
#endif
|
||||
|
||||
@@ -963,6 +963,7 @@ void F_StartTitleScreen(void)
|
||||
finalecount = 0;
|
||||
else
|
||||
wipegamestate = GS_TITLESCREEN;
|
||||
|
||||
G_SetGamestate(GS_TITLESCREEN);
|
||||
CON_ClearHUD();
|
||||
|
||||
|
||||
+2
-2
@@ -257,7 +257,7 @@ static void F_DoWipe(fademask_t *fademask)
|
||||
// shortcut - memcpy source to work
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -266,7 +266,7 @@ static void F_DoWipe(fademask_t *fademask)
|
||||
// shortcut - memcpy target to work
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
+14
-14
@@ -44,7 +44,7 @@ consvar_t cv_addons_search_case = {"addons_search_case", "No", CV_SAVE, CV_YesNo
|
||||
static CV_PossibleValue_t addons_search_type_cons_t[] = {{0, "Start"}, {1, "Anywhere"}, {0, NULL}};
|
||||
consvar_t cv_addons_search_type = {"addons_search_type", "Anywhere", CV_SAVE, addons_search_type_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
char menupath[1024];
|
||||
char menupath[MAXFILEPATH];
|
||||
size_t menupathindex[menudepth];
|
||||
size_t menudepthleft = menudepth;
|
||||
|
||||
@@ -111,7 +111,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
|
||||
int found = 0;
|
||||
char *searchname;
|
||||
int depthleft = maxsearchdepth;
|
||||
char searchpath[1024];
|
||||
char searchpath[MAXFILEPATH];
|
||||
size_t *searchpathindex;
|
||||
|
||||
dirhandle = (DIR**)malloc(maxsearchdepth * sizeof(DIR*));
|
||||
@@ -198,7 +198,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
|
||||
|
||||
for (; *path != NULL; path++)
|
||||
{
|
||||
if (strcasecmp(*path, dent->d_name) == 0)
|
||||
if (fasticmp(*path, dent->d_name))
|
||||
{
|
||||
skipfolder = true;
|
||||
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)
|
||||
{
|
||||
// Got read permissions!
|
||||
@@ -227,7 +227,7 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
|
||||
|
||||
// I am a file!
|
||||
|
||||
if (strcasecmp(searchname, dent->d_name))
|
||||
if (!fasticmp(searchname, dent->d_name))
|
||||
continue; // Not what we're looking for!
|
||||
|
||||
switch (checkfilemd5(searchpath, wantedmd5sum))
|
||||
@@ -353,7 +353,7 @@ void searchfilemenu(char *tempname)
|
||||
{
|
||||
for (i = first; i < sizedirmenu; i++)
|
||||
{
|
||||
if (!strcmp(dirmenu[i]+DIR_STRING, tempname))
|
||||
if (fastcmp(dirmenu[i]+DIR_STRING, tempname))
|
||||
{
|
||||
dir_on[menudepthleft] = i;
|
||||
break;
|
||||
@@ -400,7 +400,7 @@ void searchfilemenu(char *tempname)
|
||||
{
|
||||
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;
|
||||
Z_Free(tempname);
|
||||
@@ -478,14 +478,14 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
|
||||
|
||||
if (replayhut)
|
||||
{
|
||||
if (strcasecmp(".lmp", dent->d_name+len-5))
|
||||
if (!fasticmp(".lmp", dent->d_name+len-5))
|
||||
continue; // Not a replay
|
||||
}
|
||||
else if (!cv_addons_showall.value)
|
||||
{
|
||||
UINT8 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
|
||||
|
||||
if (ext == NUM_EXT_TABLE)
|
||||
@@ -559,7 +559,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
|
||||
|
||||
if (replayhut)
|
||||
{
|
||||
if (strcasecmp(".lmp", dent->d_name+len-5))
|
||||
if (!fasticmp(".lmp", dent->d_name+len-5))
|
||||
continue; // Not a replay
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
|
||||
if (ext == NUM_EXT_TABLE && !cv_addons_showall.value)
|
||||
@@ -587,7 +587,7 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
|
||||
nameonly(filenamebuf[i]);
|
||||
}
|
||||
|
||||
if (strcmp(dent->d_name, filenamebuf[i]))
|
||||
if (!fastcmp(dent->d_name, filenamebuf[i]))
|
||||
continue;
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
if (!strcmp(dent->d_name, configfile))
|
||||
if (fastcmp(dent->d_name, configfile))
|
||||
ext |= EXT_LOADED;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -34,7 +34,8 @@ filestatus_t filesearch(char *filename, const char *startpath, const UINT8 *want
|
||||
|
||||
#define menudepth 20
|
||||
|
||||
extern char menupath[1024];
|
||||
#define MAXFILEPATH 1024
|
||||
extern char menupath[MAXFILEPATH];
|
||||
extern size_t menupathindex[menudepth];
|
||||
extern size_t menudepthleft;
|
||||
|
||||
|
||||
+452
-372
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -67,7 +67,7 @@ typedef enum {
|
||||
} menudemotype_e;
|
||||
|
||||
typedef struct menudemo_s {
|
||||
char filepath[256];
|
||||
char filepath[1023 + 256]; // see M_PrepReplayList and sizeof menupath
|
||||
menudemotype_e type;
|
||||
|
||||
char title[65]; // Null-terminated for string prints
|
||||
|
||||
+209
-187
@@ -59,15 +59,15 @@
|
||||
#include "discord.h"
|
||||
#endif
|
||||
|
||||
gameaction_t gameaction;
|
||||
gameaction_t gameaction = 0;
|
||||
gamestate_t gamestate = GS_NULL;
|
||||
UINT8 ultimatemode = false;
|
||||
|
||||
boolean botingame;
|
||||
UINT8 botskin;
|
||||
UINT8 botcolor;
|
||||
boolean botingame = false;
|
||||
UINT8 botskin = 0;
|
||||
UINT8 botcolor = 0;
|
||||
|
||||
JoyType_t Joystick[MAXSPLITSCREENPLAYERS];
|
||||
JoyType_t Joystick[MAXSPLITSCREENPLAYERS] = {};
|
||||
|
||||
// 1024 bytes is plenty for a savegame
|
||||
#define SAVEGAMESIZE (1024)
|
||||
@@ -83,10 +83,10 @@ static void G_DoContinued(void);
|
||||
static void G_DoWorldDone(void);
|
||||
static void G_DoStartVote(void);
|
||||
|
||||
music_t mapmusic;
|
||||
music_t mapmusic = {};
|
||||
|
||||
INT16 gamemap = 1;
|
||||
INT16 maptol;
|
||||
INT16 maptol = 0;
|
||||
UINT8 globalweather = 0;
|
||||
INT32 curWeather = PRECIP_NONE;
|
||||
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 majormods = false; // Set if Lua/Gameplay SOC/replacement map has been added.
|
||||
boolean savemoddata = false;
|
||||
UINT8 paused;
|
||||
UINT8 paused = 0;
|
||||
UINT8 modeattacking = ATTACKING_NONE;
|
||||
boolean imcontinuing = false;
|
||||
boolean runemeraldmanager = false;
|
||||
|
||||
boolean netgame; // only true if packets are broadcast
|
||||
boolean multiplayer;
|
||||
boolean playeringame[MAXPLAYERS];
|
||||
boolean addedtogame;
|
||||
player_t players[MAXPLAYERS];
|
||||
boolean netgame = false; // only true if packets are broadcast
|
||||
boolean multiplayer = false;
|
||||
boolean playeringame[MAXPLAYERS] = {};
|
||||
boolean addedtogame = false;
|
||||
player_t players[MAXPLAYERS] = {};
|
||||
|
||||
INT32 consoleplayer; // player taking events and displaying
|
||||
INT32 displayplayers[MAXSPLITSCREENPLAYERS] = {0}; // view being displayed
|
||||
INT32 consoleplayer = 0; // player taking events and displaying
|
||||
INT32 displayplayers[MAXSPLITSCREENPLAYERS] = {}; // view being displayed
|
||||
|
||||
tic_t gametic;
|
||||
tic_t levelstarttic; // gametic at level start
|
||||
UINT32 totalrings; // for intermission
|
||||
INT16 lastmap; // last level you were at (returning from special stages)
|
||||
tic_t timeinmap; // Ticker for time spent in level (used for levelcard display)
|
||||
tic_t gametic = 0;
|
||||
tic_t levelstarttic = 0; // gametic at level start
|
||||
UINT32 totalrings = 0; // for intermission
|
||||
INT16 lastmap = 0; // last level you were at (returning from special stages)
|
||||
tic_t timeinmap = 0; // Ticker for time spent in level (used for levelcard display)
|
||||
|
||||
INT16 spstage_start;
|
||||
INT16 sstage_start;
|
||||
INT16 sstage_end;
|
||||
INT16 spstage_start = 0;
|
||||
INT16 sstage_start = 0;
|
||||
INT16 sstage_end = 0;
|
||||
|
||||
boolean looptitle = true;
|
||||
boolean useNightsSS = false;
|
||||
@@ -134,42 +134,42 @@ boolean countdowntimeup = false;
|
||||
|
||||
cutscene_t *cutscenes[128];
|
||||
|
||||
INT16 nextmapoverride;
|
||||
boolean skipstats;
|
||||
INT16 nextmapoverride = 0;
|
||||
boolean skipstats = false;
|
||||
|
||||
// Pointers to each CTF flag
|
||||
mobj_t *redflag;
|
||||
mobj_t *blueflag;
|
||||
mobj_t *redflag = NULL;
|
||||
mobj_t *blueflag = NULL;
|
||||
// Pointers to CTF spawn location
|
||||
mapthing_t *rflagpoint;
|
||||
mapthing_t *bflagpoint;
|
||||
mapthing_t *rflagpoint = NULL;
|
||||
mapthing_t *bflagpoint = NULL;
|
||||
|
||||
struct quake quake;
|
||||
|
||||
// Map Header Information
|
||||
mapheader_t* mapheaderinfo[NUMMAPS] = {NULL};
|
||||
mapheader_t* mapheaderinfo[NUMMAPS] = {};
|
||||
|
||||
static boolean exitgame = 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;
|
||||
UINT32 token; // Number of tokens collected in a level
|
||||
UINT32 tokenlist; // List of tokens collected
|
||||
INT32 tokenbits; // Used for setting token bits
|
||||
UINT16 emeralds = 0;
|
||||
UINT32 token = 0; // Number of tokens collected in a level
|
||||
UINT32 tokenlist = 0; // List of tokens collected
|
||||
INT32 tokenbits = 0; // Used for setting token bits
|
||||
|
||||
// Old Special Stage
|
||||
INT32 sstimer; // Time allotted in the special stage
|
||||
INT32 sstimer = 0; // Time allotted in the special stage
|
||||
|
||||
boolean gamedataloaded = false;
|
||||
|
||||
// Time attack data for levels
|
||||
// These are dynamically allocated for space reasons now
|
||||
recorddata_t *mainrecords[NUMMAPS] = {NULL};
|
||||
UINT8 mapvisited[NUMMAPS];
|
||||
recorddata_t *mainrecords[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!
|
||||
INT32 nummaprings = 0;
|
||||
@@ -179,12 +179,12 @@ INT32 nummapboxes = 0;
|
||||
INT32 numgotboxes = 0;
|
||||
|
||||
// Elminates unnecessary searching.
|
||||
boolean CheckForBustableBlocks;
|
||||
boolean CheckForBouncySector;
|
||||
boolean CheckForQuicksand;
|
||||
boolean CheckForMarioBlocks;
|
||||
boolean CheckForFloatBob;
|
||||
boolean CheckForReverseGravity;
|
||||
boolean CheckForBustableBlocks = false;
|
||||
boolean CheckForBouncySector = false;
|
||||
boolean CheckForQuicksand = false;
|
||||
boolean CheckForMarioBlocks = false;
|
||||
boolean CheckForFloatBob = false;
|
||||
boolean CheckForReverseGravity = false;
|
||||
|
||||
// Powerup durations
|
||||
UINT16 invulntics = 20*TICRATE;
|
||||
@@ -215,67 +215,66 @@ INT32 gameovertics = 15*TICRATE;
|
||||
UINT8 use1upSound = 0;
|
||||
UINT8 maxXtraLife = 2; // Max extra lives from rings
|
||||
|
||||
UINT8 introtoplay;
|
||||
UINT8 creditscutscene;
|
||||
UINT8 introtoplay = 0;
|
||||
UINT8 creditscutscene = 0;
|
||||
|
||||
// Emerald locations
|
||||
mobj_t *hunt1;
|
||||
mobj_t *hunt2;
|
||||
mobj_t *hunt3;
|
||||
mobj_t *hunt1 = NULL;
|
||||
mobj_t *hunt2 = NULL;
|
||||
mobj_t *hunt3 = NULL;
|
||||
|
||||
tic_t racecountdown, exitcountdown; // for racing
|
||||
tic_t racecountdown = 0, exitcountdown = 0; // for racing
|
||||
|
||||
fixed_t gravity;
|
||||
fixed_t mapobjectscale;
|
||||
fixed_t gravity = 0;
|
||||
fixed_t mapobjectscale = FRACUNIT;
|
||||
|
||||
struct maplighting maplighting;
|
||||
|
||||
INT16 autobalance; //for CTF team balance
|
||||
INT16 teamscramble; //for CTF team scramble
|
||||
INT16 scrambleplayers[MAXPLAYERS]; //for CTF team scramble
|
||||
INT16 scrambleteams[MAXPLAYERS]; //for CTF team scramble
|
||||
INT16 scrambletotal; //for CTF team scramble
|
||||
INT16 scramblecount; //for CTF team scramble
|
||||
INT16 autobalance = 0; //for CTF team balance
|
||||
INT16 teamscramble = 0; //for CTF team scramble
|
||||
INT16 scrambleplayers[MAXPLAYERS] = {}; //for CTF team scramble
|
||||
INT16 scrambleteams[MAXPLAYERS] = {}; //for CTF team scramble
|
||||
INT16 scrambletotal = 0; //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
|
||||
// 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 prevencoremode;
|
||||
boolean franticitems; // Frantic items currently enabled?
|
||||
boolean comeback; // Battle Mode's karma comeback is on/off
|
||||
boolean prevencoremode = 0;
|
||||
boolean franticitems = 0; // Frantic items currently enabled?
|
||||
boolean comeback = 0; // Battle Mode's karma comeback is on/off
|
||||
|
||||
// Voting system
|
||||
INT16 votelevels[4][2]; // Levels that were rolled by the host
|
||||
SINT8 votes[MAXPLAYERS]; // Each player's vote
|
||||
SINT8 pickedvote; // What vote the host rolls
|
||||
INT16 votelevels[4][2] = {}; // Levels that were rolled by the host
|
||||
SINT8 votes[MAXPLAYERS] = {}; // Each player's vote
|
||||
SINT8 pickedvote = 0; // What vote the host rolls
|
||||
|
||||
// Server-sided, synched variables
|
||||
SINT8 battlewanted[4]; // WANTED players in battle, worth x2 points
|
||||
tic_t wantedcalcdelay; // 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 hyubgone; // Cooldown before hyudoro is allowed to be rerolled
|
||||
tic_t mapreset; // 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
|
||||
boolean thwompsactive; // Thwomps activate on lap 2
|
||||
SINT8 spbplace; // SPB exists, give the person behind better items
|
||||
boolean startedInFreePlay; // Map was started in free play
|
||||
SINT8 battlewanted[4] = {}; // WANTED players in battle, worth x2 points
|
||||
tic_t wantedcalcdelay = 0; // Time before it recalculates WANTED
|
||||
tic_t indirectitemcooldown = 0; // Cooldown before any more Shrink, SPB, or any other item that works indirectly is awarded
|
||||
tic_t hyubgone = 0; // Cooldown before hyudoro is allowed to be rerolled
|
||||
tic_t mapreset = 0; // Map reset delay when enough players have joined an empty game
|
||||
UINT8 nospectategrief = 0; // How many players need to be in-game to eliminate last; for preventing spectate griefing
|
||||
boolean thwompsactive = 0; // Thwomps activate on lap 2
|
||||
SINT8 spbplace = 0; // SPB exists, give the person behind better items
|
||||
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)
|
||||
boolean legitimateexit; // Did this client actually finish the match?
|
||||
boolean comebackshowninfo; // Have you already seen the "ATTACK OR PROTECT" message?
|
||||
static INT16 randmapbuffer[NUMMAPS+1]; // Buffer for maps RandMap is allowed to roll
|
||||
boolean legitimateexit = 0; // Did this client actually finish the match?
|
||||
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
|
||||
|
||||
tic_t hidetime;
|
||||
tic_t hidetime = 0;
|
||||
|
||||
// Grading
|
||||
UINT32 timesBeaten;
|
||||
UINT32 timesBeatenWithEmeralds;
|
||||
//UINT32 timesBeatenUltimate;
|
||||
UINT32 timesBeaten = 0;
|
||||
UINT32 timesBeatenWithEmeralds = 0;
|
||||
|
||||
INT16 prevmap, nextmap;
|
||||
INT16 prevmap = 0, nextmap = 0;
|
||||
|
||||
// Analog Control
|
||||
void SendWeaponPref(void);
|
||||
@@ -452,6 +451,13 @@ consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS] = {
|
||||
{"joy4_ydeadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS] = {
|
||||
{"litesteer", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"litesteer2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"litesteer3", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"litesteer4", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}};
|
||||
consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
@@ -463,7 +469,7 @@ consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, cechotoggle_t, NULL, 0,
|
||||
#endif
|
||||
|
||||
#ifdef SEENAMES
|
||||
player_t *seenplayer; // player we're aiming at right now
|
||||
player_t *seenplayer = NULL; // player we're aiming at right now
|
||||
#endif
|
||||
|
||||
char player_names[MAXPLAYERS][MAXPLAYERNAME+1] =
|
||||
@@ -486,7 +492,7 @@ char player_names[MAXPLAYERS][MAXPLAYERNAME+1] =
|
||||
"Player 16"
|
||||
}; // SRB2kart - removed Players 17 through 32
|
||||
|
||||
INT32 player_name_changes[MAXPLAYERS];
|
||||
INT32 player_name_changes[MAXPLAYERS] = {};
|
||||
|
||||
INT16 rw_maximums[NUM_WEAPONS] =
|
||||
{
|
||||
@@ -563,6 +569,7 @@ static void G_SetSaveGameModified(void)
|
||||
{
|
||||
if (!unlockables[i].conditionset)
|
||||
continue;
|
||||
|
||||
if (!unlockables[i].unlocked)
|
||||
{
|
||||
unlockables[i].unlocked = true;
|
||||
@@ -588,7 +595,7 @@ void G_SetGameModified(boolean silent, boolean major)
|
||||
G_SetSaveGameModified();
|
||||
|
||||
if (!silent)
|
||||
CONS_Alert(CONS_NOTICE, M_GetText("Record Attack data will be saved to 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 (modeattacking)
|
||||
@@ -627,6 +634,7 @@ const char *G_BuildMapName(INT32 map)
|
||||
map = gamemap-1;
|
||||
else
|
||||
map = prevmap;
|
||||
|
||||
map = G_RandMap(G_TOLFlag(cv_newgametype.value), map, false, 0, false, NULL)+1;
|
||||
}
|
||||
|
||||
@@ -680,11 +688,12 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player)
|
||||
{
|
||||
INT32 retaxis;
|
||||
INT32 axisval;
|
||||
INT32 deadzone;
|
||||
boolean flp = false;
|
||||
|
||||
UINT8 pnum = player-1;
|
||||
|
||||
//find what axis to get
|
||||
// find what axis to get
|
||||
switch (axissel)
|
||||
{
|
||||
case AXISTURN:
|
||||
@@ -743,45 +752,33 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player)
|
||||
{
|
||||
axisval /= 2;
|
||||
retaxis = joyxmove[pnum][axisval];
|
||||
|
||||
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;
|
||||
deadzone = cv_xdeadzone[pnum].value;
|
||||
}
|
||||
else
|
||||
{
|
||||
axisval--;
|
||||
axisval /= 2;
|
||||
retaxis = joyymove[pnum][axisval];
|
||||
|
||||
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;
|
||||
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) * deadzone) >> FRACBITS;
|
||||
|
||||
if (abs(retaxis) <= jdeadzone)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (flp)
|
||||
retaxis = -retaxis; // flip it around
|
||||
|
||||
return retaxis;
|
||||
}
|
||||
|
||||
boolean InputDown(INT32 gc, UINT8 p)
|
||||
@@ -799,9 +796,9 @@ boolean InputDown(INT32 gc, UINT8 p)
|
||||
}
|
||||
}
|
||||
|
||||
INT32 localaiming[MAXSPLITSCREENPLAYERS];
|
||||
angle_t localangle[MAXSPLITSCREENPLAYERS];
|
||||
boolean camspin[MAXSPLITSCREENPLAYERS];
|
||||
INT32 localaiming[MAXSPLITSCREENPLAYERS] = {};
|
||||
angle_t localangle[MAXSPLITSCREENPLAYERS] = {};
|
||||
boolean camspin[MAXSPLITSCREENPLAYERS] = {};
|
||||
|
||||
static fixed_t forwardmove[2] = {25<<FRACBITS>>16, 50<<FRACBITS>>16};
|
||||
static fixed_t sidemove[2] = {2<<FRACBITS>>16, 4<<FRACBITS>>16};
|
||||
@@ -1014,8 +1011,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
else
|
||||
th = 0;
|
||||
|
||||
if (th < SLOWTURNTICS)
|
||||
tspeed = cv_turnsmooth.value == 2 ? 2 : 0; // slow turn
|
||||
if (th < (cv_turnsmooth[forplayer].value * 3))
|
||||
tspeed = cv_turnsmooth[forplayer].value == 2 ? 2 : 0; // slow turn
|
||||
else
|
||||
tspeed = 1;
|
||||
|
||||
@@ -1024,30 +1021,32 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
// let movement keys cancel each other out
|
||||
if (turnright && !(turnleft))
|
||||
{
|
||||
cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed]));
|
||||
cmd->driftturn = (INT16)(cmd->driftturn - (angleturn[tspeed]));
|
||||
cmd->angleturn -= angleturn[tspeed];
|
||||
side += sidemove[1];
|
||||
}
|
||||
else if (turnleft && !(turnright))
|
||||
{
|
||||
cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed]));
|
||||
cmd->driftturn = (INT16)(cmd->driftturn + (angleturn[tspeed]));
|
||||
cmd->angleturn += angleturn[tspeed];
|
||||
side -= sidemove[1];
|
||||
}
|
||||
|
||||
if (analogjoystickmove && axis != 0)
|
||||
{
|
||||
// JOYAXISRANGE should be 1023 (divide by 1024)
|
||||
cmd->angleturn = (INT16)(cmd->angleturn - (((axis * angleturn[1]) >> 10))); // ANALOG!
|
||||
cmd->driftturn = (INT16)(cmd->driftturn - (((axis * angleturn[1]) >> 10)));
|
||||
side += ((axis * sidemove[0]) >> 10);
|
||||
cmd->angleturn -= (axis * KART_FULLTURN) / JOYAXISRANGE;
|
||||
side += (axis * sidemove[0]) / JOYAXISRANGE;
|
||||
}
|
||||
|
||||
if (cv_mouseturn.value)
|
||||
{
|
||||
//THIS WORKS WTF????????
|
||||
cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8)));
|
||||
cmd->driftturn = (INT16)(cmd->driftturn - ((mousex*(encoremode ? -1 : 1)*8)));
|
||||
cmd->angleturn -= (mousex*(encoremode ? -1 : 1)*8);
|
||||
}
|
||||
|
||||
// Digital users can input diagonal-back for shallow turns.
|
||||
if (cv_litesteer[forplayer].value && InputDown(gc_aimbackward, ssplayer)
|
||||
&& abs(cmd->angleturn) == KART_FULLTURN) // My keyboard hits 1024 but my keyboard only hits 1023, video games
|
||||
{
|
||||
cmd->angleturn /= 2;
|
||||
}
|
||||
|
||||
if (objectplacing) // SRB2Kart: spectators need special controls // not anymore huehuehue
|
||||
@@ -1160,10 +1159,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
else if (cmd->angleturn < (-angleturn[1]))
|
||||
cmd->angleturn = (-angleturn[1]);
|
||||
|
||||
if (cmd->driftturn > (angleturn[1]))
|
||||
cmd->driftturn = (angleturn[1]);
|
||||
else if (cmd->driftturn < (-angleturn[1]))
|
||||
cmd->driftturn = (-angleturn[1]);
|
||||
// until here both are the very same
|
||||
cmd->driftturn = cmd->angleturn;
|
||||
|
||||
if (player->mo)
|
||||
cmd->angleturn = K_GetKartTurnValue(player, cmd->angleturn);
|
||||
@@ -1203,7 +1200,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
|
||||
if (gamestate == GS_LEVEL)
|
||||
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
|
||||
&& (cmd->forwardmove || cmd->sidemove || cmd->buttons))
|
||||
{
|
||||
@@ -1212,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;
|
||||
for (i = 0; i < n; i++)
|
||||
@@ -1254,7 +1251,7 @@ static void G_DoLoadLevel(boolean resetplayer)
|
||||
|
||||
if (gamestate == GS_INTERMISSION)
|
||||
Y_EndIntermission();
|
||||
if (gamestate == GS_VOTING)
|
||||
else if (gamestate == GS_VOTING)
|
||||
Y_EndVote();
|
||||
|
||||
G_SetGamestate(GS_LEVEL);
|
||||
@@ -2322,12 +2319,6 @@ void G_PlayerReborn(INT32 player)
|
||||
|
||||
if (gametype == GT_COOP)
|
||||
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;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2346,22 +2337,25 @@ static boolean G_CheckSpot(INT32 playernum, mapthing_t *mthing)
|
||||
if (!mthing)
|
||||
return false;
|
||||
|
||||
x = mthing->x << FRACBITS;
|
||||
y = mthing->y << FRACBITS;
|
||||
|
||||
if (!players[playernum].mo)
|
||||
{
|
||||
// first spawn of level
|
||||
for (i = 0; i < playernum; i++)
|
||||
{
|
||||
if (playeringame[i] && players[i].mo
|
||||
&& players[i].mo->x == mthing->x << FRACBITS
|
||||
&& players[i].mo->y == mthing->y << FRACBITS)
|
||||
&& players[i].mo->x == x
|
||||
&& players[i].mo->y == y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
x = mthing->x << FRACBITS;
|
||||
y = mthing->y << FRACBITS;
|
||||
|
||||
if (!K_CheckPlayersRespawnColliding(playernum, x, y))
|
||||
return false;
|
||||
|
||||
@@ -2761,7 +2755,7 @@ INT32 G_GetGametypeByName(const char *gametypestr)
|
||||
INT32 i;
|
||||
|
||||
for (i = 0; i < NUMGAMETYPES; i++)
|
||||
if (!stricmp(gametypestr, Gametype_Names[i]))
|
||||
if (fasticmp(gametypestr, Gametype_Names[i]))
|
||||
return i;
|
||||
|
||||
return -1; // unknown gametype
|
||||
@@ -2863,17 +2857,23 @@ UINT8 G_GetGametypeColor(INT16 gt)
|
||||
*/
|
||||
INT16 G_TOLFlag(INT32 pgametype)
|
||||
{
|
||||
if (!multiplayer) return TOL_SP;
|
||||
if (pgametype == GT_COOP) return TOL_RACE; // SRB2kart
|
||||
if (pgametype == GT_COMPETITION) return TOL_COMPETITION;
|
||||
if (pgametype == GT_RACE) return TOL_RACE;
|
||||
if (pgametype == GT_MATCH) return TOL_MATCH;
|
||||
if (pgametype == GT_TEAMMATCH) return TOL_MATCH;
|
||||
if (pgametype == GT_TAG) return TOL_TAG;
|
||||
if (pgametype == GT_HIDEANDSEEK) return TOL_TAG;
|
||||
if (pgametype == GT_CTF) return TOL_CTF;
|
||||
if (!multiplayer) return TOL_SP;
|
||||
|
||||
switch (pgametype)
|
||||
{
|
||||
case GT_COOP: return TOL_RACE; // SRB2kart
|
||||
case GT_COMPETITION: return TOL_COMPETITION;
|
||||
case GT_RACE: return TOL_RACE;
|
||||
case GT_MATCH: return TOL_MATCH;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -3056,6 +3056,7 @@ static void G_DoCompleted(void)
|
||||
K_StatRound();
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
if (playeringame[i])
|
||||
{
|
||||
// SRB2Kart: exitlevel shouldn't get you the points
|
||||
@@ -3065,8 +3066,10 @@ static void G_DoCompleted(void)
|
||||
if (P_IsLocalPlayer(&players[i]))
|
||||
j++;
|
||||
}
|
||||
|
||||
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)
|
||||
if (G_RaceGametype() && ((multiplayer && demo.playback) || j == splitscreen+1) && (cv_inttime.value > 0))
|
||||
@@ -3210,10 +3213,14 @@ void G_AfterIntermission(void)
|
||||
|
||||
return;
|
||||
}
|
||||
else if (demo.recording && (modeattacking || demo.savemode != DSM_NOTSAVING))
|
||||
G_SaveDemo();
|
||||
else if (demo.recording)
|
||||
G_ResetDemoRecording();
|
||||
|
||||
if (demo.recording)
|
||||
{
|
||||
if (modeattacking || demo.savemode != DSM_NOTSAVING)
|
||||
G_SaveDemo();
|
||||
else
|
||||
G_ResetDemoRecording();
|
||||
}
|
||||
|
||||
if (modeattacking) // End the run.
|
||||
{
|
||||
@@ -3222,7 +3229,9 @@ void G_AfterIntermission(void)
|
||||
}
|
||||
|
||||
if (mapheaderinfo[gamemap-1]->cutscenenum) // Start a custom cutscene.
|
||||
{
|
||||
F_StartCustomCutscene(mapheaderinfo[gamemap-1]->cutscenenum-1, false, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nextmap < 1100-1)
|
||||
@@ -3359,10 +3368,13 @@ static void G_DoContinued(void)
|
||||
// when something new is added.
|
||||
void G_EndGame(void)
|
||||
{
|
||||
if (demo.recording && (modeattacking || demo.savemode != DSM_NOTSAVING))
|
||||
G_SaveDemo();
|
||||
else if (demo.recording)
|
||||
G_ResetDemoRecording();
|
||||
if (demo.recording)
|
||||
{
|
||||
if (modeattacking || demo.savemode != DSM_NOTSAVING)
|
||||
G_SaveDemo();
|
||||
else
|
||||
G_ResetDemoRecording();
|
||||
}
|
||||
|
||||
// Only do evaluation and credits in coop games.
|
||||
if (gametype == GT_COOP)
|
||||
@@ -3372,6 +3384,7 @@ void G_EndGame(void)
|
||||
F_StartCredits();
|
||||
return;
|
||||
}
|
||||
|
||||
if (nextmap == 1101-1) // end game with evaluation
|
||||
{
|
||||
F_StartGameEvaluation();
|
||||
@@ -3456,7 +3469,8 @@ void G_LoadGameData(void)
|
||||
if (READUINT32(save.p) != 0xFCAFE211)
|
||||
{
|
||||
const char *gdfolder = "the SRB2Kart folder";
|
||||
if (strcmp(srb2home,"."))
|
||||
|
||||
if (!fastcmp(srb2home,"."))
|
||||
gdfolder = srb2home;
|
||||
|
||||
Z_Free(save.buffer);
|
||||
@@ -3470,9 +3484,8 @@ void G_LoadGameData(void)
|
||||
modded = READUINT8(save.p);
|
||||
|
||||
// Aha! Someone's been screwing with the save file!
|
||||
if ((modded && !savemoddata))
|
||||
goto datacorrupt;
|
||||
else if (modded != true && modded != false)
|
||||
if ((modded && !savemoddata) ||
|
||||
(modded != true && modded != false))
|
||||
goto datacorrupt;
|
||||
|
||||
// TODO put another cipher on these things? meh, I don't care...
|
||||
@@ -3537,10 +3550,11 @@ void G_LoadGameData(void)
|
||||
return;
|
||||
|
||||
// Landing point for corrupt gamedata
|
||||
datacorrupt:
|
||||
datacorrupt:
|
||||
{
|
||||
const char *gdfolder = "the SRB2Kart folder";
|
||||
if (strcmp(srb2home,"."))
|
||||
|
||||
if (!fastcmp(srb2home,"."))
|
||||
gdfolder = srb2home;
|
||||
|
||||
Z_Free(save.buffer);
|
||||
@@ -3751,7 +3765,8 @@ void G_LoadGame(UINT32 slot, INT16 mapoverride)
|
||||
|
||||
memset(vcheck, 0, sizeof (vcheck));
|
||||
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
|
||||
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"),
|
||||
@@ -4029,7 +4044,7 @@ char *G_BuildMapTitle(INT32 mapnum)
|
||||
if (!mapheaderinfo[mapnum-1])
|
||||
P_AllocMapHeader(mapnum-1);
|
||||
|
||||
if (strcmp(mapheaderinfo[mapnum-1]->lvlttl, ""))
|
||||
if (!fastcmp(mapheaderinfo[mapnum-1]->lvlttl, ""))
|
||||
{
|
||||
size_t len = 1;
|
||||
const char *zonetext = NULL;
|
||||
@@ -4054,7 +4069,11 @@ char *G_BuildMapTitle(INT32 mapnum)
|
||||
|
||||
title = Z_Malloc(len, PU_STATIC, NULL);
|
||||
|
||||
if (!title)
|
||||
return NULL;
|
||||
|
||||
sprintf(title, "%s", mapheaderinfo[mapnum-1]->lvlttl);
|
||||
|
||||
if (zonetext) sprintf(title + strlen(title), " %s", zonetext);
|
||||
if (actnum) sprintf(title + strlen(title), " %s", actnum);
|
||||
}
|
||||
@@ -4252,18 +4271,21 @@ INT32 G_FindMapByNameOrCode(const char *mapname, char **realmapnamep)
|
||||
{
|
||||
if (mapname[0] == '*') // current map
|
||||
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;
|
||||
else if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map
|
||||
|
||||
if (mapname[0] == '+' && mapheaderinfo[gamemap-1]) // next map
|
||||
{
|
||||
newmapnum = mapheaderinfo[gamemap-1]->nextlevel;
|
||||
|
||||
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;
|
||||
}
|
||||
else
|
||||
return newmapnum;
|
||||
|
||||
return newmapnum;
|
||||
}
|
||||
}
|
||||
else if (mapnamelen == 2)/* maybe two digit code */
|
||||
|
||||
+2
-1
@@ -72,6 +72,8 @@ extern consvar_t cv_custom3axis[MAXSPLITSCREENPLAYERS];
|
||||
extern consvar_t cv_xdeadzone[MAXSPLITSCREENPLAYERS];
|
||||
extern consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS];
|
||||
|
||||
extern consvar_t cv_litesteer[MAXSPLITSCREENPLAYERS];
|
||||
|
||||
extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_guest, cv_ghost_staff;
|
||||
|
||||
// Hud offsets
|
||||
@@ -153,7 +155,6 @@ typedef enum
|
||||
// mouseaiming (looking up/down with the mouse or keyboard)
|
||||
#define KB_LOOKSPEED (1<<25)
|
||||
#define MAXPLMOVE (50)
|
||||
#define SLOWTURNTICS (cv_turnsmooth.value * 3)
|
||||
|
||||
// build an internal map name MAPxx from map number
|
||||
const char *G_BuildMapName(INT32 map);
|
||||
|
||||
+11
-7
@@ -37,7 +37,13 @@ static CV_PossibleValue_t turnsmooth_cons_t[] = {{2, "Slow"}, {1, "Fast"}, {0, "
|
||||
consvar_t cv_mousesens = {"mousesens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_turnsmooth = {"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS] = {
|
||||
{"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"turnsmoothing2", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"turnsmoothing3", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL},
|
||||
{"turnsmoothing4", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}
|
||||
};
|
||||
|
||||
static void G_ResetPlayerDeviceRumble(INT32 player);
|
||||
static void rumble_off_handle(void);
|
||||
@@ -256,9 +262,6 @@ void G_ResetControls(void)
|
||||
|
||||
memset(joyxmove, 0, sizeof(joyxmove));
|
||||
memset(joyymove, 0, sizeof(joyymove));
|
||||
|
||||
// reset those just in case the game missed the keyup event
|
||||
memset(dpadscrollstate, false, sizeof(dpadscrollstate));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1027,7 +1030,7 @@ INT32 G_KeyStringtoNum(const char *keystr)
|
||||
return atoi(&keystr[3]);
|
||||
|
||||
for (j = 0; j < NUMKEYNAMES; j++)
|
||||
if (!stricmp(keynames[j].name, keystr))
|
||||
if (fasticmp(keynames[j].name, keystr))
|
||||
return keynames[j].keynum;
|
||||
|
||||
return 0;
|
||||
@@ -1327,14 +1330,15 @@ static void setcontrol(INT32 (*gc)[2])
|
||||
player = 0;
|
||||
|
||||
namectrl = COM_Argv(1);
|
||||
for (numctrl = 0; numctrl < num_gamecontrols && stricmp(namectrl, gamecontrolname[numctrl]);
|
||||
numctrl++)
|
||||
for (numctrl = 0; numctrl < num_gamecontrols && !fasticmp(namectrl, gamecontrolname[numctrl]); numctrl++)
|
||||
;
|
||||
|
||||
if (numctrl == num_gamecontrols)
|
||||
{
|
||||
CONS_Printf(M_GetText("Control '%s' unknown\n"), namectrl);
|
||||
return;
|
||||
}
|
||||
|
||||
keynum1 = G_KeyStringtoNum(COM_Argv(2));
|
||||
keynum2 = G_KeyStringtoNum(COM_Argv(3));
|
||||
keynum = G_FilterKeyByVersion(numctrl, 0, player, &keynum1, &keynum2, &nestedoverride);
|
||||
|
||||
+3
-2
@@ -37,7 +37,7 @@ typedef enum
|
||||
KEY_JOY1 = KEY_MOUSE1 + MOUSEBUTTONS,
|
||||
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_DBLHAT1 = KEY_DBLJOY1 + JOYBUTTONS,
|
||||
|
||||
@@ -110,7 +110,8 @@ typedef enum
|
||||
|
||||
// mouse values are used once
|
||||
extern consvar_t cv_mousesens, cv_mouseysens;
|
||||
extern consvar_t cv_controlperkey, cv_turnsmooth;
|
||||
extern consvar_t cv_controlperkey;
|
||||
extern consvar_t cv_turnsmooth[MAXSPLITSCREENPLAYERS];
|
||||
extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS];
|
||||
extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
|
||||
|
||||
|
||||
+1
-104
@@ -80,14 +80,6 @@ static poly_t *HWR_AllocPoly(INT32 numpts)
|
||||
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,
|
||||
/// for now don't free because it doesn't free in reverse order
|
||||
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]);
|
||||
|
||||
// copy child bbox
|
||||
M_Memcpy(bbox, bsp->bbox[0], 4*sizeof (fixed_t));
|
||||
memcpy(bbox, bsp->bbox[0], 4*sizeof (fixed_t));
|
||||
}
|
||||
else
|
||||
I_Error("WalkBSPNode: no front poly?");
|
||||
@@ -855,100 +847,6 @@ static INT32 SolveTProblem(void)
|
||||
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,
|
||||
// and it will generate all the convex polys for the hardware renderer
|
||||
@@ -1017,7 +915,6 @@ void HWR_CreatePlanePolygons(INT32 bspnum)
|
||||
#else
|
||||
SolveTProblem();
|
||||
#endif
|
||||
AdjustSegs();
|
||||
|
||||
#ifdef DEBUG_HWBSP
|
||||
//debug debug..
|
||||
|
||||
+39
-25
@@ -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->source = colormap;
|
||||
M_Memcpy(gltex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8));
|
||||
memcpy(gltex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8));
|
||||
|
||||
blockwidth = texture->width;
|
||||
blockheight = texture->height;
|
||||
@@ -437,8 +437,16 @@ void HWR_MakePatch(const patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipma
|
||||
// CACHING HANDLING
|
||||
// =================================================
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GLMapTexture_t normal;
|
||||
#ifdef GLENCORE
|
||||
GLMapTexture_t encore;
|
||||
#endif
|
||||
} GLMapTextureSet_t; // idk i suck at naming things
|
||||
|
||||
static size_t gl_numtextures = 0; // Texture count
|
||||
static GLMapTexture_t *gl_textures; // For all textures
|
||||
static GLMapTextureSet_t *gl_textures; // For all textures
|
||||
|
||||
static void HWR_FreeTextureData(patch_t *patch)
|
||||
{
|
||||
@@ -578,13 +586,12 @@ void HWR_FreeMapTextures(void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
#ifdef GLENCORE
|
||||
for (i = 0; i < gl_numtextures*2; i++)
|
||||
#else
|
||||
for (i = 0; i < gl_numtextures; i++)
|
||||
#endif
|
||||
{
|
||||
FreeMapTexture(&gl_textures[i]);
|
||||
FreeMapTexture(&gl_textures[i].normal);
|
||||
#ifdef GLENCORE
|
||||
FreeMapTexture(&gl_textures[i].encore);
|
||||
#endif
|
||||
}
|
||||
|
||||
// now the heap don't have any 'user' pointing to our
|
||||
@@ -603,7 +610,7 @@ static void HWR_PrecacheLevelFlats(void)
|
||||
|
||||
// special case for encore
|
||||
#ifdef GLENCORE
|
||||
if (encoremode)
|
||||
if (encoremap)
|
||||
{
|
||||
// go through all sectors to determine if it should be remapped for encore
|
||||
for (i = 0; i < numsectors; i++)
|
||||
@@ -678,8 +685,6 @@ static void HWR_PrecacheLevelTextures(void)
|
||||
const line_t *line = &lines[i];
|
||||
#ifdef GLENCORE
|
||||
const int noencoremap = ((encoremap && (line->flags & ML_TFERLINE)) ? 2 : 1);
|
||||
#else
|
||||
const int noencoremap = 1;
|
||||
#endif
|
||||
// two sides
|
||||
for (j = 0; j < 2; j++)
|
||||
@@ -695,11 +700,14 @@ static void HWR_PrecacheLevelTextures(void)
|
||||
for (f = 0; f < 3; f++)
|
||||
{
|
||||
const INT32 texnum = sidetex[f];
|
||||
|
||||
if (texnum < 0 || texnum >= numtextures || texturepresent[texnum])
|
||||
continue;
|
||||
|
||||
#ifdef GLENCORE
|
||||
texturepresent[texnum] = 1|noencoremap;
|
||||
|
||||
#else
|
||||
texturepresent[texnum] = 1;
|
||||
#endif
|
||||
HWR_GetTexture(texnum, false);
|
||||
#ifdef GLENCORE
|
||||
if (noencoremap & 2)
|
||||
@@ -737,7 +745,7 @@ static void HWR_PrecacheLevelTextures(void)
|
||||
free(texturepresent);
|
||||
}
|
||||
|
||||
static void HWR_PrecacheLevelSprites(void)
|
||||
/*static void HWR_PrecacheLevelSprites(void)
|
||||
{
|
||||
patch_t *spritepatch;
|
||||
char *spritepresent;
|
||||
@@ -800,21 +808,30 @@ static void HWR_PrecacheLevelSprites(void)
|
||||
}
|
||||
}
|
||||
free(spritepresent);
|
||||
}
|
||||
}*/
|
||||
|
||||
void HWR_PrecacheLevel(void)
|
||||
{
|
||||
if (rendermode != render_opengl)
|
||||
if (gamestate != GS_LEVEL || !cv_precachetextures.value)
|
||||
return;
|
||||
|
||||
// Precache flats.
|
||||
HWR_PrecacheLevelFlats();
|
||||
|
||||
// prevent timeouts
|
||||
NetKeepAlive();
|
||||
|
||||
// Precache textures.
|
||||
HWR_PrecacheLevelTextures();
|
||||
|
||||
// prevent timeouts
|
||||
NetKeepAlive();
|
||||
|
||||
// Precache sprites.
|
||||
HWR_PrecacheLevelSprites();
|
||||
//HWR_PrecacheLevelSprites();
|
||||
|
||||
// prevent timeouts
|
||||
//NetKeepAlive();
|
||||
}
|
||||
|
||||
void HWR_LoadMapTextures(size_t pnumtextures)
|
||||
@@ -823,11 +840,8 @@ void HWR_LoadMapTextures(size_t pnumtextures)
|
||||
HWR_FreeMapTextures();
|
||||
|
||||
gl_numtextures = pnumtextures;
|
||||
#ifdef GLENCORE
|
||||
gl_textures = calloc(gl_numtextures, sizeof (*gl_textures)*2); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore)
|
||||
#else
|
||||
gl_textures = calloc(gl_numtextures, sizeof (*gl_textures));
|
||||
#endif
|
||||
gl_textures = calloc(gl_numtextures, sizeof(*gl_textures)); // *2 - 1 for encore-remapped texture and another for noencore texture (unused when not in encore), see: GLMapTextureSet_t
|
||||
|
||||
if (gl_textures == NULL)
|
||||
I_Error("HWR_LoadMapTextures: ran out of memory for OpenGL textures. Sad!");
|
||||
}
|
||||
@@ -851,7 +865,7 @@ GLMapTexture_t *HWR_GetTexture(INT32 tex, boolean noencore)
|
||||
// Every texture in memory, stored in the
|
||||
// hardware renderer's bit depth format. Wow!
|
||||
#ifdef GLENCORE
|
||||
gltex = &gl_textures[tex*2 + (encoremap && !noencore ? 0 : 1)];
|
||||
gltex = (encoremap && !noencore) ? &gl_textures[tex].encore : &gl_textures[tex].normal;
|
||||
#else
|
||||
gltex = &gl_textures[tex];
|
||||
#endif
|
||||
@@ -965,7 +979,7 @@ void HWR_GetFlat(lumpnum_t flatlumpnum, boolean noencoremap)
|
||||
#endif
|
||||
glMipmap->colormap = Z_Calloc(sizeof(*glMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
|
||||
glMipmap->colormap->source = colormap;
|
||||
M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
|
||||
memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
|
||||
}
|
||||
|
||||
if (!glMipmap->downloaded)
|
||||
@@ -1063,7 +1077,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
|
||||
{
|
||||
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);
|
||||
}
|
||||
else
|
||||
@@ -1086,7 +1100,7 @@ void HWR_GetMappedPatch(patch_t *patch, const UINT8 *colormap)
|
||||
|
||||
newMipmap->colormap = Z_Calloc(sizeof(*newMipmap->colormap), PU_HWRPATCHCOLMIPMAP, NULL);
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -80,14 +80,13 @@
|
||||
|
||||
|
||||
typedef struct clipnode_s
|
||||
{
|
||||
struct clipnode_s *prev, *next;
|
||||
angle_t start, end;
|
||||
} clipnode_t;
|
||||
{
|
||||
struct clipnode_s *prev, *next;
|
||||
angle_t start, end;
|
||||
} clipnode_t;
|
||||
|
||||
clipnode_t *freelist;
|
||||
clipnode_t *clipnodes;
|
||||
clipnode_t *cliphead;
|
||||
static clipnode_t *freelist;
|
||||
static clipnode_t *cliphead;
|
||||
|
||||
static clipnode_t * gld_clipnode_GetNew(void);
|
||||
static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end);
|
||||
|
||||
@@ -117,7 +117,7 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FLOAT x,y,z; // position
|
||||
FLOAT x, y, z; // position
|
||||
FLOAT anglex, angley, anglez; // aimingangle / viewangle
|
||||
FLOAT scalex, scaley, scalez;
|
||||
FLOAT fovangle;
|
||||
|
||||
+30
-223
@@ -31,11 +31,6 @@
|
||||
#include "../st_stuff.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include "../i_video.h" // for rendermode != render_glide
|
||||
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -51,75 +46,13 @@ typedef struct
|
||||
UINT8 image_descriptor; //18
|
||||
} ATTRPACK TGAHeader; // sizeof is 18
|
||||
|
||||
static UINT8 softwaretranstogl[11] = { 0, 25, 51, 76,102,127,153,178,204,229,255};
|
||||
static UINT8 softwaretranstogl_hi[11] = { 0, 51,102,153,204,255,255,255,255,255,255};
|
||||
static UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111,127};
|
||||
static const UINT8 softwaretranstogl[11] = { 0, 25, 51, 76,102,127,153,178,204,229,255};
|
||||
static const UINT8 softwaretranstogl_hi[11] = { 0, 51,102,153,204,255,255,255,255,255,255};
|
||||
static const UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111,127};
|
||||
|
||||
static const float FLOATBASEVIDWIDTH = (float)BASEVIDWIDTH;
|
||||
static const float FLOATBASEVIDHEIGHT = (float)BASEVIDHEIGHT;
|
||||
|
||||
//
|
||||
// -----------------+
|
||||
// HWR_DrawPatch : Draw a 'tile' graphic
|
||||
// Notes : x,y : positions relative to the original Doom resolution
|
||||
// : textes(console+score) + menus + status bar
|
||||
// -----------------+
|
||||
void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option)
|
||||
{
|
||||
FOutVector v[4];
|
||||
FBITFIELD flags;
|
||||
GLPatch_t *hwrPatch;
|
||||
|
||||
// 3--2
|
||||
// | /|
|
||||
// |/ |
|
||||
// 0--1
|
||||
float sdup = FIXED_TO_FLOAT(vid.fdup)*2.0f;
|
||||
float pdup = FIXED_TO_FLOAT(vid.fdup)*2.0f;
|
||||
|
||||
// make patch ready in hardware cache
|
||||
HWR_GetPatch(gpatch);
|
||||
hwrPatch = ((GLPatch_t *)gpatch->hardware);
|
||||
|
||||
switch (option & V_SCALEPATCHMASK)
|
||||
{
|
||||
case V_NOSCALEPATCH:
|
||||
pdup = 2.0f;
|
||||
break;
|
||||
case V_SMALLSCALEPATCH:
|
||||
pdup = 2.0f * FIXED_TO_FLOAT(vid.smalldup*FRACUNIT);
|
||||
break;
|
||||
case V_MEDSCALEPATCH:
|
||||
pdup = 2.0f * FIXED_TO_FLOAT(vid.meddup*FRACUNIT);
|
||||
break;
|
||||
}
|
||||
|
||||
if (option & V_NOSCALESTART)
|
||||
sdup = 2.0f;
|
||||
|
||||
v[0].x = v[3].x = (x*sdup-gpatch->leftoffset*pdup)/vid.width - 1;
|
||||
v[2].x = v[1].x = (x*sdup+(gpatch->width - gpatch->leftoffset)*pdup)/vid.width - 1;
|
||||
v[0].y = v[1].y = 1-(y*sdup-gpatch->topoffset*pdup)/vid.height;
|
||||
v[2].y = v[3].y = 1-(y*sdup+(gpatch->height - gpatch->topoffset)*pdup)/vid.height;
|
||||
|
||||
v[0].z = v[1].z = v[2].z = v[3].z = 1.0f;
|
||||
|
||||
v[0].s = v[3].s = 0.0f;
|
||||
v[2].s = v[1].s = hwrPatch->max_s;
|
||||
v[0].t = v[1].t = 0.0f;
|
||||
v[2].t = v[3].t = hwrPatch->max_t;
|
||||
|
||||
flags = PF_Translucent|PF_NoDepthTest;
|
||||
|
||||
if (option & V_WRAPX)
|
||||
flags |= PF_ForceWrapX;
|
||||
if (option & V_WRAPY)
|
||||
flags |= PF_ForceWrapY;
|
||||
|
||||
// clip it since it is used for bunny scroll in doom I
|
||||
GL_DrawPolygon(NULL, v, 4, flags);
|
||||
}
|
||||
|
||||
void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags)
|
||||
{
|
||||
FOutVector v[4];
|
||||
@@ -154,15 +87,15 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p
|
||||
|
||||
switch (option & V_SCALEPATCHMASK)
|
||||
{
|
||||
case V_NOSCALEPATCH:
|
||||
dup = 1.0f;
|
||||
break;
|
||||
case V_SMALLSCALEPATCH:
|
||||
dup = (float)vid.smalldup;
|
||||
break;
|
||||
case V_MEDSCALEPATCH:
|
||||
dup = (float)vid.meddup;
|
||||
break;
|
||||
case V_NOSCALEPATCH:
|
||||
dup = 1.0f;
|
||||
break;
|
||||
case V_SMALLSCALEPATCH:
|
||||
dup = (float)vid.smalldup;
|
||||
break;
|
||||
case V_MEDSCALEPATCH:
|
||||
dup = (float)vid.meddup;
|
||||
break;
|
||||
}
|
||||
|
||||
fscalew = fscaleh = FIXED_TO_FLOAT(pscale);
|
||||
@@ -336,15 +269,15 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
||||
|
||||
switch (option & V_SCALEPATCHMASK)
|
||||
{
|
||||
case V_NOSCALEPATCH:
|
||||
dup = 1.0f;
|
||||
break;
|
||||
case V_SMALLSCALEPATCH:
|
||||
dup = (float)vid.smalldup;
|
||||
break;
|
||||
case V_MEDSCALEPATCH:
|
||||
dup = (float)vid.meddup;
|
||||
break;
|
||||
case V_NOSCALEPATCH:
|
||||
dup = 1.0f;
|
||||
break;
|
||||
case V_SMALLSCALEPATCH:
|
||||
dup = (float)vid.smalldup;
|
||||
break;
|
||||
case V_MEDSCALEPATCH:
|
||||
dup = (float)vid.meddup;
|
||||
break;
|
||||
}
|
||||
|
||||
fscale = FIXED_TO_FLOAT(pscale);
|
||||
@@ -573,7 +506,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
|
||||
|
||||
if (color & 0xFF00) // Do COLORMAP fade.
|
||||
{
|
||||
if (HWR_ShouldUsePaletteRendering() && cv_glscreentextures.value)
|
||||
if (cv_glscreentextures.value && HWR_ShouldUsePaletteRendering())
|
||||
{
|
||||
const hwdscreentexture_t scr_tex = HWD_SCREENTEXTURE_GENERIC2;
|
||||
|
||||
@@ -585,12 +518,10 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
|
||||
GL_UnSetShader();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Surf.PolyColor.rgba = UINT2RGBA(0x01010160);
|
||||
Surf.PolyColor.s.alpha = (strength*8);
|
||||
poly_flags |= PF_Translucent;
|
||||
}
|
||||
|
||||
Surf.PolyColor.rgba = UINT2RGBA(0x01010160);
|
||||
Surf.PolyColor.s.alpha = (strength*8);
|
||||
poly_flags |= PF_Translucent;
|
||||
}
|
||||
else // Do TRANSMAP** fade.
|
||||
{
|
||||
@@ -636,133 +567,6 @@ void HWR_DrawConsoleBack(UINT32 color, INT32 height)
|
||||
}
|
||||
|
||||
|
||||
// ==========================================================================
|
||||
// R_DRAW.C STUFF
|
||||
// ==========================================================================
|
||||
|
||||
// ------------------
|
||||
// HWR_DrawViewBorder
|
||||
// Fill the space around the view window with a Doom flat texture, draw the
|
||||
// beveled edges.
|
||||
// 'clearlines' is useful to clear the heads up messages, when the view
|
||||
// window is reduced, it doesn't refresh all the view borders.
|
||||
// ------------------
|
||||
void HWR_DrawViewBorder(INT32 clearlines)
|
||||
{
|
||||
INT32 x, y;
|
||||
INT32 top, side;
|
||||
INT32 baseviewwidth, baseviewheight;
|
||||
INT32 basewindowx, basewindowy;
|
||||
patch_t *patch;
|
||||
|
||||
if (!clearlines)
|
||||
clearlines = BASEVIDHEIGHT; // refresh all
|
||||
|
||||
// calc view size based on original game resolution
|
||||
baseviewwidth = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewwidth), vid.fdup)); //(cv_viewsize.value * BASEVIDWIDTH/10)&~7;
|
||||
baseviewheight = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_viewheight), vid.fdup));
|
||||
top = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_baseviewwindowy), vid.fdup));
|
||||
side = FixedInt(FixedDiv(FLOAT_TO_FIXED(gl_baseviewwindowx), vid.fdup));
|
||||
|
||||
// top
|
||||
HWR_DrawFlatFill(0, 0,
|
||||
BASEVIDWIDTH, (top < clearlines ? top : clearlines),
|
||||
st_borderpatchnum);
|
||||
|
||||
// left
|
||||
if (top < clearlines)
|
||||
HWR_DrawFlatFill(0, top, side,
|
||||
(clearlines-top < baseviewheight ? clearlines-top : baseviewheight),
|
||||
st_borderpatchnum);
|
||||
|
||||
// right
|
||||
if (top < clearlines)
|
||||
HWR_DrawFlatFill(side + baseviewwidth, top, side,
|
||||
(clearlines-top < baseviewheight ? clearlines-top : baseviewheight),
|
||||
st_borderpatchnum);
|
||||
|
||||
// bottom
|
||||
if (top + baseviewheight < clearlines)
|
||||
HWR_DrawFlatFill(0, top + baseviewheight,
|
||||
BASEVIDWIDTH, BASEVIDHEIGHT, st_borderpatchnum);
|
||||
|
||||
//
|
||||
// draw the view borders
|
||||
//
|
||||
|
||||
basewindowx = (BASEVIDWIDTH - baseviewwidth)>>1;
|
||||
if (baseviewwidth == BASEVIDWIDTH)
|
||||
basewindowy = 0;
|
||||
else
|
||||
basewindowy = top;
|
||||
|
||||
// top edge
|
||||
if (clearlines > basewindowy - 8)
|
||||
{
|
||||
patch = W_CachePatchNum(viewborderlump[BRDR_T], PU_PATCH);
|
||||
for (x = 0; x < baseviewwidth; x += 8)
|
||||
HWR_DrawPatch(patch, basewindowx + x, basewindowy - 8,
|
||||
0);
|
||||
}
|
||||
|
||||
// bottom edge
|
||||
if (clearlines > basewindowy + baseviewheight)
|
||||
{
|
||||
patch = W_CachePatchNum(viewborderlump[BRDR_B], PU_PATCH);
|
||||
for (x = 0; x < baseviewwidth; x += 8)
|
||||
HWR_DrawPatch(patch, basewindowx + x,
|
||||
basewindowy + baseviewheight, 0);
|
||||
}
|
||||
|
||||
// left edge
|
||||
if (clearlines > basewindowy)
|
||||
{
|
||||
patch = W_CachePatchNum(viewborderlump[BRDR_L], PU_PATCH);
|
||||
for (y = 0; y < baseviewheight && basewindowy + y < clearlines;
|
||||
y += 8)
|
||||
{
|
||||
HWR_DrawPatch(patch, basewindowx - 8, basewindowy + y,
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
// right edge
|
||||
if (clearlines > basewindowy)
|
||||
{
|
||||
patch = W_CachePatchNum(viewborderlump[BRDR_R], PU_PATCH);
|
||||
for (y = 0; y < baseviewheight && basewindowy+y < clearlines;
|
||||
y += 8)
|
||||
{
|
||||
HWR_DrawPatch(patch, basewindowx + baseviewwidth,
|
||||
basewindowy + y, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw beveled corners.
|
||||
if (clearlines > basewindowy - 8)
|
||||
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TL],
|
||||
PU_PATCH),
|
||||
basewindowx - 8, basewindowy - 8, 0);
|
||||
|
||||
if (clearlines > basewindowy - 8)
|
||||
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_TR],
|
||||
PU_PATCH),
|
||||
basewindowx + baseviewwidth, basewindowy - 8, 0);
|
||||
|
||||
if (clearlines > basewindowy+baseviewheight)
|
||||
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BL],
|
||||
PU_PATCH),
|
||||
basewindowx - 8, basewindowy + baseviewheight, 0);
|
||||
|
||||
if (clearlines > basewindowy + baseviewheight)
|
||||
HWR_DrawPatch(W_CachePatchNum(viewborderlump[BRDR_BR],
|
||||
PU_PATCH),
|
||||
basewindowx + baseviewwidth,
|
||||
basewindowy + baseviewheight, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ==========================================================================
|
||||
// AM_MAP.C DRAWING STUFF
|
||||
// ==========================================================================
|
||||
@@ -1084,11 +888,13 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
|
||||
|
||||
if (fx >= vid.width || fy >= vid.height)
|
||||
return;
|
||||
|
||||
if (fx < 0)
|
||||
{
|
||||
fw += fx;
|
||||
fx = 0;
|
||||
}
|
||||
|
||||
if (fy < 0)
|
||||
{
|
||||
fh += fy;
|
||||
@@ -1100,6 +906,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
|
||||
|
||||
if (fx + fw > vid.width)
|
||||
fw = fvw - fx;
|
||||
|
||||
if (fy + fh > vid.height)
|
||||
fh = fvh - fy;
|
||||
|
||||
@@ -1168,7 +975,7 @@ static inline boolean saveTGA(const char *file_name, void *buffer,
|
||||
INT32 i;
|
||||
UINT8 *buf8 = buffer;
|
||||
|
||||
fd = open(file_name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
|
||||
fd = open(file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
if (fd < 0)
|
||||
return false;
|
||||
|
||||
|
||||
+93
-178
@@ -65,8 +65,6 @@
|
||||
// Globals
|
||||
// ==========================================================================
|
||||
|
||||
#define ABS(x) ((x) < 0 ? -(x) : (x))
|
||||
|
||||
// false if shaders have not been initialized yet, or if shaders are not available
|
||||
boolean gl_shadersavailable = false;
|
||||
|
||||
@@ -77,24 +75,19 @@ boolean gl_drawing_stencil = false;
|
||||
|
||||
static INT32 current_bsp_culling_distance = 0;
|
||||
|
||||
// base values set at SetViewSize
|
||||
float gl_baseviewwindowy, gl_baseviewwindowx;
|
||||
static float gl_viewwindowy, gl_viewwindowx; // top left corner of view window
|
||||
float gl_viewwidth, gl_viewheight; // viewport clipping boundaries (screen coords)
|
||||
|
||||
FTransform atransform;
|
||||
FTransform atransform = {};
|
||||
|
||||
// Float variants of viewx, viewy, viewz, etc.
|
||||
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 angle_t gl_aimingangle;
|
||||
|
||||
seg_t *gl_curline;
|
||||
side_t *gl_sidedef;
|
||||
line_t *gl_linedef;
|
||||
sector_t *gl_frontsector;
|
||||
sector_t *gl_backsector;
|
||||
seg_t *gl_curline = NULL;
|
||||
side_t *gl_sidedef = NULL;
|
||||
line_t *gl_linedef = NULL;
|
||||
sector_t *gl_frontsector = NULL;
|
||||
sector_t *gl_backsector = NULL;
|
||||
|
||||
// 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};
|
||||
@@ -284,6 +277,7 @@ static void CV_glshaders_OnChange(void)
|
||||
{
|
||||
// can't do palette rendering without shaders, so update the state if needed
|
||||
HWR_TogglePaletteRendering();
|
||||
HWR_PrecacheLevel();
|
||||
}
|
||||
M_UpdateOGLMenu();
|
||||
}
|
||||
@@ -301,18 +295,21 @@ static void CV_gltextureformat_OnChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
GL_SetSpecialState(HWD_SET_TEXTURE_FORMAT, cv_gltexturedepth.value);
|
||||
HWR_PrecacheLevel();
|
||||
}
|
||||
|
||||
static void CV_filtermode_OnChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
GL_SetSpecialState(HWD_SET_TEXTUREFILTERMODE, cv_glfiltermode.value);
|
||||
HWR_PrecacheLevel();
|
||||
}
|
||||
|
||||
static void CV_anisotropic_OnChange(void)
|
||||
{
|
||||
ONLY_IF_GL_LOADED
|
||||
GL_SetSpecialState(HWD_SET_TEXTUREANISOTROPICMODE, cv_glanisotropicmode.value);
|
||||
HWR_PrecacheLevel();
|
||||
}
|
||||
|
||||
static void CV_glpaletterendering_OnChange(void)
|
||||
@@ -325,7 +322,9 @@ static void CV_glpaletterendering_OnChange(void)
|
||||
{
|
||||
HWR_CompileShaders();
|
||||
HWR_TogglePaletteRendering();
|
||||
HWR_PrecacheLevel();
|
||||
}
|
||||
|
||||
M_UpdateOGLMenu();
|
||||
}
|
||||
|
||||
@@ -459,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
|
||||
if (!HWR_ShouldUsePaletteRendering())
|
||||
{
|
||||
V_CubeApply(&tint_color.s.red, &tint_color.s.green, &tint_color.s.blue);
|
||||
V_CubeApply(&fade_color.s.red, &fade_color.s.green, &fade_color.s.blue);
|
||||
V_CubeApply(&tint_color);
|
||||
V_CubeApply(&fade_color);
|
||||
}
|
||||
|
||||
Surface->PolyColor.rgba = poly_color.rgba;
|
||||
@@ -729,6 +728,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
||||
|
||||
for (i = 0; i < subsector->numlines; i++, line++)
|
||||
{
|
||||
if (line->polyseg)
|
||||
continue;
|
||||
|
||||
line_t* ld = line->linedef;
|
||||
|
||||
// this check sucks and is a hotspot lel
|
||||
@@ -741,27 +743,11 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
|
||||
P_ClosestPointOnLine(viewx, viewy, ld, &v);
|
||||
dist = FixedToFloat(R_PointToDist(v.x, v.y));
|
||||
|
||||
if (line->pv1)
|
||||
{
|
||||
x1 = line->pv1->x;
|
||||
y1 = line->pv1->y;
|
||||
}
|
||||
else
|
||||
{
|
||||
x1 = FixedToFloat(line->v1->x);
|
||||
y1 = FixedToFloat(line->v1->y);
|
||||
}
|
||||
x1 = (line->fv1.x);
|
||||
y1 = (line->fv1.y);
|
||||
|
||||
if (line->pv2)
|
||||
{
|
||||
xd = line->pv2->x - x1;
|
||||
yd = line->pv2->y - y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
xd = FixedToFloat(line->v2->x) - x1;
|
||||
yd = FixedToFloat(line->v2->y) - y1;
|
||||
}
|
||||
xd = (line->fv2.x) - x1;
|
||||
yd = (line->fv2.y) - y1;
|
||||
|
||||
// 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;
|
||||
@@ -825,11 +811,11 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf)
|
||||
|
||||
M_ClearBox(segbbox);
|
||||
M_AddToBox(segbbox,
|
||||
FloatToFixed(gl_curline->pv1->x),
|
||||
FloatToFixed(gl_curline->pv1->y));
|
||||
FloatToFixed(gl_curline->fv1.x),
|
||||
FloatToFixed(gl_curline->fv1.y));
|
||||
M_AddToBox(segbbox,
|
||||
FloatToFixed(gl_curline->pv2->x),
|
||||
FloatToFixed(gl_curline->pv2->y));
|
||||
FloatToFixed(gl_curline->fv2.x),
|
||||
FloatToFixed(gl_curline->fv2.y));
|
||||
|
||||
splat = (wallsplat_t *)gl_curline->linedef->splats;
|
||||
for (; splat; splat = splat->next)
|
||||
@@ -1238,7 +1224,7 @@ static void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf)
|
||||
// Returns true if the midtexture is visible, and false if... it isn't...
|
||||
static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf)
|
||||
{
|
||||
FUINT blendmode = PF_Masked;
|
||||
FUINT blendmode = PF_Masked | PF_Translucent;
|
||||
|
||||
pSurf->PolyColor.s.alpha = 0xFF;
|
||||
|
||||
@@ -1260,8 +1246,6 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf)
|
||||
case 256:
|
||||
if (gl_linedef->blendmode)
|
||||
blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf);
|
||||
else
|
||||
blendmode = PF_Translucent;
|
||||
break;
|
||||
default:
|
||||
if (gl_linedef->blendmode)
|
||||
@@ -1273,8 +1257,6 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf)
|
||||
}
|
||||
else if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT)
|
||||
blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), pSurf);
|
||||
else
|
||||
blendmode = PF_Masked;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1324,34 +1306,24 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
|
||||
const boolean noencore = (gl_linedef->flags & ML_TFERLINE);
|
||||
|
||||
if (LIKELY(gl_curline->pv1))
|
||||
{
|
||||
vs.x = gl_curline->pv1->x;
|
||||
vs.y = gl_curline->pv1->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;
|
||||
}
|
||||
v1x = gl_curline->v1->x;
|
||||
v1y = gl_curline->v1->y;
|
||||
v2x = gl_curline->v2->x;
|
||||
v2y = gl_curline->v2->y;
|
||||
|
||||
if (LIKELY(gl_curline->pv2))
|
||||
if (gl_curline->polyseg)
|
||||
{
|
||||
ve.x = gl_curline->pv2->x;
|
||||
ve.y = gl_curline->pv2->y;
|
||||
v2x = gl_curline->pv2->x2;
|
||||
v2y = gl_curline->pv2->y2;
|
||||
vs.x = FixedToFloat(v1x);
|
||||
vs.y = FixedToFloat(v1y);
|
||||
ve.x = FixedToFloat(v2x);
|
||||
ve.y = FixedToFloat(v2y);
|
||||
}
|
||||
else
|
||||
{
|
||||
ve.x = FixedToFloat(gl_curline->v2->x);
|
||||
ve.y = FixedToFloat(gl_curline->v2->y);
|
||||
v2x = gl_curline->v2->x;
|
||||
v2y = gl_curline->v2->y;
|
||||
vs.x = gl_curline->fv1.x;
|
||||
vs.y = gl_curline->fv1.y;
|
||||
ve.x = gl_curline->fv2.x;
|
||||
ve.y = gl_curline->fv2.y;
|
||||
}
|
||||
|
||||
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
|
||||
@@ -2203,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
|
||||
|
||||
if (LIKELY(gl_curline->pv1))
|
||||
{
|
||||
v1x = gl_curline->pv1->x2;
|
||||
v1y = gl_curline->pv1->y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
v1x = gl_curline->v1->x;
|
||||
v1y = gl_curline->v1->y;
|
||||
}
|
||||
v1x = gl_curline->v1->x;
|
||||
v1y = gl_curline->v1->y;
|
||||
|
||||
if (LIKELY(gl_curline->pv2))
|
||||
{
|
||||
v2x = gl_curline->pv2->x2;
|
||||
v2y = gl_curline->pv2->y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
v2x = gl_curline->v2->x;
|
||||
v2y = gl_curline->v2->y;
|
||||
}
|
||||
v2x = gl_curline->v2->x;
|
||||
v2y = gl_curline->v2->y;
|
||||
|
||||
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
|
||||
end1 = P_GetZAt(slope, v1x, v1y, normalheight); \
|
||||
@@ -2428,27 +2384,11 @@ static void HWR_AddLine(seg_t *line)
|
||||
|
||||
gl_curline = line;
|
||||
|
||||
if (LIKELY(gl_curline->pv1))
|
||||
{
|
||||
v1x = gl_curline->pv1->x2;
|
||||
v1y = gl_curline->pv1->y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
v1x = gl_curline->v1->x;
|
||||
v1y = gl_curline->v1->y;
|
||||
}
|
||||
v1x = gl_curline->v1->x;
|
||||
v1y = gl_curline->v1->y;
|
||||
|
||||
if (LIKELY(gl_curline->pv2))
|
||||
{
|
||||
v2x = gl_curline->pv2->x2;
|
||||
v2y = gl_curline->pv2->y2;
|
||||
}
|
||||
else
|
||||
{
|
||||
v2x = gl_curline->v2->x;
|
||||
v2y = gl_curline->v2->y;
|
||||
}
|
||||
v2x = gl_curline->v2->x;
|
||||
v2y = gl_curline->v2->y;
|
||||
|
||||
// OPTIMIZE: quickly reject orthogonal back sides.
|
||||
angle1 = R_PointToAngle64(v1x, v1y);
|
||||
@@ -3377,6 +3317,9 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
|
||||
fixed_t slopez;
|
||||
float offset = 0;
|
||||
|
||||
if (!spr->mobj)
|
||||
return;
|
||||
|
||||
R_GetShadowZ(spr->mobj, &floorslope);
|
||||
|
||||
mobjfloor = HWR_OpaqueFloorAtPos(
|
||||
@@ -3388,14 +3331,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
|
||||
angle_t shadowdir;
|
||||
|
||||
// Set direction
|
||||
if (splitscreen && R_GetViewNumber() == 1)
|
||||
shadowdir = localangle[1] + FixedAngle(cv_cam_rotate[1].value);
|
||||
else if (splitscreen > 1 && R_GetViewNumber() == 2)
|
||||
shadowdir = localangle[2] + FixedAngle(cv_cam_rotate[2].value);
|
||||
else if (splitscreen > 2 && R_GetViewNumber() == 3)
|
||||
shadowdir = localangle[3] + FixedAngle(cv_cam_rotate[3].value);
|
||||
else
|
||||
shadowdir = localangle[0] + FixedAngle(cv_cam_rotate[0].value);
|
||||
shadowdir = localangle[viewssnum] + FixedAngle(cv_cam_rotate[viewssnum].value);
|
||||
|
||||
// Find floorheight
|
||||
floorheight = HWR_OpaqueFloorAtPos(
|
||||
@@ -3407,18 +3343,17 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
|
||||
// Don't draw it, then!
|
||||
if (spr->mobj->z < floorheight)
|
||||
return;
|
||||
else
|
||||
{
|
||||
fixed_t floorz;
|
||||
floorz = HWR_OpaqueFloorAtPos(
|
||||
spr->mobj->x + P_ReturnThrustX(spr->mobj, shadowdir, spr->mobj->z - floorheight),
|
||||
spr->mobj->y + P_ReturnThrustY(spr->mobj, shadowdir, spr->mobj->z - floorheight),
|
||||
spr->mobj->z, spr->mobj->height);
|
||||
// The shadow would be falling on a wall? Don't draw it, then.
|
||||
// Would draw midair otherwise.
|
||||
if (floorz < floorheight)
|
||||
return;
|
||||
}
|
||||
|
||||
fixed_t floorz;
|
||||
floorz = HWR_OpaqueFloorAtPos(
|
||||
spr->mobj->x + P_ReturnThrustX(spr->mobj, shadowdir, spr->mobj->z - floorheight),
|
||||
spr->mobj->y + P_ReturnThrustY(spr->mobj, shadowdir, spr->mobj->z - floorheight),
|
||||
spr->mobj->z, spr->mobj->height);
|
||||
|
||||
// The shadow would be falling on a wall? Don't draw it, then.
|
||||
// Would draw midair otherwise.
|
||||
if (floorz < floorheight)
|
||||
return;
|
||||
|
||||
floorheight = FixedInt(spr->mobj->z - floorheight);
|
||||
|
||||
@@ -3428,12 +3363,11 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
|
||||
floorheight = FixedInt(spr->mobj->z - mobjfloor);
|
||||
|
||||
// technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again
|
||||
const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES);
|
||||
this_scale = FixedToFloat(spr->mobj->scale);
|
||||
|
||||
if (spr->mobj)
|
||||
this_scale = FixedToFloat(spr->mobj->scale);
|
||||
if (hires)
|
||||
this_scale = this_scale * FixedToFloat(K_GetMobjSkin(spr->mobj)->highresscale);
|
||||
const skin_t *moskin = K_GetMobjSkin(spr->mobj);
|
||||
if (moskin && moskin->flags & SF_HIRES)
|
||||
this_scale *= FixedToFloat(moskin->highresscale);
|
||||
|
||||
// create the sprite billboard
|
||||
//
|
||||
@@ -3540,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
|
||||
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;
|
||||
}
|
||||
@@ -4054,7 +3988,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
|
||||
|
||||
const precipmobj_t *sprmo = spr->precip;
|
||||
|
||||
if (UNLIKELY(!sprmo || !sprmo->subsector))
|
||||
if (UNLIKELY(!sprmo->subsector))
|
||||
return;
|
||||
|
||||
// cache sprite graphics
|
||||
@@ -4287,8 +4221,8 @@ static void HWR_AddTransparentWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, I
|
||||
{
|
||||
wallinfo_t *wallinfo = static_cast<wallinfo_t*>(HWR_CreateDrawNode(DRAWNODE_WALL));
|
||||
|
||||
M_Memcpy(wallinfo->wallVerts, wallVerts, sizeof (wallinfo->wallVerts));
|
||||
M_Memcpy(&wallinfo->Surf, pSurf, sizeof (FSurfaceInfo));
|
||||
memcpy(wallinfo->wallVerts, wallVerts, sizeof (wallinfo->wallVerts));
|
||||
memcpy(&wallinfo->Surf, pSurf, sizeof (FSurfaceInfo));
|
||||
wallinfo->texnum = texnum;
|
||||
wallinfo->noencore = noencore;
|
||||
wallinfo->blend = blend;
|
||||
@@ -4335,7 +4269,7 @@ static int CompareDrawNodePlanes(const void *p1, const void *p2)
|
||||
const INT32 n1 = *(const INT32*)p1;
|
||||
const INT32 n2 = *(const INT32*)p2;
|
||||
|
||||
return ABS(drawnodes[n2].u.plane.fixedheight - viewz) - ABS(drawnodes[n1].u.plane.fixedheight - viewz);
|
||||
return abs(drawnodes[n2].u.plane.fixedheight - viewz) - abs(drawnodes[n1].u.plane.fixedheight - viewz);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -5316,10 +5250,10 @@ static void HWR_DrawSkyBackground(void)
|
||||
// -----------------+
|
||||
static inline void HWR_ClearView(void)
|
||||
{
|
||||
GL_GClipRect((INT32)gl_viewwindowx,
|
||||
(INT32)gl_viewwindowy,
|
||||
(INT32)(gl_viewwindowx + gl_viewwidth),
|
||||
(INT32)(gl_viewwindowy + gl_viewheight),
|
||||
GL_GClipRect(viewwindowx,
|
||||
viewwindowy,
|
||||
(viewwindowx + viewwidth),
|
||||
(viewwindowy + viewheight),
|
||||
ZCLIP_PLANE, FAR_ZCLIP_DEFAULT);
|
||||
GL_ClearBuffer(false, true, true, NULL);
|
||||
}
|
||||
@@ -5329,19 +5263,6 @@ static inline void HWR_ClearView(void)
|
||||
// -----------------+
|
||||
void HWR_SetViewSize(void)
|
||||
{
|
||||
// setup view size
|
||||
gl_viewwidth = (float)vid.width;
|
||||
gl_viewheight = (float)vid.height;
|
||||
|
||||
if (splitscreen)
|
||||
gl_viewheight /= 2;
|
||||
|
||||
if (splitscreen > 1)
|
||||
gl_viewwidth /= 2;
|
||||
|
||||
gl_baseviewwindowy = 0;
|
||||
gl_baseviewwindowx = 0;
|
||||
|
||||
GL_FlushScreenTextures();
|
||||
}
|
||||
|
||||
@@ -5352,7 +5273,9 @@ static void HWR_SetTransformAiming(FTransform *trans)
|
||||
if (cv_glshearing.value)
|
||||
{
|
||||
fixed_t fixedaiming = AIMINGTODY(aimingangle);
|
||||
trans->viewaiming = FixedToFloat(fixedaiming);
|
||||
trans->viewaiming = FixedToFloat(fixedaiming) * ((float)vid.width / vid.height) / ((float)BASEVIDWIDTH / BASEVIDHEIGHT);
|
||||
if (splitscreen == 1) // only for 2 player splitscreen
|
||||
trans->viewaiming *= 2.125; // splitscreen adjusts fov with 0.8, so compensate (but only halfway, since splitscreen means only half the screen is used)
|
||||
trans->shearing = true;
|
||||
gl_aimingangle = 0;
|
||||
}
|
||||
@@ -5387,8 +5310,12 @@ void HWR_SetTransform(float fpov)
|
||||
HWR_SetTransformAiming(&atransform);
|
||||
atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(FINEDEGREE);
|
||||
|
||||
gl_viewludsin = FixedToFloat(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT));
|
||||
gl_viewludcos = FixedToFloat(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT));
|
||||
// only needed for sprite billboarding
|
||||
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
|
||||
HWR_RollTransform(&atransform, viewroll);
|
||||
@@ -5404,7 +5331,9 @@ void HWR_SetTransform(float fpov)
|
||||
atransform.fliptype = TRANSFORM_FLIP;
|
||||
}
|
||||
else if (postimg & POSTIMG_MIRROR)
|
||||
{
|
||||
atransform.fliptype = TRANSFORM_MIRROR;
|
||||
}
|
||||
|
||||
// Set transform.
|
||||
GL_SetTransform(&atransform);
|
||||
@@ -5594,20 +5523,6 @@ extern "C" {
|
||||
// ==========================================================================
|
||||
static void HWR_RenderFrame(player_t *player, boolean skybox)
|
||||
{
|
||||
// set window position
|
||||
gl_viewwindowx = gl_baseviewwindowx;
|
||||
gl_viewwindowy = gl_baseviewwindowy;
|
||||
|
||||
if ((splitscreen == 1 && viewssnum == 1) || (splitscreen > 1 && viewssnum > 1))
|
||||
{
|
||||
gl_viewwindowy += gl_viewheight;
|
||||
}
|
||||
|
||||
if (splitscreen > 1 && viewssnum & 1)
|
||||
{
|
||||
gl_viewwindowx += gl_viewwidth;
|
||||
}
|
||||
|
||||
// check for new console commands.
|
||||
NetUpdate();
|
||||
|
||||
@@ -5623,10 +5538,10 @@ static void HWR_RenderFrame(player_t *player, boolean skybox)
|
||||
|
||||
if (!skybox && cv_glrenderdistance.value)
|
||||
{
|
||||
GL_GClipRect((INT32)gl_viewwindowx,
|
||||
(INT32)gl_viewwindowy,
|
||||
(INT32)(gl_viewwindowx + gl_viewwidth),
|
||||
(INT32)(gl_viewwindowy + gl_viewheight),
|
||||
GL_GClipRect(viewwindowx,
|
||||
viewwindowy,
|
||||
(viewwindowx + viewwidth),
|
||||
(viewwindowy + viewheight),
|
||||
ZCLIP_PLANE, clipping_distances[cv_glrenderdistance.value - 1]);
|
||||
current_bsp_culling_distance = bsp_culling_distances[cv_glrenderdistance.value - 1];
|
||||
}
|
||||
@@ -5872,7 +5787,7 @@ static void COM_HWR_glinfo(void)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -5994,7 +5909,7 @@ static void HWR_DoPostProcessor(player_t *player)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -42,10 +42,6 @@ extern "C" {
|
||||
void HWR_Startup(void);
|
||||
void HWR_Shutdown(void);
|
||||
|
||||
extern float gl_viewwidth, gl_viewheight, gl_baseviewwindowx, gl_baseviewwindowy;
|
||||
|
||||
extern float gl_basewindowcenterx, gl_basewindowcentery;
|
||||
|
||||
extern unsigned msaa;
|
||||
extern boolean a2c;
|
||||
|
||||
@@ -89,7 +85,6 @@ extern ps_metric_t ps_hw_batchdrawtime;
|
||||
extern boolean gl_shadersavailable;
|
||||
|
||||
// hw_draw.c
|
||||
void HWR_DrawPatch(patch_t *gpatch, INT32 x, INT32 y, INT32 option);
|
||||
void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags);
|
||||
void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h);
|
||||
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color);
|
||||
@@ -98,7 +93,6 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color);
|
||||
void HWR_drawAMline(const fline_t *fl, INT32 color);
|
||||
void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength);
|
||||
void HWR_DrawConsoleBack(UINT32 color, INT32 height);
|
||||
void HWR_DrawViewBorder(INT32 clearlines);
|
||||
void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum);
|
||||
|
||||
UINT8 *HWR_GetScreenshot(INT32 scale);
|
||||
|
||||
+13
-12
@@ -72,10 +72,9 @@
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
md2_t md2_models[NUMSPRITES];
|
||||
md2_t md2_playermodels[MAXSKINS];
|
||||
md2_t md2_localplayermodels[MAXLOCALSKINS];
|
||||
|
||||
md2_t md2_models[NUMSPRITES] = {};
|
||||
md2_t md2_playermodels[MAXSKINS] = {};
|
||||
md2_t md2_localplayermodels[MAXLOCALSKINS] = {};
|
||||
|
||||
/*
|
||||
* free model
|
||||
@@ -417,7 +416,7 @@ static void md2_loadTexture(md2_t *model)
|
||||
size = w*h;
|
||||
while (size--)
|
||||
{
|
||||
V_CubeApply(&image->s.red, &image->s.green, &image->s.blue);
|
||||
V_CubeApply(image);
|
||||
image++;
|
||||
}
|
||||
}
|
||||
@@ -549,7 +548,7 @@ void HWR_InitMD2(void)
|
||||
{
|
||||
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].offset = offset;
|
||||
@@ -561,7 +560,7 @@ void HWR_InitMD2(void)
|
||||
|
||||
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].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!
|
||||
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].scale = scale;
|
||||
@@ -650,6 +650,7 @@ void HWR_AddSpriteMD2(size_t spritenum) // For MD2s that were added after startu
|
||||
if (!f)
|
||||
{
|
||||
f = fopen(va("%s"PATHSEP"%s", srb2path, "mdls.dat"), "rt");
|
||||
|
||||
if (!f)
|
||||
{
|
||||
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!
|
||||
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].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)))
|
||||
{
|
||||
M_Memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
|
||||
memcpy(glMipmap->colormap->data, colormap, 256 * sizeof(UINT8));
|
||||
HWR_CreateBlendedTexture(patch, blendgpatch, glMipmap, skinnum, color);
|
||||
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->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);
|
||||
|
||||
|
||||
+10
-155
@@ -114,7 +114,6 @@ void UnloadModel(model_t *model)
|
||||
if (model->materials)
|
||||
Z_Free(model->materials);
|
||||
|
||||
DeleteVBOs(model);
|
||||
Z_Free(model);
|
||||
}
|
||||
|
||||
@@ -127,7 +126,7 @@ tag_t *GetTagByName(model_t *model, char *name, int frame)
|
||||
int i;
|
||||
for (i = 0; i < model->numTags; i++)
|
||||
{
|
||||
if (!stricmp(iterator[i].name, name))
|
||||
if (fasticmp(iterator[i].name, name))
|
||||
return &iterator[i];
|
||||
}
|
||||
}
|
||||
@@ -164,22 +163,22 @@ model_t *LoadModel(const char *filename, int ztag)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!strcmp(extension, ".md3"))
|
||||
if (fastcmp(extension, ".md3"))
|
||||
{
|
||||
if (!(model = MD3_LoadModel(filename, ztag, false)))
|
||||
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)))
|
||||
return NULL;
|
||||
}
|
||||
else if (!strcmp(extension, ".md2"))
|
||||
else if (fastcmp(extension, ".md2"))
|
||||
{
|
||||
if (!(model = MD2_LoadModel(filename, ztag, false)))
|
||||
return NULL;
|
||||
}
|
||||
else if (!strcmp(extension, ".md2s"))
|
||||
else if (fastcmp(extension, ".md2s"))
|
||||
{
|
||||
if (!(model = MD2_LoadModel(filename, ztag, true)))
|
||||
return NULL;
|
||||
@@ -194,7 +193,6 @@ model_t *LoadModel(const char *filename, int ztag)
|
||||
strcpy(model->mdlFilename, filename);
|
||||
|
||||
Optimize(model);
|
||||
GeneratePolygonNormals(model, ztag);
|
||||
|
||||
// Default material properties
|
||||
for (i = 0 ; i < model->numMaterials; i++)
|
||||
@@ -244,14 +242,7 @@ void GenerateVertexNormals(model_t *model)
|
||||
float *vertPtr = frame->vertices;
|
||||
float *oldNormals;
|
||||
|
||||
M_Memcpy(newNormals, frame->normals, sizeof(float)*3*mesh->numTriangles*3);
|
||||
|
||||
/* if (!systemSucks)
|
||||
{
|
||||
memTag = Z_GetTag(frame->tangents);
|
||||
float *newTangents = (float*)Z_Malloc(sizeof(float)*3*mesh->numTriangles*3, memTag);
|
||||
M_Memcpy(newTangents, frame->tangents, sizeof(float)*3*mesh->numTriangles*3);
|
||||
}*/
|
||||
memcpy(newNormals, frame->normals, sizeof(float)*3*mesh->numTriangles*3);
|
||||
|
||||
for (k = 0; k < mesh->numVertices; k++)
|
||||
{
|
||||
@@ -288,32 +279,15 @@ void GenerateVertexNormals(model_t *model)
|
||||
|
||||
if (vCount > 1)
|
||||
{
|
||||
// Vector::Normalize(&normal);
|
||||
newNormals[3 * k + 0] = (float)normal.x;
|
||||
newNormals[3 * k + 1] = (float)normal.y;
|
||||
newNormals[3 * k + 2] = (float)normal.z;
|
||||
|
||||
/* if (!systemSucks)
|
||||
{
|
||||
Vector::vector_t tangent;
|
||||
Vector::Tangent(&normal, &tangent);
|
||||
newTangents[3 * k + 0] = tangent.x;
|
||||
newTangents[3 * k + 1] = tangent.y;
|
||||
newTangents[3 * k + 2] = tangent.z;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
oldNormals = frame->normals;
|
||||
frame->normals = newNormals;
|
||||
Z_Free(oldNormals);
|
||||
|
||||
/* if (!systemSucks)
|
||||
{
|
||||
float *oldTangents = frame->tangents;
|
||||
frame->tangents = newTangents;
|
||||
Z_Free(oldTangents);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,15 +378,11 @@ void Optimize(model_t *model)
|
||||
newMesh->numTriangles = numTriangles;
|
||||
newMesh->numVertices = numTriangles * 3;
|
||||
newMesh->uvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0);
|
||||
// if (node->material->lightmap)
|
||||
// newMesh->lightuvs = (float*)Z_Malloc(sizeof(float)*2*numTriangles*3, memTag, 0);
|
||||
newMesh->frames = (mdlframe_t*)Z_Calloc(sizeof(mdlframe_t), memTag, 0);
|
||||
curFrame = &newMesh->frames[0];
|
||||
|
||||
curFrame->material = curMat;
|
||||
curFrame->normals = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
|
||||
// if (!systemSucks)
|
||||
// curFrame->tangents = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
|
||||
curFrame->vertices = (float*)Z_Malloc(sizeof(float)*3*numTriangles*3, memTag, 0);
|
||||
curFrame->colors = (char*)Z_Malloc(sizeof(char)*4*numTriangles*3, memTag, 0);
|
||||
|
||||
@@ -432,39 +402,24 @@ void Optimize(model_t *model)
|
||||
char *destByte;
|
||||
char *srcByte;
|
||||
|
||||
M_Memcpy(&newMesh->uvs[uvCount],
|
||||
memcpy(&newMesh->uvs[uvCount],
|
||||
curMesh->uvs,
|
||||
sizeof(float)*2*curMesh->numTriangles*3);
|
||||
|
||||
/* if (node->material->lightmap)
|
||||
{
|
||||
M_Memcpy(&newMesh->lightuvs[uvCount],
|
||||
curMesh->lightuvs,
|
||||
sizeof(float)*2*curMesh->numTriangles*3);
|
||||
}*/
|
||||
uvCount += 2*curMesh->numTriangles*3;
|
||||
|
||||
dest = (float*)newMesh->frames[0].vertices;
|
||||
src = (float*)curMesh->frames[0].vertices;
|
||||
M_Memcpy(&dest[vertCount],
|
||||
memcpy(&dest[vertCount],
|
||||
src,
|
||||
sizeof(float)*3*curMesh->numTriangles*3);
|
||||
|
||||
dest = (float*)newMesh->frames[0].normals;
|
||||
src = (float*)curMesh->frames[0].normals;
|
||||
M_Memcpy(&dest[vertCount],
|
||||
memcpy(&dest[vertCount],
|
||||
src,
|
||||
sizeof(float)*3*curMesh->numTriangles*3);
|
||||
|
||||
/* if (!systemSucks)
|
||||
{
|
||||
dest = (float*)newMesh->frames[0].tangents;
|
||||
src = (float*)curMesh->frames[0].tangents;
|
||||
M_Memcpy(&dest[vertCount],
|
||||
src,
|
||||
sizeof(float)*3*curMesh->numTriangles*3);
|
||||
}*/
|
||||
|
||||
vertCount += 3 * curMesh->numTriangles * 3;
|
||||
|
||||
destByte = (char*)newMesh->frames[0].colors;
|
||||
@@ -472,7 +427,7 @@ void Optimize(model_t *model)
|
||||
|
||||
if (srcByte)
|
||||
{
|
||||
M_Memcpy(&destByte[colorCount],
|
||||
memcpy(&destByte[colorCount],
|
||||
srcByte,
|
||||
sizeof(char)*4*curMesh->numTriangles*3);
|
||||
}
|
||||
@@ -494,103 +449,3 @@ void Optimize(model_t *model)
|
||||
model->meshes = newMeshes;
|
||||
model->numMeshes = numMeshes;
|
||||
}
|
||||
|
||||
void GeneratePolygonNormals(model_t *model, int ztag)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < model->numMeshes; i++)
|
||||
{
|
||||
int j;
|
||||
mesh_t *mesh = &model->meshes[i];
|
||||
|
||||
if (!mesh->frames)
|
||||
continue;
|
||||
|
||||
for (j = 0; j < mesh->numFrames; j++)
|
||||
{
|
||||
int k;
|
||||
mdlframe_t *frame = &mesh->frames[j];
|
||||
const float *vertices = frame->vertices;
|
||||
vector_t *polyNormals;
|
||||
|
||||
frame->polyNormals = (vector_t*)Z_Malloc(sizeof(vector_t) * mesh->numTriangles, ztag, 0);
|
||||
|
||||
polyNormals = frame->polyNormals;
|
||||
|
||||
for (k = 0; k < mesh->numTriangles; k++)
|
||||
{
|
||||
/// TODO: normalize vectors
|
||||
(void)vertices;
|
||||
(void)polyNormals;
|
||||
// Vector::Normal(vertices, polyNormals);
|
||||
vertices += 3 * 3;
|
||||
polyNormals++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Reload
|
||||
//
|
||||
// Reload VBOs
|
||||
//
|
||||
#if 0
|
||||
static void Reload(void)
|
||||
{
|
||||
/* model_t *node;
|
||||
for (node = modelHead; node; node = node->next)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < node->numMeshes; i++)
|
||||
{
|
||||
mesh_t *mesh = &node->meshes[i];
|
||||
|
||||
if (mesh->frames)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < mesh->numFrames; j++)
|
||||
CreateVBO(mesh, &mesh->frames[j]);
|
||||
}
|
||||
else if (mesh->tinyframes)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < mesh->numFrames; j++)
|
||||
CreateVBO(mesh, &mesh->tinyframes[j]);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
|
||||
void DeleteVBOs(model_t *model)
|
||||
{
|
||||
(void)model;
|
||||
/* for (int i = 0; i < model->numMeshes; i++)
|
||||
{
|
||||
mesh_t *mesh = &model->meshes[i];
|
||||
|
||||
if (mesh->frames)
|
||||
{
|
||||
for (int j = 0; j < mesh->numFrames; j++)
|
||||
{
|
||||
mdlframe_t *frame = &mesh->frames[j];
|
||||
if (!frame->vboID)
|
||||
continue;
|
||||
bglDeleteBuffers(1, &frame->vboID);
|
||||
frame->vboID = 0;
|
||||
}
|
||||
}
|
||||
else if (mesh->tinyframes)
|
||||
{
|
||||
for (int j = 0; j < mesh->numFrames; j++)
|
||||
{
|
||||
tinyframe_t *frame = &mesh->tinyframes[j];
|
||||
if (!frame->vboID)
|
||||
continue;
|
||||
bglDeleteBuffers(1, &frame->vboID);
|
||||
frame->vboID = 0;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
@@ -28,8 +28,6 @@ typedef struct
|
||||
float ambient[4], diffuse[4], specular[4], emissive[4];
|
||||
float shininess;
|
||||
boolean spheremap;
|
||||
// Texture::texture_t *texture;
|
||||
// Texture::texture_t *lightmap;
|
||||
} material_t;
|
||||
|
||||
typedef struct
|
||||
@@ -40,7 +38,6 @@ typedef struct
|
||||
float *tangents;
|
||||
char *colors;
|
||||
unsigned int vboID;
|
||||
vector_t *polyNormals;
|
||||
} mdlframe_t;
|
||||
|
||||
typedef struct
|
||||
@@ -70,7 +67,6 @@ typedef struct mesh_s
|
||||
typedef struct tag_s
|
||||
{
|
||||
char name[64];
|
||||
// matrix_t transform;
|
||||
} tag_t;
|
||||
|
||||
typedef struct model_s
|
||||
@@ -96,9 +92,7 @@ model_t *LoadModel(const char *filename, int ztag);
|
||||
void UnloadModel(model_t *model);
|
||||
void Optimize(model_t *model);
|
||||
void GenerateVertexNormals(model_t *model);
|
||||
void GeneratePolygonNormals(model_t *model, int ztag);
|
||||
void CreateVBOTiny(mesh_t *mesh, tinyframe_t *frame);
|
||||
void CreateVBO(mesh_t *mesh, mdlframe_t *frame);
|
||||
void DeleteVBOs(model_t *model);
|
||||
|
||||
#endif
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
SINT8 gl_portal_state = GLPORTAL_OFF;
|
||||
|
||||
gl_portallist_t *currentportallist;
|
||||
gl_portallist_t *currentportallist = NULL;
|
||||
|
||||
// clip the area outside the portal destination window
|
||||
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
|
||||
HWR_PortalFrame(portal);
|
||||
|
||||
// call HWR_RenderViewpoint
|
||||
HWR_RenderPortalViewpoint(portal, player, stencil_level + 1, true);
|
||||
|
||||
// return to current frame
|
||||
if (rootportal)
|
||||
HWR_PortalFrame(rootportal);
|
||||
|
||||
@@ -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);
|
||||
return NULL;
|
||||
}
|
||||
M_Memcpy(shader_glsl_version, read_pos, 3);
|
||||
memcpy(shader_glsl_version, read_pos, 3);
|
||||
ADVANCE(version_number_len)
|
||||
version_len = (read_pos - original) - version_pos;
|
||||
whitespace_len = strspn(read_pos, WHITESPACE_CHARS);
|
||||
@@ -304,7 +304,7 @@ static char *HWR_PreprocessShader(char *original)
|
||||
{
|
||||
strcpy(write_pos, VERSION_PART);
|
||||
write_pos += sizeof(VERSION_PART) - 1;
|
||||
M_Memcpy(write_pos, shader_glsl_version, 3);
|
||||
memcpy(write_pos, shader_glsl_version, 3);
|
||||
write_pos += 3;
|
||||
strcpy(write_pos, line_ending);
|
||||
write_pos += line_ending_len;
|
||||
@@ -344,7 +344,7 @@ static char *HWR_PreprocessShader(char *original)
|
||||
}
|
||||
|
||||
// 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.
|
||||
if (new_len != original_len && version_pos != -1)
|
||||
@@ -573,7 +573,7 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
|
||||
size = W_LumpLengthPwad(wadnum, lump);
|
||||
|
||||
line = Z_Malloc(size+1, PU_STATIC, NULL);
|
||||
M_Memcpy(line, shaderdef, size);
|
||||
memcpy(line, shaderdef, size);
|
||||
line[size] = '\0';
|
||||
|
||||
stoken = strtok(line, "\r\n ");
|
||||
@@ -586,7 +586,7 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
|
||||
goto skip_field;
|
||||
}
|
||||
|
||||
if (!stricmp(stoken, "GLSL"))
|
||||
if (fasticmp(stoken, "GLSL"))
|
||||
{
|
||||
value = strtok(NULL, "\r\n ");
|
||||
if (!value)
|
||||
@@ -596,9 +596,9 @@ void HWR_LoadCustomShadersFromFile(UINT16 wadnum, boolean PK3)
|
||||
goto skip_lump;
|
||||
}
|
||||
|
||||
if (!stricmp(value, "VERTEX"))
|
||||
if (fasticmp(value, "VERTEX"))
|
||||
shadertype = 1;
|
||||
else if (!stricmp(value, "FRAGMENT"))
|
||||
else if (fasticmp(value, "FRAGMENT"))
|
||||
shadertype = 2;
|
||||
|
||||
skip_lump:
|
||||
@@ -624,7 +624,7 @@ skip_lump:
|
||||
|
||||
for (i = 0; shaderxlat[i].type; i++)
|
||||
{
|
||||
if (!stricmp(shaderxlat[i].type, stoken))
|
||||
if (fasticmp(shaderxlat[i].type, stoken))
|
||||
{
|
||||
size_t shader_string_length;
|
||||
char *shader_source;
|
||||
|
||||
@@ -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
|
||||
GLbyte screen_depth = 0;
|
||||
GLint maximumAnisotropy = 0;
|
||||
boolean supportNPO2tex = false;
|
||||
static GLboolean MipMap = GL_FALSE;
|
||||
static GLint min_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;
|
||||
|
||||
// look for power of two that is large enough for the screen
|
||||
while (screen_texsizew < w)
|
||||
screen_texsizew <<= 1;
|
||||
if (supportNPO2tex)
|
||||
{
|
||||
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)
|
||||
screen_texsizeh <<= 1;
|
||||
while (screen_texsizeh < h)
|
||||
screen_texsizeh <<= 1;
|
||||
}
|
||||
|
||||
pglGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtexsize); // Get the maximum supported texture size
|
||||
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)
|
||||
static void PadRGBABitmap(RGBA_t *tex, UINT16 w, UINT16 h, UINT32 flags)
|
||||
{
|
||||
INT32 i;
|
||||
boolean notLeft, notRight, notTop, notBottom;
|
||||
RGBA_t *to = tex - 1, *from;
|
||||
INT32 i, c1, c2, idxAdd;
|
||||
UINT16 c1size, c2size;
|
||||
RGBA_t *current, *prev, *next, *first;
|
||||
boolean ignorePrev, wrap;
|
||||
|
||||
for (i = 0; i < w * h; i++)
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
to++;
|
||||
if (to->rgba != 0)
|
||||
continue;
|
||||
from = NULL;
|
||||
c1size = i ? h : w;
|
||||
c2size = i ? w : h;
|
||||
idxAdd = i ? 1 : w;
|
||||
wrap = i ? flags & TF_WRAPX : flags & TF_WRAPY;
|
||||
|
||||
notLeft = i % w != 0;
|
||||
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)
|
||||
for (c1 = 0; c1 < c1size; c1++)
|
||||
{
|
||||
*to = *from;
|
||||
to->s.alpha = 0;
|
||||
if (i)
|
||||
{
|
||||
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)
|
||||
static void GenerateMipmaps(INT32 w, INT32 h, RGBA_t *tex, INT32 maxLOD, UINT32 flags)
|
||||
{
|
||||
if (tex == NULL)
|
||||
{
|
||||
@@ -1916,7 +1950,7 @@ static void GenerateMipmaps(INT32 w, INT32 h, RGBA_t *tex, INT32 maxLOD)
|
||||
h /= 2;
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1991,7 +2025,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
|
||||
}
|
||||
|
||||
if (applyPadding)
|
||||
PadRGBABitmap(tex, w, h);
|
||||
PadRGBABitmap(tex, w, h, pTexInfo->flags);
|
||||
|
||||
break;
|
||||
case GL_TEXFMT_RGBA:
|
||||
@@ -2007,7 +2041,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
|
||||
ptex = tex;
|
||||
|
||||
if (applyPadding)
|
||||
PadRGBABitmap(tex, w, h);
|
||||
PadRGBABitmap(tex, w, h, pTexInfo->flags);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -2052,21 +2086,10 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
|
||||
pglBindTexture(GL_TEXTURE_2D, 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 (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
|
||||
if (MipMap)
|
||||
{
|
||||
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
|
||||
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
|
||||
{
|
||||
@@ -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?
|
||||
}
|
||||
|
||||
static const boolean gl_ext_arb_vertex_buffer_object = true;
|
||||
|
||||
#define NULL_VBO_VERTEX ((gl_skyvertex_t*)NULL)
|
||||
#define sky_vbo_x (gl_ext_arb_vertex_buffer_object ? &NULL_VBO_VERTEX->x : &sky->data[0].x)
|
||||
#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)
|
||||
//#define NULL_VBO_VERTEX ((gl_skyvertex_t*)NULL)
|
||||
#define sky_vbo_x ((void*)offsetof(gl_skyvertex_t, x))
|
||||
#define sky_vbo_u ((void*)offsetof(gl_skyvertex_t, u))
|
||||
#define sky_vbo_r ((void*)offsetof(gl_skyvertex_t, r))
|
||||
|
||||
void GL_RenderSkyDome(gl_sky_t *sky)
|
||||
{
|
||||
@@ -2476,30 +2505,23 @@ void GL_RenderSkyDome(gl_sky_t *sky)
|
||||
if (sky->rebuild)
|
||||
{
|
||||
// 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
|
||||
pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo);
|
||||
// bind VBO in order to use
|
||||
pglBindBuffer(GL_ARRAY_BUFFER, sky->vbo);
|
||||
|
||||
// upload data to VBO
|
||||
pglBufferData(GL_ARRAY_BUFFER, sky->vertex_count * sizeof(sky->data[0]), sky->data, GL_STATIC_DRAW);
|
||||
}
|
||||
// upload data to VBO
|
||||
pglBufferData(GL_ARRAY_BUFFER, sky->vertex_count * sizeof(sky->data[0]), sky->data, GL_STATIC_DRAW);
|
||||
|
||||
sky->rebuild = false;
|
||||
}
|
||||
|
||||
// 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
|
||||
pglVertexPointer(3, GL_FLOAT, sizeof(sky->data[0]), sky_vbo_x);
|
||||
@@ -2543,8 +2565,7 @@ void GL_RenderSkyDome(gl_sky_t *sky)
|
||||
pglColor4ubv(white);
|
||||
|
||||
// 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
|
||||
pglDisableClientState(GL_COLOR_ARRAY);
|
||||
@@ -3692,7 +3713,6 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
|
||||
float xfix, yfix;
|
||||
float origaspect, newaspect;
|
||||
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 fix[8];
|
||||
@@ -3743,8 +3763,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh
|
||||
|
||||
pglViewport(0, 0, width, height);
|
||||
|
||||
clearColour.red = clearColour.green = clearColour.blue = 0;
|
||||
clearColour.alpha = 1;
|
||||
FRGBAFloat clearColour = {0, 0, 0, 1};
|
||||
GL_ClearBuffer(true, false, false, &clearColour);
|
||||
GL_SetBlend(PF_NoDepthTest);
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ extern GLint screen_width;
|
||||
extern GLint screen_height;
|
||||
extern GLbyte screen_depth;
|
||||
extern GLint maximumAnisotropy;
|
||||
extern boolean supportNPO2tex;
|
||||
extern boolean supportMipMap;
|
||||
|
||||
/** \brief OpenGL flags for video driver
|
||||
|
||||
@@ -253,6 +253,9 @@ HMS_connect (const char *format, ...)
|
||||
cc = curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long)cv_masterserver_timeout.value);
|
||||
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
|
||||
|
||||
cc = curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 30L);
|
||||
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
|
||||
|
||||
cc = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
|
||||
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
|
||||
|
||||
|
||||
+30
-91
@@ -280,7 +280,7 @@ static void Command_Say_f(void);
|
||||
static void Command_Sayto_f(void);
|
||||
static void Command_Sayteam_f(void);
|
||||
static void Command_CSay_f(void);
|
||||
static void Got_Saycmd(UINT8 **p, INT32 playernum);
|
||||
static void Got_Saycmd(const UINT8 **p, INT32 playernum);
|
||||
|
||||
void HU_LoadGraphics(void)
|
||||
{
|
||||
@@ -431,7 +431,7 @@ void HU_Start(void)
|
||||
|
||||
void HU_Shiftform(void)
|
||||
{
|
||||
shiftxform = cv_keyboardlayout.value == 3 ? french_shiftxform : english_shiftxform;
|
||||
shiftxform = (cv_keyboardlayout.value == 3) ? french_shiftxform : english_shiftxform;
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
@@ -465,8 +465,8 @@ static INT16 addy = 0; // use this to make the messages scroll smoothly when one
|
||||
static void HU_removeChatText_Mini(void)
|
||||
{
|
||||
// MPC: Don't create new arrays, just iterate through an existing one
|
||||
size_t i;
|
||||
for(i=0;i<chat_nummsg_min-1;i++) {
|
||||
for (size_t i = 0; i < chat_nummsg_min - 1; i++)
|
||||
{
|
||||
strcpy(chat_mini[i], chat_mini[i+1]);
|
||||
chat_timers[i] = chat_timers[i+1];
|
||||
}
|
||||
@@ -485,8 +485,8 @@ static void HU_removeChatText_Log(void)
|
||||
return;
|
||||
|
||||
free(chat_log[0]);
|
||||
size_t i;
|
||||
for(i=0;i<chat_nummsg_log-1;i++)
|
||||
|
||||
for (size_t i = 0; i < chat_nummsg_log - 1;i++)
|
||||
{
|
||||
chat_log[i] = chat_log[i+1];
|
||||
}
|
||||
@@ -879,11 +879,12 @@ const char *HU_SkinColorToConsoleColor(skincolors_t color)
|
||||
* \sa DoSayCommand
|
||||
* \author Graue <graue@oceanbase.org>
|
||||
*/
|
||||
static void Got_Saycmd(UINT8 **p, INT32 playernum)
|
||||
static void Got_Saycmd(const UINT8 **p, INT32 playernum)
|
||||
{
|
||||
SINT8 target;
|
||||
UINT8 flags;
|
||||
const char *dispname;
|
||||
char buf[HU_MAXMSGLEN + 1];
|
||||
char *msg;
|
||||
boolean action = false;
|
||||
char *ptr;
|
||||
@@ -893,8 +894,8 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
|
||||
|
||||
target = READSINT8(*p);
|
||||
flags = READUINT8(*p);
|
||||
msg = (char *)*p;
|
||||
SKIPSTRINGL(*p, HU_MAXMSGLEN + 1);
|
||||
msg = buf;
|
||||
READSTRINGL(*p, msg, HU_MAXMSGLEN + 1);
|
||||
|
||||
if ((cv_mute.value || flags & (HU_CSAY|HU_SERVER_SAY)) && playernum != serverplayer && !(IsPlayerAdmin(playernum)))
|
||||
{
|
||||
@@ -1101,14 +1102,14 @@ void HU_Ticker(void)
|
||||
size_t i = 0;
|
||||
|
||||
// handle spam while we're at it:
|
||||
for(; (i<MAXPLAYERS); i++)
|
||||
for(; (i < MAXPLAYERS); i++)
|
||||
{
|
||||
if (stop_spamming[i] > 0)
|
||||
stop_spamming[i]--;
|
||||
}
|
||||
|
||||
// handle chat timers
|
||||
for (i=0; (i<chat_nummsg_min); i++)
|
||||
for (i = 0; (i < chat_nummsg_min); i++)
|
||||
{
|
||||
if (chat_timers[i] > 0)
|
||||
chat_timers[i]--;
|
||||
@@ -1231,7 +1232,7 @@ static void HU_SendChatMessage(void)
|
||||
nodenum[2] = '\0';
|
||||
|
||||
// check for undesirable characters in our "number"
|
||||
if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9')))
|
||||
if (((nodenum[0] < '0') || (nodenum[0] > '9')) || ((nodenum[1] < '0') || (nodenum[1] > '9')))
|
||||
{
|
||||
// check if nodenum[1] is a space
|
||||
if (nodenum[1] == ' ')
|
||||
@@ -1499,7 +1500,7 @@ static void HU_drawMiniChat(void)
|
||||
if (splitscreen > 1)
|
||||
boxw = max(64, boxw/2);
|
||||
|
||||
for (; i>0; i--)
|
||||
for (; i > 0; i--)
|
||||
{
|
||||
char *msg = CHAT_WordWrap(x+2, boxw-(charwidth*2), V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, chat_mini[i-1]);
|
||||
size_t j = 0;
|
||||
@@ -1572,7 +1573,7 @@ static void HU_drawMiniChat(void)
|
||||
i = 0;
|
||||
prev_linereturn = false;
|
||||
|
||||
for (; i<=(chat_nummsg_min-1); i++) // iterate through our hot messages
|
||||
for (; i <= (chat_nummsg_min-1); i++) // iterate through our hot messages
|
||||
{
|
||||
INT32 clrflag = 0;
|
||||
INT32 timer = ((cv_chattime.value*TICRATE)-chat_timers[i]) - cv_chattime.value*TICRATE+9; // see below...
|
||||
@@ -1749,7 +1750,6 @@ static void HU_drawChatLog(INT32 offset)
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
|
||||
if (((chat_scroll >= chat_maxscroll) || (chat_scrollmedown)) && !(justscrolleddown || justscrolledup || chat_scrolltime)) // was already at the bottom of the page before new maxscroll calculation and was NOT scrolling.
|
||||
{
|
||||
atbottom = true; // we should scroll
|
||||
@@ -2284,6 +2284,7 @@ static void HU_DrawSongCreditsBox(void)
|
||||
V_DrawFill(x, y, strwidth*dup, BOXCREDITHEIGHT*dup, 28|flags|(bgt<<V_ALPHASHIFT));
|
||||
V_DrawFill(x+dup, y+dup, (strwidth-2)*dup, (BOXCREDITHEIGHT-2)*dup, 30|flags|(bgt<<V_ALPHASHIFT));
|
||||
}
|
||||
|
||||
if (cursongcredit.trans < NUMTRANSMAPS)
|
||||
{
|
||||
V_DrawSmallString(x+2*dup, y+2*dup, V_ALLOWLOWERCASE|flags|(cursongcredit.trans<<V_ALPHASHIFT), str);
|
||||
@@ -2391,76 +2392,6 @@ void HU_Drawer(void)
|
||||
}
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// HUD MESSAGES CLEARING FROM SCREEN
|
||||
//======================================================================
|
||||
|
||||
// Clear old messages from the borders around the view window
|
||||
// (only for reduced view, refresh the borders when needed)
|
||||
//
|
||||
// startline: y coord to start clear,
|
||||
// clearlines: how many lines to clear.
|
||||
//
|
||||
static INT32 oldclearlines;
|
||||
|
||||
void HU_Erase(void)
|
||||
{
|
||||
INT32 topline, bottomline;
|
||||
INT32 y, yoffset;
|
||||
|
||||
#ifdef HWRENDER
|
||||
// clear hud msgs on double buffer (OpenGL mode)
|
||||
boolean secondframe;
|
||||
static INT32 secondframelines;
|
||||
#endif
|
||||
|
||||
if (con_clearlines == oldclearlines && !con_hudupdate && !chat_on)
|
||||
return;
|
||||
|
||||
#ifdef HWRENDER
|
||||
// clear the other frame in double-buffer modes
|
||||
secondframe = (con_clearlines != oldclearlines);
|
||||
if (secondframe)
|
||||
secondframelines = oldclearlines;
|
||||
#endif
|
||||
|
||||
// clear the message lines that go away, so use _oldclearlines_
|
||||
bottomline = oldclearlines;
|
||||
oldclearlines = con_clearlines;
|
||||
if (chat_on && OLDCHAT)
|
||||
if (bottomline < 8)
|
||||
bottomline = 8; // only do it for consolechat. consolechat is gay.
|
||||
|
||||
if (automapactive || viewwindowx == 0) // hud msgs don't need to be cleared
|
||||
return;
|
||||
|
||||
// software mode copies view border pattern & beveled edges from the backbuffer
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
topline = 0;
|
||||
for (y = topline, yoffset = y*vid.width; y < bottomline; y++, yoffset += vid.width)
|
||||
{
|
||||
if (y < viewwindowy || y >= viewwindowy + viewheight)
|
||||
R_VideoErase(yoffset, vid.width); // erase entire line
|
||||
else
|
||||
{
|
||||
R_VideoErase(yoffset, viewwindowx); // erase left border
|
||||
// erase right border
|
||||
R_VideoErase(yoffset + viewwindowx + viewwidth, viewwindowx);
|
||||
}
|
||||
}
|
||||
con_hudupdate = false; // if it was set..
|
||||
}
|
||||
#ifdef HWRENDER
|
||||
else if (rendermode != render_none)
|
||||
{
|
||||
// refresh just what is needed from the view borders
|
||||
HWR_DrawViewBorder(secondframelines);
|
||||
con_hudupdate = secondframe;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// IN-LEVEL MULTIPLAYER RANKINGS
|
||||
//======================================================================
|
||||
@@ -2915,12 +2846,8 @@ void HU_SetCEchoFlags(INT32 flags)
|
||||
|
||||
void HU_DoCEcho(const char *msg)
|
||||
{
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wstringop-truncation" // This is fine, we set null byte later
|
||||
strncpy(cechotext, msg, sizeof(cechotext));
|
||||
#pragma GCC diagnostic pop
|
||||
strncat(cechotext, "\\", sizeof(cechotext) - strlen(cechotext) - 1);
|
||||
cechotext[sizeof(cechotext) - 1] = '\0';
|
||||
strlcpy(cechotext, msg, sizeof(cechotext));
|
||||
strlcat(cechotext, "\\", sizeof(cechotext));
|
||||
|
||||
// just print it to console
|
||||
if (cv_cechotoggle.value == 2)
|
||||
@@ -2929,8 +2856,20 @@ void HU_DoCEcho(const char *msg)
|
||||
strncpy(temp, cechotext, sizeof(temp));
|
||||
|
||||
for (char *p = temp; *p != '\0'; ++p)
|
||||
{
|
||||
if (*p == '\\')
|
||||
{
|
||||
*p = '\n';
|
||||
++p;
|
||||
char *skip_p = p; // Point at which we will move part of string after all \'s
|
||||
|
||||
while (*p == '\\')
|
||||
++p;
|
||||
|
||||
memmove(skip_p, p, strlen(p)+1); // move the rest of string with null byte
|
||||
p = skip_p; // Restore p
|
||||
}
|
||||
}
|
||||
|
||||
CONS_Printf("%s\n", temp);
|
||||
|
||||
|
||||
@@ -117,7 +117,6 @@ void HU_TickSongCredits(void);
|
||||
void HU_DrawSongCredits(void);
|
||||
void HU_Drawer(void);
|
||||
char HU_dequeueChatChar(void);
|
||||
void HU_Erase(void);
|
||||
void HU_clearChatChars(void);
|
||||
void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags); // Lat': Ping drawer for scoreboard.
|
||||
//void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer);
|
||||
|
||||
@@ -1,680 +0,0 @@
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2018 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file i_addrinfo.c
|
||||
/// \brief getaddr stubs, for lesser OSes
|
||||
///
|
||||
/// Some systems/SDKs, like PSL1GHT v2 does not have addrinfo functions
|
||||
/// So a stub is needed
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#ifdef _WIN32
|
||||
#ifdef USE_WINSOCK2
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#include "i_addrinfo.h"
|
||||
|
||||
/*
|
||||
* This addrinfo stub have a testcases:
|
||||
* To test the stub, use this command to compile the stub testcase:
|
||||
* gcc -g -DTESTCASE -Dtest_stub -Wall -W i_addrinfo.c -o stub
|
||||
* To test the real getaddrinfo API, use this command to get real one:
|
||||
* gcc -g -DTESTCASE -Utest_stub -Wall -W i_addrinfo.c -o real
|
||||
* For Win32,you need the WinSock library, version 1.1 or 2.2
|
||||
* for 1.1, add -lwsock32
|
||||
* i686-w64-mingw32-gcc -g -DTESTCASE -Dtest_stub -UUSE_WINSOCK2 -Wall -W i_addrinfo.c -o stub.exe -lwsock32
|
||||
* for 2.2, add -DUSE_WINSOCK2 -lws2_32
|
||||
* i686-w64-mingw32-gcc -g -DTESTCASE -Utest_stub -DUSE_WINSOCK2 -Wall -W i_addrinfo.c -o real.exe -lws2_32
|
||||
*/
|
||||
|
||||
#ifndef I_getaddrinfo
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
// it seems windows doesn't define that... maybe some other OS? OS/2
|
||||
static int inet_aton(const char *cp, struct in_addr *addr)
|
||||
{
|
||||
if( cp == NULL || addr == NULL )
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
if (strcmp(cp, "255.255.255.225") == 0)
|
||||
{
|
||||
addr->s_addr = htonl(INADDR_BROADCAST);
|
||||
return 0;
|
||||
}
|
||||
return (addr->s_addr = inet_addr(cp)) != htonl(INADDR_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_WINSOCK2
|
||||
static HMODULE ipv6dll = NULL;
|
||||
typedef int (WSAAPI *p_getaddrinfo) (const char *, const char *,
|
||||
const struct my_addrinfo *,
|
||||
struct my_addrinfo **);
|
||||
typedef void (WSAAPI *p_freeaddrinfo) (struct my_addrinfo *);
|
||||
|
||||
static p_getaddrinfo WS_getaddrinfo = NULL;
|
||||
static p_freeaddrinfo WS_freeaddrinfo = NULL;
|
||||
|
||||
static HMODULE WS_getfunctions(HMODULE tmp)
|
||||
{
|
||||
if (tmp != NULL)
|
||||
{
|
||||
WS_getaddrinfo = (p_getaddrinfo)(LPVOID)GetProcAddress(tmp, "getaddrinfo");
|
||||
if (WS_getaddrinfo == NULL)
|
||||
return NULL;
|
||||
WS_freeaddrinfo = (p_freeaddrinfo)(LPVOID)GetProcAddress(tmp, "freeaddrinfo");
|
||||
if (WS_freeaddrinfo == NULL)
|
||||
{
|
||||
WS_getaddrinfo = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static void WS_addrinfosetup(void)
|
||||
{
|
||||
if (WS_getaddrinfo && WS_freeaddrinfo)
|
||||
return; // already have the functions
|
||||
// why not hold it into ipv6dll? becase we already link with ws2_32, silly!
|
||||
if (WS_getfunctions(GetModuleHandleA("ws2_32.dll")) == NULL)
|
||||
ipv6dll = WS_getfunctions(LoadLibraryA("wship6.dll"));
|
||||
}
|
||||
|
||||
void WS_addrinfocleanup(void)
|
||||
{
|
||||
if (ipv6dll)
|
||||
FreeLibrary(ipv6dll);
|
||||
ipv6dll = NULL;
|
||||
WS_getaddrinfo = NULL;
|
||||
WS_freeaddrinfo = NULL;
|
||||
}
|
||||
#else
|
||||
void WS_addrinfocleanup(void) {}
|
||||
#endif
|
||||
|
||||
int I_getaddrinfo(const char *node, const char *service,
|
||||
const struct my_addrinfo *hints,
|
||||
struct my_addrinfo **res)
|
||||
{
|
||||
struct hostent *nodename = NULL;
|
||||
bool hostlookup = true, passivemode = false;
|
||||
int flags = 0;
|
||||
int socktype = 0;
|
||||
int sockport = 0;
|
||||
struct my_addrinfo *ai;
|
||||
struct sockaddr_in *addr;
|
||||
struct in_addr ipv4;
|
||||
size_t addrlen = 1;
|
||||
size_t ailen = 1, i = 0, j;
|
||||
size_t famsize = sizeof(struct sockaddr_in);
|
||||
#ifdef USE_WINSOCK2
|
||||
WS_addrinfosetup();
|
||||
if (WS_getaddrinfo)
|
||||
return WS_getaddrinfo(node, service, hints, res);
|
||||
#endif
|
||||
|
||||
// param check
|
||||
if (node == NULL && service == NULL)
|
||||
return EAI_NONAME;
|
||||
//note: testcase show NULL as res crashes libc
|
||||
if (res == NULL)
|
||||
return -1;
|
||||
|
||||
// check hints
|
||||
if (hints)
|
||||
{
|
||||
// no support for IPv6
|
||||
if (hints->ai_family != AF_INET && hints->ai_family != AF_UNSPEC)
|
||||
return -1; //EAI_FAMILY
|
||||
#ifdef AI_NUMERICHOST
|
||||
// do not look up hostnames
|
||||
if ((hints->ai_flags & AI_NUMERICHOST) == AI_NUMERICHOST)
|
||||
{
|
||||
hostlookup = false;
|
||||
flags |= AI_NUMERICHOST;
|
||||
}
|
||||
#endif
|
||||
#ifdef AI_PASSIVE
|
||||
// return loopback or any address?
|
||||
if ((hints->ai_flags & AI_PASSIVE) == AI_PASSIVE)
|
||||
{
|
||||
passivemode = true;
|
||||
flags |= AI_PASSIVE;
|
||||
}
|
||||
#endif
|
||||
// why no support for canon names? lazy
|
||||
//AI_CANONNAME
|
||||
// what kind of socket?
|
||||
socktype = hints->ai_socktype;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef AI_V4MAPPED
|
||||
flags |= AI_V4MAPPED;
|
||||
#endif
|
||||
#ifdef AI_ADDRCONFIG
|
||||
flags |= AI_ADDRCONFIG;
|
||||
#endif
|
||||
}
|
||||
|
||||
// we need gethostbyname to convert numeric strings
|
||||
if (node && hostlookup)
|
||||
{
|
||||
if (node == NULL)
|
||||
return -1;
|
||||
nodename = gethostbyname(node);
|
||||
if (nodename == NULL)
|
||||
{
|
||||
if (inet_aton(node, &ipv4) != 0)
|
||||
addrlen = 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
else while (nodename->h_addr_list[addrlen] != NULL)
|
||||
addrlen++;
|
||||
}
|
||||
else if (node)
|
||||
{
|
||||
if (inet_aton(node, &ipv4) != 0)
|
||||
addrlen = 1;
|
||||
else if (!hostlookup)
|
||||
return EAI_NONAME;
|
||||
}
|
||||
else
|
||||
addrlen = 1;
|
||||
|
||||
if (service) //AI_NUMERICSERV
|
||||
sockport = atoi(service);
|
||||
|
||||
if (socktype == 0)
|
||||
ailen = addrlen*3;
|
||||
else
|
||||
ailen = addrlen;
|
||||
|
||||
ai = calloc(ailen, sizeof(struct my_addrinfo));
|
||||
if (ai == NULL)
|
||||
return -1;
|
||||
else
|
||||
*res = ai;
|
||||
|
||||
addr = calloc(ailen*2, famsize);
|
||||
if (addr == NULL)
|
||||
{
|
||||
free(ai);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
ai->ai_addr = memset(addr, 0x00, ailen*ai->ai_addrlen);
|
||||
|
||||
for (i = 0; i < ailen; i++)
|
||||
{
|
||||
ai = *res+i;
|
||||
ai->ai_flags = flags;
|
||||
ai->ai_family = AF_INET;
|
||||
ai->ai_socktype = socktype;
|
||||
switch (ai->ai_socktype)
|
||||
{
|
||||
case SOCK_STREAM:
|
||||
ai->ai_protocol = IPPROTO_TCP;
|
||||
break;
|
||||
case SOCK_DGRAM:
|
||||
ai->ai_protocol = IPPROTO_UDP;
|
||||
break;
|
||||
default:
|
||||
ai->ai_protocol = 0;
|
||||
}
|
||||
ai->ai_addrlen = famsize;
|
||||
ai->ai_addr = (struct sockaddr *)&addr[i];
|
||||
//ai_cannonname
|
||||
ai->ai_next = ai+1;
|
||||
}
|
||||
ai->ai_next = NULL;
|
||||
ai = *res;
|
||||
|
||||
for (i = 0, j = 0; i < ailen; i++, j++)
|
||||
{
|
||||
ai = *res+i;
|
||||
addr[i].sin_port = htons((UINT16)sockport);
|
||||
if (nodename)
|
||||
{
|
||||
memcpy(&addr[i].sin_addr, nodename->h_addr_list[j], ai->ai_addrlen);
|
||||
addr[i].sin_family = nodename->h_addrtype;
|
||||
}
|
||||
else if (node)
|
||||
{
|
||||
memcpy(&addr[i].sin_addr, &ipv4, ai->ai_addrlen);
|
||||
addr[i].sin_family = AF_INET;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (passivemode)
|
||||
addr[i].sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
else
|
||||
addr[i].sin_addr.s_addr = htonl(INADDR_LOOPBACK);
|
||||
addr[i].sin_family = AF_INET;
|
||||
}
|
||||
if (socktype == 0)
|
||||
{
|
||||
ai->ai_socktype = SOCK_STREAM;
|
||||
ai->ai_protocol = IPPROTO_TCP;
|
||||
memcpy(&addr[i+1], &addr[i], ai->ai_addrlen);
|
||||
i++; ai++;
|
||||
ai->ai_socktype = SOCK_DGRAM;
|
||||
ai->ai_protocol = IPPROTO_UDP;
|
||||
memcpy(&addr[i+1], &addr[i], ai->ai_addrlen);
|
||||
i++; ai++;
|
||||
ai->ai_socktype = SOCK_RAW;
|
||||
ai->ai_protocol = IPPROTO_IP;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef I_freeaddrinfo
|
||||
void I_freeaddrinfo(struct my_addrinfo *res)
|
||||
{
|
||||
#ifdef USE_WINSOCK2
|
||||
if (WS_freeaddrinfo)
|
||||
{
|
||||
WS_freeaddrinfo(res);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (!res)
|
||||
return;
|
||||
free(res->ai_addr);
|
||||
free(res);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TESTCASE
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef USE_WINSOCK2
|
||||
#define inet_ntop inet_ntopA
|
||||
#define HAVE_NTOP
|
||||
static const char* inet_ntopA(int af, const void *cp, char *buf, socklen_t len)
|
||||
{
|
||||
DWORD Dlen = len, AFlen = 0;
|
||||
SOCKADDR_STORAGE any;
|
||||
LPSOCKADDR anyp = (LPSOCKADDR)&any;
|
||||
LPSOCKADDR_IN any4 = (LPSOCKADDR_IN)&any;
|
||||
LPSOCKADDR_IN6 any6 = (LPSOCKADDR_IN6)&any;
|
||||
|
||||
if (!buf)
|
||||
{
|
||||
WSASetLastError(STATUS_INVALID_PARAMETER);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (af != AF_INET && af != AF_INET6)
|
||||
{
|
||||
WSASetLastError(WSAEAFNOSUPPORT);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ZeroMemory(&any, sizeof(SOCKADDR_STORAGE));
|
||||
any.ss_family = af;
|
||||
|
||||
switch (af)
|
||||
{
|
||||
case AF_INET:
|
||||
{
|
||||
CopyMemory(&any4->sin_addr, cp, sizeof(IN_ADDR));
|
||||
AFlen = sizeof(SOCKADDR_IN);
|
||||
break;
|
||||
}
|
||||
case AF_INET6:
|
||||
{
|
||||
CopyMemory(&any6->sin6_addr, cp, sizeof(IN6_ADDR));
|
||||
AFlen = sizeof(SOCKADDR_IN6);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (WSAAddressToStringA(anyp, AFlen, NULL, buf, &Dlen) == SOCKET_ERROR)
|
||||
return NULL;
|
||||
return buf;
|
||||
}
|
||||
#elif defined (_WIN32)
|
||||
// w32api, ws2tcpip.h, r1.12
|
||||
static inline char* gai_strerror(int ecode)
|
||||
{
|
||||
static char message[1024+1];
|
||||
DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM
|
||||
| FORMAT_MESSAGE_IGNORE_INSERTS
|
||||
| FORMAT_MESSAGE_MAX_WIDTH_MASK;
|
||||
DWORD dwLanguageId = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
|
||||
FormatMessageA(dwFlags, NULL, ecode, dwLanguageId, message, 1024, NULL);
|
||||
return message;
|
||||
}
|
||||
#else
|
||||
#define HAVE_NTOP
|
||||
#endif
|
||||
|
||||
#ifndef INET_ADDRSTRLEN
|
||||
#define INET_ADDRSTRLEN 16
|
||||
#endif
|
||||
|
||||
static inline void printflags(int ai_flags)
|
||||
{
|
||||
printf("flags: %x(", ai_flags);
|
||||
if (ai_flags == 0)
|
||||
printf("NONE|");
|
||||
#ifdef AI_PASSIVE
|
||||
if ((ai_flags & AI_PASSIVE) == AI_PASSIVE)
|
||||
printf("AI_PASSIVE|");
|
||||
ai_flags &= ~AI_PASSIVE;
|
||||
#endif
|
||||
#ifdef AI_CANONNAME
|
||||
if ((ai_flags & AI_CANONNAME) == AI_CANONNAME)
|
||||
printf("AI_CANONNAME|");
|
||||
ai_flags &= ~AI_CANONNAME;
|
||||
#endif
|
||||
#ifdef AI_NUMERICHOST
|
||||
if ((ai_flags & AI_NUMERICHOST) == AI_NUMERICHOST)
|
||||
printf("AI_NUMERICHOST|");
|
||||
ai_flags &= ~AI_NUMERICHOST;
|
||||
#endif
|
||||
#ifdef AI_V4MAPPED
|
||||
if ((ai_flags & AI_V4MAPPED) == AI_V4MAPPED)
|
||||
printf("AI_V4MAPPED|");
|
||||
ai_flags &= ~AI_V4MAPPED;
|
||||
#endif
|
||||
#ifdef AI_ALL
|
||||
if ((ai_flags & AI_ALL) == AI_ALL)
|
||||
printf("AI_ALL|");
|
||||
ai_flags &= ~AI_ALL;
|
||||
#endif
|
||||
#ifdef AI_ADDRCONFIG
|
||||
if ((ai_flags & AI_ADDRCONFIG) == AI_ADDRCONFIG)
|
||||
printf("AI_ADDRCONFIG|");
|
||||
ai_flags &= ~AI_ADDRCONFIG;
|
||||
#endif
|
||||
#ifdef AI_IDN
|
||||
if ((ai_flags & AI_IDN) == AI_IDN)
|
||||
printf("AI_IDN|");
|
||||
ai_flags &= ~AI_IDN;
|
||||
#endif
|
||||
#ifdef AI_CANONIDN
|
||||
if ((ai_flags & AI_CANONIDN) == AI_CANONIDN)
|
||||
printf("AI_CANONIDN|");
|
||||
ai_flags &= ~AI_CANONIDN;
|
||||
#endif
|
||||
#ifdef AI_IDN_ALLOW_UNASSIGNED
|
||||
if ((ai_flags & AI_IDN_ALLOW_UNASSIGNED) == AI_IDN_ALLOW_UNASSIGNED)
|
||||
printf("AI_IDN_ALLOW_UNASSIGNED|");
|
||||
ai_flags &= ~AI_IDN_ALLOW_UNASSIGNED;
|
||||
#endif
|
||||
#ifdef AI_IDN_USE_STD3_ASCII_RULES
|
||||
if ((ai_flags & AI_IDN_USE_STD3_ASCII_RULES) == AI_IDN_USE_STD3_ASCII_RULES)
|
||||
printf("AI_IDN_USE_STD3_ASCII_RULES|");
|
||||
ai_flags &= ~AI_PASSIVE;
|
||||
#endif
|
||||
#ifdef AI_NUMERICSERV
|
||||
if ((ai_flags & AI_NUMERICSERV) == AI_NUMERICSERV)
|
||||
printf("AI_NUMERICSERV|");
|
||||
ai_flags &= ~AI_NUMERICSERV;
|
||||
#endif
|
||||
printf("%x", ai_flags);
|
||||
printf(")\n");
|
||||
}
|
||||
|
||||
static inline void printsocktype(int ai_socktype)
|
||||
{
|
||||
printf("socktype: %d(", ai_socktype);
|
||||
switch (ai_socktype)
|
||||
{
|
||||
case 0:
|
||||
printf("SOCK_ Woe32");
|
||||
break;
|
||||
case SOCK_STREAM:
|
||||
printf("SOCK_STREAM");
|
||||
break;
|
||||
case SOCK_DGRAM:
|
||||
printf("SOCK_DGRAM");
|
||||
break;
|
||||
case SOCK_RAW:
|
||||
printf("SOCK_RAW");
|
||||
break;
|
||||
default:
|
||||
printf("SOCK_ERROR\n");
|
||||
exit(-1);
|
||||
}
|
||||
printf(")\n");
|
||||
}
|
||||
|
||||
static inline void printprotocol(int ai_protocol)
|
||||
{
|
||||
printf("protocol: %d(", ai_protocol);
|
||||
switch (ai_protocol)
|
||||
{
|
||||
case IPPROTO_IP:
|
||||
printf("IPPROTO_IP");
|
||||
break;
|
||||
case IPPROTO_TCP:
|
||||
printf("IPPROTO_TCP");
|
||||
break;
|
||||
case IPPROTO_UDP:
|
||||
printf("IPPROTO_UDP");
|
||||
break;
|
||||
default:
|
||||
printf("IPPROTO_ERROR\n");
|
||||
exit(-1);
|
||||
}
|
||||
printf(")\n");
|
||||
}
|
||||
|
||||
static inline void printaddr(int ai_family, const struct sockaddr *ai_addr)
|
||||
{
|
||||
char str[INET_ADDRSTRLEN+1] = "FAKE";
|
||||
printf("family: %d(", ai_family);
|
||||
switch (ai_family)
|
||||
{
|
||||
case AF_UNSPEC:
|
||||
printf("AF_UNSPEC");
|
||||
break;
|
||||
case AF_INET:
|
||||
printf("AF_INET");
|
||||
break;
|
||||
#ifdef AF_INET6
|
||||
case AF_INET6:
|
||||
printf("AF_INET6");
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
printf("AF_ERROR\n");
|
||||
exit(-1);
|
||||
}
|
||||
printf(")\n");
|
||||
if (ai_family == AF_INET && ai_addr)
|
||||
{
|
||||
const struct sockaddr_in *ip4 = (void *)ai_addr;
|
||||
#ifdef HAVE_NTOP
|
||||
inet_ntop(ai_family, &ip4->sin_addr, str, INET_ADDRSTRLEN);
|
||||
#else
|
||||
strncpy(str, inet_ntoa(ip4->sin_addr), INET_ADDRSTRLEN);
|
||||
#endif
|
||||
printf("port: %d\n", ntohs(ip4->sin_port));
|
||||
}
|
||||
printf("addr: %s\n", str);
|
||||
}
|
||||
|
||||
void printaddrinfo(const struct my_addrinfo *data)
|
||||
{
|
||||
if(data == NULL)
|
||||
{
|
||||
printf("no data\n");
|
||||
return;
|
||||
}
|
||||
else
|
||||
printf("starting addrinfo dump\n");
|
||||
while (data != NULL)
|
||||
{
|
||||
printflags(data->ai_flags);
|
||||
printsocktype(data->ai_socktype);
|
||||
printaddr(data->ai_family, data->ai_addr);
|
||||
printprotocol(data->ai_protocol);
|
||||
//addrlen
|
||||
data = data->ai_next;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct my_addrinfo *res = NULL, hints;
|
||||
int gaie;
|
||||
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
memset(&hints, 0x00, sizeof(struct my_addrinfo));
|
||||
hints.ai_family = AF_INET;
|
||||
|
||||
#ifdef _WIN32
|
||||
{
|
||||
#ifdef USE_WINSOCK2
|
||||
const WORD VerNeed = MAKEWORD(2,2);
|
||||
#else
|
||||
const WORD VerNeed = MAKEWORD(1,1);
|
||||
#endif
|
||||
WSADATA WSAData;
|
||||
WSAStartup(VerNeed, &WSAData);
|
||||
}
|
||||
#endif
|
||||
printf("-----------------------------------------------------------\n");
|
||||
#ifndef _WIN32 //NULL as res crashes Win32
|
||||
gaie = I_getaddrinfo(NULL, NULL, &hints, NULL);
|
||||
if (gaie != EAI_NONAME)
|
||||
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
I_freeaddrinfo(res);
|
||||
#endif
|
||||
#if 0 //NULL as res crashes
|
||||
gaie = I_getaddrinfo("localhost", "5029", NULL, NULL);
|
||||
if (gaie == 0)
|
||||
printf("NULL crashes: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
I_freeaddrinfo(res);
|
||||
#endif
|
||||
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
hints.ai_flags = AI_NUMERICHOST;
|
||||
gaie = I_getaddrinfo("localhost", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo(NULL, "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULLs test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("localhost", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
gaie = I_getaddrinfo("127.0.0.1", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("127.0.0.1", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
gaie = I_getaddrinfo("255.255.255.255", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("255.255.255.255", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
printf("-----------------------------------------------------------\n");
|
||||
hints.ai_flags = AI_PASSIVE;
|
||||
gaie = I_getaddrinfo("0.0.0.0", NULL, &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("NULL service test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
gaie = I_getaddrinfo("0.0.0.0", "5029", &hints, &res);
|
||||
//if (gaie != 0)
|
||||
printf("no hints test returned: %s(%d)\n", gai_strerror(gaie), gaie);
|
||||
printaddrinfo(res);
|
||||
I_freeaddrinfo(res); res = NULL;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
@@ -1,71 +0,0 @@
|
||||
// SONIC ROBO BLAST 2
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2011-2018 by Sonic Team Junior.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file i_addrinfo.h
|
||||
/// \brief getaddrinfo stub
|
||||
|
||||
#ifndef __I_ADDRINFO__
|
||||
#define __I_ADDRINFO__
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#ifndef AI_PASSIVE
|
||||
#define AI_PASSIVE 0x01
|
||||
#endif
|
||||
#ifndef AI_NUMERICHOST
|
||||
#define AI_NUMERICHOST 0x04
|
||||
#endif
|
||||
#ifndef AI_V4MAPPED
|
||||
#define AI_V4MAPPED 0x08
|
||||
#endif
|
||||
#ifndef AI_ADDRCONFIG
|
||||
#define AI_ADDRCONFIG 0x20
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifndef EAI_NONAME
|
||||
#define EAI_NONAME WSAHOST_NOT_FOUND
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EAI_NONAME
|
||||
#define EAI_NONAME -2
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32 // already use the stub for Win32
|
||||
// w32api, ws2tcpip.h, r1.12
|
||||
struct my_addrinfo {
|
||||
int ai_flags;
|
||||
int ai_family;
|
||||
int ai_socktype;
|
||||
int ai_protocol;
|
||||
size_t ai_addrlen;
|
||||
char *ai_canonname;
|
||||
struct sockaddr *ai_addr;
|
||||
struct my_addrinfo *ai_next;
|
||||
};
|
||||
#else
|
||||
#define my_addrinfo addrinfo
|
||||
#endif
|
||||
|
||||
void WS_addrinfocleanup(void);
|
||||
|
||||
#ifndef my_addrinfo
|
||||
void I_freeaddrinfo(struct my_addrinfo *res);
|
||||
int I_getaddrinfo(const char *node, const char *service,
|
||||
const struct my_addrinfo *hints,
|
||||
struct my_addrinfo **res);
|
||||
#elif !defined (test_stub)
|
||||
#define I_getaddrinfo getaddrinfo
|
||||
#define I_freeaddrinfo freeaddrinfo
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
@@ -221,10 +221,6 @@ INT32 I_mkdir(const char *dirname, INT32 unixright);
|
||||
*/
|
||||
const char *I_LocateWad(void);
|
||||
|
||||
/** \brief Joystick events
|
||||
*/
|
||||
void I_GetJoystickEvents(UINT8 index);
|
||||
|
||||
char *I_GetEnv(const char *name);
|
||||
|
||||
INT32 I_PutEnv(char *variable);
|
||||
|
||||
+108
-119
@@ -28,43 +28,37 @@
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define USE_WINSOCK
|
||||
#if defined (_WIN64) || defined (HAVE_IPV6)
|
||||
#define USE_WINSOCK2
|
||||
#else //_WIN64/HAVE_IPV6
|
||||
#define USE_WINSOCK1
|
||||
#endif
|
||||
#define USE_WINSOCK
|
||||
#endif //WIN32 OS
|
||||
|
||||
#ifdef USE_WINSOCK2
|
||||
#include <ws2tcpip.h>
|
||||
#ifdef USE_WINSOCK
|
||||
#include <ws2tcpip.h>
|
||||
#define addrinfo_t ADDRINFOA
|
||||
#else
|
||||
#define addrinfo_t struct addrinfo
|
||||
#endif
|
||||
|
||||
#include "doomdef.h"
|
||||
|
||||
#ifndef USE_WINSOCK
|
||||
#include <arpa/inet.h>
|
||||
#ifdef __APPLE_CC__
|
||||
#ifndef _BSD_SOCKLEN_T_
|
||||
#define _BSD_SOCKLEN_T_
|
||||
#endif //_BSD_SOCKLEN_T_
|
||||
#endif //__APPLE_CC__
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#endif //normal BSD API
|
||||
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#ifdef USE_WINSOCK1
|
||||
#include <winsock.h>
|
||||
#else
|
||||
#ifndef USE_WINSOCK
|
||||
#include <arpa/inet.h>
|
||||
#ifdef __APPLE_CC__
|
||||
#ifndef _BSD_SOCKLEN_T_
|
||||
#define _BSD_SOCKLEN_T_
|
||||
#endif //_BSD_SOCKLEN_T_
|
||||
#endif //__APPLE_CC__
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/ioctl.h>
|
||||
#endif //normal BSD API
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
|
||||
#include <sys/time.h>
|
||||
#endif // UNIXCOMMON
|
||||
#endif
|
||||
#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON)
|
||||
#include <sys/time.h>
|
||||
#endif // UNIXCOMMON
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
// some undefined under win32
|
||||
@@ -152,27 +146,22 @@ static UINT8 UPNP_support = TRUE;
|
||||
#define close closesocket
|
||||
#endif
|
||||
|
||||
#include "i_addrinfo.h"
|
||||
#define DEFAULTPORT "5029"
|
||||
|
||||
#if defined (USE_WINSOCK)
|
||||
typedef SOCKET SOCKET_TYPE;
|
||||
#define ERRSOCKET (SOCKET_ERROR)
|
||||
#ifdef USE_WINSOCK
|
||||
typedef SOCKET SOCKET_TYPE;
|
||||
#define ERRSOCKET (SOCKET_ERROR)
|
||||
#else
|
||||
#if defined (__unix__) || defined (__APPLE__) || defined (__HAIKU__)
|
||||
typedef int SOCKET_TYPE;
|
||||
#else
|
||||
typedef unsigned long SOCKET_TYPE;
|
||||
#endif
|
||||
#define ERRSOCKET (-1)
|
||||
#if defined (__unix__) || defined (__APPLE__) || defined (__HAIKU__)
|
||||
typedef int SOCKET_TYPE;
|
||||
#else
|
||||
typedef unsigned long SOCKET_TYPE;
|
||||
#endif
|
||||
#define ERRSOCKET (-1)
|
||||
#endif
|
||||
|
||||
#define IPV6_MULTICAST_ADDRESS "ff15::57e1:1a12"
|
||||
|
||||
#ifdef USE_WINSOCK1
|
||||
typedef int socklen_t;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
mysockaddr_t address;
|
||||
@@ -232,9 +221,8 @@ static char *get_WSAErrorStr(int e)
|
||||
#define strerror get_WSAErrorStr
|
||||
#endif
|
||||
|
||||
#ifdef USE_WINSOCK2
|
||||
#ifdef USE_WINSOCK
|
||||
#define inet_ntop inet_ntopA
|
||||
#define HAVE_NTOP
|
||||
static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len)
|
||||
{
|
||||
DWORD Dlen = len, AFlen = 0;
|
||||
@@ -278,8 +266,6 @@ static const char* inet_ntopA(short af, const void *cp, char *buf, socklen_t len
|
||||
return NULL;
|
||||
return buf;
|
||||
}
|
||||
#elif !defined (USE_WINSOCK1)
|
||||
#define HAVE_NTOP
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MINIUPNPC // based on old XChat patch
|
||||
@@ -359,18 +345,15 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk)
|
||||
{
|
||||
static char s[64]; // 255.255.255.255:65535 or
|
||||
// [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]:65535
|
||||
|
||||
#ifdef HAVE_NTOP
|
||||
#ifdef HAVE_IPV6
|
||||
int v6 = (sk->any.sa_family == AF_INET6);
|
||||
#else
|
||||
int v6 = 0;
|
||||
#endif
|
||||
|
||||
void *addr;
|
||||
int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once
|
||||
|
||||
if(sk->any.sa_family == AF_INET)
|
||||
if (sk->any.sa_family == AF_INET)
|
||||
addr = &sk->ip4.sin_addr;
|
||||
#ifdef HAVE_IPV6
|
||||
else if(sk->any.sa_family == AF_INET6)
|
||||
@@ -379,9 +362,11 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk)
|
||||
else
|
||||
addr = NULL;
|
||||
|
||||
if(addr == NULL)
|
||||
if (addr == NULL)
|
||||
{
|
||||
sprintf(s, "No address");
|
||||
else if(inet_ntop(sk->any.sa_family, addr, &s[v6], sizeof (s) - v6) == NULL)
|
||||
}
|
||||
else if (inet_ntop(sk->any.sa_family, addr, &s[v6], sizeof (s) - v6) == NULL)
|
||||
{
|
||||
e = errno;
|
||||
sprintf(s, "Unknown family type, error #%u: %s", e, strerror(e));
|
||||
@@ -396,17 +381,9 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk)
|
||||
strcat(s, va(":%d", ntohs(sk->ip6.sin6_port)));
|
||||
}
|
||||
#endif
|
||||
else if(sk->any.sa_family == AF_INET && sk->ip4.sin_port != 0)
|
||||
else if (sk->any.sa_family == AF_INET && sk->ip4.sin_port != 0)
|
||||
strcat(s, va(":%d", ntohs(sk->ip4.sin_port)));
|
||||
#else
|
||||
if (sk->any.sa_family == AF_INET)
|
||||
{
|
||||
strcpy(s, inet_ntoa(sk->ip4.sin_addr));
|
||||
if (sk->ip4.sin_port != 0) strcat(s, va(":%d", ntohs(sk->ip4.sin_port)));
|
||||
}
|
||||
else
|
||||
sprintf(s, "Unknown type");
|
||||
#endif
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -504,7 +481,6 @@ static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// This is a hack. For some reason, nodes aren't being freed properly.
|
||||
// This goes through and cleans up what nodes were supposed to be freed.
|
||||
/** \warning This function causes the file downloading to stop if someone joins.
|
||||
@@ -659,7 +635,7 @@ static boolean SOCK_Get(void)
|
||||
c = recvfrom(mysockets[n], (char *)&doomcom->data, MAXPACKETLENGTH, 0,
|
||||
(void *)&fromaddress, &fromlen);
|
||||
|
||||
if (c > 0)
|
||||
if (c != ERRSOCKET)
|
||||
{
|
||||
#ifdef USE_STUN
|
||||
if (STUN_got_response(doomcom->data, c))
|
||||
@@ -675,25 +651,26 @@ static boolean SOCK_Get(void)
|
||||
#endif
|
||||
|
||||
// find remote node number
|
||||
for (j = 1; j <= MAXNETNODES; j++) //include LAN
|
||||
for (j = 1; j <= MAXNETNODES; j++) // include LAN
|
||||
{
|
||||
if (SOCK_cmpaddr(&fromaddress, &clientaddress[j], 0))
|
||||
{
|
||||
doomcom->remotenode = (INT16)j; // good packet from a game player
|
||||
doomcom->datalength = (INT16)c;
|
||||
nodesocket[j] = mysockets[n];
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// not found
|
||||
|
||||
// find a free slot
|
||||
j = getfreenode();
|
||||
|
||||
if (j > 0)
|
||||
{
|
||||
const time_t curTime = time(NULL);
|
||||
|
||||
M_Memcpy(&clientaddress[j], &fromaddress, fromlen);
|
||||
memcpy(&clientaddress[j], &fromaddress, fromlen);
|
||||
nodesocket[j] = mysockets[n];
|
||||
DEBFILE(va("New node detected: node:%d address:%s\n", j,
|
||||
SOCK_GetNodeAddress(j)));
|
||||
@@ -775,7 +752,7 @@ static void SOCK_Send(void)
|
||||
int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once
|
||||
size_t i, j;
|
||||
|
||||
if (!nodeconnected[doomcom->remotenode])
|
||||
if (doomcom->remotenode < 0 || !nodeconnected[doomcom->remotenode])
|
||||
return;
|
||||
|
||||
if (doomcom->remotenode == BROADCASTADDR)
|
||||
@@ -868,15 +845,11 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
||||
|
||||
#ifdef USE_WINSOCK
|
||||
{ // Alam_GBC: disable the new UDP connection reset behavior for Win2k and up
|
||||
#ifdef USE_WINSOCK2
|
||||
DWORD dwBytesReturned = 0;
|
||||
BOOL bfalse = FALSE;
|
||||
rc = WSAIoctl(s, SIO_UDP_CONNRESET, &bfalse, sizeof(bfalse),
|
||||
NULL, 0, &dwBytesReturned, NULL, NULL);
|
||||
#else
|
||||
unsigned long falseval = false;
|
||||
rc = ioctl(s, SIO_UDP_CONNRESET, &falseval);
|
||||
#endif
|
||||
|
||||
if (rc == -1)
|
||||
{
|
||||
e = errno;
|
||||
@@ -997,7 +970,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
||||
e = errno;
|
||||
I_OutputMsg("getting SO_RCVBUF failed: #%u, %s\n", e, strerror(e));
|
||||
}
|
||||
CONS_Printf(M_GetText("Network system buffer: %dKb\n"), opt>>10);
|
||||
CONS_Printf(M_GetText("Network receive buffer: %dKb\n"), opt>>10);
|
||||
|
||||
if (opt < 64<<10) // 64k
|
||||
{
|
||||
@@ -1018,9 +991,44 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
||||
}
|
||||
|
||||
if (opt < 64<<10)
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Can't set buffer length to 64k, file transfer will be bad\n"));
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Can't set receive buffer length to 64k, file transfer will be bad\n"));
|
||||
else
|
||||
CONS_Printf(M_GetText("Network system buffer set to: %dKb\n"), opt>>10);
|
||||
CONS_Printf(M_GetText("Network receive buffer set to: %dKb\n"), opt>>10);
|
||||
}
|
||||
|
||||
opt = 0;
|
||||
opts = (socklen_t)sizeof(opt);
|
||||
rc = getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&opt, &opts);
|
||||
if (rc <= -1)
|
||||
{
|
||||
e = errno;
|
||||
I_OutputMsg("getting SO_SNDBUF failed: #%u, %s\n", e, strerror(e));
|
||||
}
|
||||
CONS_Printf(M_GetText("Network send buffer: %dKb\n"), opt>>10);
|
||||
|
||||
if (opt < 64<<10) // 64k
|
||||
{
|
||||
opt = 64<<10;
|
||||
opts = (socklen_t)sizeof(opt);
|
||||
rc = setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&opt, opts);
|
||||
if (rc <= -1)
|
||||
{
|
||||
e = errno;
|
||||
I_OutputMsg("setting SO_SNDBUF to %dKb failed: #%u, %s\n", opt>>10, e, strerror(e));
|
||||
}
|
||||
|
||||
opt = 0;
|
||||
rc = getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *)&opt, &opts);
|
||||
if (rc <= -1)
|
||||
{
|
||||
e = errno;
|
||||
I_OutputMsg("getting SO_SNDBUF failed: #%u, %s\n", e, strerror(e));
|
||||
}
|
||||
|
||||
if (opt < 64<<10)
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Can't set send buffer length to 64k, file transfer will be bad\n"));
|
||||
else
|
||||
CONS_Printf(M_GetText("Network send system buffer set to: %dKb\n"), opt>>10);
|
||||
}
|
||||
|
||||
rc = getsockname(s, &straddr.any, &len);
|
||||
@@ -1046,7 +1054,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
|
||||
static boolean UDP_Socket(void)
|
||||
{
|
||||
size_t s;
|
||||
struct my_addrinfo *ai, *runp, hints;
|
||||
addrinfo_t *ai, *runp, hints;
|
||||
int gaie;
|
||||
#ifdef HAVE_IPV6
|
||||
const INT32 b_ipv6 = M_CheckParm("-ipv6");
|
||||
@@ -1075,7 +1083,7 @@ static boolean UDP_Socket(void)
|
||||
{
|
||||
while (M_IsNextParm())
|
||||
{
|
||||
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||
gaie = getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -1089,13 +1097,13 @@ static boolean UDP_Socket(void)
|
||||
}
|
||||
runp = runp->ai_next;
|
||||
}
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gaie = I_getaddrinfo("0.0.0.0", serv, &hints, &ai);
|
||||
gaie = getaddrinfo("0.0.0.0", serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -1116,7 +1124,7 @@ static boolean UDP_Socket(void)
|
||||
}
|
||||
runp = runp->ai_next;
|
||||
}
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1128,7 +1136,7 @@ static boolean UDP_Socket(void)
|
||||
{
|
||||
while (M_IsNextParm())
|
||||
{
|
||||
gaie = I_getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||
gaie = getaddrinfo(M_GetNextParm(), serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -1142,13 +1150,13 @@ static boolean UDP_Socket(void)
|
||||
}
|
||||
runp = runp->ai_next;
|
||||
}
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gaie = I_getaddrinfo("::", serv, &hints, &ai);
|
||||
gaie = getaddrinfo("::", serv, &hints, &ai);
|
||||
if (gaie == 0)
|
||||
{
|
||||
runp = ai;
|
||||
@@ -1162,7 +1170,7 @@ static boolean UDP_Socket(void)
|
||||
}
|
||||
runp = runp->ai_next;
|
||||
}
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1216,11 +1224,7 @@ boolean I_InitTcpDriver(void)
|
||||
if (!init_tcp_driver)
|
||||
{
|
||||
#ifdef USE_WINSOCK
|
||||
#ifdef USE_WINSOCK2
|
||||
const WORD VerNeed = MAKEWORD(2,2);
|
||||
#else
|
||||
const WORD VerNeed = MAKEWORD(1,1);
|
||||
#endif
|
||||
WSADATA WSAData;
|
||||
const int WSAresult = WSAStartup(VerNeed, &WSAData);
|
||||
if (WSAresult != 0)
|
||||
@@ -1247,21 +1251,14 @@ boolean I_InitTcpDriver(void)
|
||||
if (WSAresult != WSAVERNOTSUPPORTED)
|
||||
CONS_Debug(DBG_NETPLAY, "WinSock(TCP/IP) error: %s\n",WSError);
|
||||
}
|
||||
#ifdef USE_WINSOCK2
|
||||
if(LOBYTE(WSAData.wVersion) != 2 ||
|
||||
|
||||
if (LOBYTE(WSAData.wVersion) != 2 ||
|
||||
HIBYTE(WSAData.wVersion) != 2)
|
||||
{
|
||||
WSACleanup();
|
||||
CONS_Debug(DBG_NETPLAY, "No WinSock(TCP/IP) 2.2 driver detected\n");
|
||||
}
|
||||
#else
|
||||
if (LOBYTE(WSAData.wVersion) != 1 ||
|
||||
HIBYTE(WSAData.wVersion) != 1)
|
||||
{
|
||||
WSACleanup();
|
||||
CONS_Debug(DBG_NETPLAY, "No WinSock(TCP/IP) 1.1 driver detected\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
CONS_Debug(DBG_NETPLAY, "WinSock description: %s\n",WSAData.szDescription);
|
||||
CONS_Debug(DBG_NETPLAY, "WinSock System Status: %s\n",WSAData.szSystemStatus);
|
||||
#endif
|
||||
@@ -1301,35 +1298,31 @@ void I_ShutdownTcpDriver(void)
|
||||
|
||||
CONS_Printf("I_ShutdownTcpDriver: ");
|
||||
#ifdef USE_WINSOCK
|
||||
WS_addrinfocleanup();
|
||||
WSACleanup();
|
||||
#endif
|
||||
CONS_Printf("shut down\n");
|
||||
init_tcp_driver = false;
|
||||
}
|
||||
|
||||
static boolean SOCK_GetAddr(struct sockaddr_in *sin, const char *address, const char *port, boolean test)
|
||||
static boolean SOCK_GetAddr(mysockaddr_t *sin, const char *address, const char *port, boolean test)
|
||||
{
|
||||
struct my_addrinfo *ai = NULL, *runp, hints;
|
||||
addrinfo_t *ai, *runp, hints;
|
||||
int gaie;
|
||||
size_t i;
|
||||
|
||||
if (!port || !port[0])
|
||||
port = DEFAULTPORT;
|
||||
|
||||
memset (&hints, 0x00, sizeof (hints));
|
||||
memset(&hints, 0x00, sizeof (hints));
|
||||
hints.ai_flags = AI_ADDRCONFIG;
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
|
||||
gaie = I_getaddrinfo(address, port, &hints, &ai);
|
||||
gaie = getaddrinfo(address, port, &hints, &ai);
|
||||
|
||||
if (gaie != 0)
|
||||
{
|
||||
I_freeaddrinfo(ai);
|
||||
return false;
|
||||
}
|
||||
|
||||
runp = ai;
|
||||
|
||||
@@ -1356,7 +1349,7 @@ static boolean SOCK_GetAddr(struct sockaddr_in *sin, const char *address, const
|
||||
if (runp != NULL)
|
||||
memcpy(sin, runp->ai_addr, runp->ai_addrlen);
|
||||
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
|
||||
return (runp != NULL);
|
||||
}
|
||||
@@ -1369,7 +1362,7 @@ static SINT8 SOCK_NetMakeNodewPort(const char *address, const char *port)
|
||||
|
||||
if (newnode != -1)
|
||||
{
|
||||
if (!SOCK_GetAddr(&clientaddress[newnode].ip4, address, port, true))
|
||||
if (!SOCK_GetAddr(&clientaddress[newnode], address, port, true))
|
||||
{
|
||||
nodeconnected[newnode] = false;
|
||||
return -1;
|
||||
@@ -1397,7 +1390,7 @@ static void rendezvous(int size)
|
||||
|
||||
if (tic != refreshtic)
|
||||
{
|
||||
if (SOCK_GetAddr(&rzv.ip4, host, (port ? port : "7777"), false))
|
||||
if (SOCK_GetAddr(&rzv, host, (port ? port : "7777"), false))
|
||||
{
|
||||
refreshtic = tic;
|
||||
}
|
||||
@@ -1492,7 +1485,7 @@ static boolean SOCK_Ban(INT32 node)
|
||||
ban = numbans;
|
||||
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)
|
||||
{
|
||||
@@ -1554,7 +1547,7 @@ static boolean SOCK_SetUnbanTime(time_t timestamp)
|
||||
|
||||
static boolean SOCK_SetBanAddress(const char *address, const char *mask)
|
||||
{
|
||||
struct my_addrinfo *ai, *runp, hints;
|
||||
addrinfo_t *ai, *runp, hints;
|
||||
int gaie;
|
||||
|
||||
if (!address)
|
||||
@@ -1566,7 +1559,7 @@ static boolean SOCK_SetBanAddress(const char *address, const char *mask)
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
hints.ai_protocol = IPPROTO_UDP;
|
||||
|
||||
gaie = I_getaddrinfo(address, "0", &hints, &ai);
|
||||
gaie = getaddrinfo(address, "0", &hints, &ai);
|
||||
if (gaie != 0)
|
||||
return false;
|
||||
|
||||
@@ -1611,7 +1604,7 @@ static boolean SOCK_SetBanAddress(const char *address, const char *mask)
|
||||
runp = runp->ai_next;
|
||||
}
|
||||
|
||||
I_freeaddrinfo(ai);
|
||||
freeaddrinfo(ai);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1660,8 +1653,6 @@ boolean I_InitTcpNetwork(void)
|
||||
// FIXME: for dedicated server, numnodes needs to be set to 0 upon start
|
||||
if (dedicated)
|
||||
doomcom->numnodes = 0;
|
||||
/* else if (M_IsNextParm())
|
||||
doomcom->numnodes = (INT16)atoi(M_GetNextParm());*/
|
||||
else
|
||||
doomcom->numnodes = 1;
|
||||
|
||||
@@ -1746,5 +1737,3 @@ boolean I_InitTcpNetwork(void)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#include "i_addrinfo.c"
|
||||
+3
-1
@@ -94,8 +94,8 @@ INT32 VID_SetMode(INT32 modenum);
|
||||
\return name of video mode
|
||||
*/
|
||||
const char *VID_GetModeName(INT32 modenum);
|
||||
void VID_PrepareModeList(void); /// note hack for SDL
|
||||
|
||||
void VID_PrepareModeList(void);
|
||||
|
||||
/** \brief can video system do fullscreen
|
||||
*/
|
||||
@@ -143,6 +143,8 @@ boolean I_CheckNativeRes(void);
|
||||
|
||||
void I_SetBorderlessWindow(void);
|
||||
|
||||
void I_HandleControllerHatRepeat(void);
|
||||
|
||||
#ifdef USE_FBO_OGL
|
||||
|
||||
void RefreshOGLSDLSurface(void);
|
||||
|
||||
+1
-1
@@ -4333,7 +4333,7 @@ static void K_drawInput(void)
|
||||
target = 0;
|
||||
else // turning of multiple strengths!
|
||||
{
|
||||
target = ((abs(cmd->driftturn) - 1)/125)+1;
|
||||
target = ((abs(cmd->driftturn) - 1)/200)+1; // was 125, do we need another toggle for this? Zzz...
|
||||
if (target > 4)
|
||||
target = 4;
|
||||
if (cmd->driftturn < 0)
|
||||
|
||||
+6
-6
@@ -608,9 +608,6 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, bo
|
||||
if (color >= MAXTRANSLATIONS)
|
||||
I_Error("Invalid skin color #%hu.", (UINT16)color);
|
||||
|
||||
if (skinnum < 0 && skinnum > TC_DEFAULT)
|
||||
I_Error("Invalid translation colormap index %d.", skinnum);
|
||||
|
||||
starttranscolor = (skinnum != TC_DEFAULT) ? K_GetSkinArray(local)[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR;
|
||||
|
||||
if (starttranscolor >= NUM_PALETTE_ENTRIES)
|
||||
@@ -640,11 +637,14 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, bo
|
||||
UINT8 K_GetKartColorByName(const char *name)
|
||||
{
|
||||
UINT8 color = (UINT8)atoi(name);
|
||||
|
||||
if (color > 0 && color < MAXSKINCOLORS)
|
||||
return color;
|
||||
|
||||
for (color = 1; color < MAXSKINCOLORS; color++)
|
||||
if (!stricmp(KartColor_Names[color], name))
|
||||
if (fasticmp(KartColor_Names[color], name))
|
||||
return color;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2860,9 +2860,9 @@ void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32
|
||||
v[3] = FRACUNIT;
|
||||
|
||||
res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle));
|
||||
M_Memcpy(&v, res, sizeof (v));
|
||||
memcpy(&v, res, sizeof (v));
|
||||
res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle));
|
||||
M_Memcpy(&v, res, sizeof (v));
|
||||
memcpy(&v, res, sizeof (v));
|
||||
|
||||
finalx = x + v[0];
|
||||
finaly = y + v[1];
|
||||
|
||||
+43
-36
@@ -45,27 +45,33 @@ boolean luaL_checkboolean(lua_State *L, int narg) {
|
||||
// String concatination
|
||||
static int lib_concat(lua_State *L)
|
||||
{
|
||||
int n = lua_gettop(L); /* number of arguments */
|
||||
int i;
|
||||
char *r = NULL;
|
||||
size_t rl = 0,sl;
|
||||
lua_getglobal(L, "tostring");
|
||||
for (i=1; i<=n; i++) {
|
||||
const char *s;
|
||||
lua_pushvalue(L, -1); /* function to be called */
|
||||
lua_pushvalue(L, i); /* value to print */
|
||||
lua_call(L, 1, 1);
|
||||
s = lua_tolstring(L, -1, &sl); /* get result */
|
||||
if (s == NULL)
|
||||
return luaL_error(L, LUA_QL("tostring") " must return a string to "
|
||||
LUA_QL("__add"));
|
||||
int n = lua_gettop(L); /* number of arguments */
|
||||
int i;
|
||||
char *r = NULL;
|
||||
size_t rl = 0, sl;
|
||||
lua_getglobal(L, "tostring");
|
||||
for (i=1; i<=n; i++) {
|
||||
const char *s;
|
||||
lua_pushvalue(L, -1); /* function to be called */
|
||||
lua_pushvalue(L, i); /* value to print */
|
||||
lua_call(L, 1, 1);
|
||||
s = lua_tolstring(L, -1, &sl); /* get result */
|
||||
|
||||
if (sl == 0) {
|
||||
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);
|
||||
M_Memcpy(r+rl, s, sl);
|
||||
memcpy(r+rl, s, sl);
|
||||
rl += sl;
|
||||
lua_pop(L, 1); /* pop result */
|
||||
}
|
||||
lua_pushlstring(L, r, rl);
|
||||
Z_Free(r);
|
||||
lua_pop(L, 1); /* pop result */
|
||||
}
|
||||
lua_pushlstring(L, r, rl);
|
||||
Z_Free(r);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -73,23 +79,24 @@ static int lib_concat(lua_State *L)
|
||||
// Copied from base Lua code
|
||||
static int lib_print(lua_State *L)
|
||||
{
|
||||
int n = lua_gettop(L); /* number of arguments */
|
||||
int i;
|
||||
//HUDSAFE
|
||||
lua_getglobal(L, "tostring");
|
||||
for (i=1; i<=n; i++) {
|
||||
const char *s;
|
||||
lua_pushvalue(L, -1); /* function to be called */
|
||||
lua_pushvalue(L, i); /* value to print */
|
||||
lua_call(L, 1, 1);
|
||||
s = lua_tostring(L, -1); /* get result */
|
||||
if (s == NULL)
|
||||
return luaL_error(L, LUA_QL("tostring") " must return a string to "
|
||||
LUA_QL("print"));
|
||||
if (i>1) CONS_Printf("\n");
|
||||
CONS_Printf("%s", s);
|
||||
lua_pop(L, 1); /* pop result */
|
||||
}
|
||||
int n = lua_gettop(L); /* number of arguments */
|
||||
int i;
|
||||
//HUDSAFE
|
||||
lua_getglobal(L, "tostring");
|
||||
for (i=1; i<=n; i++) {
|
||||
const char *s;
|
||||
lua_pushvalue(L, -1); /* function to be called */
|
||||
lua_pushvalue(L, i); /* value to print */
|
||||
lua_call(L, 1, 1);
|
||||
s = lua_tostring(L, -1); /* get result */
|
||||
|
||||
if (s == NULL)
|
||||
return luaL_error(L, LUA_QL("tostring") " must return a string to "
|
||||
LUA_QL("print"));
|
||||
if (i>1) CONS_Printf("\n");
|
||||
CONS_Printf("%s", s);
|
||||
lua_pop(L, 1); /* pop result */
|
||||
}
|
||||
CONS_Printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
+62
-57
@@ -28,13 +28,29 @@
|
||||
|
||||
#define NOHUD if (hud_running) return luaL_error(L, "HUD rendering code should not call this function!");
|
||||
|
||||
static const char *cvname = NULL;
|
||||
static consvar_t *this_cvar;
|
||||
|
||||
void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
||||
static void clear_lua_stack(void)
|
||||
{
|
||||
if (gL) // check if Lua is actually turned on first, you dummmy -- Monster Iestyn 04/07/18
|
||||
lua_settop(gL, 0); // clear stack
|
||||
}
|
||||
|
||||
void Got_Luacmd(const UINT8 **cp, INT32 playernum)
|
||||
{
|
||||
UINT8 i, argc, flags;
|
||||
const char *argv[256];
|
||||
char buf[256];
|
||||
|
||||
argc = READUINT8(*cp);
|
||||
argv[0] = (const char*)*cp;
|
||||
SKIPSTRINGN(*cp, 255);
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
argv[i] = (const char*)*cp;
|
||||
SKIPSTRINGN(*cp, 255);
|
||||
}
|
||||
|
||||
// don't use I_Assert here, goto the deny code below
|
||||
// to clean up and kick people who try nefarious exploits
|
||||
// like sending random junk lua commands to crash the server
|
||||
@@ -47,8 +63,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, "COM_Command"); // push COM_Command
|
||||
if (!lua_istable(gL, -1)) goto deny;
|
||||
|
||||
argc = READUINT8(*cp);
|
||||
READSTRINGN(*cp, buf, 255);
|
||||
strlcpy(buf, argv[0], 255);
|
||||
strlwr(buf); // must lowercase buffer
|
||||
lua_getfield(gL, -1, buf); // push command info table
|
||||
if (!lua_istable(gL, -1)) goto deny;
|
||||
@@ -74,10 +89,17 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
||||
|
||||
lua_remove(gL, -2); // pop command info table
|
||||
|
||||
if (!lua_checkstack(gL, argc)) // player + command arguments
|
||||
{
|
||||
clear_lua_stack();
|
||||
CONS_Alert(CONS_WARNING, "lua command stack overflow from %s (%d, need %d more)\n", player_names[playernum], lua_gettop(gL), argc);
|
||||
return;
|
||||
}
|
||||
|
||||
LUA_PushUserdata(gL, &players[playernum], META_PLAYER);
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
READSTRINGN(*cp, buf, 255);
|
||||
strlcpy(buf, argv[i], 255);
|
||||
lua_pushstring(gL, buf);
|
||||
}
|
||||
LUA_Call(gL, (int)argc, 0, 1); // argc is 1-based, so this will cover the player we passed too.
|
||||
@@ -88,8 +110,7 @@ void Got_Luacmd(UINT8 **cp, INT32 playernum)
|
||||
|
||||
deny:
|
||||
//must be hacked/buggy client
|
||||
if (gL) // check if Lua is actually turned on first, you dummmy -- Monster Iestyn 04/07/18
|
||||
lua_settop(gL, 0); // clear stack
|
||||
clear_lua_stack();
|
||||
|
||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal lua command received from %s\n"), player_names[playernum]);
|
||||
if (server)
|
||||
@@ -133,7 +154,7 @@ void COM_Lua_f(void)
|
||||
{
|
||||
if (!splitscreen)
|
||||
{
|
||||
lua_pop(gL, 1); // pop command info table
|
||||
lua_pop(gL, 2); // pop command info table and LUA_GetErrorMessage
|
||||
return; // can't execute splitscreen command without player 2!
|
||||
}
|
||||
|
||||
@@ -178,6 +199,13 @@ void COM_Lua_f(void)
|
||||
I_Assert(lua_isfunction(gL, -1));
|
||||
lua_remove(gL, -2); // pop command info table
|
||||
|
||||
if (!lua_checkstack(gL, COM_Argc() + 1))
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "lua command stack overflow (%d, need %s more)\n", lua_gettop(gL), sizeu1(COM_Argc() + 1));
|
||||
lua_pop(gL, 2); // pop function and LUA_GetErrorMessage
|
||||
return;
|
||||
}
|
||||
|
||||
LUA_PushUserdata(gL, &players[playernum], META_PLAYER);
|
||||
for (i = 1; i < COM_Argc(); i++)
|
||||
lua_pushstring(gL, COM_Argv(i));
|
||||
@@ -284,16 +312,13 @@ static int lib_comBufInsertText(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LUA_CVarChanged(const char *name)
|
||||
void LUA_CVarChanged(void *cvar)
|
||||
{
|
||||
cvname = name;
|
||||
this_cvar = cvar;
|
||||
}
|
||||
|
||||
static void Lua_OnChange(void)
|
||||
{
|
||||
I_Assert(gL != NULL);
|
||||
I_Assert(cvname != NULL);
|
||||
|
||||
/// \todo Network this! XD_LUAVAR
|
||||
|
||||
// Why?..
|
||||
@@ -305,13 +330,10 @@ static void Lua_OnChange(void)
|
||||
// From CV_OnChange registry field, get the function for this cvar by name.
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, "CV_OnChange");
|
||||
I_Assert(lua_istable(gL, -1));
|
||||
lua_getfield(gL, -1, cvname); // get function
|
||||
lua_pushlightuserdata(gL, this_cvar);
|
||||
lua_rawget(gL, -2); // get function
|
||||
|
||||
// From the CV_Vars registry field, get the cvar's userdata by name.
|
||||
lua_getfield(gL, LUA_REGISTRYINDEX, "CV_Vars");
|
||||
I_Assert(lua_istable(gL, -1));
|
||||
lua_getfield(gL, -1, cvname); // get consvar_t* userdata.
|
||||
lua_remove(gL, -2); // pop the CV_Vars table.
|
||||
LUA_RawPushUserdata(gL, this_cvar);
|
||||
|
||||
LUA_Call(gL, 1, 0, error_handler_i); // call function(cvar)
|
||||
lua_pop(gL, 2); // pop CV_OnChange table and error handler
|
||||
@@ -329,9 +351,8 @@ static int lib_cvRegisterVar(lua_State *L)
|
||||
luaL_checktype(L, 1, LUA_TTABLE);
|
||||
lua_settop(L, 1); // Clear out all other possible arguments, leaving only the first one.
|
||||
NOHUD
|
||||
cvar = lua_newuserdata(L, sizeof(consvar_t));
|
||||
luaL_getmetatable(L, META_CVAR);
|
||||
lua_setmetatable(L, -2);
|
||||
cvar = ZZ_Calloc(sizeof(consvar_t));
|
||||
LUA_PushUserdata(L, cvar, META_CVAR);
|
||||
|
||||
#define FIELDERROR(f, e) luaL_error(L, "bad value for " LUA_QL(f) " in table passed to " LUA_QL("CV_RegisterVar") " (%s)", e);
|
||||
#define TYPEERROR(f, t) FIELDERROR(f, va("%s expected, got %s", lua_typename(L, t), luaL_typename(L, -1)))
|
||||
@@ -384,7 +405,7 @@ static int lib_cvRegisterVar(lua_State *L)
|
||||
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "CV_PossibleValue");
|
||||
I_Assert(lua_istable(L, 5));
|
||||
lua_pushvalue(L, 2); // cvar userdata
|
||||
lua_pushlightuserdata(L, cvar);
|
||||
cvpv = lua_newuserdata(L, sizeof(CV_PossibleValue_t) * (count+1));
|
||||
lua_rawset(L, 5);
|
||||
lua_pop(L, 1); // pop CV_PossibleValue registry table
|
||||
@@ -412,13 +433,14 @@ static int lib_cvRegisterVar(lua_State *L)
|
||||
TYPEERROR("func", LUA_TFUNCTION)
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "CV_OnChange");
|
||||
I_Assert(lua_istable(L, 5));
|
||||
lua_pushlightuserdata(L, cvar);
|
||||
lua_pushvalue(L, 4);
|
||||
lua_setfield(L, 5, cvar->name);
|
||||
lua_rawset(L, 5);
|
||||
lua_pop(L, 1);
|
||||
cvar->func = Lua_OnChange;
|
||||
}
|
||||
else if (((i == 5 && !(cvar->flags & CV_CALL))
|
||||
|| (cvar->flags & CV_CALL && i == 6))
|
||||
|| (cvar->flags & CV_CALL && i == 6))
|
||||
|| (k && fasticmp(k, "category")))
|
||||
{
|
||||
category = lua_isnoneornil(L, 4) ? NULL : lua_tostring(L, 4);
|
||||
@@ -434,18 +456,12 @@ static int lib_cvRegisterVar(lua_State *L)
|
||||
#undef FIELDERROR
|
||||
#undef TYPEERROR
|
||||
|
||||
// stack: cvar table, cvar userdata
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "CV_Vars");
|
||||
I_Assert(lua_istable(L, 3));
|
||||
|
||||
lua_getfield(L, 3, cvar->name);
|
||||
if (lua_type(L, -1) != LUA_TNIL)
|
||||
return luaL_error(L, M_GetText("Variable %s is already defined\n"), cvar->name);
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_pushvalue(L, 2);
|
||||
lua_setfield(L, 3, cvar->name);
|
||||
lua_pop(L, 1);
|
||||
if (!cvar->name)
|
||||
return luaL_error(L, M_GetText("Variable has no name!\n"));
|
||||
if ((cvar->flags & CV_NOINIT) && !(cvar->flags & CV_CALL))
|
||||
return luaL_error(L, M_GetText("Variable %s has CV_NOINIT without CV_CALL\n"), cvar->name);
|
||||
if ((cvar->flags & CV_CALL) && !cvar->func)
|
||||
return luaL_error(L, M_GetText("Variable %s has CV_CALL without a function\n"), cvar->name);
|
||||
|
||||
// actually time to register it to the console now! Finally!
|
||||
cvar->flags |= CV_MODIFIED;
|
||||
@@ -453,7 +469,7 @@ static int lib_cvRegisterVar(lua_State *L)
|
||||
if (cvar->flags & CV_MODIFIED)
|
||||
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)
|
||||
{
|
||||
@@ -477,22 +493,9 @@ static int lib_cvRegisterVar(lua_State *L)
|
||||
|
||||
static int lib_cvFindVar(lua_State *L)
|
||||
{
|
||||
consvar_t *cv;
|
||||
if (( cv = CV_FindVar(luaL_checkstring(L,1)) ))
|
||||
{
|
||||
lua_settop(L,1);/* We only want one argument in the stack. */
|
||||
lua_pushlightuserdata(L, cv);/* Now the second value on stack. */
|
||||
luaL_getmetatable(L, META_CVAR);
|
||||
/*
|
||||
The metatable is the last value on the stack, so this
|
||||
applies it to the second value, which is the cvar.
|
||||
*/
|
||||
lua_setmetatable(L,2);
|
||||
lua_pushvalue(L,2);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
const char *name = luaL_checkstring(L, 1);
|
||||
LUA_PushUserdata(L, CV_FindVar(name), META_CVAR);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int CVarSetFunction
|
||||
@@ -501,7 +504,7 @@ static int CVarSetFunction
|
||||
void (*Set)(consvar_t *, const char *),
|
||||
void (*SetValue)(consvar_t *, INT32)
|
||||
){
|
||||
consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR);
|
||||
consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR);
|
||||
|
||||
switch (lua_type(L, 2))
|
||||
{
|
||||
@@ -530,7 +533,8 @@ static int lib_cvStealthSet(lua_State *L)
|
||||
|
||||
static int lib_cvAddValue(lua_State *L)
|
||||
{
|
||||
consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR);
|
||||
consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR);
|
||||
|
||||
CV_AddValue(cvar, (INT32)luaL_checknumber(L, 2));
|
||||
return 0;
|
||||
}
|
||||
@@ -545,6 +549,7 @@ static int lib_consPrintf(lua_State *L)
|
||||
if (n < 2)
|
||||
return luaL_error(L, "CONS_Printf requires at least two arguments: player and text.");
|
||||
//HUDSAFE
|
||||
|
||||
plr = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
|
||||
if (!plr)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
@@ -605,7 +610,7 @@ static int cvar_fields_ref = LUA_NOREF;
|
||||
|
||||
static int cvar_get(lua_State *L)
|
||||
{
|
||||
consvar_t *cvar = (consvar_t *)luaL_checkudata(L, 1, META_CVAR);
|
||||
consvar_t *cvar = *(consvar_t **)luaL_checkudata(L, 1, META_CVAR);
|
||||
enum cvar_e field = Lua_optoption(L, 2, -1, cvar_fields_ref);
|
||||
|
||||
switch (field)
|
||||
|
||||
+3
-3
@@ -83,7 +83,7 @@ FUNCINLINE static ATTRINLINE unsigned hook_in_list
|
||||
|
||||
for (type = 0; list[type] != NULL; ++type)
|
||||
{
|
||||
if (strcmp(name, list[type]) == 0)
|
||||
if (fastcmp(name, list[type]))
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ static int lib_addHook(lua_State *L)
|
||||
{
|
||||
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);
|
||||
}*/
|
||||
@@ -818,7 +818,7 @@ typedef struct {
|
||||
|
||||
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)
|
||||
|
||||
+3
-3
@@ -455,12 +455,12 @@ int mobj_localskin_setter(lua_State *L)
|
||||
strlcpy(skin, luaL_optstring(L, 2, "none"), sizeof skin);
|
||||
strlwr(skin); // all skin names are lowercase
|
||||
|
||||
if (stricmp(skin, "none"))
|
||||
if (!fasticmp(skin, "none"))
|
||||
{
|
||||
// Try localskins
|
||||
for (i = 0; i < numlocalskins; i++)
|
||||
{
|
||||
if (stricmp(localskins[i].name, skin) == 0)
|
||||
if (fasticmp(localskins[i].name, skin))
|
||||
{
|
||||
mo->localskin = &localskins[i];
|
||||
mo->skinlocal = true;
|
||||
@@ -471,7 +471,7 @@ int mobj_localskin_setter(lua_State *L)
|
||||
// Try other skins
|
||||
for (i = 0; i < numskins; i++)
|
||||
{
|
||||
if (stricmp(skins[i].name, skin) == 0)
|
||||
if (fasticmp(skins[i].name, skin))
|
||||
{
|
||||
mo->localskin = &skins[i];
|
||||
mo->skinlocal = false;
|
||||
|
||||
+86
-19
@@ -288,6 +288,10 @@ void LUA_LoadLump(UINT16 wad, UINT16 lump)
|
||||
lumpinfo_t *lump_p = &wadfiles[wad]->lumpinfo[lump];
|
||||
len += 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name
|
||||
name = malloc(len+1);
|
||||
|
||||
if (!name)
|
||||
I_Error("LUA_LoadLump: Out of memory!\n");
|
||||
|
||||
sprintf(name, "%s|%s", wadfiles[wad]->filename, lump_p->fullname);
|
||||
name[len] = '\0';
|
||||
}
|
||||
@@ -488,25 +492,37 @@ void LUA_InvalidateMathlibCache(const char *name)
|
||||
// Pushes it to the stack and stores it in the registry.
|
||||
void LUA_PushUserdata(lua_State *L, void *data, const char *meta)
|
||||
{
|
||||
if (LUA_RawPushUserdata(L, data) == LPUSHED_NEW)
|
||||
{
|
||||
luaL_getmetatable(L, meta);
|
||||
lua_setmetatable(L, -2);
|
||||
}
|
||||
}
|
||||
|
||||
// Same as LUA_PushUserdata but don't set a metatable yet.
|
||||
lpushed_t LUA_RawPushUserdata(lua_State *L, void *data)
|
||||
{
|
||||
lpushed_t status = LPUSHED_NIL;
|
||||
|
||||
void **userdata;
|
||||
|
||||
if (!data) { // push a NULL
|
||||
lua_pushnil(L);
|
||||
return;
|
||||
return status;
|
||||
}
|
||||
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, LREG_VALID);
|
||||
I_Assert(lua_istable(L, -1));
|
||||
|
||||
lua_pushlightuserdata(L, data);
|
||||
lua_rawget(L, -2);
|
||||
|
||||
if (lua_isnil(L, -1)) { // no userdata? deary me, we'll have to make one.
|
||||
lua_pop(L, 1); // pop the nil
|
||||
|
||||
// create the userdata
|
||||
userdata = lua_newuserdata(L, sizeof(void *));
|
||||
*userdata = data;
|
||||
luaL_getmetatable(L, meta);
|
||||
lua_setmetatable(L, -2);
|
||||
|
||||
// Set it in the registry so we can find it again
|
||||
lua_pushlightuserdata(L, data); // k (store the userdata via the data's pointer)
|
||||
@@ -514,8 +530,15 @@ void LUA_PushUserdata(lua_State *L, void *data, const char *meta)
|
||||
lua_rawset(L, -4);
|
||||
|
||||
// stack is left with the userdata on top, as if getting it had originally succeeded.
|
||||
|
||||
status = LPUSHED_NEW;
|
||||
}
|
||||
else
|
||||
status = LPUSHED_EXISTING;
|
||||
|
||||
lua_remove(L, -2); // remove LREG_VALID
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
// When userdata is freed, use this function to remove it from Lua.
|
||||
@@ -797,8 +820,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
mobj_t *mobj = *((mobj_t **)lua_touserdata(gL, myindex));
|
||||
if (!mobj)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_MOBJ);
|
||||
WRITEUINT32(*p, mobj->mobjnum);
|
||||
}
|
||||
@@ -808,8 +835,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
player_t *player = *((player_t **)lua_touserdata(gL, myindex));
|
||||
if (!player)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_PLAYER);
|
||||
WRITEUINT8(*p, player - players);
|
||||
}
|
||||
@@ -819,8 +850,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
mapthing_t *mapthing = *((mapthing_t **)lua_touserdata(gL, myindex));
|
||||
if (!mapthing)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_MAPTHING);
|
||||
WRITEUINT16(*p, mapthing - mapthings);
|
||||
}
|
||||
@@ -830,8 +865,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
vertex_t *vertex = *((vertex_t **)lua_touserdata(gL, myindex));
|
||||
if (!vertex)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_VERTEX);
|
||||
WRITEUINT16(*p, vertex - vertexes);
|
||||
}
|
||||
@@ -841,8 +880,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
line_t *line = *((line_t **)lua_touserdata(gL, myindex));
|
||||
if (!line)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_LINE);
|
||||
WRITEUINT16(*p, line - lines);
|
||||
}
|
||||
@@ -852,8 +895,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
side_t *side = *((side_t **)lua_touserdata(gL, myindex));
|
||||
if (!side)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_SIDE);
|
||||
WRITEUINT16(*p, side - sides);
|
||||
}
|
||||
@@ -863,8 +910,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
subsector_t *subsector = *((subsector_t **)lua_touserdata(gL, myindex));
|
||||
if (!subsector)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_SUBSECTOR);
|
||||
WRITEUINT16(*p, subsector - subsectors);
|
||||
}
|
||||
@@ -874,8 +925,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
sector_t *sector = *((sector_t **)lua_touserdata(gL, myindex));
|
||||
if (!sector)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_SECTOR);
|
||||
WRITEUINT16(*p, sector - sectors);
|
||||
}
|
||||
@@ -885,8 +940,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex));
|
||||
if (!slope)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_SLOPE);
|
||||
WRITEUINT16(*p, slope->id);
|
||||
}
|
||||
@@ -896,8 +955,12 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex)
|
||||
{
|
||||
mapheader_t *header = *((mapheader_t **)lua_touserdata(gL, myindex));
|
||||
if (!header)
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_NULL);
|
||||
else {
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT8(*p, ARCH_MAPHEADER);
|
||||
WRITEUINT16(*p, header - *mapheaderinfo);
|
||||
}
|
||||
@@ -1003,19 +1066,23 @@ static void ArchiveTables(UINT8 **p)
|
||||
e = ArchiveValue(p, TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this.
|
||||
if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise)
|
||||
{
|
||||
lua_pushvalue(gL, -2);
|
||||
CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -1), luaL_typename(gL, -1), i);
|
||||
lua_pop(gL, 1);
|
||||
CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -2), luaL_typename(gL, -2), i);
|
||||
}
|
||||
else if (e == 3) // nil key due to invalid userdata. NOT an error.
|
||||
{
|
||||
lua_pop(gL, 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Write value
|
||||
e = ArchiveValue(p, TABLESINDEX, -1);
|
||||
if (e == 1)
|
||||
{
|
||||
n++; // the table contained a new table we'll have to archive. :(
|
||||
}
|
||||
else if (e == 2) // invalid value type
|
||||
{
|
||||
lua_pushvalue(gL, -2);
|
||||
CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -1), luaL_typename(gL, -1));
|
||||
lua_pop(gL, 1);
|
||||
CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -2), luaL_typename(gL, -1));
|
||||
}
|
||||
|
||||
lua_pop(gL, 1);
|
||||
|
||||
+10
-2
@@ -59,7 +59,15 @@ fixed_t LUA_GetConstant(const char *word);
|
||||
// Need better name for this ;-;
|
||||
void LUA_InvalidateMathlibCache(const char *name);
|
||||
|
||||
typedef enum {
|
||||
LPUSHED_NIL,
|
||||
LPUSHED_NEW,
|
||||
LPUSHED_EXISTING,
|
||||
} lpushed_t;
|
||||
|
||||
void LUA_PushUserdata(lua_State *L, void *data, const char *meta);
|
||||
lpushed_t LUA_RawPushUserdata(lua_State *L, void *data);
|
||||
|
||||
void LUA_InvalidateUserdata(void *data);
|
||||
void LUA_InvalidateLevel(void);
|
||||
void LUA_InvalidateMapthings(void);
|
||||
@@ -68,8 +76,8 @@ void LUA_InvalidatePlayer(player_t *player);
|
||||
void LUA_Archive(savebuffer_t *save, boolean network);
|
||||
void LUA_UnArchive(savebuffer_t *save, boolean network);
|
||||
|
||||
void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c
|
||||
void LUA_CVarChanged(const char *name); // lua_consolelib.c
|
||||
void Got_Luacmd(const UINT8 **cp, INT32 playernum); // lua_consolelib.c
|
||||
void LUA_CVarChanged(void *cvar); // lua_consolelib.c
|
||||
int Lua_optoption(lua_State *L, int narg, int def, int list_ref);
|
||||
int Lua_CreateFieldTable(lua_State *L, const char *const lst[]);
|
||||
void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save);
|
||||
|
||||
@@ -192,7 +192,7 @@ lzf_decompress (const void *const in_data, size_t in_len,
|
||||
#endif
|
||||
|
||||
#if USE_MEMCPY
|
||||
M_Memcpy (op, ip, ctrl);
|
||||
memcpy(op, ip, ctrl);
|
||||
op += ctrl;
|
||||
ip += ctrl;
|
||||
#else
|
||||
@@ -435,7 +435,7 @@ lzf_compress (const void *const in_data,size_t in_len,
|
||||
|
||||
*op++ = MAX_LIT - 1;
|
||||
#if USE_MEMCPY
|
||||
M_Memcpy (op, ip - MAX_LIT, MAX_LIT);
|
||||
memcpy(op, ip - MAX_LIT, MAX_LIT);
|
||||
op += MAX_LIT;
|
||||
lit = 0;
|
||||
#else
|
||||
|
||||
+2
-2
@@ -183,7 +183,7 @@ static aatree_node_t *M_AATreeSetString_Node(aatree_node_t *node, UINT32 flags,
|
||||
else
|
||||
{
|
||||
aatree_entry_t *entry = node->value;
|
||||
if (entry != NULL && strcmp(entry->key, key) != 0)
|
||||
if (entry != NULL && !fastcmp(entry->key, key))
|
||||
entry = entry->next;
|
||||
if (entry != NULL)
|
||||
{
|
||||
@@ -252,7 +252,7 @@ void *M_AATreeGetString(aatree_t *aatree, const char *key)
|
||||
I_Assert((aatree->flags & AATREE_STRING) == AATREE_STRING);
|
||||
UINT32 hash = FNV1a_HashString(key);
|
||||
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;
|
||||
return entry != NULL ? entry->value : NULL;
|
||||
}
|
||||
|
||||
+6
-4
@@ -49,7 +49,7 @@ INT32 M_CheckParm(const char *check)
|
||||
|
||||
for (i = 1; i < myargc; i++)
|
||||
{
|
||||
if (!strcasecmp(check, myargv[i]))
|
||||
if (fasticmp(check, myargv[i]))
|
||||
{
|
||||
found = i;
|
||||
return i;
|
||||
@@ -69,16 +69,18 @@ INT32 M_CheckProtoParam(const char *check)
|
||||
|
||||
for (i = 1; i < myargc; i++)
|
||||
{
|
||||
if (strncmp(myargv[i], "srb2kart://", 11) == 0)
|
||||
if (strncmp(myargv[i], "srb2kart://", 11) == 0)
|
||||
{
|
||||
if (strncmp(myargv[i]+11, check, strlen(check))==0)
|
||||
if (strncmp(myargv[i]+11, check, strlen(check)) == 0)
|
||||
{
|
||||
found = i;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
found = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -93,7 +95,7 @@ const char *M_GetProtoParam(void)
|
||||
|
||||
for (i = 1; i < myargc; i++)
|
||||
{
|
||||
if (strncmp(myargv[i], "srb2kart://", 11) == 0)
|
||||
if (strncmp(myargv[i], "srb2kart://", 11) == 0)
|
||||
{
|
||||
string = strchr(myargv[i], '/');
|
||||
string = strchr(string+1, '/');
|
||||
|
||||
+4
-4
@@ -92,7 +92,7 @@ void M_LoadEmotes(UINT16 wadnum)
|
||||
if (emote_name.size() > MAXEMOTENAME)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "EMOTES: Emote name is too long, truncating. (file %s, line %d)\n", wadfiles[wadnum]->filename, linenum);
|
||||
emote_name = emote_name.substr(0, MAXEMOTENAME);
|
||||
emote_name.resize(MAXEMOTENAME);
|
||||
}
|
||||
|
||||
emote = &emotes[emote_name];
|
||||
@@ -112,7 +112,7 @@ void M_LoadEmotes(UINT16 wadnum)
|
||||
trim(field);
|
||||
trim(value);
|
||||
|
||||
if (stricmp(field.c_str(), "frames") == 0)
|
||||
if (fasticmp(field.c_str(), "frames"))
|
||||
{
|
||||
UINT8 numframes = 0;
|
||||
|
||||
@@ -139,7 +139,7 @@ void M_LoadEmotes(UINT16 wadnum)
|
||||
if (framelumpname.size() > 8)
|
||||
{
|
||||
CONS_Alert(CONS_WARNING, "EMOTES: Frame %d name is too long. (file %s, line %d)", numframes, wadfiles[wadnum]->filename, linenum);
|
||||
framelumpname = framelumpname.substr(0, 8);
|
||||
framelumpname.resize(8);
|
||||
}
|
||||
|
||||
std::strncpy(emote->frames[numframes], framelumpname.c_str(), framelumpname.size()+1);
|
||||
@@ -158,7 +158,7 @@ void M_LoadEmotes(UINT16 wadnum)
|
||||
|
||||
emote->numframes = numframes;
|
||||
}
|
||||
else if (stricmp(field.c_str(), "timeperframe") == 0)
|
||||
else if (fasticmp(field.c_str(), "timeperframe"))
|
||||
{
|
||||
emote->timeperframe = std::stoi(value);
|
||||
|
||||
|
||||
+3
-3
@@ -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)
|
||||
{
|
||||
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)
|
||||
@@ -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)
|
||||
{
|
||||
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)
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
M_Memcpy(dest, &result, sizeof(matrix_t));
|
||||
memcpy(dest, &result, sizeof(matrix_t));
|
||||
|
||||
#undef R
|
||||
#undef D
|
||||
|
||||
+42
-56
@@ -702,7 +702,13 @@ static void M_CheckStringItem(void)
|
||||
|
||||
// Just in case
|
||||
memset(menu_text_input_buf, 0, sizeof menu_text_input_buf);
|
||||
M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf);
|
||||
|
||||
// special case: name input, cap it to prevent writing outside the textbox
|
||||
// kinda ugly but itll work
|
||||
if (cv == &cv_playername)
|
||||
M_TextInputInit(&menuinput, menu_text_input_buf, MAXPLAYERNAME +1);
|
||||
else
|
||||
M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf);
|
||||
|
||||
M_TextInputSetString(&menuinput, cv->string);
|
||||
}
|
||||
@@ -753,8 +759,6 @@ static void Command_Manual_f(void)
|
||||
itemOn = 0;
|
||||
}
|
||||
|
||||
boolean dpadscrollstate[4] = {false, false, false, false};
|
||||
|
||||
//
|
||||
// M_Responder
|
||||
//
|
||||
@@ -801,19 +805,15 @@ boolean M_Responder(event_t *ev)
|
||||
break;
|
||||
case KEY_HAT1:
|
||||
ch = KEY_UPARROW;
|
||||
dpadscrollstate[DPAD_UP] = true;
|
||||
break;
|
||||
case KEY_HAT1 + 1:
|
||||
ch = KEY_DOWNARROW;
|
||||
dpadscrollstate[DPAD_DOWN] = true;
|
||||
break;
|
||||
case KEY_HAT1 + 2:
|
||||
ch = KEY_LEFTARROW;
|
||||
dpadscrollstate[DPAD_LEFT] = true;
|
||||
break;
|
||||
case KEY_HAT1 + 3:
|
||||
ch = KEY_RIGHTARROW;
|
||||
dpadscrollstate[DPAD_RIGHT] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -829,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)
|
||||
{
|
||||
tic_t thistime = I_GetTime();
|
||||
@@ -1725,6 +1707,9 @@ void M_Ticker(void)
|
||||
if (dedicated)
|
||||
return;
|
||||
|
||||
if (menuactive)
|
||||
I_HandleControllerHatRepeat();
|
||||
|
||||
if (--skullAnimCounter <= 0)
|
||||
skullAnimCounter = 8;
|
||||
|
||||
@@ -3107,7 +3092,7 @@ static void M_AddonsInternal(void)
|
||||
break;
|
||||
}
|
||||
|
||||
strlcpy(menupath, pathname, 1024);
|
||||
strlcpy(menupath, pathname, MAXFILEPATH);
|
||||
menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath) + 1;
|
||||
|
||||
if (menupath[menupathindex[menudepthleft]-2] != PATHSEP[0])
|
||||
@@ -3220,9 +3205,9 @@ static void M_DrawTemperature(INT32 x, fixed_t t)
|
||||
static char *M_AddonsHeaderPath(void)
|
||||
{
|
||||
UINT32 len;
|
||||
static char header[1024];
|
||||
static char header[MAXFILEPATH];
|
||||
|
||||
strlcpy(header, va("%s folder%s", cv_addons_option.string, menupath+menupathindex[menudepth-1]-1), 1024);
|
||||
strlcpy(header, va("%s folder%s", cv_addons_option.string, menupath+menupathindex[menudepth-1]-1), MAXFILEPATH);
|
||||
len = strlen(header);
|
||||
if (len > 34)
|
||||
{
|
||||
@@ -3713,10 +3698,10 @@ static void M_HandleAddons(INT32 choice)
|
||||
break;
|
||||
case EXT_TXT:
|
||||
case EXT_CFG:
|
||||
if ((strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, CONFIGFILENAME) == 0)
|
||||
|| (strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, AUTOLOADCONFIGFILENAME) == 0)
|
||||
|| (strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, "kartserv.cfg") == 0)
|
||||
|| (strcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, "kartexec.cfg") == 0))
|
||||
if (fastcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, CONFIGFILENAME)
|
||||
|| fastcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, AUTOLOADCONFIGFILENAME)
|
||||
|| fastcmp(dirmenu[dir_on[menudepthleft]]+DIR_STRING, "kartserv.cfg")
|
||||
|| 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);
|
||||
S_StartSound(NULL, sfx_s26d);
|
||||
@@ -3824,7 +3809,7 @@ static void ReplayNamesLoadThread(void* userdata)
|
||||
|
||||
Lock_search_state();
|
||||
|
||||
if (strcmp(menupath, replaydirpath) == 0)
|
||||
if (fastcmp(menupath, replaydirpath))
|
||||
{
|
||||
memcpy(demolist_all, demolist_all_local, sizeof(menudemo_t)*sizedirmenu);
|
||||
replaynamesloaded = true;
|
||||
@@ -3958,9 +3943,7 @@ static void PrepReplayList(boolean reset)
|
||||
|
||||
Lock_search_state();
|
||||
|
||||
if (demolist_all)
|
||||
Z_Free(demolist_all);
|
||||
|
||||
Z_Free(demolist_all);
|
||||
demolist_all = Z_Calloc(sizeof(menudemo_t) * sizedirmenu, PU_STATIC, NULL);
|
||||
|
||||
for (i = 0; i < sizedirmenu; i++)
|
||||
@@ -3978,9 +3961,9 @@ static void PrepReplayList(boolean reset)
|
||||
else
|
||||
{
|
||||
demolist_all[i].type = MD_NOTLOADED;
|
||||
// FIXME - do something with buffer sizes. menupath is 1024 chars but filepath is only
|
||||
// 256. I'm not really sure what to do here but don't want to leave warnings...
|
||||
snprintf(demolist_all[i].filepath, 255, "%.254s%s", menupath, dirmenu[i] + DIR_STRING);
|
||||
snprintf(demolist_all[i].filepath, sizeof(demolist_all[i].filepath),
|
||||
// 255 = UINT8 limit. dirmenu entries are restricted to this length (see DIR_LEN).
|
||||
"%s%.255s", menupath, dirmenu[i] + DIR_STRING);
|
||||
sprintf(demolist_all[i].title, ".....");
|
||||
}
|
||||
}
|
||||
@@ -4335,7 +4318,7 @@ static void DrawReplayHutReplayInfo(void)
|
||||
static void M_DrawReplayHut(void)
|
||||
{
|
||||
INT32 x, y, cursory = 0;
|
||||
INT16 i;
|
||||
INT32 i;
|
||||
INT16 replaylistitem = currentMenu->numitems-2;
|
||||
boolean processed_one_this_frame = false;
|
||||
const INT32 scaledviewheight = (vid.height/vid.dup);
|
||||
@@ -4408,7 +4391,7 @@ static void M_DrawReplayHut(void)
|
||||
V_DrawCenteredString(160, 100, V_ALLOWLOWERCASE, msg);
|
||||
}
|
||||
|
||||
for (i = 0; i < (INT16)replayqueryfound; i++)
|
||||
for (i = 0; i < (INT32)replayqueryfound; i++)
|
||||
{
|
||||
INT32 localy = y+i*10;
|
||||
INT32 localx = x;
|
||||
@@ -6952,9 +6935,9 @@ static void M_ConnectMenuModChecks(INT32 choice)
|
||||
(void)choice;
|
||||
// okay never mind we want to COMMUNICATE to the player pre-emptively instead of letting them try and then get confused when it doesn't work
|
||||
|
||||
if (modifiedgame || autoloaded)
|
||||
if (modifiedgame)
|
||||
{
|
||||
M_StartMessage(M_GetText("You have addons loaded.\nYou won't be able to join netgames!\n\nTo play online, restart the game\nand don't load any addons.\nSRB2Kart will automatically add\neverything you need when you join.\n\n(Press a key)\n"),M_ConnectMenu,MM_EVENTHANDLER);
|
||||
M_StartMessage("You have addons loaded.\nYou won't be able to join netgames!\n\nTo play online, restart the game\nand don't load any addons.\nSRB2Kart will automatically add\neverything you need when you join.\n\n(Press a key)\n", M_ConnectMenu, MM_EVENTHANDLER);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7175,17 +7158,21 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
|
||||
namescroll = 0;
|
||||
}
|
||||
|
||||
if (renderisnewtic) namescroll++;
|
||||
if (renderisnewtic)
|
||||
namescroll++;
|
||||
|
||||
char *addonname = wadfiles[mapwads[cv_nextmap.value-1]]->filename;
|
||||
INT32 len;
|
||||
INT32 charlimit = min((size_t)(21 + (dupadjust/5)), sizeof(namescrollbuf)-1);
|
||||
|
||||
nameonly(addonname);
|
||||
len = strlen(addonname);
|
||||
|
||||
if (len > charlimit)
|
||||
M_ScrollString(addonname, len, namescrollbuf, charlimit, namescroll);
|
||||
else
|
||||
strncpy(namescrollbuf, addonname, sizeof(namescrollbuf));
|
||||
strncpy(namescrollbuf, addonname, sizeof(namescrollbuf) - 1);
|
||||
|
||||
V_DrawThinString(x+w+5, y+i-8, V_TRANSLUCENT|MENUCAPS, namescrollbuf); // variable reuse...
|
||||
}
|
||||
|
||||
@@ -8275,12 +8262,12 @@ static void M_DrawSetupMultiPlayerMenu(void)
|
||||
|
||||
sprframe = &sprdef->spriteframes[frame];
|
||||
|
||||
//minenice's speen css, it's a piece of shit but hey
|
||||
// minenice's speen css, it's a piece of shit but hey
|
||||
speenframe = (I_GetTime()*cv_skinselectspin.value/TICRATE + 1)%8;
|
||||
|
||||
//this is a very shitty solution for checking if a sprite needs flipping
|
||||
//but it works
|
||||
if ((sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]) && (speenframe > 4))
|
||||
// this is a very shitty solution for checking if a sprite needs flipping
|
||||
// but it works
|
||||
if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]))
|
||||
flags = V_FLIP; // This sprite is left/right flipped!
|
||||
|
||||
patch = (patch_t *)W_CachePatchNum(sprframe->lumppat[speenframe], PU_PATCH);
|
||||
@@ -8800,7 +8787,7 @@ static boolean M_QuitMultiPlayerMenu(void)
|
||||
size_t l;
|
||||
|
||||
// send name if changed
|
||||
if (strcmp(setupm_name, setupm_cvname->string))
|
||||
if (!fastcmp(setupm_name, setupm_cvname->string))
|
||||
{
|
||||
// remove trailing whitespaces
|
||||
for (l= strlen(setupm_name)-1;
|
||||
@@ -9442,9 +9429,8 @@ static void M_VideoModeMenu(INT32 choice)
|
||||
|
||||
memset(modedescs, 0, sizeof(modedescs));
|
||||
|
||||
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
VID_PrepareModeList(); // FIXME: hack
|
||||
#endif
|
||||
|
||||
vidm_nummodes = 0;
|
||||
vidm_selected = 0;
|
||||
nummodes = VID_NumModes();
|
||||
@@ -9462,7 +9448,7 @@ static void M_VideoModeMenu(INT32 choice)
|
||||
// VESA mode, which is always a higher modenum
|
||||
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
|
||||
if (modedescs[j].modenum)
|
||||
@@ -9636,7 +9622,7 @@ static void M_DrawLocalSkinMenu(void)
|
||||
|
||||
//this is a very shitty solution for checking if a sprite needs flipping
|
||||
//but it works
|
||||
if ((sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]) && (speenframe > 4))
|
||||
if ((speenframe > 4) && (sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]))
|
||||
{
|
||||
flags = V_FLIP; // This sprite is left/right flipped!
|
||||
}
|
||||
@@ -10335,9 +10321,9 @@ static const char *M_GetDiscordName(discordRequest_t *r)
|
||||
return "";
|
||||
|
||||
if (cv_discordstreamer.value)
|
||||
return r->username;
|
||||
return DRPC_HideUsername(r->username);
|
||||
|
||||
return va("%s#%s", r->username, r->discriminator);
|
||||
return r->username;
|
||||
}
|
||||
|
||||
// (this goes in k_hud.c when merged into v2)
|
||||
|
||||
@@ -38,16 +38,6 @@ extern boolean forceshowhud;
|
||||
// Does all the real work of the menu interaction.
|
||||
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.
|
||||
boolean M_DemoResponder(event_t *ev);
|
||||
|
||||
|
||||
+92
-56
@@ -645,10 +645,20 @@ static menuitem_t OP_ControlsMenu[] =
|
||||
{IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30},
|
||||
{IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40},
|
||||
|
||||
{IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 60},
|
||||
{IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 55},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 80},
|
||||
{IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 90},
|
||||
{IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 75},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P1)", &cv_turnsmooth[0], 85},
|
||||
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P2)", &cv_turnsmooth[1], 95},
|
||||
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P3)", &cv_turnsmooth[2], 105},
|
||||
{IT_STRING | IT_CVAR, NULL, "Digital turn easing (P4)", &cv_turnsmooth[3], 115},
|
||||
|
||||
// i hate our menus sincerly
|
||||
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P1)", &cv_litesteer[0], 135},
|
||||
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P2)", &cv_litesteer[1], 145},
|
||||
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P3)", &cv_litesteer[2], 155},
|
||||
{IT_STRING | IT_CVAR, NULL, "Lite Steer (P4)", &cv_litesteer[3], 165},
|
||||
};
|
||||
|
||||
static const char* OP_ControlsTooltips[] =
|
||||
@@ -659,7 +669,15 @@ static const char* OP_ControlsTooltips[] =
|
||||
"Setup player 4 controls.",
|
||||
"Options for mouse control.",
|
||||
"Allowed amount of controls per key.",
|
||||
"Turn smoothing for non-analog turning.",
|
||||
"Turn smoothing for non-analog turning (Player 1).",
|
||||
"Turn smoothing for non-analog turning (Player 2).",
|
||||
"Turn smoothing for non-analog turning (Player 3).",
|
||||
"Turn smoothing for non-analog turning (Player 4).",
|
||||
|
||||
"Hold DOWN on d-pad/keyboard for shallow turns (Player 1).",
|
||||
"Hold DOWN on d-pad/keyboard for shallow turns (Player 2).",
|
||||
"Hold DOWN on d-pad/keyboard for shallow turns (Player 3).",
|
||||
"Hold DOWN on d-pad/keyboard for shallow turns (Player 4).",
|
||||
};
|
||||
|
||||
static menuitem_t OP_AllControlsMenu[] =
|
||||
@@ -800,26 +818,31 @@ static menuitem_t OP_VideoOptionsMenu[] =
|
||||
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
{IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 20},
|
||||
#endif
|
||||
#ifdef BACKWARDSCOMPATCORRECTION
|
||||
{IT_STRING | IT_CVAR | IT_CV_SLIDER,
|
||||
NULL, "Brightness", &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},
|
||||
NULL, "Gamma", &cv_globalgamma, 30},
|
||||
#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[] =
|
||||
@@ -828,11 +851,12 @@ static const char* OP_VideoTooltips[] =
|
||||
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
"Enable fullscreen.",
|
||||
#endif
|
||||
"Gamma (brightness) of the game.",
|
||||
"Saturation of the game.",
|
||||
"Increase the gamma of the displayed image.",
|
||||
"Increase or decrease the brightness of the displayed image.",
|
||||
"Reduce the saturation of the displayed image.",
|
||||
"Advanced color settings of the game.",
|
||||
"How far away objects are drawn.",
|
||||
"How far away weather is drawn.",
|
||||
"How far objects can be drawn.",
|
||||
"Affects how far weather visuals can be drawn.",
|
||||
"Show current game framerate and select the style.",
|
||||
"Sync game framerate to refresh rate of monitor.",
|
||||
"Set manual framerate cap.",
|
||||
@@ -851,7 +875,10 @@ enum
|
||||
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||
op_video_fullscreen,
|
||||
#endif
|
||||
#ifdef BACKWARDSCOMPATCORRECTION
|
||||
op_video_gamma,
|
||||
#endif
|
||||
op_video_bright,
|
||||
op_video_sat,
|
||||
op_video_color,
|
||||
op_video_dd,
|
||||
@@ -880,37 +907,37 @@ static menuitem_t OP_ColorOptionsMenu[] =
|
||||
{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, "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_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, "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_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, "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_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, "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_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, "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_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, "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[] =
|
||||
@@ -926,21 +953,23 @@ static menuitem_t OP_ExpOptionsMenu[] =
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 40},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 50},
|
||||
{IT_STRING | IT_CVAR, NULL, "Precache Level Textures", &cv_precachetextures, 50},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Frameskip", &cv_frameskip, 60},
|
||||
{IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 60},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Votescreen Scaling", &cv_votebgscaling, 70},
|
||||
{IT_STRING | IT_CVAR, NULL, "Frameskip", &cv_frameskip, 70},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Votescreen Scaling", &cv_votebgscaling, 80},
|
||||
|
||||
#ifdef HWRENDER
|
||||
{IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 80},
|
||||
{IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 90},
|
||||
#ifdef USE_FBO_OGL
|
||||
{IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 85},
|
||||
{IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 95},
|
||||
{IT_DISABLED, NULL, "", NULL, 105}, // dummy text
|
||||
{IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 95},
|
||||
{IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 105},
|
||||
{IT_DISABLED, NULL, "", NULL, 115}, // dummy text
|
||||
#else
|
||||
{IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 90},
|
||||
{IT_DISABLED, NULL, "", NULL, 100}, // dummy text
|
||||
{IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 100},
|
||||
{IT_DISABLED, NULL, "", NULL, 110}, // dummy text
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
@@ -950,16 +979,17 @@ static const char* OP_ExpTooltips[] =
|
||||
NULL,
|
||||
"How far Mobj interpolation should take effect.",
|
||||
"When weather is on this will cut the object amount used in half.",
|
||||
"Sets minimum sector brightness, useful for dark areas",
|
||||
"Sets minimum sector brightness, useful for dark areas.",
|
||||
//"Should the directional lightning be randomized each map?\nTakes effect on next map load.",
|
||||
"Toggle being able to see the sky.",
|
||||
"Change the FPS counter sampling method\nInaccurate updates slower and might miss frame drops and such\nAccurate updates faster and is more accurate, but might be less readable", // how to ingles??
|
||||
"Skips rendering frames if game logic takes too long preventing issues during performance drops." // idk im shit as describing things
|
||||
"Preload all level textures on level load.\nMassively reduces texture related stuttering during gameplay\nat the cost of longer level loading times.\nDisable this if you experience timeouts during level switches.",
|
||||
"Change the FPS counter sampling method\nInaccurate updates slower\nand might miss sudden framerate changes and drops,\nproviding a more averaged result.\nAccurate updates faster, but might be less readable.", // how to ingles??
|
||||
"Skips rendering frames if game logic takes too long\npreventing gameplay issues during performance drops.", // idk im shit as describing things
|
||||
"Different methods of scaling the votescreen backgrounds.",
|
||||
#ifdef HWRENDER
|
||||
"Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.",
|
||||
#ifdef USE_FBO_OGL
|
||||
"Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode. Requires a GPU with atleast OpenGL 3.0 support.",
|
||||
"Allows the game to downsample from a higher resolution\nthan your display in OpenGL renderer mode.\nRequires a GPU with atleast OpenGL 2.1 support.",
|
||||
#endif
|
||||
"Change the bit depth of the Lookup Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.",
|
||||
#endif
|
||||
@@ -973,6 +1003,7 @@ enum
|
||||
op_exp_secbright,
|
||||
//op_exp_dirlight,
|
||||
op_exp_skybox,
|
||||
op_exp_texcache,
|
||||
op_exp_accuratefps,
|
||||
op_exp_frameskip,
|
||||
op_exp_votescrn,
|
||||
@@ -1131,8 +1162,10 @@ static menuitem_t OP_SoundAdvancedMenu[] =
|
||||
{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, "Audio Buffer Size", &cv_audbuffersize, 90},
|
||||
{IT_DISABLED, NULL, "", NULL, 100}, // dummy text
|
||||
{IT_STRING | IT_CVAR, NULL, "Cache Sound", &cv_cachesound, 90},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 95},
|
||||
{IT_DISABLED, NULL, "", NULL, 105}, // dummy text
|
||||
};
|
||||
|
||||
static const char* OP_SoundAdvancedTooltips[] =
|
||||
@@ -1153,7 +1186,10 @@ static const char* OP_SoundAdvancedTooltips[] =
|
||||
"Should the Invulnerability music be on or off?",
|
||||
"Should music be kept when restarting the map?",
|
||||
"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.",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static menuitem_t OP_FocusOptionsMenu[] =
|
||||
@@ -1357,15 +1393,15 @@ static menuitem_t OP_Player4CamOptionsMenu[] =
|
||||
static const char* OP_PlayerCamOptionsTooltips[] =
|
||||
{
|
||||
NULL,
|
||||
"Should the Camera flip on gravity flipped sections?.",
|
||||
"Should the Camera flip on gravity flipped sections?",
|
||||
"Camera distance relative to the Player.",
|
||||
"Height of the Camera",
|
||||
"Pitch Camera on Upwards or Downhill Slopes",
|
||||
"Speed of the Camera",
|
||||
"Should looking back inherit the Players Momentum?\nEither inherit Player Momentum or double of it\nmay make looking back while boosting or going in high speed less jarring",
|
||||
"Height of the Camera.",
|
||||
"Pitch Camera on Upwards or Downhill Slopes.",
|
||||
"Speed of the Camera.",
|
||||
"Should looking back inherit the Players Momentum?\nEither inherit Player Momentum or double of it\nmay make looking back while boosting or going in high speed less jarring.",
|
||||
"Allows looking up/down by holding\naim forward/backward while standing still.",
|
||||
"Speed of the Freecam/Spectator Camera",
|
||||
"Toggle between Third or First Person camera",
|
||||
"Speed of the Freecam/Spectator Camera.",
|
||||
"Toggle between Third or First Person camera.",
|
||||
};
|
||||
|
||||
// Ok it's still called chatoptions but we'll put ping display in here to be clean
|
||||
@@ -1745,7 +1781,7 @@ static const char* OP_PlayerDistortTooltips[] =
|
||||
"Distance object rotation should be visable.",
|
||||
"Player rotation when sliptiding.",
|
||||
"Rotation of a player's boost trails and drift sparks.",
|
||||
"Should banans rotate when thrown?\nAnd should they stay rotated when on the ground?.",
|
||||
"Should banans rotate when thrown?\nAnd should they stay rotated when on the ground?",
|
||||
"Player squash and stretch.",
|
||||
"Player landing sound effect.",
|
||||
"Kart hopping while drifting. This is purely visual.",
|
||||
@@ -2424,7 +2460,7 @@ menu_t OP_MainDef =
|
||||
NULL
|
||||
};
|
||||
|
||||
menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30, OP_ControlsTooltips);
|
||||
menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 40, 15, OP_ControlsTooltips);
|
||||
//WTF
|
||||
menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30, OP_MouseTooltips);
|
||||
menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef);
|
||||
|
||||
+2
-2
@@ -423,7 +423,7 @@ void Command_SaveConfig_f(void)
|
||||
FIL_ForceExtension(tmpstr, ".cfg");
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -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!
|
||||
texturesToken = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL);
|
||||
// Copy the string.
|
||||
M_Memcpy(texturesToken, stringToUse+startPos, (size_t)texturesTokenLength);
|
||||
memcpy(texturesToken, stringToUse+startPos, (size_t)texturesTokenLength);
|
||||
// Make the final character NUL.
|
||||
texturesToken[texturesTokenLength] = '\0';
|
||||
return texturesToken;
|
||||
|
||||
+1
-1
@@ -916,7 +916,7 @@ static void draw_think_frame_stats(int hook_length, ps_hookinfo_t *hook)
|
||||
int len = (int)strlen(str);
|
||||
char* str_ptr;
|
||||
|
||||
if (strcmp(".lua", str + len - 4) == 0)
|
||||
if (fastcmp(".lua", str + len - 4))
|
||||
{
|
||||
str[len-4] = '\0'; // remove .lua at end
|
||||
}
|
||||
|
||||
+2
-2
@@ -239,8 +239,8 @@ void M_TextInputClear(textinput_t *input)
|
||||
void M_TextInputSetString(textinput_t *input, const char *c)
|
||||
{
|
||||
memset(input->buffer, 0, input->buffer_size);
|
||||
strcpy(input->buffer, c);
|
||||
input->cursor = input->select = input->length = strlen(c);
|
||||
strncpy(input->buffer, c, input->buffer_size);
|
||||
input->cursor = input->select = input->length = strlen(input->buffer);
|
||||
}
|
||||
|
||||
static boolean M_TextInputHandleBase(textinput_t *input, INT32 key, boolean emotes)
|
||||
|
||||
+8
-8
@@ -28,8 +28,8 @@
|
||||
|
||||
boolean LUA_CallAction(enum actionnum actionnum, void *thing);
|
||||
|
||||
INT32 var1;
|
||||
INT32 var2;
|
||||
INT32 var1 = 0;
|
||||
INT32 var2 = 0;
|
||||
|
||||
//
|
||||
// P_NewChaseDir related LUT.
|
||||
@@ -945,9 +945,9 @@ void A_PointyThink(void *thing)
|
||||
v[3] = FRACUNIT;
|
||||
|
||||
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));
|
||||
M_Memcpy(&v, res, sizeof (v));
|
||||
memcpy(&v, res, sizeof (v));
|
||||
|
||||
P_UnsetThingPosition(ball);
|
||||
ball->x = actor->x + v[0];
|
||||
@@ -4929,9 +4929,9 @@ void A_MaceRotate(void *thing)
|
||||
|
||||
// Calculate the angle matrixes for the link.
|
||||
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));
|
||||
M_Memcpy(&v, res, sizeof(v));
|
||||
memcpy(&v, res, sizeof(v));
|
||||
}
|
||||
// Rotating Chain.
|
||||
else
|
||||
@@ -4950,9 +4950,9 @@ void A_MaceRotate(void *thing)
|
||||
|
||||
// Calculate the angle matrixes for the link.
|
||||
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));
|
||||
M_Memcpy(&v, res, sizeof(v));
|
||||
memcpy(&v, res, sizeof(v));
|
||||
}
|
||||
|
||||
// Add on the appropriate distances to the actor's co-ordinates.
|
||||
|
||||
+54
-36
@@ -41,32 +41,32 @@
|
||||
|
||||
#include "m_perfstats.h" // ps_checkposition_calls
|
||||
|
||||
fixed_t tmbbox[4];
|
||||
mobj_t *tmthing;
|
||||
fixed_t tmbbox[4] = {};
|
||||
mobj_t *tmthing = NULL;
|
||||
static INT32 tmflags;
|
||||
fixed_t tmx;
|
||||
fixed_t tmy;
|
||||
fixed_t tmx = 0;
|
||||
fixed_t tmy = 0;
|
||||
|
||||
// If "floatok" true, move would be ok
|
||||
// if within "tmfloorz - tmceilingz".
|
||||
boolean floatok;
|
||||
boolean floatok = false;
|
||||
|
||||
fixed_t tmfloorz, tmceilingz;
|
||||
static fixed_t tmdropoffz, tmdrpoffceilz; // drop-off floor/ceiling heights
|
||||
mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector
|
||||
mobj_t *tmhitthing; // the solid thing you bumped into (for collisions)
|
||||
pslope_t *tmfloorslope, *tmceilingslope;
|
||||
fixed_t tmfloorz = 0, tmceilingz = 0;
|
||||
static fixed_t tmdropoffz = 0, tmdrpoffceilz = 0; // drop-off floor/ceiling heights
|
||||
mobj_t *tmfloorthing = NULL; // the thing corresponding to tmfloorz or NULL if tmfloorz is from a sector
|
||||
mobj_t *tmhitthing = NULL; // the solid thing you bumped into (for collisions)
|
||||
pslope_t *tmfloorslope = NULL, *tmceilingslope = NULL;
|
||||
|
||||
// keep track of the line that lowers the ceiling,
|
||||
// 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()
|
||||
// that is, for any line which is 'solid'
|
||||
line_t *blockingline;
|
||||
line_t *blockingline = NULL;
|
||||
|
||||
msecnode_t *sector_list = NULL;
|
||||
camera_t *mapcampointer;
|
||||
camera_t *mapcampointer = NULL;
|
||||
|
||||
//
|
||||
// TELEPORT MOVE
|
||||
@@ -708,7 +708,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
|
||||
HU_SetCEchoFlags(0);
|
||||
HU_SetCEchoDuration(5);
|
||||
HU_DoCEcho(va("%s\\was hit by a kitchen sink.\\\\\\\\", player_names[thing->player-players]));
|
||||
I_OutputMsg("%s was hit by a kitchen sink.\n", player_names[thing->player-players]);
|
||||
//I_OutputMsg("%s was hit by a kitchen sink.\n", player_names[thing->player-players]);
|
||||
P_DamageMobj(thing, tmthing, tmthing->target, DMG_INSTAKILL);
|
||||
P_KillMobj(tmthing, thing, thing);
|
||||
}
|
||||
@@ -977,7 +977,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
|
||||
HU_SetCEchoFlags(0);
|
||||
HU_SetCEchoDuration(5);
|
||||
HU_DoCEcho(va("%s\\was hit by a kitchen sink.\\\\\\\\", player_names[tmthing->player-players]));
|
||||
I_OutputMsg("%s was hit by a kitchen sink.\n", player_names[tmthing->player-players]);
|
||||
//I_OutputMsg("%s was hit by a kitchen sink.\n", player_names[tmthing->player-players]);
|
||||
P_DamageMobj(tmthing, thing, thing->target, DMG_INSTAKILL);
|
||||
P_KillMobj(thing, tmthing, tmthing);
|
||||
}
|
||||
@@ -2189,7 +2189,7 @@ static boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
|
||||
//
|
||||
boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
|
||||
{
|
||||
subsector_t *s;
|
||||
subsector_t *subsec;
|
||||
UINT8 i;
|
||||
|
||||
floatok = false;
|
||||
@@ -2198,9 +2198,9 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
|
||||
return false;
|
||||
|
||||
if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL)
|
||||
s = R_PointInSubsectorFast(x, y);
|
||||
subsec = R_PointInSubsectorFast(x, y);
|
||||
else
|
||||
s = thiscam->subsector;
|
||||
subsec = thiscam->subsector;
|
||||
|
||||
if (players[displayplayers[0]].mo)
|
||||
{
|
||||
@@ -2220,7 +2220,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
|
||||
thiscam->ceilingz = thiscam->z + thiscam->height;
|
||||
thiscam->x = x;
|
||||
thiscam->y = y;
|
||||
thiscam->subsector = s;
|
||||
thiscam->subsector = subsec;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2232,6 +2232,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
|
||||
tryx -= MAXRADIUS;
|
||||
else
|
||||
tryx = x;
|
||||
|
||||
if (y-tryy > MAXRADIUS)
|
||||
tryy += MAXRADIUS;
|
||||
else if (y-tryy < -MAXRADIUS)
|
||||
@@ -2249,14 +2250,14 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
|
||||
|
||||
if (tmceilingz - thiscam->z < thiscam->height)
|
||||
{
|
||||
if (s == thiscam->subsector && tmceilingz >= thiscam->z)
|
||||
if (subsec == thiscam->subsector && tmceilingz >= thiscam->z)
|
||||
{
|
||||
floatok = true;
|
||||
thiscam->floorz = tmfloorz;
|
||||
thiscam->ceilingz = tmfloorz + thiscam->height;
|
||||
thiscam->x = x;
|
||||
thiscam->y = y;
|
||||
thiscam->subsector = s;
|
||||
thiscam->subsector = subsec;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -2281,7 +2282,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
|
||||
thiscam->ceilingz = tmceilingz;
|
||||
thiscam->x = x;
|
||||
thiscam->y = y;
|
||||
thiscam->subsector = s;
|
||||
thiscam->subsector = subsec;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -2394,6 +2395,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
|
||||
tryx -= radius;
|
||||
else
|
||||
tryx = x;
|
||||
|
||||
if (y-tryy > radius)
|
||||
tryy += radius;
|
||||
else if (y-tryy < -radius)
|
||||
@@ -2409,28 +2411,34 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
|
||||
{
|
||||
//All things are affected by their scale.
|
||||
fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale);
|
||||
INT32 special = 0;
|
||||
|
||||
if (thing->player)
|
||||
{
|
||||
const INT32 special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1);
|
||||
special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1);
|
||||
|
||||
// If using type Section1:13, double the maxstep.
|
||||
if (P_PlayerTouchingSectorSpecial(thing->player, 1, 13)
|
||||
|| special == 13)
|
||||
if (P_PlayerTouchingSectorSpecial(thing->player, 1, 13) || special == 13)
|
||||
{
|
||||
maxstep <<= 1;
|
||||
}
|
||||
// If using type Section1:12, no maxstep. For ledges you don't want the player to climb! (see: Egg Zeppelin & SMK port walls)
|
||||
else if (P_PlayerTouchingSectorSpecial(thing->player, 1, 12)
|
||||
|| special == 12)
|
||||
else if (P_PlayerTouchingSectorSpecial(thing->player, 1, 12) || special == 12)
|
||||
{
|
||||
maxstep = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (thing->type == MT_SKIM)
|
||||
{
|
||||
maxstep = 0;
|
||||
}
|
||||
|
||||
if (tmceilingz - tmfloorz < thing->height)
|
||||
{
|
||||
if (tmfloorthing)
|
||||
tmhitthing = tmfloorthing;
|
||||
|
||||
return false; // doesn't fit
|
||||
}
|
||||
|
||||
@@ -2463,11 +2471,8 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
|
||||
return false; // mobj must lower itself to fit
|
||||
}
|
||||
}
|
||||
else if (maxstep > 0 && !(
|
||||
thing->player && (
|
||||
P_PlayerTouchingSectorSpecial(thing->player, 1, 14)
|
||||
|| GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14)
|
||||
)) // Step down
|
||||
else if (maxstep > 0 && !(thing->player &&
|
||||
(P_PlayerTouchingSectorSpecial(thing->player, 1, 14) || special == 14))) // Step down
|
||||
{
|
||||
// If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS
|
||||
// step down! Formerly required a Section1:13 sector for the full MAXSTEPMOVE, but no more.
|
||||
@@ -2489,10 +2494,14 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
|
||||
if (thing->eflags & MFE_VERTICALFLIP)
|
||||
{
|
||||
if (tmdrpoffceilz - tmceilingz > maxstep)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if (tmfloorz - tmdropoffz > maxstep)
|
||||
{
|
||||
return false; // don't stand over a dropoff
|
||||
}
|
||||
}
|
||||
}
|
||||
} while (tryx != x || tryy != y);
|
||||
@@ -2568,6 +2577,7 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y)
|
||||
|
||||
tryx = thing->x;
|
||||
tryy = thing->y;
|
||||
|
||||
do {
|
||||
if (x-tryx > MAXRADIUS)
|
||||
tryx += MAXRADIUS;
|
||||
@@ -2575,6 +2585,7 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y)
|
||||
tryx -= MAXRADIUS;
|
||||
else
|
||||
tryx = x;
|
||||
|
||||
if (y-tryy > MAXRADIUS)
|
||||
tryy += MAXRADIUS;
|
||||
else if (y-tryy < -MAXRADIUS)
|
||||
@@ -2587,14 +2598,14 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y)
|
||||
|
||||
if (!(thing->flags & MF_NOCLIP))
|
||||
{
|
||||
const fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale);
|
||||
|
||||
if (tmceilingz - tmfloorz < thing->height)
|
||||
return false; // doesn't fit
|
||||
|
||||
if (tmceilingz - thing->z < thing->height)
|
||||
return false; // mobj must lower itself to fit
|
||||
|
||||
const fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale);
|
||||
|
||||
if (tmfloorz - thing->z > maxstep)
|
||||
return false; // too big a step up
|
||||
}
|
||||
@@ -2928,6 +2939,7 @@ static boolean PTR_SlideTraverse(intercept_t *in)
|
||||
{
|
||||
if (P_PointOnLineSide(slidemo->x, slidemo->y, li))
|
||||
return true; // don't hit the back side
|
||||
|
||||
goto isblocking;
|
||||
}
|
||||
|
||||
@@ -3346,10 +3358,12 @@ void P_BouncePlayerMove(mobj_t *mo)
|
||||
|
||||
{
|
||||
mobj_t *fx = P_SpawnMobj(mo->x, mo->y, mo->z, MT_BUMP);
|
||||
|
||||
if (mo->eflags & MFE_VERTICALFLIP)
|
||||
fx->eflags |= MFE_VERTICALFLIP;
|
||||
else
|
||||
fx->eflags &= ~MFE_VERTICALFLIP;
|
||||
|
||||
fx->scale = mo->scale;
|
||||
|
||||
S_StartSound(mo, sfx_s3k49);
|
||||
@@ -3363,7 +3377,8 @@ void P_BouncePlayerMove(mobj_t *mo)
|
||||
mo->player->cmomx = tmxmove;
|
||||
mo->player->cmomy = tmymove;
|
||||
|
||||
if (!P_TryMove(mo, mo->x + tmxmove, mo->y + tmymove, true)) {
|
||||
if (!P_TryMove(mo, mo->x + tmxmove, mo->y + tmymove, true))
|
||||
{
|
||||
P_TryMove(mo, mo->x - oldmomx, mo->y - oldmomy, true);
|
||||
}
|
||||
}
|
||||
@@ -3740,6 +3755,7 @@ boolean P_CheckSector(sector_t *sector, boolean crunch)
|
||||
{
|
||||
size_t i;
|
||||
sector_t *sec;
|
||||
|
||||
for (i = 0; i < sector->numattached; i++)
|
||||
{
|
||||
sec = §ors[sector->attached[i]];
|
||||
@@ -3946,6 +3962,7 @@ static msecnode_t *P_DelSecnode(msecnode_t *node)
|
||||
|
||||
tp = node->m_sectorlist_prev;
|
||||
tn = node->m_sectorlist_next;
|
||||
|
||||
if (tp)
|
||||
tp->m_sectorlist_next = tn;
|
||||
if (tn)
|
||||
@@ -3956,6 +3973,7 @@ static msecnode_t *P_DelSecnode(msecnode_t *node)
|
||||
|
||||
sp = node->m_thinglist_prev;
|
||||
sn = node->m_thinglist_next;
|
||||
|
||||
if (sp)
|
||||
sp->m_thinglist_next = sn;
|
||||
else
|
||||
@@ -4003,7 +4021,7 @@ static inline boolean PIT_GetSectors(line_t *ld)
|
||||
// allowed to move to this position, then the sector_list
|
||||
// will be attached to the Thing's mobj_t at touching_sectorlist.
|
||||
|
||||
sector_list = P_AddSecnode(ld->frontsector,tmthing,sector_list);
|
||||
sector_list = P_AddSecnode(ld->frontsector, tmthing, sector_list);
|
||||
|
||||
// Don't assume all lines are 2-sided, since some Things
|
||||
// like MT_TFOG are allowed regardless of whether their radius takes
|
||||
|
||||
+10
-10
@@ -43,7 +43,7 @@
|
||||
consvar_t cv_splats = {"splats", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
|
||||
actioncache_t actioncachehead;
|
||||
actioncache_t actioncachehead = {};
|
||||
|
||||
static mobj_t *overlaycap = NULL;
|
||||
static mobj_t *shadowcap = NULL;
|
||||
@@ -5459,9 +5459,9 @@ static void P_MoveHoop(mobj_t *mobj)
|
||||
v[3] = 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)));
|
||||
M_Memcpy(&v, res, sizeof (v));
|
||||
memcpy(&v, res, sizeof (v));
|
||||
|
||||
finalx = x + v[0];
|
||||
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;
|
||||
|
||||
res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle));
|
||||
M_Memcpy(&v, res, sizeof (v));
|
||||
memcpy(&v, res, sizeof (v));
|
||||
res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle));
|
||||
M_Memcpy(&v, res, sizeof (v));
|
||||
memcpy(&v, res, sizeof (v));
|
||||
|
||||
finalx = x + v[0];
|
||||
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;
|
||||
|
||||
res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle));
|
||||
M_Memcpy(&v, res, sizeof (v));
|
||||
memcpy(&v, res, sizeof (v));
|
||||
res = VectorMatrixMultiply(v, *RotateZMatrix(closestangle));
|
||||
M_Memcpy(&v, res, sizeof (v));
|
||||
memcpy(&v, res, sizeof (v));
|
||||
|
||||
finalx = x + v[0];
|
||||
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;
|
||||
|
||||
res = VectorMatrixMultiply(v, *RotateXMatrix(FixedAngle(spewangle)));
|
||||
M_Memcpy(&v, res, sizeof (v));
|
||||
memcpy(&v, res, sizeof (v));
|
||||
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);
|
||||
|
||||
@@ -11889,7 +11889,7 @@ void P_SpawnHoops(mapthing_t *mthing)
|
||||
|
||||
z += P_GetSectorFloorZAt(sec, x, y);
|
||||
|
||||
hoopcenter->z -= hoopcenter->height/2;
|
||||
hoopcenter->z = z - hoopcenter->height/2;
|
||||
|
||||
P_UnsetThingPosition(hoopcenter);
|
||||
hoopcenter->x = x;
|
||||
|
||||
+41
-63
@@ -35,7 +35,7 @@
|
||||
#include "lua_script.h"
|
||||
#include "p_slopes.h"
|
||||
|
||||
savedata_t savedata;
|
||||
savedata_t savedata = {};
|
||||
|
||||
// Block UINT32s to attempt to ensure that the correct data is
|
||||
// being sent and received
|
||||
@@ -61,7 +61,7 @@ typedef enum
|
||||
//
|
||||
// P_ArchivePlayer
|
||||
//
|
||||
static inline void P_ArchivePlayer(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_ArchivePlayer(savebuffer_t *save)
|
||||
{
|
||||
const player_t *player = &players[consoleplayer];
|
||||
INT32 pllives = player->lives;
|
||||
@@ -85,7 +85,7 @@ static inline void P_ArchivePlayer(savebuffer_t *save)
|
||||
//
|
||||
// P_UnArchivePlayer
|
||||
//
|
||||
static inline void P_UnArchivePlayer(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_UnArchivePlayer(savebuffer_t *save)
|
||||
{
|
||||
savedata.skincolor = READUINT8(save->p);
|
||||
savedata.skin = READUINT8(save->p);
|
||||
@@ -1043,25 +1043,25 @@ typedef enum
|
||||
tc_end
|
||||
} specials_e;
|
||||
|
||||
static inline UINT32 SaveMobjnum(const mobj_t *mobj)
|
||||
FUNCINLINE static ATTRINLINE UINT32 SaveMobjnum(const mobj_t *mobj)
|
||||
{
|
||||
if (mobj) return mobj->mobjnum;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline UINT32 SaveSector(const sector_t *sector)
|
||||
FUNCINLINE static ATTRINLINE UINT32 SaveSector(const sector_t *sector)
|
||||
{
|
||||
if (sector) return (UINT32)(sector - sectors);
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
static inline UINT32 SaveLine(const line_t *line)
|
||||
FUNCINLINE static ATTRINLINE UINT32 SaveLine(const line_t *line)
|
||||
{
|
||||
if (line) return (UINT32)(line - lines);
|
||||
return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
static inline UINT32 SavePlayer(const player_t *player)
|
||||
FUNCINLINE static ATTRINLINE UINT32 SavePlayer(const player_t *player)
|
||||
{
|
||||
if (player) return (UINT32)(player - players);
|
||||
return 0xFFFFFFFF;
|
||||
@@ -1203,7 +1203,7 @@ static void SaveMobjThinker(savebuffer_t *save, const thinker_t *th, const UINT8
|
||||
if (diff & MD_MORE)
|
||||
WRITEUINT16(save->p, diff2);
|
||||
|
||||
// save pointer, at load time we will search this pointer to reinitilize pointers
|
||||
// keep here for vanilla compat
|
||||
WRITEUINT32(save->p, (size_t)mobj);
|
||||
|
||||
WRITEFIXED(save->p, mobj->z); // Force this so 3dfloor problems don't arise.
|
||||
@@ -1476,7 +1476,7 @@ static void SaveElevatorThinker(savebuffer_t *save, const thinker_t *th, const U
|
||||
//
|
||||
// Saves a scroll_t thinker
|
||||
//
|
||||
static inline void SaveScrollThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
FUNCINLINE static ATTRINLINE void SaveScrollThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
{
|
||||
const scroll_t *ht = (const void *)th;
|
||||
WRITEUINT8(save->p, type);
|
||||
@@ -1497,7 +1497,7 @@ static inline void SaveScrollThinker(savebuffer_t *save, const thinker_t *th, co
|
||||
//
|
||||
// Saves a friction_t thinker
|
||||
//
|
||||
static inline void SaveFrictionThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
FUNCINLINE static ATTRINLINE void SaveFrictionThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
{
|
||||
const friction_t *ht = (const void *)th;
|
||||
WRITEUINT8(save->p, type);
|
||||
@@ -1513,7 +1513,7 @@ static inline void SaveFrictionThinker(savebuffer_t *save, const thinker_t *th,
|
||||
//
|
||||
// Saves a pusher_t thinker
|
||||
//
|
||||
static inline void SavePusherThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
FUNCINLINE static ATTRINLINE void SavePusherThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
{
|
||||
const pusher_t *ht = (const void *)th;
|
||||
WRITEUINT8(save->p, type);
|
||||
@@ -1598,7 +1598,7 @@ static void SaveDisappearThinker(savebuffer_t *save, const thinker_t *th, const
|
||||
//
|
||||
// Saves a polyrotate_t thinker
|
||||
//
|
||||
static inline void SavePolyrotatetThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
FUNCINLINE static ATTRINLINE void SavePolyrotatetThinker(savebuffer_t *save, const thinker_t *th, const UINT8 type)
|
||||
{
|
||||
const polyrotate_t *ht = (const void *)th;
|
||||
WRITEUINT8(save->p, type);
|
||||
@@ -1935,25 +1935,25 @@ mobj_t *P_FindNewPosition(UINT32 oldposition)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline mobj_t *LoadMobj(UINT32 mobjnum)
|
||||
FUNCINLINE static ATTRINLINE mobj_t *LoadMobj(UINT32 mobjnum)
|
||||
{
|
||||
if (mobjnum == 0) return NULL;
|
||||
return (mobj_t *)(size_t)mobjnum;
|
||||
}
|
||||
|
||||
static inline sector_t *LoadSector(UINT32 sector)
|
||||
FUNCINLINE static ATTRINLINE sector_t *LoadSector(UINT32 sector)
|
||||
{
|
||||
if (sector >= numsectors) return NULL;
|
||||
return §ors[sector];
|
||||
}
|
||||
|
||||
static inline line_t *LoadLine(UINT32 line)
|
||||
FUNCINLINE static ATTRINLINE line_t *LoadLine(UINT32 line)
|
||||
{
|
||||
if (line >= numlines) return NULL;
|
||||
return &lines[line];
|
||||
}
|
||||
|
||||
static inline player_t *LoadPlayer(UINT32 player)
|
||||
FUNCINLINE static ATTRINLINE player_t *LoadPlayer(UINT32 player)
|
||||
{
|
||||
if (player >= MAXPLAYERS) return NULL;
|
||||
return &players[player];
|
||||
@@ -1982,7 +1982,6 @@ static void CalculateDoomednumToMobjtype(void)
|
||||
|
||||
static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
thinker_t *next;
|
||||
mobj_t *mobj;
|
||||
UINT32 diff;
|
||||
UINT16 diff2;
|
||||
@@ -1995,7 +1994,8 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
else
|
||||
diff2 = 0;
|
||||
|
||||
next = (void *)(size_t)READUINT32(save->p);
|
||||
// here for vanilla compat
|
||||
save->p += sizeof(UINT32);
|
||||
|
||||
z = READFIXED(save->p); // Force this so 3dfloor problems don't arise.
|
||||
floorz = READFIXED(save->p);
|
||||
@@ -2234,8 +2234,6 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
if (diff2 & MD2_WAYPOINTCAP)
|
||||
P_SetTarget(&waypointcap, mobj);
|
||||
|
||||
mobj->info = (mobjinfo_t *)next; // temporarily, set when leave this function
|
||||
|
||||
R_AddMobjInterpolator(mobj);
|
||||
}
|
||||
|
||||
@@ -2529,7 +2527,7 @@ static void LoadScrollThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
//
|
||||
// Loads a friction_t from a save game
|
||||
//
|
||||
static inline void LoadFrictionThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadFrictionThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
friction_t *ht = (friction_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2576,7 +2574,7 @@ static void LoadPusherThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
//
|
||||
// Loads a laserthink_t from a save game
|
||||
//
|
||||
static inline void LoadLaserThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadLaserThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
laserthink_t *ht = (laserthink_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2621,7 +2619,7 @@ FUNCINLINE static ATTRINLINE void LoadLightlevelThinker(savebuffer_t *save, acti
|
||||
//
|
||||
// Loads a executor_t from a save game
|
||||
//
|
||||
static inline void LoadExecutorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadExecutorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
executor_t *ht = (executor_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2639,7 +2637,7 @@ static inline void LoadExecutorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
//
|
||||
// Loads a disappear_t thinker
|
||||
//
|
||||
static inline void LoadDisappearThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadDisappearThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
disappear_t *ht = (disappear_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2660,7 +2658,7 @@ static inline void LoadDisappearThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
//
|
||||
// Loads a polyrotate_t thinker
|
||||
//
|
||||
static inline void LoadPolyrotatetThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadPolyrotatetThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
polyrotate_t *ht = (polyrotate_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2720,7 +2718,7 @@ static void LoadPolymoveThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
//
|
||||
// Loads a polywaypoint_t thinker
|
||||
//
|
||||
static inline void LoadPolywaypointThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadPolywaypointThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
polywaypoint_t *ht = (polywaypoint_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2776,7 +2774,7 @@ static inline void LoadPolywaypointThinker(savebuffer_t *save, actionf_p1 thinke
|
||||
//
|
||||
// loads a polyslidedoor_t thinker
|
||||
//
|
||||
static inline void LoadPolyslidedoorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadPolyslidedoorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
polyslidedoor_t *ht = (polyslidedoor_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2814,7 +2812,7 @@ static inline void LoadPolyslidedoorThinker(savebuffer_t *save, actionf_p1 think
|
||||
//
|
||||
// Loads a polyswingdoor_t thinker
|
||||
//
|
||||
static inline void LoadPolyswingdoorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadPolyswingdoorThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
polyswingdoor_t *ht = (polyswingdoor_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -2847,7 +2845,7 @@ static inline void LoadPolyswingdoorThinker(savebuffer_t *save, actionf_p1 think
|
||||
//
|
||||
// Loads a polydisplace_t thinker
|
||||
//
|
||||
static inline void LoadPolydisplaceThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
FUNCINLINE static ATTRINLINE void LoadPolydisplaceThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
{
|
||||
polydisplace_t *ht = (polydisplace_t*)Z_LevelPoolMalloc(sizeof (*ht));
|
||||
ht->thinker.alloctype = TAT_LEVELPOOL;
|
||||
@@ -3115,7 +3113,7 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save)
|
||||
#define PD_FLAGS 0x01
|
||||
#define PD_TRANS 0x02
|
||||
|
||||
static inline void P_ArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
FUNCINLINE static ATTRINLINE void P_ArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
{
|
||||
UINT8 diff = 0;
|
||||
WRITEINT32(save->p, po->id);
|
||||
@@ -3137,7 +3135,7 @@ static inline void P_ArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
WRITEINT32(save->p, po->translucency);
|
||||
}
|
||||
|
||||
static inline void P_UnArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
FUNCINLINE static ATTRINLINE void P_UnArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
{
|
||||
INT32 id;
|
||||
UINT32 angle;
|
||||
@@ -3172,7 +3170,7 @@ static inline void P_UnArchivePolyObj(savebuffer_t *save, polyobj_t *po)
|
||||
Polyobj_MoveOnLoad(po, angle, x, y);
|
||||
}
|
||||
|
||||
static inline void P_ArchivePolyObjects(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_ArchivePolyObjects(savebuffer_t *save)
|
||||
{
|
||||
INT32 i;
|
||||
|
||||
@@ -3185,7 +3183,7 @@ static inline void P_ArchivePolyObjects(savebuffer_t *save)
|
||||
P_ArchivePolyObj(save, &PolyObjects[i]);
|
||||
}
|
||||
|
||||
static inline void P_UnArchivePolyObjects(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_UnArchivePolyObjects(savebuffer_t *save)
|
||||
{
|
||||
INT32 i, numSavedPolys;
|
||||
|
||||
@@ -3200,27 +3198,8 @@ static inline void P_UnArchivePolyObjects(savebuffer_t *save)
|
||||
for (i = 0; i < numSavedPolys; ++i)
|
||||
P_UnArchivePolyObj(save, &PolyObjects[i]);
|
||||
}
|
||||
//
|
||||
// P_FinishMobjs
|
||||
//
|
||||
static inline void P_FinishMobjs(void)
|
||||
{
|
||||
thinker_t *currentthinker;
|
||||
mobj_t *mobj;
|
||||
|
||||
// put info field there real value
|
||||
for (currentthinker = thinkercap.next; currentthinker != &thinkercap;
|
||||
currentthinker = currentthinker->next)
|
||||
{
|
||||
if (currentthinker->function != (actionf_p1)P_MobjThinker)
|
||||
continue;
|
||||
|
||||
mobj = (mobj_t *)currentthinker;
|
||||
mobj->info = &mobjinfo[mobj->type];
|
||||
}
|
||||
}
|
||||
|
||||
static inline mobj_t *RelinkMobj(mobj_t **ptr)
|
||||
FUNCINLINE static ATTRINLINE mobj_t *RelinkMobj(mobj_t **ptr)
|
||||
{
|
||||
UINT32 temp = (UINT32)(size_t)*ptr;
|
||||
*ptr = NULL;
|
||||
@@ -3269,7 +3248,7 @@ static void P_RelinkPointers(void)
|
||||
//
|
||||
// P_NetArchiveSpecials
|
||||
//
|
||||
static inline void P_NetArchiveSpecials(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_NetArchiveSpecials(savebuffer_t *save)
|
||||
{
|
||||
size_t i, z;
|
||||
|
||||
@@ -3347,7 +3326,7 @@ static void P_NetUnArchiveSpecials(savebuffer_t *save)
|
||||
// =======================================================================
|
||||
// Misc
|
||||
// =======================================================================
|
||||
static inline void P_ArchiveMisc(savebuffer_t *save)
|
||||
FUNCINLINE static ATTRINLINE void P_ArchiveMisc(savebuffer_t *save)
|
||||
{
|
||||
if (gamecomplete)
|
||||
WRITEINT16(save->p, gamemap | 8192);
|
||||
@@ -3360,7 +3339,7 @@ static inline void P_ArchiveMisc(savebuffer_t *save)
|
||||
WRITESTRINGN(save->p, timeattackfolder, sizeof(timeattackfolder));
|
||||
}
|
||||
|
||||
static inline void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride)
|
||||
FUNCINLINE static ATTRINLINE void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride)
|
||||
{
|
||||
char testname[sizeof(timeattackfolder)];
|
||||
|
||||
@@ -3391,7 +3370,7 @@ static inline void P_UnArchiveSPGame(savebuffer_t *save, INT16 mapoverride)
|
||||
|
||||
READSTRINGN(save->p, testname, sizeof(testname));
|
||||
|
||||
if (strcmp(testname, timeattackfolder))
|
||||
if (!fastcmp(testname, timeattackfolder))
|
||||
{
|
||||
if (modifiedgame)
|
||||
I_Error("Save game not for this modification.");
|
||||
@@ -3531,7 +3510,8 @@ static void P_ReloadSaveLevelData(void)
|
||||
ss->floorpic_angle = spawnss->floorpic_angle;
|
||||
ss->ceilingpic_angle = spawnss->ceilingpic_angle;
|
||||
ss->tag = spawnss->tag;
|
||||
ss->firsttag = ss->nexttag = -1;
|
||||
ss->firsttag = spawnss->firsttag;
|
||||
ss->nexttag = spawnss->nexttag;
|
||||
|
||||
if (ss->ffloors)
|
||||
{
|
||||
@@ -3556,7 +3536,8 @@ static void P_ReloadSaveLevelData(void)
|
||||
li->callcount = 0;
|
||||
|
||||
li->tag = spawnli->tag;
|
||||
li->firsttag = li->nexttag = -1;
|
||||
li->firsttag = spawnli->firsttag;
|
||||
li->nexttag = spawnli->nexttag;
|
||||
|
||||
if (li->sidenum[0] != 0xffff)
|
||||
{
|
||||
@@ -3580,8 +3561,6 @@ static void P_ReloadSaveLevelData(void)
|
||||
si->midtexture = spawnsi->midtexture;
|
||||
}
|
||||
}
|
||||
|
||||
P_InitTagLists();
|
||||
}
|
||||
|
||||
FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, boolean reloading)
|
||||
@@ -3793,7 +3772,7 @@ boolean P_LoadGame(savebuffer_t *save, INT16 mapoverride)
|
||||
|
||||
boolean P_LoadNetGame(savebuffer_t *save, boolean reloading)
|
||||
{
|
||||
CV_LoadNetVars(&save->p);
|
||||
save->p += CV_LoadNetVars(save->p);
|
||||
|
||||
if (!P_NetUnArchiveMisc(save, reloading))
|
||||
return false;
|
||||
@@ -3807,7 +3786,6 @@ boolean P_LoadNetGame(savebuffer_t *save, boolean reloading)
|
||||
P_NetUnArchiveThinkers(save);
|
||||
P_NetUnArchiveSpecials(save);
|
||||
P_RelinkPointers();
|
||||
P_FinishMobjs();
|
||||
}
|
||||
|
||||
LUA_UnArchive(save, true);
|
||||
|
||||
+64
-51
@@ -92,7 +92,7 @@
|
||||
// Map MD5, calculated on level load.
|
||||
// Sent to clients in PT_SERVERINFO.
|
||||
//
|
||||
unsigned char mapmd5[16];
|
||||
unsigned char mapmd5[16] = {};
|
||||
|
||||
// true when level was loaded from netsave
|
||||
boolean midgamejoin = false;
|
||||
@@ -102,22 +102,22 @@ boolean midgamejoin = false;
|
||||
// Store VERTEXES, LINEDEFS, SIDEDEFS, etc.
|
||||
//
|
||||
|
||||
size_t numvertexes, numsegs, numsectors, numsubsectors, numnodes, numlines, numsides, nummapthings;
|
||||
vertex_t *vertexes;
|
||||
seg_t *segs;
|
||||
sector_t *sectors;
|
||||
subsector_t *subsectors;
|
||||
node_t *nodes;
|
||||
line_t *lines;
|
||||
side_t *sides;
|
||||
mapthing_t *mapthings;
|
||||
sector_t *spawnsectors;
|
||||
line_t *spawnlines;
|
||||
side_t *spawnsides;
|
||||
INT32 numstarposts;
|
||||
boolean levelloading;
|
||||
size_t numvertexes = 0, numsegs = 0, numsectors = 0, numsubsectors = 0, numnodes = 0, numlines = 0, numsides = 0, nummapthings = 0;
|
||||
vertex_t *vertexes = NULL;
|
||||
seg_t *segs = NULL;
|
||||
sector_t *sectors = NULL;
|
||||
subsector_t *subsectors = NULL;
|
||||
node_t *nodes = NULL;
|
||||
line_t *lines = NULL;
|
||||
side_t *sides = NULL;
|
||||
mapthing_t *mapthings = NULL;
|
||||
sector_t *spawnsectors = NULL;
|
||||
line_t *spawnlines = NULL;
|
||||
side_t *spawnsides = NULL;
|
||||
INT32 numstarposts = 0;
|
||||
boolean levelloading = false;
|
||||
|
||||
virtres_t *curmapvirt;
|
||||
virtres_t *curmapvirt = NULL;
|
||||
|
||||
// BLOCKMAP
|
||||
// Created from axis aligned bounding box
|
||||
@@ -127,32 +127,32 @@ virtres_t *curmapvirt;
|
||||
// by spatial subdivision in 2D.
|
||||
//
|
||||
// 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
|
||||
INT32 *blockmaplump; // Big blockmap
|
||||
INT32 *blockmaplump = NULL; // Big blockmap
|
||||
|
||||
// origin of block map
|
||||
fixed_t bmaporgx, bmaporgy;
|
||||
fixed_t bmaporgx = 0, bmaporgy = 0;
|
||||
// for thing chains
|
||||
mobj_t **blocklinks;
|
||||
precipmobj_t **precipblocklinks;
|
||||
mobj_t **blocklinks = NULL;
|
||||
precipmobj_t **precipblocklinks = NULL;
|
||||
|
||||
// REJECT
|
||||
// For fast sight rejection.
|
||||
// Speeds up enemy AI by skipping detailed LineOf Sight calculation.
|
||||
// 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.
|
||||
INT32 numdmstarts, numcoopstarts, numredctfstarts, numbluectfstarts;
|
||||
INT32 numdmstarts = 0, numcoopstarts = 0, numredctfstarts = 0, numbluectfstarts = 0;
|
||||
|
||||
mapthing_t *deathmatchstarts[MAX_DM_STARTS];
|
||||
mapthing_t *playerstarts[MAXPLAYERS];
|
||||
mapthing_t *bluectfstarts[MAXPLAYERS];
|
||||
mapthing_t *redctfstarts[MAXPLAYERS];
|
||||
mapthing_t *deathmatchstarts[MAX_DM_STARTS] = {};
|
||||
mapthing_t *playerstarts[MAXPLAYERS] = {};
|
||||
mapthing_t *bluectfstarts[MAXPLAYERS] = {};
|
||||
mapthing_t *redctfstarts[MAXPLAYERS] = {};
|
||||
|
||||
// Global state for PartialAddWadFile/MultiSetupWadFiles
|
||||
// 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->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->angle = (SHORT(ml->angle))<<FRACBITS;
|
||||
li->offset = (SHORT(ml->offset))<<FRACBITS;
|
||||
@@ -806,7 +817,7 @@ static void P_LoadSectors(UINT8 *data)
|
||||
skyflatnum = P_AddLevelFlat(SKYFLATNAME, foundflats);
|
||||
|
||||
// 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);
|
||||
|
||||
// search for animated flats and set up
|
||||
@@ -1177,10 +1188,10 @@ static void P_LoadLineDefs2(void)
|
||||
len += strlen(sides[ld->sidenum[1]].text);
|
||||
|
||||
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)
|
||||
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;
|
||||
|
||||
@@ -1309,14 +1320,14 @@ static void P_LoadSideChangeMusic(boolean firstside, mapsidedef_t *msd, side_t *
|
||||
|
||||
if (msd->bottomtexture[0] != '-' || msd->bottomtexture[1] != '\0')
|
||||
{
|
||||
M_Memcpy(process,msd->bottomtexture,8);
|
||||
memcpy(process,msd->bottomtexture,8);
|
||||
process[8] = '\0';
|
||||
sd->bottomtexture = get_number(process);
|
||||
}
|
||||
|
||||
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';
|
||||
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')
|
||||
{
|
||||
M_Memcpy(process,msd->toptexture,8);
|
||||
memcpy(process,msd->toptexture,8);
|
||||
process[8] = '\0';
|
||||
|
||||
// If they type in O_ or D_ and their music name, just shrug,
|
||||
// then copy the rest instead.
|
||||
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.
|
||||
M_Memcpy(sd->text, process, 6);
|
||||
memcpy(sd->text, process, 6);
|
||||
sd->text[6] = 0;
|
||||
}
|
||||
else
|
||||
@@ -1382,7 +1393,7 @@ static void P_LoadSidedefs(void *data)
|
||||
if (msd->toptexture[0] != '-' || msd->toptexture[1] != '\0')
|
||||
{
|
||||
char process[8+1];
|
||||
M_Memcpy(process,msd->toptexture,8);
|
||||
memcpy(process,msd->toptexture,8);
|
||||
process[8] = '\0';
|
||||
sd->toptexture = get_number(process);
|
||||
}
|
||||
@@ -1401,11 +1412,11 @@ static void P_LoadSidedefs(void *data)
|
||||
if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0')
|
||||
break;
|
||||
else
|
||||
M_Memcpy(process,msd->toptexture,8);
|
||||
memcpy(process,msd->toptexture,8);
|
||||
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')
|
||||
M_Memcpy(process+strlen(process), msd->bottomtexture, 8);
|
||||
memcpy(process+strlen(process), msd->bottomtexture, 8);
|
||||
sd->toptexture = get_number(process);
|
||||
|
||||
break;
|
||||
@@ -1418,13 +1429,13 @@ static void P_LoadSidedefs(void *data)
|
||||
if (msd->toptexture[0] == '-' && msd->toptexture[1] == '\0')
|
||||
break;
|
||||
else
|
||||
M_Memcpy(process,msd->toptexture,8);
|
||||
memcpy(process,msd->toptexture,8);
|
||||
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')
|
||||
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);
|
||||
M_Memcpy(sd->text, process, strlen(process)+1);
|
||||
memcpy(sd->text, process, strlen(process)+1);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1887,7 +1898,7 @@ static void P_LoadReject(UINT8 *data, size_t count)
|
||||
else
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1983,11 +1994,12 @@ static void P_LoadMapData(const virtres_t* virt)
|
||||
P_LoadLinedefs(virtlinedefs->data);
|
||||
P_LoadSidedefs(virtsidedefs->data);
|
||||
P_LoadThings(virtthings->data);
|
||||
P_InitTagLists(); // Create xref tables for tags
|
||||
|
||||
// Copy relevant map data for NetArchive purposes.
|
||||
spawnsectors = Z_Calloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL);
|
||||
spawnlines = Z_Calloc(numlines * sizeof(*lines), PU_LEVEL, NULL);
|
||||
spawnsides = Z_Calloc(numsides * sizeof(*sides), PU_LEVEL, NULL);
|
||||
spawnsectors = Z_Malloc(numsectors * sizeof(*sectors), PU_LEVEL, NULL);
|
||||
spawnlines = Z_Malloc(numlines * sizeof(*lines), PU_LEVEL, NULL);
|
||||
spawnsides = Z_Malloc(numsides * sizeof(*sides), PU_LEVEL, NULL);
|
||||
|
||||
memcpy(spawnsectors, sectors, numsectors * sizeof(*sectors));
|
||||
memcpy(spawnlines, lines, numlines * sizeof(*lines));
|
||||
@@ -2200,7 +2212,7 @@ static void P_MakeMapMD5(virtres_t *virt, void *dest)
|
||||
for (i = 0; i < 16; i++)
|
||||
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)
|
||||
@@ -2765,7 +2777,8 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate)
|
||||
// Make sure all sounds are stopped before Z_FreeTags.
|
||||
S_StopSounds();
|
||||
|
||||
if (!S_PrecacheSound())
|
||||
// if we dont intend to cache our sound effects, wipe them
|
||||
if (S_CacheSound() == SOUNDCACHE_OFF)
|
||||
S_ClearSfx();
|
||||
|
||||
// As oddly named as this is, this handles music only.
|
||||
@@ -3033,7 +3046,7 @@ static boolean P_CheckSoundReplacements(UINT16 wadnum, char *name, size_t i)
|
||||
I_FreeSfx(&S_sfx[j]);
|
||||
|
||||
// Re-cache it
|
||||
if (S_PrecacheSound())
|
||||
if (S_CacheSound() == SOUNDCACHE_PRECACHE)
|
||||
S_sfx[j].data = I_GetSfx(&S_sfx[j]);
|
||||
|
||||
sreplaces++;
|
||||
|
||||
+45
-23
@@ -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
|
||||
#include <errno.h>
|
||||
|
||||
mobj_t *skyboxmo[2];
|
||||
mobj_t *skyboxmo[2] = {};
|
||||
|
||||
// Amount (dx, dy) vector linedef is shifted right to get scroll amount
|
||||
#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.
|
||||
anim_t *lastanim;
|
||||
anim_t *lastanim = NULL;
|
||||
anim_t *anims = NULL; /// \todo free leak
|
||||
static size_t maxanims;
|
||||
|
||||
@@ -252,10 +252,10 @@ void P_InitPicAnims(void)
|
||||
// Populate the new array
|
||||
for (currentPos = animatedLump; *currentPos != UINT8_MAX; i++, currentPos+=23)
|
||||
{
|
||||
M_Memcpy(&(animdefs[i].istexture), currentPos, 1); // istexture, 1 byte
|
||||
M_Memcpy(animdefs[i].endname, (currentPos + 1), 9); // endname, 9 bytes
|
||||
M_Memcpy(animdefs[i].startname, (currentPos + 10), 9); // startname, 9 bytes
|
||||
M_Memcpy(&(animdefs[i].speed), (currentPos + 19), 4); // speed, 4 bytes
|
||||
memcpy(&(animdefs[i].istexture), currentPos, 1); // istexture, 1 byte
|
||||
memcpy(animdefs[i].endname, (currentPos + 1), 9); // endname, 9 bytes
|
||||
memcpy(animdefs[i].startname, (currentPos + 10), 9); // startname, 9 bytes
|
||||
memcpy(&(animdefs[i].speed), (currentPos + 19), 4); // speed, 4 bytes
|
||||
}
|
||||
|
||||
Z_Free(animatedLump);
|
||||
@@ -324,6 +324,7 @@ void P_InitPicAnims(void)
|
||||
lastanim->speed = LONG(animdefs[i].speed);
|
||||
lastanim++;
|
||||
}
|
||||
|
||||
lastanim->istexture = -1;
|
||||
R_ClearTextureNumCache(false);
|
||||
|
||||
@@ -331,6 +332,7 @@ void P_InitPicAnims(void)
|
||||
// We'll only be using anims from now on.
|
||||
if (animdefs != harddefs)
|
||||
Z_Free(animdefs);
|
||||
|
||||
animdefs = NULL;
|
||||
}
|
||||
|
||||
@@ -361,20 +363,21 @@ void P_ParseANIMDEFSLump(INT32 wadNum, UINT16 lumpnum)
|
||||
|
||||
// Now, let's start parsing this thing
|
||||
p = animdefsText;
|
||||
|
||||
animdefsToken = M_GetToken(p);
|
||||
while (animdefsToken != NULL)
|
||||
{
|
||||
if (stricmp(animdefsToken, "TEXTURE") == 0)
|
||||
if (fasticmp(animdefsToken, "TEXTURE"))
|
||||
{
|
||||
Z_Free(animdefsToken);
|
||||
P_ParseAnimationDefintion(1);
|
||||
}
|
||||
else if (stricmp(animdefsToken, "FLAT") == 0)
|
||||
else if (fasticmp(animdefsToken, "FLAT"))
|
||||
{
|
||||
Z_Free(animdefsToken);
|
||||
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.
|
||||
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);
|
||||
}
|
||||
|
||||
// parse next line
|
||||
while (*p != '\0' && *p != '\n') ++p;
|
||||
if (*p == '\n') ++p;
|
||||
while (*p != '\0' && *p != '\n')
|
||||
++p;
|
||||
|
||||
if (*p == '\n')
|
||||
++p;
|
||||
|
||||
animdefsToken = M_GetToken(p);
|
||||
}
|
||||
|
||||
Z_Free(animdefsToken);
|
||||
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");
|
||||
}
|
||||
if (stricmp(animdefsToken, "OPTIONAL") == 0)
|
||||
|
||||
if (fasticmp(animdefsToken, "OPTIONAL"))
|
||||
{
|
||||
// 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
|
||||
@@ -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");
|
||||
}
|
||||
else if (stricmp(animdefsToken, "RANGE") == 0)
|
||||
else if (fasticmp(animdefsToken, "RANGE"))
|
||||
{
|
||||
// Oh. Um. Apparently "OPTIONAL" is a texture name. Naughty.
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
|
||||
animdefsTokenLength = strlen(animdefsToken);
|
||||
if (animdefsTokenLength>8)
|
||||
if (animdefsTokenLength > 8)
|
||||
{
|
||||
I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken);
|
||||
}
|
||||
|
||||
// Search for existing animdef
|
||||
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);
|
||||
|
||||
@@ -444,6 +456,7 @@ void P_ParseAnimationDefintion(SINT8 istexture)
|
||||
Z_Free(animdefsToken);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Not found
|
||||
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);
|
||||
}
|
||||
if (stricmp(animdefsToken, "ALLOWDECALS") == 0)
|
||||
|
||||
if (fasticmp(animdefsToken, "ALLOWDECALS"))
|
||||
{
|
||||
// Another ZDoom keyword, ho-hum. Skip it, move on to the next token.
|
||||
Z_Free(animdefsToken);
|
||||
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.
|
||||
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);
|
||||
}
|
||||
|
||||
Z_Free(animdefsToken);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
animdefsTokenLength = strlen(animdefsToken);
|
||||
if (animdefsTokenLength>8)
|
||||
{
|
||||
I_Error("Error parsing ANIMDEFS lump: lump name \"%s\" exceeds 8 characters", animdefsToken);
|
||||
}
|
||||
|
||||
strncpy(animdefs[i].endname, animdefsToken, 9);
|
||||
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);
|
||||
}
|
||||
if (stricmp(animdefsToken, "RAND") == 0)
|
||||
|
||||
if (fasticmp(animdefsToken, "RAND"))
|
||||
{
|
||||
// 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");
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
Z_Free(animdefsToken);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
endPos = NULL;
|
||||
#ifndef AVOID_ERRNO
|
||||
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);
|
||||
}
|
||||
|
||||
animdefs[i].speed = animSpeed;
|
||||
Z_Free(animdefsToken);
|
||||
}
|
||||
@@ -2091,8 +2115,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
|
||||
// Change the music and apply position/fade operations
|
||||
else
|
||||
{
|
||||
strncpy(mapmusic.name, sides[line->sidenum[0]].text, 7);
|
||||
mapmusic.name[6] = 0;
|
||||
strlcpy(mapmusic.name, sides[line->sidenum[0]].text, sizeof(mapmusic.name));
|
||||
|
||||
mapmusic.flags = tracknum & MUSIC_TRACKMASK;
|
||||
if (!(line->flags & ML_BLOCKMONSTERS))
|
||||
@@ -5387,7 +5410,6 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate)
|
||||
// set current weather
|
||||
curWeather = mapheaderinfo[gamemap-1]->weather;
|
||||
|
||||
P_InitTagLists(); // Create xref tables for tags
|
||||
P_SearchForDisableLinedefs(); // Disable linedefs are now allowed to disable *any* line
|
||||
|
||||
P_SpawnScrollers(); // Add generalized scrollers
|
||||
|
||||
+3
-3
@@ -44,7 +44,7 @@
|
||||
// Dynamic slopes
|
||||
#include "p_slopes.h"
|
||||
|
||||
tic_t leveltime;
|
||||
tic_t leveltime = 0;
|
||||
|
||||
//
|
||||
// THINKERS
|
||||
@@ -55,8 +55,8 @@ tic_t leveltime;
|
||||
//
|
||||
|
||||
// Both the head and tail of the thinker list.
|
||||
thinker_t thinkercap;
|
||||
thinker_t precipcap;
|
||||
thinker_t thinkercap = {};
|
||||
thinker_t precipcap = {};
|
||||
|
||||
void Command_Numthinkers_f(void)
|
||||
{
|
||||
|
||||
+17
-7
@@ -3315,7 +3315,7 @@ static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num)
|
||||
cmd->sidemove = (SINT8)(cmd->sidemove + side);
|
||||
}
|
||||
|
||||
lang += (cmd->angleturn<<16);
|
||||
lang += (cmd->angleturn << 16);
|
||||
|
||||
cam->localangle = lang;
|
||||
if (!cam->reset_aiming)
|
||||
@@ -3821,7 +3821,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
|
||||
|
||||
if (demo.playback)
|
||||
{
|
||||
focusangle = mo->angle;
|
||||
// Hack-adjacent.
|
||||
// Sometimes stale ticcmds send a weird angle at the start of the race.
|
||||
// P_UpdatePlayerAngle knows to ignore cmd angle when you literally can't turn, so we do the same here.
|
||||
if (cv_demoangturn.value && leveltime > starttime)
|
||||
focusangle = player->cmd.angleturn << 16;
|
||||
else
|
||||
focusangle = mo->angle; // Just use something known sane.
|
||||
focusaiming = 0;
|
||||
}
|
||||
else if (P_IsLocalPlayer(player))
|
||||
@@ -4309,17 +4315,19 @@ static void P_CalcPostImg(player_t *player, camera_t *thiscam)
|
||||
{
|
||||
sector_t *sector = NULL;
|
||||
UINT8 postimgtype = 0;
|
||||
//INT32 *param;
|
||||
fixed_t pviewheight = 0;
|
||||
#ifdef MOTIONBLUR
|
||||
INT32 *param;
|
||||
|
||||
/*for (i = 0; i <= splitscreen; i++)
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
if (player == &players[displayplayers[i]])
|
||||
{
|
||||
param = &postimgparam[i];
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
|
||||
if (encoremode) // srb2kart
|
||||
postimgtype |= POSTIMG_MIRROR;
|
||||
@@ -4355,16 +4363,18 @@ static void P_CalcPostImg(player_t *player, camera_t *thiscam)
|
||||
else if (P_CameraCheckHeatFirstperson(player, sector, pviewheight))
|
||||
postimgtype |= POSTIMG_HEAT;
|
||||
|
||||
#ifdef MOTIONBLUR
|
||||
// Motion blur
|
||||
// unused
|
||||
/*if (player->speed > (35<<FRACBITS))
|
||||
if (player->speed > (35<<FRACBITS))
|
||||
{
|
||||
postimgtype |= POSTIMG_MOTION;
|
||||
*param = (player->speed - 32)/4;
|
||||
|
||||
if (*param > 5)
|
||||
*param = 5;
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
|
||||
thiscam->postimg = postimgtype;
|
||||
}
|
||||
|
||||
+21
-12
@@ -26,11 +26,11 @@
|
||||
|
||||
#include "qs22j.h"
|
||||
|
||||
seg_t *curline;
|
||||
side_t *sidedef;
|
||||
line_t *linedef;
|
||||
sector_t *frontsector;
|
||||
sector_t *backsector;
|
||||
seg_t *curline = NULL;
|
||||
side_t *sidedef = NULL;
|
||||
line_t *linedef = NULL;
|
||||
sector_t *frontsector = NULL;
|
||||
sector_t *backsector = NULL;
|
||||
|
||||
// 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
|
||||
@@ -40,29 +40,38 @@ drawseg_t *drawsegs = NULL;
|
||||
drawseg_t *ds_p = NULL;
|
||||
|
||||
// indicates doors closed wrt automap bugfix:
|
||||
INT32 doorclosed;
|
||||
INT32 doorclosed = 0;
|
||||
|
||||
// A wall was drawn covering the whole screen, which means we
|
||||
// can block off the BSP across that seg.
|
||||
boolean g_walloffscreen;
|
||||
boolean g_walloffscreen = false;
|
||||
|
||||
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
|
||||
INT32 val = GETSECSPECIAL(sector->special, 3);
|
||||
if (val != 1 && val != 3 // spring panel
|
||||
const INT32 sprnspecial = GETSECSPECIAL(sector->special, 3);
|
||||
if (sprnspecial != 1 && sprnspecial != 3 // spring panel
|
||||
#else // optimised, see #define GETSECSPECIAL(i,j) ((i >> ((j-1)*4))&15)
|
||||
if ((!(sector->special & (1<<8)) || (sector->special & ((4|8)<<8))) // spring panel
|
||||
#endif
|
||||
&& GETSECSPECIAL(sector->special, 4) != 6) // sneaker panel
|
||||
return invertencore;
|
||||
{
|
||||
return invertencore;
|
||||
}
|
||||
|
||||
if (invertencore)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ceiling)
|
||||
{
|
||||
return ((boolean)(sector->flags & SF_FLIPSPECIAL_CEILING));
|
||||
}
|
||||
|
||||
return ((boolean)(sector->flags & SF_FLIPSPECIAL_FLOOR));
|
||||
}
|
||||
|
||||
@@ -77,7 +86,7 @@ void R_ClearDrawSegs(void)
|
||||
// CPhipps -
|
||||
// Instead of clipsegs, let's try using an array with one entry for each column,
|
||||
// indicating whether it's blocked by a solid wall yet or not.
|
||||
UINT8 *solidcol;
|
||||
UINT8 *solidcol = NULL;
|
||||
|
||||
void R_AllocClipSegMemory(void)
|
||||
{
|
||||
|
||||
+48
-30
@@ -83,34 +83,34 @@ typedef struct
|
||||
// a patch or sprite is composed of zero or more columns.
|
||||
//
|
||||
|
||||
size_t numspritelumps, max_spritelumps;
|
||||
size_t numspritelumps = 0, max_spritelumps = 0;
|
||||
|
||||
// textures
|
||||
INT32 numtextures = 0; // total number of textures found,
|
||||
// size of following tables
|
||||
|
||||
texture_t **textures = NULL;
|
||||
static UINT32 **texturecolumnofs; // column offset lookup table for each texture
|
||||
UINT8 **texturecache; // graphics data for each generated full-size texture
|
||||
static UINT32 **texturecolumnofs = NULL; // column offset lookup table for each texture
|
||||
UINT8 **texturecache = NULL; // graphics data for each generated full-size texture
|
||||
|
||||
// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask
|
||||
static INT32 *texturewidth;
|
||||
static INT32 *texturewidth = NULL;
|
||||
|
||||
fixed_t *textureheight; // needed for texture pegging
|
||||
fixed_t *textureheight = NULL; // needed for texture pegging
|
||||
|
||||
INT32 *texturetranslation;
|
||||
INT32 *texturetranslation = NULL;
|
||||
|
||||
// needed for pre rendering
|
||||
sprcache_t *spritecachedinfo;
|
||||
sprcache_t *spritecachedinfo = NULL;
|
||||
|
||||
lighttable_t *colormaps;
|
||||
UINT8 *encoremap;
|
||||
lighttable_t *colormaps = NULL;
|
||||
UINT8 *encoremap = NULL;
|
||||
#ifdef HASINVERT
|
||||
UINT8 invertmap[256];
|
||||
#endif
|
||||
|
||||
// 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
|
||||
// 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;
|
||||
|
||||
if (count > 0)
|
||||
M_Memcpy(cache + position, source, count);
|
||||
memcpy(cache + position, source, count);
|
||||
|
||||
patch = (column_t *)((UINT8 *)patch + patch->length + 4);
|
||||
}
|
||||
@@ -412,7 +412,7 @@ UINT8 *R_GenerateTexture(size_t texnum)
|
||||
texture->holes = true;
|
||||
blocksize = lumplength;
|
||||
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;
|
||||
|
||||
// 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);
|
||||
|
||||
// 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->width = SHORT(patchlump.width);
|
||||
@@ -854,7 +854,7 @@ static texpatch_t *R_ParsePatch(boolean actuallyLoadPatch)
|
||||
Z_Free(patchName);
|
||||
}
|
||||
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';
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
if (strcmp(texturesToken,",")!=0)
|
||||
if (!fastcmp(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);
|
||||
}
|
||||
|
||||
if (strcmp(texturesToken,",")!=0)
|
||||
if (!fastcmp(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");
|
||||
}
|
||||
|
||||
texturesTokenLength = strlen(texturesToken);
|
||||
if (texturesTokenLength>8)
|
||||
if (texturesTokenLength > 8)
|
||||
{
|
||||
I_Error("Error parsing TEXTURES lump: Texture name \"%s\" exceeds 8 characters",texturesToken);
|
||||
}
|
||||
else
|
||||
{
|
||||
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
|
||||
strupr(newTextureName); // Just do this now so we don't have to worry about it
|
||||
}
|
||||
|
||||
Z_Free(texturesToken);
|
||||
|
||||
// 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
Z_Free(texturesToken);
|
||||
|
||||
// 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);
|
||||
}
|
||||
if (strcmp(texturesToken,",")!=0)
|
||||
|
||||
if (!fastcmp(texturesToken, ","))
|
||||
{
|
||||
I_Error("Error parsing TEXTURES lump: Expected \",\" after texture \"%s\"'s width, got \"%s\"",newTextureName,texturesToken);
|
||||
}
|
||||
|
||||
Z_Free(texturesToken);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
if (strcmp(texturesToken,"{")==0)
|
||||
if (fastcmp(texturesToken, "{"))
|
||||
{
|
||||
if (actuallyLoadTexture)
|
||||
{
|
||||
// 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);
|
||||
M_Memcpy(resultTexture->name, newTextureName, 8);
|
||||
memcpy(resultTexture->name, newTextureName, 8);
|
||||
resultTexture->hash = quickncasehash(newTextureName, 8);
|
||||
resultTexture->width = newTextureWidth;
|
||||
resultTexture->height = newTextureHeight;
|
||||
resultTexture->type = TEXTURETYPE_COMPOSITE;
|
||||
}
|
||||
|
||||
Z_Free(texturesToken);
|
||||
|
||||
texturesToken = M_GetToken(NULL);
|
||||
if (texturesToken == NULL)
|
||||
{
|
||||
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);
|
||||
if (resultTexture)
|
||||
@@ -1096,7 +1104,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
|
||||
// Make room for the new patch
|
||||
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
|
||||
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
|
||||
resultTexture->patchcount++;
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
if (resultTexture && resultTexture->patchcount == 0)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
Z_Free(texturesToken);
|
||||
|
||||
if (actuallyLoadTexture) return resultTexture;
|
||||
else return NULL;
|
||||
if (actuallyLoadTexture)
|
||||
return resultTexture;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// 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);
|
||||
while (texturesToken != NULL)
|
||||
{
|
||||
if (stricmp(texturesToken, "WALLTEXTURE")==0)
|
||||
if (fasticmp(texturesToken, "WALLTEXTURE"))
|
||||
{
|
||||
numTexturesInLump++;
|
||||
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);
|
||||
}
|
||||
|
||||
texturesToken = M_GetToken(NULL);
|
||||
}
|
||||
|
||||
Z_Free(texturesToken);
|
||||
Z_Free((void *)texturesText);
|
||||
|
||||
@@ -1211,7 +1225,7 @@ void R_ParseTEXTURESLump(UINT16 wadNum, UINT16 lumpNum, INT32 *texindex)
|
||||
texturesToken = M_GetToken(texturesText);
|
||||
while (texturesToken != NULL)
|
||||
{
|
||||
if (stricmp(texturesToken, "WALLTEXTURE")==0)
|
||||
if (fasticmp(texturesToken, "WALLTEXTURE"))
|
||||
{
|
||||
Z_Free(texturesToken);
|
||||
// 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);
|
||||
}
|
||||
|
||||
texturesToken = M_GetToken(NULL);
|
||||
}
|
||||
|
||||
Z_Free(texturesToken);
|
||||
Z_Free((void *)texturesText);
|
||||
}
|
||||
@@ -1334,8 +1350,9 @@ lumpnum_t R_GetFlatNumForName(const char *name)
|
||||
|
||||
if (lump == LUMPERROR)
|
||||
{
|
||||
if (strcmp(name, SKYFLATNAME))
|
||||
if (!fastcmp(name, SKYFLATNAME))
|
||||
CONS_Debug(DBG_SETUP, "R_GetFlatNumForName: Could not find flat %.8s\n", name);
|
||||
|
||||
lump = W_CheckNumForName("REDFLR");
|
||||
}
|
||||
|
||||
@@ -1391,6 +1408,7 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap)
|
||||
|
||||
// Load in the light tables, now 64k aligned for smokie...
|
||||
lump = W_GetNumForName(colormap);
|
||||
|
||||
if (lump == LUMPERROR)
|
||||
lump = basecolormaplump;
|
||||
else
|
||||
|
||||
@@ -91,8 +91,6 @@ UINT8 *R_GetFlat(lumpnum_t flatnum);
|
||||
void R_InitData(void);
|
||||
void R_PrecacheLevel(void);
|
||||
|
||||
extern size_t flatmemory, spritememory, texturememory;
|
||||
|
||||
// Retrieval.
|
||||
// Floor/ceiling opaque texture tiles,
|
||||
// lookup by name. For animation?
|
||||
|
||||
+8
-4
@@ -114,6 +114,11 @@ typedef struct
|
||||
fixed_t x, y, z;
|
||||
} vertex_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x, y/*, z*/;
|
||||
} floatvertex_t;
|
||||
|
||||
// Forward of linedefs, for sectors.
|
||||
struct line_s;
|
||||
|
||||
@@ -543,12 +548,11 @@ typedef struct seg_s
|
||||
sector_t *frontsector;
|
||||
sector_t *backsector;
|
||||
|
||||
fixed_t length; // precalculated seg length
|
||||
fixed_t length; // precalculated seg length
|
||||
|
||||
#ifdef HWRENDER
|
||||
// new pointers so that AdjustSegs doesn't mess with v1/v2
|
||||
polyvertex_t *pv1;
|
||||
polyvertex_t *pv2;
|
||||
floatvertex_t fv1;
|
||||
floatvertex_t fv2;
|
||||
#endif
|
||||
|
||||
polyobj_t *polyseg;
|
||||
|
||||
+139
-171
@@ -41,41 +41,40 @@
|
||||
|
||||
/** \brief view info
|
||||
*/
|
||||
INT32 linesize, viewwidth, viewheight, viewwindowx, viewwindowy;
|
||||
UINT8 *renderscreen; // haleyjd
|
||||
INT32 viewwidth = 0, viewheight = 0, viewwindowx = 0, viewwindowy = 0;
|
||||
|
||||
// =========================================================================
|
||||
// COLUMN DRAWING CODE STUFF
|
||||
// =========================================================================
|
||||
|
||||
drawcolumndata_t g_dc;
|
||||
drawcolumndata_t g_dc = {};
|
||||
|
||||
// -----------------------
|
||||
// translucency stuff here
|
||||
// -----------------------
|
||||
#define NUMTRANSTABLES 9 // how many translucency tables are used
|
||||
|
||||
UINT8 *transtables; // translucency tables
|
||||
UINT8 *blendtables[NUMBLENDMAPS];
|
||||
UINT8 *transtables = NULL; // translucency tables
|
||||
UINT8 *blendtables[NUMBLENDMAPS] = {};
|
||||
|
||||
// --------------------------------------------
|
||||
// c drawer routines
|
||||
// --------------------------------------------
|
||||
|
||||
coldrawfunc_t *colfunc;
|
||||
coldrawfunc_t *colfuncs[COLDRAWFUNC_MAX];
|
||||
int colfunctype;
|
||||
coldrawfunc_t *colfunc = NULL;
|
||||
coldrawfunc_t *colfuncs[COLDRAWFUNC_MAX] = {};
|
||||
int colfunctype = 0;
|
||||
|
||||
// =========================================================================
|
||||
// SPAN DRAWING CODE STUFF
|
||||
// =========================================================================
|
||||
|
||||
drawspandata_t g_ds;
|
||||
drawspandata_t g_ds = {};
|
||||
|
||||
// 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.
|
||||
//static INT32 *tiltlighting;
|
||||
@@ -84,8 +83,8 @@ float focallengthf;
|
||||
// c drawer routines
|
||||
// --------------------------------------------
|
||||
|
||||
spandrawfunc_t *spanfunc;
|
||||
spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX];
|
||||
spandrawfunc_t *spanfunc = NULL;
|
||||
spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX] = {};
|
||||
|
||||
// ==========================================================================
|
||||
// OLD DOOM FUZZY EFFECT
|
||||
@@ -106,14 +105,15 @@ spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX];
|
||||
#define DEFAULT_STARTTRANSCOLOR 160
|
||||
#define NUM_PALETTE_ENTRIES 256
|
||||
|
||||
static UINT8 **translationtablecache[TT_CACHE_SIZE] = {NULL};
|
||||
static UINT8 **localtranslationtablecache[MAXLOCALSKINS] = {NULL};
|
||||
static UINT8 **translationtablecache[TT_CACHE_SIZE] = {};
|
||||
static UINT8 **localtranslationtablecache[MAXLOCALSKINS] = {};
|
||||
|
||||
CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1];
|
||||
CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1] = {};
|
||||
|
||||
struct GenerateBlendTables_State
|
||||
{
|
||||
RGBA_t *LocalPalette;
|
||||
RGBA_t *gammaCorrectedPalette;
|
||||
};
|
||||
|
||||
static void R_GenerateBlendTables_Core(struct GenerateBlendTables_State *state);
|
||||
@@ -127,6 +127,7 @@ static void R_GenerateBlendTables_Thread(void *userdata)
|
||||
R_GenerateBlendTables_Core(state);
|
||||
|
||||
free(state->LocalPalette);
|
||||
free(state->gammaCorrectedPalette);
|
||||
free(state);
|
||||
}
|
||||
#endif
|
||||
@@ -155,26 +156,33 @@ void R_InitTranslucencyTables(void)
|
||||
}
|
||||
|
||||
static colorlookup_t transtab_lut;
|
||||
static colorlookup_t transtab_lut_corrected;
|
||||
|
||||
static void BlendTab_Translucent(UINT8 *table, int style, UINT8 blendamt)
|
||||
{
|
||||
INT16 bg, fg;
|
||||
RGBA_t backrgba, frontrgba, result;
|
||||
|
||||
if (table == NULL)
|
||||
I_Error("BlendTab_Translucent: input table was NULL!");
|
||||
|
||||
for (bg = 0; bg < 0x100; bg++)
|
||||
{
|
||||
backrgba = pGammaCorrectedPalette[bg];
|
||||
|
||||
for (fg = 0; fg < 0x100; fg++)
|
||||
{
|
||||
RGBA_t backrgba = V_GetColor(bg);
|
||||
RGBA_t frontrgba = V_GetColor(fg);
|
||||
RGBA_t result;
|
||||
frontrgba = pGammaCorrectedPalette[fg];
|
||||
|
||||
#if 0 // perfect implementation
|
||||
result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF);
|
||||
result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt);
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -225,7 +233,7 @@ static void BlendTab_Modulative(UINT8 *table)
|
||||
RGBA_t frontrgba = V_GetColor(fg);
|
||||
RGBA_t result;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -279,11 +287,12 @@ void R_GenerateBlendTables(void)
|
||||
size_t palsize = 256 * sizeof(RGBA_t);
|
||||
|
||||
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",
|
||||
R_GenerateBlendTables_Thread, state);
|
||||
#else
|
||||
struct GenerateBlendTables_State state = {pLocalPalette};
|
||||
struct GenerateBlendTables_State state = {pLocalPalette, pGammaCorrectedPalette};
|
||||
R_GenerateBlendTables_Core(&state);
|
||||
#endif
|
||||
}
|
||||
@@ -291,6 +300,7 @@ void R_GenerateBlendTables(void)
|
||||
static void R_GenerateBlendTables_Core(struct GenerateBlendTables_State *state)
|
||||
{
|
||||
InitColorLUT(&transtab_lut, state->LocalPalette, false);
|
||||
InitColorLUT(&transtab_lut_corrected, state->gammaCorrectedPalette, false);
|
||||
|
||||
// Additive
|
||||
BlendTab_GenerateMaps(blendtab_add, AST_ADD, BlendTab_Translucent);
|
||||
@@ -489,6 +499,92 @@ void R_FlushTranslationColormapCache(void)
|
||||
// in reality, the few routines that can work for either mode, are
|
||||
// put here
|
||||
|
||||
enum columncontext_e columncontext = COLUMNCONTEXT_DIRECT;
|
||||
|
||||
enum ColumnFlushType
|
||||
{
|
||||
FLUSH_NONE = 0x0000,
|
||||
FLUSH_OPAQUE = 0x0001,
|
||||
FLUSH_TRANS = 0x0002,
|
||||
FLUSH_COLORMAP = 0x0004,
|
||||
FLUSH_COLORMAP_TRANS = 0x0008,
|
||||
};
|
||||
|
||||
typedef struct drawcolumndata_temp_s
|
||||
{
|
||||
INT32 x;
|
||||
INT32 yl[8], yh[8];
|
||||
|
||||
// e6y: resolution limitation is removed
|
||||
UINT8 *buf;
|
||||
|
||||
INT32 startx;
|
||||
ColumnFlushType type;
|
||||
INT32 commontop, commonbot;
|
||||
UINT8 *transmap;
|
||||
// SoM 7-28-04: Fix the fuzz problem.
|
||||
UINT8 *translation;
|
||||
} drawcolumndata_temp_t;
|
||||
|
||||
drawcolumndata_temp_t temp_dc = {};
|
||||
|
||||
//
|
||||
// Error functions that will abort if R_FlushColumns tries to flush
|
||||
// columns without a column type.
|
||||
//
|
||||
FUNCNORETURN static ATTRNORETURN void R_FlushWholeError(void)
|
||||
{
|
||||
I_Error("R_FlushWholeColumns called without being initialized.\n");
|
||||
}
|
||||
|
||||
FUNCNORETURN static ATTRNORETURN void R_FlushHTError(void)
|
||||
{
|
||||
I_Error("R_FlushHTColumns called without being initialized.\n");
|
||||
}
|
||||
|
||||
FUNCNORETURN static ATTRNORETURN void R_QuadFlushError(void)
|
||||
{
|
||||
I_Error("R_FlushQuadColumn called without being initialized.\n");
|
||||
}
|
||||
|
||||
static void (*R_FlushWholeColumns)(void) = R_FlushWholeError;
|
||||
static void (*R_FlushHTColumns)(void) = R_FlushHTError;
|
||||
static void (*R_FlushQuadColumn)(void) = R_QuadFlushError;
|
||||
|
||||
static void R_FlushColumns(void)
|
||||
{
|
||||
if (temp_dc.x != 8 || temp_dc.commontop >= temp_dc.commonbot)
|
||||
R_FlushWholeColumns();
|
||||
else
|
||||
{
|
||||
R_FlushHTColumns();
|
||||
R_FlushQuadColumn();
|
||||
}
|
||||
|
||||
temp_dc.x = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// R_ResetColumnBuffer
|
||||
//
|
||||
// haleyjd 09/13/04: new function to call from main rendering loop
|
||||
// which gets rid of the unnecessary reset of various variables during
|
||||
// column drawing.
|
||||
//
|
||||
void R_ResetColumnBuffer(void)
|
||||
{
|
||||
// haleyjd 10/06/05: this must not be done if x == 0!
|
||||
if (temp_dc.x)
|
||||
{
|
||||
R_FlushColumns();
|
||||
}
|
||||
|
||||
temp_dc.type = FLUSH_NONE;
|
||||
R_FlushWholeColumns = R_FlushWholeError;
|
||||
R_FlushHTColumns = R_FlushHTError;
|
||||
R_FlushQuadColumn = R_QuadFlushError;
|
||||
}
|
||||
|
||||
/** \brief The R_InitViewBuffer function
|
||||
|
||||
Creates lookup tables for getting the framebuffer address
|
||||
@@ -521,40 +617,35 @@ static void R_AllocViewMemory(void)
|
||||
R_AllocVisSpriteMemory();
|
||||
}
|
||||
|
||||
|
||||
void R_InitViewBuffer(INT32 width, INT32 height)
|
||||
void R_InitViewBuffer(void)
|
||||
{
|
||||
if (width > MAXVIDWIDTH)
|
||||
width = MAXVIDWIDTH;
|
||||
if (height > MAXVIDHEIGHT)
|
||||
height = MAXVIDHEIGHT;
|
||||
|
||||
R_AllocViewMemory();
|
||||
|
||||
viewwindowx = 0;
|
||||
viewwindowy = 0;
|
||||
|
||||
linesize = vid.width; // killough 11/98
|
||||
renderscreen = vid.screens[0]; // haleyjd 07/02/14
|
||||
}
|
||||
INT32 bufsize = (vid.width * 8) * sizeof(*temp_dc.buf);
|
||||
|
||||
/** \brief viewborder patches lump numbers
|
||||
*/
|
||||
lumpnum_t viewborderlump[8];
|
||||
if (temp_dc.buf)
|
||||
{
|
||||
#if defined(__SSE__)
|
||||
aligned_free(temp_dc.buf);
|
||||
#else
|
||||
Z_Free(temp_dc.buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** \brief Store the lumpnumber of the viewborder patches
|
||||
*/
|
||||
memset(&temp_dc, 0, sizeof(temp_dc));
|
||||
|
||||
void R_InitViewBorder(void)
|
||||
{
|
||||
viewborderlump[BRDR_T] = W_GetNumForName("brdr_t");
|
||||
viewborderlump[BRDR_B] = W_GetNumForName("brdr_b");
|
||||
viewborderlump[BRDR_L] = W_GetNumForName("brdr_l");
|
||||
viewborderlump[BRDR_R] = W_GetNumForName("brdr_r");
|
||||
viewborderlump[BRDR_TL] = W_GetNumForName("brdr_tl");
|
||||
viewborderlump[BRDR_BL] = W_GetNumForName("brdr_bl");
|
||||
viewborderlump[BRDR_TR] = W_GetNumForName("brdr_tr");
|
||||
viewborderlump[BRDR_BR] = W_GetNumForName("brdr_br");
|
||||
#if defined(__SSE__)
|
||||
while (bufsize & 15)
|
||||
bufsize++;
|
||||
temp_dc.buf = static_cast<UINT8*>(aligned_alloc(16, bufsize));
|
||||
#else
|
||||
temp_dc.buf = static_cast<UINT8*>(Z_Malloc(bufsize, PU_STATIC, NULL));
|
||||
#endif
|
||||
|
||||
memset(temp_dc.buf, 0, bufsize);
|
||||
}
|
||||
|
||||
/** \brief The R_VideoErase function
|
||||
@@ -575,132 +666,9 @@ void R_VideoErase(size_t ofs, INT32 count)
|
||||
// is not optimal, e.g. byte by byte on
|
||||
// a 32bit CPU, as GNU GCC/Linux libc did
|
||||
// at one point.
|
||||
M_Memcpy(vid.screens[0] + ofs, vid.screens[1] + ofs, count);
|
||||
memcpy(vid.screens[0] + ofs, vid.screens[1] + ofs, count);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/** \brief R_FillBackScreen
|
||||
|
||||
Fills the back screen with a pattern for variable screen sizes
|
||||
Also draws a beveled edge.
|
||||
*/
|
||||
void R_FillBackScreen(void)
|
||||
{
|
||||
UINT8 *src, *dest;
|
||||
patch_t *patch;
|
||||
INT32 x, y, step, boff;
|
||||
|
||||
// quickfix, don't cache lumps in both modes
|
||||
if (rendermode != render_soft)
|
||||
return;
|
||||
|
||||
// draw pattern around the status bar too (when hires),
|
||||
// so return only when in full-screen without status bar.
|
||||
if (scaledviewwidth == vid.width && viewheight == vid.height)
|
||||
return;
|
||||
|
||||
src = scr_borderpatch;
|
||||
dest = vid.screens[1];
|
||||
|
||||
for (y = 0; y < vid.height; y++)
|
||||
{
|
||||
for (x = 0; x < vid.width/128; x++)
|
||||
{
|
||||
M_Memcpy (dest, src+((y&127)<<7), 128);
|
||||
dest += 128;
|
||||
}
|
||||
|
||||
if (vid.width&127)
|
||||
{
|
||||
M_Memcpy(dest, src+((y&127)<<7), vid.width&127);
|
||||
dest += (vid.width&127);
|
||||
}
|
||||
}
|
||||
|
||||
// don't draw the borders when viewwidth is full vid.width.
|
||||
if (scaledviewwidth == vid.width)
|
||||
return;
|
||||
|
||||
step = 8;
|
||||
boff = 8;
|
||||
|
||||
patch = W_CacheLumpNum(viewborderlump[BRDR_T], PU_CACHE);
|
||||
for (x = 0; x < scaledviewwidth; x += step)
|
||||
V_DrawPatch(viewwindowx + x, viewwindowy - boff, 1, patch);
|
||||
|
||||
patch = W_CacheLumpNum(viewborderlump[BRDR_B], PU_CACHE);
|
||||
for (x = 0; x < scaledviewwidth; x += step)
|
||||
V_DrawPatch(viewwindowx + x, viewwindowy + viewheight, 1, patch);
|
||||
|
||||
patch = W_CacheLumpNum(viewborderlump[BRDR_L], PU_CACHE);
|
||||
for (y = 0; y < viewheight; y += step)
|
||||
V_DrawPatch(viewwindowx - boff, viewwindowy + y, 1, patch);
|
||||
|
||||
patch = W_CacheLumpNum(viewborderlump[BRDR_R],PU_CACHE);
|
||||
for (y = 0; y < viewheight; y += step)
|
||||
V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy + y, 1,
|
||||
patch);
|
||||
|
||||
// Draw beveled corners.
|
||||
V_DrawPatch(viewwindowx - boff, viewwindowy - boff, 1,
|
||||
W_CacheLumpNum(viewborderlump[BRDR_TL], PU_CACHE));
|
||||
V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy - boff, 1,
|
||||
W_CacheLumpNum(viewborderlump[BRDR_TR], PU_CACHE));
|
||||
V_DrawPatch(viewwindowx - boff, viewwindowy + viewheight, 1,
|
||||
W_CacheLumpNum(viewborderlump[BRDR_BL], PU_CACHE));
|
||||
V_DrawPatch(viewwindowx + scaledviewwidth, viewwindowy + viewheight, 1,
|
||||
W_CacheLumpNum(viewborderlump[BRDR_BR], PU_CACHE));
|
||||
}
|
||||
|
||||
/** \brief The R_DrawViewBorder
|
||||
|
||||
Draws the border around the view
|
||||
for different size windows?
|
||||
*/
|
||||
void R_DrawViewBorder(void)
|
||||
{
|
||||
INT32 top, side, ofs;
|
||||
|
||||
if (rendermode == render_none)
|
||||
return;
|
||||
#ifdef HWRENDER
|
||||
if (rendermode != render_soft)
|
||||
{
|
||||
HWR_DrawViewBorder(0);
|
||||
return;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,"RDVB: vidwidth %d vidheight %d scaledviewwidth %d viewheight %d\n",
|
||||
vid.width, vid.height, scaledviewwidth, viewheight);
|
||||
#endif
|
||||
|
||||
if (scaledviewwidth == vid.width)
|
||||
return;
|
||||
|
||||
top = (vid.height - viewheight)>>1;
|
||||
side = (vid.width - scaledviewwidth)>>1;
|
||||
|
||||
// copy top and one line of left side
|
||||
R_VideoErase(0, top*vid.width+side);
|
||||
|
||||
// copy one line of right side and bottom
|
||||
ofs = (viewheight+top)*vid.width - side;
|
||||
R_VideoErase(ofs, top*vid.width + side);
|
||||
|
||||
// copy sides using wraparound
|
||||
ofs = top*vid.width + vid.width-side;
|
||||
side <<= 1;
|
||||
|
||||
// simpler using our VID_Blit routine
|
||||
VID_BlitLinearScreen(vid.screens[1] + ofs, vid.screens[0] + ofs, side, viewheight - 1,
|
||||
vid.width, vid.width);
|
||||
}
|
||||
#endif
|
||||
|
||||
// ==========================================================================
|
||||
// INCLUDE DRAWING CODE HERE
|
||||
// ==========================================================================
|
||||
|
||||
+24
-35
@@ -25,15 +25,12 @@ extern "C" {
|
||||
// -------------------------------
|
||||
// COMMON STUFF FOR 8bpp AND 16bpp
|
||||
// -------------------------------
|
||||
extern UINT8 *renderscreen;
|
||||
extern INT32 linesize;
|
||||
|
||||
FUNCINLINE static ATTRINLINE UINT8 *R_Address(INT32 px, INT32 py)
|
||||
{
|
||||
return renderscreen + (py + viewwindowy) * linesize + (viewwindowx + px);
|
||||
return vid.screens[0] + (py + viewwindowy) * vid.width + (viewwindowx + px);
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
float x, y, z;
|
||||
} floatv3_t;
|
||||
@@ -102,6 +99,16 @@ extern floatv3_t *ds_su, *ds_sv, *ds_sz;
|
||||
|
||||
extern float focallengthf;
|
||||
|
||||
enum columncontext_e
|
||||
{
|
||||
COLUMNCONTEXT_DIRECT = 0,
|
||||
COLUMNCONTEXT_FLUSH,
|
||||
};
|
||||
|
||||
extern enum columncontext_e columncontext;
|
||||
void R_SetColumnContext(enum columncontext_e _columncontext);
|
||||
|
||||
void R_ResetColumnBuffer(void);
|
||||
|
||||
typedef void (coldrawfunc_t)(drawcolumndata_t*);
|
||||
typedef void (spandrawfunc_t)(drawspandata_t*);
|
||||
@@ -152,29 +159,12 @@ extern spandrawfunc_t *spanfuncs[SPANDRAWFUNC_MAX];
|
||||
|
||||
void R_DrawMaskedColumn(drawcolumndata_t* dc, column_t *column);
|
||||
|
||||
/// \brief Top border
|
||||
#define BRDR_T 0
|
||||
/// \brief Bottom border
|
||||
#define BRDR_B 1
|
||||
/// \brief Left border
|
||||
#define BRDR_L 2
|
||||
/// \brief Right border
|
||||
#define BRDR_R 3
|
||||
/// \brief Topleft border
|
||||
#define BRDR_TL 4
|
||||
/// \brief Topright border
|
||||
#define BRDR_TR 5
|
||||
/// \brief Bottomleft border
|
||||
#define BRDR_BL 6
|
||||
/// \brief Bottomright border
|
||||
#define BRDR_BR 7
|
||||
|
||||
extern lumpnum_t viewborderlump[8];
|
||||
|
||||
// ------------------------------------------------
|
||||
// r_draw.c COMMON ROUTINES FOR BOTH 8bpp and 16bpp
|
||||
// r_draw.c
|
||||
// ------------------------------------------------
|
||||
|
||||
// Custom player skin translation
|
||||
|
||||
#define GTC_CACHE 1
|
||||
#define GTC_MENUCACHE GTC_CACHE
|
||||
//@TODO Add a separate caching mechanism for menu colormaps distinct from in-level GTC_CACHE. For now this is still preferable to memory leaks...
|
||||
@@ -219,19 +209,9 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel);
|
||||
|
||||
boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel);
|
||||
|
||||
// Custom player skin translation
|
||||
void R_InitViewBuffer(INT32 width, INT32 height);
|
||||
void R_InitViewBorder(void);
|
||||
void R_InitViewBuffer(void);
|
||||
void R_VideoErase(size_t ofs, INT32 count);
|
||||
|
||||
// Rendering function.
|
||||
#if 0
|
||||
void R_FillBackScreen(void);
|
||||
|
||||
// If the view size is not full screen, draws a border around it.
|
||||
void R_DrawViewBorder(void);
|
||||
#endif
|
||||
|
||||
#define TRANSPARENTPIXEL 247
|
||||
|
||||
// -----------------
|
||||
@@ -250,6 +230,15 @@ void R_DrawTranslatedTranslucentColumn(drawcolumndata_t* dc);
|
||||
void R_Draw2sMultiPatchColumn(drawcolumndata_t* dc);
|
||||
void R_Draw2sMultiPatchTranslucentColumn(drawcolumndata_t* dc);
|
||||
|
||||
// column drawers which use buffered drawing with flush
|
||||
void R_DrawColumn_Flush(drawcolumndata_t* dc);
|
||||
void R_DrawTranslucentColumn_Flush(drawcolumndata_t* dc);
|
||||
void R_DrawTranslatedColumn_Flush(drawcolumndata_t* dc);
|
||||
void R_DrawColumnShadowed_Flush(drawcolumndata_t* dc);
|
||||
void R_DrawTranslatedTranslucentColumn_Flush(drawcolumndata_t* dc);
|
||||
void R_Draw2sMultiPatchColumn_Flush(drawcolumndata_t* dc);
|
||||
void R_Draw2sMultiPatchTranslucentColumn_Flush(drawcolumndata_t* dc);
|
||||
|
||||
void R_DrawFogColumn(drawcolumndata_t* dc);
|
||||
|
||||
// span drawers
|
||||
|
||||
+64
-18
@@ -21,6 +21,8 @@
|
||||
// a has a constant z depth from top to bottom.
|
||||
//
|
||||
|
||||
#include "r_draw_flush.cpp"
|
||||
|
||||
enum DrawColumnType
|
||||
{
|
||||
DC_BASIC = 0x0000,
|
||||
@@ -28,10 +30,12 @@ enum DrawColumnType
|
||||
DC_TRANSMAP = 0x0002,
|
||||
DC_HOLES = 0x0004,
|
||||
DC_LIGHTLIST = 0x0008,
|
||||
DC_DIRECT = 0x0010, // draw our columns directly to screen!
|
||||
};
|
||||
|
||||
template<DrawColumnType Type>
|
||||
static constexpr UINT8 R_GetColumnTranslated(drawcolumndata_t* dc, UINT8 col, const UINT8 * restrict colormap)
|
||||
FUNCINLINE static ATTRINLINE constexpr UINT8
|
||||
R_GetColumnTranslated(const drawcolumndata_t* dc, UINT8 col, const UINT8 * restrict colormap)
|
||||
{
|
||||
if constexpr (Type & DrawColumnType::DC_COLORMAP)
|
||||
{
|
||||
@@ -41,8 +45,10 @@ static constexpr UINT8 R_GetColumnTranslated(drawcolumndata_t* dc, UINT8 col, co
|
||||
return colormap[col];
|
||||
}
|
||||
|
||||
// translucency is handled on flush side now!
|
||||
template<DrawColumnType Type>
|
||||
static constexpr UINT8 R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 * restrict dest, UINT8 col, const UINT8 * restrict colormap)
|
||||
FUNCINLINE static ATTRINLINE constexpr UINT8
|
||||
R_GetColumnTranslucent(const drawcolumndata_t* dc, UINT8 * restrict dest, UINT8 col, const UINT8 * restrict colormap)
|
||||
{
|
||||
col = R_GetColumnTranslated<Type>(dc, col, colormap);
|
||||
|
||||
@@ -57,7 +63,8 @@ static constexpr UINT8 R_GetColumnTranslucent(drawcolumndata_t* dc, UINT8 * rest
|
||||
}
|
||||
|
||||
template<DrawColumnType Type>
|
||||
static constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit, const UINT8 * restrict source, const UINT8 * restrict colormap)
|
||||
FUNCINLINE static ATTRINLINE constexpr UINT8
|
||||
R_DrawColumnPixel(const drawcolumndata_t* dc, UINT8 * restrict dest, UINT32 bit, const UINT8 * restrict source, const UINT8 * restrict colormap)
|
||||
{
|
||||
UINT8 col = source[bit];
|
||||
|
||||
@@ -69,6 +76,7 @@ static constexpr UINT8 R_DrawColumnPixel(drawcolumndata_t* dc, UINT8 * restrict
|
||||
}
|
||||
}
|
||||
|
||||
// if we dont buffer our columns, we need to handle translucency again
|
||||
return R_GetColumnTranslucent<Type>(dc, dest, col, colormap);
|
||||
}
|
||||
|
||||
@@ -80,8 +88,18 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
||||
{
|
||||
INT32 count;
|
||||
|
||||
// leban 1/17/99:
|
||||
// removed the + 1 here, adjusted the if test, and added an increment
|
||||
// later. this helps a compiler pipeline a bit better. the x86
|
||||
// assembler also does this.
|
||||
count = dc->yh - dc->yl;
|
||||
|
||||
// leban 1/17/99:
|
||||
// this case isn't executed too often. depending on how many instructions
|
||||
// there are between here and the second if test below, this case could
|
||||
// be moved down and might save instructions overall. since there are
|
||||
// probably different wads that favor one way or the other, i'll leave
|
||||
// this alone for now.
|
||||
if (count < 0) // Zero length, column does not exceed a pixel.
|
||||
{
|
||||
return;
|
||||
@@ -150,6 +168,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
||||
}
|
||||
|
||||
R_DrawColumnTemplate<NewType>(&dc_copy);
|
||||
|
||||
if (solid)
|
||||
{
|
||||
dc_copy.yl = bheight;
|
||||
@@ -183,19 +202,37 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
||||
// killough 2/1/98: more performance tuning
|
||||
|
||||
intptr_t frac;
|
||||
// Looks familiar.
|
||||
const intptr_t fracstep = dc->iscale;
|
||||
const intptr_t heightmask = dc->sourcelength-1;
|
||||
const intptr_t heightmask = dc->sourcelength-1; // CPhipps - specify type
|
||||
constexpr INT32 npow2min = -1;
|
||||
const INT32 npow2max = dc->sourcelength;
|
||||
const INT32 stride = vid.width;
|
||||
|
||||
const UINT8 * restrict source = dc->source;
|
||||
const lighttable_t * restrict colormap = dc->colormap;
|
||||
|
||||
// Framebuffer destination address.
|
||||
UINT8 * restrict dest = R_Address(dc->x, dc->yl);
|
||||
// SoM: MAGIC
|
||||
UINT8 * restrict dest;
|
||||
|
||||
count++;
|
||||
if constexpr (Type & DrawColumnType::DC_DIRECT)
|
||||
dest = R_Address(dc->x, dc->yl);
|
||||
else if constexpr ((Type & (DrawColumnType::DC_COLORMAP | DrawColumnType::DC_TRANSMAP))
|
||||
== (DrawColumnType::DC_COLORMAP | DrawColumnType::DC_TRANSMAP))
|
||||
dest = R_GetBufferColormapTrans(dc);
|
||||
else if constexpr (Type & DrawColumnType::DC_TRANSMAP)
|
||||
dest = R_GetBufferTrans(dc);
|
||||
else if constexpr (Type & DrawColumnType::DC_COLORMAP)
|
||||
dest = R_GetBufferColormap(dc);
|
||||
else
|
||||
dest = R_GetBufferOpaque(dc);
|
||||
|
||||
INT32 stride = 8; //SoM: Oh, Oh it's MAGIC! You know...
|
||||
|
||||
if constexpr (Type & DrawColumnType::DC_DIRECT)
|
||||
stride = vid.width;
|
||||
|
||||
count++; // killough 1/99: minor tuning
|
||||
|
||||
// Determine scaling, which is the only mapping to be done.
|
||||
frac = (dc->texturemid + FixedMul((dc->yl << FRACBITS) - centeryfrac, fracstep));
|
||||
@@ -205,15 +242,16 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
||||
case 255:
|
||||
case 127:
|
||||
{
|
||||
while(count--)
|
||||
while (count--)
|
||||
{
|
||||
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap);
|
||||
|
||||
dest += stride;
|
||||
frac += fracstep;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case -1:
|
||||
case npow2min:
|
||||
{
|
||||
if (frac < 0)
|
||||
// adjust in case we underread
|
||||
@@ -222,7 +260,8 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
||||
// texture has no height, so just go
|
||||
while (--count >= 0)
|
||||
{
|
||||
*dest = R_DrawColumnPixel<Type>(dc, dest, frac>>FRACBITS, source, colormap);
|
||||
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS), source, colormap);
|
||||
|
||||
dest += stride;
|
||||
frac += fracstep;
|
||||
}
|
||||
@@ -235,10 +274,12 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
||||
while ((count -= 2) >= 0) // texture height is a power of 2 -- killough
|
||||
{
|
||||
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap);
|
||||
|
||||
dest += stride;
|
||||
frac += fracstep;
|
||||
|
||||
*dest = R_DrawColumnPixel<Type>(dc, dest, (frac>>FRACBITS) & heightmask, source, colormap);
|
||||
|
||||
dest += stride;
|
||||
frac += fracstep;
|
||||
}
|
||||
@@ -271,7 +312,7 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
||||
{
|
||||
// Re-map color indices from wall texture column
|
||||
// using a lighting/special effects LUT.
|
||||
// heightmask is the Tutti-Frutti fix
|
||||
// heightmask is the Tutti-Frutti fix -- killough
|
||||
|
||||
// -1 is the lower clamp bound because column posts have a "safe" byte before the real data
|
||||
// and a few bytes after as well
|
||||
@@ -311,13 +352,18 @@ static void R_DrawColumnTemplate(drawcolumndata_t *dc)
|
||||
R_DrawColumnTemplate<opt>(dc); \
|
||||
}
|
||||
|
||||
DEFINE_COLUMN_FUNC(R_DrawColumn, DC_BASIC)
|
||||
DEFINE_COLUMN_FUNC(R_DrawTranslucentColumn, DC_TRANSMAP)
|
||||
DEFINE_COLUMN_FUNC(R_DrawTranslatedColumn, DC_COLORMAP)
|
||||
DEFINE_COLUMN_FUNC(R_DrawColumnShadowed, DC_LIGHTLIST)
|
||||
DEFINE_COLUMN_FUNC(R_DrawTranslatedTranslucentColumn, DC_COLORMAP|DC_TRANSMAP)
|
||||
DEFINE_COLUMN_FUNC(R_Draw2sMultiPatchColumn, DC_HOLES)
|
||||
DEFINE_COLUMN_FUNC(R_Draw2sMultiPatchTranslucentColumn, DC_HOLES|DC_TRANSMAP)
|
||||
#define DEFINE_COLUMN_COMBO(name, flags) \
|
||||
DEFINE_COLUMN_FUNC(name, flags|DC_DIRECT) \
|
||||
DEFINE_COLUMN_FUNC(name ## _Flush, flags)
|
||||
|
||||
DEFINE_COLUMN_COMBO(R_DrawColumn, DC_BASIC)
|
||||
DEFINE_COLUMN_COMBO(R_DrawTranslucentColumn, DC_TRANSMAP)
|
||||
DEFINE_COLUMN_COMBO(R_DrawTranslatedColumn, DC_COLORMAP)
|
||||
DEFINE_COLUMN_COMBO(R_DrawColumnShadowed, DC_LIGHTLIST)
|
||||
DEFINE_COLUMN_COMBO(R_DrawTranslatedTranslucentColumn, DC_COLORMAP|DC_TRANSMAP)
|
||||
DEFINE_COLUMN_COMBO(R_Draw2sMultiPatchColumn, DC_HOLES)
|
||||
DEFINE_COLUMN_COMBO(R_Draw2sMultiPatchTranslucentColumn, DC_HOLES|DC_TRANSMAP)
|
||||
|
||||
|
||||
/** \brief The R_DrawFogColumn function
|
||||
Fog wall.
|
||||
|
||||
@@ -0,0 +1,269 @@
|
||||
// SONIC ROBO BLAST 2 KART
|
||||
//-----------------------------------------------------------------------------
|
||||
// Copyright (C) 2025 by Kart Krew.
|
||||
// Copyright (C) 2020 by Sonic Team Junior.
|
||||
// Copyright (C) 2000 by DooM Legacy Team.
|
||||
// Copyright (C) 1996 by id Software, Inc.
|
||||
// Copyright (C) 1999 by Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
|
||||
// Copyright (C) 1999-2000 by Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
|
||||
// Copyright (C) Copyright 2005, 2006 by Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
|
||||
// Copyright (C) 2013 by James Haley, Stephen McGranahan, et al.
|
||||
//
|
||||
// This program is free software distributed under the
|
||||
// terms of the GNU General Public License, version 2.
|
||||
// See the 'LICENSE' file for more details.
|
||||
//-----------------------------------------------------------------------------
|
||||
/// \file r_draw_flush.cpp
|
||||
/// \brief Optimized quad column buffer code. By SoM.
|
||||
/// \note no includes because this is included as part of r_draw.cpp
|
||||
|
||||
template<ColumnFlushType Type>
|
||||
FUNCINLINE static ATTRINLINE constexpr UINT8
|
||||
R_GetFlushPixelTranslated(const drawcolumndata_temp_t *t_dc, UINT8 col)
|
||||
{
|
||||
if constexpr (Type & (ColumnFlushType::FLUSH_COLORMAP | ColumnFlushType::FLUSH_COLORMAP_TRANS))
|
||||
{
|
||||
col = t_dc->translation[col];
|
||||
}
|
||||
|
||||
return col;
|
||||
}
|
||||
|
||||
template<ColumnFlushType Type>
|
||||
FUNCINLINE static ATTRINLINE constexpr UINT8
|
||||
R_GetFlushPixelTranslucent(const drawcolumndata_temp_t *t_dc, UINT8 * restrict dest, UINT8 col)
|
||||
{
|
||||
col = R_GetFlushPixelTranslated<Type>(t_dc, col);
|
||||
|
||||
if constexpr (Type & (ColumnFlushType::FLUSH_TRANS | ColumnFlushType::FLUSH_COLORMAP_TRANS))
|
||||
{
|
||||
// haleyjd 09/11/04: use temptranmap here
|
||||
return *(t_dc->transmap + (col << 8) + (*dest));
|
||||
}
|
||||
else
|
||||
{
|
||||
return col;
|
||||
}
|
||||
}
|
||||
|
||||
template<ColumnFlushType Type>
|
||||
FUNCINLINE static ATTRINLINE constexpr UINT8
|
||||
R_DrawFlushPixel(const drawcolumndata_temp_t *t_dc, UINT8 * restrict dest, const UINT8 * restrict source)
|
||||
{
|
||||
UINT8 col = *source;
|
||||
return R_GetFlushPixelTranslucent<Type>(t_dc, dest, col);
|
||||
}
|
||||
|
||||
//
|
||||
// R_FlushWhole
|
||||
//
|
||||
// Flushes the entire columns in the buffer, one at a time.
|
||||
// This is used when a quad flush isn't possible.
|
||||
//
|
||||
template<ColumnFlushType Type>
|
||||
static void R_FlushWhole(void)
|
||||
{
|
||||
UINT8 * restrict source;
|
||||
UINT8 * restrict dest;
|
||||
INT32 count, yl;
|
||||
const INT32 stride = vid.width;
|
||||
drawcolumndata_temp_t *t_dc = &temp_dc;
|
||||
UINT8 *restrict buf = t_dc->buf;
|
||||
|
||||
while (--t_dc->x >= 0)
|
||||
{
|
||||
yl = t_dc->yl[t_dc->x];
|
||||
source = &buf[t_dc->x + (yl << 3)];
|
||||
dest = R_Address(t_dc->startx + t_dc->x, yl);
|
||||
count = t_dc->yh[t_dc->x] - yl + 1;
|
||||
|
||||
while (--count >= 0)
|
||||
{
|
||||
*dest = R_DrawFlushPixel<Type>(t_dc, dest, source);
|
||||
source += 8;
|
||||
dest += stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// R_FlushHT
|
||||
//
|
||||
// Flushes the head and tail of columns in the buffer in
|
||||
// preparation for a quad flush.
|
||||
//
|
||||
template<ColumnFlushType Type>
|
||||
static void R_FlushHT(void)
|
||||
{
|
||||
UINT8 * restrict source;
|
||||
UINT8 * restrict dest;
|
||||
INT32 count, colnum = 0;
|
||||
INT32 yl, yh;
|
||||
const INT32 stride = vid.width;
|
||||
const drawcolumndata_temp_t *t_dc = &temp_dc;
|
||||
UINT8 *restrict buf = t_dc->buf;
|
||||
|
||||
while (colnum < 8)
|
||||
{
|
||||
yl = t_dc->yl[colnum];
|
||||
yh = t_dc->yh[colnum];
|
||||
|
||||
// flush column head
|
||||
if (yl < t_dc->commontop)
|
||||
{
|
||||
source = &buf[colnum + (yl << 3)];
|
||||
dest = R_Address(t_dc->startx + colnum, yl);
|
||||
count = t_dc->commontop - yl;
|
||||
|
||||
while (--count >= 0)
|
||||
{
|
||||
*dest = R_DrawFlushPixel<Type>(t_dc, dest, source);
|
||||
source += 8;
|
||||
dest += stride;
|
||||
}
|
||||
}
|
||||
|
||||
// flush column tail
|
||||
if (yh > t_dc->commonbot)
|
||||
{
|
||||
source = &buf[colnum + ((t_dc->commonbot + 1) << 3)];
|
||||
dest = R_Address(t_dc->startx + colnum, t_dc->commonbot + 1);
|
||||
count = yh - t_dc->commonbot;
|
||||
|
||||
while (--count >= 0)
|
||||
{
|
||||
*dest = R_DrawFlushPixel<Type>(t_dc, dest, source);
|
||||
source += 8;
|
||||
dest += stride;
|
||||
}
|
||||
}
|
||||
|
||||
++colnum;
|
||||
}
|
||||
}
|
||||
|
||||
// Begin: Quad column flushing functions.
|
||||
template<ColumnFlushType Type>
|
||||
static void R_FlushQuad(void)
|
||||
{
|
||||
const INT32 stride = vid.width;
|
||||
const drawcolumndata_temp_t *t_dc = &temp_dc;
|
||||
INT32 count = t_dc->commonbot - t_dc->commontop + 1;
|
||||
const UINT8 *restrict buf = t_dc->buf;
|
||||
|
||||
const UINT8 * restrict source = buf + (t_dc->commontop << 3);
|
||||
UINT8 * restrict dest = R_Address(t_dc->startx, t_dc->commontop);
|
||||
|
||||
if constexpr (Type & ColumnFlushType::FLUSH_OPAQUE)
|
||||
{
|
||||
#if __SIZEOF_POINTER__ >= 8 // does not make much sense on 32bit targets
|
||||
// 8 byte aligned copy -- make sure our dest ptr, source ptr AND stride are a multiple of 8!
|
||||
if ((((uintptr_t)dest | (uintptr_t)source | stride) & 7) == 0)
|
||||
{
|
||||
const INT64 *source64 = reinterpret_cast<const INT64 *>(source);
|
||||
INT64 *dest64 = reinterpret_cast<INT64 *>(dest);
|
||||
const INT32 deststep = stride / 8;
|
||||
|
||||
while (--count >= 0)
|
||||
{
|
||||
*dest64 = *source64++;
|
||||
dest64 += deststep;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
while (--count >= 0)
|
||||
{
|
||||
dest[0] = source[0];
|
||||
dest[1] = source[1];
|
||||
dest[2] = source[2];
|
||||
dest[3] = source[3];
|
||||
dest[4] = source[4];
|
||||
dest[5] = source[5];
|
||||
dest[6] = source[6];
|
||||
dest[7] = source[7];
|
||||
source += 8;
|
||||
dest += stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (--count >= 0)
|
||||
{
|
||||
dest[0] = R_DrawFlushPixel<Type>(t_dc, &dest[0], &source[0]);
|
||||
dest[1] = R_DrawFlushPixel<Type>(t_dc, &dest[1], &source[1]);
|
||||
dest[2] = R_DrawFlushPixel<Type>(t_dc, &dest[2], &source[2]);
|
||||
dest[3] = R_DrawFlushPixel<Type>(t_dc, &dest[3], &source[3]);
|
||||
dest[4] = R_DrawFlushPixel<Type>(t_dc, &dest[4], &source[4]);
|
||||
dest[5] = R_DrawFlushPixel<Type>(t_dc, &dest[5], &source[5]);
|
||||
dest[6] = R_DrawFlushPixel<Type>(t_dc, &dest[6], &source[6]);
|
||||
dest[7] = R_DrawFlushPixel<Type>(t_dc, &dest[7], &source[7]);
|
||||
source += 8;
|
||||
dest += stride;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// haleyjd 09/12/04: split up R_GetBuffer into various different
|
||||
// functions to minimize the number of branches and take advantage
|
||||
// of as much precalculated information as possible.
|
||||
template<ColumnFlushType Type>
|
||||
static UINT8 *R_GetBuffer(drawcolumndata_t *dc)
|
||||
{
|
||||
drawcolumndata_temp_t *t_dc = &temp_dc;
|
||||
|
||||
// haleyjd: reordered predicates
|
||||
if (t_dc->x == 8 ||
|
||||
(t_dc->x && (t_dc->type != Type || t_dc->x + t_dc->startx != dc->x)))
|
||||
R_FlushColumns();
|
||||
|
||||
if (!t_dc->x)
|
||||
{
|
||||
++t_dc->x;
|
||||
t_dc->startx = dc->x;
|
||||
t_dc->yl[0] = t_dc->commontop = dc->yl;
|
||||
t_dc->yh[0] = t_dc->commonbot = dc->yh;
|
||||
t_dc->type = Type;
|
||||
|
||||
if constexpr (Type & (ColumnFlushType::FLUSH_TRANS | ColumnFlushType::FLUSH_COLORMAP_TRANS))
|
||||
{
|
||||
t_dc->transmap = dc->transmap;
|
||||
}
|
||||
|
||||
if constexpr (Type & (ColumnFlushType::FLUSH_COLORMAP | ColumnFlushType::FLUSH_COLORMAP_TRANS))
|
||||
{
|
||||
t_dc->translation = dc->translation;
|
||||
}
|
||||
|
||||
R_FlushWholeColumns = R_FlushWhole<Type>;
|
||||
R_FlushHTColumns = R_FlushHT<Type>;
|
||||
R_FlushQuadColumn = R_FlushQuad<Type>;
|
||||
|
||||
return &t_dc->buf[dc->yl << 3];
|
||||
}
|
||||
|
||||
t_dc->yl[t_dc->x] = dc->yl;
|
||||
t_dc->yh[t_dc->x] = dc->yh;
|
||||
|
||||
if (dc->yl > t_dc->commontop)
|
||||
t_dc->commontop = dc->yl;
|
||||
if (dc->yh < t_dc->commonbot)
|
||||
t_dc->commonbot = dc->yh;
|
||||
|
||||
return &t_dc->buf[(dc->yl << 3) + t_dc->x++];
|
||||
}
|
||||
|
||||
#define DEFINE_GETBUF_FUNC(name, flags) \
|
||||
FUNCINLINE static ATTRINLINE UINT8 *name(drawcolumndata_t *dc) \
|
||||
{ \
|
||||
constexpr ColumnFlushType opt = static_cast<ColumnFlushType>(flags); \
|
||||
return R_GetBuffer<opt>(dc); \
|
||||
}
|
||||
|
||||
DEFINE_GETBUF_FUNC(R_GetBufferOpaque, FLUSH_OPAQUE)
|
||||
DEFINE_GETBUF_FUNC(R_GetBufferTrans, FLUSH_TRANS)
|
||||
DEFINE_GETBUF_FUNC(R_GetBufferColormap, FLUSH_COLORMAP)
|
||||
DEFINE_GETBUF_FUNC(R_GetBufferColormapTrans, FLUSH_COLORMAP_TRANS)
|
||||
|
||||
+75
-46
@@ -28,6 +28,8 @@
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "cxxutil.hpp"
|
||||
|
||||
// ==========================================================================
|
||||
// SPANS
|
||||
// ==========================================================================
|
||||
@@ -50,7 +52,8 @@ enum DrawSpanType
|
||||
};
|
||||
|
||||
template<DrawSpanType Type>
|
||||
static constexpr UINT8 R_GetSpanTranslated(drawspandata_t* ds, UINT8 col)
|
||||
FUNCINLINE static ATTRINLINE constexpr UINT8
|
||||
R_GetSpanTranslated(const drawspandata_t* ds, UINT8 col)
|
||||
{
|
||||
if constexpr (Type & DrawSpanType::DS_COLORMAP)
|
||||
{
|
||||
@@ -63,7 +66,8 @@ static constexpr UINT8 R_GetSpanTranslated(drawspandata_t* ds, UINT8 col)
|
||||
}
|
||||
|
||||
template<DrawSpanType Type>
|
||||
static constexpr UINT8 R_GetSpanTranslucent(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT8 col)
|
||||
FUNCINLINE static ATTRINLINE constexpr UINT8
|
||||
R_GetSpanTranslucent(const drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT8 col)
|
||||
{
|
||||
col = colormap[R_GetSpanTranslated<Type>(ds, col)];
|
||||
|
||||
@@ -78,7 +82,8 @@ static constexpr UINT8 R_GetSpanTranslucent(drawspandata_t* ds, UINT8 *dsrc, con
|
||||
}
|
||||
|
||||
template<DrawSpanType Type>
|
||||
static constexpr UINT8 R_DrawSpanPixel(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT32 bit, const UINT8 *source)
|
||||
FUNCINLINE static ATTRINLINE constexpr UINT8
|
||||
R_DrawSpanPixel(const drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT32 bit, const UINT8 *source)
|
||||
{
|
||||
UINT8 col = source[bit];
|
||||
|
||||
@@ -157,14 +162,18 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
|
||||
{
|
||||
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
|
||||
|
||||
dest[i] = R_DrawSpanPixel<Type>(ds, &dsrc[i], colormap, bit, source);
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
dest[i] = R_DrawSpanPixel<Type>(ds, &dsrc[i], colormap, bit, source);
|
||||
else
|
||||
dest[i] = R_DrawSpanPixel<Type>(ds, &dest[i], colormap, bit, source);
|
||||
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
}
|
||||
|
||||
dest += 8;
|
||||
dsrc += 8;
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
dsrc += 8;
|
||||
|
||||
count -= 8;
|
||||
}
|
||||
@@ -173,10 +182,14 @@ static void R_DrawSpanTemplate(drawspandata_t* ds)
|
||||
{
|
||||
bit = ((yposition >> ds->nflatyshift) & ds->nflatmask) | (xposition >> ds->nflatxshift);
|
||||
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
|
||||
else
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dest, colormap, bit, source);
|
||||
|
||||
dest++;
|
||||
dsrc++;
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
dsrc++;
|
||||
|
||||
xposition += xstep;
|
||||
yposition += ystep;
|
||||
@@ -197,15 +210,15 @@ static void R_CalcTiltedLighting(std::vector<INT32>& lightbuffer, INT32 x1, INT3
|
||||
|
||||
for (i = x1; i <= x2; i++)
|
||||
{
|
||||
fixed_t light = start >> FRACBITS;
|
||||
const fixed_t light = start >> FRACBITS;
|
||||
lightbuffer[i] = CLAMP(light, 0, MAXLIGHTSCALE - 1);
|
||||
start += step;
|
||||
}
|
||||
}
|
||||
|
||||
static void R_GetTiltedLighting(std::vector<INT32>& tiltlighting, const drawspandata_t* ds, const float iz, const int width, const INT32 stride)
|
||||
static void R_GetTiltedLighting(std::vector<INT32>& tiltlighting, const drawspandata_t* ds, const float iz, const INT32 width, const INT32 stride)
|
||||
{
|
||||
float planelightfloat = PLANELIGHTFLOAT;
|
||||
const float planelightfloat = PLANELIGHTFLOAT;
|
||||
const fixed_t lightstart = FloatToFixed(iz * planelightfloat);
|
||||
const fixed_t lightend = FloatToFixed((iz + ds->szp.x * width) * planelightfloat);
|
||||
|
||||
@@ -221,7 +234,7 @@ static void R_GetTiltedLighting(std::vector<INT32>& tiltlighting, const drawspan
|
||||
template<DrawSpanType Type>
|
||||
static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
{
|
||||
int width = ds->x2 - ds->x1;
|
||||
INT32 width = ds->x2 - ds->x1;
|
||||
float iz, uz, vz;
|
||||
UINT32 u, v;
|
||||
int i;
|
||||
@@ -235,7 +248,6 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
UINT32 stepu, stepv;
|
||||
UINT32 bit;
|
||||
|
||||
INT32 x1 = ds->x1;
|
||||
const INT32 nflatxshift = ds->nflatxshift;
|
||||
const INT32 nflatyshift = ds->nflatyshift;
|
||||
const INT32 nflatmask = ds->nflatmask;
|
||||
@@ -243,15 +255,19 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
local_for_thread std::vector<INT32> tiltlighting;
|
||||
|
||||
iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
|
||||
uz = ds->sup.z + ds->sup.y*(centery-ds->y) + ds->sup.x*(ds->x1-centerx);
|
||||
vz = ds->svp.z + ds->svp.y*(centery-ds->y) + ds->svp.x*(ds->x1-centerx);
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
R_GetTiltedLighting(tiltlighting, ds, iz, width, stride);
|
||||
|
||||
uz = ds->sup.z + ds->sup.y*(centery-ds->y) + ds->sup.x*(ds->x1-centerx);
|
||||
vz = ds->svp.z + ds->svp.y*(centery-ds->y) + ds->svp.x*(ds->x1-centerx);
|
||||
const UINT8 * restrict source = ds->source;
|
||||
const UINT8 * restrict colormap = ds->colormap;
|
||||
|
||||
const UINT8 *source = ds->source;
|
||||
const UINT8 *colormap = ds->colormap;
|
||||
const ptrdiff_t colormap_diff = (colormap - colormaps);
|
||||
|
||||
const INT32 * restrict tiltlight = tiltlighting.data();
|
||||
lighttable_t * const * restrict planezlight = ds->planezlight;
|
||||
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
{
|
||||
@@ -290,7 +306,6 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
izstep = ds->szp.x * SPANSIZE;
|
||||
uzstep = ds->sup.x * SPANSIZE;
|
||||
vzstep = ds->svp.x * SPANSIZE;
|
||||
//x1 = 0;
|
||||
width++;
|
||||
|
||||
while (width >= SPANSIZE)
|
||||
@@ -302,23 +317,27 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
endz = 1.f/iz;
|
||||
endu = uz*endz;
|
||||
endv = vz*endz;
|
||||
stepu = (INT64)((endu - startu) * INVSPAN);
|
||||
stepv = (INT64)((endv - startv) * INVSPAN);
|
||||
u = (INT64)(startu);
|
||||
v = (INT64)(startv);
|
||||
stepu = srb2::floattoint<float, INT64>((endu - startu) * INVSPAN);
|
||||
stepv = srb2::floattoint<float, INT64>((endv - startv) * INVSPAN);
|
||||
u = srb2::floattoint<float, INT64>(startu);
|
||||
v = srb2::floattoint<float, INT64>(startv);
|
||||
|
||||
x1 = ds->x1;
|
||||
const INT32 x1 = ds->x1;
|
||||
|
||||
for (i = 0; i < SPANSIZE; i++)
|
||||
{
|
||||
bit = (((v + stepv * i) >> nflatyshift) & nflatmask) | ((u + stepu * i) >> nflatxshift);
|
||||
colormap = ds->planezlight[tiltlighting[x1 + i]] + (ds->colormap - colormaps);
|
||||
dest[i] = R_DrawSpanPixel<Type>(ds, &dsrc[i], colormap, bit, source);
|
||||
colormap = planezlight[tiltlight[x1 + i]] + colormap_diff;
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
dest[i] = R_DrawSpanPixel<Type>(ds, &dsrc[i], colormap, bit, source);
|
||||
else
|
||||
dest[i] = R_DrawSpanPixel<Type>(ds, &dest[i], colormap, bit, source);
|
||||
}
|
||||
|
||||
ds->x1 += SPANSIZE;
|
||||
dest += SPANSIZE;
|
||||
dsrc += SPANSIZE;
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
dsrc += SPANSIZE;
|
||||
startu = endu;
|
||||
startv = endv;
|
||||
width -= SPANSIZE;
|
||||
@@ -328,11 +347,14 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
{
|
||||
if (width == 1)
|
||||
{
|
||||
u = (INT64)(startu);
|
||||
v = (INT64)(startv);
|
||||
u = srb2::floattoint<float, INT64>(startu);
|
||||
v = srb2::floattoint<float, INT64>(startv);
|
||||
bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift);
|
||||
colormap = ds->planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps);
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
|
||||
colormap = planezlight[tiltlight[ds->x1]] + colormap_diff;
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
|
||||
else
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dest, colormap, bit, source);
|
||||
ds->x1++;
|
||||
}
|
||||
else
|
||||
@@ -346,19 +368,23 @@ static void R_DrawTiltedSpanTemplate(drawspandata_t* ds)
|
||||
endu = uz*endz;
|
||||
endv = vz*endz;
|
||||
left = 1.f/left;
|
||||
stepu = (INT64)((endu - startu) * left);
|
||||
stepv = (INT64)((endv - startv) * left);
|
||||
u = (INT64)(startu);
|
||||
v = (INT64)(startv);
|
||||
stepu = srb2::floattoint<float, INT64>((endu - startu) * left);
|
||||
stepv = srb2::floattoint<float, INT64>((endv - startv) * left);
|
||||
u = srb2::floattoint<float, INT64>(startu);
|
||||
v = srb2::floattoint<float, INT64>(startv);
|
||||
|
||||
for (; width != 0; width--)
|
||||
{
|
||||
bit = ((v >> ds->nflatyshift) & ds->nflatmask) | (u >> ds->nflatxshift);
|
||||
colormap = ds->planezlight[tiltlighting[ds->x1]] + (ds->colormap - colormaps);
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
|
||||
colormap = planezlight[tiltlight[ds->x1]] + colormap_diff;
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dsrc, colormap, bit, source);
|
||||
else
|
||||
*dest = R_DrawSpanPixel<Type>(ds, dest, colormap, bit, source);
|
||||
dest++;
|
||||
if constexpr (Type & DS_RIPPLE)
|
||||
dsrc++;
|
||||
ds->x1++;
|
||||
dsrc++;
|
||||
u += stepu;
|
||||
v += stepv;
|
||||
}
|
||||
@@ -389,11 +415,11 @@ DEFINE_SPAN_COMBO(R_DrawTranslucentWaterSpan, DS_TRANSMAP|DS_RIPPLE)
|
||||
*/
|
||||
void R_DrawFogSpan(drawspandata_t* ds)
|
||||
{
|
||||
intptr_t count = ds->x2 - ds->x1 + 1;
|
||||
|
||||
const UINT8 * restrict colormap = ds->colormap;
|
||||
UINT8 * restrict dest = R_Address(ds->x1, ds->y);
|
||||
|
||||
intptr_t count = ds->x2 - ds->x1 + 1;
|
||||
|
||||
while (count >= 4)
|
||||
{
|
||||
dest[0] = colormap[dest[0]];
|
||||
@@ -401,7 +427,7 @@ void R_DrawFogSpan(drawspandata_t* ds)
|
||||
dest[2] = colormap[dest[2]];
|
||||
dest[3] = colormap[dest[3]];
|
||||
|
||||
dest += 4;
|
||||
dest += 4;
|
||||
count -= 4;
|
||||
}
|
||||
|
||||
@@ -414,20 +440,23 @@ void R_DrawFogSpan(drawspandata_t* ds)
|
||||
|
||||
void R_DrawFogSpan_Tilted(drawspandata_t* ds)
|
||||
{
|
||||
int width = ds->x2 - ds->x1;
|
||||
float iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
|
||||
UINT8 * restrict dest;
|
||||
local_for_thread std::vector<INT32> tiltlighting;
|
||||
|
||||
dest = R_Address(ds->x1, ds->y);
|
||||
INT32 width = ds->x2 - ds->x1;
|
||||
const INT32 stride = vid.width;
|
||||
const float iz = ds->szp.z + ds->szp.y*(centery-ds->y) + ds->szp.x*(ds->x1-centerx);
|
||||
UINT8 * restrict dest = R_Address(ds->x1, ds->y);
|
||||
const ptrdiff_t colormap_diff = (ds->colormap - colormaps);
|
||||
|
||||
local_for_thread std::vector<INT32> tiltlighting;
|
||||
|
||||
// Lighting is simple. It's just linear interpolation from start to end
|
||||
R_GetTiltedLighting(tiltlighting, ds, iz, width, stride);
|
||||
|
||||
const INT32 * restrict tiltlight = tiltlighting.data();
|
||||
lighttable_t * const * restrict planezlight = ds->planezlight;
|
||||
|
||||
do
|
||||
{
|
||||
UINT8 *colormap = ds->planezlight[tiltlighting[ds->x1++]] + (ds->colormap - colormaps);
|
||||
UINT8 *colormap = planezlight[tiltlight[ds->x1++]] + colormap_diff;
|
||||
*dest = colormap[*dest];
|
||||
dest++;
|
||||
}
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ static vector3_t *R_LerpVector3(const vector3_t *from, const vector3_t *to, fixe
|
||||
// recalc necessary stuff for mouseaiming
|
||||
// slopes are already calculated for the full possible view (which is 4*viewheight).
|
||||
// 18/08/18: (No it's actually 16*viewheight, thanks Lactozilla for finding this out)
|
||||
static void R_SetupFreelook(void)
|
||||
void R_SetupFreelook(void)
|
||||
{
|
||||
// clip it in the case we are looking a hardware 90 degrees full aiming
|
||||
// (lmps, network and use F12...)
|
||||
|
||||
@@ -151,6 +151,7 @@ typedef struct levelinterpolator_s {
|
||||
};
|
||||
} levelinterpolator_t;
|
||||
|
||||
void R_SetupFreelook(void);
|
||||
// Interpolates the current view variables (r_state.h) against the selected view context in R_SetViewContext
|
||||
void R_InterpolateView(fixed_t frac, boolean forceinvalid);
|
||||
// Special function just for software
|
||||
|
||||
Loaded 100 of 134 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user