mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-17 17:25: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:
@@ -1,5 +1,6 @@
|
||||
#include "BuildingMessages.h"
|
||||
|
||||
#include "PlayerManager.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "Character.h"
|
||||
#include "ClientPackets.h"
|
||||
@@ -99,9 +100,8 @@ namespace GameMessages {
|
||||
|
||||
LOG("Handling start building with item (%i): (%d) (%d) (%i) (%llu) (%i) (%i) (%llu) (%i) (%i)", entity.GetLOT(), firstTime, success, sourceBag, sourceId, sourceLot, arrangedSourceType, targetId, targetLot, targetType);
|
||||
|
||||
auto* user = UserManager::Instance()->GetUser(sysAddr);
|
||||
|
||||
auto* player = Game::entityManager->GetEntity(user->GetLoggedInChar());
|
||||
auto* player = PlayerManager::GetPlayer(sysAddr);
|
||||
if (!player) return;
|
||||
|
||||
StartArrangingWithItem arranging;
|
||||
arranging.target = player->GetObjectID();
|
||||
@@ -435,7 +435,12 @@ namespace GameMessages {
|
||||
|
||||
void SetBuildMode::Handle(Entity& entity, const SystemAddress& sysAddr) {
|
||||
auto* player = Game::entityManager->GetEntity(playerId);
|
||||
if (!player || !player->GetCharacter()) return;
|
||||
|
||||
// A player sets their own build mode
|
||||
if (!player || !player->IsPlayer() || player->GetSystemAddress() != sysAddr || !player->GetCharacter()) {
|
||||
LOG("Player %llu of a build mode change is not the player that sent it", playerId);
|
||||
return;
|
||||
}
|
||||
|
||||
auto confirmedStartPos = startPos;
|
||||
if (confirmedStartPos == NiPoint3Constant::ZERO) {
|
||||
|
||||
Reference in New Issue
Block a user