Compare commits

...
96 Commits
Author SHA1 Message Date
Alug 48d9b2bc98 reduce netbuffer scope even further 2025-07-26 16:19:13 +02:00
Alug 939bf588b3 Merge branch 'Saturn-Next' into fixupnet 2025-07-26 16:19:09 +02:00
Alug cb2e017bcf seenames stuff is always unlikely 2025-07-26 16:18:59 +02:00
Alug d91fbf5d36 move assignments after early returns ST_drawLevelTitle 2025-07-26 16:18:56 +02:00
Alug 9859e43be7 get rid of some redundancy R_Frame stuff
R_SetupCommonFrame already checks the actual sector for us, so we dont need to do this before
2025-07-26 16:18:52 +02:00
Alug 306fec6f9e get rid of code dupe for fpscapping stuff 2025-07-26 16:18:25 +02:00
Alug 3e8b3e868b simplify this 2025-07-26 16:18:22 +02:00
Alug 9261d9c5b2 D_CleanFile can be static 2025-07-26 16:18:20 +02:00
Alug f97941f86e update link in addon menu to "mb.srb2.org/addons"
:chonkbuncle:
2025-07-24 23:47:41 +02:00
Gustaf Alhäll a4810bd6c8 Fix custom addon directory being ignored when downloading addons 2025-07-24 23:45:55 +02:00
Alug 93cbba218a add mobj islocal field
so we can skip the pushable trigger stuff for local mobjs for synch reasons
very sketchy
2025-07-24 22:33:53 +02:00
Alug a658883664 fix console taking minutes to open during frameskipping
prob not the best way to handle this, but its the simplest
the console should always be openable without issues unless during wipes, since in some cases you end up having to kill the game to do anything
2025-07-24 20:47:21 +02:00
indev d94c10014f Move server search below refresh option 2025-07-24 21:20:19 +03:00
Alug 9fb3f4c9a3 fix https://github.com/Indev450/SRB2Kart-Saturn/issues/191
was an oversight when i cleaned up the gamepad stuff a bit
2025-07-24 15:38:05 +02:00
Alug 9a60441e54 few more things for hw renderer
just moving aaround some things and declaring more stuff as const
2025-07-23 17:07:38 +02:00
Alug 29cf728fac enable ZDEBUG by default
this is just quite useful honestly
2025-07-22 17:33:23 +02:00
Alug 3c78c5c57d ok git very cool 2025-07-22 17:33:11 +02:00
Alug 7f3f332821 Remove aligned allocation functions 2025-07-22 17:33:07 +02:00
Alug 38576082fb move prints to ZDEBUG2
as it seems to be for this purpose
2025-07-22 17:31:44 +02:00
Alug 4a4b5661f2 move this stuff behind ZDEBUG 2025-07-22 17:31:22 +02:00
Alug 1e879dc432 let Z_CheckHeap print file and line of where it occured
like its supposed to lel
2025-07-22 14:18:00 +02:00
Alug f3c8ff19b9 remove redundant R_SetColumnFunc call
this would only be needed if we had brightmap support, but like this it just sets the column function to what it already is
2025-07-21 19:11:01 +02:00
Alug fdd19632bf Use R_RenderSegLoop if the back sector has any 3D floor planes
fixes issues in northern district zone
2025-07-21 19:10:58 +02:00
Alug b0653416f6 Merge branch 'Saturn-Next' into fixupnet 2025-07-20 17:03:30 +02:00
Alug e102d218ff add toggle for quake screenshake effects
TODO: make an accessability option menu for certain effects
2025-07-19 22:54:37 +02:00
Alug 20cdec33fb fix https://github.com/Indev450/SRB2Kart-Saturn/issues/190
doing it like this, so potentially wonky socked maps dont show up if its disabled
2025-07-19 22:42:37 +02:00
indev 12d4a6d291 Also add scoll into level select for displaying map source filename 2025-07-18 23:19:19 +03:00
Alug d2b1ff595d remove itemamount check here
replicate vanilla
even if this becomes negative
this does not seem to crash, so id rather do whatever vanilla does
2025-07-18 17:57:45 +02:00
indev 03d79fba16 Add filename scrolling for addons menu 2025-07-18 14:48:45 +03:00
indev 989c29f7a0 Move scrollMusicName into m_misc as M_ScrollString 2025-07-18 14:21:05 +03:00
Alug 8a79c0a4e0 simplify free block in P_RemoveMobj
should be functionally the same
2025-07-18 11:01:58 +02:00
Alug 307c333c50 use branch instrincts for P_MobjThinker
based on observations from kart stuff
2025-07-18 11:01:28 +02:00
Alug 3ce8b9f09c oop move this back
this is some global, dont wanna mess things up
2025-07-18 10:57:15 +02:00
Alug 4dbe637510 remove pointless var P_TryCameraMove 2025-07-17 00:28:22 +02:00
Alug c0e97e7f43 store sector directly P_CheckPosition
hopefully this makes pointer access faster here
2025-07-17 00:28:19 +02:00
Alug 37fc64e97d optimization K_KartUpdatePosition
this checked the distance to every single waypoint on the map always and unconditionally, but we dont need the distance unconditionally so only check if we need to
+5fps in techbatics hadal classic timedemo
2025-07-17 00:06:59 +02:00
Alug ca93f08230 use branch instricts for blua
mostly just for error handling
similar to upstream lua and bluajit
hope this speeds this up a little
2025-07-16 23:01:16 +02:00
Alug 3581ce811c cache those things 2025-07-16 23:01:12 +02:00
Alug 0411c40fae discord rpc my butt 2025-07-15 17:04:32 +02:00
Alug 0159b8d0a3 use the tooltips array in the menu_t struct for tooltips
so this was always there lel
gets rid of massively duplicated tooltip calls and is generally cleaner
2025-07-15 15:03:00 +02:00
Alug aea3b49a51 💀 fix menu screentex toggle lel
thx neppy!
2025-07-15 14:00:57 +02:00
GenericHeroGuy 1a6f775cc3 bruh
Let's try that again, this time putting the camera in a local...
2025-07-15 14:00:53 +02:00
Alug ddd192fad0 declare all the kart "time" stuff as const
as far as i can see those never get overwritten and cant be overwritten
2025-07-15 14:00:49 +02:00
Alug 2e4fb32dac dont apply player camfade when exiting or in freecam mode
also renames it and moves the check outside
2025-07-15 14:00:46 +02:00
Alug 7d6e210625 use c++ template for HWR_DrawSprites
works just as well without code dupe
2025-07-13 23:11:52 +02:00
Alug 3ca42ce42f register chasecam with the other cam vars
why dupe a loop
2025-07-13 21:52:26 +02:00
Alug e4e40cf049 remove prob pointless check
viewplayer will be the currently viewed displayplayer lel
2025-07-13 21:52:23 +02:00
Alug d4f912e3b0 add toggable player close to camera fade
similar to some other kartracers
only takes other players into account
2025-07-13 21:52:20 +02:00
Alug eec4443c95 smol stuff i missed i_video 2025-07-13 16:31:59 +02:00
Alug b938c75892 clean up i_video.c a little
what a mess
this is still far from tidy
2025-07-13 16:17:32 +02:00
Alug 455cb9ca24 delet windoze users
apparently this makes cross compile commit sudoku, need to test this on actual windoze and see if this breaks anything since idk how this file even works
thx nep for the tip!
2025-07-12 14:56:34 +02:00
Alug 24e7f5f864 readd R_PointInSubsectorFast
use it for camera, viewpoint, some precip and sound stuff and (visual) banana slope calc
after profiling it a bit, this may be 2-4x faster in a bunch cases
2025-07-12 13:39:57 +02:00
Alug 298fa36c5d uninline R_IsPointInSubsector
this gets used like once or twice, we dont need that inlined
2025-07-12 13:35:12 +02:00
indev d31e9c5b55 Strip colors from server name when searching through server list 2025-07-11 23:15:19 +03:00
Alug 30f53f398f move CopyCaretColors to m_misc 2025-07-11 21:56:10 +02:00
indev eee217deec Add server search 2025-07-11 22:43:36 +03:00
Alug 487ef6f1b9 fix windoze for the 50 trillionth time
when do we finally remove windows support?
those two things do absolutely fucking nothing but shit dies without em for whatever reason
2025-07-08 17:05:44 +01:00
Alug a554b886c6 fix peeindex overflow
lelelele thx indev <3
2025-07-08 14:23:34 +02:00
Alug f2d68b075c texturewidthmask can be static 2025-07-08 13:48:18 +02:00
Alug dc24de3501 fix color translated spans lmao
oopsie
well atleast we got some extra safety with the spandata source lel
2025-07-08 13:48:14 +02:00
Alug d2c73f072e reuse "i" 2025-07-08 12:02:10 +02:00
GenericHeroGuy 96bc7f7aa6 Fix fake floors in Donut Plains disappearing when chasecam is off
Also remove the useless R_PointInSubsector calls
2025-07-08 12:01:49 +02:00
Alug bd48b24000 some micro optimize 2025-07-08 12:01:46 +02:00
indev a26867bbdb Add separate option to toggle parallel rendering in R_DrawMaskedList 2025-07-08 00:36:25 +03:00
indev 8d570b7ba3 Revert "Disable multithreading in R_DrawMaskedList"
This reverts commit 5a44afcd9f.
2025-07-08 00:10:08 +03:00
Alug 96f5a8adb3 fix for non pow2 width textures in software from doom-legacy 2025-07-07 21:47:48 +02:00
indev 3b34f0a972 Sort replays in replay hut 2025-07-06 15:48:18 +03:00
Alug fe5a0b7c64 GL_ 2025-07-05 15:51:30 +02:00
BlueStaggo 2aa5324225 Manual mipmapping + Texture padding 2025-07-05 15:51:27 +02:00
Alug 22f50402fe remove this 2025-07-05 15:51:15 +02:00
Gustaf Alhäll 4e2f1bcf2b Fix invalid formats being passed to interal texture formats
The effects that this had on the engine is unknown, but the reference
pages makes in very clear that the old behavior is wrong.
2025-07-05 15:50:48 +02:00
indev ca34b0c8d6 Add /mute chat command 2025-07-05 00:27:17 +03:00
indev 0df5ef996c (kinda) unify LookupPlayer and nametonum, rename first into D_LookupPlayer 2025-07-04 23:15:31 +03:00
Alug 4c0ea2695e remove smoothpos cvar and add it as setting for "postitionanimation" cvar 2025-07-04 12:32:49 +02:00
Alug 48556ca428 oop lmao 2025-07-04 12:23:34 +02:00
NepDisk 5db50bbaff Port HEPII(I) position number scaling 2025-07-04 11:19:48 +02:00
Alug 416da7cdc8 use memset for S_ClearQueue
just simpler
2025-07-04 11:19:45 +02:00
Alug f47057e800 update credits
this is super full and we need to think about something better for this X)
2025-07-03 10:17:12 +02:00
Alug 090559a766 move this out of maptitle condition
it does not rely on it and may even fail
idk why i threw it in there
2025-07-03 00:34:19 +02:00
Alug 1a6a3de443 double fpscounter samples
slightly more readable
2025-07-03 00:32:15 +02:00
Alug d1a6394e52 Merge remote-tracking branch 'origin/Saturn-Next' into fixupnet 2025-06-19 15:55:22 +02:00
Alug ccc90842a7 move CopyCaretColors to m_misc 2025-06-12 17:10:08 +02:00
Alug dc069d7bb5 unnest HandlePacketFromPlayer
+ some cleanup
2025-06-12 00:53:47 +02:00
Alug f4a827dfc2 fix conflicts 2025-06-12 00:02:55 +02:00
Alug 4f3232b6cc Merge branch 'Saturn-Next' into fixupnet 2025-06-12 00:02:05 +02:00
Alug 3685502edf Revert "delet tic resending stuff"
This reverts commit 17bc8a4a36.
2025-05-26 18:10:03 +02:00
Alug f87bcef079 try fixing some crash with bogus netxcmds 2025-05-23 16:55:47 +02:00
Alug c3458afe2b unglobalise holepunchpacket aswell 2025-05-23 16:53:42 +02:00
Alug 17bc8a4a36 delet tic resending stuff 2025-05-23 16:51:26 +02:00
Alug b04f017ab6 change ticqueue system to be more like srb 2.2
mostly just renaming lel
2025-05-23 16:51:10 +02:00
Alug 083ddb6396 Refactor netbuffer out of global namespace
https://git.do.srb2.org/Hanicef/SRB2Classic/-/commit/079fd2cef97a9cf22fb5d2b66a9b500914efbc72

+ move some things into functions
2025-05-23 16:48:34 +02:00
Alug c3129742c3 simplify cmpack 2025-05-23 16:44:52 +02:00
Alug 877bd640f3 fix destinationnode check in Processackpak 2025-05-23 16:43:52 +02:00
Alug 3233df9c6c do not resolve ipv4 in curl when using ipv6 2025-05-23 16:43:24 +02:00
Alug 9ad5f5189c split portnum retrieval into own function 2025-05-23 16:43:02 +02:00
Alug c7718dea79 fixup! i_tcp
technically make ipv6 work,, but its disabled by default
2025-05-23 16:40:38 +02:00
79 changed files with 2921 additions and 2363 deletions

No files matched your search

