Compare commits
32
Commits
fixedclamp
...
bluaopti
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0016d4836a | ||
|
|
66bc684738 | ||
|
|
44e377c981 | ||
|
|
91de633633 | ||
|
|
f1047f9e76 | ||
|
|
864e28fcf7 | ||
|
|
b2b0ca17d3 | ||
|
|
513e5a7e3f | ||
|
|
6f75fab7ff | ||
|
|
38fc6d6ba1 | ||
|
|
02f2464a00 | ||
|
|
86b286fb0b | ||
|
|
ecef8913b1 | ||
|
|
277b202020 | ||
|
|
6ba97bc43c | ||
|
|
0fbde146a9 | ||
|
|
16e0c6f0f6 | ||
|
|
8cab07a4b2 | ||
|
|
55c8546d68 | ||
|
|
1762f18116 | ||
|
|
9b879e31e2 | ||
|
|
8e5633a23f | ||
|
|
8bcada1fda | ||
|
|
771152b919 | ||
|
|
b4277c88c1 | ||
|
|
63026cc11d | ||
|
|
b8385d1579 | ||
|
|
916cc9d8ca | ||
|
|
347000a326 | ||
|
|
4967313720 | ||
|
|
19b64a8b61 | ||
|
|
6a7b2b9721 |
No files matched your search
+41
-17
@@ -519,6 +519,23 @@ LUA_API int lua_pushthread (lua_State *L) {
|
||||
** get functions (Lua -> stack)
|
||||
*/
|
||||
|
||||
static void auxgetstr (lua_State *L, const TValue *t, const char *k) {
|
||||
const TValue *slot;
|
||||
TValue key;
|
||||
TString *str = luaS_new(L, k);
|
||||
api_checkvalidindex(L, t);
|
||||
if (luaV_fastget(L, t, str, slot, luaH_getstr)) {
|
||||
setobj2s(L, L->top, slot);
|
||||
api_incr_top(L);
|
||||
}
|
||||
else {
|
||||
setsvalue(L, &key, str);
|
||||
luaV_finishget(L, t, L->top, L->top, slot);
|
||||
api_incr_top(L);
|
||||
}
|
||||
lua_unlock(L);
|
||||
}
|
||||
|
||||
|
||||
LUA_API void lua_gettable (lua_State *L, int idx) {
|
||||
StkId t;
|
||||
@@ -531,15 +548,8 @@ LUA_API void lua_gettable (lua_State *L, int idx) {
|
||||
|
||||
|
||||
LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
|
||||
StkId t;
|
||||
TValue key;
|
||||
lua_lock(L);
|
||||
t = index2adr(L, idx);
|
||||
api_checkvalidindex(L, t);
|
||||
setsvalue(L, &key, luaS_new(L, k));
|
||||
luaV_gettable(L, t, &key, L->top);
|
||||
api_incr_top(L);
|
||||
lua_unlock(L);
|
||||
auxgetstr(L, index2adr(L, idx), k);
|
||||
}
|
||||
|
||||
|
||||
@@ -630,6 +640,26 @@ LUA_API void lua_getfenv (lua_State *L, int idx) {
|
||||
** set functions (stack -> Lua)
|
||||
*/
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||
static void auxsetstr (lua_State *L, const TValue *t, const char *k) {
|
||||
TValue key;
|
||||
const TValue *slot;
|
||||
TString *str = luaS_new(L, k);
|
||||
api_checknelems(L, 1);
|
||||
api_checkvalidindex(L, t);
|
||||
if (luaV_fastset(L, t, str, slot, luaH_setstr, L->top)) {
|
||||
setobj2t(L, cast(TValue *, slot), L->top - 1);
|
||||
L->top--; /* pop value */
|
||||
}
|
||||
else {
|
||||
setsvalue2s(L, &key, str);
|
||||
luaV_finishset(L, t, &key, L->top - 1, slot);
|
||||
L->top--; /* pop value */
|
||||
}
|
||||
lua_unlock(L);
|
||||
}
|
||||
|
||||
|
||||
LUA_API void lua_settable (lua_State *L, int idx) {
|
||||
StkId t;
|
||||
@@ -642,18 +672,12 @@ LUA_API void lua_settable (lua_State *L, int idx) {
|
||||
lua_unlock(L);
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
|
||||
LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
|
||||
StkId t;
|
||||
TValue key;
|
||||
lua_lock(L);
|
||||
api_checknelems(L, 1);
|
||||
t = index2adr(L, idx);
|
||||
api_checkvalidindex(L, t);
|
||||
setsvalue(L, &key, luaS_new(L, k));
|
||||
luaV_settable(L, t, &key, L->top - 1);
|
||||
L->top--; /* pop value */
|
||||
lua_unlock(L);
|
||||
auxsetstr(L, index2adr(L, idx), k);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+15
-3
@@ -20,6 +20,7 @@
|
||||
#define lauxlib_c
|
||||
#define LUA_LIB
|
||||
|
||||
#include "ldebug.h"
|
||||
#include "lua.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) {
|
||||
while (l--)
|
||||
luaL_addchar(B, *s++);
|
||||
while (l) {
|
||||
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) {
|
||||
lua_State *L = lua_newstate(l_alloc, NULL);
|
||||
if (L) lua_atpanic(L, &panic);
|
||||
if (l_likely(L)) lua_atpanic(L, &panic);
|
||||
return L;
|
||||
}
|
||||
+25
-12
@@ -626,8 +626,20 @@ static void codenot (FuncState *fs, expdesc *e) {
|
||||
removevalues(fs, e->t);
|
||||
}
|
||||
|
||||
/*
|
||||
** Check whether expression 'e' is a literal string
|
||||
*/
|
||||
static int isKstr (FuncState *fs, expdesc *e) {
|
||||
return (e->k == VK && ttisstring(&fs->f->k[e->u.s.info]));
|
||||
}
|
||||
|
||||
/*
|
||||
** Create expression 't[k]'. 't' must have its final result already in a
|
||||
** register or upvalue. Upvalues can only be indexed by literal strings.
|
||||
*/
|
||||
void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
|
||||
if (t->k == VUPVAL && !isKstr(fs, k)) /* upvalue indexed by non string? */
|
||||
luaK_exp2anyreg(fs, t); /* put it in a register */
|
||||
t->u.s.aux = luaK_exp2RK(fs, k);
|
||||
t->k = VINDEXED;
|
||||
}
|
||||
@@ -790,18 +802,19 @@ void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
|
||||
case OPR_BXOR: codearith(fs, OP_BXOR, 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_ADD: codearith(fs, OP_ADD, e1, e2); break;
|
||||
case OPR_SUB: codearith(fs, OP_SUB, e1, e2); break;
|
||||
case OPR_MUL: codearith(fs, OP_MUL, e1, e2); break;
|
||||
case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break;
|
||||
case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break;
|
||||
case OPR_POW: codearith(fs, OP_POW, e1, e2); break;
|
||||
case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break;
|
||||
case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); 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_GT: codecomp(fs, OP_LT, 0, e1, e2); break;
|
||||
case OPR_GE: codecomp(fs, OP_LE, 0, e1, e2); break;
|
||||
case OPR_ADD: case OPR_SUB: case OPR_MUL: case OPR_DIV:
|
||||
case OPR_MOD: case OPR_POW: {
|
||||
codearith(fs, op - OPR_ADD + OP_ADD, e1, e2);
|
||||
break;
|
||||
}
|
||||
case OPR_EQ: case OPR_LT: case OPR_LE: {
|
||||
codecomp(fs, op - OPR_EQ + OP_EQ, 1, e1, e2);
|
||||
break;
|
||||
}
|
||||
case OPR_NE: case OPR_GT: case OPR_GE: {
|
||||
codecomp(fs, op - OPR_NE + OP_EQ, 0, e1, e2);
|
||||
break;
|
||||
}
|
||||
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 {
|
||||
OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
|
||||
OPR_CONCAT,
|
||||
OPR_NE, OPR_EQ,
|
||||
OPR_LT, OPR_LE, OPR_GT, OPR_GE,
|
||||
OPR_EQ, OPR_LT, OPR_LE,
|
||||
OPR_NE, OPR_GT, OPR_GE,
|
||||
OPR_AND, OPR_OR,
|
||||
OPR_BAND, OPR_BOR, OPR_BXOR,
|
||||
OPR_BSHL, OPR_BSHR,
|
||||
|
||||
+28
-5
@@ -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) {
|
||||
TMS tm = 0;
|
||||
Instruction i;
|
||||
if ((isLua(ci) && ci->tailcalls > 0) || !isLua(ci - 1))
|
||||
return NULL; /* calling function is not Lua (or is unknown) */
|
||||
ci--; /* calling function */
|
||||
i = ci_func(ci)->l.p->code[currentpc(L, ci)];
|
||||
if (GET_OPCODE(i) == OP_CALL || GET_OPCODE(i) == OP_TAILCALL ||
|
||||
GET_OPCODE(i) == OP_TFORLOOP)
|
||||
return getobjname(L, ci, GETARG_A(i), name);
|
||||
else
|
||||
return NULL; /* no useful name can be found */
|
||||
switch (GET_OPCODE(i)) {
|
||||
case OP_CALL:
|
||||
case OP_TAILCALL:
|
||||
case OP_TFORLOOP:
|
||||
return getobjname(L, ci, GETARG_A(i), name);
|
||||
case OP_GETGLOBAL:
|
||||
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) {
|
||||
if (l_likely(n <= L->stacksize)) /* double size is enough? */
|
||||
if (n <= L->stacksize) /* double size is enough? */
|
||||
luaD_reallocstack(L, 2*L->stacksize);
|
||||
else
|
||||
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;
|
||||
lua_assert(ci->top <= L->stack_last);
|
||||
ci->nresults = nresults;
|
||||
if (L->hookmask & LUA_MASKCALL)
|
||||
if (l_unlikely(L->hookmask & LUA_MASKCALL))
|
||||
luaD_callhook(L, LUA_HOOKCALL, -1);
|
||||
lua_unlock(L);
|
||||
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) {
|
||||
size_t rlen; /* how much to read */
|
||||
size_t nr; /* number of chars actually read */
|
||||
size_t tbr = n; /* number of chars to be 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_buffinit(L, &b);
|
||||
rlen = LUAL_BUFFERSIZE; /* try to read that much each time */
|
||||
do {
|
||||
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);
|
||||
luaL_addsize(&b, nr);
|
||||
n -= nr; /* still have to read `n' chars */
|
||||
} while (n > 0 && nr == rlen); /* until end of count or eof */
|
||||
tbr -= nr; /* still have to read 'tbr' chars */
|
||||
} while (tbr > 0 && nr == rlen); /* until end of count or eof */
|
||||
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) {
|
||||
FILE *f = *(FILE **)lua_touserdata(L, lua_upvalueindex(1));
|
||||
int sucess;
|
||||
int success;
|
||||
if (f == NULL) /* file is already closed? */
|
||||
luaL_error(L, "file is already closed");
|
||||
sucess = read_line(L, f);
|
||||
success = read_line(L, f);
|
||||
if (ferror(f))
|
||||
return luaL_error(L, "%s", strerror(errno));
|
||||
if (sucess) return 1;
|
||||
if (success) return 1;
|
||||
else { /* EOF */
|
||||
if (lua_toboolean(L, lua_upvalueindex(2))) { /* generator created file? */
|
||||
lua_settop(L, 0);
|
||||
|
||||
@@ -232,6 +232,8 @@ OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */
|
||||
(*) In OP_SETLIST, if (B == 0) then B = `top';
|
||||
if (C == 0) then next `instruction' is real C
|
||||
|
||||
(*) In OP_SELF, the index must be a string.
|
||||
|
||||
(*) For comparisons, A specifies what condition the test should accept
|
||||
(true or false).
|
||||
|
||||
|
||||
+4
-4
@@ -881,10 +881,10 @@ static const struct {
|
||||
lu_byte right; /* right priority */
|
||||
} priority[] = { /* ORDER OPR */
|
||||
{6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */
|
||||
{10, 9}, {5, 4}, /* power and concat (right associative) */
|
||||
{3, 3}, {3, 3}, /* equality and inequality */
|
||||
{3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */
|
||||
{2, 2}, {1, 1} /* logical (and/or) */
|
||||
{10, 9}, {5, 4}, /* ^, .. (right associative) */
|
||||
{3, 3}, {3, 3}, {3, 3}, /* ==, <, <= */
|
||||
{3, 3}, {3, 3}, {3, 3}, /* ~=, >, >= */
|
||||
{2, 2}, {1, 1} /* and, or */
|
||||
,{6, 6}, {6, 6}, {6, 6}, /* bit-wise (band/bor/bxor) */
|
||||
{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) {
|
||||
TString *ts;
|
||||
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);
|
||||
ts = cast(TString *, luaM_malloc(L, (l+1)*sizeof(char)+sizeof(TString)));
|
||||
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) {
|
||||
GCObject *o;
|
||||
// string hash taken from luaJIT
|
||||
|
||||
/* 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 */
|
||||
size_t step = (l>>5)+1; /* if string is too long, don't hash all its chars */
|
||||
size_t l1;
|
||||
for (l1=l; l1>=step; l1-=step) /* compute hash */
|
||||
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)];
|
||||
o != NULL;
|
||||
o = o->gch.next) {
|
||||
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 */
|
||||
if (isdead(G(L), o)) changewhite(o);
|
||||
return ts;
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
|
||||
}
|
||||
|
||||
|
||||
TValue *luaT_gettmbyobj (lua_State *L, TValue *o, TMS event) {
|
||||
TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
|
||||
Table *mt;
|
||||
switch (ttype(o)) {
|
||||
case LUA_TTABLE:
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ LUAI_DATA const char *const luaT_typenames[];
|
||||
|
||||
|
||||
LUAI_FUNC TValue *luaT_gettm (Table *events, TMS event, TString *ename);
|
||||
LUAI_FUNC TValue *luaT_gettmbyobj (lua_State *L, TValue *o, TMS event);
|
||||
LUAI_FUNC TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event);
|
||||
LUAI_FUNC void luaT_init (lua_State *L);
|
||||
|
||||
#endif
|
||||
+145
-54
@@ -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
|
||||
|
||||
|
||||
@@ -105,61 +105,94 @@ static void callTM (lua_State *L, const TValue *f, const TValue *p1,
|
||||
}
|
||||
|
||||
|
||||
void luaV_gettable (lua_State *L, TValue *t, TValue *key, StkId val) {
|
||||
int loop;
|
||||
/*
|
||||
** Finish the table access 'val = t[key]'.
|
||||
** if 'slot' is NULL, 't' is not a table; otherwise, 'slot' points to
|
||||
** t[k] entry (which must be nil).
|
||||
*/
|
||||
void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val,
|
||||
const TValue *slot) {
|
||||
int loop; /* counter to avoid infinite loops */
|
||||
const TValue *tm; /* metamethod */
|
||||
for (loop = 0; loop < MAXTAGLOOP; loop++) {
|
||||
TValue *tm;
|
||||
if (ttistable(t)) { /* `t' is a table? */
|
||||
Table *h = hvalue(t);
|
||||
const TValue *res = luaH_get(h, key); /* do a primitive get */
|
||||
if (!ttisnil(res) || /* result is no nil? */
|
||||
(tm = fasttm(L, h->metatable, TM_INDEX)) == NULL) { /* or no TM? */
|
||||
setobj2s(L, val, res);
|
||||
if (slot == NULL) { /* 't' is not a table? */
|
||||
lua_assert(!ttistable(t));
|
||||
tm = luaT_gettmbyobj(L, t, TM_INDEX);
|
||||
if (l_unlikely(ttisnil(tm)))
|
||||
luaG_typeerror(L, t, "index"); /* no metamethod */
|
||||
/* else will try the metamethod */
|
||||
}
|
||||
else { /* 't' is a table */
|
||||
lua_assert(ttisnil(slot));
|
||||
tm = fasttm(L, hvalue(t)->metatable, TM_INDEX); /* table's metamethod */
|
||||
if (tm == NULL) { /* no metamethod? */
|
||||
setnilvalue(val); /* result is nil */
|
||||
return;
|
||||
}
|
||||
/* else will try the tag method */
|
||||
/* else will try the metamethod */
|
||||
}
|
||||
else if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX))))
|
||||
luaG_typeerror(L, t, "index");
|
||||
if (ttisfunction(tm)) {
|
||||
callTMres(L, val, tm, t, key);
|
||||
if (ttisfunction(tm)) { /* is metamethod a function? */
|
||||
callTMres(L, val, tm, t, key); /* call it */
|
||||
return;
|
||||
}
|
||||
t = tm; /* else repeat with `tm' */
|
||||
t = tm; /* else try to access 'tm[key]' */
|
||||
if (luaV_fastget(L,t,key,slot,luaH_get)) { /* fast track? */
|
||||
setobj2s(L, val, slot); /* done */
|
||||
return;
|
||||
}
|
||||
/* else repeat (tail call 'luaV_finishget') */
|
||||
}
|
||||
luaG_runerror(L, "loop in gettable");
|
||||
luaG_runerror(L, "'__index' chain too long; possible loop");
|
||||
}
|
||||
|
||||
|
||||
void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) {
|
||||
int loop;
|
||||
/*
|
||||
** Finish a table assignment 't[key] = val'.
|
||||
** If 'slot' is NULL, 't' is not a table. Otherwise, 'slot' points
|
||||
** to the entry 't[key]', or to 'luaO_nilobject' if there is no such
|
||||
** entry. (The value at 'slot' must be nil, otherwise 'luaV_fastset'
|
||||
** would have done the job.)
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||
void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
|
||||
StkId val, const TValue *slot) {
|
||||
int loop; /* counter to avoid infinite loops */
|
||||
for (loop = 0; loop < MAXTAGLOOP; loop++) {
|
||||
TValue *tm = NULL;
|
||||
if (ttistable(t)) { /* `t' is a table? */
|
||||
const TValue *tm;
|
||||
if (slot != NULL) {
|
||||
lua_assert(ttistable(t) && ttisnil(slot));
|
||||
Table *h = hvalue(t);
|
||||
TValue *oldval = luaH_set(L, h, key); /* do a primitive set */
|
||||
/* oldval is nil=> look for newindex, oldval is not nil => look for usedindex */
|
||||
if (!((ttisnil(oldval) && ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) != NULL)) ||
|
||||
((!ttisnil(oldval)) && ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) != NULL)))) {
|
||||
setobj2t(L, oldval, val);
|
||||
/* must check the metamethod */
|
||||
/* slot is nil=> look for newindex, slot is not nil => look for usedindex */
|
||||
if (!((ttisnil(slot) && ((tm = fasttm(L, h->metatable, TM_NEWINDEX)) != NULL)) ||
|
||||
((!ttisnil(slot)) && ((tm = fasttm(L, h->metatable, TM_USEDINDEX)) != NULL)))) {
|
||||
/* no metamethod and (now) there is an entry with given key */
|
||||
setobj2t(L, cast(TValue *, slot), val);
|
||||
luaC_barriert(L, h, val);
|
||||
return;
|
||||
}
|
||||
/* else will try the tag method */
|
||||
/* else will try the metamethod */
|
||||
}
|
||||
else if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))))
|
||||
luaG_typeerror(L, t, "index");
|
||||
else { /* not a table; check metamethod */
|
||||
if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))))
|
||||
luaG_typeerror(L, t, "index");
|
||||
}
|
||||
/* try the metamethod */
|
||||
if (ttisfunction(tm)) {
|
||||
callTM(L, tm, t, key, val);
|
||||
return;
|
||||
}
|
||||
t = tm; /* else repeat with `tm' */
|
||||
t = tm; /* else repeat assignment over 'tm' */
|
||||
if (luaV_fastset(L, t, key, slot, luaH_set, val))
|
||||
return; /* done */
|
||||
/* else loop */
|
||||
}
|
||||
luaG_runerror(L, "loop in settable");
|
||||
luaG_runerror(L, "settable chain too long; possible loop");
|
||||
}
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
|
||||
static int call_binTM (lua_State *L, TValue *p1, TValue *p2,
|
||||
static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
|
||||
StkId res, TMS event) {
|
||||
const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */
|
||||
if (ttisnil(tm))
|
||||
@@ -184,7 +217,7 @@ static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2,
|
||||
}
|
||||
|
||||
|
||||
static int call_orderTM (lua_State *L, TValue *p1, TValue *p2,
|
||||
static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
|
||||
TMS event) {
|
||||
const TValue *tm1 = luaT_gettmbyobj(L, p1, event);
|
||||
const TValue *tm2;
|
||||
@@ -366,6 +399,7 @@ static void Arith (lua_State *L, StkId ra, TValue *rb,
|
||||
|
||||
|
||||
#define arith_op(op,tm) { \
|
||||
StkId ra = RA(i); \
|
||||
TValue *rb = RKB(i); \
|
||||
TValue *rc = RKC(i); \
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) { \
|
||||
@@ -377,6 +411,24 @@ static void Arith (lua_State *L, StkId ra, TValue *rb,
|
||||
}
|
||||
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcast-qual"
|
||||
|
||||
/*
|
||||
** copy of 'luaV_gettable', but protecting call to potential metamethod
|
||||
** (which can reallocate the stack)
|
||||
*/
|
||||
#define gettableProtected(L,t,k,v) { const TValue *slot; \
|
||||
if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \
|
||||
else Protect(luaV_finishget(L,t,k,v,slot)); }
|
||||
|
||||
|
||||
/* same for 'luaV_settable' */
|
||||
#define settableProtected(L,t,k,v) { const TValue *slot; \
|
||||
if (!luaV_fastset(L,t,k,slot,luaH_set,v)) \
|
||||
Protect(luaV_finishset(L,t,k,v,slot)); }
|
||||
|
||||
|
||||
|
||||
void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
LClosure *cl;
|
||||
@@ -386,13 +438,12 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
reentry: /* entry point */
|
||||
lua_assert(isLua(L->ci));
|
||||
pc = L->savedpc;
|
||||
cl = &clvalue(L->ci->func)->l;
|
||||
base = L->base;
|
||||
k = cl->p->k;
|
||||
cl = &clvalue(L->ci->func)->l; /* local reference to function's closure */
|
||||
k = cl->p->k; /* local reference to function's constant table */
|
||||
base = L->base; /* local copy of function's base */
|
||||
/* main loop of interpreter */
|
||||
for (;;) {
|
||||
const Instruction i = *pc++;
|
||||
StkId ra;
|
||||
if ((L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT)) &&
|
||||
(--L->hookcount == 0 || L->hookmask & LUA_MASKLINE)) {
|
||||
traceexec(L, pc);
|
||||
@@ -402,26 +453,28 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
}
|
||||
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->top && L->top <= L->stack + L->stacksize);
|
||||
lua_assert(L->top == L->ci->top || luaG_checkopenop(i));
|
||||
switch (GET_OPCODE(i)) {
|
||||
case OP_MOVE: {
|
||||
StkId ra = RA(i);
|
||||
setobjs2s(L, ra, RB(i));
|
||||
continue;
|
||||
}
|
||||
case OP_LOADK: {
|
||||
StkId ra = RA(i);
|
||||
setobj2s(L, ra, KBx(i));
|
||||
continue;
|
||||
}
|
||||
case OP_LOADBOOL: {
|
||||
StkId ra = RA(i);
|
||||
setbvalue(ra, GETARG_B(i));
|
||||
if (GETARG_C(i)) pc++; /* skip next instruction (if C) */
|
||||
continue;
|
||||
}
|
||||
case OP_LOADNIL: {
|
||||
StkId ra = RA(i);
|
||||
TValue *rb = RB(i);
|
||||
do {
|
||||
setnilvalue(rb--);
|
||||
@@ -429,11 +482,13 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_GETUPVAL: {
|
||||
StkId ra = RA(i);
|
||||
int b = GETARG_B(i);
|
||||
setobj2s(L, ra, cl->upvals[b]->v);
|
||||
continue;
|
||||
}
|
||||
case OP_GETGLOBAL: {
|
||||
StkId ra = RA(i);
|
||||
TValue g;
|
||||
TValue *rb = KBx(i);
|
||||
sethvalue(L, &g, cl->env);
|
||||
@@ -442,10 +497,14 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_GETTABLE: {
|
||||
Protect(luaV_gettable(L, RB(i), RKC(i), ra));
|
||||
StkId ra = RA(i);
|
||||
StkId rb = RB(i);
|
||||
TValue *rc = RKC(i);
|
||||
gettableProtected(L, rb, rc, ra);
|
||||
continue;
|
||||
}
|
||||
case OP_SETGLOBAL: {
|
||||
StkId ra = RA(i);
|
||||
TValue g;
|
||||
sethvalue(L, &g, cl->env);
|
||||
lua_assert(ttisstring(KBx(i)));
|
||||
@@ -453,16 +512,21 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_SETUPVAL: {
|
||||
StkId ra = RA(i);
|
||||
UpVal *uv = cl->upvals[GETARG_B(i)];
|
||||
setobj(L, uv->v, ra);
|
||||
luaC_barrier(L, uv, ra);
|
||||
continue;
|
||||
}
|
||||
case OP_SETTABLE: {
|
||||
Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
|
||||
StkId ra = RA(i);
|
||||
TValue *rb = RKB(i);
|
||||
TValue *rc = RKC(i);
|
||||
settableProtected(L, ra, rb, rc);
|
||||
continue;
|
||||
}
|
||||
case OP_NEWTABLE: {
|
||||
StkId ra = RA(i);
|
||||
int b = GETARG_B(i);
|
||||
int c = GETARG_C(i);
|
||||
sethvalue(L, ra, luaH_new(L, luaO_fb2int(b), luaO_fb2int(c)));
|
||||
@@ -470,9 +534,16 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_SELF: {
|
||||
StkId ra = RA(i);
|
||||
const TValue *slot;
|
||||
StkId rb = RB(i);
|
||||
setobjs2s(L, ra+1, rb);
|
||||
Protect(luaV_gettable(L, rb, RKC(i), ra));
|
||||
TValue *rc = RKC(i);
|
||||
TString *key = rawtsvalue(rc); /* key must be a string */
|
||||
setobjs2s(L, ra + 1, rb);
|
||||
if (luaV_fastget(L, rb, key, slot, luaH_getstr)) {
|
||||
setobj2s(L, ra, slot);
|
||||
}
|
||||
else Protect(luaV_finishget(L, rb, rc, ra, slot));
|
||||
continue;
|
||||
}
|
||||
case OP_ADD: {
|
||||
@@ -488,6 +559,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_DIV: {
|
||||
StkId ra = RA(i);
|
||||
TValue *rb = RKB(i);
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
@@ -503,6 +575,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_MOD: {
|
||||
StkId ra = RA(i);
|
||||
TValue *rb = RKB(i);
|
||||
TValue *rc = RKC(i);
|
||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
||||
@@ -522,26 +595,27 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_BAND: {
|
||||
arith_op(luai_numand, TM_AND);
|
||||
continue;
|
||||
arith_op(luai_numand, TM_AND);
|
||||
continue;
|
||||
}
|
||||
case OP_BOR: {
|
||||
arith_op(luai_numor, TM_OR);
|
||||
continue;
|
||||
arith_op(luai_numor, TM_OR);
|
||||
continue;
|
||||
}
|
||||
case OP_BXOR: {
|
||||
arith_op(luai_numxor, TM_XOR);
|
||||
continue;
|
||||
arith_op(luai_numxor, TM_XOR);
|
||||
continue;
|
||||
}
|
||||
case OP_BSHL: {
|
||||
arith_op(luai_numshl, TM_SHL);
|
||||
continue;
|
||||
arith_op(luai_numshl, TM_SHL);
|
||||
continue;
|
||||
}
|
||||
case OP_BSHR: {
|
||||
arith_op(luai_numshr, TM_SHR);
|
||||
continue;
|
||||
arith_op(luai_numshr, TM_SHR);
|
||||
continue;
|
||||
}
|
||||
case OP_BNOT: {
|
||||
StkId ra = RA(i);
|
||||
TValue *rb = RB(i);
|
||||
if (ttisnumber(rb)) {
|
||||
lua_Number nb = nvalue(rb);
|
||||
@@ -553,6 +627,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_UNM: {
|
||||
StkId ra = RA(i);
|
||||
TValue *rb = RB(i);
|
||||
if (ttisnumber(rb)) {
|
||||
lua_Number nb = nvalue(rb);
|
||||
@@ -564,11 +639,13 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_NOT: {
|
||||
StkId ra = RA(i);
|
||||
int res = l_isfalse(RB(i)); /* next assignment may change this value */
|
||||
setbvalue(ra, res);
|
||||
continue;
|
||||
}
|
||||
case OP_LEN: {
|
||||
StkId ra = RA(i);
|
||||
TValue *rb = RB(i);
|
||||
switch (ttype(rb)) {
|
||||
case LUA_TTABLE: {
|
||||
@@ -626,12 +703,14 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_TEST: {
|
||||
StkId ra = RA(i);
|
||||
if (l_isfalse(ra) != GETARG_C(i))
|
||||
dojump(L, pc, GETARG_sBx(*pc));
|
||||
pc++;
|
||||
continue;
|
||||
}
|
||||
case OP_TESTSET: {
|
||||
StkId ra = RA(i);
|
||||
TValue *rb = RB(i);
|
||||
if (l_isfalse(rb) != GETARG_C(i)) {
|
||||
setobjs2s(L, ra, rb);
|
||||
@@ -641,6 +720,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_CALL: {
|
||||
StkId ra = RA(i);
|
||||
int b = GETARG_B(i);
|
||||
int nresults = GETARG_C(i) - 1;
|
||||
if (b != 0) L->top = ra+b; /* else previous instruction set top */
|
||||
@@ -662,6 +742,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
}
|
||||
}
|
||||
case OP_TAILCALL: {
|
||||
StkId ra = RA(i);
|
||||
int b = GETARG_B(i);
|
||||
if (b != 0) L->top = ra+b; /* else previous instruction set top */
|
||||
L->savedpc = pc;
|
||||
@@ -694,6 +775,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
}
|
||||
}
|
||||
case OP_RETURN: {
|
||||
StkId ra = RA(i);
|
||||
int b = GETARG_B(i);
|
||||
if (b != 0) L->top = ra+b-1;
|
||||
if (L->openupval) luaF_close(L, base);
|
||||
@@ -709,6 +791,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
}
|
||||
}
|
||||
case OP_FORLOOP: {
|
||||
StkId ra = RA(i);
|
||||
lua_Number step = nvalue(ra+2);
|
||||
lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */
|
||||
lua_Number limit = nvalue(ra+1);
|
||||
@@ -721,6 +804,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_FORPREP: {
|
||||
StkId ra = RA(i);
|
||||
const TValue *init = ra;
|
||||
const TValue *plimit = ra+1;
|
||||
const TValue *pstep = ra+2;
|
||||
@@ -737,6 +821,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_TFORLOOP: {
|
||||
StkId ra = RA(i);
|
||||
StkId cb = ra + 3; /* call base */
|
||||
setobjs2s(L, cb+2, ra+2);
|
||||
setobjs2s(L, cb+1, ra+1);
|
||||
@@ -753,6 +838,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_SETLIST: {
|
||||
StkId ra = RA(i);
|
||||
int n = GETARG_B(i);
|
||||
int c = GETARG_C(i);
|
||||
int last;
|
||||
@@ -775,10 +861,12 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_CLOSE: {
|
||||
StkId ra = RA(i);
|
||||
luaF_close(L, ra);
|
||||
continue;
|
||||
}
|
||||
case OP_CLOSURE: {
|
||||
StkId ra = RA(i);
|
||||
Proto *p;
|
||||
Closure *ncl;
|
||||
int nup, j;
|
||||
@@ -799,6 +887,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
continue;
|
||||
}
|
||||
case OP_VARARG: {
|
||||
StkId ra = RA(i);
|
||||
int b = GETARG_B(i) - 1;
|
||||
int j;
|
||||
CallInfo *ci = L->ci;
|
||||
@@ -822,3 +911,5 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
+51
-4
@@ -22,14 +22,61 @@
|
||||
(ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2))
|
||||
|
||||
|
||||
/*
|
||||
** fast track for 'gettable': if 't' is a table and 't[k]' is not nil,
|
||||
** return 1 with 'slot' pointing to 't[k]' (final result). Otherwise,
|
||||
** return 0 (meaning it will have to check metamethod) with 'slot'
|
||||
** pointing to a nil 't[k]' (if 't' is a table) or NULL (otherwise).
|
||||
** 'f' is the raw get function to use.
|
||||
*/
|
||||
#define luaV_fastget(L,t,k,slot,f) \
|
||||
(!ttistable(t) \
|
||||
? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \
|
||||
: (slot = f(hvalue(t), k), /* else, do raw access */ \
|
||||
!ttisnil(slot))) /* result not nil? */
|
||||
|
||||
/*
|
||||
** standard implementation for 'gettable'
|
||||
*/
|
||||
#define luaV_gettable(L,t,k,v) { const TValue *slot; \
|
||||
if (luaV_fastget(L,t,k,slot,luaH_get)) { setobj2s(L, v, slot); } \
|
||||
else luaV_finishget(L,t,k,v,slot); }
|
||||
|
||||
|
||||
/*
|
||||
** Fast track for set table. If 't' is a table and 't[k]' is not nil,
|
||||
** call GC barrier, do a raw 't[k]=v', and return true; otherwise,
|
||||
** return false with 'slot' equal to NULL (if 't' is not a table) or
|
||||
** 'nil'. (This is needed by 'luaV_finishget'.) Note that, if the macro
|
||||
** returns true, there is no need to 'invalidateTMcache', because the
|
||||
** call is not creating a new entry.
|
||||
*/
|
||||
#define luaV_fastset(L,t,k,slot,f,v) \
|
||||
(!ttistable(t) \
|
||||
? (slot = NULL, 0) \
|
||||
: (slot = f(L, hvalue(t), k), \
|
||||
ttisnil(slot) ? 0 \
|
||||
: (__extension__ ({ \
|
||||
if (valiswhite(v) && isblack(obj2gco(hvalue(t)))) \
|
||||
luaC_barrierback(L, hvalue(t)); \
|
||||
setobj2t(L, cast(TValue *,slot), v); \
|
||||
1; \
|
||||
}))))
|
||||
|
||||
#define luaV_settable(L,t,k,v) { const TValue *slot; \
|
||||
if (!luaV_fastset(L,t,k,slot,luaH_set,v)) \
|
||||
luaV_finishset(L,t,k,v,slot); }
|
||||
|
||||
|
||||
|
||||
LUAI_FUNC int luaV_lessthan (lua_State *L, TValue *l, TValue *r);
|
||||
LUAI_FUNC int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2);
|
||||
LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n);
|
||||
LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj);
|
||||
LUAI_FUNC void luaV_gettable (lua_State *L, TValue *t, TValue *key,
|
||||
StkId val);
|
||||
LUAI_FUNC void luaV_settable (lua_State *L, TValue *t, TValue *key,
|
||||
StkId val);
|
||||
LUAI_FUNC void luaV_finishget (lua_State *L, const TValue *t, TValue *key,
|
||||
StkId val, const TValue *tm);
|
||||
LUAI_FUNC void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
|
||||
StkId val, const TValue *oldval);
|
||||
LUAI_FUNC void luaV_execute (lua_State *L, int nexeccalls);
|
||||
LUAI_FUNC void luaV_concat (lua_State *L, int total, int last);
|
||||
|
||||
|
||||
+1
-1
@@ -1793,7 +1793,7 @@ void CV_AddValue(consvar_t *var, INT32 increment)
|
||||
if (newvalue == oldvalue)
|
||||
break; // don't loop forever if there's none of a certain gametype
|
||||
|
||||
if (newvalue >= 0 && !mapheaderinfo[newvalue])
|
||||
if (newvalue >= 0 && newvalue < NUMMAPS && !mapheaderinfo[newvalue])
|
||||
continue; // Don't allocate the header. That just makes memory usage skyrocket.
|
||||
|
||||
} while (!M_CanShowLevelInList(newvalue, gt));
|
||||
|
||||
+22
-33
@@ -274,21 +274,17 @@ static void D_Renderview(void)
|
||||
|
||||
R_ApplyLevelInterpolators(R_GetTimeFrac(RTF_LEVEL));
|
||||
|
||||
if (rendermode == render_soft)
|
||||
if (rendermode == render_soft && cv_homremoval.value)
|
||||
{
|
||||
// if this is display player 1
|
||||
if (cv_homremoval.value)
|
||||
if (cv_homremoval.value == 1)
|
||||
{
|
||||
if (cv_homremoval.value == 1)
|
||||
{
|
||||
// Clear the software screen buffer to remove HOM
|
||||
memset(vid.screens[0], 31, vid.width * vid.height);
|
||||
}
|
||||
else if (cv_homremoval.value == 2)
|
||||
{
|
||||
//'development' HOM removal -- makes it blindingly obvious if HOM is spotted.
|
||||
memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height);
|
||||
}
|
||||
// Clear the software screen buffer to remove HOM
|
||||
memset(vid.screens[0], 31, vid.width * vid.height);
|
||||
}
|
||||
else if (cv_homremoval.value == 2)
|
||||
{
|
||||
//'development' HOM removal -- makes it blindingly obvious if HOM is spotted.
|
||||
memset(vid.screens[0], 32+(timeinmap&15), vid.width * vid.height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,7 +318,6 @@ static void D_Renderview(void)
|
||||
break;
|
||||
default: // Initialize for P1
|
||||
viewwindowy = viewwindowx = 0;
|
||||
objectsdrawn = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -333,19 +328,17 @@ static void D_Renderview(void)
|
||||
}
|
||||
else if (rendermode == render_soft)
|
||||
#endif
|
||||
{
|
||||
R_RenderPlayerView(&players[displayplayers[i]]);
|
||||
}
|
||||
|
||||
if (rendermode == render_soft)
|
||||
{
|
||||
if (i == 0)
|
||||
R_ApplyViewMorph();
|
||||
|
||||
if (i == 0)
|
||||
R_ApplyViewMorph();
|
||||
#ifdef MOTIONBLUR
|
||||
V_DoPostProcessor(i, postimgparam[i]);
|
||||
V_DoPostProcessor(i, postimgparam[i]);
|
||||
#else
|
||||
V_DoPostProcessor(i, 0);
|
||||
V_DoPostProcessor(i, 0);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -783,11 +776,6 @@ void D_SRB2Loop(void)
|
||||
|
||||
doDisplay = true;
|
||||
}
|
||||
|
||||
if (!dedicated)
|
||||
{
|
||||
G_DeviceLEDTick();
|
||||
}
|
||||
}
|
||||
|
||||
if (interp)
|
||||
@@ -829,6 +817,13 @@ void D_SRB2Loop(void)
|
||||
if (takescreenshot)
|
||||
M_DoScreenShot();
|
||||
|
||||
#ifndef DEDICATED
|
||||
if (!dedicated && renderisnewtic)
|
||||
{
|
||||
G_DeviceLEDTick();
|
||||
}
|
||||
#endif
|
||||
|
||||
// consoleplayer -> displayplayers (hear sounds from viewpoint)
|
||||
S_UpdateSounds(); // move positional sounds
|
||||
|
||||
@@ -1643,12 +1638,6 @@ void D_SRB2Main(void)
|
||||
strcpy(srb2, "SRB2Kart");
|
||||
D_MakeTitleString(srb2);
|
||||
|
||||
#if defined (__OS2__) && !defined (HAVE_SDL)
|
||||
// set PM window title
|
||||
snprintf(pmData->title, sizeof (pmData->title), "SRB2Kart" VERSIONSTRING ": %s", title);
|
||||
pmData->title[sizeof (pmData->title) - 1] = '\0';
|
||||
#endif
|
||||
|
||||
if (devparm)
|
||||
CONS_Printf(M_GetText("Development mode ON.\n"));
|
||||
|
||||
|
||||
+1
-3
@@ -1172,9 +1172,7 @@ void F_StartWaitingPlayers(void)
|
||||
randskin = M_RandomKey(numskins);
|
||||
boolean waithires = skins[randskin].flags && SF_HIRES;
|
||||
|
||||
if (waitcolormap)
|
||||
Z_Free(waitcolormap);
|
||||
|
||||
Z_Free(waitcolormap);
|
||||
waitcolormap = R_GetTranslationColormap(randskin, skins[randskin].prefcolor, 0);
|
||||
|
||||
if (waithires)
|
||||
|
||||
+6
-8
@@ -317,8 +317,7 @@ void closefilemenu(boolean validsize)
|
||||
coredirmenu = NULL;
|
||||
}
|
||||
|
||||
if (refreshdirname)
|
||||
Z_Free(refreshdirname);
|
||||
Z_Free(refreshdirname);
|
||||
refreshdirname = NULL;
|
||||
}
|
||||
|
||||
@@ -346,8 +345,7 @@ void searchfilemenu(char *tempname)
|
||||
|
||||
if (!menusearch.length)
|
||||
{
|
||||
if (dirmenu)
|
||||
Z_Free(dirmenu);
|
||||
Z_Free(dirmenu);
|
||||
dirmenu = coredirmenu;
|
||||
sizedirmenu = sizecoredirmenu;
|
||||
|
||||
@@ -389,8 +387,8 @@ void searchfilemenu(char *tempname)
|
||||
I_Error("searchfilemenu(): could not create \"No results...\".");
|
||||
sizedirmenu = 1;
|
||||
dir_on[menudepthleft] = 0;
|
||||
if (tempname)
|
||||
Z_Free(tempname);
|
||||
Z_Free(tempname);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -505,8 +503,8 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut)
|
||||
{
|
||||
closedir(dirhandle);
|
||||
closefilemenu(false);
|
||||
if (tempname)
|
||||
Z_Free(tempname);
|
||||
Z_Free(tempname);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2605,7 +2605,7 @@ void G_DoPlayDemo(char *defdemoname)
|
||||
boolean skiperrors = false;
|
||||
#endif
|
||||
boolean spectator;
|
||||
UINT8 slots[MAXPLAYERS], kartspeed[MAXPLAYERS], kartweight[MAXPLAYERS], numslots = 0;
|
||||
UINT8 slots[MAXPLAYERS] = {}, kartspeed[MAXPLAYERS] = {}, kartweight[MAXPLAYERS] = {}, numslots = 0;
|
||||
|
||||
G_InitDemoRewind();
|
||||
|
||||
|
||||
+2
-5
@@ -523,11 +523,8 @@ void G_ClearRecords(void)
|
||||
INT16 i;
|
||||
for (i = 0; i < NUMMAPS; ++i)
|
||||
{
|
||||
if (mainrecords[i])
|
||||
{
|
||||
Z_Free(mainrecords[i]);
|
||||
mainrecords[i] = NULL;
|
||||
}
|
||||
Z_Free(mainrecords[i]);
|
||||
mainrecords[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1378,8 +1378,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
|
||||
|
||||
FSurfaceInfo Surf;
|
||||
|
||||
if (gl_frontsector)
|
||||
Surf.PolyColor.s.alpha = 255;
|
||||
Surf.PolyColor.s.alpha = 255;
|
||||
|
||||
const INT32 gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture);
|
||||
GLMapTexture_t *glTex = NULL;
|
||||
|
||||
+9
-16
@@ -693,17 +693,15 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi
|
||||
GLPatch_t *hwrBlendPatch = blendgpatch->hardware;
|
||||
UINT16 w = gpatch->width, h = gpatch->height;
|
||||
UINT32 size = w*h;
|
||||
RGBA_t *image, *blendimage, *cur, blendcolor;
|
||||
RGBA_t *image, *blendimage, *cur;
|
||||
RGBA_t blendcolor = {};
|
||||
RGBA_t *palette = HWR_GetTexturePalette();
|
||||
UINT8 translation[17]; // First the color index
|
||||
UINT8 cutoff[17]; // Brightness cutoff before using the next color
|
||||
UINT8 translation[17] = {}; // First the color index
|
||||
UINT8 cutoff[17] = {}; // Brightness cutoff before using the next color
|
||||
UINT8 translen = 0;
|
||||
UINT8 i;
|
||||
UINT8 colorbrightnesses[17];
|
||||
UINT8 color_match_lookup[256]; // optimization attempt
|
||||
|
||||
memset(translation, 0, sizeof(translation));
|
||||
memset(cutoff, 0, sizeof(cutoff));
|
||||
UINT8 colorbrightnesses[17] = {};
|
||||
UINT8 color_match_lookup[256] = {}; // optimization attempt
|
||||
|
||||
if (glMipmap->width == 0)
|
||||
{
|
||||
@@ -716,14 +714,10 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi
|
||||
glMipmap->format = GL_TEXFMT_RGBA;
|
||||
}
|
||||
|
||||
if (glMipmap->data)
|
||||
{
|
||||
Z_Free(glMipmap->data);
|
||||
glMipmap->data = NULL;
|
||||
}
|
||||
Z_Free(glMipmap->data);
|
||||
glMipmap->data = NULL;
|
||||
|
||||
cur = Z_Malloc(size*4, PU_HWRMODELTEXTURE, &glMipmap->data);
|
||||
memset(cur, 0x00, size*4);
|
||||
cur = Z_Calloc(size*4, PU_HWRMODELTEXTURE, &glMipmap->data);
|
||||
|
||||
image = hwrPatch->mipmap->data;
|
||||
blendimage = hwrBlendPatch->mipmap->data;
|
||||
@@ -1037,7 +1031,6 @@ static void HWR_GetBlendedTexture(patch_t *patch, patch_t *blendgpatch, INT32 sk
|
||||
GLPatch_t *glPatch = patch->hardware;
|
||||
GLMipmap_t *glMipmap, *newMipmap;
|
||||
|
||||
|
||||
if (blendgpatch == NULL || colormap == colormaps || colormap == NULL)
|
||||
{
|
||||
// Don't do any blending
|
||||
|
||||
+2
-1
@@ -225,9 +225,10 @@ HMS_connect (const char *format, ...)
|
||||
{
|
||||
cc = curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
|
||||
|
||||
#ifdef LOGMESSAGES
|
||||
cc = curl_easy_setopt(curl, CURLOPT_STDERR, logstream);
|
||||
if (cc != CURLE_OK) I_OutputMsg("libcurl: %s\n", buffer->errbuf);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (M_CheckParm("-bindaddr") && M_IsNextParm())
|
||||
|
||||
+7
-8
@@ -497,7 +497,9 @@ static void HU_removeChatText_Log(void)
|
||||
{
|
||||
chat_log[i] = chat_log[i+1];
|
||||
}
|
||||
|
||||
chat_nummsg_log--; // lost 1 msg.
|
||||
chat_log[chat_nummsg_log] = NULL;
|
||||
}
|
||||
|
||||
static void Chatlogsize_OnChange(void)
|
||||
@@ -516,6 +518,7 @@ static void Chatlogsize_OnChange(void)
|
||||
if (new_chat_log == NULL)
|
||||
{
|
||||
free(chat_log);
|
||||
chat_log = NULL;
|
||||
return;
|
||||
}
|
||||
chat_log = new_chat_log;
|
||||
@@ -1072,8 +1075,7 @@ static void Got_Saycmd(const UINT8 **p, INT32 playernum)
|
||||
|
||||
HU_AddChatText(va(fmt2, prefix, cstart, dispname, textcolor, msg), cv_chatnotifications.value); // add to chat
|
||||
|
||||
if (tempchar)
|
||||
Z_Free(tempchar);
|
||||
Z_Free(tempchar);
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
// I just want to point out while I'm here that because the data is still
|
||||
@@ -1569,8 +1571,7 @@ static void HU_drawMiniChat(void)
|
||||
dy = 0;
|
||||
dx = 0;
|
||||
msglines += linescount+1;
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
y = chaty - charheight*(msglines+1);
|
||||
@@ -1657,8 +1658,7 @@ static void HU_drawMiniChat(void)
|
||||
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
// decrement addy and make that shit smooth:
|
||||
@@ -1767,8 +1767,7 @@ static void HU_drawChatLog(INT32 offset)
|
||||
|
||||
dy += charheight;
|
||||
dx = 0;
|
||||
if (msg)
|
||||
Z_Free(msg);
|
||||
Z_Free(msg);
|
||||
}
|
||||
|
||||
if (((chat_scroll >= chat_maxscroll) || (chat_scrollmedown)) && !(justscrolleddown || justscrolledup || chat_scrolltime)) // was already at the bottom of the page before new maxscroll calculation and was NOT scrolling.
|
||||
|
||||
+4
-10
@@ -1510,11 +1510,8 @@ static boolean SOCK_SetBanUsername(const char *username)
|
||||
username = "Direct IP ban";
|
||||
}
|
||||
|
||||
if (banned[numbans - 1].username)
|
||||
{
|
||||
Z_Free(banned[numbans - 1].username);
|
||||
banned[numbans - 1].username = NULL;
|
||||
}
|
||||
Z_Free(banned[numbans - 1].username);
|
||||
banned[numbans - 1].username = NULL;
|
||||
|
||||
banned[numbans - 1].username = Z_StrDup(username);
|
||||
|
||||
@@ -1528,11 +1525,8 @@ static boolean SOCK_SetBanReason(const char *reason)
|
||||
reason = "No reason given";
|
||||
}
|
||||
|
||||
if (banned[numbans - 1].reason)
|
||||
{
|
||||
Z_Free(banned[numbans - 1].reason);
|
||||
banned[numbans - 1].reason = NULL;
|
||||
}
|
||||
Z_Free(banned[numbans - 1].reason);
|
||||
banned[numbans - 1].reason = NULL;
|
||||
|
||||
banned[numbans - 1].reason = Z_StrDup(reason);
|
||||
|
||||
|
||||
@@ -1415,8 +1415,6 @@ static void K_drawKartStats(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
spdoffset = 0;
|
||||
|
||||
if (G_BattleGametype() && ((speedostyle != SPEEDO_DIAL) || splitscreen))
|
||||
spdoffset += ((stplyr->kartstuff[k_bumper] ? -5 : -8));
|
||||
|
||||
@@ -1480,7 +1480,6 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid)
|
||||
fixed_t nx = FixedDiv(distx, dist);
|
||||
fixed_t ny = FixedDiv(disty, dist);
|
||||
|
||||
dist = dist ? dist : 1;
|
||||
distx = FixedMul(mobj1->radius+mobj2->radius, nx);
|
||||
disty = FixedMul(mobj1->radius+mobj2->radius, ny);
|
||||
|
||||
|
||||
+1
-2
@@ -99,8 +99,7 @@ void K_EraseStats(void)
|
||||
// The only field we want to remember
|
||||
boolean vanilla = kartstats.vanilla;
|
||||
|
||||
if (kartstats.copy)
|
||||
Z_Free(kartstats.copy);
|
||||
Z_Free(kartstats.copy);
|
||||
|
||||
memset(&kartstats, 0, sizeof(kartstats_t));
|
||||
|
||||
|
||||
+22
-22
@@ -615,7 +615,7 @@ FUNCINLINE static ATTRINLINE void res_hud(Hook_State *hook)
|
||||
|
||||
int LUA_HookMobj(mobj_t *mobj, int hook_type)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_mobj_hook(&hook, false, hook_type, mobj))
|
||||
{
|
||||
LUA_PushUserdata(gL, mobj, META_MOBJ);
|
||||
@@ -626,7 +626,7 @@ int LUA_HookMobj(mobj_t *mobj, int hook_type)
|
||||
|
||||
int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_mobj_hook(&hook, 0, hook_type, t1))
|
||||
{
|
||||
LUA_PushUserdata(gL, t1, META_MOBJ);
|
||||
@@ -638,14 +638,14 @@ int LUA_Hook2Mobj(mobj_t *t1, mobj_t *t2, int hook_type)
|
||||
|
||||
void LUA_HookVoid(int type)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_hook(&hook, 0, type))
|
||||
call_hooks(&hook, 0, res_none);
|
||||
}
|
||||
|
||||
void LUA_HookInt(INT32 number, int hook_type)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_hook(&hook, 0, hook_type))
|
||||
{
|
||||
lua_pushinteger(gL, number);
|
||||
@@ -655,7 +655,7 @@ void LUA_HookInt(INT32 number, int hook_type)
|
||||
|
||||
/*void LUA_HookBool(boolean value, int hook_type)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_hook(&hook, 0, hook_type))
|
||||
{
|
||||
//lua_pushboolean(gL, value);
|
||||
@@ -665,7 +665,7 @@ void LUA_HookInt(INT32 number, int hook_type)
|
||||
|
||||
int LUA_HookPlayer(player_t *player, int hook_type)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_hook(&hook, false, hook_type))
|
||||
{
|
||||
LUA_PushUserdata(gL, player, META_PLAYER);
|
||||
@@ -676,7 +676,7 @@ int LUA_HookPlayer(player_t *player, int hook_type)
|
||||
|
||||
int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_hook(&hook, false, hook_type))
|
||||
{
|
||||
LUA_PushUserdata(gL, player, META_PLAYER);
|
||||
@@ -695,7 +695,7 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type)
|
||||
|
||||
void LUA_HookHUD(int hook_type, huddrawlist_h list)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_hud_hook(&hook, hook_type))
|
||||
{
|
||||
LUA_SetHudHook(hook_type, list);
|
||||
@@ -723,7 +723,7 @@ static void hook_think_frame(int type)
|
||||
int hook_index = 0;
|
||||
precise_t time_taken = 0;
|
||||
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
|
||||
const hook_t * map = &hookIds[type];
|
||||
int k;
|
||||
@@ -783,7 +783,7 @@ void LUA_HookPostThinkFrame(void)
|
||||
|
||||
int LUA_HookTouchSpecial(mobj_t *special, mobj_t *toucher)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(TouchSpecial), special))
|
||||
{
|
||||
LUA_PushUserdata(gL, special, META_MOBJ);
|
||||
@@ -802,7 +802,7 @@ static int damage_hook
|
||||
int hook_type,
|
||||
Hook_Callback results_handler
|
||||
){
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_mobj_hook(&hook, 0, hook_type, target))
|
||||
{
|
||||
LUA_PushUserdata(gL, target, META_MOBJ);
|
||||
@@ -890,8 +890,8 @@ int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
||||
{
|
||||
const char *skin = ((skin_t *)tails->skin)->name;
|
||||
|
||||
Hook_State hook;
|
||||
BotAI_State botai;
|
||||
Hook_State hook = {};
|
||||
BotAI_State botai = {};
|
||||
|
||||
if (prepare_string_hook(&hook, false, STRING_HOOK(BotAI), skin))
|
||||
{
|
||||
@@ -911,7 +911,7 @@ int LUA_HookBotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
|
||||
|
||||
void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_string_hook
|
||||
(&hook, 0, STRING_HOOK(LinedefExecute), line->text))
|
||||
{
|
||||
@@ -924,7 +924,7 @@ void LUA_HookLinedefExecute(line_t *line, mobj_t *mo, sector_t *sector)
|
||||
|
||||
int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_hook(&hook, false, HOOK(PlayerMsg)))
|
||||
{
|
||||
LUA_PushUserdata(gL, &players[source], META_PLAYER); // Source player
|
||||
@@ -953,7 +953,7 @@ int LUA_HookPlayerMsg(int source, int target, int flags, char *msg, int mute)
|
||||
|
||||
int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_mobj_hook(&hook, false, MOBJ_HOOK(HurtMsg), inflictor))
|
||||
{
|
||||
LUA_PushUserdata(gL, player, META_PLAYER);
|
||||
@@ -967,7 +967,7 @@ int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source)
|
||||
void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save)
|
||||
{
|
||||
const hook_t * map = &hookIds[HOOK(NetVars)];
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
/* this is a remarkable case where the stack isn't reset */
|
||||
if (map->numHooks > 0)
|
||||
{
|
||||
@@ -997,7 +997,7 @@ void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save)
|
||||
|
||||
void LUA_HookPlayerQuit(player_t *plr, int reason)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_hook(&hook, 0, HOOK(PlayerQuit)))
|
||||
{
|
||||
LUA_PushUserdata(gL, plr, META_PLAYER); // Player that quit
|
||||
@@ -1060,7 +1060,7 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param)
|
||||
const int type = HOOK(MusicChange);
|
||||
const hook_t * map = &hookIds[type];
|
||||
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
|
||||
int k;
|
||||
|
||||
@@ -1096,7 +1096,7 @@ int LUA_HookMusicChange(const char *oldname, struct MusicChange *param)
|
||||
|
||||
int LUA_HookMusicCredit(musicdef_t *musicdef)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_hook(&hook, 0, HOOK(MusicCredit)))
|
||||
{
|
||||
LUA_PushUserdata(gL, musicdef, META_MUSICDEF);
|
||||
@@ -1114,7 +1114,7 @@ static int kartdamage_hook
|
||||
int hook_type,
|
||||
Hook_Callback results_handler
|
||||
){
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_hook(&hook, 0, hook_type))
|
||||
{
|
||||
LUA_PushUserdata(gL, player, META_PLAYER);
|
||||
@@ -1163,7 +1163,7 @@ boolean LUA_HookPlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *sourc
|
||||
|
||||
void LUA_HookSetupVote(INT16 result[], INT16 maxresults, UINT8 gt, UINT8 secondgt)
|
||||
{
|
||||
Hook_State hook;
|
||||
Hook_State hook = {};
|
||||
if (prepare_hook(&hook, 0, HOOK(SetupVote)))
|
||||
{
|
||||
// { 0, 0, 0, 0, }
|
||||
|
||||
@@ -136,18 +136,9 @@ void LUA_HUD_DestroyDrawList(huddrawlist_h list)
|
||||
{
|
||||
if (list == NULL) return;
|
||||
|
||||
if (list->items)
|
||||
{
|
||||
Z_Free(list->items);
|
||||
}
|
||||
if (list->olditems)
|
||||
{
|
||||
Z_Free(list->olditems);
|
||||
}
|
||||
if (list->strbuf)
|
||||
{
|
||||
Z_Free(list->strbuf);
|
||||
}
|
||||
Z_Free(list->items);
|
||||
Z_Free(list->olditems);
|
||||
Z_Free(list->strbuf);
|
||||
Z_Free(list);
|
||||
}
|
||||
|
||||
|
||||
+4
-7
@@ -556,7 +556,7 @@ static void GIF_framewrite(void)
|
||||
}
|
||||
else if (gif_dynamicdelay ==(UINT8) 1)
|
||||
{
|
||||
float delayf = ceil(100.0f/NEWTICRATE);
|
||||
float delayf = ceilf(100.0f/NEWTICRATE);
|
||||
|
||||
delay = (UINT16)((I_GetPreciseTime() - gif_prevframetime)) / (I_GetPrecisePrecision() / 1000000) /10/1000;
|
||||
|
||||
@@ -695,16 +695,13 @@ INT32 GIF_close(void)
|
||||
fclose(gif_out);
|
||||
gif_out = NULL;
|
||||
|
||||
if (gifbwr_buf)
|
||||
Z_Free(gifbwr_buf);
|
||||
Z_Free(gifbwr_buf);
|
||||
gifbwr_buf = gifbwr_cur = NULL;
|
||||
|
||||
if (gifframe_data)
|
||||
Z_Free(gifframe_data);
|
||||
Z_Free(gifframe_data);
|
||||
gifframe_data = NULL;
|
||||
|
||||
if (giflzw_hashTable)
|
||||
Z_Free(giflzw_hashTable);
|
||||
Z_Free(giflzw_hashTable);
|
||||
giflzw_hashTable = NULL;
|
||||
|
||||
Z_Free(scrbuf_screens);
|
||||
|
||||
+3
-6
@@ -248,12 +248,9 @@ void M_AddRawCondition(UINT8 set, UINT8 id, conditiontype_t c, INT32 r, INT16 x1
|
||||
|
||||
void M_ClearConditionSet(UINT8 set)
|
||||
{
|
||||
if (conditionSets[set - 1].numconditions)
|
||||
{
|
||||
Z_Free(conditionSets[set - 1].condition);
|
||||
conditionSets[set - 1].condition = NULL;
|
||||
conditionSets[set - 1].numconditions = 0;
|
||||
}
|
||||
Z_Free(conditionSets[set - 1].condition);
|
||||
conditionSets[set - 1].condition = NULL;
|
||||
conditionSets[set - 1].numconditions = 0;
|
||||
conditionSets[set - 1].achieved = false;
|
||||
}
|
||||
|
||||
|
||||
+11
-16
@@ -2936,7 +2936,7 @@ static void M_PrepareLevelSelect(void)
|
||||
boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt)
|
||||
{
|
||||
// invalid mapnum
|
||||
if (mapnum < -1)
|
||||
if (mapnum < -1 || mapnum >= NUMMAPS)
|
||||
return false;
|
||||
|
||||
// Random map!
|
||||
@@ -5356,7 +5356,7 @@ void M_PopupMasterServerRules(void)
|
||||
{
|
||||
firstDismissedRulesThisBoot = false;
|
||||
M_StartMessage(va("%s\n(press any key)", rules), NULL, MM_NOTHING);
|
||||
Z_Free(rules);
|
||||
free(rules);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -5522,7 +5522,6 @@ static void M_DrawChecklist(void)
|
||||
|
||||
if (conditionSets[unlockables[i].conditionset - 1].numconditions)
|
||||
{
|
||||
c = 0;
|
||||
lastid = -1;
|
||||
|
||||
for (c = 0; c < conditionSets[unlockables[i].conditionset - 1].numconditions; c++)
|
||||
@@ -5682,9 +5681,6 @@ static void M_DrawMusicTest(void)
|
||||
{
|
||||
INT32 x, y, i;
|
||||
|
||||
x = 90<<FRACBITS;
|
||||
y = (BASEVIDHEIGHT-32)<<FRACBITS;
|
||||
|
||||
y = (BASEVIDWIDTH-vid.scaledwidth)/2;
|
||||
|
||||
V_DrawFill(y-1, 20, vid.scaledwidth+1, 24, 239);
|
||||
@@ -6560,17 +6556,22 @@ static void M_EraseGuest(INT32 choice)
|
||||
|
||||
static void M_OverwriteGuest(const char *which)
|
||||
{
|
||||
char *rguest = Z_StrDup(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)));
|
||||
char *rguest;
|
||||
UINT8 *buf;
|
||||
size_t len;
|
||||
len = FIL_ReadFile(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), cv_chooseskin.string, which), &buf);
|
||||
if (!len) {
|
||||
|
||||
if (!len)
|
||||
return;
|
||||
}
|
||||
if (FIL_FileExists(rguest)) {
|
||||
|
||||
rguest = Z_StrDup(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)));
|
||||
|
||||
if (FIL_FileExists(rguest))
|
||||
{
|
||||
M_StopMessage(0);
|
||||
remove(rguest);
|
||||
}
|
||||
|
||||
FIL_WriteFile(rguest, buf, len);
|
||||
Z_Free(rguest);
|
||||
|
||||
@@ -7587,7 +7588,6 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
|
||||
|
||||
static void M_DrawServerMenu(void)
|
||||
{
|
||||
|
||||
M_DrawLevelSelectOnly(false, false);
|
||||
#ifdef MASTERSERVER
|
||||
if (currentMenu == &MP_ServerDef && cv_advertise.value) // Remind players where they're hosting.
|
||||
@@ -7996,14 +7996,9 @@ static void M_DrawSetupMultiPlayerMenu(void)
|
||||
#define GETSELECTEDSPEED (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartspeed : skins[setupm_fakeskin].kartspeed)
|
||||
#define GETSELECTEDWEIGHT (itemOn == 1 && setupm_skinselect < numskins ? skins[skinsorted[setupm_skinselect]].kartweight : skins[setupm_fakeskin].kartweight)
|
||||
|
||||
statoffset = 0;
|
||||
tw = V_StringWidth("Character", 0);//V_StringWidth(GETSELECTEDSKINNAME, 0);
|
||||
st = V_StringWidth(GETSELECTEDSKINNAME, 0);
|
||||
|
||||
INT32 selectedskin = (itemOn == 1 && setupm_skinselect < numskins ? skinsorted[setupm_skinselect] : setupm_fakeskin);
|
||||
speed = skins[selectedskin].kartspeed;
|
||||
weight = skins[selectedskin].kartweight;
|
||||
|
||||
V_DrawString((mx+(tw/2)) - (st/2), my + 37,
|
||||
((MP_PlayerSetupMenu[2].status & IT_TYPE) == IT_SPACE ? V_TRANSLUCENT : 0) | highlightflags | V_ALLOWLOWERCASE,
|
||||
GETSELECTEDSKINNAME);
|
||||
|
||||
+13
-20
@@ -986,7 +986,7 @@ static const char* OP_ExpTooltips[] =
|
||||
"Skips rendering frames if game logic takes too long\npreventing gameplay issues during performance drops.", // idk im shit as describing things
|
||||
"Different methods of scaling the votescreen backgrounds.",
|
||||
#ifdef HWRENDER
|
||||
"Should the game do Screen Textures? Provides a good boost to frames\nat the cost of some visual effects not working when disabled.",
|
||||
"Disabling Screen Textures may result in a performance boost\nbut will break certain effects.\nScreen textures are required at resolutions lower than your desktop resolution!"
|
||||
#ifdef USE_FBO_OGL
|
||||
"Allows the game to downsample from a higher resolution\nthan your display in OpenGL renderer mode.\nRequires a GPU with atleast OpenGL 2.1 support.",
|
||||
#endif
|
||||
@@ -1644,29 +1644,25 @@ static menuitem_t OP_AccessibilityMenu[] =
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Minimum Sector Brightness", &cv_secbright, 45},
|
||||
|
||||
#ifdef HWRENDER
|
||||
{IT_STRING|IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 50},
|
||||
#endif
|
||||
{IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 50},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Water Surface Ripples", &cv_ripplewater, 55},
|
||||
{IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 55},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Fade Players near Camera", &cv_playerfade, 60},
|
||||
{IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 60},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Quake Screenshakes", &cv_screenquake, 65},
|
||||
{IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 65},
|
||||
|
||||
{IT_CALL|IT_STRING, NULL, "Camera Options...", M_CameraMenu, 70},
|
||||
{IT_HEADER, NULL, "Audio", NULL, 75},
|
||||
|
||||
{IT_HEADER, NULL, "Audio", NULL, 80},
|
||||
{IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 85},
|
||||
{IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 90},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 90},
|
||||
{IT_STRING|IT_CVAR, NULL, "Same Sound Limit", &cv_samesoundlimit, 95},
|
||||
{IT_HEADER, NULL, "Controls", NULL, 100},
|
||||
|
||||
{IT_HEADER, NULL, "Controls", NULL, 105},
|
||||
|
||||
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 115},
|
||||
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 120},
|
||||
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 125},
|
||||
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 130},
|
||||
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P1)", &cv_autoaccel[0], 110},
|
||||
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P2)", &cv_autoaccel[1], 115},
|
||||
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P3)", &cv_autoaccel[2], 120},
|
||||
{IT_STRING|IT_CVAR, NULL, "Automatic Acceleration (P4)", &cv_autoaccel[3], 125},
|
||||
};
|
||||
|
||||
static const char* OP_AccessibilityTooltips[] =
|
||||
@@ -1679,9 +1675,6 @@ static const char* OP_AccessibilityTooltips[] =
|
||||
"Reduces or disables certain effects players might be sensitive to\nSuch as flashing, flickering, certain screen effects and more.",
|
||||
"Disables the flicker effect on Midnight Channel.",
|
||||
"Sets minimum sector brightness, useful for dark areas",
|
||||
#ifdef HWRENDER
|
||||
"Disabling Screen Textures will disable the Underwater and Heat screen effects.",
|
||||
#endif
|
||||
"Toggles the ripple effect on water surfaces",
|
||||
"Fades other Players that are close to the camera in and out",
|
||||
"Toggles the screen shake effect during Earthquakes",
|
||||
|
||||
+4
-3
@@ -219,8 +219,9 @@ static void Get_masterserver_rules(boolean checkfirst)
|
||||
if (HMS_fetch_rules(rules, sizeof rules))
|
||||
{
|
||||
Lock_state();
|
||||
Z_Free(MSRules);
|
||||
MSRules = Z_StrDup(rules);
|
||||
if (MSRules)
|
||||
free(MSRules);
|
||||
MSRules = strdup(rules);
|
||||
|
||||
if (MSRegistered == true)
|
||||
{
|
||||
@@ -507,7 +508,7 @@ char *GetMasterServerRules(void)
|
||||
char *rules;
|
||||
|
||||
Lock_state();
|
||||
rules = MSRules ? Z_StrDup(MSRules) : NULL;
|
||||
rules = MSRules ? strdup(MSRules) : NULL;
|
||||
Unlock_state();
|
||||
|
||||
return rules;
|
||||
|
||||
@@ -2420,7 +2420,6 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da
|
||||
{
|
||||
player->kartstuff[k_sneakertimer] = 0;
|
||||
K_SpinPlayer(player, source, 1, inflictor, false);
|
||||
damage = player->mo->health - 1;
|
||||
P_RingDamage(player, inflictor, source);
|
||||
P_PlayerRingBurst(player, 5);
|
||||
|
||||
|
||||
+5
-5
@@ -335,7 +335,7 @@ static boolean P_SetPrecipMobjState(precipmobj_t *mobj, statenum_t state)
|
||||
mobj->tics = st->tics;
|
||||
mobj->sprite = st->sprite;
|
||||
mobj->frame = st->frame;
|
||||
mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set
|
||||
//mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -3620,7 +3620,7 @@ boolean P_PrecipThinker(precipmobj_t *mobj)
|
||||
mobj->lastThink = leveltime;
|
||||
|
||||
R_ResetPrecipitationMobjInterpolationState(mobj);
|
||||
P_CycleStateAnimation((mobj_t *)mobj);
|
||||
//P_CycleStateAnimation((mobj_t *)mobj); // if we ever want animated precip, readd a specific function which does not need casting
|
||||
|
||||
if (mobj->state == &states[S_RAINRETURN])
|
||||
{
|
||||
@@ -6986,7 +6986,7 @@ static boolean P_MobjDeadThink(mobj_t *mobj)
|
||||
fixed_t ns;
|
||||
mobj_t *mo2;
|
||||
|
||||
i = P_RandomByte();
|
||||
i = P_RandomByte(); // grrrrrr
|
||||
z = mobj->subsector->sector->floorheight + ((P_RandomByte()&63)*FRACUNIT);
|
||||
|
||||
for (j = 0; j < 2; j++)
|
||||
@@ -10034,7 +10034,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
|
||||
|
||||
mobj->x = x;
|
||||
mobj->y = y;
|
||||
mobj->flags = info->flags;
|
||||
//mobj->flags = info->flags;
|
||||
|
||||
// do not set the state with P_SetMobjState,
|
||||
// because action routines can not be called yet
|
||||
@@ -10044,7 +10044,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
|
||||
mobj->tics = st->tics;
|
||||
mobj->sprite = st->sprite;
|
||||
mobj->frame = st->frame; // FF_FRAMEMASK for frame, and other bits..
|
||||
mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set
|
||||
//mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set
|
||||
|
||||
// set subsector and/or block links
|
||||
P_SetPrecipitationThingPosition(mobj);
|
||||
|
||||
+2
-5
@@ -444,12 +444,10 @@ typedef struct precipmobj_s
|
||||
// More drawing info: to determine current sprite.
|
||||
spritenum_t sprite; // used to find patch_t and flip value
|
||||
UINT32 frame; // frame number, plus bits see p_pspr.h
|
||||
UINT16 anim_duration; // for FF_ANIMATE states
|
||||
//UINT16 anim_duration; // for FF_ANIMATE states
|
||||
|
||||
INT16 lightlevel; // Add to sector lightlevel, -255 - 255
|
||||
|
||||
struct mprecipsecnode_s *touching_sectorlist; // a linked list of sectors where this object appears
|
||||
|
||||
struct subsector_s *subsector; // Subsector the mobj resides in.
|
||||
|
||||
// The closest interval over all contacted sectors (or things).
|
||||
@@ -458,11 +456,10 @@ typedef struct precipmobj_s
|
||||
|
||||
// Momentums, used to update position.
|
||||
fixed_t momx, momy, momz;
|
||||
fixed_t precipflags; // fixed_t so it uses the same spot as "pmomz" even as we use precipflags_t for it
|
||||
precipflag_t precipflags;
|
||||
|
||||
state_t *state;
|
||||
INT32 tics; // state tic counter
|
||||
UINT32 flags; // flags from mobjinfo tables
|
||||
tic_t lastThink;
|
||||
} precipmobj_t;
|
||||
|
||||
|
||||
+1
-3
@@ -320,9 +320,7 @@ void P_AddGradesForMare(INT16 i, UINT8 mare, char *gtext)
|
||||
*/
|
||||
void P_DeleteGrades(INT16 i)
|
||||
{
|
||||
if (mapheaderinfo[i]->grades)
|
||||
Z_Free(mapheaderinfo[i]->grades);
|
||||
|
||||
Z_Free(mapheaderinfo[i]->grades);
|
||||
mapheaderinfo[i]->grades = NULL;
|
||||
mapheaderinfo[i]->numGradedMares = 0;
|
||||
}
|
||||
|
||||
+17
-21
@@ -1702,7 +1702,7 @@ void P_SwitchWeather(INT32 weathernum)
|
||||
|
||||
precipmobj->type = type; // proper set the type
|
||||
precipmobj->info = &mobjinfo[type];
|
||||
precipmobj->flags = mobjinfo[type].flags;
|
||||
//precipmobj->flags = mobjinfo[type].flags;
|
||||
|
||||
st = &states[mobjinfo[type].spawnstate+z];
|
||||
|
||||
@@ -3161,11 +3161,6 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers
|
||||
INT32 section1, section2, section3, section4;
|
||||
INT32 special;
|
||||
|
||||
section1 = GETSECSPECIAL(sector->special, 1);
|
||||
section2 = GETSECSPECIAL(sector->special, 2);
|
||||
section3 = GETSECSPECIAL(sector->special, 3);
|
||||
section4 = GETSECSPECIAL(sector->special, 4);
|
||||
|
||||
// Ignore spectators
|
||||
if (player->spectator)
|
||||
return;
|
||||
@@ -3176,6 +3171,11 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers
|
||||
if (player->playerstate == PST_DEAD)
|
||||
return;
|
||||
|
||||
section1 = GETSECSPECIAL(sector->special, 1);
|
||||
section2 = GETSECSPECIAL(sector->special, 2);
|
||||
section3 = GETSECSPECIAL(sector->special, 3);
|
||||
section4 = GETSECSPECIAL(sector->special, 4);
|
||||
|
||||
// Conveyor stuff
|
||||
if (section3 == 2 || section3 == 4)
|
||||
player->onconveyor = section3;
|
||||
@@ -4381,8 +4381,6 @@ static void P_PlayerOnSpecial3DFloor(player_t *player, sector_t *sector)
|
||||
}
|
||||
}
|
||||
|
||||
#define VDOORSPEED (FRACUNIT*2)
|
||||
|
||||
//
|
||||
// P_RunSpecialSectorCheck
|
||||
//
|
||||
@@ -4512,9 +4510,7 @@ void P_UpdateSpecials(void)
|
||||
{
|
||||
anim_t *anim;
|
||||
INT32 i;
|
||||
INT32 pic;
|
||||
size_t j;
|
||||
|
||||
levelflat_t *foundflats; // for flat animation
|
||||
|
||||
// LEVEL TIMER
|
||||
@@ -4532,9 +4528,11 @@ void P_UpdateSpecials(void)
|
||||
{
|
||||
for (i = 0; i < anim->numpics; i++)
|
||||
{
|
||||
pic = anim->basepic + ((leveltime/anim->speed + i) % anim->numpics);
|
||||
if (anim->istexture)
|
||||
texturetranslation[anim->basepic+i] = pic;
|
||||
{
|
||||
texturetranslation[anim->basepic+i] = anim->basepic +
|
||||
((leveltime/anim->speed + i) % anim->numpics);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4629,8 +4627,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f
|
||||
|
||||
if (sec2->numattached == 0)
|
||||
{
|
||||
sec2->attached = Z_Malloc(sizeof (*sec2->attached) * sec2->maxattached, PU_STATIC, NULL);
|
||||
sec2->attachedsolid = Z_Malloc(sizeof (*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL);
|
||||
sec2->attached = Z_Malloc(sizeof(*sec2->attached) * sec2->maxattached, PU_STATIC, NULL);
|
||||
sec2->attachedsolid = Z_Malloc(sizeof(*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL);
|
||||
sec2->attached[0] = sec - sectors;
|
||||
sec2->numattached = 1;
|
||||
sec2->attachedsolid[0] = (flags & FF_SOLID);
|
||||
@@ -4644,8 +4642,8 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f
|
||||
if (sec2->numattached >= sec2->maxattached)
|
||||
{
|
||||
sec2->maxattached *= 2;
|
||||
sec2->attached = Z_Realloc(sec2->attached, sizeof (*sec2->attached) * sec2->maxattached, PU_STATIC, NULL);
|
||||
sec2->attachedsolid = Z_Realloc(sec2->attachedsolid, sizeof (*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL);
|
||||
sec2->attached = Z_Realloc(sec2->attached, sizeof(*sec2->attached) * sec2->maxattached, PU_STATIC, NULL);
|
||||
sec2->attachedsolid = Z_Realloc(sec2->attachedsolid, sizeof(*sec2->attachedsolid) * sec2->maxattached, PU_STATIC, NULL);
|
||||
}
|
||||
sec2->attached[sec2->numattached] = sec - sectors;
|
||||
sec2->attachedsolid[sec2->numattached] = (flags & FF_SOLID);
|
||||
@@ -4653,7 +4651,7 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f
|
||||
}
|
||||
|
||||
// Add the floor
|
||||
ffloor = Z_Calloc(sizeof (*ffloor), PU_LEVEL, NULL);
|
||||
ffloor = Z_Calloc(sizeof(*ffloor), PU_LEVEL, NULL);
|
||||
ffloor->secnum = sec2 - sectors;
|
||||
ffloor->target = sec;
|
||||
ffloor->bottomheight = &sec2->floorheight;
|
||||
@@ -5468,7 +5466,6 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate)
|
||||
break;
|
||||
|
||||
case 10: // Vertical culling plane for sprites and FOFs
|
||||
sec = sides[*lines[i].sidenum].sector - sectors;
|
||||
for (s = -1; (s = P_FindSectorFromLineTag(lines + i, s)) >= 0 ;)
|
||||
sectors[s].cullheight = &lines[i]; // This allows it to change in realtime!
|
||||
break;
|
||||
@@ -5989,7 +5986,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate)
|
||||
if (!virt)
|
||||
virt = vres_GetMap(lastloadedmaplumpnum);
|
||||
|
||||
data = (UINT8*) vres_Find(virt, "SIDEDEFS")->data;
|
||||
data = (UINT8*)vres_Find(virt, "SIDEDEFS")->data;
|
||||
|
||||
for (b = 0; b < (INT16)numsides; b++)
|
||||
{
|
||||
@@ -6221,8 +6218,7 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate)
|
||||
|
||||
// Allocate each list
|
||||
for (i = 0; i < numsectors; i++)
|
||||
if(secthinkers[i].thinkers)
|
||||
Z_Free(secthinkers[i].thinkers);
|
||||
Z_Free(secthinkers[i].thinkers);
|
||||
|
||||
Z_Free(secthinkers);
|
||||
|
||||
|
||||
+4
-3
@@ -728,11 +728,12 @@ void P_Ticker(boolean run)
|
||||
|
||||
if (cv_recordmultiplayerdemos.value)
|
||||
{
|
||||
const INT32 axis = JoyAxis(AXISLOOKBACK, 1);
|
||||
|
||||
if (demo.savemode == DSM_NOTSAVING || demo.savemode == DSM_WILLAUTOSAVE)
|
||||
if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && (InputDown(gc_lookback, 1) || (cv_usejoystick[0].value && axis > 0)))
|
||||
{
|
||||
const INT32 axis = cv_usejoystick[0].value ? JoyAxis(AXISLOOKBACK, 1) : -1;
|
||||
if (demo.savebutton && demo.savebutton + 3*TICRATE < leveltime && (InputDown(gc_lookback, 1) || (axis > 0)))
|
||||
demo.savemode = DSM_TITLEENTRY;
|
||||
}
|
||||
|
||||
// if there are no players left at all, stop demo recording
|
||||
// Demos that that dont have any players crash during playback, which can happen with dedicated servers
|
||||
|
||||
+1
-12
@@ -1822,7 +1822,6 @@ void P_DoJumpShield(player_t *player)
|
||||
|
||||
player->pflags &= ~PF_JUMPED;
|
||||
//P_DoJump(player, false);
|
||||
player->pflags &= ~PF_JUMPED;
|
||||
player->secondjump = 0;
|
||||
player->jumping = 0;
|
||||
player->pflags |= PF_THOKKED;
|
||||
@@ -1894,7 +1893,6 @@ static void P_3dMovement(player_t *player)
|
||||
ticcmd_t *cmd;
|
||||
angle_t movepushangle, movepushsideangle; // Analog
|
||||
fixed_t movepushforward = 0, movepushside = 0;
|
||||
angle_t dangle; // replaces old quadrants bits
|
||||
boolean analogmove = false;
|
||||
fixed_t oldMagnitude, newMagnitude;
|
||||
vector3_t totalthrust;
|
||||
@@ -1952,15 +1950,6 @@ static void P_3dMovement(player_t *player)
|
||||
// Calculates player's speed based on distance-of-a-line formula
|
||||
player->speed = R_PointToDist2(0, 0, player->rmomx, player->rmomy);
|
||||
|
||||
// Monster Iestyn - 04-11-13
|
||||
// Quadrants are stupid, excessive and broken, let's do this a much simpler way!
|
||||
// Get delta angle from rmom angle and player angle first
|
||||
dangle = R_PointToAngle2(0,0, player->rmomx, player->rmomy) - player->mo->angle;
|
||||
if (dangle > ANGLE_180) //flip to keep to one side
|
||||
{
|
||||
dangle = InvAngle(dangle);
|
||||
}
|
||||
|
||||
// When sliding, don't allow forward/back
|
||||
if (player->pflags & PF_SLIDING)
|
||||
cmd->forwardmove = 0;
|
||||
@@ -4464,7 +4453,7 @@ static INT32 Quaketilt(player_t *player)
|
||||
|
||||
lowb = FixedMul(lowb, player->mo->scale);
|
||||
moma = FixedMul(FixedDiv(delta, ANGLE_90), tilt);
|
||||
speed = abs( player->mo->momx + player->mo->momy );
|
||||
speed = abs(player->mo->momx + player->mo->momy);
|
||||
|
||||
if (speed < lowb)
|
||||
{
|
||||
|
||||
+1
-2
@@ -1720,8 +1720,7 @@ void R_InitData(void)
|
||||
|
||||
void R_ClearTextureNumCache(boolean btell)
|
||||
{
|
||||
if (tidcache)
|
||||
Z_Free(tidcache);
|
||||
Z_Free(tidcache);
|
||||
tidcache = NULL;
|
||||
if (btell)
|
||||
CONS_Debug(DBG_SETUP, "Fun Fact: There are %d textures used in this map.\n", tidcachelen);
|
||||
|
||||
+6
-10
@@ -925,11 +925,11 @@ void R_ExecuteSetViewSize(void)
|
||||
viewheight = vid.height;
|
||||
|
||||
if (splitscreen)
|
||||
{
|
||||
viewheight >>= 1;
|
||||
|
||||
if (splitscreen > 1)
|
||||
{
|
||||
viewwidth >>= 1;
|
||||
if (splitscreen > 1)
|
||||
viewwidth >>= 1;
|
||||
}
|
||||
|
||||
centerx = viewwidth/2;
|
||||
@@ -956,13 +956,9 @@ void R_ExecuteSetViewSize(void)
|
||||
screenheightarray[i] = (INT16)viewheight;
|
||||
}
|
||||
|
||||
if (ds_su)
|
||||
Z_Free(ds_su);
|
||||
if (ds_sv)
|
||||
Z_Free(ds_sv);
|
||||
if (ds_sz)
|
||||
Z_Free(ds_sz);
|
||||
|
||||
Z_Free(ds_su);
|
||||
Z_Free(ds_sv);
|
||||
Z_Free(ds_sz);
|
||||
ds_su = ds_sv = ds_sz = NULL;
|
||||
|
||||
memset(scalelight, 0xFF, sizeof(scalelight));
|
||||
|
||||
+2
-4
@@ -405,10 +405,8 @@ static void Patch_FreeData(patch_t *patch)
|
||||
}*/
|
||||
#endif
|
||||
|
||||
if (patch->columnofs)
|
||||
Z_Free(patch->columnofs);
|
||||
if (patch->columns)
|
||||
Z_Free(patch->columns);
|
||||
Z_Free(patch->columnofs);
|
||||
Z_Free(patch->columns);
|
||||
}
|
||||
|
||||
void Patch_Free(patch_t *patch)
|
||||
|
||||
+1
-4
@@ -391,7 +391,7 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16
|
||||
|
||||
// allocate space for the frames present and copy sprtemp to it
|
||||
if (spritedef->numframes && // has been allocated
|
||||
spritedef->numframes < maxframe) // more frames are defined ?
|
||||
spritedef->numframes < maxframe) // more frames are defined ?
|
||||
{
|
||||
|
||||
Z_Free(spritedef->spriteframes);
|
||||
@@ -1855,9 +1855,6 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||
|
||||
if (thing->subsector->sector->numlights)
|
||||
R_SplitSprite(vis);
|
||||
|
||||
// Debug
|
||||
++objectsdrawn;
|
||||
}
|
||||
|
||||
static void R_ProjectPrecipitationSprite(precipmobj_t *thing)
|
||||
|
||||
+1
-2
@@ -473,13 +473,12 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume)
|
||||
return;
|
||||
|
||||
memset(listener, 0, sizeof(listener));
|
||||
memset(listenmobj, 0, sizeof(listenmobj));
|
||||
|
||||
for (i = 0; i <= splitscreen; i++)
|
||||
{
|
||||
player_t *player = &players[displayplayers[i]];
|
||||
|
||||
listenmobj[i] = NULL;
|
||||
|
||||
if (player->awayviewtics)
|
||||
{
|
||||
listenmobj[i] = player->awayviewmobj;
|
||||
|
||||
@@ -1841,18 +1841,15 @@ static void I_Fork(void)
|
||||
I_RegisterChildSignals();
|
||||
break;
|
||||
default:
|
||||
#ifdef LOGMESSAGES
|
||||
if (logstream)
|
||||
fclose(logstream);/* the child has this */
|
||||
|
||||
#endif
|
||||
c = wait(&status);
|
||||
|
||||
#ifdef LOGMESSAGES
|
||||
/* By the way, exit closes files. */
|
||||
logstream = fopen(logfilename, "at");
|
||||
#else
|
||||
logstream = 0;
|
||||
#endif
|
||||
|
||||
if (c == -1)
|
||||
{
|
||||
kill(child, SIGKILL);
|
||||
|
||||
+2
-2
@@ -1164,8 +1164,8 @@ void I_GetEvent(void)
|
||||
SDL_GetWindowSize(window, &wwidth, &wheight);
|
||||
event.type = ev_mouse;
|
||||
event.data1 = 0;
|
||||
event.data2 = (INT32)lround(mousemovex * ((float)wwidth / (float)realwidth));
|
||||
event.data3 = (INT32)lround(mousemovey * ((float)wheight / (float)realheight));
|
||||
event.data2 = (INT32)lroundf(mousemovex * ((float)wwidth / (float)realwidth));
|
||||
event.data3 = (INT32)lroundf(mousemovey * ((float)wheight / (float)realheight));
|
||||
D_PostEvent(&event);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,8 +52,6 @@
|
||||
|
||||
#include "r_fps.h"
|
||||
|
||||
UINT16 objectsdrawn = 0;
|
||||
|
||||
// dumb fade thing for director toggle
|
||||
tic_t directortoggletimer = 0;
|
||||
|
||||
|
||||
@@ -134,8 +134,6 @@ typedef enum
|
||||
|
||||
extern hudinfo_t hudinfo[NUMHUDITEMS];
|
||||
|
||||
extern UINT16 objectsdrawn;
|
||||
|
||||
// variable to stop mayonaka static from flickering
|
||||
extern consvar_t cv_lessflicker;
|
||||
extern consvar_t cv_stagetitle;
|
||||
|
||||
+1
-3
@@ -3716,9 +3716,7 @@ void V_DoPostProcessor(INT32 view, INT32 param)
|
||||
// Make sure table is built
|
||||
if (heatshifter == NULL || lastheight != viewheight)
|
||||
{
|
||||
if (heatshifter)
|
||||
Z_Free(heatshifter);
|
||||
|
||||
Z_Free(heatshifter);
|
||||
heatshifter = Z_Calloc(viewheight * sizeof(boolean), PU_STATIC, NULL);
|
||||
|
||||
for (y = 0; y < viewheight; y++)
|
||||
|
||||
+4
-5
@@ -122,7 +122,9 @@ void W_Shutdown(void)
|
||||
|
||||
if (wad->handle)
|
||||
fclose(wad->handle);
|
||||
|
||||
Z_Free(wad->filename);
|
||||
|
||||
while (wad->numlumps--)
|
||||
{
|
||||
Z_Free(wad->lumpinfo[wad->numlumps].longname);
|
||||
@@ -453,7 +455,7 @@ static lumpinfo_t* ResGetLumpsWad(FILE* handle, UINT16* nlmp, const char* filena
|
||||
header.infotableofs = LONG(header.infotableofs);
|
||||
|
||||
// read wad file directory
|
||||
i = header.numlumps * sizeof (*fileinfo);
|
||||
i = header.numlumps * sizeof(*fileinfo);
|
||||
fileinfov = fileinfo = malloc(i);
|
||||
|
||||
if (fseek(handle, header.infotableofs, SEEK_SET) == -1
|
||||
@@ -2730,10 +2732,7 @@ void vres_Free(virtres_t* vres)
|
||||
|
||||
while (vres->numlumps--)
|
||||
{
|
||||
if (vres->vlumps[vres->numlumps].data)
|
||||
{
|
||||
Z_Free(vres->vlumps[vres->numlumps].data);
|
||||
}
|
||||
Z_Free(vres->vlumps[vres->numlumps].data);
|
||||
}
|
||||
|
||||
Z_Free(vres->vlumps);
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ void Z_Init(void);
|
||||
|
||||
// Z_Free and alloc with alignment
|
||||
#ifdef ZDEBUG
|
||||
#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__)
|
||||
#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__)
|
||||
#define Z_Malloc(s,t,u) Z_Malloc2(s, t, u, __FILE__, __LINE__)
|
||||
#define Z_Calloc(s,t,u) Z_Calloc2(s, t, u, __FILE__, __LINE__)
|
||||
#define Z_Realloc(p,s,t,u) Z_Realloc2(p,s, t, u, __FILE__, __LINE__)
|
||||
|
||||
Reference in new issue
Block a user