diff --git a/comptime.bat b/comptime.bat index 0c7ea06d6..399c5e527 100644 --- a/comptime.bat +++ b/comptime.bat @@ -1,32 +1,32 @@ -@echo off -set BRA=Unknown -set REV=illegal - -copy nul: /b +%1\comptime.c tmp.$$$ > nul -move tmp.$$$ %1\comptime.c > nul - -if exist .git goto gitrev -if exist ..\.git goto gitrev -if exist .svn goto svnrev -goto filwri - -:gitrev -set GIT=%2 -if "%GIT%"=="" set GIT=git -for /f "usebackq" %%s in (`%GIT% rev-parse --abbrev-ref HEAD`) do @set BRA=%%s -for /f "usebackq" %%s in (`%GIT% rev-parse HEAD`) do @set REV=%%s -set REV=%REV:~0,8% -goto filwri - -:svnrev -set BRA=Subversion -for /f "usebackq" %%s in (`svnversion .`) do @set REV=%%s -set REV=r%REV% -goto filwri - -:filwri -echo // Do not edit! This file was autogenerated > %1\comptime.h -echo // by the %0 batch file >> %1\comptime.h -echo // >> %1\comptime.h -echo const char* compbranch = "%BRA%"; >> %1\comptime.h -echo const char* comprevision = "%REV%"; >> %1\comptime.h +@echo off +set BRA=Unknown +set REV=illegal + +copy nul: /b +%1\comptime.c tmp.$$$ > nul +move tmp.$$$ %1\comptime.c > nul + +if exist .git goto gitrev +if exist ..\.git goto gitrev +if exist .svn goto svnrev +goto filwri + +:gitrev +set GIT=%2 +if "%GIT%"=="" set GIT=git +for /f "usebackq" %%s in (`%GIT% rev-parse --abbrev-ref HEAD`) do @set BRA=%%s +for /f "usebackq" %%s in (`%GIT% rev-parse HEAD`) do @set REV=%%s +set REV=%REV:~0,8% +goto filwri + +:svnrev +set BRA=Subversion +for /f "usebackq" %%s in (`svnversion .`) do @set REV=%%s +set REV=r%REV% +goto filwri + +:filwri +echo // Do not edit! This file was autogenerated > %1\comptime.h +echo // by the %0 batch file >> %1\comptime.h +echo // >> %1\comptime.h +echo const char* compbranch = "%BRA%"; >> %1\comptime.h +echo const char* comprevision = "%REV%"; >> %1\comptime.h diff --git a/comptime.sh b/comptime.sh index 18fd6c34f..82dfa0060 100755 --- a/comptime.sh +++ b/comptime.sh @@ -17,7 +17,7 @@ EOF versiongit() { gitbranch="$(git rev-parse --abbrev-ref HEAD)" - gitversion="$(git rev-parse HEAD | cut -c -8)" + gitversion="$(git show --pretty=format:'%h %s' -s HEAD | sed 's/"/\\"/g')" version "$gitbranch" "$gitversion"; exit 0 } diff --git a/src/.gitignore b/src/.gitignore index da5a1fff2..d1d328f14 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,2 +1,4 @@ /cscope.out /srb2wii +*.json +*.idx diff --git a/src/Makefile b/src/Makefile index caaa36f4c..63386f188 100644 --- a/src/Makefile +++ b/src/Makefile @@ -81,18 +81,19 @@ ALL_SYSTEMS=\ ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES))) ifeq ($(OS),Windows_NT) # all windows are Windows_NT... - $(info Detected a Windows system, compiling for 32-bit MinGW SDL2...) + ifeq ($(shell uname -s | grep -o MINGW64),MINGW64) # 64-bit MinGW + $(info Detected a Windows system, compiling for 64-bit MinGW SDL2...) + MINGW64=1 + else # 32-bit MinGW + $(info Detected a Windows system, compiling for 32-bit MinGW SDL2...) + MINGW=1 + endif - # go for a 32-bit sdl mingw exe by default - MINGW=1 SDL=1 WINDOWSHELL=1 - NOUPX=1 + NOOBJDUMP=1 else # if you on the *nix - - NOUPX=1 - system:=$(shell uname -s) ifeq ($(system),Linux) @@ -116,6 +117,7 @@ else # if you on the *nix endif endif +NOUPX=1 # SRB2 data files D_DIR?=../bin/Resources @@ -193,8 +195,6 @@ endif endif ifndef NONET -ifndef NOSATURNSYNCH -DOSATURNSYNCH=1 ifndef NOSATURNJOIN DOSATURNJOIN=1 endif @@ -202,7 +202,6 @@ ifndef NOSATURNPAK DOSATURNPAK=1 endif endif -endif ifdef MINGW include win32/Makefile.cfg @@ -385,8 +384,6 @@ endif endif ifndef NONET -ifndef NOSATURNSYNCH -OPTS+=-DDOSATURNSYNCH ifndef NOSATURNJOIN OPTS+=-DDOSATURNJOIN endif @@ -394,7 +391,6 @@ ifndef NOSATURNPAK OPTS+=-DDOSATURNPAK endif endif -endif ifdef HAVE_MINIUPNPC ifdef NONET @@ -772,30 +768,10 @@ $(OBJDIR)/SRB2.res: win32/Srb2win.rc win32/afxres.h win32/resource.h $(WINDRES) -i $< -O rc $(WINDRESFLAGS) --include-dir=win32 -o $@ -O coff ifdef SDL - ifdef MINGW $(OBJDIR)/win_dbg.o: win32/win_dbg.c $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ endif - -ifdef FILTERS -$(OBJDIR)/%.o: $(INTERFACE)/filter/%.c - @echo $< needs deps - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/filters.o: $(INTERFACE)/filter/filters.c $(INTERFACE)/filter/filters.c \ - $(INTERFACE)/filter/filters.h - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/hq2x.o: $(INTERFACE)/filter/hq2x.c $(INTERFACE)/filter/hq2x.c \ - $(INTERFACE)/filter/filters.h - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/lq2x.o: $(INTERFACE)/filter/lq2x.c $(INTERFACE)/filter/lq2x.c \ - $(INTERFACE)/filter/filters.h $(INTERFACE)/filter/interp.h \ - $(INTERFACE)/filter/hq2x.h $(INTERFACE)/filter/lq2x.h - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ -endif endif ############################################################# diff --git a/src/am_map.c b/src/am_map.c index 3c10f710d..f91273e8b 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -28,14 +28,15 @@ #endif // For use if I do walls with outsides/insides -static const UINT8 REDS = (2*16); +static const UINT8 REDS = (8*16); static const UINT8 REDRANGE = 16; static const UINT8 GRAYS = (1*16); static const UINT8 GRAYSRANGE = 16; -static const UINT8 BROWNS = (15*16); -static const UINT8 YELLOWS = (5*16)+8; -static const UINT8 GREENS = (6*16); -static const UINT8 BLUES = (9*16); +static const UINT8 BROWNS = (3*16); +static const UINT8 YELLOWS = (7*16); +static const UINT8 GREENS = (10*16); +//static const UINT8 CYANS = (13*16); +static const UINT8 BLUES = (14*16); static const UINT8 DBLACK = 31; static const UINT8 DWHITE = 0; @@ -46,7 +47,7 @@ static const UINT8 DWHITE = 0; #define THOKWALLCOLORS REDS #define THOKWALLRANGE REDRANGE #define TSWALLCOLORS DWHITE -#define TSFINISHLINE GRAYS +#define TSFINISHLINE (GREENS + 2) #define TSFOFINFO (BLUES + 4) #define FDWALLCOLORS BROWNS #define CDWALLCOLORS YELLOWS @@ -264,9 +265,6 @@ static void AM_findMinMaxBoundaries(void) max_w = minimapinfo.map_w << MAPBITS; max_h = minimapinfo.map_h << MAPBITS; - max_w = (max_x >>= FRACTOMAPBITS) - (min_x >>= FRACTOMAPBITS); - max_h = (max_y >>= FRACTOMAPBITS) - (min_y >>= FRACTOMAPBITS); - a = FixedDiv(f_w<x, lines[i].v1->y) + FRACUNIT/2) >> FRACBITS; \ - end2 = (P_GetZAt(slope, lines[i].v2->x, lines[i].v2->y) + FRACUNIT/2) >> FRACBITS; \ - } else \ - end1 = end2 = (normalheight + FRACUNIT/2) >> FRACBITS; + end1 = (P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y, ((normalheight + FRACUNIT/2) >> FRACBITS)) + FRACUNIT/2) >> FRACBITS; \ + end2 = (P_GetZAt(slope, lines[i].v2->x, lines[i].v2->y, ((normalheight + FRACUNIT/2) >> FRACBITS)) + FRACUNIT/2) >> FRACBITS; static ffloor_t *AM_CompareFOFs(size_t i, ffloor_t *rover, ffloor_t *secondarystore) { ffloor_t *secondaryrover = NULL; + for (; rover; rover = rover->next) { fixed_t rovt1, rovt2; fixed_t rovb1, rovb2; + if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_BLOCKPLAYER)) continue; + SLOPEPARAMS(*rover->t_slope, rovt1, rovt2, *rover->topheight) SLOPEPARAMS(*rover->b_slope, rovb1, rovb2, *rover->bottomheight) + for (secondaryrover = secondarystore; secondaryrover; secondaryrover = secondaryrover->next) { fixed_t sect1, sect2; fixed_t secb1, secb2; + if (!(secondaryrover->flags & FF_EXISTS)) continue; if (!(secondaryrover->flags & FF_BLOCKPLAYER)) continue; if (secondaryrover->secnum == rover->secnum) break; + SLOPEPARAMS(*secondaryrover->t_slope, sect1, sect2, *secondaryrover->topheight) SLOPEPARAMS(*secondaryrover->b_slope, secb1, secb2, *secondaryrover->bottomheight) + if (rovt1 != sect1) continue; if (rovt2 != sect2) @@ -939,8 +974,27 @@ static ffloor_t *AM_CompareFOFs(size_t i, ffloor_t *rover, ffloor_t *secondaryst continue; if (rovb2 != secb2) continue; + + // this is fucking horrible + INT32 damage1, damage2; + INT32 offroad1, offroad2; + INT32 special1, special2; + special1 = GETSECSPECIAL(sectors[rover->secnum].special, 1); + special2 = GETSECSPECIAL(sectors[secondaryrover->secnum].special, 1); + + damage1 = GetDamage(special1); + damage2 = GetDamage(special2); + offroad1 = GetOffroad(special1); + offroad2 = GetOffroad(special2); + + if (damage1 != damage2 + //|| sectors[rover->secnum].friction != sectors[secondaryrover->secnum].friction + || offroad1 != offroad2) + continue; + break; } + if (secondaryrover == NULL) break; } @@ -983,8 +1037,10 @@ static void AM_drawWalls(UINT8 pass) } continue; } + SLOPEPARAMS(lines[i].backsector->f_slope, backf1, backf2, lines[i].backsector->floorheight) SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight) + if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier || (frontf1 == frontc1 && frontf2 == frontc2)) // Front is thok barrier { @@ -1003,29 +1059,28 @@ static void AM_drawWalls(UINT8 pass) } else { - //dont think kart even supports those idk? - /*if (lines[i].flags & (ML_IMPASSABLE|ML_BLOCKPLAYERS)) + if (lines[i].flags & ML_IMPASSIBLE) // (ML_IMPASSABLE|ML_BLOCKPLAYERS) { if (pass & PASS_SOLID) AM_drawMline(&l, TSWALLCOLORS); // Completely solid course boundary } - else if ((lines[i].flags & ML_MIDSOLID) + else if ((lines[i].flags & ML_EFFECT4) // ML_MIDSOLID && sides[lines->sidenum[0]].midtexture) { if (pass & PASS_SOLID) AM_drawMline(&l, TSWALLCOLORS); // solid midtexture, likely a course boundary - }*/ + } if ((backf1 != frontf1 && abs(backf1 - frontf1) > maxstep) || (backf2 != frontf2 && abs(backf2 - frontf2) > maxstep)) { if (pass & PASS_SOLID) AM_drawMline(&l, TSWALLCOLORS); // floor-wall, likely a course boundary } - /*else if (lines[i].special == 2001) // guh its a sector effect in kart idk how to make it work tbh lol + else if (GETSECSPECIAL(lines[i].frontsector->special, 4) == 10 || GETSECSPECIAL(lines[i].backsector->special, 4) == 10) { if (pass & PASS_SOLID) AM_drawMline(&l, TSFINISHLINE); // finish line - }*/ + } else if (backf1 != frontf1 || backf2 != frontf2) { if (pass & PASS_INTANGIBLE) @@ -1047,54 +1102,52 @@ static void AM_drawWalls(UINT8 pass) } else { - { - ffloor_t *rover = NULL; + ffloor_t *rover = NULL; - if (lines[i].frontsector->ffloors || lines[i].backsector->ffloors) + if (lines[i].frontsector->ffloors || lines[i].backsector->ffloors) + { + if (lines[i].backsector->ffloors == NULL) { - if (lines[i].backsector->ffloors == NULL) + // Check frontside for one solid + for (rover = lines[i].frontsector->ffloors; rover; rover = rover->next) { - // Check frontside for one solid - for (rover = lines[i].frontsector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) - continue; - if (!(rover->flags & FF_BLOCKPLAYER)) - continue; - break; - } - } - else if (lines[i].frontsector->ffloors == NULL) - { - // Check backside for one solid - for (rover = lines[i].backsector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) - continue; - if (!(rover->flags & FF_BLOCKPLAYER)) - continue; - break; - } - } - else - { - // Check to see if any secnums exist in one but not the other. - rover = AM_CompareFOFs(i, lines[i].frontsector->ffloors, lines[i].backsector->ffloors); - if (rover == NULL) - rover = AM_CompareFOFs(i, lines[i].backsector->ffloors, lines[i].frontsector->ffloors); + if (!(rover->flags & FF_EXISTS)) + continue; + if (!(rover->flags & FF_BLOCKPLAYER)) + continue; + break; } } - if (rover != NULL) + else if (lines[i].frontsector->ffloors == NULL) { - if (pass & PASS_FOF) - AM_drawMline(&l, TSFOFINFO); // a FOF is here but we don't know how to distinguish them yet + // Check backside for one solid + for (rover = lines[i].backsector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + if (!(rover->flags & FF_BLOCKPLAYER)) + continue; + break; + } } - else if (!am_minigen) + else { - if (pass & PASS_INTANGIBLE) - AM_drawMline(&l, GRIDCOLORS); // likely low-relevance line + // Check to see if any secnums exist in one but not the other. + rover = AM_CompareFOFs(i, lines[i].frontsector->ffloors, lines[i].backsector->ffloors); + if (rover == NULL) + rover = AM_CompareFOFs(i, lines[i].backsector->ffloors, lines[i].frontsector->ffloors); } } + if (rover != NULL) + { + if (pass & PASS_FOF) + AM_drawMline(&l, TSFOFINFO); // a FOF is here but we don't know how to distinguish them yet + } + else if (!am_minigen) + { + if (pass & PASS_INTANGIBLE) + AM_drawMline(&l, GRIDCOLORS); // likely low-relevance line + } } } } @@ -1172,18 +1225,11 @@ static inline void AM_drawPlayers(void) player_t *p; INT32 color = GREENS; - if (!multiplayer) - { - AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 16<mo->angle, DWHITE, plr->mo->x, plr->mo->y); - return; - } - - // multiplayer (how??) for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator) continue; - + if (!players[i].mo) continue; @@ -1205,7 +1251,36 @@ static inline void AM_drawThings(UINT8 colors) t = sectors[i].thinglist; while (t) { - AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<angle, colors, t->x, t->y); + if (!t->player) + AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<angle, colors, t->x, t->y); + t = t->snext; + } + } +} + +static inline void AM_drawSpecialThingsOnly(UINT8 colors) +{ + size_t i; + + for (i = 0; i < numsectors; i++) + { + mobj_t *t = NULL; + + // this is fucking horrible + const INT32 special = GETSECSPECIAL(sectors[i].special, 1); + + if (GetDamage(special) != 0 + //|| sectors[i].friction < ORIG_FRICTION + || GetOffroad(special) != 0) + continue; + + t = sectors[i].thinglist; + while (t) + { + if (t->type == MT_RANDOMITEM + || t->type == MT_STARPOST + || (t->flags & MF_SPRING)) + AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<angle, colors, t->x, t->y); t = t->snext; } } @@ -1220,16 +1295,19 @@ static inline void AM_drawCrosshair(UINT8 color) const fixed_t scale = 4<> FRACBITS; fl.a.y = FixedMul(cross_mark[i].a.y, scale) >> FRACBITS; fl.b.x = FixedMul(cross_mark[i].b.x, scale) >> FRACBITS; fl.b.y = FixedMul(cross_mark[i].b.y, scale) >> FRACBITS; + fl.a.x += f_x + (f_w / 2); fl.a.y += f_y + (f_h / 2); fl.b.x += f_x + (f_w / 2); fl.b.y += f_y + (f_h / 2); + AM_drawFline(&fl, color); } } @@ -1250,8 +1328,8 @@ void AM_Drawer(void) AM_clearFB(BACKGROUND); if (draw_grid) AM_drawGrid(GRIDCOLORS); AM_drawWalls(PASS_FOF|PASS_INTANGIBLE|PASS_SOLID); - AM_drawPlayers(); AM_drawThings(THINGCOLORS); + AM_drawPlayers(); if (!followplayer) AM_drawCrosshair(XHAIRCOLORS); } @@ -1307,6 +1385,7 @@ minigen_t *AM_MinimapGenerate(INT32 mul) //AM_clearFB(BACKGROUND); memset(am_buf, 0xff, (f_w*f_h)); + AM_drawSpecialThingsOnly(BACKGROUND); AM_drawWalls(PASS_FOF); AM_drawWalls(PASS_INTANGIBLE); AM_drawWalls(PASS_SOLID); diff --git a/src/command.c b/src/command.c index fa84626fb..eb38a0f6a 100644 --- a/src/command.c +++ b/src/command.c @@ -1493,11 +1493,7 @@ static void Got_NetVar(UINT8 **p, INT32 playernum) if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 14ee18d17..4a2a0cc0f 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -94,7 +94,7 @@ UINT8 playernode[MAXPLAYERS]; // The actual timeout will be longer depending on the savegame length tic_t jointimeout = (3*TICRATE); static boolean sendingsavegame[MAXNETNODES]; // Are we sending the savegame? -#ifdef SATURNSYNCH +#ifdef SATURNPAK static boolean resendingsavegame[MAXNETNODES]; // Are we resending the savegame? static tic_t savegameresendcooldown[MAXNETNODES]; // How long before we can resend again? #endif @@ -114,10 +114,10 @@ boolean server_lagless; static void Lagless_OnChange(void) { /* don't back out of dishonesty, or go lagless after playing honestly */ - if (cv_lagless.value && gamestate == GS_LEVEL) + if (!cv_gentlemens.value && gamestate == GS_LEVEL) server_lagless = true; - /*if (cv_lagless.value) + /*if (!cv_gentlemens.value) HU_AddChatText(M_GetText("\x82*Gentlemans Delay has been disabled for Serverplayer."), false); else HU_AddChatText(M_GetText("\x82*Gentlemans Delay will be enabled for Serverplayer."), false);*/ @@ -125,7 +125,7 @@ static void Lagless_OnChange(void) static CV_PossibleValue_t mindelay_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; consvar_t cv_mindelay = {"mindelay", "0", CV_SAVE, mindelay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_lagless = {"serverlagless", "On", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Lagless_OnChange, 0, NULL, NULL, 0, 0, NULL}; // this should be a netvar Zzz... +consvar_t cv_gentlemens = {"gentlemensdelay", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Lagless_OnChange, 0, NULL, NULL, 0, 0, NULL}; // this should be a netvar Zzz... SINT8 nodetoplayer[MAXNETNODES]; SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) @@ -153,9 +153,8 @@ static UINT8 resynch_inprogress[MAXNETNODES]; static UINT8 resynch_local_inprogress = false; // WE are desynched and getting packets to fix it. UINT8 hu_resynching = 0; -#ifdef SATURNSYNCH +#ifdef SATURNPAK UINT8 hu_redownloadinggamestate = 0; -static boolean can_receive_gamestate[MAXNETNODES]; static UINT8 gamestate_resend_counter[MAXNETNODES]; #endif @@ -168,11 +167,8 @@ static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server -#ifdef SATURNSYNCH -static boolean cl_redownloadinggamestate = false; -#endif - #ifdef SATURNPAK +static boolean cl_redownloadinggamestate = false; boolean is_client_saturn[MAXNETNODES]; #endif @@ -234,6 +230,14 @@ consvar_t cv_httpsource = {"http_source", "", CV_SAVE, NULL, NULL, 0, NULL, NULL consvar_t cv_kicktime = {"kicktime", "10", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +static boolean UseLocalDelay(void) +{ + if (dedicated || (server && server_lagless && !cv_mindelay.value)) + return false; + + return (cv_mindelay.value || (server && !server_lagless)); +} + static inline void *G_DcpyTiccmd(void* dest, const ticcmd_t* src, const size_t n) { const size_t d = n / sizeof(ticcmd_t); @@ -488,11 +492,7 @@ static void ExtraDataTicker(void) { if (server) { - UINT8 buf[3]; - - buf[0] = (UINT8)i; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(i, KICK_MSG_CON_FAIL); DEBFILE(va("player %d kicked [gametic=%u] reason as follows:\n", i, gametic)); } CONS_Alert(CONS_WARNING, M_GetText("Got unknown net command [%s]=%d (max %d)\n"), sizeu1(curpos - bufferstart), *curpos, bufferstart[0]); @@ -539,6 +539,15 @@ void D_ResetTiccmds(void) D_Clearticcmd(textcmds[i]->tic); } +void SendKick(UINT8 playernum, UINT8 msg) +{ + UINT8 buf[2]; + + buf[0] = playernum; + buf[1] = msg; + SendNetXCmd(XD_KICK, &buf, 2); +} + // ----------------------------------------------------------------- // end of extra data function // ----------------------------------------------------------------- @@ -1112,10 +1121,7 @@ static void SV_SendResynch(INT32 node) if (resynch_score[node] > (unsigned)cv_resynchattempts.value*250) { - UINT8 buf[2]; - buf[0] = (UINT8)nodetoplayer[node]; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(nodetoplayer[node], KICK_MSG_CON_FAIL); resynch_score[node] = 0; } } @@ -1178,11 +1184,6 @@ typedef enum static void GetPackets(void); static cl_mode_t cl_mode = CL_SEARCHING; - -#ifdef HAVE_CURL -char http_source[MAX_MIRROR_LENGTH+1]; -#endif - static UINT16 cl_lastcheckedfilecount = 0; // used for full file list // Player name send/load @@ -1256,10 +1257,10 @@ static inline void CL_DrawConnectionStatus(void) { #ifdef JOININGAME case CL_DOWNLOADSAVEGAME: - if (lastfilenum != -1) + if (filedownload.current != -1) { - UINT32 currentsize = fileneeded[lastfilenum].currentsize; - UINT32 totalsize = fileneeded[lastfilenum].totalsize; + UINT32 currentsize = fileneeded[filedownload.current].currentsize; + UINT32 totalsize = fileneeded[filedownload.current].totalsize; INT32 dldlength; cltext = M_GetText("Downloading game state..."); @@ -1354,13 +1355,13 @@ static inline void CL_DrawConnectionStatus(void) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, va(" %2u/%2u Files",loadcompletednum,fileneedednum)); } - else if (lastfilenum != -1) + else if (filedownload.current != -1) { INT32 dldlength; INT32 totalfileslength; UINT32 totaldldsize; static char tempname[28]; - fileneeded_t *file = &fileneeded[lastfilenum]; + fileneeded_t *file = &fileneeded[filedownload.current]; char *filename = file->filename; // Draw the bottom box. @@ -1399,32 +1400,32 @@ static inline void CL_DrawConnectionStatus(void) V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-58-22, V_YELLOWMAP|MENUCAPS, va(M_GetText("\"%s\""), tempname)); V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uK/%4uK",fileneeded[lastfilenum].currentsize>>10,file->totalsize>>10)); + va(" %4uK/%4uK",file->currentsize>>10,file->totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-58, V_20TRANS|V_MONOSPACE|MENUCAPS, va("%3.1fK/s ", ((double)getbps)/1024)); // Download progress - if (fileneeded[lastfilenum].currentsize != fileneeded[lastfilenum].totalsize) - totaldldsize = downloadcompletedsize+fileneeded[lastfilenum].currentsize; //Add in single file progress download if applicable + if (file->currentsize != file->totalsize) + totaldldsize = filedownload.completedsize+file->currentsize; //Add in single file progress download if applicable else - totaldldsize = downloadcompletedsize; + totaldldsize = filedownload.completedsize; V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT-24-14, V_YELLOWMAP|MENUCAPS, "Overall Download Progress"); - totalfileslength = (INT32)((totaldldsize/(double)totalfilesrequestedsize) * 256); + totalfileslength = (INT32)((totaldldsize/(double)filedownload.totalsize) * 256); M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT-24-8, 32, 1); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 175); V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, totalfileslength, 8, 160); - if (totalfilesrequestedsize>>20 >= 10) //display in MB if over 10MB + if (filedownload.totalsize>>20 >= 10) //display in MB if over 10MB V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uM/%4uM",totaldldsize>>20,totalfilesrequestedsize>>20)); + va(" %4uM/%4uM",totaldldsize>>20,filedownload.totalsize>>20)); else V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va(" %4uK/%4uK",totaldldsize>>10,totalfilesrequestedsize>>10)); + va(" %4uK/%4uK",totaldldsize>>10,filedownload.totalsize>>10)); V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE|MENUCAPS, - va("%2u/%2u Files ",downloadcompletednum,totalfilesrequestednum)); + va("%2u/%2u Files ", filedownload.completednum, filedownload.totalnum)); } else { @@ -1821,7 +1822,7 @@ static boolean SV_SendServerConfig(INT32 node) #ifdef JOININGAME #define SAVEGAMESIZE (768*1024) -#ifdef SATURNSYNCH +#ifdef SATURNPAK static boolean SV_ResendingSavegameToAnyone(void) { INT32 i; @@ -2008,7 +2009,7 @@ static void CL_LoadReceivedSavegame(boolean reloading) consistancy[gametic%TICQUEUE] = Consistancy(); CON_ToggleOff(); -#ifdef SATURNSYNCH +#ifdef SATURNPAK // Tell the server we have received and reloaded the gamestate // so they know they can resume the game if (reloading) @@ -2019,7 +2020,7 @@ static void CL_LoadReceivedSavegame(boolean reloading) #endif } -#ifdef SATURNSYNCH +#ifdef SATURNPAK static void CL_ReloadReceivedSavegame(void) { INT32 i; @@ -2185,7 +2186,7 @@ void CL_QueryServerList (msg_server_t *server_list) { INT32 node = I_NetMakeNodewPort(server_list[i].ip, server_list[i].port); if (node == -1) - break; // no more node free + continue; // no more node free, or resolution failure SendAskInfo(node); resendserverlistnode[node] = true; // Leave this node open. It'll be closed if the @@ -2230,10 +2231,10 @@ void CL_TimeoutServerList(void) static void CL_ConfirmConnect(void) { - if (totalfilesrequestednum > 0) + if (filedownload.totalnum > 0) { #ifdef HAVE_CURL - if (http_source[0] == '\0' || curl_failedwebdownload) + if (filedownload.http_source[0] == '\0' || filedownload.http_failed) #endif { if (CL_SendRequestFile()) @@ -2346,7 +2347,7 @@ static boolean CL_FinishedFileList(void) // must download something // can we, though? #ifdef HAVE_CURL - if (http_source[0] == '\0' || curl_failedwebdownload) + if (filedownload.http_source[0] == '\0' || filedownload.http_failed) #endif { if (!CL_CheckDownloadable()) // nope! @@ -2366,30 +2367,31 @@ static boolean CL_FinishedFileList(void) } #ifdef HAVE_CURL - if (!curl_failedwebdownload) + if (!filedownload.http_failed) #endif { #ifndef NONET - downloadcompletednum = 0; - downloadcompletedsize = 0; - totalfilesrequestednum = 0; - totalfilesrequestedsize = 0; + filedownload.completednum = 0; + filedownload.completedsize = 0; + + filedownload.totalnum = 0; + filedownload.totalsize = 0; #endif for (i = 0; i < fileneedednum; i++) if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) { #ifndef NONET - totalfilesrequestednum++; - totalfilesrequestedsize += fileneeded[i].totalsize; + filedownload.totalnum++; + filedownload.totalsize += fileneeded[i].totalsize; #endif } #ifndef NONET - if (totalfilesrequestedsize>>20 >= 10) - downloadsize = Z_StrDup(va("%uM",totalfilesrequestedsize>>20)); + if (filedownload.totalsize>>20 >= 10) + downloadsize = Z_StrDup(va("%uM",filedownload.totalsize>>20)); else - downloadsize = Z_StrDup(va("%uK",totalfilesrequestedsize>>10)); + downloadsize = Z_StrDup(va("%uK",filedownload.totalsize>>10)); #endif if (cv_showdownloadprompt.value) @@ -2474,9 +2476,9 @@ static boolean CL_ServerConnectionSearchTicker(tic_t *asksent) { #ifdef HAVE_CURL if (serverlist[i].info.httpsource[0]) - strncpy(http_source, serverlist[i].info.httpsource, MAX_MIRROR_LENGTH); + strncpy(filedownload.http_source, serverlist[i].info.httpsource, MAX_MIRROR_LENGTH); else - http_source[0] = '\0'; + filedownload.http_source[0] = '\0'; #else if (serverlist[i].info.httpsource[0]) CONS_Printf("We received a http url from the server, however it will not be used as this build lacks curl support (%s)\n", serverlist[i].info.httpsource); @@ -2559,12 +2561,12 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic break; #ifdef HAVE_CURL case CL_PREPAREHTTPFILES: - if (http_source[0]) + if (filedownload.http_source[0]) { for (i = 0; i < fileneedednum; i++) if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) { - curl_transfers++; + filedownload.remaining++; } cl_mode = CL_DOWNLOADHTTPFILES; @@ -2576,8 +2578,8 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic for (i = 0; i < fileneedednum; i++) if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) { - if (!curl_running) - CURLPrepareFile(http_source, i); + if (!filedownload.http_running) + CURLPrepareFile(filedownload.http_source, i); waitmore = true; break; } @@ -2585,14 +2587,14 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic if (waitmore) break; // exit the case - if (curl_failedwebdownload && !curl_transfers) + if (filedownload.http_failed && !filedownload.remaining) { CONS_Printf("One or more files failed to download, falling back to internal downloader\n"); cl_mode = CL_CHECKFILES; break; } - if (!curl_transfers) + if (!filedownload.remaining) cl_mode = CL_LOADFILES; break; @@ -2769,7 +2771,7 @@ static void CL_ConnectToServer(void) #endif #ifdef CLIENT_LOADINGSCREEN - lastfilenum = -1; + filedownload.current = -1; #endif cl_mode = CL_SEARCHING; @@ -3156,10 +3158,14 @@ static void Command_connect(void) M_ClearMenus(true); - if (Playing() || demo.title) + if (Playing() || demo.title || demo.playback) { - if (demo.title) + if (demo.title || demo.playback) + { G_CheckDemoStatus(); + if (multiplayer && !demo.title) // dumb hack: G_CheckDemoStatus doesent call G_StopDemo for multiplayer demos + G_StopDemo(); + } if (netgame) { @@ -3257,6 +3263,7 @@ void CL_ClearPlayer(INT32 playernum) P_RemoveMobj(players[playernum].mo->tracer); P_RemoveMobj(players[playernum].mo); } + memset(&players[playernum], 0, sizeof (player_t)); } @@ -3336,7 +3343,7 @@ void CL_RemovePlayer(INT32 playernum, INT32 reason) // remove avatar of player playeringame[playernum] = false; playernode[playernum] = UINT8_MAX; - while (!playeringame[doomcom->numslots-1] && doomcom->numslots > 1) + while ((doomcom->numslots > 1) && !playeringame[doomcom->numslots-1]) doomcom->numslots--; // Reset the name @@ -3406,18 +3413,18 @@ void CL_Reset(void) memset(packetstat, 0, sizeof(packetstat)); #ifndef NONET - totalfilesrequestednum = 0; - totalfilesrequestedsize = 0; + filedownload.totalnum = 0; + filedownload.totalsize = 0; #endif firstconnectattempttime = 0; serverisfull = false; connectiontimeout = (tic_t)cv_nettimeout.value; //reset this temporary hack #ifdef HAVE_CURL - curl_failedwebdownload = false; - curl_transfers = 0; - curl_running = false; - http_source[0] = '\0'; + filedownload.remaining = 0; + filedownload.http_failed = false; + filedownload.http_running = false; + filedownload.http_source[0] = '\0'; #endif G_ResetAllDeviceRumbles(); @@ -4082,7 +4089,7 @@ static void Command_list_http_logins (void) } #endif/*HAVE_CURL*/ -#ifdef SATURNSYNCH +#ifdef SATURNPAK static void Command_ResendGamestate(void) { SINT8 playernum; @@ -4139,7 +4146,7 @@ consvar_t cv_discordinvites = {"discordinvites", "Everyone", CV_SAVE|CV_CALL, di static CV_PossibleValue_t resynchattempts_cons_t[] = {{0, "MIN"}, {20, "MAX"}, {0, NULL}}; consvar_t cv_resynchattempts = {"resynchattempts", "2", CV_SAVE, resynchattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#ifdef SATURNSYNCH +#ifdef SATURNPAK static CV_PossibleValue_t gamestateattempts_cons_t[] = {{0, "MIN"}, {30, "MAX"}, {0, NULL}}; consvar_t cv_gamestateattempts = {"gamestateresendattempts", "10", CV_SAVE, gamestateattempts_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -4203,7 +4210,7 @@ void D_ClientServerInit(void) COM_AddCommand("reloadbans", Command_ReloadBan); COM_AddCommand("connect", Command_connect); COM_AddCommand("nodes", Command_Nodes); -#ifdef SATURNSYNCH +#ifdef SATURNPAK COM_AddCommand("resendgamestate", Command_ResendGamestate); #endif COM_AddCommand("listplayers", Command_Listplayers); @@ -4263,11 +4270,7 @@ static void ResetNode(INT32 node) // SATURN #ifdef SATURNPAK is_client_saturn[node] = false; -#endif - -#ifdef SATURNSYNCH resendingsavegame[node] = false; - can_receive_gamestate[node] = false; savegameresendcooldown[node] = 0; gamestate_resend_counter[node] = 0; #endif @@ -4313,7 +4316,7 @@ void SV_ResetServer(void) mynode = 0; cl_packetmissed = false; -#ifdef SATURNSYNCH +#ifdef SATURNPAK cl_redownloadinggamestate = false; #endif @@ -4427,11 +4430,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal add player command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -4515,11 +4514,7 @@ static void Got_RemovePlayer(UINT8 **p, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal remove player command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -4626,14 +4621,10 @@ void CL_AddSplitscreenPlayer(void) void CL_RemoveSplitscreenPlayer(UINT8 p) { - UINT8 buf[2]; - if (cl_mode != CL_CONNECTED) return; - buf[0] = p; - buf[1] = KICK_MSG_PLAYER_QUIT; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(p, KICK_MSG_PLAYER_QUIT); } // is there a game running @@ -4943,7 +4934,7 @@ static void HandleServerInfo(SINT8 node) } #endif -#ifdef SATURNSYNCH +#ifdef SATURNPAK static void PT_WillResendGamestate(void) { char tmpsave[264]; @@ -5258,13 +5249,8 @@ static boolean CheckForSpeedHacks(UINT8 p) || netcmds[maketic%TICQUEUE][p].sidemove > MAXPLMOVE || netcmds[maketic%TICQUEUE][p].sidemove < -MAXPLMOVE || netcmds[maketic%TICQUEUE][p].driftturn > KART_FULLTURN || netcmds[maketic%TICQUEUE][p].driftturn < -KART_FULLTURN) { - char buf[2]; CONS_Alert(CONS_WARNING, M_GetText("Illegal movement value received from node %d\n"), playernode[p]); - //D_Clearticcmd(k); - - buf[0] = (char)p; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(p, KICK_MSG_CON_FAIL); return true; } @@ -5415,7 +5401,7 @@ static void HandlePacketFromPlayer(SINT8 node) break; } -#ifdef SATURNSYNCH +#ifdef SATURNPAK // this decreases by one point at twice the cooldown time (ex cooldown of 2 seconds means, this counter decreases by one every 4 seconds), pretty much there to prevent a resynch loop if ((gamestate_resend_counter[node] != 0) && (I_GetTime() % ((max(cv_resynchcooldown.value, 1) * TICRATE) *2) == 0)) { @@ -5427,27 +5413,16 @@ static void HandlePacketFromPlayer(SINT8 node) if (gamestate == GS_LEVEL && (realstart > gametic - TICQUEUE+1 && realstart <= gametic) && consistancy[realstart%TICQUEUE] != SHORT(netbuffer->u.clientpak.consistancy) - && (!can_receive_gamestate[node] || (!resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() && !SV_ResendingSavegameToAnyone()))) + && (!is_client_saturn[node] || (!resendingsavegame[node] && savegameresendcooldown[node] <= I_GetTime() && !SV_ResendingSavegameToAnyone()))) { -//#ifndef SATURNPAK // lug: keep this behaviour for v7.1 atleast - // we need to send this so the client can tell us if it can receive the savegame - netbuffer->packettype = PT_WILLRESENDGAMESTATE; - HSendPacket(node, true, 0, 0); - - if (can_receive_gamestate[node]) - resendingsavegame[node] = true; - else - { - SV_RequireResynch(node); - resendingsavegame[node] = false; - } -/*#else - if (can_receive_gamestate[node]) + // Check if a client is saturn before sending ANYTHING! + // this way we only send stuff to clients we know can use the gamestate resend + // and dont have to wait for a response from clients that never would send a response back + if (is_client_saturn[node]) { // Tell the client we are about to resend them the gamestate netbuffer->packettype = PT_WILLRESENDGAMESTATE; HSendPacket(node, true, 0, 0); - resendingsavegame[node] = true; } else @@ -5455,11 +5430,10 @@ static void HandlePacketFromPlayer(SINT8 node) SV_RequireResynch(node); resendingsavegame[node] = false; } -#endif*/ - if ((!can_receive_gamestate[node] && (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250)) || (can_receive_gamestate[node] && (gamestate_resend_counter[node] < cv_gamestateattempts.value))) + if ((!is_client_saturn[node] && (cv_resynchattempts.value && resynch_score[node] <= (unsigned)cv_resynchattempts.value*250)) || (is_client_saturn[node] && (gamestate_resend_counter[node] < cv_gamestateattempts.value))) { - if (can_receive_gamestate[node] && resendingsavegame[node]) + if (is_client_saturn[node] && resendingsavegame[node]) { gamestate_resend_counter[node]++; DEBFILE(va("gamestate counter %d for node %d\n", gamestate_resend_counter[node], netconsole)); @@ -5477,11 +5451,7 @@ static void HandlePacketFromPlayer(SINT8 node) } else { - UINT8 buf[3]; - - buf[0] = (UINT8)netconsole; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(netconsole, KICK_MSG_CON_FAIL); DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n", netconsole, realstart, consistancy[realstart%TICQUEUE], SHORT(netbuffer->u.clientpak.consistancy))); @@ -5512,11 +5482,7 @@ static void HandlePacketFromPlayer(SINT8 node) } else { - UINT8 buf[3]; - - buf[0] = (UINT8)netconsole; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(netconsole, KICK_MSG_CON_FAIL); DEBFILE(va("player %d kicked (synch failure) [%u] %d!=%d\n", netconsole, realstart, consistancy[realstart%TICQUEUE], SHORT(netbuffer->u.clientpak.consistancy))); @@ -5627,13 +5593,7 @@ static void HandlePacketFromPlayer(SINT8 node) nodewaiting[node] = 0; if (netconsole != -1 && playeringame[netconsole]) { - UINT8 buf[2]; - buf[0] = (UINT8)netconsole; - if (netbuffer->packettype == PT_NODETIMEOUT) - buf[1] = KICK_MSG_TIMEOUT; - else - buf[1] = KICK_MSG_PLAYER_QUIT; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(netconsole, (netbuffer->packettype == PT_NODETIMEOUT) ? KICK_MSG_TIMEOUT : KICK_MSG_PLAYER_QUIT); } Net_CloseConnection(node); nodeingame[node] = false; @@ -5647,10 +5607,7 @@ static void HandlePacketFromPlayer(SINT8 node) if (server) { - UINT8 buf[2]; - buf[0] = (UINT8)node; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(node, KICK_MSG_CON_FAIL); } break; @@ -5672,10 +5629,7 @@ static void HandlePacketFromPlayer(SINT8 node) if (server) { - UINT8 buf[2]; - buf[0] = (UINT8)node; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(node, KICK_MSG_CON_FAIL); } break; @@ -5739,10 +5693,7 @@ static void HandlePacketFromPlayer(SINT8 node) if (server) { - char buf[2]; - buf[0] = (char)node; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(node, KICK_MSG_CON_FAIL); } break; @@ -5758,10 +5709,7 @@ static void HandlePacketFromPlayer(SINT8 node) if (server) { - char buf[2]; - buf[0] = (char)node; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(node, KICK_MSG_CON_FAIL); } break; @@ -5789,10 +5737,7 @@ static void HandlePacketFromPlayer(SINT8 node) if (server) { - UINT8 buf[2]; - buf[0] = (UINT8)node; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(node, KICK_MSG_CON_FAIL); } break; @@ -5800,9 +5745,8 @@ static void HandlePacketFromPlayer(SINT8 node) if (client) Got_Filetxpak(); break; -#ifdef SATURNSYNCH +#ifdef SATURNPAK case PT_CANRECEIVEGAMESTATE: - can_receive_gamestate[node] = true; PT_CanReceiveGamestate(node); break; case PT_RECEIVEDGAMESTATE: @@ -5813,12 +5757,9 @@ static void HandlePacketFromPlayer(SINT8 node) case PT_WILLRESENDGAMESTATE: PT_WillResendGamestate(); break; -#endif -#ifdef SATURNPAK case PT_ISSATURN: DEBFILE(va("hi im on saturn! node = %d\n", node)); is_client_saturn[node] = true; - can_receive_gamestate[node] = true; break; #endif default: @@ -6097,7 +6038,7 @@ static void CL_SendClientCmd(void) { UINT8 lagDelay = 0; - if (lowest_lag > 0) + if (UseLocalDelay() && (lowest_lag > 0)) { // Gentlemens' ping. lagDelay = min(lowest_lag, MAXGENTLEMENDELAY); @@ -6344,9 +6285,12 @@ static inline void CreateNewLocalCMD(UINT8 p, INT32 realtics) { INT32 i; - for (i = MAXGENTLEMENDELAY-1; i > 0; i--) + if (UseLocalDelay()) { - G_MoveTiccmd(&localcmds[p][i], &localcmds[p][i-1], 1); + for (i = MAXGENTLEMENDELAY-1; i > 0; i--) + { + G_MoveTiccmd(&localcmds[p][i], &localcmds[p][i-1], 1); + } } G_BuildTiccmd(&localcmds[p][0], realtics, p+1); @@ -6543,6 +6487,7 @@ static inline void PingUpdate(void) INT32 i; UINT8 pingkick[MAXPLAYERS]; UINT8 nonlaggers = 0; + memset(pingkick, 0, sizeof(pingkick)); netbuffer->packettype = PT_PING; @@ -6589,8 +6534,6 @@ static inline void PingUpdate(void) UINT8 minimumkicklevel = (nonlaggers > 0) ? PINGKICK_LIMIT : PINGKICK_TICQUEUE; for (i = 0; i < MAXPLAYERS; i++) { - char buf[2]; - if (!playeringame[i] || pingkick[i] < minimumkicklevel) continue; @@ -6602,10 +6545,7 @@ static inline void PingUpdate(void) } pingtimeout[i] = 0; - - buf[0] = (char)i; - buf[1] = KICK_MSG_PING_HIGH; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(i, KICK_MSG_PING_HIGH); } } } @@ -6647,7 +6587,8 @@ static void UpdatePingTable(void) if (server) { - if (Playing() && !(gametime % 8)) // Value chosen based on _my vibes man_ + //if (Playing() && !(gametime % 8)) // Value chosen based on _my vibes man_ << dont do this for v8 atleast, this is placeboeing ppl to hell and back + if (Playing() && !(gametime % 35)) // update once per second. PingUpdate(); fastest = 0; @@ -6659,7 +6600,7 @@ static void UpdatePingTable(void) { realpingtable[i] += GetLag(playernode[i]); - if (!server_lagless && !players[i].spectator) + if (UseLocalDelay() && !server_lagless && !players[i].spectator) { lag = playerpingtable[i]; if (! fastest || lag < fastest) @@ -6668,30 +6609,40 @@ static void UpdatePingTable(void) } } - if (server_lagless) - lowest_lag = 0; + if (UseLocalDelay()) + { + if (server_lagless) + lowest_lag = 0; + else + lowest_lag = fastest; + + // Don't gentleman below your mindelay + if (lowest_lag < (tic_t)cv_mindelay.value) + lowest_lag = (tic_t)cv_mindelay.value; + + simulated_lag = lowest_lag; + } else - lowest_lag = fastest; - - // Don't gentleman below your mindelay - if (lowest_lag < (tic_t)cv_mindelay.value) - lowest_lag = (tic_t)cv_mindelay.value; - - simulated_lag = lowest_lag; + lowest_lag = simulated_lag = 0; pingmeasurecount++; } else // We're a client, handle mindelay on the way out. { - // Previously (neededtic - gametic) - WRONG VALUE! - // Pretty sure that's measuring jitter, not RTT. - // Stable connections would be punished by adding their mindelay to network delay! - tic_t mydelay = playerpingtable[consoleplayer]; - - if (mydelay < (tic_t)cv_mindelay.value) + if (UseLocalDelay()) { - lowest_lag = ((tic_t)cv_mindelay.value - mydelay); - simulated_lag = (tic_t)cv_mindelay.value; + // Previously (neededtic - gametic) - WRONG VALUE! + // Pretty sure that's measuring jitter, not RTT. + // Stable connections would be punished by adding their mindelay to network delay! + tic_t mydelay = playerpingtable[consoleplayer]; + + if (mydelay < (tic_t)cv_mindelay.value) + { + lowest_lag = ((tic_t)cv_mindelay.value - mydelay); + simulated_lag = (tic_t)cv_mindelay.value; + } + else + lowest_lag = simulated_lag = 0; } else lowest_lag = simulated_lag = 0; @@ -6876,7 +6827,7 @@ void NetUpdate(void) if (client) { -#ifdef SATURNSYNCH +#ifdef SATURNPAK // If the client just finished redownloading the game state, load it if (cl_redownloadinggamestate && fileneeded[0].status == FS_FOUND) CL_ReloadReceivedSavegame(); @@ -6885,7 +6836,7 @@ void NetUpdate(void) CL_SendClientCmd(); // Send tic cmd hu_resynching = resynch_local_inprogress; -#ifdef SATURNSYNCH +#ifdef SATURNPAK hu_redownloadinggamestate = cl_redownloadinggamestate; #endif } @@ -6896,17 +6847,22 @@ void NetUpdate(void) INT32 counts; hu_resynching = false; -#ifdef SATURNSYNCH +#ifdef SATURNPAK hu_redownloadinggamestate = false; #endif + // Don't erase tics not acknowledged + counts = realtics; firstticstosend = gametic; for (i = 0; i < MAXNETNODES; i++) - if (nodeingame[i] && nettics[i] < firstticstosend) + { + if (!nodeingame[i]) + continue; + if (nettics[i] < firstticstosend) firstticstosend = nettics[i]; - - // Don't erase tics not acknowledged - counts = realtics; + if (maketic + counts >= nettics[i] + (TICQUEUE - TICRATE)) + Net_ConnectionTimeout(i); + } for (i = 0; i < MAXNETNODES; ++i) if (resynch_inprogress[i]) diff --git a/src/d_clisrv.h b/src/d_clisrv.h index fd3fcca0e..65884362b 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -108,12 +108,11 @@ typedef enum PT_PING, // Packet sent to tell clients the other client's latency to server. -#ifdef SATURNSYNCH +#ifdef SATURNPAK PT_WILLRESENDGAMESTATE, // Hey Client, I am about to resend you the gamestate! PT_CANRECEIVEGAMESTATE, // Okay Server, I'm ready to receive it, you can go ahead. PT_RECEIVEDGAMESTATE, // Thank you Server, I am ready to play again! - // we will reserve this for now even if unused, so order wont get mangled PT_ISSATURN, // Saturn specific identifier packet #endif @@ -394,6 +393,7 @@ typedef struct #define MAXSERVERNAME 32 #define MAXFILENEEDED 915 #define MAX_MIRROR_LENGTH 256 + // This packet is too large typedef struct { @@ -588,7 +588,7 @@ extern tic_t servermaxping; extern boolean server_lagless; extern tic_t simulated_lag; extern tic_t lowest_lag; -extern consvar_t cv_mindelay, cv_lagless; +extern consvar_t cv_mindelay, cv_gentlemens; extern consvar_t #ifdef VANILLAJOINNEXTROUND @@ -599,7 +599,7 @@ extern consvar_t cv_allownewsaturnplayer, #endif cv_joinrefusemessage, cv_maxplayers, cv_resynchattempts, -#ifdef SATURNSYNCH +#ifdef SATURNPAK cv_resynchcooldown, cv_gamestateattempts, #endif cv_blamecfail, cv_maxsend, cv_noticedownload, cv_downloadspeed; @@ -616,6 +616,7 @@ void D_ClientServerInit(void); void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum)); void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam); #define SendNetXCmd(id, param, nparam) SendNetXCmdForPlayer(0, id, param, nparam) // Shortcut for P1 +void SendKick(UINT8 playernum, UINT8 msg); // Create any new ticcmds and broadcast to other players. void NetKeepAlive(void); @@ -666,7 +667,7 @@ tic_t GetLag(INT32 node); //UINT8 GetFreeXCmdSize(UINT8 playerid); extern UINT8 hu_resynching; -#ifdef SATURNSYNCH +#ifdef SATURNPAK extern UINT8 hu_redownloadinggamestate; #endif extern boolean hu_stopped; // kart, true when the game is stopped for players due to a disconnecting or connecting player diff --git a/src/d_main.c b/src/d_main.c index fb7a98a6e..ad65138e8 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -641,6 +641,8 @@ static boolean D_Display(void) } } + NetUpdate(); // send out any new accumulation + // It's safe to end the game now. if (G_GetExitGameFlag()) { @@ -823,7 +825,7 @@ void D_SRB2Loop(void) if (interp) { - renderdeltatics = FLOAT_TO_FIXED(deltatics); + renderdeltatics = FloatToFixed(deltatics); if (!(paused || P_AutoPause()) && deltatics < 1.0 && !hu_stopped) { @@ -867,7 +869,7 @@ void D_SRB2Loop(void) LUA_Step(); #ifdef HAVE_DISCORDRPC - if (!dedicated) + if (!dedicated && renderisnewtic) { Discord_RunCallbacks(); } @@ -927,6 +929,7 @@ void D_SRB2Loop(void) void D_StartTitle(void) { INT32 i; + if (netgame) { if (gametype == GT_RACE) // SRB2kart @@ -1060,18 +1063,21 @@ static void D_AutoloadFile(const char *file, char **filearray) COM_BufAddText(va("exec %s\n", newfile)); } -static char *strremove(char *str, const char *sub) { - char *p, *q, *r; - if (*sub && (q = r = strstr(str, sub)) != NULL) { - size_t len = strlen(sub); - while ((r = strstr(p = r + len, sub)) != NULL) { - while (p < r) - *q++ = *p++; - } - while ((*q++ = *p++) != '\0') - continue; - } - return str; +static char *strremove(char *str, const char *sub) +{ + char *p, *q, *r; + if (*sub && (q = r = strstr(str, sub)) != NULL) + { + size_t len = strlen(sub); + while ((r = strstr(p = r + len, sub)) != NULL) + { + while (p < r) + *q++ = *p++; + } + while ((*q++ = *p++) != '\0') + continue; + } + return str; } // FIND THEM @@ -1179,47 +1185,48 @@ void D_CleanFile(char **filearray) static boolean AddIWAD(void) { - char * path = va(pandf,srb2path,"srb2.srb"); + char * path = va(pandf, srb2path, "srb2.srb"); if (FIL_ReadFileOK(path)) { D_AddFile(path, startupwadfiles); return true; } - else - { - return false; - } + + return false; } // extra graphic patches for saturn specific thingies -boolean found_extra_kart; -boolean found_extra2_kart; -boolean found_extra3_kart; +boolean found_extra_kart = false; +boolean found_extra2_kart = false; +boolean found_extra3_kart = false; -boolean xtra_speedo; // extra speedometer check -boolean xtra_speedo_clr; // extra speedometer colour check -boolean xtra_speedo3; // 80x 11 extra speedometer check -boolean xtra_speedo_clr3; // 80x 11 extra speedometer colour check -boolean achi_speedo; // achiiro speedometer check -boolean achi_speedo_clr; // extra speedometer colour check -boolean kartz_speedo; // kartZ speedo +boolean xtra_speedo = false; // extra speedometer check +boolean xtra_speedo_clr = false; // extra speedometer colour check +boolean xtra_speedo3 = false; // 80x 11 extra speedometer check +boolean xtra_speedo_clr3 = false; // 80x 11 extra speedometer colour check +boolean achi_speedo = false; // achiiro speedometer check +boolean achi_speedo_clr = false; // extra speedometer colour check +boolean dial_speedo = false; // dial speedometer check +boolean dial_speedo_clr = false; // dial speedometer colour check +boolean kartz_speedo = false; // kartZ speedo +boolean kartz_speedo_smol = false; // kartZ speedo but smol -boolean clr_hud; // colour hud check -boolean big_lap; // bigger lap counter -boolean big_lap_color; // bigger lap counter but colour -boolean statdp; // stat display for extended player setup -boolean nametaggfx; // Nametag stuffs -boolean driftgaugegfx; // Driftgauge stuffs -boolean multiitem_icon; // Extra icons for Sneakers, Banana and Jawz +boolean clr_hud = false; // colour hud check +boolean driftgaugegfx_clr = false; // driftgauge colour check +boolean big_lap = false; // bigger lap counter +boolean big_lap_color = false; // bigger lap counter but colour +boolean statdp = false; // stat display for extended player setup +boolean nametaggfx = false; // Nametag stuffs +boolean driftgaugegfx = false; // Driftgauge stuffs +boolean multiitem_icon = false; // Extra icons for Sneakers, Banana and Jawz +boolean joystickicon = false; // Extra icons for the joystick input display +boolean minidoticon = false; // Dot graphic for minimap player angle display // static void IdentifyVersion(void) { const char *srb2waddir = NULL; - found_extra_kart = false; - found_extra2_kart = false; - found_extra3_kart = false; #if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) // change to the directory where 'srb2.srb' is found @@ -1229,11 +1236,11 @@ static void IdentifyVersion(void) // get the current directory (possible problem on NT with "." as current dir) if (srb2waddir) { - strlcpy(srb2path,srb2waddir,sizeof (srb2path)); + strlcpy(srb2path, srb2waddir, sizeof(srb2path)); } else { - if (getcwd(srb2path, 256) != NULL) + if (getcwd(srb2path, sizeof(srb2path))) srb2waddir = srb2path; else { @@ -1242,7 +1249,7 @@ static void IdentifyVersion(void) } // Load the IWAD - if (! AddIWAD()) + if (!AddIWAD()) { I_Error("SRB2.SRB not found! Expected in %s\n", srb2waddir); } @@ -1267,18 +1274,21 @@ static void IdentifyVersion(void) D_AddFile(va(pandf,srb2waddir,"patch.kart"), startupwadfiles); #endif // completely optional - if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra.kart"))) { + if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra.kart"))) + { D_AddFile(va(pandf,srb2waddir,"extra.kart"), startupwadfiles); found_extra_kart = true; } // completely optional 2: Back with a vengence - if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra2.kart"))) { + if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra2.kart"))) + { D_AddFile(va(pandf,srb2waddir,"extra2.kart"), startupwadfiles); found_extra2_kart = true; } - if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra3.kart"))) { + if (FIL_ReadFileOK(va(pandf,srb2waddir,"extra3.kart"))) + { D_AddFile(va(pandf,srb2waddir,"extra3.kart"), startupwadfiles); found_extra3_kart = true; } @@ -1326,6 +1336,187 @@ static inline void D_MakeTitleString(char *s) strcpy(s, temp); } +static void D_CheckSaturnExtraFiles(void) +{ + // Possible value that changes depending on whether required files for speedometer are found or not + CV_PossibleValue_t speedo_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; + CV_PossibleValue_t driftgaugestyle_cons_temp[NUMDGAUGESTUFF] = {{1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}, {0, NULL}}; + CV_PossibleValue_t inputdisplay_cons_temp[NUMINPUTDISPLAYSTUFF] = {{0, "Off"}, {1, "Wheel"}, {2, "Stick"}, {0, NULL}, {0, NULL}}; + + unsigned last_speedo_i = 0; + unsigned last_driftgauge_i = 3; + unsigned last_inputdisplay_i = 2; +#define PUSHCONS(cons, i, id, name) { ++i; cons[i].value = id; cons[i].strvalue = name; } + + // found the funny, add it in! + if (found_extra_kart) + { + mainwads++; + + // now check for extra speedometer stuff + if (W_CheckMultipleLumps("SP_SMSTC", "K_TRNULL", "SP_MKMH", "SP_MMPH", "SP_MFRAC", "SP_MPERC", NULL)) + { + xtra_speedo = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 2, "Small"); + } + + // now check for achii speedometer stuff + if (W_CheckMultipleLumps("SP_AMSTC", "K_TRNULL", "SP_AKMH", "SP_AMPH", "SP_AFRAC", "SP_APERC", NULL)) + { + achi_speedo = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 3, "Achii"); + } + + // now check for dial speedometer stuff + if (W_CheckMultipleLumps("K_DSPBS1", "K_DSPBS2", "K_DSDIAL", + "K_TRNULL", "SP_DKMH", "SP_DMPH", "SP_DFRAC", "SP_DPERC", + "K_DSPNM0", "K_DSPNM1", "K_DSPNM2", "K_DSPNM3", "K_DSPNM4", + "K_DSPNM5", "K_DSPNM6", "K_DSPNM7", "K_DSPNM8", "K_DSPNM9", + "RANKFIN", NULL)) + { + dial_speedo = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 4, "Dial"); + } + + // check for bigger lap count + if (W_CheckMultipleLumps("K_STLAPB", "K_STLA2B", NULL)) + { + big_lap = true; + } + + // kartzspeedo + if (W_CheckMultipleLumps("K_KZSP1", "K_KZSP2", "K_KZSP3", "K_KZSP4", "K_KZSP5", + "K_KZSP6", "K_KZSP7", "K_KZSP8", "K_KZSP9", "K_KZSP10", "K_KZSP11", "K_KZSP12", + "K_KZSP13", "K_KZSP14", "K_KZSP15", "K_KZSP16", "K_KZSP17", "K_KZSP18", "K_KZSP19", + "K_KZSP20", "K_KZSP21", "K_KZSP22", "K_KZSP23", "K_KZSP24", "K_KZSP25", NULL)) + { + kartz_speedo = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 5, "P-Meter"); + } + + if (W_CheckMultipleLumps("K_KZSS1", "K_KZSS2", "K_KZSS3", "K_KZSS4", "K_KZSS5", + "K_KZSS6", "K_KZSS7", "K_KZSS8", "K_KZSS9", "K_KZSS10", "K_KZSS11", "K_KZSS12", + "K_KZSS13", "K_KZSS14", "K_KZSS15", "K_KZSS16", "K_KZSS17", "K_KZSS18", "K_KZSS19", + "K_KZSS20", "K_KZSS21", "K_KZSS22", "K_KZSS23", "K_KZSS24", "K_KZSS25", NULL)) + { + kartz_speedo_smol = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 6, "P-Meter Small"); + } + + // stat display for extended player setup + if (W_CheckMultipleLumps("K_STATNB", "K_STATN1", "K_STATN2", + "K_STATN3", "K_STATN4", "K_STATN5", "K_STATN6", NULL)) + { + statdp = true; + } + + // Nametag stuffs + if (W_CheckMultipleLumps("NTLINE", "NTLINEV", "NTSP", "NTWH", NULL)) + { + nametaggfx = true; + } + + // driftgauge + if (W_CheckMultipleLumps("K_DGAU","K_DGSU", NULL)) + { + driftgaugegfx = true; + } + + // extra item icons + if (W_CheckMultipleLumps("K_ITSHO2", "K_ITSHO3", "K_ITBAN2", "K_ITBAN3", "K_ITBAN4", "K_ITJAW2", NULL)) + { + multiitem_icon = true; + } + + // extra round joystick inputdisplay sprites + if (W_CheckMultipleLumps("JOYBCK","JOYKNB","JOYSHD", NULL)) + { + joystickicon = true; + PUSHCONS(inputdisplay_cons_temp, last_inputdisplay_i, 3, "StickGFX"); + } + + if (W_LumpExists("MMAPDOT")) + { + minidoticon = true; + } + } + + // now check for colour hud stuff + if (found_extra2_kart) + { + mainwads++; + + // kart vanilla hud patches but colourizable + if (W_CheckMultipleLumps("K_SCTIME", "K_SCTIMW", "K_SCLAPS", "K_SCLAPW","K_SCBALN", "K_SCBALW", + "K_SCKARM", "K_SCTOUT", "K_ISMULC", "K_ITMULC", "K_ITBC", "K_ITBCD", "K_ISBC", "K_ISBCD", NULL)) + { + clr_hud = true; + } + + // extra speedo but colour + if (W_LumpExists("SC_SMSTC")) + { + xtra_speedo_clr = true; + } + + // achii speedo but colour + if (W_CheckMultipleLumps("SC_AMSTC", "K_TRNULL", "SC_AKMH", "SC_AMPH", "SC_AFRAC", "SC_APERC", NULL)) + { + achi_speedo_clr = true; + } + + // dial speedo but colour + if (W_CheckMultipleLumps("K_DSPBC1", "K_DSPBC2", "K_DSDIAL", + "K_TRNULL", "SC_DKMH", "SC_DMPH", "SC_DFRAC", "SC_DPERC", + "K_DSPNC0", "K_DSPNC1", "K_DSPNC2", "K_DSPNC3", "K_DSPNC4", + "K_DSPNC5", "K_DSPNC6", "K_DSPNC7", "K_DSPNC8", "K_DSPNC9", + "RANKFIN", NULL)) + { + dial_speedo_clr = true; + } + + // driftgauge but colour + if (W_CheckMultipleLumps("K_DCAU","K_DCSU", NULL)) + { + driftgaugegfx_clr = true; + } + + // check for bigger lap count but color** its color bitch + if (W_CheckMultipleLumps("K_SCLAPB", "K_SCLA2B", NULL)) + { + big_lap_color = true; + } + } + + // can be used for custom hud stuff + // currently used for the v1 beta hud + if (found_extra3_kart) + { + mainwads++; + + // 80x11 speedometer crap + if (W_LumpExists("SP_SM3TC")) + { + xtra_speedo3 = true; + PUSHCONS(speedo_cons_temp, last_speedo_i, 7, "Extra"); + PUSHCONS(driftgaugestyle_cons_temp, last_driftgauge_i, 5, "Extra"); + } + + // 80x11 speedometer crap but colour + if (W_LumpExists("SC_SM3TC")) + { + xtra_speedo_clr3 = true; + } + } + +#undef PUSHCONS + memcpy(speedo_cons_t, speedo_cons_temp, sizeof(speedo_cons_t)); + memcpy(driftgaugestyle_cons_t, driftgaugestyle_cons_temp, sizeof(driftgaugestyle_cons_t)); + memcpy(inputdisplay_cons_t, inputdisplay_cons_temp, sizeof(inputdisplay_cons_t)); +} + +#include + // // D_SRB2Main // @@ -1523,6 +1714,7 @@ void D_SRB2Main(void) CONS_Printf("I_InitializeTime()...\n"); I_InitializeTime(); + setlocale(LC_TIME, ""); // Make backups of some SOCcable tables. P_BackupTables(); @@ -1574,100 +1766,7 @@ void D_SRB2Main(void) #endif //ifndef DEVELOP - // Possible value that changes depending on whether required files for speedometer are found or not - CV_PossibleValue_t speedo_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}, {0, NULL}}; - CV_PossibleValue_t driftgaugestyle_cons_temp[NUMSPEEDOSTUFF] = {{1, "Default"}, {2, "Small"}, {3, "Big Numbers"}, {4, "Numbers Only"}, {0, NULL}, {0, NULL}}; // ugh i dont want this but bleh - unsigned last_speedo_i = 0; - unsigned last_driftgauge_i = 0; -#define PUSHCONS(cons, i, id, name) { ++i; cons[i].value = id; cons[i].strvalue = name; } - - if (found_extra_kart || found_extra2_kart || found_extra3_kart) // found the funny, add it in! - { - // HAYA: These are seperated for a reason lmao - if (found_extra_kart) - mainwads++; - if (found_extra2_kart) - mainwads++; - if (found_extra3_kart) - mainwads++; - - // now check for extra speedometer stuff - if (W_CheckMultipleLumps("SP_SMSTC", "K_TRNULL", "SP_MKMH", "SP_MMPH", "SP_MFRAC", "SP_MPERC", NULL)) - { - xtra_speedo = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 2, "Small"); - } - - if (W_LumpExists("SC_SMSTC")) - xtra_speedo_clr = true; - - // now check for achii speedometer stuff - if (W_CheckMultipleLumps("SP_AMSTC", "K_TRNULL", "SP_AKMH", "SP_AMPH", "SP_AFRAC", "SP_APERC", NULL)) - { - achi_speedo = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 3, "Achii"); - } - - if (W_CheckMultipleLumps("SC_AMSTC", "K_TRNULL", "SC_AKMH", "SC_AMPH", "SC_AFRAC", "SC_APERC", NULL)) - achi_speedo_clr = true; - - // check for bigger lap count - if (W_CheckMultipleLumps("K_STLAPB", "K_STLA2B", NULL)) - big_lap = true; - - // now check for colour hud stuff - if (W_CheckMultipleLumps("K_SCTIME", "K_SCTIMW", "K_SCLAPS", "K_SCLAPW", \ - "K_SCBALN", "K_SCBALW", "K_SCKARM", "K_SCTOUT", "K_ISMULC", "K_ITMULC", "K_ITBC", "K_ITBCD", "K_ISBC", "K_ISBCD", NULL)) - clr_hud = true; - - // check for bigger lap count but color** its color bitch - if (W_CheckMultipleLumps("K_SCLAPB", "K_SCLA2B", NULL)) - big_lap_color = true; - - // kartzspeedo - if (W_CheckMultipleLumps("K_KZSP1", "K_KZSP2", "K_KZSP3", "K_KZSP4", "K_KZSP5", \ - "K_KZSP6", "K_KZSP7", "K_KZSP8", "K_KZSP9", "K_KZSP10", "K_KZSP11", "K_KZSP12", \ - "K_KZSP13", "K_KZSP14", "K_KZSP15", "K_KZSP16", "K_KZSP17", "K_KZSP18", "K_KZSP19", \ - "K_KZSP20", "K_KZSP21", "K_KZSP22", "K_KZSP23", "K_KZSP24", "K_KZSP25", NULL)) - { - kartz_speedo = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 4, "P-Meter"); - } - - // stat display for extended player setup - if (W_CheckMultipleLumps("K_STATNB", "K_STATN1", "K_STATN2", "K_STATN3", "K_STATN4", \ - "K_STATN5", "K_STATN6", NULL)) - statdp = true; - - // Nametag stuffs - if (W_CheckMultipleLumps("NTLINE", "NTLINEV", "NTSP", "NTWH", NULL)) - nametaggfx = true; - - if (W_CheckMultipleLumps("K_DGAU","K_DCAU","K_DGSU","K_DCSU", NULL)) - driftgaugegfx = true; - - // extra item icons - if (W_CheckMultipleLumps("K_ITSHO2", "K_ITSHO3", "K_ITBAN2", "K_ITBAN3", "K_ITBAN4", "K_ITJAW2", NULL)) - multiitem_icon = true; - - if (found_extra3_kart) - { - // 80x11 speedometer crap - if (W_LumpExists("SP_SM3TC")) - { - xtra_speedo3 = true; - PUSHCONS(speedo_cons_temp, last_speedo_i, 5, "Extra"); - PUSHCONS(driftgaugestyle_cons_temp, last_driftgauge_i, 5, "Extra"); - } - - if (W_LumpExists("SC_SM3TC")) - xtra_speedo_clr3 = true; - } - } - -#undef PUSHCONS - memcpy(speedo_cons_t, speedo_cons_temp, sizeof(speedo_cons_t)); - memcpy(driftgaugestyle_cons_t, driftgaugestyle_cons_temp, sizeof(driftgaugestyle_cons_t)); + D_CheckSaturnExtraFiles(); // check all the saturn stuff :3 // Do it before P_InitMapData because PNG patch // conversion sometimes needs the palette diff --git a/src/d_main.h b/src/d_main.h index d5b5189eb..f8e5b0b41 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -17,9 +17,9 @@ #include "d_event.h" #include "w_wad.h" // for MAX_WADFILES -// make sure not to write back the config until it's been correctly loaded extern tic_t rendergametic; +// make sure not to write back the config until it's been correctly loaded extern boolean loaded_config; extern char srb2home[256]; //Alam: My Home @@ -38,15 +38,21 @@ extern boolean xtra_speedo3; // 80x11 extra speedometer check extern boolean xtra_speedo_clr3; // 80x11 extra speedometer colour check extern boolean achi_speedo; // achiiro speedometer check extern boolean achi_speedo_clr; // extra speedometer colour check -extern boolean kartz_speedo; // kartZ speedo +extern boolean dial_speedo; // dial speedometer check +extern boolean dial_speedo_clr; // dial speedometer colour check +extern boolean kartz_speedo; // kartZ speedo +extern boolean kartz_speedo_smol; // kartZ speedo but smol extern boolean clr_hud; // colour hud check +extern boolean driftgaugegfx_clr; // driftgauge colour check extern boolean big_lap; // bigger lap counter extern boolean big_lap_color; // bigger lap counter but colour extern boolean statdp; // stat display for extended player setup extern boolean nametaggfx; // Nametag stuffs extern boolean driftgaugegfx; // Driftgauge stuffs extern boolean multiitem_icon; // Extra icons for Sneakers, Banana and Jawz +extern boolean joystickicon; // Extra icons for the joystick input display +extern boolean minidoticon; // Dot icon for minimap player angle display // // autoload stuff diff --git a/src/d_net.c b/src/d_net.c index 820da034a..8a33bde55 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -220,7 +220,7 @@ FUNCMATH static INT32 cmpack(UINT8 a, UINT8 b) * \param lowtimer ??? * \return True if a free acknum was found */ -static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer) +static boolean GetFreeAcknum(UINT8 *freeack) { node_t *node = &nodes[doomcom->remotenode]; INT32 i, numfreeslot = 0; @@ -249,17 +249,8 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer) node->nextacknum++; ackpak[i].destinationnode = (UINT8)(node - nodes); ackpak[i].length = doomcom->datalength; - if (lowtimer) - { - // Lowtime means can't be sent now so try it as soon as possible - ackpak[i].senttime = 0; - ackpak[i].resentnum = 1; - } - else - { - ackpak[i].senttime = I_GetTime(); - ackpak[i].resentnum = 0; - } + ackpak[i].senttime = I_GetTime(); + ackpak[i].resentnum = 0; M_Memcpy(ackpak[i].pak.raw, netbuffer, ackpak[i].length); *freeack = ackpak[i].acknum; @@ -268,6 +259,7 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer) return true; } + #ifdef PARANOIA CONS_Debug(DBG_NETPLAY, "No more free ackpacket\n"); #endif @@ -276,38 +268,6 @@ static boolean GetFreeAcknum(UINT8 *freeack, boolean lowtimer) return false; } -/** Counts how many acks are free - * - * \param urgent True if the type of the packet meant to - * use an ack is lower than PT_CANFAIL - * If for some reason you don't want use it - * for any packet type in particular, - * just set to false - * \return The number of free acks - * - */ -INT32 Net_GetFreeAcks(boolean urgent) -{ - INT32 i, numfreeslot = 0; - INT32 n = 0; // Number of free acks found - - for (i = 0; i < MAXACKPACKETS; i++) - if (!ackpak[i].acknum) - { - // For low priority packets, make sure to let freeslots so urgent packets can be sent - if (!urgent) - { - numfreeslot++; - if (numfreeslot <= URGENTFREESLOTNUM) - continue; - } - - n++; - } - - return n; -} - // Get a ack to send in the queue of this node static UINT8 GetAcktosend(INT32 node) { @@ -832,15 +792,14 @@ const char *packettypename[NUMPACKETTYPE] = "MOREFILESNEEDED", "PING" -#ifdef SATURNSYNCH +#ifdef SATURNPAK , "WILLRESENDGAMESTATE", "CANRECEIVEGAMESTATE", "RECEIVEDGAMESTATE", - // we will reserve this for now even if unused, so order wont get mangled - "ISSATURN" + "ISSATURN" // special packet to identify saturn clients #endif }; @@ -1084,9 +1043,10 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen netbuffer->ackreturn = GetAcktosend(node); else netbuffer->ackreturn = 0; + if (reliable) { - if (!GetFreeAcknum(&netbuffer->ack, false)) + if (!GetFreeAcknum(&netbuffer->ack)) return false; } else @@ -1158,7 +1118,6 @@ boolean HGetPacket(void) while(true) { - //nodejustjoined = I_NetGet(); I_NetGet(); if (doomcom->remotenode == -1) // No packet received @@ -1187,21 +1146,6 @@ boolean HGetPacket(void) DebugPrintpacket("GET"); #endif - /*// If a new node sends an unexpected packet, just ignore it - if (nodejustjoined && server - && !(netbuffer->packettype == PT_ASKINFO - || netbuffer->packettype == PT_SERVERINFO - || netbuffer->packettype == PT_PLAYERINFO - || netbuffer->packettype == PT_REQUESTFILE - || netbuffer->packettype == PT_ASKINFOVIAMS - || netbuffer->packettype == PT_CLIENTJOIN)) - { - DEBFILE(va("New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype])); - //CONS_Alert(CONS_NOTICE, "New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype]); - Net_CloseConnection(doomcom->remotenode | FORCECLOSE); - continue; - }*/ - // Proceed the ack and ackreturn field if (!Processackpak()) continue; // discarded (duplicated) diff --git a/src/d_net.h b/src/d_net.h index 471881847..1b6cd905c 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -45,12 +45,10 @@ extern boolean nodeingame[MAXNETNODES]; // Set false as nodes leave game extern boolean serverrunning; -INT32 Net_GetFreeAcks(boolean urgent); void Net_AckTicker(void); // If reliable return true if packet sent, 0 else -boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, - size_t packetlength); +boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlength); boolean HGetPacket(void); void D_SetDoomcom(void); #ifndef NONET diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b2013dc74..37fec1869 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -290,15 +290,27 @@ consvar_t cv_skipmapcheck = {"skipmapcheck", "Off", CV_SAVE, CV_OnOff, NULL, 0, INT32 cv_debug; -consvar_t cv_usemouse = {"use_mouse", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse, 0, NULL, NULL, 0, 0, NULL}; +static void UseMouse_OnChange(void); +consvar_t cv_usemouse = {"use_mouse", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, UseMouse_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +static void UseMouse_OnChange(void) +{ + GameFocus_menu_Onchange(); + I_StartupMouse(); +} //WTF consvar_t cv_mouseturn = {"mouseturn", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Lagless camera! Yay! -consvar_t cv_laglesscam = {"laglesscamera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_laglesscam = {"lagless_camera", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_verticallook = {"verticallook", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_verticallook[MAXSPLITSCREENPLAYERS] = { + {"verticallook", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"verticallook2", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"verticallook3", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"verticallook4", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} +}; #if defined(HAVE_SDL) || defined(_WINDOWS) //joystick 1 and 2 consvar_t cv_usejoystick[MAXSPLITSCREENPLAYERS] = { @@ -652,7 +664,6 @@ void D_RegisterServerCommands(void) COM_AddCommand("addfilelocal", Command_Addfilelocal); COM_AddCommand("addfile", Command_Addfile); COM_AddCommand("addskins", Command_Addskins); - COM_AddCommand("localskin", Command_GLocalSkin); COM_AddCommand("listwad", Command_ListWADS_f); COM_AddCommand("listmapthings", Command_ListDoomednums_f); COM_AddCommand("listunusedsprites", Command_ListUnusedSprites_f); @@ -717,7 +728,7 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_competitionboxes); CV_RegisterVar(&cv_matchboxes); - K_RegisterKartStuff(); // SRB2kart + K_RegisterServerKartStuff(); // SRB2kart CV_RegisterVar(&cv_ringslinger); @@ -743,7 +754,7 @@ void D_RegisterServerCommands(void) // d_clisrv CV_RegisterVar(&cv_maxplayers); CV_RegisterVar(&cv_resynchattempts); -#ifdef SATURNSYNCH +#ifdef SATURNPAK CV_RegisterVar(&cv_gamestateattempts); CV_RegisterVar(&cv_resynchcooldown); #endif @@ -795,8 +806,6 @@ void D_RegisterServerCommands(void) CV_RegisterVar(&cv_netdemosyncquality); CV_RegisterVar(&cv_maxdemosize); CV_RegisterVar(&cv_demochangemap); - - CV_RegisterVar(&cv_keyboardlayout); } // ========================================================================= @@ -855,6 +864,10 @@ void D_RegisterClientCommands(void) COM_AddCommand("stopmovie", Command_StopMovie_f); COM_AddCommand("minigen", M_MinimapGenerate); + COM_AddCommand("localskin", Command_GLocalSkin); + + K_RegisterClientKartStuff(); // SRB2kart + CV_RegisterVar(&cv_screenshot_option); CV_RegisterVar(&cv_screenshot_folder); CV_RegisterVar(&cv_moviemode); @@ -905,11 +918,13 @@ void D_RegisterClientCommands(void) #ifdef SEENAMES CV_RegisterVar(&cv_seenames); #endif + CV_RegisterVar(&cv_rollingdemos); + CV_RegisterVar(&cv_netstat); CV_RegisterVar(&cv_netticbuffer); CV_RegisterVar(&cv_mindelay); - CV_RegisterVar(&cv_lagless); + CV_RegisterVar(&cv_gentlemens); #ifdef NETGAME_DEVMODE CV_RegisterVar(&cv_fishcake); @@ -924,6 +939,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_cechotoggle); + CV_RegisterVar(&cv_keyboardlayout); + // time attack ghost options are also saved to config CV_RegisterVar(&cv_ghost_besttime); CV_RegisterVar(&cv_ghost_bestlap); @@ -933,7 +950,7 @@ void D_RegisterClientCommands(void) COM_AddCommand("displayplayer", Command_Displayplayer_f); - CV_RegisterVar(&cv_audbuffersize); + CV_RegisterVar(&cv_audbuffersize); // m_menu.c CV_RegisterVar(&cv_chatheight); @@ -944,10 +961,10 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_chatnotifications); CV_RegisterVar(&cv_chatbacktint); CV_RegisterVar(&cv_songcredits); - CV_RegisterVar(&cv_showfreeplay); + CV_RegisterVar(&cv_showfreeplay); CV_RegisterVar(&cv_skinselectspin); CV_RegisterVar(&cv_showallmaps); - + CV_RegisterVar(&cv_growmusic); CV_RegisterVar(&cv_supermusic); @@ -1033,7 +1050,7 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_midimusicvolume); #endif CV_RegisterVar(&cv_numChannels); - + #ifdef HAVE_OPENMPT CV_RegisterVar(&cv_modfilter); CV_RegisterVar(&cv_stereosep); @@ -1048,7 +1065,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_renderview); CV_RegisterVar(&cv_vhseffect); CV_RegisterVar(&cv_shittyscreen); - CV_RegisterVar(&cv_scr_depth); CV_RegisterVar(&cv_scr_width); CV_RegisterVar(&cv_scr_height); @@ -1068,7 +1084,12 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_laglesscam); - CV_RegisterVar(&cv_verticallook); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + CV_RegisterVar(&cv_verticallook[i]); + } + + CV_RegisterVar(&cv_demodateformat); // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); @@ -1415,11 +1436,7 @@ static void SetPlayerName(INT32 playernum, char *newname) CONS_Printf(M_GetText("Player %d sent a bad name change\n"), playernum+1); if (server && netgame) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } } } @@ -2013,12 +2030,8 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum) if (kick) { - UINT8 buf[2]; CONS_Alert(CONS_WARNING, M_GetText("Illegal color change received from %s (team: %d), color: %d)\n"), player_names[playernum], p->ctfteam, p->skincolor); - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); return; } } @@ -2899,11 +2912,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal map change received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -3018,11 +3027,7 @@ static void Got_Pause(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal pause command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -3067,18 +3072,25 @@ static void Command_ReplayMarker(void) CONS_Printf(M_GetText("You must be in a level to use this.\n")); return; } - if (demo.savemode == DSM_WILLAUTOSAVE) { + if (demo.savemode == DSM_WILLAUTOSAVE) + { demo.savemode = DSM_NOTSAVING; CONS_Printf("Replay unmarked.\n"); - } else { - int adjustedleveltime = leveltime - starttime; + } + else + { demo.savemode = DSM_WILLAUTOSAVE; + + int adjustedleveltime = leveltime - starttime; + if (adjustedleveltime < 0) adjustedleveltime = 0; + char *title = G_BuildMapTitle(gamemap); snprintf(demo.titlename, 64, "%s [%i:%02d/%.5s]", title, G_TicsToMinutes(adjustedleveltime, false), G_TicsToSeconds(adjustedleveltime), modeattacking ? "Record Attack" : connectedservername); if (title) Z_Free(title); + CONS_Printf("Replay will be saved!\n"); } } @@ -3136,11 +3148,7 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal respawn command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -3210,11 +3218,7 @@ static void Got_Clearscores(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal clear scores command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -3733,11 +3737,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } } @@ -3748,11 +3748,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -3786,11 +3782,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } } return; @@ -3839,12 +3831,8 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) if (server && ((NetPacket.packet.newteam < 0 || NetPacket.packet.newteam > 3) || error)) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; CONS_Alert(CONS_WARNING, M_GetText("Illegal team change received from player %s\n"), player_names[playernum]); - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } //Safety first! @@ -4213,11 +4201,7 @@ static void Got_Verification(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal verification received from %s (serverplayer is %s)\n"), player_names[playernum], player_names[serverplayer]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -4269,11 +4253,7 @@ static void Got_Removal(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal demotion received from %s (serverplayer is %s)\n"), player_names[playernum], player_names[serverplayer]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -4349,11 +4329,7 @@ static void Got_MotD_f(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal motd change received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } Z_Free(mymotd); @@ -4412,11 +4388,7 @@ static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal runsoc command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -4578,7 +4550,7 @@ Command_Addskins (void) /* if (fasticmp(COM_Argv(2), "-force") || fasticmp(COM_Argv(2), "-f")) { CONS_Alert(CONS_NOTICE, M_GetText("Adding file %s. May or may not be a skin.\n"), COM_Argv(1)); - P_AddWadFile(COM_Argv(1), 0, true); + P_AddWadFile(COM_Argv(1), 0, true); } else { if (DumbStartsWith("KC_", COM_Argv(1))) { P_AddWadFile(COM_Argv(1), 0, true); @@ -4658,7 +4630,7 @@ static void Command_GLocalSkin (void) { int i; - for (i = 0; i < MAXPLAYERS; ++i) + for (i = 0; i < MAXPLAYERS; ++i) { if (!playeringame[i]) continue; @@ -4725,13 +4697,8 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum) if ((playernum != serverplayer && !IsPlayerAdmin(playernum)) || kick) { - UINT8 buf[2]; - CONS_Alert(CONS_WARNING, M_GetText("Illegal addfile command received from %s\n"), player_names[playernum]); - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); return; } @@ -4780,11 +4747,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal addfile command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -5594,11 +5557,7 @@ static void Got_ExitLevelcmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal exitlevel command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -5616,11 +5575,7 @@ static void Got_SetupVotecmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal vote setup received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -5681,11 +5636,7 @@ static void Got_PickVotecmd(UINT8 **cp, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal vote setup received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -5728,6 +5679,7 @@ void Command_ExitGame_f(void) botskin = 0; cv_debug = 0; emeralds = 0; + automapactive = false; if (dirmenu) closefilemenu(true); @@ -6065,7 +6017,7 @@ static void Command_ListSkins(void) } static void Command_SkinSearch(void) -{ +{ size_t i; UINT16 s; UINT16 ic = 0; @@ -6075,7 +6027,7 @@ static void Command_SkinSearch(void) { skin_t *skininput = &skins[s]; if (strcasestr(skininput->realname,COM_Argv(i))) - { + { ic++; CONS_Printf("%d. %s%s:\x80 %s\n", ic,HU_SkinColorToConsoleColor(skininput->prefcolor),skininput->realname,skininput->name); } @@ -6320,11 +6272,7 @@ void Got_DiscordInfo(UINT8 **p, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal Discord info command received from %s\n"), player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 9e1744e00..b4ee22d93 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -149,8 +149,9 @@ extern consvar_t cv_pingstyle; //extern consvar_t cv_smallpos; extern consvar_t cv_showminimapnames; extern consvar_t cv_minihead; +extern consvar_t cv_showminimapangle; -extern consvar_t cv_showlapemblem; +extern consvar_t cv_showlapemblem; extern consvar_t cv_showviewpointtext; extern consvar_t cv_showdownloadprompt; @@ -198,8 +199,6 @@ extern consvar_t cv_betainterscreen; extern consvar_t cv_laglesscam; -extern consvar_t cv_verticallook; - typedef enum { SKINMENUTYPE_SCROLL = 0, diff --git a/src/d_netfil.c b/src/d_netfil.c index 223a74066..a71df9a71 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -64,11 +64,11 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid); #ifdef HAVE_CURL size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream); -#if defined(CURL_AT_LEAST_VERSION) && CURL_AT_LEAST_VERSION(7, 35, 0) +#if (LIBCURL_VERSION_MAJOR <= 7) && (LIBCURL_VERSION_MINOR < 35) +static int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); +#else static int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow); #define XFERINFOFUNCTION -#else -static int curlprogress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow); #endif #endif @@ -114,24 +114,14 @@ fileneeded_t fileneeded[MAX_WADFILES]; // List of needed files static I_mutex downloadmutex; char downloaddir[512] = "DOWNLOAD"; -#ifdef CLIENT_LOADINGSCREEN -// for cl loading screen -INT32 lastfilenum = -1; -INT32 downloadcompletednum = 0; -UINT32 downloadcompletedsize = 0; -INT32 totalfilesrequestednum = 0; -UINT32 totalfilesrequestedsize = 0; -#endif +file_download_t filedownload; #ifdef HAVE_CURL static CURL *http_handle; static CURLM *multi_handle; -boolean curl_running = false; -boolean curl_failedwebdownload = false; -static double curl_dlnow; -static double curl_dltotal; +static UINT32 curl_dlnow; +static UINT32 curl_dltotal; static time_t curl_starttime; -INT32 curl_transfers = 0; static int curl_runninghandles = 0; static UINT32 curl_origfilesize; static UINT32 curl_origtotalfilesize; @@ -222,6 +212,7 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi for (i = firstfile; i < fileneedednum; i++) { fileneeded[i].status = FS_NOTCHECKED; // We haven't even started looking for the file yet + fileneeded[i].justdownloaded = false; filestatus = READUINT8(p); // The first byte is the file status fileneeded[i].willsend = (UINT8)(filestatus >> 4); fileneeded[i].totalsize = READUINT32(p); // The four next bytes are the file size @@ -234,10 +225,11 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi void CL_PrepareDownloadSaveGame(const char *tmpsave) { #ifdef CLIENT_LOADINGSCREEN - lastfilenum = -1; + filedownload.current = -1; #endif fileneedednum = 1; fileneeded[0].status = FS_REQUESTED; + fileneeded[0].justdownloaded = false; fileneeded[0].totalsize = UINT32_MAX; fileneeded[0].file = NULL; memset(fileneeded[0].md5sum, 0, 16); @@ -552,13 +544,13 @@ INT32 CL_CheckFiles(void) { if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD || fileneeded[i].status == FS_FALLBACK) downloadrequired = true; - + if (fileneeded[i].status != FS_OPEN) filestoload++; if (fileneeded[i].status != FS_NOTCHECKED) //since we're running this over multiple tics now, its possible for us to come across files checked in previous tics continue; - + CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename); // Check in already loaded files @@ -662,13 +654,10 @@ static boolean SV_SendFile(INT32 node, const char *filename, UINT8 fileid) q = &((*q)->next); // Allocate a file request and append it to the file list - p = *q = (filetx_t *)malloc(sizeof (filetx_t)); + p = *q = (filetx_t *)calloc(1, sizeof(filetx_t)); // Initialise with zeros if (!p) I_Error("SV_SendFile: No more memory\n"); - // Initialise with zeros - memset(p, 0, sizeof (filetx_t)); - // Allocate the file name p->id.filename = (char *)malloc(MAX_WADPATH); if (!p->id.filename) @@ -747,13 +736,10 @@ void SV_SendRam(INT32 node, void *data, size_t size, freemethod_t freemethod, UI q = &((*q)->next); // Allocate a file request and append it to the file list - p = *q = (filetx_t *)malloc(sizeof (filetx_t)); + p = *q = (filetx_t *)calloc(1, sizeof(filetx_t)); // Initialise with zeros if (!p) I_Error("SV_SendRam: No more memory\n"); - // Initialise with zeros - memset(p, 0, sizeof (filetx_t)); - p->ram = freemethod; // Remember how to free the memory block for when we're done sending it p->id.ram = data; p->size = (UINT32)size; @@ -868,8 +854,12 @@ void SV_FileSendTicker(void) if (!transferFiles[f->fileid].file) { - I_Error("Can't open file %s: %s", + CONS_Alert(CONS_ERROR, "Can't open file %s: %s\n", f->id.filename, strerror(errno)); + + SV_EndFileSend(i); + HSendPacket(i, true, 0, PT_SERVERREFUSE); + break; } } @@ -974,7 +964,7 @@ void Got_Filetxpak(void) if (filenum >= fileneedednum) { - DEBFILE(va("fileframent not needed %d>%d\n", filenum, fileneedednum)); + DEBFILE(va("filefragment not needed %d>%d\n", filenum, fileneedednum)); //I_Error("Received an unneeded file fragment (file id received: %d, file id needed: %d)\n", filenum, fileneedednum); return; } @@ -995,6 +985,7 @@ void Got_Filetxpak(void) { UINT32 pos = LONG(netbuffer->u.filetxpak.position); UINT16 size = SHORT(netbuffer->u.filetxpak.size); + // Use a special trick to know when the file is complete (not always used) // WARNING: file fragments can arrive out of order so don't stop yet! if (pos & 0x80000000) @@ -1014,15 +1005,16 @@ void Got_Filetxpak(void) fclose(file->file); file->file = NULL; file->status = FS_FOUND; + file->justdownloaded = true; CONS_Printf(M_GetText("Downloading %s...(done)\n"), filename); #ifndef NONET - downloadcompletednum++; - downloadcompletedsize += file->totalsize; + filedownload.completednum++; + filedownload.completedsize += file->totalsize; #endif } } - else + else if (!file->justdownloaded) { const char *s; switch(file->status) @@ -1045,6 +1037,7 @@ void Got_Filetxpak(void) } I_Error("Received a file not requested (file id: %d, file status: %s)\n", filenum, s); } + // Send ack back quickly if (++filetime == 3) { @@ -1053,7 +1046,7 @@ void Got_Filetxpak(void) } #ifdef CLIENT_LOADINGSCREEN - lastfilenum = filenum; + filedownload.current = filenum; #endif } @@ -1202,9 +1195,7 @@ filestatus_t findfile(char *filename, const UINT8 *wantedmd5sum, boolean complet #ifdef HAVE_CURL size_t curlwrite_data(void *ptr, size_t size, size_t nmemb, FILE *stream) { - size_t written; - written = fwrite(ptr, size, nmemb, stream); - return written; + return fwrite(ptr, size, nmemb, stream); } #ifdef XFERINFOFUNCTION @@ -1218,12 +1209,12 @@ static int curlprogress_callbackx(void *clientp, curl_off_t dltotal, curl_off_t curtime = time(NULL); - curl_dlnow = dlnow; - curl_dltotal = dltotal; + curl_dlnow = (UINT32)dlnow; + curl_dltotal = (UINT32)dltotal; if (curtime > curl_starttime) { - getbytes = curl_dlnow / (curtime - curl_starttime); // To-do: Make this more accurate??? + getbytes = ((double)dlnow) / (curtime - curl_starttime); // To-do: Make this more accurate??? } else { @@ -1243,12 +1234,12 @@ static int curlprogress_callback(void *clientp, double dltotal, double dlnow, do curtime = time(NULL); - curl_dlnow = dlnow; - curl_dltotal = dltotal; + curl_dlnow = (UINT32)dlnow; + curl_dltotal = (UINT32)dltotal; if (curtime > curl_starttime) { - getbytes = curl_dlnow / (curtime - curl_starttime); // To-do: Make this more accurate??? + getbytes = ((double)dlnow) / (curtime - curl_starttime); // To-do: Make this more accurate??? } else { @@ -1290,10 +1281,10 @@ void CURLPrepareFile(const char* url, int dfilenum) curl_easy_setopt(http_handle, CURLOPT_URL, va("%s/%s", url, curl_realname)); // Only allow HTTP and HTTPS -#if defined(CURL_AT_LEAST_VERSION) && CURL_AT_LEAST_VERSION(7, 85, 0) - curl_easy_setopt(http_handle, CURLOPT_PROTOCOLS_STR, "http,https"); -#else +#if (LIBCURL_VERSION_MAJOR <= 7) && (LIBCURL_VERSION_MINOR < 85) curl_easy_setopt(http_handle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS); +#else + curl_easy_setopt(http_handle, CURLOPT_PROTOCOLS_STR, "http,https"); #endif curl_easy_setopt(http_handle, CURLOPT_USERAGENT, va("SRB2Kart/v%d.%d", VERSION, SUBVERSION)); // Set user agent as some servers won't accept invalid user agents. @@ -1325,23 +1316,25 @@ void CURLPrepareFile(const char* url, int dfilenum) #endif curl_curfile->status = FS_DOWNLOADING; - lastfilenum = dfilenum; curl_multi_add_handle(multi_handle, http_handle); curl_multi_perform(multi_handle, &curl_runninghandles); curl_starttime = time(NULL); - curl_running = true; + filedownload.current = dfilenum; + filedownload.http_running = true; #ifdef HAVE_THREADS I_spawn_thread("http-download", (I_thread_fn)CURLGetFile, NULL); #endif } + else + filedownload.http_running = false; } void CURLAbortFile(void) { - curl_running = false; + filedownload.http_running = false; // lock and unlock to wait for the download thread to exit I_lock_mutex(&downloadmutex); @@ -1358,10 +1351,8 @@ void CURLGetFile(void) int msgs_left; /* how many messages are left */ const char *easy_handle_error; boolean running = true; - long response_code = 0; - static char *filename; - while (running && curl_running) + while (running && filedownload.http_running) { if (curl_runninghandles) { @@ -1388,11 +1379,13 @@ void CURLGetFile(void) e = m->easy_handle; easyres = m->data.result; - filename = Z_StrDup(curl_realname); + char *filename = Z_StrDup(curl_realname); nameonly(filename); if (easyres != CURLE_OK) { + long response_code = 0; + if (easyres == CURLE_HTTP_RETURNED_ERROR) curl_easy_getinfo(e, CURLINFO_RESPONSE_CODE, &response_code); @@ -1400,7 +1393,7 @@ void CURLGetFile(void) curl_curfile->status = FS_FALLBACK; curl_curfile->currentsize = curl_origfilesize; curl_curfile->totalsize = curl_origtotalfilesize; - curl_failedwebdownload = true; + filedownload.http_failed = true; fclose(curl_curfile->file); remove(curl_curfile->filename); CONS_Printf(M_GetText("Failed to download %s (%s)\n"), filename, easy_handle_error); @@ -1413,36 +1406,37 @@ void CURLGetFile(void) { CONS_Alert(CONS_ERROR, M_GetText("HTTP Download of %s finished but is corrupt or has been modified\n"), filename); curl_curfile->status = FS_FALLBACK; - curl_failedwebdownload = true; + filedownload.http_failed = true; } else { CONS_Printf(M_GetText("Finished HTTP download of %s\n"), filename); - downloadcompletednum++; - downloadcompletedsize += curl_curfile->totalsize; + filedownload.completednum++; + filedownload.completedsize += curl_curfile->totalsize; curl_curfile->status = FS_FOUND; } } Z_Free(filename); curl_curfile->file = NULL; - curl_transfers--; + filedownload.remaining--; curl_multi_remove_handle(multi_handle, e); curl_easy_cleanup(e); - if (!curl_transfers) + if (!filedownload.remaining) break; } } } - if (!curl_transfers || !curl_running) + if (!filedownload.remaining || !filedownload.http_running) { curl_multi_cleanup(multi_handle); curl_global_cleanup(); multi_handle = NULL; } - curl_running = false; + + filedownload.http_running = false; I_unlock_mutex(downloadmutex); } diff --git a/src/d_netfil.h b/src/d_netfil.h index bd54b7661..464d885b3 100644 --- a/src/d_netfil.h +++ b/src/d_netfil.h @@ -13,6 +13,7 @@ #ifndef __D_NETFIL__ #define __D_NETFIL__ +#include "d_clisrv.h" #include "w_wad.h" typedef enum @@ -45,24 +46,35 @@ typedef struct UINT32 currentsize; UINT32 totalsize; filestatus_t status; // The value returned by recsearch + boolean justdownloaded; // To prevent late fragments from causing an I_Error } fileneeded_t; extern INT32 fileneedednum; extern fileneeded_t fileneeded[MAX_WADFILES]; extern char downloaddir[512]; +typedef struct +{ #ifdef CLIENT_LOADINGSCREEN -extern INT32 lastfilenum; -extern INT32 downloadcompletednum; -extern UINT32 downloadcompletedsize; -extern INT32 totalfilesrequestednum; -extern UINT32 totalfilesrequestedsize; + INT32 current; + INT32 completednum; + UINT32 completedsize; + INT32 totalnum; + UINT32 totalsize; #endif #ifdef HAVE_CURL -extern boolean curl_failedwebdownload; -extern boolean curl_running; -extern INT32 curl_transfers; + INT32 remaining; + boolean http_failed; + boolean http_running; + + char http_source[MAX_MIRROR_LENGTH+1]; +#endif +} file_download_t; + +extern file_download_t filedownload; + +#ifdef HAVE_CURL typedef struct HTTP_login HTTP_login; diff --git a/src/d_player.h b/src/d_player.h index 7ecef63de..a1e4a0b20 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -555,6 +555,8 @@ typedef struct player_s fixed_t spinoutrot; // When a player spins out, this value increments modulus 360. + tic_t dancetime; + fixed_t fovadd; // adjust FOV for hw rendering } player_t; diff --git a/src/dehacked.c b/src/dehacked.c index 60647b91f..fd90c380e 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -690,6 +690,20 @@ static const struct { {NULL, 0} }; +static mapheader_lighting_t *usemaplighting(INT32 mapnum, const char *word) +{ + if (fastncmp(word, "ENCORE", 6)) + { + mapheaderinfo[mapnum]->use_encore_lighting = true; + + return &mapheaderinfo[mapnum]->lighting_encore; + } + else + { + return &mapheaderinfo[mapnum]->lighting; + } +} + static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) { char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL); @@ -983,6 +997,35 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum) }*/ else if (fastcmp(word, "MOBJSCALE")) mapheaderinfo[num-1]->mobj_scale = get_number(word2); + else if (fastcmp(word, "LIGHTCONTRAST") || fastcmp(word, "ENCORELIGHTCONTRAST")) + { + mapheader_lighting_t *lighting = usemaplighting(num-1, word); + lighting->light_contrast = (UINT8)i; + lighting->use_custom_light = true; + } + else if (fastcmp(word, "SPRITEBACKLIGHT") || fastcmp(word, "ENCORESPRITEBACKLIGHT")) + { + mapheader_lighting_t *lighting = usemaplighting(num-1, word); + lighting->sprite_backlight = (SINT8)i; + lighting->use_custom_light = true; + } + else if (fastcmp(word, "LIGHTANGLE") || fastcmp(word, "ENCORELIGHTANGLE")) + { + mapheader_lighting_t *lighting = usemaplighting(num-1, word); + + if (fastcmp(word2, "EVEN")) + { + lighting->use_light_angle = false; + lighting->light_angle = 0; + } + else + { + lighting->use_light_angle = true; + lighting->light_angle = FixedAngle(FloatToFixed(atof(word2))); + } + + lighting->use_custom_light = true; + } // Individual triggers for level flags, for ease of use (and 2.0 compatibility) else if (fastcmp(word, "SCRIPTISFILE")) diff --git a/src/doomdef.h b/src/doomdef.h index d57cb53b8..382713b69 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -547,6 +547,19 @@ UINT32 quickncasehash (const char *p, size_t n) #define DBL_EPSILON 2.2204460492503131e-16l #endif +#if defined(__GNUC__) || defined(__clang__) +#ifndef LIKELY +#define LIKELY(x) __builtin_expect(!!(x), 1) +#endif + +#ifndef UNLIKELY +#define UNLIKELY(x) __builtin_expect(!!(x), 0) +#endif +#else +#define LIKELY(x) (x) +#define UNLIKELY(x) (x) +#endif + // An assert-type mechanism. #ifdef PARANOIA #define I_Assert(e) ((e) ? (void)0 : I_Error("assert failed: %s, file %s, line %d", #e, __FILE__, __LINE__)) @@ -571,21 +584,15 @@ extern const char *compdate, *comptime, *comprevision, *compbranch; #ifndef NONET //-- SATURN __ -/// Enable gamestate resynching between Saturn servers and clients -/// Like SRB2 and RR does -/// Still highly experimental -#ifdef DOSATURNSYNCH -#define SATURNSYNCH - /// Detect if a client is on Saturn in the clientconfig. /// To seperately allow them to join or block joining from vanilla clients. #ifdef DOSATURNJOIN #define SATURNJOIN #endif -#endif /// Server detection for if a connecting client is on Saturn. -/// For stuff like extra synching, etc. +/// This also enables gamestate resynching between Saturn servers and clients +/// Like SRB2 and RR does #ifdef DOSATURNPAK #define SATURNPAK #endif diff --git a/src/doomstat.h b/src/doomstat.h index 57be644b2..f6e708be6 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -222,6 +222,15 @@ typedef struct char value[256]; // 255 usable characters. If this seriously isn't enough then wtf. } customoption_t; +typedef struct +{ + boolean use_custom_light; + UINT8 light_contrast; ///< Range of wall lighting. 0 is no lighting. + SINT8 sprite_backlight; ///< Subtract from wall lighting for sprites only. + boolean use_light_angle; ///< When false, wall lighting is evenly distributed. When true, wall lighting is directional. + angle_t light_angle; ///< Angle of directional wall lighting. +} mapheader_lighting_t; + /** Map header information. */ typedef struct @@ -269,6 +278,10 @@ typedef struct //boolean automap; ///< Displays a level's white map outline in modified games fixed_t mobj_scale; ///< Replacement for TOL_ERZ3 + mapheader_lighting_t lighting; ///< Wall and sprite lighting + mapheader_lighting_t lighting_encore; ///< Alternative lighting for Encore mode + boolean use_encore_lighting; ///< Whether to use separate Encore lighting + // Music stuff. UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds char musintername[7]; ///< Intermission screen music. @@ -461,6 +474,14 @@ extern tic_t racecountdown, exitcountdown; extern fixed_t gravity; extern fixed_t mapobjectscale; +extern struct maplighting +{ + UINT8 contrast; + SINT8 backlight; + boolean directional; + angle_t angle; +} maplighting; + //for CTF balancing extern INT16 autobalance; extern INT16 teamscramble; diff --git a/src/f_finale.c b/src/f_finale.c index 18eab51eb..167985c24 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -149,7 +149,7 @@ static UINT8 F_WriteText(void) static void F_NewCutscene(const char *basetext) { cutscene_basetext = basetext; - memset(cutscene_disptext,0,sizeof(cutscene_disptext)); + memset(cutscene_disptext, 0, sizeof(cutscene_disptext)); cutscene_writeptr = cutscene_baseptr = 0; cutscene_textspeed = 9; cutscene_textcount = TICRATE/2; @@ -534,8 +534,15 @@ static const char *credits[] = { "\"Sunflower\" aka \"AnimeSonic\"", "\"Yuz\" aka \"Yuzler\"", "\"Democrab\"", - "\"Expand\" aka \"Maver\"", + "\"EXpand\"", "\"Nexit\"", + "\"Spee\"", + "\"Jin\"", + "\"riomccloud\"", + "\"chromaticpipe\"", + "\"Achii\"", + "\"Anonimus\"", + "\"scizor300\"", "", "\1Special Thanks", "SEGA", @@ -1006,7 +1013,7 @@ void F_TitleScreenDrawer(void) else { INT32 transval = 0; - + if (finalecount <= (50+(9<<1))) transval = (finalecount - 50)>>1; @@ -1053,8 +1060,8 @@ void F_TitleScreenTicker(boolean run) return; // are demos disabled? - if (!cv_rollingdemos.value) - return; + if (!cv_rollingdemos.value || modifiedgame) // occasionally mappacks supply invalid replays which means the game crashes almost always when you idle on the titlescreen too long + return; // we check for all addons since added luas/socs and stuff like that makes them desynch like crazy so why would you even watch them? // Wait for a while (for the music to finish, preferably) // before starting demos diff --git a/src/filesrch.c b/src/filesrch.c index 8af9118ba..d55c33ae8 100644 --- a/src/filesrch.c +++ b/src/filesrch.c @@ -661,6 +661,10 @@ boolean preparefilemenu(boolean samedepth, boolean replayhut) return false; } + if (dirmenu != coredirmenu) + Z_Free(dirmenu); + dirmenu = NULL; + for (; sizecoredirmenu > 0; sizecoredirmenu--) // clear out existing items { Z_Free(coredirmenu[sizecoredirmenu-1]); diff --git a/src/g_game.c b/src/g_game.c index 0619ed065..7acda852e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -59,6 +59,10 @@ #include "discord.h" #endif +// for replay dates +#include +#include + gameaction_t gameaction; gamestate_t gamestate = GS_NULL; UINT8 ultimatemode = false; @@ -239,6 +243,8 @@ tic_t racecountdown, exitcountdown; // for racing fixed_t gravity; fixed_t mapobjectscale; +struct maplighting maplighting; + INT16 autobalance; //for CTF team balance INT16 teamscramble; //for CTF team scramble INT16 scrambleplayers[MAXPLAYERS]; //for CTF team scramble @@ -339,6 +345,9 @@ consvar_t cv_maxdemosize = {"maxdemosize", "10", CV_SAVE, maxdemosize_cons_t, NU static CV_PossibleValue_t demochangemap_cons_t[] = {{0, "Disabled"}, {1, "Diff Map"}, {2, "Always"}, {0, NULL}}; consvar_t cv_demochangemap = {"netdemo_savemapchange", "Disabled", CV_SAVE, demochangemap_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t demodateformat_cons_t[] = {{0, "Automatic"}, {1, "EU"}, {2, "US"}, {0, NULL}}; +consvar_t cv_demodateformat = {"netdemo_dateformat", "Automatic", CV_SAVE, demodateformat_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + // Analog Control void SendWeaponPref(void); void SendWeaponPref2(void); @@ -515,7 +524,8 @@ consvar_t cv_ydeadzone[MAXSPLITSCREENPLAYERS] = { static CV_PossibleValue_t driftsparkpulse_t[] = {{0, "MIN"}, {FRACUNIT*3, "MAX"}, {0, NULL}}; consvar_t cv_driftsparkpulse = {"driftsparkpulse", "1.4", CV_FLOAT | CV_SAVE, driftsparkpulse_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t cechotoggle_t[] = {{0, "Off"}, {1, "On"}, {2, "Console"}, {0, NULL}}; +consvar_t cv_cechotoggle = {"show_cecho", "On", CV_SAVE, cechotoggle_t, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 #error "please update player_name table using the new value for MAXPLAYERS" @@ -1279,7 +1289,7 @@ static void G_DoLoadLevel(boolean resetplayer) // clear hud messages remains (usually from game startup) CON_ClearHUD(); - server_lagless = cv_lagless.value; + server_lagless = !cv_gentlemens.value; G_ResetAllDeviceRumbles(); } @@ -6668,6 +6678,9 @@ void G_LoadDemoInfo(menudemo_t *pdemo) subversion = READUINT8(info_p); pdemoversion = READUINT16(info_p); + memset(pdemo->version, 0, sizeof(pdemo->version)); + snprintf(pdemo->version, sizeof(pdemo->version), "v%d.%d", version, subversion); + switch(pdemoversion) { case DEMOVERSION: // latest always supported @@ -6809,6 +6822,108 @@ void G_LoadDemoInfo(menudemo_t *pdemo) Z_Free(infobuffer); } +#if defined (_WIN32) +// return the file creation time +// useful for demos that were renamed +static long G_GetCreationTime(char *filepath) +{ + struct stat fileinfo; + + if (stat(filepath, &fileinfo) == 0) + return fileinfo.st_ctime; + + return 0; +} +#endif + +static char *G_GetDemoDate(menudemo_t *pdemo) +{ + char *datetime; + datetime = malloc(sizeof(pdemo->date)); // mallocma balls + + // no mallocma balls... :c + if (!datetime) + { + return NULL; + } + + time_t file_time = 0; + + // get le filepath + char *filename; + filename = strdup(pdemo->filepath); + +#if defined (_WIN32) + if (!filename) + { + // if we cant get a filename try just getting the file create time + file_time = G_GetCreationTime(pdemo->filepath); + goto skipfilenametime; + } +#else + if (!filename) + { + free(datetime); + return NULL; + } +#endif + + // get the actual filename Zzz... + nameonly(filename); + + // convert it to long Zzz.... + file_time = strtol(filename, NULL, 10); + free(filename); // dont need this anymore a + +#if defined (_WIN32) +skipfilenametime: +#endif + + // then throw it into localtime to get an actual human readable format lmao + struct tm *tm_buf = NULL; + tm_buf = localtime(&file_time); + + // cant believe we ended up in 1970 + if (tm_buf == NULL || tm_buf->tm_year <= 110) + { +#if defined (_WIN32) + // uh ohh, we got an invalid time + // try one more time getting the creation time + file_time = G_GetCreationTime(pdemo->filepath); + tm_buf = localtime(&file_time); + + if (tm_buf == NULL || tm_buf->tm_year <= 110) + { + free(datetime); + return NULL; + } + + goto gotcreationtime; +#else + free(datetime); + return NULL; +#endif + } + +#if defined (_WIN32) +gotcreationtime: +#endif + + const char *format; + + // US ppl are special (: + if (cv_demodateformat.value == 2) + format = "%m.%d.%Y"; + else if (cv_demodateformat.value == 1) + format = "%d.%m.%Y"; + else + format = strstr(setlocale(LC_TIME, NULL), "en_US") ? "%m.%d.%Y" : "%d.%m.%Y"; + + strftime(datetime, sizeof(pdemo->date), format, tm_buf); + + return datetime; +} + void G_LoadDemoTitle(menudemo_t *pdemo) { UINT8 infobuffer[96], *info_p; @@ -6842,11 +6957,20 @@ void G_LoadDemoTitle(menudemo_t *pdemo) READUINT8(info_p); pdemoversion = READUINT16(info_p); + memset(pdemo->date, 0, sizeof(pdemo->date)); + switch(pdemoversion) { case DEMOVERSION: // latest always supported // demo title M_Memcpy(pdemo->title, info_p, 64); + + // demo date + char *demodate; + demodate = G_GetDemoDate(pdemo); + if (demodate) + strncpy(pdemo->date, demodate, sizeof(pdemo->date)); + free(demodate); break; #ifdef DEMO_COMPAT_100 case 0x0001: @@ -7911,7 +8035,7 @@ void G_StopDemo(void) demobuf.buffer = NULL; demo.playback = false; if (demo.title) - modeattacking = false; + modeattacking = ATTACKING_NONE; demo.title = false; demo.timing = false; singletics = false; @@ -7938,12 +8062,37 @@ void G_StopDemo(void) if (gamestate == GS_VOTING) Y_EndVote(); + M_ClearMenus(true); + G_SetGamestate(GS_NULL); wipegamestate = GS_NULL; SV_StopServer(); SV_ResetServer(); } +// Stops timing a demo. +static void G_StopTimingDemo(void) +{ + INT32 demotime; + double f1, f2; + demotime = I_GetTime() - demostarttime; + if (!demotime) + return; + G_StopDemo(); + demo.timing = false; + f1 = (double)demotime; + f2 = (double)framecount*TICRATE; + + CONS_Printf(M_GetText("timed %u gametics in %d realtics - %u frames\n%f seconds, %f avg fps\n"), + leveltime, demotime, (UINT32)framecount, f1/TICRATE, f2/f1); + + if (restorecv_vidwait != cv_vidwait.value) + CV_SetValue(&cv_vidwait, restorecv_vidwait); + + D_StartTitle(); +} + + boolean G_CheckDemoStatus(void) { while (ghosts) @@ -7958,19 +8107,7 @@ boolean G_CheckDemoStatus(void) if (demo.timing) { - INT32 demotime; - double f1, f2; - demotime = I_GetTime() - demostarttime; - if (!demotime) - return true; - G_StopDemo(); - demo.timing = false; - f1 = (double)demotime; - f2 = (double)framecount*TICRATE; - CONS_Printf(M_GetText("timed %u gametics in %d realtics\n%f seconds, %f avg fps\n"), leveltime,demotime,f1/TICRATE,f2/f1); - if (restorecv_vidwait != cv_vidwait.value) - CV_SetValue(&cv_vidwait, restorecv_vidwait); - D_StartTitle(); + G_StopTimingDemo(); return true; } @@ -7980,15 +8117,18 @@ boolean G_CheckDemoStatus(void) I_Quit(); if (multiplayer && !demo.title) + { G_ExitLevel(); + } + else if (modeattacking && !demo.title) // nooo dont crash our titledemos + { + G_StopDemo(); + M_EndModeAttackRun(); + } else { G_StopDemo(); - - if (modeattacking) - M_EndModeAttackRun(); - else - D_StartTitle(); + D_StartTitle(); } return true; @@ -8024,6 +8164,8 @@ static void G_ResetDemoPlayback(char *pdemoname) Z_Free(demobuf.buffer); demobuf.buffer = NULL; demo.playback = false; + if (demo.title) + modeattacking = ATTACKING_NONE; demo.title = false; } diff --git a/src/g_game.h b/src/g_game.h index deec04226..8027d86f2 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -42,6 +42,7 @@ extern savebuffer_t demobuf; // demoplaying back and demo recording extern consvar_t cv_recordmultiplayerdemos, cv_netdemosyncquality, cv_maxdemosize, cv_demochangemap; +extern consvar_t cv_demodateformat; // Publicly-accessible demo vars struct demovars_s { @@ -83,6 +84,8 @@ typedef struct menudemo_s { menudemotype_e type; char title[65]; // Null-terminated for string prints + char date[11]; // date when replay was recorded + char version[12]; // combined version and subversion UINT16 map; UINT8 addonstatus; // What do we need to do addon-wise to play this demo? UINT8 gametype; @@ -170,8 +173,10 @@ extern consvar_t cv_smallposnum; extern consvar_t cv_newspeedometer; extern consvar_t cv_saltyhop; +extern consvar_t cv_saltyheight; extern consvar_t cv_saltyhopsfx; extern consvar_t cv_saltysquish; +extern consvar_t cv_saltyroll; extern consvar_t cv_driftsparkpulse; extern consvar_t cv_gravstretch; @@ -182,6 +187,10 @@ extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; extern consvar_t cv_spinoutroll; +extern consvar_t cv_squishdance; + +extern consvar_t cv_playerblendeffects; + extern consvar_t cv_cechotoggle; #ifndef NONET diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 3a8161ab3..3c7a49af9 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -172,6 +172,10 @@ static int comparePolygons(const void *p1, const void *p2) diff = poly1->surf.LightInfo.fade_start - poly2->surf.LightInfo.fade_start; if (diff != 0) return diff; diff = poly1->surf.LightInfo.fade_end - poly2->surf.LightInfo.fade_end; + if (diff != 0) return diff; + + diff = poly1->surf.LightInfo.directional - poly2->surf.LightInfo.directional; + return diff; } @@ -229,6 +233,7 @@ void HWR_RenderBatches(void) nextSurfaceInfo.LightInfo.fade_end = 0; nextSurfaceInfo.LightInfo.fade_start = 0; nextSurfaceInfo.LightInfo.light_level = 0; + nextSurfaceInfo.LightInfo.directional = false; currently_batching = false;// no longer collecting batches if (!polygonArraySize) @@ -380,7 +385,8 @@ void HWR_RenderBatches(void) currentSurfaceInfo.FadeColor.rgba != nextSurfaceInfo.FadeColor.rgba || currentSurfaceInfo.LightInfo.light_level != nextSurfaceInfo.LightInfo.light_level || currentSurfaceInfo.LightInfo.fade_start != nextSurfaceInfo.LightInfo.fade_start || - currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end) + currentSurfaceInfo.LightInfo.fade_end != nextSurfaceInfo.LightInfo.fade_end || + currentSurfaceInfo.LightInfo.directional != nextSurfaceInfo.LightInfo.directional) { changeState = true; changeSurfaceInfo = true; diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c06db3891..5ba8655b8 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -77,9 +77,6 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm (void)patchheight; // This parameter is unused - if (!mipmap) - return; - if (originPatch) // originPatch can be NULL here, unlike in the software version originy = originPatch->originy; @@ -101,10 +98,7 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm position = 0; } - position = ((position * scale_y) + (FRACUNIT/2)) >> FRACBITS; - - if (position < 0) - position = 0; + position = max(((position * scale_y) + (FRACUNIT/2)) >> FRACBITS, 0); if (position + count >= pblockheight) count = pblockheight - position; @@ -118,11 +112,11 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm alpha = 0xFF; // Make pixel transparent if chroma keyed - if ((mipmap && mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)) + if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)) alpha = 0x00; //Hurdler: 25/04/2000: now support colormap in hardware mode - if (mipmap && mipmap->colormap) + if (mipmap->colormap) texel = mipmap->colormap[texel]; // hope compiler will get this switch out of the loops (dreams...) @@ -323,36 +317,27 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe INT32 blockwidth, blockheight, blocksize; INT32 i, idx; - boolean skyspecial = false; //poor hack for Legacy large skies.. + boolean skyspecial = false; // poor hack for Legacy large skies.. RGBA_t *palette; palette = HWR_GetTexturePalette(); texture = textures[texnum]; - // hack the Legacy skies.. - if (texture->name[0] == 'S' && - texture->name[1] == 'K' && - texture->name[2] == 'Y' && - (texture->name[4] == 0 || - texture->name[5] == 0) - ) - { - skyspecial = true; - gltex->mipmap.flags = TF_WRAPXY; // don't use the chromakey for sky - } - else - gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY; - + gltex->mipmap.flags = TF_CHROMAKEYED | TF_WRAPXY; gltex->mipmap.width = (UINT16)(texture->width); gltex->mipmap.height = (UINT16)(texture->height); - - if (skyspecial) - gltex->mipmap.format = GL_TEXFMT_RGBA; // that skyspecial code below assumes this format ... - else - gltex->mipmap.format = textureformat; - gltex->mipmap.colormap = colormaps; + gltex->mipmap.format = textureformat; + + // hack the Legacy skies.. + if (UNLIKELY(strncmp(texture->name, "SKY", 3) == 0 && + (texture->name[4] == 0 || texture->name[5] == 0))) + { + skyspecial = true; + gltex->mipmap.flags &= ~TF_CHROMAKEYED; // don't use the chromakey for sky + gltex->mipmap.format = GL_TEXFMT_RGBA; // that skyspecial code below assumes this format ... + } #ifdef GLENCORE if (encoremap && !noencore) @@ -364,7 +349,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe blocksize = (blockwidth * blockheight); block = MakeBlock(&gltex->mipmap); - if (skyspecial) //Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading) + if (UNLIKELY(skyspecial)) // Hurdler: not efficient, but better than holes in the sky (and it's done only at level loading) { INT32 j; RGBA_t col; @@ -387,10 +372,11 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + if (realpatch != NULL) { HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); - Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); + //Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); } } @@ -414,16 +400,6 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe // patch may be NULL if glMipmap has been initialised already and makebitmap is false void HWR_MakePatch (patch_t *patch, GLPatch_t *glPatch, GLMipmap_t *glMipmap, boolean makebitmap) { - if (glMipmap == NULL) - return; - - if (patch == NULL || glPatch == NULL) - { - Z_Free(glMipmap->data); - glMipmap->data = NULL; - return; - } - // don't do it twice (like a cache) if (glMipmap->width == 0) { @@ -951,6 +927,7 @@ static void HWR_LoadMappedPatch(GLMipmap_t *glMipmap, GLPatch_t *glPatch) patch_t *patch = glPatch->rawpatch; if (!patch) patch = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC); + HWR_MakePatch(patch, glPatch, glMipmap, true); // You can't free rawpatch for some reason? @@ -982,6 +959,7 @@ void HWR_GetPatch(GLPatch_t *glPatch) patch_t *ptr = glPatch->rawpatch; if (!ptr) ptr = W_CacheLumpNumPwad(glPatch->wadnum, glPatch->lumpnum, PU_STATIC); + HWR_MakePatch(ptr, glPatch, glPatch->mipmap, true); // this is inefficient.. but the hardware patch in heap is purgeable so it should @@ -1007,8 +985,7 @@ void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap) { GLMipmap_t *glMipmap, *newMipmap; - // Blatant hack for encore colormapping aside... - if (colormap == colormaps || colormap == NULL || colormap == (const UINT8*)(COLORMAP_REMAPOFFSET)) + if (colormap == colormaps || colormap == NULL) { // Load the default (green) color in doom cache (temporary?) AND hardware cache HWR_GetPatch(glPatch); @@ -1017,15 +994,15 @@ void HWR_GetMappedPatch(GLPatch_t *glPatch, const UINT8 *colormap) // search for the mipmap // skip the first (no colormap translated) - for (glMipmap = glPatch->mipmap; glMipmap->nextcolormap; ) + for (glMipmap = glPatch->mipmap; LIKELY(glMipmap->nextcolormap);) { glMipmap = glMipmap->nextcolormap; - if (glMipmap->colormap != colormap) - continue; - - HWR_LoadMappedPatch(glMipmap, glPatch); - return; + if (UNLIKELY(glMipmap->colormap == colormap)) + { + HWR_LoadMappedPatch(glMipmap, glPatch); + return; + } } // not found, create it! // If we are here, the sprite with the current colormap is not already in hardware memory @@ -1344,6 +1321,7 @@ UINT32 HWR_GetLightTableID(extracolormap_t *colormap) colormap_pointer = colormaps; // don't actually use the data from the "default colormap" else colormap_pointer = colormap->colormap; + colormap->gl_lighttable_id = HWR_CreateLightTable(colormap_pointer); } diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 82c8c690c..822389758 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -128,7 +128,6 @@ typedef struct { FLOAT x,y,z; // position FLOAT anglex, angley, anglez; // aimingangle / viewangle - FLOAT anglex2, anglez2; // secondaries FLOAT scalex, scaley, scalez; FLOAT fovangle; UINT8 splitscreen; @@ -256,7 +255,8 @@ enum EPolyFlags PF_RemoveYWrap = 0x00010000, // Force clamp texture on Y PF_ForceWrapX = 0x00020000, // Force repeat texture on X PF_ForceWrapY = 0x00040000, // Forces repeat texture on Y - PF_Ripple = 0x00100000 // Water ripple effect. The current backend doesn't use it for anything. + PF_Ripple = 0x00100000, // Water ripple effect. The current backend doesn't use it for anything. + PF_Skydecal = 0x20000000 // Enables smaller polygon offset, to be used for skywalls only // 0x20000000 // 0x40000000 // 0x80000000 @@ -289,6 +289,7 @@ struct FLightInfo FUINT light_level; FUINT fade_start; FUINT fade_end; + boolean directional; }; typedef struct FLightInfo FLightInfo; @@ -310,7 +311,7 @@ enum hwdsetspecialstate HWD_SET_TEXTUREFILTERMODE, HWD_SET_TEXTUREANISOTROPICMODE, - + HWD_SET_MSAA, HWD_SET_SCREEN_TEXTURES, @@ -318,6 +319,8 @@ enum hwdsetspecialstate HWD_SET_PORTAL_MODE,// new portal thing HWD_SET_STENCIL_LEVEL, + HWD_SET_TEXTURE_FORMAT, + HWD_NUMSTATE }; typedef enum hwdsetspecialstate hwdspecialstate_t; @@ -327,6 +330,11 @@ typedef enum hwdsetspecialstate hwdspecialstate_t; enum hwdshaderinfo { HWD_SHADERINFO_LEVELTIME = 1, + HWD_SHADERINFO_LIGHT_X, + HWD_SHADERINFO_LIGHT_Y, + HWD_SHADERINFO_LIGHT_Z, + HWD_SHADERINFO_LIGHT_CONTRAST, + HWD_SHADERINFO_LIGHT_BACKLIGHT, }; typedef enum hwdshaderinfo hwdshaderinfo_t; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index b6daad7b6..70a2e6cc8 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -252,20 +252,12 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t } } - if (pscale != FRACUNIT) - { - fwidth = (float)SHORT(gpatch->width) * fscalew * dupx; - fheight = (float)SHORT(gpatch->height) * fscaleh * dupy; - } - else - { - fwidth = (float)SHORT(gpatch->width) * dupx; - fheight = (float)SHORT(gpatch->height) * dupy; - } + fwidth = (float)SHORT(gpatch->width) * fscalew * dupx; + fheight = (float)SHORT(gpatch->height) * fscaleh * dupy; // positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1 - cx = -1.0f + (cx / (vid.width / 2.0f)); - cy = 1.0f - (cy / (vid.height / 2.0f)); + cx = -1.0f + (cx / (fvw / 2.0f)); + cy = 1.0f - (cy / (fvh / 2.0f)); // fwidth and fheight are similar fwidth /= fvw / 2.0f; @@ -294,7 +286,7 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t v[0].t = v[1].t = 0.0f; v[2].t = v[3].t = gpatch->max_t; - // whoops + // clip it since it is used for bunny scroll in doom I if (blendmode) flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; else @@ -305,13 +297,11 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t if (option & V_WRAPY) flags |= PF_ForceWrapY; - // clip it since it is used for bunny scroll in doom I - if (alphalevel) { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; - + if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[hudtrans]; else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[hudtrans]; else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[hudtrans]; @@ -440,8 +430,8 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal } // positions of the cx, cy, are between 0 and vid.width/vid.height now, we need them to be between -1 and 1 - cx = -1.0f + (cx / (vid.width / 2.0f)); - cy = 1.0f - (cy / (vid.height / 2.0f)); + cx = -1.0f + (cx / (fvw / 2.0f)); + cy = 1.0f - (cy / (fvh / 2.0f)); // fwidth and fheight are similar fwidth /= fvw / 2.0f; @@ -478,7 +468,7 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal else if (alphalevel == 14) Surf.PolyColor.s.alpha = softwaretranstogl[cv_translucenthud.value]; else if (alphalevel == 15) Surf.PolyColor.s.alpha = softwaretranstogl_hi[cv_translucenthud.value]; else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; - + flags |= PF_Modulated; GL_DrawPolygon(&Surf, v, 4, flags); } @@ -614,7 +604,7 @@ void HWR_FadeScreenMenuBack(UINT16 color, UINT8 strength) RGBA_t *palette = HWR_GetTexturePalette(); Surf.PolyColor.rgba = palette[color&0xFF].rgba; - if (HWR_ShouldUsePaletteRendering()) + if (HWR_ShouldUsePaletteRendering()) Surf.PolyColor.s.alpha = softwaretranstogl[strength]; else Surf.PolyColor.s.alpha = (UINT8)(strength*25.5f); @@ -882,8 +872,8 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) if (fy + fh > vid.height) fh = fvh - fy; - fx = -1.0f + fx / (vid.width / 2.0f); - fy = 1.0f - fy / (vid.height / 2.0f); + fx = -1.0f + fx / (fvw / 2.0f); + fy = 1.0f - fy / (fvh / 2.0f); fw = fw / (fvw / 2.0f); fh = fh / (fvh / 2.0f); @@ -995,8 +985,8 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 if (fy + fh > vid.height) fh = fvh - fy; - fx = -1.0f + fx / (vid.width / 2.0f); - fy = 1.0f - fy / (vid.height / 2.0f); + fx = -1.0f + fx / (fvw / 2.0f); + fy = 1.0f - fy / (fvh / 2.0f); fw = fw / (fvw / 2.0f); fh = fh / (fvh / 2.0f); @@ -1108,8 +1098,8 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) if (fy + fh > vid.height) fh = fvh - fy; - fx = -1.0f + fx / (vid.width / 2.0f); - fy = 1.0f - fy / (vid.height / 2.0f); + fx = -1.0f + fx / (fvw / 2.0f); + fy = 1.0f - fy / (fvh / 2.0f); fw = fw / (fvw / 2.0f); fh = fh / (fvh / 2.0f); diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index edba8a025..e4659c0e6 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -43,6 +43,8 @@ typedef struct gl_vissprite_s INT32 dispoffset; // copy of info->dispoffset, affects ordering but not drawing } gl_vissprite_t; +void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model); + // -------- // hw_bsp.c // -------- diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 88d3322b3..37d0e25cd 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -94,6 +94,8 @@ line_t *gl_linedef; sector_t *gl_frontsector; sector_t *gl_backsector; +static boolean gl_maphashorizonlines = false; + // values for the far clipping plane static float clipping_distances[] = {1024.0f, 2048.0f, 4096.0f, 6144.0f, 8192.0f, 12288.0f, 16384.0f}; // values for bsp culling @@ -156,6 +158,7 @@ static void CV_glshaders_OnChange(void); static void CV_gllightdithering_OnChange(void); static void CV_filtermode_OnChange(void); static void CV_anisotropic_OnChange(void); +static void CV_gltextureformat_OnChange(void); static void CV_glpaletterendering_OnChange(void); static void CV_glpalettedepth_OnChange(void); @@ -178,6 +181,8 @@ static CV_PossibleValue_t glrenderdistance_cons_t[] = { {0, "Max"}, {1, "1024"}, {2, "2048"}, {3, "4096"}, {4, "6144"}, {5, "8192"}, {6, "12288"}, {7, "16384"}, {0, NULL}}; +static CV_PossibleValue_t gltexdepth_cons_t[] = {{16, "16 bits"}, {32, "32 bits"}, {0, NULL}}; + static CV_PossibleValue_t glpalettedepth_cons_t[] = {{16, "16 bits"}, {24, "24 bits"}, {0, NULL}}; // @@ -227,6 +232,8 @@ consvar_t cv_glpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, C consvar_t cv_glpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_glpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_gltexturedepth = {"gr_texturedepth", "32 bits", CV_CALL|CV_SAVE, gltexdepth_cons_t, CV_gltextureformat_OnChange, 0, NULL, NULL, 0, 0, NULL}; + #define ONLY_IF_GL_LOADED if (vid.glstate != VID_GL_LIBRARY_LOADED) return; static void CV_screentextures_OnChange(void) @@ -280,6 +287,12 @@ static void CV_gllightdithering_OnChange(void) } } +static void CV_gltextureformat_OnChange(void) +{ + ONLY_IF_GL_LOADED + GL_SetSpecialState(HWD_SET_TEXTURE_FORMAT, cv_gltexturedepth.value); +} + static void CV_filtermode_OnChange(void) { ONLY_IF_GL_LOADED @@ -322,7 +335,61 @@ static void HWR_SetShaderState(void) GL_SetSpecialState(HWD_SET_SHADERS, HWR_UseShader() ? 1 : 0); } -void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap) +static boolean HWR_OverrideObjectLightLevel(mobj_t *thing, INT32 *lightlevel) +{ + if (R_ThingIsFullBright(thing)) + *lightlevel = 255; + else if (R_ThingIsFullDark(thing)) + *lightlevel = 0; + else if (thing->frame & FF_ABSOLUTELIGHTLEVEL) + *lightlevel = R_ThingLightLevel(thing); + else + return false; + + return true; +} + +void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model) +{ + const boolean semibright = R_ThingIsSemiBright(spr->mobj); + + *lightlevel += R_ThingLightLevel(spr->mobj); + + if (maplighting.directional == true && P_SectorUsesDirectionalLighting(sector)) + { + if (model == false) // this is implemented by shader + { + fixed_t extralight = R_GetSpriteDirectionalLighting(R_PointToAngle(spr->mobj->x, spr->mobj->y)); + + // Less change in contrast in dark sectors + extralight = FixedMul(extralight, min(max(0, *lightlevel), 255) * FRACUNIT / 255); + + // simple OGL approximation + fixed_t tr = R_PointToDist(spr->mobj->x, spr->mobj->y); + fixed_t xscale = FixedDiv((vid.width / 2) << FRACBITS, tr); + + // Less change in contrast at further distances, to counteract DOOM diminished light + fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); + extralight = FixedMul(extralight, min(n, FRACUNIT)); + + // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance + *lightlevel += FixedFloor((extralight * 2) + (FRACUNIT / 2)) / FRACUNIT; + } + + // Semibright objects will be made slightly brighter to compensate contrast + if (semibright) + { + *lightlevel += 16; + } + } + + if (semibright) + { + *lightlevel = 128 + (*lightlevel >> 1); + } +} + +void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap, const boolean directional) { RGBA_t poly_color, tint_color, fade_color; @@ -382,6 +449,7 @@ void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *col Surface->LightInfo.light_level = light_level; Surface->LightInfo.fade_start = (colormap != NULL) ? colormap->fadestart : 0; Surface->LightInfo.fade_end = (colormap != NULL) ? colormap->fadeend : 31; + Surface->LightInfo.directional = (maplighting.directional == true && directional == true); Surface->LightTableId = HWR_ShouldUsePaletteRendering() ? HWR_GetLightTableID(colormap) : 0; } @@ -414,43 +482,33 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, seg_t *seg) { INT16 finallight = lightnum; - if (seg != NULL && cv_glfakecontrast.value != 0) + if (cv_glfakecontrast.value == 0) + return (FUINT)finallight; + + if (seg != NULL && P_ApplyLightOffsetFine(lightnum, seg->frontsector)) { - fixed_t extralight = 0; + INT16 offset = (cv_glfakecontrast.value == 2) ? seg->hwLightOffset : ((INT16)seg->lightOffset * 8); - if (cv_glfakecontrast.value == 2) // Smooth setting - extralight += seg->hwLightOffset; - else - extralight += seg->lightOffset * 8; - - if (extralight != 0) - { - finallight += extralight; - finallight = CLAMP(finallight, 0 , 255); - } + finallight += offset; + finallight = CLAMP(finallight, 0 , 255); } return (FUINT)finallight; } -static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope) +static FUINT HWR_CalcSlopeLight(FUINT lightnum, pslope_t *slope, const sector_t *sector, const boolean fof) { INT16 finallight = lightnum; - if (slope != NULL && cv_glfakecontrast.value != 0 && cv_glslopecontrast.value != 0) + if (cv_glfakecontrast.value == 0 || cv_glslopecontrast.value == 0) + return (FUINT)finallight; + + if (slope != NULL && sector != NULL && P_ApplyLightOffsetFine(lightnum, sector)) { - fixed_t extralight = 0; + INT16 offset = (cv_glfakecontrast.value == 2) ? slope->hwLightOffset : ((INT16)slope->lightOffset * 8); - if (cv_glfakecontrast.value == 2) // Smooth setting - extralight += slope->hwLightOffset; - else - extralight += slope->lightOffset * 8; - - if (extralight != 0) - { - finallight += extralight; - finallight = CLAMP(finallight, 0 , 255); - } + finallight += (fof ? -offset : offset); + finallight = CLAMP(finallight, 0 , 255); } return (FUINT)finallight; @@ -486,11 +544,13 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool static FOutVector *planeVerts = NULL; static UINT16 numAllocedPlaneVerts = 0; + poly_t *planepoly = xsub->planepoly; + // no convex poly were generated for this subsector - if (!xsub->planepoly) + if (!planepoly) return; - nrPlaneVerts = xsub->planepoly->numpts; + nrPlaneVerts = planepoly->numpts; if (nrPlaneVerts < 3) //not even a triangle ? return; @@ -513,9 +573,9 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool // Set fixedheight to the slope's height from our viewpoint, if we have a slope if (slope) - fixedheight = P_GetZAt(slope, viewx, viewy); + fixedheight = P_GetSlopeZAt(slope, viewx, viewy); - height = FIXED_TO_FLOAT(fixedheight); + height = FixedToFloat(fixedheight); // Allocate plane-vertex buffer if we need to if (!planeVerts || nrPlaneVerts > numAllocedPlaneVerts) @@ -559,7 +619,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool break; } - pv = xsub->planepoly->pts; + pv = planepoly->pts; // reference point for flat texture coord for each vertex around the polygon flatxref = (float)(((fixed_t)pv->x & (~flatflag)) / fflatsize); @@ -569,14 +629,14 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize; + scrollx = FixedToFloat(FOFsector->floor_xoffs)/fflatsize; + scrolly = FixedToFloat(FOFsector->floor_yoffs)/fflatsize; angle = FOFsector->floorpic_angle; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatsize; + scrollx = FixedToFloat(FOFsector->ceiling_xoffs)/fflatsize; + scrolly = FixedToFloat(FOFsector->ceiling_yoffs)/fflatsize; angle = FOFsector->ceilingpic_angle; } } @@ -584,14 +644,14 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(gl_frontsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gl_frontsector->floor_yoffs)/fflatsize; + scrollx = FixedToFloat(gl_frontsector->floor_xoffs)/fflatsize; + scrolly = FixedToFloat(gl_frontsector->floor_yoffs)/fflatsize; angle = gl_frontsector->floorpic_angle; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(gl_frontsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gl_frontsector->ceiling_yoffs)/fflatsize; + scrollx = FixedToFloat(gl_frontsector->ceiling_xoffs)/fflatsize; + scrolly = FixedToFloat(gl_frontsector->ceiling_yoffs)/fflatsize; angle = gl_frontsector->ceilingpic_angle; } } @@ -602,10 +662,10 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool // This needs to be done so everything aligns after rotation // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does - tempxsow = FLOAT_TO_FIXED(flatxref); - tempytow = FLOAT_TO_FIXED(flatyref); - flatxref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - flatyref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); + tempxsow = FloatToFixed(flatxref); + tempytow = FloatToFixed(flatyref); + flatxref = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); + flatyref = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); } #define SETUP3DVERT(vert, vx, vy) {\ @@ -616,10 +676,10 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool /* Need to rotate before translate */\ if (angle) /* Only needs to be done if there's an altered angle */\ {\ - tempxsow = FLOAT_TO_FIXED(vert->s);\ - tempytow = FLOAT_TO_FIXED(vert->t);\ - vert->s = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));\ - vert->t = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));\ + tempxsow = FloatToFixed(vert->s);\ + tempytow = FloatToFixed(vert->t);\ + vert->s = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle))));\ + vert->t = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle))));\ }\ \ vert->x = (vx);\ @@ -628,17 +688,17 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool \ if (slope)\ {\ - fixedheight = P_GetZAt(slope, FLOAT_TO_FIXED((vx)), FLOAT_TO_FIXED((vy)));\ - vert->y = FIXED_TO_FLOAT(fixedheight);\ + fixedheight = P_GetSlopeZAt(slope, FloatToFixed((vx)), FloatToFixed((vy)));\ + vert->y = FixedToFloat(fixedheight);\ }\ } for (i = 0, v3d = planeVerts; i < (INT32)nrPlaneVerts; i++,v3d++,pv++) SETUP3DVERT(v3d, pv->x, pv->y); if (slope) - lightlevel = HWR_CalcSlopeLight(lightlevel, slope); + lightlevel = HWR_CalcSlopeLight(lightlevel, slope, gl_frontsector, (FOFsector != NULL)); - HWR_Lighting(&Surf, lightlevel, planecolormap); + HWR_Lighting(&Surf, lightlevel, planecolormap, P_SectorUsesDirectionalLighting(gl_frontsector)); if (PolyFlags & (PF_Translucent|PF_Fog|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) { @@ -662,7 +722,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool HWR_ProcessPolygon(&Surf, planeVerts, nrPlaneVerts, PolyFlags, shader, false); - if (subsector && cv_glhorizonlines.value) + if (gl_maphashorizonlines && subsector && cv_glhorizonlines.value) { // Horizon lines FOutVector horizonpts[6]; @@ -678,11 +738,14 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool for (i = 0; i < subsector->numlines; i++, line++) { - if (!(line->linedef->special == HORIZONSPECIAL && R_PointOnSegSide(viewx, viewy, line) == 0)) + if (line->linedef->special != HORIZONSPECIAL) + continue; + + if (R_PointOnSegSide(viewx, viewy, line) != 0) continue; P_ClosestPointOnLine(viewx, viewy, line->linedef, &v); - dist = FIXED_TO_FLOAT(R_PointToDist(v.x, v.y)); + dist = FixedToFloat(R_PointToDist(v.x, v.y)); if (line->pv1) { @@ -691,9 +754,10 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool } else { - x1 = FIXED_TO_FLOAT(line->v1->x); - y1 = FIXED_TO_FLOAT(line->v1->x); + x1 = FixedToFloat(line->v1->x); + y1 = FixedToFloat(line->v1->x); } + if (line->pv2) { xd = ((polyvertex_t *)line->pv2)->x - x1; @@ -701,8 +765,8 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool } else { - xd = FIXED_TO_FLOAT(line->v2->x) - x1; - yd = FIXED_TO_FLOAT(line->v2->y) - y1; + xd = FixedToFloat(line->v2->x) - x1; + yd = FixedToFloat(line->v2->y) - y1; } // Based on the seg length and the distance from the line, split horizon into multiple poly sets to reduce distortion @@ -766,11 +830,11 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) M_ClearBox(segbbox); M_AddToBox(segbbox, - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y)); + FloatToFixed(((polyvertex_t *)gl_curline->pv1)->x), + FloatToFixed(((polyvertex_t *)gl_curline->pv1)->y)); M_AddToBox(segbbox, - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x), - FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y)); + FloatToFixed(((polyvertex_t *)gl_curline->pv2)->x), + FloatToFixed(((polyvertex_t *)gl_curline->pv2)->y)); splat = (wallsplat_t *)gl_curline->linedef->splats; for (; splat; splat = splat->next) @@ -783,17 +847,17 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) gpatch = W_CachePatchNum(splat->patch, PU_CACHE); HWR_GetPatch(gpatch); - wallVerts[0].x = wallVerts[3].x = FIXED_TO_FLOAT(splat->v1.x); - wallVerts[0].z = wallVerts[3].z = FIXED_TO_FLOAT(splat->v1.y); - wallVerts[2].x = wallVerts[1].x = FIXED_TO_FLOAT(splat->v2.x); - wallVerts[2].z = wallVerts[1].z = FIXED_TO_FLOAT(splat->v2.y); + wallVerts[0].x = wallVerts[3].x = FixedToFloat(splat->v1.x); + wallVerts[0].z = wallVerts[3].z = FixedToFloat(splat->v1.y); + wallVerts[2].x = wallVerts[1].x = FixedToFloat(splat->v2.x); + wallVerts[2].z = wallVerts[1].z = FixedToFloat(splat->v2.y); i = splat->top; if (splat->yoffset) i += *splat->yoffset; - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(i)+(gpatch->height>>1); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(i)-(gpatch->height>>1); + wallVerts[2].y = wallVerts[3].y = FixedToFloat(i)+(gpatch->height>>1); + wallVerts[0].y = wallVerts[1].y = FixedToFloat(i)-(gpatch->height>>1); wallVerts[3].s = wallVerts[3].t = wallVerts[2].s = wallVerts[0].t = 0.0f; wallVerts[1].s = wallVerts[1].t = wallVerts[2].t = wallVerts[0].s = 1.0f; @@ -895,7 +959,7 @@ static void HWR_ProjectWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIEL { INT32 shader = SHADER_NONE; - HWR_Lighting(pSurf, lightlevel, wallcolormap); + HWR_Lighting(pSurf, lightlevel, wallcolormap, P_SectorUsesDirectionalLighting(gl_frontsector)); if (HWR_UseShader()) { @@ -1147,7 +1211,7 @@ static void HWR_DrawSkyWallList(void) GL_UnSetShader(); for (i = 0; i < skyWallVertexArraySize; i++) { - GL_DrawPolygon(&surf, skyWallVertexArray + i * 4, 4, PF_Occlude|PF_Invisible|PF_NoTexture); + GL_DrawPolygon(&surf, skyWallVertexArray + i * 4, 4, PF_Occlude|PF_Invisible|PF_NoTexture|PF_Skydecal); } } @@ -1162,14 +1226,14 @@ static void HWR_DrawSkyWall(FOutVector *wallVerts, FSurfaceInfo *Surf) wallVerts[0].s = wallVerts[3].s = 0; wallVerts[2].s = wallVerts[1].s = 0; - if (gl_collect_skywalls) + if (UNLIKELY(gl_collect_skywalls)) { HWR_SkyWallList_Add(wallVerts); } else { HWR_SetCurrentTexture(NULL); - HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_NoTexture, 255, NULL); + HWR_ProjectWall(wallVerts, Surf, PF_Invisible|PF_NoTexture|PF_Skydecal, 255, NULL); } // PF_Invisible so it's not drawn into the colour buffer // PF_NoTexture for no texture @@ -1183,7 +1247,7 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) pSurf->PolyColor.s.alpha = 0xFF; - if (!gl_curline->polyseg) + if (LIKELY(!gl_curline->polyseg)) { // set alpha for transparent walls switch (gl_linedef->special) @@ -1265,38 +1329,39 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom const boolean noencore = (gl_linedef->flags & ML_TFERLINE); - if (gl_curline->pv1) + if (LIKELY(gl_curline->pv1)) { vs.x = ((polyvertex_t *)gl_curline->pv1)->x; vs.y = ((polyvertex_t *)gl_curline->pv1)->y; + v1x = FloatToFixed(vs.x); + v1y = FloatToFixed(vs.y); } else { - vs.x = FIXED_TO_FLOAT(gl_curline->v1->x); - vs.y = FIXED_TO_FLOAT(gl_curline->v1->y); + vs.x = FixedToFloat(gl_curline->v1->x); + vs.y = FixedToFloat(gl_curline->v1->y); + v1x = gl_curline->v1->x; + v1y = gl_curline->v1->y; } - if (gl_curline->pv2) + + if (LIKELY(gl_curline->pv2)) { ve.x = ((polyvertex_t *)gl_curline->pv2)->x; ve.y = ((polyvertex_t *)gl_curline->pv2)->y; + v2x = FloatToFixed(ve.x); + v2y = FloatToFixed(ve.y); } else { - ve.x = FIXED_TO_FLOAT(gl_curline->v2->x); - ve.y = FIXED_TO_FLOAT(gl_curline->v2->y); + ve.x = FixedToFloat(gl_curline->v2->x); + ve.y = FixedToFloat(gl_curline->v2->y); + v2x = gl_curline->v2->x; + v2y = gl_curline->v2->y; } - v1x = FLOAT_TO_FIXED(vs.x); - v1y = FLOAT_TO_FIXED(vs.y); - v2x = FLOAT_TO_FIXED(ve.x); - v2y = FLOAT_TO_FIXED(ve.y); - #define SLOPEPARAMS(slope, end1, end2, normalheight) \ - if (slope) { \ - end1 = P_GetZAt(slope, v1x, v1y); \ - end2 = P_GetZAt(slope, v2x, v2y); \ - } else \ - end1 = end2 = normalheight; + end1 = P_GetZAt(slope, v1x, v1y, normalheight); \ + end2 = P_GetZAt(slope, v2x, v2y, normalheight); SLOPEPARAMS(gl_frontsector->c_slope, worldtop, worldtopslope, gl_frontsector->ceilingheight) SLOPEPARAMS(gl_frontsector->f_slope, worldbottom, worldbottomslope, gl_frontsector->floorheight) @@ -1344,7 +1409,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom if (!gl_curline->polyseg) // Don't do it for polyobjects { // Sky Ceilings - wallVerts[3].y = wallVerts[2].y = FIXED_TO_FLOAT(INT32_MAX); + wallVerts[3].y = wallVerts[2].y = FixedToFloat(INT32_MAX); if (gl_frontsector->ceilingpic == skyflatnum) { @@ -1356,29 +1421,29 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom && (worldhigh != worldtop || worldhighslope != worldtopslope)) // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race { - wallVerts[0].y = FIXED_TO_FLOAT(worldhigh); - wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); + wallVerts[0].y = FixedToFloat(worldhigh); + wallVerts[1].y = FixedToFloat(worldhighslope); HWR_DrawSkyWall(wallVerts, &Surf); } } else { // Only the frontsector is sky, just draw a skywall from the front ceiling - wallVerts[0].y = FIXED_TO_FLOAT(worldtop); - wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); + wallVerts[0].y = FixedToFloat(worldtop); + wallVerts[1].y = FixedToFloat(worldtopslope); HWR_DrawSkyWall(wallVerts, &Surf); } } else if (gl_backsector->ceilingpic == skyflatnum) { // Only the backsector is sky, just draw a skywall from the front ceiling - wallVerts[0].y = FIXED_TO_FLOAT(worldtop); - wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); + wallVerts[0].y = FixedToFloat(worldtop); + wallVerts[1].y = FixedToFloat(worldtopslope); HWR_DrawSkyWall(wallVerts, &Surf); } // Sky Floors - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); + wallVerts[0].y = wallVerts[1].y = FixedToFloat(INT32_MIN); if (gl_frontsector->floorpic == skyflatnum) { @@ -1392,24 +1457,24 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // Removing the second line above will render more rarely visible skywalls. Example: Cave garden ceiling in Dark race && !(gl_sidedef->bottomtexture)) { - wallVerts[3].y = FIXED_TO_FLOAT(worldlow); - wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); + wallVerts[3].y = FixedToFloat(worldlow); + wallVerts[2].y = FixedToFloat(worldlowslope); HWR_DrawSkyWall(wallVerts, &Surf); } } else { // Only the backsector has sky, just draw a skywall from the back floor - wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); - wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); + wallVerts[3].y = FixedToFloat(worldbottom); + wallVerts[2].y = FixedToFloat(worldbottomslope); HWR_DrawSkyWall(wallVerts, &Surf); } } else if ((gl_backsector->floorpic == skyflatnum) && !(gl_sidedef->bottomtexture)) { // Only the backsector has sky, just draw a skywall from the back floor if there's no bottomtexture - wallVerts[3].y = FIXED_TO_FLOAT(worldlow); - wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); + wallVerts[3].y = FixedToFloat(worldlow); + wallVerts[2].y = FixedToFloat(worldlowslope); HWR_DrawSkyWall(wallVerts, &Surf); } } @@ -1424,10 +1489,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } gl_toptexture = R_GetTextureNum(gl_sidedef->toptexture); - gl_bottomtexture = R_GetTextureNum(gl_sidedef->bottomtexture); // check TOP TEXTURE - if ((worldhighslope < worldtopslope || worldhigh < worldtop) && gl_toptexture) + if (gl_toptexture && (worldhighslope < worldtopslope || worldhigh < worldtop)) { // PEGGING if (gl_linedef->flags & ML_DONTPEGTOP) @@ -1473,10 +1537,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } // set top/bottom coords - wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = FIXED_TO_FLOAT(worldhigh); - wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); - wallVerts[1].y = FIXED_TO_FLOAT(worldhighslope); + wallVerts[3].y = FixedToFloat(worldtop); + wallVerts[0].y = FixedToFloat(worldhigh); + wallVerts[2].y = FixedToFloat(worldtopslope); + wallVerts[1].y = FixedToFloat(worldhighslope); if (!gl_drawing_stencil && gl_frontsector->numlights) HWR_SplitWall(gl_frontsector, wallVerts, gl_toptexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0); @@ -1486,8 +1550,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom HWR_ProjectWall(wallVerts, &Surf, PF_Masked, lightnum, colormap); } + gl_bottomtexture = R_GetTextureNum(gl_sidedef->bottomtexture); + // check BOTTOM TEXTURE - if ((worldlowslope > worldbottomslope || worldlow > worldbottom) && gl_bottomtexture) + if (gl_bottomtexture && (worldlowslope > worldbottomslope || worldlow > worldbottom)) { // PEGGING if (!(gl_linedef->flags & ML_DONTPEGBOTTOM)) @@ -1532,10 +1598,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } // set top/bottom coords - wallVerts[3].y = FIXED_TO_FLOAT(worldlow); - wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); - wallVerts[2].y = FIXED_TO_FLOAT(worldlowslope); - wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); + wallVerts[3].y = FixedToFloat(worldlow); + wallVerts[0].y = FixedToFloat(worldbottom); + wallVerts[2].y = FixedToFloat(worldlowslope); + wallVerts[1].y = FixedToFloat(worldbottomslope); if (!gl_drawing_stencil && gl_frontsector->numlights) HWR_SplitWall(gl_frontsector, wallVerts, gl_bottomtexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0); @@ -1696,10 +1762,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom // set top/bottom coords // Take the texture peg into account, rather than changing the offsets past // where the polygon might not be. - wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[0].y = FIXED_TO_FLOAT(l); - wallVerts[2].y = FIXED_TO_FLOAT(hS); - wallVerts[1].y = FIXED_TO_FLOAT(lS); + wallVerts[3].y = FixedToFloat(h); + wallVerts[0].y = FixedToFloat(l); + wallVerts[2].y = FixedToFloat(hS); + wallVerts[1].y = FixedToFloat(lS); // TODO: Actually use the surface's flags so that I don't have to do this FUINT blendmode = Surf.PolyFlags; @@ -1758,10 +1824,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } //Set textures properly on single sided walls that are sloped - wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); - wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); - wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); + wallVerts[3].y = FixedToFloat(worldtop); + wallVerts[0].y = FixedToFloat(worldbottom); + wallVerts[2].y = FixedToFloat(worldtopslope); + wallVerts[1].y = FixedToFloat(worldbottomslope); if (gl_frontsector->numlights) { @@ -1778,10 +1844,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom else { //Set textures properly on single sided walls that are sloped - wallVerts[3].y = FIXED_TO_FLOAT(worldtop); - wallVerts[0].y = FIXED_TO_FLOAT(worldbottom); - wallVerts[2].y = FIXED_TO_FLOAT(worldtopslope); - wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); + wallVerts[3].y = FixedToFloat(worldtop); + wallVerts[0].y = FixedToFloat(worldbottom); + wallVerts[2].y = FixedToFloat(worldtopslope); + wallVerts[1].y = FixedToFloat(worldbottomslope); // When there's no midtexture, draw a skywall to prevent rendering behind it HWR_DrawSkyWall(wallVerts, &Surf); @@ -1791,17 +1857,17 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { if (gl_frontsector->ceilingpic == skyflatnum) // It's a single-sided line with sky for its sector { - wallVerts[2].y = wallVerts[3].y = FIXED_TO_FLOAT(INT32_MAX); // draw to top of map space - wallVerts[0].y = FIXED_TO_FLOAT(worldtop); - wallVerts[1].y = FIXED_TO_FLOAT(worldtopslope); + wallVerts[2].y = wallVerts[3].y = FixedToFloat(INT32_MAX); // draw to top of map space + wallVerts[0].y = FixedToFloat(worldtop); + wallVerts[1].y = FixedToFloat(worldtopslope); HWR_DrawSkyWall(wallVerts, &Surf); } if (gl_frontsector->floorpic == skyflatnum) { - wallVerts[3].y = FIXED_TO_FLOAT(worldbottom); - wallVerts[2].y = FIXED_TO_FLOAT(worldbottomslope); - wallVerts[0].y = wallVerts[1].y = FIXED_TO_FLOAT(INT32_MIN); // draw to bottom of map space + wallVerts[3].y = FixedToFloat(worldbottom); + wallVerts[2].y = FixedToFloat(worldbottomslope); + wallVerts[0].y = wallVerts[1].y = FixedToFloat(INT32_MIN); // draw to bottom of map space HWR_DrawSkyWall(wallVerts, &Surf); } @@ -1830,13 +1896,15 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { for (rover = gl_backsector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || (rover->flags & FF_INVERTSIDES)) + const ffloortype_e roverflags = rover->flags; + + if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || (roverflags & FF_INVERTSIDES)) continue; SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) - if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) + if ((high1 < lowcut || highslope1 < lowcutslope) || (low1 > highcut || lowslope1 > highcutslope)) continue; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); @@ -1869,12 +1937,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom //FIXME: check if peging is correct // set top/bottom coords - wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[2].y = FIXED_TO_FLOAT(hS); - wallVerts[0].y = FIXED_TO_FLOAT(l); - wallVerts[1].y = FIXED_TO_FLOAT(lS); + wallVerts[3].y = FixedToFloat(h); + wallVerts[2].y = FixedToFloat(hS); + wallVerts[0].y = FixedToFloat(l); + wallVerts[1].y = FixedToFloat(lS); - if (rover->flags & FF_FOG) + if (roverflags & FF_FOG) { wallVerts[3].t = wallVerts[2].t = 0; wallVerts[0].t = wallVerts[1].t = 0; @@ -1935,7 +2003,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom } FBITFIELD blendmode; - if (rover->flags & FF_FOG) + if (roverflags & FF_FOG) { blendmode = PF_Fog|PF_NoTexture; @@ -1947,7 +2015,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gl_curline); if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, blendmode); + HWR_SplitWall(gl_frontsector, wallVerts, 0, false, &Surf, roverflags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } @@ -1955,14 +2023,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { blendmode = PF_Masked; - if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) + if ((roverflags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, blendmode); + HWR_SplitWall(gl_frontsector, wallVerts, texnum, noencore, &Surf, roverflags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -1978,13 +2046,15 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_ALLSIDES)) + const ffloortype_e roverflags = rover->flags; + + if (!(roverflags & FF_EXISTS) || !(roverflags & FF_RENDERSIDES) || !(roverflags & FF_ALLSIDES)) continue; SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) - if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) + if ((high1 < lowcut || highslope1 < lowcutslope) || (low1 > highcut || lowslope1 > highcutslope)) continue; texnum = R_GetTextureNum(sides[rover->master->sidenum[0]].midtexture); @@ -2017,12 +2087,12 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom //FIXME: check if peging is correct // set top/bottom coords - wallVerts[3].y = FIXED_TO_FLOAT(h); - wallVerts[2].y = FIXED_TO_FLOAT(hS); - wallVerts[0].y = FIXED_TO_FLOAT(l); - wallVerts[1].y = FIXED_TO_FLOAT(lS); + wallVerts[3].y = FixedToFloat(h); + wallVerts[2].y = FixedToFloat(hS); + wallVerts[0].y = FixedToFloat(l); + wallVerts[1].y = FixedToFloat(lS); - if (rover->flags & FF_FOG) + if (roverflags & FF_FOG) { wallVerts[3].t = wallVerts[2].t = 0; wallVerts[0].t = wallVerts[1].t = 0; @@ -2050,7 +2120,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom FBITFIELD blendmode; - if (rover->flags & FF_FOG) + if (roverflags & FF_FOG) { blendmode = PF_Fog|PF_NoTexture; @@ -2062,7 +2132,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom lightnum = (HWR_ShouldUsePaletteRendering() && colormap) ? lightnum : HWR_CalcWallLight(lightnum, gl_curline); if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, blendmode); + HWR_SplitWall(gl_backsector, wallVerts, 0, false, &Surf, roverflags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } @@ -2070,14 +2140,14 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom { blendmode = PF_Masked; - if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) + if ((roverflags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { blendmode = rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent; Surf.PolyColor.s.alpha = CLAMP(rover->alpha, 0, 255); } if (gl_backsector->numlights) - HWR_SplitWall(gl_backsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, blendmode); + HWR_SplitWall(gl_backsector, wallVerts, texnum, noencore, &Surf, roverflags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -2112,20 +2182,21 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) { fixed_t v1x, v1y, v2x, v2y; // the seg's vertexes as fixed_t - if (gl_curline->pv1) + if (LIKELY(gl_curline->pv1)) { - v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); - v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); + v1x = FloatToFixed(((polyvertex_t *)gl_curline->pv1)->x); + v1y = FloatToFixed(((polyvertex_t *)gl_curline->pv1)->y); } else { v1x = gl_curline->v1->x; v1y = gl_curline->v1->y; } - if (gl_curline->pv2) + + if (LIKELY(gl_curline->pv2)) { - v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); - v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); + v2x = FloatToFixed(((polyvertex_t *)gl_curline->pv2)->x); + v2y = FloatToFixed(((polyvertex_t *)gl_curline->pv2)->y); } else { @@ -2134,11 +2205,8 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) } #define SLOPEPARAMS(slope, end1, end2, normalheight) \ - if (slope) { \ - end1 = P_GetZAt(slope, v1x, v1y); \ - end2 = P_GetZAt(slope, v2x, v2y); \ - } else \ - end1 = end2 = normalheight; + end1 = P_GetZAt(slope, v1x, v1y, normalheight); \ + end2 = P_GetZAt(slope, v2x, v2y, normalheight); SLOPEPARAMS(afrontsector->f_slope, frontf1, frontf2, afrontsector->floorheight) SLOPEPARAMS(afrontsector->c_slope, frontc1, frontc2, afrontsector->ceilingheight) @@ -2155,7 +2223,7 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) } // using this check with portals causes weird culling issues on ante-station - if (!portalclipline && (afrontsector == viewsector || abacksector == viewsector)) + if (LIKELY(!portalclipline) && (afrontsector == viewsector || abacksector == viewsector)) { fixed_t viewf1, viewf2, viewc1, viewc2; if (afrontsector == viewsector) @@ -2185,10 +2253,7 @@ static boolean CheckClip(sector_t * afrontsector, sector_t * abacksector) if (backc1 <= frontf1 && backc2 <= frontf2) { checkforemptylines = false; - if (portalclipline)// during portal rendering view position may cause undesired culling and the above code has some wrong side effects - return false; - else - return true; + return (!portalclipline); // during portal rendering view position may cause undesired culling and the above code has some wrong side effects } // here we're talking about floors higher than ceilings, don't even bother either. @@ -2253,20 +2318,21 @@ static void HWR_AddLine(seg_t *line) gl_curline = line; - if (gl_curline->pv1) + if (LIKELY(gl_curline->pv1)) { - v1x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->x); - v1y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv1)->y); + v1x = FloatToFixed(((polyvertex_t *)gl_curline->pv1)->x); + v1y = FloatToFixed(((polyvertex_t *)gl_curline->pv1)->y); } else { v1x = gl_curline->v1->x; v1y = gl_curline->v1->y; } - if (gl_curline->pv2) + + if (LIKELY(gl_curline->pv2)) { - v2x = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->x); - v2y = FLOAT_TO_FIXED(((polyvertex_t *)gl_curline->pv2)->y); + v2x = FloatToFixed(((polyvertex_t *)gl_curline->pv2)->x); + v2y = FloatToFixed(((polyvertex_t *)gl_curline->pv2)->y); } else { @@ -2279,7 +2345,7 @@ static void HWR_AddLine(seg_t *line) angle2 = R_PointToAngle64(v2x, v2y); // PrBoom: Back side, i.e. backface culling - read: endAngle >= startAngle! - if (angle2 - angle1 < ANGLE_180 || !gl_curline->linedef) + if (angle2 - angle1 < ANGLE_180) return; // PrBoom: use REAL clipping math YAYYYYYYY!!! @@ -2290,7 +2356,7 @@ static void HWR_AddLine(seg_t *line) gl_backsector = line->backsector; - if (!cv_glportals.value || !gl_maphasportals) + if (!cv_glportals.value || LIKELY(!gl_maphasportals)) goto doaddline; // do extra checks on the seg when rendering portals: @@ -2351,7 +2417,7 @@ doaddline: return; } - if (gl_portal_state != GLPORTAL_SEARCH && !dont_draw)// no need to do this during the portal check + if (LIKELY(gl_portal_state != GLPORTAL_SEARCH && !dont_draw))// no need to do this during the portal check HWR_ProcessSeg(); // Doesn't need arguments because they're defined globally :D return; @@ -2514,7 +2580,7 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, Z_Malloc(numAllocedPlaneVerts * sizeof (FOutVector), PU_LEVEL, &planeVerts); } - height = FIXED_TO_FLOAT(fixedheight); + height = FixedToFloat(fixedheight); len = W_LumpLength(lumpnum); @@ -2551,8 +2617,8 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, } // reference point for flat texture coord for each vertex around the polygon - flatxref = FIXED_TO_FLOAT(polysector->origVerts[0].x); - flatyref = FIXED_TO_FLOAT(polysector->origVerts[0].y); + flatxref = FixedToFloat(polysector->origVerts[0].x); + flatyref = FixedToFloat(polysector->origVerts[0].y); flatxref = (float)(((fixed_t)flatxref & (~flatflag)) / fflatsize); flatyref = (float)(((fixed_t)flatyref & (~flatflag)) / fflatsize); @@ -2564,14 +2630,14 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(FOFsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->floor_yoffs)/fflatsize; + scrollx = FixedToFloat(FOFsector->floor_xoffs)/fflatsize; + scrolly = FixedToFloat(FOFsector->floor_yoffs)/fflatsize; angle = FOFsector->floorpic_angle>>ANGLETOFINESHIFT; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(FOFsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(FOFsector->ceiling_yoffs)/fflatsize; + scrollx = FixedToFloat(FOFsector->ceiling_xoffs)/fflatsize; + scrolly = FixedToFloat(FOFsector->ceiling_yoffs)/fflatsize; angle = FOFsector->ceilingpic_angle>>ANGLETOFINESHIFT; } } @@ -2579,14 +2645,14 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, { if (!isceiling) // it's a floor { - scrollx = FIXED_TO_FLOAT(gl_frontsector->floor_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gl_frontsector->floor_yoffs)/fflatsize; + scrollx = FixedToFloat(gl_frontsector->floor_xoffs)/fflatsize; + scrolly = FixedToFloat(gl_frontsector->floor_yoffs)/fflatsize; angle = gl_frontsector->floorpic_angle>>ANGLETOFINESHIFT; } else // it's a ceiling { - scrollx = FIXED_TO_FLOAT(gl_frontsector->ceiling_xoffs)/fflatsize; - scrolly = FIXED_TO_FLOAT(gl_frontsector->ceiling_yoffs)/fflatsize; + scrollx = FixedToFloat(gl_frontsector->ceiling_xoffs)/fflatsize; + scrolly = FixedToFloat(gl_frontsector->ceiling_yoffs)/fflatsize; angle = gl_frontsector->ceilingpic_angle>>ANGLETOFINESHIFT; } } @@ -2594,40 +2660,40 @@ static void HWR_RenderPolyObjectPlane(polyobj_t *polysector, boolean isceiling, if (angle) // Only needs to be done if there's an altered angle { // This needs to be done so that it scrolls in a different direction after rotation like software - tempxsow = FLOAT_TO_FIXED(scrollx); - tempytow = FLOAT_TO_FIXED(scrolly); - scrollx = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - scrolly = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); + tempxsow = FloatToFixed(scrollx); + tempytow = FloatToFixed(scrolly); + scrollx = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); + scrolly = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); // This needs to be done so everything aligns after rotation // It would be done so that rotation is done, THEN the translation, but I couldn't get it to rotate AND scroll like software does - tempxsow = FLOAT_TO_FIXED(flatxref); - tempytow = FLOAT_TO_FIXED(flatyref); - flatxref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - flatyref = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); + tempxsow = FloatToFixed(flatxref); + tempytow = FloatToFixed(flatyref); + flatxref = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); + flatyref = (FixedToFloat(FixedMul(tempxsow, FINESINE(angle)) + FixedMul(tempytow, FINECOSINE(angle)))); } for (i = 0; i < (INT32)nrPlaneVerts; i++,v3d++) { // Hurdler: add scrolling texture on floor/ceiling - v3d->s = (float)((FIXED_TO_FLOAT(polysector->origVerts[i].x) / fflatsize) - flatxref + scrollx); // Go from the polysector's original vertex locations - v3d->t = (float)(flatyref - (FIXED_TO_FLOAT(polysector->origVerts[i].y) / fflatsize) + scrolly); // Means the flat is offset based on the original vertex locations + v3d->s = (float)((FixedToFloat(polysector->origVerts[i].x) / fflatsize) - flatxref + scrollx); // Go from the polysector's original vertex locations + v3d->t = (float)(flatyref - (FixedToFloat(polysector->origVerts[i].y) / fflatsize) + scrolly); // Means the flat is offset based on the original vertex locations // Need to rotate before translate if (angle) // Only needs to be done if there's an altered angle { - tempxsow = FLOAT_TO_FIXED(v3d->s); - tempytow = FLOAT_TO_FIXED(v3d->t); - v3d->s = (FIXED_TO_FLOAT(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); - v3d->t = (FIXED_TO_FLOAT(-FixedMul(tempxsow, FINESINE(angle)) - FixedMul(tempytow, FINECOSINE(angle)))); + tempxsow = FloatToFixed(v3d->s); + tempytow = FloatToFixed(v3d->t); + v3d->s = (FixedToFloat(FixedMul(tempxsow, FINECOSINE(angle)) - FixedMul(tempytow, FINESINE(angle)))); + v3d->t = (FixedToFloat(-FixedMul(tempxsow, FINESINE(angle)) - FixedMul(tempytow, FINECOSINE(angle)))); } - v3d->x = FIXED_TO_FLOAT(polysector->vertices[i]->x); + v3d->x = FixedToFloat(polysector->vertices[i]->x); v3d->y = height; - v3d->z = FIXED_TO_FLOAT(polysector->vertices[i]->y); + v3d->z = FixedToFloat(polysector->vertices[i]->y); } - HWR_Lighting(&Surf, lightlevel, planecolormap); + HWR_Lighting(&Surf, lightlevel, planecolormap, P_SectorUsesDirectionalLighting((FOFsector != NULL) ? FOFsector : gl_frontsector)); if (blendmode & PF_Translucent) { @@ -2724,7 +2790,7 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v if (!cullheight) return false; - cullplane = FIXED_TO_FLOAT(cullheight->frontsector->floorheight); + cullplane = FixedToFloat(cullheight->frontsector->floorheight); if (cullheight->flags & ML_NOCLIMB) // Group culling { @@ -2839,7 +2905,7 @@ static void HWR_Subsector(size_t num) sector_t *controlSec = §ors[rover->secnum]; - if (controlSec->moved != true) + if (!controlSec->moved) continue; anyMoved = true; @@ -2910,7 +2976,7 @@ static void HWR_Subsector(size_t num) { fixed_t bottomCullHeight, topCullHeight, centerHeight; - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) continue; if (sub->validcount == validcount) continue; @@ -2922,7 +2988,7 @@ static void HWR_Subsector(size_t num) if (gl_frontsector->cullheight) { - if (HWR_DoCulling(gl_frontsector->cullheight, viewsector->cullheight, gl_viewz, FIXED_TO_FLOAT(*rover->bottomheight), FIXED_TO_FLOAT(*rover->topheight))) + if (HWR_DoCulling(gl_frontsector->cullheight, viewsector->cullheight, gl_viewz, FixedToFloat(*rover->bottomheight), FixedToFloat(*rover->topheight))) continue; } @@ -3068,11 +3134,22 @@ doaddline: // without talking about the overdraw of course. sub->sector->validcount = validcount;/// \todo fix that in a better way - while (count--) + if (UNLIKELY(numPolyObjects)) { - if (!line->polyseg) // ignore segs that belong to polyobjects + while (count--) + { + if (LIKELY(!line->polyseg)) // ignore segs that belong to polyobjects + HWR_AddLine(line); + line++; + } + } + else + { + while (count--) + { HWR_AddLine(line); - line++; + line++; + } } } @@ -3243,11 +3320,11 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) 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 && ((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->flags & SF_HIRES); + const boolean hires = (spr->mobj && spr->mobj->skin && K_GetMobjSkin(spr->mobj)->flags & SF_HIRES); if (spr->mobj) - this_scale = FIXED_TO_FLOAT(spr->mobj->scale); + this_scale = FixedToFloat(spr->mobj->scale); if (hires) - this_scale = this_scale * FIXED_TO_FLOAT(((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->highresscale); + this_scale = this_scale * FixedToFloat(K_GetMobjSkin(spr->mobj)->highresscale); R_GetShadowZ(spr->mobj, &floorslope); @@ -3349,8 +3426,8 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) { for (int i = 0; i < 4; i++) { - slopez = P_GetZAt(floorslope, FLOAT_TO_FIXED(swallVerts[i].x), FLOAT_TO_FIXED(swallVerts[i].z)); - swallVerts[i].y = FIXED_TO_FLOAT(slopez) + 0.05f; + slopez = P_GetSlopeZAt(floorslope, FloatToFixed(swallVerts[i].x), FloatToFixed(swallVerts[i].z)); + swallVerts[i].y = FixedToFloat(slopez) + 0.05f; } } @@ -3443,11 +3520,11 @@ static void HWR_RotateSpritePolyToAim(gl_vissprite_t *spr, FOutVector *wallVerts if (!precip && P_MobjFlip(spr->mobj) == -1) // precip doesn't have eflags so they can't flip { - basey = FIXED_TO_FLOAT(interp.z + spr->mobj->height); + basey = FixedToFloat(interp.z + spr->mobj->height); } else { - basey = FIXED_TO_FLOAT(interp.z); + basey = FixedToFloat(interp.z); } lowy = wallVerts[0].y; @@ -3494,7 +3571,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) GLPatch_t *gpatch; FSurfaceInfo Surf; extracolormap_t *colormap; - FUINT lightlevel; + INT32 lightlevel; + boolean lightset = true; FBITFIELD blend = 0; UINT8 alpha; @@ -3539,10 +3617,10 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) baseWallVerts[2].y = baseWallVerts[3].y = spr->gzt; baseWallVerts[0].y = baseWallVerts[1].y = spr->gz; - v1x = FLOAT_TO_FIXED(spr->x1); - v1y = FLOAT_TO_FIXED(spr->z1); - v2x = FLOAT_TO_FIXED(spr->x2); - v2y = FLOAT_TO_FIXED(spr->z2); + v1x = FloatToFixed(spr->x1); + v1y = FloatToFixed(spr->z1); + v2x = FloatToFixed(spr->x2); + v2y = FloatToFixed(spr->z2); if (spr->flip) { @@ -3628,12 +3706,9 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) colormap = list[sector->numlights - 1].extra_colormap; i = 0; - temp = FLOAT_TO_FIXED(realtop); + temp = FloatToFixed(realtop); - if (R_ThingIsFullBright(spr->mobj)) - lightlevel = 255; - else if (R_ThingIsFullDark(spr->mobj)) - lightlevel = 0; + lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); for (i = 1; i < sector->numlights; i++) { @@ -3641,14 +3716,14 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) if (!(h <= temp)) continue; - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (!lightset) lightlevel = min(*list[i-1].lightlevel, 255); colormap = list[i-1].extra_colormap; break; } - if (R_ThingIsSemiBright(spr->mobj)) - lightlevel = 128 + (lightlevel>>1); + if (!lightset) + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); for (i = 0; i < sector->numlights; i++) { @@ -3658,17 +3733,21 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) // even if we aren't changing colormap or lightlevel, we still need to continue drawing down the sprite if (!(list[i].flags & FF_NOSHADE) && (list[i].flags & FF_CUTSPRITES)) { - if (!(spr->mobj->frame & FF_FULLBRIGHT)) + if (!lightset) + { lightlevel = min(*list[i].lightlevel, 255); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); + } + colormap = list[i].extra_colormap; } if (i + 1 < sector->numlights) { temp = P_GetLightZAt(&list[i+1], v1x, v1y); - bheight = FIXED_TO_FLOAT(temp); + bheight = FixedToFloat(temp); temp = P_GetLightZAt(&list[i+1], v2x, v2y); - endbheight = FIXED_TO_FLOAT(temp); + endbheight = FixedToFloat(temp); } else { @@ -3720,7 +3799,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) wallVerts[1].z = baseWallVerts[2].z + (baseWallVerts[2].z - baseWallVerts[1].z) * heightmult; } - HWR_Lighting(&Surf, lightlevel, colormap); + HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT)); Surf.PolyColor.s.alpha = alpha; @@ -3747,7 +3826,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) wallVerts[0].y = bot; wallVerts[1].y = endbot; - HWR_Lighting(&Surf, lightlevel, colormap); + HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector)); Surf.PolyColor.s.alpha = alpha; @@ -3765,19 +3844,16 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) GLPatch_t *gpatch; // sprite patch converted to hardware FSurfaceInfo Surf; FBITFIELD blend = 0; - INT32 blendmode; INT32 shader = SHADER_NONE; - if (P_MobjWasRemoved(spr->mobj)) - return; - - if (!spr->mobj->subsector) + if (!spr->mobj || !spr->mobj->subsector) return; const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE); + sector_t *sector = spr->mobj->subsector->sector; - if (spr->mobj->subsector->sector->numlights) + if (sector->numlights) { HWR_SplitSprite(spr, papersprite); return; @@ -3813,7 +3889,9 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) { wallVerts[0].s = wallVerts[3].s = gpatch->max_s; wallVerts[2].s = wallVerts[1].s = 0; - }else{ + } + else + { wallVerts[0].s = wallVerts[3].s = 0; wallVerts[2].s = wallVerts[1].s = gpatch->max_s; } @@ -3823,7 +3901,9 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) { wallVerts[3].t = wallVerts[2].t = gpatch->max_t; wallVerts[0].t = wallVerts[1].t = 0; - }else{ + } + else + { wallVerts[3].t = wallVerts[2].t = 0; wallVerts[0].t = wallVerts[1].t = gpatch->max_t; } @@ -3853,20 +3933,20 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) /// \todo coloured // colormap test - sector_t *sector = spr->mobj->subsector->sector; - UINT8 lightlevel = 255; + INT32 lightlevel = 255; + boolean lightset = HWR_OverrideObjectLightLevel(spr->mobj, &lightlevel); extracolormap_t *colormap = sector->extra_colormap; + const boolean fullbright = R_ThingIsFullBright(spr->mobj); - if (R_ThingIsFullDark(spr->mobj)) - lightlevel = 0; - else if (!(R_ThingIsFullBright(spr->mobj))) + if (!lightset) + { lightlevel = min(sector->lightlevel, 255); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false); + } - if (R_ThingIsSemiBright(spr->mobj)) - lightlevel = 128 + (lightlevel>>1); - - HWR_Lighting(&Surf, lightlevel, colormap); + 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; else @@ -3977,7 +4057,7 @@ static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) colormap = sector->extra_colormap; } - HWR_Lighting(&Surf, lightlevel, colormap); + HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector)); if (spr->mobj->frame & FF_TRANSMASK) { @@ -4239,12 +4319,15 @@ static void HWR_RenderDrawNodes(void) { if (drawnodes[sortindex[i]].type != DRAWNODE_PLANE) break; } + run_end = i-1; + if (run_end > run_start) // if there are multiple consecutive planes, not just one { // consecutive run of planes found, now sort it qs22j(sortindex + run_start, run_end - run_start + 1, sizeof(INT32), CompareDrawNodePlanes); } + run_start = run_end + 1; // continue looking for runs coming right after this one } else @@ -4265,41 +4348,49 @@ static void HWR_RenderDrawNodes(void) { gl_drawnode_t *drawnode = &drawnodes[sortindex[i]]; - if (drawnode->type == DRAWNODE_PLANE) + switch (drawnode->type) { - planeinfo_t *plane = &drawnode->u.plane; + case DRAWNODE_PLANE: + { + planeinfo_t *plane = &drawnode->u.plane; - // We aren't traversing the BSP tree, so make gl_frontsector null to avoid crashes. - gl_frontsector = NULL; + // We aren't traversing the BSP tree, so make gl_frontsector null to avoid crashes. + gl_frontsector = NULL; - if (!(plane->blend & PF_NoTexture)) - HWR_GetFlat(plane->lumpnum, R_NoEncore(plane->FOFSector, plane->isceiling)); + if (!(plane->blend & PF_NoTexture)) + HWR_GetFlat(plane->lumpnum, R_NoEncore(plane->FOFSector, plane->isceiling)); - HWR_RenderPlane(NULL, plane->xsub, plane->isceiling, plane->fixedheight, plane->blend, plane->lightlevel, - plane->lumpnum, plane->FOFSector, plane->alpha, plane->planecolormap); - } - else if (drawnode->type == DRAWNODE_POLYOBJECT_PLANE) - { - polyplaneinfo_t *polyplane = &drawnode->u.polyplane; + HWR_RenderPlane(NULL, plane->xsub, plane->isceiling, plane->fixedheight, plane->blend, plane->lightlevel, + plane->lumpnum, plane->FOFSector, plane->alpha, plane->planecolormap); + break; + } + case DRAWNODE_POLYOBJECT_PLANE: + { + polyplaneinfo_t *polyplane = &drawnode->u.polyplane; - // We aren't traversing the BSP tree, so make gl_frontsector null to avoid crashes. - gl_frontsector = NULL; + // We aren't traversing the BSP tree, so make gl_frontsector null to avoid crashes. + gl_frontsector = NULL; - if (!(polyplane->blend & PF_NoTexture)) - HWR_GetFlat(polyplane->lumpnum, R_NoEncore(polyplane->FOFSector, polyplane->isceiling)); + if (!(polyplane->blend & PF_NoTexture)) + HWR_GetFlat(polyplane->lumpnum, R_NoEncore(polyplane->FOFSector, polyplane->isceiling)); - HWR_RenderPolyObjectPlane(polyplane->polysector, polyplane->isceiling, polyplane->fixedheight, polyplane->blend, polyplane->lightlevel, - polyplane->lumpnum, polyplane->FOFSector, polyplane->alpha, polyplane->planecolormap); - } - else if (drawnode->type == DRAWNODE_WALL) - { - wallinfo_t *wall = &drawnode->u.wall; + HWR_RenderPolyObjectPlane(polyplane->polysector, polyplane->isceiling, polyplane->fixedheight, polyplane->blend, polyplane->lightlevel, + polyplane->lumpnum, polyplane->FOFSector, polyplane->alpha, polyplane->planecolormap); + break; + } + case DRAWNODE_WALL: + { + wallinfo_t *wall = &drawnode->u.wall; - if (!(wall->blend & PF_NoTexture)) - HWR_GetTexture(wall->texnum, wall->noencore); + if (!(wall->blend & PF_NoTexture)) + HWR_GetTexture(wall->texnum, wall->noencore); - HWR_RenderWall(wall->wallVerts, &wall->Surf, wall->blend, wall->fogwall, - wall->lightlevel, wall->wallcolormap); + HWR_RenderWall(wall->wallVerts, &wall->Surf, wall->blend, wall->fogwall, + wall->lightlevel, wall->wallcolormap); + break; + } + default: + break; } } @@ -4383,7 +4474,7 @@ static void HWR_DrawModels(void) static void HWR_AddSprites(sector_t *sec) { mobj_t *thing; - fixed_t limit_dist; + INT32 limit_dist; // BSP is traversed by subsector. // A sector might have been split into several @@ -4395,16 +4486,16 @@ static void HWR_AddSprites(sector_t *sec) // Well, now it will be done. sec->validcount = validcount; + limit_dist = cv_drawdist.value; + if (current_bsp_culling_distance) { // Use the smaller setting - if (cv_drawdist.value) - limit_dist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist.value) * mapobjectscale); + if (limit_dist) + limit_dist = min(current_bsp_culling_distance/mapobjectscale, limit_dist); else - limit_dist = (fixed_t)current_bsp_culling_distance; + limit_dist = current_bsp_culling_distance/mapobjectscale; } - else - limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; // Handle all things in sector. for (thing = sec->thinglist; thing; thing = thing->snext) @@ -4438,13 +4529,7 @@ static void HWR_AddPrecipitationSprites(void) return; } - const fixed_t precipscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); - //const fixed_t drawdist = cv_drawdist_precip.value * mapobjectscale; - - if (current_bsp_culling_distance) - drawdist = min((fixed_t)current_bsp_culling_distance, (fixed_t)(cv_drawdist_precip.value) * precipscale); - else - drawdist = ((fixed_t)(cv_drawdist_precip.value) * precipscale); + drawdist = ((fixed_t)(cv_drawdist_precip.value) * (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT)); // No to infinite precipitation draw distance. if (drawdist == 0) @@ -4452,6 +4537,9 @@ static void HWR_AddPrecipitationSprites(void) return; } + if (current_bsp_culling_distance) + drawdist = min((fixed_t)current_bsp_culling_distance, drawdist); + R_GetRenderBlockMapDimensions(drawdist, &xl, &xh, &yl, &yh); for (bx = xl; bx <= xh; bx++) @@ -4488,7 +4576,6 @@ static void HWR_ProjectSprite(mobj_t *thing) float this_scale; float spritexscale, spriteyscale; float gz, gzt; - INT32 blendmode; spritedef_t *sprdef; spriteframe_t *sprframe; #ifdef ROTSPRITE @@ -4514,7 +4601,7 @@ static void HWR_ProjectSprite(mobj_t *thing) angle_t sliptiderollangle = 0; #endif - if (P_MobjWasRemoved(thing) || thing->subsector == NULL) + if (!thing || thing->subsector == NULL) return; // uncapped/interpolation @@ -4537,6 +4624,7 @@ static void HWR_ProjectSprite(mobj_t *thing) const boolean papersprite = (thing->frame & FF_PAPERSPRITE); + INT32 blendmode; if (thing->frame & FF_BLENDMASK) blendmode = ((thing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; else @@ -4550,8 +4638,8 @@ static void HWR_ProjectSprite(mobj_t *thing) } // transform the origin point - tr_x = FIXED_TO_FLOAT(interp.x); - tr_y = FIXED_TO_FLOAT(interp.y); + tr_x = FixedToFloat(interp.x); + tr_y = FixedToFloat(interp.y); // rotation around vertical axis tz = ((tr_x - gl_viewx) * gl_viewcos) + ((tr_y - gl_viewy) * gl_viewsin); @@ -4564,9 +4652,9 @@ static void HWR_ProjectSprite(mobj_t *thing) const boolean vflip = (thing->eflags & MFE_VERTICALFLIP); const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); - this_scale = FIXED_TO_FLOAT(interp.scale); - spritexscale = FIXED_TO_FLOAT(interp.spritexscale); - spriteyscale = FIXED_TO_FLOAT(interp.spriteyscale); + this_scale = FixedToFloat(interp.scale); + spritexscale = FixedToFloat(interp.spritexscale); + spriteyscale = FixedToFloat(interp.spriteyscale); // decide which patch to use for sprite relative to player #ifdef RANGECHECK @@ -4579,15 +4667,15 @@ static void HWR_ProjectSprite(mobj_t *thing) #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.roll || interp.pitch || interp.sloperoll || interp.slopepitch || thing->rollangle || sliprollrotate); + 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) { - sprdef = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->spritedef; + sprdef = &K_GetMobjSkin(thing)->spritedef; #ifdef ROTSPRITE - sprinfo = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->sprinfo; + sprinfo = &K_GetMobjSkin(thing)->sprinfo; #endif } else @@ -4666,8 +4754,8 @@ static void HWR_ProjectSprite(mobj_t *thing) flip ^= (1<skin && ((skin_t *)(thing->localskin ? thing->localskin : thing->skin))->flags & SF_HIRES) - this_scale *= FIXED_TO_FLOAT(((skin_t *)(thing->localskin ? thing->localskin : thing->skin))->highresscale); + if ((thing->skin || thing->localskin) && K_GetMobjSkin(thing)->flags & SF_HIRES) + this_scale *= FixedToFloat(K_GetMobjSkin(thing)->highresscale); spr_width = spritecachedinfo[lumpoff].width; spr_height = spritecachedinfo[lumpoff].height; @@ -4693,7 +4781,7 @@ static void HWR_ProjectSprite(mobj_t *thing) pitchnroll += rollangle; rollangle = R_GetRollAngle(pitchnroll); - rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle); if (rotsprite != NULL) { @@ -4715,13 +4803,13 @@ static void HWR_ProjectSprite(mobj_t *thing) if (papersprite) { - rightsin = FIXED_TO_FLOAT(FINESINE(interp.angle >> ANGLETOFINESHIFT)); - rightcos = FIXED_TO_FLOAT(FINECOSINE(interp.angle >> ANGLETOFINESHIFT)); + rightsin = FixedToFloat(FINESINE(interp.angle >> ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE(interp.angle >> ANGLETOFINESHIFT)); } else { - rightsin = FIXED_TO_FLOAT(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - rightcos = FIXED_TO_FLOAT(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); } spritexscale *= this_scale; @@ -4731,13 +4819,13 @@ static void HWR_ProjectSprite(mobj_t *thing) if (flip) { - x1 = (FIXED_TO_FLOAT(spr_width - spr_offset) * spritexscale); - x2 = (FIXED_TO_FLOAT(spr_offset) * spritexscale); + x1 = (FixedToFloat(spr_width - spr_offset) * spritexscale); + x2 = (FixedToFloat(spr_offset) * spritexscale); } else { - x1 = (FIXED_TO_FLOAT(spr_offset) * spritexscale); - x2 = (FIXED_TO_FLOAT(spr_width - spr_offset) * spritexscale); + x1 = (FixedToFloat(spr_offset) * spritexscale); + x2 = (FixedToFloat(spr_width - spr_offset) * spritexscale); } z1 = tr_y + x1 * rightsin; @@ -4747,13 +4835,13 @@ static void HWR_ProjectSprite(mobj_t *thing) if (vflip) { - gz = FIXED_TO_FLOAT(interp.z + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * spriteyscale); - gzt = gz + (FIXED_TO_FLOAT(spr_height) * spriteyscale); + gz = FixedToFloat(interp.z + thing->height) - (FixedToFloat(spr_topoffset) * spriteyscale); + gzt = gz + (FixedToFloat(spr_height) * spriteyscale); } else { - gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spr_topoffset) * spriteyscale); - gz = gzt - (FIXED_TO_FLOAT(spr_height) * spriteyscale); + gzt = FixedToFloat(interp.z) + (FixedToFloat(spr_topoffset) * spriteyscale); + gz = gzt - (FixedToFloat(spr_height) * spriteyscale); } if (thing->subsector->sector->cullheight) @@ -4770,13 +4858,13 @@ static void HWR_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { - if (gl_viewz < FIXED_TO_FLOAT(sectors[phs].floorheight) ? - FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) : - gzt < FIXED_TO_FLOAT(sectors[heightsec].floorheight)) + if (gl_viewz < FixedToFloat(sectors[phs].floorheight) ? + FixedToFloat(interp.z) >= FixedToFloat(sectors[heightsec].floorheight) : + gzt < FixedToFloat(sectors[heightsec].floorheight)) return; - if (gl_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ? - gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gl_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) : - FIXED_TO_FLOAT(interp.z) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight)) + if (gl_viewz > FixedToFloat(sectors[phs].ceilingheight) ? + gzt < FixedToFloat(sectors[heightsec].ceilingheight) && gl_viewz >= FixedToFloat(sectors[heightsec].ceilingheight) : + FixedToFloat(interp.z) >= FixedToFloat(sectors[heightsec].ceilingheight)) return; } @@ -4795,8 +4883,8 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->scale = this_scale; vis->spritexscale = spritexscale; vis->spriteyscale = spriteyscale; - vis->spritexoffset = FIXED_TO_FLOAT(spr_offset); - vis->spriteyoffset = FIXED_TO_FLOAT(spr_topoffset); + vis->spritexoffset = FixedToFloat(spr_offset); + vis->spriteyoffset = FixedToFloat(spr_topoffset); #ifdef ROTSPRITE if (rotsprite != NULL) @@ -4868,15 +4956,15 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) if (!thing) return; - // uncapped/interpolation - interpmobjstate_t interp = {0}; - // okay... this is a hack, but weather isn't networked, so it should be ok if (!P_PrecipThinker(thing)) { return; } + // uncapped/interpolation + interpmobjstate_t interp = {0}; + if (cv_maxinterpdist.value) dist = R_QuickCamDist(thing->x, thing->y); @@ -4898,8 +4986,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) } // transform the origin point - tr_x = FIXED_TO_FLOAT(interp.x); - tr_y = FIXED_TO_FLOAT(interp.y); + tr_x = FixedToFloat(interp.x); + tr_y = FixedToFloat(interp.y); // rotation around vertical axis tz = ((tr_x - gl_viewx) * gl_viewcos) + ((tr_y - gl_viewy) * gl_viewsin); @@ -4931,7 +5019,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #endif } - this_scale = FIXED_TO_FLOAT(interp.scale); + this_scale = FixedToFloat(interp.scale); sprframe = &sprdef->spriteframes[thing->frame & FF_FRAMEMASK]; @@ -4939,17 +5027,18 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) lumpoff = sprframe->lumpid[0]; flip = sprframe->flip; // Will only be 0x00 or 0xFF - rightsin = FIXED_TO_FLOAT(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - rightcos = FIXED_TO_FLOAT(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + if (flip) { - x1 = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); - x2 = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].offset); + x1 = FixedToFloat(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); + x2 = FixedToFloat(spritecachedinfo[lumpoff].offset); } else { - x1 = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].offset); - x2 = FIXED_TO_FLOAT(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); + x1 = FixedToFloat(spritecachedinfo[lumpoff].offset); + x2 = FixedToFloat(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); } x1 *= this_scale; @@ -4982,8 +5071,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #endif // set top/bottom coords - vis->gzt = FIXED_TO_FLOAT(interp.z) + (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].topoffset) * this_scale); - vis->gz = vis->gzt - (FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height) * this_scale); + vis->gzt = FixedToFloat(interp.z) + (FixedToFloat(spritecachedinfo[lumpoff].topoffset) * this_scale); + vis->gz = vis->gzt - (FixedToFloat(spritecachedinfo[lumpoff].height) * this_scale); vis->precip = true; } @@ -5139,6 +5228,9 @@ void HWR_BuildSkyDome(void) static boolean drewsky = false; +// precompute to save a bit of division +static const float FINEDEGREE = (360.0f/(float)FINEANGLES); + static void HWR_DrawSkyBackground(void) { FTransform dometransform; @@ -5157,7 +5249,7 @@ static void HWR_DrawSkyBackground(void) //04/01/2000: Hurdler: added for T&L // It should replace all other gl_viewxxx when finished HWR_SetTransformAiming(&dometransform); - dometransform.angley = (float)((viewangle-ANGLE_270)>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); + dometransform.angley = (float)((viewangle-ANGLE_270)>>ANGLETOFINESHIFT)*(FINEDEGREE); HWR_GetTexture(texturetranslation[skytexture], false); @@ -5215,7 +5307,7 @@ static void HWR_SetTransformAiming(FTransform *trans) if (cv_glshearing.value) { fixed_t fixedaiming = AIMINGTODY(aimingangle); - trans->viewaiming = FIXED_TO_FLOAT(fixedaiming); + trans->viewaiming = FixedToFloat(fixedaiming); trans->shearing = true; gl_aimingangle = 0; } @@ -5224,7 +5316,7 @@ static void HWR_SetTransformAiming(FTransform *trans) trans->shearing = false; gl_aimingangle = aimingangle; } - trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); + trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(FINEDEGREE); } void HWR_SetTransform(float fpov) @@ -5232,11 +5324,11 @@ void HWR_SetTransform(float fpov) UINT8 viewnum = R_GetViewNumber(); camera_t *thiscam = &camera[viewnum]; - gl_viewx = FIXED_TO_FLOAT(viewx); - gl_viewy = FIXED_TO_FLOAT(viewy); - gl_viewz = FIXED_TO_FLOAT(viewz); - gl_viewsin = FIXED_TO_FLOAT(viewsin); - gl_viewcos = FIXED_TO_FLOAT(viewcos); + gl_viewx = FixedToFloat(viewx); + gl_viewy = FixedToFloat(viewy); + gl_viewz = FixedToFloat(viewz); + gl_viewsin = FixedToFloat(viewsin); + gl_viewcos = FixedToFloat(viewcos); memset(&atransform, 0x00, sizeof(FTransform)); @@ -5250,10 +5342,10 @@ void HWR_SetTransform(float fpov) atransform.scalez = 1; HWR_SetTransformAiming(&atransform); - atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); + atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(FINEDEGREE); - gl_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT)); - gl_viewludcos = FIXED_TO_FLOAT(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT)); + gl_viewludsin = FixedToFloat(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT)); + gl_viewludcos = FixedToFloat(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT)); atransform.fovangle = fpov; // Tails HWR_RollTransform(&atransform, viewroll); @@ -5302,7 +5394,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl const boolean skybox = (skyboxmo[0] && cv_skybox.value); const boolean useportals = cv_glportals.value && gl_maphasportals && allow_portals; - bspfunc bspFunc = portalclipline ? HWR_RenderPortalBSPNode : HWR_RenderBSPNode; + bspfunc bspFunc = (useportals && portalclipline) ? HWR_RenderPortalBSPNode : HWR_RenderBSPNode; portallist.base = portallist.cap = NULL; @@ -5405,7 +5497,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl HWR_SortVisSprites(); PS_STOP_TIMING(ps_hw_spritesorttime); PS_START_TIMING(ps_hw_spritedrawtime); - if (!cv_glmdls.value) + if (LIKELY(!cv_glmdls.value)) HWR_DrawSprites(); else HWR_DrawModels(); @@ -5455,6 +5547,9 @@ static void HWR_RenderFrame(player_t *player, boolean skybox) } } + // check for new console commands. + NetUpdate(); + // Clear view, set viewport (glViewport), set perspective... HWR_ClearView(); @@ -5488,6 +5583,9 @@ static void HWR_RenderFrame(player_t *player, boolean skybox) if (!skybox) HWR_DoPostProcessor(player); + // Check for new console commands. + NetUpdate(); + // added by Hurdler for correct splitscreen // moved here by hurdler so it works with the new near clipping plane GL_GClipRect(0, 0, vid.width, vid.height, NZCLIP_PLANE, FAR_ZCLIP_DEFAULT); @@ -5527,9 +5625,17 @@ void HWR_RenderPlayerView(void) GL_ClearBuffer(true, false, false, &ClearColor); } - if (HWR_UseShader() && cv_ripplewater.value) + if (HWR_UseShader()) { - GL_SetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime. + if (cv_ripplewater.value) + GL_SetShaderInfo(HWD_SHADERINFO_LEVELTIME, (INT32)leveltime); // The water surface shader needs the leveltime. + const angle_t light_angle = maplighting.angle - viewangle + ANGLE_90; // I fucking hate OGL's coordinate system + GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_X, FINECOSINE(light_angle >> ANGLETOFINESHIFT)); + GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_Y, 0); + GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_Z, -FINESINE(light_angle >> ANGLETOFINESHIFT)); + + GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_CONTRAST, maplighting.contrast); + GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_BACKLIGHT, maplighting.backlight); } if (viewssnum > 3) @@ -5550,6 +5656,39 @@ void HWR_RenderPlayerView(void) HWR_RenderFrame(player, false); } +static void HWR_CheckForHorizonLines(void) +{ + size_t i; + INT32 h; + + gl_maphashorizonlines = false; + + if (!cv_glhorizonlines.value) + return; + + for (i = 0; i < numsubsectors; i++) + { + subsector_t *subsec = &subsectors[i]; + + // sector checked already? + if (subsec->validcount == validcount) + continue; + + subsec->validcount = validcount; + + seg_t *line = &segs[subsec->firstline]; + + for (h = 0; h < subsec->numlines; h++, line++) + { + if (line->linedef->special != HORIZONSPECIAL) + continue; + + gl_maphashorizonlines = true; + break; + } + } +} + void HWR_LoadLevel(void) { // Lactozilla (December 8, 2019) @@ -5569,6 +5708,8 @@ void HWR_LoadLevel(void) HWR_ClearSkyDome(); HWR_BuildSkyDome(); + HWR_CheckForHorizonLines(); + if (HWR_ShouldUsePaletteRendering()) HWR_SetMapPalette(); } @@ -5619,6 +5760,8 @@ static void HWR_TogglePaletteRendering(void) //added by Hurdler: console varibale that are saved void HWR_AddCommands(void) { + CV_RegisterVar(&cv_gltexturedepth); + CV_RegisterVar(&cv_glscreentextures); #ifdef USE_FBO_OGL @@ -5718,7 +5861,7 @@ static void COM_HWR_glinfo(void) CONS_Printf("Unrecognized argument: %s\n", argv); return; } - + } CONS_Printf("\x88OpenGL %s\x80\n", gl_version); @@ -5777,7 +5920,7 @@ static void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD INT32 shader = SHADER_NONE; // Lighting is done here instead so that fog isn't drawn incorrectly on transparent walls after sorting - HWR_Lighting(pSurf, lightlevel, wallcolormap); + HWR_Lighting(pSurf, lightlevel, wallcolormap, P_SectorUsesDirectionalLighting(gl_frontsector)); pSurf->PolyColor.s.alpha = alpha; // put the alpha back after lighting @@ -5854,7 +5997,7 @@ static void HWR_DoPostProcessor(player_t *player) { // 10 by 10 grid. 2 coordinates (xy) float v[SCREENVERTS][SCREENVERTS][2]; - float disStart = (leveltime-1) + FIXED_TO_FLOAT(rendertimefrac); + float disStart = (leveltime-1) + FixedToFloat(rendertimefrac); UINT8 x, y; INT32 WAVELENGTH; diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 8263fa438..ba093c6ca 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -118,7 +118,7 @@ void HWR_SetStencilState(int state, int level); // into files like hw_bsp.c, hw_sprites.c... // hw_main.c: Lighting and fog -void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap); +void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap, const boolean directional); UINT8 HWR_GetTranstableAlpha(INT32 transtablenum); FBITFIELD HWR_GetBlendModeFlag(INT32 ast); @@ -178,6 +178,8 @@ RGBA_t *HWR_GetTexturePalette(void); // Console variables extern CV_PossibleValue_t glanisotropicmode_cons_t[]; +extern consvar_t cv_gltexturedepth; + extern consvar_t cv_glscreentextures; #ifdef USE_FBO_OGL extern consvar_t cv_glframebuffer; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index cf934d725..f109ddd41 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -403,7 +403,7 @@ static void md2_loadTexture(md2_t *model) glpatch->height = (INT16)h; glpatch->mipmap->width = (UINT16)w; glpatch->mipmap->height = (UINT16)h; - + // for palette rendering, color cube is applied in post-processing instead of here if (!HWR_ShouldUsePaletteRendering()) { @@ -607,7 +607,7 @@ void HWR_AddPlayerMD2(int skin, boolean local) // For MD2's that were added afte // Check for any MD2s that match the names of player skins! while (fscanf(f, "%19s %31s %f %f", name, filename, &scale, &offset) == 4) { - if (stricmp(name, ( (local) ? localskins : skins )[skin].name) == 0) + if (stricmp(name, K_GetSkinArray(local)[skin].name) == 0) { md2s[skin].skin = skin; md2s[skin].scale = scale; @@ -1120,7 +1120,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) { sector_t *sector = spr->mobj->subsector->sector; extracolormap_t *colormap = sector->extra_colormap; - UINT8 lightlevel = 255; + INT32 lightlevel = 255; if (sector->numlights) { @@ -1143,7 +1143,9 @@ void HWR_DrawMD2(gl_vissprite_t *spr) colormap = sector->extra_colormap; } - HWR_Lighting(&Surf, lightlevel, colormap); + HWR_ObjectLightLevelPost(spr, sector, &lightlevel, true); + + HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT)); } else { @@ -1177,13 +1179,13 @@ void HWR_DrawMD2(gl_vissprite_t *spr) // Apparently people don't like jump frames like that, so back it goes //if (tics > durs) //durs = tics; - + INT32 blendmode; if (spr->mobj->frame & FF_BLENDMASK) blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; else blendmode = spr->mobj->blendmode; - + blendmode = min(AST_MODULATE, blendmode); if (spr->mobj->flags2 & MF2_SHADOW) @@ -1205,7 +1207,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) // dont forget to enabled the depth test because we can't do this like // before: polygons models are not sorted - + /* fuck you */ if (spr->mobj->localskin) { @@ -1296,7 +1298,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) tcskinnum = TC_RAINBOW; else { - tcskinnum = (INT32)((skin_t*)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ) - ( (spr->mobj->skinlocal) ? localskins : skins )); + tcskinnum = (INT32)(K_GetMobjSkinNum(K_GetMobjSkin(spr->mobj), spr->mobj->skinlocal)); } } else tcskinnum = TC_DEFAULT; @@ -1362,8 +1364,8 @@ void HWR_DrawMD2(gl_vissprite_t *spr) else p.z = FIXED_TO_FLOAT(interp.z); - if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) - sprdef = &((skin_t *)( (spr->mobj->localskin) ? spr->mobj->localskin : spr->mobj->skin ))->spritedef; + if ((spr->mobj->skin || spr->mobj->localskin) && spr->mobj->sprite == SPR_PLAY) + sprdef = &K_GetMobjSkin(spr->mobj)->spritedef; else sprdef = &sprites[spr->mobj->sprite]; diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 8f039e4e8..b4041fcae 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -36,7 +36,7 @@ static struct { {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Model shader - {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, + {GLSL_MODEL_LIGHTING_VERTEX_SHADER, GLSL_WALL_FRAGMENT_SHADER}, // Water shader {GLSL_DEFAULT_VERTEX_SHADER, GLSL_WATER_FRAGMENT_SHADER}, diff --git a/src/hardware/hw_shaders.h b/src/hardware/hw_shaders.h index 9826ba06f..40f936f69 100644 --- a/src/hardware/hw_shaders.h +++ b/src/hardware/hw_shaders.h @@ -31,6 +31,31 @@ "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ "}\0" +// reinterpretation of sprite lighting for models +// it's a combination of how it works for normal sprites & papersprites +#define GLSL_MODEL_LIGHTING_VERTEX_SHADER \ + "uniform float lighting;\n" \ + "uniform vec3 light_dir;\n" \ + "uniform float light_contrast;\n" \ + "uniform float light_backlight;\n" \ + "void main()\n" \ + "{\n" \ + "gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;\n" \ + "float light = lighting;\n" \ + "if (length(light_dir) > 0.000001) {\n" \ + "mat4 m4 = gl_ProjectionMatrix * gl_ModelViewMatrix;\n" \ + "mat3 m3 = mat3( m4[0].xyz, m4[1].xyz, m4[2].xyz );\n" \ + "float extralight = -dot(normalize(gl_Normal * m3), normalize(light_dir));\n" \ + "extralight *= light_contrast - light_backlight;\n" \ + "extralight *= lighting / 255.0;\n" \ + "light += extralight * 2.5;\n" \ + "}\n" \ + "light = clamp(light / 255.0, 0.0, 1.0);\n" \ + "gl_FrontColor = vec4(light, light, light, 1.0);\n" \ + "gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;\n" \ + "gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;\n" \ + "}\0" + // ================== // Fragment shaders // ================== @@ -195,21 +220,28 @@ // hand tuned adjustments for light level calculation #define GLSL_FLOOR_FUDGES \ - "#version 120\n" \ "#define STARTMAP_FUDGE 1.06\n" \ "#define SCALE_FUDGE 1.15\n" #define GLSL_WALL_FUDGES \ - "#version 120\n" \ "#define STARTMAP_FUDGE 1.05\n" \ "#define SCALE_FUDGE 2.2\n" #define GLSL_FLOOR_FRAGMENT_SHADER \ + "#version 120\n" \ GLSL_FLOOR_FUDGES \ GLSL_SOFTWARE_FRAGMENT_SHADER +// this is very backwards +// but we wanna have the game look like vanilla does +// oh well #define GLSL_WALL_FRAGMENT_SHADER \ + "#version 120\n" \ + "#ifdef SRB2_PALETTE_RENDERING\n" \ GLSL_WALL_FUDGES \ + "#else\n" \ + GLSL_FLOOR_FUDGES \ + "#endif\n" \ GLSL_SOFTWARE_FRAGMENT_SHADER // @@ -227,6 +259,7 @@ "vec4 texel = texture2D(tex, vec2(gl_TexCoord[0].s - sdistort, gl_TexCoord[0].t - cdistort));\n" #define GLSL_WATER_FRAGMENT_SHADER \ + "#version 120\n" \ GLSL_FLOOR_FUDGES \ "const float freq = 0.025;\n" \ "const float amp = 0.025;\n" \ @@ -275,6 +308,7 @@ // The floor fudges are used, but should the wall fudges be used instead? or something inbetween? // or separate values for floors and walls? (need to change more than this shader for that) #define GLSL_FOG_FRAGMENT_SHADER \ + "#version 120\n" \ GLSL_FLOOR_FUDGES \ "uniform vec4 tint_color;\n" \ "uniform vec4 fade_color;\n" \ diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 3b9c3bac5..0fcb58a3d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -99,14 +99,14 @@ static GLuint screenPaletteTex = 0; // 1D texture containing the screen palette static GLuint paletteLookupTex = 0; // 3D texture containing RGB -> palette index lookup table RGBA_t myPaletteData[256]; // the palette for converting textures to RGBA -GLint screen_width = 0; // used by Draw2DLine() -GLint screen_height = 0; -GLbyte screen_depth = 0; -GLint textureformatGL = 0; -GLint maximumAnisotropy = 0; -static GLboolean MipMap = GL_FALSE; -static GLint min_filter = GL_LINEAR; -static GLint mag_filter = GL_LINEAR; +static GLint gltexformat = GL_RGB5_A1; +GLint screen_width = 0; // used by Draw2DLine() +GLint screen_height = 0; +GLbyte screen_depth = 0; +GLint maximumAnisotropy = 0; +static GLboolean MipMap = GL_FALSE; +static GLint min_filter = GL_LINEAR; +static GLint mag_filter = GL_LINEAR; static GLint anisotropic_filter = 0; boolean supportMipMap = false; @@ -670,6 +670,9 @@ typedef enum gluniform_lighting, gluniform_fade_start, gluniform_fade_end, + gluniform_light_dir, + gluniform_light_contrast, + gluniform_light_backlight, // palette rendering gluniform_palette_tex, // 1d texture containing a palette @@ -707,6 +710,11 @@ static gl_shaderstate_t gl_shaderstate; // Shader info static float shader_leveltime = 0; +static float shader_light_x = 0.0f; +static float shader_light_y = 0.0f; +static float shader_light_z = 0.0f; +static INT32 shader_light_contrast = 0; +static INT32 shader_light_backlight = 0; // Lactozilla: Shader functions static boolean GL_Shader_CompileProgram(gl_shader_t *shader, GLint i); @@ -867,6 +875,21 @@ void GL_SetShaderInfo(hwdshaderinfo_t info, INT32 value) case HWD_SHADERINFO_LEVELTIME: shader_leveltime = (((float)(value-1)) + FIXED_TO_FLOAT(rendertimefrac)) / TICRATE; break; + case HWD_SHADERINFO_LIGHT_X: + shader_light_x = FixedToFloat(value); + break; + case HWD_SHADERINFO_LIGHT_Y: + shader_light_y = FixedToFloat(value); + break; + case HWD_SHADERINFO_LIGHT_Z: + shader_light_z = FixedToFloat(value); + break; + case HWD_SHADERINFO_LIGHT_CONTRAST: + shader_light_contrast = value; + break; + case HWD_SHADERINFO_LIGHT_BACKLIGHT: + shader_light_backlight = value; + break; default: break; } @@ -1506,7 +1529,7 @@ void GL_SetBlend(FBITFIELD PolyFlags) { const FBITFIELD Xor = CurrentPolyFlags^PolyFlags;; - if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Invisible)) + if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Skydecal|PF_Invisible)) { if (Xor & PF_Blending) // if blending mode must be changed GL_SetBlendMode(PolyFlags & PF_Blending); @@ -1522,7 +1545,21 @@ void GL_SetBlend(FBITFIELD PolyFlags) if (Xor & PF_Decal) { if (PolyFlags & PF_Decal) + { + pglPolygonOffset(-1.0f, -1.0f); pglEnable(GL_POLYGON_OFFSET_FILL); + } + else + pglDisable(GL_POLYGON_OFFSET_FILL); + } + + if (Xor & PF_Skydecal) + { + if (PolyFlags & PF_Skydecal) + { + pglPolygonOffset(-0.45f, -0.45f); // dont let skywalls draw over actual walls tho + pglEnable(GL_POLYGON_OFFSET_FILL); + } else pglDisable(GL_POLYGON_OFFSET_FILL); } @@ -1600,8 +1637,8 @@ void GL_SetBlend(FBITFIELD PolyFlags) GL_SetNoTexture(); } } - CurrentPolyFlags = PolyFlags; + } static void GL_AllocTextureBuffer(GLMipmap_t *pTexInfo) @@ -1646,9 +1683,10 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) //GL_DBG_Printf("UpdateTexture %d %x\n", (INT32)num, pImgData); - texformat = textureformatGL; + texformat = gltexformat; + const GLTextureFormat_t texinfoformat = pTexInfo->format; - switch (pTexInfo->format) + switch (texinfoformat) { case GL_TEXFMT_P_8: case GL_TEXFMT_AP_88: @@ -1673,7 +1711,7 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) pImgData++; - if (pTexInfo->format != GL_TEXFMT_AP_88) + if (texinfoformat != GL_TEXFMT_AP_88) continue; if (chromakeyed) continue; @@ -1721,7 +1759,7 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) } break; default: - GL_MSG_Warning("UpdateTexture: bad format %d\n", pTexInfo->format); + GL_MSG_Warning("UpdateTexture: bad format %d\n", texinfoformat); break; } @@ -1744,6 +1782,8 @@ static 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) @@ -1753,7 +1793,7 @@ static 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, 4); + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, maxlod); } else { @@ -1868,11 +1908,32 @@ static void GL_Shader_SetUniforms(FSurfaceInfo *Surface, GLRGBAFloat *poly, GLRG UNIFORM_4(shader->uniforms[gluniform_tint_color], tint->red, tint->green, tint->blue, tint->alpha, pglUniform4f); UNIFORM_4(shader->uniforms[gluniform_fade_color], fade->red, fade->green, fade->blue, fade->alpha, pglUniform4f); + boolean directional = false; if (Surface != NULL) { UNIFORM_1(shader->uniforms[gluniform_lighting], (GLfloat)Surface->LightInfo.light_level, pglUniform1f); UNIFORM_1(shader->uniforms[gluniform_fade_start], (GLfloat)Surface->LightInfo.fade_start, pglUniform1f); UNIFORM_1(shader->uniforms[gluniform_fade_end], (GLfloat)Surface->LightInfo.fade_end, pglUniform1f); + directional = Surface->LightInfo.directional; + } + else + { + UNIFORM_1(shader->uniforms[gluniform_lighting], 255, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_fade_start], 0, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_fade_end], 31, pglUniform1f); + } + + if (directional) + { + UNIFORM_3(shader->uniforms[gluniform_light_dir], shader_light_x, shader_light_y, shader_light_z, pglUniform3f); + UNIFORM_1(shader->uniforms[gluniform_light_contrast], shader_light_contrast, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_light_backlight], shader_light_backlight, pglUniform1f); + } + else + { + UNIFORM_3(shader->uniforms[gluniform_light_dir], 0, 0, 0, pglUniform3f); + UNIFORM_1(shader->uniforms[gluniform_light_contrast], 0, pglUniform1f); + UNIFORM_1(shader->uniforms[gluniform_light_backlight], 0, pglUniform1f); } UNIFORM_1(shader->uniforms[gluniform_leveltime], shader_leveltime, pglUniform1f); @@ -1997,6 +2058,9 @@ static boolean GL_Shader_CompileProgram(gl_shader_t *shader, GLint i) shader->uniforms[gluniform_lighting] = GETUNI("lighting"); shader->uniforms[gluniform_fade_start] = GETUNI("fade_start"); shader->uniforms[gluniform_fade_end] = GETUNI("fade_end"); + shader->uniforms[gluniform_light_dir] = GETUNI("light_dir"); + shader->uniforms[gluniform_light_contrast] = GETUNI("light_contrast"); + shader->uniforms[gluniform_light_backlight] = GETUNI("light_backlight"); // palette rendering shader->uniforms[gluniform_palette_tex] = GETUNI("palette_tex"); @@ -2258,6 +2322,11 @@ void GL_SetSpecialState(hwdspecialstate_t IdState, INT32 Value) GL_Flush(); //??? if we want to change filter mode by texture, remove this break; + + case HWD_SET_TEXTURE_FORMAT: + gltexformat = (Value == 32) ? GL_RGBA : GL_RGB5_A1; + GL_Flush(); + break; case HWD_SET_MSAA: if (Value) @@ -2875,6 +2944,7 @@ void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) pglDisable(GL_DEPTH_TEST); pglDisable(GL_BLEND); + pglDisableClientState(GL_TEXTURE_COORD_ARRAY); // Draw a black square behind the screen texture, // so nothing shows through the edges @@ -2882,8 +2952,8 @@ void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) pglVertexPointer(3, GL_FLOAT, 0, blackBack); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); - pglEnableClientState(GL_TEXTURE_COORD_ARRAY); + for(x = 0; x < SCREENVERTS-1;x ++) { for(y = 0; y < SCREENVERTS-1; y++) @@ -3074,8 +3144,6 @@ void GL_DoScreenWipe(int wipeStart, int wipeEnd) pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - // const float defaultST[8] - pglClientActiveTexture(GL_TEXTURE0); pglTexCoordPointer(2, GL_FLOAT, 0, fix); pglVertexPointer(3, GL_FLOAT, 0, screenVerts); diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index dfbae7f6d..2f2b9ba98 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -136,7 +136,6 @@ extern boolean supportMipMap; /** \brief OpenGL flags for video driver */ extern INT32 oglflags; -extern GLint textureformatGL; extern GLfloat projMatrix[16]; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 8ffcc3743..268059d06 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -169,7 +169,7 @@ char french_shiftxform[] = 31, ' ','$', //shift-! '3', //shift-" - '#', '$', '%', + '#', '$', '%', '1', //shift-& '4', // shift-' '5', // shift-( @@ -179,7 +179,7 @@ char french_shiftxform[] = '6', // shift-- '.', '/', '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', + '6', '7', '8', '9', '/', // shitf-: '.', // shift-; '>', // shift-< @@ -222,7 +222,7 @@ char french_altgrxform[] = '|', //altg-- '.', '/', '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', + '6', '7', '8', '9', ':', ';', '<', '}', //altgr-= '>', '?', '@', @@ -914,12 +914,9 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) player_names[playernum]); if (server) { - UINT8 buf[2]; - - buf[0] = (UINT8)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } + return; } @@ -934,11 +931,7 @@ static void Got_Saycmd(UINT8 **p, INT32 playernum) CONS_Alert(CONS_WARNING, M_GetText("Illegal say command received from %s containing invalid characters\n"), player_names[playernum]); if (server) { - char buf[2]; - - buf[0] = (char)playernum; - buf[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } return; } @@ -1147,10 +1140,10 @@ void HU_Ticker(void) } if (cechotimer > 0) --cechotimer; - + // Animate the desynch dots if (hu_resynching -#ifdef SATURNSYNCH +#ifdef SATURNPAK || hu_redownloadinggamestate #endif ) @@ -2251,7 +2244,7 @@ void HU_Drawer(void) // draw desynch text if (hu_resynching -#ifdef SATURNSYNCH +#ifdef SATURNPAK || hu_redownloadinggamestate #endif ) @@ -2357,7 +2350,7 @@ Ping_gfx_num (int lag) } static int -Ping_gfx_color (int lag) +Ping_gfx_color (UINT32 lag) { if (lag < 2) return SKINCOLOR_JAWZ; @@ -2367,8 +2360,17 @@ Ping_gfx_color (int lag) return SKINCOLOR_GOLD; else if (lag < 10) return SKINCOLOR_RED; + else if (lag < servermaxping) + { + if (hu_tick & 2) + return SKINCOLOR_GREEN; + else if (hu_tick & 4) + return SKINCOLOR_YELLOW; + else + return SKINCOLOR_BLUEBERRY; + } else - return SKINCOLOR_WHITE; // SKINCOLOR_MAGENTA + return SKINCOLOR_WHITE; // to make the flashing work } static const UINT8 * @@ -2432,7 +2434,7 @@ void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) if (measureid == 1) V_DrawScaledPatch(x+11 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]); - + if (cv_pingicon.value) V_DrawScaledPatch(x+2, y, flags, pinggfx[gfxnum]); @@ -2561,24 +2563,19 @@ static inline void HU_DrawSpectatorTicker(void) if (cv_showspecstuff.value) { - if (players[i].mo) + player_t *player; + player = &players[i]; + + if (player->mo && player->mo->color) { - player_t *p; - p = &players[i]; + const UINT8 *colormap = R_GetTranslationColormap(player->skin, player->mo->color, GTC_CACHE); + if (player->mo->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, player->mo->color, GTC_CACHE); - if (players[i].mo->color) - { - const UINT8 *colormap; - if (players[i].mo->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, players[i].mo->color, GTC_CACHE); - else - colormap = R_GetTranslationColormap(players[i].skin, players[i].mo->color, GTC_CACHE); - - if (cv_highresportrait.value) - V_DrawSmallMappedPatch((templength - duptweak), height+10, V_TRANSLUCENT, R_GetSkinFaceWant(p), colormap); - else - V_DrawMappedPatch((templength - duptweak), height+10, V_TRANSLUCENT, R_GetSkinFaceRank(p), colormap); - } + if (K_UseHighResPortraits()) + V_DrawSmallMappedPatch((templength - duptweak), height+10, V_TRANSLUCENT, R_GetSkinFaceWant(player), colormap); + else + V_DrawMappedPatch((templength - duptweak), height+10, V_TRANSLUCENT, R_GetSkinFaceRank(player), colormap); } if ((netgame && i != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(&players[i]))) @@ -2593,7 +2590,6 @@ static inline void HU_DrawSpectatorTicker(void) } } - // // HU_DrawRankings // @@ -2777,16 +2773,31 @@ void HU_SetCEchoFlags(INT32 flags) void HU_DoCEcho(const char *msg) { - if (!cv_cechotoggle.value) - return - - I_OutputMsg("%s\n", msg); // print to log - #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-truncation" // This is fine, we set null byte later strncpy(cechotext, msg, sizeof(cechotext)); #pragma GCC diagnostic pop strncat(cechotext, "\\", sizeof(cechotext) - strlen(cechotext) - 1); cechotext[sizeof(cechotext) - 1] = '\0'; + + // just print it to console + if (cv_cechotoggle.value == 2) + { + char temp[1024]; + strncpy(temp, cechotext, sizeof(temp)); + + for (char *p = temp; *p != '\0'; ++p) + if (*p == '\\') + *p = '\n'; + + CONS_Printf("%s\n", temp); + return; + } + + I_OutputMsg("%s\n", msg); // print to log + + if (!cv_cechotoggle.value) + return; + cechotimer = cechoduration; } diff --git a/src/i_tcp.c b/src/i_tcp.c index 2b7af0e12..c27fa2480 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -24,7 +24,7 @@ #endif // __OS2__ #ifndef NO_IPV6 -#define HAVE_IPV6 +//#define HAVE_IPV6 #endif #ifdef _WIN32 @@ -183,6 +183,8 @@ typedef unsigned long SOCKET_TYPE; #define ERRSOCKET (-1) #endif +#define IPV6_MULTICAST_ADDRESS "ff15::57e1:1a12" + #ifdef USE_WINSOCK1 typedef int socklen_t; #endif @@ -379,6 +381,7 @@ static const char *SOCK_AddrToStr(mysockaddr_t *sk) static char s[64]; // 255.255.255.255:65535 or IPv6:65535 #ifdef HAVE_NTOP void *addr; + int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once if(sk->any.sa_family == AF_INET) addr = &sk->ip4.sin_addr; @@ -392,7 +395,10 @@ 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) - sprintf(s, "Unknown family type, error #%u", errno); + { + 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))); @@ -593,6 +599,7 @@ void Command_Numnodes(void) #endif #ifndef NONET +#ifdef HOLEPUNCH /* not one of the reserved "local" addresses */ static boolean is_external_address (UINT32 p) @@ -618,7 +625,6 @@ is_external_address (UINT32 p) } } -#ifdef HOLEPUNCH static boolean hole_punch(ssize_t c) { @@ -644,7 +650,7 @@ static boolean hole_punch(ssize_t c) } } -#endif +#endif //ifdef HOLEPUNCH // Returns true if a packet was received from a new node, false in all other cases static boolean SOCK_Get(void) @@ -770,11 +776,12 @@ static inline ssize_t SOCK_SendToAddr(SOCKET_TYPE socket, mysockaddr_t *sockaddr return sendto(socket, (char *)&doomcom->data, doomcom->datalength, 0, &sockaddr->any, d); } -#define ALLOWEDERROR(x) ((x) == ECONNREFUSED || (x) == EWOULDBLOCK || (x) == EHOSTUNREACH || (x) == ENETUNREACH) +#define ALLOWEDERROR(x) ((x) == ECONNREFUSED || (x) == EWOULDBLOCK || (x) == EHOSTUNREACH || (x) == ENETUNREACH || (x) == EADDRNOTAVAIL) static void SOCK_Send(void) { ssize_t c = ERRSOCKET; + int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once size_t i, j; if (!nodeconnected[doomcom->remotenode]) @@ -789,12 +796,15 @@ static void SOCK_Send(void) if (myfamily[i] == broadcastaddress[j].any.sa_family) { c = SOCK_SendToAddr(mysockets[i], &broadcastaddress[j]); - if (c == ERRSOCKET && !ALLOWEDERROR(errno)) - break; + if (c == ERRSOCKET) + { + e = errno; + if (!ALLOWEDERROR(e)) + break; + } } } } - return; } else if (nodesocket[doomcom->remotenode] == (SOCKET_TYPE)ERRSOCKET) { @@ -803,22 +813,28 @@ static void SOCK_Send(void) if (myfamily[i] == clientaddress[doomcom->remotenode].any.sa_family) { c = SOCK_SendToAddr(mysockets[i], &clientaddress[doomcom->remotenode]); - if (c == ERRSOCKET && !ALLOWEDERROR(errno)) - break; + if (c == ERRSOCKET) + { + e = errno; + if (!ALLOWEDERROR(e)) + break; + } } } - return; } else { c = SOCK_SendToAddr(nodesocket[doomcom->remotenode], &clientaddress[doomcom->remotenode]); + if (c == ERRSOCKET) + { + e = errno; + } } - if (c == ERRSOCKET) + if (c == ERRSOCKET && e != 0) // 0 means no socket for the address family was found { - int e = errno; // save error code so it can't be modified later if (!ALLOWEDERROR(e)) - I_Error("SOCK_Send, error sending to node %d (%s) #%u: %s", doomcom->remotenode, + I_Error("SOCK_Send, error sending to node %d (%s) #%u, %s", doomcom->remotenode, SOCK_GetNodeAddress(doomcom->remotenode), e, strerror(e)); } } @@ -852,6 +868,8 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen { SOCKET_TYPE s = socket(family, SOCK_DGRAM, IPPROTO_UDP); int opt; + int rc; + int e = 0; // save error code so it can't be modified later code and avoid calling WSAGetLastError() more then once socklen_t opts; #ifdef FIONBIO unsigned long trueval = true; @@ -867,12 +885,17 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen #ifdef USE_WINSOCK2 DWORD dwBytesReturned = 0; BOOL bfalse = FALSE; - WSAIoctl(s, SIO_UDP_CONNRESET, &bfalse, sizeof(bfalse), + rc = WSAIoctl(s, SIO_UDP_CONNRESET, &bfalse, sizeof(bfalse), NULL, 0, &dwBytesReturned, NULL, NULL); #else unsigned long falseval = false; - ioctl(s, SIO_UDP_CONNRESET, &falseval); + rc = ioctl(s, SIO_UDP_CONNRESET, &falseval); #endif + if (rc == -1) + { + e = errno; + I_OutputMsg("SIO_UDP_CONNRESET failed: #%u, %s\n", e, strerror(e)); + } } #endif @@ -887,14 +910,22 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen { opt = true; opts = (socklen_t)sizeof(opt); - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, opts); + rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, opts); + if (rc <= -1) + { + e = errno; + I_OutputMsg("setting SO_REUSEADDR failed: #%u, %s\n", e, strerror(e)); + } } // make it broadcastable opt = true; opts = (socklen_t)sizeof(opt); - if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&opt, opts)) + rc = setsockopt(s, SOL_SOCKET, SO_BROADCAST, (char *)&opt, opts); + if (rc <= -1) { + e = errno; CONS_Alert(CONS_WARNING, M_GetText("Could not get broadcast rights\n")); // I do not care anymore + I_OutputMsg("setting SO_BROADCAST failed: #%u, %s\n", e, strerror(e)); } } #ifdef HAVE_IPV6 @@ -904,56 +935,117 @@ static SOCKET_TYPE UDP_Bind(int family, struct sockaddr *addr, socklen_t addrlen { opt = true; opts = (socklen_t)sizeof(opt); - setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, opts); + rc = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, opts); + if (rc <= -1) + { + e = errno; + I_OutputMsg("setting SO_REUSEADDR failed: #%u, %s\n", e, strerror(e)); + } } #ifdef IPV6_V6ONLY // make it IPv6 ony opt = true; opts = (socklen_t)sizeof(opt); - if (setsockopt(s, SOL_SOCKET, IPV6_V6ONLY, (char *)&opt, opts)) + rc = setsockopt(s, SOL_SOCKET, IPV6_V6ONLY, (char *)&opt, opts); + if (rc <= -1) { + e = errno; CONS_Alert(CONS_WARNING, M_GetText("Could not limit IPv6 bind\n")); // I do not care anymore + I_OutputMsg("setting IPV6_V6ONLY failed: #%u, %s\n", e, strerror(e)); } #endif } #endif - if (bind(s, addr, addrlen) == ERRSOCKET) + rc = bind(s, addr, addrlen); + if (rc == ERRSOCKET) { + e = errno; close(s); - I_OutputMsg("Binding failed\n"); + I_OutputMsg("Binding failed: #%u, %s\n", e, strerror(e)); return (SOCKET_TYPE)ERRSOCKET; } +#ifdef HAVE_IPV6 + if (family == AF_INET6) + { + // we need to set all of this *after* binding to an address! + if (memcmp(&straddr.ip6.sin6_addr, &in6addr_any, sizeof(in6addr_any)) == 0) //IN6_ARE_ADDR_EQUAL + { + struct ipv6_mreq maddr; + + 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)); + if (rc <= -1) + { + e = errno; + CONS_Alert(CONS_WARNING, M_GetText("Could not register multicast address\n")); + if (e == ENODEV) + { + close(s); + I_OutputMsg("Binding failed: no IPv6 device\n"); + return (SOCKET_TYPE)ERRSOCKET; + } + I_OutputMsg("setting IPV6_JOIN_GROUP failed: #%u, %s \n", e, strerror(e)); + } + } + } +#endif + #ifdef FIONBIO // make it non blocking - opt = true; - if (ioctl(s, FIONBIO, &trueval) != 0) + rc = ioctl(s, FIONBIO, &trueval); + if (rc == -1) { + e = errno; close(s); - I_OutputMsg("Seting FIOBIO on failed\n"); + I_OutputMsg("FIOBIO failed: #%u, %s\n", e, strerror(e)); return (SOCKET_TYPE)ERRSOCKET; } #endif + opt = 0; opts = (socklen_t)sizeof(opt); - getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &opts); + rc = getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &opts); + if (rc <= -1) + { + e = errno; + I_OutputMsg("getting SO_RCVBUF failed: #%u, %s\n", e, strerror(e)); + } CONS_Printf(M_GetText("Network system buffer: %dKb\n"), opt>>10); if (opt < 64<<10) // 64k { opt = 64<<10; opts = (socklen_t)sizeof(opt); - setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, opts); - getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &opts); + rc = setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, opts); + if (rc <= -1) + { + e = errno; + I_OutputMsg("setting SO_RCVBUF failed: #%u, %s\n", e, strerror(e)); + } + opt = 0; + rc = getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *)&opt, &opts); + if (rc <= -1) + { + e = errno; + I_OutputMsg("getting SO_RCVBUF failed: #%u, %s\n", e, strerror(e)); + } + if (opt < 64<<10) CONS_Alert(CONS_WARNING, M_GetText("Can't set buffer length to 64k, file transfer will be bad\n")); else CONS_Printf(M_GetText("Network system buffer set to: %dKb\n"), opt>>10); } - if (getsockname(s, (struct sockaddr *)&sin, &len) == -1) + rc = getsockname(s, (struct sockaddr *)&sin, &len); + if (rc != 0) + { + e = errno; CONS_Alert(CONS_WARNING, M_GetText("Failed to get port number\n")); + I_OutputMsg("getsockname failed: #%u, %s\n", e, strerror(e)); + } else current_port = (UINT16)ntohs(sin.sin_port); @@ -1093,65 +1185,28 @@ static boolean UDP_Socket(void) // ip + udp packetheaderlength = 20 + 8; // for stats - hints.ai_family = AF_INET; - gaie = I_getaddrinfo("127.0.0.1", "0", &hints, &ai); - if (gaie == 0) - { - runp = ai; - while (runp != NULL && s < MAXNETNODES+1) - { - memcpy(&clientaddress[s], runp->ai_addr, runp->ai_addrlen); - s++; - runp = runp->ai_next; - } - I_freeaddrinfo(ai); - } - else - { - clientaddress[s].any.sa_family = AF_INET; - clientaddress[s].ip4.sin_port = htons(0); - clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip - s++; - } + clientaddress[s].any.sa_family = AF_INET; + clientaddress[s].ip4.sin_port = htons(0); + clientaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_LOOPBACK); //GetLocalAddress(); // my own ip + s++; s = 0; // setup broadcast adress to BROADCASTADDR entry - gaie = I_getaddrinfo("255.255.255.255", "0", &hints, &ai); - if (gaie == 0) - { - runp = ai; - while (runp != NULL && s < MAXNETNODES+1) - { - memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen); - s++; - runp = runp->ai_next; - } - I_freeaddrinfo(ai); - } - else - { - broadcastaddress[s].any.sa_family = AF_INET; - broadcastaddress[s].ip4.sin_port = htons(0); - broadcastaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_BROADCAST); - s++; - } + broadcastaddress[s].any.sa_family = AF_INET; + broadcastaddress[s].ip4.sin_port = htons(atoi(DEFAULTPORT)); + broadcastaddress[s].ip4.sin_addr.s_addr = htonl(INADDR_BROADCAST); + s++; + #ifdef HAVE_IPV6 if (b_ipv6) { - hints.ai_family = AF_INET6; - gaie = I_getaddrinfo("ff02::1", "0", &hints, &ai); - if (gaie == 0) - { - runp = ai; - while (runp != NULL && s < MAXNETNODES+1) - { - memcpy(&broadcastaddress[s], runp->ai_addr, runp->ai_addrlen); - s++; - runp = runp->ai_next; - } - I_freeaddrinfo(ai); - } + broadcastaddress[s].any.sa_family = AF_INET6; + broadcastaddress[s].ip6.sin6_port = htons(atoi(DEFAULTPORT)); + broadcastaddress[s].ip6.sin6_flowinfo = 0; + inet_pton(AF_INET6, IPV6_MULTICAST_ADDRESS, &broadcastaddress[s].ip6.sin6_addr); + broadcastaddress[s].ip6.sin6_scope_id = 0; + s++; } #endif diff --git a/src/i_time.c b/src/i_time.c index 931696379..2d136f27e 100644 --- a/src/i_time.c +++ b/src/i_time.c @@ -58,7 +58,7 @@ void I_UpdateTime(fixed_t timescale) tic_t realtics; // get real tics - ticratescaled = (double)TICRATE * FIXED_TO_FLOAT(timescale); + ticratescaled = (double)TICRATE * FixedToFloat(timescale); enterprecise = I_GetPreciseTime(); elapsedseconds = (double)((INT64)enterprecise - oldenterprecise) / I_GetPrecisePrecision(); @@ -77,6 +77,6 @@ void I_UpdateTime(fixed_t timescale) { double fractional, integral; fractional = modf(tictimer * ticratescaled, &integral); - g_time.timefrac = FLOAT_TO_FIXED(fractional); + g_time.timefrac = FloatToFixed(fractional); } } diff --git a/src/k_director.c b/src/k_director.c index 70fd66bbf..8fd5ab960 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -14,12 +14,15 @@ #include "doomdef.h" #include "doomstat.h" #include "g_game.h" +#include "m_random.h" #include "v_video.h" #include "k_director.h" #include "d_netcmd.h" #include "p_local.h" #include "st_stuff.h" +#include "r_fps.h" + #define SWITCHTIME TICRATE * 5 // cooldown between unforced switches #define BOREDOMTIME 3 * TICRATE / 2 // how long until players considered far apart? #define TRANSFERTIME TICRATE // how long to delay reaction shots? @@ -31,6 +34,7 @@ struct directorinfo { player_t* viewplayer; tic_t cooldown; // how long has it been since we last switched? + tic_t chaosleep;// how long did we watch the same player? tic_t freeze; // when nonzero, fixed switch pending, freeze logic! INT32 attacker; // who to switch to when freeze delay elapses INT32 maxdist; // how far is the closest player from finishing? @@ -40,6 +44,19 @@ struct directorinfo INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers? } directorinfo; +static INT32 K_PlayersPlaying(void) +{ + INT32 num = 0, i; + for (i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].spectator || !players[i].mo) + continue; + + num++; + } + return num; +} + static inline boolean race_rules(void) { return gametype == GT_RACE; @@ -52,9 +69,9 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) boolean K_DirectorIsAvailable(void) { - if (splitscreen || (demo.playback && demo.title) || modeattacking) + if (splitscreen || dedicated || (demo.playback && demo.title) || modeattacking) return false; - return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && (D_NumPlayers() > 1)))); + return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && (K_PlayersPlaying() > 1)))); } static boolean K_DirectorIsEnabled(void) @@ -62,6 +79,48 @@ static boolean K_DirectorIsEnabled(void) return (cv_director.value && K_DirectorIsAvailable()); } +static mobj_t *finishmo = NULL; + +// scan for the waypoint on the finish line +// used to get a very approximate distance from player to finishline +// we probably should like, do some maths to find the middle point between multiplayer +// waypoints with the same values, but idk if its really worth it +static void K_SetupFinishMo(void) +{ + INT16 maxMoveCount = -1; + INT16 maxAngle = -1; + + finishmo = NULL; + + if (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE)) // not a sprint map + { + // waypoint with angle 0 should always be at the finish line + for (finishmo = waypointcap; finishmo != NULL; finishmo = finishmo->tracer) + { + if (finishmo->spawnpoint->angle == 0) + break; + } + } + else // crappy optimization weeeee + { + // sprint maps finishline waypoint is the one with highest movecount AND angle + for (finishmo = waypointcap; finishmo != NULL; finishmo = finishmo->tracer) + { + if (finishmo->movecount > maxMoveCount) + maxMoveCount = finishmo->movecount; + if (finishmo->spawnpoint->angle > maxAngle) + maxAngle = finishmo->spawnpoint->angle; + } + + // now actually get the one + for (finishmo = waypointcap; finishmo != NULL; finishmo = finishmo->tracer) + { + if (finishmo->movecount == maxMoveCount && finishmo->spawnpoint->angle == maxAngle) + break; // found it + } + } +} + void K_InitDirector(void) { INT32 playernum; @@ -71,6 +130,7 @@ void K_InitDirector(void) directorinfo.attacker = 0; directorinfo.maxdist = 0; directorinfo.viewplayer = NULL; + directorinfo.chaosleep = 0; for (playernum = 0; playernum < MAXPLAYERS; playernum++) { @@ -78,50 +138,18 @@ void K_InitDirector(void) directorinfo.gap[playernum] = INT32_MAX; directorinfo.boredom[playernum] = 0; } + + K_SetupFinishMo(); } static fixed_t K_GetDistanceToFinish(player_t player) { - mobj_t *mo; - fixed_t dist = 0; - INT16 maxMoveCount = -1; - INT16 maxAngle = -1; + if (P_MobjWasRemoved(finishmo)) + return 0; - if (!(mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE)) - { - for (mo = waypointcap; mo != NULL; mo = mo->tracer) - { - if (mo->spawnpoint->angle != 0) - continue; - - dist = P_AproxDistance(P_AproxDistance(mo->x - player.mo->x, - mo->y - player.mo->y), - mo->z - player.mo->z) / FRACUNIT; - - break; - } - } - else // crappy optimization weeeee - { - for (mo = waypointcap; mo != NULL; mo = mo->tracer) - { - if (mo->movecount > maxMoveCount) - maxMoveCount = mo->movecount; - if (mo->spawnpoint->angle > maxAngle) - maxAngle = mo->spawnpoint->angle; - - if (!(mo->movecount == maxMoveCount && mo->spawnpoint->angle == maxAngle)) // sprint maps finishline waypoint is the one with highest movecount AND angle - continue; - - dist = P_AproxDistance(P_AproxDistance(mo->x - player.mo->x, - mo->y - player.mo->y), - mo->z - player.mo->z) / FRACUNIT; - - break; - } - } - - return dist; + return P_AproxDistance(P_AproxDistance(finishmo->x - player.mo->x, + finishmo->y - player.mo->y), + finishmo->z - player.mo->z) / FRACUNIT; } static fixed_t K_GetFinishGap(INT32 leader, INT32 follower) @@ -145,10 +173,10 @@ static void K_UpdateDirectorPositions(void) INT32 position; player_t* target; - memset(directorinfo.sortedplayers, -1, sizeof(directorinfo.sortedplayers)); - for (playernum = 0; playernum < MAXPLAYERS; playernum++) { + directorinfo.sortedplayers[playernum] = -1; + target = &players[playernum]; if (playeringame[playernum] && !target->spectator && target->kartstuff[k_position] > 0) @@ -216,6 +244,7 @@ static void K_DirectorSwitch(INT32 player, boolean force) G_ResetView(1, player, true); directorinfo.cooldown = SWITCHTIME; + directorinfo.chaosleep = 0; } static void K_DirectorForceSwitch(INT32 player, INT32 time) @@ -227,6 +256,26 @@ static void K_DirectorForceSwitch(INT32 player, INT32 time) directorinfo.attacker = player; directorinfo.freeze = time; + directorinfo.chaosleep = 0; +} + +static void K_DirectorSwitchRandom(void) +{ + INT32 randomplayer = -1; + + // kinda dumb but just check if the random player is existing lmao + for (INT32 h = 0; h < MAXPLAYERS; h++) + { + randomplayer = directorinfo.sortedplayers[M_RandomRange(0, K_PlayersPlaying()-1)]; // switch to someone random + + if (randomplayer != -1 && randomplayer != displayplayers[0]) // dont switch to ourselves Zzz... + { + break; + } + } + + if (randomplayer != -1) + K_DirectorSwitch(randomplayer, true); } void K_DirectorFollowAttack(player_t *player, mobj_t *inflictor, mobj_t *source) @@ -269,6 +318,7 @@ void K_DrawDirectorDebugger(void) V_DrawThinString(120, 0, V_70TRANS, va("BORED")); V_DrawThinString(150, 0, V_70TRANS, va("COOLDOWN: %d", directorinfo.cooldown)); V_DrawThinString(230, 0, V_70TRANS, va("MAXDIST: %d", directorinfo.maxdist)); + V_DrawThinString(310, 0, V_70TRANS, va("SLEEPTIME: %d", directorinfo.chaosleep)); for (position = 0; position < MAXPLAYERS - 1; position++) { @@ -315,7 +365,8 @@ void K_UpdateDirector(void) K_UpdateDirectorPositions(); - if (directorinfo.cooldown > 0) { + if (directorinfo.cooldown > 0) + { directorinfo.cooldown--; } @@ -337,6 +388,27 @@ void K_UpdateDirector(void) return; } + // insta switch if the player were watching finishes + if (players[displayplayers[0]].exiting) + { + K_DirectorSwitchRandom(); + return; + } + + // begin counting when cooldown wore off + if (!directorinfo.cooldown) + { + directorinfo.chaosleep++; + } + + // force switch 10 seconds after the cooldown has ended + // otherwise i fall asleeb zzz... + if (directorinfo.chaosleep > TICRATE*10) + { + K_DirectorSwitchRandom(); + return; + } + // aaight, time to walk through the standings to find the first interesting pair // NB: targetposition/sortedplayers is 0-indexed, aiming at the "back half" of a given pair by default. // we adjust for this when comparing to player->position or when looking at the leading player, Don't Freak Out diff --git a/src/k_kart.c b/src/k_kart.c index c496eabb4..1e2190c2f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -78,7 +78,7 @@ IMPL_HUD_OFFSET(stat); // Stats #undef IMPL_HUD_OFFSET_Y // extra colourisation stuff -static CV_PossibleValue_t colorspeedlines_cons_t[] = {{0, "Off"}, {1, "Normal"}, {2, "+Driftcharge"}, {0, NULL}}; +static CV_PossibleValue_t colorspeedlines_cons_t[] = {{0, "Off"}, {1, "Normal"}, {2, "+Driftcharge"}, {3, "Drift only"}, {0, NULL}}; consvar_t cv_coloredspeedlines = {"colorizedspeedlines", "Off", CV_SAVE, colorspeedlines_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_coloredsneakertrail = {"sneakertrailcolor", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -91,7 +91,7 @@ consvar_t cv_airsparks = {"airdriftsparks", "Off", CV_SAVE, CV_OnOff, NULL, 0, N //extra hud things consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t inputdisplay_cons_t[] = {{0, "Off"}, {1, "Wheel"}, {2, "Stick"}, {0, NULL}}; +CV_PossibleValue_t inputdisplay_cons_t[NUMINPUTDISPLAYSTUFF]; consvar_t cv_showinput = {"showinput", "Off", CV_SAVE, inputdisplay_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showlaptimes = {"showlaptimes", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -102,13 +102,14 @@ consvar_t cv_fancyroulette = {"animatedroulette", "Off", CV_SAVE, CV_OnOff, NULL consvar_t cv_minihead = {"smallminimapplayers", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showminimapnames = {"showminimapnames", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_showminimapangle = {"showminimapangle", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_highresportrait = {"highresportrait", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // make char potraits use their high-res version instead consvar_t cv_showlapemblem = {"showlapemblem", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_biglaps = {"biglaphud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // here for ppl who dont want to make 2 more patches for their custom hud -consvar_t cv_darkitembox = {"darkitembox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // itembox gets a dark box with specific items +consvar_t cv_darkitembox = {"darkitembox", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // itembox gets a dark border with specific items consvar_t cv_multiitemicon = {"multiitemicon", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t huditemamount_cons_t[] = {{0, "Vanilla"}, {1, "Multiple"}, {2, "Always"},{0, NULL}}; consvar_t cv_huditemamount = {"showitemamountnumber", "Vanilla", CV_SAVE, huditemamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -117,12 +118,11 @@ CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; consvar_t cv_newspeedometer = {"newspeedometer", "Default", CV_SAVE, speedo_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // toggle for showing the speedometer in battlemode +consvar_t cv_playerblendeffects = {"playerblendeffects", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + // funn-E streeetch -static CV_PossibleValue_t stretchfactor_t[] = { - {0, "Off"}, {FRACUNIT/4, "0.250"}, - {3*FRACUNIT/8, "0.375"}, {FRACUNIT/2, "0.500"}, {5*FRACUNIT/8, "0.625"}, - {3*FRACUNIT/4, "0.750"}, {7*FRACUNIT/8, "0.875"}, {FRACUNIT, "Max"}, {0, NULL}}; -consvar_t cv_gravstretch = {"gravstretch", "0", CV_SAVE, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t stretchfactor_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; +consvar_t cv_gravstretch = {"gravstretch", "MIN", CV_SAVE|CV_FLOAT, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t slamsound_t[] = {{0, "Off"}, {1, "On"}, {0, NULL}}; consvar_t cv_slamsound = {"slamsound", "1", CV_SAVE, slamsound_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -145,34 +145,36 @@ static void saltyhop_onchange(void); consvar_t cv_saltyhop = {"hardcodehop", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, saltyhop_onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_saltyhopsfx = {"hardcodehopsfx", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_saltysquish = {"hardcodehopsquish", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t saltyheight_t[] = {{FRACUNIT/4, "MIN"}, {2*FRACUNIT, "MAX"}, {0, NULL}}; +consvar_t cv_saltyheight = {"hardcodehopheight", "1", CV_FLOAT|CV_SAVE|CV_CALL|CV_NOINIT, saltyheight_t, saltyhop_onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_saltyroll = {"hardcodehoproll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_squishdance = {"squishdance", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static void saltyhop_onchange(void) { - // reset everything when toggling saltyhop off - if (!cv_saltyhop.value) + // reset everything when toggling saltyhop + if (gamestate != GS_LEVEL) + return; + + for (INT32 i = 0; i < MAXPLAYERS; i++) { - if (gamestate != GS_LEVEL) - return; + player_t *player = &players[i]; - for (INT32 i = 0; i < MAXPLAYERS; i++) - { - player_t *player = &players[i]; + if (!player || !playeringame[i] || P_MobjWasRemoved(player->mo)) + continue; - if (!playeringame[i] || P_MobjWasRemoved(player->mo)) - continue; + player->mo->salty_jump = false; + player->mo->salty_zoffset = 0; + player->mo->salty_momz = 0; - player->mo->salty_jump = false; - player->mo->salty_zoffset = 0; - player->mo->salty_momz = 0; - - player->mo->salty_ready = false; - player->mo->salty_tapping = false; - player->mo->init_salty = false; - } + player->mo->salty_ready = false; + player->mo->salty_tapping = false; + player->mo->init_salty = false; } } -//Colourized HUD +// Colourized HUD consvar_t cv_colorizedhud = {"colorizedhud", "Off", CV_SAVE|CV_CALL, CV_OnOff, SaturnHud_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_colorizeditembox = {"colorizeditembox", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -182,7 +184,7 @@ consvar_t cv_colorizedhudcolor = {"colorizedhudcolor", "Skin Color", CV_SAVE, Hu // driftgauge stuffs static CV_PossibleValue_t driftgaugeoffset_cons_t[] = { {-FRACUNIT*128, "MIN"}, {FRACUNIT*128, "MAX"}, {0, NULL}}; -CV_PossibleValue_t driftgaugestyle_cons_t[NUMSPEEDOSTUFF]; +CV_PossibleValue_t driftgaugestyle_cons_t[NUMDGAUGESTUFF]; consvar_t cv_driftgauge = {"kartdriftgauge", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_driftgaugeofs = {"kartdriftgaugeoffset", "-20", CV_FLOAT|CV_SAVE, driftgaugeoffset_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -216,6 +218,7 @@ consvar_t cv_smallnametags = {"kartnametagsmall", "Off", CV_SAVE, nametagsize_co consvar_t cv_nametagscore = {"kartnametagscore", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +static boolean K_SpeedLinesShouldBlend(player_t *player); // SOME IMPORTANT VARIABLES DEFINED IN DOOMDEF.H: // gamespeed is cc (0 for easy, 1 for normal, 2 for hard) @@ -696,7 +699,7 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, bo return; } - starttranscolor = (skinnum != TC_DEFAULT) ? ((local) ? localskins : skins)[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR; + starttranscolor = (skinnum != TC_DEFAULT) ? K_GetSkinArray(local)[skinnum].starttranscolor : DEFAULT_STARTTRANSCOLOR; // Fill in the entries of the palette that are fixed for (i = 0; i < starttranscolor; i++) @@ -742,23 +745,96 @@ boolean K_UseColorHud(void) return (cv_colorizedhud.value && clr_hud); } +enum +{ + SPEEDO_VANILLA, + SPEEDO_EXTRA, + SPEEDO_ACHII, + SPEEDO_DIAL, + SPEEDO_PMETER, + SPEEDO_PMETERSMOL, + SPEEDO_EXTRA3, +}; + +static UINT8 K_GetSpeedometerStyle(void) +{ + if (cv_newspeedometer.value == 2 && xtra_speedo) + return SPEEDO_EXTRA; + else if (cv_newspeedometer.value == 3 && achi_speedo) + return SPEEDO_ACHII; + else if (cv_newspeedometer.value == 4 && dial_speedo) + return SPEEDO_DIAL; + else if (cv_newspeedometer.value == 5 && kartz_speedo) + return SPEEDO_PMETER; + else if (cv_newspeedometer.value == 6 && kartz_speedo_smol) + return SPEEDO_PMETERSMOL; + else if (cv_newspeedometer.value == 7 && xtra_speedo3) + return SPEEDO_EXTRA3; + else + return SPEEDO_VANILLA; +} + +static boolean K_IsHighResolution(void) +{ + return (vid.width >= 640 && vid.height >= 400); +} + +boolean K_UseHighResPortraits(void) +{ + return (cv_highresportrait.value && K_IsHighResolution()); +} + +// returns the players skinnumber +// accounts for localskins +INT32 K_GetSkinNum(player_t *player) +{ + return player->localskin ? (player->localskin - 1) : player->skin; +} + +// returns the mobj skinnumber +// accounts for localskins +INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local) +{ + return skin - K_GetSkinArray(local); +} + +// returns the players skinnumber +// accounts for localskins +skin_t *K_GetMobjSkin(const mobj_t *mobj) +{ + return mobj->localskin ? mobj->localskin : mobj->skin; +} + +// returns the skin array to use +// accounts for localskins +skin_t *K_GetSkinArray(boolean local) +{ + return local ? localskins : skins; +} + +// returns the players skin +// accounts for localskins +skin_t *K_GetPlayerSkin(player_t *player) +{ + return &K_GetSkinArray(player->skinlocal)[K_GetSkinNum(player)]; +} + +// returns the players faceprefix +// accounts for localskins +patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum) +{ + if (!player->skinlocal) + return (K_UseHighResPortraits() ? facewantprefix[skinnum] : facerankprefix[skinnum]); + else + return (K_UseHighResPortraits() ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); +} + //} //{ SRB2kart Net Variables -void K_RegisterKartStuff(void) +void K_RegisterServerKartStuff(void) { - HudColor_cons_t[0].value = 0; - HudColor_cons_t[0].strvalue = "Skin Color"; - - for (INT32 i = 1; i < MAXSKINCOLORS; i++) - { - HudColor_cons_t[i].value = i; - HudColor_cons_t[i].strvalue = KartColor_Names[i]; // SRB2kart - } - HudColor_cons_t[MAXSKINCOLORS].value = 0; - HudColor_cons_t[MAXSKINCOLORS].strvalue = NULL; - CV_RegisterVar(&cv_sneaker); CV_RegisterVar(&cv_rocketsneaker); CV_RegisterVar(&cv_invincibility); @@ -808,6 +884,22 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_kartdebugcheckpoint); CV_RegisterVar(&cv_kartdebugnodes); CV_RegisterVar(&cv_kartdebugcolorize); +} + +// Registers kart client commands and variables. +// Nothing needed for a dedicated server should be registered here. +void K_RegisterClientKartStuff(void) +{ + HudColor_cons_t[0].value = 0; + HudColor_cons_t[0].strvalue = "Skin Color"; + + for (INT32 i = 1; i < MAXSKINCOLORS; i++) + { + HudColor_cons_t[i].value = i; + HudColor_cons_t[i].strvalue = KartColor_Names[i]; // SRB2kart + } + HudColor_cons_t[MAXSKINCOLORS].value = 0; + HudColor_cons_t[MAXSKINCOLORS].strvalue = NULL; #define REG_HUD_OFFSET_X(name)\ CV_RegisterVar(&cv_##name##_xoffset); @@ -863,10 +955,14 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_minihead); CV_RegisterVar(&cv_showminimapnames); + CV_RegisterVar(&cv_showminimapangle); + CV_RegisterVar(&cv_showlapemblem); CV_RegisterVar(&cv_stagetitle); + CV_RegisterVar(&cv_playerblendeffects); + // Colourized HUD CV_RegisterVar(&cv_colorizedhud); CV_RegisterVar(&cv_colorizedhudcolor); @@ -902,8 +998,13 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_saltyhop); CV_RegisterVar(&cv_saltyhopsfx); CV_RegisterVar(&cv_saltysquish); + CV_RegisterVar(&cv_saltyheight); + CV_RegisterVar(&cv_saltyroll); + CV_RegisterVar(&cv_slamsound); + CV_RegisterVar(&cv_squishdance); + CV_RegisterVar(&cv_lessflicker); CV_RegisterVar(&cv_mouseturn); @@ -1665,6 +1766,10 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) fx->eflags |= MFE_VERTICALFLIP; else fx->eflags &= ~MFE_VERTICALFLIP; + + if (cv_playerblendeffects.value) + fx->blendmode = AST_ADD; + P_SetScale(fx, mobj1->scale); // Because this is done during collision now, rmomx and rmomy need to be recalculated @@ -2059,8 +2164,7 @@ static void K_PlayGenericCombatSound(mobj_t *source, mobj_t *other, sfxenum_t sf // I HATE LOCALSKINS! I HATE LOCALSKINS! :AAAAAAAAAA: if (source->player) { - INT32 skinnum = source->player->skinlocal ? (source->player->localskin - 1) : source->player->skin; - skin = &(source->player->skinlocal ? localskins : skins)[skinnum]; + skin = K_GetPlayerSkin(source->player); } if (!skin) @@ -2462,14 +2566,19 @@ void K_SpawnBattlePoints(player_t *source, player_t *victim, UINT8 amount) if (!source || !source->mo) return; - if (amount == 1) - st = S_BATTLEPOINT1A; - else if (amount == 2) - st = S_BATTLEPOINT2A; - else if (amount == 3) - st = S_BATTLEPOINT3A; - else - return; // NO STATE! + switch (amount) + { + case 1: + st = S_BATTLEPOINT1A; + break; + case 2: + st = S_BATTLEPOINT2A; + break; + case 3: + st = S_BATTLEPOINT3A; + default: + return; // NO STATE! + } pt = P_SpawnMobj(source->mo->x, source->mo->y, source->mo->z, MT_BATTLEPOINT); P_SetTarget(&pt->target, source->mo); @@ -3242,9 +3351,14 @@ static void K_SpawnDriftSparks(player_t *player) if (leveltime % 2 == 1) return; - if (!cv_airsparks.value && !P_IsObjectOnGround(player->mo)) + if (cv_airsparks.value) + goto skipground; + + if (!P_IsObjectOnGround(player->mo)) return; +skipground: // idk im sleepy + if (!player->kartstuff[k_drift] || player->kartstuff[k_driftcharge] < K_GetKartDriftSparkValue(player)) return; @@ -3253,8 +3367,12 @@ static void K_SpawnDriftSparks(player_t *player) for (i = 0; i < 2; i++) { fixed_t driftExtraScale = 0; - newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(32*FRACUNIT, player->mo->scale)); - newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(32*FRACUNIT, player->mo->scale)); + + angle_t thrustangle = (travelangle + ((i&1) ? -1 : 1)*ANGLE_135); + fixed_t smolscale = FixedMul(32*FRACUNIT, player->mo->scale); + + newx = player->mo->x + P_ReturnThrustX(player->mo, thrustangle, smolscale); + newy = player->mo->y + P_ReturnThrustY(player->mo, thrustangle, smolscale); spark = P_SpawnMobj(newx, newy, player->mo->z, MT_DRIFTSPARK); P_SetTarget(&spark->target, player->mo); @@ -3263,7 +3381,7 @@ static void K_SpawnDriftSparks(player_t *player) // scale increase while driftspark level gained timer is running driftExtraScale = FixedDiv(player->driftsparkGrowTimer, DRIFTSPARKGROWTICS); spark->destscale = FixedMul(player->mo->scale, FRACUNIT + FixedMul(driftExtraScale, cv_driftsparkpulse.value)); - P_SetScale(spark, FixedMul(player->mo->scale, FRACUNIT + FixedMul(driftExtraScale, cv_driftsparkpulse.value))); + P_SetScale(spark, spark->destscale); // why not use what we calculated above? spark->momx = player->mo->momx/2; spark->momy = player->mo->momy/2; @@ -3299,6 +3417,9 @@ static void K_SpawnDriftSparks(player_t *player) P_SetMobjState(spark, S_DRIFTSPARK_A1); } + if (cv_playerblendeffects.value && player->kartstuff[k_sneakertimer]) + spark->blendmode = AST_ADD; + K_MatchGenericExtraFlags(spark, player->mo); } } @@ -3311,7 +3432,6 @@ static void K_SpawnAIZDust(player_t *player) angle_t travelangle; I_Assert(player != NULL); - I_Assert(player->mo != NULL); I_Assert(!P_MobjWasRemoved(player->mo)); if (leveltime % 2 == 1) @@ -3324,8 +3444,11 @@ static void K_SpawnAIZDust(player_t *player) //S_StartSound(player->mo, sfx_s3k47); { - newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle - (player->kartstuff[k_aizdriftstrat]*ANGLE_45), FixedMul(24*FRACUNIT, player->mo->scale)); - newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle - (player->kartstuff[k_aizdriftstrat]*ANGLE_45), FixedMul(24*FRACUNIT, player->mo->scale)); + angle_t thrustangle = (travelangle - (player->kartstuff[k_aizdriftstrat]*ANGLE_45)); + fixed_t smolscale = FixedMul(24*FRACUNIT, player->mo->scale); + + newx = player->mo->x + P_ReturnThrustX(player->mo, thrustangle, smolscale); + newy = player->mo->y + P_ReturnThrustY(player->mo, thrustangle, smolscale); spark = P_SpawnMobj(newx, newy, player->mo->z, MT_AIZDRIFTSTRAT); spark->angle = travelangle+(player->kartstuff[k_aizdriftstrat]*ANGLE_90); @@ -3341,211 +3464,240 @@ static void K_SpawnAIZDust(player_t *player) #define MAXSTRETCHDIV 17476977 -static void K_StretchPlayerGravity(player_t *p) +static void K_StretchPlayerGravity(player_t *player) { - if (cv_gravstretch.value == 0) + I_Assert(player != NULL); + I_Assert(!P_MobjWasRemoved(player->mo)); + + mobj_t *pmo = player->mo; + + fixed_t tempxscale = pmo->realxscale; + fixed_t tempyscale = pmo->realyscale; + + const fixed_t stretchScaleFactor = min(FixedDiv(FRACUNIT*60, cv_gravstretch.value), MAXSTRETCHDIV); + + if (pmo->slamsoundtimer) + pmo->slamsoundtimer--; + + if (!P_IsObjectOnGround(pmo)) { - return; - } + fixed_t pzmom = abs(pmo->momz); + const fixed_t stretchDiv = FixedDiv(pzmom, stretchScaleFactor); - I_Assert(p != NULL); - I_Assert(p->mo != NULL); - I_Assert(!P_MobjWasRemoved(p->mo)); - - fixed_t mos = FRACUNIT; - fixed_t rzs = abs(p->mo->momz); - fixed_t zspd = abs(rzs/mos); - fixed_t stretchScaleFactor = FixedDiv(FRACUNIT*60, cv_gravstretch.value); - fixed_t rzsDiv, slamDiv; - - fixed_t dxs = p->mo->realxscale; - fixed_t dys = p->mo->realyscale; - - if (stretchScaleFactor > MAXSTRETCHDIV) - rzsDiv = 0; - else - rzsDiv = FixedDiv(rzs, stretchScaleFactor); - - //CONS_Printf(M_GetText("div: %d, scale factor: %d, stretch value: %d\n"), rzsDiv, stretchScaleFactor, cv_gravstretch.value); - - if (p->mo->slamsoundtimer) - p->mo->slamsoundtimer--; - - if (cv_slamsound.value && (p->mo->eflags & MFE_JUSTHITFLOOR) && !p->mo->slamsoundtimer && (p->mo->stretchslam > 4*mos)) - { - S_StartSound(p->mo, sfx_s3k4c); - p->mo->slamsoundtimer = TICRATE; - } - - if (!P_IsObjectOnGround(p->mo)) - { - if (zspd != 0) + if (abs(pzmom/FRACUNIT) != 0) { - if (((dxs-(rzsDiv))) > (dxs/5)) + if (((tempxscale-(stretchDiv))) > (tempxscale/5)) { - p->mo->spritexscale = ((dxs-(rzsDiv))); - p->mo->stretchslam = rzs; + pmo->spritexscale = (tempxscale - stretchDiv); + pmo->stretchslam = pzmom; } else - p->mo->spritexscale = (dxs/5); + pmo->spritexscale = (tempxscale/5); - p->mo->spriteyscale = (dys+((rzsDiv*2)/3)); + pmo->spriteyscale = (tempyscale + ((stretchDiv*2)/3)); } - else + } + else if (pmo->stretchslam > 0) + { + // Funni slam sound when landing + if (cv_slamsound.value && (pmo->eflags & MFE_JUSTHITFLOOR) && !pmo->slamsoundtimer && (pmo->stretchslam > 4*FRACUNIT)) { - p->mo->spritexscale = (dxs); - p->mo->spriteyscale = (dys); + S_StartSound(pmo, sfx_s3k4c); + pmo->slamsoundtimer = TICRATE; } + + const fixed_t slamDiv = FixedDiv(pmo->stretchslam, stretchScaleFactor); + + pmo->spritexscale = (tempxscale + (((slamDiv*2)/3)*2)); + pmo->spriteyscale = (tempyscale - slamDiv); + pmo->stretchslam -= (4*FRACUNIT); } else - { - if (stretchScaleFactor > MAXSTRETCHDIV) - slamDiv = 0; - else - slamDiv = FixedDiv(p->mo->stretchslam, stretchScaleFactor); - - p->mo->spritexscale = (dxs+(((slamDiv*2)/3)*2)); - p->mo->spriteyscale = (dys-(slamDiv)); - if (p->mo->stretchslam > 0) - p->mo->stretchslam -= (4*mos); - else - p->mo->stretchslam = 0; - } + pmo->stretchslam = 0; } -static void K_QuiteSaltyHop(player_t *p) +// copy pasted from above +// but here to allow salty squish to work when gravstretch is disabled +static void K_SaltySquish(player_t *player) +{ + I_Assert(player != NULL); + I_Assert(!P_MobjWasRemoved(player->mo)); + + mobj_t *pmo = player->mo; + + fixed_t tempxscale = pmo->realxscale; + fixed_t tempyscale = pmo->realyscale; + + if (pmo->stretchslam > 0) + { + const fixed_t slamDiv = FixedDiv(pmo->stretchslam, 3932160); // stretchScaleFactor = FixedDiv(FRACUNIT*60, FRACUNIT) + + pmo->spritexscale = (tempxscale + (((slamDiv*2)/3)*2)); + pmo->spriteyscale = (tempyscale - slamDiv); + pmo->stretchslam -= (4*FRACUNIT); + } + else + pmo->stretchslam = 0; +} + +static void K_QuiteSaltyHop(player_t *player) { if (!cv_saltyhop.value) return; // what the fuck is this haya - fixed_t mos = FRACUNIT; // doesnt work correctly if it isnt :/ + //fixed_t mos = FRACUNIT; // doesnt work correctly if it isnt :/ + mobj_t *pmo = player->mo; + const boolean onground = P_IsObjectOnGround(pmo); // ready? - if (!p->kartstuff[k_jmp]) + if (!player->kartstuff[k_jmp]) { - p->mo->salty_ready = true; - p->mo->salty_tapping = false; + pmo->salty_ready = true; + pmo->salty_tapping = false; } - else if (p->mo->salty_ready) + else if (pmo->salty_ready) { - p->mo->salty_ready = false; - p->mo->salty_tapping = true; + pmo->salty_ready = false; + pmo->salty_tapping = true; } else { - p->mo->salty_tapping = false; + pmo->salty_tapping = false; } // GO! - if (!p->mo->init_salty) + if (!pmo->init_salty) { - p->mo->salty_jump = false; - p->mo->salty_zoffset = 0; - p->mo->salty_momz = 0; - p->mo->init_salty = true; + pmo->salty_jump = false; + pmo->salty_zoffset = 0; + pmo->salty_momz = 0; + pmo->init_salty = true; } - else if (p->mo->salty_jump) + else if (pmo->salty_jump) { - if (p->mo->eflags & MFE_JUSTHITFLOOR) + if (pmo->eflags & MFE_JUSTHITFLOOR) { - p->mo->salty_zoffset = 0; + pmo->salty_zoffset = 0; } - else if (P_IsObjectOnGround(p->mo)) + else if (onground) { - p->mo->salty_zoffset += p->mo->salty_momz; - p->mo->salty_momz -= (mos*3/2); + pmo->salty_zoffset += pmo->salty_momz; + pmo->salty_momz -= (FRACUNIT*3/2); } else { - p->mo->salty_zoffset *= (49/50)*mos; - p->mo->salty_momz = 0; + pmo->salty_zoffset *= (49/50)*FRACUNIT; + pmo->salty_momz = 0; } - if (p->mo->salty_zoffset <= 0) + if (pmo->salty_zoffset <= 0) { - if (!(p->mo->eflags & MFE_JUSTHITFLOOR) && P_IsObjectOnGround(p->mo) && cv_saltyhopsfx.value) - S_StartSound(p->mo, sfx_s268); - p->mo->salty_jump = false; - p->mo->salty_zoffset = 0; - p->mo->salty_momz = 0; + if (cv_saltyhopsfx.value && !(pmo->eflags & MFE_JUSTHITFLOOR) && onground) + S_StartSound(pmo, sfx_s268); + pmo->salty_jump = false; + pmo->salty_zoffset = 0; + pmo->salty_momz = 0; // shlamma damma - p->mo->stretchslam += cv_saltysquish.value ? (8*mos) : 0; + if (cv_saltysquish.value) + pmo->stretchslam += 8*FRACUNIT; } - else if (p->mo->salty_zoffset >= 0 && cv_saltysquish.value) + else if (cv_saltysquish.value && pmo->salty_zoffset >= 0) { // goofy ahh hack - p->mo->spriteyscale += (mos/8); - p->mo->spritexscale -= (mos/8); + pmo->spriteyscale += (FRACUNIT/8); + pmo->spritexscale -= (FRACUNIT/8); } - p->mo->spriteyoffset = p->mo->salty_zoffset; + pmo->spriteyoffset = FixedMul(pmo->salty_zoffset, cv_saltyheight.value); - if (S_SoundPlaying(p->mo, sfx_screec)) - S_StopSoundByID(p->mo, sfx_screec); - if (S_SoundPlaying(p->mo, sfx_drift)) - S_StopSoundByID(p->mo, sfx_drift); - } - else if (p->mo->salty_tapping && P_IsObjectOnGround(p->mo) && !p->kartstuff[k_spinouttimer] && !p->kartstuff[k_squishedtimer]) - { - p->mo->salty_jump = true; - p->mo->salty_zoffset = 0; - p->mo->salty_momz = 6*mos; if (cv_saltyhopsfx.value) - S_StartSound(p->mo, sfx_s25a); + { + if (S_SoundPlaying(pmo, sfx_screec)) + S_StopSoundByID(pmo, sfx_screec); + if (S_SoundPlaying(pmo, sfx_drift)) + S_StopSoundByID(pmo, sfx_drift); + } } + else if (pmo->salty_tapping && onground && !player->kartstuff[k_spinouttimer] && !player->kartstuff[k_squishedtimer]) + { + pmo->salty_jump = true; + pmo->salty_zoffset = 0; + pmo->salty_momz = 6*FRACUNIT; + if (cv_saltyhopsfx.value) + S_StartSound(pmo, sfx_s25a); + } +} + +boolean K_CheckSlopeRollDist(mobj_t *mobj) +{ + const boolean usedistance = cv_sloperolldist.value && !splitscreen; + + // always roll from any distance + if (!usedistance) + return true; + + const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; + const fixed_t m_dist = (R_QuickCamDist(mobj->x, mobj->y)*FRACUNIT); + + return (m_dist <= rolldist); +} + +// checks if slope rotation should be applied +boolean K_ShouldSlopeRoll(mobj_t *mobj) +{ + if (!cv_sloperoll.value || (!mobj->player && cv_sloperoll.value != 2)) // not a player and sloperoll not set to "Everything" + return false; + + // seeing a character rotate mid-hop looks really janky + if (!cv_saltyroll.value && mobj->player && mobj->player->mo->salty_jump) + return false; + + return K_CheckSlopeRollDist(mobj); } #define SLOPEROLL_DIV 3 void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) { + // save one P_MobjWasRemoved check for dedis lel + if (rendermode == render_none) + return; + if (P_MobjWasRemoved(mo)) return; I_Assert(mo->subsector != NULL); I_Assert(mo->subsector->sector != NULL); + if (!K_ShouldSlopeRoll(mo)) + { + mo->pitch_sprite = mo->roll_sprite = 0; + mo->sloperoll = mo->slopepitch = 0; + return; + } + // lifted from hw_md2 if (slope) { angle_t an; const boolean flip = (mo->eflags & MFE_VERTICALFLIP); - const boolean usedistance = cv_sloperolldist.value && !splitscreen; - const fixed_t rolldist = cv_sloperolldist.value * mapobjectscale; - const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0; - const boolean usepitchnroll = (!usedistance || (m_dist <= rolldist)); - fixed_t tempz = slope->normal.z; fixed_t tempy = slope->normal.y; fixed_t tempx = slope->normal.x; - fixed_t tempangle = -(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx)); + fixed_t tempangle = 0; // admittedly this is a very hacky way to do the pitch and roll easing // pitch - if (usepitchnroll) - { - an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV; - - mo->pitch_sprite = an ? mo->pitch_sprite + an : (angle_t)tempangle; - } - else - mo->pitch_sprite = 0; - + tempangle = -(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx)); + an = (INT32)((angle_t)tempangle - mo->pitch_sprite) / SLOPEROLL_DIV; + mo->pitch_sprite = an ? mo->pitch_sprite + an : (angle_t)tempangle; mo->slopepitch = flip ? InvAngle(mo->pitch_sprite) : mo->pitch_sprite; // roll - tempangle = (R_PointToAngle2(0, 0, tempz, tempy)); - - if (usepitchnroll) - { - an = (INT32)((angle_t)tempangle - mo->roll_sprite) / SLOPEROLL_DIV; - - mo->roll_sprite = an ? mo->roll_sprite + an : (angle_t)tempangle; - } - else - mo->roll_sprite = 0; - + tempangle = R_PointToAngle2(0, 0, tempz, tempy); + an = (INT32)((angle_t)tempangle - mo->roll_sprite) / SLOPEROLL_DIV; + mo->roll_sprite = an ? mo->roll_sprite + an : (angle_t)tempangle; mo->sloperoll = flip ? InvAngle(mo->roll_sprite) : mo->roll_sprite; } else if (P_IsObjectOnGround(mo)) @@ -3585,14 +3737,20 @@ void K_SpawnBoostTrail(player_t *player) for (i = 0; i < 2; i++) { - newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); - newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); + angle_t thrustangle = (travelangle + ((i&1) ? -1 : 1)*ANGLE_135); + fixed_t smolscale = FixedMul(24*FRACUNIT, player->mo->scale); + + newx = player->mo->x + P_ReturnThrustX(player->mo, thrustangle, smolscale); + newy = player->mo->y + P_ReturnThrustY(player->mo, thrustangle, smolscale); + if (player->mo->standingslope) { - ground = P_GetZAt(player->mo->standingslope, newx, newy); + ground = P_GetSlopeZAt(player->mo->standingslope, newx, newy); + if (player->mo->eflags & MFE_VERTICALFLIP) ground -= FixedMul(mobjinfo[MT_SNEAKERTRAIL].height, player->mo->scale); } + flame = P_SpawnMobj(newx, newy, ground, MT_SNEAKERTRAIL); P_SetTarget(&flame->target, player->mo); @@ -3604,6 +3762,8 @@ void K_SpawnBoostTrail(player_t *player) { flame->colorized = true; flame->color = player->skincolor; + if (cv_playerblendeffects.value) + flame->blendmode = AST_ADD; } P_SetScale(flame, player->mo->scale); @@ -3655,6 +3815,9 @@ void K_SpawnSparkleTrail(mobj_t *mo) sparkle->destscale = mo->destscale; P_SetScale(sparkle, mo->scale); sparkle->color = mo->color; + + if (cv_playerblendeffects.value && mo->player && K_SpeedLinesShouldBlend(mo->player)) + sparkle->blendmode = AST_ADD; } P_SetMobjState(sparkle, S_KARTINVULN_LARGE1); @@ -3917,13 +4080,13 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map if (mo->eflags & MFE_UNDERWATER) mo->momz = (117 * mo->momz) / 200; - if (cv_sloperoll.value == 2 && cv_bananthrowroll.value && mapthing == MT_BANANA) + if (cv_bananthrowroll.value && (mapthing == MT_BANANA)) { //mo->angle = FixedAngle(M_RandomRange(-180, 180) << FRACBITS); - if (cv_bananthrowroll.value == 1) - mo->sloperoll = FixedAngle(M_RandomRange(-180, 180) << FRACBITS); // im lazy but this makes sure the banan goes back to upright when it lands lmao + if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mo)) + mo->sloperoll = (angle_t)FixedAngle(M_RandomRange(-180, 180) << FRACBITS); // im lazy but this makes sure the banan goes back to upright when it lands lmao else if (cv_bananthrowroll.value == 2) - mo->rollangle = FixedAngle(M_RandomRange(-180, 180) << FRACBITS); + mo->rollangle = (angle_t)FixedAngle(M_RandomRange(-180, 180) << FRACBITS); } } @@ -4693,12 +4856,7 @@ static fixed_t K_BananaSlopeZ(pslope_t *slope, fixed_t x, fixed_t y, fixed_t z, testy += y; } - if (slope) - { - slopez = P_GetZAt(slope, testx, testy); - } - else - slopez = z; + slopez = P_GetZAt(slope, testx, testy, z); return slopez; } @@ -4999,7 +5157,7 @@ static void K_MoveHeldObjects(player_t *player) if (R_PointToDist2(cur->x, cur->y, targx, targy) > 768*FRACUNIT) P_MoveOrigin(cur, targx, targy, cur->z); - if (cv_sloperoll.value == 2 && P_IsObjectOnGround(cur)) + if (P_IsObjectOnGround(cur) && K_ShouldSlopeRoll(cur)) { K_CalculateBananaSlope(cur, cur->x, cur->y, cur->z, cur->radius, cur->height, (cur->eflags & MFE_VERTICALFLIP), false); @@ -5407,13 +5565,16 @@ static boolean K_SpeedLinesShouldBlend(player_t *player) { fixed_t percentspeed = 0; + if (!cv_playerblendeffects.value) + return false; + if (!player->mo) return false; if (player->kartstuff[k_sneakertimer]) return true; - // this is how the percentage speedometer calcs, i suck at maths so this was the easiest thing to fo lmao + // this is how the percentage speedometer calcs, i suck at maths so this was the easiest thing to do lmao percentspeed = (FixedDiv(player->speed, FixedMul(K_GetKartSpeed(player, false), ORIG_FRICTION))*100)>>FRACBITS; if (percentspeed > 127) // sneaker boost is around 25% @@ -5422,9 +5583,44 @@ static boolean K_SpeedLinesShouldBlend(player_t *player) return false; } +static UINT8 K_GetSpeedLineColor(player_t *player, boolean colorSpeed) +{ + UINT8 speedcolor = SKINCOLOR_NONE; + + if (colorSpeed) + { + if (cv_coloredspeedlines.value >= 2 && player->kartstuff[k_driftboost]) + { + if (player->kartstuff[k_driftboost] <= 20) + speedcolor = SKINCOLOR_SAPPHIRE; + else if (player->kartstuff[k_driftboost] <= 50) + speedcolor = SKINCOLOR_RASPBERRY; + else if (player->kartstuff[k_driftboost] <= 125) + speedcolor = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); + } + + speedcolor = (leveltime & 1) ? ((cv_coloredspeedlines.value == 3) ? SKINCOLOR_NONE : player->mo->color) : speedcolor; + } + + if (cv_coloredspeedlines.value != 3) + { + if (player->kartstuff[k_eggmanexplode]) + { + // Make it red when you have the eggman speed boost + speedcolor = SKINCOLOR_RED; + } + else if (player->kartstuff[k_invincibilitytimer]) + { + speedcolor = player->mo->color; + } + } + + return speedcolor; +} + typedef INT32 (*randomFunc)(INT32 min, INT32 max); -static inline void K_SpawnNormalSpeedLines(player_t *player, boolean synched) +FUNCINLINE static ATTRINLINE void K_SpawnNormalSpeedLines(player_t *player, boolean synched) { randomFunc randomfunc = synched ? P_RandomRange : M_RandomRange; @@ -5441,36 +5637,13 @@ static inline void K_SpawnNormalSpeedLines(player_t *player, boolean synched) K_MatchGenericExtraFlags(fast, player->mo); - if (cv_coloredspeedlines.value) + if (cv_coloredspeedlines.value || cv_playerblendeffects.value) { const boolean colorSpeed = (player->speed >= (3*K_GetKartSpeed(player, false))/4); - if (player->kartstuff[k_eggmanexplode]) + if (cv_coloredspeedlines.value) { - // Make it red when you have the eggman speed boost - fast->color = SKINCOLOR_RED; - fast->colorized = true; - } - else if (player->kartstuff[k_invincibilitytimer]) - { - fast->color = player->mo->color; - fast->colorized = true; - } - else if (colorSpeed) - { - UINT8 driftcolor = SKINCOLOR_NONE; - - if (cv_coloredspeedlines.value == 2 && player->kartstuff[k_driftboost]) - { - if (player->kartstuff[k_driftboost] <= 20) - driftcolor = SKINCOLOR_SAPPHIRE; - else if (player->kartstuff[k_driftboost] <= 50) - driftcolor = SKINCOLOR_RASPBERRY; - else if (player->kartstuff[k_driftboost] <= 125) - driftcolor = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); - } - - fast->color = (leveltime & 1) ? player->mo->color : driftcolor; + fast->color = K_GetSpeedLineColor(player, colorSpeed); fast->colorized = true; } @@ -5502,7 +5675,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) { K_SpawnNormalSpeedLines(player, true); } - else if (cv_coloredspeedlines.value && player->kartstuff[k_eggmanexplode]) // gotta love the speedlines calling synched rng :chaosleep: + else if ((cv_coloredspeedlines.value == 1 || cv_coloredspeedlines.value == 2) && player->kartstuff[k_eggmanexplode]) // gotta love the speedlines calling synched rng :chaosleep: { K_SpawnNormalSpeedLines(player, false); } @@ -6017,59 +6190,68 @@ static void K_KartDrift(player_t *player, boolean onground) } // Incease/decrease the drift value to continue drifting in that direction - if (player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_jmp] == 1 && onground && player->kartstuff[k_drift] != 0) + if (player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_jmp] == 1 && player->kartstuff[k_drift] != 0) { fixed_t driftadditive = 24; - if (player->kartstuff[k_drift] >= 1) // Drifting to the left + // well this is kinda dumb but we cannot modify a drift in midair so + if (onground) { - player->kartstuff[k_drift]++; - if (player->kartstuff[k_drift] > 5) - player->kartstuff[k_drift] = 5; + if (player->kartstuff[k_drift] >= 1) // Drifting to the left + { + player->kartstuff[k_drift]++; + if (player->kartstuff[k_drift] > 5) + player->kartstuff[k_drift] = 5; - if (player->cmd.driftturn > 0) // Inward - driftadditive += abs(player->cmd.driftturn)/100; - if (player->cmd.driftturn < 0) // Outward - driftadditive -= abs(player->cmd.driftturn)/75; + if (player->cmd.driftturn > 0) // Inward + driftadditive += abs(player->cmd.driftturn)/100; + if (player->cmd.driftturn < 0) // Outward + driftadditive -= abs(player->cmd.driftturn)/75; + } + else if (player->kartstuff[k_drift] <= -1) // Drifting to the right + { + player->kartstuff[k_drift]--; + if (player->kartstuff[k_drift] < -5) + player->kartstuff[k_drift] = -5; + + if (player->cmd.driftturn < 0) // Inward + driftadditive += abs(player->cmd.driftturn)/100; + if (player->cmd.driftturn > 0) // Outward + driftadditive -= abs(player->cmd.driftturn)/75; + } + + // Disable drift-sparks until you're going fast enough + if (player->kartstuff[k_getsparks] == 0 || (player->kartstuff[k_offroad] && !player->kartstuff[k_invincibilitytimer] && !player->kartstuff[k_hyudorotimer] && !player->kartstuff[k_sneakertimer])) + driftadditive = 0; + if (player->speed > minspeed*2) + player->kartstuff[k_getsparks] = 1; + + // Sound whenever you get a different tier of sparks + if ((player->kartstuff[k_driftcharge] < dsone && player->kartstuff[k_driftcharge]+driftadditive >= dsone) + || (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo) + || (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree)) + { + //S_StartSound(player->mo, sfx_s3ka2); + if (P_IsLocalPlayer(player)) // UGHGHGH... + S_StartSoundAtVolume(player->mo, sfx_s3ka2, 192); // Ugh... + + player->driftsparkGrowTimer = DRIFTSPARKGROWTICS; + } } - else if (player->kartstuff[k_drift] <= -1) // Drifting to the right + else { - player->kartstuff[k_drift]--; - if (player->kartstuff[k_drift] < -5) - player->kartstuff[k_drift] = -5; - - if (player->cmd.driftturn < 0) // Inward - driftadditive += abs(player->cmd.driftturn)/100; - if (player->cmd.driftturn > 0) // Outward - driftadditive -= abs(player->cmd.driftturn)/75; - } - - // Disable drift-sparks until you're going fast enough - if (player->kartstuff[k_getsparks] == 0 || (player->kartstuff[k_offroad] && !player->kartstuff[k_invincibilitytimer] && !player->kartstuff[k_hyudorotimer] && !player->kartstuff[k_sneakertimer])) driftadditive = 0; - if (player->speed > minspeed*2) - player->kartstuff[k_getsparks] = 1; - - // Sound whenever you get a different tier of sparks - if ((player->kartstuff[k_driftcharge] < dsone && player->kartstuff[k_driftcharge]+driftadditive >= dsone) - || (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo) - || (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree)) - { - //S_StartSound(player->mo, sfx_s3ka2); - if (P_IsLocalPlayer(player)) // UGHGHGH... - S_StartSoundAtVolume(player->mo, sfx_s3ka2, 192); // Ugh... - - player->driftsparkGrowTimer = DRIFTSPARKGROWTICS; } - - // moved this below sounds to help with scaling // This spawns the drift sparks if (player->kartstuff[k_driftcharge] + driftadditive >= dsone) K_SpawnDriftSparks(player); - player->kartstuff[k_driftcharge] += driftadditive; - player->kartstuff[k_driftend] = 0; + if (onground) + { + player->kartstuff[k_driftcharge] += driftadditive; + player->kartstuff[k_driftend] = 0; + } } if (player->driftsparkGrowTimer) @@ -6449,8 +6631,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (P_IsLocalPlayer(player) && cv_supermusic.value == 1 && cv_birdmusic.value) S_ChangeMusicSpecial("kinvnc"); - else - S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmi : sfx_kinvnc)); P_RestoreMusic(player); K_PlayPowerGloatSound(player->mo); @@ -6655,8 +6835,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->kartstuff[k_growshrinktimer] = itemtime+(4*TICRATE); // 12 seconds if (P_IsLocalPlayer(player) && cv_growmusic.value == 1 && cv_birdmusic.value ) S_ChangeMusicSpecial("kgrow"); - else - S_StartSound(player->mo, (cv_kartinvinsfx.value ? sfx_alarmg : sfx_kgrow)); P_RestoreMusic(player); S_StartSound(player->mo, sfx_kc5a); } @@ -6874,17 +7052,13 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->sliproll -= (4*ANG1); } - K_StretchPlayerGravity(player); + // funneh Saturn sprite stuff + if (cv_gravstretch.value) + K_StretchPlayerGravity(player); + else if (cv_saltyhop.value && cv_saltysquish.value) + K_SaltySquish(player); - if (cv_sloperoll.value && !player->mo->salty_jump) // seeing a character rotate mid-hop looks really janky - { - K_RollMobjBySlopes(player->mo, player->mo->standingslope); - } - else - { - player->mo->sloperoll = 0; - player->mo->slopepitch = 0; - } + K_RollMobjBySlopes(player->mo, player->mo->standingslope); // Quick Turning // You can't turn your kart when you're not moving. @@ -7368,6 +7542,7 @@ static patch_t *kp_itembgclr[4]; //Kartz speedo static patch_t *kp_kartzspeedo[25]; +static patch_t *kp_kartzspeedo_smol[25]; static patch_t *kp_startcountdown[16]; static patch_t *kp_racefinish[6]; @@ -7453,6 +7628,22 @@ static patch_t *skp_speedpatchesachi[5]; static patch_t *skp_smallstickerachiclr; static patch_t *skp_speedpatchesachiclr[5]; +// dial speedometer +static patch_t *skp_rankfinish; +static patch_t *skp_dialbase[2]; +static patch_t *skp_speedpatchesdial[5]; +static patch_t *skp_dialnum[10]; +//static patch_t *skp_dialclr; +static patch_t *skp_dialbaseclr[2]; +static patch_t *skp_speedpatchesdialclr[5]; +static patch_t *skp_dialnumclr[10]; + +static patch_t *joybacking; +static patch_t *joyknob; +static patch_t *joyshadow; + +static patch_t *kp_minimapdot; + void K_LoadKartHUDGraphics(void) { INT32 i, j; @@ -7499,6 +7690,26 @@ void K_LoadKartHUDGraphics(void) skp_speedpatchesachi[4] = W_CachePatchName("SP_APERC", PU_HUDGFX); } + if (dial_speedo) + { + skp_rankfinish = W_CachePatchName("RANKFIN", PU_HUDGFX); + skp_dialbase[0] = W_CachePatchName("K_DSPBS1", PU_HUDGFX); + skp_dialbase[1] = W_CachePatchName("K_DSPBS2", PU_HUDGFX); + + skp_speedpatchesdial[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd + skp_speedpatchesdial[1] = W_CachePatchName("SP_DKMH", PU_HUDGFX); + skp_speedpatchesdial[2] = W_CachePatchName("SP_DMPH", PU_HUDGFX); + skp_speedpatchesdial[3] = W_CachePatchName("SP_DFRAC", PU_HUDGFX); + skp_speedpatchesdial[4] = W_CachePatchName("SP_DPERC", PU_HUDGFX); + + sprintf(buffer, "K_DSPNMx"); + for (i = 0; i < 10; i++) + { + buffer[7] = '0'+(i%10); + skp_dialnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); + } + } + if (big_lap) { kp_lapstickerbig = W_CachePatchName("K_STLAPB", PU_HUDGFX); @@ -7522,26 +7733,46 @@ void K_LoadKartHUDGraphics(void) kp_itembgclr[3] = W_CachePatchName("K_ISBCD", PU_HUDGFX); kp_itemmulstickerclr[1] = W_CachePatchName("K_ISMULC", PU_HUDGFX); kp_itemmulstickerclr[0] = W_CachePatchName("K_ITMULC", PU_HUDGFX); + } - if (big_lap_color){ - kp_lapstickerbigclr = W_CachePatchName("K_SCLAPB", PU_HUDGFX); - kp_lapstickerbig2clr = W_CachePatchName("K_SCLA2B", PU_HUDGFX); - } + if (big_lap_color) + { + kp_lapstickerbigclr = W_CachePatchName("K_SCLAPB", PU_HUDGFX); + kp_lapstickerbig2clr = W_CachePatchName("K_SCLA2B", PU_HUDGFX); + } - if (xtra_speedo && xtra_speedo_clr) - skp_smallstickerclr = W_CachePatchName("SC_SMSTC", PU_HUDGFX); + if (xtra_speedo && xtra_speedo_clr) + skp_smallstickerclr = W_CachePatchName("SC_SMSTC", PU_HUDGFX); - if (xtra_speedo3 && xtra_speedo_clr3) // 80x11 patch scaled to size - skp_smallstickerclr3 = W_CachePatchName("SC_SM3TC", PU_HUDGFX); + if (xtra_speedo3 && xtra_speedo_clr3) // 80x11 patch scaled to size + skp_smallstickerclr3 = W_CachePatchName("SC_SM3TC", PU_HUDGFX); - if (achi_speedo && achi_speedo_clr) + if (achi_speedo && achi_speedo_clr) + { + skp_smallstickerachiclr = W_CachePatchName("SC_AMSTC", PU_HUDGFX); + skp_speedpatchesachiclr[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd + skp_speedpatchesachiclr[1] = W_CachePatchName("SC_AKMH", PU_HUDGFX); + skp_speedpatchesachiclr[2] = W_CachePatchName("SC_AMPH", PU_HUDGFX); + skp_speedpatchesachiclr[3] = W_CachePatchName("SC_AFRAC", PU_HUDGFX); + skp_speedpatchesachiclr[4] = W_CachePatchName("SC_APERC", PU_HUDGFX); + } + + if (dial_speedo && dial_speedo_clr) + { + skp_dialbaseclr[0] = W_CachePatchName("K_DSPBC1", PU_HUDGFX); + skp_dialbaseclr[1] = W_CachePatchName("K_DSPBC2", PU_HUDGFX); + + skp_speedpatchesdialclr[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd + skp_speedpatchesdialclr[1] = W_CachePatchName("SC_DKMH", PU_HUDGFX); + skp_speedpatchesdialclr[2] = W_CachePatchName("SC_DMPH", PU_HUDGFX); + skp_speedpatchesdialclr[3] = W_CachePatchName("SC_DFRAC", PU_HUDGFX); + skp_speedpatchesdialclr[4] = W_CachePatchName("SC_DPERC", PU_HUDGFX); + + sprintf(buffer, "K_DSPNCx"); + for (i = 0; i < 10; i++) { - skp_smallstickerachiclr = W_CachePatchName("SC_AMSTC", PU_HUDGFX); - skp_speedpatchesachiclr[0] = W_CachePatchName("K_TRNULL", PU_HUDGFX); // lolxd - skp_speedpatchesachiclr[1] = W_CachePatchName("SC_AKMH", PU_HUDGFX); - skp_speedpatchesachiclr[2] = W_CachePatchName("SC_AMPH", PU_HUDGFX); - skp_speedpatchesachiclr[3] = W_CachePatchName("SC_AFRAC", PU_HUDGFX); - skp_speedpatchesachiclr[4] = W_CachePatchName("SC_APERC", PU_HUDGFX); + buffer[7] = '0'+(i%10); + skp_dialnumclr[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); } } @@ -7562,6 +7793,22 @@ void K_LoadKartHUDGraphics(void) } } + if (kartz_speedo_smol) + { + const char* patchNames[] = { + "K_KZSS1", "K_KZSS2", "K_KZSS3", "K_KZSS4", "K_KZSS5", + "K_KZSS6", "K_KZSS7", "K_KZSS8", "K_KZSS9", "K_KZSS10", + "K_KZSS11", "K_KZSS12", "K_KZSS13", "K_KZSS14", "K_KZSS15", + "K_KZSS16", "K_KZSS17", "K_KZSS18", "K_KZSS19", "K_KZSS20", + "K_KZSS21", "K_KZSS22", "K_KZSS23", "K_KZSS24", "K_KZSS25" + }; + + for (size_t m = 0; m < sizeof(patchNames) / sizeof(patchNames[0]); ++m) + { + kp_kartzspeedo_smol[m] = W_CachePatchName(patchNames[m], PU_HUDGFX); + } + } + // Nametags if (nametaggfx) { @@ -7575,10 +7822,21 @@ void K_LoadKartHUDGraphics(void) { driftgauge = W_CachePatchName("K_DGAU", PU_HUDGFX); driftgaugecolor = W_CachePatchName("K_DCAU", PU_HUDGFX); + } + + if (driftgaugegfx_clr) + { driftgaugesmall = W_CachePatchName("K_DGSU", PU_HUDGFX); driftgaugesmallcolor = W_CachePatchName("K_DCSU", PU_HUDGFX); } + if (joystickicon) + { + joybacking = W_CachePatchName("JOYBCK", PU_HUDGFX); + joyknob = W_CachePatchName("JOYKNB", PU_HUDGFX); + joyshadow = W_CachePatchName("JOYSHD", PU_HUDGFX); + } + // Starting countdown kp_startcountdown[0] = W_CachePatchName("K_CNT3A", PU_HUDGFX); kp_startcountdown[1] = W_CachePatchName("K_CNT2A", PU_HUDGFX); @@ -7659,6 +7917,9 @@ void K_LoadKartHUDGraphics(void) kp_wantedsplit = W_CachePatchName("4PWANTED", PU_HUDGFX); kp_wantedreticle = W_CachePatchName("MMAPWANT", PU_HUDGFX); + if (minidoticon) + kp_minimapdot = W_CachePatchName("MMAPDOT", PU_HUDGFX); + // Kart Item Windows kp_itembg[0] = W_CachePatchName("K_ITBG", PU_HUDGFX); kp_itembg[1] = W_CachePatchName("K_ITBGD", PU_HUDGFX); @@ -8017,7 +8278,7 @@ static void K_initKartHUD(void) // K_GetScreenCoords needs the right view* variables R_SetViewContext(stplyrnum); - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, !cv_uncappedhud.value); + R_InterpolateView(rendertimefrac_unpaused, !cv_uncappedhud.value); } INT32 K_calcSplitFlags(INT32 snapflags) @@ -8131,6 +8392,28 @@ void K_getMinimapDrawinfo(drawinfo_t *out) out->flags = fflags; } +INT32 K_getMinimapTrans(void) +{ + INT32 minimaptrans = cv_kartminimap.value; + + if (!minimaptrans) + return -1; + + if (forceshowhud) + return (10-minimaptrans)<kartstuff[k_bumper] ? -5 : -8) : 0); + // Customizations c: if (!splitscreen) { - x += 18 + cv_stat_xoffset.value; - y += cv_stat_yoffset.value + (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0) + spdoffset; + x += 18 + cv_stat_xoffset.value + spdxoffset; + y += cv_stat_yoffset.value + spdoffset; } else if (splitscreen == 1) // I tried my best, but this is still mess :/ < :Blobcatpats: c: { x -= 10; y -= 40; - y += (G_BattleGametype() ? (stplyr->kartstuff[k_bumper] ? -5 : -8) : 0); + y += spdoffset; // If we are in 2-player splitscreen, for player 1 we move hud to up and remove snapping // to bottom @@ -8220,24 +8516,22 @@ static void K_drawKartStats(void) flags |= V_HUDTRANS; skin_t *fakeskin; - fakeskin = &skins[stplyr->skin]; - - // local skinner - if (stplyr->localskin) - { - if (stplyr->skinlocal) - fakeskin = &localskins[stplyr->localskin - 1]; - else - fakeskin = &skins[stplyr->localskin - 1]; - } + fakeskin = K_GetPlayerSkin(stplyr); if (!splitscreen) { // Skin name - V_DrawSmallString(x+20, y+12, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); + if (K_IsHighResolution()) // V_DrawSmallString becomes a mess at low resolutions lel + { + V_DrawSmallString(x+20, y+12, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); + } + else + { + V_DrawThinString(x+20, y+7, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); + } // Icon and stats - if (cv_highresportrait.value) + if (K_UseHighResPortraits()) V_DrawSmallMappedPatch(x, y, flags, R_GetSkinFaceWant(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); else V_DrawMappedPatch(x, y, flags, R_GetSkinFaceRank(stplyr), R_GetLocalTranslationColormap(fakeskin, fakeskin, stplyr->skincolor, GTC_CACHE, stplyr->skinlocal)); @@ -8282,8 +8576,7 @@ static void K_drawKartItem(void) if (stplyr->kartstuff[k_itemroulette]) { - if (K_GetHudColor()) - localcolor = K_GetHudColor(); + localcolor = K_GetHudColor(); switch((stplyr->kartstuff[k_itemroulette] % (14*3)) / 3) { @@ -8866,7 +9159,9 @@ static void K_DrawKartPositionNum(INT32 num) while (num) { if (win) // 1st place winner? You get rainbows!! + { localpatch = kp_winnernum[(leveltime % (NUMWINFRAMES*3)) / 3]; + } else if (stplyr->laps+1 >= cv_numlaps.value || stplyr->exiting) // Check for the final lap, or won { // Alternate frame every three frames @@ -8991,39 +9286,37 @@ static boolean K_drawKartPositionFaces(void) for (; i < ranklines; i++) { + player_t *player; + player = &players[rankplayer[i]]; + if (!playeringame[rankplayer[i]]) continue; - if (players[rankplayer[i]].spectator) + if (player->spectator) continue; - if (!players[rankplayer[i]].mo) + if (!player->mo) continue; - const UINT8 mocolor = players[rankplayer[i]].mo->color; + const UINT8 mocolor = player->mo->color; bumperx = FACE_X+19; if (mocolor) { - player_t *p; - - colormap = R_GetTranslationColormap(players[rankplayer[i]].skin, mocolor, GTC_CACHE); - - if (players[rankplayer[i]].mo->colorized) + colormap = R_GetTranslationColormap(player->skin, mocolor, GTC_CACHE); + if (player->mo->colorized) colormap = R_GetTranslationColormap(TC_RAINBOW, mocolor, GTC_CACHE); - p = &players[rankplayer[i]]; - - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceWant(p), colormap); + if (K_UseHighResPortraits()) + V_DrawSmallMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceWant(player), colormap); else - V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceRank(p), colormap); + V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceRank(player), colormap); if (LUA_HudEnabled(hud_battlebumpers)) { - if (G_BattleGametype() && players[rankplayer[i]].kartstuff[k_bumper] > 0) + if (G_BattleGametype() && player->kartstuff[k_bumper] > 0) { V_DrawMappedPatch(bumperx-2, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[0], colormap); - for (j = 1; j < players[rankplayer[i]].kartstuff[k_bumper]; j++) + for (j = 1; j < player->kartstuff[k_bumper]; j++) { bumperx += 5; V_DrawMappedPatch(bumperx, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_tinybumper[1], colormap); @@ -9035,11 +9328,11 @@ static boolean K_drawKartPositionFaces(void) if (i == strank) V_DrawScaledPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, kp_facehighlight[(leveltime / 4) % 8]); - if (G_BattleGametype() && players[rankplayer[i]].kartstuff[k_bumper] <= 0) + if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) V_DrawScaledPatch(FACE_X-4, Y-3, V_HUDTRANS|V_SNAPTOLEFT, kp_ranknobumpers); else { - INT32 pos = players[rankplayer[i]].kartstuff[k_position]; + INT32 pos = player->kartstuff[k_position]; if (pos < 0 || pos > MAXPLAYERS) pos = 0; // Draws the little number over the face @@ -9059,7 +9352,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I { INT32 i, rightoffset = 240; const UINT8 *colormap; - INT32 dupadjust = (vid.width/vid.dupx), duptweak = (dupadjust - BASEVIDWIDTH)/2; + INT32 dupadjust = cv_betainterscreen.value ? 314 : (vid.width/vid.dupx), duptweak = cv_betainterscreen.value ? -3 : (dupadjust - BASEVIDWIDTH)/2; boolean (*_isHighlightedPlayer)(const player_t *) = (demo.playback ? P_IsDisplayPlayer : P_IsLocalPlayer); @@ -9105,7 +9398,7 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I else colormap = R_GetTranslationColormap(player->skin, player->mo->color, GTC_CACHE); - if (cv_highresportrait.value) + if (K_UseHighResPortraits()) V_DrawSmallMappedPatch(x, y-4, 0, R_GetSkinFaceWant(player), colormap); else V_DrawMappedPatch(x, y-4, 0, R_GetSkinFaceRank(player), colormap); @@ -9226,58 +9519,217 @@ static void K_drawKartLaps(void) } } +#ifdef ROTSPRITE + +#define DIALSPDDIV 97090 // 1.48148; converts 200 to 135 +#define MPHDIV 68283 // 1.04192; converts 141 to 135 + +static void K_DrawDialNum(INT32 x, INT32 y, boolean colorized, INT32 flags, INT32 num, INT32 digits, const UINT8 *colormap) +{ + INT32 w; + + if (colorized) + w = SHORT(skp_dialnumclr[0]->width); + else + w = SHORT(skp_dialnum[0]->width); + + if (flags & V_NOSCALESTART) + w *= vid.dupx; + + if (num < 0) + num = -num; + + // draw the number + do + { + x -= (w); + + if (colorized) + V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, flags, skp_dialnumclr[num % 10], colormap); + else + V_DrawFixedPatch(x << FRACBITS, y << FRACBITS, FRACUNIT, flags, skp_dialnum[num % 10], colormap); + + num /= 10; + } while (--digits); +} + +static void K_DrawDialLaps(INT32 x, INT32 y, INT32 num, INT32 total, INT32 flags) +{ + INT32 fx; + fx = x + ((num < 10) ? 0 : 6); + V_DrawRankNum(fx, y, flags, num, (num < 10) ? 1 : 2, NULL); + V_DrawScaledPatch(fx + 2, y, flags, frameslash); + V_DrawRankNum(fx + 13 + ((total < 10) ? 0 : 6), y, flags, total, (total < 10) ? 1 : 2, NULL); +} + +static void K_DrawDialSpeedometer(fixed_t speed, + fixed_t divisor, + INT32 splitflags, + boolean battlemode, + boolean infoactive, + boolean colorized) +{ + UINT8* colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); + + INT32 rot = 0; + UINT8 infoidx = (infoactive) ? 1 : 0; + patch_t* dialpatch; + + angle_t speedangle = + FixedAngle(((min(135 * FRACUNIT, FixedDiv(speed, divisor)) - (45 * FRACUNIT)))); + + rot = R_GetRollAngle(speedangle); + + if (rot) + { + dialpatch = W_CachePatchNameRotated("K_DSDIAL", rot, PU_STATIC); + } + else + { + dialpatch = W_CachePatchName("K_DSDIAL", PU_STATIC); + } + + if (colorized) // Colourized hud + { + V_DrawMappedPatch( + SPDM_X, SPDM_Y - 9, (V_HUDTRANS | splitflags), skp_dialbaseclr[infoidx], colormap); + V_DrawMappedPatch(SPDM_X, + SPDM_Y + 30, + V_HUDTRANS | splitflags, + skp_speedpatchesdialclr[cv_kartspeedometer.value], + colormap); + } + else + { + V_DrawScaledPatch(SPDM_X, SPDM_Y - 9, (V_HUDTRANS | splitflags), skp_dialbase[infoidx]); + V_DrawScaledPatch(SPDM_X, + SPDM_Y + 30, + V_HUDTRANS | splitflags, + skp_speedpatchesdial[cv_kartspeedometer.value]); + } + + K_DrawDialNum(SPDM_X + 10, + SPDM_Y + 25, + colorized, + V_HUDTRANS | splitflags, + speed / FRACUNIT, + 3, + colormap); + + // gotta center the dial manually + V_DrawMappedPatch(SPDM_X - 19, SPDM_Y + 15, (V_HUDTRANS | splitflags), (dialpatch), colormap); + + if (!infoactive) + { + // no need to draw info if we're not supposed to + return; + } + + // draw the info + if (battlemode) + { + if (stplyr->kartstuff[k_bumper] <= 0) + { + V_DrawMappedPatch( + SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_splitkarmabomb, colormap); + K_DrawDialLaps(SPDM_X + 46, + SPDM_Y + 29, + stplyr->kartstuff[k_comebackpoints], + 2, + V_HUDTRANS | splitflags); + } + else // the above doesn't need to account for weird stuff since the max amount of karma + // necessary is always 2 ^^^^ + { + V_DrawMappedPatch( + SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_rankbumper, colormap); + K_DrawDialLaps(SPDM_X + 46, + SPDM_Y + 29, + stplyr->kartstuff[k_bumper], + cv_kartbumpers.value, + V_HUDTRANS | splitflags); + } + } + else + { + V_DrawScaledPatch(SPDM_X + 28, SPDM_Y + 27, V_HUDTRANS | splitflags, kp_splitlapflag); + + if (stplyr->exiting) + V_DrawScaledPatch(SPDM_X + 39, SPDM_Y + 29, V_HUDTRANS | splitflags, skp_rankfinish); + else + K_DrawDialLaps(SPDM_X + 46, + SPDM_Y + 29, + stplyr->laps + 1, + cv_numlaps.value, + V_HUDTRANS | splitflags); + } +} + +#endif + static void K_drawKartSpeedometer(void) { // why? if (cv_kartspeedometer.value == 0) return; - fixed_t convSpeed = 0; + // index 0 is the raw value, index 1 is the converted value + fixed_t convSpeed[2] = {0,0}; + fixed_t dial_divisor = DIALSPDDIV; + INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTOLEFT); // man. - const boolean useoldspeedo = ((cv_newspeedometer.value == 1) || (cv_newspeedometer.value == 2 && !xtra_speedo) || (cv_newspeedometer.value == 3 && !achi_speedo) || (cv_newspeedometer.value == 4 && !kartz_speedo) || (cv_newspeedometer.value == 5 && !xtra_speedo3)); + const UINT8 speedostyle = K_GetSpeedometerStyle(); switch (cv_kartspeedometer.value) { case 1: - convSpeed = FixedDiv(FixedMul(stplyr->speed, 142371), mapobjectscale)/FRACUNIT; // 2.172409058 + convSpeed[0] = FixedDiv(FixedMul(stplyr->speed, 142371), mapobjectscale); // 2.172409058 + convSpeed[1] = convSpeed[0] / FRACUNIT; break; case 2: - convSpeed = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale)/FRACUNIT; // 1.349868774 + convSpeed[0] = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale); // 1.349868774 + convSpeed[1] = convSpeed[0] / FRACUNIT; + dial_divisor = MPHDIV; break; case 3: - convSpeed = FixedDiv(stplyr->speed, mapobjectscale)/FRACUNIT; + convSpeed[0] = FixedDiv(stplyr->speed, mapobjectscale); + convSpeed[1] = convSpeed[0] / FRACUNIT; + dial_divisor = MPHDIV; break; case 4: if (stplyr->mo) - convSpeed = (FixedDiv(stplyr->speed, FixedMul(K_GetKartSpeed(stplyr, false), ORIG_FRICTION))*100)>>FRACBITS; + { + convSpeed[0] = (FixedDiv(stplyr->speed, FixedMul(K_GetKartSpeed(stplyr, false), ORIG_FRICTION))*100); + convSpeed[1] = convSpeed[0] >> FRACBITS; + } break; default: break; } - if (useoldspeedo) + if (speedostyle == SPEEDO_VANILLA) { const char *metric = ""; switch (cv_kartspeedometer.value) { case 1: - metric = va("%3d km/h", convSpeed); + metric = va("%3d km/h", convSpeed[1]); break; case 2: - metric = va("%3d mph", convSpeed); + metric = va("%3d mph", convSpeed[1]); break; case 3: - metric = va("%3d fu/t", convSpeed); + metric = va("%3d fu/t", convSpeed[1]); break; case 4: // if extra.kart is found, use its included % symbol if (!xtra_speedo) - metric = va("%4d P", convSpeed); + metric = va("%4d P", convSpeed[1]); else - metric = va("%4d %%", convSpeed); + metric = va("%4d %%", convSpeed[1]); break; default: break; @@ -9285,7 +9737,7 @@ static void K_drawKartSpeedometer(void) V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, metric); } - else if (cv_newspeedometer.value == 2 && xtra_speedo) // why bother if we dont? + else if (speedostyle == SPEEDO_EXTRA) // why bother if we dont? { if (K_UseColorHud() && xtra_speedo_clr) //Colourized hud { @@ -9295,26 +9747,37 @@ static void K_drawKartSpeedometer(void) else V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallsticker)); - V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed, 3, NULL); + V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatches[cv_kartspeedometer.value]); } - else if (cv_newspeedometer.value == 3 && achi_speedo) // why bother if we dont? + else if (speedostyle == SPEEDO_ACHII) // why bother if we dont? { if (K_UseColorHud() && achi_speedo_clr) //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); V_DrawMappedPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallstickerachiclr), colormap); - V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed, 3, NULL); + V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawMappedPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachiclr[cv_kartspeedometer.value], colormap); } else { V_DrawScaledPatch(SPDM_X + 1, SPDM_Y + 4, (V_HUDTRANS|splitflags), (skp_smallstickerachi)); - V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed, 3, NULL); + V_DrawRankNum(SPDM_X + 26, SPDM_Y + 4, V_HUDTRANS|splitflags, convSpeed[1], 3, NULL); V_DrawScaledPatch(SPDM_X + 31, SPDM_Y + 4, V_HUDTRANS|splitflags, skp_speedpatchesachi[cv_kartspeedometer.value]); } } - else if (cv_newspeedometer.value == 5 && xtra_speedo3) // why bother if we dont? +#ifdef ROTSPRITE + else if (speedostyle == SPEEDO_DIAL) // why bother if we dont? + { + K_DrawDialSpeedometer(convSpeed[0], + dial_divisor, + splitflags, + (boolean)(G_BattleGametype()), + (LUA_HudEnabled(hud_gametypeinfo)), + (boolean)(K_UseColorHud() && dial_speedo_clr)); + } +#endif + else if (speedostyle == SPEEDO_EXTRA3) // why bother if we dont? { if (K_UseColorHud() && xtra_speedo_clr3) //Colourized hud { @@ -9324,12 +9787,12 @@ static void K_drawKartSpeedometer(void) else V_DrawStretchyFixedPatch((SPDM_X-1)< 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && !(leveltime & 4)) spdpatch = 23; - V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, kp_kartzspeedo[spdpatch]); + patch_t *patch = NULL; + + if (speedostyle == SPEEDO_PMETER) + patch = kp_kartzspeedo[spdpatch]; + else if (speedostyle == SPEEDO_PMETERSMOL) + patch = kp_kartzspeedo_smol[spdpatch]; + + V_DrawScaledPatch(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, patch); } } +#ifdef ROTSPRITE +#undef DIALSPDDIV +#undef MPHDIV +#endif + static void K_drawKartBumpersOrKarma(void) { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); @@ -9374,7 +9849,9 @@ static void K_drawKartBumpersOrKarma(void) if (cv_battlespeedo.value && !splitscreen) { - if ((cv_newspeedometer.value == 2 && xtra_speedo) || (cv_newspeedometer.value == 3 && achi_speedo) || (cv_newspeedometer.value == 5 && xtra_speedo3)) + const UINT8 speedostyle = K_GetSpeedometerStyle(); + + if ((speedostyle == SPEEDO_EXTRA) || (speedostyle == SPEEDO_ACHII) || (speedostyle == SPEEDO_EXTRA3)) fy += 5; else fy += 7; @@ -10086,6 +10563,46 @@ static void K_drawKartPlayerCheck(void) } } +static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32 hudy, INT32 flags, patch_t *icon, UINT8 *colormap) +{ + // amnum xpos & ypos are the icon's speed around the HUD. + // The number being divided by is for how fast it moves. + // The higher the number, the slower it moves. + + // am xpos & ypos are the icon's starting position. Withouht + // it, they wouldn't 'spawn' on the top-right side of the HUD. + + fixed_t amnumxpos, amnumypos; + INT32 amxpos, amypos; + fixed_t scale = FRACUNIT; + patch_t *AutomapPic; + + AutomapPic = minimapinfo.minimap_pic; + + if (AutomapPic == NULL) + { + return; // no pic, just get outta here + } + + amnumxpos = (FixedMul(objx, minimapinfo.zoom) - minimapinfo.offs_x); + amnumypos = -(FixedMul(objy, minimapinfo.zoom) - minimapinfo.offs_y); + + if (encoremode) + amnumxpos = -amnumxpos; + + amxpos = amnumxpos + ((hudx + (SHORT(AutomapPic->width)-SHORT(icon->width))/2)<height)-SHORT(icon->height))/2)<width) / 4)<height) / 4)<player; const boolean skinlocal = mo->skinlocal; - const skin_t *skin = (skin_t*)(mo->localskin ? mo->localskin : mo->skin); fixed_t amnumxpos, amnumypos; INT32 amxpos, amypos, wntdamxpos, wntdamypos; @@ -10109,10 +10626,8 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) INT32 rot = 0; #endif - if (mo->skin) - skinnum = (skin-(skinlocal ? localskins : skins)); - - minimaphead = (skinlocal ? localfacemmapprefix : facemmapprefix)[skinnum]; + skin = K_GetMobjSkin(mo); + minimaphead = (skinlocal ? localfacemmapprefix : facemmapprefix)[K_GetMobjSkinNum(skin, skinlocal)]; amnumxpos = (FixedMul(lerp(mo->old_x, mo->x), minimapinfo.zoom) - minimapinfo.offs_x); amnumypos = -(FixedMul(lerp(mo->old_y, mo->y), minimapinfo.zoom) - minimapinfo.offs_y); @@ -10123,9 +10638,9 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) amxpos = amnumxpos + ((x + (SHORT(minimapinfo.minimap_pic->width)-SHORT(minimaphead->width)) / 2)<height)-SHORT(minimaphead->height)) / 2)<player && !(modeattacking || gamestate == GS_TIMEATTACK)) + if (cv_showminimapnames.value && player && !(modeattacking || gamestate == GS_TIMEATTACK)) { - V_DrawCenteredSmallStringAtFixed(amxpos + (4*FRACUNIT), amypos - (3*FRACUNIT), V_ALLOWLOWERCASE|flags|V_SkinColorToHighlightcolor(mo->color), player_names[mo->player - players]); + V_DrawCenteredSmallStringAtFixed(amxpos + (4*FRACUNIT), amypos - (3*FRACUNIT), V_ALLOWLOWERCASE|flags|V_SkinColorToHighlightcolor(mo->color), player_names[player - players]); } // thx wanted reticle for having weird offsets very cool @@ -10140,10 +10655,10 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) } #ifdef ROTSPRITE - if (cv_spinoutroll.value && mo->player && mo->player->spinoutrot) + if (cv_spinoutroll.value && player && player->spinoutrot) { // Rotate counterclockwise. - rollangle = FixedAngle(mo->player->spinoutrot * -1); + rollangle = FixedAngle(player->spinoutrot * -1); rot = R_GetRollAngle(rollangle); if (rot) @@ -10166,17 +10681,15 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) V_DrawFixedPatch(amxpos, amypos, scale, flags, minimaphead, colormap); - if (mo->player - && ((G_RaceGametype() && mo->player->kartstuff[k_position] == spbplace) - || (G_BattleGametype() && K_IsPlayerWanted(mo->player)))) + if (player + && ((G_RaceGametype() && player->kartstuff[k_position] == spbplace) + || (G_BattleGametype() && K_IsPlayerWanted(player)))) { V_DrawFixedPatch(wntdamxpos, wntdamypos, scale, flags, kp_wantedreticle, NULL); } } } -#undef lerp - static void K_drawKartMinimap(void) { INT32 i = 0; @@ -10190,6 +10703,7 @@ static void K_drawKartMinimap(void) if (gamestate != GS_LEVEL) return; + // Only draw for the first player if (stplyrnum != 0) return; @@ -10198,26 +10712,18 @@ static void K_drawKartMinimap(void) return; // no pic, just get outta here } + minimaptrans = K_getMinimapTrans(); + + // Exit early if it wouldn't draw anyway. + if (minimaptrans == -1) + return; + drawinfo_t info; K_getMinimapDrawinfo(&info); x = info.x - (SHORT(minimapinfo.minimap_pic->width)/2); y = info.y - (SHORT(minimapinfo.minimap_pic->height)/2); splitflags = info.flags; - if (forceshowhud) - minimaptrans = cv_kartminimap.value; - else if (timeinmap > 105) - { - minimaptrans = cv_kartminimap.value; - if (timeinmap <= 113) - minimaptrans = ((((INT32)timeinmap) - 105)*minimaptrans)/(113-105); - if (!minimaptrans) - return; - } - else - return; - - minimaptrans = ((10-minimaptrans)<health <= 0 && players[localplayers[i]].pflags & PF_TIMEOVER) + continue; + + UINT8 *colormap; + fixed_t interpx, interpy; + + angle_t ang = R_InterpolateAngle(mobj->old_angle, mobj->angle); + + if (mobj->colorized) + colormap = R_GetTranslationColormap(TC_RAINBOW, mobj->color, GTC_CACHE); + else + colormap = R_GetLocalTranslationColormap(mobj->skin, mobj->localskin, mobj->color, GTC_CACHE, mobj->skinlocal); + + interpx = lerp(mobj->old_x, mobj->x); + interpy = lerp(mobj->old_y, mobj->y); + + K_drawKartMinimapIcon( + interpx, + interpy, + x + FixedMul(FCOS(ang), icondotradius), + y - FixedMul(FSIN(ang), icondotradius), + splitflags, + kp_minimapdot, + colormap + ); } } +#undef lerp + static void K_drawKartStartCountdown(void) { INT32 pnum = 0, splitflags = K_calcSplitFlags(0); // 3 @@ -10637,20 +11180,25 @@ static void K_drawKartFirstPerson(void) // doesn't need to ever support 4p static void K_drawInput(void) { - if (!cv_showinput.value && !modeattacking) // dont bother - return; - static INT32 pn = 0; - INT32 target = 0, splitflags = (V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS); - INT32 x = (BASEVIDWIDTH - 32 + cv_wheel_xoffset.value)*FRACUNIT, y = (BASEVIDHEIGHT - 24 + cv_wheel_yoffset.value)*FRACUNIT; INT32 offs, col; - const INT32 accent1 = splitflags|colortranslations[K_GetHudColor()][5]; - const INT32 accent2 = splitflags|colortranslations[K_GetHudColor()][9]; - ticcmd_t *cmd = &stplyr->cmd; + + if (!cv_showinput.value) // dont bother + return; if (timeinmap <= 105) return; + INT32 target = 0, splitflags = (V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS); + INT32 x = (BASEVIDWIDTH - 32 + cv_wheel_xoffset.value)*FRACUNIT, y = (BASEVIDHEIGHT - 24 + cv_wheel_yoffset.value)*FRACUNIT; + + const UINT8 hudcolor = K_GetHudColor(); + const INT32 accent1 = splitflags|colortranslations[hudcolor][5]; + const INT32 accent2 = splitflags|colortranslations[hudcolor][9]; + const UINT8 *hudcolormap = R_GetTranslationColormap(0, hudcolor, GTC_CACHE); + + ticcmd_t *cmd = &stplyr->cmd; + if (timeinmap < 113) { INT32 count = ((INT32)(timeinmap) - 105); @@ -10692,22 +11240,37 @@ static void K_drawInput(void) y -= FRACUNIT; - if (cv_showinput.value == 2) + if (cv_showinput.value == 2 || cv_showinput.value == 3) { INT32 joyx, joyxoffs, joyy, joyyoffs, axis; joyxoffs = -8, joyyoffs = -24; joyx = x>>FRACBITS, joyy = y>>FRACBITS; + UINT8 *shadowcolormap = NULL; + const boolean usejoysprite = (cv_showinput.value == 3 && joystickicon); // O backing - V_DrawFill(joyx+joyxoffs, joyy+joyyoffs-1, 16, 16, splitflags|accent2); - V_DrawFill(joyx+joyxoffs, joyy+joyyoffs+15, 16, 1, splitflags|31); + if (usejoysprite) + { + shadowcolormap = R_GetTranslationColormap(0, SKINCOLOR_BLACK, GTC_CACHE); + V_DrawMappedPatch(joyx+joyxoffs, joyy+joyyoffs-1, splitflags, joybacking, hudcolormap); + } + else + { + V_DrawFill(joyx+joyxoffs, joyy+joyyoffs-1, 16, 16, splitflags|accent2); + V_DrawFill(joyx+joyxoffs, joyy+joyyoffs+15, 16, 1, splitflags|31); + } // time for pain and suffering // kart does not have anything we can get analogue joystick y axis values from // during normal gameplay, so replicate shit here INT32 hudforward = 0; // for the stick input display :chaosleep: - if (!demo.playback) + // this is horrid but we cant get actual input in replays so uhh + if (demo.playback || !P_IsLocalPlayer(stplyr)) // yeah........... + { + hudforward = stplyr->kartstuff[k_throwdir] * KART_FULLTURN; + } + else { const boolean analogjoystickmove = cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[stplyrnum].value && Joystick[stplyrnum].bGamepadStyle; @@ -10732,38 +11295,43 @@ static void K_drawInput(void) } } } - else // this is horrid but we cant get actual input in replays so uhh - { - hudforward = stplyr->kartstuff[k_throwdir] * KART_FULLTURN; - } hudforward = CLAMP(hudforward, -KART_FULLTURN, KART_FULLTURN); if (cmd->driftturn || hudforward) { INT16 turning = encoremode ? -cmd->driftturn : cmd->driftturn; - // joystick hole - V_DrawFill(joyx+joyxoffs+5, joyy+joyyoffs+4, 6, 6, splitflags|accent1); - // joystick top and back - V_DrawFill(joyx+joyxoffs+3-turning/80, - joyy+joyyoffs+2-hudforward/80, - 10, 10, splitflags|31); - V_DrawFill(joyx+joyxoffs+3-turning/64, - joyy+joyyoffs+1-hudforward/64, - 10, 10, splitflags|accent1); + + if (usejoysprite) + { + V_DrawMappedPatch(joyx+joyxoffs+3-turning/80, joyy+joyyoffs+2-hudforward/80, splitflags, joyknob, shadowcolormap); + V_DrawMappedPatch(joyx+joyxoffs+3-turning/64, joyy+joyyoffs+1-hudforward/64, splitflags, joyknob, hudcolormap); + } + else + { + // joystick hole + V_DrawFill(joyx+joyxoffs+5, joyy+joyyoffs+4, 6, 6, splitflags|accent1); + // joystick top and back + V_DrawFill(joyx+joyxoffs+3-turning/80, joyy+joyyoffs+2-hudforward/80, 10, 10, splitflags|31); + V_DrawFill(joyx+joyxoffs+3-turning/64, joyy+joyyoffs+1-hudforward/64, 10, 10, splitflags|accent1); + } } else { - V_DrawFill(joyx+joyxoffs+3, joyy+joyyoffs+11, 10, 1, splitflags|accent2); - V_DrawFill(joyx+joyxoffs+3, - joyy+joyyoffs+1, - 10, 10,splitflags|accent1); + if (usejoysprite) + { + V_DrawMappedPatch(joyx+joyxoffs+3, joyy+joyyoffs+8, splitflags, joyshadow, shadowcolormap); + V_DrawMappedPatch(joyx+joyxoffs+3, joyy+joyyoffs+1, splitflags, joyknob, hudcolormap); + } + else + { + V_DrawFill(joyx+joyxoffs+3, joyy+joyyoffs+11, 10, 1, splitflags|accent2); + V_DrawFill(joyx+joyxoffs+3, joyy+joyyoffs+1, 10, 10,splitflags|accent1); + } } } else { - UINT8 *colormap = NULL; - if (!cmd->driftturn) // no turn target = 0; else // turning of multiple strengths! @@ -10795,10 +11363,7 @@ static void K_drawInput(void) if (target > 4) target = 4; - if (K_GetHudColor()) - colormap = R_GetTranslationColormap(0, K_GetHudColor(), GTC_CACHE); - - V_DrawFixedPatch(x, y, FRACUNIT, splitflags, kp_inputwheel[target], colormap); + V_DrawFixedPatch(x, y, FRACUNIT, splitflags, kp_inputwheel[target], hudcolormap); } } @@ -10994,11 +11559,45 @@ static void K_drawCheckpointDebugger(void) V_DrawString(8, 192, 0, va("Waypoint dist: Prev %d, Next %d", stplyr->kartstuff[k_prevcheck], stplyr->kartstuff[k_nextcheck])); } +// determines if gametype info (laps/bumpers) should be hidden +static boolean K_DisableGametypeInfo(void) +{ + if (!LUA_HudEnabled(hud_gametypeinfo)) + { + return true; + } + +#ifdef ROTSPRITE + if (splitscreen || (!cv_kartspeedometer.value)) + { + // don't need to run checks if we're in splitscreen, or not using the speedometer + return false; + } + + const UINT8 speedostyle = K_GetSpeedometerStyle(); + + if (G_RaceGametype()) + { + if (speedostyle == SPEEDO_DIAL) + return true; + } + else if (G_BattleGametype()) + { + if ((cv_battlespeedo.value) && (speedostyle == SPEEDO_DIAL)) + return true; + } +#endif + + return false; +} + + void K_drawKartHUD(void) { boolean isfreeplay = false; boolean battlefullscreen = false; boolean freecam = camera[stplyrnum].freecam; //disable some hud elements w/ freecam + boolean gameinfovisible = false; // Define the X and Y for each drawn object // This is handled by console/menu values @@ -11078,7 +11677,7 @@ void K_drawKartHUD(void) && stplyr->kartstuff[k_lapanimation] && !stplyr->exiting && stplyr->laptime[LAP_LAST] != 0 - && !midgamejoin) + && !midgamejoin) // due to vanilla compat, we cannot synch this oh well { if ((stplyr->kartstuff[k_lapanimation] / 5) & 1) { @@ -11104,9 +11703,12 @@ void K_drawKartHUD(void) if (!stplyr->spectator && !freecam) // Bottom of the screen elements, don't need in spectate mode { + // get gametype info visibility ahead of time + gameinfovisible = (!K_DisableGametypeInfo()); + if (!(splitscreen || demo.title)) { - if (LUA_HudEnabled(hud_position)) + if (LUA_HudEnabled(hud_inputdisplay)) K_drawInput(); } @@ -11144,7 +11746,7 @@ void K_drawKartHUD(void) else if (G_RaceGametype()) // Race-only elements { // Draw the lap counter - if (LUA_HudEnabled(hud_gametypeinfo)) + if (gameinfovisible) K_drawKartLaps(); if (!splitscreen) @@ -11163,17 +11765,11 @@ void K_drawKartHUD(void) if (LUA_HudEnabled(hud_position)) K_DrawKartPositionNum(stplyr->kartstuff[k_position]); } - else //if (!(demo.playback && hu_showscores)) - { - // Draw the input UI - if (LUA_HudEnabled(hud_position)) - K_drawInput(); - } } else if (G_BattleGametype()) // Battle-only { // Draw the hits left! - if (LUA_HudEnabled(hud_gametypeinfo)) + if (gameinfovisible) K_drawKartBumpersOrKarma(); if ((!splitscreen) && cv_battlespeedo.value) diff --git a/src/k_kart.h b/src/k_kart.h index 75727f072..8a53a2102 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -20,8 +20,10 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color, bo UINT8 K_GetKartColorByName(const char *name); UINT8 K_GetHudColor(void); boolean K_UseColorHud(void); +boolean K_UseHighResPortraits(void); -void K_RegisterKartStuff(void); +void K_RegisterServerKartStuff(void); +void K_RegisterClientKartStuff(void); extern consvar_t cv_coloredspeedlines, cv_coloredsneakertrail; extern consvar_t cv_bananajitter; @@ -39,9 +41,12 @@ extern consvar_t cv_battlespeedo; extern consvar_t cv_multiitemicon; extern consvar_t cv_huditemamount; -#define NUMSPEEDOSTUFF 6 +#define NUMSPEEDOSTUFF 8 extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; -extern CV_PossibleValue_t driftgaugestyle_cons_t[NUMSPEEDOSTUFF]; +#define NUMDGAUGESTUFF 6 +extern CV_PossibleValue_t driftgaugestyle_cons_t[NUMDGAUGESTUFF]; +#define NUMINPUTDISPLAYSTUFF 5 +extern CV_PossibleValue_t inputdisplay_cons_t[NUMINPUTDISPLAYSTUFF]; boolean K_IsPlayerLosing(player_t *player); boolean K_IsPlayerWanted(player_t *player); @@ -61,6 +66,8 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor); void K_StealBumper(player_t *player, player_t *victim, boolean force); void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle, boolean spawncenter, boolean ghostit, mobj_t *source); void K_SpawnMineExplosion(mobj_t *source, UINT8 color); +boolean K_CheckSlopeRollDist(mobj_t *mobj); +boolean K_ShouldSlopeRoll(mobj_t *mobj); void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope); void K_SpawnBoostTrail(player_t *player); void K_SpawnSparkleTrail(mobj_t *mo); @@ -118,6 +125,7 @@ typedef struct patch_t *K_getItemBoxPatch(boolean small, boolean dark); patch_t *K_getItemMulPatch(boolean small); void K_getItemBoxDrawinfo(drawinfo_t *out); +INT32 K_getMinimapTrans(void); void K_getLapsDrawinfo(drawinfo_t *out); void K_getMinimapDrawinfo(drawinfo_t *out); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index c621bd256..43ca81325 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -25,6 +25,7 @@ #include "console.h" #include "k_kart.h" // SRB2Kart #include "d_netcmd.h" // IsPlayerAdmin +#include "d_main.h" #include "lua_script.h" #include "lua_libs.h" @@ -1649,7 +1650,7 @@ static int lib_pGetZAt(lua_State *L) if (!slope) return LUA_ErrInvalid(L, "pslope_t"); - lua_pushfixed(L, P_GetZAt(slope, x, y)); + lua_pushfixed(L, P_GetSlopeZAt(slope, x, y)); return 1; } diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 4c29ee317..7ddf1a1d7 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -94,11 +94,7 @@ deny: CONS_Alert(CONS_WARNING, M_GetText("Illegal lua command received from %s\n"), player_names[playernum]); if (server) { - UINT8 bufn[2]; - - bufn[0] = (UINT8)playernum; - bufn[1] = KICK_MSG_CON_FAIL; - SendNetXCmd(XD_KICK, &bufn, 2); + SendKick(playernum, KICK_MSG_CON_FAIL); } } @@ -458,13 +454,10 @@ static int lib_cvRegisterVar(lua_State *L) if (!(((cvar->flags & CV_HIDEN)) || (cvar->flags & CV_NOSHOWHELP)) && (cvar->PossibleValue || !(cvar->value == 0 && stricmp(cvar->string, "0")))) { - char *temp = NULL; - if (!category) { - temp = strdup(wadfiles[numwadfiles - 1]->filename); - nameonly(temp); - + char *temp = wadfiles[numwadfiles - 1]->filename; + temp += strlen(temp) - nameonlylength(temp); category = temp; } @@ -472,8 +465,6 @@ static int lib_cvRegisterVar(lua_State *L) M_SlotCvarIntoModMenu(cvar, category, menu_name); else M_SlotCvarIntoModMenu(cvar, category, cvar->name); - - free (temp); } // return cvar userdata diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 3a4cf555e..a0f795985 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -935,40 +935,7 @@ int LUA_HookHurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source) return hook.status; } -#if 0 -void LUA_HookNetArchive(lua_CFunction archFunc) -{ - const hook_t * map = &hookIds[HOOK(NetVars)]; - Hook_State hook; - hook.force_mobj = false; - /* this is a remarkable case where the stack isn't reset */ - if (map->numHooks > 0) - { - // stack: tables - I_Assert(lua_gettop(gL) > 0); - I_Assert(lua_istable(gL, -1)); - - push_error_handler(); - lua_insert(gL, EINDEX); - - begin_hook_values(&hook); - - // tables becomes an upvalue of archFunc - lua_pushvalue(gL, -1); - lua_pushcclosure(gL, archFunc, 1); - // stack: tables, archFunc - - init_hook_call(&hook, 0, res_none); - call_mapped(&hook, map); - - lua_pop(gL, 1); // pop archFunc - lua_remove(gL, EINDEX); // pop error handler - // stack: tables - } -} -#endif - -void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save) // +void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save) { const hook_t * map = &hookIds[HOOK(NetVars)]; Hook_State hook; diff --git a/src/lua_hud.h b/src/lua_hud.h index 76ce9eb48..ea4d8ee02 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -32,6 +32,7 @@ enum hud { hud_wanted, hud_speedometer, hud_statdisplay, + hud_inputdisplay, hud_nametags, hud_driftgauge, hud_freeplay, diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 45570b2cd..60e4e729c 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -61,6 +61,7 @@ static const char *const hud_disable_options[] = { "wanted", "speedometer", "statdisplay", + "inputdisplay", "nametags", "driftgauge", "freeplay", @@ -187,7 +188,8 @@ enum hudoffsets { hudoffsets_check, hudoffsets_minimap, hudoffsets_wanted, - hudoffsets_statdisplay + hudoffsets_statdisplay, + hudoffsets_inputdisplay, }; static const char *const hud_offsets_options[] = { @@ -203,6 +205,7 @@ static const char *const hud_offsets_options[] = { "minimap", "wanted", "statdisplay", + "inputdisplay", NULL}; enum huddrawinfo { @@ -513,7 +516,7 @@ static int libd_getSpritePatch(lua_State *L) if (rot) { - patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<flip & (1< 1) // 3P : bottom right - { - MM_X = (3*BASEVIDWIDTH/4) + cv_mini_xoffset.value; - MM_Y = (3*BASEVIDHEIGHT/4) + cv_mini_yoffset.value; - - if (splitscreen > 2) // 4P: centered - { - MM_X = (BASEVIDWIDTH/2) + cv_mini_xoffset.value; - MM_Y = (BASEVIDHEIGHT/2) + cv_mini_yoffset.value; - } - } - } - - // splitscreen flags - splitflags = (splitscreen == 3 ? 0 : V_SNAPTORIGHT); // flags should only be 0 when it's centered (4p split) - - // translucency: - if (timeinmap > 105) - { - minimaptrans = cv_kartminimap.value; - if (timeinmap <= 113) - minimaptrans = ((((INT32)timeinmap) - 105)*minimaptrans)/(113-105); - if (!minimaptrans) - return 0; - } - else - return 0; - - minimaptrans = ((10-minimaptrans)<width)/2); - mm_y = MM_Y - (SHORT(AutomapPic->height)/2); + mm_x = info.x - (SHORT(AutomapPic->width)/2); + mm_y = info.y - (SHORT(AutomapPic->height)/2); // let offsets transfer to the heads, too! if (encoremode) @@ -696,13 +672,12 @@ static int libd_drawOnMinimap(lua_State *L) mm_y -= SHORT(AutomapPic->topoffset); - // scale patch coords - patchw = (SHORT(patch->width) * scale / 2); - patchh = (SHORT(patch->height) * scale / 2); - - if (centered) + // patch is supposedly already centered, don't butt in. + if (!centered) { - patchw = patchh = 0; // patch is supposedly already centered, don't butt in. + // scale patch coords + patchw = (SHORT(patch->width) * scale / 2); + patchh = (SHORT(patch->height) * scale / 2); } amnumxpos = (FixedMul(x, minimapinfo.zoom) - minimapinfo.offs_x); @@ -716,11 +691,6 @@ static int libd_drawOnMinimap(lua_State *L) amxpos = amnumxpos + ((mm_x + SHORT(AutomapPic->width) / 2)<height) / 2)<type) { case DI_Draw: - if (!item->patch || item->patch == NULL) - return; V_DrawBlendingFixedPatch(LERPS(x), LERPS(y), FRACUNIT, item->flags, item->patch, item->colormap, item->blend); break; case DI_DrawScaled: - if (!item->patch || item->patch == NULL) - return; V_DrawBlendingFixedPatch(LERPS(x), LERPS(y), LERP(scale), item->flags, item->patch, item->colormap, item->blend); break; case DI_DrawStretched: - if (!item->patch || item->patch == NULL) - return; V_DrawStretchyFixedPatch(LERPS(x), LERPS(y), LERP(hscale), LERP(vscale), item->flags, item->patch, item->colormap, item->blend); break; case DI_DrawNum: diff --git a/src/lua_infolib.c b/src/lua_infolib.c index c220ad25b..a82fc947d 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -154,7 +154,7 @@ static int lib_setState(lua_State *L) return luaL_error(L, "Do not alter states in BuildCMD code!"); // clear the state to start with, in case of missing table elements - memset(state,0,sizeof(state_t)); + memset(state, 0, sizeof(state_t)); state->tics = -1; lua_pushnil(L); @@ -262,8 +262,8 @@ boolean LUA_CallAction(enum actionnum actionnum, mobj_t *actor) return false; // action not called. if (superstack && fasticmp(actionpointers[actionnum].name, superactions[superstack-1])) // the action is calling itself, - return false; // let it call the hardcoded function - + return false; // let it call the hardcoded function + lua_pushcfunction(gL, LUA_GetErrorMessage); // grab function by uppercase name. @@ -514,7 +514,7 @@ static int lib_setMobjInfo(lua_State *L) return luaL_error(L, "Do not alter mobjinfo in BuildCMD code!"); // clear the mobjinfo to start with, in case of missing table elements - memset(info,0,sizeof(mobjinfo_t)); + memset(info, 0, sizeof(mobjinfo_t)); info->doomednum = -1; // default to no editor value info->spawnhealth = 1; // avoid 'dead' noclip behaviors diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 8b01b4ce3..9498974d5 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -99,6 +99,7 @@ static const udata_field_t mobj_fields[] = { FIELD(mobj_t, spritexoffset, udatalib_getter_fixed, mobj_spriteoffset_setter), FIELD(mobj_t, spriteyoffset, udatalib_getter_fixed, mobj_spriteoffset_setter), FIELD(mobj_t, touching_sectorlist, mobj_touching_sectorlist_unimplemented, mobj_touching_sectorlist_unimplemented), + FIELD(mobj_t, lightlevel, udatalib_getter_int16, udatalib_setter_int16), FIELD(mobj_t, subsector, udatalib_getter_subsector, mobj_nosetpos_subsector), FIELD(mobj_t, floorz, udatalib_getter_fixed, mobj_nosetpos_floorz), FIELD(mobj_t, ceilingz, udatalib_getter_fixed, mobj_nosetpos_ceilingz), @@ -391,16 +392,16 @@ int mobj_skin_getter(lua_State *L) mobj_t *mo = GETMO(); if (!mo->skin) - return 0; + return 0; + + // HUD ONLY!!!!!!!!!! + if (hud_running && cv_luaimmersion.value) + { + lua_pushstring(L, K_GetMobjSkin(mo)->name); + } + else + lua_pushstring(L, ((skin_t *)mo->skin)->name); - if (hud_running && cv_luaimmersion.value) { - if (mo->localskin) // HUD ONLY!!!!!!!!!! - lua_pushstring(L, ((skin_t *)mo->localskin)->name); - else - lua_pushstring(L, ((skin_t *)mo->skin)->name); - } else { - lua_pushstring(L, ((skin_t *)mo->skin)->name); - } return 1; } @@ -501,12 +502,12 @@ int mobj_color_setter(lua_State *L) int mobj_blendmode_setter(lua_State *L) { mobj_t *mo = GETMO(); - + INT32 blendmode = (INT32)luaL_checkinteger(L, 2); if (blendmode < 0 || blendmode > AST_OVERLAY) return luaL_error(L, "mobj.blendmode %d out of range (0 - %d).", blendmode, AST_OVERLAY); mo->blendmode = blendmode; - + return 0; } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 32b4abfe7..849f42b39 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -295,7 +295,7 @@ int player_localskin_getter(lua_State *L) player_t *plr = GETPLAYER(); if (plr->localskin) - lua_pushstring(L, (plr->skinlocal ? localskins : skins)[plr->localskin - 1].name); + lua_pushstring(L, K_GetPlayerSkin(plr)->name); else lua_pushnil(L); diff --git a/src/lua_script.c b/src/lua_script.c index 12192b0b2..8d481b95b 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -696,6 +696,7 @@ static UINT8 ArchiveValue(UINT8 **p, int TABLESINDEX, int myindex) } lua_pop(gL, 1); } + if (!found) { t++; @@ -1231,7 +1232,6 @@ void LUA_Archive(savebuffer_t *save, boolean network) WRITEUINT32(save->p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. LUA_HookNetArchive(NetArchive, save); // call the NetArchive hook in archive mode - //LUA_HookNetArchive(NetArchive); // call the NetArchive hook in archive mode } ArchiveTables(&save->p); @@ -1272,7 +1272,6 @@ void LUA_UnArchive(savebuffer_t *save, boolean network) } while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker. LUA_HookNetArchive(NetUnArchive, save); // call the NetArchive hook in unarchive mode - //LUA_HookNetArchive(NetUnArchive); // call the NetArchive hook in unarchive mode } UnArchiveTables(&save->p, network); diff --git a/src/lua_script.h b/src/lua_script.h index 9b8c65e20..47dfd245b 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -64,7 +64,6 @@ void LUA_CVarChanged(const char *name); // lua_consolelib.c int Lua_optoption(lua_State *L, int narg, int def, int list_ref); int Lua_CreateFieldTable(lua_State *L, const char *const lst[]); void LUA_HookNetArchive(lua_CFunction archFunc, savebuffer_t *save); -//void LUA_HookNetArchive(lua_CFunction archFunc); // Console wrapper void COM_Lua_f(void); diff --git a/src/lzf.c b/src/lzf.c index f81c3ee0a..96f8973fc 100644 --- a/src/lzf.c +++ b/src/lzf.c @@ -37,9 +37,8 @@ /* * Sacrifice very little compression quality in favour of compression speed. * This gives almost the same compression as the default code, and is - * (very roughly) 15% faster. This is the preferable mode of operation. + * (very roughly) 15% faster. This is the preferred mode of operation. */ - #ifndef VERY_FAST # define VERY_FAST 1 #endif @@ -48,7 +47,7 @@ * Sacrifice some more compression quality in favour of compression speed. * (roughly 1-2% worse compression for large blocks and * 9-10% for small, redundant, blocks and >>20% better speed in both cases) - * In INT16: when in need for speed, enable this for binary data, + * In short: when in need for speed, enable this for binary data, * possibly disable this for text data. */ #ifndef ULTRA_FAST @@ -80,7 +79,8 @@ /* * You may choose to pre-set the hash table (might be faster on some - * modern cpus and large (>>64k) blocks) + * modern cpus and large (>>64k) blocks, and also makes compression + * deterministic/repeatable when the configuration otherwise is the same). */ #ifndef INIT_HTAB # define INIT_HTAB 1 @@ -88,15 +88,15 @@ /* * Avoid assigning values to errno variable? for some embedding purposes - * (linux kernel for example), this is neccessary. NOTE: this breaks - * the documentation in lzf.h. + * (linux kernel for example), this is necessary. NOTE: this breaks + * the documentation in lzf.h. Avoiding errno has no speed impact. */ #ifndef AVOID_ERRNO # define AVOID_ERRNO 0 #endif /* - * Wether to pass the LZF_STATE variable as argument, or allocate it + * Whether to pass the LZF_STATE variable as argument, or allocate it * on the stack. For small-stack environments, define this to 1. * NOTE: this breaks the prototype in lzf.h. */ @@ -105,11 +105,11 @@ #endif /* - * Wether to add extra checks for input validity in lzf_decompress + * Whether to add extra checks for input validity in lzf_decompress * and return EINVAL if the input stream has been corrupted. This * only shields against overflowing the input buffer and will not * detect most corrupted streams. - * This check is not normally noticable on modern hardware + * This check is not normally noticeable on modern hardware * (<1% slowdown), but might slow down older cpus considerably. */ #ifndef CHECK_INPUT diff --git a/src/m_aatree.c b/src/m_aatree.c index f19fa1dc0..45482f6f3 100644 --- a/src/m_aatree.c +++ b/src/m_aatree.c @@ -98,7 +98,6 @@ static aatree_node_t *M_AATreeSet_Node(aatree_node_t *node, UINT32 flags, INT32 if (!node) { // Nothing here, so just add where we are - node = Z_Malloc(sizeof (aatree_node_t), PU_STATIC, NULL); node->level = 1; node->key = key; @@ -134,11 +133,11 @@ void M_AATreeSet(aatree_t *aatree, INT32 key, void* value) // and nodes with value == NULL. static void *M_AATreeGet_Node(aatree_node_t *node, INT32 key) { - if (node) + if (LIKELY(node)) { - if (node->key == key) + if (UNLIKELY(node->key == key)) return node->value; - else if(node->key < key) + else if (node->key < key) return M_AATreeGet_Node(node->right, key); else return M_AATreeGet_Node(node->left, key); @@ -152,7 +151,6 @@ void *M_AATreeGet(aatree_t *aatree, INT32 key) return M_AATreeGet_Node(aatree->root, key); } - static void M_AATreeIterate_Node(aatree_node_t *node, aatree_iter_t callback) { if (node->left) M_AATreeIterate_Node(node->left, callback); diff --git a/src/m_cheat.c b/src/m_cheat.c index 5f8648cbd..1cdb57419 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -864,7 +864,7 @@ static boolean OP_HeightOkay(player_t *player, UINT8 ceiling) { // Truncate position to match where mapthing would be when spawned // (this applies to every further P_GetZAt call as well) - fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->ceilingheight; + fixed_t cheight = P_GetSectorCeilingZAt(sec, (player->mo->x & 0xFFFF0000), (player->mo->y & 0xFFFF0000)); if (((cheight - player->mo->z - player->mo->height)>>FRACBITS) >= (1 << (16-ZSHIFT))) { @@ -875,7 +875,8 @@ static boolean OP_HeightOkay(player_t *player, UINT8 ceiling) } else { - fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight; + fixed_t fheight = P_GetSectorFloorZAt(sec, (player->mo->x & 0xFFFF0000), (player->mo->y & 0xFFFF0000)); + if (((player->mo->z - fheight)>>FRACBITS) >= (1 << (16-ZSHIFT))) { CONS_Printf(M_GetText("Sorry, you're too %s to place this object (max: %d %s).\n"), M_GetText("high"), @@ -922,12 +923,12 @@ static mapthing_t *OP_CreateNewMapThing(player_t *player, UINT16 type, boolean c mt->y = (INT16)(player->mo->y>>FRACBITS); if (ceiling) { - fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, mt->x << FRACBITS, mt->y << FRACBITS) : sec->ceilingheight; + fixed_t cheight = P_GetSectorCeilingZAt(sec, (mt->x << FRACBITS), (mt->y << FRACBITS)); mt->options = (UINT16)((cheight - player->mo->z - player->mo->height)>>FRACBITS); } else { - fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, mt->x << FRACBITS, mt->y << FRACBITS) : sec->floorheight; + fixed_t fheight = P_GetSectorFloorZAt(sec, (mt->x << FRACBITS), (mt->y << FRACBITS)); mt->options = (UINT16)((player->mo->z - fheight)>>FRACBITS); } mt->options <<= ZSHIFT; @@ -984,8 +985,7 @@ void OP_NightsObjectplace(player_t *player) UINT16 angle = (UINT16)(player->anotherflyangle % 360); INT16 temp = (INT16)FixedInt(AngleFixed(player->mo->angle)); // Traditional 2D Angle sector_t *sec = player->mo->subsector->sector; - fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight; - + fixed_t fheight = P_GetSectorFloorZAt(sec, (player->mo->x & 0xFFFF0000), (player->mo->y & 0xFFFF0000)); player->pflags |= PF_ATTACKDOWN; @@ -1141,12 +1141,12 @@ void OP_ObjectplaceMovement(player_t *player) if (!!(mobjinfo[op_currentthing].flags & MF_SPAWNCEILING) ^ !!(cv_opflags.value & MTF_OBJECTFLIP)) { - fixed_t cheight = sec->c_slope ? P_GetZAt(sec->c_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->ceilingheight; + fixed_t cheight = P_GetSectorCeilingZAt(sec, (player->mo->x & 0xFFFF0000), (player->mo->y & 0xFFFF0000)); op_displayflags = (UINT16)((cheight - player->mo->z - mobjinfo[op_currentthing].height)>>FRACBITS); } else { - fixed_t fheight = sec->f_slope ? P_GetZAt(sec->f_slope, player->mo->x & 0xFFFF0000, player->mo->y & 0xFFFF0000) : sec->floorheight; + fixed_t fheight = P_GetSectorFloorZAt(sec, (player->mo->x & 0xFFFF0000), (player->mo->y & 0xFFFF0000)); op_displayflags = (UINT16)((player->mo->z - fheight)>>FRACBITS); } op_displayflags <<= ZSHIFT; diff --git a/src/m_menu.c b/src/m_menu.c index 0ec2540a2..72c28857c 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -343,6 +343,8 @@ menu_t OP_SoundOptionsDef; menu_t OP_SoundAdvancedDef; //static void M_RestartAudio(void); +menu_t OP_FocusOptionsDef; + //Misc menu_t OP_DataOptionsDef, OP_ScreenshotOptionsDef, OP_EraseDataDef; menu_t OP_ProtocolDef; @@ -645,6 +647,7 @@ static menuitem_t MISC_ReplayOptionsMenu[] = {IT_CVAR|IT_STRING, NULL, "Sync Check Interval", &cv_netdemosyncquality, 20}, {IT_CVAR|IT_STRING, NULL, "Max demo size (MiB)", &cv_maxdemosize, 30}, {IT_CVAR|IT_STRING, NULL, "Replay Search Rate", &cv_replaysearchrate, 40}, + {IT_CVAR|IT_STRING, NULL, "Replay Date Format", &cv_demodateformat, 50}, }; static tic_t playback_last_menu_interaction_leveltime = 0; @@ -1142,22 +1145,42 @@ static menuitem_t OP_MainMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Video Options...", &OP_VideoOptionsDef, 15}, {IT_SUBMENU|IT_STRING, NULL, "Sound Options...", &OP_SoundOptionsDef, 25}, + {IT_SUBMENU|IT_STRING, NULL, "Game Focus Options...", &OP_FocusOptionsDef, 35}, - {IT_SUBMENU|IT_STRING, NULL, "HUD Options...", &OP_HUDOptionsDef, 40}, - {IT_SUBMENU|IT_STRING, NULL, "Camera Options...", &OP_CamOptionsDef, 50}, - {IT_SUBMENU|IT_STRING, NULL, "Gameplay Options...", &OP_GameOptionsDef, 60}, - {IT_SUBMENU|IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 70}, + {IT_SUBMENU|IT_STRING, NULL, "HUD Options...", &OP_HUDOptionsDef, 50}, + {IT_SUBMENU|IT_STRING, NULL, "Camera Options...", &OP_CamOptionsDef, 60}, + {IT_SUBMENU|IT_STRING, NULL, "Gameplay Options...", &OP_GameOptionsDef, 70}, + {IT_SUBMENU|IT_STRING, NULL, "Server Options...", &OP_ServerOptionsDef, 80}, - {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 85}, - {IT_CALL|IT_STRING, NULL, "Custom Options...", M_CustomCvarMenu, 95}, + {IT_SUBMENU|IT_STRING, NULL, "Data Options...", &OP_DataOptionsDef, 95}, + {IT_CALL|IT_STRING, NULL, "Custom Addon Options...", M_CustomCvarMenu, 105}, - {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 105}, - {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 115}, + {IT_CALL|IT_STRING, NULL, "Tricks & Secrets (F1)", M_Manual, 115}, + {IT_CALL|IT_STRING, NULL, "Play Credits", M_Credits, 125}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 135}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 140}, - {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 145}, - {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 155}, + {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 150}, + {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 160}, +}; + +enum +{ + ctrlsetup, + vidopt, + soundopt, + focusopt, + hudopt, + camopt, + gameopt, + serveropt, + dataopt, + addonopt, + tricksandshit, + credits, + satopt, + bird, + localskin }; static menuitem_t OP_ControlsMenu[] = @@ -1400,31 +1423,30 @@ static const char* OP_MouseTooltips[] = static menuitem_t OP_VideoOptionsMenu[] = { - {IT_STRING | IT_CALL, NULL, "Set Resolution...", M_VideoModeMenu, 10}, + {IT_STRING | IT_CALL, NULL, "Set Resolution...", M_VideoModeMenu, 10}, #if defined (__unix__) || defined (UNIXCOMMON) || defined (HAVE_SDL) - {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 20}, + {IT_STRING|IT_CVAR, NULL, "Fullscreen", &cv_fullscreen, 20}, #endif {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Brightness", &cv_globalgamma, 30}, + NULL, "Brightness", &cv_globalgamma, 30}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Saturation", &cv_globalsaturation , 40}, + NULL, "Saturation", &cv_globalsaturation , 40}, - {IT_SUBMENU|IT_STRING, NULL, "Advanced Color Settings...", &OP_ColorOptionsDef, 50}, + {IT_SUBMENU|IT_STRING, NULL, "Advanced Color Settings...", &OP_ColorOptionsDef, 50}, - {IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 65}, - {IT_STRING | IT_CVAR, NULL, "Weather Draw Distance",&cv_drawdist_precip, 75}, + {IT_STRING | IT_CVAR, NULL, "Draw Distance", &cv_drawdist, 65}, + {IT_STRING | IT_CVAR, NULL, "Weather Draw Distance", &cv_drawdist_precip, 75}, - {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 95}, - {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 105}, - {IT_STRING | IT_CVAR, NULL, "FPS Cap", &cv_fpscap, 115}, - {IT_STRING | IT_CVAR, NULL, "Drift spark pulse size",&cv_driftsparkpulse, 125}, - {IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 135}, + {IT_STRING | IT_CVAR, NULL, "Show FPS", &cv_ticrate, 95}, + {IT_STRING | IT_CVAR, NULL, "Vertical Sync", &cv_vidwait, 105}, + {IT_STRING | IT_CVAR, NULL, "FPS Cap", &cv_fpscap, 115}, + {IT_STRING | IT_CVAR, NULL, "Drift spark pulse size", &cv_driftsparkpulse, 125}, + {IT_STRING | IT_CVAR, NULL, "VHS effect", &cv_vhseffect, 135}, #ifdef HWRENDER - {IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "OpenGL Options...", &OP_OpenGLOptionsDef, 145}, #endif - {IT_SUBMENU|IT_STRING, NULL, "Advanced Video Options...", &OP_ExpOptionsDef, 155}, - + {IT_SUBMENU|IT_STRING, NULL, "Advanced Video Options...", &OP_ExpOptionsDef, 155}, }; static const char* OP_VideoTooltips[] = @@ -1520,23 +1542,29 @@ static menuitem_t OP_ColorOptionsMenu[] = static menuitem_t OP_ExpOptionsMenu[] = { - {IT_HEADER, NULL, "Advanced Video Options", NULL, 10}, - {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_maxinterpdist, 30}, - {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 40}, + {IT_HEADER, NULL, "Advanced Video Options", NULL, 0}, + {IT_STRING|IT_CVAR, NULL, "Interpolation Distance", &cv_maxinterpdist, 10}, + {IT_STRING | IT_CVAR, NULL, "Weather Interpolation", &cv_precipinterp, 15}, - {IT_STRING | IT_CVAR, NULL, "Scale Weather with Mobjscale", &cv_mobjscaleprecip, 60}, - {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 70}, + {IT_STRING | IT_CVAR, NULL, "Scale Weather with Mobjscale", &cv_mobjscaleprecip, 25}, + {IT_STRING | IT_CVAR, NULL, "Less Weather Effects", &cv_lessprecip, 30}, - {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 80}, + //{IT_STRING | IT_CVAR, NULL, "Randomized Directional Light", &cv_randomdirlight, 55}, // should this ever come back - {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 90}, + {IT_STRING | IT_CVAR, NULL, "Skyboxes", &cv_skybox, 40}, + + {IT_STRING | IT_CVAR, NULL, "FPS counter sampling", &cv_accuratefps, 50}, #ifdef HWRENDER - {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 110}, + {IT_STRING | IT_CVAR, NULL, "Screen Textures", &cv_glscreentextures, 60}, #ifdef USE_FBO_OGL - {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 120}, + {IT_STRING | IT_CVAR, NULL, "FBO Downsampling support", &cv_glframebuffer, 65}, + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 75}, + {IT_DISABLED, NULL, "", NULL, 85}, // dummy text +#else + {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 70}, + {IT_DISABLED, NULL, "", NULL, 80}, // dummy text #endif - {IT_STRING | IT_CVAR, NULL, "Palette Depth", &cv_glpalettedepth, 140}, #endif }; @@ -1547,6 +1575,7 @@ static const char* OP_ExpTooltips[] = "Should weather be interpolated? Weather should look about the\nsame but perform a bit better when disabled.", "Should weather be scaled with Mapobjectscale?.", "When weather is on this will cut the object amount used in half.", + //"Should the directional lightning be randomized each map?\nTakes effect on next map load.", "Toggle being able to see the sky.", "Change the FPS counter sampling method\nInaccurate updates slower and might miss frame drops and such\nAccurate updates faster and is more accurate, but might be less readable", // how to ingles?? #ifdef HWRENDER @@ -1554,7 +1583,7 @@ static const char* OP_ExpTooltips[] = #ifdef USE_FBO_OGL "Allows the game to downsample from a higher resolution than your display\nin OpenGL renderer mode. Requires a GPU with atleast OpenGL 3.0 support.", #endif - "Change the depth of the Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", + "Change the bit depth of the Lookup Palette in Palette rendering mode\n 16 bits is like software looks ingame\nwhile 24 bits is how software looks in screenshots.", #endif }; @@ -1565,6 +1594,7 @@ enum op_exp_precipinter, op_exp_precipmoscale, op_exp_lessprecip, + //op_exp_dirlight, op_exp_skybox, op_exp_accuratefps, #ifdef HWRENDER @@ -1587,7 +1617,7 @@ static menuitem_t OP_OpenGLOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Palette Rendering Flashpals",&cv_glflashpal, 35}, {IT_STRING | IT_CVAR, NULL, "Min Shader Brightness", &cv_glsecbright, 40}, - {IT_STRING | IT_CVAR, NULL, "Texture Quality", &cv_scr_depth, 50}, + {IT_STRING | IT_CVAR, NULL, "Texture Quality", &cv_gltexturedepth, 50}, {IT_STRING | IT_CVAR, NULL, "Texture Filter", &cv_glfiltermode, 55}, {IT_STRING | IT_CVAR, NULL, "Anisotropic", &cv_glanisotropicmode, 60}, {IT_STRING | IT_CVAR, NULL, "Visual Portals", &cv_glportals, 65}, @@ -1670,9 +1700,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 105}, {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 115}, - {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 125}, - {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 135}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 145} + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 125} #else {IT_STRING|IT_CVAR, NULL, "Reverse L/R Channels", &stereoreverse, 60}, @@ -1684,9 +1712,7 @@ static menuitem_t OP_SoundOptionsMenu[] = {IT_KEYHANDLER|IT_STRING, NULL, "Sound Test", M_HandleSoundTest, 115}, {IT_STRING|IT_CALL, NULL, "Music Test", M_MusicTest, 125}, - {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 135}, - {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 145}, - {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 155} + {IT_STRING|IT_SUBMENU, NULL, "Advanced Settings...", &OP_SoundAdvancedDef, 135} #endif }; @@ -1707,8 +1733,6 @@ static const char* OP_SoundTooltips[] = "Should the powerup warning be a sound effect or music?", "Testing sounds...", "Testing music...", - "Should the games music play while unfocused?", - "Should the games sound play while unfocused?", "Options for advanced sound settings.", }; @@ -1718,23 +1742,24 @@ static menuitem_t OP_SoundAdvancedMenu[] = #ifdef HAVE_OPENMPT {IT_HEADER, NULL, "Tracker Module Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 20}, - {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 30}, + {IT_STRING | IT_CVAR, NULL, "Instrument Filter", &cv_modfilter, 10}, + {IT_STRING | IT_CVAR, NULL, "Amiga Resampler", &cv_amigafilter, 20}, #if OPENMPT_API_VERSION_MAJOR < 1 && OPENMPT_API_VERSION_MINOR > 4 - {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 40}, + {IT_STRING | IT_CVAR, NULL, "Amiga Type", &cv_amigatype, 25}, #endif - {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 50}, + {IT_STRING | IT_CVAR, NULL, "Stereo Seperation", &cv_stereosep, 35}, #endif - {IT_HEADER, NULL, "Misc", NULL, 70}, + {IT_HEADER, NULL, "Misc", NULL, 45}, - {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 90}, - {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 100}, + {IT_STRING | IT_CVAR, NULL, "Grow Music", &cv_growmusic, 55}, + {IT_STRING | IT_CVAR, NULL, "Invulnerability Music", &cv_supermusic, 60}, - {IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 120}, - {IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 130}, + {IT_STRING | IT_CVAR, NULL, "Keep Map Music", &cv_keepmusic, 70}, + {IT_STRING | IT_CVAR, NULL, "Skip Intro Music", &cv_skipintromusic, 75}, - {IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 150}, + {IT_STRING | IT_CVAR, NULL, "Audio Buffer Size", &cv_audbuffersize, 80}, + {IT_DISABLED, NULL, "", NULL, 90}, // dummy text }; static const char* OP_SoundAdvancedTooltips[] = @@ -1757,6 +1782,30 @@ static const char* OP_SoundAdvancedTooltips[] = "Size of the Audio Buffer\nreducing it will result in less sound latency\nbut may cause issues such as crackling or distorted Sound.", }; +static menuitem_t OP_FocusOptionsMenu[] = +{ + {IT_HEADER, NULL, "Game Focus Options", NULL, 0}, + + {IT_STRING|IT_CVAR, NULL, "Play Music While Unfocused", &cv_playmusicifunfocused, 30}, + {IT_STRING|IT_CVAR, NULL, "Play SFX While Unfocused", &cv_playsoundifunfocused, 40}, + + {IT_STRING|IT_CVAR, NULL, "Pause Game While Unfocused", &cv_pauseifunfocused, 60}, + + {IT_STRING|IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 80}, + + {IT_STRING|IT_CVAR, NULL, "Always Grab Mouse While Focused", &cv_alwaysgrabmouse, 100}, +}; + +static const char* OP_FocusOptionsTooltips[] = +{ + NULL, + "Should music play while the game is unfocused?", + "Should soundeffects play while the game is unfocused?", + "Should the game pause while the game is unfocused?", + "Should the FOCUS LOST window appear\n while the game is unfocused?", + "Should the mouse cursor be grabbed and hidden\n while the game is in focus?", +}; + static menuitem_t OP_DataOptionsMenu[] = { {IT_STRING | IT_CALL, NULL, "Screenshot Options...", M_ScreenshotOptions, 10}, @@ -1775,25 +1824,25 @@ static menuitem_t OP_DataOptionsMenu[] = static menuitem_t OP_ScreenshotOptionsMenu[] = { {IT_HEADER, NULL, "Screenshots (F8)", NULL, 5}, - {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_screenshot_option, 15}, - {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 25}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 55}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 65}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 75}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 85}, + {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_screenshot_option, 10}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 15}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 30}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 35}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 40}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 45}, - {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 100}, - {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_movie_option, 110}, - {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_movie_folder, 120}, - {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 150}, + {IT_HEADER, NULL, "Movie Mode (F9)", NULL, 55}, + {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_movie_option, 60}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_movie_folder, 65}, + {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 80}, - {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 160}, - {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 170}, + {IT_STRING|IT_CVAR, NULL, "Region Optimizing", &cv_gif_optimize, 90}, + {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 95}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 160}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 170}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 180}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 190}, + {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 90}, + {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 95}, + {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 100}, + {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 105}, }; enum @@ -1855,30 +1904,28 @@ static menuitem_t OP_DiscordOptionsMenu[] = static menuitem_t OP_HUDOptionsMenu[] = { - {IT_STRING | IT_CVAR, NULL, "Show HUD (F3)", &cv_showhud, 10}, + {IT_STRING | IT_CVAR, NULL, "Show HUD (F3)", &cv_showhud, 10}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "HUD Visibility", &cv_translucenthud, 20}, + NULL, "HUD Visibility", &cv_translucenthud, 20}, - {IT_STRING | IT_SUBMENU, NULL, "Online HUD options...", &OP_ChatOptionsDef, 35}, - {IT_STRING | IT_CVAR, NULL, "Background Glass", &cons_backcolor, 45}, + {IT_STRING | IT_SUBMENU, NULL, "Online HUD options...", &OP_ChatOptionsDef, 35}, + {IT_STRING | IT_CVAR, NULL, "Background Glass", &cons_backcolor, 45}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Minimap Visibility", &cv_kartminimap, 60}, - {IT_STRING | IT_CVAR, NULL, "Speedometer Display", &cv_kartspeedometer, 70}, - {IT_STRING | IT_CVAR, NULL, "Show \"CHECK\"", &cv_kartcheck, 80}, + NULL, "Minimap Visibility", &cv_kartminimap, 60}, + {IT_STRING | IT_CVAR, NULL, "Speedometer Display", &cv_kartspeedometer, 70}, + {IT_STRING | IT_CVAR, NULL, "Show \"CHECK\"", &cv_kartcheck, 80}, - {IT_STRING | IT_CVAR, NULL, "Menu Highlights", &cons_menuhighlight, 95}, + {IT_STRING | IT_CVAR, NULL, "Menu Highlights", &cons_menuhighlight, 95}, // highlight info - (GOOD HIGHLIGHT, WARNING HIGHLIGHT) - 110 (see M_DrawHUDOptions) - {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 120}, + {IT_STRING | IT_CVAR, NULL, "Console Text Size", &cv_constextsize, 120}, - {IT_STRING | IT_CVAR, NULL, "Show Track Addon Name", &cv_showtrackaddon, 135}, + {IT_STRING | IT_CVAR, NULL, "Show Track Addon Name", &cv_showtrackaddon, 135}, - {IT_STRING | IT_CVAR, NULL, "Show All Maps", &cv_showallmaps, 145}, + {IT_STRING | IT_CVAR, NULL, "Show All Maps", &cv_showallmaps, 145}, - {IT_STRING | IT_CVAR, NULL, "Show \"FOCUS LOST\"", &cv_showfocuslost, 155}, - - {IT_STRING | IT_CVAR, NULL, "2D character select", &cv_skinselectmenu, 165}, + {IT_STRING | IT_CVAR, NULL, "2D character select", &cv_skinselectmenu, 155}, }; static menuitem_t OP_CamOptionsMenu[] = @@ -1887,23 +1934,16 @@ static menuitem_t OP_CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Field of View",&cv_fov, 30}, - {IT_STRING | IT_CVAR, NULL, "Lagless Camera", &cv_laglesscam, 50}, - {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom, 60}, - {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook, 70}, - - {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 90}, - {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 100}, - {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 110}, - {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 120}, + {IT_STRING | IT_SUBMENU, NULL, "Player 1 Camera options...", &OP_Player1CamOptionsDef, 50}, + {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 60}, + {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 70}, + {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 80}, }; static const char* OP_CamOptionsTooltips[] = { NULL, "Player field of view.", - "Removes Camera Lag in netgames\nMay cause Camera stutters in poor net conditions.", - "Should looking back inherit the Players Momentum?\nEither inherit Player Momentum or double of it\nmay make looking back while boosting or going in high speed less jarring", - "Allows looking up/down by holding aim forward/backward while standing still.", NULL, NULL, NULL, @@ -1919,9 +1959,13 @@ static menuitem_t OP_Player1CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[0], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[0], 70}, - {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[0], 90}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[0], 90}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[0], 105}, + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[0], 100}, + + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[0], 120}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[0], 135}, }; static menuitem_t OP_Player2CamOptionsMenu[] = @@ -1933,9 +1977,13 @@ static menuitem_t OP_Player2CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[1], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[1], 70}, - {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[1], 90}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[1], 90}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[1], 105}, + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[1], 100}, + + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[1], 120}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[1], 135}, }; static menuitem_t OP_Player3CamOptionsMenu[] = @@ -1947,9 +1995,13 @@ static menuitem_t OP_Player3CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[2], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[2], 70}, - {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[2], 90}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[2], 90}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[2], 105}, + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[2], 100}, + + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[2], 120}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[2], 135}, }; static menuitem_t OP_Player4CamOptionsMenu[] = @@ -1961,9 +2013,13 @@ static menuitem_t OP_Player4CamOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[3], 60}, {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[3], 70}, - {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[3], 90}, + {IT_STRING | IT_CVAR, NULL, "Camera Lookback Momentum", &cv_lookbackmom[3], 90}, - {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[3], 105}, + {IT_STRING | IT_CVAR, NULL, "Camera Vertical Look", &cv_verticallook[3], 100}, + + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[3], 120}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[3], 135}, }; static const char* OP_PlayerCamOptionsTooltips[] = @@ -1973,6 +2029,8 @@ static const char* OP_PlayerCamOptionsTooltips[] = "Camera distance relative to the Player.", "Height of the Camera", "Speed of the Camera", + "Should looking back inherit the Players Momentum?\nEither inherit Player Momentum or double of it\nmay make looking back while boosting or going in high speed less jarring", + "Allows looking up/down by holding\naim forward/backward while standing still.", "Speed of the Freecam/Spectator Camera", "Toggle between Third or First Person camera", }; @@ -2036,6 +2094,21 @@ static menuitem_t OP_GameOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Restrict Character Changes", &cv_restrictskinchange, 150}, }; +enum +{ + op_game_ittggl, + op_game_spd, + op_game_frantic, + op_game_encore, + op_game_numlaps, + op_game_countdown, + op_game_timelimit, + op_game_startbump, + op_game_karma, + op_game_forcechar, + op_game_restrictchar, +}; + static const char* OP_GameTooltips[] = { "Toggles for all in-game items.", @@ -2102,7 +2175,7 @@ static menuitem_t OP_AdvServerOptionsMenu[] = NULL, "Server Browser Address", &cv_masterserver, 10}, #endif {IT_STRING | IT_CVAR, NULL, "Attempts to resynchronise", &cv_resynchattempts, 25}, -#ifdef SATURNSYNCH +#ifdef SATURNPAK {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Cooldown", &cv_resynchcooldown, 35}, {IT_STRING | IT_CVAR, NULL, "Resend Gamestate Attempts", &cv_gamestateattempts, 40}, @@ -2136,7 +2209,7 @@ static const char* OP_AdvServerOptionsTooltips[] = { "Server used for master server.", "Attempts to resynchronise player to server.", -#ifdef SATURNSYNCH +#ifdef SATURNPAK "Cooldown in seconds before the Server attempts\nto resend the gamestate to a Saturn Client\nbetween resending attempts.", "Attempts to resend the Gamestate to player\nThis increments a Counter everytime a gamestate resend occurs\nThis Counter decrements at double the time of the Cooldown\nonce the Counter reaches the threshold, the client gets kicked.", #endif @@ -2224,33 +2297,45 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Serverqueue waittime", &cv_connectawaittime, 10}, - {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 20}, + {IT_STRING | IT_CVAR, NULL, "Minimum Input Delay", &cv_mindelay, 20}, + {IT_STRING | IT_CVAR, NULL, "Gentlemens Ping", &cv_gentlemens, 25}, - {IT_STRING | IT_CVAR, NULL, "Colourized Speedlines", &cv_coloredspeedlines, 30}, - {IT_STRING | IT_CVAR, NULL, "Colourized Sneakertrails", &cv_coloredsneakertrail, 35}, + {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 35}, - {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 45}, + {IT_STRING | IT_CVAR, NULL, "Colorized Speedlines", &cv_coloredspeedlines, 45}, + {IT_STRING | IT_CVAR, NULL, "Colorized Sneakertrails", &cv_coloredsneakertrail, 40}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 55}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 65}, + {IT_STRING | IT_CVAR, NULL, "Player Blendeffects", &cv_playerblendeffects, 50}, - {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 70}, + {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 60}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 80}, + {IT_STRING | IT_CVAR, NULL, "Midair Driftsparks", &cv_airsparks, 70}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 90}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 95}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 105}, // uwu + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 80}, + + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 90}, + + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 100}, + + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 110}, + + {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 120}, + {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 125}, + {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 130}, // uwu }; static const char* OP_SaturnTooltips[] = { NULL, "How long can the game wait before it kicks you out from the server\nconnecting screen.", + "Practice for online play! 0 = instant response.", + "Simulate online input delay when hosting a server.\nValue choosen by Player with the lowest ping", "How much speen do you want?", "Colourize the speedlines in your skincolor if you go fast enough!", "Colourize the sneaker flame trails in your skincolor!", + "Enables blending effects for certain player effects when boosting.", "Makes bananas and other items jump and jitter\nwhen dragged behind.", + "Keep your driftsparks going while in air.", "Show Localskin Menus.", "Force menu to only use uppercase.", "Use your desired Keyboard Layout for Text Input\nthis is either the Default, Native or Azerty\nNative does not affect Gameplay only Text!", @@ -2264,10 +2349,14 @@ enum { sm_header, sm_waittime, + sm_mindelay, + sm_gentlemens, sm_skinselspeed, sm_colorlines, sm_colorflames, + sm_blendeffects, sm_bananjumpy, + sm_airsparks, sm_showlocalskin, op_uppercase_menu, sm_nativkey, @@ -2281,18 +2370,21 @@ static menuitem_t OP_PlayerDistortMenu[] = { {IT_HEADER, NULL, "Sprite Distortion", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Sprite Slope Rotation", &cv_sloperoll, 15}, - {IT_STRING | IT_CVAR, NULL, "Slope Rotation Distance", &cv_sloperolldist, 30}, + {IT_STRING | IT_CVAR, NULL, "Sprite Slope Rotation", &cv_sloperoll, 10}, + {IT_STRING | IT_CVAR, NULL, "Slope Rotation Distance", &cv_sloperolldist, 15}, - {IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 45}, - {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 60}, - {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 75}, + {IT_STRING | IT_CVAR, NULL, "Rotate Players when Sliptiding", &cv_sliptideroll, 25}, + {IT_STRING | IT_CVAR, NULL, "Rotate Sparks and Boost Trails", &cv_sparkroll, 30}, + {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 35}, - {IT_STRING | IT_CVAR, NULL, "Player Stretch Factor", &cv_gravstretch, 90}, - {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 105}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 120}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 135}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 150}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Player Stretch Factor", &cv_gravstretch, 45}, + {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 50}, + + {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 60}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Saltyhop Height", &cv_saltyheight, 65}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 70}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 75}, + {IT_STRING | IT_CVAR, NULL, "Saltyhop Roll", &cv_saltyroll, 80}, }; static const char* OP_PlayerDistortTooltips[] = @@ -2306,8 +2398,10 @@ static const char* OP_PlayerDistortTooltips[] = "Player squash and stretch.", "Player landing sound effect.", "Kart hopping while drifting. This is purely visual.", + "Jump Height for Kart hopping.", "Player hop sound effect.", "Player hop squash and stretch.", + "Should the player rotation be kept during player hop.", }; enum @@ -2321,8 +2415,10 @@ enum stretchyplayer, squishsound, salthmmm, + saltheight, saltsound, saltsquishy, + saltroll, }; static menuitem_t OP_SaturnHudMenu[] = @@ -2336,7 +2432,7 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 30}, {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 35}, - {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 45}, + {IT_STRING | IT_CVAR, NULL, "Input Display", &cv_showinput, 45}, {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 55}, @@ -2357,15 +2453,16 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 135}, {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 140}, {IT_STRING | IT_CVAR, NULL, "Spin Minimap Icons", &cv_spinoutroll, 150}, + {IT_STRING | IT_CVAR, NULL, "Player Angle Dot", &cv_showminimapangle, 160}, - {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 160}, + {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 170}, - {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 170}, + {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 180}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 180}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 185}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 190}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 195}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 195}, + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 205}, }; static const char* OP_SaturnHudTooltips[] = @@ -2376,7 +2473,7 @@ static const char* OP_SaturnHudTooltips[] = "Enable colourized hud.", "Enable the colourized itembox when colourized hud is enabled.", "The color to use instead of the player color when\ncolourized hud is enabled.", - "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", + "Displays the input display and lets you choose its style.", "Enable the stat display.", "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "Make the Postionnumber half the size.", @@ -2390,6 +2487,7 @@ static const char* OP_SaturnHudTooltips[] = "Show player names on the minimap.", "Minimize the player icons on the minimap.", "Erratically rotate player icons during spinouts.", + "Show a dot showing the player facing angle.", "Make the Intermission screen look like in beta versions of Kart!\nEither with background or just the rest.", "Show the Director Toggle prompt when spectating.", "Nametag Options.", @@ -2419,6 +2517,7 @@ enum sh_mapname, sh_smallmap, sh_iconspinout, + sh_minidot, sh_betainter, sh_directorhud, sh_nametagmen, @@ -2473,39 +2572,45 @@ static menuitem_t OP_SaturnCreditsMenu[] = { {IT_HEADER, NULL, "Saturn Credits", NULL, 0}, - {IT_HEADER, NULL, "Thanks to all contributers <3", NULL, 15}, + {IT_HEADER, NULL, "Thanks to all contributers <3", NULL, 7}, - {IT_STRING2+IT_SPACE, NULL, "Alug", NULL, 20}, - {IT_STRING2+IT_SPACE, NULL, "Indev", NULL, 30}, - {IT_STRING2+IT_SPACE, NULL, "Haya", NULL, 40}, - {IT_STRING2+IT_SPACE, NULL, "Nepdisk", NULL, 50}, - {IT_STRING2+IT_SPACE, NULL, "GenericHeroGuy", NULL, 60}, - {IT_STRING2+IT_SPACE, NULL, "xyzzy", NULL, 70}, - {IT_STRING2+IT_SPACE, NULL, "Chearii", NULL, 80}, + {IT_STRING2+IT_SPACE, NULL, "Alug", NULL, 17}, + {IT_STRING2+IT_SPACE, NULL, "Indev", NULL, 27}, + {IT_STRING2+IT_SPACE, NULL, "Haya", NULL, 37}, + {IT_STRING2+IT_SPACE, NULL, "Nepdisk", NULL, 47}, + {IT_STRING2+IT_SPACE, NULL, "GenericHeroGuy", NULL, 57}, + {IT_STRING2+IT_SPACE, NULL, "xyzzy", NULL, 67}, + {IT_STRING2+IT_SPACE, NULL, "Chearii", NULL, 77}, - {IT_STRING+IT_SPACE, NULL, "", NULL, 83}, // dummy text + {IT_STRING2+IT_SPACE, NULL, "Sunflower aka AnimeSonic", NULL, 87}, + {IT_STRING2+IT_SPACE, NULL, "Yuz aka Yuzler", NULL, 97}, + {IT_STRING2+IT_SPACE, NULL, "Democrab", NULL, 107}, + {IT_STRING2+IT_SPACE, NULL, "EXpand", NULL, 117}, + {IT_STRING2+IT_SPACE, NULL, "Nexit", NULL, 127}, + {IT_STRING2+IT_SPACE, NULL, "Spee", NULL, 137}, + {IT_STRING2+IT_SPACE, NULL, "Jin", NULL, 147}, + {IT_STRING2+IT_SPACE, NULL, "riomccloud", NULL, 157}, + {IT_STRING2+IT_SPACE, NULL, "chromaticpipe", NULL, 167}, + {IT_STRING2+IT_SPACE, NULL, "Achii", NULL, 177}, + {IT_STRING2+IT_SPACE, NULL, "Anonimus", NULL, 187}, + {IT_STRING2+IT_SPACE, NULL, "scizor300", NULL, 197}, - {IT_STRING2+IT_SPACE, NULL, "Sunflower aka AnimeSonic", NULL, 90}, - {IT_STRING2+IT_SPACE, NULL, "Yuz aka Yuzler", NULL, 100}, - {IT_STRING2+IT_SPACE, NULL, "Democrab", NULL, 110}, - {IT_STRING2+IT_SPACE, NULL, "EXpand aka Maver", NULL, 120}, - {IT_STRING2+IT_SPACE, NULL, "Nexit", NULL, 130}, + {IT_HEADER, NULL, "Special Thanks <3", NULL, 167}, - {IT_HEADER, NULL, "Special Thanks <3", NULL, 140}, + {IT_STRING2+IT_SPACE, NULL, "All of Sunflower's Garden", NULL, 177}, + {IT_STRING2+IT_SPACE, NULL, "The Moe Mansion and Birdhouse Team", NULL, 187}, + {IT_STRING2+IT_SPACE, NULL, "Galactice for Galaxy", NULL, 197}, - {IT_STRING2+IT_SPACE, NULL, "All of Sunflower's Garden", NULL, 160}, - {IT_STRING2+IT_SPACE, NULL, "The Moe Mansion and Birdhouse Team", NULL, 170}, - {IT_STRING2+IT_SPACE, NULL, "Galactice for Galaxy", NULL, 180}, - - {IT_STRING+IT_SPACE, NULL, "", NULL, 190}, // dummy text II - {IT_STRING, NULL, "", NULL, 250}, // dummy text III + {IT_STRING+IT_SPACE, NULL, "", NULL, 207}, // dummy text I + {IT_STRING, NULL, "", NULL, 267}, // dummy text II }; -static const char* OP_CreditTooltips[] = +// sry we dont have space for this anymore :/ +/*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,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, "Thanks everyone! <3" -}; +};*/ static menuitem_t OP_BirdMenu[] = @@ -3056,7 +3161,7 @@ menu_t OP_MainDef = &MainDef, OP_MainMenu, M_DrawGenericMenu, - 60, 30, + 60, 25, 0, NULL, {NULL} @@ -3157,7 +3262,9 @@ menu_t OP_Player4CamOptionsDef = DEFAULTMENUSTYLE(NULL, OP_Player4CamOptionsMenu menu_t OP_ChatOptionsDef = DEFAULTMENUSTYLE("M_HUD", OP_ChatOptionsMenu, &OP_HUDOptionsDef, 30, 30); -menu_t OP_SoundAdvancedDef = DEFAULTMENUSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); +menu_t OP_SoundAdvancedDef = DEFAULTSCROLLSTYLE("M_SOUND", OP_SoundAdvancedMenu, &OP_SoundOptionsDef, 30, 30); + +menu_t OP_FocusOptionsDef = DEFAULTMENUSTYLE(NULL, OP_FocusOptionsMenu, &OP_MainDef, 25, 30); 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); @@ -3185,10 +3292,10 @@ menu_t OP_MonitorToggleDef = menu_t OP_OpenGLOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_OpenGLOptionsMenu, &OP_VideoOptionsDef, 30, 30); #endif -menu_t OP_ExpOptionsDef = DEFAULTMENUSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 30); +menu_t OP_ExpOptionsDef = DEFAULTSCROLLSTYLE("M_VIDEO", OP_ExpOptionsMenu, &OP_VideoOptionsDef, 30, 25); menu_t OP_DataOptionsDef = DEFAULTMENUSTYLE("M_DATA", OP_DataOptionsMenu, &OP_MainDef, 60, 30); -menu_t OP_ScreenshotOptionsDef = DEFAULTMENUSTYLE("M_SCSHOT", OP_ScreenshotOptionsMenu, &OP_DataOptionsDef, 30, 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); #ifdef HAVE_DISCORDRPC @@ -3197,11 +3304,11 @@ menu_t OP_DiscordOptionsDef = DEFAULTMENUSTYLE(NULL, OP_DiscordOptionsMenu, &OP_ menu_t OP_EraseDataDef = DEFAULTMENUSTYLE("M_DATA", OP_EraseDataMenu, &OP_DataOptionsDef, 30, 30); menu_t OP_SaturnDef = DEFAULTSCROLLSTYLE(NULL, OP_SaturnMenu, &OP_MainDef, 30, 30); -menu_t OP_PlayerDistortDef = DEFAULTMENUSTYLE("M_VIDEO", OP_PlayerDistortMenu, &OP_SaturnDef, 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_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 10); +menu_t OP_SaturnCreditsDef = DEFAULTMENUSTYLE(NULL, OP_SaturnCreditsMenu, &OP_SaturnDef, 30, 0); menu_t OP_BirdDef = DEFAULTMENUSTYLE(NULL, OP_BirdMenu, &OP_MainDef, 30, 30); @@ -3475,8 +3582,16 @@ void Moviemode_option_Onchange(void) void PDistort_menu_Onchange(void) { - OP_PlayerDistortMenu[slrotatedist].status = - (cv_sloperoll.value) ? IT_STRING | IT_CVAR : IT_GRAYEDOUT; + if (cv_sloperoll.value) + { + OP_PlayerDistortMenu[slrotatedist].status = IT_STRING | IT_CVAR; + OP_PlayerDistortMenu[saltroll].status = IT_STRING | IT_CVAR; + } + else + { + OP_PlayerDistortMenu[slrotatedist].status = IT_GRAYEDOUT; + OP_PlayerDistortMenu[saltroll].status = IT_GRAYEDOUT; + } } void Bird_menu_Onchange(void) @@ -3530,6 +3645,11 @@ void SaturnHud_menu_Onchange(void) OP_SaturnHudMenu[sh_colorhud_customcolor].status = status; } +void GameFocus_menu_Onchange(void) +{ + OP_FocusOptionsMenu[5].status = cv_usemouse.value ? IT_GRAYEDOUT : IT_STRING | IT_CVAR; +} + #ifdef HWRENDER void M_UpdateOGLMenu(void) { @@ -3579,31 +3699,33 @@ static void M_ChangeCvar(INT32 choice) choice = (choice<<1) - 1; - if (((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_SLIDER) - ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_INVISSLIDER) - ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD)) - { - CV_SetValue(cv,cv->value+choice); - } - else if (cv->flags & CV_FLOAT) + if (cv->flags & CV_FLOAT) { char s[20]; float increment; - increment = (currentMenu->menuitems[itemOn].status & IT_CV_BIGFLOAT) ? 0.5 : (1.f/16); - - sprintf(s,"%f",FIXED_TO_FLOAT(cv->value)+(choice)*increment); - CV_Set(cv,s); + increment = (currentMenu->menuitems[itemOn].status & IT_CV_BIGFLOAT) ? 0.5f : (1.0f/16.0f); + sprintf(s, "%f",FIXED_TO_FLOAT(cv->value)+(choice)*increment); + CV_Set(cv, s); } else { + if (((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_SLIDER) + ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_INVISSLIDER) + ||((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_NOMOD)) + { + CV_SetValue(cv,cv->value+choice); + } + else + { #ifndef NONET - if (cv == &cv_nettimeout || cv == &cv_jointimeout) - choice *= (TICRATE/7); - else if (cv == &cv_maxsend) - choice *= 512; + if (cv == &cv_nettimeout || cv == &cv_jointimeout) + choice *= (TICRATE/7); + else if (cv == &cv_maxsend) + choice *= 512; #endif - CV_AddValue(cv,choice); + CV_AddValue(cv,choice); + } } } @@ -4390,6 +4512,7 @@ void M_Drawer(void) V_DrawThinString(vid.dupx, vid.height - 20*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, compbranch); V_DrawThinString(vid.dupx, vid.height - 10*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, comprevision); #else // Regular build + V_DrawThinString(vid.dupx, vid.height - 20*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, comprevision); // Removeur this for release! im just lazy to make a new flag or smth V_DrawThinString(vid.dupx, vid.height - 10*vid.dupy, V_NOSCALESTART|V_TRANSLUCENT|V_ALLOWLOWERCASE, va("%s", VERSIONSTRING)); #endif @@ -4520,7 +4643,7 @@ void M_StartControlPanel(void) { MPauseMenu[mpause_switchmap].status = IT_STRING | IT_CALL; MPauseMenu[mpause_addons].status = IT_STRING | IT_CALL; - + if (G_GametypeHasTeams()) MPauseMenu[mpause_scramble].status = IT_STRING | IT_SUBMENU; } @@ -4826,7 +4949,7 @@ void M_Init(void) } #endif - if (!xtra_speedo && !kartz_speedo && !achi_speedo) // why bother? + if (!xtra_speedo && !kartz_speedo && !achi_speedo && !dial_speedo) // why bother? OP_SaturnHudMenu[sh_speedometer].status = IT_GRAYEDOUT; //if (!xtra_speedo && kartz_speedo) @@ -4846,6 +4969,9 @@ void M_Init(void) if (!nametaggfx) OP_NametagMenu[nt_ntchar].status = IT_GRAYEDOUT; + if (!minidoticon) + OP_SaturnHudMenu[sh_minidot].status = IT_GRAYEDOUT; + #ifndef NONET CV_RegisterVar(&cv_serversort); #endif @@ -5318,14 +5444,12 @@ static void M_DrawGenericMenu(void) DoToolTips(OP_ControlsDef, OP_ControlsTooltips); DoToolTips(OP_MouseOptionsDef, OP_MouseTooltips); DoToolTips(OP_VideoOptionsDef, OP_VideoTooltips); - DoToolTips(OP_ExpOptionsDef, OP_ExpTooltips); DoToolTips(OP_SoundOptionsDef, OP_SoundTooltips); - DoToolTips(OP_SoundAdvancedDef, OP_SoundAdvancedTooltips); + DoToolTips(OP_FocusOptionsDef, OP_FocusOptionsTooltips); DoToolTips(OP_ChatOptionsDef, OP_ChatOptionsTooltips); DoToolTips(OP_GameOptionsDef, OP_GameTooltips); DoToolTips(OP_ServerOptionsDef, OP_ServerOptionsTooltips); - DoToolTips(OP_PlayerDistortDef, OP_PlayerDistortTooltips); - DoToolTips(OP_SaturnCreditsDef, OP_CreditTooltips); // C: + //DoToolTips(OP_SaturnCreditsDef, OP_CreditTooltips); // C: DoToolTips(OP_BirdDef, OP_BirdTooltips); DoToolTips(OP_TiltDef, OP_TiltTooltips); DoToolTips(OP_AdvancedBirdDef, OP_AdvancedBirdTooltips); @@ -5464,12 +5588,15 @@ 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); } static void M_DrawPauseMenu(void) @@ -5516,16 +5643,15 @@ static void M_DrawCenteredMenu(void) case IT_PATCH: if (currentMenu->menuitems[i].patch && currentMenu->menuitems[i].patch[0]) { + patch_t *p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); + if (currentMenu->menuitems[i].status & IT_CENTER) { - patch_t *p; - p = W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE); V_DrawScaledPatch((BASEVIDWIDTH - SHORT(p->width))/2, y, 0, p); } else { - V_DrawScaledPatch(x, y, 0, - W_CachePatchName(currentMenu->menuitems[i].patch, PU_CACHE)); + V_DrawScaledPatch(x, y, 0, p); } } /* FALLTHRU */ @@ -6402,6 +6528,8 @@ static void M_DrawAddons(void) if (modifiedgame) V_DrawSmallScaledPatch(x, y + 4, 0, addonsp[NUM_EXT+2]); + + V_DrawThinString(0, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_TRANSLUCENT|V_ALLOWLOWERCASE, ("END Key - Add addon to autoload")); } static void M_AddonExec(INT32 ch) @@ -6423,7 +6551,7 @@ static void M_AddonAutoLoad(INT32 ch) FILE *autoloadconfigfile; // check our controls // - if (ch != 'y' && ch != KEY_ENTER && ch != KEY_RSHIFT) + if (ch != 'y' && ch != KEY_ENTER && ch != KEY_END) { S_StartSound(NULL, sfx_s26d); return; @@ -6610,7 +6738,7 @@ static void M_HandleAddons(INT32 choice) } break; - case KEY_RSHIFT: + case KEY_END: { boolean refresh = true; if (!dirmenu[dir_on[menudepthleft]]) @@ -6725,7 +6853,15 @@ static void ReplayNamesLoadThread(void* userdata) for (size_t i = 0; i < demolist_all_size; ++i) { if (demolist_all_local[i].type != MD_SUBDIR) + { G_LoadDemoTitle(&demolist_all_local[i]); + + // this is fucking horrid, but i wanna be able to search for dates + /*if (demolist_all_local[i].date[0] != '\0') + { + snprintf(demolist_all_local[i].title, sizeof(demolist_all_local[i].title), "%s %s", demolist_all_local[i].title, demolist_all_local[i].date); + }*/ + } } Lock_search_state(); @@ -6879,10 +7015,9 @@ void M_ReplayHut(INT32 choice) { snprintf(menupath, 1024, "%s"PATHSEP"replay"PATHSEP"online"PATHSEP, srb2home); menupathindex[(menudepthleft = menudepth-1)] = strlen(menupath); + ResetReplayQuery(); } - ResetReplayQuery(); - if (!preparefilemenu(false, true)) { M_StartMessage("No replays found.\n\n(Press a key)\n", NULL, MM_NOTHING); @@ -6935,14 +7070,19 @@ static void M_HandleReplayHutList(INT32 choice) if (M_HandleReplayHutQuery(choice)) return; + size_t scrollamt = 1; + switch (choice) { + case KEY_PGUP: + scrollamt = 8; + /* FALLTHRU */ case KEY_UPARROW: if (!replaynamesloaded) return; if (dir_on[menudepthleft]) - dir_on[menudepthleft]--; + dir_on[menudepthleft] -= min(dir_on[menudepthleft], scrollamt); else return; //M_PrevOpt(); @@ -6951,12 +7091,15 @@ static void M_HandleReplayHutList(INT32 choice) replayScrollTitle = 0; replayScrollDelay = TICRATE; replayScrollDir = 1; break; + case KEY_PGDN: + scrollamt = 8; + /* FALLTHRU */ case KEY_DOWNARROW: if (!replaynamesloaded) return; if (dir_on[menudepthleft] < replayqueryfound-1) - dir_on[menudepthleft]++; + dir_on[menudepthleft] = min(replayqueryfound-1, dir_on[menudepthleft] + scrollamt); else return; //itemOn = 0; // Not M_NextOpt because that would take us to the extra dummy item @@ -7087,7 +7230,7 @@ static void DrawReplayHutReplayInfo(void) break; // Can't think of anything to draw here right now case MD_OUTDATED: - V_DrawThinString(17, 64, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT|highlightflags, "Recorded on an outdated version."); + V_DrawThinString(17, 64, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT|highlightflags, va("Recorded on an outdated version. %s", demolist[dir_on[menudepthleft]].version)); /*fallthru*/ default: // Draw level stuff @@ -7128,8 +7271,16 @@ static void DrawReplayHutReplayInfo(void) else V_DrawString(x, y, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "Level is not loaded."); + INT32 datew = 0; + + if (demolist[dir_on[menudepthleft]].date[0] != '\0') + { + datew = V_StringWidth(demolist[dir_on[menudepthleft]].date, 0); + V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("%s", demolist[dir_on[menudepthleft]].date)); + } + if (demolist[dir_on[menudepthleft]].numlaps) - V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demolist[dir_on[menudepthleft]].numlaps)); + V_DrawThinString(x+datew, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demolist[dir_on[menudepthleft]].numlaps)); V_DrawString(x, y+20, V_SNAPTOTOP|V_ALLOWLOWERCASE, demolist[dir_on[menudepthleft]].gametype == GT_RACE ? va("Race (%s speed)", kartspeed_cons_t[demolist[dir_on[menudepthleft]].kartspeed & ~DF_ENCORE].strvalue) : @@ -7890,11 +8041,11 @@ static void M_Options(INT32 choice) (void)choice; // if the player is not admin or server, disable gameplay & server options - OP_MainMenu[5].status = OP_MainMenu[6].status = (Playing() && !(server || IsPlayerAdmin(consoleplayer))) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); + OP_MainMenu[gameopt].status = OP_MainMenu[serveropt].status = (Playing() && !(server || IsPlayerAdmin(consoleplayer))) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); - OP_MainMenu[10].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_CALL); // Play credits + OP_MainMenu[credits].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_CALL); // Play credits - OP_MainMenu[13].status = (!cv_showlocalskinmenus.value) ? (IT_DISABLED) : (IT_CALL|IT_STRING); + OP_MainMenu[localskin].status = (!cv_showlocalskinmenus.value) ? (IT_DISABLED) : (IT_CALL|IT_STRING); #ifdef HAVE_DISCORDRPC OP_DataOptionsMenu[4].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); // Erase data @@ -7902,8 +8053,7 @@ static void M_Options(INT32 choice) OP_DataOptionsMenu[3].status = (Playing()) ? (IT_GRAYEDOUT) : (IT_STRING|IT_SUBMENU); // Erase data #endif - OP_GameOptionsMenu[3].status = - (M_SecretUnlocked(SECRET_ENCORE)) ? (IT_CVAR|IT_STRING) : IT_SECRET; // cv_kartencore + OP_GameOptionsMenu[op_game_encore].status = (M_SecretUnlocked(SECRET_ENCORE)) ? (IT_CVAR|IT_STRING) : IT_SECRET; // cv_kartencore OP_MainDef.prevMenu = currentMenu; M_SetupNextMenu(&OP_MainDef); @@ -9371,13 +9521,7 @@ static void M_ModeAttackEndGame(INT32 choice) Command_ExitGame_f(); M_StartControlPanel(); - switch(modeattacking) - { - default: - case ATTACKING_RECORD: - currentMenu = &SP_TimeAttackDef; - break; - } + currentMenu = &SP_TimeAttackDef; itemOn = currentMenu->lastOn; G_SetGamestate(GS_TIMEATTACK); modeattacking = ATTACKING_NONE; @@ -11269,9 +11413,9 @@ static void M_DrawSetupMultiPlayerMenu(void) //this is a very shitty solution for checking if a sprite needs flipping //but it works - if ((sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]) && (speenframe > 4)) { + if ((sprframe->lumppat[speenframe] == sprframe->lumppat[8-speenframe]) && (speenframe > 4)) flags = V_FLIP; // This sprite is left/right flipped! - } + patch = W_CachePatchNum(sprframe->lumppat[speenframe], PU_CACHE); // draw box around guy @@ -11298,9 +11442,10 @@ static void M_DrawSetupMultiPlayerMenu(void) // Handle 1P/2P MP Setup static void M_HandleSetupMultiPlayer(INT32 choice) { - boolean exitmenu = false; // exit to previous menu and send name change + boolean exitmenu = false; // exit to previous menu and send name change + const boolean gridselect = (cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED); // menus with "grids" - if ((choice == gamecontrol[gc_fire][0] || choice == gamecontrol[gc_fire][1]) && itemOn == 2) + if ((choice == gamecontrol[gc_fire][0] || choice == gamecontrol[gc_fire][1]) && (itemOn == 2 || (gridselect && itemOn == 1))) choice = KEY_BACKSPACE; // Hack to allow resetting prefcolor on controllers #define BREAKWHENLOCKED {\ @@ -11325,7 +11470,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) S_StartSound(NULL,sfx_menu1); // Tails break; } - else if (cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) //grid skin select menu + else if (gridselect) //grid skin select menu { if (itemOn == 1) //if we are on the skin select menu { @@ -11333,11 +11478,13 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { setupm_skinselect += SKINGRIDWIDTH; - if (cv_skinselectmenu.value == SKINMENUTYPE_GRID){ + if (cv_skinselectmenu.value == SKINMENUTYPE_GRID) + { if (setupm_skinselect >= ((setupm_skinypos-1)+SKINGRIDHEIGHT)*8 && setupm_skinypos < (ROUNDSKINSUPTO8/8)-SKINGRIDHEIGHT) setupm_skinypos++; } - else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED){ + else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) + { if (setupm_skinselect >= ((setupm_skinypos-1)+SKINGRIDHEIGHT)*8+24 && setupm_skinypos < (ROUNDSKINSUPTO8/8)-SKINGRIDHEIGHT+24) setupm_skinypos++; } @@ -11379,13 +11526,14 @@ static void M_HandleSetupMultiPlayer(INT32 choice) S_StartSound(NULL,sfx_menu1); // Tails break; } - else if (cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) + else if (gridselect) { if (itemOn == 1) { if (setupm_skinselect >= SKINGRIDWIDTH) //if we arent at the top of the menu { setupm_skinselect -= SKINGRIDWIDTH; + if (setupm_skinselect < ((setupm_skinypos+1)*SKINGRIDWIDTH) && setupm_skinypos > 0) setupm_skinypos--; } @@ -11398,14 +11546,15 @@ static void M_HandleSetupMultiPlayer(INT32 choice) else if (itemOn == 2) { setupm_skinselect = numskins - 1; - if (cv_skinselectmenu.value == SKINMENUTYPE_GRID){ + if (cv_skinselectmenu.value == SKINMENUTYPE_GRID) + { setupm_skinypos = (((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)) > 0 ? ((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)) : 0); M_PrevOpt(); } - else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED){ - setupm_skinypos = (((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)-2) > 0 ? ((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)-2) : 0); - M_PrevOpt(); - + else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) + { + setupm_skinypos = (((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)-2) > 0 ? ((numskins / SKINGRIDWIDTH) - (SKINGRIDHEIGHT-1)-2) : 0); + M_PrevOpt(); } } @@ -11437,6 +11586,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) else //player skin { S_StartSound(NULL,sfx_menu1); // Tails + if (setupm_skinxpos > 0) setupm_skinxpos--; else @@ -11444,11 +11594,12 @@ static void M_HandleSetupMultiPlayer(INT32 choice) } break; } - else if ((cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) && itemOn == 1) + else if (gridselect && itemOn == 1) { if (setupm_skinselect > 0) { setupm_skinselect--; + if (setupm_skinselect < ((setupm_skinypos+1)*SKINGRIDWIDTH) && setupm_skinypos > 0) setupm_skinypos--; } @@ -11456,6 +11607,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) { INT32 roundedskins = ROUNDSKINSUPTO8; setupm_skinselect = roundedskins-1; + if (cv_skinselectmenu.value == SKINMENUTYPE_GRID) setupm_skinypos = (((roundedskins/8) - SKINGRIDHEIGHT) > 0 ? (roundedskins/8) - SKINGRIDHEIGHT : 0); else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) @@ -11503,16 +11655,19 @@ static void M_HandleSetupMultiPlayer(INT32 choice) } break; } - else if ((cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) && itemOn == 1) + else if (gridselect && itemOn == 1) { if (setupm_skinselect < ROUNDSKINSUPTO8 - 1) { setupm_skinselect++; - if (cv_skinselectmenu.value == SKINMENUTYPE_GRID){ + + if (cv_skinselectmenu.value == SKINMENUTYPE_GRID) + { if (setupm_skinselect >= ((setupm_skinypos-1)+SKINGRIDHEIGHT)*8 && setupm_skinypos < (ROUNDSKINSUPTO8/8)-SKINGRIDHEIGHT) setupm_skinypos++; } - else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED){ + else if (cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) + { if (setupm_skinselect >= ((setupm_skinypos-1)+SKINGRIDHEIGHT)*8+24 && setupm_skinypos < (ROUNDSKINSUPTO8/8)-SKINGRIDHEIGHT+24) setupm_skinypos++; } @@ -11555,7 +11710,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) M_TextInputHandle(&setupm_input, choice); S_StartSound(NULL,sfx_menu1); // Tails } - else if ((cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED) && itemOn == 1) + else if (gridselect && itemOn == 1) { // change sort for select menu (damn now i have to add another cvar...) // now we have the cvar @@ -11610,7 +11765,7 @@ static void M_HandleSetupMultiPlayer(INT32 choice) S_StartSound(NULL,sfx_menu1); } } - else if ((cv_skinselectmenu.value == SKINMENUTYPE_GRID || cv_skinselectmenu.value == SKINMENUTYPE_EXTENDED ) && itemOn == 1 && setupm_skinselect < numskins) + else if (gridselect && itemOn == 1 && setupm_skinselect < numskins) { setupm_fakeskin = skinsorted[setupm_skinselect]; S_StartSound(NULL, sfx_s221); diff --git a/src/m_menu.h b/src/m_menu.h index 4ee8615ce..45f0fbbf9 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -298,6 +298,8 @@ void Bird_menu_Onchange(void); // Saturn Hud menu updating void SaturnHud_menu_Onchange(void); +void GameFocus_menu_Onchange (void); + #ifdef HWRENDER void M_UpdateOGLMenu(void); #endif diff --git a/src/m_misc.c b/src/m_misc.c index c6dd4175c..ca4b745ed 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1668,7 +1668,6 @@ failure: #endif //#ifdef USE_PNG } - // ========================================================================== // TRANSLATION FUNCTIONS // ========================================================================== diff --git a/src/m_random.c b/src/m_random.c index 9b4396cbd..cb8367b43 100644 --- a/src/m_random.c +++ b/src/m_random.c @@ -19,8 +19,6 @@ #include "m_random.h" #include "m_fixed.h" - - // --------------------------- // RNG functions (not synched) // --------------------------- diff --git a/src/p_floor.c b/src/p_floor.c index 07d8a8f91..2aa9cf0f7 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -2923,6 +2923,7 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) // soundorg z height never gets set normally, so MEH. sec->soundorg.z = sec->floorheight; + //sec->soundorg.z = (rover->master->frontsector->floorheight + rover->master->frontsector->ceilingheight)/2; // actual accurate z but well smth smth synchsafe S_StartSound(&sec->soundorg, sfx_crumbl); // Find the outermost vertexes in the subsector diff --git a/src/p_local.h b/src/p_local.h index ae72fee77..76506ac87 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -158,7 +158,9 @@ extern consvar_t cv_tiltsmoothing; extern consvar_t cv_actionmovie; -extern consvar_t cv_lookbackmom; +extern consvar_t cv_lookbackmom[MAXSPLITSCREENPLAYERS]; + +extern consvar_t cv_verticallook[MAXSPLITSCREENPLAYERS]; extern fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS]; @@ -235,7 +237,6 @@ void P_PlayRinglossSound(mobj_t *source, mobj_t *damager); void P_PlayDeathSound(mobj_t *source); void P_PlayVictorySound(mobj_t *source); - // // P_MOBJ // diff --git a/src/p_map.c b/src/p_map.c index 91b15d8ab..aacbb2e6e 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1699,7 +1699,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) INT32 xl, xh, yl, yh, bx, by; subsector_t *newsubsec; boolean blockval = true; - + ps_checkposition_calls.value.i++; I_Assert(thing != NULL); @@ -4102,10 +4102,7 @@ void P_MapEnd(void) fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) { sector_t *sec = R_PointInSubsector(x, y)->sector; - fixed_t floorz = sec->floorheight; - - if (sec->f_slope) - floorz = P_GetZAt(sec->f_slope, x, y); + fixed_t floorz = P_GetSectorFloorZAt(sec, x, y); // Intercept the stupid 'fall through 3dfloors' bug Tails 03-17-2002 if (sec->ffloors) @@ -4116,19 +4113,15 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) for (rover = sec->ffloors; rover; rover = rover->next) { fixed_t topheight, bottomheight; + if (!(rover->flags & FF_EXISTS)) continue; if ((!(rover->flags & FF_SOLID || rover->flags & FF_QUICKSAND) || (rover->flags & FF_SWIMMABLE))) continue; - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, x, y); - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, x, y); + topheight = P_GetFFloorTopZAt (rover, x, y); + bottomheight = P_GetFFloorBottomZAt(rover, x, y); if (rover->flags & FF_QUICKSAND) { @@ -4142,6 +4135,7 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height) delta1 = z - (bottomheight + ((topheight - bottomheight)/2)); delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2)); + if (topheight > floorz && abs(delta1) < abs(delta2)) floorz = topheight; } diff --git a/src/p_maputl.c b/src/p_maputl.c index a88545135..7b748c22e 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -294,50 +294,34 @@ void P_CameraLineOpening(line_t *linedef) // If you can see through it, why not move the camera through it too? if (front->camsec >= 0) { - frontfloor = sectors[front->camsec].floorheight; - frontceiling = sectors[front->camsec].ceilingheight; - if (sectors[front->camsec].f_slope) - frontfloor = P_GetZAt(sectors[front->camsec].f_slope, camera[0].x, camera[0].y); - if (sectors[front->camsec].c_slope) - frontceiling = P_GetZAt(sectors[front->camsec].c_slope, camera[0].x, camera[0].y); + frontfloor = P_GetSectorFloorZAt (§ors[front->camsec], camera[0].x, camera[0].y); + frontceiling = P_GetSectorCeilingZAt(§ors[front->camsec], camera[0].x, camera[0].y); } else if (front->heightsec >= 0) { - frontfloor = sectors[front->heightsec].floorheight; - frontceiling = sectors[front->heightsec].ceilingheight; - if (sectors[front->heightsec].f_slope) - frontfloor = P_GetZAt(sectors[front->heightsec].f_slope, camera[0].x, camera[0].y); - if (sectors[front->heightsec].c_slope) - frontceiling = P_GetZAt(sectors[front->heightsec].c_slope, camera[0].x, camera[0].y); + frontfloor = P_GetSectorFloorZAt (§ors[front->heightsec], camera[0].x, camera[0].y); + frontceiling = P_GetSectorCeilingZAt(§ors[front->heightsec], camera[0].x, camera[0].y); } else { - frontfloor = P_CameraGetFloorZ(mapcampointer, front, tmx, tmy, linedef); + frontfloor = P_CameraGetFloorZ (mapcampointer, front, tmx, tmy, linedef); frontceiling = P_CameraGetCeilingZ(mapcampointer, front, tmx, tmy, linedef); } if (back->camsec >= 0) { - backfloor = sectors[back->camsec].floorheight; - backceiling = sectors[back->camsec].ceilingheight; - if (sectors[back->camsec].f_slope) - frontfloor = P_GetZAt(sectors[back->camsec].f_slope, camera[0].x, camera[0].y); - if (sectors[back->camsec].c_slope) - frontceiling = P_GetZAt(sectors[back->camsec].c_slope, camera[0].x, camera[0].y); + backfloor = P_GetSectorFloorZAt (§ors[back->camsec], camera[0].x, camera[0].y); + backceiling = P_GetSectorCeilingZAt(§ors[back->camsec], camera[0].x, camera[0].y); } else if (back->heightsec >= 0) { - backfloor = sectors[back->heightsec].floorheight; - backceiling = sectors[back->heightsec].ceilingheight; - if (sectors[back->heightsec].f_slope) - frontfloor = P_GetZAt(sectors[back->heightsec].f_slope, camera[0].x, camera[0].y); - if (sectors[back->heightsec].c_slope) - frontceiling = P_GetZAt(sectors[back->heightsec].c_slope, camera[0].x, camera[0].y); + backfloor = P_GetSectorFloorZAt (§ors[back->heightsec], camera[0].x, camera[0].y); + backceiling = P_GetSectorCeilingZAt(§ors[back->heightsec], camera[0].x, camera[0].y); } else { - backfloor = P_CameraGetFloorZ(mapcampointer, back, tmx, tmy, linedef); + backfloor = P_CameraGetFloorZ(mapcampointer, back, tmx, tmy, linedef); backceiling = P_CameraGetCeilingZ(mapcampointer, back, tmx, tmy, linedef); } diff --git a/src/p_mobj.c b/src/p_mobj.c index df2964df5..a743f05fc 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -172,20 +172,28 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) { // Start flashing, since you've landed. player->powers[pw_flashing] = K_GetKartFlashing(player)-1; - //P_DoPityCheck(player); } // Set animation state // The pflags version of this was just as convoluted. // Rewriten for SRB2kart ... though I don't know what this is. - if ((state >= S_KART_STND1 && state <= S_KART_STND2_R) || state == S_KART_SQUISH || state == S_KART_SPIN) - player->panim = PA_IDLE; - else if (state >= S_KART_WALK1 && state <= S_KART_WALK2_R) - player->panim = PA_WALK; - else if (state >= S_KART_RUN1 && state <= S_KART_DRIFT2_R) - player->panim = PA_RUN; - else - player->panim = PA_ETC; + switch(state) + { + case S_KART_STND1...S_KART_STND2_R: + case S_KART_SQUISH: + case S_KART_SPIN: + player->panim = PA_IDLE; + break; + case S_KART_WALK1...S_KART_WALK2_R: + player->panim = PA_WALK; + break; + case S_KART_RUN1...S_KART_DRIFT2_R: + player->panim = PA_RUN; + break; + default: + player->panim = PA_ETC; + break; + } if (recursion++) // if recursion detected, memset(seenstate = tempstate, 0, sizeof tempstate); // clear state table @@ -494,12 +502,12 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, /*CONS_Printf("BEFORE: v1 = %f %f %f\n", FIXED_TO_FLOAT(v1.x), FIXED_TO_FLOAT(v1.y), - FIXED_TO_FLOAT(P_GetZAt(slope, v1.x, v1.y)) + FIXED_TO_FLOAT(P_GetSlopeZAt(slope, v1.x, v1.y)) ); CONS_Printf(" v2 = %f %f %f\n", FIXED_TO_FLOAT(v2.x), FIXED_TO_FLOAT(v2.y), - FIXED_TO_FLOAT(P_GetZAt(slope, v2.x, v2.y)) + FIXED_TO_FLOAT(P_GetSlopeZAt(slope, v2.x, v2.y)) );*/ if (abs(v1.x-x) > radius) { @@ -557,24 +565,24 @@ static fixed_t HighestOnLine(fixed_t radius, fixed_t x, fixed_t y, line_t *line, /*CONS_Printf("AFTER: v1 = %f %f %f\n", FIXED_TO_FLOAT(v1.x), FIXED_TO_FLOAT(v1.y), - FIXED_TO_FLOAT(P_GetZAt(slope, v1.x, v1.y)) + FIXED_TO_FLOAT(P_GetSlopeZAt(slope, v1.x, v1.y)) ); CONS_Printf(" v2 = %f %f %f\n", FIXED_TO_FLOAT(v2.x), FIXED_TO_FLOAT(v2.y), - FIXED_TO_FLOAT(P_GetZAt(slope, v2.x, v2.y)) + FIXED_TO_FLOAT(P_GetSlopeZAt(slope, v2.x, v2.y)) );*/ // Return the higher of the two points if (actuallylowest) return min( - P_GetZAt(slope, v1.x, v1.y), - P_GetZAt(slope, v2.x, v2.y) + P_GetSlopeZAt(slope, v1.x, v1.y), + P_GetSlopeZAt(slope, v2.x, v2.y) ); else return max( - P_GetZAt(slope, v1.x, v1.y), - P_GetZAt(slope, v2.x, v2.y) + P_GetSlopeZAt(slope, v1.x, v1.y), + P_GetSlopeZAt(slope, v2.x, v2.y) ); } @@ -582,6 +590,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t { I_Assert(mobj != NULL); I_Assert(sector != NULL); + if (sector->f_slope) { fixed_t testx, testy; @@ -609,7 +618,7 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t // 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)) - return P_GetZAt(slope, testx, testy); + 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 if (perfect) @@ -648,10 +657,11 @@ fixed_t P_MobjFloorZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed_t // If we're just testing for base sector location (no collision line), just go for the center's spot... // It'll get fixed when we test for collision anyway, and the final result can't be lower than this if (line == NULL) - return P_GetZAt(slope, x, y); + return P_GetSlopeZAt(slope, x, y); return HighestOnLine(mobj->radius, x, y, line, slope, lowest); - } else // Well, that makes it easy. Just get the floor height + } + else // Well, that makes it easy. Just get the floor height return sector->floorheight; } @@ -659,6 +669,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed { I_Assert(mobj != NULL); I_Assert(sector != NULL); + if (sector->c_slope) { fixed_t testx, testy; @@ -686,7 +697,7 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed // 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)) - return P_GetZAt(slope, testx, testy); + 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 if (perfect) @@ -725,10 +736,11 @@ fixed_t P_MobjCeilingZ(mobj_t *mobj, sector_t *sector, sector_t *boundsec, fixed // If we're just testing for base sector location (no collision line), just go for the center's spot... // It'll get fixed when we test for collision anyway, and the final result can't be lower than this if (line == NULL) - return P_GetZAt(slope, x, y); + return P_GetSlopeZAt(slope, x, y); return HighestOnLine(mobj->radius, x, y, line, slope, lowest); - } else // Well, that makes it easy. Just get the ceiling height + } + else // Well, that makes it easy. Just get the ceiling height return sector->ceilingheight; } @@ -765,7 +777,7 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix // 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)) - return P_GetZAt(slope, testx, testy); + 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 if (perfect) @@ -804,10 +816,11 @@ fixed_t P_CameraFloorZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, fix // If we're just testing for base sector location (no collision line), just go for the center's spot... // It'll get fixed when we test for collision anyway, and the final result can't be lower than this if (line == NULL) - return P_GetZAt(slope, x, y); + return P_GetSlopeZAt(slope, x, y); return HighestOnLine(mobj->radius, x, y, line, slope, lowest); - } else // Well, that makes it easy. Just get the floor height + } + else // Well, that makes it easy. Just get the floor height return sector->floorheight; } @@ -843,7 +856,7 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f // 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)) - return P_GetZAt(slope, testx, testy); + 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 if (perfect) @@ -882,10 +895,11 @@ fixed_t P_CameraCeilingZ(camera_t *mobj, sector_t *sector, sector_t *boundsec, f // If we're just testing for base sector location (no collision line), just go for the center's spot... // It'll get fixed when we test for collision anyway, and the final result can't be lower than this if (line == NULL) - return P_GetZAt(slope, x, y); + return P_GetSlopeZAt(slope, x, y); return HighestOnLine(mobj->radius, x, y, line, slope, lowest); - } else // Well, that makes it easy. Just get the ceiling height + } + else // Well, that makes it easy. Just get the ceiling height return sector->ceilingheight; } static void P_PlayerFlip(mobj_t *mo) @@ -1904,9 +1918,7 @@ boolean P_CheckSolidLava(mobj_t *mo, ffloor_t *rover) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); - fixed_t topheight = - *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : - *rover->topheight; + 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) @@ -2400,9 +2412,6 @@ static void P_PlayerZMovement(mobj_t *mo) mo->player->viewheight -= (mo->z+mo->height) - mo->ceilingz; else mo->player->viewheight -= mo->floorz - mo->z; - - /*mo->player->deltaviewheight = - (FixedMul(cv_viewheight.value<scale) - mo->player->viewheight)>>3;*/ } // adjust height @@ -2468,11 +2477,6 @@ static void P_PlayerZMovement(mobj_t *mo) { mo->pmomz = 0; // We're on a new floor, don't keep doing platform movement. - // Squat down. Decrease viewheight for a moment after hitting the ground (hard), - /*if (P_MobjFlip(mo)*mo->momz < -FixedMul(8*FRACUNIT, mo->scale)) - mo->player->deltaviewheight = (P_MobjFlip(mo)*mo->momz)>>3; // make sure momz is negative - */ - if (!tmfloorthing || tmfloorthing->flags & (MF_PUSHABLE|MF_MONITOR) || tmfloorthing->flags2 & MF2_STANDONME || tmfloorthing->type == MT_PLAYER) // Spin Attack { @@ -2580,7 +2584,6 @@ static void P_PlayerZMovement(mobj_t *mo) if (!(mo->player->pflags & PF_GLIDING)) mo->player->pflags &= ~PF_JUMPED; mo->player->pflags &= ~PF_THOKKED; - //mo->player->pflags &= ~PF_GLIDING; mo->player->jumping = 0; mo->player->secondjump = 0; mo->player->glidetime = 0; @@ -2882,14 +2885,8 @@ void P_MobjCheckWater(mobj_t *mobj) || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) continue; - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y); - - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, mobj->x, mobj->y); + topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); if (mobj->eflags & MFE_VERTICALFLIP) { @@ -3107,14 +3104,8 @@ static void P_SceneryCheckWater(mobj_t *mobj) if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKOTHERS) continue; - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, mobj->x, mobj->y); - - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, mobj->x, mobj->y); + topheight = P_GetFFloorTopZAt(rover, mobj->x, mobj->y); + bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); if (topheight <= mobj->z || bottomheight > (mobj->z + FixedMul(mobj->info->height >> 1, mobj->scale))) @@ -6033,20 +6024,6 @@ static void P_KoopaThinker(mobj_t *koopa) // void P_RollPitchMobj(mobj_t* mobj) { - // we dont need this in dedi do we? - if (rendermode == render_none) - return; - - if (P_MobjWasRemoved(mobj)) - return; - - if (cv_sloperoll.value != 2) - { - mobj->sloperoll = 0; - mobj->slopepitch = 0; - return; - } - K_RollMobjBySlopes(mobj, mobj->standingslope); } @@ -6058,9 +6035,6 @@ angle_t P_MobjPitchAndRoll(mobj_t *mobj) angle_t camang = 0; angle_t return_angle = 0; - if (!cv_sloperoll.value) - return 0; - if (P_MobjWasRemoved(mobj)) return 0; @@ -6100,9 +6074,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; } @@ -6264,11 +6238,8 @@ void P_MobjThinker(mobj_t *mobj) return; } - if (cv_sloperoll.value == 2 && mobj->state == &states[S_SHADOW]) - { - mobj->slopepitch = mobj->target->slopepitch; - mobj->sloperoll = mobj->target->sloperoll; - } + K_RollMobjBySlopes(mobj, mobj->target->standingslope); + P_AddShadow(mobj); break; //{ SRB2kart mobs @@ -7059,15 +7030,14 @@ void P_MobjThinker(mobj_t *mobj) break; //{ SRB2kart Items - Death States case MT_BANANA: - if (cv_sloperoll.value == 2 && cv_bananthrowroll.value) + if (cv_bananthrowroll.value) { - angle_t spin = FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); //mobj->angle -= spin; - if (cv_bananthrowroll.value == 1) - mobj->sloperoll += spin; // im lazy but this makes sure the banan goes back to upright when it lands lmao + if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mobj)) + mobj->sloperoll += (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); // im lazy but this makes sure the banan goes back to upright when it lands lmao else if (cv_bananthrowroll.value == 2) - mobj->rollangle += spin; + mobj->rollangle += (angle_t)FixedMul(FixedDiv(abs(mobj->momz), 8 * mobj->scale), ANGLE_67h); //if (P_IsObjectOnGround(mobj) && mobj->momz * P_MobjFlip(mobj) <= 0) } @@ -7814,16 +7784,15 @@ void P_MobjThinker(mobj_t *mobj) } case MT_BANANA: case MT_EGGMANITEM: - if (cv_sloperoll.value == 2 && cv_bananthrowroll.value && !P_IsObjectOnGround(mobj)) + if (cv_bananthrowroll.value && !P_IsObjectOnGround(mobj)) { // tilt n tumble - angle_t spin = FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); //mobj->angle += spin; - if (cv_bananthrowroll.value == 1) - mobj->sloperoll -= spin; // im lazy but this makes sure the banan goes back to upright when it lands lmao + if (cv_bananthrowroll.value == 1 && K_CheckSlopeRollDist(mobj)) + mobj->sloperoll -= (angle_t)FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); // im lazy but this makes sure the banan goes back to upright when it lands lmao else if (cv_bananthrowroll.value == 2) - mobj->rollangle -= spin; + mobj->rollangle -= (angle_t)FixedMul(FixedDiv(mobj->momz, 8 * mobj->scale), ANGLE_67h); } mobj->friction = ORIG_FRICTION/4; @@ -9403,13 +9372,8 @@ void P_SceneryThinker(mobj_t *mobj) // GAME SPAWN FUNCTIONS // -// -// P_SpawnMobj -// -mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) +FUNCINLINE static ATTRINLINE mobj_t *P_AllocMobj(void) { - const mobjinfo_t *info = &mobjinfo[type]; - state_t *st; mobj_t *mobj; if (mobjcache != NULL) @@ -9423,6 +9387,20 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); } + return mobj; +} + +// +// P_SpawnMobj +// +mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) +{ + const mobjinfo_t *info = &mobjinfo[type]; + state_t *st; + mobj_t *mobj; + + mobj = P_AllocMobj(); + // this is officially a mobj, declared as soon as possible. mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; mobj->type = type; @@ -9434,11 +9412,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->radius = info->radius; mobj->height = info->height; mobj->flags = info->flags; - mobj->sloperoll = 0; - mobj->slopepitch = 0; - - mobj->pitch_sprite = 0; - mobj->roll_sprite = 0; mobj->health = info->spawnhealth; @@ -9476,12 +9449,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->realxscale = mobj->realyscale = mobj->scale; mobj->spritexscale = mobj->realxscale; mobj->spriteyscale = mobj->realyscale; - mobj->realxoffset = mobj->realyoffset = 0; - mobj->spritexoffset = mobj->realxoffset; - mobj->spriteyoffset = mobj->realyoffset; - - // Funni slam sound when landing - mobj->slamsoundtimer = 0; // set subsector and/or block links P_SetThingPosition(mobj); @@ -9490,12 +9457,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) // Make sure scale matches destscale immediately when spawned P_SetScale(mobj, mobj->destscale); - mobj->floorz = - mobj->subsector->sector->f_slope ? P_GetZAt(mobj->subsector->sector->f_slope, x, y) : - mobj->subsector->sector->floorheight; - mobj->ceilingz = - mobj->subsector->sector->c_slope ? P_GetZAt(mobj->subsector->sector->c_slope, x, y) : - mobj->subsector->sector->ceilingheight; + mobj->floorz = P_GetSectorFloorZAt(mobj->subsector->sector, x, y); + mobj->ceilingz = P_GetSectorCeilingZAt(mobj->subsector->sector, x, y); // Tells MobjCheckWater that the water height was not set. mobj->watertop = INT32_MAX; @@ -9887,16 +9850,7 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) state_t *st; mobj_t *mobj; - if (mobjcache != NULL) - { - mobj = mobjcache; - mobjcache = mobjcache->hnext; - memset(mobj, 0, sizeof(*mobj)); - } - else - { - mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); - } + mobj = P_AllocMobj(); // this is officially a mobj, declared as soon as possible. mobj->thinker.function.acp1 = (actionf_p1)P_MobjThinker; @@ -9946,7 +9900,6 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) // Sprite rendering mobj->spritexscale = mobj->spriteyscale = mobj->scale; - mobj->spritexoffset = mobj->spriteyoffset = 0; // set subsector and/or block links P_SetThingPosition(mobj); @@ -10571,9 +10524,8 @@ void P_RespawnSpecials(void) if (mthing->options & MTF_OBJECTFLIP) { - z = ( - ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : - ss->sector->ceilingheight) - (mthing->options >> ZSHIFT) * FRACUNIT; + z = P_GetSectorCeilingZAt(ss->sector, x, y) - (mthing->options >> ZSHIFT) * FRACUNIT; + if (mthing->options & MTF_AMBUSH && (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i))) z -= 24*FRACUNIT; @@ -10581,9 +10533,8 @@ void P_RespawnSpecials(void) } else { - z = ( - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : - ss->sector->floorheight) + (mthing->options >> ZSHIFT) * FRACUNIT; + z = P_GetSectorFloorZAt(ss->sector, x, y) + (mthing->options >> ZSHIFT) * FRACUNIT; + if (mthing->options & MTF_AMBUSH && (i == MT_RING || i == MT_REDTEAMRING || i == MT_BLUETEAMRING || i == MT_COIN || P_WeaponOrPanel(i))) z += 24*FRACUNIT; @@ -10702,7 +10653,7 @@ void P_SpawnPlayer(INT32 playernum) // the dead body mobj retains the skin through the 'spritedef' override). mobj->skin = &skins[p->skin]; - mobj->localskin = ((p->localskin > 0) ? (p->skinlocal ? &localskins[p->localskin - 1] : &skins[p->localskin - 1]) : 0); + mobj->localskin = (p->localskin ? K_GetPlayerSkin(p) : 0); mobj->skinlocal = p->skinlocal; mobj->health = p->health; @@ -10882,14 +10833,9 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) //spawn at the origin as a desperation move if there is no mapthing // set Z height - sector = R_PointInSubsector(x, y)->sector; - - floor = - sector->f_slope ? P_GetZAt(sector->f_slope, x, y) : - sector->floorheight; - ceiling = - sector->c_slope ? P_GetZAt(sector->c_slope, x, y) : - sector->ceilingheight; + sector = R_PointInSubsector(x, y)->sector; + floor = P_GetSectorFloorZAt(sector, x, y); + ceiling = P_GetSectorCeilingZAt(sector, x, y); if (mthing) { @@ -10957,14 +10903,11 @@ void P_MovePlayerToStarpost(INT32 playernum) mobj->x = p->starpostx << FRACBITS; mobj->y = p->starposty << FRACBITS; P_SetThingPosition(mobj); - sector = R_PointInSubsector(mobj->x, mobj->y)->sector; - floor = - sector->f_slope ? P_GetZAt(sector->f_slope, mobj->x, mobj->y) : - sector->floorheight; - ceiling = - sector->c_slope ? P_GetZAt(sector->c_slope, mobj->x, mobj->y) : - sector->ceilingheight; + // set Z height + sector = R_PointInSubsector(mobj->x, mobj->y)->sector; + floor = P_GetSectorFloorZAt(sector, mobj->x, mobj->y); + ceiling = P_GetSectorCeilingZAt(sector, mobj->x, mobj->y); if (mobj->player->kartstuff[k_starpostflip]) z = (p->starpostz<height; @@ -11136,10 +11079,8 @@ void P_SpawnMapThing(mapthing_t *mthing) if (gametype != GT_COOP) return; - ss = R_PointInSubsector(mthing->x << FRACBITS, mthing->y << FRACBITS); - mthing->z = (INT16)((( - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, mthing->x << FRACBITS, mthing->y << FRACBITS) : - ss->sector->floorheight)>>FRACBITS) + (mthing->options >> ZSHIFT)); + ss = R_PointInSubsector((mthing->x << FRACBITS), (mthing->y << FRACBITS)); + mthing->z = (INT16)((P_GetSectorFloorZAt(ss->sector, (mthing->x << FRACBITS), (mthing->y << FRACBITS)) >> FRACBITS) + (mthing->options >> ZSHIFT)); if (numhuntemeralds < MAXHUNTEMERALDS) huntemeralds[numhuntemeralds++] = mthing; @@ -11253,18 +11194,14 @@ void P_SpawnMapThing(mapthing_t *mthing) ss = R_PointInSubsector(x, y); if (i == MT_NIGHTSBUMPER) - z = ( - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : - ss->sector->floorheight) + ((mthing->options >> ZSHIFT) << FRACBITS); + z = P_GetSectorFloorZAt(ss->sector, x, y) + ((mthing->options >> ZSHIFT) << FRACBITS); else if (i == MT_AXIS || i == MT_AXISTRANSFER || i == MT_AXISTRANSFERLINE) z = ONFLOORZ; else if (i == MT_SPECIALSPIKEBALL || P_WeaponOrPanel(i) || i == MT_EMERALDSPAWN || i == MT_EMMY) { if (mthing->options & MTF_OBJECTFLIP) { - z = ( - ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : - ss->sector->ceilingheight); + z = P_GetSectorCeilingZAt(ss->sector, x, y); if (mthing->options & MTF_AMBUSH) // Special flag for rings z -= 24*FRACUNIT; @@ -11275,9 +11212,7 @@ void P_SpawnMapThing(mapthing_t *mthing) } else { - z = ( - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : - ss->sector->floorheight); + z = P_GetSectorFloorZAt(ss->sector, x, y); if (mthing->options & MTF_AMBUSH) // Special flag for rings z += 24*FRACUNIT; @@ -11297,13 +11232,9 @@ void P_SpawnMapThing(mapthing_t *mthing) // base positions if (flip) - z = ( - ss->sector->c_slope ? P_GetZAt(ss->sector->c_slope, x, y) : - ss->sector->ceilingheight) - mobjinfo[i].height; + z = P_GetSectorCeilingZAt(ss->sector, x, y) - mobjinfo[i].height; else - z = ( - ss->sector->f_slope ? P_GetZAt(ss->sector->f_slope, x, y) : - ss->sector->floorheight); + z = P_GetSectorFloorZAt(ss->sector, x, y); // offsetting if (mthing->options >> ZSHIFT) @@ -11876,9 +11807,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER); hoopcenter->spawnpoint = mthing; - z += - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : - sec->floorheight; + z += P_GetSectorFloorZAt(sec, x, y); hoopcenter->z = z - hoopcenter->height/2; @@ -12009,9 +11938,7 @@ void P_SpawnHoopsAndRings(mapthing_t *mthing) hoopcenter = P_SpawnMobj(x, y, z, MT_HOOPCENTER); hoopcenter->spawnpoint = mthing; - z += - sec->f_slope ? P_GetZAt(sec->f_slope, x, y) : - sec->floorheight; + z += P_GetSectorFloorZAt(sec, x, y); hoopcenter->z = z - hoopcenter->height/2; P_UnsetThingPosition(hoopcenter); diff --git a/src/p_mobj.h b/src/p_mobj.h index f0dd9e836..0b380786b 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -294,6 +294,7 @@ typedef struct mobj_s fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; fixed_t old_spritexoffset, old_spriteyoffset; + INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch fixed_t realxoffset, realyoffset; @@ -396,7 +397,7 @@ typedef struct mobj_s boolean colorized; // Whether the mobj uses the rainbow colormap boolean mirrored; // The object's rotations will be mirrored left to right, e.g., see frame AL from the right and AR from the left - tic_t slamsoundtimer; + tic_t slamsoundtimer; // Funni slam sound when landing // saltyhop! hardcode edition boolean salty_ready; @@ -447,6 +448,7 @@ typedef struct precipmobj_s fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; fixed_t old_spritexoffset, old_spriteyoffset; + INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch fixed_t realxoffset, realyoffset; diff --git a/src/p_polyobj.c b/src/p_polyobj.c index ffc6651b8..61c08a05d 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -848,8 +848,7 @@ static polymaplink_t *Polyobj_getLink(void) } else { - l = Z_Malloc(sizeof(*l), PU_LEVEL, NULL); - memset(l, 0, sizeof(*l)); + l = Z_Calloc(sizeof(*l), PU_LEVEL, NULL); } return l; @@ -1565,8 +1564,7 @@ void Polyobj_InitLevel(void) { ++numPolyObjects; - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); + qitem = calloc(1, sizeof(mobjqitem_t)); qitem->mo = mo; M_QueueInsert(&(qitem->mqitem), &spawnqueue); } @@ -1574,8 +1572,7 @@ void Polyobj_InitLevel(void) { ++numAnchors; - qitem = malloc(sizeof(mobjqitem_t)); - memset(qitem, 0, sizeof(mobjqitem_t)); + qitem = calloc(1, sizeof(mobjqitem_t)); qitem->mo = mo; M_QueueInsert(&(qitem->mqitem), &anchorqueue); } @@ -2466,7 +2463,7 @@ INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) R_CreateInterpolator_Polyobj(&th->thinker, po); // T_PolyObjWaypoint is the only polyobject movement // that can adjust z, so we add these ones too. - R_CreateInterpolator_SectorPlane(&th->thinker, po->lines[0]->backsector, false); + R_CreateInterpolator_SectorPlane(&th->thinker, po->lines[0]->backsector, false); R_CreateInterpolator_SectorPlane(&th->thinker, po->lines[0]->backsector, true); // Most other polyobject functions handle children by recursively diff --git a/src/p_pspr.h b/src/p_pspr.h index 90cfc40fc..89f6c1108 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -77,6 +77,9 @@ /// \brief Frame flags: frame appears between sector bright and full bright #define FF_SEMIBRIGHT (FF_FULLBRIGHT|FF_FULLDARK) +/// \brief mobj_t.lightlevel is absolute instead of relative +#define FF_ABSOLUTELIGHTLEVEL 0x00400000 + /// \brief Frame flags: Simple stateless animation #define FF_ANIMATE 0x10000000 diff --git a/src/p_saveg.c b/src/p_saveg.c index ea3ed47b6..b5f11cedb 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1866,7 +1866,7 @@ static void P_NetArchiveThinkers(savebuffer_t *save) continue; } #ifdef PARANOIA - else // wait garbage collection + else if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) // wait garbage collection I_Error("unknown thinker type %p", th->function.acp1); #endif } @@ -1895,7 +1895,7 @@ mobj_t *P_FindNewPosition(UINT32 oldposition) if (mobj->mobjnum == oldposition) return mobj; } - CONS_Debug(DBG_GAMELOGIC, "mobj not found\n"); + CONS_Debug(DBG_GAMELOGIC, "mobj %d not found\n", oldposition); return NULL; } @@ -1928,6 +1928,25 @@ static inline player_t *LoadPlayer(UINT32 player) // // Loads a mobj_t from a save game // + +FUNCINLINE static ATTRINLINE mobj_t *AllocMobj(void) +{ + mobj_t *mobj; + + if (mobjcache != NULL) + { + mobj = mobjcache; + mobjcache = mobjcache->hnext; + memset(mobj, 0, sizeof(*mobj)); + } + else + { + mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); + } + + return mobj; +} + static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) { thinker_t *next; @@ -1959,13 +1978,12 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) return; } - mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); - + mobj = AllocMobj(); mobj->spawnpoint = &mapthings[spawnpointnum]; mapthings[spawnpointnum].mobj = mobj; } else - mobj = Z_Calloc(sizeof (*mobj), PU_LEVEL, NULL); + mobj = AllocMobj(); // declare this as a valid mobj as soon as possible. mobj->thinker.function.acp1 = thinker; @@ -1991,7 +2009,9 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) } mobj->type = i; } + mobj->info = &mobjinfo[mobj->type]; + if (diff & MD_POS) { mobj->x = READFIXED(save->p); @@ -2004,6 +2024,7 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->y = mobj->spawnpoint->y << FRACBITS; mobj->angle = FixedAngle(mobj->spawnpoint->angle*FRACUNIT); } + if (diff & MD_MOM) { mobj->momx = READFIXED(save->p); @@ -2135,30 +2156,10 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->colorized = READUINT8(save->p); //{ Saturn stuff, needs to be set, but shouldnt be synched - - // Sprite Rotation - mobj->rollangle = 0; - mobj->pitch = 0; - mobj->roll = 0; - mobj->sloperoll = 0; - mobj->slopepitch = 0; - mobj->pitch_sprite = 0; - mobj->roll_sprite = 0; - - // Horizontal flip - mobj->mirrored = 0; - // Sprite Rendering stuff mobj->blendmode = AST_TRANSLUCENT; - mobj->spritexoffset = mobj->realxoffset = 0; - mobj->spriteyoffset = mobj->realxoffset = 0; mobj->spritexscale = mobj->realxscale = FRACUNIT; mobj->spriteyscale = mobj->realyscale = FRACUNIT; - mobj->stretchslam = 0; - - // Timer for slam sound effect - mobj->slamsoundtimer = 0; - //} if (diff & MD_REDFLAG) @@ -3027,6 +3028,7 @@ static void P_RelinkPointers(void) { thinker_t *currentthinker; mobj_t *mobj; + player_t *player; // use info field (value = oldposition) to relink mobjs for (currentthinker = thinkercap.next; currentthinker != &thinkercap; @@ -3040,46 +3042,24 @@ static void P_RelinkPointers(void) if (mobj->type == MT_HOOP || mobj->type == MT_HOOPCOLLIDE || mobj->type == MT_HOOPCENTER) continue; - if (mobj->tracer) +#define RELINK(obj, name) if ((obj) && !RelinkMobj(&(obj))) \ + CONS_Debug(DBG_GAMELOGIC, name " not found on %d\n", obj->type); + + RELINK(mobj->tracer, "tracer"); + RELINK(mobj->target, "target"); + RELINK(mobj->hnext, "hnext"); + RELINK(mobj->hprev, "hprev"); + + player = mobj->player; + + if (player) { - if (!RelinkMobj(&mobj->tracer)) - CONS_Debug(DBG_GAMELOGIC, "tracer not found on %d\n", mobj->type); - } - if (mobj->target) - { - if (!RelinkMobj(&mobj->target)) - CONS_Debug(DBG_GAMELOGIC, "target not found on %d\n", mobj->type); - } - if (mobj->hnext) - { - if (!RelinkMobj(&mobj->hnext)) - CONS_Debug(DBG_GAMELOGIC, "hnext not found on %d\n", mobj->type); - } - if (mobj->hprev) - { - if (!RelinkMobj(&mobj->hprev)) - CONS_Debug(DBG_GAMELOGIC, "hprev not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->capsule) - { - if (!RelinkMobj(&mobj->player->capsule)) - CONS_Debug(DBG_GAMELOGIC, "capsule not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis1) - { - if (!RelinkMobj(&mobj->player->axis1)) - CONS_Debug(DBG_GAMELOGIC, "axis1 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->axis2) - { - if (!RelinkMobj(&mobj->player->axis2)) - CONS_Debug(DBG_GAMELOGIC, "axis2 not found on %d\n", mobj->type); - } - if (mobj->player && mobj->player->awayviewmobj) - { - if (!RelinkMobj(&mobj->player->awayviewmobj)) - CONS_Debug(DBG_GAMELOGIC, "awayviewmobj not found on %d\n", mobj->type); + RELINK(player->capsule, "capsule"); + RELINK(player->axis1, "axis1"); + RELINK(player->axis2, "axis2"); + RELINK(player->awayviewmobj, "awayviewmobj"); } +#undef RELINK } } diff --git a/src/p_setup.c b/src/p_setup.c index 048b58ecf..e4c22f253 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -279,6 +279,15 @@ FUNCNORETURN static ATTRNORETURN void CorruptMapError(const char *msg) #define NUMLAPS_DEFAULT 3 +static void P_ClearMapHeaderLighting(mapheader_lighting_t *lighting) +{ + lighting->light_contrast = 8; + lighting->sprite_backlight = 0; + lighting->use_light_angle = false; + lighting->light_angle = 0; + lighting->use_custom_light = false; +} + /** Clears the data from a single map header. * * \param i Map number to clear header for. @@ -325,9 +334,13 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) // SRB2Kart //mapheaderinfo[num]->automap = false; mapheaderinfo[num]->mobj_scale = FRACUNIT; - // an even further impossibility, delfile custom opts support + mapheaderinfo[num]->customopts = NULL; mapheaderinfo[num]->numCustomOptions = 0; + + P_ClearMapHeaderLighting(&mapheaderinfo[num]->lighting); + P_ClearMapHeaderLighting(&mapheaderinfo[num]->lighting_encore); + mapheaderinfo[num]->use_encore_lighting = false; } /** Allocates a new map-header structure. @@ -497,21 +510,130 @@ static inline float P_SegLengthFloat(seg_t *seg) */ void P_UpdateSegLightOffset(seg_t *li) { - const UINT8 contrast = 8; + const UINT8 contrast = maplighting.contrast; const fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT; fixed_t light = FRACUNIT; fixed_t extralight = 0; - light = FixedDiv(R_PointToAngle2(0, 0, abs(li->v1->x - li->v2->x), abs(li->v1->y - li->v2->y)), ANGLE_90); + if (maplighting.directional == true) + { + angle_t liAngle = R_PointToAngle2(0, 0, (li->v1->x - li->v2->x), (li->v1->y - li->v2->y)) - ANGLE_90; + + light = FixedMul(FINECOSINE(liAngle >> ANGLETOFINESHIFT), FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT)) + + FixedMul(FINESINE(liAngle >> ANGLETOFINESHIFT), FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); + light = (light + FRACUNIT) / 2; + } + else + { + light = FixedDiv(R_PointToAngle2(0, 0, abs(li->v1->x - li->v2->x), abs(li->v1->y - li->v2->y)), ANGLE_90); + } + extralight = -contrastFixed + FixedMul(light, contrastFixed * 2); // Between -2 and 2 for software, -8 and 8 for hardware - li->lightOffset = FixedFloor((extralight / contrast) + (FRACUNIT / 2)) / FRACUNIT; + li->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; #ifdef HWRENDER li->hwLightOffset = FixedFloor(extralight + (FRACUNIT / 2)) / FRACUNIT; #endif } +boolean P_SectorUsesDirectionalLighting(const sector_t *sector) +{ + if (sector != NULL) + { + // automatically turned on + if (sector->ceilingpic == skyflatnum || sector->floorpic == skyflatnum) + { + // sky is visible + return true; + } + } + + // default is off, for indoors + return false; +} + +boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector) +{ + mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; + + if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) + { + lighting = &mapheaderinfo[gamemap-1]->lighting_encore; + } + + if (!cv_randomdirlight.value && lighting->use_custom_light == false) + return (baselightnum < LIGHTLEVELS-1 && baselightnum > 0); + + if (!P_SectorUsesDirectionalLighting(sector)) + { + return false; + } + + // Don't apply light offsets at full bright or full dark. + // Is in steps of light num . + return (baselightnum < LIGHTLEVELS-1 && baselightnum > 0); +} + +boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector) +{ + mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; + + if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) + { + lighting = &mapheaderinfo[gamemap-1]->lighting_encore; + } + + if (!cv_randomdirlight.value && lighting->use_custom_light == false) + return (baselightlevel < 255 && baselightlevel > 0); + + if (!P_SectorUsesDirectionalLighting(sector)) + { + return false; + } + + // Don't apply light offsets at full bright or full dark. + // Uses exact light levels for more smoothness. + return (baselightlevel < 255 && baselightlevel > 0); +} + +// dumb thing to reset maplight on next map change when its toggled +boolean reinitmaplight = false; +static void P_SetupDirectionalLight(void) +{ + mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting; + + if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting) + { + lighting = &mapheaderinfo[gamemap-1]->lighting_encore; + } + + if (cv_randomdirlight.value && lighting->use_custom_light == false) + { + static INT16 oldmap = 0; // dont reset stuff when you restart a map + static boolean oldencore = false; + + if (gamemap != oldmap || encoremode != oldencore || reinitmaplight) + { + lighting->light_contrast = M_RandomRange(0, 58); + lighting->sprite_backlight = 0; + lighting->use_light_angle = M_RandomRange(0, 1); // either on or off + lighting->light_angle = M_RandomRange(-382, 382); + + reinitmaplight = false; + } + + oldmap = gamemap; + oldencore = encoremode; + return; + } + + maplighting.contrast = lighting->light_contrast; + maplighting.backlight = lighting->sprite_backlight; + maplighting.directional = lighting->use_light_angle; + maplighting.angle = lighting->light_angle; +} + // Loads the SEGS resource from a level. static void P_LoadRawSegs(UINT8 *data) { @@ -521,6 +643,9 @@ static void P_LoadRawSegs(UINT8 *data) line_t *ldef; size_t i; + // Set map lighting settings. + P_SetupDirectionalLight(); + for (i = 0; i < numsegs; i++, li++, ml++) { li->v1 = &vertexes[SHORT(ml->v1)]; @@ -877,14 +1002,13 @@ static void P_LoadThings(void) mt = mapthings; numhuntemeralds = 0; + for (i = 0; i < nummapthings; i++, mt++) { - sector_t *mtsector = R_PointInSubsector(mt->x << FRACBITS, mt->y << FRACBITS)->sector; + sector_t *mtsector = R_PointInSubsector((mt->x << FRACBITS), (mt->y << FRACBITS))->sector; // Z for objects - mt->z = (INT16)( - mtsector->f_slope ? P_GetZAt(mtsector->f_slope, mt->x << FRACBITS, mt->y << FRACBITS) : - mtsector->floorheight)>>FRACBITS; + mt->z = (INT16)(P_GetSectorFloorZAt(mtsector, (mt->x << FRACBITS), (mt->y << FRACBITS))) >> FRACBITS; if (mt->type == 1700 // MT_AXIS || mt->type == 1701 // MT_AXISTRANSFER @@ -1312,7 +1436,7 @@ static void P_LoadRawSideDefs2(void *data) // encore mode colormaps! // do it like software by aproximating a color to a palette index, and then convert it to its encore variant and then back to a color code. // do this for both the start and fade colormaps. - + color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); @@ -1353,7 +1477,7 @@ static void P_LoadRawSideDefs2(void *data) col = msd->bottomtexture; // do the exact same thing as above here. - + color.s.red = (HEX2INT(col[1]) << 4) + HEX2INT(col[2]); color.s.green = (HEX2INT(col[3]) << 4) + HEX2INT(col[4]); color.s.blue = (HEX2INT(col[5]) << 4) + HEX2INT(col[6]); @@ -2915,6 +3039,11 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) // Clear pointers that would be left dangling by the purge R_FlushTranslationColormapCache(); +#ifdef HWRENDER + // Delete light table textures + HWR_ClearLightTables(); +#endif + Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); #if defined (WALLSPLATS) || defined (FLOORSPLATS) @@ -2939,7 +3068,7 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) curmapvirt = vres_GetMap(lastloadedmaplumpnum); R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, - (encoremode ? W_CheckNumForName(va("%sE", maplumpname)) : LUMPERROR)); + W_CheckNumForName(va("%s%c", maplumpname, (encoremode ? 'E' : 'T')))); CON_SetupBackColormap(); // SRB2 determines the sky texture to be used depending on the map header. @@ -3002,7 +3131,9 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) { P_InitCamera(); memset(localaiming, 0, sizeof(localaiming)); - K_InitDirector(); + + if (!dedicated) + K_InitDirector(); } // clear special respawning que diff --git a/src/p_setup.h b/src/p_setup.h index 5985fb016..723b48d18 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -99,8 +99,14 @@ void P_WriteThings(lumpnum_t lump); fixed_t P_SegLength(seg_t *seg); #endif +extern boolean reinitmaplight; void P_UpdateSegLightOffset(seg_t *li); +boolean P_ApplyLightOffset(UINT8 baselightnum, const sector_t *sector); +boolean P_ApplyLightOffsetFine(UINT8 baselightlevel, const sector_t *sector); +boolean P_SectorUsesDirectionalLighting(const sector_t *sector); + size_t P_PrecacheLevelFlats(void); + void P_AllocMapHeader(INT16 i); // Needed for NiGHTS diff --git a/src/p_sight.c b/src/p_sight.c index 874ba5ae5..5dfc796b8 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -33,6 +33,8 @@ typedef struct { static INT32 sightcounts[2]; +typedef INT32 (*divlinefunc)(fixed_t x, fixed_t y, const divline_t *node); + // // P_DivlineSide // @@ -51,6 +53,15 @@ static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node) right == left ? 2 : 1); } +static inline INT32 P_DivlineSideFast(fixed_t x, fixed_t y, const divline_t *node) +{ + INT64 v = ((INT64)y - node->y) * node->dx - ((INT64)x - node->x) * node->dy; + + if (v == 0) + return 2; + return v > 0; +} + static inline INT32 P_DivlineCrossed(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node) { return (P_DivlineSide(x1, y1, node) == P_DivlineSide(x2, y2, node)); @@ -292,16 +303,19 @@ static boolean P_CrossSubsector(size_t num, register los_t *los) // killough 4/20/98: rewritten to remove tail recursion, clean up, and optimize static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) { + const divlinefunc divlineFunc = fast ? P_DivlineSideFast : P_DivlineSide; + while (!(bspnum & NF_SUBSECTOR)) { register node_t *bsp = nodes + bspnum; - INT32 side = (fast ? R_PointOnSideFast(los->strace.x, los->strace.y, bsp) : (P_DivlineSide(los->strace.x, los->strace.y, (divline_t *)bsp) & 1)); - INT32 side2 = (fast ? R_PointOnSideFast(los->t2x, los->t2y, bsp) : P_DivlineSide(los->t2x, los->t2y, (divline_t *) bsp)); + INT32 side = divlineFunc(los->strace.x, los->strace.y, (divline_t *)bsp) & 1; + INT32 side2 = divlineFunc(los->t2x, los->t2y, (divline_t *) bsp); if (side == side2) { - bspnum = bsp->children[side]; // doesn't touch the other side + // doesn't touch the other side + bspnum = bsp->children[side]; } else // the partition plane is crossed here { diff --git a/src/p_slopes.c b/src/p_slopes.c index 542ce244d..e64cd6f6b 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -30,14 +30,14 @@ static UINT16 slopecount = 0; // Calculate light static void P_UpdateSlopeLightOffset(pslope_t *slope) { - const boolean ceiling = (slope->normal.z < 0); - const UINT8 contrast = 8; + const UINT8 contrast = maplighting.contrast; fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT; fixed_t zMul = FRACUNIT; - angle_t slopeDir = ANGLE_MAX; + fixed_t light = FRACUNIT; fixed_t extralight = 0; + if (slope->normal.z == 0) { slope->lightOffset = 0; @@ -47,15 +47,47 @@ static void P_UpdateSlopeLightOffset(pslope_t *slope) return; } - slopeDir = R_PointToAngle2(0, 0, abs(slope->normal.y), abs(slope->normal.x)); - if (ceiling == true) + if (maplighting.directional == true) { - slopeDir ^= ANGLE_180; + fixed_t nX = -slope->normal.x; + fixed_t nY = -slope->normal.y; + fixed_t nLen = FixedHypot(nX, nY); + + if (nLen == 0) + { + slope->lightOffset = 0; +#ifdef HWRENDER + slope->hwLightOffset = 0; +#endif + return; + } + + nX = FixedDiv(nX, nLen); + nY = FixedDiv(nY, nLen); + + /* + * if (slope is ceiling) + * { + * // There is no good way to calculate this condition here. + * // We reverse it in R_FindPlane now. + * nX = -nX; + * nY = -nY; + } + */ + + light = FixedMul(nX, FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT)) + + FixedMul(nY, FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); + light = (light + FRACUNIT) / 2; + } + else + { + light = FixedDiv(R_PointToAngle2(0, 0, abs(slope->d.x), abs(slope->d.y)), ANGLE_90); } zMul = min(FRACUNIT, abs(slope->zdelta)*3/2); // *3/2, to make 60 degree slopes match walls. contrastFixed = FixedMul(contrastFixed, zMul); - extralight = -contrastFixed + FixedMul(FixedDiv(AngleFixed(slopeDir), ANGLE_90), (contrastFixed * 2)); + + extralight = -contrastFixed + FixedMul(light, contrastFixed * 2); // Between -2 and 2 for software, -8 and 8 for hardware slope->lightOffset = FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; @@ -149,54 +181,60 @@ void P_RunDynamicSlopes(void) { pslope_t *slope; - for (slope = slopelist; slope; slope = slope->next) { + for (slope = slopelist; slope; slope = slope->next) + { fixed_t zdelta; if (slope->flags & SL_NODYNAMIC) continue; - switch(slope->refpos) { - case 1: // front floor - zdelta = slope->sourceline->backsector->floorheight - slope->sourceline->frontsector->floorheight; - slope->o.z = slope->sourceline->frontsector->floorheight; - break; - case 2: // front ceiling - zdelta = slope->sourceline->backsector->ceilingheight - slope->sourceline->frontsector->ceilingheight; - slope->o.z = slope->sourceline->frontsector->ceilingheight; - break; - case 3: // back floor - zdelta = slope->sourceline->frontsector->floorheight - slope->sourceline->backsector->floorheight; - slope->o.z = slope->sourceline->backsector->floorheight; - break; - case 4: // back ceiling - zdelta = slope->sourceline->frontsector->ceilingheight - slope->sourceline->backsector->ceilingheight; - slope->o.z = slope->sourceline->backsector->ceilingheight; - break; - case 5: // vertices - { - mapthing_t *mt; - size_t i; - INT32 l; - line_t *line; + switch(slope->refpos) + { + case 1: // front floor + zdelta = slope->sourceline->backsector->floorheight - slope->sourceline->frontsector->floorheight; + slope->o.z = slope->sourceline->frontsector->floorheight; + break; + case 2: // front ceiling + zdelta = slope->sourceline->backsector->ceilingheight - slope->sourceline->frontsector->ceilingheight; + slope->o.z = slope->sourceline->frontsector->ceilingheight; + break; + case 3: // back floor + zdelta = slope->sourceline->frontsector->floorheight - slope->sourceline->backsector->floorheight; + slope->o.z = slope->sourceline->backsector->floorheight; + break; + case 4: // back ceiling + zdelta = slope->sourceline->frontsector->ceilingheight - slope->sourceline->backsector->ceilingheight; + slope->o.z = slope->sourceline->backsector->ceilingheight; + break; + case 5: // vertices + { + mapthing_t *mt; + size_t i; + INT32 l; + line_t *line; - for (i = 0; i < 3; i++) { - mt = slope->vertices[i]; - l = P_FindSpecialLineFromTag(799, mt->angle, -1); - if (l != -1) { - line = &lines[l]; - mt->z = line->frontsector->floorheight >> FRACBITS; + for (i = 0; i < 3; i++) + { + mt = slope->vertices[i]; + l = P_FindSpecialLineFromTag(799, mt->angle, -1); + + if (l != -1) + { + line = &lines[l]; + mt->z = line->frontsector->floorheight >> FRACBITS; + } } + + P_ReconfigureVertexSlope(slope); } + continue; // TODO - P_ReconfigureVertexSlope(slope); - } - continue; // TODO - - default: - I_Error("P_RunDynamicSlopes: slope has invalid type!"); + default: + I_Error("P_RunDynamicSlopes: slope has invalid type!"); } - if (slope->zdelta != FixedDiv(zdelta, slope->extent)) { + if (slope->zdelta != FixedDiv(zdelta, slope->extent)) + { slope->zdelta = FixedDiv(zdelta, slope->extent); slope->zangle = R_PointToAngle2(0, 0, slope->extent, -zdelta); slope->real_zangle = slope->zangle; @@ -213,8 +251,7 @@ void P_RunDynamicSlopes(void) static pslope_t *P_MakeSlope(const vector3_t *o, const vector2_t *d, const fixed_t zdelta, UINT8 flags) { - pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL); - memset(ret, 0, sizeof(*ret)); + pslope_t *ret = Z_Calloc(sizeof(pslope_t), PU_LEVEL, NULL); ret->o.x = o->x; ret->o.y = o->y; @@ -308,13 +345,13 @@ void P_SpawnSlope_Line(int linenum) if (line->flags & ML_NOKNUX) flags |= SL_ANCHORVERTEX; - if(!frontfloor && !backfloor && !frontceil && !backceil) + if (!frontfloor && !backfloor && !frontceil && !backceil) { CONS_Printf("P_SpawnSlope_Line called with non-slope line special.\n"); return; } - if(!line->frontsector || !line->backsector) + if (!line->frontsector || !line->backsector) { CONS_Debug(DBG_SETUP, "P_SpawnSlope_Line used on a line without two sides. (line number %i)\n", linenum); return; @@ -380,7 +417,7 @@ void P_SpawnSlope_Line(int linenum) fslope->sourceline = line; // To find the real highz/lowz of a slope, you need to check all the vertexes - // in the slope's sector with P_GetZAt to get the REAL lowz & highz + // in the slope's sector with P_GetSlopeZAt to get the REAL lowz & highz // Although these slopes are set by floorheights the ANGLE is what a slope is, // so technically any slope can extend on forever (they are just bound by sectors) // *You can use sourceline as a reference to see if two slopes really are the same @@ -394,7 +431,7 @@ void P_SpawnSlope_Line(int linenum) for (l = 0; l < line->frontsector->linecount; l++) { - fixed_t height = P_GetZAt(line->frontsector->f_slope, line->frontsector->lines[l]->v1->x, line->frontsector->lines[l]->v1->y); + fixed_t height = P_GetSlopeZAt(line->frontsector->f_slope, line->frontsector->lines[l]->v1->x, line->frontsector->lines[l]->v1->y); if (height > highest) highest = height; @@ -441,7 +478,7 @@ void P_SpawnSlope_Line(int linenum) for (l = 0; l < line->frontsector->linecount; l++) { - fixed_t height = P_GetZAt(line->frontsector->c_slope, line->frontsector->lines[l]->v1->x, line->frontsector->lines[l]->v1->y); + fixed_t height = P_GetSlopeZAt(line->frontsector->c_slope, line->frontsector->lines[l]->v1->x, line->frontsector->lines[l]->v1->y); if (height > highest) highest = height; @@ -510,7 +547,7 @@ void P_SpawnSlope_Line(int linenum) for (l = 0; l < line->backsector->linecount; l++) { - fixed_t height = P_GetZAt(line->backsector->f_slope, line->backsector->lines[l]->v1->x, line->backsector->lines[l]->v1->y); + fixed_t height = P_GetSlopeZAt(line->backsector->f_slope, line->backsector->lines[l]->v1->x, line->backsector->lines[l]->v1->y); if (height > highest) highest = height; @@ -557,7 +594,7 @@ void P_SpawnSlope_Line(int linenum) for (l = 0; l < line->backsector->linecount; l++) { - fixed_t height = P_GetZAt(line->backsector->c_slope, line->backsector->lines[l]->v1->x, line->backsector->lines[l]->v1->y); + fixed_t height = P_GetSlopeZAt(line->backsector->c_slope, line->backsector->lines[l]->v1->x, line->backsector->lines[l]->v1->y); if (height > highest) highest = height; @@ -594,15 +631,13 @@ static pslope_t *P_NewVertexSlope(INT16 tag1, INT16 tag2, INT16 tag3, UINT8 flag size_t i; mapthing_t *mt = mapthings; - pslope_t *ret = Z_Malloc(sizeof(pslope_t), PU_LEVEL, NULL); - memset(ret, 0, sizeof(*ret)); + pslope_t *ret = Z_Calloc(sizeof(pslope_t), PU_LEVEL, NULL); // Start by setting flags ret->flags = flags; // Now set up the vertex list - ret->vertices = Z_Malloc(3*sizeof(mapthing_t), PU_LEVEL, NULL); - memset(ret->vertices, 0, 3*sizeof(mapthing_t)); + ret->vertices = Z_Calloc(3*sizeof(mapthing_t), PU_LEVEL, NULL); // And... look for the vertices in question. for (i = 0; i < nummapthings; i++, mt++) @@ -656,7 +691,7 @@ void P_CopySectorSlope(line_t *line) int i, special = line->special; // Check for copy linedefs - for(i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;) + for (i = -1; (i = P_FindSectorFromLineTag(line, i)) >= 0;) { sector_t *srcsec = sectors + i; @@ -867,11 +902,14 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) { vector3_t mom; // Ditto. - if (slope->flags & SL_NOPHYSICS) { // No physics, no need to make anything complicated. - if (P_MobjFlip(thing)*(thing->momz) < 0) { // falling, land on slope + if (slope->flags & SL_NOPHYSICS) // No physics, no need to make anything complicated. + { + if (P_MobjFlip(thing)*(thing->momz) < 0) // falling, land on slope + { thing->momz = -P_MobjFlip(thing); thing->standingslope = slope; } + return; } @@ -881,11 +919,11 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) P_ReverseQuantizeMomentumToSlope(&mom, slope); - if (P_MobjFlip(thing)*mom.z < 0) { // falling, land on slope + if (P_MobjFlip(thing)*mom.z < 0) // falling, land on slope + { thing->momx = mom.x; thing->momy = mom.y; thing->momz = -P_MobjFlip(thing); - thing->standingslope = slope; } } @@ -905,7 +943,8 @@ void P_ButteredSlope(mobj_t *mo) if (mo->flags & (MF_NOCLIPHEIGHT|MF_NOGRAVITY)) return; // don't slide down slopes if you can't touch them or you're not affected by gravity - if (mo->player) { + if (mo->player) + { if (abs(mo->standingslope->zdelta) < FRACUNIT/4 && !(mo->player->pflags & PF_SPINNING)) return; // Don't slide on non-steep slopes unless spinning @@ -915,9 +954,12 @@ void P_ButteredSlope(mobj_t *mo) thrust = FINESINE(mo->standingslope->zangle>>ANGLETOFINESHIFT) * 15 / 16 * (mo->eflags & MFE_VERTICALFLIP ? 1 : -1); - if (mo->player && (mo->player->pflags & PF_SPINNING)) { + if (mo->player && (mo->player->pflags & PF_SPINNING)) + { fixed_t mult = 0; - if (mo->momx || mo->momy) { + + if (mo->momx || mo->momy) + { angle_t angle = R_PointToAngle2(0, 0, mo->momx, mo->momy) - mo->standingslope->xydirection; if (P_MobjFlip(mo) * mo->standingslope->zdelta < 0) diff --git a/src/p_slopes.h b/src/p_slopes.h index 89cfdc343..40502a5ea 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -40,39 +40,44 @@ extern pslope_t *slopelist; // // Returns the height of the sloped plane at (x, y) as a fixed_t -FUNCINLINE static ATTRINLINE fixed_t P_GetZAt(pslope_t *z_slope, fixed_t x, fixed_t y) +FUNCINLINE static ATTRINLINE fixed_t P_GetSlopeZAt(const pslope_t *z_slope, fixed_t x, fixed_t y) { return z_slope->o.z + FixedMul((FixedMul(x - z_slope->o.x, z_slope->d.x) + FixedMul(y - z_slope->o.y, z_slope->d.y)), z_slope->zdelta); } +// Like P_GetSlopeZAt but falls back to z if slope is NULL +FUNCINLINE static ATTRINLINE fixed_t P_GetZAt(const pslope_t *slope, fixed_t x, fixed_t y, fixed_t z) +{ + return slope ? P_GetSlopeZAt(slope, x, y) : z; +} // Returns the height of the sector floor at (x, y) FUNCINLINE static ATTRINLINE fixed_t P_GetSectorFloorZAt(const sector_t *z_sector, fixed_t x, fixed_t y) { - return z_sector->f_slope ? P_GetZAt(z_sector->f_slope, x, y) : z_sector->floorheight; + return z_sector->f_slope ? P_GetSlopeZAt(z_sector->f_slope, x, y) : z_sector->floorheight; } // Returns the height of the sector ceiling at (x, y) FUNCINLINE static ATTRINLINE fixed_t P_GetSectorCeilingZAt(const sector_t *z_sector, fixed_t x, fixed_t y) { - return z_sector->c_slope ? P_GetZAt(z_sector->c_slope, x, y) : z_sector->ceilingheight; + return z_sector->c_slope ? P_GetSlopeZAt(z_sector->c_slope, x, y) : z_sector->ceilingheight; } // Returns the height of the FOF top at (x, y) FUNCINLINE static ATTRINLINE fixed_t P_GetFFloorTopZAt(const ffloor_t *z_ffloor, fixed_t x, fixed_t y) { - return *z_ffloor->t_slope ? P_GetZAt(*z_ffloor->t_slope, x, y) : *z_ffloor->topheight; + return *z_ffloor->t_slope ? P_GetSlopeZAt(*z_ffloor->t_slope, x, y) : *z_ffloor->topheight; } // Returns the height of the FOF bottom at (x, y) FUNCINLINE static ATTRINLINE fixed_t P_GetFFloorBottomZAt(const ffloor_t *z_ffloor, fixed_t x, fixed_t y) { - return *z_ffloor->b_slope ? P_GetZAt(*z_ffloor->b_slope, x, y) : *z_ffloor->bottomheight; + return *z_ffloor->b_slope ? P_GetSlopeZAt(*z_ffloor->b_slope, x, y) : *z_ffloor->bottomheight; } // Returns the height of the light list at (x, y) FUNCINLINE static ATTRINLINE fixed_t P_GetLightZAt(const lightlist_t *z_light, fixed_t x, fixed_t y) { - return z_light->slope ? P_GetZAt(z_light->slope, x, y) : z_light->height; + return z_light->slope ? P_GetSlopeZAt(z_light->slope, x, y) : z_light->height; } // Lots of physics-based bullshit diff --git a/src/p_spec.c b/src/p_spec.c index 7dc7ce6bb..670289fcf 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -3287,9 +3287,10 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers if (roversector || P_MobjReadyToTrigger(player->mo, sector)) P_DamageMobj(player->mo, NULL, NULL, 1); break; - case 2: // Damage (Water) // SRB2kart - These three damage types are now offroad sectors - case 3: // Damage (Fire) - case 4: // Damage (Electrical) + // SRB2kart - These three damage types are now offroad sectors + case 2: // Offroad (Weak) + case 3: // Offroad + case 4: // Offroad (Strong) break; case 5: // Spikes // Don't do anything. In Soviet Russia, spikes find you. @@ -5124,11 +5125,10 @@ void T_LaserFlash(laserthink_t *flash) sourcesec = ffloor->master->frontsector; // Less to type! - top = (*ffloor->t_slope) ? P_GetZAt(*ffloor->t_slope, sector->soundorg.x, sector->soundorg.y) - : *ffloor->topheight; - bottom = (*ffloor->b_slope) ? P_GetZAt(*ffloor->b_slope, sector->soundorg.x, sector->soundorg.y) - : *ffloor->bottomheight; + top = P_GetFFloorTopZAt (ffloor, sector->soundorg.x, sector->soundorg.y); + bottom = P_GetFFloorBottomZAt(ffloor, sector->soundorg.x, sector->soundorg.y); sector->soundorg.z = (top + bottom)/2; + S_StartSound(§or->soundorg, sfx_laser); // Seek out objects to DESTROY! MUAHAHHAHAHAA!!!*cough* @@ -6764,10 +6764,7 @@ void T_Disappear(disappear_t *d) if (!(lines[d->sourceline].flags & ML_NOCLIMB)) { - if (*rover->t_slope) - sectors[s].soundorg.z = P_GetZAt(*rover->t_slope, sectors[s].soundorg.x, sectors[s].soundorg.y); - else - sectors[s].soundorg.z = *rover->topheight; + sectors[s].soundorg.z = P_GetFFloorTopZAt(rover, sectors[s].soundorg.x, sectors[s].soundorg.y); S_StartSound(§ors[s].soundorg, sfx_appear); } } diff --git a/src/p_tick.c b/src/p_tick.c index dc8036828..8fbdf8b6a 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -297,7 +297,6 @@ void P_UnlinkThinker(thinker_t *thinker) } } - // // P_RemoveThinker // @@ -364,7 +363,7 @@ static inline void P_RunThinkers(void) for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { #ifdef PARANOIA - I_Assert(currentthinker->function.acp1 != NULL) + I_Assert(currentthinker->function.acp1 != NULL); #endif currentthinker->function.acp1(currentthinker); } @@ -465,10 +464,10 @@ void P_RunChaseCameras(void) player_t *p = &players[displayplayers[i]]; camera_t *cam = &camera[i]; - if (cv_verticallook.value && leveltime > starttime && p->mo && p->kartstuff[k_respawn] == 0 && p->kartstuff[k_throwdir] != 0) + if (cv_verticallook[i].value && leveltime > starttime && p->mo && p->kartstuff[k_respawn] == 0 && p->kartstuff[k_throwdir] != 0) { if (p->speed < 6 * p->mo->scale && abs(cam->dpad_y_held) < 2*TICRATE) - cam->dpad_y_held += intsign(p->kartstuff[k_throwdir]); + cam->dpad_y_held += p->kartstuff[k_throwdir]; } else cam->dpad_y_held = 0; @@ -524,7 +523,7 @@ static inline void P_ResetSpriteStuff(void) mo = (mobj_t *)th; - if (mo->sprite == SPR_NULL || mo->flags2 & MF2_DONTDRAW || mo->type == MT_SHADOW) + if (!mo || (mo->sprite == SPR_NULL) || (mo->flags2 & MF2_DONTDRAW) || (mo->type == MT_SHADOW)) continue; mo->spritexscale = mo->realxscale; @@ -630,7 +629,7 @@ void P_Ticker(boolean run) } #endif } - + ps_lua_mobjhooks.value.i = 0; ps_checkposition_calls.value.i = 0; @@ -836,6 +835,7 @@ void P_PreTicker(INT32 frames) LUA_HOOK(PreThinkFrame); for (i = 0; i < MAXPLAYERS; i++) + { if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) { // stupid fucking cmd hack @@ -850,6 +850,7 @@ void P_PreTicker(INT32 frames) memcpy(&players[i].cmd, &temptic, sizeof(ticcmd_t)); } + } // Dynamic slopeness if (midgamejoin) diff --git a/src/p_user.c b/src/p_user.c index dacd18868..c9712048e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -557,14 +557,9 @@ void P_PlayRinglossSound(mobj_t *source, mobj_t *damager) { sfxenum_t sfx = sfx_khurt1 + key; - INT32 skinnum = -1; - // I HATE LOCALSKINS! I HATE LOCALSKINS! :AAAAAAAAAA: if (source->player) - skinnum = source->player->skinlocal ? (source->player->localskin - 1) : source->player->skin; - - if (skinnum >= 0) - sfx = (source->player->skinlocal ? localskins : skins)[skinnum].soundsid[SKSKPAN1 + key]; + sfx = K_GetPlayerSkin(source->player)->soundsid[SKSKPAN1 + key]; S_StartSound(NULL, sfx); } @@ -1195,9 +1190,9 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->tics = -1; ghost->frame &= ~FF_TRANSMASK; ghost->frame |= tr_trans50<slopepitch = mobj->slopepitch; + ghost->slopepitch = mobj->slopepitch; ghost->sloperoll = mobj->sloperoll; - + ghost->fuse = ghost->info->damage; ghost->skin = mobj->skin; ghost->localskin = mobj->localskin; @@ -1254,17 +1249,13 @@ void P_DoPlayerExit(player_t *player) { sfxenum_t sfx_id; // fix godjjsa win sounds - if (K_IsPlayerLosing(player)) { - if (player->mo->localskin) - sfx_id = ((skin_t *)player->mo->localskin)->soundsid[S_sfx[sfx_klose].skinsound]; - else - sfx_id = ((skin_t *)player->mo->skin)->soundsid[S_sfx[sfx_klose].skinsound]; + if (K_IsPlayerLosing(player)) + { + sfx_id = K_GetMobjSkin(player->mo)->soundsid[S_sfx[sfx_klose].skinsound]; } - else { - if (player->mo->localskin) - sfx_id = ((skin_t *)player->mo->localskin)->soundsid[S_sfx[sfx_kwin].skinsound]; - else - sfx_id = ((skin_t *)player->mo->skin)->soundsid[S_sfx[sfx_kwin].skinsound]; + else + { + sfx_id = K_GetMobjSkin(player->mo)->soundsid[S_sfx[sfx_kwin].skinsound]; } S_StartSound(NULL, sfx_id); } @@ -1326,8 +1317,9 @@ boolean P_InSpaceSector(mobj_t *mo) // Returns true if you are in space if (GETSECSPECIAL(rover->master->frontsector->special, 1) != SPACESPECIAL) continue; - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, mo->x, mo->y) : *rover->bottomheight; + + topheight = P_GetFFloorTopZAt(rover, mo->x, mo->y); + bottomheight = P_GetFFloorBottomZAt(rover, mo->x, mo->y); if (mo->z + (mo->height/2) > topheight) continue; @@ -1361,8 +1353,8 @@ boolean P_InQuicksand(mobj_t *mo) // Returns true if you are in quicksand if (!(rover->flags & FF_QUICKSAND)) continue; - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, mo->x, mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, mo->x, mo->y) : *rover->bottomheight; + topheight = P_GetFFloorTopZAt(rover, mo->x, mo->y); + bottomheight = P_GetFFloorBottomZAt(rover, mo->x, mo->y); if (mo->z + flipoffset > topheight) continue; @@ -1653,8 +1645,8 @@ static void P_CheckQuicksand(player_t *player) if (!(rover->flags & FF_QUICKSAND)) continue; - topheight = *rover->t_slope ? P_GetZAt(*rover->t_slope, player->mo->x, player->mo->y) : *rover->topheight; - bottomheight = *rover->b_slope ? P_GetZAt(*rover->b_slope, player->mo->x, player->mo->y) : *rover->bottomheight; + topheight = P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y); + bottomheight = P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y); if (topheight >= player->mo->z && bottomheight < player->mo->z + player->mo->height) { @@ -2142,12 +2134,16 @@ static void P_SpectatorMovement(player_t *player) void P_BlackOw(player_t *player) { INT32 i; - S_StartSound (player->mo, sfx_bkpoof); // Sound the BANG! + S_StartSound(player->mo, sfx_bkpoof); // Sound the BANG! for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && P_AproxDistance(player->mo->x - players[i].mo->x, - player->mo->y - players[i].mo->y) < 1536*FRACUNIT) + { + if (!playeringame[i]) + continue; + + if (P_AproxDistance(player->mo->x - players[i].mo->x, player->mo->y - players[i].mo->y) < 1536*FRACUNIT) P_FlashPal(&players[i], PAL_NUKE, 10); + } P_NukeEnemies(player->mo, player->mo, 1536*FRACUNIT); // Search for all nearby enemies and nuke their pants off! player->powers[pw_shield] = player->powers[pw_shield] & SH_STACK; @@ -2177,12 +2173,15 @@ void P_ElementalFireTrail(player_t *player) { newx = player->mo->x + P_ReturnThrustX(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); newy = player->mo->y + P_ReturnThrustY(player->mo, travelangle + ((i&1) ? -1 : 1)*ANGLE_135, FixedMul(24*FRACUNIT, player->mo->scale)); + if (player->mo->standingslope) { - ground = P_GetZAt(player->mo->standingslope, newx, newy); + ground = P_GetSlopeZAt(player->mo->standingslope, newx, newy); + if (player->mo->eflags & MFE_VERTICALFLIP) ground -= FixedMul(mobjinfo[MT_SPINFIRE].height, player->mo->scale); } + flame = P_SpawnMobj(newx, newy, ground, MT_SPINFIRE); P_SetTarget(&flame->target, player->mo); flame->angle = travelangle; @@ -2193,6 +2192,7 @@ void P_ElementalFireTrail(player_t *player) flame->momx = 8; P_XYMovement(flame); + if (P_MobjWasRemoved(flame)) continue; @@ -3095,7 +3095,7 @@ consvar_t cv_cam_timeover[MAXSPLITSCREENPLAYERS] = { {"cam_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam2_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam3_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam4_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam4_timeover", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} }; static CV_PossibleValue_t freecam_speed_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; @@ -3103,7 +3103,7 @@ consvar_t cv_freecam_speed[MAXSPLITSCREENPLAYERS] = { {"freecam_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"freecam2_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"freecam3_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"freecam4_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"freecam4_speed", "1", CV_SAVE, freecam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; consvar_t cv_tilting = {"tilting", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; @@ -3113,7 +3113,13 @@ 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}; static CV_PossibleValue_t lookbackmom_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Double"}, {0, NULL}}; -consvar_t cv_lookbackmom = {"cameralookbackmom", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_lookbackmom[MAXSPLITSCREENPLAYERS] = { + {"cameralookbackmom", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cameralookbackmom2", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cameralookbackmom3", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cameralookbackmom4", "Off", CV_SAVE, lookbackmom_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +}; fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42}; @@ -4000,10 +4006,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // when looking back, camera's momentum // should inherit the momentum of the player // if value is 2, add extra - if (cv_lookbackmom.value && lookback && lookbackdelay[num]) + if (cv_lookbackmom[num].value && lookback && lookbackdelay[num]) { - thiscam->momx += cv_lookbackmom.value*mo->momx; - thiscam->momy += cv_lookbackmom.value*mo->momy; + thiscam->momx += cv_lookbackmom[num].value*mo->momx; + thiscam->momy += cv_lookbackmom[num].value*mo->momy; } thiscam->momz = FixedMul(z - thiscam->z, camspeed/2); @@ -4433,6 +4439,37 @@ DoABarrelRoll (player_t *player) #define SPINOUTROTSPEED (24 * FRACUNIT) #define MAXSPINROT (360 * FRACUNIT) +static void P_DoFunnyDance (player_t *player) +{ + static tic_t time = 0; + fixed_t bounce; + fixed_t work, bpm; + angle_t ang; + + if (player->spectator || !player->mo || player->kartstuff[k_respawn] || player->mo->salty_jump) // this looks jank as hell during hop + return; + + bounce = 0; + + // bpm = FLOAT_TO_FIXED(mapmusic.bpm) << maybe can get the tempo and beat detection lib to work for bpm autodetection + bpm = FixedDiv((60*TICRATE)<= (FRACUNIT>>1)) // prevent overflow jump - takes about 15 minutes + time = (work>>FRACBITS); + + work = FixedDiv(work*180, bpm); + + ang = (FixedAngle(work)>>ANGLETOFINESHIFT) & FINEMASK; + bounce = (FINESINE(ang) - FRACUNIT/2); + + player->mo->spritexscale -= bounce/2; + player->mo->spriteyscale += bounce/2; + + time++; // bruh +} + // // P_PlayerThink // @@ -4709,7 +4746,7 @@ void P_PlayerThink(player_t *player) continue; break; } - + if (i < MAXPLAYERS && !player->spectator && !player->exiting && !(player->pflags & PF_TIMEOVER)) { const tic_t griefval = cv_antigrief.value * TICRATE; @@ -4730,11 +4767,7 @@ void P_PlayerThink(player_t *player) && !P_IsLocalPlayer(player)) // P_IsMachineLocalPlayer for DRRR { // Send kick - UINT8 buf[2]; - - buf[0] = n; - buf[1] = KICK_MSG_GRIEF; - SendNetXCmd(XD_KICK, &buf, 2); + SendKick(n, KICK_MSG_GRIEF); } else { @@ -4974,6 +5007,16 @@ void P_PlayerThink(player_t *player) if (player->losstime && !player->powers[pw_flashing]) player->losstime--; + if (cv_squishdance.value && (cmd->buttons & BT_CUSTOM3)) + { + player->dancetime++; + + if (player->dancetime > TICRATE*2) + P_DoFunnyDance(player); + } + else + player->dancetime = 0; + // Flash player after being hit. if (!(player->kartstuff[k_hyudorotimer] // SRB2kart - fixes Hyudoro not flashing when it should. || player->kartstuff[k_growshrinktimer] > 0 // Grow doesn't flash either. diff --git a/src/r_bsp.c b/src/r_bsp.c index 9cfc3e515..e2e878078 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -372,30 +372,11 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, return sec; } -boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back) +boolean R_IsEmptyLine(seg_t *line, const sector_t *front, const sector_t *back) { - return ( - !line->polyseg && - back->ceilingpic == front->ceilingpic - && back->floorpic == front->floorpic - && back->f_slope == front->f_slope - && back->c_slope == front->c_slope - && back->lightlevel == front->lightlevel - && !line->sidedef->midtexture - // Check offsets too! - && back->floor_xoffs == front->floor_xoffs - && back->floor_yoffs == front->floor_yoffs - && back->floorpic_angle == front->floorpic_angle - && back->ceiling_xoffs == front->ceiling_xoffs - && back->ceiling_yoffs == front->ceiling_yoffs - && back->ceilingpic_angle == front->ceilingpic_angle - // Consider altered lighting. - && back->floorlightsec == front->floorlightsec - && back->ceilinglightsec == front->ceilinglightsec - // Consider colormaps - && back->extra_colormap == front->extra_colormap - && ((!front->ffloors && !back->ffloors) - || front->tag == back->tag)); + return (!line->sidedef->midtexture && !line->polyseg + && ((!front->ffloors && !back->ffloors) || front->tag == back->tag) + && (memcmp(front, back, (offsetof(sector_t, extra_colormap) + sizeof(extracolormap_t *))) == 0)); } // @@ -501,11 +482,8 @@ static void R_AddLine(seg_t *line) if (frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope) { #define SLOPEPARAMS(slope, end1, end2, normalheight) \ - if (slope) { \ - end1 = P_GetZAt(slope, line->v1->x, line->v1->y); \ - end2 = P_GetZAt(slope, line->v2->x, line->v2->y); \ - } else \ - end1 = end2 = normalheight; + end1 = P_GetZAt(slope, line->v1->x, line->v1->y, normalheight); \ + end2 = P_GetZAt(slope, line->v2->x, line->v2->y, normalheight); SLOPEPARAMS(frontsector->f_slope, frontf1, frontf2, frontsector->floorheight) SLOPEPARAMS(frontsector->c_slope, frontc1, frontc2, frontsector->ceilingheight) @@ -813,7 +791,7 @@ static void R_AddPolyObjects(subsector_t *sub) ++numpolys; po = (polyobj_t *)(po->link.next); } - + // for render stats ps_numpolyobjects.value.i += numpolys; @@ -868,13 +846,8 @@ static void R_Subsector(size_t num) floorcolormap = ceilingcolormap = frontsector->extra_colormap; - floorcenterz = - frontsector->f_slope ? P_GetZAt(frontsector->f_slope, frontsector->soundorg.x, frontsector->soundorg.y) : - frontsector->floorheight; - - ceilingcenterz = - frontsector->c_slope ? P_GetZAt(frontsector->c_slope, frontsector->soundorg.x, frontsector->soundorg.y) : - frontsector->ceilingheight; + floorcenterz = P_GetSectorFloorZAt(frontsector, frontsector->soundorg.x, frontsector->soundorg.y); + ceilingcenterz = P_GetSectorCeilingZAt(frontsector, frontsector->soundorg.x, frontsector->soundorg.y); // Check and prep all 3D floors. Set the sector floor/ceiling light levels and colormaps. if (frontsector->ffloors) @@ -919,23 +892,19 @@ static void R_Subsector(size_t num) sub->sector->extra_colormap = frontsector->extra_colormap; - if ((( - frontsector->f_slope ? P_GetZAt(frontsector->f_slope, viewx, viewy) : - frontsector->floorheight) < viewz || (frontsector->heightsec != -1 + if ((P_GetSectorFloorZAt(frontsector, viewx, viewy) < viewz || (frontsector->heightsec != -1 && sectors[frontsector->heightsec].ceilingpic == skyflatnum))) { floorplane = R_FindPlane(frontsector->floorheight, frontsector->floorpic, floorlightlevel, frontsector->floor_xoffs, frontsector->floor_yoffs, frontsector->floorpic_angle, floorcolormap, NULL , NULL , frontsector->f_slope - , R_NoEncore(frontsector, false)); + , R_NoEncore(frontsector, false), false, frontsector); } else floorplane = NULL; - if ((( - frontsector->c_slope ? P_GetZAt(frontsector->c_slope, viewx, viewy) : - frontsector->ceilingheight) > viewz || frontsector->ceilingpic == skyflatnum + if ((P_GetSectorCeilingZAt(frontsector, viewx, viewy) > viewz || frontsector->ceilingpic == skyflatnum || (frontsector->heightsec != -1 && sectors[frontsector->heightsec].floorpic == skyflatnum))) { @@ -944,7 +913,7 @@ static void R_Subsector(size_t num) ceilingcolormap, NULL , NULL , frontsector->c_slope - , R_NoEncore(frontsector, true)); + , R_NoEncore(frontsector, true), true, frontsector); } else ceilingplane = NULL; @@ -953,13 +922,14 @@ static void R_Subsector(size_t num) ffloor[numffloors].slope = NULL; ffloor[numffloors].plane = NULL; ffloor[numffloors].polyobj = NULL; + if (frontsector->ffloors) { fixed_t heightcheck, planecenterz; for (rover = frontsector->ffloors; rover && numffloors < MAXFFLOORS; rover = rover->next) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES) || !(rover->flags & FF_RENDERALL)) continue; if (frontsector->cullheight) @@ -974,13 +944,9 @@ static void R_Subsector(size_t num) ffloor[numffloors].plane = NULL; ffloor[numffloors].polyobj = NULL; - heightcheck = - *rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : - *rover->bottomheight; + heightcheck = P_GetFFloorBottomZAt(rover, viewx, viewy); + planecenterz = P_GetFFloorBottomZAt(rover, frontsector->soundorg.x, frontsector->soundorg.y); - planecenterz = - *rover->b_slope ? P_GetZAt(*rover->b_slope, frontsector->soundorg.x, frontsector->soundorg.y) : - *rover->bottomheight; if (planecenterz <= ceilingcenterz && planecenterz >= floorcenterz && ((viewz < heightcheck && !(rover->flags & FF_INVERTPLANES)) @@ -994,7 +960,7 @@ static void R_Subsector(size_t num) *rover->bottomyoffs, *rover->bottomangle, frontsector->lightlist[light].extra_colormap, rover , NULL , *rover->b_slope - , R_NoEncore(rover->master->frontsector, true)); + , R_NoEncore(rover->master->frontsector, true), true, frontsector); ffloor[numffloors].slope = *rover->b_slope; @@ -1006,18 +972,16 @@ static void R_Subsector(size_t num) ffloor[numffloors].ffloor = rover; numffloors++; } + if (numffloors >= MAXFFLOORS) break; + ffloor[numffloors].plane = NULL; ffloor[numffloors].polyobj = NULL; - heightcheck = - *rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : - *rover->topheight; + heightcheck = P_GetFFloorTopZAt(rover, viewx, viewy); + planecenterz = P_GetFFloorTopZAt(rover, frontsector->soundorg.x, frontsector->soundorg.y); - planecenterz = - *rover->t_slope ? P_GetZAt(*rover->t_slope, frontsector->soundorg.x, frontsector->soundorg.y) : - *rover->topheight; if (planecenterz >= floorcenterz && planecenterz <= ceilingcenterz && ((viewz > heightcheck && !(rover->flags & FF_INVERTPLANES)) @@ -1030,7 +994,7 @@ static void R_Subsector(size_t num) frontsector->lightlist[light].extra_colormap, rover , NULL , *rover->t_slope - , R_NoEncore(rover->master->frontsector, false)); + , R_NoEncore(rover->master->frontsector, false), false, frontsector); ffloor[numffloors].slope = *rover->t_slope; @@ -1075,7 +1039,7 @@ static void R_Subsector(size_t num) polysec->floorpic_angle-po->angle, (light == -1 ? frontsector->extra_colormap : frontsector->lightlist[light].extra_colormap), NULL, po ,NULL // will ffloors be slopable eventually? - , R_NoEncore(polysec, false)); + , R_NoEncore(polysec, false), false, frontsector); ffloor[numffloors].height = polysec->floorheight; ffloor[numffloors].polyobj = po; @@ -1099,7 +1063,7 @@ static void R_Subsector(size_t num) (light == -1 ? frontsector->lightlevel : *frontsector->lightlist[light].lightlevel), polysec->ceiling_xoffs, polysec->ceiling_yoffs, polysec->ceilingpic_angle-po->angle, (light == -1 ? frontsector->extra_colormap : frontsector->lightlist[light].extra_colormap), NULL, po ,NULL // will ffloors be slopable eventually? - , R_NoEncore(polysec, true)); + , R_NoEncore(polysec, true), false, frontsector); ffloor[numffloors].polyobj = po; ffloor[numffloors].height = polysec->ceilingheight; @@ -1185,7 +1149,7 @@ void R_Prep3DFloors(sector_t *sector) else memset(sector->lightlist, 0, sizeof (lightlist_t) * count); - heighttest = sector->c_slope ? P_GetZAt(sector->c_slope, sector->soundorg.x, sector->soundorg.y) : sector->ceilingheight; + heighttest = P_GetSectorCeilingZAt(sector, sector->soundorg.x, sector->soundorg.y); sector->lightlist[0].height = heighttest + 1; sector->lightlist[0].slope = sector->c_slope; @@ -1206,7 +1170,7 @@ void R_Prep3DFloors(sector_t *sector) && !(rover->flags & FF_CUTLEVEL) && !(rover->flags & FF_CUTSPRITES))) continue; - heighttest = *rover->t_slope ? P_GetZAt(*rover->t_slope, sector->soundorg.x, sector->soundorg.y) : *rover->topheight; + heighttest = P_GetFFloorTopZAt(rover, sector->soundorg.x, sector->soundorg.y); if (heighttest > bestheight && heighttest < maxheight) { @@ -1215,8 +1179,9 @@ void R_Prep3DFloors(sector_t *sector) bestslope = *rover->t_slope; continue; } - if (rover->flags & FF_DOUBLESHADOW) { - heighttest = *rover->b_slope ? P_GetZAt(*rover->b_slope, sector->soundorg.x, sector->soundorg.y) : *rover->bottomheight; + if (rover->flags & FF_DOUBLESHADOW) + { + heighttest = P_GetFFloorBottomZAt(rover, sector->soundorg.x, sector->soundorg.y); if (heighttest > bestheight && heighttest < maxheight) @@ -1240,6 +1205,7 @@ void R_Prep3DFloors(sector_t *sector) sector->lightlist[i].slope = bestslope; sec = §ors[best->secnum]; mapnum = sec->midmap; + if (mapnum >= 0 && (size_t)mapnum < num_extra_colormaps) sec->extra_colormap = &extra_colormaps[mapnum]; else @@ -1263,7 +1229,8 @@ void R_Prep3DFloors(sector_t *sector) if (best->flags & FF_DOUBLESHADOW) { - heighttest = *best->b_slope ? P_GetZAt(*best->b_slope, sector->soundorg.x, sector->soundorg.y) : *best->bottomheight; + heighttest = P_GetFFloorBottomZAt(best, sector->soundorg.x, sector->soundorg.y); + if (bestheight == heighttest) ///TODO: do this in a more efficient way -Red { sector->lightlist[i].lightlevel = sector->lightlist[best->lastlight].lightlevel; @@ -1317,7 +1284,6 @@ void R_RenderBSPNode(INT32 bspnum) // Decide which side the view point is on. side = R_PointOnSideFast(viewx, viewy, bsp); - // Recursively divide front space. R_RenderBSPNode(bsp->children[side]); diff --git a/src/r_bsp.h b/src/r_bsp.h index f93541d7b..7ba6c330c 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -55,7 +55,7 @@ extern polyobj_t **po_ptrs; // temp ptr array to sort polyobject pointers sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, INT32 *ceilinglightlevel, boolean back); -boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back); +boolean R_IsEmptyLine(seg_t *line, const sector_t *front, const sector_t *back); INT32 R_GetPlaneLight(sector_t *sector, fixed_t planeheight, boolean underside); void R_Prep3DFloors(sector_t *sector); diff --git a/src/r_data.c b/src/r_data.c index ddac60598..6b4bef3d0 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -28,7 +28,6 @@ #ifdef HWRENDER #include "hardware/hw_main.h" -#include "hardware/hw_glob.h" // HWR_ClearLightTables #endif #ifdef _WIN32 @@ -1266,11 +1265,6 @@ void R_ClearColormaps(void) foundcolormaps[i] = LUMPERROR; memset(extra_colormaps, 0, sizeof (extra_colormaps)); - -#ifdef HWRENDER - if (rendermode == render_opengl) - HWR_ClearLightTables(); -#endif } /*INT32 R_ColormapNumForName(char *name) @@ -1451,13 +1445,13 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) extra_colormaps[mapnum].fadestart = (UINT16)fadestart; extra_colormaps[mapnum].fadeend = (UINT16)fadeend; extra_colormaps[mapnum].fog = fog; - + if (rendermode != render_none) - { + { double r, g, b, cbrightness; int p; lighttable_t *colormap_p; - + // Initialise the map and delta arrays // map[i] stores an RGB color (as double) for index i, // which is then converted to SRB2's palette later @@ -1537,7 +1531,7 @@ INT32 R_CreateColormap(char *p1, char *p2, char *p3) } } } - + return (INT32)mapnum; } diff --git a/src/r_defs.h b/src/r_defs.h index 389dd497d..a1706289f 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -279,13 +279,32 @@ typedef enum // typedef struct sector_s { - fixed_t floorheight; - fixed_t ceilingheight; INT32 floorpic; INT32 ceilingpic; INT16 lightlevel; + + pslope_t *f_slope; // floor slope + pslope_t *c_slope; // ceiling slope + + // floor and ceiling texture offsets + fixed_t floor_xoffs, floor_yoffs; + fixed_t ceiling_xoffs, ceiling_yoffs; + + // flat angle + angle_t floorpic_angle; + angle_t ceilingpic_angle; + + INT32 floorlightsec, ceilinglightsec; + + // per-sector colormaps! + extracolormap_t *extra_colormap; + + fixed_t floorheight; + fixed_t ceilingheight; + INT16 special; UINT16 tag; + INT32 nexttag, firsttag; // for fast tag searches // origin for any sounds played by the sector @@ -303,18 +322,9 @@ typedef struct sector_s void *ceilingdata; // ceiling move thinker void *lightingdata; // lighting change thinker - // floor and ceiling texture offsets - fixed_t floor_xoffs, floor_yoffs; - fixed_t ceiling_xoffs, ceiling_yoffs; - - // flat angle - angle_t floorpic_angle; - angle_t ceilingpic_angle; - INT32 heightsec; // other sector, or -1 if no other sector INT32 camsec; // used for camera clipping - INT32 floorlightsec, ceilinglightsec; INT32 crumblestate; // used for crumbling and bobbing INT32 bottommap, midmap, topmap; // dynamic colormaps @@ -341,9 +351,6 @@ typedef struct sector_s INT32 numlights; boolean moved; - // per-sector colormaps! - extracolormap_t *extra_colormap; - // This points to the master's floorheight, so it can be changed in realtime! fixed_t *gravity; // per-sector gravity boolean verticalflip; // If gravity < 0, then allow flipped physics @@ -356,8 +363,6 @@ typedef struct sector_s fixed_t floorspeed, ceilspeed; // Eternity engine slope - pslope_t *f_slope; // floor slope - pslope_t *c_slope; // ceiling slope boolean hasslope; // The sector, or one of its visible FOFs, contains a slope // these are saved for netgames, so do not let Lua touch these! @@ -648,7 +653,7 @@ typedef struct INT16 height; INT16 leftoffset; // pixels to the left of origin INT16 topoffset; // pixels below the origin - INT32 columnofs[]; // only [width] used + INT32 columnofs[8]; // only [width] used // the [0] is &columnofs[width] } patch_t; @@ -715,9 +720,9 @@ typedef struct // Flip bits (1 = flip) to use for view angles 0-7. UINT8 flip; - + #ifdef ROTSPRITE - rotsprite_t *rotated[2][16]; // Rotated patches + rotsprite_t *rotated[16]; // Rotated patches #endif } spriteframe_t; diff --git a/src/r_draw.c b/src/r_draw.c index ef4496349..f7d1fb413 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -214,14 +214,12 @@ const UINT8 Color_Opposite[MAXSKINCOLORS*2] = CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; -#define TRANSTAB_AMTMUL10 (256.0f / 10.0f) - /** \brief Initializes the translucency tables used by the Software renderer. */ void R_InitTranslucencyTables(void) { - // Load here the transparency lookup tables 'TINTTAB' - // NOTE: the TINTTAB resource MUST BE aligned on 64k for the asm + // 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 = Z_MallocAlign(NUMTRANSTABLES*0x10000, PU_STATIC, NULL, 16); @@ -317,7 +315,7 @@ static void BlendTab_Modulative(UINT8 *table) static INT32 BlendTab_Count[NUMBLENDMAPS] = { - NUMTRANSTABLES, // blendtab_add + NUMTRANSTABLES+1, // blendtab_add NUMTRANSTABLES+1, // blendtab_subtract NUMTRANSTABLES+1, // blendtab_reversesubtract 1 // blendtab_modulate @@ -337,7 +335,7 @@ static INT32 BlendTab_FromStyle[] = static void BlendTab_GenerateMaps(INT32 tab, INT32 style, void (*genfunc)(UINT8 *, int, UINT8)) { INT32 i = 0, num = BlendTab_Count[tab]; - const float amtmul = (256.0f / (float)(NUMTRANSTABLES)); + const float amtmul = (256.0f / (float)(NUMTRANSTABLES + 1)); for (; i < num; i++) { const size_t offs = (0x10000 * i); @@ -384,8 +382,8 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel) { size_t offs; - if (style == AST_COPY || style == AST_OVERLAY) - return NULL; + if (style <= AST_COPY || style >= AST_OVERLAY) + return transtables + (ClipTransLevel(alphalevel) << FF_TRANSSHIFT); offs = (ClipBlendLevel(style, alphalevel) << FF_TRANSSHIFT); @@ -414,7 +412,7 @@ UINT8 *R_GetBlendTable(int style, INT32 alphalevel) boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel) { - if (blendmode == AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode == AST_OVERLAY) + if (blendmode <= AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode >= AST_OVERLAY) return true; return (alphalevel < BlendTab_Count[BlendTab_FromStyle[blendmode]]); @@ -454,7 +452,6 @@ static UINT8* RGetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 f if (flags & GTC_CACHE) { - // Allocate table for skin if necessary if (!tt[skintableindex]) tt[skintableindex] = Z_Calloc(MAXTRANSLATIONS * sizeof(UINT8**), PU_STATIC, NULL); @@ -486,12 +483,12 @@ UINT8* R_GetTranslationColormap(INT32 skinnum, skincolors_t color, UINT8 flags) UINT8* R_GetLocalTranslationColormap(skin_t *skin, skin_t *localskin, skincolors_t color, UINT8 flags, boolean local) { if (localskin) - return RGetTranslationColormap(( localskin - ( (local) ? localskins : skins ) ), color, flags, local); + return RGetTranslationColormap(localskin - K_GetSkinArray(local), color, flags, local); else - return RGetTranslationColormap(( skin - skins ), color, flags, false); + return RGetTranslationColormap((skin - skins), color, flags, false); } -patch_t* R_GetSkinFaceRank(player_t* ply) +patch_t* R_GetSkinFaceRank(player_t* ply) { if (ply->skinlocal && ply->localskin) return localfacerankprefix[ply->localskin - 1]; @@ -500,7 +497,7 @@ patch_t* R_GetSkinFaceRank(player_t* ply) return facerankprefix[ply->skin]; } -patch_t* R_GetSkinFaceWant(player_t* ply) +patch_t* R_GetSkinFaceWant(player_t* ply) { if (ply->skinlocal && ply->localskin) return localfacewantprefix[ply->localskin - 1]; @@ -509,7 +506,7 @@ patch_t* R_GetSkinFaceWant(player_t* ply) return facewantprefix[ply->skin]; } -patch_t* R_GetSkinFaceMini(player_t* ply) +patch_t* R_GetSkinFaceMini(player_t* ply) { if (ply->skinlocal && ply->localskin) return localfacemmapprefix[ply->localskin - 1]; diff --git a/src/r_draw8.c b/src/r_draw8.c index 1a6e45a5a..f9e3e12e7 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -25,9 +25,9 @@ void R_DrawColumn_8(void) { INT32 count; - register UINT8 *dest; - register fixed_t frac; - fixed_t fracstep; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; INT32 npow2min; INT32 npow2max; @@ -57,12 +57,12 @@ void R_DrawColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - register const UINT8 *source = dc_source; - register const lighttable_t *colormap = dc_colormap; + const UINT8 *restrict source = dc_source; + const lighttable_t *restrict colormap = dc_colormap; - register INT32 heightmask = dc_sourcelength-1; + intptr_t heightmask = dc_sourcelength-1; npow2min = -1; - npow2max = dc_sourcelength-1; + npow2max = dc_sourcelength; if (dc_sourcelength & heightmask) // not a power of 2 -- killough { @@ -105,12 +105,15 @@ void R_DrawColumn_8(void) dest += vid.width; + +#if __SIZEOF_POINTER__ < 8 // 64-bit systems have large enough numbers for this to be a non-issue // Avoid overflow. if (fracstep > 0x7FFFFFFF - frac) { frac += fracstep - heightmask; } else +#endif { frac += fracstep; } @@ -147,9 +150,10 @@ void R_DrawColumn_8(void) void R_Draw2sMultiPatchColumn_8(void) { INT32 count; - register UINT8 *dest; - register fixed_t frac; - fixed_t fracstep; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + INT32 npow2min; INT32 npow2max; @@ -178,12 +182,13 @@ void R_Draw2sMultiPatchColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - register const UINT8 *source = dc_source; - register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_sourcelength-1; - register UINT8 val; + const UINT8 *restrict source = dc_source; + const lighttable_t *restrict colormap = dc_colormap; + intptr_t heightmask = dc_sourcelength-1; + UINT8 val; + npow2min = -1; - npow2max = dc_sourcelength-1; + npow2max = dc_sourcelength; if (dc_sourcelength & heightmask) // not a power of 2 -- killough { @@ -233,11 +238,13 @@ void R_Draw2sMultiPatchColumn_8(void) dest += vid.width; // Avoid overflow. +#if __SIZEOF_POINTER__ < 8 if (fracstep > 0x7FFFFFFF - frac) { frac += fracstep - heightmask; } else +#endif { frac += fracstep; } @@ -285,9 +292,10 @@ void R_Draw2sMultiPatchColumn_8(void) void R_Draw2sMultiPatchTranslucentColumn_8(void) { INT32 count; - register UINT8 *dest; - register fixed_t frac; - fixed_t fracstep; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + INT32 npow2min; INT32 npow2max; @@ -316,13 +324,14 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - register const UINT8 *source = dc_source; - register const UINT8 *transmap = dc_transmap; - register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_sourcelength-1; + const UINT8 *restrict source = dc_source; + const UINT8 *transmap = dc_transmap; + const lighttable_t *restrict colormap = dc_colormap; + intptr_t heightmask = dc_sourcelength-1; register UINT8 val; + npow2min = -1; - npow2max = dc_sourcelength-1; + npow2max = dc_sourcelength; if (dc_sourcelength & heightmask) // not a power of 2 -- killough { @@ -372,11 +381,13 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) dest += vid.width; // Avoid overflow. +#if __SIZEOF_POINTER__ < 8 if (fracstep > 0x7FFFFFFF - frac) { frac += fracstep - heightmask; } else +#endif { frac += fracstep; } @@ -470,8 +481,10 @@ void R_DrawShadeColumn_8(void) void R_DrawTranslucentColumn_8(void) { register INT32 count; - register UINT8 *dest; - register fixed_t frac, fracstep; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + INT32 npow2min; INT32 npow2max; @@ -496,12 +509,13 @@ void R_DrawTranslucentColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - register const UINT8 *source = dc_source; - register const UINT8 *transmap = dc_transmap; - register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_sourcelength-1; + const UINT8 *restrict source = dc_source; + const UINT8 *transmap = dc_transmap; + const lighttable_t *restrict colormap = dc_colormap; + intptr_t heightmask = dc_sourcelength-1; + npow2min = -1; - npow2max = dc_sourcelength-1; + npow2max = dc_sourcelength; if (dc_sourcelength & heightmask) { @@ -579,8 +593,10 @@ void R_DrawTranslucentColumn_8(void) void R_DrawTranslatedTranslucentColumn_8(void) { register INT32 count; - register UINT8 *dest; - register fixed_t frac, fracstep; + UINT8 *restrict dest; + intptr_t frac; + intptr_t fracstep; + INT32 npow2min; INT32 npow2max; @@ -605,9 +621,10 @@ void R_DrawTranslatedTranslucentColumn_8(void) // Inner loop that does the actual texture mapping, e.g. a DDA-like scaling. // This is as fast as it gets. - register INT32 heightmask = dc_sourcelength-1; + intptr_t heightmask = dc_sourcelength-1; + npow2min = -1; - npow2max = dc_sourcelength-1; + npow2max = dc_sourcelength; if (dc_sourcelength & heightmask) { @@ -739,19 +756,22 @@ void R_DrawTranslatedColumn_8(void) */ void R_DrawSpan_8 (void) { - fixed_t xposition; - fixed_t yposition; - fixed_t xstep, ystep; + uintptr_t xposition; + uintptr_t yposition; + uintptr_t xstep, ystep; register UINT32 bit; - const UINT8 *source = ds_source; - const UINT8 *colormap = ds_colormap; - register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; - const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; + UINT8 *restrict source = ds_source; + UINT8 *restrict colormap = ds_colormap; + UINT8 *restrict dest = ylookup[ds_y] + columnofs[ds_x1]; + const UINT8 *restrict deststop = screens[0] + vid.rowbytes * vid.height; register size_t count = (ds_x2 - ds_x1 + 1); size_t i; + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the // texture with two shifts, an OR and one AND. (see below) @@ -759,8 +779,12 @@ void R_DrawSpan_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; + + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; if (dest+8 > deststop) { @@ -801,13 +825,14 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) { // ZDoom uses a different lighting setup to us, and I couldn't figure out how to adapt their version // of this function. Here's my own. - INT32 i; + INT32 left = ds_x1, right = ds_x2; fixed_t step = (end-start)/(ds_x2-ds_x1+1); + INT32 i; // I wanna do some optimizing by checking for out-of-range segments on either side to fill in all at once, // but I'm too bad at coding to not crash the game trying to do that. I guess this is fast enough for now... - for (i = ds_x1; i <= ds_x2; i++) + for (i = left; i <= right; i++) { tiltlighting[i] = (start += step) >> FRACBITS; @@ -1541,14 +1566,17 @@ void R_DrawTranslucentSpan_8 (void) fixed_t xstep, ystep; register UINT32 bit; - const UINT8 *source = ds_source; - const UINT8 *colormap = ds_colormap; - register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; + UINT8 *source; + UINT8 *colormap; + register UINT8 *dest; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; register size_t count = (ds_x2 - ds_x1 + 1); size_t i; + xposition = ds_xfrac; yposition = ds_yfrac; + xstep = ds_xstep; ystep = ds_ystep; + // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the // texture with two shifts, an OR and one AND. (see below) @@ -1556,8 +1584,12 @@ void R_DrawTranslucentSpan_8 (void) // bit per power of two (obviously) // Ok, because I was able to eliminate the variable spot below, this function is now FASTER // than the original span renderer. Whodathunkit? - xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; - xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; + xposition <<= nflatshiftup; yposition <<= nflatshiftup; + xstep <<= nflatshiftup; ystep <<= nflatshiftup; + + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; while (count >= 8) { @@ -1593,10 +1625,10 @@ void R_DrawTranslucentWaterSpan_8(void) UINT32 xstep, ystep; register UINT32 bit; - const UINT8 *source = ds_source; - const UINT8 *colormap = ds_colormap; - register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; - register UINT8 *dsrc; + UINT8 *source; + UINT8 *colormap; + register UINT8 *dest; + UINT8 *dsrc; register size_t count; size_t i; @@ -1611,6 +1643,9 @@ void R_DrawTranslucentWaterSpan_8(void) xposition = ds_xfrac << nflatshiftup; yposition = (ds_yfrac + ds_waterofs) << nflatshiftup; xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; + source = ds_source; + colormap = ds_colormap; + dest = ylookup[ds_y] + columnofs[ds_x1]; dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; count = ds_x2 - ds_x1 + 1; diff --git a/src/r_fps.c b/src/r_fps.c index 92eb37a32..9827a65f2 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -171,14 +171,7 @@ void R_InterpolateView(fixed_t frac, boolean forceinvalid) if (frac > FRACUNIT) frac = FRACUNIT; - if (viewcontext >= VIEWCONTEXT_SKY1) - { - i = viewcontext - VIEWCONTEXT_SKY1; - } - else - { - i = viewcontext - VIEWCONTEXT_PLAYER1; - } + i = R_GetViewNumber(); if (oldview_invalid[i] != 0 || forceinvalid) { @@ -211,8 +204,7 @@ void R_UpdateViewInterpolation(void) { pview_old[i] = pview_new[i]; skyview_old[i] = skyview_new[i]; - - if (oldview_invalid[i]) oldview_invalid[i]--; + if (oldview_invalid[i] > 0) oldview_invalid[i]--; } last_view_update = I_GetTime(); @@ -286,7 +278,7 @@ void R_SetViewContext(enum viewcontext_e _viewcontext) } return (R_LerpFixed(from, to, rendertimefrac)); -} +}*/ angle_t R_InterpolateAngle(angle_t from, angle_t to) { @@ -296,7 +288,7 @@ angle_t R_InterpolateAngle(angle_t from, angle_t to) } return (R_LerpAngle(from, to, rendertimefrac)); -}*/ +} void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out) { @@ -364,11 +356,7 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst out->z = mobj->z; out->scale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; //out->subsector = mobj->subsector; - out->angle = mobj->angle; - out->spritexscale = mobj->spritexscale; - out->spriteyscale = mobj->spriteyscale; - out->spritexoffset = mobj->spritexoffset; - out->spriteyoffset = mobj->spriteyoffset; + //out->angle = mobj->angle; return; } @@ -376,13 +364,8 @@ void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjst out->y = R_LerpFixed(mobj->old_y, mobj->y, frac); out->z = R_LerpFixed(mobj->old_z, mobj->z, frac); out->scale = cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT; - out->spritexscale = mobj->spritexscale; - out->spriteyscale = mobj->spriteyscale; - out->spritexoffset = mobj->spritexoffset; - out->spriteyoffset = mobj->spriteyoffset; //out->subsector = R_PointInSubsector(out->x, out->y); // this is unused - - out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); + //out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac); } static void AddInterpolator(levelinterpolator_t* interpolator) diff --git a/src/r_fps.h b/src/r_fps.h index 563989fa6..006f80b67 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -134,7 +134,7 @@ void R_RelativeTeleportViewInterpolation(UINT8 p, fixed_t xdiff, fixed_t ydiff, // Set the current view context (the viewvars pointed to by newview) void R_SetViewContext(enum viewcontext_e _viewcontext); -fixed_t R_InterpolateFixed(fixed_t from, fixed_t to); +//fixed_t R_InterpolateFixed(fixed_t from, fixed_t to); angle_t R_InterpolateAngle(angle_t from, angle_t to); // Evaluate the interpolated mobj state for the given mobj diff --git a/src/r_main.c b/src/r_main.c index c39047b01..4ff9a96ff 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -29,6 +29,7 @@ #include "d_main.h" #include "v_video.h" #include "p_spec.h" // skyboxmo +#include "p_setup.h" #include "z_zone.h" #include "m_random.h" // quake camera shake #include "r_portal.h" @@ -160,6 +161,8 @@ void SendWeaponPref2(void); void SendWeaponPref3(void); void SendWeaponPref4(void); +static void DirLight_OnChange(void); + static void Precipstuff_OnChange(void); consvar_t cv_tailspickup = {"tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -211,6 +214,15 @@ consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL consvar_t cv_maxportals = {"maxportals", "2", CV_SAVE, maxportals_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +// randomized directional lightning +consvar_t cv_randomdirlight = {"randomdirectionallight", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, DirLight_OnChange, 0, NULL, NULL, 0, 0, NULL}; + +// tells to reset the maplight at next map change +static void DirLight_OnChange(void) +{ + reinitmaplight = true; +} + void SplitScreen_OnChange(void) { UINT8 i; @@ -1040,34 +1052,6 @@ 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); - side = R_PointOnSideFast(x, y, node); // this is fine since R_IsPointInSubsector is only used for precip spawn unless you disable noclipcam lol - 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 // @@ -1089,7 +1073,7 @@ static void R_SetupCommonFrame(player_t * player, sector_t * sector) else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); + R_InterpolateView(rendertimefrac_unpaused, false); } static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) @@ -1390,7 +1374,7 @@ void R_RenderPlayerView(player_t *player) } Portal_InitList(); - + PS_START_TIMING(ps_skyboxtime); if (skybox && skyVisible) { @@ -1441,6 +1425,9 @@ void R_RenderPlayerView(player_t *player) R_ClearVisibleFloorSplats(); #endif + // check for new console commands. + NetUpdate(); + // The head node is the last node output. ps_numbspcalls.value.i = ps_numpolyobjects.value.i = ps_numdrawnodes.value.i = 0; @@ -1451,7 +1438,7 @@ void R_RenderPlayerView(player_t *player) PS_START_TIMING(ps_sw_spritecliptime); R_ClipSprites(); PS_STOP_TIMING(ps_sw_spritecliptime); - + ps_numsprites.value.i = numvisiblesprites; PS_START_TIMING(ps_sw_portaltime); @@ -1502,6 +1489,9 @@ void R_RenderPlayerView(player_t *player) R_DrawMasked(); PS_STOP_TIMING(ps_sw_maskedtime); + // Check for new console commands. + NetUpdate(); + // save value to skyVisiblePerPlayer // this is so that P1 can't affect whether P2 can see a skybox or not, or vice versa for (i = 0; i <= splitscreen; i++) @@ -1567,6 +1557,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam_rotate[i]); CV_RegisterVar(&cv_cam_timeover[i]); CV_RegisterVar(&cv_freecam_speed[i]); + + CV_RegisterVar(&cv_lookbackmom[i]); } CV_RegisterVar(&cv_tilting); @@ -1574,8 +1566,6 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_tiltsmoothing); CV_RegisterVar(&cv_actionmovie); - CV_RegisterVar(&cv_lookbackmom); - CV_RegisterVar(&cv_driftsparkpulse); CV_RegisterVar(&cv_gravstretch); CV_RegisterVar(&cv_sloperoll); @@ -1590,6 +1580,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_maxportals); + CV_RegisterVar(&cv_randomdirlight); + CV_RegisterVar(&cv_maxinterpdist); CV_RegisterVar(&cv_ripplewater); diff --git a/src/r_main.h b/src/r_main.h index 1b8d8c71c..780e4db70 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -128,8 +128,6 @@ angle_t R_PlayerSliptideAngle(player_t *player); fixed_t R_ScaleFromGlobalAngle(angle_t visangle); -subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y); - // // R_PointInSubsector // @@ -143,6 +141,32 @@ FUNCINLINE static ATTRINLINE subsector_t *R_PointInSubsector(fixed_t x, fixed_t 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; + + 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; +} #define R_PointToDist(x, y) R_PointToDist2(viewx, viewy, x, y) #define R_PointToDist2(px2, py2, px1, py1) FixedHypot((px1) - (px2), (py1) - (py2)) @@ -189,6 +213,8 @@ extern consvar_t cv_tailspickup; extern consvar_t cv_maxinterpdist; extern consvar_t cv_ripplewater; +extern consvar_t cv_randomdirlight; + // Called by startup code. void R_Init(void); diff --git a/src/r_patch.c b/src/r_patch.c index 75bd3361c..ed8d5962d 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -335,9 +335,9 @@ static unsigned char imgbuf[1<<26]; // Convert a masked flat to a patch. // Explanation of "masked" flats in R_PatchToMaskedFlat. // -void *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) +static void *R_MaskedFlatToPatch(UINT16 *raw, INT16 width, INT16 height, INT16 leftoffset, INT16 topoffset, size_t *destsize) { - UINT32 x, y; + INT16 x, y; UINT8 *img; UINT8 *imgptr = imgbuf; UINT8 *colpointers, *startofspan; @@ -440,7 +440,6 @@ void *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 lefto if (destsize != NULL) *destsize = size; - return img; } @@ -448,24 +447,38 @@ static UINT16 GetPatchPixel(patch_t *patch, INT32 x, INT32 y, boolean flip) { fixed_t ofs; column_t *column; - UINT8 *source; + UINT8 *source = NULL; + INT16 width; - if (x >= 0 && x < SHORT(patch->width)) + if (patch == NULL) + I_Error("GetPatchPixel: patch == NULL"); + + width = SHORT(patch->width); + + if (x >= 0 && x < width) { + INT32 colx = flip ? (width-1)-x : x; INT32 topdelta, prevdelta = -1; - column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[flip ? (patch->width-1-x) : x])); + + column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[colx])); + while (column->topdelta != 0xff) { topdelta = column->topdelta; + if (topdelta <= prevdelta) topdelta += prevdelta; + prevdelta = topdelta; - source = (UINT8 *)(column) + 3; - for (ofs = 0; ofs < column->length; ofs++) + + ofs = (y - topdelta); + + if (y >= topdelta && ofs < column->length) { - if ((topdelta + ofs) == y) - return source[ofs]; + source = (UINT8 *)(column) + 3; + return source[ofs]; } + column = (column_t *)((UINT8 *)column + column->length + 4); } } @@ -512,22 +525,21 @@ angle_t R_RotationAngle(angle_t ang, angle_t camang, interpmobjstate_t *interp) FixedMul(FINESINE((camang) >> ANGLETOFINESHIFT), interp->slopepitch); } -patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, boolean adjustfeet, void *info, INT32 rotationangle) +patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle) { rotsprite_t *rotsprite; spriteinfo_t *sprinfo = (spriteinfo_t *)info; INT32 idx = rotationangle; - UINT8 type = (adjustfeet ? 1 : 0); if (rotationangle < 1 || rotationangle >= ROTANGLES) return NULL; - rotsprite = sprite->rotated[type][spriteangle]; + rotsprite = sprite->rotated[spriteangle]; if (rotsprite == NULL) { rotsprite = RotatedPatch_Create(ROTANGLES); - sprite->rotated[type][spriteangle] = rotsprite; + sprite->rotated[spriteangle] = rotsprite; } if (flip) @@ -542,7 +554,7 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri if (lump == LUMPERROR) return NULL; - patch = (patch_t *)W_CacheLumpNum(lump, PU_STATIC); + patch = (patch_t *)W_CacheLumpNum(lump, PU_CACHE); // PU_LEVEL if (sprinfo->available) { @@ -556,13 +568,6 @@ patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spri } RotatedPatch_DoRotation(rotsprite, patch, rotationangle, xpivot, ypivot, flip); - - //BP: we cannot use special tric in hardware mode because feet in ground caused by z-buffer - if (adjustfeet) - ((patch_t *)rotsprite->patches[idx])->topoffset += FEETADJUST>>FRACBITS; - - // free image data - Z_Free(patch); } return rotsprite->patches[idx]; @@ -576,6 +581,7 @@ rotsprite_t *RotatedPatch_Create(INT32 numangles) return rotsprite; } + static void RotatedPatch_CalculateDimensions( INT32 width, INT32 height, fixed_t ca, fixed_t sa, @@ -601,6 +607,7 @@ static void RotatedPatch_CalculateDimensions( void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip) { UINT32 i; + patch_t *rotated; UINT16 *rawdst, *rawconv; @@ -657,7 +664,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle size = (newwidth * newheight); if (!size) size = (width * height); - rawdst = Z_Calloc(size * sizeof(UINT16), PU_STATIC, NULL); + rawdst = Z_Malloc(size * sizeof(UINT16), PU_STATIC, NULL); for (i = 0; i < size; i++) rawdst[i] = 0xFF00; @@ -673,9 +680,20 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle sx >>= FRACBITS; sy >>= FRACBITS; - + if (sx >= 0 && sy >= 0 && sx < width && sy < height) - rawdst[(dy*newwidth)+dx] = GetPatchPixel(patch, sx, sy, bflip); + { + rawdst[(dy * newwidth) + dx] = GetPatchPixel(patch, sx, sy, bflip); + + if (dx < minx) + minx = dx; + if (dy < miny) + miny = dy; + if (dx > maxx) + maxx = dx; + if (dy > maxy) + maxy = dy; + } } } @@ -713,7 +731,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle width = newwidth; height = newheight; } - + // make patch rotated = (patch_t *)R_MaskedFlatToPatch(rawconv, width, height, 0, 0, &size); diff --git a/src/r_patch.h b/src/r_patch.h index 447f1b4fc..75347df3c 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -40,7 +40,6 @@ typedef struct // Conversions between patches / flats / textures... boolean R_CheckIfPatch(lumpnum_t lump); -void *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); // SpriteInfo extern spriteinfo_t spriteinfo[NUMSPRITES]; @@ -52,11 +51,7 @@ void R_ParseSPRTINFOLump(UINT16 wadNum, UINT16 lumpNum); INT32 R_GetRollAngle(angle_t rollangle); angle_t R_RotationAngle(angle_t ang, angle_t camang, interpmobjstate_t *interp); -patch_t *Patch_GetRotatedSprite( - spriteframe_t *sprite, - size_t frame, size_t spriteangle, - boolean flip, boolean adjustfeet, - void *info, INT32 rotationangle); +patch_t *Patch_GetRotatedSprite(spriteframe_t *sprite, size_t frame, size_t spriteangle, boolean flip, void *info, INT32 rotationangle); rotsprite_t *RotatedPatch_Create(INT32 numangles); void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle, INT32 xpivot, INT32 ypivot, boolean flip); diff --git a/src/r_plane.c b/src/r_plane.c index c2bae83f3..d4e9c92ff 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -350,7 +350,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, ffloor_t *pfloor , polyobj_t *polyobj , pslope_t *slope - , boolean noencore) + , boolean noencore + , boolean reverseLight, const sector_t *lighting_sector) { visplane_t *check; unsigned hash; @@ -387,9 +388,16 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, } } - if (slope != NULL) + if (slope != NULL && P_ApplyLightOffset(lightlevel >> LIGHTSEGSHIFT, lighting_sector)) { - lightlevel += slope->lightOffset * 8; + if (reverseLight) + { + lightlevel -= slope->lightOffset * 8; + } + else + { + lightlevel += slope->lightOffset * 8; + } } // This appears to fix the Nimbus Ruins sky bug. @@ -689,7 +697,7 @@ void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planev vy = FIXED_TO_FLOAT(planeviewy-planeyoffset); vz = FIXED_TO_FLOAT(planeviewz); - temp = P_GetZAt(slope, planeviewx, planeviewy); + temp = P_GetSlopeZAt(slope, planeviewx, planeviewy); zeroheight = FIXED_TO_FLOAT(temp); // p is the texture origin in view space @@ -698,7 +706,7 @@ void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planev ang = ANG2RAD(ANGLE_270 - planeviewangle); p.x = vx * cos(ang) - vy * sin(ang); p.z = vx * sin(ang) + vy * cos(ang); - temp = P_GetZAt(slope, -planexoffset, planeyoffset); + temp = P_GetSlopeZAt(slope, -planexoffset, planeyoffset); p.y = FIXED_TO_FLOAT(temp) - vz; // m is the v direction vector in view space @@ -711,9 +719,9 @@ void R_CalculateSlopeVectors(pslope_t *slope, fixed_t planeviewx, fixed_t planev n.z = -xscale * cos(ang); ang = ANG2RAD(planeangle); - temp = P_GetZAt(slope, planeviewx + FLOAT_TO_FIXED(yscale * sin(ang)), planeviewy + FLOAT_TO_FIXED(yscale * cos(ang))); + temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(yscale * sin(ang)), planeviewy + FLOAT_TO_FIXED(yscale * cos(ang))); m.y = FIXED_TO_FLOAT(temp) - zeroheight; - temp = P_GetZAt(slope, planeviewx + FLOAT_TO_FIXED(xscale * cos(ang)), planeviewy - FLOAT_TO_FIXED(xscale * sin(ang))); + temp = P_GetSlopeZAt(slope, planeviewx + FLOAT_TO_FIXED(xscale * cos(ang)), planeviewy - FLOAT_TO_FIXED(xscale * sin(ang))); n.y = FIXED_TO_FLOAT(temp) - zeroheight; m.x /= fudge; @@ -1046,7 +1054,7 @@ void R_DrawSinglePlane(visplane_t *pl) #ifndef NOWATER if (planeripple.active) { - fixed_t plheight = abs(P_GetZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); + fixed_t plheight = abs(P_GetSlopeZAt(pl->slope, pl->viewx, pl->viewy) - pl->viewz); R_PlaneBounds(pl); diff --git a/src/r_plane.h b/src/r_plane.h index 21607cf00..5f0db2c7c 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -87,7 +87,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t extracolormap_t *planecolormap, ffloor_t *ffloor , polyobj_t *polyobj , pslope_t *slope - , boolean noencore); + , boolean noencore + , boolean reverseLight, const sector_t *lighting_sector); visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop); void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop); void R_PlaneBounds(visplane_t *plane); diff --git a/src/r_segs.c b/src/r_segs.c index b8e60ed7e..a1d3b626e 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -23,6 +23,7 @@ #include "d_netcmd.h" #include "m_misc.h" #include "p_local.h" // Camera... +#include "p_setup.h" #include "p_slopes.h" #include "console.h" // con_clipviewtop @@ -247,14 +248,13 @@ static void R_DrawWallSplats(void) // way we don't have to store extra post_t info with each column for // multi-patch textures. They are not normally needed as multi-patch // textures don't have holes in it. At least not for now. -static INT32 column2s_length; // column->length : for multi-patch on 2sided wall = texture->height static void R_Render2sidedMultiPatchColumn(column_t *column) { INT32 topscreen, bottomscreen; topscreen = sprtopscreen; // + spryscale*column->topdelta; topdelta is 0 for the wall - bottomscreen = topscreen + spryscale * column2s_length; + bottomscreen = topscreen + spryscale * lengthcol; dc_yl = (sprtopscreen+FRACUNIT-1)>>FRACBITS; dc_yh = (bottomscreen-1)>>FRACBITS; @@ -276,7 +276,7 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) if (dc_yl <= dc_yh && dc_yh < vid.height && dc_yh > 0) { dc_source = (UINT8 *)column + 3; - dc_sourcelength = column2s_length; + dc_sourcelength = lengthcol; if (colfunc == wallcolfunc) twosmultipatchfunc(); @@ -289,24 +289,7 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) transnum_t R_GetLinedefTransTable(fixed_t alpha) { - if (alpha < 9830) - return tr_trans90; - else if (alpha < 16384) - return tr_trans80; - else if (alpha < 22937) - return tr_trans70; - else if (alpha < 29491) - return tr_trans60; - else if (alpha < 36044) - return tr_trans50; - else if (alpha < 42598) - return tr_trans40; - else if (alpha < 49152) - return tr_trans30; - else if (alpha < 55705) - return tr_trans20; - else - return tr_trans10; + return (20*(FRACUNIT - alpha - 1) + FRACUNIT) >> (FRACBITS+1); } void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) @@ -339,7 +322,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (!ldef->alpha) return; - + if (ldef->blendmode) { if (ldef->alpha == NUMTRANSMAPS || ldef->blendmode == AST_MODULATE) @@ -350,7 +333,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } else if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) { - dc_transmap = transtables + ((R_GetLinedefTransTable(ldef->alpha) - 1) << FF_TRANSSHIFT); + dc_transmap = R_GetTranslucencyTable(R_GetLinedefTransTable(ldef->alpha)); colfunc = fuzzcolfunc; } else if (ldef->special == 909) @@ -387,7 +370,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) else { colfunc_2s = R_Render2sidedMultiPatchColumn; // render multipatch with no holes (no post_t info) - column2s_length = textures[texnum]->height; + lengthcol = textures[texnum]->height; } // Setup lighting based on the presence/lack-of 3D floors. @@ -406,11 +389,9 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) fixed_t leftheight, rightheight; light = &frontsector->lightlist[i]; rlight = &dc_lightlist[i]; - if (light->slope) { - leftheight = P_GetZAt(light->slope, ds->leftpos.x, ds->leftpos.y); - rightheight = P_GetZAt(light->slope, ds->rightpos.x, ds->rightpos.y); - } else - leftheight = rightheight = light->height; + + leftheight = P_GetLightZAt(light, ds-> leftpos.x, ds-> leftpos.y); + rightheight = P_GetLightZAt(light, ds->rightpos.x, ds->rightpos.y); leftheight -= viewz; rightheight -= viewz; @@ -418,8 +399,6 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1); rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); rlight->heightstep = (rlight->heightstep-rlight->height)/(range); - //if (x1 > ds->x1) - //rlight->height -= (x1 - ds->x1)*rlight->heightstep; rlight->startheight = rlight->height; // keep starting value here to reset for each repeat rlight->lightlevel = *light->lightlevel; rlight->extra_colormap = light->extra_colormap; @@ -434,7 +413,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (rlight->extra_colormap && rlight->extra_colormap->fog) ; - else + else if (P_ApplyLightOffset(lightnum, frontsector)) lightnum += curline->lightOffset; rlight->lightnum = lightnum; @@ -455,7 +434,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (colfunc == R_DrawFogColumn_8 || (frontsector->extra_colormap && frontsector->extra_colormap->fog)) ; - else + else if (P_ApplyLightOffset(lightnum, frontsector)) lightnum += curline->lightOffset; if (lightnum < 0) @@ -645,7 +624,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) // draw the texture col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc_x]) - 3); - + colfunc_2s(col); } spryscale += rw_scalestep; @@ -779,11 +758,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) rlight = &dc_lightlist[p]; #define SLOPEPARAMS(slope, end1, end2, normalheight) \ - if (slope) { \ - end1 = P_GetZAt(slope, ds->leftpos.x, ds->leftpos.y); \ - end2 = P_GetZAt(slope, ds->rightpos.x, ds->rightpos.y); \ - } else \ - end1 = end2 = normalheight; + end1 = P_GetZAt(slope, ds->leftpos.x, ds->leftpos.y, normalheight); \ + end2 = P_GetZAt(slope, ds->rightpos.x, ds->rightpos.y, normalheight); SLOPEPARAMS(light->slope, leftheight, rightheight, light->height) SLOPEPARAMS(*pfloor->b_slope, pfloorleft, pfloorright, *pfloor->bottomheight) @@ -796,8 +772,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (leftheight > pfloorleft && rightheight > pfloorright && i+1 < dc_numlights) { lightlist_t *nextlight = &frontsector->lightlist[i+1]; - if ((nextlight->slope ? P_GetZAt(nextlight->slope, ds->leftpos.x, ds->leftpos.y) : nextlight->height) > pfloorleft - && (nextlight->slope ? P_GetZAt(nextlight->slope, ds->rightpos.x, ds->rightpos.y) : nextlight->height) > pfloorright) + if ((P_GetLightZAt(nextlight, ds->leftpos.x, ds->leftpos.y) > pfloorleft) + && (P_GetLightZAt(nextlight, ds->rightpos.x, ds->rightpos.y) > pfloorright)) continue; } @@ -849,7 +825,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (pfloor->flags & FF_FOG || rlight->flags & FF_FOG || (rlight->extra_colormap && rlight->extra_colormap->fog)) ; - else + else if (P_ApplyLightOffset(rlight->lightnum, frontsector)) rlight->lightnum += curline->lightOffset; p++; @@ -872,7 +848,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (pfloor->flags & FF_FOG || (frontsector->extra_colormap && frontsector->extra_colormap->fog)) ; - else + else if (P_ApplyLightOffset(lightnum, frontsector)) lightnum += curline->lightOffset; if (lightnum < 0) @@ -890,16 +866,11 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) dc_texheight = textureheight[texnum]>>FRACBITS; // calculate both left ends - if (*pfloor->t_slope) - left_top = P_GetZAt(*pfloor->t_slope, ds->leftpos.x, ds->leftpos.y) - viewz; - else - left_top = *pfloor->topheight - viewz; + left_top = P_GetFFloorTopZAt (pfloor, ds->leftpos.x, ds->leftpos.y) - viewz; + left_bottom = P_GetFFloorBottomZAt(pfloor, ds->leftpos.x, ds->leftpos.y) - viewz; - if (*pfloor->b_slope) - left_bottom = P_GetZAt(*pfloor->b_slope, ds->leftpos.x, ds->leftpos.y) - viewz; - else - left_bottom = *pfloor->bottomheight - viewz; skewslope = *pfloor->t_slope; // skew using top slope by default + if (newline) { if (newline->flags & ML_DONTPEGTOP) @@ -958,7 +929,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) else { colfunc_2s = R_Render2sidedMultiPatchColumn; //render multipatch with no holes (no post_t info) - column2s_length = textures[texnum]->height; + lengthcol = textures[texnum]->height; } // Set heights according to plane, or slope, whichever @@ -966,15 +937,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) fixed_t right_top, right_bottom; // calculate right ends now - if (*pfloor->t_slope) - right_top = P_GetZAt(*pfloor->t_slope, ds->rightpos.x, ds->rightpos.y) - viewz; - else - right_top = *pfloor->topheight - viewz; - - if (*pfloor->b_slope) - right_bottom = P_GetZAt(*pfloor->b_slope, ds->rightpos.x, ds->rightpos.y) - viewz; - else - right_bottom = *pfloor->bottomheight - viewz; + right_top = P_GetFFloorTopZAt (pfloor, ds->rightpos.x, ds->rightpos.y) - viewz; + right_bottom = P_GetFFloorBottomZAt(pfloor, ds->rightpos.x, ds->rightpos.y) - viewz; // using INT64 to avoid 32bit overflow top_frac = (INT64)centeryfrac - (((INT64)left_top * ds->scale1) >> FRACBITS); @@ -1198,6 +1162,18 @@ static boolean R_FFloorCanClip(visffloor_t *pfloor) return (cv_ffloorclip.value && !R_IsFFloorTranslucent(pfloor) && !pfloor->polyobj); } +// R_ExpandPlaneY +// +// A simple function to modify a vsplane's top and bottom for a particular column +// Sort of like R_ExpandPlane in r_plane.c, except this is vertical expansion +static inline void R_ExpandPlaneY(visplane_t *pl, INT32 x, INT16 top, INT16 bottom) +{ + // Expand the plane, don't shrink it! + // note: top and bottom default to 0xFFFF and 0x0000 respectively, which is totally compatible with this + if (pl->top[x] > top) pl->top[x] = top; + if (pl->bottom[x] < bottom) pl->bottom[x] = bottom; +} + // // R_RenderSegLoop // Draws zero, one, or two textures (and possibly a masked @@ -1237,15 +1213,11 @@ static void R_RenderSegLoop (void) if (markceiling) { - bottom = yl-1; + bottom = yl > floorclip[rw_x] ? floorclip[rw_x] : yl; - if (bottom >= floorclip[rw_x]) - bottom = floorclip[rw_x]-1; - - if (top <= bottom && ceilingplane) + if (top <= --bottom && ceilingplane) { - ceilingplane->top[rw_x] = (INT16)top; - ceilingplane->bottom[rw_x] = (INT16)bottom; + R_ExpandPlaneY(ceilingplane, rw_x, top, bottom); } } @@ -1262,8 +1234,7 @@ static void R_RenderSegLoop (void) if (++top <= bottom && floorplane) { - floorplane->top[rw_x] = (INT16)top; - floorplane->bottom[rw_x] = (INT16)bottom; + R_ExpandPlaneY(floorplane, rw_x, top, bottom); } } @@ -1283,14 +1254,6 @@ static void R_RenderSegLoop (void) if (ffloor[i].polyobj && (!curline->polyseg || ffloor[i].polyobj != curline->polyseg)) continue; - // FIXME hack to fix planes disappearing when a seg goes behind the camera. This NEEDS to be changed to be done properly. -Red - if (curline->polyseg) { - if (ffloor[i].plane->minx > rw_x) - ffloor[i].plane->minx = rw_x; - else if (ffloor[i].plane->maxx < rw_x) - ffloor[i].plane->maxx = rw_x; - } - if (ffloor[i].height < viewz) { INT32 top_w = (ffloor[i].f_frac >> HEIGHTBITS) + 1; @@ -1303,7 +1266,7 @@ static void R_RenderSegLoop (void) bottom_w = bottom; // Polyobject-specific hack to fix plane leaking -Red - if (curline->polyseg && ffloor[i].polyobj && ffloor[i].polyobj == curline->polyseg && top_w >= bottom_w) { + if (ffloor[i].polyobj && top_w >= bottom_w) { ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; } else @@ -1347,7 +1310,7 @@ static void R_RenderSegLoop (void) bottom_w = bottom; // Polyobject-specific hack to fix plane leaking -Red - if (curline->polyseg && ffloor[i].polyobj && ffloor[i].polyobj == curline->polyseg && top_w >= bottom_w) { + if (ffloor[i].polyobj && top_w >= bottom_w) { ffloor[i].plane->top[rw_x] = ffloor[i].plane->bottom[rw_x] = 0xFFFF; } else @@ -1427,7 +1390,7 @@ static void R_RenderSegLoop (void) if (dc_lightlist[i].extra_colormap) ; - else + else if (P_ApplyLightOffset(lightnum, curline->frontsector)) lightnum += curline->lightOffset; if (lightnum < 0) @@ -1598,7 +1561,7 @@ static void R_RenderSegLoop (void) { if (curline->polyseg && (ffloor[i].polyobj != curline->polyseg)) continue; - + ffloor[i].f_clip[rw_x] = ffloor[i].c_clip[rw_x] = (INT16)((ffloor[i].b_frac >> HEIGHTBITS) & 0xFFFF); ffloor[i].b_frac += ffloor[i].b_step; } @@ -1607,7 +1570,7 @@ static void R_RenderSegLoop (void) topfrac += topstep; bottomfrac += bottomstep; } - + //colfunc = wallcolfunc; } @@ -1707,7 +1670,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) while (need > maxopenings); openings = Z_Realloc(openings, maxopenings * sizeof (*openings), PU_STATIC, NULL); lastopening = openings + pos; - + if (oldopenings == NULL) return; @@ -1817,22 +1780,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) } - if (frontsector->c_slope) { - worldtop = P_GetZAt(frontsector->c_slope, segleft.x, segleft.y) - viewz; - worldtopslope = P_GetZAt(frontsector->c_slope, segright.x, segright.y) - viewz; - } else { - worldtopslope = - worldtop = frontsector->ceilingheight - viewz; - } +#define SLOPEPARAMS(slope, end1, end2, normalheight) \ + end1 = P_GetZAt(slope, segleft.x, segleft.y, normalheight); \ + end2 = P_GetZAt(slope, segright.x, segright.y, normalheight); - - if (frontsector->f_slope) { - worldbottom = P_GetZAt(frontsector->f_slope, segleft.x, segleft.y) - viewz; - worldbottomslope = P_GetZAt(frontsector->f_slope, segright.x, segright.y) - viewz; - } else { - worldbottomslope = - worldbottom = frontsector->floorheight - viewz; - } + SLOPEPARAMS(frontsector->c_slope, worldtop, worldtopslope, frontsector->ceilingheight) + SLOPEPARAMS(frontsector->f_slope, worldbottom, worldbottomslope, frontsector->floorheight) + // subtract viewz from these to turn them into + // positions relative to the camera's z position + worldtop -= viewz; + worldtopslope -= viewz; + worldbottom -= viewz; + worldbottomslope -= viewz; midtexture = toptexture = bottomtexture = maskedtexture = 0; ds_p->maskedtexturecol = NULL; @@ -1852,12 +1811,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (ffloor[i].polyobj && (!ds_p->curline->polyseg || ffloor[i].polyobj != ds_p->curline->polyseg)) continue; - if (ffloor[i].slope) { - ffloor[i].f_pos = P_GetZAt(ffloor[i].slope, segleft.x, segleft.y) - viewz; - ffloor[i].f_pos_slope = P_GetZAt(ffloor[i].slope, segright.x, segright.y) - viewz; - } else - ffloor[i].f_pos_slope = - ffloor[i].f_pos = ffloor[i].height - viewz; + ffloor[i].f_pos = P_GetZAt(ffloor[i].slope, segleft .x, segleft .y, ffloor[i].height) - viewz; + ffloor[i].f_pos_slope = P_GetZAt(ffloor[i].slope, segright.x, segright.y, ffloor[i].height) - viewz; } } @@ -1916,26 +1871,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) else { // two sided line - - if (backsector->c_slope) { - worldhigh = P_GetZAt(backsector->c_slope, segleft.x, segleft.y) - viewz; - worldhighslope = P_GetZAt(backsector->c_slope, segright.x, segright.y) - viewz; - } else { - worldhighslope = - worldhigh = backsector->ceilingheight - viewz; - } - - - if (backsector->f_slope) { - worldlow = P_GetZAt(backsector->f_slope, segleft.x, segleft.y) - viewz; - worldlowslope = P_GetZAt(backsector->f_slope, segright.x, segright.y) - viewz; - } else { - worldlowslope = - worldlow = backsector->floorheight - viewz; - } - + SLOPEPARAMS(backsector->c_slope, worldhigh, worldhighslope, backsector->ceilingheight) + SLOPEPARAMS(backsector->f_slope, worldlow, worldlowslope, backsector->floorheight) + worldhigh -= viewz; + worldhighslope -= viewz; + worldlow -= viewz; + worldlowslope -= viewz; // hack to allow height changes in outdoor areas + // This is what gets rid of the upper textures if there should be sky if (frontsector->ceilingpic == skyflatnum && backsector->ceilingpic == skyflatnum) { @@ -1949,12 +1893,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (worldbottomslope > worldlowslope || worldbottom > worldlow) { ds_p->silhouette = SIL_BOTTOM; - if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz) + if (P_GetSectorFloorZAt(backsector, viewx, viewy) > viewz) ds_p->bsilheight = INT32_MAX; else ds_p->bsilheight = (frontsector->f_slope ? INT32_MAX : frontsector->floorheight); } - else if ((backsector->f_slope ? P_GetZAt(backsector->f_slope, viewx, viewy) : backsector->floorheight) > viewz) + else if (P_GetSectorFloorZAt(backsector, viewx, viewy) > viewz) { ds_p->silhouette = SIL_BOTTOM; ds_p->bsilheight = INT32_MAX; @@ -1964,16 +1908,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (worldtopslope < worldhighslope || worldtop < worldhigh) { ds_p->silhouette |= SIL_TOP; - if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz) + if (P_GetSectorCeilingZAt(backsector, viewx, viewy) < viewz) ds_p->tsilheight = INT32_MIN; else ds_p->tsilheight = (frontsector->c_slope ? INT32_MIN : frontsector->ceilingheight); } - else if ((backsector->c_slope ? P_GetZAt(backsector->c_slope, viewx, viewy) : backsector->ceilingheight) < viewz) + else if (P_GetSectorCeilingZAt(backsector, viewx, viewy) < viewz) { ds_p->silhouette |= SIL_TOP; ds_p->tsilheight = INT32_MIN; - // ds_p->sprtopclip = screenheightarray; } if (viewsector != frontsector && viewsector != backsector) @@ -2071,13 +2014,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) toptexture = R_GetTextureNum(sidedef->toptexture); texheight = textureheight[toptexture]; } - if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked + + if (!(linedef->flags & ML_EFFECT1)) // Ignore slopes for lower/upper textures unless flag is checked + { if (linedef->flags & ML_DONTPEGTOP) rw_toptexturemid = frontsector->ceilingheight - viewz; else rw_toptexturemid = backsector->ceilingheight - viewz; - } else - if (linedef->flags & ML_DONTPEGTOP) + } + else if (linedef->flags & ML_DONTPEGTOP) { // top of texture at top rw_toptexturemid = worldtop; @@ -2095,20 +2040,22 @@ void R_StoreWallRange(INT32 start, INT32 stop) // bottom texture bottomtexture = R_GetTextureNum(sidedef->bottomtexture); - if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked + if (!(linedef->flags & ML_EFFECT1)) // Ignore slopes for lower/upper textures unless flag is checked + { if (linedef->flags & ML_DONTPEGBOTTOM) rw_bottomtexturemid = frontsector->floorheight - viewz; else rw_bottomtexturemid = backsector->floorheight - viewz; - } else - if (linedef->flags & ML_DONTPEGBOTTOM) + } + else if (linedef->flags & ML_DONTPEGBOTTOM) { // bottom of texture at bottom // top of texture at top rw_bottomtexturemid = worldbottom; rw_bottomtextureslide = floorfrontslide; } - else { // top of texture at top + else // top of texture at top + { rw_bottomtexturemid = worldlow; rw_bottomtextureslide = floorbackslide; } @@ -2141,6 +2088,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (frontsector->ffloors && backsector->ffloors) { i = 0; + for (rover = backsector->ffloors; rover && i < MAXFFLOORS; rover = rover->next) { if (!(rover->flags & FF_RENDERSIDES) || !(rover->flags & FF_EXISTS)) @@ -2151,16 +2099,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (rover->norender == leveltime) continue; - if (*rover->t_slope) { - high1 = P_GetZAt(*rover->t_slope, segleft.x, segleft.y); - highslope1 = P_GetZAt(*rover->t_slope, segright.x, segright.y); - } else - high1 = highslope1 = *rover->topheight; - if (*rover->b_slope) { - low1 = P_GetZAt(*rover->b_slope, segleft.x, segleft.y); - lowslope1 = P_GetZAt(*rover->b_slope, segright.x, segright.y); - } else - low1 = lowslope1 = *rover->bottomheight; + SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) + SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; @@ -2187,16 +2127,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; } - if (*r2->t_slope) { - high2 = P_GetZAt(*r2->t_slope, segleft.x, segleft.y); - highslope2 = P_GetZAt(*r2->t_slope, segright.x, segright.y); - } else - high2 = highslope2 = *r2->topheight; - if (*r2->b_slope) { - low2 = P_GetZAt(*r2->b_slope, segleft.x, segleft.y); - lowslope2 = P_GetZAt(*r2->b_slope, segright.x, segright.y); - } else - low2 = lowslope2 = *r2->bottomheight; + SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) + SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) continue; @@ -2205,6 +2137,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) break; } + if (r2) continue; @@ -2222,16 +2155,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (rover->norender == leveltime) continue; - if (*rover->t_slope) { - high1 = P_GetZAt(*rover->t_slope, segleft.x, segleft.y); - highslope1 = P_GetZAt(*rover->t_slope, segright.x, segright.y); - } else - high1 = highslope1 = *rover->topheight; - if (*rover->b_slope) { - low1 = P_GetZAt(*rover->b_slope, segleft.x, segleft.y); - lowslope1 = P_GetZAt(*rover->b_slope, segright.x, segright.y); - } else - low1 = lowslope1 = *rover->bottomheight; + SLOPEPARAMS(*rover->t_slope, high1, highslope1, *rover->topheight) + SLOPEPARAMS(*rover->b_slope, low1, lowslope1, *rover->bottomheight) if ((high1 < lowcut && highslope1 < lowcutslope) || (low1 > highcut && lowslope1 > highcutslope)) continue; @@ -2258,16 +2183,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; } - if (*r2->t_slope) { - high2 = P_GetZAt(*r2->t_slope, segleft.x, segleft.y); - highslope2 = P_GetZAt(*r2->t_slope, segright.x, segright.y); - } else - high2 = highslope2 = *r2->topheight; - if (*r2->b_slope) { - low2 = P_GetZAt(*r2->b_slope, segleft.x, segleft.y); - lowslope2 = P_GetZAt(*r2->b_slope, segright.x, segright.y); - } else - low2 = lowslope2 = *r2->bottomheight; + SLOPEPARAMS(*r2->t_slope, high2, highslope2, *r2->topheight) + SLOPEPARAMS(*r2->b_slope, low2, lowslope2, *r2->bottomheight) if ((high2 < lowcut || highslope2 < lowcutslope) || (low2 > highcut || lowslope2 > highcutslope)) continue; @@ -2293,10 +2210,10 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; // Oy vey. - if (( (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) <= worldbottom+viewz - && (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) <= worldbottomslope+viewz) - ||((*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) >= worldtop+viewz - && (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) >= worldtopslope+viewz)) + if ( ((P_GetFFloorTopZAt (rover, segleft .x, segleft .y)) <= worldbottom + viewz + && (P_GetFFloorTopZAt (rover, segright.x, segright.y)) <= worldbottomslope + viewz) + ||((P_GetFFloorBottomZAt(rover, segleft .x, segleft .y)) >= worldtop + viewz + && (P_GetFFloorBottomZAt(rover, segright.x, segright.y)) >= worldtopslope + viewz)) continue; ds_p->thicksides[i] = rover; @@ -2311,17 +2228,18 @@ void R_StoreWallRange(INT32 start, INT32 stop) continue; if (rover->norender == leveltime) continue; + // Oy vey. - if (( (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) <= worldbottom+viewz - && (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) <= worldbottomslope+viewz) - ||((*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) >= worldtop+viewz - && (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) >= worldtopslope+viewz)) + if ( (P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= worldbottom + viewz + && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= worldbottomslope + viewz) + ||(P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) >= worldtop + viewz + && P_GetFFloorBottomZAt(rover, segright.x, segright.y) >= worldtopslope + viewz)) continue; - if (( (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) <= worldlow+viewz - && (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) <= worldlowslope+viewz) - ||((*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) >= worldhigh+viewz - && (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) >= worldhighslope+viewz)) + if ( (P_GetFFloorTopZAt (rover, segleft .x, segleft .y) <= worldlow + viewz + && P_GetFFloorTopZAt (rover, segright.x, segright.y) <= worldlowslope + viewz) + ||(P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) >= worldhigh + viewz + && P_GetFFloorBottomZAt(rover, segright.x, segright.y) >= worldhighslope + viewz)) continue; ds_p->thicksides[i] = rover; @@ -2331,6 +2249,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ds_p->numthicksides = numthicksides = i; } + if (sidedef->midtexture > 0 && sidedef->midtexture < numtextures) { // masked midtexture @@ -2347,6 +2266,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (curline->polyseg) // use REAL front and back floors please, so midtexture rendering isn't mucked up { rw_midtextureslide = rw_midtexturebackslide = 0; + if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) rw_midtexturemid = rw_midtextureback = max(curline->frontsector->floorheight, curline->backsector->floorheight) - viewz; else @@ -2358,6 +2278,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (linedef->flags & ML_EFFECT2) // Ignore slopes when texturing { rw_midtextureslide = rw_midtexturebackslide = 0; + if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) rw_midtexturemid = rw_midtextureback = max(frontsector->floorheight, backsector->floorheight) - viewz; else @@ -2426,7 +2347,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) // OPTIMIZE: get rid of LIGHTSEGSHIFT globally lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); - lightnum += curline->lightOffset; + if (P_ApplyLightOffset(lightnum, frontsector)) + lightnum += curline->lightOffset; if (lightnum < 0) walllights = scalelight[0]; @@ -2441,18 +2363,13 @@ void R_StoreWallRange(INT32 start, INT32 stop) // and doesn't need to be marked. if (frontsector->heightsec == -1) { - if (( - frontsector->f_slope ? P_GetZAt(frontsector->f_slope, viewx, viewy) : - frontsector->floorheight) >= viewz) + if (P_GetSectorFloorZAt(frontsector, viewx, viewy) >= viewz) { // above view plane markfloor = false; } - if (( - frontsector->c_slope ? P_GetZAt(frontsector->c_slope, viewx, viewy) : - frontsector->ceilingheight) <= viewz && - frontsector->ceilingpic != skyflatnum) + if (frontsector->ceilingpic != skyflatnum && P_GetSectorCeilingZAt(frontsector, viewx, viewy) <= viewz) { // below view plane markceiling = false; @@ -2465,7 +2382,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) worldtopslope >>= 4; worldbottomslope >>= 4; - if (linedef->special == 41) // HORIZON LINES + if (linedef->special == HORIZONSPECIAL) // HORIZON LINES { topstep = bottomstep = 0; topfrac = bottomfrac = (centeryfrac>>4); @@ -2509,14 +2426,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) light = &frontsector->lightlist[i]; rlight = &dc_lightlist[p]; - if (light->slope) { - leftheight = P_GetZAt(light->slope, segleft.x, segleft.y); - rightheight = P_GetZAt(light->slope, segright.x, segright.y); + leftheight = P_GetLightZAt(light, segleft.x, segleft.y); + rightheight = P_GetLightZAt(light, segright.x, segright.y); - // Flag sector as having slopes + // Flag sector as having slopes + if (light->slope) frontsector->hasslope = true; - } else - leftheight = rightheight = light->height; leftheight -= viewz; rightheight -= viewz; @@ -2540,14 +2455,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (light->caster && light->caster->flags & FF_CUTSOLIDS) { - if (*light->caster->b_slope) { - leftheight = P_GetZAt(*light->caster->b_slope, segleft.x, segleft.y); - rightheight = P_GetZAt(*light->caster->b_slope, segright.x, segright.y); + leftheight = P_GetFFloorBottomZAt(light->caster, segleft.x, segleft.y); + rightheight = P_GetFFloorBottomZAt(light->caster, segright.x, segright.y); - // Flag sector as having slopes + // Flag sector as having slopes + if (*light->caster->b_slope) frontsector->hasslope = true; - } else - leftheight = rightheight = *light->caster->bottomheight; leftheight -= viewz; rightheight -= viewz; @@ -2575,7 +2488,8 @@ void R_StoreWallRange(INT32 start, INT32 stop) { ffloor[i].f_pos >>= 4; ffloor[i].f_pos_slope >>= 4; - if (linedef->special == 41) // Horizon lines extend FOFs in contact with them too. + + if (linedef->special == HORIZONSPECIAL) // Horizon lines extend FOFs in contact with them too. { ffloor[i].f_step = 0; ffloor[i].f_frac = (centeryfrac>>4); @@ -2639,9 +2553,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (*rover->b_slope || *rover->t_slope) backsector->hasslope = true; - roverleft = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; - roverright = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; - planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight); + roverleft = P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) - viewz; + roverright = P_GetFFloorBottomZAt(rover, segright.x, segright.y) - viewz; + planevistest = P_GetFFloorBottomZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2662,9 +2576,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (i >= MAXFFLOORS) break; - roverleft = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; - roverright = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; - planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight); + roverleft = P_GetFFloorTopZAt(rover, segleft .x, segleft .y) - viewz; + roverright = P_GetFFloorTopZAt(rover, segright.x, segright.y) - viewz; + planevistest = P_GetFFloorTopZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2696,9 +2610,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (*rover->b_slope || *rover->t_slope) frontsector->hasslope = true; - roverleft = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segleft.x, segleft.y) : *rover->bottomheight) - viewz; - roverright = (*rover->b_slope ? P_GetZAt(*rover->b_slope, segright.x, segright.y) : *rover->bottomheight) - viewz; - planevistest = (*rover->b_slope ? P_GetZAt(*rover->b_slope, viewx, viewy) : *rover->bottomheight); + roverleft = P_GetFFloorBottomZAt(rover, segleft .x, segleft .y) - viewz; + roverright = P_GetFFloorBottomZAt(rover, segright.x, segright.y) - viewz; + planevistest = P_GetFFloorBottomZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2719,9 +2633,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (i >= MAXFFLOORS) break; - roverleft = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segleft.x, segleft.y) : *rover->topheight) - viewz; - roverright = (*rover->t_slope ? P_GetZAt(*rover->t_slope, segright.x, segright.y) : *rover->topheight) - viewz; - planevistest = (*rover->t_slope ? P_GetZAt(*rover->t_slope, viewx, viewy) : *rover->topheight); + roverleft = P_GetFFloorTopZAt(rover, segleft .x, segleft .y) - viewz; + roverright = P_GetFFloorTopZAt(rover, segright.x, segright.y) - viewz; + planevistest = P_GetFFloorTopZAt(rover, viewx, viewy); if ((roverleft>>4 <= worldhigh || roverright>>4 <= worldhighslope) && (roverleft>>4 >= worldlow || roverright>>4 >= worldlowslope) && @@ -2740,9 +2654,12 @@ void R_StoreWallRange(INT32 start, INT32 stop) } } } + if (curline->polyseg && frontsector && (curline->polyseg->flags & POF_RENDERPLANES)) { - while (i < numffloors && ffloor[i].polyobj != curline->polyseg) i++; + while (i < numffloors && ffloor[i].polyobj != curline->polyseg) + i++; + if (i < numffloors && backsector->floorheight <= frontsector->ceilingheight && backsector->floorheight >= frontsector->floorheight && (viewz < backsector->floorheight)) @@ -2760,6 +2677,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) ffloor[i].b_frac = (centeryfrac >> 4) - FixedMul(ffloor[i].b_pos, rw_scale); i++; } + if (i < numffloors && backsector->ceilingheight >= frontsector->floorheight && backsector->ceilingheight <= frontsector->ceilingheight && (viewz > backsector->ceilingheight)) @@ -2831,8 +2749,24 @@ void R_StoreWallRange(INT32 start, INT32 stop) for (i = 0; i < numffloors; i++) R_ExpandPlane(ffloor[i].plane, rw_x, rw_stopx - 1); } + + // FIXME hack to fix planes disappearing when a seg goes behind the camera. This NEEDS to be changed to be done properly. -Red + if (curline->polyseg) + { + for (i = 0; i < numffloors; i++) + { + if (!ffloor[i].polyobj || ffloor[i].polyobj != curline->polyseg) + continue; + if (ffloor[i].plane->minx > rw_x) + ffloor[i].plane->minx = rw_x; + + if (ffloor[i].plane->maxx < rw_stopx - 1) + ffloor[i].plane->maxx = rw_stopx - 1; + } + } + } - + rw_silhouette = &(ds_p->silhouette); rw_tsilheight = &(ds_p->tsilheight); rw_bsilheight = &(ds_p->bsilheight); diff --git a/src/r_things.c b/src/r_things.c index 4235c81df..ddae1d7ec 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -27,6 +27,7 @@ #include "r_plane.h" #include "p_tick.h" #include "p_local.h" +#include "p_setup.h" #include "p_slopes.h" #include "dehacked.h" // get_number (for thok) #include "d_netfil.h" // blargh. for nameonly(). @@ -108,6 +109,13 @@ static drawseg_xrange_item_t *drawsegs_xrange; static size_t drawsegs_xrange_size = 0; static INT32 drawsegs_xrange_count = 0; +INT32 R_ThingLightLevel(mobj_t* thing) +{ + INT32 lightlevel = thing->lightlevel; + + return lightlevel; +} + // ========================================================================== // // Sprite loading routines: support sprites in pwad, dehacked sprite renaming, @@ -143,8 +151,7 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch #ifdef ROTSPRITE for (r = 0; r < 16; r++) { - sprtemp[frame].rotated[0][r] = NULL; - sprtemp[frame].rotated[1][r] = NULL; + sprtemp[frame].rotated[r] = NULL; } #endif/*ROTSPRITE*/ @@ -584,9 +591,6 @@ void R_DrawMaskedColumn(column_t *column) basetexturemid = dc_texturemid; - if (column == NULL) - return; - for (; column->topdelta != 0xff ;) { // calculate unclipped screen coordinates @@ -633,7 +637,7 @@ void R_DrawMaskedColumn(column_t *column) colfunc(); #ifdef PARANOIA else - I_Error("R_DrawMaskedColumn: Invalid ylookup for dc_yl %d", dc->yl); + I_Error("R_DrawMaskedColumn: Invalid ylookup for dc_yl %d", dc_yl); #endif } column = (column_t *)((UINT8 *)column + column->length + 4); @@ -681,7 +685,7 @@ static void R_DrawFlippedMaskedColumn(column_t *column) dc_yl = mceilingclip[dc_x]+1; if (dc_yl < 0) dc_yl = 0; - if (dc_yh >= vid.height) + if (dc_yh >= vid.height) // dc_yl must be < vid.height, so reduces number of checks in tight loop dc_yh = vid.height - 1; if (dc_yl <= dc_yh && dc_yh > 0 && column->length != 0) @@ -696,6 +700,10 @@ static void R_DrawFlippedMaskedColumn(column_t *column) // Still drawn by R_DrawColumn. if (ylookup[dc_yl]) colfunc(); +#ifdef PARANOIA + else + I_Error("R_DrawMaskedColumn: Invalid ylookup for dc_yl %d", dc_yl); +#endif Z_Free(dc_source); } column = (column_t *)((UINT8 *)column + column->length + 4); @@ -811,10 +819,8 @@ static void R_DrawVisSprite(vissprite_t *vis) frac = vis->startfrac; windowtop = windowbottom = sprbotscreen = INT32_MAX; - if (vis->mobj->localskin && ((skin_t *)vis->mobj->localskin)->flags & SF_HIRES) - this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->localskin)->highresscale); - else if (vis->mobj->skin && ((skin_t *)vis->mobj->skin)->flags & SF_HIRES) - this_scale = FixedMul(this_scale, ((skin_t *)vis->mobj->skin)->highresscale); + if ((vis->mobj->skin || vis->mobj->localskin) && K_GetMobjSkin(vis->mobj)->flags & SF_HIRES) + this_scale = FixedMul(this_scale, K_GetMobjSkin(vis->mobj)->highresscale); if (this_scale <= 0) this_scale = 1; @@ -853,6 +859,7 @@ static void R_DrawVisSprite(vissprite_t *vis) localcolfunc = (vis->vflip) ? R_DrawFlippedMaskedColumn : R_DrawMaskedColumn; lengthcol = SHORT(patch->height); + pwidth = SHORT(patch->width); // Split drawing loops for paper and non-paper to reduce conditional checks per sprite if (vis->scalestep) @@ -860,8 +867,6 @@ static void R_DrawVisSprite(vissprite_t *vis) fixed_t horzscale = FixedMul(vis->spritexscale, this_scale); fixed_t scalestep = FixedMul(vis->scalestep, vis->spriteyscale); - pwidth = SHORT(patch->width); - // Papersprite drawing loop for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, spryscale += scalestep) { @@ -885,9 +890,9 @@ static void R_DrawVisSprite(vissprite_t *vis) else { // Non-paper drawing loop - for (dc_x = vis->x1; dc_x <= vis->x2; dc_x++, frac += vis->xiscale) + for (dc_x = vis->x1; dc_x <= vis->x2 && (frac>>FRACBITS) < pwidth; dc_x++, frac += vis->xiscale) { - texturecolumn = CLAMP(frac >> FRACBITS, 0, SHORT(patch->width) - 1); + texturecolumn = CLAMP(frac >> FRACBITS, 0, pwidth - 1); column = (column_t *)((UINT8 *)patch + LONG(patch->columnofs[texturecolumn])); localcolfunc (column); @@ -979,13 +984,12 @@ static void R_SplitSprite(vissprite_t *sprite) for (i = 1; i < sector->numlights; i++) { - fixed_t testheight = sector->lightlist[i].height; + fixed_t testheight; if (!(sector->lightlist[i].caster->flags & FF_CUTSPRITES)) continue; - if (sector->lightlist[i].slope) - testheight = P_GetZAt(sector->lightlist[i].slope, sprite->gx, sprite->gy); + testheight = P_GetLightZAt(§or->lightlist[i], sprite->gx, sprite->gy); if (testheight >= sprite->gzt) continue; @@ -1113,6 +1117,26 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) #undef CHECKZ } +fixed_t R_GetSpriteDirectionalLighting(angle_t angle) +{ + // Copied from P_UpdateSegLightOffset + const UINT8 contrast = min(max(0, maplighting.contrast - maplighting.backlight), UINT8_MAX); + const fixed_t contrastFixed = ((fixed_t)contrast) * FRACUNIT; + + fixed_t light = FRACUNIT; + fixed_t extralight = 0; + + light = FixedMul(FINECOSINE(angle >> ANGLETOFINESHIFT), FINECOSINE(maplighting.angle >> ANGLETOFINESHIFT)) + + FixedMul(FINESINE(angle >> ANGLETOFINESHIFT), FINESINE(maplighting.angle >> ANGLETOFINESHIFT)); + light = (light + FRACUNIT) / 2; + + light = FixedMul(light, FRACUNIT - FSIN(abs(AngleDeltaSigned(angle, maplighting.angle)) / 2)); + + extralight = -contrastFixed + FixedMul(light, contrastFixed * 2); + + return extralight; +} + // // R_ProjectSprite // Generates a vissprite for a thing @@ -1121,7 +1145,6 @@ fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope) static void R_ProjectSprite(mobj_t *thing) { fixed_t tr_x, tr_y; - fixed_t gxt, gyt; fixed_t tx, tz; fixed_t xscale, yscale, sortscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! @@ -1151,11 +1174,14 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t offset, offset2; fixed_t paperoffset = 0, paperdistance = 0; angle_t centerangle = 0; + INT32 lightnum; + //SoM: 3/17/2000 fixed_t gz, gzt; INT32 heightsec, phs; INT32 dist = -1; INT32 light = 0; + lighttable_t **lights_array = spritelights; fixed_t this_scale; fixed_t spritexscale, spriteyscale; @@ -1198,25 +1224,23 @@ static void R_ProjectSprite(mobj_t *thing) this_scale = interp.scale; + if (this_scale < 1) + return; + // transform the origin point tr_x = interp.x - viewx; tr_y = interp.y - viewy; - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - - tz = gxt-gyt; + tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance // thing is behind view plane? if (!papersprite && (tz < FixedMul(MINZ, this_scale))) // papersprite clipping is handled later return; - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - tx = -(gyt + gxt); + tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // sideways distance // too far off the side? - if (!papersprite && abs(tx) > (INT64)tz<<2) // papersprite clipping is handled later + if (!papersprite && abs(tx) > tz<<2) // papersprite clipping is handled later return; // aspect ratio stuff @@ -1234,15 +1258,15 @@ static void R_ProjectSprite(mobj_t *thing) #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.roll || interp.pitch || interp.sloperoll || interp.slopepitch || thing->rollangle || sliprollrotate); + 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) { - sprdef = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->spritedef; + sprdef = &K_GetMobjSkin(thing)->spritedef; #ifdef ROTSPRITE - sprinfo = &((skin_t *)( (thing->localskin) ? thing->localskin : thing->skin ))->sprinfo; + sprinfo = &K_GetMobjSkin(thing)->sprinfo; #endif if (rot >= sprdef->numframes) @@ -1323,11 +1347,6 @@ static void R_ProjectSprite(mobj_t *thing) I_Assert(lump < max_spritelumps); - if (thing->localskin && ((skin_t *)thing->localskin)->flags & SF_HIRES) - this_scale = FixedMul(this_scale, ((skin_t *)thing->localskin)->highresscale); - else if (thing->skin && ((skin_t *)thing->skin)->flags & SF_HIRES) - this_scale = FixedMul(this_scale, ((skin_t *)thing->skin)->highresscale); - spr_width = spritecachedinfo[lump].width; spr_height = spritecachedinfo[lump].height; spr_offset = spritecachedinfo[lump].offset; @@ -1367,7 +1386,7 @@ static void R_ProjectSprite(mobj_t *thing) pitchnroll += rollangle; rollangle = R_GetRollAngle(pitchnroll); - rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, false, sprinfo, rollangle); + rotsprite = Patch_GetRotatedSprite(sprframe, (thing->frame & FF_FRAMEMASK), rot, flip, sprinfo, rollangle); if (rotsprite != NULL) { @@ -1389,6 +1408,14 @@ static void R_ProjectSprite(mobj_t *thing) // calculate edges of the shape spritexscale = interp.spritexscale; spriteyscale = interp.spriteyscale; + + if ((thing->skin || thing->localskin) && K_GetMobjSkin(thing)->flags & SF_HIRES) + { + fixed_t highresscale = ((skin_t *)thing->skin)->highresscale; + spritexscale = FixedMul(spritexscale, highresscale); + spriteyscale = FixedMul(spriteyscale, highresscale); + } + if (spritexscale < 1 || spriteyscale < 1) return; @@ -1419,16 +1446,9 @@ static void R_ProjectSprite(mobj_t *thing) tr_x += FixedMul(offset, cosmul); tr_y += FixedMul(offset, sinmul); - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - tz = gxt-gyt; - yscale = FixedDiv(projectiony, tz); + tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - tx = -(gyt + gxt); - xscale = FixedDiv(projection, tz); - x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; + tx = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); // Get paperoffset (offset) and paperoffset (distance) paperoffset = -FixedMul(tr_x, cosmul) - FixedMul(tr_y, sinmul); @@ -1442,17 +1462,9 @@ static void R_ProjectSprite(mobj_t *thing) tr_x += FixedMul(offset2, cosmul); tr_y += FixedMul(offset2, sinmul); - gxt = FixedMul(tr_x, viewcos); - gyt = -FixedMul(tr_y, viewsin); - tz2 = gxt-gyt; - yscale2 = FixedDiv(projectiony, tz2); - //if (yscale2 < 64) return; // ditto + tz2 = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); - gxt = -FixedMul(tr_x, viewsin); - gyt = FixedMul(tr_y, viewcos); - tx2 = -(gyt + gxt); - xscale2 = FixedDiv(projection, tz2); - x2 = ((centerxfrac + FixedMul(tx2,xscale2))>>FRACBITS); + tx2 = FixedMul(tr_x, viewsin) - FixedMul(tr_y, viewcos); if (max(tz, tz2) < FixedMul(MINZ, this_scale)) // non-papersprite clipping is handled earlier return; @@ -1471,7 +1483,7 @@ static void R_ProjectSprite(mobj_t *thing) tz2 = FixedMul(MINZ, this_scale); } - if ((tx2 / 4) < -(FixedMul(tz2, fovtan)) || (tx / 4) > FixedMul(tz, fovtan)) // too far off the side? + if (tx2 < -(FixedMul(tz2, fovtan)<<2) || tx > FixedMul(tz, fovtan)<<2) // too far off the side? return; yscale = FixedDiv(projectiony, tz); @@ -1492,9 +1504,7 @@ static void R_ProjectSprite(mobj_t *thing) if (x2 < 0) return; - range = x2 - x1; - - if (range < 0) + if ((range = x2 - x1) <= 0) return; range++; // fencepost problem @@ -1506,7 +1516,8 @@ static void R_ProjectSprite(mobj_t *thing) return; } - scalestep = ((yscale2 - yscale)/range) ?: 1; + // Compatibility with MSVC - SSNTails + scalestep = ((yscale2 - yscale)/range); if (scalestep == 0) scalestep = 1; @@ -1522,16 +1533,14 @@ static void R_ProjectSprite(mobj_t *thing) scalestep = 0; yscale = sortscale; tx += offset; - //x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; - x1 = centerx + (FixedMul(tx,xscale) / FRACUNIT); + x1 = (centerxfrac + FixedMul(tx,xscale))>>FRACBITS; // off the right side? if (x1 > viewwidth) return; tx += offset2; - //x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; - x2 = (centerx + (FixedMul(tx,xscale) / FRACUNIT)) - 1; + x2 = ((centerxfrac + FixedMul(tx,xscale))>>FRACBITS); x2--; // off the left side if (x2 < 0) @@ -1587,45 +1596,99 @@ static void R_ProjectSprite(mobj_t *thing) return; } - if (thing->subsector->sector->numlights) + if (oldthing->frame & FF_ABSOLUTELIGHTLEVEL) { - INT32 lightnum; - light = thing->subsector->sector->numlights - 1; + const UINT8 n = R_ThingLightLevel(oldthing); - for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { - fixed_t h = thing->subsector->sector->lightlist[lightnum].slope ? P_GetZAt(thing->subsector->sector->lightlist[lightnum].slope, interp.x, interp.y) - : thing->subsector->sector->lightlist[lightnum].height; - if (h <= gzt) + // n = uint8 aka 0 - 255, so the shift will always be 0 - LIGHTLEVELS - 1 + lights_array = scalelight[n >> LIGHTSEGSHIFT]; + } + else + { + if (thing->subsector->sector->numlights) + { + light = thing->subsector->sector->numlights - 1; + + for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { - light = lightnum - 1; - break; + fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], interp.x, interp.y); + + if (h <= gzt) + { + light = lightnum - 1; + break; + } + } + + lightnum = *thing->subsector->sector->lightlist[light].lightlevel; + } + else + { + lightnum = thing->subsector->sector->lightlevel; + } + + lightnum = (lightnum + R_ThingLightLevel(thing)) >> LIGHTSEGSHIFT; + + if (maplighting.directional == true && P_SectorUsesDirectionalLighting(thing->subsector->sector)) + { + fixed_t extralight = R_GetSpriteDirectionalLighting(papersprite + ? interp.angle + (ang >= ANGLE_180 ? -ANGLE_90 : ANGLE_90) + : R_PointToAngle(interp.x, interp.y)); + + // Krangle contrast in 3P/4P because scalelight + // scales differently depending on the screen + // width (which is halved in 3P/4P). + if (splitscreen > 1) + { + extralight *= 2; + } + + // Less change in contrast in dark sectors + extralight = FixedMul(extralight, min(max(0, lightnum), LIGHTLEVELS - 1) * FRACUNIT / (LIGHTLEVELS - 1)); + + if (papersprite) + { + // Papersprite contrast should match walls + lightnum += FixedFloor((extralight / 8) + (FRACUNIT / 2)) / FRACUNIT; + } + else + { + fixed_t n = FixedDiv(FixedMul(xscale, LIGHTRESOLUTIONFIX), ((MAXLIGHTSCALE-1) << LIGHTSCALESHIFT)); + + // Less change in contrast at further distances, to counteract DOOM diminished light + extralight = FixedMul(extralight, min(n, FRACUNIT)); + + // Contrast is stronger for normal sprites, stronger than wall lighting is at the same distance + lightnum += FixedFloor((extralight / 4) + (FRACUNIT / 2)) / FRACUNIT; } } - lightnum = (*thing->subsector->sector->lightlist[light].lightlevel >> LIGHTSEGSHIFT); if (lightnum < 0) - spritelights = scalelight[0]; + lights_array = scalelight[0]; else if (lightnum >= LIGHTLEVELS) - spritelights = scalelight[LIGHTLEVELS-1]; + lights_array = scalelight[LIGHTLEVELS-1]; else - spritelights = scalelight[lightnum]; + lights_array = scalelight[lightnum]; } heightsec = thing->subsector->sector->heightsec; - if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) + if (viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; else phs = -1; if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { + fixed_t top = gzt; + fixed_t bottom = interp.z; + if (viewz < sectors[phs].floorheight ? - interp.z >= sectors[heightsec].floorheight : - gzt < sectors[heightsec].floorheight) + bottom >= sectors[heightsec].floorheight : + top < sectors[heightsec].floorheight) return; if (viewz > sectors[phs].ceilingheight ? - gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : - interp.z >= sectors[heightsec].ceilingheight) + top < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : + bottom >= sectors[heightsec].ceilingheight) return; } @@ -1704,15 +1767,6 @@ static void R_ProjectSprite(mobj_t *thing) else if (R_ThingIsFullDark(oldthing)) vis->cut |= SC_FULLDARK; - //Fab: lumppat is the lump number of the patch to use, this is different - // than lumpid for sprites-in-pwad : the graphics are patched -#ifdef ROTSPRITE - if (rotsprite != NULL) - vis->patch = rotsprite; - else -#endif - vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); - // // determine the colormap (lightlevel & special effects) // @@ -1736,9 +1790,18 @@ static void R_ProjectSprite(mobj_t *thing) if (vis->cut & SC_SEMIBRIGHT) lindex = (MAXLIGHTSCALE/2) + (lindex >> 1); - vis->colormap = spritelights[lindex]; + vis->colormap = lights_array[lindex]; } + //Fab: lumppat is the lump number of the patch to use, this is different + // than lumpid for sprites-in-pwad : the graphics are patched +#ifdef ROTSPRITE + if (rotsprite != NULL) + vis->patch = rotsprite; + else +#endif + vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); + vis->precip = false; vis->vflip = vflip; @@ -1820,7 +1883,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) tx = -(gyt + gxt); // too far off the side? - if (abs(tx) > FixedMul(tz, fovtan)<<2) + if (abs(tx) > tz<<2) return; // aspect ratio stuff : @@ -1979,7 +2042,7 @@ void R_AddSprites(sector_t *sec, INT32 lightlevel) // Handle all things in sector. // If a limit exists, handle things a tiny bit different. - const fixed_t limit_dist = (fixed_t)(cv_drawdist.value) * mapobjectscale; + const INT32 limit_dist = cv_drawdist.value; for (thing = sec->thinglist; thing; thing = thing->snext) { @@ -2026,7 +2089,7 @@ void R_AddPrecipitationSprites(void) { for (th = precipblocklinks[(by * bmapwidth) + bx]; th; th = next) { - // Store this beforehand because R_ProjectPrecipitionSprite may free th (see P_PrecipThinker) + // Store this beforehand because R_ProjectPrecipitationSprite may free th (see P_PrecipThinker) next = th->bnext; if (th->precipflags & PCF_INVISIBLE) @@ -2219,6 +2282,7 @@ static void R_CreateDrawNodes(void) { if (!PolyObjects[i].visplane) continue; + plane = PolyObjects[i].visplane; R_PlaneBounds(plane); @@ -2227,6 +2291,7 @@ static void R_CreateDrawNodes(void) PolyObjects[i].visplane = NULL; continue; } + entry = R_CreateDrawNode(&nodehead); entry->plane = plane; // note: no seg is set, for what should be obvious reasons @@ -2237,6 +2302,7 @@ static void R_CreateDrawNodes(void) return; R_SortVisSprites(); + for (rover = vsprsortedhead.prev; rover != &vsprsortedhead; rover = rover->prev) { if (rover->szt > vid.height || rover->sz < 0) @@ -2255,13 +2321,8 @@ static void R_CreateDrawNodes(void) continue; // Effective height may be different for each comparison in the case of slopes - if (r2->plane->slope) - { - planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy); - planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy); - } - else - planeobjectz = planecameraz = r2->plane->height; + planeobjectz = P_GetZAt(r2->plane->slope, rover->gx, rover->gy, r2->plane->height); + planecameraz = P_GetZAt(r2->plane->slope, viewx, viewy, r2->plane->height); if (rover->mobjflags & MF_NOCLIPHEIGHT) { @@ -2296,6 +2357,7 @@ static void R_CreateDrawNodes(void) if (r2->seg->frontscale[i] > rover->sortscale) break; } + if (i > x2) continue; } @@ -2309,31 +2371,22 @@ static void R_CreateDrawNodes(void) else if (r2->thickseg) { fixed_t topplaneobjectz, topplanecameraz, botplaneobjectz, botplanecameraz; + if (rover->x1 > r2->thickseg->x2 || rover->x2 < r2->thickseg->x1) continue; scale = r2->thickseg->scale1 > r2->thickseg->scale2 ? r2->thickseg->scale1 : r2->thickseg->scale2; if (scale <= rover->sortscale) continue; + scale = r2->thickseg->scale1 + (r2->thickseg->scalestep * (sintersect - r2->thickseg->x1)); if (scale <= rover->sortscale) continue; - if (*r2->ffloor->t_slope) - { - topplaneobjectz = P_GetZAt(*r2->ffloor->t_slope, rover->gx, rover->gy); - topplanecameraz = P_GetZAt(*r2->ffloor->t_slope, viewx, viewy); - } - else - topplaneobjectz = topplanecameraz = *r2->ffloor->topheight; - - if (*r2->ffloor->b_slope) - { - botplaneobjectz = P_GetZAt(*r2->ffloor->b_slope, rover->gx, rover->gy); - botplanecameraz = P_GetZAt(*r2->ffloor->b_slope, viewx, viewy); - } - else - botplaneobjectz = botplanecameraz = *r2->ffloor->bottomheight; + topplaneobjectz = P_GetFFloorTopZAt (r2->ffloor, rover->gx, rover->gy); + topplanecameraz = P_GetFFloorTopZAt (r2->ffloor, viewx, viewy); + botplaneobjectz = P_GetFFloorBottomZAt(r2->ffloor, rover->gx, rover->gy); + botplanecameraz = P_GetFFloorBottomZAt(r2->ffloor, viewx, viewy); if ((topplanecameraz > viewz && botplanecameraz < viewz) || (topplanecameraz < viewz && rover->gzt < topplaneobjectz) || @@ -2803,7 +2856,7 @@ void R_ClipSprites(void) /* Check if thing may be drawn from our current view. */ boolean R_ThingVisible (mobj_t *thing) { - if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) + if (UNLIKELY(thing->sprite == SPR_NULL) || UNLIKELY((thing->flags2 & MF2_DONTDRAW))) return false; if (splitscreen) @@ -2818,11 +2871,11 @@ boolean R_ThingVisible (mobj_t *thing) return true; } -boolean R_ThingWithinDist(mobj_t *thing, fixed_t limit_dist) +boolean R_ThingWithinDist(mobj_t *thing, INT32 limit_dist) { if (limit_dist) { - if (P_AproxDistance(viewx-thing->x, viewy-thing->y) > limit_dist) + if (P_AproxDistance(viewx-thing->x, viewy-thing->y)/mapobjectscale > limit_dist) { return false; } @@ -2937,8 +2990,7 @@ static void Sk_SetDefaultValue(skin_t *skin, boolean local) // set default skin values // memset(skin, 0, sizeof (skin_t)); - snprintf(skin->name, - sizeof skin->name, "skin %u", (UINT32)(skin-(local ? localskins : skins))); + snprintf(skin->name, sizeof skin->name, "skin %u", K_GetMobjSkinNum(skin, local)); skin->name[sizeof skin->name - 1] = '\0'; skin->wadnum = INT16_MAX; strcpy(skin->sprite, ""); @@ -3159,8 +3211,9 @@ void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) { if (player->localskin > 0) { - CV_StealthSet(&cv_fakelocalskin, (player->skinlocal ? localskins : skins)[player->localskin-1].name); - CV_StealthSet(cvar, (player->skinlocal ? localskins : skins)[player->localskin-1].name); + CV_StealthSet(&cv_fakelocalskin, K_GetSkinArray(player->skinlocal)[player->localskin-1].name); + CV_StealthSet(cvar, K_GetSkinArray(player->skinlocal)[player->localskin-1].name); + } else { @@ -3349,7 +3402,6 @@ void R_AddSkins(UINT16 wadnum, boolean local) skin_t *skin; boolean hudname, realname; -#define lskin (local ? localskins : skins) #define lnumskins (local ? numlocalskins : numskins) // @@ -3383,7 +3435,7 @@ void R_AddSkins(UINT16 wadnum, boolean local) buf2[size] = '\0'; // set defaults - skin = &lskin[lnumskins]; + skin = &K_GetSkinArray(local)[lnumskins]; Sk_SetDefaultValue(skin, local); skin->wadnum = wadnum; hudname = realname = false; @@ -3418,10 +3470,10 @@ void R_AddSkins(UINT16 wadnum, boolean local) else { const size_t stringspace = - strlen(value) + sizeof (( (local) ? numlocalskins : numskins )) + 1; + strlen(value) + sizeof lnumskins + 1; char *value2 = Z_Malloc(stringspace, PU_STATIC, NULL); snprintf(value2, stringspace, - "%s%d", value, ( (local) ? numlocalskins : numskins )); + "%s%d", value, lnumskins); value2[stringspace - 1] = '\0'; if (R_LocalSkinAvailable(value2, local) == -1) { @@ -3642,7 +3694,7 @@ next_token: skinsorted[numskins] = numskins; } - allskins[numallskins] = lskin[lnumskins]; + allskins[numallskins] = K_GetSkinArray(local)[lnumskins]; local ? numlocalskins++ : numskins++; numallskins++; diff --git a/src/r_things.h b/src/r_things.h index 899400598..fe4f532b6 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -57,6 +57,9 @@ extern fixed_t windowtop; extern fixed_t windowbottom; extern INT32 lengthcol; +INT32 R_ThingLightLevel(mobj_t *thing); +fixed_t R_GetSpriteDirectionalLighting(angle_t angle); + fixed_t R_GetShadowZ(mobj_t *thing, pslope_t **shadowslope); void R_DrawMaskedColumn(column_t *column); @@ -74,7 +77,7 @@ void R_ClearSprites(void); void R_DrawMasked(void); boolean R_ThingVisible (mobj_t *thing); -boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist); +boolean R_ThingWithinDist (mobj_t *thing, INT32 limit_dist); boolean R_ThingIsFullBright (mobj_t *thing); boolean R_ThingIsSemiBright (mobj_t *thing); @@ -115,13 +118,21 @@ typedef struct // specific sounds per skin sfxenum_t soundsid[NUMSKINSOUNDS]; // sound # in S_sfx table - + boolean localskin; INT32 localnum; } skin_t; extern CV_PossibleValue_t Forceskin_cons_t[]; +// had to move those here Zzz... +INT32 K_GetSkinNum(player_t *player); +INT32 K_GetMobjSkinNum(const skin_t *skin, boolean local); +skin_t *K_GetPlayerSkin(player_t *player); +skin_t *K_GetMobjSkin(const mobj_t *mobj); +patch_t *K_GetFacePrefix(player_t *player, INT32 skinnum); +skin_t *K_GetSkinArray(boolean local); + // ----------- // NOT SKINS STUFF ! // ----------- diff --git a/src/s_sound.c b/src/s_sound.c index abd5afbd9..6aa3f74ae 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -423,17 +423,14 @@ static INT32 S_ScaleVolumeWithSplitscreen(INT32 volume) root = FixedSqrt((splitscreen + 1) * (FRACUNIT/3)); - return FixedDiv( - volume * FRACUNIT, - root - ) / FRACUNIT; + return FixedDiv(volume * FRACUNIT, root) / FRACUNIT; } void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) { const mobj_t *origin = (const mobj_t *)origin_p; const boolean reverse = (stereoreverse.value ^ encoremode); - const INT32 initial_volume = (origin ? S_ScaleVolumeWithSplitscreen(volume) : volume); + INT32 initial_volume; sfxinfo_t *sfx; INT32 sep, pitch, priority, cnum; @@ -451,6 +448,8 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) if (sfx_id == sfx_None) return; + initial_volume = (origin ? S_ScaleVolumeWithSplitscreen(volume) : volume); + for (i = 0; i <= splitscreen; i++) { player_t *player = &players[displayplayers[i]]; @@ -510,7 +509,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) if (sfx->skinsound != -1 && origin && origin->skin) { // redirect player sound to the sound in the skin table - sfx_id = ((skin_t *)( (origin->localskin) ? origin->localskin : origin->skin ))->soundsid[sfx->skinsound]; + sfx_id = K_GetMobjSkin(origin)->soundsid[sfx->skinsound]; sfx = &S_sfx[sfx_id]; } @@ -1840,7 +1839,7 @@ void S_ResumeAudio(void) if (S_MusicNotInFocus()) return; - if (I_SongPlaying() && I_SongPaused()) + if (!paused && I_SongPlaying() && I_SongPaused()) I_ResumeSong(); } diff --git a/src/screen.c b/src/screen.c index f6a94c052..0a9468d25 100644 --- a/src/screen.c +++ b/src/screen.c @@ -56,14 +56,11 @@ void (*twosmultipatchtransfunc)(void); // for cols with transparent pixels AND t viddef_t vid; INT32 setmodeneeded; //video mode change needed if > 0 (the mode number to set + 1) -static CV_PossibleValue_t scr_depth_cons_t[] = {{8, "8 bits"}, {16, "16 bits"}, {24, "24 bits"}, {32, "32 bits"}, {0, NULL}}; - static CV_PossibleValue_t shittyscreen_cons_t[] = {{0, "Okay"}, {1, "Shitty"}, {2, "Extra Shitty"}, {0, NULL}}; //added : 03-02-98: default screen mode, as loaded/saved in config consvar_t cv_scr_width = {"scr_width", "1280", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_scr_height = {"scr_height", "800", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_scr_depth = {"scr_depth", "16 bits", CV_SAVE, scr_depth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_renderview = {"renderview", "On", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_vhseffect = {"vhspause", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shittyscreen = {"televisionsignal", "Okay", CV_NOSHOWHELP, shittyscreen_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -322,8 +319,7 @@ void SCR_CheckDefaultMode(void) } else { - CONS_Printf(M_GetText("Default resolution: %d x %d (%d bits)\n"), cv_scr_width.value, - cv_scr_height.value, cv_scr_depth.value); + CONS_Printf(M_GetText("Default resolution: %d x %d\n"), cv_scr_width.value, cv_scr_height.value); // see note above setmodeneeded = VID_GetModeForSize(cv_scr_width.value, cv_scr_height.value) + 1; } @@ -335,7 +331,6 @@ void SCR_SetDefaultMode(void) // remember the default screen size CV_SetValue(&cv_scr_width, vid.width); CV_SetValue(&cv_scr_height, vid.height); - //CV_SetValue(&cv_scr_depth, vid.bpp*8); } // Change fullscreen on/off according to cv_fullscreen @@ -460,7 +455,7 @@ void SCR_DisplayTicRate(void) // draw "FPS" if (cv_ticrate.value == 1) V_DrawFixedPatch(306< (benchmark - 5)) ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE); else if (fps < 20) @@ -479,10 +474,10 @@ void SCR_DisplayTicRate(void) // draw total frame: V_DrawPingNum(x, 190, fpsflags, cap, ticcntcolor); - + x -= digits * 4; - // draw "/" + // draw "/" V_DrawFixedPatch(x< servermaxping)) // only show 2 (warning) if our ping is at a bad level { INT32 dispy = (cv_ticrate.value == 1) ? 165 : ((cv_ticrate.value == 2 || cv_ticrate.value == 4) ? 172 : ((cv_ticrate.value == 3) ? 163 : 181)); // absolute buttpain diff --git a/src/screen.h b/src/screen.h index 000957ed9..4a97e159b 100644 --- a/src/screen.h +++ b/src/screen.h @@ -145,12 +145,14 @@ extern double averageFPS; extern INT32 scr_bpp; extern UINT8 *scr_borderpatch; // patch used to fill the view borders -extern consvar_t cv_scr_width, cv_scr_height, cv_scr_depth, cv_renderview, cv_fullscreen, cv_vhseffect, cv_shittyscreen; +extern consvar_t cv_scr_width, cv_scr_height, cv_renderview, cv_fullscreen, cv_vhseffect, cv_shittyscreen; extern consvar_t cv_highreshudscale; // wait for page flipping to end or not extern consvar_t cv_vidwait; extern consvar_t cv_timescale; +extern consvar_t cv_alwaysgrabmouse; + // quick fix for tall/short skies, depending on bytesperpixel extern void (*walldrawerfunc)(void); diff --git a/src/sdl/i_net.c b/src/sdl/i_net.c index ee4a34c13..9fcc1fd38 100644 --- a/src/sdl/i_net.c +++ b/src/sdl/i_net.c @@ -436,6 +436,7 @@ boolean I_InitNetwork(void) I_Error("-net not supported, use -server and -connect\n" "see docs for more\n"); } + return false; #endif } diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 606eff094..f585fc44b 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -344,7 +344,7 @@ static void write_backtrace(bt_crash_reason_t reason) fprintf(out, "Program name: %s %s\n", SRB2APPLICATION, VERSIONSTRING); if (compdate && comptime && comprevision && compbranch) - fprintf(out, "Compiled: %s %s, commit %s, branch %s\n", compdate, comptime, comprevision, compbranch); + fprintf(out, "Compiled: %s %s, commit %s, branch %s\n", compdate, comptime, comprevision, compbranch); if (gamestate == GS_LEVEL) { @@ -877,7 +877,6 @@ static void I_RegisterSignals (void) #ifdef NEWSIGNALHANDLER static void signal_handler_child(INT32 num) { - #ifdef HAVE_LIBBACKTRACE write_backtrace(BT_CRASH_REASON_SIGNAL(num)); #endif @@ -1090,7 +1089,7 @@ INT32 I_GetJoystickDeviceIndex(SDL_GameController *dev) SDL_Joystick *joystick = NULL; joystick = SDL_GameControllerGetJoystick(dev); - + if (joystick) { return SDL_JoystickInstanceID(joystick); @@ -1243,8 +1242,6 @@ void I_GetJoystickEvents(UINT8 index) \param fname name of joystick \return axises - - */ static int joy_open(int playerIndex, int joyIndex) { diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 76d95a897..4754df855 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -138,6 +138,9 @@ static void I_CheckDesktopRes(void); consvar_t cv_vidwait = {"vid_wait", "Off", CV_SAVE|CV_CALL|CV_NOINIT, CV_OnOff, Impl_SetVsync, 0, NULL, NULL, 0, 0, NULL}; static consvar_t cv_stretch = {"stretch", "Off", CV_SAVE|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static void mousegrabOnChange(void); +consvar_t cv_alwaysgrabmouse = {"alwaysgrabmouse", "Off", CV_SAVE|CV_CALL, CV_OnOff, mousegrabOnChange, 0, NULL, NULL, 0, 0, NULL}; + // these cant be used since config is read after window creation, so need to use command line parameter instead //static CV_PossibleValue_t msaa_cons_t[] = {{0, "Off"}, {2, "2X"}, {4, "4X"}, {8, "8X"}, {16, "16X"}, {0, NULL}}; //consvar_t cv_msaa = {"msaa", "Off", CV_SAVE, msaa_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -222,6 +225,9 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); //static void Impl_SetWindowName(const char *title); static void Impl_SetWindowIcon(void); +static void SDLdoGrabMouse(void); +static void SDLdoUngrabMouse(void); + #ifdef USE_FBO_OGL boolean downsample = false; void RefreshOGLSDLSurface(void) @@ -231,6 +237,23 @@ void RefreshOGLSDLSurface(void) } #endif +static void mousegrabOnChange(void) +{ + static SDL_bool firsttimeonmouse = SDL_TRUE; + + if (!firsttimeonmouse) + { + HalfWarpMouse(realwidth, realheight); // warp to center + } + else + firsttimeonmouse = SDL_FALSE; + + if (cv_usemouse.value || cv_alwaysgrabmouse.value) + SDLdoGrabMouse(); + else + SDLdoUngrabMouse(); +} + static void SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen) { static SDL_bool wasfullscreen = SDL_FALSE; @@ -888,7 +911,9 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) { if (USE_MOUSEINPUT) { - if ((SDL_GetMouseFocus() != window && SDL_GetKeyboardFocus() != window)) + const boolean windowinfocus = (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window); + + if (!windowinfocus) { SDLdoUngrabMouse(); return; @@ -898,7 +923,7 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) // add on the offsets so we can make an overall event later. if (SDL_GetRelativeMouseMode()) { - if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) + if (windowinfocus) { mousemovex += evt.xrel; mousemovey += -evt.yrel; @@ -918,7 +943,21 @@ static void Impl_HandleMouseMotionEvent(SDL_MouseMotionEvent evt) // just grab and set relative mode // this fixes the stupid camera jerk on mouse entering bug // -- Monster Iestyn - if (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window) + if (windowinfocus) + { + SDLdoGrabMouse(); + } + } + else if (cv_alwaysgrabmouse.value) + { + const boolean windowinfocus = (SDL_GetMouseFocus() == window && SDL_GetKeyboardFocus() == window); + + if (!windowinfocus) + { + SDLdoUngrabMouse(); + return; + } + else if (windowinfocus) { SDLdoGrabMouse(); } @@ -1368,7 +1407,7 @@ void I_StartupMouse(void) } else firsttimeonmouse = SDL_FALSE; - if (cv_usemouse.value) + if (cv_usemouse.value || cv_alwaysgrabmouse.value) SDLdoGrabMouse(); else SDLdoUngrabMouse(); @@ -1964,6 +2003,7 @@ void I_StartupGraphics(void) COM_AddCommand ("vid_mode", VID_Command_Mode_f); CV_RegisterVar (&cv_vidwait); CV_RegisterVar (&cv_stretch); + CV_RegisterVar (&cv_alwaysgrabmouse); disable_mouse = M_CheckParm("-nomouse"); disable_fullscreen = M_CheckParm("-win") ? 1 : 0; @@ -2180,10 +2220,7 @@ void I_StartupGraphics(void) if (mousegrabok && !disable_mouse) { - SDL_ShowCursor(SDL_DISABLE); - SDL_SetRelativeMouseMode(SDL_TRUE); - wrapmouseok = SDL_TRUE; - SDL_SetWindowGrab(window, SDL_TRUE); + SDLdoGrabMouse(); } graphics_started = true; diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index f590d2a0f..73f6635e3 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -46,8 +46,6 @@ #include "../i_video.h" #include "../f_finale.h" -#include "../f_finale.h" - #ifdef DEBUG_TO_FILE #include #if defined (_WIN32) && !defined (__CYGWIN__) @@ -130,7 +128,6 @@ static boolean first_init = false; boolean OglSdlSurface(INT32 w, INT32 h) { - INT32 cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value; const char *gllogdir = NULL; oglflags = 0; @@ -159,7 +156,28 @@ boolean OglSdlSurface(INT32 w, INT32 h) GL_DBG_Printf("OpenGL %s\n", gl_version); GL_DBG_Printf("GPU: %s\n", gl_renderer); - GL_DBG_Printf("Extensions: %s\n", gl_extensions); + GL_DBG_Printf("Extensions:"); + + { + // Need to do it with strtok for same reason its done like that in gr_glinfo command + + char *copy = strdup((const char*)gl_extensions); + char *ext = strtok(copy, " "); + + if (copy == NULL) + { + GL_DBG_Printf("Ran out of memory listing extensions?!?!"); + } + else + { + do + { + GL_DBG_Printf(" %s", ext); + } while ((ext = strtok(NULL, " ")) != NULL); + + free(copy); + } + } if (strcmp((const char*)gl_renderer, "GDI Generic") == 0 && strcmp((const char*)gl_version, "1.1.0") == 0) @@ -192,14 +210,17 @@ boolean OglSdlSurface(INT32 w, INT32 h) #if defined (__unix__) #ifdef USE_FBO_OGL - if (supportFBO && strstr((const char*)gl_renderer, "NVIDIA")) + char videodriver[4] = {'S','D','L',0}; + if (supportFBO && strstr((const char*)gl_renderer, "NVIDIA") + && (*strncpy(videodriver, SDL_GetCurrentVideoDriver(), 4) != '\0') + && (strncasecmp("x11",videodriver,4) == 0)) xwaylandcrap = true; #endif #endif } SDL_GL_SetSwapInterval(cv_vidwait.value ? 1 : 0); - + // The screen textures need to be flushed if the width or height change so that they be remade for the correct size if (screen_width != w || screen_height != h) { @@ -226,7 +247,6 @@ boolean OglSdlSurface(INT32 w, INT32 h) if (!first_init) HWR_Startup(); - textureformatGL = cbpp > 16 ? GL_RGBA : GL_RGB5_A1; first_init = true; diff --git a/src/sdl/sdlmain.h b/src/sdl/sdlmain.h index 0ba8da762..b0def402d 100644 --- a/src/sdl/sdlmain.h +++ b/src/sdl/sdlmain.h @@ -54,7 +54,6 @@ typedef struct SDLJoyInfo_s int hats; /// number of balls int balls; - } SDLJoyInfo_t; /** \brief SDL info about controller 1 diff --git a/src/tables.c b/src/tables.c index 71b74636c..e293842bc 100644 --- a/src/tables.c +++ b/src/tables.c @@ -176,13 +176,18 @@ fixed_t *finecosine = &finesine[FINEANGLES/4]; #include "t_facon.c" - FUNCMATH angle_t FixedAcos(fixed_t x) { if (-FRACUNIT > x || x >= FRACUNIT) return 0; return fineacon[((x<<(FINE_FRACBITS-FRACBITS)))+FRACUNIT]; } +INT32 AngleDeltaSigned(angle_t a1, angle_t a2) +{ + // Silly but easy way to do it through integer conversion. + return (INT32)(a1) - (INT32)(a2); +} + // // AngleBetweenVectors // diff --git a/src/tables.h b/src/tables.h index f643895a5..4856c90ea 100644 --- a/src/tables.h +++ b/src/tables.h @@ -110,6 +110,8 @@ FUNCMATH angle_t FixedAngleC(fixed_t fa, fixed_t factor); /// The FixedAcos function FUNCMATH angle_t FixedAcos(fixed_t x); +FUNCMATH INT32 AngleDeltaSigned(angle_t a1, angle_t a2); + /// Fixed Point Vector functions angle_t FV2_AngleBetweenVectors(const vector2_t *Vector1, const vector2_t *Vector2); angle_t FV3_AngleBetweenVectors(const vector3_t *Vector1, const vector3_t *Vector2); diff --git a/src/v_video.c b/src/v_video.c index 0accbc86e..1d0b7ddfb 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -129,6 +129,7 @@ static boolean InitCube(void) } } }; + float desatur[3]; // grey float globalgammamul, globalgammaoffs; boolean doinggamma; @@ -136,7 +137,9 @@ static boolean InitCube(void) if (loaded_config == false) return false; -#define diffcons(cv) (cv.value != atoi(cv.defaultvalue)) +#define diffcons(cv) (strcmp(cv.string, cv.defaultvalue)) +#define diffconsgamma(cv) (cv.value != 0) +#define diffconssat(cv) (cv.value != 10) #ifdef BACKWARDSCOMPATCORRECTION doinggamma = (cv_globalgamma.value < 0); //dont mess up gamma when raising brightness pls @@ -156,12 +159,12 @@ static boolean InitCube(void) || diffcons(cv_chue) || diffcons(cv_bhue) || diffcons(cv_mhue) - || diffcons(cv_rgamma) - || diffcons(cv_ygamma) - || diffcons(cv_ggamma) - || diffcons(cv_cgamma) - || diffcons(cv_bgamma) - || diffcons(cv_mgamma)) // set the gamma'd/hued positions (saturation is done later) + || diffconsgamma(cv_rgamma) + || diffconsgamma(cv_ygamma) + || diffconsgamma(cv_ggamma) + || diffconsgamma(cv_cgamma) + || diffconsgamma(cv_bgamma) + || diffconsgamma(cv_mgamma)) // set the gamma'd/hued positions (saturation is done later) { float mod, tempgammamul, tempgammaoffs; @@ -219,7 +222,7 @@ static boolean InitCube(void) #define dosaturation(a, e) a = ((1 - work)*e + work*a) #define docvsat(cv_sat, hue, gamma, r, g, b) \ - if diffcons(cv_sat)\ + if diffconssat(cv_sat)\ {\ float work, mod, tempgammamul, tempgammaoffs;\ apply = true;\ @@ -244,7 +247,7 @@ static boolean InitCube(void) #undef gammascale - if diffcons(cv_globalsaturation) + if diffconssat(cv_globalsaturation) { float work = (cv_globalsaturation.value/10.0); @@ -265,6 +268,8 @@ static boolean InitCube(void) #undef dosaturation #undef diffcons +#undef diffconsgamma +#undef diffconssat if (!apply) return false; @@ -442,10 +447,6 @@ static void LoadPalette(const char *lumpname) pLocalPalette[i].s.alpha = 0xFF; // lerp of colour cubing! if you want, make it smoother yourself - - if (!Cubeapply) - continue; - V_CubeApply(&pLocalPalette[i].s.red, &pLocalPalette[i].s.green, &pLocalPalette[i].s.blue); } } @@ -589,28 +590,22 @@ static UINT8 hudplusalpha[11] = { 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0}; static UINT8 hudminusalpha[11] = { 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5}; UINT8 hudtrans = 0; -// this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol -INT32 V_LocalTransFlag(void) -{ - return ((10-cv_translucenthud.value)*V_10TRANS); -} - static const UINT8 *v_colormap = NULL; static const UINT8 *v_translevel = NULL; -static inline UINT8 standardpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) +FUNCINLINE static ATTRINLINE UINT8 standardpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) { (void)dest; return source[ofs>>FRACBITS]; } -static inline UINT8 mappedpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) +FUNCINLINE static ATTRINLINE UINT8 mappedpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) { (void)dest; return *(v_colormap + source[ofs>>FRACBITS]); } -static inline UINT8 translucentpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) +FUNCINLINE static ATTRINLINE UINT8 translucentpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) { return *(v_translevel + ((source[ofs>>FRACBITS]<<8)&0xff00) + (*dest&0xff)); } -static inline UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) +FUNCINLINE static ATTRINLINE UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fixed_t ofs) { return *(v_translevel + (((*(v_colormap + source[ofs>>FRACBITS]))<<8)&0xff00) + (*dest&0xff)); } @@ -633,6 +628,9 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (rendermode == render_none) return; + if (!patch) + return; + #ifdef HWRENDER //if (rendermode != render_soft && !con_startup) // Why? if (rendermode == render_opengl) @@ -665,6 +663,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca } v_colormap = NULL; + if (colormap) { v_colormap = colormap; @@ -673,21 +672,25 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca dupx = vid.dupx; dupy = vid.dupy; - if (scrn & V_SCALEPATCHMASK) switch ((scrn & V_SCALEPATCHMASK) >> V_SCALEPATCHSHIFT) + + if (scrn & V_SCALEPATCHMASK) { - case 1: // V_NOSCALEPATCH - dupx = dupy = 1; - break; - case 2: // V_SMALLSCALEPATCH - dupx = vid.smalldupx; - dupy = vid.smalldupy; - break; - case 3: // V_MEDSCALEPATCH - dupx = vid.meddupx; - dupy = vid.meddupy; - break; - default: - break; + switch ((scrn & V_SCALEPATCHMASK) >> V_SCALEPATCHSHIFT) + { + case 1: // V_NOSCALEPATCH + dupx = dupy = 1; + break; + case 2: // V_SMALLSCALEPATCH + dupx = vid.smalldupx; + dupy = vid.smalldupy; + break; + case 3: // V_MEDSCALEPATCH + dupx = vid.meddupx; + dupy = vid.meddupy; + break; + default: + break; + } } // only use one dup, to avoid stretching (har har) @@ -863,6 +866,9 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ if (rendermode == render_none) return; + if (!patch) + return; + #ifdef HWRENDER if (rendermode == render_opengl) { @@ -909,7 +915,8 @@ void V_DrawCroppedPatch(fixed_t x, fixed_t y, fixed_t pscale, INT32 scrn, patch_ deststop = desttop + vid.rowbytes * vid.height; - if (scrn & V_NOSCALESTART) { + if (scrn & V_NOSCALESTART) + { x >>= FRACBITS; y >>= FRACBITS; desttop += (y*vid.width) + x; @@ -1695,6 +1702,7 @@ void V_DrawCharacter(INT32 x, INT32 y, INT32 c, boolean lowercaseallowed) c -= HU_FONTSTART; else c = toupper(c) - HU_FONTSTART; + if (c < 0 || c >= HU_FONTSIZE || !hu_font[c]) return; diff --git a/src/v_video.h b/src/v_video.h index 2303b08c0..85338751c 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -17,6 +17,7 @@ #include "doomdef.h" #include "doomtype.h" #include "r_defs.h" +#include "r_main.h" // // VIDEO @@ -66,8 +67,6 @@ extern RGBA_t *pLocalPalette; extern UINT8 hudtrans; -extern INT32 V_LocalTransFlag(void); - void V_CubeApply(UINT8 *red, UINT8 *green, UINT8 *blue); // Retrieve the ARGB value from a palette color index @@ -270,6 +269,12 @@ char V_GetSkincolorChar(INT32 color); INT32 V_SkinColorToHighlightcolor(skincolors_t color); +// this is pretty dumb, but has to be done like this, otherwise the fps counter just disappears sometimes for no reason lol +FUNCINLINE static ATTRINLINE INT32 V_LocalTransFlag(void) +{ + return ((10-cv_translucenthud.value)*V_10TRANS); +} + typedef struct player_s player_t; void V_DoPostProcessor(INT32 view, INT32 param); diff --git a/src/w_wad.c b/src/w_wad.c index 37c992d29..6432c3223 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1780,7 +1780,7 @@ void W_UnlockCachedPatch(void *patch) // The hardware code does its own memory management, as its patches // have different lifetimes from software's. #ifdef HWRENDER - if (rendermode != render_soft && rendermode != render_none) + if (rendermode == render_opengl) HWR_UnlockCachedPatch((GLPatch_t*)patch); else #endif diff --git a/src/y_inter.c b/src/y_inter.c index 99445e17f..444df52d4 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -409,14 +409,9 @@ static void Y_PlayerStandingsDrawer(y_data_t *standings, INT32 x, INT32 hilicol) { UINT8 *colormap = R_GetTranslationColormap(*standings->character[i], *standings->color[i], GTC_CACHE); INT32 skinnum = (player->localskin ? (player->localskin - 1) : *standings->character[i]); - patch_t *faceprefix = NULL; + patch_t *faceprefix = K_GetFacePrefix(player, skinnum); - if (!player->skinlocal) - faceprefix = (cv_highresportrait.value ? facewantprefix[skinnum] : facerankprefix[skinnum]); - else - faceprefix = (cv_highresportrait.value ? localfacewantprefix[skinnum] : localfacerankprefix[skinnum]); - - if (cv_highresportrait.value) + if (K_UseHighResPortraits()) V_DrawSmallMappedPatch(x + 16, y - 4, 0, faceprefix, colormap); else V_DrawMappedPatch(x + 16, y - 4, 0, faceprefix, colormap); @@ -513,7 +508,7 @@ void Y_IntermissionDrawer(void) return; if (cv_betainterscreen.value == 1 -#ifdef HWRENDER +#ifdef HWRENDER || (rendermode == render_opengl && cv_glscreentextures.value != 2) // use the neato kart bg for intermission on disabled screen textures #endif ) @@ -621,7 +616,7 @@ void Y_Ticker(void) if (paused || P_AutoPause()) return; - LUA_HookVoid(HOOK(IntermissionThinker)); + LUA_HOOK(IntermissionThinker); intertic++; @@ -1143,7 +1138,9 @@ void Y_VoteDrawer(void) if (dedicated && i == 0) // While leaving blank spots for non-existent players is largely intentional, the first spot *always* being blank looks a tad silly :V continue; - if ((playeringame[i] && !players[i].spectator) && votes[i] != -1) + player_t *player = &players[i]; + + if ((playeringame[i] && !player->spectator) && votes[i] != -1) { patch_t *pic; @@ -1175,13 +1172,16 @@ void Y_VoteDrawer(void) V_DrawDiag(x, y, 6, V_SNAPTOLEFT|levelinfo[votes[i]].gtc); } - if (players[i].skincolor) + if (player->skincolor) { - UINT8 *colormap = R_GetTranslationColormap(players[i].skin, players[i].skincolor, GTC_CACHE); - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(x+24, y+9, V_SNAPTOLEFT, (players[i].skinlocal ? localfacewantprefix : facewantprefix)[((players[i].localskin) ? players[i].localskin-1 : players[i].skin)], colormap); + UINT8 *colormap = R_GetTranslationColormap(player->skin, player->skincolor, GTC_CACHE); + + patch_t *faceprefix = K_GetFacePrefix(player, K_GetSkinNum(player)); + + if (K_UseHighResPortraits()) + V_DrawSmallMappedPatch(x+24, y+9, V_SNAPTOLEFT, faceprefix, colormap); else - V_DrawMappedPatch(x+24, y+9, V_SNAPTOLEFT, (players[i].skinlocal ? localfacerankprefix : facerankprefix)[((players[i].localskin) ? players[i].localskin-1 : players[i].skin)], colormap); + V_DrawMappedPatch(x+24, y+9, V_SNAPTOLEFT, faceprefix, colormap); } if (!splitscreen && i == consoleplayer)