Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
crdunwel committed Feb 12, 2024
1 parent 4d5973f commit 1c10877
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 28 deletions.
24 changes: 12 additions & 12 deletions common/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,19 +454,17 @@ bool Database::SetMule(const char* charname) {
auto row = results.begin();
uint32 account_id = std::stoul(row[0]);

// iterate over every character associated with account and verify they're all level 1
std::string query = StringFormat("SELECT `account_id`, `level` FROM `character_data` WHERE `account_id` = %u", account_id);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
if (std::stoi(row[1]) != 1) {
Log(Logs::General, Logs::WorldServer, "Can not set mule status on account because character exists that is not level 1");
return false;
}
// iterate over every character associated with account and verify they're all level 1 (exclude char with charname)
query = StringFormat("SELECT `account_id` FROM `character_data` WHERE `account_id` = %u", account_id);
results = QueryDatabase(query);
if (results.RowCount() != 1) {
Log(Logs::General, Logs::WorldServer, "Can not set mule status on account because more than one character exists on account.");
return false;
}

// finally set account to mule status
std::string query = StringFormat("UPDATE account SET mule = %d where id = %u AND status < 80", 1, account_id);
auto results = QueryDatabase(query);
query = StringFormat("UPDATE account SET mule = %d where id = %u AND status < 80", 1, account_id);
results = QueryDatabase(query);
if (!results.Success()) {
return false;
}
Expand Down Expand Up @@ -1424,9 +1422,9 @@ bool Database::AddToNameFilter(const char* name) {
return true;
}

uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* oStatus, int8* oRevoked) {
uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* oStatus, int8* oRevoked, bool* isMule) {
uint32 account_id = 0;
std::string query = StringFormat("SELECT id, name, status, revoked FROM account WHERE lsaccount_id=%i", iLSID);
std::string query = StringFormat("SELECT id, name, status, revoked, mule FROM account WHERE lsaccount_id=%i", iLSID);
auto results = QueryDatabase(query);

if (!results.Success()) {
Expand All @@ -1445,6 +1443,8 @@ uint32 Database::GetAccountIDFromLSID(uint32 iLSID, char* oAccountName, int16* o
*oStatus = atoi(row[2]);
if (oRevoked)
*oRevoked = atoi(row[3]);
if (isMule)
*isMule = atoi(row[4]);
}

return account_id;
Expand Down
2 changes: 1 addition & 1 deletion common/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class Database : public DBcore {
bool SetAccountStatus(const char* name, int16 status);
bool SetAccountStatus(const std::string& account_name, int16 status);
bool SetLocalPassword(uint32 accid, const char* password);
uint32 GetAccountIDFromLSID(uint32 iLSID, char* oAccountName = 0, int16* oStatus = 0, int8* oRevoked = 0);
uint32 GetAccountIDFromLSID(uint32 iLSID, char* oAccountName = 0, int16* oStatus = 0, int8* oRevoked = 0, bool* isMule = nullptr);
bool UpdateLiveChar(char* charname,uint32 lsaccount_id);
bool GetLiveChar(uint32 account_id, char* cname);
bool GetLiveCharByLSID(uint32 ls_id, char* cname);
Expand Down
3 changes: 2 additions & 1 deletion world/cliententry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ ClientListEntry::ClientListEntry(uint32 in_id, uint32 iLSID, const char* iLoginN
pIP = ip;
pLSID = iLSID;
if(iLSID > 0)
paccountid = database.GetAccountIDFromLSID(iLSID, paccountname, &padmin);
paccountid = database.GetAccountIDFromLSID(iLSID, paccountname, &padmin, 0, &pmule);
strn0cpy(plsname, iLoginName, sizeof(plsname));
strn0cpy(plskey, iLoginKey, sizeof(plskey));
strn0cpy(pForumName, iForumName, sizeof(pForumName));
Expand Down Expand Up @@ -70,6 +70,7 @@ ClientListEntry::ClientListEntry(uint32 in_id, ZoneServer* iZS, ServerClientList
//THIS IS FOR AN ALTERNATE LOGIN METHOD FOR RAPID TESTING. Hardcoded to the PC client because only PCs should be using this 'hackish' login method. Requires password field set in the database.
pversion = 2;
pRevoked = scl->Revoked;
pmule = scl->mule;

if (iOnline >= CLE_Status_Zoning)
Update(iZS, scl, iOnline);
Expand Down
9 changes: 5 additions & 4 deletions zone/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ Client::Client(EQStreamInterface* ieqs)
wake_corpse_id = 0;
ranged_attack_leeway_timer.Disable();
last_fatigue = 0;
mule_initiated = false;
}

Client::~Client() {
Expand Down Expand Up @@ -987,7 +988,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s

if(TotalKarma < RuleI(Chat, KarmaGlobalChatLimit))
{
if(GetLevel() < RuleI(Chat, KarmaGlobalChatLevelLimit))
if(GetLevel() < RuleI(Chat, KarmaGlobalChatLevelLimit) && !this->IsMule())
{
Message(CC_Default, "You do not have permission to talk in Auction at this time.");
return;
Expand Down Expand Up @@ -1034,7 +1035,7 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s

if(TotalKarma < RuleI(Chat, KarmaGlobalChatLimit))
{
if(GetLevel() < RuleI(Chat, KarmaGlobalChatLevelLimit))
if(GetLevel() < RuleI(Chat, KarmaGlobalChatLevelLimit) && !this->IsMule())
{
Message(CC_Default, "You do not have permission to talk in OOC at this time.");
return;
Expand Down Expand Up @@ -1067,15 +1068,15 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
}
case ChatChannel_Tell: { /* Tell */

if (GetLevel() < RuleI(Chat, GlobalChatLevelLimit))
if (GetLevel() < RuleI(Chat, GlobalChatLevelLimit) && !this->IsMule())
{
Message(CC_Default, "You do not have permission to send tells until level %i.", RuleI(Chat, GlobalChatLevelLimit));
return;
}

if(TotalKarma < RuleI(Chat, KarmaGlobalChatLimit))
{
if(GetLevel() < RuleI(Chat, KarmaGlobalChatLevelLimit))
if(GetLevel() < RuleI(Chat, KarmaGlobalChatLevelLimit) && !this->IsMule())
{
Message(CC_Default, "You do not have permission to send tells.");
return;
Expand Down
2 changes: 1 addition & 1 deletion zone/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ class Client : public Mob
bool IsLockSavePosition() const;
void SetLockSavePosition(bool lock_save_position);
inline bool IsMuleInitiated() { return mule_initiated; }
inline bool SetMuleInitiated(bool initiated) { mule_initiated = initiated; }
inline void SetMuleInitiated(bool initiated) { mule_initiated = initiated; }
private:


Expand Down
19 changes: 10 additions & 9 deletions zone/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10953,29 +10953,30 @@ void command_makemule(Client* c, const Seperator* sep)
c->Message(CC_Red, "Account is already flagged as a mule.");
return;
}
if (c->GetLevel() != 1) {
c->Message(CC_Red, "Mule accounts and characters must be level 1.");
return;
}
if (!c->IsMuleInitiated()) {
c->SetMuleInitiated(true);
c->Message(CC_Default, "You have initiated the process to make this account a mule. Mules can not leave designated trader zones or level past 1. Once an account is made a mule it can not be undone. If you wish to proceed then type: #makemule confirm");
if (c->GetLevel() < RuleI(Chat, GlobalChatLevelLimit)) {
c->Message(CC_Red, "To flag an account as a mule you must first level to %i.", RuleI(Chat, GlobalChatLevelLimit));
return;
}
if (c->IsMuleInitiated() && sep->arg[1][0] != 0 && strcasecmp(sep->arg[1], "confirm") == 0) {
if (!database.SetMule(c->GetName())) {
c->Message(CC_Red, "Could not set mule status for this account. It may already be a mule account or all characters are not level 1.");
c->Message(CC_Red, "Could not set mule status for this account. It may already be a mule account or more than one character already exist.");
}
else {
c->MovePC(ecommons, -164, -1651, 4, 0.0f, 0, SummonPC);
c->Message(CC_Green, "Successfully flagged your account as a mule.");
c->SetLevel(1);
c->SetBindPoint(ecommons, glm::vec3(-164.0f, -1651.0f, 4.0f));
c->GoToBind();
c->WorldKick();
}
return;
}
if (sep->arg[1][0] != 0 && strcasecmp(sep->arg[1], "confirm") != 0) {
c->Message(CC_Red, "To confirm your mule account you must type: #makemule confirm");
return;
}
c->SetMuleInitiated(true);
c->Message(CC_Default, "You have initiated the process to make this account a mule. Mules can not leave designated trader zones or level past 1.");
c->Message(CC_Default, "Once an account is made a mule it can not be undone. If you wish to proceed then type: #makemule confirm");
}

void command_mule(Client *c, const Seperator *sep)
Expand Down

0 comments on commit 1c10877

Please sign in to comment.