void Raid::SetRaidLeader(const char *wasLead, const char *name) { std::string query = StringFormat("UPDATE raid_members SET israidleader = 0 WHERE name = '%s'", wasLead); auto results = database.QueryDatabase(query); if (!results.Success()) LogFile->write(EQEMuLog::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str()); query = StringFormat("UPDATE raid_members SET israidleader = 1 WHERE name = '%s'", name); results = database.QueryDatabase(query); if (!results.Success()) LogFile->write(EQEMuLog::Error, "Set Raid Leader error: %s\n", results.ErrorMessage().c_str()); strn0cpy(leadername, name, 64); Client *c = entity_list.GetClientByName(name); if(c) SetLeader(c); LearnMembers(); VerifyRaid(); SendMakeLeaderPacket(name); ServerPacket *pack = new ServerPacket(ServerOP_RaidLeader, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, name, 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); }
void Raid::SetGroupLeader(const char *who, bool glFlag) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; if (database.RunQuery(query,MakeAnyLenString(&query, "UPDATE raid_members SET isgroupleader=%lu WHERE name='%s'", (unsigned long)glFlag, who),errbuf,&result)){ mysql_free_result(result); } safe_delete_array(query); LearnMembers(); VerifyRaid(); //if(glFlag == true){ //we're setting the flag //this->SendMakeGroupLeaderPacket(who); //} ServerPacket *pack = new ServerPacket(ServerOP_RaidGroupLeader, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, who, 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); }
void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bool looter){ if(!c) return; char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; if (database.RunQuery(query,MakeAnyLenString(&query, "INSERT INTO raid_members SET raidid=%lu, charid=%lu, groupid=%lu, _class=%d, level=%d, name='%s', isgroupleader=%d, israidleader=%d, islooter=%d", (unsigned long)GetID(), (unsigned long)c->CharacterID(), (unsigned long)group, c->GetClass(), c->GetLevel(), c->GetName(), groupleader, rleader, looter ),errbuf,&result)){ mysql_free_result(result); } safe_delete_array(query); LearnMembers(); VerifyRaid(); if(group < 12) GroupUpdate(group); SendRaidAddAll(c->GetName()); c->SetRaidGrouped(true); ServerPacket *pack = new ServerPacket(ServerOP_RaidAdd, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, c->GetName(), 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); }
void Raid::DisbandRaid() { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; if (database.RunQuery(query,MakeAnyLenString(&query, "DELETE FROM raid_members WHERE raidid=%lu", (unsigned long)GetID()),errbuf,&result)){ mysql_free_result(result); } safe_delete_array(query); LearnMembers(); VerifyRaid(); SendRaidDisbandAll(); ServerPacket *pack = new ServerPacket(ServerOP_RaidDisband, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, " ", 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); forceDisband = true; }
void Raid::RemoveMember(const char *c) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; if (database.RunQuery(query,MakeAnyLenString(&query, "DELETE FROM raid_members where name='%s'", c ),errbuf,&result)){ mysql_free_result(result); } Client *m = entity_list.GetClientByName(c); safe_delete_array(query); disbandCheck = true; SendRaidRemoveAll(c); SendRaidDisband(m); LearnMembers(); VerifyRaid(); if(m){ m->SetRaidGrouped(false); } ServerPacket *pack = new ServerPacket(ServerOP_RaidRemove, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); rga->instance_id = zone->GetInstanceID(); strn0cpy(rga->playername, c, 64); rga->zoneid = zone->GetZoneID(); worldserver.SendPacket(pack); safe_delete(pack); }
void Raid::UpdateLevel(const char *name, int newLevel) { std::string query = StringFormat("UPDATE raid_members SET level = %lu WHERE name = '%s'", (unsigned long)newLevel, name); auto results = database.QueryDatabase(query); LearnMembers(); VerifyRaid(); }
void Raid::UpdateLevel(const char *name, int newLevel) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; if (database.RunQuery(query,MakeAnyLenString(&query, "UPDATE raid_members SET level=%lu WHERE name='%s'", (unsigned long)newLevel, name),errbuf,&result)){ mysql_free_result(result); } safe_delete_array(query); LearnMembers(); VerifyRaid(); }
//create a group which should allready exist in the database Group::Group(uint32 gid) : GroupIDConsumer(gid) { leader = nullptr; memset(members,0,sizeof(Mob*) * MAX_GROUP_MEMBERS); uint32 i; for(i=0;i<MAX_GROUP_MEMBERS;i++) { memset(membername[i],0,64); MemberRoles[i] = 0; } if(gid != 0) { if(!LearnMembers()) SetID(0); } }
void Raid::SetGroupLeader(const char *who, bool glFlag) { std::string query = StringFormat("UPDATE raid_members SET isgroupleader = %lu WHERE name = '%s'", (unsigned long)glFlag, who); auto results = database.QueryDatabase(query); LearnMembers(); VerifyRaid(); ServerPacket *pack = new ServerPacket(ServerOP_RaidGroupLeader, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, who, 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); }
void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bool looter){ if(!c) return; std::string query = StringFormat("INSERT INTO raid_members SET raidid = %lu, charid = %lu, " "groupid = %lu, _class = %d, level = %d, name = '%s', " "isgroupleader = %d, israidleader = %d, islooter = %d", (unsigned long)GetID(), (unsigned long)c->CharacterID(), (unsigned long)group, c->GetClass(), c->GetLevel(), c->GetName(), groupleader, rleader, looter); auto results = database.QueryDatabase(query); if(!results.Success()) { LogFile->write(EQEMuLog::Error, "Error inserting into raid members: %s", results.ErrorMessage().c_str()); } LearnMembers(); VerifyRaid(); if (rleader) { database.SetRaidGroupLeaderInfo(RAID_GROUPLESS, GetID()); UpdateRaidAAs(); } if (group != RAID_GROUPLESS && groupleader) { database.SetRaidGroupLeaderInfo(group, GetID()); UpdateGroupAAs(group); } if(group < 12) GroupUpdate(group); else // get raid AAs, GroupUpdate will handles it otherwise SendGroupLeadershipAA(c, RAID_GROUPLESS); SendRaidAddAll(c->GetName()); c->SetRaidGrouped(true); SendRaidMOTD(c); ServerPacket *pack = new ServerPacket(ServerOP_RaidAdd, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, c->GetName(), 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); }
void Raid::MoveMember(const char *name, uint32 newGroup) { std::string query = StringFormat("UPDATE raid_members SET groupid = %lu WHERE name = '%s'", (unsigned long)newGroup, name); auto results = database.QueryDatabase(query); LearnMembers(); VerifyRaid(); SendRaidMoveAll(name); ServerPacket *pack = new ServerPacket(ServerOP_RaidChangeGroup, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, name, 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); }
void Raid::DisbandRaid() { std::string query = StringFormat("DELETE FROM raid_members WHERE raidid = %lu", (unsigned long)GetID()); auto results = database.QueryDatabase(query); LearnMembers(); VerifyRaid(); SendRaidDisbandAll(); ServerPacket *pack = new ServerPacket(ServerOP_RaidDisband, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, " ", 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); forceDisband = true; }
void Raid::SetRaidLeader(const char *wasLead, const char *name) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; if (!database.RunQuery(query,MakeAnyLenString(&query, "UPDATE raid_members SET israidleader=0 WHERE name='%s'", wasLead),errbuf,&result)){ printf("Set Raid Leader error: %s\n", errbuf); } else mysql_free_result(result); safe_delete_array(query); query = 0; if (!database.RunQuery(query,MakeAnyLenString(&query, "UPDATE raid_members SET israidleader=1 WHERE name='%s'", name),errbuf,&result)){ printf("Set Raid Leader error: %s\n", errbuf); } else mysql_free_result(result); safe_delete_array(query); strn0cpy(leadername, name, 64); Client *c = entity_list.GetClientByName(name); if(c) SetLeader(c); LearnMembers(); VerifyRaid(); SendMakeLeaderPacket(name); ServerPacket *pack = new ServerPacket(ServerOP_RaidLeader, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, name, 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); }
void Raid::MoveMember(const char *name, uint32 newGroup) { char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; MYSQL_RES *result; if (database.RunQuery(query,MakeAnyLenString(&query, "UPDATE raid_members SET groupid=%lu WHERE name='%s'", (unsigned long)newGroup, name),errbuf,&result)){ mysql_free_result(result); } safe_delete_array(query); LearnMembers(); VerifyRaid(); SendRaidMoveAll(name); ServerPacket *pack = new ServerPacket(ServerOP_RaidChangeGroup, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); strn0cpy(rga->playername, name, 64); rga->zoneid = zone->GetZoneID(); rga->instance_id = zone->GetInstanceID(); worldserver.SendPacket(pack); safe_delete(pack); }
void Raid::RemoveMember(const char *characterName) { std::string query = StringFormat("DELETE FROM raid_members where name='%s'", characterName); auto results = database.QueryDatabase(query); Client *client = entity_list.GetClientByName(characterName); disbandCheck = true; SendRaidRemoveAll(characterName); SendRaidDisband(client); LearnMembers(); VerifyRaid(); if(client) client->SetRaidGrouped(false); ServerPacket *pack = new ServerPacket(ServerOP_RaidRemove, sizeof(ServerRaidGeneralAction_Struct)); ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer; rga->rid = GetID(); rga->instance_id = zone->GetInstanceID(); strn0cpy(rga->playername, characterName, 64); rga->zoneid = zone->GetZoneID(); worldserver.SendPacket(pack); safe_delete(pack); }