+2
View File
@@ -69,6 +69,7 @@ opts+=-DHAVE_MINIUPNPC
endif
ifndef NOLIBBACKTRACE
$(eval $(call Propogate_flags,LIBBACKTRACE))
libs+=-lbacktrace
opts+=-DHAVE_LIBBACKTRACE
endif
@@ -81,6 +82,7 @@ endif
endif
ifdef HAVE_DISCORDRPC
$(eval $(call Propogate_flags,DISCORDRPC))
libs+=-ldiscord-rpc
opts+=-DUSE_STUN
sources+=discord.c stun.c
+5 -5
View File
@@ -133,26 +133,26 @@ LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {
LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *mes) {
if (!lua_checkstack(L, space))
if (l_unlikely(!lua_checkstack(L, space)))
luaL_error(L, "stack overflow (%s)", mes);
}
LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
if (lua_type(L, narg) != t)
if (l_unlikely(lua_type(L, narg) != t))
tag_error(L, narg, t);
}
LUALIB_API void luaL_checkany (lua_State *L, int narg) {
if (lua_type(L, narg) == LUA_TNONE)
if (l_unlikely(lua_type(L, narg) == LUA_TNONE))
luaL_argerror(L, narg, "value expected");
}
LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t *len) {
const char *s = lua_tolstring(L, narg, len);
if (!s) tag_error(L, narg, LUA_TSTRING);
if (l_unlikely(!s)) tag_error(L, narg, LUA_TSTRING);
return s;
}
@@ -170,7 +170,7 @@ LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
lua_Number d = lua_tonumber(L, narg);
if (d == 0 && !lua_isnumber(L, narg)) /* avoid extra test when d is not 0 */
if (l_unlikely(d == 0 && !lua_isnumber(L, narg))) /* avoid extra test when d is not 0 */
tag_error(L, narg, LUA_TNUMBER);
return d;
}
+1 -1
View File
@@ -102,7 +102,7 @@ LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
*/
#define luaL_argcheck(L, cond,numarg,extramsg) \
((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
((void)(l_likely(cond) || luaL_argerror(L, (numarg), (extramsg))))
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
+9 -9
View File
@@ -106,7 +106,7 @@ static int luaB_setmetatable (lua_State *L) {
luaL_checktype(L, 1, LUA_TTABLE);
luaL_argcheck(L, t == LUA_TNIL || t == LUA_TTABLE, 2,
"nil or table expected");
if (luaL_getmetafield(L, 1, "__metatable"))
if (l_unlikely(luaL_getmetafield(L, 1, "__metatable")))
luaL_error(L, "cannot change a protected metatable");
lua_settop(L, 2);
lua_setmetatable(L, 1);
@@ -120,10 +120,10 @@ static void getfunc (lua_State *L, int opt) {
lua_Debug ar;
int level = opt ? luaL_optint(L, 1, 1) : luaL_checkint(L, 1);
luaL_argcheck(L, level >= 0, 1, "level must be non-negative");
if (lua_getstack(L, level, &ar) == 0)
if (l_unlikely(lua_getstack(L, level, &ar) == 0))
luaL_argerror(L, 1, "invalid level");
lua_getinfo(L, "f", &ar);
if (lua_isnil(L, -1))
if (l_unlikely(lua_isnil(L, -1)))
luaL_error(L, "no function environment for tail call at level %d",
level);
}
@@ -151,7 +151,7 @@ static int luaB_setfenv (lua_State *L) {
lua_setfenv(L, -2);
return 0;
}
else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0)
else if (l_unlikely(lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0))
luaL_error(L,
LUA_QL("setfenv") " cannot change environment of given object");
return 1;
@@ -265,7 +265,7 @@ static int luaB_ipairs (lua_State *L) {
static int luaB_assert (lua_State *L) {
luaL_checkany(L, 1);
if (!lua_toboolean(L, 1))
if (l_unlikely(!lua_toboolean(L, 1)))
return luaL_error(L, "%s", luaL_optstring(L, 2, "assertion failed!"));
return lua_gettop(L);
}
@@ -278,7 +278,7 @@ static int luaB_unpack (lua_State *L) {
e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
if (i > e) return 0; /* empty range */
n = e - i + 1; /* number of elements */
if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */
if (l_unlikely(n <= 0 || !lua_checkstack(L, n))) /* n <= 0 means arith. overflow */
return luaL_error(L, "too many results to unpack");
lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */
while (i++ < e) /* push arg[i + 1...e] */
@@ -445,9 +445,9 @@ static int luaB_costatus (lua_State *L) {
static int auxresume (lua_State *L, lua_State *co, int narg) {
int status = costatus(L, co);
if (!lua_checkstack(co, narg))
if (l_unlikely(!lua_checkstack(co, narg)))
luaL_error(L, "too many arguments to resume");
if (status != CO_SUS) {
if (l_unlikely(status != CO_SUS)) {
lua_pushfstring(L, "cannot resume %s coroutine", statnames[status]);
return -1; /* error flag */
}
@@ -456,7 +456,7 @@ static int auxresume (lua_State *L, lua_State *co, int narg) {
status = lua_resume(co, narg);
if (status == 0 || status == LUA_YIELD) {
int nres = lua_gettop(co);
if (!lua_checkstack(L, nres + 1))
if (l_unlikely(!lua_checkstack(L, nres + 1)))
luaL_error(L, "too many results to resume");
lua_xmove(co, L, nres); /* move yielded values */
return nres;
+2 -2
View File
@@ -73,7 +73,7 @@ static int db_getinfo (lua_State *L) {
}
else
return luaL_argerror(L, arg+1, "function or level expected");
if (!lua_getinfo(L1, options, &ar))
if (l_unlikely(!lua_getinfo(L1, options, &ar)))
return luaL_argerror(L, arg+2, "invalid option");
lua_createtable(L, 0, 2);
if (strchr(options, 'S')) {
@@ -104,7 +104,7 @@ static int db_getlocal (lua_State *L) {
lua_State *L1 = getthread(L, &arg);
lua_Debug ar;
const char *name;
if (!lua_getstack(L1, luaL_checkint(L, arg+1), &ar)) /* out of range? */
if (l_unlikely(!lua_getstack(L1, luaL_checkint(L, arg+1), &ar))) /* out of range? */
return luaL_argerror(L, arg+1, "level out of range");
name = lua_getlocal(L1, &ar, luaL_checkint(L, arg+2));
if (name) {
+13 -13
View File
@@ -172,7 +172,7 @@ void luaD_reallocCI (lua_State *L, int newsize) {
void luaD_growstack (lua_State *L, int n) {
if (n <= L->stacksize) /* double size is enough? */
if (l_likely(n <= L->stacksize)) /* double size is enough? */
luaD_reallocstack(L, 2*L->stacksize);
else
luaD_reallocstack(L, L->stacksize + n);
@@ -180,11 +180,11 @@ void luaD_growstack (lua_State *L, int n) {
static CallInfo *growCI (lua_State *L) {
if (L->size_ci > LUAI_MAXCALLS) /* overflow while handling overflow? */
if (l_unlikely(L->size_ci > LUAI_MAXCALLS)) /* overflow while handling overflow? */
luaD_throw(L, LUA_ERRERR);
else {
luaD_reallocCI(L, 2*L->size_ci);
if (L->size_ci > LUAI_MAXCALLS)
if (l_unlikely(L->size_ci > LUAI_MAXCALLS))
luaG_runerror(L, "stack overflow");
}
return ++L->ci;
@@ -257,7 +257,7 @@ static StkId tryfuncTM (lua_State *L, StkId func) {
const TValue *tm = luaT_gettmbyobj(L, func, TM_CALL);
StkId p;
ptrdiff_t funcr = savestack(L, func);
if (!ttisfunction(tm))
if (l_unlikely(!ttisfunction(tm)))
luaG_typeerror(L, func, "call");
/* Open a hole inside the stack at `func' */
for (p = L->top; p > func; p--) setobjs2s(L, p, p-1);
@@ -356,7 +356,7 @@ int luaD_poscall (lua_State *L, StkId firstResult) {
StkId res;
int wanted, i;
CallInfo *ci;
if (L->hookmask & LUA_MASKRET)
if (l_unlikely(L->hookmask) & LUA_MASKRET)
firstResult = callrethooks(L, firstResult);
ci = L->ci--;
res = ci->func; /* res == final position of 1st result */
@@ -380,7 +380,7 @@ int luaD_poscall (lua_State *L, StkId firstResult) {
** function position.
*/
void luaD_call (lua_State *L, StkId func, int nResults) {
if (++L->nCcalls >= LUAI_MAXCCALLS) {
if (l_unlikely(++L->nCcalls >= LUAI_MAXCCALLS)) {
if (L->nCcalls == LUAI_MAXCCALLS)
luaG_runerror(L, "C stack overflow");
else if (L->nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS>>3)))
@@ -430,15 +430,15 @@ static int resume_error (lua_State *L, const char *msg) {
LUA_API int lua_resume (lua_State *L, int nargs) {
int status;
lua_lock(L);
if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
if (l_unlikely(L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci)))
return resume_error(L, "cannot resume non-suspended coroutine");
if (L->nCcalls >= LUAI_MAXCCALLS)
if (l_unlikely(L->nCcalls >= LUAI_MAXCCALLS))
return resume_error(L, "C stack overflow");
luai_userstateresume(L, nargs);
lua_assert(L->errfunc == 0);
L->baseCcalls = ++L->nCcalls;
status = luaD_rawrunprotected(L, resume, L->top - nargs);
if (status != 0) { /* error? */
if (l_unlikely(status != 0)) { /* error? */
L->status = cast_byte(status); /* mark thread as `dead' */
luaD_seterrorobj(L, status, L->top);
L->ci->top = L->top;
@@ -456,7 +456,7 @@ LUA_API int lua_resume (lua_State *L, int nargs) {
LUA_API int lua_yield (lua_State *L, int nresults) {
luai_userstateyield(L, nresults);
lua_lock(L);
if (L->nCcalls > L->baseCcalls)
if (l_unlikely(L->nCcalls > L->baseCcalls))
luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
L->base = L->top - nresults; /* protect stack slots below */
L->status = LUA_YIELD;
@@ -474,7 +474,7 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u,
ptrdiff_t old_errfunc = L->errfunc;
L->errfunc = ef;
status = luaD_rawrunprotected(L, func, u);
if (status != 0) { /* an error occurred? */
if (l_unlikely(status != 0)) { /* an error occurred? */
StkId oldtop = restorestack(L, old_top);
luaF_close(L, oldtop); /* close eventual pending closures */
luaD_seterrorobj(L, status, oldtop);
@@ -511,8 +511,8 @@ static void f_parser (lua_State *L, void *ud) {
tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z,
&p->buff, p->name);
#else
if (c == LUA_SIGNATURE[0])
luaG_runerror(L, "invalid format, cannot load bytecode scripts");
if (l_unlikely(c == LUA_SIGNATURE[0]))
luaG_runerror(L, "invalid format, cannot load bytecode scripts");
tf = luaY_parser(L, p->z, &p->buff, p->name);
#endif
cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L)));
+1 -1
View File
@@ -14,7 +14,7 @@
#define luaD_checkstack(L,n) \
if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
if (l_unlikely((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue))) \
luaD_growstack(L, n); \
else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
+10 -10
View File
@@ -84,7 +84,7 @@ static int io_type (lua_State *L) {
static FILE *tofile (lua_State *L) {
FILE **f = tofilep(L);
if (*f == NULL)
if (l_unlikely(*f == NULL))
luaL_error(L, "attempt to use a closed file");
return *f;
}
@@ -184,8 +184,8 @@ static int io_open (lua_State *L) {
break;
}
}
if (strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\")
|| StartsWith(filename, "/") || !pass)
if (l_unlikely(strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\")
|| StartsWith(filename, "/") || !pass))
{
luaL_error(L,"access denied to %s", filename);
return pushresult(L,0,filename);
@@ -202,7 +202,7 @@ static int io_open (lua_State *L) {
{
*splitter = 0;
I_mkdir(destFilename, 0755);
*splitter = '/';
*splitter = '/';
splitter++;
forward = strchr(splitter, '/');
@@ -226,7 +226,7 @@ static FILE *getiofile (lua_State *L, int findex) {
FILE *f;
lua_rawgeti(L, LUA_ENVIRONINDEX, findex);
f = *(FILE **)lua_touserdata(L, -1);
if (f == NULL)
if (l_unlikely(f == NULL))
luaL_error(L, "standard %s file is closed", fnames[findex - 1]);
return f;
}
@@ -238,7 +238,7 @@ static int g_iofile (lua_State *L, int f, const char *mode) {
if (filename) {
FILE **pf = newfile(L);
*pf = fopen(filename, mode);
if (*pf == NULL)
if (l_unlikely(*pf == NULL))
fileerror(L, 1, filename);
}
else {
@@ -290,7 +290,7 @@ static int io_lines (lua_State *L) {
const char *filename = luaL_checkstring(L, 1);
FILE **pf = newfile(L);
*pf = fopen(filename, "r");
if (*pf == NULL)
if (l_unlikely(*pf == NULL))
fileerror(L, 1, filename);
aux_lines(L, lua_gettop(L), 1);
return 1;
@@ -307,7 +307,7 @@ static int io_lines (lua_State *L) {
static int read_number (lua_State *L, FILE *f) {
lua_Number d;
if (fscanf(f, LUA_NUMBER_SCAN, &d) == 1) {
if (l_likely(fscanf(f, LUA_NUMBER_SCAN, &d) == 1)) {
lua_pushnumber(L, d);
return 1;
}
@@ -454,7 +454,7 @@ static int g_write (lua_State *L, FILE *f, int arg) {
else {
size_t l;
const char *s = luaL_checklstring(L, arg, &l);
if (ftell(f) + l > FILELIMIT)
if (l_unlikely(ftell(f) + l > FILELIMIT))
{
luaL_error(L,"write limit bypassed in file. Changes have been discarded.");
break;
@@ -483,7 +483,7 @@ static int f_seek (lua_State *L) {
int op = luaL_checkoption(L, 2, "cur", modenames);
long offset = luaL_optlong(L, 3, 0);
op = fseek(f, offset, mode[op]);
if (op)
if (l_unlikely(op))
return pushresult(L, 0, NULL); /* error */
else {
lua_pushinteger(L, ftell(f));
+2 -2
View File
@@ -48,7 +48,7 @@ void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems,
void *newblock;
int newsize;
if (*size >= limit/2) { /* cannot double it? */
if (*size >= limit) /* cannot grow even a little? */
if (l_unlikely(*size >= limit)) /* cannot grow even a little? */
luaG_runerror(L, errormsg);
newsize = limit; /* still have at least one free place */
}
@@ -77,7 +77,7 @@ void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) {
global_State *g = G(L);
lua_assert((osize == 0) == (block == NULL));
block = (*g->frealloc)(g->ud, block, osize, nsize);
if (block == NULL && nsize > 0)
if (l_unlikely(block == NULL && nsize > 0))
luaD_throw(L, LUA_ERRMEM);
lua_assert((nsize == 0) == (block == NULL));
g->totalbytes = (g->totalbytes - osize) + nsize;
+6 -6
View File
@@ -103,7 +103,7 @@ static void checknext (LexState *ls, int c) {
static void check_match (LexState *ls, int what, int who, int where) {
if (!testnext(ls, what)) {
if (l_unlikely(!testnext(ls, what))) {
if (where == ls->linenumber)
error_expected(ls, what);
else {
@@ -275,7 +275,7 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
static void enterlevel (LexState *ls) {
if (++ls->L->nCcalls > LUAI_MAXCCALLS)
if (l_unlikely(++ls->L->nCcalls > LUAI_MAXCCALLS))
luaX_lexerror(ls, "chunk has too many syntax levels", 0);
}
@@ -643,7 +643,7 @@ static void funcargs (LexState *ls, expdesc *f) {
int line = ls->linenumber;
switch (ls->t.token) {
case '(': { /* funcargs -> `(' [ explist1 ] `)' */
if (line != ls->lastline)
if (l_unlikely(line != ls->lastline))
luaX_syntaxerror(ls,"ambiguous syntax (function call x new statement)");
luaX_next(ls);
if (ls->t.token == ')') /* arg list is empty? */
@@ -712,7 +712,7 @@ static void prefixexp (LexState *ls, expdesc *v) {
case '$': {
lua_Number i = ls->t.seminfo.r;
if (i == 0) i = ls->fs->nrhs;
if (i <= 0 || i > ls->fs->nlhs)
if (l_unlikely(i <= 0 || i > ls->fs->nlhs))
luaX_syntaxerror(ls, "pseudo-variable out of range or not in assignment");
else {
expdesc_list *lhs = ls->fs->lhs;
@@ -1105,7 +1105,7 @@ static void breakstat (LexState *ls, lua_Number n) {
upval |= bl->upval;
bl = bl->previous;
}
if (!bl)
if (l_unlikely(!bl))
luaX_syntaxerror(ls, "no loop to break");
if (upval)
luaK_codeABC(fs, OP_CLOSE, bl->nactvar, 0, 0);
@@ -1124,7 +1124,7 @@ static void continuestat (LexState *ls) {
//upval |= bl->upval; // AK: ADDITION (would this fix forbody probs?)
bl = bl->previous;
}
if (!bl)
if (l_unlikely(!bl))
luaX_syntaxerror(ls, "no loop to continue");
//if (upval) //AK: experimental
+2 -2
View File
@@ -83,7 +83,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
o != NULL;
o = o->gch.next) {
TString *ts = rawgco2ts(o);
if (ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0)) {
if (l_unlikely(ts->tsv.len == l && (memcmp(str, getstr(ts), l) == 0))) {
/* string may be dead */
if (isdead(G(L), o)) changewhite(o);
return ts;
@@ -95,7 +95,7 @@ TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
Udata *u;
if (s > MAX_SIZET - sizeof(Udata))
if (l_unlikely(s > MAX_SIZET - sizeof(Udata)))
luaM_toobig(L);
u = cast(Udata *, luaM_malloc(L, s + sizeof(Udata)));
u->uv.marked = luaC_white(G(L)); /* is not finalized */
+14 -12
View File
@@ -113,7 +113,7 @@ static int str_byte (lua_State *L) {
if ((size_t)pose > l) pose = l;
if (posi > pose) return 0; /* empty interval; return no values */
n = (int)(pose - posi + 1);
if (posi + n <= pose) /* overflow? */
if (l_unlikely(posi + n <= pose)) /* overflow? */
luaL_error(L, "string slice too long");
luaL_checkstack(L, n, "string slice too long");
for (i=0; i<n; i++)
@@ -187,7 +187,7 @@ typedef struct MatchState {
static int check_capture (MatchState *ms, int l) {
l -= '1';
if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
if (l_unlikely(l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED))
return luaL_error(ms->L, "invalid capture index");
return l;
}
@@ -204,14 +204,14 @@ static int capture_to_close (MatchState *ms) {
static const char *classend (MatchState *ms, const char *p) {
switch (*p++) {
case L_ESC: {
if (*p == '\0')
if (l_unlikely(*p == '\0'))
luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")");
return p+1;
}
case '[': {
if (*p == '^') p++;
do { /* look for a `]' */
if (*p == '\0')
if (l_unlikely(*p == '\0'))
luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")");
if (*(p++) == L_ESC && *p != '\0')
p++; /* skip escapes (e.g. `%]') */
@@ -282,7 +282,7 @@ static const char *match (MatchState *ms, const char *s, const char *p);
static const char *matchbalance (MatchState *ms, const char *s,
const char *p) {
if (*p == 0 || *(p+1) == 0)
if (l_unlikely(*p == 0 || *(p+1) == 0))
luaL_error(ms->L, "unbalanced pattern");
if (*s != *p) return NULL;
else {
@@ -332,7 +332,8 @@ static const char *start_capture (MatchState *ms, const char *s,
const char *p, int what) {
const char *res;
int level = ms->level;
if (level >= LUA_MAXCAPTURES) luaL_error(ms->L, "too many captures");
if (l_unlikely(level >= LUA_MAXCAPTURES))
luaL_error(ms->L, "too many captures");
ms->capture[level].init = s;
ms->capture[level].len = what;
ms->level = level+1;
@@ -386,7 +387,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) {
case 'f': { /* frontier? */
const char *ep; char previous;
p += 2;
if (*p != '[')
if (l_unlikely(*p != '['))
luaL_error(ms->L, "missing " LUA_QL("[") " after "
LUA_QL("%%f") " in pattern");
ep = classend(ms, p); /* points to what is next */
@@ -468,14 +469,15 @@ static const char *lmemfind (const char *s1, size_t l1,
static void push_onecapture (MatchState *ms, int i, const char *s,
const char *e) {
if (i >= ms->level) {
if (i == 0) /* ms->level == 0, too */
if (l_likely(i == 0)) /* ms->level == 0, too */
lua_pushlstring(ms->L, s, e - s); /* add whole match */
else
luaL_error(ms->L, "invalid capture index");
}
else {
ptrdiff_t l = ms->capture[i].len;
if (l == CAP_UNFINISHED) luaL_error(ms->L, "unfinished capture");
if (l_unlikely(l == CAP_UNFINISHED))
luaL_error(ms->L, "unfinished capture");
if (l == CAP_POSITION)
lua_pushinteger(ms->L, ms->capture[i].init - ms->src_init + 1);
else
@@ -637,7 +639,7 @@ static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
lua_pop(L, 1);
lua_pushlstring(L, s, e - s); /* keep original text */
}
else if (!lua_isstring(L, -1))
else if (l_unlikely(!lua_isstring(L, -1)))
luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
luaL_addvalue(b); /* add result to accumulator */
}
@@ -727,7 +729,7 @@ static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
const char *p = strfrmt;
while (*p != '\0' && strchr(FLAGS, *p) != NULL) p++; /* skip flags */
if ((size_t)(p - strfrmt) >= sizeof(FLAGS))
if (l_unlikely((size_t)(p - strfrmt) >= sizeof(FLAGS)))
luaL_error(L, "invalid format (repeated flags)");
if (isdigit(uchar(*p))) p++; /* skip width */
if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
@@ -736,7 +738,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
if (isdigit(uchar(*p))) p++; /* skip precision */
if (isdigit(uchar(*p))) p++; /* (2 digits at most) */
}
if (isdigit(uchar(*p)))
if (l_unlikely(isdigit(uchar(*p))))
luaL_error(L, "invalid format (width or precision too long)");
*(form++) = '%';
strncpy(form, strfrmt, p - strfrmt + 1);
+4 -3
View File
@@ -278,7 +278,7 @@ static void setnodevector (lua_State *L, Table *t, int size) {
else {
int i;
lsize = ceillog2(size);
if (lsize > MAXBITS)
if (l_unlikely(lsize > MAXBITS))
luaG_runerror(L, "table overflow");
size = twoto(lsize);
t->node = luaM_newvector(L, size, Node);
@@ -498,8 +498,9 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
if (p != luaO_nilobject)
return cast(TValue *, p);
else {
if (ttisnil(key)) luaG_runerror(L, "table index is nil");
else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
if (l_unlikely(ttisnil(key)))
luaG_runerror(L, "table index is nil");
else if (l_unlikely(ttisnumber(key) && luai_numisnan(nvalue(key))))
luaG_runerror(L, "table index is NaN");
return newkey(L, t, key);
}
+5 -3
View File
@@ -134,7 +134,7 @@ static int tremove (lua_State *L) {
static void addfield (lua_State *L, luaL_Buffer *b, int i) {
lua_rawgeti(L, 1, i);
if (!lua_isstring(L, -1))
if (l_unlikely(!lua_isstring(L, -1)))
luaL_error(L, "invalid value (%s) at index %d in table for "
LUA_QL("concat"), luaL_typename(L, -1), i);
luaL_addvalue(b);
@@ -224,12 +224,14 @@ static void auxsort (lua_State *L, int l, int u) {
for (;;) { /* invariant: a[l..i] <= P <= a[j..u] */
/* repeat ++i until a[i] >= P */
while (lua_rawgeti(L, 1, ++i), sort_comp(L, -1, -2)) {
if (i>u) luaL_error(L, "invalid order function for sorting");
if (l_unlikely(i>u))
luaL_error(L, "invalid order function for sorting");
lua_pop(L, 1); /* remove a[i] */
}
/* repeat --j until a[j] <= P */
while (lua_rawgeti(L, 1, --j), sort_comp(L, -3, -1)) {
if (j<l) luaL_error(L, "invalid order function for sorting");
if (l_unlikely(j<l))
luaL_error(L, "invalid order function for sorting");
lua_pop(L, 1); /* remove a[j] */
}
if (j<i) {
+17
View File
@@ -773,6 +773,23 @@ union luai_Cast { double l_d; long l_l; };
/* =================================================================== */
/*
* * macros to improve jump prediction, used mostly for error handling
** and debug facilities.
*/
#if !defined(l_likely)
#include <stdio.h>
#if defined(__GNUC__)
#define l_likely(x) (__builtin_expect(((x) != 0), 1))
#define l_unlikely(x) (__builtin_expect(((x) != 0), 0))
#else
#define l_likely(x) (x)
#define l_unlikely(x) (x)
#endif
#endif
/*
** Local configuration. You can use this space to add your redefinitions
** without modifying the main part of the file.
+12 -11
View File
@@ -119,7 +119,7 @@ void luaV_gettable (lua_State *L, TValue *t, TValue *key, StkId val) {
}
/* else will try the tag method */
}
else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))
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);
@@ -147,7 +147,7 @@ void luaV_settable (lua_State *L, TValue *t, TValue *key, StkId val) {
}
/* else will try the tag method */
}
else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))
else if (l_unlikely(ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX))))
luaG_typeerror(L, t, "index");
if (ttisfunction(tm)) {
callTM(L, tm, t, key, val);
@@ -293,7 +293,8 @@ void luaV_concat (lua_State *L, int total, int last) {
/* collect total length */
for (n = 1; n < total && tostring(L, top-n-1); n++) {
size_t l = tsvalue(top-n-1)->len;
if (l >= MAX_SIZET - tl) luaG_runerror(L, "string length overflow");
if (l_unlikely(l >= MAX_SIZET - tl))
luaG_runerror(L, "string length overflow");
tl += l;
}
buffer = luaZ_openspace(L, &G(L)->buff, tl);
@@ -322,8 +323,8 @@ static void Arith (lua_State *L, StkId ra, TValue *rb,
case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break;
case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break;
case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break;
case TM_DIV: if (nc == 0) { luaG_runerror(L, "divide by zero error"); } else setnvalue(ra, luai_numdiv(nb, nc)); break;
case TM_MOD: if (nc == 0) { luaG_runerror(L, "modulo by zero error"); } else setnvalue(ra, luai_nummod(nb, nc)); break;
case TM_DIV: if (l_unlikely(nc == 0)) { luaG_runerror(L, "divide by zero error"); } else setnvalue(ra, luai_numdiv(nb, nc)); break;
case TM_MOD: if (l_unlikely(nc == 0)) { luaG_runerror(L, "modulo by zero error"); } else setnvalue(ra, luai_nummod(nb, nc)); break;
case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
case TM_AND: setnvalue(ra, luai_numand(nb, nc)); break;
@@ -491,7 +492,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
TValue *rc = RKC(i);
if (ttisnumber(rb) && ttisnumber(rc)) {
lua_Number nb = nvalue(rb), nc = nvalue(rc);
if (nc == 0) {
if (l_unlikely(nc == 0)) {
luaG_runerror(L, "divide by zero error");
}
else
@@ -506,7 +507,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
TValue *rc = RKC(i);
if (ttisnumber(rb) && ttisnumber(rc)) {
lua_Number nb = nvalue(rb), nc = nvalue(rc);
if (nc == 0) {
if (l_unlikely(nc == 0)) {
luaG_runerror(L, "modulo by zero error");
}
else
@@ -580,7 +581,7 @@ void luaV_execute (lua_State *L, int nexeccalls) {
}
default: { /* try metamethod */
Protect(
if (!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN))
if (l_unlikely(!call_binTM(L, rb, luaO_nilobject, ra, TM_LEN)))
luaG_typeerror(L, rb, "get length of");
)
}
@@ -724,11 +725,11 @@ void luaV_execute (lua_State *L, int nexeccalls) {
const TValue *plimit = ra+1;
const TValue *pstep = ra+2;
L->savedpc = pc; /* next steps may throw errors */
if (!tonumber(init, ra))
if (l_unlikely(!tonumber(init, ra)))
luaG_runerror(L, LUA_QL("for") " initial value must be a number");
else if (!tonumber(plimit, ra+1))
else if (l_unlikely(!tonumber(plimit, ra+1)))
luaG_runerror(L, LUA_QL("for") " limit must be a number");
else if (!tonumber(pstep, ra+2))
else if (l_unlikely(!tonumber(pstep, ra+2)))
luaG_runerror(L, LUA_QL("for") " step must be a number");
if (ra && pstep)
setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
+844 -841
View File
File diff suppressed because it is too large. Load diff
+4 -3
View File
@@ -42,8 +42,8 @@ applications may follow different packet versions.
#define VANILLA_GT_MATCH 3
// Networking and tick handling related.
#define BACKUPTICS 32
#define TICQUEUE 512 // more than enough for most timeouts....
#define BACKUPTICS 512 // more than enough for most timeouts....
#define CLIENTBACKUPTICS 32
#define MAXTEXTCMD 256
// No. of tics your controls can be delayed by.
@@ -533,7 +533,6 @@ extern UINT32 serverlistultimatecount;
extern INT32 mapchangepending;
// Points inside doomcom
extern doomdata_t *netbuffer;
extern consvar_t cv_stunserver;
extern consvar_t cv_httpsource;
extern consvar_t cv_kicktime;
@@ -671,6 +670,8 @@ SINT8 nametonum(const char *name);
extern char motd[254], server_context[8];
extern UINT8 playernode[MAXPLAYERS];
extern boolean player_muted[MAXPLAYERS];
INT32 D_NumPlayers(void);
void D_ResetTiccmds(void);
+22 -4
View File
@@ -152,6 +152,8 @@ boolean dedicated = false;
boolean loaded_config = false; // true once config.cfg loaded AND executed
static void D_CleanFile(char **filearray);
//
// D_PostEvent
// Called by the I/O functions when input is detected
@@ -896,9 +898,25 @@ void D_SRB2Loop(void)
rendertimefrac_unpaused = FRACUNIT;
}
if ((interp || doDisplay) && !frameskip)
if (interp || doDisplay)
{
ranwipe = D_Display();
if (!frameskip)
{
ranwipe = D_Display();
}
else if (frameskip)
{
// always update console and hud
// otherwise it may take minutes to open it
CON_Drawer();
if (gamestate == GS_LEVEL)
{
ST_Drawer();
HU_Drawer();
}
}
}
// Only take screenshots after drawing.
@@ -1215,7 +1233,7 @@ void D_AddPostloadFiles(void)
postautoloaded = true;
}
void D_CleanFile(char **filearray)
static void D_CleanFile(char **filearray)
{
size_t pnumwadfiles;
for (pnumwadfiles = 0; filearray[pnumwadfiles]; pnumwadfiles++)
@@ -1478,7 +1496,7 @@ static void D_CheckSaturnExtraFiles(void)
}
// extra round joystick inputdisplay sprites
if (W_CheckMultipleLumps("JOYBCK","JOYKNB","JOYSHD", NULL))
if (W_CheckMultipleLumps("JOYBCK", "JOYKNB", "JOYSHD", NULL))
{
joystickicon = true;
PUSHCONS(inputdisplay_cons_temp, last_inputdisplay_i, 3, "StickGFX");
-2
View File
@@ -85,8 +85,6 @@ void D_PostEvent(const event_t *ev);
void D_ProcessEvents(void);
void D_CleanFile(char **filearray);
const char *D_Home(void);
//
+34 -29
View File
@@ -48,12 +48,6 @@ tic_t connectiontimeout = (10*TICRATE);
/// \brief network packet
doomcom_t *doomcom = NULL;
/// \brief network packet data, points inside doomcom
doomdata_t *netbuffer = NULL;
/// \brief hole punching packet, also points inside doomcom
#ifdef HOLEPUNCH
holepunch_t *holepunchpacket = NULL;
#endif
#ifdef DEBUGFILE
FILE *debugfile = NULL; // put some net info in a file during the game
@@ -209,13 +203,9 @@ static node_t nodes[MAXNETNODES];
// 0 if a = n (mod 256)
// >0 if a > b (mod 256)
// mnemonic: to use it compare to 0: cmpack(a,b)<0 is "a < b" ...
FUNCMATH static INT32 cmpack(UINT8 a, UINT8 b)
FUNCMATH static inline INT32 cmpack(UINT8 a, UINT8 b)
{
register INT32 d = a - b;
if (d >= 127 || d < -128)
return -d;
return d;
return (SINT8)(a - b);
}
/** Sets freeack to a free acknum and copies the netbuffer in the ackpak table
@@ -229,6 +219,8 @@ static boolean GetFreeAcknum(UINT8 *freeack)
node_t *node = &nodes[doomcom->remotenode];
INT32 i, numfreeslot = 0;
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
if (cmpack((UINT8)((node->remotefirstack + MAXACKTOSEND) % 256), node->nextacknum) < 0)
{
DEBFILE(va("too fast %d %d\n",node->remotefirstack,node->nextacknum));
@@ -298,6 +290,7 @@ static boolean Processackpak(void)
INT32 i;
boolean goodpacket = true;
node_t *node = &nodes[doomcom->remotenode];
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
// Received an ack return, so remove the ack in the list
if (netbuffer->ackreturn && cmpack(node->remotefirstack, netbuffer->ackreturn) < 0)
@@ -307,7 +300,7 @@ static boolean Processackpak(void)
// Search the ackbuffer and free it
for (i = 0; i < MAXACKPACKETS; i++)
{
if (ackpak[i].acknum && ackpak[i].destinationnode == node - nodes
if (ackpak[i].acknum && ackpak[i].destinationnode == doomcom->remotenode
&& cmpack(ackpak[i].acknum, netbuffer->ackreturn) <= 0)
{
RemoveAck(i);
@@ -423,6 +416,7 @@ void Net_SendAcks(INT32 node)
#ifdef NONET
(void)node;
#else
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
netbuffer->packettype = PT_NOTHING;
M_Memcpy(netbuffer->u.textcmd, nodes[node].acktosend, MAXACKTOSEND);
HSendPacket(node, false, 0, MAXACKTOSEND);
@@ -434,6 +428,8 @@ static void GotAcks(void)
{
INT32 i, j;
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
for (j = 0; j < MAXACKTOSEND; j++)
{
if (netbuffer->u.textcmd[j])
@@ -487,6 +483,8 @@ void Net_AckTicker(void)
#ifndef NONET
INT32 i;
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
for (i = 0; i < MAXACKPACKETS; i++)
{
const INT32 nodei = ackpak[i].destinationnode;
@@ -542,6 +540,7 @@ void Net_UnAcknowledgePacket(INT32 node)
#ifdef NONET
(void)node;
#else
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
INT32 hm1 = (nodes[node].acktosend_head-1+MAXACKTOSEND) % MAXACKTOSEND;
DEBFILE(va("UnAcknowledge node %d\n", node));
@@ -736,6 +735,7 @@ void Net_CloseConnection(INT32 node)
//
static UINT32 NetbufferChecksum(void)
{
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
UINT32 c = 0x1234567;
const INT32 l = doomcom->datalength - 4;
const UINT8 *buf = (UINT8 *)netbuffer + 4;
@@ -852,6 +852,8 @@ const char *Net_GetPacketName(UINT8 packettype)
static void DebugPrintpacket(const char *header)
{
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
fprintf(debugfile, "%-12s (node %d,ack %d,ackret %d,size %d) type(%d) : %s\n",
header, doomcom->remotenode, netbuffer->ack, netbuffer->ackreturn, doomcom->datalength,
netbuffer->packettype, Net_GetPacketName(netbuffer->packettype));
@@ -1021,6 +1023,7 @@ void Command_Droprate(void)
#ifndef NONET
static boolean ShouldDropPacket(void)
{
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
return (packetdropquantity[netbuffer->packettype])
|| (packetdroprate != 0 && rand() < (((double)RAND_MAX) * (packetdroprate / 100.f))) || packetdroprate == 100;
}
@@ -1032,6 +1035,7 @@ static boolean ShouldDropPacket(void)
//
boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlength)
{
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
doomcom->datalength = (INT16)(packetlength + BASEPACKETSIZE);
if (node == 0) // Packet is to go back to us
@@ -1132,7 +1136,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen
//
boolean HGetPacket(void)
{
//boolean nodejustjoined;
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
// Get a packet from self
if (rebound_tail != rebound_head)
@@ -1220,6 +1224,18 @@ static void Internal_FreeNodenum(INT32 nodenum)
(void)nodenum;
}
static char *I_NetSplitAddress(char *host, char **port)
{
boolean v4 = (host[0] != '[');
host = strtok(host, v4 ? ":" : "[]");
if (port)
*port = strtok(NULL, ":");
return host;
}
SINT8 I_NetMakeNode(const char *hostname)
{
SINT8 newnode = -1;
@@ -1227,20 +1243,14 @@ SINT8 I_NetMakeNode(const char *hostname)
if (I_NetMakeNodewPort)
{
char *localhostname = strdup(hostname);
char *t = localhostname;
const char *port;
char *port;
if (!localhostname)
return newnode;
// retrieve portnum from address!
strtok(localhostname, ":");
port = strtok(NULL, ":");
hostname = I_NetSplitAddress(localhostname, &port);
// remove the port in the hostname as we've it already
while ((*t != ':') && (*t != '\0'))
t++;
*t = '\0';
newnode = I_NetMakeNodewPort(localhostname, port);
newnode = I_NetMakeNodewPort(hostname, port);
free(localhostname);
}
return newnode;
@@ -1332,11 +1342,6 @@ boolean D_CheckNetGame(void)
if (doomcom->numnodes > MAXNETNODES)
I_Error("Too many nodes (%d), max:%d", doomcom->numnodes, MAXNETNODES);
netbuffer = (doomdata_t *)(void *)&doomcom->data;
#ifdef HOLEPUNCH
holepunchpacket = (holepunch_t *)(void *)&doomcom->data;
#endif
#ifdef DEBUGFILE
if (M_CheckParm("-debugfile"))
{
+4 -4
View File
@@ -1026,6 +1026,7 @@ void D_RegisterClientCommands(void)
CV_RegisterVar(&cv_scr_height);
CV_RegisterVar(&cv_parallelsoftware);
CV_RegisterVar(&cv_paralleldrawmasked);
CV_RegisterVar(&cv_soundtest);
@@ -2082,7 +2083,7 @@ static void Command_ResetCamera_f(void)
}
/* Consider replacing nametonum with this */
static INT32 LookupPlayer(const char *s)
INT32 D_LookupPlayer(const char *s)
{
INT32 playernum;
@@ -2098,8 +2099,7 @@ static INT32 LookupPlayer(const char *s)
for (playernum = 0; playernum < MAXPLAYERS; ++playernum)
{
/* Match name case-insensitively: fully, or partially the start. */
if (playeringame[playernum])
if (strnicmp(player_names[playernum], s, strlen(s)) == 0)
if (playeringame[playernum] && (strnicmp(player_names[playernum], s, strlen(s)) == 0))
{
return playernum;
}
@@ -2210,7 +2210,7 @@ static void Command_View_f(void)
}
else
{
if (( playernum = LookupPlayer(COM_Argv(1)) ) == -1)
if (( playernum = D_LookupPlayer(COM_Argv(1)) ) == -1)
{
CONS_Alert(CONS_WARNING, "There is no player by that name!\n");
return;
+1
View File
@@ -323,6 +323,7 @@ void ClearAdminPlayers(void);
void RemoveAdminPlayer(INT32 playernum);
void ItemFinder_OnChange(void);
void D_SetPassword(const char *pw);
INT32 D_LookupPlayer(const char *s);
// used for the player setup menu
UINT8 CanChangeSkin(INT32 playernum);
+18
View File
@@ -142,6 +142,7 @@ UINT8 *PutFileNeeded(UINT16 firstfile)
{
size_t i;
UINT8 count = 0;
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
UINT8 *p_start = netbuffer->packettype == PT_MOREFILESNEEDED ? netbuffer->u.filesneededcfg.files : netbuffer->u.serverinfo.fileneeded;
UINT8 *p = p_start;
char wadfilename[MAX_WADPATH] = "";
@@ -323,6 +324,7 @@ boolean CL_SendRequestFile(void)
#ifdef MORELEGACYDOWNLOADER
boolean firstloop = true;
#endif
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
#ifdef PARANOIA
if (M_CheckParm("-nodownload"))
@@ -451,9 +453,11 @@ tryagain:
// returns false if a requested file was not found or cannot be sent
boolean Got_RequestFilePak(INT32 node)
{
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
char wad[MAX_WADPATH+1];
UINT8 *p = netbuffer->u.textcmd;
UINT8 id;
while (p < netbuffer->u.textcmd + MAXTEXTCMD) // Don't allow hacked client to overflow
{
id = READUINT8(p);
@@ -817,6 +821,7 @@ void SV_FileSendTicker(void)
size_t size;
filetx_t *f;
INT32 packetsent, ram, i, j;
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
if (!filestosend) // No file to send
return;
@@ -945,6 +950,7 @@ void SV_FileSendTicker(void)
void Got_Filetxpak(void)
{
doomdata_t *netbuffer = DOOMCOM_DATA(doomcom);
INT32 filenum = netbuffer->u.filetxpak.fileid;
fileneeded_t *file = &fileneeded[filenum];
char *filename = file->filename;
@@ -1185,6 +1191,18 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet
badmd5 = true;
// if not found at all, just move on without doing anything
if (cv_addons_option.value == 3 && *cv_addons_folder.string != '\0')
{
// next, check any custom directory if specified
homecheck = filesearch(filename, cv_addons_folder.string, wantedmd5sum, completepath, 10);
if (homecheck == FS_FOUND) // we found the file, so return that we have :)
return FS_FOUND;
else if (homecheck == FS_MD5SUMBAD) // file has a bad md5; move on and look for a file with the right md5
badmd5 = true;
// if not found at all, just move on without doing anything
}
// finally check "." directory
homecheck = filesearch(filename, ".", wantedmd5sum, completepath, 10);
+14 -14
View File
@@ -446,19 +446,19 @@ extern UINT16 spacetimetics;
extern UINT16 extralifetics;
// SRB2kart
extern tic_t introtime;
extern tic_t starttime;
extern tic_t raceexittime;
extern tic_t battleexittime;
extern INT32 hyudorotime;
extern INT32 stealtime;
extern INT32 sneakertime;
extern INT32 itemtime;
extern INT32 comebacktime;
extern INT32 bumptime;
extern INT32 wipeoutslowtime;
extern INT32 wantedreduce;
extern INT32 wantedfrequency;
extern const tic_t introtime;
extern const tic_t starttime;
extern const tic_t raceexittime;
extern const tic_t battleexittime;
extern const INT32 hyudorotime;
extern const INT32 stealtime;
extern const INT32 sneakertime;
extern const INT32 itemtime;
extern const INT32 comebacktime;
extern const INT32 bumptime;
extern const INT32 wipeoutslowtime;
extern const INT32 wantedreduce;
extern const INT32 wantedfrequency;
extern UINT8 introtoplay;
extern UINT8 creditscutscene;
@@ -575,7 +575,7 @@ extern consvar_t cv_downloading; // allow clients to downloading WADs.
extern consvar_t cv_nettimeout; // SRB2Kart: Advanced server options menu
extern consvar_t cv_jointimeout;
extern consvar_t cv_maxping;
extern ticcmd_t netcmds[TICQUEUE][MAXPLAYERS];
extern ticcmd_t netcmds[BACKUPTICS][MAXPLAYERS];
extern INT32 serverplayer;
extern INT32 adminplayers[MAXPLAYERS];
+2
View File
@@ -540,6 +540,8 @@ static const char *credits[] = {
"\"Jin\"",
"\"riomccloud\"",
"\"chromaticpipe\"",
"\"PAS\"",
"\"$HOME\"",
"\"Achii\"",
"\"Anonimus\"",
"\"scizor300\"",
+48 -45
View File
@@ -196,19 +196,19 @@ UINT16 spacetimetics = 11*TICRATE + (TICRATE/2);
UINT16 extralifetics = 4*TICRATE;
// SRB2kart
tic_t introtime = 108+5; // plus 5 for white fade
tic_t starttime = 6*TICRATE + (3*TICRATE/4);
tic_t raceexittime = 5*TICRATE + (2*TICRATE/3);
tic_t battleexittime = 8*TICRATE;
INT32 hyudorotime = 7*TICRATE;
INT32 stealtime = TICRATE/2;
INT32 sneakertime = TICRATE + (TICRATE/3);
INT32 itemtime = 8*TICRATE;
INT32 comebacktime = 10*TICRATE;
INT32 bumptime = 6;
INT32 wipeoutslowtime = 20;
INT32 wantedreduce = 5*TICRATE;
INT32 wantedfrequency = 10*TICRATE;
const tic_t introtime = 108+5; // plus 5 for white fade
const tic_t starttime = 6*TICRATE + (3*TICRATE/4);
const tic_t raceexittime = 5*TICRATE + (2*TICRATE/3);
const tic_t battleexittime = 8*TICRATE;
const INT32 hyudorotime = 7*TICRATE;
const INT32 stealtime = TICRATE/2;
const INT32 sneakertime = TICRATE + (TICRATE/3);
const INT32 itemtime = 8*TICRATE;
const INT32 comebacktime = 10*TICRATE;
const INT32 bumptime = 6;
const INT32 wipeoutslowtime = 20;
const INT32 wantedreduce = 5*TICRATE;
const INT32 wantedfrequency = 10*TICRATE;
INT32 gameovertics = 15*TICRATE;
@@ -681,47 +681,49 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player)
INT32 axisval;
boolean flp = false;
UINT8 pnum = player-1;
//find what axis to get
switch (axissel)
{
case AXISTURN:
axisval = cv_turnaxis[player-1].value;
axisval = cv_turnaxis[pnum].value;
break;
case AXISMOVE:
axisval = cv_moveaxis[player-1].value;
axisval = cv_moveaxis[pnum].value;
break;
case AXISCAMTURN:
axisval = cv_camturnaxis[player-1].value;
axisval = cv_camturnaxis[pnum].value;
break;
case AXISCAMSTRAFE:
axisval = cv_camstrafeaxis[player-1].value;
axisval = cv_camstrafeaxis[pnum].value;
break;
case AXISBRAKE:
axisval = cv_brakeaxis[player-1].value;
axisval = cv_brakeaxis[pnum].value;
break;
case AXISAIM:
axisval = cv_aimaxis[player-1].value;
axisval = cv_aimaxis[pnum].value;
break;
case AXISLOOK:
axisval = cv_lookaxis[player-1].value;
axisval = cv_lookaxis[pnum].value;
break;
case AXISFIRE:
axisval = cv_fireaxis[player-1].value;
axisval = cv_fireaxis[pnum].value;
break;
case AXISDRIFT:
axisval = cv_driftaxis[player-1].value;
axisval = cv_driftaxis[pnum].value;
break;
case AXISLOOKBACK:
axisval = cv_lookbackaxis[player-1].value;
axisval = cv_lookbackaxis[pnum].value;
break;
case AXISCUSTOM1:
axisval = cv_custom1axis[player-1].value;
axisval = cv_custom1axis[pnum].value;
break;
case AXISCUSTOM2:
axisval = cv_custom2axis[player-1].value;
axisval = cv_custom2axis[pnum].value;
break;
case AXISCUSTOM3:
axisval = cv_custom3axis[player-1].value;
axisval = cv_custom3axis[pnum].value;
break;
default:
return 0;
@@ -732,44 +734,51 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player)
axisval = -axisval;
flp = true;
}
if (axisval > JOYAXISSET*2 || axisval == 0) //not there in array or None
return 0;
if (axisval%2)
if (axisval % 2)
{
axisval /= 2;
retaxis = joyxmove[axisval];
retaxis = joyxmove[pnum][axisval];
if (retaxis < (-JOYAXISRANGE))
retaxis = -JOYAXISRANGE;
if (retaxis > (+JOYAXISRANGE))
retaxis = +JOYAXISRANGE;
if (!Joystick[player-1].bGamepadStyle && axissel < AXISDEAD)
if (!Joystick[pnum].bGamepadStyle && axissel < AXISDEAD)
{
const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_xdeadzone[player-1].value) >> FRACBITS;
const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_xdeadzone[pnum].value) >> FRACBITS;
if (abs(retaxis) <= jdeadzone)
return 0;
}
if (flp) retaxis = -retaxis; //flip it around
if (flp)
retaxis = -retaxis; // flip it around
return retaxis;
}
else
{
axisval--;
axisval /= 2;
retaxis = joyymove[axisval];
retaxis = joyymove[pnum][axisval];
if (retaxis < (-JOYAXISRANGE))
retaxis = -JOYAXISRANGE;
if (retaxis > (+JOYAXISRANGE))
retaxis = +JOYAXISRANGE;
if (!Joystick[player-1].bGamepadStyle && axissel < AXISDEAD)
if (!Joystick[pnum].bGamepadStyle && axissel < AXISDEAD)
{
const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_ydeadzone[player-1].value) >> FRACBITS;
const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_ydeadzone[pnum].value) >> FRACBITS;
if (abs(retaxis) <= jdeadzone)
return 0;
}
if (flp) retaxis = -retaxis; //flip it around
if (flp)
retaxis = -retaxis; // flip it around
return retaxis;
}
}
@@ -1216,15 +1225,9 @@ static void G_DoLoadLevel(boolean resetplayer)
}
// clear cmd building stuff
memset(gamekeydown, 0, sizeof (gamekeydown));
for (i = 0; i < JOYAXISSET; i++)
{
joyxmove[i] = joyymove[i] = 0;
joy2xmove[i] = joy2ymove[i] = 0;
joy3xmove[i] = joy3ymove[i] = 0;
joy4xmove[i] = joy4ymove[i] = 0;
}
memset(gamekeydown, 0, sizeof(gamekeydown));
memset(joyxmove, 0, sizeof(joyxmove));
memset(joyymove, 0, sizeof(joyymove));
mousex = mousey = 0;
// clear hud messages remains (usually from game startup)
@@ -1784,7 +1787,7 @@ void G_Ticker(boolean run)
}
}
buf = gametic % TICQUEUE;
buf = gametic % BACKUPTICS;
if (!demo.playback)
{
+9 -19
View File
@@ -114,8 +114,7 @@ INT32 mousex, mousey;
INT32 mlooky; // like mousey but with a custom sensitivity for mlook
// joystick values are repeated
INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], joy2ymove[JOYAXISSET],
joy3xmove[JOYAXISSET], joy3ymove[JOYAXISSET], joy4xmove[JOYAXISSET], joy4ymove[JOYAXISSET];
INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
// current state of the keys: true if pushed
UINT8 gamekeydown[NUMINPUTS];
@@ -187,32 +186,32 @@ void G_MapEventsToControls(event_t *ev)
i = ev->data1;
if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on)
break;
if (ev->data2 != INT32_MAX) joyxmove[i] = ev->data2;
if (ev->data3 != INT32_MAX) joyymove[i] = ev->data3;
if (ev->data2 != INT32_MAX) joyxmove[0][i] = ev->data2;
if (ev->data3 != INT32_MAX) joyymove[0][i] = ev->data3;
break;
case ev_joystick2: // buttons are virtual keys
i = ev->data1;
if (i >= JOYAXISSET || menuactive)
break;
if (ev->data2 != INT32_MAX) joy2xmove[i] = ev->data2;
if (ev->data3 != INT32_MAX) joy2ymove[i] = ev->data3;
if (ev->data2 != INT32_MAX) joyxmove[1][i] = ev->data2;
if (ev->data3 != INT32_MAX) joyymove[1][i] = ev->data3;
break;
case ev_joystick3:
i = ev->data1;
if (i >= JOYAXISSET)
break;
if (ev->data2 != INT32_MAX) joy3xmove[i] = ev->data2;
if (ev->data3 != INT32_MAX) joy3ymove[i] = ev->data3;
if (ev->data2 != INT32_MAX) joyxmove[2][i] = ev->data2;
if (ev->data3 != INT32_MAX) joyymove[2][i] = ev->data3;
break;
case ev_joystick4:
i = ev->data1;
if (i >= JOYAXISSET)
break;
if (ev->data2 != INT32_MAX) joy4xmove[i] = ev->data2;
if (ev->data3 != INT32_MAX) joy4ymove[i] = ev->data3;
if (ev->data2 != INT32_MAX) joyxmove[3][i] = ev->data2;
if (ev->data3 != INT32_MAX) joyymove[3][i] = ev->data3;
break;
default:
@@ -258,15 +257,6 @@ void G_ResetControls(void)
memset(joyxmove, 0, sizeof(joyxmove));
memset(joyymove, 0, sizeof(joyymove));
memset(joy2xmove, 0, sizeof(joy2xmove));
memset(joy2ymove, 0, sizeof(joy2ymove));
memset(joy3xmove, 0, sizeof(joy3xmove));
memset(joy3ymove, 0, sizeof(joy3ymove));
memset(joy4xmove, 0, sizeof(joy4xmove));
memset(joy4ymove, 0, sizeof(joy4ymove));
// reset those just in case the game missed the keyup event
memset(dpadscrollstate, false, sizeof(dpadscrollstate));
}
+8 -5
View File
@@ -41,10 +41,12 @@ typedef enum
KEY_DBLJOY1 = KEY_DBLMOUSE1 + MOUSEBUTTONS,
KEY_DBLHAT1 = KEY_DBLJOY1 + JOYBUTTONS,
KEY_2JOY1 = KEY_DBLHAT1 + MOUSEBUTTONS,
KEY_2MOUSE1 = KEY_DBLHAT1 + JOYHATS*4,
KEY_2JOY1 = KEY_2MOUSE1 + MOUSEBUTTONS,
KEY_2HAT1 = KEY_2JOY1 + JOYBUTTONS,
KEY_DBL2JOY1 = KEY_2HAT1 + MOUSEBUTTONS,
KEY_DBL2MOUSE1 = KEY_2HAT1 + JOYHATS*4,
KEY_DBL2JOY1 = KEY_DBL2MOUSE1 + MOUSEBUTTONS,
KEY_DBL2HAT1 = KEY_DBL2JOY1 + JOYBUTTONS,
KEY_3JOY1 = KEY_DBL2HAT1 + JOYHATS*4,
@@ -61,8 +63,10 @@ typedef enum
KEY_MOUSEWHEELUP = KEY_DBL4HAT1 + JOYHATS*4,
KEY_MOUSEWHEELDOWN = KEY_MOUSEWHEELUP + 1,
KEY_2MOUSEWHEELUP = KEY_MOUSEWHEELDOWN + 1,
KEY_2MOUSEWHEELDOWN = KEY_2MOUSEWHEELUP + 1,
NUMINPUTS = KEY_MOUSEWHEELDOWN + 1,
NUMINPUTS = KEY_2MOUSEWHEELDOWN + 1, // FIXME: all the mouse 2 stuff should be removed, but it screws up mappings somehow
} key_input_e;
typedef enum
@@ -113,8 +117,7 @@ extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS];
extern INT32 mousex, mousey;
extern INT32 mlooky; //mousey with mlookSensitivity
extern INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], joy2ymove[JOYAXISSET],
joy3xmove[JOYAXISSET], joy3ymove[JOYAXISSET], joy4xmove[JOYAXISSET], joy4ymove[JOYAXISSET];
extern INT32 joyxmove[MAXSPLITSCREENPLAYERS][JOYAXISSET], joyymove[MAXSPLITSCREENPLAYERS][JOYAXISSET];
// current state of the keys: true if pushed
extern UINT8 gamekeydown[NUMINPUTS];
+3 -2
View File
@@ -161,7 +161,7 @@ static boolean SameVertice (polyvertex_t *p1, polyvertex_t *p2)
return false;
#else
#define DIVLINE_VERTEX_DIFF 0.45f
float ep = DIVLINE_VERTEX_DIFF;
static const float ep = DIVLINE_VERTEX_DIFF;
if (fabsf( p2->x - p1->x ) > ep )
return false;
if (fabsf( p2->y - p1->y ) > ep )
@@ -283,6 +283,7 @@ static void SplitPoly (fdivline_t *bsp, //splitting parametric line
*backpoly = NULL;
return;
}
if (pe <= ps)
I_Error("SplitPoly: invalid splitting line (%d %d)", ps, pe);
@@ -368,7 +369,7 @@ static poly_t *CutOutSubsecPoly(seg_t *lseg, INT32 count, poly_t *poly)
for (; count--; lseg++)
{
//x,y,dx,dy (like a divline)
line_t *line = lseg->linedef;
const line_t *line = lseg->linedef;
// portal check
if (!gl_maphasportals && line->special == PORTALSPECIAL && lseg->side == 0)
+1 -1
View File
@@ -121,7 +121,7 @@ static clipnode_t * gld_clipnode_NewRange(angle_t start, angle_t end)
boolean gld_clipper_SafeCheckRange(angle_t startAngle, angle_t endAngle)
{
if(startAngle > endAngle)
if (startAngle > endAngle)
{
return (gld_clipper_IsRangeVisible(startAngle, ANGLE_MAX) || gld_clipper_IsRangeVisible(0, endAngle));
}
+107 -96
View File
@@ -746,7 +746,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
for (i = 0; i < subsector->numlines; i++, line++)
{
if (line->linedef->special != HORIZONSPECIAL)
// this check sucks and is a hotspot lel
if (LIKELY(line->linedef->special != HORIZONSPECIAL))
continue;
if (R_PointOnSegSide(viewx, viewy, line) != 0)
@@ -762,8 +763,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool
}
else
{
x1 = FixedToFloat(line->v1->x);
y1 = FixedToFloat(line->v1->x);
x1 = y1 = FixedToFloat(line->v1->x);
}
if (line->pv2)
@@ -1049,7 +1049,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
if ((endtop < endrealbot) && (top < realbot))
return;
lightlist_t *list = sector->lightlist;
const lightlist_t *list = sector->lightlist;
if (!(list[i].flags & FF_NOSHADE))
{
@@ -1387,9 +1387,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
wallVerts[2].z = wallVerts[1].z = ve.y;
// x offset the texture
fixed_t texturehpeg = gl_sidedef->textureoffset + gl_curline->offset;
float cliplow = (float)texturehpeg;
float cliphigh = (float)(texturehpeg + (gl_curline->flength*FRACUNIT));
const fixed_t texturehpeg = gl_sidedef->textureoffset + gl_curline->offset;
const float cliplow = (float)texturehpeg;
const float cliphigh = (float)(texturehpeg + (gl_curline->flength*FRACUNIT));
FUINT lightnum = gl_frontsector->lightlevel;
extracolormap_t *colormap = gl_frontsector->extra_colormap;
@@ -1400,7 +1400,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
if (gl_frontsector)
Surf.PolyColor.s.alpha = 255;
INT32 gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture);
const INT32 gl_midtexture = R_GetTextureNum(gl_sidedef->midtexture);
GLMapTexture_t *glTex = NULL;
// two sided line
@@ -1678,7 +1678,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
}
// Find the wall's coordinates
fixed_t midtexheight = textureheight[gl_midtexture] * repeats;
const fixed_t midtexheight = textureheight[gl_midtexture] * repeats;
if (gl_linedef->flags & ML_EFFECT2)
{
@@ -2004,6 +2004,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom
wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX;
wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX;
}
FBITFIELD blendmode;
if (roverflags & FF_FOG)
@@ -3296,7 +3297,7 @@ static gl_vissprite_t gl_overflowsprite;
static gl_vissprite_t *HWR_GetVisSprite(UINT32 num)
{
UINT32 chunk = num >> VISSPRITECHUNKBITS;
const UINT32 chunk = num >> VISSPRITECHUNKBITS;
// Allocate chunk if necessary
if (!gl_visspritechunks[chunk])
@@ -3316,7 +3317,7 @@ static gl_vissprite_t *HWR_NewVisSprite(void)
// Finds a floor through which light does not pass.
static fixed_t HWR_OpaqueFloorAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
{
const sector_t *sec = R_PointInSubsector(x, y)->sector;
const sector_t *sec = R_PointInSubsectorFast(x, y)->sector;
fixed_t floorz = sec->floorheight;
if (sec->ffloors)
@@ -3358,13 +3359,6 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
fixed_t slopez;
float offset = 0;
// technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again
const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES);
if (spr->mobj)
this_scale = FixedToFloat(spr->mobj->scale);
if (hires)
this_scale = this_scale * FixedToFloat(K_GetMobjSkin(spr->mobj)->highresscale);
R_GetShadowZ(spr->mobj, &floorslope);
mobjfloor = HWR_OpaqueFloorAtPos(
@@ -3415,6 +3409,14 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, patch_t *gpatch, GLPatch_t
else
floorheight = FixedInt(spr->mobj->z - mobjfloor);
// technically this_scale gets multiplied and added to sprite y/x scale, but this thing needs it for some crap so ill just throw it in here again
const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES);
if (spr->mobj)
this_scale = FixedToFloat(spr->mobj->scale);
if (hires)
this_scale = this_scale * FixedToFloat(K_GetMobjSkin(spr->mobj)->highresscale);
// create the sprite billboard
//
// 3--2
@@ -3732,6 +3734,9 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite)
blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude;
}
if (cv_playerfade.value && spr->mobj->player)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha);
if (HWR_UseShader())
{
shader = SHADER_SPRITE;
@@ -3886,11 +3891,13 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
INT32 shader = SHADER_NONE;
if (!spr->mobj || !spr->mobj->subsector)
const mobj_t *sprmo = spr->mobj;
if (UNLIKELY(!sprmo || !sprmo->subsector))
return;
const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE);
const sector_t *sector = spr->mobj->subsector->sector;
const boolean papersprite = (sprmo->frame & FF_PAPERSPRITE);
const sector_t *sector = sprmo->subsector->sector;
if (sector->numlights)
{
@@ -3956,9 +3963,9 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
// Draw shadow BEFORE sprite
if (UNLIKELY(cv_shadow.value // Shadows enabled
&& (spr->mobj->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow.
&& !(spr->mobj->flags2 & MF2_DEBRIS) // Debris have no corona or shadow.
&& (spr->mobj->z >= spr->mobj->floorz))) // Without this, your shadow shows on the floor, even after you die and fall through the ground.
&& (sprmo->flags & (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY)) != (MF_SCENERY|MF_SPAWNCEILING|MF_NOGRAVITY) // Ceiling scenery have no shadow.
&& !(sprmo->flags2 & MF2_DEBRIS) // Debris have no corona or shadow.
&& (sprmo->z >= sprmo->floorz))) // Without this, your shadow shows on the floor, even after you die and fall through the ground.
{
////////////////////
// SHADOW SPRITE! //
@@ -3988,24 +3995,24 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !fullbright);
INT32 blendmode;
if (spr->mobj->frame & FF_BLENDMASK)
blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1;
if (sprmo->frame & FF_BLENDMASK)
blendmode = ((sprmo->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1;
else
blendmode = spr->mobj->blendmode;
blendmode = sprmo->blendmode;
if (UNLIKELY(!cv_translucency.value)) // translucency disabled
{
Surf.PolyColor.s.alpha = 0xFF;
blend = PF_Translucent|PF_Occlude;
}
else if (spr->mobj->flags2 & MF2_SHADOW)
else if (sprmo->flags2 & MF2_SHADOW)
{
Surf.PolyColor.s.alpha = 0x40;
blend = HWR_GetBlendModeFlag(blendmode);
}
else if (spr->mobj->frame & FF_TRANSMASK)
else if (sprmo->frame & FF_TRANSMASK)
{
INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT;
INT32 trans = (sprmo->frame & FF_TRANSMASK)>>FF_TRANSSHIFT;
blend = HWR_SurfaceBlend(blendmode, trans, &Surf);
}
else
@@ -4018,6 +4025,9 @@ static void HWR_DrawSprite(gl_vissprite_t *spr)
blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude;
}
if (cv_playerfade.value && sprmo->player)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha);
if (HWR_UseShader())
{
shader = SHADER_SPRITE;
@@ -4038,7 +4048,9 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
INT32 shader = SHADER_NONE;
if (!spr->mobj || !spr->mobj->subsector)
const mobj_t *sprmo = spr->mobj;
if (UNLIKELY(!sprmo || !sprmo->subsector))
return;
// cache sprite graphics
@@ -4076,7 +4088,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
wallVerts[0].t = wallVerts[1].t = hwrpatch->max_t;
// colormap test
sector_t *sector = spr->mobj->subsector->sector;
sector_t *sector = sprmo->subsector->sector;
UINT8 lightlevel = 255;
extracolormap_t *colormap = sector->extra_colormap;
@@ -4084,9 +4096,9 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
{
INT32 light;
light = R_GetPlaneLight(sector, spr->mobj->z + spr->mobj->height, false); // Always use the light at the top instead of whatever I was doing before
light = R_GetPlaneLight(sector, sprmo->z + sprmo->height, false); // Always use the light at the top instead of whatever I was doing before
if (!(spr->mobj->frame & FF_FULLBRIGHT))
if (!(sprmo->frame & FF_FULLBRIGHT))
lightlevel = static_cast<UINT8>(CLAMP(*sector->lightlist[light].lightlevel, 0, 255));
if (sector->lightlist[light].extra_colormap)
@@ -4094,7 +4106,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
}
else
{
if (!(spr->mobj->frame & FF_FULLBRIGHT))
if (!(sprmo->frame & FF_FULLBRIGHT))
lightlevel = static_cast<UINT8>(CLAMP(sector->lightlevel, 0, 255));
if (sector->extra_colormap)
@@ -4103,9 +4115,9 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr)
HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector));
if (spr->mobj->frame & FF_TRANSMASK)
if (sprmo->frame & FF_TRANSMASK)
{
INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT;
INT32 trans = (sprmo->frame & FF_TRANSMASK)>>FF_TRANSSHIFT;
blend = HWR_SurfaceBlend(AST_TRANSLUCENT, trans, &Surf);
}
else
@@ -4137,8 +4149,8 @@ gl_vissprite_t* gl_vsprorder[MAXVISSPRITES];
// sorted and drawn together with transparent surfaces.
static int CompareVisSprites(const void *p1, const void *p2)
{
gl_vissprite_t* spr1 = *(gl_vissprite_t*const*)p1;
gl_vissprite_t* spr2 = *(gl_vissprite_t*const*)p2;
const gl_vissprite_t* spr1 = *(gl_vissprite_t*const*)p1;
const gl_vissprite_t* spr2 = *(gl_vissprite_t*const*)p2;
int idiff;
float fdiff;
@@ -4316,8 +4328,8 @@ static void HWR_AddTransparentPolyobjectFloor(lumpnum_t lumpnum, polyobj_t *poly
static int CompareDrawNodePlanes(const void *p1, const void *p2)
{
INT32 n1 = *(const INT32*)p1;
INT32 n2 = *(const INT32*)p2;
const INT32 n1 = *(const INT32*)p1;
const INT32 n2 = *(const INT32*)p2;
return ABS(drawnodes[n2].u.plane.fixedheight - viewz) - ABS(drawnodes[n1].u.plane.fixedheight - viewz);
}
@@ -4450,6 +4462,15 @@ static void HWR_RenderDrawNodes(void)
// --------------------------------------------------------------------------
// Draw all vissprites
// --------------------------------------------------------------------------
namespace
{
enum class DrawSpritesType
{
kSprites,
kModels,
};
template <DrawSpritesType Type>
static void HWR_DrawSprites(void)
{
UINT32 i;
@@ -4464,56 +4485,44 @@ static void HWR_DrawSprites(void)
continue;
}
HWR_DrawSprite(spr);
}
}
static void HWR_DrawModels(void)
{
UINT32 i;
for (i = 0; i < gl_visspritecount; i++)
{
gl_vissprite_t *spr = gl_vsprorder[i];
if (spr->precip)
if constexpr (Type == DrawSpritesType::kModels)
{
HWR_DrawPrecipitationSprite(spr);
continue;
}
if (!spr->mobj)
continue;
if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
{
md2_t *md2;
if (spr->mobj->localskin)
if (spr->mobj && spr->mobj->skin && spr->mobj->sprite == SPR_PLAY)
{
if (spr->mobj->skinlocal)
md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins];
md2_t *md2;
if (spr->mobj->localskin)
{
if (spr->mobj->skinlocal)
md2 = &md2_localplayermodels[(skin_t *)spr->mobj->localskin - localskins];
else
md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins];
}
else
md2 = &md2_playermodels [(skin_t *)spr->mobj->localskin - skins];
md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins];
// 8/1/19: Only don't display player models if no default SPR_PLAY is found.
if (((md2->notfound || md2->scale < 0.0f) && ((!cv_glfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN])
HWR_DrawSprite(spr);
else
HWR_DrawMD2(spr);
}
else
md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins];
// 8/1/19: Only don't display player models if no default SPR_PLAY is found.
if (((md2->notfound || md2->scale < 0.0f) && ((!cv_glfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN])
HWR_DrawSprite(spr);
else
HWR_DrawMD2(spr);
{
if (md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f)
HWR_DrawSprite(spr);
else
HWR_DrawMD2(spr);
}
}
else
if constexpr (Type == DrawSpritesType::kSprites)
{
if (md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f)
HWR_DrawSprite(spr);
else
HWR_DrawMD2(spr);
HWR_DrawSprite(spr);
}
}
}
}
// --------------------------------------------------------------------------
// HWR_AddSprites
@@ -4666,8 +4675,6 @@ static void HWR_ProjectSprite(mobj_t *thing)
if (interp.spritexscale < 1 || interp.spriteyscale < 1)
return;
const boolean papersprite = (thing->frame & FF_PAPERSPRITE);
INT32 blendmode;
if (thing->frame & FF_BLENDMASK)
blendmode = ((thing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1;
@@ -4681,6 +4688,8 @@ static void HWR_ProjectSprite(mobj_t *thing)
return;
}
const boolean papersprite = (thing->frame & FF_PAPERSPRITE);
// transform the origin point
tr_x = FixedToFloat(interp.x);
tr_y = FixedToFloat(interp.y);
@@ -4708,12 +4717,6 @@ static void HWR_ProjectSprite(mobj_t *thing)
rot = (thing->frame & FF_FRAMEMASK);
#ifdef ROTSPRITE
// determine here if sprite should rotate for optimization
const boolean sliprollrotate = (cv_sliptideroll.value && (thing->player && thing->player->sliproll));
const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate);
#endif
//Fab : 02-08-98: 'skin' override spritedef currently used for skin
if ((thing->skin || thing->localskin) && thing->sprite == SPR_PLAY)
{
@@ -4752,6 +4755,12 @@ static void HWR_ProjectSprite(mobj_t *thing)
I_Error("sprframes NULL for sprite %d\n", thing->sprite);
#endif
#ifdef ROTSPRITE
// determine here if sprite should rotate for optimization
const boolean sliprollrotate = (cv_sliptideroll.value && (thing->player && thing->player->sliproll));
const boolean shouldrotate = (interp.sloperoll || interp.slopepitch || interp.roll || interp.pitch || thing->rollangle || sliprollrotate);
#endif
if (sprframe->rotate != SRF_SINGLE || papersprite
#ifdef ROTSPRITE
|| (shouldrotate)
@@ -5195,13 +5204,13 @@ void HWR_BuildSkyDome(void)
{
int c, r;
signed char yflip;
int row_count = 4;
static constexpr int row_count = 4;
int col_count = 4;
float delta;
gl_sky_t *sky = &gl_sky;
gl_skyvertex_t *vertex_p;
texture_t *texture = textures[texturetranslation[skytexture]];
const texture_t *texture = textures[texturetranslation[skytexture]];
sky->detail = 16;
col_count *= sky->detail;
@@ -5410,7 +5419,7 @@ void HWR_SetTransform(float fpov)
void HWR_ClearClipper(void)
{
angle_t a1 = gld_FrustumAngle(gl_aimingangle);
const angle_t a1 = gld_FrustumAngle(gl_aimingangle);
gld_clipper_Clear();
gld_clipper_SafeAddClipRange(viewangle + a1, viewangle - a1);
#ifdef HAVE_SPHEREFRUSTRUM
@@ -5563,10 +5572,10 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, player_t *player, int stencil_
HWR_SortVisSprites();
PS_STOP_TIMING(ps_hw_spritesorttime);
PS_START_TIMING(ps_hw_spritedrawtime);
if (LIKELY(!cv_glmdls.value))
HWR_DrawSprites();
if (UNLIKELY(cv_glmdls.value))
HWR_DrawSprites<DrawSpritesType::kModels>();
else
HWR_DrawModels();
HWR_DrawSprites<DrawSpritesType::kSprites>();
PS_STOP_TIMING(ps_hw_spritedrawtime);
ps_numdrawnodes.value.i = 0;
@@ -5716,6 +5725,8 @@ void HWR_RenderPlayerView(void)
HWR_RenderFrame(player, false);
}
// Determine on mapload if current map has any Horizonlines present
// so we can avoid rather hot checks in HWR_Subsector
static void HWR_CheckForHorizonLines(void)
{
size_t i;
@@ -5969,7 +5980,7 @@ void HWR_Shutdown(void)
static void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap)
{
FBITFIELD blendmode = blend;
UINT8 alpha = pSurf->PolyColor.s.alpha; // retain the alpha
const UINT8 alpha = pSurf->PolyColor.s.alpha; // retain the alpha
INT32 shader = SHADER_NONE;
+6 -1
View File
@@ -1227,6 +1227,9 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode);
}
if (cv_playerfade.value && spr->mobj->player)
Surf.PolyColor.s.alpha = FixedMul(R_DoPlayerFade(spr->mobj), Surf.PolyColor.s.alpha);
// dont forget to enabled the depth test because we can't do this like
// before: polygons models are not sorted
@@ -1241,7 +1244,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
else
{
md2s = md2_playermodels;
skinnum = (skin_t *)spr->mobj->localskin - skins;
skinnum = (skin_t *)spr->mobj->localskin - skins;
}
}
else
@@ -1266,6 +1269,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
if (md2->error)
return; // we already failed loading this before :(
if (!md2->model)
{
CONS_Debug(DBG_RENDER, "Loading model... (%s, %s)", sprnames[spr->mobj->sprite], md2->filename);
@@ -1284,6 +1288,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr)
return;
}
}
//Hurdler: arf, I don't like that implementation at all... too much crappy
gpatch = md2->glpatch;
if (gpatch)
+1 -1
View File
@@ -132,7 +132,7 @@ void HWR_PortalFrame(gl_portal_t* portal)
{
portalclipline = NULL;
portalcullsector = NULL;
viewsector = R_PointInSubsector(viewx, viewy)->sector;
viewsector = R_PointInSubsectorFast(viewx, viewy)->sector;
}
}
+133 -9
View File
@@ -689,7 +689,7 @@ typedef enum
gluniform_leveltime,
gluniform_scr_resolution,
gluniform_max,
} gluniform_t;
@@ -1729,6 +1729,114 @@ static void GL_AllocTextureBuffer(GLMipmap_t *pTexInfo)
}
}
#define PADDING_CHECK(offset, alphaCheck) { from = to + (offset); if ((alphaCheck)) from = NULL; else goto foundFrom; }
static void PadRGBABitmap(RGBA_t *tex, UINT16 w, UINT16 h)
{
INT32 i;
boolean notLeft, notRight, notTop, notBottom;
RGBA_t *to = tex - 1, *from;
for (i = 0; i < w * h; i++)
{
to++;
if (to->rgba != 0)
continue;
from = NULL;
notLeft = i % w != 0;
notRight = i % w != w - 1;
notTop = i / w != 0;
notBottom = i / w != h - 1;
if (notRight) PADDING_CHECK(1, from->s.alpha == 0) // Check +X
if (notBottom) PADDING_CHECK(w, from->s.alpha == 0) // Check +Y
if (notLeft) PADDING_CHECK(-1, from->s.alpha == 0) // Check -X
if (notTop) PADDING_CHECK(-w, from->s.alpha == 0) // Check -Y
if (notRight && notBottom) PADDING_CHECK(1 + w, from->s.alpha == 0) // Check +X+Y
if (notLeft && notBottom) PADDING_CHECK(-1 + w, from->s.alpha == 0) // Check -X+Y
if (notLeft && notTop) PADDING_CHECK(-1 - w, from->s.alpha == 0) // Check -X-Y
if (notRight && notTop) PADDING_CHECK(1 - w, from->s.alpha == 0) // Check +X-Y
foundFrom:
if (from != NULL)
{
*to = *from;
to->s.alpha = 0;
}
}
}
#undef PADDING_CHECK
static void GenerateMipmaps(INT32 w, INT32 h, RGBA_t *tex, INT32 maxLOD)
{
if (tex == NULL)
{
GL_MSG_Warning("GenerateMipmaps: attempted to generate mipmaps without texture data");
return;
}
RGBA_t samplePoint[4];
boolean padTexture;
INT32 pointsSampled = 0;
INT32 m, j, i, p;
UINT16 sumR, sumG, sumB, sumA;
for (m = 0; m < maxLOD; m++)
{
if (w <= 1 || h <= 1)
return;
padTexture = false;
for (j = 0; j < h / 2; j++)
{
for (i = 0; i < w / 2; i++)
{
samplePoint[0] = tex[w*j*2 + i*2];
samplePoint[1] = tex[w*j*2 + i*2+1];
samplePoint[2] = tex[w*(j*2+1) + i*2];
samplePoint[3] = tex[w*(j*2+1) + i*2+1];
pointsSampled = sumR = sumG = sumB = sumA = 0;
for (p = 0; p < 4; p++)
{
if (samplePoint[p].s.alpha == 0)
continue;
sumR += samplePoint[p].s.red;
sumG += samplePoint[p].s.green;
sumB += samplePoint[p].s.blue;
sumA += samplePoint[p].s.alpha;
pointsSampled++;
}
if (pointsSampled > 0)
{
tex[(w/2)*j+i].s.red = sumR / pointsSampled;
tex[(w/2)*j+i].s.green = sumG / pointsSampled;
tex[(w/2)*j+i].s.blue = sumB / pointsSampled;
tex[(w/2)*j+i].s.alpha = sumA / pointsSampled;
}
else
{
tex[(w/2)*j+i].rgba = 0;
padTexture = true;
}
}
}
w /= 2;
h /= 2;
if (padTexture)
PadRGBABitmap(tex, w, h);
pglTexSubImage2D(GL_TEXTURE_2D, m + 1, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, tex);
}
}
// -----------------+
// UpdateTexture : Updates texture data.
// -----------------+
@@ -1737,6 +1845,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
// Upload a texture
GLuint num = pTexInfo->downloaded;
boolean update = true;
const boolean applyPadding = mag_filter == GL_LINEAR || min_filter == GL_LINEAR;
INT32 w = pTexInfo->width, h = pTexInfo->height;
INT32 i, j;
@@ -1795,15 +1904,32 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
pImgData++;
}
}
if (applyPadding)
PadRGBABitmap(tex, w, h);
break;
case GL_TEXFMT_RGBA:
// Directly upload the texture data without any kind of conversion.
ptex = pImgData;
// However, it does need to be copied to a buffer for generating mipmaps and padding
if (MipMap || applyPadding)
{
GL_AllocTextureBuffer(pTexInfo);
tex = textureBuffer;
memcpy(tex, ptex, w * h * 4);
ptex = tex;
if (applyPadding)
PadRGBABitmap(tex, w, h);
}
break;
case GL_TEXFMT_ALPHA_INTENSITY_88:
GL_AllocTextureBuffer(pTexInfo);
ptex = tex = textureBuffer;
texformat = GL_LUMINANCE_ALPHA;
texformat = GL_RGBA;
for (idx = 0, j = 0; j < h; j++)
{
@@ -1821,7 +1947,7 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
case GL_TEXFMT_ALPHA_8: // Used for fade masks
GL_AllocTextureBuffer(pTexInfo);
ptex = tex = textureBuffer;
texformat = GL_ALPHA;
texformat = GL_RGBA;
memset(&tex->s, 255, sizeof(byteColor_t)*w*h); // 255 because the fade mask is modulated with the screen texture, so alpha affects it while the colours don't
@@ -1857,8 +1983,6 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
if (MipMap && !transparent) // No mipmaps on transparent stuff
{
int maxlod = (texformat == GL_LUMINANCE_ALPHA || texformat == GL_ALPHA) ? 4 : 5;
pglTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
if (update)
@@ -1868,7 +1992,8 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
// Control the mipmap level of detail
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, 0);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, maxlod);
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 5);
GenerateMipmaps(w, h, tex, 5);
}
else
{
@@ -1892,7 +2017,6 @@ void GL_UpdateTexture(GLMipmap_t *pTexInfo)
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropic_filter);
}
// -----------------+
// SetTexture : The mipmap becomes the current texture source
// -----------------+
@@ -2735,7 +2859,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics
poly.green = byte2float[Surface->PolyColor.s.green];
poly.blue = byte2float[Surface->PolyColor.s.blue];
poly.alpha = byte2float[Surface->PolyColor.s.alpha];
pglColor4ubv((GLubyte*)&Surface->PolyColor.s);
GL_SetBlend(((poly.alpha < 1) ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated);
@@ -2749,7 +2873,7 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics
fade.green = byte2float[Surface->FadeColor.s.green];
fade.blue = byte2float[Surface->FadeColor.s.blue];
fade.alpha = byte2float[Surface->FadeColor.s.alpha];
if (Surface->LightTableId && Surface->LightTableId != lt_downloaded)
{
pglActiveTexture(GL_TEXTURE2);
+5 -1
View File
@@ -220,7 +220,11 @@ HMS_connect (const char *format, ...)
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, (long)CURL_IPRESOLVE_V4);
#ifdef HAVE_IPV6
if (!M_CheckParm("-ipv6"))
#endif
curl_easy_setopt(curl, CURLOPT_IPRESOLVE, (long)CURL_IPRESOLVE_V4);
curl_easy_setopt(curl, CURLOPT_TIMEOUT, (long)cv_masterserver_timeout.value);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, HMS_on_read);
+40 -10
View File
@@ -310,7 +310,7 @@ void HU_LoadGraphics(void)
lt_font[0] = (patch_t *)W_CachePatchName("LTFNT039", PU_HUDGFX); /// \note fake start hack
// Number support
lt_font[9] = (patch_t *)W_CachePatchName("LTFNT048", PU_HUDGFX);
lt_font[9] = (patch_t *)W_CachePatchName("LTFNT048", PU_HUDGFX);
lt_font[10] = (patch_t *)W_CachePatchName("LTFNT049", PU_HUDGFX);
lt_font[11] = (patch_t *)W_CachePatchName("LTFNT050", PU_HUDGFX);
lt_font[12] = (patch_t *)W_CachePatchName("LTFNT051", PU_HUDGFX);
@@ -701,7 +701,7 @@ static void Command_Sayto_f(void)
return;
}
target = nametonum(COM_Argv(1));
target = D_LookupPlayer(COM_Argv(1));
if (target == -1)
{
CONS_Alert(CONS_NOTICE, M_GetText("No player with that name!\n"));
@@ -747,7 +747,7 @@ static void Command_CSay_f(void)
return;
}
if(!server && !IsPlayerAdmin(consoleplayer))
if (!server && !IsPlayerAdmin(consoleplayer))
{
CONS_Alert(CONS_NOTICE, M_GetText("Only servers and admins can use csay.\n"));
return;
@@ -949,6 +949,9 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum)
else
stop_spamming[playernum] = 4; // you can hold off for 4 tics, can you?
if (player_muted[playernum])
spam_eatmsg = 1; // Let lua know we're skipping this message
// run the lua hook even if we were supposed to eat the msg, netgame consistency goes first.
if (LUA_HookPlayerMsg(playernum, target, flags, msg, spam_eatmsg))
@@ -1179,6 +1182,23 @@ static boolean HU_clearChatSpaces(void)
return nothingbutspaces;
}
static void DoMute(const char *name)
{
INT32 pnum = D_LookupPlayer(name);
if (pnum < 0)
{
HU_AddChatText("\x85""ERROR: \x80Player not found.", false);
return;
}
player_muted[pnum] = !player_muted[pnum];
HU_AddChatText(va("Player '%s' has been %smuted.", player_names[pnum], player_muted[pnum] ? "" : "un"), false);
if (player_muted[pnum])
HU_AddChatText("Use same command to unmute them.", false);
}
static void HU_SendChatMessage(void)
{
char buf[2 + HU_MAXMSGLEN + 1];
@@ -1205,7 +1225,19 @@ static void HU_SendChatMessage(void)
return;
}
if (strlen(msg) > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
size_t len = strlen(msg);
if (len >= 5 && strnicmp(msg, "/mute", 5) == 0) // Used /mute
{
if (len > 6)
DoMute(msg+6);
else
HU_AddChatText("\x82NOTICE: \x80Usage: /mute <name|node>", false);
return;
}
if (len > 4 && strnicmp(msg, "/pm", 3) == 0) // used /pm
{
INT32 spc = 1; // used if nodenum[1] is a space.
char *nodenum = (char*) malloc(3);
@@ -2849,13 +2881,11 @@ void HU_DoCEcho(const char *msg)
*p = '\n';
CONS_Printf("%s\n", temp);
return;
}
else if (cv_cechotoggle.value)
cechotimer = cechoduration;
I_OutputMsg("%s\n", msg); // print to log
if (!cv_cechotoggle.value)
return;
cechotimer = cechoduration;
I_OutputMsg("%s\n", msg); // ALWAYS print to log
}
+4 -4
View File
@@ -82,6 +82,8 @@ typedef struct
char data[MAXPACKETLENGTH];
} ATTRPACK doomcom_t;
#define DOOMCOM_DATA(d) (doomdata_t *)&(d)->data
#ifdef HOLEPUNCH
typedef struct
{
@@ -89,6 +91,8 @@ typedef struct
INT32 addr;
INT16 port;
} ATTRPACK holepunch_t;
#define HOLEPUNCH_DATA(d) (holepunch_t *)&(d)->data
#endif
#if defined(_MSC_VER)
@@ -97,10 +101,6 @@ typedef struct
extern doomcom_t *doomcom;
#ifdef HOLEPUNCH
extern holepunch_t *holepunchpacket;
#endif
/** \brief return packet in doomcom struct
*/
extern boolean (*I_NetGet)(void);
+78 -28
View File
@@ -371,8 +371,16 @@ static inline void I_UPnP_rem(const char *port, const char * servicetype)
static const char *SOCK_AddrToStr(mysockaddr_t *sk)
{
static char s[64]; // 255.255.255.255:65535 or IPv6:65535
static char s[64]; // 255.255.255.255:65535 or
// [ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]:65535
#ifdef HAVE_NTOP
#ifdef HAVE_IPV6
int v6 = (sk->any.sa_family == AF_INET6);
#else
int v6 = 0;
#endif
void *addr;
int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once
@@ -387,14 +395,20 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk)
if(addr == NULL)
sprintf(s, "No address");
else if(inet_ntop(sk->any.sa_family, addr, s, sizeof (s)) == NULL)
else if(inet_ntop(sk->any.sa_family, addr, &s[v6], sizeof (s) - v6) == NULL)
{
e = errno;
sprintf(s, "Unknown family type, error #%u: %s", e, strerror(e));
}
#ifdef HAVE_IPV6
else if(sk->any.sa_family == AF_INET6 && sk->ip6.sin6_port != 0)
strcat(s, va(":%d", ntohs(sk->ip6.sin6_port)));
else if(sk->any.sa_family == AF_INET6)
{
s[0] = '[';
strcat(s, "]");
if (sk->ip6.sin6_port != 0)
strcat(s, va(":%d", ntohs(sk->ip6.sin6_port)));
}
#endif
else if(sk->any.sa_family == AF_INET && sk->ip4.sin_port != 0)
strcat(s, va(":%d", ntohs(sk->ip4.sin_port)));
@@ -486,10 +500,30 @@ static time_t SOCK_GetUnbanTime(size_t ban)
}
#ifndef NONET
#ifdef HAVE_IPV6
static boolean SOCK_cmpipv6(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask)
{
UINT8 bitmask;
I_Assert(mask <= 128);
if (mask == 0)
mask = 128;
if (memcmp(&a->ip6.sin6_addr.s6_addr, &b->ip6.sin6_addr.s6_addr, mask / 8) != 0)
return false;
if (mask % 8 == 0)
return true;
bitmask = 255 << (mask % 8);
return (a->ip6.sin6_addr.s6_addr[mask / 8] & bitmask) == (b->ip6.sin6_addr.s6_addr[mask / 8] & bitmask);
}
#endif
static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask)
{
UINT32 bitmask = INADDR_NONE;
if (a->any.sa_family != b->any.sa_family)
return false;
if (mask && mask < 32)
bitmask = htonl((UINT32)(-1) << (32 - mask));
@@ -498,13 +532,14 @@ static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask)
&& (b->ip4.sin_port == 0 || (a->ip4.sin_port == b->ip4.sin_port));
#ifdef HAVE_IPV6
else if (b->any.sa_family == AF_INET6)
return memcmp(&a->ip6.sin6_addr, &b->ip6.sin6_addr, sizeof(b->ip6.sin6_addr))
return SOCK_cmpipv6(a, b, mask)
&& (b->ip6.sin6_port == 0 || (a->ip6.sin6_port == b->ip6.sin6_port));
#endif
else
return false;
}
// This is a hack. For some reason, nodes aren't being freed properly.
// This goes through and cleans up what nodes were supposed to be freed.
/** \warning This function causes the file downloading to stop if someone joins.
@@ -620,6 +655,7 @@ is_external_address (UINT32 p)
static boolean hole_punch(ssize_t c)
{
holepunch_t *holepunchpacket = HOLEPUNCH_DATA(doomcom);
/* See ../doc/Holepunch-Protocol.txt */
if (cv_rendezvousserver.string[0] &&
@@ -659,6 +695,7 @@ static boolean SOCK_Get(void)
fromlen = (socklen_t)sizeof(fromaddress);
c = recvfrom(mysockets[n], (char *)&doomcom->data, MAXPACKETLENGTH, 0,
(void *)&fromaddress, &fromlen);
if (c > 0)
{
#ifdef USE_STUN
@@ -868,11 +905,11 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
unsigned long trueval = true;
#endif
mysockaddr_t straddr;
struct sockaddr_in sin;
socklen_t len = sizeof(sin);
socklen_t len = sizeof(straddr);
if (s == (SOCKET_TYPE)ERRSOCKET)
return (SOCKET_TYPE)ERRSOCKET;
#ifdef USE_WINSOCK
{ // Alam_GBC: disable the new UDP connection reset behavior for Win2k and up
#ifdef USE_WINSOCK2
@@ -892,14 +929,12 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
}
#endif
straddr.any = *addr;
memcpy(&straddr, addr, addrlen);
I_OutputMsg("Binding to %s\n", SOCK_AddrToStr(&straddr));
if (family == AF_INET)
{
mysockaddr_t tmpaddr;
tmpaddr.any = *addr ;
if (tmpaddr.ip4.sin_addr.s_addr == htonl(INADDR_ANY))
if (straddr.ip4.sin_addr.s_addr == htonl(INADDR_ANY))
{
opt = true;
opts = (socklen_t)sizeof(opt);
@@ -924,7 +959,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
#ifdef HAVE_IPV6
else if (family == AF_INET6)
{
if (memcmp(addr, &in6addr_any, sizeof(in6addr_any)) == 0) //IN6_ARE_ADDR_EQUAL
if (memcmp(&straddr.ip6.sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0) //IN6_ARE_ADDR_EQUAL
{
opt = true;
opts = (socklen_t)sizeof(opt);
@@ -939,7 +974,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
// make it IPv6 ony
opt = true;
opts = (socklen_t)sizeof(opt);
rc = setsockopt(s, SOL_SOCKET, IPV6_V6ONLY, (char *)&opt, opts);
rc = setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&opt, opts);
if (rc <= -1)
{
e = errno;
@@ -969,7 +1004,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &maddr.ipv6mr_multiaddr);
maddr.ipv6mr_interface = 0;
rc = setsockopt(s, SOL_SOCKET, IPV6_JOIN_GROUP, (const char *)&maddr, sizeof(maddr));
rc = setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP, (const char *)&maddr, sizeof(maddr));
if (rc <= -1)
{
e = errno;
@@ -1032,7 +1067,7 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
CONS_Printf(M_GetText("Network system buffer set to: %dKb\n"), opt>>10);
}
rc = getsockname(s, (struct sockaddr *)&sin, &len);
rc = getsockname(s, &straddr.any, &len);
if (rc != 0)
{
e = errno;
@@ -1040,7 +1075,14 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen
I_OutputMsg("getsockname failed: #%u, %s\n", e, strerror(e));
}
else
current_port = (UINT16)ntohs(sin.sin_port);
{
if (family == AF_INET)
current_port = (UINT16)ntohs(straddr.ip4.sin_port);
#ifdef HAVE_IPV6
else if (family == AF_INET6)
current_port = (UINT16)ntohs(straddr.ip6.sin6_port);
#endif
}
return s;
}
@@ -1121,6 +1163,7 @@ static boolean UDP_Socket(void)
I_freeaddrinfo(ai);
}
}
#ifdef HAVE_IPV6
if (b_ipv6)
{
@@ -1319,12 +1362,13 @@ static boolean SOCK_GetAddr(struct sockaddr_in *sin, const char *address, const
{
struct my_addrinfo *ai = NULL, *runp, hints;
int gaie;
size_t i;
if (!port || !port[0])
port = DEFAULTPORT;
memset (&hints, 0x00, sizeof (hints));
hints.ai_flags = 0;
hints.ai_flags = AI_ADDRCONFIG;
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
@@ -1343,10 +1387,19 @@ static boolean SOCK_GetAddr(struct sockaddr_in *sin, const char *address, const
{
while (runp != NULL)
{
if (sendto(mysockets[0], NULL, 0, 0, runp->ai_addr, runp->ai_addrlen) == 0)
break;
// test ip address of server
for (i = 0; i < mysocketses; ++i)
{
if (runp->ai_addr->sa_family == myfamily[i])
{
break;
}
}
runp = runp->ai_next;
if (i >= mysocketses)
runp = runp->ai_next;
else
break;
}
}
@@ -1390,6 +1443,8 @@ static void rendezvous(int size)
tic_t tic = I_GetTime();
holepunch_t *holepunchpacket = HOLEPUNCH_DATA(doomcom);
if (tic != refreshtic)
{
if (SOCK_GetAddr(&rzv.ip4, host, (port ? port : "7777"), false))
@@ -1415,6 +1470,7 @@ static void rendezvous(int size)
static void SOCK_RequestHolePunch(INT32 node)
{
mysockaddr_t * addr = &clientaddress[node];
holepunch_t *holepunchpacket = HOLEPUNCH_DATA(doomcom);
holepunchpacket->addr = addr->ip4.sin_addr.s_addr;
holepunchpacket->port = addr->ip4.sin_port;
@@ -1475,13 +1531,7 @@ static void AddBannedIndex(void)
banned_size *= 2;
}
banned = Z_ReallocAlign(
(void*) banned,
sizeof(banned_t) * banned_size,
PU_STATIC,
NULL,
sizeof(banned_t) * 8
);
banned = Z_Realloc((void*) banned, sizeof(banned_t) * banned_size, PU_STATIC, NULL);
}
numbans++;
@@ -1742,7 +1792,7 @@ boolean I_InitTcpNetwork(void)
// server address only in ip
if (serverhostname[0])
{
{
CONS_Printf("SERVERNAME: %s\n", serverhostname);
COM_BufAddText("connect \"");
COM_BufAddText(serverhostname);
+14 -3
View File
@@ -96,8 +96,9 @@ consvar_t cv_showminimapnames = {"showminimapnames", "Off", CV_SAVE, CV_OnOff, N
CV_PossibleValue_t minimapdot_cons_t[NUMMINIMAPDOTSTUFF];
consvar_t cv_showminimapangle = {"showminimapangle", "Off", CV_SAVE, minimapdot_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_posanim = {"postitionanimation", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_smallposnum = {"smallpositionnumber", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t posanim_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}};
consvar_t cv_posanim = {"postitionanimation", "On", CV_SAVE, posanim_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_smallposnum = {"smallpositionnumber", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_showlapemblem = {"showlapemblem", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -1948,6 +1949,8 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI
}
}
#define POS_DELAY_TIME 10
static void K_DrawKartPositionNum(INT32 num)
{
// POSI_X = BASEVIDWIDTH - 51; // 269
@@ -1966,7 +1969,15 @@ static void K_DrawKartPositionNum(INT32 num)
if ((cv_posanim.value && stplyr->kartstuff[k_positiondelay]) || stplyr->exiting)
{
scale *= 2;
if (cv_posanim.value == 2)
{
const UINT8 delay = (stplyr->exiting) ? POS_DELAY_TIME : stplyr->kartstuff[k_positiondelay];
const fixed_t add = (scale * 3) >> ((splitscreen == 1) ? 1 : 2);
scale = (scale + min((add * (delay * delay)) / (POS_DELAY_TIME * POS_DELAY_TIME), add));
}
else
scale *= 2;
overtake = true; // this is used for splitscreen stuff in conjunction with flipdraw.
}
+44 -28
View File
@@ -3081,14 +3081,12 @@ static void K_SpawnDriftSparks(player_t *player)
if (leveltime % 2 == 1)
return;
if (cv_airsparks.value)
goto skipground;
const boolean onground = P_IsObjectOnGround(player->mo);
if (!P_IsObjectOnGround(player->mo))
// kinda sketchy
if (!cv_airsparks.value && onground)
return;
skipground: // idk im sleepy
if (!player->kartstuff[k_drift] || player->kartstuff[k_driftcharge] < K_GetKartDriftSparkValue(player))
return;
@@ -3105,6 +3103,8 @@ skipground: // idk im sleepy
newy = player->mo->y + P_ReturnThrustY(player->mo, thrustangle, smolscale);
spark = P_SpawnMobj(newx, newy, player->mo->z, MT_DRIFTSPARK);
spark->islocal = cv_airsparks.value && !onground;
P_SetTarget(&spark->target, player->mo);
spark->angle = travelangle-(ANGLE_45/5)*player->kartstuff[k_drift];
@@ -4600,7 +4600,7 @@ static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z
//sec = R_PointInSubsector(x, y)->sector;
if (mobj->x != x || mobj->y != y || mobj->subsector == NULL)
sec = R_PointInSubsector(x, y)->sector;
sec = R_PointInSubsectorFast(x, y)->sector;
else
sec = mobj->subsector->sector;
@@ -5361,6 +5361,7 @@ FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, bool
fast->momx = 3*player->mo->momx/4;
fast->momy = 3*player->mo->momy/4;
fast->momz = 3*player->mo->momz/4;
fast->islocal = !synched;
P_SetTarget(&fast->target, player->mo); // easier lua access
K_MatchGenericExtraFlags(fast, player->mo);
@@ -6062,32 +6063,47 @@ void K_KartUpdatePosition(player_t *player)
// This checks every thing on the map, and looks for MT_BOSS3WAYPOINT (the thing we're using for checkpoint wp's, for now)
for (mo = waypointcap; mo != NULL; mo = mo->tracer)
{
pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x,
mo->y - player->mo->y),
mo->z - player->mo->z) / FRACUNIT;
imo = P_AproxDistance(P_AproxDistance( mo->x - players[i].mo->x,
mo->y - players[i].mo->y),
mo->z - players[i].mo->z) / FRACUNIT;
const boolean isprevcheckpointp = mo->health == player->starpostnum;
const boolean isnextcheckpointp = mo->health == (player->starpostnum + 1);
if (mo->health == player->starpostnum && (!mo->movecount || mo->movecount == player->laps+1))
if ((isprevcheckpointp || isnextcheckpointp) && (!mo->movecount || mo->movecount == player->laps+1))
{
player->kartstuff[k_prevcheck] += pmo;
ppcd++;
pmo = P_AproxDistance(P_AproxDistance( mo->x - player->mo->x,
mo->y - player->mo->y),
mo->z - player->mo->z) / FRACUNIT;
if (isprevcheckpointp)
{
player->kartstuff[k_prevcheck] += pmo;
ppcd++;
}
if (isnextcheckpointp)
{
player->kartstuff[k_nextcheck] += pmo;
pncd++;
}
}
if (mo->health == (player->starpostnum + 1) && (!mo->movecount || mo->movecount == player->laps+1))
const boolean isprevcheckpointi = mo->health == players[i].starpostnum;
const boolean isnextcheckpointi = mo->health == (players[i].starpostnum + 1);
if ((isprevcheckpointi || isnextcheckpointi) && (!mo->movecount || mo->movecount == players[i].laps+1))
{
player->kartstuff[k_nextcheck] += pmo;
pncd++;
}
if (mo->health == players[i].starpostnum && (!mo->movecount || mo->movecount == players[i].laps+1))
{
players[i].kartstuff[k_prevcheck] += imo;
ipcd++;
}
if (mo->health == (players[i].starpostnum + 1) && (!mo->movecount || mo->movecount == players[i].laps+1))
{
players[i].kartstuff[k_nextcheck] += imo;
incd++;
imo = P_AproxDistance(P_AproxDistance( mo->x - players[i].mo->x,
mo->y - players[i].mo->y),
mo->z - players[i].mo->z) / FRACUNIT;
if (isprevcheckpointi)
{
players[i].kartstuff[k_prevcheck] += imo;
ipcd++;
}
if (isnextcheckpointi )
{
players[i].kartstuff[k_nextcheck] += imo;
incd++;
}
}
}
+2 -1
View File
@@ -150,7 +150,8 @@ static const udata_field_t mobj_fields[] = {
FIELD(mobj_t, cvmem, udatalib_getter_int32, udatalib_setter_int32),
FIELD(mobj_t, standingslope, udatalib_getter_slope, mobj_standingslope_noset),
FIELD(mobj_t, colorized, udatalib_getter_boolean, udatalib_setter_boolean),
FIELD(mobj_t, mirrored, udatalib_getter_boolean, udatalib_setter_boolean),
FIELD(mobj_t, mirrored, udatalib_getter_boolean, udatalib_setter_boolean),
FIELD(mobj_t, islocal, udatalib_getter_boolean, udatalib_setter_boolean),
{ NULL, 0, NULL, NULL },
};
#undef FIELD
+277 -187
View File
@@ -107,7 +107,7 @@
#define SMALLLINEHEIGHT 8
#define SLIDER_RANGE 10
#define SLIDER_WIDTH (8*SLIDER_RANGE+6)
#define SERVERS_PER_PAGE 11
#define SERVERS_PER_PAGE 10
#define MAXSTAT 9 //Max number a stat can have
typedef enum
@@ -183,6 +183,8 @@ static char joystickInfo[8][29];
static UINT32 serverlistpage;
static UINT32 oldserverlistpage;
static float serverlistslidex;
static INT32 serverlistsearched[MAXSERVERLIST] = {0};
static UINT32 serverlistsearchedcount = 0;
#endif
//static saveinfo_t savegameinfo[MAXSAVEGAMES]; // Extra info about the save games.
@@ -211,6 +213,8 @@ static void M_StopMessage(INT32 choice);
#ifndef NONET
static void M_HandleServerPage(INT32 choice);
static void M_HandleServerSearch(INT32 choice);
static void M_SearchServerList(void);
#endif
// Prototyping is fun, innit?
@@ -1110,11 +1114,11 @@ static menuitem_t MP_PlayerSetupMenu[] =
#ifndef NONET
static menuitem_t MP_ConnectMenu[] =
{
{IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 4},
{IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 12},
{IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 20},
{IT_STRING | IT_CVAR, NULL, "Sort By", &cv_serversort, 0},
{IT_STRING | IT_KEYHANDLER, NULL, "Page", M_HandleServerPage, 8},
{IT_STRING | IT_CALL, NULL, "Refresh", M_Refresh, 16},
{IT_STRING | IT_KEYHANDLER, NULL, "", M_HandleServerSearch,25},
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 36},
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 48},
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 60},
{IT_STRING | IT_SPACE, NULL, "", M_Connect, 72},
@@ -1132,6 +1136,7 @@ enum
mp_connect_sort,
mp_connect_page,
mp_connect_refresh,
mp_connect_search,
FIRSTSERVERLINE
};
#endif
@@ -1522,6 +1527,7 @@ enum
//op_exp_dirlight,
op_exp_skybox,
op_exp_accuratefps,
op_exp_votescrn,
#ifdef HWRENDER
op_exp_glscrtx,
#ifdef USE_FBO_OGL
@@ -2471,9 +2477,13 @@ static menuitem_t OP_HudOffsetMenu[] =
{IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_stat_yoffset, 185},
};
// FIXME: WE EFFECTIVELY HAVE NO MORE SPACE FOR GREEN RES
// i had to put multiple names into single lines at this point
// we ought to really do something better for this at this point
// absolutely crazy how many people put work into this at this point <3
static menuitem_t OP_SaturnCreditsMenu[] =
{
{IT_HEADER, NULL, "Thanks to all contributers <3", NULL, 0},
{IT_HEADER, NULL, "Thanks to all contributers <3", NULL, 0},
{IT_STRING2+IT_SPACE, NULL, "Alug", NULL, 10},
{IT_STRING2+IT_SPACE, NULL, "Indev", NULL, 20},
@@ -2482,20 +2492,21 @@ static menuitem_t OP_SaturnCreditsMenu[] =
{IT_STRING2+IT_SPACE, NULL, "GenericHeroGuy", NULL, 50},
{IT_STRING2+IT_SPACE, NULL, "xyzzy", NULL, 60},
{IT_STRING2+IT_SPACE, NULL, "Chearii", NULL, 70},
{IT_STRING2+IT_SPACE, NULL, "riomccloud", NULL, 80},
{IT_STRING2+IT_SPACE, NULL, "chromaticpipe", NULL, 90},
{IT_STRING2+IT_SPACE, NULL, "PAS", NULL, 100},
{IT_STRING2+IT_SPACE, NULL, "$HOME", NULL, 110},
{IT_STRING2+IT_SPACE, NULL, "Achii", NULL, 120},
{IT_STRING2+IT_SPACE, NULL, "Anonimus", NULL, 130},
{IT_STRING2+IT_SPACE, NULL, "scizor300", NULL, 140},
{IT_STRING2+IT_SPACE, NULL, "Lugent", NULL, 150},
{IT_STRING2+IT_SPACE, NULL, "Sunflower", NULL, 80},
{IT_STRING2+IT_SPACE, NULL, "Yuz", NULL, 90},
{IT_STRING2+IT_SPACE, NULL, "Democrab", NULL, 100},
{IT_STRING2+IT_SPACE, NULL, "EXpand", NULL, 110},
{IT_STRING2+IT_SPACE, NULL, "Nexit", NULL, 120},
{IT_STRING2+IT_SPACE, NULL, "Spee", NULL, 130},
{IT_STRING2+IT_SPACE, NULL, "jin", NULL, 140},
{IT_STRING2+IT_SPACE, NULL, "riomccloud", NULL, 150},
{IT_STRING2+IT_SPACE, NULL, "chromaticpipe", NULL, 160},
{IT_STRING2+IT_SPACE, NULL, "Achii", NULL, 170},
{IT_STRING2+IT_SPACE, NULL, "Anonimus", NULL, 180},
{IT_STRING2+IT_SPACE, NULL, "scizor300", NULL, 190},
{IT_STRING2+IT_SPACE, NULL, "Lugent", NULL, 200},
{IT_HEADER, NULL, "", NULL, 124},
{IT_STRING2+IT_SPACE, NULL, "Sunflower Yuz", NULL, 180},
{IT_STRING2+IT_SPACE, NULL, "Democrab EXpand", NULL, 190},
{IT_STRING2+IT_SPACE, NULL, "Nexit Spee", NULL, 200},
{IT_STRING2+IT_SPACE, NULL, "jin", NULL, 210},
{IT_HEADER, NULL, "Special Thanks <3", NULL, 168},
@@ -2507,7 +2518,7 @@ static menuitem_t OP_SaturnCreditsMenu[] =
{IT_STRING, NULL, "", NULL, 258}, // dummy text II
};
// sry we dont have space for this anymore :/
// sry we dont have space for this anymore :c
/*static const char* OP_CreditTooltips[] =
{
NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
@@ -2731,7 +2742,7 @@ menu_t MISC_AddonsDef =
50, 28,
0,
NULL,
{NULL}
NULL
};
menu_t MISC_ReplayHutDef =
@@ -2744,7 +2755,7 @@ menu_t MISC_ReplayHutDef =
30, 80,
0,
M_QuitReplayHut,
{NULL}
NULL
};
menu_t MISC_ReplayOptionsDef =
@@ -2757,7 +2768,7 @@ menu_t MISC_ReplayOptionsDef =
27, 40,
0,
NULL,
{NULL}
NULL
};
menu_t MISC_ReplayStartDef =
@@ -2770,7 +2781,7 @@ menu_t MISC_ReplayStartDef =
30, 90,
0,
NULL,
{NULL}
NULL
};
menu_t PlaybackMenuDef = {
@@ -2783,12 +2794,12 @@ menu_t PlaybackMenuDef = {
BASEVIDWIDTH/2 - 88, 2,
0,
NULL,
{NULL}
NULL
};
menu_t MAPauseDef = PAUSEMENUSTYLE(MAPauseMenu, 40, 72);
menu_t SPauseDef = PAUSEMENUSTYLE(SPauseMenu, 40, 72);
menu_t MPauseDef = PAUSEMENUSTYLE(MPauseMenu, 40, 72);
menu_t SPauseDef = PAUSEMENUSTYLE(SPauseMenu, 40, 72);
menu_t MPauseDef = PAUSEMENUSTYLE(MPauseMenu, 40, 72);
#ifdef HAVE_DISCORDRPC
menu_t MISC_DiscordRequestsDef = {
@@ -2800,16 +2811,16 @@ menu_t MISC_DiscordRequestsDef = {
0, 0,
0,
NULL,
{NULL}
NULL
};
#endif
// Misc Main Menu
menu_t MISC_ScrambleTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ScrambleTeamMenu, &MPauseDef, 27, 40);
menu_t MISC_ChangeTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeTeamMenu, &MPauseDef, 27, 40);
menu_t MISC_ChangeSpectateDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeSpectateMenu, &MPauseDef, 27, 40);
menu_t MISC_ChangeLevelDef = MAPICONMENUSTYLE(NULL, MISC_ChangeLevelMenu, &MPauseDef);
menu_t MISC_HelpDef = IMAGEDEF(MISC_HelpMenu);
menu_t MISC_ScrambleTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ScrambleTeamMenu, &MPauseDef, 27, 40, NULL);
menu_t MISC_ChangeTeamDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeTeamMenu, &MPauseDef, 27, 40, NULL);
menu_t MISC_ChangeSpectateDef = DEFAULTMENUSTYLE(NULL, MISC_ChangeSpectateMenu, &MPauseDef, 27, 40, NULL);
menu_t MISC_ChangeLevelDef = MAPICONMENUSTYLE(NULL, MISC_ChangeLevelMenu, &MPauseDef);
menu_t MISC_HelpDef = IMAGEDEF(MISC_HelpMenu);
//
// M_GetGametypeColor
@@ -2896,7 +2907,7 @@ menu_t SR_PandoraDef =
60, 40,
0,
M_ExitPandorasBox,
{NULL}
NULL
};
menu_t SR_MainDef = CENTERMENUSTYLE(NULL, SR_MainMenu, &MainDef, 72);
@@ -2912,7 +2923,7 @@ menu_t SR_UnlockChecklistDef =
280, 185,
0,
NULL,
{NULL}
NULL
};
menu_t SR_MusicTestDef =
@@ -2925,7 +2936,7 @@ menu_t SR_MusicTestDef =
60, 150,
0,
NULL,
{NULL}
NULL
};
menu_t SR_EmblemHintDef =
@@ -2938,7 +2949,7 @@ menu_t SR_EmblemHintDef =
60, 150,
0,
NULL,
{NULL}
NULL
};
// Single Player
@@ -2954,7 +2965,7 @@ menu_t SP_LevelStatsDef =
280, 185,
0,
NULL,
{NULL}
NULL
};
static menu_t SP_TimeAttackDef =
@@ -2967,7 +2978,7 @@ static menu_t SP_TimeAttackDef =
34, 40,
0,
M_QuitTimeAttackMenu,
{NULL}
NULL
};
static menu_t SP_ReplayDef =
{
@@ -2979,7 +2990,7 @@ static menu_t SP_ReplayDef =
34, 40,
0,
NULL,
{NULL}
NULL
};
static menu_t SP_GuestReplayDef =
{
@@ -2991,7 +3002,7 @@ static menu_t SP_GuestReplayDef =
34, 40,
0,
NULL,
{NULL}
NULL
};
static menu_t SP_GhostDef =
{
@@ -3003,7 +3014,7 @@ static menu_t SP_GhostDef =
34, 40,
0,
NULL,
{NULL}
NULL
};
// Multiplayer
@@ -3021,7 +3032,7 @@ menu_t MP_MainDef =
#else
NULL,
#endif
{NULL}
NULL
};
menu_t MP_OfflineServerDef = MAPICONMENUSTYLE("M_MULTI", MP_OfflineServerMenu, &MP_MainDef);
@@ -3039,7 +3050,7 @@ menu_t MP_ConnectDef =
27,24,
0,
M_CancelConnect,
{NULL}
NULL
};
#endif
menu_t MP_PlayerSetupDef =
@@ -3052,7 +3063,7 @@ menu_t MP_PlayerSetupDef =
36, 14,
0,
M_QuitMultiPlayerMenu,
{NULL}
NULL
};
// Options
@@ -3066,18 +3077,18 @@ menu_t OP_MainDef =
60, 25,
0,
NULL,
{NULL}
NULL
};
menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30);
menu_t OP_ControlsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_ControlsMenu, &OP_MainDef, 60, 30, OP_ControlsTooltips);
//WTF
menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30);
menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef);
menu_t OP_Joystick1Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 30, 36);
menu_t OP_Joystick2Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 30, 36);
menu_t OP_Joystick3Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 30, 36);
menu_t OP_Joystick4Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 30, 36);
menu_t OP_JoystickSetDef =
menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE("M_CONTRO", OP_MouseOptionsMenu, &OP_ControlsDef, 60, 30, OP_MouseTooltips);
menu_t OP_AllControlsDef = CONTROLMENUSTYLE(OP_AllControlsMenu, &OP_ControlsDef);
menu_t OP_Joystick1Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick1Menu, &OP_AllControlsDef, 30, 36, NULL);
menu_t OP_Joystick2Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick2Menu, &OP_AllControlsDef, 30, 36, NULL);
menu_t OP_Joystick3Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick3Menu, &OP_AllControlsDef, 30, 36, NULL);
menu_t OP_Joystick4Def = DEFAULTSCROLLSTYLE("M_CONTRO", OP_Joystick4Menu, &OP_AllControlsDef, 30, 36, NULL);
menu_t OP_JoystickSetDef =
{
"M_CONTRO",
sizeof (OP_JoystickSetMenu)/sizeof (menuitem_t),
@@ -3087,7 +3098,7 @@ menu_t OP_JoystickSetDef =
50, 40,
0,
NULL,
{NULL}
NULL
};
menu_t OP_VideoOptionsDef =
@@ -3100,7 +3111,7 @@ menu_t OP_VideoOptionsDef =
30, 15,
0,
NULL,
{NULL}
OP_VideoTooltips
};
menu_t OP_VideoModeDef =
@@ -3113,7 +3124,7 @@ menu_t OP_VideoModeDef =
48, 26,
0,
NULL,
{NULL}
NULL
};
menu_t OP_ColorOptionsDef =
@@ -3126,7 +3137,7 @@ menu_t OP_ColorOptionsDef =
30, 30,
0,
NULL,
{NULL}
NULL
};
menu_t OP_SoundOptionsDef =
@@ -3139,7 +3150,7 @@ menu_t OP_SoundOptionsDef =
30, 20,
0,
NULL,
{NULL}
OP_SoundTooltips
};
@@ -3153,25 +3164,25 @@ menu_t OP_HUDOptionsDef =
30, 20,
0,
NULL,
{NULL}
NULL
};
menu_t OP_CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_CamOptionsMenu, &OP_MainDef, 30, 30);
menu_t OP_Player1CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player1CamOptionsMenu, &OP_CamOptionsDef, 30, 30);
menu_t OP_Player2CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player2CamOptionsMenu, &OP_CamOptionsDef, 30, 30);
menu_t OP_Player3CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player3CamOptionsMenu, &OP_CamOptionsDef, 30, 30);
menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu, &OP_CamOptionsDef, 30, 30);
menu_t OP_CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_CamOptionsMenu, &OP_MainDef, 30, 30, OP_CamOptionsTooltips);
menu_t OP_Player1CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player1CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips);
menu_t OP_Player2CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player2CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips);
menu_t OP_Player3CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player3CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips);
menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu, &OP_CamOptionsDef, 30, 30, OP_PlayerCamOptionsTooltips);
menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30);
menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30, OP_ChatOptionsTooltips);
menu_t OP_SoundAdvancedDef = DEFAULTSCROLLSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30);
menu_t OP_SoundAdvancedDef = DEFAULTSCROLLSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30, OP_SoundAdvancedTooltips);
menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 17, 30);
menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 17, 30, OP_FocusOptionsTooltips);
menu_t OP_GameOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_GameOptionsMenu, &OP_MainDef, 30, 20);
menu_t OP_ServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 24, 20);
menu_t OP_GameOptionsDef = DEFAULTMENUSTYLE("M_GAME", OP_GameOptionsMenu, &OP_MainDef, 30, 20, OP_GameTooltips);
menu_t OP_ServerOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_ServerOptionsMenu, &OP_MainDef, 24, 20, OP_ServerOptionsTooltips);
#ifndef NONET
menu_t OP_AdvServerOptionsDef = DEFAULTSCROLLSTYLE("M_SERVER", OP_AdvServerOptionsMenu, &OP_ServerOptionsDef, 24, 30);
menu_t OP_AdvServerOptionsDef = DEFAULTSCROLLSTYLE("M_SERVER", OP_AdvServerOptionsMenu, &OP_ServerOptionsDef, 24, 30, OP_AdvServerOptionsTooltips);
#endif
//menu_t OP_NetgameOptionsDef = DEFAULTMENUSTYLE("M_SERVER", OP_NetgameOptionsMenu, &OP_ServerOptionsDef, 30, 30);
@@ -3187,38 +3198,38 @@ menu_t OP_MonitorToggleDef =
47, 30,
0,
NULL,
{NULL}
NULL
};
#ifdef HWRENDER
menu_t OP_OpenGLOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30);
menu_t OP_OpenGLOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30, OP_OpenGLTooltips);
#endif
menu_t OP_ExpOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 25);
menu_t OP_ExpOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 25, OP_ExpTooltips);
menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30);
menu_t OP_ScreenshotOptionsDef = DEFAULTSCROLLSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30);
menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30);
menu_t OP_ProtocolDef = DEFAULTMENUSTYLE(NULL, OP_ProtocolMenu, &OP_DataOptionsDef, 30, 30);
menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30, NULL);
menu_t OP_ScreenshotOptionsDef = DEFAULTSCROLLSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 30, NULL);
menu_t OP_AddonsOptionsDef = DEFAULTMENUSTYLE("M_ADDONS", OP_AddonsOptionsMenu, &OP_DataOptionsDef, 30, 30, NULL);
menu_t OP_ProtocolDef = DEFAULTMENUSTYLE(NULL, OP_ProtocolMenu, &OP_DataOptionsDef, 30, 30, NULL);
#ifdef HAVE_DISCORDRPC
menu_t OP_DiscordOptionsDef = DEFAULTMENUSTYLE(NULL, OP_DiscordOptionsMenu, &OP_DataOptionsDef, 30, 30);
menu_t OP_DiscordOptionsDef = DEFAULTMENUSTYLE(NULL, OP_DiscordOptionsMenu, &OP_DataOptionsDef, 30, 30, NULL);
#endif
menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 30, 30);
menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 30, 30, NULL);
menu_t OP_SaturnDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnMenu, &OP_MainDef, 30, 30);
menu_t OP_PlayerDistortDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_PlayerDistortMenu, &OP_SaturnDef, 30, 30);
menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnHudDef, 30, 30);
menu_t OP_SaturnHudDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnHudMenu, &OP_SaturnDef, 30, 30);
menu_t OP_SaturnDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnMenu, &OP_MainDef, 30, 30, OP_SaturnTooltips);
menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 0, NULL); // OP_CreditTooltips no space :c
menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 0);
menu_t OP_SaturnHudDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnHudMenu, &OP_SaturnDef, 30, 30, OP_SaturnHudTooltips);
menu_t OP_PlayerDistortDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_PlayerDistortMenu, &OP_SaturnDef, 30, 30, OP_PlayerDistortTooltips);
menu_t OP_HudOffsetDef = DEFAULTSCROLLSTYLE(NULL, OP_HudOffsetMenu, &OP_SaturnHudDef, 30, 30, NULL);
menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30);
menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30, OP_BirdTooltips);
menu_t OP_NametagDef = DEFAULTMENUSTYLE(NULL, OP_NametagMenu, &OP_SaturnHudDef, 30, 40);
menu_t OP_DriftGaugeDef = DEFAULTMENUSTYLE(NULL, OP_DriftGaugeMenu, &OP_SaturnHudDef, 30, 40);
menu_t OP_NametagDef = DEFAULTMENUSTYLE(NULL, OP_NametagMenu, &OP_SaturnHudDef, 30, 40, OP_NametagTooltips);
menu_t OP_DriftGaugeDef = DEFAULTMENUSTYLE(NULL, OP_DriftGaugeMenu, &OP_SaturnHudDef, 30, 40, OP_DriftGaugeTooltips);
menu_t OP_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60);
menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60);
menu_t OP_TiltDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_BirdDef, 30, 60, OP_TiltTooltips);
menu_t OP_AdvancedBirdDef = DEFAULTMENUSTYLE(NULL, OP_AdvancedBirdMenu, &OP_BirdDef, 30, 60, OP_AdvancedBirdTooltips);
INT16 ccvarposition = 0;
@@ -3235,7 +3246,7 @@ static void M_CustomCvarMenu(INT32 choice)
/*menu_t OP_CustomCvarMenuDef = DEFAULTSCROLLMENUSTYLE(
MTREE3(MN_OP_MAIN, MN_OP_DATA, MN_OP_ADDONS),
"M_ADDONS", OP_CustomCvarMenu, &OP_MainDef, 30, 30);*/
menu_t OP_CustomCvarMenuDef = DEFAULTSCROLLSTYLE("M_ADDONS", OP_CustomCvarMenu, &OP_MainDef, 10, 30);
menu_t OP_CustomCvarMenuDef = DEFAULTSCROLLSTYLE("M_ADDONS", OP_CustomCvarMenu, &OP_MainDef, 10, 30, NULL);
menu_t OP_ForkedBirdDef = {
NULL,
@@ -3246,10 +3257,10 @@ menu_t OP_ForkedBirdDef = {
30, 6,
0,
NULL,
{NULL}
NULL
};
menu_t OP_LocalSkinDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_ForkedBirdDef, 30, 60);
menu_t OP_LocalSkinDef = DEFAULTMENUSTYLE(NULL, OP_TiltMenu, &OP_ForkedBirdDef, 30, 60, NULL);
// ==========================================================================
@@ -4870,6 +4881,9 @@ void M_Init(void)
//todo put this somewhere better...
CV_RegisterVar(&cv_allcaps);
memset(menu_text_input_buf, 0, sizeof menu_text_input_buf);
M_TextInputInit(&menuinput, menu_text_input_buf, sizeof menu_text_input_buf);
}
void M_InitCharacterTables(void)
@@ -5186,6 +5200,16 @@ static void M_DrawSplitText(INT32 x, INT32 y, INT32 option, const char* str, INT
free(clines);
}
static void M_DoToolTips(menu_t* menu)
{
if (!menu->tooltips || itemOn == -1 || !menu->tooltips[itemOn])
return;
M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, menu->tooltips[itemOn], coolalphatimer);
if ((coolalphatimer > 0) && interpTimerHackAllow)
coolalphatimer--;
}
static void M_DrawGenericMenu(void)
{
@@ -5332,23 +5356,7 @@ static void M_DrawGenericMenu(void)
// dumb hack
// tooltips
// replaced with macro so it doesent look as terrible anymore lol
DoToolTips(OP_ControlsDef, OP_ControlsTooltips);
DoToolTips(OP_MouseOptionsDef, OP_MouseTooltips);
DoToolTips(OP_VideoOptionsDef, OP_VideoTooltips);
DoToolTips(OP_SoundOptionsDef, OP_SoundTooltips);
DoToolTips(OP_FocusOptionsDef, OP_FocusOptionsTooltips);
DoToolTips(OP_ChatOptionsDef, OP_ChatOptionsTooltips);
DoToolTips(OP_GameOptionsDef, OP_GameTooltips);
DoToolTips(OP_ServerOptionsDef, OP_ServerOptionsTooltips);
//DoToolTips(OP_SaturnCreditsDef, OP_CreditTooltips); // C:
DoToolTips(OP_BirdDef, OP_BirdTooltips);
DoToolTips(OP_TiltDef, OP_TiltTooltips);
DoToolTips(OP_AdvancedBirdDef, OP_AdvancedBirdTooltips);
DoToolTips(OP_NametagDef, OP_NametagTooltips);
DoToolTips(OP_DriftGaugeDef, OP_DriftGaugeTooltips);
DoToolTips(OP_CamOptionsDef, OP_CamOptionsTooltips);
DoToolTips(OP_Player1CamOptionsDef || currentMenu == &OP_Player2CamOptionsDef || currentMenu == &OP_Player3CamOptionsDef || currentMenu == &OP_Player4CamOptionsDef, OP_PlayerCamOptionsTooltips); // god this one is still terrible lmao
M_DoToolTips(currentMenu);
}
static void M_DrawGenericBackgroundMenu(void)
@@ -5479,16 +5487,7 @@ static void M_DrawGenericScrollMenu(void)
// dumb hack
// tooltips
// same macro here
DoToolTips(OP_ExpOptionsDef, OP_ExpTooltips);
#ifdef HWRENDER
DoToolTips(OP_OpenGLOptionsDef, OP_OpenGLTooltips);
#endif
DoToolTips(OP_SaturnDef, OP_SaturnTooltips);
DoToolTips(OP_SaturnHudDef, OP_SaturnHudTooltips);
DoToolTips(OP_AdvServerOptionsDef, OP_AdvServerOptionsTooltips);
DoToolTips(OP_SoundAdvancedDef, OP_SoundAdvancedTooltips);
DoToolTips(OP_PlayerDistortDef, OP_PlayerDistortTooltips);
M_DoToolTips(currentMenu);
}
static void M_DrawPauseMenu(void)
@@ -5722,8 +5721,16 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt)
{
case LLM_CREATESERVER:
// Should the map be hidden? <-- well imma wanna toggle it, its just annoying being unable to select hell maps in mapselect
if ((mapheaderinfo[mapnum]->menuflags & LF2_HIDEINMENU && mapnum+1 != gamemap) && (gt == GT_RACE && (mapheaderinfo[mapnum]->typeoflevel & TOL_RACE))) // map hell
return cv_showallmaps.value;
if (mapheaderinfo[mapnum]->menuflags & LF2_HIDEINMENU && mapnum+1 != gamemap)
{
if (cv_showallmaps.value &&
((gt == GT_RACE && (mapheaderinfo[mapnum]->typeoflevel & TOL_RACE)) || // race map hell
((gt == GT_MATCH || gt == GT_TEAMMATCH) && (mapheaderinfo[mapnum]->typeoflevel & TOL_MATCH)))) // battle map hell
return true;
else
return false;
}
// same goes here, just show every map if i want to
if (M_MapLocked(mapnum+1)) // not unlocked
@@ -5803,7 +5810,7 @@ menu_t MessageDef =
0, 0, // x, y (TO HACK)
0, // lastOn, flags (TO HACK)
NULL,
{0},
NULL,
};
@@ -6065,8 +6072,8 @@ static void M_AddonsOptions(INT32 choice)
M_SetupNextMenu(&OP_AddonsOptionsDef);
}
#define LOCATIONSTRING1 "Visit \x83SRB2.ORG/MODS\x80 to get & make addons!"
#define LOCATIONSTRING2 "Visit \x88SRB2.ORG/MODS\x80 to get & make addons!"
#define LOCATIONSTRING1 "Visit \x83mb.srb2.org/addons\x80 to get & make addons!"
#define LOCATIONSTRING2 "Visit \x88mb.srb2.org/addons\x80 to get & make addons!"
static void M_AddonsInternal(void)
{
@@ -6296,6 +6303,8 @@ static boolean M_AddonsRefresh(void)
return false;
}
static tic_t addons_scrolltic = 0; // maybe not the best place but e
static void M_DrawAddons(void)
{
INT32 x, y;
@@ -6303,6 +6312,8 @@ static void M_DrawAddons(void)
const UINT8 *flashcol = NULL;
UINT8 hilicol;
if (renderisnewtic) addons_scrolltic++;
// hack - need to refresh at end of frame to handle addfile...
if (refreshdirmenu & M_AddonsRefresh())
{
@@ -6386,6 +6397,9 @@ static void M_DrawAddons(void)
for (; i < m; i++)
{
UINT32 flags = V_ALLOWLOWERCASE;
#define MAXADDONNAME 31
char scrollbuf[MAXADDONNAME+1] = {0};
if (y > BASEVIDHEIGHT) break;
if (dirmenu[i])
#define type (UINT8)(dirmenu[i][DIR_TYPE])
@@ -6406,11 +6420,22 @@ static void M_DrawAddons(void)
}
#define charsonside 14
if (dirmenu[i][DIR_LEN] > (charsonside*2 + 3))
V_DrawString(x, y+4, flags, va("%.*s...%s", charsonside, dirmenu[i]+DIR_STRING, dirmenu[i]+DIR_STRING+dirmenu[i][DIR_LEN]-(charsonside+1)));
if (dirmenu[i][DIR_LEN] > MAXADDONNAME)
{
if ((size_t)i == dir_on[menudepthleft])
{
M_ScrollString(dirmenu[i]+DIR_STRING, dirmenu[i][DIR_LEN]-1, scrollbuf, MAXADDONNAME, addons_scrolltic);
}
else
strncpy(scrollbuf, va("%.*s...%s", charsonside, dirmenu[i]+DIR_STRING, dirmenu[i]+DIR_STRING+dirmenu[i][DIR_LEN]-(charsonside+1)), MAXADDONNAME);
V_DrawString(x, y+4, flags, scrollbuf);
}
#undef charsonside
else
V_DrawString(x, y+4, flags, dirmenu[i]+DIR_STRING);
#undef MAXADDONNAME
}
#undef type
y += 16;
@@ -6535,11 +6560,13 @@ static void M_HandleAddons(INT32 choice)
case KEY_DOWNARROW:
if (dir_on[menudepthleft] < sizedirmenu-1)
dir_on[menudepthleft]++;
addons_scrolltic = 0;
S_StartSound(NULL, sfx_menu1);
break;
case KEY_UPARROW:
if (dir_on[menudepthleft])
dir_on[menudepthleft]--;
addons_scrolltic = 0;
S_StartSound(NULL, sfx_menu1);
break;
case KEY_PGDN:
@@ -6548,6 +6575,7 @@ static void M_HandleAddons(INT32 choice)
for (i = numaddonsshown; i && (dir_on[menudepthleft] < sizedirmenu-1); i--)
dir_on[menudepthleft]++;
}
addons_scrolltic = 0;
S_StartSound(NULL, sfx_menu1);
break;
case KEY_PGUP:
@@ -6556,6 +6584,7 @@ static void M_HandleAddons(INT32 choice)
for (i = numaddonsshown; i && (dir_on[menudepthleft]); i--)
dir_on[menudepthleft]--;
}
addons_scrolltic = 0;
S_StartSound(NULL, sfx_menu1);
break;
case KEY_ENTER:
@@ -6695,6 +6724,7 @@ static void M_HandleAddons(INT32 choice)
case KEY_ESCAPE:
exitmenu = true;
addons_scrolltic = 0;
break;
default:
@@ -6867,6 +6897,32 @@ static void M_HutCheckReplays(size_t maxnum)
}
}
static int ReplayListSortComparator(const void *entry1, const void *entry2)
{
const menudemo_t *demo1 = (const menudemo_t*)entry1;
const menudemo_t *demo2 = (const menudemo_t*)entry2;
char filepath1[sizeof(demo1->filepath)];
char filepath2[sizeof(demo2->filepath)];
// First check for directories, they always should be at the top
if (demo1->type == MD_SUBDIR && demo2->type != MD_SUBDIR)
return -1;
else if (demo2->type == MD_SUBDIR && demo1->type != MD_SUBDIR)
return 1;
else if (demo1->type == MD_SUBDIR && demo2->type == MD_SUBDIR)
return 0;
memcpy(filepath1, demo1->filepath, sizeof(filepath1));
memcpy(filepath2, demo2->filepath, sizeof(filepath2));
nameonly(filepath1);
nameonly(filepath2);
// Comparing in opposite order to move new replays to the top
return strncmp(filepath2, filepath1, sizeof(filepath1));
}
static void PrepReplayList(boolean reset)
{
size_t i;
@@ -6910,6 +6966,8 @@ static void PrepReplayList(boolean reset)
}
}
qs22j(demolist_all, sizedirmenu, sizeof(menudemo_t), ReplayListSortComparator);
Unlock_search_state();
LoadReplayNames();
@@ -8433,51 +8491,6 @@ static musicdef_t *curplaying = NULL;
static INT32 st_sel = 0;
static tic_t st_musictime = 0;
static void scrollMusicName(const char name[], size_t len, size_t maxlen, char result[])
{
// How much should we scroll. Not sure why +1 is needed, but without it this function skips 2
// characters at once sometimes
const size_t amount = len - maxlen + 1;
// Note: anything above 17 will cause zero division
const size_t MAXSPEED = 6;
const size_t t = st_musictime / (35/min(amount, MAXSPEED));
const size_t state = (t / amount) % 4;
switch (state)
{
// Show beginning of the name
case 0:
memcpy(result, name, maxlen-1);
break;
// Scroll towards end of the name
case 1:
{
const size_t advance = t % amount;
memcpy(result, name+advance, maxlen-1);
}
break;
// Show end of the name
case 2:
memcpy(result, name+len+1-maxlen, maxlen-1);
break;
// Scroll towards start of the name
case 3:
{
const size_t advance = t % amount;
memcpy(result, name+len+1-maxlen-advance, maxlen-1);
}
break;
}
// Technically not necessary, since it gets set again after function call, but just in case
result[maxlen] = 0;
}
static void M_MusicTest(INT32 choice)
{
(void)choice;
@@ -8619,7 +8632,7 @@ static void M_DrawMusicTest(void)
char buf[MAXLENGTH+1];
if (t == st_sel && namelength > MAXLENGTH)
scrollMusicName(songname, namelength, MAXLENGTH, buf);
M_ScrollString(songname, namelength, buf, MAXLENGTH, st_musictime);
else
strncpy(buf, songname, MAXLENGTH);
buf[MAXLENGTH] = 0;
@@ -9596,7 +9609,7 @@ Fetch_servers_thread (int *id)
}
#endif/*MASTERSERVER*/
#define SERVERHEADERHEIGHT 36
#define SERVERHEADERHEIGHT 48
#define SERVERLINEHEIGHT 12
#define S_LINEY(n) currentMenu->y + SERVERHEADERHEIGHT + (n * SERVERLINEHEIGHT)
@@ -9604,6 +9617,57 @@ Fetch_servers_thread (int *id)
#ifndef NONET
static UINT32 localservercount;
static void M_SearchServerList(void)
{
char servername[MAXSERVERNAME+1] = {0};
serverlistsearchedcount = 0;
for (UINT32 i = 0; i < serverlistcount; ++i)
{
StripColors(servername, serverlist[i].info.servername, MAXSERVERNAME);
if (menuinput.length == 0 || strcasestr(servername, menuinput.buffer) != NULL)
serverlistsearched[serverlistsearchedcount++] = i;
}
if (menuinput.length > 0)
serverlistpage = 0;
}
static void M_HandleServerSearch(INT32 choice)
{
boolean exitmenu = false; // exit to previous menu
switch (choice)
{
case KEY_DOWNARROW:
M_NextOpt();
S_StartSound(NULL, sfx_menu1);
break;
case KEY_UPARROW:
M_PrevOpt();
S_StartSound(NULL, sfx_menu1);
break;
case KEY_ESCAPE:
exitmenu = true;
break;
default:
if (M_TextInputHandle(&menuinput, choice))
{
S_StartSound(NULL, sfx_menu1);
M_SearchServerList();
}
break;
}
if (exitmenu)
{
if (currentMenu->prevMenu)
M_SetupNextMenu(currentMenu->prevMenu);
else
M_ClearMenus(true);
}
}
static void M_HandleServerPage(INT32 choice)
{
boolean exitmenu = false; // exit to previous menu
@@ -9626,7 +9690,7 @@ static void M_HandleServerPage(INT32 choice)
case KEY_ENTER:
case KEY_RIGHTARROW:
S_StartSound(NULL, sfx_menu1);
if ((serverlistpage + 1) * SERVERS_PER_PAGE < serverlistcount)
if ((serverlistpage + 1) * SERVERS_PER_PAGE < serverlistsearchedcount)
{
oldserverlistpage = serverlistpage++;
serverlistslidex = BASEVIDWIDTH;
@@ -9657,7 +9721,7 @@ static void M_Connect(INT32 choice)
{
// do not call menuexitfunc
M_ClearMenus(false);
COM_BufAddText(va("connect node %d\n", serverlist[choice-FIRSTSERVERLINE + serverlistpage * SERVERS_PER_PAGE].node));
COM_BufAddText(va("connect node %d\n", serverlist[serverlistsearched[choice-FIRSTSERVERLINE + serverlistpage * SERVERS_PER_PAGE]].node));
}
static void M_Refresh(INT32 choice)
@@ -9715,11 +9779,11 @@ static void M_DrawServerCountAndHorizontalBar(void)
radius = V_StringWidth(text, 0) / 2;
V_DrawCenteredString(center, currentMenu->y+28, 0, text);
V_DrawCenteredString(center, currentMenu->y+40, 0, text);
// Horizontal line!
V_DrawFill(1, currentMenu->y+32, center - radius - 2, 1, 0);
V_DrawFill(center + radius + 2, currentMenu->y+32, BASEVIDWIDTH - 1, 1, 0);
V_DrawFill(1, currentMenu->y+44, center - radius - 2, 1, 0);
V_DrawFill(center + radius + 2, currentMenu->y+44, BASEVIDWIDTH - 1, 1, 0);
}
#endif
@@ -9729,9 +9793,9 @@ static void M_DrawServerLines(INT32 x, INT32 page)
const char *gt = "Unknown";
const char *spd = "";
for (i = 0; i < min(serverlistcount - page * SERVERS_PER_PAGE, SERVERS_PER_PAGE); i++)
for (i = 0; i < min(serverlistsearchedcount - page * SERVERS_PER_PAGE, SERVERS_PER_PAGE); i++)
{
INT32 slindex = i + page * SERVERS_PER_PAGE;
INT32 slindex = serverlistsearched[i + page * SERVERS_PER_PAGE];
UINT32 globalflags = ((serverlist[slindex].info.numberofplayer >= serverlist[slindex].info.maxplayer) ? V_TRANSLUCENT : 0)
|((itemOn == FIRSTSERVERLINE+i) ? highlightflags : 0)|V_ALLOWLOWERCASE;
@@ -9770,7 +9834,7 @@ static void M_DrawServerLines(INT32 x, INT32 page)
static void M_DrawConnectMenu(void)
{
UINT16 i;
INT32 numPages = (serverlistcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE;
INT32 numPages = (serverlistsearchedcount+(SERVERS_PER_PAGE-1))/SERVERS_PER_PAGE;
INT32 mservflags = V_ALLOWLOWERCASE;
for (i = FIRSTSERVERLINE; i < min(localservercount, SERVERS_PER_PAGE)+FIRSTSERVERLINE; i++)
@@ -9820,6 +9884,17 @@ static void M_DrawConnectMenu(void)
M_DrawServerLines(currentMenu->x, serverlistpage);
}
INT32 input_y = currentMenu->menuitems[mp_connect_search].alphaKey;
V_DrawFill(currentMenu->x, currentMenu->y+input_y, MAXSTRINGLENGTH*8+6, 8+6, 239);
const INT32 xoff = 3, yoff = 3;
if (itemOn != mp_connect_search)
V_DrawString(currentMenu->x+xoff, currentMenu->y+yoff+input_y, V_ALLOWLOWERCASE, menuinput.buffer);
else
M_DrawTextInput(currentMenu->x+xoff, currentMenu->y+yoff+input_y, &menuinput, 0);
localservercount = serverlistcount;
M_DrawGenericMenu();
@@ -9899,6 +9974,7 @@ void M_SortServerList(void)
qs22j(serverlist, serverlistcount, sizeof(serverelem_t), ServerListEntryComparator_gametype);
break;
}
M_SearchServerList();
#endif
}
@@ -9957,6 +10033,9 @@ static void M_ConnectMenu(INT32 choice)
CL_UpdateServerList();
// Reset
M_TextInputSetString(&menuinput, "");
M_SetupNextMenu(&MP_ConnectDef);
itemOn = 0;
@@ -10212,17 +10291,28 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
if (cv_nextmap.value && cv_showtrackaddon.value)
{
static tic_t namescroll = 0;
static INT32 namescrollmap = 0;
char namescrollbuf[64]= {0};
if (cv_nextmap.value != namescrollmap)
{
namescrollmap = cv_nextmap.value;
namescroll = 0;
}
if (renderisnewtic) namescroll++;
char *addonname = wadfiles[mapwads[cv_nextmap.value-1]]->filename;
INT32 len;
INT32 charlimit = 21 + (dupadjust/5);
INT32 charlimit = min((size_t)(21 + (dupadjust/5)), sizeof(namescrollbuf)-1);
nameonly(addonname);
len = strlen(addonname);
#define charsonside 14
if (len > charlimit)
V_DrawThinString(x+w+5, y+i-8, V_TRANSLUCENT|MENUCAPS, va("%.*s...%s", charsonside, addonname, addonname+((len-charlimit) + charsonside))); // variable reuse...
#undef charsonside
M_ScrollString(addonname, len, namescrollbuf, charlimit, namescroll);
else
V_DrawThinString(x+w+5, y+i-8, V_TRANSLUCENT|MENUCAPS, addonname); // variable reuse...
strncpy(namescrollbuf, addonname, sizeof(namescrollbuf));
V_DrawThinString(x+w+5, y+i-8, V_TRANSLUCENT|MENUCAPS, namescrollbuf); // variable reuse...
}
if (!cv_kartencore.value || gamestate == GS_TIMEATTACK || cv_newgametype.value != GT_RACE)
+17 -28
View File
@@ -212,14 +212,14 @@ extern menuitem_t PlayerMenu[MAXSKINS];
typedef struct menu_s
{
const char *menutitlepic;
INT16 numitems; // # of menu items
struct menu_s *prevMenu; // previous menu
menuitem_t *menuitems; // menu items
void (*drawroutine)(void); // draw routine
INT16 x, y; // x, y of menu
INT16 lastOn; // last item user was on in menu
boolean (*quitroutine)(void); // called before quit a menu return true if we can
const char* tooltips[MAXTOOLTIPS]; // tooltips! give me that info bitch
INT16 numitems; // # of menu items
struct menu_s *prevMenu; // previous menu
menuitem_t *menuitems; // menu items
void (*drawroutine)(void); // draw routine
INT16 x, y; // x, y of menu
INT16 lastOn; // last item user was on in menu
boolean (*quitroutine)(void); // called before quit a menu return true if we can
const char* *tooltips; // tooltips! give me that info bitch
} menu_t;
void M_SetupNextMenu(menu_t *menudef);
@@ -335,7 +335,7 @@ void M_PopupMasterServerConnectError(void);
void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* name);
// These defines make it a little easier to make menus
#define DEFAULTMENUSTYLE(header, source, prev, x, y)\
#define DEFAULTMENUSTYLE(header, source, prev, x, y, tooltip)\
{\
header,\
sizeof(source)/sizeof(menuitem_t),\
@@ -345,10 +345,10 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
x, y,\
0,\
NULL,\
{NULL}\
tooltip\
}
#define DEFAULTSCROLLSTYLE(header, source, prev, x, y)\
#define DEFAULTSCROLLSTYLE(header, source, prev, x, y, tooltip)\
{\
header,\
sizeof(source)/sizeof(menuitem_t),\
@@ -358,7 +358,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
x, y,\
0,\
NULL,\
{NULL}\
tooltip\
}
@@ -372,7 +372,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
x, y,\
0,\
NULL,\
{NULL}\
NULL\
}
#define CENTERMENUSTYLE(header, source, prev, y)\
@@ -385,7 +385,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
BASEVIDWIDTH/2, y,\
0,\
NULL,\
{NULL}\
NULL\
}
#define MAPICONMENUSTYLE(header, source, prev)\
@@ -398,7 +398,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
24,40,\
0,\
NULL,\
{NULL}\
NULL\
}
#define CONTROLMENUSTYLE(source, prev)\
@@ -411,7 +411,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
26, 40,\
0,\
NULL,\
{NULL}\
NULL\
}
#define IMAGEDEF(source)\
@@ -424,18 +424,7 @@ void M_SlotCvarIntoModMenu(consvar_t* cvar, const char* category, const char* na
0, 0,\
0,\
NULL,\
{NULL}\
}
#define DoToolTips(menu, tooltip)\
if (currentMenu == &menu)\
{\
if (!(tooltip[itemOn] == NULL))\
{\
M_DrawSplitText(BASEVIDWIDTH / 2, BASEVIDHEIGHT-50, V_ALLOWLOWERCASE|V_SNAPTOBOTTOM, tooltip[itemOn], coolalphatimer);\
if (coolalphatimer > 0 && interpTimerHackAllow)\
coolalphatimer--;\
}\
NULL\
}
#ifdef __cplusplus
+127
View File
@@ -1604,6 +1604,52 @@ boolean M_ScreenshotResponder(event_t *ev)
return true;
}
void M_ScrollString(const char name[], size_t len, char result[], size_t maxlen, tic_t timer)
{
// How much should we scroll. Not sure why +1 is needed, but without it this function skips 2
// characters at once sometimes
const size_t amount = len - maxlen + 1;
// Note: anything above 17 will cause zero division
const size_t MAXSPEED = 6;
const tic_t t = timer / (35/min(amount, MAXSPEED));
const size_t state = (t / amount) % 4;
switch (state)
{
// Show beginning of the name
case 0:
memcpy(result, name, maxlen-1);
break;
// Scroll towards end of the name
case 1:
{
const size_t advance = t % amount;
memcpy(result, name+advance, maxlen-1);
}
break;
// Show end of the name
case 2:
memcpy(result, name+len+1-maxlen, maxlen-1);
break;
// Scroll towards start of the name
case 3:
{
const size_t advance = t % amount;
memcpy(result, name+len+1-maxlen-advance, maxlen-1);
}
break;
}
// Technically not necessary, since it gets set again after function call, but just in case
result[maxlen] = 0;
}
void M_MinimapGenerate(void)
{
#ifdef USE_PNG
@@ -1762,6 +1808,87 @@ INT32 axtoi(const char *hexStg)
return intValue;
}
void CopyCaretColors(char *p, const char *s, int n)
{
char *t;
int m;
int c;
if (!n)
return;
while (( t = strchr(s, '^') ))
{
m = ( t - s );
if (m >= n)
{
memcpy(p, s, n);
return;
}
else
memcpy(p, s, m);
p += m;
n -= m;
s += m;
if (!n)
return;
if (s[1])
{
c = toupper(s[1]);
if (isdigit(c))
c = 0x80 + ( c - '0' );
else if (c >= 'A' && c <= 'F')
c = 0x80 + ( c - 'A' );
else
c = 0;
if (c)
{
*p++ = c;
n--;
if (!n)
return;
}
else
{
if (n < 2)
break;
memcpy(p, s, 2);
p += 2;
n -= 2;
}
s += 2;
}
else
break;
}
strncpy(p, s, n);
}
void StripColors(char *dst, char *src, size_t n)
{
size_t j = 0;
for (size_t i = 0; j < n && src[i] != 0; ++i)
{
char c = src[i];
if ((c & 0x80) == 0)
dst[j++] = c;
}
dst[j] = 0;
}
/** Token parser for TEXTURES, ANIMDEFS, and potentially other lumps later down the line.
* Was originally R_GetTexturesToken when I was coding up the TEXTURES parser, until I realized I needed it for ANIMDEFS too.
* Parses up to the next whitespace character or comma. When finding the start of the next token, whitespace is skipped.
+7
View File
@@ -73,6 +73,8 @@ void M_ScreenShot(void);
void M_DoScreenShot(void);
boolean M_ScreenshotResponder(event_t *ev);
void M_ScrollString(const char name[], size_t len, char result[], size_t maxlen, tic_t timer);
void M_MinimapGenerate(void);
void Command_SaveConfig_f(void);
@@ -85,6 +87,11 @@ void M_SaveConfig(const char *filename);
INT32 axtoi(const char *hexStg);
void CopyCaretColors(char *p, const char *s, int n);
// Remove color codes from string
void StripColors(char *dst, char *src, size_t n);
const char *GetRevisionString(void);
// Vector/matrix math
+4
View File
@@ -30,7 +30,11 @@ typedef union
typedef struct
{
msg_header_t header;
#ifndef HAVE_IPV6
char ip[16];
#else
char ip[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"];
#endif
char port[8];
char contact[32];
char version[8]; // format is: x.yy.z (like 1.30.2 or 1.31)
+3 -1
View File
@@ -1542,15 +1542,17 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source)
{
if (target->target->hnext)
K_KillBananaChain(target->target->hnext, inflictor, source);
target->target->player->kartstuff[k_itemamount] = 0;
}
else if (target->target->player->kartstuff[k_itemamount])
else
target->target->player->kartstuff[k_itemamount]--;
}
else if ((target->type == MT_ORBINAUT_SHIELD && target->target->player->kartstuff[k_itemtype] == KITEM_ORBINAUT) // orbit items
|| (target->type == MT_JAWZ_SHIELD && target->target->player->kartstuff[k_itemtype] == KITEM_JAWZ))
{
target->target->player->kartstuff[k_itemamount]--;
if (target->lastlook != 0)
{
K_RepairOrbitChain(target);
+2
View File
@@ -158,6 +158,8 @@ extern consvar_t cv_tiltsmoothing;
extern consvar_t cv_actionmovie;
extern consvar_t cv_screenquake;
extern consvar_t cv_lookbackmom[MAXSPLITSCREENPLAYERS];
extern consvar_t cv_verticallook[MAXSPLITSCREENPLAYERS];
+37 -35
View File
@@ -1691,7 +1691,7 @@ static boolean PIT_CheckLine(line_t *ld)
boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
{
INT32 xl, xh, yl, yh, bx, by;
subsector_t *newsubsec;
sector_t *newsec;
boolean blockval = true;
ps_checkposition_calls.value.i++;
@@ -1714,9 +1714,9 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
tmbbox[BOXLEFT] = x - tmthing->radius;
if (thing->x != x || thing->y != y || thing->subsector == NULL)
newsubsec = R_PointInSubsector(x, y);
newsec = R_PointInSubsector(x, y)->sector;
else
newsubsec = thing->subsector;
newsec = thing->subsector->sector;
ceilingline = blockingline = NULL;
@@ -1724,33 +1724,34 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y)
// that contains the point.
// Any contacted lines the step closer together
// will adjust them.
tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->floorheight;
tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight;
tmfloorslope = newsubsec->sector->f_slope;
tmceilingslope = newsubsec->sector->c_slope;
tmfloorz = tmdropoffz = P_GetFloorZ(thing, newsec, x, y, NULL); //newsec->floorheight;
tmceilingz = P_GetCeilingZ(thing, newsec, x, y, NULL); //newsec->ceilingheight;
tmfloorslope = newsec->f_slope;
tmceilingslope = newsec->c_slope;
// Check list of fake floors and see if tmfloorz/tmceilingz need to be altered.
if (newsubsec->sector->ffloors)
if (newsec->ffloors)
{
ffloor_t *rover;
fixed_t delta1, delta2;
INT32 thingtop = thing->z + thing->height;
for (rover = newsubsec->sector->ffloors; rover; rover = rover->next)
for (rover = newsec->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight, midheight;
if (!(rover->flags & FF_EXISTS))
continue;
topheight = P_GetFOFTopZ(thing, newsubsec->sector, rover, x, y, NULL);
bottomheight = P_GetFOFBottomZ(thing, newsubsec->sector, rover, x, y, NULL);
topheight = P_GetFOFTopZ(thing, newsec, rover, x, y, NULL);
bottomheight = P_GetFOFBottomZ(thing, newsec, rover, x, y, NULL);
if ((rover->flags & (FF_SWIMMABLE|FF_GOOWATER)) == (FF_SWIMMABLE|FF_GOOWATER) && !(thing->flags & MF_NOGRAVITY))
{
// If you're inside goowater and slowing down
fixed_t sinklevel = FixedMul(thing->info->height/6, thing->scale);
fixed_t minspeed = FixedMul(thing->info->height/9, thing->scale);
if (thing->z < topheight && bottomheight < thingtop
&& abs(thing->momz) < minspeed)
{
@@ -1984,7 +1985,7 @@ void P_CheckHoopPosition(mobj_t *hoopthing, fixed_t x, fixed_t y, fixed_t z, fix
boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
{
INT32 xl, xh, yl, yh, bx, by;
subsector_t *newsubsec;
sector_t *newsec;
tmx = x;
tmy = y;
@@ -1995,15 +1996,15 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
tmbbox[BOXLEFT] = x - thiscam->radius;
if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL)
newsubsec = R_PointInSubsector(x, y);
newsec = R_PointInSubsectorFast(x, y)->sector;
else
newsubsec = thiscam->subsector;
newsec = thiscam->subsector->sector;
ceilingline = blockingline = NULL;
mapcampointer = thiscam;
if (GETSECSPECIAL(newsubsec->sector->special, 4) == 12)
if (GETSECSPECIAL(newsec->special, 4) == 12)
{ // Camera noclip on entire sector.
tmfloorz = tmdropoffz = thiscam->z;
tmceilingz = tmdrpoffceilz = thiscam->z + thiscam->height;
@@ -2014,45 +2015,47 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
// that contains the point.
// Any contacted lines the step closer together
// will adjust them.
tmfloorz = tmdropoffz = P_CameraGetFloorZ(thiscam, newsubsec->sector, x, y, NULL);
tmfloorz = tmdropoffz = P_CameraGetFloorZ(thiscam, newsec, x, y, NULL);
tmceilingz = P_CameraGetCeilingZ(thiscam, newsubsec->sector, x, y, NULL);
tmceilingz = P_CameraGetCeilingZ(thiscam, newsec, x, y, NULL);
// Cameras use the heightsec's heights rather then the actual sector heights.
// If you can see through it, why not move the camera through it too?
if (newsubsec->sector->heightsec >= 0)
if (newsec->heightsec >= 0)
{
tmfloorz = tmdropoffz = sectors[newsubsec->sector->heightsec].floorheight;
tmceilingz = tmdrpoffceilz = sectors[newsubsec->sector->heightsec].ceilingheight;
tmfloorz = tmdropoffz = sectors[newsec->heightsec].floorheight;
tmceilingz = tmdrpoffceilz = sectors[newsec->heightsec].ceilingheight;
}
// Use preset camera clipping heights if set with Sector Special Parameters whose control sector has Camera Intangible special -Red
if (newsubsec->sector->camsec >= 0)
if (newsec->camsec >= 0)
{
tmfloorz = tmdropoffz = sectors[newsubsec->sector->camsec].floorheight;
tmceilingz = tmdrpoffceilz = sectors[newsubsec->sector->camsec].ceilingheight;
tmfloorz = tmdropoffz = sectors[newsec->camsec].floorheight;
tmceilingz = tmdrpoffceilz = sectors[newsec->camsec].ceilingheight;
}
// Check list of fake floors and see if tmfloorz/tmceilingz need to be altered.
if (newsubsec->sector->ffloors)
if (newsec->ffloors)
{
ffloor_t *rover;
fixed_t delta1, delta2;
INT32 thingtop = thiscam->z + thiscam->height;
for (rover = newsubsec->sector->ffloors; rover; rover = rover->next)
for (rover = newsec->ffloors; rover; rover = rover->next)
{
fixed_t topheight, bottomheight;
if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERALL) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12)
continue;
topheight = P_CameraGetFOFTopZ(thiscam, newsubsec->sector, rover, x, y, NULL);
bottomheight = P_CameraGetFOFBottomZ(thiscam, newsubsec->sector, rover, x, y, NULL);
topheight = P_CameraGetFOFTopZ(thiscam, newsec, rover, x, y, NULL);
bottomheight = P_CameraGetFOFBottomZ(thiscam, newsec, rover, x, y, NULL);
delta1 = thiscam->z - (bottomheight
+ ((topheight - bottomheight)/2));
delta2 = thingtop - (bottomheight
+ ((topheight - bottomheight)/2));
if (topheight > tmfloorz && abs(delta1) < abs(delta2))
{
tmfloorz = tmdropoffz = topheight;
@@ -2171,8 +2174,6 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam)
boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
{
subsector_t *s;
boolean retval = true;
UINT8 i;
floatok = false;
@@ -2181,7 +2182,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
return false;
if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL)
s = R_PointInSubsector(x, y);
s = R_PointInSubsectorFast(x, y);
else
s = thiscam->subsector;
@@ -2222,12 +2223,12 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
else
tryy = y;
if (!P_CheckCameraPosition(tryx, tryy, thiscam))
return false; // solid wall or thing
if (tmceilingz - tmfloorz < thiscam->height)
return false; // doesn't fit
if (!P_CheckCameraPosition(tryx, tryy, thiscam))
return false; // solid wall or thing
floatok = true;
if (tmceilingz - thiscam->z < thiscam->height)
@@ -2248,7 +2249,8 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
if ((tmfloorz - thiscam->z > MAXCAMERASTEPMOVE))
return false; // too big a step up
} while(tryx != x || tryy != y);
} while (tryx != x || tryy != y);
}
else
{
@@ -2265,7 +2267,7 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam)
thiscam->y = y;
thiscam->subsector = s;
return retval;
return true;
}
//
+1 -1
View File
@@ -908,7 +908,7 @@ void P_SetUnderlayPosition(mobj_t *thing)
void P_SetPrecipitationThingPosition(precipmobj_t *thing)
{
thing->subsector = R_PointInSubsector(thing->x, thing->y);
thing->subsector = R_PointInSubsectorFast(thing->x, thing->y);
// NOTE: this works because bnext/bprev are at the same
// offsets in precipmobj_t and mobj_t
+67 -86
View File
@@ -178,7 +178,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
// Set animation state
// The pflags version of this was just as convoluted.
// Rewriten for SRB2kart ... though I don't know what this is.
switch(state)
switch (state)
{
case S_KART_STND1...S_KART_STND2_R:
case S_KART_SQUISH:
@@ -203,7 +203,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
do
{
if (state == S_NULL)
if (UNLIKELY(state == S_NULL))
{ // Bad SOC!
CONS_Alert(CONS_ERROR, "Cannot remove player mobj by setting its state to S_NULL.\n");
//P_RemoveMobj(mobj);
@@ -239,7 +239,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
state = st->nextstate;
} while (!mobj->tics && !seenstate[state]);
if (!mobj->tics)
if (UNLIKELY(!mobj->tics))
CONS_Alert(CONS_WARNING, M_GetText("State cycle detected, exiting.\n"));
if (!--recursion)
@@ -306,7 +306,7 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state)
state = st->nextstate;
} while (!mobj->tics && !seenstate[state]);
if (!mobj->tics)
if (UNLIKELY(!mobj->tics))
CONS_Alert(CONS_WARNING, M_GetText("State cycle detected, exiting.\n"));
if (!--recursion)
@@ -777,7 +777,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix
testy += y;
// If the highest point is in the sector, then we have it easy! Just get the Z at that point
if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
if (R_PointInSubsectorFast(testx, testy)->sector == (boundsec ? boundsec : sector))
return P_GetSlopeZAt(slope, testx, testy);
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
@@ -856,7 +856,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f
testy += y;
// If the highest point is in the sector, then we have it easy! Just get the Z at that point
if (R_PointInSubsector(testx, testy)->sector == (boundsec ? boundsec : sector))
if (R_PointInSubsectorFast(testx, testy)->sector == (boundsec ? boundsec : sector))
return P_GetSlopeZAt(slope, testx, testy);
// If boundsec is set, we're looking for specials. In that case, iterate over every line in this sector to find the TRUE highest/lowest point
@@ -1916,11 +1916,9 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover)
I_Assert(mo != NULL);
I_Assert(!P_MobjWasRemoved(mo));
fixed_t topheight = P_GetFFloorTopZAt(rover, mo->x, mo->y);
if (rover->flags & FF_SWIMMABLE && GETSECSPECIAL(rover->master->frontsector->special, 1) == 3
&& !(rover->master->flags & ML_BLOCKMONSTERS)
&& ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > topheight - FixedMul(16*FRACUNIT, mo->scale)))
&& ((rover->master->flags & ML_EFFECT3) || mo->z-mo->momz > P_GetFFloorTopZAt(rover, mo->x, mo->y) - FixedMul(16*FRACUNIT, mo->scale)))
return true;
return false;
@@ -3308,7 +3306,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
}
}
thiscam->subsector = R_PointInSubsector(thiscam->x, thiscam->y);
thiscam->subsector = R_PointInSubsectorFast(thiscam->x, thiscam->y);
thiscam->floorz = tmfloorz;
thiscam->ceilingz = tmceilingz;
@@ -3367,6 +3365,7 @@ boolean P_CameraThinker(player_t *player, camera_t *thiscam, boolean resetcalled
thiscam->ceilingz = thiscam->z + thiscam->height;
thiscam->floorz = thiscam->z;
}
return false;
}
@@ -3392,7 +3391,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
mobj->eflags &= ~MFE_JUSTSTEPPEDDOWN;
// Zoom tube
if (mobj->tracer && mobj->tracer->type == MT_TUBEWAYPOINT)
if (UNLIKELY(mobj->tracer && mobj->tracer->type == MT_TUBEWAYPOINT))
{
P_UnsetThingPosition(mobj);
mobj->x += mobj->momx;
@@ -3402,7 +3401,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
P_CheckPosition(mobj, mobj->x, mobj->y);
goto animonly;
}
else if (mobj->player->pflags & PF_MACESPIN && mobj->tracer)
else if (UNLIKELY(mobj->player->pflags & PF_MACESPIN && mobj->tracer))
{
P_CheckPosition(mobj, mobj->x, mobj->y);
goto animonly;
@@ -3421,7 +3420,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
else
P_TryMove(mobj, mobj->x, mobj->y, true);
if (!(netgame && mobj->player->spectator))
if (LIKELY(!(netgame && mobj->player->spectator)))
{
// Crumbling platforms
for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next)
@@ -3468,6 +3467,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
}
}
}
if (thereiswater)
{
for (node = mobj->touching_sectorlist; node; node = node->m_sectorlist_next)
@@ -6015,7 +6015,8 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
return 0;
// if mobj doesent have any of those, no need to do the rest
if (mobj->roll == 0 && mobj->pitch == 0 && mobj->sloperoll == 0 && mobj->slopepitch == 0)
if (mobj->roll == 0 && mobj->pitch == 0
&& mobj->sloperoll == 0 && mobj->slopepitch == 0)
return 0;
size_t rot = (mobj->frame & FF_FRAMEMASK);
@@ -6041,7 +6042,8 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
sprframe = &sprdef->spriteframes[rot];
// No sprite frame? I guess it is possible
if (!sprframe) return 0;
if (!sprframe)
return 0;
if (sprframe->rotate != SRF_SINGLE || (mobj->frame & FF_PAPERSPRITE))
{
@@ -6050,9 +6052,9 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj)
}
return_angle = FixedMul(FINECOSINE((ang) >> ANGLETOFINESHIFT), mobj->roll)
+ FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch)
+ FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll)
+ FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch);
+ FixedMul(FINESINE((ang) >> ANGLETOFINESHIFT), mobj->pitch)
+ FixedMul(FINECOSINE((camang) >> ANGLETOFINESHIFT), mobj->sloperoll)
+ FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), mobj->slopepitch);
return return_angle;
}
@@ -6065,7 +6067,7 @@ void P_MobjThinker(mobj_t *mobj)
I_Assert(mobj != NULL);
I_Assert(!P_MobjWasRemoved(mobj));
if (mobj->flags & MF_NOTHINK)
if (UNLIKELY(mobj->flags & MF_NOTHINK))
return;
// Remove dead target/tracer.
@@ -6084,11 +6086,12 @@ void P_MobjThinker(mobj_t *mobj)
tmfloorthing = tmhitthing = NULL;
const sector_t *sec1 = mobj->subsector ? mobj->subsector->sector : NULL;
// 970 allows ANY mobj to trigger a linedef exec
if (mobj->subsector && GETSECSPECIAL(mobj->subsector->sector->special, 2) == 8)
if (UNLIKELY(!mobj->islocal && sec1 && GETSECSPECIAL(sec1->special, 2) == 8)) // BEWARE: islocal does not exist in vanilla
{
sector_t *sec2;
sec2 = P_ThingOnSpecial3DFloor(mobj);
if (sec2 && GETSECSPECIAL(sec2->special, 2) == 1)
P_LinedefExecute(sec2->tag, mobj, sec2);
@@ -8808,7 +8811,7 @@ void P_MobjThinker(mobj_t *mobj)
mobj->angle = R_PointToAngle2(mobj->x, mobj->y, mobj->target->x, mobj->target->y);
}
if (mobj->flags & MF_AMBIENT)
if (UNLIKELY(mobj->flags & MF_AMBIENT))
{
if (!(leveltime % mobj->health) && mobj->info->seesound)
S_StartSound(mobj, mobj->info->seesound);
@@ -9049,21 +9052,21 @@ void P_MobjThinker(mobj_t *mobj)
mobj->eflags &= ~MFE_JUSTHITFLOOR;
}
if (mobj->type == MT_FLINGRING
if (UNLIKELY(mobj->type == MT_FLINGRING
|| mobj->type == MT_FLINGCOIN
|| P_WeaponOrPanel(mobj->type)
|| mobj->type == MT_FLINGEMERALD
|| mobj->type == MT_BIGTUMBLEWEED
|| mobj->type == MT_LITTLETUMBLEWEED
|| mobj->type == MT_CANNONBALLDECOR
|| mobj->type == MT_FALLINGROCK) {
|| mobj->type == MT_CANNONBALLDECOR)
|| mobj->type == MT_FALLINGROCK)
{
P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly
//if (mobj->standingslope) CONS_Printf("slope physics on mobj\n");
P_ButteredSlope(mobj);
}
if (mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health
&& P_CheckDeathPitCollide(mobj)) // extra pit check in case these didn't have momz
if (UNLIKELY(mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health
&& P_CheckDeathPitCollide(mobj))) // extra pit check in case these didn't have momz
{
P_KillMobj(mobj, NULL, NULL);
return;
@@ -9072,10 +9075,10 @@ void P_MobjThinker(mobj_t *mobj)
// Crush enemies!
if (mobj->ceilingz - mobj->floorz < mobj->height)
{
if ((
if (UNLIKELY((
(mobj->flags & (MF_ENEMY|MF_BOSS)
&& mobj->flags & MF_SHOOTABLE)
|| mobj->type == MT_EGGSHIELD)
|| mobj->type == MT_EGGSHIELD))
&& !(mobj->flags & MF_NOCLIPHEIGHT)
&& mobj->health > 0)
{
@@ -9093,30 +9096,21 @@ void P_MobjThinker(mobj_t *mobj)
if (P_MobjWasRemoved(mobj))
return;
switch (mobj->type)
if (UNLIKELY(P_WeaponOrPanel(mobj->type)))
{
case MT_BOUNCEPICKUP:
case MT_RAILPICKUP:
case MT_AUTOPICKUP:
case MT_EXPLODEPICKUP:
case MT_SCATTERPICKUP:
case MT_GRENADEPICKUP:
if (mobj->health == 0) // Fading tile
{
INT32 value = mobj->info->damage/10;
value = mobj->fuse/value;
value = 10-value;
value--;
if (mobj->health == 0) // Fading tile
{
INT32 value = mobj->info->damage/10;
value = mobj->fuse/value;
value = 10-value;
value--;
if (value <= 0)
value = 1;
if (value <= 0)
value = 1;
mobj->frame &= ~FF_TRANSMASK;
mobj->frame |= value << FF_TRANSSHIFT;
}
break;
default:
break;
mobj->frame &= ~FF_TRANSMASK;
mobj->frame |= value << FF_TRANSSHIFT;
}
}
}
@@ -9931,8 +9925,7 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype
mobj->precipflags |= PCF_FOF;
else
{
INT32 special = GETSECSPECIAL(mobj->subsector->sector->special, 1);
const INT32 special = GETSECSPECIAL(mobj->subsector->sector->special, 1);
if (special == 7 || special == 6 || mobj->subsector->sector->floorpic == skyflatnum)
mobj->precipflags |= PCF_PIT;
}
@@ -9964,14 +9957,14 @@ void P_RemoveMobj(mobj_t *mobj)
mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; // needed for P_UnsetThingPosition, etc. to work.
// Rings only, please!
if (mobj->spawnpoint &&
if (UNLIKELY(mobj->spawnpoint &&
(mobj->type == MT_RING
|| mobj->type == MT_COIN
|| mobj->type == MT_BLUEBALL
|| mobj->type == MT_REDTEAMRING
|| mobj->type == MT_BLUETEAMRING
|| P_WeaponOrPanel(mobj->type))
&& !(mobj->flags2 & MF2_DONTRESPAWN))
&& !(mobj->flags2 & MF2_DONTRESPAWN)))
{
itemrespawnque[iquehead] = mobj->spawnpoint;
itemrespawntime[iquehead] = leveltime;
@@ -9993,13 +9986,13 @@ void P_RemoveMobj(mobj_t *mobj)
}
}
if (mobj->type == MT_OVERLAY)
if (UNLIKELY(mobj->type == MT_OVERLAY))
P_RemoveOverlay(mobj);
if (mobj->type == MT_SHADOW)
if (UNLIKELY(mobj->type == MT_SHADOW))
P_RemoveShadow(mobj);
if (mobj->type == MT_SPB)
if (UNLIKELY(mobj->type == MT_SPB))
spbplace = -1;
mobj->health = 0; // Just because
@@ -10011,6 +10004,7 @@ void P_RemoveMobj(mobj_t *mobj)
P_DelSeclist(sector_list);
sector_list = NULL;
}
mobj->flags |= MF_NOSECTOR|MF_NOBLOCKMAP;
mobj->subsector = NULL;
mobj->state = NULL;
@@ -10046,46 +10040,33 @@ void P_RemoveMobj(mobj_t *mobj)
R_RemoveMobjInterpolator(mobj);
// free block
// DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error.
if (mobj->flags & MF_NOTHINK && !mobj->thinker.next)
{ // Uh-oh, the mobj doesn't think, P_RemoveThinker would never go through!
if (!mobj->thinker.references)
{
#ifdef SCRAMBLE_REMOVED
// Invalidate mobj_t data to cause crashes if accessed!
memset(mobj, 0xff, sizeof(mobj_t));
#endif
// no references, dump it directly in the mobj cache
mobj->hnext = mobjcache;
mobjcache = mobj;
return;
}
else
{ // Add thinker just to delay removing it until refrences are gone.
mobj->flags &= ~MF_NOTHINK;
P_AddThinker((thinker_t *)mobj);
#ifdef PARANOIA
// Saved to avoid being scrambled like below...
mobj->thinker.debug_mobjtype = mobj->type;
#endif
#ifdef SCRAMBLE_REMOVED
// Invalidate mobj_t data to cause crashes if accessed!
memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t));
#endif
P_RemoveThinker((thinker_t *)mobj);
}
// Add thinker just to delay removing it until refrences are gone.
mobj->flags &= ~MF_NOTHINK;
P_AddThinker((thinker_t *)mobj);
}
else
{
P_RemoveThinker((thinker_t *)mobj);
#ifdef PARANOIA
// Saved to avoid being scrambled like below...
mobj->thinker.debug_mobjtype = mobj->type;
// Saved to avoid being scrambled like below...
mobj->thinker.debug_mobjtype = mobj->type;
#endif
// DBG: set everything in mobj_t to 0xFF instead of leaving it. debug memory error.
#ifdef SCRAMBLE_REMOVED
// Invalidate mobj_t data to cause crashes if accessed!
memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t));
// Invalidate mobj_t data to cause crashes if accessed!
memset((UINT8 *)mobj + sizeof(thinker_t), 0xff, sizeof(mobj_t) - sizeof(thinker_t));
#endif
P_RemoveThinker((thinker_t *)mobj);
}
}
void P_FreePrecipMobj(precipmobj_t *mobj)
@@ -10319,7 +10300,7 @@ void P_PrecipitationEffects(void)
for (y = yl; y <= yh; y += RADIUSSTEP)
for (x = xl; x <= xh; x += RADIUSSTEP)
{
if (R_PointInSubsector((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors!
if (R_PointInSubsectorFast((fixed_t)x, (fixed_t)y)->sector->ceilingpic != skyflatnum) // Found the outdoors!
continue;
newdist = S_CalculateSoundDistance(players[displayplayers[0]].mo->x, players[displayplayers[0]].mo->y, 0, (fixed_t)x, (fixed_t)y, 0);
+1
View File
@@ -414,6 +414,7 @@ typedef struct mobj_s
boolean init_salty;
// WARNING: New fields must be added separately to savegame and Lua.
boolean islocal; // BEWARE: islocal does not exist in vanilla, strictly to be used for locally loaded addons to not cause desynchs with the mobj linedef trigger check. DO NOT USE THIS IN ACTUAL ADDONS YOU INTEND TO USE ON YOUR SERVER
} mobj_t;
//
+3 -3
View File
@@ -2510,7 +2510,6 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam)
cam->y = players[pnum].mo->y;
cam->z = players[pnum].mo->z;
cam->angle = players[pnum].mo->angle;
cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
}
else
{
@@ -2535,9 +2534,10 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam)
cam->y = thing->y;
cam->z = thing->z;
cam->angle = FixedAngle((fixed_t)thing->angle << FRACBITS);
cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
}
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18)
cam->chase = false; // tell camera to reset its position next tic
}
@@ -3071,7 +3071,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate)
if (!fromnetsave) // uglier hack
{ // to make a newly loaded level start on the second frame.
INT32 buf = gametic % TICQUEUE;
INT32 buf = gametic % BACKUPTICS;
for (i = 0; i < MAXPLAYERS; i++)
{
+1 -1
View File
@@ -2022,7 +2022,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
camera[i].y += y;
camera[i].z += z;
camera[i].reset = true;
camera[i].subsector = R_PointInSubsector(camera[i].x, camera[i].y);
camera[i].subsector = R_PointInSubsectorFast(camera[i].x, camera[i].y);
R_RelativeTeleportViewInterpolation(i, x, y, z, 0);
break;
}
+3 -3
View File
@@ -573,7 +573,7 @@ static void P_RunQuakes(void)
{
fixed_t ir;
if (quake.time <= 0)
if (!cv_screenquake.value || quake.time <= 0)
{
quake.x = quake.y = quake.z = quake.roll = 0;
return;
@@ -618,8 +618,8 @@ static inline void P_ResetSpriteStuff(void)
if (!mo || (mo->sprite == SPR_NULL) || (mo->flags2 & MF2_DONTDRAW) || (mo->type == MT_SHADOW))
continue;
mo->spritexscale = mo->realxscale;
mo->spriteyscale = mo->realyscale;
mo->spritexscale = mo->realxscale;
mo->spriteyscale = mo->realyscale;
mo->spritexoffset = mo->realxoffset;
mo->spriteyoffset = mo->realyoffset;
}
+5 -3
View File
@@ -3044,6 +3044,8 @@ consvar_t cv_tiltsmoothing = {"tiltsmoothing", "32", CV_SAVE, CV_Natural, NULL,
consvar_t cv_actionmovie = {"actionmovie", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_screenquake = {"quakescreenshake", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Double"}, {0, NULL}};
consvar_t cv_lookbackmom[MAXSPLITSCREENPLAYERS] = {
@@ -3402,7 +3404,7 @@ static void P_DemoCameraMovement(camera_t *cam, UINT8 num)
}
// update subsector to avoid crashes;
cam->subsector = R_PointInSubsector(cam->x, cam->y);
cam->subsector = R_PointInSubsectorFast(cam->x, cam->y);
}
void P_ResetCamera(player_t *player, camera_t *thiscam)
@@ -3446,7 +3448,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
thiscam->relativex = 0;
thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y);
thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y);
thiscam->radius = 20*FRACUNIT;
thiscam->height = 16*FRACUNIT;
@@ -3682,7 +3684,7 @@ static void P_MoveCameraToSpawn(UINT8 playernum)
thiscam->angle = player->mo->angle;
thiscam->aiming = 0;
thiscam->subsector = R_PointInSubsector(thiscam->x,thiscam->y);
thiscam->subsector = R_PointInSubsectorFast(thiscam->x,thiscam->y);
thiscam->reset_aiming = true;
+5 -5
View File
@@ -196,12 +196,12 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel,
mobj_t *pviewmobj = viewplayer->mo;
INT32 heightsec;
boolean underwater;
UINT8 i = R_GetViewNumber();
camera_t *thiscam = &camera[R_GetViewNumber()];
if (viewplayer == &players[displayplayers[i]] && camera[i].chase)
heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec;
else if (i > splitscreen && viewmobj)
heightsec = R_PointInSubsector(pviewmobj->x, pviewmobj->y)->sector->heightsec;
if (thiscam->chase)
heightsec = thiscam->subsector->sector->heightsec;
else if (viewmobj)
heightsec = pviewmobj->subsector->sector->heightsec;
else
return sec;
+37 -7
View File
@@ -103,7 +103,7 @@ static UINT32 **texturecolumnofs; // column offset lookup table for each texture
UINT8 **texturecache; // graphics data for each generated full-size texture
// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask
INT32 *texturewidthmask;
static INT32 *texturewidthmask;
fixed_t *textureheight; // needed for texture pegging
@@ -473,11 +473,28 @@ UINT8 *R_GetColumn(fixed_t tex, INT32 col)
{
UINT8 *data;
col &= texturewidthmask[tex];
data = texturecache[tex];
if (texturewidthmask[tex])
col &= texturewidthmask[tex]; // set by load textures
else
{
const INT16 texwidth = textures[tex]->width;
// Odd width texture, cannot just mask.
// Sometime gets colnum = -1 or = width, even without tiling.
// Test LostCiv, Map 20, crates.
col = ( col < 0 ) ?
texwidth - (((-col - 1) % texwidth) + 1)
: col % texwidth;
}
if (!data)
{
// This must be here because cache can be freed by other operations.
// To prevent must lock individual texture cache on every draw.
data = R_GenerateTexture(tex);
}
return data + LONG(texturecolumnofs[tex][col]);
}
@@ -662,9 +679,23 @@ void R_LoadTextures(void)
Z_Free(patchlump);
// determine width power of 2
#if 1
// [WDJ] only need to determine if exact power of 2.
k = 1;
while (k < texture->width)
k<<=1;
#else
// Largest power of 2 that fits within width.
k = 1;
while (k << 1 <= texture->width)
k <<= 1;
#endif
if (k != texture->width)
{
// Odd width
k = 1; // make texturewidthmask = 0
}
texturewidthmask[i] = k - 1;
textureheight[i] = texture->height << FRACBITS;
@@ -1223,8 +1254,7 @@ static void R_InitColormaps(void)
// Load in the light tables
lump = W_GetNumForName("COLORMAP");
//Z_MallocAlign(W_LumpLength (lump), PU_STATIC, NULL, 8);
colormaps = Z_MallocAlign((256 * 64), PU_STATIC, NULL, 8);
colormaps = Z_Malloc((256 * 64), PU_STATIC, NULL);
W_ReadLump(lump, colormaps);
// no need to init encoremap at this stage
@@ -1265,7 +1295,7 @@ void R_ReInitColormaps(UINT16 num, lumpnum_t newencoremap)
lighttable_t *colormap_p, *colormap_p2;
size_t p, i;
encoremap = Z_MallocAlign(256 + 10, PU_LEVEL, NULL, 8);
encoremap = Z_Malloc(256 + 10, PU_LEVEL, NULL);
W_ReadLump(newencoremap, encoremap);
colormap_p = colormap_p2 = colormaps;
colormap_p += (256 * 32);
@@ -1324,7 +1354,7 @@ void R_ClearColormaps(void)
foundcolormaps[num_extra_colormaps] = lump;
// aligned on 8 bit for asm code
extra_colormaps[num_extra_colormaps].colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16);
extra_colormaps[num_extra_colormaps].colormap = Z_Malloc(W_LumpLength(lump), PU_LEVEL, NULL);
W_ReadLump(lump, extra_colormaps[num_extra_colormaps].colormap);
// We set all params of the colormap to normal because there
@@ -1520,7 +1550,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3)
}
// Now allocate memory for the actual colormap array itself!
colormap_p = Z_MallocAlign((256 * (encoremap ? 64 : 32)) + 10, PU_LEVEL, NULL, 8);
colormap_p = Z_Malloc((256 * (encoremap ? 64 : 32)) + 10, PU_LEVEL, NULL);
extra_colormaps[mapnum].colormap = (UINT8 *)colormap_p;
// Calculate the palette index for each palette index, for each light level
-4
View File
@@ -55,7 +55,6 @@ typedef struct
UINT8 type; // TEXTURETYPE_
INT16 width, height;
boolean holes;
// All the patches[patchcount] are drawn back to front into the cached texture.
INT16 patchcount;
texpatch_t patches[0];
@@ -65,9 +64,6 @@ typedef struct
extern texture_t **textures;
extern UINT8 **texturecache; // graphics data for each generated full-size texture
// texture width is a power of 2, so it can easily repeat along sidedefs using a simple mask
extern INT32 *texturewidthmask;
extern fixed_t *textureheight; // needed for texture pegging
UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha);
+3 -3
View File
@@ -119,7 +119,7 @@ void R_InitTranslucencyTables(void)
// Load here the transparency lookup tables 'TRANSx0'
// NOTE: the TRANSx0 resources MUST BE aligned on 64k for the asm
// optimised code (in other words, transtables pointer low word is 0)
transtables = static_cast<UINT8*>(Z_MallocAlign(NUMTRANSTABLES*0x10000, PU_STATIC, NULL, 16));
transtables = static_cast<UINT8*>(Z_Malloc(NUMTRANSTABLES*0x10000, PU_STATIC, NULL));
W_ReadLump(W_GetNumForName("TRANS10"), transtables);
W_ReadLump(W_GetNumForName("TRANS20"), transtables+0x10000);
@@ -246,7 +246,7 @@ static void R_GenerateBlendTables(void)
INT32 i;
for (i = 0; i < NUMBLENDMAPS; i++)
blendtables[i] = static_cast<UINT8*>(Z_MallocAlign(BlendTab_Count[i] * 0x10000, PU_STATIC, NULL, 16));
blendtables[i] = static_cast<UINT8*>(Z_Malloc(BlendTab_Count[i] * 0x10000, PU_STATIC, NULL));
InitColorLUT(&transtab_lut, pLocalPalette, false);
@@ -365,7 +365,7 @@ static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 f
// Generate the colormap if necessary
if (!ret)
{
ret = static_cast<UINT8*>(Z_MallocAlign(NUM_PALETTE_ENTRIES, (flags & GTC_CACHE) ? PU_LEVEL : PU_STATIC, NULL, 8));
ret = static_cast<UINT8*>(Z_Malloc(NUM_PALETTE_ENTRIES, (flags & GTC_CACHE) ? PU_LEVEL : PU_STATIC, NULL));
K_GenerateKartColormap(ret, skinnum, color, local); //R_GenerateTranslationColormap(ret, skinnum, color); // SRB2kart
// Cache the colormap if desired
+14 -1
View File
@@ -46,10 +46,23 @@ enum DrawSpanType
DS_RIPPLE = 0x0008,
};
template<DrawSpanType Type>
static constexpr UINT8 R_GetSpanTranslated(drawspandata_t* ds, UINT8 col)
{
if constexpr (Type & DrawSpanType::DS_COLORMAP)
{
return ds->translation[col];
}
else
{
return col;
}
}
template<DrawSpanType Type>
static constexpr UINT8 R_GetSpanTranslucent(drawspandata_t* ds, UINT8 *dsrc, const UINT8 *colormap, UINT8 col)
{
col = colormap[col];
col = colormap[R_GetSpanTranslated<Type>(ds, col)];
if constexpr (Type & DrawSpanType::DS_TRANSMAP)
{
+9 -21
View File
@@ -42,13 +42,13 @@ static CV_PossibleValue_t fpscap_cons_t[] = {
{0, NULL}
};
consvar_t cv_fpscap = {"fpscap", "Match refresh rate", CV_SAVE, fpscap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fpscap = {"fpscap", "Match refresh rate", CV_SAVE, fpscap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_fpscapbg = {"fpscapbackground", "Match refresh rate", CV_SAVE, fpscap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_precipinterp = {"precipinterpolation", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
ps_metric_t ps_interp_frac = {0};
ps_metric_t ps_interp_lag = {0};
ps_metric_t ps_interp_lag = {0};
static boolean R_UseBackgroundFramerateCap(void)
{
@@ -67,21 +67,21 @@ static boolean R_UseBackgroundFramerateCap(void)
return false;
}
static UINT32 R_GetBackgroundFramerateCap(void)
static UINT32 R_GetFrameCap(INT32 val)
{
if (cv_fpscapbg.value == 0)
if (val == 0)
{
// 0: Match refresh rate
return I_GetRefreshRate();
}
if (cv_fpscapbg.value < 0)
if (val < 0)
{
// -1: Unlimited
return 0;
}
return cv_fpscapbg.value;
return val;
}
UINT32 R_GetFramerateCap(void)
@@ -95,22 +95,10 @@ UINT32 R_GetFramerateCap(void)
if (R_UseBackgroundFramerateCap())
{
return R_GetBackgroundFramerateCap();
return R_GetFrameCap(cv_fpscapbg.value);
}
if (cv_fpscap.value == 0)
{
// 0: Match refresh rate
return I_GetRefreshRate();
}
if (cv_fpscap.value < 0)
{
// -1: Unlimited
return 0;
}
return cv_fpscap.value;
return R_GetFrameCap(cv_fpscap.value);
}
boolean R_UsingFrameInterpolation(void)
@@ -232,7 +220,7 @@ void R_InterpolateView(fixed_t frac, boolean forceinvalid)
viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT);
viewplayer = newview->player;
viewsector = R_PointInSubsector(viewx, viewy)->sector;
viewsector = R_PointInSubsectorFast(viewx, viewy)->sector;
R_SetupFreelook();
}
+79 -48
View File
@@ -141,10 +141,10 @@ static CV_PossibleValue_t drawdist_precip_cons_t[] = {
#endif
static CV_PossibleValue_t maxinterpdist_cons_t[] = {
/*{256, "256"},*/ {512, "512"}, {768, "768"},
{1024, "1024"}, {1536, "1536"}, {2048, "2048"},
{3072, "3072"}, {4096, "4096"}, {6144, "6144"},
{8192, "8192"}, {0, "Infinite"}, {0, NULL}};
/*{256, "256"},*/ {512, "512"}, {768, "768"},
{1024, "1024"}, {1536, "1536"}, {2048, "2048"},
{3072, "3072"}, {4096, "4096"}, {6144, "6144"},
{8192, "8192"}, {0, "Infinite"}, {0, NULL}};
static CV_PossibleValue_t fov_cons_t[] = {{MINFOV*FRACUNIT, "MIN"}, {MAXFOV*FRACUNIT, "MAX"}, {0, NULL}};
@@ -170,14 +170,14 @@ consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnO
consvar_t cv_precachetextures = {"precachetextures", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS] = {
{"chasecam", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"chasecam", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"chasecam2", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"chasecam3", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL},
{"chasecam4", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}
};
consvar_t cv_flipcam[MAXSPLITSCREENPLAYERS] = {
{"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"flipcam", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"flipcam2", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam2_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"flipcam3", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam3_OnChange, 0, NULL, NULL, 0, 0, NULL},
{"flipcam4", "No", CV_SAVE|CV_CALL|CV_NOINIT, CV_YesNo, FlipCam4_OnChange, 0, NULL, NULL, 0, 0, NULL}
@@ -195,6 +195,7 @@ consvar_t cv_drawdist_precip = {"drawdist_precip", "1024", CV_SAVE|CV_CALL|CV_NO
consvar_t cv_lessprecip = {"lessweathereffects", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_mobjscaleprecip = {"scaleprecipmobjscale", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Precipstuff_OnChange, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_maxinterpdist = {"maxinterpdist", "Infinite", CV_SAVE, maxinterpdist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_playerfade = {"playerfade", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_ripplewater = {"waterripples", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
// Okay, whoever said homremoval causes a performance hit should be shot.
@@ -211,6 +212,7 @@ consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE|CV_CALL
consvar_t cv_showhud = {"showhud", "Yes", CV_CALL, CV_YesNo, R_SetViewSize, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_translucenthud = {"translucenthud", "10", CV_SAVE, translucenthud_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_uncappedhud = {"uncappedhud", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_soniccd = {"soniccd", "Off", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_allowmlook = {"allowmlook", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -400,7 +402,8 @@ angle_t R_PlayerSliptideAngle(player_t *player)
sprframe = &sprdef->spriteframes[rot];
// No sprite frame? I guess it is possible
if (!sprframe) return 0;
if (!sprframe)
return 0;
if (sprframe->rotate != SRF_SINGLE || (mo->frame & FF_PAPERSPRITE))
ang = R_PointToAngle(mo->x, mo->y) - mo->angle;
@@ -460,6 +463,7 @@ boolean R_DoCulling(line_t *cullheight, line_t *viewcullheight, fixed_t vz, fixe
return false;
cullplane = cullheight->frontsector->floorheight;
if (cullheight->flags & ML_NOCLIMB) // Group culling
{
if (!viewcullheight)
@@ -579,8 +583,6 @@ static void R_InitTextureMapping(void)
doubleclipangle = clipangle*2;
}
//
// R_InitLightTables
// Only inits the zlight table,
@@ -1047,6 +1049,33 @@ void R_Init(void)
framecount = 0;
}
//
// R_IsPointInSubsector, same as above but returns 0 if not in subsector
//
subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
{
node_t *node;
INT32 side, i;
size_t nodenum;
subsector_t *ret;
nodenum = numnodes - 1;
while (!(nodenum & NF_SUBSECTOR))
{
node = &nodes[nodenum];
side = R_PointOnSide(x, y, node);
nodenum = node->children[side];
}
ret = &subsectors[nodenum & ~NF_SUBSECTOR];
for (i = 0; i < ret->numlines; i++)
if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side)
return 0;
return ret;
}
//
// R_SetupFrame
//
@@ -1066,7 +1095,7 @@ static void R_SetupCommonFrame(player_t * player, sector_t * sector)
if (sector != NULL)
newview->sector = sector;
else
newview->sector = R_PointInSubsector(newview->x, newview->y)->sector;
newview->sector = R_PointInSubsectorFast(newview->x, newview->y)->sector;
R_InterpolateView(rendertimefrac_unpaused, false);
}
@@ -1104,7 +1133,6 @@ static void R_SetupSkyScale(player_t *player, camera_t *thiscam, mapheader_t *mh
{
if (skyboxmo[1])
{
angle_t ang;
fixed_t x = 0, y = 0;
if (mh->skybox_scalex > 0)
@@ -1136,8 +1164,8 @@ static void R_SetupSkyScale(player_t *player, camera_t *thiscam, mapheader_t *mh
newview->y -= x;
break;
default:
ang = viewmobj->angle>>ANGLETOFINESHIFT;
newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
angle_t ang = viewmobj->angle>>ANGLETOFINESHIFT;
newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang));
newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang));
break;
}
@@ -1163,14 +1191,14 @@ static void R_SetupSkyScale(player_t *player, camera_t *thiscam, mapheader_t *mh
}
}
void R_SkyboxFrame(int s)
void R_SkyboxFrame(UINT8 pnum)
{
player_t *player = &players[displayplayers[s]];
camera_t *thiscam = &camera[s];
subsector_t * subsector = NULL;
player_t *player = &players[displayplayers[pnum]];
camera_t *thiscam = &camera[pnum];
sector_t *viewsec = NULL;
mapheader_t *mh = mapheaderinfo[gamemap-1];
R_SetViewContext(static_cast<viewcontext_e>(VIEWCONTEXT_SKY1 + s));
R_SetViewContext(static_cast<viewcontext_e>(VIEWCONTEXT_SKY1 + pnum));
// cut-away view stuff
newview->sky = true;
@@ -1186,35 +1214,38 @@ void R_SkyboxFrame(int s)
R_SetupAimingFrame(player, thiscam);
newview->angle += viewmobj->angle;
if (!P_MobjWasRemoved(viewmobj))
{
newview->angle += viewmobj->angle;
newview->x = viewmobj->x;
newview->y = viewmobj->y;
newview->z = (viewmobj->spawnpoint) ? (((fixed_t)viewmobj->spawnpoint->angle)<<FRACBITS) : 0;
newview->x = viewmobj->x;
newview->y = viewmobj->y;
newview->z = (viewmobj->spawnpoint) ? (((fixed_t)viewmobj->spawnpoint->angle) << FRACBITS) : 0;
if (viewmobj->subsector)
viewsec = viewmobj->subsector->sector;
}
if (mh)
{
R_SetupSkyScale(player, thiscam, mh);
}
if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && viewmobj->subsector->sector)
subsector = viewmobj->subsector;
R_SetupCommonFrame(player, subsector->sector);
R_SetupCommonFrame(player, viewsec);
}
void R_SetupFrame(int s, boolean skybox)
void R_SetupFrame(UINT8 pnum, boolean skybox)
{
player_t *player = &players[displayplayers[s]];
camera_t *thiscam = &camera[s];
boolean chasecam = (cv_chasecam[s].value);
sector_t * sector = NULL;
player_t *player = &players[displayplayers[pnum]];
camera_t *thiscam = &camera[pnum];
boolean chasecam = (cv_chasecam[pnum].value);
sector_t *viewsec = NULL;
R_SetViewContext(static_cast<viewcontext_e>(VIEWCONTEXT_PLAYER1 + s));
R_SetViewContext(static_cast<viewcontext_e>(VIEWCONTEXT_PLAYER1 + pnum));
if (thiscam->reset)
{
R_ResetViewInterpolation(s);
R_ResetViewInterpolation(pnum);
thiscam->reset = false;
}
@@ -1249,10 +1280,10 @@ void R_SetupFrame(int s, boolean skybox)
newview->y = viewmobj->y;
newview->z = viewmobj->z + 20*FRACUNIT;
if (viewmobj->subsector && viewmobj->subsector->sector)
sector = viewmobj->subsector->sector;
if (viewmobj->subsector)
viewsec = viewmobj->subsector->sector;
R_SetupCommonFrame(player, sector);
R_SetupCommonFrame(player, viewsec);
}
else if (thiscam && chasecam) // use outside cam view
{
@@ -1263,10 +1294,10 @@ void R_SetupFrame(int s, boolean skybox)
newview->y = thiscam->y;
newview->z = thiscam->z + (thiscam->height>>1);
if (thiscam->subsector && thiscam->subsector->sector)
sector = thiscam->subsector->sector;
if (thiscam->subsector)
viewsec = thiscam->subsector->sector;
R_SetupCommonFrame(player, sector);
R_SetupCommonFrame(player, viewsec);
}
else if (player->mo) // use the player's eyes view
{
@@ -1277,10 +1308,10 @@ void R_SetupFrame(int s, boolean skybox)
newview->y = viewmobj->y;
newview->z = player->viewz;
if (viewmobj->subsector && viewmobj->subsector->sector)
sector = viewmobj->subsector->sector;
if (viewmobj->subsector)
viewsec = viewmobj->subsector->sector;
R_SetupCommonFrame(player, sector);
R_SetupCommonFrame(player, viewsec);
}
}
@@ -1306,7 +1337,7 @@ static void R_PortalFrame(portal_t *portal)
{
portalclipline = NULL;
portalcullsector = NULL;
viewsector = R_PointInSubsector(viewx, viewy)->sector;
viewsector = R_PointInSubsectorFast(viewx, viewy)->sector;
}
}
@@ -1522,11 +1553,6 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_fovchange);
CV_RegisterVar(&cv_fov);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_chasecam[i]);
}
CV_RegisterVar(&cv_shadow);
CV_RegisterVar(&cv_shadowoffs);
CV_RegisterVar(&cv_skybox);
@@ -1536,6 +1562,8 @@ void R_RegisterEngineStuff(void)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
CV_RegisterVar(&cv_chasecam[i]);
CV_RegisterVar(&cv_cam_dist[i]);
CV_RegisterVar(&cv_cam_still[i]);
CV_RegisterVar(&cv_cam_height[i]);
@@ -1552,6 +1580,8 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_tiltsmoothing);
CV_RegisterVar(&cv_actionmovie);
CV_RegisterVar(&cv_screenquake);
CV_RegisterVar(&cv_driftsparkpulse);
CV_RegisterVar(&cv_gravstretch);
CV_RegisterVar(&cv_sloperoll);
@@ -1569,6 +1599,7 @@ void R_RegisterEngineStuff(void)
CV_RegisterVar(&cv_randomdirlight);
CV_RegisterVar(&cv_maxinterpdist);
CV_RegisterVar(&cv_playerfade);
CV_RegisterVar(&cv_ripplewater);
+18 -40
View File
@@ -88,7 +88,7 @@ extern lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ];
//
// killough 5/2/98: reformatted
//
FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t * restrict node)
FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSide(fixed_t x, fixed_t y, const node_t* restrict node)
{
if (!node->dx)
return x <= node->x ? node->dy > 0 : node->dy < 0;
@@ -117,10 +117,10 @@ FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSideFast(fixed_t x, fixed_t
FUNCINLINE static ATTRINLINE PUREFUNC INT32 R_PointOnSegSide(fixed_t x, fixed_t y, const seg_t *line)
{
fixed_t lx = line->v1->x;
fixed_t ly = line->v1->y;
fixed_t ldx = line->v2->x - lx;
fixed_t ldy = line->v2->y - ly;
fixed_t lx = line->v1->x;
fixed_t ly = line->v1->y;
fixed_t ldx = line->v2->x - lx;
fixed_t ldy = line->v2->y - ly;
// use cross product to determine side quickly
INT64 v = ((INT64)y - ly) * ldx - ((INT64)x - lx) * ldy;
@@ -137,42 +137,19 @@ fixed_t R_ScaleFromGlobalAngle(angle_t visangle);
//
// R_PointInSubsector
//
FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsector(fixed_t x, fixed_t y)
{
size_t nodenum = numnodes-1;
while (!(nodenum & NF_SUBSECTOR))
nodenum = nodes[nodenum].children[R_PointOnSide(x, y, nodes+nodenum)];
return &subsectors[nodenum & ~NF_SUBSECTOR];
#define R_POINTINSUBSECTOR(FUNCNAME, SIDEFUNC)\
FUNCINLINE static ATTRINLINE subsector_t *FUNCNAME(fixed_t x, fixed_t y)\
{\
size_t nodenum = numnodes-1;\
while (!(nodenum & NF_SUBSECTOR))\
nodenum = nodes[nodenum].children[SIDEFUNC(x, y, nodes+nodenum)];\
return &subsectors[nodenum & ~NF_SUBSECTOR];\
}
//
// R_IsPointInSubsector, same as above but returns 0 if not in subsector
//
FUNCINLINE static ATTRINLINE subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y)
{
node_t *node;
INT32 side, i;
size_t nodenum;
subsector_t *ret;
R_POINTINSUBSECTOR(R_PointInSubsector, R_PointOnSide)
R_POINTINSUBSECTOR(R_PointInSubsectorFast, R_PointOnSideFast)
nodenum = numnodes - 1;
while (!(nodenum & NF_SUBSECTOR))
{
node = &nodes[nodenum];
side = R_PointOnSide(x, y, node);
nodenum = node->children[side];
}
ret = &subsectors[nodenum & ~NF_SUBSECTOR];
for (i = 0; i < ret->numlines; i++)
if (P_PointOnLineSide(x, y, segs[ret->firstline + i].linedef) != segs[ret->firstline + i].side)
return 0;
return ret;
}
subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y);
#define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y)
#define R_PointToDist2(px2, py2, px1, py1) FixedHypot((px1) - (px2), (py1) - (py2))
@@ -218,6 +195,7 @@ extern consvar_t cv_fov, cv_fovchange;
extern consvar_t cv_skybox;
extern consvar_t cv_tailspickup;
extern consvar_t cv_maxinterpdist;
extern consvar_t cv_playerfade;
extern consvar_t cv_ripplewater;
extern consvar_t cv_randomdirlight;
@@ -237,8 +215,8 @@ void R_SetViewSize(void);
void R_ExecuteSetViewSize(void);
fixed_t R_GetPlayerFov(player_t *player);
void R_SkyboxFrame(int s);
void R_SetupFrame(int s, boolean skybox);
void R_SkyboxFrame(UINT8 pnum);
void R_SetupFrame(UINT8 pnum, boolean skybox);
// Called by G_Drawer.
void R_RenderPlayerView(player_t *player);
+51 -49
View File
@@ -247,9 +247,7 @@ static void R_MapPlane(drawspandata_t *ds, spandrawfunc_t *localspanfunc, INT32
ds->bgofs = -y;
}
pindex = distance >> LIGHTZSHIFT;
if (pindex >= MAXLIGHTZ)
pindex = MAXLIGHTZ - 1;
pindex = std::min<size_t>(distance >> LIGHTZSHIFT, MAXLIGHTZ - 1);
ds->colormap = ds->planezlight[pindex];
@@ -352,8 +350,8 @@ void R_ClearPlanes(void)
angle = (viewangle-ANGLE_90)>>ANGLETOFINESHIFT;
// scale will be unit scale at SCREENWIDTH/2 distance
basexscale = FixedDiv (FINECOSINE(angle), centerxfrac);
baseyscale = -FixedDiv (FINESINE(angle), centerxfrac);
basexscale = FixedDiv (FINECOSINE(angle), centerxfrac);
baseyscale = -FixedDiv (FINESINE(angle), centerxfrac);
}
static visplane_t *new_visplane(unsigned hash)
@@ -442,26 +440,20 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
}
}
// This appears to fix the Nimbus Ruins sky bug.
if (picnum == skyflatnum && pfloor)
{
height = 0; // all skies map together
lightlevel = 0;
}
else if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector))
{
if (reverseLight)
{
lightlevel -= slope->lightOffset * 8;
}
else
{
lightlevel += slope->lightOffset * 8;
}
}
if (!pfloor)
{
if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector))
{
if (reverseLight)
{
lightlevel -= slope->lightOffset * 8;
}
else
{
lightlevel += slope->lightOffset * 8;
}
}
hash = visplane_hash(picnum, lightlevel, height);
for (check = visplanes[hash]; check; check = check->next)
@@ -485,6 +477,13 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel,
}
else
{
// This appears to fix the Nimbus Ruins sky bug.
if (picnum == skyflatnum)
{
height = 0; // all skies map together
lightlevel = 0;
}
hash = MAXVISPLANES - 1;
}
@@ -592,6 +591,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop)
memset(pl->top, 0xff, sizeof(*pl->top) * viewwidth);
memset(pl->bottom, 0x00, sizeof(*pl->bottom) * viewwidth);
}
return pl;
}
@@ -628,14 +628,13 @@ static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(draw
if (b2 >= vidheight) b2 = vidheight-1;
if (x-1 >= vid.width) x = vid.width;
drawspandata_t dc_copy = *ds;
#ifdef HAVE_THREADS
// We want to draw N spans per subtask to ensure the work is
// coarse enough to not be too slow due to task scheduling overhead.
// To safely do this, we need to copy part of spanstart to a local.
// This is essentially loop unrolling across threads.
constexpr const int kSpanTaskGranularity = 8;
drawspandata_t ds_copy = *ds;
while (t1 < t2 && t1 <= b1)
{
INT32 spanstartcopy[kSpanTaskGranularity] = {0};
@@ -652,7 +651,7 @@ static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(draw
auto task = [=]() mutable -> void {
for (int i = 0; i < taskspans; i++)
{
mapfunc(&dc_copy, localspanfunc, t1 + i, spanstartcopy[i], x - 1, false);
mapfunc(&ds_copy, localspanfunc, t1 + i, spanstartcopy[i], x - 1, false);
}
};
if (allow_parallel)
@@ -681,7 +680,7 @@ static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(draw
auto task = [=]() mutable -> void {
for (int i = 0; i < taskspans; i++)
{
mapfunc(&dc_copy, localspanfunc, b1 - i, spanstartcopy[i], x - 1, false);
mapfunc(&ds_copy, localspanfunc, b1 - i, spanstartcopy[i], x - 1, false);
}
};
if (allow_parallel)
@@ -699,12 +698,12 @@ static void R_MakeSpans(void (*mapfunc)(drawspandata_t* ds, void(*spanfunc)(draw
while (t1 < t2 && t1 <= b1)
{
mapfunc(&dc_copy, localspanfunc, t1, spanstart[t1], x - 1, false);
mapfunc(ds, localspanfunc, t1, spanstart[t1], x - 1, false);
t1++;
}
while (b1 > b2 && b1 >= t1)
{
mapfunc(&dc_copy, localspanfunc, b1, spanstart[b1], x - 1, false);
mapfunc(ds, localspanfunc, b1, spanstart[b1], x - 1, false);
b1--;
}
#endif
@@ -1020,13 +1019,12 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle
size_t size;
INT32 spanfunctype = BASEDRAWFUNC;
ffloor_t *rover;
levelflat_t *levelflat;
void (*mapfunc)(drawspandata_t*, void(*)(drawspandata_t*), INT32, INT32, INT32, boolean) = R_MapPlane;
if (!(pl->minx <= pl->maxx))
if (pl->minx > pl->maxx)
return;
R_UpdatePlaneRipple(ds);
// sky flat
if (pl->picnum == skyflatnum)
{
@@ -1039,6 +1037,8 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle
return;
}
R_UpdatePlaneRipple(ds);
ds->planeripple.active = false;
R_SetSpanFunc(BASEDRAWFUNC);
@@ -1175,16 +1175,17 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle
else light = (pl->lightlevel >> LIGHTSEGSHIFT);
}
// Don't mess with angle on slopes! We'll handle this ourselves later
if (!pl->slope && viewangle != pl->viewangle+pl->plangle)
{
viewangle = pl->viewangle+pl->plangle;
}
ds->currentplane = pl;
ds->source = (UINT8 *)W_CacheLumpNum(levelflats[pl->picnum].lumpnum, PU_STATIC); // Stay here until Z_ChangeTag
size = W_LumpLength(levelflats[pl->picnum].lumpnum);
levelflat = &levelflats[pl->picnum];
// Get the texture
ds->source = (UINT8 *)W_CacheLumpNum(levelflat->lumpnum, PU_STATIC); // Stay here until Z_ChangeTag
if (ds->source == NULL)
return;
size = W_LumpLength(levelflat->lumpnum);
switch (size)
{
@@ -1235,11 +1236,7 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle
ds->xoffs = pl->xoffs;
ds->yoffs = pl->yoffs;
if (light >= LIGHTLEVELS)
light = LIGHTLEVELS-1;
if (light < 0)
light = 0;
light = CLAMP(light, 0, LIGHTLEVELS-1);
if (pl->slope)
{
@@ -1292,6 +1289,12 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle
}
else
{
// Don't mess with angle on slopes! We'll handle this ourselves later
if (viewangle != pl->viewangle + pl->plangle)
{
viewangle = pl->viewangle + pl->plangle;
}
ds->planeheight = abs(pl->height - pl->viewz);
ds->planezlight = zlight[light];
}
@@ -1299,10 +1302,8 @@ void R_DrawSinglePlane(drawspandata_t* ds, visplane_t *pl, boolean allow_paralle
R_SetSpanFunc(spanfunctype);
// set the maximum value for unsigned
pl->top[pl->maxx+1] = 0xffff;
pl->top[pl->minx-1] = 0xffff;
pl->bottom[pl->maxx+1] = 0x0000;
pl->bottom[pl->minx-1] = 0x0000;
pl->top[pl->maxx+1] = pl->top[pl->minx-1] = 0xffff;
pl->bottom[pl->maxx+1] = pl->bottom[pl->minx-1] = 0x0000;
stop = pl->maxx + 1;
@@ -1403,6 +1404,7 @@ void R_PlaneBounds(visplane_t *plane)
if (plane->bottom[i] > low)
low = plane->bottom[i];
}
plane->high = hi;
plane->low = low;
}
+9 -5
View File
@@ -306,8 +306,10 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
else
dc->texturemid -= (textureheight[texnum])*times;
const INT16 colnum = maskedtexturecol[dc->x];
// calculate lighting
if (maskedtexturecol[dc->x] != INT16_MAX)
if (colnum != INT16_MAX)
{
// Check for overflows first
if (R_OverflowTest(dc))
@@ -337,7 +339,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
dc->iscale = 0xffffffffu / (unsigned)spryscale;
// draw the texture
col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc->x]) - 3);
col = (column_t *)((UINT8 *)R_GetColumn(texnum, colnum) - 3);
auto set_light_vars = [&](INT32 k)
{
@@ -434,7 +436,7 @@ static void R_RenderMaskedSegLoop(drawcolumndata_t* dc, drawseg_t *drawseg, INT3
dc->iscale = 0xffffffffu / (unsigned)spryscale;
// draw the texture
col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc->x]) - 3);
col = (column_t *)((UINT8 *)R_GetColumn(texnum, colnum) - 3);
colfunc_2s(dc, col);
}
@@ -1164,7 +1166,7 @@ static void R_DrawWallColumn(drawcolumndata_t* dc, INT32 yl, INT32 yh, fixed_t m
dc->source = R_GetColumn(texture, texturecolumn);
dc->texheight = textureheight[texture] >> FRACBITS;
dc->sourcelength = dc->texheight;
R_SetColumnFunc(colfunctype);
//R_SetColumnFunc(colfunctype);
coldrawfunc_t* colfunccopy = colfunc;
drawcolumndata_t dc_copy = *dc;
if (remap)
@@ -1190,6 +1192,7 @@ static void R_RenderSegLoop(drawcolumndata_t* dc)
INT32 bottom;
INT32 i;
// Loop over width
for (; rw_x < rw_stopx; rw_x++)
{
// mark floor / ceiling areas
@@ -1563,6 +1566,7 @@ static void R_MarkSegBounds(void)
INT32 top, bottom;
INT16 topclip, bottomclip;
// Loop over width
for (; rw_x < rw_stopx; rw_x++)
{
// mark floor / ceiling areas
@@ -2884,7 +2888,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
didsolidcol = false;
if (!segtextured && !numffloors)
if (!segtextured && !numffloors && !numbackffloors)
{
if (markfloor || markceiling)
R_MarkSegBounds();
+51 -2
View File
@@ -737,6 +737,13 @@ static void R_DrawFlippedMaskedColumn(drawcolumndata_t* dc, column_t *column)
dc->texturemid = basetexturemid;
}
// Based off of R_GetLinedefTransTable
transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap)
{
return static_cast<transnum_t>((20*(FRACUNIT - ((alpha * (10 - transmap))/10) - 1) + FRACUNIT) >> (FRACBITS+1));
}
//
// R_DrawVisSprite
// mfloorclip and mceilingclip should also be set.
@@ -1596,6 +1603,9 @@ static void R_ProjectSprite(mobj_t *thing)
else
trans = 0;
if (cv_playerfade.value && oldthing->player)
trans = static_cast<INT32>(R_GetThingTransTable(R_DoPlayerFade(oldthing), static_cast<transnum_t>(trans)));
//SoM: 3/17/2000: Disregard sprites that are out of view..
if (vflip)
{
@@ -2931,6 +2941,32 @@ boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist)
return true;
}
fixed_t R_DoPlayerFade(mobj_t *thing)
{
fixed_t fadealpha = FRACUNIT;
static constexpr tic_t countdownstarttime = (15 * TICRATE) / 4; // starttime - (3*TICRATE)
if (thing->player == viewplayer || viewplayer->exiting || camera[R_GetViewNumber()].freecam || leveltime < countdownstarttime)
return fadealpha;
const INT32 playerdist = (FixedMul((thing->x - viewx), viewcos) + FixedMul((thing->y - viewy), viewsin)) >> FRACBITS;
const INT32 viewplayerdist = (FixedMul((viewplayer->mo->x - viewx), viewcos) + FixedMul((viewplayer->mo->y - viewy), viewsin)) >> FRACBITS;
if (playerdist < viewplayerdist)
{
if (playerdist < viewplayerdist / 2) // stronger fade when very close
{
fadealpha = (playerdist * FRACUNIT) / (viewplayerdist / 2) / 3;
}
else
{
fadealpha = (playerdist * FRACUNIT) / viewplayerdist;
}
}
return fadealpha;
}
boolean R_CheckInterpDist(mobj_t *thing)
{
if (!cv_maxinterpdist.value)
@@ -2970,8 +3006,21 @@ static void R_DrawMaskedList(drawnode_t* head)
{
drawspandata_t ds = {};
next = r2->prev;
// Force disable multithreading since it is usually slower because of waiting for each plane to render
R_DrawSinglePlane(&ds, r2->plane, false);
boolean parallel = cv_parallelsoftware.value && cv_paralleldrawmasked.value;
#ifdef HAVE_THREADS
srb2::ThreadPool::Sema tp_sema;
if (parallel)
srb2::g_main_threadpool->begin_sema();
#endif
R_DrawSinglePlane(&ds, r2->plane, parallel);
#ifdef HAVE_THREADS
if (parallel)
{
tp_sema = srb2::g_main_threadpool->end_sema();
srb2::g_main_threadpool->notify_sema(tp_sema);
srb2::g_main_threadpool->wait_sema(tp_sema);
}
#endif
R_DoneWithNode(r2);
r2 = next;
}
+3
View File
@@ -87,9 +87,12 @@ typedef struct
void R_DrawMasked(maskcount_t* masks, INT32 nummasks);
transnum_t R_GetThingTransTable(fixed_t alpha, transnum_t transmap);
boolean R_ThingVisible(mobj_t *thing);
boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist);
boolean R_CheckInterpDist(mobj_t *thing);
fixed_t R_DoPlayerFade(mobj_t *thing);
boolean R_ThingIsFullBright(mobj_t *thing);
boolean R_ThingIsSemiBright(mobj_t *thing);
+15 -14
View File
@@ -957,7 +957,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32
INT64 x, y, yl, yh, xl, xh;
fixed_t newdist;
if (R_PointInSubsector(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum)
if (R_PointInSubsectorFast(listensource.x, listensource.y)->sector->ceilingpic == skyflatnum)
approx_dist = 0;
else
{
@@ -970,7 +970,7 @@ boolean S_AdjustSoundParams(const mobj_t *listener, const mobj_t *source, INT32
for (y = yl; y <= yh; y += FRACUNIT*64)
for (x = xl; x <= xh; x += FRACUNIT*64)
{
if (R_PointInSubsector(x, y)->sector->ceilingpic == skyflatnum)
if (R_PointInSubsectorFast(x, y)->sector->ceilingpic == skyflatnum)
{
// Found the outdoors!
newdist = S_CalculateSoundDistance(listensource.x, listensource.y, 0, x, y, 0);
@@ -1718,15 +1718,15 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms)
static void S_QueueMusic(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 fadeinms)
{
strncpy(queue.name, mmusic, 7);
queue.flags = mflags;
queue.looping = looping;
queue.flags = mflags;
queue.looping = looping;
queue.position = position;
queue.fadeinms = fadeinms;
}
static void S_ClearQueue(void)
{
queue.name[0] = queue.flags = queue.looping = queue.position = queue.fadeinms = 0;
memset(&queue, 0, sizeof(music_t));
}
static void S_ChangeMusicToQueue(void)
@@ -1757,7 +1757,7 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32
|| demo.title) // SRB2Kart: Demos don't interrupt title screen music
return;
strncpy(newmusic, mmusic, 6);
strncpy(newmusic, mmusic, 6);
strncpy(checkmusic, mmusic, 6);
if (LUA_HookMusicChange(music.name, &hook_param))
@@ -2030,7 +2030,7 @@ void S_KeepMusic(void)
}
// Sets up the map music in case it should be reloaded
// Special case for keep music
// Special case for keepmusic
void S_HandleReloadResetMusic(void)
{
if (!(mapmusic.flags & MUSIC_RELOADRESET))
@@ -2055,23 +2055,24 @@ void S_HandleReloadResetMusic(void)
static boolean S_SkipIntroMusic(void)
{
boolean skip = cv_skipintromusic.value;
if (!cv_skipintromusic.value)
return false;
if (!skip)
// check if menu music is playing, otherwise it may continue playing
if (!stricmp(music.name, "titles"))
return false;
char *maptitle = G_BuildMapTitle(gamemap); // Zzz...
if (maptitle)
if (maptitle && !stricmp(maptitle, "Wandering Falls")) // wandering balls changes its song when the race starts Zzz...
{
// check if menu music is playing, otherwise it may continue playing
if (!stricmp(music.name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // wandering balls changes its song when the race starts Zzz...
skip = false;
Z_Free(maptitle);
return false;
}
Z_Free(maptitle);
return skip;
return true;
}
//
+2 -1
View File
@@ -49,6 +49,7 @@ consvar_t cv_vhseffect = {"vhspause", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NU
consvar_t cv_shittyscreen = {"televisionsignal", "Okay", CV_NOSHOWHELP, shittyscreen_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_parallelsoftware = {"parallelsoftware", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
consvar_t cv_paralleldrawmasked = {"paralleldrawmasked", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
static CV_PossibleValue_t votescale_cons_t[] = {{0, "Vanilla"}, {1, "Adaptive"}, {2, "VerticalFill"}, {3, "HorizontalFill"}, {0, NULL}};
consvar_t cv_votebgscaling = {"votebgscaling", "Adaptive", CV_SAVE, votescale_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@@ -349,7 +350,7 @@ double averageFPS = 0.0f;
#ifdef USE_FPS_SAMPLES
#define MAX_FRAME_TIME (0.05)
#define NUM_FPS_SAMPLES (16) // Number of samples to store
#define NUM_FPS_SAMPLES (32) // Number of samples to store
static double total_frame_time = 0.0;
static int frame_index;
+1
View File
@@ -88,6 +88,7 @@ extern UINT8 *scr_borderpatch; // patch used to fill the view borders
extern consvar_t cv_scr_width, cv_scr_height, cv_renderview, cv_fullscreen, cv_vhseffect, cv_shittyscreen;
extern consvar_t cv_parallelsoftware;
extern consvar_t cv_paralleldrawmasked;
extern consvar_t cv_highreshudscale;
// wait for page flipping to end or not
+391 -512
View File
File diff suppressed because it is too large. Load diff
+1
View File
@@ -1037,6 +1037,7 @@ sfxenum_t S_AddSoundFx(const char *name, boolean singular, INT32 flags, boolean
S_sfx[i].data = I_GetSfx(&S_sfx[i]);
else
S_sfx[i].data = NULL;
return i;
}
}
+17 -16
View File
@@ -419,27 +419,28 @@ static void ST_drawDebugInfo(void)
static void ST_drawLevelTitle(void)
{
char *lvlttl = mapheaderinfo[gamemap-1]->lvlttl;
char *subttl = mapheaderinfo[gamemap-1]->subttl;
char *zonttl = mapheaderinfo[gamemap-1]->zonttl; // SRB2kart
char *actnum = mapheaderinfo[gamemap-1]->actnum;
INT32 lvlttlxpos;
INT32 ttlnumxpos;
INT32 zonexpos;
INT32 dupcalc = (vid.width/vid.dupx);
UINT8 gtc = G_GetGametypeColor(gametype);
char *lvlttl, *subttl, *zonttl, *actnum;
INT32 lvlttlxpos, ttlnumxpos, zonexpos;
INT32 dupcalc;
UINT8 gtc;
INT32 sub = 0;
INT32 bary = (splitscreen)
? BASEVIDHEIGHT/2
: 163;
INT32 bary;
INT32 lvlw;
if (!cv_stagetitle.value)
if (!cv_stagetitle.value || (timeinmap > 113))
return;
if (timeinmap > 113)
if (*mapheaderinfo[gamemap-1]->lvlttl == '\0')
return;
lvlttl = mapheaderinfo[gamemap-1]->lvlttl;
subttl = mapheaderinfo[gamemap-1]->subttl;
zonttl = mapheaderinfo[gamemap-1]->zonttl; // SRB2kart
actnum = mapheaderinfo[gamemap-1]->actnum;
dupcalc = (vid.width/vid.dupx);
gtc = G_GetGametypeColor(gametype);
bary = (splitscreen) ? BASEVIDHEIGHT/2 : 163;
lvlw = V_LevelNameWidth(lvlttl);
if (actnum[0])
@@ -603,7 +604,7 @@ static void ST_overlayDrawer(void)
}
// draw level title Tails
if (*mapheaderinfo[gamemap-1]->lvlttl != '\0' && !(hu_showscores && (netgame || multiplayer) && !mapreset) && LUA_HudEnabled(hud_stagetitle) && !forceshowhud)
if (!(hu_showscores && (netgame || multiplayer) && !mapreset) && LUA_HudEnabled(hud_stagetitle) && !forceshowhud)
ST_drawLevelTitle();
if (!hu_showscores && netgame && !mapreset)
@@ -740,7 +741,7 @@ void ST_Drawer(void)
UINT8 i;
#ifdef SEENAMES
if (cv_seenames.value && cv_allowseenames.value && displayplayers[0] == consoleplayer && seenplayer && seenplayer->mo && !mapreset)
if (UNLIKELY(cv_seenames.value && cv_allowseenames.value && displayplayers[0] == consoleplayer && seenplayer && seenplayer->mo && !mapreset))
{
if (cv_seenames.value == 1)
V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2 + 15, V_HUDTRANSHALF, player_names[seenplayer-players]);
+1 -1
View File
@@ -611,7 +611,7 @@ static lumpinfo_t* ResGetLumpsZip (FILE* handle, UINT16* nlmp)
fseek(handle, LONG(zend.cdiroffset), SEEK_SET);
char *cdir = (Z_MallocAlign(LONG(zend.cdirsize), PU_STATIC, &cdir, 7));
char *cdir = Z_Malloc(LONG(zend.cdirsize), PU_STATIC, &cdir);
if (fread(cdir, 1, LONG(zend.cdirsize), handle) < (UINT32)(LONG(zend.cdirsize)))
{
-2
View File
@@ -1,5 +1,3 @@
#include <winuser.h>
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
+85 -37
View File
@@ -149,9 +149,12 @@ void Z_Free(void *ptr)
#endif
#endif
#ifdef ZDEBUG
#ifdef ZDEBUG2
// Write every Z_Free call to a debug file.
CONS_Debug(DBG_MEMORY, "Z_Free at %s:%d\n", file, line);
#elif defined(ZDEBUG)
(void)file;
(void)line;
#endif
// anything that isn't by lua gets passed to lua just in case.
@@ -202,7 +205,7 @@ static void *xm(size_t size)
return p;
}
/** The Z_MallocAlign function.
/** The Z_Malloc function.
* Allocates a block of memory, adds it to a linked list so we can keep track of it.
*
* \param size Amount of memory to be allocated, in bytes.
@@ -210,22 +213,19 @@ static void *xm(size_t size)
* \param user The address of a pointer to the memory to be allocated.
* When the memory is freed by Z_Free later,
* the pointer at this address will then be automatically set to NULL.
* \param alignbits The alignment of the memory to be allocated, in bits. Can be 0.
* \note You can pass Z_Malloc() a NULL user if the tag is less than PU_PURGELEVEL.
* \sa Z_CallocAlign, Z_ReallocAlign
* \sa Z_Calloc, Z_Realloc
*/
#ifdef ZDEBUG
void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits,
void *Z_Malloc2(size_t size, INT32 tag, void *user,
const char *file, INT32 line)
#else
void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits)
void *Z_Malloc(size_t size, INT32 tag, void *user)
#endif
{
memblock_t *block;
void *ptr;
(void)(alignbits); // no longer used, so silence warnings. TODO we should figure out a solution for this
#ifdef ZDEBUG2
CONS_Debug(DBG_MEMORY, "Z_Malloc %s:%d\n", file, line);
#endif
@@ -270,55 +270,53 @@ void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits)
return ptr;
}
/** The Z_CallocAlign function.
/** The Z_Calloc function.
* Allocates a block of memory, adds it to a linked list so we can keep track of it.
* Unlike Z_MallocAlign, this also initialises the bytes to zero.
* Unlike Z_Malloc, this also initialises the bytes to zero.
*
* \param size Amount of memory to be allocated, in bytes.
* \param tag Purge tag.
* \param user The address of a pointer to the memory to be allocated.
* When the memory is freed by Z_Free later,
* the pointer at this address will then be automatically set to NULL.
* \param alignbits The alignment of the memory to be allocated, in bits. Can be 0.
* \note You can pass Z_Calloc() a NULL user if the tag is less than PU_PURGELEVEL.
* \sa Z_MallocAlign, Z_ReallocAlign
* \sa Z_Malloc, Z_Realloc
*/
#ifdef ZDEBUG
void *Z_Calloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line)
void *Z_Calloc2(size_t size, INT32 tag, void *user, const char *file, INT32 line)
#else
void *Z_CallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits)
void *Z_Calloc(size_t size, INT32 tag, void *user)
#endif
{
#ifdef VALGRIND_MEMPOOL_ALLOC
Z_calloc = true;
#endif
#ifdef ZDEBUG
return memset(Z_Malloc2 (size, tag, user, alignbits, file, line), 0, size);
return memset(Z_Malloc2(size, tag, user, file, line), 0, size);
#else
return memset(Z_MallocAlign(size, tag, user, alignbits ), 0, size);
return memset(Z_Malloc (size, tag, user ), 0, size);
#endif
}
/** The Z_ReallocAlign function.
/** The Z_Realloc function.
* Reallocates a block of memory with a new size.
*
* \param ptr A pointer to allocated memory,
* assumed to have been allocated with Z_Malloc/Z_Calloc.
* If NULL, this function instead acts as a wrapper for Z_CallocAlign.
* If NULL, this function instead acts as a wrapper for Z_Calloc.
* \param size New size of memory block, in bytes.
* If zero, then the memory is freed and NULL is returned.
* \param tag New purge tag.
* \param user The address of a pointer to the memory to be reallocated.
* This can be a different user to the one originally assigned to the memory block.
* \param alignbits The alignment of the memory to be allocated, in bits. Can be 0.
* \return A pointer to the reallocated memory. Can be NULL if memory was freed.
* \note You can pass Z_Realloc() a NULL user if the tag is less than PU_PURGELEVEL.
* \sa Z_MallocAlign, Z_CallocAlign
* \sa Z_Malloc, Z_Calloc
*/
#ifdef ZDEBUG
void *Z_Realloc2(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line)
void *Z_Realloc2(void *ptr, size_t size, INT32 tag, void *user, const char *file, INT32 line)
#else
void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits)
void *Z_Realloc(void *ptr, size_t size, INT32 tag, void *user)
#endif
{
void *rez;
@@ -338,9 +336,9 @@ void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignb
if (!ptr)
{
#ifdef ZDEBUG
return Z_Calloc2(size, tag, user, alignbits, file , line);
return Z_Calloc2(size, tag, user, file, line);
#else
return Z_CallocAlign(size, tag, user, alignbits);
return Z_Calloc(size, tag, user);
#endif
}
@@ -348,9 +346,9 @@ void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignb
#ifdef PARANOIA
if (block->id != ZONEID)
#ifdef ZDEBUG
I_Error("Z_ReallocAlign at %s:%d: wrong id", file, line);
I_Error("Z_Realloc at %s:%d: wrong id", file, line);
#else
I_Error("Z_ReallocAlign: wrong id");
I_Error("Z_Realloc: wrong id");
#endif
#endif
@@ -358,11 +356,13 @@ void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignb
return NULL;
#ifdef ZDEBUG
#ifdef ZDEBUG2
// Write every Z_Realloc call to a debug file.
DEBFILE(va("Z_Realloc at %s:%d\n", file, line));
rez = Z_Malloc2(size, tag, user, alignbits, file, line);
#endif
rez = Z_Malloc2(size, tag, user, file, line);
#else
rez = Z_MallocAlign(size, tag, user, alignbits);
rez = Z_Malloc(size, tag, user);
#endif
if (size < block->realsize)
@@ -394,11 +394,19 @@ void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignb
* \param lowtag The lowest tag to consider.
* \param hightag The highest tag to consider.
*/
#ifdef ZDEBUG
void Z_FreeTags2(INT32 lowtag, INT32 hightag, const char *file, INT32 line)
#else
void Z_FreeTags(INT32 lowtag, INT32 hightag)
#endif
{
memblock_t *block, *next;
#ifdef ZDEBUG
Z_CheckHeap2(file, line);
#else
Z_CheckHeap(420);
#endif
for (block = head.next; block != &head; block = next)
{
next = block->next; // get link before freeing
@@ -468,12 +476,20 @@ void Z_CheckMemCleanup(void)
* \param i Identifies from where in the code Z_CheckHeap was called.
* \author Graue <graue@oceanbase.org>
*/
void Z_CheckHeap(INT32 i)
#ifdef ZDEBUG
void Z_CheckHeap2(const char *file, INT32 line)
#else
void Z_CheckHeap(INT32 tag)
#endif
{
memblock_t *block;
UINT32 blocknumon = 0;
void *given;
#ifndef ZDEBUG
(void)tag;
#endif
for (block = head.next; block != &head; block = block->next)
{
blocknumon++;
@@ -498,11 +514,19 @@ void Z_CheckHeap(INT32 i)
#endif
if (block->user != NULL && *(block->user) != given)
{
I_Error("Z_CheckHeap %d: block %u"
I_Error("Z_CheckHeap"
#ifdef ZDEBUG
"at %s %d :"
#endif
"block %u"
#ifdef ZDEBUG
"(owned by %s:%d)"
#endif
" doesn't have a proper user", i, blocknumon
" doesn't have a proper user"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
@@ -510,11 +534,19 @@ void Z_CheckHeap(INT32 i)
}
if (block->next->prev != block)
{
I_Error("Z_CheckHeap %d: block %u"
I_Error("Z_CheckHeap"
#ifdef ZDEBUG
"at %s %d :"
#endif
"block %u"
#ifdef ZDEBUG
"(owned by %s:%d)"
#endif
" lacks proper backlink", i, blocknumon
" lacks proper backlink"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
@@ -522,11 +554,19 @@ void Z_CheckHeap(INT32 i)
}
if (block->prev->next != block)
{
I_Error("Z_CheckHeap %d: block %u"
I_Error("Z_CheckHeap"
#ifdef ZDEBUG
"at %s %d :"
#endif
"block %u"
#ifdef ZDEBUG
"(owned by %s:%d)"
#endif
" lacks proper forward link", i, blocknumon
" lacks proper forward link"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
@@ -534,11 +574,19 @@ void Z_CheckHeap(INT32 i)
}
if (block->id != ZONEID)
{
I_Error("Z_CheckHeap %d: block %u"
I_Error("Z_CheckHeap"
#ifdef ZDEBUG
"at %s %d :"
#endif
"block %u"
#ifdef ZDEBUG
"(owned by %s:%d)"
#endif
" have the wrong ID", i, blocknumon
" have the wrong ID"
#ifdef ZDEBUG
, file, line
#endif
, blocknumon
#ifdef ZDEBUG
, block->ownerfile, block->ownerline
#endif
+23 -16
View File
@@ -32,7 +32,7 @@ extern "C" {
#define FUNCALLOC(x)
#endif
//#define ZDEBUG
#define ZDEBUG
//
// Purge tags
@@ -92,30 +92,31 @@ void Z_Init(void);
// Z_Free and alloc with alignment
#ifdef ZDEBUG
#define Z_Free(p) Z_Free2(p, __FILE__, __LINE__)
#define Z_MallocAlign(s,t,u,a) Z_Malloc2(s, t, u, a, __FILE__, __LINE__)
#define Z_CallocAlign(s,t,u,a) Z_Calloc2(s, t, u, a, __FILE__, __LINE__)
#define Z_ReallocAlign(p,s,t,u,a) Z_Realloc2(p,s, t, u, a, __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__)
void Z_Free2(void *ptr, const char *file, INT32 line);
void *Z_Malloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1);
void *Z_Calloc2(size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(1);
void *Z_Realloc2(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits, const char *file, INT32 line) FUNCALLOC(2);
void *Z_Malloc2(size_t size, INT32 tag, void *user, const char *file, INT32 line) FUNCALLOC(1);
void *Z_Calloc2(size_t size, INT32 tag, void *user, const char *file, INT32 line) FUNCALLOC(1);
void *Z_Realloc2(void *ptr, size_t size, INT32 tag, void *user, const char *file, INT32 line) FUNCALLOC(2);
#else
void Z_Free(void *ptr);
void *Z_MallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(1);
void *Z_CallocAlign(size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(1);
void *Z_ReallocAlign(void *ptr, size_t size, INT32 tag, void *user, INT32 alignbits) FUNCALLOC(2);
void *Z_Malloc(size_t size, INT32 tag, void *user) FUNCALLOC(1);
void *Z_Calloc(size_t size, INT32 tag, void *user) FUNCALLOC(1);
void *Z_Realloc(void *ptr, size_t size, INT32 tag, void *user) FUNCALLOC(2);
#endif
// Alloc with standard alignment
#define Z_Malloc(s,t,u) Z_MallocAlign(s, t, u, sizeof(void *))
#define Z_Calloc(s,t,u) Z_CallocAlign(s, t, u, sizeof(void *))
#define Z_Realloc(p,s,t,u) Z_ReallocAlign(p, s, t, u, sizeof(void *))
// Free all memory by tag
// these don't give line numbers for ZDEBUG currently though
// (perhaps this should be changed in future?)
#ifdef ZDEBUG
#define Z_FreeTag(tagnum) Z_FreeTags2(tagnum, tagnum, __FILE__, __LINE__)
#define Z_FreeTags(tagnum, tagnum2) Z_FreeTags2(tagnum, tagnum2, __FILE__, __LINE__)
void Z_FreeTags2(INT32 lowtag, INT32 hightag, const char *file, INT32 line);
#else
#define Z_FreeTag(tagnum) Z_FreeTags(tagnum, tagnum)
void Z_FreeTags(INT32 lowtag, INT32 hightag);
#endif
// Iterate memory by tag
#define Z_IterateTag(tagnum, func) Z_IterateTags(tagnum, tagnum, func)
@@ -125,7 +126,13 @@ void Z_IterateTags(INT32 lowtag, INT32 hightag, boolean (*iterfunc)(void *));
// Utility functions
//
void Z_CheckMemCleanup(void);
void Z_CheckHeap(INT32 i);
#ifdef ZDEBUG
#define Z_CheckHeap(tag) Z_CheckHeap2(__FILE__, __LINE__)
void Z_CheckHeap2(const char *file, INT32 line);
#else
void Z_CheckHeap(INT32 tag);
#endif
//
// Zone memory modification