Skip to content

Commit

Permalink
replace magic numbers with proper defines
Browse files Browse the repository at this point in the history
  • Loading branch information
edgyaf authored and AmyrAhmady committed Jan 9, 2024
1 parent d2b1cf2 commit 40d149a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions SDK/include/values.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions Server/Components/CustomModels/models.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/RakNet
Submodule RakNet updated 1 files
+0 −122 Source/rakserver.cpp

0 comments on commit 40d149a

Please sign in to comment.