Secrets: Identified OP_GuildPromote for RoF clients.

Secrets: Fixed promotion, demotion, transferring a leader and displaying of client ranks in the Rain of Fear client. The rain of fear client, as such, will only have 3 ranks like the other clients, but supports a theoretical 8 ranks later.
Secrets/Akkadius: Fixed an issue involving character name lookup in the new DB code.
This commit is contained in:
SecretsOTheP
2014-09-02 21:16:20 -04:00
parent 8422178233
commit 832e5e90d1
14 changed files with 158 additions and 33 deletions
+87 -6
View File
@@ -190,6 +190,7 @@ void MapOpcodes() {
ConnectedOpcodes[OP_GuildWar] = &Client::Handle_OP_GuildWar;
ConnectedOpcodes[OP_GuildLeader] = &Client::Handle_OP_GuildLeader;
ConnectedOpcodes[OP_GuildDemote] = &Client::Handle_OP_GuildDemote;
ConnectedOpcodes[OP_GuildPromote] = &Client::Handle_OP_GuildPromote;
ConnectedOpcodes[OP_GuildInvite] = &Client::Handle_OP_GuildInvite;
ConnectedOpcodes[OP_GuildRemove] = &Client::Handle_OP_GuildRemove;
ConnectedOpcodes[OP_GetGuildMOTD] = &Client::Handle_OP_GetGuildMOTD;
@@ -4088,7 +4089,7 @@ void Client::Handle_OP_GuildLeader(const EQApplicationPacket *app)
GuildMakeLeader* gml=(GuildMakeLeader*)app->pBuffer;
if (!IsInAGuild())
Message(0, "Error: You arent in a guild!");
else if (!guild_mgr.IsGuildLeader(GuildID(), CharacterID()))
else if (GuildRank() != GUILD_LEADER)
Message(0, "Error: You arent the guild leader!");
else if (!worldserver.Connected())
Message(0, "Error: World server disconnected");
@@ -4169,6 +4170,57 @@ void Client::Handle_OP_GuildDemote(const EQApplicationPacket *app)
return;
}
void Client::Handle_OP_GuildPromote(const EQApplicationPacket *app)
{
mlog(GUILDS__IN_PACKETS, "Received OP_GuildPromote");
mpkt(GUILDS__IN_PACKET_TRACE, app);
if(app->size != sizeof(GuildPromoteStruct)) {
mlog(GUILDS__ERROR, "Error: app size of %i != size of GuildDemoteStruct of %i\n",app->size,sizeof(GuildPromoteStruct));
return;
}
if (!IsInAGuild())
Message(0, "Error: You arent in a guild!");
else if (!guild_mgr.CheckPermission(GuildID(), GuildRank(), GUILD_PROMOTE))
Message(0, "You dont have permission to invite.");
else if (!worldserver.Connected())
Message(0, "Error: World server disconnected");
else {
GuildPromoteStruct* promote = (GuildPromoteStruct*)app->pBuffer;
CharGuildInfo gci;
if(!guild_mgr.GetCharInfo(promote->target, gci)) {
Message(0, "Unable to find '%s'", promote->target);
return;
}
if(gci.guild_id != GuildID()) {
Message(0, "You aren't in the same guild, what do you think you are doing?");
return;
}
uint8 rank = gci.rank + 1;
if(rank > GUILD_OFFICER)
return;
mlog(GUILDS__ACTIONS, "Promoting %s (%d) from rank %s (%d) to %s (%d) in %s (%d)",
promote->target, gci.char_id,
guild_mgr.GetRankName(GuildID(), gci.rank), gci.rank,
guild_mgr.GetRankName(GuildID(), rank), rank,
guild_mgr.GetGuildName(GuildID()), GuildID());
if(!guild_mgr.SetGuildRank(gci.char_id, rank)) {
Message(13, "Error while setting rank %d on '%s'.", rank, promote->target);
return;
}
Message(0, "Successfully promoted %s to rank %d", promote->target, rank);
}
return;
}
void Client::Handle_OP_GuildInvite(const EQApplicationPacket *app)
{
mlog(GUILDS__IN_PACKETS, "Received OP_GuildInvite");
@@ -4379,6 +4431,16 @@ void Client::Handle_OP_GuildInviteAccept(const EQApplicationPacket *app)
GuildInviteAccept_Struct* gj = (GuildInviteAccept_Struct*) app->pBuffer;
if(GetClientVersion() >= EQClientRoF)
{
if(gj->response > 9)
{
//dont care if the check fails (since we dont know the rank), just want to clear the entry.
guild_mgr.VerifyAndClearInvite(CharacterID(), gj->guildeqid, gj->response);
worldserver.SendEmoteMessage(gj->inviter, 0, 0, "%s has declined to join the guild.", this->GetName());
return;
}
}
if (gj->response == 5 || gj->response == 4) {
//dont care if the check fails (since we dont know the rank), just want to clear the entry.
guild_mgr.VerifyAndClearInvite(CharacterID(), gj->guildeqid, gj->response);
@@ -4424,15 +4486,24 @@ void Client::Handle_OP_GuildInviteAccept(const EQApplicationPacket *app)
guild_mgr.GetGuildName(gj->guildeqid), gj->guildeqid,
gj->response);
//change guild and rank.
if(!guild_mgr.SetGuild(CharacterID(), gj->guildeqid, gj->response)) {
//change guild and rank
uint32 guildrank = gj->response;
if(GetClientVersion() == EQClientRoF)
{
if(gj->response == 8)
{
guildrank = 0;
}
}
if(!guild_mgr.SetGuild(CharacterID(), gj->guildeqid, guildrank)) {
Message(13, "There was an error during the invite, DB may now be inconsistent.");
return;
}
if(zone->GetZoneID() == RuleI(World, GuildBankZoneID) && GuildBanks)
GuildBanks->SendGuildBank(this);
SendGuildRanks();
}
}
}
@@ -9301,8 +9372,18 @@ void Client::CompleteConnect() {
UpdateAdmin(false);
if (IsInAGuild()){
uint8 rank = GuildRank();
if(GetClientVersion() >= EQClientRoF)
{
switch (rank) {
case 0: { rank = 5; break; } // GUILD_MEMBER 0
case 1: { rank = 3; break; } // GUILD_OFFICER 1
case 2: { rank = 1; break; } // GUILD_LEADER 2
default: { break; } // GUILD_NONE
}
}
SendAppearancePacket(AT_GuildID, GuildID(), false);
SendAppearancePacket(AT_GuildRank, GuildRank(), false);
SendAppearancePacket(AT_GuildRank, rank, false);
}
for (uint32 spellInt = 0; spellInt < MAX_PP_SPELLBOOK; spellInt++)
{