Fix data type inconsistencies lets cook
All checks were successful
Linux arm64 / Build (push) Successful in 4m39s

This commit is contained in:
Morph01
2024-03-28 15:32:08 +01:00
parent 255eafa35e
commit 78d68446f2
22 changed files with 85 additions and 80 deletions

View File

@@ -7,7 +7,7 @@ namespace gui {
class CrossHair : public GuiWidget {
private:
int m_CrossHairTexture;
std::uint64_t m_CrossHairTexture;
public:
CrossHair(Client* client);

View File

@@ -13,8 +13,8 @@ class Hud : public GuiWidget {
/* data */
void Draw(const char* title, bool* p_open);
unsigned int m_GunTexture;
unsigned int m_JP;
std::uint64_t m_GunTexture;
std::uint64_t m_JP;
public:
Hud(GuiWidget* parent, Client* client);

View File

@@ -70,7 +70,7 @@ class VertexArray : private NonCopyable {
VertexArray(ElementBuffer&& indicies);
~VertexArray();
unsigned int GetVertexCount() const {
std::size_t GetVertexCount() const {
return m_ElementBuffer.GetTriangleCount();
}

View File

@@ -59,7 +59,7 @@ Mat4f Inverse(const Mat4f& mat) {
assert(det != 0 && "Determinant equals 0 !");
float invdet = 1.0 / det;
float invdet = 1.0f / det;
Mat4f result;

View File

@@ -14,7 +14,7 @@ static DataBuffer Inflate(const std::uint8_t* source, std::size_t size, std::siz
result.Resize(uncompressedSize);
uncompress(reinterpret_cast<Bytef*>(result.data()), reinterpret_cast<uLongf*>(&uncompressedSize),
reinterpret_cast<const Bytef*>(source), size);
reinterpret_cast<const Bytef*>(source), static_cast<uLong>(size));
assert(result.GetSize() == uncompressedSize);
return result;
@@ -25,7 +25,8 @@ static DataBuffer Deflate(const std::uint8_t* source, std::size_t size) {
uLongf compressedSize;
result.Resize(size); // Resize for the compressed data to fit into
compress(reinterpret_cast<Bytef*>(result.data()), &compressedSize, reinterpret_cast<const Bytef*>(source), size);
compress(
reinterpret_cast<Bytef*>(result.data()), &compressedSize, reinterpret_cast<const Bytef*>(source), static_cast<uLong>(size));
result.Resize(compressedSize); // Resize to cut useless data
return result;

View File

@@ -10,122 +10,126 @@ namespace utils {
/* Sine functions */
float EaseInSine(float x) {
return 1.0f - std::cos((x * maths::PI) / 2.0f);
return static_cast<float>(1.0 - std::cos((x * maths::PI) / 2.0));
}
float EaseOutSine(float x) {
return std::sin((x * maths::PI) / 2.0f);
return static_cast<float>(std::sin((x * maths::PI) / 2.0));
}
float EaseInOutSine(float x) {
return -(std::cos(maths::PI * x) - 1.0f) / 2.0f;
return static_cast<float>(-(std::cos(maths::PI * x) - 1.0) / 2.0);
}
/* Cubic functions */
float EaseInCubic(float x) {
return x * EaseInQuad(x);
return static_cast<float>(x * EaseInQuad(x));
}
float EaseOutCubic(float x) {
return 1 - std::pow(1 - x, 3);
return static_cast<float>(1 - std::pow(1 - x, 3));
}
float EaseInOutCubic(float x) {
return x < 0.5 ? 4 * EaseInCubic(x) : 1 - std::pow(-2 * x + 2, 3) / 2.0f;
return static_cast<float>(x < 0.5 ? 4 * EaseInCubic(x) : 1 - std::pow(-2 * x + 2, 3) / 2.0);
}
/* Quint functions */
float EaseInQuint(float x) {
return x * EaseInQuart(x);
return static_cast<float>(x * EaseInQuart(x));
}
float EaseOutQuint(float x) {
return 1 - std::pow(1 - x, 5);
return static_cast<float>(1 - std::pow(1 - x, 5));
}
float EaseInOutQuint(float x) {
return x < 0.5 ? 16 * EaseInQuint(x) : 1 - std::pow(-2 * x + 2, 5) / 2.0f;
return static_cast<float>(x < 0.5 ? 16 * EaseInQuint(x) : 1 - std::pow(-2 * x + 2, 5) / 2.0);
}
/* Circ functions */
float EaseInCirc(float x) {
return 1 - std::sqrt(1 - std::pow(x, 2));
return static_cast<float>(1 - std::sqrt(1 - std::pow(x, 2)));
}
float EaseOutCirc(float x) {
return std::sqrt(1 - std::pow(x - 1, 2));
return static_cast<float>(std::sqrt(1 - std::pow(x - 1, 2)));
}
float EaseInOutCirc(float x) {
return x < 0.5 ? (1 - std::sqrt(1 - std::pow(2 * x, 2))) / 2.0f : (std::sqrt(1 - std::pow(-2 * x + 2, 2)) + 1) / 2.0f;
return static_cast<float>(
x < 0.5 ? (1 - std::sqrt(1 - std::pow(2 * x, 2))) / 2.0 : (std::sqrt(1 - std::pow(-2 * x + 2, 2)) + 1) / 2.0);
}
/* Elastic functions */
float EaseInElastic(float x) {
const float c4 = (2 * maths::PI) / 3.0f;
const float c4 = (2 * maths::PI) / 3.0;
return x == 0 ? 0 : x == 1 ? 1 : -std::pow(2, 10 * x - 10) * std::sin((x * 10 - 10.75) * c4);
return static_cast<float>(x == 0 ? 0 : x == 1 ? 1 : -std::pow(2, 10 * x - 10) * std::sin((x * 10 - 10.75) * c4));
}
float EaseOutElastic(float x) {
const float c4 = (2 * maths::PI) / 3.0f;
const float c4 = (2 * maths::PI) / 3.0;
return x == 0 ? 0 : x == 1 ? 1 : std::pow(2, -10 * x) * std::sin((x * 10 - 0.75) * c4) + 1;
return static_cast<float>(x == 0 ? 0 : x == 1 ? 1 : std::pow(2, -10 * x) * std::sin((x * 10 - 0.75) * c4) + 1);
}
float EaseInOutElastic(float x) {
const float c5 = (2 * maths::PI) / 4.5;
return x == 0 ? 0
: x == 1 ? 1
: x < 0.5 ? -(std::pow(2, 20 * x - 10) * std::sin((20 * x - 11.125) * c5)) / 2.0f
: (std::pow(2, -20 * x + 10) * std::sin((20 * x - 11.125) * c5)) / 2.0f + 1;
return static_cast<float>(x == 0 ? 0
: x == 1 ? 1
: x < 0.5 ? -(std::pow(2, 20 * x - 10) * std::sin((20 * x - 11.125) * c5)) / 2.0
: (std::pow(2, -20 * x + 10) * std::sin((20 * x - 11.125) * c5)) / 2.0 + 1);
}
/* Quad functions */
float EaseInQuad(float x) {
return x * x;
return static_cast<float>(x * x);
}
float EaseOutQuad(float x) {
return 1 - (1 - x) * (1 - x);
return static_cast<float>(1 - (1 - x) * (1 - x));
}
float EaseInOutQuad(float x) {
return x < 0.5 ? 2 * x * x : 1 - std::pow(-2 * x + 2, 2) / 2.0f;
return static_cast<float>(x < 0.5 ? 2 * x * x : 1 - std::pow(-2 * x + 2, 2) / 2.0);
}
/* Quart functions */
float EaseInQuart(float x) {
return x * EaseInCubic(x);
return static_cast<float>(x * EaseInCubic(x));
}
float EaseOutQuart(float x) {
return 1 - std::pow(1 - x, 4);
return static_cast<float>(1 - std::pow(1 - x, 4));
}
float EaseInOutQuart(float x) {
return x < 0.5 ? 8 * EaseInQuart(x) : 1 - std::pow(-2 * x + 2, 4) / 2.0f;
return static_cast<float>(x < 0.5 ? 8 * EaseInQuart(x) : 1 - std::pow(-2 * x + 2, 4) / 2.0);
}
/* Expo functions */
float EaseInExpo(float x) {
return x == 0 ? 0 : std::pow(2, 10 * x - 10);
return static_cast<float>(x == 0 ? 0 : std::pow(2, 10 * x - 10));
}
float EaseOutExpo(float x) {
return x == 1 ? 1 : 1 - std::pow(2, -10 * x);
return static_cast<float>(x == 1 ? 1 : 1 - std::pow(2, -10 * x));
}
float EaseInOutExpo(float x) {
return x == 0 ? 0 : x == 1 ? 1 : x < 0.5 ? std::pow(2, 20 * x - 10) / 2.0f : (2 - std::pow(2, -20 * x + 10)) / 2.0f;
return static_cast<float>(x == 0 ? 0
: x == 1 ? 1
: x < 0.5 ? std::pow(2, 20 * x - 10) / 2.0
: (2 - std::pow(2, -20 * x + 10)) / 2.0);
}
/* Back functions */
@@ -134,28 +138,28 @@ float EaseInBack(float x) {
const float c1 = 1.70158;
const float c3 = c1 + 1;
return c3 * EaseInCubic(x) - c1 * EaseInQuad(x);
return static_cast<float>(c3 * EaseInCubic(x) - c1 * EaseInQuad(x));
}
float EaseOutBack(float x) {
const float c1 = 1.70158;
const float c3 = c1 + 1;
return 1 + c3 * std::pow(x - 1, 3) + c1 * std::pow(x - 1, 2);
return static_cast<float>(1 + c3 * std::pow(x - 1, 3) + c1 * std::pow(x - 1, 2));
}
float EaseInOutBack(float x) {
const float c1 = 1.70158;
const float c2 = c1 * 1.525;
return x < 0.5 ? (std::pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2)) / 2.0f
: (std::pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2.0f;
return static_cast<float>(x < 0.5 ? (std::pow(2 * x, 2) * ((c2 + 1) * 2 * x - c2)) / 2.0
: (std::pow(2 * x - 2, 2) * ((c2 + 1) * (x * 2 - 2) + c2) + 2) / 2.0);
}
/* Bounce functions */
float EaseInBounce(float x) {
return 1 - EaseOutBounce(1 - x);
return static_cast<float>(1 - EaseOutBounce(1 - x));
}
float EaseOutBounce(float x) {
@@ -163,21 +167,21 @@ float EaseOutBounce(float x) {
const float d1 = 2.75;
if (x < 1 / d1) {
return n1 * EaseInQuad(x);
return static_cast<float>(n1 * EaseInQuad(x));
} else if (x < 2 / d1) {
x -= 1.5;
return n1 * (x / d1) * x + 0.75;
return static_cast<float>(n1 * (x / d1) * x + 0.75);
} else if (x < 2.5 / d1) {
x -= 2.25;
return n1 * (x / d1) * x + 0.9375;
return static_cast<float>(n1 * (x / d1) * x + 0.9375);
} else {
x -= 2.625;
return n1 * (x / d1) * x + 0.984375;
return static_cast<float>(n1 * (x / d1) * x + 0.984375);
}
}
float EaseInOutBounce(float x) {
return x < 0.5 ? (1 - EaseOutBounce(1 - 2 * x)) / 2.0f : (1 + EaseOutBounce(2 * x - 1)) / 2.0f;
return static_cast<float>(x < 0.5 ? (1 - EaseOutBounce(1 - 2 * x)) / 2.0 : (1 + EaseOutBounce(2 * x - 1)) / 2.0);
}
} // namespace utils

View File

@@ -1,8 +1,6 @@
#include "blitz/misc/Log.h"
#if defined(__ANDROID__) and not defined(BLITZ_HEADLESS)
#define BLITZ_ANDROID_LOGGING
#endif
#ifdef BLITZ_ANDROID_LOGGING
#include <android/log.h>

View File

@@ -6,7 +6,7 @@ namespace blitz {
namespace utils {
void TickCounter::Reset() {
m_TPS = m_TargetTPS;
m_TPS = static_cast<float>(m_TargetTPS);
m_LastTPSTime = utils::GetTime();
m_TickCount = 0;
}

View File

@@ -11,14 +11,14 @@
namespace blitz {
namespace network {
TCPListener::TCPListener() : m_Handle(INVALID_SOCKET), m_Port(0), m_MaxConnections(0) {}
TCPListener::TCPListener() : m_Handle(static_cast<blitz::network::SocketHandle>(INVALID_SOCKET)), m_Port(0), m_MaxConnections(0) {}
TCPListener::~TCPListener() {
Destroy();
}
bool TCPListener::Listen(std::uint16_t port, int maxConnections) {
if ((m_Handle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
if ((m_Handle = static_cast<SocketHandle>(socket(AF_INET, SOCK_STREAM, IPPROTO_TCP))) < 0) {
utils::LOGE("[TCPListener] Failed to create server socket !");
return false;
}
@@ -47,8 +47,8 @@ bool TCPListener::Listen(std::uint16_t port, int maxConnections) {
bool TCPListener::Accept(TCPSocket& newSocket) {
int addrlen = sizeof(newSocket.m_RemoteAddr);
newSocket.m_Handle =
accept(m_Handle, reinterpret_cast<sockaddr*>(&newSocket.m_RemoteAddr), reinterpret_cast<socklen_t*>(&addrlen));
newSocket.m_Handle = static_cast<SocketHandle>(
accept(m_Handle, reinterpret_cast<sockaddr*>(&newSocket.m_RemoteAddr), reinterpret_cast<socklen_t*>(&addrlen)));
if (newSocket.m_Handle < 0)
return false;

View File

@@ -83,7 +83,7 @@ bool TCPSocket::Connect(const std::string& host, unsigned short port) {
return false;
}
m_Handle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
m_Handle = static_cast<SocketHandle>(socket(AF_INET, SOCK_STREAM, IPPROTO_TCP));
if (m_Handle < 0) {
utils::LOGE("[TCPSocket] Failed to create socket !");
return false;
@@ -120,7 +120,7 @@ size_t TCPSocket::Send(const unsigned char* data, size_t size) {
std::size_t sent = 0;
while (sent < size) {
int cur = send(m_Handle, reinterpret_cast<const char*>(data + sent), size - sent, 0);
int cur = send(m_Handle, reinterpret_cast<const char*>(data + sent), static_cast<int>(size - sent), 0);
if (cur <= 0) {
Disconnect();
return 0;
@@ -135,7 +135,7 @@ std::size_t TCPSocket::Receive(DataBuffer& buffer, std::size_t amount) {
buffer.Resize(amount);
buffer.SetReadOffset(0);
int recvAmount = recv(m_Handle, reinterpret_cast<char*>(buffer.data()), amount, 0);
int recvAmount = recv(m_Handle, reinterpret_cast<char*>(buffer.data()), static_cast<int>(amount), 0);
if (recvAmount <= 0) {
#if defined(_WIN32) || defined(WIN32)
int err = WSAGetLastError();

View File

@@ -83,7 +83,7 @@ ColoredText ChatPacket::ColorizeText(const std::string& text) {
static_cast<float>(std::stoul(green, nullptr, 16)) / 255.0f,
static_cast<float>(std::stoul(blue, nullptr, 16)) / 255.0f, 1.0f};
cursor += 6;
} catch (std::exception& e) {
} catch (std::exception&) {
utils::LOG("[ChatPacket] warning ! wrong color providen !");
}
break;

View File

@@ -40,7 +40,7 @@ void BlitzConfig::LoadConfig() {
jsonInput.at("keys").get_to<Keybinds>(m_Keybinds);
utils::LOG("[BlitzConfig] Restored config !");
} catch (std::exception& e) {
} catch (std::exception&) {
utils::LOGE("[BlitzConfig] Failed to load config !");
}
}

View File

@@ -218,11 +218,12 @@ void Display::InitImGui() {
ImGui_ImplOpenGL3_Init();
ImFontConfig c;
c.SizePixels = 25;
c.SizePixels = 25.0f;
ImGui::GetIO().Fonts->AddFontDefault(&c);
// doom font
DataBuffer doomFontFile = utils::AssetsManager::GetAsset("doom.ttf");
auto* doomFont = ImGui::GetIO().Fonts->AddFontFromMemoryTTF(doomFontFile.HeapAllocatedData(), doomFontFile.GetSize(), 25);
auto* doomFont =
ImGui::GetIO().Fonts->AddFontFromMemoryTTF(doomFontFile.HeapAllocatedData(), static_cast<int>(doomFontFile.GetSize()), 25.0f);
ImGui::GetIO().FontDefault = doomFont;
#ifndef __ANDROID__

View File

@@ -22,9 +22,9 @@ GameChatGui::GameChatGui(GuiWidget* parent, Client* client) : GuiWidget(parent,
void GameChatGui::Draw(const char* title, bool* p_open) {
HistoryPos = -1;
static int chat_width = 620;
static int chat_height = 450;
static int chatInput_width = 590;
static float chat_width = 620.0f;
static float chat_height = 450.0f;
static float chatInput_width = 590.0f;
ImGui::SetNextWindowPos(ImVec2(0, ImGui::GetIO().DisplaySize.y - 2 * chat_height));
ImGui::SetNextWindowSize(ImVec2(chat_width, chat_height));
// const float footer_height_to_reserve = ImGui::GetStyle().ItemSpacing.y + ImGui::GetFrameHeightWithSpacing();
@@ -60,9 +60,9 @@ void GameChatGui::Draw(const char* title, bool* p_open) {
}
void GameChatGui::DrawMini(const char* title, bool* p_open) {
static int chat_width = 620;
static int chat_height = 225;
ImGui::SetNextWindowPos(ImVec2(0, ImGui::GetIO().DisplaySize.y - 3.5 * chat_height));
static float chat_width = 620.0f;
static float chat_height = 225.0f;
ImGui::SetNextWindowPos(ImVec2(0.0f, ImGui::GetIO().DisplaySize.y - 3.5f * chat_height));
ImGui::SetNextWindowSize(ImVec2(chat_width, chat_height));
ImGui::Begin(title, p_open, GetWindowFullScreenFlags() | ImGuiWindowFlags_NoNav);
{

View File

@@ -15,8 +15,8 @@ LeaderBoard::LeaderBoard(GuiWidget* parent, Client* client) : GuiWidget(parent,
LeaderBoard::~LeaderBoard() {}
void LeaderBoard::Draw(const char* title, bool* p_open) {
static int leaderboard_width = 640;
static int leaderboard_height = 450;
static float leaderboard_width = 640.0f;
static float leaderboard_height = 450.0f;
ImGuiWindowFlags leaderboard_flags =
ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize;

View File

@@ -75,7 +75,7 @@ void OptionsMenu::HotkeyBindingPopUp() {
ImGui::SameLine();
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "%s", GetKeyActionCodeName(m_CurrentAction).c_str());
if (m_KeyPopupShouldClose && m_Timer.Update(ImGui::GetIO().DeltaTime * 1000)) {
if (m_KeyPopupShouldClose && m_Timer.Update(static_cast<std::uint64_t>(ImGui::GetIO().DeltaTime * 1000.0f))) {
m_KeyPopupShouldClose = false;
m_IsKeyPopupOpen = false;
ImGui::CloseCurrentPopup();

View File

@@ -70,7 +70,7 @@ void BulletRenderer::Render() {
for (Trail& trail : m_Trails) {
m_Shader->SetDecay(trail.m_Decay / BULLET_DECAY_TIME);
m_Shader->SetTransform(trail.m_Transform);
glDrawElements(GL_TRIANGLES, vao->GetVertexCount(), GL_UNSIGNED_INT, nullptr);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(vao->GetVertexCount()), GL_UNSIGNED_INT, nullptr);
}
vao->Unbind();
}

View File

@@ -10,8 +10,8 @@ namespace render {
static const float EyeHeight = 1.25f;
void Camera::Update(float delta) {
int windowWidth = ImGui::GetIO().DisplaySize.x;
int windowHeight = ImGui::GetIO().DisplaySize.y;
int windowWidth = static_cast<int>(ImGui::GetIO().DisplaySize.x);
int windowHeight = static_cast<int>(ImGui::GetIO().DisplaySize.y);
if (windowWidth != m_LastWindowSize.x || windowHeight != m_LastWindowSize.y) {
m_LastWindowSize = {windowWidth, windowHeight};

View File

@@ -69,14 +69,14 @@ void MainRenderer::RenderEntity(const GL::VertexArray& vao, const Vec3f& positio
m_EntityShader->Start();
m_EntityShader->SetModelTransform(maths::Dot(maths::RotateY(yaw - maths::PI / 2.0f), maths::Translate(position)));
vao.Bind();
glDrawElements(GL_TRIANGLES, vao.GetVertexCount(), GL_UNSIGNED_INT, nullptr);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(vao.GetVertexCount()), GL_UNSIGNED_INT, nullptr);
vao.Unbind();
}
void MainRenderer::RenderWorld(const GL::VertexArray& vao) {
m_WorldShader->Start();
vao.Bind();
glDrawElements(GL_TRIANGLES, vao.GetVertexCount(), GL_UNSIGNED_INT, nullptr);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(vao.GetVertexCount()), GL_UNSIGNED_INT, nullptr);
vao.Unbind();
}
@@ -129,7 +129,7 @@ void MainRenderer::RenderGun() {
for (auto& Vao : m_GunModel.mVaos) {
Vao->Bind();
glDrawElements(GL_TRIANGLES, Vao->GetVertexCount(), GL_UNSIGNED_INT, nullptr);
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(Vao->GetVertexCount()), GL_UNSIGNED_INT, nullptr);
Vao->Unbind();
}
}

View File

@@ -69,7 +69,7 @@ void VertexBuffer::BindVertexAttribs() const {
for (const VertexAttribPointer& pointer : m_VertexAttribs) {
glEnableVertexAttribArray(pointer.m_Index);
glVertexAttribPointer(pointer.m_Index, static_cast<GLint>(pointer.m_Size), GL_FLOAT, false, m_DataStride * sizeof(float),
reinterpret_cast<void*>(pointer.m_Offset));
reinterpret_cast<GLvoid*>(static_cast<std::size_t>(pointer.m_Offset)));
}
}

View File

@@ -16,7 +16,8 @@ unsigned int LoadGLTexture(const std::string& fileName) {
DataBuffer buffer = utils::AssetsManager::GetAsset(fileName.c_str());
const unsigned char* image = stbi_load_from_memory(buffer.data(), buffer.GetSize(), &width, &height, &comp, STBI_default);
const unsigned char* image =
stbi_load_from_memory(buffer.data(), static_cast<int>(buffer.GetSize()), &width, &height, &comp, STBI_default);
if (image == nullptr) {
utils::LOGE("[TextureLoader] Erreur lors du chargement de la texture !");

View File

@@ -33,7 +33,7 @@ void Server::ServerLoop() {
if (delta >= SERVER_TICK) {
Tick(delta);
lastTime = utils::GetTime();
m_TickCounter.SetMSPT(lastTime - time);
m_TickCounter.SetMSPT(static_cast<float>(lastTime - time));
std::uint64_t sleepTime = SERVER_TICK - (delta - SERVER_TICK);
std::this_thread::sleep_for(std::chrono::milliseconds(sleepTime));
}
@@ -119,7 +119,7 @@ game::PlayerID Server::GetNewPlayerID() {
}
void Server::UpdateSockets() {
static std::vector<std::int16_t> closeConnexions;
static std::vector<std::uint8_t> closeConnexions;
for (auto& connection : m_Connections) {
auto& con = connection.second;
if (con->GetSocketStatus() != network::TCPSocket::Status::Connected) {