mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-27 19:42:26 +00:00
RefreshGroupFromDB converted to QueryDatabase
This commit is contained in:
parent
351a7a52fe
commit
fbefad9eaf
@ -1696,62 +1696,55 @@ bool ZoneDatabase::SetZoneTZ(uint32 zoneid, uint32 version, uint32 tz) {
|
|||||||
return results.RowsAffected() == 1;
|
return results.RowsAffected() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneDatabase::RefreshGroupFromDB(Client *c){
|
void ZoneDatabase::RefreshGroupFromDB(Client *client){
|
||||||
if(!c){
|
if(!client)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
Group *g = c->GetGroup();
|
Group *group = client->GetGroup();
|
||||||
|
|
||||||
if(!g){
|
if(!group)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupUpdate2_Struct));
|
EQApplicationPacket* outapp = new EQApplicationPacket(OP_GroupUpdate,sizeof(GroupUpdate2_Struct));
|
||||||
GroupUpdate2_Struct* gu = (GroupUpdate2_Struct*)outapp->pBuffer;
|
GroupUpdate2_Struct* gu = (GroupUpdate2_Struct*)outapp->pBuffer;
|
||||||
gu->action = groupActUpdate;
|
gu->action = groupActUpdate;
|
||||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
|
||||||
char *query = 0;
|
|
||||||
MYSQL_RES *result;
|
|
||||||
MYSQL_ROW row;
|
|
||||||
|
|
||||||
strcpy(gu->yourname, c->GetName());
|
strcpy(gu->yourname, client->GetName());
|
||||||
GetGroupLeadershipInfo(g->GetID(), gu->leadersname, nullptr, nullptr, nullptr, nullptr, &gu->leader_aas);
|
GetGroupLeadershipInfo(group->GetID(), gu->leadersname, nullptr, nullptr, nullptr, nullptr, &gu->leader_aas);
|
||||||
gu->NPCMarkerID = g->GetNPCMarkerID();
|
gu->NPCMarkerID = group->GetNPCMarkerID();
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if (RunQuery(query, MakeAnyLenString(&query, "SELECT name from group_id where groupid=%d", g->GetID()), errbuf, &result)) {
|
|
||||||
while((row = mysql_fetch_row(result))){
|
|
||||||
if(index < 6){
|
|
||||||
if(strcmp(c->GetName(), row[0]) != 0){
|
|
||||||
strcpy(gu->membername[index], row[0]);
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mysql_free_result(result);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Error in group update query: %s\n", errbuf);
|
|
||||||
}
|
|
||||||
safe_delete_array(query);
|
|
||||||
|
|
||||||
c->QueuePacket(outapp);
|
std::string query = StringFormat("SELECT name FROM group_id WHERE groupid = %d", group->GetID());
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
|
if (!results.Success())
|
||||||
|
printf("Error in group update query: %s\n", results.ErrorMessage().c_str());
|
||||||
|
else
|
||||||
|
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||||
|
if(index >= 6)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(strcmp(client->GetName(), row[0]) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
strcpy(gu->membername[index], row[0]);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
|
||||||
|
client->QueuePacket(outapp);
|
||||||
safe_delete(outapp);
|
safe_delete(outapp);
|
||||||
|
|
||||||
if(c->GetClientVersion() >= EQClientSoD) {
|
if(client->GetClientVersion() >= EQClientSoD) {
|
||||||
g->NotifyMainTank(c, 1);
|
group->NotifyMainTank(client, 1);
|
||||||
g->NotifyPuller(c, 1);
|
group->NotifyPuller(client, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
g->NotifyMainAssist(c, 1);
|
group->NotifyMainAssist(client, 1);
|
||||||
|
group->NotifyMarkNPC(client);
|
||||||
g->NotifyMarkNPC(c);
|
group->NotifyAssistTarget(client);
|
||||||
g->NotifyAssistTarget(c);
|
group->NotifyTankTarget(client);
|
||||||
g->NotifyTankTarget(c);
|
group->NotifyPullerTarget(client);
|
||||||
g->NotifyPullerTarget(c);
|
group->SendMarkedNPCsToMember(client);
|
||||||
g->SendMarkedNPCsToMember(c);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user