[Commands] Cleanup #refreshgroup Command. (#2119)

- Cleanup messages and logic.
This commit is contained in:
Kinglykrab 2022-05-06 20:42:25 -04:00 committed by GitHub
parent 6bbd1e94c3
commit 2f962c2c8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 65 additions and 21 deletions

View File

@ -286,7 +286,7 @@ int command_init(void)
command_add("race", "[racenum] - Change your or your target's race. Use racenum 0 to return to normal", AccountStatus::Guide, command_race) ||
command_add("raidloot", "[All|GroupLeader|RaidLeader|Selected] - Sets your Raid Loot Type if you have permission to do so.", AccountStatus::Player, command_raidloot) ||
command_add("randomfeatures", "- Temporarily randomizes the Facial Features of your target", AccountStatus::QuestTroupe, command_randomfeatures) ||
command_add("refreshgroup", "- Refreshes Group.", AccountStatus::Player, command_refreshgroup) ||
command_add("refreshgroup", "- Refreshes Group for you or your player target.", AccountStatus::Player, command_refreshgroup) ||
command_add("reloadaa", "Reloads AA data", AccountStatus::GMMgmt, command_reloadaa) ||
command_add("reloadallrules", "Executes a reload of all rules globally.", AccountStatus::QuestTroupe, command_reloadallrules) ||
command_add("reloadcontentflags", "Executes a reload of all expansion and content flags", AccountStatus::QuestTroupe, command_reloadcontentflags) ||

View File

@ -3,17 +3,58 @@
void command_refreshgroup(Client *c, const Seperator *sep)
{
if (!c) {
auto target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
target = c->GetTarget()->CastToClient();
}
Group *group = target->GetGroup();
if (!group) {
c->Message(
Chat::White,
fmt::format(
"{} not in a group.",
(
c == target ?
"You are" :
fmt::format(
"{} ({}} is",
target->GetCleanName(),
target->GetID()
)
)
).c_str()
);
return;
}
Group *g = c->GetGroup();
database.RefreshGroupFromDB(target);
if (!g) {
return;
c->Message(
Chat::White,
fmt::format(
"Group has been refreshed for {}.",
(
c == target ?
"yourself" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
)
).c_str()
);
if (c != target) {
target->Message(
Chat::White,
fmt::format(
"Your group has been refreshed by {}.",
c->GetCleanName()
).c_str()
);
}
database.RefreshGroupFromDB(c);
//g->SendUpdate(7, c);
}

View File

@ -3205,13 +3205,15 @@ bool ZoneDatabase::SetZoneTZ(uint32 zoneid, uint32 version, uint32 tz) {
}
void ZoneDatabase::RefreshGroupFromDB(Client *client){
if(!client)
if (!client) {
return;
}
Group *group = client->GetGroup();
if(!group)
if (!group) {
return;
}
auto outapp = new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupUpdate2_Struct));
GroupUpdate2_Struct* gu = (GroupUpdate2_Struct*)outapp->pBuffer;
@ -3223,19 +3225,21 @@ void ZoneDatabase::RefreshGroupFromDB(Client *client){
int index = 0;
std::string query = StringFormat("SELECT name FROM group_id WHERE groupid = %d", group->GetID());
auto query = fmt::format(
"SELECT name FROM group_id WHERE groupid = {}",
group->GetID()
);
auto results = QueryDatabase(query);
if (!results.Success())
{
}
else
{
for (auto row = results.begin(); row != results.end(); ++row) {
if(index >= 6)
continue;
if(strcmp(client->GetName(), row[0]) == 0)
if (results.Success()) {
for (auto row : results) {
if (index >= 6) {
continue;
}
if (!strcmp(client->GetName(), row[0])) {
continue;
}
strcpy(gu->membername[index], row[0]);
index++;
@ -3256,7 +3260,6 @@ void ZoneDatabase::RefreshGroupFromDB(Client *client){
group->NotifyTankTarget(client);
group->NotifyPullerTarget(client);
group->SendMarkedNPCsToMember(client);
}
uint8 ZoneDatabase::GroupCount(uint32 groupid) {