mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Bug Fix] Fix GetLeaderName() for Groups (#4184)
* [Bug Fix] Fix GetLeaderName() for Groups # Notes - We were getting bogus data in this. - Made it its own method. * Remove ExpeditionRequest::GetGroupLeaderName()
This commit is contained in:
parent
e48dae2392
commit
b29c26becb
@ -1389,6 +1389,24 @@ void Database::SetGroupLeaderName(uint32 gid, const char* name) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string Database::GetGroupLeaderName(uint32 group_id)
|
||||
{
|
||||
const std::string& query = fmt::format(
|
||||
"SELECT `leadername` FROM `group_leaders` WHERE `gid` = {}",
|
||||
group_id
|
||||
);
|
||||
|
||||
auto results = QueryDatabase(query);
|
||||
|
||||
if (!results.Success() || !results.RowCount()) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
|
||||
return row[0];
|
||||
}
|
||||
|
||||
char *Database::GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank, char* assist, char* puller, char *marknpc, char *mentoree, int *mentor_percent, GroupLeadershipAA_Struct* GLAA)
|
||||
{
|
||||
std::string query = StringFormat("SELECT `leadername`, `maintank`, `assist`, `puller`, `marknpc`, `mentoree`, `mentor_percent`, `leadershipaa` FROM `group_leaders` WHERE `gid` = %lu",(unsigned long)gid);
|
||||
|
||||
@ -205,6 +205,8 @@ public:
|
||||
std::string GetGroupLeaderForLogin(std::string character_name);
|
||||
char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr, char *mentoree = nullptr, int *mentor_percent = nullptr, GroupLeadershipAA_Struct* GLAA = nullptr);
|
||||
|
||||
std::string GetGroupLeaderName(uint32 group_id);
|
||||
|
||||
uint32 GetGroupID(const char* name);
|
||||
|
||||
void ClearGroup(uint32 gid = 0);
|
||||
|
||||
@ -2152,7 +2152,7 @@ Group *EntityList::GetGroupByLeaderName(const char *leader)
|
||||
iterator = group_list.begin();
|
||||
|
||||
while (iterator != group_list.end()) {
|
||||
if (!strcmp((*iterator)->GetLeaderName(), leader))
|
||||
if (!strcmp((*iterator)->GetLeaderName().c_str(), leader))
|
||||
return *iterator;
|
||||
++iterator;
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ bool ExpeditionRequest::CanGroupRequest(Group* group)
|
||||
}
|
||||
|
||||
// Group::GetLeaderName() is broken if group formed across zones, ask database instead
|
||||
m_leader_name = m_leader ? m_leader->GetName() : GetGroupLeaderName(group->GetID()); // group->GetLeaderName();
|
||||
m_leader_name = m_leader ? m_leader->GetName() : group->GetLeaderName();
|
||||
m_leader_id = m_leader ? m_leader->CharacterID() : database.GetCharacterID(m_leader_name);
|
||||
|
||||
std::vector<std::string> member_names;
|
||||
@ -148,13 +148,6 @@ bool ExpeditionRequest::CanGroupRequest(Group* group)
|
||||
return CanMembersJoin(member_names);
|
||||
}
|
||||
|
||||
std::string ExpeditionRequest::GetGroupLeaderName(uint32_t group_id)
|
||||
{
|
||||
char leader_name_buffer[64] = { 0 };
|
||||
database.GetGroupLeadershipInfo(group_id, leader_name_buffer);
|
||||
return std::string(leader_name_buffer);
|
||||
}
|
||||
|
||||
bool ExpeditionRequest::CanMembersJoin(const std::vector<std::string>& member_names)
|
||||
{
|
||||
if (member_names.empty())
|
||||
|
||||
@ -54,7 +54,6 @@ private:
|
||||
bool CanRaidRequest(Raid* raid);
|
||||
bool CanGroupRequest(Group* group);
|
||||
bool CheckMembersForConflicts(const std::vector<std::string>& member_names);
|
||||
std::string GetGroupLeaderName(uint32_t group_id);
|
||||
bool IsPlayerCountValidated();
|
||||
bool SaveLeaderLockouts(const std::vector<ExpeditionLockoutTimer>& leader_lockouts);
|
||||
void SendLeaderMemberInExpedition(const std::string& member_name, bool is_solo);
|
||||
|
||||
@ -620,7 +620,7 @@ bool Group::DelMemberOOZ(const char *Name) {
|
||||
if(!strcasecmp(Name, membername[i]))
|
||||
// This shouldn't be called if the member is in this zone.
|
||||
if(!members[i]) {
|
||||
if(!strncmp(GetLeaderName(), Name, 64))
|
||||
if(!strncmp(GetLeaderName().c_str(), Name, 64))
|
||||
{
|
||||
//TODO: Transfer leadership if leader disbands OOZ.
|
||||
UpdateGroupAAs();
|
||||
@ -703,7 +703,7 @@ bool Group::DelMember(Mob* oldmember, bool ignoresender)
|
||||
}
|
||||
}
|
||||
|
||||
if (!GetLeaderName())
|
||||
if (GetLeaderName().empty())
|
||||
{
|
||||
DisbandGroup();
|
||||
return true;
|
||||
@ -1676,7 +1676,7 @@ void Group::NotifyMainTank(Client *c, uint8 toggle)
|
||||
|
||||
strn0cpy(grs->Name1, MainTankName.c_str(), sizeof(grs->Name1));
|
||||
|
||||
strn0cpy(grs->Name2, GetLeaderName(), sizeof(grs->Name2));
|
||||
strn0cpy(grs->Name2, GetLeaderName().c_str(), sizeof(grs->Name2));
|
||||
|
||||
grs->RoleNumber = 1;
|
||||
|
||||
@ -1729,7 +1729,7 @@ void Group::NotifyMainAssist(Client *c, uint8 toggle)
|
||||
|
||||
strn0cpy(grs->Name1, MainAssistName.c_str(), sizeof(grs->Name1));
|
||||
|
||||
strn0cpy(grs->Name2, GetLeaderName(), sizeof(grs->Name2));
|
||||
strn0cpy(grs->Name2, GetLeaderName().c_str(), sizeof(grs->Name2));
|
||||
|
||||
grs->RoleNumber = 2;
|
||||
|
||||
@ -1771,7 +1771,7 @@ void Group::NotifyPuller(Client *c, uint8 toggle)
|
||||
|
||||
strn0cpy(grs->Name1, PullerName.c_str(), sizeof(grs->Name1));
|
||||
|
||||
strn0cpy(grs->Name2, GetLeaderName(), sizeof(grs->Name2));
|
||||
strn0cpy(grs->Name2, GetLeaderName().c_str(), sizeof(grs->Name2));
|
||||
|
||||
grs->RoleNumber = 3;
|
||||
|
||||
@ -2511,8 +2511,6 @@ bool Group::IsLeader(const char* name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string Group::GetGroupLeaderName(uint32 group_id) {
|
||||
char leader_name_buffer[64] = { 0 };
|
||||
database.GetGroupLeadershipInfo(group_id, leader_name_buffer);
|
||||
return std::string(leader_name_buffer);
|
||||
std::string Group::GetLeaderName() {
|
||||
return database.GetGroupLeaderName(GetID());
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ public:
|
||||
void SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, Client *splitter = nullptr);
|
||||
inline void SetLeader(Mob* c){ leader = c; };
|
||||
inline Mob* GetLeader() { return leader; };
|
||||
const char* GetLeaderName() { return GetGroupLeaderName(GetID()).c_str(); };
|
||||
std::string GetLeaderName();
|
||||
void SendHPManaEndPacketsTo(Mob* newmember);
|
||||
void SendHPPacketsFrom(Mob* member);
|
||||
void SendManaPacketFrom(Mob* member);
|
||||
@ -177,8 +177,6 @@ private:
|
||||
int mentor_percent;
|
||||
|
||||
XTargetAutoHaters m_autohatermgr;
|
||||
|
||||
std::string GetGroupLeaderName(uint32 group_id);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -72,7 +72,7 @@ Lua_Mob Lua_Group::GetLeader() {
|
||||
return self->GetLeader();
|
||||
}
|
||||
|
||||
const char *Lua_Group::GetLeaderName() {
|
||||
std::string Lua_Group::GetLeaderName() {
|
||||
Lua_Safe_Call_String();
|
||||
return self->GetLeaderName();
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public:
|
||||
void SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, Lua_Client splitter);
|
||||
void SetLeader(Lua_Mob c);
|
||||
Lua_Mob GetLeader();
|
||||
const char *GetLeaderName();
|
||||
std::string GetLeaderName();
|
||||
bool IsLeader(const char* name);
|
||||
bool IsLeader(Lua_Mob c);
|
||||
int GroupCount();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user