Address being able to friend yourself (#779)

* Address being able to friend yourself

Fix an issue where players could friend themselves.  Also stops yourself as appearing as a friend on your own friends list.

* Send a Response instead

Send a MYTHRAN response since the player is attempting to friend a Mythran.
This commit is contained in:
David Markowitz 2022-10-21 17:35:12 -07:00 committed by GitHub
parent 409d682c9d
commit f02e9c0f6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,9 +33,10 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
"WHEN friend_id = ? THEN player_id "
"END AS requested_player, best_friend FROM friends) AS fr "
"JOIN charinfo AS ci ON ci.id = fr.requested_player "
"WHERE fr.requested_player IS NOT NULL;"));
"WHERE fr.requested_player IS NOT NULL AND fr.requested_player != ?;"));
stmt->setUInt(1, static_cast<uint32_t>(playerID));
stmt->setUInt(2, static_cast<uint32_t>(playerID));
stmt->setUInt(3, static_cast<uint32_t>(playerID));
std::vector<FriendData> friends;
@ -113,6 +114,10 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
inStream.Read(isBestFriendRequest);
auto requestor = playerContainer.GetPlayerData(requestorPlayerID);
if (requestor->playerName == playerName) {
SendFriendResponse(requestor, requestor, AddFriendResponseType::MYTHRAN);
return;
};
std::unique_ptr<PlayerData> requestee(playerContainer.GetPlayerData(playerName));
// Check if player is online first