mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-15 03:48:07 +00:00
Merge branch 'main' into fix/cmake-libs-2
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "UserManager.h"
|
||||
#include "dConfig.h"
|
||||
#include <optional>
|
||||
#include "PlayerManager.h"
|
||||
|
||||
Entity* GetPossessedEntity(const LWOOBJID& objId) {
|
||||
auto* entity = Game::entityManager->GetEntity(objId);
|
||||
@@ -49,7 +50,7 @@ void LogAndSaveFailedAntiCheatCheck(const LWOOBJID& id, const SystemAddress& sys
|
||||
User* toReport = nullptr;
|
||||
switch (checkType) {
|
||||
case CheckType::Entity: {
|
||||
auto* player = Player::GetPlayer(sysAddr);
|
||||
auto* player = PlayerManager::GetPlayer(sysAddr);
|
||||
auto* entity = GetPossessedEntity(id);
|
||||
|
||||
// If player exists and entity exists in world, use both for logging info.
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#include "dServer.h"
|
||||
#include "Entity.h"
|
||||
#include "Character.h"
|
||||
#include "PacketUtils.h"
|
||||
#include "BitStreamUtils.h"
|
||||
#include "Logger.h"
|
||||
#include "EntityManager.h"
|
||||
@@ -305,7 +304,6 @@ void Mail::HandleDataRequest(RakNet::BitStream* packet, const SystemAddress& sys
|
||||
}
|
||||
|
||||
Game::server->Send(&bitStream, sysAddr, false);
|
||||
// PacketUtils::SavePacket("Max_Mail_Data.bin", (const char*)bitStream.GetData(), bitStream.GetNumberOfBytesUsed());
|
||||
}
|
||||
|
||||
void Mail::HandleAttachmentCollect(RakNet::BitStream* packet, const SystemAddress& sysAddr, Entity* player) {
|
||||
|
@@ -82,11 +82,13 @@
|
||||
#include "eConnectionType.h"
|
||||
#include "eChatInternalMessageType.h"
|
||||
#include "eMasterMessageType.h"
|
||||
#include "PlayerManager.h"
|
||||
|
||||
#include "CDRewardCodesTable.h"
|
||||
#include "CDObjectsTable.h"
|
||||
#include "CDZoneTableTable.h"
|
||||
#include "ePlayerFlag.h"
|
||||
#include "dNavMesh.h"
|
||||
|
||||
void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entity* entity, const SystemAddress& sysAddr) {
|
||||
auto commandCopy = command;
|
||||
@@ -214,10 +216,10 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if (chatCommand == "who") {
|
||||
ChatPackets::SendSystemMessage(
|
||||
sysAddr,
|
||||
u"Players in this instance: (" + GeneralUtils::to_u16string(Player::GetAllPlayers().size()) + u")"
|
||||
u"Players in this instance: (" + GeneralUtils::to_u16string(PlayerManager::GetAllPlayers().size()) + u")"
|
||||
);
|
||||
|
||||
for (auto* player : Player::GetAllPlayers()) {
|
||||
for (auto* player : PlayerManager::GetAllPlayers()) {
|
||||
const auto& name = player->GetCharacter()->GetName();
|
||||
|
||||
ChatPackets::SendSystemMessage(
|
||||
@@ -347,17 +349,6 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
});
|
||||
}
|
||||
|
||||
if (chatCommand == "resetmission") {
|
||||
uint32_t missionId;
|
||||
if (!GeneralUtils::TryParse(args[0], missionId)) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission ID.");
|
||||
return;
|
||||
}
|
||||
auto* missionComponent = entity->GetComponent<MissionComponent>();
|
||||
if (!missionComponent) return;
|
||||
missionComponent->ResetMission(missionId);
|
||||
}
|
||||
|
||||
if (user->GetMaxGMLevel() == eGameMasterLevel::CIVILIAN || entity->GetGMLevel() >= eGameMasterLevel::CIVILIAN) {
|
||||
if (chatCommand == "die") {
|
||||
entity->Smash(entity->GetObjectID());
|
||||
@@ -387,6 +378,18 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if (entity->GetGMLevel() == eGameMasterLevel::CIVILIAN) return;
|
||||
}
|
||||
|
||||
if (chatCommand == "resetmission" && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
uint32_t missionId;
|
||||
if (!GeneralUtils::TryParse(args[0], missionId)) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto* missionComponent = entity->GetComponent<MissionComponent>();
|
||||
if (!missionComponent) return;
|
||||
missionComponent->ResetMission(missionId);
|
||||
}
|
||||
|
||||
// Log command to database
|
||||
Database::Get()->InsertSlashCommandUsage(entity->GetObjectID(), chatCommand);
|
||||
|
||||
@@ -472,7 +475,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if (chatCommand == "kill" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Brutally murdering that player, if online on this server.");
|
||||
|
||||
auto* player = Player::GetPlayer(args[0]);
|
||||
auto* player = PlayerManager::GetPlayer(args[0]);
|
||||
if (player) {
|
||||
player->Smash(entity->GetObjectID());
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"It has been done, do you feel good about yourself now?");
|
||||
@@ -703,33 +706,6 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
entity->GetCharacter()->SetPlayerFlag(flagId, false);
|
||||
}
|
||||
|
||||
if (chatCommand == "resetmission" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
if (args.size() == 0) return;
|
||||
|
||||
uint32_t missionID;
|
||||
|
||||
if (!GeneralUtils::TryParse(args[0], missionID)) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission id.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto* comp = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION));
|
||||
|
||||
if (comp == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto* mission = comp->GetMission(missionID);
|
||||
|
||||
if (mission == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
mission->SetMissionState(eMissionState::ACTIVE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (chatCommand == "playeffect" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 3) {
|
||||
int32_t effectID = 0;
|
||||
|
||||
@@ -793,7 +769,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
auto control = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS));
|
||||
if (!control) return;
|
||||
|
||||
float y = dpWorld::Instance().GetNavMesh()->GetHeightAtPoint(control->GetPosition());
|
||||
float y = dpWorld::GetNavMesh()->GetHeightAtPoint(control->GetPosition());
|
||||
std::u16string msg = u"Navmesh height: " + (GeneralUtils::to_u16string(y));
|
||||
ChatPackets::SendSystemMessage(sysAddr, msg);
|
||||
}
|
||||
@@ -1019,7 +995,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
if (chatCommand == "mute" && entity->GetGMLevel() >= eGameMasterLevel::JUNIOR_DEVELOPER) {
|
||||
if (args.size() >= 1) {
|
||||
auto* player = Player::GetPlayer(args[0]);
|
||||
auto* player = PlayerManager::GetPlayer(args[0]);
|
||||
|
||||
uint32_t accountId = 0;
|
||||
LWOOBJID characterId = 0;
|
||||
@@ -1098,7 +1074,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
if (chatCommand == "kick" && entity->GetGMLevel() >= eGameMasterLevel::JUNIOR_MODERATOR) {
|
||||
if (args.size() == 1) {
|
||||
auto* player = Player::GetPlayer(args[0]);
|
||||
auto* player = PlayerManager::GetPlayer(args[0]);
|
||||
|
||||
std::u16string username = GeneralUtils::UTF8ToUTF16(args[0]);
|
||||
if (player == nullptr) {
|
||||
@@ -1116,7 +1092,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
|
||||
if (chatCommand == "ban" && entity->GetGMLevel() >= eGameMasterLevel::SENIOR_MODERATOR) {
|
||||
if (args.size() == 1) {
|
||||
auto* player = Player::GetPlayer(args[0]);
|
||||
auto* player = PlayerManager::GetPlayer(args[0]);
|
||||
|
||||
uint32_t accountId = 0;
|
||||
|
||||
@@ -1329,7 +1305,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if (args.size() > 1) {
|
||||
requestedPlayerToSetLevelOf = args[1];
|
||||
|
||||
auto requestedPlayer = Player::GetPlayer(requestedPlayerToSetLevelOf);
|
||||
auto requestedPlayer = PlayerManager::GetPlayer(requestedPlayerToSetLevelOf);
|
||||
|
||||
if (!requestedPlayer) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"No player found with username: (" + GeneralUtils::UTF8ToUTF16(requestedPlayerToSetLevelOf) + u").");
|
||||
@@ -1762,7 +1738,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if (chatCommand == "reloadconfig" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||
Game::config->ReloadConfig();
|
||||
VanityUtilities::SpawnVanity();
|
||||
dpWorld::Instance().Reload();
|
||||
dpWorld::Reload();
|
||||
auto entities = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
||||
for (auto entity : entities) {
|
||||
auto* scriptedActivityComponent = entity->GetComponent<ScriptedActivityComponent>();
|
||||
|
Reference in New Issue
Block a user