diff --git a/LUASTUFF.md b/LUASTUFF.md index d753723f1..881cbe4f7 100644 --- a/LUASTUFF.md +++ b/LUASTUFF.md @@ -28,6 +28,10 @@ exist. Returns the values of the given HUD item's `xoffset`/`yoffset` cvars. Available for any HUD item with offset cvars. +## patch = v.cachePatchRotated(name, rollangle) +Like v.cachePatch, it caches a new patch with the corresponding name. Unlike v.cachePatch, however, +a rollangle can be supplied to the function so that it returns a rotated patch instead. + ## x, y, flags = v.getDrawInfo(item) Returns the X, Y and flags where the given HUD item will be drawn for the current displayplayer. diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..0a17f3214 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +ifdef SILENT +MAKEFLAGS+=--no-print-directory +endif + +all : + +% :: + @$(MAKE) -C src $(MAKECMDGOALS) \ No newline at end of file diff --git a/README.md b/README.md index d5a3d2b41..1c0ee936d 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ Crashlogs now contain alot more informations. and even more if your build has de Also allows 64bit Windows builds to produce Crashlogs! ## MISC -- Bird's Camara Tilting feature is no longer turned on by default +- Bird's Camera Tilting feature is no longer turned on by default - Bird's warning on the title screen has been removed ## Bugs diff --git a/src/android/i_system.c b/src/android/i_system.c index f190699a4..7f034c752 100644 --- a/src/android/i_system.c +++ b/src/android/i_system.c @@ -184,8 +184,6 @@ void I_OutputMsg(const char *fmt, ...) void I_StartupMouse(void){} -void I_StartupMouse2(void){} - void I_StartupKeyboard(void){} INT32 I_GetKey(void) @@ -242,8 +240,6 @@ void I_GetJoystickEvents(void){} void I_GetJoystick2Events(void){} -void I_GetMouseEvents(void){} - char *I_GetEnv(const char *name) { LOGW("I_GetEnv() called?!"); diff --git a/src/console.c b/src/console.c index f36b3b7cb..3212521b0 100644 --- a/src/console.c +++ b/src/console.c @@ -608,7 +608,7 @@ static void CON_MoveConsole(void) } // Not instant - Increment fracmovement fractionally - fracmovement += FixedMul(cons_speed.value*vid.fdupy, renderdeltatics); + fracmovement += FixedMul(cons_speed.value*vid.fdupy, (cv_uncappedhud.value ? renderdeltatics : FRACUNIT)); if (con_curlines < con_destlines) // Move the console downwards { @@ -1466,7 +1466,10 @@ static void CON_DrawHudlines(void) { charflags = (*p & 0x7f) << V_CHARCOLORSHIFT; p++; + c++; } + if (c >= con_width) + break; if (*p < HU_FONTSTART) ;//charwidth = 4 * con_scalefactor; else @@ -1546,7 +1549,10 @@ static void CON_DrawConsole(void) { charflags = (*p & 0x7f) << V_CHARCOLORSHIFT; p++; + c++; } + if (c >= con_width) + break; V_DrawCharacter(x, y, (INT32)(*p) | charflags | cv_constextsize.value | V_NOSCALESTART, !cv_allcaps.value); } } diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 775668d5b..1b5478b62 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -103,6 +103,30 @@ static tic_t freezetimeout[MAXNETNODES]; // Until when can this node freeze the UINT16 pingmeasurecount = 1; UINT32 realpingtable[MAXPLAYERS]; //the base table of ping where an average will be sent to everyone. UINT32 playerpingtable[MAXPLAYERS]; //table of player latency values. + +#define GENTLEMANSMOOTHING (TICRATE) +static tic_t reference_lag; +static UINT8 spike_time; +tic_t lowest_lag; +tic_t simulated_lag; +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) + server_lagless = true; + + /*if (cv_lagless.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);*/ +} + +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... + SINT8 nodetoplayer[MAXNETNODES]; SINT8 nodetoplayer2[MAXNETNODES]; // say the numplayer for this node if any (splitscreen) SINT8 nodetoplayer3[MAXNETNODES]; // say the numplayer for this node if any (splitscreen == 2) @@ -140,7 +164,7 @@ static UINT8 gamestate_resend_counter[MAXNETNODES]; boolean hu_stopped = false; // Client specific -static ticcmd_t localcmds[MAXSPLITSCREENPLAYERS]; +static ticcmd_t localcmds[MAXSPLITSCREENPLAYERS][MAXGENTLEMENDELAY]; static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server @@ -187,6 +211,16 @@ typedef struct textcmdtic_s struct textcmdtic_s *next; } textcmdtic_t; +typedef struct textcmdbuf_s textcmdbuf_t; + +struct textcmdbuf_s +{ + textcmdbuf_t *next; + UINT8 cmd[MAXTEXTCMD]; +}; + +static textcmdbuf_t *textcmdbuf[MAXSPLITSCREENPLAYERS] = {NULL}; + ticcmd_t netcmds[TICQUEUE][MAXPLAYERS]; static textcmdtic_t *textcmds[TEXTCMD_HASH_SIZE] = {NULL}; @@ -271,25 +305,59 @@ void RegisterNetXCmd(netxcmd_t id, void (*cmd_f)(UINT8 **p, INT32 playernum)) listnetxcmd[id] = cmd_f; } -void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam) +static void WriteNetXCmd(UINT8 *cmd, netxcmd_t id, const void *param, size_t nparam) { - if ((localtextcmd[playerid])[0]+2+nparam > MAXTEXTCMD) - { - // for future reference: if (cht_debug) != debug disabled. - CONS_Alert(CONS_ERROR, M_GetText("NetXCmd buffer full, cannot add netcmd %d! (size: %d, needed: %s)\n"), id, localtextcmd[playerid][0], sizeu1(nparam)); - return; - } - - localtextcmd[playerid][0]++; - localtextcmd[playerid][localtextcmd[playerid][0]] = (UINT8)id; - + cmd[0]++; + cmd[cmd[0]] = (UINT8)id; if (param && nparam) { - M_Memcpy(&localtextcmd[playerid][localtextcmd[playerid][0] + 1], param, nparam); - localtextcmd[playerid][0] = (UINT8)(localtextcmd[playerid][0] + (UINT8)nparam); + M_Memcpy(&cmd[cmd[0]+1], param, nparam); + cmd[0] = (UINT8)(cmd[0] + (UINT8)nparam); } } +void SendNetXCmdForPlayer(UINT8 playerid, netxcmd_t id, const void *param, size_t nparam) +{ + if (localtextcmd[playerid][0]+2+nparam > MAXTEXTCMD) + { + textcmdbuf_t *buf = textcmdbuf[playerid]; + + if (2+nparam > MAXTEXTCMD) + { + CONS_Alert(CONS_ERROR, M_GetText("packet too large to fit NetXCmd, cannot add netcmd %d! (size: %s, max: %d)\n"), id, sizeu1(2+nparam), MAXTEXTCMD); + return; + } + + // for future reference: if (cv_debug) != debug disabled. + CONS_Alert(CONS_NOTICE, M_GetText("NetXCmd buffer full, delaying netcmd %d... (size: %d, needed: %s)\n"), id, localtextcmd[playerid][0], sizeu1(nparam)); + if (buf == NULL) + { + textcmdbuf[playerid] = Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL); + textcmdbuf[playerid]->cmd[0] = 0; + textcmdbuf[playerid]->next = NULL; + WriteNetXCmd(textcmdbuf[playerid]->cmd, id, param, nparam); + return; + } + + while (buf->next != NULL) + buf = buf->next; + + if (buf->cmd[0]+2+nparam > MAXTEXTCMD) + { + buf->next = Z_Malloc(sizeof(textcmdbuf_t), PU_STATIC, NULL); + buf->next->cmd[0] = 0; + buf->next->next = NULL; + WriteNetXCmd(buf->next->cmd, id, param, nparam); + } + else + { + WriteNetXCmd(buf->cmd, id, param, nparam); + } + return; + } + WriteNetXCmd(localtextcmd[playerid], id, param, nparam); +} + /*UINT8 GetFreeXCmdSize(UINT8 playerid) { // -1 for the size and another -1 for the ID. @@ -456,10 +524,15 @@ static void D_Clearticcmd(tic_t tic) void D_ResetTiccmds(void) { - INT32 i; + INT32 i, j; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - memset(&localcmds[i], 0, sizeof(ticcmd_t)); + { + for (j = 0; j < MAXGENTLEMENDELAY; j++) + { + memset(&localcmds[i][j], 0, sizeof(ticcmd_t)); + } + } // Reset the net command list for (i = 0; i < TEXTCMD_HASH_SIZE; i++) @@ -1159,7 +1232,8 @@ static inline void CL_DrawConnectionStatus(void) INT32 ccstime = I_GetTime(); // Draw background fade - V_DrawFadeScreen(0xFF00, 16); + if (!menuactive) // menu already draws its own fade + V_DrawFadeScreen(0xFF00, 16); // force default if (cl_mode != CL_DOWNLOADFILES && cl_mode != CL_LOADFILES && cl_mode != CL_CHECKFILES #ifdef HAVE_CURL @@ -1185,10 +1259,22 @@ static inline void CL_DrawConnectionStatus(void) case CL_DOWNLOADSAVEGAME: if (lastfilenum != -1) { + UINT32 currentsize = fileneeded[lastfilenum].currentsize; + UINT32 totalsize = fileneeded[lastfilenum].totalsize; + INT32 dldlength; + cltext = M_GetText("Downloading game state..."); Net_GetNetStat(); + + dldlength = (INT32)((currentsize/(double)totalsize) * 256); + if (dldlength > 256) + dldlength = 256; + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, 256, 8, 111); + V_DrawFill(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, dldlength, 8, 96); + V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, - va(" %4uK",fileneeded[lastfilenum].currentsize>>10)); + va(" %4uK/%4uK",currentsize>>10,totalsize>>10)); + V_DrawRightAlignedString(BASEVIDWIDTH/2+128, BASEVIDHEIGHT-24, V_20TRANS|V_MONOSPACE, va("%3.1fK/s ", ((double)getbps)/1024)); } @@ -2683,12 +2769,12 @@ static void CL_ConnectToServer(void) sprintf(tmpsave, "%s" PATHSEP TMPSAVENAME, srb2home); #endif - cl_mode = CL_SEARCHING; - #ifdef CLIENT_LOADINGSCREEN lastfilenum = -1; #endif + cl_mode = CL_SEARCHING; + #ifdef JOININGAME // Don't get a corrupt savegame error because tmpsave already exists if (FIL_FileExists(tmpsave) && unlink(tmpsave) == -1) @@ -5270,6 +5356,12 @@ static void HandlePacketFromPlayer(SINT8 node) /// \todo Use a separate cvar for that kind of timeout? freezetimeout[node] = I_GetTime() + connectiontimeout; + // If we've alredy received a ticcmd for this tic, just submit it for the next one. + tic_t faketic = maketic; + if ((!!(netcmds[maketic % TICQUEUE][netconsole].angleturn & TICCMD_RECEIVED)) + && (maketic - firstticstosend < TICQUEUE - 1)) + faketic++; + // Don't do anything for packets of type NODEKEEPALIVE? // Sryder 2018/07/01: Update the freezetimeout still! if (netbuffer->packettype == PT_NODEKEEPALIVE @@ -5277,7 +5369,7 @@ static void HandlePacketFromPlayer(SINT8 node) break; // Copy ticcmd - G_MoveTiccmd(&netcmds[maketic%TICQUEUE][netconsole], &netbuffer->u.clientpak.cmd, 1); + G_MoveTiccmd(&netcmds[faketic%TICQUEUE][netconsole], &netbuffer->u.clientpak.cmd, 1); // Check ticcmd for "speed hacks" if (CheckForSpeedHacks((UINT8)netconsole)) @@ -5289,7 +5381,7 @@ static void HandlePacketFromPlayer(SINT8 node) || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) && (nodetoplayer2[node] >= 0)) { - G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer2[node]], + G_MoveTiccmd(&netcmds[faketic%TICQUEUE][(UINT8)nodetoplayer2[node]], &netbuffer->u.client2pak.cmd2, 1); if (CheckForSpeedHacks((UINT8)nodetoplayer2[node])) @@ -5300,7 +5392,7 @@ static void HandlePacketFromPlayer(SINT8 node) || (netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS)) && (nodetoplayer3[node] >= 0)) { - G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer3[node]], + G_MoveTiccmd(&netcmds[faketic%TICQUEUE][(UINT8)nodetoplayer3[node]], &netbuffer->u.client3pak.cmd3, 1); if (CheckForSpeedHacks((UINT8)nodetoplayer3[node])) @@ -5310,7 +5402,7 @@ static void HandlePacketFromPlayer(SINT8 node) if ((netbuffer->packettype == PT_CLIENT4CMD || netbuffer->packettype == PT_CLIENT4MIS) && (nodetoplayer4[node] >= 0)) { - G_MoveTiccmd(&netcmds[maketic%TICQUEUE][(UINT8)nodetoplayer4[node]], + G_MoveTiccmd(&netcmds[faketic%TICQUEUE][(UINT8)nodetoplayer4[node]], &netbuffer->u.client4pak.cmd4, 1); if (CheckForSpeedHacks((UINT8)nodetoplayer4[node])) @@ -6007,27 +6099,78 @@ static void CL_SendClientCmd(void) } else if (gamestate != GS_NULL) { + UINT8 lagDelay = 0; + + if (lowest_lag > 0) + { + // Gentlemens' ping. + lagDelay = min(lowest_lag, MAXGENTLEMENDELAY); + + // Is our connection worse than our current gentleman point? + // Make sure it stays that way for a bit before increasing delay levels. + if (lagDelay > reference_lag) + { + spike_time++; + if (spike_time >= GENTLEMANSMOOTHING) + { + // Okay, this is genuinely the new baseline delay. + reference_lag = lagDelay; + spike_time = 0; + } + else + { + // Just a temporary fluctuation, ignore it. + lagDelay = reference_lag; + } + } + else + { + reference_lag = lagDelay; // Adjust quickly if the connection improves. + spike_time = 0; + } + + /* + if (server) // Clients have to wait for the gamestate to make it back. Servers don't! + lagDelay *= 2; // Simulate the HELLFUCK NIGHTMARE of a complete round trip. + */ + + // [deep breath in] + // Plausible, elegant explanation that is WRONG AND SUPER HARMFUL. + // Clients with stable connections were adding their mindelay to network delay, + // even when their mindelay was as high or higher than network delay—which made + // client delay APPEAR slower than host mindelay, by the exact value that made + // "lmao just double it" make sense at the time. + // + // While this fix made client connections match server mindelay in our most common + // test environment, it also masked an issue that seriously affected online handling + // responsiveness, completely ruining our opportunity to further investigate it! + // + // See UpdatePingTable. + // I am taking this shitty code to my grave as an example of "never trust your brain". + // -Tyron 2024-05-15 + } + packetsize = sizeof (clientcmd_pak); - G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds[0], 1); - netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic%TICQUEUE]); + G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds[0][lagDelay], 1); + netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic % TICQUEUE]); if (splitscreen || botingame) // Send a special packet with 2 cmd for splitscreen { netbuffer->packettype = (mis ? PT_CLIENT2MIS : PT_CLIENT2CMD); packetsize = sizeof (client2cmd_pak); - G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds[1], 1); + G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds[1][lagDelay], 1); if (splitscreen > 1) { netbuffer->packettype = (mis ? PT_CLIENT3MIS : PT_CLIENT3CMD); packetsize = sizeof (client3cmd_pak); - G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds[2], 1); + G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds[2][lagDelay], 1); if (splitscreen > 2) { netbuffer->packettype = (mis ? PT_CLIENT4MIS : PT_CLIENT4CMD); packetsize = sizeof (client4cmd_pak); - G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds[3], 1); + G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds[3][lagDelay], 1); } } } @@ -6062,7 +6205,16 @@ static void CL_SendClientCmd(void) M_Memcpy(netbuffer->u.textcmd, localtextcmd[i], localtextcmd[i][0]+1); // All extra data have been sent if (HSendPacket(servernode, true, 0, localtextcmd[i][0]+1)) // Send can fail... + { localtextcmd[i][0] = 0; + if (textcmdbuf[i] != NULL) + { + textcmdbuf_t *buf = textcmdbuf[i]; + M_Memcpy(localtextcmd[i], textcmdbuf[i]->cmd, textcmdbuf[i]->cmd[0]+1); + textcmdbuf[i] = textcmdbuf[i]->next; + Z_Free(buf); + } + } } } } @@ -6194,8 +6346,15 @@ static void SV_SendTics(void) // static inline void CreateNewLocalCMD(UINT8 p, INT32 realtics) { - G_BuildTiccmd(&localcmds[p], realtics, p+1); - localcmds[p].angleturn |= TICCMD_RECEIVED; + INT32 i; + + 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); + localcmds[p][0].angleturn |= TICCMD_RECEIVED; } static void Local_Maketic(INT32 realtics) @@ -6207,8 +6366,8 @@ static void Local_Maketic(INT32 realtics) // game responder calls HU_Responder, AM_Responder, F_Responder, // and G_MapEventsToControls if (!dedicated) rendergametic = gametic; - // translate inputs (keyboard/mouse/joystick) into game controls + // translate inputs (keyboard/mouse/joystick) into game controls for (i = 0; i <= splitscreen; i++) { CreateNewLocalCMD(i, realtics); @@ -6328,21 +6487,19 @@ boolean TryRunTics(tic_t realtics) } #endif - ticking = neededtic > gametic; - - if (ticking) + if (neededtic > gametic) { - if (realtics) - hu_stopped = false; + hu_stopped = false; } if (player_joining) { - if (realtics) - hu_stopped = true; + hu_stopped = true; return false; } + ticking = neededtic > gametic; + if (ticking) { // run the count * tics @@ -6497,17 +6654,62 @@ static tic_t gametime = 0; static void UpdatePingTable(void) { + tic_t fastest; + tic_t lag; + INT32 i; + if (server) { - if (netgame && !(gametime % 35)) // update once per second. + if (Playing() && !(gametime % 8)) // Value chosen based on _my vibes man_ PingUpdate(); + + fastest = 0; + // update node latency values so we can take an average later. for (i = 0; i < MAXPLAYERS; i++) - if (playeringame[i] && playernode[i] != UINT8_MAX) + { + if (playeringame[i] && playernode[i] > 0 && playernode[i] != UINT8_MAX) + { realpingtable[i] += GetLag(playernode[i]); + + if (!server_lagless && !players[i].spectator) + { + lag = playerpingtable[i]; + if (! fastest || lag < fastest) + fastest = lag; + } + } + } + + 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; + 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) + { + lowest_lag = ((tic_t)cv_mindelay.value - mydelay); + simulated_lag = (tic_t)cv_mindelay.value; + } + else + lowest_lag = simulated_lag = 0; + } } #ifdef HOLEPUNCH @@ -6602,14 +6804,6 @@ void NetUpdate(void) if (realtics <= 0) // nothing new to update return; - if (realtics > 5) - { - if (server) - realtics = 1; - else - realtics = 5; - } - #ifdef DEDICATEDIDLETIME if (server && dedicated && gamestate == GS_LEVEL) { @@ -6658,6 +6852,14 @@ void NetUpdate(void) } #endif + if (realtics > 5) + { + if (server) + realtics = 1; + else + realtics = 5; + } + gametime = nowtime; UpdatePingTable(); @@ -6751,8 +6953,6 @@ void NetUpdate(void) Net_AckTicker(); HandleNodeTimeouts(); - nowtime /= NEWTICRATERATIO; - if (nowtime > resptime) { resptime = nowtime; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 4e81621d9..fd3fcca0e 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -41,6 +41,15 @@ applications may follow different packet versions. #define BACKUPTICS 32 #define TICQUEUE 512 // more than enough for most timeouts.... #define MAXTEXTCMD 256 + +// No. of tics your controls can be delayed by. + +// TODO: Instead of storing a ton of extra cmds for gentlemens' delay, +// keep them in a linked-list, with timestamps to discard everything that's older than already sent. +// That will support any amount of lag, and be less wasteful for clients who don't use it. +// This just works as a quick implementation. +#define MAXGENTLEMENDELAY TICRATE + // // Packet structure // @@ -576,6 +585,11 @@ extern UINT32 realpingtable[MAXPLAYERS]; extern UINT32 playerpingtable[MAXPLAYERS]; 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 #ifdef VANILLAJOINNEXTROUND cv_joinnextround, @@ -645,6 +659,7 @@ extern char motd[254], server_context[8]; extern UINT8 playernode[MAXPLAYERS]; INT32 D_NumPlayers(void); + void D_ResetTiccmds(void); tic_t GetLag(INT32 node); diff --git a/src/d_event.h b/src/d_event.h index 8cbf8560d..b76e5c6a4 100644 --- a/src/d_event.h +++ b/src/d_event.h @@ -25,7 +25,6 @@ typedef enum ev_console, ev_mouse, ev_joystick, - ev_mouse2, ev_joystick2, ev_joystick3, ev_joystick4, diff --git a/src/d_main.c b/src/d_main.c index b03fa3da4..fb7a98a6e 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -133,6 +133,7 @@ char srb2home[256] = "."; char srb2path[256] = "."; boolean usehome = true; const char *pandf = "%s" PATHSEP "%s"; +static char addonsdir[MAX_WADPATH]; // // EVENT HANDLING @@ -182,6 +183,9 @@ static void D_GamePadMenuScrollTicker(void) static SINT8 menuInputDelayTimer = 0; int key = 0; // butt-on output + if (dedicated) + return; + // wish i had a switch ono if (DPADUPSCROLL) key = KEY_UPARROW; @@ -210,20 +214,17 @@ static void D_GamePadMenuScrollTicker(void) static void D_DeviceLEDTick(void) { UINT8 i; - UINT16 color[MAXSPLITSCREENPLAYERS]; - UINT16 curcolor[MAXSPLITSCREENPLAYERS]; + static UINT16 color[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; + static UINT16 curcolor[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; - if (I_NumJoys() == 0) + if (dedicated || numcontrollers == 0) { return; } for (i = 0; i <= splitscreen; i++) { - if (!cv_usejoystick[i].value) - continue; - - if (!cv_gamepadled[i].value) + if (!cv_usejoystick[i].value || !cv_gamepadled[i].value) continue; color[i] = G_GetSkinColor(i); @@ -334,7 +335,7 @@ static boolean D_Display(void) if (rendermode == render_soft && !splitscreen) { - R_InterpolateViewRollAngle(rendertimefrac); + R_InterpolateViewRollAngle(rendertimefrac_unpaused); R_CheckViewMorph(); } @@ -352,6 +353,7 @@ static boolean D_Display(void) // save the current screen if about to wipe wipe = (gamestate != wipegamestate); + if (wipe) { // set for all later @@ -504,7 +506,7 @@ static boolean D_Display(void) #ifdef HWRENDER if (rendermode == render_opengl) - HWR_RenderPlayerView(i, &players[displayplayers[i]]); + HWR_RenderPlayerView(); else #endif if (rendermode != render_none) @@ -558,7 +560,7 @@ static boolean D_Display(void) for (i = 0; i <= splitscreen; i++) { - V_DoPostProcessor(i, &players[displayplayers[i]], postimgparam[i]); + V_DoPostProcessor(i, postimgparam[i]); } } @@ -579,8 +581,6 @@ static boolean D_Display(void) PS_START_TIMING(ps_uitime); ST_Drawer(); HU_Drawer(); - - NetUpdate(); // TEST: run this EVERY frame } else { @@ -741,11 +741,9 @@ void D_SRB2Loop(void) precise_t enterprecise = I_GetPreciseTime(); precise_t finishprecise = enterprecise; - { - // Casting the return value of a function is bad practice (apparently) - double budget = ((R_GetFramerateCap() == 0) ? 0.0 : round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision())); - capbudget = (precise_t) budget; - } + // Casting the return value of a function is bad practice (apparently) + double budget = ((R_GetFramerateCap() == 0) ? 0.0 : round((1.0 / R_GetFramerateCap()) * I_GetPrecisePrecision())); + capbudget = (precise_t) budget; boolean ranwipe = false; @@ -774,15 +772,15 @@ void D_SRB2Loop(void) debugload--; #endif - interp = R_UsingFrameInterpolation() && !dedicated; + interp = (R_UsingFrameInterpolation() && !dedicated); doDisplay = false; renderisnewtic = (realtics > 0 || singletics); + refreshdirmenu = 0; // not sure where to put this, here as good as any? + if (renderisnewtic) { - refreshdirmenu = 0; // not sure where to put this, here as good as any? - // don't skip more than 10 frames at a time // (fadein / fadeout cause massive frame skip!) if (realtics > 8) @@ -791,7 +789,7 @@ void D_SRB2Loop(void) // process tics (but maybe not if realtic == 0) TryRunTics(realtics); - if (lastdraw || singletics || gametic > rendergametic) + if (lastdraw || singletics || (gametic > rendergametic)) { rendergametic = gametic; rendertimeout = entertic + TICRATE/17; @@ -805,7 +803,7 @@ void D_SRB2Loop(void) { // Evaluate the chase cam once for every local realtic // This might actually be better suited inside G_Ticker or TryRunTics - for (tic_t chasecamtics = 0; chasecamtics < realtics; chasecamtics++) + for (tic_t chasecamtics = 0; (chasecamtics < realtics); chasecamtics++) { P_RunChaseCameras(); } @@ -827,7 +825,7 @@ void D_SRB2Loop(void) { renderdeltatics = FLOAT_TO_FIXED(deltatics); - if (!(paused || P_AutoPause()) && !hu_stopped) + if (!(paused || P_AutoPause()) && deltatics < 1.0 && !hu_stopped) { rendertimefrac = g_time.timefrac; } @@ -836,7 +834,14 @@ void D_SRB2Loop(void) rendertimefrac = FRACUNIT; } - rendertimefrac_unpaused = g_time.timefrac; + if ((deltatics < 1.0) && !hu_stopped) + { + rendertimefrac_unpaused = g_time.timefrac; + } + else + { + rendertimefrac_unpaused = FRACUNIT; + } } else { @@ -859,7 +864,6 @@ void D_SRB2Loop(void) // consoleplayer -> displayplayers (hear sounds from viewpoint) S_UpdateSounds(); // move positional sounds - LUA_Step(); #ifdef HAVE_DISCORDRPC @@ -885,7 +889,7 @@ void D_SRB2Loop(void) // // Wipes run an inner loop and artificially increase // the measured time. - if (!ranwipe && frameskip < 3 && deltatics > 1.0) + if (!ranwipe && (frameskip < 3) && (deltatics > 1.0)) { frameskip++; } @@ -901,7 +905,7 @@ void D_SRB2Loop(void) // in the case of "match refresh rate" + vsync, don't sleep at all const boolean vsync_with_match_refresh = cv_vidwait.value && cv_fpscap.value == 0; - if (elapsed > 0 && (INT64)capbudget > elapsed && !vsync_with_match_refresh) + if ((elapsed > 0) && ((INT64)capbudget > elapsed) && !vsync_with_match_refresh) { I_SleepDuration(capbudget - (finishprecise - enterprecise)); } @@ -976,10 +980,6 @@ void D_StartTitle(void) S_ResetKeepAndSpecialMus(); // just in case F_StartTitleScreen(); - - // Reset the palette -- SRB2Kart: actually never mind let's do this in the middle of every fade - /*if (rendermode != render_none) - V_SetPaletteLump("PLAYPAL");*/ } // @@ -1197,19 +1197,22 @@ boolean found_extra_kart; boolean found_extra2_kart; boolean found_extra3_kart; -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 clr_hud; // colour hud check -boolean big_lap; // bigger lap counter -boolean big_lap_color; // bigger lap counter but colour -boolean kartzspeedo; // kartZ speedo -boolean statdp; // stat display for extended player setup -boolean nametaggfx; // Nametag stuffs -boolean driftgaugegfx; +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 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 +// static void IdentifyVersion(void) { @@ -1435,8 +1438,6 @@ void D_SRB2Main(void) // can't use sprintf since there is %u in savegamename strcatbf(savegamename, srb2home, PATHSEP); - - I_mkdir(srb2home, 0700); #else snprintf(srb2home, sizeof srb2home, "%s", userhome); snprintf(downloaddir, sizeof downloaddir, "%s", userhome); @@ -1473,6 +1474,10 @@ void D_SRB2Main(void) } } + // Create addons dir + snprintf(addonsdir, sizeof addonsdir, "%s%s%s", srb2home, PATHSEP, "addons"); + I_mkdir(addonsdir, 0755); + D_SetupProtocol(); // rand() needs seeded regardless of password @@ -1625,7 +1630,7 @@ void D_SRB2Main(void) "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)) { - kartzspeedo = true; + kartz_speedo = true; PUSHCONS(speedo_cons_temp, last_speedo_i, 4, "P-Meter"); } @@ -1639,9 +1644,11 @@ void D_SRB2Main(void) 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) { @@ -2070,7 +2077,7 @@ void D_SRB2Main(void) } #ifdef HAVE_DISCORDRPC - if (! dedicated) + if (!dedicated) { DRPC_Init(); } diff --git a/src/d_main.h b/src/d_main.h index ddd6c3ab4..d5b5189eb 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -27,23 +27,27 @@ extern boolean usehome; //Alam: which path? extern const char *pandf; //Alam: how to path? extern char srb2path[256]; //Alam: SRB2's Home +// extra graphic patches for saturn specific thingies extern boolean found_extra_kart; // for use in k_kart.c extern boolean found_extra2_kart; // for use in k_kart.c extern boolean found_extra3_kart; // for use in k_kart.c -extern boolean xtra_speedo; // extra speedometer check -extern boolean xtra_speedo_clr; // extra speedometer colour check -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 clr_hud; // colour hud check -extern boolean big_lap; // bigger lap counter -extern boolean big_lap_color; // bigger lap counter but colour -extern boolean kartzspeedo; // kartZ speedo -extern boolean statdp; // stat display for extended player setup -extern boolean nametaggfx; // Nametag stuffs -extern boolean driftgaugegfx; +extern boolean xtra_speedo; // extra speedometer check +extern boolean xtra_speedo_clr; // extra speedometer colour check +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 clr_hud; // colour hud 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 +// // autoload stuff extern boolean autoloading; diff --git a/src/d_net.c b/src/d_net.c index 2725fca14..d6b0e2f80 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -638,6 +638,7 @@ void Net_WaitAllAckReceived(UINT32 timeout) static void InitNode(node_t *node) { node->acktosend_head = node->acktosend_tail = 0; + memset(node->acktosend, 0, sizeof(node->acktosend)); node->firstacktosend = 0; node->nextacknum = 1; node->remotefirstack = 0; @@ -1339,9 +1340,9 @@ boolean D_CheckNetGame(void) I_Error("Too many nodes (%d), max:%d", doomcom->numnodes, MAXNETNODES); netbuffer = (doomdata_t *)(void *)&doomcom->data; - #ifdef HOLEPUNCH +#ifdef HOLEPUNCH holepunchpacket = (holepunch_t *)(void *)&doomcom->data; - #endif +#endif #ifdef DEBUGFILE if (M_CheckParm("-debugfile")) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index b01f87e5a..c7ba62636 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -209,13 +209,6 @@ void SendWeaponPref3(void); void SendWeaponPref4(void); static CV_PossibleValue_t usemouse_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Force"}, {0, NULL}}; -#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) -static CV_PossibleValue_t mouse2port_cons_t[] = {{0, "/dev/gpmdata"}, {1, "/dev/ttyS0"}, - {2, "/dev/ttyS1"}, {3, "/dev/ttyS2"}, {4, "/dev/ttyS3"}, {0, NULL}}; -#else -static CV_PossibleValue_t mouse2port_cons_t[] = {{1, "COM1"}, {2, "COM2"}, {3, "COM3"}, {4, "COM4"}, - {0, NULL}}; -#endif #ifdef LJOYSTICK static CV_PossibleValue_t joyport_cons_t[] = {{1, "/dev/js0"}, {2, "/dev/js1"}, {3, "/dev/js2"}, @@ -298,13 +291,15 @@ 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}; -consvar_t cv_usemouse2 = {"use_mouse2", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse2, 0, NULL, NULL, 0, 0, NULL}; + //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_verticallook = {"verticallook", "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] = { {"use_joystick", "1", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick1, 0, NULL, NULL, 0, 0, NULL}, @@ -331,12 +326,6 @@ consvar_t cv_joyscale[2] = { //Alam: Dummy for save {"joyscale", "1", CV_SAVE|CV_HIDEN, NULL, NULL, 0, NULL, NULL, 0, 0, NULL} }; #endif -#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) -consvar_t cv_mouse2port = {"mouse2port", "/dev/gpmdata", CV_SAVE, mouse2port_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mouse2opt = {"mouse2opt", "0", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -#else -consvar_t cv_mouse2port = {"mouse2port", "COM2", CV_SAVE, mouse2port_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -#endif consvar_t cv_matchboxes = {"matchboxes", "Normal", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, matchboxes_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_specialrings = {"specialrings", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -404,18 +393,18 @@ static CV_PossibleValue_t kartvoices_cons_t[] = {{0, "Never"}, {1, "Tasteful"}, consvar_t cv_kartvoices = {"kartvoices", "Tasteful", CV_SAVE, kartvoices_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_karthitemdialog = {"karthitemdialog", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_karteliminatelast = {"karteliminatelast", "Yes", CV_NETVAR|CV_CHEAT|CV_CALL|CV_NOSHOWHELP, CV_YesNo, KartEliminateLast_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_karteliminatelast = {"karteliminatelast", "Yes", CV_NETVAR|CV_CHEAT|CV_CALL, CV_YesNo, KartEliminateLast_OnChange, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugitem_cons_t[] = {{-1, "MIN"}, {NUMKARTITEMS-1, "MAX"}, {0, NULL}}; -consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugitem = {"kartdebugitem", "0", CV_NETVAR|CV_CHEAT, kartdebugitem_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t kartdebugamount_cons_t[] = {{1, "MIN"}, {255, "MAX"}, {0, NULL}}; -consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebugshrink = {"kartdebugshrink", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebugdistribution = {"kartdebugdistribution", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebughuddrop = {"kartdebughuddrop", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugamount = {"kartdebugamount", "1", CV_NETVAR|CV_CHEAT, kartdebugamount_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugshrink = {"kartdebugshrink", "Off", CV_NETVAR|CV_CHEAT, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugdistribution = {"kartdebugdistribution", "Off", CV_NETVAR|CV_CHEAT, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebughuddrop = {"kartdebughuddrop", "Off", CV_NETVAR|CV_CHEAT, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebugcheckpoint = {"kartdebugcheckpoint", "Off", CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_kartdebugnodes = {"kartdebugnodes", "Off", CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugcheckpoint = {"kartdebugcheckpoint", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_kartdebugnodes = {"kartdebugnodes", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebugcolorize = {"kartdebugcolorize", "Off", CV_NOSHOWHELP, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; static CV_PossibleValue_t votetime_cons_t[] = {{1, "MIN"}, {3600, "MAX"}, {0, NULL}}; @@ -527,7 +516,8 @@ static CV_PossibleValue_t ps_descriptor_cons_t[] = { {1, "Average"}, {2, "SD"}, {3, "Minimum"}, {4, "Maximum"}, {0, NULL}}; consvar_t cv_ps_descriptor = {"ps_descriptor", "Average", 0, ps_descriptor_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_director = {"director", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +// only there to better keep track of it globally +consvar_t cv_director = {"director", "Off", CV_HIDEN, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_kartdebugdirector = {"debugdirector", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showdirectorhud = {"showdirectorhud", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -868,6 +858,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_screenshot_option); CV_RegisterVar(&cv_screenshot_folder); CV_RegisterVar(&cv_moviemode); + CV_RegisterVar(&cv_movie_option); + CV_RegisterVar(&cv_movie_folder); // PNG variables CV_RegisterVar(&cv_zlib_level); CV_RegisterVar(&cv_zlib_memory); @@ -916,6 +908,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_rollingdemos); CV_RegisterVar(&cv_netstat); CV_RegisterVar(&cv_netticbuffer); + CV_RegisterVar(&cv_mindelay); + CV_RegisterVar(&cv_lagless); #ifdef NETGAME_DEVMODE CV_RegisterVar(&cv_fishcake); @@ -970,14 +964,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_showlocalskinmenus); - //CV_RegisterVar(&cv_crosshair); - //CV_RegisterVar(&cv_crosshair2); - //CV_RegisterVar(&cv_crosshair3); - //CV_RegisterVar(&cv_crosshair4); - //CV_RegisterVar(&cv_alwaysfreelook); - //CV_RegisterVar(&cv_alwaysfreelook2); - //CV_RegisterVar(&cv_chasefreelook); - //CV_RegisterVar(&cv_chasefreelook2); CV_RegisterVar(&cv_replaysearchrate); CV_RegisterVar(&cv_showfocuslost); CV_RegisterVar(&cv_pauseifunfocused); @@ -987,6 +973,8 @@ void D_RegisterClientCommands(void) { CV_RegisterVar(&cv_turnaxis[i]); CV_RegisterVar(&cv_moveaxis[i]); + CV_RegisterVar(&cv_camturnaxis[i]); + CV_RegisterVar(&cv_camstrafeaxis[i]); CV_RegisterVar(&cv_brakeaxis[i]); CV_RegisterVar(&cv_aimaxis[i]); CV_RegisterVar(&cv_lookaxis[i]); @@ -1008,12 +996,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_addons_search_type); CV_RegisterVar(&cv_addons_search_case); - // WARNING: the order is important when initialising mouse2 - // we need the mouse2port - CV_RegisterVar(&cv_mouse2port); -#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) - CV_RegisterVar(&cv_mouse2opt); -#endif CV_RegisterVar(&cv_controlperkey); CV_RegisterVar(&cv_turnsmooth); @@ -1025,15 +1007,10 @@ void D_RegisterClientCommands(void) } CV_RegisterVar(&cv_usemouse); - CV_RegisterVar(&cv_usemouse2); CV_RegisterVar(&cv_invertmouse); - CV_RegisterVar(&cv_invertmouse2); CV_RegisterVar(&cv_mousesens); - CV_RegisterVar(&cv_mousesens2); CV_RegisterVar(&cv_mouseysens); - CV_RegisterVar(&cv_mouseysens2); //CV_RegisterVar(&cv_mousemove); - //CV_RegisterVar(&cv_mousemove2); for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { @@ -1091,6 +1068,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_laglesscam); + CV_RegisterVar(&cv_verticallook); + // ingame object placing COM_AddCommand("objectplace", Command_ObjectPlace_f); COM_AddCommand("writethings", Command_Writethings_f); @@ -2237,7 +2216,7 @@ static void Command_View_f(void) return; } - if (demo.freecam) + if (camera[viewnum-1].freecam) return; displayplayerp = &displayplayers[viewnum-1]; @@ -2455,8 +2434,6 @@ static void Command_StopMovie_f(void) INT32 mapchangepending = 0; -tic_t driftsparkGrowTimer[MAXPLAYERS]; - /** Runs a map change. * The supplied data are assumed to be good. If provided by a user, they will * have already been checked in Command_Map_f(). @@ -2490,9 +2467,6 @@ void D_MapChange(INT32 mapnum, INT32 newgametype, boolean pencoremode, boolean r CONS_Debug(DBG_GAMELOGIC, "Map change: mapnum=%d gametype=%d encoremode=%d resetplayers=%d delay=%d skipprecutscene=%d\n", mapnum, newgametype, pencoremode, resetplayers, delay, skipprecutscene); - // just gonna hack in a timer reset here... - memset(driftsparkGrowTimer, 0, sizeof(driftsparkGrowTimer)); - if (netgame || multiplayer) FLS = false; @@ -2702,6 +2676,8 @@ static void Command_Map_f(void) return; } + M_ClearMenus(true); + last_map_cmd = I_GetTime(); size_t first_option; @@ -2894,6 +2870,7 @@ static void Command_Map_f(void) } fromlevelselect = false; + D_MapChange(newmapnum, newgametype, newencoremode, newresetplayers, 0, false, false); Z_Free(realmapname); @@ -3177,7 +3154,7 @@ static void Got_Respawn(UINT8 **cp, INT32 playernum) return; if (players[respawnplayer].mo) - P_DamageMobj(players[respawnplayer].mo, NULL, NULL, 10000); + P_DamageMobj(players[respawnplayer].mo, NULL, NULL, DMG_INSTAKILL); demo_extradata[playernum] |= DXD_RESPAWN; } @@ -3879,7 +3856,7 @@ static void Got_Teamchange(UINT8 **cp, INT32 playernum) if (!players[playernum].spectator) { if (players[playernum].mo) - P_DamageMobj(players[playernum].mo, NULL, NULL, 10000); + P_DamageMobj(players[playernum].mo, NULL, NULL, DMG_INSTAKILL); else players[playernum].playerstate = PST_REBORN; } diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 87d96b40d..9e1744e00 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -50,13 +50,6 @@ extern consvar_t cv_joyport2; #endif extern consvar_t cv_joyscale[4]; //MAXSPLITSCREENPLAYERS -// splitscreen with second mouse -extern consvar_t cv_mouse2port; -extern consvar_t cv_usemouse2; -#if defined (__unix__) || defined (__APPLE__) || defined (UNIXCOMMON) -extern consvar_t cv_mouse2opt; -#endif - // normally in p_mobj but the .h is not read extern consvar_t cv_itemrespawntime; extern consvar_t cv_itemrespawn; @@ -179,9 +172,7 @@ extern consvar_t cv_nametagdist; extern consvar_t cv_showownnametag; extern consvar_t cv_smallnametags; extern consvar_t cv_nametagrestat; -extern consvar_t cv_nametaghop; extern consvar_t cv_nametagscore; -extern consvar_t cv_shownametagfinish; extern consvar_t cv_shownametagspectator; #define SKINSELECTSPIN_PAIN 25 @@ -207,6 +198,8 @@ extern consvar_t cv_betainterscreen; extern consvar_t cv_laglesscam; +extern consvar_t cv_verticallook; + typedef enum { SKINMENUTYPE_SCROLL = 0, @@ -304,8 +297,6 @@ typedef union { #pragma pack() #endif -extern tic_t driftsparkGrowTimer[16]; - // add game commands, needs cleanup void D_RegisterServerCommands(void); void D_RegisterClientCommands(void); diff --git a/src/d_netfil.c b/src/d_netfil.c index fd0bf879c..e488e083e 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -233,6 +233,9 @@ void D_ParseFileneeded(INT32 fileneedednum_parm, UINT8 *fileneededstr, UINT16 fi void CL_PrepareDownloadSaveGame(const char *tmpsave) { +#ifdef CLIENT_LOADINGSCREEN + lastfilenum = -1; +#endif fileneedednum = 1; fileneeded[0].status = FS_REQUESTED; fileneeded[0].totalsize = UINT32_MAX; diff --git a/src/d_player.h b/src/d_player.h index 140a4a748..7ecef63de 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -351,6 +351,7 @@ typedef enum typedef enum { LAP_CUR, + LAP_BEST, LAP_LAST, LAP__MAX } laptime_e; @@ -412,8 +413,6 @@ typedef struct player_s // See pflags_t, above. pflags_t pflags; - UINT16 postimgflags; - // playing animation. panim_t panim; @@ -551,9 +550,12 @@ typedef struct player_s UINT8 hitemvictim; UINT8 splitscreenindex; -#ifdef HWRENDER + + tic_t driftsparkGrowTimer; + + fixed_t spinoutrot; // When a player spins out, this value increments modulus 360. + fixed_t fovadd; // adjust FOV for hw rendering -#endif } player_t; #endif diff --git a/src/dehacked.c b/src/dehacked.c index c914bc5cb..b986597a2 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7761,7 +7761,18 @@ struct { {"FF_HORIZONTALFLIP",FF_HORIZONTALFLIP}, {"FF_PAPERSPRITE",FF_PAPERSPRITE}, {"FF_ANIMATE",FF_ANIMATE}, + // brightness + {"FF_BRIGHTMASK",FF_BRIGHTMASK}, {"FF_FULLBRIGHT",FF_FULLBRIGHT}, + {"FF_SEMIBRIGHT",FF_SEMIBRIGHT}, + {"FF_FULLDARK",FF_FULLDARK}, + // blending + {"FF_BLENDMASK",FF_BLENDMASK}, + {"FF_BLENDSHIFT",FF_BRIGHTMASK}, + {"FF_ADD",FF_ADD}, + {"FF_SUBTRACT",FF_SUBTRACT}, + {"FF_REVERSESUBTRACT",FF_REVERSESUBTRACT}, + {"FF_MODULATE",FF_MODULATE}, {"FF_TRANSMASK",FF_TRANSMASK}, {"FF_TRANSSHIFT",FF_TRANSSHIFT}, // new preshifted translucency (used in source) @@ -7797,6 +7808,15 @@ struct { {"tr_trans90",tr_trans90}, {"NUMTRANSMAPS",NUMTRANSMAPS}, + // Alpha styles (blend modes) + {"AST_COPY",AST_COPY}, + {"AST_TRANSLUCENT",AST_TRANSLUCENT}, + {"AST_ADD",AST_ADD}, + {"AST_SUBTRACT",AST_SUBTRACT}, + {"AST_REVERSESUBTRACT",AST_REVERSESUBTRACT}, + {"AST_MODULATE",AST_MODULATE}, + {"AST_OVERLAY",AST_OVERLAY}, + // Type of levels {"TOL_SP",TOL_SP}, {"TOL_COOP",TOL_COOP}, @@ -8161,6 +8181,14 @@ struct { {"V_CHARCOLORSHIFT",V_CHARCOLORSHIFT}, {"V_ALPHASHIFT",V_ALPHASHIFT}, + // Blending + {"V_BLENDSHIFT",V_BLENDSHIFT}, + {"V_BLENDMASK",V_BLENDMASK}, + {"B_ADD",B_ADD}, + {"B_SUBTRACT",B_SUBTRACT}, + {"B_REVERSESUBTRACT",B_REVERSESUBTRACT}, + {"B_MODULATE",B_MODULATE}, + //Kick Reasons {"KR_KICK",KR_KICK}, {"KR_PINGLIMIT",KR_PINGLIMIT}, @@ -8585,6 +8613,16 @@ static int lua_enumlib_mariomode_get(lua_State *L) return 1; } +static int lua_enumlib_replayfreecam_get(lua_State *L) +{ + if (dedicated) // huh? + lua_pushboolean(L, false); + else + lua_pushboolean(L, camera[R_GetViewNumber()].freecam); + + return 1; +} + static int lua_enumlib_twodlevel_get(lua_State *L) { lua_pushboolean(L, twodlevel); @@ -9189,8 +9227,6 @@ int LUA_EnumLib(lua_State *L) PUSHGETTER(globalweather, u8); PUSHGETTER(levelskynum, i32); PUSHGETTER(globallevelskynum, i32); - PUSHGETTER(mapmusflags, u16); - PUSHGETTER(mapmusposition, u32); PUSHGETTER(gravity, fxp); PUSHGETTER(gamespeed, u8); PUSHGETTER(encoremode, bool); @@ -9205,9 +9241,19 @@ int LUA_EnumLib(lua_State *L) PUSHGETTER(racecountdown, u32); PUSHGETTER(exitcountdown, u32); + lua_pushcfunction(L, lua_glib_new_getter); + lua_pushliteral(L, "mapmusflags"); + lua_glib_push_u16_getter(L, &mapmusic.flags); + lua_call(L, 2, 0); + + lua_pushcfunction(L, lua_glib_new_getter); + lua_pushliteral(L, "mapmusposition"); + lua_glib_push_u32_getter(L, &mapmusic.position); + lua_call(L, 2, 0); + lua_pushcfunction(L, lua_glib_new_getter); lua_pushliteral(L, "mapmusname"); - lua_glib_push_str_getter(L, mapmusname); + lua_glib_push_str_getter(L, mapmusic.name); lua_call(L, 2, 0); lua_pushcfunction(L, lua_glib_new_getter); @@ -9262,7 +9308,7 @@ int LUA_EnumLib(lua_State *L) lua_pushcfunction(L, lua_glib_new_getter); lua_pushliteral(L, "replayfreecam"); - lua_glib_push_bool_getter(L, &demo.freecam); + lua_pushcfunction(L, lua_enumlib_replayfreecam_get); lua_call(L, 2, 0); if (!mathlib) diff --git a/src/doomdef.h b/src/doomdef.h index 8751b6a86..d57cb53b8 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -530,9 +530,8 @@ UINT32 quickncasehash (const char *p, size_t n) #ifndef max // Double-Check with WATTCP-32's cdefs.h #define max(x, y) (((x) > (y)) ? (x) : (y)) #endif - #ifndef CLAMP -#define CLAMP(x, min_val, max_val) ((x) < (min_val) ? (min_val) : ((x) > (max_val) ? (max_val) : (x))) +#define CLAMP(x, y, z) ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x))) #endif #ifndef M_PIl diff --git a/src/doomstat.h b/src/doomstat.h index a97723b5a..495a6672a 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -30,16 +30,26 @@ // ============================= // Selected by user. -extern INT16 gamemap; -extern char mapmusname[7]; -extern UINT16 mapmusflags; -extern UINT32 mapmusposition; -extern UINT32 mapmusresume; + +typedef struct +{ + char name[7]; // Music name, up to 6-character name + void *data; // Music lump + UINT16 flags; // Track and reset bit + boolean looping; // Is this music looping? + UINT32 position; // Position to jump to + UINT32 resume; // Saved Position when music was stopped + UINT32 fadeinms; // Fade in time in ms (used for queue) +} music_t; + +extern music_t mapmusic; + #define MUSIC_TRACKMASK 0x0FFF // ----************ #define MUSIC_RELOADRESET 0x8000 // *--------------- #define MUSIC_FORCERESET 0x4000 // -*-------------- // Use other bits if necessary. +extern INT16 gamemap; extern INT16 maptol; extern UINT8 globalweather; extern INT32 curWeather; @@ -503,7 +513,6 @@ extern boolean startedInFreePlay; extern boolean legitimateexit; extern boolean comebackshowninfo; -extern tic_t curlap, bestlap; extern INT16 votelevels[4][2]; extern SINT8 votes[MAXPLAYERS]; diff --git a/src/doomtype.h b/src/doomtype.h index 429eba77e..174bba5b1 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -342,15 +342,6 @@ union FColorRGBA } ATTRPACK; typedef union FColorRGBA RGBA_t; -typedef enum -{ - POSTIMG_WATER = 1, // Underwater screen effect. - POSTIMG_MOTION = 1<<1, // Unused motion blur effect. - POSTIMG_FLIP = 1<<2, // Flipcam screen effect. - POSTIMG_HEAT = 1<<3, // Heatwave screen effect. - POSTIMG_MIRROR = 1<<4, // encore screen effect. -} postimgflag_t; - typedef UINT32 lumpnum_t; // 16 : 16 unsigned long (wad num: lump num) #define LUMPERROR UINT32_MAX @@ -389,6 +380,9 @@ unset_bit_array (bitarray_t * const array, const int value) array[value >> 3] &= ~(1<<(value & 7)); } +#define intsign(n) \ + ((n) < 0 ? -1 : (n) > 0 ? 1 : 0) + typedef UINT64 precise_t; #endif //__DOOMTYPE__ diff --git a/src/dummy/i_system.c b/src/dummy/i_system.c index f0c7e48ef..32af5f9c8 100644 --- a/src/dummy/i_system.c +++ b/src/dummy/i_system.c @@ -92,8 +92,6 @@ void I_OutputMsg(const char *error, ...) void I_StartupMouse(void){} -void I_StartupMouse2(void){} - void I_StartupKeyboard(void){} INT32 I_GetKey(void) @@ -146,8 +144,6 @@ void I_GetJoystickEvents(void){} void I_GetJoystick2Events(void){} -void I_GetMouseEvents(void){} - char *I_GetEnv(const char *name) { (void)name; diff --git a/src/f_wipe.c b/src/f_wipe.c index da5b9dac1..1523ca1d3 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -273,7 +273,7 @@ static void F_DoWipe(fademask_t *fademask) else { // pointer to transtable that this mask would use - transtbl = transtables + ((9 - *mask)<d_name, "log.txt") || !strcmp(dent->d_name, "errorlog.txt")) + if (!strncmp(dent->d_name, "log-", 4) || !strcmp(dent->d_name, "errorlog.txt")) ext |= EXT_LOADED; } diff --git a/src/g_game.c b/src/g_game.c index 83c253304..026f514e2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -84,10 +84,7 @@ static void G_DoStartVote(void); static void G_ResetDemoPlayback(char *pdemoname); -char mapmusname[7]; // Music name -UINT16 mapmusflags; // Track and reset bit -UINT32 mapmusposition; // Position to jump to -UINT32 mapmusresume; +music_t mapmusic; INT16 gamemap = 1; INT16 maptol; @@ -281,8 +278,6 @@ boolean startedInFreePlay; // Map was started in free play // Client-sided, unsynched variables (NEVER use in anything that needs to be synced with other players) boolean legitimateexit; // Did this client actually finish the match? boolean comebackshowninfo; // Have you already seen the "ATTACK OR PROTECT" message? -tic_t curlap; // Current lap time -tic_t bestlap; // Best lap time static INT16 randmapbuffer[NUMMAPS+1]; // Buffer for maps RandMap is allowed to roll tic_t hidetime; @@ -336,11 +331,6 @@ boolean precache = true; // if true, load all graphics at start INT16 prevmap, nextmap; -// save if director is enabled -// so demos can disable it by default and restore it after -static int directorstate = 0; -tic_t directortoggletimer = 0; - static CV_PossibleValue_t recordmultiplayerdemos_cons_t[] = {{0, "Disabled"}, {1, "Manual Save"}, {2, "Auto Save"}, {0, NULL}}; consvar_t cv_recordmultiplayerdemos = {"netdemo_record", "Manual Save", CV_SAVE, recordmultiplayerdemos_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -360,8 +350,6 @@ void SendWeaponPref2(void); void SendWeaponPref3(void); void SendWeaponPref4(void); -static void G_FixCamera(UINT8 view); - // don't mind me putting these here, I was lazy to figure out where else I could put those without blowing up the compiler. // chat timer thingy @@ -403,20 +391,9 @@ static CV_PossibleValue_t powermusic_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "SFX consvar_t cv_growmusic = {"growmusic", "On", CV_SAVE, powermusic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_supermusic = {"supermusic", "On", CV_SAVE, powermusic_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -/*consvar_t cv_crosshair = {"crosshair", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_crosshair2 = {"crosshair2", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_crosshair3 = {"crosshair3", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_crosshair4 = {"crosshair4", "Off", CV_SAVE, crosshair_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};*/ consvar_t cv_invertmouse = {"invertmouse", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_invertmouse2 = {"invertmouse2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -/*consvar_t cv_alwaysfreelook = {"alwaysmlook", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_alwaysfreelook2 = {"alwaysmlook2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasefreelook = {"chasemlook", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_chasefreelook2 = {"chasemlook2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mousemove = {"mousemove", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mousemove2 = {"mousemove2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};*/ +//consvar_t cv_mousemove = {"mousemove", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -//static CV_PossibleValue_t crosshair_cons_t[] = {{0, "Off"}, {1, "Cross"}, {2, "Angle"}, {3, "Point"}, {0, NULL}}; static CV_PossibleValue_t joyaxis_cons_t[] = {{0, "None"}, {1, "Left X"}, {2, "Left Y"}, {-1, "Left X-"}, {-2, "Left Y-"}, #if JOYAXISSET > 1 @@ -449,6 +426,20 @@ consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS] = { {"joyaxis4_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; +consvar_t cv_camstrafeaxis[MAXSPLITSCREENPLAYERS] = { + {"joyaxis_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis2_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis3_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis4_camstrafe", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + +consvar_t cv_camturnaxis[MAXSPLITSCREENPLAYERS] = { + {"joyaxis_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis2_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis3_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"joyaxis4_camturn", "Left X", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +}; + consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS] = { {"joyaxis_brake", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"joyaxis2_brake", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, @@ -529,26 +520,6 @@ 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}; -static CV_PossibleValue_t stretchfactor_t[] = { - {0, "Off"}, {FRACUNIT/8, "0.125"}, {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 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}; - -static CV_PossibleValue_t sloperolldist_cons_t[] = { - /*{256, "256"},*/ {512, "512"}, {768, "768"}, - {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, - {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, - {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; -consvar_t cv_sloperolldist = {"sloperolldist", "Infinite", CV_SAVE, sloperolldist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2, "Everything"}, {0, NULL}}; -consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, 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}; #if MAXPLAYERS > 16 @@ -741,6 +712,12 @@ INT32 JoyAxis(axis_input_e axissel, UINT8 player) case AXISMOVE: axisval = cv_moveaxis[player-1].value; break; + case AXISCAMTURN: + axisval = cv_camturnaxis[player-1].value; + break; + case AXISCAMSTRAFE: + axisval = cv_camstrafeaxis[player-1].value; + break; case AXISBRAKE: axisval = cv_brakeaxis[player-1].value; break; @@ -834,14 +811,6 @@ boolean InputDown(INT32 gc, UINT8 p) } } -// -// G_BuildTiccmd -// Builds a ticcmd from all of the available inputs -// or reads it from the demo buffer. -// If recording a demo, write it out -// -// set secondaryplayer true to build player 2's ticcmd in splitscreen mode -// INT32 localaiming[MAXSPLITSCREENPLAYERS]; angle_t localangle[MAXSPLITSCREENPLAYERS]; boolean camspin[MAXSPLITSCREENPLAYERS]; @@ -850,42 +819,94 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn +// +// G_BuildLocalTiccmd +// extremely basic cut down ticcmd builder +// for spectator and freecam +// this does not make the player move at all but keeps important things working +// +static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) +{ + boolean moveinput = false; + INT32 axis = 0; + const boolean usejoystick = (cv_usejoystick[(ssplayer-1)].value); + + // check for inputs and return button commands + // for stuff like joining with item button, saltyhop, honking, etc. +#define CHECKINPUT(button, AXIS, buttflag) \ + axis = JoyAxis(AXIS, ssplayer); \ + if (InputDown(button, ssplayer) || (usejoystick && axis > 0)) cmd->buttons |= buttflag; + + CHECKINPUT(gc_fire, AXISFIRE, BT_ATTACK); + CHECKINPUT(gc_drift, AXISDRIFT, BT_DRIFT); + CHECKINPUT(gc_custom1, AXISCUSTOM1, BT_CUSTOM1); + CHECKINPUT(gc_custom2, AXISCUSTOM2, BT_CUSTOM2); + CHECKINPUT(gc_custom3, AXISCUSTOM3, BT_CUSTOM3); + + // we dont need the rest of this if were in freecam state + if (freecam) + { + return; + } + + CHECKINPUT(gc_accelerate, AXISMOVE, BT_ACCELERATE); + CHECKINPUT(gc_brake, AXISBRAKE, BT_BRAKE); + +#undef CHECKINPUT + + moveinput = (InputDown(gc_turnleft, ssplayer) || InputDown(gc_turnright, ssplayer) + || InputDown(gc_aimforward, ssplayer) || InputDown(gc_aimbackward, ssplayer) || + (usejoystick && JoyAxis(AXISAIM, ssplayer) != 0) || (usejoystick && JoyAxis(AXISTURN, ssplayer) != 0)); + + axis = JoyAxis(AXISLOOKBACK, ssplayer); + camspin[ssplayer-1] = (InputDown(gc_lookback, ssplayer) || (usejoystick && axis > 0)); + + // Reset to our spec player if we watch someone else. + if ((moveinput || cmd->buttons) + && displayplayers[0] != consoleplayer && ssplayer == 1) + { + if (cv_director.value) + CV_SetValue(&cv_director, 0); + + displayplayers[0] = consoleplayer; + R_ResetViewInterpolation(0); + camera[0].reset_aiming = true; + } +} + +// +// G_BuildTiccmd +// Builds a ticcmd from all of the available inputs +// or reads it from the demo buffer. +// If recording a demo, write it out +// void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { - const UINT8 forplayer = ssplayer-1; - INT32 laim, th, tspeed, forward, side, axis; //i - const INT32 speed = 1; + INT32 laim, th, tspeed, forward, side, axis; + // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming; - boolean invertmouse, usejoystick, kbl, rd; - player_t *player; - camera_t *thiscam; + boolean turnleft, turnright; + boolean usejoystick, rd; angle_t lang; static INT32 turnheld[MAXSPLITSCREENPLAYERS]; // for accelerative turning - static boolean keyboard_look[MAXSPLITSCREENPLAYERS]; // true if lookup/down using keyboard static boolean resetdown[MAXSPLITSCREENPLAYERS]; // don't cam reset every frame - const boolean lookaxis = cv_lookaxis[forplayer].value; + if (demo.playback) + return; + + const UINT8 forplayer = (ssplayer-1); + player_t *player = ((ssplayer == 1) ? &players[consoleplayer] : &players[displayplayers[forplayer]]); + + camera_t *thiscam = &camera[forplayer]; + const boolean freecam = camera[forplayer].freecam; + const boolean analogjoystickmove = cv_usejoystick[forplayer].value && !Joystick[forplayer].bGamepadStyle; const boolean gamepadjoystickmove = cv_usejoystick[forplayer].value && Joystick[forplayer].bGamepadStyle; - if (demo.playback) return; - - if (ssplayer == 1) - player = &players[consoleplayer]; - else - player = &players[displayplayers[forplayer]]; - - if (ssplayer == 2) - thiscam = (player->bot == 2 ? &camera[0] : &camera[forplayer]); - else - thiscam = &camera[forplayer]; - lang = localangle[forplayer]; laim = localaiming[forplayer]; th = turnheld[forplayer]; - kbl = keyboard_look[forplayer]; rd = resetdown[forplayer]; switch (ssplayer) @@ -915,25 +936,17 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) return; } - switch (ssplayer) + // dumbass thing so we can use a few buttons but dont accidentally drive away + if (player->spectator || freecam) { - case 2: - mouseaiming = player->spectator; //(PLAYER2INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook2.value; - invertmouse = cv_invertmouse2.value; - break; - case 3: - mouseaiming = false; - invertmouse = false; - break; - case 4: - mouseaiming = false; - invertmouse = false; - break; - case 1: - default: - mouseaiming = player->spectator; //(PLAYER1INPUTDOWN(gc_mouseaiming)) ^ cv_alwaysfreelook.value; - invertmouse = cv_invertmouse.value; - break; + cmd->angleturn = (INT16)(lang >> 16); + G_BuildLocalTiccmd(cmd, ssplayer, freecam); + + // let lua override everything + if (gamestate == GS_LEVEL) + LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); + + return; } usejoystick = (analogjoystickmove || gamepadjoystickmove); @@ -967,7 +980,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (th < SLOWTURNTICS) tspeed = cv_turnsmooth.value == 2 ? 2 : 0; // slow turn else - tspeed = speed; + tspeed = 1; cmd->driftturn = 0; @@ -993,14 +1006,14 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) side += ((axis * sidemove[0]) >> 10); } - if (player->spectator || cv_mouseturn.value) + if (cv_mouseturn.value) { //THIS WORKS WTF???????? cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); cmd->driftturn = (INT16)(cmd->driftturn - ((mousex*(encoremode ? -1 : 1)*8))); } - if (player->spectator || objectplacing) // SRB2Kart: spectators need special controls + if (objectplacing) // SRB2Kart: spectators need special controls // not anymore huehuehue { axis = JoyAxis(AXISMOVE, ssplayer); if (InputDown(gc_accelerate, ssplayer) || (usejoystick && axis > 0)) @@ -1082,54 +1095,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else rd = false; - // spectator aiming shit, ahhhh... - { - INT32 player_invert = invertmouse ? -1 : 1; - INT32 screen_invert = - (player->mo && (player->mo->eflags & MFE_VERTICALFLIP) - && (!thiscam->chase || player->pflags & PF_FLIPCAM)) //because chasecam's not inverted - ? -1 : 1; // set to -1 or 1 to multiply - - // mouse look stuff (mouse look is not the same as mouse aim) - if (mouseaiming && player->spectator) - { - kbl = false; - - // looking up/down - laim += (mlooky<<19)*player_invert*screen_invert; - } - - axis = JoyAxis(AXISLOOK, ssplayer); - if (analogjoystickmove && axis != 0 && lookaxis && player->spectator) - laim += (axis<<16) * screen_invert; - - // spring back if not using keyboard neither mouselookin' - if (!kbl && !lookaxis && !mouseaiming) - laim = 0; - - if (player->spectator) - { - if (InputDown(gc_lookup, ssplayer) || (gamepadjoystickmove && axis < 0)) - { - laim += KB_LOOKSPEED * screen_invert; - kbl = true; - } - else if (InputDown(gc_lookdown, ssplayer) || (gamepadjoystickmove && axis > 0)) - { - laim -= KB_LOOKSPEED * screen_invert; - kbl = true; - } - } - - if (InputDown(gc_centerview, ssplayer)) // No need to put a spectator limit on this one though :V - laim = 0; - - // accept no mlook for network games - if (!cv_allowmlook.value) - laim = 0; - - cmd->aiming = G_ClipAimingPitch(&laim); - } + cmd->aiming = G_ClipAimingPitch(&laim); mousex = mousey = mlooky = 0; @@ -1181,7 +1147,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { localangle[forplayer] = lang; localaiming[forplayer] = laim; - keyboard_look[forplayer] = kbl; turnheld[forplayer] = th; resetdown[forplayer] = rd; axis = JoyAxis(AXISLOOKBACK, ssplayer); @@ -1202,8 +1167,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) LUA_HookTiccmd(player, cmd, HOOK(PlayerCmd)); //Reset away view if a command is given. - if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) - && displayplayers[0] != consoleplayer && ssplayer == 1) + if (displayplayers[0] != consoleplayer && ssplayer == 1 + && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) { displayplayers[0] = consoleplayer; G_FixCamera(1); @@ -1219,7 +1184,7 @@ static void G_DoLoadLevel(boolean resetplayer) // Saturn Music Feature stuffs S_ResetKeepAndSpecialMus(); - S_CheckMap(); + S_KeepMusic(); // Make sure objectplace is OFF when you first start the level! OP_ResetObjectplace(); @@ -1282,17 +1247,18 @@ static void G_DoLoadLevel(boolean resetplayer) joy4xmove[i] = joy4ymove[i] = 0; } mousex = mousey = 0; - mouse2x = mouse2y = 0; // clear hud messages remains (usually from game startup) CON_ClearHUD(); + server_lagless = cv_lagless.value; + G_ResetAllDeviceRumbles(); } static INT32 pausedelay = 0; -static INT32 camtoggledelay, camtoggledelay2, camtoggledelay3, camtoggledelay4 = 0; -static INT32 spectatedelay, spectatedelay2, spectatedelay3, spectatedelay4 = 0; +static INT32 camtoggledelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; +static INT32 spectatedelay[MAXSPLITSCREENPLAYERS] = {0,0,0,0}; // // G_Responder @@ -1395,7 +1361,7 @@ boolean G_Responder(event_t *ev) } } - if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback && !demo.freecam) + if (gamestate == GS_LEVEL && ev->type == ev_keydown && multiplayer && demo.playback) { if (ev->data1 == gamecontrolbis[gc_viewpoint][0] || ev->data1 == gamecontrolbis[gc_viewpoint][1]) { @@ -1473,72 +1439,72 @@ boolean G_Responder(event_t *ev) if (ev->data1 == gamecontrol[gc_camtoggle][0] || ev->data1 == gamecontrol[gc_camtoggle][1]) { - if (!camtoggledelay) + if (!camtoggledelay[0]) { - camtoggledelay = NEWTICRATE / 7; + camtoggledelay[0] = NEWTICRATE / 7; CV_SetValue(&cv_chasecam[0], cv_chasecam[0].value ? 0 : 1); } } if (ev->data1 == gamecontrolbis[gc_camtoggle][0] || ev->data1 == gamecontrolbis[gc_camtoggle][1]) { - if (!camtoggledelay2) + if (!camtoggledelay[1]) { - camtoggledelay2 = NEWTICRATE / 7; + camtoggledelay[1] = NEWTICRATE / 7; CV_SetValue(&cv_chasecam[1], cv_chasecam[1].value ? 0 : 1); } } if (ev->data1 == gamecontrol3[gc_camtoggle][0] || ev->data1 == gamecontrol3[gc_camtoggle][1]) { - if (!camtoggledelay3) + if (!camtoggledelay[2]) { - camtoggledelay3 = NEWTICRATE / 7; + camtoggledelay[2] = NEWTICRATE / 7; CV_SetValue(&cv_chasecam[2], cv_chasecam[2].value ? 0 : 1); } } if (ev->data1 == gamecontrol4[gc_camtoggle][0] || ev->data1 == gamecontrol4[gc_camtoggle][1]) { - if (!camtoggledelay4) + if (!camtoggledelay[3]) { - camtoggledelay4 = NEWTICRATE / 7; + camtoggledelay[3] = NEWTICRATE / 7; CV_SetValue(&cv_chasecam[3], cv_chasecam[3].value ? 0 : 1); } } if (ev->data1 == gamecontrol[gc_spectate][0] || ev->data1 == gamecontrol[gc_spectate][1]) { - if (!spectatedelay) + if (!spectatedelay[0]) { - spectatedelay = NEWTICRATE / 7; + spectatedelay[0] = NEWTICRATE / 7; COM_ImmedExecute("changeteam spectator"); } } if (ev->data1 == gamecontrolbis[gc_spectate][0] || ev->data1 == gamecontrolbis[gc_spectate][1]) { - if (!spectatedelay2) + if (!spectatedelay[1]) { - spectatedelay2 = NEWTICRATE / 7; + spectatedelay[1] = NEWTICRATE / 7; COM_ImmedExecute("changeteam2 spectator"); } } if (ev->data1 == gamecontrol3[gc_spectate][0] || ev->data1 == gamecontrol3[gc_spectate][1]) { - if (!spectatedelay3) + if (!spectatedelay[2]) { - spectatedelay3 = NEWTICRATE / 7; + spectatedelay[2] = NEWTICRATE / 7; COM_ImmedExecute("changeteam3 spectator"); } } if (ev->data1 == gamecontrol4[gc_spectate][0] || ev->data1 == gamecontrol4[gc_spectate][1]) { - if (!spectatedelay4) + if (!spectatedelay[3]) { - spectatedelay4 = NEWTICRATE / 7; + spectatedelay[3] = NEWTICRATE / 7; COM_ImmedExecute("changeteam4 spectator"); } } @@ -1548,6 +1514,23 @@ boolean G_Responder(event_t *ev) K_ToggleDirector(); } + if (ev->data1 == gamecontrol[gc_freecam][0] || ev->data1 == gamecontrol[gc_freecam][1]) + { + P_ToggleDemoCamera(0); + } + else if (ev->data1 == gamecontrolbis[gc_freecam][0] || ev->data1 == gamecontrolbis[gc_freecam][1]) + { + P_ToggleDemoCamera(1); + } + else if (ev->data1 == gamecontrol3[gc_freecam][0] || ev->data1 == gamecontrol3[gc_freecam][1]) + { + P_ToggleDemoCamera(2); + } + else if (ev->data1 == gamecontrol4[gc_freecam][0] || ev->data1 == gamecontrol4[gc_freecam][1]) + { + P_ToggleDemoCamera(3); + } + return true; case ev_keyup: @@ -1682,13 +1665,14 @@ INT32 G_CountPlayersPotentiallyViewable(boolean active) // Reset camera position, angle and interpolation on a view // after changing state. // -static void G_FixCamera(UINT8 view) +void G_FixCamera(UINT8 view) { player_t *player = &players[displayplayers[view - 1]]; // The order of displayplayers can change, which would // invalidate localangle. - localangle[view - 1] = (angle_t)(player->cmd.angleturn << 16); + if (!P_MobjWasRemoved(player->mo)) + localangle[view - 1] = player->mo->angle; P_ResetCamera(player, &camera[view - 1]); @@ -1728,13 +1712,6 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) viewnum = playersviewable; splitscreen = viewnum-1; - /* Prepare extra views for G_FindView to pass. */ - for (viewd = splits+1; viewd < viewnum; ++viewd) - { - displayplayerp = (&displayplayers[viewd-1]); - (*displayplayerp) = INT32_MAX; - } - R_ExecuteSetViewSize(); } @@ -1752,10 +1729,17 @@ void G_ResetView(UINT8 viewnum, INT32 playernum, boolean onlyactive) (*displayplayerp) = playernumd; /* If a viewpoint changes, reset the camera to clear uninitialized memory. */ - G_FixCamera(viewd); + if (viewnum > splits) + { + G_FixCamera(viewd); + } + else if ((*displayplayerp) != olddisplayplayer) + { + G_FixCamera(viewnum); + } } - if (viewnum == 1 && demo.playback) + if (demo.playback && viewnum == 1) consoleplayer = displayplayers[0]; } @@ -1769,6 +1753,10 @@ void G_AdjustView(UINT8 viewnum, INT32 offset, boolean onlyactive) INT32 *displayplayerp, oldview; displayplayerp = &displayplayers[viewnum-1]; oldview = (*displayplayerp); + + // turn off the freecam + camera[viewnum-1].freecam = false; + G_ResetView(viewnum, ( (*displayplayerp) + offset ), onlyactive); // If no other view could be found, go back to what we had. @@ -1975,23 +1963,14 @@ void G_Ticker(boolean run) if (pausedelay) pausedelay--; - if (camtoggledelay) - camtoggledelay--; - if (camtoggledelay2) - camtoggledelay2--; - if (camtoggledelay3) - camtoggledelay3--; - if (camtoggledelay4) - camtoggledelay4--; + for (UINT8 j = 0; j < MAXSPLITSCREENPLAYERS;j++) + { + if (camtoggledelay[j]) + camtoggledelay[j]--; - if (spectatedelay) - spectatedelay--; - if (spectatedelay2) - spectatedelay2--; - if (spectatedelay3) - spectatedelay3--; - if (spectatedelay4) - spectatedelay4--; + if (spectatedelay[j]) + spectatedelay[j]--; + } if (gametic % NAMECHANGERATE == 0) { @@ -2288,13 +2267,9 @@ void G_PlayerReborn(INT32 player) if (p-players == consoleplayer) { - if (mapmusflags & MUSIC_RELOADRESET) + if (mapmusic.flags & MUSIC_RELOADRESET) { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); - mapmusposition = mapheaderinfo[gamemap-1]->muspos; - mapmusresume = 0; + S_HandleReloadResetMusic(); songcredit = true; } } @@ -4052,7 +4027,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool globalweather = mapheaderinfo[gamemap-1]->weather; // Don't carry over custom music change to another map. - mapmusflags |= MUSIC_RELOADRESET; + mapmusic.flags |= MUSIC_RELOADRESET; automapactive = false; imcontinuing = false; @@ -4532,7 +4507,7 @@ void G_ReadDemoExtraData(void) if (extradata & DXD_RESPAWN) { if (players[p].mo) - P_DamageMobj(players[p].mo, NULL, NULL, 10000); // Is this how this should work..? + P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); // Is this how this should work..? } if (extradata & DXD_SKIN) { @@ -4598,7 +4573,7 @@ void G_ReadDemoExtraData(void) { players[p].spectator = true; if (players[p].mo) - P_DamageMobj(players[p].mo, NULL, NULL, 10000); + P_DamageMobj(players[p].mo, NULL, NULL, DMG_INSTAKILL); else players[p].playerstate = PST_REBORN; } @@ -4625,18 +4600,23 @@ void G_ReadDemoExtraData(void) while (p != DW_END) { UINT32 rng; + UINT32 checkrng; switch (p) { case DW_RNG: rng = READUINT32(demobuf.p); - if (P_GetRandSeed() != rng) + checkrng = P_GetRandSeed(); + if (checkrng != rng) { - P_SetRandSeed(rng); - if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + { + CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (RNG)!\n")); + CONS_Printf("expected rng %d got %d\n", rng, checkrng); + } demosynced = false; + + P_SetRandSeed(rng); } } @@ -4902,7 +4882,7 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim) ghostext[playernum].flags |= EZT_HIT; ghostext[playernum].hits++; ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, NULL); - ghostext[playernum].hitlist[ghostext[playernum].hits-1] = victim; + P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim); } void G_WriteAllGhostTics(void) @@ -4913,6 +4893,7 @@ void G_WriteAllGhostTics(void) UINT8 *save_demo_p = demobuf.p; #define CHECKSPACE(num) if (demobuf.p+(num) > demoend) { demobuf.p = save_demo_p; G_CheckDemoStatus(); return; } + boolean toobig = false; INT32 i, counter = leveltime; for (i = 0; i < MAXPLAYERS; i++) @@ -4925,18 +4906,32 @@ void G_WriteAllGhostTics(void) counter++; - if (counter % cv_netdemosyncquality.value != 0) // Only write 1 in this many ghost datas per tic to cut down on multiplayer replay size. + if (multiplayer && ((counter % cv_netdemosyncquality.value) != 0)) // Only write 1 in this many ghost datas per tic to cut down on multiplayer replay size. continue; CHECKSPACE(1); WRITEUINT8(demobuf.p, i); G_WriteGhostTic(players[i].mo, i); + + // attention here for the ticcmd size! + // latest demos with mouse aiming byte in ticcmd + if (demobuf.p >= demoend - (13 + 9 + 9)) + { + toobig = true; + break; + } } CHECKSPACE(1); WRITEUINT8(demobuf.p, 0xFF); + if (toobig) + { + G_CheckDemoStatus(); // no more space + return; + } + #undef CHECKSPACE } @@ -5111,6 +5106,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEFIXED(demobuf.p,mo->y); WRITEFIXED(demobuf.p,mo->z); WRITEANGLE(demobuf.p,mo->angle); + P_SetTarget(ghostext[playernum].hitlist+i, NULL); } Z_Free(ghostext[playernum].hitlist); ghostext[playernum].hits = 0; @@ -5133,23 +5129,17 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) } *ziptic_p = ziptic; - - // attention here for the ticcmd size! - // latest demos with mouse aiming byte in ticcmd - if (demobuf.p >= demoend - (13 + 9)) - { - G_CheckDemoStatus(); // no more space - return; - } #undef CHECKSPACE } void G_ConsAllGhostTics(void) { - if (!demobuf.p) + UINT8 p; + + if (!demobuf.p || !demo.deferstart) return; - UINT8 p = READUINT8(demobuf.p); + p = READUINT8(demobuf.p); while (p != 0xFF) { @@ -5175,8 +5165,6 @@ void G_ConsGhostTic(INT32 playernum) fixed_t syncleeway; boolean nightsfail = false; - if (!demobuf.p || !demo.deferstart) - return; if (!(demoflags & DF_GHOST)) return; // No ghost data to use. @@ -5259,7 +5247,10 @@ void G_ConsGhostTic(INT32 playernum) if (mobj && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + { + CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (health)!\n")); + CONS_Printf("expected health %d got %d\n", health, mobj->health); + } demosynced = false; P_DamageMobj(mobj, players[0].mo, players[0].mo, 1); } @@ -5292,7 +5283,7 @@ void G_ConsGhostTic(INT32 playernum) if (ghostext[playernum].desyncframes >= 2) { if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + CONS_Alert(CONS_WARNING, "Demo playback has desynced (player %s)!\n", player_names[playernum]); demosynced = false; P_UnsetThingPosition(testmo); @@ -5322,7 +5313,11 @@ void G_ConsGhostTic(INT32 playernum) ) { if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + { + CONS_Alert(CONS_WARNING, "Demo playback has desynced (item/bumpers)!(player %s)!\n", player_names[playernum]); + CONS_Printf("expected item type %d got %d\n", ghostext[playernum].kartitem, players[playernum].kartstuff[k_itemtype]); + CONS_Printf("expected item amount %d got %d\n", ghostext[playernum].kartamount, players[playernum].kartstuff[k_itemamount]); + } demosynced = false; players[playernum].kartstuff[k_itemtype] = ghostext[playernum].kartitem; @@ -5769,9 +5764,6 @@ void G_ConfirmRewind(tic_t rewindtime) COM_BufInsertText("renderview on\n"); - if (demo.freecam) - return; // don't touch from there - splitscreen = oldss; displayplayers[0] = olddp1; displayplayers[1] = olddp2; @@ -6014,7 +6006,7 @@ void G_RecordDemo(const char *name) maxsize = cv_maxdemosize.value*1024*1024; - demobuf.buffer = Z_Malloc(maxsize, PU_STATIC, NULL); + demobuf.buffer = Z_Malloc(maxsize + 100*1024, PU_STATIC, NULL); demoend = demobuf.buffer + maxsize; if (demobuf.buffer) @@ -6032,7 +6024,7 @@ void G_RecordMetal(void) Z_Free(demobuf.buffer); demobuf.p = NULL; metalrecording = false; - demobuf.buffer = Z_Malloc(maxsize, PU_STATIC, NULL); + demobuf.buffer = Z_Malloc(maxsize + 100*1024, PU_STATIC, NULL); demoend = demobuf.buffer + maxsize; if (demobuf.buffer) @@ -7186,15 +7178,14 @@ void G_DoPlayDemo(char *defdemoname) //LUA_HookInt(gamemap, HOOK(MapChange)); - displayplayers[0] = consoleplayer = 0; + consoleplayer = 0; memset(playeringame,0,sizeof(playeringame)); + memset(displayplayers,0,sizeof(displayplayers)); + memset(camera,0,sizeof(camera)); // reset freecam // Load players that were in-game when the map started p = READUINT8(demobuf.p); - for (i = 1; i < MAXSPLITSCREENPLAYERS; i++) - displayplayers[i] = INT32_MAX; - while (p != 0xFF) { spectator = false; @@ -7310,8 +7301,8 @@ post_compat: players[i].kartweight = kartweight[i]; } - directorstate = cv_director.value; - CV_SetValue(&cv_director, 0); + if (cv_director.value) + CV_SetValue(&cv_director, 0); demo.deferstart = true; } @@ -7836,7 +7827,6 @@ void G_DoneLevelLoad(void) // Stops metal sonic's demo. Separate from other functions because metal + replays can coexist void G_StopMetalDemo(void) { - // Metal Sonic finishing doesn't end the game, dammit. Z_Free(metalbuffer); metalbuffer = NULL; @@ -7876,11 +7866,6 @@ void G_StopDemo(void) { Z_Free(demobuf.buffer); demobuf.buffer = NULL; - if (demo.playback) - { - CV_SetValue(&cv_director, directorstate); - directorstate = 0; - } demo.playback = false; if (demo.title) modeattacking = false; @@ -7888,14 +7873,13 @@ void G_StopDemo(void) demo.timing = false; singletics = false; - demo.freecam = false; - // reset democam shit too: - democam.cam = NULL; - democam.soundmobj = NULL; - democam.localangle = 0; - democam.localaiming = 0; - democam.turnheld = false; - democam.keyboardlook = false; + UINT8 i; + for (i = 0; i < MAXSPLITSCREENPLAYERS; ++i) + { + camera[i].freecam = false; + camera[i].localangle = 0; + camera[i].localaiming = 0; + } CV_SetValue(&cv_playbackspeed, 1); demo.rewinding = false; @@ -8177,32 +8161,3 @@ boolean G_GetRetryFlag(void) { return retrying; } - -// Time utility functions -INT32 G_TicsToHours(tic_t tics) -{ - return tics/(3600*TICRATE); -} - -INT32 G_TicsToMinutes(tic_t tics, boolean full) -{ - if (full) - return tics/(60*TICRATE); - else - return tics/(60*TICRATE)%60; -} - -INT32 G_TicsToSeconds(tic_t tics) -{ - return (tics/TICRATE)%60; -} - -INT32 G_TicsToCentiseconds(tic_t tics) -{ - return (INT32)((tics%TICRATE) * (100.00f/TICRATE)); -} - -INT32 G_TicsToMilliseconds(tic_t tics) -{ - return (INT32)((tics%TICRATE) * (1000.00f/TICRATE)); -} diff --git a/src/g_game.h b/src/g_game.h index d092f229f..deec04226 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -66,9 +66,6 @@ struct demovars_s { DSM_WILLSAVE, DSM_SAVED } savemode; - - boolean freecam; - }; extern struct demovars_s demo; @@ -118,12 +115,12 @@ extern consvar_t cv_songcredits; extern consvar_t cv_showfreeplay; extern consvar_t cv_growmusic, cv_supermusic; extern consvar_t cv_pauseifunfocused; -//extern consvar_t cv_crosshair, cv_crosshair2, cv_crosshair3, cv_crosshair4; -extern consvar_t cv_invertmouse/*, cv_alwaysfreelook, cv_chasefreelook, cv_mousemove*/; -extern consvar_t cv_invertmouse2/*, cv_alwaysfreelook2, cv_chasefreelook2, cv_mousemove2*/; +extern consvar_t cv_invertmouse; extern consvar_t cv_turnaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_moveaxis[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_camturnaxis[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_camstrafeaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_brakeaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_aimaxis[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_lookaxis[MAXSPLITSCREENPLAYERS]; @@ -149,18 +146,19 @@ extern consvar_t cv_##name##_yoffset; DECL_HUD_OFFSET_X(name)\ DECL_HUD_OFFSET_Y(name) -DECL_HUD_OFFSET(item); // Item box -DECL_HUD_OFFSET(time); // Time -DECL_HUD_OFFSET(laps); // Number of laps -DECL_HUD_OFFSET(dnft); // Countdown (did not finish timer) -DECL_HUD_OFFSET(speed); // Speedometer -DECL_HUD_OFFSET(posi); // Position in race -DECL_HUD_OFFSET(face); // Mini rankings -DECL_HUD_OFFSET(stcd); // Starting countdown +DECL_HUD_OFFSET(item); // Item box +DECL_HUD_OFFSET(time); // Time +DECL_HUD_OFFSET(laps); // Number of laps +DECL_HUD_OFFSET(dnft); // Countdown (did not finish timer) +DECL_HUD_OFFSET(speed); // Speedometer +DECL_HUD_OFFSET(posi); // Position in race +DECL_HUD_OFFSET(wheel); // RA Wheel +DECL_HUD_OFFSET(face); // Mini rankings +DECL_HUD_OFFSET(stcd); // Starting countdown DECL_HUD_OFFSET_Y(chek); // Check gfx -DECL_HUD_OFFSET(mini); // Minimap -DECL_HUD_OFFSET(want); // Wanted -DECL_HUD_OFFSET(stat); // Stats +DECL_HUD_OFFSET(mini); // Minimap +DECL_HUD_OFFSET(want); // Wanted +DECL_HUD_OFFSET(stat); // Stats #undef DECL_HUD_OFFSET #undef DECL_HUD_OFFSET_X @@ -182,6 +180,7 @@ extern consvar_t cv_sliptideroll; extern consvar_t cv_slamsound; extern consvar_t cv_sloperolldist; extern consvar_t cv_sparkroll; +extern consvar_t cv_spinoutroll; extern consvar_t cv_cechotoggle; @@ -194,6 +193,8 @@ typedef enum AXISNONE = 0, AXISTURN, AXISMOVE, + AXISCAMTURN, + AXISCAMSTRAFE, AXISBRAKE, AXISAIM, AXISLOOK, @@ -231,8 +232,6 @@ extern angle_t localangle[MAXSPLITSCREENPLAYERS]; extern INT32 localaiming[MAXSPLITSCREENPLAYERS]; // should be an angle_t but signed extern boolean camspin[MAXSPLITSCREENPLAYERS]; // SRB2Kart -extern tic_t directortoggletimer; - // // GAME // @@ -434,11 +433,32 @@ void G_ClearRecords(void); tic_t G_GetBestTime(INT16 map); -FUNCMATH INT32 G_TicsToHours(tic_t tics); -FUNCMATH INT32 G_TicsToMinutes(tic_t tics, boolean full); -FUNCMATH INT32 G_TicsToSeconds(tic_t tics); -FUNCMATH INT32 G_TicsToCentiseconds(tic_t tics); -FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics); +// Time utility functions + +FUNCINLINE static ATTRINLINE FUNCMATH INT32 G_TicsToHours(tic_t tics) +{ + return tics/(3600*TICRATE); +} + +FUNCINLINE static ATTRINLINE FUNCMATH INT32 G_TicsToMinutes(tic_t tics, boolean full) +{ + return full ? (tics/(60*TICRATE)) : (tics/(60*TICRATE)%60); +} + +FUNCINLINE static ATTRINLINE FUNCMATH INT32 G_TicsToSeconds(tic_t tics) +{ + return (tics/TICRATE)%60; +} + +FUNCINLINE static ATTRINLINE FUNCMATH INT32 G_TicsToCentiseconds(tic_t tics) +{ + return (INT32)((tics%TICRATE) * (100.00f/TICRATE)); +} + +FUNCINLINE static ATTRINLINE FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics) +{ + return (INT32)((tics%TICRATE) * (1000.00f/TICRATE)); +} // Don't split up TOL handling INT16 G_TOLFlag(INT32 pgametype); @@ -446,4 +466,6 @@ INT16 G_TOLFlag(INT32 pgametype); INT16 G_RandMap(INT16 tolflags, INT16 pprevmap, boolean ignorebuffer, UINT8 maphell, boolean callagainsoon, INT16 *extbuffer); void G_AddMapToBuffer(INT16 map); +void G_FixCamera(UINT8 view); + #endif diff --git a/src/g_input.c b/src/g_input.c index 1f3c69464..f0121f37d 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -33,9 +33,7 @@ static CV_PossibleValue_t turnsmooth_cons_t[] = {{2, "Slow"}, {1, "Fast"}, {0, " // mouse values are used once consvar_t cv_mousesens = {"mousesens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mousesens2 = {"mousesens2", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_mouseysens = {"mouseysens", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_mouseysens2 = {"mouseysens2", "20", CV_SAVE, mousesens_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_controlperkey = {"controlperkey", "One", CV_SAVE, onecontrolperkey_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_turnsmooth = {"turnsmoothing", "Slow", CV_SAVE, turnsmooth_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -125,8 +123,6 @@ static void led_off_handle4(void) INT32 mousex, mousey; INT32 mlooky; // like mousey but with a custom sensitivity for mlook -INT32 mouse2x, mouse2y, mlook2y; - // joystick values are repeated INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], joy2ymove[JOYAXISSET], joy3xmove[JOYAXISSET], joy3ymove[JOYAXISSET], joy4xmove[JOYAXISSET], joy4ymove[JOYAXISSET]; @@ -148,7 +144,6 @@ typedef struct } dclick_t; static dclick_t mousedclicks[MOUSEBUTTONS]; static dclick_t joydclicks[JOYBUTTONS + JOYHATS*4]; -static dclick_t mouse2dclicks[MOUSEBUTTONS]; static dclick_t joy2dclicks[JOYBUTTONS + JOYHATS*4]; static dclick_t joy3dclicks[JOYBUTTONS + JOYHATS*4]; static dclick_t joy4dclicks[JOYBUTTONS + JOYHATS*4]; @@ -233,14 +228,6 @@ void G_MapEventsToControls(event_t *ev) if (ev->data3 != INT32_MAX) joy4ymove[i] = ev->data3; break; - case ev_mouse2: // buttons are virtual keys - if (menuactive || CON_Ready() || chat_on) - break; - mouse2x = (INT32)(ev->data2*((cv_mousesens2.value*cv_mousesens2.value)/110.0f + 0.1f)); - mouse2y = (INT32)(ev->data3*((cv_mousesens2.value*cv_mousesens2.value)/110.0f + 0.1f)); - mlook2y = (INT32)(ev->data3*((cv_mouseysens2.value*cv_mousesens2.value)/110.0f + 0.1f)); - break; - default: break; } @@ -258,12 +245,6 @@ void G_MapEventsToControls(event_t *ev) gamekeydown[KEY_DBLJOY1+i] = flag; } - for (i = 0; i < MOUSEBUTTONS; i++) - { - flag = G_CheckDoubleClick(gamekeydown[KEY_2MOUSE1+i], &mouse2dclicks[i]); - gamekeydown[KEY_DBL2MOUSE1+i] = flag; - } - for (i = 0; i < JOYBUTTONS + JOYHATS*4; i++) { flag = G_CheckDoubleClick(gamekeydown[KEY_2JOY1+i], &joy2dclicks[i]); @@ -401,18 +382,8 @@ static keyname_t keynames[] = {KEY_MOUSE1+5,"MOUSE6"}, {KEY_MOUSE1+6,"MOUSE7"}, {KEY_MOUSE1+7,"MOUSE8"}, - {KEY_2MOUSE1+0,"SEC_MOUSE2"}, // BP: sorry my mouse handler swap button 1 and 2 - {KEY_2MOUSE1+1,"SEC_MOUSE1"}, - {KEY_2MOUSE1+2,"SEC_MOUSE3"}, - {KEY_2MOUSE1+3,"SEC_MOUSE4"}, - {KEY_2MOUSE1+4,"SEC_MOUSE5"}, - {KEY_2MOUSE1+5,"SEC_MOUSE6"}, - {KEY_2MOUSE1+6,"SEC_MOUSE7"}, - {KEY_2MOUSE1+7,"SEC_MOUSE8"}, {KEY_MOUSEWHEELUP, "Wheel 1 UP"}, {KEY_MOUSEWHEELDOWN, "Wheel 1 Down"}, - {KEY_2MOUSEWHEELUP, "Wheel 2 UP"}, - {KEY_2MOUSEWHEELDOWN, "Wheel 2 Down"}, {KEY_JOY1+0, "JOY1"}, {KEY_JOY1+1, "JOY2"}, @@ -423,7 +394,7 @@ static keyname_t keynames[] = {KEY_JOY1+6, "JOY7"}, {KEY_JOY1+7, "JOY8"}, {KEY_JOY1+8, "JOY9"}, - + #if !defined (NOMOREJOYBTN_1S) // we use up to 32 buttons in DirectInput {KEY_JOY1+9, "JOY10"}, @@ -476,14 +447,6 @@ static keyname_t keynames[] = {KEY_DBLMOUSE1+5, "DBLMOUSE6"}, {KEY_DBLMOUSE1+6, "DBLMOUSE7"}, {KEY_DBLMOUSE1+7, "DBLMOUSE8"}, - {KEY_DBL2MOUSE1+0, "DBLSEC_MOUSE2"}, // BP: sorry my mouse handler swap button 1 and 2 - {KEY_DBL2MOUSE1+1, "DBLSEC_MOUSE1"}, - {KEY_DBL2MOUSE1+2, "DBLSEC_MOUSE3"}, - {KEY_DBL2MOUSE1+3, "DBLSEC_MOUSE4"}, - {KEY_DBL2MOUSE1+4, "DBLSEC_MOUSE5"}, - {KEY_DBL2MOUSE1+5, "DBLSEC_MOUSE6"}, - {KEY_DBL2MOUSE1+6, "DBLSEC_MOUSE7"}, - {KEY_DBL2MOUSE1+7, "DBLSEC_MOUSE8"}, {KEY_DBLJOY1+0, "DBLJOY1"}, {KEY_DBLJOY1+1, "DBLJOY2"}, @@ -868,7 +831,6 @@ static keyname_t keynames[] = {KEY_DBL4HAT1+13, "DBLFOR_HATDOWN4"}, {KEY_DBL4HAT1+14, "DBLFOR_HATLEFT4"}, {KEY_DBL4HAT1+15, "DBLFOR_HATRIGHT4"}, - }; static const char *gamecontrolname[num_gamecontrols] = @@ -902,6 +864,11 @@ static const char *gamecontrolname[num_gamecontrols] = "custom2", "custom3", "director", + "freecam", + "camfloat", + "camsink", + "strafeleft", + "straferight", }; #define NUMKEYNAMES (sizeof (keynames)/sizeof (keyname_t)) @@ -928,36 +895,27 @@ UINT16 G_GetSkinColor(INT32 playernum) { case 0: return cv_playercolor.value; - break; case 1: return cv_playercolor2.value; - break; case 2: return cv_playercolor3.value; - break; case 3: return cv_playercolor4.value; - break; default: return 0; - break; } + + return 0; } void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color) { - INT32 device; UINT16 skincolor; byteColor_t byte_color; I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); if (cv_gamepadled[playernum].value == 0) - return; - - device = cv_usejoystick[playernum].value; - - if (device <= 0) { return; } @@ -965,19 +923,14 @@ void G_SetPlayerGamepadIndicatorColor(INT32 playernum, UINT16 color) skincolor = color ? color : G_GetSkinColor(playernum); byte_color = V_GetColor(colortranslations[skincolor][8]).s; - I_SetGamepadIndicatorColor(device, byte_color.red, byte_color.green, byte_color.blue); + I_SetGamepadIndicatorColor(playernum, byte_color.red, byte_color.green, byte_color.blue); } static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) { if (cv_gamepadled[playernum].value == 0) { - INT32 device = cv_usejoystick[playernum].value; - - if (device <= 0) - return; - - I_SetGamepadIndicatorColor(device, 0, 0, 255); + I_SetGamepadIndicatorColor(playernum, 0, 0, 255); } else G_SetPlayerGamepadIndicatorColor(playernum, 0); @@ -985,16 +938,7 @@ static void G_ResetPlayerGamepadIndicatorColor(INT32 playernum) static void G_ResetPlayerDeviceRumble(INT32 playernum) { - INT32 device_id; - - device_id = cv_usejoystick[playernum].value; - - if (device_id < 1) - { - return; - } - - I_GamepadRumble(device_id, 0, 0, 0); + I_GamepadRumble(playernum, 0, 0, 0); } void G_ResetAllDeviceRumbles(void) @@ -1006,29 +950,20 @@ void G_ResetAllDeviceRumbles(void) for (i = 0; i < devices; i++) { - INT32 device_id = cv_usejoystick[i].value; - - I_GamepadRumble(device_id, 0, 0, 0); + I_GamepadRumble(devices, 0, 0, 0); } } void G_PlayerDeviceRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration) { - INT32 device_id; + I_Assert(playernum >= 0 && playernum < MAXSPLITSCREENPLAYERS); if (cv_rumble[playernum].value == 0) { return; } - device_id = cv_usejoystick[playernum].value; - - if (device_id < 1) - { - return; - } - - I_GamepadRumble(device_id, low_strength, high_strength, duration); + I_GamepadRumble(playernum, low_strength, high_strength, duration); } // diff --git a/src/g_input.h b/src/g_input.h index f6e69337d..505d210f8 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -41,12 +41,10 @@ typedef enum KEY_DBLJOY1 = KEY_DBLMOUSE1 + MOUSEBUTTONS, KEY_DBLHAT1 = KEY_DBLJOY1 + JOYBUTTONS, - KEY_2MOUSE1 = KEY_DBLHAT1 + JOYHATS*4, - KEY_2JOY1 = KEY_2MOUSE1 + MOUSEBUTTONS, + KEY_2JOY1 = KEY_DBLHAT1 + MOUSEBUTTONS, KEY_2HAT1 = KEY_2JOY1 + JOYBUTTONS, - KEY_DBL2MOUSE1 = KEY_2HAT1 + JOYHATS*4, - KEY_DBL2JOY1 = KEY_DBL2MOUSE1 + MOUSEBUTTONS, + KEY_DBL2JOY1 = KEY_2HAT1 + MOUSEBUTTONS, KEY_DBL2HAT1 = KEY_DBL2JOY1 + JOYBUTTONS, KEY_3JOY1 = KEY_DBL2HAT1 + JOYHATS*4, @@ -63,10 +61,8 @@ typedef enum KEY_MOUSEWHEELUP = KEY_DBL4HAT1 + JOYHATS*4, KEY_MOUSEWHEELDOWN = KEY_MOUSEWHEELUP + 1, - KEY_2MOUSEWHEELUP = KEY_MOUSEWHEELDOWN + 1, - KEY_2MOUSEWHEELDOWN = KEY_2MOUSEWHEELUP + 1, - NUMINPUTS = KEY_2MOUSEWHEELDOWN + 1, + NUMINPUTS = KEY_MOUSEWHEELDOWN + 1, } key_input_e; typedef enum @@ -100,12 +96,16 @@ typedef enum gc_custom2, // Lua scriptable gc_custom3, // Lua scriptable gc_director, + gc_freecam, // Toggle for freecam while ingame + gc_camfloat, // alternative button for raising cam + gc_camsink, // alternative button for sinking + gc_strafeleft, + gc_straferight, num_gamecontrols } gamecontrols_e; // mouse values are used once extern consvar_t cv_mousesens, cv_mouseysens; -extern consvar_t cv_mousesens2, cv_mouseysens2; extern consvar_t cv_controlperkey, cv_turnsmooth; extern consvar_t cv_rumble[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_gamepadled[MAXSPLITSCREENPLAYERS]; @@ -113,7 +113,6 @@ extern consvar_t cv_ledpowerup[MAXSPLITSCREENPLAYERS]; extern INT32 mousex, mousey; extern INT32 mlooky; //mousey with mlookSensitivity -extern INT32 mouse2x, mouse2y, mlook2y; extern INT32 joyxmove[JOYAXISSET], joyymove[JOYAXISSET], joy2xmove[JOYAXISSET], joy2ymove[JOYAXISSET], joy3xmove[JOYAXISSET], joy3ymove[JOYAXISSET], joy4xmove[JOYAXISSET], joy4ymove[JOYAXISSET]; diff --git a/src/hardware/hw_batching.c b/src/hardware/hw_batching.c index 2ae7be05e..3c7a49af9 100644 --- a/src/hardware/hw_batching.c +++ b/src/hardware/hw_batching.c @@ -141,27 +141,19 @@ static int comparePolygons(const void *p1, const void *p2) PolygonArrayEntry *poly2 = *(PolygonArrayEntry *const *)p2; int diff; INT64 diff64; - UINT32 downloaded1 = 0; - UINT32 downloaded2 = 0; - int shader1 = poly1->shader; - int shader2 = poly2->shader; - // make skywalls and horizon lines first in order - if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) - shader1 = -1; - if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) - shader2 = -1; - diff = shader1 - shader2; - if (diff != 0) return diff; + int shader1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? -1 : poly1->shader; + int shader2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? -1 : poly2->shader; // skywalls and horizon lines must retain their order for horizon lines to work if (shader1 == -1 && shader2 == -1) return poly1 - poly2; - if (poly1->texture) - downloaded1 = poly1->texture->downloaded; // there should be a opengl texture name here, usable for comparisons - if (poly2->texture) - downloaded2 = poly2->texture->downloaded; + diff = shader1 - shader2; + if (diff != 0) return diff; + + UINT32 downloaded1 = poly1->texture ? poly1->texture->downloaded : 0; // there should be a opengl texture name here, usable for comparisons + UINT32 downloaded2 = poly2->texture ? poly2->texture->downloaded : 0; diff64 = downloaded1 - downloaded2; if (diff64 != 0) return diff64; @@ -194,21 +186,15 @@ static int comparePolygonsNoShaders(const void *p1, const void *p2) int diff; INT64 diff64; - GLMipmap_t *texture1 = poly1->texture; - GLMipmap_t *texture2 = poly2->texture; - UINT32 downloaded1 = 0; - UINT32 downloaded2 = 0; - if (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) - texture1 = NULL; - if (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) - texture2 = NULL; - if (texture1) - downloaded1 = texture1->downloaded; // there should be a opengl texture name here, usable for comparisons - if (texture2) - downloaded2 = texture2->downloaded; + GLMipmap_t *texture1 = (poly1->polyFlags & PF_NoTexture || poly1->horizonSpecial) ? NULL : poly1->texture; + GLMipmap_t *texture2 = (poly2->polyFlags & PF_NoTexture || poly2->horizonSpecial) ? NULL : poly2->texture; + // skywalls and horizon lines must retain their order for horizon lines to work if (!texture1 && !texture2) return poly1 - poly2; + + UINT32 downloaded1 = texture1 ? texture1->downloaded : 0; // there should be a opengl texture name here, usable for comparisons + UINT32 downloaded2 = texture2 ? texture2->downloaded : 0; diff64 = downloaded1 - downloaded2; if (diff64 != 0) return diff64; diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 65e120002..f41547912 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -319,7 +319,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe patch_t *realpatch; INT32 blockwidth, blockheight, blocksize; - INT32 i; + INT32 i, idx; boolean skyspecial = false; //poor hack for Legacy large skies.. RGBA_t *palette; @@ -368,12 +368,10 @@ static void HWR_GenerateTexture(INT32 texnum, GLMapTexture_t *gltex, boolean noe col = palette[HWR_CHROMAKEY_EQUIVALENTCOLORINDEX]; - for (j = 0; j < blockheight; j++) + for (idx = 0, j = 0; j < blockheight; j++) { - for (i = 0; i < blockwidth; i++) + for (i = 0; i < blockwidth; i++, idx++) { - int idx = (j*blockwidth+i); - block[4*idx+0] = col.s.red; block[4*idx+1] = col.s.green; block[4*idx+2] = col.s.blue; @@ -386,8 +384,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); - HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); - Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); + if (realpatch != NULL) + { + HWR_DrawTexturePatchInCache(&gltex->mipmap, blockwidth, blockheight, texture, patch, realpatch); + Z_ChangeTag(realpatch, PU_HWRCACHE_UNLOCKED); + } } //Hurdler: not efficient at all but I don't remember exactly how HWR_DrawPatchInCache works :( @@ -639,8 +640,7 @@ static void HWR_CacheFlat(GLMipmap_t *glMipmap, lumpnum_t flatlumpnum) glMipmap->height = (UINT16)pflatsize; // the flat raw data needn't be converted with palettized textures - W_ReadLump(flatlumpnum, Z_Malloc(W_LumpLength(flatlumpnum), - PU_HWRCACHE, &glMipmap->data)); + W_ReadLump(flatlumpnum, Z_Malloc(size, PU_HWRCACHE, &glMipmap->data)); #ifdef GLENCORE flat = glMipmap->data; @@ -835,6 +835,7 @@ static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 stepy = ((INT32)SHORT(fmheight)<= 180.0) return 0xffffffff; diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 85e204961..a99db6acc 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -121,38 +121,24 @@ typedef struct poly_t *planepoly; // the generated convex polygon } extrasubsector_t; -// Kart features -#define USE_FTRANSFORM_ANGLEZ -#define USE_FTRANSFORM_MIRROR - // Vanilla features //#define USE_MODEL_NEXTFRAME typedef struct { FLOAT x,y,z; // position -#ifdef USE_FTRANSFORM_ANGLEZ FLOAT anglex, angley, anglez; // aimingangle / viewangle FLOAT anglex2, anglez2; // secondaries -#else - FLOAT anglex, angley; // aimingangle / viewangle - FLOAT anglex2; // secondaries -#endif FLOAT scalex, scaley, scalez; - FLOAT spritexscale, spriteyscale; - FLOAT fovxangle, fovyangle; + FLOAT fovangle; UINT8 splitscreen; boolean flip; // screenflip boolean roll; - boolean rollmodel; - SINT8 rollflip; FLOAT rollangle; - UINT8 rotaxis; FLOAT centerx, centery; -#ifdef USE_FTRANSFORM_MIRROR + FLOAT rollx, rollz; boolean mirror; // SRB2Kart: Encore Mode boolean mirrorflip; // Encore Mode with Flipcam -#endif boolean shearing; // 14042019 float viewaiming; // 17052019 } FTransform; @@ -246,22 +232,22 @@ enum EPolyFlags { // the first 5 are mutually exclusive - PF_Masked = 0x00000001, // Poly is alpha scaled and 0 alpha pels are discarded (holes in texture) + PF_Masked = 0x00000001, // Poly is alpha scaled and 0 alpha pixels are discarded (holes in texture) PF_Translucent = 0x00000002, // Poly is transparent, alpha = level of transparency - PF_Additive = 0x00000004, // Poly is added to the frame buffer - PF_Environment = 0x00000008, // Poly should be drawn environment mapped. - // Hurdler: used for text drawing - PF_Substractive = 0x00000010, // for splat - PF_NoAlphaTest = 0x00000020, // hiden param - PF_Fog = 0x00000040, // Fog blocks - PF_Blending = (PF_Environment|PF_Additive|PF_Translucent|PF_Masked|PF_Substractive|PF_Fog)&~PF_NoAlphaTest, + PF_Environment = 0x00000004, // Poly should be drawn environment mapped. (Hurdler: used for text drawing) + PF_Additive = 0x00000008, // Source blending factor is additive. + PF_Subtractive = 0x00000010, // Subtractive color blending + PF_ReverseSubtract = 0x00000020, // Reverse subtract, used in wall splats (decals) + PF_Multiplicative = 0x00000040, // Multiplicative color blending + PF_Fog = 0x20000000, // Fog blocks + PF_NoAlphaTest = 0x40000000, // Disables alpha testing + PF_Blending = (PF_Masked|PF_Translucent|PF_Environment|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Fog) & ~PF_NoAlphaTest, // other flag bits - - PF_Occlude = 0x00000100, // Update the depth buffer - PF_NoDepthTest = 0x00000200, // Disable the depth test mode - PF_Invisible = 0x00000400, // Disable write to color buffer - PF_Decal = 0x00000800, // Enable polygon offset + PF_Occlude = 0x00000100, // Updates the depth buffer + PF_NoDepthTest = 0x00000200, // Disables the depth test mode + PF_Invisible = 0x00000400, // Disables write to color buffer + PF_Decal = 0x00000800, // Enables polygon offset PF_Modulated = 0x00001000, // Modulation (multiply output with constant RGBA) // When set, pass the color constant into the FSurfaceInfo -> FlatColor PF_NoTexture = 0x00002000, // Disable texture diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index e38300309..b6daad7b6 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -62,6 +62,9 @@ static UINT8 softwaretranstogl[11] = { 0, 25, 51, 76,102,127,153,178,204,229 static UINT8 softwaretranstogl_hi[11] = { 0, 51,102,153,204,255,255,255,255,255,255}; static UINT8 softwaretranstogl_lo[11] = { 0, 12, 24, 36, 48, 60, 71, 83, 95,111,127}; +static const float FLOATBASEVIDWIDTH = (float)BASEVIDWIDTH; +static const float FLOATBASEVIDHEIGHT = (float)BASEVIDHEIGHT; + // // -----------------+ // HWR_DrawPatch : Draw a 'tile' graphic @@ -126,13 +129,14 @@ void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option) GL_DrawPolygon(NULL, v, 4, flags); } -void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap) +void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags) { FOutVector v[4]; FBITFIELD flags; float cx = FIXED_TO_FLOAT(x); float cy = FIXED_TO_FLOAT(y); UINT8 alphalevel = ((option & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT8 blendmode = ((bflags & V_BLENDMASK) >> V_BLENDSHIFT); // 3--2 // | /| @@ -143,6 +147,9 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t if (alphalevel >= 10 && alphalevel < 13) return; + const float fvw = (float)vid.width; + const float fvh = (float)vid.height; + // make patch ready in hardware cache if (!colormap) HWR_GetPatch(gpatch); @@ -226,21 +233,21 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t Z_Free(realpatch); } // centre screen - if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) + if (fabsf(fvw - FLOATBASEVIDWIDTH * dupx) > 1.0E-36f) { if (option & V_SNAPTORIGHT) - cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); + cx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(option & V_SNAPTOLEFT)) - cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/2; + cx += (fvw - (FLOATBASEVIDWIDTH * dupx))/2; } - if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) + if (fabsf(fvh - FLOATBASEVIDHEIGHT * dupy) > 1.0E-36f) { if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) - cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); + cy += (fvh/2 - (FLOATBASEVIDHEIGHT/2 * dupy)); else if (option & V_SNAPTOBOTTOM) - cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); + cy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(option & V_SNAPTOTOP)) - cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/2; + cy += (fvh - (FLOATBASEVIDHEIGHT * dupy))/2; } } } @@ -257,12 +264,12 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t } // 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 + (cx / (vid.width/2)); - cy = 1 - (cy / (vid.height/2)); + cx = -1.0f + (cx / (vid.width / 2.0f)); + cy = 1.0f - (cy / (vid.height / 2.0f)); // fwidth and fheight are similar - fwidth /= vid.width / 2; - fheight /= vid.height / 2; + fwidth /= fvw / 2.0f; + fheight /= fvh / 2.0f; // set the polygon vertices to the right positions v[0].x = v[3].x = cx; @@ -287,7 +294,11 @@ 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; - flags = PF_Translucent|PF_NoDepthTest; + // whoops + if (blendmode) + flags = HWR_GetBlendModeFlag(blendmode+1)|PF_NoDepthTest; + else + flags = PF_Translucent|PF_NoDepthTest; if (option & V_WRAPX) flags |= PF_ForceWrapX; @@ -295,14 +306,17 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t 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]; else Surf.PolyColor.s.alpha = softwaretranstogl[10-alphalevel]; + flags |= PF_Modulated; GL_DrawPolygon(&Surf, v, 4, flags); } @@ -327,6 +341,9 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal if (alphalevel >= 10 && alphalevel < 13) return; + const float fvw = (float)vid.width; + const float fvh = (float)vid.height; + // make patch ready in hardware cache HWR_GetPatch(gpatch); @@ -377,21 +394,21 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal Z_Free(realpatch); } // centre screen - if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) + if (fabsf(fvw - FLOATBASEVIDWIDTH * dupx) > 1.0E-36f) { if (option & V_SNAPTORIGHT) - cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); + cx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(option & V_SNAPTOLEFT)) - cx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx))/2; + cx += (fvw - (FLOATBASEVIDWIDTH * dupx))/2; } - if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) + if (fabsf(fvh - FLOATBASEVIDHEIGHT * dupy) > 1.0E-36f) { if ((option & (V_SPLITSCREEN|V_SNAPTOTOP)) == (V_SPLITSCREEN|V_SNAPTOTOP)) - cy += ((float)vid.height/2 - ((float)BASEVIDHEIGHT/2 * dupy)); + cy += (fvh/2 - (FLOATBASEVIDHEIGHT/2 * dupy)); else if (option & V_SNAPTOBOTTOM) - cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); + cy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(option & V_SNAPTOTOP)) - cy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy))/2; + cy += (fvh - (FLOATBASEVIDHEIGHT * dupy))/2; } } } @@ -423,12 +440,12 @@ 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 + (cx / (vid.width/2)); - cy = 1 - (cy / (vid.height/2)); + cx = -1.0f + (cx / (vid.width / 2.0f)); + cy = 1.0f - (cy / (vid.height / 2.0f)); // fwidth and fheight are similar - fwidth /= vid.width / 2; - fheight /= vid.height / 2; + fwidth /= fvw / 2.0f; + fheight /= fvh / 2.0f; // set the polygon vertices to the right positions v[0].x = v[3].x = cx; @@ -456,10 +473,12 @@ void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscal { FSurfaceInfo Surf; Surf.PolyColor.s.red = Surf.PolyColor.s.green = Surf.PolyColor.s.blue = 0xff; + if (alphalevel == 13) Surf.PolyColor.s.alpha = softwaretranstogl_lo[cv_translucenthud.value]; 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); } @@ -811,6 +830,9 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) fy = (float)y; fw = fh = (float)wh; + const float fvw = (float)vid.width; + const float fvh = (float)vid.height; + if (!(color & V_NOSCALESTART)) { float dupx = (float)vid.dupx, dupy = (float)vid.dupy; @@ -820,20 +842,20 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) fw *= dupx; fh *= dupy; - if (fabsf((float)vid.width - ((float)BASEVIDWIDTH * dupx)) > 1.0E-36f) + if (fabsf(fvw - (FLOATBASEVIDWIDTH * dupx)) > 1.0E-36f) { if (color & V_SNAPTORIGHT) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(color & V_SNAPTOLEFT)) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2; + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)) / 2; } - if (fabsf((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) > 1.0E-36f) + if (fabsf(fvh - (FLOATBASEVIDHEIGHT * dupy)) > 1.0E-36f) { // same thing here if (color & V_SNAPTOBOTTOM) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(color & V_SNAPTOTOP)) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2; + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)) / 2; } } @@ -854,16 +876,16 @@ void HWR_DrawDiag(INT32 x, INT32 y, INT32 wh, INT32 color) return; if (fx + fw > vid.width) { - fwait = fw - ((float)vid.width - fx); - fw = (float)vid.width - fx; + fwait = fw - (fvw- fx); + fw = fvw - fx; } if (fy + fh > vid.height) - fh = (float)vid.height - fy; + fh = fvh - fy; - fx = -1 + fx / (vid.width / 2); - fy = 1 - fy / (vid.height / 2); - fw = fw / (vid.width / 2); - fh = fh / (vid.height / 2); + fx = -1.0f + fx / (vid.width / 2.0f); + fy = 1.0f - fy / (vid.height / 2.0f); + fw = fw / (fvw / 2.0f); + fh = fh / (fvh / 2.0f); v[0].x = v[3].x = fx; v[2].x = v[1].x = fx + fw; @@ -907,6 +929,9 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 fw = (float)w; fh = (float)h; + const float fvw = (float)vid.width; + const float fvh = (float)vid.height; + if (!(options & V_NOSCALESTART)) { float dupx = (float)vid.dupx, dupy = (float)vid.dupy; @@ -928,25 +953,25 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 fw *= dupx; fh *= dupy; - if (fabsf((float)vid.width - ((float)BASEVIDWIDTH * dupx)) > 1.0E-36f) + if (fabsf(fvw - (FLOATBASEVIDWIDTH * dupx)) > 1.0E-36f) { if (options & V_SNAPTORIGHT) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(options & V_SNAPTOLEFT)) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2; + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)) / 2; } - if (fabsf((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) > 1.0E-36f) + if (fabsf(fvh - (FLOATBASEVIDHEIGHT * dupy)) > 1.0E-36f) { // same thing here if (options & V_SNAPTOBOTTOM) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(options & V_SNAPTOTOP)) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2; + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)) / 2; } if (options & V_SPLITSCREEN) - fy += ((float)BASEVIDHEIGHT * dupy)/2; + fy += (FLOATBASEVIDHEIGHT * dupy)/2; if (options & V_HORZSCREEN) - fx += ((float)BASEVIDWIDTH * dupx)/2; + fx += (FLOATBASEVIDWIDTH * dupx)/2; } @@ -966,14 +991,14 @@ void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 if (fw <= 0 || fh <= 0) return; if (fx + fw > vid.width) - fw = (float)vid.width - fx; + fw = fvw - fx; if (fy + fh > vid.height) - fh = (float)vid.height - fy; + fh = fvh - fy; - fx = -1 + fx / (vid.width / 2); - fy = 1 - fy / (vid.height / 2); - fw = fw / (vid.width / 2); - fh = fh / (vid.height / 2); + fx = -1.0f + fx / (vid.width / 2.0f); + fy = 1.0f - fy / (vid.height / 2.0f); + fw = fw / (fvw / 2.0f); + fh = fh / (fvh / 2.0f); v[0].x = v[3].x = fx; v[2].x = v[1].x = fx + fw; @@ -1018,6 +1043,9 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) fw = (float)w; fh = (float)h; + const float fvw = (float)vid.width; + const float fvh = (float)vid.height; + if (!(color & V_NOSCALESTART)) { float dupx = (float)vid.dupx, dupy = (float)vid.dupy; @@ -1039,26 +1067,25 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) fw *= dupx; fh *= dupy; - if (fabsf((float)vid.width - (float)BASEVIDWIDTH * dupx) > 1.0E-36f) + if (fabsf(fvw - FLOATBASEVIDWIDTH * dupx) > 1.0E-36f) { if (color & V_SNAPTORIGHT) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)); + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)); else if (!(color & V_SNAPTOLEFT)) - fx += ((float)vid.width - ((float)BASEVIDWIDTH * dupx)) / 2; + fx += (fvw - (FLOATBASEVIDWIDTH * dupx)) / 2; } - if (fabsf((float)vid.height - (float)BASEVIDHEIGHT * dupy) > 1.0E-36f) + if (fabsf(fvh - FLOATBASEVIDHEIGHT * dupy) > 1.0E-36f) { // same thing here if (color & V_SNAPTOBOTTOM) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)); + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)); else if (!(color & V_SNAPTOTOP)) - fy += ((float)vid.height - ((float)BASEVIDHEIGHT * dupy)) / 2; + fy += (fvh - (FLOATBASEVIDHEIGHT * dupy)) / 2; } if (color & V_SPLITSCREEN) - fy += ((float)BASEVIDHEIGHT * dupy)/2; + fy += (FLOATBASEVIDHEIGHT * dupy)/2; if (color & V_HORZSCREEN) - fx += ((float)BASEVIDWIDTH * dupx)/2; - + fx += (FLOATBASEVIDWIDTH * dupx)/2; } if (fx >= vid.width || fy >= vid.height) @@ -1077,14 +1104,14 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) if (fw <= 0 || fh <= 0) return; if (fx + fw > vid.width) - fw = (float)vid.width - fx; + fw = fvw - fx; if (fy + fh > vid.height) - fh = (float)vid.height - fy; + fh = fvh - fy; - fx = -1 + fx / (vid.width / 2); - fy = 1 - fy / (vid.height / 2); - fw = fw / (vid.width / 2); - fh = fh / (vid.height / 2); + fx = -1.0f + fx / (vid.width / 2.0f); + fy = 1.0f - fy / (vid.height / 2.0f); + fw = fw / (fvw / 2.0f); + fh = fh / (fvh / 2.0f); v[0].x = v[3].x = fx; v[2].x = v[1].x = fx + fw; @@ -1127,7 +1154,7 @@ void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color) #define _FILE_OFFSET_BITS 0 #endif - #include "png.h" +#include "png.h" #ifdef PNG_WRITE_SUPPORTED #define USE_PNG // PNG is only used if write is supported (see ../m_misc.c) #endif diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c7620d9e4..24d0c406b 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -223,8 +223,6 @@ consvar_t cv_glrenderdistance = {"gr_renderdistance", "Max", CV_SAVE, glrenderdi consvar_t cv_glhorizonlines = {"gr_horizonlines", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glportals = {"gr_portals", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_glfovchange = {"gr_fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_glpaletterendering = {"gr_paletteshader", "Off", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glpalettedepth = {"gr_palettedepth", "16 bits", CV_SAVE|CV_CALL, glpalettedepth_cons_t, CV_glpalettedepth_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_glflashpal = {"gr_flashpal", "On", CV_CALL|CV_SAVE, CV_OnOff, CV_glpaletterendering_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -319,27 +317,12 @@ static void CV_glpalettedepth_OnChange(void) // Lighting // ========================================================================== -boolean HWR_UseShader(void) -{ - return (cv_glshaders.value && gl_shadersavailable); -} - static void HWR_SetShaderState(void) { GL_SetSpecialState(HWD_SET_SHADERS, HWR_UseShader() ? 1 : 0); } -boolean HWR_ShouldUsePaletteRendering(void) -{ - return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader()); -} - -boolean HWR_PalRenderFlashpal(void) -{ - return (HWR_ShouldUsePaletteRendering() && cv_glflashpal.value); -} - -void HWR_ObjectLightLevelPost(gl_vissprite_t *spr, const sector_t *sector, INT32 *lightlevel, boolean model, const boolean papersprite) +void HWR_Lighting(FSurfaceInfo *Surface, INT32 light_level, extracolormap_t *colormap) { (void)papersprite; @@ -703,7 +686,7 @@ static void HWR_RenderPlane(subsector_t *subsector, extrasubsector_t *xsub, bool HWR_Lighting(&Surf, lightlevel, planecolormap, P_SectorUsesDirectionalLighting(gl_frontsector)); - if (PolyFlags & (PF_Translucent|PF_Fog)) + if (PolyFlags & (PF_Translucent|PF_Fog|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) { Surf.PolyColor.s.alpha = (UINT8)alpha; PolyFlags |= PF_Modulated; @@ -885,20 +868,65 @@ static void HWR_DrawSegsSplats(FSurfaceInfo * pSurf) } #endif -FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf) +FBITFIELD HWR_GetBlendModeFlag(INT32 style) +{ + switch (style) + { + case AST_TRANSLUCENT: + return PF_Translucent; + case AST_ADD: + return PF_Additive; + case AST_SUBTRACT: + return PF_Subtractive; + case AST_REVERSESUBTRACT: + return PF_ReverseSubtract; + case AST_MODULATE: + return PF_Multiplicative; + default: + return PF_Masked; + } +} + +UINT8 HWR_GetTranstableAlpha(INT32 transtablenum) { switch (transtablenum) { - case tr_trans10 : pSurf->PolyColor.s.alpha = 0xe6;return PF_Translucent; - case tr_trans20 : pSurf->PolyColor.s.alpha = 0xcc;return PF_Translucent; - case tr_trans30 : pSurf->PolyColor.s.alpha = 0xb3;return PF_Translucent; - case tr_trans40 : pSurf->PolyColor.s.alpha = 0x99;return PF_Translucent; - case tr_trans50 : pSurf->PolyColor.s.alpha = 0x80;return PF_Translucent; - case tr_trans60 : pSurf->PolyColor.s.alpha = 0x66;return PF_Translucent; - case tr_trans70 : pSurf->PolyColor.s.alpha = 0x4c;return PF_Translucent; - case tr_trans80 : pSurf->PolyColor.s.alpha = 0x33;return PF_Translucent; - case tr_trans90 : pSurf->PolyColor.s.alpha = 0x19;return PF_Translucent; + case 0 : return 0xff; + case tr_trans10 : return 0xe6; + case tr_trans20 : return 0xcc; + case tr_trans30 : return 0xb3; + case tr_trans40 : return 0x99; + case tr_trans50 : return 0x80; + case tr_trans60 : return 0x66; + case tr_trans70 : return 0x4c; + case tr_trans80 : return 0x33; + case tr_trans90 : return 0x19; } + + return 0xff; +} + +FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf) +{ + if (!transtablenum || style <= AST_COPY || style >= AST_OVERLAY) + { + pSurf->PolyColor.s.alpha = 0xff; + return PF_Masked; + } + + pSurf->PolyColor.s.alpha = HWR_GetTranstableAlpha(transtablenum); + return HWR_GetBlendModeFlag(style); +} + +FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf) +{ + if (!transtablenum) + { + pSurf->PolyColor.s.alpha = 0x00; + return PF_Masked; + } + + pSurf->PolyColor.s.alpha = HWR_GetTranstableAlpha(transtablenum); return PF_Translucent; } @@ -1083,8 +1111,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (cutflag & FF_FOG) HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); + else if (polyflags & (PF_Translucent|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); @@ -1112,8 +1140,8 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum, if (cutflag & FF_FOG) HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Fog|PF_NoTexture|polyflags, true, lightnum, colormap); - else if (cutflag & FF_TRANSLUCENT) - HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, PF_Translucent|polyflags, false, lightnum, colormap); + else if (polyflags & (PF_Translucent|PF_Additive|PF_Subtractive|PF_ReverseSubtract|PF_Multiplicative|PF_Environment)) + HWR_AddTransparentWall(wallVerts, Surf, texnum, noencore, polyflags, false, lightnum, colormap); else HWR_ProjectWall(wallVerts, Surf, PF_Masked|polyflags, lightnum, colormap); } @@ -1206,33 +1234,6 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) // set alpha for transparent walls switch (gl_linedef->special) { - case 900: - blendmode = HWR_TranstableToAlpha(tr_trans10, pSurf); - break; - case 901: - blendmode = HWR_TranstableToAlpha(tr_trans20, pSurf); - break; - case 902: - blendmode = HWR_TranstableToAlpha(tr_trans30, pSurf); - break; - case 903: - blendmode = HWR_TranstableToAlpha(tr_trans40, pSurf); - break; - case 904: - blendmode = HWR_TranstableToAlpha(tr_trans50, pSurf); - break; - case 905: - blendmode = HWR_TranstableToAlpha(tr_trans60, pSurf); - break; - case 906: - blendmode = HWR_TranstableToAlpha(tr_trans70, pSurf); - break; - case 907: - blendmode = HWR_TranstableToAlpha(tr_trans80, pSurf); - break; - case 908: - blendmode = HWR_TranstableToAlpha(tr_trans90, pSurf); - break; // Translucent linedef types case 102: case 121 ... 125: @@ -1242,11 +1243,25 @@ static inline boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) case 192: case 195: case 221: - case 253 ... 256: - blendmode = PF_Translucent; + case 253: + case 256: + if (gl_linedef->blendmode) + blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf); + else + blendmode = PF_Translucent; break; default: - blendmode = PF_Masked; + if (gl_linedef->blendmode) + { + if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) + blendmode = HWR_SurfaceBlend(gl_linedef->blendmode, R_GetLinedefTransTable(gl_linedef->alpha), pSurf); + else + blendmode = HWR_GetBlendModeFlag(gl_linedef->blendmode); + } + else if (gl_linedef->alpha >= 0 && gl_linedef->alpha < FRACUNIT) + blendmode = HWR_TranstableToAlpha(R_GetLinedefTransTable(gl_linedef->alpha), pSurf); + else + blendmode = PF_Masked; break; } } @@ -1740,7 +1755,7 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom blendmode |= PF_Decal; if (!gl_drawing_stencil && gl_frontsector->numlights) - HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, noencore, &Surf, (!(blendmode & PF_Masked)) ? FF_TRANSLUCENT : FF_CUTLEVEL, NULL, PF_Decal); + HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, noencore, &Surf, (!(blendmode & PF_Masked)) ? FF_TRANSLUCENT : FF_CUTLEVEL, NULL, blendmode); else if (!gl_drawing_stencil && !(blendmode & PF_Masked)) HWR_AddTransparentWall(wallVerts, &Surf, gl_midtexture, noencore, blendmode, false, lightnum, colormap); else @@ -1795,7 +1810,9 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[1].y = FIXED_TO_FLOAT(worldbottomslope); if (gl_frontsector->numlights) + { HWR_SplitWall(gl_frontsector, wallVerts, gl_midtexture, noencore, &Surf, FF_CUTLEVEL, NULL, 0); + } else // I don't think that solid walls can use translucent linedef types... { if (glTex->mipmap.flags & TF_TRANSPARENT) @@ -1962,10 +1979,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[0].s = wallVerts[3].s = cliplow * glTex->scaleX; wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX; } + FBITFIELD blendmode; + if (rover->flags & FF_FOG) { - FBITFIELD blendmode; - blendmode = PF_Fog|PF_NoTexture; lightnum = rover->master->frontsector->lightlevel; @@ -1976,22 +1993,22 @@ 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, 0); + HWR_SplitWall(gl_frontsector, wallVerts, 0, false, &Surf, rover->flags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } else { - FBITFIELD blendmode = PF_Masked; + blendmode = PF_Masked; - if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - blendmode = PF_Translucent; + 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, 0); + HWR_SplitWall(gl_frontsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -2077,10 +2094,10 @@ void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom wallVerts[2].s = wallVerts[1].s = cliphigh * glTex->scaleX; } + FBITFIELD blendmode; + if (rover->flags & FF_FOG) { - FBITFIELD blendmode; - blendmode = PF_Fog|PF_NoTexture; lightnum = rover->master->frontsector->lightlevel; @@ -2091,22 +2108,22 @@ 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, 0); + HWR_SplitWall(gl_backsector, wallVerts, 0, false, &Surf, rover->flags, rover, blendmode); else HWR_AddTransparentWall(wallVerts, &Surf, 0, false, blendmode, true, lightnum, colormap); } else { - FBITFIELD blendmode = PF_Masked; + blendmode = PF_Masked; - if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { - blendmode = PF_Translucent; + 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, 0); + HWR_SplitWall(gl_backsector, wallVerts, texnum, noencore, &Surf, rover->flags, rover, blendmode); else { if (blendmode != PF_Masked) @@ -2319,6 +2336,9 @@ static void HWR_AddLine(seg_t *line) gl_backsector = line->backsector; + if (!cv_glportals.value || !gl_maphasportals) + goto doaddline; + // do extra checks on the seg when rendering portals: // don't render segs that are behind the portal destination line if (portalclipline && @@ -2386,31 +2406,19 @@ doaddline: // HWR_CheckBBox // Checks BSP node/subtree bounding box. // Returns true -// if some part of the bbox might be visible. +// if some part of the bbox might be visible. // // modified to use local variables static boolean HWR_CheckBBox(const fixed_t *bspcoord) { - INT32 boxpos; fixed_t px1, py1, px2, py2; angle_t angle1, angle2; // Find the corners of the box // that define the edges from current viewpoint. - if (viewx <= bspcoord[BOXLEFT]) - boxpos = 0; - else if (viewx < bspcoord[BOXRIGHT]) - boxpos = 1; - else - boxpos = 2; - - if (viewy >= bspcoord[BOXTOP]) - boxpos |= 0; - else if (viewy > bspcoord[BOXBOTTOM]) - boxpos |= 1<<2; - else - boxpos |= 2<<2; + const INT32 boxpos = (viewx <= bspcoord[BOXLEFT] ? 0 : viewx < bspcoord[BOXRIGHT ] ? 1 : 2) + + (viewy >= bspcoord[BOXTOP ] ? 0 : viewy > bspcoord[BOXBOTTOM] ? 4 : 8); if (boxpos == 5) return true; @@ -2792,27 +2800,11 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v return false; } -static inline void HWR_PortalSubsector(seg_t *line, subsector_t *sub, INT16 count) +static FBITFIELD HWR_RippleBlend(sector_t *sector, ffloor_t *rover, boolean ceiling) { - if (line) - { - //Hurdler: at this point validcount must be the same, but is not because - // gl_frontsector doesn't point anymore to sub->sector due to - // the call gl_frontsector = R_FakeFlat(...) - // if it's not done, the sprite is drawn more than once, - // what looks really bad with translucency or dynamic light, - // without talking about the overdraw of course. - sub->sector->validcount = validcount;/// \todo fix that in a better way - - while (count--) - { - if (!line->polyseg) // ignore segs that belong to polyobjects - HWR_AddLine(line); - line++; - } - } - - sub->validcount = validcount; + (void)sector; + (void)ceiling; + return /*R_IsRipplePlane(sector, rover, ceiling)*/ (rover->flags & FF_RIPPLE) ? PF_Ripple : 0; } // -----------------+ @@ -2867,8 +2859,7 @@ static void HWR_Subsector(size_t num) if (gl_portal_state == GLPORTAL_SEARCH) { - HWR_PortalSubsector(line, sub, count); - return; + goto doaddline; } floorcolormap = ceilingcolormap = gl_frontsector->extra_colormap; @@ -2886,6 +2877,12 @@ static void HWR_Subsector(size_t num) { for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + continue; + + if (sub->validcount == validcount) + continue; + sector_t *controlSec = §ors[rover->secnum]; if (controlSec->moved != true) @@ -2955,8 +2952,7 @@ static void HWR_Subsector(size_t num) if (gl_frontsector->ffloors) { /// \todo fix light, xoffs, yoffs, extracolormap ? - for (rover = gl_frontsector->ffloors; - rover; rover = rover->next) + for (rover = gl_frontsector->ffloors; rover; rover = rover->next) { fixed_t bottomCullHeight, topCullHeight, centerHeight; @@ -2999,7 +2995,7 @@ static void HWR_Subsector(size_t num) alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } - else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) // SoM: Flags are more efficient + else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) // SoM: Flags are more efficient { light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); @@ -3008,7 +3004,7 @@ static void HWR_Subsector(size_t num) false, *rover->bottomheight, *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), false, gl_frontsector->lightlist[light].extra_colormap); } else @@ -3016,7 +3012,7 @@ static void HWR_Subsector(size_t num) HWR_GetFlat(levelflats[*rover->bottompic].lumpnum, R_NoEncore(gl_frontsector, false)); light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < bottomCullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, + HWR_RenderPlane(sub, &extrasubsectors[num], false, *rover->bottomheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->bottompic].lumpnum, rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } } @@ -3045,7 +3041,7 @@ static void HWR_Subsector(size_t num) alpha, rover->master->frontsector, PF_Fog|PF_NoTexture, true, rover->master->frontsector->extra_colormap); } - else if (rover->flags & FF_TRANSLUCENT && rover->alpha < 256) + else if ((rover->flags & FF_TRANSLUCENT && rover->alpha < 256) || rover->blend) { light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); @@ -3054,7 +3050,7 @@ static void HWR_Subsector(size_t num) true, *rover->topheight, *gl_frontsector->lightlist[light].lightlevel, - CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Translucent, + CLAMP(rover->alpha, 0 ,255), rover->master->frontsector, HWR_RippleBlend(gl_frontsector, rover, false) | (rover->blend ? HWR_GetBlendModeFlag(rover->blend) : PF_Translucent), false, gl_frontsector->lightlist[light].extra_colormap); } else @@ -3062,7 +3058,7 @@ static void HWR_Subsector(size_t num) HWR_GetFlat(levelflats[*rover->toppic].lumpnum, R_NoEncore(gl_frontsector, true)); light = R_GetPlaneLight(gl_frontsector, centerHeight, viewz < topCullHeight ? true : false); - HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, (rover->flags & FF_RIPPLE ? PF_Ripple : 0)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, + HWR_RenderPlane(sub, &extrasubsectors[num], true, *rover->topheight, HWR_RippleBlend(gl_frontsector, rover, false)|PF_Occlude, *gl_frontsector->lightlist[light].lightlevel, levelflats[*rover->toppic].lumpnum, rover->master->frontsector, 255, gl_frontsector->lightlist[light].extra_colormap); } } @@ -3099,6 +3095,7 @@ static void HWR_Subsector(size_t num) } } +doaddline: // Hurdler: here interesting things are happening! // we have just drawn the floor and ceiling // we now draw the sprites first and then the walls @@ -3119,9 +3116,9 @@ static void HWR_Subsector(size_t num) while (count--) { - if (!line->polyseg) // ignore segs that belong to polyobjects - HWR_AddLine(line); - line++; + if (!line->polyseg) // ignore segs that belong to polyobjects + HWR_AddLine(line); + line++; } } @@ -3132,25 +3129,56 @@ static void HWR_Subsector(size_t num) // Renders all subsectors below a given node, // traversing subtree recursively. // Just call with BSP root. +// static void HWR_RenderBSPNode(INT32 bspnum) { - const node_t *bsp; - INT32 side; + register const node_t *bsp; + register INT32 side; ps_numbspcalls.value.i++; - while (!(bspnum & NF_SUBSECTOR)) // Found a subsector? + while (!(bspnum & NF_SUBSECTOR)) // Keep going until found a subsector { bsp = &nodes[bspnum]; // Decide which side the view point is on. side = R_PointOnSideFast(viewx, viewy, bsp); - // Recursively divide front space. - if (HWR_PortalCheckBBox(bsp->bbox[side])) - HWR_RenderBSPNode(bsp->children[side]); + // Recursively divide front space (toward the viewer). + HWR_RenderBSPNode(bsp->children[side]); - // Possibly divide back space + // Possibly divide back space (away from the viewer). + if (!(HWR_CheckBBox(bsp->bbox[side^1]))) + return; + + bspnum = bsp->children[side^1]; + } + + // e6y: support for extended nodes + HWR_Subsector(bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR); +} + +// +// Same thing but with extra portal checks +// +static void HWR_RenderPortalBSPNode(INT32 bspnum) +{ + register const node_t *bsp; + register INT32 side; + ps_numbspcalls.value.i++; + + while (!(bspnum & NF_SUBSECTOR)) // Keep going until found a subsector + { + bsp = &nodes[bspnum]; + + // Decide which side the view point is on. + side = R_PointOnSideFast(viewx, viewy, bsp); + + // Recursively divide front space (toward the viewer). + if (HWR_PortalCheckBBox(bsp->bbox[side])) + HWR_RenderPortalBSPNode(bsp->children[side]); + + // Possibly divide back space (away from the viewer). if (!(HWR_CheckBBox(bsp->bbox[side^1]) && HWR_PortalCheckBBox(bsp->bbox[side^1]))) return; @@ -3158,7 +3186,7 @@ static void HWR_RenderBSPNode(INT32 bspnum) } // PORTAL CULLING - if (portalclipline && portalcullsector) + if (portalcullsector) { // skip all subsectors encountered before the portal // destination's front sector @@ -3186,7 +3214,7 @@ static gl_vissprite_t *gl_visspritechunks[MAXVISSPRITES >> VISSPRITECHUNKBITS] = // HWR_ClearSprites // Called at frame start. // -------------------------------------------------------------------------- -static void HWR_ClearSprites(void) +static inline void HWR_ClearSprites(void) { gl_visspritecount = 0; } @@ -3278,11 +3306,11 @@ static void HWR_DrawSpriteShadow(gl_vissprite_t *spr, GLPatch_t *gpatch) angle_t shadowdir; // Set direction - if (splitscreen && stplyr == &players[displayplayers[1]]) + if (splitscreen && R_GetViewNumber() == 1) shadowdir = localangle[1] + FixedAngle(cv_cam_rotate[1].value); - else if (splitscreen > 1 && stplyr == &players[displayplayers[2]]) + else if (splitscreen > 1 && R_GetViewNumber() == 2) shadowdir = localangle[2] + FixedAngle(cv_cam_rotate[2].value); - else if (splitscreen > 2 && stplyr == &players[displayplayers[3]]) + else if (splitscreen > 2 && R_GetViewNumber() == 3) shadowdir = localangle[3] + FixedAngle(cv_cam_rotate[3].value); else shadowdir = localangle[0] + FixedAngle(cv_cam_rotate[0].value); @@ -3602,6 +3630,12 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) // co-ordinates memcpy(wallVerts, baseWallVerts, sizeof(baseWallVerts)); + INT32 blendmode; + if (spr->mobj->frame & FF_BLENDMASK) + blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = spr->mobj->blendmode; + if (!cv_translucency.value) // translucency disabled { Surf.PolyColor.s.alpha = 0xFF; @@ -3610,10 +3644,13 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) else if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - blend = PF_Translucent; + blend = HWR_GetBlendModeFlag(blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + { + INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; + blend = HWR_SurfaceBlend(blendmode, trans, &Surf); + } else { // BP: i agree that is little better in environement but it don't @@ -3621,7 +3658,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; + blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } if (HWR_UseShader()) @@ -3639,8 +3676,10 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) i = 0; temp = FLOAT_TO_FIXED(realtop); - if (spr->mobj->frame & FF_FULLBRIGHT) + if (R_ThingIsFullBright(spr->mobj)) lightlevel = 255; + else if (R_ThingIsFullDark(spr->mobj)) + lightlevel = 0; for (i = 1; i < sector->numlights; i++) { @@ -3654,7 +3693,8 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite) break; } - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); + if (R_ThingIsSemiBright(spr->mobj)) + lightlevel = 128 + (lightlevel>>1); for (i = 0; i < sector->numlights; i++) { @@ -3772,6 +3812,7 @@ 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; @@ -3862,14 +3903,21 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) sector_t *sector = spr->mobj->subsector->sector; INT32 lightlevel = 255; extracolormap_t *colormap = sector->extra_colormap; - const boolean fullbright = (spr->mobj->frame & FF_FULLBRIGHT); - if (!fullbright) + if (R_ThingIsFullDark(spr->mobj)) + lightlevel = 0; + else if (!(R_ThingIsFullBright(spr->mobj))) lightlevel = min(sector->lightlevel, 255); - HWR_ObjectLightLevelPost(spr, sector, &lightlevel, false, papersprite); + if (R_ThingIsSemiBright(spr->mobj)) + lightlevel = 128 + (lightlevel>>1); - HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector) && !(spr->mobj->frame & FF_FULLBRIGHT)); + HWR_Lighting(&Surf, lightlevel, colormap); + + if (spr->mobj->frame & FF_BLENDMASK) + blendmode = ((spr->mobj->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = spr->mobj->blendmode; if (!cv_translucency.value) // translucency disabled { @@ -3879,10 +3927,13 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) else if (spr->mobj->flags2 & MF2_SHADOW) { Surf.PolyColor.s.alpha = 0x40; - blend = PF_Translucent; + blend = HWR_GetBlendModeFlag(blendmode); } else if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + { + INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; + blend = HWR_SurfaceBlend(blendmode, trans, &Surf); + } else { // BP: i agree that is little better in environement but it don't @@ -3890,7 +3941,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; + blend = HWR_GetBlendModeFlag(blendmode)|PF_Occlude; } if (HWR_UseShader()) @@ -3903,7 +3954,7 @@ static void HWR_DrawSprite(gl_vissprite_t *spr) } // Sprite drawer for precipitation -static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) +static void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) { FBITFIELD blend = 0; FOutVector wallVerts[4]; @@ -3912,10 +3963,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) INT32 shader = SHADER_NONE; - if (!spr->mobj) - return; - - if (!spr->mobj->subsector) + if (!spr->mobj || !spr->mobj->subsector) return; // cache sprite graphics @@ -3979,7 +4027,10 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) HWR_Lighting(&Surf, lightlevel, colormap, P_SectorUsesDirectionalLighting(sector)); if (spr->mobj->frame & FF_TRANSMASK) - blend = HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + { + INT32 trans = (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT; + blend = HWR_SurfaceBlend(AST_TRANSLUCENT, trans, &Surf); + } else { // BP: i agree that is little better in environement but it don't @@ -3987,7 +4038,7 @@ static inline void HWR_DrawPrecipitationSprite(gl_vissprite_t *spr) // Hurdler: PF_Environement would be cool, but we need to fix // the issue with the fog before Surf.PolyColor.s.alpha = 0xFF; - blend = PF_Translucent|PF_Occlude; + blend = HWR_GetBlendModeFlag(AST_TRANSLUCENT)|PF_Occlude; } if (HWR_UseShader()) @@ -4314,6 +4365,24 @@ static void HWR_DrawSprites(void) { UINT32 i; + for (i = 0; i < gl_visspritecount; i++) + { + gl_vissprite_t *spr = gl_vsprorder[i]; + + if (spr->precip) + { + HWR_DrawPrecipitationSprite(spr); + continue; + } + + HWR_DrawSprite(spr); + } +} + +static void HWR_DrawModels(void) +{ + UINT32 i; + for (i = 0; i < gl_visspritecount; i++) { gl_vissprite_t *spr = gl_vsprorder[i]; @@ -4339,14 +4408,14 @@ static void HWR_DrawSprites(void) md2 = &md2_playermodels[(skin_t *)spr->mobj->skin - skins]; // 8/1/19: Only don't display player models if no default SPR_PLAY is found. - if (!cv_glmdls.value || ((md2->notfound || md2->scale < 0.0f) && ((!cv_glfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN]) + if (((md2->notfound || md2->scale < 0.0f) && ((!cv_glfallbackplayermodel.value) || md2_models[SPR_PLAY].notfound || md2_models[SPR_PLAY].scale < 0.0f)) || spr->mobj->state == &states[S_PLAY_SIGN]) HWR_DrawSprite(spr); else HWR_DrawMD2(spr); } else { - if (!cv_glmdls.value || md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) + if (md2_models[spr->mobj->sprite].notfound || md2_models[spr->mobj->sprite].scale < 0.0f) HWR_DrawSprite(spr); else HWR_DrawMD2(spr); @@ -4406,7 +4475,7 @@ static void HWR_AddSprites(sector_t *sec) static void HWR_AddPrecipitationSprites(void) { INT32 xl, xh, yl, yh, bx, by; - precipmobj_t *th; + precipmobj_t *th, *next; fixed_t drawdist; @@ -4436,8 +4505,11 @@ static void HWR_AddPrecipitationSprites(void) { for (by = yl; by <= yh; by++) { - for (th = precipblocklinks[(by * bmapwidth) + bx]; th; th = th->bnext) + for (th = precipblocklinks[(by * bmapwidth) + bx]; th; th = next) { + // Store this beforehand because HWR_ProjectPrecipitationSprite may free th (see P_PrecipThinker) + next = th->bnext; + if (th->precipflags & PCF_INVISIBLE) continue; @@ -4463,6 +4535,7 @@ 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 @@ -4509,30 +4582,39 @@ static void HWR_ProjectSprite(mobj_t *thing) if (interp.spritexscale < 1 || interp.spriteyscale < 1) return; + const boolean papersprite = (thing->frame & FF_PAPERSPRITE); + + if (thing->frame & FF_BLENDMASK) + blendmode = ((thing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = thing->blendmode; + + // Visibility check by the blend mode. + if (thing->frame & FF_TRANSMASK) + { + if (!R_BlendLevelVisible(blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT)) + return; + } + + // transform the origin point + tr_x = FIXED_TO_FLOAT(interp.x); + tr_y = FIXED_TO_FLOAT(interp.y); + + // rotation around vertical axis + tz = ((tr_x - gl_viewx) * gl_viewcos) + ((tr_y - gl_viewy) * gl_viewsin); + + // thing is behind view plane? + if (tz < ZCLIP_PLANE && !papersprite && (!cv_glmdls.value || md2_models[thing->sprite].notfound == true)) // Yellow: Only MD2's dont disappear + return; + const boolean mirrored = thing->mirrored; const boolean vflip = (thing->eflags & MFE_VERTICALFLIP); const boolean hflip = (!(thing->frame & FF_HORIZONTALFLIP) != !mirrored); - const boolean papersprite = (thing->frame & FF_PAPERSPRITE); this_scale = FIXED_TO_FLOAT(interp.scale); spritexscale = FIXED_TO_FLOAT(interp.spritexscale); spriteyscale = FIXED_TO_FLOAT(interp.spriteyscale); - // transform the origin point - tr_x = FIXED_TO_FLOAT(interp.x) - gl_viewx; - tr_y = FIXED_TO_FLOAT(interp.y) - gl_viewy; - - // rotation around vertical axis - tz = (tr_x * gl_viewcos) + (tr_y * gl_viewsin); - - // thing is behind view plane? - if (tz < ZCLIP_PLANE && !papersprite && (!cv_glmdls.value || md2_models[thing->sprite].notfound == true)) //Yellow: Only MD2's dont disappear - return; - - // The above can stay as it works for cutting sprites that are too close - tr_x = FIXED_TO_FLOAT(interp.x); - tr_y = FIXED_TO_FLOAT(interp.y); - // decide which patch to use for sprite relative to player #ifdef RANGECHECK if ((unsigned)thing->sprite >= numsprites) @@ -4543,8 +4625,8 @@ static void HWR_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE // determine here if sprite should rotate for optimization - const boolean sliprollrotate = (cv_sloperoll.value && cv_sliptideroll.value && (thing->player && thing->player->sliproll)); - const boolean shouldrotate = (cv_sloperoll.value && (interp.roll || interp.pitch || interp.sloperoll || interp.slopepitch || thing->rollangle || sliprollrotate)); + 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); #endif //Fab : 02-08-98: 'skin' override spritedef currently used for skin @@ -4585,9 +4667,9 @@ static void HWR_ProjectSprite(mobj_t *thing) I_Error("sprframes NULL for sprite %d\n", thing->sprite); #endif - if (sprframe->rotate != SRF_SINGLE || papersprite || + if (sprframe->rotate != SRF_SINGLE || papersprite #ifdef ROTSPRITE - (shouldrotate) + || (shouldrotate) #endif ) { @@ -4855,40 +4937,48 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) R_InterpolatePrecipMobjState(thing, FRACUNIT, &interp); } - this_scale = FIXED_TO_FLOAT(interp.scale); + // Visibility check by the blend mode. + if (thing->frame & FF_TRANSMASK) + { + if (!R_BlendLevelVisible(thing->blendmode, (thing->frame & FF_TRANSMASK)>>FF_TRANSSHIFT)) + return; + } // transform the origin point - tr_x = FIXED_TO_FLOAT(interp.x) - gl_viewx; - tr_y = FIXED_TO_FLOAT(interp.y) - gl_viewy; + tr_x = FIXED_TO_FLOAT(interp.x); + tr_y = FIXED_TO_FLOAT(interp.y); // rotation around vertical axis - tz = (tr_x * gl_viewcos) + (tr_y * gl_viewsin); + tz = ((tr_x - gl_viewx) * gl_viewcos) + ((tr_y - gl_viewy) * gl_viewsin); // thing is behind view plane? if (tz < ZCLIP_PLANE) return; - tr_x = FIXED_TO_FLOAT(interp.x); - tr_y = FIXED_TO_FLOAT(interp.y); - // decide which patch to use for sprite relative to player if ((unsigned)thing->sprite >= numsprites) + { #ifdef RANGECHECK I_Error("HWR_ProjectPrecipitationSprite: invalid sprite number %i ", thing->sprite); #else return; #endif + } sprdef = &sprites[thing->sprite]; if ((size_t)(thing->frame&FF_FRAMEMASK) >= sprdef->numframes) + { #ifdef RANGECHECK I_Error("HWR_ProjectPrecipitationSprite: invalid sprite frame %i : %i for %s", thing->sprite, thing->frame, sprnames[thing->sprite]); #else return; #endif + } + + this_scale = FIXED_TO_FLOAT(interp.scale); sprframe = &sprdef->spriteframes[thing->frame & FF_FRAMEMASK]; @@ -5184,8 +5274,11 @@ static void HWR_SetTransformAiming(FTransform *trans) trans->anglex = (float)(gl_aimingangle>>ANGLETOFINESHIFT)*(360.0f/(float)FINEANGLES); } -void HWR_SetTransform(float fpov, player_t *player) +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); @@ -5209,21 +5302,20 @@ void HWR_SetTransform(float fpov, player_t *player) gl_viewludsin = FIXED_TO_FLOAT(FINECOSINE(gl_aimingangle>>ANGLETOFINESHIFT)); gl_viewludcos = FIXED_TO_FLOAT(-FINESINE(gl_aimingangle>>ANGLETOFINESHIFT)); - atransform.fovxangle = fpov; // Tails - atransform.fovyangle = fpov; // Tails + atransform.fovangle = fpov; // Tails HWR_RollTransform(&atransform, viewroll); atransform.splitscreen = splitscreen; atransform.flip = false; - if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR)) + if ((thiscam->postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) atransform.flip = true; atransform.mirror = false; - if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP)) + if ((thiscam->postimg & POSTIMG_MIRROR) && !(thiscam->postimg & POSTIMG_FLIP)) atransform.mirror = true; atransform.mirrorflip = false; - if ((player->postimgflags & POSTIMG_FLIP) && (player->postimgflags & POSTIMG_MIRROR)) + if ((thiscam->postimg & POSTIMG_FLIP) && (thiscam->postimg & POSTIMG_MIRROR)) atransform.mirrorflip = true; // Set transform. @@ -5248,6 +5340,8 @@ void HWR_SetStencilState(int state, int level) GL_SetSpecialState(HWD_SET_PORTAL_MODE, state); } +typedef void (*bspfunc)(INT32 bspnum); + // Renders the current viewpoint, though takes portal arguments for recursive portals. void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *player, int stencil_level, boolean allow_portals) { @@ -5255,6 +5349,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; portallist.base = portallist.cap = NULL; @@ -5273,7 +5368,8 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl validcount++; - HWR_RenderBSPNode((INT32)numnodes-1);// no actual rendering happens + // no actual rendering happens + bspFunc((INT32)numnodes-1); // for each found portal: // note: if necessary, could sort the portals here? @@ -5290,7 +5386,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl // draw normal things in current frame in current incremented stencil buffer area HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); - HWR_SetTransform(fpov, player); + HWR_SetTransform(fpov); HWR_ClearSprites(); HWR_ClearClipper(); @@ -5304,12 +5400,12 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl // Set transform. GL_SetTransform(&atransform); - validcount++; - ps_numbspcalls.value.i = 0; ps_numpolyobjects.value.i = 0; PS_START_TIMING(ps_bsptime); + validcount++; + if (cv_glbatching.value) HWR_StartBatching(); @@ -5324,7 +5420,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl HWR_SetPortalState(GLPORTAL_INSIDE); // TURN IT OFF // Recursively "render" the BSP tree. - HWR_RenderBSPNode((INT32)numnodes-1); + bspFunc((INT32)numnodes-1); // woo we back HWR_SetPortalState(oldgl_portal_state); @@ -5347,7 +5443,7 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl HWR_DrawSkyBackground(); HWR_SetStencilState(HWR_STENCIL_NORMAL, 0); GL_ClearBuffer(false, false, true, 0);// clear skywall markings from the stencil buffer - HWR_SetTransform(fpov, player);// restore transform + HWR_SetTransform(fpov);// restore transform } gl_collect_skywalls = false; @@ -5356,7 +5452,10 @@ 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); - HWR_DrawSprites(); + if (!cv_glmdls.value) + HWR_DrawSprites(); + else + HWR_DrawModels(); PS_STOP_TIMING(ps_hw_spritedrawtime); ps_numdrawnodes.value.i = 0; @@ -5371,20 +5470,20 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *pl // ========================================================================== // Render the current frame. // ========================================================================== -static void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) +static void HWR_RenderFrame(player_t *player, boolean skybox) { - const float fpov = FIXED_TO_FLOAT(cv_fov.value+player->fovadd); + const float fpov = FixedToFloat(R_GetPlayerFov(player)); // set window position gl_viewwindowx = gl_baseviewwindowx; gl_viewwindowy = gl_baseviewwindowy; - if ((splitscreen == 1 && viewnumber == 1) || (splitscreen > 1 && viewnumber > 1)) + if ((splitscreen == 1 && viewssnum == 1) || (splitscreen > 1 && viewssnum > 1)) { gl_viewwindowy += gl_viewheight; } - if (splitscreen > 1 && viewnumber & 1) + if (splitscreen > 1 && viewssnum & 1) { gl_viewwindowx += gl_viewwidth; } @@ -5399,7 +5498,7 @@ static void HWR_RenderFrame(INT32 viewnumber, player_t *player, boolean skybox) for (x = vid.width>>1; x < vid.width; x += pw) { for (y = vid.height>>1; y < vid.height; y += ph) - HWR_DrawStretchyFixedPatch(gpatch, (x)<rollangle = roll / (float)ANG1; tr->roll = true; + tr->rollx = 1.0f; + tr->rollz = 0.0f; } } -void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) +void HWR_RenderPlayerView(void) { + player_t * player = &players[displayplayers[viewssnum]]; + const boolean skybox = (skyboxmo[0] && cv_skybox.value); // True if there's a skybox object and skyboxes are on // Clear the color buffer, stops HOMs. Also seems to fix the skybox issue on Intel GPUs. - if (viewnumber == 0) // Only do it if it's the first screen being rendered + if (viewssnum == 0) // Only do it if it's the first screen being rendered { FRGBAFloat ClearColor; @@ -5484,7 +5587,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) GL_SetShaderInfo(HWD_SHADERINFO_LIGHT_BACKLIGHT, maplighting.backlight); } - if (viewnumber > 3) + if (viewssnum > 3) return; // Render the skybox if there is one. @@ -5493,13 +5596,13 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) if (skybox) { R_SkyboxFrame(viewssnum); - HWR_RenderFrame(viewnumber, player, true); + HWR_RenderFrame(player, true); } PS_STOP_TIMING(ps_skyboxtime); R_SetupFrame(viewssnum, false); // This can stay false because it is only used to set viewsky in r_main.c, which isn't used here framecount++; // for timedemo - HWR_RenderFrame(viewnumber, player, false); + HWR_RenderFrame(player, false); } void HWR_LoadLevel(void) @@ -5603,8 +5706,6 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_glhorizonlines); CV_RegisterVar(&cv_glportals); - CV_RegisterVar(&cv_glfovchange); - CV_RegisterVar(&cv_glpaletterendering); CV_RegisterVar(&cv_glpalettedepth); CV_RegisterVar(&cv_glflashpal); @@ -5760,11 +5861,6 @@ static void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD #endif } -INT32 HWR_GetTextureUsed(void) -{ - return GL_GetTextureUsed(); -} - static void HWR_DoPostProcessor(player_t *player) { GL_UnSetShader(); @@ -5804,8 +5900,12 @@ static void HWR_DoPostProcessor(player_t *player) if (splitscreen) // Not supported in splitscreen - someone want to add support? return; + //UINT8 viewnum = R_GetViewNumber(); // see above + //camera_t *thiscam = &camera[viewnum]; + camera_t *thiscam = &camera[0]; + // Drunken vision! WooOOooo~ - if (player->postimgflags & POSTIMG_WATER || player->postimgflags & POSTIMG_HEAT) + if (thiscam->postimg & POSTIMG_WATER || thiscam->postimg & POSTIMG_HEAT) { // 10 by 10 grid. 2 coordinates (xy) float v[SCREENVERTS][SCREENVERTS][2]; @@ -5817,7 +5917,7 @@ static void HWR_DoPostProcessor(player_t *player) INT32 FREQUENCY; // Modifies the wave. - if (player->postimgflags & POSTIMG_WATER) + if (thiscam->postimg & POSTIMG_WATER) { WAVELENGTH = 5; AMPLITUDE = 20; @@ -5848,21 +5948,6 @@ static void HWR_DoPostProcessor(player_t *player) // Flipping of the screen isn't done here anymore } -void HWR_StartScreenWipe(void) -{ - GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_START); -} - -void HWR_EndScreenWipe(void) -{ - GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_END); -} - -void HWR_DrawIntermissionBG(void) -{ - GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); -} - void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) { static char lumpname[9] = "FADEmmss"; @@ -5897,19 +5982,4 @@ void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum) GL_DoScreenWipe(HWD_SCREENTEXTURE_WIPE_START, HWD_SCREENTEXTURE_WIPE_END); } -void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) -{ - GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); -} - -void HWR_MakeScreenFinalTexture(void) -{ - GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); -} - -void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader) -{ - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height, useshader); -} - #endif // HWRENDER diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 345c0e0a5..8ccb1b2a1 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -20,6 +20,7 @@ #ifndef __HWR_MAIN_H__ #define __HWR_MAIN_H__ +#include "hw_gl.h" #include "hw_glob.h" #include "hw_data.h" #include "hw_defs.h" @@ -29,6 +30,7 @@ #include "../d_player.h" #include "../r_defs.h" #include "../m_perfstats.h" +#include "../v_video.h" #define GLENCORE @@ -56,11 +58,11 @@ extern sector_t *gl_backsector; enum { - HWR_STENCIL_NORMAL, - HWR_STENCIL_BEGIN, - HWR_STENCIL_REVERSE, - HWR_STENCIL_DEPTH, - HWR_STENCIL_SKY + HWR_STENCIL_NORMAL, + HWR_STENCIL_BEGIN, + HWR_STENCIL_REVERSE, + HWR_STENCIL_DEPTH, + HWR_STENCIL_SKY }; // Performance stats @@ -84,7 +86,7 @@ extern boolean gl_shadersavailable; // hw_draw.c void HWR_DrawPatch(GLPatch_t *gpatch, INT32 x, INT32 y, INT32 option); -void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap); +void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 option, const UINT8 *colormap, INT32 bflags); void HWR_DrawCroppedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t pscale, INT32 option, fixed_t sx, fixed_t sy, fixed_t w, fixed_t h); void HWR_DrawFill(INT32 x, INT32 y, INT32 w, INT32 h, INT32 color); void HWR_DrawConsoleFill(INT32 x, INT32 y, INT32 w, INT32 h, UINT32 color, INT32 options); // Lat: separate flags from color since color needs to be an uint to work right. @@ -102,39 +104,65 @@ boolean HWR_Screenshot(const char *lbmname); void HWR_SetViewSize(void); void HWR_AddCommands(void); -void HWR_RenderPlayerView(INT32 viewnumber, player_t *player); +void HWR_RenderPlayerView(void); void HWR_RenderViewpoint(gl_portal_t *rootportal, const float fpov, player_t *player, int stencil_level, boolean allow_portals); void HWR_ClearSkyDome(void); void HWR_BuildSkyDome(void); -void HWR_SetTransform(float fpov, player_t *player); +void HWR_SetTransform(float fpov); void HWR_ClearClipper(void); void HWR_SetStencilState(int state, int level); -boolean HWR_UseShader(void); -boolean HWR_ShouldUsePaletteRendering(void); -boolean HWR_PalRenderFlashpal(void); - // My original intention was to split hw_main.c // 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, const boolean directional); +UINT8 HWR_GetTranstableAlpha(INT32 transtablenum); +FBITFIELD HWR_GetBlendModeFlag(INT32 ast); +FBITFIELD HWR_SurfaceBlend(INT32 style, INT32 transtablenum, FSurfaceInfo *pSurf); FBITFIELD HWR_TranstableToAlpha(INT32 transtablenum, FSurfaceInfo *pSurf); -// Get amount of memory used by gpu textures in bytes -INT32 HWR_GetTextureUsed(void); +// Get amount of memory used by gpu textures in bytes; +FUNCINLINE static ATTRINLINE INT32 HWR_GetTextureUsed(void) +{ + return GL_GetTextureUsed(); +} // hw_main.c: Post-rendering -void HWR_StartScreenWipe(void); -void HWR_EndScreenWipe(void); -void HWR_DrawIntermissionBG(void); void HWR_DoWipe(UINT8 wipenum, UINT8 scrnnum); -void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize); -void HWR_MakeScreenFinalTexture(void); -void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader); + +FUNCINLINE static ATTRINLINE void HWR_StartScreenWipe(void) +{ + GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_START); +} + +FUNCINLINE static ATTRINLINE void HWR_EndScreenWipe(void) +{ + GL_MakeScreenTexture(HWD_SCREENTEXTURE_WIPE_END); +} + +FUNCINLINE static ATTRINLINE void HWR_DrawIntermissionBG(void) +{ + GL_DrawScreenTexture(HWD_SCREENTEXTURE_GENERIC1, NULL, 0); +} + +FUNCINLINE static ATTRINLINE void HWR_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) +{ + GL_RenderVhsEffect(upbary, downbary, updistort, downdistort, barsize); +} + +FUNCINLINE static ATTRINLINE void HWR_MakeScreenFinalTexture(void) +{ + GL_MakeScreenTexture(HWD_SCREENTEXTURE_GENERIC2); +} + +FUNCINLINE static ATTRINLINE void HWR_DrawScreenFinalTexture(INT32 width, INT32 height, boolean useshader) +{ + GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, width, height, useshader); +} // hw_main.c: Segs void HWR_ProcessSeg(void); // Sort of like GLWall::Process in GZDoom @@ -181,10 +209,23 @@ extern consvar_t cv_glrenderdistance; extern consvar_t cv_glhorizonlines; extern consvar_t cv_glportals; -extern consvar_t cv_glfovchange; - extern consvar_t cv_glpaletterendering; extern consvar_t cv_glpalettedepth; extern consvar_t cv_glflashpal; +FUNCINLINE static ATTRINLINE boolean HWR_UseShader(void) +{ + return (cv_glshaders.value && gl_shadersavailable); +} + +FUNCINLINE static ATTRINLINE boolean HWR_ShouldUsePaletteRendering(void) +{ + return (cv_glpaletterendering.value && (pLocalPalette != NULL) && HWR_UseShader()); +} + +FUNCINLINE static ATTRINLINE boolean HWR_PalRenderFlashpal(void) +{ + return (HWR_ShouldUsePaletteRendering() && cv_glflashpal.value); +} + #endif diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 09d2ba979..611871a9a 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1163,8 +1163,6 @@ void HWR_DrawMD2(gl_vissprite_t *spr) spritedef_t *sprdef; spriteframe_t *sprframe; spriteinfo_t *sprinfo; - INT32 rollfactor = 0; - angle_t ang; interpmobjstate_t interp; if (R_UsingFrameInterpolation() && !paused && (!cv_maxinterpdist.value || R_QuickCamDist(spr->mobj->x, spr->mobj->y) < cv_maxinterpdist.value)) @@ -1181,13 +1179,31 @@ 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) + { Surf.PolyColor.s.alpha = 0x40; + Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); + } else if (spr->mobj->frame & FF_TRANSMASK) + { HWR_TranstableToAlpha((spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + Surf.PolyFlags = HWR_SurfaceBlend(blendmode, (spr->mobj->frame & FF_TRANSMASK)>>FF_TRANSSHIFT, &Surf); + } else - Surf.PolyColor.s.alpha = 0xFF; + { + // this hack is dumb, but the blendmodes refuse to work otherwise + Surf.PolyColor.s.alpha = (blendmode == AST_TRANSLUCENT) ? 0xFF : 0xFE; + Surf.PolyFlags = HWR_GetBlendModeFlag(blendmode); + } // dont forget to enabled the depth test because we can't do this like // before: polygons models are not sorted @@ -1343,7 +1359,7 @@ void HWR_DrawMD2(gl_vissprite_t *spr) p.x = FIXED_TO_FLOAT(interp.x); p.y = FIXED_TO_FLOAT(interp.y)+md2->offset; - if (spr->mobj->eflags & MFE_VERTICALFLIP) + if (flip) p.z = FIXED_TO_FLOAT(interp.z + spr->mobj->height); else p.z = FIXED_TO_FLOAT(interp.z); @@ -1366,109 +1382,58 @@ void HWR_DrawMD2(gl_vissprite_t *spr) const fixed_t anglef = AngleFixed((R_PointToAngle(interp.x, interp.y))-ANGLE_180); p.angley = FIXED_TO_FLOAT(anglef); } - - p.rollangle = 0.0f; - p.rollflip = 1; - p.rotaxis = 0; - - p.spritexscale = FIXED_TO_FLOAT(spr->mobj->spritexscale); - p.spriteyscale = FIXED_TO_FLOAT(spr->mobj->spriteyscale); - angle_t sliptideroll = ((cv_sloperoll.value && cv_sliptideroll.value && spr->mobj->player) ? spr->mobj->player->sliproll : 0); + const angle_t sliptideroll = ((cv_sliptideroll.value && spr->mobj->player) ? spr->mobj->player->sliproll : 0); + const SINT8 flipfactor = flip ? -1 : 1; if (spr->mobj->rollangle || sliptideroll) { - angle_t rollang = 0; - rollfactor = ((spr->mobj->rollmodel == true) ? 1 : 0); + angle_t rollang = sliptideroll + ? (spr->mobj->rollangle) + (sliptideroll * spr->mobj->player->kartstuff[k_aizdriftstrat]) + : (spr->mobj->rollangle); - rollang = sliptideroll - ? (spr->mobj->rollangle * rollfactor) + (sliptideroll * spr->mobj->player->kartstuff[k_aizdriftstrat]) - : (spr->mobj->rollangle * rollfactor); - fixed_t anglef = AngleFixed(rollang); - p.rollangle = FIXED_TO_FLOAT(anglef); - p.rollmodel = (spr->mobj->rollmodel); - p.roll = true; - // rotation pivot - p.centerx = FIXED_TO_FLOAT(spr->mobj->radius/2)*(p.spritexscale); - p.centery = FIXED_TO_FLOAT(spr->mobj->height/2)*(p.spriteyscale); + p.rollangle = 0.0f; - // rotation axis - if (sprinfo->available) - p.rotaxis = (UINT8)(sprinfo->pivot[(spr->mobj->frame & FF_FRAMEMASK)].rotaxis); + if (anglef) + { + fixed_t camAngleDiff = AngleFixed(viewangle) - FLOAT_TO_FIXED(p.angley); // dumb reconversion back, I know - // for NiGHTS specifically but should work everywhere else - ang = R_PointToAngle (spr->mobj->x, spr->mobj->y) - (spr->mobj->player ? spr->mobj->player->frameangle : spr->mobj->angle); - if ((sprframe->rotate & SRF_RIGHT) && (ang < ANGLE_180)) // See from right - p.rollflip = 1; - else if ((sprframe->rotate & SRF_LEFT) && (ang >= ANGLE_180)) // See from left - p.rollflip = -1; + p.rollangle = FIXED_TO_FLOAT(anglef); + p.roll = true; + + // rotation pivot + if (sprinfo->available) + { + p.centerx = FIXED_TO_FLOAT(sprinfo->pivot[frame].x); + p.centery = FIXED_TO_FLOAT(sprinfo->pivot[frame].y); + } + else + { + p.centerx = FIXED_TO_FLOAT(spr->mobj->radius/2); + p.centery = FIXED_TO_FLOAT(spr->mobj->height/2); + } + + // rotation axes relative to camera + p.rollx = FIXED_TO_FLOAT(FINECOSINE(FixedAngle(camAngleDiff) >> ANGLETOFINESHIFT)); + p.rollz = FIXED_TO_FLOAT(FINESINE(FixedAngle(camAngleDiff) >> ANGLETOFINESHIFT)); + } } - - p.anglex = 0.0f; - p.anglex2 = 0.0f; -#ifdef USE_FTRANSFORM_ANGLEZ - // Slope rotation from Kart - p.anglez = 0.0f; - p.anglez2 = 0.0f; - - // use secondary angles for the slope rotation - if (spr->mobj->standingslope) - { - fixed_t tempz = spr->mobj->standingslope->normal.z; - fixed_t tempy = spr->mobj->standingslope->normal.y; - fixed_t tempx = spr->mobj->standingslope->normal.x; - fixed_t tempangle = AngleFixed(R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx)); - p.anglez2 = FIXED_TO_FLOAT(tempangle); - tempangle = -AngleFixed(R_PointToAngle2(0, 0, tempz, tempy)); - p.anglex2 = FIXED_TO_FLOAT(tempangle); - } - else if ((spr->mobj->sloperoll || spr->mobj->slopepitch) && (!P_IsObjectOnGround(spr->mobj)) && (!paused)) - { - SINT8 flipfactor = flip ? -1 : 1; - - angle_t camang = R_PointToAngle(interp.x, interp.y); - angle_t mobjang; - - if (spr->mobj->flags & (MF_NOTHINK|MF_SCENERY)) - mobjang = spr->mobj->angle; - else - mobjang = interp.angle; - - angle_t fmoang; - fmoang = camang - mobjang; - - // slopepitch - p.anglex += flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINESINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.slopepitch)) ); - p.anglez -= flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINECOSINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.slopepitch)) ); - - // sloperoll - p.anglex += flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINECOSINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.sloperoll)) ); - p.anglez += flipfactor*FIXED_TO_FLOAT( AngleFixed(FixedMul(FINESINE((camang-fmoang) >> ANGLETOFINESHIFT), interp.sloperoll)) ); - p.roll = true; - } + // slope pitch and roll + p.anglex += flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.sloperoll)); + p.anglez -= flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.slopepitch)); // pitch and roll - if (interp.roll || interp.pitch) - { - SINT8 flipfactor = flip ? -1 : 1; - p.anglex += flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.roll)); - p.anglez -= flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.pitch)); - p.roll = true; - } -#endif + p.anglex += flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.roll)); + p.anglez -= flipfactor*FIXED_TO_FLOAT(AngleFixed(interp.pitch)); p.flip = atransform.flip; -#ifdef USE_FTRANSFORM_MIRROR p.mirror = atransform.mirror; // from Kart -#endif GL_SetShader(SHADER_MODEL); // model shader { - SINT8 flipfactor = flip ? -1 : 1; - float this_scale = FIXED_TO_FLOAT(interp.scale); float xs = this_scale * FIXED_TO_FLOAT(interp.spritexscale); diff --git a/src/hardware/hw_portal.c b/src/hardware/hw_portal.c index 27d77af2e..9bb5af40f 100644 --- a/src/hardware/hw_portal.c +++ b/src/hardware/hw_portal.c @@ -160,7 +160,7 @@ static void HWR_RenderPortalSeg(gl_portal_t* portal, SINT8 state) void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float fpov, player_t *player, int stencil_level) { // draw portal seg to stencil buffer with increment - HWR_SetTransform(fpov, player); + HWR_SetTransform(fpov); HWR_ClearClipper(); HWR_SetStencilState(HWR_STENCIL_BEGIN, stencil_level); @@ -180,7 +180,7 @@ void HWR_RenderPortal(gl_portal_t* portal, gl_portal_t* rootportal, const float } // remove portal seg from stencil buffer - HWR_SetTransform(fpov, player); + HWR_SetTransform(fpov); HWR_ClearClipper(); HWR_SetStencilState(HWR_STENCIL_REVERSE, stencil_level); diff --git a/src/hardware/hw_shaders.c b/src/hardware/hw_shaders.c index 0433636ac..b4041fcae 100644 --- a/src/hardware/hw_shaders.c +++ b/src/hardware/hw_shaders.c @@ -400,17 +400,18 @@ void HWR_CompileShaders(void) int HWR_GetShaderFromTarget(int shader_target) { - int custom_shader = gl_shadertargets[shader_target].custom_shader; - // use custom shader if following are true - // - custom shader exists - // - custom shader has been compiled successfully - // - custom shaders are enabled - // - custom shaders are allowed by the server - if (custom_shader != -1 && gl_shaders[custom_shader].compiled && - cv_glshaders.value == 1) - return custom_shader; - else - return gl_shadertargets[shader_target].base_shader; + if (cv_glshaders.value == 1) + { + int custom_shader = gl_shadertargets[shader_target].custom_shader; + // use custom shader if following are true + // - custom shader exists + // - custom shader has been compiled successfully + // - custom shaders are enabled + if (custom_shader != -1 && gl_shaders[custom_shader].compiled) + return custom_shader; + } + + return gl_shadertargets[shader_target].base_shader; } static inline UINT16 HWR_FindShaderDefs(UINT16 wadnum) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 5e072e600..a4a593d95 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -109,7 +109,6 @@ static GLint min_filter = GL_LINEAR; static GLint mag_filter = GL_LINEAR; static GLint anisotropic_filter = 0; boolean supportMipMap = false; -static FTransform md2_transform; const GLubyte *gl_version = NULL; const GLubyte *gl_renderer = NULL; @@ -495,6 +494,10 @@ static PFNglDeleteBuffers pglDeleteBuffers; typedef void (APIENTRY *PFNglColorPointer) (GLint, GLenum, GLsizei, const GLvoid*); static PFNglColorPointer pglColorPointer; +/* 2.0 functions */ +typedef void (APIENTRY * PFNglBlendEquation) (GLenum mode); +static PFNglBlendEquation pglBlendEquation; + /* 1.2 Parms */ /* GL_CLAMP_TO_EDGE_EXT */ #ifndef GL_CLAMP_TO_EDGE @@ -747,6 +750,9 @@ void SetupGLFunc4(void) pglBufferData = GetGLFunc("glBufferData"); pglDeleteBuffers = GetGLFunc("glDeleteBuffers"); pglColorPointer = GetGLFunc("glColorPointer"); + + /* 2.0 funcs */ + pglBlendEquation = GetGLFunc("glBlendEquation"); pglStencilFuncSeparate = GetGLFunc("glStencilFuncSeparate"); pglStencilOpSeparate = GetGLFunc("glStencilOpSeparate"); @@ -1164,7 +1170,7 @@ static void GL_Framebuffer_Delete(void) FramebufferObject = 0; } -inline void GL_Framebuffer_Unbind(void) +void GL_Framebuffer_Unbind(void) { if (!supportFBO || fboinit == false) return; @@ -1176,7 +1182,7 @@ inline void GL_Framebuffer_Unbind(void) pglBindRenderbuffer(GL_RENDERBUFFER, 0); } -inline void GL_Framebuffer_Enable(void) +void GL_Framebuffer_Enable(void) { if (!supportFBO || !UseScreenFBO()) return; @@ -1426,7 +1432,11 @@ void GL_Draw2DLine(F2DCoord * v1, F2DCoord * v2, RGBA_t Color) pglEnableClientState(GL_TEXTURE_COORD_ARRAY); pglEnable(GL_TEXTURE_2D); } - +// -----------------+ +// SetBlend : Set render mode +// -----------------+ +// PF_Masked - we could use an ALPHA_TEST of GL_EQUAL, and alpha ref of 0, +// is it faster when pixels are discarded ? static void Clamp2D(GLenum pname) { pglTexParameteri(GL_TEXTURE_2D, pname, GL_CLAMP); // fallback clamp @@ -1435,148 +1445,185 @@ static void Clamp2D(GLenum pname) #endif } -// -----------------+ -// SetBlend : Set render mode -// -----------------+ -// PF_Masked - we could use an ALPHA_TEST of GL_EQUAL, and alpha ref of 0, -// is it faster when pixels are discarded ? +static void GL_SetBlendEquation(GLenum mode) +{ + if (pglBlendEquation) + pglBlendEquation(mode); +} + +static void GL_SetBlendMode(FBITFIELD flags) +{ + // Set blending function + switch (flags) + { + case PF_Translucent & PF_Blending: + pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency + break; + case PF_Masked & PF_Blending: + // Hurdler: does that mean lighting is only made by alpha src? + // it sounds ok, but not for polygonsmooth + pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); // 0 alpha = holes in texture + break; + case PF_Additive & PF_Blending: + case PF_Subtractive & PF_Blending: + case PF_ReverseSubtract & PF_Blending: + pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest + break; + case PF_Environment & PF_Blending: + pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + break; + case PF_Multiplicative & PF_Blending: + pglBlendFunc(GL_DST_COLOR, GL_ZERO); + break; + case PF_Fog & PF_Fog: + // Sryder: Fog + // multiplies input colour by input alpha, and destination colour by input colour, then adds them + pglBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR); + break; + default: // must be 0, otherwise it's an error + // No blending + pglBlendFunc(GL_ONE, GL_ZERO); // the same as no blending + break; + } + + // Set blending equation + switch (flags) + { + case PF_Subtractive & PF_Blending: + GL_SetBlendEquation(GL_FUNC_SUBTRACT); + break; + case PF_ReverseSubtract & PF_Blending: + // good for shadow + // not really but what else ? + GL_SetBlendEquation(GL_FUNC_REVERSE_SUBTRACT); + break; + default: + GL_SetBlendEquation(GL_FUNC_ADD); + break; + } + + // Alpha test + switch (flags) + { + case PF_Masked & PF_Blending: + pglAlphaFunc(GL_GREATER, 0.5f); + break; + case PF_Translucent & PF_Blending: + case PF_Additive & PF_Blending: + case PF_Subtractive & PF_Blending: + case PF_ReverseSubtract & PF_Blending: + case PF_Environment & PF_Blending: + case PF_Multiplicative & PF_Blending: + pglAlphaFunc(GL_NOTEQUAL, 0.0f); + break; + case PF_Fog & PF_Fog: + pglAlphaFunc(GL_ALWAYS, 0.0f); // Don't discard zero alpha fragments + break; + default: + pglAlphaFunc(GL_GREATER, 0.5f); + break; + } +} + void GL_SetBlend(FBITFIELD PolyFlags) { - const FBITFIELD Xor = (CurrentPolyFlags ^ 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|PF_NoAlphaTest))) + if (Xor & (PF_Blending|PF_RemoveYWrap|PF_ForceWrapX|PF_ForceWrapY|PF_Occlude|PF_NoTexture|PF_Modulated|PF_NoDepthTest|PF_Decal|PF_Invisible)) { - CurrentPolyFlags = PolyFlags; - return; - } + if (Xor & PF_Blending) // if blending mode must be changed + GL_SetBlendMode(PolyFlags & PF_Blending); - if (Xor & PF_Blending) // if blending mode must be changed - { - switch (PolyFlags & PF_Blending) + if (Xor & PF_NoAlphaTest) { - case (PF_Translucent & PF_Blending): - pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // alpha = level of transparency - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case (PF_Masked & PF_Blending): - // Hurdler: does that mean lighting is only made by alpha src? - // it sounds ok, but not for polygonsmooth - pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); // 0 alpha = holes in texture - pglAlphaFunc(GL_GREATER, 0.5f); - break; - case (PF_Additive & PF_Blending): - pglBlendFunc(GL_SRC_ALPHA, GL_ONE); // src * alpha + dest - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case (PF_Environment & PF_Blending): - pglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case (PF_Substractive & PF_Blending): - // good for shadow - // not really but what else ? - pglBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR); - pglAlphaFunc(GL_NOTEQUAL, 0.0f); - break; - case (PF_Fog & PF_Fog): - // Sryder: Fog - // multiplies input colour by input alpha, and destination colour by input colour, then adds them - pglBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR); - pglAlphaFunc(GL_ALWAYS, 0.0f); // Don't discard zero alpha fragments - break; - default : // must be 0, otherwise it's an error - // No blending - pglBlendFunc(GL_ONE, GL_ZERO); // the same as no blending - pglAlphaFunc(GL_GREATER, 0.5f); - break; + if (PolyFlags & PF_NoAlphaTest) + pglDisable(GL_ALPHA_TEST); + else + pglEnable(GL_ALPHA_TEST); // discard 0 alpha pixels (holes in texture) } - } - if (Xor & PF_NoAlphaTest) - { - if (PolyFlags & PF_NoAlphaTest) - pglDisable(GL_ALPHA_TEST); - else - pglEnable(GL_ALPHA_TEST); // discard 0 alpha pixels (holes in texture) - } + if (Xor & PF_Decal) + { + if (PolyFlags & PF_Decal) + pglEnable(GL_POLYGON_OFFSET_FILL); + else + pglDisable(GL_POLYGON_OFFSET_FILL); + } - if (Xor & PF_Decal) - { - if (PolyFlags & PF_Decal) - pglEnable(GL_POLYGON_OFFSET_FILL); - else - pglDisable(GL_POLYGON_OFFSET_FILL); - } - if (Xor & PF_NoDepthTest) - { - if (PolyFlags & PF_NoDepthTest) - pglDepthFunc(GL_ALWAYS); //pglDisable(GL_DEPTH_TEST); - else - pglDepthFunc(GL_LEQUAL); //pglEnable(GL_DEPTH_TEST); - } + if (Xor & PF_NoDepthTest) + { + if (PolyFlags & PF_NoDepthTest) + pglDepthFunc(GL_ALWAYS); //pglDisable(GL_DEPTH_TEST); + else + pglDepthFunc(GL_LEQUAL); //pglEnable(GL_DEPTH_TEST); + } - if (Xor & PF_RemoveYWrap) - { - if (PolyFlags & PF_RemoveYWrap) - Clamp2D(GL_TEXTURE_WRAP_T); - } + if (Xor & PF_RemoveYWrap) + { + if (PolyFlags & PF_RemoveYWrap) + Clamp2D(GL_TEXTURE_WRAP_T); + } - if (Xor & PF_ForceWrapX) - { - if (PolyFlags & PF_ForceWrapX) - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - } + if (Xor & PF_ForceWrapX) + { + if (PolyFlags & PF_ForceWrapX) + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + } - if (Xor & PF_ForceWrapY) - { - if (PolyFlags & PF_ForceWrapY) - pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - } + if (Xor & PF_ForceWrapY) + { + if (PolyFlags & PF_ForceWrapY) + pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + } - if (Xor & PF_Modulated) - { + if (Xor & PF_Modulated) + { #if defined (__unix__) || defined (UNIXCOMMON) - if (oglflags & GLF_NOTEXENV) - { - if (!(PolyFlags & PF_Modulated)) - pglColor4ubv(white); - } - else + if (oglflags & GLF_NOTEXENV) + { + if (!(PolyFlags & PF_Modulated)) + pglColor4ubv(white); + } + else #endif + if (PolyFlags & PF_Modulated) + { // mix texture colour with Surface->PolyColor + pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + } + else + { // colour from texture is unchanged before blending + pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + } + } - // mix texture colour with Surface->PolyColor - if (PolyFlags & PF_Modulated) - pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - // colour from texture is unchanged before blending - else - pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - } - - if (Xor & PF_Occlude) // depth test but (no) depth write - { - if (PolyFlags & PF_Occlude) - pglDepthMask(1); - else - pglDepthMask(0); - } - - ////Hurdler: not used if we don't define POLYSKY - if (Xor & PF_Invisible) - { - if (PolyFlags&PF_Invisible) - pglBlendFunc(GL_ZERO, GL_ONE); // transparent blending - else - { // big hack: (TODO: manage that better) - // we test only for PF_Masked because PF_Invisible is only used - // (for now) with it (yeah, that's crappy, sorry) - if ((PolyFlags & PF_Blending) == PF_Masked) - pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); + if (Xor & PF_Occlude) // depth test but (no) depth write + { + if (PolyFlags&PF_Occlude) + { + pglDepthMask(1); + } + else + pglDepthMask(0); + } + ////Hurdler: not used if we don't define POLYSKY + if (Xor & PF_Invisible) + { + if (PolyFlags&PF_Invisible) + pglBlendFunc(GL_ZERO, GL_ONE); // transparent blending + else + { // big hack: (TODO: manage that better) + // we test only for PF_Masked because PF_Invisible is only used + // (for now) with it (yeah, that's crappy, sorry) + if ((PolyFlags&PF_Blending)==PF_Masked) + pglBlendFunc(GL_SRC_ALPHA, GL_ZERO); + } + } + if (PolyFlags & PF_NoTexture) + { + GL_SetNoTexture(); } } - if (PolyFlags & PF_NoTexture) - GL_SetNoTexture(); - CurrentPolyFlags = PolyFlags; } @@ -1604,6 +1651,7 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) INT32 w = pTexInfo->width, h = pTexInfo->height; INT32 i, j; + INT32 idx; const GLubyte *pImgData = (const GLubyte *)pTexInfo->data; const GLvoid *ptex = NULL; @@ -1632,18 +1680,13 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) const int chromakeyed = (pTexInfo->flags & TF_CHROMAKEYED); - for (j = 0; j < h; j++) + for (idx = 0, j = 0; j < h; j++) { - for (i = 0; i < w; i++) + for (i = 0; i < w; i++, idx++) { - int idx = (w*j+i); - if (chromakeyed && (*pImgData == HWR_PATCHES_CHROMAKEY_COLORINDEX)) { - tex[idx].s.red = 0; - tex[idx].s.green = 0; - tex[idx].s.blue = 0; - tex[idx].s.alpha = 0; + tex[idx].s = (byteColor_t){0, 0, 0, 0}; pTexInfo->flags |= TF_TRANSPARENT; // there is a hole in it } else @@ -1672,12 +1715,10 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) ptex = tex = textureBuffer; texformat = GL_LUMINANCE_ALPHA; - for (j = 0; j < h; j++) + for (idx = 0, j = 0; j < h; j++) { - for (i = 0; i < w; i++) + for (i = 0; i < w; i++, idx++) { - int idx = (w*j+i); - tex[idx].s.red = *pImgData; tex[idx].s.green = *pImgData; tex[idx].s.blue = *pImgData; @@ -1692,17 +1733,13 @@ static void GL_UpdateTexture(GLMipmap_t *pTexInfo) ptex = tex = textureBuffer; texformat = GL_ALPHA; - for (j = 0; j < h; j++) - { - for (i = 0; i < w; i++) - { - int idx = (w*j+i); + memset(&tex->s, 255, sizeof(byteColor_t)*w*h); // 255 because the fade mask is modulated with the screen texture, so alpha affects it while the colours don't - tex[idx].s.red = 255; // 255 because the fade mask is modulated with the screen texture, so alpha affects it while the colours don't - tex[idx].s.green = 255; - tex[idx].s.blue = 255; - tex[idx].s.alpha = *pImgData; - pImgData++; + for (idx = 0, j = 0; j < h; j++) + { + for (i = 0; i < w; i++, idx++) + { + tex[idx].s.alpha = *pImgData++; } } break; @@ -2596,14 +2633,11 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics poly.green = byte2float[Surface->PolyColor.s.green]; poly.blue = byte2float[Surface->PolyColor.s.blue]; poly.alpha = byte2float[Surface->PolyColor.s.alpha]; - - if (poly.alpha < 1) - GL_SetBlend(PF_Translucent|PF_Modulated); - else - GL_SetBlend(PF_Masked|PF_Modulated|PF_Occlude); - + pglColor4ubv((GLubyte*)&Surface->PolyColor.s); + GL_SetBlend((poly.alpha < 1 ? Surface->PolyFlags : (PF_Masked|PF_Occlude))|PF_Modulated); + tint.red = byte2float[Surface->TintColor.s.red]; tint.green = byte2float[Surface->TintColor.s.green]; tint.blue = byte2float[Surface->TintColor.s.blue]; @@ -2627,7 +2661,6 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics pglEnable(GL_CULL_FACE); pglEnable(GL_NORMALIZE); -#ifdef USE_FTRANSFORM_MIRROR // flipped is if the object is vertically flipped // hflipped is if the object is horizontally flipped // pos->flip is if the screen is flipped vertically @@ -2640,13 +2673,6 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics else pglCullFace(GL_BACK); } -#else - // pos->flip is if the screen is flipped too - if (flipped ^ hflipped ^ pos->flip) // If one or three of these are active, but not two, invert the model's culling - pglCullFace(GL_FRONT); - else - pglCullFace(GL_BACK); -#endif pglPushMatrix(); // should be the same as glLoadIdentity pglTranslatef(pos->x, pos->z, pos->y); @@ -2654,30 +2680,15 @@ void GL_DrawModelEx(model_t *model, INT32 frameIndex, float duration, float tics scaley = -scaley; if (hflipped) scalez = -scalez; -#ifdef USE_FTRANSFORM_ANGLEZ - pglRotatef(pos->anglez2, 0.0f, 0.0f, -1.0f); // rotate by slope from Kart -#endif - pglRotatef(pos->anglex2, -1.0f, 0.0f, 0.0f); + + pglRotatef(pos->anglez, 0.0f, 0.0f, -1.0f); + pglRotatef(pos->anglex, 1.0f, 0.0f, 0.0f); pglRotatef(pos->angley, 0.0f, -1.0f, 0.0f); if (pos->roll) { - float roll = (1.0f * pos->rollflip); pglTranslatef(pos->centerx, pos->centery, 0); - - // rotate model for pitch and roll - pglRotatef(pos->anglex, 1.0f, 0.0f, 0.0f); -#ifdef USE_FTRANSFORM_ANGLEZ - pglRotatef(pos->anglez, 0.0f, 0.0f, -1.0f); -#endif - - if (pos->rotaxis == 2) // Z - pglRotatef(pos->rollangle, 0.0f, 0.0f, roll); - else if (pos->rotaxis == 1) // Y - pglRotatef(pos->rollangle, 0.0f, roll, 0.0f); - else // X - pglRotatef(pos->rollangle, roll, 0.0f, 0.0f); - + pglRotatef(pos->rollangle, pos->rollx, 0.0f, pos->rollz); pglTranslatef(-pos->centerx, -pos->centery, 0); } @@ -2800,20 +2811,14 @@ void GL_SetTransform(FTransform *stransform) if (stransform) { - used_fov = stransform->fovxangle; + used_fov = stransform->fovangle; shearing = stransform->shearing; - // keep a trace of the transformation for md2 - memcpy(&md2_transform, stransform, sizeof (md2_transform)); -#ifdef USE_FTRANSFORM_MIRROR - // mirroring from Kart if (stransform->mirror) pglScalef(-stransform->scalex, stransform->scaley, -stransform->scalez); else if (stransform->mirrorflip) pglScalef(-stransform->scalex, -stransform->scaley, -stransform->scalez); - else -#endif - if (stransform->flip) + else if (stransform->flip) pglScalef(stransform->scalex, -stransform->scaley, -stransform->scalez); else pglScalef(stransform->scalex, stransform->scaley, -stransform->scalez); @@ -2891,7 +2896,7 @@ void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) INT32 x, y; float float_x, float_y, float_nextx, float_nexty; float xfix, yfix; - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; const float blackBack[16] = { @@ -2905,12 +2910,15 @@ void GL_PostImgRedraw(float points[SCREENVERTS][SCREENVERTS][2]) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; + + while (texsizey < screen_height) + texsizey <<= 1; // X/Y stretch fix for all resolutions(!) - xfix = (float)(texsize)/((float)((screen_width)/(float)(SCREENVERTS-1))); - yfix = (float)(texsize)/((float)((screen_height)/(float)(SCREENVERTS-1))); + xfix = (float)(texsizew)/((float)((screen_width)/(float)(SCREENVERTS-1))); + yfix = (float)(texsizey)/((float)((screen_height)/(float)(SCREENVERTS-1))); pglDisable(GL_DEPTH_TEST); pglDisable(GL_BLEND); @@ -2983,7 +2991,7 @@ void GL_FlushScreenTextures(void) void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) { float xfix, yfix; - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; const float screenVerts[12] = { @@ -2999,11 +3007,14 @@ void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); // const float screenVerts[12] @@ -3036,7 +3047,7 @@ void GL_DrawScreenTexture(int tex, FSurfaceInfo *surf, FBITFIELD polyflags) // Do screen fades! void GL_DoScreenWipe(int wipeStart, int wipeEnd) { - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; float xfix, yfix; INT32 fademaskdownloaded = tex_downloaded; // the fade mask that has been set @@ -3063,11 +3074,14 @@ void GL_DoScreenWipe(int wipeStart, int wipeEnd) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); // const float screenVerts[12] @@ -3127,7 +3141,7 @@ void GL_DoScreenWipe(int wipeStart, int wipeEnd) void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 downdistort, UINT8 barsize) { - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; int tex = HWD_SCREENTEXTURE_VHS; float xfix, yfix; float fix[8]; @@ -3146,11 +3160,14 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); // Slight fuzziness GL_MakeScreenTexture(tex); @@ -3234,15 +3251,18 @@ void GL_RenderVhsEffect(fixed_t upbary, fixed_t downbary, UINT8 updistort, UINT8 // Create a texture from the screen. void GL_MakeScreenTexture(int tex) { - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; boolean firstTime = (screenTextures[tex] == 0); if (!gl_enable_screen_textures) return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; + + while (texsizey < screen_height) + texsizey <<= 1; // Create screen texture if (firstTime) @@ -3255,10 +3275,10 @@ void GL_MakeScreenTexture(int tex) pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); Clamp2D(GL_TEXTURE_WRAP_S); Clamp2D(GL_TEXTURE_WRAP_T); - pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texsize, texsize, 0); + pglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, texsizew, texsizey, 0); } else - pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texsize, texsize); + pglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, texsizew, texsizey); tex_downloaded = screenTextures[tex]; } @@ -3269,7 +3289,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh float origaspect, newaspect; float xoff = 1, yoff = 1; // xoffset and yoffset for the polygon to have black bars around the screen FRGBAFloat clearColour; - INT32 texsize = 512; + INT32 texsizew = 512, texsizey = 512; float off[12]; float fix[8]; @@ -3278,11 +3298,14 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh return; // look for power of two that is large enough for the screen - while (texsize < screen_width || texsize < screen_height) - texsize <<= 1; + while (texsizew < screen_width) + texsizew <<= 1; - xfix = 1/((float)(texsize)/((float)((screen_width)))); - yfix = 1/((float)(texsize)/((float)((screen_height)))); + while (texsizey < screen_height) + texsizey <<= 1; + + xfix = 1/((float)(texsizew)/((float)((screen_width)))); + yfix = 1/((float)(texsizey)/((float)((screen_height)))); origaspect = (float)screen_width / screen_height; newaspect = (float)width / height; @@ -3339,7 +3362,7 @@ void GL_DrawScreenFinalTexture(int tex, INT32 width, INT32 height, boolean usesh pglVertexPointer(3, GL_FLOAT, 0, off); pglDrawArrays(GL_TRIANGLE_FAN, 0, 4); - + if (useshader) pglUseProgram(0); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 6cbb46148..3cefb74d0 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -26,6 +26,7 @@ #include "i_video.h" #include "i_system.h" +#include "r_fps.h" #include "st_stuff.h" // ST_HEIGHT #include "r_local.h" @@ -69,7 +70,6 @@ patch_t *hu_font[HU_FONTSIZE]; patch_t *kart_font[KART_FONTSIZE]; // SRB2kart patch_t *tny_font[HU_FONTSIZE]; patch_t *tallnum[10]; // 0-9 -patch_t *nightsnum[10]; // 0-9 // Level title and credits fonts patch_t *lt_font[LT_FONTSIZE]; @@ -100,24 +100,8 @@ patch_t *rflagico; patch_t *bflagico; patch_t *rmatcico; patch_t *bmatcico; -patch_t *tagico; patch_t *tallminus; -//------------------------------------------- -// coop hud -//------------------------------------------- - -patch_t *emeraldpics[7]; -patch_t *tinyemeraldpics[7]; -static patch_t *emblemicon; -static patch_t *tokenicon; - -//------------------------------------------- -// misc vars -//------------------------------------------- - -// crosshair 0 = off, 1 = cross, 2 = angle, 3 = point, see m_menu.c -static patch_t *crosshair[HU_CROSSHAIRS]; // 3 precached crosshair graphics // song credits static patch_t *songcreditbg; @@ -381,8 +365,6 @@ void HU_LoadGraphics(void) { sprintf(buffer, "STTNUM%d", i); tallnum[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - sprintf(buffer, "NGTNUM%d", i); - nightsnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); sprintf(buffer, "PINGN%d", i); pingnum[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); sprintf(buffer, "OPPRNK0%d", i); @@ -392,32 +374,6 @@ void HU_LoadGraphics(void) // minus for negative tallnums tallminus = (patch_t *)W_CachePatchName("STTMINUS", PU_HUDGFX); - // cache the crosshairs, don't bother to know which one is being used, - // just cache all 3, they're so small anyway. - for (i = 0; i < HU_CROSSHAIRS; i++) - { - sprintf(buffer, "CROSHAI%c", '1'+i); - crosshair[i] = (patch_t *)W_CachePatchName(buffer, PU_HUDGFX); - } - - emblemicon = W_CachePatchName("EMBLICON", PU_HUDGFX); - tokenicon = W_CachePatchName("TOKNICON", PU_HUDGFX); - - emeraldpics[0] = W_CachePatchName("CHAOS1", PU_HUDGFX); - emeraldpics[1] = W_CachePatchName("CHAOS2", PU_HUDGFX); - emeraldpics[2] = W_CachePatchName("CHAOS3", PU_HUDGFX); - emeraldpics[3] = W_CachePatchName("CHAOS4", PU_HUDGFX); - emeraldpics[4] = W_CachePatchName("CHAOS5", PU_HUDGFX); - emeraldpics[5] = W_CachePatchName("CHAOS6", PU_HUDGFX); - emeraldpics[6] = W_CachePatchName("CHAOS7", PU_HUDGFX); - tinyemeraldpics[0] = W_CachePatchName("TEMER1", PU_HUDGFX); - tinyemeraldpics[1] = W_CachePatchName("TEMER2", PU_HUDGFX); - tinyemeraldpics[2] = W_CachePatchName("TEMER3", PU_HUDGFX); - tinyemeraldpics[3] = W_CachePatchName("TEMER4", PU_HUDGFX); - tinyemeraldpics[4] = W_CachePatchName("TEMER5", PU_HUDGFX); - tinyemeraldpics[5] = W_CachePatchName("TEMER6", PU_HUDGFX); - tinyemeraldpics[6] = W_CachePatchName("TEMER7", PU_HUDGFX); - songcreditbg = W_CachePatchName("K_SONGCR", PU_HUDGFX); // cache ping gfx: @@ -1198,7 +1154,7 @@ void HU_Ticker(void) || hu_redownloadinggamestate #endif ) - resynch_ticker++; //tic tic tic tic tic + resynch_ticker++; //tic tic tic tic tic HU_TickSongCredits(); } @@ -2231,7 +2187,7 @@ void HU_DrawSongCredits(void) // void HU_Drawer(void) { - if (cv_vhseffect.value && (paused || (demo.playback && cv_playbackspeed.value > 1))) + if (cv_vhseffect.value && ((paused && !camera[R_GetViewNumber()].freecam) || (demo.playback && cv_playbackspeed.value > 1))) V_DrawVhsEffect(demo.rewinding); #ifndef NONET @@ -2289,22 +2245,6 @@ void HU_Drawer(void) if (gamestate != GS_LEVEL) return; - // draw the crosshair, not when viewing demos nor with chasecam - /*if (!automapactive && !demo.playback) - { - if (cv_crosshair.value && !camera[0].chase && !players[displayplayers[0]].spectator) - HU_DrawCrosshair(); - - if (cv_crosshair2.value && !camera[1].chase && !players[displayplayers[1]].spectator) - HU_DrawCrosshair2(); - - if (cv_crosshair3.value && !camera[2].chase && !players[displayplayers[2]].spectator) - HU_DrawCrosshair3(); - - if (cv_crosshair4.value && !camera[3].chase && !players[displayplayers[3]].spectator) - HU_DrawCrosshair4(); - }*/ - // draw song credits if (cv_songcredits.value) HU_DrawSongCredits(); @@ -2416,92 +2356,138 @@ Ping_gfx_num (int lag) return 4; } +static int +Ping_gfx_color (int lag) +{ + if (lag < 2) + return SKINCOLOR_JAWZ; + else if (lag < 4) + return SKINCOLOR_MINT; + else if (lag < 7) + return SKINCOLOR_GOLD; + else if (lag < 10) + return SKINCOLOR_RED; + else + return SKINCOLOR_WHITE; // SKINCOLOR_MAGENTA +} + +static const UINT8 * +Ping_gfx_colormap (UINT32 lag, boolean gentleman) +{ + const UINT8 *colormap = NULL; + + if (K_UseColorHud()) + colormap = R_GetTranslationColormap(TC_RAINBOW, Ping_gfx_color(lag), GTC_CACHE); + + if (servermaxping && lag > servermaxping && hu_tick < 4) + { + // flash ping red if too high + colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE); + } + else if (gentleman) + { + colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_PASTEL, GTC_CACHE); + } + + return colormap; +} + +static UINT32 +Ping_conversion (UINT32 lag) +{ + if (cv_pingmeasurement.value) + { + lag = (INT32)(lag * (1000.00f / TICRATE)); + } + + return lag; +} + // // HU_drawPing // -void HU_drawPing(INT32 x, INT32 y, UINT32 lag, INT32 flags) +void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags) { - UINT8 *colormap = NULL; INT32 measureid = cv_pingmeasurement.value ? 1 : 0; INT32 gfxnum; // gfx to draw - + //SRB2/Kart v1.0 style UINT8 numbars = 0; // how many ping bars do we draw? UINT8 barcolor = 31; // color we use for the bars (green, yellow, red or black) SINT8 i = 0; SINT8 yoffset = 6; - //INT32 dx; - gfxnum = Ping_gfx_num(lag); - - if (!cv_pingstyle.value) + UINT32 lag = playerpingtable[pnum]; + const boolean gentleman = (cv_mindelay.value && (lag < (tic_t)simulated_lag)); + + if (gentleman) { + lag = simulated_lag; + } + + if (cv_pingstyle.value == 0) // kart + { + gfxnum = Ping_gfx_num(lag); + 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]); - if (servermaxping && lag > servermaxping && hu_tick < 4) - colormap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE); // flash ping red if too high - - if (cv_pingmeasurement.value) - lag = (INT32)(lag * (1000.00f / TICRATE)); - - x = V_DrawPingNum(x + (measureid == 1 ? 11 - pingmeasure[measureid]->width : 10), y+9, flags, lag, colormap); + x = V_DrawPingNum(x + (measureid == 1 ? 11 - pingmeasure[measureid]->width : 10), y+9, flags, Ping_conversion(lag), Ping_gfx_colormap(lag, gentleman)); if (measureid == 0) - V_DrawScaledPatch(x+1 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]); + V_DrawScaledPatch(x+1 - pingmeasure[measureid]->width, y+9, flags, pingmeasure[measureid]); } - else if (cv_pingstyle.value) // old style ping + else if (cv_pingstyle.value == 1) // old style ping { - if (cv_pingicon.value) - { - if (lag < 4) - { - numbars = 3; - barcolor = 184; - } - else if (lag < 7) - { - numbars = 2; // Apparently ternaries w/ multiple statements don't look good in C so I decided against it. - barcolor = 103; - } - else if (lag < 10) - { - numbars = 1; - barcolor = 155; // need a better red - } - else // brazil - { - numbars = 0; - barcolor = 31; - } - } - - if (cv_pingmeasurement.value) - lag = (INT32)(lag * (1000.00f / TICRATE)); - if (vid.width >= 640) // how sad, we're using a shit resolution. { if (measureid == 1) { - //dx = x+1 - (V_SmallStringWidth(va("%dms", lag), V_ALLOWLOWERCASE|flags)/2); - //V_DrawSmallString(dx, y+4, V_ALLOWLOWERCASE|flags, va("%dms", lag)); - V_DrawRightAlignedSmallString(x+12, y+13, V_ALLOWLOWERCASE|flags, va("%dms", lag)); + V_DrawRightAlignedSmallString(x+12, y+13, V_ALLOWLOWERCASE|flags, va("%dms", Ping_conversion(lag))); } else if (measureid == 0) { - //dx = x+1 - (V_SmallStringWidth(va("d%d", lag), flags)/2); - //V_DrawSmallString(dx, y+4, flags, va("d%d", lag)); - V_DrawRightAlignedSmallString(x+12, y+13, flags, va("d%d", lag)); + V_DrawRightAlignedSmallString(x+12, y+13, flags, va("d%d", Ping_conversion(lag))); } } if (cv_pingicon.value) - { - for (i=0; (i<3); i++) // Draw the ping bar + { + switch (lag) + { + case 0 ... 1: + numbars = 3; + barcolor = 215; // Blue + break; + case 2 ... 3: + numbars = 3; + barcolor = 184; // Green + break; + case 4 ... 6: + numbars = 2; // Apparently ternaries w/ multiple statements don't look good in C so I decided against it. + barcolor = 103; // Yellow + break; + case 7 ... 9: + numbars = 1; + barcolor = 155; // Red + break; + default: // Brazil + numbars = 0; + barcolor = 31; // black + break; + } + + if (gentleman) + { + barcolor = 194; // make it purplish + // bars get indirectly set earlier + } + + for (i = 0; (i < 3); i++) // Draw the ping bar { V_DrawFill(x+2 *(i-1)+7, y+8+yoffset-4, 2, 8-yoffset, 31|flags); if (i < numbars) @@ -2595,8 +2581,10 @@ static inline void HU_DrawSpectatorTicker(void) } } - if (netgame && i != serverplayer) - HU_drawPing((templength - duptweak)+8, height-20, playerpingtable[i], V_TRANSLUCENT); + if ((netgame && i != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(&players[i]))) + { + HU_drawPlayerPing((templength - duptweak)+8, height-20, i, V_TRANSLUCENT); + } } if ((length += len) >= dupadjust+8) diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 66459c716..00ee1a1e7 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -42,8 +42,6 @@ #define CRED_FONTEND 'Z' // the last font character #define CRED_FONTSIZE (CRED_FONTEND - CRED_FONTSTART + 1) -#define HU_CROSSHAIRS 3 // maximum of 9 - see HU_Init(); - extern char *shiftxform; // english translation shift table extern char english_shiftxform[]; @@ -90,18 +88,14 @@ extern patch_t *tallnum[10]; extern patch_t *pingnum[10]; extern patch_t *pinggfx[5]; extern patch_t *ranknum[10]; -extern patch_t *nightsnum[10]; extern patch_t *framecounter; extern patch_t *frameslash; extern patch_t *lt_font[LT_FONTSIZE]; extern patch_t *cred_font[CRED_FONTSIZE]; -extern patch_t *emeraldpics[7]; -extern patch_t *tinyemeraldpics[7]; extern patch_t *rflagico; extern patch_t *bflagico; extern patch_t *rmatcico; extern patch_t *bmatcico; -extern patch_t *tagico; extern patch_t *tallminus; // set true whenever the tab rankings are being shown for any reason @@ -125,7 +119,7 @@ void HU_Drawer(void); char HU_dequeueChatChar(void); void HU_Erase(void); void HU_clearChatChars(void); -void HU_drawPing(INT32 x, INT32 y, UINT32 ping, INT32 flags); // Lat': Ping drawer for scoreboard. +void HU_drawPlayerPing(INT32 x, INT32 y, INT32 pnum, INT32 flags); // Lat': Ping drawer for scoreboard. //void HU_DrawTeamTabRankings(playersort_t *tab, INT32 whiteplayer); //void HU_DrawDualTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer); void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, INT32 whiteplayer, INT32 hilicol); diff --git a/src/i_system.h b/src/i_system.h index baaa0d446..90887444f 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -226,6 +226,8 @@ void I_InitJoystick4(void); */ INT32 I_NumJoys(void); +extern INT32 numcontrollers; + /** \brief The *I_GetJoyName function \param joyindex which joystick @@ -234,8 +236,8 @@ INT32 I_NumJoys(void); */ const char *I_GetJoyName(INT32 joyindex); -void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, UINT32 duration); -void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue); +void I_GamepadRumble(INT32 playernum, UINT16 low_strength, UINT16 high_strength, UINT32 duration); +void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 blue); #ifndef NOMUMBLE #include "p_mobj.h" // mobj_t @@ -249,10 +251,6 @@ void I_UpdateMumble(const mobj_t *mobj, const listener_t listener); */ void I_StartupMouse(void); -/** \brief Startup the second mouse -*/ -void I_StartupMouse2(void); - /** \brief setup timer irq and user timer routine. */ void I_StartupTimer(void); @@ -315,10 +313,6 @@ const char *I_LocateWad(void); */ void I_GetJoystickEvents(UINT8 index); -/** \brief Mouses events -*/ -void I_GetMouseEvents(void); - char *I_GetEnv(const char *name); INT32 I_PutEnv(char *variable); diff --git a/src/i_time.c b/src/i_time.c index a1ef580bd..931696379 100644 --- a/src/i_time.c +++ b/src/i_time.c @@ -61,7 +61,7 @@ void I_UpdateTime(fixed_t timescale) ticratescaled = (double)TICRATE * FIXED_TO_FLOAT(timescale); enterprecise = I_GetPreciseTime(); - elapsedseconds = (double)(enterprecise - oldenterprecise) / I_GetPrecisePrecision(); + elapsedseconds = (double)((INT64)enterprecise - oldenterprecise) / I_GetPrecisePrecision(); tictimer += elapsedseconds; while (tictimer > 1.0/ticratescaled) { diff --git a/src/k_director.c b/src/k_director.c index 611c64701..70fd66bbf 100644 --- a/src/k_director.c +++ b/src/k_director.c @@ -40,25 +40,6 @@ struct directorinfo INT32 boredom[MAXPLAYERS]; // how long has a given position had no credible attackers? } directorinfo; -static boolean K_DirectorIsPlayerAlone(void) -{ - UINT8 pingame = 0; - - // Gotta check how many players are active at this moment. - for (UINT8 i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].spectator) - continue; - - pingame++; - - if (pingame >= 2) // we dont need to check further - break; - } - - return (pingame <= 1); -} - static inline boolean race_rules(void) { return gametype == GT_RACE; @@ -71,9 +52,9 @@ static fixed_t ScaleFromMap(fixed_t n, fixed_t scale) boolean K_DirectorIsAvailable(void) { - if ((demo.playback && demo.title) || modeattacking) + if (splitscreen || (demo.playback && demo.title) || modeattacking) return false; - return ((gamestate == GS_LEVEL) && (demo.playback || (players[consoleplayer].spectator && !K_DirectorIsPlayerAlone()))); + return ((gamestate == GS_LEVEL) && ((demo.playback && !camera[0].freecam) || (players[consoleplayer].spectator && (D_NumPlayers() > 1)))); } static boolean K_DirectorIsEnabled(void) @@ -422,10 +403,9 @@ void K_ToggleDirector(void) if (!K_DirectorIsAvailable()) return; - G_AdjustView(1, 1, true); - if (!K_DirectorIsEnabled()) { + G_AdjustView(1, 1, true); directorinfo.cooldown = 0; // switch immediately } diff --git a/src/k_kart.c b/src/k_kart.c index 8afc37819..90f1c94d2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -12,6 +12,7 @@ #include "d_player.h" #include "hu_stuff.h" #include "g_game.h" +#include "i_joy.h" #include "m_fixed.h" #include "m_random.h" #include "m_menu.h" // ffdhidshfuisduifigergho9igj89dgodhfih AAAAAAAAAA @@ -57,49 +58,119 @@ consvar_t cv_##name##_yoffset = {"hud_" #name "_yoffset", "0", CV_SAVE, NULL, NU IMPL_HUD_OFFSET_X(name)\ IMPL_HUD_OFFSET_Y(name) -IMPL_HUD_OFFSET(item); // Item box -IMPL_HUD_OFFSET(time); // Time -IMPL_HUD_OFFSET(laps); // Number of laps -IMPL_HUD_OFFSET(dnft); // Countdown (did not finish timer) -IMPL_HUD_OFFSET(speed); // Speedometer -IMPL_HUD_OFFSET(posi); // Position in race -IMPL_HUD_OFFSET(face); // Mini rankings -IMPL_HUD_OFFSET(stcd); // Starting countdown +IMPL_HUD_OFFSET(item); // Item box +IMPL_HUD_OFFSET(time); // Time +IMPL_HUD_OFFSET(laps); // Number of laps +IMPL_HUD_OFFSET(dnft); // Countdown (did not finish timer) +IMPL_HUD_OFFSET(speed); // Speedometer +IMPL_HUD_OFFSET(posi); // Position in race +IMPL_HUD_OFFSET(wheel); // RA Wheel +IMPL_HUD_OFFSET(face); // Mini rankings +IMPL_HUD_OFFSET(stcd); // Starting countdown IMPL_HUD_OFFSET_Y(chek); // Check gfx -IMPL_HUD_OFFSET(mini); // Minimap -IMPL_HUD_OFFSET(want); // Wanted -IMPL_HUD_OFFSET(stat); // Stats +IMPL_HUD_OFFSET(mini); // Minimap +IMPL_HUD_OFFSET(want); // Wanted +IMPL_HUD_OFFSET(stat); // Stats #undef IMPL_HUD_OFFSET #undef IMPL_HUD_OFFSET_X #undef IMPL_HUD_OFFSET_Y +// extra colourisation stuff +static CV_PossibleValue_t colorspeedlines_cons_t[] = {{0, "Off"}, {1, "Normal"}, {2, "+Driftcharge"}, {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}; + +consvar_t cv_bananajitter = {"bananadragjitter", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t bananthrowroll_cons_t[] = {{0, "Off"}, {1, "Throw"}, {2, "+Onground"}, {0, NULL}}; +consvar_t cv_bananthrowroll = {"bananthrowroll", "0", CV_SAVE, bananthrowroll_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; + +consvar_t cv_airsparks = {"airdriftsparks", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; + //extra hud things consvar_t cv_showstats = {"showstats", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_showinput = {"showinput", "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}}; +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}; consvar_t cv_posanim = {"postitionanimation", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_smallposnum = {"smallpositionnumber", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fancyroulette = {"animatedroulette", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, 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_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_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_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_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_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_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}; 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_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // toggle for showing the speedometer in battlemode + +// 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 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}; + +// sprite rotatuer stuff +static CV_PossibleValue_t sloperolldist_cons_t[] = { + {512, "512"}, {768, "768"}, + {1024, "1024"}, {1536, "1536"}, {2048, "2048"}, + {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, + {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; +consvar_t cv_sloperolldist = {"sloperolldist", "Infinite", CV_SAVE, sloperolldist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +static CV_PossibleValue_t sloperoll_cons_t[] = {{0, "Off"}, {1, "Players"}, {2, "Everything"}, {0, NULL}}; +consvar_t cv_sloperoll = {"sloperoll", "Off", CV_SAVE|CV_CALL, sloperoll_cons_t, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_sparkroll = {"sparkroll", "Off", CV_SAVE|CV_CALL, CV_OnOff, PDistort_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_sliptideroll = {"sliptideroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_spinoutroll = {"spinoutroll", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //hardcode saltyhop mhhm -consvar_t cv_saltyhop = {"hardcodehop", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +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 void saltyhop_onchange(void) +{ + // reset everything when toggling saltyhop off + if (!cv_saltyhop.value) + { + if (gamestate != GS_LEVEL) + return; + + for (INT32 i = 0; i < MAXPLAYERS; i++) + { + player_t *player = &players[i]; + + 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_ready = false; + player->mo->salty_tapping = false; + player->mo->init_salty = false; + } + } +} + //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}; @@ -141,9 +212,7 @@ consvar_t cv_nametagmaxlenght = {"kartnametagmaxlenght", "12", CV_SAVE, CV_Unsig //consvar_t cv_nametagscaling = {"nametagscaling", "160", CV_SAVE, nametagscaling_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_showownnametag = {"kartnametagshowown", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_smallnametags = {"kartnametagsmall", "Off", CV_SAVE, nametagsize_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_nametaghop = {"kartnametaghop", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_nametagscore = {"kartnametagscore", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_shownametagfinish = {"kartshownametagfinished", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_shownametagspectator = {"kartshownametagspectator", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -749,29 +818,43 @@ void K_RegisterKartStuff(void) REG_HUD_OFFSET_X(name)\ REG_HUD_OFFSET_Y(name) - REG_HUD_OFFSET(item); // Item box - REG_HUD_OFFSET(time); // Time - REG_HUD_OFFSET(laps); // Number of laps - REG_HUD_OFFSET(dnft); // Countdown (did not finish timer) - REG_HUD_OFFSET(speed); // Speedometer - REG_HUD_OFFSET(posi); // Position in race - REG_HUD_OFFSET(face); // Mini rankings - REG_HUD_OFFSET(stcd); // Starting countdown + REG_HUD_OFFSET(item); // Item box + REG_HUD_OFFSET(time); // Time + REG_HUD_OFFSET(laps); // Number of laps + REG_HUD_OFFSET(dnft); // Countdown (did not finish timer) + REG_HUD_OFFSET(speed); // Speedometer + REG_HUD_OFFSET(posi); // Position in race + REG_HUD_OFFSET(wheel); // Position in race + REG_HUD_OFFSET(face); // Mini rankings + REG_HUD_OFFSET(stcd); // Starting countdown REG_HUD_OFFSET_Y(chek); // Check gfx - REG_HUD_OFFSET(mini); // Minimap - REG_HUD_OFFSET(want); // Wanted - REG_HUD_OFFSET(stat); // Stats + REG_HUD_OFFSET(mini); // Minimap + REG_HUD_OFFSET(want); // Wanted + REG_HUD_OFFSET(stat); // Stats #undef REG_HUD_OFFSET #undef REG_HUD_OFFSET_X #undef REG_HUD_OFFSET_Y + // Colored speedlines + CV_RegisterVar(&cv_coloredspeedlines); + // Colored trails + CV_RegisterVar(&cv_coloredsneakertrail); + + // makes banans do funny jitter jumpy when dragged + CV_RegisterVar(&cv_bananajitter); + CV_RegisterVar(&cv_bananthrowroll); + + CV_RegisterVar(&cv_airsparks); + CV_RegisterVar(&cv_showstats); CV_RegisterVar(&cv_showinput); CV_RegisterVar(&cv_posanim); CV_RegisterVar(&cv_smallposnum); + CV_RegisterVar(&cv_fancyroulette); + CV_RegisterVar(&cv_showlaptimes); CV_RegisterVar(&cv_newspeedometer); @@ -783,14 +866,17 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_stagetitle); - //Colourized HUD + // Colourized HUD CV_RegisterVar(&cv_colorizedhud); CV_RegisterVar(&cv_colorizedhudcolor); CV_RegisterVar(&cv_colorizeditembox); + CV_RegisterVar(&cv_biglaps); + CV_RegisterVar(&cv_darkitembox); - CV_RegisterVar(&cv_biglaps); + CV_RegisterVar(&cv_multiitemicon); + CV_RegisterVar(&cv_huditemamount); CV_RegisterVar(&cv_highresportrait); @@ -804,9 +890,7 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_showownnametag); CV_RegisterVar(&cv_smallnametags); CV_RegisterVar(&cv_nametagrestat); - CV_RegisterVar(&cv_nametaghop); CV_RegisterVar(&cv_nametagscore); - CV_RegisterVar(&cv_shownametagfinish); CV_RegisterVar(&cv_shownametagspectator); CV_RegisterVar(&cv_driftgauge); @@ -822,7 +906,6 @@ void K_RegisterKartStuff(void) CV_RegisterVar(&cv_lessflicker); CV_RegisterVar(&cv_mouseturn); - } //} @@ -1301,7 +1384,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) dontforcespb = true; // This makes the roulette produce the random noises. - if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player) && !demo.freecam) + if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player)) { #define PLAYROULETTESND S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8)) for (i = 0; i <= splitscreen; i++) @@ -1335,7 +1418,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) //player->kartstuff[k_itemblinkmode] = 1; player->kartstuff[k_itemroulette] = 0; player->kartstuff[k_roulettetype] = 0; - if (P_IsDisplayPlayer(player) && !demo.freecam) + if (P_IsDisplayPlayer(player)) S_StartSound(NULL, sfx_itrole); return; } @@ -1348,7 +1431,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) player->kartstuff[k_itemblinkmode] = 2; player->kartstuff[k_itemroulette] = 0; player->kartstuff[k_roulettetype] = 0; - if (P_IsDisplayPlayer(player) && !demo.freecam) + if (P_IsDisplayPlayer(player)) S_StartSound(NULL, sfx_dbgsal); return; } @@ -1380,7 +1463,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) player->kartstuff[k_itemamount] = 1; } - if (P_IsDisplayPlayer(player) && !demo.freecam) + if (P_IsDisplayPlayer(player)) S_StartSound(NULL, ((player->kartstuff[k_roulettetype] == 1) ? sfx_itrolk : (mashed ? sfx_itrolm : sfx_itrolf))); player->kartstuff[k_itemblink] = TICRATE; @@ -3116,6 +3199,29 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I return NULL; } +static UINT16 K_DriftSparkColor(player_t *player, INT32 charge) +{ + UINT16 color = SKINCOLOR_NONE; + + if (charge >= K_GetKartDriftSparkValue(player)*4) + { + color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); + } + else if (charge >= K_GetKartDriftSparkValue(player)*2) + { + if (charge <= (K_GetKartDriftSparkValue(player)*2)+(24*3)) + color = SKINCOLOR_RASPBERRY; // transition + else + color = SKINCOLOR_KETCHUP; + } + else + { + color = SKINCOLOR_SAPPHIRE; + } + + return color; +} + #define DRIFTSPARKGROWTICS 8 static void K_SpawnDriftSparks(player_t *player) @@ -3133,7 +3239,7 @@ static void K_SpawnDriftSparks(player_t *player) if (leveltime % 2 == 1) return; - if (!P_IsObjectOnGround(player->mo)) + if (!cv_airsparks.value && !P_IsObjectOnGround(player->mo)) return; if (!player->kartstuff[k_drift] || player->kartstuff[k_driftcharge] < K_GetKartDriftSparkValue(player)) @@ -3143,7 +3249,6 @@ static void K_SpawnDriftSparks(player_t *player) for (i = 0; i < 2; i++) { - UINT8 pindex; 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)); @@ -3153,16 +3258,7 @@ static void K_SpawnDriftSparks(player_t *player) spark->angle = travelangle-(ANGLE_45/5)*player->kartstuff[k_drift]; // scale increase while driftspark level gained timer is running - - // hack to find the correct player number - for (pindex = 0; pindex < MAXPLAYERS; pindex++) - { - if (player == &players[pindex]) - { - driftExtraScale = FixedDiv(driftsparkGrowTimer[pindex], DRIFTSPARKGROWTICS); - break; - } - } + 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))); @@ -3177,21 +3273,7 @@ static void K_SpawnDriftSparks(player_t *player) spark->sloperoll = player->mo->sloperoll; } - if (player->kartstuff[k_driftcharge] >= K_GetKartDriftSparkValue(player)*4) - { - spark->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); - } - else if (player->kartstuff[k_driftcharge] >= K_GetKartDriftSparkValue(player)*2) - { - if (player->kartstuff[k_driftcharge] <= (K_GetKartDriftSparkValue(player)*2)+(24*3)) - spark->color = SKINCOLOR_RASPBERRY; // transition - else - spark->color = SKINCOLOR_KETCHUP; - } - else - { - spark->color = SKINCOLOR_SAPPHIRE; - } + spark->color = K_DriftSparkColor(player, player->kartstuff[k_driftcharge]); if ((player->kartstuff[k_drift] > 0 && player->cmd.driftturn > 0) // Inward drifts || (player->kartstuff[k_drift] < 0 && player->cmd.driftturn < 0)) @@ -3254,8 +3336,15 @@ static void K_SpawnAIZDust(player_t *player) } } +#define MAXSTRETCHDIV 17476977 + static void K_StretchPlayerGravity(player_t *p) { + if (cv_gravstretch.value == 0) + { + return; + } + I_Assert(p != NULL); I_Assert(p->mo != NULL); I_Assert(!P_MobjWasRemoved(p->mo)); @@ -3263,15 +3352,13 @@ static void K_StretchPlayerGravity(player_t *p) fixed_t mos = FRACUNIT; fixed_t rzs = abs(p->mo->momz); fixed_t zspd = abs(rzs/mos); - fixed_t stretchScaleFactor = 0; - fixed_t rzsDiv = 1; - fixed_t slamDiv = 1; + 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; - stretchScaleFactor = FixedDiv(FRACUNIT*60, cv_gravstretch.value); - if (stretchScaleFactor > 17476977) + if (stretchScaleFactor > MAXSTRETCHDIV) rzsDiv = 0; else rzsDiv = FixedDiv(rzs, stretchScaleFactor); @@ -3281,7 +3368,7 @@ static void K_StretchPlayerGravity(player_t *p) if (p->mo->slamsoundtimer) p->mo->slamsoundtimer--; - if (cv_slamsound.value && (p->mo->eflags & MFE_JUSTHITFLOOR) && p->mo->stretchslam > 4*mos && !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; @@ -3309,7 +3396,7 @@ static void K_StretchPlayerGravity(player_t *p) } else { - if (stretchScaleFactor > 17476977) + if (stretchScaleFactor > MAXSTRETCHDIV) slamDiv = 0; else slamDiv = FixedDiv(p->mo->stretchslam, stretchScaleFactor); @@ -3325,38 +3412,55 @@ static void K_StretchPlayerGravity(player_t *p) static void K_QuiteSaltyHop(player_t *p) { + if (!cv_saltyhop.value) + return; + // what the fuck is this haya fixed_t mos = FRACUNIT; // doesnt work correctly if it isnt :/ // ready? - if (!p->kartstuff[k_jmp]) { + if (!p->kartstuff[k_jmp]) + { p->mo->salty_ready = true; p->mo->salty_tapping = false; - } else if (p->mo->salty_ready) { + } + else if (p->mo->salty_ready) + { p->mo->salty_ready = false; p->mo->salty_tapping = true; - } else { + } + else + { p->mo->salty_tapping = false; } // GO! - if (!p->mo->init_salty) { + if (!p->mo->init_salty) + { p->mo->salty_jump = false; p->mo->salty_zoffset = 0; p->mo->salty_momz = 0; p->mo->init_salty = true; } - else if ((p->mo->salty_jump)) { - if (p->mo->eflags & MFE_JUSTHITFLOOR) { + else if (p->mo->salty_jump) + { + if (p->mo->eflags & MFE_JUSTHITFLOOR) + { p->mo->salty_zoffset = 0; - } else if (P_IsObjectOnGround(p->mo)) { + } + else if (P_IsObjectOnGround(p->mo)) + { p->mo->salty_zoffset += p->mo->salty_momz; p->mo->salty_momz -= (mos*3/2); - } else { + } + else + { p->mo->salty_zoffset *= (49/50)*mos; p->mo->salty_momz = 0; } - if (p->mo->salty_zoffset <= 0) { + + if (p->mo->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; @@ -3364,18 +3468,23 @@ static void K_QuiteSaltyHop(player_t *p) p->mo->salty_momz = 0; // shlamma damma p->mo->stretchslam += cv_saltysquish.value ? (8*mos) : 0; - } else if (p->mo->salty_zoffset >= 0 && cv_saltysquish.value) { + } + else if (p->mo->salty_zoffset >= 0 && cv_saltysquish.value) + { // goofy ahh hack p->mo->spriteyscale += (mos/8); p->mo->spritexscale -= (mos/8); } + p->mo->spriteyoffset = p->mo->salty_zoffset; + 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]) { + 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; @@ -3385,7 +3494,7 @@ static void K_QuiteSaltyHop(player_t *p) } #define SLOPEROLL_DIV 3 -void K_RollMobjBySlopes(mobj_t* mo, boolean usedistance) +void K_RollMobjBySlopes(mobj_t* mo, pslope_t *slope) { if (P_MobjWasRemoved(mo)) return; @@ -3394,50 +3503,52 @@ void K_RollMobjBySlopes(mobj_t* mo, boolean usedistance) I_Assert(mo->subsector->sector != NULL); // lifted from hw_md2 - if (mo->standingslope) + if (slope) { angle_t an; const boolean flip = (mo->eflags & MFE_VERTICALFLIP); - const fixed_t m_dist = usedistance ? R_PointToDist(mo->x, mo->y) : 0; + 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 = mo->standingslope->normal.z; - fixed_t tempy = mo->standingslope->normal.y; - fixed_t tempx = mo->standingslope->normal.x; + 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)); // admittedly this is a very hacky way to do the pitch and roll easing // pitch - if (!usedistance || (m_dist <= (rolldist))) + 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 = FixedAngle(0); + mo->pitch_sprite = 0; mo->slopepitch = flip ? InvAngle(mo->pitch_sprite) : mo->pitch_sprite; // roll tempangle = (R_PointToAngle2(0, 0, tempz, tempy)); - if (!usedistance || (m_dist <= (rolldist))) + 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 = FixedAngle(0); + mo->roll_sprite = 0; mo->sloperoll = flip ? InvAngle(mo->roll_sprite) : mo->roll_sprite; } else if (P_IsObjectOnGround(mo)) { - mo->sloperoll = FixedAngle(0); - mo->slopepitch = FixedAngle(0); + mo->sloperoll = 0; + mo->slopepitch = 0; } } @@ -3485,6 +3596,13 @@ void K_SpawnBoostTrail(player_t *player) flame->angle = travelangle; flame->fuse = TICRATE*2; flame->destscale = player->mo->scale; + + if (cv_coloredsneakertrail.value) + { + flame->colorized = true; + flame->color = player->skincolor; + } + P_SetScale(flame, player->mo->scale); // not K_MatchGenericExtraFlags so that a stolen sneaker can be seen K_FlipFromObject(flame, player->mo); @@ -3795,6 +3913,15 @@ 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) + { + //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 + else if (cv_bananthrowroll.value == 2) + mo->rollangle = FixedAngle(M_RandomRange(-180, 180) << FRACBITS); + } } // this is the small graphic effect that plops in you when you throw an item: @@ -4216,6 +4343,10 @@ void K_KillBananaChain(mobj_t *banana, mobj_t *inflictor, mobj_t *source) mobj_t *cachenext; killnext: + + if (!banana) + return; + cachenext = banana->hnext; if (banana->health) @@ -4526,6 +4657,150 @@ void K_RepairOrbitChain(mobj_t *orbit) } } +// Simplified version of a code bit in P_MobjFloorZ +static fixed_t K_BananaSlopeZ(pslope_t *slope, fixed_t x, fixed_t y, fixed_t z, fixed_t radius, boolean ceiling) +{ + fixed_t testx, testy; + fixed_t slopez = 0; + + if (slope == NULL) + { + testx = x; + testy = y; + } + else + { + if (slope->d.x < 0) + testx = radius; + else + testx = -radius; + + if (slope->d.y < 0) + testy = radius; + else + testy = -radius; + + if ((slope->zdelta > 0) ^ !!(ceiling)) + { + testx = -testx; + testy = -testy; + } + + testx += x; + testy += y; + } + + if (slope) + { + slopez = P_GetZAt(slope, testx, testy); + } + else + slopez = z; + + return slopez; +} + +static void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z, fixed_t radius, fixed_t height, boolean flip, boolean player) +{ + fixed_t newz; + sector_t *sec; + pslope_t *slope = NULL; + + //sec = R_PointInSubsector(x, y)->sector; + + if (mobj->x != x || mobj->y != y || mobj->subsector == NULL) + sec = R_PointInSubsector(x, y)->sector; + else + sec = mobj->subsector->sector; + + if (flip) + { + slope = sec->c_slope; + newz = K_BananaSlopeZ(slope, x, y, sec->ceilingheight, radius, true); + } + else + { + slope = sec->f_slope; + newz = K_BananaSlopeZ(slope, x, y, sec->floorheight, radius, true); + } + + // Check FOFs for a better suited slope + if (sec->ffloors) + { + ffloor_t *rover; + + for (rover = sec->ffloors; rover; rover = rover->next) + { + fixed_t top, bottom; + fixed_t d1, d2; + + if (!(rover->flags & FF_EXISTS)) + continue; + + if ((!(((rover->flags & FF_BLOCKPLAYER && player) + || (rover->flags & FF_BLOCKOTHERS && !player)) + || (rover->flags & FF_QUICKSAND)) + || (rover->flags & FF_SWIMMABLE))) + continue; + + top = K_BananaSlopeZ(*rover->t_slope, x, y, *rover->topheight, radius, false); + bottom = K_BananaSlopeZ(*rover->b_slope, x, y, *rover->bottomheight, radius, true); + + if (flip) + { + if (rover->flags & FF_QUICKSAND) + { + if (z < top && (z + height) > bottom) + { + if (newz > (z + height)) + { + newz = (z + height); + slope = NULL; + } + } + continue; + } + + d1 = (z + height) - (top + ((bottom - top)/2)); + d2 = z - (top + ((bottom - top)/2)); + + if (bottom < newz && abs(d1) < abs(d2)) + { + newz = bottom; + slope = *rover->b_slope; + } + } + else + { + if (rover->flags & FF_QUICKSAND) + { + if (z < top && (z + height) > bottom) + { + if (newz < z) + { + newz = z; + slope = NULL; + } + } + continue; + } + + d1 = z - (bottom + ((top - bottom)/2)); + d2 = (z + height) - (bottom + ((top - bottom)/2)); + + if (top > newz && abs(d1) < abs(d2)) + { + newz = top; + slope = *rover->t_slope; + } + } + } + } + + //mobj->standingslope = slope; + K_RollMobjBySlopes(mobj, slope); +} + // Move the hnext chain! static void K_MoveHeldObjects(player_t *player) { @@ -4704,6 +4979,15 @@ static void K_MoveHeldObjects(player_t *player) targz -= 8*(2*FRACUNIT)/7; }*/ + if (cv_bananajitter.value && P_IsObjectOnGround(player->mo) && player->speed > 0 && player->kartstuff[k_bananadrag] > TICRATE + && M_RandomChance(min(FRACUNIT/2, FixedDiv(player->speed, K_GetKartSpeed(player, false))/2))) + { + if (leveltime & 1) + cur->spriteyoffset += 8*(2*FRACUNIT)/7; + else + cur->spriteyoffset -= 8*(2*FRACUNIT)/7; + } + if (speed > dist) P_InstaThrust(cur, cur->angle, speed-dist); @@ -4712,6 +4996,12 @@ 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)) + { + K_CalculateBananaSlope(cur, cur->x, cur->y, cur->z, + cur->radius, cur->height, (cur->eflags & MFE_VERTICALFLIP), false); + } + cur = cur->hnext; } } @@ -5110,6 +5400,82 @@ void K_KartPlayerHUDUpdate(player_t *player) player->kartstuff[k_cardanimation] = 0; } +static boolean K_SpeedLinesShouldBlend(player_t *player) +{ + fixed_t percentspeed = 0; + + 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 + percentspeed = (FixedDiv(player->speed, FixedMul(K_GetKartSpeed(player, false), ORIG_FRICTION))*100)>>FRACBITS; + + if (percentspeed > 127) // sneaker boost is around 25% + return true; + + return false; +} + +typedef INT32 (*randomFunc)(INT32 min, INT32 max); + +static inline void K_SpawnNormalSpeedLines(player_t *player, boolean synched) +{ + randomFunc randomfunc = synched ? P_RandomRange : M_RandomRange; + + mobj_t *fast = P_SpawnMobj(player->mo->x + (randomfunc(-36,36) * player->mo->scale), + player->mo->y + (randomfunc(-36,36) * player->mo->scale), + player->mo->z + (player->mo->height/2) + (randomfunc(-20,20) * player->mo->scale), + MT_FASTLINE); + + fast->angle = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); + fast->momx = 3*player->mo->momx/4; + fast->momy = 3*player->mo->momy/4; + fast->momz = 3*player->mo->momz/4; + P_SetTarget(&fast->target, player->mo); // easier lua access + + K_MatchGenericExtraFlags(fast, player->mo); + + if (cv_coloredspeedlines.value) + { + const boolean colorSpeed = (player->speed >= (3*K_GetKartSpeed(player, false))/4); + + if (player->kartstuff[k_eggmanexplode]) + { + // 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->colorized = true; + } + + if (colorSpeed && K_SpeedLinesShouldBlend(player)) + fast->blendmode = AST_ADD; + } +} + /** \brief Decreases various kart timers and powers per frame. Called in P_PlayerThink in p_user.c \param player player object passed from P_PlayerThink @@ -5131,16 +5497,11 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) // Speed lines if ((player->kartstuff[k_sneakertimer] || player->kartstuff[k_driftboost] || player->kartstuff[k_startboost]) && player->speed > 0) { - mobj_t *fast = P_SpawnMobj(player->mo->x + (P_RandomRange(-36,36) * player->mo->scale), - player->mo->y + (P_RandomRange(-36,36) * player->mo->scale), - player->mo->z + (player->mo->height/2) + (P_RandomRange(-20,20) * player->mo->scale), - MT_FASTLINE); - fast->angle = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); - fast->momx = 3*player->mo->momx/4; - fast->momy = 3*player->mo->momy/4; - fast->momz = 3*player->mo->momz/4; - P_SetTarget(&fast->target, player->mo); // easier lua access - K_MatchGenericExtraFlags(fast, player->mo); + K_SpawnNormalSpeedLines(player, true); + } + else if (cv_coloredspeedlines.value && player->kartstuff[k_eggmanexplode]) // gotta love the speedlines calling synched rng :chaosleep: + { + K_SpawnNormalSpeedLines(player, false); } if (player->playerstate == PST_DEAD || player->kartstuff[k_respawn] > 1) // Ensure these are set correctly here @@ -5523,11 +5884,6 @@ static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer) INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) { - fixed_t p_topspeed = K_GetKartSpeed(player, false); - fixed_t p_curspeed = min(player->speed, p_topspeed * 2); - fixed_t p_maxspeed = p_topspeed * 3; - fixed_t adjustangle = FixedDiv((p_maxspeed>>16) - (p_curspeed>>16), (p_maxspeed>>16) + player->kartweight); - if (player->spectator) return turnvalue; @@ -5546,6 +5902,11 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) return turnvalue; } + fixed_t p_topspeed = K_GetKartSpeed(player, false); + fixed_t p_curspeed = min(player->speed, p_topspeed * 2); + fixed_t p_maxspeed = p_topspeed * 3; + fixed_t adjustangle = FixedDiv((p_maxspeed>>16) - (p_curspeed>>16), (p_maxspeed>>16) + player->kartweight); + turnvalue = FixedMul(turnvalue, adjustangle); // Weight has a small effect on turning if (player->kartstuff[k_invincibilitytimer] || player->kartstuff[k_sneakertimer] || player->kartstuff[k_growshrinktimer] > 0) @@ -5652,7 +6013,6 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_driftend] = 0; } - // 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) { @@ -5692,20 +6052,11 @@ static void K_KartDrift(player_t *player, boolean onground) || (player->kartstuff[k_driftcharge] < dstwo && player->kartstuff[k_driftcharge]+driftadditive >= dstwo) || (player->kartstuff[k_driftcharge] < dsthree && player->kartstuff[k_driftcharge]+driftadditive >= dsthree)) { - UINT8 pindex; //S_StartSound(player->mo, sfx_s3ka2); if (P_IsLocalPlayer(player)) // UGHGHGH... S_StartSoundAtVolume(player->mo, sfx_s3ka2, 192); // Ugh... - // hack to find the correct player number - for (pindex = 0; pindex < MAXPLAYERS; pindex++) - { - if (player == &players[pindex]) - { - driftsparkGrowTimer[pindex] = DRIFTSPARKGROWTICS; - break; - } - } + player->driftsparkGrowTimer = DRIFTSPARKGROWTICS; } @@ -5718,33 +6069,14 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_driftend] = 0; } - { - //im putting this in a block because i want the variables here, not at the top of the block - UINT8 pindex; - - // hack to find the correct player number - for (pindex = 0; pindex < MAXPLAYERS; pindex++) - { - if (player == &players[pindex]) - { - if (driftsparkGrowTimer[pindex]) - driftsparkGrowTimer[pindex]--; - break; - } - } - } + if (player->driftsparkGrowTimer) + player->driftsparkGrowTimer--; // Stop drifting if (player->kartstuff[k_spinouttimer] > 0 || player->speed < minspeed) { player->kartstuff[k_drift] = player->kartstuff[k_driftcharge] = 0; player->kartstuff[k_aizdriftstrat] = player->kartstuff[k_brakedrift] = 0; - - if (!player->sliproll) - { - player->sliproll = 0; - } - player->kartstuff[k_getsparks] = 0; } @@ -6539,22 +6871,16 @@ void K_MoveKartPlayer(player_t *player, boolean onground) player->sliproll -= (4*ANG1); } - if (cv_gravstretch.value > 13107) - K_StretchPlayerGravity(player); - else - { - player->mo->spritexscale = player->mo->realxscale; - player->mo->spriteyscale = player->mo->realyscale; - } + K_StretchPlayerGravity(player); if (cv_sloperoll.value && !player->mo->salty_jump) // seeing a character rotate mid-hop looks really janky { - K_RollMobjBySlopes(player->mo, (cv_sloperolldist.value && !splitscreen)); + K_RollMobjBySlopes(player->mo, player->mo->standingslope); } else { - player->mo->sloperoll = FixedAngle(0); - player->mo->slopepitch = FixedAngle(0); + player->mo->sloperoll = 0; + player->mo->slopepitch = 0; } // Quick Turning @@ -6660,14 +6986,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } // salty hop! i wanna die - if (cv_saltyhop.value) - K_QuiteSaltyHop(player); - else { - player->mo->spriteyoffset = 0; - player->mo->salty_jump = false; - player->mo->salty_zoffset = 0; - player->mo->salty_momz = 0; - } + K_QuiteSaltyHop(player); } void K_CalculateBattleWanted(void) @@ -7075,12 +7394,15 @@ static patch_t *kp_itemmulsticker[2]; static patch_t *kp_itemx; static patch_t *kp_sneaker[2]; +static patch_t *kp_multsneaker[2]; static patch_t *kp_rocketsneaker[2]; static patch_t *kp_invincibility[13]; static patch_t *kp_banana[2]; +static patch_t *kp_multbanana[3]; static patch_t *kp_eggman[2]; static patch_t *kp_orbinaut[5]; static patch_t *kp_jawz[2]; +static patch_t *kp_multjawz[1]; static patch_t *kp_mine[2]; static patch_t *kp_ballhog[2]; static patch_t *kp_selfpropelledbomb[2]; @@ -7221,7 +7543,7 @@ void K_LoadKartHUDGraphics(void) } // KartZ speedo - if (kartzspeedo) + if (kartz_speedo) { const char* patchNames[] = { "K_KZSP1", "K_KZSP2", "K_KZSP3", "K_KZSP4", "K_KZSP5", @@ -7342,6 +7664,11 @@ void K_LoadKartHUDGraphics(void) kp_itemx = W_CachePatchName("K_ITX", PU_HUDGFX); kp_sneaker[0] = W_CachePatchName("K_ITSHOE", PU_HUDGFX); + if (multiitem_icon) + { + kp_multsneaker[0] = W_CachePatchName("K_ITSHO2", PU_HUDGFX); + kp_multsneaker[1] = W_CachePatchName("K_ITSHO3", PU_HUDGFX); + } kp_rocketsneaker[0] = W_CachePatchName("K_ITRSHE", PU_HUDGFX); sprintf(buffer, "K_ITINVx"); @@ -7350,7 +7677,14 @@ void K_LoadKartHUDGraphics(void) buffer[7] = '1'+i; kp_invincibility[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); } + kp_banana[0] = W_CachePatchName("K_ITBANA", PU_HUDGFX); + if (multiitem_icon) + { + kp_multbanana[0] = W_CachePatchName("K_ITBAN2", PU_HUDGFX); + kp_multbanana[1] = W_CachePatchName("K_ITBAN3", PU_HUDGFX); + kp_multbanana[2] = W_CachePatchName("K_ITBAN4", PU_HUDGFX); + } kp_eggman[0] = W_CachePatchName("K_ITEGGM", PU_HUDGFX); sprintf(buffer, "K_ITORBx"); for (i = 0; i < 4; i++) @@ -7359,6 +7693,10 @@ void K_LoadKartHUDGraphics(void) kp_orbinaut[i] = (patch_t *) W_CachePatchName(buffer, PU_HUDGFX); } kp_jawz[0] = W_CachePatchName("K_ITJAWZ", PU_HUDGFX); + if (multiitem_icon) + { + kp_multjawz[0] = W_CachePatchName("K_ITJAW2", PU_HUDGFX); + } kp_mine[0] = W_CachePatchName("K_ITMINE", PU_HUDGFX); kp_ballhog[0] = W_CachePatchName("K_ITBHOG", PU_HUDGFX); kp_selfpropelledbomb[0] = W_CachePatchName("K_ITSPB", PU_HUDGFX); @@ -7676,7 +8014,7 @@ static void K_initKartHUD(void) // K_GetScreenCoords needs the right view* variables R_SetViewContext(stplyrnum); - R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac : FRACUNIT, !cv_uncappedhud.value); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, !cv_uncappedhud.value); } INT32 K_calcSplitFlags(INT32 snapflags) @@ -7686,17 +8024,17 @@ INT32 K_calcSplitFlags(INT32 snapflags) if (splitscreen == 0) return snapflags; - if (stplyr != &players[displayplayers[0]]) + if (stplyrnum != 0) { - if (splitscreen == 1 && stplyr == &players[displayplayers[1]]) + if (splitscreen == 1 && stplyrnum == 1) { splitflags |= V_SPLITSCREEN; } else if (splitscreen > 1) { - if (stplyr == &players[displayplayers[2]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]])) + if (stplyrnum == 2 || (splitscreen == 3 && stplyrnum == 3)) splitflags |= V_SPLITSCREEN; - if (stplyr == &players[displayplayers[1]] || (splitscreen == 3 && stplyr == &players[displayplayers[3]])) + if (stplyrnum == 1 || (splitscreen == 3 && stplyrnum == 3)) splitflags |= V_HORZSCREEN; } } @@ -7816,7 +8154,7 @@ static void K_drawKartStats(void) for (; splitnum < MAXSPLITSCREENPLAYERS; ++splitnum) { - if (stplyr == &players[displayplayers[splitnum]]) + if (stplyrnum == splitnum) break; } @@ -7893,13 +8231,14 @@ static void K_drawKartStats(void) if (!splitscreen) { // Skin name - V_DrawSmallString(x+20, y+12, flags|V_ALLOWLOWERCASE, va("%c%s", V_GetSkincolorChar(stplyr->skincolor), fakeskin->realname)); + V_DrawSmallString(x+20, y+12, flags|V_ALLOWLOWERCASE|V_SkinColorToHighlightcolor(stplyr->skincolor), fakeskin->realname); // Icon and stats if (cv_highresportrait.value) 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)); + V_DrawMappedPatch(x-3, y-2, flags, kp_facenum[min(9, max(1, stplyr->kartspeed))], R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_BLUEBERRY, GTC_CACHE)); V_DrawMappedPatch(x+10, y+10, flags, kp_facenum[min(9, max(1, stplyr->kartweight))], R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_BURGUNDY, GTC_CACHE)); } @@ -7925,7 +8264,7 @@ static void K_drawKartItem(void) patch_t *localinv = ((offset) ? kp_invincibility[((leveltime % (6*3)) / 3) + 7] : kp_invincibility[(leveltime % (7*3)) / 3]); INT32 fx = 0, fy = 0, fflags = 0; // final coords for hud and flags... //INT32 splitflags = K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOLEFT); - const INT32 numberdisplaymin = ((!offset && stplyr->kartstuff[k_itemtype] == KITEM_ORBINAUT) ? 5 : 2); + INT32 numberdisplaymin = cv_huditemamount.value == 2 ? 1 : 2; // No longer a constant so other things can modify this value INT32 itembar = 0; INT32 maxl = 0; // itembar's normal highest value const INT32 barlength = (splitscreen > 1 ? 12 : 26); @@ -7936,6 +8275,8 @@ static void K_drawKartItem(void) boolean flipamount = splitscreen > 1 && stplyrnum & 1; // Used for 3P/4P splitscreen to flip item amount stuff + const boolean usemultiicon = (multiitem_icon && cv_multiitemicon.value && !offset); + if (stplyr->kartstuff[k_itemroulette]) { if (K_GetHudColor()) @@ -8074,7 +8415,27 @@ static void K_drawKartItem(void) switch(stplyr->kartstuff[k_itemtype]) { case KITEM_SNEAKER: - localpatch = kp_sneaker[offset]; + if (usemultiicon) + { + if (!cv_huditemamount.value) + numberdisplaymin = 4; + switch(stplyr->kartstuff[k_itemamount]) + { + case 1: + localpatch = kp_sneaker[offset]; + break; + case 2: + localpatch = kp_multsneaker[0]; + break; + default: + localpatch = kp_multsneaker[1]; + break; + } + } + else + { + localpatch = kp_sneaker[offset]; + } break; case KITEM_ROCKETSNEAKER: localpatch = kp_rocketsneaker[offset]; @@ -8084,16 +8445,50 @@ static void K_drawKartItem(void) dark = true; break; case KITEM_BANANA: - localpatch = kp_banana[offset]; + if (usemultiicon) + { + if (!cv_huditemamount.value) + numberdisplaymin = 4; + switch(stplyr->kartstuff[k_itemamount]) + { + case 1: + localpatch = kp_banana[offset]; + break; + case 2: + localpatch = kp_multbanana[0]; + break; + case 3: + localpatch = kp_multbanana[1]; + break; + default: + localpatch = kp_multbanana[2]; + break; + } + } + else + { + localpatch = kp_banana[offset]; + } break; case KITEM_EGGMAN: localpatch = kp_eggman[offset]; break; case KITEM_ORBINAUT: + if (!cv_huditemamount.value) + numberdisplaymin = offset ? 2 : 5; localpatch = kp_orbinaut[(offset ? 4 : min(stplyr->kartstuff[k_itemamount]-1, 3))]; break; case KITEM_JAWZ: - localpatch = kp_jawz[offset]; + if (usemultiicon) + { + if (!cv_huditemamount.value) + numberdisplaymin = 3; + localpatch = ((stplyr->kartstuff[k_itemamount] == 1) ? kp_jawz[offset] : kp_multjawz[0]); + } + else + { + localpatch = kp_jawz[offset]; + } break; case KITEM_MINE: localpatch = kp_mine[offset]; @@ -8161,24 +8556,45 @@ static void K_drawKartItem(void) fy = info.y; fflags = info.flags; - if (localcolor != SKINCOLOR_NONE) - colmap = R_GetTranslationColormap(colormode, localcolor, GTC_CACHE); if (K_UseColorHud()) colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, localbg, cv_colorizeditembox.value ? colormap : NULL); + fixed_t rfy = fy<kartstuff[k_itemroulette] && !stplyr->deadtimer) + { + fixed_t frac = R_GetHudUncap(); + UINT8 fancystep = (offset ? 6 : 10); + fixed_t fancyoffset = (stplyr->kartstuff[k_itemroulette] % 3)-1; + + if (fancyoffset != 0) + { + fancyflags &= ~V_HUDTRANS; + fancyflags |=V_HUDTRANSHALF; + } + + rfy += (fancystep * fancyoffset * FRACUNIT) + FixedMul(fancystep*FRACUNIT, frac) - fancystep/2*FRACUNIT; + } + + if (localcolor != SKINCOLOR_NONE) + colmap = R_GetTranslationColormap(colormode, localcolor, GTC_CACHE); + // Then, the numbers: if (stplyr->kartstuff[k_itemamount] >= numberdisplaymin && !stplyr->kartstuff[k_itemroulette]) { localbg = K_getItemMulPatch((boolean)offset); + V_DrawMappedPatch(fx + (flipamount ? 48 : 0), fy, V_HUDTRANS|fflags|(flipamount ? V_FLIP : 0), localbg, colormap); // flip this graphic for p2 and p4 in split and shift it. V_DrawFixedPatch(fx<kartstuff[k_itemamount])); - else - V_DrawString(fx+24, fy+31, V_ALLOWLOWERCASE|V_HUDTRANS|fflags, va("x%d", stplyr->kartstuff[k_itemamount])); + { + const INT32 xofs = flipamount ? 2 : 24; // reminder that this is for 3/4p's right end of the screen. + V_DrawString(fx+xofs, fy+31, V_ALLOWLOWERCASE|V_HUDTRANS|fflags, va("x%d", stplyr->kartstuff[k_itemamount])); + } else { V_DrawScaledPatch(fx+28, fy+41, V_HUDTRANS|fflags, kp_itemx); @@ -8186,7 +8602,7 @@ static void K_drawKartItem(void) } } else - V_DrawFixedPatch(fx< (timelimitintics + starttime + TICRATE/2)) && cv_overtime.value)) // i hate this so much + if (cv_timelimit.value && cv_overtime.value && G_BattleGametype() && !players[consoleplayer].exiting && (leveltime > (timelimitintics + starttime + TICRATE/2))) // i hate this so much { V_DrawKartString(TX, TY+3, splitflags, va("OVERTIME")); } @@ -8352,6 +8768,7 @@ void K_drawKartTimestamp(tic_t drawtime, INT32 TX, INT32 TY, INT16 emblemmap, UI if (!mode) splitflags = (splitflags &~ V_HUDTRANSHALF)|V_HUDTRANS; + while (curemb--) { workx -= 12; @@ -8365,6 +8782,7 @@ static void K_DrawKartPositionNum(INT32 num) // POSI_X = BASEVIDWIDTH - 51; // 269 // POSI_Y = BASEVIDHEIGHT- 64; // 136 + const boolean wheeloffs = (cv_showinput.value && cv_posi_xoffset.value == 0 && cv_posi_yoffset.value == 0 && cv_wheel_xoffset.value == 0 && cv_wheel_yoffset.value == 0); boolean win = (stplyr->exiting && num == 1); //INT32 X = POSI_X; INT32 W = SHORT(kp_positionnum[0][0]->width); @@ -8372,7 +8790,7 @@ static void K_DrawKartPositionNum(INT32 num) patch_t *localpatch = kp_positionnum[0][0]; //INT32 splitflags = K_calcSplitFlags(V_SNAPTOBOTTOM|V_SNAPTORIGHT); INT32 fx = 0, fy = 0, fflags = 0; - INT32 xoffs = (cv_showinput.value) ? -48 : 0; + INT32 xoffs = wheeloffs ? -48 : 0; boolean flipdraw = false; // flip the order we draw it in for MORE splitscreen bs. fun. boolean flipvdraw = false; // used only for 2p splitscreen so overtaking doesn't make 1P's position fly off the screen. boolean overtake = false; @@ -8383,8 +8801,10 @@ static void K_DrawKartPositionNum(INT32 num) overtake = true; // this is used for splitscreen stuff in conjunction with flipdraw. } - if (splitscreen || cv_smallposnum.value || cv_showinput.value) + if (splitscreen || cv_smallposnum.value || wheeloffs) + { scale /= 2; + } W = FixedMul(W<>FRACBITS; @@ -8398,7 +8818,7 @@ static void K_DrawKartPositionNum(INT32 num) else if (splitscreen == 1) // for this splitscreen, we'll use case by case because it's a bit different. { fx = POSI_X; - if (stplyr == &players[displayplayers[0]]) // for player 1: display this at the top right, above the minimap. + if (stplyrnum == 0) // for player 1: display this at the top right, above the minimap. { fy = 30 + cv_posi_yoffset.value; fflags = V_SNAPTOTOP|V_SNAPTORIGHT; @@ -8413,11 +8833,11 @@ static void K_DrawKartPositionNum(INT32 num) } else { - if (stplyr == &players[displayplayers[0]] || stplyr == &players[displayplayers[2]]) // If we are P1 or P3... + if (!(stplyrnum & 1)) // If we are P1 or P3... { fx = POSI_X; fy = POSI_Y; - fflags = V_SNAPTOLEFT|((stplyr == &players[displayplayers[2]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. + fflags = V_SNAPTOLEFT|((stplyrnum == 2) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P3 to the bottom. flipdraw = true; if (num && num >= 10) fx += W; // this seems dumb, but we need to do this in order for positions above 10 going off screen. @@ -8426,7 +8846,7 @@ static void K_DrawKartPositionNum(INT32 num) { fx = POSI2_X; fy = POSI2_Y; - fflags = V_SNAPTORIGHT|((stplyr == &players[displayplayers[3]]) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom + fflags = V_SNAPTORIGHT|((stplyrnum == 3) ? V_SPLITSCREEN|V_SNAPTOBOTTOM : 0); // flip P4 to the bottom } } @@ -8473,7 +8893,9 @@ static void K_DrawKartPositionNum(INT32 num) } } else + { localpatch = kp_positionnum[num % 10][0]; + } V_DrawFixedPatch((fx<width)*scale/2) : 0), (fy<height)*scale/2) : 0), scale, V_HUDTRANSHALF|fflags, localpatch, NULL); // ^ if we overtake as p1 or p3 in splitscren, we shift it so that it doesn't go off screen. @@ -8566,28 +8988,32 @@ static boolean K_drawKartPositionFaces(void) for (; i < ranklines; i++) { - if (!playeringame[rankplayer[i]]) continue; - if (players[rankplayer[i]].spectator) continue; - if (!players[rankplayer[i]].mo) continue; + if (!playeringame[rankplayer[i]]) + continue; + if (players[rankplayer[i]].spectator) + continue; + if (!players[rankplayer[i]].mo) + continue; + + const UINT8 mocolor = players[rankplayer[i]].mo->color; bumperx = FACE_X+19; - if (players[rankplayer[i]].mo->color) + if (mocolor) { - colormap = R_GetTranslationColormap(players[rankplayer[i]].skin, players[rankplayer[i]].mo->color, GTC_CACHE); - if (players[rankplayer[i]].mo->colorized) - colormap = R_GetTranslationColormap(TC_RAINBOW, players[rankplayer[i]].mo->color, GTC_CACHE); - else - colormap = R_GetTranslationColormap(players[rankplayer[i]].skin, players[rankplayer[i]].mo->color, GTC_CACHE); + player_t *p; - { - player_t *p; - p = &players[rankplayer[i]]; - if (cv_highresportrait.value) - V_DrawSmallMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceWant(p), colormap); - else - V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceRank(p), colormap); - } + colormap = R_GetTranslationColormap(players[rankplayer[i]].skin, mocolor, GTC_CACHE); + + if (players[rankplayer[i]].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); + else + V_DrawMappedPatch(FACE_X, Y, V_HUDTRANS|V_SNAPTOLEFT, R_GetSkinFaceRank(p), colormap); if (LUA_HudEnabled(hud_battlebumpers)) { @@ -8650,9 +9076,10 @@ void HU_DrawTabRankings(INT32 x, INT32 y, playersort_t *tab, INT32 scorelines, I if (players[tab[i].num].spectator || !players[tab[i].num].mo) continue; //ignore them. - if (netgame // don't draw it offline - && tab[i].num != serverplayer) - HU_drawPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, playerpingtable[tab[i].num], 0); + if ((netgame && tab[i].num != serverplayer) || (cv_mindelay.value && P_IsLocalPlayer(&players[tab[i].num]))) + { + HU_drawPlayerPing(x + ((i < 8) ? -17 : rightoffset + 11), y-4, tab[i].num, 0); + } STRBUFCPY(strtime, tab[i].name); @@ -8749,6 +9176,7 @@ static void K_drawKartLaps(void) INT32 fx = 0, fy = 0, fflags = 0; // stuff for 3p / 4p splitscreen. boolean flipstring = splitscreen > 1 && stplyrnum & 1; // used for 3p or 4p INT32 stringw = 0; // used with the above + const char *laps; drawinfo_t info; K_getLapsDrawinfo(&info); @@ -8756,26 +9184,23 @@ static void K_drawKartLaps(void) fy = info.y; fflags = info.flags; + laps = (stplyr->exiting ? "FIN" : va("%d/%d", stplyr->laps+1, cv_numlaps.value)); + + // draw stuff as god intended. if (splitscreen > 1) { - if (stplyr->exiting) // draw stuff as god intended. + if (flipstring) + { + stringw = V_StringWidth(laps, 0); + + V_DrawScaledPatch(fx-stringw-13, fy, V_HUDTRANS|fflags, kp_splitlapflag); + V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, laps); + } + else // draw stuff NORMALLY. { V_DrawScaledPatch(fx, fy, V_HUDTRANS|fflags, kp_splitlapflag); - V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, "FIN"); + V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, laps); } - else // take flipstring into account here since we may have more laps than just 10 - if (flipstring) - { - stringw = V_StringWidth(va("%d/%d", stplyr->laps+1, cv_numlaps.value), 0); - - V_DrawScaledPatch(fx-stringw-13, fy, V_HUDTRANS|fflags, kp_splitlapflag); - V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); - } - else // draw stuff NORMALLY. - { - V_DrawScaledPatch(fx, fy, V_HUDTRANS|fflags, kp_splitlapflag); - V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); - } } else { @@ -8791,10 +9216,7 @@ static void K_drawKartLaps(void) V_DrawScaledPatch(fx, fy, V_HUDTRANS|splitflags, biglap); } - if (stplyr->exiting) - V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, "FIN"); - else - V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, va("%d/%d", stplyr->laps+1, cv_numlaps.value)); + V_DrawKartString(fx+33, fy+3, V_HUDTRANS|splitflags, laps); } } @@ -8805,59 +9227,57 @@ static void K_drawKartSpeedometer(void) return; fixed_t convSpeed = 0; - - //KartZ speedo - fixed_t fuspeed = 0; - INT32 spdpatch = 0; - - INT32 speedtype = 0; 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)); + switch (cv_kartspeedometer.value) { case 1: convSpeed = FixedDiv(FixedMul(stplyr->speed, 142371), mapobjectscale)/FRACUNIT; // 2.172409058 - speedtype = 1; break; case 2: convSpeed = FixedDiv(FixedMul(stplyr->speed, 88465), mapobjectscale)/FRACUNIT; // 1.349868774 - speedtype = 2; break; case 3: convSpeed = FixedDiv(stplyr->speed, mapobjectscale)/FRACUNIT; - speedtype = 3; break; case 4: if (stplyr->mo) convSpeed = (FixedDiv(stplyr->speed, FixedMul(K_GetKartSpeed(stplyr, false), ORIG_FRICTION))*100)>>FRACBITS; - speedtype = 4; break; default: break; } - // man. - if ((cv_newspeedometer.value == 1) || (cv_newspeedometer.value == 2 && !xtra_speedo) || (cv_newspeedometer.value == 3 && !achi_speedo) || (cv_newspeedometer.value == 4 && !kartzspeedo) || (cv_newspeedometer.value == 5 && !xtra_speedo3)) + if (useoldspeedo) { - switch (speedtype) { + const char *metric = ""; + + switch (cv_kartspeedometer.value) + { case 1: - V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%3d km/h", convSpeed)); + metric = va("%3d km/h", convSpeed); break; case 2: - V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%3d mph", convSpeed)); + metric = va("%3d mph", convSpeed); break; case 3: - V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%3d fu/t", convSpeed)); + metric = va("%3d fu/t", convSpeed); break; - case 4: // if extra.kart is found, use its included % symbol + case 4: + // if extra.kart is found, use its included % symbol if (!xtra_speedo) - V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%4d P", convSpeed)); + metric = va("%4d P", convSpeed); else - V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, va("%4d %%", convSpeed)); - break; + metric = va("%4d %%", convSpeed); + break; default: break; } + + V_DrawKartString(SPDM_X, SPDM_Y, V_HUDTRANS|splitflags, metric); } else if (cv_newspeedometer.value == 2 && xtra_speedo) // why bother if we dont? { @@ -8893,25 +9313,28 @@ static void K_drawKartSpeedometer(void) if (K_UseColorHud() && xtra_speedo_clr3) //Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((SPDM_X-1)<speed, mapobjectscale)/FRACUNIT; + fixed_t fuspeed = 0; + INT32 spdpatch = 0; + static const INT32 speedIntervals[22] = {2, 5, 7, 10, 12, 15, 17, + 20, 22, 25, 27, 30, 32, + 35, 37, 40, 42, 45, 47, + 50, 52, 55}; -#define NUM_INTERVALS 22 - const int speedIntervals[NUM_INTERVALS] = {2, 5, 7, 10, 12, 15, 17, 20, 22, 25, 27, 30, 32, 35, 37, 40, 42, 45, 47, 50, 52, 55}; + fuspeed = FixedDiv(stplyr->speed, mapobjectscale)/FRACUNIT; - for (int i = 0; i < NUM_INTERVALS; ++i) + for (INT32 i = 0; i < 22; ++i) { if (fuspeed < speedIntervals[i]) { @@ -8919,7 +9342,6 @@ static void K_drawKartSpeedometer(void) break; } } -#undef NUM_INTERVALS if (((fuspeed < 57 && fuspeed > 54) || (fuspeed < 60 && fuspeed > 56) || (fuspeed > 59)) && (leveltime & 4)) spdpatch = 24; @@ -8936,6 +9358,7 @@ static void K_drawKartBumpersOrKarma(void) INT32 fx, fy, fflags; boolean flipstring = splitscreen > 1 && stplyrnum & 1; // same as laps, used for splitscreen INT32 stringw = 0; // used with the above + const char *bumpval = ""; drawinfo_t info; K_getLapsDrawinfo(&info); @@ -8955,43 +9378,52 @@ static void K_drawKartBumpersOrKarma(void) { if (stplyr->kartstuff[k_bumper] <= 0) { + bumpval = va("%d/2", stplyr->kartstuff[k_comebackpoints]); + if (flipstring) fx -= 37; V_DrawMappedPatch(fx, fy-1, V_HUDTRANS|fflags, kp_splitkarmabomb, colormap); - V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, va("%d/2", stplyr->kartstuff[k_comebackpoints])); + V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, bumpval); } else // the above doesn't need to account for weird stuff since the max amount of karma necessary is always 2 ^^^^ { + bumpval = va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value); + if (flipstring) // for p2 and p4, assume we can have more than 10 bumpers. It's retarded but who knows. { - stringw = V_StringWidth(va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value), 0); + stringw = V_StringWidth(bumpval, 0); V_DrawMappedPatch(fx-stringw-13, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); - V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); + V_DrawRightAlignedString(fx, fy+1, V_HUDTRANS|fflags, bumpval); } else // draw bumpers normally. { V_DrawMappedPatch(fx, fy-1, V_HUDTRANS|fflags, kp_rankbumper, colormap); - V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); + V_DrawString(fx+13, fy+1, V_HUDTRANS|fflags, bumpval); } } } else { + patch_t *patch; + if (stplyr->kartstuff[k_bumper] <= 0) { - V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_karmastickerclr : kp_karmasticker), colormap); - V_DrawKartString(fx+47, fy+3, V_HUDTRANS|fflags, va("%d/2", stplyr->kartstuff[k_comebackpoints])); + patch = (K_UseColorHud() ? kp_karmastickerclr : kp_karmasticker); + bumpval = va("%d/2", stplyr->kartstuff[k_comebackpoints]); } else { if (stplyr->kartstuff[k_bumper] > 9 && cv_kartbumpers.value > 9) - V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_bumperstickerwideclr : kp_bumperstickerwide), colormap); + patch = (K_UseColorHud() ? kp_bumperstickerwideclr : kp_bumperstickerwide); else - V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, (K_UseColorHud() ? kp_bumperstickerclr : kp_bumpersticker), colormap); + patch = (K_UseColorHud() ? kp_bumperstickerclr : kp_bumpersticker); - V_DrawKartString(fx+47, fy+3, V_HUDTRANS|fflags, va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value)); + bumpval = va("%d/%d", stplyr->kartstuff[k_bumper], cv_kartbumpers.value); } + + V_DrawMappedPatch(fx, fy, V_HUDTRANS|fflags, patch, colormap); + V_DrawKartString(fx+47, fy+3, V_HUDTRANS|fflags, bumpval); } } @@ -9135,27 +9567,31 @@ static void K_drawNameTags(void) UINT8 i,j; INT32 trans = 0; vector2_t pos = {0}; - fixed_t tagwidth; - fixed_t tagwidthsmall; fixed_t namex,namey; int tagsdisplayed = 0; + fixed_t distance = 0; + fixed_t maxdistance = 0; + boolean flipped = false; + fixed_t z; + char *tag; patch_t *icon; - const INT32 hudtransflag = V_LocalTransFlag(); - if (P_MobjWasRemoved(stplyr->mo) || (stplyr->spectator && !cv_shownametagspectator.value) || (stplyr->exiting && !cv_shownametagfinish.value)) + INT32 dup = 0; + UINT8 *cm = NULL; + UINT8 tagcolor = 0; + INT32 vflags = 0; + boolean usenametagrestat = false; + fixed_t tagwidthsmall; + fixed_t tagwidth; + + if (P_MobjWasRemoved(stplyr->mo) || (stplyr->spectator && !cv_shownametagspectator.value) || stplyr->exiting) return; - // True if currently viewed player is flipped and has flipcam on - const boolean flipcam = ((stplyr->pflags & PF_FLIPCAM) && (stplyr->mo->eflags & MFE_VERTICALFLIP)); + maxdistance = ((10*cv_nametagdist.value) * mapobjectscale); for (i = 0; i < MAXPLAYERS; i++) { - fixed_t distance = 0; - const fixed_t maxdistance = ((10*cv_nametagdist.value)* mapobjectscale); - boolean flipped = 0; - fixed_t z; - if (i > PLAYERSMASK) continue; if (P_MobjWasRemoved(players[i].mo) || players[i].spectator || !playeringame[i]) @@ -9173,6 +9609,19 @@ static void K_drawNameTags(void) if (!P_CheckSightFast(stplyr->mo, players[i].mo)) continue; + z = players[i].mo->height; + + //Saltyhop hehe + z += lerp(players[i].mo->old_spriteyoffset, players[i].mo->spriteyoffset); + + if (!K_GetScreenCoords(&pos, stplyr, players[i].mo, z, false)) + continue; + + tagsdisplayed += 1; + + if (tagsdisplayed > cv_nametagmaxplayers.value) + break; + switch (cv_nametagtrans.value) { case 0: @@ -9202,49 +9651,34 @@ static void K_drawNameTags(void) trans = V_40TRANS; break; case 4: - trans = hudtransflag; + trans = V_LocalTransFlag(); break; default: break; } - const INT32 dup = vid.dupx; - - // If flipcam is on, other player is flipped relative to us when we have different - // verticalflip flag value. Otherwise, they are simply flipped when verticalflip flag says - // so - if (flipcam) - flipped = (players[i].mo->eflags & MFE_VERTICALFLIP) != (stplyr->mo->eflags & MFE_VERTICALFLIP); - else - flipped = players[i].mo->eflags & MFE_VERTICALFLIP; - - z = players[i].mo->height; - - //Saltyhop hehe - if (cv_saltyhop.value && cv_nametaghop.value) - z += lerp(players[i].mo->old_spriteyoffset, players[i].mo->spriteyoffset); - - if (!K_GetScreenCoords(&pos, stplyr, players[i].mo, z, false)) - continue; - - tagsdisplayed += 1; - - if (tagsdisplayed > cv_nametagmaxplayers.value) - break; - namex = pos.x>>FRACBITS; namey = pos.y>>FRACBITS; tag = va("%s%s ", HU_SkinColorToConsoleColor(players[i].mo->color),player_names[i]); icon = R_GetSkinFaceMini(players[i].mo->player); - const UINT8 *cm = R_GetTranslationColormap(players[i].skin, players[i].mo->color, GTC_CACHE); - const INT32 tagcolor = colortranslations[players[i].mo->color][7]; - const INT32 vflags = trans | V_NOSCALESTART; - tagwidth = cv_smallnametags.value ? dup*V_SmallStringWidth(player_names[i], V_ALLOWLOWERCASE) : dup*V_ThinStringWidth(player_names[i], V_ALLOWLOWERCASE); + dup = vid.dupx; + cm = R_GetTranslationColormap(players[i].skin, players[i].mo->color, GTC_CACHE); + tagcolor = colortranslations[players[i].mo->color][7]; + vflags = trans | V_NOSCALESTART; + usenametagrestat = ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2); tagwidthsmall = cv_smallnametags.value ? V_SmallStringWidth(player_names[i], V_ALLOWLOWERCASE) : V_ThinStringWidth(player_names[i], V_ALLOWLOWERCASE); + tagwidth = dup*tagwidthsmall; - if (cv_smallnametags.value == 2 || cv_smallnametags.value == 1 || !nametaggfx) + // If flipcam is on, other player is flipped relative to us when we have different + // verticalflip flag value. Otherwise, they are simply flipped when verticalflip flag says so + if ((stplyr->pflags & PF_FLIPCAM) && (stplyr->mo->eflags & MFE_VERTICALFLIP)) + flipped = (players[i].mo->eflags & MFE_VERTICALFLIP) != (stplyr->mo->eflags & MFE_VERTICALFLIP); + else + flipped = players[i].mo->eflags & MFE_VERTICALFLIP; + + if (cv_smallnametags.value || !nametaggfx) { if (flipped) namey += dup*5; @@ -9259,8 +9693,9 @@ static void K_drawNameTags(void) // Have to draw the nametag using patches here since drawfill can't draw at this scale... if (!flipped) V_DrawFixedPatch(namex<height/2)<width/2); // add offset to other stuff + V_DrawFixedPatch(namex<height/2)<width/2); // add offset to other stuff } //Name V_DrawSmallString(namex, namey, V_ALLOWLOWERCASE | vflags, tag); - if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) + if (usenametagrestat) { V_DrawSmallString(namex, namey - dup*5, vflags, va("\x84S%d ", players[i].kartspeed)); V_DrawSmallString(namex + dup*10, namey - dup*5, vflags, va("\x87W%d ", players[i].kartweight)); @@ -9283,10 +9718,8 @@ static void K_drawNameTags(void) if (cv_nametagscore.value) { - if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) - V_DrawSmallString(namex, namey - dup*10, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); - else - V_DrawSmallString(namex, namey - dup*5, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + INT32 yofs = usenametagrestat ? 10 : 5; + V_DrawSmallString(namex, namey - dup*yofs, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); } } else @@ -9311,16 +9744,17 @@ static void K_drawNameTags(void) } else { - for (j = 0; j < 4; j++) + for (j = 0; j < 4; j++) { namey -= dup*4; V_DrawFill(namex, namey, dup*3, dup*4, 31 | vflags); V_DrawFill(namex+dup, namey, dup, dup*4, tagcolor | vflags); namex += dup; } - V_DrawFill(namex, namey, dup, dup, 31 | vflags); - V_DrawFill(namex+dup, namey, tagwidth - dup*2, dup*3, 31 | vflags); - V_DrawFill(namex+dup, namey+dup, tagwidth - dup*3, dup, tagcolor | vflags); + + V_DrawFill(namex, namey, dup, dup, 31 | vflags); + V_DrawFill(namex+dup, namey, tagwidth - dup*2, dup*3, 31 | vflags); + V_DrawFill(namex+dup, namey+dup, tagwidth - dup*3, dup, tagcolor | vflags); } if (cv_nametagfacerank.value) @@ -9331,7 +9765,7 @@ static void K_drawNameTags(void) V_DrawThinString(namex, namey - dup*10, V_ALLOWLOWERCASE | vflags, tag); - if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) + if (usenametagrestat) { V_DrawScaledPatch(namex, namey - dup*20, vflags, nametagspeed); V_DrawScaledPatch(namex + dup*18, namey - dup*20, vflags, nametagweight); @@ -9341,10 +9775,8 @@ static void K_drawNameTags(void) if (cv_nametagscore.value) { - if ((cv_nametagrestat.value == 1 && (players[i].kartspeed != skins[players[i].skin].kartspeed || players[i].kartweight != skins[players[i].skin].kartweight)) || cv_nametagrestat.value == 2) - V_DrawSmallString(namex, namey - dup*25, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); - else - V_DrawSmallString(namex, namey - dup*15, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); + INT32 yofs = usenametagrestat ? 25 : 15; + V_DrawSmallString(namex, namey - dup*yofs, V_ALLOWLOWERCASE | vflags, va("\x8A%d ", players[i].score)); } } } @@ -9355,27 +9787,27 @@ static void K_drawDriftGauge(void) { vector2_t pos = {0}; fixed_t basex, basey; - const INT32 hudtransflag = V_LocalTransFlag(); const int dup = vid.dupx; int i; + UINT8 *cmap; - UINT8 driftcolors[3][4] = { + static UINT8 driftcolors[3][4] = { {0, 0, 10, 16}, // no drift {215, 215, 204, 253}, // blue {125, 125, 151, 159} // red }; - UINT8 driftskins[3] = { + static UINT8 driftskins[3] = { SKINCOLOR_NONE, SKINCOLOR_TEAL, SKINCOLOR_SALMON, }; - UINT8 driftrainbow[18] = { + static UINT8 driftrainbow[18] = { 0, 31, 47, 63, 79, 95, 111, 119, 127, 143, 159, 175, 183, 191, 199, 207, 223, 247 }; - if (demo.playback && demo.freecam) + if (camera[stplyrnum].freecam) return; if (P_MobjWasRemoved(stplyr->mo) || (!splitscreen && !camera->chase)) @@ -9392,17 +9824,17 @@ skipcrap: if (!K_GetScreenCoords(&pos, stplyr, stplyr->mo, FixedMul(cv_driftgaugeofs.value, cv_driftgaugeofs.value > 0 ? stplyr->mo->scale : mapobjectscale), false)) return; - const INT32 driftval = K_GetKartDriftSparkValue(stplyr); - const INT32 driftcharge = min(driftval*4, stplyr->kartstuff[k_driftcharge]); - - basex = pos.x>>FRACBITS; - basey = pos.y>>FRACBITS; - fixed_t barx; fixed_t bary; INT32 BAR_WIDTH; - const INT32 drifttrans = ((cv_driftgaugetrans.value) ? hudtransflag : 0); + const INT32 driftval = K_GetKartDriftSparkValue(stplyr); + const INT32 driftcharge = min(driftval*4, stplyr->kartstuff[k_driftcharge]); + const INT32 driftlevel = min(driftcharge / driftval, 2); + const INT32 drifttrans = ((cv_driftgaugetrans.value) ? V_LocalTransFlag() : 0); + + basex = pos.x>>FRACBITS; + basey = pos.y>>FRACBITS; switch (cv_driftgaugestyle.value) { @@ -9429,20 +9861,15 @@ skipcrap: bary = basey - dup*2; - UINT8 *cmap; - const INT32 limit = driftval * (driftcharge >= driftval*2 ? 2 : 1); - const INT32 width = ((driftcharge - (driftcharge >= driftval ? limit : 0)) * BAR_WIDTH) / limit; - const INT32 level = min(driftcharge / driftval, 2); - if (usescaledpatch) // i hate hud code i hate hud code i hate hud code i hate hud code i hate hud code..... { if (K_UseColorHud() && xtra_speedo_clr3) // Colourized hud { UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, K_GetHudColor(), GTC_CACHE); - V_DrawStretchyFixedPatch((basex - dup*30)<= driftval*4) // rainbow sparks { cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); - for (i = 0; i < 4; i++) + + for (i = 0; i < 4; i++) V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, (driftrainbow[min((leveltime % 18) + 1, 18 - 1)] + i*2) | V_NOSCALESTART|drifttrans); } else // none/blue/red { - cmap = R_GetTranslationColormap(TC_RAINBOW, driftskins[level],GTC_CACHE); + const INT32 limit = (driftval * (driftcharge >= driftval*2 ? 2 : 1)); + const INT32 width = ((driftcharge - (driftcharge >= driftval ? limit : 0)) * BAR_WIDTH) / limit; + + cmap = R_GetTranslationColormap(TC_RAINBOW, driftskins[driftlevel],GTC_CACHE); + for (i = 0; i < 4; i++) { if (driftcharge >= driftval) - V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, driftcolors[level-1][i] | V_NOSCALESTART|drifttrans); + V_DrawFill(barx, bary+dup*1+dup*i, BAR_WIDTH, dup, driftcolors[driftlevel-1][i] | V_NOSCALESTART|drifttrans); - V_DrawFill(barx, bary+dup*1+dup*i, width, dup, driftcolors[level][i] | V_NOSCALESTART|drifttrans); + V_DrawFill(barx, bary+dup*1+dup*i, width, dup, driftcolors[driftlevel][i] | V_NOSCALESTART|drifttrans); } } @@ -9484,12 +9916,10 @@ skipcrap: break; case 4: { - UINT8 *cmap; - const INT32 level = min(driftcharge / driftval, 2); + cmap = R_GetTranslationColormap(TC_RAINBOW, driftskins[driftlevel],GTC_CACHE); + if (driftcharge >= driftval*4) cmap = R_GetTranslationColormap(TC_RAINBOW, 1 + leveltime % (MAXSKINCOLORS-1),GTC_CACHE); - else - cmap = R_GetTranslationColormap(TC_RAINBOW, driftskins[level],GTC_CACHE); V_DrawPaddedTallColorNum(basex + (dup*16), basey, V_NOSCALESTART|V_OFFSET|drifttrans, driftcharge*100 / driftval, 3, cmap); } @@ -9509,17 +9939,17 @@ static fixed_t K_FindCheckX(fixed_t px, fixed_t py, angle_t ang, fixed_t mx, fix dist = abs(R_PointToDist2(px, py, mx, my)); if (dist > range) - return -320; + return -BASEVIDWIDTH; diff = R_PointToAngle2(px, py, mx, my) - ang; if (diff < ANGLE_90 || diff > ANGLE_270) - return -320; + return -BASEVIDWIDTH; else x = (FixedMul(FINETANGENT(((diff+ANGLE_90)>>ANGLETOFINESHIFT) & 4095), 160<>FRACBITS; if (encoremode) - x = 320-x; + x = BASEVIDWIDTH-x; if (splitscreen > 1) x /= 2; @@ -9533,7 +9963,7 @@ static void K_drawKartWanted(void) UINT8 *colormap = NULL; INT32 basex = 0, basey = 0; - if (stplyr != &players[displayplayers[0]]) + if (stplyrnum != 0) return; for (i = 0; i < 4; i++) @@ -9566,6 +9996,7 @@ static void K_drawKartWanted(void) if (battlewanted[0] != -1) colormap = R_GetTranslationColormap(0, players[battlewanted[0]].skincolor, GTC_CACHE); + V_DrawFixedPatch(basex< 1 ? kp_wantedsplit : kp_wanted), colormap); /*if (basey2) V_DrawFixedPatch(basex<skinlocal; + UINT8 skinnum = 0; + 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; fixed_t scale = FRACUNIT; + patch_t *minimaphead = NULL; + +#ifdef ROTSPRITE + angle_t rollangle = 0; + INT32 rot = 0; +#endif if (mo->skin) - skin = ((skin_t*)(mo->localskin ? mo->localskin : mo->skin))-(skinlocal ? localskins : skins); + skinnum = (skin-(skinlocal ? localskins : skins)); + + minimaphead = (skinlocal ? localfacemmapprefix : facemmapprefix)[skinnum]; 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); @@ -9674,13 +10114,12 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) if (encoremode) amnumxpos = -amnumxpos; - amxpos = amnumxpos + ((x + (SHORT(minimapinfo.minimap_pic->width)-SHORT((skinlocal ? localfacemmapprefix : facemmapprefix)[skin]->width)) / 2)<height)-SHORT((skinlocal ? localfacemmapprefix : facemmapprefix)[skin]->height)) / 2)<width)-SHORT(minimaphead->width)) / 2)<height)-SHORT(minimaphead->height)) / 2)<player && !(modeattacking || gamestate == GS_TIMEATTACK)) { - const char *player_name = va("%c%s", (mo->color) ? V_GetSkincolorChar(mo->color) : 0, player_names[mo->player - players]); - V_DrawCenteredSmallStringAtFixed(amxpos + (4*FRACUNIT), amypos - (3*FRACUNIT), V_ALLOWLOWERCASE|flags, player_name); + V_DrawCenteredSmallStringAtFixed(amxpos + (4*FRACUNIT), amypos - (3*FRACUNIT), V_ALLOWLOWERCASE|flags|V_SkinColorToHighlightcolor(mo->color), player_names[mo->player - players]); } // thx wanted reticle for having weird offsets very cool @@ -9689,22 +10128,37 @@ static void K_drawKartMinimapHead(mobj_t *mo, INT32 x, INT32 y, INT32 flags) if (cv_minihead.value) { - amxpos += (SHORT((skinlocal ? localfacemmapprefix : facemmapprefix)[skin]->width) / 4)<height) / 4)<width) / 4)<height) / 4)<player && mo->player->spinoutrot) + { + // Rotate counterclockwise. + rollangle = FixedAngle(mo->player->spinoutrot * -1); + rot = R_GetRollAngle(rollangle); + + if (rot) + { + minimaphead = W_CachePatchNameRotated(skin->facemmap, rot, PU_STATIC); + } + } +#endif + if (!mo->color) // 'default' color - V_DrawSciencePatch(amxpos, amypos, flags, ((skinlocal) ? localfacemmapprefix : facemmapprefix)[skin], scale); + V_DrawSciencePatch(amxpos, amypos, flags, minimaphead, scale); else { UINT8 *colormap; + if (mo->colorized) colormap = R_GetTranslationColormap(TC_RAINBOW, mo->color, GTC_CACHE); else colormap = R_GetLocalTranslationColormap(mo->skin, mo->localskin, mo->color, GTC_CACHE, skinlocal); - V_DrawFixedPatch(amxpos, amypos, scale, flags, ((skinlocal) ? localfacemmapprefix : facemmapprefix)[skin], colormap); + V_DrawFixedPatch(amxpos, amypos, scale, flags, minimaphead, colormap); if (mo->player && ((G_RaceGametype() && mo->player->kartstuff[k_position] == spbplace) @@ -9722,7 +10176,7 @@ static void K_drawKartMinimap(void) INT32 i = 0; INT32 x, y; INT32 minimaptrans, splitflags; - SINT8 localplayers[4]; + SINT8 localplayers[MAXSPLITSCREENPLAYERS]; SINT8 numlocalplayers = 0; // Draw the HUD only when playing in a level. @@ -9730,7 +10184,7 @@ static void K_drawKartMinimap(void) if (gamestate != GS_LEVEL) return; - if (stplyr != &players[displayplayers[0]]) + if (stplyrnum != 0) return; if (minimapinfo.minimap_pic == NULL) @@ -9744,7 +10198,6 @@ static void K_drawKartMinimap(void) y = info.y - (SHORT(minimapinfo.minimap_pic->height)/2); splitflags = info.flags; - if (forceshowhud) minimaptrans = cv_kartminimap.value; else if (timeinmap > 105) @@ -9780,7 +10233,7 @@ static void K_drawKartMinimap(void) y -= SHORT(minimapinfo.minimap_pic->topoffset); // initialize - for (i = 0; i < 4; i++) + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) localplayers[i] = -1; // Player's tiny icons on the Automap. (drawn opposite direction so player 1 is drawn last in splitscreen) @@ -9796,8 +10249,7 @@ static void K_drawKartMinimap(void) if (!stplyr->mo || stplyr->spectator) // do we need the latter..? return; - localplayers[numlocalplayers] = stplyr-players; - numlocalplayers++; + localplayers[numlocalplayers++] = stplyr-players; } else { @@ -9805,31 +10257,29 @@ static void K_drawKartMinimap(void) { if (!playeringame[i]) continue; + if (!players[i].mo || players[i].spectator) continue; - if (i != displayplayers[0] || splitscreen) - { - if (G_BattleGametype() && players[i].kartstuff[k_bumper] <= 0) - continue; - - if (players[i].kartstuff[k_hyudorotimer] > 0) - { - if (!((players[i].kartstuff[k_hyudorotimer] < 1*TICRATE/2 - || players[i].kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)) - && !(leveltime & 1))) - continue; - } - } - if (P_IsDisplayPlayer(&players[i])) { // Draw display players on top of everything else - localplayers[numlocalplayers] = i; - numlocalplayers++; + localplayers[numlocalplayers++] = i; continue; } + // Now we know it's not a display player, handle non-local player exceptions. + if (G_BattleGametype() && players[i].kartstuff[k_bumper] <= 0) + continue; + + if (players[i].kartstuff[k_hyudorotimer] > 0) + { + if (!((players[i].kartstuff[k_hyudorotimer] < 1*TICRATE/2 + || players[i].kartstuff[k_hyudorotimer] > hyudorotime-(1*TICRATE/2)) + && !(leveltime & 1))) + continue; + } + K_drawKartMinimapHead(players[i].mo, x, y, splitflags); } } @@ -9840,7 +10290,7 @@ static void K_drawKartMinimap(void) for (i = 0; i < numlocalplayers; i++) { - if (i == -1) + if (localplayers[i] == -1) continue; // this doesn't interest us K_drawKartMinimapHead(players[localplayers[i]].mo, x, y, splitflags); } @@ -9892,7 +10342,7 @@ static void K_drawKartFinish(void) xval = (SHORT(kp_racefinish[pnum]->width)<kartstuff[k_cardanimation])< x ? xval : x))/TICRATE; - if (splitscreen && stplyr == &players[displayplayers[1]]) + if (splitscreen && stplyrnum == 1) x = -x; V_DrawFixedPatch(x + (STCD_X<>1), @@ -10049,14 +10499,9 @@ static void K_drawKartFirstPerson(void) if (stplyr->spectator || !stplyr->mo || (stplyr->mo->flags2 & MF2_DONTDRAW)) return; - if (stplyr == &players[displayplayers[1]] && splitscreen) - { pn = pnum[1]; tn = turn[1]; dr = drift[1]; } - else if (stplyr == &players[displayplayers[2]] && splitscreen > 1) - { pn = pnum[2]; tn = turn[2]; dr = drift[2]; } - else if (stplyr == &players[displayplayers[3]] && splitscreen > 2) - { pn = pnum[3]; tn = turn[3]; dr = drift[3]; } - else - { pn = pnum[0]; tn = turn[0]; dr = drift[0]; } + pn = pnum[stplyrnum]; + tn = turn[stplyrnum]; + dr = drift[stplyrnum]; if (splitscreen) { @@ -10178,14 +10623,9 @@ static void K_drawKartFirstPerson(void) V_DrawFixedPatch(x, y, scale, splitflags, kp_fpview[target], colmap); - if (stplyr == &players[displayplayers[1]] && splitscreen) - { pnum[1] = pn; turn[1] = tn; drift[1] = dr; } - else if (stplyr == &players[displayplayers[2]] && splitscreen > 1) - { pnum[2] = pn; turn[2] = tn; drift[2] = dr; } - else if (stplyr == &players[displayplayers[3]] && splitscreen > 2) - { pnum[3] = pn; turn[3] = tn; drift[3] = dr; } - else - { pnum[0] = pn; turn[0] = tn; drift[0] = dr; } + pnum[stplyrnum] = pn; + turn[stplyrnum] = tn; + drift[stplyrnum] = dr; } // doesn't need to ever support 4p @@ -10196,7 +10636,7 @@ static void K_drawInput(void) static INT32 pn = 0; INT32 target = 0, splitflags = (V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS); - INT32 x = (BASEVIDWIDTH - 32 + cv_posi_xoffset.value)*FRACUNIT, y = (BASEVIDHEIGHT - 24 + cv_posi_yoffset.value)*FRACUNIT; + 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]; @@ -10220,7 +10660,7 @@ static void K_drawInput(void) #define BUTTH 11 #define drawbutt(xoffs, butt, symb)\ - if (stplyr->cmd.buttons & butt)\ + if (cmd->buttons & butt)\ {\ offs = 2*FRACUNIT;\ col = accent1;\ @@ -10246,43 +10686,112 @@ static void K_drawInput(void) y -= FRACUNIT; - if (!cmd->driftturn) // no turn - target = 0; - else // turning of multiple strengths! + if (cv_showinput.value == 2) { - target = ((abs(cmd->driftturn) - 1)/125)+1; - if (target > 4) - target = 4; - if (cmd->driftturn < 0) - target = -target; + INT32 joyx, joyxoffs, joyy, joyyoffs, axis; + joyxoffs = -8, joyyoffs = -24; + joyx = x>>FRACBITS, joyy = y>>FRACBITS; + + // O backing + 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) + { + const boolean analogjoystickmove = cv_usejoystick[stplyrnum].value && !Joystick[stplyrnum].bGamepadStyle; + const boolean gamepadjoystickmove = cv_usejoystick[stplyrnum].value && Joystick[stplyrnum].bGamepadStyle; + const UINT8 ssplayer = stplyrnum+1; + + axis = JoyAxis(AXISAIM, ssplayer); + + if (analogjoystickmove && axis != 0) + { + // JOYAXISRANGE is supposed to be 1023 (divide by 1024) + hudforward -= ((axis * KART_FULLTURN) / (JOYAXISRANGE-1)); + } + else + { + if (InputDown(gc_aimforward, ssplayer) || (gamepadjoystickmove && axis < 0)) + { + hudforward += KART_FULLTURN; + } + if (InputDown(gc_aimbackward, ssplayer) || (gamepadjoystickmove && axis > 0)) + { + hudforward-= KART_FULLTURN; + } + } + } + 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); + } + 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 (pn != target) - { - if (abs(pn - target) == 1) - pn = target; - else if (pn < target) - pn += 2; - else //if (pn > target) - pn -= 2; - } - - if (pn < 0) - { - splitflags |= V_FLIP; // right turn - x -= FRACUNIT; - } - - target = abs(pn); - if (target > 4) - target = 4; - - if (!K_GetHudColor()) - V_DrawFixedPatch(x, y, FRACUNIT, splitflags, kp_inputwheel[target], NULL); else { - UINT8 *colormap; - colormap = R_GetTranslationColormap(0, K_GetHudColor(), GTC_CACHE); + UINT8 *colormap = NULL; + + if (!cmd->driftturn) // no turn + target = 0; + else // turning of multiple strengths! + { + target = ((abs(cmd->driftturn) - 1)/125)+1; + if (target > 4) + target = 4; + if (cmd->driftturn < 0) + target = -target; + } + + if (pn != target) + { + if (abs(pn - target) == 1) + pn = target; + else if (pn < target) + pn += 2; + else //if (pn > target) + pn -= 2; + } + + if (pn < 0) + { + splitflags |= V_FLIP; // right turn + x -= FRACUNIT; + } + + target = abs(pn); + 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); } } @@ -10405,7 +10914,7 @@ static void K_drawDistributionDebugger(void) boolean dontforcespb = false; boolean spbrush = false; - if (stplyr != &players[displayplayers[0]]) // only for p1 + if (stplyrnum != 0) // only for p1 return; // The only code duplication from the Kart, just to avoid the actual item function from calculating pingame twice @@ -10469,7 +10978,7 @@ static void K_drawDistributionDebugger(void) static void K_drawCheckpointDebugger(void) { - if (stplyr != &players[displayplayers[0]]) // only for p1 + if (stplyrnum != 0) // only for p1 return; if (stplyr->starpostnum >= (numstarposts - (numstarposts/2))) @@ -10483,22 +10992,18 @@ void K_drawKartHUD(void) { boolean isfreeplay = false; boolean battlefullscreen = false; - boolean freecam = demo.freecam; //disable some hud elements w/ freecam - UINT8 i; + boolean freecam = camera[stplyrnum].freecam; //disable some hud elements w/ freecam // Define the X and Y for each drawn object // This is handled by console/menu values K_initKartHUD(); // Draw that fun first person HUD! Drawn ASAP so it looks more "real". - for (i = 0; i <= splitscreen; i++) - { - if (stplyr == &players[displayplayers[i]] && !camera[i].chase && !freecam) - K_drawKartFirstPerson(); - } + if (!camera[stplyrnum].chase && !freecam) + K_drawKartFirstPerson(); // Draw full screen stuff that turns off the rest of the HUD - if (mapreset && stplyr == &players[displayplayers[0]]) + if (mapreset && stplyrnum == 0) { K_drawChallengerScreen(); return; @@ -10591,7 +11096,7 @@ void K_drawKartHUD(void) } } - if (!stplyr->spectator && !demo.freecam) // Bottom of the screen elements, don't need in spectate mode + if (!stplyr->spectator && !freecam) // Bottom of the screen elements, don't need in spectate mode { if (!(splitscreen || demo.title)) { diff --git a/src/k_kart.h b/src/k_kart.h index 34c59c622..75727f072 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -11,6 +11,7 @@ #define KART_FULLTURN 800 + extern UINT8 colortranslations[MAXTRANSLATIONS][16]; extern const char *KartColor_Names[MAXSKINCOLORS]; extern const UINT8 KartColor_Opposite[MAXSKINCOLORS*2]; @@ -22,17 +23,21 @@ boolean K_UseColorHud(void); void K_RegisterKartStuff(void); -extern consvar_t cv_colorizedhud; -extern consvar_t cv_colorizeditembox; -extern consvar_t cv_colorizedhudcolor; +extern consvar_t cv_coloredspeedlines, cv_coloredsneakertrail; +extern consvar_t cv_bananajitter; +extern consvar_t cv_bananthrowroll; +extern consvar_t cv_airsparks; +extern consvar_t cv_colorizedhud, cv_colorizeditembox, cv_colorizedhudcolor; extern consvar_t cv_darkitembox; extern consvar_t cv_biglaps; extern consvar_t cv_highresportrait; -extern consvar_t cv_stat_xoffset; -extern consvar_t cv_stat_yoffset; +extern consvar_t cv_stat_xoffset, cv_stat_yoffset; extern consvar_t cv_showstats; +extern consvar_t cv_fancyroulette; extern consvar_t cv_showlaptimes; extern consvar_t cv_battlespeedo; +extern consvar_t cv_multiitemicon; +extern consvar_t cv_huditemamount; #define NUMSPEEDOSTUFF 6 extern CV_PossibleValue_t speedo_cons_t[NUMSPEEDOSTUFF]; @@ -56,7 +61,7 @@ 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); -void K_RollMobjBySlopes(mobj_t *mo, boolean usedistance); +void K_RollMobjBySlopes(mobj_t *mo, pslope_t *slope); void K_SpawnBoostTrail(player_t *player); void K_SpawnSparkleTrail(mobj_t *mo); void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent); diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 0a8ee9cae..3a4cf555e 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -64,7 +64,7 @@ static UINT8 * hooksErrored; static int errorRef; -static boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type) +FUNCINLINE static ATTRINLINE boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type) { return ( @@ -73,7 +73,7 @@ static boolean mobj_hook_available(int hook_type, mobjtype_t mobj_type) ); } -static unsigned hook_in_list +FUNCINLINE static ATTRINLINE unsigned hook_in_list ( const char * const name, const char * const * const list @@ -106,7 +106,7 @@ static void get_table(lua_State *L) lua_remove(L, -2); } -static void add_hook_to_table(lua_State *L, int n) +FUNCINLINE static ATTRINLINE void add_hook_to_table(lua_State *L, int n) { lua_pushnumber(L, nextid); lua_rawseti(L, -2, n); @@ -175,14 +175,14 @@ static void add_string_hook(lua_State *L, int type) add_hook_to_table(L, ++hook->numGeneric); } -static void add_hook(hook_t *map) +FUNCINLINE static ATTRINLINE void add_hook(hook_t *map) { Z_Realloc(map->ids, (map->numHooks + 1) * sizeof *map->ids, PU_STATIC, &map->ids); map->ids[map->numHooks++] = nextid; } -static void add_mobj_hook(lua_State *L, int hook_type) +FUNCINLINE static ATTRINLINE void add_mobj_hook(lua_State *L, int hook_type) { mobjtype_t mobj_type = luaL_optnumber(L, 3, MT_NULL); @@ -191,7 +191,7 @@ static void add_mobj_hook(lua_State *L, int hook_type) add_hook(&mobjHookIds[mobj_type][hook_type]); } -static void add_hud_hook(lua_State *L, int idx) +FUNCINLINE static ATTRINLINE void add_hud_hook(lua_State *L, int idx) { add_hook(&hudHookIds[luaL_checkoption(L, idx, "game", hudHookNames)]); @@ -263,7 +263,6 @@ int LUA_HookLib(lua_State *L) return 0; } - int lib_hudadd(lua_State *L);/* yeah compiler */ int lib_hudadd(lua_State *L) { @@ -297,24 +296,24 @@ enum { SINDEX = 2,/* string itself is pushed in case of string hook */ }; -static void push_error_handler(void) +FUNCINLINE static ATTRINLINE void push_error_handler(void) { lua_getref(gL, errorRef); } /* repush hook string */ -static void push_string(void) +FUNCINLINE static ATTRINLINE void push_string(void) { lua_pushvalue(gL, SINDEX); } -static boolean begin_hook_values(Hook_State *hook) +FUNCINLINE static ATTRINLINE boolean begin_hook_values(Hook_State *hook) { hook->top = lua_gettop(gL); return true; } -static void start_hook_stack(void) +FUNCINLINE static ATTRINLINE void start_hook_stack(void) { lua_settop(gL, 0); push_error_handler(); @@ -343,7 +342,7 @@ static boolean init_hook_type return false; } -static boolean prepare_hook +FUNCINLINE static ATTRINLINE boolean prepare_hook ( Hook_State * hook, int default_status, @@ -356,7 +355,7 @@ static boolean prepare_hook hookIds[hook_type].numHooks); } -static boolean prepare_mobj_hook +FUNCINLINE static ATTRINLINE boolean prepare_mobj_hook ( Hook_State * hook, int default_status, @@ -373,7 +372,7 @@ static boolean prepare_mobj_hook mobj_hook_available(hook_type, mobj_type)); } -static boolean prepare_string_hook +FUNCINLINE static ATTRINLINE boolean prepare_string_hook ( Hook_State * hook, int default_status, @@ -393,7 +392,7 @@ static boolean prepare_string_hook return false; } -static void init_hook_call +FUNCINLINE static ATTRINLINE void init_hook_call ( Hook_State * hook, int results, @@ -406,13 +405,13 @@ static void init_hook_call hook->results_handler = results_handler; } -static void get_hook(Hook_State *hook, const int *ids, int n) +FUNCINLINE static ATTRINLINE void get_hook(Hook_State *hook, const int *ids, int n) { hook->id = ids[n]; lua_getref(gL, hookRefs[hook->id]); } -static void get_hook_from_table(Hook_State *hook, int n) +FUNCINLINE static ATTRINLINE void get_hook_from_table(Hook_State *hook, int n) { lua_rawgeti(gL, -1, n); hook->id = lua_tonumber(gL, -1); @@ -444,7 +443,7 @@ static int call_single_hook_no_copy(Hook_State *hook) return 1; } -static int call_single_hook(Hook_State *hook) +FUNCINLINE static ATTRINLINE int call_single_hook(Hook_State *hook) { int i; @@ -454,7 +453,7 @@ static int call_single_hook(Hook_State *hook) return call_single_hook_no_copy(hook); } -static int call_hook_table_for(Hook_State *hook, int n) +FUNCINLINE static ATTRINLINE int call_hook_table_for(Hook_State *hook, int n) { int k; @@ -467,12 +466,12 @@ static int call_hook_table_for(Hook_State *hook, int n) return n; } -static int call_hook_table(Hook_State *hook) +FUNCINLINE static ATTRINLINE int call_hook_table(Hook_State *hook) { return call_hook_table_for(hook, lua_objlen(gL, -1)); } -static int call_mapped(Hook_State *hook, const hook_t *map) +FUNCINLINE static ATTRINLINE int call_mapped(Hook_State *hook, const hook_t *map) { int k; @@ -503,7 +502,7 @@ static int call_string_hooks(Hook_State *hook) return calls; } -static int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) +FUNCINLINE static ATTRINLINE int call_mobj_type_hooks(Hook_State *hook, mobjtype_t mobj_type) { return call_mapped(hook, &mobjHookIds[mobj_type][hook->hook_type]); } @@ -546,7 +545,7 @@ static int call_hooks #define res_none NULL -static void res_true(Hook_State *hook) +FUNCINLINE static ATTRINLINE void res_true(Hook_State *hook) { if (lua_toboolean(gL, -1)) hook->status = true; @@ -558,7 +557,7 @@ static void res_true(Hook_State *hook) hook->status = false; }*/ -static void res_force(Hook_State *hook) +FUNCINLINE static ATTRINLINE void res_force(Hook_State *hook) { if (!lua_isnil(gL, -1)) { @@ -569,7 +568,7 @@ static void res_force(Hook_State *hook) } } -static void res_hud(Hook_State *hook) +FUNCINLINE static ATTRINLINE void res_hud(Hook_State *hook) { (void)hook; @@ -700,6 +699,8 @@ static void hook_think_frame(int type) const hook_t * map = &hookIds[type]; int k; + const boolean perfstats = (cv_perfstats.value >= 3); + if (prepare_hook(&hook, 0, type)) { init_hook_call(&hook, 0, res_none); @@ -708,7 +709,7 @@ static void hook_think_frame(int type) { get_hook(&hook, map->ids, k); - if (cv_perfstats.value >= 3) + if (perfstats) { lua_pushvalue(gL, -1);/* need the function again */ time_taken = I_GetPreciseTime(); @@ -716,7 +717,7 @@ static void hook_think_frame(int type) call_single_hook(&hook); - if (cv_perfstats.value >= 3) + if (perfstats) { lua_Debug ar; time_taken = I_GetPreciseTime() - time_taken; @@ -808,7 +809,7 @@ typedef struct { ticcmd_t * cmd; } BotAI_State; -static boolean checkbotkey(const char *field) +FUNCINLINE static ATTRINLINE boolean checkbotkey(const char *field) { return lua_toboolean(gL, -1) && strcmp(lua_tostring(gL, -2), field) == 0; } diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index f3c01f4eb..45570b2cd 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -397,6 +397,18 @@ static int libd_cachePatch(lua_State *L) return 1; } +#ifdef ROTSPRITE +static int libd_cachePatchRotated(lua_State *L) +{ + HUDONLY + angle_t rollangle = luaL_checkangle(L, 2); + INT32 rot = R_GetRollAngle(rollangle); + LUA_PushUserdata(L, W_CachePatchNameRotated(luaL_checkstring(L, 1), rot, PU_STATIC), META_PATCH); + + return 1; +} +#endif + // this is structured like getSprite2Patch in vanilla 2.2 // v.getSpritePatch(skin, sprite, [frame, [angle, [rollangle]]]) static int libd_getSpritePatch(lua_State *L) @@ -462,12 +474,16 @@ static int libd_getSpritePatch(lua_State *L) if (skn < 0) // standard sprite { sprdef = &sprites[i]; +#ifdef ROTSPRITE sprinfo = &spriteinfo[i]; +#endif } else // player skin { sprdef = &skins[skn].spritedef; +#ifdef ROTSPRITE sprinfo = &skins[skn].sprinfo; +#endif } // set frame number @@ -488,13 +504,15 @@ static int libd_getSpritePatch(lua_State *L) if (angle >= 8) // out of range? angle = (angle & 7); // modulus angle by 8 +#ifdef ROTSPRITE // rotsprite????? - if (lua_isnumber(L, 4) && cv_sloperoll.value) + if (lua_isnumber(L, 4)) { angle_t rollangle = luaL_checkangle(L, 4); INT32 rot = R_GetRollAngle(rollangle); - if (rot) { + if (rot) + { patch_t *rotsprite = Patch_GetRotatedSprite(sprframe, frame, angle, sprframe->flip & (1<lumppat[angle], PU_STATIC), META_PATCH); @@ -511,7 +530,7 @@ static int libd_getSpritePatch(lua_State *L) static int libd_draw(lua_State *L) { - INT32 x, y, flags; + INT32 x, y, flags, blend; patch_t *patch; UINT8 *colormap = NULL; huddrawlist_h list; @@ -523,6 +542,7 @@ static int libd_draw(lua_State *L) flags = luaL_optinteger(L, 4, 0); if (!lua_isnoneornil(L, 5)) colormap = *((UINT8 **)luaL_checkudata(L, 5, META_COLORMAP)); + blend = luaL_optinteger(L, 6, 0); flags &= ~V_PARAMMASK; // Don't let crashes happen. @@ -531,16 +551,16 @@ static int libd_draw(lua_State *L) lua_pop(L, 1); if (LUA_HUD_IsDrawListValid(list)) - LUA_HUD_AddDraw(list, x, y, patch, flags, colormap); + LUA_HUD_AddDraw(list, x, y, patch, flags, colormap, blend); else - V_DrawFixedPatch(x<patch = patch; item->flags = flags; item->colormap = colormap; + item->blend = blend; } void LUA_HUD_AddDrawScaled( @@ -366,7 +369,8 @@ void LUA_HUD_AddDrawScaled( fixed_t scale, patch_t *patch, INT32 flags, - UINT8 *colormap + UINT8 *colormap, + INT32 blend ) { size_t i = AllocateDrawItem(list); @@ -379,6 +383,7 @@ void LUA_HUD_AddDrawScaled( item->patch = patch; item->flags = flags; item->colormap = colormap; + item->blend = blend; } void LUA_HUD_AddDrawStretched( @@ -389,7 +394,8 @@ void LUA_HUD_AddDrawStretched( fixed_t vscale, patch_t *patch, INT32 flags, - UINT8 *colormap + UINT8 *colormap, + INT32 blend ) { size_t i = AllocateDrawItem(list); @@ -403,6 +409,7 @@ void LUA_HUD_AddDrawStretched( item->patch = patch; item->flags = flags; item->colormap = colormap; + item->blend = blend; } void LUA_HUD_AddDrawNum( @@ -634,17 +641,17 @@ void LUA_HUD_DrawList(huddrawlist_h list) case DI_Draw: if (!item->patch || item->patch == NULL) return; - V_DrawFixedPatch(LERPS(x), LERPS(y), FRACUNIT, item->flags, item->patch, item->colormap); + 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_DrawFixedPatch(LERPS(x), LERPS(y), LERP(scale), item->flags, item->patch, item->colormap); + 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); + V_DrawStretchyFixedPatch(LERPS(x), LERPS(y), LERP(hscale), LERP(vscale), item->flags, item->patch, item->colormap, item->blend); break; case DI_DrawNum: V_DrawTallNum(LERPS(x), LERPS(y), item->flags, item->num); diff --git a/src/lua_hudlib_drawlist.h b/src/lua_hudlib_drawlist.h index 4354b6f95..4d19bcae2 100644 --- a/src/lua_hudlib_drawlist.h +++ b/src/lua_hudlib_drawlist.h @@ -40,7 +40,8 @@ void LUA_HUD_AddDraw( INT32 y, patch_t *patch, INT32 flags, - UINT8 *colormap + UINT8 *colormap, + INT32 blend ); void LUA_HUD_AddDrawStretched( huddrawlist_h list, @@ -50,7 +51,8 @@ void LUA_HUD_AddDrawStretched( fixed_t vscale, patch_t *patch, INT32 flags, - UINT8 *colormap + UINT8 *colormap, + INT32 blend ); void LUA_HUD_AddDrawScaled( huddrawlist_h list, @@ -59,7 +61,8 @@ void LUA_HUD_AddDrawScaled( fixed_t scale, patch_t *patch, INT32 flags, - UINT8 *colormap + UINT8 *colormap, + INT32 blend ); void LUA_HUD_AddDrawNum( huddrawlist_h list, diff --git a/src/lua_maplib.c b/src/lua_maplib.c index a6bca2ff6..c4718ae90 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -94,6 +94,7 @@ enum line_e { line_sidenum, line_frontside, line_backside, + line_alpha, line_slopetype, line_frontsector, line_backsector, @@ -115,6 +116,7 @@ static const char *const line_opt[] = { "sidenum", "frontside", "backside", + "alpha", "slopetype", "frontsector", "backsector", @@ -186,6 +188,7 @@ enum ffloor_e { ffloor_next, ffloor_prev, ffloor_alpha, + ffloor_blend, }; static const char *const ffloor_opt[] = { @@ -204,6 +207,7 @@ static const char *const ffloor_opt[] = { "next", "prev", "alpha", + "blend", NULL}; static int ffloor_fields_ref = LUA_NOREF; @@ -652,6 +656,9 @@ static int line_get(lua_State *L) return 0; LUA_PushUserdata(L, &sides[line->sidenum[1]], META_SIDE); return 1; + case line_alpha: + lua_pushfixed(L, line->alpha); + return 1; case line_slopetype: switch(line->slopetype) { @@ -1168,6 +1175,9 @@ static int ffloor_get(lua_State *L) case ffloor_alpha: lua_pushinteger(L, ffloor->alpha); return 1; + case ffloor_blend: + lua_pushinteger(L, ffloor->blend); + return 1; } return 0; } @@ -1246,6 +1256,9 @@ static int ffloor_set(lua_State *L) case ffloor_alpha: ffloor->alpha = (INT32)luaL_checkinteger(L, 3); break; + case ffloor_blend: + ffloor->blend = (INT32)luaL_checkinteger(L, 3); + break; } return 0; } diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 8cb3ecf98..978f75d01 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -40,6 +40,7 @@ int mobj_sprev_unimplemented(lua_State *L); int mobj_angle_setter(lua_State *L); int mobj_sloperoll_noop(lua_State *L); int mobj_spritescale_setter(lua_State *L); +int mobj_spriteoffset_setter(lua_State *L); int mobj_touching_sectorlist_unimplemented(lua_State *L); int mobj_radius_setter(lua_State *L); int mobj_height_setter(lua_State *L); @@ -52,6 +53,7 @@ int mobj_skin_setter(lua_State *L); int mobj_localskin_getter(lua_State *L); int mobj_localskin_setter(lua_State *L); int mobj_color_setter(lua_State *L); +int mobj_blendmode_setter(lua_State *L); int mobj_bnext_noset(lua_State *L); int mobj_bprev_unimplemented(lua_State *L); int mobj_hnext_setter(lua_State *L); @@ -94,8 +96,8 @@ static const udata_field_t mobj_fields[] = { FIELD(mobj_t, anim_duration, udatalib_getter_uint16, udatalib_setter_uint16), FIELD(mobj_t, spritexscale, udatalib_getter_fixed, mobj_spritescale_setter), FIELD(mobj_t, spriteyscale, udatalib_getter_fixed, mobj_spritescale_setter), - FIELD(mobj_t, spritexoffset, udatalib_getter_fixed, udatalib_setter_fixed), - FIELD(mobj_t, spriteyoffset, udatalib_getter_fixed, udatalib_setter_fixed), + 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), @@ -115,6 +117,7 @@ static const udata_field_t mobj_fields[] = { FIELD(mobj_t, skin, mobj_skin_getter, mobj_skin_setter), FIELD(mobj_t, localskin, mobj_localskin_getter, mobj_localskin_setter), FIELD(mobj_t, color, udatalib_getter_uint8, mobj_color_setter), + FIELD(mobj_t, blendmode, udatalib_getter_int32, mobj_blendmode_setter), FIELD(mobj_t, bnext, udatalib_getter_mobj, mobj_bnext_noset), FIELD(mobj_t, bprev, mobj_bprev_unimplemented, mobj_bprev_unimplemented), FIELD(mobj_t, hnext, udatalib_getter_mobj, mobj_hnext_setter), @@ -147,7 +150,6 @@ static const udata_field_t mobj_fields[] = { FIELD(mobj_t, standingslope, udatalib_getter_slope, mobj_standingslope_noset), FIELD(mobj_t, colorized, udatalib_getter_boolean, udatalib_setter_boolean), FIELD(mobj_t, mirrored, udatalib_getter_boolean, udatalib_setter_boolean), - FIELD(mobj_t, rollmodel, udatalib_getter_boolean, udatalib_setter_boolean), { NULL, 0, NULL, NULL }, }; #undef FIELD @@ -278,6 +280,26 @@ int mobj_spritescale_setter(lua_State *L) return 0; } +int mobj_spriteoffset_setter(lua_State *L) +{ + mobj_t *mo = GETMO(); + + fixed_t *spriteoffset; + UDATALIB_GETFIELD(fixed_t, spriteoffset); + + if (!mo->player) + *spriteoffset = luaL_checkfixed(L, 2); + else + { + // Mmm yea + if (spriteoffset == &mo->spritexoffset) + mo->realxoffset = luaL_checkfixed(L, 2); + else + mo->realyoffset = luaL_checkfixed(L, 2); + } + return 0; +} + int mobj_radius_setter(lua_State *L) { mobj_t *mo = GETMO(); @@ -477,6 +499,18 @@ int mobj_color_setter(lua_State *L) return 0; } +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; +} + int mobj_hnext_setter(lua_State *L) { mobj_t *mo = GETMO(); diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index dd4cf7b03..32b4abfe7 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -157,9 +157,8 @@ static const udata_field_t player_fields[] = { FIELD(player_t, grieftime, udatalib_getter_tic, udatalib_setter_tic), FIELD(player_t, griefstrikes, udatalib_getter_uint8, udatalib_setter_uint8), FIELD(player_t, splitscreenindex, udatalib_getter_uint8, player_splitscreenindex_noset), -#ifdef HWRENDER FIELD(player_t, fovadd, udatalib_getter_fixed, udatalib_setter_fixed), // Mmm yeah thats definitely synch safe -#endif + // Same as player.name { "sliproll", 0, player_sliproll_getter, player_sliproll_noset }, { "viewrollangle", 0, player_viewrollangle_getter, player_viewrollangle_noset }, @@ -882,4 +881,4 @@ int LUA_PlayerLib(lua_State *L) lua_setglobal(L, "displayplayers"); return 0; -} \ No newline at end of file +} diff --git a/src/lua_script.c b/src/lua_script.c index 6f439479e..12192b0b2 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -504,6 +504,8 @@ void LUA_InvalidateLevel(void) { thinker_t *th; size_t i; + ffloor_t *rover = NULL; + if (!gL) return; @@ -515,32 +517,55 @@ void LUA_InvalidateLevel(void) for (i = 0; i < numsubsectors; i++) LUA_InvalidateUserdata(&subsectors[i]); for (i = 0; i < numsectors; i++) + { LUA_InvalidateUserdata(§ors[i]); + LUA_InvalidateUserdata(§ors[i].lines); + + if (sectors[i].ffloors) + { + for (rover = sectors[i].ffloors; rover; rover = rover->next) + LUA_InvalidateUserdata(rover); + } + } + for (i = 0; i < numlines; i++) { LUA_InvalidateUserdata(&lines[i]); LUA_InvalidateUserdata(lines[i].sidenum); } + for (i = 0; i < numsides; i++) LUA_InvalidateUserdata(&sides[i]); for (i = 0; i < numvertexes; i++) LUA_InvalidateUserdata(&vertexes[i]); + + for (pslope_t *slope = slopelist; slope; slope = slope->next) + { + LUA_InvalidateUserdata(slope); + LUA_InvalidateUserdata(&slope->normal); + LUA_InvalidateUserdata(&slope->o); + LUA_InvalidateUserdata(&slope->d); + } } void LUA_InvalidateMapthings(void) { size_t i; + if (!gL) return; for (i = 0; i < nummapthings; i++) + { LUA_InvalidateUserdata(&mapthings[i]); + } } void LUA_InvalidatePlayer(player_t *player) { if (!gL) return; + LUA_InvalidateUserdata(player); LUA_InvalidateUserdata(player->powers); LUA_InvalidateUserdata(player->kartstuff); @@ -586,7 +611,7 @@ static const struct { {META_SUBSECTOR,ARCH_SUBSECTOR}, {META_SECTOR, ARCH_SECTOR}, {META_SLOPE, ARCH_SLOPE}, - {META_MAPHEADER, ARCH_MAPHEADER}, + {META_MAPHEADER,ARCH_MAPHEADER}, {NULL, ARCH_NULL} }; @@ -940,7 +965,7 @@ static void ArchiveTables(UINT8 **p) } } -static UINT8 UnArchiveValue(UINT8 **p, int TABLESINDEX) +static UINT8 UnArchiveValue(UINT8 **p, int TABLESINDEX, boolean network) { UINT8 type = READUINT8(*p); switch (type) @@ -992,6 +1017,12 @@ static UINT8 UnArchiveValue(UINT8 **p, int TABLESINDEX) LUA_PushUserdata(gL, &states[READUINT16(*p)], META_STATE); break; case ARCH_MOBJ: + if (network == false) // for replays :chaosleep: + { + *p += sizeof(UINT32); // Skip this data, we can't read a mobj here, it'd point to garbage and crash the game. + return 3; // Don't set the field + } + LUA_PushUserdata(gL, P_FindNewPosition(READUINT32(*p)), META_MOBJ); break; case ARCH_PLAYER: @@ -1033,106 +1064,6 @@ static UINT8 UnArchiveValue(UINT8 **p, int TABLESINDEX) return 0; } - -// Unarchives from demo_p: -// Return values: -// 0: Normal -// 1: Read table key -// 2: Read table value -// 3: Don't use setfield - -static UINT8 UnArchiveValueDemo(UINT8 **p, int TABLESINDEX, char field[1024]) -{ - UINT8 type = READUINT8(*p); - switch (type) - { - case ARCH_NULL: - lua_pushnil(gL); - break; - case ARCH_BOOLEAN: - lua_pushboolean(gL, READUINT8(*p)); - break; - case ARCH_SIGNED: - lua_pushinteger(gL, READFIXED(*p)); - break; - case ARCH_STRING: - { - UINT16 len = READUINT16(*p); // length of string, including embedded zeros - char *value; - UINT16 i = 0; - // See my comments in the ArchiveValue function; - // it's much the same for reading strings as writing them! - // (i.e. we can't use READSTRING either) - // -- Monster Iestyn 05/08/18 - value = malloc(len); // make temp buffer of size len - // now read the actual string - while (i < len) - value[i++] = READCHAR(*p); // read chars individually, including the embedded zeros - lua_pushlstring(gL, value, len); // push the string (note: this function supports embedded zeros) - free(value); // free the buffer - break; - } - case ARCH_TABLE: - { - UINT16 tid = READUINT16(*p); - lua_rawgeti(gL, TABLESINDEX, tid); - if (lua_isnil(gL, -1)) - { - lua_pop(gL, 1); - lua_newtable(gL); - lua_pushvalue(gL, -1); - lua_rawseti(gL, TABLESINDEX, tid); - return 2; - } - break; - } - case ARCH_MOBJINFO: - LUA_PushUserdata(gL, &mobjinfo[READUINT16(*p)], META_MOBJINFO); - break; - case ARCH_STATE: - LUA_PushUserdata(gL, &states[READUINT16(*p)], META_STATE); - break; - case ARCH_MOBJ: - *p += sizeof(UINT32); // Skip this data, we can't read a mobj here, it'd point to garbage and crash the game. - if (field) - CONS_Alert(CONS_WARNING,"Cannot read mobj_t stored in player variable \'%s\'. Desyncs may occur.\n", field); - else - CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); - return 3; // Don't set the field - - case ARCH_PLAYER: - LUA_PushUserdata(gL, &players[READUINT8(*p)], META_PLAYER); - break; - case ARCH_MAPTHING: - LUA_PushUserdata(gL, &mapthings[READUINT16(*p)], META_MAPTHING); - break; - case ARCH_VERTEX: - LUA_PushUserdata(gL, &vertexes[READUINT16(*p)], META_VERTEX); - break; - case ARCH_LINE: - LUA_PushUserdata(gL, &lines[READUINT16(*p)], META_LINE); - break; - case ARCH_SIDE: - LUA_PushUserdata(gL, &sides[READUINT16(*p)], META_SIDE); - break; - case ARCH_SUBSECTOR: - LUA_PushUserdata(gL, &subsectors[READUINT16(*p)], META_SUBSECTOR); - break; - case ARCH_SECTOR: - LUA_PushUserdata(gL, §ors[READUINT16(*p)], META_SECTOR); - break; - case ARCH_SLOPE: - LUA_PushUserdata(gL, P_SlopeById(READUINT16(*p)), META_SLOPE); - break; - case ARCH_MAPHEADER: - LUA_PushUserdata(gL, mapheaderinfo[READUINT16(*p)], META_MAPHEADER); - break; - case ARCH_TEND: - return 1; - } - return 0; -} - static void UnArchiveExtVars(UINT8 **p, void *pointer, boolean network) { int TABLESINDEX; @@ -1152,29 +1083,25 @@ static void UnArchiveExtVars(UINT8 **p, void *pointer, boolean network) TABLESINDEX = lua_gettop(gL); lua_createtable(gL, 0, field_count); // pointer's ext vars subtable - if (network) + for (i = 0; i < field_count; i++) { - for (i = 0; i < field_count; i++) - { - READSTRING(*p, field); + UINT8 ret; + READSTRING(*p, field); - if (UnArchiveValue(p, TABLESINDEX) == 1) - { - CONS_Alert(CONS_ERROR, "Unexpected end marker when reading ExtVars (field '%s')\n", field); - break; - } + ret = UnArchiveValue(p, TABLESINDEX, network); - lua_setfield(gL, -2, field); - } - } - else - { - for (i = 0; i < field_count; i++) + if (ret == 1) { - READSTRING(*p, field); - if (UnArchiveValueDemo(p, TABLESINDEX, field) != 3) // This will return 3 if we shouldn't set this field. - lua_setfield(gL, -2, field); + CONS_Alert(CONS_ERROR, "Unexpected end marker when reading ExtVars (field '%s')\n", field); + break; } + else if (ret == 3) // This will return 3 if we shouldn't set this field. + { + CONS_Alert(CONS_WARNING,"Cannot read mobj_t stored in player variable \'%s\'. Desyncs may occur.\n", field); + continue; + } + + lua_setfield(gL, -2, field); } lua_getfield(gL, LUA_REGISTRYINDEX, LREG_EXTVARS); @@ -1191,7 +1118,7 @@ static int NetUnArchive(lua_State *L) savebuffer_t *save = lua_touserdata(L, lua_upvalueindex(2)); int i, n = lua_gettop(L); for (i = 1; i <= n; i++) - UnArchiveValue(&save->p, TABLESINDEX); + UnArchiveValue(&save->p, TABLESINDEX, true); return n; } @@ -1221,35 +1148,29 @@ static void UnArchiveTables(UINT8 **p, boolean network) { UINT8 ret; - if (network) + ret = UnArchiveValue(p, TABLESINDEX, network); + if (ret == 3) { - if (UnArchiveValue(p, TABLESINDEX) == 1) // read key - break; - - ret = UnArchiveValue(p, TABLESINDEX); - if (ret == 1) - { - CONS_Alert(CONS_ERROR, "Unexpected end of save reached (Corrupted save?)\n"); - lua_pop(gL, 1); // Pop key - break; - } - else if (ret == 2) // read value - n++; + CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); + lua_pushnil(gL); } - else + else if (ret == 1) // read key + break; + + ret = UnArchiveValue(p, TABLESINDEX, network); + if (ret == 1) { - ret = UnArchiveValueDemo(p, TABLESINDEX, NULL); - if (ret == 3) - lua_pushnil(gL); - else if (ret == 1) // read key - break; - - ret = UnArchiveValueDemo(p, TABLESINDEX, NULL); - if (ret == 3) - lua_pushnil(gL); - else if (ret == 2) // read value - n++; + CONS_Alert(CONS_ERROR, "Unexpected end of save reached (Corrupted save?)\n"); + lua_pop(gL, 1); // Pop key + break; } + else if (ret == 3) + { + CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); + lua_pushnil(gL); + } + else if (ret == 2) // read value + n++; if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved) { diff --git a/src/m_anigif.c b/src/m_anigif.c index 44b5a96c0..05b1f8287 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -32,6 +32,7 @@ consvar_t cv_gif_downscale = {"gif_downscale", "On", CV_SAVE, CV_OnOff, NULL, 0 #ifdef HAVE_ANIGIF static boolean gif_optimize = false; // So nobody can do something dumb static boolean gif_downscale = false; // like changing cvars mid output +static RGBA_t *gif_palette = NULL; static FILE *gif_out = NULL; static INT32 gif_frames = 0; @@ -461,13 +462,15 @@ static size_t gifframe_size = 8192; // converts an RGB frame to a frame with a palette. // #ifdef HWRENDER +static colorlookup_t gif_colorlookup; + static void GIF_rgbconvert(UINT8 *linear, UINT8 *scr) { UINT8 r, g, b; size_t src, dest; int x, y; - InitColorLUT(); + InitColorLUT(&gif_colorlookup, gif_palette, true); for (x = 0; x < vid.width; x += scrbuf_downscaleamt) { @@ -479,7 +482,7 @@ static void GIF_rgbconvert(UINT8 *linear, UINT8 *scr) r = (UINT8)linear[src]; g = (UINT8)linear[src + 1]; b = (UINT8)linear[src + 2]; - scr[dest] = colorlookup[r >> SHIFTCOLORBITS][g >> SHIFTCOLORBITS][b >> SHIFTCOLORBITS]; + scr[dest] = GetColorLUTDirect(&gif_colorlookup, r, g, b); } } } @@ -636,6 +639,10 @@ INT32 GIF_open(const char *filename) gif_optimize = (!!cv_gif_optimize.value); gif_downscale = (!!cv_gif_downscale.value); + + // no master palettes in SRB2Kart land + gif_palette = pLocalPalette; + GIF_headwrite(); gif_frames = 0; return 1; diff --git a/src/m_menu.c b/src/m_menu.c index f54bb8269..cddc8c981 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -311,7 +311,7 @@ static void M_SetupMultiHandler(INT32 choice); // Split into multiple parts due to size // Controls menu_t OP_ControlsDef, OP_AllControlsDef; -menu_t OP_MouseOptionsDef, OP_Mouse2OptionsDef; +menu_t OP_MouseOptionsDef; menu_t OP_Joystick1Def, OP_Joystick2Def, OP_Joystick3Def, OP_Joystick4Def; menu_t OP_CustomCvarMenuDef; static void M_VideoModeMenu(INT32 choice); @@ -643,23 +643,23 @@ static menuitem_t MISC_ReplayOptionsMenu[] = static tic_t playback_last_menu_interaction_leveltime = 0; static menuitem_t PlaybackMenu[] = { - {IT_CALL | IT_STRING, "M_PHIDE", "Hide Menu (Esc)", M_SelectableClearMenus, 0}, + {IT_CALL | IT_STRING, "M_PHIDE", "Hide Menu (Esc)", M_SelectableClearMenus, 0}, - {IT_CALL | IT_STRING, "M_PREW", "Rewind ([)", M_PlaybackRewind, 20}, - {IT_CALL | IT_STRING, "M_PPAUSE", "Pause (\\)", M_PlaybackPause, 36}, - {IT_CALL | IT_STRING, "M_PFFWD", "Fast-Forward (])", M_PlaybackFastForward, 52}, - {IT_CALL | IT_STRING, "M_PSTEPB", "Backup Frame ([)", M_PlaybackRewind, 20}, - {IT_CALL | IT_STRING, "M_PRESUM", "Resume", M_PlaybackPause, 36}, - {IT_CALL | IT_STRING, "M_PFADV", "Advance Frame (])", M_PlaybackAdvance, 52}, + {IT_CALL | IT_STRING, "M_PREW", "Rewind ([)", M_PlaybackRewind, 20}, + {IT_CALL | IT_STRING, "M_PPAUSE", "Pause (\\)", M_PlaybackPause, 36}, + {IT_CALL | IT_STRING, "M_PFFWD", "Fast-Forward (])", M_PlaybackFastForward, 52}, + {IT_CALL | IT_STRING, "M_PSTEPB", "Backup Frame ([)", M_PlaybackRewind, 20}, + {IT_CALL | IT_STRING, "M_PRESUM", "Resume", M_PlaybackPause, 36}, + {IT_CALL | IT_STRING, "M_PFADV", "Advance Frame (])", M_PlaybackAdvance, 52}, - {IT_ARROWS | IT_STRING, "M_PVIEWS", "View Count (- and =)", M_PlaybackSetViews, 72}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint (1)", M_PlaybackAdjustView, 88}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 2 (2)", M_PlaybackAdjustView, 104}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 3 (3)", M_PlaybackAdjustView, 120}, - {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 4 (4)", M_PlaybackAdjustView, 136}, + {IT_ARROWS | IT_STRING, "M_PVIEWS", "View Count (- and =)", M_PlaybackSetViews, 72}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint (1)", M_PlaybackAdjustView, 88}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 2 (2)", M_PlaybackAdjustView, 104}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 3 (3)", M_PlaybackAdjustView, 120}, + {IT_ARROWS | IT_STRING, "M_PNVIEW", "Viewpoint 4 (4)", M_PlaybackAdjustView, 136}, {IT_CALL | IT_STRING, "M_PVIEWS", "Toggle Free Camera (')", M_PlaybackToggleFreecam, 156}, - {IT_CALL | IT_STRING, "M_PEXIT", "Stop Playback", M_PlaybackQuit, 172}, + {IT_CALL | IT_STRING, "M_PEXIT", "Stop Playback", M_PlaybackQuit, 172}, }; typedef enum { @@ -702,8 +702,8 @@ typedef enum // --------------------- static menuitem_t MPauseMenu[] = { - {IT_STRING | IT_CALL, NULL, "Addons...", M_Addons, 8}, - {IT_STRING | IT_CALL, NULL, "Add local skins...", M_LocalSkins, 16}, + {IT_STRING | IT_CALL, NULL, "Addons...", M_Addons, 8}, + {IT_STRING | IT_CALL, NULL, "Add local skins...", M_LocalSkins, 16}, {IT_STRING | IT_SUBMENU, NULL, "Scramble Teams...", &MISC_ScrambleTeamDef, 24}, {IT_STRING | IT_CALL, NULL, "Switch Map..." , M_MapChange, 32}, @@ -766,7 +766,7 @@ static menuitem_t SPauseMenu[] = // Pandora's Box will be shifted up if both options are available {IT_CALL | IT_STRING, NULL, "Pandora's Box...", M_PandorasBox, 16}, {IT_CALL | IT_STRING, NULL, "Medal Hints...", M_EmblemHints, 24}, - //{IT_CALL | IT_STRING, NULL, "Level Select...", M_LoadGameLevelSelect, 32}, + //{IT_CALL | IT_STRING, NULL, "Level Select...", M_LoadGameLevelSelect, 32}, {IT_CALL | IT_STRING, NULL, "Continue", M_SelectableClearMenus,48}, {IT_CALL | IT_STRING, NULL, "Retry", M_Retry, 56}, @@ -1034,13 +1034,13 @@ menuitem_t PlayerMenu[MAXSKINS]; static menuitem_t MP_MainMenu[] = { {IT_HEADER, NULL, "Players", NULL, 0}, - {IT_STRING|IT_CVAR, NULL, "Number of local players", &cv_splitplayers, 10}, + {IT_STRING|IT_CVAR, NULL, "Number of local players", &cv_splitplayers, 10}, - {IT_STRING|IT_KEYHANDLER,NULL, "Player setup...", M_SetupMultiHandler,18}, + {IT_STRING|IT_KEYHANDLER,NULL, "Player setup...", M_SetupMultiHandler, 18}, {IT_HEADER, NULL, "Host a game", NULL, 100-24}, #ifndef NONET - {IT_STRING|IT_CALL, NULL, "Internet/LAN...", M_PreStartServerMenu, 110-24}, + {IT_STRING|IT_CALL, NULL, "Internet/LAN...", M_PreStartServerMenu, 110-24}, #else {IT_GRAYEDOUT, NULL, "Internet/LAN...", NULL, 110-24}, #endif @@ -1049,11 +1049,11 @@ static menuitem_t MP_MainMenu[] = {IT_HEADER, NULL, "Join a game", NULL, 132-24}, #ifndef NONET #ifndef MASTERSERVER - {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, + {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, #else - {IT_STRING|IT_CALL, NULL, "Internet server browser...",M_PreConnectMenu, 142-24}, + {IT_STRING|IT_CALL, NULL, "Internet server browser...",M_PreConnectMenu, 142-24}, #endif - {IT_STRING|IT_CALL, NULL, "Join last server", M_ConnectLastServer, 150-24}, + {IT_STRING|IT_CALL, NULL, "Join last server", M_ConnectLastServer, 150-24}, {IT_STRING|IT_KEYHANDLER, NULL, "Specify IPv4 address:", M_HandleConnectIP, 158-24}, #else {IT_GRAYEDOUT, NULL, "Internet server browser...",NULL, 142-24}, @@ -1149,7 +1149,7 @@ static menuitem_t OP_MainMenu[] = {IT_SUBMENU|IT_STRING, NULL, "Saturn Options...", &OP_SaturnDef, 135}, - {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 145}, + {IT_SUBMENU|IT_STRING, NULL, "Bird...", &OP_BirdDef, 145}, {IT_CALL|IT_STRING, NULL, "Local Skin Options...", M_LocalSkinMenu, 155}, }; @@ -1158,13 +1158,13 @@ static menuitem_t OP_ControlsMenu[] = {IT_CALL | IT_STRING, NULL, "Player 1 Controls...", M_Setup1PControlsMenu, 10}, {IT_CALL | IT_STRING, NULL, "Player 2 Controls...", M_Setup2PControlsMenu, 20}, - {IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30}, - {IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40}, + {IT_CALL | IT_STRING, NULL, "Player 3 Controls...", &M_Setup3PControlsMenu, 30}, + {IT_CALL | IT_STRING, NULL, "Player 4 Controls...", &M_Setup4PControlsMenu, 40}, - {IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 60}, + {IT_SUBMENU | IT_STRING, NULL, "Mouse Options...", &OP_MouseOptionsDef, 60}, - {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 80}, - {IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 90}, + {IT_STRING | IT_CVAR, NULL, "Controls per key", &cv_controlperkey, 80}, + {IT_STRING | IT_CVAR, NULL, "Digital turn easing", &cv_turnsmooth, 90}, }; static const char* OP_ControlsTooltips[] = @@ -1182,6 +1182,7 @@ static menuitem_t OP_AllControlsMenu[] = { {IT_SUBMENU|IT_STRING, NULL, "Gamepad Options...", &OP_Joystick1Def, 0}, {IT_CALL|IT_STRING, NULL, "Reset to defaults", M_ResetControls, 8}, + //{IT_SPACE, NULL, NULL, NULL, 0}, {IT_HEADER, NULL, "Gameplay Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, @@ -1194,26 +1195,37 @@ static menuitem_t OP_AllControlsMenu[] = {IT_CONTROL, NULL, "Aim Forward", M_ChangeControl, gc_aimforward }, {IT_CONTROL, NULL, "Aim Backward", M_ChangeControl, gc_aimbackward}, {IT_CONTROL, NULL, "Look Backward", M_ChangeControl, gc_lookback }, - {IT_HEADER, NULL, "Miscelleanous Controls", NULL, 0}, + + {IT_HEADER, NULL, "Miscellaneous Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, {IT_CONTROL, NULL, "Chat", M_ChangeControl, gc_talkkey }, - //{IT_CONTROL, NULL, "Team Chat", M_ChangeControl, gc_teamkey }, + //{IT_CONTROL, NULL, "Team Chat", M_ChangeControl, gc_teamkey }, {IT_CONTROL, NULL, "Show Rankings", M_ChangeControl, gc_scores }, - {IT_CONTROL, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, - {IT_CONTROL, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, - {IT_CONTROL, NULL, "Toggle First-Person", M_ChangeControl, gc_camtoggle }, {IT_CONTROL, NULL, "Pause", M_ChangeControl, gc_pause }, {IT_CONTROL, NULL, "Screenshot", M_ChangeControl, gc_screenshot }, {IT_CONTROL, NULL, "Toggle GIF Recording", M_ChangeControl, gc_recordgif }, {IT_CONTROL, NULL, "Open/Close Menu (ESC)", M_ChangeControl, gc_systemmenu }, {IT_CONTROL, NULL, "Developer Console", M_ChangeControl, gc_console }, - {IT_HEADER, NULL, "Spectator Controls", NULL, 0}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, - {IT_CONTROL, NULL, "Become Spectator", M_ChangeControl, gc_spectate }, + {IT_CONTROL, NULL, "Toggle Freecam", M_ChangeControl, gc_freecam }, {IT_CONTROL, NULL, "Look Up", M_ChangeControl, gc_lookup }, {IT_CONTROL, NULL, "Look Down", M_ChangeControl, gc_lookdown }, {IT_CONTROL, NULL, "Center View", M_ChangeControl, gc_centerview }, + {IT_CONTROL, NULL, "Float", M_ChangeControl, gc_camfloat }, + {IT_CONTROL, NULL, "Sink", M_ChangeControl, gc_camsink }, + {IT_CONTROL, NULL, "Change Viewpoint", M_ChangeControl, gc_viewpoint }, + {IT_CONTROL, NULL, "Reset Camera", M_ChangeControl, gc_camreset }, + {IT_CONTROL, NULL, "Strafe Left", M_ChangeControl, gc_strafeleft }, + {IT_CONTROL, NULL, "Strafe Right", M_ChangeControl, gc_straferight}, + //{IT_CONTROL, NULL, "Toggle First-Person", M_ChangeControl, gc_camtoggle }, + + {IT_HEADER, NULL, "Spectator Controls", NULL, 0}, + {IT_SPACE, NULL, NULL, NULL, 0}, + {IT_CONTROL, NULL, "Become Spectator", M_ChangeControl, gc_spectate }, {IT_CONTROL, NULL, "Toggle Director", M_ChangeControl, gc_director }, + {IT_HEADER, NULL, "Custom Lua Actions", NULL, 0}, {IT_SPACE, NULL, NULL, NULL, 0}, {IT_CONTROL, NULL, "Custom Action 1", M_ChangeControl, gc_custom1 }, @@ -1223,90 +1235,126 @@ static menuitem_t OP_AllControlsMenu[] = static menuitem_t OP_Joystick1Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[0] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[0] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[0] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[0] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[0] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[0] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[0] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[0] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[0] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[0] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[0] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[0] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[0] , 80}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup1PJoystickMenu , 0}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 100}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[0] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[0] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[0] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[0] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[0] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[0] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[0] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[0] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[0] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[0] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[0] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[0] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[0] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[0] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[0] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[0] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[0] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[0] , 130}, }; static menuitem_t OP_Joystick2Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup2PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[1] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[1] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[1] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[1] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[1] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[1] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[1] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[1] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[1] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[1] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[1] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[1] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[1] , 80}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup2PJoystickMenu , 10}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 100}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[1] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[1] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[1] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[1] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[1] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[1] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[1] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[1] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[1] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[1] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[1] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[1] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[1] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[1] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[1] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[1] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[1] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[1] , 130}, }; static menuitem_t OP_Joystick3Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup3PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[2] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[2] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[2] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[2] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[2] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[2] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[2] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[2] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[2] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[2] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[2] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[2] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[2] , 80}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup3PJoystickMenu , 10}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 100}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[2] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[2] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[2] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[2] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[2] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[2] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[2] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[2] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[2] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[2] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[2] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[2] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[2] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[2] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[2] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[2] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[2] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[2] , 130}, }; static menuitem_t OP_Joystick4Menu[] = { - {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup4PJoystickMenu, 10}, - {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[3] , 20}, - {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[3] , 25}, - {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[3] , 30}, - {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[3] , 35}, - {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[3] , 40}, - {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[3] , 45}, - {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[3] , 50}, - {IT_STRING | IT_CVAR, NULL, "Spec. Look Up/Down" , &cv_lookaxis[3] , 55}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[3] , 60}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[3] , 65}, - {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[3] , 70}, - {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[3] , 75}, - {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[3] , 80}, + {IT_STRING | IT_CALL, NULL, "Select Gamepad..." , M_Setup4PJoystickMenu , 10}, - {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 90}, - {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 95}, - {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 100}, + {IT_HEADER, NULL, "Gameplay Controls", NULL, 7}, + {IT_STRING | IT_CVAR, NULL, "Aim Forward/Back" , &cv_aimaxis[3] , 15}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_turnaxis[3] , 20}, + {IT_STRING | IT_CVAR, NULL, "Accelerate" , &cv_moveaxis[3] , 25}, + {IT_STRING | IT_CVAR, NULL, "Brake" , &cv_brakeaxis[3] , 30}, + {IT_STRING | IT_CVAR, NULL, "Drift" , &cv_driftaxis[3] , 35}, + {IT_STRING | IT_CVAR, NULL, "Use Item" , &cv_fireaxis[3] , 40}, + {IT_STRING | IT_CVAR, NULL, "Look Backward" , &cv_lookbackaxis[3] , 45}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 1" , &cv_custom1axis[3] , 50}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 2" , &cv_custom2axis[3] , 55}, + {IT_STRING | IT_CVAR, NULL, "Custom Button 3" , &cv_custom3axis[3] , 60}, + + {IT_HEADER, NULL, "Camera Controls", NULL, 67}, + {IT_STRING | IT_CVAR, NULL, "Look Up/Down" , &cv_lookaxis[3] , 75}, + {IT_STRING | IT_CVAR, NULL, "Turn Left/Right" , &cv_camturnaxis[3] , 80}, + {IT_STRING | IT_CVAR, NULL, "Strafe Left/Right" , &cv_camstrafeaxis[3] , 85}, + + {IT_HEADER, NULL, "Deadzones", NULL, 92}, + {IT_STRING | IT_CVAR, NULL, "X deadzone" , &cv_xdeadzone[3] , 100}, + {IT_STRING | IT_CVAR, NULL, "Y deadzone" , &cv_ydeadzone[3] , 105}, + + {IT_HEADER, NULL, "Miscellaneous", NULL, 112}, + {IT_STRING | IT_CVAR, NULL, "Controller Rumble" , &cv_rumble[3] , 120}, + {IT_STRING | IT_CVAR, NULL, "Set LED to skin color" , &cv_gamepadled[3] , 125}, + {IT_STRING | IT_CVAR, NULL, "Flash LED on powerups" , &cv_ledpowerup[3] , 130}, }; static menuitem_t OP_JoystickSetMenu[] = @@ -1326,15 +1374,12 @@ static menuitem_t OP_MouseOptionsMenu[] = { {IT_STRING | IT_CVAR, NULL, "Use Mouse", &cv_usemouse, 10}, - - //{IT_STRING | IT_CVAR, NULL, "First-Person MouseLook", &cv_alwaysfreelook, 30}, - //{IT_STRING | IT_CVAR, NULL, "Third-Person MouseLook", &cv_chasefreelook, 40}, - {IT_STRING | IT_CVAR, NULL, "Mouse Turning", &cv_mouseturn, 20}, + {IT_STRING | IT_CVAR, NULL, "Mouse Turning", &cv_mouseturn, 20}, {IT_STRING | IT_CVAR, NULL, "Invert Mouse", &cv_invertmouse, 30}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Mouse X Speed", &cv_mousesens, 40}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Mouse Y Speed", &cv_mouseysens, 50}, + NULL, "Mouse Y Speed", &cv_mouseysens, 50}, }; static const char* OP_MouseTooltips[] = @@ -1346,21 +1391,6 @@ static const char* OP_MouseTooltips[] = "Mouse vertical sensitivity.", }; -/*static menuitem_t OP_Mouse2OptionsMenu[] = -{ - {IT_STRING | IT_CVAR, NULL, "Use Mouse 2", &cv_usemouse2, 10}, - {IT_STRING | IT_CVAR, NULL, "Second Mouse Serial Port", - &cv_mouse2port, 20}, - {IT_STRING | IT_CVAR, NULL, "First-Person MouseLook", &cv_alwaysfreelook2, 30}, - {IT_STRING | IT_CVAR, NULL, "Third-Person MouseLook", &cv_chasefreelook2, 40}, - {IT_STRING | IT_CVAR, NULL, "Mouse Move", &cv_mousemove2, 50}, - {IT_STRING | IT_CVAR, NULL, "Invert Mouse", &cv_invertmouse2, 60}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Mouse X Speed", &cv_mousesens2, 70}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, - NULL, "Mouse Y Speed", &cv_mouseysens2, 80}, -};*/ - static menuitem_t OP_VideoOptionsMenu[] = { {IT_STRING | IT_CALL, NULL, "Set Resolution...", M_VideoModeMenu, 10}, @@ -1740,37 +1770,40 @@ static menuitem_t OP_DataOptionsMenu[] = static menuitem_t OP_ScreenshotOptionsMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Storage Location", &cv_screenshot_option, 10}, - {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Custom Folder", &cv_screenshot_folder, 20}, + {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_HEADER, NULL, "Screenshots (F8)", NULL, 50}, - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memory, 60}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_level, 70}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategy, 80}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bits, 90}, + {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, 105}, - {IT_STRING|IT_CVAR, NULL, "Capture Mode", &cv_moviemode, 115}, + {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, 125}, - {IT_STRING|IT_CVAR, NULL, "Downscaling", &cv_gif_downscale, 135}, - - {IT_STRING|IT_CVAR, NULL, "Memory Level", &cv_zlib_memorya, 125}, - {IT_STRING|IT_CVAR, NULL, "Compression Level", &cv_zlib_levela, 135}, - {IT_STRING|IT_CVAR, NULL, "Strategy", &cv_zlib_strategya, 145}, - {IT_STRING|IT_CVAR, NULL, "Window Size", &cv_zlib_window_bitsa, 155}, + {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}, }; enum { - op_screenshot_folder = 1, - op_screenshot_capture = 8, - op_screenshot_gif_start = 9, - op_screenshot_gif_end = 10, - op_screenshot_apng_start = 11, - op_screenshot_apng_end = 14, + op_screenshot_folder = 2, + op_movie_folder = 9, + op_screenshot_capture = 10, + op_screenshot_gif_start = 11, + op_screenshot_gif_end = 12, + op_screenshot_apng_start = 13, + op_screenshot_apng_end = 16, }; + static menuitem_t OP_EraseDataMenu[] = { {IT_STRING | IT_CALL, NULL, "Erase Record Data", M_EraseData, 10}, @@ -1852,11 +1885,12 @@ static menuitem_t OP_CamOptionsMenu[] = {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, 80}, - {IT_STRING | IT_SUBMENU, NULL, "Player 2 Camera options...", &OP_Player2CamOptionsDef, 90}, - {IT_STRING | IT_SUBMENU, NULL, "Player 3 Camera options...", &OP_Player3CamOptionsDef, 100}, - {IT_STRING | IT_SUBMENU, NULL, "Player 4 Camera options...", &OP_Player4CamOptionsDef, 110}, + {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}, }; static const char* OP_CamOptionsTooltips[] = @@ -1865,6 +1899,7 @@ static const char* OP_CamOptionsTooltips[] = "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, @@ -1875,52 +1910,56 @@ static menuitem_t OP_Player1CamOptionsMenu[] = { {IT_HEADER, NULL, "Player 1 Camera Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[0], 30}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[0], 40}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[0], 50}, - {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[0], 60}, - {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam_rotspeed[0], 70}, + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[0], 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[0], 50}, + {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, "Third Person Camera", &cv_chasecam[0], 85}, + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[0], 90}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[0], 105}, }; static menuitem_t OP_Player2CamOptionsMenu[] = { {IT_HEADER, NULL, "Player 2 Camera Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[1], 30}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[1], 40}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[1], 50}, - {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[1], 60}, - {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam_rotspeed[1], 70}, + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[1], 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[1], 50}, + {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, "Third Person Camera", &cv_chasecam[1], 85}, + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[1], 90}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[1], 105}, }; static menuitem_t OP_Player3CamOptionsMenu[] = { {IT_HEADER, NULL, "Player 3 Camera Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[2], 30}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[2], 40}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[2], 50}, - {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[2], 60}, - {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam_rotspeed[2], 70}, + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[2], 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[2], 50}, + {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, "Third Person Camera", &cv_chasecam[2], 85}, + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[2], 90}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[2], 105}, }; static menuitem_t OP_Player4CamOptionsMenu[] = { {IT_HEADER, NULL, "Player 4 Camera Options", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[3], 30}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[3], 40}, - {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Height", &cv_cam_height[3], 50}, - {IT_STRING | IT_CVAR, NULL, "Camera Speed", &cv_cam_speed[3], 60}, - {IT_STRING | IT_CVAR, NULL, "Camera Rotation Speed", &cv_cam_rotspeed[3], 70}, + {IT_STRING | IT_CVAR, NULL, "Flipcam", &cv_flipcam[3], 30}, + {IT_STRING | IT_CVAR | IT_CV_BIGFLOAT, NULL, "Camera Distance", &cv_cam_dist[3], 50}, + {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, "Third Person Camera", &cv_chasecam[3], 85}, + {IT_STRING | IT_CVAR, NULL, "Freecam Speed", &cv_freecam_speed[3], 90}, + + {IT_STRING | IT_CVAR, NULL, "Third Person Camera", &cv_chasecam[3], 105}, }; static const char* OP_PlayerCamOptionsTooltips[] = @@ -1930,7 +1969,7 @@ static const char* OP_PlayerCamOptionsTooltips[] = "Camera distance relative to the Player.", "Height of the Camera", "Speed of the Camera", - "Speed of the Camera rotation", + "Speed of the Freecam/Spectator Camera", "Toggle between Third or First Person camera", }; @@ -2183,16 +2222,21 @@ static menuitem_t OP_SaturnMenu[] = {IT_STRING | IT_CVAR, NULL, "Skin Select Spinning Speed", &cv_skinselectspin, 20}, - {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 30}, - {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 35}, + {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, "Keyboard Layout", &cv_keyboardlayout, 45}, + {IT_STRING | IT_CVAR, NULL, "Bananadrag Jitter", &cv_bananajitter, 45}, - {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 55}, + {IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 55}, + {IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 65}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Hud...", &OP_SaturnHudDef, 65}, - {IT_SUBMENU|IT_STRING, NULL, "Sprite Distortion...", &OP_PlayerDistortDef, 70}, - {IT_SUBMENU|IT_STRING, NULL, "Saturn Credits", &OP_SaturnCreditsDef, 80}, // uwu + {IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 70}, + + {IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 80}, + + {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 }; static const char* OP_SaturnTooltips[] = @@ -2200,6 +2244,9 @@ static const char* OP_SaturnTooltips[] = NULL, "How long can the game wait before it kicks you out from the server\nconnecting screen.", "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!", + "Makes bananas and other items jump and jitter\nwhen dragged behind.", "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!", @@ -2214,6 +2261,9 @@ enum sm_header, sm_waittime, sm_skinselspeed, + sm_colorlines, + sm_colorflames, + sm_bananjumpy, sm_showlocalskin, op_uppercase_menu, sm_nativkey, @@ -2229,13 +2279,16 @@ static menuitem_t OP_PlayerDistortMenu[] = {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, "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, "Player Stretch Factor", &cv_gravstretch, 75}, - {IT_STRING | IT_CVAR, NULL, "Squish Sound Effect", &cv_slamsound, 90}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop", &cv_saltyhop, 105}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Sound Effect", &cv_saltyhopsfx, 120}, - {IT_STRING | IT_CVAR, NULL, "Saltyhop Squish", &cv_saltysquish, 135}, + {IT_STRING | IT_CVAR, NULL, "Rotate Bananas on Throw", &cv_bananthrowroll, 75}, + + {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}, }; static const char* OP_PlayerDistortTooltips[] = @@ -2245,6 +2298,7 @@ static const char* OP_PlayerDistortTooltips[] = "Distance object rotation should be visable.", "Player rotation when sliptiding.", "Rotation of a player's boost trails and drift sparks.", + "Should banans rotate when thrown?\nAnd should they stay rotated when on the ground?.", "Player squash and stretch.", "Player landing sound effect.", "Kart hopping while drifting. This is purely visual.", @@ -2259,6 +2313,7 @@ enum slrotatedist, sliptide, sparkrotate, + bananrotat, stretchyplayer, squishsound, salthmmm, @@ -2273,34 +2328,40 @@ static menuitem_t OP_SaturnHudMenu[] = {IT_STRING | IT_CVAR, NULL, "Speedometer Style", &cv_newspeedometer, 10}, {IT_STRING | IT_CVAR, NULL, "Battle Speedometer", &cv_battlespeedo, 15}, - {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 20}, + {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 25}, + {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, "Flash Lap Times", &cv_showlaptimes, 25}, + {IT_STRING | IT_CVAR, NULL, "Input Display outside of RA", &cv_showinput, 45}, - {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 30}, + {IT_STRING | IT_CVAR, NULL, "Stat Display", &cv_showstats, 55}, - {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 35}, + {IT_STRING | IT_CVAR, NULL, "Higher Resolution Portraits", &cv_highresportrait, 65}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD", &cv_colorizedhud, 40}, - {IT_STRING | IT_CVAR, NULL, "Colourized Itembox", &cv_colorizeditembox, 45}, - {IT_STRING | IT_CVAR, NULL, "Colourized HUD Color", &cv_colorizedhudcolor, 50}, + {IT_STRING | IT_CVAR, NULL, "Small Positionnumber", &cv_smallposnum, 75}, + {IT_STRING | IT_CVAR, NULL, "Positionnumber Animation", &cv_posanim, 80}, - {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 60}, - {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 65}, + {IT_STRING | IT_CVAR, NULL, "Flash Lap Times", &cv_showlaptimes, 90}, - {IT_STRING | IT_CVAR, NULL, "Show Names on Minimap", &cv_showminimapnames, 70}, - {IT_STRING | IT_CVAR, NULL, "Small Minimap Players", &cv_minihead, 75}, + {IT_STRING | IT_CVAR, NULL, "Multi-Item icons", &cv_multiitemicon, 100}, + {IT_STRING | IT_CVAR, NULL, "Item Amount Number", &cv_huditemamount, 105}, + {IT_STRING | IT_CVAR, NULL, "Animated Roulette", &cv_fancyroulette, 110}, - {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 80}, + {IT_STRING | IT_CVAR, NULL, "Show Lap Emblem", &cv_showlapemblem, 120}, + {IT_STRING | IT_CVAR, NULL, "Show Cecho Messages", &cv_cechotoggle, 125}, - {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 90}, + {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, "Uncapped HUD", &cv_uncappedhud, 100}, + {IT_STRING | IT_CVAR, NULL, "Beta Intermissionscreen", &cv_betainterscreen, 160}, - {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 110}, - {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 115}, + {IT_STRING | IT_CVAR, NULL, "Show Director Prompt", &cv_showdirectorhud, 170}, - {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 125}, + {IT_STRING | IT_SUBMENU, NULL, "Nametags...", &OP_NametagDef, 180}, + {IT_STRING | IT_SUBMENU, NULL, "Driftgauge...", &OP_DriftGaugeDef, 185}, + + {IT_SUBMENU|IT_STRING, NULL, "Hud Offsets...", &OP_HudOffsetDef, 195}, }; static const char* OP_SaturnHudTooltips[] = @@ -2308,20 +2369,25 @@ static const char* OP_SaturnHudTooltips[] = NULL, "Change what style the speedometer is.", "Draw the Speedometer in Battle.", - "Displays the input display outside of Record Attack. Also adjusts the\nposition scale to match.", - "Flash current Lap Time when doing a Lap on the Timer.", - "Enable the stat display.", - "Enable the use of the higher resolution want icons instead of rank\nfor some places.", "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.", + "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.", + "Disable the animation of the Positionnumber\nwhen overtaking someone.", + "Flash current Lap Time when doing a Lap on the Timer.", + "Use extra graphics for multiple sneakers, bananas and jawz.", + "Change when the item amount is to be displayed\nMultiple will always display the number.\nwhen you have multiple of the same Item.\nAlways will always display the number regardless of Item amount.", + "Enables an animation while the roulette is active.", "Show the big 'LAP' text on a lap change.", "Show the big Cecho Messages.", "Show player names on the minimap.", "Minimize the player icons on the minimap.", - "Show the Director Toggle prompt when spectating.", + "Erratically rotate player icons during spinouts.", "Make the Intermission screen look like in beta versions of Kart!\nEither with background or just the rest.", - "Uncaps the HUD framerate, making it appear smoother.", + "Show the Director Toggle prompt when spectating.", "Nametag Options.", "Driftgauge Options.", "Move position of HUD elements.", @@ -2332,20 +2398,25 @@ enum sh_header, sh_speedometer, sh_battlespeedo, - sh_input, - sh_laptime, - sh_statdisplay, - sh_highresport, sh_colorhud, sh_coloritem, sh_colorhud_customcolor, + sh_input, + sh_statdisplay, + sh_highresport, + sh_smolpos, + sh_posanim, + sh_multicon, + sh_itamnum, + sh_laptime, + sh_fancy, sh_lapemblem, sh_cechotogle, sh_mapname, sh_smallmap, - sh_directorhud, + sh_iconspinout, sh_betainter, - sh_uncappedhud, + sh_directorhud, sh_nametagmen, sh_driftgaugemen, sh_hudoffsets, @@ -2381,13 +2452,17 @@ static menuitem_t OP_HudOffsetMenu[] = {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_mini_xoffset, 120}, {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_mini_yoffset, 125}, - {IT_HEADER, NULL, "Position / R.A. Wheel", NULL, 135}, + {IT_HEADER, NULL, "Position Number", NULL, 135}, {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_posi_xoffset, 140}, {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_posi_yoffset, 145}, - {IT_HEADER, NULL, "Stat Display", NULL, 155}, - {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_stat_xoffset, 160}, - {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_stat_yoffset, 165}, + {IT_HEADER, NULL, "R.A. Wheel", NULL, 155}, + {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_wheel_xoffset, 160}, + {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_wheel_yoffset, 165}, + + {IT_HEADER, NULL, "Stat Display", NULL, 175}, + {IT_STRING | IT_CVAR, NULL, "Horizontal Offset", &cv_stat_xoffset, 180}, + {IT_STRING | IT_CVAR, NULL, "Vertical Offset", &cv_stat_yoffset, 185}, }; static menuitem_t OP_SaturnCreditsMenu[] = @@ -2503,10 +2578,8 @@ static menuitem_t OP_NametagMenu[] = {IT_STRING | IT_CVAR, NULL, "Nametag Transparency", &cv_nametagtrans, 70}, {IT_STRING | IT_CVAR, NULL, "Nametag Score", &cv_nametagscore, 80}, {IT_STRING | IT_CVAR, NULL, "Nametag Restat", &cv_nametagrestat, 90}, - {IT_STRING | IT_CVAR, NULL, "Nametag Hop", &cv_nametaghop, 100}, - {IT_STRING | IT_CVAR, NULL, "Small Nametags", &cv_smallnametags, 110}, - {IT_STRING | IT_CVAR, NULL, "Show Nametags after Race finish", &cv_shownametagfinish, 120}, - {IT_STRING | IT_CVAR, NULL, "Show Nametags in Spectator Mode", &cv_shownametagspectator, 130}, + {IT_STRING | IT_CVAR, NULL, "Small Nametags", &cv_smallnametags, 100}, + {IT_STRING | IT_CVAR, NULL, "Show Nametags while Spectating", &cv_shownametagspectator, 110}, //{IT_STRING | IT_CVAR, NULL, "Nametag Scaling", &cv_nametagscaling, 70} }; @@ -2521,9 +2594,7 @@ static const char* OP_NametagTooltips[] = "Transparency of nametags.", "Show player score in nametag.", "Show stats in nametags.", - "Enable Saltyhop support for nametags.", "Alternative smaller nametags.", - "Show Nametags after Race finish.", "Show Nametags when you are spectating.", }; @@ -2538,13 +2609,10 @@ enum nt_nttrans, nt_ntpscore, nt_ntrestat, - nt_nthop, nt_smol, - nt_finish, nt_spec, }; - static menuitem_t OP_DriftGaugeMenu[] = { {IT_HEADER, NULL, "Driftgauge", NULL, 0}, @@ -3395,21 +3463,16 @@ void Addons_option_Onchange(void) (cv_addons_option.value == 3 ? IT_CVAR|IT_STRING|IT_CV_STRING : IT_DISABLED); } +void Moviemode_option_Onchange(void) +{ + OP_ScreenshotOptionsMenu[op_movie_folder].status = + (cv_movie_option.value == 3 ? IT_CVAR|IT_STRING|IT_CV_STRING : IT_DISABLED); +} + void PDistort_menu_Onchange(void) { - if (!cv_sloperoll.value) - { - OP_PlayerDistortMenu[sliptide].status = IT_GRAYEDOUT; - } - else - { - OP_PlayerDistortMenu[sliptide].status = IT_STRING | IT_CVAR; - } - - if (cv_sloperoll.value) //enable/disable sloperotate distance - OP_PlayerDistortMenu[slrotatedist].status = IT_STRING | IT_CVAR; - else - OP_PlayerDistortMenu[slrotatedist].status = IT_GRAYEDOUT; + OP_PlayerDistortMenu[slrotatedist].status = + (cv_sloperoll.value) ? IT_STRING | IT_CVAR : IT_GRAYEDOUT; } void Bird_menu_Onchange(void) @@ -3941,7 +4004,7 @@ boolean M_Responder(event_t *ev) else { // dirty hack: for customising controls, I want only buttons/keys, not moves - if (ev->type == ev_mouse || ev->type == ev_mouse2 || ev->type == ev_joystick + if (ev->type == ev_mouse || ev->type == ev_joystick || ev->type == ev_joystick2 || ev->type == ev_joystick3 || ev->type == ev_joystick4) return true; if (routine) @@ -4012,19 +4075,19 @@ boolean M_Responder(event_t *ev) // switch viewpoints: case '1': // viewpoint for p1 (also f12) // maximum laziness: - if (!demo.freecam) + if (!camera[0].freecam) G_AdjustView(1, 1, true); break; case '2': // viewpoint for p2 - if (!demo.freecam) + if (!camera[1].freecam) G_AdjustView(2, 1, true); break; case '3': // viewpoint for p3 - if (!demo.freecam) + if (!camera[2].freecam) G_AdjustView(3, 1, true); break; case '4': // viewpoint for p4 - if (!demo.freecam) + if (!camera[3].freecam) G_AdjustView(4, 1, true); break; @@ -4251,19 +4314,19 @@ boolean M_DemoResponder(event_t *ev) // switch viewpoints: case '1': // viewpoint for p1 (also f12) // maximum laziness: - if (!demo.freecam) + if (!camera[0].freecam) G_AdjustView(1, 1, true); break; case '2': // viewpoint for p2 - if (!demo.freecam) + if (!camera[1].freecam) G_AdjustView(2, 1, true); break; case '3': // viewpoint for p3 - if (!demo.freecam) + if (!camera[2].freecam) G_AdjustView(3, 1, true); break; case '4': // viewpoint for p4 - if (!demo.freecam) + if (!camera[3].freecam) G_AdjustView(4, 1, true); break; @@ -4770,13 +4833,13 @@ void M_Init(void) } #endif - if (!xtra_speedo && !kartzspeedo && !achi_speedo) // why bother? + if (!xtra_speedo && !kartz_speedo && !achi_speedo) // why bother? OP_SaturnHudMenu[sh_speedometer].status = IT_GRAYEDOUT; - //if (!xtra_speedo && kartzspeedo) + //if (!xtra_speedo && kartz_speedo) //OP_SaturnMenu[sm_speedometer].text = "Speedometer (No Small)"; - //if (xtra_speedo && !kartzspeedo) + //if (xtra_speedo && !kartz_speedo) //OP_SaturnMenu[sm_speedometer].text = "Speedometer (No PMeter)"; // idk i dont wanna bother with this tbh lmao @@ -4909,53 +4972,60 @@ static void M_DrawSlider(INT32 x, INT32 y, const consvar_t *cv, boolean ontop) INT32 range; patch_t *p; - for (i = 0; cv->PossibleValue[i+1].strvalue; i++); - x = BASEVIDWIDTH - x - SLIDER_WIDTH; - if (ontop) - { - V_DrawCharacter(x - 16 - (skullAnimCounter/5), y, - '\x1C' | highlightflags, false); // left arrow - V_DrawCharacter(x+(SLIDER_RANGE*8) + 8 + (skullAnimCounter/5), y, - '\x1D' | highlightflags, false); // right arrow - } - - if ((range = atoi(cv->defaultvalue)) != cv->value) - { - range = ((range - cv->PossibleValue[0].value) * 100 / - (cv->PossibleValue[1].value - cv->PossibleValue[0].value)); - - if (range < 0) - range = 0; - if (range > 100) - range = 100; - - // draw the default - p = W_CachePatchName("M_SLIDEC", PU_CACHE); - V_DrawScaledPatch(x - 4 + (((SLIDER_RANGE)*8 + 4)*range)/100, y, 0, p); - } - - V_DrawScaledPatch(x - 8, y, 0, W_CachePatchName("M_SLIDEL", PU_CACHE)); + p = W_CachePatchName("M_SLIDEL", PU_CACHE); + V_DrawScaledPatch(x - 8, y, 0, p); p = W_CachePatchName("M_SLIDEM", PU_CACHE); for (i = 0; i < SLIDER_RANGE; i++) V_DrawScaledPatch (x+i*8, y, 0,p); p = W_CachePatchName("M_SLIDER", PU_CACHE); - V_DrawScaledPatch(x+SLIDER_RANGE*8, y, 0, p); - - range = ((cv->value - cv->PossibleValue[0].value) * 100 / - (cv->PossibleValue[1].value - cv->PossibleValue[0].value)); - - if (range < 0) - range = 0; - if (range > 100) - range = 100; + V_DrawScaledPatch(x+i*8, y, 0, p); // draw the slider cursor p = W_CachePatchName("M_SLIDEC", PU_CACHE); - V_DrawScaledPatch(x - 4 + (((SLIDER_RANGE)*8 + 4)*range)/100, y, 0, p); + + for (i = 0; cv->PossibleValue[i+1].strvalue; i++); + + if (cv->flags & CV_FLOAT) + range = (INT32)(atof(cv->defaultvalue)*FRACUNIT); + else + range = atoi(cv->defaultvalue); + + if (range != cv->value) + { + range = ((range - cv->PossibleValue[0].value) * 100 / + (cv->PossibleValue[i].value - cv->PossibleValue[0].value)); + + if (range < 0) + range = 0; + else if (range > 100) + range = 100; + + V_DrawMappedPatch(x - 4 + (((SLIDER_RANGE)*8 + 4)*range)/100, y, 0, p, yellowmap); + } + + range = ((cv->value - cv->PossibleValue[0].value) * 100 / + (cv->PossibleValue[i].value - cv->PossibleValue[0].value)); + + if (range < 0) + range = 0; + else if (range > 100) + range = 100; + + V_DrawMappedPatch(x - 4 + (((SLIDER_RANGE)*8 + 4)*range)/100, y, 0, p, yellowmap); + + if (ontop) + { + V_DrawCharacter(x - 16 - (skullAnimCounter/5), y, + '\x1C' | highlightflags, false); + V_DrawCharacter(x+(SLIDER_RANGE*8) + 8 + (skullAnimCounter/5), y, + '\x1D' | highlightflags, false); + V_DrawCenteredString(x + ((SLIDER_RANGE*8) + 8)/2, y, V_30TRANS, + (cv->flags & CV_FLOAT) ? va("%.2f", FIXED_TO_FLOAT(cv->value)) : va("%d", cv->value)); + } } // @@ -6146,8 +6216,6 @@ static void M_AddonsClearName(INT32 choice) M_StopMessage(choice); } -int errorshitspam = 0; // prevent the warning screen from crapping itself when errors get spammed lmao - // returns whether to do message draw static boolean M_AddonsRefresh(void) { @@ -6176,11 +6244,10 @@ static boolean M_AddonsRefresh(void) else message = va("%c%s\x80\nA file was not loaded.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname); } - else if ((refreshdirmenu & (REFRESHDIR_WARNING | REFRESHDIR_ERROR)) && !errorshitspam) + else if (refreshdirmenu & (REFRESHDIR_WARNING | REFRESHDIR_ERROR)) { S_StartSound(NULL, sfx_s224); message = va("%c%s\x80\nA file was loaded with %s.\nCheck the console log for more information.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), refreshdirname, ((refreshdirmenu & REFRESHDIR_ERROR) ? "errors" : "warnings")); - errorshitspam = 1; // you already said that shit } else if (majormods && !prevmajormods) { @@ -6532,7 +6599,6 @@ static void M_HandleAddons(INT32 choice) if (DumbStartsWith("KC_", dirmenu[dir_on[menudepthleft]]+DIR_STRING) || DumbStartsWith("kc_", dirmenu[dir_on[menudepthleft]]+DIR_STRING)) { M_StartMessage(va("%c%s\x80\nYou are loading a local skin.\nLocal skins will not be usable\nafter going back from\nthe title screen.\n\n(Press a key)\n", ('\x80' + (highlightflags>>V_CHARCOLORSHIFT)), dirmenu[dir_on[menudepthleft]]+DIR_STRING),NULL,MM_NOTHING); COM_BufAddText(va("addskins \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); - errorshitspam = 0; // reset it so it can show the warning screen again lmao } else S_StartSound(NULL, sfx_s26d); @@ -6540,7 +6606,6 @@ static void M_HandleAddons(INT32 choice) else { COM_BufAddText(va("addfile \"%s%s\"", menupath, dirmenu[dir_on[menudepthleft]]+DIR_STRING)); - errorshitspam = 0; // reset it so it can show the warning screen again lmao } break; default: @@ -7646,8 +7711,7 @@ static void M_PlaybackAdvance(INT32 choice) static void M_PlaybackSetViews(INT32 choice) { - - if (demo.freecam) + if (camera[0].freecam || camera[1].freecam || camera[2].freecam || camera[3].freecam) return; // not here. if (choice > 0) @@ -7677,19 +7741,10 @@ static void M_PlaybackToggleFreecam(INT32 choice) splitscreen = 0; R_ExecuteSetViewSize(); - P_InitCameraCmd(); // init camera controls - if (!demo.freecam) // toggle on + UINT8 i; + for (i = 0; i <= splitscreen; ++i) { - demo.freecam = true; - democam.cam = &camera[0]; // this is rather useful - } - else // toggle off - { - demo.freecam = false; - // reset democam vars: - democam.cam = NULL; - democam.turnheld = false; - democam.keyboardlook = false; // reset only these. localangle / aiming gets set before the cam does anything anyway + P_ToggleDemoCamera(i); } } @@ -10429,8 +10484,9 @@ static void M_HandleConnectIP(INT32 choice) default: // Rudimentary number and period enforcing - also allows letters so hostnames can be used instead - if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z') - || (choice >= 199 && choice <= 211 && choice != 202 && choice != 206)) //numpad too! + // ctrl-v allows to bypass that anyway, so we just remove that for now to allow stuff like shift+insert + /*if ((choice >= '-' && choice <= ':') || (choice >= 'A' && choice <= 'Z') || (choice >= 'a' && choice <= 'z') + || (choice >= 199 && choice <= 211 && choice != 202 && choice != 206))*/ //numpad too! { if (M_TextInputHandle(&setupm_input_ip, choice)) S_StartSound(NULL,sfx_menu1); // Tails @@ -12058,12 +12114,12 @@ static void M_Setup1PControlsMenu(INT32 choice) // Unhide P1-only controls OP_AllControlsMenu[15].status = IT_CONTROL; // Chat OP_AllControlsMenu[16].status = IT_CONTROL; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_CONTROL; // Pause - OP_AllControlsMenu[21].status = IT_CONTROL; // Screenshot - OP_AllControlsMenu[22].status = IT_CONTROL; // GIF - OP_AllControlsMenu[23].status = IT_CONTROL; // System Menu - OP_AllControlsMenu[24].status = IT_CONTROL; // Console + OP_AllControlsMenu[17].status = IT_CONTROL; // Pause + OP_AllControlsMenu[18].status = IT_CONTROL; // Screenshot + OP_AllControlsMenu[19].status = IT_CONTROL; // GIF + OP_AllControlsMenu[20].status = IT_CONTROL; // System Menu + OP_AllControlsMenu[21].status = IT_CONTROL; // Console + OP_AllControlsMenu[37].status = IT_CONTROL; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12081,12 +12137,12 @@ static void M_Setup2PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause - OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot - OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF - OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu - OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Pause + OP_AllControlsMenu[18].status = IT_GRAYEDOUT2; // Screenshot + OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF + OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu + OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[37].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12104,12 +12160,12 @@ static void M_Setup3PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause - OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot - OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF - OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu - OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Pause + OP_AllControlsMenu[18].status = IT_GRAYEDOUT2; // Screenshot + OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF + OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu + OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[37].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12127,12 +12183,12 @@ static void M_Setup4PControlsMenu(INT32 choice) // Hide P1-only controls OP_AllControlsMenu[15].status = IT_GRAYEDOUT2; // Chat OP_AllControlsMenu[16].status = IT_GRAYEDOUT2; // Rankings - // 18 is Reset Camera, 19 is Toggle Chasecam - OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // Pause - OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Screenshot - OP_AllControlsMenu[22].status = IT_GRAYEDOUT2; // GIF - OP_AllControlsMenu[23].status = IT_GRAYEDOUT2; // System Menu - OP_AllControlsMenu[24].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[17].status = IT_GRAYEDOUT2; // Pause + OP_AllControlsMenu[18].status = IT_GRAYEDOUT2; // Screenshot + OP_AllControlsMenu[19].status = IT_GRAYEDOUT2; // GIF + OP_AllControlsMenu[20].status = IT_GRAYEDOUT2; // System Menu + OP_AllControlsMenu[21].status = IT_GRAYEDOUT2; // Console + OP_AllControlsMenu[37].status = IT_GRAYEDOUT2; // Director M_SetupNextMenu(&OP_AllControlsDef); } @@ -12257,7 +12313,6 @@ static void M_ChangecontrolResponse(event_t *ev) { // ignore mouse/joy movements, just get buttons case ev_mouse: - case ev_mouse2: case ev_joystick: case ev_joystick2: case ev_joystick3: @@ -12290,8 +12345,6 @@ static void M_ChangecontrolResponse(event_t *ev) setupcontrols[control][found] = ch-KEY_MOUSE1+KEY_DBLMOUSE1; else if (ch >= KEY_JOY1 && ch <= KEY_JOY1+JOYBUTTONS) setupcontrols[control][found] = ch-KEY_JOY1+KEY_DBLJOY1; - else if (ch >= KEY_2MOUSE1 && ch <= KEY_2MOUSE1+MOUSEBUTTONS) - setupcontrols[control][found] = ch-KEY_2MOUSE1+KEY_DBL2MOUSE1; else if (ch >= KEY_2JOY1 && ch <= KEY_2JOY1+JOYBUTTONS) setupcontrols[control][found] = ch-KEY_2JOY1+KEY_DBL2JOY1; else if (ch >= KEY_3JOY1 && ch <= KEY_3JOY1+JOYBUTTONS) @@ -12388,55 +12441,26 @@ static void M_ResetControlsResponse(INT32 ch) G_Controldefault(setupcontrolplayer); // Setup gamepad option defaults (yucky) - switch (setupcontrolplayer) + for (UINT8 j = 0; j < MAXSPLITSCREENPLAYERS; j++) { - case 4: - CV_StealthSet(&cv_usejoystick[3], cv_usejoystick[3].defaultvalue); - CV_StealthSet(&cv_turnaxis[3], cv_turnaxis[3].defaultvalue); - CV_StealthSet(&cv_moveaxis[3], cv_moveaxis[3].defaultvalue); - CV_StealthSet(&cv_brakeaxis[3], cv_brakeaxis[3].defaultvalue); - CV_StealthSet(&cv_aimaxis[3], cv_aimaxis[3].defaultvalue); - CV_StealthSet(&cv_lookaxis[3], cv_lookaxis[3].defaultvalue); - CV_StealthSet(&cv_fireaxis[3], cv_fireaxis[3].defaultvalue); - CV_StealthSet(&cv_driftaxis[3], cv_driftaxis[3].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[3], cv_lookbackaxis[3].defaultvalue); - break; - case 3: - CV_StealthSet(&cv_usejoystick[2], cv_usejoystick[2].defaultvalue); - CV_StealthSet(&cv_turnaxis[2], cv_turnaxis[2].defaultvalue); - CV_StealthSet(&cv_moveaxis[2], cv_moveaxis[2].defaultvalue); - CV_StealthSet(&cv_brakeaxis[2], cv_brakeaxis[2].defaultvalue); - CV_StealthSet(&cv_aimaxis[2], cv_aimaxis[2].defaultvalue); - CV_StealthSet(&cv_lookaxis[2], cv_lookaxis[2].defaultvalue); - CV_StealthSet(&cv_fireaxis[2], cv_fireaxis[2].defaultvalue); - CV_StealthSet(&cv_driftaxis[2], cv_driftaxis[2].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[2], cv_lookbackaxis[2].defaultvalue); - break; - case 2: - CV_StealthSet(&cv_usejoystick[1], cv_usejoystick[1].defaultvalue); - CV_StealthSet(&cv_turnaxis[1], cv_turnaxis[1].defaultvalue); - CV_StealthSet(&cv_moveaxis[1], cv_moveaxis[1].defaultvalue); - CV_StealthSet(&cv_brakeaxis[1], cv_brakeaxis[1].defaultvalue); - CV_StealthSet(&cv_aimaxis[1], cv_aimaxis[1].defaultvalue); - CV_StealthSet(&cv_lookaxis[1], cv_lookaxis[1].defaultvalue); - CV_StealthSet(&cv_fireaxis[1], cv_fireaxis[1].defaultvalue); - CV_StealthSet(&cv_driftaxis[1], cv_driftaxis[1].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[1], cv_lookbackaxis[1].defaultvalue); - break; - case 1: - default: - CV_StealthSet(&cv_usejoystick[0], cv_usejoystick[0].defaultvalue); - CV_StealthSet(&cv_turnaxis[0], cv_turnaxis[0].defaultvalue); - CV_StealthSet(&cv_moveaxis[0], cv_moveaxis[0].defaultvalue); - CV_StealthSet(&cv_brakeaxis[0], cv_brakeaxis[0].defaultvalue); - CV_StealthSet(&cv_aimaxis[0], cv_aimaxis[0].defaultvalue); - CV_StealthSet(&cv_lookaxis[0], cv_lookaxis[0].defaultvalue); - CV_StealthSet(&cv_fireaxis[0], cv_fireaxis[0].defaultvalue); - CV_StealthSet(&cv_driftaxis[0], cv_driftaxis[0].defaultvalue); - CV_StealthSet(&cv_lookbackaxis[0], cv_lookbackaxis[0].defaultvalue); - break; - } + if (setupcontrolplayer != j) + continue; + CV_StealthSet(&cv_usejoystick[j], cv_usejoystick[j].defaultvalue); + CV_StealthSet(&cv_turnaxis[j], cv_turnaxis[j].defaultvalue); + CV_StealthSet(&cv_camturnaxis[j], cv_camturnaxis[j].defaultvalue); + CV_StealthSet(&cv_camstrafeaxis[j], cv_camstrafeaxis[j].defaultvalue); + CV_StealthSet(&cv_moveaxis[j], cv_moveaxis[j].defaultvalue); + CV_StealthSet(&cv_brakeaxis[j], cv_brakeaxis[j].defaultvalue); + CV_StealthSet(&cv_aimaxis[j], cv_aimaxis[j].defaultvalue); + CV_StealthSet(&cv_lookaxis[j], cv_lookaxis[j].defaultvalue); + CV_StealthSet(&cv_fireaxis[j], cv_fireaxis[j].defaultvalue); + CV_StealthSet(&cv_driftaxis[j], cv_driftaxis[j].defaultvalue); + CV_StealthSet(&cv_lookbackaxis[j], cv_lookbackaxis[j].defaultvalue); + CV_StealthSet(&cv_custom1axis[j], cv_custom1axis[j].defaultvalue); + CV_StealthSet(&cv_custom2axis[j], cv_custom2axis[j].defaultvalue); + CV_StealthSet(&cv_custom3axis[j], cv_custom3axis[j].defaultvalue); + } S_StartSound(NULL, sfx_s224); } diff --git a/src/m_menu.h b/src/m_menu.h index 72864c669..4ee8615ce 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -286,6 +286,9 @@ void Screenshot_option_Onchange(void); // Addons menu updating void Addons_option_Onchange(void); +// Moviemode menu updating +void Moviemode_option_Onchange(void); + // Player distortion menu updating void PDistort_menu_Onchange(void); diff --git a/src/m_misc.c b/src/m_misc.c index a3768120d..c6dd4175c 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -110,6 +110,9 @@ consvar_t cv_screenshot_folder = {"screenshot_folder", "", CV_SAVE, NULL, NULL, static CV_PossibleValue_t moviemode_cons_t[] = {{MM_GIF, "GIF"}, {MM_APNG, "aPNG"}, {MM_SCREENSHOT, "Screenshots"}, {0, NULL}}; consvar_t cv_moviemode = {"moviemode_mode", "GIF", CV_SAVE|CV_CALL, moviemode_cons_t, Moviemode_mode_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_movie_option = {"movie_option", "Default", CV_SAVE|CV_CALL, screenshot_cons_t, Moviemode_option_Onchange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_movie_folder = {"movie_folder", "", CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; + static CV_PossibleValue_t zlib_mem_level_t[] = { {1, "(Min Memory) 1"}, {2, "2"}, {3, "3"}, {4, "4"}, {5, "5"}, {6, "6"}, {7, "7"}, @@ -1144,19 +1147,25 @@ static inline moviemode_t M_StartMovieGIF(const char *pathname) void M_StartMovie(void) { #if NUMSCREENS > 2 - const char *pathname = "."; + char pathname[MAX_WADPATH]; if (moviemode) return; - if (cv_screenshot_option.value == 0) - pathname = usehome ? srb2home : srb2path; - else if (cv_screenshot_option.value == 1) - pathname = srb2home; - else if (cv_screenshot_option.value == 2) - pathname = srb2path; - else if (cv_screenshot_option.value == 3 && *cv_screenshot_folder.string != '\0') - pathname = cv_screenshot_folder.string; + if (cv_movie_option.value == 0) + strcpy(pathname, usehome ? srb2home : srb2path); + else if (cv_movie_option.value == 1) + strcpy(pathname, srb2home); + else if (cv_movie_option.value == 2) + strcpy(pathname, srb2path); + else if (cv_movie_option.value == 3 && *cv_movie_folder.string != '\0') + strcpy(pathname, cv_movie_folder.string); + + if (cv_movie_option.value != 3) + { + strcat(pathname, PATHSEP"gifs"PATHSEP); + I_mkdir(pathname, 0755); + } if (rendermode == render_none) I_Error("Can't make a movie without a render system\n"); @@ -1482,7 +1491,8 @@ void M_ScreenShot(void) void M_DoScreenShot(void) { #if NUMSCREENS > 2 - const char *freename = NULL, *pathname = "."; + const char *freename = NULL; + char pathname[MAX_WADPATH]; boolean ret = false; UINT8 *linear = NULL; @@ -1494,13 +1504,19 @@ void M_DoScreenShot(void) return; if (cv_screenshot_option.value == 0) - pathname = usehome ? srb2home : srb2path; + strcpy(pathname, usehome ? srb2home : srb2path); else if (cv_screenshot_option.value == 1) - pathname = srb2home; + strcpy(pathname, srb2home); else if (cv_screenshot_option.value == 2) - pathname = srb2path; + strcpy(pathname, srb2path); else if (cv_screenshot_option.value == 3 && *cv_screenshot_folder.string != '\0') - pathname = cv_screenshot_folder.string; + strcpy(pathname, cv_screenshot_folder.string); + + if (cv_screenshot_option.value != 3) + { + strcat(pathname, PATHSEP"screenshots"PATHSEP); + I_mkdir(pathname, 0755); + } #ifdef USE_PNG freename = Newsnapshotfile(pathname,"png"); @@ -2076,3 +2092,94 @@ const char *M_FileError(FILE *fp) else return "end-of-file"; } + +/** Return the number of parts of this path. +*/ +int M_PathParts(const char *path) +{ + int n; + const char *p; + const char *t; + if (path == NULL) + return 0; + for (n = 0, p = path ;; ++n) + { + t = p; + if (( p = strchr(p, PATHSEP[0]) )) + p += strspn(p, PATHSEP); + else + { + if (*t)/* there is something after the final delimiter */ + n++; + break; + } + } + return n; +} + +/** Check whether a path is an absolute path. +*/ +boolean M_IsPathAbsolute(const char *path) +{ +#ifdef _WIN32 + return ( strncmp(&path[1], ":\\", 2) == 0 ); +#else + return ( path[0] == '/' ); +#endif +} + +/** I_mkdir for each part of the path. +*/ +void M_MkdirEachUntil(const char *cpath, int start, int end, int mode) +{ + char path[MAX_WADPATH]; + char *p; + char *t; + + if (end > 0 && end <= start) + return; + + strlcpy(path, cpath, sizeof path); +#ifdef _WIN32 + if (strncmp(&path[1], ":\\", 2) == 0) + p = &path[3]; + else +#endif + p = path; + + if (end > 0) + end -= start; + + for (; start > 0; --start) + { + p += strspn(p, PATHSEP); + if (!( p = strchr(p, PATHSEP[0]) )) + return; + } + p += strspn(p, PATHSEP); + for (;;) + { + if (end > 0 && !--end) + break; + + t = p; + if (( p = strchr(p, PATHSEP[0]) )) + { + *p = '\0'; + I_mkdir(path, mode); + *p = PATHSEP[0]; + p += strspn(p, PATHSEP); + } + else + { + if (*t) + I_mkdir(path, mode); + break; + } + } +} + +void M_MkdirEach(const char *path, int start, int mode) +{ + M_MkdirEachUntil(path, start, -1, mode); +} diff --git a/src/m_misc.h b/src/m_misc.h index c858ae128..013da2235 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -30,7 +30,7 @@ typedef enum { extern moviemode_t moviemode; extern consvar_t cv_screenshot_option, cv_screenshot_folder; -extern consvar_t cv_moviemode; +extern consvar_t cv_moviemode, cv_movie_folder, cv_movie_option; extern consvar_t cv_zlib_memory, cv_zlib_level, cv_zlib_strategy, cv_zlib_window_bits; extern consvar_t cv_zlib_memorya, cv_zlib_levela, cv_zlib_strategya, cv_zlib_window_bitsa; extern consvar_t cv_apng_delay; @@ -99,6 +99,11 @@ void strcatbf(char *s1, const char *s2, const char *s3); const char *M_FileError(FILE *handle); +int M_PathParts (const char *path); +boolean M_IsPathAbsolute (const char *path); +void M_MkdirEach (const char *path, int start, int mode); +void M_MkdirEachUntil (const char *path, int start, int end, int mode); + // counting bits, for weapon ammo code, usually FUNCMATH UINT8 M_CountBits(UINT32 num, UINT8 size); diff --git a/src/m_perfstats.c b/src/m_perfstats.c index 14980b162..e54d1df06 100644 --- a/src/m_perfstats.c +++ b/src/m_perfstats.c @@ -577,8 +577,7 @@ static void PS_CountThinkers(void) ps_removecount.value.i = 0; for (thinker = thinkercap.next; thinker != &thinkercap; thinker = thinker->next) { - if (thinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) - ps_thinkercount.value.i++; + ps_thinkercount.value.i++; if (thinker->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) ps_removecount.value.i++; @@ -593,11 +592,18 @@ static void PS_CountThinkers(void) else ps_regularcount.value.i++; } - else if (thinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) - ps_precipcount.value.i++; else ps_otherthcount.value.i++; } + + for (thinker = precipcap.next; thinker != &precipcap; thinker = thinker->next) + { + if (thinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) + continue; // not a precipmobj thinker + + ps_precipcount.value.i++; + } + /*for (i = 0; i < NUM_THINKERLISTS; i++) { for (thinker = thlist[i].next; thinker != &thlist[i]; thinker = thinker->next) diff --git a/src/p_enemy.c b/src/p_enemy.c index dfb237d74..1ee8b9a2c 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3920,10 +3920,12 @@ void A_MineExplode(mobj_t *actor) for (d = 0; d < 16; d++) K_SpawnKartExplosion(actor->x, actor->y, actor->z, explodedist + 32*mapobjectscale, 32, type, d*(ANGLE_45/4), true, false, actor->target); // 32 <-> 64 + skincolors_t color = SKINCOLOR_KETCHUP; + if (actor->target && actor->target->player) - K_SpawnMineExplosion(actor, actor->target->player->skincolor); - else - K_SpawnMineExplosion(actor, SKINCOLOR_KETCHUP); + color = actor->target->player->skincolor; + + K_SpawnMineExplosion(actor, color); P_SpawnMobj(actor->x, actor->y, actor->z, MT_MINEEXPLOSIONSOUND); @@ -10137,7 +10139,7 @@ void A_RemoteDamage(mobj_t *actor) if (locvar2 == 1) // Kill mobj! { if (target->player) // players die using P_DamageMobj instead for some reason - P_DamageMobj(target, source, source, 10000); + P_DamageMobj(target, source, source, DMG_INSTAKILL); else P_KillMobj(target, source, source); } diff --git a/src/p_floor.c b/src/p_floor.c index 17e32c089..07d8a8f91 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -327,7 +327,7 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case bounceFloorCrush: // Graue 03-27-2004 if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight) @@ -343,14 +343,14 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case crushFloorOnce: movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight; movefloor->direction = -1; movefloor->sector->soundorg.z = movefloor->sector->floorheight; S_StartSound(&movefloor->sector->soundorg,sfx_pstop); - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; default: break; @@ -376,7 +376,7 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case bounceFloorCrush: // Graue 03-27-2004 if (movefloor->floordestheight == lines[movefloor->texture].frontsector->floorheight) @@ -392,13 +392,13 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case crushFloorOnce: movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it P_RemoveThinker(&movefloor->thinker); movefloor->sector->floorspeed = 0; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; return; default: break; @@ -415,7 +415,7 @@ void T_MoveFloor(floormove_t *movefloor) else movefloor->sector->floorspeed = 0; - P_RecalcPrecipInSector(movefloor->sector); + movefloor->sector->moved = true; } // @@ -817,7 +817,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) bouncer->sector->floorheight = bouncer->sector->ceilingheight - (halfheight*2); T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, 0, 1, -1); // update things on ceiling T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor - P_RecalcPrecipInSector(actionsector); bouncer->sector->ceilingdata = NULL; bouncer->sector->floordata = NULL; bouncer->sector->floorspeed = 0; @@ -833,7 +832,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) bouncer->sector->floorheight = floorheight; T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, 0, 1, -1); // update things on ceiling T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor - P_RecalcPrecipInSector(actionsector); bouncer->sector->ceilingdata = NULL; bouncer->sector->floordata = NULL; bouncer->sector->floorspeed = 0; @@ -913,9 +911,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) if (bouncer->distance > 0) bouncer->distance--; - - if (actionsector) - P_RecalcPrecipInSector(actionsector); } #undef speed #undef distance @@ -1102,7 +1097,6 @@ void T_StartCrumble(elevator_t *elevator) { sector = §ors[i]; sector->moved = true; - P_RecalcPrecipInSector(sector); } } @@ -1156,7 +1150,7 @@ void T_MarioBlock(levelspecthink_t *block) } for (i = -1; (i = P_FindSectorFromTag((INT16)block->vars[0], i)) >= 0 ;) - P_RecalcPrecipInSector(§ors[i]); + sectors[i].moved = true; #undef speed #undef direction @@ -1272,7 +1266,7 @@ void T_FloatSector(levelspecthink_t *floater) else if (floater->sector->crumblestate == 0 || floater->sector->crumblestate >= 3/* || floatanyway*/) EV_BounceSector(floater->sector, FRACUNIT, floater->sourceline); - P_RecalcPrecipInSector(actionsector); + actionsector->moved = true; } } @@ -1974,7 +1968,7 @@ void T_ThwompSector(levelspecthink_t *thwomp) thwomp->sector->floorspeed = 0; } - P_RecalcPrecipInSector(actionsector); + actionsector->moved = true; #undef speed #undef direction #undef distance @@ -2119,11 +2113,11 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) sec = §ors[secnum]; FOFsector = false; - INT32 special = GETSECSPECIAL(sec->special, 2); + const INT32 secspecial = GETSECSPECIAL(sec->special, 2); - if (special == 3 || special == 5) + if (secspecial == 3 || secspecial == 5) floortouch = true; - else if (special >= 1 && special <= 8) + else if (secspecial >= 1 && secspecial <= 8) floortouch = false; else continue; @@ -2255,7 +2249,7 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) continue; if (!(players[i].mo->subsector->sector == sec - || P_PlayerTouchingSectorSpecial(&players[i], 2, special) == sec)) + || P_PlayerTouchingSectorSpecial(&players[i], 2, GETSECSPECIAL(sec->special, 2)) == sec)) continue; if (floortouch == true && P_IsObjectOnRealGround(players[i].mo, sec)) @@ -2299,9 +2293,9 @@ void T_EachTimeThinker(levelspecthink_t *eachtime) while ((affectPlayer = P_HavePlayersEnteredArea(playersArea, oldPlayersArea, inAndOut)) != -1) { - INT32 special = GETSECSPECIAL(sec->special, 2); + const INT32 secspecial = GETSECSPECIAL(sec->special, 2); - if (special == 2 || special == 3) + if (secspecial == 2 || secspecial == 3) { for (i = 0; i < MAXPLAYERS; i++) { @@ -2503,7 +2497,7 @@ void T_RaiseSector(levelspecthink_t *raise) raise->sector->floorspeed = raise->vars[3]*raise->vars[8]; for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;) - P_RecalcPrecipInSector(§ors[i]); + sectors[i].moved = true; } void T_CameraScanner(elevator_t *elevator) @@ -2920,12 +2914,12 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover) fixed_t a, b, c; mobjtype_t type = MT_ROCKCRUMBLE1; const fixed_t spacing = 48*mapobjectscale; - INT32 special = GETSECSPECIAL(rover->master->frontsector->special, 3); + const INT32 secspecial = GETSECSPECIAL(rover->master->frontsector->special, 3); // If the control sector has a special // of Section3:7-15, use the custom debris. - if (special >= 8) - type = MT_ROCKCRUMBLE1+(special-7); + if (secspecial >= 8) + type = MT_ROCKCRUMBLE1+(secspecial-7); // soundorg z height never gets set normally, so MEH. sec->soundorg.z = sec->floorheight; diff --git a/src/p_inter.c b/src/p_inter.c index d4a5b3c1d..0cbe6577f 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2364,10 +2364,9 @@ static void P_RingDamage(player_t *player, mobj_t *inflictor, mobj_t *source, IN * player is hit by a ring, the player who shot it. In some * cases, the target will go after this object after * receiving damage. This can be NULL. - * \param damage Amount of damage to be dealt. 10000 is instant death. + * \param damage Amount of damage to be dealt. DMG_INSTAKILL is instant death. * \return True if the target sustained damage, otherwise false. * \todo Clean up this mess, split into multiple functions. - * \todo Get rid of the magic number 10000. * \sa P_KillMobj */ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 damage) @@ -2378,14 +2377,18 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (objectplacing) return false; + // well no clue but this may happen ig + if (!target) + return false; + if (target->health <= 0) return false; // Spectator handling if (netgame) { - if (damage == 42000 && target->player && target->player->spectator) - damage = 10000; + if (damage == DMG_SPECTATOR && target->player && target->player->spectator) + damage = DMG_INSTAKILL; else if (target->player && target->player->spectator) return false; @@ -2397,6 +2400,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (!metalrecording) { UINT8 shouldForce = LUA_HookShouldDamage(target, inflictor, source, damage); + if (P_MobjWasRemoved(target)) return (shouldForce == 1); // mobj was removed if (shouldForce == 1) @@ -2524,7 +2528,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da { if ((G_BattleGametype()) && cv_suddendeath.value && !player->powers[pw_flashing] && !player->powers[pw_invulnerability]) - damage = 10000; + damage = DMG_INSTAKILL; } // Player hits another player @@ -2538,7 +2542,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return false; // Instant-Death - if (damage == 10000) + if (damage == DMG_INSTAKILL) P_KillPlayer(player, source, damage); else if (player->kartstuff[k_invincibilitytimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->powers[pw_flashing]) { @@ -2591,7 +2595,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da else { player->health -= damage; // mirror mobj health here - if (damage < 10000) + if (damage < DMG_INSTAKILL) { target->player->powers[pw_flashing] = K_GetKartFlashing(target->player); if (damage > 0) // don't spill emeralds/ammo/panels for shield damage diff --git a/src/p_local.h b/src/p_local.h index ea0bff603..ae72fee77 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -66,21 +66,38 @@ // both the head and tail of the thinker list extern thinker_t thinkercap; +extern thinker_t precipcap; extern mobj_t *mobjcache; void P_InitThinkers(void); void P_AddThinker(thinker_t *thinker); +void P_AddPrecipThinker(thinker_t *thinker); void P_RemoveThinker(thinker_t *thinker); void P_UnlinkThinker(thinker_t *thinker); // // P_USER // + typedef struct camera_s { boolean chase; + boolean freecam; + + angle_t localangle; + INT32 localaiming; + angle_t aiming; + // Freecam: A button was held since entering from menu, so don't move camera + UINT8 button_a_held; + + // Freecam: aiming needs to be reset after switching from chasecam + boolean reset_aiming; + + // Hold up/down to pan the camera vertically + SINT8 dpad_y_held; + // Things used by FS cameras. fixed_t viewheight; angle_t startangle; @@ -110,29 +127,30 @@ typedef struct camera_s // SRB2Kart: camera pans while drifting fixed_t pan; + + // postproccess effects + UINT8 postimg; } camera_t; -// demo freecam or something before i commit die -struct demofreecam_s { - - camera_t *cam; // this is useful when the game is paused, notably - mobj_t *soundmobj; // mobj to play sound from, used in s_sound - - angle_t localangle; // keeps track of the cam angle for cmds - angle_t localaiming; // ditto with aiming - boolean turnheld; // holding turn button for gradual turn speed - boolean keyboardlook; // keyboard look +// post process types +enum +{ + POSTIMG_WATER = 1, // Underwater screen effect. + POSTIMG_MOTION = 1<<1, // Unused motion blur effect. + POSTIMG_FLIP = 1<<2, // Flipcam screen effect. + POSTIMG_HEAT = 1<<3, // Heatwave screen effect. + POSTIMG_MIRROR = 1<<4, // encore screen effect. }; -extern struct demofreecam_s democam; - extern camera_t camera[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_dist[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_height[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_speed[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_cam_rotate[MAXSPLITSCREENPLAYERS]; -extern consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS]; +extern consvar_t cv_cam_timeover[MAXSPLITSCREENPLAYERS]; + +extern consvar_t cv_freecam_speed[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_tilting; extern consvar_t cv_quaketilt; @@ -150,10 +168,11 @@ void P_AddPlayerScore(player_t *player, UINT32 amount); void P_ResetCamera(player_t *player, camera_t *thiscam); boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam); void P_SlideCameraMove(camera_t *thiscam); -void P_DemoCameraMovement(camera_t *cam); +//void P_DemoCameraMovement(camera_t *cam, UINT8 num); boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcalled); void P_ResetLocalCamAiming(player_t *player); -void P_InitCameraCmd(void); +void P_ToggleDemoCamera(UINT8 viewnum); +void P_CalcChasePostImg(player_t *player, camera_t *thiscam); boolean P_PlayerInPain(player_t *player); void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor); void P_ResetPlayer(player_t *player); @@ -238,7 +257,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type); mobj_t *P_SpawnShadowMobj(mobj_t * caster); -void P_RecalcPrecipInSector(sector_t *sector); void P_PrecipitationEffects(void); void P_RemoveMobj(mobj_t *th); @@ -296,7 +314,7 @@ void P_ColorTeamMissile(mobj_t *missile, player_t *source); // Special utility to return +1 or -1 depending on mobj's gravity FUNCINLINE static ATTRINLINE SINT8 P_MobjFlip(const mobj_t *mobj) { - return (mobj && mobj->eflags & MFE_VERTICALFLIP) ? -1 : 1; + return (mobj && (mobj->eflags & MFE_VERTICALFLIP)) ? -1 : 1; } fixed_t P_GetMobjGravity(mobj_t *mo); @@ -353,8 +371,6 @@ extern line_t *ceilingline; extern line_t *blockingline; extern msecnode_t *sector_list; -extern mprecipsecnode_t *precipsector_list; - void P_UnsetThingPosition(mobj_t *thing); void P_SetThingPosition(mobj_t *thing); void P_SetUnderlayPosition(mobj_t *thing); @@ -378,7 +394,6 @@ void P_CheckHoopPosition(mobj_t *hoopthing, fixed_t x, fixed_t y, fixed_t z, fix boolean P_CheckSector(sector_t *sector, boolean crunch); void P_DelSeclist(msecnode_t *node); -void P_DelPrecipSeclist(mprecipsecnode_t *node); void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y); void P_Initsecnode(void); @@ -406,7 +421,6 @@ extern precipmobj_t **precipblocklinks; // special blockmap for precip rendering extern struct minimapinfo { patch_t *minimap_pic; - UINT8 mapthingcount; INT32 min_x, min_y; INT32 max_x, max_y; INT32 map_w, map_h; @@ -430,6 +444,10 @@ typedef struct BasicFF_s INT32 Magnitude; ///< Magnitude of the effect, in the range from 0 through 10,000. } BasicFF_t; +// replace damage magic numbers with smth readable +#define DMG_INSTAKILL 10000 +#define DMG_SPECTATOR 42000 + void P_ForceFeed(const player_t *player, INT32 attack, INT32 fade, tic_t duration, INT32 period); void P_ForceConstant(const BasicFF_t *FFInfo); void P_RampConstant(const BasicFF_t *FFInfo, INT32 Start, INT32 End); diff --git a/src/p_map.c b/src/p_map.c index 6825141a4..01965c423 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -46,9 +46,6 @@ static INT32 tmflags; fixed_t tmx; fixed_t tmy; -static precipmobj_t *tmprecipthing; -static fixed_t preciptmbbox[4]; - // If "floatok" true, move would be ok // if within "tmfloorz - tmceilingz". boolean floatok; @@ -68,7 +65,6 @@ line_t *ceilingline; line_t *blockingline; msecnode_t *sector_list = NULL; -mprecipsecnode_t *precipsector_list = NULL; camera_t *mapcampointer; // @@ -76,9 +72,9 @@ camera_t *mapcampointer; // // -// P_TeleportMove +// P_MoveOrigin - P_TeleportMove which KEEPS interpolation values. // -static boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) +boolean P_MoveOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) { // the move is ok, // so link the thing into its new position @@ -108,28 +104,19 @@ static boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) return true; } +// // P_SetOrigin - P_TeleportMove which RESETS interpolation values. // boolean P_SetOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) { - boolean result = P_TeleportMove(thing, x, y, z); - - if (result == true) + if (P_MoveOrigin(thing, x, y, z)) { thing->old_x = thing->x; thing->old_y = thing->y; thing->old_z = thing->z; } - return result; -} - -// -// P_MoveOrigin - P_TeleportMove which KEEPS interpolation values. -// -boolean P_MoveOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) -{ - return P_TeleportMove(thing, x, y, z); + return true; } // ========================================================================= @@ -235,14 +222,15 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (!demo.playback || P_AnalogMove(object->player)) { - if (object->player == &players[consoleplayer]) - localangle[0] = spring->angle; - else if (object->player == &players[displayplayers[1]]) - localangle[1] = spring->angle; - else if (object->player == &players[displayplayers[2]]) - localangle[2] = spring->angle; - else if (object->player == &players[displayplayers[3]]) - localangle[3] = spring->angle; + for (UINT8 j = 0; j <= splitscreen; ++j) + { + INT32 id = (j == 0 ? consoleplayer : displayplayers[j]); + if (object->player == &players[id]) + { + localangle[j] = spring->angle; + break; + } + } } } @@ -724,7 +712,7 @@ static boolean PIT_CheckThing(mobj_t *thing) HU_SetCEchoDuration(5); HU_DoCEcho(va("%s\\was hit by a kitchen sink.\\\\\\\\", player_names[thing->player-players])); I_OutputMsg("%s was hit by a kitchen sink.\n", player_names[thing->player-players]); - P_DamageMobj(thing, tmthing, tmthing->target, 10000); + P_DamageMobj(thing, tmthing, tmthing->target, DMG_INSTAKILL); P_KillMobj(tmthing, thing, thing); } @@ -991,7 +979,7 @@ static boolean PIT_CheckThing(mobj_t *thing) HU_SetCEchoDuration(5); HU_DoCEcho(va("%s\\was hit by a kitchen sink.\\\\\\\\", player_names[tmthing->player-players])); I_OutputMsg("%s was hit by a kitchen sink.\n", player_names[tmthing->player-players]); - P_DamageMobj(tmthing, thing, thing->target, 10000); + P_DamageMobj(tmthing, thing, thing->target, DMG_INSTAKILL); P_KillMobj(thing, tmthing, tmthing); } @@ -1726,7 +1714,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) tmbbox[BOXRIGHT] = x + tmthing->radius; tmbbox[BOXLEFT] = x - tmthing->radius; - newsubsec = R_PointInSubsector(x, y); + if (thing->x != x || thing->y != y || thing->subsector == NULL) + newsubsec = R_PointInSubsector(x, y); + else + newsubsec = thing->subsector; ceilingline = blockingline = NULL; @@ -1748,7 +1739,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) for (rover = newsubsec->sector->ffloors; rover; rover = rover->next) { - fixed_t topheight, bottomheight; + fixed_t topheight, bottomheight, midheight; if (!(rover->flags & FF_EXISTS)) continue; @@ -1813,10 +1804,10 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) continue; } - delta1 = thing->z - (bottomheight - + ((topheight - bottomheight)/2)); - delta2 = thingtop - (bottomheight - + ((topheight - bottomheight)/2)); + midheight = (bottomheight + ((topheight - bottomheight)/2)); + + delta1 = thing->z - midheight; + delta2 = thingtop - midheight; if (topheight > tmfloorz && abs(delta1) < abs(delta2) && !(rover->flags & FF_REVERSEPLATFORM)) @@ -1847,10 +1838,13 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) BMBOUNDFIX(xl, xh, yl, yh); // Check polyobjects and see if tmfloorz/tmceilingz need to be altered + // do we really have to iterate through the complete blockmap for polyobjects if there are no polyobjects on the map? + if (numPolyObjects) { validcount++; for (by = yl; by <= yh; by++) + { for (bx = xl; bx <= xh; bx++) { INT32 offset; @@ -1901,12 +1895,14 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) delta1 = thing->z - (polybottom + ((polytop - polybottom)/2)); delta2 = thingtop - (polybottom + ((polytop - polybottom)/2)); - if (polytop > tmfloorz && abs(delta1) < abs(delta2)) { + if (polytop > tmfloorz && abs(delta1) < abs(delta2)) + { tmfloorz = tmdropoffz = polytop; tmfloorslope = NULL; } - if (polybottom < tmceilingz && abs(delta1) >= abs(delta2)) { + if (polybottom < tmceilingz && abs(delta1) >= abs(delta2)) + { tmceilingz = tmdrpoffceilz = polybottom; tmceilingslope = NULL; } @@ -1914,6 +1910,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) plink = (polymaplink_t *)(plink->link.next); } } + } } // tmfloorthing is set when tmfloorz comes from a thing's top @@ -1994,7 +1991,11 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) tmbbox[BOXRIGHT] = x + thiscam->radius; tmbbox[BOXLEFT] = x - thiscam->radius; - newsubsec = R_PointInSubsector(x, y); + if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) + newsubsec = R_PointInSubsector(x, y); + else + newsubsec = thiscam->subsector; + ceilingline = blockingline = NULL; mapcampointer = thiscam; @@ -2073,6 +2074,8 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) BMBOUNDFIX(xl, xh, yl, yh); // Check polyobjects and see if tmfloorz/tmceilingz need to be altered + // do we really have to iterate through the complete blockmap for polyobjects if there are no polyobjects on the map? + if (numPolyObjects) { validcount++; @@ -2164,7 +2167,8 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam) // boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) { - subsector_t *s = R_PointInSubsector(x, y); + subsector_t *s; + boolean retval = true; boolean itsatwodlevel = false; UINT8 i; @@ -2174,6 +2178,11 @@ boolean P_TryCameraMove(fixed_t x, fixed_t y, camera_t *thiscam) if (dedicated) // this crashes so don't even try it return false; + if (thiscam->x != x || thiscam->y != y || thiscam->subsector == NULL) + s = R_PointInSubsector(x, y); + else + s = thiscam->subsector; + if (twodlevel) itsatwodlevel = true; else @@ -2367,10 +2376,13 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) radius = MAXRADIUS/2; do { - if (thing->flags & MF_NOCLIP) { + if (thing->flags & MF_NOCLIP) + { tryx = x; tryy = y; - } else { + } + else + { if (x-tryx > radius) tryx += radius; else if (x-tryx < -radius) @@ -2392,19 +2404,16 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) { //All things are affected by their scale. fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale); - INT32 special = 0; if (thing->player) { - special = GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1); - // If using type Section1:13, double the maxstep. if (P_PlayerTouchingSectorSpecial(thing->player, 1, 13) - || special == 13) + || GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 13) maxstep <<= 1; // If using type Section1:12, no maxstep. For ledges you don't want the player to climb! (see: Egg Zeppelin & SMK port walls) else if (P_PlayerTouchingSectorSpecial(thing->player, 1, 12) - || special == 12) + || GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 12) maxstep = 0; } @@ -2450,7 +2459,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) else if (maxstep > 0 && !( thing->player && ( P_PlayerTouchingSectorSpecial(thing->player, 1, 14) - || special == 14) + || GETSECSPECIAL(R_PointInSubsector(x, y)->sector->special, 1) == 14) )) // Step down { // If the floor difference is MAXSTEPMOVE or less, and the sector isn't Section1:14, ALWAYS @@ -2514,14 +2523,16 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (!(thing->flags & MF_NOCLIPHEIGHT)) { // Assign thing's standingslope if needed - if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) { + if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) + { if (!startingonground && tmfloorslope) P_HandleSlopeLanding(thing, tmfloorslope); if (thing->momz <= 0) thing->standingslope = tmfloorslope; } - else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) { + else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) + { if (!startingonground && tmceilingslope) P_HandleSlopeLanding(thing, tmceilingslope); @@ -3650,7 +3661,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) { // Crush the object if (netgame && thing->player && thing->player->spectator) - P_DamageMobj(thing, NULL, NULL, 42000); // Respawn crushed spectators + P_DamageMobj(thing, NULL, NULL, DMG_SPECTATOR); // Respawn crushed spectators else { if (!killer) @@ -3660,7 +3671,7 @@ static boolean PIT_ChangeSector(mobj_t *thing, boolean realcrush) killer->threshold = 44; // Special flag for crushing } if (!thing->player) - P_DamageMobj(thing, killer, killer, 10000); + P_DamageMobj(thing, killer, killer, DMG_INSTAKILL); else K_SquishPlayer(thing->player, killer, killer); // SRB2kart - Squish instead of kill } @@ -3706,8 +3717,6 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) sec->moved = true; - P_RecalcPrecipInSector(sec); - if (!sector->attachedsolid[i]) continue; @@ -3768,8 +3777,6 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) sec->moved = true; - P_RecalcPrecipInSector(sec); - if (!sector->attachedsolid[i]) continue; @@ -3820,12 +3827,10 @@ boolean P_CheckSector(sector_t *sector, boolean crunch) */ static msecnode_t *headsecnode = NULL; -static mprecipsecnode_t *headprecipsecnode = NULL; void P_Initsecnode(void) { headsecnode = NULL; - headprecipsecnode = NULL; } // P_GetSecnode() retrieves a node from the freelist. The calling routine @@ -3845,20 +3850,6 @@ static msecnode_t *P_GetSecnode(void) return node; } -static mprecipsecnode_t *P_GetPrecipSecnode(void) -{ - mprecipsecnode_t *node; - - if (headprecipsecnode) - { - node = headprecipsecnode; - headprecipsecnode = headprecipsecnode->m_thinglist_next; - } - else - node = Z_Calloc(sizeof (*node), PU_LEVEL, NULL); - return node; -} - // P_PutSecnode() returns a node to the freelist. static inline void P_PutSecnode(msecnode_t *node) @@ -3867,13 +3858,6 @@ static inline void P_PutSecnode(msecnode_t *node) headsecnode = node; } -// Tails 08-25-2002 -static inline void P_PutPrecipSecnode(mprecipsecnode_t *node) -{ - node->m_thinglist_next = headprecipsecnode; - headprecipsecnode = node; -} - // P_AddSecnode() searches the current list to see if this sector is // already there. If not, it adds a sector node at the head of the list of // sectors this object appears in. This is called when creating a list of @@ -3919,47 +3903,6 @@ static msecnode_t *P_AddSecnode(sector_t *s, mobj_t *thing, msecnode_t *nextnode return node; } -// More crazy crap Tails 08-25-2002 -static mprecipsecnode_t *P_AddPrecipSecnode(sector_t *s, precipmobj_t *thing, mprecipsecnode_t *nextnode) -{ - mprecipsecnode_t *node; - - node = nextnode; - while (node) - { - if (node->m_sector == s) // Already have a node for this sector? - { - node->m_thing = thing; // Yes. Setting m_thing says 'keep it'. - return nextnode; - } - node = node->m_sectorlist_next; - } - - // Couldn't find an existing node for this sector. Add one at the head - // of the list. - - node = P_GetPrecipSecnode(); - - // mark new nodes unvisited. - node->visited = 0; - - node->m_sector = s; // sector - node->m_thing = thing; // mobj - node->m_sectorlist_prev = NULL; // prev node on Thing thread - node->m_sectorlist_next = nextnode; // next node on Thing thread - if (nextnode) - nextnode->m_sectorlist_prev = node; // set back link on Thing - - // Add new node at head of sector thread starting at s->touching_thinglist - - node->m_thinglist_prev = NULL; // prev node on sector thread - node->m_thinglist_next = s->touching_preciplist; // next node on sector thread - if (s->touching_preciplist) - node->m_thinglist_next->m_thinglist_prev = node; - s->touching_preciplist = node; - return node; -} - // P_DelSecnode() deletes a sector node from the list of // sectors this object appears in. Returns a pointer to the next node // on the linked list, or NULL. @@ -4002,45 +3945,6 @@ static msecnode_t *P_DelSecnode(msecnode_t *node) return tn; } -// Tails 08-25-2002 -static mprecipsecnode_t *P_DelPrecipSecnode(mprecipsecnode_t *node) -{ - mprecipsecnode_t *tp; // prev node on thing thread - mprecipsecnode_t *tn; // next node on thing thread - mprecipsecnode_t *sp; // prev node on sector thread - mprecipsecnode_t *sn; // next node on sector thread - - if (!node) - return NULL; - - // Unlink from the Thing thread. The Thing thread begins at - // sector_list and not from mobj_t->touching_sectorlist. - - tp = node->m_sectorlist_prev; - tn = node->m_sectorlist_next; - if (tp) - tp->m_sectorlist_next = tn; - if (tn) - tn->m_sectorlist_prev = tp; - - // Unlink from the sector thread. This thread begins at - // sector_t->touching_thinglist. - - sp = node->m_thinglist_prev; - sn = node->m_thinglist_next; - if (sp) - sp->m_thinglist_next = sn; - else - node->m_sector->touching_preciplist = sn; - if (sn) - sn->m_thinglist_prev = sp; - - // Return this node to the freelist - - P_PutPrecipSecnode(node); - return tn; -} - // Delete an entire sector list void P_DelSeclist(msecnode_t *node) { @@ -4048,13 +3952,6 @@ void P_DelSeclist(msecnode_t *node) node = P_DelSecnode(node); } -// Tails 08-25-2002 -void P_DelPrecipSeclist(mprecipsecnode_t *node) -{ - while (node) - node = P_DelPrecipSecnode(node); -} - // PIT_GetSectors // Locates all the sectors the object is in by looking at the lines that // cross through it. You have already decided that the object is allowed @@ -4095,41 +3992,6 @@ static inline boolean PIT_GetSectors(line_t *ld) return true; } -// Tails 08-25-2002 -static inline boolean PIT_GetPrecipSectors(line_t *ld) -{ - if (preciptmbbox[BOXRIGHT] <= ld->bbox[BOXLEFT] || - preciptmbbox[BOXLEFT] >= ld->bbox[BOXRIGHT] || - preciptmbbox[BOXTOP] <= ld->bbox[BOXBOTTOM] || - preciptmbbox[BOXBOTTOM] >= ld->bbox[BOXTOP]) - return true; - - if (P_BoxOnLineSide(preciptmbbox, ld) != -1) - return true; - - if (ld->polyobj) // line belongs to a polyobject, don't add it - return true; - - // This line crosses through the object. - - // Collect the sector(s) from the line and add to the - // sector_list you're examining. If the Thing ends up being - // allowed to move to this position, then the sector_list - // will be attached to the Thing's mobj_t at touching_sectorlist. - - precipsector_list = P_AddPrecipSecnode(ld->frontsector, tmprecipthing, precipsector_list); - - // Don't assume all lines are 2-sided, since some Things - // like MT_TFOG are allowed regardless of whether their radius takes - // them beyond an impassable linedef. - - // Use sidedefs instead of 2s flag to determine two-sidedness. - if (ld->backsector) - precipsector_list = P_AddPrecipSecnode(ld->backsector, tmprecipthing, precipsector_list); - - return true; -} - // P_CreateSecNodeList alters/creates the sector_list that shows what sectors // the object resides in. @@ -4216,73 +4078,6 @@ void P_CreateSecNodeList(mobj_t *thing, fixed_t x, fixed_t y) } } -// More crazy crap Tails 08-25-2002 -void P_CreatePrecipSecNodeList(precipmobj_t *thing,fixed_t x,fixed_t y) -{ - INT32 xl, xh, yl, yh, bx, by; - mprecipsecnode_t *node = precipsector_list; - precipmobj_t *saved_tmthing = tmprecipthing; /* cph - see comment at func end */ - - // First, clear out the existing m_thing fields. As each node is - // added or verified as needed, m_thing will be set properly. When - // finished, delete all nodes where m_thing is still NULL. These - // represent the sectors the Thing has vacated. - - while (node) - { - node->m_thing = NULL; - node = node->m_sectorlist_next; - } - - tmprecipthing = thing; - - preciptmbbox[BOXTOP] = y + 2*FRACUNIT; - preciptmbbox[BOXBOTTOM] = y - 2*FRACUNIT; - preciptmbbox[BOXRIGHT] = x + 2*FRACUNIT; - preciptmbbox[BOXLEFT] = x - 2*FRACUNIT; - - validcount++; // used to make sure we only process a line once - - xl = (unsigned)(preciptmbbox[BOXLEFT] - bmaporgx)>>MAPBLOCKSHIFT; - xh = (unsigned)(preciptmbbox[BOXRIGHT] - bmaporgx)>>MAPBLOCKSHIFT; - yl = (unsigned)(preciptmbbox[BOXBOTTOM] - bmaporgy)>>MAPBLOCKSHIFT; - yh = (unsigned)(preciptmbbox[BOXTOP] - bmaporgy)>>MAPBLOCKSHIFT; - - BMBOUNDFIX(xl, xh, yl, yh); - - for (bx = xl; bx <= xh; bx++) - for (by = yl; by <= yh; by++) - P_BlockLinesIterator(bx, by, PIT_GetPrecipSectors); - - // Add the sector of the (x, y) point to sector_list. - precipsector_list = P_AddPrecipSecnode(thing->subsector->sector, thing, precipsector_list); - - // Now delete any nodes that won't be used. These are the ones where - // m_thing is still NULL. - node = precipsector_list; - while (node) - { - if (!node->m_thing) - { - if (node == precipsector_list) - precipsector_list = node->m_sectorlist_next; - node = P_DelPrecipSecnode(node); - } - else - node = node->m_sectorlist_next; - } - - /* cph - - * This is the strife we get into for using global variables. tmthing - * is being used by several different functions calling - * P_BlockThingIterator, including functions that can be called *from* - * P_BlockThingIterator. Using a global tmthing is not reentrant. - * OTOH for Boom/MBF demos we have to preserve the buggy behavior. - * Fun. We restore its previous value unless we're in a Boom/MBF demo. - */ - tmprecipthing = saved_tmthing; -} - /* cphipps 2004/08/30 - * Must clear tmthing at tic end, as it might contain a pointer to a removed thinker, or the level might have ended/been ended and we clear the objects it was pointing too. Hopefully we don't need to carry this between tics for sync. */ void P_MapStart(void) diff --git a/src/p_maputl.c b/src/p_maputl.c index 3c91dc922..a88545135 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -296,7 +296,7 @@ void P_CameraLineOpening(line_t *linedef) { frontfloor = sectors[front->camsec].floorheight; frontceiling = sectors[front->camsec].ceilingheight; - if (sectors[front->camsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + 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); @@ -306,7 +306,7 @@ void P_CameraLineOpening(line_t *linedef) { frontfloor = sectors[front->heightsec].floorheight; frontceiling = sectors[front->heightsec].ceilingheight; - if (sectors[front->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + 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); @@ -316,11 +316,12 @@ void P_CameraLineOpening(line_t *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) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + 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); @@ -329,7 +330,7 @@ void P_CameraLineOpening(line_t *linedef) { backfloor = sectors[back->heightsec].floorheight; backceiling = sectors[back->heightsec].ceilingheight; - if (sectors[back->heightsec].f_slope) // SRB2CBTODO: ESLOPE (sectors[front->heightsec].f_slope) + 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); @@ -340,104 +341,111 @@ void P_CameraLineOpening(line_t *linedef) backceiling = P_CameraGetCeilingZ(mapcampointer, back, tmx, tmy, linedef); } + fixed_t thingtop = mapcampointer->z + mapcampointer->height; + + if (frontceiling < backceiling) { - fixed_t thingtop = mapcampointer->z + mapcampointer->height; - - if (frontceiling < backceiling) - { - opentop = frontceiling; - highceiling = backceiling; - } - else - { - opentop = backceiling; - highceiling = frontceiling; - } - - if (frontfloor > backfloor) - { - openbottom = frontfloor; - lowfloor = backfloor; - } - else - { - openbottom = backfloor; - lowfloor = frontfloor; - } - - // Check for fake floors in the sector. - if (front->ffloors || back->ffloors) - { - ffloor_t *rover; - fixed_t highestceiling = highceiling; - fixed_t lowestceiling = opentop; - fixed_t highestfloor = openbottom; - fixed_t lowestfloor = lowfloor; - fixed_t delta1, delta2; - - // Check for frontsector's fake floors - if (front->ffloors) - for (rover = front->ffloors; rover; rover = rover->next) - { - fixed_t topheight, bottomheight; - if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) - continue; - - topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); - - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; - - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; - } - - // Check for backsectors fake floors - if (back->ffloors) - for (rover = back->ffloors; rover; rover = rover->next) - { - fixed_t topheight, bottomheight; - if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) - continue; - - topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); - bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); - - delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); - delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); - if (bottomheight < lowestceiling && delta1 >= delta2) - lowestceiling = bottomheight; - else if (bottomheight < highestceiling && delta1 >= delta2) - highestceiling = bottomheight; - - if (topheight > highestfloor && delta1 < delta2) - highestfloor = topheight; - else if (topheight > lowestfloor && delta1 < delta2) - lowestfloor = topheight; - } - - if (highestceiling < highceiling) - highceiling = highestceiling; - - if (highestfloor > openbottom) - openbottom = highestfloor; - - if (lowestceiling < opentop) - opentop = lowestceiling; - - if (lowestfloor > lowfloor) - lowfloor = lowestfloor; - } - openrange = opentop - openbottom; - return; + opentop = frontceiling; + highceiling = backceiling; } + else + { + opentop = backceiling; + highceiling = frontceiling; + } + + if (frontfloor > backfloor) + { + openbottom = frontfloor; + lowfloor = backfloor; + } + else + { + openbottom = backfloor; + lowfloor = frontfloor; + } + + // Check for fake floors in the sector. + if (front->ffloors || back->ffloors) + { + ffloor_t *rover; + fixed_t highestceiling = highceiling; + fixed_t lowestceiling = opentop; + fixed_t highestfloor = openbottom; + fixed_t lowestfloor = lowfloor; + fixed_t delta1, delta2; + + // Check for frontsector's fake floors + if (front->ffloors) + { + for (rover = front->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + + if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) + continue; + + topheight = P_CameraGetFOFTopZ(mapcampointer, front, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, front, rover, tmx, tmy, linedef); + + delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); + delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + + if (bottomheight < lowestceiling && delta1 >= delta2) + lowestceiling = bottomheight; + else if (bottomheight < highestceiling && delta1 >= delta2) + highestceiling = bottomheight; + + if (topheight > highestfloor && delta1 < delta2) + highestfloor = topheight; + else if (topheight > lowestfloor && delta1 < delta2) + lowestfloor = topheight; + } + } + + // Check for backsectors fake floors + if (back->ffloors) + { + for (rover = back->ffloors; rover; rover = rover->next) + { + fixed_t topheight, bottomheight; + + if (!(rover->flags & FF_BLOCKOTHERS) || !(rover->flags & FF_RENDERALL) || !(rover->flags & FF_EXISTS) || GETSECSPECIAL(rover->master->frontsector->special, 4) == 12) + continue; + + topheight = P_CameraGetFOFTopZ(mapcampointer, back, rover, tmx, tmy, linedef); + bottomheight = P_CameraGetFOFBottomZ(mapcampointer, back, rover, tmx, tmy, linedef); + + delta1 = abs(mapcampointer->z - (bottomheight + ((topheight - bottomheight)/2))); + delta2 = abs(thingtop - (bottomheight + ((topheight - bottomheight)/2))); + + if (bottomheight < lowestceiling && delta1 >= delta2) + lowestceiling = bottomheight; + else if (bottomheight < highestceiling && delta1 >= delta2) + highestceiling = bottomheight; + + if (topheight > highestfloor && delta1 < delta2) + highestfloor = topheight; + else if (topheight > lowestfloor && delta1 < delta2) + lowestfloor = topheight; + } + } + + if (highestceiling < highceiling) + highceiling = highestceiling; + + if (highestfloor > openbottom) + openbottom = highestfloor; + + if (lowestceiling < opentop) + opentop = lowestceiling; + + if (lowestfloor > lowfloor) + lowfloor = lowestfloor; + } + + openrange = opentop - openbottom; + return; } void P_LineOpening(line_t *linedef, mobj_t *mobj) @@ -466,40 +474,39 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) I_Assert(front != NULL); I_Assert(back != NULL); - { // Set open and high/low values here - fixed_t frontheight, backheight; + // Set open and high/low values here + fixed_t frontheight, backheight; - frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); + frontheight = P_GetCeilingZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetCeilingZ(mobj, back, tmx, tmy, linedef); - if (frontheight < backheight) - { - opentop = frontheight; - highceiling = backheight; - opentopslope = front->c_slope; - } - else - { - opentop = backheight; - highceiling = frontheight; - opentopslope = back->c_slope; - } + if (frontheight < backheight) + { + opentop = frontheight; + highceiling = backheight; + opentopslope = front->c_slope; + } + else + { + opentop = backheight; + highceiling = frontheight; + opentopslope = back->c_slope; + } - frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); - backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); + frontheight = P_GetFloorZ(mobj, front, tmx, tmy, linedef); + backheight = P_GetFloorZ(mobj, back, tmx, tmy, linedef); - if (frontheight > backheight) - { - openbottom = frontheight; - lowfloor = backheight; - openbottomslope = front->f_slope; - } - else - { - openbottom = backheight; - lowfloor = frontheight; - openbottomslope = back->f_slope; - } + if (frontheight > backheight) + { + openbottom = frontheight; + lowfloor = backheight; + openbottomslope = front->f_slope; + } + else + { + openbottom = backheight; + lowfloor = frontheight; + openbottomslope = back->f_slope; } if (mobj) @@ -508,29 +515,33 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) // Check for collision with front side's midtexture if Effect 4 is set if (linedef->flags & ML_EFFECT4 - && !linedef->polyobj // don't do anything for polyobjects! ...for now - ) { + && !linedef->polyobj) // don't do anything for polyobjects! ...for now + { side_t *side = &sides[linedef->sidenum[0]]; fixed_t textop, texbottom, texheight; fixed_t texmid, delta1, delta2; INT32 texnum = R_GetTextureNum(side->midtexture); // make sure the texture is actually valid - if (texnum) { + if (texnum) + { // Get the midtexture's height texheight = textures[texnum]->height << FRACBITS; // Set texbottom and textop to the Z coordinates of the texture's boundaries + if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) // "infinite" repeat { - if (linedef->flags & ML_EFFECT5 && !side->repeatcnt) { // "infinite" repeat - texbottom = openbottom + side->rowoffset; - textop = opentop + side->rowoffset; - } else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) { - texbottom = openbottom + side->rowoffset; - textop = texbottom + texheight*(side->repeatcnt+1); - } else { - textop = opentop + side->rowoffset; - texbottom = textop - texheight*(side->repeatcnt+1); - } + texbottom = openbottom + side->rowoffset; + textop = opentop + side->rowoffset; + } + else if (!!(linedef->flags & ML_DONTPEGBOTTOM) ^ !!(linedef->flags & ML_EFFECT3)) + { + texbottom = openbottom + side->rowoffset; + textop = texbottom + texheight*(side->repeatcnt+1); + } + else + { + textop = opentop + side->rowoffset; + texbottom = textop - texheight*(side->repeatcnt+1); } texmid = texbottom+(textop-texbottom)/2; @@ -538,10 +549,13 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - texmid); delta2 = abs(thingtop - texmid); - if (delta1 > delta2) { // Below + if (delta1 > delta2) // Below + { if (opentop > texbottom) opentop = texbottom; - } else { // Above + } + else // Above + { if (openbottom < textop) openbottom = textop; } @@ -549,9 +563,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) } // Check for fake floors in the sector. - if (front->ffloors || back->ffloors - || linedef->polyobj - ) + if (front->ffloors || back->ffloors || linedef->polyobj) { ffloor_t *rover; @@ -567,6 +579,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) for (rover = front->ffloors; rover; rover = rover->next) { fixed_t topheight, bottomheight; + if (!(rover->flags & FF_EXISTS)) continue; @@ -584,7 +597,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { - if (bottomheight < lowestceiling) { + if (bottomheight < lowestceiling) + { lowestceiling = bottomheight; ceilingslope = *rover->b_slope; } @@ -594,7 +608,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF { - if (topheight > highestfloor) { + if (topheight > highestfloor) + { highestfloor = topheight; floorslope = *rover->t_slope; } @@ -624,7 +639,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 >= delta2 && !(rover->flags & FF_PLATFORM)) // thing is below FOF { - if (bottomheight < lowestceiling) { + if (bottomheight < lowestceiling) + { lowestceiling = bottomheight; ceilingslope = *rover->b_slope; } @@ -634,7 +650,8 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (delta1 < delta2 && !(rover->flags & FF_REVERSEPLATFORM)) // thing is above FOF { - if (topheight > highestfloor) { + if (topheight > highestfloor) + { highestfloor = topheight; floorslope = *rover->t_slope; } @@ -650,29 +667,35 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) delta1 = abs(mobj->z - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); delta2 = abs(thingtop - (polysec->floorheight + ((polysec->ceilingheight - polysec->floorheight)/2))); - if (polysec->floorheight < lowestceiling && delta1 >= delta2) { + + if (polysec->floorheight < lowestceiling && delta1 >= delta2) + { lowestceiling = polysec->floorheight; ceilingslope = NULL; } else if (polysec->floorheight < highestceiling && delta1 >= delta2) highestceiling = polysec->floorheight; - if (polysec->ceilingheight > highestfloor && delta1 < delta2) { + if (polysec->ceilingheight > highestfloor && delta1 < delta2) + { highestfloor = polysec->ceilingheight; floorslope = NULL; } else if (polysec->ceilingheight > lowestfloor && delta1 < delta2) lowestfloor = polysec->ceilingheight; } + if (highestceiling < highceiling) highceiling = highestceiling; - if (highestfloor > openbottom) { + if (highestfloor > openbottom) + { openbottom = highestfloor; openbottomslope = floorslope; } - if (lowestceiling < opentop) { + if (lowestceiling < opentop) + { opentop = lowestceiling; opentopslope = ceilingslope; } @@ -759,9 +782,6 @@ void P_UnsetPrecipThingPosition(precipmobj_t *thing) if (bprev && (*bprev = bnext) != NULL) // unlink from block map bnext->bprev = bprev; - - precipsector_list = thing->touching_sectorlist; - thing->touching_sectorlist = NULL; //to be restored by P_SetPrecipThingPosition } static void P_LinkToBlockMap(mobj_t *thing, mobj_t **bmap) @@ -906,10 +926,6 @@ void P_SetPrecipitationThingPosition(precipmobj_t *thing) { thing->subsector = R_PointInSubsector(thing->x, thing->y); - P_CreatePrecipSecNodeList(thing, thing->x, thing->y); - thing->touching_sectorlist = precipsector_list; // Attach to Thing's precipmobj_t - precipsector_list = NULL; // clear for next time - // NOTE: this works because bnext/bprev are at the same // offsets in precipmobj_t and mobj_t P_LinkToBlockMap((mobj_t*)thing, (mobj_t**)precipblocklinks); diff --git a/src/p_mobj.c b/src/p_mobj.c index 30bc10c9a..df2964df5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -435,7 +435,7 @@ void P_ExplodeMissile(mobj_t *mo) } // Hack: Release an animal. - P_DamageMobj(mo, NULL, NULL, 10000); + P_DamageMobj(mo, NULL, NULL, DMG_INSTAKILL); } mo->flags &= ~MF_MISSILE; @@ -1357,12 +1357,16 @@ void P_XYMovement(mobj_t *mo) oldy = mo->y; // adjust various things based on slope - if (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8) { - if (!P_IsObjectOnGround(mo)) { // We fell off at some point? Do the twisty thing! + if (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8) + { + if (!P_IsObjectOnGround(mo)) // We fell off at some point? Do the twisty thing! + { P_SlopeLaunch(mo); xmove = mo->momx; ymove = mo->momy; - } else { // Still on the ground. + } + else // Still on the ground. + { slopemom.x = xmove; slopemom.y = ymove; slopemom.z = 0; @@ -1375,7 +1379,8 @@ void P_XYMovement(mobj_t *mo) oldslope = mo->standingslope; } - } else if (P_IsObjectOnGround(mo) && !mo->momz) + } + else if (P_IsObjectOnGround(mo) && !mo->momz) predictedz = mo->z; // Pushables can break some blocks @@ -1882,13 +1887,13 @@ boolean P_CheckDeathPitCollide(mobj_t *mo) I_Assert(mo != NULL); I_Assert(!P_MobjWasRemoved(mo)); - INT32 special = GETSECSPECIAL(mo->subsector->sector->special, 1); + const INT32 secspecial = GETSECSPECIAL(mo->subsector->sector->special, 1); if (((mo->z <= mo->subsector->sector->floorheight && !(mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_FLOOR)) || (mo->z + mo->height >= mo->subsector->sector->ceilingheight && (mo->eflags & MFE_VERTICALFLIP) && (mo->subsector->sector->flags & SF_FLIPSPECIAL_CEILING))) - && (special == 6 || special == 7)) + && (secspecial == 6 || secspecial == 7)) return true; return false; @@ -2480,55 +2485,58 @@ static void P_PlayerZMovement(mobj_t *mo) msecnode_t *node; boolean stopmovecut = false; - for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) + if (numPolyObjects) { - sector_t *sec = node->m_sector; - subsector_t *newsubsec; - size_t i; - - for (i = 0; i < numsubsectors; i++) + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) { - newsubsec = &subsectors[i]; + sector_t *sec = node->m_sector; + subsector_t *newsubsec; + size_t i; - if (newsubsec->sector != sec) - continue; - - if (!newsubsec->polyList) - continue; - - polyobj_t *po = newsubsec->polyList; - sector_t *polysec; - - while(po) + for (i = 0; i < numsubsectors; i++) { - if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) - { - po = (polyobj_t *)(po->link.next); + newsubsec = &subsectors[i]; + + if (newsubsec->sector != sec) continue; - } - // We're inside it! Yess... - polysec = po->lines[0]->backsector; - - // Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red - if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker) - stopmovecut = true; - - if (!(po->flags & POF_LDEXEC)) - { - po = (polyobj_t *)(po->link.next); + if (!newsubsec->polyList) continue; - } - if (mo->z == polysec->ceilingheight) + polyobj_t *po = newsubsec->polyList; + sector_t *polysec; + + while(po) { - // We're landing on a PO, so check for - // a linedef executor. - // Trigger tags are 32000 + the PO's ID number. - P_LinedefExecute((INT16)(32000 + po->id), mo, NULL); - } + if (!P_MobjInsidePolyobj(po, mo) || !(po->flags & POF_SOLID)) + { + po = (polyobj_t *)(po->link.next); + continue; + } - po = (polyobj_t *)(po->link.next); + // We're inside it! Yess... + polysec = po->lines[0]->backsector; + + // Moving polyobjects should act like conveyors if the player lands on one. (I.E. none of the momentum cut thing below) -Red + if ((mo->z == polysec->ceilingheight || mo->z+mo->height == polysec->floorheight) && po->thinker) + stopmovecut = true; + + if (!(po->flags & POF_LDEXEC)) + { + po = (polyobj_t *)(po->link.next); + continue; + } + + if (mo->z == polysec->ceilingheight) + { + // We're landing on a PO, so check for + // a linedef executor. + // Trigger tags are 32000 + the PO's ID number. + P_LinedefExecute((INT16)(32000 + po->id), mo, NULL); + } + + po = (polyobj_t *)(po->link.next); + } } } } @@ -2999,11 +3007,6 @@ void P_MobjCheckWater(mobj_t *mobj) else if (mobj->eflags & MFE_VERTICALFLIP && mobj->momz > FixedMul(-min, mobj->scale)) mobj->momz = FixedMul(-min, mobj->scale); - /*if (!(mobj->eflags & MFE_VERTICALFLIP) && mobj->momz > FixedMul(max, mobj->scale)) - mobj->momz = FixedMul(max, mobj->scale); - else if (mobj->eflags & MFE_VERTICALFLIP && mobj->momz < FixedMul(-max, mobj->scale)) - mobj->momz = FixedMul(-max, mobj->scale);*/ - p->kartstuff[k_waterskip]++; } @@ -3141,7 +3144,7 @@ static boolean P_CameraCheckHeat(camera_t *thiscam) sector_t *sector; fixed_t halfheight; - if (!thiscam) + if (!thiscam || !thiscam->subsector) return false; halfheight = thiscam->z + (thiscam->height >> 1); @@ -3179,7 +3182,7 @@ static boolean P_CameraCheckWater(camera_t *thiscam) sector_t *sector; fixed_t halfheight; - if (!thiscam) + if (!thiscam || !thiscam->subsector) return false; halfheight = thiscam->z + (thiscam->height >> 1); @@ -3232,16 +3235,23 @@ void P_DestroyRobots(void) } // the below is chasecam only, if you're curious. check out P_CalcPostImg in p_user.c for first person -static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) +void P_CalcChasePostImg(player_t *player, camera_t *thiscam) { const boolean flipcam = (player->pflags & PF_FLIPCAM && !(player->pflags & PF_NIGHTSMODE) && player->mo->eflags & MFE_VERTICALFLIP); - UINT16 postimgflags = 0; - UINT8 i; + UINT8 postimgtype = 0; if (encoremode) - postimgflags |= POSTIMG_MIRROR; + postimgtype |= POSTIMG_MIRROR; if (flipcam) - postimgflags |= POSTIMG_FLIP; + postimgtype |= POSTIMG_FLIP; + +#ifdef HWRENDER + if (rendermode == render_opengl && splitscreen) + { + thiscam->postimg = postimgtype; + return; + } +#endif if (player->awayviewtics && player->awayviewmobj && !P_MobjWasRemoved(player->awayviewmobj)) // Camera must obviously exist { @@ -3256,27 +3266,20 @@ static void P_CalcChasePostImg(player_t *player, camera_t *thiscam) // Are we in water? if (P_CameraCheckWater(&dummycam)) - postimgflags |= POSTIMG_WATER; - if (P_CameraCheckHeat(&dummycam)) - postimgflags |= POSTIMG_HEAT; + postimgtype |= POSTIMG_WATER; + else if (P_CameraCheckHeat(&dummycam)) + postimgtype |= POSTIMG_HEAT; } else { // Are we in water? if (P_CameraCheckWater(thiscam)) - postimgflags |= POSTIMG_WATER; - if (P_CameraCheckHeat(thiscam)) - postimgflags |= POSTIMG_HEAT; + postimgtype |= POSTIMG_WATER; + else if (P_CameraCheckHeat(thiscam)) + postimgtype |= POSTIMG_HEAT; } - for (i = 0; i <= splitscreen; i++) - { - if (player != &players[displayplayers[i]]) - continue; - - players[displayplayers[i]].postimgflags = postimgflags; - break; - } + thiscam->postimg = postimgtype; } // P_CameraThinker @@ -3564,7 +3567,7 @@ animonly: } } -static void CalculatePrecipFloor(precipmobj_t *mobj) +static void P_CalculatePrecipFloor(precipmobj_t *mobj, boolean spawn) { // recalculate floorz each time const sector_t *mobjsecsubsec; @@ -3574,6 +3577,10 @@ static void CalculatePrecipFloor(precipmobj_t *mobj) else return; + // no need to recalc anything if not moved + if (!spawn && !mobjsecsubsec->moved) + return; + mobj->floorz = P_GetSectorFloorZAt(mobjsecsubsec, mobj->x, mobj->y); if (mobjsecsubsec->ffloors) @@ -3598,19 +3605,6 @@ static void CalculatePrecipFloor(precipmobj_t *mobj) } } -void P_RecalcPrecipInSector(sector_t *sector) -{ - mprecipsecnode_t *psecnode; - - if (!sector) - return; - - sector->moved = true; // Recalc lighting and things too, maybe - - for (psecnode = sector->touching_preciplist; psecnode; psecnode = psecnode->m_thinglist_next) - CalculatePrecipFloor(psecnode->m_thing); -} - // // P_NullPrecipThinker // @@ -3677,6 +3671,9 @@ boolean P_PrecipThinker(precipmobj_t *mobj) if (mobj->precipflags & PCF_SPLASH) return true; + if (renderisnewtic) + P_CalculatePrecipFloor(mobj, false); + // adjust height if ((mobj->z += mobj->momz) <= mobj->floorz) { @@ -4847,7 +4844,13 @@ static void P_Boss7Thinker(mobj_t *mobj) continue; mo2 = (mobj_t *)th; - if (mo2->type == MT_BOSS3WAYPOINT && mo2->spawnpoint && (mo2->spawnpoint->options & 7) == waypointNum) + + if (mo2->type != MT_BOSS3WAYPOINT) + continue; + if (!mo2->spawnpoint) + continue; + + if ((mo2->spawnpoint->options & 7) == waypointNum) { hitspot = mo2; break; @@ -5690,9 +5693,6 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y if (!dest || dest->health <= 0 || !dest->player || !source->tracer) return; - // change angle - //source->angle = R_PointToAngle2(source->x, source->y, tx, ty); - // change slope dist = P_AproxDistance(P_AproxDistance(tx - source->x, ty - source->y), tz - source->z); @@ -6033,17 +6033,21 @@ 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 = FixedAngle(0); - mobj->slopepitch = FixedAngle(0); + mobj->sloperoll = 0; + mobj->slopepitch = 0; return; } - K_RollMobjBySlopes(mobj, cv_sloperolldist.value && !splitscreen); + K_RollMobjBySlopes(mobj, mobj->standingslope); } angle_t P_MobjPitchAndRoll(mobj_t *mobj) @@ -7054,8 +7058,21 @@ void P_MobjThinker(mobj_t *mobj) } break; //{ SRB2kart Items - Death States - case MT_ORBINAUT: case MT_BANANA: + if (cv_sloperoll.value == 2 && 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 + else if (cv_bananthrowroll.value == 2) + mobj->rollangle += spin; + + //if (P_IsObjectOnGround(mobj) && mobj->momz * P_MobjFlip(mobj) <= 0) + } + /* FALLTHRU */ + case MT_ORBINAUT: case MT_EGGMANITEM: case MT_SPB: if (P_IsObjectOnGround(mobj)) @@ -7797,6 +7814,18 @@ void P_MobjThinker(mobj_t *mobj) } case MT_BANANA: case MT_EGGMANITEM: + if (cv_sloperoll.value == 2 && 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 + else if (cv_bananthrowroll.value == 2) + mobj->rollangle -= spin; + } + mobj->friction = ORIG_FRICTION/4; if (mobj->momx || mobj->momy) P_SpawnGhostMobj(mobj); @@ -9443,10 +9472,13 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) } // Sprite rendering + mobj->blendmode = AST_TRANSLUCENT; mobj->realxscale = mobj->realyscale = mobj->scale; mobj->spritexscale = mobj->realxscale; mobj->spriteyscale = mobj->realyscale; - mobj->spritexoffset = mobj->spriteyoffset = 0; + mobj->realxoffset = mobj->realyoffset = 0; + mobj->spritexoffset = mobj->realxoffset; + mobj->spriteyoffset = mobj->realyoffset; // Funni slam sound when landing mobj->slamsoundtimer = 0; @@ -9877,6 +9909,7 @@ mobj_t *P_SpawnShadowMobj(mobj_t * caster) mobj->radius = info->radius; mobj->height = info->height; mobj->flags = info->flags; + mobj->blendmode = AST_TRANSLUCENT; mobj->health = info->spawnhealth; @@ -10006,9 +10039,9 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->momz = cv_mobjscaleprecip.value ? FixedMul(info->speed, mapobjectscale) : info->speed; mobj->thinker.function.acp1 = (actionf_p1)P_NullPrecipThinker; - P_AddThinker(&mobj->thinker); + P_AddPrecipThinker(&mobj->thinker); - CalculatePrecipFloor(mobj); + P_CalculatePrecipFloor(mobj, true); if (mobj->floorz != starting_floorz) mobj->precipflags |= PCF_FOF; @@ -10168,12 +10201,6 @@ void P_FreePrecipMobj(precipmobj_t *mobj) // unlink from sector and block lists P_UnsetPrecipThingPosition(mobj); - if (precipsector_list) - { - P_DelPrecipSeclist(precipsector_list); - precipsector_list = NULL; - } - // free block // Precipmobjs don't actually think using their thinker, // so the free cannot be delayed. @@ -10187,12 +10214,6 @@ void P_RemoveSavegameMobj(mobj_t *mobj) if (((thinker_t *)mobj)->function.acp1 == (actionf_p1)P_NullPrecipThinker) { P_UnsetPrecipThingPosition((precipmobj_t *)mobj); - - if (precipsector_list) - { - P_DelPrecipSeclist(precipsector_list); - precipsector_list = NULL; - } } else { @@ -10225,28 +10246,26 @@ consvar_t cv_suddendeath = {"suddendeath", "Off", CV_NETVAR|CV_CHEAT|CV_NOSHOWHE void P_SpawnPrecipitation(void) { - INT32 i, mrand; - fixed_t basex, basey, j, x, y, z; + INT32 i, j, mrand; + fixed_t basex, basey, x, y, z; subsector_t *precipsector = NULL; precipmobj_t *rainmo = NULL; - if (dedicated || !cv_drawdist_precip.value || curWeather == PRECIP_NONE) // SRB2Kart + if (dedicated || !cv_drawdist_precip.value || curWeather == PRECIP_NONE || curWeather == PRECIP_STORM_NORAIN) return; - fixed_t density = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); - - if (cv_lessprecip.value) - density *= 2; // just spawn half the precip + const fixed_t precipmoscale = (cv_mobjscaleprecip.value ? mapobjectscale : FRACUNIT); + const INT32 density = (cv_lessprecip.value ? 2 : 1); // only spawn half as much // Use the blockmap to narrow down our placing patterns - for (i = 0; i < bmapwidth*bmapheight; ++i) + for (i = 0; i < bmapwidth*bmapheight; i += density) { basex = bmaporgx + (i % bmapwidth) * MAPBLOCKSIZE; basey = bmaporgy + (i / bmapwidth) * MAPBLOCKSIZE; // If mobjscale < FRACUNIT, each blockmap cell covers // more area so spawn more precipitation in that area. - for (j = 0; j < FRACUNIT; j += density) + for (j = 0; j < FRACUNIT; j += precipmoscale) { INT32 floorz; INT32 ceilingz; @@ -10284,6 +10303,9 @@ void P_SpawnPrecipitation(void) else // everything else. rainmo = P_SpawnPrecipMobj(x, y, z, MT_RAIN); + if (curWeather == PRECIP_BLANK) + rainmo->precipflags |= PCF_INVISIBLE; + floorz = rainmo->floorz >> FRACBITS; ceilingz = rainmo->ceilingz >> FRACBITS; @@ -10299,17 +10321,6 @@ void P_SpawnPrecipitation(void) } } } - - if (curWeather == PRECIP_BLANK) - { - curWeather = PRECIP_RAIN; - P_SwitchWeather(PRECIP_BLANK); - } - else if (curWeather == PRECIP_STORM_NORAIN) - { - curWeather = PRECIP_RAIN; - P_SwitchWeather(PRECIP_STORM_NORAIN); - } } // @@ -10621,7 +10632,9 @@ void P_SpawnPlayer(INT32 playernum) if (multiplayer && demo.playback) ; // Don't mess with spectator values since the demo setup handles them already. else if (!G_GametypeHasSpectators()) + { p->spectator = false; + } else if (netgame && p->jointime <= 1 && pcount) { p->spectator = true; @@ -10653,7 +10666,9 @@ void P_SpawnPlayer(INT32 playernum) SendNetXCmd(XD_TEAMCHANGE, &usvalue, sizeof(usvalue)); } else // Otherwise, never spectator. + { p->spectator = false; + } } if (G_GametypeHasTeams()) @@ -10713,6 +10728,8 @@ void P_SpawnPlayer(INT32 playernum) p->hitemtimer = 0; p->hitemvictim = 255; + p->spinoutrot = 0; + if (G_BattleGametype()) // SRB2kart { mobj_t *overheadarrow = P_SpawnMobj(mobj->x, mobj->y, mobj->z + P_GetPlayerHeight(p)+16*FRACUNIT, MT_PLAYERARROW); @@ -10758,6 +10775,30 @@ void P_SpawnPlayer(INT32 playernum) P_SetScale(karmahitbox, mobj->scale); } } + + // TODO: handle splitscreen + // Spectators can switch to freecam. This should be + // disabled when they enter the race, or when the level + // changes. + if (!demo.playback) + { + if (!p->spectator) + { + if (playernum == consoleplayer) + camera[0].freecam = false; + else if (splitscreen) + { + for (i = 1; i <= splitscreen; i++) + { + if (playernum == displayplayers[i]) + { + camera[i].freecam = false; + break; + } + } + } + } + } } void P_AfterPlayerSpawn(INT32 playernum) @@ -10800,15 +10841,18 @@ void P_AfterPlayerSpawn(INT32 playernum) SV_SpawnPlayer(playernum, mobj->x, mobj->y, mobj->angle); - for (i = 0; i <= splitscreen; i++) + if (p->spectator == false) { - if (!camera[i].chase) - continue; + for (i = 0; i <= splitscreen; i++) + { + if (!camera[i].chase) + continue; - if (displayplayers[i] != playernum) - continue; + if (displayplayers[i] != playernum) + continue; - P_ResetCamera(p, &camera[i]); + P_ResetCamera(p, &camera[i]); + } } if (CheckForReverseGravity) @@ -11607,7 +11651,7 @@ ML_NOCLIMB : Direction not controllable mobj_t *elecmobj; elecmobj = P_SpawnMobj(x, y, z, MT_CYBRAKDEMON_ELECTRIC_BARRIER); P_SetTarget(&elecmobj->target, mobj); - elecmobj->angle = FixedAngle(mthing->angle*FRACUNIT);; + elecmobj->angle = FixedAngle(mthing->angle*FRACUNIT); elecmobj->destscale = mobj->scale*2; P_SetScale(elecmobj, elecmobj->destscale); } diff --git a/src/p_mobj.h b/src/p_mobj.h index 0529c4891..46c7f6fae 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -289,6 +289,7 @@ typedef struct mobj_s UINT32 frame; // frame number, plus bits see p_pspr.h UINT16 anim_duration; // for FF_ANIMATE states + INT32 blendmode; // blend mode fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; @@ -296,6 +297,7 @@ typedef struct mobj_s INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch + fixed_t realxoffset, realyoffset; fixed_t stretchslam; // "squish" effect when you land @@ -394,7 +396,6 @@ typedef struct mobj_s boolean resetinterp; // if true, some fields should not be interpolated (see R_InterpolateMobjState implementation) 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 - boolean rollmodel; // OpenGL: Should this model rotate? tic_t slamsoundtimer; @@ -442,6 +443,7 @@ typedef struct precipmobj_s UINT32 frame; // frame number, plus bits see p_pspr.h UINT16 anim_duration; // for FF_ANIMATE states + INT32 blendmode; // blend mode fixed_t spritexscale, spriteyscale; fixed_t spritexoffset, spriteyoffset; fixed_t old_spritexscale, old_spriteyscale; @@ -449,6 +451,7 @@ typedef struct precipmobj_s INT16 lightlevel; // Add to sector lightlevel, -255 - 255 fixed_t realxscale, realyscale; // funn-E streeetch + fixed_t realxoffset, realyoffset; fixed_t stretchslam; // "squish" effect when you land diff --git a/src/p_pspr.h b/src/p_pspr.h index 2c173608b..90cfc40fc 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -41,12 +41,18 @@ #define FF_HORIZONTALFLIP 0x400 /// \brief Frame flags: Thin, paper-like sprite (for collision equivalent, see MF_PAPERCOLLISION) #define FF_PAPERSPRITE 0x800 -/// \brief mobj_t.lightlevel is absolute instead of relative -#define FF_ABSOLUTELIGHTLEVEL 0x2000 -/// \brief Frame flags: Simple stateless animation -#define FF_ANIMATE 0x4000 -/// \brief Frame flags: frame always appears full bright -#define FF_FULLBRIGHT 0x8000 + +/// \brief Frame flags: blend types +#define FF_BLENDMASK 0x7000 +/// \brief shift for FF_BLENDMASK +#define FF_BLENDSHIFT 12 +/// \brief preshifted blend flags minus 1 as effects don't distinguish between AST_COPY and AST_TRANSLUCENT +#define FF_ADD ((AST_ADD-1)<next) { - if (!(th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed - || th->function.acp1 == (actionf_p1)P_NullPrecipThinker)) + if (th->function.acp1 != (actionf_p1)P_RemoveThinkerDelayed) numsaved++; if (th->function.acp1 == (actionf_p1)P_MobjThinker) @@ -1689,9 +1688,6 @@ static void P_NetArchiveThinkers(savebuffer_t *save) SaveMobjThinker(save, th, tc_mobj); continue; } -#ifdef PARANOIA - else if (th->function.acp1 == (actionf_p1)P_NullPrecipThinker); -#endif else if (th->function.acp1 == (actionf_p1)T_MoveCeiling) { SaveCeilingThinker(save, th, tc_ceiling); @@ -2151,12 +2147,11 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->mirrored = 0; // Sprite Rendering stuff - mobj->spritexoffset = 0; - mobj->spriteyoffset = 0; - mobj->spritexscale = FRACUNIT; - mobj->spriteyscale = FRACUNIT; - mobj->realxscale = FRACUNIT; - mobj->realyscale = FRACUNIT; + 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 @@ -2674,6 +2669,8 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) { thinker_t *currentthinker; thinker_t *next; + thinker_t *currentprecipthinker; + thinker_t *nextprecip; UINT8 tclass; UINT8 restoreNum = false; UINT32 i; @@ -2688,7 +2685,7 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) { next = currentthinker->next; - if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker || currentthinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) + if (currentthinker->function.acp1 == (actionf_p1)P_MobjThinker) P_RemoveSavegameMobj((mobj_t *)currentthinker); // item isn't saved, don't remove it else { @@ -2698,6 +2695,24 @@ static void P_NetUnArchiveThinkers(savebuffer_t *save) } } + // remove all the current precip thinkers + currentprecipthinker = precipcap.next; + for (currentprecipthinker = precipcap.next; currentprecipthinker != &precipcap; currentprecipthinker = nextprecip) + { + nextprecip = currentprecipthinker->next; + +#ifdef PARANOIA + if (currentprecipthinker->function.acp1 != (actionf_p1)P_NullPrecipThinker) + { + (next->prev = currentprecipthinker->prev)->next = nextprecip; + R_DestroyLevelInterpolators(currentprecipthinker); + Z_Free(currentprecipthinker); + } + else +#endif + P_RemoveSavegameMobj((mobj_t *)currentprecipthinker); // item isn't saved, don't remove it + } + // we don't want the removed mobjs to come back iquetail = iquehead = 0; P_InitThinkers(); @@ -3336,7 +3351,7 @@ FUNCINLINE static ATTRINLINE boolean P_NetUnArchiveMisc(savebuffer_t *save, bool // tell the sound code to reset the music since we're skipping what // normally sets this flag if (!reloading) - mapmusflags |= MUSIC_RELOADRESET; + mapmusic.flags |= MUSIC_RELOADRESET; G_SetGamestate(READINT16(save->p)); diff --git a/src/p_setup.c b/src/p_setup.c index 27f8ba3a3..17a46d931 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -91,6 +91,9 @@ // unsigned char mapmd5[16]; +// true when level was loaded from netsave +boolean midgamejoin = false; + // // MAP related Lookup tables. // Store VERTEXES, LINEDEFS, SIDEDEFS, etc. @@ -247,8 +250,6 @@ static SINT8 partadd_stage = -1; static boolean partadd_replacescurrentmap = false; static boolean partadd_important = false; -SINT8 midgamejoin = 0; - /** Logs an error about a map being corrupt, then terminate. * This allows reporting highly technical errors for usefulness, without * confusing a novice map designer who simply needs to run ZenNode. @@ -872,8 +873,6 @@ static void P_LoadRawSectors(UINT8 *data) ss->thinglist = NULL; ss->touching_thinglist = NULL; - ss->touching_preciplist = NULL; - ss->floordata = NULL; ss->ceilingdata = NULL; ss->lightingdata = NULL; @@ -1207,6 +1206,9 @@ static void P_SetupLines(void) ld->dx = v2->x - v1->x; ld->dy = v2->y - v1->y; + ld->alpha = FRACUNIT; + ld->blendmode = 0; + if (!ld->dx) ld->slopetype = ST_VERTICAL; else if (!ld->dy) @@ -1314,6 +1316,26 @@ static void P_LoadLineDefs2(void) } break; } + + // Set alpha for translucent walls + if (ld->special >= 900 && ld->special < 909) + ld->alpha = ((909 - ld->special) << FRACBITS)/10; + + // Set alpha for additive/subtractive/reverse subtractive walls + if (ld->special >= 910 && ld->special <= 939) + ld->alpha = ((10 - ld->special % 10) << FRACBITS)/10; + + if (ld->special >= 910 && ld->special <= 919) // additive + ld->blendmode = AST_ADD; + + if (ld->special >= 920 && ld->special <= 929) // subtractive + ld->blendmode = AST_SUBTRACT; + + if (ld->special >= 930 && ld->special <= 939) // reverse subtractive + ld->blendmode = AST_REVERSESUBTRACT; + + if (ld->special == 940) // modulate + ld->blendmode = AST_MODULATE; } } @@ -1592,8 +1614,10 @@ static void P_LoadRawSideDefs2(void *data) if (msd->toptexture[0] == '#') { char *col = msd->toptexture; - sd->toptexture = sd->bottomtexture = - ((col[1]-'0')*100 + (col[2]-'0')*10 + col[3]-'0') + 1; + sd->toptexture = + ((col[1]-'0')*100 + (col[2]-'0')*10 + col[3]-'0')+1; + if (col[4]) // extra num for blendmode + sd->toptexture += (col[4]-'0')*1000; sd->midtexture = R_TextureNumForName(msd->midtexture); } else @@ -2223,7 +2247,13 @@ static void P_LevelInitStuff(boolean reloadinggamestate) players[i].lives = 1; // SRB2Kart players[i].realtime = racecountdown = exitcountdown = 0; - curlap = bestlap = 0; // SRB2Kart + + for (INT32 j = 0; j < LAP__MAX; j++) + { + players[i].laptime[j] = 0; + } + + players[i].driftsparkGrowTimer = 0; players[i].gotcontinue = false; @@ -2596,27 +2626,33 @@ static void P_SetupCamera(UINT8 pnum, camera_t *cam) cam->angle = FixedAngle((fixed_t)thing->angle << FRACBITS); cam->subsector = R_PointInSubsector(cam->x, cam->y); // make sure camera has a subsector set -- Monster Iestyn (12/11/18) } + + cam->chase = false; // tell camera to reset its position next tic } static void P_InitCamera(void) { INT32 i; - if (!dedicated) + if (dedicated) + return; + + for (i = 0; i <= splitscreen; i++) { - if (!demo.freecam) - for (i = 0; i <= splitscreen; i++) - P_SetupCamera(displayplayers[i], &camera[i]); + if (camera[i].freecam) + continue; - // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (!cv_cam_rotate[i].changed) - CV_Set(&cv_cam_rotate[i], cv_cam_rotate[i].defaultvalue); - } - - displayplayers[0] = consoleplayer; // Start with your OWN view, please! + P_SetupCamera(displayplayers[i], &camera[i]); } + + // Though, I don't think anyone would care about cam_rotate being reset back to the only value that makes sense :P + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (!cv_cam_rotate[i].changed) + CV_Set(&cv_cam_rotate[i], cv_cam_rotate[i].defaultvalue); + } + + displayplayers[0] = consoleplayer; // Start with your OWN view, please! } static boolean P_CanSave(void) @@ -2627,7 +2663,7 @@ static boolean P_CanSave(void) struct minimapinfo minimapinfo; static void P_InitMinimapInfo(void) { - INT32 lumpnum; + lumpnum_t lumpnum; fixed_t a; fixed_t b; node_t *bsp = &nodes[numnodes-1]; @@ -2636,11 +2672,9 @@ static void P_InitMinimapInfo(void) lumpnum = W_CheckNumForName(va("%sR", G_BuildMapName(gamemap))); - if (lumpnum != -1) + if (lumpnum != LUMPERROR) minimapinfo.minimap_pic = W_CachePatchName(va("%sR", G_BuildMapName(gamemap)), PU_HUDGFX); - minimapinfo.mapthingcount = 0; - // TODO iterate over mapthings to look for possible user-defined bounds minimapinfo.min_x = bsp->bbox[0][BOXLEFT]; minimapinfo.max_x = bsp->bbox[0][BOXRIGHT]; minimapinfo.min_y = bsp->bbox[0][BOXBOTTOM]; @@ -2689,72 +2723,8 @@ static void P_InitMinimapInfo(void) minimapinfo.offs_y = FixedMul((minimapinfo.min_y + minimapinfo.map_h/2) << FRACBITS, minimapinfo.zoom); } -/** Loads a level from a lump or external wad. - * - * \param skipprecip If true, don't spawn precipitation. - * \todo Clean up, refactor, split up; get rid of the bloat. - */ -boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) +static boolean P_RunSpecialWipe(boolean reloadinggamestate) { - // use gamemap to get map number. - // 99% of the things already did, so. - // Map header should always be in place at this point - INT32 i, loadprecip = 1, ranspecialwipe = 0; - INT32 loademblems = 1; - INT32 fromnetsave = 0; - midgamejoin = 0; - sector_t *ss; - boolean chase; - - levelloading = true; - - // This is needed. Don't touch. - maptol = mapheaderinfo[gamemap-1]->typeoflevel; - - CON_Drawer(); // let the user know what we are going to do - I_FinishUpdate(); // page flip or blit buffer - - // Initialize sector node list. - P_Initsecnode(); - - if (netgame || multiplayer) - cv_debug = botskin = 0; - - if (metalplayback) - G_StopMetalDemo(); - - // Clear CECHO messages - HU_ClearCEcho(); - - if (mapheaderinfo[gamemap-1]->runsoc[0] != '#') - P_RunSOC(mapheaderinfo[gamemap-1]->runsoc); - - if (cv_runscripts.value && mapheaderinfo[gamemap-1]->scriptname[0] != '#') - P_RunLevelScript(mapheaderinfo[gamemap-1]->scriptname); - - P_LevelInitStuff(reloadinggamestate); - - if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0' - && atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255) - P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter); - - // chasecam on in chaos, race, coop - // chasecam off in match, tag, capture the flag - chase = true; // srb2kart: always on - - if (!dedicated) - { - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (!cv_chasecam[i].changed) - CV_SetValue(&cv_chasecam[i], chase); - } - } - - // Initial height of PointOfView - // will be set by player think. - players[consoleplayer].viewz = 1; - // Cancel all d_main.c fadeouts (keep fade in though). if (reloadinggamestate) wipegamestate = gamestate; // Don't fade if reloading the gamestate @@ -2787,7 +2757,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) F_RunWipe(wipedefs[wipe_speclevel_towhite], false); F_RunWipe(wipedefs[wipe_level_final], false); } - + locstarttime = nowtime = lastwipetic; endtime = locstarttime + (3*TICRATE)/2; @@ -2808,162 +2778,15 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) NetKeepAlive(); } - ranspecialwipe = 1; + return true; } - // Make sure all sounds are stopped before Z_FreeTags. - S_StopSounds(); + return false; +} - if (!S_PrecacheSound()) - S_ClearSfx(); - - // As oddly named as this is, this handles music only. - // We should be fine starting it here. - if (!reloadinggamestate) - S_InitMapMusic(); - - levelfadecol = (encoremode && !ranspecialwipe ? 122 : 120); - - // Let's fade to white here - // But only if we didn't do the encore startup wipe - if (!ranspecialwipe && !demo.rewinding && !reloadinggamestate) - { - if (rendermode != render_none) - { - F_WipeStartScreen(); - V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); - - F_WipeEndScreen(); - F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); - } - else //dedicated servers - { - F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); - } - } - - // Reset the palette now all fades have been done - if (rendermode != render_none) - V_SetPaletteLump(GetPalette()); // Set the level palette - - // Print "SPEEDING OFF TO [ZONE] [ACT 1]..." - /*if (rendermode != render_none) - { - // Don't include these in the fade! - char tx[64]; - V_DrawSmallString(1, 191, V_ALLOWLOWERCASE, M_GetText("Speeding off to...")); - snprintf(tx, 63, "%s%s%s", - mapheaderinfo[gamemap-1]->lvlttl, - (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart - ((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " Zone"), - (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) ? va(", Act %s",mapheaderinfo[gamemap-1]->actnum) : ""); - V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx); - I_UpdateNoVsync(); - }*/ - - LUA_InvalidateLevel(); - - for (ss = sectors; sectors+numsectors != ss; ss++) - { - Z_Free(ss->attached); - Z_Free(ss->attachedsolid); - } - - // Clear pointers that would be left dangling by the purge - R_FlushTranslationColormapCache(); - - Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); - -#if defined (WALLSPLATS) || defined (FLOORSPLATS) - // clear the splats from previous level - R_ClearLevelSplats(); -#endif - - mobjcache = NULL; - - R_InitializeLevelInterpolators(); - - P_InitThinkers(); - R_InitMobjInterpolators(); - P_InitCachedActions(); - - /// \note for not spawning precipitation, etc. when loading netgame snapshots - if (skipprecip) - { - fromnetsave = 1; - loadprecip = 0; - loademblems = 0; - midgamejoin = 1; - } - - // internal game map - maplumpname = G_BuildMapName(gamemap); - lastloadedmaplumpnum = W_CheckNumForName(maplumpname); - if (lastloadedmaplumpnum == INT16_MAX) - I_Error("Map %s not found.\n", maplumpname); - - curmapvirt = vres_GetMap(lastloadedmaplumpnum); - - R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, - (encoremode ? W_CheckNumForName(va("%sE", maplumpname)) : LUMPERROR)); - CON_SetupBackColormap(); - - // SRB2 determines the sky texture to be used depending on the map header. - P_SetupLevelSky(mapheaderinfo[gamemap-1]->skynum, true); - - numdmstarts = numredctfstarts = numbluectfstarts = 0; - - // reset the player starts - for (i = 0; i < MAXPLAYERS; i++) - playerstarts[i] = NULL; - for (i = 0; i < 2; i++) - skyboxmo[i] = NULL; - - P_ResetWaypoints(); - - P_MapStart(); - - if (lastloadedmaplumpnum) - P_LoadMapFromFile(); - - P_ResetDynamicSlopes(); - - P_LoadThings(); - - P_SpawnSecretItems(loademblems); - - P_InitMinimapInfo(); - - for (numcoopstarts = 0; numcoopstarts < MAXPLAYERS; numcoopstarts++) - if (!playerstarts[numcoopstarts]) - break; - - globalweather = mapheaderinfo[gamemap-1]->weather; - - // set up world state - P_SpawnSpecials(fromnetsave, reloadinggamestate); - - if (loadprecip) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) - P_SpawnPrecipitation(); - -#ifdef HWRENDER // not win32 only 19990829 by Kin - if (rendermode == render_opengl) - { - HWR_FreeExtraSubsectors(); - - // stuff like HWR_CreatePlanePolygons is called there - HWR_LoadLevel(); - } -#endif - - // oh god I hope this helps - // (addendum: apparently it does! - // none of this needs to be done because it's not the beginning of the map when - // a netgame save is being loaded, and could actively be harmful by messing with - // the client's view of the data.) - if (fromnetsave) - goto netgameskip; - // ========== +static void P_SetupPlayer(void) +{ + INT32 i; for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) @@ -3014,7 +2837,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) } } - if (realnumplayers) //this should also fix the dedicated crash bug. You only pick a player if one exists to be picked. + if (realnumplayers) // this should also fix the dedicated crash bug. You only pick a player if one exists to be picked. { i = P_RandomKey(realnumplayers); players[playersactive[i]].pflags |= PF_TAGIT; //choose our initial tagger before map starts. @@ -3083,10 +2906,213 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) startedInFreePlay = true; } } +} - // =========== - // landing point for netgames. - netgameskip: +/** Loads a level from a lump or external wad. + * + * \param fromnetsave If true, skip some stuff because we're loading a netgame snapshot. + * \todo Clean up, refactor, split up; get rid of the bloat. + */ +boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) +{ + // use gamemap to get map number. + // 99% of the things already did, so. + // Map header should always be in place at this point + INT32 i; + boolean ranspecialwipe = false; + sector_t *ss; + + midgamejoin = fromnetsave; // makes dynslopes run in P_Ticker/P_PreTicker to avoid synch issues and other stuff + + levelloading = true; + + // This is needed. Don't touch. + maptol = mapheaderinfo[gamemap-1]->typeoflevel; + + CON_Drawer(); // let the user know what we are going to do + I_FinishUpdate(); // page flip or blit buffer + + // Initialize sector node list. + P_Initsecnode(); + + if (netgame || multiplayer) + cv_debug = botskin = 0; + + if (metalplayback) + G_StopMetalDemo(); + + // Clear CECHO messages + HU_ClearCEcho(); + + if (mapheaderinfo[gamemap-1]->runsoc[0] != '#') + P_RunSOC(mapheaderinfo[gamemap-1]->runsoc); + + if (cv_runscripts.value && mapheaderinfo[gamemap-1]->scriptname[0] != '#') + P_RunLevelScript(mapheaderinfo[gamemap-1]->scriptname); + + P_LevelInitStuff(reloadinggamestate); + + if (mapheaderinfo[gamemap-1]->forcecharacter[0] != '\0' + && atoi(mapheaderinfo[gamemap-1]->forcecharacter) != 255) + P_ForceCharacter(mapheaderinfo[gamemap-1]->forcecharacter); + + if (!dedicated) + { + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (!cv_chasecam[i].changed) + CV_SetValue(&cv_chasecam[i], true); // srb2kart: always on + } + } + + // Initial height of PointOfView + // will be set by player think. + players[consoleplayer].viewz = 1; + + ranspecialwipe = P_RunSpecialWipe(reloadinggamestate); + + // Make sure all sounds are stopped before Z_FreeTags. + S_StopSounds(); + + if (!S_PrecacheSound()) + S_ClearSfx(); + + // As oddly named as this is, this handles music only. + // We should be fine starting it here. + if (!reloadinggamestate) + S_InitMapMusic(); + + levelfadecol = (encoremode && !ranspecialwipe ? 122 : 120); + + // Let's fade to white here + // But only if we didn't do the encore startup wipe + if (!ranspecialwipe && !demo.rewinding && !reloadinggamestate) + { + if (rendermode != render_none) + { + F_WipeStartScreen(); + V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, levelfadecol); + F_WipeEndScreen(); + F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); + } + else //dedicated servers + { + F_RunWipe(wipedefs[(encoremode ? wipe_level_final : wipe_level_toblack)], false); + } + } + + // Reset the palette now all fades have been done + if (rendermode != render_none) + V_SetPaletteLump(GetPalette()); // Set the level palette + + // Print "SPEEDING OFF TO [ZONE] [ACT 1]..." + /*if (rendermode != render_none) + { + // Don't include these in the fade! + char tx[64]; + V_DrawSmallString(1, 191, V_ALLOWLOWERCASE, M_GetText("Speeding off to...")); + snprintf(tx, 63, "%s%s%s", + mapheaderinfo[gamemap-1]->lvlttl, + (strlen(mapheaderinfo[gamemap-1]->zonttl) > 0) ? va(" %s",mapheaderinfo[gamemap-1]->zonttl) : // SRB2kart + ((mapheaderinfo[gamemap-1]->levelflags & LF_NOZONE) ? "" : " Zone"), + (strlen(mapheaderinfo[gamemap-1]->actnum) > 0) ? va(", Act %s",mapheaderinfo[gamemap-1]->actnum) : ""); + V_DrawSmallString(1, 195, V_ALLOWLOWERCASE, tx); + I_UpdateNoVsync(); + }*/ + + LUA_InvalidateLevel(); + + for (ss = sectors; sectors+numsectors != ss; ss++) + { + Z_Free(ss->attached); + Z_Free(ss->attachedsolid); + } + + // Clear pointers that would be left dangling by the purge + R_FlushTranslationColormapCache(); + + Z_FreeTags(PU_LEVEL, PU_PURGELEVEL - 1); + +#if defined (WALLSPLATS) || defined (FLOORSPLATS) + // clear the splats from previous level + R_ClearLevelSplats(); +#endif + + mobjcache = NULL; + + R_InitializeLevelInterpolators(); + + P_InitThinkers(); + R_InitMobjInterpolators(); + P_InitCachedActions(); + + // internal game map + maplumpname = G_BuildMapName(gamemap); + lastloadedmaplumpnum = W_CheckNumForName(maplumpname); + if (lastloadedmaplumpnum == INT16_MAX) + I_Error("Map %s not found.\n", maplumpname); + + curmapvirt = vres_GetMap(lastloadedmaplumpnum); + + R_ReInitColormaps(mapheaderinfo[gamemap-1]->palette, + (encoremode ? W_CheckNumForName(va("%sE", maplumpname)) : LUMPERROR)); + CON_SetupBackColormap(); + + // SRB2 determines the sky texture to be used depending on the map header. + P_SetupLevelSky(mapheaderinfo[gamemap-1]->skynum, true); + + numdmstarts = numredctfstarts = numbluectfstarts = 0; + + // reset the player starts + for (i = 0; i < MAXPLAYERS; i++) + playerstarts[i] = NULL; + for (i = 0; i < 2; i++) + skyboxmo[i] = NULL; + + P_ResetWaypoints(); + + P_MapStart(); + + if (lastloadedmaplumpnum) + P_LoadMapFromFile(); + + P_ResetDynamicSlopes(); + + P_LoadThings(); + + P_SpawnSecretItems(!fromnetsave); + + P_InitMinimapInfo(); + + for (numcoopstarts = 0; numcoopstarts < MAXPLAYERS; numcoopstarts++) + if (!playerstarts[numcoopstarts]) + break; + + globalweather = mapheaderinfo[gamemap-1]->weather; + + // set up world state + P_SpawnSpecials(fromnetsave, reloadinggamestate); + + if (!fromnetsave) // ugly hack for P_NetUnArchiveMisc (and P_LoadNetGame) + P_SpawnPrecipitation(); + +#ifdef HWRENDER // not win32 only 19990829 by Kin + if (rendermode == render_opengl) + { + HWR_FreeExtraSubsectors(); + + // stuff like HWR_CreatePlanePolygons is called there + HWR_LoadLevel(); + } +#endif + + // oh god I hope this helps + // (addendum: apparently it does! + // none of this needs to be done because it's not the beginning of the map when + // a netgame save is being loaded, and could actively be harmful by messing with + // the client's view of the data.) + if (!fromnetsave) + P_SetupPlayer(); if (!reloadinggamestate) { @@ -3136,7 +3162,7 @@ boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate) skyVisible = true; memset(skyVisiblePerPlayer, true, sizeof(skyVisiblePerPlayer)); - if (loadprecip) // uglier hack + if (!fromnetsave) // uglier hack { // to make a newly loaded level start on the second frame. INT32 buf = gametic % TICQUEUE; for (i = 0; i < MAXPLAYERS; i++) @@ -3208,6 +3234,12 @@ boolean P_AddWadFileLocal(const char *wadfilename) return true; } +// check for replacement votescreen backgrounds +boolean wideracereplaced = false; +boolean racereplaced = false; +boolean widebattlereplaced = false; +boolean battlereplaced = false; + // // Add a WAD file and do the per-WAD setup stages. // Call P_MultiSetupWadFiles as soon as possible after any number of these. @@ -3332,6 +3364,41 @@ UINT16 P_PartialAddWadFile(const char *wadfilename, boolean local) // TODO: Experimental SPRTINFO support, test first R_LoadSpriteInfoLumps(wadnum, wadfiles[wadnum]->numlumps); + // + // check for votescreen replacements + // + lumpinfo = wadfiles[wadnum]->lumpinfo; + for (i = 0; i < numlumps; i++, lumpinfo++) + { + name = lumpinfo->name; + + // widescreen patch Race + if (!wideracereplaced && !strncmp(name, "INTERSCW", 8)) + { + wideracereplaced = true; + continue; + } + + if (!racereplaced && !strncmp(name, "INTERSCR", 8)) + { + racereplaced = true; + continue; + } + + // widescreen patch Battle + if (!widebattlereplaced && !strncmp(name, "BATTLSCW", 8)) + { + widebattlereplaced = true; + continue; + } + + if (!battlereplaced && !strncmp(name, "BATTLSCR", 8)) + { + battlereplaced = true; + continue; + } + } + refreshdirmenu &= ~REFRESHDIR_GAMEDATA; // Under usual circumstances we'd wait for REFRESHDIR_GAMEDATA to disappear the next frame, but it's a bit too dangerous for that... partadd_stage = 0; return wadnum; @@ -3361,6 +3428,10 @@ boolean P_MultiSetupWadFiles(boolean fullsetup) ST_LoadGraphics(); ST_ReloadSkinFaceGraphics(); + // reload minimap stuff while were in the map since it may get replaced otherwise + if (gamestate == GS_LEVEL) + P_InitMinimapInfo(); + if (!partadd_important) partadd_stage = -1; // everything done else if (fullsetup) diff --git a/src/p_setup.h b/src/p_setup.h index 79acfff3f..723b48d18 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -19,11 +19,12 @@ #include "r_defs.h" #include "w_wad.h" -extern SINT8 midgamejoin; - // map md5, sent to players via PT_SERVERINFO extern unsigned char mapmd5[16]; +// true when level was loaded from netsave +extern boolean midgamejoin; + // Player spawn spots for deathmatch. #define MAX_DM_STARTS 64 extern mapthing_t *deathmatchstarts[MAX_DM_STARTS]; @@ -60,13 +61,18 @@ extern mapthing_t *mapthings; void P_SetupLevelSky(INT32 skynum, boolean global); void P_LoadThingsOnly(void); -boolean P_SetupLevel(boolean skipprecip, boolean reloadinggamestate); +boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate); #ifdef HWRENDER void HWR_LoadLevel(void); #endif boolean P_AddWadFile(const char *wadfilename, boolean local); boolean P_AddWadFileLocal(const char *wadfilename); +extern boolean wideracereplaced; +extern boolean racereplaced; +extern boolean widebattlereplaced; +extern boolean battlereplaced; + // WARNING: The following functions should be grouped as follows: // any amount of PartialAdds followed by MultiSetups until returned true, // as soon as possible. diff --git a/src/p_sight.c b/src/p_sight.c index 1d71e5553..874ba5ae5 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -42,15 +42,16 @@ static INT32 sightcounts[2]; static INT32 P_DivlineSide(fixed_t x, fixed_t y, const divline_t *node) { fixed_t left, right; - return + + return( !node->dx ? x == node->x ? 2 : x <= node->x ? node->dy > 0 : node->dy < 0 : !node->dy ? y == node->y ? 2 : y <= node->y ? node->dx < 0 : node->dx > 0 : (right = ((y - node->y) >> FRACBITS) * (node->dx >> FRACBITS)) < (left = ((x - node->x) >> FRACBITS) * (node->dy >> FRACBITS)) ? 0 : - right == left ? 2 : 1; + right == left ? 2 : 1); } -static INT32 P_DivlineCrossed(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, const divline_t *node) +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)); } @@ -100,10 +101,6 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) if (P_DivlineCrossed(los->strace.x, los->strace.y, los->t2x, los->t2y, &divl)) continue; - // stop because it is not two sided - //if (!(po->flags & POF_TESTHEIGHT)) - //return false; - frac = P_InterceptVector(&los->strace, &divl); // get slopes of top and bottom of this polyobject line @@ -112,17 +109,11 @@ static boolean P_CrossSubsecPolyObj(polyobj_t *po, register los_t *los) if (topslope >= los->topslope && bottomslope <= los->bottomslope) return false; // view completely blocked - - // TODO: figure out if it's worth considering partially blocked cases or not? - // maybe to adjust los's top/bottom slopes if needed - //if (los->topslope <= los->bottomslope) - //return false; } return true; } - // // P_CrossSubsector // @@ -305,24 +296,19 @@ static boolean P_CrossBSPNode(INT32 bspnum, register los_t *los, boolean fast) { 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 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)); if (side == side2) { bspnum = bsp->children[side]; // doesn't touch the other side } - else + else // the partition plane is crossed here { - // the partition plane is crossed here if (!P_CrossBSPNode(bsp->children[side], los, fast)) - { return false; // cross the starting side - } - else - { - bspnum = bsp->children[side^1]; // cross the ending side - } + + bspnum = bsp->children[side^1]; // cross the ending side } } diff --git a/src/p_slopes.c b/src/p_slopes.c index f3428d91f..81d8c54e3 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -24,7 +24,7 @@ #include "w_wad.h" -static pslope_t *slopelist = NULL; +pslope_t *slopelist = NULL; static UINT16 slopecount = 0; // Calculate light diff --git a/src/p_slopes.h b/src/p_slopes.h index 82dd90738..89cfdc343 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -33,6 +33,8 @@ void P_CopySectorSlope(line_t *line); pslope_t *P_SlopeById(UINT16 id); +extern pslope_t *slopelist; + // // P_GetZAt // diff --git a/src/p_spec.c b/src/p_spec.c index d272764be..43f543fdf 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1427,14 +1427,14 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller } else if (caller) { - INT32 special = GETSECSPECIAL(caller->special, 2); + const INT32 secspecial = GETSECSPECIAL(caller->special, 2); - if (special == 6) + if (secspecial == 6) { if (!(ALL7EMERALDS(emeralds))) return false; } - else if (special == 7) // SRB2Kart: reusing for Race Lap executor + else if (secspecial == 7) // SRB2Kart: reusing for Race Lap executor { UINT8 lap; @@ -1468,7 +1468,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller // If we were not triggered by a sector type especially for the purpose, // a Linedef Executor linedef trigger is not handling sector triggers properly, return. - else if ((!special || special > 7) && (specialtype > 322)) + else if ((!secspecial || secspecial > 7) && (specialtype > 322)) { CONS_Alert(CONS_WARNING, M_GetText("Linedef executor trigger isn't handling sector triggers properly!\nspecialtype = %d, if you are not a dev, report this warning instance\nalong with the wad that caused it!\n"), @@ -1718,6 +1718,22 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller) } } +static boolean is_rain_type (INT32 weathernum) +{ + switch (weathernum) + { + case PRECIP_SNOW: + case PRECIP_RAIN: + case PRECIP_STORM: + case PRECIP_STORM_NOSTRIKES: + case PRECIP_BLANK: + return true; + + default: + return false; + } +} + // // P_SwitchWeather // @@ -1725,53 +1741,14 @@ void P_LinedefExecute(INT16 tag, mobj_t *actor, sector_t *caller) // void P_SwitchWeather(INT32 weathernum) { - boolean purge = false; - INT32 swap = 0; + boolean purge = true; - switch (weathernum) - { - case PRECIP_NONE: // None - if (curWeather == PRECIP_NONE) - return; // Nothing to do. - purge = true; - break; - case PRECIP_STORM: // Storm - case PRECIP_STORM_NOSTRIKES: // Storm w/ no lightning - case PRECIP_RAIN: // Rain - if (curWeather == PRECIP_SNOW || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) - swap = PRECIP_RAIN; - break; - case PRECIP_SNOW: // Snow - if (curWeather == PRECIP_SNOW) - return; // Nothing to do. - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES || curWeather == PRECIP_BLANK || curWeather == PRECIP_STORM_NORAIN) - swap = PRECIP_SNOW; // Need to delete the other precips. - break; - case PRECIP_STORM_NORAIN: // Storm w/o rain - if (curWeather == PRECIP_SNOW - || curWeather == PRECIP_STORM - || curWeather == PRECIP_STORM_NOSTRIKES - || curWeather == PRECIP_RAIN - || curWeather == PRECIP_BLANK) - swap = PRECIP_STORM_NORAIN; - else if (curWeather == PRECIP_STORM_NORAIN) - return; - break; - case PRECIP_BLANK: - if (curWeather == PRECIP_SNOW - || curWeather == PRECIP_STORM - || curWeather == PRECIP_STORM_NOSTRIKES - || curWeather == PRECIP_RAIN) - swap = PRECIP_BLANK; - else if (curWeather == PRECIP_STORM_NORAIN) - swap = PRECIP_BLANK; - else if (curWeather == PRECIP_BLANK) - return; - break; - default: - CONS_Debug(DBG_GAMELOGIC, "P_SwitchWeather: Unknown weather type %d.\n", weathernum); - break; - } + if (weathernum == curWeather) + return; + + if (is_rain_type(weathernum) && + is_rain_type(curWeather)) + purge = false; if (purge) { @@ -1779,44 +1756,47 @@ void P_SwitchWeather(INT32 weathernum) thinker_t *next; precipmobj_t *precipmobj; - for (think = thinkercap.next; think != &thinkercap; think = next) + for (think = precipcap.next; think != &precipcap; think = next) { next = think->next; +#ifdef PARANOIA if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker +#endif precipmobj = (precipmobj_t *)think; P_FreePrecipMobj(precipmobj); } } - else if (swap && !((swap == PRECIP_BLANK && curWeather == PRECIP_STORM_NORAIN) || (swap == PRECIP_STORM_NORAIN && curWeather == PRECIP_BLANK))) // Rather than respawn all that crap, reuse it! + else // Rather than respawn all that crap, reuse it! { thinker_t *think; precipmobj_t *precipmobj; state_t *st; - for (think = thinkercap.next; think != &thinkercap; think = think->next) + for (think = precipcap.next; think != &precipcap; think = think->next) { +#ifdef PARANOIA if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker +#endif precipmobj = (precipmobj_t *)think; - mobjtype_t type = 0; INT32 z = 0; + mobjtype_t type = MT_NULL; - if (swap == PRECIP_BLANK || swap == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. + if (weathernum == PRECIP_NONE || weathernum == PRECIP_BLANK || weathernum == PRECIP_STORM_NORAIN) // Remove precip, but keep it around for reuse. { precipmobj->precipflags |= PCF_INVISIBLE; continue; } - - if (swap == PRECIP_RAIN) // Snow To Rain + else if (weathernum == PRECIP_RAIN || weathernum == PRECIP_STORM || weathernum == PRECIP_STORM_NOSTRIKES) // Snow To Rain { type = MT_RAIN; } - else if (swap == PRECIP_SNOW) // Rain To Snow + else if (weathernum == PRECIP_SNOW) // Rain To Snow { type = MT_SNOWFLAKE; @@ -1846,50 +1826,45 @@ void P_SwitchWeather(INT32 weathernum) } } - boolean dontspawn = false; + boolean spawnprecip = false; switch (weathernum) { case PRECIP_SNOW: // snow curWeather = PRECIP_SNOW; - break; + spawnprecip = true; + break; case PRECIP_RAIN: // rain { - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) - dontspawn = true; - curWeather = PRECIP_RAIN; + spawnprecip = true; break; } case PRECIP_STORM: // storm { - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) - dontspawn = true; - curWeather = PRECIP_STORM; + spawnprecip = true; break; } case PRECIP_STORM_NOSTRIKES: // storm w/o lightning { - if (curWeather == PRECIP_RAIN || curWeather == PRECIP_STORM || curWeather == PRECIP_STORM_NOSTRIKES) - dontspawn = true; - curWeather = PRECIP_STORM_NOSTRIKES; + spawnprecip = true; break; } case PRECIP_STORM_NORAIN: // storm w/o rain curWeather = PRECIP_STORM_NORAIN; break; - case PRECIP_BLANK: + case PRECIP_BLANK: //preloaded curWeather = PRECIP_BLANK; - break; + spawnprecip = true; + break; default: - dontspawn = true; curWeather = PRECIP_NONE; break; } - if (!dontspawn && !swap) + if (spawnprecip && purge) P_SpawnPrecipitation(); } @@ -2105,7 +2080,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) break; case 413: // Change music - if (keepmusic && (leveltime <= MUSICSTARTTIME)) //why check for starttime? cause encore music Zzz... + if (keepmapmusic && (leveltime <= MUSICSTARTTIME)) // why check for starttime? cause encore music Zzz... return; //if (cv_ignoremusicchanges.value && (leveltime >= MUSICSTARTTIME) && !fromlapexec) // keep lap music intanct tho @@ -2153,19 +2128,19 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // Change the music and apply position/fade operations else { - strncpy(mapmusname, sides[line->sidenum[0]].text, 7); - mapmusname[6] = 0; + strncpy(mapmusic.name, sides[line->sidenum[0]].text, 7); + mapmusic.name[6] = 0; - mapmusflags = tracknum & MUSIC_TRACKMASK; + mapmusic.flags = tracknum & MUSIC_TRACKMASK; if (!(line->flags & ML_BLOCKMONSTERS)) - mapmusflags |= MUSIC_RELOADRESET; + mapmusic.flags |= MUSIC_RELOADRESET; if (line->flags & ML_BOUNCY) - mapmusflags |= MUSIC_FORCERESET; + mapmusic.flags |= MUSIC_FORCERESET; - mapmusposition = position; - mapmusresume = 0; + mapmusic.position = position; + mapmusic.resume = 0; - S_ChangeMusicEx(mapmusname, mapmusflags, !(line->flags & ML_EFFECT4), position, + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, !(line->flags & ML_EFFECT4), position, !(line->flags & ML_EFFECT2) ? prefadems : 0, !(line->flags & ML_EFFECT2) ? postfadems : 0); @@ -2192,7 +2167,7 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) INT32 sfxnum; //dont play any funky sound intros that may interfere with the music - if (skipintromus && (leveltime < MUSICSTARTTIME)) + if ((skipintromus || keepmapmusic) && (leveltime < MUSICSTARTTIME)) return; sfxnum = sides[line->sidenum[0]].toptexture; //P_AproxDistance(line->dx, line->dy)>>FRACBITS; @@ -3335,10 +3310,10 @@ void P_ProcessSpecialSector(player_t *player, sector_t *sector, sector_t *rovers case 6: // Death Pit (Camera Tilt) case 7: // Death Pit (No Camera Tilt) if (roversector || P_MobjReadyToTrigger(player->mo, sector)) - P_DamageMobj(player->mo, NULL, NULL, 10000); + P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL); break; case 8: // Instant Kill - P_DamageMobj(player->mo, NULL, NULL, 10000); + P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL); break; case 9: // Ring Drainer (Floor Touch) case 10: // Ring Drainer (No Floor Touch) @@ -3586,14 +3561,15 @@ DoneSection2: if (!demo.playback || P_AnalogMove(player)) { - if (player == &players[consoleplayer]) - localangle[0] = player->mo->angle; - else if (player == &players[displayplayers[1]]) - localangle[1] = player->mo->angle; - else if (player == &players[displayplayers[2]]) - localangle[2] = player->mo->angle; - else if (player == &players[displayplayers[3]]) - localangle[3] = player->mo->angle; + for (UINT8 j = 0; j <= splitscreen; ++j) + { + INT32 id = (j == 0 ? consoleplayer : displayplayers[j]); + if (player == &players[id]) + { + localangle[j] = player->mo->angle; + break; + } + } } if (!(lines[i].flags & ML_EFFECT4)) @@ -3937,17 +3913,13 @@ DoneSection2: CON_LogMessage(va(M_GetText("%s has finished the race.\n"), player_names[player-players])); // SRB2Kart: save best lap for record attack - if (player == &players[consoleplayer]) + if (player->laptime[LAP_CUR] < player->laptime[LAP_BEST] || player->laptime[LAP_BEST] == 0) { - if (curlap < bestlap || bestlap == 0) - bestlap = curlap; - curlap = 0; + player->laptime[LAP_BEST] = player->laptime[LAP_CUR]; } - // ONLY FOR HUD player->laptime[LAP_LAST] = player->laptime[LAP_CUR]; player->laptime[LAP_CUR] = 0; - // player->starposttime = player->realtime; player->starpostnum = 0; @@ -4779,16 +4751,34 @@ static ffloor_t *P_AddFakeFloor(sector_t *sec, sector_t *sec2, line_t *master, f else th = th->next; } - if (flags & FF_TRANSLUCENT) { if (sides[master->sidenum[0]].toptexture > 0) - ffloor->alpha = sides[master->sidenum[0]].toptexture; // for future reference, "#0" is 1, and "#255" is 256. Be warned + { + // for future reference, "#0" is 1, and "#255" is 256. Be warned + ffloor->alpha = sides[master->sidenum[0]].toptexture; + + if (ffloor->alpha >= 1001) // fourth digit + { + ffloor->blend = (ffloor->alpha/1000)+1; // becomes an AST + ffloor->alpha %= 1000; + } + else + { + ffloor->blend = 0; + } + } else + { ffloor->alpha = 0x80; + ffloor->blend = 0; + } } else + { ffloor->alpha = 0xff; + ffloor->blend = 0; + } ffloor->spawnalpha = ffloor->alpha; // save for netgames @@ -5298,20 +5288,8 @@ void P_SpawnSpecials(INT32 fromnetsave, boolean reloadinggamestate) } } - if (mapheaderinfo[gamemap-1]->weather == 2) // snow - curWeather = PRECIP_SNOW; - else if (mapheaderinfo[gamemap-1]->weather == 3) // rain - curWeather = PRECIP_RAIN; - else if (mapheaderinfo[gamemap-1]->weather == 1) // storm - curWeather = PRECIP_STORM; - else if (mapheaderinfo[gamemap-1]->weather == 5) // storm w/o rain - curWeather = PRECIP_STORM_NORAIN; - else if (mapheaderinfo[gamemap-1]->weather == 6) // storm w/o lightning - curWeather = PRECIP_STORM_NOSTRIKES; - else if (mapheaderinfo[gamemap-1]->weather == 4) // blank - curWeather = PRECIP_BLANK; - else - curWeather = PRECIP_NONE; + // set current weather + curWeather = mapheaderinfo[gamemap-1]->weather; P_InitTagLists(); // Create xref tables for tags P_SearchForDisableLinedefs(); // Disable linedefs are now allowed to disable *any* line @@ -7429,33 +7407,18 @@ void T_Pusher(pusher_t *p) if (!demo.playback || P_AnalogMove(thing->player)) { - if (thing->player == &players[consoleplayer]) + for (UINT8 i = 0; i <= splitscreen; ++i) { - if (thing->angle - localangle[0] > ANGLE_180) - localangle[0] -= (localangle[0] - thing->angle) / 8; - else - localangle[0] += (thing->angle - localangle[0]) / 8; - } - else if (thing->player == &players[displayplayers[1]]) - { - if (thing->angle - localangle[1] > ANGLE_180) - localangle[1] -= (localangle[1] - thing->angle) / 8; - else - localangle[1] += (thing->angle - localangle[1]) / 8; - } - else if (thing->player == &players[displayplayers[2]]) - { - if (thing->angle - localangle[2] > ANGLE_180) - localangle[2] -= (localangle[2] - thing->angle) / 8; - else - localangle[2] += (thing->angle - localangle[2]) / 8; - } - else if (thing->player == &players[displayplayers[3]]) - { - if (thing->angle - localangle[3] > ANGLE_180) - localangle[3] -= (localangle[3] - thing->angle) / 8; - else - localangle[3] += (thing->angle - localangle[3]) / 8; + INT32 id = (i == 0 ? consoleplayer : displayplayers[i]); + if (thing->player == &players[id]) + { + if (thing->angle - localangle[i] > ANGLE_180) + localangle[i] -= (localangle[i] - thing->angle) / 8; + else + localangle[i] += (thing->angle - localangle[i]) / 8; + + break; + } } } } diff --git a/src/p_tick.c b/src/p_tick.c index 9d5a64cf3..0db1d5d48 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -49,6 +49,7 @@ tic_t leveltime; // Both the head and tail of the thinker list. thinker_t thinkercap; +thinker_t precipcap; void Command_Numthinkers_f(void) { @@ -56,6 +57,7 @@ void Command_Numthinkers_f(void) INT32 count = 0; actionf_p1 action; thinker_t *think; + thinker_t *listtype; if (gamestate != GS_LEVEL) { @@ -104,7 +106,9 @@ void Command_Numthinkers_f(void) return; } - for (think = thinkercap.next; think != &thinkercap; think = think->next) + listtype = (num == 2) ? &precipcap : &thinkercap; + + for (think = listtype->next; think != listtype; think = think->next) { if (think->function.acp1 != action) continue; @@ -181,6 +185,7 @@ void Command_CountMobjs_f(void) void P_InitThinkers(void) { thinkercap.prev = thinkercap.next = &thinkercap; + precipcap.prev = precipcap.next = &precipcap; waypointcap = NULL; } @@ -200,6 +205,22 @@ void P_AddThinker(thinker_t *thinker) thinker->cachable = (thinker->function.acp1 == (actionf_p1)P_MobjThinker); } +// +// P_AddPrecipThinker +// Adds a new precip thinker at the end of the list. +// +void P_AddPrecipThinker(thinker_t *thinker) +{ + precipcap.prev->next = thinker; + thinker->next = &precipcap; + thinker->prev = precipcap.prev; + precipcap.prev = thinker; + + thinker->references = 0; // killough 11/98: init reference counter to 0 + + thinker->cachable = false; +} + // // killough 11/98: // @@ -341,8 +362,6 @@ static inline void P_RunThinkers(void) { for (currentthinker = thinkercap.next; currentthinker != &thinkercap; currentthinker = currentthinker->next) { - if (currentthinker->function.acp1 == (actionf_p1)P_NullPrecipThinker) - continue; #ifdef PARANOIA I_Assert(currentthinker->function.acp1 != NULL) #endif @@ -354,7 +373,7 @@ static void P_DeviceRumbleTick(void) { UINT8 i; - if (I_NumJoys() == 0 || gamestate != GS_LEVEL) + if (dedicated || numcontrollers == 0 || gamestate != GS_LEVEL) { return; } @@ -364,24 +383,19 @@ static void P_DeviceRumbleTick(void) UINT16 low = 0; UINT16 high = 0; + if (!cv_usejoystick[i].value || !cv_rumble[i].value) + { + continue; + } + player_t *player = ((i == 0) ? &players[consoleplayer] : &players[displayplayers[i]]); - if (!cv_usejoystick[i].value) + if (player->spectator || !player->mo) { continue; } - if (!cv_rumble[i].value) - { - continue; - } - - if (player->spectator) - { - continue; - } - - if (player->mo == NULL) + if (camera[i].freecam) { continue; } @@ -394,7 +408,8 @@ static void P_DeviceRumbleTick(void) if (player->kartstuff[k_spinouttimer]) { - low = high = FRACUNIT / 4; + //low = high = FRACUNIT / 6; + low = high = FixedMul((FRACUNIT / 4), (FixedDiv(player->kartstuff[k_spinouttimer], (3*TICRATE / 2)))); } else if (player->kartstuff[k_sneakertimer] > (sneakertime-(TICRATE/2))) { @@ -416,6 +431,12 @@ static void P_DeviceRumbleTick(void) low = high = FRACUNIT / 64; } } + else if ((player->kartstuff[k_bananadrag] > TICRATE) + && P_IsObjectOnGround(player->mo) && player->speed != 0) + { + if (leveltime & 1) // this is actually funny lel + high = FRACUNIT / 64; + } if (player->kartstuff[k_brakedrift]) { @@ -439,7 +460,20 @@ void P_RunChaseCameras(void) for (i = 0; i <= splitscreen; i++) { if (camera[i].chase) - P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); + { + 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 (p->speed < 6 * p->mo->scale && abs(cam->dpad_y_held) < 2*TICRATE) + cam->dpad_y_held += intsign(p->kartstuff[k_throwdir]); + } + else + cam->dpad_y_held = 0; + + P_MoveChaseCamera(p, cam, false); + } } } @@ -473,6 +507,32 @@ static void P_RunQuakes(void) --quake.time; } +static inline void P_ResetSpriteStuff(void) +{ + thinker_t *th; + + if (rendermode == render_none) + return; + + for (th = thinkercap.next; th != &thinkercap; th = th->next) + { + mobj_t *mo; + + if (th->function.acp1 != (actionf_p1)P_MobjThinker) // not a mobj + continue; + + mo = (mobj_t *)th; + + if (mo->sprite == SPR_NULL || mo->flags2 & MF2_DONTDRAW || mo->type == MT_SHADOW) + continue; + + mo->spritexscale = mo->realxscale; + mo->spriteyscale = mo->realyscale; + mo->spritexoffset = mo->realxoffset; + mo->spriteyoffset = mo->realyoffset; + } +} + // // P_Ticker // @@ -520,8 +580,8 @@ void P_Ticker(boolean run) timeinmap = (timeinmap-1) & ~3; G_PreviewRewind(leveltime); } - else if (demo.freecam && democam.cam) // special case: allow freecam to MOVE during pause! - P_DemoCameraMovement(democam.cam); + else + P_RunChaseCameras(); // special case: allow freecam to MOVE during pause! return; } @@ -573,6 +633,8 @@ void P_Ticker(boolean run) ps_lua_mobjhooks.value.i = 0; ps_checkposition_calls.value.i = 0; + P_ResetSpriteStuff(); + PS_START_TIMING(ps_lua_prethinkframe_time); LUA_HookPreThinkFrame(); PS_STOP_TIMING(ps_lua_prethinkframe_time); @@ -614,10 +676,7 @@ void P_Ticker(boolean run) PS_STOP_TIMING(ps_lua_thinkframe_time); } - // Run shield positioning - //P_RunShields(); P_RunOverlays(); - P_RunShadows(); P_UpdateSpecials(); @@ -647,7 +706,7 @@ void P_Ticker(boolean run) if (!players[i].mo) continue; - P_DamageMobj(players[i].mo, NULL, NULL, 10000); + P_DamageMobj(players[i].mo, NULL, NULL, DMG_INSTAKILL); } } diff --git a/src/p_user.c b/src/p_user.c index 0e587e659..dacd18868 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -362,7 +362,6 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor) if (inflictor) { ang = R_PointToAngle2(inflictor->x, inflictor->y, player->mo->x, player->mo->y); // SRB2kart - //ang = R_PointToAngle2(inflictor->x-inflictor->momx, inflictor->y - inflictor->momy, player->mo->x - player->mo->momx, player->mo->y - player->mo->momy); // explosion and rail rings send you farther back, making it more difficult // to recover @@ -789,14 +788,14 @@ void P_RestoreMusic(player_t *player) if (G_RaceGametype() && player->laps >= (UINT8)(cv_numlaps.value - 1)) S_SpeedMusic(1.2f); #endif - if (mapmusresume && cv_resume.value) // mapmusresume will be 0 anyways when birdmusic stuff is disabled - position = mapmusresume; + if (mapmusic.resume && cv_resume.value) // mapmusresume will be 0 anyways when birdmusic stuff is disabled + position = mapmusic.resume; else - position = mapmusposition; + position = mapmusic.position; - S_ChangeMusicEx(mapmusname, mapmusflags, true, position, 0, S_GetRestoreMusicFadeIn()); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, position, 0, S_GetRestoreMusicFadeIn()); S_ClearRestoreMusicFadeInCvar(); - mapmusresume = 0; + mapmusic.resume = 0; } } } @@ -1054,6 +1053,15 @@ boolean P_IsDisplayPlayer(const player_t *player) for (i = 0; i <= splitscreen; i++) // DON'T skip P1 { + if (camera[i].freecam) + { + // Freecam still techically has a player in + // displayplayers. But since the camera is + // detached, it would be weird if sounds were + // heard from that player's perspective. + continue; + } + if (player == &players[displayplayers[i]]) return true; } @@ -1198,6 +1206,7 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->spriteyscale = mobj->spriteyscale; ghost->spritexoffset = mobj->spritexoffset; ghost->spriteyoffset = mobj->spriteyoffset; + ghost->rollangle = mobj->rollangle; if (mobj->flags2 & MF2_OBJECTFLIP) ghost->flags |= MF2_OBJECTFLIP; @@ -2096,7 +2105,7 @@ static void P_SpectatorMovement(player_t *player) { ticcmd_t *cmd = &player->cmd; - player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); + player->mo->angle = (angle_t)(cmd->angleturn<<16 /* not FRACBITS */); ticruned++; if (!(cmd->angleturn & TICCMD_RECEIVED)) @@ -2262,6 +2271,7 @@ static void P_MovePlayer(player_t *player) } } + // have to keep this crap for synch reasons if (player->spectator) { P_SpectatorMovement(player); @@ -2469,13 +2479,12 @@ static void P_MovePlayer(player_t *player) K_DriftDustHandling(player->mo); - // Crush test... if ((player->mo->ceilingz - player->mo->floorz < player->mo->height) && !(player->mo->flags & MF_NOCLIP)) { if ((netgame || multiplayer) && player->spectator) - P_DamageMobj(player->mo, NULL, NULL, 42000); // Respawn crushed spectators + P_DamageMobj(player->mo, NULL, NULL, DMG_SPECTATOR); // Respawn crushed spectators else { K_SquishPlayer(player, NULL, NULL); // SRB2kart - we don't kill when squished, we squish when squished. @@ -2485,8 +2494,7 @@ static void P_MovePlayer(player_t *player) return; } -#ifdef HWRENDER - if (rendermode == render_opengl && cv_glfovchange.value) + if (cv_fovchange.value) { fixed_t speed; const fixed_t runnyspeed = 20*FRACUNIT; @@ -2506,7 +2514,6 @@ static void P_MovePlayer(player_t *player) } else player->fovadd = 0; -#endif #ifdef FLOORSPLATS if (cv_shadow.value && rendermode == render_soft) @@ -2666,9 +2673,6 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) if (mo->flags & MF_MONITOR) continue; // Monitors cannot be 'nuked'. - //if (!G_BattleGametype() && mo->type == MT_PLAYER) - // continue; // Don't hurt players in Co-Op! - if (abs(inflictor->x - mo->x) > radius || abs(inflictor->y - mo->y) > radius || abs(inflictor->z - mo->z) > radius) continue; // Workaround for possible integer overflow in the below -Red @@ -2922,24 +2926,15 @@ static void P_DeathThink(player_t *player) if (leveltime >= starttime) { player->realtime = leveltime - starttime; - if (player == &players[consoleplayer]) - { - if (player->spectator || !circuitmap) - curlap = 0; - else - curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V - } if (player->spectator) player->laptime[LAP_CUR] = 0; - else + else if (player->laptime[LAP_CUR] != UINT32_MAX) player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V } else { player->realtime = 0; - if (player == &players[consoleplayer]) - curlap = 0; player->laptime[LAP_CUR] = 0; } @@ -2994,10 +2989,6 @@ static void CV_CamRotate4_OnChange(void) CV_SetValue(&cv_cam_rotate[3], cv_cam_rotate[3].value % 360); } -static CV_PossibleValue_t CV_CamSpeed[] = {{0, "MIN"}, {1*FRACUNIT, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t rotation_cons_t[] = {{1, "MIN"}, {45, "MAX"}, {0, NULL}}; -static CV_PossibleValue_t CV_CamRotate[] = {{-720, "MIN"}, {720, "MAX"}, {0, NULL}}; - static void CV_PlayerCam1_OnChange(void) { if (gamestate != GS_LEVEL) @@ -3083,25 +3074,36 @@ consvar_t cv_cam_still[MAXSPLITSCREENPLAYERS] = { {"cam4_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL} }; +static CV_PossibleValue_t cam_speed_cons_t[] = {{0, "MIN"}, {1*FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_cam_speed[MAXSPLITSCREENPLAYERS] = { - {"cam_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam3_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL} + {"cam_speed", "0.4", CV_FLOAT|CV_SAVE, cam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_speed", "0.4", CV_FLOAT|CV_SAVE, cam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam3_speed", "0.4", CV_FLOAT|CV_SAVE, cam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam4_speed", "0.4", CV_FLOAT|CV_SAVE, cam_speed_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} }; + +static CV_PossibleValue_t cam_rotate_cons_t[] = {{-720, "MIN"}, {720, "MAX"}, {0, NULL}}; consvar_t cv_cam_rotate[MAXSPLITSCREENPLAYERS] = { - {"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL}, - {"cam3_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate3_OnChange, 0, NULL, NULL, 0, 0, NULL}, - {"cam4_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL} + {"cam_rotate", "0", CV_CALL|CV_NOINIT, cam_rotate_cons_t, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_rotate", "0", CV_CALL|CV_NOINIT, cam_rotate_cons_t, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam3_rotate", "0", CV_CALL|CV_NOINIT, cam_rotate_cons_t, CV_CamRotate3_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"cam4_rotate", "0", CV_CALL|CV_NOINIT, cam_rotate_cons_t, CV_CamRotate4_OnChange, 0, NULL, NULL, 0, 0, NULL} }; -consvar_t cv_cam_rotspeed[MAXSPLITSCREENPLAYERS] = { - {"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam3_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam4_rotspeed", "10", CV_SAVE, rotation_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL} +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}, +}; + +static CV_PossibleValue_t freecam_speed_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; +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}, }; consvar_t cv_tilting = {"tilting", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; @@ -3117,61 +3119,92 @@ fixed_t t_cam_rotate[MAXSPLITSCREENPLAYERS] = {-42, -42, -42, -42}; #define MAXCAMERADIST 140*FRACUNIT // Max distance the camera can be in front of the player (2D mode) -// Heavily simplified version of G_BuildTicCmd that only takes the local first player's control input and converts it to readable ticcmd_t -// we then throw that ticcmd garbage in the camera and make it move - -// redefine this static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {KART_FULLTURN/2, KART_FULLTURN, KART_FULLTURN/4}; // + slow turn +static fixed_t strafemove[2] = {25<>16, 50<>16}; // faster! -static ticcmd_t cameracmd; - -struct demofreecam_s democam; - -// called by m_menu to reinit cam input every time it's toggled -void P_InitCameraCmd(void) +void P_ToggleDemoCamera(UINT8 viewnum) { - memset(&cameracmd, 0, sizeof(ticcmd_t)); // initialize cmd + camera_t *cam = &camera[viewnum]; + + // dont toggle freecam when in spec + // special case since only non splitscreen can change viewpoints + if ((!splitscreen && players[consoleplayer].spectator) || players[displayplayers[viewnum]].spectator) + { + cam->freecam = false; + return; + } + + if (!cam->freecam) // toggle on + { + cam->freecam = true; + cam->button_a_held = 2; + cam->reset_aiming = true; + + // get rid of some hud elements + if (displayplayers[0] != consoleplayer) + { + displayplayers[0] = consoleplayer; + } + } + else // toggle off + { + cam->freecam = false; + G_FixCamera(viewnum+1); + } } -static ticcmd_t *P_CameraCmd(camera_t *cam) +static ticcmd_t cameracmd[MAXSPLITSCREENPLAYERS]; +static ticcmd_t *P_CameraCmd(camera_t *cam, UINT8 num) { - INT32 laim, th, tspeed, forward, side, axis; //i - const INT32 speed = 1; + INT32 laim, forward, side, axis; + // these ones used for multiple conditions - boolean turnleft, turnright, mouseaiming; - boolean invertmouse, lookaxis, usejoystick, kbl; + boolean turnleft, turnright; + boolean strafeleft, straferight; + boolean usejoystick; angle_t lang; - INT32 player_invert; - INT32 screen_invert; + const UINT8 forplayer = num+1; - ticcmd_t *cmd = &cameracmd; + SINT8 player_invert = cv_invertmouse.value ? -1 : 1; // who tf uses two mice? - (void)cam; + memset(&cameracmd[num], 0, sizeof(ticcmd_t)); // initialize cmd - if (!demo.playback) - return cmd; // empty cmd, no. + ticcmd_t *cmd = &cameracmd[num]; - lang = democam.localangle; - laim = democam.localaiming; - th = democam.turnheld; - kbl = democam.keyboardlook; + lang = cam->localangle; + laim = cam->localaiming; - G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + switch (forplayer) + { + case 2: + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); + break; + case 3: + G_CopyTiccmd(cmd, I_BaseTiccmd3(), 1); + break; + case 4: + G_CopyTiccmd(cmd, I_BaseTiccmd4(), 1); + break; + case 1: + default: + G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + break; + } cmd->angleturn = (INT16)(lang >> 16); cmd->aiming = G_ClipAimingPitch(&laim); - mouseaiming = true; - invertmouse = cv_invertmouse.value; - lookaxis = cv_lookaxis[0].value; + const boolean analogjoystickmove = cv_usejoystick[num].value && !Joystick[num].bGamepadStyle; + const boolean gamepadjoystickmove = cv_usejoystick[num].value && Joystick[num].bGamepadStyle; - usejoystick = true; - turnright = InputDown(gc_turnright, 1); - turnleft = InputDown(gc_turnleft, 1); + usejoystick = (analogjoystickmove || gamepadjoystickmove); - axis = JoyAxis(AXISTURN, 1); + turnright = InputDown(gc_turnright, forplayer); + turnleft = InputDown(gc_turnleft, forplayer); + + axis = JoyAxis(AXISCAMTURN, forplayer); if (encoremode) { @@ -3181,87 +3214,119 @@ static ticcmd_t *P_CameraCmd(camera_t *cam) axis = -axis; } - if (axis != 0) + if (usejoystick && axis != 0) { turnright = turnright || (axis > 0); turnleft = turnleft || (axis < 0); } forward = side = 0; - // use two stage accelerative turning - // on the keyboard and joystick - if (turnleft || turnright) - th += 1; - else - th = 0; - - if (th < SLOWTURNTICS) - tspeed = 2; // slow turn - else - tspeed = speed; - // let movement keys cancel each other out if (turnright && !(turnleft)) { - cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[tspeed])); + cmd->angleturn = (INT16)(cmd->angleturn - (angleturn[1])); side += sidemove[1]; } else if (turnleft && !(turnright)) { - cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[tspeed])); + cmd->angleturn = (INT16)(cmd->angleturn + (angleturn[1])); side -= sidemove[1]; } + straferight = InputDown(gc_straferight, forplayer); + strafeleft = InputDown(gc_strafeleft, forplayer); + + axis = JoyAxis(AXISCAMSTRAFE, forplayer); + + if (encoremode) + { + straferight ^= strafeleft; // swap these using three XORs + strafeleft ^= straferight; + straferight ^= strafeleft; + axis = -axis; + } + + if (usejoystick && axis != 0) + { + straferight = straferight || (axis > 0); + strafeleft = strafeleft || (axis < 0); + } + + // let strafe keys cancel each other out + if (straferight && !(strafeleft)) + { + side += strafemove[1]; + } + else if (strafeleft && !(straferight)) + { + side -= strafemove[1]; + } + cmd->angleturn = (INT16)(cmd->angleturn - ((mousex*(encoremode ? -1 : 1)*8))); - axis = JoyAxis(AXISMOVE, 1); - if (InputDown(gc_accelerate, 1) || (usejoystick && axis > 0)) - cmd->buttons |= BT_ACCELERATE; - axis = JoyAxis(AXISBRAKE, 1); - if (InputDown(gc_brake, 1) || (usejoystick && axis > 0)) - cmd->buttons |= BT_BRAKE; - axis = JoyAxis(AXISAIM, 1); - if (InputDown(gc_aimforward, 1) || (usejoystick && axis < 0)) + axis = JoyAxis(AXISAIM, forplayer); + if (InputDown(gc_aimforward, forplayer) || (usejoystick && axis < 0)) forward += forwardmove[1]; - if (InputDown(gc_aimbackward, 1) || (usejoystick && axis > 0)) + if (InputDown(gc_aimbackward, forplayer) || (usejoystick && axis > 0)) forward -= forwardmove[1]; - // fire with any button/key - axis = JoyAxis(AXISFIRE, 1); - if (InputDown(gc_fire, 1) || (usejoystick && axis > 0)) + axis = JoyAxis(AXISFIRE, forplayer); + if (InputDown(gc_fire, forplayer) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; - // spectator aiming shit, ahhhh... - player_invert = invertmouse ? -1 : 1; - screen_invert = 1; // nope + // drift with any button/key + axis = JoyAxis(AXISDRIFT, forplayer); + if (InputDown(gc_drift, forplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_DRIFT; - // mouse look stuff (mouse look is not the same as mouse aim) - kbl = false; + // float and sink + axis = JoyAxis(AXISMOVE, forplayer); + if (InputDown(gc_accelerate, forplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_ACCELERATE; + axis = JoyAxis(AXISBRAKE, forplayer); + if (InputDown(gc_brake, forplayer) || (usejoystick && axis > 0)) + cmd->buttons |= BT_BRAKE; - // looking up/down - laim += (mlooky<<19)*player_invert*screen_invert; + axis = JoyAxis(AXISLOOK, forplayer); - axis = JoyAxis(AXISLOOK, 1); + laim += (mlooky<<19)*player_invert; - // spring back if not using keyboard neither mouselookin' - if (!kbl && !lookaxis && !mouseaiming) - laim = 0; - - if (InputDown(gc_lookup, 1) || (axis < 0)) + if (InputDown(gc_lookup, forplayer) || (usejoystick && axis < 0)) { - laim += KB_LOOKSPEED * screen_invert; - kbl = true; + laim += KB_LOOKSPEED; } - else if (InputDown(gc_lookdown, 1) || (axis > 0)) + else if (InputDown(gc_lookdown, forplayer) || (usejoystick && axis > 0)) { - laim -= KB_LOOKSPEED * screen_invert; - kbl = true; + laim -= KB_LOOKSPEED; } - if (InputDown(gc_centerview, 1)) // No need to put a spectator limit on this one though :V + if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V + { laim = 0; + cam->reset_aiming = false; + } - cmd->aiming = G_ClipAimingPitch(&laim); + //if (cam->reset_aiming || ((cmd->buttons & BT_DRIFT) && !cam->button_a_held)) + if (cam->reset_aiming) + { + INT32 aiming = laim; + INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(laim)); + + if (abs(smooth) < abs(aiming)) + { + laim -= (angle_t)(smooth * intsign(aiming)); + } + else + { + laim = 0; + cam->reset_aiming = false; // completely smoothed out + } + } + + if (!cam->reset_aiming) + { + cmd->aiming = G_ClipAimingPitch(&laim); + } mousex = mousey = mlooky = 0; @@ -3283,69 +3348,120 @@ static ticcmd_t *P_CameraCmd(camera_t *cam) lang += (cmd->angleturn<<16); - democam.localangle = lang; - democam.localaiming = laim; - democam.turnheld = th; - democam.keyboardlook = kbl; + cam->localangle = lang; + if (!cam->reset_aiming) + { + cam->localaiming = laim; + } return cmd; } -void P_DemoCameraMovement(camera_t *cam) +static void P_DemoCameraMovement(camera_t *cam, UINT8 num) { ticcmd_t *cmd; angle_t thrustangle; - mobj_t *awayviewmobj_hack; player_t *lastp; + const UINT8 forplayer = num+1; - // update democam stuff with what we got here: - democam.cam = cam; - democam.localangle = cam->angle; - democam.localaiming = cam->aiming; + cam->localangle = cam->angle; + cam->localaiming = cam->aiming; // first off we need to get button input - cmd = P_CameraCmd(cam); + cmd = P_CameraCmd(cam, num); - cam->aiming = cmd->aiming<angle = cmd->angleturn<<16; + // make sure we dont aim away during reset + if (!cam->reset_aiming) + { + cam->aiming = cmd->aiming << FRACBITS; + } + + cam->angle = cmd->angleturn << 16; // camera movement: + if (!cam->button_a_held) + { + fixed_t spd = (32*mapobjectscale*cv_freecam_speed[num].value); + int dir = ((cmd->buttons & BT_ACCELERATE || InputDown(gc_camfloat, forplayer)) ? 1 : 0) + ((cmd->buttons & BT_BRAKE || InputDown(gc_camsink, forplayer)) ? -1 : 0); + cam->z += spd * dir; + } - if (cmd->buttons & BT_ACCELERATE) - cam->z += 32*mapobjectscale; - else if (cmd->buttons & BT_BRAKE) - cam->z -= 32*mapobjectscale; + if (!(cmd->buttons & (BT_ACCELERATE | BT_DRIFT) || InputDown(gc_camfloat, forplayer)) && cam->button_a_held) + { + cam->button_a_held--; + } // if you hold item, you will lock on to displayplayer. (The last player you were ""f12-ing"") - if (cmd->buttons & BT_ATTACK) + // this feels kinda pointless for ingame freecam so keep it for replays only + if (demo.playback && cmd->buttons & BT_ATTACK) { lastp = &players[displayplayers[0]]; // Fun fact, I was trying displayplayers[0]->mo as if it was Lua like an absolute idiot. + + const fixed_t dist = R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); - cam->aiming = R_PointToAngle2(0, cam->z, R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y), lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. + cam->aiming = R_PointToAngle2(0, cam->z, dist, lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. + cam->reset_aiming = false; + } + + if (InputDown(gc_centerview, forplayer)) // No need to put a spectator limit on this one though :V + { + cam->aiming = 0; + cam->reset_aiming = false; + } + + // After switching to democam, the vertical angle of + // chasecam is inherited. This is intentional because it + // creates a smooth transition. However, moving + // forward/back will have a slope. So, as long as democam + // controls haven't been used to alter the vertical angle, + // slowly reset it to flat. + //if (cam->reset_aiming || ((cmd->buttons & BT_DRIFT) && !cam->button_a_held)) + if (cam->reset_aiming) + { + INT32 aiming = cam->aiming; + INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming)); + + if (abs(smooth) < abs(aiming)) + { + cam->aiming -= smooth * intsign(aiming); + } + else + { + cam->aiming = 0; + cam->reset_aiming = false; // completely smoothed out + } } cam->momx = cam->momy = cam->momz = 0; if (cmd->forwardmove != 0) { + fixed_t spd = cmd->forwardmove*mapobjectscale*cv_freecam_speed[num].value; thrustangle = cam->angle >> ANGLETOFINESHIFT; - cam->x += FixedMul(cmd->forwardmove*mapobjectscale, FINECOSINE(thrustangle)); - cam->y += FixedMul(cmd->forwardmove*mapobjectscale, FINESINE(thrustangle)); - cam->z += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(cam->aiming)); + cam->x += FixedMul(spd, FINECOSINE(thrustangle)); + cam->y += FixedMul(spd, FINESINE(thrustangle)); + if (!cam->reset_aiming) + { + cam->z += FixedMul(spd, AIMINGTOSLOPE(cam->aiming)); + } + // momentums are useless here, directly add to the coordinates // this.......... doesn't actually check for floors and walls and whatnot but the function to do that is a pure mess so fuck that. // besides freecam going inside walls sounds pretty cool on paper. } - // awayviewmobj hack; this is to prevent us from hearing sounds from the player's perspective + // cmd->strafemove -- cant really add stuff to ticcmd struct so im reusing this + if (cmd->sidemove != 0) // was disabled in practice anyways, since sidemove was suppressed + { + //False I fixed this shit - Nep + fixed_t spd = cmd->sidemove*mapobjectscale*cv_freecam_speed[num].value; - awayviewmobj_hack = P_SpawnMobj(cam->x, cam->y, cam->z, MT_THOK); - awayviewmobj_hack->tics = 2; - awayviewmobj_hack->flags2 |= MF2_DONTDRAW; - - democam.soundmobj = awayviewmobj_hack; + thrustangle = (cam->angle-ANGLE_90) >> ANGLETOFINESHIFT; + cam->x += FixedMul(spd, FINECOSINE(thrustangle)); + cam->y += FixedMul(spd, FINESINE(thrustangle)); + } // update subsector to avoid crashes; cam->subsector = R_PointInSubsector(cam->x, cam->y); @@ -3355,8 +3471,9 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) { tic_t tries = 0; fixed_t x, y, z; + UINT8 i; - if (demo.freecam) + if (thiscam->freecam) return; // do not reset the camera there. if (!player->mo) @@ -3379,13 +3496,14 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->z = z; thiscam->reset = true; - if (!(thiscam == &camera[0] && (cv_cam_still[0].value)) - && !(thiscam == &camera[1] && (cv_cam_still[1].value)) - && !(thiscam == &camera[2] && (cv_cam_still[2].value)) - && !(thiscam == &camera[3] && (cv_cam_still[3].value))) + for (i = 0; i <= splitscreen; i++) { - thiscam->angle = player->mo->angle; - thiscam->aiming = 0; + if (!(thiscam == &camera[i] && cv_cam_still[i].value)) + { + thiscam->angle = player->mo->angle; + thiscam->aiming = 0; + break; + } } thiscam->relativex = 0; @@ -3395,6 +3513,8 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->radius = 20*FRACUNIT; thiscam->height = 16*FRACUNIT; + thiscam->reset_aiming = true; + while (!P_MoveChaseCamera(player,thiscam,true) && ++tries < 2*TICRATE); } @@ -3608,7 +3728,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { static boolean lookbackactive[MAXSPLITSCREENPLAYERS]; static UINT8 lookbackdelay[MAXSPLITSCREENPLAYERS]; - UINT8 num, plyrnum; + UINT8 num = 0; angle_t angle = 0, focusangle = 0, focusaiming = 0; fixed_t x, y, z, dist, viewpointx, viewpointy, camspeed, camdist, camheight, pviewheight; fixed_t pan, xpan, ypan; @@ -3618,8 +3738,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall mobj_t *mo; fixed_t f1, f2; - democam.soundmobj = NULL; // reset this each frame, we don't want the game crashing for stupid reasons now do we - // We probably shouldn't move the camera if there is no player or player mobj somehow if (!player || !player->mo) return true; @@ -3628,54 +3746,31 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (thiscam->subsector == NULL || thiscam->subsector->sector == NULL) return true; - if (demo.freecam) + for (UINT8 i = 0; i <= splitscreen; i++) { - P_DemoCameraMovement(thiscam); + if (thiscam == &camera[i]) + { + num = i; + break; + } + } + + if (thiscam->freecam || player->spectator) + { + P_DemoCameraMovement(thiscam, num); + P_CalcChasePostImg(player, thiscam); return true; } - if (thiscam == &camera[1]) // Camera 2 - { - num = 1; - } - else if (thiscam == &camera[2]) // Camera 3 - { - num = 2; - } - else if (thiscam == &camera[3]) // Camera 4 - { - num = 3; - } - else // Camera 1 - { - num = 0; - } - - if (player == &players[consoleplayer]) - { - plyrnum = 0; - } - else if (player == &players[displayplayers[1]]) - { - plyrnum = 1; - } - else if (player == &players[displayplayers[2]]) - { - plyrnum = 2; - } - else if (player == &players[displayplayers[3]]) - { - plyrnum = 3; - } - else - { - plyrnum = 255; - } + if (paused || P_AutoPause()) + return true; mo = player->mo; - if (player->pflags & PF_TIMEOVER) // 1 for momentum keep, 2 for turnaround - timeover = (player->kartstuff[k_timeovercam] > 2*TICRATE ? 2 : 1); + const boolean vflip = (mo->eflags & MFE_VERTICALFLIP); + + if (cv_cam_timeover[num].value && (player->pflags & PF_TIMEOVER)) + timeover = (player->kartstuff[k_timeovercam] > 2*TICRATE ? 2 : 1); // 1 for momentum keep, 2 for turnaround else timeover = 0; @@ -3690,19 +3785,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (!thiscam->chase && !resetcalled) { - if (plyrnum != 255) - { - focusangle = localangle[plyrnum]; - } - else - { - focusangle = mo->angle; - } - - if (thiscam == &camera[num]) - camrotate = cv_cam_rotate[num].value; - else - camrotate = 0; + focusangle = ((P_IsLocalPlayer(player)) ? localangle[num] : mo->angle); + camrotate = ((thiscam == &camera[num]) ? cv_cam_rotate[num].value : 0); if (leveltime < introtime) // Whoooshy camera! { @@ -3723,10 +3807,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall focusangle = mo->angle; focusaiming = 0; } - else if (plyrnum != 255) + else if (P_IsLocalPlayer(player)) { - focusangle = localangle[plyrnum]; - focusaiming = localaiming[plyrnum]; + focusangle = localangle[num]; + focusaiming = localaiming[num]; } else { @@ -3734,6 +3818,11 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall focusaiming = player->aiming; } + if (abs(thiscam->dpad_y_held) >= 2*TICRATE) + { + focusaiming += ANGLE_45 * intsign(thiscam->dpad_y_held) * P_MobjFlip(mo); + } + if (P_CameraThinker(player, thiscam, resetcalled)) return true; @@ -3757,7 +3846,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camheight += (introcam * mapobjectscale)*2; } else if (player->exiting) // SRB2Kart: Leave the camera behind while exiting, for dramatic effect! + { camstill = true; + } else if (lookback || lookbackdelay[num]) // SRB2kart - Camera flipper { #define MAXLOOKBACKDELAY 2 @@ -3770,26 +3861,35 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall else lookbackdelay[num]--; } + lookbackdown = (lookbackdelay[num] == MAXLOOKBACKDELAY) != lookbackactive[num]; lookbackactive[num] = (lookbackdelay[num] == MAXLOOKBACKDELAY); #undef MAXLOOKBACKDELAY - if (mo->eflags & MFE_VERTICALFLIP) + if (vflip) camheight += thiscam->height; if (camspeed > FRACUNIT) camspeed = FRACUNIT; if (timeover) + { angle = mo->angle + FixedAngle(camrotate*FRACUNIT); + } else if (leveltime < starttime) + { angle = focusangle + FixedAngle(camrotate*FRACUNIT); + } else if (camstill || resetcalled || player->playerstate == PST_DEAD) + { angle = thiscam->angle; + } else { if (camspeed == FRACUNIT) + { angle = focusangle + FixedAngle(camrotate<angle; @@ -3827,7 +3927,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall // SRB2Kart: set camera panning if (camstill || resetcalled || player->playerstate == PST_DEAD) + { pan = xpan = ypan = 0; + } else { if (player->kartstuff[k_drift] != 0) @@ -3853,7 +3955,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall pviewheight = FixedMul(32<scale); - if (mo->eflags & MFE_VERTICALFLIP) + if (vflip) z = mo->z + mo->height - pviewheight - camheight; else z = mo->z + pviewheight + camheight; @@ -3881,7 +3983,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall thiscam->momz = 0; } else if (player->exiting || timeover == 2) + { thiscam->momx = thiscam->momy = thiscam->momz = 0; + } else if (leveltime < starttime) { thiscam->momx = FixedMul(x - thiscam->x, camspeed); @@ -3912,7 +4016,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall f2 = viewpointy-thiscam->y; dist = FixedHypot(f1, f2); - if (mo->eflags & MFE_VERTICALFLIP) + if (vflip) angle = R_PointToAngle2(0, thiscam->z + thiscam->height, dist, mo->z + mo->height - P_GetPlayerHeight(player)); else angle = R_PointToAngle2(0, thiscam->z, dist, mo->z + P_GetPlayerHeight(player)); @@ -3925,7 +4029,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall G_ClipAimingPitch((INT32 *)&angle); if (camspeed == FRACUNIT) + { thiscam->aiming = angle; + } else { angle_t input; @@ -3948,12 +4054,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { // Don't let the camera match your movement. thiscam->momz = 0; + if (player->spectator) thiscam->aiming = 0; // Only let the camera go a little bit downwards. - else if (!(mo->eflags & MFE_VERTICALFLIP) && thiscam->aiming < ANGLE_337h && thiscam->aiming > ANGLE_180) + else if (!vflip && thiscam->aiming < ANGLE_337h && thiscam->aiming > ANGLE_180) thiscam->aiming = ANGLE_337h; - else if (mo->eflags & MFE_VERTICALFLIP && thiscam->aiming > ANGLE_22h && thiscam->aiming < ANGLE_180) + else if (vflip && thiscam->aiming > ANGLE_22h && thiscam->aiming < ANGLE_180) thiscam->aiming = ANGLE_22h; } @@ -3968,12 +4075,19 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall void P_ResetLocalCamAiming(player_t *player) { - for (int i = 0; i <= splitscreen; i++) + UINT8 i; + + if (player == &players[consoleplayer]) + localaiming[0] = 0; + else if (splitscreen) { - UINT8 id = (i == 0) ? consoleplayer : displayplayers[i]; - if (player - players == id) + for (i = 1; i <= splitscreen; i++) // Skip P1 { - localaiming[i] = 0; + if (player == &players[displayplayers[i]]) + { + localaiming[i] = 0; + break; + } } } } @@ -4067,14 +4181,90 @@ boolean P_SpectatorJoinGame(player_t *player) return false; } -// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam -static void P_CalcPostImg(player_t *player) +static boolean P_CameraCheckHeatFirstperson(player_t *player, sector_t *sector, fixed_t pviewheight) { - sector_t *sector = player->mo->subsector->sector; - INT16 typeflag = 0; + if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1) + return true; + + if (sector->ffloors) + { + ffloor_t *rover; + + for (rover = sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS)) + continue; + + if (pviewheight >= P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y)) + continue; + + if (pviewheight <= P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y)) + continue; + + if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1) + return true; + } + } + + return false; +} + +static boolean P_CameraCheckWaterFirstperson(player_t *player, sector_t *sector, fixed_t pviewheight) +{ + if (sector->ffloors) + { + ffloor_t *rover; + + for (rover = sector->ffloors; rover; rover = rover->next) + { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKPLAYER) + continue; + + if (pviewheight >= P_GetFFloorTopZAt(rover, player->mo->x, player->mo->y)) + continue; + + if (pviewheight <= P_GetFFloorBottomZAt(rover, player->mo->x, player->mo->y)) + continue; + + return true; + } + } + + return false; +} + +// the below is first person only, if you're curious. check out P_CalcChasePostImg in p_mobj.c for chasecam +static void P_CalcPostImg(player_t *player, camera_t *thiscam) +{ + sector_t *sector = NULL; + UINT8 postimgtype = 0; //INT32 *param; - fixed_t pviewheight; - UINT8 i; + fixed_t pviewheight = 0; + + /*for (i = 0; i <= splitscreen; i++) + { + if (player == &players[displayplayers[i]]) + { + param = &postimgparam[i]; + break; + } + }*/ + + if (encoremode) // srb2kart + postimgtype |= POSTIMG_MIRROR; + + if (player->mo->eflags & MFE_VERTICALFLIP) + postimgtype |= POSTIMG_FLIP; + +#ifdef HWRENDER + if (rendermode == render_opengl && splitscreen) + { + thiscam->postimg = postimgtype; + return; + } +#endif + + sector = player->mo->subsector->sector; if (player->mo->eflags & MFE_VERTICALFLIP) pviewheight = player->mo->z + player->mo->height - player->viewheight; @@ -4087,88 +4277,25 @@ static void P_CalcPostImg(player_t *player) pviewheight = player->awayviewmobj->z + 20*FRACUNIT; } - /*for (i = 0; i <= splitscreen; i++) - { - if (player == &players[displayplayers[i]]) - { - param = &postimgparam[i]; - break; - } - }*/ - - // see if we are in heat (no, not THAT kind of heat...) - - if (P_FindSpecialLineFromTag(13, sector->tag, -1) != -1) - typeflag |= POSTIMG_HEAT; - else if (sector->ffloors) - { - ffloor_t *rover; - fixed_t topheight; - fixed_t bottomheight; - - for (rover = sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS)) - 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; - - if (pviewheight >= topheight || pviewheight <= bottomheight) - continue; - - if (P_FindSpecialLineFromTag(13, rover->master->frontsector->tag, -1) != -1) - typeflag |= POSTIMG_HEAT; - } - } - // see if we are in water (water trumps heat) - if (sector->ffloors) - { - ffloor_t *rover; - fixed_t topheight; - fixed_t bottomheight; - - for (rover = sector->ffloors; rover; rover = rover->next) - { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) || rover->flags & FF_BLOCKPLAYER) - 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; - - if (pviewheight >= topheight || pviewheight <= bottomheight) - continue; - - typeflag |= POSTIMG_WATER; - } - } - - if (encoremode) // srb2kart - typeflag |= POSTIMG_MIRROR; - - if (player->mo->eflags & MFE_VERTICALFLIP) - typeflag |= POSTIMG_FLIP; + if (P_CameraCheckWaterFirstperson(player, sector, pviewheight)) + postimgtype |= POSTIMG_WATER; + // see if we are in heat (no, not THAT kind of heat...) + else if (P_CameraCheckHeatFirstperson(player, sector, pviewheight)) + postimgtype |= POSTIMG_HEAT; // Motion blur // unused /*if (player->speed > (35<speed - 32)/4; if (*param > 5) *param = 5; }*/ - for (i = 0; i <= splitscreen; i++) - { - if (player != &players[displayplayers[i]]) - continue; - - players[displayplayers[i]].postimgflags = typeflag; - break; - } + thiscam->postimg = postimgtype; } void P_DoTimeOver(player_t *player) @@ -4186,7 +4313,7 @@ void P_DoTimeOver(player_t *player) if (player->mo) { S_StopSound(player->mo); - P_DamageMobj(player->mo, NULL, NULL, 10000); + P_DamageMobj(player->mo, NULL, NULL, DMG_INSTAKILL); } player->lives = 0; @@ -4303,6 +4430,9 @@ DoABarrelRoll (player_t *player) player->tilt = slope; } +#define SPINOUTROTSPEED (24 * FRACUNIT) +#define MAXSPINROT (360 * FRACUNIT) + // // P_PlayerThink // @@ -4446,6 +4576,31 @@ void P_PlayerThink(player_t *player) } } + if (player->kartstuff[k_spinouttimer] && (player->spinoutrot == 0)) + { + player->spinoutrot = SPINOUTROTSPEED; + } + + // MKWii-styled icon spinouts: do a full 360 rotation before stopping. + if (player->spinoutrot && (player->spinoutrot < MAXSPINROT)) + { + if ((player->spinoutrot + SPINOUTROTSPEED) >= MAXSPINROT) + { + if (player->kartstuff[k_spinouttimer]) + { + player->spinoutrot = (player->spinoutrot + SPINOUTROTSPEED) % MAXSPINROT; + } + else + { + player->spinoutrot = 0; + } + } + else + { + player->spinoutrot += SPINOUTROTSPEED; + } + } + // If it is set, start subtracting // Don't allow it to go back to 0 if (player->exiting > 1 && (player->exiting < raceexittime+2 || !G_RaceGametype())) // SRB2kart - "&& player->exiting > 1" @@ -4530,25 +4685,15 @@ void P_PlayerThink(player_t *player) if (leveltime >= starttime) { player->realtime = leveltime - starttime; - if (player == &players[consoleplayer]) - { - if (player->spectator || !circuitmap) - curlap = 0; - else - curlap++; // This is too complicated to sync to realtime, just sorta hope for the best :V - } if (player->spectator) player->laptime[LAP_CUR] = 0; - else + else if (player->laptime[LAP_CUR] != UINT32_MAX) player->laptime[LAP_CUR]++; // This is too complicated to sync to realtime, just sorta hope for the best :V } else { player->realtime = 0; - if (player == &players[consoleplayer]) - curlap = 0; - player->laptime[LAP_CUR] = 0; } } @@ -4619,8 +4764,6 @@ void P_PlayerThink(player_t *player) { player->pflags ^= PF_WANTSTOJOIN; player->powers[pw_flashing] = TICRATE/2 + 1; - /*if (P_SpectatorJoinGame(player)) - return; // player->mo was removed.*/ } // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. @@ -4660,21 +4803,23 @@ void P_PlayerThink(player_t *player) player->linkcount = 0; } - // Move around. - // Reactiontime is used to prevent movement - // for a bit after a teleport. if (player->mo->reactiontime) + { + // Reactiontime is used to prevent movement + // for a bit after a teleport. player->mo->reactiontime--; + } else if (player->mo->tracer && player->mo->tracer->type == MT_TUBEWAYPOINT) { - { - P_DoZoomTube(player); - } + P_DoZoomTube(player); player->rmomx = player->rmomy = 0; // no actual momentum from your controls P_ResetScore(player); } else + { + // Move around. P_MovePlayer(player); + } if (!player->mo) { @@ -4855,7 +5000,7 @@ void P_PlayerThink(player_t *player) K_KartPlayerThink(player, cmd); // SRB2kart - if (rendermode != render_none) + if (rendermode != render_none && cv_tilting.value) DoABarrelRoll(player); LUA_HookPlayer(player, HOOK(PlayerThink)); @@ -4953,7 +5098,7 @@ void P_PlayerAfterThink(player_t *player) if (!thiscam->chase) // bob view only if looking through the player's eyes { P_CalcHeight(player); - P_CalcPostImg(player); + P_CalcPostImg(player, thiscam); } else { diff --git a/src/qs22j.c b/src/qs22j.c index 17f2b7c2e..c610bde4d 100644 --- a/src/qs22j.c +++ b/src/qs22j.c @@ -16,6 +16,7 @@ #include #include + #include "qs22j.h" #define INSORTTHRESH 5 // if n < this use insertion sort diff --git a/src/r_bsp.c b/src/r_bsp.c index 7f0f6fff8..c68432012 100644 --- a/src/r_bsp.c +++ b/src/r_bsp.c @@ -263,21 +263,11 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, mobj_t *pviewmobj = viewplayer->mo; INT32 heightsec; boolean underwater; - UINT8 i; - - for (i = 0; i <= splitscreen; i++) - { - if (viewplayer != &players[displayplayers[i]]) - continue; - - if (!camera[i].chase) - continue; + UINT8 i = R_GetViewNumber(); + if (viewplayer == &players[displayplayers[i]] && camera[i].chase) heightsec = R_PointInSubsector(camera[i].x, camera[i].y)->sector->heightsec; - break; - } - - if (i > splitscreen && pviewmobj) + else if (i > splitscreen && viewmobj) heightsec = R_PointInSubsector(pviewmobj->x, pviewmobj->y)->sector->heightsec; else return sec; @@ -433,7 +423,7 @@ static void R_AddLine(seg_t *line) span = angle1 - angle2; // Back side? i.e. backface culling? - if (span >= ANGLE_180) + if (span >= ANGLE_180 || !line->linedef) return; // Global angle needed by segcalc. @@ -504,11 +494,12 @@ static void R_AddLine(seg_t *line) doorclosed = 0; + fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends + fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends + // Closed door. if (frontsector->f_slope || frontsector->c_slope || backsector->f_slope || backsector->c_slope) { - fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends - fixed_t backf1, backf2, backc1, backc2; // back floor ceiling ends #define SLOPEPARAMS(slope, end1, end2, normalheight) \ if (slope) { \ end1 = P_GetZAt(slope, line->v1->x, line->v1->y); \ @@ -521,57 +512,44 @@ static void R_AddLine(seg_t *line) SLOPEPARAMS( backsector->f_slope, backf1, backf2, backsector->floorheight) SLOPEPARAMS( backsector->c_slope, backc1, backc2, backsector->ceilingheight) #undef SLOPEPARAMS - if (viewsector != backsector && viewsector != frontsector) - { - if ((backc1 <= frontf1 && backc2 <= frontf2) - || (backf1 >= frontc1 && backf2 >= frontc2)) - { - goto clipsolid; - } - - // Check for automap fix. Store in doorclosed for r_segs.c - doorclosed = (backc1 <= backf1 && backc2 <= backf2 - && ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture) - && ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture) - && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum)); - - if (doorclosed) - goto clipsolid; - } - - // Window. - if (backc1 != frontc1 || backc2 != frontc2 - || backf1 != frontf1 || backf2 != frontf2) - { - goto clippass; - } } else { - if (viewsector != backsector && viewsector != frontsector) + frontf1 = frontf2 = frontsector->floorheight; + frontc1 = frontc2 = frontsector->ceilingheight; + backf1 = backf2 = backsector->floorheight; + backc1 = backc2 = backsector->ceilingheight; + } + + if (viewsector != backsector && viewsector != frontsector) + { + // here we're talking about a CEILING lower than a floor. ...yeah we don't even need to bother. + if (backc1 <= frontf1 && backc2 <= frontf2) { - if (backsector->ceilingheight <= frontsector->floorheight - || backsector->floorheight >= frontsector->ceilingheight) - { - goto clipsolid; - } - - // Check for automap fix. Store in doorclosed for r_segs.c - doorclosed = (backsector->ceilingheight <= backsector->floorheight - && (backsector->ceilingheight >= frontsector->ceilingheight || curline->sidedef->toptexture) - && (backsector->floorheight <= frontsector->floorheight || curline->sidedef->bottomtexture) - && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum)); - - if (doorclosed) - goto clipsolid; + goto clipsolid; } - // Window. - if (backsector->ceilingheight != frontsector->ceilingheight - || backsector->floorheight != frontsector->floorheight) + // here we're talking about floors higher than ceilings, don't even bother either. + if (backf1 >= frontc1 && backf2 >= frontc2) { - goto clippass; + goto clipsolid; } + + // Check for automap fix. Store in doorclosed for r_segs.c + doorclosed = (backc1 <= backf1 && backc2 <= backf2 + && ((backc1 >= frontc1 && backc2 >= frontc2) || curline->sidedef->toptexture) + && ((backf1 <= frontf1 && backf2 >= frontf2) || curline->sidedef->bottomtexture) + && (backsector->ceilingpic != skyflatnum || frontsector->ceilingpic != skyflatnum)); + + if (doorclosed) + goto clipsolid; + } + + // Window. + if (backc1 != frontc1 || backc2 != frontc2 + || backf1 != frontf1 || backf2 != frontf2) + { + goto clippass; } // Reject empty lines used for triggers and special events. @@ -907,6 +885,9 @@ static void R_Subsector(size_t num) { for (rover = frontsector->ffloors; rover; rover = rover->next) { + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_RENDERPLANES)) + continue; + sector_t *controlSec = §ors[rover->secnum]; if (controlSec->moved != true) diff --git a/src/r_data.c b/src/r_data.c index 98431510d..26fdb06aa 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -126,6 +126,113 @@ size_t flatmemory, spritememory, texturememory; // gotta play by 2.2 rules to ge INT16 color8to16[256]; // remap color index to highcolor rgb value INT16 *hicolormaps; // test a 32k colormap remaps high -> high +// Blends two pixels together, using the equation +// that matches the specified alpha style. +UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha) +{ + RGBA_t output; + INT16 fullalpha = (alpha - (0xFF - foreground.s.alpha)); + if (style == AST_TRANSLUCENT) + { + if (fullalpha <= 0) + output.rgba = background.rgba; + else + { + // don't go too high + if (fullalpha >= 0xFF) + fullalpha = 0xFF; + alpha = (UINT8)fullalpha; + + // if the background pixel is empty, + // match software and don't blend anything + if (!background.s.alpha) + { + // ...unless the foreground pixel ISN'T actually translucent. + if (alpha == 0xFF) + output.rgba = foreground.rgba; + else + output.rgba = 0; + } + else + { + UINT8 beta = (0xFF - alpha); + output.s.red = ((background.s.red * beta) + (foreground.s.red * alpha)) / 0xFF; + output.s.green = ((background.s.green * beta) + (foreground.s.green * alpha)) / 0xFF; + output.s.blue = ((background.s.blue * beta) + (foreground.s.blue * alpha)) / 0xFF; + output.s.alpha = 0xFF; + } + } + return output.rgba; + } +#define clamp(c) max(min(c, 0xFF), 0x00); + else + { + float falpha = ((float)alpha / 256.0f); + float fr = ((float)foreground.s.red * falpha); + float fg = ((float)foreground.s.green * falpha); + float fb = ((float)foreground.s.blue * falpha); + if (style == AST_ADD) + { + output.s.red = clamp((int)(background.s.red + fr)); + output.s.green = clamp((int)(background.s.green + fg)); + output.s.blue = clamp((int)(background.s.blue + fb)); + } + else if (style == AST_SUBTRACT) + { + output.s.red = clamp((int)(background.s.red - fr)); + output.s.green = clamp((int)(background.s.green - fg)); + output.s.blue = clamp((int)(background.s.blue - fb)); + } + else if (style == AST_REVERSESUBTRACT) + { + output.s.red = clamp((int)((-background.s.red) + fr)); + output.s.green = clamp((int)((-background.s.green) + fg)); + output.s.blue = clamp((int)((-background.s.blue) + fb)); + } + else if (style == AST_MODULATE) + { + fr = ((float)foreground.s.red / 256.0f); + fg = ((float)foreground.s.green / 256.0f); + fb = ((float)foreground.s.blue / 256.0f); + output.s.red = clamp((int)(background.s.red * fr)); + output.s.green = clamp((int)(background.s.green * fg)); + output.s.blue = clamp((int)(background.s.blue * fb)); + } + // just copy the pixel + else if (style == AST_COPY) + output.rgba = foreground.rgba; + + output.s.alpha = 0xFF; + return output.rgba; + } +#undef clamp + return 0; +} + +INT32 ASTTextureBlendingThreshold[2] = {255/11, (10*255/11)}; + +// Blends a pixel for a texture patch. +UINT32 ASTBlendTexturePixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha) +{ + // Alpha style set to translucent? + if (style == AST_TRANSLUCENT) + { + // Is the alpha small enough for translucency? + if (alpha <= ASTTextureBlendingThreshold[1]) + { + // Is the patch way too translucent? Don't blend then. + if (alpha < ASTTextureBlendingThreshold[0]) + return background.rgba; + + return ASTBlendPixel(background, foreground, style, alpha); + } + else // just copy the pixel + return foreground.rgba; + } + else + return ASTBlendPixel(background, foreground, style, alpha); +} + // Painfully simple texture id cacheing to make maps load faster. :3 static struct { char name[9]; @@ -282,6 +389,11 @@ static UINT8 *R_GenerateTexture(size_t texnum) for (i = 0, patch = texture->patches; i < texture->patchcount; i++, patch++) { realpatch = W_CacheLumpNumPwad(patch->wad, patch->lump, PU_CACHE); + + // Well, it's not valid... + if (realpatch == NULL) + continue; + x1 = patch->originx; x2 = x1 + SHORT(realpatch->width); diff --git a/src/r_data.h b/src/r_data.h index ec1146322..f27dd0822 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -56,6 +56,9 @@ extern INT32 *texturewidthmask; extern fixed_t *textureheight; // needed for texture pegging +UINT32 ASTBlendPixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha); +UINT32 ASTBlendTexturePixel(RGBA_t background, RGBA_t foreground, int style, UINT8 alpha); + extern INT16 color8to16[256]; // remap color index to highcolor extern INT16 *hicolormaps; // remap high colors to high colors.. diff --git a/src/r_defs.h b/src/r_defs.h index bc95649bb..389dd497d 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -172,6 +172,7 @@ typedef struct ffloor_s INT32 lastlight; INT32 alpha; + UINT8 blend; // blendmode tic_t norender; // for culling // these are saved for netgames, so do not let Lua touch these! @@ -354,9 +355,6 @@ typedef struct sector_s // Current speed of ceiling/floor. For Knuckles to hold onto stuff. fixed_t floorspeed, ceilspeed; - // list of precipitation mobjs in sector - struct mprecipsecnode_s *touching_preciplist; - // Eternity engine slope pslope_t *f_slope; // floor slope pslope_t *c_slope; // ceiling slope @@ -402,6 +400,8 @@ typedef struct line_s // Visual appearance: sidedefs. UINT16 sidenum[2]; // sidenum[1] will be 0xffff if one-sided + fixed_t alpha; // translucency + UINT8 blendmode; // blendmode fixed_t bbox[4]; // bounding box for the extent of the linedef @@ -492,17 +492,6 @@ typedef struct msecnode_s boolean visited; // used in search algorithms } msecnode_t; -typedef struct mprecipsecnode_s -{ - sector_t *m_sector; // a sector containing this object - struct precipmobj_s *m_thing; // this object - struct mprecipsecnode_s *m_sectorlist_prev; // prev msecnode_t for this thing - struct mprecipsecnode_s *m_sectorlist_next; // next msecnode_t for this thing - struct mprecipsecnode_s *m_thinglist_prev; // prev msecnode_t for this sector - struct mprecipsecnode_s *m_thinglist_next; // next msecnode_t for this sector - boolean visited; // used in search algorithms -} mprecipsecnode_t; - // // The lineseg. // @@ -687,6 +676,9 @@ typedef struct #pragma pack() #endif +// Possible alpha types for a patch. +enum patchalphastyle {AST_COPY, AST_TRANSLUCENT, AST_ADD, AST_SUBTRACT, AST_REVERSESUBTRACT, AST_MODULATE, AST_OVERLAY}; + typedef enum { SRF_SINGLE = 0, // 0-angle for all rotations diff --git a/src/r_draw.c b/src/r_draw.c index faa9ba638..ef4496349 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -86,6 +86,7 @@ INT32 dc_sourcelength; #define NUMTRANSTABLES 9 // how many translucency tables are used UINT8 *transtables; // translucency tables +UINT8 *blendtables[NUMBLENDMAPS]; /** \brief R_DrawTransColumn uses this */ @@ -213,11 +214,11 @@ const UINT8 Color_Opposite[MAXSKINCOLORS*2] = CV_PossibleValue_t Color_cons_t[MAXSKINCOLORS+1]; -/** \brief The R_InitTranslationTables +#define TRANSTAB_AMTMUL10 (256.0f / 10.0f) - load in color translation tables +/** \brief Initializes the translucency tables used by the Software renderer. */ -void R_InitTranslationTables(void) +void R_InitTranslucencyTables(void) { // Load here the transparency lookup tables 'TINTTAB' // NOTE: the TINTTAB resource MUST BE aligned on 64k for the asm @@ -234,6 +235,189 @@ void R_InitTranslationTables(void) W_ReadLump(W_GetNumForName("TRANS70"), transtables+0x60000); W_ReadLump(W_GetNumForName("TRANS80"), transtables+0x70000); W_ReadLump(W_GetNumForName("TRANS90"), transtables+0x80000); + + R_GenerateBlendTables(); +} + +static colorlookup_t transtab_lut; + +static void BlendTab_Translucent(UINT8 *table, int style, UINT8 blendamt) +{ + INT16 bg, fg; + + if (table == NULL) + I_Error("BlendTab_Translucent: input table was NULL!"); + + for (bg = 0; bg < 0x100; bg++) + { + for (fg = 0; fg < 0x100; fg++) + { + RGBA_t backrgba = V_GetColor(bg); + RGBA_t frontrgba = V_GetColor(fg); + RGBA_t result; + + result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); + result.rgba = ASTBlendPixel(result, frontrgba, AST_TRANSLUCENT, blendamt); + + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); + } + } +} + +static void BlendTab_Subtractive(UINT8 *table, int style, UINT8 blendamt) +{ + INT16 bg, fg; + + if (table == NULL) + I_Error("BlendTab_Subtractive: input table was NULL!"); + + if (blendamt == 0xFF) + { + memset(table, GetColorLUT(&transtab_lut, 0, 0, 0), 0x10000); + return; + } + + for (bg = 0; bg < 0x100; bg++) + { + for (fg = 0; fg < 0x100; fg++) + { + RGBA_t backrgba = V_GetColor(bg); + RGBA_t frontrgba = V_GetColor(fg); + RGBA_t result; + + result.rgba = ASTBlendPixel(backrgba, frontrgba, style, 0xFF); + result.s.red = max(0, result.s.red - blendamt); + result.s.green = max(0, result.s.green - blendamt); + result.s.blue = max(0, result.s.blue - blendamt); + + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); + } + } +} + +static void BlendTab_Modulative(UINT8 *table) +{ + INT16 bg, fg; + + if (table == NULL) + I_Error("BlendTab_Modulative: input table was NULL!"); + + for (bg = 0; bg < 0x100; bg++) + { + for (fg = 0; fg < 0x100; fg++) + { + RGBA_t backrgba = V_GetColor(bg); + RGBA_t frontrgba = V_GetColor(fg); + RGBA_t result; + result.rgba = ASTBlendPixel(backrgba, frontrgba, AST_MODULATE, 0); + table[((bg * 0x100) + fg)] = GetColorLUT(&transtab_lut, result.s.red, result.s.green, result.s.blue); + } + } +} + +static INT32 BlendTab_Count[NUMBLENDMAPS] = +{ + NUMTRANSTABLES, // blendtab_add + NUMTRANSTABLES+1, // blendtab_subtract + NUMTRANSTABLES+1, // blendtab_reversesubtract + 1 // blendtab_modulate +}; + +static INT32 BlendTab_FromStyle[] = +{ + 0, // AST_COPY + 0, // AST_TRANSLUCENT + blendtab_add, // AST_ADD + blendtab_subtract, // AST_SUBTRACT + blendtab_reversesubtract, // AST_REVERSESUBTRACT + blendtab_modulate, // AST_MODULATE + 0 // AST_OVERLAY +}; + +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)); + for (; i < num; i++) + { + const size_t offs = (0x10000 * i); + const UINT16 alpha = min(amtmul * i, 0xFF); + genfunc(blendtables[tab] + offs, style, alpha); + } +} + +void R_GenerateBlendTables(void) +{ + INT32 i; + + for (i = 0; i < NUMBLENDMAPS; i++) + blendtables[i] = Z_MallocAlign(BlendTab_Count[i] * 0x10000, PU_STATIC, NULL, 16); + + InitColorLUT(&transtab_lut, pLocalPalette, false); + + // Additive + BlendTab_GenerateMaps(blendtab_add, AST_ADD, BlendTab_Translucent); + + // Subtractive +#if 1 + BlendTab_GenerateMaps(blendtab_subtract, AST_SUBTRACT, BlendTab_Subtractive); +#else + BlendTab_GenerateMaps(blendtab_subtract, AST_SUBTRACT, BlendTab_Translucent); +#endif + + // Reverse subtractive + BlendTab_GenerateMaps(blendtab_reversesubtract, AST_REVERSESUBTRACT, BlendTab_Translucent); + + // Modulative blending only requires a single table + BlendTab_Modulative(blendtables[blendtab_modulate]); +} + +#define ClipBlendLevel(style, trans) max(min((trans), BlendTab_Count[BlendTab_FromStyle[style]]-1), 0) +#define ClipTransLevel(trans) max(min((trans), NUMTRANSMAPS-2), 0) + +UINT8 *R_GetTranslucencyTable(INT32 alphalevel) +{ + return transtables + (ClipTransLevel(alphalevel-1) << FF_TRANSSHIFT); +} + +UINT8 *R_GetBlendTable(int style, INT32 alphalevel) +{ + size_t offs; + + if (style == AST_COPY || style == AST_OVERLAY) + return NULL; + + offs = (ClipBlendLevel(style, alphalevel) << FF_TRANSSHIFT); + + // Lactozilla: Returns the equivalent to AST_TRANSLUCENT + // if no alpha style matches any of the blend tables. + switch (style) + { + case AST_ADD: + return blendtables[blendtab_add] + offs; + case AST_SUBTRACT: + return blendtables[blendtab_subtract] + offs; + case AST_REVERSESUBTRACT: + return blendtables[blendtab_reversesubtract] + offs; + case AST_MODULATE: + return blendtables[blendtab_modulate]; + default: + break; + } + + // Return a normal translucency table + if (--alphalevel >= 0) + return transtables + (ClipTransLevel(alphalevel) << FF_TRANSSHIFT); + else + return NULL; +} + +boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel) +{ + if (blendmode == AST_COPY || blendmode == AST_SUBTRACT || blendmode == AST_MODULATE || blendmode == AST_OVERLAY) + return true; + + return (alphalevel < BlendTab_Count[BlendTab_FromStyle[blendmode]]); } /** \brief Retrieves a translation colormap from the cache. diff --git a/src/r_draw.h b/src/r_draw.h index 7dbeda7c9..39587a696 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -40,7 +40,6 @@ extern UINT8 dc_hires; extern UINT8 *dc_source; // first pixel in a column // translucency stuff here -extern UINT8 *transtables; // translucency tables, should be (*transtables)[5][256][256] extern UINT8 *dc_transmap; // translation stuff here @@ -117,7 +116,6 @@ extern lumpnum_t viewborderlump[8]; #define TC_BLINK -6 // For item blinking // Initialize color translation tables, for player rendering etc. -void R_InitTranslationTables(void); 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); patch_t* R_GetSkinFaceRank(player_t* ply); @@ -126,6 +124,27 @@ patch_t* R_GetSkinFaceMini(player_t* ply); void R_FlushTranslationColormapCache(void); UINT8 R_GetColorByName(const char *name); +extern UINT8 *transtables; // translucency tables, should be (*transtables)[5][256][256] + +enum +{ + blendtab_add, + blendtab_subtract, + blendtab_reversesubtract, + blendtab_modulate, + NUMBLENDMAPS +}; + +extern UINT8 *blendtables[NUMBLENDMAPS]; + +void R_InitTranslucencyTables(void); +void R_GenerateBlendTables(void); + +UINT8 *R_GetTranslucencyTable(INT32 alphalevel); +UINT8 *R_GetBlendTable(int style, INT32 alphalevel); + +boolean R_BlendLevelVisible(INT32 blendmode, INT32 alphalevel); + // Custom player skin translation void R_InitViewBuffer(INT32 width, INT32 height); void R_InitViewBorder(void); diff --git a/src/r_draw8.c b/src/r_draw8.c index 30fe49372..1a6e45a5a 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -60,25 +60,13 @@ void R_DrawColumn_8(void) register const UINT8 *source = dc_source; register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight-1; + register INT32 heightmask = dc_sourcelength-1; + npow2min = -1; + npow2max = dc_sourcelength-1; - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (dc_sourcelength & heightmask) // not a power of 2 -- killough { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -192,26 +180,14 @@ void R_Draw2sMultiPatchColumn_8(void) // This is as fast as it gets. register const UINT8 *source = dc_source; register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight-1; + register INT32 heightmask = dc_sourcelength-1; register UINT8 val; + npow2min = -1; + npow2max = dc_sourcelength-1; - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (dc_sourcelength & heightmask) // not a power of 2 -- killough { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -343,26 +319,14 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) register const UINT8 *source = dc_source; register const UINT8 *transmap = dc_transmap; register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight-1; + register INT32 heightmask = dc_sourcelength-1; register UINT8 val; + npow2min = -1; + npow2max = dc_sourcelength-1; - if (dc_texheight & heightmask) // not a power of 2 -- killough + if (dc_sourcelength & heightmask) // not a power of 2 -- killough { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -535,25 +499,13 @@ void R_DrawTranslucentColumn_8(void) register const UINT8 *source = dc_source; register const UINT8 *transmap = dc_transmap; register const lighttable_t *colormap = dc_colormap; - register INT32 heightmask = dc_texheight - 1; + register INT32 heightmask = dc_sourcelength-1; + npow2min = -1; + npow2max = dc_sourcelength-1; - if (dc_texheight & heightmask) + if (dc_sourcelength & heightmask) { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -653,25 +605,13 @@ 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_texheight - 1; + register INT32 heightmask = dc_sourcelength-1; + npow2min = -1; + npow2max = dc_sourcelength-1; - if (dc_texheight & heightmask) + if (dc_sourcelength & heightmask) { - heightmask++; - heightmask <<= FRACBITS; - - if (dc_sourcelength <= 0) - { - // Note: we need to unconditionally clamp in npow2 draw loop to avoid a CPU branch - // This is to just render it effectively the identity function. - npow2min = INT32_MIN; - npow2max = INT32_MAX; - } - else - { - npow2min = -1; - npow2max = dc_sourcelength; - } + heightmask = dc_texheight << FRACBITS; if (frac < 0) { @@ -804,17 +744,14 @@ void R_DrawSpan_8 (void) fixed_t xstep, ystep; register UINT32 bit; - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; + 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; 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) @@ -822,12 +759,8 @@ 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 <<= nflatshiftup; yposition <<= nflatshiftup; - xstep <<= nflatshiftup; ystep <<= nflatshiftup; - - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; + xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; + xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; if (dest+8 > deststop) { @@ -868,14 +801,13 @@ 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 left = ds_x1, right = ds_x2; - fixed_t step = (end-start)/(ds_x2-ds_x1+1); INT32 i; + fixed_t step = (end-start)/(ds_x2-ds_x1+1); // 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 = left; i <= right; i++) + for (i = ds_x1; i <= ds_x2; i++) { tiltlighting[i] = (start += step) >> FRACBITS; @@ -897,7 +829,6 @@ void R_CalcTiltedLighting(fixed_t start, fixed_t end) */ void R_DrawTiltedSpan_8(void) { - // x1, x2 = ds_x1, ds_x2 int width = ds_x2 - ds_x1; double iz, uz, vz; UINT32 u, v; @@ -933,7 +864,6 @@ void R_DrawTiltedSpan_8(void) dest = ylookup[ds_y] + columnofs[ds_x1]; source = ds_source; - //colormap = ds_colormap; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -961,7 +891,6 @@ void R_DrawTiltedSpan_8(void) izstep = ds_szp->x * SPANSIZE; uzstep = ds_sup->x * SPANSIZE; vzstep = ds_svp->x * SPANSIZE; - //x1 = 0; width++; while (width >= SPANSIZE) @@ -1038,7 +967,6 @@ void R_DrawTiltedSpan_8(void) */ void R_DrawTiltedTranslucentSpan_8(void) { - // x1, x2 = ds_x1, ds_x2 int width = ds_x2 - ds_x1; double iz, uz, vz; UINT32 u, v; @@ -1074,7 +1002,6 @@ void R_DrawTiltedTranslucentSpan_8(void) dest = ylookup[ds_y] + columnofs[ds_x1]; source = ds_source; - //colormap = ds_colormap; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -1102,7 +1029,6 @@ void R_DrawTiltedTranslucentSpan_8(void) izstep = ds_szp->x * SPANSIZE; uzstep = ds_sup->x * SPANSIZE; vzstep = ds_svp->x * SPANSIZE; - //x1 = 0; width++; while (width >= SPANSIZE) @@ -1180,7 +1106,6 @@ void R_DrawTiltedTranslucentSpan_8(void) */ void R_DrawTiltedTranslucentWaterSpan_8(void) { - // x1, x2 = ds_x1, ds_x2 int width = ds_x2 - ds_x1; double iz, uz, vz; UINT32 u, v; @@ -1218,7 +1143,6 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; source = ds_source; - //colormap = ds_colormap; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -1246,7 +1170,6 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) izstep = ds_szp->x * SPANSIZE; uzstep = ds_sup->x * SPANSIZE; vzstep = ds_svp->x * SPANSIZE; - //x1 = 0; width++; while (width >= SPANSIZE) @@ -1618,17 +1541,14 @@ void R_DrawTranslucentSpan_8 (void) fixed_t xstep, ystep; register UINT32 bit; - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; + 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; 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) @@ -1636,12 +1556,8 @@ 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 <<= nflatshiftup; yposition <<= nflatshiftup; - xstep <<= nflatshiftup; ystep <<= nflatshiftup; - - source = ds_source; - colormap = ds_colormap; - dest = ylookup[ds_y] + columnofs[ds_x1]; + xposition = ds_xfrac << nflatshiftup; yposition = ds_yfrac << nflatshiftup; + xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; while (count >= 8) { @@ -1677,10 +1593,10 @@ void R_DrawTranslucentWaterSpan_8(void) UINT32 xstep, ystep; register UINT32 bit; - UINT8 *source; - UINT8 *colormap; - register UINT8 *dest; - UINT8 *dsrc; + const UINT8 *source = ds_source; + const UINT8 *colormap = ds_colormap; + register UINT8 *dest = ylookup[ds_y] + columnofs[ds_x1]; + register UINT8 *dsrc; register size_t count; size_t i; @@ -1695,9 +1611,6 @@ 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; @@ -1739,7 +1652,6 @@ void R_DrawFogSpan_8(void) register size_t count; colormap = ds_colormap; - //dest = ylookup[ds_y] + columnofs[ds_x1]; dest = &topleft[ds_y *vid.width + ds_x1]; count = ds_x2 - ds_x1 + 1; diff --git a/src/r_fps.h b/src/r_fps.h index 5ac6cfe90..563989fa6 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -37,6 +37,10 @@ enum viewcontext_e VIEWCONTEXT_SKY4 }; +extern enum viewcontext_e viewcontext; + +#define R_GetViewNumber() ((viewcontext - VIEWCONTEXT_PLAYER1) & 3) + typedef struct { fixed_t x; fixed_t y; diff --git a/src/r_main.c b/src/r_main.c index 276083778..0a0d75053 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -143,12 +143,14 @@ static CV_PossibleValue_t maxinterpdist_cons_t[] = { {3072, "3072"}, {4096, "4096"}, {6144, "6144"}, {8192, "8192"}, {0, "Infinite"}, {0, NULL}}; -static CV_PossibleValue_t fov_cons_t[] = {{5*FRACUNIT, "MIN"}, {178*FRACUNIT, "MAX"}, {0, NULL}}; +static CV_PossibleValue_t fov_cons_t[] = {{MINFOV*FRACUNIT, "MIN"}, {MAXFOV*FRACUNIT, "MAX"}, {0, NULL}}; static CV_PossibleValue_t translucenthud_cons_t[] = {{0, "MIN"}, {10, "MAX"}, {0, NULL}}; static CV_PossibleValue_t maxportals_cons_t[] = {{0, "MIN"}, {12, "MAX"}, {0, NULL}}; // lmao rendering 32 portals, you're a card static CV_PossibleValue_t homremoval_cons_t[] = {{0, "No"}, {1, "Yes"}, {2, "Flash"}, {0, NULL}}; +static void R_SetFov(fixed_t playerfov); + static void Fov_OnChange(void); static void FlipCam_OnChange(void); static void FlipCam2_OnChange(void); @@ -202,6 +204,7 @@ consvar_t cv_ripplewater = {"waterripples", "On", CV_SAVE, CV_OnOff, NULL, 0, NU // cap fov, fov too high tears software apart. consvar_t cv_fov = {"fov", "90", CV_FLOAT|CV_CALL|CV_SAVE, fov_cons_t, Fov_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_fovchange = {"fovchange", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; // Okay, whoever said homremoval causes a performance hit should be shot. consvar_t cv_homremoval = {"homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -296,12 +299,14 @@ static void Precipstuff_OnChange(void) thinker_t *next; precipmobj_t *precipmobj; - for (think = thinkercap.next; think != &thinkercap; think = next) + for (think = precipcap.next; think != &precipcap; think = next) { next = think->next; +#ifdef PARANOIA if (think->function.acp1 != (actionf_p1)P_NullPrecipThinker) continue; // not a precipmobj thinker +#endif precipmobj = (precipmobj_t *)think; P_FreePrecipMobj(precipmobj); @@ -379,7 +384,7 @@ angle_t R_PlayerSliptideAngle(player_t *player) spriteframe_t *sprframe; angle_t ang = 0; - if (!cv_sloperoll.value || !cv_sliptideroll.value || !player || P_MobjWasRemoved(player->mo)) + if (!cv_sliptideroll.value || !player || P_MobjWasRemoved(player->mo)) return 0; mo = player->mo; @@ -846,13 +851,10 @@ void R_ApplyViewMorph(void) vid.width*vid.bpp, vid.height, vid.width*vid.bpp, vid.width); } -static inline int intsign(int n) { - return n < 0 ? -1 : n > 0 ? 1 : 0; -} - angle_t R_ViewRollAngle(const player_t *player) { angle_t roll = 0; + const UINT8 viewnum = R_GetViewNumber(); if (gamestate != GS_LEVEL) { @@ -871,7 +873,7 @@ angle_t R_ViewRollAngle(const player_t *player) if (cv_tilting.value) { - if (!player->spectator && !demo.freecam) + if (!player->spectator && !camera[viewnum].freecam) roll += player->tilt; if (cv_actionmovie.value) @@ -904,12 +906,10 @@ void R_SetViewSize(void) // void R_ExecuteSetViewSize(void) { - fixed_t dy; INT32 i; INT32 j; INT32 level; INT32 startmapl; - angle_t fov; setsizeneeded = false; @@ -938,17 +938,10 @@ void R_ExecuteSetViewSize(void) centerxfrac = centerx<> ANGLETOFINESHIFT), viewmorph.zoomneeded); - if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view - fovtan = 17*fovtan/10; - - projection = projectiony = FixedDiv(centerxfrac, fovtan); + R_SetFov(cv_fov.value); R_InitViewBuffer(scaledviewwidth, viewheight); - R_InitTextureMapping(); - // why did we calc all the software crap? #ifdef HWRENDER if (rendermode == render_opengl) @@ -963,19 +956,6 @@ void R_ExecuteSetViewSize(void) for (i = 0; i < viewwidth; i++) screenheightarray[i] = (INT16)viewheight; - // setup sky scaling - R_SetSkyScale(); - - // planes - // this is only used for planes rendering in software mode - j = viewheight*16; - for (i = 0; i < j; i++) - { - dy = (i - viewheight*8)<fovadd; + return max(MINFOV*FRACUNIT, min(fov, MAXFOV*FRACUNIT)); +} + +static void R_SetFov(fixed_t playerfov) +{ + angle_t fov = FixedAngle(playerfov/2) + ANGLE_90; + fovtan = FixedMul(FINETANGENT(fov >> ANGLETOFINESHIFT), viewmorph.zoomneeded); + if (splitscreen == 1) // Splitscreen FOV should be adjusted to maintain expected vertical view + fovtan = 17*fovtan/10; + + // this is only used for planes rendering in software mode + INT32 j = viewheight*16; + for (INT32 i = 0; i < j; i++) + { + fixed_t dy = (i - viewheight*8)<player = player; @@ -1082,12 +1093,12 @@ static void R_SetupCommonFrame(player_t * player, subsector_t * subsector) newview->roll = R_ViewRollAngle(player); - if (subsector && subsector->sector) - newview->sector = subsector->sector; + if (sector != NULL) + newview->sector = sector; else newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - R_InterpolateView(R_UsingFrameInterpolation() ? (demo.playback && demo.freecam) ? rendertimefrac_unpaused : rendertimefrac : FRACUNIT, false); + R_InterpolateView(R_UsingFrameInterpolation() ? rendertimefrac_unpaused : FRACUNIT, false); } static void R_SetupAimingFrame(player_t *player, camera_t *thiscam) @@ -1213,10 +1224,10 @@ void R_SkyboxFrame(int s) } #undef SETUPSKYVIEW - if (!P_MobjWasRemoved(viewmobj)) + if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && viewmobj->subsector->sector) subsector = viewmobj->subsector; - R_SetupCommonFrame(player, subsector); + R_SetupCommonFrame(player, subsector->sector); } void R_SetupFrame(int s, boolean skybox) @@ -1224,7 +1235,7 @@ void R_SetupFrame(int s, boolean skybox) player_t *player = &players[displayplayers[s]]; camera_t *thiscam = &camera[s]; boolean chasecam = (cv_chasecam[s].value); - subsector_t * subsector = NULL; + sector_t * sector = NULL; R_SetViewContext(VIEWCONTEXT_PLAYER1 + s); if (thiscam->reset) @@ -1233,9 +1244,14 @@ void R_SetupFrame(int s, boolean skybox) thiscam->reset = false; } - if (player->spectator) // no spectator chasecam - chasecam = false; // force chasecam off - else if (player->playerstate == PST_DEAD || player->exiting) + if (player->spectator) + { + // Free flying spectator uses demo freecam. This + // requires chasecam to be enabled. + chasecam = true; + } + + if (player->playerstate == PST_DEAD || player->exiting) chasecam = true; // force chasecam on if (chasecam && (thiscam && !thiscam->chase)) @@ -1259,12 +1275,12 @@ void R_SetupFrame(int s, boolean skybox) newview->y = viewmobj->y; newview->z = viewmobj->z + 20*FRACUNIT; - if (!P_MobjWasRemoved(viewmobj)) - subsector = viewmobj->subsector; + if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && viewmobj->subsector->sector) + sector = viewmobj->subsector->sector; - R_SetupCommonFrame(player, subsector); + R_SetupCommonFrame(player, sector); } - else if (!player->spectator && (thiscam && chasecam)) // use outside cam view + else if (thiscam && chasecam) // use outside cam view { viewmobj = NULL; @@ -1272,10 +1288,10 @@ void R_SetupFrame(int s, boolean skybox) newview->y = thiscam->y; newview->z = thiscam->z + (thiscam->height>>1); - if (thiscam != NULL) - subsector = thiscam->subsector; + if (thiscam != NULL && thiscam->subsector && thiscam->subsector->sector) + sector = thiscam->subsector->sector; - R_SetupCommonFrame(player, subsector); + R_SetupCommonFrame(player, sector); } else // use the player's eyes view { @@ -1286,10 +1302,10 @@ void R_SetupFrame(int s, boolean skybox) newview->y = viewmobj->y; newview->z = player->viewz; - if (!P_MobjWasRemoved(viewmobj)) - subsector = viewmobj->subsector; + if (!P_MobjWasRemoved(viewmobj) && viewmobj->subsector && viewmobj->subsector->sector) + sector = viewmobj->subsector->sector; - R_SetupCommonFrame(player, subsector); + R_SetupCommonFrame(player, sector); } } @@ -1330,6 +1346,8 @@ static void R_PortalFrame(portal_t *portal) // I mean, there is a win16lock() or something that lasts all the rendering, // so maybe we should release screen lock before each netupdate below..? +static fixed_t viewfov[MAXSPLITSCREENPLAYERS]; + void R_RenderPlayerView(player_t *player) { const boolean skybox = (skyboxmo[0] && cv_skybox.value); @@ -1368,6 +1386,18 @@ void R_RenderPlayerView(player_t *player) break; } + fixed_t fov = R_GetPlayerFov(player); + + for (UINT8 j = 0; j <= splitscreen; j++) + { + if (player == &players[displayplayers[i]] + && viewfov[i] != fov) + { + viewfov[i] = fov; + R_SetFov(fov); + } + } + Portal_InitList(); PS_START_TIMING(ps_skyboxtime); @@ -1521,6 +1551,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_drawdist_precip); CV_RegisterVar(&cv_lessprecip); CV_RegisterVar(&cv_mobjscaleprecip); + + CV_RegisterVar(&cv_fovchange); CV_RegisterVar(&cv_fov); for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) @@ -1540,7 +1572,8 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam_height[i]); CV_RegisterVar(&cv_cam_speed[i]); CV_RegisterVar(&cv_cam_rotate[i]); - CV_RegisterVar(&cv_cam_rotspeed[i]); + CV_RegisterVar(&cv_cam_timeover[i]); + CV_RegisterVar(&cv_freecam_speed[i]); } CV_RegisterVar(&cv_tilting); @@ -1556,6 +1589,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_sliptideroll); CV_RegisterVar(&cv_sloperolldist); CV_RegisterVar(&cv_sparkroll); + CV_RegisterVar(&cv_spinoutroll); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); diff --git a/src/r_main.h b/src/r_main.h index 756fe3783..5cbcd7740 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -29,6 +29,9 @@ extern fixed_t centerxfrac, centeryfrac; extern fixed_t projection, projectiony; extern fixed_t fovtan; // field of view +#define MINFOV 5 +#define MAXFOV 179 + extern size_t validcount, linecount, loopcount, framecount; // The fraction of a tic being drawn (for interpolation between two tics) @@ -179,7 +182,7 @@ extern consvar_t cv_shadow, cv_shadowoffs; extern consvar_t cv_ffloorclip, cv_spriteclip; extern consvar_t cv_translucency; extern consvar_t cv_drawdist, cv_drawdist_precip, cv_lessprecip, cv_mobjscaleprecip; -extern consvar_t cv_fov; +extern consvar_t cv_fov, cv_fovchange; extern consvar_t cv_skybox; extern consvar_t cv_tailspickup; extern consvar_t cv_maxinterpdist; @@ -201,6 +204,7 @@ void R_SetViewSize(void); // do it (sometimes explicitly called) void R_ExecuteSetViewSize(void); +fixed_t R_GetPlayerFov(player_t *player); void R_SkyboxFrame(int s); void R_SetupFrame(int s, boolean skybox); diff --git a/src/r_plane.c b/src/r_plane.c index 078ab0bb3..807baca5c 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -662,6 +662,7 @@ static void R_DrawSkyPlane(visplane_t *pl) dc_texturemid = skytexturemid; dc_texheight = textureheight[skytexture] >>FRACBITS; + dc_sourcelength = dc_texheight; for (x = pl->minx; x <= pl->maxx; x++) { @@ -804,7 +805,7 @@ void R_DrawSinglePlane(visplane_t *pl) if (pl->polyobj->translucency >= 10) return; // Don't even draw it else if (pl->polyobj->translucency > 0) - ds_transmap = transtables + ((pl->polyobj->translucency-1)<polyobj->translucency); else // Opaque, but allow transparent flat pixels spanfunc = splatfunc; @@ -841,28 +842,17 @@ void R_DrawSinglePlane(visplane_t *pl) spanfunc = R_DrawTranslucentSpan_8; // Hacked up support for alpha value in software mode Tails 09-24-2002 - if (pl->ffloor->alpha < 12) - return; // Don't even draw it - else if (pl->ffloor->alpha < 38) - ds_transmap = transtables + ((tr_trans90-1)<ffloor->alpha < 64) - ds_transmap = transtables + ((tr_trans80-1)<ffloor->alpha < 89) - ds_transmap = transtables + ((tr_trans70-1)<ffloor->alpha < 115) - ds_transmap = transtables + ((tr_trans60-1)<ffloor->alpha < 140) - ds_transmap = transtables + ((tr_trans50-1)<ffloor->alpha < 166) - ds_transmap = transtables + ((tr_trans40-1)<ffloor->alpha < 192) - ds_transmap = transtables + ((tr_trans30-1)<ffloor->alpha < 217) - ds_transmap = transtables + ((tr_trans20-1)<ffloor->alpha < 243) - ds_transmap = transtables + ((tr_trans10-1)<ffloor->alpha))/255; + if (trans >= 10) + return; // Don't even draw it + if (pl->ffloor->blend) // additive, (reverse) subtractive, modulative + ds_transmap = R_GetBlendTable(pl->ffloor->blend, trans); + else if (!(ds_transmap = R_GetTranslucencyTable(trans)) || trans == 0) + spanfunc = splatfunc; // Opaque, but allow transparent flat pixels + } #ifdef SHITPLANESPARENCY if (spanfunc == splatfunc || (pl->extra_colormap && pl->extra_colormap->fog)) @@ -1137,7 +1127,7 @@ using the palette colors. if (spanfunc == R_DrawSpan_8) { INT32 i; - ds_transmap = transtables + ((tr_trans50-1)< 0) { dc_source = (UINT8 *)column + 3; - dc_sourcelength = 0; + dc_sourcelength = column2s_length; if (colfunc == wallcolfunc) twosmultipatchfunc(); @@ -288,6 +288,28 @@ 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; +} + void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) { size_t pindex; @@ -315,28 +337,32 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) // hack translucent linedef types (900-909 for transtables 1-9) ldef = curline->linedef; - switch (ldef->special) + + if (!ldef->alpha) + return; + + if (ldef->blendmode) { - case 900: - case 901: - case 902: - case 903: - case 904: - case 905: - case 906: - case 907: - case 908: - dc_transmap = transtables + ((ldef->special-900)<ceilingheight; - windowbottom = frontsector->floorheight; - break; - default: - colfunc = wallcolfunc; - break; + if (ldef->alpha == NUMTRANSMAPS || ldef->blendmode == AST_MODULATE) + dc_transmap = R_GetBlendTable(ldef->blendmode, 0); + else + dc_transmap = R_GetBlendTable(ldef->blendmode, R_GetLinedefTransTable(ldef->alpha)); + colfunc = fuzzcolfunc; + } + else if (ldef->alpha > 0 && ldef->alpha < FRACUNIT) + { + dc_transmap = transtables + ((R_GetLinedefTransTable(ldef->alpha) - 1) << FF_TRANSSHIFT); + colfunc = fuzzcolfunc; + } + else if (ldef->special == 909) + { + colfunc = R_DrawFogColumn_8; + windowtop = frontsector->ceilingheight; + windowbottom = frontsector->floorheight; + } + else + { + colfunc = wallcolfunc; } if (curline->polyseg && curline->polyseg->translucency > 0) @@ -344,7 +370,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (curline->polyseg->translucency >= NUMTRANSMAPS) return; - dc_transmap = transtables + ((curline->polyseg->translucency-1)<polyseg->translucency); colfunc = fuzzcolfunc; } @@ -712,28 +738,17 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) boolean fuzzy = true; // Hacked up support for alpha value in software mode Tails 09-24-2002 - if (pfloor->alpha < 12) - return; // Don't even draw it - else if (pfloor->alpha < 38) - dc_transmap = transtables + ((tr_trans90-1)<alpha < 64) - dc_transmap = transtables + ((tr_trans80-1)<alpha < 89) - dc_transmap = transtables + ((tr_trans70-1)<alpha < 115) - dc_transmap = transtables + ((tr_trans60-1)<alpha < 140) - dc_transmap = transtables + ((tr_trans50-1)<alpha < 166) - dc_transmap = transtables + ((tr_trans40-1)<alpha < 192) - dc_transmap = transtables + ((tr_trans30-1)<alpha < 217) - dc_transmap = transtables + ((tr_trans20-1)<alpha < 243) - dc_transmap = transtables + ((tr_trans10-1)<alpha))/255; + if (trans >= 10) + return; // Don't even draw it + if (pfloor->blend) // additive, (reverse) subtractive, modulative + dc_transmap = R_GetBlendTable(pfloor->blend, trans); + else if (!(dc_transmap = R_GetTranslucencyTable(trans)) || trans == 0) + fuzzy = false; // Opaque + } if (fuzzy) colfunc = fuzzcolfunc; @@ -1450,7 +1465,7 @@ static void R_RenderSegLoop (void) dc_texturemid = rw_midtexturemid; dc_source = R_GetColumn(midtexture,texturecolumn); dc_texheight = textureheight[midtexture]>>FRACBITS; - dc_sourcelength = 0; + dc_sourcelength = dc_texheight; colfunc(); // dont draw anything more for this column, since @@ -1498,7 +1513,7 @@ static void R_RenderSegLoop (void) dc_texturemid = rw_toptexturemid; dc_source = R_GetColumn(toptexture,texturecolumn); dc_texheight = textureheight[toptexture]>>FRACBITS; - dc_sourcelength = 0; + dc_sourcelength = dc_texheight; colfunc(); ceilingclip[rw_x] = (INT16)mid; } @@ -1536,7 +1551,7 @@ static void R_RenderSegLoop (void) dc_source = R_GetColumn(bottomtexture, texturecolumn); dc_texheight = textureheight[bottomtexture]>>FRACBITS; - dc_sourcelength = 0; + dc_sourcelength = dc_texheight; colfunc(); floorclip[rw_x] = (INT16)mid; } @@ -1614,12 +1629,6 @@ static INT64 R_CalcSegDist(seg_t* seg, INT64 x2, INT64 y2) } } -static inline INT32 get_flat_tex (INT32 texnum) -{ - texnum = R_GetTextureNum(texnum); - return textures[texnum]->holes ? 0 : texnum; // R_DrawWallColumn cannot render holey textures -} - // // R_StoreWallRange // A wall segment will be drawn @@ -1875,7 +1884,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) { fixed_t texheight; // single sided line - midtexture = get_flat_tex(sidedef->midtexture); + midtexture = R_GetTextureNum(sidedef->midtexture); texheight = textureheight[midtexture]; // a single sided line is terminal, so it must mark ends markfloor = markceiling = true; @@ -2052,15 +2061,15 @@ void R_StoreWallRange(INT32 start, INT32 stop) { // Special case... use offsets from 2nd side but only if it has a texture. side_t *def = &sides[linedef->sidenum[1]]; - toptexture = get_flat_tex(def->toptexture); + toptexture = R_GetTextureNum(def->toptexture); if (!toptexture) //Second side has no texture, use the first side's instead. - toptexture = get_flat_tex(sidedef->toptexture); + toptexture = R_GetTextureNum(sidedef->toptexture); texheight = textureheight[toptexture]; } else { - toptexture = get_flat_tex(sidedef->toptexture); + toptexture = R_GetTextureNum(sidedef->toptexture); texheight = textureheight[toptexture]; } if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked @@ -2085,7 +2094,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (worldlow > worldbottom || worldlowslope > worldbottomslope) // Only if VISIBLE!!! { // bottom texture - bottomtexture = get_flat_tex(sidedef->bottomtexture); + bottomtexture = R_GetTextureNum(sidedef->bottomtexture); if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked if (linedef->flags & ML_DONTPEGBOTTOM) diff --git a/src/r_segs.h b/src/r_segs.h index 92d0100e2..006e81279 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -18,6 +18,7 @@ #pragma interface #endif +transnum_t R_GetLinedefTransTable(fixed_t alpha); void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2); void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pffloor); void R_StoreWallRange(INT32 start, INT32 stop); diff --git a/src/r_sky.c b/src/r_sky.c index f42907a54..cb21092bb 100644 --- a/src/r_sky.c +++ b/src/r_sky.c @@ -79,6 +79,5 @@ void R_SetupSkyDraw(void) */ void R_SetSkyScale(void) { - fixed_t difference = vid.fdupx-(vid.dupx<topdelta != 0xff ;) @@ -976,7 +976,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) // R_SplitSprite // runs through a sector's lightlist and splits the sprite according to the heights // -static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) +static void R_SplitSprite(vissprite_t *sprite) { INT32 i, lightnum, lindex; INT16 cutfrac; @@ -1042,7 +1042,7 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) newsprite->extra_colormap = sector->lightlist[i].extra_colormap; - if (!((thing->frame & (FF_FULLBRIGHT|FF_TRANSMASK) || thing->flags2 & MF2_SHADOW) + if (!((newsprite->cut & SC_FULLBRIGHT) && (!newsprite->extra_colormap || !(newsprite->extra_colormap->fog & 1)))) { lindex = FixedMul(sprite->xscale, LIGHTRESOLUTIONFIX)>>(LIGHTSCALESHIFT); @@ -1050,6 +1050,9 @@ static void R_SplitSprite(vissprite_t *sprite, mobj_t *thing) // Mitigate against negative xscale and arithmetic overflow lindex = CLAMP(lindex, 0, MAXLIGHTSCALE - 1); + if (newsprite->cut & SC_SEMIBRIGHT) + lindex = (MAXLIGHTSCALE/2) + (lindex >>1); + newsprite->colormap = spritelights[lindex]; } } @@ -1163,6 +1166,7 @@ static void R_ProjectSprite(mobj_t *thing) UINT8 flip; INT32 lindex; + INT32 trans; vissprite_t *vis; @@ -1260,8 +1264,8 @@ static void R_ProjectSprite(mobj_t *thing) #ifdef ROTSPRITE // determine here if sprite should rotate for optimization - const boolean sliprollrotate = (cv_sloperoll.value && cv_sliptideroll.value && (thing->player && thing->player->sliproll)); - const boolean shouldrotate = (cv_sloperoll.value && (interp.roll || interp.pitch || interp.sloperoll || interp.slopepitch || thing->rollangle || sliprollrotate)); + 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); #endif //Fab : 02-08-98: 'skin' override spritedef currently used for skin @@ -1308,9 +1312,9 @@ static void R_ProjectSprite(mobj_t *thing) I_Error("R_ProjectSprite: sprframes NULL for sprite %d\n", thing->sprite); #endif - if (sprframe->rotate != SRF_SINGLE || papersprite || + if (sprframe->rotate != SRF_SINGLE || papersprite #ifdef ROTSPRITE - (shouldrotate) + || (shouldrotate) #endif ) { @@ -1575,6 +1579,24 @@ static void R_ProjectSprite(mobj_t *thing) return; } + INT32 blendmode; + if (oldthing->frame & FF_BLENDMASK) + blendmode = ((oldthing->frame & FF_BLENDMASK) >> FF_BLENDSHIFT) + 1; + else + blendmode = oldthing->blendmode; + + // Determine the translucency value. + if (oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility) + trans = tr_trans80; // because now the translucency is set through FF_TRANSMASK + else if (oldthing->frame & FF_TRANSMASK) + { + trans = (oldthing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT; + if (!R_BlendLevelVisible(blendmode, trans)) + return; + } + else + trans = 0; + //SoM: 3/17/2000: Disregard sprites that are out of view.. if (vflip) { @@ -1752,6 +1774,18 @@ static void R_ProjectSprite(mobj_t *thing) vis->scale += FixedMul(scalestep, spriteyscale) * (vis->x1 - x1); } + if ((blendmode != AST_COPY) && cv_translucency.value) + vis->transmap = R_GetBlendTable(blendmode, trans); + else + vis->transmap = NULL; + + if (R_ThingIsFullBright(oldthing) || oldthing->flags2 & MF2_SHADOW || thing->flags2 & MF2_SHADOW) + vis->cut |= SC_FULLBRIGHT; + else if (R_ThingIsSemiBright(oldthing)) + vis->cut |= SC_SEMIBRIGHT; + 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 @@ -1761,25 +1795,18 @@ static void R_ProjectSprite(mobj_t *thing) #endif vis->patch = W_CachePatchNum(sprframe->lumppat[rot], PU_CACHE); -// -// determine the colormap (lightlevel & special effects) -// - vis->transmap = NULL; + // + // determine the colormap (lightlevel & special effects) + // - // specific translucency - if (!cv_translucency.value) - ; // no translucency - else if (thing->flags2 & MF2_SHADOW) // actually only the player should use this (temporary invisibility) - vis->transmap = transtables + ((tr_trans80-1)<frame & FF_TRANSMASK) - vis->transmap = transtables + (thing->frame & FF_TRANSMASK) - 0x10000; - - if (((thing->frame & FF_FULLBRIGHT) || (thing->flags2 & MF2_SHADOW)) + if ((vis->cut & SC_FULLBRIGHT) && (!vis->extra_colormap || !(vis->extra_colormap->fog & 1))) { // full bright: goggles vis->colormap = colormaps; } + else if (vis->cut & SC_FULLDARK) + vis->colormap = scalelight[0][0]; else { // diminished light @@ -1788,7 +1815,10 @@ static void R_ProjectSprite(mobj_t *thing) // Mitigate against negative xscale and arithmetic overflow lindex = CLAMP(lindex, 0, MAXLIGHTSCALE - 1); - vis->colormap = lights_array[lindex]; + if (vis->cut & SC_SEMIBRIGHT) + lindex = (MAXLIGHTSCALE/2) + (lindex >> 1); + + vis->colormap = spritelights[lindex]; } vis->precip = false; @@ -1798,7 +1828,7 @@ static void R_ProjectSprite(mobj_t *thing) vis->isScaled = false; if (thing->subsector->sector->numlights) - R_SplitSprite(vis, thing); + R_SplitSprite(vis); // Debug ++objectsdrawn; @@ -1977,8 +2007,8 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis->patch = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); // specific translucency - if (thing->frame & FF_TRANSMASK) - vis->transmap = (thing->frame & FF_TRANSMASK) - 0x10000 + transtables; + if ((thing->blendmode != AST_COPY) && cv_translucency.value) + vis->transmap = R_GetTranslucencyTable((thing->frame & FF_TRANSMASK) >> FF_TRANSSHIFT); else vis->transmap = NULL; @@ -2858,9 +2888,6 @@ boolean R_ThingVisible (mobj_t *thing) if (thing->sprite == SPR_NULL || thing->flags2 & MF2_DONTDRAW) return false; - if (!P_MobjWasRemoved(viewmobj) && (thing == viewmobj)) - return false; - if (splitscreen) { if ((viewssnum == 0 && (thing->eflags & MFE_DRAWONLYFORP1)) @@ -2873,12 +2900,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, fixed_t limit_dist) { if (limit_dist) { - const fixed_t dist = P_AproxDistance(viewx-thing->x, viewy-thing->y); - if (dist > limit_dist) + if (P_AproxDistance(viewx-thing->x, viewy-thing->y) > limit_dist) { return false; } @@ -2887,6 +2913,21 @@ boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist) return true; } +boolean R_ThingIsFullBright(mobj_t *thing) +{ + return ((thing->frame & FF_BRIGHTMASK) == FF_FULLBRIGHT); +} + +boolean R_ThingIsSemiBright(mobj_t *thing) +{ + return ((thing->frame & FF_BRIGHTMASK) == FF_SEMIBRIGHT); +} + +boolean R_ThingIsFullDark(mobj_t *thing) +{ + return ((thing->frame & FF_BRIGHTMASK) == FF_FULLDARK); +} + // // R_DrawMasked // @@ -2979,7 +3020,7 @@ static void Sk_SetDefaultValue(skin_t *skin, boolean local) // memset(skin, 0, sizeof (skin_t)); snprintf(skin->name, - sizeof skin->name, "skin %u", (UINT32)(skin-( (local) ? localskins : skins ))); + sizeof skin->name, "skin %u", (UINT32)(skin-(local ? localskins : skins))); skin->name[sizeof skin->name - 1] = '\0'; skin->wadnum = INT16_MAX; strcpy(skin->sprite, ""); @@ -3149,8 +3190,8 @@ boolean SetPlayerSkin(INT32 playernum, const char *skinname) void SetLocalPlayerSkin(INT32 playernum, const char *skinname, consvar_t *cvar) { - player_t *player = &players[playernum]; INT32 i; + player_t *player = &players[playernum]; if (strcasecmp(skinname, "none")) { @@ -3200,8 +3241,8 @@ 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, (player->skinlocal ? localskins : skins)[player->localskin-1].name); + CV_StealthSet(cvar, (player->skinlocal ? localskins : skins)[player->localskin-1].name); } else { @@ -3390,6 +3431,9 @@ void R_AddSkins(UINT16 wadnum, boolean local) skin_t *skin; boolean hudname, realname; +#define lskin (local ? localskins : skins) +#define lnumskins (local ? numlocalskins : numskins) + // // search for all skin markers in pwad // @@ -3421,7 +3465,7 @@ void R_AddSkins(UINT16 wadnum, boolean local) buf2[size] = '\0'; // set defaults - skin = &( (local) ? localskins : skins )[( (local) ? numlocalskins : numskins )]; + skin = &lskin[lnumskins]; Sk_SetDefaultValue(skin, local); skin->wadnum = wadnum; hudname = realname = false; @@ -3647,34 +3691,29 @@ next_token: CONS_Printf(M_GetText("Added skin '%s'\n"), skin->name); #ifdef SKINVALUES - (local ? localskin_cons_t : skin_cons_t)[(local ? numlocalskins : numskins)].value = (local ? numlocalskins : numskins); - (local ? localskin_cons_t : skin_cons_t)[(local ? numlocalskins : numskins)].strvalue = skin->name; + (local ? localskin_cons_t : skin_cons_t)[lnumskins].value = lnumskins; + (local ? localskin_cons_t : skin_cons_t)[lnumskins].strvalue = skin->name; #endif - // Update the forceskin possiblevalues if (!local) { + // Update the forceskin possiblevalues Forceskin_cons_t[numskins+1].value = numskins; Forceskin_cons_t[numskins+1].strvalue = skins[numskins].name; - } - - skin->localskin = local; - - // so we dont have to guess - if (local) - skin->localnum = numlocalskins; - else + skin->localskin = false; skin->localnum = numskins; - - // add face graphics - if (local) - ST_LoadLocalFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numlocalskins); - else ST_LoadFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numskins); + } + else + { + skin->localskin = true; + skin->localnum = numlocalskins; + ST_LoadLocalFaceGraphics(skin->facerank, skin->facewant, skin->facemmap, numlocalskins); + } #ifdef HWRENDER if (rendermode == render_opengl) - HWR_AddPlayerMD2(((local) ? numlocalskins : numskins), local); + HWR_AddPlayerMD2(lnumskins, local); #endif if (!local) { @@ -3685,12 +3724,14 @@ next_token: skinsorted[numskins] = numskins; } - allskins[numallskins] = ( (local) ? localskins : skins )[( (local) ? numlocalskins : numskins )]; + allskins[numallskins] = lskin[lnumskins]; local ? numlocalskins++ : numskins++; numallskins++; } +#undef lskin +#undef lnumskins //sortSkinGrid(); return; diff --git a/src/r_things.h b/src/r_things.h index 1af5d99bd..c594c26cb 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -79,6 +79,10 @@ void R_DrawMasked(void); boolean R_ThingVisible (mobj_t *thing); boolean R_ThingWithinDist (mobj_t *thing, fixed_t limit_dist); +boolean R_ThingIsFullBright (mobj_t *thing); +boolean R_ThingIsSemiBright (mobj_t *thing); +boolean R_ThingIsFullDark (mobj_t *thing); + // ----------- // SKINS STUFF // ----------- @@ -131,6 +135,9 @@ typedef enum SC_BOTTOM = 2, SC_VFLIP = 3, SC_NOTVISIBLE = 4, + SC_FULLBRIGHT = 8, + SC_SEMIBRIGHT = 16, + SC_FULLDARK = 32, SC_CUTMASK = SC_TOP|SC_BOTTOM|SC_NOTVISIBLE, SC_FLAGMASK = ~SC_CUTMASK } spritecut_e; diff --git a/src/s_sound.c b/src/s_sound.c index 4181d57d4..abd5afbd9 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -113,13 +113,15 @@ consvar_t cv_resume = {"resume", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0 consvar_t cv_fading = {"fading", "Off", CV_SAVE|CV_CALL, CV_OnOff, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_birdmusic = {"birdmusicstuff", "No", CV_SAVE|CV_CALL, CV_YesNo, Bird_menu_Onchange, 0, NULL, NULL, 0, 0, NULL}; - consvar_t cv_keepmusic = {"keepmusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_skipintromusic = {"skipintromusic", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; //consvar_t cv_ignoremusicchanges = {"ignoremusicchanges", "No", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; -boolean keepmusic = false; -static void S_CheckEventMus(const char *newmus); +boolean keepmapmusic = false; // keep the current music on map restart +boolean skipintromus = false; // skip the intro fanfare +static boolean resumekeepmusic = false; +static music_t keepmusic; +static void S_SetKeepMusResume(void); #ifdef HAVE_OPENMPT openmpt_module *openmpt_mhandle = NULL; @@ -342,7 +344,7 @@ lumpnum_t S_GetSfxLumpNum(sfxinfo_t *sfx) if (sfxlump != LUMPERROR) return sfxlump; - strlcpy(namebuf, sfx->name, sizeof namebuf); + strlcpy(namebuf, sfx->name, sizeof(namebuf)); sfxlump = W_CheckNumForName(namebuf); if (sfxlump != LUMPERROR) @@ -456,11 +458,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) memset(&listener[i], 0, sizeof (listener[i])); listenmobj[i] = NULL; - if (i == 0 && democam.soundmobj) - { - listenmobj[i] = democam.soundmobj; - } - else if (player->awayviewtics) + if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; } @@ -469,7 +467,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) listenmobj[i] = player->mo; } - if (origin && origin == listenmobj[i]) + if (origin && origin == listenmobj[i] && !camera[i].freecam) { itsUs = true; } @@ -719,12 +717,6 @@ void S_UpdateSounds(void) memset(&listener[i], 0, sizeof (listener[i])); listenmobj[i] = NULL; - if (i == 0 && democam.soundmobj) - { - listenmobj[i] = democam.soundmobj; - continue; - } - if (player->awayviewtics) { listenmobj[i] = player->awayviewmobj; @@ -780,6 +772,9 @@ void S_UpdateSounds(void) for (i = splitscreen; i >= 0; i--) { + if (camera[i].freecam) + continue; + if (c->origin != listenmobj[i]) continue; @@ -1199,17 +1194,10 @@ const char *compat_special_music_slots[16] = }; #endif -static char music_name[7]; // up to 6-character name -static void *music_data; -static UINT16 music_flags; -static boolean music_looping; -static consvar_t *music_refade_cv; +static music_t music; +static music_t queue; -static char queue_name[7]; -static UINT16 queue_flags; -static boolean queue_looping; -static UINT32 queue_position; -static UINT32 queue_fadeinms; +static consvar_t *music_refade_cv; /// ------------------------ /// Music Definitions @@ -1481,7 +1469,7 @@ void S_ShowSpecifiedMusicCredit(const char *musname) // void S_ShowMusicCredit(void) { - S_ShowSpecifiedMusicCredit(music_name); + S_ShowSpecifiedMusicCredit(music.name); } musicdef_t **soundtestdefs = NULL; @@ -1560,7 +1548,7 @@ musictype_t S_MusicType(void) const char *S_MusicName(void) { - return music_name; + return music.name; } boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) @@ -1568,10 +1556,10 @@ boolean S_MusicInfo(char *mname, UINT16 *mflags, boolean *looping) if (!I_SongPlaying()) return false; - strncpy(mname, music_name, 7); + strncpy(mname, music.name, 7); mname[6] = 0; - *mflags = music_flags; - *looping = music_looping; + *mflags = music.flags; + *looping = music.looping; return (boolean)mname[0]; } @@ -1661,9 +1649,9 @@ static boolean S_LoadMusic(const char *mname) if (I_LoadSong(mdata, W_LumpLength(mlumpnum))) { - strncpy(music_name, mname, 7); - music_name[6] = 0; - music_data = mdata; + strncpy(music.name, mname, 7); + music.name[6] = 0; + music.data = mdata; return true; } else @@ -1675,13 +1663,13 @@ static void S_UnloadMusic(void) I_UnloadSong(); #ifndef HAVE_SDL //SDL uses RWOPS - Z_ChangeTag(music_data, PU_CACHE); + Z_ChangeTag(music.data, PU_CACHE); #endif - music_data = NULL; + music.data = NULL; - music_name[0] = 0; - music_flags = 0; - music_looping = false; + music.name[0] = 0; + music.flags = 0; + music.looping = false; music_refade_cv = 0; } @@ -1710,24 +1698,28 @@ static boolean S_PlayMusic(boolean looping, UINT32 fadeinms) static void S_QueueMusic(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 fadeinms) { - strncpy(queue_name, mmusic, 7); - queue_flags = mflags; - queue_looping = looping; - queue_position = position; - queue_fadeinms = fadeinms; + strncpy(queue.name, mmusic, 7); + queue.flags = mflags; + queue.looping = looping; + queue.position = position; + queue.fadeinms = fadeinms; } static void S_ClearQueue(void) { - queue_name[0] = queue_flags = queue_looping = queue_position = queue_fadeinms = 0; + queue.name[0] = queue.flags = queue.looping = queue.position = queue.fadeinms = 0; } static void S_ChangeMusicToQueue(void) { - S_ChangeMusicEx(queue_name, queue_flags, queue_looping, queue_position, 0, queue_fadeinms); + S_ChangeMusicEx(queue.name, queue.flags, queue.looping, queue.position, 0, queue.fadeinms); S_ClearQueue(); } +// keep copy of music name before lua hook change +// for custom vote music etc +static char checkmusic[7] = {0}; + void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 position, UINT32 prefadems, UINT32 fadeinms) { char newmusic[7] = {0}; @@ -1747,10 +1739,9 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; strncpy(newmusic, mmusic, 6); + strncpy(checkmusic, mmusic, 6); - S_CheckEventMus(newmusic); - - if (LUA_HookMusicChange(music_name, &hook_param)) + if (LUA_HookMusicChange(music.name, &hook_param)) return; // No Music (empty string) @@ -1765,12 +1756,12 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 if (prefadems && S_MusicPlaying()) // queue music change for after fade // allow even if the music is the same { - CONS_Debug(DBG_DETAILED, "Now fading out song %s\n", music_name); + CONS_Debug(DBG_DETAILED, "Now fading out song %s\n", music.name); S_QueueMusic(newmusic, mflags, looping, position, fadeinms); I_FadeSong(0, prefadems, S_ChangeMusicToQueue); return; } - else if (strnicmp(music_name, newmusic, 6) || (mflags & MUSIC_FORCERESET)) + else if (strnicmp(music.name, newmusic, 6) || (mflags & MUSIC_FORCERESET)) { CONS_Debug(DBG_DETAILED, "Now playing song %s\n", newmusic); @@ -1782,8 +1773,8 @@ void S_ChangeMusicEx(const char *mmusic, UINT16 mflags, boolean looping, UINT32 return; } - music_flags = mflags; - music_looping = looping; + music.flags = mflags; + music.looping = looping; if (!S_PlayMusic(looping, fadeinms)) { @@ -1823,7 +1814,9 @@ void S_StopMusic(void) || demo.title) // SRB2Kart: Demos don't interrupt title screen music return; - mapmusresume = (cv_birdmusic.value && (strcasecmp(music_name, mapmusname) == 0)) ? I_GetSongPosition() : 0; + mapmusic.resume = (cv_birdmusic.value && (strcasecmp(music.name, mapmusic.name) == 0)) ? I_GetSongPosition() : 0; + + S_SetKeepMusResume(); if (I_SongPaused()) I_ResumeSong(); @@ -1938,83 +1931,123 @@ boolean S_FadeOutStopMusic(UINT32 ms) /// Init & Others /// ------------------------ -/*static boolean S_KeepMusic(void) -{ - //if (!cv_keepmusic.value) - //return false; - - // should i compare songs or maps? - static char oldmusname[7] = ""; - - if (strcmp(music_name, mapmusname) != 0) - return false; - - if (strcmp(oldmusname, mapmusname) == 0) - return true; - - strncpy(oldmusname, mapmusname, 7); - oldmusname[6] = '\0'; - - return false; -}*/ - -static boolean skipmusic = false; -boolean skipintromus = false; - -static const char *musicexception_list[17] = { +static const char *musicexception_list[] = { "vote", "voteea", "voteeb", "racent", "krwin", "krok", "krlose", "krfail", "kbwin", "kbok", "kblose", "kstart", "estart", "wait2j", "titles", - "CHRSHF", "CHRSHP" // no clue what those are tbh + "kinvnc", "kgrow", // grow and invinc + "SPBA_W", "SPBA_L", // SPB Attack music + "CHRSHF", "CHRSHP" // no clue what those are tbh }; +// check if the current music is smth we dont want to keep (vote music, etc) +static boolean S_CheckMusicException(void) +{ + if (stricmp(music.name, mapmusic.name)) + return true; + + // in case somehow the mapmusic was replaced with smth we dont want to keep + for (size_t i = 0; i < sizeof(musicexception_list)/sizeof(musicexception_list[0]); i++) + { + if (!stricmp(music.name, musicexception_list[i]) || !stricmp(checkmusic, musicexception_list[i])) + { + return true; + } + } + + return false; +} + void S_ResetKeepAndSpecialMus(void) { - keepmusic = skipintromus = false; + keepmapmusic = skipintromus = false; } -//checks for any kind of event music like intermission, vote etc. -//always runs when musicchange gets invoked -static void S_CheckEventMus(const char *newmus) +// saves the current song position everytime a song stops +// so we can resume it in some cases +static void S_SetKeepMusResume(void) { - skipmusic = false; + keepmusic.resume = 0; - if (!cv_keepmusic.value) - return; - - for (int i = 0; i < 17; i++) - if (stricmp(music_name, musicexception_list[i]) == 0 || stricmp(newmus, musicexception_list[i]) == 0) // weird? sure! but were lucky enough newmus reflects whats being replaced - { - skipmusic = true; - break; - } - - //CONS_Printf("music_name = %s\n", music_name); - //CONS_Printf("newmus = %s\n", newmus); - //CONS_Printf("skipmusic = %d\n", skipmusic); + if (strcasecmp(music.name, mapmusic.name) == 0) + { + keepmusic.resume = I_GetSongPosition(); + } } -//this one compares map and encoremode instead of the music itself -//makes tunes work and stuff -void S_CheckMap(void) +// determine if we should keep the music on a map restart +// this gets called BEFORE the level gets loaded in G_DoLoadLevel +void S_KeepMusic(void) { - static INT16 oldmap = 0; + static INT16 oldmap = -1; static boolean oldencore = false; + keepmapmusic = resumekeepmusic = false; + if (!cv_keepmusic.value) { - keepmusic = false; return; } - keepmusic = (!skipmusic && gamestate == GS_LEVEL && oldmap == gamemap && oldencore == encoremode); + // copy over mapmusicname stuff into temporary var + memset(keepmusic.name, 0, sizeof(keepmusic.name)); + strlcpy(keepmusic.name, mapmusic.name, sizeof(keepmusic.name)); + keepmusic.name[6] = 0; - //CONS_Printf("keepmusic = %s\n", keepmusic); + if (oldmap == gamemap && oldencore == encoremode) + { + const boolean musicchanged = S_CheckMusicException(); + + resumekeepmusic = (musicchanged && keepmusic.resume); + keepmapmusic = (!musicchanged || resumekeepmusic); + } oldencore = encoremode; oldmap = gamemap; } +// Sets up the map music in case it should be reloaded +// Special case for keep music +void S_HandleReloadResetMusic(void) +{ + if (!(mapmusic.flags & MUSIC_RELOADRESET)) + return; + + // replace mapmusic with our saved keepmusic stuff + if (keepmapmusic) + { + // this is horrible, but oh well + strlcpy(mapmusic.name, keepmusic.name, sizeof(mapmusic.name)); + } + else + { + strlcpy(mapmusic.name, mapheaderinfo[gamemap-1]->musname, sizeof(mapmusic.name)); + } + + mapmusic.name[6] = 0; + mapmusic.flags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); + mapmusic.position = mapheaderinfo[gamemap-1]->muspos; + mapmusic.resume = 0; +} + +static boolean S_SkipIntroMusic(void) +{ + boolean skip = cv_skipintromusic.value; + + if (!skip) + return false; + + char *maptitle = G_BuildMapTitle(gamemap); // Zzz... + + // check if menu music is playing, otherwise it may continue playing + if (!stricmp(music.name, "titles") || (maptitle && (!stricmp(maptitle, "Wandering Falls")))) // wandering balls changes its song when the race starts Zzz... + skip = false; + + Z_Free(maptitle); + + return skip; +} + // // Per level startup code. // Kills playing sounds at start of level, @@ -2022,56 +2055,49 @@ void S_CheckMap(void) // void S_InitMapMusic(void) { - skipintromus = false; + S_HandleReloadResetMusic(); - if (mapmusflags & MUSIC_RELOADRESET) + if (keepmapmusic) { - strncpy(mapmusname, mapheaderinfo[gamemap-1]->musname, 7); - mapmusname[6] = 0; - mapmusflags = (mapheaderinfo[gamemap-1]->mustrack & MUSIC_TRACKMASK); - mapmusposition = mapheaderinfo[gamemap-1]->muspos; - mapmusresume = 0; - } - - if (keepmusic) + // this is kinda silly, but we can use it to fade back into the map song at the saved point, should the current music be different from the map music + if (resumekeepmusic) + { + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, keepmusic.resume, 0, 500); + } return; + } // Starting ambience should always be restarted // lug: but not when we keep the map music lol S_StopMusic(); - if (cv_skipintromusic.value) - { - char *maptitle = G_BuildMapTitle(gamemap); - // for some reason, occasionally the title screen music doesent seem to be reset in time, so skipping the intro may make it just continue playing it instead, weird.. - skipintromus = (stricmp(music_name, "titles") != 0) && (maptitle && (stricmp(maptitle, "Wandering Falls") != 0)); // thanks diggle! - if (maptitle) - Z_Free(maptitle); - } + skipintromus = S_SkipIntroMusic(); if (skipintromus) return; if (leveltime < MUSICSTARTTIME) // SRB2Kart S_ChangeMusicInternal((encoremode ? "estart" : "kstart"), false); //S_StopMusic(); - //S_ChangeMusicEx((encoremode ? "estart" : "kstart"), 0, false, mapmusposition, 0, 0); } void S_StartMapMusic(void) { - //no need to constantly run this after race has started + // no need to constantly run this after race has started if (leveltime > MUSICSTARTTIME) return; - if (keepmusic) + if (keepmapmusic) + { return; + } if (skipintromus) { if (leveltime < starttime) - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); - if (leveltime == MUSICSTARTTIME) + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); + else if (leveltime == MUSICSTARTTIME) S_ShowMusicCredit(); + return; } @@ -2081,7 +2107,7 @@ void S_StartMapMusic(void) S_StopMusic(); else if (leveltime == MUSICSTARTTIME) // Plays the music after the starting countdown. { - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); S_ShowMusicCredit(); } } @@ -2131,7 +2157,7 @@ static void Command_Tunes_f(void) if (!strcasecmp(tunearg, "-show")) { CONS_Printf(M_GetText("The current tune is: %s [track %d]\n"), - mapmusname, (mapmusflags & MUSIC_TRACKMASK)); + mapmusic.name, (mapmusic.flags & MUSIC_TRACKMASK)); return; } if (!strcasecmp(tunearg, "-none")) @@ -2159,19 +2185,19 @@ static void Command_Tunes_f(void) track = (UINT16)atoi(COM_Argv(2))-1; if (tunenum) - snprintf(mapmusname, 7, "%sM", G_BuildMapName(tunenum)); + snprintf(mapmusic.name, 7, "%sM", G_BuildMapName(tunenum)); else - strncpy(mapmusname, tunearg, 7); + strncpy(mapmusic.name, tunearg, 7); if (argc > 4) position = (UINT32)atoi(COM_Argv(4)); - mapmusname[6] = 0; - mapmusflags = (track & MUSIC_TRACKMASK); - mapmusposition = position; - mapmusresume = 0; + mapmusic.name[6] = 0; + mapmusic.flags = (track & MUSIC_TRACKMASK); + mapmusic.position = position; + mapmusic.resume = 0; - S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, 0, 0); + S_ChangeMusicEx(mapmusic.name, mapmusic.flags, true, mapmusic.position, 0, 0); if (argc > 3) { @@ -2219,7 +2245,7 @@ static void Command_RestartMusic_f(void) //same as RestartAudio but only music g static void Command_ShowMusicCredit_f(void) { - const char *musname = music_name; + const char *musname = music.name; if (COM_Argc() > 1) { diff --git a/src/s_sound.h b/src/s_sound.h index 124b74de3..92e206e1b 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -71,7 +71,7 @@ extern consvar_t cv_birdmusic; extern consvar_t cv_keepmusic; extern consvar_t cv_skipintromusic; //extern consvar_t cv_ignoremusicchanges; -extern boolean keepmusic; +extern boolean keepmapmusic; extern boolean skipintromus; #define MUSICSTARTTIME (starttime + (TICRATE/2)) @@ -113,8 +113,9 @@ void S_ResetKeepAndSpecialMus(void); void S_InitMapMusic(void); void S_StartMapMusic(void); +void S_HandleReloadResetMusic(void); -void S_CheckMap(void); +void S_KeepMusic(void); // Stops music and restarts it from same position. Used for instant applying changes to amiga filters. void S_RestartMusic(void); diff --git a/src/screen.c b/src/screen.c index 249c7225c..f6a94c052 100644 --- a/src/screen.c +++ b/src/screen.c @@ -443,22 +443,20 @@ void SCR_CalculateFPS(void) void SCR_DisplayTicRate(void) { - const UINT8 *ticcntcolor = NULL; UINT32 cap = R_GetFramerateCap(); UINT32 benchmark = (cap == 0) ? I_GetRefreshRate() : cap; - INT32 x = 318; double fps = round(averageFPS); INT32 fpsflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; - const char *fps_string; - - INT32 ticcntcolor2 = 0; - + if (gamestate == GS_NULL) return; // new kart counter if (cv_ticrate.value == 1 || cv_ticrate.value == 2) { + const UINT8 *ticcntcolor = NULL; + INT32 x = 318; + // draw "FPS" if (cv_ticrate.value == 1) V_DrawFixedPatch(306< (benchmark - 5)) ticcntcolor2 = V_GREENMAP; else if (fps < 20) @@ -502,7 +503,8 @@ void SCR_DisplayTicRate(void) fps_string = va("%d/%d\x82", (INT32)fps, cap); else fps_string = va("%d\x82", (INT32)fps); - + + // draw "FPS" if (cv_ticrate.value == 3) V_DrawRightAlignedString(319, 181, V_YELLOWMAP|fpsflags, "FPS"); @@ -515,13 +517,13 @@ void SCR_DisplayTicRate(void) void SCR_DisplayLocalPing(void) { - UINT32 ping = playerpingtable[consoleplayer]; // consoleplayer's ping is everyone's ping in a splitnetgame :P + UINT32 ping = playerpingtable[consoleplayer]; INT32 pingflags = V_LocalTransFlag()|V_SNAPTOBOTTOM|V_SNAPTORIGHT; - if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > servermaxping)) // only show 2 (warning) if our ping is at a bad level + if (cv_showping.value == 1 || (cv_showping.value == 2 && ping > 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 - - HU_drawPing(308, dispy, ping, pingflags); + + HU_drawPlayerPing(308, dispy, consoleplayer, pingflags); // consoleplayer's ping is everyone's ping in a splitnetgame :P } } diff --git a/src/screen.h b/src/screen.h index be8cd9614..000957ed9 100644 --- a/src/screen.h +++ b/src/screen.h @@ -44,7 +44,7 @@ #define BASEVIDWIDTH 320 // NEVER CHANGE THIS! This is the original #define BASEVIDHEIGHT 200 // resolution of the graphics. -// max res for png capture; just here to prevent some crashes on very high resoltions; tho you should never go this high cause ogl allocs certain things with MAXVIDWIDTH and MAXVIDHEIGHT too Zzz... +// max res for png capture; just here to prevent some crashes on very high resolutions; tho you should never go this high cause ogl allocs certain things with MAXVIDWIDTH and MAXVIDHEIGHT too Zzz... #define MAXPNGWIDTH 7680 #define MAXPNGHEIGHT 4320 @@ -94,6 +94,7 @@ typedef struct INT32 vesamode; // vesa mode number plus LINEAR_MODE bit void *plinearmem; // linear address of start of frame buffer } vesa_extra_t; + // a video modes from the video modes list, // note: video mode 0 is always standard VGA320x200. typedef struct vmode_s diff --git a/src/sdl/i_main.c b/src/sdl/i_main.c index 1d2e2395f..d6a007919 100644 --- a/src/sdl/i_main.c +++ b/src/sdl/i_main.c @@ -20,12 +20,19 @@ #include "../doomdef.h" #include "../m_argv.h" #include "../d_main.h" +#include "../m_misc.h"/* path shit */ #include "../i_system.h" -#ifdef __GNUC__ +#if defined (__GNUC__) || defined (__unix__) #include #endif +#ifdef __unix__ +#include +#endif + +#include "time.h" // For log timestamps + #ifdef HAVE_SDL #ifdef HAVE_TTF @@ -89,6 +96,93 @@ ChDirToExe (void) } #endif +#ifdef LOGMESSAGES +static void InitLogging(void) +{ + const char *logdir = NULL; + time_t my_time; + struct tm * timeinfo; + const char *format; + const char *reldir; + int left; + boolean fileabs; +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) + const char *link; +#endif + + logdir = D_Home(); + + my_time = time(NULL); + timeinfo = localtime(&my_time); + + if (M_CheckParm("-logfile") && M_IsNextParm()) + { + format = M_GetNextParm(); + fileabs = M_IsPathAbsolute(format); + } + else + { + format = "log-%Y-%m-%d_%H-%M-%S.txt"; + fileabs = false; + } + + if (fileabs) + { + strftime(logfilename, sizeof logfilename, format, timeinfo); + } + else + { + if (M_CheckParm("-logdir") && M_IsNextParm()) + reldir = M_GetNextParm(); + else + reldir = "logs"; + + if (M_IsPathAbsolute(reldir)) + { + left = snprintf(logfilename, sizeof logfilename, + "%s"PATHSEP, reldir); + } + else +#ifdef DEFAULTDIR + if (logdir) + { + left = snprintf(logfilename, sizeof logfilename, + "%s"PATHSEP DEFAULTDIR PATHSEP"%s"PATHSEP, logdir, reldir); + } + else +#endif/*DEFAULTDIR*/ + { + left = snprintf(logfilename, sizeof logfilename, + "."PATHSEP"%s"PATHSEP, reldir); + } + + strftime(&logfilename[left], sizeof logfilename - left, + format, timeinfo); + } + + M_MkdirEachUntil(logfilename, + M_PathParts(logdir) - 1, + M_PathParts(logfilename) - 1, 0755); + +#if defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON) + logstream = fopen(logfilename, "w"); +#ifdef DEFAULTDIR + if (logdir) + link = va("%s/"DEFAULTDIR"/latest-log.txt", logdir); + else +#endif/*DEFAULTDIR*/ + link = "latest-log.txt"; + unlink(link); + if (symlink(logfilename, link) == -1) + { + I_OutputMsg("Error symlinking latest-log.txt: %s\n", strerror(errno)); + } +#else/*defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)*/ + logstream = fopen("latest-log.txt", "wt+"); +#endif/*defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)*/ +} +#endif + /** \brief The main function @@ -107,7 +201,6 @@ int SDL_main(int argc, char **argv) int main(int argc, char **argv) #endif { - const char *logdir = NULL; myargc = argc; myargv = argv; /// \todo pull out path to exe from this string @@ -136,36 +229,18 @@ int main(int argc, char **argv) ChDirToExe(); #endif - logdir = D_Home(); - #ifdef LOGMESSAGES -#ifdef DEFAULTDIR - if (logdir) - strcpy(logfilename, va("%s/"DEFAULTDIR"/log.txt",logdir)); - else -#endif - strcpy(logfilename, "./log.txt"); - - logstream = fopen(logfilename, "wt"); -#endif + if (!M_CheckParm("-nolog")) + InitLogging(); +#endif/*LOGMESSAGES*/ //I_OutputMsg("I_StartupSystem() ...\n"); I_StartupSystem(); #if defined (_WIN32) { -#if 0 // just load the DLL - p_IsDebuggerPresent pfnIsDebuggerPresent = (p_IsDebuggerPresent)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsDebuggerPresent"); - if ((!pfnIsDebuggerPresent || !pfnIsDebuggerPresent()) -#ifdef BUGTRAP - && !InitBugTrap() -#endif - ) -#endif - { #ifdef DRMINGW - ExcHndlInit(); + ExcHndlInit(); #endif - } } #endif diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 7302a12e1..214d4264f 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -201,6 +201,8 @@ static char returnWadPath[256]; #include "../byteptr.h" #endif +INT32 numcontrollers = 0; + #ifdef HAVE_LIBBACKTRACE #include // TODO - move this to some header file instead @@ -420,12 +422,6 @@ static INT32 joystick_started[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; */ SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS]; - -#ifdef HAVE_TERMIOS -static INT32 fdmouse2 = -1; -static INT32 mouse2_started = 0; -#endif - SDL_bool consolevent = SDL_FALSE; SDL_bool framebuffer = SDL_FALSE; @@ -1170,21 +1166,21 @@ void I_ShutdownJoystick(UINT8 index) { INT32 i; event_t event; - event.type=ev_keyup; + event.type = ev_keyup; event.data2 = 0; event.data3 = 0; lastjoybuttons[index] = lastjoyhats[index] = 0; // emulate the up of all joystick buttons - for (i=0;i 0); // Gamepad devices are always ID 1 or higher - - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); + SDL_GameController *controller = JoyInfo[playernum].dev; if (controller == NULL) { return; @@ -1503,17 +1497,15 @@ void I_GamepadRumble(INT32 device_id, UINT16 low_strength, UINT16 high_strength, #endif } -void I_SetGamepadIndicatorColor(INT32 device_id, UINT8 red, UINT8 green, UINT8 blue) +void I_SetGamepadIndicatorColor(INT32 playernum, UINT8 red, UINT8 green, UINT8 blue) { #if !(SDL_VERSION_ATLEAST(2,0,14)) - (void)device_id; + (void)playernum; (void)red; (void)green; (void)blue; #else - I_Assert(device_id > 0); // Gamepad devices are always ID 1 or higher - - SDL_GameController *controller = SDL_GameControllerFromInstanceID(device_id - 1); + SDL_GameController *controller = JoyInfo[playernum].dev; if (controller == NULL) { return; @@ -1651,337 +1643,6 @@ void I_UpdateMumble(const mobj_t *mobj, const listener_t listener) #undef WINMUMBLE #endif // NOMUMBLE -#ifdef HAVE_TERMIOS - -void I_GetMouseEvents(void) -{ - static UINT8 mdata[5]; - static INT32 i = 0,om2b = 0; - INT32 di, j, mlp, button; - event_t event; - const INT32 mswap[8] = {0, 4, 1, 5, 2, 6, 3, 7}; - - if (!mouse2_started) return; - for (mlp = 0; mlp < 20; mlp++) - { - for (; i < 5; i++) - { - di = read(fdmouse2, mdata+i, 1); - if (di == -1) return; - } - if ((mdata[0] & 0xf8) != 0x80) - { - for (j = 1; j < 5; j++) - if ((mdata[j] & 0xf8) == 0x80) - for (i = 0; i < 5-j; i++) // shift - mdata[i] = mdata[i+j]; - if (i < 5) continue; - } - else - { - button = mswap[~mdata[0] & 0x07]; - for (j = 0; j < MOUSEBUTTONS; j++) - { - if (om2b & (1<> 4); - } - else if (bytenum == 3) - { - dx = (char)((combytes[0] & 3) << 6); - dy = (char)((combytes[0] & 12) << 4); - dx = (char)(dx + combytes[1]); - dy = (char)(dy + combytes[2]); - handlermouse2x+= dx; - handlermouse2y+= dy; - } - else if (bytenum == 4) // fourth UINT8 (logitech mouses) - { - if (buffer[i] & 32) - handlermouse2buttons |= 4; - else - handlermouse2buttons &= ~4; - } - } -} - -void I_GetMouseEvents(void) -{ - static UINT8 lastbuttons2 = 0; //mouse movement - event_t event; - - if (mouse2filehandle == INVALID_HANDLE_VALUE) - return; - - I_PoolMouse2(); - // post key event for buttons - if (handlermouse2buttons != lastbuttons2) - { - INT32 i, j = 1, k; - k = (handlermouse2buttons ^ lastbuttons2); // only changed bit to 1 - lastbuttons2 = (UINT8)handlermouse2buttons; - - for (i = 0; i < MOUSEBUTTONS; i++, j <<= 1) - if (k & j) - { - if (handlermouse2buttons & j) - event.type = ev_keydown; - else - event.type = ev_keyup; - event.data1 = KEY_2MOUSE1+i; - D_PostEvent(&event); - } - } - - if (handlermouse2x != 0 || handlermouse2y != 0) - { - event.type = ev_mouse2; - event.data1 = 0; -// event.data1 = buttons; // not needed - event.data2 = handlermouse2x << 1; - event.data3 = -handlermouse2y << 1; - handlermouse2x = 0; - handlermouse2y = 0; - - D_PostEvent(&event); - } -} -#else -void I_GetMouseEvents(void){}; -#endif - -// -// I_StartupMouse2 -// -void I_StartupMouse2(void) -{ -#ifdef HAVE_TERMIOS - struct termios m2tio; - size_t i; - INT32 dtr = -1, rts = -1;; - I_ShutdownMouse2(); - if (cv_usemouse2.value == 0) return; - if ((fdmouse2 = open(cv_mouse2port.string, O_RDONLY|O_NONBLOCK|O_NOCTTY)) == -1) - { - CONS_Printf(M_GetText("Error opening %s!\n"), cv_mouse2port.string); - return; - } - tcflush(fdmouse2, TCIOFLUSH); - m2tio.c_iflag = IGNBRK; - m2tio.c_oflag = 0; - m2tio.c_cflag = CREAD|CLOCAL|HUPCL|CS8|CSTOPB|B1200; - m2tio.c_lflag = 0; - m2tio.c_cc[VTIME] = 0; - m2tio.c_cc[VMIN] = 1; - tcsetattr(fdmouse2, TCSANOW, &m2tio); - for (i = 0; i < strlen(cv_mouse2opt.string); i++) - { - if (toupper(cv_mouse2opt.string[i]) == 'D') - { - if (cv_mouse2opt.string[i+1] == '-') - dtr = 0; - else - dtr = 1; - } - if (toupper(cv_mouse2opt.string[i]) == 'R') - { - if (cv_mouse2opt.string[i+1] == '-') - rts = 0; - else - rts = 1; - } - if (dtr != -1 || rts != -1) - { - INT32 c; - if (!ioctl(fdmouse2, TIOCMGET, &c)) - { - if (!dtr) - c &= ~TIOCM_DTR; - else if (dtr > 0) - c |= TIOCM_DTR; - } - if (!rts) - c &= ~TIOCM_RTS; - else if (rts > 0) - c |= TIOCM_RTS; - ioctl(fdmouse2, TIOCMSET, &c); - } - } - mouse2_started = 1; - I_AddExitFunc(I_ShutdownMouse2); -#elif defined (_WIN32) - DCB dcb; - - if (mouse2filehandle != INVALID_HANDLE_VALUE) - I_ShutdownMouse2(); - - if (cv_usemouse2.value == 0) - return; - - if (mouse2filehandle == INVALID_HANDLE_VALUE) - { - // COM file handle - mouse2filehandle = CreateFileA(cv_mouse2port.string, GENERIC_READ | GENERIC_WRITE, - 0, // exclusive access - NULL, // no security attrs - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, - NULL); - if (mouse2filehandle == INVALID_HANDLE_VALUE) - { - INT32 e = GetLastError(); - if (e == 5) - CONS_Alert(CONS_ERROR, M_GetText("Can't open %s: Access denied\n"), cv_mouse2port.string); - else - CONS_Alert(CONS_ERROR, M_GetText("Can't open %s: error %d\n"), cv_mouse2port.string, e); - return; - } - } - - // getevent when somthing happens - //SetCommMask(mouse2filehandle, EV_RXCHAR); - - // buffers - SetupComm(mouse2filehandle, MOUSECOMBUFFERSIZE, MOUSECOMBUFFERSIZE); - - // purge buffers - PurgeComm(mouse2filehandle, PURGE_TXABORT | PURGE_RXABORT - | PURGE_TXCLEAR | PURGE_RXCLEAR); - - // setup port to 1200 7N1 - dcb.DCBlength = sizeof (DCB); - - GetCommState(mouse2filehandle, &dcb); - - dcb.BaudRate = CBR_1200; - dcb.ByteSize = 7; - dcb.Parity = NOPARITY; - dcb.StopBits = ONESTOPBIT; - - dcb.fDtrControl = DTR_CONTROL_ENABLE; - dcb.fRtsControl = RTS_CONTROL_ENABLE; - - dcb.fBinary = TRUE; - dcb.fParity = TRUE; - - SetCommState(mouse2filehandle, &dcb); - I_AddExitFunc(I_ShutdownMouse2); -#endif -} - // // I_Tactile // @@ -2502,6 +2163,48 @@ void I_RemoveExitFunc(void (*func)()) } } +#if !(defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)) +static void Shittycopyerror(const char *name) +{ + I_OutputMsg( + "Error copying log file: %s: %s\n", + name, + strerror(errno) + ); +} + +static void Shittylogcopy(void) +{ + char buf[8192]; + FILE *fp; + size_t r; + if (fseek(logstream, 0, SEEK_SET) == -1) + { + Shittycopyerror("fseek"); + } + else if (( fp = fopen(logfilename, "wt") )) + { + while (( r = fread(buf, 1, sizeof buf, logstream) )) + { + if (fwrite(buf, 1, r, fp) < r) + { + Shittycopyerror("fwrite"); + break; + } + } + if (ferror(logstream)) + { + Shittycopyerror("fread"); + } + fclose(fp); + } + else + { + Shittycopyerror(logfilename); + } +} +#endif/*!(defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON))*/ + // // Closes down everything. This includes restoring the initial // palette and video mode, and removing whatever mouse, keyboard, and @@ -2524,6 +2227,9 @@ void I_ShutdownSystem(void) if (logstream) { I_OutputMsg("I_ShutdownSystem(): end of logstream.\n"); +#if !(defined (__unix__) || defined(__APPLE__) || defined (UNIXCOMMON)) + Shittylogcopy(); +#endif fclose(logstream); logstream = NULL; } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 609afc30a..76d95a897 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -417,13 +417,15 @@ static INT32 Impl_SDL_Scancode_To_Keycode(SDL_Scancode code) } // Get the equivalent ASCII (Unicode?) character for a keypress. -static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) +static INT32 GetTypedChar(SDL_Keysym keysym) { SDL_Event next_event; - boolean Text_Input_Only = (chat_on || CON_Ready() || (menu_text_input && menuactive)); //only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) + SDL_Keycode keycode = keysym.sym; + SDL_Scancode scancode = keysym.scancode; + const boolean Text_Input_Only = (chat_on || CON_Ready() || (menu_text_input && menuactive)); // only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig) // Special cases, where we always return a fixed value. - switch (sym->sym) + switch (keycode) { case SDLK_BACKSPACE: return KEY_BACKSPACE; case SDLK_RETURN: return KEY_ENTER; @@ -440,13 +442,13 @@ static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym) } } - return Impl_SDL_Scancode_To_Keycode(code); //fallback + return Impl_SDL_Scancode_To_Keycode(scancode); // fallback } static INT32 Impl_SDL_Keysym_To_Keycode(SDL_Keysym keysym) { - SDL_Keycode keycode= keysym.sym; - SDL_Scancode scancode= keysym.scancode; + SDL_Keycode keycode = keysym.sym; + SDL_Scancode scancode = keysym.scancode; if (keycode >= SDLK_a && keycode <= SDLK_z) { @@ -457,15 +459,14 @@ static INT32 Impl_SDL_Keysym_To_Keycode(SDL_Keysym keysym) { return KEY_F1 + (keycode - SDLK_F1); } - if(scancode == SDL_SCANCODE_APOSTROPHE) + + switch (scancode) { - return KEY_FR_U_GRAVE; - } - switch(scancode){ case SDL_SCANCODE_APOSTROPHE: return KEY_FR_U_GRAVE; case SDL_SCANCODE_LEFTBRACKET: return '^'; default: break; } + switch (keycode) { // F11 and F12 are separated from the rest of the function keys @@ -658,11 +659,6 @@ static void VID_Command_Mode_f (void) setmodeneeded = modenum+1; // request vid mode change } -static inline void SDLJoyRemap(event_t *event) -{ - (void)event; -} - static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which) { // -32768 to 32767 @@ -858,6 +854,7 @@ static void Impl_HandleWindowEvent(SDL_WindowEvent evt) static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) { event_t event; + if (type == SDL_KEYUP) { event.type = ev_keyup; @@ -871,12 +868,18 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type) return; } - if (cv_keyboardlayout.value == 2) - event.data1 = GetTypedChar(evt.keysym.scancode, &evt.keysym); - else if (cv_keyboardlayout.value == 3) - event.data1 = Impl_SDL_Keysym_To_Keycode(evt.keysym); - else - event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); + switch (cv_keyboardlayout.value) + { + case 2: // "native" + event.data1 = GetTypedChar(evt.keysym); + break; + case 3: // AZERTY + event.data1 = Impl_SDL_Keysym_To_Keycode(evt.keysym); + break; + default: + event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode); + break; + } if (event.data1) D_PostEvent(&event); } @@ -926,8 +929,6 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) { event_t event; - SDL_memset(&event, 0, sizeof(event_t)); - // Ignore the event if the mouse is not actually focused on the window. // This can happen if you used the mouse to restore keyboard focus; // this apparently makes a mouse button down event but not a mouse button up event, @@ -939,6 +940,8 @@ static void Impl_HandleMouseButtonEvent(SDL_MouseButtonEvent evt, Uint32 type) /// \todo inputEvent.button.which if (USE_MOUSEINPUT) { + SDL_memset(&event, 0, sizeof(event_t)); + if (type == SDL_MOUSEBUTTONUP) { event.type = ev_keyup; @@ -969,26 +972,29 @@ static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt) { event_t event; - SDL_memset(&event, 0, sizeof(event_t)); + if (USE_MOUSEINPUT) + { + SDL_memset(&event, 0, sizeof(event_t)); - if (evt.y > 0) - { - event.data1 = KEY_MOUSEWHEELUP; - event.type = ev_keydown; - } - if (evt.y < 0) - { - event.data1 = KEY_MOUSEWHEELDOWN; - event.type = ev_keydown; - } - if (evt.y == 0) - { - event.data1 = 0; - event.type = ev_keyup; - } - if (event.type == ev_keyup || event.type == ev_keydown) - { - D_PostEvent(&event); + if (evt.y > 0) + { + event.data1 = KEY_MOUSEWHEELUP; + event.type = ev_keydown; + } + if (evt.y < 0) + { + event.data1 = KEY_MOUSEWHEELDOWN; + event.type = ev_keydown; + } + if (evt.y == 0) + { + event.data1 = 0; + event.type = ev_keyup; + } + if (event.type == ev_keyup || event.type == ev_keydown) + { + D_PostEvent(&event); + } } } @@ -1101,6 +1107,7 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint event.data1 = KEY_4JOY1; } else return; + if (type == SDL_CONTROLLERBUTTONUP) { event.type = ev_keyup; @@ -1110,13 +1117,13 @@ static void Impl_HandleControllerButtonEvent(SDL_ControllerButtonEvent evt, Uint event.type = ev_keydown; } else return; + if (evt.button < JOYBUTTONS) { event.data1 += evt.button; } else return; - SDLJoyRemap(&event); if (event.type != ev_console) D_PostEvent(&event); } @@ -1238,7 +1245,10 @@ void I_GetEvent(void) //////////////////////////////////////////////////////////// for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { I_InitJoystick(i); + G_SetPlayerGamepadIndicatorColor(i, G_GetSkinColor(i)); // gotta update the controller led again on reconnect + } //////////////////////////////////////////////////////////// @@ -1249,6 +1259,8 @@ void I_GetEvent(void) if (currentMenu == &OP_JoystickSetDef) M_SetupJoystickMenu(0); + numcontrollers = I_NumJoys(); + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { if (JoyInfo[i].dev == newcontroller) @@ -1308,6 +1320,9 @@ void I_GetEvent(void) // update the menu if (currentMenu == &OP_JoystickSetDef) M_SetupJoystickMenu(0); + + numcontrollers = I_NumJoys(); + break; case SDL_DROPFILE: dropped_filedir = evt.drop.file; @@ -1376,8 +1391,6 @@ void I_OsPolling(void) I_GetJoystickEvents(i); } - I_GetMouseEvents(); - I_GetEvent(); mod = SDL_GetModState(); @@ -1418,37 +1431,6 @@ void I_UpdateNoBlit(void) exposevideo = SDL_FALSE; } -// I_SkipFrame -// -// Returns true if it thinks we can afford to skip this frame -// from PrBoom's src/SDL/i_video.c -static inline boolean I_SkipFrame(void) -{ -#if 1 - // While I fixed the FPS counter bugging out with this, - // I actually really like being able to pause and - // use perfstats to measure rendering performance - // without game logic changes. - return false; -#else - static boolean skip = false; - - skip = !skip; - - switch (gamestate) - { - case GS_LEVEL: - if (!paused) - return false; - /* FALLTHRU */ - case GS_WAITINGPLAYERS: - return skip; // Skip odd frames - default: - return false; - } -#endif -} - // // I_FinishUpdate // @@ -1461,14 +1443,14 @@ void I_FinishUpdate(void) SCR_CalculateFPS(); - if (I_SkipFrame()) - return; + if (st_overlay) + { + if (cv_ticrate.value) + SCR_DisplayTicRate(); - if (cv_ticrate.value && st_overlay) - SCR_DisplayTicRate(); - - if (cv_showping.value && netgame && consoleplayer != serverplayer && st_overlay) - SCR_DisplayLocalPing(); + if (cv_showping.value && ((netgame && consoleplayer != serverplayer) || (simulated_lag != 0 && consoleplayer == serverplayer && Playing()))) + SCR_DisplayLocalPing(); + } #ifdef HAVE_DISCORDRPC if (discordRequestList != NULL) diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index ced911eba..647958653 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -282,6 +282,9 @@ static Mix_Chunk *ds2chunk(void *stream) freq = READUINT16(stream); samples = READUINT32(stream); + if (freq == 0) + return NULL; // division by zero + // convert from signed 8bit ???hz to signed 16bit 44100hz. switch(freq) { @@ -616,7 +619,7 @@ Countstutter (int len) else bytes = ( music_bytes - music_stutter_bytes ); - I_SetSongPosition((int)( bytes/4/44100.0*1000 )); + I_SetSongPosition((int)( (float)bytes/4/44100.0*1000 )); } } } diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index 8a3a0eabb..f590d2a0f 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -44,6 +44,7 @@ #include "hwsym_sdl.h" #include "../m_argv.h" #include "../i_video.h" +#include "../f_finale.h" #include "../f_finale.h" @@ -264,7 +265,7 @@ void OglSdlFinishUpdate(boolean waitvbl) } #endif - GL_DrawScreenFinalTexture(HWD_SCREENTEXTURE_GENERIC2, sdlw, sdlh, HWR_ShouldUsePaletteRendering()); + HWR_DrawScreenFinalTexture(sdlw, sdlh, HWR_ShouldUsePaletteRendering()); #ifdef USE_FBO_OGL if (usefbo) @@ -289,8 +290,8 @@ void OglSdlFinishUpdate(boolean waitvbl) #if defined (__unix__) #ifdef USE_FBO_OGL - if (loaded_config == true) - xwaylandcrap = false; + if (loaded_config == true) + xwaylandcrap = false; #endif #endif } diff --git a/src/st_stuff.c b/src/st_stuff.c index 8b431b2f0..6e39661e7 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -53,6 +53,9 @@ UINT16 objectsdrawn = 0; +// dumb fade thing for director toggle +tic_t directortoggletimer = 0; + // // STATUS BAR DATA // @@ -77,73 +80,6 @@ char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap*/ // status bar overlay // ------------------------------------------ -// icons for overlay -patch_t *sboscore; // Score logo -patch_t *sbotime; // Time logo -patch_t *sbocolon; // Colon for time -patch_t *sboperiod; // Period for time centiseconds -patch_t *livesback; // Lives icon background -static patch_t *nrec_timer; // Timer for NiGHTS records -static patch_t *sborings; -static patch_t *sboover; -static patch_t *timeover; -static patch_t *stlivex; -static patch_t *rrings; -static patch_t *getall; // Special Stage HUD -static patch_t *timeup; // Special Stage HUD -static patch_t *hunthoming[6]; -static patch_t *itemhoming[6]; -static patch_t *race1; -static patch_t *race2; -static patch_t *race3; -static patch_t *racego; -//static patch_t *ttlnum; -static patch_t *nightslink; -static patch_t *count5; -static patch_t *count4; -static patch_t *count3; -static patch_t *count2; -static patch_t *count1; -static patch_t *count0; -static patch_t *curweapon; -static patch_t *normring; -static patch_t *bouncering; -static patch_t *infinityring; -static patch_t *autoring; -static patch_t *explosionring; -static patch_t *scatterring; -static patch_t *grenadering; -static patch_t *railring; -static patch_t *jumpshield; -static patch_t *forceshield; -static patch_t *ringshield; -static patch_t *watershield; -static patch_t *bombshield; -static patch_t *pityshield; -static patch_t *invincibility; -static patch_t *sneakers; -static patch_t *gravboots; -static patch_t *nonicon; -static patch_t *bluestat; -static patch_t *byelstat; -static patch_t *orngstat; -static patch_t *redstat; -static patch_t *yelstat; -static patch_t *nbracket; -static patch_t *nhud[12]; -static patch_t *nsshud; -static patch_t *narrow[9]; -static patch_t *nredar[8]; // Red arrow -static patch_t *drillbar; -static patch_t *drillfill[3]; -static patch_t *capsulebar; -static patch_t *capsulefill; -patch_t *ngradeletters[7]; -static patch_t *minus5sec; -static patch_t *minicaps; -static patch_t *gotrflag; -static patch_t *gotbflag; - // Midnight Channel: static patch_t *hud_tv1; static patch_t *hud_tv2; @@ -280,8 +216,6 @@ void ST_UnloadGraphics(void) void ST_LoadGraphics(void) { - int i; - // SRB2 border patch st_borderpatchnum = W_GetNumForName("GFZFLR01"); scr_borderpatch = W_CacheLumpNum(st_borderpatchnum, PU_HUDGFX); @@ -291,95 +225,11 @@ void ST_LoadGraphics(void) // but load them in R_AddSkins, that gets called // first anyway // cache the status bar overlay icons (fullscreen mode) - sborings = W_CachePatchName("SBORINGS", PU_HUDGFX); - sboscore = W_CachePatchName("SBOSCORE", PU_HUDGFX); - sboover = W_CachePatchName("SBOOVER", PU_HUDGFX); - timeover = W_CachePatchName("TIMEOVER", PU_HUDGFX); - stlivex = W_CachePatchName("STLIVEX", PU_HUDGFX); - livesback = W_CachePatchName("STLIVEBK", PU_HUDGFX); - rrings = W_CachePatchName("RRINGS", PU_HUDGFX); - sbotime = W_CachePatchName("SBOTIME", PU_HUDGFX); // Time logo - sbocolon = W_CachePatchName("SBOCOLON", PU_HUDGFX); // Colon for time - sboperiod = W_CachePatchName("SBOPERIO", PU_HUDGFX); // Period for time centiseconds - nrec_timer = W_CachePatchName("NGRTIMER", PU_HUDGFX); // Timer for NiGHTS - getall = W_CachePatchName("GETALL", PU_HUDGFX); // Special Stage HUD - timeup = W_CachePatchName("TIMEUP", PU_HUDGFX); // Special Stage HUD - race1 = W_CachePatchName("RACE1", PU_HUDGFX); - race2 = W_CachePatchName("RACE2", PU_HUDGFX); - race3 = W_CachePatchName("RACE3", PU_HUDGFX); - racego = W_CachePatchName("RACEGO", PU_HUDGFX); - nightslink = W_CachePatchName("NGHTLINK", PU_HUDGFX); - count5 = W_CachePatchName("DRWNF0", PU_HUDGFX); - count4 = W_CachePatchName("DRWNE0", PU_HUDGFX); - count3 = W_CachePatchName("DRWND0", PU_HUDGFX); - count2 = W_CachePatchName("DRWNC0", PU_HUDGFX); - count1 = W_CachePatchName("DRWNB0", PU_HUDGFX); - count0 = W_CachePatchName("DRWNA0", PU_HUDGFX); - for (i = 0; i < 6; ++i) - { - hunthoming[i] = W_CachePatchName(va("HOMING%d", i+1), PU_HUDGFX); - itemhoming[i] = W_CachePatchName(va("HOMITM%d", i+1), PU_HUDGFX); - } - - curweapon = W_CachePatchName("CURWEAP", PU_HUDGFX); - normring = W_CachePatchName("RINGIND", PU_HUDGFX); - bouncering = W_CachePatchName("BNCEIND", PU_HUDGFX); - infinityring = W_CachePatchName("INFNIND", PU_HUDGFX); - autoring = W_CachePatchName("AUTOIND", PU_HUDGFX); - explosionring = W_CachePatchName("BOMBIND", PU_HUDGFX); - scatterring = W_CachePatchName("SCATIND", PU_HUDGFX); - grenadering = W_CachePatchName("GRENIND", PU_HUDGFX); - railring = W_CachePatchName("RAILIND", PU_HUDGFX); - jumpshield = W_CachePatchName("WHTVB0", PU_HUDGFX); - forceshield = W_CachePatchName("BLTVB0", PU_HUDGFX); - ringshield = W_CachePatchName("YLTVB0", PU_HUDGFX); - watershield = W_CachePatchName("ELTVB0", PU_HUDGFX); - bombshield = W_CachePatchName("BKTVB0", PU_HUDGFX); - pityshield = W_CachePatchName("GRTVB0", PU_HUDGFX); - invincibility = W_CachePatchName("PINVB0", PU_HUDGFX); - sneakers = W_CachePatchName("SHTVB0", PU_HUDGFX); - gravboots = W_CachePatchName("GBTVB0", PU_HUDGFX); - - tagico = W_CachePatchName("TAGICO", PU_HUDGFX); rflagico = W_CachePatchName("RFLAGICO", PU_HUDGFX); bflagico = W_CachePatchName("BFLAGICO", PU_HUDGFX); rmatcico = W_CachePatchName("RMATCICO", PU_HUDGFX); bmatcico = W_CachePatchName("BMATCICO", PU_HUDGFX); - gotrflag = W_CachePatchName("GOTRFLAG", PU_HUDGFX); - gotbflag = W_CachePatchName("GOTBFLAG", PU_HUDGFX); - nonicon = W_CachePatchName("NONICON", PU_HUDGFX); - - // NiGHTS HUD things - bluestat = W_CachePatchName("BLUESTAT", PU_HUDGFX); - byelstat = W_CachePatchName("BYELSTAT", PU_HUDGFX); - orngstat = W_CachePatchName("ORNGSTAT", PU_HUDGFX); - redstat = W_CachePatchName("REDSTAT", PU_HUDGFX); - yelstat = W_CachePatchName("YELSTAT", PU_HUDGFX); - nbracket = W_CachePatchName("NBRACKET", PU_HUDGFX); - for (i = 0; i < 12; ++i) - nhud[i] = W_CachePatchName(va("NHUD%d", i+1), PU_HUDGFX); - nsshud = W_CachePatchName("NSSHUD", PU_HUDGFX); - minicaps = W_CachePatchName("MINICAPS", PU_HUDGFX); - - for (i = 0; i < 8; ++i) - { - narrow[i] = W_CachePatchName(va("NARROW%d", i+1), PU_HUDGFX); - nredar[i] = W_CachePatchName(va("NREDAR%d", i+1), PU_HUDGFX); - } - - // non-animated version - narrow[8] = W_CachePatchName("NARROW9", PU_HUDGFX); - - drillbar = W_CachePatchName("DRILLBAR", PU_HUDGFX); - for (i = 0; i < 3; ++i) - drillfill[i] = W_CachePatchName(va("DRILLFI%d", i+1), PU_HUDGFX); - capsulebar = W_CachePatchName("CAPSBAR", PU_HUDGFX); - capsulefill = W_CachePatchName("CAPSFILL", PU_HUDGFX); - minus5sec = W_CachePatchName("MINUS5", PU_HUDGFX); - - for (i = 0; i < 7; ++i) - ngradeletters[i] = W_CachePatchName(va("GRADE%d", i), PU_HUDGFX); K_LoadKartHUDGraphics(); @@ -427,9 +277,8 @@ void ST_ReloadSkinFaceGraphics(void) for (i = 0; i < numskins; i++) ST_LoadFaceGraphics(skins[i].facerank, skins[i].facewant, skins[i].facemmap, i); - for (i = 0; i < numlocalskins; i++) { + for (i = 0; i < numlocalskins; i++) ST_LoadLocalFaceGraphics(localskins[i].facerank, localskins[i].facewant, localskins[i].facemmap, i); - } } static inline void ST_InitData(void) @@ -651,6 +500,25 @@ static void ST_drawLevelTitle(void) V_DrawLevelTitle(ttlnumxpos+12, bary+6, V_SNAPTOBOTTOM, actnum); } +// returns the actual button name for any gamecontrol +// if unbound is set, it returns "Unbound" as a string should there be no button bound to a gamecontrol +// if gamectrl is set, it adds an extra "-" for cases where theres also a hardcoded button like accelerate +static const char *ST_GetButtonName(INT32 control, const char *inputtext, boolean unbound, boolean gamectrl) +{ + static char buttname[32] = ""; + const char *butt1 = (gamecontrol[control][0] != 0 ? G_KeynumToString(gamecontrol[control][0]) : NULL); + const char *butt2 = (gamecontrol[control][1] != 0 ? G_KeynumToString(gamecontrol[control][1]) : NULL); // alternative bind + + if (butt1 == NULL && butt2 == NULL) // not bound to a button + snprintf(buttname, 32, (unbound ? "%s - %s" : (gamectrl ? "-%s - %s" : "%s - %s")), (unbound ? "Unbound" : ""), inputtext); + else if (butt1 != NULL && butt2 != NULL) // bound to two buttons + snprintf(buttname, 32, "%s/%s - %s", butt1, butt2, inputtext); + else // bound to only one + snprintf(buttname, 32, (gamectrl ? "-%s - %s" : "%s - %s"), (butt1 != NULL ? butt1 : butt2 != NULL ? butt2 : ""), inputtext); + + return buttname; +} + // Draw the status bar overlay, customisable: the user chooses which // kind of information to overlay // @@ -702,7 +570,7 @@ static void ST_overlayDrawer(void) V_DrawCenteredString((BASEVIDWIDTH/2), BASEVIDHEIGHT-32, V_SNAPTOBOTTOM|V_HUDTRANS|V_ALLOWLOWERCASE, player_names[stplyr-players]); } } - else if (!demo.title && !demo.freecam) + else if (!demo.title && !camera[stplyrnum].freecam) { if (!splitscreen) { @@ -713,7 +581,7 @@ static void ST_overlayDrawer(void) { char name[MAXPLAYERNAME+12]; - INT32 y = (stplyr == &players[displayplayers[0]]) ? 4 : BASEVIDHEIGHT/2-12; + INT32 y = (stplyrnum == 0) ? 4 : BASEVIDHEIGHT/2-12; sprintf(name, "VIEWPOINT: %s", player_names[stplyr-players]); V_DrawRightAlignedThinString(BASEVIDWIDTH-40, y, V_HUDTRANSHALF|V_ALLOWLOWERCASE|K_calcSplitFlags(V_SNAPTOTOP|V_SNAPTOBOTTOM|V_SNAPTORIGHT), name); } @@ -775,26 +643,16 @@ static void ST_overlayDrawer(void) { V_DrawString(2, BASEVIDHEIGHT-50, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Accelerate - Float")); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Brake - Sink")); - - char directortoggle[32] = {0}; - const char *item1 = gamecontrol[gc_director][0] != 0 ? G_KeynumToString(gamecontrol[gc_director][0]) : NULL; - const char *item2 = gamecontrol[gc_director][1] != 0 ? G_KeynumToString(gamecontrol[gc_director][1]) : NULL; - - if (item1 != NULL && item2 != NULL) - snprintf(directortoggle, 32, "%s/%s - Toggle Director", item1, item2); - else - snprintf(directortoggle, 32, "%s - Toggle Director", item1 != NULL ? item1 : item2 != NULL ? item2 : "Not Bound"); - - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, directortoggle); + V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, ST_GetButtonName(gc_director, "Toggle Director", true, false)); } else { V_DrawString(2, BASEVIDHEIGHT-40, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF|V_YELLOWMAP, M_GetText("- SPECTATING -")); V_DrawString(2, BASEVIDHEIGHT-30, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, itemtxt); - V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Accelerate - Float")); - V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, M_GetText("Brake - Sink")); + V_DrawString(2, BASEVIDHEIGHT-20, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Accelerate %s", ST_GetButtonName(gc_camfloat, "Float", false, true))); + V_DrawString(2, BASEVIDHEIGHT-10, V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_HUDTRANSHALF, va("Brake %s", ST_GetButtonName(gc_camsink, "Sink", false, true))); } } } diff --git a/src/st_stuff.h b/src/st_stuff.h index 250db1e7f..54d2483ee 100644 --- a/src/st_stuff.h +++ b/src/st_stuff.h @@ -23,6 +23,8 @@ // STATUS BAR // +extern tic_t directortoggletimer; + // Called by main loop. void ST_Ticker(void); @@ -71,10 +73,6 @@ extern UINT8 stplyrnum; extern lumpnum_t st_borderpatchnum; // patches, also used in intermission extern patch_t *tallnum[10]; -extern patch_t *sboscore; -extern patch_t *sbotime; -extern patch_t *sbocolon; -extern patch_t *sboperiod; extern patch_t *facerankprefix[MAXSKINS]; // ranking extern patch_t *facewantprefix[MAXSKINS]; // wanted extern patch_t *facemmapprefix[MAXSKINS]; // minimap @@ -87,8 +85,6 @@ extern char *facemmapprefix_name[MAXSKINS]; // minimap extern char *localfacerankprefix_name[MAXLOCALSKINS]; // ranking extern char *localfacewantprefix_name[MAXLOCALSKINS]; // wanted extern char *localfacemmapprefix_name[MAXLOCALSKINS]; // minimap*/ -extern patch_t *livesback; -extern patch_t *ngradeletters[7]; /** HUD location information (don't move this comment) */ diff --git a/src/v_video.c b/src/v_video.c index 987a40a03..fcf10e2f4 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -616,10 +616,11 @@ static inline UINT8 transmappedpdraw(const UINT8 *dest, const UINT8 *source, fix } // Draws a patch scaled to arbitrary size. -void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap) +void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vscale, INT32 scrn, patch_t *patch, const UINT8 *colormap, INT32 bflags) { UINT8 (*patchdrawfunc)(const UINT8*, const UINT8*, fixed_t); - UINT32 alphalevel = 0; + UINT32 alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT); + UINT32 blendmode = ((bflags & V_BLENDMASK) >> V_BLENDSHIFT); fixed_t col, ofs, colfrac, rowfrac, fdup, vdup; INT32 dupx, dupy; @@ -636,7 +637,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca //if (rendermode != render_soft && !con_startup) // Why? if (rendermode == render_opengl) { - HWR_DrawStretchyFixedPatch((GLPatch_t *)patch, x, y, pscale, vscale, scrn, colormap); + HWR_DrawStretchyFixedPatch((GLPatch_t *)patch, x, y, pscale, vscale, scrn, colormap, bflags); return; } #endif @@ -644,7 +645,7 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca patchdrawfunc = standardpdraw; v_translevel = NULL; - if ((alphalevel = ((scrn & V_ALPHAMASK) >> V_ALPHASHIFT))) + if (alphalevel || blendmode) { if (alphalevel == 13) alphalevel = hudminusalpha[hudtrans]; @@ -656,9 +657,9 @@ void V_DrawStretchyFixedPatch(fixed_t x, fixed_t y, fixed_t pscale, fixed_t vsca if (alphalevel >= 10) return; // invis - if (alphalevel) + if (alphalevel || blendmode) { - v_translevel = transtables + ((alphalevel-1)<topoffset)< 3 || view > splitscreen) return; - if (!player->postimgflags) + camera_t *thiscam = &camera[view]; + + if (!thiscam->postimg) return; if ((view == 1 && splitscreen == 1) || view >= 2) @@ -3210,7 +3213,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) UINT8 *tmpscr = screens[4]; UINT8 *srcscr = screens[0]; - if (player->postimgflags & POSTIMG_WATER) + if (thiscam->postimg & POSTIMG_WATER) { INT32 y; // Set disStart to a range from 0 to FINEANGLE, incrementing by 128 per tic @@ -3269,22 +3272,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) tmpscr = srcscr; srcscr = tmp; } - - /*if (player->postimgflags & POSTIMG_MOTION) // Motion Blur! - { - INT32 x, y; - - // TODO: Add a postimg_param so that we can pick the translucency level... - UINT8 *transme = transtables + ((param-1)<postimgflags & POSTIMG_HEAT) // Heat wave + else if (thiscam->postimg & POSTIMG_HEAT) // Heat wave { INT32 y; @@ -3331,7 +3319,21 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) srcscr = tmp; } - if ((player->postimgflags & POSTIMG_FLIP) && !(player->postimgflags & POSTIMG_MIRROR)) // Flip the screen upside-down + /*if (thiscam->postimg & POSTIMG_MOTION) // Motion Blur! + { + INT32 x, y; + + // TODO: Add a postimg_param so that we can pick the translucency level... + UINT8 *transme = transtables + ((param-1)<postimg & POSTIMG_FLIP) && !(thiscam->postimg & POSTIMG_MIRROR)) // Flip the screen upside-down { INT32 y, y2; @@ -3342,7 +3344,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) tmpscr = srcscr; srcscr = tmp; } - else if ((player->postimgflags & POSTIMG_MIRROR) && !(player->postimgflags & POSTIMG_FLIP)) // Flip the screen on the x axis + else if ((thiscam->postimg & POSTIMG_MIRROR) && !(thiscam->postimg & POSTIMG_FLIP)) // Flip the screen on the x axis { INT32 y, x, x2; @@ -3354,7 +3356,7 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) tmpscr = srcscr; srcscr = tmp; } - else if ((player->postimgflags & POSTIMG_MIRROR) && (player->postimgflags & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis + else if ((thiscam->postimg & POSTIMG_MIRROR) && (thiscam->postimg & POSTIMG_FLIP)) // Flip the screen upside-down and on the x axis { INT32 y, x; @@ -3372,30 +3374,51 @@ void V_DoPostProcessor(INT32 view, player_t *player, INT32 param) #endif } - -// Taken from my videos-in-SRB2 project -// Generates a color look-up table -// which has up to 64 colors at each channel -// (see the defines in v_video.h) - -UINT8 colorlookup[CLUTSIZE][CLUTSIZE][CLUTSIZE]; - -void InitColorLUT(void) +// Generates a RGB565 color look-up table +void InitColorLUT(colorlookup_t *lut, RGBA_t *palette, boolean makecolors) { - UINT8 r, g, b; - static boolean clutinit = false; - static RGBA_t *lastpalette = NULL; - if ((!clutinit) || (lastpalette != pLocalPalette)) + size_t palsize = (sizeof(RGBA_t) * 256); + + if (!lut->init || memcmp(lut->palette, palette, palsize)) { - for (r = 0; r < CLUTSIZE; r++) - for (g = 0; g < CLUTSIZE; g++) - for (b = 0; b < CLUTSIZE; b++) - colorlookup[r][g][b] = NearestColor(r << SHIFTCOLORBITS, g << SHIFTCOLORBITS, b << SHIFTCOLORBITS); - clutinit = true; - lastpalette = pLocalPalette; + INT32 i; + + lut->init = true; + memcpy(lut->palette, palette, palsize); + + for (i = 0; i < 0xFFFF; i++) + lut->table[i] = 0xFFFF; + + if (makecolors) + { + UINT8 r, g, b; + + for (r = 0; r < 0xFF; r++) + for (g = 0; g < 0xFF; g++) + for (b = 0; b < 0xFF; b++) + { + i = CLUTINDEX(r, g, b); + if (lut->table[i] == 0xFFFF) + lut->table[i] = NearestPaletteColor(r, g, b, palette); + } + } } } +UINT8 GetColorLUT(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b) +{ + INT32 i = CLUTINDEX(r, g, b); + if (lut->table[i] == 0xFFFF) + lut->table[i] = NearestPaletteColor(r, g, b, lut->palette); + return lut->table[i]; +} + +UINT8 GetColorLUTDirect(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b) +{ + INT32 i = CLUTINDEX(r, g, b); + return lut->table[i]; +} + // V_Init // old software stuff, buffers are allocated at video mode setup // here we set the screens[x] pointers accordingly diff --git a/src/v_video.h b/src/v_video.h index dfab7dfde..1c614e989 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -37,17 +37,19 @@ cv_rsaturation, cv_ysaturation, cv_gsaturation, cv_csaturation, cv_bsaturation, // Allocates buffer screens, call before R_Init. void V_Init(void); -// Taken from my videos-in-SRB2 project -// Generates a color look-up table -// which has up to 64 colors at each channel +// Color look-up table +#define CLUTINDEX(r, g, b) (((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3) -#define COLORBITS 6 -#define SHIFTCOLORBITS (8-COLORBITS) -#define CLUTSIZE (1<hwrcache = M_AATreeAlloc(AATREE_ZUSER); #endif +#ifdef ROTSPRITE + // allocates rotsprite structures and store them in a tree + wadfile->rotcache = M_AATreeAlloc(AATREE_ZUSER); +#endif + // // add the wadfile // @@ -1021,8 +1031,7 @@ UINT16 W_CheckNumForLongNamePwad(const char *name, UINT16 wad, UINT16 startlump) return INT16_MAX; } -UINT16 -W_CheckNumForMarkerStartPwad (const char *name, UINT16 wad, UINT16 startlump) +UINT16 W_CheckNumForMarkerStartPwad (const char *name, UINT16 wad, UINT16 startlump) { UINT16 marker; marker = W_CheckNumForNamePwad(name, wad, startlump); @@ -1117,12 +1126,15 @@ lumpnum_t W_CheckNumForName(const char *name) break; //found it } - if (check == INT16_MAX) return LUMPERROR; + if (check == INT16_MAX) + { + return LUMPERROR; + } else { // Update the cache. lumpnumcacheindex = (lumpnumcacheindex + 1) & (LUMPNUMCACHESIZE - 1); - memset(lumpnumcache[lumpnumcacheindex].lumpname, '\0', 32); + memset(lumpnumcache[lumpnumcacheindex].lumpname, '\0', LUMPNUMCACHENAME); strncpy(lumpnumcache[lumpnumcacheindex].lumpname, name, 8); lumpnumcache[lumpnumcacheindex].lumpnum = (i<<16)+check; @@ -1166,15 +1178,18 @@ lumpnum_t W_CheckNumForLongName(const char *name) } } - if (check == INT16_MAX) return LUMPERROR; + if (check == INT16_MAX) + { + return LUMPERROR; + } else { - if (strlen(name) < 32) + if (strlen(name) < LUMPNUMCACHENAME) { // Update the cache. lumpnumcacheindex = (lumpnumcacheindex + 1) & (LUMPNUMCACHESIZE - 1); - memset(lumpnumcache[lumpnumcacheindex].lumpname, '\0', 32); - strlcpy(lumpnumcache[lumpnumcacheindex].lumpname, name, 32); + memset(lumpnumcache[lumpnumcacheindex].lumpname, '\0', LUMPNUMCACHENAME); + strlcpy(lumpnumcache[lumpnumcacheindex].lumpname, name, LUMPNUMCACHENAME); lumpnumcache[lumpnumcacheindex].lumpnum = (i << 16) + check; } @@ -1739,6 +1754,24 @@ void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag) #endif // HWRENDER +#ifdef ROTSPRITE +// Caches a rotsprite for patch rotation. +void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum) +{ + aatree_t *rotcache = wadfiles[wadnum]->rotcache; + rotsprite_t *rspr; + + if (!(rspr = M_AATreeGet(rotcache, lumpnum))) + { + rspr = RotatedPatch_Create(ROTANGLES); + M_AATreeSet(rotcache, lumpnum, rspr); + } + + return (void *)rspr; +} + +#endif // ROTSPRITE + void W_UnlockCachedPatch(void *patch) { if (!patch) @@ -1767,6 +1800,50 @@ void *W_CachePatchName(const char *name, INT32 tag) return W_CachePatchNum(num, tag); } +#ifdef ROTSPRITE +// Caches a patch, and if needed, rotates said patch. +void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag) +{ + lumpnum_t num; + patch_t *ptr; + rotsprite_t *rspr; + INT32 idx = rotationangle; + + const char *finalname = name; + + num = W_CheckNumForName(finalname); + + if (num == LUMPERROR) + num = W_GetNumForName("MISSING"); + + // No rotation? No need to do any of this nonsense. + if (rotationangle < 1 || rotationangle >= ROTANGLES) + return W_CachePatchNum(num, tag); + + rspr = (rotsprite_t *)W_GetCachedRotPatchPwad(WADFILENUM(num),LUMPNUM(num)); + + if (rspr->patches[idx] == NULL) + { + INT32 xpivot = 0, ypivot = 0; + + ptr = (patch_t *)(W_CacheLumpNum(num, PU_STATIC)); + + // >y pivot centered + // >x pivot not centered + // Why? + xpivot = SHORT(ptr->width) / 2; + ypivot = SHORT(ptr->height) / 2; + + RotatedPatch_DoRotation(rspr, ptr, rotationangle, xpivot, ypivot, false); + + // free image data + Z_Free(ptr); + } + + return rspr->patches[idx]; +} +#endif + #ifndef NOMD5 /** diff --git a/src/w_wad.h b/src/w_wad.h index fd2038db2..d0eb28f2f 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -106,9 +106,7 @@ virtlump_t* vres_Find(const virtres_t*, const char*); #define lumpcache_t void * -#ifdef HWRENDER #include "m_aatree.h" -#endif // Resource type of the WAD. Yeah, I know this sounds dumb, but I'll leave it like this until I clean up the code further. typedef enum restype @@ -129,6 +127,9 @@ typedef struct wadfile_s lumpcache_t *lumpcache; #ifdef HWRENDER aatree_t *hwrcache; // patches are cached in renderer's native format +#endif +#ifdef ROTSPRITE + aatree_t *rotcache; // Cache rotsprites for rotating patches. #endif UINT16 numlumps; // this wad's number of resources FILE *handle; @@ -220,6 +221,11 @@ void *W_CachePatchNum(lumpnum_t lumpnum, INT32 tag); // return a patch_t #define W_CachePatchNum(lumpnum, tag) W_CacheLumpNum(lumpnum, tag) #endif +#ifdef ROTSPRITE +void *W_GetCachedRotPatchPwad(UINT16 wadnum, UINT16 lumpnum); // Get patch-based rotsprites from the cache. +void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag); +#endif + void W_UnlockCachedPatch(void *patch); void W_VerifyFileMD5(UINT16 wadfilenum, const char *matchmd5); diff --git a/src/y_inter.c b/src/y_inter.c index 61f4a069b..009980919 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -319,7 +319,7 @@ static void Y_AnimatedVoteScreenCheck(void) strncpy(tmpPrefix, luaVoteScreen, 4); else { - if(G_BattleGametype()) + if (G_BattleGametype()) strcpy(tmpPrefix, "BTLS"); } @@ -616,7 +616,7 @@ void Y_Ticker(void) if (demo.savemode == DSM_WILLSAVE || demo.savemode == DSM_WILLAUTOSAVE) G_SaveDemo(); - else + else if (demo.savemode != DSM_TITLEENTRY) G_ResetDemoRecording(); } @@ -721,13 +721,13 @@ static void Y_UpdateRecordReplays(void) if ((mainrecords[gamemap-1]->time == 0) || (players[consoleplayer].realtime < mainrecords[gamemap-1]->time)) mainrecords[gamemap-1]->time = players[consoleplayer].realtime; - if ((mainrecords[gamemap-1]->lap == 0) || (bestlap < mainrecords[gamemap-1]->lap)) - mainrecords[gamemap-1]->lap = bestlap; + if ((mainrecords[gamemap-1]->lap == 0) || (players[consoleplayer].laptime[LAP_BEST] < mainrecords[gamemap-1]->lap)) + mainrecords[gamemap-1]->lap = players[consoleplayer].laptime[LAP_BEST]; // Save demo! bestdemo[255] = '\0'; lastdemo[255] = '\0'; - G_SetDemoTime(players[consoleplayer].realtime, bestlap); + G_SetDemoTime(players[consoleplayer].realtime, players[consoleplayer].laptime[LAP_BEST]); G_CheckDemoStatus(); I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); @@ -920,23 +920,15 @@ static void Y_UnloadData(void) // // Draw animated patch based on frame counter on vote screen // -static inline void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) +static void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) { char tempAnimPrefix[7]; - (widePatch) ? strcpy(tempAnimPrefix, animWidePrefix) : strcpy(tempAnimPrefix, animPrefix); - INT32 tempFoundAnimVoteFrames = (widePatch) ? foundAnimVoteWideFrames : foundAnimVoteFrames; + widePatch ? strcpy(tempAnimPrefix, animWidePrefix) : strcpy(tempAnimPrefix, animPrefix); + const INT32 tempFoundAnimVoteFrames = widePatch ? foundAnimVoteWideFrames : foundAnimVoteFrames; // Just in case someone provides LESS widescreen frames than normal frames or vice versa, reset the frame counter to 0 - if (widePatch) - { - if (currentAnimFrame > foundAnimVoteWideFrames-1) - currentAnimFrame = 0; - } - else - { - if (currentAnimFrame > foundAnimVoteFrames-1) - currentAnimFrame = 0; - } + if (currentAnimFrame > tempFoundAnimVoteFrames - 1) + currentAnimFrame = 0; patch_t *background = W_CachePatchName(va("%s%d", tempAnimPrefix, currentAnimFrame + 1), PU_CACHE); V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(background->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) @@ -947,6 +939,34 @@ static inline void Y_DrawAnimatedVoteScreenPatch(boolean widePatch) currentAnimFrame = (currentAnimFrame + 1 > tempFoundAnimVoteFrames - 1) ? 0 : currentAnimFrame + 1; } +static void Y_DrawVoteScreenPatch(void) +{ + const boolean widescreen = (vid.width / vid.dupx > 320); + const boolean animvote = (foundAnimVoteWideFrames || foundAnimVoteFrames); + + if (animvote) + { + Y_DrawAnimatedVoteScreenPatch((foundAnimVoteWideFrames && widescreen)); + return; + } + + patch_t *votebg = bgpatch; // non widescreen patch + + UINT8 prefgametype = (votelevels[0][1] & ~0x80); + const boolean widebgreplaced = (prefgametype == GT_MATCH) ? widebattlereplaced : wideracereplaced; + const boolean bgreplaced = (prefgametype == GT_MATCH) ? battlereplaced : racereplaced; + + if ((widescreen && (widebgreplaced || !bgreplaced)) + || (!widescreen && (widebgreplaced && !bgreplaced))) + { + votebg = widebgpatch; + } + + V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(votebg->width)/2), + (vid.height / vid.dupy) - SHORT(votebg->height), + V_SNAPTOTOP|V_SNAPTOLEFT, votebg); +} + // // Y_VoteDrawer // @@ -973,24 +993,8 @@ void Y_VoteDrawer(void) V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); - if (widebgpatch && vid.width / vid.dupx > 320) - { - if (foundAnimVoteWideFrames == 0) - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(widebgpatch->width)/2), - (vid.height / vid.dupy) - SHORT(widebgpatch->height), - V_SNAPTOTOP|V_SNAPTOLEFT, widebgpatch); - else - Y_DrawAnimatedVoteScreenPatch(true); - } - else - { - if (foundAnimVoteFrames == 0) - V_DrawScaledPatch(((vid.width/2) / vid.dupx) - (SHORT(bgpatch->width)/2), // Keep the width/height adjustments, for screens that are less wide than 320(?) - (vid.height / vid.dupy) - SHORT(bgpatch->height), - V_SNAPTOTOP|V_SNAPTOLEFT, bgpatch); - else - Y_DrawAnimatedVoteScreenPatch(false); - } + // decides which votebg to draw and draws it + Y_DrawVoteScreenPatch(); for (i = 0; i < 4; i++) // First, we need to figure out the height of this thing... {