From a1abb740639634ecbcd0b72c0a06c8196447561a Mon Sep 17 00:00:00 2001 From: iAmir Date: Mon, 12 Feb 2024 17:14:50 +0330 Subject: [PATCH] change invalid weapon slot to -1 --- SDK/include/player.hpp | 4 ++-- SDK/include/values.hpp | 2 +- Server/Source/player_impl.hpp | 4 ++-- Server/Source/player_pool.hpp | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/SDK/include/player.hpp b/SDK/include/player.hpp index dd039185d..9bb0fd67b 100644 --- a/SDK/include/player.hpp +++ b/SDK/include/player.hpp @@ -326,9 +326,9 @@ struct WeaponSlotData { } - uint8_t slot() + int8_t slot() { - static const uint8_t slots[] = { + static const int8_t slots[] = { 0, // 0 - Fist 0, // 1 - Brass Knuckles 1, // 2 - Golf Club diff --git a/SDK/include/values.hpp b/SDK/include/values.hpp index ff26f480e..f48a9ba52 100644 --- a/SDK/include/values.hpp +++ b/SDK/include/values.hpp @@ -12,7 +12,7 @@ constexpr int MAX_WEAPON_SLOTS = 13; constexpr int MAX_VEHICLE_MODELS = 611 - 400 + 1; constexpr int MAX_WEAPON_ID = 46; constexpr int NUM_SKILL_LEVELS = 11; -constexpr uint8_t INVALID_WEAPON_SLOT = 0xFF; +constexpr int8_t INVALID_WEAPON_SLOT = -1; constexpr int MIN_PLAYER_NAME = 3; constexpr int MAX_PLAYER_NAME = 24; constexpr int MAX_ANIMATIONS = 1813; diff --git a/Server/Source/player_impl.hpp b/Server/Source/player_impl.hpp index 211d4bca7..f7b728652 100644 --- a/Server/Source/player_impl.hpp +++ b/Server/Source/player_impl.hpp @@ -1287,7 +1287,7 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy void giveWeapon(WeaponSlotData weapon) override { - uint8_t slot = weapon.slot(); + auto slot = weapon.slot(); if (slot == INVALID_WEAPON_SLOT) { // Fail. @@ -1343,7 +1343,7 @@ struct Player final : public IPlayer, public PoolIDProvider, public NoCopy void setWeaponAmmo(WeaponSlotData weapon) override { // Set from sync - uint8_t slot = weapon.slot(); + auto slot = weapon.slot(); if (slot == INVALID_WEAPON_SLOT) { // Fail. diff --git a/Server/Source/player_pool.hpp b/Server/Source/player_pool.hpp index 7f5b32445..8b229a5bd 100644 --- a/Server/Source/player_pool.hpp +++ b/Server/Source/player_pool.hpp @@ -671,7 +671,7 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public Player& player = static_cast(peer); - uint8_t slot = WeaponSlotData(footSync.Weapon).slot(); + auto slot = WeaponSlotData(footSync.Weapon).slot(); if (slot == INVALID_WEAPON_SLOT) { return false; @@ -1112,7 +1112,7 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public return false; } - uint8_t slot = WeaponSlotData(vehicleSync.WeaponID).slot(); + auto slot = WeaponSlotData(vehicleSync.WeaponID).slot(); if (slot == INVALID_WEAPON_SLOT) { return false; @@ -1363,7 +1363,7 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public return false; } - uint8_t slot = WeaponSlotData(passengerSync.WeaponID).slot(); + auto slot = WeaponSlotData(passengerSync.WeaponID).slot(); if (slot == INVALID_WEAPON_SLOT) { return false;