mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-22 13:33:35 +00:00
chore: split out slash commands into multiple files (#1539)
* chore: split out slash commands into multiple files Breakup the monolithic file don't register slashcommands on startup * fix typo
This commit is contained in:
parent
1ee45639af
commit
d067a8d12f
@ -8,9 +8,15 @@ set(DGAME_DUTILITIES_SOURCES "BrickDatabase.cpp"
|
||||
"SlashCommandHandler.cpp"
|
||||
"VanityUtilities.cpp")
|
||||
|
||||
add_subdirectory(SlashCommands)
|
||||
|
||||
foreach(file ${DGAME_DUTILITIES_SLASHCOMMANDS})
|
||||
set(DGAME_DUTILITIES_SOURCES ${DGAME_DUTILITIES_SOURCES} "SlashCommands/${file}")
|
||||
endforeach()
|
||||
|
||||
add_library(dUtilities OBJECT ${DGAME_DUTILITIES_SOURCES})
|
||||
target_precompile_headers(dUtilities REUSE_FROM dGameBase)
|
||||
target_include_directories(dUtilities PUBLIC "."
|
||||
target_include_directories(dUtilities PUBLIC "." "SlashCommands"
|
||||
PRIVATE
|
||||
"${PROJECT_SOURCE_DIR}/dGame/dComponents"
|
||||
"${PROJECT_SOURCE_DIR}/dGame/dInventory" # transitive via PossessableComponent.h
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,114 +21,14 @@ struct Command {
|
||||
};
|
||||
|
||||
namespace SlashCommandHandler {
|
||||
void Startup();
|
||||
void HandleChatCommand(const std::u16string& command, Entity* entity, const SystemAddress& sysAddr);
|
||||
void SendAnnouncement(const std::string& title, const std::string& message);
|
||||
void RegisterCommand(Command info);
|
||||
void Startup();
|
||||
};
|
||||
|
||||
namespace DEVGMCommands {
|
||||
void SetGMLevel(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ToggleNameplate(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ToggleSkipCinematics(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Kill(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Metrics(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Announce(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetAnnTitle(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetAnnMsg(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ShutdownUniverse(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetMinifig(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void TestMap(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ReportProxPhys(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SpawnPhysicsVerts(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Teleport(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ActivateSpawner(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void AddMission(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Boost(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Unboost(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Buff(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void BuffMe(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void BuffMed(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ClearFlag(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void CompleteMission(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void CreatePrivate(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void DebugUi(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Dismount(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ReloadConfig(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ForceSave(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Freecam(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void FreeMoney(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GetNavmeshHeight(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GiveUScore(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GmAddItem(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Inspect(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ListSpawns(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void LocRow(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Lookup(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void PlayAnimation(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void PlayEffect(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void PlayLvlFx(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void PlayRebuildFx(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Pos(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void RefillStats(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Reforge(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ResetMission(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Rot(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void RunMacro(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetControlScheme(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetCurrency(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetFlag(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetInventorySize(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetUiState(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Spawn(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SpawnGroup(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SpeedBoost(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void StartCelebration(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void StopEffect(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Toggle(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void TpAll(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void TriggerSpawner(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void UnlockEmote(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetLevel(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetSkillSlot(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetFaction(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void AddFaction(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GetFactions(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetRewardCode(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Crash(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void RollLoot(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void CastSkill(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void DeleteInven(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
}
|
||||
|
||||
namespace GMZeroCommands {
|
||||
void Help(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Credits(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Info(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Die(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Ping(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Pvp(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void RequestMailCount(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Who(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void FixStats(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Join(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void LeaveZone(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Resurrect(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void InstanceInfo(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
}
|
||||
|
||||
namespace GMGreaterThanZeroCommands {
|
||||
void Kick(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void MailItem(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Ban(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ApproveProperty(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Mute(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Fly(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void AttackImmune(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GmImmune(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GmInvis(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetName(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Title(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
}
|
||||
|
||||
#endif // SLASHCOMMANDHANDLER_H
|
||||
|
6
dGame/dUtilities/SlashCommands/CMakeLists.txt
Normal file
6
dGame/dUtilities/SlashCommands/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
||||
set(DGAME_DUTILITIES_SLASHCOMMANDS
|
||||
"DEVGMCommands.cpp"
|
||||
"GMGreaterThanZeroCommands.cpp"
|
||||
"GMZeroCommands.cpp"
|
||||
PARENT_SCOPE
|
||||
)
|
1592
dGame/dUtilities/SlashCommands/DEVGMCommands.cpp
Normal file
1592
dGame/dUtilities/SlashCommands/DEVGMCommands.cpp
Normal file
File diff suppressed because it is too large
Load Diff
73
dGame/dUtilities/SlashCommands/DEVGMCommands.h
Normal file
73
dGame/dUtilities/SlashCommands/DEVGMCommands.h
Normal file
@ -0,0 +1,73 @@
|
||||
namespace DEVGMCommands {
|
||||
void SetGMLevel(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ToggleNameplate(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ToggleSkipCinematics(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Kill(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Metrics(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Announce(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetAnnTitle(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetAnnMsg(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ShutdownUniverse(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetMinifig(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void TestMap(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ReportProxPhys(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SpawnPhysicsVerts(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Teleport(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ActivateSpawner(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void AddMission(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Boost(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Unboost(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Buff(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void BuffMe(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void BuffMed(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ClearFlag(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void CompleteMission(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void CreatePrivate(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void DebugUi(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Dismount(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ReloadConfig(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ForceSave(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Freecam(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void FreeMoney(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GetNavmeshHeight(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GiveUScore(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GmAddItem(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Inspect(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ListSpawns(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void LocRow(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Lookup(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void PlayAnimation(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void PlayEffect(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void PlayLvlFx(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void PlayRebuildFx(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Pos(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void RefillStats(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Reforge(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ResetMission(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Rot(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void RunMacro(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetControlScheme(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetCurrency(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetFlag(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetInventorySize(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetUiState(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Spawn(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SpawnGroup(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SpeedBoost(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void StartCelebration(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void StopEffect(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Toggle(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void TpAll(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void TriggerSpawner(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void UnlockEmote(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetLevel(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetSkillSlot(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetFaction(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void AddFaction(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GetFactions(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetRewardCode(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Crash(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void RollLoot(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void CastSkill(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void DeleteInven(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
}
|
290
dGame/dUtilities/SlashCommands/GMGreaterThanZeroCommands.cpp
Normal file
290
dGame/dUtilities/SlashCommands/GMGreaterThanZeroCommands.cpp
Normal file
@ -0,0 +1,290 @@
|
||||
#include "GMGreaterThanZeroCommands.h"
|
||||
|
||||
// Classes
|
||||
#include "Character.h"
|
||||
#include "ChatPackets.h"
|
||||
#include "dServer.h"
|
||||
#include "PlayerManager.h"
|
||||
#include "User.h"
|
||||
|
||||
// Database
|
||||
#include "Database.h"
|
||||
|
||||
// Components
|
||||
#include "DestroyableComponent.h"
|
||||
#include "PropertyManagementComponent.h"
|
||||
|
||||
// Enums
|
||||
#include "eChatMessageType.h"
|
||||
#include "eServerDisconnectIdentifiers.h"
|
||||
#include "eObjectBits.h"
|
||||
|
||||
namespace GMGreaterThanZeroCommands {
|
||||
|
||||
void Kick(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto splitArgs = GeneralUtils::SplitString(args, ' ');
|
||||
if (splitArgs.size() == 1) {
|
||||
auto* player = PlayerManager::GetPlayer(splitArgs[0]);
|
||||
|
||||
std::u16string username = GeneralUtils::UTF8ToUTF16(splitArgs[0]);
|
||||
if (player == nullptr) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Count not find player of name: " + username);
|
||||
return;
|
||||
}
|
||||
|
||||
Game::server->Disconnect(player->GetSystemAddress(), eServerDisconnectIdentifiers::KICK);
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Kicked: " + username);
|
||||
} else {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /kick <username>");
|
||||
}
|
||||
}
|
||||
|
||||
void Ban(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto splitArgs = GeneralUtils::SplitString(args, ' ');
|
||||
|
||||
if (splitArgs.size() == 1) {
|
||||
auto* player = PlayerManager::GetPlayer(splitArgs[0]);
|
||||
|
||||
uint32_t accountId = 0;
|
||||
|
||||
if (player == nullptr) {
|
||||
auto characterInfo = Database::Get()->GetCharacterInfo(splitArgs[0]);
|
||||
|
||||
if (characterInfo) {
|
||||
accountId = characterInfo->accountId;
|
||||
}
|
||||
|
||||
if (accountId == 0) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Count not find player of name: " + GeneralUtils::UTF8ToUTF16(splitArgs[0]));
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
auto* character = player->GetCharacter();
|
||||
auto* user = character != nullptr ? character->GetParentUser() : nullptr;
|
||||
if (user) accountId = user->GetAccountID();
|
||||
}
|
||||
|
||||
if (accountId != 0) Database::Get()->UpdateAccountBan(accountId, true);
|
||||
|
||||
if (player != nullptr) {
|
||||
Game::server->Disconnect(player->GetSystemAddress(), eServerDisconnectIdentifiers::FREE_TRIAL_EXPIRED);
|
||||
}
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Banned: " + GeneralUtils::ASCIIToUTF16(splitArgs[0]));
|
||||
} else {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /ban <username>");
|
||||
}
|
||||
}
|
||||
|
||||
void MailItem(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto splitArgs = GeneralUtils::SplitString(args, ' ');
|
||||
if (splitArgs.size() < 2) return;
|
||||
|
||||
const auto& playerName = splitArgs[0];
|
||||
|
||||
auto playerInfo = Database::Get()->GetCharacterInfo(playerName);
|
||||
|
||||
uint32_t receiverID = 0;
|
||||
if (!playerInfo) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Failed to find that player");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
receiverID = playerInfo->id;
|
||||
|
||||
const auto lot = GeneralUtils::TryParse<LOT>(splitArgs.at(1));
|
||||
|
||||
if (!lot) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid item lot.");
|
||||
return;
|
||||
}
|
||||
|
||||
IMail::MailInfo mailInsert;
|
||||
mailInsert.senderId = entity->GetObjectID();
|
||||
mailInsert.senderUsername = "Darkflame Universe";
|
||||
mailInsert.receiverId = receiverID;
|
||||
mailInsert.recipient = playerName;
|
||||
mailInsert.subject = "Lost item";
|
||||
mailInsert.body = "This is a replacement item for one you lost.";
|
||||
mailInsert.itemID = LWOOBJID_EMPTY;
|
||||
mailInsert.itemLOT = lot.value();
|
||||
mailInsert.itemSubkey = LWOOBJID_EMPTY;
|
||||
mailInsert.itemCount = 1;
|
||||
Database::Get()->InsertNewMail(mailInsert);
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Mail sent");
|
||||
}
|
||||
|
||||
void ApproveProperty(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
if (PropertyManagementComponent::Instance() != nullptr) {
|
||||
PropertyManagementComponent::Instance()->UpdateApprovedStatus(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Mute(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto splitArgs = GeneralUtils::SplitString(args, ' ');
|
||||
|
||||
if (splitArgs.size() >= 1) {
|
||||
auto* player = PlayerManager::GetPlayer(splitArgs[0]);
|
||||
|
||||
uint32_t accountId = 0;
|
||||
LWOOBJID characterId = 0;
|
||||
|
||||
if (player == nullptr) {
|
||||
auto characterInfo = Database::Get()->GetCharacterInfo(splitArgs[0]);
|
||||
|
||||
if (characterInfo) {
|
||||
accountId = characterInfo->accountId;
|
||||
characterId = characterInfo->id;
|
||||
|
||||
GeneralUtils::SetBit(characterId, eObjectBits::CHARACTER);
|
||||
GeneralUtils::SetBit(characterId, eObjectBits::PERSISTENT);
|
||||
}
|
||||
|
||||
if (accountId == 0) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Count not find player of name: " + GeneralUtils::UTF8ToUTF16(splitArgs[0]));
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
auto* character = player->GetCharacter();
|
||||
auto* user = character != nullptr ? character->GetParentUser() : nullptr;
|
||||
if (user) accountId = user->GetAccountID();
|
||||
characterId = player->GetObjectID();
|
||||
}
|
||||
|
||||
time_t expire = 1; // Default to indefinate mute
|
||||
|
||||
if (splitArgs.size() >= 2) {
|
||||
const auto days = GeneralUtils::TryParse<uint32_t>(splitArgs[1]);
|
||||
if (!days) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid days.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::optional<uint32_t> hours;
|
||||
if (splitArgs.size() >= 3) {
|
||||
hours = GeneralUtils::TryParse<uint32_t>(splitArgs[2]);
|
||||
if (!hours) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid hours.");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
expire = time(NULL);
|
||||
expire += 24 * 60 * 60 * days.value();
|
||||
expire += 60 * 60 * hours.value_or(0);
|
||||
}
|
||||
|
||||
if (accountId != 0) Database::Get()->UpdateAccountUnmuteTime(accountId, expire);
|
||||
|
||||
char buffer[32] = "brought up for review.\0";
|
||||
|
||||
if (expire != 1) {
|
||||
std::tm* ptm = std::localtime(&expire);
|
||||
// Format: Mo, 15.06.2009 20:20:00
|
||||
std::strftime(buffer, 32, "%a, %d.%m.%Y %H:%M:%S", ptm);
|
||||
}
|
||||
|
||||
const auto timeStr = GeneralUtils::ASCIIToUTF16(std::string(buffer));
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Muted: " + GeneralUtils::UTF8ToUTF16(splitArgs[0]) + u" until " + timeStr);
|
||||
|
||||
//Notify chat about it
|
||||
CBITSTREAM;
|
||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::CHAT, eChatMessageType::GM_MUTE);
|
||||
|
||||
bitStream.Write(characterId);
|
||||
bitStream.Write(expire);
|
||||
|
||||
Game::chatServer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE, 0, Game::chatSysAddr, false);
|
||||
} else {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /mute <username> <days (optional)> <hours (optional)>");
|
||||
}
|
||||
}
|
||||
|
||||
void Fly(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto splitArgs = GeneralUtils::SplitString(args, ' ');
|
||||
auto* character = entity->GetCharacter();
|
||||
|
||||
if (character) {
|
||||
bool isFlying = character->GetIsFlying();
|
||||
|
||||
if (isFlying) {
|
||||
GameMessages::SendSetJetPackMode(entity, false);
|
||||
|
||||
character->SetIsFlying(false);
|
||||
} else {
|
||||
float speedScale = 1.0f;
|
||||
|
||||
if (splitArgs.size() >= 1) {
|
||||
const auto tempScaleStore = GeneralUtils::TryParse<float>(splitArgs.at(0));
|
||||
|
||||
if (tempScaleStore) {
|
||||
speedScale = tempScaleStore.value();
|
||||
} else {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Failed to parse speed scale argument.");
|
||||
}
|
||||
}
|
||||
|
||||
float airSpeed = 20 * speedScale;
|
||||
float maxAirSpeed = 30 * speedScale;
|
||||
float verticalVelocity = 1.5 * speedScale;
|
||||
|
||||
GameMessages::SendSetJetPackMode(entity, true, true, false, 167, airSpeed, maxAirSpeed, verticalVelocity);
|
||||
|
||||
character->SetIsFlying(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AttackImmune(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto splitArgs = GeneralUtils::SplitString(args, ' ');
|
||||
if (splitArgs.empty()) return;
|
||||
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
|
||||
const auto state = GeneralUtils::TryParse<int32_t>(splitArgs[0]);
|
||||
|
||||
if (!state) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid state.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (destroyableComponent) destroyableComponent->SetIsImmune(state.value());
|
||||
}
|
||||
|
||||
void GmImmune(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto splitArgs = GeneralUtils::SplitString(args, ' ');
|
||||
if (splitArgs.empty()) return;
|
||||
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
|
||||
const auto state = GeneralUtils::TryParse<int32_t>(splitArgs[0]);
|
||||
|
||||
if (!state) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid state.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (destroyableComponent) destroyableComponent->SetIsGMImmune(state.value());
|
||||
}
|
||||
|
||||
void GmInvis(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
GameMessages::SendToggleGMInvis(entity->GetObjectID(), true, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
void SetName(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
GameMessages::SendSetName(entity->GetObjectID(), GeneralUtils::UTF8ToUTF16(args), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
|
||||
void Title(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
std::string name = entity->GetCharacter()->GetName() + " - " + args;
|
||||
GameMessages::SendSetName(entity->GetObjectID(), GeneralUtils::UTF8ToUTF16(name), UNASSIGNED_SYSTEM_ADDRESS);
|
||||
}
|
||||
}
|
13
dGame/dUtilities/SlashCommands/GMGreaterThanZeroCommands.h
Normal file
13
dGame/dUtilities/SlashCommands/GMGreaterThanZeroCommands.h
Normal file
@ -0,0 +1,13 @@
|
||||
namespace GMGreaterThanZeroCommands {
|
||||
void Kick(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void MailItem(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Ban(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void ApproveProperty(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Mute(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Fly(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void AttackImmune(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GmImmune(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void GmInvis(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void SetName(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Title(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
}
|
228
dGame/dUtilities/SlashCommands/GMZeroCommands.cpp
Normal file
228
dGame/dUtilities/SlashCommands/GMZeroCommands.cpp
Normal file
@ -0,0 +1,228 @@
|
||||
#include "GMZeroCommands.h"
|
||||
|
||||
// Classes
|
||||
#include "Amf3.h"
|
||||
#include "BinaryPathFinder.h"
|
||||
#include "ChatPackets.h"
|
||||
#include "dServer.h"
|
||||
#include "dZoneManager.h"
|
||||
#include "Mail.h"
|
||||
#include "PlayerManager.h"
|
||||
#include "SlashCommandHandler.h"
|
||||
#include "VanityUtilities.h"
|
||||
#include "WorldPackets.h"
|
||||
#include "ZoneInstanceManager.h"
|
||||
|
||||
// Components
|
||||
#include "BuffComponent.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "ScriptedActivityComponent.h"
|
||||
#include "SkillComponent.h"
|
||||
|
||||
// Emuns
|
||||
#include "eGameMasterLevel.h"
|
||||
|
||||
namespace GMZeroCommands {
|
||||
void Pvp(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
auto* character = entity->GetComponent<CharacterComponent>();
|
||||
|
||||
if (character == nullptr) {
|
||||
LOG("Failed to find character component!");
|
||||
return;
|
||||
}
|
||||
|
||||
character->SetPvpEnabled(!character->GetPvpEnabled());
|
||||
Game::entityManager->SerializeEntity(entity);
|
||||
|
||||
std::stringstream message;
|
||||
message << character->GetName() << " changed their PVP flag to " << std::to_string(character->GetPvpEnabled()) << "!";
|
||||
|
||||
ChatPackets::SendSystemMessage(UNASSIGNED_SYSTEM_ADDRESS, GeneralUtils::UTF8ToUTF16(message.str()), true);
|
||||
}
|
||||
|
||||
void Who(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
ChatPackets::SendSystemMessage(
|
||||
sysAddr,
|
||||
u"Players in this instance: (" + GeneralUtils::to_u16string(PlayerManager::GetAllPlayers().size()) + u")"
|
||||
);
|
||||
|
||||
for (auto* player : PlayerManager::GetAllPlayers()) {
|
||||
const auto& name = player->GetCharacter()->GetName();
|
||||
|
||||
ChatPackets::SendSystemMessage(
|
||||
sysAddr,
|
||||
GeneralUtils::UTF8ToUTF16(player == entity ? name + " (you)" : name)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Ping(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
if (!args.empty() && args.starts_with("-l")) {
|
||||
std::stringstream message;
|
||||
message << "Your latest ping: " << std::to_string(Game::server->GetLatestPing(sysAddr)) << "ms";
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::ASCIIToUTF16(message.str()));
|
||||
} else {
|
||||
std::stringstream message;
|
||||
message << "Your average ping: " << std::to_string(Game::server->GetPing(sysAddr)) << "ms";
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::ASCIIToUTF16(message.str()));
|
||||
}
|
||||
}
|
||||
|
||||
void FixStats(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
// Reset skill component and buff component
|
||||
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
||||
auto* buffComponent = entity->GetComponent<BuffComponent>();
|
||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||
|
||||
// If any of the components are nullptr, return
|
||||
if (skillComponent == nullptr || buffComponent == nullptr || destroyableComponent == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset skill component
|
||||
skillComponent->Reset();
|
||||
|
||||
// Reset buff component
|
||||
buffComponent->Reset();
|
||||
|
||||
// Fix the destroyable component
|
||||
destroyableComponent->FixStats();
|
||||
}
|
||||
|
||||
void Credits(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto& customText = VanityUtilities::ParseMarkdown((BinaryPathFinder::GetBinaryDir() / "vanity/CREDITS.md").string());
|
||||
|
||||
{
|
||||
AMFArrayValue args;
|
||||
|
||||
args.Insert("state", "Story");
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", args);
|
||||
}
|
||||
|
||||
entity->AddCallbackTimer(0.5f, [customText, entity]() {
|
||||
AMFArrayValue args;
|
||||
|
||||
args.Insert("visible", true);
|
||||
args.Insert("text", customText);
|
||||
|
||||
LOG("Sending %s", customText.c_str());
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "ToggleStoryBox", args);
|
||||
});
|
||||
}
|
||||
|
||||
void Info(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto& customText = VanityUtilities::ParseMarkdown((BinaryPathFinder::GetBinaryDir() / "vanity/INFO.md").string());
|
||||
|
||||
{
|
||||
AMFArrayValue args;
|
||||
|
||||
args.Insert("state", "Story");
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "pushGameState", args);
|
||||
}
|
||||
|
||||
entity->AddCallbackTimer(0.5f, [customText, entity]() {
|
||||
AMFArrayValue args;
|
||||
|
||||
args.Insert("visible", true);
|
||||
args.Insert("text", customText);
|
||||
|
||||
LOG("Sending %s", customText.c_str());
|
||||
|
||||
GameMessages::SendUIMessageServerToSingleClient(entity, entity->GetSystemAddress(), "ToggleStoryBox", args);
|
||||
});
|
||||
}
|
||||
|
||||
void LeaveZone(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto currentZone = Game::zoneManager->GetZone()->GetZoneID().GetMapID();
|
||||
LWOMAPID newZone = 0;
|
||||
|
||||
if (currentZone == 1001 || currentZone % 100 == 0) {
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"You are not in an instanced zone.");
|
||||
return;
|
||||
} else {
|
||||
newZone = (currentZone / 100) * 100;
|
||||
}
|
||||
// If new zone would be inaccessible, then default to Avant Gardens.
|
||||
if (!Game::zoneManager->CheckIfAccessibleZone(newZone)) newZone = 1100;
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Leaving zone...");
|
||||
|
||||
const auto objid = entity->GetObjectID();
|
||||
|
||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, newZone, 0, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
||||
auto* entity = Game::entityManager->GetEntity(objid);
|
||||
|
||||
if (entity == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto sysAddr = entity->GetSystemAddress();
|
||||
|
||||
LOG("Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", entity->GetCharacter()->GetName().c_str(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
|
||||
|
||||
if (entity->GetCharacter()) {
|
||||
entity->GetCharacter()->SetZoneID(zoneID);
|
||||
entity->GetCharacter()->SetZoneInstance(zoneInstance);
|
||||
entity->GetCharacter()->SetZoneClone(zoneClone);
|
||||
}
|
||||
|
||||
entity->GetCharacter()->SaveXMLToDatabase();
|
||||
|
||||
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
|
||||
});
|
||||
}
|
||||
|
||||
void Join(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
auto splitArgs = GeneralUtils::SplitString(args, ' ');
|
||||
if (splitArgs.empty()) return;
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Requesting private map...");
|
||||
const auto& password = splitArgs[0];
|
||||
|
||||
ZoneInstanceManager::Instance()->RequestPrivateZone(Game::server, false, password, [=](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
||||
LOG("Transferring %s to Zone %i (Instance %i | Clone %i | Mythran Shift: %s) with IP %s and Port %i", sysAddr.ToString(), zoneID, zoneInstance, zoneClone, mythranShift == true ? "true" : "false", serverIP.c_str(), serverPort);
|
||||
|
||||
if (entity->GetCharacter()) {
|
||||
entity->GetCharacter()->SetZoneID(zoneID);
|
||||
entity->GetCharacter()->SetZoneInstance(zoneInstance);
|
||||
entity->GetCharacter()->SetZoneClone(zoneClone);
|
||||
}
|
||||
|
||||
entity->GetCharacter()->SaveXMLToDatabase();
|
||||
|
||||
WorldPackets::SendTransferToWorld(sysAddr, serverIP, serverPort, mythranShift);
|
||||
});
|
||||
}
|
||||
|
||||
void Die(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
entity->Smash(entity->GetObjectID());
|
||||
}
|
||||
|
||||
void Resurrect(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
ScriptedActivityComponent* scriptedActivityComponent = Game::zoneManager->GetZoneControlObject()->GetComponent<ScriptedActivityComponent>();
|
||||
|
||||
if (scriptedActivityComponent) { // check if user is in activity world and if so, they can't resurrect
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"You cannot resurrect in an activity world.");
|
||||
return;
|
||||
}
|
||||
|
||||
GameMessages::SendResurrect(entity);
|
||||
}
|
||||
|
||||
void RequestMailCount(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
Mail::HandleNotificationRequest(entity->GetSystemAddress(), entity->GetObjectID());
|
||||
}
|
||||
|
||||
void InstanceInfo(Entity* entity, const SystemAddress& sysAddr, const std::string args) {
|
||||
const auto zoneId = Game::zoneManager->GetZone()->GetZoneID();
|
||||
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Map: " + (GeneralUtils::to_u16string(zoneId.GetMapID())) + u"\nClone: " + (GeneralUtils::to_u16string(zoneId.GetCloneID())) + u"\nInstance: " + (GeneralUtils::to_u16string(zoneId.GetInstanceID())));
|
||||
}
|
||||
};
|
||||
|
15
dGame/dUtilities/SlashCommands/GMZeroCommands.h
Normal file
15
dGame/dUtilities/SlashCommands/GMZeroCommands.h
Normal file
@ -0,0 +1,15 @@
|
||||
namespace GMZeroCommands {
|
||||
void Help(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Credits(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Info(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Die(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Ping(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Pvp(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void RequestMailCount(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Who(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void FixStats(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Join(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void LeaveZone(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void Resurrect(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
void InstanceInfo(Entity* entity, const SystemAddress& sysAddr, const std::string args);
|
||||
}
|
@ -314,8 +314,8 @@ int main(int argc, char** argv) {
|
||||
uint32_t sqlPingTime = 10 * 60 * currentFramerate; // 10 minutes in frames
|
||||
uint32_t emptyShutdownTime = (cloneID == 0 ? 30 : 5) * 60 * currentFramerate; // 30 minutes for main worlds, 5 for all others.
|
||||
|
||||
// Register slash commands
|
||||
SlashCommandHandler::Startup();
|
||||
// Register slash commands if not in zone 0
|
||||
if (zoneID != 0) SlashCommandHandler::Startup();
|
||||
|
||||
Game::logger->Flush(); // once immediately before the main loop
|
||||
while (true) {
|
||||
|
Loading…
Reference in New Issue
Block a user