Fix automatic hammer on release when cl_dummy_control is set to 1

Let's say you have this bind:

```bind x +toggle cl_dummy_hammer 1 0```

and you set cl_dummy_control to 1.

When you press the bind i mentioned above, and then release, the dummy will hammer where he is looking (not at you). So, in total, there will be two hammers. One hammer when you press down the button and the dummy hammers towards you, and then another hammer when you release the button and the dummy hammers where he is looking.

This fixes it, and also makes sure it does not conflict with cl_dummy_copy_moves (as if it is enabled and cl_dummy_control is enabled, the dummy will not copy fire, hook, or jump) so I made sure it keeps this functionality as it's pretty cool.

This does not fix any other bugs yet, maybe I will fix those in the future but we'll see. Any bug you may encounter with this change is also probably present in the main branch, such as resetonswitch not working perfectly with dummy_control, but if you do find something different then let me know.
This commit is contained in:
MrBlubberBut 2023-12-26 13:59:06 -05:00 committed by GitHub
parent 8ce103f04f
commit 32e187f18e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -284,8 +284,10 @@ int CControls::SnapInput(int *pData)
pDummyInput->m_TargetX = m_aInputData[g_Config.m_ClDummy].m_TargetX;
pDummyInput->m_TargetY = m_aInputData[g_Config.m_ClDummy].m_TargetY;
pDummyInput->m_WantedWeapon = m_aInputData[g_Config.m_ClDummy].m_WantedWeapon;
pDummyInput->m_Fire += m_aInputData[g_Config.m_ClDummy].m_Fire - m_aLastData[g_Config.m_ClDummy].m_Fire;
if(!g_Config.m_ClDummyControl)
pDummyInput->m_Fire += m_aInputData[g_Config.m_ClDummy].m_Fire - m_aLastData[g_Config.m_ClDummy].m_Fire;
pDummyInput->m_NextWeapon += m_aInputData[g_Config.m_ClDummy].m_NextWeapon - m_aLastData[g_Config.m_ClDummy].m_NextWeapon;
pDummyInput->m_PrevWeapon += m_aInputData[g_Config.m_ClDummy].m_PrevWeapon - m_aLastData[g_Config.m_ClDummy].m_PrevWeapon;
@ -296,7 +298,12 @@ int CControls::SnapInput(int *pData)
{
CNetObj_PlayerInput *pDummyInput = &m_pClient->m_DummyInput;
pDummyInput->m_Jump = g_Config.m_ClDummyJump;
pDummyInput->m_Fire = g_Config.m_ClDummyFire;
if(g_Config.m_ClDummyFire)
pDummyInput->m_Fire = g_Config.m_ClDummyFire;
else if((pDummyInput->m_Fire & 1) != 0)
pDummyInput->m_Fire++;
pDummyInput->m_Hook = g_Config.m_ClDummyHook;
}