6372: Check in CI that no C standard headers are used, replace all usages of C standard headers with C++ headers, replace usages of C math functions r=def- a=Robyt3

Closes #6334.

## 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] 2023-03-01 22:34:26 +00:00 committed by GitHub
commit 0f5d4d8bec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
72 changed files with 247 additions and 227 deletions

View file

@ -42,6 +42,8 @@ jobs:
run: scripts/check_dilate.sh release data
- name: Check absolute includes
run: "! grep --exclude-dir rust-bridge -rE '^#include \"(antibot|base|engine|game|steam|test)/' src/"
- name: Check standard header includes
run: scripts/check_standard_headers.sh
# TODO: Enable on release branches
#- name: Out-of-date translations
# run: |

View file

@ -0,0 +1,33 @@
#!/usr/bin/env bash
# List of C headers and their corresponding C++ headers
c_headers=(assert complex ctype errno fenv float inttypes iso646 limits locale math setjmp signal stdarg stdbool stddef stdint stdio stdlib string tgmath time wchar wctype)
c_headers_map=(cassert complex cctype cerrno cfenv cfloat cinttypes ciso646 climits clocale cmath csetjmp csignal cstdarg cstdbool cstddef cstdint cstdio cstdlib cstring ctgmath ctime cwchar cwctype)
# Create regex dynamically from the array to match any C header
c_headers_regex=$(IFS="|"; echo "${c_headers[*]}")
# Find all C++ source and header files
files=$(find ./src -type f \( -name '*.cpp' -o -name '*.hpp' -o -name '*.h' \) ! -path "./src/engine/external/*")
error_found=0
# Check each source file for C headers
for file in $files; do
# First check if the file includes any C headers for more efficiency when no C header is used
if grep -E "#include\s+<($c_headers_regex)\.h>" "$file" >/dev/null; then
# Check each C header individually to print an error message with the appropriate replacement C++ header
for (( i=0; i < ${#c_headers[@]}; i++ )); do
if grep -E "#include\s+<${c_headers[i]}\.h>" "$file" >/dev/null; then
echo "Error: '$file' includes C header '${c_headers[i]}.h'. Include the C++ header '${c_headers_map[i]}' instead."
fi
done
error_found=1
fi
done
if [ $error_found -eq 1 ]; then
exit 1
fi
echo "Success: No standard C headers are used."

View file

@ -53,7 +53,7 @@ def generate_decompositions():
def gen_header(decompositions, len_set):
print("""\
#include <stdint.h>
#include <cstdint>
struct DECOMP_SLICE
{

View file

@ -16,7 +16,7 @@ def generate_cases():
def gen_header(cases):
print(f"""\
#include <stdint.h>
#include <cstdint>
struct UPPER_LOWER
{{

View file

@ -1,8 +1,8 @@
#ifndef BASE_LOG_H
#define BASE_LOG_H
#include <stdarg.h>
#include <stdint.h>
#include <cstdarg>
#include <cstdint>
#ifdef __GNUC__
#define GNUC_ATTRIBUTE(x) __attribute__(x)

View file

@ -4,8 +4,8 @@
#define BASE_MATH_H
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#include <cmath>
#include <cstdlib>
using std::clamp;
@ -19,11 +19,6 @@ constexpr inline int round_truncate(float f)
return (int)f;
}
inline int round_ceil(float f)
{
return (int)ceilf(f);
}
template<typename T, typename TB>
constexpr inline T mix(const T a, const T b, TB amount)
{

View file

@ -70,7 +70,7 @@
#include <ws2tcpip.h>
#include <cerrno>
#include <fenv.h>
#include <cfenv>
#include <io.h>
#include <objbase.h>
#include <process.h>

View file

@ -14,9 +14,9 @@
#define __USE_GNU
#endif
#include <inttypes.h>
#include <stdint.h>
#include <time.h>
#include <cinttypes>
#include <cstdint>
#include <ctime>
#ifdef __MINGW32__
#undef PRId64
@ -62,7 +62,7 @@
void dbg_assert_imp(const char *filename, int line, int test, const char *msg);
#ifdef __clang_analyzer__
#include <assert.h>
#include <cassert>
#undef dbg_assert
#define dbg_assert(test, msg) assert(test)
#endif

View file

@ -1,4 +1,4 @@
#include <stdint.h>
#include <cstdint>
struct DECOMP_SLICE
{

View file

@ -1,4 +1,4 @@
#include <stdint.h>
#include <cstdint>
struct UPPER_LOWER
{

View file

@ -3,7 +3,7 @@
#ifndef BASE_VMATH_H
#define BASE_VMATH_H
#include <math.h>
#include <cmath>
#include "math.h"
@ -87,8 +87,8 @@ template<typename T>
constexpr inline vector2_base<T> rotate(const vector2_base<T> &a, float angle)
{
angle = angle * pi / 180.0f;
float s = sinf(angle);
float c = cosf(angle);
float s = std::sin(angle);
float c = std::cos(angle);
return vector2_base<T>((T)(c * a.x - s * a.y), (T)(s * a.x + c * a.y));
}
@ -106,7 +106,7 @@ constexpr inline T dot(const vector2_base<T> a, const vector2_base<T> &b)
inline float length(const vector2_base<float> &a)
{
return sqrtf(dot(a, a));
return std::sqrt(dot(a, a));
}
constexpr inline float angle(const vector2_base<float> &a)
@ -115,7 +115,7 @@ constexpr inline float angle(const vector2_base<float> &a)
return 0.0f;
else if(a.x == 0)
return a.y < 0 ? -pi / 2 : pi / 2;
float result = atanf(a.y / a.x);
float result = std::atan(a.y / a.x);
if(a.x < 0)
result = result + pi;
return result;
@ -140,7 +140,7 @@ inline vector2_base<float> normalize(const vector2_base<float> &v)
inline vector2_base<float> direction(float angle)
{
return vector2_base<float>(cosf(angle), sinf(angle));
return vector2_base<float>(std::cos(angle), std::sin(angle));
}
typedef vector2_base<float> vec2;
@ -271,7 +271,7 @@ constexpr inline vector3_base<T> cross(const vector3_base<T> &a, const vector3_b
//
inline float length(const vector3_base<float> &a)
{
return sqrtf(dot(a, a));
return std::sqrt(dot(a, a));
}
inline vector3_base<float> normalize(const vector3_base<float> &v)

View file

@ -1780,7 +1780,7 @@ protected:
static size_t ImageMipLevelCount(size_t Width, size_t Height, size_t Depth)
{
return floor(log2(maximum(Width, maximum(Height, Depth)))) + 1;
return std::floor(std::log2(maximum(Width, maximum(Height, Depth)))) + 1;
}
static size_t ImageMipLevelCount(const VkExtent3D &ImgExtent)

View file

@ -1,8 +1,8 @@
#ifndef ENGINE_CLIENT_GRAPHICS_DEFINES_H
#define ENGINE_CLIENT_GRAPHICS_DEFINES_H
#include <stddef.h>
#include <stdint.h>
#include <cstddef>
#include <cstdint>
typedef uint32_t TWGLuint;
typedef int32_t TWGLint;

View file

@ -1262,12 +1262,12 @@ void CGraphics_Threaded::DrawRectExt(float x, float y, float w, float h, float r
float a1 = i * SegmentsAngle;
float a2 = (i + 1) * SegmentsAngle;
float a3 = (i + 2) * SegmentsAngle;
float Ca1 = cosf(a1);
float Ca2 = cosf(a2);
float Ca3 = cosf(a3);
float Sa1 = sinf(a1);
float Sa2 = sinf(a2);
float Sa3 = sinf(a3);
float Ca1 = std::cos(a1);
float Ca2 = std::cos(a2);
float Ca3 = std::cos(a3);
float Sa1 = std::sin(a1);
float Sa2 = std::sin(a2);
float Sa3 = std::sin(a3);
if(Corners & CORNER_TL)
aFreeform[NumItems++] = IGraphics::CFreeformItem(
@ -1336,12 +1336,12 @@ void CGraphics_Threaded::DrawRectExt4(float x, float y, float w, float h, ColorR
float a1 = i * SegmentsAngle;
float a2 = (i + 1) * SegmentsAngle;
float a3 = (i + 2) * SegmentsAngle;
float Ca1 = cosf(a1);
float Ca2 = cosf(a2);
float Ca3 = cosf(a3);
float Sa1 = sinf(a1);
float Sa2 = sinf(a2);
float Sa3 = sinf(a3);
float Ca1 = std::cos(a1);
float Ca2 = std::cos(a2);
float Ca3 = std::cos(a3);
float Sa1 = std::sin(a1);
float Sa2 = std::sin(a2);
float Sa3 = std::sin(a3);
if(Corners & CORNER_TL)
{
@ -1504,12 +1504,12 @@ int CGraphics_Threaded::CreateRectQuadContainer(float x, float y, float w, float
float a1 = i * SegmentsAngle;
float a2 = (i + 1) * SegmentsAngle;
float a3 = (i + 2) * SegmentsAngle;
float Ca1 = cosf(a1);
float Ca2 = cosf(a2);
float Ca3 = cosf(a3);
float Sa1 = sinf(a1);
float Sa2 = sinf(a2);
float Sa3 = sinf(a3);
float Ca1 = std::cos(a1);
float Ca2 = std::cos(a2);
float Ca3 = std::cos(a3);
float Sa1 = std::sin(a1);
float Sa2 = std::sin(a2);
float Sa3 = std::sin(a3);
if(Corners & CORNER_TL)
aFreeform[NumItems++] = IGraphics::CFreeformItem(
@ -1598,9 +1598,9 @@ void CGraphics_Threaded::DrawCircle(float CenterX, float CenterY, float Radius,
const float a3 = (i + 2) * SegmentsAngle;
aItems[NumItems++] = IGraphics::CFreeformItem(
CenterX, CenterY,
CenterX + cosf(a1) * Radius, CenterY + sinf(a1) * Radius,
CenterX + cosf(a3) * Radius, CenterY + sinf(a3) * Radius,
CenterX + cosf(a2) * Radius, CenterY + sinf(a2) * Radius);
CenterX + std::cos(a1) * Radius, CenterY + std::sin(a1) * Radius,
CenterX + std::cos(a3) * Radius, CenterY + std::sin(a3) * Radius,
CenterX + std::cos(a2) * Radius, CenterY + std::sin(a2) * Radius);
if(NumItems == std::size(aItems))
{
QuadsDrawFreeform(aItems, std::size(aItems));

View file

@ -890,8 +890,8 @@ class CGraphics_Threaded : public IEngineGraphics
template<typename TName>
void Rotate(const CCommandBuffer::SPoint &rCenter, TName *pPoints, int NumPoints)
{
float c = cosf(m_Rotation);
float s = sinf(m_Rotation);
float c = std::cos(m_Rotation);
float s = std::sin(m_Rotation);
float x, y;
int i;

View file

@ -153,7 +153,7 @@ static void Mix(short *pFinalOut, unsigned Frames)
// dx and dy can be larger than 46341 and thus the calculation would go beyond the limits of a integer,
// therefore we cast them into float
int Dist = (int)sqrtf((float)dx * dx + (float)dy * dy);
int Dist = (int)length(vec2(dx, dy));
if(Dist < r)
{
InVoiceField = true;
@ -175,8 +175,8 @@ static void Mix(short *pFinalOut, unsigned Frames)
{
RangeX = Voice.m_Rectangle.m_Width / 2.0f;
int abs_dx = abs(dx);
int abs_dy = abs(dy);
int abs_dx = absolute(dx);
int abs_dy = absolute(dy);
int w = Voice.m_Rectangle.m_Width / 2.0f;
int h = Voice.m_Rectangle.m_Height / 2.0f;
@ -800,7 +800,7 @@ void CSound::SetVoiceTimeOffset(CVoiceHandle Voice, float offset)
// at least 200msec off, else depend on buffer size
float Threshold = maximum(0.2f * m_aVoices[VoiceID].m_pSample->m_Rate, (float)m_MaxFrames);
if(abs(m_aVoices[VoiceID].m_Tick - Tick) > Threshold)
if(absolute(m_aVoices[VoiceID].m_Tick - Tick) > Threshold)
{
// take care of looping (modulo!)
if(!(IsLooping && (minimum(m_aVoices[VoiceID].m_Tick, Tick) + m_aVoices[VoiceID].m_pSample->m_NumFrames - maximum(m_aVoices[VoiceID].m_Tick, Tick)) <= Threshold))

View file

@ -1,8 +1,8 @@
#ifndef ENGINE_GFX_IMAGE_LOADER_H
#define ENGINE_GFX_IMAGE_LOADER_H
#include <stddef.h>
#include <stdint.h>
#include <cstddef>
#include <cstdint>
#include <vector>
enum EImageFormat

View file

@ -143,11 +143,11 @@ static void SampleBicubic(const uint8_t *pSourceImage, float u, float v, uint32_
{
float X = (u * W) - 0.5f;
int xInt = (int)X;
float xFract = X - floorf(X);
float xFract = X - std::floor(X);
float Y = (v * H) - 0.5f;
int yInt = (int)Y;
float yFract = Y - floorf(Y);
float yFract = Y - std::floor(Y);
uint8_t aPX00[4];
uint8_t aPX10[4];

View file

@ -1,7 +1,7 @@
#ifndef ENGINE_GFX_IMAGE_MANIPULATION_H
#define ENGINE_GFX_IMAGE_MANIPULATION_H
#include <stdint.h>
#include <cstdint>
void DilateImage(unsigned char *pImageBuff, int w, int h, int BPP);
void DilateImageSub(unsigned char *pImageBuff, int w, int h, int BPP, int x, int y, int sw, int sh);

View file

@ -7,17 +7,18 @@
#include "warning.h"
#include <base/color.h>
#include <stddef.h>
#include <stdint.h>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <vector>
#define GRAPHICS_TYPE_UNSIGNED_BYTE 0x1401
#define GRAPHICS_TYPE_UNSIGNED_SHORT 0x1403
#define GRAPHICS_TYPE_INT 0x1404
#define GRAPHICS_TYPE_UNSIGNED_INT 0x1405
#define GRAPHICS_TYPE_FLOAT 0x1406
struct SBufferContainerInfo
{
int m_Stride;

View file

@ -5,7 +5,7 @@
#include <base/system.h>
#include <stdint.h>
#include <cstdint>
class IStorage;

View file

@ -4,7 +4,7 @@
#define ENGINE_SHARED_SNAPSHOT_H
#include <cstddef>
#include <stdint.h>
#include <cstdint>
// CSnapshot

View file

@ -7,7 +7,7 @@
#include <engine/storage.h>
#ifdef CONF_PLATFORM_HAIKU
#include <stdlib.h>
#include <cstdlib>
#endif
class CStorage : public IStorage

View file

@ -6,7 +6,7 @@
#include <winsock2.h>
#endif
#include <stddef.h>
#include <cstddef>
int websocket_create(const char *addr, int port);
int websocket_destroy(int socket);

View file

@ -5,7 +5,7 @@
#include <game/client/components/maplayers.h>
#include <stdint.h>
#include <cstdint>
class CLayers;
class CMapImages;

View file

@ -138,7 +138,7 @@ void CCamera::OnRender()
s_SpeedBias += CameraSpeed * DeltaTime;
if(g_Config.m_ClDyncam)
{
s_SpeedBias -= length(m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy] - s_LastMousePos) * log10f(CameraStabilizingFactor) * 0.02f;
s_SpeedBias -= length(m_pClient->m_Controls.m_aMousePos[g_Config.m_ClDummy] - s_LastMousePos) * std::log10(CameraStabilizingFactor) * 0.02f;
s_SpeedBias = clamp(s_SpeedBias, 0.5f, CameraSpeed);
}
else
@ -188,7 +188,7 @@ void CCamera::OnConsoleInit()
void CCamera::OnReset()
{
m_Zoom = pow(ZoomStep, g_Config.m_ClDefaultZoom - 10);
m_Zoom = std::pow(ZoomStep, g_Config.m_ClDefaultZoom - 10);
m_Zooming = false;
}
@ -211,7 +211,7 @@ void CCamera::ConZoomMinus(IConsole::IResult *pResult, void *pUserData)
void CCamera::ConZoom(IConsole::IResult *pResult, void *pUserData)
{
float TargetLevel = pResult->NumArguments() ? pResult->GetFloat(0) : g_Config.m_ClDefaultZoom;
((CCamera *)pUserData)->ChangeZoom(pow(ZoomStep, TargetLevel - 10));
((CCamera *)pUserData)->ChangeZoom(std::pow(ZoomStep, TargetLevel - 10));
}
void CCamera::ConSetView(IConsole::IResult *pResult, void *pUserData)
{

View file

@ -524,8 +524,7 @@ void CGameConsole::OnReset()
// only defined for 0<=t<=1
static float ConsoleScaleFunc(float t)
{
//return t;
return sinf(acosf(1.0f - t));
return std::sin(std::acos(1.0f - t));
}
struct CCompletionOptionRenderInfo

View file

@ -291,8 +291,8 @@ int CControls::SnapInput(int *pData)
m_aInputData[g_Config.m_ClDummy].m_Fire = ((int)(t * 10));
m_aInputData[g_Config.m_ClDummy].m_Hook = ((int)(t * 2)) & 1;
m_aInputData[g_Config.m_ClDummy].m_WantedWeapon = ((int)t) % NUM_WEAPONS;
m_aInputData[g_Config.m_ClDummy].m_TargetX = (int)(sinf(t * 3) * 100.0f);
m_aInputData[g_Config.m_ClDummy].m_TargetY = (int)(cosf(t * 3) * 100.0f);
m_aInputData[g_Config.m_ClDummy].m_TargetX = (int)(std::sin(t * 3) * 100.0f);
m_aInputData[g_Config.m_ClDummy].m_TargetY = (int)(std::cos(t * 3) * 100.0f);
}
#endif

View file

@ -167,7 +167,7 @@ void CEffects::PlayerSpawn(vec2 Pos)
p.SetDefault();
p.m_Spr = SPRITE_PART_SHELL;
p.m_Pos = Pos;
p.m_Vel = RandomDir() * (powf(random_float(), 3) * 600.0f);
p.m_Vel = RandomDir() * (std::pow(random_float(), 3) * 600.0f);
p.m_LifeSpan = 0.3f + random_float() * 0.3f;
p.m_StartSize = 64.0f + random_float() * 32;
p.m_EndSize = 0;

View file

@ -120,9 +120,8 @@ void CEmoticon::OnRender()
Graphics()->QuadsSetSubset(0, 0, 1, 1);
Graphics()->QuadsBegin();
float NudgeX = 150.0f * cosf(Angle);
float NudgeY = 150.0f * sinf(Angle);
IGraphics::CQuadItem QuadItem(Screen.w / 2 + NudgeX, Screen.h / 2 + NudgeY, Size, Size);
const vec2 Nudge = direction(Angle) * 150.0f;
IGraphics::CQuadItem QuadItem(Screen.w / 2 + Nudge.x, Screen.h / 2 + Nudge.y, Size, Size);
Graphics()->QuadsDraw(&QuadItem, 1);
Graphics()->QuadsEnd();
}
@ -146,11 +145,9 @@ void CEmoticon::OnRender()
bool Selected = m_SelectedEyeEmote == i;
float NudgeX = 70.0f * cosf(Angle);
float NudgeY = 70.0f * sinf(Angle);
const vec2 Nudge = direction(Angle) * 70.0f;
pTeeInfo->m_Size = Selected ? 64.0f : 48.0f;
RenderTools()->RenderTee(CAnimState::GetIdle(), pTeeInfo, i, vec2(-1, 0), vec2(Screen.w / 2 + NudgeX, Screen.h / 2 + NudgeY));
RenderTools()->RenderTee(CAnimState::GetIdle(), pTeeInfo, i, vec2(-1, 0), vec2(Screen.w / 2 + Nudge.x, Screen.h / 2 + Nudge.y));
pTeeInfo->m_Size = 64.0f;
}

View file

@ -317,7 +317,7 @@ void CHud::RenderScoreHud()
if(m_pClient->m_GameInfo.m_TimeScore && g_Config.m_ClDDRaceScoreBoard)
{
if(apPlayerInfo[t]->m_Score != -9999)
str_time((int64_t)abs(apPlayerInfo[t]->m_Score) * 100, TIME_HOURS, aScore[t], sizeof(aScore[t]));
str_time((int64_t)absolute(apPlayerInfo[t]->m_Score) * 100, TIME_HOURS, aScore[t], sizeof(aScore[t]));
else
aScore[t][0] = 0;
}
@ -834,23 +834,23 @@ void CHud::RenderPlayerState(const int ClientID)
UsedJumps = !Grounded;
}
if(pCharacter->m_EndlessJump && UsedJumps >= abs(pCharacter->m_Jumps))
if(pCharacter->m_EndlessJump && UsedJumps >= absolute(pCharacter->m_Jumps))
{
UsedJumps = abs(pCharacter->m_Jumps) - 1;
UsedJumps = absolute(pCharacter->m_Jumps) - 1;
}
int UnusedJumps = abs(pCharacter->m_Jumps) - UsedJumps;
int UnusedJumps = absolute(pCharacter->m_Jumps) - UsedJumps;
if(!(pPlayer->m_Jumped & 2) && UnusedJumps <= 0)
{
// In some edge cases when the player just got another number of jumps, UnusedJumps is not correct
UnusedJumps = 1;
}
TotalJumpsToDisplay = maximum(minimum(abs(pCharacter->m_Jumps), 10), 0);
TotalJumpsToDisplay = maximum(minimum(absolute(pCharacter->m_Jumps), 10), 0);
AvailableJumpsToDisplay = maximum(minimum(UnusedJumps, TotalJumpsToDisplay), 0);
}
else
{
TotalJumpsToDisplay = AvailableJumpsToDisplay = abs(m_pClient->m_Snap.m_aCharacters[ClientID].m_ExtendedData.m_Jumps);
TotalJumpsToDisplay = AvailableJumpsToDisplay = absolute(m_pClient->m_Snap.m_aCharacters[ClientID].m_ExtendedData.m_Jumps);
}
// render available and used jumps
@ -1303,7 +1303,7 @@ inline int CHud::GetDigitsIndex(int Value, int Max)
{
Value *= -1;
}
int DigitsIndex = (int)log10((Value ? Value : 1));
int DigitsIndex = std::log10((Value ? Value : 1));
if(DigitsIndex > Max)
{
DigitsIndex = Max;

View file

@ -189,8 +189,7 @@ void CItems::RenderPickup(const CNetObj_Pickup *pPrev, const CNetObj_Pickup *pCu
if(m_pClient->m_Snap.m_pGameInfoObj && !(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED))
s_Time += LocalTime() - s_LastLocalTime;
}
Pos.x += cosf(s_Time * 2.0f + Offset) * 2.5f;
Pos.y += sinf(s_Time * 2.0f + Offset) * 2.5f;
Pos += direction(s_Time * 2.0f + Offset) * 2.5f;
s_LastLocalTime = LocalTime();
Graphics()->RenderQuadContainerAsSprite(m_ItemsQuadContainerIndex, QuadOffset, Pos.x, Pos.y);
@ -424,7 +423,7 @@ void CItems::OnRender()
{
bool IsOtherTeam = m_pClient->IsOtherTeam(pProj->GetOwner());
if(pProj->m_LastRenderTick <= 0 && (pProj->m_Type != WEAPON_SHOTGUN || (!pProj->m_Freeze && !pProj->m_Explosive)) // skip ddrace shotgun bullets
&& (pProj->m_Type == WEAPON_SHOTGUN || fabs(length(pProj->m_Direction) - 1.f) < 0.02f) // workaround to skip grenades on ball mod
&& (pProj->m_Type == WEAPON_SHOTGUN || absolute(length(pProj->m_Direction) - 1.f) < 0.02f) // workaround to skip grenades on ball mod
&& (pProj->GetOwner() < 0 || !GameClient()->m_aClients[pProj->GetOwner()].m_IsPredictedLocal || IsOtherTeam) // skip locally predicted projectiles
&& !Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID))
{

View file

@ -438,7 +438,7 @@ void CMapImages::UpdateEntityLayerText(void *pTexBuffer, int ImageColorChannelCo
char aBuf[4];
int DigitsCount = NumbersPower + 1;
int CurrentNumber = pow(10, NumbersPower);
int CurrentNumber = std::pow(10, NumbersPower);
if(MaxNumber == -1)
MaxNumber = CurrentNumber * 10 - 1;

View file

@ -186,8 +186,8 @@ void FillTmpTileSpeedup(SGraphicTile *pTmpTile, SGraphicTileTexureCoords *pTmpTe
//same as in rotate from Graphics()
float Angle = (float)AngleRotate * (pi / 180.0f);
float c = cosf(Angle);
float s = sinf(Angle);
float c = std::cos(Angle);
float s = std::sin(Angle);
float xR, yR;
int i;
@ -1017,10 +1017,10 @@ void CMapLayers::RenderTileLayer(int LayerIndex, ColorRGBA &Color, CMapItemLayer
int BorderX0, BorderY0, BorderX1, BorderY1;
bool DrawBorder = false;
int Y0 = BorderY0 = (int)floorf((ScreenY0) / 32);
int X0 = BorderX0 = (int)floorf((ScreenX0) / 32);
int Y1 = BorderY1 = (int)floorf((ScreenY1) / 32);
int X1 = BorderX1 = (int)floorf((ScreenX1) / 32);
int Y0 = BorderY0 = std::floor((ScreenY0) / 32);
int X0 = BorderX0 = std::floor((ScreenX0) / 32);
int Y1 = BorderY1 = std::floor((ScreenY1) / 32);
int X1 = BorderX1 = std::floor((ScreenX1) / 32);
if(X0 <= 0)
{
@ -1095,7 +1095,7 @@ void CMapLayers::RenderTileLayer(int LayerIndex, ColorRGBA &Color, CMapItemLayer
}
if(DrawBorder)
RenderTileBorder(LayerIndex, Color, pTileLayer, pGroup, BorderX0, BorderY0, BorderX1, BorderY1, (int)(-floorf((-ScreenX1) / 32.f)) - BorderX0, (int)(-floorf((-ScreenY1) / 32.f)) - BorderY0);
RenderTileBorder(LayerIndex, Color, pTileLayer, pGroup, BorderX0, BorderY0, BorderX1, BorderY1, -std::floor(-ScreenX1 / 32.f) - BorderX0, -std::floor(-ScreenY1 / 32.f) - BorderY0);
}
void CMapLayers::RenderTileBorderCornerTiles(int WidthOffsetToOrigin, int HeightOffsetToOrigin, int TileCountWidth, int TileCountHeight, int BufferContainerIndex, const ColorRGBA &Color, offset_ptr_size IndexBufferOffset, const vec2 &Offset, const vec2 &Dir)
@ -1775,7 +1775,7 @@ void CMapLayers::OnRender()
{
// slow blinking to hint that it's not a part of the map
double Seconds = time_get() / (double)time_freq();
ColorRGBA ColorHint = ColorRGBA(1.0f, 1.0f, 1.0f, 0.3 + 0.7 * (1 + sin(2 * (double)pi * Seconds / 3)) / 2);
ColorRGBA ColorHint = ColorRGBA(1.0f, 1.0f, 1.0f, 0.3 + 0.7 * (1 + std::sin(2 * (double)pi * Seconds / 3)) / 2);
RenderTools()->RenderTileRectangle(-201, -201, pTMap->m_Width + 402, pTMap->m_Height + 402,
0, TILE_DEATH, // display air inside, death outside
@ -1794,7 +1794,7 @@ void CMapLayers::OnRender()
{
// slow blinking to hint that it's not a part of the map
double Seconds = time_get() / (double)time_freq();
ColorRGBA ColorHint = ColorRGBA(1.0f, 1.0f, 1.0f, 0.3 + 0.7 * (1.0 + sin(2 * (double)pi * Seconds / 3)) / 2);
ColorRGBA ColorHint = ColorRGBA(1.0f, 1.0f, 1.0f, 0.3 + 0.7 * (1.0 + std::sin(2 * (double)pi * Seconds / 3)) / 2);
ColorRGBA ColorKill(Color.x * ColorHint.x, Color.y * ColorHint.y, Color.z * ColorHint.z, Color.w * ColorHint.w);
RenderKillTileBorder(TileLayerCounter - 1, ColorKill, pTMap, pGroup);

View file

@ -345,7 +345,7 @@ bool CMenuBackground::Render()
// move time
m_MoveTime += clamp(Client()->RenderFrameTime(), 0.0f, 0.1f) * g_Config.m_ClCameraSpeed / 10.0f;
float XVal = 1 - m_MoveTime;
XVal = pow(XVal, 7.0f);
XVal = std::pow(XVal, 7.0f);
m_Camera.m_Center = TargetPos + Dir * (XVal * Distance);
if(m_CurrentPosition < 0)

View file

@ -525,7 +525,7 @@ int CMenus::DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool
if(absolute(s_Value) > Scale)
{
int Count = (int)(s_Value / Scale);
s_Value = fmod(s_Value, Scale);
s_Value = std::fmod(s_Value, Scale);
Current += Step * Count;
Current = clamp(Current, Min, Max);
@ -533,7 +533,7 @@ int CMenus::DoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, bool
if(Count > 0)
Current = Current / Step * Step;
else
Current = round_ceil(Current / (float)Step) * Step;
Current = std::ceil(Current / (float)Step) * Step;
}
}
}
@ -2476,7 +2476,7 @@ void CMenus::RenderBackground()
Graphics()->TextureClear();
Graphics()->QuadsBegin();
float Size = 15.0f;
float OffsetTime = fmod(LocalTime() * 0.15f, 2.0f);
float OffsetTime = std::fmod(LocalTime() * 0.15f, 2.0f);
for(int y = -2; y < (int)(sw / Size); y++)
for(int x = -2; x < (int)(sh / Size); x++)
{

View file

@ -780,7 +780,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View)
ServerFilter.HSplitBottom(4.0f, &ServerFilter, 0);
const float TypesWidth = 40.0f;
const float TypesHeight = ServerFilter.h / ceil(MaxTypes / (float)PerLine);
const float TypesHeight = ServerFilter.h / std::ceil(MaxTypes / (float)PerLine);
CUIRect TypesRect, Left, Right;
@ -1134,7 +1134,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View)
if(CurrentClient.m_Score == -9999 || CurrentClient.m_Score == 0)
aTemp[0] = 0;
else
str_time((int64_t)abs(CurrentClient.m_Score) * 100, TIME_HOURS, aTemp, sizeof(aTemp));
str_time((int64_t)absolute(CurrentClient.m_Score) * 100, TIME_HOURS, aTemp, sizeof(aTemp));
}
else
str_format(aTemp, sizeof(aTemp), "%d", CurrentClient.m_Score);

View file

@ -84,7 +84,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP
{
float a = 1;
if(g_Config.m_ClNameplatesAlways == 0)
a = clamp(1 - powf(distance(m_pClient->m_Controls.m_aTargetPos[g_Config.m_ClDummy], Position) / 200.0f, 16.0f), 0.0f, 1.0f);
a = clamp(1 - std::pow(distance(m_pClient->m_Controls.m_aTargetPos[g_Config.m_ClDummy], Position) / 200.0f, 16.0f), 0.0f, 1.0f);
const char *pName = m_pClient->m_aClients[pPlayerInfo->m_ClientID].m_aName;
if(str_comp(pName, m_aNamePlates[ClientID].m_aName) != 0 || FontSize != m_aNamePlates[ClientID].m_NameTextFontSize)

View file

@ -195,7 +195,7 @@ bool CParticles::ParticleIsVisibleOnScreen(const vec2 &CurPos, float CurSize)
Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1);
// for simplicity assume the worst case rotation, that increases the bounding box around the particle by its diagonal
const float SqrtOf2 = sqrtf(2);
const float SqrtOf2 = std::sqrt(2);
CurSize = SqrtOf2 * CurSize;
// always uses the mid of the particle

View file

@ -57,13 +57,7 @@ void CPlayers::RenderHand(CTeeRenderInfo *pInfo, vec2 CenterPos, vec2 Dir, float
}
}
inline float NormalizeAngular(float f)
{
return fmod(f + pi * 2, pi * 2);
}
inline float AngularMixDirection(float Src, float Dst) { return sinf(Dst - Src) > 0 ? 1 : -1; }
inline float AngularDistance(float Src, float Dst) { return asinf(sinf(Dst - Src)); }
inline float AngularMixDirection(float Src, float Dst) { return std::sin(Dst - Src) > 0 ? 1 : -1; }
inline float AngularApproach(float Src, float Dst, float Amount)
{
@ -418,8 +412,8 @@ void CPlayers::RenderPlayer(
bool Inactive = m_pClient->m_aClients[ClientID].m_Afk || m_pClient->m_aClients[ClientID].m_Paused;
// evaluate animation
float WalkTime = fmod(Position.x, 100.0f) / 100.0f;
float RunTime = fmod(Position.x, 200.0f) / 200.0f;
float WalkTime = std::fmod(Position.x, 100.0f) / 100.0f;
float RunTime = std::fmod(Position.x, 200.0f) / 200.0f;
// Don't do a moon walk outside the left border
if(WalkTime < 0)
@ -589,7 +583,7 @@ void CPlayers::RenderPlayer(
Recoil = 0;
float a = AttackTicksPassed / 5.0f;
if(a < 1)
Recoil = sinf(a * pi);
Recoil = std::sin(a * pi);
WeaponPosition = Position + Dir * g_pData->m_Weapons.m_aId[CurrentWeapon].m_Offsetx - Dir * Recoil * 10.0f;
WeaponPosition.y += g_pData->m_Weapons.m_aId[CurrentWeapon].m_Offsety;
if(IsSit)
@ -726,7 +720,7 @@ void CPlayers::RenderPlayer(
if(SinceStart < Client()->GameTickSpeed() / 5)
Wiggle = SinceStart / (Client()->GameTickSpeed() / 5.0f);
float WiggleAngle = sinf(5 * Wiggle);
float WiggleAngle = std::sin(5 * Wiggle);
Graphics()->QuadsSetRotation(pi / 6 * WiggleAngle);

View file

@ -402,7 +402,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch
if(pInfo->m_Score == -9999)
aBuf[0] = 0;
else
str_time((int64_t)abs(pInfo->m_Score) * 100, TIME_HOURS, aBuf, sizeof(aBuf));
str_time((int64_t)absolute(pInfo->m_Score) * 100, TIME_HOURS, aBuf, sizeof(aBuf));
}
else
str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Score, -999, 99999));

View file

@ -1867,7 +1867,7 @@ void CGameClient::OnPredict()
static vec2 s_aLastPos[MAX_CLIENTS] = {{0, 0}};
static bool s_aLastActive[MAX_CLIENTS] = {false};
if(g_Config.m_ClAntiPingSmooth && Predict() && AntiPingPlayers() && m_NewTick && abs(m_PredictedTick - Client()->PredGameTick(g_Config.m_ClDummy)) <= 1 && abs(Client()->GameTick(g_Config.m_ClDummy) - Client()->PrevGameTick(g_Config.m_ClDummy)) <= 2)
if(g_Config.m_ClAntiPingSmooth && Predict() && AntiPingPlayers() && m_NewTick && absolute(m_PredictedTick - Client()->PredGameTick(g_Config.m_ClDummy)) <= 1 && absolute(Client()->GameTick(g_Config.m_ClDummy) - Client()->PrevGameTick(g_Config.m_ClDummy)) <= 2)
{
int PredTime = clamp(Client()->GetPredictionTime(), 0, 800);
float SmoothPace = 4 - 1.5f * PredTime / 800.f; // smoothing pace (a lower value will make the smoothing quicker)
@ -1893,13 +1893,13 @@ void CGameClient::OnPredict()
for(int j = 0; j < 2; j++)
{
aMixAmount[j] = 1.0f;
if(fabs(PredErr[j]) > 0.05f)
if(absolute(PredErr[j]) > 0.05f)
{
aMixAmount[j] = 0.0f;
if(fabs(RenderDiff[j]) > 0.01f)
if(absolute(RenderDiff[j]) > 0.01f)
{
aMixAmount[j] = 1.f - clamp(RenderDiff[j] / PredDiff[j], 0.f, 1.f);
aMixAmount[j] = 1.f - powf(1.f - aMixAmount[j], 1 / 1.2f);
aMixAmount[j] = 1.f - std::pow(1.f - aMixAmount[j], 1 / 1.2f);
}
}
int64_t TimePassed = time_get() - m_aClients[i].m_aSmoothStart[j];
@ -1907,7 +1907,7 @@ void CGameClient::OnPredict()
aMixAmount[j] = minimum(aMixAmount[j], (float)(TimePassed / (double)Len));
}
for(int j = 0; j < 2; j++)
if(fabs(RenderDiff[j]) < 0.01f && fabs(PredDiff[j]) < 0.01f && fabs(m_aClients[i].m_PrevPredicted.m_Pos[j] - m_aClients[i].m_Predicted.m_Pos[j]) < 0.01f && aMixAmount[j] > aMixAmount[j ^ 1])
if(absolute(RenderDiff[j]) < 0.01f && absolute(PredDiff[j]) < 0.01f && absolute(m_aClients[i].m_PrevPredicted.m_Pos[j] - m_aClients[i].m_Predicted.m_Pos[j]) < 0.01f && aMixAmount[j] > aMixAmount[j ^ 1])
aMixAmount[j] = aMixAmount[j ^ 1];
for(int j = 0; j < 2; j++)
{
@ -2379,7 +2379,7 @@ void CGameClient::UpdatePrediction()
}
// advance the gameworld to the current gametick
if(pLocalChar && abs(m_GameWorld.GameTick() - Client()->GameTick(g_Config.m_ClDummy)) < SERVER_TICK_SPEED)
if(pLocalChar && absolute(m_GameWorld.GameTick() - Client()->GameTick(g_Config.m_ClDummy)) < SERVER_TICK_SPEED)
{
for(int Tick = m_GameWorld.GameTick() + 1; Tick <= Client()->GameTick(g_Config.m_ClDummy); Tick++)
{
@ -2512,7 +2512,7 @@ void CGameClient::DetectStrongHook()
int ToPlayer = m_Snap.m_aCharacters[FromPlayer].m_Prev.m_HookedPlayer;
if(ToPlayer < 0 || ToPlayer >= MAX_CLIENTS || !m_Snap.m_aCharacters[ToPlayer].m_Active || ToPlayer != m_Snap.m_aCharacters[FromPlayer].m_Cur.m_HookedPlayer)
continue;
if(abs(minimum(s_aLastUpdateTick[ToPlayer], s_aLastUpdateTick[FromPlayer]) - Client()->GameTick(g_Config.m_ClDummy)) < SERVER_TICK_SPEED / 4)
if(absolute(minimum(s_aLastUpdateTick[ToPlayer], s_aLastUpdateTick[FromPlayer]) - Client()->GameTick(g_Config.m_ClDummy)) < SERVER_TICK_SPEED / 4)
continue;
if(m_Snap.m_aCharacters[FromPlayer].m_Prev.m_Direction != m_Snap.m_aCharacters[FromPlayer].m_Cur.m_Direction || m_Snap.m_aCharacters[ToPlayer].m_Prev.m_Direction != m_Snap.m_aCharacters[ToPlayer].m_Cur.m_Direction)
continue;
@ -2597,7 +2597,7 @@ vec2 CGameClient::GetSmoothPos(int ClientID)
int64_t TimePassed = Now - m_aClients[ClientID].m_aSmoothStart[i];
if(in_range(TimePassed, (int64_t)0, Len - 1))
{
float MixAmount = 1.f - powf(1.f - TimePassed / (float)Len, 1.2f);
float MixAmount = 1.f - std::pow(1.f - TimePassed / (float)Len, 1.2f);
int SmoothTick;
float SmoothIntra;
Client()->GetSmoothTick(&SmoothTick, &SmoothIntra, MixAmount);

View file

@ -402,7 +402,7 @@ void CCharacter::FireWeapon()
WEAPON_SHOTGUN, //Type
GetCID(), //Owner
ProjStartPos, //Pos
vec2(cosf(a), sinf(a)) * Speed, //Dir
direction(a) * Speed, //Dir
(int)(GameWorld()->GameTickSpeed() * Tuning()->m_ShotgunLifetime), //Span
false, //Freeze
false, //Explosive
@ -643,36 +643,36 @@ void CCharacter::HandleSkippableTiles(int Index)
if(MaxSpeed > 0)
{
if(Direction.x > 0.0000001f)
SpeederAngle = -atan(Direction.y / Direction.x);
SpeederAngle = -std::atan(Direction.y / Direction.x);
else if(Direction.x < 0.0000001f)
SpeederAngle = atan(Direction.y / Direction.x) + 2.0f * asin(1.0f);
SpeederAngle = std::atan(Direction.y / Direction.x) + 2.0f * std::asin(1.0f);
else if(Direction.y > 0.0000001f)
SpeederAngle = asin(1.0f);
SpeederAngle = std::asin(1.0f);
else
SpeederAngle = asin(-1.0f);
SpeederAngle = std::asin(-1.0f);
if(SpeederAngle < 0)
SpeederAngle = 4.0f * asin(1.0f) + SpeederAngle;
SpeederAngle = 4.0f * std::asin(1.0f) + SpeederAngle;
if(TempVel.x > 0.0000001f)
TeeAngle = -atan(TempVel.y / TempVel.x);
TeeAngle = -std::atan(TempVel.y / TempVel.x);
else if(TempVel.x < 0.0000001f)
TeeAngle = atan(TempVel.y / TempVel.x) + 2.0f * asin(1.0f);
TeeAngle = std::atan(TempVel.y / TempVel.x) + 2.0f * std::asin(1.0f);
else if(TempVel.y > 0.0000001f)
TeeAngle = asin(1.0f);
TeeAngle = std::asin(1.0f);
else
TeeAngle = asin(-1.0f);
TeeAngle = std::asin(-1.0f);
if(TeeAngle < 0)
TeeAngle = 4.0f * asin(1.0f) + TeeAngle;
TeeAngle = 4.0f * std::asin(1.0f) + TeeAngle;
TeeSpeed = sqrt(pow(TempVel.x, 2) + pow(TempVel.y, 2));
TeeSpeed = std::sqrt(std::pow(TempVel.x, 2) + std::pow(TempVel.y, 2));
DiffAngle = SpeederAngle - TeeAngle;
SpeedLeft = MaxSpeed / 5.0f - cos(DiffAngle) * TeeSpeed;
if(abs((int)SpeedLeft) > Force && SpeedLeft > 0.0000001f)
SpeedLeft = MaxSpeed / 5.0f - std::cos(DiffAngle) * TeeSpeed;
if(absolute((int)SpeedLeft) > Force && SpeedLeft > 0.0000001f)
TempVel += Direction * Force;
else if(abs((int)SpeedLeft) > Force)
else if(absolute((int)SpeedLeft) > Force)
TempVel += Direction * -Force;
else
TempVel += Direction * SpeedLeft;
@ -1334,8 +1334,8 @@ void CCharacter::Read(CNetObj_Character *pChar, CNetObj_DDNetCharacter *pExtende
}
else
{
m_Input.m_TargetX = m_SavedInput.m_TargetX = cosf(pChar->m_Angle / 256.0f) * 256.0f;
m_Input.m_TargetY = m_SavedInput.m_TargetY = sinf(pChar->m_Angle / 256.0f) * 256.0f;
m_Input.m_TargetX = m_SavedInput.m_TargetX = std::cos(pChar->m_Angle / 256.0f) * 256.0f;
m_Input.m_TargetY = m_SavedInput.m_TargetY = std::sin(pChar->m_Angle / 256.0f) * 256.0f;
}
}

View file

@ -122,9 +122,9 @@ void CProjectile::Tick()
m_Direction.x = -m_Direction.x;
else if(m_Bouncing == 2)
m_Direction.y = -m_Direction.y;
if(fabs(m_Direction.x) < 1e-6f)
if(absolute(m_Direction.x) < 1e-6f)
m_Direction.x = 0;
if(fabs(m_Direction.y) < 1e-6f)
if(absolute(m_Direction.y) < 1e-6f)
m_Direction.y = 0;
m_Pos += m_Direction;
}
@ -172,7 +172,7 @@ CProjectile::CProjectile(CGameWorld *pGameWorld, int ID, CProjectileData *pProj,
m_Owner = -1;
m_Bouncing = 0;
m_Freeze = false;
m_Explosive = (pProj->m_Type == WEAPON_GRENADE) && (fabs(1.0f - length(m_Direction)) < 0.015f);
m_Explosive = (pProj->m_Type == WEAPON_GRENADE) && (absolute(1.0f - length(m_Direction)) < 0.015f);
}
m_Type = pProj->m_Type;
m_StartTick = pProj->m_StartTick;

View file

@ -421,7 +421,7 @@ void CGameWorld::NetObjAdd(int ObjID, int ObjType, const void *pObjData, const C
}
CProjectile NetProj = CProjectile(this, ObjID, &Data, pDataEx);
if(NetProj.m_Type != WEAPON_SHOTGUN && fabs(length(NetProj.m_Direction) - 1.f) > 0.02f) // workaround to skip grenades on ball mod
if(NetProj.m_Type != WEAPON_SHOTGUN && absolute(length(NetProj.m_Direction) - 1.f) > 0.02f) // workaround to skip grenades on ball mod
return;
if(CProjectile *pProj = (CProjectile *)GetEntity(ObjID, ENTTYPE_PROJECTILE))

View file

@ -43,8 +43,8 @@ CProjectileData ExtractProjectileInfoDDNet(const CNetObj_DDNetProjectile *pProj,
Result.m_StartPos.x = pProj->m_X / 100.0f;
Result.m_StartPos.y = pProj->m_Y / 100.0f;
float Angle = pProj->m_Angle / 1000000.0f;
Result.m_StartVel.x = sin(-Angle);
Result.m_StartVel.y = cos(-Angle);
Result.m_StartVel.x = std::sin(-Angle);
Result.m_StartVel.y = std::cos(-Angle);
Result.m_Type = pProj->m_Type;
Result.m_StartTick = pProj->m_StartTick;

View file

@ -111,7 +111,7 @@ void CRenderTools::GetSpriteScale(int Id, float &ScaleX, float &ScaleY)
void CRenderTools::GetSpriteScaleImpl(int Width, int Height, float &ScaleX, float &ScaleY)
{
float f = sqrtf(Height * Height + Width * Width);
const float f = length(vec2(Width, Height));
ScaleX = Width / f;
ScaleY = Height / f;
}
@ -381,7 +381,7 @@ void CRenderTools::CalcScreenParams(float Aspect, float Zoom, float *pWidth, flo
const float WMax = 1500;
const float HMax = 1050;
float f = sqrtf(Amount) / sqrtf(Aspect);
const float f = std::sqrt(Amount) / std::sqrt(Aspect);
*pWidth = f * Aspect;
*pHeight = f;

View file

@ -86,8 +86,8 @@ static void Rotate(CPoint *pCenter, CPoint *pPoint, float Rotation)
{
int x = pPoint->x - pCenter->x;
int y = pPoint->y - pCenter->y;
pPoint->x = (int)(x * cosf(Rotation) - y * sinf(Rotation) + pCenter->x);
pPoint->y = (int)(x * sinf(Rotation) + y * cosf(Rotation) + pCenter->y);
pPoint->x = (int)(x * std::cos(Rotation) - y * std::sin(Rotation) + pCenter->x);
pPoint->y = (int)(x * std::sin(Rotation) + y * std::cos(Rotation) + pCenter->y);
}
void CRenderTools::RenderQuads(CQuad *pQuads, int NumQuads, int RenderFlags, ENVELOPE_EVAL pfnEval, void *pUser)

View file

@ -67,7 +67,7 @@ public:
Min += m_MinAdjustment;
Max += m_MinAdjustment;
}
return (log(AbsoluteValue) - log(Min)) / (float)(log(Max) - log(Min));
return (std::log(AbsoluteValue) - std::log(Min)) / (float)(std::log(Max) - std::log(Min));
}
int ToAbsolute(float RelativeValue, int Min, int Max) const override
{
@ -78,7 +78,7 @@ public:
Max += m_MinAdjustment;
ResultAdjustment = -m_MinAdjustment;
}
return round_to_int(exp(RelativeValue * (log(Max) - log(Min)) + log(Min))) + ResultAdjustment;
return round_to_int(std::exp(RelativeValue * (std::log(Max) - std::log(Min)) + std::log(Min))) + ResultAdjustment;
}
};

View file

@ -112,7 +112,7 @@ void CScrollRegion::End()
if(m_AnimTime > 0.0f)
{
m_AnimTime -= Client()->RenderFrameTime();
float AnimProgress = (1.0f - powf(m_AnimTime / m_AnimTimeMax, 3.0f)); // cubic ease out
float AnimProgress = (1.0f - std::pow(m_AnimTime / m_AnimTimeMax, 3.0f)); // cubic ease out
m_ScrollY = m_AnimInitScrollY + (m_AnimTargetScrollY - m_AnimInitScrollY) * AnimProgress;
}
else
@ -174,7 +174,7 @@ bool CScrollRegion::AddRect(const CUIRect &Rect, bool ShouldScrollHere)
{
m_LastAddedRect = Rect;
// Round up and add 1 to fix pixel clipping at the end of the scrolling area
m_ContentH = maximum(ceilf(Rect.y + Rect.h - (m_ClipRect.y + m_ContentScrollOff.y)) + 1.0f, m_ContentH);
m_ContentH = maximum(std::ceil(Rect.y + Rect.h - (m_ClipRect.y + m_ContentScrollOff.y)) + 1.0f, m_ContentH);
if(ShouldScrollHere)
ScrollHere();
return !IsRectClipped(Rect);

View file

@ -724,7 +724,7 @@ void CCollision::GetSpeedup(int Index, vec2 *pDir, int *pForce, int *pMaxSpeed)
return;
float Angle = m_pSpeedup[Index].m_Angle * (pi / 180.0f);
*pForce = m_pSpeedup[Index].m_Force;
*pDir = vec2(cos(Angle), sin(Angle));
*pDir = direction(Angle);
if(pMaxSpeed)
*pMaxSpeed = m_pSpeedup[Index].m_MaxSpeed;
}
@ -993,7 +993,7 @@ int CCollision::GetIndex(vec2 PrevPos, vec2 Pos) const
}
}
for(int i = 0, id = (int)ceilf(Distance); i < id; i++)
for(int i = 0, id = std::ceil(Distance); i < id; i++)
{
float a = (float)i / Distance;
vec2 Tmp = mix(PrevPos, Pos, a);
@ -1126,7 +1126,7 @@ void ThroughOffset(vec2 Pos0, vec2 Pos1, int *pOffsetX, int *pOffsetY)
{
float x = Pos0.x - Pos1.x;
float y = Pos0.y - Pos1.y;
if(fabs(x) > fabs(y))
if(absolute(x) > absolute(y))
{
if(x < 0)
{
@ -1159,7 +1159,7 @@ int CCollision::IntersectNoLaser(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2
float d = distance(Pos0, Pos1);
vec2 Last = Pos0;
for(int i = 0, id = (int)ceilf(d); i < id; i++)
for(int i = 0, id = std::ceil(d); i < id; i++)
{
float a = (int)i / d;
vec2 Pos = mix(Pos0, Pos1, a);
@ -1190,7 +1190,7 @@ int CCollision::IntersectNoLaserNW(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, ve
float d = distance(Pos0, Pos1);
vec2 Last = Pos0;
for(int i = 0, id = (int)ceilf(d); i < id; i++)
for(int i = 0, id = std::ceil(d); i < id; i++)
{
float a = (float)i / d;
vec2 Pos = mix(Pos0, Pos1, a);
@ -1219,7 +1219,7 @@ int CCollision::IntersectAir(vec2 Pos0, vec2 Pos1, vec2 *pOutCollision, vec2 *pO
float d = distance(Pos0, Pos1);
vec2 Last = Pos0;
for(int i = 0, id = (int)ceilf(d); i < id; i++)
for(int i = 0, id = std::ceil(d); i < id; i++)
{
float a = (float)i / d;
vec2 Pos = mix(Pos0, Pos1, a);

View file

@ -630,7 +630,7 @@ int CEditor::UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, in
if(absolute(s_Value) >= Scale)
{
int Count = (int)(s_Value / Scale);
s_Value = fmod(s_Value, Scale);
s_Value = std::fmod(s_Value, Scale);
Current += Step * Count;
Current = clamp(Current, Min, Max);
@ -638,7 +638,7 @@ int CEditor::UiDoValueSelector(void *pID, CUIRect *pRect, const char *pLabel, in
if(Count > 0)
Current = Current / Step * Step;
else
Current = round_ceil(Current / (float)Step) * Step;
Current = std::ceil(Current / (float)Step) * Step;
}
}
if(pToolTip && !s_TextMode)
@ -1282,8 +1282,8 @@ static void Rotate(const CPoint *pCenter, CPoint *pPoint, float Rotation)
{
int x = pPoint->x - pCenter->x;
int y = pPoint->y - pCenter->y;
pPoint->x = (int)(x * cosf(Rotation) - y * sinf(Rotation) + pCenter->x);
pPoint->y = (int)(x * sinf(Rotation) + y * cosf(Rotation) + pCenter->y);
pPoint->x = (int)(x * std::cos(Rotation) - y * std::sin(Rotation) + pCenter->x);
pPoint->y = (int)(x * std::sin(Rotation) + y * std::cos(Rotation) + pCenter->y);
}
void CEditor::DoSoundSource(CSoundSource *pSource, int Index)
@ -1780,7 +1780,7 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V)
float CEditor::TriangleArea(vec2 A, vec2 B, vec2 C)
{
return abs(((B.x - A.x) * (C.y - A.y) - (C.x - A.x) * (B.y - A.y)) * 0.5f);
return absolute(((B.x - A.x) * (C.y - A.y) - (C.x - A.x) * (B.y - A.y)) * 0.5f);
}
bool CEditor::IsInTriangle(vec2 Point, vec2 A, vec2 B, vec2 C)
@ -1801,7 +1801,7 @@ bool CEditor::IsInTriangle(vec2 Point, vec2 A, vec2 B, vec2 C)
Point = (Point - Min) * Normal;
float Area = TriangleArea(A, B, C);
return Area > 0.f && abs(TriangleArea(Point, A, B) + TriangleArea(Point, B, C) + TriangleArea(Point, C, A) - Area) < 0.000001f;
return Area > 0.f && absolute(TriangleArea(Point, A, B) + TriangleArea(Point, B, C) + TriangleArea(Point, C, A) - Area) < 0.000001f;
}
void CEditor::DoQuadKnife(int QuadIndex)
@ -1833,7 +1833,7 @@ void CEditor::DoQuadKnife(int QuadIndex)
if(m_GridActive && !IgnoreGrid)
{
float CellSize = (float)GetLineDistance();
vec2 OnGrid = vec2(roundf(Mouse.x / CellSize) * CellSize, roundf(Mouse.y / CellSize) * CellSize);
vec2 OnGrid = vec2(std::round(Mouse.x / CellSize) * CellSize, std::round(Mouse.y / CellSize) * CellSize);
if(IsInTriangle(OnGrid, v[0], v[1], v[2]) || IsInTriangle(OnGrid, v[0], v[3], v[2]))
Point = OnGrid;
@ -1850,7 +1850,7 @@ void CEditor::DoQuadKnife(int QuadIndex)
if(in_range(OnGrid.y, Min.y, Max.y) && Max.y - Min.y > 0.0000001f)
{
vec2 OnEdge(v[i].x + (OnGrid.y - v[i].y) / (v[j].y - v[i].y) * (v[j].x - v[i].x), OnGrid.y);
float Distance = abs(OnGrid.x - OnEdge.x);
float Distance = absolute(OnGrid.x - OnEdge.x);
if(Distance < CellSize && (Distance < MinDistance || MinDistance < 0.f))
{
@ -1862,7 +1862,7 @@ void CEditor::DoQuadKnife(int QuadIndex)
if(in_range(OnGrid.x, Min.x, Max.x) && Max.x - Min.x > 0.0000001f)
{
vec2 OnEdge(OnGrid.x, v[i].y + (OnGrid.x - v[i].x) / (v[j].x - v[i].x) * (v[j].y - v[i].y));
float Distance = abs(OnGrid.y - OnEdge.y);
float Distance = absolute(OnGrid.y - OnEdge.y);
if(Distance < CellSize && (Distance < MinDistance || MinDistance < 0.f))
{
@ -1950,13 +1950,13 @@ void CEditor::DoQuadKnife(int QuadIndex)
float WeightB = TriangleArea(m_aQuadKnifePoints[i], C, A) / TriArea;
float WeightC = TriangleArea(m_aQuadKnifePoints[i], A, B) / TriArea;
pResult->m_aColors[i].r = (int)round(pQuad->m_aColors[0].r * WeightA + pQuad->m_aColors[3].r * WeightB + pQuad->m_aColors[t].r * WeightC);
pResult->m_aColors[i].g = (int)round(pQuad->m_aColors[0].g * WeightA + pQuad->m_aColors[3].g * WeightB + pQuad->m_aColors[t].g * WeightC);
pResult->m_aColors[i].b = (int)round(pQuad->m_aColors[0].b * WeightA + pQuad->m_aColors[3].b * WeightB + pQuad->m_aColors[t].b * WeightC);
pResult->m_aColors[i].a = (int)round(pQuad->m_aColors[0].a * WeightA + pQuad->m_aColors[3].a * WeightB + pQuad->m_aColors[t].a * WeightC);
pResult->m_aColors[i].r = (int)std::round(pQuad->m_aColors[0].r * WeightA + pQuad->m_aColors[3].r * WeightB + pQuad->m_aColors[t].r * WeightC);
pResult->m_aColors[i].g = (int)std::round(pQuad->m_aColors[0].g * WeightA + pQuad->m_aColors[3].g * WeightB + pQuad->m_aColors[t].g * WeightC);
pResult->m_aColors[i].b = (int)std::round(pQuad->m_aColors[0].b * WeightA + pQuad->m_aColors[3].b * WeightB + pQuad->m_aColors[t].b * WeightC);
pResult->m_aColors[i].a = (int)std::round(pQuad->m_aColors[0].a * WeightA + pQuad->m_aColors[3].a * WeightB + pQuad->m_aColors[t].a * WeightC);
pResult->m_aTexcoords[i].x = (int)round(pQuad->m_aTexcoords[0].x * WeightA + pQuad->m_aTexcoords[3].x * WeightB + pQuad->m_aTexcoords[t].x * WeightC);
pResult->m_aTexcoords[i].y = (int)round(pQuad->m_aTexcoords[0].y * WeightA + pQuad->m_aTexcoords[3].y * WeightB + pQuad->m_aTexcoords[t].y * WeightC);
pResult->m_aTexcoords[i].x = (int)std::round(pQuad->m_aTexcoords[0].x * WeightA + pQuad->m_aTexcoords[3].x * WeightB + pQuad->m_aTexcoords[t].x * WeightC);
pResult->m_aTexcoords[i].y = (int)std::round(pQuad->m_aTexcoords[0].y * WeightA + pQuad->m_aTexcoords[3].y * WeightB + pQuad->m_aTexcoords[t].y * WeightC);
pResult->m_aPoints[i].x = f2fx(m_aQuadKnifePoints[i].x);
pResult->m_aPoints[i].y = f2fx(m_aQuadKnifePoints[i].y);
@ -3034,7 +3034,7 @@ int CEditor::DoProperties(CUIRect *pToolBox, CProperty *pProps, int *pIDs, int *
int NewValue = UiDoValueSelector(&pIDs[i], &Shifter, "", Value, pProps[i].m_Min, pProps[i].m_Max, Shift ? 1 : 45, Shift ? 1.0f : 10.0f, "Use left mouse button to drag and change the value. Hold shift to be more precise. Rightclick to edit as text.", false, false, 0);
if(DoButton_ButtonDec(&pIDs[i] + 1, nullptr, 0, &Dec, 0, "Decrease"))
{
NewValue = (round_ceil((pProps[i].m_Value / (float)Step)) - 1) * Step;
NewValue = (std::ceil((pProps[i].m_Value / (float)Step)) - 1) * Step;
if(NewValue < 0)
NewValue += 360;
}

View file

@ -180,8 +180,8 @@ void Rotate(vec2 *pCenter, vec2 *pPoint, float Rotation)
{
float x = pPoint->x - pCenter->x;
float y = pPoint->y - pCenter->y;
pPoint->x = x * cosf(Rotation) - y * sinf(Rotation) + pCenter->x;
pPoint->y = x * sinf(Rotation) + y * cosf(Rotation) + pCenter->y;
pPoint->x = x * std::cos(Rotation) - y * std::sin(Rotation) + pCenter->x;
pPoint->y = x * std::sin(Rotation) + y * std::cos(Rotation) + pCenter->y;
}
void CLayerQuads::BrushRotate(float Amount)

View file

@ -80,7 +80,7 @@ float VelocityRamp(float Value, float Start, float Range, float Curvature)
{
if(Value < Start)
return 1.0f;
return 1.0f / powf(Curvature, (Value - Start) / Range);
return 1.0f / std::pow(Curvature, (Value - Start) / Range);
}
void CCharacterCore::Init(CWorldCore *pWorld, CCollision *pCollision, CTeamsCore *pTeams, std::map<int, std::vector<vec2>> *pTeleOuts)

View file

@ -1,7 +1,7 @@
#ifndef GAME_PRNG_H
#define GAME_PRNG_H
#include <stdint.h>
#include <cstdint>
class CPrng
{

View file

@ -1330,36 +1330,36 @@ void CCharacter::HandleSkippableTiles(int Index)
if(MaxSpeed > 0)
{
if(Direction.x > 0.0000001f)
SpeederAngle = -atan(Direction.y / Direction.x);
SpeederAngle = -std::atan(Direction.y / Direction.x);
else if(Direction.x < 0.0000001f)
SpeederAngle = atan(Direction.y / Direction.x) + 2.0f * asin(1.0f);
SpeederAngle = std::atan(Direction.y / Direction.x) + 2.0f * std::asin(1.0f);
else if(Direction.y > 0.0000001f)
SpeederAngle = asin(1.0f);
SpeederAngle = std::asin(1.0f);
else
SpeederAngle = asin(-1.0f);
SpeederAngle = std::asin(-1.0f);
if(SpeederAngle < 0)
SpeederAngle = 4.0f * asin(1.0f) + SpeederAngle;
SpeederAngle = 4.0f * std::asin(1.0f) + SpeederAngle;
if(TempVel.x > 0.0000001f)
TeeAngle = -atan(TempVel.y / TempVel.x);
TeeAngle = -std::atan(TempVel.y / TempVel.x);
else if(TempVel.x < 0.0000001f)
TeeAngle = atan(TempVel.y / TempVel.x) + 2.0f * asin(1.0f);
TeeAngle = std::atan(TempVel.y / TempVel.x) + 2.0f * std::asin(1.0f);
else if(TempVel.y > 0.0000001f)
TeeAngle = asin(1.0f);
TeeAngle = std::asin(1.0f);
else
TeeAngle = asin(-1.0f);
TeeAngle = std::asin(-1.0f);
if(TeeAngle < 0)
TeeAngle = 4.0f * asin(1.0f) + TeeAngle;
TeeAngle = 4.0f * std::asin(1.0f) + TeeAngle;
TeeSpeed = sqrt(pow(TempVel.x, 2) + pow(TempVel.y, 2));
TeeSpeed = std::sqrt(std::pow(TempVel.x, 2) + std::pow(TempVel.y, 2));
DiffAngle = SpeederAngle - TeeAngle;
SpeedLeft = MaxSpeed / 5.0f - cos(DiffAngle) * TeeSpeed;
if(abs((int)SpeedLeft) > Force && SpeedLeft > 0.0000001f)
SpeedLeft = MaxSpeed / 5.0f - std::cos(DiffAngle) * TeeSpeed;
if(absolute((int)SpeedLeft) > Force && SpeedLeft > 0.0000001f)
TempVel += Direction * Force;
else if(abs((int)SpeedLeft) > Force)
else if(absolute((int)SpeedLeft) > Force)
TempVel += Direction * -Force;
else
TempVel += Direction * SpeedLeft;

View file

@ -16,7 +16,7 @@ CDoor::CDoor(CGameWorld *pGameWorld, vec2 Pos, float Rotation, int Length,
m_Number = Number;
m_Pos = Pos;
m_Length = Length;
m_Direction = vec2(sin(Rotation), cos(Rotation));
m_Direction = vec2(std::sin(Rotation), std::cos(Rotation));
vec2 To = Pos + normalize(m_Direction) * m_Length;
GameServer()->Collision()->IntersectNoLaser(Pos, To, &this->m_To, 0);

View file

@ -71,7 +71,7 @@ void CLight::Move()
void CLight::Step()
{
Move();
vec2 dir(sin(m_Rotation), cos(m_Rotation));
vec2 dir(std::sin(m_Rotation), std::cos(m_Rotation));
vec2 to2 = m_Pos + normalize(dir) * m_CurveLength;
GameServer()->Collision()->IntersectNoLaser(m_Pos, to2, &m_To, 0);
}

View file

@ -225,9 +225,9 @@ void CProjectile::Tick()
m_Direction.x = -m_Direction.x;
else if(m_Bouncing == 2)
m_Direction.y = -m_Direction.y;
if(fabs(m_Direction.x) < 1e-6f)
if(absolute(m_Direction.x) < 1e-6f)
m_Direction.x = 0;
if(fabs(m_Direction.y) < 1e-6f)
if(absolute(m_Direction.y) < 1e-6f)
m_Direction.y = 0;
m_Pos += m_Direction;
}
@ -374,7 +374,7 @@ void CProjectile::SetBouncing(int Value)
bool CProjectile::FillExtraInfo(CNetObj_DDNetProjectile *pProj)
{
const int MaxPos = 0x7fffffff / 100;
if(abs((int)m_Pos.y) + 1 >= MaxPos || abs((int)m_Pos.x) + 1 >= MaxPos)
if(absolute((int)m_Pos.y) + 1 >= MaxPos || absolute((int)m_Pos.x) + 1 >= MaxPos)
{
//If the modified data would be too large to fit in an integer, send normal data instead
return false;
@ -383,7 +383,7 @@ bool CProjectile::FillExtraInfo(CNetObj_DDNetProjectile *pProj)
float Angle = -atan2f(m_Direction.x, m_Direction.y);
int Data = 0;
Data |= (abs(m_Owner) & 255) << 0;
Data |= (absolute(m_Owner) & 255) << 0;
if(m_Owner < 0)
Data |= PROJECTILEFLAG_NO_OWNER;
//This bit tells the client to use the extra info

View file

@ -3,7 +3,7 @@
#ifndef GAME_SERVER_EVENTHANDLER_H
#define GAME_SERVER_EVENTHANDLER_H
#include <stdint.h>
#include <cstdint>
#include <engine/shared/protocol.h>

View file

@ -2689,7 +2689,7 @@ void CGameContext::ConToggleTuneParam(IConsole::IResult *pResult, void *pUserDat
return;
}
float NewValue = fabs(OldValue - pResult->GetFloat(1)) < 0.0001f ? pResult->GetFloat(2) : pResult->GetFloat(1);
float NewValue = absolute(OldValue - pResult->GetFloat(1)) < 0.0001f ? pResult->GetFloat(2) : pResult->GetFloat(1);
pSelf->Tuning()->Set(pParamName, NewValue);
pSelf->Tuning()->Get(pParamName, &NewValue);

View file

@ -227,7 +227,7 @@ bool IGameController::OnEntity(int Index, int x, int y, int Layer, int Flags, bo
WEAPON_SHOTGUN, //Type
-1, //Owner
Pos, //Pos
vec2(sin(Deg), cos(Deg)), //Dir
vec2(std::sin(Deg), std::cos(Deg)), //Dir
-2, //Span
true, //Freeze
true, //Explosive
@ -253,7 +253,7 @@ bool IGameController::OnEntity(int Index, int x, int y, int Layer, int Flags, bo
WEAPON_SHOTGUN, //Type
-1, //Owner
Pos, //Pos
vec2(sin(Deg), cos(Deg)), //Dir
vec2(std::sin(Deg), std::cos(Deg)), //Dir
-2, //Span
true, //Freeze
false, //Explosive

View file

@ -337,7 +337,7 @@ void CPlayer::Snap(int SnappingClient)
int SnappingClientVersion = GameServer()->GetClientVersion(SnappingClient);
int Latency = SnappingClient == SERVER_DEMO_CLIENT ? m_Latency.m_Min : GameServer()->m_apPlayers[SnappingClient]->m_aCurLatency[m_ClientID];
int Score = abs(m_Score) * -1;
int Score = absolute(m_Score) * -1;
// send 0 if times of others are not shown
if(SnappingClient != m_ClientID && g_Config.m_SvHideScore)

View file

@ -17,7 +17,7 @@ void CSaveTee::Save(CCharacter *pChr)
str_copy(m_aName, pChr->Server()->ClientName(m_ClientID), sizeof(m_aName));
m_Alive = pChr->m_Alive;
m_Paused = abs(pChr->m_pPlayer->IsPaused());
m_Paused = absolute(pChr->m_pPlayer->IsPaused());
m_NeededFaketuning = pChr->m_NeededFaketuning;
m_TeeStarted = pChr->Teams()->TeeStarted(m_ClientID);

View file

@ -914,7 +914,7 @@ bool CScoreWorker::ShowTop(IDbConnection *pSqlServer, const ISqlData *pGameData,
const auto *pData = dynamic_cast<const CSqlPlayerRequest *>(pGameData);
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
int LimitStart = maximum(abs(pData->m_Offset) - 1, 0);
int LimitStart = maximum(absolute(pData->m_Offset) - 1, 0);
const char *pOrder = pData->m_Offset >= 0 ? "ASC" : "DESC";
const char *pAny = "%";
@ -1002,7 +1002,7 @@ bool CScoreWorker::ShowTeamTop5(IDbConnection *pSqlServer, const ISqlData *pGame
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
auto *paMessages = pResult->m_Data.m_aaMessages;
int LimitStart = maximum(abs(pData->m_Offset) - 1, 0);
int LimitStart = maximum(absolute(pData->m_Offset) - 1, 0);
const char *pOrder = pData->m_Offset >= 0 ? "ASC" : "DESC";
// check sort method
@ -1089,7 +1089,7 @@ bool CScoreWorker::ShowPlayerTeamTop5(IDbConnection *pSqlServer, const ISqlData
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
auto *paMessages = pResult->m_Data.m_aaMessages;
int LimitStart = maximum(abs(pData->m_Offset) - 1, 0);
int LimitStart = maximum(absolute(pData->m_Offset) - 1, 0);
const char *pOrder = pData->m_Offset >= 0 ? "ASC" : "DESC";
// check sort method
@ -1181,7 +1181,7 @@ bool CScoreWorker::ShowTimes(IDbConnection *pSqlServer, const ISqlData *pGameDat
auto *pResult = dynamic_cast<CScorePlayerResult *>(pGameData->m_pResult.get());
auto *paMessages = pResult->m_Data.m_aaMessages;
int LimitStart = maximum(abs(pData->m_Offset) - 1, 0);
int LimitStart = maximum(absolute(pData->m_Offset) - 1, 0);
const char *pOrder = pData->m_Offset >= 0 ? "DESC" : "ASC";
char aCurrentTimestamp[512];

View file

@ -680,7 +680,7 @@ void CGameTeams::OnFinish(CPlayer *Player, float Time, const char *pTimestamp)
else
GameServer()->SendChat(-1, CGameContext::CHAT_ALL, aBuf, -1., CGameContext::CHAT_SIX);
float Diff = fabs(Time - pData->m_BestTime);
float Diff = absolute(Time - pData->m_BestTime);
if(Time - pData->m_BestTime < 0)
{

View file

@ -6,7 +6,7 @@
#include <engine/shared/protocol.h>
#include <game/generated/protocol.h>
#include <time.h>
#include <ctime>
class CConfig;
class CTuningParams;

View file

@ -3,7 +3,7 @@
#include <base/dynamic.h>
#include <stdint.h>
#include <cstdint>
#ifndef STEAMAPI
#define STEAMAPI DYNAMIC_IMPORT

View file

@ -17,7 +17,7 @@ TEST(Color, HRHConv)
EXPECT_FLOAT_EQ(hsl.l, hsl2.l);
else
{
EXPECT_NEAR(fmod(hsl.h, 1.0f), fmod(hsl2.h, 1.0f), 0.001f);
EXPECT_NEAR(std::fmod(hsl.h, 1.0f), std::fmod(hsl2.h, 1.0f), 0.001f);
EXPECT_NEAR(hsl.s, hsl2.s, 0.0001f);
EXPECT_FLOAT_EQ(hsl.l, hsl2.l);
}

View file

@ -83,7 +83,7 @@ bool CreatePixelArt(const char aFilenames[3][64], const int aLayerID[2], const i
if(!pQuadLayer)
return false;
int MaxNewQuads = ceil((Img.m_Width * Img.m_Height) / aPixelSizes[0]);
int MaxNewQuads = std::ceil((Img.m_Width * Img.m_Height) / aPixelSizes[0]);
CQuad *pQuads = new CQuad[pQuadLayer->m_NumQuads + MaxNewQuads];
InsertCurrentQuads(InputMap, pQuadLayer, pQuads);

View file

@ -46,7 +46,7 @@ bool GetLayerGroupIDs(CDataFileReader &InputMap, const int LayerNumber, int &Gro
int FxToTilePos(const int FxPos)
{
return (int)floor(fx2f(FxPos) / 32);
return std::floor(fx2f(FxPos) / 32);
}
bool GetEnvelopedQuads(const CQuad *pQuads, const int NumQuads, const int EnvID, const int GroupID, const int LayerID, int &QuadsCounter, EnvelopedQuad pEnvQuads[1024])
@ -79,7 +79,7 @@ void PrintEnvelopedQuads(const EnvelopedQuad pEnvQuads[1024], const int EnvID, c
dbg_msg("map_find_env", "Found %d quads with env number #%d:", QuadsCounter, EnvID + 1);
for(int i = 0; i < QuadsCounter; i++)
dbg_msg("map_find_env", "%*d. Group: #%d - Layer: #%d - Pos: %d,%d", (int)(log10(abs(QuadsCounter))) + 1, i + 1, pEnvQuads[i].m_GroupID, pEnvQuads[i].m_LayerID, pEnvQuads[i].m_TilePosX, pEnvQuads[i].m_TilePosY);
dbg_msg("map_find_env", "%*d. Group: #%d - Layer: #%d - Pos: %d,%d", (int)(std::log10(absolute(QuadsCounter))) + 1, i + 1, pEnvQuads[i].m_GroupID, pEnvQuads[i].m_LayerID, pEnvQuads[i].m_TilePosX, pEnvQuads[i].m_TilePosY);
}
bool FindEnv(const char aFilename[64], const int EnvID)

View file

@ -618,8 +618,8 @@ void ConvertToTiles(const float aaArea[2][2], int aaTiles[2][2])
{
for(int i = 0; i < 2; i++)
{
aaTiles[i][0] = floor((floor(aaArea[i][0] * 100.0f) / 100.0f) / 32.0f);
aaTiles[i][1] = ceil((floor(aaArea[i][1] * 100.0f) / 100.0f) / 32.0f);
aaTiles[i][0] = std::floor((std::floor(aaArea[i][0] * 100.0f) / 100.0f) / 32.0f);
aaTiles[i][1] = std::ceil((std::floor(aaArea[i][1] * 100.0f) / 100.0f) / 32.0f);
}
}