mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-25 23:17:28 +00:00
fix: properly check friend list limits
added a config for friend list limit for the brave that want to mod the client to sanely go over 50 moved the best friend limit config to chatconfig.ini where it should be cleanup loading these configs options a bit Tested that the BFF limit works and that the new friend limit works as well
This commit is contained in:
parent
0ddd20e2b5
commit
697989f6be
@ -96,9 +96,6 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
|
void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
|
||||||
auto maxNumberOfBestFriendsAsString = Game::config->GetValue("max_number_of_best_friends");
|
|
||||||
// If this config option doesn't exist, default to 5 which is what live used.
|
|
||||||
auto maxNumberOfBestFriends = maxNumberOfBestFriendsAsString != "" ? std::stoi(maxNumberOfBestFriendsAsString) : 5U;
|
|
||||||
CINSTREAM_SKIP_HEADER;
|
CINSTREAM_SKIP_HEADER;
|
||||||
LWOOBJID requestorPlayerID;
|
LWOOBJID requestorPlayerID;
|
||||||
inStream.Read(requestorPlayerID);
|
inStream.Read(requestorPlayerID);
|
||||||
@ -204,11 +201,12 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
|
|||||||
|
|
||||||
// Only do updates if there was a change in the bff status.
|
// Only do updates if there was a change in the bff status.
|
||||||
if (oldBestFriendStatus != bestFriendStatus) {
|
if (oldBestFriendStatus != bestFriendStatus) {
|
||||||
if (requestee->countOfBestFriends >= maxNumberOfBestFriends || requestor->countOfBestFriends >= maxNumberOfBestFriends) {
|
auto maxBestFriends = playerContainer.GetMaxNumberOfBestFriends();
|
||||||
if (requestee->countOfBestFriends >= maxNumberOfBestFriends) {
|
if (requestee->countOfBestFriends >= maxBestFriends || requestor->countOfBestFriends >= maxBestFriends) {
|
||||||
|
if (requestee->countOfBestFriends >= maxBestFriends) {
|
||||||
SendFriendResponse(requestor, requestee.get(), eAddFriendResponseType::THEIRFRIENDLISTFULL, false);
|
SendFriendResponse(requestor, requestee.get(), eAddFriendResponseType::THEIRFRIENDLISTFULL, false);
|
||||||
}
|
}
|
||||||
if (requestor->countOfBestFriends >= maxNumberOfBestFriends) {
|
if (requestor->countOfBestFriends >= maxBestFriends) {
|
||||||
SendFriendResponse(requestor, requestee.get(), eAddFriendResponseType::YOURFRIENDSLISTFULL, false);
|
SendFriendResponse(requestor, requestee.get(), eAddFriendResponseType::YOURFRIENDSLISTFULL, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -241,10 +239,17 @@ void ChatPacketHandler::HandleFriendRequest(Packet* packet) {
|
|||||||
} else {
|
} else {
|
||||||
if (requestor->sysAddr != UNASSIGNED_SYSTEM_ADDRESS) SendFriendResponse(requestor, requestee.get(), eAddFriendResponseType::WAITINGAPPROVAL, true, true);
|
if (requestor->sysAddr != UNASSIGNED_SYSTEM_ADDRESS) SendFriendResponse(requestor, requestee.get(), eAddFriendResponseType::WAITINGAPPROVAL, true, true);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
auto maxFriends = playerContainer.GetMaxNumberOfFriends();
|
||||||
|
if (requestee->friends.size() >= maxFriends) {
|
||||||
|
SendFriendResponse(requestor, requestee.get(), eAddFriendResponseType::THEIRFRIENDLISTFULL, false);
|
||||||
|
} else if (requestor->friends.size() >= maxFriends) {
|
||||||
|
SendFriendResponse(requestor, requestee.get(), eAddFriendResponseType::YOURFRIENDSLISTFULL, false);
|
||||||
} else {
|
} else {
|
||||||
// Do not send this if we are requesting to be a best friend.
|
// Do not send this if we are requesting to be a best friend.
|
||||||
SendFriendRequest(requestee.get(), requestor);
|
SendFriendRequest(requestee.get(), requestor);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If the player is actually a player and not a ghost one defined above, release it from being deleted.
|
// If the player is actually a player and not a ghost one defined above, release it from being deleted.
|
||||||
if (requestee->sysAddr != UNASSIGNED_SYSTEM_ADDRESS) requestee.release();
|
if (requestee->sysAddr != UNASSIGNED_SYSTEM_ADDRESS) requestee.release();
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include "dConfig.h"
|
#include "dConfig.h"
|
||||||
|
|
||||||
PlayerContainer::PlayerContainer() {
|
PlayerContainer::PlayerContainer() {
|
||||||
|
GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("max_number_of_best_friends"), maxNumberOfBestFriends);
|
||||||
|
GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("max_number_of_friends"), maxNumberOfFriends);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerContainer::~PlayerContainer() {
|
PlayerContainer::~PlayerContainer() {
|
||||||
|
@ -67,6 +67,8 @@ public:
|
|||||||
std::u16string GetName(LWOOBJID playerID);
|
std::u16string GetName(LWOOBJID playerID);
|
||||||
LWOOBJID GetId(const std::u16string& playerName);
|
LWOOBJID GetId(const std::u16string& playerName);
|
||||||
bool GetIsMuted(PlayerData* data);
|
bool GetIsMuted(PlayerData* data);
|
||||||
|
uint32_t GetMaxNumberOfBestFriends() { return mMaxNumberOfBestFriends; }
|
||||||
|
uint32_t GetMaxNumberOfFriends() { return mMaxNumberOfFriends; }
|
||||||
|
|
||||||
std::map<LWOOBJID, PlayerData*>& GetAllPlayerData() { return mPlayers; }
|
std::map<LWOOBJID, PlayerData*>& GetAllPlayerData() { return mPlayers; }
|
||||||
|
|
||||||
@ -75,5 +77,7 @@ private:
|
|||||||
std::map<LWOOBJID, PlayerData*> mPlayers;
|
std::map<LWOOBJID, PlayerData*> mPlayers;
|
||||||
std::vector<TeamData*> mTeams;
|
std::vector<TeamData*> mTeams;
|
||||||
std::unordered_map<LWOOBJID, std::u16string> mNames;
|
std::unordered_map<LWOOBJID, std::u16string> mNames;
|
||||||
|
uint32_t mMaxNumberOfBestFriends = 5;
|
||||||
|
uint32_t mMaxNumberOfFriends = 50;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,2 +1,11 @@
|
|||||||
# Port number
|
# Port number
|
||||||
port=2005
|
port=2005
|
||||||
|
|
||||||
|
# If you would like to increase the maximum number of best friends a player can have on the server
|
||||||
|
# Change the value below to what you would like this to be (5 is live accurate)
|
||||||
|
max_number_of_best_friends=5
|
||||||
|
|
||||||
|
# If you would like to increase the maximum number of friends a player can have on the server
|
||||||
|
# Change the value below to what you would like this to be (50 is live accurate)
|
||||||
|
# going over 50 will be allowed in some secnarios, but proper handling will require client modding
|
||||||
|
max_number_of_friends=50
|
||||||
|
@ -40,10 +40,6 @@ classic_survival_scoring=0
|
|||||||
# If this value is 1, pets will consume imagination as they did in live. if 0 they will not consume imagination at all.
|
# If this value is 1, pets will consume imagination as they did in live. if 0 they will not consume imagination at all.
|
||||||
pets_take_imagination=1
|
pets_take_imagination=1
|
||||||
|
|
||||||
# If you would like to increase the maximum number of best friends a player can have on the server
|
|
||||||
# Change the value below to what you would like this to be (5 is live accurate)
|
|
||||||
max_number_of_best_friends=5
|
|
||||||
|
|
||||||
# Disables loot drops
|
# Disables loot drops
|
||||||
disable_drops=0
|
disable_drops=0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user