Skip to content

Commit

Permalink
fix play key not working
Browse files Browse the repository at this point in the history
  • Loading branch information
EmosewaMC committed Nov 16, 2023
1 parent 45a4ad7 commit 2e7d636
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dDatabase/GameDatabase/ITables/IPlayKeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class IPlayKeys {
// Get the playkey id for the given playkey.
// Optional of bool may seem pointless, however the optional indicates if the playkey exists
// and the bool indicates if the playkey is active.
virtual std::optional<bool> IsPlaykeyActive(const uint32_t playkeyId) = 0;
virtual std::optional<bool> IsPlaykeyActive(const int32_t playkeyId) = 0;
};

#endif //!__IPLAYKEYS__H__
2 changes: 1 addition & 1 deletion dDatabase/GameDatabase/MySQL/MySQLDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class MySQLDatabase : public GameDatabase {
void InsertDefaultPersistentId() override;
void UpdatePersistentId(const uint32_t id) override;
std::optional<uint32_t> GetDonationTotal(const uint32_t activityId) override;
std::optional<bool> IsPlaykeyActive(const uint32_t playkeyId) override;
std::optional<bool> IsPlaykeyActive(const int32_t playkeyId) override;
std::vector<IUgc::Model> GetUgcModels(const LWOOBJID& propertyId) override;
private:

Expand Down
2 changes: 1 addition & 1 deletion dDatabase/GameDatabase/MySQL/Tables/PlayKeys.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "MySQLDatabase.h"

std::optional<bool> MySQLDatabase::IsPlaykeyActive(const uint32_t playkeyId) {
std::optional<bool> MySQLDatabase::IsPlaykeyActive(const int32_t playkeyId) {
auto keyCheckRes = ExecuteSelect("SELECT active FROM `play_keys` WHERE id=?", playkeyId);

if (!keyCheckRes->next()) {
Expand Down
11 changes: 6 additions & 5 deletions dNet/AuthPackets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
return;
}

if (Game::config->GetValue("dont_use_keys") != "1") {
if (Game::config->GetValue("dont_use_keys") != "1" && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) {
LOG("");
//Check to see if we have a play key:
if (accountInfo->playKeyId == 0 && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) {
if (accountInfo->playKeyId == 0) {
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username);
LOG("User %s tried to log in, but they don't have a play key.", username.c_str());
return;
Expand All @@ -91,12 +92,12 @@ void AuthPackets::HandleLoginRequest(dServer* server, Packet* packet) {
//Check if the play key is _valid_:
auto playKeyStatus = Database::Get()->IsPlaykeyActive(accountInfo->playKeyId);

if (!playKeyStatus || accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) {
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a play key associated with it!", "", 2001, username);
if (!playKeyStatus) {
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your account doesn't have a valid play key associated with it!", "", 2001, username);
return;
}

if (!playKeyStatus.value() && accountInfo->maxGmLevel == eGameMasterLevel::CIVILIAN) {
if (!playKeyStatus.value()) {
AuthPackets::SendLoginResponse(server, packet->systemAddress, eLoginResponse::PERMISSIONS_NOT_HIGH_ENOUGH, "Your play key has been disabled.", "", 2001, username);
LOG("User %s tried to log in, but their play key was disabled", username.c_str());
return;
Expand Down

0 comments on commit 2e7d636

Please sign in to comment.