Merge pull request #8705 from Robyt3/Clang-Tidy-Static-Name-Fixes

Remove clang-tidy `static` variable name exceptions
This commit is contained in:
Dennis Felsing 2024-08-10 11:47:02 +00:00 committed by GitHub
commit 3a84cfeb8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 69 additions and 55 deletions

View file

@ -121,8 +121,6 @@ CheckOptions:
value: ms_ value: ms_
- key: readability-identifier-naming.StaticVariablePrefix - key: readability-identifier-naming.StaticVariablePrefix
value: s_ value: s_
- key: readability-identifier-naming.StaticVariableIgnoredRegexp
value: '^(NullAddr$|aDummyNameBuf$|aModifier$|EXPLANATION$|LocalClientId$|Dir$|LOCATION_NAMES$|EditorHotkeyWasPressed$|EditorHotKeyChecktime$|FrictionFraction$|LastTime$|SkidSoundTime$|NewVal$|aRotated$).*'
- key: readability-identifier-naming.ClassMethodCase - key: readability-identifier-naming.ClassMethodCase
value: CamelCase value: CamelCase
- key: readability-identifier-naming.ClassCase - key: readability-identifier-naming.ClassCase

View file

@ -247,7 +247,7 @@ public:
// //
virtual const char *PlayerName() const = 0; virtual const char *PlayerName() const = 0;
virtual const char *DummyName() const = 0; virtual const char *DummyName() = 0;
virtual const char *ErrorString() const = 0; virtual const char *ErrorString() const = 0;
virtual const char *LatestVersion() const = 0; virtual const char *LatestVersion() const = 0;
virtual bool ConnectionProblems() const = 0; virtual bool ConnectionProblems() const = 0;

View file

@ -876,7 +876,7 @@ const char *CClient::PlayerName() const
return "nameless tee"; return "nameless tee";
} }
const char *CClient::DummyName() const const char *CClient::DummyName()
{ {
if(g_Config.m_ClDummyName[0]) if(g_Config.m_ClDummyName[0])
{ {
@ -893,9 +893,8 @@ const char *CClient::DummyName() const
} }
if(pBase) if(pBase)
{ {
static char aDummyNameBuf[16]; str_format(m_aAutomaticDummyName, sizeof(m_aAutomaticDummyName), "[D] %s", pBase);
str_format(aDummyNameBuf, sizeof(aDummyNameBuf), "[D] %s", pBase); return m_aAutomaticDummyName;
return aDummyNameBuf;
} }
return "brainless tee"; return "brainless tee";
} }

View file

@ -255,6 +255,9 @@ class CClient : public IClient, public CDemoPlayer::IListener
std::shared_ptr<ILogger> m_pFileLogger = nullptr; std::shared_ptr<ILogger> m_pFileLogger = nullptr;
std::shared_ptr<ILogger> m_pStdoutLogger = nullptr; std::shared_ptr<ILogger> m_pStdoutLogger = nullptr;
// For DummyName function
char m_aAutomaticDummyName[MAX_NAME_LENGTH];
public: public:
IConfigManager *ConfigManager() { return m_pConfigManager; } IConfigManager *ConfigManager() { return m_pConfigManager; }
CConfig *Config() { return m_pConfig; } CConfig *Config() { return m_pConfig; }
@ -339,7 +342,7 @@ public:
void Quit() override; void Quit() override;
const char *PlayerName() const override; const char *PlayerName() const override;
const char *DummyName() const override; const char *DummyName() override;
const char *ErrorString() const override; const char *ErrorString() const override;
const char *LoadMap(const char *pName, const char *pFilename, SHA256_DIGEST *pWantedSha256, unsigned WantedCrc); const char *LoadMap(const char *pName, const char *pFilename, SHA256_DIGEST *pWantedSha256, unsigned WantedCrc);

View file

