mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #6014
6014: Use traditional casts instead of functional-style casts r=def- a=Robyt3 For consistency. ## 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:
commit
415cfedaba
|
@ -2059,13 +2059,11 @@ void CCommandProcessorFragment_OpenGL2::RenderBorderTileEmulation(SBufferContain
|
|||
{
|
||||
GLint RealOffset = (GLint)((((size_t)(uintptr_t)(pBuffOffset)) / (6 * sizeof(unsigned int))) * 4);
|
||||
size_t SingleVertSize = (sizeof(vec2) + (IsTextured ? sizeof(vec3) : 0));
|
||||
size_t CurBufferOffset = (RealOffset)*SingleVertSize;
|
||||
|
||||
size_t CurBufferOffset = RealOffset * SingleVertSize;
|
||||
int XCount = i - (size_t)(i / JumpIndex) * JumpIndex;
|
||||
int YCount = (size_t)(i / JumpIndex);
|
||||
for(size_t n = 0; n < 4; ++n)
|
||||
{
|
||||
int XCount = i - (int(i / JumpIndex) * JumpIndex);
|
||||
int YCount = (int(i / JumpIndex));
|
||||
|
||||
ptrdiff_t VertOffset = (ptrdiff_t)(CurBufferOffset + (n * SingleVertSize));
|
||||
vec2 *pPos = (vec2 *)((uint8_t *)BufferObject.m_pData + VertOffset);
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ void CInput::SelectNextJoystick()
|
|||
|
||||
float CInput::CJoystick::GetAxisValue(int Axis)
|
||||
{
|
||||
return (SDL_JoystickGetAxis(m_pDelegate, Axis) - SDL_JOYSTICK_AXIS_MIN) / float(SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) * 2.0f - 1.0f;
|
||||
return (SDL_JoystickGetAxis(m_pDelegate, Axis) - SDL_JOYSTICK_AXIS_MIN) / (float)(SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) * 2.0f - 1.0f;
|
||||
}
|
||||
|
||||
int CInput::CJoystick::GetJoystickHatKey(int Hat, int HatValue)
|
||||
|
|
|
@ -506,7 +506,7 @@ CGameConsole::~CGameConsole()
|
|||
float CGameConsole::TimeNow()
|
||||
{
|
||||
static int64_t s_TimeStart = time_get();
|
||||
return float(time_get() - s_TimeStart) / float(time_freq());
|
||||
return (time_get() - s_TimeStart) / (float)time_freq();
|
||||
}
|
||||
|
||||
CGameConsole::CInstance *CGameConsole::CurrentConsole()
|
||||
|
|
|
@ -1515,7 +1515,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
|||
int OldSelected = -1;
|
||||
{
|
||||
int G = std::gcd(g_Config.m_GfxScreenWidth, g_Config.m_GfxScreenHeight);
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %dx%d @%dhz %d bit (%d:%d)", Localize("Current"), int(g_Config.m_GfxScreenWidth * Graphics()->ScreenHiDPIScale()), int(g_Config.m_GfxScreenHeight * Graphics()->ScreenHiDPIScale()), g_Config.m_GfxScreenRefreshRate, g_Config.m_GfxColorDepth, g_Config.m_GfxScreenWidth / G, g_Config.m_GfxScreenHeight / G);
|
||||
str_format(aBuf, sizeof(aBuf), "%s: %dx%d @%dhz %d bit (%d:%d)", Localize("Current"), (int)(g_Config.m_GfxScreenWidth * Graphics()->ScreenHiDPIScale()), (int)(g_Config.m_GfxScreenHeight * Graphics()->ScreenHiDPIScale()), g_Config.m_GfxScreenRefreshRate, g_Config.m_GfxColorDepth, g_Config.m_GfxScreenWidth / G, g_Config.m_GfxScreenHeight / G);
|
||||
}
|
||||
|
||||
UI()->DoLabel(&ModeLabel, aBuf, sc_FontSizeResListHeader, TEXTALIGN_CENTER);
|
||||
|
|
|
@ -128,7 +128,7 @@ void CPickup::Tick()
|
|||
|
||||
void CPickup::Move()
|
||||
{
|
||||
if(GameWorld()->GameTick() % int(GameWorld()->GameTickSpeed() * 0.15f) == 0)
|
||||
if(GameWorld()->GameTick() % (int)(GameWorld()->GameTickSpeed() * 0.15f) == 0)
|
||||
{
|
||||
int Flags;
|
||||
int index = Collision()->IsMover(m_Pos.x, m_Pos.y, &Flags);
|
||||
|
|
|
@ -33,7 +33,7 @@ CDragger::CDragger(CGameWorld *pGameWorld, vec2 Pos, float Strength, bool Ignore
|
|||
|
||||
void CDragger::Tick()
|
||||
{
|
||||
if(Server()->Tick() % int(Server()->TickSpeed() * 0.15f) == 0)
|
||||
if(Server()->Tick() % (int)(Server()->TickSpeed() * 0.15f) == 0)
|
||||
{
|
||||
int Flags;
|
||||
m_EvalTick = Server()->Tick();
|
||||
|
|
|
@ -47,7 +47,7 @@ void CDraggerBeam::Tick()
|
|||
// after CDraggerBeam::Tick and only every 150ms
|
||||
// When the dragger is disabled for the target player's team, the dragger beam dissolves. The check if a dragger
|
||||
// is disabled is only executed every 150ms, so the beam can stay activated up to 6 extra ticks
|
||||
if(Server()->Tick() % int(Server()->TickSpeed() * 0.15f) == 0)
|
||||
if(Server()->Tick() % (int)(Server()->TickSpeed() * 0.15f) == 0)
|
||||
{
|
||||
if(m_Layer == LAYER_SWITCH && m_Number > 0 &&
|
||||
!Switchers()[m_Number].m_aStatus[pTarget->Team()])
|
||||
|
|
|
@ -30,7 +30,7 @@ CGun::CGun(CGameWorld *pGameWorld, vec2 Pos, bool Freeze, bool Explosive, int La
|
|||
|
||||
void CGun::Tick()
|
||||
{
|
||||
if(Server()->Tick() % int(Server()->TickSpeed() * 0.15f) == 0)
|
||||
if(Server()->Tick() % (int)(Server()->TickSpeed() * 0.15f) == 0)
|
||||
{
|
||||
int Flags;
|
||||
m_EvalTick = Server()->Tick();
|
||||
|
|
|
@ -83,7 +83,7 @@ void CLight::Reset()
|
|||
|
||||
void CLight::Tick()
|
||||
{
|
||||
if(Server()->Tick() % int(Server()->TickSpeed() * 0.15f) == 0)
|
||||
if(Server()->Tick() % (int)(Server()->TickSpeed() * 0.15f) == 0)
|
||||
{
|
||||
int Flags;
|
||||
m_EvalTick = Server()->Tick();
|
||||
|
|
|
@ -220,7 +220,7 @@ void CPickup::Snap(int SnappingClient)
|
|||
|
||||
void CPickup::Move()
|
||||
{
|
||||
if(Server()->Tick() % int(Server()->TickSpeed() * 0.15f) == 0)
|
||||
if(Server()->Tick() % (int)(Server()->TickSpeed() * 0.15f) == 0)
|
||||
{
|
||||
int Flags;
|
||||
int index = GameServer()->Collision()->IsMover(m_Pos.x, m_Pos.y, &Flags);
|
||||
|
|
|
@ -228,13 +228,13 @@ void CGameContext::FillAntibot(CAntibotRoundData *pData)
|
|||
|
||||
void CGameContext::CreateDamageInd(vec2 Pos, float Angle, int Amount, int64_t Mask)
|
||||
{
|
||||
float a = 3 * 3.14159f / 2 + Angle;
|
||||
float a = 3 * pi / 2 + Angle;
|
||||
//float a = get_angle(dir);
|
||||
float s = a - pi / 3;
|
||||
float e = a + pi / 3;
|
||||
for(int i = 0; i < Amount; i++)
|
||||
{
|
||||
float f = mix(s, e, float(i + 1) / float(Amount + 2));
|
||||
float f = mix(s, e, (i + 1) / (float)(Amount + 2));
|
||||
CNetEvent_DamageInd *pEvent = (CNetEvent_DamageInd *)m_Events.Create(NETEVENTTYPE_DAMAGEIND, sizeof(CNetEvent_DamageInd), Mask);
|
||||
if(pEvent)
|
||||
{
|
||||
|
@ -688,8 +688,8 @@ void CGameContext::SendVoteStatus(int ClientID, int Total, int Yes, int No)
|
|||
|
||||
if(Total > VANILLA_MAX_CLIENTS && m_apPlayers[ClientID] && m_apPlayers[ClientID]->GetClientVersion() <= VERSION_DDRACE)
|
||||
{
|
||||
Yes = float(Yes * VANILLA_MAX_CLIENTS) / float(Total);
|
||||
No = float(No * VANILLA_MAX_CLIENTS) / float(Total);
|
||||
Yes = (Yes * VANILLA_MAX_CLIENTS) / (float)Total;
|
||||
No = (No * VANILLA_MAX_CLIENTS) / (float)Total;
|
||||
Total = VANILLA_MAX_CLIENTS;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,8 @@ TEST(CVariableInt, RoundtripPackUnpack)
|
|||
{
|
||||
unsigned char aPacked[CVariableInt::MAX_BYTES_PACKED];
|
||||
int Result;
|
||||
EXPECT_EQ(int(CVariableInt::Pack(aPacked, DATA[i], sizeof(aPacked)) - aPacked), SIZES[i]);
|
||||
EXPECT_EQ(int(CVariableInt::Unpack(aPacked, &Result, sizeof(aPacked)) - aPacked), SIZES[i]);
|
||||
EXPECT_EQ(CVariableInt::Pack(aPacked, DATA[i], sizeof(aPacked)) - aPacked, (ptrdiff_t)SIZES[i]);
|
||||
EXPECT_EQ(CVariableInt::Unpack(aPacked, &Result, sizeof(aPacked)) - aPacked, (ptrdiff_t)SIZES[i]);
|
||||
EXPECT_EQ(Result, DATA[i]);
|
||||
}
|
||||
}
|
||||
|
@ -25,12 +25,12 @@ TEST(CVariableInt, UnpackInvalid)
|
|||
Byte = 0xFF;
|
||||
|
||||
int Result;
|
||||
EXPECT_EQ(int(CVariableInt::Unpack(aPacked, &Result, sizeof(aPacked)) - aPacked), int(CVariableInt::MAX_BYTES_PACKED));
|
||||
EXPECT_EQ(CVariableInt::Unpack(aPacked, &Result, sizeof(aPacked)) - aPacked, (ptrdiff_t)CVariableInt::MAX_BYTES_PACKED);
|
||||
EXPECT_EQ(Result, (-2147483647 - 1));
|
||||
|
||||
aPacked[0] &= ~0x40; // unset sign bit
|
||||
|
||||
EXPECT_EQ(int(CVariableInt::Unpack(aPacked, &Result, sizeof(aPacked)) - aPacked), int(CVariableInt::MAX_BYTES_PACKED));
|
||||
EXPECT_EQ(CVariableInt::Unpack(aPacked, &Result, sizeof(aPacked)) - aPacked, (ptrdiff_t)CVariableInt::MAX_BYTES_PACKED);
|
||||
EXPECT_EQ(Result, 2147483647);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue