Compare commits
62
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fed7020da1 | ||
|
|
1a4255d9df | ||
|
|
f6ead71f0c | ||
|
|
966f60f590 | ||
|
|
9afc018a45 | ||
|
|
43608810da | ||
|
|
90b5f9050a | ||
|
|
edc10a35a1 | ||
|
|
91435fe1b2 | ||
|
|
a7ebc7e745 | ||
|
|
3cf3c1bb99 | ||
|
|
2c170f1956 | ||
|
|
98da654e02 | ||
|
|
af84105e40 | ||
|
|
a1666704e5 | ||
|
|
7b408a33d7 | ||
|
|
9ee535066e | ||
|
|
6430150b63 | ||
|
|
16cf4ede89 | ||
|
|
efe8732188 | ||
|
|
07fc0eb03a | ||
|
|
f2b46fd148 | ||
|
|
8247133966 | ||
|
|
397fb071e5 | ||
|
|
1a9fa94cbd | ||
|
|
e8c7cc6a9b | ||
|
|
5ca3ab5966 | ||
|
|
1cf04514b3 | ||
|
|
5577ba4c7a | ||
|
|
6ff1cbf4b0 | ||
|
|
db4cd73912 | ||
|
|
1ec29c1c94 | ||
|
|
1e51365cad | ||
|
|
94026e4331 | ||
|
|
2084cdc6d5 | ||
|
|
1b22c3af19 | ||
|
|
3e327263c9 | ||
|
|
7c24d92613 | ||
|
|
3204b5c3b4 | ||
|
|
cd02242a01 | ||
|
|
6cbb8a36cf | ||
|
|
bf1aa47854 | ||
|
|
be423b2910 | ||
|
|
3bf3bdf641 | ||
|
|
e923777eb6 | ||
|
|
cf6eb0010e | ||
|
|
5184115216 | ||
|
|
39a46e8f79 | ||
|
|
d9712cf85e | ||
|
|
0691e2d9e2 | ||
|
|
08864e27b2 | ||
|
|
4a3c9ccfbb | ||
|
|
cedd789a27 | ||
|
|
8f91707164 | ||
|
|
37eba186f5 | ||
|
|
7eb2ad1e35 | ||
|
|
f49e57a38c | ||
|
|
265f4a50ef | ||
|
|
e83e2659a7 | ||
|
|
c680dd3222 | ||
|
|
96aaaf5261 | ||
|
|
efb29e6be5 |
No files matched your search
+3
-3
@@ -269,13 +269,13 @@ endif
|
|||||||
|
|
||||||
ifdef USEASAN
|
ifdef USEASAN
|
||||||
# compile with asan
|
# compile with asan
|
||||||
opts+=-fsanitize=address
|
opts+=-O1 -fsanitize=address -fno-omit-frame-pointer -fno-common
|
||||||
libs+=-fsanitize=address
|
libs+=-fsanitize=address
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef USEUBSAN
|
ifdef USEUBSAN
|
||||||
# compile with asan
|
# compile with ubsan
|
||||||
opts+=-fsanitize=undefined
|
opts+=-O1 -fsanitize=undefined -fno-omit-frame-pointer
|
||||||
libs+=-fsanitize=undefined
|
libs+=-fsanitize=undefined
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
+13
-12
@@ -20,7 +20,8 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\
|
|||||||
CXXFLAGS+= -Wno-aggregate-return
|
CXXFLAGS+= -Wno-aggregate-return
|
||||||
|
|
||||||
# -W -Wno-unused
|
# -W -Wno-unused
|
||||||
WFLAGS:=-Wall -Wno-trigraphs -Wnull-dereference
|
WFLAGS:=-Wall -Wnull-dereference
|
||||||
|
#WFLAGS+=-Wno-trigraphs
|
||||||
ifdef GCC152
|
ifdef GCC152
|
||||||
WFLAGS+=-Wzero-as-null-pointer-constant
|
WFLAGS+=-Wzero-as-null-pointer-constant
|
||||||
endif
|
endif
|
||||||
@@ -31,7 +32,7 @@ ifndef RELAXWARNINGS
|
|||||||
WFLAGS+=-W
|
WFLAGS+=-W
|
||||||
#WFLAGS+=-Wno-sign-compare
|
#WFLAGS+=-Wno-sign-compare
|
||||||
ifndef GCC295
|
ifndef GCC295
|
||||||
WFLAGS+=-Wno-div-by-zero
|
# WFLAGS+=-Wno-div-by-zero
|
||||||
endif
|
endif
|
||||||
#WFLAGS+=-Wsystem-headers
|
#WFLAGS+=-Wsystem-headers
|
||||||
WFLAGS+=-Wfloat-equal
|
WFLAGS+=-Wfloat-equal
|
||||||
@@ -62,7 +63,7 @@ endif
|
|||||||
endif
|
endif
|
||||||
WFLAGS+=-Wsign-compare
|
WFLAGS+=-Wsign-compare
|
||||||
ifdef GCC91
|
ifdef GCC91
|
||||||
WFLAGS+=-Wno-error=address-of-packed-member
|
# WFLAGS+=-Wno-error=address-of-packed-member
|
||||||
endif
|
endif
|
||||||
ifdef GCC45
|
ifdef GCC45
|
||||||
WFLAGS+=-Wlogical-op
|
WFLAGS+=-Wlogical-op
|
||||||
@@ -105,14 +106,14 @@ endif
|
|||||||
endif
|
endif
|
||||||
WFLAGS+=-Wformat-y2k
|
WFLAGS+=-Wformat-y2k
|
||||||
ifdef GCC71
|
ifdef GCC71
|
||||||
WFLAGS+=-Wno-error=format-overflow=2
|
#WFLAGS+=-Wno-error=format-overflow=2
|
||||||
endif
|
endif
|
||||||
WFLAGS+=-Wformat-security
|
WFLAGS+=-Wformat-security
|
||||||
ifndef GCC29
|
ifndef GCC29
|
||||||
#WFLAGS+=-Winit-self
|
#WFLAGS+=-Winit-self
|
||||||
endif
|
endif
|
||||||
ifdef GCC46
|
ifdef GCC46
|
||||||
WFLAGS+=-Wno-suggest-attribute=noreturn
|
#WFLAGS+=-Wno-suggest-attribute=noreturn
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef NOLDWARNING
|
ifdef NOLDWARNING
|
||||||
@@ -130,21 +131,21 @@ ifdef GCC44
|
|||||||
#WFLAGS+=-Wno-error=array-bounds
|
#WFLAGS+=-Wno-error=array-bounds
|
||||||
endif
|
endif
|
||||||
ifdef GCC46
|
ifdef GCC46
|
||||||
WFLAGS+=-Wno-error=suggest-attribute=noreturn
|
# WFLAGS+=-Wno-error=suggest-attribute=noreturn
|
||||||
endif
|
endif
|
||||||
ifdef GCC54
|
ifdef GCC54
|
||||||
WFLAGS+=-Wno-logical-op -Wno-error=logical-op
|
# WFLAGS+=-Wno-logical-op -Wno-error=logical-op
|
||||||
endif
|
endif
|
||||||
ifdef GCC61
|
ifdef GCC61
|
||||||
WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare
|
# WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare
|
||||||
endif
|
endif
|
||||||
ifdef GCC71
|
ifdef GCC71
|
||||||
WFLAGS+=-Wimplicit-fallthrough=4
|
WFLAGS+=-Wimplicit-fallthrough=4
|
||||||
endif
|
endif
|
||||||
ifdef GCC81
|
ifdef GCC81
|
||||||
WFLAGS+=-Wno-error=format-overflow
|
# WFLAGS+=-Wno-error=format-overflow
|
||||||
WFLAGS+=-Wno-format-overflow
|
# WFLAGS+=-Wno-format-overflow
|
||||||
WFLAGS+=-Wno-error=multistatement-macros
|
# WFLAGS+=-Wno-error=multistatement-macros
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter $(CC) $(CXX),clang clang++))
|
ifneq (,$(filter $(CC) $(CXX),clang clang++))
|
||||||
@@ -183,6 +184,6 @@ endif
|
|||||||
# Lua
|
# Lua
|
||||||
ifdef GCC43
|
ifdef GCC43
|
||||||
ifndef GCC44
|
ifndef GCC44
|
||||||
WFLAGS+=-Wno-logical-op
|
#WFLAGS+=-Wno-logical-op
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
+15
-3
@@ -20,6 +20,7 @@
|
|||||||
#define lauxlib_c
|
#define lauxlib_c
|
||||||
#define LUA_LIB
|
#define LUA_LIB
|
||||||
|
|
||||||
|
#include "ldebug.h"
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
|
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
@@ -468,8 +469,19 @@ LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
|
|||||||
|
|
||||||
|
|
||||||
LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
|
LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
|
||||||
while (l--)
|
while (l) {
|
||||||
luaL_addchar(B, *s++);
|
size_t space = bufffree(B);
|
||||||
|
if (space == 0) {
|
||||||
|
luaL_prepbuffer(B);
|
||||||
|
lua_assert(bufffree(B) == LUAL_BUFFERSIZE);
|
||||||
|
space = LUAL_BUFFERSIZE;
|
||||||
|
}
|
||||||
|
if (space > l) space = l;
|
||||||
|
memcpy(B->p, s, space);
|
||||||
|
B->p += space;
|
||||||
|
s += space;
|
||||||
|
l -= space;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -686,6 +698,6 @@ static int panic (lua_State *L) {
|
|||||||
|
|
||||||
LUALIB_API lua_State *luaL_newstate (void) {
|
LUALIB_API lua_State *luaL_newstate (void) {
|
||||||
lua_State *L = lua_newstate(l_alloc, NULL);
|
lua_State *L = lua_newstate(l_alloc, NULL);
|
||||||
if (L) lua_atpanic(L, &panic);
|
if (l_likely(L)) lua_atpanic(L, &panic);
|
||||||
return L;
|
return L;
|
||||||
}
|
}
|
||||||
+13
-12
@@ -790,18 +790,19 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
|
|||||||
case OPR_BXOR: codearith(fs, OP_BXOR, e1, e2); break;
|
case OPR_BXOR: codearith(fs, OP_BXOR, e1, e2); break;
|
||||||
case OPR_BSHL: codearith(fs, OP_BSHL, e1, e2); break;
|
case OPR_BSHL: codearith(fs, OP_BSHL, e1, e2); break;
|
||||||
case OPR_BSHR: codearith(fs, OP_BSHR, e1, e2); break;
|
case OPR_BSHR: codearith(fs, OP_BSHR, e1, e2); break;
|
||||||
case OPR_ADD: codearith(fs, OP_ADD, e1, e2); break;
|
case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
|
||||||
case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break;
|
case OPR_MOD: case OPR_POW: {
|
||||||
case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break;
|
codearith(fs, op - OPR_ADD + OP_ADD, e1, e2);
|
||||||
case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break;
|
break;
|
||||||
case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break;
|
}
|
||||||
case OPR_POW: codearith(fs, OP_POW, e1, e2); break;
|
case OPR_EQ: case OPR_LT: case OPR_LE: {
|
||||||
case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break;
|
codecomp(fs, op - OPR_EQ + OP_EQ, 1, e1, e2);
|
||||||
case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break;
|
break;
|
||||||
case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break;
|
}
|
||||||
case OPR_LE: codecomp(fs, OP_LE, 1, e1, e2); break;
|
case OPR_NE: case OPR_GT: case OPR_GE: {
|
||||||
case OPR_GT: codecomp(fs, OP_LT, 0, e1, e2); break;
|
codecomp(fs, op - OPR_NE + OP_EQ, 0, e1, e2);
|
||||||
case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break;
|
break;
|
||||||
|
}
|
||||||
default: lua_assert(0);
|
default: lua_assert(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -21,13 +21,13 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** grep "ORDER OPR" if you change these enums
|
** grep "ORDER OPR" if you change these enums (ORDER OP)
|
||||||
*/
|
*/
|
||||||
typedef enum BinOpr {
|
typedef enum BinOpr {
|
||||||
OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
|
OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
|
||||||
OPR_CONCAT,
|
OPR_CONCAT,
|
||||||
OPR_NE, OPR_EQ,
|
OPR_EQ, OPR_LT, OPR_LE,
|
||||||
OPR_LT, OPR_LE, OPR_GT, OPR_GE,
|
OPR_NE, OPR_GT, OPR_GE,
|
||||||
OPR_AND, OPR_OR,
|
OPR_AND, OPR_OR,
|
||||||
OPR_BAND, OPR_BOR, OPR_BXOR,
|
OPR_BAND, OPR_BOR, OPR_BXOR,
|
||||||
OPR_BSHL, OPR_BSHR,
|
OPR_BSHL, OPR_BSHR,
|
||||||
|
|||||||
+27
-4
@@ -542,16 +542,39 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int stackpos,
|
|||||||
|
|
||||||
|
|
||||||
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
|
static const char *getfuncname (lua_State *L, CallInfo *ci, const char **name) {
|
||||||
|
TMS tm = 0;
|
||||||
Instruction i;
|
Instruction i;
|
||||||
if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
|
if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
|
||||||
return NULL; /* calling function is not Lua (or is unknown) */
|
return NULL; /* calling function is not Lua (or is unknown) */
|
||||||
ci--; /* calling function */
|
ci--; /* calling function */
|
||||||
i = ci_func(ci)->l.p->code[currentpc(L, ci)];
|
i = ci_func(ci)->l.p->code[currentpc(L, ci)];
|
||||||
if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL ||
|
switch (GET_OPCODE(i)) {
|
||||||
GET_OPCODE(i) == OP_TFORLOOP)
|
case OP_CALL:
|
||||||
|
case OP_TAILCALL:
|
||||||
|
case OP_TFORLOOP:
|
||||||
return getobjname(L, ci, GETARG_A(i), name);
|
return getobjname(L, ci, GETARG_A(i), name);
|
||||||
else
|
case OP_GETGLOBAL:
|
||||||
return NULL; /* no useful name can be found */
|
case OP_SELF:
|
||||||
|
case OP_GETTABLE: tm = TM_INDEX; break;
|
||||||
|
case OP_SETGLOBAL:
|
||||||
|
case OP_SETTABLE: tm = TM_NEWINDEX; break;
|
||||||
|
case OP_EQ: tm = TM_EQ; break;
|
||||||
|
case OP_ADD: tm = TM_ADD; break;
|
||||||
|
case OP_SUB: tm = TM_SUB; break;
|
||||||
|
case OP_MUL: tm = TM_MUL; break;
|
||||||
|
case OP_DIV: tm = TM_DIV; break;
|
||||||
|
case OP_MOD: tm = TM_MOD; break;
|
||||||
|
case OP_POW: tm = TM_POW; break;
|
||||||
|
case OP_UNM: tm = TM_UNM; break;
|
||||||
|
case OP_LEN: tm = TM_LEN; break;
|
||||||
|
case OP_LT: tm = TM_LT; break;
|
||||||
|
case OP_LE: tm = TM_LE; break;
|
||||||
|
case OP_CONCAT: tm = TM_CONCAT; break;
|
||||||
|
default:
|
||||||
|
return NULL; /* else no useful name can be found */
|
||||||
|
}
|
||||||
|
*name = getstr(G(L)->tmname[tm]);
|
||||||
|
return "metamethod";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -164,7 +164,7 @@ void luaD_reallocCI (lua_State *L, int newsize) {
|
|||||||
|
|
||||||
|
|
||||||
void luaD_growstack (lua_State *L, int n) {
|
void luaD_growstack (lua_State *L, int n) {
|
||||||
if (l_likely(n <= L->stacksize)) /* double size is enough? */
|
if (n <= L->stacksize) /* double size is enough? */
|
||||||
luaD_reallocstack(L, 2*L->stacksize);
|
luaD_reallocstack(L, 2*L->stacksize);
|
||||||
else
|
else
|
||||||
luaD_reallocstack(L, L->stacksize + n);
|
luaD_reallocstack(L, L->stacksize + n);
|
||||||
@@ -318,7 +318,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) {
|
|||||||
ci->top = L->top + LUA_MINSTACK;
|
ci->top = L->top + LUA_MINSTACK;
|
||||||
lua_assert(ci->top <= L->stack_last);
|
lua_assert(ci->top <= L->stack_last);
|
||||||
ci->nresults = nresults;
|
ci->nresults = nresults;
|
||||||
if (L->hookmask & LUA_MASKCALL)
|
if (l_unlikely(L->hookmask & LUA_MASKCALL))
|
||||||
luaD_callhook(L, LUA_HOOKCALL, -1);
|
luaD_callhook(L, LUA_HOOKCALL, -1);
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
n = (*curr_func(L)->c.f)(L); /* do the actual call */
|
n = (*curr_func(L)->c.f)(L); /* do the actual call */
|
||||||
|
|||||||
+10
-9
@@ -356,20 +356,21 @@ static int read_line (lua_State *L, FILE *f) {
|
|||||||
|
|
||||||
|
|
||||||
static int read_chars (lua_State *L, FILE *f, size_t n) {
|
static int read_chars (lua_State *L, FILE *f, size_t n) {
|
||||||
size_t rlen; /* how much to read */
|
size_t tbr = n; /* number of chars to be read */
|
||||||
size_t nr; /* number of chars actually read */
|
size_t rlen; /* how much to read in each cycle */
|
||||||
|
size_t nr; /* number of chars actually read in each cycle */
|
||||||
luaL_Buffer b;
|
luaL_Buffer b;
|
||||||
luaL_buffinit(L, &b);
|
luaL_buffinit(L, &b);
|
||||||
rlen = LUAL_BUFFERSIZE; /* try to read that much each time */
|
rlen = LUAL_BUFFERSIZE; /* try to read that much each time */
|
||||||
do {
|
do {
|
||||||
char *p = luaL_prepbuffer(&b);
|
char *p = luaL_prepbuffer(&b);
|
||||||
if (rlen > n) rlen = n; /* cannot read more than asked */
|
if (rlen > tbr) rlen = tbr; /* cannot read more than asked */
|
||||||
nr = fread(p, sizeof(char), rlen, f);
|
nr = fread(p, sizeof(char), rlen, f);
|
||||||
luaL_addsize(&b, nr);
|
luaL_addsize(&b, nr);
|
||||||
n -= nr; /* still have to read `n' chars */
|
tbr -= nr; /* still have to read 'tbr' chars */
|
||||||
} while (n > 0 && nr == rlen); /* until end of count or eof */
|
} while (tbr > 0 && nr == rlen); /* until end of count or eof */
|
||||||
luaL_pushresult(&b); /* close buffer */
|
luaL_pushresult(&b); /* close buffer */
|
||||||
return (n == 0 || lua_objlen(L, -1) > 0);
|
return (tbr == 0 || tbr < n); /* true iff read something */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -432,13 +433,13 @@ static int f_read (lua_State *L) {
|
|||||||
|
|
||||||
static int io_readline (lua_State *L) {
|
static int io_readline (lua_State *L) {
|
||||||
FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1));
|
FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1));
|
||||||
int sucess;
|
int success;
|
||||||
if (f == NULL) /* file is already closed? */
|
if (f == NULL) /* file is already closed? */
|
||||||
luaL_error(L, "file is already closed");
|
luaL_error(L, "file is already closed");
|
||||||
sucess = read_line(L, f);
|
success = read_line(L, f);
|
||||||
if (ferror(f))
|
if (ferror(f))
|
||||||
return luaL_error(L, "%s", strerror(errno));
|
return luaL_error(L, "%s", strerror(errno));
|
||||||
if (sucess) return 1;
|
if (success) return 1;
|
||||||
else { /* EOF */
|
else { /* EOF */
|
||||||
if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */
|
if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */
|
||||||
lua_settop(L, 0);
|
lua_settop(L, 0);
|
||||||
|
|||||||
+4
-4
@@ -881,10 +881,10 @@ static const struct {
|
|||||||
lu_byte right; /* right priority */
|
lu_byte right; /* right priority */
|
||||||
} priority[] = { /* ORDER OPR */
|
} priority[] = { /* ORDER OPR */
|
||||||
{6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */
|
{6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */
|
||||||
{10, 9}, {5, 4}, /* power and concat (right associative) */
|
{10, 9}, {5, 4}, /* ^, .. (right associative) */
|
||||||
{3, 3}, {3, 3}, /* equality and inequality */
|
{3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */
|
||||||
{3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */
|
{3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */
|
||||||
{2, 2}, {1, 1} /* logical (and/or) */
|
{2, 2}, {1, 1} /* and, or */
|
||||||
,{6, 6}, {6, 6}, {6, 6}, /* bit-wise (band/bor/bxor) */
|
,{6, 6}, {6, 6}, {6, 6}, /* bit-wise (band/bor/bxor) */
|
||||||
{7, 7}, {7, 7} /* shl/shr */
|
{7, 7}, {7, 7} /* shl/shr */
|
||||||
};
|
};
|
||||||
|
|||||||
+58
-4
@@ -51,7 +51,7 @@ static TString *newlstr (lua_State *L, const char *str, size_t l,
|
|||||||
unsigned int h) {
|
unsigned int h) {
|
||||||
TString *ts;
|
TString *ts;
|
||||||
stringtable *tb;
|
stringtable *tb;
|
||||||
if (l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char))
|
if (l_unlikely(l+1 > (MAX_SIZET - sizeof(TString))/sizeof(char)))
|
||||||
luaM_toobig(L);
|
luaM_toobig(L);
|
||||||
ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString)));
|
ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString)));
|
||||||
ts->tsv.len = l;
|
ts->tsv.len = l;
|
||||||
@@ -72,18 +72,72 @@ static TString *newlstr (lua_State *L, const char *str, size_t l,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
|
// string hash taken from luaJIT
|
||||||
GCObject *o;
|
|
||||||
|
/* Unaligned load of uint32_t. */
|
||||||
|
static inline __attribute__((always_inline)) uint32_t getu32(const void* ptr)
|
||||||
|
{
|
||||||
|
uint32_t result;
|
||||||
|
memcpy(&result, ptr, 4);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// smol macro to look a little less messy lul
|
||||||
|
#define getu8(p) *cast(const uint8_t *, p)
|
||||||
|
|
||||||
|
/* Keyed sparse ARX string hash. Constant time. */
|
||||||
|
static unsigned hash_sparse(const char *str, size_t len)
|
||||||
|
{
|
||||||
|
/* Constants taken from lookup3 hash by Bob Jenkins. */
|
||||||
|
unsigned int a, b, h = cast(unsigned int, len);
|
||||||
|
#define rol(x, n) (((x)<<(n)) | ((x)>>(-cast(int, n)&(8*sizeof(x)-1))))
|
||||||
|
if (len >= 4) { /* Caveat: unaligned access! */
|
||||||
|
a = getu32(str);
|
||||||
|
h ^= getu32(str+len-4);
|
||||||
|
b = getu32(str+(len>>1)-2);
|
||||||
|
h ^= b; h -= rol(b, 14);
|
||||||
|
b += getu32(str+(len>>2)-1);
|
||||||
|
} else if (len > 0) {
|
||||||
|
a = getu8(str);
|
||||||
|
h ^= getu8(str+len-1);
|
||||||
|
b = getu8(str+(len>>1));
|
||||||
|
h ^= b; h -= rol(b, 14);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
a ^= h; a -= rol(h, 11);
|
||||||
|
b ^= a; b -= rol(a, 25);
|
||||||
|
h ^= b; h -= rol(b, 16);
|
||||||
|
#undef rol
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef getu8
|
||||||
|
|
||||||
|
|
||||||
|
static inline __attribute__((always_inline)) unsigned luaS_hash (const char *str, size_t l) {
|
||||||
|
#if 0
|
||||||
unsigned int h = cast(unsigned int, l); /* seed */
|
unsigned int h = cast(unsigned int, l); /* seed */
|
||||||
size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
|
size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
|
||||||
size_t l1;
|
size_t l1;
|
||||||
for (l1=l; l1>=step; l1-=step) /* compute hash */
|
for (l1=l; l1>=step; l1-=step) /* compute hash */
|
||||||
h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1]));
|
h = h ^ ((h<<5)+(h>>2)+cast(unsigned char, str[l1-1]));
|
||||||
|
return h;
|
||||||
|
#else
|
||||||
|
return hash_sparse(str, l);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
|
||||||
|
GCObject *o;
|
||||||
|
unsigned int h = luaS_hash(str, l);
|
||||||
for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
|
for (o = G(L)->strt.hash[lmod(h, G(L)->strt.size)];
|
||||||
o != NULL;
|
o != NULL;
|
||||||
o = o->gch.next) {
|
o = o->gch.next) {
|
||||||
TString *ts = rawgco2ts(o);
|
TString *ts = rawgco2ts(o);
|
||||||
if (l_unlikely(ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0))) {
|
if (ts->tsv.hash == h &&
|
||||||
|
ts->tsv.len == l &&
|
||||||
|
(memcmp(str, getstr(ts), l) == 0)) {
|
||||||
/* string may be dead */
|
/* string may be dead */
|
||||||
if (isdead(G(L), o)) changewhite(o);
|
if (isdead(G(L), o)) changewhite(o);
|
||||||
return ts;
|
return ts;
|
||||||
|
|||||||
+38
-6
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* limit for table tag-method chains (to avoid loops) */
|
/* limit for table tag-method chains (to avoid infinite loops) */
|
||||||
#define MAXTAGLOOP 100
|
#define MAXTAGLOOP 100
|
||||||
|
|
||||||
|
|
||||||
@@ -366,6 +366,7 @@ static void Arith (lua_State *L, StkId ra, TValue *rb,
|
|||||||
|
|
||||||
|
|
||||||
#define arith_op(op,tm) { \
|
#define arith_op(op,tm) { \
|
||||||
|
StkId ra = RA(i); \
|
||||||
TValue *rb = RKB(i); \
|
TValue *rb = RKB(i); \
|
||||||
TValue *rc = RKC(i); \
|
TValue *rc = RKC(i); \
|
||||||
if (ttisnumber(rb) && ttisnumber(rc)) { \
|
if (ttisnumber(rb) && ttisnumber(rc)) { \
|
||||||
@@ -392,7 +393,6 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
/* main loop of interpreter */
|
/* main loop of interpreter */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const Instruction i = *pc++;
|
const Instruction i = *pc++;
|
||||||
StkId ra;
|
|
||||||
if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
|
if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
|
||||||
(--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
|
(--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
|
||||||
traceexec(L, pc);
|
traceexec(L, pc);
|
||||||
@@ -402,26 +402,28 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
}
|
}
|
||||||
base = L->base;
|
base = L->base;
|
||||||
}
|
}
|
||||||
/* warning!! several calls may realloc the stack and invalidate `ra' */
|
|
||||||
ra = RA(i);
|
|
||||||
lua_assert(base == L->base && L->base == L->ci->base);
|
lua_assert(base == L->base && L->base == L->ci->base);
|
||||||
lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
|
lua_assert(base <= L->top && L->top <= L->stack + L->stacksize);
|
||||||
lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
|
lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
|
||||||
switch (GET_OPCODE(i)) {
|
switch (GET_OPCODE(i)) {
|
||||||
case OP_MOVE: {
|
case OP_MOVE: {
|
||||||
|
StkId ra = RA(i);
|
||||||
setobjs2s(L, ra, RB(i));
|
setobjs2s(L, ra, RB(i));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_LOADK: {
|
case OP_LOADK: {
|
||||||
|
StkId ra = RA(i);
|
||||||
setobj2s(L, ra, KBx(i));
|
setobj2s(L, ra, KBx(i));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_LOADBOOL: {
|
case OP_LOADBOOL: {
|
||||||
|
StkId ra = RA(i);
|
||||||
setbvalue(ra, GETARG_B(i));
|
setbvalue(ra, GETARG_B(i));
|
||||||
if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
|
if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_LOADNIL: {
|
case OP_LOADNIL: {
|
||||||
|
StkId ra = RA(i);
|
||||||
TValue *rb = RB(i);
|
TValue *rb = RB(i);
|
||||||
do {
|
do {
|
||||||
setnilvalue(rb--);
|
setnilvalue(rb--);
|
||||||
@@ -429,11 +431,13 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_GETUPVAL: {
|
case OP_GETUPVAL: {
|
||||||
|
StkId ra = RA(i);
|
||||||
int b = GETARG_B(i);
|
int b = GETARG_B(i);
|
||||||
setobj2s(L, ra, cl->upvals[b]->v);
|
setobj2s(L, ra, cl->upvals[b]->v);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_GETGLOBAL: {
|
case OP_GETGLOBAL: {
|
||||||
|
StkId ra = RA(i);
|
||||||
TValue g;
|
TValue g;
|
||||||
TValue *rb = KBx(i);
|
TValue *rb = KBx(i);
|
||||||
sethvalue(L, &g, cl->env);
|
sethvalue(L, &g, cl->env);
|
||||||
@@ -442,10 +446,14 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_GETTABLE: {
|
case OP_GETTABLE: {
|
||||||
Protect(luaV_gettable(L, RB(i), RKC(i), ra));
|
StkId ra = RA(i);
|
||||||
|
StkId rb = RB(i);
|
||||||
|
TValue *rc = RKC(i);
|
||||||
|
Protect(luaV_gettable(L, rb, rc, ra));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_SETGLOBAL: {
|
case OP_SETGLOBAL: {
|
||||||
|
StkId ra = RA(i);
|
||||||
TValue g;
|
TValue g;
|
||||||
sethvalue(L, &g, cl->env);
|
sethvalue(L, &g, cl->env);
|
||||||
lua_assert(ttisstring(KBx(i)));
|
lua_assert(ttisstring(KBx(i)));
|
||||||
@@ -453,16 +461,21 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_SETUPVAL: {
|
case OP_SETUPVAL: {
|
||||||
|
StkId ra = RA(i);
|
||||||
UpVal *uv = cl->upvals[GETARG_B(i)];
|
UpVal *uv = cl->upvals[GETARG_B(i)];
|
||||||
setobj(L, uv->v, ra);
|
setobj(L, uv->v, ra);
|
||||||
luaC_barrier(L, uv, ra);
|
luaC_barrier(L, uv, ra);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_SETTABLE: {
|
case OP_SETTABLE: {
|
||||||
Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
|
StkId ra = RA(i);
|
||||||
|
TValue *rb = RKB(i);
|
||||||
|
TValue *rc = RKC(i);
|
||||||
|
Protect(luaV_settable(L, ra, rb, rc));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_NEWTABLE: {
|
case OP_NEWTABLE: {
|
||||||
|
StkId ra = RA(i);
|
||||||
int b = GETARG_B(i);
|
int b = GETARG_B(i);
|
||||||
int c = GETARG_C(i);
|
int c = GETARG_C(i);
|
||||||
sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
|
sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
|
||||||
@@ -470,6 +483,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_SELF: {
|
case OP_SELF: {
|
||||||
|
StkId ra = RA(i);
|
||||||
StkId rb = RB(i);
|
StkId rb = RB(i);
|
||||||
setobjs2s(L, ra+1, rb);
|
setobjs2s(L, ra+1, rb);
|
||||||
Protect(luaV_gettable(L, rb, RKC(i), ra));
|
Protect(luaV_gettable(L, rb, RKC(i), ra));
|
||||||
@@ -488,6 +502,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_DIV: {
|
case OP_DIV: {
|
||||||
|
StkId ra = RA(i);
|
||||||
TValue *rb = RKB(i);
|
TValue *rb = RKB(i);
|
||||||
TValue *rc = RKC(i);
|
TValue *rc = RKC(i);
|
||||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||||
@@ -503,6 +518,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_MOD: {
|
case OP_MOD: {
|
||||||
|
StkId ra = RA(i);
|
||||||
TValue *rb = RKB(i);
|
TValue *rb = RKB(i);
|
||||||
TValue *rc = RKC(i);
|
TValue *rc = RKC(i);
|
||||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||||
@@ -542,6 +558,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_BNOT: {
|
case OP_BNOT: {
|
||||||
|
StkId ra = RA(i);
|
||||||
TValue *rb = RB(i);
|
TValue *rb = RB(i);
|
||||||
if (ttisnumber(rb)) {
|
if (ttisnumber(rb)) {
|
||||||
lua_Number nb = nvalue(rb);
|
lua_Number nb = nvalue(rb);
|
||||||
@@ -553,6 +570,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_UNM: {
|
case OP_UNM: {
|
||||||
|
StkId ra = RA(i);
|
||||||
TValue *rb = RB(i);
|
TValue *rb = RB(i);
|
||||||
if (ttisnumber(rb)) {
|
if (ttisnumber(rb)) {
|
||||||
lua_Number nb = nvalue(rb);
|
lua_Number nb = nvalue(rb);
|
||||||
@@ -564,11 +582,13 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_NOT: {
|
case OP_NOT: {
|
||||||
|
StkId ra = RA(i);
|
||||||
int res = l_isfalse(RB(i)); /* next assignment may change this value */
|
int res = l_isfalse(RB(i)); /* next assignment may change this value */
|
||||||
setbvalue(ra, res);
|
setbvalue(ra, res);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_LEN: {
|
case OP_LEN: {
|
||||||
|
StkId ra = RA(i);
|
||||||
TValue *rb = RB(i);
|
TValue *rb = RB(i);
|
||||||
switch (ttype(rb)) {
|
switch (ttype(rb)) {
|
||||||
case LUA_TTABLE: {
|
case LUA_TTABLE: {
|
||||||
@@ -626,12 +646,14 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_TEST: {
|
case OP_TEST: {
|
||||||
|
StkId ra = RA(i);
|
||||||
if (l_isfalse(ra) != GETARG_C(i))
|
if (l_isfalse(ra) != GETARG_C(i))
|
||||||
dojump(L, pc, GETARG_sBx(*pc));
|
dojump(L, pc, GETARG_sBx(*pc));
|
||||||
pc++;
|
pc++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_TESTSET: {
|
case OP_TESTSET: {
|
||||||
|
StkId ra = RA(i);
|
||||||
TValue *rb = RB(i);
|
TValue *rb = RB(i);
|
||||||
if (l_isfalse(rb) != GETARG_C(i)) {
|
if (l_isfalse(rb) != GETARG_C(i)) {
|
||||||
setobjs2s(L, ra, rb);
|
setobjs2s(L, ra, rb);
|
||||||
@@ -641,6 +663,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_CALL: {
|
case OP_CALL: {
|
||||||
|
StkId ra = RA(i);
|
||||||
int b = GETARG_B(i);
|
int b = GETARG_B(i);
|
||||||
int nresults = GETARG_C(i) - 1;
|
int nresults = GETARG_C(i) - 1;
|
||||||
if (b != 0) L->top = ra+b; /* else previous instruction set top */
|
if (b != 0) L->top = ra+b; /* else previous instruction set top */
|
||||||
@@ -662,6 +685,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case OP_TAILCALL: {
|
case OP_TAILCALL: {
|
||||||
|
StkId ra = RA(i);
|
||||||
int b = GETARG_B(i);
|
int b = GETARG_B(i);
|
||||||
if (b != 0) L->top = ra+b; /* else previous instruction set top */
|
if (b != 0) L->top = ra+b; /* else previous instruction set top */
|
||||||
L->savedpc = pc;
|
L->savedpc = pc;
|
||||||
@@ -694,6 +718,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case OP_RETURN: {
|
case OP_RETURN: {
|
||||||
|
StkId ra = RA(i);
|
||||||
int b = GETARG_B(i);
|
int b = GETARG_B(i);
|
||||||
if (b != 0) L->top = ra+b-1;
|
if (b != 0) L->top = ra+b-1;
|
||||||
if (L->openupval) luaF_close(L, base);
|
if (L->openupval) luaF_close(L, base);
|
||||||
@@ -709,6 +734,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case OP_FORLOOP: {
|
case OP_FORLOOP: {
|
||||||
|
StkId ra = RA(i);
|
||||||
lua_Number step = nvalue(ra+2);
|
lua_Number step = nvalue(ra+2);
|
||||||
lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
|
lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
|
||||||
lua_Number limit = nvalue(ra+1);
|
lua_Number limit = nvalue(ra+1);
|
||||||
@@ -721,6 +747,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_FORPREP: {
|
case OP_FORPREP: {
|
||||||
|
StkId ra = RA(i);
|
||||||
const TValue *init = ra;
|
const TValue *init = ra;
|
||||||
const TValue *plimit = ra+1;
|
const TValue *plimit = ra+1;
|
||||||
const TValue *pstep = ra+2;
|
const TValue *pstep = ra+2;
|
||||||
@@ -737,6 +764,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_TFORLOOP: {
|
case OP_TFORLOOP: {
|
||||||
|
StkId ra = RA(i);
|
||||||
StkId cb = ra + 3; /* call base */
|
StkId cb = ra + 3; /* call base */
|
||||||
setobjs2s(L, cb+2, ra+2);
|
setobjs2s(L, cb+2, ra+2);
|
||||||
setobjs2s(L, cb+1, ra+1);
|
setobjs2s(L, cb+1, ra+1);
|
||||||
@@ -753,6 +781,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_SETLIST: {
|
case OP_SETLIST: {
|
||||||
|
StkId ra = RA(i);
|
||||||
int n = GETARG_B(i);
|
int n = GETARG_B(i);
|
||||||
int c = GETARG_C(i);
|
int c = GETARG_C(i);
|
||||||
int last;
|
int last;
|
||||||
@@ -775,10 +804,12 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_CLOSE: {
|
case OP_CLOSE: {
|
||||||
|
StkId ra = RA(i);
|
||||||
luaF_close(L, ra);
|
luaF_close(L, ra);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_CLOSURE: {
|
case OP_CLOSURE: {
|
||||||
|
StkId ra = RA(i);
|
||||||
Proto *p;
|
Proto *p;
|
||||||
Closure *ncl;
|
Closure *ncl;
|
||||||
int nup, j;
|
int nup, j;
|
||||||
@@ -799,6 +830,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_VARARG: {
|
case OP_VARARG: {
|
||||||
|
StkId ra = RA(i);
|
||||||
int b = GETARG_B(i) - 1;
|
int b = GETARG_B(i) - 1;
|
||||||
int j;
|
int j;
|
||||||
CallInfo *ci = L->ci;
|
CallInfo *ci = L->ci;
|
||||||
|
|||||||
+228
-200
@@ -173,11 +173,11 @@ static UINT16 resynch_delay[MAXNETNODES]; // delay time before the player can be
|
|||||||
static UINT32 resynch_status[MAXNETNODES]; // 0 bit means synched for that player, 1 means possibly desynched
|
static UINT32 resynch_status[MAXNETNODES]; // 0 bit means synched for that player, 1 means possibly desynched
|
||||||
static UINT8 resynch_sent[MAXNETNODES][MAXPLAYERS]; // what synch packets have we attempted to send to the player
|
static UINT8 resynch_sent[MAXNETNODES][MAXPLAYERS]; // what synch packets have we attempted to send to the player
|
||||||
static UINT8 resynch_inprogress[MAXNETNODES];
|
static UINT8 resynch_inprogress[MAXNETNODES];
|
||||||
static UINT8 resynch_local_inprogress = false; // WE are desynched and getting packets to fix it.
|
static boolean resynch_local_inprogress = false; // WE are desynched and getting packets to fix it.
|
||||||
UINT8 hu_resynching = 0;
|
boolean hu_resynching = false;
|
||||||
|
|
||||||
#ifdef SATURNPAK
|
#ifdef SATURNPAK
|
||||||
UINT8 hu_redownloadinggamestate = 0;
|
boolean hu_redownloadinggamestate = false;
|
||||||
static UINT8 gamestate_resend_counter[MAXNETNODES];
|
static UINT8 gamestate_resend_counter[MAXNETNODES];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -192,7 +192,7 @@ static UINT8 mynode; // my address pointofview server
|
|||||||
|
|
||||||
#ifdef SATURNPAK
|
#ifdef SATURNPAK
|
||||||
static boolean cl_redownloadinggamestate = false;
|
static boolean cl_redownloadinggamestate = false;
|
||||||
boolean is_client_saturn[MAXNETNODES];
|
static boolean is_client_saturn[MAXNETNODES];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SATURNJOIN
|
#ifdef SATURNJOIN
|
||||||
@@ -212,14 +212,9 @@ tic_t firstconnectattempttime = 0;
|
|||||||
|
|
||||||
// engine
|
// engine
|
||||||
|
|
||||||
// Must be a power of two
|
|
||||||
#define TEXTCMD_HASH_SIZE 4
|
|
||||||
|
|
||||||
typedef struct textcmdtic_s
|
typedef struct textcmdtic_s
|
||||||
{
|
{
|
||||||
tic_t tic;
|
|
||||||
UINT8 *playercmds[MAXPLAYERS];
|
UINT8 *playercmds[MAXPLAYERS];
|
||||||
struct textcmdtic_s *next;
|
|
||||||
} textcmdtic_t;
|
} textcmdtic_t;
|
||||||
|
|
||||||
typedef struct textcmdbuf_s textcmdbuf_t;
|
typedef struct textcmdbuf_s textcmdbuf_t;
|
||||||
@@ -234,7 +229,7 @@ static textcmdbuf_t *textcmdbuf[MAXSPLITSCREENPLAYERS] = {NULL};
|
|||||||
|
|
||||||
static ticcmd_t playercmds[MAXPLAYERS];
|
static ticcmd_t playercmds[MAXPLAYERS];
|
||||||
ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS] = {};
|
ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS] = {};
|
||||||
static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL};
|
static textcmdtic_t *textcmds[BACKUPTICS] = {NULL};
|
||||||
|
|
||||||
consvar_t cv_showjoinaddress = {"showjoinaddress", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_showjoinaddress = {"showjoinaddress", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
@@ -396,20 +391,10 @@ void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_
|
|||||||
// Frees all textcmd memory for the specified tic
|
// Frees all textcmd memory for the specified tic
|
||||||
static void D_FreeTextcmd(tic_t tic)
|
static void D_FreeTextcmd(tic_t tic)
|
||||||
{
|
{
|
||||||
textcmdtic_t **tctprev = &textcmds[tic & (TEXTCMD_HASH_SIZE - 1)];
|
textcmdtic_t *textcmdtic = textcmds[tic%BACKUPTICS];
|
||||||
textcmdtic_t *textcmdtic = *tctprev;
|
|
||||||
|
|
||||||
while (textcmdtic && textcmdtic->tic != tic)
|
|
||||||
{
|
|
||||||
tctprev = &textcmdtic->next;
|
|
||||||
textcmdtic = textcmdtic->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (textcmdtic)
|
if (textcmdtic)
|
||||||
{
|
{
|
||||||
// Remove this tic from the list.
|
|
||||||
*tctprev = textcmdtic->next;
|
|
||||||
|
|
||||||
// Free all players.
|
// Free all players.
|
||||||
for (INT32 i = 0; i < MAXPLAYERS; i++)
|
for (INT32 i = 0; i < MAXPLAYERS; i++)
|
||||||
{
|
{
|
||||||
@@ -418,14 +403,14 @@ static void D_FreeTextcmd(tic_t tic)
|
|||||||
|
|
||||||
// Free this tic's own memory.
|
// Free this tic's own memory.
|
||||||
Z_Free(textcmdtic);
|
Z_Free(textcmdtic);
|
||||||
|
textcmds[tic%BACKUPTICS] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the buffer for the specified ticcmd, or NULL if there isn't one
|
// Gets the buffer for the specified ticcmd, or NULL if there isn't one
|
||||||
static UINT8* D_GetExistingTextcmd(tic_t tic, INT32 playernum)
|
static UINT8* D_GetExistingTextcmd(tic_t tic, INT32 playernum)
|
||||||
{
|
{
|
||||||
textcmdtic_t *textcmdtic = textcmds[tic & (TEXTCMD_HASH_SIZE - 1)];
|
textcmdtic_t *textcmdtic = textcmds[tic%BACKUPTICS];
|
||||||
while (textcmdtic && textcmdtic->tic != tic) textcmdtic = textcmdtic->next;
|
|
||||||
|
|
||||||
// Do we have an entry for the tic? If so, look for player.
|
// Do we have an entry for the tic? If so, look for player.
|
||||||
if (textcmdtic)
|
if (textcmdtic)
|
||||||
@@ -441,22 +426,11 @@ static UINT8* D_GetExistingTextcmd(tic_t tic, INT32 playernum)
|
|||||||
// Gets the buffer for the specified ticcmd, creating one if necessary
|
// Gets the buffer for the specified ticcmd, creating one if necessary
|
||||||
static UINT8* D_GetTextcmd(tic_t tic, INT32 playernum)
|
static UINT8* D_GetTextcmd(tic_t tic, INT32 playernum)
|
||||||
{
|
{
|
||||||
textcmdtic_t *textcmdtic = textcmds[tic & (TEXTCMD_HASH_SIZE - 1)];
|
textcmdtic_t *textcmdtic = textcmds[tic%BACKUPTICS];
|
||||||
textcmdtic_t **tctprev = &textcmds[tic & (TEXTCMD_HASH_SIZE - 1)];
|
|
||||||
|
|
||||||
// Look for the tic.
|
|
||||||
while (textcmdtic && textcmdtic->tic != tic)
|
|
||||||
{
|
|
||||||
tctprev = &textcmdtic->next;
|
|
||||||
textcmdtic = textcmdtic->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we don't have an entry for the tic, make it.
|
// If we don't have an entry for the tic, make it.
|
||||||
if (!textcmdtic)
|
if (!textcmdtic)
|
||||||
{
|
textcmds[tic%BACKUPTICS] = textcmdtic = (textcmdtic_t*)Z_Calloc(sizeof(textcmdtic_t), PU_STATIC, NULL);
|
||||||
textcmdtic = *tctprev = (textcmdtic_t*)Z_Calloc(sizeof (textcmdtic_t), PU_STATIC, NULL);
|
|
||||||
textcmdtic->tic = tic;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we don't have an entry for the player, make it.
|
// If we don't have an entry for the player, make it.
|
||||||
if (!textcmdtic->playercmds[playernum])
|
if (!textcmdtic->playercmds[playernum])
|
||||||
@@ -540,9 +514,8 @@ void D_ResetTiccmds(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reset the net command list
|
// Reset the net command list
|
||||||
for (i = 0; i < TEXTCMD_HASH_SIZE; i++)
|
for (i = 0; i < BACKUPTICS; i++)
|
||||||
while (textcmds[i])
|
D_Clearticcmd(i);
|
||||||
D_Clearticcmd(textcmds[i]->tic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendKick(UINT8 playernum, UINT8 msg)
|
void SendKick(UINT8 playernum, UINT8 msg)
|
||||||
@@ -1946,16 +1919,17 @@ static boolean SV_SendServerConfig(INT32 node)
|
|||||||
return waspacketsent;
|
return waspacketsent;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SAVEGAMESIZE (768*1024)
|
|
||||||
|
|
||||||
#ifdef SATURNPAK
|
#ifdef SATURNPAK
|
||||||
static boolean SV_ResendingSavegameToAnyone(void)
|
static boolean SV_ResendingSavegameToAnyone(void)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
||||||
for (i = 0; i < MAXNETNODES; i++)
|
for (i = 0; i < MAXNETNODES; i++)
|
||||||
|
{
|
||||||
if (nodeingame[i] && resendingsavegame[i])
|
if (nodeingame[i] && resendingsavegame[i])
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -2943,10 +2917,12 @@ static void CL_ConnectToServer(void)
|
|||||||
{
|
{
|
||||||
pnumnodes = 0;
|
pnumnodes = 0;
|
||||||
for (i = 0; i < MAXNETNODES; i++)
|
for (i = 0; i < MAXNETNODES; i++)
|
||||||
|
{
|
||||||
if (nodeingame[i])
|
if (nodeingame[i])
|
||||||
pnumnodes++;
|
pnumnodes++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
while (!(cl_mode == CL_CONNECTED && (client || (server && nodewaited <= pnumnodes))));
|
while (!(cl_mode == CL_CONNECTED && (client || (server && nodewaited <= pnumnodes))));
|
||||||
|
|
||||||
if (netgame)
|
if (netgame)
|
||||||
@@ -4152,7 +4128,7 @@ static void Command_ResendGamestate(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
playernum = nametonum(COM_Argv(1));
|
playernum = nametonum(COM_Argv(1));
|
||||||
if (playernum == -1 || playernum == 0)
|
if (playernum <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
||||||
@@ -4428,8 +4404,10 @@ void D_QuitNetGame(void)
|
|||||||
|
|
||||||
netbuffer->packettype = PT_SERVERSHUTDOWN;
|
netbuffer->packettype = PT_SERVERSHUTDOWN;
|
||||||
for (i = 0; i < MAXNETNODES; i++)
|
for (i = 0; i < MAXNETNODES; i++)
|
||||||
|
{
|
||||||
if (nodeingame[i])
|
if (nodeingame[i])
|
||||||
HSendPacket(i, true, 0, 0);
|
HSendPacket(i, true, 0, 0);
|
||||||
|
}
|
||||||
#ifdef MASTERSERVER
|
#ifdef MASTERSERVER
|
||||||
if (serverrunning && netgame && cv_advertise.value) // see mserv.c Online()
|
if (serverrunning && netgame && cv_advertise.value) // see mserv.c Online()
|
||||||
UnregisterServer();
|
UnregisterServer();
|
||||||
@@ -4473,18 +4451,21 @@ static inline void SV_AddNode(INT32 node)
|
|||||||
// Xcmd XD_ADDPLAYER
|
// Xcmd XD_ADDPLAYER
|
||||||
static void Got_AddPlayer(const UINT8 **p, INT32 playernum)
|
static void Got_AddPlayer(const UINT8 **p, INT32 playernum)
|
||||||
{
|
{
|
||||||
|
UINT8 i;
|
||||||
INT16 node, newplayernum;
|
INT16 node, newplayernum;
|
||||||
UINT8 splitscreenplayer = 0;
|
UINT8 splitscreenplayer = 0;
|
||||||
UINT8 i;
|
player_t *newplayer;
|
||||||
|
|
||||||
if (playernum != serverplayer && !IsPlayerAdmin(playernum))
|
if (playernum != serverplayer && !IsPlayerAdmin(playernum))
|
||||||
{
|
{
|
||||||
// protect against hacked/buggy client
|
// protect against hacked/buggy client
|
||||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal add player command received from %s\n"), player_names[playernum]);
|
CONS_Alert(CONS_WARNING, M_GetText("Illegal add player command received from %s\n"), player_names[playernum]);
|
||||||
|
|
||||||
if (server)
|
if (server)
|
||||||
{
|
{
|
||||||
SendKick(playernum, KICK_MSG_CON_FAIL);
|
SendKick(playernum, KICK_MSG_CON_FAIL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4493,14 +4474,19 @@ static void Got_AddPlayer(const UINT8 **p, INT32 playernum)
|
|||||||
splitscreenplayer = newplayernum/MAXPLAYERS;
|
splitscreenplayer = newplayernum/MAXPLAYERS;
|
||||||
newplayernum %= MAXPLAYERS;
|
newplayernum %= MAXPLAYERS;
|
||||||
|
|
||||||
|
CONS_Debug(DBG_NETPLAY, "addplayer: %d %d\n", node, newplayernum);
|
||||||
|
|
||||||
// Clear player before joining, lest some things get set incorrectly
|
// Clear player before joining, lest some things get set incorrectly
|
||||||
CL_ClearPlayer(newplayernum);
|
CL_ClearPlayer(newplayernum);
|
||||||
|
|
||||||
playeringame[newplayernum] = true;
|
playeringame[newplayernum] = true;
|
||||||
G_AddPlayer(newplayernum);
|
G_AddPlayer(newplayernum);
|
||||||
|
|
||||||
if (newplayernum+1 > doomcom->numslots)
|
if (newplayernum+1 > doomcom->numslots)
|
||||||
doomcom->numslots = (INT16)(newplayernum+1);
|
doomcom->numslots = (INT16)(newplayernum+1);
|
||||||
|
|
||||||
|
newplayer = &players[newplayernum];
|
||||||
|
|
||||||
// the server is creating my player
|
// the server is creating my player
|
||||||
if (node == mynode)
|
if (node == mynode)
|
||||||
{
|
{
|
||||||
@@ -4511,7 +4497,7 @@ static void Got_AddPlayer(const UINT8 **p, INT32 playernum)
|
|||||||
displayplayers[splitscreenplayer] = newplayernum;
|
displayplayers[splitscreenplayer] = newplayernum;
|
||||||
DEBFILE(va("spawning one of my sister number %d\n", splitscreenplayer));
|
DEBFILE(va("spawning one of my sister number %d\n", splitscreenplayer));
|
||||||
if (splitscreenplayer == 1 && botingame)
|
if (splitscreenplayer == 1 && botingame)
|
||||||
players[newplayernum].bot = 1;
|
newplayer->bot = 1; // do we really want this löl
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -4521,13 +4507,13 @@ static void Got_AddPlayer(const UINT8 **p, INT32 playernum)
|
|||||||
DEBFILE("spawning me\n");
|
DEBFILE("spawning me\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
P_ForceLocalAngle(&players[newplayernum], (angle_t)(players[newplayernum].cmd.angleturn << TICCMD_REDUCE));
|
P_ForceLocalAngle(newplayer, (angle_t)(newplayer->cmd.angleturn << TICCMD_REDUCE));
|
||||||
|
|
||||||
D_SendPlayerConfig();
|
D_SendPlayerConfig(splitscreenplayer);
|
||||||
addedtogame = true;
|
addedtogame = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
players[newplayernum].splitscreenindex = splitscreenplayer;
|
newplayer->splitscreenindex = splitscreenplayer;
|
||||||
|
|
||||||
if (netgame)
|
if (netgame)
|
||||||
{
|
{
|
||||||
@@ -4591,32 +4577,34 @@ static void Got_RemovePlayer(const UINT8 **p, INT32 playernum)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean SV_AddWaitingPlayers(void)
|
static boolean SV_AddWaitingPlayers(SINT8 node)
|
||||||
{
|
{
|
||||||
INT32 node, n, newplayer = false;
|
INT32 n;
|
||||||
UINT8 buf[2];
|
UINT8 buf[2];
|
||||||
UINT8 newplayernum = 0;
|
UINT8 newplayernum = 0;
|
||||||
|
boolean newplayer = false;
|
||||||
|
|
||||||
// What is the reason for this? Why can't newplayernum always be 0?
|
|
||||||
// Sal: Because the dedicated player is stupidly forced into players[0].....
|
|
||||||
if (dedicated)
|
|
||||||
newplayernum = 1;
|
|
||||||
|
|
||||||
for (node = 0; node < MAXNETNODES; node++)
|
|
||||||
{
|
|
||||||
// splitscreen can allow 2+ players in one node
|
// splitscreen can allow 2+ players in one node
|
||||||
for (; nodewaiting[node] > 0; nodewaiting[node]--)
|
for (; nodewaiting[node] > 0; nodewaiting[node]--)
|
||||||
{
|
{
|
||||||
newplayer = true;
|
newplayer = true;
|
||||||
|
|
||||||
// search for a free playernum
|
// search for a free playernum
|
||||||
// we can't use playeringame since it is not updated here
|
// we can't solely use playeringame since it is not updated here
|
||||||
for (; newplayernum < MAXPLAYERS; newplayernum++)
|
for (newplayernum = dedicated ? 1 : 0; newplayernum < MAXPLAYERS; newplayernum++)
|
||||||
{
|
{
|
||||||
|
if (playeringame[newplayernum])
|
||||||
|
continue;
|
||||||
|
|
||||||
for (n = 0; n < MAXNETNODES; n++)
|
for (n = 0; n < MAXNETNODES; n++)
|
||||||
if (nodetoplayer[n] == newplayernum || nodetoplayer2[n] == newplayernum
|
{
|
||||||
|| nodetoplayer3[n] == newplayernum || nodetoplayer4[n] == newplayernum)
|
if (nodetoplayer[n] == newplayernum ||
|
||||||
|
nodetoplayer2[n] == newplayernum ||
|
||||||
|
nodetoplayer3[n] == newplayernum ||
|
||||||
|
nodetoplayer4[n] == newplayernum)
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (n == MAXNETNODES)
|
if (n == MAXNETNODES)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -4625,10 +4613,9 @@ static boolean SV_AddWaitingPlayers(void)
|
|||||||
// before accepting the join
|
// before accepting the join
|
||||||
I_Assert(newplayernum < MAXPLAYERS);
|
I_Assert(newplayernum < MAXPLAYERS);
|
||||||
|
|
||||||
playernode[newplayernum] = (UINT8)node;
|
|
||||||
|
|
||||||
buf[0] = (UINT8)node;
|
buf[0] = (UINT8)node;
|
||||||
buf[1] = newplayernum;
|
buf[1] = newplayernum;
|
||||||
|
|
||||||
if (playerpernode[node] < 1)
|
if (playerpernode[node] < 1)
|
||||||
{
|
{
|
||||||
nodetoplayer[node] = newplayernum;
|
nodetoplayer[node] = newplayernum;
|
||||||
@@ -4643,11 +4630,21 @@ static boolean SV_AddWaitingPlayers(void)
|
|||||||
nodetoplayer3[node] = newplayernum;
|
nodetoplayer3[node] = newplayernum;
|
||||||
buf[1] += MAXPLAYERS*2;
|
buf[1] += MAXPLAYERS*2;
|
||||||
}
|
}
|
||||||
else
|
else if (playerpernode[node] < 4)
|
||||||
{
|
{
|
||||||
nodetoplayer4[node] = newplayernum;
|
nodetoplayer4[node] = newplayernum;
|
||||||
buf[1] += MAXPLAYERS*3;
|
buf[1] += MAXPLAYERS*3;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// I don't know if it's safe to assert here,
|
||||||
|
// but I do know this should not be allowed
|
||||||
|
// to be reached.
|
||||||
|
return newplayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
playernode[newplayernum] = (UINT8)node;
|
||||||
|
|
||||||
playerpernode[node]++;
|
playerpernode[node]++;
|
||||||
|
|
||||||
SendNetXCmd(XD_ADDPLAYER, &buf, 2);
|
SendNetXCmd(XD_ADDPLAYER, &buf, 2);
|
||||||
@@ -4656,7 +4653,6 @@ static boolean SV_AddWaitingPlayers(void)
|
|||||||
// use the next free slot (we can't put playeringame[newplayernum] = true here)
|
// use the next free slot (we can't put playeringame[newplayernum] = true here)
|
||||||
newplayernum++;
|
newplayernum++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return newplayer;
|
return newplayer;
|
||||||
}
|
}
|
||||||
@@ -4692,6 +4688,8 @@ boolean Playing(void)
|
|||||||
|
|
||||||
boolean SV_SpawnServer(void)
|
boolean SV_SpawnServer(void)
|
||||||
{
|
{
|
||||||
|
boolean result = false;
|
||||||
|
|
||||||
if (demo.playback)
|
if (demo.playback)
|
||||||
G_StopDemo(); // reset engine parameter
|
G_StopDemo(); // reset engine parameter
|
||||||
|
|
||||||
@@ -4712,7 +4710,15 @@ boolean SV_SpawnServer(void)
|
|||||||
else doomcom->numslots = 1;
|
else doomcom->numslots = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SV_AddWaitingPlayers();
|
// strictly speaking, i'm not convinced the following is necessary
|
||||||
|
// but I'm not confident enough to remove it entirely in case it breaks something
|
||||||
|
{
|
||||||
|
SINT8 node = 0;
|
||||||
|
for (; node < MAXNETNODES; node++)
|
||||||
|
result |= SV_AddWaitingPlayers(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SV_StopServer(void)
|
void SV_StopServer(void)
|
||||||
@@ -4766,17 +4772,6 @@ void SV_StartSinglePlayerServer(void)
|
|||||||
multiplayer = true;
|
multiplayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SV_SendRefuse(INT32 node, const char *reason)
|
|
||||||
{
|
|
||||||
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
|
||||||
|
|
||||||
strcpy(netbuffer->u.serverrefuse.reason, reason);
|
|
||||||
|
|
||||||
netbuffer->packettype = PT_SERVERREFUSE;
|
|
||||||
HSendPacket(node, false, 0, strlen(netbuffer->u.serverrefuse.reason) + 1);
|
|
||||||
Net_CloseConnection(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
// used at txtcmds received to check packetsize bound
|
// used at txtcmds received to check packetsize bound
|
||||||
static size_t TotalTextCmdPerTic(tic_t tic)
|
static size_t TotalTextCmdPerTic(tic_t tic)
|
||||||
{
|
{
|
||||||
@@ -4793,15 +4788,25 @@ static size_t TotalTextCmdPerTic(tic_t tic)
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called when a PT_CLIENTJOIN packet is received
|
static void SV_SendRefuse(INT32 node, const char *reason)
|
||||||
*
|
|
||||||
* \param node The packet sender
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static void HandleConnect(SINT8 node)
|
|
||||||
{
|
{
|
||||||
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
||||||
|
|
||||||
|
strcpy(netbuffer->u.serverrefuse.reason, reason);
|
||||||
|
|
||||||
|
netbuffer->packettype = PT_SERVERREFUSE;
|
||||||
|
HSendPacket(node, false, 0, strlen(netbuffer->u.serverrefuse.reason) + 1);
|
||||||
|
Net_CloseConnection(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *GetRefuseMessage(SINT8 node)
|
||||||
|
{
|
||||||
|
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
||||||
|
clientconfig_pak *cc = &netbuffer->u.clientcfg;
|
||||||
|
|
||||||
|
if (!node) /* server connecting to itself */
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// Sal: Dedicated mode is INCREDIBLY hacked together.
|
// Sal: Dedicated mode is INCREDIBLY hacked together.
|
||||||
// If a server filled out, then it'd overwrite the host and turn everyone into weird husks.....
|
// If a server filled out, then it'd overwrite the host and turn everyone into weird husks.....
|
||||||
// It's too much effort to legimately fix right now. Just prevent it from reaching that state.
|
// It's too much effort to legimately fix right now. Just prevent it from reaching that state.
|
||||||
@@ -4809,11 +4814,19 @@ static void HandleConnect(SINT8 node)
|
|||||||
UINT8 connectedplayers = 0;
|
UINT8 connectedplayers = 0;
|
||||||
|
|
||||||
for (UINT8 i = dedicated ? 1 : 0; i < MAXPLAYERS; i++)
|
for (UINT8 i = dedicated ? 1 : 0; i < MAXPLAYERS; i++)
|
||||||
if (playernode[i] != UINT8_MAX) // We use this to count players because it is affected by SV_AddWaitingPlayers when more than one client joins on the same tic, unlike playeringame and D_NumPlayers. UINT8_MAX denotes no node for that player
|
{
|
||||||
|
// We use this to count players because it is affected by SV_AddWaitingPlayers when
|
||||||
|
// more than one client joins on the same tic, unlike playeringame and D_NumPlayers.
|
||||||
|
// UINT8_MAX denotes no node for that player.
|
||||||
|
|
||||||
|
if (playernode[i] != UINT8_MAX)
|
||||||
|
{
|
||||||
connectedplayers++;
|
connectedplayers++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SATURNJOIN
|
#ifdef SATURNJOIN
|
||||||
const boolean issaturn = (((doomcom->datalength) == sizeof(clientconfig_pak)) && netbuffer->u.clientcfg.issaturn == ISSATURN); // Check the packet lenght to skip potential garbo data!
|
const boolean issaturn = (((doomcom->datalength) == sizeof(clientconfig_pak)) && (cc->issaturn == ISSATURN)); // Check the packet length to skip garbo data!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (bannednode && bannednode[node].banid != SIZE_MAX)
|
if (bannednode && bannednode[node].banid != SIZE_MAX)
|
||||||
@@ -4833,40 +4846,37 @@ static void HandleConnect(SINT8 node)
|
|||||||
|
|
||||||
if (days)
|
if (days)
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, va("K|%s\n(Time remaining: %d day%s)", reason, days, days > 1 ? "s" : ""));
|
return va("K|%s\n(Time remaining: %d day%s)", reason, days, days > 1 ? "s" : "");
|
||||||
}
|
}
|
||||||
else if (hours)
|
else if (hours)
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, va("K|%s\n(Time remaining: %d hour%s)", reason, hours, hours > 1 ? "s" : ""));
|
return va("K|%s\n(Time remaining: %d hour%s)", reason, hours, hours > 1 ? "s" : "");
|
||||||
}
|
}
|
||||||
else if (minutes)
|
else if (minutes)
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, va("K|%s\n(Time remaining: %d minute%s)", reason, minutes, minutes > 1 ? "s" : ""));
|
return va("K|%s\n(Time remaining: %d minute%s)", reason, minutes, minutes > 1 ? "s" : "");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, va("K|%s\n(Time remaining: <1 minute)", reason));
|
return va("K|%s\n(Time remaining: <1 minute)", reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, va("B|%s", reason));
|
return va("B|%s", reason);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (netbuffer->u.clientcfg._255 != 255 ||
|
else if (cc->_255 != 255 || cc->packetversion != PACKETVERSION)
|
||||||
netbuffer->u.clientcfg.packetversion != PACKETVERSION)
|
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, "Incompatible packet formats.");
|
return "Incompatible packet formats.";
|
||||||
}
|
}
|
||||||
else if (strncmp(netbuffer->u.clientcfg.application, SRB2APPLICATION,
|
else if (strncmp(cc->application, SRB2APPLICATION, sizeof(cc->application)))
|
||||||
sizeof netbuffer->u.clientcfg.application))
|
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, "Different SRB2Kart modifications\nare not compatible.");
|
return "Different SRB2Kart modifications\nare not compatible.";
|
||||||
}
|
}
|
||||||
else if (netbuffer->u.clientcfg.version != VERSION
|
else if (cc->version != VERSION || cc->subversion != SUBVERSION)
|
||||||
|| netbuffer->u.clientcfg.subversion != SUBVERSION)
|
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, va(M_GetText("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)"), VERSION, SUBVERSION));
|
return va("Different SRB2Kart versions cannot\nplay a netgame!\n(server version %d.%d)", VERSION, SUBVERSION);
|
||||||
}
|
}
|
||||||
#ifdef SATURNJOIN
|
#ifdef SATURNJOIN
|
||||||
else if (((!cv_allownewplayer.value && !issaturn) || (!cv_allownewsaturnplayer.value && issaturn)) && node)
|
else if (((!cv_allownewplayer.value && !issaturn) || (!cv_allownewsaturnplayer.value && issaturn)) && node)
|
||||||
@@ -4874,37 +4884,54 @@ static void HandleConnect(SINT8 node)
|
|||||||
else if (!cv_allownewplayer.value && node)
|
else if (!cv_allownewplayer.value && node)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, M_GetText(cv_joinrefusemessage.string));
|
return cv_joinrefusemessage.string;
|
||||||
}
|
}
|
||||||
else if (connectedplayers >= maxplayers)
|
else if (connectedplayers >= maxplayers)
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, va(M_GetText("Maximum players reached: %d"), maxplayers));
|
return va("Maximum players reached: %d", maxplayers);
|
||||||
}
|
}
|
||||||
else if (netgame && netbuffer->u.clientcfg.localplayers > 4) // Hacked client?
|
else if (netgame && !cc->localplayers) // Stealth join?
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, M_GetText("Too many players from\nthis node."));
|
return "No players from\nthis node.";
|
||||||
}
|
}
|
||||||
else if (netgame && connectedplayers + netbuffer->u.clientcfg.localplayers > maxplayers)
|
else if (netgame && cc->localplayers > 4) // Hacked client?
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, va(M_GetText("Number of local players\nwould exceed maximum: %d"), maxplayers));
|
return "Too many players from\nthis node.";
|
||||||
}
|
}
|
||||||
else if (netgame && !netbuffer->u.clientcfg.localplayers) // Stealth join?
|
else if (netgame && connectedplayers + cc->localplayers > maxplayers)
|
||||||
{
|
{
|
||||||
SV_SendRefuse(node, M_GetText("No players from\nthis node."));
|
return va("Number of local players\nwould exceed maximum: %d", maxplayers);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called when a PT_CLIENTJOIN packet is received
|
||||||
|
*
|
||||||
|
* \param node The packet sender
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void PT_ClientJoin(SINT8 node)
|
||||||
{
|
{
|
||||||
boolean newnode = false;
|
// Ignore duplicate packets
|
||||||
|
if (client || nodeingame[node] || levelloading)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const char *refuse = GetRefuseMessage(node);
|
||||||
|
|
||||||
|
if (refuse)
|
||||||
|
{
|
||||||
|
SV_SendRefuse(node, refuse);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
||||||
|
|
||||||
// client authorised to join
|
// client authorised to join
|
||||||
nodewaiting[node] = (UINT8)(netbuffer->u.clientcfg.localplayers - playerpernode[node]);
|
nodewaiting[node] = (UINT8)(netbuffer->u.clientcfg.localplayers - playerpernode[node]);
|
||||||
|
|
||||||
if (!nodeingame[node])
|
|
||||||
{
|
|
||||||
gamestate_t backupstate = gamestate;
|
gamestate_t backupstate = gamestate;
|
||||||
|
|
||||||
newnode = true;
|
|
||||||
|
|
||||||
SV_AddNode(node);
|
SV_AddNode(node);
|
||||||
|
|
||||||
/// \note Wait what???
|
/// \note Wait what???
|
||||||
@@ -4917,29 +4944,25 @@ static void HandleConnect(SINT8 node)
|
|||||||
{
|
{
|
||||||
G_SetGamestate(backupstate);
|
G_SetGamestate(backupstate);
|
||||||
/// \note Shouldn't SV_SendRefuse be called before ResetNode?
|
/// \note Shouldn't SV_SendRefuse be called before ResetNode?
|
||||||
SV_SendRefuse(node, M_GetText("Server couldn't send info, please try again"));
|
SV_SendRefuse(node, "Server couldn't send info, please try again");
|
||||||
ResetNode(node); // Yeah, lets try it!
|
ResetNode(node); // Yeah, lets try it!
|
||||||
/// \todo fix this !!!
|
/// \todo fix this !!!
|
||||||
return; // restart the while
|
return; // restart the while
|
||||||
}
|
}
|
||||||
|
|
||||||
SV_SendServerInfo(node, 0); // Dunno if 0 time is good idea
|
SV_SendServerInfo(node, 0); // Dunno if 0 time is good idea
|
||||||
//if (gamestate != GS_LEVEL) // GS_INTERMISSION, etc?
|
|
||||||
// SV_SendPlayerConfigs(node); // send bare minimum player info
|
|
||||||
G_SetGamestate(backupstate);
|
G_SetGamestate(backupstate);
|
||||||
DEBFILE("new node joined\n");
|
DEBFILE("new node joined\n");
|
||||||
}
|
|
||||||
|
|
||||||
if (nodewaiting[node])
|
if (nodewaiting[node])
|
||||||
{
|
{
|
||||||
if (node && newnode)
|
if (node)
|
||||||
{
|
{
|
||||||
SV_SendSaveGame(node, false); // send a complete game state
|
SV_SendSaveGame(node, false); // send a complete game state
|
||||||
DEBFILE("send savegame\n");
|
DEBFILE("send savegame\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
SV_AddWaitingPlayers();
|
SV_AddWaitingPlayers(node);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4948,8 +4971,11 @@ static void HandleConnect(SINT8 node)
|
|||||||
* \param node The packet sender (should be the server)
|
* \param node The packet sender (should be the server)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void HandleShutdown(SINT8 node)
|
static void PT_ServerShutdown(SINT8 node)
|
||||||
{
|
{
|
||||||
|
if (node != servernode || server || cl_mode == CL_SEARCHING)
|
||||||
|
return;
|
||||||
|
|
||||||
(void)node;
|
(void)node;
|
||||||
D_QuitNetGame();
|
D_QuitNetGame();
|
||||||
CL_Reset();
|
CL_Reset();
|
||||||
@@ -4977,7 +5003,7 @@ static void HandleTimeout(SINT8 node)
|
|||||||
* \note What happens if the packet comes from a client or something like that?
|
* \note What happens if the packet comes from a client or something like that?
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void HandleServerInfo(SINT8 node)
|
static void PT_ServerInfo(SINT8 node)
|
||||||
{
|
{
|
||||||
char servername[MAXSERVERNAME];
|
char servername[MAXSERVERNAME];
|
||||||
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
||||||
@@ -5000,7 +5026,7 @@ static void HandleServerInfo(SINT8 node)
|
|||||||
memcpy(connectedservername, netbuffer->u.serverinfo.servername, MAXSERVERNAME);
|
memcpy(connectedservername, netbuffer->u.serverinfo.servername, MAXSERVERNAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void HandlePlayerInfo(void)
|
static void PT_PlayerInfo(void)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
||||||
@@ -5398,6 +5424,9 @@ static void HandlePacketFromAwayNode(SINT8 node)
|
|||||||
case PT_ASKINFOVIAMS:
|
case PT_ASKINFOVIAMS:
|
||||||
Net_CloseConnection(node);
|
Net_CloseConnection(node);
|
||||||
break;
|
break;
|
||||||
|
case PT_SERVERINFO:
|
||||||
|
PT_ServerInfo(node);
|
||||||
|
break;
|
||||||
case PT_TELLFILESNEEDED:
|
case PT_TELLFILESNEEDED:
|
||||||
PT_TellFilesNeeded(node);
|
PT_TellFilesNeeded(node);
|
||||||
break;
|
break;
|
||||||
@@ -5428,7 +5457,7 @@ static void HandlePacketFromAwayNode(SINT8 node)
|
|||||||
case PT_CLIENTCMD:
|
case PT_CLIENTCMD:
|
||||||
break; // This is not an "unknown packet"
|
break; // This is not an "unknown packet"
|
||||||
case PT_PLAYERINFO:
|
case PT_PLAYERINFO:
|
||||||
HandlePlayerInfo();
|
PT_PlayerInfo();
|
||||||
break;
|
break;
|
||||||
case PT_MAPICON:
|
case PT_MAPICON:
|
||||||
PT_MapIcon();
|
PT_MapIcon();
|
||||||
@@ -5436,12 +5465,17 @@ static void HandlePacketFromAwayNode(SINT8 node)
|
|||||||
case PT_NEEDMAPICON:
|
case PT_NEEDMAPICON:
|
||||||
PT_NeedMapIcon(node);
|
PT_NeedMapIcon(node);
|
||||||
break;
|
break;
|
||||||
|
case PT_SERVERSHUTDOWN:
|
||||||
|
PT_ServerShutdown(node);
|
||||||
|
break;
|
||||||
|
case PT_CLIENTJOIN:
|
||||||
|
PT_ClientJoin(node);
|
||||||
|
break;
|
||||||
case PT_SERVERTICS:
|
case PT_SERVERTICS:
|
||||||
// Do not remove my own server (we have just get a out of order packet)
|
// Do not remove my own server (we have just get a out of order packet)
|
||||||
if (node == servernode)
|
if (node == servernode)
|
||||||
break;
|
break;
|
||||||
/* FALLTHRU */
|
/* FALLTHRU */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DEBFILE(va("unknown packet received (%d) from unknown host\n", netbuffer->packettype));
|
DEBFILE(va("unknown packet received (%d) from unknown host\n", netbuffer->packettype));
|
||||||
Net_CloseConnection(node);
|
Net_CloseConnection(node);
|
||||||
@@ -5685,6 +5719,10 @@ static void PT_BasicKeepAlive(INT32 netconsole, SINT8 node)
|
|||||||
|
|
||||||
static void PT_TextCmd(INT32 netconsole, SINT8 node)
|
static void PT_TextCmd(INT32 netconsole, SINT8 node)
|
||||||
{
|
{
|
||||||
|
size_t j;
|
||||||
|
tic_t tic;
|
||||||
|
UINT8 *textcmd;
|
||||||
|
|
||||||
if (client)
|
if (client)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -5706,12 +5744,10 @@ static void PT_TextCmd(INT32 netconsole, SINT8 node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (netconsole < 0 || netconsole >= MAXPLAYERS)
|
if (netconsole < 0 || netconsole >= MAXPLAYERS)
|
||||||
Net_UnAcknowledgePacket(node);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
size_t j;
|
Net_UnAcknowledgePacket(node);
|
||||||
tic_t tic = maketic;
|
return;
|
||||||
UINT8 *textcmd;
|
}
|
||||||
|
|
||||||
// ignore if the textcmd has a reported size of zero
|
// ignore if the textcmd has a reported size of zero
|
||||||
// this shouldn't be sent at all
|
// this shouldn't be sent at all
|
||||||
@@ -5738,6 +5774,8 @@ static void PT_TextCmd(INT32 netconsole, SINT8 node)
|
|||||||
// doomcom->numslots+1 "+1" since doomcom->numslots can change within this time and sent time
|
// doomcom->numslots+1 "+1" since doomcom->numslots can change within this time and sent time
|
||||||
j = (software_MAXPACKETLENGTH - (netbuffer->u.textcmd[0]+2+BASESERVERTICSSIZE + (doomcom->numslots+1)*sizeof(ticcmd_t)));
|
j = (software_MAXPACKETLENGTH - (netbuffer->u.textcmd[0]+2+BASESERVERTICSSIZE + (doomcom->numslots+1)*sizeof(ticcmd_t)));
|
||||||
|
|
||||||
|
tic = maketic;
|
||||||
|
|
||||||
// search a tic that have enougth space in the ticcmd
|
// search a tic that have enougth space in the ticcmd
|
||||||
while ((textcmd = D_GetExistingTextcmd(tic, netconsole)),
|
while ((textcmd = D_GetExistingTextcmd(tic, netconsole)),
|
||||||
(TotalTextCmdPerTic(tic) > j || netbuffer->u.textcmd[0] + (textcmd ? textcmd[0] : 0) > MAXTEXTCMD)
|
(TotalTextCmdPerTic(tic) > j || netbuffer->u.textcmd[0] + (textcmd ? textcmd[0] : 0) > MAXTEXTCMD)
|
||||||
@@ -5765,20 +5803,25 @@ static void PT_TextCmd(INT32 netconsole, SINT8 node)
|
|||||||
memcpy(&textcmd[textcmd[0]+1], netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]);
|
memcpy(&textcmd[textcmd[0]+1], netbuffer->u.textcmd+1, netbuffer->u.textcmd[0]);
|
||||||
textcmd[0] += (UINT8)netbuffer->u.textcmd[0];
|
textcmd[0] += (UINT8)netbuffer->u.textcmd[0];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void PT_ClientQuit(INT32 netconsole, SINT8 node)
|
static void PT_ClientQuit(INT32 netconsole, SINT8 node)
|
||||||
{
|
{
|
||||||
|
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
||||||
|
|
||||||
if (client)
|
if (client)
|
||||||
|
{
|
||||||
|
if (node == servernode && cl_mode != CL_SEARCHING && netbuffer->packettype == PT_NODETIMEOUT)
|
||||||
|
HandleTimeout(node);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// nodeingame will be put false in the execution of kick command
|
// nodeingame will be put false in the execution of kick command
|
||||||
// this allow to send some packets to the quitting client to have their ack back
|
// this allow to send some packets to the quitting client to have their ack back
|
||||||
nodewaiting[node] = 0;
|
nodewaiting[node] = 0;
|
||||||
if (netconsole != -1 && playeringame[netconsole])
|
if (netconsole != -1 && playeringame[netconsole])
|
||||||
{
|
{
|
||||||
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
|
const int quitreason = ((netbuffer->packettype == PT_NODETIMEOUT) ? KICK_MSG_TIMEOUT : KICK_MSG_PLAYER_QUIT);
|
||||||
SendKick(netconsole, (netbuffer->packettype == PT_NODETIMEOUT) ? KICK_MSG_TIMEOUT : KICK_MSG_PLAYER_QUIT);
|
SendKick(netconsole, quitreason);
|
||||||
}
|
}
|
||||||
Net_CloseConnection(node);
|
Net_CloseConnection(node);
|
||||||
nodeingame[node] = false;
|
nodeingame[node] = false;
|
||||||
@@ -5964,9 +6007,6 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||||||
switch (netbuffer->packettype)
|
switch (netbuffer->packettype)
|
||||||
{
|
{
|
||||||
// -------------------------------------------- SERVER RECEIVE ----------
|
// -------------------------------------------- SERVER RECEIVE ----------
|
||||||
case PT_RESYNCHGET:
|
|
||||||
SV_AcknowledgeResynchAck(node, netbuffer->u.resynchgot);
|
|
||||||
break;
|
|
||||||
case PT_CLIENTCMD:
|
case PT_CLIENTCMD:
|
||||||
case PT_CLIENT2CMD:
|
case PT_CLIENT2CMD:
|
||||||
case PT_CLIENT3CMD:
|
case PT_CLIENT3CMD:
|
||||||
@@ -5992,24 +6032,6 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||||||
case PT_CLIENTQUIT:
|
case PT_CLIENTQUIT:
|
||||||
PT_ClientQuit(netconsole, node);
|
PT_ClientQuit(netconsole, node);
|
||||||
break;
|
break;
|
||||||
// -------------------------------------------- CLIENT RECEIVE ----------
|
|
||||||
case PT_RESYNCHEND:
|
|
||||||
PT_Resynched(node);
|
|
||||||
break;
|
|
||||||
case PT_SERVERTICS:
|
|
||||||
PT_ServerTics(node);
|
|
||||||
break;
|
|
||||||
case PT_RESYNCHING:
|
|
||||||
PT_Resynching(node);
|
|
||||||
break;
|
|
||||||
case PT_PING:
|
|
||||||
PT_Ping(node);
|
|
||||||
break;
|
|
||||||
case PT_SERVERCFG:
|
|
||||||
break;
|
|
||||||
case PT_FILEFRAGMENT:
|
|
||||||
PT_FileFragmentFromPlayer(node);
|
|
||||||
break;
|
|
||||||
#ifdef SATURNPAK
|
#ifdef SATURNPAK
|
||||||
case PT_CANRECEIVEGAMESTATE:
|
case PT_CANRECEIVEGAMESTATE:
|
||||||
PT_CanReceiveGamestate(node);
|
PT_CanReceiveGamestate(node);
|
||||||
@@ -6017,6 +6039,25 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||||||
case PT_RECEIVEDGAMESTATE:
|
case PT_RECEIVEDGAMESTATE:
|
||||||
PT_ReceivedGamestate(node);
|
PT_ReceivedGamestate(node);
|
||||||
break;
|
break;
|
||||||
|
#endif
|
||||||
|
case PT_SERVERINFO:
|
||||||
|
PT_ServerInfo(node);
|
||||||
|
break;
|
||||||
|
case PT_RESYNCHGET:
|
||||||
|
SV_AcknowledgeResynchAck(node, netbuffer->u.resynchgot);
|
||||||
|
break;
|
||||||
|
// -------------------------------------------- CLIENT RECEIVE ----------
|
||||||
|
case PT_SERVERTICS:
|
||||||
|
PT_ServerTics(node);
|
||||||
|
break;
|
||||||
|
case PT_PING:
|
||||||
|
PT_Ping(node);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PT_FILEFRAGMENT:
|
||||||
|
PT_FileFragmentFromPlayer(node);
|
||||||
|
break;
|
||||||
|
#ifdef SATURNPAK
|
||||||
case PT_WILLRESENDGAMESTATE:
|
case PT_WILLRESENDGAMESTATE:
|
||||||
PT_WillResendGamestate();
|
PT_WillResendGamestate();
|
||||||
break;
|
break;
|
||||||
@@ -6025,6 +6066,20 @@ static void HandlePacketFromPlayer(SINT8 node)
|
|||||||
is_client_saturn[node] = true;
|
is_client_saturn[node] = true;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case PT_SERVERSHUTDOWN:
|
||||||
|
PT_ServerShutdown(node);
|
||||||
|
break;
|
||||||
|
case PT_SERVERCFG:
|
||||||
|
break;
|
||||||
|
case PT_CLIENTJOIN:
|
||||||
|
PT_ClientJoin(node);
|
||||||
|
break;
|
||||||
|
case PT_RESYNCHING:
|
||||||
|
PT_Resynching(node);
|
||||||
|
break;
|
||||||
|
case PT_RESYNCHEND:
|
||||||
|
PT_Resynched(node);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", netbuffer->packettype, node));
|
DEBFILE(va("UNKNOWN PACKET TYPE RECEIVED %d from host %d\n", netbuffer->packettype, node));
|
||||||
}
|
}
|
||||||
@@ -6045,36 +6100,6 @@ static void GetPackets(void)
|
|||||||
{
|
{
|
||||||
node = (SINT8)doomcom->remotenode;
|
node = (SINT8)doomcom->remotenode;
|
||||||
|
|
||||||
if (server && netbuffer->packettype == PT_CLIENTJOIN)
|
|
||||||
{
|
|
||||||
if (!levelloading) // Otherwise just ignore
|
|
||||||
{
|
|
||||||
HandleConnect(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (client && node == servernode && cl_mode != CL_SEARCHING)
|
|
||||||
{
|
|
||||||
if (netbuffer->packettype == PT_SERVERSHUTDOWN)
|
|
||||||
{
|
|
||||||
HandleShutdown(node);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (netbuffer->packettype == PT_NODETIMEOUT)
|
|
||||||
{
|
|
||||||
HandleTimeout(node);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (netbuffer->packettype == PT_SERVERINFO)
|
|
||||||
{
|
|
||||||
HandleServerInfo(node);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if (netbuffer->packettype == PT_PLAYERINFO)
|
/*if (netbuffer->packettype == PT_PLAYERINFO)
|
||||||
continue; // We do nothing with PLAYERINFO, that's for the MS browser. Not quite true anymore :p*/
|
continue; // We do nothing with PLAYERINFO, that's for the MS browser. Not quite true anymore :p*/
|
||||||
|
|
||||||
@@ -6393,21 +6418,7 @@ static void CL_SendClientCmd(void)
|
|||||||
{
|
{
|
||||||
if (localtextcmd[i][0])
|
if (localtextcmd[i][0])
|
||||||
{
|
{
|
||||||
switch (i)
|
netbuffer->packettype = PT_TEXTCMD + i;
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
netbuffer->packettype = PT_TEXTCMD4;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
netbuffer->packettype = PT_TEXTCMD3;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
netbuffer->packettype = PT_TEXTCMD2;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
netbuffer->packettype = PT_TEXTCMD;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(netbuffer->u.textcmd, localtextcmd[i], localtextcmd[i][0]+1);
|
memcpy(netbuffer->u.textcmd, localtextcmd[i], localtextcmd[i][0]+1);
|
||||||
|
|
||||||
@@ -6451,7 +6462,7 @@ static void SV_SendTics(void)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// assert supposedtics[n]>=nettics[n]
|
// assert supposedtics[n]>=nettics[n]
|
||||||
realfirsttic = max(supposedtics[n], firstticstosend);
|
realfirsttic = supposedtics[n];
|
||||||
lasttictosend = min(maketic, nettics[n] + CLIENTBACKUPTICS);
|
lasttictosend = min(maketic, nettics[n] + CLIENTBACKUPTICS);
|
||||||
|
|
||||||
if (realfirsttic >= lasttictosend)
|
if (realfirsttic >= lasttictosend)
|
||||||
@@ -6625,7 +6636,7 @@ void SV_SpawnPlayer(INT32 playernum, INT32 x, INT32 y, angle_t angle)
|
|||||||
// create missed tic
|
// create missed tic
|
||||||
static void SV_Maketic(void)
|
static void SV_Maketic(void)
|
||||||
{
|
{
|
||||||
G_MoveTiccmd(netcmds[maketic % BACKUPTICS], playercmds, MAXPLAYERS);
|
G_CopyTiccmd(netcmds[maketic % BACKUPTICS], playercmds, MAXPLAYERS);
|
||||||
maketic++;
|
maketic++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6842,8 +6853,10 @@ static inline void PingUpdate(void)
|
|||||||
|
|
||||||
//send out our ping packets
|
//send out our ping packets
|
||||||
for (i = 0; i < MAXNETNODES; i++)
|
for (i = 0; i < MAXNETNODES; i++)
|
||||||
|
{
|
||||||
if (nodeingame[i])
|
if (nodeingame[i])
|
||||||
HSendPacket(i, true, 0, sizeof(INT32) * (MAXPLAYERS+1));
|
HSendPacket(i, true, 0, sizeof(INT32) * (MAXPLAYERS+1));
|
||||||
|
}
|
||||||
|
|
||||||
pingmeasurecount = 0; //Reset count
|
pingmeasurecount = 0; //Reset count
|
||||||
}
|
}
|
||||||
@@ -6946,11 +6959,16 @@ static void RenewHolePunch(void)
|
|||||||
static void HandleNodeTimeouts(void)
|
static void HandleNodeTimeouts(void)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
|
||||||
if (server)
|
if (server)
|
||||||
|
{
|
||||||
for (i = 1; i < MAXNETNODES; i++)
|
for (i = 1; i < MAXNETNODES; i++)
|
||||||
|
{
|
||||||
if (nodeingame[i] && freezetimeout[i] < I_GetTime())
|
if (nodeingame[i] && freezetimeout[i] < I_GetTime())
|
||||||
Net_ConnectionTimeout(i);
|
Net_ConnectionTimeout(i);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Keep the network alive while not advancing tics!
|
// Keep the network alive while not advancing tics!
|
||||||
void NetKeepAlive(void)
|
void NetKeepAlive(void)
|
||||||
@@ -7159,11 +7177,13 @@ void NetUpdate(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAXNETNODES; ++i)
|
for (i = 0; i < MAXNETNODES; ++i)
|
||||||
|
{
|
||||||
if (resynch_inprogress[i])
|
if (resynch_inprogress[i])
|
||||||
{
|
{
|
||||||
SV_SendResynch(i);
|
SV_SendResynch(i);
|
||||||
counts = -666;
|
counts = -666;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do not make tics while resynching
|
// Do not make tics while resynching
|
||||||
if (counts != -666)
|
if (counts != -666)
|
||||||
@@ -7190,6 +7210,8 @@ void NetUpdate(void)
|
|||||||
Net_AckTicker();
|
Net_AckTicker();
|
||||||
HandleNodeTimeouts();
|
HandleNodeTimeouts();
|
||||||
|
|
||||||
|
nowtime /= NEWTICRATERATIO;
|
||||||
|
|
||||||
if (nowtime > resptime)
|
if (nowtime > resptime)
|
||||||
{
|
{
|
||||||
resptime = nowtime;
|
resptime = nowtime;
|
||||||
@@ -7215,9 +7237,15 @@ void NetUpdate(void)
|
|||||||
INT32 D_NumPlayers(void)
|
INT32 D_NumPlayers(void)
|
||||||
{
|
{
|
||||||
INT32 num = 0, ix;
|
INT32 num = 0, ix;
|
||||||
|
|
||||||
for (ix = 0; ix < MAXPLAYERS; ix++)
|
for (ix = 0; ix < MAXPLAYERS; ix++)
|
||||||
|
{
|
||||||
if (playeringame[ix])
|
if (playeringame[ix])
|
||||||
|
{
|
||||||
num++;
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-3
@@ -654,15 +654,17 @@ void D_ResetTiccmds(void);
|
|||||||
|
|
||||||
tic_t GetLag(INT32 node);
|
tic_t GetLag(INT32 node);
|
||||||
|
|
||||||
extern UINT8 hu_resynching;
|
extern boolean hu_resynching;
|
||||||
#ifdef SATURNPAK
|
#ifdef SATURNPAK
|
||||||
extern UINT8 hu_redownloadinggamestate;
|
extern boolean hu_redownloadinggamestate;
|
||||||
#endif
|
#endif
|
||||||
extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player
|
extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player
|
||||||
|
|
||||||
|
#define SAVEGAMESIZE (768*1024)
|
||||||
|
|
||||||
typedef struct rewind_s
|
typedef struct rewind_s
|
||||||
{
|
{
|
||||||
UINT8 savebuffer[(768*1024)];
|
UINT8 savebuffer[SAVEGAMESIZE];
|
||||||
tic_t leveltime;
|
tic_t leveltime;
|
||||||
size_t demopos;
|
size_t demopos;
|
||||||
|
|
||||||
|
|||||||
+39
-19
@@ -130,8 +130,8 @@ static size_t startuppwadcount = 0;
|
|||||||
// autoloading
|
// autoloading
|
||||||
static char *autoloadwadfiles[MAX_WADFILES];
|
static char *autoloadwadfiles[MAX_WADFILES];
|
||||||
static char *autoloadwadfilespost[MAX_WADFILES];
|
static char *autoloadwadfilespost[MAX_WADFILES];
|
||||||
static size_t autoloadcount = 0;
|
static size_t autoloadwadcount = 0;
|
||||||
static size_t postloadcount = 0;
|
static size_t postloadwadcount = 0;
|
||||||
//
|
//
|
||||||
|
|
||||||
boolean devparm = false; // started game with -devparm
|
boolean devparm = false; // started game with -devparm
|
||||||
@@ -1037,25 +1037,38 @@ static INT32 D_DetectFileType(const char* filename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// autoload that shit
|
// autoload that shit
|
||||||
static void D_AutoloadFile(const char *file, char **filearray, size_t index)
|
static void D_AutoloadFile(const char *file, char **filearray, size_t *index)
|
||||||
{
|
{
|
||||||
char *newfile;
|
char *newfile;
|
||||||
INT32 fileType = D_DetectFileType(file);
|
INT32 fileType = D_DetectFileType(file);
|
||||||
|
|
||||||
|
if (*index >= MAX_WADFILES)
|
||||||
|
{
|
||||||
|
CONS_Printf("D_AutoloadFile: Failed to add file %s! Too many autoloaded files\n", file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!fileType)
|
if (!fileType)
|
||||||
{
|
{
|
||||||
CONS_Printf("D_AutoloadFile: File %s is unknown or invalid\n", file);
|
CONS_Printf("D_AutoloadFile: File %s is unknown or invalid\n", file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fileType == 1)
|
||||||
|
{
|
||||||
|
CONS_Printf("D_AutoloadFile: File %s is a directory\n", file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (fileType <= 6)
|
if (fileType <= 6)
|
||||||
{
|
{
|
||||||
newfile = malloc(strlen(file) + 1);
|
newfile = malloc(strlen(file) + 1);
|
||||||
if (!newfile)
|
if (!newfile)
|
||||||
I_Error("No more free memory to AutoloadFile %s",file);
|
I_Error("D_AutoloadFile: No more free memory to autoload file %s", file);
|
||||||
|
|
||||||
strcpy(newfile, file);
|
strcpy(newfile, file);
|
||||||
filearray[index] = newfile;
|
filearray[*index] = newfile;
|
||||||
|
(*index)++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1098,7 +1111,7 @@ static void D_FindAddonsToAutoload(void)
|
|||||||
// If the file is found, run our shit
|
// If the file is found, run our shit
|
||||||
if (!autoloadconfigfile) // nope outta here
|
if (!autoloadconfigfile) // nope outta here
|
||||||
{
|
{
|
||||||
autoloadcount = postloadcount = 0; // so D_AddAutoloadFiles can skip everything since nothings there to autoload
|
autoloadwadcount = postloadwadcount = 0; // so D_AddAutoloadFiles can skip everything since nothings there to autoload
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1124,27 +1137,34 @@ static void D_FindAddonsToAutoload(void)
|
|||||||
if (newline)
|
if (newline)
|
||||||
*newline = '\0';
|
*newline = '\0';
|
||||||
|
|
||||||
|
// ok so theres still issues with players adding stuff to autoload by accident
|
||||||
|
// sometimes this stuff contains maps
|
||||||
|
// you can probably imagine how that goes in a netgame....
|
||||||
|
if (W_CheckAutoLoadContainsMap(wadsToAutoload))
|
||||||
|
{
|
||||||
|
CONS_Printf("Autoload: file %s contains map data! skipping...", wadsToAutoload);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!postload && W_CheckPostLoadList(wadsToAutoload))
|
if (!postload && W_CheckPostLoadList(wadsToAutoload))
|
||||||
{
|
{
|
||||||
CONS_Printf("forcing postload for file %s\n", wadsToAutoload);
|
CONS_Printf("Autoload: forcing postload for file %s\n", wadsToAutoload);
|
||||||
postload = true;
|
postload = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// LOAD IT
|
// LOAD IT
|
||||||
if (!postload)
|
if (!postload)
|
||||||
{
|
{
|
||||||
D_AutoloadFile(wadsToAutoload, autoloadwadfiles, autoloadcount);
|
D_AutoloadFile(wadsToAutoload, autoloadwadfiles, &autoloadwadcount);
|
||||||
autoloadcount++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
D_AutoloadFile(wadsToAutoload, autoloadwadfilespost, postloadcount);
|
D_AutoloadFile(wadsToAutoload, autoloadwadfilespost, &postloadwadcount);
|
||||||
postloadcount++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
autoloadwadfiles[autoloadcount] = NULL;
|
autoloadwadfiles[autoloadwadcount] = NULL;
|
||||||
autoloadwadfilespost[postloadcount] = NULL;
|
autoloadwadfilespost[postloadwadcount] = NULL;
|
||||||
|
|
||||||
// we dont want memory leaks around here do we?
|
// we dont want memory leaks around here do we?
|
||||||
fclose(autoloadconfigfile);
|
fclose(autoloadconfigfile);
|
||||||
@@ -1153,7 +1173,7 @@ static void D_FindAddonsToAutoload(void)
|
|||||||
static void D_AddAutoloadFiles(void)
|
static void D_AddAutoloadFiles(void)
|
||||||
{
|
{
|
||||||
// nothing to autoload
|
// nothing to autoload
|
||||||
if (autoloadcount == 0)
|
if (autoloadwadcount == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n");
|
CONS_Printf("D_AutoloadFile(): Loading autoloaded addons...\n");
|
||||||
@@ -1161,15 +1181,15 @@ static void D_AddAutoloadFiles(void)
|
|||||||
if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0)
|
if (W_AddAutoloadedLocalFiles(autoloadwadfiles) == 0)
|
||||||
CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
|
CONS_Printf("D_AutoloadFile(): Are you sure you put in valid files or what?\n");
|
||||||
|
|
||||||
D_CleanFile(autoloadwadfiles, autoloadcount);
|
D_CleanFile(autoloadwadfiles, autoloadwadcount);
|
||||||
|
|
||||||
autoloadcount = 0;
|
autoloadwadcount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void D_AddPostloadFiles(void)
|
void D_AddPostloadFiles(void)
|
||||||
{
|
{
|
||||||
// nothing to postload
|
// nothing to postload
|
||||||
if (postloadcount == 0 || !netgame)
|
if (postloadwadcount == 0 || !netgame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CONS_Printf("D_AddPostloadFiles(): Loading postloaded addons...\n");
|
CONS_Printf("D_AddPostloadFiles(): Loading postloaded addons...\n");
|
||||||
@@ -1177,9 +1197,9 @@ void D_AddPostloadFiles(void)
|
|||||||
if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0)
|
if (W_AddAutoloadedLocalFiles(autoloadwadfilespost) == 0)
|
||||||
CONS_Printf("D_AddPostloadFiles(): Are you sure you put in valid files or what?\n");
|
CONS_Printf("D_AddPostloadFiles(): Are you sure you put in valid files or what?\n");
|
||||||
|
|
||||||
D_CleanFile(autoloadwadfilespost, postloadcount);
|
D_CleanFile(autoloadwadfilespost, postloadwadcount);
|
||||||
|
|
||||||
postloadcount = 0;
|
postloadwadcount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==========================================================================
|
// ==========================================================================
|
||||||
|
|||||||
+1
-5
@@ -612,12 +612,8 @@ void Net_WaitAllAckReceived(UINT32 timeout)
|
|||||||
|
|
||||||
static void InitNode(node_t *node)
|
static void InitNode(node_t *node)
|
||||||
{
|
{
|
||||||
node->acktosend_head = node->acktosend_tail = 0;
|
memset(node, 0, sizeof(node_t));
|
||||||
memset(node->acktosend, 0, sizeof(node->acktosend));
|
|
||||||
node->firstacktosend = 0;
|
|
||||||
node->nextacknum = 1;
|
node->nextacknum = 1;
|
||||||
node->remotefirstack = 0;
|
|
||||||
node->flags = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InitAck(void)
|
static void InitAck(void)
|
||||||
|
|||||||
+133
-471
@@ -1208,11 +1208,11 @@ static boolean AllowedPlayerNameChar(char ch)
|
|||||||
|
|
||||||
static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum)
|
static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum)
|
||||||
{
|
{
|
||||||
INT32 ix;
|
size_t ix, len = strlen(name);
|
||||||
|
|
||||||
if (strlen(name) == 0 || strlen(name) > MAXPLAYERNAME)
|
if (len == 0 || len > MAXPLAYERNAME)
|
||||||
return false; // Empty or too long.
|
return false; // Empty or too long.
|
||||||
if (name[0] == ' ' || name[strlen(name)-1] == ' ')
|
if (name[0] == ' ' || name[len-1] == ' ')
|
||||||
return false; // Starts or ends with a space.
|
return false; // Starts or ends with a space.
|
||||||
if (isdigit(name[0]))
|
if (isdigit(name[0]))
|
||||||
return false; // Starts with a digit.
|
return false; // Starts with a digit.
|
||||||
@@ -1226,20 +1226,19 @@ static boolean EnsurePlayerNameIsGood(char *name, INT32 playernum)
|
|||||||
|
|
||||||
// Also, anything over 0x80 is disallowed too, since compilers love to
|
// Also, anything over 0x80 is disallowed too, since compilers love to
|
||||||
// differ on whether they're printable characters or not.
|
// differ on whether they're printable characters or not.
|
||||||
for (ix = 0; name[ix] != '\0'; ix++)
|
for (ix = 0; ix < len; ix++)
|
||||||
if (!AllowedPlayerNameChar(name[ix]))
|
if (!AllowedPlayerNameChar(name[ix]))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Check if a player is currently using the name, case-insensitively.
|
// Check if a player is currently using the name, case-insensitively.
|
||||||
for (ix = 0; ix < MAXPLAYERS; ix++)
|
for (ix = 0; ix < MAXPLAYERS; ix++)
|
||||||
{
|
{
|
||||||
if (ix != playernum && playeringame[ix]
|
if (ix != (size_t)playernum && playeringame[ix]
|
||||||
&& fasticmp(name, player_names[ix]))
|
&& fasticmp(name, player_names[ix]))
|
||||||
{
|
{
|
||||||
// We shouldn't kick people out just because
|
// We shouldn't kick people out just because
|
||||||
// they joined the game with the same name
|
// they joined the game with the same name
|
||||||
// as someone else -- modify the name instead.
|
// as someone else -- modify the name instead.
|
||||||
size_t len = strlen(name);
|
|
||||||
|
|
||||||
// Recursion!
|
// Recursion!
|
||||||
// Slowly strip characters off the end of the
|
// Slowly strip characters off the end of the
|
||||||
@@ -1458,7 +1457,9 @@ UINT8 CanChangeSkin(INT32 playernum)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (players[playernum].spectator || players[playernum].playerstate == PST_DEAD || players[playernum].playerstate == PST_REBORN)
|
if (players[playernum].spectator ||
|
||||||
|
players[playernum].playerstate == PST_DEAD ||
|
||||||
|
players[playernum].playerstate == PST_REBORN)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -1492,445 +1493,144 @@ static void ForceAllSkins(INT32 forcedskin)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static INT32 snacpending = 0, snac2pending = 0, snac3pending = 0, snac4pending = 0, chmappending = 0;
|
static INT32 chmappending;
|
||||||
|
static INT32 snacpending[MAXSPLITSCREENPLAYERS];
|
||||||
|
|
||||||
|
// wonky compat, idk if anything uses this....
|
||||||
|
#define playerisbot (splitplayer == 1 && botingame)
|
||||||
|
|
||||||
// name, color, or skin has changed
|
// name, color, or skin has changed
|
||||||
//
|
//
|
||||||
static void SendNameAndColor(void)
|
static void SendNameAndColor(UINT8 splitplayer)
|
||||||
{
|
{
|
||||||
char buf[MAXPLAYERNAME+2];
|
char buf[MAXPLAYERNAME+2];
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
p = buf;
|
p = buf;
|
||||||
|
|
||||||
|
// splitscreen
|
||||||
|
if (splitscreen < splitplayer && !playerisbot)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const INT32 pnum = P_GetLocalPlayerNumForNum(splitplayer);
|
||||||
|
|
||||||
|
player_t *player = &players[pnum];
|
||||||
|
|
||||||
|
// TODO: make those cvars arrays
|
||||||
|
consvar_t *playercolor, *playername, *playerskin;
|
||||||
|
consvar_t *colorvars[] = {&cv_playercolor, &cv_playercolor2, &cv_playercolor3, &cv_playercolor4};
|
||||||
|
consvar_t *namevars[] = {&cv_playername, &cv_playername2, &cv_playername3, &cv_playername4};
|
||||||
|
consvar_t *skinvars[] = {&cv_skin, &cv_skin2, &cv_skin3, &cv_skin4};
|
||||||
|
|
||||||
|
playercolor = colorvars[splitplayer];
|
||||||
|
playername = namevars[splitplayer];
|
||||||
|
playerskin = skinvars[splitplayer];
|
||||||
|
|
||||||
// normal player colors
|
// normal player colors
|
||||||
if (G_GametypeHasTeams())
|
if (G_GametypeHasTeams())
|
||||||
{
|
{
|
||||||
if (players[consoleplayer].ctfteam == 1 && cv_playercolor.value != skincolor_redteam)
|
if (player->ctfteam == 1 && playercolor->value != skincolor_redteam)
|
||||||
CV_StealthSetValue(&cv_playercolor, skincolor_redteam);
|
CV_StealthSetValue(playercolor, skincolor_redteam);
|
||||||
else if (players[consoleplayer].ctfteam == 2 && cv_playercolor.value != skincolor_blueteam)
|
else if (player->ctfteam == 2 && playercolor->value != skincolor_blueteam)
|
||||||
CV_StealthSetValue(&cv_playercolor, skincolor_blueteam);
|
CV_StealthSetValue(playercolor, skincolor_blueteam);
|
||||||
}
|
}
|
||||||
|
|
||||||
// never allow the color "none"
|
// never allow the color "none"
|
||||||
if (!cv_playercolor.value)
|
if (!playercolor->value)
|
||||||
{
|
{
|
||||||
if (players[consoleplayer].skincolor)
|
if (player->skincolor)
|
||||||
CV_StealthSetValue(&cv_playercolor, players[consoleplayer].skincolor);
|
CV_StealthSetValue(playercolor, player->skincolor);
|
||||||
else if (skins[players[consoleplayer].skin].prefcolor)
|
else if (skins[player->skin].prefcolor)
|
||||||
CV_StealthSetValue(&cv_playercolor, skins[players[consoleplayer].skin].prefcolor);
|
CV_StealthSetValue(playercolor, skins[player->skin].prefcolor);
|
||||||
else
|
else
|
||||||
CV_StealthSet(&cv_playercolor, cv_playercolor.defaultvalue);
|
CV_StealthSet(playercolor, playercolor->defaultvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fastcmp(cv_playername.string, player_names[consoleplayer])
|
|
||||||
&& cv_playercolor.value == players[consoleplayer].skincolor
|
|
||||||
&& fastcmp(cv_skin.string, skins[players[consoleplayer].skin].name))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// We'll handle it later if we're not playing.
|
// We'll handle it later if we're not playing.
|
||||||
if (!Playing())
|
if (!Playing())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (fastcmp(playername->string, player_names[pnum])
|
||||||
|
&& playercolor->value == player->skincolor
|
||||||
|
&& fastcmp(playerskin->string, skins[player->skin].name))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (playerisbot)
|
||||||
|
{
|
||||||
|
players[pnum].skincolor = botcolor;
|
||||||
|
if (players[pnum].mo)
|
||||||
|
players[pnum].mo->color = players[pnum].skincolor;
|
||||||
|
SetPlayerSkinByNum(pnum, botskin-1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// If you're not in a netgame, merely update the skin, color, and name.
|
// If you're not in a netgame, merely update the skin, color, and name.
|
||||||
if (!netgame)
|
if (!netgame)
|
||||||
{
|
{
|
||||||
INT32 foundskin;
|
INT32 foundskin;
|
||||||
|
|
||||||
CleanupPlayerName(consoleplayer, cv_playername.zstring);
|
CleanupPlayerName(pnum, playername->zstring);
|
||||||
strcpy(player_names[consoleplayer], cv_playername.zstring);
|
strcpy(player_names[pnum], playername->zstring);
|
||||||
|
|
||||||
players[consoleplayer].skincolor = cv_playercolor.value;
|
player->skincolor = playercolor->value;
|
||||||
|
|
||||||
if (players[consoleplayer].mo)
|
if (player->mo)
|
||||||
players[consoleplayer].mo->color = players[consoleplayer].skincolor;
|
player->mo->color = player->skincolor;
|
||||||
|
|
||||||
if ((foundskin = R_SkinAvailable(cv_skin.string)) != -1)
|
if ((foundskin = R_SkinAvailable(playerskin->string)) != -1)
|
||||||
{
|
{
|
||||||
cv_skin.value = foundskin;
|
playerskin->value = foundskin;
|
||||||
SetPlayerSkin(consoleplayer, cv_skin.string);
|
SetPlayerSkin(pnum, playerskin->string);
|
||||||
CV_StealthSet(&cv_skin, skins[cv_skin.value].name);
|
CV_StealthSet(playerskin, skins[playerskin->value].name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cv_skin.value = players[consoleplayer].skin;
|
playerskin->value = player->skin;
|
||||||
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name);
|
CV_StealthSet(playerskin, skins[player->skin].name);
|
||||||
// will always be same as current
|
// will always be same as current
|
||||||
SetPlayerSkin(consoleplayer, cv_skin.string);
|
SetPlayerSkin(pnum, playerskin->string);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
snacpending++;
|
snacpending[splitplayer]++;
|
||||||
|
|
||||||
// Don't change name if muted
|
// Don't change name if muted
|
||||||
if (player_name_changes[consoleplayer] >= MAXNAMECHANGES)
|
if (player_name_changes[pnum] >= MAXNAMECHANGES)
|
||||||
{
|
{
|
||||||
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
CV_StealthSet(playername, player_names[pnum]);
|
||||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
HU_AddChatText("\x85*You must wait to change your name again", false);
|
||||||
}
|
}
|
||||||
else if (cv_mute.value && !(server || IsPlayerAdmin(consoleplayer)))
|
else if (cv_mute.value && !(server || IsPlayerAdmin(pnum)))
|
||||||
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
CV_StealthSet(playername, player_names[pnum]);
|
||||||
else // Cleanup name if changing it
|
else // Cleanup name if changing it
|
||||||
CleanupPlayerName(consoleplayer, cv_playername.zstring);
|
CleanupPlayerName(pnum, playername->zstring);
|
||||||
|
|
||||||
// Don't change skin if the server doesn't want you to.
|
// Don't change skin if the server doesn't want you to.
|
||||||
if (!CanChangeSkin(consoleplayer))
|
if (!CanChangeSkin(pnum))
|
||||||
CV_StealthSet(&cv_skin, skins[players[consoleplayer].skin].name);
|
CV_StealthSet(playerskin, skins[player->skin].name);
|
||||||
|
|
||||||
// check if player has the skin loaded (cv_skin may have
|
// check if player has the skin loaded (cv_skin may have
|
||||||
// the name of a skin that was available in the previous game)
|
// the name of a skin that was available in the previous game)
|
||||||
cv_skin.value = R_SkinAvailable(cv_skin.string);
|
playerskin->value = R_SkinAvailable(playerskin->string);
|
||||||
if (cv_skin.value < 0)
|
if (playerskin->value < 0)
|
||||||
{
|
{
|
||||||
INT32 skinnum = players[consoleplayer].skin;
|
INT32 skinnum = player->skin;
|
||||||
CV_StealthSet(&cv_skin, skins[skinnum].name);
|
CV_StealthSet(playerskin, skins[skinnum].name);
|
||||||
cv_skin.value = skinnum;
|
playerskin->value = skinnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally write out the complete packet and send it off.
|
// Finally write out the complete packet and send it off.
|
||||||
WRITESTRINGN(p, cv_playername.zstring, MAXPLAYERNAME);
|
WRITESTRINGN(p, playername->zstring, MAXPLAYERNAME);
|
||||||
WRITEUINT8(p, (UINT8)cv_playercolor.value);
|
WRITEUINT8(p, (UINT8)playercolor->value);
|
||||||
WRITEUINT8(p, (UINT8)cv_skin.value);
|
WRITEUINT8(p, (UINT8)playerskin->value);
|
||||||
SendNetXCmdForPlayer(0, XD_NAMEANDCOLOR, buf, p - buf);
|
SendNetXCmdForPlayer(splitplayer, XD_NAMEANDCOLOR, buf, p - buf);
|
||||||
}
|
|
||||||
|
|
||||||
// splitscreen
|
|
||||||
static void SendNameAndColor2(void)
|
|
||||||
{
|
|
||||||
INT32 secondplaya = -1;
|
|
||||||
char buf[MAXPLAYERNAME+2];
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
if (splitscreen < 1 && !botingame)
|
|
||||||
return; // can happen if skin2/color2/name2 changed
|
|
||||||
|
|
||||||
if (displayplayers[1] != consoleplayer)
|
|
||||||
secondplaya = displayplayers[1];
|
|
||||||
else if (!netgame) // HACK
|
|
||||||
secondplaya = 1;
|
|
||||||
|
|
||||||
if (secondplaya == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
p = buf;
|
|
||||||
|
|
||||||
// normal player colors
|
|
||||||
if (G_GametypeHasTeams())
|
|
||||||
{
|
|
||||||
if (players[secondplaya].ctfteam == 1 && cv_playercolor2.value != skincolor_redteam)
|
|
||||||
CV_StealthSetValue(&cv_playercolor2, skincolor_redteam);
|
|
||||||
else if (players[secondplaya].ctfteam == 2 && cv_playercolor2.value != skincolor_blueteam)
|
|
||||||
CV_StealthSetValue(&cv_playercolor2, skincolor_blueteam);
|
|
||||||
}
|
|
||||||
|
|
||||||
// never allow the color "none"
|
|
||||||
if (!cv_playercolor2.value)
|
|
||||||
{
|
|
||||||
if (players[secondplaya].skincolor)
|
|
||||||
CV_StealthSetValue(&cv_playercolor2, players[secondplaya].skincolor);
|
|
||||||
else if (skins[players[secondplaya].skin].prefcolor)
|
|
||||||
CV_StealthSetValue(&cv_playercolor2, skins[players[secondplaya].skin].prefcolor);
|
|
||||||
else
|
|
||||||
CV_StealthSet(&cv_playercolor2, cv_playercolor2.defaultvalue);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We'll handle it later if we're not playing.
|
|
||||||
if (!Playing())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// If you're not in a netgame, merely update the skin, color, and name.
|
|
||||||
if (botingame)
|
|
||||||
{
|
|
||||||
players[secondplaya].skincolor = botcolor;
|
|
||||||
if (players[secondplaya].mo)
|
|
||||||
players[secondplaya].mo->color = players[secondplaya].skincolor;
|
|
||||||
SetPlayerSkinByNum(secondplaya, botskin-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (!netgame)
|
|
||||||
{
|
|
||||||
INT32 foundskin;
|
|
||||||
|
|
||||||
CleanupPlayerName(secondplaya, cv_playername2.zstring);
|
|
||||||
strcpy(player_names[secondplaya], cv_playername2.zstring);
|
|
||||||
|
|
||||||
// don't use displayplayers[1]: the second player must be 1
|
|
||||||
players[secondplaya].skincolor = cv_playercolor2.value;
|
|
||||||
if (players[secondplaya].mo)
|
|
||||||
players[secondplaya].mo->color = players[secondplaya].skincolor;
|
|
||||||
|
|
||||||
if ((foundskin = R_SkinAvailable(cv_skin2.string)) != -1)
|
|
||||||
{
|
|
||||||
cv_skin2.value = foundskin;
|
|
||||||
SetPlayerSkin(secondplaya, cv_skin2.string);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cv_skin2.value = players[secondplaya].skin;
|
|
||||||
CV_StealthSet(&cv_skin2, skins[players[secondplaya].skin].name);
|
|
||||||
// will always be same as current
|
|
||||||
SetPlayerSkin(secondplaya, cv_skin2.string);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
snac2pending++;
|
|
||||||
|
|
||||||
// Don't change name if muted
|
|
||||||
if (player_name_changes[displayplayers[1]] >= MAXNAMECHANGES)
|
|
||||||
{
|
|
||||||
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
|
||||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
|
||||||
}
|
|
||||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[1])))
|
|
||||||
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
|
||||||
else // Cleanup name if changing it
|
|
||||||
CleanupPlayerName(displayplayers[1], cv_playername2.zstring);
|
|
||||||
|
|
||||||
// Don't change skin if the server doesn't want you to.
|
|
||||||
if (!CanChangeSkin(displayplayers[1]))
|
|
||||||
CV_StealthSet(&cv_skin2, skins[players[displayplayers[1]].skin].name);
|
|
||||||
|
|
||||||
// check if player has the skin loaded (cv_skin2 may have
|
|
||||||
// the name of a skin that was available in the previous game)
|
|
||||||
cv_skin2.value = R_SkinAvailable(cv_skin2.string);
|
|
||||||
if (cv_skin2.value < 0)
|
|
||||||
{
|
|
||||||
INT32 skinnum = players[displayplayers[1]].skin;
|
|
||||||
CV_StealthSet(&cv_skin2, skins[skinnum].name);
|
|
||||||
cv_skin2.value = skinnum;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally write out the complete packet and send it off.
|
|
||||||
WRITESTRINGN(p, cv_playername2.zstring, MAXPLAYERNAME);
|
|
||||||
WRITEUINT8(p, (UINT8)cv_playercolor2.value);
|
|
||||||
WRITEUINT8(p, (UINT8)cv_skin2.value);
|
|
||||||
SendNetXCmdForPlayer(1, XD_NAMEANDCOLOR, buf, p - buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SendNameAndColor3(void)
|
|
||||||
{
|
|
||||||
INT32 thirdplaya = -1;
|
|
||||||
char buf[MAXPLAYERNAME+2];
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
if (splitscreen < 2)
|
|
||||||
return; // can happen if skin3/color3/name3 changed
|
|
||||||
|
|
||||||
if (displayplayers[2] != consoleplayer)
|
|
||||||
thirdplaya = displayplayers[2];
|
|
||||||
else if (!netgame) // HACK
|
|
||||||
thirdplaya = 2;
|
|
||||||
|
|
||||||
if (thirdplaya == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
p = buf;
|
|
||||||
|
|
||||||
// normal player colors
|
|
||||||
if (G_GametypeHasTeams())
|
|
||||||
{
|
|
||||||
if (players[thirdplaya].ctfteam == 1 && cv_playercolor3.value != skincolor_redteam)
|
|
||||||
CV_StealthSetValue(&cv_playercolor3, skincolor_redteam);
|
|
||||||
else if (players[thirdplaya].ctfteam == 2 && cv_playercolor3.value != skincolor_blueteam)
|
|
||||||
CV_StealthSetValue(&cv_playercolor3, skincolor_blueteam);
|
|
||||||
}
|
|
||||||
|
|
||||||
// never allow the color "none"
|
|
||||||
if (!cv_playercolor3.value)
|
|
||||||
{
|
|
||||||
if (players[thirdplaya].skincolor)
|
|
||||||
CV_StealthSetValue(&cv_playercolor3, players[thirdplaya].skincolor);
|
|
||||||
else if (skins[players[thirdplaya].skin].prefcolor)
|
|
||||||
CV_StealthSetValue(&cv_playercolor3, skins[players[thirdplaya].skin].prefcolor);
|
|
||||||
else
|
|
||||||
CV_StealthSet(&cv_playercolor3, cv_playercolor3.defaultvalue);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We'll handle it later if we're not playing.
|
|
||||||
if (!Playing())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// If you're not in a netgame, merely update the skin, color, and name.
|
|
||||||
if (!netgame)
|
|
||||||
{
|
|
||||||
INT32 foundskin;
|
|
||||||
|
|
||||||
CleanupPlayerName(thirdplaya, cv_playername3.zstring);
|
|
||||||
strcpy(player_names[thirdplaya], cv_playername3.zstring);
|
|
||||||
|
|
||||||
// don't use displayplayers[2]: the third player must be 2
|
|
||||||
players[thirdplaya].skincolor = cv_playercolor3.value;
|
|
||||||
if (players[thirdplaya].mo)
|
|
||||||
players[thirdplaya].mo->color = players[thirdplaya].skincolor;
|
|
||||||
|
|
||||||
if ((foundskin = R_SkinAvailable(cv_skin3.string)) != -1)
|
|
||||||
{
|
|
||||||
cv_skin3.value = foundskin;
|
|
||||||
SetPlayerSkin(thirdplaya, cv_skin3.string);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cv_skin3.value = players[thirdplaya].skin;
|
|
||||||
CV_StealthSet(&cv_skin3, skins[players[thirdplaya].skin].name);
|
|
||||||
// will always be same as current
|
|
||||||
SetPlayerSkin(thirdplaya, cv_skin3.string);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
snac3pending++;
|
|
||||||
|
|
||||||
// Don't change name if muted
|
|
||||||
if (player_name_changes[displayplayers[2]] >= MAXNAMECHANGES)
|
|
||||||
{
|
|
||||||
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
|
||||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
|
||||||
}
|
|
||||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[2])))
|
|
||||||
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
|
||||||
else // Cleanup name if changing it
|
|
||||||
CleanupPlayerName(displayplayers[2], cv_playername3.zstring);
|
|
||||||
|
|
||||||
// Don't change skin if the server doesn't want you to.
|
|
||||||
if (!CanChangeSkin(displayplayers[2]))
|
|
||||||
CV_StealthSet(&cv_skin3, skins[players[displayplayers[2]].skin].name);
|
|
||||||
|
|
||||||
// check if player has the skin loaded (cv_skin3 may have
|
|
||||||
// the name of a skin that was available in the previous game)
|
|
||||||
cv_skin3.value = R_SkinAvailable(cv_skin3.string);
|
|
||||||
if (cv_skin3.value < 0)
|
|
||||||
{
|
|
||||||
INT32 skinnum = players[displayplayers[2]].skin;
|
|
||||||
CV_StealthSet(&cv_skin3, skins[skinnum].name);
|
|
||||||
cv_skin3.value = skinnum;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally write out the complete packet and send it off.
|
|
||||||
WRITESTRINGN(p, cv_playername3.zstring, MAXPLAYERNAME);
|
|
||||||
WRITEUINT8(p, (UINT8)cv_playercolor3.value);
|
|
||||||
WRITEUINT8(p, (UINT8)cv_skin3.value);
|
|
||||||
SendNetXCmdForPlayer(2, XD_NAMEANDCOLOR, buf, p - buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SendNameAndColor4(void)
|
|
||||||
{
|
|
||||||
INT32 fourthplaya = -1;
|
|
||||||
char buf[MAXPLAYERNAME+2];
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
if (splitscreen < 3)
|
|
||||||
return; // can happen if skin4/color4/name4 changed
|
|
||||||
|
|
||||||
if (displayplayers[3] != consoleplayer)
|
|
||||||
fourthplaya = displayplayers[3];
|
|
||||||
else if (!netgame) // HACK
|
|
||||||
fourthplaya = 3;
|
|
||||||
|
|
||||||
if (fourthplaya == -1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
p = buf;
|
|
||||||
|
|
||||||
// normal player colors
|
|
||||||
if (G_GametypeHasTeams())
|
|
||||||
{
|
|
||||||
if (players[fourthplaya].ctfteam == 1 && cv_playercolor4.value != skincolor_redteam)
|
|
||||||
CV_StealthSetValue(&cv_playercolor4, skincolor_redteam);
|
|
||||||
else if (players[fourthplaya].ctfteam == 2 && cv_playercolor4.value != skincolor_blueteam)
|
|
||||||
CV_StealthSetValue(&cv_playercolor4, skincolor_blueteam);
|
|
||||||
}
|
|
||||||
|
|
||||||
// never allow the color "none"
|
|
||||||
if (!cv_playercolor4.value)
|
|
||||||
{
|
|
||||||
if (players[fourthplaya].skincolor)
|
|
||||||
CV_StealthSetValue(&cv_playercolor4, players[fourthplaya].skincolor);
|
|
||||||
else if (skins[players[fourthplaya].skin].prefcolor)
|
|
||||||
CV_StealthSetValue(&cv_playercolor4, skins[players[fourthplaya].skin].prefcolor);
|
|
||||||
else
|
|
||||||
CV_StealthSet(&cv_playercolor4, cv_playercolor4.defaultvalue);
|
|
||||||
}
|
|
||||||
|
|
||||||
// We'll handle it later if we're not playing.
|
|
||||||
if (!Playing())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// If you're not in a netgame, merely update the skin, color, and name.
|
|
||||||
if (botingame)
|
|
||||||
{
|
|
||||||
players[fourthplaya].skincolor = botcolor;
|
|
||||||
if (players[fourthplaya].mo)
|
|
||||||
players[fourthplaya].mo->color = players[fourthplaya].skincolor;
|
|
||||||
SetPlayerSkinByNum(fourthplaya, botskin-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (!netgame)
|
|
||||||
{
|
|
||||||
INT32 foundskin;
|
|
||||||
|
|
||||||
CleanupPlayerName(fourthplaya, cv_playername4.zstring);
|
|
||||||
strcpy(player_names[fourthplaya], cv_playername4.zstring);
|
|
||||||
|
|
||||||
// don't use displayplayers[3]: the second player must be 4
|
|
||||||
players[fourthplaya].skincolor = cv_playercolor4.value;
|
|
||||||
if (players[fourthplaya].mo)
|
|
||||||
players[fourthplaya].mo->color = players[fourthplaya].skincolor;
|
|
||||||
|
|
||||||
if ((foundskin = R_SkinAvailable(cv_skin4.string)) != -1)
|
|
||||||
{
|
|
||||||
cv_skin4.value = foundskin;
|
|
||||||
SetPlayerSkin(fourthplaya, cv_skin4.string);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cv_skin4.value = players[fourthplaya].skin;
|
|
||||||
CV_StealthSet(&cv_skin4, skins[players[fourthplaya].skin].name);
|
|
||||||
// will always be same as current
|
|
||||||
SetPlayerSkin(fourthplaya, cv_skin4.string);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
snac4pending++;
|
|
||||||
|
|
||||||
// Don't change name if muted
|
|
||||||
if (player_name_changes[displayplayers[3]] >= MAXNAMECHANGES)
|
|
||||||
{
|
|
||||||
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
|
||||||
HU_AddChatText("\x85*You must wait to change your name again", false);
|
|
||||||
}
|
|
||||||
else if (cv_mute.value && !(server || IsPlayerAdmin(displayplayers[3])))
|
|
||||||
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
|
||||||
else // Cleanup name if changing it
|
|
||||||
CleanupPlayerName(displayplayers[3], cv_playername4.zstring);
|
|
||||||
|
|
||||||
// Don't change skin if the server doesn't want you to.
|
|
||||||
if (!CanChangeSkin(displayplayers[3]))
|
|
||||||
CV_StealthSet(&cv_skin4, skins[players[displayplayers[3]].skin].name);
|
|
||||||
|
|
||||||
// check if player has the skin loaded (cv_skin4 may have
|
|
||||||
// the name of a skin that was available in the previous game)
|
|
||||||
cv_skin4.value = R_SkinAvailable(cv_skin4.string);
|
|
||||||
if (cv_skin4.value < 0)
|
|
||||||
{
|
|
||||||
INT32 skinnum = players[displayplayers[3]].skin;
|
|
||||||
CV_StealthSet(&cv_skin4, skins[skinnum].name);
|
|
||||||
cv_skin4.value = skinnum;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally write out the complete packet and send it off.
|
|
||||||
WRITESTRINGN(p, cv_playername4.zstring, MAXPLAYERNAME);
|
|
||||||
WRITEUINT8(p, (UINT8)cv_playercolor4.value);
|
|
||||||
WRITEUINT8(p, (UINT8)cv_skin4.value);
|
|
||||||
SendNetXCmdForPlayer(3, XD_NAMEANDCOLOR, buf, p - buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
||||||
{
|
{
|
||||||
player_t *p = &players[playernum];
|
player_t *player = &players[playernum];
|
||||||
char name[MAXPLAYERNAME+1];
|
char name[MAXPLAYERNAME+1];
|
||||||
UINT8 color, skin;
|
UINT8 color, skin;
|
||||||
|
|
||||||
@@ -1939,19 +1639,14 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
|||||||
I_Error("There is no player %d!", playernum);
|
I_Error("There is no player %d!", playernum);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (playernum == consoleplayer)
|
if (P_IsLocalPlayer(player))
|
||||||
snacpending--; // TODO: make snacpending an array instead of 4 separate vars?
|
{
|
||||||
else if (playernum == displayplayers[1])
|
snacpending[playernum]--;
|
||||||
snac2pending--;
|
|
||||||
else if (playernum == displayplayers[2])
|
|
||||||
snac3pending--;
|
|
||||||
else if (playernum == displayplayers[3])
|
|
||||||
snac4pending--;
|
|
||||||
|
|
||||||
#ifdef PARANOIA
|
#ifdef PARANOIA
|
||||||
if (snacpending < 0 || snac2pending < 0 || snac3pending < 0 || snac4pending < 0)
|
if (snacpending[playernum] < 0)
|
||||||
I_Error("snacpending negative!");
|
I_Error("snacpending negative!");
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
READSTRINGN(*cp, name, MAXPLAYERNAME);
|
READSTRINGN(*cp, name, MAXPLAYERNAME);
|
||||||
color = READUINT8(*cp);
|
color = READUINT8(*cp);
|
||||||
@@ -1965,33 +1660,32 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set color
|
// set color
|
||||||
p->skincolor = color % MAXSKINCOLORS;
|
player->skincolor = color % MAXSKINCOLORS;
|
||||||
if (p->mo)
|
if (player->mo)
|
||||||
p->mo->color = (UINT8)p->skincolor;
|
player->mo->color = (UINT8)player->skincolor;
|
||||||
demo_extradata[playernum] |= DXD_COLOR;
|
demo_extradata[playernum] |= DXD_COLOR;
|
||||||
|
|
||||||
// normal player colors
|
// normal player colors
|
||||||
if (server && (p != &players[consoleplayer] && p != &players[displayplayers[1]]
|
if (server && !P_IsLocalPlayer(player))
|
||||||
&& p != &players[displayplayers[2]] && p != &players[displayplayers[3]]))
|
|
||||||
{
|
{
|
||||||
boolean kick = false;
|
boolean kick = false;
|
||||||
|
|
||||||
// team colors
|
// team colors
|
||||||
if (G_GametypeHasTeams())
|
if (G_GametypeHasTeams())
|
||||||
{
|
{
|
||||||
if (p->ctfteam == 1 && p->skincolor != skincolor_redteam)
|
if (player->ctfteam == 1 && player->skincolor != skincolor_redteam)
|
||||||
kick = true;
|
kick = true;
|
||||||
else if (p->ctfteam == 2 && p->skincolor != skincolor_blueteam)
|
else if (player->ctfteam == 2 && player->skincolor != skincolor_blueteam)
|
||||||
kick = true;
|
kick = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't allow color "none"
|
// don't allow color "none"
|
||||||
if (!p->skincolor)
|
if (!player->skincolor)
|
||||||
kick = true;
|
kick = true;
|
||||||
|
|
||||||
if (kick)
|
if (kick)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_WARNING, M_GetText("Illegal color change received from %s (team: %d), color: %d)\n"), player_names[playernum], p->ctfteam, p->skincolor);
|
CONS_Alert(CONS_WARNING, M_GetText("Illegal color change received from %s (team: %d), color: %d)\n"), player_names[playernum], player->ctfteam, player->skincolor);
|
||||||
SendKick(playernum, KICK_MSG_CON_FAIL);
|
SendKick(playernum, KICK_MSG_CON_FAIL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2003,6 +1697,7 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
|||||||
const INT32 forcedskin = cv_forceskin.value;
|
const INT32 forcedskin = cv_forceskin.value;
|
||||||
SetPlayerSkinByNum(playernum, forcedskin);
|
SetPlayerSkinByNum(playernum, forcedskin);
|
||||||
|
|
||||||
|
// TODO: make cv_skin an array
|
||||||
if (playernum == consoleplayer)
|
if (playernum == consoleplayer)
|
||||||
CV_StealthSet(&cv_skin, skins[forcedskin].name);
|
CV_StealthSet(&cv_skin, skins[forcedskin].name);
|
||||||
else if (playernum == displayplayers[1])
|
else if (playernum == displayplayers[1])
|
||||||
@@ -2016,44 +1711,16 @@ static void Got_NameAndColor(const UINT8 **cp, INT32 playernum)
|
|||||||
SetPlayerSkinByNum(playernum, skin);
|
SetPlayerSkinByNum(playernum, skin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendWeaponPref(void)
|
void SendWeaponPref(UINT8 splitplayer)
|
||||||
{
|
{
|
||||||
UINT8 buf[1];
|
UINT8 buf[1];
|
||||||
|
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
if (cv_flipcam[0].value)
|
|
||||||
|
if (cv_flipcam[splitplayer].value)
|
||||||
buf[0] |= 1;
|
buf[0] |= 1;
|
||||||
SendNetXCmdForPlayer(0, XD_WEAPONPREF, buf, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendWeaponPref2(void)
|
SendNetXCmdForPlayer(splitplayer, XD_WEAPONPREF, buf, 1);
|
||||||
{
|
|
||||||
UINT8 buf[1];
|
|
||||||
|
|
||||||
buf[0] = 0;
|
|
||||||
if (cv_flipcam[1].value)
|
|
||||||
buf[0] |= 1;
|
|
||||||
SendNetXCmdForPlayer(1, XD_WEAPONPREF, buf, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendWeaponPref3(void)
|
|
||||||
{
|
|
||||||
UINT8 buf[1];
|
|
||||||
|
|
||||||
buf[0] = 0;
|
|
||||||
if (cv_flipcam[2].value)
|
|
||||||
buf[0] |= 1;
|
|
||||||
SendNetXCmdForPlayer(2, XD_WEAPONPREF, buf, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SendWeaponPref4(void)
|
|
||||||
{
|
|
||||||
UINT8 buf[1];
|
|
||||||
|
|
||||||
buf[0] = 0;
|
|
||||||
if (cv_flipcam[3].value)
|
|
||||||
buf[0] |= 1;
|
|
||||||
SendNetXCmdForPlayer(3, XD_WEAPONPREF, buf, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Got_WeaponPref(const UINT8 **cp, INT32 playernum)
|
static void Got_WeaponPref(const UINT8 **cp, INT32 playernum)
|
||||||
@@ -2069,23 +1736,10 @@ static void Got_WeaponPref(const UINT8 **cp, INT32 playernum)
|
|||||||
player->pflags |= PF_ANALOGMODE;
|
player->pflags |= PF_ANALOGMODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void D_SendPlayerConfig(void)
|
void D_SendPlayerConfig(UINT8 splitplayer)
|
||||||
{
|
{
|
||||||
SendNameAndColor();
|
SendNameAndColor(splitplayer);
|
||||||
if (splitscreen || botingame)
|
SendWeaponPref(splitplayer);
|
||||||
SendNameAndColor2();
|
|
||||||
if (splitscreen > 1)
|
|
||||||
SendNameAndColor3();
|
|
||||||
if (splitscreen > 2)
|
|
||||||
SendNameAndColor4();
|
|
||||||
|
|
||||||
SendWeaponPref();
|
|
||||||
if (splitscreen)
|
|
||||||
SendWeaponPref2();
|
|
||||||
if (splitscreen > 1)
|
|
||||||
SendWeaponPref3();
|
|
||||||
if (splitscreen > 2)
|
|
||||||
SendWeaponPref4();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only works for displayplayer, sorry!
|
// Only works for displayplayer, sorry!
|
||||||
@@ -2108,10 +1762,12 @@ INT32 D_LookupPlayer(const char *s)
|
|||||||
return playernum;
|
return playernum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const size_t len = strlen(s);
|
||||||
|
|
||||||
for (playernum = 0; playernum < MAXPLAYERS; ++playernum)
|
for (playernum = 0; playernum < MAXPLAYERS; ++playernum)
|
||||||
{
|
{
|
||||||
/* Match name case-insensitively: fully, or partially the start. */
|
/* Match name case-insensitively: fully, or partially the start. */
|
||||||
if (playeringame[playernum] && (strnicmp(player_names[playernum], s, strlen(s)) == 0))
|
if (playeringame[playernum] && (strnicmp(player_names[playernum], s, len) == 0))
|
||||||
{
|
{
|
||||||
return playernum;
|
return playernum;
|
||||||
}
|
}
|
||||||
@@ -2151,6 +1807,7 @@ static void GetViewablePlayerPlaceRange(INT32 *first, INT32 *last)
|
|||||||
(*last) = 0;
|
(*last) = 0;
|
||||||
|
|
||||||
for (i = 0; i < MAXPLAYERS; ++i)
|
for (i = 0; i < MAXPLAYERS; ++i)
|
||||||
|
{
|
||||||
if (G_CouldView(i))
|
if (G_CouldView(i))
|
||||||
{
|
{
|
||||||
place = players[i].kartstuff[k_position];
|
place = players[i].kartstuff[k_position];
|
||||||
@@ -2160,6 +1817,7 @@ static void GetViewablePlayerPlaceRange(INT32 *first, INT32 *last)
|
|||||||
(*last) = place;
|
(*last) = place;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#define PRINTVIEWPOINT( pre,suf ) \
|
#define PRINTVIEWPOINT( pre,suf ) \
|
||||||
CONS_Printf(pre"viewing \x84(%d) \x83%s\x80"suf".\n",\
|
CONS_Printf(pre"viewing \x84(%d) \x83%s\x80"suf".\n",\
|
||||||
@@ -2491,7 +2149,7 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r
|
|||||||
displayplayers[1] = 1;
|
displayplayers[1] = 1;
|
||||||
playeringame[1] = true;
|
playeringame[1] = true;
|
||||||
players[1].bot = 1;
|
players[1].bot = 1;
|
||||||
SendNameAndColor2();
|
SendNameAndColor(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5775,9 +5433,10 @@ static void Name_OnChange(void)
|
|||||||
{
|
{
|
||||||
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
||||||
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
CV_StealthSet(&cv_playername, player_names[consoleplayer]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
SendNameAndColor();
|
SendNameAndColor(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5787,9 +5446,10 @@ static void Name2_OnChange(void)
|
|||||||
{
|
{
|
||||||
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
||||||
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
CV_StealthSet(&cv_playername2, player_names[displayplayers[1]]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
SendNameAndColor2();
|
SendNameAndColor(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Name3_OnChange(void)
|
static void Name3_OnChange(void)
|
||||||
@@ -5798,9 +5458,10 @@ static void Name3_OnChange(void)
|
|||||||
{
|
{
|
||||||
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
||||||
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
CV_StealthSet(&cv_playername3, player_names[displayplayers[2]]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
SendNameAndColor3();
|
SendNameAndColor(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Name4_OnChange(void)
|
static void Name4_OnChange(void)
|
||||||
@@ -5809,9 +5470,10 @@ static void Name4_OnChange(void)
|
|||||||
{
|
{
|
||||||
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
|
||||||
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
CV_StealthSet(&cv_playername4, player_names[displayplayers[3]]);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
SendNameAndColor4();
|
SendNameAndColor(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sends a skin change for the console player, unless that player is moving.
|
/** Sends a skin change for the console player, unless that player is moving.
|
||||||
@@ -5833,7 +5495,7 @@ static void Skin_OnChange(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CanChangeSkin(consoleplayer) && !P_PlayerMoving(consoleplayer))
|
if (CanChangeSkin(consoleplayer) && !P_PlayerMoving(consoleplayer))
|
||||||
SendNameAndColor();
|
SendNameAndColor(0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
||||||
@@ -5854,7 +5516,7 @@ static void Skin2_OnChange(void)
|
|||||||
return; // do whatever you want
|
return; // do whatever you want
|
||||||
|
|
||||||
if (CanChangeSkin(displayplayers[1]) && !P_PlayerMoving(displayplayers[1]))
|
if (CanChangeSkin(displayplayers[1]) && !P_PlayerMoving(displayplayers[1]))
|
||||||
SendNameAndColor2();
|
SendNameAndColor(1);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
||||||
@@ -5870,7 +5532,7 @@ static void Skin3_OnChange(void)
|
|||||||
return; // do whatever you want
|
return; // do whatever you want
|
||||||
|
|
||||||
if (CanChangeSkin(displayplayers[2]) && !P_PlayerMoving(displayplayers[2]))
|
if (CanChangeSkin(displayplayers[2]) && !P_PlayerMoving(displayplayers[2]))
|
||||||
SendNameAndColor3();
|
SendNameAndColor(2);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
||||||
@@ -5886,7 +5548,7 @@ static void Skin4_OnChange(void)
|
|||||||
return; // do whatever you want
|
return; // do whatever you want
|
||||||
|
|
||||||
if (CanChangeSkin(displayplayers[3]) && !P_PlayerMoving(displayplayers[3]))
|
if (CanChangeSkin(displayplayers[3]) && !P_PlayerMoving(displayplayers[3]))
|
||||||
SendNameAndColor4();
|
SendNameAndColor(3);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));
|
||||||
@@ -5999,7 +5661,7 @@ static void Color_OnChange(void)
|
|||||||
if (!P_PlayerMoving(consoleplayer))
|
if (!P_PlayerMoving(consoleplayer))
|
||||||
{
|
{
|
||||||
// Color change menu scrolling fix is no longer necessary
|
// Color change menu scrolling fix is no longer necessary
|
||||||
SendNameAndColor();
|
SendNameAndColor(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -6021,7 +5683,7 @@ static void Color2_OnChange(void)
|
|||||||
if (!P_PlayerMoving(displayplayers[1]))
|
if (!P_PlayerMoving(displayplayers[1]))
|
||||||
{
|
{
|
||||||
// Color change menu scrolling fix is no longer necessary
|
// Color change menu scrolling fix is no longer necessary
|
||||||
SendNameAndColor2();
|
SendNameAndColor(1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -6038,7 +5700,7 @@ static void Color3_OnChange(void)
|
|||||||
if (!P_PlayerMoving(displayplayers[2]))
|
if (!P_PlayerMoving(displayplayers[2]))
|
||||||
{
|
{
|
||||||
// Color change menu scrolling fix is no longer necessary
|
// Color change menu scrolling fix is no longer necessary
|
||||||
SendNameAndColor3();
|
SendNameAndColor(2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -6055,7 +5717,7 @@ static void Color4_OnChange(void)
|
|||||||
if (!P_PlayerMoving(displayplayers[3]))
|
if (!P_PlayerMoving(displayplayers[3]))
|
||||||
{
|
{
|
||||||
// Color change menu scrolling fix is no longer necessary
|
// Color change menu scrolling fix is no longer necessary
|
||||||
SendNameAndColor4();
|
SendNameAndColor(3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-5
@@ -21,10 +21,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
|
||||||
void SendWeaponPref(void);
|
void SendWeaponPref(UINT8 splitplayer);
|
||||||
void SendWeaponPref2(void);
|
|
||||||
void SendWeaponPref3(void);
|
|
||||||
void SendWeaponPref4(void);
|
|
||||||
|
|
||||||
// console vars
|
// console vars
|
||||||
extern consvar_t cv_playername;
|
extern consvar_t cv_playername;
|
||||||
@@ -295,7 +292,7 @@ typedef union {
|
|||||||
// add game commands, needs cleanup
|
// add game commands, needs cleanup
|
||||||
void D_RegisterServerCommands(void);
|
void D_RegisterServerCommands(void);
|
||||||
void D_RegisterClientCommands(void);
|
void D_RegisterClientCommands(void);
|
||||||
void D_SendPlayerConfig(void);
|
void D_SendPlayerConfig(UINT8 splitplayer);
|
||||||
void Command_ExitGame_f(void);
|
void Command_ExitGame_f(void);
|
||||||
void Command_Retry_f(void);
|
void Command_Retry_f(void);
|
||||||
void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore
|
void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore
|
||||||
|
|||||||
+1
-1
@@ -960,7 +960,7 @@ void Got_Filetxpak(void)
|
|||||||
|| fastcmp(filename, "music.kart")
|
|| fastcmp(filename, "music.kart")
|
||||||
|| fastcmp(filename, "patch.kart")
|
|| fastcmp(filename, "patch.kart")
|
||||||
))
|
))
|
||||||
I_Error("Tried to download \"%s\"", filename);
|
I_Error("Tried to download base-game file: \"%s\"", filename);
|
||||||
|
|
||||||
if (filenum >= fileneedednum)
|
if (filenum >= fileneedednum)
|
||||||
{
|
{
|
||||||
|
|||||||
+22
-5
@@ -115,20 +115,25 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f)
|
|||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
if (myfeof(f))
|
if (myfeof(f))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// we need one byte for a null terminated string
|
// we need one byte for a null terminated string
|
||||||
bufsize--;
|
bufsize--;
|
||||||
|
|
||||||
while (i < bufsize && !myfeof(f))
|
while (i < bufsize && !myfeof(f))
|
||||||
{
|
{
|
||||||
char c = *f->curpos++;
|
char c = *f->curpos++;
|
||||||
|
|
||||||
if (c == '^')
|
if (c == '^')
|
||||||
buf[i++] = myfget_color(f);
|
buf[i++] = myfget_color(f);
|
||||||
else if (c == '\\')
|
else if (c == '\\')
|
||||||
buf[i++] = myfget_hex(f);
|
buf[i++] = myfget_hex(f);
|
||||||
else if (c != '\r')
|
else if (c != '\r')
|
||||||
buf[i++] = c;
|
buf[i++] = c;
|
||||||
|
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf[i] = '\0';
|
buf[i] = '\0';
|
||||||
|
|
||||||
dbg_line++;
|
dbg_line++;
|
||||||
@@ -138,25 +143,31 @@ char *myfgets(char *buf, size_t bufsize, MYFILE *f)
|
|||||||
static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f)
|
static char *myhashfgets(char *buf, size_t bufsize, MYFILE *f)
|
||||||
{
|
{
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
if (myfeof(f))
|
if (myfeof(f))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// we need one byte for a null terminated string
|
// we need one byte for a null terminated string
|
||||||
bufsize--;
|
bufsize--;
|
||||||
|
|
||||||
while (i < bufsize && !myfeof(f))
|
while (i < bufsize && !myfeof(f))
|
||||||
{
|
{
|
||||||
char c = *f->curpos++;
|
char c = *f->curpos++;
|
||||||
|
|
||||||
if (c == '^')
|
if (c == '^')
|
||||||
buf[i++] = myfget_color(f);
|
buf[i++] = myfget_color(f);
|
||||||
else if (c == '\\')
|
else if (c == '\\')
|
||||||
buf[i++] = myfget_hex(f);
|
buf[i++] = myfget_hex(f);
|
||||||
else if (c != '\r')
|
else if (c != '\r')
|
||||||
buf[i++] = c;
|
buf[i++] = c;
|
||||||
|
|
||||||
if (c == '\n') // Ensure debug line is right...
|
if (c == '\n') // Ensure debug line is right...
|
||||||
dbg_line++;
|
dbg_line++;
|
||||||
|
|
||||||
if (c == '#')
|
if (c == '#')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
buf[i] = '\0';
|
buf[i] = '\0';
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
@@ -315,7 +326,10 @@ static void readPlayer(MYFILE *f, INT32 num)
|
|||||||
goto done;
|
goto done;
|
||||||
PlayerMenu[num].status = IT_CALL;
|
PlayerMenu[num].status = IT_CALL;
|
||||||
|
|
||||||
for (i = 0; i < MAXLINELEN-3; i++)
|
// A friendly neighborhood alias for brevity's sake
|
||||||
|
const size_t note_size = sizeof(description[num].notes);
|
||||||
|
|
||||||
|
for (i = 0; i < (INT32)(MAXLINELEN-note_size-3); i++)
|
||||||
{
|
{
|
||||||
if (s[i] == '=')
|
if (s[i] == '=')
|
||||||
{
|
{
|
||||||
@@ -323,10 +337,12 @@ static void readPlayer(MYFILE *f, INT32 num)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playertext)
|
if (playertext)
|
||||||
{
|
{
|
||||||
strcpy(description[num].notes, playertext);
|
strlcpy(description[num].notes, playertext, note_size);
|
||||||
strcat(description[num].notes, myhashfgets(playertext, sizeof (description[num].notes), f));
|
strlcat(description[num].notes,
|
||||||
|
myhashfgets(playertext, note_size, f), note_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strcpy(description[num].notes, "");
|
strcpy(description[num].notes, "");
|
||||||
@@ -335,7 +351,7 @@ static void readPlayer(MYFILE *f, INT32 num)
|
|||||||
// It works down here, though.
|
// It works down here, though.
|
||||||
{
|
{
|
||||||
INT32 numline = 0;
|
INT32 numline = 0;
|
||||||
for (i = 0; (size_t)i < sizeof(description[num].notes)-1; i++)
|
for (i = 0; (size_t)i < note_size-1; i++)
|
||||||
{
|
{
|
||||||
if (numline < 20 && description[num].notes[i] == '\n')
|
if (numline < 20 && description[num].notes[i] == '\n')
|
||||||
numline++;
|
numline++;
|
||||||
@@ -344,6 +360,7 @@ static void readPlayer(MYFILE *f, INT32 num)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
description[num].notes[strlen(description[num].notes)-1] = '\0';
|
description[num].notes[strlen(description[num].notes)-1] = '\0';
|
||||||
description[num].notes[i] = '\0';
|
description[num].notes[i] = '\0';
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
+1
-4
@@ -69,9 +69,6 @@ UINT8 botcolor = 0;
|
|||||||
|
|
||||||
JoyType_t Joystick[MAXSPLITSCREENPLAYERS] = {};
|
JoyType_t Joystick[MAXSPLITSCREENPLAYERS] = {};
|
||||||
|
|
||||||
// 1024 bytes is plenty for a savegame
|
|
||||||
#define SAVEGAMESIZE (1024)
|
|
||||||
|
|
||||||
// SRB2kart
|
// SRB2kart
|
||||||
char gamedatafilename[64] = "kartdata.dat";
|
char gamedatafilename[64] = "kartdata.dat";
|
||||||
char timeattackfolder[64] = "kart";
|
char timeattackfolder[64] = "kart";
|
||||||
@@ -3902,7 +3899,7 @@ void G_SaveGame(UINT32 savegameslot)
|
|||||||
char name[VERSIONSIZE];
|
char name[VERSIONSIZE];
|
||||||
size_t length;
|
size_t length;
|
||||||
|
|
||||||
save.p = save.buffer = (UINT8 *)Z_Malloc(SAVEGAMESIZE, PU_STATIC, NULL);
|
save.p = save.buffer = (UINT8 *)Z_Malloc(1024, PU_STATIC, NULL); // 1024 bytes is plenty for a savegame
|
||||||
if (!save.p)
|
if (!save.p)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("No more free memory for saving game data\n"));
|
CONS_Alert(CONS_ERROR, M_GetText("No more free memory for saving game data\n"));
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ void HWR_DrawStretchyFixedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t p
|
|||||||
|
|
||||||
if (alphalevel)
|
if (alphalevel)
|
||||||
{
|
{
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff;
|
Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff;
|
||||||
|
|
||||||
switch (alphalevel)
|
switch (alphalevel)
|
||||||
@@ -385,7 +385,7 @@ void HWR_DrawCroppedPatch(patch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale,
|
|||||||
// clip it since it is used for bunny scroll in doom I
|
// clip it since it is used for bunny scroll in doom I
|
||||||
if (alphalevel)
|
if (alphalevel)
|
||||||
{
|
{
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff;
|
Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff;
|
||||||
|
|
||||||
switch (alphalevel)
|
switch (alphalevel)
|
||||||
@@ -490,7 +490,7 @@ void HWR_DrawFlatFill(INT32 x, INT32 y, INT32 w, INT32 h, lumpnum_t flatlumpnum)
|
|||||||
void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
|
void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
|
||||||
{
|
{
|
||||||
FOutVector v[4];
|
FOutVector v[4];
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
FBITFIELD poly_flags = PF_NoTexture|PF_Modulated|PF_NoDepthTest;
|
FBITFIELD poly_flags = PF_NoTexture|PF_Modulated|PF_NoDepthTest;
|
||||||
|
|
||||||
v[0].x = v[3].x = -1.0f;
|
v[0].x = v[3].x = -1.0f;
|
||||||
@@ -543,7 +543,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength)
|
|||||||
void HWR_DrawConsoleBack(UINT32 color, INT32 height)
|
void HWR_DrawConsoleBack(UINT32 color, INT32 height)
|
||||||
{
|
{
|
||||||
FOutVector v[4];
|
FOutVector v[4];
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
|
|
||||||
// setup some neat-o translucency effect
|
// setup some neat-o translucency effect
|
||||||
if (!height) //cool hack 0 height is full height
|
if (!height) //cool hack 0 height is full height
|
||||||
@@ -598,7 +598,7 @@ void HWR_drawAMline(const fline_t *fl, INT32 color)
|
|||||||
void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color)
|
void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color)
|
||||||
{
|
{
|
||||||
FOutVector v[4];
|
FOutVector v[4];
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
float fx, fy, fw, fh, fwait = 0;
|
float fx, fy, fw, fh, fwait = 0;
|
||||||
RGBA_t *palette;
|
RGBA_t *palette;
|
||||||
|
|
||||||
@@ -702,7 +702,7 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color)
|
|||||||
void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options)
|
void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options)
|
||||||
{
|
{
|
||||||
FOutVector v[4];
|
FOutVector v[4];
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
float fx, fy, fw, fh;
|
float fx, fy, fw, fh;
|
||||||
|
|
||||||
if (w < 0 || h < 0)
|
if (w < 0 || h < 0)
|
||||||
@@ -820,7 +820,7 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32
|
|||||||
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
|
void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color)
|
||||||
{
|
{
|
||||||
FOutVector v[4];
|
FOutVector v[4];
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
float fx, fy, fw, fh;
|
float fx, fy, fw, fh;
|
||||||
|
|
||||||
if (w < 0 || h < 0)
|
if (w < 0 || h < 0)
|
||||||
|
|||||||
+12
-16
@@ -242,7 +242,6 @@ consvar_t cv_glportals = {"gr_portals", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL,
|
|||||||
|
|
||||||
consvar_t cv_glpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_glpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_glpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_glpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_glpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_glpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_glflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
|
||||||
|
|
||||||
consvar_t cv_gltexturedepth = {"gr_texturedepth", "32 bits", CV_CALL|CV_SAVE, gltexdepth_cons_t, CV_gltextureformat_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_gltexturedepth = {"gr_texturedepth", "32 bits", CV_CALL|CV_SAVE, gltexdepth_cons_t, CV_gltextureformat_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
@@ -551,7 +550,7 @@ static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t
|
|||||||
// Render a floor or ceiling convex polygon
|
// Render a floor or ceiling convex polygon
|
||||||
static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap)
|
static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, boolean isceiling, fixed_t fixedheight, FBITFIELD PolyFlags, INT32 lightlevel, lumpnum_t lumpnum, sector_t *FOFsector, UINT8 alpha, extracolormap_t *planecolormap)
|
||||||
{
|
{
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
FOutVector *v3d;
|
FOutVector *v3d;
|
||||||
polyvertex_t *pv;
|
polyvertex_t *pv;
|
||||||
pslope_t *slope = NULL;
|
pslope_t *slope = NULL;
|
||||||
@@ -1376,7 +1375,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
|||||||
extracolormap_t *colormap = gl_frontsector->extra_colormap;
|
extracolormap_t *colormap = gl_frontsector->extra_colormap;
|
||||||
lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap);
|
lightnum = HWR_CalcWallLight(lightnum, gl_curline, colormap);
|
||||||
|
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
|
|
||||||
Surf.PolyColor.s.alpha = 255;
|
Surf.PolyColor.s.alpha = 255;
|
||||||
|
|
||||||
@@ -2675,7 +2674,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling,
|
|||||||
float scrollx = 0.0f, scrolly = 0.0f;
|
float scrollx = 0.0f, scrolly = 0.0f;
|
||||||
float anglef = 0.0f, cosangf = 0.0f, sinangf = 0.0f;
|
float anglef = 0.0f, cosangf = 0.0f, sinangf = 0.0f;
|
||||||
angle_t angle = 0;
|
angle_t angle = 0;
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
fixed_t tempxsow, tempytow;
|
fixed_t tempxsow, tempytow;
|
||||||
size_t nrPlaneVerts;
|
size_t nrPlaneVerts;
|
||||||
|
|
||||||
@@ -2842,9 +2841,8 @@ static void HWR_AddPolyObjectPlanes(void)
|
|||||||
light = R_GetPlaneLight(gl_frontsector, polyobjsector->floorheight, true);
|
light = R_GetPlaneLight(gl_frontsector, polyobjsector->floorheight, true);
|
||||||
if (po_ptrs[i]->translucency > 0)
|
if (po_ptrs[i]->translucency > 0)
|
||||||
{
|
{
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
FBITFIELD blendmode;
|
FBITFIELD blendmode;
|
||||||
memset(&Surf, 0x00, sizeof(Surf));
|
|
||||||
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
|
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
|
||||||
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight,
|
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->floorpic].lumpnum, po_ptrs[i], false, polyobjsector->floorheight,
|
||||||
(light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap));
|
(light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap));
|
||||||
@@ -2865,9 +2863,8 @@ static void HWR_AddPolyObjectPlanes(void)
|
|||||||
light = R_GetPlaneLight(gl_frontsector, polyobjsector->ceilingheight, true);
|
light = R_GetPlaneLight(gl_frontsector, polyobjsector->ceilingheight, true);
|
||||||
if (po_ptrs[i]->translucency > 0)
|
if (po_ptrs[i]->translucency > 0)
|
||||||
{
|
{
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
FBITFIELD blendmode;
|
FBITFIELD blendmode;
|
||||||
memset(&Surf, 0x00, sizeof(Surf));
|
|
||||||
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
|
blendmode = HWR_TranstableToAlpha(po_ptrs[i]->translucency, &Surf);
|
||||||
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight,
|
HWR_AddTransparentPolyobjectFloor(levelflats[polyobjsector->ceilingpic].lumpnum, po_ptrs[i], true, polyobjsector->ceilingheight,
|
||||||
(light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap));
|
(light == -1 ? gl_frontsector->lightlevel : *gl_frontsector->lightlist[light].lightlevel), Surf.PolyColor.s.alpha, polyobjsector, blendmode, (light == -1 ? gl_frontsector->extra_colormap : gl_frontsector->lightlist[light].extra_colormap));
|
||||||
@@ -3419,7 +3416,7 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
|
|||||||
{
|
{
|
||||||
float this_scale = 1.0f;
|
float this_scale = 1.0f;
|
||||||
FOutVector swallVerts[4];
|
FOutVector swallVerts[4];
|
||||||
FSurfaceInfo sSurf;
|
FSurfaceInfo sSurf = {};
|
||||||
FBITFIELD blendmode = 0;
|
FBITFIELD blendmode = 0;
|
||||||
fixed_t floorheight, mobjfloor;
|
fixed_t floorheight, mobjfloor;
|
||||||
pslope_t *floorslope;
|
pslope_t *floorslope;
|
||||||
@@ -3655,7 +3652,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite)
|
|||||||
FOutVector baseWallVerts[4]; // This is what the verts should end up as
|
FOutVector baseWallVerts[4]; // This is what the verts should end up as
|
||||||
patch_t *gpatch;
|
patch_t *gpatch;
|
||||||
GLPatch_t *hwrpatch;
|
GLPatch_t *hwrpatch;
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
extracolormap_t *colormap;
|
extracolormap_t *colormap;
|
||||||
INT32 lightlevel;
|
INT32 lightlevel;
|
||||||
boolean lightset = true;
|
boolean lightset = true;
|
||||||
@@ -3940,7 +3937,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
|
|||||||
FOutVector wallVerts[4];
|
FOutVector wallVerts[4];
|
||||||
patch_t *gpatch; // sprite patch converted to hardware
|
patch_t *gpatch; // sprite patch converted to hardware
|
||||||
GLPatch_t *hwrpatch;
|
GLPatch_t *hwrpatch;
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
FBITFIELD blend = 0;
|
FBITFIELD blend = 0;
|
||||||
|
|
||||||
INT32 shader = SHADER_NONE;
|
INT32 shader = SHADER_NONE;
|
||||||
@@ -4105,7 +4102,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
|
|||||||
FOutVector wallVerts[4];
|
FOutVector wallVerts[4];
|
||||||
patch_t *gpatch; // sprite patch converted to hardware
|
patch_t *gpatch; // sprite patch converted to hardware
|
||||||
GLPatch_t *hwrpatch;
|
GLPatch_t *hwrpatch;
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
|
|
||||||
INT32 shader = SHADER_NONE;
|
INT32 shader = SHADER_NONE;
|
||||||
|
|
||||||
@@ -4850,7 +4847,7 @@ static void HWR_ProjectSprite(mobj_t *thing)
|
|||||||
flip = sprframe->flip; // Will only be 0x00 or 0xFF
|
flip = sprframe->flip; // Will only be 0x00 or 0xFF
|
||||||
|
|
||||||
if (papersprite && ang < ANGLE_180)
|
if (papersprite && ang < ANGLE_180)
|
||||||
flip ^= 0xFFFF;
|
flip ^= 0xFF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -5913,7 +5910,6 @@ void HWR_AddCommands(void)
|
|||||||
|
|
||||||
CV_RegisterVar(&cv_glpaletterendering);
|
CV_RegisterVar(&cv_glpaletterendering);
|
||||||
CV_RegisterVar(&cv_glpalettedepth);
|
CV_RegisterVar(&cv_glpalettedepth);
|
||||||
CV_RegisterVar(&cv_glflashpal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -6070,7 +6066,7 @@ static void HWR_DoPostProcessor(void)
|
|||||||
{
|
{
|
||||||
// Armageddon Blast Flash!
|
// Armageddon Blast Flash!
|
||||||
// Could this even be considered postprocessor?
|
// Could this even be considered postprocessor?
|
||||||
if (!HWR_PalRenderFlashpal())
|
if (!HWR_ShouldUsePaletteRendering())
|
||||||
{
|
{
|
||||||
const player_t *player = &players[displayplayers[viewssnum]];
|
const player_t *player = &players[displayplayers[viewssnum]];
|
||||||
|
|
||||||
@@ -6083,7 +6079,7 @@ static void HWR_DoPostProcessor(void)
|
|||||||
{-4.0f, -4.0f, 4.0f, 0.0f, 0.0f}
|
{-4.0f, -4.0f, 4.0f, 0.0f, 0.0f}
|
||||||
};
|
};
|
||||||
|
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
|
|
||||||
// This won't change if the flash palettes are changed unfortunately, but it works for its purpose
|
// This won't change if the flash palettes are changed unfortunately, but it works for its purpose
|
||||||
if (player->flashpal == PAL_NUKE)
|
if (player->flashpal == PAL_NUKE)
|
||||||
|
|||||||
@@ -208,7 +208,6 @@ extern consvar_t cv_glportals;
|
|||||||
|
|
||||||
extern consvar_t cv_glpaletterendering;
|
extern consvar_t cv_glpaletterendering;
|
||||||
extern consvar_t cv_glpalettedepth;
|
extern consvar_t cv_glpalettedepth;
|
||||||
extern consvar_t cv_glflashpal;
|
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE boolean HWR_UseShader(void)
|
FUNCINLINE static ATTRINLINE boolean HWR_UseShader(void)
|
||||||
{
|
{
|
||||||
@@ -220,11 +219,6 @@ FUNCINLINE static ATTRINLINE boolean HWR_ShouldUsePaletteRendering(void)
|
|||||||
return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader());
|
return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader());
|
||||||
}
|
}
|
||||||
|
|
||||||
FUNCINLINE static ATTRINLINE boolean HWR_PalRenderFlashpal(void)
|
|
||||||
{
|
|
||||||
return (cv_glflashpal.value && HWR_ShouldUsePaletteRendering());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns a pointer to the palette which should be used for caching textures.
|
// Returns a pointer to the palette which should be used for caching textures.
|
||||||
FUNCINLINE static ATTRINLINE RGBA_t *HWR_GetTexturePalette(void)
|
FUNCINLINE static ATTRINLINE RGBA_t *HWR_GetTexturePalette(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1099,7 +1099,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
|
|||||||
INT32 frame = 0;
|
INT32 frame = 0;
|
||||||
INT32 nextFrame = -1;
|
INT32 nextFrame = -1;
|
||||||
FTransform p;
|
FTransform p;
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
|
|
||||||
if (!cv_glmdls.value || spr->precip)
|
if (!cv_glmdls.value || spr->precip)
|
||||||
return;
|
return;
|
||||||
@@ -1336,8 +1336,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
|
|||||||
if (spr->mobj->frame & FF_ANIMATE)
|
if (spr->mobj->frame & FF_ANIMATE)
|
||||||
{
|
{
|
||||||
// set duration and tics to be the correct values for FF_ANIMATE states
|
// set duration and tics to be the correct values for FF_ANIMATE states
|
||||||
durs = (float)spr->mobj->state->var2;
|
durs = spr->mobj->state->var2;
|
||||||
tics = (float)spr->mobj->anim_duration;
|
tics = (INT32)spr->mobj->anim_duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: this is not yet correct
|
//FIXME: this is not yet correct
|
||||||
@@ -1475,7 +1475,7 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c
|
|||||||
patch_t *gpatch, *blendgpatch;
|
patch_t *gpatch, *blendgpatch;
|
||||||
GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL;
|
GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL;
|
||||||
FTransform p;
|
FTransform p;
|
||||||
FSurfaceInfo Surf;
|
FSurfaceInfo Surf = {};
|
||||||
|
|
||||||
if (!md2->model)
|
if (!md2->model)
|
||||||
{
|
{
|
||||||
@@ -1526,7 +1526,6 @@ void HWR_Draw2DModel(md2_t *md2, INT32 x, INT32 y, INT32 skinnum, skincolors_t c
|
|||||||
if (blendgpatch)
|
if (blendgpatch)
|
||||||
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
|
hwrBlendPatch = ((GLPatch_t *)blendgpatch->hardware);
|
||||||
|
|
||||||
memset(&Surf, 0x00, sizeof(FSurfaceInfo));
|
|
||||||
Surf.PolyColor.rgba = 0xFFFFFFFF;
|
Surf.PolyColor.rgba = 0xFFFFFFFF;
|
||||||
Surf.PolyFlags = PF_Occlude | PF_Modulated;
|
Surf.PolyFlags = PF_Occlude | PF_Modulated;
|
||||||
|
|
||||||
|
|||||||
+8
-6
@@ -496,9 +496,11 @@ static void cleanupnodes(void)
|
|||||||
|
|
||||||
// Why can't I start at zero?
|
// Why can't I start at zero?
|
||||||
for (j = 1; j < MAXNETNODES; j++)
|
for (j = 1; j < MAXNETNODES; j++)
|
||||||
|
{
|
||||||
if (!(nodeingame[j] || SV_SendingFile(j)))
|
if (!(nodeingame[j] || SV_SendingFile(j)))
|
||||||
nodeconnected[j] = false;
|
nodeconnected[j] = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static SINT8 getfreenode(void)
|
static SINT8 getfreenode(void)
|
||||||
{
|
{
|
||||||
@@ -507,11 +509,13 @@ static SINT8 getfreenode(void)
|
|||||||
cleanupnodes();
|
cleanupnodes();
|
||||||
|
|
||||||
for (j = 0; j < MAXNETNODES; j++)
|
for (j = 0; j < MAXNETNODES; j++)
|
||||||
|
{
|
||||||
if (!nodeconnected[j])
|
if (!nodeconnected[j])
|
||||||
{
|
{
|
||||||
nodeconnected[j] = true;
|
nodeconnected[j] = true;
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** \warning No free node? Just in case a node might not have been freed properly,
|
/** \warning No free node? Just in case a node might not have been freed properly,
|
||||||
* look if there are connected nodes that aren't in game, and forget them.
|
* look if there are connected nodes that aren't in game, and forget them.
|
||||||
@@ -812,7 +816,7 @@ static void SOCK_Send(void)
|
|||||||
static void SOCK_FreeNodenum(INT32 numnode)
|
static void SOCK_FreeNodenum(INT32 numnode)
|
||||||
{
|
{
|
||||||
// can't disconnect from self :)
|
// can't disconnect from self :)
|
||||||
if (!numnode || numnode > MAXNETNODES)
|
if (numnode <= 0 || numnode > MAXNETNODES)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DEBFILE(va("Free node %d (%s)\n", numnode, SOCK_GetNodeAddress(numnode)));
|
DEBFILE(va("Free node %d (%s)\n", numnode, SOCK_GetNodeAddress(numnode)));
|
||||||
@@ -1432,14 +1436,12 @@ static void SOCK_RegisterHolePunch(void)
|
|||||||
|
|
||||||
static boolean SOCK_OpenSocket(void)
|
static boolean SOCK_OpenSocket(void)
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
|
|
||||||
memset(clientaddress, 0, sizeof(clientaddress));
|
memset(clientaddress, 0, sizeof(clientaddress));
|
||||||
|
|
||||||
|
memset(nodeconnected, false, sizeof(nodeconnected));
|
||||||
nodeconnected[0] = true; // always connected to self
|
nodeconnected[0] = true; // always connected to self
|
||||||
for (i = 1; i < MAXNETNODES; i++)
|
|
||||||
nodeconnected[i] = false;
|
|
||||||
nodeconnected[BROADCASTADDR] = true;
|
nodeconnected[BROADCASTADDR] = true;
|
||||||
|
|
||||||
I_NetSend = SOCK_Send;
|
I_NetSend = SOCK_Send;
|
||||||
I_NetGet = SOCK_Get;
|
I_NetGet = SOCK_Get;
|
||||||
I_NetCloseSocket = SOCK_CloseSocket;
|
I_NetCloseSocket = SOCK_CloseSocket;
|
||||||
@@ -1479,7 +1481,7 @@ static boolean SOCK_Ban(INT32 node)
|
|||||||
{
|
{
|
||||||
INT32 ban;
|
INT32 ban;
|
||||||
|
|
||||||
if (node > MAXNETNODES)
|
if (node < 0 || node > MAXNETNODES)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ban = numbans;
|
ban = numbans;
|
||||||
|
|||||||
+17
-2
@@ -2159,7 +2159,13 @@ static void K_GetKartBoostPower(player_t *player)
|
|||||||
&& player->speed > 0
|
&& player->speed > 0
|
||||||
&& !player->spectator)
|
&& !player->spectator)
|
||||||
{
|
{
|
||||||
K_SpawnWipeoutTrail(player->mo, true);
|
mobj_t *dust = K_SpawnWipeoutTrail(player->mo, true);
|
||||||
|
|
||||||
|
// Technically, all mobjs that think can cause desynchs if they are spawned conditionally, so best we can do
|
||||||
|
// is to hide them if you are in saltyhop jump
|
||||||
|
if (dust && player->mo->salty.jump)
|
||||||
|
dust->flags2 |= MF2_DONTDRAW;
|
||||||
|
|
||||||
if (leveltime % 6 == 0)
|
if (leveltime % 6 == 0)
|
||||||
S_StartSound(player->mo, sfx_cdfm70);
|
S_StartSound(player->mo, sfx_cdfm70);
|
||||||
}
|
}
|
||||||
@@ -3634,7 +3640,7 @@ void K_SpawnSparkleTrail(mobj_t *mo)
|
|||||||
P_SetMobjState(sparkle, S_KARTINVULN_LARGE1);
|
P_SetMobjState(sparkle, S_KARTINVULN_LARGE1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent)
|
mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent)
|
||||||
{
|
{
|
||||||
mobj_t *dust;
|
mobj_t *dust;
|
||||||
angle_t aoff;
|
angle_t aoff;
|
||||||
@@ -3675,6 +3681,8 @@ void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent)
|
|||||||
|
|
||||||
if (translucent)
|
if (translucent)
|
||||||
dust->flags2 |= MF2_SHADOW;
|
dust->flags2 |= MF2_SHADOW;
|
||||||
|
|
||||||
|
return dust;
|
||||||
}
|
}
|
||||||
|
|
||||||
// K_DriftDustHandling
|
// K_DriftDustHandling
|
||||||
@@ -6175,6 +6183,13 @@ void K_KartUpdatePosition(player_t *player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the player should NOT be checked against themselves! lol
|
||||||
|
// otherwise prevcheck will effectively be halved
|
||||||
|
// sadly this stuff is exposed to lua and atleast one script uses those so we cant fix it
|
||||||
|
// oh well
|
||||||
|
//if (player == &players[i])
|
||||||
|
//continue;
|
||||||
|
|
||||||
const boolean isprevcheckpointi = mo->health == players[i].starpostnum;
|
const boolean isprevcheckpointi = mo->health == players[i].starpostnum;
|
||||||
const boolean isnextcheckpointi = mo->health == (players[i].starpostnum + 1);
|
const boolean isnextcheckpointi = mo->health == (players[i].starpostnum + 1);
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -57,7 +57,7 @@ boolean K_ShouldSlopeRoll(mobj_t *mobj);
|
|||||||
void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope);
|
void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope);
|
||||||
void K_SpawnBoostTrail(player_t *player);
|
void K_SpawnBoostTrail(player_t *player);
|
||||||
void K_SpawnSparkleTrail(mobj_t *mo);
|
void K_SpawnSparkleTrail(mobj_t *mo);
|
||||||
void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent);
|
mobj_t *K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent);
|
||||||
void K_DriftDustHandling(mobj_t *spawner);
|
void K_DriftDustHandling(mobj_t *spawner);
|
||||||
void K_PuntMine(mobj_t *mine, mobj_t *punter);
|
void K_PuntMine(mobj_t *mine, mobj_t *punter);
|
||||||
void K_DoSneaker(player_t *player, INT32 type);
|
void K_DoSneaker(player_t *player, INT32 type);
|
||||||
|
|||||||
@@ -1023,8 +1023,6 @@ static menuitem_t OP_OpenGLOptionsMenu[] =
|
|||||||
{IT_STRING | IT_CVAR, NULL, "Fallback Player 3D Model", &cv_glfallbackplayermodel, 20},
|
{IT_STRING | IT_CVAR, NULL, "Fallback Player 3D Model", &cv_glfallbackplayermodel, 20},
|
||||||
{IT_STRING | IT_CVAR, NULL, "Shaders", &cv_glshaders, 25},
|
{IT_STRING | IT_CVAR, NULL, "Shaders", &cv_glshaders, 25},
|
||||||
{IT_STRING | IT_CVAR, NULL, "Palette Rendering", &cv_glpaletterendering, 30},
|
{IT_STRING | IT_CVAR, NULL, "Palette Rendering", &cv_glpaletterendering, 30},
|
||||||
{IT_STRING | IT_CVAR, NULL, "Palette Rendering Flashpals",&cv_glflashpal, 35},
|
|
||||||
//{IT_STRING | IT_CVAR, NULL, "Min Shader Brightness", &cv_glsecbright, 40},
|
|
||||||
|
|
||||||
{IT_STRING | IT_CVAR, NULL, "Texture Quality", &cv_gltexturedepth, 45},
|
{IT_STRING | IT_CVAR, NULL, "Texture Quality", &cv_gltexturedepth, 45},
|
||||||
{IT_STRING | IT_CVAR, NULL, "Texture Filter", &cv_glfiltermode, 50},
|
{IT_STRING | IT_CVAR, NULL, "Texture Filter", &cv_glfiltermode, 50},
|
||||||
|
|||||||
+17
-4
@@ -804,9 +804,15 @@ static void M_PNGText(png_structp png_ptr, png_infop png_info_ptr, PNG_CONST png
|
|||||||
png_infotext[5].text = locationtxt;
|
png_infotext[5].text = locationtxt;
|
||||||
png_infotext[6].text = interfacetxt;
|
png_infotext[6].text = interfacetxt;
|
||||||
png_infotext[7].text = rendermodetxt;
|
png_infotext[7].text = rendermodetxt;
|
||||||
png_infotext[8].text = strncpy(ctrevision, comprevision, sizeof(ctrevision)-1);
|
strncpy(ctrevision, comprevision, sizeof(ctrevision)-1);
|
||||||
png_infotext[9].text = strncpy(ctdate, compdate, sizeof(ctdate)-1);
|
ctrevision[sizeof(ctrevision)-1] = '\0';
|
||||||
png_infotext[10].text = strncpy(cttime, comptime, sizeof(cttime)-1);
|
png_infotext[8].text = ctrevision;
|
||||||
|
strncpy(ctdate, compdate, sizeof(ctdate)-1);
|
||||||
|
ctdate[sizeof(ctdate)-1] = '\0';
|
||||||
|
png_infotext[9].text = ctdate;
|
||||||
|
strncpy(cttime, comptime, sizeof(cttime)-1);
|
||||||
|
cttime[sizeof(cttime)-1] = '\0';
|
||||||
|
png_infotext[10].text = cttime;
|
||||||
|
|
||||||
png_set_text(png_ptr, png_info_ptr, png_infotext, SRB2PNGTXT);
|
png_set_text(png_ptr, png_info_ptr, png_infotext, SRB2PNGTXT);
|
||||||
#undef SRB2PNGTXT
|
#undef SRB2PNGTXT
|
||||||
@@ -1564,6 +1570,7 @@ char *M_GetToken(const char *inputString)
|
|||||||
{
|
{
|
||||||
startPos = endPos;
|
startPos = endPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stringToUse == NULL)
|
if (stringToUse == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -1634,7 +1641,8 @@ char *M_GetToken(const char *inputString)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the end of the string is reached, no token is to be read
|
// If the end of the string is reached, no token is to be read
|
||||||
if (startPos == stringLength) {
|
if (startPos == stringLength)
|
||||||
|
{
|
||||||
endPos = stringLength;
|
endPos = stringLength;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1855,8 +1863,10 @@ int M_PathParts(const char *path)
|
|||||||
int n;
|
int n;
|
||||||
const char *p;
|
const char *p;
|
||||||
const char *t;
|
const char *t;
|
||||||
|
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (n = 0, p = path ;; ++n)
|
for (n = 0, p = path ;; ++n)
|
||||||
{
|
{
|
||||||
t = p;
|
t = p;
|
||||||
@@ -1869,6 +1879,7 @@ int M_PathParts(const char *path)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1911,7 +1922,9 @@ void M_MkdirEachUntil(const char *cpath, int start, int end, int mode)
|
|||||||
if (!( p = strchr(p, PATHSEP[0]) ))
|
if (!( p = strchr(p, PATHSEP[0]) ))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p += strspn(p, PATHSEP);
|
p += strspn(p, PATHSEP);
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (end > 0 && !--end)
|
if (end > 0 && !--end)
|
||||||
|
|||||||
+3
-3
@@ -1914,7 +1914,7 @@ static void P_LoadMapBSP(const virtres_t* virt)
|
|||||||
if (numsubsectors <= 0)
|
if (numsubsectors <= 0)
|
||||||
I_Error("Level has no subsectors (did you forget to run it through a nodesbuilder?)");
|
I_Error("Level has no subsectors (did you forget to run it through a nodesbuilder?)");
|
||||||
if (numnodes <= 0)
|
if (numnodes <= 0)
|
||||||
I_Error("Level has no nodes");
|
I_Error("Level has no nodes (does your map have at least 2 sectors?)");
|
||||||
if (numsegs <= 0)
|
if (numsegs <= 0)
|
||||||
I_Error("Level has no segs");
|
I_Error("Level has no segs");
|
||||||
|
|
||||||
@@ -2174,14 +2174,14 @@ static INT32 P_MakeBufferMD5(const char *buffer, size_t len, void *resblock)
|
|||||||
memset(resblock, 0x00, 16);
|
memset(resblock, 0x00, 16);
|
||||||
return 1;
|
return 1;
|
||||||
#else
|
#else
|
||||||
tic_t t = I_GetTime();
|
precise_t t = I_GetPreciseTime();
|
||||||
|
|
||||||
CONS_Debug(DBG_SETUP, "Making MD5\n");
|
CONS_Debug(DBG_SETUP, "Making MD5\n");
|
||||||
|
|
||||||
if (md5_buffer(buffer, len, resblock) == NULL)
|
if (md5_buffer(buffer, len, resblock) == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
CONS_Debug(DBG_SETUP, "MD5 calc took %f seconds\n", (float)(I_GetTime() - t)/NEWTICRATE);
|
CONS_Debug(DBG_SETUP, "MD5 calc took %f seconds\n", (float)(I_GetPreciseTime() - t)/I_GetPrecisePrecision());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+4
-4
@@ -280,22 +280,22 @@ static void Fov_OnChange(void)
|
|||||||
|
|
||||||
static void FlipCam_OnChange(void)
|
static void FlipCam_OnChange(void)
|
||||||
{
|
{
|
||||||
SendWeaponPref();
|
SendWeaponPref(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FlipCam2_OnChange(void)
|
static void FlipCam2_OnChange(void)
|
||||||
{
|
{
|
||||||
SendWeaponPref2();
|
SendWeaponPref(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FlipCam3_OnChange(void)
|
static void FlipCam3_OnChange(void)
|
||||||
{
|
{
|
||||||
SendWeaponPref3();
|
SendWeaponPref(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FlipCam4_OnChange(void)
|
static void FlipCam4_OnChange(void)
|
||||||
{
|
{
|
||||||
SendWeaponPref4();
|
SendWeaponPref(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Precipstuff_OnChange(void)
|
static void Precipstuff_OnChange(void)
|
||||||
|
|||||||
+2
-25
@@ -116,9 +116,7 @@ consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL,
|
|||||||
|
|
||||||
boolean keepmapmusic = false; // keep the current music on map restart
|
boolean keepmapmusic = false; // keep the current music on map restart
|
||||||
boolean skipintromus = false; // skip the intro fanfare
|
boolean skipintromus = false; // skip the intro fanfare
|
||||||
static boolean resumekeepmusic = false;
|
|
||||||
static music_t keepmusic;
|
static music_t keepmusic;
|
||||||
static void S_SetKeepMusResume(void);
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENMPT
|
#ifdef HAVE_OPENMPT
|
||||||
openmpt_module *openmpt_mhandle = NULL;
|
openmpt_module *openmpt_mhandle = NULL;
|
||||||
@@ -1848,8 +1846,6 @@ void S_StopMusic(void)
|
|||||||
|
|
||||||
mapmusic.resume = (cv_resume.value && fasticmp(music.name, mapmusic.name)) ? I_GetSongPosition() : 0;
|
mapmusic.resume = (cv_resume.value && fasticmp(music.name, mapmusic.name)) ? I_GetSongPosition() : 0;
|
||||||
|
|
||||||
S_SetKeepMusResume();
|
|
||||||
|
|
||||||
if (I_SongPaused())
|
if (I_SongPaused())
|
||||||
I_ResumeSong();
|
I_ResumeSong();
|
||||||
|
|
||||||
@@ -1976,17 +1972,6 @@ void S_ResetKeepAndSpecialMus(void)
|
|||||||
keepmapmusic = skipintromus = false;
|
keepmapmusic = skipintromus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// saves the current song position everytime a song stops
|
|
||||||
// so we can resume it in some cases
|
|
||||||
static void S_SetKeepMusResume(void)
|
|
||||||
{
|
|
||||||
keepmusic.resume = 0;
|
|
||||||
|
|
||||||
if (fasticmp(music.name, mapmusic.name))
|
|
||||||
{
|
|
||||||
keepmusic.resume = I_GetSongPosition();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// determine if we should keep the music on a map restart
|
// determine if we should keep the music on a map restart
|
||||||
// this gets called BEFORE the level gets loaded in G_DoLoadLevel
|
// this gets called BEFORE the level gets loaded in G_DoLoadLevel
|
||||||
@@ -1995,7 +1980,7 @@ void S_KeepMusic(void)
|
|||||||
static INT16 oldmap = -1;
|
static INT16 oldmap = -1;
|
||||||
static boolean oldencore = false;
|
static boolean oldencore = false;
|
||||||
|
|
||||||
keepmapmusic = resumekeepmusic = false;
|
keepmapmusic = false;
|
||||||
|
|
||||||
if (!cv_keepmusic.value)
|
if (!cv_keepmusic.value)
|
||||||
{
|
{
|
||||||
@@ -2009,9 +1994,7 @@ void S_KeepMusic(void)
|
|||||||
|
|
||||||
if (oldmap == gamemap && oldencore == encoremode)
|
if (oldmap == gamemap && oldencore == encoremode)
|
||||||
{
|
{
|
||||||
const boolean musicchanged = S_CheckMusicException();
|
keepmapmusic = (S_CheckMusicException() == false);
|
||||||
resumekeepmusic = (musicchanged && keepmusic.resume);
|
|
||||||
keepmapmusic = (!musicchanged || resumekeepmusic);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
oldencore = encoremode;
|
oldencore = encoremode;
|
||||||
@@ -2072,12 +2055,6 @@ void S_InitMapMusic(void)
|
|||||||
|
|
||||||
if (keepmapmusic)
|
if (keepmapmusic)
|
||||||
{
|
{
|
||||||
// this is kinda silly, but we can use it to fade back into the map song at the saved point, should the current music be different from the map music
|
|
||||||
if (resumekeepmusic)
|
|
||||||
{
|
|
||||||
S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, keepmusic.resume, 0, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,8 +216,13 @@ void I_StartupSound(void)
|
|||||||
SDLmixlinked->major, SDLmixlinked->minor, SDLmixlinked->patch);
|
SDLmixlinked->major, SDLmixlinked->minor, SDLmixlinked->patch);
|
||||||
|
|
||||||
#ifdef HAVE_OPENMPT
|
#ifdef HAVE_OPENMPT
|
||||||
I_OutputMsg("libopenmpt version: %s\n", openmpt_get_string("library_version"));
|
const char *openmptstr;
|
||||||
I_OutputMsg("libopenmpt build date: %s\n", openmpt_get_string("build"));
|
openmptstr = openmpt_get_string("library_version");
|
||||||
|
I_OutputMsg("libopenmpt version: %s\n", openmptstr);
|
||||||
|
openmpt_free_string(openmptstr);
|
||||||
|
openmptstr = openmpt_get_string("build");
|
||||||
|
I_OutputMsg("libopenmpt build date: %s\n", openmptstr);
|
||||||
|
openmpt_free_string(openmptstr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
sound_started = true;
|
sound_started = true;
|
||||||
|
|||||||
+1
-1
@@ -180,7 +180,7 @@ static void ST_doPaletteStuff(void)
|
|||||||
INT32 palette = 0;
|
INT32 palette = 0;
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (rendermode == render_opengl && !HWR_PalRenderFlashpal())
|
if (rendermode == render_opengl && !HWR_ShouldUsePaletteRendering())
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,525 @@
|
|||||||
|
#ifndef H_PALDELTA
|
||||||
|
#define H_PALDELTA
|
||||||
|
|
||||||
|
// those are the differences in palette indices between the main srb2 playpal and its white and nuke subpalettes
|
||||||
|
// this is probably not the best way of doing any of this, but it works lol
|
||||||
|
|
||||||
|
static const INT16 pPaletteDeltaFlash[256][3] = {
|
||||||
|
{ 6, 6, 6},
|
||||||
|
{ 12, 12, 12},
|
||||||
|
{ 18, 18, 18},
|
||||||
|
{ 24, 24, 24},
|
||||||
|
{ 30, 30, 30},
|
||||||
|
{ 36, 36, 36},
|
||||||
|
{ 42, 42, 42},
|
||||||
|
{ 48, 48, 48},
|
||||||
|
{ 54, 54, 54},
|
||||||
|
{ 60, 60, 60},
|
||||||
|
{ 66, 66, 66},
|
||||||
|
{ 72, 72, 72},
|
||||||
|
{ 78, 78, 78},
|
||||||
|
{ 84, 84, 84},
|
||||||
|
{ 90, 90, 90},
|
||||||
|
{ 95, 95, 95},
|
||||||
|
{ 101, 101, 101},
|
||||||
|
{ 107, 107, 107},
|
||||||
|
{ 113, 113, 113},
|
||||||
|
{ 119, 119, 119},
|
||||||
|
{ 125, 125, 125},
|
||||||
|
{ 131, 131, 131},
|
||||||
|
{ 137, 137, 137},
|
||||||
|
{ 143, 143, 143},
|
||||||
|
{ 149, 149, 149},
|
||||||
|
{ 155, 155, 155},
|
||||||
|
{ 161, 161, 161},
|
||||||
|
{ 167, 167, 167},
|
||||||
|
{ 173, 173, 173},
|
||||||
|
{ 179, 179, 179},
|
||||||
|
{ 185, 185, 185},
|
||||||
|
{ 191, 191, 191},
|
||||||
|
{ 48, 66, 84},
|
||||||
|
{ 54, 71, 89},
|
||||||
|
{ 60, 77, 95},
|
||||||
|
{ 66, 83, 100},
|
||||||
|
{ 72, 88, 105},
|
||||||
|
{ 79, 94, 111},
|
||||||
|
{ 85, 99, 117},
|
||||||
|
{ 91, 105, 123},
|
||||||
|
{ 96, 111, 129},
|
||||||
|
{ 102, 117, 135},
|
||||||
|
{ 108, 123, 141},
|
||||||
|
{ 114, 128, 146},
|
||||||
|
{ 120, 134, 152},
|
||||||
|
{ 127, 140, 158},
|
||||||
|
{ 133, 145, 163},
|
||||||
|
{ 140, 152, 170},
|
||||||
|
{ 48, 98, 134},
|
||||||
|
{ 57, 104, 137},
|
||||||
|
{ 63, 107, 140},
|
||||||
|
{ 69, 110, 143},
|
||||||
|
{ 75, 116, 146},
|
||||||
|
{ 84, 119, 149},
|
||||||
|
{ 90, 125, 152},
|
||||||
|
{ 95, 128, 155},
|
||||||
|
{ 101, 131, 158},
|
||||||
|
{ 110, 137, 161},
|
||||||
|
{ 119, 140, 164},
|
||||||
|
{ 128, 143, 167},
|
||||||
|
{ 134, 149, 170},
|
||||||
|
{ 143, 155, 173},
|
||||||
|
{ 152, 158, 176},
|
||||||
|
{ 158, 164, 179},
|
||||||
|
{ 0, 15, 24},
|
||||||
|
{ 0, 21, 33},
|
||||||
|
{ 0, 27, 42},
|
||||||
|
{ 0, 33, 51},
|
||||||
|
{ 0, 36, 57},
|
||||||
|
{ 0, 42, 66},
|
||||||
|
{ 0, 48, 75},
|
||||||
|
{ 0, 51, 81},
|
||||||
|
{ 0, 57, 93},
|
||||||
|
{ 6, 63, 98},
|
||||||
|
{ 12, 69, 104},
|
||||||
|
{ 18, 75, 110},
|
||||||
|
{ 24, 81, 116},
|
||||||
|
{ 30, 87, 122},
|
||||||
|
{ 36, 93, 128},
|
||||||
|
{ 39, 95, 131},
|
||||||
|
{ 0, 12, 26},
|
||||||
|
{ 0, 26, 52},
|
||||||
|
{ 0, 39, 78},
|
||||||
|
{ 0, 52, 102},
|
||||||
|
{ 0, 65, 127},
|
||||||
|
{ 0, 78, 150},
|
||||||
|
{ 0, 91, 172},
|
||||||
|
{ 0, 102, 191},
|
||||||
|
{ 9, 108, 191},
|
||||||
|
{ 19, 114, 191},
|
||||||
|
{ 29, 120, 191},
|
||||||
|
{ 39, 127, 191},
|
||||||
|
{ 48, 133, 191},
|
||||||
|
{ 58, 139, 191},
|
||||||
|
{ 68, 145, 191},
|
||||||
|
{ 78, 150, 191},
|
||||||
|
{ 0, 0, 12},
|
||||||
|
{ 0, 0, 36},
|
||||||
|
{ 0, 0, 60},
|
||||||
|
{ 0, 0, 84},
|
||||||
|
{ 0, 0, 107},
|
||||||
|
{ 0, 0, 131},
|
||||||
|
{ 0, 0, 155},
|
||||||
|
{ 0, 0, 179},
|
||||||
|
{ 0, 0, 191},
|
||||||
|
{ 36, 36, 191},
|
||||||
|
{ 60, 60, 191},
|
||||||
|
{ 84, 84, 191},
|
||||||
|
{ 107, 107, 191},
|
||||||
|
{ 131, 131, 191},
|
||||||
|
{ 155, 155, 191},
|
||||||
|
{ 179, 179, 191},
|
||||||
|
{ 0, 0, 104},
|
||||||
|
{ 15, 27, 125},
|
||||||
|
{ 30, 51, 140},
|
||||||
|
{ 45, 75, 155},
|
||||||
|
{ 60, 98, 167},
|
||||||
|
{ 75, 122, 176},
|
||||||
|
{ 90, 140, 185},
|
||||||
|
{ 104, 158, 191},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 24, 24},
|
||||||
|
{ 0, 48, 48},
|
||||||
|
{ 0, 72, 72},
|
||||||
|
{ 0, 95, 95},
|
||||||
|
{ 0, 119, 119},
|
||||||
|
{ 0, 143, 143},
|
||||||
|
{ 0, 167, 167},
|
||||||
|
{ 0, 191, 191},
|
||||||
|
{ 12, 191, 191},
|
||||||
|
{ 24, 191, 191},
|
||||||
|
{ 36, 191, 191},
|
||||||
|
{ 48, 191, 191},
|
||||||
|
{ 60, 191, 191},
|
||||||
|
{ 72, 191, 191},
|
||||||
|
{ 84, 191, 191},
|
||||||
|
{ 95, 191, 191},
|
||||||
|
{ 107, 191, 191},
|
||||||
|
{ 119, 191, 191},
|
||||||
|
{ 131, 191, 191},
|
||||||
|
{ 143, 191, 191},
|
||||||
|
{ 155, 191, 191},
|
||||||
|
{ 167, 191, 191},
|
||||||
|
{ 179, 191, 191},
|
||||||
|
{ 0, 54, 54},
|
||||||
|
{ 9, 69, 69},
|
||||||
|
{ 18, 84, 84},
|
||||||
|
{ 27, 98, 98},
|
||||||
|
{ 39, 110, 110},
|
||||||
|
{ 48, 122, 122},
|
||||||
|
{ 57, 131, 131},
|
||||||
|
{ 66, 143, 143},
|
||||||
|
{ 85, 156, 191},
|
||||||
|
{ 91, 161, 191},
|
||||||
|
{ 96, 166, 191},
|
||||||
|
{ 102, 172, 191},
|
||||||
|
{ 108, 177, 191},
|
||||||
|
{ 114, 182, 191},
|
||||||
|
{ 120, 187, 191},
|
||||||
|
{ 127, 191, 191},
|
||||||
|
{ 101, 0, 131},
|
||||||
|
{ 106, 11, 134},
|
||||||
|
{ 111, 23, 138},
|
||||||
|
{ 117, 35, 142},
|
||||||
|
{ 123, 47, 145},
|
||||||
|
{ 129, 59, 149},
|
||||||
|
{ 134, 71, 153},
|
||||||
|
{ 140, 83, 157},
|
||||||
|
{ 145, 95, 160},
|
||||||
|
{ 151, 106, 164},
|
||||||
|
{ 157, 118, 168},
|
||||||
|
{ 162, 130, 172},
|
||||||
|
{ 168, 142, 175},
|
||||||
|
{ 173, 154, 179},
|
||||||
|
{ 179, 166, 183},
|
||||||
|
{ 185, 179, 187},
|
||||||
|
{ 24, 0, 65},
|
||||||
|
{ 42, 20, 80},
|
||||||
|
{ 61, 41, 95},
|
||||||
|
{ 79, 61, 110},
|
||||||
|
{ 97, 82, 124},
|
||||||
|
{ 115, 101, 139},
|
||||||
|
{ 135, 123, 154},
|
||||||
|
{ 153, 143, 169},
|
||||||
|
{ 191, 0, 191},
|
||||||
|
{ 191, 24, 191},
|
||||||
|
{ 191, 48, 191},
|
||||||
|
{ 191, 72, 191},
|
||||||
|
{ 191, 95, 191},
|
||||||
|
{ 191, 119, 191},
|
||||||
|
{ 191, 143, 191},
|
||||||
|
{ 191, 167, 191},
|
||||||
|
{ 0, 107, 0},
|
||||||
|
{ 0, 191, 0},
|
||||||
|
{ 24, 191, 24},
|
||||||
|
{ 48, 191, 48},
|
||||||
|
{ 72, 191, 72},
|
||||||
|
{ 95, 191, 95},
|
||||||
|
{ 119, 191, 119},
|
||||||
|
{ 143, 191, 143},
|
||||||
|
{ 16, 16, 9},
|
||||||
|
{ 44, 44, 22},
|
||||||
|
{ 73, 73, 36},
|
||||||
|
{ 101, 101, 51},
|
||||||
|
{ 127, 127, 66},
|
||||||
|
{ 142, 142, 93},
|
||||||
|
{ 156, 156, 121},
|
||||||
|
{ 170, 170, 151},
|
||||||
|
{ 31, 10, 0},
|
||||||
|
{ 48, 15, 0},
|
||||||
|
{ 64, 21, 0},
|
||||||
|
{ 79, 25, 0},
|
||||||
|
{ 95, 30, 0},
|
||||||
|
{ 111, 36, 0},
|
||||||
|
{ 127, 41, 0},
|
||||||
|
{ 143, 48, 0},
|
||||||
|
{ 149, 73, 24},
|
||||||
|
{ 155, 84, 48},
|
||||||
|
{ 161, 101, 72},
|
||||||
|
{ 167, 119, 95},
|
||||||
|
{ 191, 48, 48},
|
||||||
|
{ 191, 95, 95},
|
||||||
|
{ 191, 119, 119},
|
||||||
|
{ 191, 143, 143},
|
||||||
|
{ 18, 18, 0},
|
||||||
|
{ 42, 42, 0},
|
||||||
|
{ 61, 61, 0},
|
||||||
|
{ 86, 86, 0},
|
||||||
|
{ 104, 104, 0},
|
||||||
|
{ 129, 129, 0},
|
||||||
|
{ 154, 154, 0},
|
||||||
|
{ 172, 172, 0},
|
||||||
|
{ 191, 191, 0},
|
||||||
|
{ 191, 191, 18},
|
||||||
|
{ 191, 191, 36},
|
||||||
|
{ 191, 191, 55},
|
||||||
|
{ 191, 191, 74},
|
||||||
|
{ 191, 191, 92},
|
||||||
|
{ 191, 191, 110},
|
||||||
|
{ 191, 191, 129},
|
||||||
|
{ 191, 191, 131},
|
||||||
|
{ 191, 191, 143},
|
||||||
|
{ 191, 191, 149},
|
||||||
|
{ 191, 191, 161},
|
||||||
|
{ 191, 191, 167},
|
||||||
|
{ 191, 191, 179},
|
||||||
|
{ 191, 191, 185},
|
||||||
|
{ 191, 0, 0},
|
||||||
|
{ 36, 95, 36},
|
||||||
|
{ 54, 107, 54},
|
||||||
|
{ 72, 119, 72},
|
||||||
|
{ 90, 131, 90},
|
||||||
|
{ 107, 143, 107},
|
||||||
|
{ 125, 155, 125},
|
||||||
|
{ 143, 167, 143},
|
||||||
|
{ 161, 179, 161}
|
||||||
|
};
|
||||||
|
|
||||||
|
static const INT16 pPaletteDeltaNuke[256][3] = {
|
||||||
|
{ 6,-133,-133},
|
||||||
|
{ 12,-125,-125},
|
||||||
|
{ 18,-117,-117},
|
||||||
|
{ 24,-109,-109},
|
||||||
|
{ 30,-101,-101},
|
||||||
|
{ 36, -93, -93},
|
||||||
|
{ 42, -85, -85},
|
||||||
|
{ 48, -77, -77},
|
||||||
|
{ 54, -69, -69},
|
||||||
|
{ 60, -61, -61},
|
||||||
|
{ 66, -53, -53},
|
||||||
|
{ 72, -45, -45},
|
||||||
|
{ 78, -37, -37},
|
||||||
|
{ 84, -29, -29},
|
||||||
|
{ 90, -21, -21},
|
||||||
|
{ 95, -14, -14},
|
||||||
|
{ 101, -6, -6},
|
||||||
|
{ 107, 2, 2},
|
||||||
|
{ 113, 10, 10},
|
||||||
|
{ 119, 18, 18},
|
||||||
|
{ 125, 26, 26},
|
||||||
|
{ 131, 34, 34},
|
||||||
|
{ 137, 42, 42},
|
||||||
|
{ 143, 50, 50},
|
||||||
|
{ 149, 58, 58},
|
||||||
|
{ 155, 66, 66},
|
||||||
|
{ 161, 74, 74},
|
||||||
|
{ 167, 82, 82},
|
||||||
|
{ 173, 90, 90},
|
||||||
|
{ 179, 98, 98},
|
||||||
|
{ 185, 106, 106},
|
||||||
|
{ 191, 113, 113},
|
||||||
|
{ 48, -53, -29},
|
||||||
|
{ 54, -46, -22},
|
||||||
|
{ 60, -38, -14},
|
||||||
|
{ 66, -30, -7},
|
||||||
|
{ 72, -23, 0},
|
||||||
|
{ 79, -15, 8},
|
||||||
|
{ 85, -8, 16},
|
||||||
|
{ 91, -1, 23},
|
||||||
|
{ 96, 7, 31},
|
||||||
|
{ 102, 15, 39},
|
||||||
|
{ 108, 23, 47},
|
||||||
|
{ 114, 30, 54},
|
||||||
|
{ 120, 38, 62},
|
||||||
|
{ 127, 46, 70},
|
||||||
|
{ 133, 53, 77},
|
||||||
|
{ 140, 62, 86},
|
||||||
|
{ 48, -10, 38},
|
||||||
|
{ 57, -2, 42},
|
||||||
|
{ 63, 2, 46},
|
||||||
|
{ 69, 6, 50},
|
||||||
|
{ 75, 14, 54},
|
||||||
|
{ 84, 18, 58},
|
||||||
|
{ 90, 26, 62},
|
||||||
|
{ 95, 30, 66},
|
||||||
|
{ 101, 34, 70},
|
||||||
|
{ 110, 42, 74},
|
||||||
|
{ 119, 46, 78},
|
||||||
|
{ 128, 50, 82},
|
||||||
|
{ 134, 58, 86},
|
||||||
|
{ 143, 66, 90},
|
||||||
|
{ 152, 70, 94},
|
||||||
|
{ 158, 78, 98},
|
||||||
|
{ 0,-121,-109},
|
||||||
|
{ 0,-113, -97},
|
||||||
|
{ 0,-105, -85},
|
||||||
|
{ 0, -97, -73},
|
||||||
|
{ 0, -93, -65},
|
||||||
|
{ 0, -85, -53},
|
||||||
|
{ 0, -77, -41},
|
||||||
|
{ 0, -73, -33},
|
||||||
|
{ 0, -65, -17},
|
||||||
|
{ 6, -57, -10},
|
||||||
|
{ 12, -49, -2},
|
||||||
|
{ 18, -41, 6},
|
||||||
|
{ 24, -33, 14},
|
||||||
|
{ 30, -25, 22},
|
||||||
|
{ 36, -17, 30},
|
||||||
|
{ 39, -14, 34},
|
||||||
|
{ 0,-124,-106},
|
||||||
|
{ 0,-106, -71},
|
||||||
|
{ 0, -89, -37},
|
||||||
|
{ 0, -71, -4},
|
||||||
|
{ 0, -54, 28},
|
||||||
|
{ 0, -37, 59},
|
||||||
|
{ 0, -20, 88},
|
||||||
|
{ 0, -4, 113},
|
||||||
|
{ 9, 4, 113},
|
||||||
|
{ 19, 12, 113},
|
||||||
|
{ 29, 20, 113},
|
||||||
|
{ 39, 28, 113},
|
||||||
|
{ 48, 36, 113},
|
||||||
|
{ 58, 44, 113},
|
||||||
|
{ 68, 52, 113},
|
||||||
|
{ 78, 59, 113},
|
||||||
|
{ 0,-141,-125},
|
||||||
|
{ 0,-141, -93},
|
||||||
|
{ 0,-141, -61},
|
||||||
|
{ 0,-141, -29},
|
||||||
|
{ 0,-141, 2},
|
||||||
|
{ 0,-141, 34},
|
||||||
|
{ 0,-141, 66},
|
||||||
|
{ 0,-141, 98},
|
||||||
|
{ 0,-141, 113},
|
||||||
|
{ 36, -93, 113},
|
||||||
|
{ 60, -61, 113},
|
||||||
|
{ 84, -29, 113},
|
||||||
|
{ 107, 2, 113},
|
||||||
|
{ 131, 34, 113},
|
||||||
|
{ 155, 66, 113},
|
||||||
|
{ 179, 98, 113},
|
||||||
|
{ 0,-141, -2},
|
||||||
|
{ 15,-105, 26},
|
||||||
|
{ 30, -73, 46},
|
||||||
|
{ 45, -41, 66},
|
||||||
|
{ 60, -10, 82},
|
||||||
|
{ 75, 22, 94},
|
||||||
|
{ 90, 46, 106},
|
||||||
|
{ 104, 70, 113},
|
||||||
|
{ 0,-141,-141},
|
||||||
|
{ 0,-109,-109},
|
||||||
|
{ 0, -77, -77},
|
||||||
|
{ 0, -45, -45},
|
||||||
|
{ 0, -14, -14},
|
||||||
|
{ 0, 18, 18},
|
||||||
|
{ 0, 50, 50},
|
||||||
|
{ 0, 82, 82},
|
||||||
|
{ 0, 113, 113},
|
||||||
|
{ 12, 113, 113},
|
||||||
|
{ 24, 113, 113},
|
||||||
|
{ 36, 113, 113},
|
||||||
|
{ 48, 113, 113},
|
||||||
|
{ 60, 113, 113},
|
||||||
|
{ 72, 113, 113},
|
||||||
|
{ 84, 113, 113},
|
||||||
|
{ 95, 113, 113},
|
||||||
|
{ 107, 113, 113},
|
||||||
|
{ 119, 113, 113},
|
||||||
|
{ 131, 113, 113},
|
||||||
|
{ 143, 113, 113},
|
||||||
|
{ 155, 113, 113},
|
||||||
|
{ 167, 113, 113},
|
||||||
|
{ 179, 113, 113},
|
||||||
|
{ 0, -69, -69},
|
||||||
|
{ 9, -49, -49},
|
||||||
|
{ 18, -29, -29},
|
||||||
|
{ 27, -10, -10},
|
||||||
|
{ 39, 6, 6},
|
||||||
|
{ 48, 22, 22},
|
||||||
|
{ 57, 34, 34},
|
||||||
|
{ 66, 50, 50},
|
||||||
|
{ 85, 67, 113},
|
||||||
|
{ 91, 74, 113},
|
||||||
|
{ 96, 81, 113},
|
||||||
|
{ 102, 88, 113},
|
||||||
|
{ 108, 95, 113},
|
||||||
|
{ 114, 102, 113},
|
||||||
|
{ 120, 108, 113},
|
||||||
|
{ 127, 113, 113},
|
||||||
|
{ 101,-141, 34},
|
||||||
|
{ 106,-126, 38},
|
||||||
|
{ 111,-110, 43},
|
||||||
|
{ 117, -94, 48},
|
||||||
|
{ 123, -78, 53},
|
||||||
|
{ 129, -62, 58},
|
||||||
|
{ 134, -46, 63},
|
||||||
|
{ 140, -30, 68},
|
||||||
|
{ 145, -14, 73},
|
||||||
|
{ 151, 1, 78},
|
||||||
|
{ 157, 17, 83},
|
||||||
|
{ 162, 33, 88},
|
||||||
|
{ 168, 49, 93},
|
||||||
|
{ 173, 65, 98},
|
||||||
|
{ 179, 81, 103},
|
||||||
|
{ 185, 98, 109},
|
||||||
|
{ 24,-141, -54},
|
||||||
|
{ 42,-114, -34},
|
||||||
|
{ 61, -86, -14},
|
||||||
|
{ 79, -59, 6},
|
||||||
|
{ 97, -32, 25},
|
||||||
|
{ 115, -6, 45},
|
||||||
|
{ 135, 23, 65},
|
||||||
|
{ 153, 50, 84},
|
||||||
|
{ 191,-141, 113},
|
||||||
|
{ 191,-109, 113},
|
||||||
|
{ 191, -77, 113},
|
||||||
|
{ 191, -45, 113},
|
||||||
|
{ 191, -14, 113},
|
||||||
|
{ 191, 18, 113},
|
||||||
|
{ 191, 50, 113},
|
||||||
|
{ 191, 82, 113},
|
||||||
|
{ 0, 2,-141},
|
||||||
|
{ 0, 113,-141},
|
||||||
|
{ 24, 113,-109},
|
||||||
|
{ 48, 113, -77},
|
||||||
|
{ 72, 113, -45},
|
||||||
|
{ 95, 113, -14},
|
||||||
|
{ 119, 113, 18},
|
||||||
|
{ 143, 113, 50},
|
||||||
|
{ 16,-119,-129},
|
||||||
|
{ 44, -82,-111},
|
||||||
|
{ 73, -43, -92},
|
||||||
|
{ 101, -6, -73},
|
||||||
|
{ 127, 29, -53},
|
||||||
|
{ 142, 48, -17},
|
||||||
|
{ 156, 67, 21},
|
||||||
|
{ 170, 86, 61},
|
||||||
|
{ 31,-127,-141},
|
||||||
|
{ 48,-121,-141},
|
||||||
|
{ 64,-113,-141},
|
||||||
|
{ 79,-107,-141},
|
||||||
|
{ 95,-100,-141},
|
||||||
|
{ 111, -93,-141},
|
||||||
|
{ 127, -86,-141},
|
||||||
|
{ 143, -77,-141},
|
||||||
|
{ 149, -43,-109},
|
||||||
|
{ 155, -29, -77},
|
||||||
|
{ 161, -6, -45},
|
||||||
|
{ 167, 18, -14},
|
||||||
|
{ 191, -77, -77},
|
||||||
|
{ 191, -14, -14},
|
||||||
|
{ 191, 18, 18},
|
||||||
|
{ 191, 50, 50},
|
||||||
|
{ 18,-117,-141},
|
||||||
|
{ 42, -84,-141},
|
||||||
|
{ 61, -59,-141},
|
||||||
|
{ 86, -26,-141},
|
||||||
|
{ 104, -2,-141},
|
||||||
|
{ 129, 31,-141},
|
||||||
|
{ 154, 64,-141},
|
||||||
|
{ 172, 89,-141},
|
||||||
|
{ 191, 113,-141},
|
||||||
|
{ 191, 113,-117},
|
||||||
|
{ 191, 113, -92},
|
||||||
|
{ 191, 113, -67},
|
||||||
|
{ 191, 113, -42},
|
||||||
|
{ 191, 113, -18},
|
||||||
|
{ 191, 113, 6},
|
||||||
|
{ 191, 113, 31},
|
||||||
|
{ 191, 113, 34},
|
||||||
|
{ 191, 113, 50},
|
||||||
|
{ 191, 113, 58},
|
||||||
|
{ 191, 113, 74},
|
||||||
|
{ 191, 113, 82},
|
||||||
|
{ 191, 113, 98},
|
||||||
|
{ 191, 113, 106},
|
||||||
|
{ 191,-141,-141},
|
||||||
|
{ 36, -14, -93},
|
||||||
|
{ 54, 2, -69},
|
||||||
|
{ 72, 18, -45},
|
||||||
|
{ 90, 34, -21},
|
||||||
|
{ 107, 50, 2},
|
||||||
|
{ 125, 66, 26},
|
||||||
|
{ 143, 82, 50},
|
||||||
|
{ 161, 98, 74}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
+93
-168
@@ -91,6 +91,7 @@ consvar_t cv_menucaps = {"menucaps", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NUL
|
|||||||
// local copy of the palette for V_GetColor()
|
// local copy of the palette for V_GetColor()
|
||||||
RGBA_t *pLocalPalette = NULL;
|
RGBA_t *pLocalPalette = NULL;
|
||||||
RGBA_t *pGammaCorrectedPalette = NULL;
|
RGBA_t *pGammaCorrectedPalette = NULL;
|
||||||
|
static RGBA_t *pFallbackFlashPal = NULL;
|
||||||
|
|
||||||
static size_t currentPaletteSize;
|
static size_t currentPaletteSize;
|
||||||
|
|
||||||
@@ -409,6 +410,58 @@ UINT32 V_GammaCorrect(UINT32 input, double power)
|
|||||||
return result.rgba;
|
return result.rgba;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "v_paldeltas.h"
|
||||||
|
// remaps a palette with given "deltas"
|
||||||
|
// this is used with premade deltas between the srb2 palette and its both flashpals
|
||||||
|
// so we may approximate generate our own, should the current palette miss them
|
||||||
|
static void ApplyPaletteDelta(const RGBA_t *pal_in, RGBA_t *pal_out, const INT16 pal_delta[][3])
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
INT16 r = (INT16)pal_in[i].s.red + pal_delta[i][0];
|
||||||
|
INT16 g = (INT16)pal_in[i].s.green + pal_delta[i][1];
|
||||||
|
INT16 b = (INT16)pal_in[i].s.blue + pal_delta[i][2];
|
||||||
|
pal_out[i].s.red = (UINT8)CLAMP(r, 0 , 255);
|
||||||
|
pal_out[i].s.green = (UINT8)CLAMP(g, 0 , 255);
|
||||||
|
pal_out[i].s.blue = (UINT8)CLAMP(b, 0 , 255);
|
||||||
|
pal_out[i].s.alpha = 0xFF; // pal_in[i].s.alpha
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void GenerateFlashPalettes(void)
|
||||||
|
{
|
||||||
|
size_t i, palsize;
|
||||||
|
RGBA_t *pFlashPalGammaCorrectedPalette = NULL;
|
||||||
|
|
||||||
|
// generate flashpalettes if the current palette does not provide any subpalettes
|
||||||
|
if (currentPaletteSize >= (14 * (256 * 3))) // 14 palettes are in playpal
|
||||||
|
return;
|
||||||
|
|
||||||
|
palsize = (2*256);
|
||||||
|
|
||||||
|
pFallbackFlashPal = Z_Malloc(sizeof(*pFallbackFlashPal)*palsize, PU_STATIC, NULL);
|
||||||
|
pFlashPalGammaCorrectedPalette = Z_Malloc(sizeof (*pFlashPalGammaCorrectedPalette)*palsize, PU_STATIC, NULL);
|
||||||
|
|
||||||
|
// apply our deltas to the palettes to get the white and red "flashes"
|
||||||
|
ApplyPaletteDelta(pLocalPalette, pFallbackFlashPal, pPaletteDeltaFlash);
|
||||||
|
ApplyPaletteDelta(pLocalPalette, pFallbackFlashPal+256, pPaletteDeltaNuke);
|
||||||
|
|
||||||
|
// apply colour and gamma correction if needed
|
||||||
|
if (Cubeapply)
|
||||||
|
{
|
||||||
|
for (i = 0; i < palsize; i++)
|
||||||
|
{
|
||||||
|
pFlashPalGammaCorrectedPalette[i].rgba = V_GammaDecode(pFallbackFlashPal[i].rgba);
|
||||||
|
V_CubeApply(&pFlashPalGammaCorrectedPalette[i]);
|
||||||
|
pFallbackFlashPal[i].rgba = V_GammaEncode(pFlashPalGammaCorrectedPalette[i].rgba);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Z_Free(pFlashPalGammaCorrectedPalette);
|
||||||
|
}
|
||||||
|
|
||||||
// keep a copy of the palette so that we can get the RGB value for a color index at any time.
|
// keep a copy of the palette so that we can get the RGB value for a color index at any time.
|
||||||
static void LoadPalette(const char *lumpname)
|
static void LoadPalette(const char *lumpname)
|
||||||
{
|
{
|
||||||
@@ -428,6 +481,8 @@ static void LoadPalette(const char *lumpname)
|
|||||||
|
|
||||||
Z_Free(pLocalPalette);
|
Z_Free(pLocalPalette);
|
||||||
Z_Free(pGammaCorrectedPalette);
|
Z_Free(pGammaCorrectedPalette);
|
||||||
|
Z_Free(pFallbackFlashPal);
|
||||||
|
pFallbackFlashPal = NULL;
|
||||||
|
|
||||||
pLocalPalette = Z_Malloc(sizeof (*pLocalPalette)*palsize, PU_STATIC, NULL);
|
pLocalPalette = Z_Malloc(sizeof (*pLocalPalette)*palsize, PU_STATIC, NULL);
|
||||||
pGammaCorrectedPalette = Z_Malloc(sizeof (*pGammaCorrectedPalette)*palsize, PU_STATIC, NULL);
|
pGammaCorrectedPalette = Z_Malloc(sizeof (*pGammaCorrectedPalette)*palsize, PU_STATIC, NULL);
|
||||||
@@ -447,14 +502,21 @@ static void LoadPalette(const char *lumpname)
|
|||||||
pLocalPalette[i].s.alpha = 0xFF;
|
pLocalPalette[i].s.alpha = 0xFF;
|
||||||
|
|
||||||
pGammaCorrectedPalette[i].rgba = V_GammaDecode(pLocalPalette[i].rgba);
|
pGammaCorrectedPalette[i].rgba = V_GammaDecode(pLocalPalette[i].rgba);
|
||||||
|
}
|
||||||
|
|
||||||
if (!Cubeapply)
|
GenerateFlashPalettes();
|
||||||
continue;
|
|
||||||
|
|
||||||
|
// gotta apply any colour and gamma adjustments afterwards
|
||||||
|
// so we dont double apply it to the generated flashpals
|
||||||
|
if (Cubeapply)
|
||||||
|
{
|
||||||
|
for (i = 0; i < palsize; i++)
|
||||||
|
{
|
||||||
V_CubeApply(&pGammaCorrectedPalette[i]);
|
V_CubeApply(&pGammaCorrectedPalette[i]);
|
||||||
pLocalPalette[i].rgba = V_GammaEncode(pGammaCorrectedPalette[i].rgba);
|
pLocalPalette[i].rgba = V_GammaEncode(pGammaCorrectedPalette[i].rgba);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void V_CubeApply(RGBA_t *input)
|
void V_CubeApply(RGBA_t *input)
|
||||||
{
|
{
|
||||||
@@ -543,6 +605,7 @@ void V_ReloadPalette(void)
|
|||||||
// -------------+
|
// -------------+
|
||||||
void V_SetPalette(INT32 palettenum)
|
void V_SetPalette(INT32 palettenum)
|
||||||
{
|
{
|
||||||
|
RGBA_t *pal = NULL;
|
||||||
if (!pLocalPalette)
|
if (!pLocalPalette)
|
||||||
V_ReloadPalette();
|
V_ReloadPalette();
|
||||||
|
|
||||||
@@ -554,24 +617,47 @@ void V_SetPalette(INT32 palettenum)
|
|||||||
if (palettenum == 0)
|
if (palettenum == 0)
|
||||||
{
|
{
|
||||||
palettenum = cv_palettenum.value;
|
palettenum = cv_palettenum.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (palettenum * 256U > currentPaletteSize - 256)
|
// in many cases custom palettes do not provide the needed subpalettes for flashpals to work
|
||||||
|
// before this would mean the renderer gets passed random data out of allocated memory bounds
|
||||||
|
// which was not very cool :chonkbuncle:
|
||||||
|
// gladly 2.1 only actually has 2 different subpalettes
|
||||||
|
// one for "white flash" and one red/pinkish one for nuke
|
||||||
|
// since we checked the palette earlier we should have generated those ourselves
|
||||||
|
if (((size_t)palettenum >= currentPaletteSize / (256 * 3)))
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_WARNING, "cv_palettenum %d out of range\n", palettenum);
|
CONS_Debug(DBG_RENDER, "palettenum %d out of range\n", palettenum);
|
||||||
palettenum = 0;
|
|
||||||
|
// if for some reason we did not generate flashpals
|
||||||
|
// just fall back to the main palette i guess?
|
||||||
|
if (pFallbackFlashPal != NULL)
|
||||||
|
{
|
||||||
|
if (palettenum == PAL_NUKE)
|
||||||
|
pal = &pFallbackFlashPal[256];
|
||||||
|
else
|
||||||
|
pal = pFallbackFlashPal;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pal = pLocalPalette;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pal = &pLocalPalette[palettenum*256];
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
if (rendermode == render_opengl)
|
if (rendermode == render_opengl)
|
||||||
HWR_SetPalette(&pLocalPalette[palettenum*256]);
|
HWR_SetPalette(pal);
|
||||||
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
#if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL)
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if (rendermode != render_none)
|
if (rendermode != render_none)
|
||||||
I_SetPalette(&pLocalPalette[palettenum*256]);
|
I_SetPalette(pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void V_SetPaletteLump(const char *pal)
|
void V_SetPaletteLump(const char *pal)
|
||||||
@@ -3309,167 +3395,6 @@ INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option)
|
|||||||
return max(i-1, 0);
|
return max(i-1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
char V_GetSkincolorChar(INT32 color)
|
|
||||||
{
|
|
||||||
char cstart = 0x80;
|
|
||||||
|
|
||||||
switch (color)
|
|
||||||
{
|
|
||||||
case SKINCOLOR_WHITE:
|
|
||||||
case SKINCOLOR_SILVER:
|
|
||||||
case SKINCOLOR_SLATE:
|
|
||||||
cstart = 0x80; // White
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_GREY:
|
|
||||||
case SKINCOLOR_NICKEL:
|
|
||||||
case SKINCOLOR_BLACK:
|
|
||||||
case SKINCOLOR_SKUNK:
|
|
||||||
case SKINCOLOR_JET:
|
|
||||||
cstart = 0x86; // V_GRAYMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_SEPIA:
|
|
||||||
case SKINCOLOR_BEIGE:
|
|
||||||
case SKINCOLOR_WALNUT:
|
|
||||||
case SKINCOLOR_BROWN:
|
|
||||||
case SKINCOLOR_LEATHER:
|
|
||||||
case SKINCOLOR_RUST:
|
|
||||||
case SKINCOLOR_WRISTWATCH:
|
|
||||||
cstart = 0x8e; // V_BROWNMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_FAIRY:
|
|
||||||
case SKINCOLOR_SALMON:
|
|
||||||
case SKINCOLOR_PINK:
|
|
||||||
case SKINCOLOR_ROSE:
|
|
||||||
case SKINCOLOR_BRICK:
|
|
||||||
case SKINCOLOR_LEMONADE:
|
|
||||||
case SKINCOLOR_BUBBLEGUM:
|
|
||||||
case SKINCOLOR_LILAC:
|
|
||||||
cstart = 0x8d; // V_PINKMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_CINNAMON:
|
|
||||||
case SKINCOLOR_RUBY:
|
|
||||||
case SKINCOLOR_RASPBERRY:
|
|
||||||
case SKINCOLOR_CHERRY:
|
|
||||||
case SKINCOLOR_RED:
|
|
||||||
case SKINCOLOR_CRIMSON:
|
|
||||||
case SKINCOLOR_MAROON:
|
|
||||||
case SKINCOLOR_FLAME:
|
|
||||||
case SKINCOLOR_SCARLET:
|
|
||||||
case SKINCOLOR_KETCHUP:
|
|
||||||
cstart = 0x85; // V_REDMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_DAWN:
|
|
||||||
case SKINCOLOR_SUNSET:
|
|
||||||
case SKINCOLOR_CREAMSICLE:
|
|
||||||
case SKINCOLOR_ORANGE:
|
|
||||||
case SKINCOLOR_PUMPKIN:
|
|
||||||
case SKINCOLOR_ROSEWOOD:
|
|
||||||
case SKINCOLOR_BURGUNDY:
|
|
||||||
case SKINCOLOR_TANGERINE:
|
|
||||||
cstart = 0x87; // V_ORANGEMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_PEACH:
|
|
||||||
case SKINCOLOR_CARAMEL:
|
|
||||||
case SKINCOLOR_CREAM:
|
|
||||||
cstart = 0x8f; // V_PEACHMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_GOLD:
|
|
||||||
case SKINCOLOR_ROYAL:
|
|
||||||
case SKINCOLOR_BRONZE:
|
|
||||||
case SKINCOLOR_COPPER:
|
|
||||||
case SKINCOLOR_THUNDER:
|
|
||||||
cstart = 0x8a; // V_GOLDMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_POPCORN:
|
|
||||||
case SKINCOLOR_QUARRY:
|
|
||||||
case SKINCOLOR_YELLOW:
|
|
||||||
case SKINCOLOR_MUSTARD:
|
|
||||||
case SKINCOLOR_CROCODILE:
|
|
||||||
case SKINCOLOR_OLIVE:
|
|
||||||
cstart = 0x82; // V_YELLOWMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_ARTICHOKE:
|
|
||||||
case SKINCOLOR_VOMIT:
|
|
||||||
case SKINCOLOR_GARDEN:
|
|
||||||
case SKINCOLOR_TEA:
|
|
||||||
case SKINCOLOR_PISTACHIO:
|
|
||||||
cstart = 0x8b; // V_TEAMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_LIME:
|
|
||||||
case SKINCOLOR_HANDHELD:
|
|
||||||
case SKINCOLOR_MOSS:
|
|
||||||
case SKINCOLOR_CAMOUFLAGE:
|
|
||||||
case SKINCOLOR_ROBOHOOD:
|
|
||||||
case SKINCOLOR_MINT:
|
|
||||||
case SKINCOLOR_GREEN:
|
|
||||||
case SKINCOLOR_PINETREE:
|
|
||||||
case SKINCOLOR_EMERALD:
|
|
||||||
case SKINCOLOR_SWAMP:
|
|
||||||
case SKINCOLOR_DREAM:
|
|
||||||
case SKINCOLOR_PLAGUE:
|
|
||||||
case SKINCOLOR_ALGAE:
|
|
||||||
cstart = 0x83; // V_GREENMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_CARIBBEAN:
|
|
||||||
case SKINCOLOR_AZURE:
|
|
||||||
case SKINCOLOR_AQUA:
|
|
||||||
case SKINCOLOR_TEAL:
|
|
||||||
case SKINCOLOR_CYAN:
|
|
||||||
case SKINCOLOR_JAWZ:
|
|
||||||
case SKINCOLOR_CERULEAN:
|
|
||||||
case SKINCOLOR_NAVY:
|
|
||||||
case SKINCOLOR_SAPPHIRE:
|
|
||||||
cstart = 0x88; // V_SKYMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_PIGEON:
|
|
||||||
case SKINCOLOR_PLATINUM:
|
|
||||||
case SKINCOLOR_STEEL:
|
|
||||||
cstart = 0x8c; // V_STEELMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_PERIWINKLE:
|
|
||||||
case SKINCOLOR_BLUE:
|
|
||||||
case SKINCOLOR_BLUEBERRY:
|
|
||||||
case SKINCOLOR_NOVA:
|
|
||||||
cstart = 0x84; // V_BLUEMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_ULTRAVIOLET:
|
|
||||||
case SKINCOLOR_PURPLE:
|
|
||||||
case SKINCOLOR_FUCHSIA:
|
|
||||||
cstart = 0x81; // V_PURPLEMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SKINCOLOR_PASTEL:
|
|
||||||
case SKINCOLOR_MOONSLAM:
|
|
||||||
case SKINCOLOR_DUSK:
|
|
||||||
case SKINCOLOR_TOXIC:
|
|
||||||
case SKINCOLOR_MAUVE:
|
|
||||||
case SKINCOLOR_LAVENDER:
|
|
||||||
case SKINCOLOR_BYZANTIUM:
|
|
||||||
case SKINCOLOR_POMEGRANATE:
|
|
||||||
cstart = 0x89; // V_LAVENDERMAP
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return cstart;
|
|
||||||
}
|
|
||||||
|
|
||||||
INT32 V_SkinColorToHighlightcolor(skincolors_t color)
|
INT32 V_SkinColorToHighlightcolor(skincolors_t color)
|
||||||
{
|
{
|
||||||
switch (color)
|
switch (color)
|
||||||
|
|||||||
@@ -287,8 +287,6 @@ INT32 V_ThinSubStringWidth(const char *string, INT32 length, INT32 option);
|
|||||||
// Find maximum length for substring taken from current string to fit into given width
|
// Find maximum length for substring taken from current string to fit into given width
|
||||||
INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option);
|
INT32 V_SubStringLengthToFit(const char *string, INT32 width, INT32 option);
|
||||||
|
|
||||||
char V_GetSkincolorChar(INT32 color);
|
|
||||||
|
|
||||||
INT32 V_SkinColorToHighlightcolor(skincolors_t color);
|
INT32 V_SkinColorToHighlightcolor(skincolors_t color);
|
||||||
|
|
||||||
// this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol
|
// this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol
|
||||||
|
|||||||
+16
-4
@@ -365,7 +365,7 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock)
|
|||||||
|
|
||||||
if ((fhandle = fopen(filename, "rb")) != NULL)
|
if ((fhandle = fopen(filename, "rb")) != NULL)
|
||||||
{
|
{
|
||||||
tic_t t = I_GetTime();
|
precise_t t = I_GetPreciseTime();
|
||||||
|
|
||||||
CONS_Debug(DBG_SETUP, "Making MD5 for %s\n",filename);
|
CONS_Debug(DBG_SETUP, "Making MD5 for %s\n",filename);
|
||||||
|
|
||||||
@@ -376,7 +376,7 @@ static inline INT32 W_MakeFileMD5(const char *filename, void *resblock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CONS_Debug(DBG_SETUP, "MD5 calc for %s took %f seconds\n",
|
CONS_Debug(DBG_SETUP, "MD5 calc for %s took %f seconds\n",
|
||||||
filename, (float)(I_GetTime() - t)/NEWTICRATE);
|
filename, (float)(I_GetPreciseTime() - t)/I_GetPrecisePrecision());
|
||||||
|
|
||||||
fclose(fhandle);
|
fclose(fhandle);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -2589,6 +2589,18 @@ static int W_CheckFileContains(const char *filename, lumpchecklist_t *checklist)
|
|||||||
return contains;
|
return contains;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int W_CheckAutoLoadContainsMap(const char *filename)
|
||||||
|
{
|
||||||
|
// for now this checks for map marker
|
||||||
|
static lumpchecklist_t autoloadblacklist[] =
|
||||||
|
{
|
||||||
|
{"MAP", 3},
|
||||||
|
{NULL, 0},
|
||||||
|
};
|
||||||
|
|
||||||
|
return W_CheckFileContains(filename, autoloadblacklist);
|
||||||
|
}
|
||||||
|
|
||||||
int W_CheckPostLoadList(const char *filename)
|
int W_CheckPostLoadList(const char *filename)
|
||||||
{
|
{
|
||||||
static lumpchecklist_t postloadlist[] =
|
static lumpchecklist_t postloadlist[] =
|
||||||
@@ -2601,7 +2613,6 @@ int W_CheckPostLoadList(const char *filename)
|
|||||||
{"SOC_", 4},
|
{"SOC_", 4},
|
||||||
{"MAINCFG", 7},
|
{"MAINCFG", 7},
|
||||||
{"OBJCTCFG", 8},
|
{"OBJCTCFG", 8},
|
||||||
{"MAP", 3},
|
|
||||||
|
|
||||||
{NULL, 0},
|
{NULL, 0},
|
||||||
};
|
};
|
||||||
@@ -2662,11 +2673,12 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
|||||||
{
|
{
|
||||||
if (vsizecache[realentry] == 0)
|
if (vsizecache[realentry] == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vlumps[i].size = vsizecache[realentry];
|
vlumps[i].size = vsizecache[realentry];
|
||||||
|
|
||||||
const char *name = (fileinfo + realentry)->name;
|
const char *name = (fileinfo + realentry)->name;
|
||||||
|
|
||||||
if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0)
|
if (strnlen(name, 8) == 5 && memcmp(name, "MAP", 3) == 0)
|
||||||
{
|
{
|
||||||
numlumps--; // We skip map marker, so 1 of entries becomes empty
|
numlumps--; // We skip map marker, so 1 of entries becomes empty
|
||||||
continue; // This will skip i++ so we will write to same entry
|
continue; // This will skip i++ so we will write to same entry
|
||||||
|
|||||||
@@ -241,6 +241,7 @@ void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5);
|
|||||||
|
|
||||||
int W_VerifyNMUSlumps(const char *filename, FILE *handle, boolean exit_on_error);
|
int W_VerifyNMUSlumps(const char *filename, FILE *handle, boolean exit_on_error);
|
||||||
|
|
||||||
|
int W_CheckAutoLoadContainsMap(const char *filename);
|
||||||
int W_CheckPostLoadList(const char *filename);
|
int W_CheckPostLoadList(const char *filename);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
+10
-2
@@ -523,11 +523,19 @@ void Z_CheckHeap(INT32 tag)
|
|||||||
#ifdef VALGRIND_MEMPOOL_EXISTS
|
#ifdef VALGRIND_MEMPOOL_EXISTS
|
||||||
if (!VALGRIND_MEMPOOL_EXISTS(block))
|
if (!VALGRIND_MEMPOOL_EXISTS(block))
|
||||||
{
|
{
|
||||||
I_Error("Z_CheckHeap %d: block %u"
|
I_Error("Z_CheckHeap :"
|
||||||
|
#ifdef ZDEBUG
|
||||||
|
" %s %d"
|
||||||
|
#endif
|
||||||
|
" block %u"
|
||||||
#ifdef ZDEBUG
|
#ifdef ZDEBUG
|
||||||
" (owned by %s:%d)"
|
" (owned by %s:%d)"
|
||||||
#endif
|
#endif
|
||||||
" should not exist", i, blocknumon
|
" should not exist"
|
||||||
|
#ifdef ZDEBUG
|
||||||
|
, file, line
|
||||||
|
#endif
|
||||||
|
, blocknumon
|
||||||
#ifdef ZDEBUG
|
#ifdef ZDEBUG
|
||||||
, block->ownerfile, block->ownerline
|
, block->ownerfile, block->ownerline
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in new issue
Block a user