5718: Various minor refactorings cherry-picked from upstream r=def- a=Robyt3



## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test (especially base/) or added coverage to integration test
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: Robert Müller <robytemueller@gmail.com>
This commit is contained in:
bors[bot] 2022-08-09 22:40:44 +00:00 committed by GitHub
commit c7a7ad63ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 26 deletions

View file

@ -289,18 +289,18 @@ void CBinds::ConDumpBinds(IConsole::IResult *pResult, void *pUserData)
const char *pKeyName = pResult->GetString(0);
int Modifier;
int id = pBinds->GetBindSlot(pKeyName, &Modifier);
if(!id)
int KeyID = pBinds->GetBindSlot(pKeyName, &Modifier);
if(!KeyID)
{
str_format(aBuf, sizeof(aBuf), "key '%s' not found", pKeyName);
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
}
else
{
if(!pBinds->m_aapKeyBindings[Modifier][id])
str_format(aBuf, sizeof(aBuf), "%s (%d) is not bound", pKeyName, id);
if(!pBinds->m_aapKeyBindings[Modifier][KeyID])
str_format(aBuf, sizeof(aBuf), "%s (%d) is not bound", pKeyName, KeyID);
else
str_format(aBuf, sizeof(aBuf), "%s (%d) = %s", pKeyName, id, pBinds->m_aapKeyBindings[Modifier][id]);
str_format(aBuf, sizeof(aBuf), "%s (%d) = %s", pKeyName, KeyID, pBinds->m_aapKeyBindings[Modifier][KeyID]);
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
}
@ -327,9 +327,9 @@ void CBinds::ConUnbind(IConsole::IResult *pResult, void *pUserData)
CBinds *pBinds = (CBinds *)pUserData;
const char *pKeyName = pResult->GetString(0);
int Modifier;
int id = pBinds->GetBindSlot(pKeyName, &Modifier);
int KeyID = pBinds->GetBindSlot(pKeyName, &Modifier);
if(!id)
if(!KeyID)
{
char aBuf[256];
str_format(aBuf, sizeof(aBuf), "key %s not found", pKeyName);
@ -337,7 +337,7 @@ void CBinds::ConUnbind(IConsole::IResult *pResult, void *pUserData)
return;
}
pBinds->Bind(id, "", false, Modifier);
pBinds->Bind(KeyID, "", false, Modifier);
}
void CBinds::ConUnbindAll(IConsole::IResult *pResult, void *pUserData)

View file

@ -448,7 +448,7 @@ CGameConsole::~CGameConsole()
float CGameConsole::TimeNow()
{
static long long s_TimeStart = time_get();
static int64_t s_TimeStart = time_get();
return float(time_get() - s_TimeStart) / float(time_freq());
}

View file

@ -48,11 +48,6 @@ bool CTuningParams::Get(const char *pName, float *pValue) const
return false;
}
float HermiteBasis1(float v)
{
return 2 * v * v * v - 3 * v * v + 1;
}
float VelocityRamp(float Value, float Start, float Range, float Curvature)
{
if(Value < Start)
@ -122,12 +117,7 @@ void CCharacterCore::Tick(bool UseInput, bool DoDeferredTick)
m_TriggeredEvents = 0;
// get ground state
bool Grounded = false;
if(m_pCollision->CheckPoint(m_Pos.x + PhysicalSize() / 2, m_Pos.y + PhysicalSize() / 2 + 5))
Grounded = true;
if(m_pCollision->CheckPoint(m_Pos.x - PhysicalSize() / 2, m_Pos.y + PhysicalSize() / 2 + 5))
Grounded = true;
const bool Grounded = m_pCollision->CheckPoint(m_Pos.x + PhysicalSize() / 2, m_Pos.y + PhysicalSize() / 2 + 5) || m_pCollision->CheckPoint(m_Pos.x - PhysicalSize() / 2, m_Pos.y + PhysicalSize() / 2 + 5);
vec2 TargetDirection = normalize(vec2(m_Input.m_TargetX, m_Input.m_TargetY));
m_Vel.y += m_Tuning.m_Gravity;

View file

@ -2598,9 +2598,9 @@ void CGameContext::ConTuneDump(IConsole::IResult *pResult, void *pUserData)
char aBuf[256];
for(int i = 0; i < pSelf->Tuning()->Num(); i++)
{
float v;
pSelf->Tuning()->Get(i, &v);
str_format(aBuf, sizeof(aBuf), "%s %.2f", pSelf->Tuning()->ms_apNames[i], v);
float Value;
pSelf->Tuning()->Get(i, &Value);
str_format(aBuf, sizeof(aBuf), "%s %.2f", pSelf->Tuning()->ms_apNames[i], Value);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tuning", aBuf);
}
}
@ -2635,9 +2635,9 @@ void CGameContext::ConTuneDumpZone(IConsole::IResult *pResult, void *pUserData)
{
for(int i = 0; i < pSelf->TuningList()[List].Num(); i++)
{
float v;
pSelf->TuningList()[List].Get(i, &v);
str_format(aBuf, sizeof(aBuf), "zone %d: %s %.2f", List, pSelf->TuningList()[List].ms_apNames[i], v);
float Value;
pSelf->TuningList()[List].Get(i, &Value);
str_format(aBuf, sizeof(aBuf), "zone %d: %s %.2f", List, pSelf->TuningList()[List].ms_apNames[i], Value);
pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "tuning", aBuf);
}
}