Revert playerflags functions to uint instead of int (#1130)

Prevents issue with negative numbers resulting in bugs.
This commit is contained in:
David Markowitz 2023-06-26 00:51:28 -07:00 committed by GitHub
parent 41898bef86
commit c4135eac46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -418,7 +418,7 @@ void Character::WriteToDatabase() {
delete printer; delete printer;
} }
void Character::SetPlayerFlag(const int32_t flagId, const bool value) { void Character::SetPlayerFlag(const uint32_t flagId, const bool value) {
// If the flag is already set, we don't have to recalculate it // If the flag is already set, we don't have to recalculate it
if (GetPlayerFlag(flagId) == value) return; if (GetPlayerFlag(flagId) == value) return;
@ -465,7 +465,7 @@ void Character::SetPlayerFlag(const int32_t flagId, const bool value) {
GameMessages::SendNotifyClientFlagChange(m_ObjectID, flagId, value, m_ParentUser->GetSystemAddress()); GameMessages::SendNotifyClientFlagChange(m_ObjectID, flagId, value, m_ParentUser->GetSystemAddress());
} }
bool Character::GetPlayerFlag(const int32_t flagId) const { bool Character::GetPlayerFlag(const uint32_t flagId) const {
// Calculate the index first // Calculate the index first
const auto flagIndex = uint32_t(std::floor(flagId / 64)); const auto flagIndex = uint32_t(std::floor(flagId / 64));

View File

@ -415,14 +415,14 @@ public:
* @param flagId the ID of the flag to set * @param flagId the ID of the flag to set
* @param value the value to set for the flag * @param value the value to set for the flag
*/ */
void SetPlayerFlag(int32_t flagId, bool value); void SetPlayerFlag(uint32_t flagId, bool value);
/** /**
* Gets the value for a certain character flag * Gets the value for a certain character flag
* @param flagId the ID of the flag to get a value for * @param flagId the ID of the flag to get a value for
* @return the value of the flag given the ID (the default is false, obviously) * @return the value of the flag given the ID (the default is false, obviously)
*/ */
bool GetPlayerFlag(int32_t flagId) const; bool GetPlayerFlag(uint32_t flagId) const;
/** /**
* Notifies the character that they're now muted * Notifies the character that they're now muted