@ -590,7 +590,7 @@ bool CGraphics_Threaded::LoadPng(CImageInfo &Image, const char *pFilename, int S
SWarning Warning; SWarning Warning;
str_format(Warning.m_aWarningMsg, sizeof(Warning.m_aWarningMsg), Localize("\"%s\" is not compatible with pnglite and cannot be loaded by old DDNet versions: "), pFilename); str_format(Warning.m_aWarningMsg, sizeof(Warning.m_aWarningMsg), Localize("\"%s\" is not compatible with pnglite and cannot be loaded by old DDNet versions: "), pFilename);
static const int FLAGS[] = {PNGLITE_COLOR_TYPE, PNGLITE_BIT_DEPTH, PNGLITE_INTERLACE_TYPE, PNGLITE_COMPRESSION_TYPE, PNGLITE_FILTER_TYPE}; static const int FLAGS[] = {PNGLITE_COLOR_TYPE, PNGLITE_BIT_DEPTH, PNGLITE_INTERLACE_TYPE, PNGLITE_COMPRESSION_TYPE, PNGLITE_FILTER_TYPE};
static const char *EXPLANATION[] = {"color type", "bit depth", "interlace type", "compression type", "filter type"}; static const char *const EXPLANATION[] = {"color type", "bit depth", "interlace type", "compression type", "filter type"};
bool First = true; bool First = true;
for(size_t i = 0; i < std::size(FLAGS); ++i) for(size_t i = 0; i < std::size(FLAGS); ++i)

View file

@ -122,8 +122,8 @@ int CNetServer::Update()
SECURITY_TOKEN CNetServer::GetGlobalToken() SECURITY_TOKEN CNetServer::GetGlobalToken()
{ {
static NETADDR NullAddr = {0}; static const NETADDR NULL_ADDR = {0};
return GetToken(NullAddr); return GetToken(NULL_ADDR);
} }
SECURITY_TOKEN CNetServer::GetToken(const NETADDR &Addr) SECURITY_TOKEN CNetServer::GetToken(const NETADDR &Addr)
{ {

View file

@ -48,16 +48,18 @@ void CBinds::Bind(int KeyId, const char *pStr, bool FreeOnly, int ModifierCombin
m_aapKeyBindings[ModifierCombination][KeyId] = nullptr; m_aapKeyBindings[ModifierCombination][KeyId] = nullptr;
char aBuf[256]; char aBuf[256];
char aModifiers[128];
GetKeyBindModifiersName(ModifierCombination, aModifiers, sizeof(aModifiers));
if(!pStr[0]) if(!pStr[0])
{ {
str_format(aBuf, sizeof(aBuf), "unbound %s%s (%d)", GetKeyBindModifiersName(ModifierCombination), Input()->KeyName(KeyId), KeyId); str_format(aBuf, sizeof(aBuf), "unbound %s%s (%d)", aModifiers, Input()->KeyName(KeyId), KeyId);
} }
else else
{ {
int Size = str_length(pStr) + 1; int Size = str_length(pStr) + 1;
m_aapKeyBindings[ModifierCombination][KeyId] = (char *)malloc(Size); m_aapKeyBindings[ModifierCombination][KeyId] = (char *)malloc(Size);
str_copy(m_aapKeyBindings[ModifierCombination][KeyId], pStr, Size); str_copy(m_aapKeyBindings[ModifierCombination][KeyId], pStr, Size);
str_format(aBuf, sizeof(aBuf), "bound %s%s (%d) = %s", GetKeyBindModifiersName(ModifierCombination), Input()->KeyName(KeyId), KeyId, m_aapKeyBindings[ModifierCombination][KeyId]); str_format(aBuf, sizeof(aBuf), "bound %s%s (%d) = %s", aModifiers, Input()->KeyName(KeyId), KeyId, m_aapKeyBindings[ModifierCombination][KeyId]);
} }
Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "binds", aBuf, gs_BindPrintColor); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "binds", aBuf, gs_BindPrintColor);
} }
@ -227,6 +229,8 @@ void CBinds::GetKey(const char *pBindStr, char *pBuf, size_t BufSize)
pBuf[0] = '\0'; pBuf[0] = '\0';
for(int Modifier = MODIFIER_NONE; Modifier < MODIFIER_COMBINATION_COUNT; Modifier++) for(int Modifier = MODIFIER_NONE; Modifier < MODIFIER_COMBINATION_COUNT; Modifier++)
{ {
char aModifiers[128];
GetKeyBindModifiersName(Modifier, aModifiers, sizeof(aModifiers));
for(int KeyId = KEY_FIRST; KeyId < KEY_LAST; KeyId++) for(int KeyId = KEY_FIRST; KeyId < KEY_LAST; KeyId++)
{ {
const char *pBind = Get(KeyId, Modifier); const char *pBind = Get(KeyId, Modifier);
@ -235,7 +239,7 @@ void CBinds::GetKey(const char *pBindStr, char *pBuf, size_t BufSize)
if(str_comp(pBind, pBindStr) == 0) if(str_comp(pBind, pBindStr) == 0)
{ {
str_format(pBuf, BufSize, "%s%s", GetKeyBindModifiersName(Modifier), Input()->KeyName(KeyId)); str_format(pBuf, BufSize, "%s%s", aModifiers, Input()->KeyName(KeyId));
return; return;
} }
} }
@ -360,12 +364,14 @@ void CBinds::ConBinds(IConsole::IResult *pResult, void *pUserData)
char aBuf[1024]; char aBuf[1024];
for(int Modifier = MODIFIER_NONE; Modifier < MODIFIER_COMBINATION_COUNT; Modifier++) for(int Modifier = MODIFIER_NONE; Modifier < MODIFIER_COMBINATION_COUNT; Modifier++)
{ {
char aModifiers[128];
GetKeyBindModifiersName(Modifier, aModifiers, sizeof(aModifiers));
for(int Key = KEY_FIRST; Key < KEY_LAST; Key++) for(int Key = KEY_FIRST; Key < KEY_LAST; Key++)
{ {
if(!pBinds->m_aapKeyBindings[Modifier][Key]) if(!pBinds->m_aapKeyBindings[Modifier][Key])
continue; continue;
str_format(aBuf, sizeof(aBuf), "%s%s (%d) = %s", GetKeyBindModifiersName(Modifier), pBinds->Input()->KeyName(Key), Key, pBinds->m_aapKeyBindings[Modifier][Key]); str_format(aBuf, sizeof(aBuf), "%s%s (%d) = %s", aModifiers, pBinds->Input()->KeyName(Key), Key, pBinds->m_aapKeyBindings[Modifier][Key]);
pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor); pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf, gs_BindPrintColor);
} }
} }
@ -440,19 +446,17 @@ const char *CBinds::GetModifierName(int Modifier)
} }
} }
const char *CBinds::GetKeyBindModifiersName(int ModifierCombination) void CBinds::GetKeyBindModifiersName(int ModifierCombination, char *pBuf, size_t BufSize)
{ {
static char aModifier[256]; pBuf[0] = '\0';
aModifier[0] = '\0';
for(int k = 1; k < MODIFIER_COUNT; k++) for(int k = 1; k < MODIFIER_COUNT; k++)
{ {
if(ModifierCombination & (1 << k)) if(ModifierCombination & (1 << k))
{ {
str_append(aModifier, GetModifierName(k)); str_append(pBuf, GetModifierName(k), BufSize);
str_append(aModifier, "+"); str_append(pBuf, "+", BufSize);
} }
} }
return aModifier;
} }
void CBinds::ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData) void CBinds::ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData)
@ -462,6 +466,8 @@ void CBinds::ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData)
pConfigManager->WriteLine("unbindall"); pConfigManager->WriteLine("unbindall");
for(int Modifier = MODIFIER_NONE; Modifier < MODIFIER_COMBINATION_COUNT; Modifier++) for(int Modifier = MODIFIER_NONE; Modifier < MODIFIER_COMBINATION_COUNT; Modifier++)
{ {
char aModifiers[128];
GetKeyBindModifiersName(Modifier, aModifiers, sizeof(aModifiers));
for(int Key = KEY_FIRST; Key < KEY_LAST; Key++) for(int Key = KEY_FIRST; Key < KEY_LAST; Key++)
{ {
if(!pSelf->m_aapKeyBindings[Modifier][Key]) if(!pSelf->m_aapKeyBindings[Modifier][Key])
@ -472,7 +478,7 @@ void CBinds::ConfigSaveCallback(IConfigManager *pConfigManager, void *pUserData)
char *pBuffer = (char *)malloc(Size); char *pBuffer = (char *)malloc(Size);
char *pEnd = pBuffer + Size; char *pEnd = pBuffer + Size;
str_format(pBuffer, Size, "bind %s%s \"", GetKeyBindModifiersName(Modifier), pSelf->Input()->KeyName(Key)); str_format(pBuffer, Size, "bind %s%s \"", aModifiers, pSelf->Input()->KeyName(Key));
// process the string. we need to escape some characters // process the string. we need to escape some characters
char *pDst = pBuffer + str_length(pBuffer); char *pDst = pBuffer + str_length(pBuffer);
str_escape(&pDst, pSelf->m_aapKeyBindings[Modifier][Key], pEnd); str_escape(&pDst, pSelf->m_aapKeyBindings[Modifier][Key], pEnd);

View file

@ -72,7 +72,7 @@ public:
static int GetModifierMask(IInput *pInput); static int GetModifierMask(IInput *pInput);
static int GetModifierMaskOfKey(int Key); static int GetModifierMaskOfKey(int Key);
static const char *GetModifierName(int Modifier); static const char *GetModifierName(int Modifier);
static const char *GetKeyBindModifiersName(int ModifierCombination); static void GetKeyBindModifiersName(int ModifierCombination, char *pBuf, size_t BufSize);
virtual void OnConsoleInit() override; virtual void OnConsoleInit() override;
virtual bool OnInput(const IInput::CEvent &Event) override; virtual bool OnInput(const IInput::CEvent &Event) override;

View file

@ -343,9 +343,8 @@ void CHud::RenderScoreHud()
aScore[t][0] = 0; aScore[t][0] = 0;
} }
static int LocalClientId = -1; bool RecreateScores = str_comp(aScore[0], m_aScoreInfo[0].m_aScoreText) != 0 || str_comp(aScore[1], m_aScoreInfo[1].m_aScoreText) != 0 || m_LastLocalClientId != m_pClient->m_Snap.m_LocalClientId;
bool RecreateScores = str_comp(aScore[0], m_aScoreInfo[0].m_aScoreText) != 0 || str_comp(aScore[1], m_aScoreInfo[1].m_aScoreText) != 0 || LocalClientId != m_pClient->m_Snap.m_LocalClientId; m_LastLocalClientId = m_pClient->m_Snap.m_LocalClientId;
LocalClientId = m_pClient->m_Snap.m_LocalClientId;
bool RecreateRect = ForceScoreInfoInit; bool RecreateRect = ForceScoreInfoInit;
for(int t = 0; t < 2; t++) for(int t = 0; t < 2; t++)

View file

@ -77,7 +77,10 @@ class CHud : public CComponent
void RenderGameTimer(); void RenderGameTimer();
void RenderPauseNotification(); void RenderPauseNotification();
void RenderSuddenDeath(); void RenderSuddenDeath();
void RenderScoreHud(); void RenderScoreHud();
int m_LastLocalClientId = -1;
void RenderSpectatorHud(); void RenderSpectatorHud();
void RenderWarmupTimer(); void RenderWarmupTimer();
void RenderLocalTime(float x); void RenderLocalTime(float x);

View file

@ -307,15 +307,14 @@ bool CMenuBackground::Render()
return false; return false;
m_Camera.m_Zoom = 0.7f; m_Camera.m_Zoom = 0.7f;
static vec2 Dir = vec2(1.0f, 0.0f);
float DistToCenter = distance(m_Camera.m_Center, m_RotationCenter); float DistToCenter = distance(m_Camera.m_Center, m_RotationCenter);
if(!m_ChangedPosition && absolute(DistToCenter - (float)g_Config.m_ClRotationRadius) <= 0.5f) if(!m_ChangedPosition && absolute(DistToCenter - (float)g_Config.m_ClRotationRadius) <= 0.5f)
{ {
// do little rotation // do little rotation
float RotPerTick = 360.0f / (float)g_Config.m_ClRotationSpeed * clamp(Client()->RenderFrameTime(), 0.0f, 0.1f); float RotPerTick = 360.0f / (float)g_Config.m_ClRotationSpeed * clamp(Client()->RenderFrameTime(), 0.0f, 0.1f);
Dir = rotate(Dir, RotPerTick); m_CurrentDirection = rotate(m_CurrentDirection, RotPerTick);
m_Camera.m_Center = m_RotationCenter + Dir * (float)g_Config.m_ClRotationRadius; m_Camera.m_Center = m_RotationCenter + m_CurrentDirection * (float)g_Config.m_ClRotationRadius;
} }
else else
{ {
@ -328,16 +327,16 @@ bool CMenuBackground::Render()
vec2 TargetPos = m_RotationCenter + DirToCenter * (float)g_Config.m_ClRotationRadius; vec2 TargetPos = m_RotationCenter + DirToCenter * (float)g_Config.m_ClRotationRadius;
float Distance = distance(m_AnimationStartPos, TargetPos); float Distance = distance(m_AnimationStartPos, TargetPos);
if(Distance > 0.001f) if(Distance > 0.001f)
Dir = normalize(m_AnimationStartPos - TargetPos); m_CurrentDirection = normalize(m_AnimationStartPos - TargetPos);
else else
Dir = vec2(1, 0); m_CurrentDirection = vec2(1.0f, 0.0f);
// move time // move time
m_MoveTime += clamp(Client()->RenderFrameTime(), 0.0f, 0.1f) * g_Config.m_ClCameraSpeed / 10.0f; m_MoveTime += clamp(Client()->RenderFrameTime(), 0.0f, 0.1f) * g_Config.m_ClCameraSpeed / 10.0f;
float XVal = 1 - m_MoveTime; float XVal = 1 - m_MoveTime;
XVal = std::pow(XVal, 7.0f); XVal = std::pow(XVal, 7.0f);
m_Camera.m_Center = TargetPos + Dir * (XVal * Distance); m_Camera.m_Center = TargetPos + m_CurrentDirection * (XVal * Distance);
if(m_CurrentPosition < 0) if(m_CurrentPosition < 0)
{ {
m_AnimationStartPos = m_Camera.m_Center; m_AnimationStartPos = m_Camera.m_Center;

View file

@ -85,6 +85,7 @@ public:
vec2 m_RotationCenter; vec2 m_RotationCenter;
std::array<vec2, NUM_POS> m_aPositions; std::array<vec2, NUM_POS> m_aPositions;
int m_CurrentPosition; int m_CurrentPosition;
vec2 m_CurrentDirection = vec2(1.0f, 0.0f);
vec2 m_AnimationStartPos; vec2 m_AnimationStartPos;
bool m_ChangedPosition; bool m_ChangedPosition;
float m_MoveTime; float m_MoveTime;

View file

@ -503,7 +503,11 @@ int CMenus::DoKeyReader(const void *pId, const CUIRect *pRect, int Key, int Modi
else if(NewKey == 0) else if(NewKey == 0)
aBuf[0] = '\0'; aBuf[0] = '\0';
else else
str_format(aBuf, sizeof(aBuf), "%s%s", CBinds::GetKeyBindModifiersName(*pNewModifierCombination), Input()->KeyName(NewKey)); {
char aModifiers[128];
CBinds::GetKeyBindModifiersName(*pNewModifierCombination, aModifiers, sizeof(aModifiers));
str_format(aBuf, sizeof(aBuf), "%s%s", aModifiers, Input()->KeyName(NewKey));
}
const ColorRGBA Color = m_Binder.m_pKeyReaderId == pId && m_Binder.m_TakeKey ? ColorRGBA(0.0f, 1.0f, 0.0f, 0.4f) : ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f * Ui()->ButtonColorMul(pId)); const ColorRGBA Color = m_Binder.m_pKeyReaderId == pId && m_Binder.m_TakeKey ? ColorRGBA(0.0f, 1.0f, 0.0f, 0.4f) : ColorRGBA(1.0f, 1.0f, 1.0f, 0.5f * Ui()->ButtonColorMul(pId));
pRect->Draw(Color, IGraphics::CORNER_ALL, 5.0f); pRect->Draw(Color, IGraphics::CORNER_ALL, 5.0f);

View file

@ -460,6 +460,8 @@ protected:
// found in menus_start.cpp // found in menus_start.cpp
void RenderStartMenu(CUIRect MainView); void RenderStartMenu(CUIRect MainView);
bool m_EditorHotkeyWasPressed = true;
float m_EditorHotKeyChecktime = 0.0f;
// found in menus_ingame.cpp // found in menus_ingame.cpp
STextContainerIndex m_MotdTextContainerIndex; STextContainerIndex m_MotdTextContainerIndex;

View file

@ -33,7 +33,7 @@ static void FormatServerbrowserPing(char (&aBuffer)[N], const CServerInfo *pInfo
str_format(aBuffer, sizeof(aBuffer), "%d", pInfo->m_Latency); str_format(aBuffer, sizeof(aBuffer), "%d", pInfo->m_Latency);
return; return;
} }
static const char *LOCATION_NAMES[CServerInfo::NUM_LOCS] = { static const char *const LOCATION_NAMES[CServerInfo::NUM_LOCS] = {
"", // LOC_UNKNOWN "", // LOC_UNKNOWN
Localizable("AFR"), // LOC_AFRICA Localizable("AFR"), // LOC_AFRICA
Localizable("ASI"), // LOC_ASIA Localizable("ASI"), // LOC_ASIA

View file

@ -154,21 +154,19 @@ void CMenus::RenderStartMenu(CUIRect MainView)
} }
#endif #endif
static bool EditorHotkeyWasPressed = true;
static float EditorHotKeyChecktime = 0.0f;
Menu.HSplitBottom(5.0f, &Menu, 0); // little space Menu.HSplitBottom(5.0f, &Menu, 0); // little space
Menu.HSplitBottom(40.0f, &Menu, &Button); Menu.HSplitBottom(40.0f, &Menu, &Button);
static CButtonContainer s_MapEditorButton; static CButtonContainer s_MapEditorButton;
if(DoButton_Menu(&s_MapEditorButton, Localize("Editor"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "editor" : 0, IGraphics::CORNER_ALL, Rounding, 0.5f, m_pClient->Editor()->HasUnsavedData() ? ColorRGBA(0.0f, 1.0f, 0.0f, 0.25f) : ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f)) || (!EditorHotkeyWasPressed && Client()->LocalTime() - EditorHotKeyChecktime < 0.1f && CheckHotKey(KEY_E))) if(DoButton_Menu(&s_MapEditorButton, Localize("Editor"), 0, &Button, g_Config.m_ClShowStartMenuImages ? "editor" : 0, IGraphics::CORNER_ALL, Rounding, 0.5f, m_pClient->Editor()->HasUnsavedData() ? ColorRGBA(0.0f, 1.0f, 0.0f, 0.25f) : ColorRGBA(0.0f, 0.0f, 0.0f, 0.25f)) || (!m_EditorHotkeyWasPressed && Client()->LocalTime() - m_EditorHotKeyChecktime < 0.1f && CheckHotKey(KEY_E)))
{ {
g_Config.m_ClEditor = 1; g_Config.m_ClEditor = 1;
Input()->MouseModeRelative(); Input()->MouseModeRelative();
EditorHotkeyWasPressed = true; m_EditorHotkeyWasPressed = true;
} }
if(!Input()->KeyIsPressed(KEY_E)) if(!Input()->KeyIsPressed(KEY_E))
{ {
EditorHotkeyWasPressed = false; m_EditorHotkeyWasPressed = false;
EditorHotKeyChecktime = Client()->LocalTime(); m_EditorHotKeyChecktime = Client()->LocalTime();
} }
Menu.HSplitBottom(5.0f, &Menu, 0); // little space Menu.HSplitBottom(5.0f, &Menu, 0); // little space

View file

@ -78,17 +78,16 @@ void CParticles::Update(float TimePassed)
if(TimePassed <= 0.0f) if(TimePassed <= 0.0f)
return; return;
static float FrictionFraction = 0; m_FrictionFraction += TimePassed;
FrictionFraction += TimePassed;
if(FrictionFraction > 2.0f) // safety measure if(m_FrictionFraction > 2.0f) // safety measure
FrictionFraction = 0; m_FrictionFraction = 0;
int FrictionCount = 0; int FrictionCount = 0;
while(FrictionFraction > 0.05f) while(m_FrictionFraction > 0.05f)
{ {
FrictionCount++; FrictionCount++;
FrictionFraction -= 0.05f; m_FrictionFraction -= 0.05f;
} }
for(int &FirstPart : m_aFirstPart) for(int &FirstPart : m_aFirstPart)
@ -149,22 +148,21 @@ void CParticles::OnRender()
return; return;
set_new_tick(); set_new_tick();
static int64_t LastTime = 0;
int64_t t = time(); int64_t t = time();
if(Client()->State() == IClient::STATE_DEMOPLAYBACK) if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
{ {
const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo();
if(!pInfo->m_Paused) if(!pInfo->m_Paused)
Update((float)((t - LastTime) / (double)time_freq()) * pInfo->m_Speed); Update((float)((t - m_LastRenderTime) / (double)time_freq()) * pInfo->m_Speed);
} }
else else
{ {
if(m_pClient->m_Snap.m_pGameInfoObj && !(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED)) if(m_pClient->m_Snap.m_pGameInfoObj && !(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED))
Update((float)((t - LastTime) / (double)time_freq())); Update((float)((t - m_LastRenderTime) / (double)time_freq()));
} }
LastTime = t; m_LastRenderTime = t;
} }
void CParticles::OnInit() void CParticles::OnInit()

View file

@ -96,6 +96,9 @@ private:
int m_FirstFree; int m_FirstFree;
int m_aFirstPart[NUM_GROUPS]; int m_aFirstPart[NUM_GROUPS];
float m_FrictionFraction = 0.0f;
int64_t m_LastRenderTime = 0;
void RenderGroup(int Group); void RenderGroup(int Group);
void Update(float TimePassed); void Update(float TimePassed);

View file

@ -460,12 +460,11 @@ void CPlayers::RenderPlayer(
// do skidding // do skidding
if(!InAir && WantOtherDir && length(Vel * 50) > 500.0f) if(!InAir && WantOtherDir && length(Vel * 50) > 500.0f)
{ {
static int64_t SkidSoundTime = 0; if(time() - m_SkidSoundTime > time_freq() / 10)
if(time() - SkidSoundTime > time_freq() / 10)
{ {
if(g_Config.m_SndGame) if(g_Config.m_SndGame)
m_pClient->m_Sounds.PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_SKID, 0.25f, Position); m_pClient->m_Sounds.PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_SKID, 0.25f, Position);
SkidSoundTime = time(); m_SkidSoundTime = time();
} }
m_pClient->m_Effects.SkidTrail( m_pClient->m_Effects.SkidTrail(

View file

@ -34,6 +34,8 @@ class CPlayers : public CComponent
int m_WeaponEmoteQuadContainerIndex; int m_WeaponEmoteQuadContainerIndex;
int m_aWeaponSpriteMuzzleQuadContainerIndex[NUM_WEAPONS]; int m_aWeaponSpriteMuzzleQuadContainerIndex[NUM_WEAPONS];
int64_t m_SkidSoundTime = 0;
public: public:
float GetPlayerTargetAngle( float GetPlayerTargetAngle(
const CNetObj_Character *pPrevChar, const CNetObj_Character *pPrevChar,

View file

@ -2845,9 +2845,9 @@ void CEditor::DoQuadEnvelopes(const std::vector<CQuad> &vQuads, IGraphics::CText
Graphics()->SetColorVertex(aArray, 4); Graphics()->SetColorVertex(aArray, 4);
// Rotation // Rotation
CPoint aRotated[4];
if(Rot != 0) if(Rot != 0)
{ {
static CPoint aRotated[4];
aRotated[0] = vQuads[j].m_aPoints[0]; aRotated[0] = vQuads[j].m_aPoints[0];
aRotated[1] = vQuads[j].m_aPoints[1]; aRotated[1] = vQuads[j].m_aPoints[1];
aRotated[2] = vQuads[j].m_aPoints[2]; aRotated[2] = vQuads[j].m_aPoints[2];

View file

@ -2508,7 +2508,7 @@ CUi::EPopupMenuFunctionResult CEditor::PopupTele(void *pContext, CUIRect View, b
static int s_aIds[NUM_PROPS] = {0}; static int s_aIds[NUM_PROPS] = {0};
static int NewVal = 0; int NewVal = 0;
int Prop = pEditor->DoProperties(&NumberPicker, aProps, s_aIds, &NewVal, s_vColors); int Prop = pEditor->DoProperties(&NumberPicker, aProps, s_aIds, &NewVal, s_vColors);
if(Prop == PROP_TELE) if(Prop == PROP_TELE)
pEditor->m_TeleNumber = (NewVal - 1 + 255) % 255 + 1; pEditor->m_TeleNumber = (NewVal - 1 + 255) % 255 + 1;