Skip to content

Commit 65d4d3b

Browse files
committed
Fixed key binds being deleted on disconnect
1 parent e387cca commit 65d4d3b

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

Client/core/CCommands.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,13 @@ tagCOMMANDENTRY* CCommands::Get ( const char* szCommand, bool bCheckIfMod, bool
212212
{
213213
// Find the entry we're looking for
214214
auto iter = std::find_if(m_CommandList.begin(), m_CommandList.end(),
215-
[szCommand](auto& command)
215+
[szCommand, bCheckIfMod, bModCommand](auto& command)
216216
{
217-
return stricmp(szCommand, command.szCommandName) == 0;
217+
if ( !bCheckIfMod || ( bModCommand == command.bModCommand ) )
218+
{
219+
return stricmp(szCommand, command.szCommandName) == 0;
220+
}
221+
return false;
218222
});
219223

220224
if (iter != m_CommandList.end())

Client/core/CKeyBinds.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ void CKeyBinds::RemoveDeletedBinds ( void )
507507
void CKeyBinds::ClearCommandsAndControls ( void )
508508
{
509509
m_List.remove_if([](auto& pBind) {
510-
return pBind->GetType() == KEY_BIND_FUNCTION || pBind->GetType() == KEY_BIND_CONTROL_FUNCTION;
510+
return pBind->GetType() != KEY_BIND_FUNCTION && pBind->GetType() != KEY_BIND_CONTROL_FUNCTION;
511511
});
512512
}
513513

@@ -706,6 +706,10 @@ bool CKeyBinds::RemoveAllCommands ( void )
706706
return false;
707707
if (pBind->GetType() != KEY_BIND_COMMAND)
708708
return false;
709+
if (m_bProcessingKeyStroke) {
710+
pBind->beingDeleted = true;
711+
return false;
712+
}
709713
return true;
710714
});
711715
return bFound;
@@ -1610,7 +1614,7 @@ bool CKeyBinds::RemoveAllControlFunctions ( ControlFunctionBindHandler Handler )
16101614
[&](auto& pBind) {
16111615
if (pBind->IsBeingDeleted())
16121616
return false;
1613-
if (pBind->GetType() == KEY_BIND_CONTROL_FUNCTION)
1617+
if (pBind->GetType() != KEY_BIND_CONTROL_FUNCTION)
16141618
return false;
16151619
CControlFunctionBind* pControlBind = static_cast<CControlFunctionBind*>(pBind.get());
16161620
if (pControlBind->Handler != Handler)
@@ -1636,7 +1640,7 @@ bool CKeyBinds::RemoveAllControlFunctions ( void )
16361640
[&](auto& pBind) {
16371641
if (pBind->IsBeingDeleted())
16381642
return false;
1639-
if (pBind->GetType() == KEY_BIND_CONTROL_FUNCTION)
1643+
if (pBind->GetType() != KEY_BIND_CONTROL_FUNCTION)
16401644
return false;
16411645
bFound = true;
16421646

Client/core/Settings/CBindSettingsTab.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ void CBindSettingsTab::Initialize(void)
395395
for (int k = 0; k < SecKeyNum; k++)
396396
m_pBindsList->SetItemText(iBind, m_hSecKeys[k], CORE_SETTINGS_NO_KEY);
397397
m_pBindsList->SetItemData(iBind, m_hBind, (void*)KEY_BIND_GTA_CONTROL);
398-
m_pBindsList->SetItemData(iBind, m_hPriKey, (void*)&pGTABind);
398+
m_pBindsList->SetItemData(iBind, m_hPriKey, (void*)pGTABind);
399399
iGameRowCount++;
400400
}
401401
// Secondary keys?
@@ -404,7 +404,7 @@ void CBindSettingsTab::Initialize(void)
404404
if (uiMatchCount == k + 1)
405405
{
406406
m_pBindsList->SetItemText(iBind, m_hSecKeys[k], pGTABind->boundKey->szKey);
407-
m_pBindsList->SetItemData(iBind, m_hSecKeys[k], (void*)&pGTABind);
407+
m_pBindsList->SetItemData(iBind, m_hSecKeys[k], (void*)pGTABind);
408408
}
409409
uiMatchCount++;
410410
}
@@ -460,7 +460,7 @@ void CBindSettingsTab::Initialize(void)
460460
if (pListedCommand->uiMatchCount == k)
461461
{
462462
m_pBindsList->SetItemText(pListedCommand->iIndex, m_hSecKeys[k], pCommandBind->boundKey->szKey);
463-
m_pBindsList->SetItemData(pListedCommand->iIndex, m_hSecKeys[k], (void*)&pCommandBind);
463+
m_pBindsList->SetItemData(pListedCommand->iIndex, m_hSecKeys[k], (void*)pCommandBind);
464464
}
465465
pListedCommand->uiMatchCount++;
466466
}

0 commit comments

Comments
 (0)