mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-18 17:55:27 +00:00
fix: check for the player before handling the messages a player sends
Several messages used the player, the character or the user they named without checking that there is one. A match request and a trade request are now only handled for the player that sent them, a linked mission request and a build mode change only for the sending player, and the remaining handlers return when the player, character or user is missing. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -114,8 +114,15 @@ namespace GameMessages {
|
||||
}
|
||||
|
||||
void ClientTradeRequest::Handle(Entity& entity, const SystemAddress& sysAddr) {
|
||||
// A player asks for their own trade
|
||||
if (!entity.IsPlayer() || entity.GetSystemAddress() != sysAddr) {
|
||||
LOG("Object %llu (LOT %i) is not the player that sent a trade request for it", entity.GetObjectID(), entity.GetLOT());
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the player has restricted trade access
|
||||
auto* character = entity.GetCharacter();
|
||||
if (!character || !character->GetParentUser()) return;
|
||||
const bool restrictTradeOnMute = UserManager::Instance()->GetMuteRestrictTrade();
|
||||
|
||||
if (character->HasPermission(ePermissionMap::RestrictedTradeAccess) || (restrictTradeOnMute && character->GetParentUser()->GetIsMuted())) {
|
||||
@@ -132,6 +139,7 @@ namespace GameMessages {
|
||||
|
||||
if (invitee != nullptr && invitee->IsPlayer()) {
|
||||
character = invitee->GetCharacter();
|
||||
if (!character || !character->GetParentUser()) return;
|
||||
|
||||
if (character->HasPermission(ePermissionMap::RestrictedTradeAccess) || (restrictTradeOnMute && character->GetParentUser()->GetIsMuted())) {
|
||||
// Send a message to the player
|
||||
|
||||
Reference in New Issue
Block a user