Skip to content

Commit

Permalink
Merge pull request ddnet#9005 from Robyt3/Client-Toggle-Fix
Browse files Browse the repository at this point in the history
Fix `toggle` command always setting value to `1`
  • Loading branch information
def- authored Sep 20, 2024
2 parents 034e497 + e1a21f5 commit b34edb6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/engine/shared/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,8 @@ void CConfigManager::Con_Toggle(IConsole::IResult *pResult, void *pUserData)
if(pVariable->m_Type == SConfigVariable::VAR_INT)
{
SIntConfigVariable *pIntVariable = static_cast<SIntConfigVariable *>(pVariable);
pIntVariable->SetValue(*pIntVariable->m_pVariable == pResult->GetInteger(pResult->GetInteger(1) ? 2 : 1));
const bool EqualToFirst = *pIntVariable->m_pVariable == pResult->GetInteger(1);
pIntVariable->SetValue(pResult->GetInteger(EqualToFirst ? 2 : 1));
}
else if(pVariable->m_Type == SConfigVariable::VAR_COLOR)
{
Expand All @@ -504,7 +505,8 @@ void CConfigManager::Con_Toggle(IConsole::IResult *pResult, void *pUserData)
else if(pVariable->m_Type == SConfigVariable::VAR_STRING)
{
SStringConfigVariable *pStringVariable = static_cast<SStringConfigVariable *>(pVariable);
pStringVariable->SetValue(pResult->GetString(str_comp(pStringVariable->m_pStr, pResult->GetString(1)) == 0 ? 2 : 1));
const bool EqualToFirst = str_comp(pStringVariable->m_pStr, pResult->GetString(1)) == 0;
pStringVariable->SetValue(pResult->GetString(EqualToFirst ? 2 : 1));
}
return;
}
Expand Down

0 comments on commit b34edb6

Please sign in to comment.