Skip to content

Commit

Permalink
Merge pull request #862 from openmultiplayer/amir/fix-invalid-weap-slot
Browse files Browse the repository at this point in the history
change invalid weapon slot to -1
  • Loading branch information
AmyrAhmady authored Feb 13, 2024
2 parents 8f9a05c + a1abb74 commit 62a2fa9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions SDK/include/player.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion SDK/include/values.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Server/Source/player_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions Server/Source/player_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ struct PlayerPool final : public IPlayerPool, public NetworkEventHandler, public

Player& player = static_cast<Player&>(peer);

uint8_t slot = WeaponSlotData(footSync.Weapon).slot();
auto slot = WeaponSlotData(footSync.Weapon).slot();
if (slot == INVALID_WEAPON_SLOT)
{
return false;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 62a2fa9

Please sign in to comment.