From 40d149a3aa338575e2ddb565e179793420249306 Mon Sep 17 00:00:00 2001 From: edgyaf <136128742+edgyaf@users.noreply.github.com> Date: Tue, 9 Jan 2024 19:33:32 +0100 Subject: [PATCH] replace magic numbers with proper defines --- SDK/include/values.hpp | 4 ++++ Server/Components/CustomModels/models.cpp | 6 +++--- lib/RakNet | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/SDK/include/values.hpp b/SDK/include/values.hpp index d61659b2a..ff26f480e 100644 --- a/SDK/include/values.hpp +++ b/SDK/include/values.hpp @@ -59,6 +59,10 @@ constexpr float MIN_WORLD_BOUNDS = -20000.0f; constexpr int MAX_TEXTDRAW_STR_LENGTH = 800; constexpr int MAX_VEHICLE_CARRIAGES = 3; constexpr int MAX_GAMETEXT_STYLES = 16; +constexpr int MIN_CUSTOM_SKIN_ID = 20001; +constexpr int MAX_CUSTOM_SKIN_ID = 30000; +constexpr int MIN_CUSTOM_OBJECT_ID = -30000; +constexpr int MAX_CUSTOM_OBJECT_ID = -1000; enum Key { diff --git a/Server/Components/CustomModels/models.cpp b/Server/Components/CustomModels/models.cpp index f5e602671..23694c9ae 100644 --- a/Server/Components/CustomModels/models.cpp +++ b/Server/Components/CustomModels/models.cpp @@ -589,9 +589,9 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player return false; } - if (type == ModelType::Skin && !(id > 20000 && id <= 30000)) + if (type == ModelType::Skin && !(id >= MIN_CUSTOM_SKIN_ID && id <= MAX_CUSTOM_SKIN_ID)) return false; - else if (type == ModelType::Object && !(id >= -30000 && id <= -1000)) + else if (type == ModelType::Object && !(id >= MIN_CUSTOM_OBJECT_ID && id <= MAX_CUSTOM_OBJECT_ID)) return false; else if (baseModels.find(id) != baseModels.end()) { @@ -648,7 +648,7 @@ class CustomModelsComponent final : public ICustomModelsComponent, public Player { // Check if model is default one (base). // If so, there's no custom model to be returned. - if (baseModelIdOrInput >= 0 && baseModelIdOrInput <= 20000) + if (baseModelIdOrInput >= 0 && baseModelIdOrInput < MIN_CUSTOM_SKIN_ID) return false; // Check if input is valid custom model. diff --git a/lib/RakNet b/lib/RakNet index e04879f77..2d8588b62 160000 --- a/lib/RakNet +++ b/lib/RakNet @@ -1 +1 @@ -Subproject commit e04879f77b04a5415daa08241d2eab027c933a73 +Subproject commit 2d8588b62b9b9b4a1dc772d6c7275dc9053bbdbe