Implement Raid MOTD for UF

Don't forget to source 2014_10_11_RaidMOTD.sql

SoD and RoF implementations still to come
This commit is contained in:
Michael Cook (mackal)
2014-10-11 01:14:11 -04:00
parent 66cfb2e32b
commit 35049d530e
11 changed files with 158 additions and 12 deletions
+16 -2
View File
@@ -565,6 +565,7 @@ void Client::CompleteConnect()
raid->SendRaidAdd(GetName(), this);
raid->SendBulkRaid(this);
raid->SendGroupUpdate(this);
raid->SendRaidMOTD(this);
uint32 grpID = raid->GetGroup(GetName());
if (grpID < 12){
raid->SendRaidGroupRemove(GetName(), grpID);
@@ -10656,8 +10657,8 @@ void Client::Handle_OP_PVPLeaderBoardRequest(const EQApplicationPacket *app)
void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
{
if (app->size != sizeof(RaidGeneral_Struct)) {
LogFile->write(EQEMuLog::Error, "Wrong size: OP_RaidCommand, size=%i, expected %i", app->size, sizeof(RaidGeneral_Struct));
if (app->size < sizeof(RaidGeneral_Struct)) {
LogFile->write(EQEMuLog::Error, "Wrong size: OP_RaidCommand, size=%i, expected at least %i", app->size, sizeof(RaidGeneral_Struct));
DumpPacket(app);
return;
}
@@ -11219,6 +11220,19 @@ void Client::Handle_OP_RaidCommand(const EQApplicationPacket *app)
break;
}
case RaidCommandSetMotd:
{
Raid *r = entity_list.GetRaidByClient(this);
if (!r)
break;
// we don't use the RaidGeneral here!
RaidMOTD_Struct *motd = (RaidMOTD_Struct *)app->pBuffer;
r->SetRaidMOTD(std::string(motd->motd));
r->SaveRaidMOTD();
r->SendRaidMOTDToWorld();
break;
}
default: {
Message(13, "Raid command (%d) NYI", ri->action);
break;
+50 -2
View File
@@ -89,6 +89,7 @@ void Raid::AddMember(Client *c, uint32 group, bool rleader, bool groupleader, bo
SendRaidAddAll(c->GetName());
c->SetRaidGrouped(true);
SendRaidMOTD(c);
ServerPacket *pack = new ServerPacket(ServerOP_RaidAdd, sizeof(ServerRaidGeneralAction_Struct));
ServerRaidGeneralAction_Struct *rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
@@ -1205,6 +1206,44 @@ void Raid::SendRaidGroupRemove(const char *who, uint32 gid)
safe_delete(pack);
}
void Raid::SendRaidMOTD(Client *c)
{
if (!c || motd.empty())
return;
size_t size = motd.size() + 1;
EQApplicationPacket *outapp = new EQApplicationPacket(OP_RaidUpdate, sizeof(RaidMOTD_Struct) + size);
RaidMOTD_Struct *rmotd = (RaidMOTD_Struct *)outapp->pBuffer;
rmotd->general.action = raidSetMotd;
strn0cpy(rmotd->general.player_name, c->GetName(), 64);
strn0cpy(rmotd->motd, motd.c_str(), size);
c->FastQueuePacket(&outapp);
}
void Raid::SendRaidMOTD()
{
if (motd.empty())
return;
for (uint32 i = 0; i < MAX_RAID_MEMBERS; i++)
if (members[i].member)
SendRaidMOTD(members[i].member);
}
void Raid::SendRaidMOTDToWorld()
{
if (motd.empty())
return;
size_t size = motd.size() + 1;
ServerPacket *pack = new ServerPacket(ServerOP_RaidMOTD, sizeof(ServerRaidMOTD_Struct) + size);
ServerRaidMOTD_Struct *smotd = (ServerRaidMOTD_Struct *)pack->pBuffer;
smotd->rid = GetID();
strn0cpy(smotd->motd, motd.c_str(), size);
worldserver.SendPacket(pack);
safe_delete(pack);
}
void Raid::LockRaid(bool lockFlag)
{
std::string query = StringFormat("UPDATE raid_details SET locked = %d WHERE raidid = %lu",
@@ -1229,14 +1268,14 @@ void Raid::LockRaid(bool lockFlag)
void Raid::SetRaidDetails()
{
std::string query = StringFormat("INSERT INTO raid_details SET raidid = %lu, loottype = 4, locked = 0",
std::string query = StringFormat("INSERT INTO raid_details SET raidid = %lu, loottype = 4, locked = 0, motd = ''",
(unsigned long)GetID());
auto results = database.QueryDatabase(query);
}
void Raid::GetRaidDetails()
{
std::string query = StringFormat("SELECT locked, loottype FROM raid_details WHERE raidid = %lu",
std::string query = StringFormat("SELECT locked, loottype, motd FROM raid_details WHERE raidid = %lu",
(unsigned long)GetID());
auto results = database.QueryDatabase(query);
if (!results.Success())
@@ -1251,6 +1290,15 @@ void Raid::GetRaidDetails()
locked = atoi(row[0]);
LootType = atoi(row[1]);
motd = std::string(row[2]);
}
void Raid::SaveRaidMOTD()
{
std::string query = StringFormat("UPDATE raid_details SET motd = '%s' WHERE raidid = %lu",
EscapeString(motd).c_str(), (unsigned long)GetID());
auto results = database.QueryDatabase(query);
}
bool Raid::LearnMembers()
+8 -1
View File
@@ -38,7 +38,7 @@ enum { //raid packet types:
raidMembers = 6, //len 395+, details + members list
raidNoAssignLeadership = 7,
raidCreate = 8, //len 72
raidUnknown = 9,
raidUnknown = 9, // unused?
raidNoRaid = 10, //parameter=0
raidChangeLootType = 11,
raidStringID = 12,
@@ -130,6 +130,8 @@ public:
void AddRaidLooter(const char* looter);
void RemoveRaidLooter(const char* looter);
inline void SetRaidMOTD(std::string in_motd) { motd = in_motd; };
//util func
//keeps me from having to keep iterating through the list
//when I want lots of data from the same entry
@@ -160,6 +162,7 @@ public:
//also learns raid structure based on db.
void SetRaidDetails();
void GetRaidDetails();
void SaveRaidMOTD();
bool LearnMembers();
void VerifyRaid();
void MemberZoned(Client *c);
@@ -194,6 +197,9 @@ public:
void SendMakeGroupLeaderPacketAll();
void SendMakeGroupLeaderPacket(const char *who); //13
void SendMakeGroupLeaderPacketTo(const char *who, Client *to);
void SendRaidMOTD(Client *c);
void SendRaidMOTD();
void SendRaidMOTDToWorld();
void QueuePacket(const EQApplicationPacket *app, bool ack_req = true);
@@ -206,6 +212,7 @@ protected:
uint32 LootType;
bool disbandCheck;
bool forceDisband;
std::string motd;
};
+12
View File
@@ -1372,6 +1372,18 @@ void WorldServer::Process() {
break;
}
case ServerOP_RaidMOTD: {
ServerRaidMOTD_Struct *rmotd = (ServerRaidMOTD_Struct *)pack->pBuffer;
if (!zone)
break;
Raid *r = entity_list.GetRaidByID(rmotd->rid);
if (!r)
break;
r->SetRaidMOTD(std::string(rmotd->motd));
r->SendRaidMOTD();
break;
}
case ServerOP_SpawnPlayerCorpse: {
SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer;
Corpse* NewCorpse = database.LoadPlayerCorpse(s->player_corpse_id);