Loading...   


void ZoneClientConnection::_handleGuildInviteAccept(const EQApplicationPacket* pPacket) {
	ARG_PTR_CHECK(pPacket);
	EXPECTED(mConnected);
	if (mCharacter->hasGuild()) { return; } // NOTE: UF sends OP_GuildInvite and OP_GuildInviteAccept(response=2,guildid=0) when using /guildinvite .. not sure why.
	EXPECTED(mCharacter->getPendingGuildInviteID() != NO_GUILD); // Check: This Character has actually been invited to *A* Guild
	PACKET_SIZE_CHECK(pPacket->size == sizeof(GuildInviteAccept_Struct));

	auto payload = reinterpret_cast<GuildInviteAccept_Struct*>(pPacket->pBuffer);
	String characterName = Utility::safeString(payload->newmember, MAX_CHARACTER_NAME_LENGTH);
	String inviterName = Utility::safeString(payload->inviter, MAX_CHARACTER_NAME_LENGTH);

	EXPECTED(mCharacter->getName() == characterName); // Check: Sanity.
	EXPECTED(mCharacter->getPendingGuildInviteName() == inviterName); // Check: This Character is responding to the correct inviter.
	EXPECTED(mCharacter->getPendingGuildInviteID() == payload->guildeqid); // Check: This Character is responding to the correct Guild invite.
	
	static const auto Accept = 0;
	static const auto Decline = 5;

	// Character is accepting the invite.
	if (payload->response == Accept) {
		GuildManager::getInstance().handleGuildInviteAccept(mCharacter, inviterName);
		return;
	}
	// Character is declining the invite.
	if (payload->response == Decline) {
		GuildManager::getInstance().handleGuildInviteDecline(mCharacter, inviterName);
		return;
	}

	Log::error("[Zone Client Connection] Got unexpected response(" + std::to_string(payload->response) + ") to Guild invite" + Utility::characterLogDetails(mCharacter));
	mCharacter->clearPendingGuildInvite();
}

Raw Paste Data