From f602e5bfb7131dcecdec82ef7665f0e42ae6b923 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 24 Nov 2019 14:35:31 +0000 Subject: [PATCH 001/126] "showconditionset" option for Unlockables and Extra Emblems. See merge request (coming shortly) for full description/prompt. --- src/dehacked.c | 4 ++++ src/m_cond.h | 14 ++++++++------ src/m_menu.c | 8 ++++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 49ad5dc67..5fa4902cb 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -3195,6 +3195,8 @@ static void readextraemblemdata(MYFILE *f, INT32 num) sizeof (extraemblems[num-1].description), va("Extra emblem %d: objective", num)); else if (fastcmp(word, "CONDITIONSET")) extraemblems[num-1].conditionset = (UINT8)value; + else if (fastcmp(word, "SHOWCONDITIONSET")) + extraemblems[num-1].showconditionset = (UINT8)value; else { strupr(word2); @@ -3281,6 +3283,8 @@ static void readunlockable(MYFILE *f, INT32 num) unlockables[num].height = (UINT16)i; else if (fastcmp(word, "CONDITIONSET")) unlockables[num].conditionset = (UINT8)i; + else if (fastcmp(word, "SHOWCONDITIONSET")) + unlockables[num].showconditionset = (UINT8)i; else if (fastcmp(word, "NOCECHO")) unlockables[num].nocecho = (UINT8)(i || word2[0] == 'T' || word2[0] == 'Y'); else if (fastcmp(word, "NOCHECKLIST")) diff --git a/src/m_cond.h b/src/m_cond.h index e9859cf11..f6d011a8f 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -97,12 +97,13 @@ typedef struct } emblem_t; typedef struct { - char name[20]; ///< Name of the goal (used in the "emblem awarded" cecho) - char description[40];///< Description of goal (used in statistics) - UINT8 conditionset; ///< Condition set that awards this emblem. - UINT8 sprite; ///< emblem sprite to use, 0 - 25 - UINT8 color; ///< skincolor to use - UINT8 collected; ///< Do you have this emblem? + char name[20]; ///< Name of the goal (used in the "emblem awarded" cecho) + char description[40]; ///< Description of goal (used in statistics) + UINT8 conditionset; ///< Condition set that awards this emblem. + UINT8 showconditionset; ///< Condition set that shows this emblem. + UINT8 sprite; ///< emblem sprite to use, 0 - 25 + UINT8 color; ///< skincolor to use + UINT8 collected; ///< Do you have this emblem? } extraemblem_t; // Unlockable information @@ -112,6 +113,7 @@ typedef struct char objective[64]; UINT16 height; // menu height UINT8 conditionset; + UINT8 showconditionset; INT16 type; INT16 variable; UINT8 nocecho; diff --git a/src/m_menu.c b/src/m_menu.c index 32efa3fed..df6a2d449 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6685,7 +6685,8 @@ static void M_DrawChecklist(void) while (i < MAXUNLOCKABLES) { if (unlockables[i].name[0] == 0 //|| unlockables[i].nochecklist - || !unlockables[i].conditionset || unlockables[i].conditionset > MAXCONDITIONSETS) + || !unlockables[i].conditionset || unlockables[i].conditionset > MAXCONDITIONSETS + || (!unlockables[i].unlocked && unlockables[i].showconditionset && !M_Achieved(unlockables[i].showconditionset))) continue; V_DrawString(currentMenu->x, y, ((unlockables[i].unlocked) ? V_GREENMAP : V_TRANSLUCENT)|V_ALLOWLOWERCASE, ((unlockables[i].unlocked || !unlockables[i].nochecklist) ? unlockables[i].name : M_CreateSecretMenuOption(unlockables[i].name))); @@ -8901,7 +8902,10 @@ static void M_DrawStatsMaps(int location) else V_DrawSmallScaledPatch(292, y, 0, W_CachePatchName("NEEDIT", PU_CACHE)); - V_DrawString(20, y, V_YELLOWMAP|V_ALLOWLOWERCASE, va("%s", exemblem->description)); + V_DrawString(20, y, V_YELLOWMAP|V_ALLOWLOWERCASE, + (!exemblem->collected && exemblem->showconditionset && !M_Achieved(exemblem->showconditionset)) + ? M_CreateSecretMenuOption(exemblem->description) + : exemblem->description); } y += 8; From fd657d2ff4ac16a415f1b7cbdd32fc8860c1f197 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 24 Nov 2019 15:06:37 +0000 Subject: [PATCH 002/126] Fix bugs discovered in testing. --- src/m_menu.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index df6a2d449..303ba3453 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6625,6 +6625,8 @@ static void M_HandleChecklist(INT32 choice) continue; if (unlockables[j].conditionset > MAXCONDITIONSETS) continue; + if (!unlockables[j].unlocked && unlockables[j].showconditionset && !M_Achieved(unlockables[j].showconditionset)) + continue; if (unlockables[j].conditionset == unlockables[check_on].conditionset) continue; break; @@ -6648,6 +6650,8 @@ static void M_HandleChecklist(INT32 choice) continue; if (unlockables[j].conditionset > MAXCONDITIONSETS) continue; + if (!unlockables[j].unlocked && unlockables[j].showconditionset && !M_Achieved(unlockables[j].showconditionset)) + continue; if (j && unlockables[j].conditionset == unlockables[j-1].conditionset) continue; break; @@ -6687,7 +6691,10 @@ static void M_DrawChecklist(void) if (unlockables[i].name[0] == 0 //|| unlockables[i].nochecklist || !unlockables[i].conditionset || unlockables[i].conditionset > MAXCONDITIONSETS || (!unlockables[i].unlocked && unlockables[i].showconditionset && !M_Achieved(unlockables[i].showconditionset))) + { + i++; continue; + } V_DrawString(currentMenu->x, y, ((unlockables[i].unlocked) ? V_GREENMAP : V_TRANSLUCENT)|V_ALLOWLOWERCASE, ((unlockables[i].unlocked || !unlockables[i].nochecklist) ? unlockables[i].name : M_CreateSecretMenuOption(unlockables[i].name))); @@ -6709,10 +6716,11 @@ static void M_DrawChecklist(void) if (unlockables[i].objective[0] != '/') { - addy(8); - V_DrawString(currentMenu->x, y, + addy(16); + V_DrawString(currentMenu->x, y-8, V_ALLOWLOWERCASE, va("\x1E %s", unlockables[i].objective)); + y -= 8; } else { From 514616c546777ca20e833d40c0a2488d10ef6add Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Dec 2019 19:09:41 +0000 Subject: [PATCH 003/126] Allow for 10 emblem hints on a map by poking the drawer a bit. This is a very small diff, but I can understand if you'd not feel comfortable having this until after 2.2.0. --- src/m_menu.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index bd96b5d0d..b5a28d0f7 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6955,11 +6955,23 @@ static void M_EmblemHints(INT32 choice) static void M_DrawEmblemHints(void) { - INT32 i, j = 0; - UINT32 collected = 0; + INT32 i, j = 0, x, y; + UINT32 collected = 0, local = 0; emblem_t *emblem; const char *hint; + for (i = 0; i < numemblems; i++) + { + emblem = &emblemlocations[i]; + if (emblem->level != gamemap || emblem->type > ET_SKIN) + continue; + if (++local >= NUMHINTS*2) + break; + } + + x = (local > NUMHINTS ? 4 : 12); + y = 8; + for (i = 0; i < numemblems; i++) { emblem = &emblemlocations[i]; @@ -6969,13 +6981,13 @@ static void M_DrawEmblemHints(void) if (emblem->collected) { collected = V_GREENMAP; - V_DrawMappedPatch(12, 12+(28*j), 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_CACHE), + V_DrawMappedPatch(x, y+4, 0, W_CachePatchName(M_GetEmblemPatch(emblem, false), PU_CACHE), R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(emblem), GTC_CACHE)); } else { collected = 0; - V_DrawScaledPatch(12, 12+(28*j), 0, W_CachePatchName("NEEDIT", PU_CACHE)); + V_DrawScaledPatch(x, y+4, 0, W_CachePatchName("NEEDIT", PU_CACHE)); } if (emblem->hint[0]) @@ -6983,9 +6995,19 @@ static void M_DrawEmblemHints(void) else hint = M_GetText("No hints available."); hint = V_WordWrap(40, BASEVIDWIDTH-12, 0, hint); - V_DrawString(40, 8+(28*j), V_RETURN8|V_ALLOWLOWERCASE|collected, hint); + if (local > NUMHINTS) + V_DrawThinString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); + else + V_DrawString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); - if (++j >= NUMHINTS) + y += 28; + + if (++j == NUMHINTS) + { + x = 4+(BASEVIDWIDTH/2); + y = 8; + } + else if (j >= NUMHINTS*2) break; } if (!j) From b76a1d3df733754d2c56ac12e91cde10cceb82fe Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 5 Dec 2019 19:26:31 +0000 Subject: [PATCH 004/126] * Don't iterate through the list twice to print "No hidden emblems on this map". * Make it "No hint available for this emblem" instead of "No hints available", which people may confuse as the first message (I know I did!) --- src/m_menu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index b5a28d0f7..061ea1e96 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6972,7 +6972,9 @@ static void M_DrawEmblemHints(void) x = (local > NUMHINTS ? 4 : 12); y = 8; - for (i = 0; i < numemblems; i++) + if (!local) + V_DrawCenteredString(160, 48, V_YELLOWMAP, "No hidden emblems on this map."); + else for (i = 0; i < numemblems; i++) { emblem = &emblemlocations[i]; if (emblem->level != gamemap || emblem->type > ET_SKIN) @@ -6993,7 +6995,7 @@ static void M_DrawEmblemHints(void) if (emblem->hint[0]) hint = emblem->hint; else - hint = M_GetText("No hints available."); + hint = M_GetText("No hint available for this emblem."); hint = V_WordWrap(40, BASEVIDWIDTH-12, 0, hint); if (local > NUMHINTS) V_DrawThinString(x+28, y, V_RETURN8|V_ALLOWLOWERCASE|collected, hint); @@ -7010,8 +7012,6 @@ static void M_DrawEmblemHints(void) else if (j >= NUMHINTS*2) break; } - if (!j) - V_DrawCenteredString(160, 48, V_YELLOWMAP, "No hidden emblems on this map."); M_DrawGenericMenu(); } From 32c9c912abfda9c75921666a89deac4081cccad3 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 13:27:11 -0600 Subject: [PATCH 005/126] Consolidate G_BuildTiccmd --- src/d_clisrv.c | 4 +- src/g_game.c | 541 ++++++++++++------------------------------------- src/g_game.h | 3 +- src/g_input.h | 1 + 4 files changed, 131 insertions(+), 418 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 188304fda..394ce9b5d 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4624,9 +4624,9 @@ static void Local_Maketic(INT32 realtics) // and G_MapEventsToControls if (!dedicated) rendergametic = gametic; // translate inputs (keyboard/mouse/joystick) into game controls - G_BuildTiccmd(&localcmds, realtics); + G_BuildTiccmd(&localcmds, realtics, 1); if (splitscreen || botingame) - G_BuildTiccmd2(&localcmds2, realtics); + G_BuildTiccmd(&localcmds2, realtics, 2); localcmds.angleturn |= TICCMD_RECEIVED; } diff --git a/src/g_game.c b/src/g_game.c index 2a12dd298..a55c1b1eb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -965,6 +965,8 @@ static INT32 Joy2Axis(axis_input_e axissel) return retaxis; } +#define PlayerJoyAxis(p, ax) ((p) == 1 ? JoyAxis(ax) : Joy2Axis(ax)) + // // G_BuildTiccmd @@ -981,7 +983,7 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {25<>16, 50<>16}; // faster! static fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn -void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) +void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { boolean forcestrafe = false; boolean forcefullinput = false; @@ -989,48 +991,81 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) const INT32 speed = 1; // these ones used for multiple conditions boolean turnleft, turnright, strafelkey, straferkey, movefkey, movebkey, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming; - player_t *player = &players[consoleplayer]; - camera_t *thiscam = &camera; + player_t *player = &players[ssplayer == 2 ? secondarydisplayplayer : consoleplayer]; + camera_t *thiscam = ((ssplayer == 1 || player->bot == 2) ? &camera : &camera2); + angle_t *myangle = (ssplayer == 1 ? &localangle : &localangle2); + INT32 *myaiming = (ssplayer == 1 ? &localaiming : &localaiming2); - static INT32 turnheld; // for accelerative turning - static boolean keyboard_look; // true if lookup/down using keyboard - static boolean resetdown; // don't cam reset every frame - static boolean joyaiming; // check the last frame's value if we need to reset the camera + INT32 chasecam, chasefreelook, alwaysfreelook, usejoystick, analog, invertmouse, mousemove; + INT32 *mx; INT32 *my; INT32 *mly; - G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + static INT32 turnheld[2]; // for accelerative turning + static boolean keyboard_look[2]; // true if lookup/down using keyboard + static boolean resetdown[2]; // don't cam reset every frame + static boolean joyaiming[2]; // check the last frame's value if we need to reset the camera + UINT8 forplayer = ssplayer-1; + + if (ssplayer == 1) + { + chasecam = cv_chasecam.value; + chasefreelook = cv_chasefreelook.value; + alwaysfreelook = cv_alwaysfreelook.value; + usejoystick = cv_usejoystick.value; + analog = cv_analog.value; + invertmouse = cv_invertmouse.value; + mousemove = cv_mousemove.value; + mx = &mousex; + my = &mousey; + mly = &mlooky; + G_CopyTiccmd(cmd, I_BaseTiccmd(), 1); // empty, or external driver + } + else + { + chasecam = cv_chasecam2.value; + chasefreelook = cv_chasefreelook2.value; + alwaysfreelook = cv_alwaysfreelook2.value; + usejoystick = cv_usejoystick2.value; + analog = cv_analog2.value; + invertmouse = cv_invertmouse2.value; + mousemove = cv_mousemove2.value; + mx = &mouse2x; + my = &mouse2y; + mly = &mlook2y; + G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver + } // why build a ticcmd if we're paused? // Or, for that matter, if we're being reborn. // ...OR if we're blindfolded. No looking into the floor. if (paused || P_AutoPause() || (gamestate == GS_LEVEL && (player->playerstate == PST_REBORN || ((gametype == GT_TAG || gametype == GT_HIDEANDSEEK) && (leveltime < hidetime * TICRATE) && (player->pflags & PF_TAGIT))))) - { - cmd->angleturn = (INT16)(localangle >> 16); - cmd->aiming = G_ClipAimingPitch(&localaiming); + {//@TODO splitscreen player + cmd->angleturn = (INT16)(*myangle >> 16); + cmd->aiming = G_ClipAimingPitch(myaiming); return; } - turnright = PLAYER1INPUTDOWN(gc_turnright); - turnleft = PLAYER1INPUTDOWN(gc_turnleft); + turnright = PLAYERINPUTDOWN(ssplayer, gc_turnright); + turnleft = PLAYERINPUTDOWN(ssplayer, gc_turnleft); - straferkey = PLAYER1INPUTDOWN(gc_straferight); - strafelkey = PLAYER1INPUTDOWN(gc_strafeleft); - movefkey = PLAYER1INPUTDOWN(gc_forward); - movebkey = PLAYER1INPUTDOWN(gc_backward); + straferkey = PLAYERINPUTDOWN(ssplayer, gc_straferight); + strafelkey = PLAYERINPUTDOWN(ssplayer, gc_strafeleft); + movefkey = PLAYERINPUTDOWN(ssplayer, gc_forward); + movebkey = PLAYERINPUTDOWN(ssplayer, gc_backward); - mouseaiming = (PLAYER1INPUTDOWN(gc_mouseaiming)) ^ - ((cv_chasecam.value && !player->spectator) ? cv_chasefreelook.value : cv_alwaysfreelook.value); - analogjoystickmove = cv_usejoystick.value && !Joystick.bGamepadStyle; - gamepadjoystickmove = cv_usejoystick.value && Joystick.bGamepadStyle; + mouseaiming = (PLAYERINPUTDOWN(ssplayer, gc_mouseaiming)) ^ + ((chasecam && !player->spectator) ? chasefreelook : alwaysfreelook); + analogjoystickmove = usejoystick && !Joystick.bGamepadStyle; + gamepadjoystickmove = usejoystick && Joystick.bGamepadStyle; - thisjoyaiming = (cv_chasecam.value && !player->spectator) ? cv_chasefreelook.value : cv_alwaysfreelook.value; + thisjoyaiming = (chasecam && !player->spectator) ? chasefreelook : alwaysfreelook; // Reset the vertical look if we're no longer joyaiming - if (!thisjoyaiming && joyaiming) - localaiming = 0; - joyaiming = thisjoyaiming; + if (!thisjoyaiming && joyaiming[forplayer]) + *myaiming = 0; + joyaiming[forplayer] = thisjoyaiming; - axis = JoyAxis(AXISTURN); + axis = PlayerJoyAxis(ssplayer, AXISTURN); if (gamepadjoystickmove && axis != 0) { turnright = turnright || (axis > 0); @@ -1041,17 +1076,17 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) // use two stage accelerative turning // on the keyboard and joystick if (turnleft || turnright) - turnheld += realtics; + turnheld[forplayer] += realtics; else - turnheld = 0; + turnheld[forplayer] = 0; - if (turnheld < SLOWTURNTICS) + if (turnheld[forplayer] < SLOWTURNTICS) tspeed = 2; // slow turn else tspeed = speed; // let movement keys cancel each other out - if (cv_analog.value) // Analog + if (analog) // Analog { if (turnright) cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); @@ -1080,7 +1115,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) side += ((axis * sidemove[1]) >> 10); } } - else if (cv_analog.value) // Analog + else if (analog) // Analog { if (turnright) cmd->buttons |= BT_CAMRIGHT; @@ -1101,7 +1136,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) } } - axis = JoyAxis(AXISSTRAFE); + axis = PlayerJoyAxis(ssplayer, AXISSTRAFE); if (gamepadjoystickmove && axis != 0) { if (axis < 0) @@ -1116,15 +1151,15 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) } // forward with key or button - axis = JoyAxis(AXISMOVE); - altaxis = JoyAxis(AXISLOOK); + axis = PlayerJoyAxis(ssplayer, AXISMOVE); + altaxis = PlayerJoyAxis(ssplayer, AXISLOOK); if (movefkey || (gamepadjoystickmove && axis < 0) || ((player->powers[pw_carry] == CR_NIGHTSMODE) - && (PLAYER1INPUTDOWN(gc_lookup) || (gamepadjoystickmove && altaxis < 0)))) + && (PLAYERINPUTDOWN(ssplayer, gc_lookup) || (gamepadjoystickmove && altaxis < 0)))) forward = forwardmove[speed]; if (movebkey || (gamepadjoystickmove && axis > 0) || ((player->powers[pw_carry] == CR_NIGHTSMODE) - && (PLAYER1INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && altaxis > 0)))) + && (PLAYERINPUTDOWN(ssplayer, gc_lookdown) || (gamepadjoystickmove && altaxis > 0)))) forward -= forwardmove[speed]; if (analogjoystickmove && axis != 0) @@ -1137,9 +1172,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) if (strafelkey) side -= sidemove[speed]; - if (PLAYER1INPUTDOWN(gc_weaponnext)) + if (PLAYERINPUTDOWN(ssplayer, gc_weaponnext)) cmd->buttons |= BT_WEAPONNEXT; // Next Weapon - if (PLAYER1INPUTDOWN(gc_weaponprev)) + if (PLAYERINPUTDOWN(ssplayer, gc_weaponprev)) cmd->buttons |= BT_WEAPONPREV; // Previous Weapon #if NUM_WEAPONS > 10 @@ -1148,119 +1183,120 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) //use the four avaliable bits to determine the weapon. cmd->buttons &= ~BT_WEAPONMASK; for (i = 0; i < NUM_WEAPONS; ++i) - if (PLAYER1INPUTDOWN(gc_wepslot1 + i)) + if (PLAYERINPUTDOWN(ssplayer, gc_wepslot1 + i)) { cmd->buttons |= (UINT16)(i + 1); break; } // fire with any button/key - axis = JoyAxis(AXISFIRE); - if (PLAYER1INPUTDOWN(gc_fire) || (cv_usejoystick.value && axis > 0)) + axis = PlayerJoyAxis(ssplayer, AXISFIRE); + if (PLAYERINPUTDOWN(ssplayer, gc_fire) || (usejoystick && axis > 0)) cmd->buttons |= BT_ATTACK; // fire normal with any button/key - axis = JoyAxis(AXISFIRENORMAL); - if (PLAYER1INPUTDOWN(gc_firenormal) || (cv_usejoystick.value && axis > 0)) + axis = PlayerJoyAxis(ssplayer, AXISFIRENORMAL); + if (PLAYERINPUTDOWN(ssplayer, gc_firenormal) || (usejoystick && axis > 0)) cmd->buttons |= BT_FIRENORMAL; - if (PLAYER1INPUTDOWN(gc_tossflag)) + if (PLAYERINPUTDOWN(ssplayer, gc_tossflag)) cmd->buttons |= BT_TOSSFLAG; // Lua scriptable buttons - if (PLAYER1INPUTDOWN(gc_custom1)) + if (PLAYERINPUTDOWN(ssplayer, gc_custom1)) cmd->buttons |= BT_CUSTOM1; - if (PLAYER1INPUTDOWN(gc_custom2)) + if (PLAYERINPUTDOWN(ssplayer, gc_custom2)) cmd->buttons |= BT_CUSTOM2; - if (PLAYER1INPUTDOWN(gc_custom3)) + if (PLAYERINPUTDOWN(ssplayer, gc_custom3)) cmd->buttons |= BT_CUSTOM3; // use with any button/key - axis = JoyAxis(AXISSPIN); - if (PLAYER1INPUTDOWN(gc_use) || (cv_usejoystick.value && axis > 0)) + axis = PlayerJoyAxis(ssplayer, AXISSPIN); + if (PLAYERINPUTDOWN(ssplayer, gc_use) || (usejoystick && axis > 0)) cmd->buttons |= BT_USE; - if (PLAYER1INPUTDOWN(gc_camreset)) + if (PLAYERINPUTDOWN(ssplayer, gc_camreset)) { - if (camera.chase && !resetdown) - P_ResetCamera(&players[displayplayer], &camera); - resetdown = true; + if (camera.chase && !resetdown[forplayer]) + P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], &camera); + resetdown[forplayer] = true; } else - resetdown = false; + resetdown[forplayer] = false; // jump button - axis = JoyAxis(AXISJUMP); - if (PLAYER1INPUTDOWN(gc_jump) || (cv_usejoystick.value && axis > 0)) + axis = PlayerJoyAxis(ssplayer, AXISJUMP); + if (PLAYERINPUTDOWN(ssplayer, gc_jump) || (usejoystick && axis > 0)) cmd->buttons |= BT_JUMP; // player aiming shit, ahhhh... { - INT32 player_invert = cv_invertmouse.value ? -1 : 1; + INT32 player_invert = invertmouse ? -1 : 1; INT32 screen_invert = (player->mo && (player->mo->eflags & MFE_VERTICALFLIP) && (!camera.chase || player->pflags & PF_FLIPCAM)) //because chasecam's not inverted ? -1 : 1; // set to -1 or 1 to multiply + INT32 lookaxis = ssplayer == 1 ? cv_lookaxis.value : cv_lookaxis2.value; // mouse look stuff (mouse look is not the same as mouse aim) if (mouseaiming) { - keyboard_look = false; + keyboard_look[forplayer] = false; // looking up/down - localaiming += (mlooky<<19)*player_invert*screen_invert; + *myaiming += (*mly<<19)*player_invert*screen_invert; } - axis = JoyAxis(AXISLOOK); - if (analogjoystickmove && joyaiming && axis != 0 && cv_lookaxis.value != 0) - localaiming += (axis<<16) * screen_invert; + axis = PlayerJoyAxis(ssplayer, AXISLOOK); + if (analogjoystickmove && joyaiming[forplayer] && axis != 0 && lookaxis != 0) + *myaiming += (axis<<16) * screen_invert; // spring back if not using keyboard neither mouselookin' - if (!keyboard_look && cv_lookaxis.value == 0 && !joyaiming && !mouseaiming) - localaiming = 0; + if (!keyboard_look[forplayer] && lookaxis == 0 && !joyaiming[forplayer] && !mouseaiming) + *myaiming = 0; if (!(player->powers[pw_carry] == CR_NIGHTSMODE)) { - if (PLAYER1INPUTDOWN(gc_lookup) || (gamepadjoystickmove && axis < 0)) + if (PLAYERINPUTDOWN(ssplayer, gc_lookup) || (gamepadjoystickmove && axis < 0)) { - localaiming += KB_LOOKSPEED * screen_invert; - keyboard_look = true; + *myaiming += KB_LOOKSPEED * screen_invert; + keyboard_look[forplayer] = true; } - else if (PLAYER1INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && axis > 0)) + else if (PLAYERINPUTDOWN(ssplayer, gc_lookdown) || (gamepadjoystickmove && axis > 0)) { - localaiming -= KB_LOOKSPEED * screen_invert; - keyboard_look = true; + *myaiming -= KB_LOOKSPEED * screen_invert; + keyboard_look[forplayer] = true; } - else if (PLAYER1INPUTDOWN(gc_centerview)) - localaiming = 0; + else if (PLAYERINPUTDOWN(ssplayer, gc_centerview)) + *myaiming = 0; } // accept no mlook for network games if (!cv_allowmlook.value) - localaiming = 0; + *myaiming = 0; - cmd->aiming = G_ClipAimingPitch(&localaiming); + cmd->aiming = G_ClipAimingPitch(myaiming); } - if (!mouseaiming && cv_mousemove.value) - forward += mousey; + if (!mouseaiming && mousemove) + forward += *my; if ((!demoplayback && (player->pflags & PF_SLIDING))) // Analog for mouse - side += mousex*2; - else if (cv_analog.value) + side += *mx*2; + else if (analog) { - if (mousex) + if (*mx) { - if (mousex > 0) + if (*mx > 0) cmd->buttons |= BT_CAMRIGHT; else cmd->buttons |= BT_CAMLEFT; } } else - cmd->angleturn = (INT16)(cmd->angleturn - (mousex*8)); + cmd->angleturn = (INT16)(cmd->angleturn - (*mx*8)); - mousex = mousey = mlooky = 0; + *mx = *my = *mly = 0; if (forward > MAXPLMOVE) forward = MAXPLMOVE; @@ -1293,335 +1329,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics) cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); cmd->sidemove = (SINT8)(cmd->sidemove + side); - if (cv_analog.value) { - if (player->awayviewtics) - cmd->angleturn = (INT16)(player->awayviewmobj->angle >> 16); - else - cmd->angleturn = (INT16)(thiscam->angle >> 16); - } - else - { - localangle += (cmd->angleturn<<16); - cmd->angleturn = (INT16)(localangle >> 16); - } - - //Reset away view if a command is given. - if ((cmd->forwardmove || cmd->sidemove || cmd->buttons) - && displayplayer != consoleplayer) - displayplayer = consoleplayer; -} - -// like the g_buildticcmd 1 but using mouse2, gamcontrolbis, ... -void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics) -{ - boolean forcestrafe = false; - boolean forcefullinput = false; - INT32 tspeed, forward, side, axis, altaxis, i; - const INT32 speed = 1; - // these ones used for multiple conditions - boolean turnleft, turnright, strafelkey, straferkey, movefkey, movebkey, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming; - player_t *player = &players[secondarydisplayplayer]; - camera_t *thiscam = (player->bot == 2 ? &camera : &camera2); - - static INT32 turnheld; // for accelerative turning - static boolean keyboard_look; // true if lookup/down using keyboard - static boolean resetdown; // don't cam reset every frame - static boolean joyaiming; // check the last frame's value if we need to reset the camera - - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver - - //why build a ticcmd if we're paused? - // Or, for that matter, if we're being reborn. - if (paused || P_AutoPause() || player->playerstate == PST_REBORN) - { - cmd->angleturn = (INT16)(localangle2 >> 16); - cmd->aiming = G_ClipAimingPitch(&localaiming2); - return; - } - - turnright = PLAYER2INPUTDOWN(gc_turnright); - turnleft = PLAYER2INPUTDOWN(gc_turnleft); - - straferkey = PLAYER2INPUTDOWN(gc_straferight); - strafelkey = PLAYER2INPUTDOWN(gc_strafeleft); - movefkey = PLAYER2INPUTDOWN(gc_forward); - movebkey = PLAYER2INPUTDOWN(gc_backward); - - mouseaiming = (PLAYER2INPUTDOWN(gc_mouseaiming)) ^ - ((cv_chasecam2.value && !player->spectator) ? cv_chasefreelook2.value : cv_alwaysfreelook2.value); - analogjoystickmove = cv_usejoystick2.value && !Joystick2.bGamepadStyle; - gamepadjoystickmove = cv_usejoystick2.value && Joystick2.bGamepadStyle; - - thisjoyaiming = (cv_chasecam2.value && !player->spectator) ? cv_chasefreelook2.value : cv_alwaysfreelook2.value; - - // Reset the vertical look if we're no longer joyaiming - if (!thisjoyaiming && joyaiming) - localaiming2 = 0; - joyaiming = thisjoyaiming; - - axis = Joy2Axis(AXISTURN); - if (gamepadjoystickmove && 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) - turnheld += realtics; - else - turnheld = 0; - - if (turnheld < SLOWTURNTICS) - tspeed = 2; // slow turn - else - tspeed = speed; - - // let movement keys cancel each other out - if (cv_analog2.value) // Analog - { - if (turnright) - cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); - if (turnleft) - cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]); - } - if (twodlevel - || (player->mo && (player->mo->flags2 & MF2_TWOD)) - || (!demoplayback && (player->pflags & PF_SLIDING))) - forcefullinput = true; - if (twodlevel - || (player->mo && (player->mo->flags2 & MF2_TWOD)) - || player->climbing - || (player->powers[pw_carry] == CR_NIGHTSMODE) - || (player->pflags & (PF_SLIDING|PF_FORCESTRAFE))) // Analog - forcestrafe = true; - if (forcestrafe) // Analog - { - if (turnright) - side += sidemove[speed]; - if (turnleft) - side -= sidemove[speed]; - - if (analogjoystickmove && axis != 0) - { - // JOYAXISRANGE is supposed to be 1023 (divide by 1024) - side += ((axis * sidemove[1]) >> 10); - } - } - else if (cv_analog2.value) // Analog - { - if (turnright) - cmd->buttons |= BT_CAMRIGHT; - if (turnleft) - cmd->buttons |= BT_CAMLEFT; - } - else - { - if (turnright) - cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); - else if (turnleft) - cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]); - - if (analogjoystickmove && axis != 0) - { - // JOYAXISRANGE should be 1023 (divide by 1024) - cmd->angleturn = (INT16)(cmd->angleturn - ((axis * angleturn[1]) >> 10)); // ANALOG! - } - } - - axis = Joy2Axis(AXISSTRAFE); - if (gamepadjoystickmove && axis != 0) - { - if (axis < 0) - side += sidemove[speed]; - else if (axis > 0) - side -= sidemove[speed]; - } - else if (analogjoystickmove && axis != 0) - { - // JOYAXISRANGE is supposed to be 1023 (divide by 1024) - side += ((axis * sidemove[1]) >> 10); - } - - // forward with key or button - axis = Joy2Axis(AXISMOVE); - altaxis = Joy2Axis(AXISLOOK); - if (movefkey || (gamepadjoystickmove && axis < 0) - || ((player->powers[pw_carry] == CR_NIGHTSMODE) - && (PLAYER2INPUTDOWN(gc_lookup) || (gamepadjoystickmove && altaxis < 0)))) - forward = forwardmove[speed]; - if (movebkey || (gamepadjoystickmove && axis > 0) - || ((player->powers[pw_carry] == CR_NIGHTSMODE) - && (PLAYER2INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && altaxis > 0)))) - forward -= forwardmove[speed]; - - if (analogjoystickmove && axis != 0) - forward -= ((axis * forwardmove[1]) >> 10); // ANALOG! - - // some people strafe left & right with mouse buttons - // those people are (still) weird - if (straferkey) - side += sidemove[speed]; - if (strafelkey) - side -= sidemove[speed]; - - if (PLAYER2INPUTDOWN(gc_weaponnext)) - cmd->buttons |= BT_WEAPONNEXT; // Next Weapon - if (PLAYER2INPUTDOWN(gc_weaponprev)) - cmd->buttons |= BT_WEAPONPREV; // Previous Weapon - - //use the four avaliable bits to determine the weapon. - cmd->buttons &= ~BT_WEAPONMASK; - for (i = 0; i < NUM_WEAPONS; ++i) - if (PLAYER2INPUTDOWN(gc_wepslot1 + i)) - { - cmd->buttons |= (UINT16)(i + 1); - break; - } - - // fire with any button/key - axis = Joy2Axis(AXISFIRE); - if (PLAYER2INPUTDOWN(gc_fire) || (cv_usejoystick2.value && axis > 0)) - cmd->buttons |= BT_ATTACK; - - // fire normal with any button/key - axis = Joy2Axis(AXISFIRENORMAL); - if (PLAYER2INPUTDOWN(gc_firenormal) || (cv_usejoystick2.value && axis > 0)) - cmd->buttons |= BT_FIRENORMAL; - - if (PLAYER2INPUTDOWN(gc_tossflag)) - cmd->buttons |= BT_TOSSFLAG; - - // Lua scriptable buttons - if (PLAYER2INPUTDOWN(gc_custom1)) - cmd->buttons |= BT_CUSTOM1; - if (PLAYER2INPUTDOWN(gc_custom2)) - cmd->buttons |= BT_CUSTOM2; - if (PLAYER2INPUTDOWN(gc_custom3)) - cmd->buttons |= BT_CUSTOM3; - - // use with any button/key - axis = Joy2Axis(AXISSPIN); - if (PLAYER2INPUTDOWN(gc_use) || (cv_usejoystick2.value && axis > 0)) - cmd->buttons |= BT_USE; - - if (PLAYER2INPUTDOWN(gc_camreset)) - { - if (camera2.chase && !resetdown) - P_ResetCamera(&players[secondarydisplayplayer], &camera2); - resetdown = true; - } - else - resetdown = false; - - // jump button - axis = Joy2Axis(AXISJUMP); - if (PLAYER2INPUTDOWN(gc_jump) || (cv_usejoystick2.value && axis > 0)) - cmd->buttons |= BT_JUMP; - - // player aiming shit, ahhhh... - { - INT32 player_invert = cv_invertmouse2.value ? -1 : 1; - INT32 screen_invert = - (player->mo && (player->mo->eflags & MFE_VERTICALFLIP) - && (!camera2.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) - { - keyboard_look = false; - - // looking up/down - localaiming2 += (mlook2y<<19)*player_invert*screen_invert; - } - - axis = Joy2Axis(AXISLOOK); - if (analogjoystickmove && joyaiming && axis != 0 && cv_lookaxis2.value != 0) - localaiming2 += (axis<<16) * screen_invert; - - // spring back if not using keyboard neither mouselookin' - if (!keyboard_look && cv_lookaxis2.value == 0 && !joyaiming && !mouseaiming) - localaiming2 = 0; - - if (!(player->powers[pw_carry] == CR_NIGHTSMODE)) - { - if (PLAYER2INPUTDOWN(gc_lookup) || (gamepadjoystickmove && axis < 0)) - { - localaiming2 += KB_LOOKSPEED * screen_invert; - keyboard_look = true; - } - else if (PLAYER2INPUTDOWN(gc_lookdown) || (gamepadjoystickmove && axis > 0)) - { - localaiming2 -= KB_LOOKSPEED * screen_invert; - keyboard_look = true; - } - else if (PLAYER2INPUTDOWN(gc_centerview)) - localaiming2 = 0; - } - - // accept no mlook for network games - if (!cv_allowmlook.value) - localaiming2 = 0; - - cmd->aiming = G_ClipAimingPitch(&localaiming2); - } - - if (!mouseaiming && cv_mousemove2.value) - forward += mouse2y; - - if (player->climbing - || (player->pflags & PF_SLIDING)) // Analog for mouse - side += mouse2x*2; - else if (cv_analog2.value) - { - if (mouse2x) - { - if (mouse2x > 0) - cmd->buttons |= BT_CAMRIGHT; - else - cmd->buttons |= BT_CAMLEFT; - } - } - else - cmd->angleturn = (INT16)(cmd->angleturn - (mouse2x*8)); - - mouse2x = mouse2y = mlook2y = 0; - - if (forward > MAXPLMOVE) - forward = MAXPLMOVE; - else if (forward < -MAXPLMOVE) - forward = -MAXPLMOVE; - if (side > MAXPLMOVE) - side = MAXPLMOVE; - else if (side < -MAXPLMOVE) - side = -MAXPLMOVE; - - // No additional acceleration when moving forward/backward and strafing simultaneously. - // do this AFTER we cap to MAXPLMOVE so people can't find ways to cheese around this. - if (!forcefullinput && forward && side) - { - angle_t angle = R_PointToAngle2(0, 0, side << FRACBITS, forward << FRACBITS); - INT32 maxforward = abs(P_ReturnThrustY(NULL, angle, MAXPLMOVE)); - INT32 maxside = abs(P_ReturnThrustX(NULL, angle, MAXPLMOVE)); - forward = max(min(forward, maxforward), -maxforward); - side = max(min(side, maxside), -maxside); - } - - //Silly hack to make 2d mode *somewhat* playable with no chasecam. - if ((twodlevel || (player->mo && player->mo->flags2 & MF2_TWOD)) && !camera2.chase) - { - INT32 temp = forward; - forward = side; - side = temp; - } - - cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); - cmd->sidemove = (SINT8)(cmd->sidemove + side); - - if (player->bot == 1) { + if (player->bot == 1) { // Tailsbot for P2 if (!player->powers[pw_tailsfly] && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) { player->bot = 2; // A player-controlled bot. Returns to AI when it respawns. @@ -1634,7 +1342,7 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics) } } - if (cv_analog2.value) { + if (analog) { if (player->awayviewtics) cmd->angleturn = (INT16)(player->awayviewmobj->angle >> 16); else @@ -1642,9 +1350,14 @@ void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics) } else { - localangle2 += (cmd->angleturn<<16); - cmd->angleturn = (INT16)(localangle2 >> 16); + *myangle += (cmd->angleturn<<16); + cmd->angleturn = (INT16)(*myangle >> 16); } + + //Reset away view if a command is given. + if (ssplayer == 1 && (cmd->forwardmove || cmd->sidemove || cmd->buttons) + && displayplayer != consoleplayer) + displayplayer = consoleplayer; } // User has designated that they want diff --git a/src/g_game.h b/src/g_game.h index e7f4a4677..3067751ee 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -83,8 +83,7 @@ extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_g // build an internal map name MAPxx from map number const char *G_BuildMapName(INT32 map); -void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics); -void G_BuildTiccmd2(ticcmd_t *cmd, INT32 realtics); +void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer); // copy ticcmd_t to and fro the normal way ticcmd_t *G_CopyTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n); diff --git a/src/g_input.h b/src/g_input.h index d089332c5..f7f952d72 100644 --- a/src/g_input.h +++ b/src/g_input.h @@ -132,6 +132,7 @@ extern INT32 gamecontroldefault[num_gamecontrolschemes][num_gamecontrols][2]; // extern INT32 gamecontrolbisdefault[num_gamecontrolschemes][num_gamecontrols][2]; #define PLAYER1INPUTDOWN(gc) (gamekeydown[gamecontrol[gc][0]] || gamekeydown[gamecontrol[gc][1]]) #define PLAYER2INPUTDOWN(gc) (gamekeydown[gamecontrolbis[gc][0]] || gamekeydown[gamecontrolbis[gc][1]]) +#define PLAYERINPUTDOWN(p, gc) ((p) == 2 ? PLAYER2INPUTDOWN(gc) : PLAYER1INPUTDOWN(gc)) #define num_gcl_tutorial_check 6 #define num_gcl_tutorial_used 8 From 075f751f674e0285f554e7d2569a04470e9ba902 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 14:17:48 -0600 Subject: [PATCH 006/126] Add cvar to use abilities in input direction --- src/d_netcmd.c | 4 ++++ src/g_game.c | 25 ++++++++++++++++++++++++- src/g_game.h | 3 +++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index e80d07b76..f181c6e57 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -823,6 +823,10 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_autobrake); CV_RegisterVar(&cv_autobrake2); + // hi here's some new controls + CV_RegisterVar(&cv_abilitydirection[0]); + CV_RegisterVar(&cv_abilitydirection[1]); + // s_sound.c CV_RegisterVar(&cv_soundvolume); CV_RegisterVar(&cv_closedcaptioning); diff --git a/src/g_game.c b/src/g_game.c index a55c1b1eb..598f328aa 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -394,6 +394,12 @@ consvar_t cv_directionchar2 = {"directionchar2", "Movement", CV_SAVE|CV_CALL, di consvar_t cv_autobrake = {"autobrake", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_autobrake2 = {"autobrake2", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake2_OnChange, 0, NULL, NULL, 0, 0, NULL}; +// hi here's some new controls +consvar_t cv_abilitydirection[2] = { + {"abilitydirection", "Movement", CV_SAVE, directionchar_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"abilitydirection2", "Movement", CV_SAVE, directionchar_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; + typedef enum { AXISNONE = 0, @@ -996,7 +1002,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) angle_t *myangle = (ssplayer == 1 ? &localangle : &localangle2); INT32 *myaiming = (ssplayer == 1 ? &localaiming : &localaiming2); - INT32 chasecam, chasefreelook, alwaysfreelook, usejoystick, analog, invertmouse, mousemove; + INT32 chasecam, chasefreelook, alwaysfreelook, usejoystick, analog, invertmouse, mousemove, abilitydirection; INT32 *mx; INT32 *my; INT32 *mly; static INT32 turnheld[2]; // for accelerative turning @@ -1033,6 +1039,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) mly = &mlook2y; G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver } + abilitydirection = cv_abilitydirection[forplayer].value; // why build a ticcmd if we're paused? // Or, for that matter, if we're being reborn. @@ -1352,6 +1359,22 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { *myangle += (cmd->angleturn<<16); cmd->angleturn = (INT16)(*myangle >> 16); + + if (abilitydirection && !player->climbing && !forcestrafe) + { + if (cmd->forwardmove || cmd->sidemove) + { + angle_t controlangle = R_PointToAngle2(0, 0, cmd->forwardmove << FRACBITS, -cmd->sidemove << FRACBITS); + cmd->angleturn += (controlangle>>16); + + cmd->forwardmove = R_PointToDist2(0, 0, cmd->forwardmove, cmd->sidemove); + if (cmd->forwardmove > MAXPLMOVE) + cmd->forwardmove = MAXPLMOVE; + cmd->sidemove = 0; + } + else + cmd->angleturn = (player->drawangle>>16); + } } //Reset away view if a command is given. diff --git a/src/g_game.h b/src/g_game.h index 3067751ee..86bcf3d59 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -76,6 +76,9 @@ extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_ extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2; extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; +// hi here's some new controls +extern consvar_t cv_abilitydirection[2]; + // mouseaiming (looking up/down with the mouse or keyboard) #define KB_LOOKSPEED (1<<25) #define MAXPLMOVE (50) From 36fa94a22ce53810500146728a541b364ab09d84 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 14:35:50 -0600 Subject: [PATCH 007/126] Automatically rotate camera to reflect player actions --- src/d_netcmd.c | 6 ++++++ src/g_game.c | 43 ++++++++++++++++++++++++++++++++++++++++++- src/g_game.h | 2 +- src/p_user.c | 6 ++++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index f181c6e57..49d3d060c 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -826,6 +826,12 @@ void D_RegisterClientCommands(void) // hi here's some new controls CV_RegisterVar(&cv_abilitydirection[0]); CV_RegisterVar(&cv_abilitydirection[1]); + CV_RegisterVar(&cv_cam_turnfacing[0]); + CV_RegisterVar(&cv_cam_turnfacing[1]); + CV_RegisterVar(&cv_cam_turnfacingability[0]); + CV_RegisterVar(&cv_cam_turnfacingability[1]); + CV_RegisterVar(&cv_cam_turnfacinginput[0]); + CV_RegisterVar(&cv_cam_turnfacinginput[1]); // s_sound.c CV_RegisterVar(&cv_soundvolume); diff --git a/src/g_game.c b/src/g_game.c index 598f328aa..c55058b99 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -399,6 +399,19 @@ consvar_t cv_abilitydirection[2] = { {"abilitydirection", "Movement", CV_SAVE, directionchar_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"abilitydirection2", "Movement", CV_SAVE, directionchar_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; +static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; +consvar_t cv_cam_turnfacing[2] = { + {"cam_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; +consvar_t cv_cam_turnfacingability[2] = { + {"cam_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; +consvar_t cv_cam_turnfacinginput[2] = { + {"cam_turnfacinginput", "0.15", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacinginput", "0.15", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; typedef enum { @@ -1133,7 +1146,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { if (turnright) cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); - else if (turnleft) + if (turnleft) cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]); if (analogjoystickmove && axis != 0) @@ -1360,6 +1373,15 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) *myangle += (cmd->angleturn<<16); cmd->angleturn = (INT16)(*myangle >> 16); + // Adjust camera angle by player input + if (!forcestrafe && !turnheld[forplayer] && !player->climbing) + { + fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar + + if (camadjustfactor) + *myangle -= cmd->sidemove * 50 * camadjustfactor; + } + if (abilitydirection && !player->climbing && !forcestrafe) { if (cmd->forwardmove || cmd->sidemove) @@ -1375,6 +1397,25 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else cmd->angleturn = (player->drawangle>>16); } + + // Adjust camera angle to face player direction, depending on circumstances + // Nothing happens if cam left/right are held, so you can hold both to lock the camera in one direction + if (!forcestrafe && !turnheld[forplayer]) + { + fixed_t camadjustfactor; + + if (player->climbing || player->pflags & (PF_GLIDING|PF_STARTDASH)) + camadjustfactor = cv_cam_turnfacingability[forplayer].value; + else + camadjustfactor = cv_cam_turnfacing[forplayer].value; + + if (camadjustfactor) + { + INT32 anglediff = player->drawangle - *myangle; + + *myangle += FixedMul(anglediff, camadjustfactor); + } + } } //Reset away view if a command is given. diff --git a/src/g_game.h b/src/g_game.h index 86bcf3d59..ea2098f35 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -77,7 +77,7 @@ extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; // hi here's some new controls -extern consvar_t cv_abilitydirection[2]; +extern consvar_t cv_abilitydirection[2], cv_cam_turnfacing[2], cv_cam_turnfacingability[2], cv_cam_turnfacinginput[2]; // mouseaiming (looking up/down with the mouse or keyboard) #define KB_LOOKSPEED (1<<25) diff --git a/src/p_user.c b/src/p_user.c index ea42a2c36..21bc45502 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5350,6 +5350,12 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->pflags &= ~(PF_SPINNING|PF_STARTDASH); player->pflags |= PF_THOKKED; + + // Change localangle to match? + if (player == &players[consoleplayer] && cv_cam_turnfacingability[0].value > 0) + localangle = player->mo->angle; + else if (player == &players[secondarydisplayplayer] && cv_cam_turnfacingability[1].value > 0) + localangle2 = player->mo->angle; } break; From ebd2861593a0e1f1a5262dd0edfbba1488883b03 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 14:43:25 -0600 Subject: [PATCH 008/126] Add menu options for new camera controls Crank everything down to zero and set ability direction to "Camera", and you're back to base 2.2 behavior. --- src/m_menu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index e367041e0..71d5b1bfb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1035,6 +1035,7 @@ static menuitem_t OP_P1ControlsMenu[] = //{IT_STRING | IT_CVAR, NULL, "Analog Control", &cv_useranalog, 100}, {IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar, 70}, {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake, 80}, + {IT_STRING | IT_CVAR, NULL, "Ability angle", &cv_abilitydirection[0], 90}, }; static menuitem_t OP_P2ControlsMenu[] = @@ -1048,6 +1049,7 @@ static menuitem_t OP_P2ControlsMenu[] = //{IT_STRING | IT_CVAR, NULL, "Analog Control", &cv_useranalog2, 100}, {IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar2, 70}, {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake2, 80}, + {IT_STRING | IT_CVAR, NULL, "Ability angle", &cv_abilitydirection[1], 90}, }; static menuitem_t OP_ChangeControlsMenu[] = @@ -1180,7 +1182,11 @@ static menuitem_t OP_CameraOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 70}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 80}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 100}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[0], 100}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 110}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 120}, + + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 140}, }; static menuitem_t OP_Camera2OptionsMenu[] = @@ -1194,7 +1200,11 @@ static menuitem_t OP_Camera2OptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 70}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 80}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 100}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 100}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 110}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 120}, + + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 140}, }; static menuitem_t OP_VideoOptionsMenu[] = From eee0d42b1f4de4c5c72512268ca2c37eb6e09261 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 15:05:44 -0600 Subject: [PATCH 009/126] Make first-person and directionchar-off work as expected --- src/g_game.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index c55058b99..629f6b9c1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1374,7 +1374,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(*myangle >> 16); // Adjust camera angle by player input - if (!forcestrafe && !turnheld[forplayer] && !player->climbing) + if (!forcestrafe && camera.chase && !turnheld[forplayer] && !player->climbing) { fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar @@ -1382,7 +1382,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) *myangle -= cmd->sidemove * 50 * camadjustfactor; } - if (abilitydirection && !player->climbing && !forcestrafe) + if (abilitydirection && camera.chase && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR)) { if (cmd->forwardmove || cmd->sidemove) { @@ -1400,7 +1400,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // Adjust camera angle to face player direction, depending on circumstances // Nothing happens if cam left/right are held, so you can hold both to lock the camera in one direction - if (!forcestrafe && !turnheld[forplayer]) + if (!forcestrafe && camera.chase && !turnheld[forplayer]) { fixed_t camadjustfactor; From c94d7895dfbe067acc4f1199be552f4ac888a212 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 15:17:46 -0600 Subject: [PATCH 010/126] Make cam_rotspeed affect non-mouse turn speed 10 remains the default and is vanilla behavior. --- src/g_game.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 629f6b9c1..d300fb80d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1154,6 +1154,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // JOYAXISRANGE should be 1023 (divide by 1024) cmd->angleturn = (INT16)(cmd->angleturn - ((axis * angleturn[1]) >> 10)); // ANALOG! } + + // Make rotspeed affect turning speed :) + cmd->angleturn = (cmd->angleturn * (ssplayer == 1 ? cv_cam_rotspeed.value : cv_cam2_rotspeed.value)) / 10; } axis = PlayerJoyAxis(ssplayer, AXISSTRAFE); From 575b5027e8afa312ce6c7323f9b64a965cb22bed Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 15:22:51 -0600 Subject: [PATCH 011/126] Don't snap thok if the player is holding a camera control --- src/p_user.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 21bc45502..b15531055 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -42,6 +42,8 @@ #include "b_bot.h" // Objectplace #include "m_cheat.h" +// Thok camera snap (ctrl-f "chalupa") +#include "g_input.h" #ifdef HW3SOUND #include "hardware/hw3sound.h" @@ -5351,10 +5353,10 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->pflags &= ~(PF_SPINNING|PF_STARTDASH); player->pflags |= PF_THOKKED; - // Change localangle to match? - if (player == &players[consoleplayer] && cv_cam_turnfacingability[0].value > 0) + // Change localangle to match? (P.S. chalupa) + if (player == &players[consoleplayer] && cv_cam_turnfacingability[0].value > 0 && !(PLAYER1INPUTDOWN(gc_turnleft) || PLAYER1INPUTDOWN(gc_turnright))) localangle = player->mo->angle; - else if (player == &players[secondarydisplayplayer] && cv_cam_turnfacingability[1].value > 0) + else if (player == &players[secondarydisplayplayer] && cv_cam_turnfacingability[1].value > 0 && !(PLAYER2INPUTDOWN(gc_turnleft) || PLAYER2INPUTDOWN(gc_turnright))) localangle2 = player->mo->angle; } break; From 4784eb68fa2916df99c0cae3f6fb77c0b9fbd6f1 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 15:49:10 -0600 Subject: [PATCH 012/126] Don't do thok camera snap in replays --- src/p_user.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index b15531055..3b8b64e04 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5354,10 +5354,13 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->pflags |= PF_THOKKED; // Change localangle to match? (P.S. chalupa) - if (player == &players[consoleplayer] && cv_cam_turnfacingability[0].value > 0 && !(PLAYER1INPUTDOWN(gc_turnleft) || PLAYER1INPUTDOWN(gc_turnright))) - localangle = player->mo->angle; - else if (player == &players[secondarydisplayplayer] && cv_cam_turnfacingability[1].value > 0 && !(PLAYER2INPUTDOWN(gc_turnleft) || PLAYER2INPUTDOWN(gc_turnright))) - localangle2 = player->mo->angle; + if (!demoplayback) + { + if (player == &players[consoleplayer] && cv_cam_turnfacingability[0].value > 0 && !(PLAYER1INPUTDOWN(gc_turnleft) || PLAYER1INPUTDOWN(gc_turnright))) + localangle = player->mo->angle; + else if (player == &players[secondarydisplayplayer] && cv_cam_turnfacingability[1].value > 0 && !(PLAYER2INPUTDOWN(gc_turnleft) || PLAYER2INPUTDOWN(gc_turnright))) + localangle2 = player->mo->angle; + } } break; From e92d7eca8e5c9ab2f62a6b40ac3ec7e7d78bd685 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 15:54:16 -0600 Subject: [PATCH 013/126] Shift camera sideways toward player angle --- src/d_netcmd.c | 2 ++ src/g_game.c | 4 ++++ src/g_game.h | 2 +- src/m_menu.c | 14 ++++++++------ src/p_user.c | 24 ++++++++++++++++++++++-- 5 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 49d3d060c..24df649fc 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -826,6 +826,8 @@ void D_RegisterClientCommands(void) // hi here's some new controls CV_RegisterVar(&cv_abilitydirection[0]); CV_RegisterVar(&cv_abilitydirection[1]); + CV_RegisterVar(&cv_cam_shiftfacing[0]); + CV_RegisterVar(&cv_cam_shiftfacing[1]); CV_RegisterVar(&cv_cam_turnfacing[0]); CV_RegisterVar(&cv_cam_turnfacing[1]); CV_RegisterVar(&cv_cam_turnfacingability[0]); diff --git a/src/g_game.c b/src/g_game.c index d300fb80d..2d44c8e00 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -400,6 +400,10 @@ consvar_t cv_abilitydirection[2] = { {"abilitydirection2", "Movement", CV_SAVE, directionchar_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; +consvar_t cv_cam_shiftfacing[2] = { + {"cam_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; consvar_t cv_cam_turnfacing[2] = { {"cam_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam2_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, diff --git a/src/g_game.h b/src/g_game.h index ea2098f35..ea2cd1694 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -77,7 +77,7 @@ extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; // hi here's some new controls -extern consvar_t cv_abilitydirection[2], cv_cam_turnfacing[2], cv_cam_turnfacingability[2], cv_cam_turnfacinginput[2]; +extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacing[2], cv_cam_turnfacingability[2], cv_cam_turnfacinginput[2]; // mouseaiming (looking up/down with the mouse or keyboard) #define KB_LOOKSPEED (1<<25) diff --git a/src/m_menu.c b/src/m_menu.c index 71d5b1bfb..4ae2b7036 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1182,9 +1182,10 @@ static menuitem_t OP_CameraOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 70}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 80}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[0], 100}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 110}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 120}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[0], 100}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[0], 110}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 120}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 130}, {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 140}, }; @@ -1200,9 +1201,10 @@ static menuitem_t OP_Camera2OptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 70}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 80}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 100}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 110}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 120}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[1], 100}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 110}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 120}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 130}, {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 140}, }; diff --git a/src/p_user.c b/src/p_user.c index 3b8b64e04..0a3636884 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9677,6 +9677,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall subsector_t *newsubsec; fixed_t f1, f2; + static fixed_t camsideshift[2] = {0, 0}; + fixed_t shiftx = 0, shifty = 0; + // We probably shouldn't move the camera if there is no player or player mobj somehow if (!player || !player->mo) return true; @@ -9882,6 +9885,20 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } } + if (cv_abilitydirection[(thiscam == &camera) ? 0 : 1].value) + { + // Shift the camera slightly to the sides depending on the player facing direction + UINT8 forplayer = (thiscam == &camera) ? 0 : 1; + fixed_t shift = FixedMul(FINESINE((player->drawangle - angle) >> ANGLETOFINESHIFT), cv_cam_shiftfacing[forplayer].value); + + shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3)); + camsideshift[forplayer] = shift; + + shift = FixedMul(shift, camdist); + shiftx = -FixedMul(FINESINE(angle>>ANGLETOFINESHIFT), shift); + shifty = FixedMul(FINECOSINE(angle>>ANGLETOFINESHIFT), shift); + } + // sets ideal cam pos if (twodlevel || (mo->flags2 & MF2_TWOD)) dist = 480<x + FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); - viewpointy = mo->y + FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); + viewpointx = mo->x + shiftx + FixedMul(FINECOSINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); + viewpointy = mo->y + shifty + FixedMul(FINESINE((angle>>ANGLETOFINESHIFT) & FINEMASK), dist); } if (!camstill && !resetcalled && !paused) @@ -10270,6 +10287,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } else thiscam->momz = FixedMul(z - thiscam->z, camspeed); + + thiscam->momx += FixedMul(shiftx, camspeed); + thiscam->momy += FixedMul(shifty, camspeed); } // compute aming to look the viewed point From a30623e4ed4d16e6735267534b07df2e544386f1 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 15:54:37 -0600 Subject: [PATCH 014/126] Default to no turn-facing since it looks like controller drift --- src/g_game.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 2d44c8e00..5f34846b6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -405,8 +405,8 @@ consvar_t cv_cam_shiftfacing[2] = { {"cam2_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacing[2] = { - {"cam_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacingchar", "0.002", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam_turnfacingchar", "0.0", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingchar", "0.0", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacingability[2] = { {"cam_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, From 0cad5021a99f0bfa3f742ef324d510cfb3bb93ab Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 18:26:20 -0600 Subject: [PATCH 015/126] Make input turn slow down when moving slowly --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 5f34846b6..f5bc56e1c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1386,7 +1386,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar if (camadjustfactor) - *myangle -= cmd->sidemove * 50 * camadjustfactor; + *myangle -= cmd->sidemove * min(50, player->speed / (FRACUNIT/7)) * camadjustfactor; } if (abilitydirection && camera.chase && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR)) From c99b137298c7d3530b6039f68038459fdd5a261a Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 8 Dec 2019 20:47:11 -0600 Subject: [PATCH 016/126] Fix abilitydirection camera breaking minecarts --- src/g_game.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index f5bc56e1c..b6d765693 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1381,7 +1381,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(*myangle >> 16); // Adjust camera angle by player input - if (!forcestrafe && camera.chase && !turnheld[forplayer] && !player->climbing) + if (!forcestrafe && camera.chase && !turnheld[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar @@ -1389,7 +1389,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) *myangle -= cmd->sidemove * min(50, player->speed / (FRACUNIT/7)) * camadjustfactor; } - if (abilitydirection && camera.chase && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR)) + if (abilitydirection && camera.chase && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) { if (cmd->forwardmove || cmd->sidemove) { @@ -1407,7 +1407,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // Adjust camera angle to face player direction, depending on circumstances // Nothing happens if cam left/right are held, so you can hold both to lock the camera in one direction - if (!forcestrafe && camera.chase && !turnheld[forplayer]) + if (!forcestrafe && camera.chase && !turnheld[forplayer] && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor; From e4626e93965cb756ddf91fc7433ee889d248036b Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 9 Dec 2019 20:21:32 -0600 Subject: [PATCH 017/126] Lock camera behind player when holding cam reset This also disables abilitydirection movement temporarily. --- src/g_game.c | 18 +++++++++++------- src/g_game.h | 2 ++ src/p_user.c | 17 +++++++++++++++-- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index b6d765693..13396a3a0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1006,6 +1006,7 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {25<>16, 50<>16}; // faster! static fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn +boolean ticcmd_resetdown[2]; // don't cam reset every frame void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { boolean forcestrafe = false; @@ -1024,7 +1025,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) static INT32 turnheld[2]; // for accelerative turning static boolean keyboard_look[2]; // true if lookup/down using keyboard - static boolean resetdown[2]; // don't cam reset every frame static boolean joyaiming[2]; // check the last frame's value if we need to reset the camera UINT8 forplayer = ssplayer-1; @@ -1244,12 +1244,16 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (PLAYERINPUTDOWN(ssplayer, gc_camreset)) { - if (camera.chase && !resetdown[forplayer]) + if (camera.chase && !ticcmd_resetdown[forplayer]) + { + ticcmd_resetdown[forplayer] = true; P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], &camera); - resetdown[forplayer] = true; + } + else + ticcmd_resetdown[forplayer] = true; } else - resetdown[forplayer] = false; + ticcmd_resetdown[forplayer] = false; // jump button axis = PlayerJoyAxis(ssplayer, AXISJUMP); @@ -1381,7 +1385,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(*myangle >> 16); // Adjust camera angle by player input - if (!forcestrafe && camera.chase && !turnheld[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) + if (!forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_resetdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar @@ -1389,7 +1393,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) *myangle -= cmd->sidemove * min(50, player->speed / (FRACUNIT/7)) * camadjustfactor; } - if (abilitydirection && camera.chase && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) + if (abilitydirection && camera.chase && !ticcmd_resetdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) { if (cmd->forwardmove || cmd->sidemove) { @@ -1407,7 +1411,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // Adjust camera angle to face player direction, depending on circumstances // Nothing happens if cam left/right are held, so you can hold both to lock the camera in one direction - if (!forcestrafe && camera.chase && !turnheld[forplayer] && player->powers[pw_carry] != CR_MINECART) + if (!forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_resetdown[forplayer] && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor; diff --git a/src/g_game.h b/src/g_game.h index ea2cd1694..2a030a49d 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -86,6 +86,8 @@ extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacin // build an internal map name MAPxx from map number const char *G_BuildMapName(INT32 map); + +extern boolean ticcmd_resetdown[2]; // don't cam reset every frame void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer); // copy ticcmd_t to and fro the normal way diff --git a/src/p_user.c b/src/p_user.c index 0a3636884..e9297b667 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9651,7 +9651,17 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->y = y; thiscam->z = z; - if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value)) + if (thiscam == &camera && cv_abilitydirection[0].value && ticcmd_resetdown[0]) + { + localangle = player->mo->angle; + localaiming = thiscam->aiming = 0; + } + else if (thiscam == &camera2 && cv_abilitydirection[1].value && ticcmd_resetdown[1]) + { + localangle2 = player->mo->angle; + localaiming2 = thiscam->aiming = 0; + } + else if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value)) && !(thiscam == &camera2 && (cv_cam2_still.value || cv_analog2.value))) { thiscam->angle = player->mo->angle; @@ -9891,7 +9901,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall UINT8 forplayer = (thiscam == &camera) ? 0 : 1; fixed_t shift = FixedMul(FINESINE((player->drawangle - angle) >> ANGLETOFINESHIFT), cv_cam_shiftfacing[forplayer].value); - shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3)); + if (ticcmd_resetdown[(thiscam == &camera) ? 0 : 1]) + shift = FixedMul(camsideshift[forplayer], FRACUNIT-camspeed); + else + shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3)); camsideshift[forplayer] = shift; shift = FixedMul(shift, camdist); From 27996ada0464f7e1f5331fc38361d1e0d758708d Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 9 Dec 2019 20:26:12 -0600 Subject: [PATCH 018/126] Scale down turn values (and increase defaults to compensate) This allows more granularity in menu sliders while limiting the maximums to reasonable amounts. --- src/g_game.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 13396a3a0..6f5ca6383 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -409,12 +409,12 @@ consvar_t cv_cam_turnfacing[2] = { {"cam2_turnfacingchar", "0.0", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacingability[2] = { - {"cam_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam_turnfacingability", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingability", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacinginput[2] = { - {"cam_turnfacinginput", "0.15", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacinginput", "0.15", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam_turnfacinginput", "0.375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacinginput", "0.375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; typedef enum @@ -1390,7 +1390,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar if (camadjustfactor) - *myangle -= cmd->sidemove * min(50, player->speed / (FRACUNIT/7)) * camadjustfactor; + *myangle -= cmd->sidemove * min(20, player->speed / (FRACUNIT/7)) * camadjustfactor; } if (abilitydirection && camera.chase && !ticcmd_resetdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) @@ -1416,9 +1416,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) fixed_t camadjustfactor; if (player->climbing || player->pflags & (PF_GLIDING|PF_STARTDASH)) - camadjustfactor = cv_cam_turnfacingability[forplayer].value; + camadjustfactor = cv_cam_turnfacingability[forplayer].value/2; else - camadjustfactor = cv_cam_turnfacing[forplayer].value; + camadjustfactor = cv_cam_turnfacing[forplayer].value/8; if (camadjustfactor) { From 3735134948e27b84fe99f4fcf39669870db9456d Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 9 Dec 2019 20:31:19 -0600 Subject: [PATCH 019/126] Fix smoothing into input-based camera rotation --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 6f5ca6383..95e612b28 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1390,7 +1390,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar if (camadjustfactor) - *myangle -= cmd->sidemove * min(20, player->speed / (FRACUNIT/7)) * camadjustfactor; + *myangle -= cmd->sidemove * min(20, player->speed / FRACUNIT) * camadjustfactor; } if (abilitydirection && camera.chase && !ticcmd_resetdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) From 834a3bf3346b8f71518ae5330e1c3d0658d1c170 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 9 Dec 2019 20:39:05 -0600 Subject: [PATCH 020/126] Port deadzone configuration from Kart I don't feel like getting out my gamepad, so I'll trust that this works. --- src/d_netcmd.c | 2 ++ src/g_game.c | 6 ++++-- src/g_game.h | 4 ++-- src/m_menu.c | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 24df649fc..9c19fee5f 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -774,6 +774,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_fireaxis2); CV_RegisterVar(&cv_firenaxis); CV_RegisterVar(&cv_firenaxis2); + CV_RegisterVar(&cv_deadzone); + CV_RegisterVar(&cv_deadzone2); // filesrch.c CV_RegisterVar(&cv_addons_option); diff --git a/src/g_game.c b/src/g_game.c index 95e612b28..4cd527291 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -439,6 +439,7 @@ consvar_t cv_jumpaxis = {"joyaxis_jump", "None", CV_SAVE, joyaxis_cons_t, NULL, consvar_t cv_spinaxis = {"joyaxis_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_fireaxis = {"joyaxis_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_firenaxis = {"joyaxis_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_deadzone = {"joy_deadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_turnaxis2 = {"joyaxis2_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_moveaxis2 = {"joyaxis2_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -448,6 +449,7 @@ consvar_t cv_jumpaxis2 = {"joyaxis2_jump", "None", CV_SAVE, joyaxis_cons_t, NULL consvar_t cv_spinaxis2 = {"joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_fireaxis2 = {"joyaxis2_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_firenaxis2 = {"joyaxis2_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_deadzone2 = {"joy_deadzone2", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; #ifdef SEENAMES player_t *seenplayer; // player we're aiming at right now @@ -907,7 +909,7 @@ static INT32 JoyAxis(axis_input_e axissel) retaxis = +JOYAXISRANGE; if (!Joystick.bGamepadStyle && axissel < AXISDEAD) { - const INT32 jdeadzone = JOYAXISRANGE/4; + const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_deadzone.value) >> FRACBITS; if (-jdeadzone < retaxis && retaxis < jdeadzone) return 0; } @@ -980,7 +982,7 @@ static INT32 Joy2Axis(axis_input_e axissel) retaxis = +JOYAXISRANGE; if (!Joystick2.bGamepadStyle && axissel < AXISDEAD) { - const INT32 jdeadzone = JOYAXISRANGE/4; + const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_deadzone2.value) >> FRACBITS; if (-jdeadzone < retaxis && retaxis < jdeadzone) return 0; } diff --git a/src/g_game.h b/src/g_game.h index 2a030a49d..7da31f259 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -72,8 +72,8 @@ extern consvar_t cv_useranalog, cv_useranalog2; extern consvar_t cv_analog, cv_analog2; extern consvar_t cv_directionchar, cv_directionchar2; extern consvar_t cv_autobrake, cv_autobrake2; -extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis; -extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2; +extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis,cv_deadzone; +extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2,cv_deadzone2; extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; // hi here's some new controls diff --git a/src/m_menu.c b/src/m_menu.c index 4ae2b7036..5f65c894b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1121,6 +1121,7 @@ static menuitem_t OP_Joystick1Menu[] = {IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook, 120}, {IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook, 130}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Deadzone", &cv_deadzone, 140}, }; static menuitem_t OP_Joystick2Menu[] = @@ -1137,6 +1138,7 @@ static menuitem_t OP_Joystick2Menu[] = {IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook2,120}, {IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook2, 130}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Deadzone", &cv_deadzone2,140}, }; static menuitem_t OP_JoystickSetMenu[1+MAX_JOYSTICKS]; From b5f7f5f7326300fc160ee0354c6a50451011b0be Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 9 Dec 2019 22:06:50 -0600 Subject: [PATCH 021/126] Replace direction toggles with a playstyle selection It's kinda ugly right now... --- src/m_menu.c | 249 ++++++++++++++++++++++++++++++++++++++++++++++----- src/m_menu.h | 2 + src/p_user.c | 2 +- 3 files changed, 230 insertions(+), 23 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 5f65c894b..093d0b5ee 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -298,11 +298,14 @@ menu_t OP_MPControlsDef, OP_MiscControlsDef; menu_t OP_P1ControlsDef, OP_P2ControlsDef, OP_MouseOptionsDef; menu_t OP_Mouse2OptionsDef, OP_Joystick1Def, OP_Joystick2Def; menu_t OP_CameraOptionsDef, OP_Camera2OptionsDef; +menu_t OP_PlaystyleDef; static void M_VideoModeMenu(INT32 choice); static void M_Setup1PControlsMenu(INT32 choice); static void M_Setup2PControlsMenu(INT32 choice); static void M_Setup1PJoystickMenu(INT32 choice); static void M_Setup2PJoystickMenu(INT32 choice); +static void M_Setup1PPlaystyleMenu(INT32 choice); +static void M_Setup2PPlaystyleMenu(INT32 choice); static void M_AssignJoystick(INT32 choice); static void M_ChangeControl(INT32 choice); @@ -347,6 +350,8 @@ static void M_DrawLevelStats(void); static void M_DrawTimeAttackMenu(void); static void M_DrawNightsAttackMenu(void); static void M_DrawSetupChoosePlayerMenu(void); +static void M_DrawControlsDefMenu(void); +static void M_DrawPlaystyleMenu(void); static void M_DrawControl(void); static void M_DrawMainVideoMenu(void); static void M_DrawVideoMode(void); @@ -375,6 +380,7 @@ static void M_HandleSoundTest(INT32 choice); static void M_HandleImageDef(INT32 choice); static void M_HandleLoadSave(INT32 choice); static void M_HandleLevelStats(INT32 choice); +static void M_HandlePlaystyleMenu(INT32 choice); #ifndef NONET static boolean M_CancelConnect(void); static void M_HandleConnectIP(INT32 choice); @@ -1032,10 +1038,10 @@ static menuitem_t OP_P1ControlsMenu[] = {IT_SUBMENU | IT_STRING, NULL, "Camera Options...", &OP_CameraOptionsDef, 50}, - //{IT_STRING | IT_CVAR, NULL, "Analog Control", &cv_useranalog, 100}, - {IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar, 70}, - {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake, 80}, - {IT_STRING | IT_CVAR, NULL, "Ability angle", &cv_abilitydirection[0], 90}, + //{IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar, 70}, + {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake, 70}, + {IT_CALL | IT_STRING, NULL, "Play Style...", M_Setup1PPlaystyleMenu, 80}, + //{IT_STRING | IT_CVAR, NULL, "Ability angle", &cv_abilitydirection[0], 90}, }; static menuitem_t OP_P2ControlsMenu[] = @@ -1046,10 +1052,10 @@ static menuitem_t OP_P2ControlsMenu[] = {IT_SUBMENU | IT_STRING, NULL, "Camera Options...", &OP_Camera2OptionsDef, 50}, - //{IT_STRING | IT_CVAR, NULL, "Analog Control", &cv_useranalog2, 100}, - {IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar2, 70}, - {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake2, 80}, - {IT_STRING | IT_CVAR, NULL, "Ability angle", &cv_abilitydirection[1], 90}, + //{IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar2, 70}, + {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake2, 70}, + {IT_CALL | IT_STRING, NULL, "Play Style...", M_Setup2PPlaystyleMenu, 80}, + //{IT_STRING | IT_CVAR, NULL, "Ability angle", &cv_abilitydirection[1], 90}, }; static menuitem_t OP_ChangeControlsMenu[] = @@ -1183,13 +1189,14 @@ static menuitem_t OP_CameraOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 60}, {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 70}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 80}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam_rotspeed, 90}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[0], 100}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[0], 110}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 120}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 130}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[0], 110}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[0], 120}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 130}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 140}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 140}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 160}, }; static menuitem_t OP_Camera2OptionsMenu[] = @@ -1202,13 +1209,14 @@ static menuitem_t OP_Camera2OptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 60}, {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 70}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 80}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam2_rotspeed, 90}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[1], 100}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 110}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 120}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 130}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[1], 110}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 120}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 130}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 140}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 140}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 160}, }; static menuitem_t OP_VideoOptionsMenu[] = @@ -1924,12 +1932,24 @@ menu_t OP_MainDef = DEFAULTMENUSTYLE( menu_t OP_ChangeControlsDef = CONTROLMENUSTYLE( MN_OP_MAIN + (MN_OP_CHANGECONTROLS << 12), // second level (<<6) set on runtime OP_ChangeControlsMenu, &OP_MainDef); -menu_t OP_P1ControlsDef = DEFAULTMENUSTYLE( + +menu_t OP_P1ControlsDef = { MN_OP_MAIN + (MN_OP_P1CONTROLS << 6), - "M_CONTRO", OP_P1ControlsMenu, &OP_MainDef, 50, 30); -menu_t OP_P2ControlsDef = DEFAULTMENUSTYLE( + "M_CONTRO", + sizeof(OP_P1ControlsMenu)/sizeof(menuitem_t), + &OP_MainDef, + OP_P1ControlsMenu, + M_DrawControlsDefMenu, + 50, 30, 0, NULL}; +menu_t OP_P2ControlsDef = { MN_OP_MAIN + (MN_OP_P2CONTROLS << 6), - "M_CONTRO", OP_P2ControlsMenu, &OP_MainDef, 50, 30); + "M_CONTRO", + sizeof(OP_P2ControlsMenu)/sizeof(menuitem_t), + &OP_MainDef, + OP_P2ControlsMenu, + M_DrawControlsDefMenu, + 50, 30, 0, NULL}; + menu_t OP_MouseOptionsDef = DEFAULTMENUSTYLE( MN_OP_MAIN + (MN_OP_P1CONTROLS << 6) + (MN_OP_P1MOUSE << 12), "M_CONTRO", OP_MouseOptionsMenu, &OP_P1ControlsDef, 35, 30); @@ -1961,6 +1981,18 @@ menu_t OP_Camera2OptionsDef = DEFAULTMENUSTYLE( MN_OP_MAIN + (MN_OP_P2CONTROLS << 6) + (MN_OP_P2CAMERA << 12), "M_CONTRO", OP_Camera2OptionsMenu, &OP_P2ControlsDef, 35, 30); +static menuitem_t OP_PlaystyleMenu[] = {{IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandlePlaystyleMenu, 0}}; + +menu_t OP_PlaystyleDef = { + MN_OP_MAIN + (MN_OP_P1CONTROLS << 6) + (MN_OP_PLAYSTYLE << 12), + NULL, + 1, + &OP_P1ControlsDef, + OP_PlaystyleMenu, + M_DrawPlaystyleMenu, + 0, 0, 0, NULL +}; + menu_t OP_VideoOptionsDef = { @@ -4166,6 +4198,98 @@ static void M_DrawGenericMenu(void) } } +const char *PlaystyleNames[3] = {"Legacy", "Standard", "Simple"}; +const char *PlaystyleDesc[3] = { + // Legacy + "The play style used for\n" + "old-school SRB2.\n" + "\n" + "This play style is identical\n" + "to Standard, except that the\n" + "player always looks in the\n" + "direction of the camera." + , + + // Standard + "The default play style,\n" + "designed for full control\n" + "with a keyboard and mouse.\n" + "\n" + "The camera rotates only when\n" + "you tell it to. The player\n" + "looks in the direction they're\n" + "moving, but acts in the direction\n" + "the camera is facing.\n" + "\n" + "Mastery of this play style will\n" + "open up the highest level of play!" + , + + // Simple + "A play style designed for\n" + "gamepads and hassle-free play.\n" + "\n" + "The camera rotates automatically\n" + "as you move, and the player faces\n" + "and acts in the direction\n" + "they're moving.\n" + "\n" + "Hold \x82Reset Camera\x80 to lock the\n" + "camera behind the player!\n" +}; + +static void M_DrawControlsDefMenu(void) +{ + UINT8 opt = 0; + + M_DrawGenericMenu(); + + if (currentMenu == &OP_P1ControlsDef) + { + opt = (cv_abilitydirection[0].value ? 2 : cv_directionchar.value); + + if (opt == 2) + { + OP_CameraOptionsMenu[8].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; + OP_CameraOptionsMenu[9].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; + OP_CameraOptionsMenu[10].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; + OP_CameraOptionsMenu[11].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; + OP_CameraOptionsMenu[12].alphaKey = 160; + } + else + { + OP_CameraOptionsMenu[8].status = IT_DISABLED; + OP_CameraOptionsMenu[9].status = IT_DISABLED; + OP_CameraOptionsMenu[10].status = IT_DISABLED; + OP_CameraOptionsMenu[11].status = IT_DISABLED; + OP_CameraOptionsMenu[12].alphaKey = 110; + } + } + else + { + opt = (cv_abilitydirection[1].value ? 2 : cv_directionchar2.value); + + if (opt == 2) + { + OP_Camera2OptionsMenu[8].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; + OP_Camera2OptionsMenu[9].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; + OP_Camera2OptionsMenu[10].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; + OP_Camera2OptionsMenu[11].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; + OP_Camera2OptionsMenu[12].alphaKey = 160; + } + else + { + OP_Camera2OptionsMenu[8].status = IT_DISABLED; + OP_Camera2OptionsMenu[9].status = IT_DISABLED; + OP_Camera2OptionsMenu[10].status = IT_DISABLED; + OP_Camera2OptionsMenu[11].status = IT_DISABLED; + OP_Camera2OptionsMenu[12].alphaKey = 110; + } + } + + V_DrawRightAlignedString(BASEVIDWIDTH - currentMenu->x, currentMenu->y + 80, V_YELLOWMAP, PlaystyleNames[opt]); +} + #define scrollareaheight 72 // note that alphakey is multiplied by 2 for scrolling menus to allow greater usage in UINT8 range. @@ -11430,6 +11554,87 @@ static void M_ChangeControl(INT32 choice) M_StartMessage(tmp, M_ChangecontrolResponse, MM_EVENTHANDLER); } +static UINT8 playstyle_activeplayer = 0, playstyle_currentchoice = 0; + +static void M_Setup1PPlaystyleMenu(INT32 choice) +{ + (void)choice; + + playstyle_activeplayer = 0; + playstyle_currentchoice = (cv_abilitydirection[0].value ? 2 : cv_directionchar.value); + OP_PlaystyleDef.prevMenu = &OP_P1ControlsDef; + M_SetupNextMenu(&OP_PlaystyleDef); +} + +static void M_Setup2PPlaystyleMenu(INT32 choice) +{ + (void)choice; + + playstyle_activeplayer = 1; + playstyle_currentchoice = (cv_abilitydirection[1].value ? 2 : cv_directionchar2.value); + OP_PlaystyleDef.prevMenu = &OP_P2ControlsDef; + M_SetupNextMenu(&OP_PlaystyleDef); +} + +static void M_DrawPlaystyleMenu(void) +{ + size_t i; + + for (i = 0; i < 3; i++) + { + V_DrawCenteredString((i+1)*BASEVIDWIDTH/4, 20, (i == playstyle_currentchoice) ? V_YELLOWMAP : 0, PlaystyleNames[i]); + + if (i == playstyle_currentchoice) + { + V_DrawScaledPatch((i+1)*BASEVIDWIDTH/4 - 8, 10, 0, W_CachePatchName("M_CURSOR", PU_CACHE)); + V_DrawString(30, 50, V_ALLOWLOWERCASE, PlaystyleDesc[i]); + } + } +} + +static void M_HandlePlaystyleMenu(INT32 choice) +{ + switch (choice) + { + case KEY_ESCAPE: + case KEY_BACKSPACE: + M_SetupNextMenu(currentMenu->prevMenu); + break; + + case KEY_ENTER: + S_StartSound(NULL, sfx_menu1); + if (cv_abilitydirection[playstyle_activeplayer].value != (playstyle_currentchoice/2)) + { + if (cv_abilitydirection[playstyle_activeplayer].value) + { + CV_Set((playstyle_activeplayer ? &cv_cam2_dist : &cv_cam_dist), cv_cam_dist.defaultvalue); + CV_Set((playstyle_activeplayer ? &cv_cam2_height : &cv_cam_height), cv_cam_height.defaultvalue); + } + else + { + CV_SetValue((playstyle_activeplayer ? &cv_cam2_dist : &cv_cam_dist), 224); + CV_SetValue((playstyle_activeplayer ? &cv_cam2_height : &cv_cam_height), 50); + } + + CV_SetValue(&cv_abilitydirection[playstyle_activeplayer], playstyle_currentchoice/2); + } + CV_SetValue((playstyle_activeplayer ? &cv_directionchar2 : &cv_directionchar), playstyle_currentchoice ? 1 : 0); + + M_SetupNextMenu(currentMenu->prevMenu); + break; + + case KEY_LEFTARROW: + S_StartSound(NULL, sfx_menu1); + playstyle_currentchoice = (playstyle_currentchoice+2)%3; + break; + + case KEY_RIGHTARROW: + S_StartSound(NULL, sfx_menu1); + playstyle_currentchoice = (playstyle_currentchoice+1)%3; + break; + } +} + // =============== // VIDEO MODE MENU // =============== diff --git a/src/m_menu.h b/src/m_menu.h index ce9b422dc..09bf371cb 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -81,6 +81,8 @@ typedef enum MN_OP_P2JOYSTICK, MN_OP_P2CAMERA, + MN_OP_PLAYSTYLE, + MN_OP_VIDEO, MN_OP_VIDEOMODE, MN_OP_COLOR, diff --git a/src/p_user.c b/src/p_user.c index e9297b667..c0381c380 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9598,7 +9598,7 @@ static void CV_CamRotate2_OnChange(void) } 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 rotation_cons_t[] = {{1, "MIN"}, {25, "MAX"}, {0, NULL}}; static CV_PossibleValue_t CV_CamRotate[] = {{-720, "MIN"}, {720, "MAX"}, {0, NULL}}; consvar_t cv_cam_dist = {"cam_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; From 2a9819947eefec9b1d226a7d68dc51da7eabb38a Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 9 Dec 2019 22:09:58 -0600 Subject: [PATCH 022/126] Disable all new camera behavior if playstyle is not Simple --- src/g_game.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 4cd527291..654747da4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1387,7 +1387,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(*myangle >> 16); // Adjust camera angle by player input - if (!forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_resetdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) + if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_resetdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar @@ -1413,7 +1413,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // Adjust camera angle to face player direction, depending on circumstances // Nothing happens if cam left/right are held, so you can hold both to lock the camera in one direction - if (!forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_resetdown[forplayer] && player->powers[pw_carry] != CR_MINECART) + if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_resetdown[forplayer] && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor; From a3961efc4314b0870751530a26cbd0bc8dcb9513 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 9 Dec 2019 22:12:19 -0600 Subject: [PATCH 023/126] Draw crosshair in Simple mode while holding cam reset I think this gives extra indication that abilities face toward the camera now. --- src/hu_stuff.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 91a167a60..03489101d 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2194,10 +2194,10 @@ void HU_Drawer(void) return; // draw the crosshair, not when viewing demos nor with chasecam - if (!automapactive && cv_crosshair.value && !demoplayback && !camera.chase && !players[displayplayer].spectator) + if (!automapactive && cv_crosshair.value && !demoplayback && (!camera.chase || (cv_abilitydirection[0].value && ticcmd_resetdown[0])) && !players[displayplayer].spectator) HU_DrawCrosshair(); - if (!automapactive && cv_crosshair2.value && !demoplayback && !camera2.chase && !players[secondarydisplayplayer].spectator) + if (!automapactive && cv_crosshair2.value && !demoplayback && (!camera2.chase || (cv_abilitydirection[1].value && ticcmd_resetdown[1])) && !players[secondarydisplayplayer].spectator) HU_DrawCrosshair2(); // draw desynch text From 2fa1e750168fb4d4dbc9f55c50feaf788f2ca8c6 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 9 Dec 2019 22:45:34 -0600 Subject: [PATCH 024/126] I'm hilarious --- src/m_menu.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 093d0b5ee..5cde16712 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4198,8 +4198,8 @@ static void M_DrawGenericMenu(void) } } -const char *PlaystyleNames[3] = {"Legacy", "Standard", "Simple"}; -const char *PlaystyleDesc[3] = { +const char *PlaystyleNames[4] = {"Legacy", "Standard", "Simple", "Old Analog??"}; +const char *PlaystyleDesc[4] = { // Legacy "The play style used for\n" "old-school SRB2.\n" @@ -4236,6 +4236,18 @@ const char *PlaystyleDesc[3] = { "\n" "Hold \x82Reset Camera\x80 to lock the\n" "camera behind the player!\n" + , + + // Old Analog + "I see.\n" + "\n" + "You really liked the old analog mode,\n" + "so when 2.2 came out, you opened up\n" + "your config file and brought it back.\n" + "\n" + "That's absolutely valid, but I implore\n" + "you to try the new Simple play style\n" + "instead!" }; static void M_DrawControlsDefMenu(void) @@ -4246,7 +4258,7 @@ static void M_DrawControlsDefMenu(void) if (currentMenu == &OP_P1ControlsDef) { - opt = (cv_abilitydirection[0].value ? 2 : cv_directionchar.value); + opt = cv_useranalog.value ? 3 : (cv_abilitydirection[0].value ? 2 : cv_directionchar.value); if (opt == 2) { @@ -4267,7 +4279,7 @@ static void M_DrawControlsDefMenu(void) } else { - opt = (cv_abilitydirection[1].value ? 2 : cv_directionchar2.value); + opt = cv_useranalog2.value ? 3 : (cv_abilitydirection[1].value ? 2 : cv_directionchar2.value); if (opt == 2) { @@ -11561,7 +11573,7 @@ static void M_Setup1PPlaystyleMenu(INT32 choice) (void)choice; playstyle_activeplayer = 0; - playstyle_currentchoice = (cv_abilitydirection[0].value ? 2 : cv_directionchar.value); + playstyle_currentchoice = cv_useranalog.value ? 3 : (cv_abilitydirection[0].value ? 2 : cv_directionchar.value); OP_PlaystyleDef.prevMenu = &OP_P1ControlsDef; M_SetupNextMenu(&OP_PlaystyleDef); } @@ -11571,7 +11583,7 @@ static void M_Setup2PPlaystyleMenu(INT32 choice) (void)choice; playstyle_activeplayer = 1; - playstyle_currentchoice = (cv_abilitydirection[1].value ? 2 : cv_directionchar2.value); + playstyle_currentchoice = cv_useranalog2.value ? 3 : (cv_abilitydirection[1].value ? 2 : cv_directionchar2.value); OP_PlaystyleDef.prevMenu = &OP_P2ControlsDef; M_SetupNextMenu(&OP_PlaystyleDef); } @@ -11580,9 +11592,10 @@ static void M_DrawPlaystyleMenu(void) { size_t i; - for (i = 0; i < 3; i++) + for (i = 0; i < 4; i++) { - V_DrawCenteredString((i+1)*BASEVIDWIDTH/4, 20, (i == playstyle_currentchoice) ? V_YELLOWMAP : 0, PlaystyleNames[i]); + if (i != 3) + V_DrawCenteredString((i+1)*BASEVIDWIDTH/4, 20, (i == playstyle_currentchoice) ? V_YELLOWMAP : 0, PlaystyleNames[i]); if (i == playstyle_currentchoice) { @@ -11619,6 +11632,7 @@ static void M_HandlePlaystyleMenu(INT32 choice) CV_SetValue(&cv_abilitydirection[playstyle_activeplayer], playstyle_currentchoice/2); } CV_SetValue((playstyle_activeplayer ? &cv_directionchar2 : &cv_directionchar), playstyle_currentchoice ? 1 : 0); + CV_SetValue((playstyle_activeplayer ? &cv_useranalog2 : &cv_useranalog), 0); M_SetupNextMenu(currentMenu->prevMenu); break; From 08ab15b1b95d085448f42cd940d6fac02a904da7 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 10 Dec 2019 07:54:27 -0600 Subject: [PATCH 025/126] Disable thok camera snap --- src/p_user.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index c0381c380..c5d4e2846 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -5353,14 +5353,15 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) player->pflags &= ~(PF_SPINNING|PF_STARTDASH); player->pflags |= PF_THOKKED; - // Change localangle to match? (P.S. chalupa) - if (!demoplayback) + // Change localangle to match for simple controls? (P.S. chalupa) + // disabled because it seemed to disorient people and Z-targeting exists now + /*if (!demoplayback) { if (player == &players[consoleplayer] && cv_cam_turnfacingability[0].value > 0 && !(PLAYER1INPUTDOWN(gc_turnleft) || PLAYER1INPUTDOWN(gc_turnright))) localangle = player->mo->angle; else if (player == &players[secondarydisplayplayer] && cv_cam_turnfacingability[1].value > 0 && !(PLAYER2INPUTDOWN(gc_turnleft) || PLAYER2INPUTDOWN(gc_turnright))) localangle2 = player->mo->angle; - } + }*/ } break; From e1d4e2edcb79d1a72d4a5fbe6f8a555bcdc2c4aa Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 10 Dec 2019 07:58:50 -0600 Subject: [PATCH 026/126] Suspend directionchar while holding cam reset This should make it completely clear that thok will face the camera while it's held. --- src/g_game.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 654747da4..4f2258f6f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1250,13 +1250,21 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { ticcmd_resetdown[forplayer] = true; P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], &camera); + + if (abilitydirection) + CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 0); } else ticcmd_resetdown[forplayer] = true; } else + { ticcmd_resetdown[forplayer] = false; + if (abilitydirection) + CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 1); + } + // jump button axis = PlayerJoyAxis(ssplayer, AXISJUMP); if (PLAYERINPUTDOWN(ssplayer, gc_jump) || (usejoystick && axis > 0)) From 194e77a6f08cb194c64ecf5bf0d188b692b7b037 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 10 Dec 2019 08:07:41 -0600 Subject: [PATCH 027/126] Give spindash turn a separate slider --- src/d_netcmd.c | 2 ++ src/g_game.c | 8 +++++++- src/g_game.h | 3 ++- src/m_menu.c | 26 ++++++++++++++++---------- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 9c19fee5f..2b7bb3302 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -834,6 +834,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_cam_turnfacing[1]); CV_RegisterVar(&cv_cam_turnfacingability[0]); CV_RegisterVar(&cv_cam_turnfacingability[1]); + CV_RegisterVar(&cv_cam_turnfacingspindash[0]); + CV_RegisterVar(&cv_cam_turnfacingspindash[1]); CV_RegisterVar(&cv_cam_turnfacinginput[0]); CV_RegisterVar(&cv_cam_turnfacinginput[1]); diff --git a/src/g_game.c b/src/g_game.c index 4f2258f6f..25ed91f27 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -412,6 +412,10 @@ consvar_t cv_cam_turnfacingability[2] = { {"cam_turnfacingability", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam2_turnfacingability", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; +consvar_t cv_cam_turnfacingspindash[2] = { + {"cam_turnfacingspindash", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingspindash", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; consvar_t cv_cam_turnfacinginput[2] = { {"cam_turnfacinginput", "0.375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam2_turnfacinginput", "0.375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, @@ -1425,8 +1429,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { fixed_t camadjustfactor; - if (player->climbing || player->pflags & (PF_GLIDING|PF_STARTDASH)) + if (player->climbing || player->pflags & PF_GLIDING) camadjustfactor = cv_cam_turnfacingability[forplayer].value/2; + else if (player->pflags & PF_STARTDASH) + camadjustfactor = cv_cam_turnfacingspindash[forplayer].value/2; else camadjustfactor = cv_cam_turnfacing[forplayer].value/8; diff --git a/src/g_game.h b/src/g_game.h index 7da31f259..312e7e663 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -77,7 +77,8 @@ extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; // hi here's some new controls -extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacing[2], cv_cam_turnfacingability[2], cv_cam_turnfacinginput[2]; +extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacing[2], + cv_cam_turnfacingability[2], cv_cam_turnfacingspindash[2], cv_cam_turnfacinginput[2]; // mouseaiming (looking up/down with the mouse or keyboard) #define KB_LOOKSPEED (1<<25) diff --git a/src/m_menu.c b/src/m_menu.c index 5cde16712..6d317950d 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1191,9 +1191,10 @@ static menuitem_t OP_CameraOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 80}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam_rotspeed, 90}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[0], 110}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[0], 120}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 130}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[0], 100}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[0], 110}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 120}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[0], 130}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 140}, {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 160}, @@ -1211,9 +1212,10 @@ static menuitem_t OP_Camera2OptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 80}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam2_rotspeed, 90}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[1], 110}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 120}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 130}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[1], 100}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 110}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 120}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[1], 130}, {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 140}, {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 160}, @@ -4266,7 +4268,8 @@ static void M_DrawControlsDefMenu(void) OP_CameraOptionsMenu[9].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; OP_CameraOptionsMenu[10].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; OP_CameraOptionsMenu[11].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_CameraOptionsMenu[12].alphaKey = 160; + OP_CameraOptionsMenu[12].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; + OP_CameraOptionsMenu[13].alphaKey = 160; } else { @@ -4274,7 +4277,8 @@ static void M_DrawControlsDefMenu(void) OP_CameraOptionsMenu[9].status = IT_DISABLED; OP_CameraOptionsMenu[10].status = IT_DISABLED; OP_CameraOptionsMenu[11].status = IT_DISABLED; - OP_CameraOptionsMenu[12].alphaKey = 110; + OP_CameraOptionsMenu[12].status = IT_DISABLED; + OP_CameraOptionsMenu[13].alphaKey = 110; } } else @@ -4287,7 +4291,8 @@ static void M_DrawControlsDefMenu(void) OP_Camera2OptionsMenu[9].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; OP_Camera2OptionsMenu[10].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; OP_Camera2OptionsMenu[11].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_Camera2OptionsMenu[12].alphaKey = 160; + OP_Camera2OptionsMenu[12].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; + OP_Camera2OptionsMenu[13].alphaKey = 160; } else { @@ -4295,7 +4300,8 @@ static void M_DrawControlsDefMenu(void) OP_Camera2OptionsMenu[9].status = IT_DISABLED; OP_Camera2OptionsMenu[10].status = IT_DISABLED; OP_Camera2OptionsMenu[11].status = IT_DISABLED; - OP_Camera2OptionsMenu[12].alphaKey = 110; + OP_Camera2OptionsMenu[12].status = IT_DISABLED; + OP_Camera2OptionsMenu[13].alphaKey = 110; } } From 72cf5d9927a56f2af9315331db0b9ce4933e43f5 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 10 Dec 2019 08:17:41 -0600 Subject: [PATCH 028/126] Don't flood directionchar commands!!! --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 25ed91f27..394e9a09d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1261,7 +1261,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else ticcmd_resetdown[forplayer] = true; } - else + else if (ticcmd_resetdown[forplayer]) { ticcmd_resetdown[forplayer] = false; From 2b70b4bf36887854f3e08e70cdbb11863802f961 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 10 Dec 2019 09:08:30 -0600 Subject: [PATCH 029/126] TODO --- src/g_game.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 394e9a09d..a05812768 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1409,6 +1409,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (abilitydirection && camera.chase && !ticcmd_resetdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) { + ///@TODO This block of code is a hack to get the desired abilitydirection and player angle behaviors while remaining netplay-compatible with EXEs without those features. + // This has side effects like making F12 spectate look kind of weird, and making the input viewer inaccurate. + // In a perfect world, this will be removed and player behavior would use facing direction in a way that mimics this. + // But that's a lot more work and I want to A) have this out quickly B) be netplay-compatible. + if (cmd->forwardmove || cmd->sidemove) { angle_t controlangle = R_PointToAngle2(0, 0, cmd->forwardmove << FRACBITS, -cmd->sidemove << FRACBITS); From 054d51dac6fae047fb1f98e630642ad6beb35ce2 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 10 Dec 2019 21:14:50 -0600 Subject: [PATCH 030/126] Make input turn speed tween by lateral momentum, not total --- src/g_game.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index a05812768..dacf86bcf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1404,7 +1404,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar if (camadjustfactor) - *myangle -= cmd->sidemove * min(20, player->speed / FRACUNIT) * camadjustfactor; + { + fixed_t sine = FINESINE((R_PointToAngle2(0, 0, player->rmomx, player->rmomy) - localangle)>>ANGLETOFINESHIFT); + *myangle -= cmd->sidemove * min(20, FixedMul(player->speed, abs(sine)) / FRACUNIT) * camadjustfactor; + } } if (abilitydirection && camera.chase && !ticcmd_resetdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) From a89f8e91f792ef9c95e214cb1b746b4ec50269fb Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 10 Dec 2019 21:24:43 -0600 Subject: [PATCH 031/126] Change defaults and factors of simplecam options --- src/g_game.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index dacf86bcf..3126499cf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -409,16 +409,16 @@ consvar_t cv_cam_turnfacing[2] = { {"cam2_turnfacingchar", "0.0", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacingability[2] = { - {"cam_turnfacingability", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacingability", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam_turnfacingability", "0.0", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingability", "0.0", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacingspindash[2] = { {"cam_turnfacingspindash", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam2_turnfacingspindash", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacinginput[2] = { - {"cam_turnfacinginput", "0.375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacinginput", "0.375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam_turnfacinginput", "0.4375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacinginput", "0.4375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; typedef enum @@ -1438,9 +1438,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) fixed_t camadjustfactor; if (player->climbing || player->pflags & PF_GLIDING) - camadjustfactor = cv_cam_turnfacingability[forplayer].value/2; + camadjustfactor = cv_cam_turnfacingability[forplayer].value/4; else if (player->pflags & PF_STARTDASH) - camadjustfactor = cv_cam_turnfacingspindash[forplayer].value/2; + camadjustfactor = cv_cam_turnfacingspindash[forplayer].value/4; else camadjustfactor = cv_cam_turnfacing[forplayer].value/8; From cdf5287fccd1fe875b230acc2a224e350c7ef8f2 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 10 Dec 2019 21:34:57 -0600 Subject: [PATCH 032/126] Turn camera with strafe keys in camlock while charging spindash --- src/g_game.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 3126499cf..25f99c66f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1399,15 +1399,25 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(*myangle >> 16); // Adjust camera angle by player input - if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_resetdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) + if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && + !(ticcmd_resetdown[forplayer] && !(player->pflags & PF_STARTDASH)) + && !player->climbing && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar if (camadjustfactor) { fixed_t sine = FINESINE((R_PointToAngle2(0, 0, player->rmomx, player->rmomy) - localangle)>>ANGLETOFINESHIFT); - *myangle -= cmd->sidemove * min(20, FixedMul(player->speed, abs(sine)) / FRACUNIT) * camadjustfactor; + fixed_t factor = min(20, FixedMul(player->speed, abs(sine)) / FRACUNIT); + + if (ticcmd_resetdown[forplayer] && (player->pflags & PF_STARTDASH)) + factor = (ssplayer == 1 ? cv_cam_rotspeed.value : cv_cam2_rotspeed.value); // Turn while in startdash and locking camera + + *myangle -= cmd->sidemove * factor * camadjustfactor; } + + if (ticcmd_resetdown[forplayer] && (player->pflags & PF_STARTDASH)) + cmd->sidemove = 0; } if (abilitydirection && camera.chase && !ticcmd_resetdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) From 69b623e086f85c702aa48cc92e948571b2774157 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 10 Dec 2019 22:01:17 -0600 Subject: [PATCH 033/126] Add option to always turn with input while locked Uhhh also camera options scrolls now. --- src/d_netcmd.c | 2 ++ src/g_game.c | 15 +++++++--- src/g_game.h | 3 +- src/m_menu.c | 78 ++++++++++++++++++++++++++++---------------------- 4 files changed, 58 insertions(+), 40 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 2b7bb3302..512451b85 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -838,6 +838,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_cam_turnfacingspindash[1]); CV_RegisterVar(&cv_cam_turnfacinginput[0]); CV_RegisterVar(&cv_cam_turnfacinginput[1]); + CV_RegisterVar(&cv_cam_lockedinput[0]); + CV_RegisterVar(&cv_cam_lockedinput[1]); // s_sound.c CV_RegisterVar(&cv_soundvolume); diff --git a/src/g_game.c b/src/g_game.c index 25f99c66f..0ba7081fa 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -421,6 +421,13 @@ consvar_t cv_cam_turnfacinginput[2] = { {"cam2_turnfacinginput", "0.4375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; +static CV_PossibleValue_t lockedinput_cons_t[] = {{0, "Strafe"}, {1, "Turn Slow"}, {2, "Turn"}, {0, NULL}}; + +consvar_t cv_cam_lockedinput[2] = { + {"cam_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; + typedef enum { AXISNONE = 0, @@ -1400,7 +1407,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // Adjust camera angle by player input if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && - !(ticcmd_resetdown[forplayer] && !(player->pflags & PF_STARTDASH)) + !(ticcmd_resetdown[forplayer] && !(cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) && !player->climbing && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar @@ -1410,13 +1417,13 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) fixed_t sine = FINESINE((R_PointToAngle2(0, 0, player->rmomx, player->rmomy) - localangle)>>ANGLETOFINESHIFT); fixed_t factor = min(20, FixedMul(player->speed, abs(sine)) / FRACUNIT); - if (ticcmd_resetdown[forplayer] && (player->pflags & PF_STARTDASH)) - factor = (ssplayer == 1 ? cv_cam_rotspeed.value : cv_cam2_rotspeed.value); // Turn while in startdash and locking camera + if (ticcmd_resetdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) + factor = (ssplayer == 1 ? cv_cam_rotspeed.value : cv_cam2_rotspeed.value) * (cv_cam_lockedinput[forplayer].value ?: 1); // Turn while in startdash and locking camera *myangle -= cmd->sidemove * factor * camadjustfactor; } - if (ticcmd_resetdown[forplayer] && (player->pflags & PF_STARTDASH)) + if (ticcmd_resetdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) cmd->sidemove = 0; } diff --git a/src/g_game.h b/src/g_game.h index 312e7e663..2775382c9 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -78,7 +78,8 @@ extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_g // hi here's some new controls extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacing[2], - cv_cam_turnfacingability[2], cv_cam_turnfacingspindash[2], cv_cam_turnfacinginput[2]; + cv_cam_turnfacingability[2], cv_cam_turnfacingspindash[2], cv_cam_turnfacinginput[2], + cv_cam_lockedinput[2]; // mouseaiming (looking up/down with the mouse or keyboard) #define KB_LOOKSPEED (1<<25) diff --git a/src/m_menu.c b/src/m_menu.c index 6d317950d..668e6b3d6 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1181,44 +1181,46 @@ static menuitem_t OP_Mouse2OptionsMenu[] = static menuitem_t OP_CameraOptionsMenu[] = { - {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam , 10}, - {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam , 20}, - {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam_orbit , 30}, - {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 40}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam , 5}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam , 10}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam_orbit , 15}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 20}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 60}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 70}, - {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 80}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam_rotspeed, 90}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 30}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 35}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 40}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam_rotspeed, 45}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[0], 100}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[0], 110}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 120}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[0], 130}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 140}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[0], 55}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[0], 60}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 65}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[0], 70}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 75}, + {IT_STRING | IT_CVAR, NULL, "Locked movement", &cv_cam_lockedinput[0], 80}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 160}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 90}, }; static menuitem_t OP_Camera2OptionsMenu[] = { - {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam2 , 10}, - {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam2 , 20}, - {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam2_orbit , 30}, - {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 40}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam2 , 5}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam2 , 10}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam2_orbit , 15}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 20}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 60}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 70}, - {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 80}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam2_rotspeed, 90}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 30}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 35}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 40}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam2_rotspeed, 45}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[1], 100}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 110}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 120}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[1], 130}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 140}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[1], 55}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 60}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 65}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[1], 70}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 75}, + {IT_STRING | IT_CVAR, NULL, "Locked movement", &cv_cam_lockedinput[0], 80}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 160}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 90}, }; static menuitem_t OP_VideoOptionsMenu[] = @@ -1976,10 +1978,10 @@ menu_t OP_JoystickSetDef = 0, NULL }; -menu_t OP_CameraOptionsDef = DEFAULTMENUSTYLE( +menu_t OP_CameraOptionsDef = DEFAULTSCROLLMENUSTYLE( MN_OP_MAIN + (MN_OP_P1CONTROLS << 6) + (MN_OP_P1CAMERA << 12), "M_CONTRO", OP_CameraOptionsMenu, &OP_P1ControlsDef, 35, 30); -menu_t OP_Camera2OptionsDef = DEFAULTMENUSTYLE( +menu_t OP_Camera2OptionsDef = DEFAULTSCROLLMENUSTYLE( MN_OP_MAIN + (MN_OP_P2CONTROLS << 6) + (MN_OP_P2CAMERA << 12), "M_CONTRO", OP_Camera2OptionsMenu, &OP_P2ControlsDef, 35, 30); @@ -4269,7 +4271,8 @@ static void M_DrawControlsDefMenu(void) OP_CameraOptionsMenu[10].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; OP_CameraOptionsMenu[11].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; OP_CameraOptionsMenu[12].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_CameraOptionsMenu[13].alphaKey = 160; + OP_CameraOptionsMenu[13].status = IT_STRING|IT_CVAR; + OP_CameraOptionsMenu[14].alphaKey = 90; } else { @@ -4278,7 +4281,8 @@ static void M_DrawControlsDefMenu(void) OP_CameraOptionsMenu[10].status = IT_DISABLED; OP_CameraOptionsMenu[11].status = IT_DISABLED; OP_CameraOptionsMenu[12].status = IT_DISABLED; - OP_CameraOptionsMenu[13].alphaKey = 110; + OP_CameraOptionsMenu[13].status = IT_DISABLED; + OP_CameraOptionsMenu[14].alphaKey = 55; } } else @@ -4292,7 +4296,8 @@ static void M_DrawControlsDefMenu(void) OP_Camera2OptionsMenu[10].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; OP_Camera2OptionsMenu[11].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; OP_Camera2OptionsMenu[12].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_Camera2OptionsMenu[13].alphaKey = 160; + OP_Camera2OptionsMenu[13].status = IT_STRING|IT_CVAR; + OP_Camera2OptionsMenu[14].alphaKey = 90; } else { @@ -4301,7 +4306,8 @@ static void M_DrawControlsDefMenu(void) OP_Camera2OptionsMenu[10].status = IT_DISABLED; OP_Camera2OptionsMenu[11].status = IT_DISABLED; OP_Camera2OptionsMenu[12].status = IT_DISABLED; - OP_Camera2OptionsMenu[13].alphaKey = 110; + OP_Camera2OptionsMenu[13].status = IT_DISABLED; + OP_Camera2OptionsMenu[14].alphaKey = 55; } } @@ -4319,7 +4325,9 @@ static void M_DrawGenericScrollMenu(void) x = currentMenu->x; y = currentMenu->y; - if ((currentMenu->menuitems[itemOn].alphaKey*2 - currentMenu->menuitems[0].alphaKey*2) <= scrollareaheight) + if (currentMenu->menuitems[currentMenu->numitems-1].alphaKey < scrollareaheight) + tempcentery = currentMenu->y; // Not tall enough to scroll, but this thinker is used in case it becomes so + else if ((currentMenu->menuitems[itemOn].alphaKey*2 - currentMenu->menuitems[0].alphaKey*2) <= scrollareaheight) tempcentery = currentMenu->y - currentMenu->menuitems[0].alphaKey*2; else if ((currentMenu->menuitems[currentMenu->numitems-1].alphaKey*2 - currentMenu->menuitems[itemOn].alphaKey*2) <= scrollareaheight) tempcentery = currentMenu->y - currentMenu->menuitems[currentMenu->numitems-1].alphaKey*2 + 2*scrollareaheight; From 2ab83bac6007cb9e5e5003bafef08cd4e3dd2b0a Mon Sep 17 00:00:00 2001 From: fickleheart Date: Tue, 10 Dec 2019 23:18:46 -0600 Subject: [PATCH 034/126] Run camera movement in the camera options menu It's really nice to see adjustments reflected in real time. --- src/m_menu.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 668e6b3d6..92f2e21d8 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -351,6 +351,7 @@ static void M_DrawTimeAttackMenu(void); static void M_DrawNightsAttackMenu(void); static void M_DrawSetupChoosePlayerMenu(void); static void M_DrawControlsDefMenu(void); +static void M_DrawCameraOptionsMenu(void); static void M_DrawPlaystyleMenu(void); static void M_DrawControl(void); static void M_DrawMainVideoMenu(void); @@ -1978,12 +1979,29 @@ menu_t OP_JoystickSetDef = 0, NULL }; -menu_t OP_CameraOptionsDef = DEFAULTSCROLLMENUSTYLE( + +menu_t OP_CameraOptionsDef = { MN_OP_MAIN + (MN_OP_P1CONTROLS << 6) + (MN_OP_P1CAMERA << 12), - "M_CONTRO", OP_CameraOptionsMenu, &OP_P1ControlsDef, 35, 30); -menu_t OP_Camera2OptionsDef = DEFAULTSCROLLMENUSTYLE( + "M_CONTRO", + sizeof (OP_CameraOptionsMenu)/sizeof (menuitem_t), + &OP_P1ControlsDef, + OP_CameraOptionsMenu, + M_DrawCameraOptionsMenu, + 35, 30, + 0, + NULL +}; +menu_t OP_Camera2OptionsDef = { MN_OP_MAIN + (MN_OP_P2CONTROLS << 6) + (MN_OP_P2CAMERA << 12), - "M_CONTRO", OP_Camera2OptionsMenu, &OP_P2ControlsDef, 35, 30); + "M_CONTRO", + sizeof (OP_Camera2OptionsMenu)/sizeof (menuitem_t), + &OP_P2ControlsDef, + OP_Camera2OptionsMenu, + M_DrawCameraOptionsMenu, + 35, 30, + 0, + NULL +}; static menuitem_t OP_PlaystyleMenu[] = {{IT_KEYHANDLER | IT_NOTHING, NULL, "", M_HandlePlaystyleMenu, 0}}; @@ -11663,6 +11681,19 @@ static void M_HandlePlaystyleMenu(INT32 choice) } } +static void M_DrawCameraOptionsMenu(void) +{ + M_DrawGenericScrollMenu(); + + if (gamestate == GS_LEVEL && (paused || P_AutoPause())) + { + if (currentMenu == &OP_Camera2OptionsDef && splitscreen && camera2.chase) + P_MoveChaseCamera(&players[secondarydisplayplayer], &camera2, false); + if (currentMenu == &OP_CameraOptionsDef && camera.chase) + P_MoveChaseCamera(&players[displayplayer], &camera, false); + } +} + // =============== // VIDEO MODE MENU // =============== From f74d7163e68191faf31600d45a610a33beab0aec Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 11 Dec 2019 01:26:43 -0600 Subject: [PATCH 035/126] Fix RVZ camera stuff --- src/g_game.c | 5 +++-- src/p_user.c | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 0ba7081fa..f198301a9 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1033,6 +1033,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) angle_t *myangle = (ssplayer == 1 ? &localangle : &localangle2); INT32 *myaiming = (ssplayer == 1 ? &localaiming : &localaiming2); + angle_t drawangleoffset = (player->powers[pw_carry] == CR_ROLLOUT) ? ANGLE_180 : 0; INT32 chasecam, chasefreelook, alwaysfreelook, usejoystick, analog, invertmouse, mousemove, abilitydirection; INT32 *mx; INT32 *my; INT32 *mly; @@ -1445,7 +1446,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->sidemove = 0; } else - cmd->angleturn = (player->drawangle>>16); + cmd->angleturn = (player->drawangle+drawangleoffset)>>16; } // Adjust camera angle to face player direction, depending on circumstances @@ -1463,7 +1464,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (camadjustfactor) { - INT32 anglediff = player->drawangle - *myangle; + INT32 anglediff = player->drawangle + drawangleoffset - *myangle; *myangle += FixedMul(anglediff, camadjustfactor); } diff --git a/src/p_user.c b/src/p_user.c index c5d4e2846..8dd76d0ef 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9902,6 +9902,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall UINT8 forplayer = (thiscam == &camera) ? 0 : 1; fixed_t shift = FixedMul(FINESINE((player->drawangle - angle) >> ANGLETOFINESHIFT), cv_cam_shiftfacing[forplayer].value); + if (player->powers[pw_carry] == CR_ROLLOUT) + shift = -shift; + if (ticcmd_resetdown[(thiscam == &camera) ? 0 : 1]) shift = FixedMul(camsideshift[forplayer], FRACUNIT-camspeed); else From f1b5a2b2d33809600d83d5cf45f52177b6f4da77 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 11 Dec 2019 21:09:23 -0600 Subject: [PATCH 036/126] Move Z-targeting behavior to Center View --- src/g_game.c | 51 +++++++++++++++++++++++++++++--------------------- src/g_game.h | 2 +- src/hu_stuff.c | 4 ++-- src/m_menu.c | 2 +- src/p_user.c | 14 ++------------ 5 files changed, 36 insertions(+), 37 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index f198301a9..86a0252ac 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1019,7 +1019,7 @@ static fixed_t forwardmove[2] = {25<>16, 50<>16}; static fixed_t sidemove[2] = {25<>16, 50<>16}; // faster! static fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn -boolean ticcmd_resetdown[2]; // don't cam reset every frame +boolean ticcmd_centerviewdown[2]; // For simple controls, lock the camera behind the player void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { boolean forcestrafe = false; @@ -1039,6 +1039,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) static INT32 turnheld[2]; // for accelerative turning static boolean keyboard_look[2]; // true if lookup/down using keyboard + static boolean resetdown[2]; // don't cam reset every frame static boolean joyaiming[2]; // check the last frame's value if we need to reset the camera UINT8 forplayer = ssplayer-1; @@ -1256,26 +1257,34 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (PLAYERINPUTDOWN(ssplayer, gc_use) || (usejoystick && axis > 0)) cmd->buttons |= BT_USE; + if (PLAYERINPUTDOWN(ssplayer, gc_centerview)) + { + if (abilitydirection) + { + CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 0); + *myangle = player->mo->angle; + *myaiming = 0; + } + + ticcmd_centerviewdown[forplayer] = true; + } + else + { + CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 1); + + ticcmd_centerviewdown[forplayer] = false; + } + if (PLAYERINPUTDOWN(ssplayer, gc_camreset)) { - if (camera.chase && !ticcmd_resetdown[forplayer]) - { - ticcmd_resetdown[forplayer] = true; + if (camera.chase && !resetdown[forplayer]) P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], &camera); - if (abilitydirection) - CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 0); - } - else - ticcmd_resetdown[forplayer] = true; + resetdown[forplayer] = true; } - else if (ticcmd_resetdown[forplayer]) - { - ticcmd_resetdown[forplayer] = false; + else + resetdown[forplayer] = false; - if (abilitydirection) - CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 1); - } // jump button axis = PlayerJoyAxis(ssplayer, AXISJUMP); @@ -1320,7 +1329,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) *myaiming -= KB_LOOKSPEED * screen_invert; keyboard_look[forplayer] = true; } - else if (PLAYERINPUTDOWN(ssplayer, gc_centerview)) + else if (ticcmd_centerviewdown[forplayer]) *myaiming = 0; } @@ -1408,7 +1417,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // Adjust camera angle by player input if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && - !(ticcmd_resetdown[forplayer] && !(cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) + !(ticcmd_centerviewdown[forplayer] && !(cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) && !player->climbing && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar @@ -1418,17 +1427,17 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) fixed_t sine = FINESINE((R_PointToAngle2(0, 0, player->rmomx, player->rmomy) - localangle)>>ANGLETOFINESHIFT); fixed_t factor = min(20, FixedMul(player->speed, abs(sine)) / FRACUNIT); - if (ticcmd_resetdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) + if (ticcmd_centerviewdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) factor = (ssplayer == 1 ? cv_cam_rotspeed.value : cv_cam2_rotspeed.value) * (cv_cam_lockedinput[forplayer].value ?: 1); // Turn while in startdash and locking camera *myangle -= cmd->sidemove * factor * camadjustfactor; } - if (ticcmd_resetdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) + if (ticcmd_centerviewdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) cmd->sidemove = 0; } - if (abilitydirection && camera.chase && !ticcmd_resetdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) + if (abilitydirection && camera.chase && !ticcmd_centerviewdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) { ///@TODO This block of code is a hack to get the desired abilitydirection and player angle behaviors while remaining netplay-compatible with EXEs without those features. // This has side effects like making F12 spectate look kind of weird, and making the input viewer inaccurate. @@ -1451,7 +1460,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // Adjust camera angle to face player direction, depending on circumstances // Nothing happens if cam left/right are held, so you can hold both to lock the camera in one direction - if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_resetdown[forplayer] && player->powers[pw_carry] != CR_MINECART) + if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor; diff --git a/src/g_game.h b/src/g_game.h index 2775382c9..f0cdcd844 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -89,7 +89,7 @@ extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacin // build an internal map name MAPxx from map number const char *G_BuildMapName(INT32 map); -extern boolean ticcmd_resetdown[2]; // don't cam reset every frame +extern boolean ticcmd_centerviewdown[2]; // For simple controls, lock the camera behind the player void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer); // copy ticcmd_t to and fro the normal way diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 03489101d..e1e271064 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2194,10 +2194,10 @@ void HU_Drawer(void) return; // draw the crosshair, not when viewing demos nor with chasecam - if (!automapactive && cv_crosshair.value && !demoplayback && (!camera.chase || (cv_abilitydirection[0].value && ticcmd_resetdown[0])) && !players[displayplayer].spectator) + if (!automapactive && cv_crosshair.value && !demoplayback && (!camera.chase || (cv_abilitydirection[0].value && ticcmd_centerviewdown[0])) && !players[displayplayer].spectator) HU_DrawCrosshair(); - if (!automapactive && cv_crosshair2.value && !demoplayback && (!camera2.chase || (cv_abilitydirection[1].value && ticcmd_resetdown[1])) && !players[secondarydisplayplayer].spectator) + if (!automapactive && cv_crosshair2.value && !demoplayback && (!camera2.chase || (cv_abilitydirection[1].value && ticcmd_centerviewdown[1])) && !players[secondarydisplayplayer].spectator) HU_DrawCrosshair2(); // draw desynch text diff --git a/src/m_menu.c b/src/m_menu.c index 92f2e21d8..c57126805 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4256,7 +4256,7 @@ const char *PlaystyleDesc[4] = { "and acts in the direction\n" "they're moving.\n" "\n" - "Hold \x82Reset Camera\x80 to lock the\n" + "Hold \x82Center View\x80 to lock the\n" "camera behind the player!\n" , diff --git a/src/p_user.c b/src/p_user.c index 8dd76d0ef..6930f3da7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9652,17 +9652,7 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->y = y; thiscam->z = z; - if (thiscam == &camera && cv_abilitydirection[0].value && ticcmd_resetdown[0]) - { - localangle = player->mo->angle; - localaiming = thiscam->aiming = 0; - } - else if (thiscam == &camera2 && cv_abilitydirection[1].value && ticcmd_resetdown[1]) - { - localangle2 = player->mo->angle; - localaiming2 = thiscam->aiming = 0; - } - else if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value)) + if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value)) && !(thiscam == &camera2 && (cv_cam2_still.value || cv_analog2.value))) { thiscam->angle = player->mo->angle; @@ -9905,7 +9895,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (player->powers[pw_carry] == CR_ROLLOUT) shift = -shift; - if (ticcmd_resetdown[(thiscam == &camera) ? 0 : 1]) + if (ticcmd_centerviewdown[(thiscam == &camera) ? 0 : 1]) shift = FixedMul(camsideshift[forplayer], FRACUNIT-camspeed); else shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3)); From a830a20c52664a16d494ac3918d270a7839a12f4 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 11 Dec 2019 21:12:38 -0600 Subject: [PATCH 037/126] [pink text] nter View --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_menu.c b/src/m_menu.c index c57126805..16a398cde 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4256,7 +4256,7 @@ const char *PlaystyleDesc[4] = { "and acts in the direction\n" "they're moving.\n" "\n" - "Hold \x82Center View\x80 to lock the\n" + "Hold \x82" "Center View\x80 to lock the\n" "camera behind the player!\n" , From a0ecb4b71d12acea5396e96699ec659164f6ad6c Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 11 Dec 2019 21:20:07 -0600 Subject: [PATCH 038/126] Fix the console spam issue AGAIN --- src/g_game.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 86a0252ac..d92209d4e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1259,7 +1259,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (PLAYERINPUTDOWN(ssplayer, gc_centerview)) { - if (abilitydirection) + if (abilitydirection && !ticcmd_centerviewdown[forplayer]) { CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 0); *myangle = player->mo->angle; @@ -1268,9 +1268,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) ticcmd_centerviewdown[forplayer] = true; } - else + else if (ticcmd_centerviewdown[forplayer]) { - CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 1); + if (abilitydirection) + CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 1); ticcmd_centerviewdown[forplayer] = false; } From 34706515ca02e948f5cf9fce558f862abf235f3e Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 11 Dec 2019 21:34:32 -0600 Subject: [PATCH 039/126] Make locked input turn act the same as normal turning --- src/g_game.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index d92209d4e..1663b147c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -421,7 +421,7 @@ consvar_t cv_cam_turnfacinginput[2] = { {"cam2_turnfacinginput", "0.4375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; -static CV_PossibleValue_t lockedinput_cons_t[] = {{0, "Strafe"}, {1, "Turn Slow"}, {2, "Turn"}, {0, NULL}}; +static CV_PossibleValue_t lockedinput_cons_t[] = {{0, "Strafe"}, {1, "Turn"}, {0, NULL}}; consvar_t cv_cam_lockedinput[2] = { {"cam_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, @@ -1028,6 +1028,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) const INT32 speed = 1; // these ones used for multiple conditions boolean turnleft, turnright, strafelkey, straferkey, movefkey, movebkey, mouseaiming, analogjoystickmove, gamepadjoystickmove, thisjoyaiming; + boolean strafeisturn; // Simple controls only player_t *player = &players[ssplayer == 2 ? secondarydisplayplayer : consoleplayer]; camera_t *thiscam = ((ssplayer == 1 || player->bot == 2) ? &camera : &camera2); angle_t *myangle = (ssplayer == 1 ? &localangle : &localangle2); @@ -1073,6 +1074,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } abilitydirection = cv_abilitydirection[forplayer].value; + strafeisturn = abilitydirection && ticcmd_centerviewdown[forplayer] && + (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH)) && + !player->climbing && player->powers[pw_carry] != CR_MINECART; + // why build a ticcmd if we're paused? // Or, for that matter, if we're being reborn. // ...OR if we're blindfolded. No looking into the floor. @@ -1092,6 +1097,13 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) movefkey = PLAYERINPUTDOWN(ssplayer, gc_forward); movebkey = PLAYERINPUTDOWN(ssplayer, gc_backward); + if (strafeisturn) + { + turnright |= straferkey; + turnleft |= strafelkey; + straferkey = strafelkey = false; + } + mouseaiming = (PLAYERINPUTDOWN(ssplayer, gc_mouseaiming)) ^ ((chasecam && !player->spectator) ? chasefreelook : alwaysfreelook); analogjoystickmove = usejoystick && !Joystick.bGamepadStyle; @@ -1105,6 +1117,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) joyaiming[forplayer] = thisjoyaiming; axis = PlayerJoyAxis(ssplayer, AXISTURN); + if (strafeisturn) + axis += PlayerJoyAxis(ssplayer, AXISSTRAFE); if (gamepadjoystickmove && axis != 0) { turnright = turnright || (axis > 0); @@ -1178,7 +1192,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (cmd->angleturn * (ssplayer == 1 ? cv_cam_rotspeed.value : cv_cam2_rotspeed.value)) / 10; } - axis = PlayerJoyAxis(ssplayer, AXISSTRAFE); + axis = strafeisturn ? 0 : PlayerJoyAxis(ssplayer, AXISSTRAFE); if (gamepadjoystickmove && axis != 0) { if (axis < 0) @@ -1417,9 +1431,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(*myangle >> 16); // Adjust camera angle by player input - if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && - !(ticcmd_centerviewdown[forplayer] && !(cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) - && !player->climbing && player->powers[pw_carry] != CR_MINECART) + if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar From efec52c48aecced4d412f44104043b47add1d720 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 11 Dec 2019 22:47:09 -0600 Subject: [PATCH 040/126] Fix input turning still happening with centered view --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 1663b147c..7e23a757f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1431,7 +1431,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(*myangle >> 16); // Adjust camera angle by player input - if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) + if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar From a188cd5db8eff18c95af0105ead0fe0b9bf00899 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Thu, 12 Dec 2019 00:48:15 -0600 Subject: [PATCH 041/126] Add boss target assist and finally organize camera options --- src/d_netcmd.c | 2 + src/g_game.c | 42 ++++++++++++++++ src/g_game.h | 3 +- src/hu_stuff.c | 8 ++- src/m_menu.c | 132 ++++++++++++++++++++++++++++++------------------- src/p_local.h | 2 + src/p_user.c | 88 +++++++++++++++++++++++++++++++++ 7 files changed, 223 insertions(+), 54 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 512451b85..d05c5cc45 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -840,6 +840,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_cam_turnfacinginput[1]); CV_RegisterVar(&cv_cam_lockedinput[0]); CV_RegisterVar(&cv_cam_lockedinput[1]); + CV_RegisterVar(&cv_cam_lockonboss[0]); + CV_RegisterVar(&cv_cam_lockonboss[1]); // s_sound.c CV_RegisterVar(&cv_soundvolume); diff --git a/src/g_game.c b/src/g_game.c index 7e23a757f..a118ec09d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -428,6 +428,11 @@ consvar_t cv_cam_lockedinput[2] = { {"cam2_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; +consvar_t cv_cam_lockonboss[2] = { + {"cam_lockonboss", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_lockonboss", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; + typedef enum { AXISNONE = 0, @@ -1020,6 +1025,7 @@ static fixed_t sidemove[2] = {25<>16, 50<>16}; // faster! static fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn boolean ticcmd_centerviewdown[2]; // For simple controls, lock the camera behind the player +mobj_t *ticcmd_ztargetfocus[2]; // Locking onto an object? void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { boolean forcestrafe = false; @@ -1278,6 +1284,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 0); *myangle = player->mo->angle; *myaiming = 0; + + if (cv_cam_lockonboss[forplayer].value) + P_SetTarget(&ticcmd_ztargetfocus[forplayer], P_LookForFocusTarget(player, NULL, 0)); } ticcmd_centerviewdown[forplayer] = true; @@ -1285,11 +1294,44 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else if (ticcmd_centerviewdown[forplayer]) { if (abilitydirection) + { + P_SetTarget(&ticcmd_ztargetfocus[forplayer], NULL); CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 1); + } ticcmd_centerviewdown[forplayer] = false; } + if (ticcmd_ztargetfocus[forplayer]) + { + if ( + P_MobjWasRemoved(ticcmd_ztargetfocus[forplayer]) || + !ticcmd_ztargetfocus[forplayer]->health || + (ticcmd_ztargetfocus[forplayer]->flags2 & MF2_FRET) || + (ticcmd_ztargetfocus[forplayer]->type == MT_EGGMOBILE3 && !ticcmd_ztargetfocus[forplayer]->movecount) // Sea Egg is moving around underground and shouldn't be tracked + ) + P_SetTarget(&ticcmd_ztargetfocus[forplayer], NULL); + else + { + if (P_AproxDistance( + player->mo->x - ticcmd_ztargetfocus[forplayer]->x, + player->mo->y - ticcmd_ztargetfocus[forplayer]->y + ) > 50*player->mo->scale) + { + INT32 anglediff = R_PointToAngle2(player->mo->x, player->mo->y, ticcmd_ztargetfocus[forplayer]->x, ticcmd_ztargetfocus[forplayer]->y) - *myangle; + const INT32 maxturn = ANG10/2; + anglediff /= 4; + + if (anglediff > maxturn) + anglediff = maxturn; + else if (anglediff < -maxturn) + anglediff = -maxturn; + + *myangle += anglediff; + } + } + } + if (PLAYERINPUTDOWN(ssplayer, gc_camreset)) { if (camera.chase && !resetdown[forplayer]) diff --git a/src/g_game.h b/src/g_game.h index f0cdcd844..f6e7acede 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -79,7 +79,7 @@ extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_g // hi here's some new controls extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacing[2], cv_cam_turnfacingability[2], cv_cam_turnfacingspindash[2], cv_cam_turnfacinginput[2], - cv_cam_lockedinput[2]; + cv_cam_lockedinput[2], cv_cam_lockonboss[2]; // mouseaiming (looking up/down with the mouse or keyboard) #define KB_LOOKSPEED (1<<25) @@ -90,6 +90,7 @@ extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacin const char *G_BuildMapName(INT32 map); extern boolean ticcmd_centerviewdown[2]; // For simple controls, lock the camera behind the player +extern mobj_t *ticcmd_ztargetfocus[2]; // Locking onto an object? void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer); // copy ticcmd_t to and fro the normal way diff --git a/src/hu_stuff.c b/src/hu_stuff.c index e1e271064..c1818bd4b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2194,10 +2194,14 @@ void HU_Drawer(void) return; // draw the crosshair, not when viewing demos nor with chasecam - if (!automapactive && cv_crosshair.value && !demoplayback && (!camera.chase || (cv_abilitydirection[0].value && ticcmd_centerviewdown[0])) && !players[displayplayer].spectator) + if (!automapactive && cv_crosshair.value && !demoplayback && + (!camera.chase || (cv_abilitydirection[0].value && ticcmd_centerviewdown[0] && ticcmd_ztargetfocus[0])) + && !players[displayplayer].spectator) HU_DrawCrosshair(); - if (!automapactive && cv_crosshair2.value && !demoplayback && (!camera2.chase || (cv_abilitydirection[1].value && ticcmd_centerviewdown[1])) && !players[secondarydisplayplayer].spectator) + if (!automapactive && cv_crosshair2.value && !demoplayback && + (!camera2.chase || (cv_abilitydirection[1].value && ticcmd_centerviewdown[1] && ticcmd_ztargetfocus[1])) + && !players[secondarydisplayplayer].spectator) HU_DrawCrosshair2(); // draw desynch text diff --git a/src/m_menu.c b/src/m_menu.c index 16a398cde..6d42fddda 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1182,46 +1182,96 @@ static menuitem_t OP_Mouse2OptionsMenu[] = static menuitem_t OP_CameraOptionsMenu[] = { + {IT_HEADER, NULL, "General Toggles", NULL, 0}, {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam , 5}, {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam , 10}, {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam_orbit , 15}, {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 20}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 30}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 35}, - {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 40}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam_rotspeed, 45}, + {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 35}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 40}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 45}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam_rotspeed, 50}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[0], 55}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[0], 60}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 65}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[0], 70}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 75}, - {IT_STRING | IT_CVAR, NULL, "Locked movement", &cv_cam_lockedinput[0], 80}, - - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 90}, + {IT_HEADER, NULL, "Display Options", NULL, 60}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 65}, }; static menuitem_t OP_Camera2OptionsMenu[] = { + {IT_HEADER, NULL, "General Toggles", NULL, 0}, {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam2 , 5}, {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam2 , 10}, {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam2_orbit , 15}, {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 20}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 30}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 35}, - {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 40}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam2_rotspeed, 45}, + {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 35}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 40}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 45}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam2_rotspeed, 50}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to character angle", &cv_cam_shiftfacing[1], 55}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to character angle", &cv_cam_turnfacing[1], 60}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 65}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[1], 70}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 75}, - {IT_STRING | IT_CVAR, NULL, "Locked movement", &cv_cam_lockedinput[0], 80}, + {IT_HEADER, NULL, "Display Options", NULL, 60}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 65}, +}; - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 90}, +static menuitem_t OP_CameraExtendedOptionsMenu[] = +{ + {IT_HEADER, NULL, "General Toggles", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam , 5}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam , 10}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam_orbit , 15}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 20}, + + {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 35}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 40}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 45}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam_rotspeed, 50}, + + {IT_HEADER, NULL, "Automatic Camera Options", NULL, 60}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[0], 65}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[0], 70}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 75}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[0], 80}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 85}, + + {IT_HEADER, NULL, "Locked Camera Options", NULL, 95}, + {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[0], 100}, + {IT_STRING | IT_CVAR, NULL, "Boss targeting assist", &cv_cam_lockonboss[0], 105}, + + {IT_HEADER, NULL, "Display Options", NULL, 115}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 120}, +}; + +static menuitem_t OP_Camera2ExtendedOptionsMenu[] = +{ + {IT_HEADER, NULL, "General Toggles", NULL, 0}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam2 , 5}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam2 , 10}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam2_orbit , 15}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 20}, + + {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 35}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 40}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 45}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam2_rotspeed, 50}, + + {IT_HEADER, NULL, "Automatic Camera Options", NULL, 60}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[1], 65}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[1], 70}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 75}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[1], 80}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 85}, + + {IT_HEADER, NULL, "Locked Camera Options", NULL, 95}, + {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[1], 100}, + {IT_STRING | IT_CVAR, NULL, "Boss targeting assist", &cv_cam_lockonboss[1], 105}, + + {IT_HEADER, NULL, "Display Options", NULL, 115}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 120}, }; static menuitem_t OP_VideoOptionsMenu[] = @@ -4284,23 +4334,13 @@ static void M_DrawControlsDefMenu(void) if (opt == 2) { - OP_CameraOptionsMenu[8].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_CameraOptionsMenu[9].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_CameraOptionsMenu[10].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_CameraOptionsMenu[11].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_CameraOptionsMenu[12].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_CameraOptionsMenu[13].status = IT_STRING|IT_CVAR; - OP_CameraOptionsMenu[14].alphaKey = 90; + OP_CameraOptionsDef.menuitems = OP_CameraExtendedOptionsMenu; + OP_CameraOptionsDef.numitems = sizeof (OP_CameraExtendedOptionsMenu) / sizeof (menuitem_t); } else { - OP_CameraOptionsMenu[8].status = IT_DISABLED; - OP_CameraOptionsMenu[9].status = IT_DISABLED; - OP_CameraOptionsMenu[10].status = IT_DISABLED; - OP_CameraOptionsMenu[11].status = IT_DISABLED; - OP_CameraOptionsMenu[12].status = IT_DISABLED; - OP_CameraOptionsMenu[13].status = IT_DISABLED; - OP_CameraOptionsMenu[14].alphaKey = 55; + OP_CameraOptionsDef.menuitems = OP_CameraOptionsMenu; + OP_CameraOptionsDef.numitems = sizeof (OP_CameraOptionsMenu) / sizeof (menuitem_t); } } else @@ -4309,23 +4349,13 @@ static void M_DrawControlsDefMenu(void) if (opt == 2) { - OP_Camera2OptionsMenu[8].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_Camera2OptionsMenu[9].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_Camera2OptionsMenu[10].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_Camera2OptionsMenu[11].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_Camera2OptionsMenu[12].status = IT_STRING|IT_CVAR|IT_CV_SLIDER; - OP_Camera2OptionsMenu[13].status = IT_STRING|IT_CVAR; - OP_Camera2OptionsMenu[14].alphaKey = 90; + OP_Camera2OptionsDef.menuitems = OP_Camera2ExtendedOptionsMenu; + OP_Camera2OptionsDef.numitems = sizeof (OP_Camera2ExtendedOptionsMenu) / sizeof (menuitem_t); } else { - OP_Camera2OptionsMenu[8].status = IT_DISABLED; - OP_Camera2OptionsMenu[9].status = IT_DISABLED; - OP_Camera2OptionsMenu[10].status = IT_DISABLED; - OP_Camera2OptionsMenu[11].status = IT_DISABLED; - OP_Camera2OptionsMenu[12].status = IT_DISABLED; - OP_Camera2OptionsMenu[13].status = IT_DISABLED; - OP_Camera2OptionsMenu[14].alphaKey = 55; + OP_Camera2OptionsDef.menuitems = OP_Camera2OptionsMenu; + OP_Camera2OptionsDef.numitems = sizeof (OP_Camera2OptionsMenu) / sizeof (menuitem_t); } } diff --git a/src/p_local.h b/src/p_local.h index 286d7201f..f87930e28 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -181,6 +181,8 @@ fixed_t P_ReturnThrustX(mobj_t *mo, angle_t angle, fixed_t move); fixed_t P_ReturnThrustY(mobj_t *mo, angle_t angle, fixed_t move); void P_InstaThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move); +mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction); + mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet); void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius); boolean P_HomingAttack(mobj_t *source, mobj_t *enemy); /// \todo doesn't belong in p_user diff --git a/src/p_user.c b/src/p_user.c index 6930f3da7..e57c56aa4 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9135,6 +9135,94 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) } } +// +// P_LookForFocusTarget +// Looks for a target for a player to focus on, for Z-targeting etc. +// exclude would be the current focus target, to ignore. +// direction, if set, requires the target to be to the left (1) or right (-1) of the angle +// mobjflags can be used to limit the flags of objects that can be focused +// +mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction) +{ + mobj_t *mo; + thinker_t *think; + mobj_t *closestmo = NULL; + const fixed_t maxdist = 2560*player->mo->scale; + const angle_t span = ANGLE_45; + fixed_t dist, closestdist = 0; + angle_t dangle, closestdangle = 0; + + for (think = thlist[THINK_MOBJ].next; think != &thlist[THINK_MOBJ]; think = think->next) + { + if (think->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + + mo = (mobj_t *)think; + + if (mo->flags & MF_NOCLIPTHING) + continue; + + if (mo->health <= 0) // dead + continue; + + if (!(mo->flags & MF_BOSS && (mo->flags & MF_SHOOTABLE)) == !(mo->flags2 & MF2_INVERTAIMABLE)) // allows if it has the flags desired XOR it has the invert aimable flag + continue; // not a valid target + + if (mo == player->mo) + continue; + + if (mo->flags2 & MF2_FRET) + continue; + + if (mo->type == MT_DETON) // Don't be STUPID, Sonic! + continue; + + { + fixed_t zdist = (player->mo->z + player->mo->height/2) - (mo->z + mo->height/2); + dist = P_AproxDistance(player->mo->x-mo->x, player->mo->y-mo->y); + + if (abs(zdist) > dist) + continue; // Don't home outside of desired angle! + + dist = P_AproxDistance(dist, zdist); + if (dist > maxdist) + continue; // out of range + } + + if ((twodlevel || player->mo->flags2 & MF2_TWOD) + && abs(player->mo->y-mo->y) > player->mo->radius) + continue; // not in your 2d plane + + if (mo->type == MT_PLAYER) // Don't chase after other players! + continue; + + dangle = R_PointToAngle2(player->mo->x + P_ReturnThrustX(player->mo, player->mo->angle, player->mo->radius), player->mo->y + P_ReturnThrustY(player->mo, player->mo->angle, player->mo->radius), mo->x, mo->y) - player->mo->angle; + + if ((dangle + span) > span*2) + continue; // behind back + + if (direction) + { + if (direction == 1 && dangle > ANGLE_180) + continue; // To the right of the player + if (direction == -1 && dangle < ANGLE_180) + continue; // To the left of the player + } + + if (closestmo && (exclude ? (dangle > closestdangle) : (dist > closestdist))) + continue; + + if (!P_CheckSight(player->mo, mo)) + continue; // out of sight + + closestmo = mo; + closestdist = dist; + closestdangle = dangle; + } + + return closestmo; +} + // // P_LookForEnemies // Looks for something you can hit - Used for homing attack From 4941ef4aac380b396f7106094b1841b54fc1666e Mon Sep 17 00:00:00 2001 From: fickleheart Date: Thu, 12 Dec 2019 22:13:44 -0600 Subject: [PATCH 042/126] Don't turn strafe keys into turn when locked onto something --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index a118ec09d..522777ee5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1081,7 +1081,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) abilitydirection = cv_abilitydirection[forplayer].value; strafeisturn = abilitydirection && ticcmd_centerviewdown[forplayer] && - (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH)) && + ((cv_cam_lockedinput[forplayer].value && !ticcmd_ztargetfocus[forplayer]) || (player->pflags & PF_STARTDASH)) && !player->climbing && player->powers[pw_carry] != CR_MINECART; // why build a ticcmd if we're paused? From d14fa39d7aeb8189616b98c0c4a9fb0908194dc8 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Thu, 12 Dec 2019 23:03:51 -0600 Subject: [PATCH 043/126] Expand options for aim assist This will need a lot of testing to ensure each type works properly. --- src/g_game.c | 15 ++++++++--- src/g_game.h | 8 ++++++ src/m_menu.c | 4 +-- src/p_local.h | 2 +- src/p_user.c | 72 +++++++++++++++++++++++++++++++++++++++------------ 5 files changed, 78 insertions(+), 23 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 522777ee5..6ea14bcff 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -428,9 +428,18 @@ consvar_t cv_cam_lockedinput[2] = { {"cam2_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; +static CV_PossibleValue_t lockedassist_cons_t[] = { + {0, "Off"}, + {LOCK_BOSS, "Bosses"}, + {LOCK_BOSS|LOCK_ENEMY, "Enemies"}, + {LOCK_BOSS|LOCK_INTERESTS, "Interests"}, + {LOCK_BOSS|LOCK_ENEMY|LOCK_INTERESTS, "Full"}, + {0, NULL} +}; + consvar_t cv_cam_lockonboss[2] = { - {"cam_lockonboss", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_lockonboss", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; typedef enum @@ -1286,7 +1295,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) *myaiming = 0; if (cv_cam_lockonboss[forplayer].value) - P_SetTarget(&ticcmd_ztargetfocus[forplayer], P_LookForFocusTarget(player, NULL, 0)); + P_SetTarget(&ticcmd_ztargetfocus[forplayer], P_LookForFocusTarget(player, NULL, 0, cv_cam_lockonboss[forplayer].value)); } ticcmd_centerviewdown[forplayer] = true; diff --git a/src/g_game.h b/src/g_game.h index f6e7acede..0a018e253 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -81,6 +81,14 @@ extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacin cv_cam_turnfacingability[2], cv_cam_turnfacingspindash[2], cv_cam_turnfacinginput[2], cv_cam_lockedinput[2], cv_cam_lockonboss[2]; +typedef enum +{ + LOCK_BOSS = 1<<0, + LOCK_ENEMY = 1<<1, + LOCK_INTERESTS = 1<<2, +} lockassist_e; + + // mouseaiming (looking up/down with the mouse or keyboard) #define KB_LOOKSPEED (1<<25) #define MAXPLMOVE (50) diff --git a/src/m_menu.c b/src/m_menu.c index 6d42fddda..bfe118af1 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1239,7 +1239,7 @@ static menuitem_t OP_CameraExtendedOptionsMenu[] = {IT_HEADER, NULL, "Locked Camera Options", NULL, 95}, {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[0], 100}, - {IT_STRING | IT_CVAR, NULL, "Boss targeting assist", &cv_cam_lockonboss[0], 105}, + {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[0], 105}, {IT_HEADER, NULL, "Display Options", NULL, 115}, {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 120}, @@ -1268,7 +1268,7 @@ static menuitem_t OP_Camera2ExtendedOptionsMenu[] = {IT_HEADER, NULL, "Locked Camera Options", NULL, 95}, {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[1], 100}, - {IT_STRING | IT_CVAR, NULL, "Boss targeting assist", &cv_cam_lockonboss[1], 105}, + {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[1], 105}, {IT_HEADER, NULL, "Display Options", NULL, 115}, {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 120}, diff --git a/src/p_local.h b/src/p_local.h index f87930e28..ee52ac808 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -181,7 +181,7 @@ fixed_t P_ReturnThrustX(mobj_t *mo, angle_t angle, fixed_t move); fixed_t P_ReturnThrustY(mobj_t *mo, angle_t angle, fixed_t move); void P_InstaThrustEvenIn2D(mobj_t *mo, angle_t angle, fixed_t move); -mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction); +mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction, UINT8 lockonflags); mobj_t *P_LookForEnemies(player_t *player, boolean nonenemies, boolean bullet); void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius); diff --git a/src/p_user.c b/src/p_user.c index e57c56aa4..9c4c8a100 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9142,7 +9142,7 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius) // direction, if set, requires the target to be to the left (1) or right (-1) of the angle // mobjflags can be used to limit the flags of objects that can be focused // -mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction) +mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction, UINT8 lockonflags) { mobj_t *mo; thinker_t *think; @@ -9162,20 +9162,53 @@ mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction) if (mo->flags & MF_NOCLIPTHING) continue; - if (mo->health <= 0) // dead - continue; - - if (!(mo->flags & MF_BOSS && (mo->flags & MF_SHOOTABLE)) == !(mo->flags2 & MF2_INVERTAIMABLE)) // allows if it has the flags desired XOR it has the invert aimable flag - continue; // not a valid target - if (mo == player->mo) continue; - if (mo->flags2 & MF2_FRET) + if (mo->health <= 0) // dead continue; - if (mo->type == MT_DETON) // Don't be STUPID, Sonic! - continue; + switch (mo->type) + { + case MT_TNTBARREL: + if (lockonflags & LOCK_INTERESTS) + break; + /*fallthru*/ + case MT_PLAYER: // Don't chase other players! + case MT_DETON: + continue; // Don't be STUPID, Sonic! + + case MT_FAKEMOBILE: + if (!(lockonflags & LOCK_BOSS)) + continue; + break; + + case MT_EGGSHIELD: + if (!(lockonflags & LOCK_ENEMY)) + continue; + break; + + case MT_EGGSTATUE: + if (tutorialmode) + break; // Always focus egg statue in the tutorial + /*fallthru*/ + default: + + if ((lockonflags & LOCK_BOSS) && ((mo->flags & (MF_BOSS|MF_SHOOTABLE)) == (MF_BOSS|MF_SHOOTABLE))) // allows if it has the flags desired XOR it has the invert aimable flag + { + if (mo->flags2 & MF2_FRET) + continue; + break; + } + + if ((lockonflags & LOCK_ENEMY) && (!((mo->flags & (MF_ENEMY|MF_SHOOTABLE)) == (MF_ENEMY|MF_SHOOTABLE)) != !(mo->flags2 & MF2_INVERTAIMABLE))) // allows if it has the flags desired XOR it has the invert aimable flag + break; + + if ((lockonflags & LOCK_INTERESTS) && (mo->flags & (MF_PUSHABLE|MF_MONITOR))) // allows if it has the flags desired XOR it has the invert aimable flag + break; + + continue; // not a valid object + } { fixed_t zdist = (player->mo->z + player->mo->height/2) - (mo->z + mo->height/2); @@ -9193,13 +9226,9 @@ mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction) && abs(player->mo->y-mo->y) > player->mo->radius) continue; // not in your 2d plane - if (mo->type == MT_PLAYER) // Don't chase after other players! - continue; - - dangle = R_PointToAngle2(player->mo->x + P_ReturnThrustX(player->mo, player->mo->angle, player->mo->radius), player->mo->y + P_ReturnThrustY(player->mo, player->mo->angle, player->mo->radius), mo->x, mo->y) - player->mo->angle; - - if ((dangle + span) > span*2) - continue; // behind back + dangle = R_PointToAngle2(player->mo->x, player->mo->y, mo->x, mo->y) - ( + !exclude ? player->mo->angle : R_PointToAngle2(player->mo->x, player->mo->y, exclude->x, exclude->y) + ); if (direction) { @@ -9209,6 +9238,15 @@ mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction) continue; // To the left of the player } + if (dangle > ANGLE_180) + dangle = InvAngle(dangle); + + if (dangle > span) + continue; // behind back + + // Inflate dist by angle difference to bias toward objects at a closer angle + dist = FixedDiv(dist, FINECOSINE(dangle>>ANGLETOFINESHIFT)*3); + if (closestmo && (exclude ? (dangle > closestdangle) : (dist > closestdist))) continue; From bc4b1e1abefc6f1b469b50147bb63695307e589b Mon Sep 17 00:00:00 2001 From: fickleheart Date: Thu, 12 Dec 2019 23:52:13 -0600 Subject: [PATCH 044/126] Allow switching lockon targets with turn buttons --- src/g_game.c | 21 +++++++++++++++++++++ src/p_user.c | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 6ea14bcff..7eca22aac 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1057,6 +1057,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) static boolean keyboard_look[2]; // true if lookup/down using keyboard static boolean resetdown[2]; // don't cam reset every frame static boolean joyaiming[2]; // check the last frame's value if we need to reset the camera + static boolean zchange[2]; // only switch z targets once per press UINT8 forplayer = ssplayer-1; if (ssplayer == 1) @@ -1322,6 +1323,26 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) P_SetTarget(&ticcmd_ztargetfocus[forplayer], NULL); else { + mobj_t *newtarget = NULL; + if (zchange[forplayer]) + { + if (!turnleft && !turnright && abs(cmd->angleturn) < angleturn[0]) + zchange[forplayer] = false; + } + else if (turnleft || cmd->angleturn > angleturn[0]) + { + zchange[forplayer] = true; + newtarget = P_LookForFocusTarget(player, ticcmd_ztargetfocus[forplayer], 1, cv_cam_lockonboss[forplayer].value); + } + else if (turnright || cmd->angleturn < -angleturn[0]) + { + zchange[forplayer] = true; + newtarget = P_LookForFocusTarget(player, ticcmd_ztargetfocus[forplayer], -1, cv_cam_lockonboss[forplayer].value); + } + + if (newtarget) + P_SetTarget(&ticcmd_ztargetfocus[forplayer], newtarget); + if (P_AproxDistance( player->mo->x - ticcmd_ztargetfocus[forplayer]->x, player->mo->y - ticcmd_ztargetfocus[forplayer]->y diff --git a/src/p_user.c b/src/p_user.c index 9c4c8a100..c7347462c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9162,7 +9162,7 @@ mobj_t *P_LookForFocusTarget(player_t *player, mobj_t *exclude, SINT8 direction, if (mo->flags & MF_NOCLIPTHING) continue; - if (mo == player->mo) + if (mo == player->mo || mo == exclude) continue; if (mo->health <= 0) // dead From 098c99a834eb0282a22cc694e438edd5879a04ef Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 00:34:34 -0600 Subject: [PATCH 045/126] Adjust how turn-to-angle tweens --- src/g_game.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 7eca22aac..08f9396fc 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1548,18 +1548,33 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor; + boolean alt = false; // Reduce intensity on diagonals and prevent backwards movement from turning the camera if (player->climbing || player->pflags & PF_GLIDING) camadjustfactor = cv_cam_turnfacingability[forplayer].value/4; else if (player->pflags & PF_STARTDASH) camadjustfactor = cv_cam_turnfacingspindash[forplayer].value/4; else + { + alt = true; camadjustfactor = cv_cam_turnfacing[forplayer].value/8; + } if (camadjustfactor) { INT32 anglediff = player->drawangle + drawangleoffset - *myangle; + if (alt) + { + fixed_t sine = FINESINE((angle_t) (anglediff)>>ANGLETOFINESHIFT); + sine = abs(sine); + + if (abs(anglediff) > ANGLE_90) + sine = max(0, sine*3 - 2*FRACUNIT); // At about 135 degrees, this will stop turning + + anglediff = FixedMul(anglediff, sine); + } + *myangle += FixedMul(anglediff, camadjustfactor); } } From c41b2e7456f8a9808655b6d6c4f2b05cfd1a35bb Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 00:52:48 -0600 Subject: [PATCH 046/126] Suspend turn-to-angle when rotating the camera --- src/g_game.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 08f9396fc..6292683eb 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1058,6 +1058,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) static boolean resetdown[2]; // don't cam reset every frame static boolean joyaiming[2]; // check the last frame's value if we need to reset the camera static boolean zchange[2]; // only switch z targets once per press + static fixed_t tta_factor[2] = {FRACUNIT, FRACUNIT}; // disables turn-to-angle when manually turning camera until movement happens UINT8 forplayer = ssplayer-1; if (ssplayer == 1) @@ -1204,6 +1205,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(cmd->angleturn - ((axis * angleturn[1]) >> 10)); // ANALOG! } + if (turnright || turnleft || abs(cmd->angleturn) > angleturn[1]) + tta_factor[forplayer] = 0; // suspend turn to angle + // Make rotspeed affect turning speed :) cmd->angleturn = (cmd->angleturn * (ssplayer == 1 ? cv_cam_rotspeed.value : cv_cam2_rotspeed.value)) / 10; } @@ -1557,9 +1561,14 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else { alt = true; - camadjustfactor = cv_cam_turnfacing[forplayer].value/8; + camadjustfactor = FixedMul(cv_cam_turnfacing[forplayer].value/8, tta_factor[forplayer]); } + if (tta_factor[forplayer] < FRACUNIT && (!alt || cmd->forwardmove || cmd->sidemove || tta_factor[forplayer] >= FRACUNIT/3)) + tta_factor[forplayer] += FRACUNIT>>5; + else if (tta_factor[forplayer] && tta_factor[forplayer] < FRACUNIT/3) + tta_factor[forplayer] -= FRACUNIT>>5; + if (camadjustfactor) { INT32 anglediff = player->drawangle + drawangleoffset - *myangle; From 87ad91a2be223338613204e17afad85d77de813d Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 17:35:48 -0600 Subject: [PATCH 047/126] LMAO right stick checking used the wrong value --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 6292683eb..f7ecbe0e1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1205,7 +1205,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(cmd->angleturn - ((axis * angleturn[1]) >> 10)); // ANALOG! } - if (turnright || turnleft || abs(cmd->angleturn) > angleturn[1]) + if (turnright || turnleft || abs(cmd->angleturn) > angleturn[2]) tta_factor[forplayer] = 0; // suspend turn to angle // Make rotspeed affect turning speed :) From 1a60f7a2ad572947e447edc93d9cab0340a120a8 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 19:30:19 -0600 Subject: [PATCH 048/126] Fix wacky CEZ2 platform camera --- src/p_polyobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index c37926adf..6637d238c 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1341,9 +1341,9 @@ static void Polyobj_rotateThings(polyobj_t *po, vertex_t origin, angle_t delta, if (turnthings == 2 || (turnthings == 1 && !mo->player)) { mo->angle += delta; if (mo->player == &players[consoleplayer]) - localangle = mo->angle; + localangle += delta; else if (mo->player == &players[secondarydisplayplayer]) - localangle2 = mo->angle; + localangle2 += delta; } } } From a03ab5e29437686c409ff05a499bf802059b7722 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 19:37:01 -0600 Subject: [PATCH 049/126] Patch slight camera turn when airbraking --- src/g_game.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index f7ecbe0e1..c08973b6e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1571,7 +1571,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (camadjustfactor) { - INT32 anglediff = player->drawangle + drawangleoffset - *myangle; + INT32 anglediff = + // This check to potentially use angleturn fixes the judder when holding back in the air to brake + ((alt && (forward || side) && !P_IsObjectOnGround(player->mo)) ? (cmd->angleturn<<16) : player->drawangle) + + drawangleoffset - *myangle; if (alt) { From 022a44fb01c7a900226e180cfd3a194feaad5c8f Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 19:49:56 -0600 Subject: [PATCH 050/126] Don't turn-to-ability while climbing --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index c08973b6e..ff330278a 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1554,7 +1554,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) fixed_t camadjustfactor; boolean alt = false; // Reduce intensity on diagonals and prevent backwards movement from turning the camera - if (player->climbing || player->pflags & PF_GLIDING) + if (player->pflags & PF_GLIDING) camadjustfactor = cv_cam_turnfacingability[forplayer].value/4; else if (player->pflags & PF_STARTDASH) camadjustfactor = cv_cam_turnfacingspindash[forplayer].value/4; From f82f1513ba3d5620d508057b354d3500f293a11f Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 20:17:31 -0600 Subject: [PATCH 051/126] Tweaks to camera shifting --- src/p_user.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index c7347462c..835fe7f67 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -10012,7 +10012,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } } - if (cv_abilitydirection[(thiscam == &camera) ? 0 : 1].value) + if (cv_abilitydirection[(thiscam == &camera) ? 0 : 1].value && !sign) { // Shift the camera slightly to the sides depending on the player facing direction UINT8 forplayer = (thiscam == &camera) ? 0 : 1; @@ -10021,6 +10021,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall if (player->powers[pw_carry] == CR_ROLLOUT) shift = -shift; + if (player->powers[pw_carry] == CR_NIGHTSMODE) + { + fixed_t cos = FINECOSINE((angle_t) (player->flyangle * ANG1)>>ANGLETOFINESHIFT); + shift = FixedMul(shift, min(FRACUNIT, player->speed*abs(cos)/6000)); + } + if (ticcmd_centerviewdown[(thiscam == &camera) ? 0 : 1]) shift = FixedMul(camsideshift[forplayer], FRACUNIT-camspeed); else From fdc3347e2229c221debba4419463be9c3c44456e Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 20:19:38 -0600 Subject: [PATCH 052/126] More turn-to-angle changes --- src/g_game.c | 5 +---- src/p_user.c | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ff330278a..20b9a656e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1571,10 +1571,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (camadjustfactor) { - INT32 anglediff = - // This check to potentially use angleturn fixes the judder when holding back in the air to brake - ((alt && (forward || side) && !P_IsObjectOnGround(player->mo)) ? (cmd->angleturn<<16) : player->drawangle) - + drawangleoffset - *myangle; + INT32 anglediff = (cmd->angleturn<<16) + drawangleoffset - *myangle; if (alt) { diff --git a/src/p_user.c b/src/p_user.c index 835fe7f67..93c3c2ef0 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -10016,7 +10016,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { // Shift the camera slightly to the sides depending on the player facing direction UINT8 forplayer = (thiscam == &camera) ? 0 : 1; - fixed_t shift = FixedMul(FINESINE((player->drawangle - angle) >> ANGLETOFINESHIFT), cv_cam_shiftfacing[forplayer].value); + fixed_t shift = FixedMul(FINESINE((player->mo->angle - angle) >> ANGLETOFINESHIFT), cv_cam_shiftfacing[forplayer].value); if (player->powers[pw_carry] == CR_ROLLOUT) shift = -shift; From 097fc48f52181c30a52ea943e5270f87b1414ffd Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 20:30:56 -0600 Subject: [PATCH 053/126] Even MORE tta changes: - All automatic turning is suspended upon manual rotation - Dest angle uses drawangle again for rolling only --- src/g_game.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 20b9a656e..c3f4be3cd 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1561,17 +1561,19 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else { alt = true; - camadjustfactor = FixedMul(cv_cam_turnfacing[forplayer].value/8, tta_factor[forplayer]); + camadjustfactor = cv_cam_turnfacing[forplayer].value/8; } - if (tta_factor[forplayer] < FRACUNIT && (!alt || cmd->forwardmove || cmd->sidemove || tta_factor[forplayer] >= FRACUNIT/3)) + camadjustfactor = FixedMul(camadjustfactor, tta_factor[forplayer]); + + if (tta_factor[forplayer] < FRACUNIT && (cmd->forwardmove || cmd->sidemove || tta_factor[forplayer] >= FRACUNIT/3)) tta_factor[forplayer] += FRACUNIT>>5; else if (tta_factor[forplayer] && tta_factor[forplayer] < FRACUNIT/3) tta_factor[forplayer] -= FRACUNIT>>5; if (camadjustfactor) { - INT32 anglediff = (cmd->angleturn<<16) + drawangleoffset - *myangle; + INT32 anglediff = ((player->pflags & PF_SPINNING) ? player->drawangle : (cmd->angleturn<<16)) + drawangleoffset - *myangle; if (alt) { From 252b77c6519e106d03658a5de79968d928326db7 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 22:30:04 -0600 Subject: [PATCH 054/126] Scale angle-related camera turns by player speed They also operate at full when idle, too. --- src/g_game.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index c3f4be3cd..c85a291fe 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1564,6 +1564,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) camadjustfactor = cv_cam_turnfacing[forplayer].value/8; } + camadjustfactor = FixedMul(camadjustfactor, max(FRACUNIT - player->speed, min(player->speed/18, FRACUNIT))); + camadjustfactor = FixedMul(camadjustfactor, tta_factor[forplayer]); if (tta_factor[forplayer] < FRACUNIT && (cmd->forwardmove || cmd->sidemove || tta_factor[forplayer] >= FRACUNIT/3)) From bc2ed5262581ebcf877c156b4b21fe658203fce6 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 22:55:34 -0600 Subject: [PATCH 055/126] Double sensitivity and halve default of turn to input --- src/g_game.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index c85a291fe..6b5eff4ad 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -417,8 +417,8 @@ consvar_t cv_cam_turnfacingspindash[2] = { {"cam2_turnfacingspindash", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacinginput[2] = { - {"cam_turnfacinginput", "0.4375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacinginput", "0.4375", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; static CV_PossibleValue_t lockedinput_cons_t[] = {{0, "Strafe"}, {1, "Turn"}, {0, NULL}}; @@ -1509,15 +1509,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // Adjust camera angle by player input if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) { - fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; //@TODO cvar + fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; if (camadjustfactor) { fixed_t sine = FINESINE((R_PointToAngle2(0, 0, player->rmomx, player->rmomy) - localangle)>>ANGLETOFINESHIFT); - fixed_t factor = min(20, FixedMul(player->speed, abs(sine)) / FRACUNIT); - - if (ticcmd_centerviewdown[forplayer] && (cv_cam_lockedinput[forplayer].value || (player->pflags & PF_STARTDASH))) - factor = (ssplayer == 1 ? cv_cam_rotspeed.value : cv_cam2_rotspeed.value) * (cv_cam_lockedinput[forplayer].value ?: 1); // Turn while in startdash and locking camera + fixed_t factor = min(40, FixedMul(player->speed, abs(sine))*2 / FRACUNIT); *myangle -= cmd->sidemove * factor * camadjustfactor; } From 0047dba279490ba65f5212188d64e4f4a1b6dac3 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 13 Dec 2019 23:05:36 -0600 Subject: [PATCH 056/126] Fix float cvars saving wrong when set to max --- src/command.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/command.c b/src/command.c index 33d8ead96..889ea3f02 100644 --- a/src/command.c +++ b/src/command.c @@ -2060,7 +2060,12 @@ void CV_SaveVariables(FILE *f) // Silly hack for Min/Max vars if (!strcmp(cvar->string, "MAX") || !strcmp(cvar->string, "MIN")) - sprintf(stringtowrite, "%d", cvar->value); + { + if (cvar->flags & CV_FLOAT) + sprintf(stringtowrite, "%f", FIXED_TO_FLOAT(cvar->value)); + else + sprintf(stringtowrite, "%d", cvar->value); + } else strcpy(stringtowrite, cvar->string); From 87b816e408fec280637957af9e08bd1f20bbceb6 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sat, 14 Dec 2019 15:28:24 -0600 Subject: [PATCH 057/126] Added PlayerThink hook --- src/lua_hook.h | 2 ++ src/lua_hooklib.c | 2 ++ src/p_user.c | 23 ++++++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 6617bca93..073773f52 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -51,6 +51,7 @@ enum hook { hook_PlayerCanDamage, hook_PlayerQuit, hook_IntermissionThinker, + hook_PlayerThink, hook_MAX // last hook }; @@ -93,5 +94,6 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj); // Hook for P_PlayerAft UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_PlayerCanDamage void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting void LUAh_IntermissionThinker(void); // Hook for Y_Ticker +#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink #endif diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index ef87d0b6f..30ab27da1 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -62,6 +62,7 @@ const char *const hookNames[hook_MAX+1] = { "PlayerCanDamage", "PlayerQuit", "IntermissionThinker", + "PlayerThink", NULL }; @@ -205,6 +206,7 @@ static int lib_addHook(lua_State *L) case hook_PlayerCanDamage: case hook_ShieldSpawn: case hook_ShieldSpecial: + case hook_PlayerThink: lastp = &playerhooks; break; case hook_LinedefExecute: diff --git a/src/p_user.c b/src/p_user.c index ea42a2c36..6b9cde62a 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11313,7 +11313,12 @@ void P_PlayerThink(player_t *player) player->playerstate = PST_REBORN; } if (player->playerstate == PST_REBORN) + { +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif return; + } } #ifdef SEENAMES @@ -11414,7 +11419,12 @@ void P_PlayerThink(player_t *player) player->lives = 0; if (player->playerstate == PST_DEAD) + { +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); return; +#endif + } } } @@ -11533,7 +11543,9 @@ void P_PlayerThink(player_t *player) { player->mo->flags2 &= ~MF2_SHADOW; P_DeathThink(player); - +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif return; } @@ -11574,7 +11586,12 @@ void P_PlayerThink(player_t *player) if (player->spectator && cmd->buttons & BT_ATTACK && !player->powers[pw_flashing] && G_GametypeHasSpectators()) { if (P_SpectatorJoinGame(player)) + { +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif return; // player->mo was removed. + } } // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. @@ -11675,6 +11692,10 @@ void P_PlayerThink(player_t *player) P_MovePlayer(player); } +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif + if (!player->mo) return; // P_MovePlayer removed player->mo. From a812ddd88e5642b5a0033f062e8478d2fd2c8f3a Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 14 Dec 2019 19:04:29 -0600 Subject: [PATCH 058/126] Fix turn-to-input jerk when braking sideways --- src/g_game.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 6b5eff4ad..b91e0a797 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1514,6 +1514,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (camadjustfactor) { fixed_t sine = FINESINE((R_PointToAngle2(0, 0, player->rmomx, player->rmomy) - localangle)>>ANGLETOFINESHIFT); + + if ((sine > 0) == (cmd->sidemove > 0)) + sine = 0; // Prevent jerking right when braking from going left, or vice versa + fixed_t factor = min(40, FixedMul(player->speed, abs(sine))*2 / FRACUNIT); *myangle -= cmd->sidemove * factor * camadjustfactor; From 0702e366b61a1da58ba8024719349c8daffc9eef Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 14 Dec 2019 19:17:41 -0600 Subject: [PATCH 059/126] Allow setting center view to a toggle --- src/d_netcmd.c | 2 ++ src/g_game.c | 30 +++++++++++++++++++++++++++--- src/g_game.h | 2 +- src/m_menu.c | 18 ++++++++++-------- 4 files changed, 40 insertions(+), 12 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index d05c5cc45..3574f2e90 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -838,6 +838,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_cam_turnfacingspindash[1]); CV_RegisterVar(&cv_cam_turnfacinginput[0]); CV_RegisterVar(&cv_cam_turnfacinginput[1]); + CV_RegisterVar(&cv_cam_centertoggle[0]); + CV_RegisterVar(&cv_cam_centertoggle[1]); CV_RegisterVar(&cv_cam_lockedinput[0]); CV_RegisterVar(&cv_cam_lockedinput[1]); CV_RegisterVar(&cv_cam_lockonboss[0]); diff --git a/src/g_game.c b/src/g_game.c index b91e0a797..6fed500b3 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -421,8 +421,13 @@ consvar_t cv_cam_turnfacinginput[2] = { {"cam2_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; -static CV_PossibleValue_t lockedinput_cons_t[] = {{0, "Strafe"}, {1, "Turn"}, {0, NULL}}; +static CV_PossibleValue_t centertoggle_cons_t[] = {{0, "Hold"}, {1, "Toggle"}, {0, NULL}}; +consvar_t cv_cam_centertoggle[2] = { + {"cam_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, +}; +static CV_PossibleValue_t lockedinput_cons_t[] = {{0, "Strafe"}, {1, "Turn"}, {0, NULL}}; consvar_t cv_cam_lockedinput[2] = { {"cam_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam2_lockedinput", "Strafe", CV_SAVE, lockedinput_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, @@ -436,7 +441,6 @@ static CV_PossibleValue_t lockedassist_cons_t[] = { {LOCK_BOSS|LOCK_ENEMY|LOCK_INTERESTS, "Full"}, {0, NULL} }; - consvar_t cv_cam_lockonboss[2] = { {"cam_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam2_lockaimassist", "Bosses", CV_SAVE, lockedassist_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, @@ -1057,8 +1061,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) static boolean keyboard_look[2]; // true if lookup/down using keyboard static boolean resetdown[2]; // don't cam reset every frame static boolean joyaiming[2]; // check the last frame's value if we need to reset the camera + + // simple mode vars static boolean zchange[2]; // only switch z targets once per press static fixed_t tta_factor[2] = {FRACUNIT, FRACUNIT}; // disables turn-to-angle when manually turning camera until movement happens + boolean centerviewdown = false; + UINT8 forplayer = ssplayer-1; if (ssplayer == 1) @@ -1291,7 +1299,23 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (PLAYERINPUTDOWN(ssplayer, gc_use) || (usejoystick && axis > 0)) cmd->buttons |= BT_USE; - if (PLAYERINPUTDOWN(ssplayer, gc_centerview)) + // Centerview can be a toggle in simple mode! + { + static boolean last_centerviewdown[2], centerviewhold[2]; // detect taps for toggle behavior + boolean down = PLAYERINPUTDOWN(ssplayer, gc_centerview); + + if (!(abilitydirection && cv_cam_centertoggle[forplayer].value)) + centerviewdown = down; + else + { + if (down && !last_centerviewdown[forplayer]) + centerviewhold[forplayer] = !centerviewhold[forplayer]; + last_centerviewdown[forplayer] = down; + centerviewdown = centerviewhold[forplayer]; + } + } + + if (centerviewdown) { if (abilitydirection && !ticcmd_centerviewdown[forplayer]) { diff --git a/src/g_game.h b/src/g_game.h index 0a018e253..8ba3bc373 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -79,7 +79,7 @@ extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_g // hi here's some new controls extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacing[2], cv_cam_turnfacingability[2], cv_cam_turnfacingspindash[2], cv_cam_turnfacinginput[2], - cv_cam_lockedinput[2], cv_cam_lockonboss[2]; + cv_cam_centertoggle[2], cv_cam_lockedinput[2], cv_cam_lockonboss[2]; typedef enum { diff --git a/src/m_menu.c b/src/m_menu.c index bfe118af1..fb1737f10 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1238,11 +1238,12 @@ static menuitem_t OP_CameraExtendedOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 85}, {IT_HEADER, NULL, "Locked Camera Options", NULL, 95}, - {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[0], 100}, - {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[0], 105}, + {IT_STRING | IT_CVAR, NULL, "Lock button behavior", &cv_cam_centertoggle[0], 100}, + {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[0], 105}, + {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[0], 110}, - {IT_HEADER, NULL, "Display Options", NULL, 115}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 120}, + {IT_HEADER, NULL, "Display Options", NULL, 120}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 125}, }; static menuitem_t OP_Camera2ExtendedOptionsMenu[] = @@ -1267,11 +1268,12 @@ static menuitem_t OP_Camera2ExtendedOptionsMenu[] = {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 85}, {IT_HEADER, NULL, "Locked Camera Options", NULL, 95}, - {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[1], 100}, - {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[1], 105}, + {IT_STRING | IT_CVAR, NULL, "Lock button behavior", &cv_cam_centertoggle[1], 100}, + {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[1], 105}, + {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[1], 110}, - {IT_HEADER, NULL, "Display Options", NULL, 115}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 120}, + {IT_HEADER, NULL, "Display Options", NULL, 120}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 125}, }; static menuitem_t OP_VideoOptionsMenu[] = From 7fd2153c0887c3b35d1e776860b5f0b6ba88258b Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 14 Dec 2019 19:20:19 -0600 Subject: [PATCH 060/126] Realign camera options menu options --- src/m_menu.c | 104 +++++++++++++++++++++++++-------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index fb1737f10..89c0b04bd 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1183,97 +1183,97 @@ static menuitem_t OP_Mouse2OptionsMenu[] = static menuitem_t OP_CameraOptionsMenu[] = { {IT_HEADER, NULL, "General Toggles", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam , 5}, - {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam , 10}, - {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam_orbit , 15}, - {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 20}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam , 6}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam , 11}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam_orbit , 16}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 21}, {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 35}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 40}, - {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 45}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam_rotspeed, 50}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 41}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 46}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam_rotspeed, 51}, {IT_HEADER, NULL, "Display Options", NULL, 60}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 65}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 66}, }; static menuitem_t OP_Camera2OptionsMenu[] = { {IT_HEADER, NULL, "General Toggles", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam2 , 5}, - {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam2 , 10}, - {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam2_orbit , 15}, - {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 20}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam2 , 6}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam2 , 11}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam2_orbit , 16}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 21}, {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 35}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 40}, - {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 45}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam2_rotspeed, 50}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 41}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 46}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam2_rotspeed, 51}, {IT_HEADER, NULL, "Display Options", NULL, 60}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 65}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 66}, }; static menuitem_t OP_CameraExtendedOptionsMenu[] = { {IT_HEADER, NULL, "General Toggles", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam , 5}, - {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam , 10}, - {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam_orbit , 15}, - {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 20}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam , 6}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam , 11}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam_orbit , 16}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 21}, {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 35}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 40}, - {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 45}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam_rotspeed, 50}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 41}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam_speed, 46}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam_rotspeed, 51}, {IT_HEADER, NULL, "Automatic Camera Options", NULL, 60}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[0], 65}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[0], 70}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 75}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[0], 80}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 85}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[0], 66}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[0], 71}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[0], 76}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[0], 81}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[0], 86}, {IT_HEADER, NULL, "Locked Camera Options", NULL, 95}, - {IT_STRING | IT_CVAR, NULL, "Lock button behavior", &cv_cam_centertoggle[0], 100}, - {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[0], 105}, - {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[0], 110}, + {IT_STRING | IT_CVAR, NULL, "Lock button behavior", &cv_cam_centertoggle[0], 101}, + {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[0], 106}, + {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[0], 111}, {IT_HEADER, NULL, "Display Options", NULL, 120}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 125}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair, 126}, }; static menuitem_t OP_Camera2ExtendedOptionsMenu[] = { {IT_HEADER, NULL, "General Toggles", NULL, 0}, - {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam2 , 5}, - {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam2 , 10}, - {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam2_orbit , 15}, - {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 20}, + {IT_STRING | IT_CVAR, NULL, "Third-person Camera" , &cv_chasecam2 , 6}, + {IT_STRING | IT_CVAR, NULL, "Flip Camera with Gravity" , &cv_flipcam2 , 11}, + {IT_STRING | IT_CVAR, NULL, "Orbital Looking" , &cv_cam2_orbit , 16}, + {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 21}, {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 35}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 40}, - {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 45}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam2_rotspeed, 50}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 41}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Speed", &cv_cam2_speed, 46}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Rotation Speed", &cv_cam2_rotspeed, 51}, {IT_HEADER, NULL, "Automatic Camera Options", NULL, 60}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[1], 65}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[1], 70}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 75}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[1], 80}, - {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 85}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Shift to player angle", &cv_cam_shiftfacing[1], 66}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to player angle", &cv_cam_turnfacing[1], 71}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to ability", &cv_cam_turnfacingability[1], 76}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to spindash", &cv_cam_turnfacingspindash[1], 81}, + {IT_STRING | IT_CVAR | IT_CV_SLIDER, NULL, "Turn to input", &cv_cam_turnfacinginput[1], 86}, {IT_HEADER, NULL, "Locked Camera Options", NULL, 95}, - {IT_STRING | IT_CVAR, NULL, "Lock button behavior", &cv_cam_centertoggle[1], 100}, - {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[1], 105}, - {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[1], 110}, + {IT_STRING | IT_CVAR, NULL, "Lock button behavior", &cv_cam_centertoggle[1], 101}, + {IT_STRING | IT_CVAR, NULL, "Sideways movement", &cv_cam_lockedinput[1], 106}, + {IT_STRING | IT_CVAR, NULL, "Targeting assist", &cv_cam_lockonboss[1], 111}, {IT_HEADER, NULL, "Display Options", NULL, 120}, - {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 125}, + {IT_STRING | IT_CVAR, NULL, "Crosshair", &cv_crosshair2, 126}, }; static menuitem_t OP_VideoOptionsMenu[] = From 3db7e48c73701dff825878cf881c5c49ae555eed Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 14 Dec 2019 19:21:11 -0600 Subject: [PATCH 061/126] [POTENTIALLY RISKY] Show target arrow above lock-on target My judgement on "is this netgame-safe" is "Gunslinger's targeting spawns this only for the local player, so maybe". --- src/g_game.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index 6fed500b3..f0275bbf4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1371,6 +1371,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (newtarget) P_SetTarget(&ticcmd_ztargetfocus[forplayer], newtarget); + // I assume this is netgame-safe because gunslinger spawns this for only the local player...... *sweats intensely* + newtarget = P_SpawnMobj(ticcmd_ztargetfocus[forplayer]->x, ticcmd_ztargetfocus[forplayer]->y, ticcmd_ztargetfocus[forplayer]->z, MT_LOCKON); // positioning, flip handled in P_SceneryThinker + P_SetTarget(&newtarget->target, ticcmd_ztargetfocus[forplayer]); + if (P_AproxDistance( player->mo->x - ticcmd_ztargetfocus[forplayer]->x, player->mo->y - ticcmd_ztargetfocus[forplayer]->y From fce6ea03842e8ad0b9d90dbe3229dcbc327e3d76 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sat, 14 Dec 2019 19:32:49 -0600 Subject: [PATCH 062/126] Fixed mistake with #endif placement --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 22f92791a..3baf8cd04 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11422,8 +11422,8 @@ void P_PlayerThink(player_t *player) { #ifdef HAVE_BLUA LUAh_PlayerThink(player); - return; #endif + return; } } } From a885380e8a8a5650ce8a0c5a10be48819dc7b872 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 14 Dec 2019 19:41:54 -0600 Subject: [PATCH 063/126] Add analog deadzone option separate from digital deadzones --- src/d_netcmd.c | 2 ++ src/g_game.c | 14 ++++++++------ src/g_game.h | 4 ++-- src/m_menu.c | 6 ++++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3574f2e90..165c89b58 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -776,6 +776,8 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_firenaxis2); CV_RegisterVar(&cv_deadzone); CV_RegisterVar(&cv_deadzone2); + CV_RegisterVar(&cv_digitaldeadzone); + CV_RegisterVar(&cv_digitaldeadzone2); // filesrch.c CV_RegisterVar(&cv_addons_option); diff --git a/src/g_game.c b/src/g_game.c index f0275bbf4..d5cd0c991 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -468,7 +468,8 @@ consvar_t cv_jumpaxis = {"joyaxis_jump", "None", CV_SAVE, joyaxis_cons_t, NULL, consvar_t cv_spinaxis = {"joyaxis_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_fireaxis = {"joyaxis_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_firenaxis = {"joyaxis_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_deadzone = {"joy_deadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_deadzone = {"joy_deadzone", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_digitaldeadzone = {"joy_digdeadzone", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_turnaxis2 = {"joyaxis2_turn", "X-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_moveaxis2 = {"joyaxis2_move", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -478,7 +479,8 @@ consvar_t cv_jumpaxis2 = {"joyaxis2_jump", "None", CV_SAVE, joyaxis_cons_t, NULL consvar_t cv_spinaxis2 = {"joyaxis2_spin", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_fireaxis2 = {"joyaxis2_fire", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_firenaxis2 = {"joyaxis2_firenormal", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_deadzone2 = {"joy_deadzone2", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_deadzone2 = {"joy_deadzone2", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_digitaldeadzone2 = {"joy_digdeadzone2", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; #ifdef SEENAMES player_t *seenplayer; // player we're aiming at right now @@ -936,9 +938,9 @@ static INT32 JoyAxis(axis_input_e axissel) retaxis = -JOYAXISRANGE; if (retaxis > (+JOYAXISRANGE)) retaxis = +JOYAXISRANGE; - if (!Joystick.bGamepadStyle && axissel < AXISDEAD) + if (!Joystick.bGamepadStyle) { - const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_deadzone.value) >> FRACBITS; + const INT32 jdeadzone = ((JOYAXISRANGE-1) * ((axissel < AXISDEAD) ? cv_deadzone.value : cv_digitaldeadzone.value)) >> FRACBITS; if (-jdeadzone < retaxis && retaxis < jdeadzone) return 0; } @@ -1009,9 +1011,9 @@ static INT32 Joy2Axis(axis_input_e axissel) retaxis = -JOYAXISRANGE; if (retaxis > (+JOYAXISRANGE)) retaxis = +JOYAXISRANGE; - if (!Joystick2.bGamepadStyle && axissel < AXISDEAD) + if (!Joystick2.bGamepadStyle) { - const INT32 jdeadzone = ((JOYAXISRANGE-1) * cv_deadzone2.value) >> FRACBITS; + const INT32 jdeadzone = ((JOYAXISRANGE-1) * ((axissel < AXISDEAD) ? cv_deadzone2.value : cv_digitaldeadzone2.value)) >> FRACBITS; if (-jdeadzone < retaxis && retaxis < jdeadzone) return 0; } diff --git a/src/g_game.h b/src/g_game.h index 8ba3bc373..5f094fbda 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -72,8 +72,8 @@ extern consvar_t cv_useranalog, cv_useranalog2; extern consvar_t cv_analog, cv_analog2; extern consvar_t cv_directionchar, cv_directionchar2; extern consvar_t cv_autobrake, cv_autobrake2; -extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis,cv_deadzone; -extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2,cv_deadzone2; +extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis,cv_deadzone,cv_digitaldeadzone; +extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2,cv_deadzone2,cv_digitaldeadzone2; extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; // hi here's some new controls diff --git a/src/m_menu.c b/src/m_menu.c index 89c0b04bd..a6a933114 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1128,7 +1128,8 @@ static menuitem_t OP_Joystick1Menu[] = {IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook, 120}, {IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook, 130}, - {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Deadzone", &cv_deadzone, 140}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Analog Deadzone", &cv_deadzone, 140}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Digital Deadzone", &cv_digitaldeadzone, 150}, }; static menuitem_t OP_Joystick2Menu[] = @@ -1145,7 +1146,8 @@ static menuitem_t OP_Joystick2Menu[] = {IT_STRING | IT_CVAR, NULL, "First-Person Vert-Look", &cv_alwaysfreelook2,120}, {IT_STRING | IT_CVAR, NULL, "Third-Person Vert-Look", &cv_chasefreelook2, 130}, - {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Deadzone", &cv_deadzone2,140}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Analog Deadzone", &cv_deadzone2,140}, + {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Digital Deadzone", &cv_digitaldeadzone2,150}, }; static menuitem_t OP_JoystickSetMenu[1+MAX_JOYSTICKS]; From 1f88c70d6ad77fbba9f8a994a30a9eb4ff18d596 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sun, 15 Dec 2019 13:33:21 -0600 Subject: [PATCH 064/126] Fix RVZ autocam AGAIN --- src/g_game.c | 2 +- src/p_user.c | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index d5cd0c991..bd88c5dd5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1606,7 +1606,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (camadjustfactor) { - INT32 anglediff = ((player->pflags & PF_SPINNING) ? player->drawangle : (cmd->angleturn<<16)) + drawangleoffset - *myangle; + INT32 anglediff = ((player->pflags & PF_SPINNING) ? player->drawangle + drawangleoffset : (cmd->angleturn<<16)) - *myangle; if (alt) { diff --git a/src/p_user.c b/src/p_user.c index 93c3c2ef0..d6db2e26f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -10018,16 +10018,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall UINT8 forplayer = (thiscam == &camera) ? 0 : 1; fixed_t shift = FixedMul(FINESINE((player->mo->angle - angle) >> ANGLETOFINESHIFT), cv_cam_shiftfacing[forplayer].value); - if (player->powers[pw_carry] == CR_ROLLOUT) - shift = -shift; - if (player->powers[pw_carry] == CR_NIGHTSMODE) { fixed_t cos = FINECOSINE((angle_t) (player->flyangle * ANG1)>>ANGLETOFINESHIFT); shift = FixedMul(shift, min(FRACUNIT, player->speed*abs(cos)/6000)); + shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>2)); } - - if (ticcmd_centerviewdown[(thiscam == &camera) ? 0 : 1]) + else if (ticcmd_centerviewdown[(thiscam == &camera) ? 0 : 1]) shift = FixedMul(camsideshift[forplayer], FRACUNIT-camspeed); else shift += FixedMul(camsideshift[forplayer] - shift, FRACUNIT-(camspeed>>3)); From fc70164f93722414057e728e5de477f75ee6f131 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Tue, 17 Dec 2019 18:41:26 -0600 Subject: [PATCH 065/126] Don't execute LUAh_PlayerThink(player) for respawning bots --- src/p_user.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 3baf8cd04..6682c128b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11313,12 +11313,7 @@ void P_PlayerThink(player_t *player) player->playerstate = PST_REBORN; } if (player->playerstate == PST_REBORN) - { -#ifdef HAVE_BLUA - LUAh_PlayerThink(player); -#endif return; - } } #ifdef SEENAMES From 3fc1069082fa3cc60e2b1929e0a25571007e1ad9 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Tue, 17 Dec 2019 19:20:46 -0600 Subject: [PATCH 066/126] Don't run the LUAh_PlayerThink function if the time ran out in Race or Competition --- src/p_user.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 6682c128b..0ec02c3f4 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11414,12 +11414,7 @@ void P_PlayerThink(player_t *player) player->lives = 0; if (player->playerstate == PST_DEAD) - { -#ifdef HAVE_BLUA - LUAh_PlayerThink(player); -#endif return; - } } } From c1815bfe11ee173264b8419e3f5745184c5e6f4d Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 19 Dec 2019 15:07:28 -0600 Subject: [PATCH 067/126] Revert "Don't execute LUAh_PlayerThink(player) for respawning bots" This reverts commit fc70164f93722414057e728e5de477f75ee6f131. --- src/p_user.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 0ec02c3f4..83e28ece3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11313,7 +11313,12 @@ void P_PlayerThink(player_t *player) player->playerstate = PST_REBORN; } if (player->playerstate == PST_REBORN) + { +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif return; + } } #ifdef SEENAMES From e82b3174519d76c4698ef1ee8162e70d4f8d14ef Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 19 Dec 2019 15:07:34 -0600 Subject: [PATCH 068/126] Revert "Don't run the LUAh_PlayerThink function if the time ran out in Race or Competition" This reverts commit 3fc1069082fa3cc60e2b1929e0a25571007e1ad9. --- src/p_user.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 83e28ece3..3baf8cd04 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11419,7 +11419,12 @@ void P_PlayerThink(player_t *player) player->lives = 0; if (player->playerstate == PST_DEAD) + { +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif return; + } } } From 9f82cdb4010cd38994cfc09e5b75212085050230 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 19 Dec 2019 16:41:25 -0600 Subject: [PATCH 069/126] Added CalculateCamera Hook --- src/lua_hook.h | 2 ++ src/lua_hooklib.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/p_user.c | 33 ++++++++++++++++++++------------- 3 files changed, 63 insertions(+), 13 deletions(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 073773f52..4b31fda28 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -52,6 +52,7 @@ enum hook { hook_PlayerQuit, hook_IntermissionThinker, hook_PlayerThink, + hook_CalculateCamera, hook_MAX // last hook }; @@ -95,5 +96,6 @@ UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_Player void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting void LUAh_IntermissionThinker(void); // Hook for Y_Ticker #define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink +boolean LUAh_CalculateCamera(player_t *player, camera_t *camera); // Hook for P_PlayerAfterThink Camera calculations #endif diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 30ab27da1..b7e544ed0 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -63,6 +63,7 @@ const char *const hookNames[hook_MAX+1] = { "PlayerQuit", "IntermissionThinker", "PlayerThink", + "CalculateCamera", NULL }; @@ -207,6 +208,7 @@ static int lib_addHook(lua_State *L) case hook_ShieldSpawn: case hook_ShieldSpecial: case hook_PlayerThink: + case hook_CalculateCamera: lastp = &playerhooks; break; case hook_LinedefExecute: @@ -1348,4 +1350,43 @@ void LUAh_IntermissionThinker(void) } } +boolean LUAh_CalculateCamera(player_t *player, camera_t *camera) +{ + hook_p hookp; + boolean hooked; + if (!gL || !(hooksAvailable[hook_CalculateCamera/8] & (1<<(hook_CalculateCamera%8)))) + return 0; + + lua_settop(gL, 0); + + for (hookp = playerhooks; hookp; hookp = hookp->next) + { + if (hookp->type != hook_CalculateCamera) + continue; + + if (lua_gettop(gL) == 0) + { + LUA_PushUserdata(gL, player, META_PLAYER); + LUA_PushUserdata(gL, camera, META_CAMERA); + } + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + lua_pushvalue(gL, -3); + lua_pushvalue(gL, -3); + if (lua_pcall(gL, 2, 1, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + continue; + } + if (lua_toboolean(gL, -1)) + hooked = true; + lua_pop(gL, 1); + } + + lua_settop(gL, 0); + return hooked; +} + #endif diff --git a/src/p_user.c b/src/p_user.c index 3baf8cd04..6eedec10f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12626,22 +12626,29 @@ void P_PlayerAfterThink(player_t *player) if (thiscam) { - if (!thiscam->chase) // bob view only if looking through the player's eyes - { - P_CalcHeight(player); - P_CalcPostImg(player); - } +#ifdef HAVE_BLUA + if (LUAh_CalculateCamera(player, thiscam)) + {;} else +#endif { - // defaults to make sure 1st person cam doesn't do anything weird on startup - player->deltaviewheight = 0; - player->viewheight = FixedMul(41*player->height/48, player->mo->scale); - if (player->mo->eflags & MFE_VERTICALFLIP) - player->viewz = player->mo->z + player->mo->height - player->viewheight; + if (!thiscam->chase) // bob view only if looking through the player's eyes + { + P_CalcHeight(player); + P_CalcPostImg(player); + } else - player->viewz = player->mo->z + player->viewheight; - if (server || addedtogame) - P_MoveChaseCamera(player, thiscam, false); // calculate the camera movement + { + // defaults to make sure 1st person cam doesn't do anything weird on startup + player->deltaviewheight = 0; + player->viewheight = FixedMul(41*player->height/48, player->mo->scale); + if (player->mo->eflags & MFE_VERTICALFLIP) + player->viewz = player->mo->z + player->mo->height - player->viewheight; + else + player->viewz = player->mo->z + player->viewheight; + if (server || addedtogame) + P_MoveChaseCamera(player, thiscam, false); // calculate the camera movement + } } } From c1465c5accd1844db55b86696f062879aa24f313 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 19 Dec 2019 17:17:17 -0600 Subject: [PATCH 070/126] Fix CalculateCamera compiling error --- src/lua_hook.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua_hook.h b/src/lua_hook.h index 4b31fda28..6bdcada24 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -14,6 +14,7 @@ #include "r_defs.h" #include "d_player.h" +#include "p_local.h" enum hook { hook_NetVars=0, From f5c2341f59a98dfc2ac9009cc3bbb69fde160005 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 19 Dec 2019 17:21:46 -0600 Subject: [PATCH 071/126] Revert "Fix CalculateCamera compiling error" This reverts commit c1465c5accd1844db55b86696f062879aa24f313. --- src/lua_hook.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 6bdcada24..4b31fda28 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -14,7 +14,6 @@ #include "r_defs.h" #include "d_player.h" -#include "p_local.h" enum hook { hook_NetVars=0, From 124a0754a60e896cfd86546c37ac7350d2937e34 Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Thu, 19 Dec 2019 17:21:55 -0600 Subject: [PATCH 072/126] Revert "Added CalculateCamera Hook" This reverts commit 9f82cdb4010cd38994cfc09e5b75212085050230. --- src/lua_hook.h | 2 -- src/lua_hooklib.c | 41 ----------------------------------------- src/p_user.c | 35 ++++++++++++++--------------------- 3 files changed, 14 insertions(+), 64 deletions(-) diff --git a/src/lua_hook.h b/src/lua_hook.h index 4b31fda28..073773f52 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -52,7 +52,6 @@ enum hook { hook_PlayerQuit, hook_IntermissionThinker, hook_PlayerThink, - hook_CalculateCamera, hook_MAX // last hook }; @@ -96,6 +95,5 @@ UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_Player void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting void LUAh_IntermissionThinker(void); // Hook for Y_Ticker #define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink -boolean LUAh_CalculateCamera(player_t *player, camera_t *camera); // Hook for P_PlayerAfterThink Camera calculations #endif diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index b7e544ed0..30ab27da1 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -63,7 +63,6 @@ const char *const hookNames[hook_MAX+1] = { "PlayerQuit", "IntermissionThinker", "PlayerThink", - "CalculateCamera", NULL }; @@ -208,7 +207,6 @@ static int lib_addHook(lua_State *L) case hook_ShieldSpawn: case hook_ShieldSpecial: case hook_PlayerThink: - case hook_CalculateCamera: lastp = &playerhooks; break; case hook_LinedefExecute: @@ -1350,43 +1348,4 @@ void LUAh_IntermissionThinker(void) } } -boolean LUAh_CalculateCamera(player_t *player, camera_t *camera) -{ - hook_p hookp; - boolean hooked; - if (!gL || !(hooksAvailable[hook_CalculateCamera/8] & (1<<(hook_CalculateCamera%8)))) - return 0; - - lua_settop(gL, 0); - - for (hookp = playerhooks; hookp; hookp = hookp->next) - { - if (hookp->type != hook_CalculateCamera) - continue; - - if (lua_gettop(gL) == 0) - { - LUA_PushUserdata(gL, player, META_PLAYER); - LUA_PushUserdata(gL, camera, META_CAMERA); - } - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - lua_pushvalue(gL, -3); - lua_pushvalue(gL, -3); - if (lua_pcall(gL, 2, 1, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - continue; - } - if (lua_toboolean(gL, -1)) - hooked = true; - lua_pop(gL, 1); - } - - lua_settop(gL, 0); - return hooked; -} - #endif diff --git a/src/p_user.c b/src/p_user.c index d42b08c5f..c2834f777 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -12626,29 +12626,22 @@ void P_PlayerAfterThink(player_t *player) if (thiscam) { -#ifdef HAVE_BLUA - if (LUAh_CalculateCamera(player, thiscam)) - {;} - else -#endif + if (!thiscam->chase) // bob view only if looking through the player's eyes { - if (!thiscam->chase) // bob view only if looking through the player's eyes - { - P_CalcHeight(player); - P_CalcPostImg(player); - } + P_CalcHeight(player); + P_CalcPostImg(player); + } + else + { + // defaults to make sure 1st person cam doesn't do anything weird on startup + player->deltaviewheight = 0; + player->viewheight = FixedMul(41*player->height/48, player->mo->scale); + if (player->mo->eflags & MFE_VERTICALFLIP) + player->viewz = player->mo->z + player->mo->height - player->viewheight; else - { - // defaults to make sure 1st person cam doesn't do anything weird on startup - player->deltaviewheight = 0; - player->viewheight = FixedMul(41*player->height/48, player->mo->scale); - if (player->mo->eflags & MFE_VERTICALFLIP) - player->viewz = player->mo->z + player->mo->height - player->viewheight; - else - player->viewz = player->mo->z + player->viewheight; - if (server || addedtogame) - P_MoveChaseCamera(player, thiscam, false); // calculate the camera movement - } + player->viewz = player->mo->z + player->viewheight; + if (server || addedtogame) + P_MoveChaseCamera(player, thiscam, false); // calculate the camera movement } } From 745cced08e560475da66795bc119b65f4128a60a Mon Sep 17 00:00:00 2001 From: Zachary McAlpin Date: Sat, 28 Dec 2019 17:40:47 -0600 Subject: [PATCH 073/126] Execute LUAh_PlayerThink(player) at the end if the player has a valid mobj_t object --- src/p_user.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 1c9d1c051..b26615b46 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11700,12 +11700,13 @@ void P_PlayerThink(player_t *player) P_MovePlayer(player); } -#ifdef HAVE_BLUA - LUAh_PlayerThink(player); -#endif - if (!player->mo) + { +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif return; // P_MovePlayer removed player->mo. + } // deez New User eXperiences. { @@ -12137,6 +12138,11 @@ void P_PlayerThink(player_t *player) dashmode = 0; } #undef dashmode + +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif + /* // Colormap verification { From 8a15e9abc4b36a9c5af0e0f81c7aeea8096ee666 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 29 Dec 2019 20:46:43 -0800 Subject: [PATCH 074/126] Bro player 2 can't use the console --- src/lua_consolelib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 58e720c85..d6c532b65 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -130,7 +130,6 @@ void COM_Lua_f(void) lua_pop(gL, 1); // pop command info table return; // can't execute splitscreen command without player 2! } - playernum = secondarydisplayplayer; } if (netgame) From dc757f3086591729e24772cb213cd33c631fc432 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 29 Dec 2019 20:59:48 -0800 Subject: [PATCH 075/126] Fuck magic numbers; COM_ flags for Lua commands! --- src/command.h | 7 +++++++ src/dehacked.c | 4 ++++ src/lua_consolelib.c | 15 +++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/command.h b/src/command.h index 51e161cd0..7078c333a 100644 --- a/src/command.h +++ b/src/command.h @@ -20,6 +20,13 @@ // Command buffer & command execution //=================================== +/* Lua command registration flags. */ +enum +{ + COM_ADMIN = 1, + COM_SPLITSCREEN = 2, +}; + typedef void (*com_func_t)(void); void COM_AddCommand(const char *name, com_func_t func); diff --git a/src/dehacked.c b/src/dehacked.c index 4c90211cc..7d473bd51 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9732,6 +9732,10 @@ struct { {"BT_CUSTOM2",BT_CUSTOM2}, // Lua customizable {"BT_CUSTOM3",BT_CUSTOM3}, // Lua customizable + // Lua command registration flags + {"COM_ADMIN",COM_ADMIN}, + {"COM_SPLITSCREEN",COM_SPLITSCREEN}, + // cvflags_t {"CV_SAVE",CV_SAVE}, {"CV_CALL",CV_CALL}, diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index d6c532b65..b861a4ad7 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -118,12 +118,12 @@ void COM_Lua_f(void) lua_rawgeti(gL, -1, 2); // push flags from command info table if (lua_isboolean(gL, -1)) - flags = (lua_toboolean(gL, -1) ? 1 : 0); + flags = (lua_toboolean(gL, -1) ? COM_ADMIN : 0); else flags = (UINT8)lua_tointeger(gL, -1); lua_pop(gL, 1); // pop flags - if (flags & 2) // flag 2: splitscreen player command. + if (flags & COM_SPLITSCREEN) // flag 2: splitscreen player command. { if (!splitscreen) { @@ -137,7 +137,7 @@ void COM_Lua_f(void) UINT8 argc; lua_pop(gL, 1); // pop command info table - if (flags & 1 && !server && !IsPlayerAdmin(playernum)) // flag 1: only server/admin can use this command. + if (flags & COM_ADMIN && !server && !IsPlayerAdmin(playernum)) // flag 1: only server/admin can use this command. { CONS_Printf(M_GetText("Only the server or a remote admin can use this.\n")); return; @@ -191,7 +191,14 @@ static int lib_comAddCommand(lua_State *L) if (lua_gettop(L) >= 3) { // For the third argument, only take a boolean or a number. lua_settop(L, 3); - if (lua_type(L, 3) != LUA_TBOOLEAN) + if (lua_type(L, 3) == LUA_TBOOLEAN) + { + CONS_Alert(CONS_WARNING, + "Using a boolean is deprecated and will be removed.\n" + "Use \"COM_\" flags instead.\n" + ); + } + else luaL_checktype(L, 3, LUA_TNUMBER); } else From 6546e3c3bc38415150bd3a2c405a465fe67509a0 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 29 Dec 2019 21:02:42 -0800 Subject: [PATCH 076/126] No. --- src/lua_consolelib.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index b861a4ad7..cbfa42f87 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -157,10 +157,7 @@ void COM_Lua_f(void) WRITEUINT8(p, argc); for (i = 0; i < argc; i++) WRITESTRINGN(p, COM_Argv(i), 255); - if (flags & 2) - SendNetXCmd2(XD_LUACMD, buf, p-buf); - else - SendNetXCmd(XD_LUACMD, buf, p-buf); + SendNetXCmd(XD_LUACMD, buf, p-buf); free(buf); return; } From 802ef0aba1ff9c5dab5b826b5393566b3b5ac40e Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 29 Dec 2019 21:07:28 -0800 Subject: [PATCH 077/126] COM_LOCAL makes your commands NetXCmd free, FUCK NetXCmd --- src/command.h | 1 + src/dehacked.c | 1 + src/lua_consolelib.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/command.h b/src/command.h index 7078c333a..554c1131b 100644 --- a/src/command.h +++ b/src/command.h @@ -25,6 +25,7 @@ enum { COM_ADMIN = 1, COM_SPLITSCREEN = 2, + COM_LOCAL = 4, }; typedef void (*com_func_t)(void); diff --git a/src/dehacked.c b/src/dehacked.c index 7d473bd51..b3a8ed1dd 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9735,6 +9735,7 @@ struct { // Lua command registration flags {"COM_ADMIN",COM_ADMIN}, {"COM_SPLITSCREEN",COM_SPLITSCREEN}, + {"COM_LOCAL",COM_LOCAL}, // cvflags_t {"CV_SAVE",CV_SAVE}, diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index cbfa42f87..f40b63ac6 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -132,7 +132,7 @@ void COM_Lua_f(void) } } - if (netgame) + if (netgame && !( flags & COM_LOCAL ))/* don't send local commands */ { // Send the command through the network UINT8 argc; lua_pop(gL, 1); // pop command info table From 65921c170207d2e4be1bd2bbfd43f7225d1e0fe9 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 29 Dec 2019 21:09:07 -0800 Subject: [PATCH 078/126] Improve COM_AddCommand boolean deprecated warning --- src/lua_consolelib.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index f40b63ac6..4e397fb32 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -191,8 +191,9 @@ static int lib_comAddCommand(lua_State *L) if (lua_type(L, 3) == LUA_TBOOLEAN) { CONS_Alert(CONS_WARNING, - "Using a boolean is deprecated and will be removed.\n" - "Use \"COM_\" flags instead.\n" + "Using a boolean for admin commands is " + "deprecated and will be removed.\n" + "Use \"COM_ADMIN\" instead.\n" ); } else From f4e7227e112af4b9d896b6a383c03faf16fd8a6e Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 11:01:56 -0600 Subject: [PATCH 079/126] Fix compilation errors --- src/g_game.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 46495ecd6..008fc7f1b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -459,6 +459,9 @@ typedef enum AXISMOVE, AXISLOOK, AXISSTRAFE, + + AXISDIGITAL, // axes below this use digital deadzone + AXISJUMP, AXISSPIN, AXISFIRE, @@ -1222,7 +1225,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) *myaiming = 0; joyaiming[forplayer] = thisjoyaiming; - turnaxis = JPlayerJoyAxis(ssplayer, AXISTURN); + turnaxis = PlayerJoyAxis(ssplayer, AXISTURN); if (strafeisturn) turnaxis += PlayerJoyAxis(ssplayer, AXISSTRAFE); lookaxis = PlayerJoyAxis(ssplayer, AXISLOOK); @@ -1301,9 +1304,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (turnright || turnleft || abs(cmd->angleturn) > angleturn[2]) tta_factor[forplayer] = 0; // suspend turn to angle - - // Make rotspeed affect turning speed :) - cmd->angleturn = (cmd->angleturn * (ssplayer == 1 ? cv_cam_rotspeed.value : cv_cam2_rotspeed.value)) / 10; } strafeaxis = strafeisturn ? 0 : PlayerJoyAxis(ssplayer, AXISSTRAFE); From ebbe5938a8bc5ecb75b4179acacee7e28c149b2c Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 11:07:29 -0600 Subject: [PATCH 080/126] Fix tailsbot flying weird with P1=standard P2=simple controls --- src/g_game.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 008fc7f1b..2a4e67d7b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1181,7 +1181,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) mly = &mlook2y; G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver } - abilitydirection = cv_abilitydirection[forplayer].value; + abilitydirection = cv_abilitydirection[player->bot ? 0 : forplayer].value; strafeisturn = abilitydirection && ticcmd_centerviewdown[forplayer] && ((cv_cam_lockedinput[forplayer].value && !ticcmd_ztargetfocus[forplayer]) || (player->pflags & PF_STARTDASH)) && @@ -1608,6 +1608,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver B_BuildTiccmd(player, cmd); + } } From 7fa9eed5735b9192fe9f1036c2b2da62277c14ab Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 11:22:54 -0600 Subject: [PATCH 081/126] Fix camera reset snap in simple controls --- src/p_user.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index f5a8208a3..7c7f94863 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9781,7 +9781,13 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->y = y; thiscam->z = z; - if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value)) + if ((thiscam == &camera && cv_abilitydirection[0].value) + || (thiscam == &camera2 && cv_abilitydirection[1].value)) + { + thiscam->angle = (thiscam == &camera) ? localangle : localangle2; + thiscam->aiming = (thiscam == &camera) ? localaiming : localaiming2; + } + else if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value)) && !(thiscam == &camera2 && (cv_cam2_still.value || cv_analog2.value))) { thiscam->angle = player->mo->angle; From d980d526c89f416e7ffe8db42b8aeb7aae8c21de Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 11:36:40 -0600 Subject: [PATCH 082/126] Change defaults to match my personal settings --- src/g_game.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 2a4e67d7b..aaac4cbc2 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -411,23 +411,23 @@ consvar_t cv_cam_shiftfacing[2] = { {"cam2_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacing[2] = { - {"cam_turnfacingchar", "0.0", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacingchar", "0.0", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingchar", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacingability[2] = { - {"cam_turnfacingability", "0.0", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacingability", "0.0", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingability", "0.125", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacingspindash[2] = { - {"cam_turnfacingspindash", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"cam2_turnfacingspindash", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_turnfacingspindash", "0.5", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; consvar_t cv_cam_turnfacinginput[2] = { {"cam_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam2_turnfacinginput", "0.25", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, }; -static CV_PossibleValue_t centertoggle_cons_t[] = {{0, "Hold"}, {1, "Toggle"}, {0, NULL}}; +static CV_PossibleValue_t centertoggle_cons_t[] = {{0, "Hold"}, {1, "Toggle"}, {2, "Sticky Hold"}, {0, NULL}}; consvar_t cv_cam_centertoggle[2] = { {"cam_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, {"cam2_centertoggle", "Hold", CV_SAVE, centertoggle_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, From b46cbe76d6fffc06341421524110ba94766b2f37 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 11:36:59 -0600 Subject: [PATCH 083/126] Somehow miss committing the ACTUAL stickyhold part --- src/g_game.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/g_game.c b/src/g_game.c index aaac4cbc2..3ffe8839b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1400,6 +1400,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (down && !last_centerviewdown[forplayer]) centerviewhold[forplayer] = !centerviewhold[forplayer]; last_centerviewdown[forplayer] = down; + + if (cv_cam_centertoggle[forplayer].value == 2 && !down && !ticcmd_ztargetfocus[forplayer]) + centerviewhold[forplayer] = false; + centerviewdown = centerviewhold[forplayer]; } } From 085c39128f1128b6493ad02ffbf89c6b3c851d75 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 12:10:38 -0600 Subject: [PATCH 084/126] Save separate camera settings for standard/simple modes --- src/m_menu.c | 31 ++++++++++++------------------- src/p_local.h | 4 ++++ src/p_setup.c | 3 +++ src/p_user.c | 44 ++++++++++++++++++++++++++++++++++++++++---- src/r_main.c | 10 ++++++++++ 5 files changed, 69 insertions(+), 23 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 3fb7eee7a..0675dceb9 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1190,8 +1190,8 @@ static menuitem_t OP_CameraOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 21}, {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 36}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 41}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_savedist[0][0], 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_saveheight[0][0], 41}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Spacial Speed", &cv_cam_speed, 46}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Rotation Speed", &cv_cam_turnmultiplier, 51}, @@ -1208,8 +1208,8 @@ static menuitem_t OP_Camera2OptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 21}, {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 36}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 41}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_savedist[0][1], 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_saveheight[0][1], 41}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Spacial Speed", &cv_cam2_speed, 46}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Rotation Speed", &cv_cam2_turnmultiplier, 51}, @@ -1226,8 +1226,8 @@ static menuitem_t OP_CameraExtendedOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam_adjust, 21}, {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_dist, 36}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_height, 41}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_savedist[1][0], 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_saveheight[1][0], 41}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Spacial Speed", &cv_cam_speed, 46}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Rotation Speed", &cv_cam_turnmultiplier, 51}, @@ -1256,8 +1256,8 @@ static menuitem_t OP_Camera2ExtendedOptionsMenu[] = {IT_STRING | IT_CVAR, NULL, "Downhill Slope Adjustment", &cv_cam2_adjust, 21}, {IT_HEADER, NULL, "Camera Positioning", NULL, 30}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam2_dist, 36}, - {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam2_height, 41}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Distance", &cv_cam_savedist[1][1], 36}, + {IT_STRING | IT_CVAR | IT_CV_INTEGERSTEP, NULL, "Camera Height", &cv_cam_saveheight[1][1], 41}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Camera Spacial Speed", &cv_cam2_speed, 46}, {IT_STRING | IT_CVAR | IT_CV_FLOATSLIDER, NULL, "Rotation Speed", &cv_cam2_turnmultiplier, 51}, @@ -11664,18 +11664,11 @@ static void M_HandlePlaystyleMenu(INT32 choice) S_StartSound(NULL, sfx_menu1); if (cv_abilitydirection[playstyle_activeplayer].value != (playstyle_currentchoice/2)) { - if (cv_abilitydirection[playstyle_activeplayer].value) - { - CV_Set((playstyle_activeplayer ? &cv_cam2_dist : &cv_cam_dist), cv_cam_dist.defaultvalue); - CV_Set((playstyle_activeplayer ? &cv_cam2_height : &cv_cam_height), cv_cam_height.defaultvalue); - } - else - { - CV_SetValue((playstyle_activeplayer ? &cv_cam2_dist : &cv_cam_dist), 224); - CV_SetValue((playstyle_activeplayer ? &cv_cam2_height : &cv_cam_height), 50); - } - CV_SetValue(&cv_abilitydirection[playstyle_activeplayer], playstyle_currentchoice/2); + if (playstyle_activeplayer) + CV_UpdateCam2Dist(); + else + CV_UpdateCamDist(); } CV_SetValue((playstyle_activeplayer ? &cv_directionchar2 : &cv_directionchar), playstyle_currentchoice ? 1 : 0); CV_SetValue((playstyle_activeplayer ? &cv_useranalog2 : &cv_useranalog), 0); diff --git a/src/p_local.h b/src/p_local.h index 19213959d..687af23e5 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -120,6 +120,10 @@ extern consvar_t cv_cam_speed, cv_cam_rotate, cv_cam_rotspeed, cv_cam_turnmultip extern consvar_t cv_cam2_dist, cv_cam2_still, cv_cam2_height; extern consvar_t cv_cam2_speed, cv_cam2_rotate, cv_cam2_rotspeed, cv_cam2_turnmultiplier, cv_cam2_orbit, cv_cam2_adjust; +extern consvar_t cv_cam_savedist[2][2], cv_cam_saveheight[2][2]; +void CV_UpdateCamDist(void); +void CV_UpdateCam2Dist(void); + extern fixed_t t_cam_dist, t_cam_height, t_cam_rotate; extern fixed_t t_cam2_dist, t_cam2_height, t_cam2_rotate; diff --git a/src/p_setup.c b/src/p_setup.c index bf3493d8c..e6bf684d7 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2692,6 +2692,9 @@ boolean P_SetupLevel(boolean skipprecip) /*if (!cv_cam_speed.changed) CV_Set(&cv_cam_speed, cv_cam_speed.defaultvalue);*/ + CV_UpdateCamDist(); + CV_UpdateCam2Dist(); + if (!cv_chasecam.changed) CV_SetValue(&cv_chasecam, chase); diff --git a/src/p_user.c b/src/p_user.c index 7c7f94863..bf6651a72 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9729,8 +9729,8 @@ static CV_PossibleValue_t rotation_cons_t[] = {{1, "MIN"}, {25, "MAX"}, {0, NULL static CV_PossibleValue_t CV_CamRotate[] = {{-720, "MIN"}, {720, "MAX"}, {0, NULL}}; static CV_PossibleValue_t multiplier_cons_t[] = {{0, "MIN"}, {3*FRACUNIT, "MAX"}, {0, NULL}}; -consvar_t cv_cam_dist = {"cam_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam_height = {"cam_height", "25", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_dist = {"cam_curdist", "160", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam_height = {"cam_curheight", "25", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_still = {"cam_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_speed = {"cam_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_rotate = {"cam_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -9738,8 +9738,8 @@ consvar_t cv_cam_rotspeed = {"cam_rotspeed", "10", CV_SAVE, rotation_cons_t, NUL consvar_t cv_cam_turnmultiplier = {"cam_turnmultiplier", "1.0", CV_FLOAT|CV_SAVE, multiplier_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_orbit = {"cam_orbit", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam_adjust = {"cam_adjust", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_dist = {"cam2_dist", "160", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_cam2_height = {"cam2_height", "25", CV_FLOAT|CV_SAVE, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam2_dist = {"cam2_curdist", "160", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_cam2_height = {"cam2_curheight", "25", CV_FLOAT, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_still = {"cam2_still", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_speed = {"cam2_speed", "0.3", CV_FLOAT|CV_SAVE, CV_CamSpeed, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_rotate = {"cam2_rotate", "0", CV_CALL|CV_NOINIT, CV_CamRotate, CV_CamRotate2_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -9748,6 +9748,42 @@ consvar_t cv_cam2_turnmultiplier = {"cam2_turnmultiplier", "1.0", CV_FLOAT|CV_SA consvar_t cv_cam2_orbit = {"cam2_orbit", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_cam2_adjust = {"cam2_adjust", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +// [standard vs simple][p1 or p2] +consvar_t cv_cam_savedist[2][2] = { + { // standard + {"cam_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_dist", "160", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + }, + { // simple + {"cam_simpledist", "224", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_simpledist", "224", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + + } +}; +consvar_t cv_cam_saveheight[2][2] = { + { // standard + {"cam_height", "25", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_height", "25", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + }, + { // simple + {"cam_simpleheight", "48", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCamDist, 0, NULL, NULL, 0, 0, NULL}, + {"cam2_simpleheight", "48", CV_FLOAT|CV_SAVE|CV_CALL, NULL, CV_UpdateCam2Dist, 0, NULL, NULL, 0, 0, NULL} + + } +}; + +void CV_UpdateCamDist(void) +{ + CV_Set(&cv_cam_dist, va("%f", FIXED_TO_FLOAT(cv_cam_savedist[cv_abilitydirection[0].value][0].value))); + CV_Set(&cv_cam_height, va("%f", FIXED_TO_FLOAT(cv_cam_saveheight[cv_abilitydirection[0].value][0].value))); +} + +void CV_UpdateCam2Dist(void) +{ + CV_Set(&cv_cam2_dist, va("%f", FIXED_TO_FLOAT(cv_cam_savedist[cv_abilitydirection[1].value][1].value))); + CV_Set(&cv_cam2_height, va("%f", FIXED_TO_FLOAT(cv_cam_saveheight[cv_abilitydirection[1].value][1].value))); +} + fixed_t t_cam_dist = -42; fixed_t t_cam_height = -42; fixed_t t_cam_rotate = -42; diff --git a/src/r_main.c b/src/r_main.c index 115db8cb5..efea00af8 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1206,6 +1206,16 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam2_orbit); CV_RegisterVar(&cv_cam2_adjust); + CV_RegisterVar(&cv_cam_savedist[0][0]); + CV_RegisterVar(&cv_cam_savedist[0][1]); + CV_RegisterVar(&cv_cam_savedist[1][0]); + CV_RegisterVar(&cv_cam_savedist[1][1]); + + CV_RegisterVar(&cv_cam_saveheight[0][0]); + CV_RegisterVar(&cv_cam_saveheight[0][1]); + CV_RegisterVar(&cv_cam_saveheight[1][0]); + CV_RegisterVar(&cv_cam_saveheight[1][1]); + CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); From 631b5ff883a3f557e6c582793b68caf003e79de7 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 12:13:41 -0600 Subject: [PATCH 085/126] Disable lock-on in Ringslinger --- src/g_game.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 3ffe8839b..471c6db6c 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1410,7 +1410,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (centerviewdown) { - if (abilitydirection && !ticcmd_centerviewdown[forplayer]) + if (abilitydirection && !ticcmd_centerviewdown[forplayer] && !G_RingSlingerGametype()) { CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 0); *myangle = player->mo->angle; From e0f35d207ff12eee1e183d367b057842ee038fd0 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 14:01:14 -0600 Subject: [PATCH 086/126] Convert analog/directionchar cvars into 2-long arrays --- src/b_bot.c | 2 +- src/d_main.c | 2 +- src/d_netcmd.c | 22 ++++++++++---------- src/doomstat.h | 2 +- src/g_game.c | 54 ++++++++++++++++++++++++++++---------------------- src/g_game.h | 5 ++--- src/m_cheat.c | 2 +- src/m_menu.c | 22 ++++++++++---------- src/m_misc.c | 4 ++-- src/p_map.c | 6 +++--- src/p_setup.c | 24 +++++++++++----------- src/p_user.c | 14 ++++++------- src/r_main.c | 12 +++++------ 13 files changed, 88 insertions(+), 83 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index dfb5ee1cf..cd5edf990 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -379,7 +379,7 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd) } // Bot AI isn't programmed in analog. - CV_SetValue(&cv_analog2, false); + CV_SetValue(&cv_analog[1], false); #ifdef HAVE_BLUA // Let Lua scripts build ticcmds diff --git a/src/d_main.c b/src/d_main.c index c4b0d7117..f3e84985a 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -781,7 +781,7 @@ void D_StartTitle(void) CV_SetValue(&cv_usemouse, tutorialusemouse); CV_SetValue(&cv_alwaysfreelook, tutorialfreelook); CV_SetValue(&cv_mousemove, tutorialmousemove); - CV_SetValue(&cv_analog, tutorialanalog); + CV_SetValue(&cv_analog[0], tutorialanalog); M_StartMessage("Do you want to \x82save the recommended \x82movement controls?\x80\n\nPress 'Y' or 'Enter' to confirm\nPress 'N' or any key to keep \nyour current controls", M_TutorialSaveControlResponse, MM_YESNO); } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ffb5b90ca..df6d70446 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -816,14 +816,14 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_joyscale2); // Analog Control - CV_RegisterVar(&cv_analog); - CV_RegisterVar(&cv_analog2); - CV_RegisterVar(&cv_useranalog); - CV_RegisterVar(&cv_useranalog2); + CV_RegisterVar(&cv_analog[0]); + CV_RegisterVar(&cv_analog[1]); + CV_RegisterVar(&cv_useranalog[0]); + CV_RegisterVar(&cv_useranalog[1]); // deez New User eXperiences - CV_RegisterVar(&cv_directionchar); - CV_RegisterVar(&cv_directionchar2); + CV_RegisterVar(&cv_directionchar[0]); + CV_RegisterVar(&cv_directionchar[1]); CV_RegisterVar(&cv_autobrake); CV_RegisterVar(&cv_autobrake2); @@ -1510,9 +1510,9 @@ void SendWeaponPref(void) buf[0] = 0; if (cv_flipcam.value) buf[0] |= 1; - if (cv_analog.value) + if (cv_analog[0].value) buf[0] |= 2; - if (cv_directionchar.value) + if (cv_directionchar[0].value) buf[0] |= 4; if (cv_autobrake.value) buf[0] |= 8; @@ -1526,9 +1526,9 @@ void SendWeaponPref2(void) buf[0] = 0; if (cv_flipcam2.value) buf[0] |= 1; - if (cv_analog2.value) + if (cv_analog[1].value) buf[0] |= 2; - if (cv_directionchar2.value) + if (cv_directionchar[1].value) buf[0] |= 4; if (cv_autobrake2.value) buf[0] |= 8; @@ -2036,7 +2036,7 @@ static void Command_Map_f(void) CV_SetValue(&cv_usemouse, tutorialusemouse); CV_SetValue(&cv_alwaysfreelook, tutorialfreelook); CV_SetValue(&cv_mousemove, tutorialmousemove); - CV_SetValue(&cv_analog, tutorialanalog); + CV_SetValue(&cv_analog[0], tutorialanalog); } tutorialmode = false; // warping takes us out of tutorial mode diff --git a/src/doomstat.h b/src/doomstat.h index 3c0b4773a..cc4e0ca98 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -137,7 +137,7 @@ extern INT32 tutorialgcs; // which control scheme is loaded? extern INT32 tutorialusemouse; // store cv_usemouse user value extern INT32 tutorialfreelook; // store cv_alwaysfreelook user value extern INT32 tutorialmousemove; // store cv_mousemove user value -extern INT32 tutorialanalog; // store cv_analog user value +extern INT32 tutorialanalog; // store cv_analog[0] user value extern boolean looptitle; diff --git a/src/g_game.c b/src/g_game.c index 471c6db6c..df5e2afd1 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -139,7 +139,7 @@ INT32 tutorialgcs = gcs_custom; // which control scheme is loaded? INT32 tutorialusemouse = 0; // store cv_usemouse user value INT32 tutorialfreelook = 0; // store cv_alwaysfreelook user value INT32 tutorialmousemove = 0; // store cv_mousemove user value -INT32 tutorialanalog = 0; // store cv_analog user value +INT32 tutorialanalog = 0; // store cv_analog[0] user value boolean looptitle = false; @@ -388,15 +388,21 @@ consvar_t cv_mousemove2 = {"mousemove2", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL // previously "analog", "analog2", "useranalog", and "useranalog2", invalidating 2.1-era copies of config.cfg // changed because it'd be nice to see people try out our actually good controls with gamepads now autobrake exists -consvar_t cv_analog = {"sessionanalog", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_analog2 = {"sessionanalog2", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog2_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_useranalog = {"configanalog", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_useranalog2 = {"configanalog2", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog2_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_analog[2] = { + {"sessionanalog", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"sessionanalog2", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, Analog2_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; +consvar_t cv_useranalog[2] = { + {"configanalog", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"configanalog2", "Off", CV_SAVE|CV_CALL|CV_NOSHOWHELP, CV_OnOff, UserAnalog2_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; // deez New User eXperiences static CV_PossibleValue_t directionchar_cons_t[] = {{0, "Camera"}, {1, "Movement"}, {0, NULL}}; -consvar_t cv_directionchar = {"directionchar", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_directionchar2 = {"directionchar2", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar2_OnChange, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_directionchar[2] = { + {"directionchar", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar_OnChange, 0, NULL, NULL, 0, 0, NULL}, + {"directionchar2", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar2_OnChange, 0, NULL, NULL, 0, 0, NULL} +}; consvar_t cv_autobrake = {"autobrake", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake_OnChange, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_autobrake2 = {"autobrake2", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake2_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -1159,7 +1165,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) chasefreelook = cv_chasefreelook.value; alwaysfreelook = cv_alwaysfreelook.value; usejoystick = cv_usejoystick.value; - analog = cv_analog.value; + analog = cv_analog[0].value; invertmouse = cv_invertmouse.value; mousemove = cv_mousemove.value; mx = &mousex; @@ -1173,7 +1179,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) chasefreelook = cv_chasefreelook2.value; alwaysfreelook = cv_alwaysfreelook2.value; usejoystick = cv_usejoystick2.value; - analog = cv_analog2.value; + analog = cv_analog[1].value; invertmouse = cv_invertmouse2.value; mousemove = cv_mousemove2.value; mx = &mouse2x; @@ -1412,7 +1418,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { if (abilitydirection && !ticcmd_centerviewdown[forplayer] && !G_RingSlingerGametype()) { - CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 0); + CV_SetValue((ssplayer == 1 ? &cv_directionchar[0] : &cv_directionchar[1]), 0); *myangle = player->mo->angle; *myaiming = 0; @@ -1427,7 +1433,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (abilitydirection) { P_SetTarget(&ticcmd_ztargetfocus[forplayer], NULL); - CV_SetValue((ssplayer == 1 ? &cv_directionchar : &cv_directionchar2), 1); + CV_SetValue((ssplayer == 1 ? &cv_directionchar[0] : &cv_directionchar[1]), 1); } ticcmd_centerviewdown[forplayer] = false; @@ -1606,7 +1612,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (!player->powers[pw_tailsfly] && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) { player->bot = 2; // A player-controlled bot. Returns to AI when it respawns. - CV_SetValue(&cv_analog2, true); + CV_SetValue(&cv_analog[1], true); } else { @@ -1726,20 +1732,20 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // fudging with it. static void UserAnalog_OnChange(void) { - if (cv_useranalog.value) - CV_SetValue(&cv_analog, 1); + if (cv_useranalog[0].value) + CV_SetValue(&cv_analog[0], 1); else - CV_SetValue(&cv_analog, 0); + CV_SetValue(&cv_analog[0], 0); } static void UserAnalog2_OnChange(void) { if (botingame) return; - if (cv_useranalog2.value) - CV_SetValue(&cv_analog2, 1); + if (cv_useranalog[1].value) + CV_SetValue(&cv_analog[1], 1); else - CV_SetValue(&cv_analog2, 0); + CV_SetValue(&cv_analog[1], 0); } static void Analog_OnChange(void) @@ -1749,8 +1755,8 @@ static void Analog_OnChange(void) // cameras are not initialized at this point - if (!cv_chasecam.value && cv_analog.value) { - CV_SetValue(&cv_analog, 0); + if (!cv_chasecam.value && cv_analog[0].value) { + CV_SetValue(&cv_analog[0], 0); return; } @@ -1764,8 +1770,8 @@ static void Analog2_OnChange(void) // cameras are not initialized at this point - if (!cv_chasecam2.value && cv_analog2.value) { - CV_SetValue(&cv_analog2, 0); + if (!cv_chasecam2.value && cv_analog[1].value) { + CV_SetValue(&cv_analog[1], 0); return; } @@ -5956,12 +5962,12 @@ void G_BeginRecording(void) buf |= 0x01; pflags |= PF_FLIPCAM; } - if (cv_analog.value) + if (cv_analog[0].value) { buf |= 0x02; pflags |= PF_ANALOGMODE; } - if (cv_directionchar.value) + if (cv_directionchar[0].value) { buf |= 0x04; pflags |= PF_DIRECTIONCHAR; diff --git a/src/g_game.h b/src/g_game.h index 5f094fbda..b2a237d7e 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -68,9 +68,8 @@ extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, extern consvar_t cv_crosshair, cv_crosshair2; 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_useranalog, cv_useranalog2; -extern consvar_t cv_analog, cv_analog2; -extern consvar_t cv_directionchar, cv_directionchar2; +extern consvar_t cv_useranalog[2], cv_analog[2]; +extern consvar_t cv_directionchar[2]; extern consvar_t cv_autobrake, cv_autobrake2; extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis,cv_deadzone,cv_digitaldeadzone; extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2,cv_deadzone2,cv_digitaldeadzone2; diff --git a/src/m_cheat.c b/src/m_cheat.c index e31ce7869..66d09faba 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -1316,7 +1316,7 @@ void OP_ObjectplaceMovement(player_t *player) { ticcmd_t *cmd = &player->cmd; - if (!player->climbing && (netgame || !cv_analog.value || (player->pflags & PF_SPINNING))) + if (!player->climbing && (netgame || !cv_analog[0].value || (player->pflags & PF_SPINNING))) player->drawangle = player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); ticruned++; diff --git a/src/m_menu.c b/src/m_menu.c index 0675dceb9..c5691a7c3 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1038,7 +1038,7 @@ static menuitem_t OP_P1ControlsMenu[] = {IT_SUBMENU | IT_STRING, NULL, "Camera Options...", &OP_CameraOptionsDef, 50}, - //{IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar, 70}, + //{IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar[0], 70}, {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake, 70}, {IT_CALL | IT_STRING, NULL, "Play Style...", M_Setup1PPlaystyleMenu, 80}, //{IT_STRING | IT_CVAR, NULL, "Ability angle", &cv_abilitydirection[0], 90}, @@ -1052,7 +1052,7 @@ static menuitem_t OP_P2ControlsMenu[] = {IT_SUBMENU | IT_STRING, NULL, "Camera Options...", &OP_Camera2OptionsDef, 50}, - //{IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar2, 70}, + //{IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar[1], 70}, {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake2, 70}, {IT_CALL | IT_STRING, NULL, "Play Style...", M_Setup2PPlaystyleMenu, 80}, //{IT_STRING | IT_CVAR, NULL, "Ability angle", &cv_abilitydirection[1], 90}, @@ -4318,7 +4318,7 @@ static void M_DrawControlsDefMenu(void) if (currentMenu == &OP_P1ControlsDef) { - opt = cv_useranalog.value ? 3 : (cv_abilitydirection[0].value ? 2 : cv_directionchar.value); + opt = cv_useranalog[0].value ? 3 : (cv_abilitydirection[0].value ? 2 : cv_directionchar[0].value); if (opt == 2) { @@ -4333,7 +4333,7 @@ static void M_DrawControlsDefMenu(void) } else { - opt = cv_useranalog2.value ? 3 : (cv_abilitydirection[1].value ? 2 : cv_directionchar2.value); + opt = cv_useranalog[1].value ? 3 : (cv_abilitydirection[1].value ? 2 : cv_directionchar[1].value); if (opt == 2) { @@ -7773,7 +7773,7 @@ void M_TutorialSaveControlResponse(INT32 ch) CV_Set(&cv_usemouse, cv_usemouse.defaultvalue); CV_Set(&cv_alwaysfreelook, cv_alwaysfreelook.defaultvalue); CV_Set(&cv_mousemove, cv_mousemove.defaultvalue); - CV_Set(&cv_analog, cv_analog.defaultvalue); + CV_Set(&cv_analog[0], cv_analog[0].defaultvalue); S_StartSound(NULL, sfx_itemup); } else @@ -7791,13 +7791,13 @@ static void M_TutorialControlResponse(INT32 ch) tutorialusemouse = cv_usemouse.value; tutorialfreelook = cv_alwaysfreelook.value; tutorialmousemove = cv_mousemove.value; - tutorialanalog = cv_analog.value; + tutorialanalog = cv_analog[0].value; G_CopyControls(gamecontrol, gamecontroldefault[tutorialgcs], gcl_tutorial_full, num_gcl_tutorial_full); CV_Set(&cv_usemouse, cv_usemouse.defaultvalue); CV_Set(&cv_alwaysfreelook, cv_alwaysfreelook.defaultvalue); CV_Set(&cv_mousemove, cv_mousemove.defaultvalue); - CV_Set(&cv_analog, cv_analog.defaultvalue); + CV_Set(&cv_analog[0], cv_analog[0].defaultvalue); //S_StartSound(NULL, sfx_itemup); } @@ -11619,7 +11619,7 @@ static void M_Setup1PPlaystyleMenu(INT32 choice) (void)choice; playstyle_activeplayer = 0; - playstyle_currentchoice = cv_useranalog.value ? 3 : (cv_abilitydirection[0].value ? 2 : cv_directionchar.value); + playstyle_currentchoice = cv_useranalog[0].value ? 3 : (cv_abilitydirection[0].value ? 2 : cv_directionchar[0].value); OP_PlaystyleDef.prevMenu = &OP_P1ControlsDef; M_SetupNextMenu(&OP_PlaystyleDef); } @@ -11629,7 +11629,7 @@ static void M_Setup2PPlaystyleMenu(INT32 choice) (void)choice; playstyle_activeplayer = 1; - playstyle_currentchoice = cv_useranalog2.value ? 3 : (cv_abilitydirection[1].value ? 2 : cv_directionchar2.value); + playstyle_currentchoice = cv_useranalog[1].value ? 3 : (cv_abilitydirection[1].value ? 2 : cv_directionchar[1].value); OP_PlaystyleDef.prevMenu = &OP_P2ControlsDef; M_SetupNextMenu(&OP_PlaystyleDef); } @@ -11670,8 +11670,8 @@ static void M_HandlePlaystyleMenu(INT32 choice) else CV_UpdateCamDist(); } - CV_SetValue((playstyle_activeplayer ? &cv_directionchar2 : &cv_directionchar), playstyle_currentchoice ? 1 : 0); - CV_SetValue((playstyle_activeplayer ? &cv_useranalog2 : &cv_useranalog), 0); + CV_SetValue((playstyle_activeplayer ? &cv_directionchar[1] : &cv_directionchar[0]), playstyle_currentchoice ? 1 : 0); + CV_SetValue((playstyle_activeplayer ? &cv_useranalog[1] : &cv_useranalog[0]), 0); M_SetupNextMenu(currentMenu->prevMenu); break; diff --git a/src/m_misc.c b/src/m_misc.c index 83c0c7bec..0fe1b6087 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -600,12 +600,12 @@ void M_SaveConfig(const char *filename) CV_SetValue(&cv_usemouse, tutorialusemouse); CV_SetValue(&cv_alwaysfreelook, tutorialfreelook); CV_SetValue(&cv_mousemove, tutorialmousemove); - CV_SetValue(&cv_analog, tutorialanalog); + CV_SetValue(&cv_analog[0], tutorialanalog); CV_SaveVariables(f); CV_Set(&cv_usemouse, cv_usemouse.defaultvalue); CV_Set(&cv_alwaysfreelook, cv_alwaysfreelook.defaultvalue); CV_Set(&cv_mousemove, cv_mousemove.defaultvalue); - CV_Set(&cv_analog, cv_analog.defaultvalue); + CV_Set(&cv_analog[0], cv_analog[0].defaultvalue); } else CV_SaveVariables(f); diff --git a/src/p_map.c b/src/p_map.c index 2d36f747c..20b0eae05 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -632,7 +632,7 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails) && P_MobjFlip(tails->mo)*sonic->mo->momz <= 0) { if (sonic-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, false); + CV_SetValue(&cv_analog[1], false); P_ResetPlayer(sonic); P_SetTarget(&sonic->mo->tracer, tails->mo); sonic->powers[pw_carry] = CR_PLAYER; @@ -644,7 +644,7 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails) } else { if (sonic-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, true); + CV_SetValue(&cv_analog[1], true); P_SetTarget(&sonic->mo->tracer, NULL); sonic->powers[pw_carry] = CR_NONE; } @@ -1621,7 +1621,7 @@ static boolean PIT_CheckThing(mobj_t *thing) } else if (thing->player) { if (thing->player-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, true); + CV_SetValue(&cv_analog[1], true); if (thing->player->powers[pw_carry] == CR_PLAYER) { P_SetTarget(&thing->tracer, NULL); diff --git a/src/p_setup.c b/src/p_setup.c index e6bf684d7..babe0265e 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2304,7 +2304,7 @@ static void P_LevelInitStuff(void) } if (botingame) - CV_SetValue(&cv_analog2, true); + CV_SetValue(&cv_analog[1], true); } // @@ -3180,26 +3180,26 @@ boolean P_SetupLevel(boolean skipprecip) if (!cv_cam2_rotate.changed) CV_Set(&cv_cam2_rotate, cv_cam2_rotate.defaultvalue); - if (!cv_analog.changed) - CV_SetValue(&cv_analog, 0); - if (!cv_analog2.changed) - CV_SetValue(&cv_analog2, 0); + if (!cv_analog[0].changed) + CV_SetValue(&cv_analog[0], 0); + if (!cv_analog[1].changed) + CV_SetValue(&cv_analog[1], 0); displayplayer = consoleplayer; // Start with your OWN view, please! } - if (cv_useranalog.value) - CV_SetValue(&cv_analog, true); + if (cv_useranalog[0].value) + CV_SetValue(&cv_analog[0], true); - if (splitscreen && cv_useranalog2.value) - CV_SetValue(&cv_analog2, true); + if (splitscreen && cv_useranalog[1].value) + CV_SetValue(&cv_analog[1], true); else if (botingame) - CV_SetValue(&cv_analog2, true); + CV_SetValue(&cv_analog[1], true); if (twodlevel) { - CV_SetValue(&cv_analog2, false); - CV_SetValue(&cv_analog, false); + CV_SetValue(&cv_analog[1], false); + CV_SetValue(&cv_analog[0], false); } // clear special respawning que diff --git a/src/p_user.c b/src/p_user.c index bf6651a72..215cd88ee 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1064,7 +1064,7 @@ void P_ResetPlayer(player_t *player) player->onconveyor = 0; player->skidtime = 0; if (player-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, true); + CV_SetValue(&cv_analog[1], true); } // P_PlayerCanDamage @@ -4438,7 +4438,7 @@ void P_DoJump(player_t *player, boolean soundandstate) player->powers[pw_carry] = CR_NONE; P_SetTarget(&player->mo->tracer, NULL); if (player-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, true); + CV_SetValue(&cv_analog[1], true); } else if (player->powers[pw_carry] == CR_GENERIC) { @@ -9823,8 +9823,8 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->angle = (thiscam == &camera) ? localangle : localangle2; thiscam->aiming = (thiscam == &camera) ? localaiming : localaiming2; } - else if (!(thiscam == &camera && (cv_cam_still.value || cv_analog.value)) - && !(thiscam == &camera2 && (cv_cam2_still.value || cv_analog2.value))) + else if (!(thiscam == &camera && (cv_cam_still.value || cv_analog[0].value)) + && !(thiscam == &camera2 && (cv_cam2_still.value || cv_analog[1].value))) { thiscam->angle = player->mo->angle; thiscam->aiming = 0; @@ -10029,14 +10029,14 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall else angle = focusangle + FixedAngle(camrotate*FRACUNIT); - if (!resetcalled && (cv_analog.value || demoplayback) && ((thiscam == &camera && t_cam_rotate != -42) || (thiscam == &camera2 + if (!resetcalled && (cv_analog[0].value || demoplayback) && ((thiscam == &camera && t_cam_rotate != -42) || (thiscam == &camera2 && t_cam2_rotate != -42))) { angle = FixedAngle(camrotate*FRACUNIT); thiscam->angle = angle; } - if ((((thiscam == &camera) && cv_analog.value) || ((thiscam != &camera) && cv_analog2.value) || demoplayback) && !sign && !objectplacing && !(twodlevel || (mo->flags2 & MF2_TWOD)) && (player->powers[pw_carry] != CR_NIGHTSMODE) && displayplayer == consoleplayer) + if ((((thiscam == &camera) && cv_analog[0].value) || ((thiscam != &camera) && cv_analog[1].value) || demoplayback) && !sign && !objectplacing && !(twodlevel || (mo->flags2 & MF2_TWOD)) && (player->powers[pw_carry] != CR_NIGHTSMODE) && displayplayer == consoleplayer) { #ifdef REDSANALOG if ((player->cmd.buttons & (BT_CAMLEFT|BT_CAMRIGHT)) == (BT_CAMLEFT|BT_CAMRIGHT)); else @@ -12625,7 +12625,7 @@ void P_PlayerAfterThink(player_t *player) P_SetTarget(&player->mo->tracer, NULL); if (player-players == consoleplayer && botingame) - CV_SetValue(&cv_analog2, (player->powers[pw_carry] != CR_PLAYER)); + CV_SetValue(&cv_analog[1], (player->powers[pw_carry] != CR_PLAYER)); break; } case CR_GENERIC: // being carried by some generic item diff --git a/src/r_main.c b/src/r_main.c index efea00af8..9cb0f3edb 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -185,20 +185,20 @@ void SplitScreen_OnChange(void) static void ChaseCam_OnChange(void) { - if (!cv_chasecam.value || !cv_useranalog.value) - CV_SetValue(&cv_analog, 0); + if (!cv_chasecam.value || !cv_useranalog[0].value) + CV_SetValue(&cv_analog[0], 0); else - CV_SetValue(&cv_analog, 1); + CV_SetValue(&cv_analog[0], 1); } static void ChaseCam2_OnChange(void) { if (botingame) return; - if (!cv_chasecam2.value || !cv_useranalog2.value) - CV_SetValue(&cv_analog2, 0); + if (!cv_chasecam2.value || !cv_useranalog[1].value) + CV_SetValue(&cv_analog[1], 0); else - CV_SetValue(&cv_analog2, 1); + CV_SetValue(&cv_analog[1], 1); } static void FlipCam_OnChange(void) From d670139404831a32fc57c477223cd286fe2a4cc5 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 30 Dec 2019 12:30:35 -0800 Subject: [PATCH 087/126] Revert revert revert This reverts commit 6546e3c3bc38415150bd3a2c405a465fe67509a0. This reverts commit 8a15e9abc4b36a9c5af0e0f81c7aeea8096ee666. --- src/lua_consolelib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lua_consolelib.c b/src/lua_consolelib.c index 4e397fb32..06a3b3388 100644 --- a/src/lua_consolelib.c +++ b/src/lua_consolelib.c @@ -130,6 +130,7 @@ void COM_Lua_f(void) lua_pop(gL, 1); // pop command info table return; // can't execute splitscreen command without player 2! } + playernum = secondarydisplayplayer; } if (netgame && !( flags & COM_LOCAL ))/* don't send local commands */ @@ -157,7 +158,10 @@ void COM_Lua_f(void) WRITEUINT8(p, argc); for (i = 0; i < argc; i++) WRITESTRINGN(p, COM_Argv(i), 255); - SendNetXCmd(XD_LUACMD, buf, p-buf); + if (flags & COM_SPLITSCREEN) + SendNetXCmd2(XD_LUACMD, buf, p-buf); + else + SendNetXCmd(XD_LUACMD, buf, p-buf); free(buf); return; } From c3d14064e2538e1fc968fcb6a8ba5dc87f7b5118 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 15:05:24 -0600 Subject: [PATCH 088/126] Convert simple movement to directionchar+analog Analog + no directionchar is old analog (now known as CS_LMAOGALOG because lmao if you still use it). --- src/g_game.c | 61 ++++++++++++++---------------------- src/g_game.h | 11 +++++++ src/p_local.h | 6 +--- src/p_map.c | 6 ++-- src/p_spec.c | 4 +-- src/p_user.c | 84 ++++++++++++++++++++++++++++++-------------------- src/st_stuff.c | 12 +++++++- 7 files changed, 102 insertions(+), 82 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index df5e2afd1..7234add65 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1144,7 +1144,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) INT32 *myaiming = (ssplayer == 1 ? &localaiming : &localaiming2); angle_t drawangleoffset = (player->powers[pw_carry] == CR_ROLLOUT) ? ANGLE_180 : 0; - INT32 chasecam, chasefreelook, alwaysfreelook, usejoystick, analog, invertmouse, mousemove, abilitydirection; + INT32 chasecam, chasefreelook, alwaysfreelook, usejoystick, invertmouse, mousemove; + controlstyle_e controlstyle = G_ControlStyle(ssplayer); INT32 *mx; INT32 *my; INT32 *mly; static INT32 turnheld[2]; // for accelerative turning @@ -1165,7 +1166,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) chasefreelook = cv_chasefreelook.value; alwaysfreelook = cv_alwaysfreelook.value; usejoystick = cv_usejoystick.value; - analog = cv_analog[0].value; invertmouse = cv_invertmouse.value; mousemove = cv_mousemove.value; mx = &mousex; @@ -1179,7 +1179,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) chasefreelook = cv_chasefreelook2.value; alwaysfreelook = cv_alwaysfreelook2.value; usejoystick = cv_usejoystick2.value; - analog = cv_analog[1].value; invertmouse = cv_invertmouse2.value; mousemove = cv_mousemove2.value; mx = &mouse2x; @@ -1187,9 +1186,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) mly = &mlook2y; G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver } - abilitydirection = cv_abilitydirection[player->bot ? 0 : forplayer].value; - strafeisturn = abilitydirection && ticcmd_centerviewdown[forplayer] && + strafeisturn = controlstyle == CS_SIMPLE && ticcmd_centerviewdown[forplayer] && ((cv_cam_lockedinput[forplayer].value && !ticcmd_ztargetfocus[forplayer]) || (player->pflags & PF_STARTDASH)) && !player->climbing && player->powers[pw_carry] != CR_MINECART; @@ -1259,7 +1257,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) tspeed = speed; // let movement keys cancel each other out - if (analog) // Analog + if (controlstyle == CS_LMAOGALOG) // Analog { if (turnright) cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); @@ -1288,7 +1286,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) side += ((lookjoystickvector.xaxis * sidemove[1]) >> 10); } } - else if (analog) // Analog + else if (controlstyle == CS_LMAOGALOG) // Analog { if (turnright) cmd->buttons |= BT_CAMRIGHT; @@ -1399,7 +1397,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) static boolean last_centerviewdown[2], centerviewhold[2]; // detect taps for toggle behavior boolean down = PLAYERINPUTDOWN(ssplayer, gc_centerview); - if (!(abilitydirection && cv_cam_centertoggle[forplayer].value)) + if (!(controlstyle == CS_SIMPLE && cv_cam_centertoggle[forplayer].value)) centerviewdown = down; else { @@ -1416,9 +1414,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (centerviewdown) { - if (abilitydirection && !ticcmd_centerviewdown[forplayer] && !G_RingSlingerGametype()) + if (controlstyle == CS_SIMPLE && !ticcmd_centerviewdown[forplayer] && !G_RingSlingerGametype()) { - CV_SetValue((ssplayer == 1 ? &cv_directionchar[0] : &cv_directionchar[1]), 0); + CV_SetValue(&cv_directionchar[forplayer], 0); ///@TODO will break things *myangle = player->mo->angle; *myaiming = 0; @@ -1430,10 +1428,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } else if (ticcmd_centerviewdown[forplayer]) { - if (abilitydirection) + if (controlstyle == CS_SIMPLE) { P_SetTarget(&ticcmd_ztargetfocus[forplayer], NULL); - CV_SetValue((ssplayer == 1 ? &cv_directionchar[0] : &cv_directionchar[1]), 1); + CV_SetValue(&cv_directionchar[forplayer], 1); } ticcmd_centerviewdown[forplayer] = false; @@ -1562,7 +1560,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if ((!demoplayback && (player->pflags & PF_SLIDING))) // Analog for mouse side += *mx*2; - else if (analog) + else if (controlstyle == CS_LMAOGALOG) { if (*mx) { @@ -1622,7 +1620,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } } - if (analog) { + if (controlstyle == CS_LMAOGALOG) { if (player->awayviewtics) cmd->angleturn = (INT16)(player->awayviewmobj->angle >> 16); else @@ -1634,7 +1632,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(*myangle >> 16); // Adjust camera angle by player input - if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) + if (controlstyle == CS_SIMPLE && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; @@ -1654,30 +1652,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->sidemove = 0; } - if (abilitydirection && camera.chase && !ticcmd_centerviewdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) - { - ///@TODO This block of code is a hack to get the desired abilitydirection and player angle behaviors while remaining netplay-compatible with EXEs without those features. - // This has side effects like making F12 spectate look kind of weird, and making the input viewer inaccurate. - // In a perfect world, this will be removed and player behavior would use facing direction in a way that mimics this. - // But that's a lot more work and I want to A) have this out quickly B) be netplay-compatible. - - if (cmd->forwardmove || cmd->sidemove) - { - angle_t controlangle = R_PointToAngle2(0, 0, cmd->forwardmove << FRACBITS, -cmd->sidemove << FRACBITS); - cmd->angleturn += (controlangle>>16); - - cmd->forwardmove = R_PointToDist2(0, 0, cmd->forwardmove, cmd->sidemove); - if (cmd->forwardmove > MAXPLMOVE) - cmd->forwardmove = MAXPLMOVE; - cmd->sidemove = 0; - } - else - cmd->angleturn = (player->drawangle+drawangleoffset)>>16; - } - // Adjust camera angle to face player direction, depending on circumstances // Nothing happens if cam left/right are held, so you can hold both to lock the camera in one direction - if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && player->powers[pw_carry] != CR_MINECART) + if (controlstyle == CS_SIMPLE && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor; boolean alt = false; // Reduce intensity on diagonals and prevent backwards movement from turning the camera @@ -1703,7 +1680,15 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (camadjustfactor) { - INT32 anglediff = ((player->pflags & PF_SPINNING) ? player->drawangle + drawangleoffset : (cmd->angleturn<<16)) - *myangle; + angle_t controlangle; + INT32 anglediff; + + if ((cmd->forwardmove || cmd->sidemove) && !(player->pflags & PF_SPINNING)) + controlangle = (cmd->angleturn<<16) + R_PointToAngle2(0, 0, cmd->forwardmove << FRACBITS, -cmd->sidemove << FRACBITS); + else + controlangle = player->drawangle + drawangleoffset; + + anglediff = controlangle - *myangle; if (alt) { diff --git a/src/g_game.h b/src/g_game.h index b2a237d7e..1aac2ddb9 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -68,8 +68,19 @@ extern consvar_t cv_chatwidth, cv_chatnotifications, cv_chatheight, cv_chattime, extern consvar_t cv_crosshair, cv_crosshair2; 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_useranalog[2], cv_analog[2]; extern consvar_t cv_directionchar[2]; + +typedef enum { + CS_LEGACY, + CS_LMAOGALOG, + CS_STANDARD, + CS_SIMPLE = CS_LMAOGALOG|CS_STANDARD, +} controlstyle_e; +#define G_ControlStyle(ssplayer) ((cv_analog[(ssplayer)-1].value ? CS_LMAOGALOG : 0) | (cv_directionchar[(ssplayer)-1].value ? CS_STANDARD : 0)) +#define P_ControlStyle(player) ((((player)->pflags & PF_ANALOGMODE) ? CS_LMAOGALOG : 0) | (((player)->pflags & PF_DIRECTIONCHAR) ? CS_STANDARD : 0)) + extern consvar_t cv_autobrake, cv_autobrake2; extern consvar_t cv_sideaxis,cv_turnaxis,cv_moveaxis,cv_lookaxis,cv_jumpaxis,cv_spinaxis,cv_fireaxis,cv_firenaxis,cv_deadzone,cv_digitaldeadzone; extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis2,cv_spinaxis2,cv_fireaxis2,cv_firenaxis2,cv_deadzone2,cv_digitaldeadzone2; diff --git a/src/p_local.h b/src/p_local.h index 687af23e5..a5f3d313c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -192,11 +192,7 @@ void P_NukeEnemies(mobj_t *inflictor, mobj_t *source, fixed_t radius); boolean P_HomingAttack(mobj_t *source, mobj_t *enemy); /// \todo doesn't belong in p_user boolean P_SuperReady(player_t *player); void P_DoJump(player_t *player, boolean soundandstate); -#if 0 -boolean P_AnalogMove(player_t *player); -#else -#define P_AnalogMove(player) (player->pflags & PF_ANALOGMODE) -#endif +#define P_AnalogMove(player) (P_ControlStyle(player) == CS_LMAOGALOG) boolean P_TransferToNextMare(player_t *player); UINT8 P_FindLowestMare(void); void P_FindEmerald(void); diff --git a/src/p_map.c b/src/p_map.c index 20b0eae05..b6519ffca 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -377,7 +377,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) { object->angle = object->player->drawangle = spring->angle; - if (!demoplayback || P_AnalogMove(object->player)) + if (!demoplayback || P_ControlStyle(object->player) == CS_LMAOGALOG) { if (object->player == &players[consoleplayer]) localangle = spring->angle; @@ -1322,7 +1322,7 @@ static boolean PIT_CheckThing(mobj_t *thing) thing->angle = tmthing->angle; - if (!demoplayback || P_AnalogMove(thing->player)) + if (!demoplayback || P_ControlStyle(thing->player) == CS_LMAOGALOG) { if (thing->player == &players[consoleplayer]) localangle = thing->angle; @@ -3491,7 +3491,7 @@ isblocking: && canclimb) { slidemo->angle = climbangle; - /*if (!demoplayback || P_AnalogMove(slidemo->player)) + /*if (!demoplayback || P_ControlStyle(slidemo->player) == CS_LMAOGALOG) { if (slidemo->player == &players[consoleplayer]) localangle = slidemo->angle; diff --git a/src/p_spec.c b/src/p_spec.c index d7a2133c8..d0890f3c9 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4619,7 +4619,7 @@ DoneSection2: player->mo->angle = player->drawangle = lineangle; - if (!demoplayback || P_AnalogMove(player)) + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) { if (player == &players[consoleplayer]) localangle = player->mo->angle; @@ -9176,7 +9176,7 @@ void T_Pusher(pusher_t *p) thing->player->pflags |= PF_SLIDING; thing->angle = R_PointToAngle2 (0, 0, xspeed<<(FRACBITS-PUSH_FACTOR), yspeed<<(FRACBITS-PUSH_FACTOR)); - if (!demoplayback || P_AnalogMove(thing->player)) + if (!demoplayback || P_ControlStyle(thing->player) == CS_LMAOGALOG) { if (thing->player == &players[consoleplayer]) { diff --git a/src/p_user.c b/src/p_user.c index 215cd88ee..3a6425478 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3579,7 +3579,7 @@ static void P_DoClimbing(player_t *player) } #define CLIMBCONEMAX FixedAngle(90*FRACUNIT) - if (!demoplayback || P_AnalogMove(player)) + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) { if (player == &players[consoleplayer]) { @@ -4394,7 +4394,7 @@ void P_DoJump(player_t *player, boolean soundandstate) player->drawangle = player->mo->angle = player->mo->angle - ANGLE_180; // Turn around from the wall you were climbing. - if (!demoplayback || P_AnalogMove(player)) + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) { if (player == &players[consoleplayer]) localangle = player->mo->angle; // Adjust the local control angle. @@ -4719,7 +4719,7 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd) { player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, lockon->x, lockon->y); bullet = P_SpawnPointMissile(player->mo, lockon->x, lockon->y, zpos(lockon), player->revitem, player->mo->x, player->mo->y, zpos(player->mo)); - if (!demoplayback || P_AnalogMove(player)) + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) { if (player == &players[consoleplayer]) localangle = player->mo->angle; @@ -5616,13 +5616,6 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd) } } -#if 0 -boolean P_AnalogMove(player_t *player) -{ - return player->pflags & PF_ANALOGMODE; -} -#endif - // // P_GetPlayerControlDirection // @@ -5661,7 +5654,7 @@ INT32 P_GetPlayerControlDirection(player_t *player) origtempangle = tempangle = 0; // relative to the axis rather than the player! controlplayerdirection = R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); } - else if (P_AnalogMove(player) && thiscam->chase) + else if ((P_ControlStyle(player) & CS_LMAOGALOG) && thiscam->chase) { if (player->awayviewtics) origtempangle = tempangle = player->awayviewmobj->angle; @@ -5887,7 +5880,7 @@ static void P_3dMovement(player_t *player) INT32 mforward = 0, mbackward = 0; angle_t dangle; // replaces old quadrants bits fixed_t normalspd = FixedMul(player->normalspeed, player->mo->scale); - boolean analogmove = false; + controlstyle_e controlstyle; boolean spin = ((onground = P_IsObjectOnGround(player->mo)) && (player->pflags & (PF_SPINNING|PF_THOKKED)) == PF_SPINNING && (player->rmomx || player->rmomy) && !(player->pflags & PF_STARTDASH)); fixed_t oldMagnitude, newMagnitude; #ifdef ESLOPE @@ -5900,7 +5893,7 @@ static void P_3dMovement(player_t *player) // Get the old momentum; this will be needed at the end of the function! -SH oldMagnitude = R_PointToDist2(player->mo->momx - player->cmomx, player->mo->momy - player->cmomy, 0, 0); - analogmove = P_AnalogMove(player); + controlstyle = P_ControlStyle(player); cmd = &player->cmd; @@ -5927,7 +5920,7 @@ static void P_3dMovement(player_t *player) } } - if (analogmove) + if (controlstyle & CS_LMAOGALOG) { movepushangle = (cmd->angleturn<<16 /* not FRACBITS */); } @@ -6073,7 +6066,7 @@ static void P_3dMovement(player_t *player) P_SetObjectMomZ(player->mo, FixedDiv(cmd->forwardmove*FRACUNIT, 15*FRACUNIT>>1), false); } } - else if (!analogmove + else if (!(controlstyle == CS_LMAOGALOG) && cmd->forwardmove != 0 && !(player->pflags & PF_GLIDING || player->exiting || (P_PlayerInPain(player) && !onground))) { @@ -6112,7 +6105,7 @@ static void P_3dMovement(player_t *player) P_InstaThrust(player->mo, player->mo->angle-ANGLE_90, FixedDiv(cmd->sidemove*player->mo->scale, 15*FRACUNIT>>1)); } // Analog movement control - else if (analogmove) + else if (controlstyle == CS_LMAOGALOG) { if (!(player->pflags & PF_GLIDING || player->exiting || P_PlayerInPain(player))) { @@ -8132,8 +8125,33 @@ static void P_MovePlayer(player_t *player) P_2dMovement(player); else { - if (!player->climbing && (!P_AnalogMove(player))) - player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); + if (!player->climbing) + { + switch (P_ControlStyle(player)) + { + case CS_LEGACY: + case CS_STANDARD: + player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); + break; + + case CS_LMAOGALOG: + break; // handled elsewhere + + case CS_SIMPLE: + if (cmd->forwardmove || cmd->sidemove) + { + angle_t controlangle = R_PointToAngle2(0, 0, cmd->forwardmove << FRACBITS, -cmd->sidemove << FRACBITS); + player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */) + controlangle; + } + else + { + angle_t drawangleoffset = (player->powers[pw_carry] == CR_ROLLOUT) ? ANGLE_180 : 0; + player->mo->angle = player->drawangle + drawangleoffset; + } + + break; + } + } ticruned++; if ((cmd->angleturn & TICCMD_RECEIVED) == 0) @@ -8259,7 +8277,7 @@ static void P_MovePlayer(player_t *player) if (player->pflags & PF_GLIDING) { mobj_t *mo = player->mo; // seriously why isn't this at the top of the function hngngngng - fixed_t leeway = !P_AnalogMove(player) ? FixedAngle(cmd->sidemove*(FRACUNIT)) : 0; + fixed_t leeway = (P_ControlStyle(player) != CS_LMAOGALOG) ? FixedAngle(cmd->sidemove*(FRACUNIT)) : 0; fixed_t glidespeed = player->actionspd; fixed_t momx = mo->momx - player->cmomx, momy = mo->momy - player->cmomy; angle_t angle, moveangle = R_PointToAngle2(0, 0, momx, momy); @@ -8531,7 +8549,7 @@ static void P_MovePlayer(player_t *player) ////////////////// // This really looks like it should be moved to P_3dMovement. -Red - if (P_AnalogMove(player) + if (P_ControlStyle(player) == CS_LMAOGALOG && (cmd->forwardmove != 0 || cmd->sidemove != 0) && !player->climbing && !twodlevel && !(player->mo->flags2 & MF2_TWOD)) { // If travelling slow enough, face the way the controls @@ -9376,7 +9394,7 @@ boolean P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target if (source->player) { source->player->drawangle = source->angle; - if (!demoplayback || P_AnalogMove(source->player)) + if (!demoplayback || P_ControlStyle(source->player) == CS_LMAOGALOG) { if (source->player == &players[consoleplayer]) localangle = source->angle; @@ -9982,7 +10000,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camheight = FixedMul(camheight, player->camerascale); #ifdef REDSANALOG - if (P_AnalogMove(player) && (player->cmd.buttons & (BT_CAMLEFT|BT_CAMRIGHT)) == (BT_CAMLEFT|BT_CAMRIGHT)) { + if (P_ControlStyle(player) == CS_LMAOGALOG && (player->cmd.buttons & (BT_CAMLEFT|BT_CAMRIGHT)) == (BT_CAMLEFT|BT_CAMRIGHT)) { camstill = true; if (camspeed < 4*FRACUNIT/5) @@ -10012,7 +10030,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall angle = R_PointToAngle2(mo->x, mo->y, mo->target->x, mo->target->y); } } - else if (P_AnalogMove(player) && !sign) // Analog + else if (P_ControlStyle(player) == CS_LMAOGALOG && !sign) // Analog angle = R_PointToAngle2(thiscam->x, thiscam->y, mo->x, mo->y); else if (demoplayback) { @@ -10102,7 +10120,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall camheight = mo->scale << 7; camspeed = FRACUNIT/12; } - else if (P_AnalogMove(player)) // x1.2 dist for analog + else if (P_ControlStyle(player) == CS_LMAOGALOG) // x1.2 dist for analog { dist = FixedMul(dist, 6*FRACUNIT/5); camheight = FixedMul(camheight, 6*FRACUNIT/5); @@ -10995,7 +11013,7 @@ static void P_MinecartThink(player_t *player) else if (angdiff > ANGLE_180 && angdiff < InvAngle(MINECARTCONEMAX)) player->mo->angle = minecart->angle - MINECARTCONEMAX; - if (angdiff + minecart->angle != player->mo->angle && (!demoplayback || P_AnalogMove(player))) + if (angdiff + minecart->angle != player->mo->angle && (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG)) { if (player == &players[consoleplayer]) localangle = player->mo->angle; @@ -11074,7 +11092,7 @@ static void P_MinecartThink(player_t *player) else minecart->angle = targetangle + ANGLE_180; angdiff = (minecart->angle - prevangle); - if (angdiff && (!demoplayback || P_AnalogMove(player))) // maintain relative angle on turns + if (angdiff && (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG)) // maintain relative angle on turns { player->mo->angle += angdiff; if (player == &players[consoleplayer]) @@ -11840,7 +11858,7 @@ void P_PlayerThink(player_t *player) player->mo->reactiontime--; else if (player->powers[pw_carry] == CR_MINECART) { - if (!P_AnalogMove(player)) + if (P_ControlStyle(player) != CS_LMAOGALOG) player->mo->angle = (cmd->angleturn << 16 /* not FRACBITS */); ticruned++; @@ -11853,7 +11871,7 @@ void P_PlayerThink(player_t *player) { if (player->powers[pw_carry] == CR_ROPEHANG) { - if (!P_AnalogMove(player)) + if (P_ControlStyle(player) != CS_LMAOGALOG) player->mo->angle = (cmd->angleturn<<16 /* not FRACBITS */); ticruned++; @@ -11901,7 +11919,7 @@ void P_PlayerThink(player_t *player) ; else if (!(player->pflags & PF_DIRECTIONCHAR) || (player->climbing) // stuff where the direction is forced at all times - || (P_AnalogMove(player) || twodlevel || player->mo->flags2 & MF2_TWOD) // keep things synchronised up there, since the camera IS seperate from player motion when that happens + || (twodlevel || player->mo->flags2 & MF2_TWOD) // keep things synchronised up there, since the camera IS seperate from player motion when that happens || G_RingSlingerGametype()) // no firing rings in directions your player isn't aiming player->drawangle = player->mo->angle; else if (P_PlayerInPain(player)) @@ -11932,7 +11950,7 @@ void P_PlayerThink(player_t *player) case CR_ROLLOUT: if (cmd->forwardmove || cmd->sidemove) // only when you're pressing movement keys { // inverse direction! - diff = ((player->mo->angle + R_PointToAngle2(0, 0, -cmd->forwardmove<sidemove<drawangle); + diff = (((player->cmd.angleturn<<16) + R_PointToAngle2(0, 0, -cmd->forwardmove<sidemove<drawangle); factor = 4; } break; @@ -11989,7 +12007,7 @@ void P_PlayerThink(player_t *player) } else if (cmd->forwardmove || cmd->sidemove) // only when you're pressing movement keys { - diff = ((player->mo->angle + R_PointToAngle2(0, 0, cmd->forwardmove<sidemove<drawangle); + diff = ((player->mo->angle + ((player->pflags & PF_ANALOGMODE) ? 0 : R_PointToAngle2(0, 0, cmd->forwardmove<sidemove<drawangle); factor = 4; } else if (player->rmomx || player->rmomy) @@ -12602,7 +12620,7 @@ void P_PlayerAfterThink(player_t *player) { player->mo->angle = tails->angle; - if (!demoplayback || P_AnalogMove(player)) + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) { if (player == &players[consoleplayer]) localangle = player->mo->angle; @@ -12691,7 +12709,7 @@ void P_PlayerAfterThink(player_t *player) macecenter->angle += cmd->sidemove<mo->angle += cmd->sidemove< ANGLE_MAX - if (!demoplayback || P_AnalogMove(player)) + if (!demoplayback || P_ControlStyle(player) == CS_LMAOGALOG) { if (player == &players[consoleplayer]) localangle = player->mo->angle; // Adjust the local control angle. diff --git a/src/st_stuff.c b/src/st_stuff.c index 1b8107edb..03b32285d 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1157,10 +1157,20 @@ static void ST_drawInput(void) "AUTOBRAKE"); y -= 8; } - if (stplyr->pflags & PF_ANALOGMODE) + switch (P_ControlStyle(stplyr)) { + case CS_LMAOGALOG: V_DrawThinString(x, y, hudinfo[HUD_LIVES].f, "ANALOG"); y -= 8; + break; + + case CS_SIMPLE: + V_DrawThinString(x, y, hudinfo[HUD_LIVES].f, "SIMPLE"); + y -= 8; + break; + + default: + break; } } if (!demosynced) // should always be last, so it doesn't push anything else around From a51f2500e09db67e27319fef11515e83339f8f80 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 15:15:37 -0600 Subject: [PATCH 089/126] Update playstyle menu handling to use analog/directionchar combo --- src/d_netcmd.c | 2 -- src/g_game.c | 4 ---- src/g_game.h | 2 +- src/hu_stuff.c | 4 ++-- src/m_menu.c | 27 ++++++++++----------------- src/p_user.c | 14 +++++++------- 6 files changed, 20 insertions(+), 33 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index df6d70446..12a62a6b8 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -828,8 +828,6 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_autobrake2); // hi here's some new controls - CV_RegisterVar(&cv_abilitydirection[0]); - CV_RegisterVar(&cv_abilitydirection[1]); CV_RegisterVar(&cv_cam_shiftfacing[0]); CV_RegisterVar(&cv_cam_shiftfacing[1]); CV_RegisterVar(&cv_cam_turnfacing[0]); diff --git a/src/g_game.c b/src/g_game.c index 7234add65..ce661cc97 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -407,10 +407,6 @@ consvar_t cv_autobrake = {"autobrake", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrak consvar_t cv_autobrake2 = {"autobrake2", "On", CV_SAVE|CV_CALL, CV_OnOff, AutoBrake2_OnChange, 0, NULL, NULL, 0, 0, NULL}; // hi here's some new controls -consvar_t cv_abilitydirection[2] = { - {"abilitydirection", "Movement", CV_SAVE, directionchar_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, - {"abilitydirection2", "Movement", CV_SAVE, directionchar_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, -}; static CV_PossibleValue_t zerotoone_cons_t[] = {{0, "MIN"}, {FRACUNIT, "MAX"}, {0, NULL}}; consvar_t cv_cam_shiftfacing[2] = { {"cam_shiftfacingchar", "0.33", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}, diff --git a/src/g_game.h b/src/g_game.h index 1aac2ddb9..27cb8bc00 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -87,7 +87,7 @@ extern consvar_t cv_sideaxis2,cv_turnaxis2,cv_moveaxis2,cv_lookaxis2,cv_jumpaxis extern consvar_t cv_ghost_bestscore, cv_ghost_besttime, cv_ghost_bestrings, cv_ghost_last, cv_ghost_guest; // hi here's some new controls -extern consvar_t cv_abilitydirection[2], cv_cam_shiftfacing[2], cv_cam_turnfacing[2], +extern consvar_t cv_cam_shiftfacing[2], cv_cam_turnfacing[2], cv_cam_turnfacingability[2], cv_cam_turnfacingspindash[2], cv_cam_turnfacinginput[2], cv_cam_centertoggle[2], cv_cam_lockedinput[2], cv_cam_lockonboss[2]; diff --git a/src/hu_stuff.c b/src/hu_stuff.c index c1818bd4b..ccfeed4f1 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -2195,12 +2195,12 @@ void HU_Drawer(void) // draw the crosshair, not when viewing demos nor with chasecam if (!automapactive && cv_crosshair.value && !demoplayback && - (!camera.chase || (cv_abilitydirection[0].value && ticcmd_centerviewdown[0] && ticcmd_ztargetfocus[0])) + (!camera.chase || ticcmd_ztargetfocus[0]) && !players[displayplayer].spectator) HU_DrawCrosshair(); if (!automapactive && cv_crosshair2.value && !demoplayback && - (!camera2.chase || (cv_abilitydirection[1].value && ticcmd_centerviewdown[1] && ticcmd_ztargetfocus[1])) + (!camera2.chase || ticcmd_ztargetfocus[1]) && !players[secondarydisplayplayer].spectator) HU_DrawCrosshair2(); diff --git a/src/m_menu.c b/src/m_menu.c index c5691a7c3..ead0fe544 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1038,10 +1038,8 @@ static menuitem_t OP_P1ControlsMenu[] = {IT_SUBMENU | IT_STRING, NULL, "Camera Options...", &OP_CameraOptionsDef, 50}, - //{IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar[0], 70}, {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake, 70}, {IT_CALL | IT_STRING, NULL, "Play Style...", M_Setup1PPlaystyleMenu, 80}, - //{IT_STRING | IT_CVAR, NULL, "Ability angle", &cv_abilitydirection[0], 90}, }; static menuitem_t OP_P2ControlsMenu[] = @@ -1052,10 +1050,8 @@ static menuitem_t OP_P2ControlsMenu[] = {IT_SUBMENU | IT_STRING, NULL, "Camera Options...", &OP_Camera2OptionsDef, 50}, - //{IT_STRING | IT_CVAR, NULL, "Character angle", &cv_directionchar[1], 70}, {IT_STRING | IT_CVAR, NULL, "Automatic braking", &cv_autobrake2, 70}, {IT_CALL | IT_STRING, NULL, "Play Style...", M_Setup2PPlaystyleMenu, 80}, - //{IT_STRING | IT_CVAR, NULL, "Ability angle", &cv_abilitydirection[1], 90}, }; static menuitem_t OP_ChangeControlsMenu[] = @@ -4318,7 +4314,7 @@ static void M_DrawControlsDefMenu(void) if (currentMenu == &OP_P1ControlsDef) { - opt = cv_useranalog[0].value ? 3 : (cv_abilitydirection[0].value ? 2 : cv_directionchar[0].value); + opt = cv_useranalog[0].value ? 3 - cv_directionchar[0].value : cv_directionchar[0].value; if (opt == 2) { @@ -4333,7 +4329,7 @@ static void M_DrawControlsDefMenu(void) } else { - opt = cv_useranalog[1].value ? 3 : (cv_abilitydirection[1].value ? 2 : cv_directionchar[1].value); + opt = cv_useranalog[1].value ? 3 - cv_directionchar[1].value : cv_directionchar[1].value; if (opt == 2) { @@ -11619,7 +11615,7 @@ static void M_Setup1PPlaystyleMenu(INT32 choice) (void)choice; playstyle_activeplayer = 0; - playstyle_currentchoice = cv_useranalog[0].value ? 3 : (cv_abilitydirection[0].value ? 2 : cv_directionchar[0].value); + playstyle_currentchoice = cv_useranalog[0].value ? 3 - cv_directionchar[0].value : cv_directionchar[0].value; OP_PlaystyleDef.prevMenu = &OP_P1ControlsDef; M_SetupNextMenu(&OP_PlaystyleDef); } @@ -11629,7 +11625,7 @@ static void M_Setup2PPlaystyleMenu(INT32 choice) (void)choice; playstyle_activeplayer = 1; - playstyle_currentchoice = cv_useranalog[1].value ? 3 : (cv_abilitydirection[1].value ? 2 : cv_directionchar[1].value); + playstyle_currentchoice = cv_useranalog[1].value ? 3 - cv_directionchar[1].value : cv_directionchar[1].value; OP_PlaystyleDef.prevMenu = &OP_P2ControlsDef; M_SetupNextMenu(&OP_PlaystyleDef); } @@ -11662,16 +11658,13 @@ static void M_HandlePlaystyleMenu(INT32 choice) case KEY_ENTER: S_StartSound(NULL, sfx_menu1); - if (cv_abilitydirection[playstyle_activeplayer].value != (playstyle_currentchoice/2)) - { - CV_SetValue(&cv_abilitydirection[playstyle_activeplayer], playstyle_currentchoice/2); - if (playstyle_activeplayer) - CV_UpdateCam2Dist(); - else - CV_UpdateCamDist(); - } CV_SetValue((playstyle_activeplayer ? &cv_directionchar[1] : &cv_directionchar[0]), playstyle_currentchoice ? 1 : 0); - CV_SetValue((playstyle_activeplayer ? &cv_useranalog[1] : &cv_useranalog[0]), 0); + CV_SetValue((playstyle_activeplayer ? &cv_useranalog[1] : &cv_useranalog[0]), playstyle_currentchoice/2); + + if (playstyle_activeplayer) + CV_UpdateCam2Dist(); + else + CV_UpdateCamDist(); M_SetupNextMenu(currentMenu->prevMenu); break; diff --git a/src/p_user.c b/src/p_user.c index 3a6425478..25448ffb3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9792,14 +9792,14 @@ consvar_t cv_cam_saveheight[2][2] = { void CV_UpdateCamDist(void) { - CV_Set(&cv_cam_dist, va("%f", FIXED_TO_FLOAT(cv_cam_savedist[cv_abilitydirection[0].value][0].value))); - CV_Set(&cv_cam_height, va("%f", FIXED_TO_FLOAT(cv_cam_saveheight[cv_abilitydirection[0].value][0].value))); + CV_Set(&cv_cam_dist, va("%f", FIXED_TO_FLOAT(cv_cam_savedist[cv_useranalog[0].value][0].value))); + CV_Set(&cv_cam_height, va("%f", FIXED_TO_FLOAT(cv_cam_saveheight[cv_useranalog[0].value][0].value))); } void CV_UpdateCam2Dist(void) { - CV_Set(&cv_cam2_dist, va("%f", FIXED_TO_FLOAT(cv_cam_savedist[cv_abilitydirection[1].value][1].value))); - CV_Set(&cv_cam2_height, va("%f", FIXED_TO_FLOAT(cv_cam_saveheight[cv_abilitydirection[1].value][1].value))); + CV_Set(&cv_cam2_dist, va("%f", FIXED_TO_FLOAT(cv_cam_savedist[cv_useranalog[1].value][1].value))); + CV_Set(&cv_cam2_height, va("%f", FIXED_TO_FLOAT(cv_cam_saveheight[cv_useranalog[1].value][1].value))); } fixed_t t_cam_dist = -42; @@ -9835,8 +9835,8 @@ void P_ResetCamera(player_t *player, camera_t *thiscam) thiscam->y = y; thiscam->z = z; - if ((thiscam == &camera && cv_abilitydirection[0].value) - || (thiscam == &camera2 && cv_abilitydirection[1].value)) + if ((thiscam == &camera && G_ControlStyle(1) == CS_SIMPLE) + || (thiscam == &camera2 && G_ControlStyle(2) == CS_SIMPLE)) { thiscam->angle = (thiscam == &camera) ? localangle : localangle2; thiscam->aiming = (thiscam == &camera) ? localaiming : localaiming2; @@ -10075,7 +10075,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } } - if (cv_abilitydirection[(thiscam == &camera) ? 0 : 1].value && !sign) + if (G_ControlStyle((thiscam == &camera) ? 1 : 2) == CS_SIMPLE && !sign) { // Shift the camera slightly to the sides depending on the player facing direction UINT8 forplayer = (thiscam == &camera) ? 0 : 1; From 2c45ecbaa5f21c1940446e4817a783ef41b921f9 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 15:34:43 -0600 Subject: [PATCH 090/126] Fix camera reset button --- src/d_netcmd.c | 8 ++++---- src/g_game.c | 7 +++++-- src/m_menu.c | 12 ++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 12a62a6b8..c7f1b765d 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1508,9 +1508,9 @@ void SendWeaponPref(void) buf[0] = 0; if (cv_flipcam.value) buf[0] |= 1; - if (cv_analog[0].value) + if (cv_analog[0].value && cv_directionchar[0].value != 2) buf[0] |= 2; - if (cv_directionchar[0].value) + if (cv_directionchar[0].value == 1) buf[0] |= 4; if (cv_autobrake.value) buf[0] |= 8; @@ -1524,9 +1524,9 @@ void SendWeaponPref2(void) buf[0] = 0; if (cv_flipcam2.value) buf[0] |= 1; - if (cv_analog[1].value) + if (cv_analog[1].value && cv_directionchar[1].value != 2) buf[0] |= 2; - if (cv_directionchar[1].value) + if (cv_directionchar[1].value == 1) buf[0] |= 4; if (cv_autobrake2.value) buf[0] |= 8; diff --git a/src/g_game.c b/src/g_game.c index ce661cc97..86e0491cf 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -398,7 +398,7 @@ consvar_t cv_useranalog[2] = { }; // deez New User eXperiences -static CV_PossibleValue_t directionchar_cons_t[] = {{0, "Camera"}, {1, "Movement"}, {0, NULL}}; +static CV_PossibleValue_t directionchar_cons_t[] = {{0, "Camera"}, {1, "Movement"}, {2, "Simple Locked"}, {0, NULL}}; consvar_t cv_directionchar[2] = { {"directionchar", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar_OnChange, 0, NULL, NULL, 0, 0, NULL}, {"directionchar2", "Movement", CV_SAVE|CV_CALL, directionchar_cons_t, DirectionChar2_OnChange, 0, NULL, NULL, 0, 0, NULL} @@ -1412,7 +1412,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { if (controlstyle == CS_SIMPLE && !ticcmd_centerviewdown[forplayer] && !G_RingSlingerGametype()) { - CV_SetValue(&cv_directionchar[forplayer], 0); ///@TODO will break things + CV_SetValue(&cv_directionchar[forplayer], 2); *myangle = player->mo->angle; *myaiming = 0; @@ -1487,6 +1487,9 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } } + if (ticcmd_centerviewdown[forplayer] && controlstyle == CS_SIMPLE) + controlstyle = CS_LEGACY; + if (PLAYERINPUTDOWN(ssplayer, gc_camreset)) { if (camera.chase && !resetdown[forplayer]) diff --git a/src/m_menu.c b/src/m_menu.c index ead0fe544..01baa9963 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4306,6 +4306,8 @@ const char *PlaystyleDesc[4] = { "instead!" }; +static UINT8 playstyle_activeplayer = 0, playstyle_currentchoice = 0; + static void M_DrawControlsDefMenu(void) { UINT8 opt = 0; @@ -4314,7 +4316,8 @@ static void M_DrawControlsDefMenu(void) if (currentMenu == &OP_P1ControlsDef) { - opt = cv_useranalog[0].value ? 3 - cv_directionchar[0].value : cv_directionchar[0].value; + opt = cv_directionchar[0].value ? 1 : 0; + opt = playstyle_currentchoice = cv_useranalog[0].value ? 3 - opt : opt; if (opt == 2) { @@ -4329,7 +4332,8 @@ static void M_DrawControlsDefMenu(void) } else { - opt = cv_useranalog[1].value ? 3 - cv_directionchar[1].value : cv_directionchar[1].value; + opt = cv_directionchar[1].value ? 1 : 0; + opt = playstyle_currentchoice = cv_useranalog[1].value ? 3 - opt : opt; if (opt == 2) { @@ -11608,14 +11612,11 @@ static void M_ChangeControl(INT32 choice) M_StartMessage(tmp, M_ChangecontrolResponse, MM_EVENTHANDLER); } -static UINT8 playstyle_activeplayer = 0, playstyle_currentchoice = 0; - static void M_Setup1PPlaystyleMenu(INT32 choice) { (void)choice; playstyle_activeplayer = 0; - playstyle_currentchoice = cv_useranalog[0].value ? 3 - cv_directionchar[0].value : cv_directionchar[0].value; OP_PlaystyleDef.prevMenu = &OP_P1ControlsDef; M_SetupNextMenu(&OP_PlaystyleDef); } @@ -11625,7 +11626,6 @@ static void M_Setup2PPlaystyleMenu(INT32 choice) (void)choice; playstyle_activeplayer = 1; - playstyle_currentchoice = cv_useranalog[1].value ? 3 - cv_directionchar[1].value : cv_directionchar[1].value; OP_PlaystyleDef.prevMenu = &OP_P2ControlsDef; M_SetupNextMenu(&OP_PlaystyleDef); } From 85e2e92ee09ed84fea54767681893234ffcbf967 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 15:44:52 -0600 Subject: [PATCH 091/126] Fix spying on simple mode players having dumb camera angles --- src/p_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 25448ffb3..c88566f4d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9960,7 +9960,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall } else { - focusangle = mo->angle; + focusangle = player->cmd.angleturn << 16; focusaiming = player->aiming; } From 0eb65d0fa75c998c2282e1fdc1f47c140d43d516 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Mon, 30 Dec 2019 23:58:58 -0600 Subject: [PATCH 092/126] Fix tailsbot behavior that broke with Simple mode --- src/b_bot.c | 18 +++++++++++------- src/g_game.c | 3 ++- src/g_game.h | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index cd5edf990..c300466ad 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -127,13 +127,17 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) } // Orientation - if ((bot->pflags & (PF_SPINNING|PF_STARTDASH)) || flymode == 2) + if (bot->pflags & (PF_SPINNING|PF_STARTDASH)) { - cmd->angleturn = (sonic->angle - tails->angle) >> FRACBITS; + cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT + } + else if (flymode == 2) + { + cmd->angleturn = sonic->player->cmd.angleturn - (tails->angle >> 16); } else { - cmd->angleturn = (ang - tails->angle) >> FRACBITS; + cmd->angleturn = (ang - tails->angle) >> 16; // NOT FRACBITS DAMNIT } // ******** @@ -222,7 +226,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) { if (dist < followthres && dist > touchdist) // Do positioning { - cmd->angleturn = (ang - tails->angle) >> FRACBITS; + cmd->angleturn = (ang - tails->angle) >> 16; // NOT FRACBITS DAMNIT cmd->forwardmove = 50; spinmode = true; } @@ -230,7 +234,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) { if (!bmom && (!(bot->pflags & PF_SPINNING) || (bot->dashspeed && bot->pflags & PF_SPINNING))) { - cmd->angleturn = (sonic->angle - tails->angle) >> FRACBITS; + cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT spin = true; } spinmode = true; @@ -244,7 +248,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) if (bot->pflags & PF_SPINNING || !spin_last) { spin = true; - cmd->angleturn = (sonic->angle - tails->angle) >> FRACBITS; + cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT cmd->forwardmove = MAXPLMOVE; spinmode = true; } @@ -290,7 +294,7 @@ static void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd) else if (dist < followmin) { // Copy inputs - cmd->angleturn = (sonic->angle - tails->angle) >> FRACBITS; + cmd->angleturn = (sonic->angle - tails->angle) >> 16; // NOT FRACBITS DAMNIT bot->drawangle = ang; cmd->forwardmove = 8 * pcmd->forwardmove / 10; cmd->sidemove = 8 * pcmd->sidemove / 10; diff --git a/src/g_game.c b/src/g_game.c index 86e0491cf..f73b6cffd 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1615,9 +1615,10 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver B_BuildTiccmd(player, cmd); - } } + else if (player->bot == 2) + *myangle = localangle; // Fix offset angle for P2-controlled Tailsbot when P2's controls are set to non-Legacy if (controlstyle == CS_LMAOGALOG) { if (player->awayviewtics) diff --git a/src/g_game.h b/src/g_game.h index 27cb8bc00..de814109e 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -78,7 +78,7 @@ typedef enum { CS_STANDARD, CS_SIMPLE = CS_LMAOGALOG|CS_STANDARD, } controlstyle_e; -#define G_ControlStyle(ssplayer) ((cv_analog[(ssplayer)-1].value ? CS_LMAOGALOG : 0) | (cv_directionchar[(ssplayer)-1].value ? CS_STANDARD : 0)) +#define G_ControlStyle(ssplayer) (cv_directionchar[(ssplayer)-1].value == 3 ? CS_LMAOGALOG : ((cv_analog[(ssplayer)-1].value ? CS_LMAOGALOG : 0) | (cv_directionchar[(ssplayer)-1].value ? CS_STANDARD : 0))) #define P_ControlStyle(player) ((((player)->pflags & PF_ANALOGMODE) ? CS_LMAOGALOG : 0) | (((player)->pflags & PF_DIRECTIONCHAR) ? CS_STANDARD : 0)) extern consvar_t cv_autobrake, cv_autobrake2; From 98b7d8aaca1e9c667b4d8ee55d7015998588646f Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 15:55:18 -0300 Subject: [PATCH 093/126] Fix broken model light lists in ACZ3 --- src/hardware/hw_md2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 630c1e181..13a8cc44e 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1108,7 +1108,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) { sector_t *sector = spr->mobj->subsector->sector; UINT8 lightlevel = 255; - extracolormap_t *colormap = sector->extra_colormap; + extracolormap_t *colormap = NULL; if (sector->numlights) { From 401c35b4075d2345609b690420705c81d34b6423 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 17:28:22 -0300 Subject: [PATCH 094/126] Fix transparent PNG conversion --- src/r_patch.c | 61 ++++++++++++++++++++++++++++++++++++++++++--------- src/r_patch.h | 2 +- src/w_wad.c | 31 +++++++++++++------------- 3 files changed, 67 insertions(+), 27 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index 18dfe523a..7508234a5 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -250,6 +250,9 @@ patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffse UINT8 *colpointers, *startofspan; size_t size = 0; + if (!raw) + return NULL; + // Write image size and offset WRITEINT16(imgptr, width); WRITEINT16(imgptr, height); @@ -353,12 +356,13 @@ patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffse // // Convert a 16-bit flat to a patch. // -patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *size) +patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) { UINT32 x, y; UINT8 *img; UINT8 *imgptr = imgbuf; UINT8 *colpointers, *startofspan; + size_t size = 0; if (!raw) return NULL; @@ -366,9 +370,8 @@ patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *s // Write image size and offset WRITEINT16(imgptr, width); WRITEINT16(imgptr, height); - // no offsets - WRITEINT16(imgptr, 0); - WRITEINT16(imgptr, 0); + WRITEINT16(imgptr, leftoffset); + WRITEINT16(imgptr, topoffset); // Leave placeholder to column pointers colpointers = imgptr; @@ -452,9 +455,12 @@ patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *s WRITEUINT8(imgptr, 0xFF); } - *size = imgptr-imgbuf; - img = Z_Malloc(*size, PU_STATIC, NULL); - memcpy(img, imgbuf, *size); + size = imgptr-imgbuf; + img = Z_Malloc(size, PU_STATIC, NULL); + memcpy(img, imgbuf, size); + + if (destsize != NULL) + *destsize = size; return (patch_t *)img; } @@ -677,6 +683,41 @@ static UINT8 *PNG_RawConvert(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topo return flat; } +// Convert a PNG with transparency to a raw image. +static UINT16 *PNG_RawConvert_16bpp(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size) +{ + UINT16 *flat; + png_uint_32 x, y; + png_bytep *row_pointers = PNG_Read(png, w, h, topoffset, leftoffset, size); + png_uint_32 width = *w, height = *h; + size_t flatsize, i; + + if (!row_pointers) + I_Error("PNG_RawConvert_16bpp: conversion failed"); + + // Convert the image to 16bpp + flatsize = (width * height); + flat = Z_Malloc(flatsize * sizeof(UINT16), PU_LEVEL, NULL); + + // can't memset here + for (i = 0; i < flatsize; i++) + flat[i] = 0xFF00; + + for (y = 0; y < height; y++) + { + png_bytep row = row_pointers[y]; + for (x = 0; x < width; x++) + { + png_bytep px = &(row[x * 4]); + if ((UINT8)px[3]) + flat[((y * width) + x)] = NearestColor((UINT8)px[0], (UINT8)px[1], (UINT8)px[2]); + } + } + free(row_pointers); + + return flat; +} + // // R_PNGToFlat // @@ -696,12 +737,12 @@ patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean t { UINT16 width, height; INT16 topoffset = 0, leftoffset = 0; - UINT8 *raw = PNG_RawConvert(png, &width, &height, &topoffset, &leftoffset, size); + UINT16 *raw = PNG_RawConvert_16bpp(png, &width, &height, &topoffset, &leftoffset, size); if (!raw) I_Error("R_PNGToPatch: conversion failed"); - return R_FlatToPatch(raw, width, height, leftoffset, topoffset, destsize, transparency); + return R_FlatToPatch_16bpp(raw, width, height, leftoffset, topoffset, destsize); } // @@ -1264,7 +1305,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp } // make patch - newpatch = R_FlatToPatch_16bpp(rawdst, newwidth, newheight, &size); + newpatch = R_FlatToPatch_16bpp(rawdst, newwidth, newheight, 0, 0, &size); { newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px); newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py); diff --git a/src/r_patch.h b/src/r_patch.h index 53d306b88..71f715ccc 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -47,7 +47,7 @@ void R_TextureToFlat(size_t tex, UINT8 *flat); void R_PatchToFlat(patch_t *patch, UINT8 *flat); void R_PatchToFlat_16bpp(patch_t *patch, UINT16 *raw, boolean flip); patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency); -patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, size_t *size); +patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); // Portable Network Graphics boolean R_IsLumpPNG(const UINT8 *d, size_t s); diff --git a/src/w_wad.c b/src/w_wad.c index d8b362d49..82f9526c6 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1465,6 +1465,21 @@ boolean W_IsPatchCached(lumpnum_t lumpnum, void *ptr) return W_IsPatchCachedPWAD(WADFILENUM(lumpnum),LUMPNUM(lumpnum), ptr); } +void W_FlushCachedPatches(void) +{ + if (needpatchflush) + { + Z_FreeTag(PU_CACHE); + Z_FreeTag(PU_PATCH); + Z_FreeTag(PU_HUDGFX); + Z_FreeTag(PU_HWRPATCHINFO); + Z_FreeTag(PU_HWRMODELTEXTURE); + Z_FreeTag(PU_HWRCACHE); + Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRPATCHINFO_UNLOCKED); + } + needpatchflush = false; +} + // ========================================================================== // W_CacheLumpName // ========================================================================== @@ -1488,22 +1503,6 @@ void *W_CacheLumpName(const char *name, INT32 tag) // Cache a patch into heap memory, convert the patch format as necessary // -void W_FlushCachedPatches(void) -{ - if (needpatchflush) - { - Z_FreeTag(PU_CACHE); - Z_FreeTag(PU_PATCH); - Z_FreeTag(PU_HUDGFX); - Z_FreeTag(PU_HWRPATCHINFO); - Z_FreeTag(PU_HWRMODELTEXTURE); - Z_FreeTag(PU_HWRCACHE); - Z_FreeTags(PU_HWRCACHE_UNLOCKED, PU_HWRPATCHINFO_UNLOCKED); - } - needpatchflush = false; -} - -// Software-only compile cache the data without conversion void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) { #ifdef HWRENDER From 6d2f2e0865ffceb59e825897d5eda5b23facf541 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 17:30:07 -0300 Subject: [PATCH 095/126] Update copyrights --- src/r_patch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index 7508234a5..db5d874b4 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -2,8 +2,8 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 2005-2009 by Andrey "entryway" Budko. -// Copyright (C) 2018-2019 by Jaime "Lactozilla" Passos. -// Copyright (C) 2019 by Sonic Team Junior. +// Copyright (C) 2018-2020 by Jaime "Lactozilla" Passos. +// Copyright (C) 2019-2020 by Sonic Team Junior. // // This program is free software distributed under the // terms of the GNU General Public License, version 2. From c7794d4ce03eff87afd40d59234de7129c319dc7 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 17:36:55 -0300 Subject: [PATCH 096/126] Remove unused parameter --- src/hardware/hw_cache.c | 4 ++-- src/r_data.c | 2 +- src/r_patch.c | 2 +- src/r_patch.h | 2 +- src/r_things.c | 2 +- src/w_wad.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index c47833187..46f7b2bde 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -654,7 +654,7 @@ static void HWR_GenerateTexture(INT32 texnum, GLTexture_t *grtex) #ifndef NO_PNG_LUMPS if (R_IsLumpPNG((UINT8 *)realpatch, lumplength)) - realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL, false); + realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL); else #endif #ifdef WALLFLATS @@ -698,7 +698,7 @@ void HWR_MakePatch (const patch_t *patch, GLPatch_t *grPatch, GLMipmap_t *grMipm // lump is a png so convert it size_t len = W_LumpLengthPwad(grPatch->wadnum, grPatch->lumpnum); if ((patch != NULL) && R_IsLumpPNG((const UINT8 *)patch, len)) - patch = R_PNGToPatch((const UINT8 *)patch, len, NULL, true); + patch = R_PNGToPatch((const UINT8 *)patch, len, NULL); #endif // don't do it twice (like a cache) diff --git a/src/r_data.c b/src/r_data.c index bfd83a62d..5eac508d6 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -571,7 +571,7 @@ static UINT8 *R_GenerateTexture(size_t texnum) #ifndef NO_PNG_LUMPS if (R_IsLumpPNG((UINT8 *)realpatch, lumplength)) - realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL, false); + realpatch = R_PNGToPatch((UINT8 *)realpatch, lumplength, NULL); else #endif #ifdef WALLFLATS diff --git a/src/r_patch.c b/src/r_patch.c index db5d874b4..308385686 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -733,7 +733,7 @@ UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size) // // Convert a PNG to a patch. // -patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean transparency) +patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize) { UINT16 width, height; INT16 topoffset = 0, leftoffset = 0; diff --git a/src/r_patch.h b/src/r_patch.h index 71f715ccc..2a216193f 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -55,7 +55,7 @@ boolean R_IsLumpPNG(const UINT8 *d, size_t s); #ifndef NO_PNG_LUMPS UINT8 *R_PNGToFlat(UINT16 *width, UINT16 *height, UINT8 *png, size_t size); -patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize, boolean transparency); +patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize); boolean R_PNGDimensions(UINT8 *png, INT16 *width, INT16 *height, size_t size); #endif diff --git a/src/r_things.c b/src/r_things.c index a328da03a..7ecb14e7e 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -284,7 +284,7 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, // lump is a png so convert it if (R_IsLumpPNG((UINT8 *)png, len)) { - png = R_PNGToPatch((UINT8 *)png, len, NULL, true); + png = R_PNGToPatch((UINT8 *)png, len, NULL); M_Memcpy(&patch, png, sizeof(INT16)*4); } Z_Free(png); diff --git a/src/w_wad.c b/src/w_wad.c index 82f9526c6..bbb30d3fa 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1540,7 +1540,7 @@ void *W_CachePatchNumPwad(UINT16 wad, UINT16 lump, INT32 tag) if (R_IsLumpPNG((UINT8 *)lumpdata, len)) { size_t newlen; - srcdata = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen, true); + srcdata = R_PNGToPatch((UINT8 *)lumpdata, len, &newlen); ptr = Z_Realloc(ptr, newlen, tag, &lumpcache[lump]); M_Memcpy(ptr, srcdata, newlen); Z_Free(srcdata); From 03d4082f218fa3cb8282357d70e2bcd838d0e69d Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 17:46:26 -0300 Subject: [PATCH 097/126] Rename functions --- src/r_patch.c | 29 +++++++++++++++++------------ src/r_patch.h | 4 ++-- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/r_patch.c b/src/r_patch.c index 308385686..31f4411b1 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -201,11 +201,15 @@ void R_PatchToFlat(patch_t *patch, UINT8 *flat) } // -// R_PatchToFlat_16bpp +// R_PatchToMaskedFlat // -// Convert a patch to a 16-bit flat. +// Convert a patch to a masked flat. +// Now, what is a "masked" flat anyway? +// It means the flat uses two bytes to store image data. +// The upper byte is used to store the transparent pixel, +// and the lower byte stores a palette index. // -void R_PatchToFlat_16bpp(patch_t *patch, UINT16 *raw, boolean flip) +void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip) { fixed_t col, ofs; column_t *column; @@ -352,11 +356,12 @@ patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffse } // -// R_FlatToPatch_16bpp +// R_MaskedFlatToPatch // -// Convert a 16-bit flat to a patch. +// Convert a masked flat to a patch. +// Explanation of "masked" flats in R_PatchToMaskedFlat. // -patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) +patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize) { UINT32 x, y; UINT8 *img; @@ -684,7 +689,7 @@ static UINT8 *PNG_RawConvert(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topo } // Convert a PNG with transparency to a raw image. -static UINT16 *PNG_RawConvert_16bpp(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size) +static UINT16 *PNG_MaskedRawConvert(const UINT8 *png, UINT16 *w, UINT16 *h, INT16 *topoffset, INT16 *leftoffset, size_t size) { UINT16 *flat; png_uint_32 x, y; @@ -693,7 +698,7 @@ static UINT16 *PNG_RawConvert_16bpp(const UINT8 *png, UINT16 *w, UINT16 *h, INT1 size_t flatsize, i; if (!row_pointers) - I_Error("PNG_RawConvert_16bpp: conversion failed"); + I_Error("PNG_MaskedRawConvert: conversion failed"); // Convert the image to 16bpp flatsize = (width * height); @@ -737,12 +742,12 @@ patch_t *R_PNGToPatch(const UINT8 *png, size_t size, size_t *destsize) { UINT16 width, height; INT16 topoffset = 0, leftoffset = 0; - UINT16 *raw = PNG_RawConvert_16bpp(png, &width, &height, &topoffset, &leftoffset, size); + UINT16 *raw = PNG_MaskedRawConvert(png, &width, &height, &topoffset, &leftoffset, size); if (!raw) I_Error("R_PNGToPatch: conversion failed"); - return R_FlatToPatch_16bpp(raw, width, height, leftoffset, topoffset, destsize); + return R_MaskedFlatToPatch(raw, width, height, leftoffset, topoffset, destsize); } // @@ -1209,7 +1214,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp for (i = 0; i < size; i++) rawsrc[i] = 0xFF00; - R_PatchToFlat_16bpp(patch, rawsrc, bflip); + R_PatchToMaskedFlat(patch, rawsrc, bflip); // Don't cache angle = 0 for (angle = 1; angle < ROTANGLES; angle++) @@ -1305,7 +1310,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp } // make patch - newpatch = R_FlatToPatch_16bpp(rawdst, newwidth, newheight, 0, 0, &size); + newpatch = R_MaskedFlatToPatch(rawdst, newwidth, newheight, 0, 0, &size); { newpatch->leftoffset = (newpatch->width / 2) + (leftoffset - px); newpatch->topoffset = (newpatch->height / 2) + (patch->topoffset - py); diff --git a/src/r_patch.h b/src/r_patch.h index 2a216193f..f5c98ad76 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -45,9 +45,9 @@ typedef struct boolean R_CheckIfPatch(lumpnum_t lump); void R_TextureToFlat(size_t tex, UINT8 *flat); void R_PatchToFlat(patch_t *patch, UINT8 *flat); -void R_PatchToFlat_16bpp(patch_t *patch, UINT16 *raw, boolean flip); +void R_PatchToMaskedFlat(patch_t *patch, UINT16 *raw, boolean flip); patch_t *R_FlatToPatch(UINT8 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize, boolean transparency); -patch_t *R_FlatToPatch_16bpp(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); +patch_t *R_MaskedFlatToPatch(UINT16 *raw, UINT16 width, UINT16 height, UINT16 leftoffset, UINT16 topoffset, size_t *destsize); // Portable Network Graphics boolean R_IsLumpPNG(const UINT8 *d, size_t s); From 874d4d01ee3320aa1474c1ba83458095fa5bbf26 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Wed, 1 Jan 2020 18:00:01 -0300 Subject: [PATCH 098/126] Don't Y-billboard papersprite models (?!?!??!??!?!?) --- src/hardware/hw_md2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 13a8cc44e..d1d6e91a2 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1145,6 +1145,7 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) INT32 durs = spr->mobj->state->tics; INT32 tics = spr->mobj->tics; //mdlframe_t *next = NULL; + const boolean papersprite = (spr->mobj->frame & FF_PAPERSPRITE); const UINT8 flip = (UINT8)(!(spr->mobj->eflags & MFE_VERTICALFLIP) != !(spr->mobj->frame & FF_VERTICALFLIP)); spritedef_t *sprdef; spriteframe_t *sprframe; @@ -1367,14 +1368,12 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) sprframe = &sprdef->spriteframes[spr->mobj->frame & FF_FRAMEMASK]; - if (sprframe->rotate) + if (sprframe->rotate || papersprite) { fixed_t anglef = AngleFixed(spr->mobj->angle); if (spr->mobj->player) anglef = AngleFixed(spr->mobj->player->drawangle); - else - anglef = AngleFixed(spr->mobj->angle); p.angley = FIXED_TO_FLOAT(anglef); } From eac8732bc85c50059f61b9908ee8a09ba1c32ef2 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Fri, 3 Jan 2020 23:26:31 -0600 Subject: [PATCH 099/126] Make holding both turn keys freeze camera direction (broke in merge) --- src/g_game.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 0a3753972..9bb1c241e 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1291,7 +1291,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } else { - if (turnright) + if (turnright && turnleft); + else if (turnright) cmd->angleturn = (INT16)(cmd->angleturn - ((angleturn[tspeed] * cv_cam_turnmultiplier.value)>>FRACBITS)); else if (turnleft) cmd->angleturn = (INT16)(cmd->angleturn + ((angleturn[tspeed] * cv_cam_turnmultiplier.value)>>FRACBITS)); From 34fe284416dd43beaa41f782c0c98ec7efbd4f1d Mon Sep 17 00:00:00 2001 From: fickleheart Date: Sat, 4 Jan 2020 09:54:56 -0600 Subject: [PATCH 100/126] Fix camera stuff in splitscreen --- src/g_game.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 1abd904c2..0bb6e798f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1291,7 +1291,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } else { - if (turnright) + if (turnright && turnleft); + else if (turnright) cmd->angleturn = (INT16)(cmd->angleturn - ((angleturn[tspeed] * cv_cam_turnmultiplier.value)>>FRACBITS)); else if (turnleft) cmd->angleturn = (INT16)(cmd->angleturn + ((angleturn[tspeed] * cv_cam_turnmultiplier.value)>>FRACBITS)); @@ -1489,8 +1490,8 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (PLAYERINPUTDOWN(ssplayer, gc_camreset)) { - if (camera.chase && !resetdown[forplayer]) - P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], &camera); + if (thiscam->chase && !resetdown[forplayer]) + P_ResetCamera(&players[ssplayer == 1 ? displayplayer : secondarydisplayplayer], thiscam); resetdown[forplayer] = true; } @@ -1508,7 +1509,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) INT32 player_invert = invertmouse ? -1 : 1; INT32 screen_invert = (player->mo && (player->mo->eflags & MFE_VERTICALFLIP) - && (!camera.chase || player->pflags & PF_FLIPCAM)) //because chasecam's not inverted + && (!thiscam->chase || player->pflags & PF_FLIPCAM)) //because chasecam's not inverted ? -1 : 1; // set to -1 or 1 to multiply INT32 lookaxis = ssplayer == 1 ? cv_lookaxis.value : cv_lookaxis2.value; @@ -1592,7 +1593,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) } //Silly hack to make 2d mode *somewhat* playable with no chasecam. - if ((twodlevel || (player->mo && player->mo->flags2 & MF2_TWOD)) && !camera.chase) + if ((twodlevel || (player->mo && player->mo->flags2 & MF2_TWOD)) && !thiscam->chase) { INT32 temp = forward; forward = side; @@ -1628,7 +1629,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->angleturn = (INT16)(*myangle >> 16); // Adjust camera angle by player input - if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) + if (abilitydirection && !forcestrafe && thiscam->chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && !player->climbing && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor = cv_cam_turnfacinginput[forplayer].value; @@ -1648,7 +1649,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->sidemove = 0; } - if (abilitydirection && camera.chase && !ticcmd_centerviewdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) + if (abilitydirection && thiscam->chase && !ticcmd_centerviewdown[forplayer] && !player->climbing && !forcestrafe && (player->pflags & PF_DIRECTIONCHAR) && player->powers[pw_carry] != CR_MINECART) { ///@TODO This block of code is a hack to get the desired abilitydirection and player angle behaviors while remaining netplay-compatible with EXEs without those features. // This has side effects like making F12 spectate look kind of weird, and making the input viewer inaccurate. @@ -1671,7 +1672,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // Adjust camera angle to face player direction, depending on circumstances // Nothing happens if cam left/right are held, so you can hold both to lock the camera in one direction - if (abilitydirection && !forcestrafe && camera.chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && player->powers[pw_carry] != CR_MINECART) + if (abilitydirection && !forcestrafe && thiscam->chase && !turnheld[forplayer] && !ticcmd_centerviewdown[forplayer] && player->powers[pw_carry] != CR_MINECART) { fixed_t camadjustfactor; boolean alt = false; // Reduce intensity on diagonals and prevent backwards movement from turning the camera From 6d754821fbe565ed6dd714c877caad7ed68015f9 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Fri, 3 Jan 2020 23:25:26 -0300 Subject: [PATCH 101/126] AA trees are not needed at all for rotated patches --- src/hardware/hw_cache.c | 17 ----------------- src/hardware/hw_glob.h | 3 --- src/r_defs.h | 3 --- src/r_patch.c | 6 ++++-- src/r_things.c | 3 --- 5 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 46f7b2bde..3b69c3c40 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -1324,23 +1324,6 @@ GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum) return HWR_GetCachedGLPatchPwad(WADFILENUM(lumpnum),LUMPNUM(lumpnum)); } -#ifdef ROTSPRITE -GLPatch_t *HWR_GetCachedGLRotSprite(aatree_t *hwrcache, UINT16 rollangle, patch_t *rawpatch) -{ - GLPatch_t *grpatch; - - if (!(grpatch = M_AATreeGet(hwrcache, rollangle))) - { - grpatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); - grpatch->rawpatch = rawpatch; - grpatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); - M_AATreeSet(hwrcache, rollangle, grpatch); - } - - return grpatch; -} -#endif - // Need to do this because they aren't powers of 2 static void HWR_DrawFadeMaskInCache(GLMipmap_t *mipmap, INT32 pblockwidth, INT32 pblockheight, lumpnum_t fademasklumpnum, UINT16 fmwidth, UINT16 fmheight) diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index cf98e7317..a2bf79817 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -113,9 +113,6 @@ GLPatch_t *HWR_GetPic(lumpnum_t lumpnum); void HWR_SetPalette(RGBA_t *palette); GLPatch_t *HWR_GetCachedGLPatchPwad(UINT16 wad, UINT16 lump); GLPatch_t *HWR_GetCachedGLPatch(lumpnum_t lumpnum); -#ifdef ROTSPRITE -GLPatch_t *HWR_GetCachedGLRotSprite(aatree_t *hwrcache, UINT16 rollangle, patch_t *rawpatch); -#endif void HWR_GetFadeMask(lumpnum_t fademasklumpnum); // -------- diff --git a/src/r_defs.h b/src/r_defs.h index 2791ac8b0..f6ea36f9f 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -740,9 +740,6 @@ typedef struct { patch_t *patch[8][ROTANGLES]; boolean cached[8]; -#ifdef HWRENDER - aatree_t *hardware_patch[8]; -#endif/*HWRENDER*/ } rotsprite_t; #endif/*ROTSPRITE*/ diff --git a/src/r_patch.c b/src/r_patch.c index 31f4411b1..c1f251ae7 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -1326,9 +1326,11 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp #ifdef HWRENDER if (rendermode == render_opengl) { - GLPatch_t *grPatch = HWR_GetCachedGLRotSprite(sprframe->rotsprite.hardware_patch[rot], angle, newpatch); - HWR_MakePatch(newpatch, grPatch, grPatch->mipmap, false); + GLPatch_t *grPatch = Z_Calloc(sizeof(GLPatch_t), PU_HWRPATCHINFO, NULL); + grPatch->mipmap = Z_Calloc(sizeof(GLMipmap_t), PU_HWRPATCHINFO, NULL); + grPatch->rawpatch = newpatch; sprframe->rotsprite.patch[rot][angle] = (patch_t *)grPatch; + HWR_MakePatch(newpatch, grPatch, grPatch->mipmap, false); } else #endif // HWRENDER diff --git a/src/r_things.c b/src/r_things.c index 7ecb14e7e..d22c8d2ca 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -125,9 +125,6 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch sprtemp[frame].rotsprite.cached[r] = false; for (ang = 0; ang < ROTANGLES; ang++) sprtemp[frame].rotsprite.patch[r][ang] = NULL; -#ifdef HWRENDER - sprtemp[frame].rotsprite.hardware_patch[r] = M_AATreeAlloc(AATREE_ZUSER); -#endif/*HWRENDER*/ } #endif/*ROTSPRITE*/ From d93adbacbb60b5f571991bcc7874059db38e7490 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Fri, 3 Jan 2020 23:01:12 -0300 Subject: [PATCH 102/126] Fix GetTextureUsed --- src/hardware/r_opengl/r_opengl.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 129bf5678..9fa49cf76 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2275,14 +2275,30 @@ EXPORT void HWRAPI(SetTransform) (FTransform *stransform) EXPORT INT32 HWRAPI(GetTextureUsed) (void) { - FTextureInfo* tmp = gr_cachehead; - INT32 res = 0; + FTextureInfo *tmp = gr_cachehead; + INT32 res = 0; while (tmp) { - res += tmp->height*tmp->width*(screen_depth/8); + // Figure out the correct bytes-per-pixel for this texture + // I don't know which one the game actually _uses_ but this + // follows format2bpp in hw_cache.c + int bpp = 1; + int format = tmp->grInfo.format; + if (format == GR_RGBA) + bpp = 4; + else if (format == GR_TEXFMT_RGB_565 + || format == GR_TEXFMT_ARGB_1555 + || format == GR_TEXFMT_ARGB_4444 + || format == GR_TEXFMT_ALPHA_INTENSITY_88 + || format == GR_TEXFMT_AP_88) + bpp = 2; + + // Add it up! + res += tmp->height*tmp->width*bpp; tmp = tmp->nextmipmap; } + return res; } From 9086b1851d0c76a52a724e3c183cd1ada4c84f39 Mon Sep 17 00:00:00 2001 From: Jaime Passos Date: Sun, 5 Jan 2020 22:04:19 -0300 Subject: [PATCH 103/126] Fix chroma key --- src/hardware/hw_cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 3b69c3c40..ccffc8a49 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -122,11 +122,11 @@ static void HWR_DrawColumnInCache(const column_t *patchcol, UINT8 *block, GLMipm if (mipmap->colormap) texel = mipmap->colormap[texel]; - // transparent pixel - if (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX) + // If the mipmap is chromakeyed, check if the texel's color + // is equivalent to the chroma key's color index. + alpha = 0xff; + if ((mipmap->flags & TF_CHROMAKEYED) && (texel == HWR_PATCHES_CHROMAKEY_COLORINDEX)) alpha = 0x00; - else - alpha = 0xff; // hope compiler will get this switch out of the loops (dreams...) // gcc do it ! but vcc not ! (why don't use cygwin gcc for win32 ?) From 808d7316527375c323eb1fbd9f492ad07ed253c3 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Mon, 6 Jan 2020 17:16:27 -0500 Subject: [PATCH 104/126] Update copyright statements for changed names --- src/f_wipe.c | 2 +- src/m_anigif.c | 2 +- src/m_anigif.h | 2 +- src/m_cond.c | 2 +- src/m_cond.h | 2 +- src/m_menu.c | 2 +- src/m_menu.h | 2 +- src/m_random.c | 2 +- src/m_random.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/f_wipe.c b/src/f_wipe.c index a83d104f2..a350e0f36 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2013-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 1999-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_anigif.c b/src/m_anigif.c index f761db143..32fc2746d 100644 --- a/src/m_anigif.c +++ b/src/m_anigif.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2013-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2013 by "Ninji". // Copyright (C) 2013-2019 by Sonic Team Junior. // diff --git a/src/m_anigif.h b/src/m_anigif.h index 592d2cf19..9bdf2cc7f 100644 --- a/src/m_anigif.h +++ b/src/m_anigif.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2013-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2013-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2013-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_cond.c b/src/m_cond.c index 1e761fdb4..08f3fe038 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2012-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_cond.h b/src/m_cond.h index 3ea77145d..f4f017787 100644 --- a/src/m_cond.h +++ b/src/m_cond.h @@ -1,6 +1,6 @@ // SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 2012-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_menu.c b/src/m_menu.c index ea2c5c6d8..fb89b7e7b 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2011-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2011-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 1999-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_menu.h b/src/m_menu.h index 00c258fe8..3504868c9 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2011-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2011-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 1999-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_random.c b/src/m_random.c index 8a7b62b19..8fd0e1e4e 100644 --- a/src/m_random.c +++ b/src/m_random.c @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 1999-2019 by Sonic Team Junior. // // This program is free software distributed under the diff --git a/src/m_random.h b/src/m_random.h index fb14249bc..5efd3e02c 100644 --- a/src/m_random.h +++ b/src/m_random.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // Copyright (C) 1993-1996 by id Software, Inc. // Copyright (C) 1998-2000 by DooM Legacy Team. -// Copyright (C) 2012-2016 by Matthew "Inuyasha" Walsh. +// Copyright (C) 2012-2016 by Matthew "Kaito Sinclaire" Walsh. // Copyright (C) 1999-2019 by Sonic Team Junior. // // This program is free software distributed under the From e069e149d983a6795aecb362bd502efa46007dc3 Mon Sep 17 00:00:00 2001 From: lachwright Date: Tue, 7 Jan 2020 13:56:54 +0800 Subject: [PATCH 105/126] Apply skin's highresscale to continue screen --- src/f_finale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/f_finale.c b/src/f_finale.c index bf5f2ba40..bc904d8f2 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -3790,7 +3790,7 @@ void F_ContinueDrawer(void) sprdef = &contskins[n]->sprites[cont_spr2[n][0]];\ sprframe = &sprdef->spriteframes[cont_spr2[n][1]];\ patch = W_CachePatchNum(sprframe->lumppat[cont_spr2[n][2]], PU_PATCH);\ - V_DrawFixedPatch((dx), (dy), FRACUNIT, (sprframe->flip & (1<highresscale, (sprframe->flip & (1< Date: Tue, 7 Jan 2020 15:38:48 +0800 Subject: [PATCH 106/126] Dashmode tweaks: - Remove the ability for non-SF_MACHINE players in dashmode to break spikes and monitors - Replace instances of dashmode magic numbers with dashmode constants - Add dashmode constants to dehacked.c --- src/dehacked.c | 4 ++++ src/p_map.c | 4 ++-- src/p_mobj.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 161a41c46..a4571eddb 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -9461,6 +9461,10 @@ struct { {"SF_MULTIABILITY",SF_MULTIABILITY}, {"SF_NONIGHTSROTATION",SF_NONIGHTSROTATION}, + // Dashmode constants + {"DASHMODE_THRESHOLD",DASHMODE_THRESHOLD}, + {"DASHMODE_MAX",DASHMODE_MAX}, + // Character abilities! // Primary {"CA_NONE",CA_NONE}, // now slot 0! diff --git a/src/p_map.c b/src/p_map.c index a522418f7..c468e5b3c 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -426,7 +426,7 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) object->player->pflags |= pflags; object->player->secondjump = secondjump; } - else if (object->player->dashmode >= 3*TICRATE) + else if (object->player->dashmode >= DASHMODE_THRESHOLD) P_SetPlayerMobjState(object, S_PLAY_DASH); else if (P_IsObjectOnGround(object) && horizspeed >= FixedMul(object->player->runspeed, object->scale)) P_SetPlayerMobjState(object, S_PLAY_RUN); @@ -806,7 +806,7 @@ static boolean PIT_CheckThing(mobj_t *thing) // SF_DASHMODE users destroy spikes and monitors, CA_TWINSPIN users and CA2_MELEE users destroy spikes. if ((tmthing->player) - && (((tmthing->player->charflags & SF_DASHMODE) && (tmthing->player->dashmode >= 3*TICRATE) + && ((((tmthing->player->charflags & (SF_DASHMODE|SF_MACHINE)) == (SF_DASHMODE|SF_MACHINE)) && (tmthing->player->dashmode >= DASHMODE_THRESHOLD) && (thing->flags & (MF_MONITOR) || (thing->type == MT_SPIKE || thing->type == MT_WALLSPIKE))) diff --git a/src/p_mobj.c b/src/p_mobj.c index e8461957f..2f24bc6e0 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3298,7 +3298,7 @@ boolean P_CanRunOnWater(player_t *player, ffloor_t *rover) *rover->topheight; if (!player->powers[pw_carry] && !player->homing - && ((player->powers[pw_super] || player->charflags & SF_RUNONWATER || player->dashmode >= 3*TICRATE) && player->mo->ceilingz-topheight >= player->mo->height) + && ((player->powers[pw_super] || player->charflags & SF_RUNONWATER || player->dashmode >= DASHMODE_THRESHOLD) && player->mo->ceilingz-topheight >= player->mo->height) && (rover->flags & FF_SWIMMABLE) && !(player->pflags & PF_SPINNING) && player->speed > FixedMul(player->runspeed, player->mo->scale) && !(player->pflags & PF_SLIDING) && abs(player->mo->z - topheight) < FixedMul(30*FRACUNIT, player->mo->scale)) From 5abf0c24f962a0034d875c207a8269a679582f07 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 8 Jan 2020 00:21:03 -0600 Subject: [PATCH 107/126] oh god I forget why this is here but let's not remove it now --- src/g_game.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 08e6865e3..33f871a83 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1514,7 +1514,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) (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 - INT32 lookaxis = ssplayer == 1 ? cv_lookaxis.value : cv_lookaxis2.value; + INT32 configlookaxis = ssplayer == 1 ? cv_lookaxis.value : cv_lookaxis2.value; // mouse look stuff (mouse look is not the same as mouse aim) if (mouseaiming) @@ -1525,11 +1525,11 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) *myaiming += (*mly<<19)*player_invert*screen_invert; } - if (analogjoystickmove && joyaiming[forplayer] && lookjoystickvector.yaxis != 0 && lookaxis != 0) + if (analogjoystickmove && joyaiming[forplayer] && lookjoystickvector.yaxis != 0 && configlookaxis != 0) *myaiming += (lookjoystickvector.yaxis<<16) * screen_invert; // spring back if not using keyboard neither mouselookin' - if (!keyboard_look[forplayer] && lookaxis == 0 && !joyaiming[forplayer] && !mouseaiming) + if (!keyboard_look[forplayer] && configlookaxis == 0 && !joyaiming[forplayer] && !mouseaiming) *myaiming = 0; if (!(player->powers[pw_carry] == CR_NIGHTSMODE)) From 6211c80a697f28f80477dc72d13a9c3f99f61fb9 Mon Sep 17 00:00:00 2001 From: fickleheart Date: Wed, 8 Jan 2020 00:22:17 -0600 Subject: [PATCH 108/126] Mixed code and declaration stuff --- src/g_game.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_game.c b/src/g_game.c index 33f871a83..f7778df8f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1641,11 +1641,12 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (camadjustfactor) { fixed_t sine = FINESINE((R_PointToAngle2(0, 0, player->rmomx, player->rmomy) - localangle)>>ANGLETOFINESHIFT); + fixed_t factor; if ((sine > 0) == (cmd->sidemove > 0)) sine = 0; // Prevent jerking right when braking from going left, or vice versa - fixed_t factor = min(40, FixedMul(player->speed, abs(sine))*2 / FRACUNIT); + factor = min(40, FixedMul(player->speed, abs(sine))*2 / FRACUNIT); *myangle -= cmd->sidemove * factor * camadjustfactor; } From 031e7cfb824937fc0e1f9f41304824767c7c525b Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Wed, 8 Jan 2020 08:43:36 +0100 Subject: [PATCH 109/126] Fix a condition in the flame jet thinkers I accidentally messed up --- src/p_mobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index e8461957f..a36189d6e 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7286,7 +7286,7 @@ static void P_FlameJetSceneryThink(mobj_t *mobj) if (!(mobj->flags2 & MF2_FIRING)) return; - if ((leveltime & 3) == 0) + if ((leveltime & 3) != 0) return; // Wave the flames back and forth. Reactiontime determines which direction it's going. @@ -7325,7 +7325,7 @@ static void P_VerticalFlameJetSceneryThink(mobj_t *mobj) if (!(mobj->flags2 & MF2_FIRING)) return; - if ((leveltime & 3) == 0) + if ((leveltime & 3) != 0) return; // Wave the flames back and forth. Reactiontime determines which direction it's going. From faac4ea545fbceb413f8366525e26076b780b349 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Wed, 8 Jan 2020 09:28:37 +0100 Subject: [PATCH 110/126] Don't create colormap data out of sidedef text for fake planes linedef (the colormap data isn't even used anymore) --- src/p_setup.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_setup.c b/src/p_setup.c index c61f97d92..df276d34b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1120,7 +1120,6 @@ static void P_LoadSidedefs(UINT8 *data) // Special info stored in texture fields! switch (sd->special) { - case 63: // Fake floor/ceiling planes case 606: //SoM: 4/4/2000: Just colormap transfer case 447: // Change colormap of tagged sectors! -- Monster Iestyn 14/06/18 case 455: // Fade colormaps! mazmazz 9/12/2018 (:flag_us:) From d865b72b13f68f26ba2551615600001f2ba631cb Mon Sep 17 00:00:00 2001 From: Nami <50415197+namishere@users.noreply.github.com> Date: Wed, 8 Jan 2020 03:48:30 -0800 Subject: [PATCH 111/126] Splits part of PTR_SlideTraverse into a lua-exposed function, exposes P_RailThinker --- src/lua_baselib.c | 26 ++++ src/p_local.h | 1 + src/p_map.c | 299 ++++++++++++++++++++++++---------------------- 3 files changed, 181 insertions(+), 145 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 695e9367e..b6edb5fc2 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -681,6 +681,17 @@ static int lib_pSpawnPlayerMissile(lua_State *L) return 1; } +static int lib_pRailThinker(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + NOHUD + INLEVEL + if (!mobj) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, P_RailThinker(mobj)); + return 1; +} + static int lib_pMobjFlip(lua_State *L) { mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -1406,6 +1417,19 @@ static int lib_pTeleportMove(lua_State *L) return 2; } +static int lib_pCheckMoveBlocked(lua_State *L) +{ + line_t *li = luaL_checkudata(L, 1, META_LINE); + mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); + INLEVEL + if (!li) + return LUA_ErrInvalid(L, "line_t"); + if (!mo) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, P_CheckMoveBlocked(li, mo)); + return 1; +} + static int lib_pSlideMove(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -2979,6 +3003,7 @@ static luaL_Reg lib[] = { {"P_ColorTeamMissile",lib_pColorTeamMissile}, {"P_SPMAngle",lib_pSPMAngle}, {"P_SpawnPlayerMissile",lib_pSpawnPlayerMissile}, + {"P_RailThinker",lib_pRailThinker}, {"P_MobjFlip",lib_pMobjFlip}, {"P_GetMobjGravity",lib_pGetMobjGravity}, {"P_WeaponOrPanel",lib_pWeaponOrPanel}, @@ -3041,6 +3066,7 @@ static luaL_Reg lib[] = { {"P_TryMove",lib_pTryMove}, {"P_Move",lib_pMove}, {"P_TeleportMove",lib_pTeleportMove}, + {"P_CheckMoveBlocked",lib_pCheckMoveBlocked}, {"P_SlideMove",lib_pSlideMove}, {"P_BounceMove",lib_pBounceMove}, {"P_CheckSight", lib_pCheckSight}, diff --git a/src/p_local.h b/src/p_local.h index 88deb0942..22d732298 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -403,6 +403,7 @@ boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam); boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff); boolean P_Move(mobj_t *actor, fixed_t speed); boolean P_TeleportMove(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z); +boolean P_CheckMoveBlocked(line_t *li, mobj_t *mo); void P_SlideMove(mobj_t *mo); void P_BounceMove(mobj_t *mo); boolean P_CheckSight(mobj_t *t1, mobj_t *t2); diff --git a/src/p_map.c b/src/p_map.c index 1b6f23cde..1ca4946ea 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3367,6 +3367,45 @@ static boolean P_IsClimbingValid(player_t *player, angle_t angle) return false; } +// +//P_CheckMoveBlocked +// +boolean P_CheckMoveBlocked(line_t *li, mobj_t *mo) +{ + // one-sided linedefs are always solid to sliding movement. + // one-sided linedef + if (!li->backsector) + { + if (P_PointOnLineSide(mo->x, mo->y, li)) + return true; // don't hit the back side + return false; + } + + if (!(mo->flags & MF_MISSILE)) + { + if (li->flags & ML_IMPASSIBLE) + return false; + + if ((mo->flags & (MF_ENEMY|MF_BOSS)) && li->flags & ML_BLOCKMONSTERS) + return false; + } + + // set openrange, opentop, openbottom + P_LineOpening(li, mo); + + if (openrange < mo->height) + return false; // doesn't fit + + if (opentop - mo->z < mo->height) + return false; // mobj is too high + + if (openbottom - mo->z > FixedMul(MAXSTEPMOVE, mo->scale)) + return false; // too big a step up + + // this line doesn't block movement + return true; +} + // // PTR_SlideTraverse // @@ -3378,163 +3417,133 @@ static boolean PTR_SlideTraverse(intercept_t *in) li = in->d.line; - // one-sided linedefs are always solid to sliding movement. - // one-sided linedef - if (!li->backsector) + if (!P_CheckMoveBlocked(li, slidemo)) { - if (P_PointOnLineSide(slidemo->x, slidemo->y, li)) - return true; // don't hit the back side - goto isblocking; - } - - if (!(slidemo->flags & MF_MISSILE)) - { - if (li->flags & ML_IMPASSIBLE) - goto isblocking; - - if ((slidemo->flags & (MF_ENEMY|MF_BOSS)) && li->flags & ML_BLOCKMONSTERS) - goto isblocking; - } - - // set openrange, opentop, openbottom - P_LineOpening(li, slidemo); - - if (openrange < slidemo->height) - goto isblocking; // doesn't fit - - if (opentop - slidemo->z < slidemo->height) - goto isblocking; // mobj is too high - - if (openbottom - slidemo->z > FixedMul(MAXSTEPMOVE, slidemo->scale)) - goto isblocking; // too big a step up - - // this line doesn't block movement - return true; - - // the line does block movement, - // see if it is closer than best so far -isblocking: - if (li->polyobj && slidemo->player) - { - if ((li->polyobj->lines[0]->backsector->flags & SF_TRIGGERSPECIAL_TOUCH) && !(li->polyobj->flags & POF_NOSPECIALS)) - P_ProcessSpecialSector(slidemo->player, slidemo->subsector->sector, li->polyobj->lines[0]->backsector); - } - - if (slidemo->player && (slidemo->player->pflags & PF_GLIDING || slidemo->player->climbing) - && slidemo->player->charability == CA_GLIDEANDCLIMB) - { - line_t *checkline = li; - sector_t *checksector; - ffloor_t *rover; - fixed_t topheight, bottomheight; - boolean fofline = false; - INT32 side = P_PointOnLineSide(slidemo->x, slidemo->y, li); - - if (!side && li->backsector) - checksector = li->backsector; - else - checksector = li->frontsector; - - if (checksector->ffloors) + // the line does block movement, + // see if it is closer than best so far + if (li->polyobj && slidemo->player) { - for (rover = checksector->ffloors; rover; rover = rover->next) + if ((li->polyobj->lines[0]->backsector->flags & SF_TRIGGERSPECIAL_TOUCH) && !(li->polyobj->flags & POF_NOSPECIALS)) + P_ProcessSpecialSector(slidemo->player, slidemo->subsector->sector, li->polyobj->lines[0]->backsector); + } + + if (slidemo->player && (slidemo->player->pflags & PF_GLIDING || slidemo->player->climbing) + && slidemo->player->charability == CA_GLIDEANDCLIMB) + { + line_t *checkline = li; + sector_t *checksector; + ffloor_t *rover; + fixed_t topheight, bottomheight; + boolean fofline = false; + INT32 side = P_PointOnLineSide(slidemo->x, slidemo->y, li); + + if (!side && li->backsector) + checksector = li->backsector; + else + checksector = li->frontsector; + + if (checksector->ffloors) { - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) - continue; - - topheight = *rover->topheight; - bottomheight = *rover->bottomheight; - -#ifdef ESLOPE - if (*rover->t_slope) - topheight = P_GetZAt(*rover->t_slope, slidemo->x, slidemo->y); - if (*rover->b_slope) - bottomheight = P_GetZAt(*rover->b_slope, slidemo->x, slidemo->y); -#endif - - if (topheight < slidemo->z) - continue; - - if (bottomheight > slidemo->z + slidemo->height) - continue; - - // Got this far, so I guess it's climbable. // TODO: Climbing check, also, better method to do this? - if (rover->master->flags & ML_TFERLINE) + for (rover = checksector->ffloors; rover; rover = rover->next) { - size_t linenum = li-checksector->lines[0]; - checkline = rover->master->frontsector->lines[0] + linenum; - fofline = true; - } + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_BLOCKPLAYER) || (rover->flags & FF_BUSTUP)) + continue; - break; + topheight = *rover->topheight; + bottomheight = *rover->bottomheight; + + #ifdef ESLOPE + if (*rover->t_slope) + topheight = P_GetZAt(*rover->t_slope, slidemo->x, slidemo->y); + if (*rover->b_slope) + bottomheight = P_GetZAt(*rover->b_slope, slidemo->x, slidemo->y); + #endif + + if (topheight < slidemo->z) + continue; + + if (bottomheight > slidemo->z + slidemo->height) + continue; + + // Got this far, so I guess it's climbable. // TODO: Climbing check, also, better method to do this? + if (rover->master->flags & ML_TFERLINE) + { + size_t linenum = li-checksector->lines[0]; + checkline = rover->master->frontsector->lines[0] + linenum; + fofline = true; + } + + break; + } + } + + // see about climbing on the wall + if (!(checkline->flags & ML_NOCLIMB) && checkline->special != HORIZONSPECIAL) + { + boolean canclimb; + angle_t climbangle, climbline; + INT32 whichside = P_PointOnLineSide(slidemo->x, slidemo->y, li); + + climbangle = climbline = R_PointToAngle2(li->v1->x, li->v1->y, li->v2->x, li->v2->y); + + if (whichside) // on second side? + climbline += ANGLE_180; + + climbangle += (ANGLE_90 * (whichside ? -1 : 1)); + + canclimb = (li->backsector ? P_IsClimbingValid(slidemo->player, climbangle) : true); + + if (((!slidemo->player->climbing && abs((signed)(slidemo->angle - ANGLE_90 - climbline)) < ANGLE_45) + || (slidemo->player->climbing == 1 && abs((signed)(slidemo->angle - climbline)) < ANGLE_135)) + && canclimb) + { + slidemo->angle = climbangle; + /*if (!demoplayback || P_AnalogMove(slidemo->player)) + { + if (slidemo->player == &players[consoleplayer]) + localangle = slidemo->angle; + else if (slidemo->player == &players[secondarydisplayplayer]) + localangle2 = slidemo->angle; + }*/ + + if (!slidemo->player->climbing) + { + S_StartSound(slidemo->player->mo, sfx_s3k4a); + slidemo->player->climbing = 5; + } + + slidemo->player->pflags &= ~(PF_GLIDING|PF_SPINNING|PF_JUMPED|PF_NOJUMPDAMAGE|PF_THOKKED); + slidemo->player->glidetime = 0; + slidemo->player->secondjump = 0; + + if (slidemo->player->climbing > 1) + slidemo->momz = slidemo->momx = slidemo->momy = 0; + + if (fofline) + whichside = 0; + + if (!whichside) + { + slidemo->player->lastsidehit = checkline->sidenum[whichside]; + slidemo->player->lastlinehit = (INT16)(checkline - lines); + } + + P_Thrust(slidemo, slidemo->angle, FixedMul(5*FRACUNIT, slidemo->scale)); + } } } - // see about climbing on the wall - if (!(checkline->flags & ML_NOCLIMB) && checkline->special != HORIZONSPECIAL) + if (in->frac < bestslidefrac && (!slidemo->player || !slidemo->player->climbing)) { - boolean canclimb; - angle_t climbangle, climbline; - INT32 whichside = P_PointOnLineSide(slidemo->x, slidemo->y, li); - - climbangle = climbline = R_PointToAngle2(li->v1->x, li->v1->y, li->v2->x, li->v2->y); - - if (whichside) // on second side? - climbline += ANGLE_180; - - climbangle += (ANGLE_90 * (whichside ? -1 : 1)); - - canclimb = (li->backsector ? P_IsClimbingValid(slidemo->player, climbangle) : true); - - if (((!slidemo->player->climbing && abs((signed)(slidemo->angle - ANGLE_90 - climbline)) < ANGLE_45) - || (slidemo->player->climbing == 1 && abs((signed)(slidemo->angle - climbline)) < ANGLE_135)) - && canclimb) - { - slidemo->angle = climbangle; - /*if (!demoplayback || P_AnalogMove(slidemo->player)) - { - if (slidemo->player == &players[consoleplayer]) - localangle = slidemo->angle; - else if (slidemo->player == &players[secondarydisplayplayer]) - localangle2 = slidemo->angle; - }*/ - - if (!slidemo->player->climbing) - { - S_StartSound(slidemo->player->mo, sfx_s3k4a); - slidemo->player->climbing = 5; - } - - slidemo->player->pflags &= ~(PF_GLIDING|PF_SPINNING|PF_JUMPED|PF_NOJUMPDAMAGE|PF_THOKKED); - slidemo->player->glidetime = 0; - slidemo->player->secondjump = 0; - - if (slidemo->player->climbing > 1) - slidemo->momz = slidemo->momx = slidemo->momy = 0; - - if (fofline) - whichside = 0; - - if (!whichside) - { - slidemo->player->lastsidehit = checkline->sidenum[whichside]; - slidemo->player->lastlinehit = (INT16)(checkline - lines); - } - - P_Thrust(slidemo, slidemo->angle, FixedMul(5*FRACUNIT, slidemo->scale)); - } + secondslidefrac = bestslidefrac; + secondslideline = bestslideline; + bestslidefrac = in->frac; + bestslideline = li; } - } - if (in->frac < bestslidefrac && (!slidemo->player || !slidemo->player->climbing)) - { - secondslidefrac = bestslidefrac; - secondslideline = bestslideline; - bestslidefrac = in->frac; - bestslideline = li; + return false; // stop } - - return false; // stop + return true; // keep going! } // From 6476a92817fee8fcb3c3bf6f832a881393d5a989 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 25 Dec 2019 18:46:30 -0500 Subject: [PATCH 112/126] Update blend textures to smooth out colors that have duplicate indices --- src/hardware/hw_md2.c | 101 ++++++++++++++++++++++++++++++++---------- 1 file changed, 77 insertions(+), 24 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 3800b6ad9..23145b525 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -654,10 +654,14 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, UINT16 w = gpatch->width, h = gpatch->height; UINT32 size = w*h; RGBA_t *image, *blendimage, *cur, blendcolor; + UINT8 i; + + UINT8 translation[16]; // First the color index + UINT8 cutoff[16]; // Brightness cutoff before using the next color + UINT8 translen = 0; - // vanilla port - UINT8 translation[16]; memset(translation, 0, sizeof(translation)); + memset(cutoff, 0, sizeof(cutoff)); if (grmip->width == 0) { @@ -684,7 +688,33 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, blendcolor = V_GetColor(0); // initialize if (color != SKINCOLOR_NONE) - memcpy(&translation, &Color_Index[color - 1], 16); + { + UINT8 numdupes = 1; + + translation[translen] = Color_Index[color-1][0]; + cutoff[translen] = 255; + + for (i = 1; i < 16; i++) + { + if (translation[translen] == Color_Index[color-1][i]) + { + numdupes++; + continue; + } + + if (translen > 0) + { + cutoff[translen] = cutoff[translen-1] - (256 / (16 / numdupes)); + } + + numdupes = 1; + translen++; + + translation[translen] = (UINT8)Color_Index[color-1][i]; + } + + translen++; + } while (size--) { @@ -710,7 +740,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, // Turn everything below a certain blue threshold white if (image->s.red == 0 && image->s.green == 0 && image->s.blue <= 82) { - cur->s.red = cur->s.green = cur->s.blue = 255; + cur->s.red = cur->s.green = cur->s.blue = (255 - image->s.blue); } else { @@ -762,6 +792,8 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, { UINT16 brightness; + I_Assert(translen > 0); + // Don't bother with blending the pixel if the alpha of the blend pixel is 0 if (skinnum == TC_RAINBOW) { @@ -798,8 +830,8 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, // (Me splitting this into a function didn't work, so I had to ruin this entire function's groove...) { RGBA_t nextcolor; - UINT8 firsti, secondi, mul; - UINT32 r, g, b; + UINT8 firsti, secondi, mul, mulmax; + INT32 r, g, b; // Rainbow needs to find the closest match to the textures themselves, instead of matching brightnesses to other colors. // Ensue horrible mess. @@ -808,7 +840,6 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, UINT16 brightdif = 256; UINT8 colorbrightnesses[16]; INT32 compare, m, d; - UINT8 i; // Ignore pure white & pitch black if (brightness > 253 || brightness < 2) @@ -820,18 +851,21 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, firsti = 0; mul = 0; + mulmax = 1; - for (i = 0; i < 16; i++) + for (i = 0; i < translen; i++) { RGBA_t tempc = V_GetColor(translation[i]); SETBRIGHTNESS(colorbrightnesses[i], tempc.s.red, tempc.s.green, tempc.s.blue); // store brightnesses for comparison } - for (i = 0; i < 16; i++) + for (i = 0; i < translen; i++) { if (brightness > colorbrightnesses[i]) // don't allow greater matches (because calculating a makeshift gradient for this is already a huge mess as is) continue; + compare = abs((INT16)(colorbrightnesses[i]) - (INT16)(brightness)); + if (compare < brightdif) { brightdif = (UINT16)compare; @@ -840,7 +874,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, } secondi = firsti+1; // next color in line - if (secondi == 16) + if (secondi >= translen) { m = (INT16)brightness; // - 0; d = (INT16)colorbrightnesses[firsti]; // - 0; @@ -856,38 +890,57 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, // calculate the "gradient" multiplier based on how close this color is to the one next in line if (m <= 0 || d <= 0) + { mul = 0; + } else - mul = 15 - ((m * 16) / d); + { + mulmax = cutoff[firsti]; + if (secondi < translen) + mulmax -= cutoff[secondi]; + + mul = (mulmax-1) - ((m * mulmax) / d); + } } else { - // Thankfully, it's normally way more simple. - // Just convert brightness to a skincolor value, use remainder to find the gradient multipler - firsti = ((UINT8)(255-brightness) / 16); + // Just convert brightness to a skincolor value, use distance to next position to find the gradient multipler + firsti = 0; + + for (i = 1; i < translen; i++) + { + if (brightness >= cutoff[i]) + break; + firsti = i; + } + secondi = firsti+1; - mul = ((UINT8)(255-brightness) % 16); + + mulmax = cutoff[firsti]; + if (secondi < translen) + mulmax -= cutoff[secondi]; + + mul = cutoff[firsti] - brightness; } blendcolor = V_GetColor(translation[firsti]); - if (mul > 0 // If it's 0, then we only need the first color. - && translation[firsti] != translation[secondi]) // Some colors have duplicate colors in a row, so let's just save the process + if (mul > 0) // If it's 0, then we only need the first color. { - if (secondi == 16) // blend to black + if (secondi >= translen) // blend to black nextcolor = V_GetColor(31); else nextcolor = V_GetColor(translation[secondi]); // Find difference between points - r = (UINT32)(nextcolor.s.red - blendcolor.s.red); - g = (UINT32)(nextcolor.s.green - blendcolor.s.green); - b = (UINT32)(nextcolor.s.blue - blendcolor.s.blue); + r = (INT32)(nextcolor.s.red - blendcolor.s.red); + g = (INT32)(nextcolor.s.green - blendcolor.s.green); + b = (INT32)(nextcolor.s.blue - blendcolor.s.blue); // Find the gradient of the two points - r = ((mul * r) / 16); - g = ((mul * g) / 16); - b = ((mul * b) / 16); + r = ((mul * r) / mulmax); + g = ((mul * g) / mulmax); + b = ((mul * b) / mulmax); // Add gradient value to color blendcolor.s.red += r; From ac365a0c81204f756ad91a0b07e69748e8e70ac9 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 25 Dec 2019 20:09:31 -0500 Subject: [PATCH 113/126] Fake contrast --- src/hardware/hw_main.c | 66 +++++++++++++++++++++++++++++++++++------- src/hardware/hw_main.h | 1 + 2 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2f986085a..9f6e497a6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1026,6 +1026,46 @@ static float HWR_ClipViewSegment(INT32 x, polyvertex_t *v1, polyvertex_t *v2) } #endif +static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y) +{ + INT16 finallight = lightnum; + + if (cv_grfakecontrast.value != 0) + { + const UINT8 contrast = 8; + fixed_t extralight = 0; + + if (cv_grfakecontrast.value == 2) // Smooth setting + { + extralight = -(contrast<>1)) >> FRACBITS; + } + else + { + if (v1y == v2y) + extralight = -contrast; + else if (v1x == v2x) + extralight = contrast; + } + + if (extralight != 0) + { + finallight += extralight; + + if (finallight < 0) + finallight = 0; + if (finallight > 255) + finallight = 255; + } + } + + return (FUINT)finallight; +} + // // HWR_SplitWall // @@ -1044,19 +1084,20 @@ static void HWR_SplitWall(sector_t *sector, wallVert3D *wallVerts, INT32 texnum, float endpegt, endpegb, endpegmul; float endheight = 0.0f, endbheight = 0.0f; - fixed_t v1x = FLOAT_TO_FIXED(wallVerts[0].x); - fixed_t v1y = FLOAT_TO_FIXED(wallVerts[0].z); // not a typo - fixed_t v2x = FLOAT_TO_FIXED(wallVerts[1].x); - fixed_t v2y = FLOAT_TO_FIXED(wallVerts[1].z); // not a typo // compiler complains when P_GetZAt is used in FLOAT_TO_FIXED directly // use this as a temp var to store P_GetZAt's return value each time fixed_t temp; #endif - INT32 solid, i; + fixed_t v1x = FLOAT_TO_FIXED(wallVerts[0].x); + fixed_t v1y = FLOAT_TO_FIXED(wallVerts[0].z); // not a typo + fixed_t v2x = FLOAT_TO_FIXED(wallVerts[1].x); + fixed_t v2y = FLOAT_TO_FIXED(wallVerts[1].z); // not a typo + + INT32 solid, i; lightlist_t * list = sector->lightlist; const UINT8 alpha = Surf->FlatColor.s.alpha; - FUINT lightnum = sector->lightlevel; + FUINT lightnum = HWR_CalcWallLight(sector->lightlevel, v1x, v1y, v2x, v2y); extracolormap_t *colormap = NULL; realtop = top = wallVerts[3].y; @@ -1086,12 +1127,12 @@ static void HWR_SplitWall(sector_t *sector, wallVert3D *wallVerts, INT32 texnum, { if (pfloor && (pfloor->flags & FF_FOG)) { - lightnum = pfloor->master->frontsector->lightlevel; + lightnum = HWR_CalcWallLight(pfloor->master->frontsector->lightlevel, v1x, v1y, v2x, v2y); colormap = pfloor->master->frontsector->extra_colormap; } else { - lightnum = *list[i].lightlevel; + lightnum = HWR_CalcWallLight(*list[i].lightlevel, v1x, v1y, v2x, v2y); colormap = *list[i].extra_colormap; } } @@ -1395,7 +1436,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) cliphigh = (float)(texturehpeg + (gr_curline->flength*FRACUNIT)); } - lightnum = gr_frontsector->lightlevel; + lightnum = HWR_CalcWallLight(gr_frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = gr_frontsector->extra_colormap; if (gr_frontsector) @@ -2150,7 +2191,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) blendmode = PF_Fog|PF_NoTexture; - lightnum = rover->master->frontsector->lightlevel; + lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = rover->master->frontsector->extra_colormap; if (rover->master->frontsector->extra_colormap) @@ -2270,7 +2311,7 @@ static void HWR_StoreWallRange(double startfrac, double endfrac) blendmode = PF_Fog|PF_NoTexture; - lightnum = rover->master->frontsector->lightlevel; + lightnum = HWR_CalcWallLight(rover->master->frontsector->lightlevel, vs.x, vs.y, ve.x, ve.y); colormap = rover->master->frontsector->extra_colormap; if (rover->master->frontsector->extra_colormap) @@ -6544,6 +6585,7 @@ static void HWR_FoggingOn(void) static CV_PossibleValue_t grsoftwarefog_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "LightPlanes"}, {0, NULL}}; static CV_PossibleValue_t grmodelinterpolation_cons_t[] = {{0, "Off"}, {1, "Sometimes"}, {2, "Always"}, {0, NULL}}; +static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}}; static void CV_grmodellighting_OnChange(void); static void CV_grfiltermode_OnChange(void); @@ -6578,6 +6620,7 @@ consvar_t cv_grmodellighting = {"gr_modellighting", "Off", CV_SAVE|CV_CALL, CV_O consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grskydome = {"gr_skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grfakecontrast = {"gr_fakecontrast", "Smooth", CV_SAVE, grfakecontrast_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grrounddown = {"gr_rounddown", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grfov = {"gr_fov", "90", CV_FLOAT|CV_CALL, grfov_cons_t, CV_grfov_OnChange, 0, NULL, NULL, 0, 0, NULL}; @@ -6646,6 +6689,7 @@ void HWR_AddCommands(void) CV_RegisterVar(&cv_grskydome); CV_RegisterVar(&cv_grspritebillboarding); + CV_RegisterVar(&cv_grfakecontrast); CV_RegisterVar(&cv_grfiltermode); CV_RegisterVar(&cv_grrounddown); diff --git a/src/hardware/hw_main.h b/src/hardware/hw_main.h index 573338226..20ff3ad9f 100644 --- a/src/hardware/hw_main.h +++ b/src/hardware/hw_main.h @@ -99,6 +99,7 @@ extern consvar_t cv_grfovchange; extern consvar_t cv_grsolvetjoin; extern consvar_t cv_grspritebillboarding; extern consvar_t cv_grskydome; +extern consvar_t cv_grfakecontrast; extern float gr_viewwidth, gr_viewheight, gr_baseviewwindowy; From 65a02b0f8f4179ab28ddfdcbc0361fd75830cde6 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 25 Dec 2019 22:50:41 -0500 Subject: [PATCH 114/126] Increase precision of smooth contrast (cherry picked from commit 4c6664292e1f9b0d5c2ff34e28f05a8b63a4dd45) --- src/hardware/hw_main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9f6e497a6..769aad5b7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1037,12 +1037,11 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t if (cv_grfakecontrast.value == 2) // Smooth setting { - extralight = -(contrast<>1)) >> FRACBITS; + * (contrast * 2)) >> FRACBITS; } else { From 15075d4e1be0ce830c7470bc8c0fd29df5d33753 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Sun, 29 Dec 2019 16:36:53 -0500 Subject: [PATCH 115/126] More blend image updates - Allow the translations that don't make use a blend image to work without requiring a blend image to be present - Fix TC_RAINBOW not working properly - TC_METALSONIC now remaps the _blend image to SKINCOLOR_COBALT, then inverts all of the blue, replicating how it works in Software (cherry picked from commit 74d7f256a7849d0c829177614b37089e2446f86b) --- src/hardware/hw_md2.c | 502 ++++++++++++++++++++++-------------------- 1 file changed, 260 insertions(+), 242 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 23145b525..099eaec4f 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -654,12 +654,12 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, UINT16 w = gpatch->width, h = gpatch->height; UINT32 size = w*h; RGBA_t *image, *blendimage, *cur, blendcolor; - UINT8 i; - UINT8 translation[16]; // First the color index UINT8 cutoff[16]; // Brightness cutoff before using the next color UINT8 translen = 0; + UINT8 i; + blendcolor = V_GetColor(0); // initialize memset(translation, 0, sizeof(translation)); memset(cutoff, 0, sizeof(cutoff)); @@ -685,7 +685,10 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, image = gpatch->mipmap->grInfo.data; blendimage = blendgpatch->mipmap->grInfo.data; - blendcolor = V_GetColor(0); // initialize + + // TC_METALSONIC includes an actual skincolor translation, on top of its flashing. + if (skinnum == TC_METALSONIC) + color = SKINCOLOR_COBALT; if (color != SKINCOLOR_NONE) { @@ -721,7 +724,7 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, if (skinnum == TC_BOSS) { // Turn everything below a certain threshold white - if ((image->s.red == image->s.green) && (image->s.green == image->s.blue) && image->s.blue <= 82) + if ((image->s.red == image->s.green) && (image->s.green == image->s.blue) && image->s.blue < 127) { // Lactozilla: Invert the colors cur->s.red = cur->s.green = cur->s.blue = (255 - image->s.blue); @@ -735,53 +738,6 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, cur->s.alpha = image->s.alpha; } - else if (skinnum == TC_METALSONIC) - { - // Turn everything below a certain blue threshold white - if (image->s.red == 0 && image->s.green == 0 && image->s.blue <= 82) - { - cur->s.red = cur->s.green = cur->s.blue = (255 - image->s.blue); - } - else - { - cur->s.red = image->s.red; - cur->s.green = image->s.green; - cur->s.blue = image->s.blue; - } - - cur->s.alpha = image->s.alpha; - } - else if (skinnum == TC_DASHMODE) - { - if (image->s.alpha == 0 && blendimage->s.alpha == 0) - { - // Don't bother with blending the pixel if the alpha of the blend pixel is 0 - cur->rgba = image->rgba; - } - else - { - UINT8 ialpha = 255 - blendimage->s.alpha, balpha = blendimage->s.alpha; - RGBA_t icolor = *image, bcolor; - - memset(&bcolor, 0x00, sizeof(RGBA_t)); - - if (blendimage->s.alpha) - { - bcolor.s.blue = 0; - bcolor.s.red = 255; - bcolor.s.green = (blendimage->s.red + blendimage->s.green + blendimage->s.blue) / 3; - } - if (image->s.alpha && image->s.red > image->s.green << 1) // this is pretty arbitrary, but it works well for Metal Sonic - { - icolor.s.red = image->s.blue; - icolor.s.blue = image->s.red; - } - cur->s.red = (ialpha * icolor.s.red + balpha * bcolor.s.red)/255; - cur->s.green = (ialpha * icolor.s.green + balpha * bcolor.s.green)/255; - cur->s.blue = (ialpha * icolor.s.blue + balpha * bcolor.s.blue)/255; - cur->s.alpha = image->s.alpha; - } - } else if (skinnum == TC_ALLWHITE) { // Turn everything white @@ -790,208 +746,268 @@ static void HWR_CreateBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, } else { - UINT16 brightness; + // Everything below requires a blend image + if (blendimage == NULL) + { + cur->rgba = image->rgba; + goto skippixel; + } - I_Assert(translen > 0); - - // Don't bother with blending the pixel if the alpha of the blend pixel is 0 - if (skinnum == TC_RAINBOW) + // Metal Sonic dash mode + if (skinnum == TC_DASHMODE) { if (image->s.alpha == 0 && blendimage->s.alpha == 0) { + // Don't bother with blending the pixel if the alpha of the blend pixel is 0 cur->rgba = image->rgba; - cur++; image++; blendimage++; - continue; } else { - UINT16 imagebright, blendbright; - SETBRIGHTNESS(imagebright,image->s.red,image->s.green,image->s.blue); - SETBRIGHTNESS(blendbright,blendimage->s.red,blendimage->s.green,blendimage->s.blue); - // slightly dumb average between the blend image color and base image colour, usually one or the other will be fully opaque anyway - brightness = (imagebright*(255-blendimage->s.alpha))/255 + (blendbright*blendimage->s.alpha)/255; + UINT8 ialpha = 255 - blendimage->s.alpha, balpha = blendimage->s.alpha; + RGBA_t icolor = *image, bcolor; + + memset(&bcolor, 0x00, sizeof(RGBA_t)); + + if (blendimage->s.alpha) + { + bcolor.s.blue = 0; + bcolor.s.red = 255; + bcolor.s.green = (blendimage->s.red + blendimage->s.green + blendimage->s.blue) / 3; + } + + if (image->s.alpha && image->s.red > image->s.green << 1) // this is pretty arbitrary, but it works well for Metal Sonic + { + icolor.s.red = image->s.blue; + icolor.s.blue = image->s.red; + } + + cur->s.red = (ialpha * icolor.s.red + balpha * bcolor.s.red)/255; + cur->s.green = (ialpha * icolor.s.green + balpha * bcolor.s.green)/255; + cur->s.blue = (ialpha * icolor.s.blue + balpha * bcolor.s.blue)/255; + cur->s.alpha = image->s.alpha; } } else { - if (blendimage->s.alpha == 0) + // All settings that use skincolors! + UINT16 brightness; + + if (translen <= 0) { cur->rgba = image->rgba; - cur++; image++; blendimage++; - continue; + goto skippixel; + } + + // Don't bother with blending the pixel if the alpha of the blend pixel is 0 + if (skinnum == TC_RAINBOW) + { + if (image->s.alpha == 0 && blendimage->s.alpha == 0) + { + cur->rgba = image->rgba; + goto skippixel; + } + else + { + UINT16 imagebright, blendbright; + SETBRIGHTNESS(imagebright,image->s.red,image->s.green,image->s.blue); + SETBRIGHTNESS(blendbright,blendimage->s.red,blendimage->s.green,blendimage->s.blue); + // slightly dumb average between the blend image color and base image colour, usually one or the other will be fully opaque anyway + brightness = (imagebright*(255-blendimage->s.alpha))/255 + (blendbright*blendimage->s.alpha)/255; + } } else { - SETBRIGHTNESS(brightness,blendimage->s.red,blendimage->s.green,blendimage->s.blue); - } - } - - // Calculate a sort of "gradient" for the skincolor - // (Me splitting this into a function didn't work, so I had to ruin this entire function's groove...) - { - RGBA_t nextcolor; - UINT8 firsti, secondi, mul, mulmax; - INT32 r, g, b; - - // Rainbow needs to find the closest match to the textures themselves, instead of matching brightnesses to other colors. - // Ensue horrible mess. - if (skinnum == TC_RAINBOW) - { - UINT16 brightdif = 256; - UINT8 colorbrightnesses[16]; - INT32 compare, m, d; - - // Ignore pure white & pitch black - if (brightness > 253 || brightness < 2) + if (blendimage->s.alpha == 0) { cur->rgba = image->rgba; - cur++; image++; blendimage++; - continue; + goto skippixel; // for metal sonic blend } - - firsti = 0; - mul = 0; - mulmax = 1; - - for (i = 0; i < translen; i++) + else { - RGBA_t tempc = V_GetColor(translation[i]); - SETBRIGHTNESS(colorbrightnesses[i], tempc.s.red, tempc.s.green, tempc.s.blue); // store brightnesses for comparison + SETBRIGHTNESS(brightness,blendimage->s.red,blendimage->s.green,blendimage->s.blue); } + } - for (i = 0; i < translen; i++) + // Calculate a sort of "gradient" for the skincolor + // (Me splitting this into a function didn't work, so I had to ruin this entire function's groove...) + { + RGBA_t nextcolor; + UINT8 firsti, secondi, mul, mulmax; + INT32 r, g, b; + + // Rainbow needs to find the closest match to the textures themselves, instead of matching brightnesses to other colors. + // Ensue horrible mess. + if (skinnum == TC_RAINBOW) { - if (brightness > colorbrightnesses[i]) // don't allow greater matches (because calculating a makeshift gradient for this is already a huge mess as is) - continue; + UINT16 brightdif = 256; + UINT8 colorbrightnesses[16]; + INT32 compare, m, d; - compare = abs((INT16)(colorbrightnesses[i]) - (INT16)(brightness)); - - if (compare < brightdif) + // Ignore pure white & pitch black + if (brightness > 253 || brightness < 2) { - brightdif = (UINT16)compare; - firsti = i; // best matching color that's equal brightness or darker + cur->rgba = image->rgba; + cur++; image++; blendimage++; + continue; } - } - secondi = firsti+1; // next color in line - if (secondi >= translen) - { - m = (INT16)brightness; // - 0; - d = (INT16)colorbrightnesses[firsti]; // - 0; - } - else - { - m = (INT16)brightness - (INT16)colorbrightnesses[secondi]; - d = (INT16)colorbrightnesses[firsti] - (INT16)colorbrightnesses[secondi]; - } - - if (m >= d) - m = d-1; - - // calculate the "gradient" multiplier based on how close this color is to the one next in line - if (m <= 0 || d <= 0) - { + firsti = 0; mul = 0; + mulmax = 1; + + for (i = 0; i < translen; i++) + { + RGBA_t tempc = V_GetColor(translation[i]); + SETBRIGHTNESS(colorbrightnesses[i], tempc.s.red, tempc.s.green, tempc.s.blue); // store brightnesses for comparison + } + + for (i = 0; i < translen; i++) + { + if (brightness > colorbrightnesses[i]) // don't allow greater matches (because calculating a makeshift gradient for this is already a huge mess as is) + continue; + + compare = abs((INT16)(colorbrightnesses[i]) - (INT16)(brightness)); + + if (compare < brightdif) + { + brightdif = (UINT16)compare; + firsti = i; // best matching color that's equal brightness or darker + } + } + + secondi = firsti+1; // next color in line + if (secondi >= translen) + { + m = (INT16)brightness; // - 0; + d = (INT16)colorbrightnesses[firsti]; // - 0; + } + else + { + m = (INT16)brightness - (INT16)colorbrightnesses[secondi]; + d = (INT16)colorbrightnesses[firsti] - (INT16)colorbrightnesses[secondi]; + } + + if (m >= d) + m = d-1; + + mulmax = 16; + + // calculate the "gradient" multiplier based on how close this color is to the one next in line + if (m <= 0 || d <= 0) + mul = 0; + else + mul = (mulmax-1) - ((m * mulmax) / d); } else { + // Just convert brightness to a skincolor value, use distance to next position to find the gradient multipler + firsti = 0; + + for (i = 1; i < translen; i++) + { + if (brightness >= cutoff[i]) + break; + firsti = i; + } + + secondi = firsti+1; + mulmax = cutoff[firsti]; if (secondi < translen) mulmax -= cutoff[secondi]; - mul = (mulmax-1) - ((m * mulmax) / d); + mul = cutoff[firsti] - brightness; } + + blendcolor = V_GetColor(translation[firsti]); + + if (mul > 0) // If it's 0, then we only need the first color. + { + if (secondi >= translen) // blend to black + nextcolor = V_GetColor(31); + else + nextcolor = V_GetColor(translation[secondi]); + + // Find difference between points + r = (INT32)(nextcolor.s.red - blendcolor.s.red); + g = (INT32)(nextcolor.s.green - blendcolor.s.green); + b = (INT32)(nextcolor.s.blue - blendcolor.s.blue); + + // Find the gradient of the two points + r = ((mul * r) / mulmax); + g = ((mul * g) / mulmax); + b = ((mul * b) / mulmax); + + // Add gradient value to color + blendcolor.s.red += r; + blendcolor.s.green += g; + blendcolor.s.blue += b; + } + } + + if (skinnum == TC_RAINBOW) + { + UINT32 tempcolor; + UINT16 colorbright; + + SETBRIGHTNESS(colorbright,blendcolor.s.red,blendcolor.s.green,blendcolor.s.blue); + if (colorbright == 0) + colorbright = 1; // no dividing by 0 please + + tempcolor = (brightness * blendcolor.s.red) / colorbright; + tempcolor = min(255, tempcolor); + cur->s.red = (UINT8)tempcolor; + + tempcolor = (brightness * blendcolor.s.green) / colorbright; + tempcolor = min(255, tempcolor); + cur->s.green = (UINT8)tempcolor; + + tempcolor = (brightness * blendcolor.s.blue) / colorbright; + tempcolor = min(255, tempcolor); + cur->s.blue = (UINT8)tempcolor; + cur->s.alpha = image->s.alpha; } else { - // Just convert brightness to a skincolor value, use distance to next position to find the gradient multipler - firsti = 0; + // Color strength depends on image alpha + INT32 tempcolor; - for (i = 1; i < translen; i++) + tempcolor = ((image->s.red * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.red * blendimage->s.alpha) / 255); + tempcolor = min(255, tempcolor); + cur->s.red = (UINT8)tempcolor; + + tempcolor = ((image->s.green * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.green * blendimage->s.alpha) / 255); + tempcolor = min(255, tempcolor); + cur->s.green = (UINT8)tempcolor; + + tempcolor = ((image->s.blue * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.blue * blendimage->s.alpha) / 255); + tempcolor = min(255, tempcolor); + cur->s.blue = (UINT8)tempcolor; + cur->s.alpha = image->s.alpha; + } + +skippixel: + + // *Now* we can do Metal Sonic's flashing + if (skinnum == TC_METALSONIC) + { + // Blend dark blue into white + if (cur->s.alpha > 0 && cur->s.red == 0 && cur->s.green == 0 && cur->s.blue < 255 && cur->s.blue > 31) { - if (brightness >= cutoff[i]) - break; - firsti = i; + // Sal: Invert non-blue + cur->s.red = cur->s.green = (255 - cur->s.blue); + cur->s.blue = 255; } - secondi = firsti+1; - - mulmax = cutoff[firsti]; - if (secondi < translen) - mulmax -= cutoff[secondi]; - - mul = cutoff[firsti] - brightness; + cur->s.alpha = image->s.alpha; } - - blendcolor = V_GetColor(translation[firsti]); - - if (mul > 0) // If it's 0, then we only need the first color. - { - if (secondi >= translen) // blend to black - nextcolor = V_GetColor(31); - else - nextcolor = V_GetColor(translation[secondi]); - - // Find difference between points - r = (INT32)(nextcolor.s.red - blendcolor.s.red); - g = (INT32)(nextcolor.s.green - blendcolor.s.green); - b = (INT32)(nextcolor.s.blue - blendcolor.s.blue); - - // Find the gradient of the two points - r = ((mul * r) / mulmax); - g = ((mul * g) / mulmax); - b = ((mul * b) / mulmax); - - // Add gradient value to color - blendcolor.s.red += r; - blendcolor.s.green += g; - blendcolor.s.blue += b; - } - } - - if (skinnum == TC_RAINBOW) - { - UINT32 tempcolor; - UINT16 colorbright; - - SETBRIGHTNESS(colorbright,blendcolor.s.red,blendcolor.s.green,blendcolor.s.blue); - if (colorbright == 0) - colorbright = 1; // no dividing by 0 please - - tempcolor = (brightness * blendcolor.s.red) / colorbright; - tempcolor = min(255, tempcolor); - cur->s.red = (UINT8)tempcolor; - - tempcolor = (brightness * blendcolor.s.green) / colorbright; - tempcolor = min(255, tempcolor); - cur->s.green = (UINT8)tempcolor; - - tempcolor = (brightness * blendcolor.s.blue) / colorbright; - tempcolor = min(255, tempcolor); - cur->s.blue = (UINT8)tempcolor; - cur->s.alpha = image->s.alpha; - } - else - { - // Color strength depends on image alpha - INT32 tempcolor; - - tempcolor = ((image->s.red * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.red * blendimage->s.alpha) / 255); - tempcolor = min(255, tempcolor); - cur->s.red = (UINT8)tempcolor; - - tempcolor = ((image->s.green * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.green * blendimage->s.alpha) / 255); - tempcolor = min(255, tempcolor); - cur->s.green = (UINT8)tempcolor; - - tempcolor = ((image->s.blue * (255-blendimage->s.alpha)) / 255) + ((blendcolor.s.blue * blendimage->s.alpha) / 255); - tempcolor = min(255, tempcolor); - cur->s.blue = (UINT8)tempcolor; - cur->s.alpha = image->s.alpha; } } - cur++; image++; blendimage++; + cur++; image++; + + if (blendimage != NULL) + blendimage++; } return; @@ -1030,6 +1046,14 @@ static void HWR_GetBlendedTexture(GLPatch_t *gpatch, GLPatch_t *blendgpatch, INT // If here, the blended texture has not been created // So we create it + if ((blendgpatch && blendgpatch->mipmap->grInfo.format) + && (gpatch->width != blendgpatch->width || gpatch->height != blendgpatch->height)) + { + // Blend image exists, but it's bad. + HWD.pfnSetTexture(gpatch->mipmap); + return; + } + //BP: WARNING: don't free it manually without clearing the cache of harware renderer // (it have a liste of mipmap) // this malloc is cleared in HWR_FreeTextureCache @@ -1273,50 +1297,44 @@ boolean HWR_DrawModel(gr_vissprite_t *spr) if (gpatch && gpatch->mipmap->grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture { - if (md2->blendgrpatch && ((GLPatch_t *)md2->blendgrpatch)->mipmap->grInfo.format - && gpatch->width == ((GLPatch_t *)md2->blendgrpatch)->width && gpatch->height == ((GLPatch_t *)md2->blendgrpatch)->height) - { - INT32 skinnum = INT32_MAX; - if ((spr->mobj->flags & (MF_ENEMY|MF_BOSS)) && (spr->mobj->flags2 & MF2_FRET) && !(spr->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" - { - if (spr->mobj->type == MT_CYBRAKDEMON || spr->mobj->colorized) - skinnum = TC_ALLWHITE; - else if (spr->mobj->type == MT_METALSONIC_BATTLE) - skinnum = TC_METALSONIC; - else - skinnum = TC_BOSS; - } - else if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE) - { - if (spr->mobj->colorized) - skinnum = TC_RAINBOW; - else if (spr->mobj->player && spr->mobj->player->dashmode >= DASHMODE_THRESHOLD - && (spr->mobj->player->charflags & SF_DASHMODE) - && ((leveltime/2) & 1)) - { - if (spr->mobj->player->charflags & SF_MACHINE) - skinnum = TC_DASHMODE; - else - skinnum = TC_RAINBOW; - } - else if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) - skinnum = (INT32)((skin_t*)spr->mobj->skin-skins); - else - skinnum = TC_DEFAULT; - } + INT32 skinnum = INT32_MAX; - // Translation or skin number found - if (skinnum != INT32_MAX) - HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color); + if ((spr->mobj->flags & (MF_ENEMY|MF_BOSS)) && (spr->mobj->flags2 & MF2_FRET) && !(spr->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" + { + if (spr->mobj->type == MT_CYBRAKDEMON || spr->mobj->colorized) + skinnum = TC_ALLWHITE; + else if (spr->mobj->type == MT_METALSONIC_BATTLE) + skinnum = TC_METALSONIC; else + skinnum = TC_BOSS; + } + else if ((skincolors_t)spr->mobj->color != SKINCOLOR_NONE) + { + if (spr->mobj->colorized) + skinnum = TC_RAINBOW; + else if (spr->mobj->player && spr->mobj->player->dashmode >= DASHMODE_THRESHOLD + && (spr->mobj->player->charflags & SF_DASHMODE) + && ((leveltime/2) & 1)) { - // Sorry nothing - HWD.pfnSetTexture(gpatch->mipmap); + if (spr->mobj->player->charflags & SF_MACHINE) + skinnum = TC_DASHMODE; + else + skinnum = TC_RAINBOW; } + else if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) + skinnum = (INT32)((skin_t*)spr->mobj->skin-skins); + else + skinnum = TC_DEFAULT; + } + + // Translation or skin number found + if (skinnum != INT32_MAX) + { + HWR_GetBlendedTexture(gpatch, (GLPatch_t *)md2->blendgrpatch, skinnum, spr->colormap, (skincolors_t)spr->mobj->color); } else { - // This is safe, since we know the texture has been downloaded + // Sorry nothing HWD.pfnSetTexture(gpatch->mipmap); } } From d49cd9755bdb11b7037a3fe906c322df22225180 Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Wed, 8 Jan 2020 04:10:23 -0500 Subject: [PATCH 116/126] Fullbright transparent planes (I disagree with this feature so hard but w/e) (cherry picked from commit fe809b2734d430655966151e56f96963e2d7b2cf) --- src/hardware/hw_main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 769aad5b7..50b6fcbf5 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5158,7 +5158,12 @@ void HWR_AddTransparentFloor(levelflat_t *levelflat, extrasubsector_t *xsub, boo planeinfo[numplanes].isceiling = isceiling; planeinfo[numplanes].fixedheight = fixedheight; - planeinfo[numplanes].lightlevel = lightlevel; + + if (planecolormap && (planecolormap->fog & 1)) + planeinfo[numplanes].lightlevel = lightlevel; + else + planeinfo[numplanes].lightlevel = 255; + planeinfo[numplanes].levelflat = levelflat; planeinfo[numplanes].xsub = xsub; planeinfo[numplanes].alpha = alpha; @@ -5190,7 +5195,12 @@ void HWR_AddTransparentPolyobjectFloor(levelflat_t *levelflat, polyobj_t *polyse polyplaneinfo[numpolyplanes].isceiling = isceiling; polyplaneinfo[numpolyplanes].fixedheight = fixedheight; - polyplaneinfo[numpolyplanes].lightlevel = lightlevel; + + if (planecolormap && (planecolormap->fog & 1)) + polyplaneinfo[numpolyplanes].lightlevel = lightlevel; + else + polyplaneinfo[numpolyplanes].lightlevel = 255; + polyplaneinfo[numpolyplanes].levelflat = levelflat; polyplaneinfo[numpolyplanes].polysector = polysector; polyplaneinfo[numpolyplanes].alpha = alpha; From 0b1108425d4a95815eaf6bf0fdf2c9aaa10b8683 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 8 Jan 2020 20:49:14 +0000 Subject: [PATCH 117/126] Hexafaceted sprite angle support (See merge request description coming soon). Also, some minor memory efficiency fixes to both rotsprite and ordinary sprite rotations. --- src/hardware/hw_main.c | 23 ++++----- src/lua_hudlib.c | 8 ++-- src/r_data.c | 27 ++++++++--- src/r_defs.h | 26 ++++++----- src/r_patch.c | 10 ++-- src/r_things.c | 104 +++++++++++++++++++++++++---------------- src/r_things.h | 27 ++++++++--- 7 files changed, 136 insertions(+), 89 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 2f986085a..80ca623ca 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5493,7 +5493,7 @@ static void HWR_ProjectSprite(mobj_t *thing) spriteinfo_t *sprinfo; size_t lumpoff; unsigned rot; - UINT8 flip; + UINT16 flip; boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP)); angle_t ang; @@ -5579,12 +5579,7 @@ static void HWR_ProjectSprite(mobj_t *thing) flip = sprframe->flip; // Will only be 0x00 or 0xFF if (papersprite && ang < ANGLE_180) - { - if (flip) - flip = 0; - else - flip = 255; - } + flip ^= 0xFFFF; } else { @@ -5593,6 +5588,11 @@ static void HWR_ProjectSprite(mobj_t *thing) rot = 6; // F7 slot else if ((sprframe->rotate & SRF_LEFT) && (ang >= ANGLE_180)) // See from left rot = 2; // F3 slot + else if (sprframe->rotate & SRF_3DGE) // 16-angle mode + { + rot = (ang+ANGLE_180+ANGLE_11hh)>>28; + rot = ((rot & 1)<<3)|(rot>>1); + } else // Normal behaviour rot = (ang+ANGLE_202h)>>29; @@ -5601,12 +5601,7 @@ static void HWR_ProjectSprite(mobj_t *thing) flip = sprframe->flip & (1<skin && ((skin_t *)thing->skin)->flags & SF_HIRES) @@ -5621,7 +5616,7 @@ static void HWR_ProjectSprite(mobj_t *thing) if (thing->rollangle) { rollangle = R_GetRollAngle(thing->rollangle); - if (!sprframe->rotsprite.cached[rot]) + if (!(sprframe->rotsprite.cached & (1<sprite, (thing->frame & FF_FRAMEMASK), sprinfo, sprframe, rot, flip); rotsprite = sprframe->rotsprite.patch[rot][rollangle]; if (rotsprite != NULL) diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index 58af64359..f451944e3 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -468,11 +468,11 @@ static int libd_getSpritePatch(lua_State *L) // convert WAD editor angle numbers (1-8) to internal angle numbers (0-7) // keep 0 the same since we'll make it default to angle 1 (which is internally 0) - // in case somebody didn't know that angle 0 really just maps all 8 angles to the same patch + // in case somebody didn't know that angle 0 really just maps all 8/16 angles to the same patch if (angle != 0) angle--; - if (angle >= 8) // out of range? + if (angle >= ((sprframe->rotate & SRF_3DGE) ? 16 : 8)) // out of range? return 0; // push both the patch and it's "flip" value @@ -563,11 +563,11 @@ static int libd_getSprite2Patch(lua_State *L) // convert WAD editor angle numbers (1-8) to internal angle numbers (0-7) // keep 0 the same since we'll make it default to angle 1 (which is internally 0) - // in case somebody didn't know that angle 0 really just maps all 8 angles to the same patch + // in case somebody didn't know that angle 0 really just maps all 8/16 angles to the same patch if (angle != 0) angle--; - if (angle >= 8) // out of range? + if (angle >= ((sprframe->rotate & SRF_3DGE) ? 16 : 8)) // out of range? return 0; // push both the patch and it's "flip" value diff --git a/src/r_data.c b/src/r_data.c index 986b65dea..26fc0043c 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -2710,14 +2710,29 @@ void R_PrecacheLevel(void) for (j = 0; j < sprites[i].numframes; j++) { sf = &sprites[i].spriteframes[j]; - for (k = 0; k < 8; k++) +#define cacheang(a) {\ + lump = sf->lumppat[a];\ + if (devparm)\ + spritememory += W_LumpLength(lump);\ + W_CachePatchNum(lump, PU_PATCH);\ + } + // see R_InitSprites for more about lumppat,lumpid + switch (sf->rotate) { - // see R_InitSprites for more about lumppat,lumpid - lump = sf->lumppat[k]; - if (devparm) - spritememory += W_LumpLength(lump); - W_CachePatchNum(lump, PU_PATCH); + case SRF_SINGLE: + cacheang(0); + break; + case SRF_2D: + cacheang(2); + cacheang(6); + break; + default: + k = (sf->rotate & SRF_3DGE ? 16 : 8); + while (k--) + cacheang(k); + break; } +#undef cacheang } } free(spritepresent); diff --git a/src/r_defs.h b/src/r_defs.h index c7c198d66..a841bca08 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -727,10 +727,10 @@ typedef struct #ifdef ROTSPRITE typedef struct { - patch_t *patch[8][ROTANGLES]; - boolean cached[8]; + patch_t *patch[16][ROTANGLES]; + UINT16 cached; #ifdef HWRENDER - aatree_t *hardware_patch[8]; + aatree_t *hardware_patch[16]; #endif/*HWRENDER*/ } rotsprite_t; #endif/*ROTSPRITE*/ @@ -739,9 +739,11 @@ typedef enum { SRF_SINGLE = 0, // 0-angle for all rotations SRF_3D = 1, // Angles 1-8 - SRF_LEFT = 2, // Left side uses single patch - SRF_RIGHT = 4, // Right side uses single patch - SRF_2D = SRF_LEFT|SRF_RIGHT, // 6 + SRF_3DGE = 2, // 3DGE, ZDoom and Doom Legacy all have 16-angle support. Why not us? + SRF_3DMASK = SRF_3D|SRF_3DGE, // 3 + SRF_LEFT = 4, // Left side uses single patch + SRF_RIGHT = 8, // Right side uses single patch + SRF_2D = SRF_LEFT|SRF_RIGHT, // 12 SRF_NONE = 0xff // Initial value } spriterotateflags_t; // SRF's up! @@ -767,7 +769,7 @@ typedef struct patchinfo_s patchinfo_t; // Sprites are patches with a special naming convention so they can be // recognized by R_InitSprites. // The base name is NNNNFx or NNNNFxFx, with x indicating the rotation, -// x = 0, 1-8, L/R +// x = 0, 1-8, 9+A-G, L/R // The sprite and frame specified by a thing_t is range checked at run time. // A sprite is a patch_t that is assumed to represent a three dimensional // object and may have multiple rotations predrawn. @@ -784,12 +786,12 @@ typedef struct // name eight times. UINT8 rotate; // see spriterotateflags_t above - // Lump to use for view angles 0-7. - lumpnum_t lumppat[8]; // lump number 16 : 16 wad : lump - size_t lumpid[8]; // id in the spriteoffset, spritewidth, etc. tables + // Lump to use for view angles 0-7/15. + lumpnum_t lumppat[16]; // lump number 16 : 16 wad : lump + size_t lumpid[16]; // id in the spriteoffset, spritewidth, etc. tables - // Flip bits (1 = flip) to use for view angles 0-7. - UINT8 flip; + // Flip bits (1 = flip) to use for view angles 0-7/15. + UINT16 flip; #ifdef ROTSPRITE rotsprite_t rotsprite; diff --git a/src/r_patch.c b/src/r_patch.c index fbb64e362..7fb764d22 100644 --- a/src/r_patch.c +++ b/src/r_patch.c @@ -1159,7 +1159,7 @@ void R_CacheRotSprite(spritenum_t sprnum, UINT8 frame, spriteinfo_t *sprinfo, sp #define ROTSPRITE_XCENTER (newwidth / 2) #define ROTSPRITE_YCENTER (newheight / 2) - if (!sprframe->rotsprite.cached[rot]) + if (!(sprframe->rotsprite.cached & (1<rotsprite.cached[rot] = true; + sprframe->rotsprite.cached |= (1<numframes; frame++) { spriteframe_t *sprframe = &spritedef->spriteframes[frame]; - for (rot = 0; rot < 8; rot++) + for (rot = 0; rot < 16; rot++) { - if (sprframe->rotsprite.cached[rot]) + if (sprframe->rotsprite.cached & (1<rotsprite.cached[rot] = false; + sprframe->rotsprite.cached &= ~(1<= 64 || !(R_ValidSpriteAngle(rotation))) - I_Error("R_InstallSpriteLump: Bad frame characters in lump %s", W_CheckNameForNum(lumppat)); - if (maxframe ==(size_t)-1 || frame > maxframe) maxframe = frame; // rotsprite #ifdef ROTSPRITE - for (r = 0; r < 8; r++) + sprtemp[frame].rotsprite.cached = 0; + for (r = 0; r < 16; r++) { - sprtemp[frame].rotsprite.cached[r] = false; for (ang = 0; ang < ROTANGLES; ang++) sprtemp[frame].rotsprite.patch[r][ang] = NULL; #ifdef HWRENDER @@ -136,16 +133,16 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch // the lump should be used for all rotations if (sprtemp[frame].rotate == SRF_SINGLE) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has multiple rot = 0 lump\n", spritename, cn); - else if (sprtemp[frame].rotate != SRF_NONE) // Let's bundle 1-8 and L/R rotations into one debug message. + else if (sprtemp[frame].rotate != SRF_NONE) // Let's bundle 1-8/16 and L/R rotations into one debug message. CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has rotations and a rot = 0 lump\n", spritename, cn); sprtemp[frame].rotate = SRF_SINGLE; - for (r = 0; r < 8; r++) + for (r = 0; r < 16; r++) { sprtemp[frame].lumppat[r] = lumppat; sprtemp[frame].lumpid[r] = lumpid; } - sprtemp[frame].flip = flipped ? 0xFF : 0; // 11111111 in binary + sprtemp[frame].flip = flipped ? 0xFFFF : 0; // 1111111111111111 in binary return; } @@ -154,54 +151,67 @@ static void R_InstallSpriteLump(UINT16 wad, // graphics patch UINT8 rightfactor = ((rotation == ROT_R) ? 4 : 0); // the lump should be used for half of all rotations - if (sprtemp[frame].rotate == SRF_SINGLE) + if (sprtemp[frame].rotate == SRF_NONE) + sprtemp[frame].rotate = SRF_SINGLE; + else if (sprtemp[frame].rotate == SRF_SINGLE) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has L/R rotations and a rot = 0 lump\n", spritename, cn); else if (sprtemp[frame].rotate == SRF_3D) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has both L/R and 1-8 rotations\n", spritename, cn); + else if (sprtemp[frame].rotate == SRF_3DGE) + CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has both L/R and 1-G rotations\n", spritename, cn); else if ((sprtemp[frame].rotate & SRF_LEFT) && (rotation == ROT_L)) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has multiple L rotations\n", spritename, cn); else if ((sprtemp[frame].rotate & SRF_RIGHT) && (rotation == ROT_R)) CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s frame %c has multiple R rotations\n", spritename, cn); - if (sprtemp[frame].rotate == SRF_NONE) - sprtemp[frame].rotate = SRF_SINGLE; - sprtemp[frame].rotate |= ((rotation == ROT_R) ? SRF_RIGHT : SRF_LEFT); - if (sprtemp[frame].rotate == (SRF_3D|SRF_2D)) - sprtemp[frame].rotate = SRF_2D; // SRF_3D|SRF_2D being enabled at the same time doesn't HURT in the current sprite angle implementation, but it DOES mean more to check in some of the helper functions. Let's not allow this scenario to happen. + if ((sprtemp[frame].rotate & SRF_2D) == SRF_2D) + sprtemp[frame].rotate &= ~SRF_3DMASK; // SRF_3D|SRF_2D being enabled at the same time doesn't HURT in the current sprite angle implementation, but it DOES mean more to check in some of the helper functions. Let's not allow this scenario to happen. - for (r = 0; r < 4; r++) // Thanks to R_PrecacheLevel, we can't leave sprtemp[*].lumppat[*] == LUMPERROR... so we load into the front/back angle too. + // load into every relevant angle, including the front one + for (r = 0; r < 4; r++) { sprtemp[frame].lumppat[r + rightfactor] = lumppat; sprtemp[frame].lumpid[r + rightfactor] = lumpid; + sprtemp[frame].lumppat[r + rightfactor + 8] = lumppat; + sprtemp[frame].lumpid[r + rightfactor + 8] = lumpid; + } if (flipped) - sprtemp[frame].flip |= (0x0F< 3) // Right side - sprtemp[frame].rotate = (SRF_3D | (sprtemp[frame].rotate & SRF_LEFT)); // Continue allowing L frame changeover - else // if (rotation <= 3) // Left side - sprtemp[frame].rotate = (SRF_3D | (sprtemp[frame].rotate & SRF_RIGHT)); // Continue allowing R frame changeover + { + // SRF_3D|SRF_3DGE being enabled at the same time doesn't HURT in the current sprite angle implementation, but it DOES mean more to check in some of the helper functions. Let's not allow this scenario to happen. + UINT8 threedrot = (rotation > 7) ? SRF_3DGE : (sprtemp[frame].rotate & SRF_3DMASK); + if (!threedrot) + threedrot = SRF_3D; + + if (rotation == 0 || rotation == 4) // Front or back... + sprtemp[frame].rotate = threedrot; // Prevent L and R changeover + else if ((rotation & 7) > 3) // Right side + sprtemp[frame].rotate = (threedrot | (sprtemp[frame].rotate & SRF_LEFT)); // Continue allowing L frame changeover + else // if ((rotation & 7) <= 3) // Left side + sprtemp[frame].rotate = (threedrot | (sprtemp[frame].rotate & SRF_RIGHT)); // Continue allowing R frame changeover + } if (sprtemp[frame].lumppat[rotation] != LUMPERROR) - CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s: %c%c has two lumps mapped to it\n", spritename, cn, '1'+rotation); + CONS_Debug(DBG_SETUP, "R_InitSprites: Sprite %s: %c%c has two lumps mapped to it\n", spritename, cn, cr); // lumppat & lumpid are the same for original Doom, but different // when using sprites in pwad : the lumppat points the new graphics @@ -262,9 +272,9 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, if (memcmp(lumpinfo[l].name,sprname,4)==0) { frame = R_Char2Frame(lumpinfo[l].name[4]); - rotation = (UINT8)(lumpinfo[l].name[5] - '0'); + rotation = R_Char2Rotation(lumpinfo[l].name[5]); - if (frame >= 64 || !(R_ValidSpriteAngle(rotation))) // Give an actual NAME error -_-... + if (frame >= 64 || rotation == 255) // Give an actual NAME error -_-... { CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum,l)); continue; @@ -311,7 +321,13 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, if (lumpinfo[l].name[6]) { frame = R_Char2Frame(lumpinfo[l].name[6]); - rotation = (UINT8)(lumpinfo[l].name[7] - '0'); + rotation = R_Char2Rotation(lumpinfo[l].name[7]); + + if (frame >= 64 || rotation == 255) // Give an actual NAME error -_-... + { + CONS_Alert(CONS_WARNING, M_GetText("Bad sprite name: %s\n"), W_CheckNameForNumPwad(wadnum,l)); + continue; + } R_InstallSpriteLump(wadnum, l, numspritelumps, frame, rotation, 1); } @@ -372,18 +388,19 @@ static boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, case SRF_2D: // both Left and Right rotations // we test to see whether the left and right slots are present if ((sprtemp[frame].lumppat[2] == LUMPERROR) || (sprtemp[frame].lumppat[6] == LUMPERROR)) - I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations", + I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations (L-R mode)", sprname, R_Frame2Char(frame)); break; default: - // must have all 8 frames - for (rotation = 0; rotation < 8; rotation++) + // must have all 8/16 frames + rotation = ((sprtemp[frame].rotate & SRF_3DGE) ? 16 : 8); + while (rotation--) // we test the patch lump, or the id lump whatever // if it was not loaded the two are LUMPERROR if (sprtemp[frame].lumppat[rotation] == LUMPERROR) - I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations", - sprname, R_Frame2Char(frame)); + I_Error("R_AddSingleSpriteDef: Sprite %.4s frame %c is missing rotations (1-%c mode)", + sprname, R_Frame2Char(frame), ((sprtemp[frame].rotate & SRF_3DGE) ? 'G' : '8')); break; } } @@ -1097,7 +1114,7 @@ static void R_ProjectSprite(mobj_t *thing) size_t lump; size_t rot; - UINT8 flip; + UINT16 flip; boolean vflip = (!(thing->eflags & MFE_VERTICALFLIP) != !(thing->frame & FF_VERTICALFLIP)); INT32 lindex; @@ -1227,7 +1244,7 @@ static void R_ProjectSprite(mobj_t *thing) // use single rotation for all views rot = 0; //Fab: for vis->patch below lump = sprframe->lumpid[0]; //Fab: see note above - flip = sprframe->flip; // Will only be 0x00 or 0xFF + flip = sprframe->flip; // Will only be 0 or 0xFFFF } else { @@ -1238,6 +1255,11 @@ static void R_ProjectSprite(mobj_t *thing) rot = 6; // F7 slot else if ((sprframe->rotate & SRF_LEFT) && (ang >= ANGLE_180)) // See from left rot = 2; // F3 slot + else if (sprframe->rotate & SRF_3DGE) // 16-angle mode + { + rot = (ang+ANGLE_180+ANGLE_11hh)>>28; + rot = ((rot & 1)<<3)|(rot>>1); + } else // Normal behaviour rot = (ang+ANGLE_202h)>>29; @@ -1260,7 +1282,7 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->rollangle) { rollangle = R_GetRollAngle(thing->rollangle); - if (!sprframe->rotsprite.cached[rot]) + if (!(sprframe->rotsprite.cached & (1<sprite, (thing->frame & FF_FRAMEMASK), sprinfo, sprframe, rot, flip); rotsprite = sprframe->rotsprite.patch[rot][rollangle]; if (rotsprite != NULL) diff --git a/src/r_things.h b/src/r_things.h index 8e4a543c3..b4ef66a62 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -20,10 +20,6 @@ #include "r_portal.h" #include "r_defs.h" -// "Left" and "Right" character symbols for additional rotation functionality -#define ROT_L ('L' - '0') -#define ROT_R ('R' - '0') - // number of sprite lumps for spritewidth,offset,topoffset lookup tables // Fab: this is a hack : should allocate the lookup tables per sprite #define MAXVISSPRITES 2048 // added 2-2-98 was 128 @@ -270,7 +266,7 @@ FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Frame(char cn) if (cn == '+') return '\\' - 'A'; // PK3 can't use backslash, so use + instead return cn - 'A'; #else - if (cn >= 'A' && cn <= 'Z') return cn - 'A'; + if (cn >= 'A' && cn <= 'Z') return (cn - 'A'); if (cn >= '0' && cn <= '9') return (cn - '0') + 26; if (cn >= 'a' && cn <= 'z') return (cn - 'a') + 36; if (cn == '!') return 62; @@ -279,9 +275,26 @@ FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Frame(char cn) #endif } -FUNCMATH FUNCINLINE static ATTRINLINE boolean R_ValidSpriteAngle(UINT8 rotation) +// "Left" and "Right" character symbols for additional rotation functionality +#define ROT_L 17 +#define ROT_R 18 + +FUNCMATH FUNCINLINE static ATTRINLINE char R_Rotation2Char(UINT8 rot) { - return ((rotation <= 8) || (rotation == ROT_L) || (rotation == ROT_R)); + if (rot <= 9) return '0' + rot; + if (rot <= 16) return 'A' + (rot - 10); + if (rot == ROT_L) return 'L'; + if (rot == ROT_R) return 'R'; + return '\xFF'; +} + +FUNCMATH FUNCINLINE static ATTRINLINE UINT8 R_Char2Rotation(char cn) +{ + if (cn >= '0' && cn <= '9') return (cn - '0'); + if (cn >= 'A' && cn <= 'G') return (cn - 'A') + 10; + if (cn == 'L') return ROT_L; + if (cn == 'R') return ROT_R; + return 255; } #endif //__R_THINGS__ From 07dfc5cce79b5e02a0b353e38f85942d7e1ef2e7 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 8 Jan 2020 16:00:02 -0500 Subject: [PATCH 118/126] Fix S_HAMMER being off by one --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index 30f3e96d0..5f1cb8fbe 100644 --- a/src/info.c +++ b/src/info.c @@ -3565,7 +3565,7 @@ state_t states[NUMSTATES] = {SPR_PUMA, FF_FULLBRIGHT|FF_TRANS60|8, 3, {NULL}, 0, 0, S_NULL}, // S_PUMATRAIL4 // Hammer - {SPR_HAMM, FF_ANIMATE, -1, {NULL}, 4, 3, S_NULL}, // S_HAMMER + {SPR_HAMM, FF_ANIMATE, -1, {NULL}, 3, 3, S_NULL}, // S_HAMMER // Koopa {SPR_KOOP, 0, -1, {NULL}, 0, 0, S_NULL}, // S_KOOPA1 From 004cfb45aa2edbc9a1b1a18a26372822896e4ef5 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 8 Jan 2020 22:36:29 +0000 Subject: [PATCH 119/126] Allow Rollout Rocks that are being ridden to: * Break bustable FOFs like pushables. * Activate pushable-counting executor activators. * Get pushed by currents/wind. This takes advantage of the previously-existing hack relating to objects with MF_PUSHABLE infotable (but not active) flags and a nonzero fuse, which is used as the condition to group this under (rather than MT_ROLLOUTROCK specific fuckery). Thanks to the bug report submitted by our kirbs pal for getting me off my ass this evening. --- src/p_enemy.c | 7 ++----- src/p_mobj.c | 2 +- src/p_spec.c | 5 +++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index ce201844f..bd7b81d40 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -14603,12 +14603,9 @@ void A_RolloutRock(mobj_t *actor) if (!actor->tracer || P_MobjWasRemoved(actor->tracer) || !actor->tracer->health) actor->flags |= MF_PUSHABLE; - if (!(actor->flags & MF_PUSHABLE)) // if being ridden, don't disappear - actor->fuse = 0; - else if (!actor->fuse && actor->movecount == 1) // otherwise if rock has moved, set its fuse + if (!(actor->flags & MF_PUSHABLE) || (actor->movecount != 1)) // if being ridden or haven't moved, don't disappear actor->fuse = actor->info->painchance; - - if (actor->fuse && actor->fuse < 2*TICRATE) + else if (actor->fuse < 2*TICRATE) actor->flags2 ^= MF2_DONTDRAW; } diff --git a/src/p_mobj.c b/src/p_mobj.c index b771103a9..1b2fc7d6a 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1892,7 +1892,7 @@ void P_XYMovement(mobj_t *mo) #endif // Pushables can break some blocks - if (CheckForBustableBlocks && mo->flags & MF_PUSHABLE) + if (CheckForBustableBlocks && ((mo->flags & MF_PUSHABLE) || ((mo->info->flags & MF_PUSHABLE) && mo->fuse))) P_PushableCheckBustables(mo); if (!P_TryMove(mo, mo->x + xmove, mo->y + ymove, true) diff --git a/src/p_spec.c b/src/p_spec.c index cc0b185ad..f2cb17e0e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1887,7 +1887,7 @@ boolean P_RunTriggerLinedef(line_t *triggerline, mobj_t *actor, sector_t *caller while (node) { mo = node->m_thing; - if (mo->flags & MF_PUSHABLE) + if ((mo->flags & MF_PUSHABLE) || ((mo->info->flags & MF_PUSHABLE) && mo->fuse)) numpush++; node = node->m_thinglist_next; } @@ -8974,7 +8974,8 @@ void T_Pusher(pusher_t *p) || thing->type == MT_EXTRALARGEBUBBLE)) continue; - if (!(thing->flags & MF_PUSHABLE) && !(thing->type == MT_PLAYER + if (!((thing->flags & MF_PUSHABLE) || ((thing->info->flags & MF_PUSHABLE) && thing->fuse)) + && !(thing->type == MT_PLAYER || thing->type == MT_SMALLBUBBLE || thing->type == MT_MEDIUMBUBBLE || thing->type == MT_EXTRALARGEBUBBLE From 487e1b02f1fb3b3b018390c5505775c10d371e1f Mon Sep 17 00:00:00 2001 From: Sally Cochenour Date: Thu, 9 Jan 2020 01:28:14 -0500 Subject: [PATCH 120/126] Remove smooth setting It got denied before for Software so I won't include it in the merge request :( --- src/hardware/hw_main.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 50b6fcbf5..9bfd75edc 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1035,21 +1035,10 @@ static FUINT HWR_CalcWallLight(FUINT lightnum, fixed_t v1x, fixed_t v1y, fixed_t const UINT8 contrast = 8; fixed_t extralight = 0; - if (cv_grfakecontrast.value == 2) // Smooth setting - { - extralight = (-(contrast<> FRACBITS; - } - else - { - if (v1y == v2y) - extralight = -contrast; - else if (v1x == v2x) - extralight = contrast; - } + if (v1y == v2y) + extralight = -contrast; + else if (v1x == v2x) + extralight = contrast; if (extralight != 0) { @@ -6594,7 +6583,6 @@ static void HWR_FoggingOn(void) static CV_PossibleValue_t grsoftwarefog_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "LightPlanes"}, {0, NULL}}; static CV_PossibleValue_t grmodelinterpolation_cons_t[] = {{0, "Off"}, {1, "Sometimes"}, {2, "Always"}, {0, NULL}}; -static CV_PossibleValue_t grfakecontrast_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Smooth"}, {0, NULL}}; static void CV_grmodellighting_OnChange(void); static void CV_grfiltermode_OnChange(void); @@ -6629,7 +6617,7 @@ consvar_t cv_grmodellighting = {"gr_modellighting", "Off", CV_SAVE|CV_CALL, CV_O consvar_t cv_grspritebillboarding = {"gr_spritebillboarding", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grskydome = {"gr_skydome", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_grfakecontrast = {"gr_fakecontrast", "Smooth", CV_SAVE, grfakecontrast_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_grfakecontrast = {"gr_fakecontrast", "On", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grrounddown = {"gr_rounddown", "Off", 0, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_grfov = {"gr_fov", "90", CV_FLOAT|CV_CALL, grfov_cons_t, CV_grfov_OnChange, 0, NULL, NULL, 0, 0, NULL}; From 3e3cb48feba3bd7f777cd14acb1622771ca62cd4 Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Thu, 9 Jan 2020 12:15:26 -0300 Subject: [PATCH 121/126] This is stupid --- src/dehacked.c | 1 + src/info.c | 29 ++++++++++++++++++++++++++++- src/info.h | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index 8220f5aa3..50b5c81da 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8669,6 +8669,7 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s "MT_NIGHTSCHIP", // NiGHTS Chip "MT_FLINGNIGHTSCHIP", // Lost NiGHTS Chip "MT_NIGHTSSTAR", // NiGHTS Star + "MT_FLINGNIGHTSSTAR", // Lost NiGHTS Star "MT_NIGHTSSUPERLOOP", "MT_NIGHTSDRILLREFILL", "MT_NIGHTSHELPER", diff --git a/src/info.c b/src/info.c index 5f1cb8fbe..a5483d961 100644 --- a/src/info.c +++ b/src/info.c @@ -19791,7 +19791,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 1000, // spawnhealth S_NIGHTSSTARXMAS, // seestate sfx_None, // seesound - 8, // reactiontime + MT_FLINGNIGHTSSTAR, // reactiontime sfx_None, // attacksound S_NULL, // painstate 0, // painchance @@ -19811,6 +19811,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = MF_SLIDEME|MF_SPECIAL|MF_NOGRAVITY|MF_NOCLIPHEIGHT, // flags S_NULL // raisestate }, + + { // MT_FLINGNIGHTSSTAR + -1, // doomednum + S_NIGHTSSTAR, // spawnstate + 1000, // spawnhealth + S_NIGHTSSTARXMAS, // seestate + sfx_None, // seesound + MT_FLINGNIGHTSSTAR, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + MT_NIGHTSSTAR, // painchance + sfx_s3k33, // painsound + S_RING, // meleestate + S_NULL, // missilestate + S_SPRK1, // deathstate + S_NULL, // xdeathstate + sfx_ncitem, // deathsound + 38*FRACUNIT, // speed + 16*FRACUNIT, // radius + 24*FRACUNIT, // height + 0, // display offset + 100, // mass + 0, // damage + sfx_None, // activesound + MF_SLIDEME|MF_SPECIAL, // flags + S_NULL // raisestate + }, { // MT_NIGHTSSUPERLOOP 1707, // doomednum diff --git a/src/info.h b/src/info.h index 261abbac5..324795d45 100644 --- a/src/info.h +++ b/src/info.h @@ -4702,6 +4702,7 @@ typedef enum mobj_type MT_NIGHTSCHIP, // NiGHTS Chip MT_FLINGNIGHTSCHIP, // Lost NiGHTS Chip MT_NIGHTSSTAR, // NiGHTS Star + MT_FLINGNIGHTSSTAR, // Lost NiGHTS Star MT_NIGHTSSUPERLOOP, MT_NIGHTSDRILLREFILL, MT_NIGHTSHELPER, From 10e9dd2c23929132b4175c9bebd2fec8dcd444da Mon Sep 17 00:00:00 2001 From: Tatsuru <44866610+Ikkarin@users.noreply.github.com> Date: Thu, 9 Jan 2020 16:16:24 -0300 Subject: [PATCH 122/126] *bends over seductively to pick up whitespace* --- src/info.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/info.c b/src/info.c index a5483d961..60913b519 100644 --- a/src/info.c +++ b/src/info.c @@ -19760,14 +19760,14 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = { // MT_FLINGNIGHTSCHIP -1, // doomednum - S_NIGHTSCHIP, // spawnstate + S_NIGHTSCHIP, // spawnstate 1000, // spawnhealth S_NULL, // seestate sfx_None, // seesound - MT_FLINGNIGHTSCHIP, // reactiontime + MT_FLINGNIGHTSCHIP, // reactiontime sfx_None, // attacksound S_NULL, // painstate - MT_NIGHTSCHIP, // painchance + MT_NIGHTSCHIP, // painchance sfx_None, // painsound S_NULL, // meleestate S_NULL, // missilestate @@ -19791,7 +19791,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 1000, // spawnhealth S_NIGHTSSTARXMAS, // seestate sfx_None, // seesound - MT_FLINGNIGHTSSTAR, // reactiontime + MT_FLINGNIGHTSSTAR, // reactiontime sfx_None, // attacksound S_NULL, // painstate 0, // painchance @@ -19818,21 +19818,21 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 1000, // spawnhealth S_NIGHTSSTARXMAS, // seestate sfx_None, // seesound - MT_FLINGNIGHTSSTAR, // reactiontime + MT_FLINGNIGHTSSTAR, // reactiontime sfx_None, // attacksound S_NULL, // painstate - MT_NIGHTSSTAR, // painchance + MT_NIGHTSSTAR, // painchance sfx_s3k33, // painsound S_RING, // meleestate S_NULL, // missilestate S_SPRK1, // deathstate S_NULL, // xdeathstate sfx_ncitem, // deathsound - 38*FRACUNIT, // speed + 38*FRACUNIT, // speed 16*FRACUNIT, // radius 24*FRACUNIT, // height 0, // display offset - 100, // mass + 100, // mass 0, // damage sfx_None, // activesound MF_SLIDEME|MF_SPECIAL, // flags From 71c2ee38501df6773e085d7a9de6f74a94647465 Mon Sep 17 00:00:00 2001 From: Alam Ed Arias Date: Thu, 9 Jan 2020 16:19:12 -0500 Subject: [PATCH 123/126] whitespace cleanup --- src/p_map.c | 2 +- src/p_mobj.c | 2 +- src/p_user.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index b6f532124..40fee7b46 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2005,7 +2005,7 @@ static boolean PIT_CheckLine(line_t *ld) if (lowfloor < tmdropoffz) tmdropoffz = lowfloor; - + return true; } diff --git a/src/p_mobj.c b/src/p_mobj.c index b771103a9..f281db50d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -7977,7 +7977,7 @@ static void P_MobjSceneryThink(mobj_t *mobj) mobj->x = mobj->extravalue1 + P_ReturnThrustX(mobj, mobj->movedir, mobj->cvmem*mobj->scale); mobj->y = mobj->extravalue2 + P_ReturnThrustY(mobj, mobj->movedir, mobj->cvmem*mobj->scale); P_SetThingPosition(mobj); - + if (!mobj->fuse) { #ifdef HAVE_BLUA diff --git a/src/p_user.c b/src/p_user.c index c5024d7ec..b40e647b6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -349,11 +349,11 @@ void P_GiveEmerald(boolean spawnObj) continue; P_SetTarget(&emmo->target, players[i].mo); P_SetMobjState(emmo, mobjinfo[MT_GOTEMERALD].meleestate + em); - + // Make sure we're not being carried before our tracer is changed if (players[i].powers[pw_carry] != CR_NIGHTSMODE) players[i].powers[pw_carry] = CR_NONE; - + P_SetTarget(&players[i].mo->tracer, emmo); if (pnum == 255) From 80b801e91e540dfb88a5cff25cb99f85b975e501 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 10 Jan 2020 11:43:41 +0000 Subject: [PATCH 124/126] Mario brick blocks are likely to always have square sectors dividing seperate bricks, so allow them to be busted individually. --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 7d83fffb0..a4231fa74 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3127,7 +3127,7 @@ nightsdone: { // DO THE MARIO! if (rover->flags & FF_SHATTERBOTTOM) // Brick block! - EV_CrumbleChain(NULL, rover); // node->m_sector + EV_CrumbleChain(node->m_sector, rover); else // Question block! EV_MarioBlock(rover, node->m_sector, mo); } From cbbc76b673e9d4f87459881cffcb39a87d9de4ef Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 10 Jan 2020 12:50:58 +0000 Subject: [PATCH 125/126] Fix snapping of extra multiplayer text. (Resolves #101) --- src/st_stuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/st_stuff.c b/src/st_stuff.c index 68803b665..4676506fc 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -2208,7 +2208,7 @@ static void ST_drawTextHUD(void) #define textHUDdraw(str) \ {\ - V_DrawThinString(16, y, V_PERPLAYER|V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOBOTTOM, str);\ + V_DrawThinString(16, y, V_PERPLAYER|V_HUDTRANS|V_SNAPTOLEFT|V_SNAPTOTOP, str);\ y += 8;\ } From 2046f524c776b4f3d1fdd467499d5c07eea63050 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Fri, 10 Jan 2020 23:32:31 +0100 Subject: [PATCH 126/126] Fix incorrect cast --- src/p_setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 9a924e67d..cfe141381 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1105,8 +1105,8 @@ static void P_LoadSidedefs(UINT8 *data) if (((sd->line->flags & (ML_TWOSIDED|ML_EFFECT5)) == (ML_TWOSIDED|ML_EFFECT5)) && !(sd->special >= 300 && sd->special < 500)) // exempt linedef exec specials { - sd->repeatcnt = (INT16)(((unsigned)textureoffset) >> 12); - sd->textureoffset = (((unsigned)textureoffset) & 2047) << FRACBITS; + sd->repeatcnt = (INT16)(((UINT16)textureoffset) >> 12); + sd->textureoffset = (((UINT16)textureoffset) & 2047) << FRACBITS; } else {