mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-24 06:27:24 +00:00
refactor: Change TryParse implementation (#1442)
* Changed how the TryParse function works (and also did some general cleanup along the way) * Update noexcept attributes (verified these are correct) * Add fp overload for MacOS functionality * resolving some feedback * Split out unrelated changes to CleanupRoundup branch * Update in response to feedback * the consequences of emo's member variable renaming request * Revert "the consequences of emo's member variable renaming request" This reverts commitbf318caeda
. * Fully revert renaming attempt * Revert "the consequences of emo's member variable renaming request" This reverts commitbf318caeda
. Fully revert renaming attempt * Created ClientVersion.h and moved the client version defaults to it * Fix partial parsing and MacOS floating point errors * attempting fix to MacOS compiler error * syntax pass (should be the last commit unless the CI fails) * ah, wait, forgot to uncomment the preprocessor statements for MacOS. THIS should be the last commit pending CI * Okay, one last thing I noticed: We were including C headers here. Now they're C++ headers. Pinky swear this is it! * typo and I am OCD. please let this be the last * hash is usally but not always noexcept, so the specifier should go * Address MOST of the feedback * address the claim codes issue
This commit is contained in:
parent
62b670d283
commit
0c1ee0513d
@ -82,11 +82,11 @@ int main(int argc, char** argv) {
|
|||||||
Game::randomEngine = std::mt19937(time(0));
|
Game::randomEngine = std::mt19937(time(0));
|
||||||
|
|
||||||
//It's safe to pass 'localhost' here, as the IP is only used as the external IP.
|
//It's safe to pass 'localhost' here, as the IP is only used as the external IP.
|
||||||
uint32_t maxClients = 999;
|
|
||||||
uint32_t ourPort = 1001; //LU client is hardcoded to use this for auth port, so I'm making it the default.
|
|
||||||
std::string ourIP = "localhost";
|
std::string ourIP = "localhost";
|
||||||
GeneralUtils::TryParse(Game::config->GetValue("max_clients"), maxClients);
|
const uint32_t maxClients = GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("max_clients")).value_or(999);
|
||||||
GeneralUtils::TryParse(Game::config->GetValue("auth_server_port"), ourPort);
|
|
||||||
|
//LU client is hardcoded to use this for auth port, so I'm making it the default.
|
||||||
|
const uint32_t ourPort = GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("auth_server_port")).value_or(1001);
|
||||||
const auto externalIPString = Game::config->GetValue("external_ip");
|
const auto externalIPString = Game::config->GetValue("external_ip");
|
||||||
if (!externalIPString.empty()) ourIP = externalIPString;
|
if (!externalIPString.empty()) ourIP = externalIPString;
|
||||||
|
|
||||||
|
@ -99,18 +99,15 @@ int main(int argc, char** argv) {
|
|||||||
masterPort = masterInfo->port;
|
masterPort = masterInfo->port;
|
||||||
}
|
}
|
||||||
//It's safe to pass 'localhost' here, as the IP is only used as the external IP.
|
//It's safe to pass 'localhost' here, as the IP is only used as the external IP.
|
||||||
uint32_t maxClients = 999;
|
|
||||||
uint32_t ourPort = 1501;
|
|
||||||
std::string ourIP = "localhost";
|
std::string ourIP = "localhost";
|
||||||
GeneralUtils::TryParse(Game::config->GetValue("max_clients"), maxClients);
|
const uint32_t maxClients = GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("max_clients")).value_or(999);
|
||||||
GeneralUtils::TryParse(Game::config->GetValue("chat_server_port"), ourPort);
|
const uint32_t ourPort = GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("chat_server_port")).value_or(1501);
|
||||||
const auto externalIPString = Game::config->GetValue("external_ip");
|
const auto externalIPString = Game::config->GetValue("external_ip");
|
||||||
if (!externalIPString.empty()) ourIP = externalIPString;
|
if (!externalIPString.empty()) ourIP = externalIPString;
|
||||||
|
|
||||||
Game::server = new dServer(ourIP, ourPort, 0, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::Chat, Game::config, &Game::lastSignal);
|
Game::server = new dServer(ourIP, ourPort, 0, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::Chat, Game::config, &Game::lastSignal);
|
||||||
|
|
||||||
bool dontGenerateDCF = false;
|
const bool dontGenerateDCF = GeneralUtils::TryParse<bool>(Game::config->GetValue("dont_generate_dcf")).value_or(false);
|
||||||
GeneralUtils::TryParse(Game::config->GetValue("dont_generate_dcf"), dontGenerateDCF);
|
|
||||||
Game::chatFilter = new dChatFilter(Game::assetManager->GetResPath().string() + "/chatplus_en_us", dontGenerateDCF);
|
Game::chatFilter = new dChatFilter(Game::assetManager->GetResPath().string() + "/chatplus_en_us", dontGenerateDCF);
|
||||||
|
|
||||||
Game::randomEngine = std::mt19937(time(0));
|
Game::randomEngine = std::mt19937(time(0));
|
||||||
|
@ -15,8 +15,10 @@
|
|||||||
#include "dConfig.h"
|
#include "dConfig.h"
|
||||||
|
|
||||||
void PlayerContainer::Initialize() {
|
void PlayerContainer::Initialize() {
|
||||||
GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("max_number_of_best_friends"), m_MaxNumberOfBestFriends);
|
m_MaxNumberOfBestFriends =
|
||||||
GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("max_number_of_friends"), m_MaxNumberOfFriends);
|
GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("max_number_of_best_friends")).value_or(m_MaxNumberOfBestFriends);
|
||||||
|
m_MaxNumberOfFriends =
|
||||||
|
GeneralUtils::TryParse<uint32_t>(Game::config->GetValue("max_number_of_friends")).value_or(m_MaxNumberOfFriends);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerContainer::~PlayerContainer() {
|
PlayerContainer::~PlayerContainer() {
|
||||||
|
@ -319,7 +319,3 @@ std::vector<std::string> GeneralUtils::GetSqlFileNamesFromFolder(const std::stri
|
|||||||
|
|
||||||
return sortedFiles;
|
return sortedFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneralUtils::TryParse(const std::string& x, const std::string& y, const std::string& z, NiPoint3& dst) {
|
|
||||||
return TryParse<float>(x.c_str(), dst.x) && TryParse<float>(y.c_str(), dst.y) && TryParse<float>(z.c_str(), dst.z);
|
|
||||||
}
|
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// C++
|
// C++
|
||||||
#include <stdint.h>
|
#include <charconv>
|
||||||
|
#include <cstdint>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <time.h>
|
#include <ctime>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <string_view>
|
||||||
|
#include <optional>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include "BitStream.h"
|
#include "BitStream.h"
|
||||||
#include "NiPoint3.h"
|
#include "NiPoint3.h"
|
||||||
|
|
||||||
|
#include "dPlatforms.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
|
||||||
@ -123,90 +126,125 @@ namespace GeneralUtils {
|
|||||||
|
|
||||||
std::vector<std::string> GetSqlFileNamesFromFolder(const std::string& folder);
|
std::vector<std::string> GetSqlFileNamesFromFolder(const std::string& folder);
|
||||||
|
|
||||||
|
// Concept constraining to enum types
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T Parse(const char* value);
|
concept Enum = std::is_enum_v<T>;
|
||||||
|
|
||||||
template <>
|
|
||||||
inline bool Parse(const char* value) {
|
|
||||||
return std::stoi(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline int32_t Parse(const char* value) {
|
|
||||||
return std::stoi(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline int64_t Parse(const char* value) {
|
|
||||||
return std::stoll(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline float Parse(const char* value) {
|
|
||||||
return std::stof(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline double Parse(const char* value) {
|
|
||||||
return std::stod(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline uint16_t Parse(const char* value) {
|
|
||||||
return std::stoul(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline uint32_t Parse(const char* value) {
|
|
||||||
return std::stoul(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline uint64_t Parse(const char* value) {
|
|
||||||
return std::stoull(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline eInventoryType Parse(const char* value) {
|
|
||||||
return static_cast<eInventoryType>(std::stoul(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline eReplicaComponentType Parse(const char* value) {
|
|
||||||
return static_cast<eReplicaComponentType>(std::stoul(value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Concept constraining to numeric types
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool TryParse(const char* value, T& dst) {
|
concept Numeric = std::integral<T> || Enum<T> || std::floating_point<T>;
|
||||||
try {
|
|
||||||
dst = Parse<T>(value);
|
|
||||||
|
|
||||||
return true;
|
// Concept trickery to enable parsing underlying numeric types
|
||||||
} catch (...) {
|
template <Numeric T>
|
||||||
return false;
|
struct numeric_parse { using type = T; };
|
||||||
|
|
||||||
|
// If an enum, present an alias to its underlying type for parsing
|
||||||
|
template <Numeric T> requires Enum<T>
|
||||||
|
struct numeric_parse<T> { using type = std::underlying_type_t<T>; };
|
||||||
|
|
||||||
|
// If a boolean, present an alias to an intermediate integral type for parsing
|
||||||
|
template <Numeric T> requires std::same_as<T, bool>
|
||||||
|
struct numeric_parse<T> { using type = uint32_t; };
|
||||||
|
|
||||||
|
// Shorthand type alias
|
||||||
|
template <Numeric T>
|
||||||
|
using numeric_parse_t = numeric_parse<T>::type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For numeric values: Parses a string_view and returns an optional variable depending on the result.
|
||||||
|
* @param str The string_view to be evaluated
|
||||||
|
* @returns An std::optional containing the desired value if it is equivalent to the string
|
||||||
|
*/
|
||||||
|
template <Numeric T>
|
||||||
|
[[nodiscard]] std::optional<T> TryParse(const std::string_view str) {
|
||||||
|
numeric_parse_t<T> result;
|
||||||
|
|
||||||
|
const char* const strEnd = str.data() + str.size();
|
||||||
|
const auto [parseEnd, ec] = std::from_chars(str.data(), strEnd, result);
|
||||||
|
const bool isParsed = parseEnd == strEnd && ec == std::errc{};
|
||||||
|
|
||||||
|
return isParsed ? static_cast<T>(result) : std::optional<T>{};
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DARKFLAME_PLATFORM_MACOS
|
||||||
|
|
||||||
|
// Anonymous namespace containing MacOS floating-point parse function specializations
|
||||||
|
namespace {
|
||||||
|
template <std::floating_point T>
|
||||||
|
[[nodiscard]] T Parse(const std::string_view str, size_t* parseNum);
|
||||||
|
|
||||||
|
template <>
|
||||||
|
[[nodiscard]] float Parse<float>(const std::string_view str, size_t* parseNum) {
|
||||||
|
return std::stof(std::string{ str }, parseNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
[[nodiscard]] double Parse<double>(const std::string_view str, size_t* parseNum) {
|
||||||
|
return std::stod(std::string{ str }, parseNum);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
[[nodiscard]] long double Parse<long double>(const std::string_view str, size_t* parseNum) {
|
||||||
|
return std::stold(std::string{ str }, parseNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For floating-point values: Parses a string_view and returns an optional variable depending on the result.
|
||||||
|
* Note that this function overload is only included for MacOS, as from_chars will fulfill its purpose otherwise.
|
||||||
|
* @param str The string_view to be evaluated
|
||||||
|
* @returns An std::optional containing the desired value if it is equivalent to the string
|
||||||
|
*/
|
||||||
|
template <std::floating_point T>
|
||||||
|
[[nodiscard]] std::optional<T> TryParse(const std::string_view str) noexcept try {
|
||||||
|
size_t parseNum;
|
||||||
|
const T result = Parse<T>(str, &parseNum);
|
||||||
|
const bool isParsed = str.length() == parseNum;
|
||||||
|
|
||||||
|
return isParsed ? result : std::optional<T>{};
|
||||||
|
} catch (...) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TryParse overload for handling NiPoint3 by passing 3 seperate string references
|
||||||
|
* @param strX The string representing the X coordinate
|
||||||
|
* @param strY The string representing the Y coordinate
|
||||||
|
* @param strZ The string representing the Z coordinate
|
||||||
|
* @returns An std::optional containing the desired NiPoint3 if it can be constructed from the string parameters
|
||||||
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T Parse(const std::string& value) {
|
[[nodiscard]] std::optional<NiPoint3> TryParse(const std::string& strX, const std::string& strY, const std::string& strZ) {
|
||||||
return Parse<T>(value.c_str());
|
const auto x = TryParse<float>(strX);
|
||||||
|
if (!x) return std::nullopt;
|
||||||
|
|
||||||
|
const auto y = TryParse<float>(strY);
|
||||||
|
if (!y) return std::nullopt;
|
||||||
|
|
||||||
|
const auto z = TryParse<float>(strZ);
|
||||||
|
return z ? std::make_optional<NiPoint3>(x.value(), y.value(), z.value()) : std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The TryParse overload for handling NiPoint3 by passingn a reference to a vector of three strings
|
||||||
|
* @param str The string vector representing the X, Y, and Xcoordinates
|
||||||
|
* @returns An std::optional containing the desired NiPoint3 if it can be constructed from the string parameters
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
[[nodiscard]] std::optional<NiPoint3> TryParse(const std::vector<std::string>& str) {
|
||||||
|
return (str.size() == 3) ? TryParse<NiPoint3>(str[0], str[1], str[2]) : std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool TryParse(const std::string& value, T& dst) {
|
|
||||||
return TryParse<T>(value.c_str(), dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TryParse(const std::string& x, const std::string& y, const std::string& z, NiPoint3& dst);
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
std::u16string to_u16string(T value) {
|
std::u16string to_u16string(T value) {
|
||||||
return GeneralUtils::ASCIIToUTF16(std::to_string(value));
|
return GeneralUtils::ASCIIToUTF16(std::to_string(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// From boost::hash_combine
|
// From boost::hash_combine
|
||||||
template <class T>
|
template <class T>
|
||||||
void hash_combine(std::size_t& s, const T& v) {
|
constexpr void hash_combine(std::size_t& s, const T& v) {
|
||||||
std::hash<T> h;
|
std::hash<T> h;
|
||||||
s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2);
|
s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2);
|
||||||
}
|
}
|
||||||
@ -239,10 +277,8 @@ namespace GeneralUtils {
|
|||||||
* @param entry Enum entry to cast
|
* @param entry Enum entry to cast
|
||||||
* @returns The enum entry's value in its underlying type
|
* @returns The enum entry's value in its underlying type
|
||||||
*/
|
*/
|
||||||
template <typename eType>
|
template <Enum eType>
|
||||||
inline constexpr typename std::underlying_type_t<eType> CastUnderlyingType(const eType entry) {
|
constexpr typename std::underlying_type_t<eType> CastUnderlyingType(const eType entry) noexcept {
|
||||||
static_assert(std::is_enum_v<eType>, "Not an enum");
|
|
||||||
|
|
||||||
return static_cast<typename std::underlying_type_t<eType>>(entry);
|
return static_cast<typename std::underlying_type_t<eType>>(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,33 +61,33 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LDF_TYPE_S32: {
|
case LDF_TYPE_S32: {
|
||||||
int32_t data;
|
const auto data = GeneralUtils::TryParse<int32_t>(ldfTypeAndValue.second);
|
||||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
if (!data) {
|
||||||
LOG("Warning: Attempted to process invalid int32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
LOG("Warning: Attempted to process invalid int32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
returnValue = new LDFData<int32_t>(key, data);
|
returnValue = new LDFData<int32_t>(key, data.value());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LDF_TYPE_FLOAT: {
|
case LDF_TYPE_FLOAT: {
|
||||||
float data;
|
const auto data = GeneralUtils::TryParse<float>(ldfTypeAndValue.second);
|
||||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
if (!data) {
|
||||||
LOG("Warning: Attempted to process invalid float value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
LOG("Warning: Attempted to process invalid float value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
returnValue = new LDFData<float>(key, data);
|
returnValue = new LDFData<float>(key, data.value());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LDF_TYPE_DOUBLE: {
|
case LDF_TYPE_DOUBLE: {
|
||||||
double data;
|
const auto data = GeneralUtils::TryParse<double>(ldfTypeAndValue.second);
|
||||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
if (!data) {
|
||||||
LOG("Warning: Attempted to process invalid double value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
LOG("Warning: Attempted to process invalid double value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
returnValue = new LDFData<double>(key, data);
|
returnValue = new LDFData<double>(key, data.value());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,10 +100,12 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) {
|
|||||||
} else if (ldfTypeAndValue.second == "false") {
|
} else if (ldfTypeAndValue.second == "false") {
|
||||||
data = 0;
|
data = 0;
|
||||||
} else {
|
} else {
|
||||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
const auto dataOptional = GeneralUtils::TryParse<uint32_t>(ldfTypeAndValue.second);
|
||||||
|
if (!dataOptional) {
|
||||||
LOG("Warning: Attempted to process invalid uint32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
LOG("Warning: Attempted to process invalid uint32 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
data = dataOptional.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
returnValue = new LDFData<uint32_t>(key, data);
|
returnValue = new LDFData<uint32_t>(key, data);
|
||||||
@ -118,10 +120,12 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) {
|
|||||||
} else if (ldfTypeAndValue.second == "false") {
|
} else if (ldfTypeAndValue.second == "false") {
|
||||||
data = false;
|
data = false;
|
||||||
} else {
|
} else {
|
||||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
const auto dataOptional = GeneralUtils::TryParse<bool>(ldfTypeAndValue.second);
|
||||||
|
if (!dataOptional) {
|
||||||
LOG("Warning: Attempted to process invalid bool value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
LOG("Warning: Attempted to process invalid bool value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
data = dataOptional.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
returnValue = new LDFData<bool>(key, data);
|
returnValue = new LDFData<bool>(key, data);
|
||||||
@ -129,22 +133,22 @@ LDFBaseData* LDFBaseData::DataFromString(const std::string_view& format) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LDF_TYPE_U64: {
|
case LDF_TYPE_U64: {
|
||||||
uint64_t data;
|
const auto data = GeneralUtils::TryParse<uint64_t>(ldfTypeAndValue.second);
|
||||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
if (!data) {
|
||||||
LOG("Warning: Attempted to process invalid uint64 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
LOG("Warning: Attempted to process invalid uint64 value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
returnValue = new LDFData<uint64_t>(key, data);
|
returnValue = new LDFData<uint64_t>(key, data.value());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LDF_TYPE_OBJID: {
|
case LDF_TYPE_OBJID: {
|
||||||
LWOOBJID data;
|
const auto data = GeneralUtils::TryParse<LWOOBJID>(ldfTypeAndValue.second);
|
||||||
if (!GeneralUtils::TryParse(ldfTypeAndValue.second.data(), data)) {
|
if (!data) {
|
||||||
LOG("Warning: Attempted to process invalid LWOOBJID value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
LOG("Warning: Attempted to process invalid LWOOBJID value (%s) from string (%s)", ldfTypeAndValue.second.data(), format.data());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
returnValue = new LDFData<LWOOBJID>(key, data);
|
returnValue = new LDFData<LWOOBJID>(key, data.value());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
set(DCOMMON_DCLIENT_SOURCES
|
set(DCOMMON_DCLIENT_SOURCES
|
||||||
|
"AssetManager.cpp"
|
||||||
"PackIndex.cpp"
|
"PackIndex.cpp"
|
||||||
"Pack.cpp"
|
"Pack.cpp"
|
||||||
"AssetManager.cpp"
|
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
12
dCommon/dClient/ClientVersion.h
Normal file
12
dCommon/dClient/ClientVersion.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef __CLIENTVERSION_H__
|
||||||
|
#define __CLIENTVERSION_H__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace ClientVersion {
|
||||||
|
constexpr uint16_t major = 1;
|
||||||
|
constexpr uint16_t current = 10;
|
||||||
|
constexpr uint16_t minor = 64;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // !__CLIENTVERSION_H__
|
@ -452,10 +452,10 @@ void Entity::Initialize() {
|
|||||||
if (!setFaction.empty()) {
|
if (!setFaction.empty()) {
|
||||||
// TODO also split on space here however we do not have a general util for splitting on multiple characters yet.
|
// TODO also split on space here however we do not have a general util for splitting on multiple characters yet.
|
||||||
std::vector<std::string> factionsToAdd = GeneralUtils::SplitString(setFaction, ';');
|
std::vector<std::string> factionsToAdd = GeneralUtils::SplitString(setFaction, ';');
|
||||||
int32_t factionToAdd;
|
|
||||||
for (const auto faction : factionsToAdd) {
|
for (const auto faction : factionsToAdd) {
|
||||||
if (GeneralUtils::TryParse(faction, factionToAdd)) {
|
const auto factionToAdd = GeneralUtils::TryParse<int32_t>(faction);
|
||||||
comp->AddFaction(factionToAdd, true);
|
if (factionToAdd) {
|
||||||
|
comp->AddFaction(factionToAdd.value(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,13 +396,7 @@ template<typename T>
|
|||||||
T Entity::GetVarAs(const std::u16string& name) const {
|
T Entity::GetVarAs(const std::u16string& name) const {
|
||||||
const auto data = GetVarAsString(name);
|
const auto data = GetVarAsString(name);
|
||||||
|
|
||||||
T value;
|
return GeneralUtils::TryParse<T>(data).value_or(LDFData<T>::Default);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(data, value)) {
|
|
||||||
return LDFData<T>::Default;
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -83,7 +83,8 @@ void ActivityComponent::LoadActivityData(const int32_t activityId) {
|
|||||||
if (m_ActivityInfo.instanceMapID == -1) {
|
if (m_ActivityInfo.instanceMapID == -1) {
|
||||||
const auto& transferOverride = m_Parent->GetVarAsString(u"transferZoneID");
|
const auto& transferOverride = m_Parent->GetVarAsString(u"transferZoneID");
|
||||||
if (!transferOverride.empty()) {
|
if (!transferOverride.empty()) {
|
||||||
GeneralUtils::TryParse(transferOverride, m_ActivityInfo.instanceMapID);
|
m_ActivityInfo.instanceMapID =
|
||||||
|
GeneralUtils::TryParse<uint32_t>(transferOverride).value_or(m_ActivityInfo.instanceMapID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,10 +33,9 @@ QuickBuildComponent::QuickBuildComponent(Entity* entity) : Component(entity) {
|
|||||||
// Should a setting that has the build activator position exist, fetch that setting here and parse it for position.
|
// Should a setting that has the build activator position exist, fetch that setting here and parse it for position.
|
||||||
// It is assumed that the user who sets this setting uses the correct character delimiter (character 31 or in hex 0x1F)
|
// It is assumed that the user who sets this setting uses the correct character delimiter (character 31 or in hex 0x1F)
|
||||||
auto positionAsVector = GeneralUtils::SplitString(m_Parent->GetVarAsString(u"rebuild_activators"), 0x1F);
|
auto positionAsVector = GeneralUtils::SplitString(m_Parent->GetVarAsString(u"rebuild_activators"), 0x1F);
|
||||||
if (positionAsVector.size() == 3 &&
|
const auto activatorPositionValid = GeneralUtils::TryParse<NiPoint3>(positionAsVector);
|
||||||
GeneralUtils::TryParse(positionAsVector[0], m_ActivatorPosition.x) &&
|
if (positionAsVector.size() == 3 && activatorPositionValid) {
|
||||||
GeneralUtils::TryParse(positionAsVector[1], m_ActivatorPosition.y) &&
|
m_ActivatorPosition = activatorPositionValid.value();
|
||||||
GeneralUtils::TryParse(positionAsVector[2], m_ActivatorPosition.z)) {
|
|
||||||
} else {
|
} else {
|
||||||
LOG("Failed to find activator position for lot %i. Defaulting to parents position.", m_Parent->GetLOT());
|
LOG("Failed to find activator position for lot %i. Defaulting to parents position.", m_Parent->GetLOT());
|
||||||
m_ActivatorPosition = m_Parent->GetPosition();
|
m_ActivatorPosition = m_Parent->GetPosition();
|
||||||
@ -328,7 +327,7 @@ float QuickBuildComponent::GetTimeBeforeSmash() {
|
|||||||
return m_TimeBeforeSmash;
|
return m_TimeBeforeSmash;
|
||||||
}
|
}
|
||||||
|
|
||||||
eQuickBuildState QuickBuildComponent::GetState() {
|
eQuickBuildState QuickBuildComponent::GetState() const noexcept {
|
||||||
return m_State;
|
return m_State;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ public:
|
|||||||
* Returns the current quickbuild state
|
* Returns the current quickbuild state
|
||||||
* @return the current quickbuild state
|
* @return the current quickbuild state
|
||||||
*/
|
*/
|
||||||
eQuickBuildState GetState();
|
[[nodiscard]] eQuickBuildState GetState() const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the player that is currently building this quickbuild
|
* Returns the player that is currently building this quickbuild
|
||||||
|
@ -30,13 +30,15 @@ RenderComponent::RenderComponent(Entity* const parentEntity, const int32_t compo
|
|||||||
auto* animationsTable = CDClientManager::GetTable<CDAnimationsTable>();
|
auto* animationsTable = CDClientManager::GetTable<CDAnimationsTable>();
|
||||||
auto groupIdsSplit = GeneralUtils::SplitString(animationGroupIDs, ',');
|
auto groupIdsSplit = GeneralUtils::SplitString(animationGroupIDs, ',');
|
||||||
for (auto& groupId : groupIdsSplit) {
|
for (auto& groupId : groupIdsSplit) {
|
||||||
int32_t groupIdInt;
|
const auto groupIdInt = GeneralUtils::TryParse<int32_t>(groupId);
|
||||||
if (!GeneralUtils::TryParse(groupId, groupIdInt)) {
|
|
||||||
|
if (!groupIdInt) {
|
||||||
LOG("bad animation group Id %s", groupId.c_str());
|
LOG("bad animation group Id %s", groupId.c_str());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
m_animationGroupIds.push_back(groupIdInt);
|
|
||||||
animationsTable->CacheAnimationGroup(groupIdInt);
|
m_animationGroupIds.push_back(groupIdInt.value());
|
||||||
|
animationsTable->CacheAnimationGroup(groupIdInt.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,8 @@ TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo
|
|||||||
|
|
||||||
std::vector<std::string> tokens = GeneralUtils::SplitString(triggerInfo, ':');
|
std::vector<std::string> tokens = GeneralUtils::SplitString(triggerInfo, ':');
|
||||||
|
|
||||||
uint32_t sceneID;
|
const auto sceneID = GeneralUtils::TryParse<uint32_t>(tokens.at(0)).value_or(0);
|
||||||
GeneralUtils::TryParse<uint32_t>(tokens.at(0), sceneID);
|
const auto triggerID = GeneralUtils::TryParse<uint32_t>(tokens.at(1)).value_or(0);
|
||||||
uint32_t triggerID;
|
|
||||||
GeneralUtils::TryParse<uint32_t>(tokens.at(1), triggerID);
|
|
||||||
|
|
||||||
m_Trigger = Game::zoneManager->GetZone()->GetTrigger(sceneID, triggerID);
|
m_Trigger = Game::zoneManager->GetZone()->GetTrigger(sceneID, triggerID);
|
||||||
|
|
||||||
@ -190,9 +188,8 @@ void TriggerComponent::HandleFireEvent(Entity* targetEntity, std::string args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args){
|
||||||
uint32_t killType;
|
const eKillType killType = GeneralUtils::TryParse<eKillType>(args).value_or(eKillType::VIOLENT);
|
||||||
GeneralUtils::TryParse<uint32_t>(args, killType);
|
targetEntity->Smash(m_Parent->GetObjectID(), killType);
|
||||||
targetEntity->Smash(m_Parent->GetObjectID(), static_cast<eKillType>(killType));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleToggleTrigger(Entity* targetEntity, std::string args){
|
||||||
@ -216,9 +213,8 @@ void TriggerComponent::HandleResetRebuild(Entity* targetEntity, std::string args
|
|||||||
void TriggerComponent::HandleMoveObject(Entity* targetEntity, std::vector<std::string> argArray){
|
void TriggerComponent::HandleMoveObject(Entity* targetEntity, std::vector<std::string> argArray){
|
||||||
if (argArray.size() <= 2) return;
|
if (argArray.size() <= 2) return;
|
||||||
|
|
||||||
auto position = targetEntity->GetPosition();
|
NiPoint3 position = targetEntity->GetPosition();
|
||||||
NiPoint3 offset = NiPoint3Constant::ZERO;
|
const NiPoint3 offset = GeneralUtils::TryParse<NiPoint3>(argArray).value_or(NiPoint3Constant::ZERO);
|
||||||
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), offset);
|
|
||||||
|
|
||||||
position += offset;
|
position += offset;
|
||||||
targetEntity->SetPosition(position);
|
targetEntity->SetPosition(position);
|
||||||
@ -227,8 +223,7 @@ void TriggerComponent::HandleMoveObject(Entity* targetEntity, std::vector<std::s
|
|||||||
void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std::string> argArray){
|
void TriggerComponent::HandleRotateObject(Entity* targetEntity, std::vector<std::string> argArray){
|
||||||
if (argArray.size() <= 2) return;
|
if (argArray.size() <= 2) return;
|
||||||
|
|
||||||
NiPoint3 vector = NiPoint3Constant::ZERO;
|
const NiPoint3 vector = GeneralUtils::TryParse<NiPoint3>(argArray).value_or(NiPoint3Constant::ZERO);
|
||||||
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), vector);
|
|
||||||
|
|
||||||
NiQuaternion rotation = NiQuaternion::FromEulerAngles(vector);
|
NiQuaternion rotation = NiQuaternion::FromEulerAngles(vector);
|
||||||
targetEntity->SetRotation(rotation);
|
targetEntity->SetRotation(rotation);
|
||||||
@ -245,8 +240,7 @@ void TriggerComponent::HandlePushObject(Entity* targetEntity, std::vector<std::s
|
|||||||
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
||||||
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::PUSH);
|
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::PUSH);
|
||||||
phantomPhysicsComponent->SetDirectionalMultiplier(1);
|
phantomPhysicsComponent->SetDirectionalMultiplier(1);
|
||||||
NiPoint3 direction = NiPoint3Constant::ZERO;
|
const NiPoint3 direction = GeneralUtils::TryParse<NiPoint3>(argArray).value_or(NiPoint3Constant::ZERO);
|
||||||
GeneralUtils::TryParse(argArray.at(0), argArray.at(1), argArray.at(2), direction);
|
|
||||||
phantomPhysicsComponent->SetDirection(direction);
|
phantomPhysicsComponent->SetDirection(direction);
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(m_Parent);
|
Game::entityManager->SerializeEntity(m_Parent);
|
||||||
@ -259,8 +253,8 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args)
|
|||||||
LOG_DEBUG("Phantom Physics component not found!");
|
LOG_DEBUG("Phantom Physics component not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float forceMultiplier;
|
const float forceMultiplier = GeneralUtils::TryParse<float>(args).value_or(1.0f);
|
||||||
GeneralUtils::TryParse<float>(args, forceMultiplier);
|
|
||||||
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
||||||
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
|
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
|
||||||
phantomPhysicsComponent->SetDirectionalMultiplier(forceMultiplier);
|
phantomPhysicsComponent->SetDirectionalMultiplier(forceMultiplier);
|
||||||
@ -279,11 +273,10 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args)
|
|||||||
|
|
||||||
void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::string> argArray){
|
void TriggerComponent::HandleSetTimer(Entity* targetEntity, std::vector<std::string> argArray){
|
||||||
if (argArray.size() != 2) {
|
if (argArray.size() != 2) {
|
||||||
LOG_DEBUG("Not ehought variables!");
|
LOG_DEBUG("Not enough variables!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float time = 0.0;
|
const float time = GeneralUtils::TryParse<float>(argArray.at(1)).value_or(0.0f);
|
||||||
GeneralUtils::TryParse<float>(argArray.at(1), time);
|
|
||||||
m_Parent->AddTimer(argArray.at(0), time);
|
m_Parent->AddTimer(argArray.at(0), time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,7 +292,7 @@ void TriggerComponent::HandlePlayCinematic(Entity* targetEntity, std::vector<std
|
|||||||
bool hidePlayer = false;
|
bool hidePlayer = false;
|
||||||
|
|
||||||
if (argArray.size() >= 2) {
|
if (argArray.size() >= 2) {
|
||||||
GeneralUtils::TryParse<float>(argArray.at(1), leadIn);
|
leadIn = GeneralUtils::TryParse<float>(argArray.at(1)).value_or(leadIn);
|
||||||
if (argArray.size() >= 3 && argArray.at(2) == "wait") {
|
if (argArray.size() >= 3 && argArray.at(2) == "wait") {
|
||||||
wait = eEndBehavior::WAIT;
|
wait = eEndBehavior::WAIT;
|
||||||
if (argArray.size() >= 4 && argArray.at(3) == "unlock") {
|
if (argArray.size() >= 4 && argArray.at(3) == "unlock") {
|
||||||
@ -344,12 +337,16 @@ void TriggerComponent::HandleUpdateMission(Entity* targetEntity, std::vector<std
|
|||||||
|
|
||||||
void TriggerComponent::HandlePlayEffect(Entity* targetEntity, std::vector<std::string> argArray) {
|
void TriggerComponent::HandlePlayEffect(Entity* targetEntity, std::vector<std::string> argArray) {
|
||||||
if (argArray.size() < 3) return;
|
if (argArray.size() < 3) return;
|
||||||
int32_t effectID = 0;
|
const auto effectID = GeneralUtils::TryParse<int32_t>(argArray.at(1));
|
||||||
if (!GeneralUtils::TryParse<int32_t>(argArray.at(1), effectID)) return;
|
if (!effectID) return;
|
||||||
std::u16string effectType = GeneralUtils::UTF8ToUTF16(argArray.at(2));
|
std::u16string effectType = GeneralUtils::UTF8ToUTF16(argArray.at(2));
|
||||||
|
|
||||||
float priority = 1;
|
float priority = 1;
|
||||||
if (argArray.size() == 4) GeneralUtils::TryParse<float>(argArray.at(3), priority);
|
if (argArray.size() == 4) {
|
||||||
GameMessages::SendPlayFXEffect(targetEntity, effectID, effectType, argArray.at(0), LWOOBJID_EMPTY, priority);
|
priority = GeneralUtils::TryParse<float>(argArray.at(3)).value_or(priority);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameMessages::SendPlayFXEffect(targetEntity, effectID.value(), effectType, argArray.at(0), LWOOBJID_EMPTY, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){
|
void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){
|
||||||
@ -358,8 +355,7 @@ void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){
|
|||||||
LOG_DEBUG("Skill component not found!");
|
LOG_DEBUG("Skill component not found!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint32_t skillId;
|
const uint32_t skillId = GeneralUtils::TryParse<uint32_t>(args).value_or(0);
|
||||||
GeneralUtils::TryParse<uint32_t>(args, skillId);
|
|
||||||
skillComponent->CastSkill(skillId, targetEntity->GetObjectID());
|
skillComponent->CastSkill(skillId, targetEntity->GetObjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,17 +377,16 @@ void TriggerComponent::HandleSetPhysicsVolumeEffect(Entity* targetEntity, std::v
|
|||||||
phantomPhysicsComponent->SetEffectType(effectType);
|
phantomPhysicsComponent->SetEffectType(effectType);
|
||||||
phantomPhysicsComponent->SetDirectionalMultiplier(std::stof(argArray.at(1)));
|
phantomPhysicsComponent->SetDirectionalMultiplier(std::stof(argArray.at(1)));
|
||||||
if (argArray.size() > 4) {
|
if (argArray.size() > 4) {
|
||||||
NiPoint3 direction = NiPoint3Constant::ZERO;
|
const NiPoint3 direction =
|
||||||
GeneralUtils::TryParse(argArray.at(2), argArray.at(3), argArray.at(4), direction);
|
GeneralUtils::TryParse<NiPoint3>(argArray.at(2), argArray.at(3), argArray.at(4)).value_or(NiPoint3Constant::ZERO);
|
||||||
|
|
||||||
phantomPhysicsComponent->SetDirection(direction);
|
phantomPhysicsComponent->SetDirection(direction);
|
||||||
}
|
}
|
||||||
if (argArray.size() > 5) {
|
if (argArray.size() > 5) {
|
||||||
uint32_t min;
|
const uint32_t min = GeneralUtils::TryParse<uint32_t>(argArray.at(6)).value_or(0);
|
||||||
GeneralUtils::TryParse<uint32_t>(argArray.at(6), min);
|
|
||||||
phantomPhysicsComponent->SetMin(min);
|
phantomPhysicsComponent->SetMin(min);
|
||||||
|
|
||||||
uint32_t max;
|
const uint32_t max = GeneralUtils::TryParse<uint32_t>(argArray.at(7)).value_or(0);
|
||||||
GeneralUtils::TryParse<uint32_t>(argArray.at(7), max);
|
|
||||||
phantomPhysicsComponent->SetMax(max);
|
phantomPhysicsComponent->SetMax(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,14 +468,14 @@ void Item::DisassembleModel(uint32_t numToDismantle) {
|
|||||||
// First iteration gets the count
|
// First iteration gets the count
|
||||||
std::map<int32_t, int32_t> parts;
|
std::map<int32_t, int32_t> parts;
|
||||||
while (currentBrick) {
|
while (currentBrick) {
|
||||||
auto* designID = currentBrick->Attribute("designID");
|
const char* const designID = currentBrick->Attribute("designID");
|
||||||
if (designID) {
|
if (designID) {
|
||||||
uint32_t designId;
|
const auto designId = GeneralUtils::TryParse<uint32_t>(designID);
|
||||||
if (!GeneralUtils::TryParse(designID, designId)) {
|
if (!designId) {
|
||||||
LOG("Failed to parse designID %s", designID);
|
LOG("Failed to parse designID %s", designID);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
parts[designId]++;
|
parts[designId.value()]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentBrick = currentBrick->NextSiblingElement(searchTerm.c_str());
|
currentBrick = currentBrick->NextSiblingElement(searchTerm.c_str());
|
||||||
|
@ -87,10 +87,8 @@ ItemSet::ItemSet(const uint32_t id, InventoryComponent* inventoryComponent) {
|
|||||||
m_Items = {};
|
m_Items = {};
|
||||||
|
|
||||||
while (std::getline(stream, token, ',')) {
|
while (std::getline(stream, token, ',')) {
|
||||||
int32_t value;
|
const auto validToken = GeneralUtils::TryParse<int32_t>(token);
|
||||||
if (GeneralUtils::TryParse(token, value)) {
|
if (validToken) m_Items.push_back(validToken.value());
|
||||||
m_Items.push_back(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Equipped = {};
|
m_Equipped = {};
|
||||||
|
@ -27,19 +27,15 @@ MissionTask::MissionTask(Mission* mission, CDMissionTasks* info, uint32_t mask)
|
|||||||
std::string token;
|
std::string token;
|
||||||
|
|
||||||
while (std::getline(stream, token, ',')) {
|
while (std::getline(stream, token, ',')) {
|
||||||
uint32_t parameter;
|
const auto parameter = GeneralUtils::TryParse<uint32_t>(token);
|
||||||
if (GeneralUtils::TryParse(token, parameter)) {
|
if (parameter) parameters.push_back(parameter.value());
|
||||||
parameters.push_back(parameter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stream = std::istringstream(info->targetGroup);
|
stream = std::istringstream(info->targetGroup);
|
||||||
|
|
||||||
while (std::getline(stream, token, ',')) {
|
while (std::getline(stream, token, ',')) {
|
||||||
uint32_t parameter;
|
const auto parameter = GeneralUtils::TryParse<uint32_t>(token);
|
||||||
if (GeneralUtils::TryParse(token, parameter)) {
|
if (parameter) targets.push_back(parameter.value());
|
||||||
targets.push_back(parameter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "dCommonVars.h"
|
#include "dCommonVars.h"
|
||||||
|
|
||||||
BehaviorMessageBase::BehaviorMessageBase(AMFArrayValue* arguments) {
|
BehaviorMessageBase::BehaviorMessageBase(AMFArrayValue* arguments) {
|
||||||
behaviorId = GetBehaviorIdFromArgument(arguments);
|
this->behaviorId = GetBehaviorIdFromArgument(arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments) {
|
int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments) {
|
||||||
@ -13,12 +13,13 @@ int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments)
|
|||||||
auto* behaviorIDValue = arguments->Get<std::string>(key);
|
auto* behaviorIDValue = arguments->Get<std::string>(key);
|
||||||
|
|
||||||
if (behaviorIDValue && behaviorIDValue->GetValueType() == eAmf::String) {
|
if (behaviorIDValue && behaviorIDValue->GetValueType() == eAmf::String) {
|
||||||
GeneralUtils::TryParse(behaviorIDValue->GetValue(), behaviorId);
|
this->behaviorId =
|
||||||
|
GeneralUtils::TryParse<int32_t>(behaviorIDValue->GetValue()).value_or(this->behaviorId);
|
||||||
} else if (arguments->Get(key) && arguments->Get(key)->GetValueType() != eAmf::Undefined) {
|
} else if (arguments->Get(key) && arguments->Get(key)->GetValueType() != eAmf::Undefined) {
|
||||||
throw std::invalid_argument("Unable to find behavior ID");
|
throw std::invalid_argument("Unable to find behavior ID");
|
||||||
}
|
}
|
||||||
|
|
||||||
return behaviorId;
|
return this->behaviorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t BehaviorMessageBase::GetActionIndexFromArgument(AMFArrayValue* arguments, const std::string& keyName) {
|
int32_t BehaviorMessageBase::GetActionIndexFromArgument(AMFArrayValue* arguments, const std::string& keyName) {
|
||||||
|
@ -40,10 +40,8 @@ Precondition::Precondition(const uint32_t condition) {
|
|||||||
std::string token;
|
std::string token;
|
||||||
|
|
||||||
while (std::getline(stream, token, ',')) {
|
while (std::getline(stream, token, ',')) {
|
||||||
uint32_t value;
|
const auto validToken = GeneralUtils::TryParse<uint32_t>(token);
|
||||||
if (GeneralUtils::TryParse(token, value)) {
|
if (validToken) this->values.push_back(validToken.value());
|
||||||
this->values.push_back(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,13 +113,13 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
if ((chatCommand == "setgmlevel" || chatCommand == "makegm" || chatCommand == "gmlevel") && user->GetMaxGMLevel() > eGameMasterLevel::CIVILIAN) {
|
if ((chatCommand == "setgmlevel" || chatCommand == "makegm" || chatCommand == "gmlevel") && user->GetMaxGMLevel() > eGameMasterLevel::CIVILIAN) {
|
||||||
if (args.size() != 1) return;
|
if (args.size() != 1) return;
|
||||||
|
|
||||||
uint32_t level_intermed = 0;
|
const auto level_intermed = GeneralUtils::TryParse<uint32_t>(args[0]);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], level_intermed)) {
|
if (!level_intermed) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid gm level.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid gm level.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
eGameMasterLevel level = static_cast<eGameMasterLevel>(level_intermed);
|
eGameMasterLevel level = static_cast<eGameMasterLevel>(level_intermed.value());
|
||||||
|
|
||||||
#ifndef DEVELOPER_SERVER
|
#ifndef DEVELOPER_SERVER
|
||||||
if (user->GetMaxGMLevel() == eGameMasterLevel::JUNIOR_DEVELOPER) {
|
if (user->GetMaxGMLevel() == eGameMasterLevel::JUNIOR_DEVELOPER) {
|
||||||
@ -378,26 +378,27 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "resetmission" && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "resetmission" && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
uint32_t missionId;
|
const auto missionId = GeneralUtils::TryParse<uint32_t>(args[0]);
|
||||||
if (!GeneralUtils::TryParse(args[0], missionId)) {
|
if (!missionId) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission ID.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* missionComponent = entity->GetComponent<MissionComponent>();
|
auto* missionComponent = entity->GetComponent<MissionComponent>();
|
||||||
if (!missionComponent) return;
|
if (!missionComponent) return;
|
||||||
missionComponent->ResetMission(missionId);
|
missionComponent->ResetMission(missionId.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log command to database
|
// Log command to database
|
||||||
Database::Get()->InsertSlashCommandUsage(entity->GetObjectID(), chatCommand);
|
Database::Get()->InsertSlashCommandUsage(entity->GetObjectID(), chatCommand);
|
||||||
|
|
||||||
if (chatCommand == "setminifig" && args.size() == 2 && entity->GetGMLevel() >= eGameMasterLevel::FORUM_MODERATOR) { // could break characters so only allow if GM > 0
|
if (chatCommand == "setminifig" && args.size() == 2 && entity->GetGMLevel() >= eGameMasterLevel::FORUM_MODERATOR) { // could break characters so only allow if GM > 0
|
||||||
int32_t minifigItemId;
|
const auto minifigItemIdExists = GeneralUtils::TryParse<int32_t>(args[1]);
|
||||||
if (!GeneralUtils::TryParse(args[1], minifigItemId)) {
|
if (!minifigItemIdExists) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid Minifig Item Id ID.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid Minifig Item Id ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const int32_t minifigItemId = minifigItemIdExists.value();
|
||||||
Game::entityManager->DestructEntity(entity, sysAddr);
|
Game::entityManager->DestructEntity(entity, sysAddr);
|
||||||
auto* charComp = entity->GetComponent<CharacterComponent>();
|
auto* charComp = entity->GetComponent<CharacterComponent>();
|
||||||
std::string lowerName = args[0];
|
std::string lowerName = args[0];
|
||||||
@ -457,14 +458,14 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "unlock-emote" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "unlock-emote" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
int32_t emoteID;
|
const auto emoteID = GeneralUtils::TryParse<int32_t>(args.at(0));
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], emoteID)) {
|
if (!emoteID) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid emote ID.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid emote ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity->GetCharacter()->UnlockEmote(emoteID);
|
entity->GetCharacter()->UnlockEmote(emoteID.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "force-save" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "force-save" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
@ -486,19 +487,19 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "speedboost" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "speedboost" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
float boost;
|
const auto boostOptional = GeneralUtils::TryParse<float>(args[0]);
|
||||||
|
if (!boostOptional) {
|
||||||
if (!GeneralUtils::TryParse(args[0], boost)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid boost.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid boost.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const float boost = boostOptional.value();
|
||||||
|
|
||||||
auto* controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
auto* controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
||||||
|
|
||||||
if (!controllablePhysicsComponent) return;
|
if (!controllablePhysicsComponent) return;
|
||||||
controllablePhysicsComponent->SetSpeedMultiplier(boost);
|
controllablePhysicsComponent->SetSpeedMultiplier(boost);
|
||||||
|
|
||||||
// speedboost possesables
|
// speedboost possessables
|
||||||
auto possessor = entity->GetComponent<PossessorComponent>();
|
auto possessor = entity->GetComponent<PossessorComponent>();
|
||||||
if (possessor) {
|
if (possessor) {
|
||||||
auto possessedID = possessor->GetPossessable();
|
auto possessedID = possessor->GetPossessable();
|
||||||
@ -527,14 +528,14 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "setcontrolscheme" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "setcontrolscheme" && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
uint32_t scheme;
|
const auto scheme = GeneralUtils::TryParse<uint32_t>(args[0]);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], scheme)) {
|
if (!scheme) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid control scheme.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid control scheme.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendSetPlayerControlScheme(entity, static_cast<eControlScheme>(scheme));
|
GameMessages::SendSetPlayerControlScheme(entity, static_cast<eControlScheme>(scheme.value()));
|
||||||
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Switched control scheme.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Switched control scheme.");
|
||||||
return;
|
return;
|
||||||
@ -574,29 +575,28 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((chatCommand == "setinventorysize" || chatCommand == "setinvsize") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
if ((chatCommand == "setinventorysize" || chatCommand == "setinvsize") && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
||||||
uint32_t size;
|
const auto sizeOptional = GeneralUtils::TryParse<uint32_t>(args[0]);
|
||||||
|
if (!sizeOptional) {
|
||||||
if (!GeneralUtils::TryParse(args.at(0), size)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid size.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid size.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const uint32_t size = sizeOptional.value();
|
||||||
|
|
||||||
eInventoryType selectedInventory = eInventoryType::ITEMS;
|
eInventoryType selectedInventory = eInventoryType::ITEMS;
|
||||||
|
|
||||||
// a possible inventory was provided if we got more than 1 argument
|
// a possible inventory was provided if we got more than 1 argument
|
||||||
if (args.size() >= 2) {
|
if (args.size() >= 2) {
|
||||||
selectedInventory = eInventoryType::INVALID;
|
selectedInventory = GeneralUtils::TryParse<eInventoryType>(args.at(1)).value_or(eInventoryType::INVALID);
|
||||||
if (!GeneralUtils::TryParse(args.at(1), selectedInventory)) {
|
if (selectedInventory == eInventoryType::INVALID) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid inventory.");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
// In this case, we treat the input as a string and try to find it in the reflection list
|
// In this case, we treat the input as a string and try to find it in the reflection list
|
||||||
std::transform(args.at(1).begin(), args.at(1).end(), args.at(1).begin(), ::toupper);
|
std::transform(args.at(1).begin(), args.at(1).end(), args.at(1).begin(), ::toupper);
|
||||||
for (uint32_t index = 0; index < NUMBER_OF_INVENTORIES; index++) {
|
for (uint32_t index = 0; index < NUMBER_OF_INVENTORIES; index++) {
|
||||||
if (std::string_view(args.at(1)) == std::string_view(InventoryType::InventoryTypeToString(static_cast<eInventoryType>(index)))) selectedInventory = static_cast<eInventoryType>(index);
|
if (std::string_view(args.at(1)) == std::string_view(InventoryType::InventoryTypeToString(static_cast<eInventoryType>(index)))) selectedInventory = static_cast<eInventoryType>(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (selectedInventory == eInventoryType::INVALID) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid inventory.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Setting inventory " +
|
ChatPackets::SendSystemMessage(sysAddr, u"Setting inventory " +
|
||||||
GeneralUtils::ASCIIToUTF16(args.at(1)) +
|
GeneralUtils::ASCIIToUTF16(args.at(1)) +
|
||||||
@ -643,48 +643,48 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
if (chatCommand == "addmission" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "addmission" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
if (args.size() == 0) return;
|
if (args.size() == 0) return;
|
||||||
|
|
||||||
uint32_t missionID;
|
const auto missionID = GeneralUtils::TryParse<uint32_t>(args.at(0));
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], missionID)) {
|
if (!missionID) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission id.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission id.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto comp = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION));
|
auto comp = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION));
|
||||||
if (comp) comp->AcceptMission(missionID, true);
|
if (comp) comp->AcceptMission(missionID.value(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "completemission" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "completemission" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
if (args.size() == 0) return;
|
if (args.size() == 0) return;
|
||||||
|
|
||||||
uint32_t missionID;
|
const auto missionID = GeneralUtils::TryParse<uint32_t>(args.at(0));
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], missionID)) {
|
if (!missionID) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission id.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid mission id.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto comp = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION));
|
auto comp = static_cast<MissionComponent*>(entity->GetComponent(eReplicaComponentType::MISSION));
|
||||||
if (comp) comp->CompleteMission(missionID, true);
|
if (comp) comp->CompleteMission(missionID.value(), true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "setflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) {
|
if (chatCommand == "setflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) {
|
||||||
int32_t flagId;
|
const auto flagId = GeneralUtils::TryParse<int32_t>(args.at(0));
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], flagId)) {
|
if (!flagId) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity->GetCharacter()->SetPlayerFlag(flagId, true);
|
entity->GetCharacter()->SetPlayerFlag(flagId.value(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "setflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 2) {
|
if (chatCommand == "setflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 2) {
|
||||||
int32_t flagId;
|
const auto flagId = GeneralUtils::TryParse<int32_t>(args.at(1));
|
||||||
std::string onOffFlag = args[0];
|
std::string onOffFlag = args.at(0);
|
||||||
if (!GeneralUtils::TryParse(args[1], flagId)) {
|
if (!flagId) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -692,28 +692,26 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag type.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag type.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
entity->GetCharacter()->SetPlayerFlag(flagId, onOffFlag == "on");
|
entity->GetCharacter()->SetPlayerFlag(flagId.value(), onOffFlag == "on");
|
||||||
}
|
}
|
||||||
if (chatCommand == "clearflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) {
|
if (chatCommand == "clearflag" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) {
|
||||||
int32_t flagId;
|
const auto flagId = GeneralUtils::TryParse<int32_t>(args.at(0));
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], flagId)) {
|
if (!flagId) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid flag id.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity->GetCharacter()->SetPlayerFlag(flagId, false);
|
entity->GetCharacter()->SetPlayerFlag(flagId.value(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "playeffect" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 3) {
|
if (chatCommand == "playeffect" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 3) {
|
||||||
int32_t effectID = 0;
|
const auto effectID = GeneralUtils::TryParse<int32_t>(args.at(0));
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], effectID)) {
|
if (!effectID) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: use fallible ASCIIToUTF16 conversion, because non-ascii isn't valid anyway
|
// FIXME: use fallible ASCIIToUTF16 conversion, because non-ascii isn't valid anyway
|
||||||
GameMessages::SendPlayFXEffect(entity->GetObjectID(), effectID, GeneralUtils::ASCIIToUTF16(args[1]), args[2]);
|
GameMessages::SendPlayFXEffect(entity->GetObjectID(), effectID.value(), GeneralUtils::ASCIIToUTF16(args.at(1)), args.at(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "stopeffect" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
if (chatCommand == "stopeffect" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
||||||
@ -775,34 +773,32 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
|
|
||||||
if (chatCommand == "gmadditem" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "gmadditem" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
if (args.size() == 1) {
|
if (args.size() == 1) {
|
||||||
uint32_t itemLOT;
|
const auto itemLOT = GeneralUtils::TryParse<uint32_t>(args.at(0));
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], itemLOT)) {
|
if (!itemLOT) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid item LOT.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid item LOT.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InventoryComponent* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
InventoryComponent* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||||
|
|
||||||
inventory->AddItem(itemLOT, 1, eLootSourceType::MODERATION);
|
inventory->AddItem(itemLOT.value(), 1, eLootSourceType::MODERATION);
|
||||||
} else if (args.size() == 2) {
|
} else if (args.size() == 2) {
|
||||||
uint32_t itemLOT;
|
const auto itemLOT = GeneralUtils::TryParse<uint32_t>(args.at(0));
|
||||||
|
if (!itemLOT) {
|
||||||
if (!GeneralUtils::TryParse(args[0], itemLOT)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid item LOT.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid item LOT.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t count;
|
const auto count = GeneralUtils::TryParse<uint32_t>(args.at(1));
|
||||||
|
if (!count) {
|
||||||
if (!GeneralUtils::TryParse(args[1], count)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid item count.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid item count.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InventoryComponent* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
InventoryComponent* inventory = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
|
||||||
|
|
||||||
inventory->AddItem(itemLOT, count, eLootSourceType::MODERATION);
|
inventory->AddItem(itemLOT.value(), count.value(), eLootSourceType::MODERATION);
|
||||||
} else {
|
} else {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /gmadditem <lot>");
|
ChatPackets::SendSystemMessage(sysAddr, u"Correct usage: /gmadditem <lot>");
|
||||||
}
|
}
|
||||||
@ -822,9 +818,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
|
|
||||||
receiverID = playerInfo->id;
|
receiverID = playerInfo->id;
|
||||||
|
|
||||||
LOT lot;
|
const auto lot = GeneralUtils::TryParse<LOT>(args.at(1));
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[1], lot)) {
|
if (!lot) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid item lot.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid item lot.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -837,7 +833,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
mailInsert.subject = "Lost item";
|
mailInsert.subject = "Lost item";
|
||||||
mailInsert.body = "This is a replacement item for one you lost.";
|
mailInsert.body = "This is a replacement item for one you lost.";
|
||||||
mailInsert.itemID = LWOOBJID_EMPTY;
|
mailInsert.itemID = LWOOBJID_EMPTY;
|
||||||
mailInsert.itemLOT = lot;
|
mailInsert.itemLOT = lot.value();
|
||||||
mailInsert.itemSubkey = LWOOBJID_EMPTY;
|
mailInsert.itemSubkey = LWOOBJID_EMPTY;
|
||||||
mailInsert.itemCount = 1;
|
mailInsert.itemCount = 1;
|
||||||
Database::Get()->InsertNewMail(mailInsert);
|
Database::Get()->InsertNewMail(mailInsert);
|
||||||
@ -871,46 +867,47 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
NiPoint3 pos{};
|
NiPoint3 pos{};
|
||||||
if (args.size() == 3) {
|
if (args.size() == 3) {
|
||||||
|
|
||||||
float x, y, z;
|
const auto x = GeneralUtils::TryParse<float>(args.at(0));
|
||||||
|
if (!x) {
|
||||||
if (!GeneralUtils::TryParse(args[0], x)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid x.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid x.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[1], y)) {
|
const auto y = GeneralUtils::TryParse<float>(args.at(1));
|
||||||
|
if (!y) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid y.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid y.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[2], z)) {
|
const auto z = GeneralUtils::TryParse<float>(args.at(2));
|
||||||
|
if (!z) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid z.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid z.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos.SetX(x);
|
pos.SetX(x.value());
|
||||||
pos.SetY(y);
|
pos.SetY(y.value());
|
||||||
pos.SetZ(z);
|
pos.SetZ(z.value());
|
||||||
|
|
||||||
LOG("Teleporting objectID: %llu to %f, %f, %f", entity->GetObjectID(), pos.x, pos.y, pos.z);
|
LOG("Teleporting objectID: %llu to %f, %f, %f", entity->GetObjectID(), pos.x, pos.y, pos.z);
|
||||||
GameMessages::SendTeleport(entity->GetObjectID(), pos, NiQuaternion(), sysAddr);
|
GameMessages::SendTeleport(entity->GetObjectID(), pos, NiQuaternion(), sysAddr);
|
||||||
} else if (args.size() == 2) {
|
} else if (args.size() == 2) {
|
||||||
|
|
||||||
float x, z;
|
const auto x = GeneralUtils::TryParse<float>(args.at(0));
|
||||||
|
if (!x) {
|
||||||
if (!GeneralUtils::TryParse(args[0], x)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid x.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid x.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[1], z)) {
|
const auto z = GeneralUtils::TryParse<float>(args.at(1));
|
||||||
|
if (!z) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid z.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid z.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pos.SetX(x);
|
pos.SetX(x.value());
|
||||||
pos.SetY(0.0f);
|
pos.SetY(0.0f);
|
||||||
pos.SetZ(z);
|
pos.SetZ(z.value());
|
||||||
|
|
||||||
LOG("Teleporting objectID: %llu to X: %f, Z: %f", entity->GetObjectID(), pos.x, pos.z);
|
LOG("Teleporting objectID: %llu to X: %f, Z: %f", entity->GetObjectID(), pos.x, pos.z);
|
||||||
GameMessages::SendTeleport(entity->GetObjectID(), pos, NiQuaternion(), sysAddr);
|
GameMessages::SendTeleport(entity->GetObjectID(), pos, NiQuaternion(), sysAddr);
|
||||||
@ -970,10 +967,10 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
float speedScale = 1.0f;
|
float speedScale = 1.0f;
|
||||||
|
|
||||||
if (args.size() >= 1) {
|
if (args.size() >= 1) {
|
||||||
float tempScaleStore;
|
const auto tempScaleStore = GeneralUtils::TryParse<float>(args.at(0));
|
||||||
|
|
||||||
if (GeneralUtils::TryParse<float>(args[0], tempScaleStore)) {
|
if (tempScaleStore) {
|
||||||
speedScale = tempScaleStore;
|
speedScale = tempScaleStore.value();
|
||||||
} else {
|
} else {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Failed to parse speed scale argument.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Failed to parse speed scale argument.");
|
||||||
}
|
}
|
||||||
@ -1025,16 +1022,17 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
time_t expire = 1; // Default to indefinate mute
|
time_t expire = 1; // Default to indefinate mute
|
||||||
|
|
||||||
if (args.size() >= 2) {
|
if (args.size() >= 2) {
|
||||||
uint32_t days = 0;
|
const auto days = GeneralUtils::TryParse<uint32_t>(args[1]);
|
||||||
uint32_t hours = 0;
|
if (!days) {
|
||||||
if (!GeneralUtils::TryParse(args[1], days)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid days.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid days.");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<uint32_t> hours;
|
||||||
if (args.size() >= 3) {
|
if (args.size() >= 3) {
|
||||||
if (!GeneralUtils::TryParse(args[2], hours)) {
|
hours = GeneralUtils::TryParse<uint32_t>(args[2]);
|
||||||
|
if (!hours) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid hours.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid hours.");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -1042,8 +1040,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
expire = time(NULL);
|
expire = time(NULL);
|
||||||
expire += 24 * 60 * 60 * days;
|
expire += 24 * 60 * 60 * days.value();
|
||||||
expire += 60 * 60 * hours;
|
expire += 60 * 60 * hours.value_or(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accountId != 0) Database::Get()->UpdateAccountUnmuteTime(accountId, expire);
|
if (accountId != 0) Database::Get()->UpdateAccountUnmuteTime(accountId, expire);
|
||||||
@ -1143,14 +1141,14 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "startcelebration" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) {
|
if (chatCommand == "startcelebration" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() == 1) {
|
||||||
int32_t celebration;
|
const auto celebration = GeneralUtils::TryParse<int32_t>(args.at(0));
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], celebration)) {
|
if (!celebration) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid celebration.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid celebration.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendStartCelebrationEffect(entity, entity->GetSystemAddress(), celebration);
|
GameMessages::SendStartCelebrationEffect(entity, entity->GetSystemAddress(), celebration.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "buffmed" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "buffmed" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
@ -1204,15 +1202,15 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
ControllablePhysicsComponent* comp = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS));
|
ControllablePhysicsComponent* comp = static_cast<ControllablePhysicsComponent*>(entity->GetComponent(eReplicaComponentType::CONTROLLABLE_PHYSICS));
|
||||||
if (!comp) return;
|
if (!comp) return;
|
||||||
|
|
||||||
uint32_t lot;
|
const auto lot = GeneralUtils::TryParse<uint32_t>(args[0]);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], lot)) {
|
if (!lot) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid lot.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid lot.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityInfo info;
|
EntityInfo info;
|
||||||
info.lot = lot;
|
info.lot = lot.value();
|
||||||
info.pos = comp->GetPosition();
|
info.pos = comp->GetPosition();
|
||||||
info.rot = comp->GetRotation();
|
info.rot = comp->GetRotation();
|
||||||
info.spawner = nullptr;
|
info.spawner = nullptr;
|
||||||
@ -1233,28 +1231,29 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
auto controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
auto controllablePhysicsComponent = entity->GetComponent<ControllablePhysicsComponent>();
|
||||||
if (!controllablePhysicsComponent) return;
|
if (!controllablePhysicsComponent) return;
|
||||||
|
|
||||||
LOT lot{};
|
const auto lot = GeneralUtils::TryParse<LOT>(args[0]);
|
||||||
uint32_t numberToSpawn{};
|
if (!lot) {
|
||||||
float radiusToSpawnWithin{};
|
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], lot)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid lot.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid lot.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[1], numberToSpawn) && numberToSpawn > 0) {
|
const auto numberToSpawnOptional = GeneralUtils::TryParse<uint32_t>(args[1]);
|
||||||
|
if (!numberToSpawnOptional && numberToSpawnOptional.value() > 0) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid number of enemies to spawn.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid number of enemies to spawn.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
uint32_t numberToSpawn = numberToSpawnOptional.value();
|
||||||
|
|
||||||
// Must spawn within a radius of at least 0.0f
|
// Must spawn within a radius of at least 0.0f
|
||||||
if (!GeneralUtils::TryParse(args[2], radiusToSpawnWithin) && radiusToSpawnWithin < 0.0f) {
|
const auto radiusToSpawnWithinOptional = GeneralUtils::TryParse<float>(args[2]);
|
||||||
|
if (!radiusToSpawnWithinOptional && radiusToSpawnWithinOptional.value() < 0.0f) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid radius to spawn within.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid radius to spawn within.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const float radiusToSpawnWithin = radiusToSpawnWithinOptional.value();
|
||||||
|
|
||||||
EntityInfo info;
|
EntityInfo info;
|
||||||
info.lot = lot;
|
info.lot = lot.value();
|
||||||
info.spawner = nullptr;
|
info.spawner = nullptr;
|
||||||
info.spawnerID = entity->GetObjectID();
|
info.spawnerID = entity->GetObjectID();
|
||||||
info.spawnerNodeID = 0;
|
info.spawnerNodeID = 0;
|
||||||
@ -1281,12 +1280,12 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((chatCommand == "giveuscore") && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if ((chatCommand == "giveuscore") && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
int32_t uscore;
|
const auto uscoreOptional = GeneralUtils::TryParse<int32_t>(args[0]);
|
||||||
|
if (!uscoreOptional) {
|
||||||
if (!GeneralUtils::TryParse(args[0], uscore)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid uscore.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid uscore.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const int32_t uscore = uscoreOptional.value();
|
||||||
|
|
||||||
CharacterComponent* character = entity->GetComponent<CharacterComponent>();
|
CharacterComponent* character = entity->GetComponent<CharacterComponent>();
|
||||||
if (character) character->SetUScore(character->GetUScore() + uscore);
|
if (character) character->SetUScore(character->GetUScore() + uscore);
|
||||||
@ -1294,9 +1293,9 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
|
|
||||||
eLootSourceType lootType = eLootSourceType::MODERATION;
|
eLootSourceType lootType = eLootSourceType::MODERATION;
|
||||||
|
|
||||||
int32_t type;
|
if (args.size() >= 2) {
|
||||||
if (args.size() >= 2 && GeneralUtils::TryParse(args[1], type)) {
|
const auto type = GeneralUtils::TryParse<eLootSourceType>(args[1]);
|
||||||
lootType = static_cast<eLootSourceType>(type);
|
lootType = type.value_or(lootType);
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, lootType);
|
GameMessages::SendModifyLEGOScore(entity, entity->GetSystemAddress(), uscore, lootType);
|
||||||
@ -1322,14 +1321,15 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
|
|
||||||
entity = requestedPlayer->GetOwner();
|
entity = requestedPlayer->GetOwner();
|
||||||
}
|
}
|
||||||
uint32_t requestedLevel;
|
const auto requestedLevelOptional = GeneralUtils::TryParse<uint32_t>(args[0]);
|
||||||
uint32_t oldLevel;
|
uint32_t oldLevel;
|
||||||
// first check the level is valid
|
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], requestedLevel)) {
|
// first check the level is valid
|
||||||
|
if (!requestedLevelOptional) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid level.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid level.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
uint32_t requestedLevel = requestedLevelOptional.value();
|
||||||
// query to set our uscore to the correct value for this level
|
// query to set our uscore to the correct value for this level
|
||||||
|
|
||||||
auto characterComponent = entity->GetComponent<CharacterComponent>();
|
auto characterComponent = entity->GetComponent<CharacterComponent>();
|
||||||
@ -1402,27 +1402,27 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((chatCommand == "freemoney" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) && args.size() == 1) {
|
if ((chatCommand == "freemoney" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) && args.size() == 1) {
|
||||||
int64_t money;
|
const auto money = GeneralUtils::TryParse<int64_t>(args[0]);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], money)) {
|
if (!money) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid money.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid money.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* ch = entity->GetCharacter();
|
auto* ch = entity->GetCharacter();
|
||||||
ch->SetCoins(ch->GetCoins() + money, eLootSourceType::MODERATION);
|
ch->SetCoins(ch->GetCoins() + money.value(), eLootSourceType::MODERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((chatCommand == "setcurrency") && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if ((chatCommand == "setcurrency") && args.size() == 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
int32_t money;
|
const auto money = GeneralUtils::TryParse<int64_t>(args[0]);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], money)) {
|
if (!money) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid money.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid money.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* ch = entity->GetCharacter();
|
auto* ch = entity->GetCharacter();
|
||||||
ch->SetCoins(money, eLootSourceType::MODERATION);
|
ch->SetCoins(money.value(), eLootSourceType::MODERATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow for this on even while not a GM, as it sometimes toggles incorrrectly.
|
// Allow for this on even while not a GM, as it sometimes toggles incorrrectly.
|
||||||
@ -1435,17 +1435,14 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
if (chatCommand == "gmimmune" && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "gmimmune" && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
int32_t state = false;
|
const auto state = GeneralUtils::TryParse<int32_t>(args[0]);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], state)) {
|
if (!state) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid state.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid state.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destroyableComponent != nullptr) {
|
if (destroyableComponent) destroyableComponent->SetIsGMImmune(state.value());
|
||||||
destroyableComponent->SetIsGMImmune(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1453,53 +1450,47 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
if (chatCommand == "attackimmune" && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "attackimmune" && args.size() >= 1 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
int32_t state = false;
|
const auto state = GeneralUtils::TryParse<int32_t>(args[0]);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], state)) {
|
if (!state) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid state.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid state.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destroyableComponent != nullptr) {
|
if (destroyableComponent) destroyableComponent->SetIsImmune(state.value());
|
||||||
destroyableComponent->SetIsImmune(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "buff" && args.size() >= 2 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
if (chatCommand == "buff" && args.size() >= 2 && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER) {
|
||||||
auto* buffComponent = entity->GetComponent<BuffComponent>();
|
auto* buffComponent = entity->GetComponent<BuffComponent>();
|
||||||
|
|
||||||
int32_t id = 0;
|
const auto id = GeneralUtils::TryParse<int32_t>(args[0]);
|
||||||
int32_t duration = 0;
|
if (!id) {
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], id)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid buff id.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid buff id.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[1], duration)) {
|
const auto duration = GeneralUtils::TryParse<int32_t>(args[1]);
|
||||||
|
if (!duration) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid buff duration.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid buff duration.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffComponent != nullptr) {
|
if (buffComponent) buffComponent->ApplyBuff(id.value(), duration.value(), entity->GetObjectID());
|
||||||
buffComponent->ApplyBuff(id, duration, entity->GetObjectID());
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((chatCommand == "testmap" && args.size() >= 1) && entity->GetGMLevel() >= eGameMasterLevel::FORUM_MODERATOR) {
|
if ((chatCommand == "testmap" && args.size() >= 1) && entity->GetGMLevel() >= eGameMasterLevel::FORUM_MODERATOR) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Requesting map change...");
|
ChatPackets::SendSystemMessage(sysAddr, u"Requesting map change...");
|
||||||
uint32_t reqZone;
|
|
||||||
LWOCLONEID cloneId = 0;
|
LWOCLONEID cloneId = 0;
|
||||||
bool force = false;
|
bool force = false;
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], reqZone)) {
|
const auto reqZoneOptional = GeneralUtils::TryParse<LWOMAPID>(args[0]);
|
||||||
|
if (!reqZoneOptional) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid zone.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid zone.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const LWOMAPID reqZone = reqZoneOptional.value();
|
||||||
|
|
||||||
if (args.size() > 1) {
|
if (args.size() > 1) {
|
||||||
auto index = 1;
|
auto index = 1;
|
||||||
@ -1510,9 +1501,13 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
force = true;
|
force = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() > index && !GeneralUtils::TryParse(args[index], cloneId)) {
|
if (args.size() > index) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid clone id.");
|
const auto cloneIdOptional = GeneralUtils::TryParse<LWOCLONEID>(args[index]);
|
||||||
return;
|
if (!cloneIdOptional) {
|
||||||
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid clone id.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cloneId = cloneIdOptional.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1550,23 +1545,21 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "createprivate" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 3) {
|
if (chatCommand == "createprivate" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 3) {
|
||||||
uint32_t zone;
|
const auto zone = GeneralUtils::TryParse<uint32_t>(args[0]);
|
||||||
|
if (!zone) {
|
||||||
if (!GeneralUtils::TryParse(args[0], zone)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid zone.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid zone.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t clone;
|
const auto clone = GeneralUtils::TryParse<uint32_t>(args[1]);
|
||||||
|
if (!clone) {
|
||||||
if (!GeneralUtils::TryParse(args[1], clone)) {
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid clone.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid clone.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& password = args[2];
|
const auto& password = args[2];
|
||||||
|
|
||||||
ZoneInstanceManager::Instance()->CreatePrivateZone(Game::server, zone, clone, password);
|
ZoneInstanceManager::Instance()->CreatePrivateZone(Game::server, zone.value(), clone.value(), password);
|
||||||
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::ASCIIToUTF16("Sent request for private zone with password: " + password));
|
ChatPackets::SendSystemMessage(sysAddr, GeneralUtils::ASCIIToUTF16("Sent request for private zone with password: " + password));
|
||||||
|
|
||||||
@ -1593,14 +1586,14 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() >= 1) {
|
if (args.size() >= 1) {
|
||||||
float time;
|
const auto time = GeneralUtils::TryParse<float>(args[0]);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], time)) {
|
if (!time) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Invalid boost time.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Invalid boost time.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
GameMessages::SendVehicleAddPassiveBoostAction(vehicle->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendVehicleAddPassiveBoostAction(vehicle->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
entity->AddCallbackTimer(time, [vehicle]() {
|
entity->AddCallbackTimer(time.value(), [vehicle]() {
|
||||||
if (!vehicle) return;
|
if (!vehicle) return;
|
||||||
GameMessages::SendVehicleRemovePassiveBoostAction(vehicle->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendVehicleRemovePassiveBoostAction(vehicle->GetObjectID(), UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
});
|
});
|
||||||
@ -1676,20 +1669,19 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "reforge" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 2) {
|
if (chatCommand == "reforge" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 2) {
|
||||||
LOT baseItem;
|
const auto baseItem = GeneralUtils::TryParse<LOT>(args[0]);
|
||||||
LOT reforgedItem;
|
if (!baseItem) return;
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], baseItem)) return;
|
const auto reforgedItem = GeneralUtils::TryParse<LOT>(args[1]);
|
||||||
if (!GeneralUtils::TryParse(args[1], reforgedItem)) return;
|
if (!reforgedItem) return;
|
||||||
|
|
||||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||||
|
if (!inventoryComponent) return;
|
||||||
if (inventoryComponent == nullptr) return;
|
|
||||||
|
|
||||||
std::vector<LDFBaseData*> data{};
|
std::vector<LDFBaseData*> data{};
|
||||||
data.push_back(new LDFData<int32_t>(u"reforgedLOT", reforgedItem));
|
data.push_back(new LDFData<int32_t>(u"reforgedLOT", reforgedItem.value()));
|
||||||
|
|
||||||
inventoryComponent->AddItem(baseItem, 1, eLootSourceType::MODERATION, eInventoryType::INVALID, data);
|
inventoryComponent->AddItem(baseItem.value(), 1, eLootSourceType::MODERATION, eInventoryType::INVALID, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "crash" && entity->GetGMLevel() >= eGameMasterLevel::OPERATOR) {
|
if (chatCommand == "crash" && entity->GetGMLevel() >= eGameMasterLevel::OPERATOR) {
|
||||||
@ -1743,8 +1735,8 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
VanityUtilities::SpawnVanity();
|
VanityUtilities::SpawnVanity();
|
||||||
dpWorld::Reload();
|
dpWorld::Reload();
|
||||||
auto entities = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
auto entities = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
|
||||||
for (auto entity : entities) {
|
for (const auto* const entity : entities) {
|
||||||
auto* scriptedActivityComponent = entity->GetComponent<ScriptedActivityComponent>();
|
auto* const scriptedActivityComponent = entity->GetComponent<ScriptedActivityComponent>();
|
||||||
if (!scriptedActivityComponent) continue;
|
if (!scriptedActivityComponent) continue;
|
||||||
|
|
||||||
scriptedActivityComponent->ReloadConfig();
|
scriptedActivityComponent->ReloadConfig();
|
||||||
@ -1755,19 +1747,20 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "rollloot" && entity->GetGMLevel() >= eGameMasterLevel::OPERATOR && args.size() >= 3) {
|
if (chatCommand == "rollloot" && entity->GetGMLevel() >= eGameMasterLevel::OPERATOR && args.size() >= 3) {
|
||||||
uint32_t lootMatrixIndex = 0;
|
const auto lootMatrixIndex = GeneralUtils::TryParse<uint32_t>(args[0]);
|
||||||
uint32_t targetLot = 0;
|
if (!lootMatrixIndex) return;
|
||||||
uint32_t loops = 1;
|
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], lootMatrixIndex)) return;
|
const auto targetLot = GeneralUtils::TryParse<uint32_t>(args[1]);
|
||||||
if (!GeneralUtils::TryParse(args[1], targetLot)) return;
|
if (!targetLot) return;
|
||||||
if (!GeneralUtils::TryParse(args[2], loops)) return;
|
|
||||||
|
const auto loops = GeneralUtils::TryParse<uint32_t>(args[2]);
|
||||||
|
if (!loops) return;
|
||||||
|
|
||||||
uint64_t totalRuns = 0;
|
uint64_t totalRuns = 0;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < loops; i++) {
|
for (uint32_t i = 0; i < loops; i++) {
|
||||||
while (true) {
|
while (true) {
|
||||||
auto lootRoll = Loot::RollLootMatrix(lootMatrixIndex);
|
auto lootRoll = Loot::RollLootMatrix(lootMatrixIndex.value());
|
||||||
totalRuns += 1;
|
totalRuns += 1;
|
||||||
bool doBreak = false;
|
bool doBreak = false;
|
||||||
for (const auto& kv : lootRoll) {
|
for (const auto& kv : lootRoll) {
|
||||||
@ -1780,26 +1773,30 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::u16string message = u"Ran loot drops looking for "
|
std::u16string message = u"Ran loot drops looking for "
|
||||||
+ GeneralUtils::to_u16string(targetLot)
|
+ GeneralUtils::to_u16string(targetLot.value())
|
||||||
+ u", "
|
+ u", "
|
||||||
+ GeneralUtils::to_u16string(loops)
|
+ GeneralUtils::to_u16string(loops.value())
|
||||||
+ u" times. It ran "
|
+ u" times. It ran "
|
||||||
+ GeneralUtils::to_u16string(totalRuns)
|
+ GeneralUtils::to_u16string(totalRuns)
|
||||||
+ u" times. Averaging out at "
|
+ u" times. Averaging out at "
|
||||||
+ GeneralUtils::to_u16string(static_cast<float>(totalRuns) / loops);
|
+ GeneralUtils::to_u16string(static_cast<float>(totalRuns) / loops.value());
|
||||||
|
|
||||||
ChatPackets::SendSystemMessage(sysAddr, message);
|
ChatPackets::SendSystemMessage(sysAddr, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "deleteinven" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
if (chatCommand == "deleteinven" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
||||||
eInventoryType inventoryType = eInventoryType::INVALID;
|
eInventoryType inventoryType = eInventoryType::INVALID;
|
||||||
if (!GeneralUtils::TryParse(args[0], inventoryType)) {
|
|
||||||
|
const auto inventoryTypeOptional = GeneralUtils::TryParse<eInventoryType>(args[0]);
|
||||||
|
if (!inventoryTypeOptional) {
|
||||||
// In this case, we treat the input as a string and try to find it in the reflection list
|
// In this case, we treat the input as a string and try to find it in the reflection list
|
||||||
std::transform(args[0].begin(), args[0].end(), args[0].begin(), ::toupper);
|
std::transform(args[0].begin(), args[0].end(), args[0].begin(), ::toupper);
|
||||||
LOG("looking for inventory %s", args[0].c_str());
|
LOG("looking for inventory %s", args[0].c_str());
|
||||||
for (uint32_t index = 0; index < NUMBER_OF_INVENTORIES; index++) {
|
for (uint32_t index = 0; index < NUMBER_OF_INVENTORIES; index++) {
|
||||||
if (std::string_view(args[0]) == std::string_view(InventoryType::InventoryTypeToString(static_cast<eInventoryType>(index)))) inventoryType = static_cast<eInventoryType>(index);
|
if (std::string_view(args[0]) == std::string_view(InventoryType::InventoryTypeToString(static_cast<eInventoryType>(index)))) inventoryType = static_cast<eInventoryType>(index);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
inventoryType = inventoryTypeOptional.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inventoryType == eInventoryType::INVALID || inventoryType >= NUMBER_OF_INVENTORIES) {
|
if (inventoryType == eInventoryType::INVALID || inventoryType >= NUMBER_OF_INVENTORIES) {
|
||||||
@ -1821,32 +1818,32 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
if (chatCommand == "castskill" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
if (chatCommand == "castskill" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
||||||
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
||||||
if (skillComponent) {
|
if (skillComponent) {
|
||||||
uint32_t skillId;
|
const auto skillId = GeneralUtils::TryParse<uint32_t>(args[0]);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], skillId)) {
|
if (!skillId) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Error getting skill ID.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Error getting skill ID.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
skillComponent->CastSkill(skillId, entity->GetObjectID(), entity->GetObjectID());
|
skillComponent->CastSkill(skillId.value(), entity->GetObjectID(), entity->GetObjectID());
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Cast skill");
|
ChatPackets::SendSystemMessage(sysAddr, u"Cast skill");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatCommand == "setskillslot" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 2) {
|
if (chatCommand == "setskillslot" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 2) {
|
||||||
uint32_t skillId;
|
auto* const inventoryComponent = entity->GetComponent<InventoryComponent>();
|
||||||
int slot;
|
|
||||||
auto* inventoryComponent = entity->GetComponent<InventoryComponent>();
|
|
||||||
if (inventoryComponent) {
|
if (inventoryComponent) {
|
||||||
if (!GeneralUtils::TryParse(args[0], slot)) {
|
const auto slot = GeneralUtils::TryParse<BehaviorSlot>(args[0]);
|
||||||
|
if (!slot) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Error getting slot.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Error getting slot.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (!GeneralUtils::TryParse(args[1], skillId)) {
|
const auto skillId = GeneralUtils::TryParse<uint32_t>(args[1]);
|
||||||
|
if (!skillId) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Error getting skill.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Error getting skill.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (inventoryComponent->SetSkill(slot, skillId)) ChatPackets::SendSystemMessage(sysAddr, u"Set skill to slot successfully");
|
if (inventoryComponent->SetSkill(slot.value(), skillId.value())) ChatPackets::SendSystemMessage(sysAddr, u"Set skill to slot successfully");
|
||||||
else ChatPackets::SendSystemMessage(sysAddr, u"Set skill to slot failed");
|
else ChatPackets::SendSystemMessage(sysAddr, u"Set skill to slot failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1856,13 +1853,13 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
if (chatCommand == "setfaction" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
if (chatCommand == "setfaction" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
||||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||||
if (destroyableComponent) {
|
if (destroyableComponent) {
|
||||||
int32_t faction;
|
const auto faction = GeneralUtils::TryParse<int32_t>(args[0]);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], faction)) {
|
if (!faction) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Error getting faction.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Error getting faction.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
destroyableComponent->SetFaction(faction);
|
destroyableComponent->SetFaction(faction.value());
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Set faction and updated enemies list");
|
ChatPackets::SendSystemMessage(sysAddr, u"Set faction and updated enemies list");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1871,13 +1868,13 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
if (chatCommand == "addfaction" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
if (chatCommand == "addfaction" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
||||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||||
if (destroyableComponent) {
|
if (destroyableComponent) {
|
||||||
int32_t faction;
|
const auto faction = GeneralUtils::TryParse<int32_t>(args[0]);
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], faction)) {
|
if (!faction) {
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Error getting faction.");
|
ChatPackets::SendSystemMessage(sysAddr, u"Error getting faction.");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
destroyableComponent->AddFaction(faction);
|
destroyableComponent->AddFaction(faction.value());
|
||||||
ChatPackets::SendSystemMessage(sysAddr, u"Added faction and updated enemies list");
|
ChatPackets::SendSystemMessage(sysAddr, u"Added faction and updated enemies list");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1908,13 +1905,12 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
if (chatCommand == "inspect" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
if (chatCommand == "inspect" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
||||||
Entity* closest = nullptr;
|
Entity* closest = nullptr;
|
||||||
|
|
||||||
eReplicaComponentType component;
|
|
||||||
|
|
||||||
std::u16string ldf;
|
std::u16string ldf;
|
||||||
|
|
||||||
bool isLDF = false;
|
bool isLDF = false;
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(args[0], component)) {
|
auto component = GeneralUtils::TryParse<eReplicaComponentType>(args[0]);
|
||||||
|
if (!component) {
|
||||||
component = eReplicaComponentType::INVALID;
|
component = eReplicaComponentType::INVALID;
|
||||||
|
|
||||||
ldf = GeneralUtils::UTF8ToUTF16(args[0]);
|
ldf = GeneralUtils::UTF8ToUTF16(args[0]);
|
||||||
@ -1926,7 +1922,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
|
|
||||||
auto closestDistance = 0.0f;
|
auto closestDistance = 0.0f;
|
||||||
|
|
||||||
const auto candidates = Game::entityManager->GetEntitiesByComponent(component);
|
const auto candidates = Game::entityManager->GetEntitiesByComponent(component.value());
|
||||||
|
|
||||||
for (auto* candidate : candidates) {
|
for (auto* candidate : candidates) {
|
||||||
if (candidate->GetLOT() == 1 || candidate->GetLOT() == 8092) {
|
if (candidate->GetLOT() == 1 || candidate->GetLOT() == 8092) {
|
||||||
@ -1937,7 +1933,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (closest == nullptr) {
|
if (!closest) {
|
||||||
closest = candidate;
|
closest = candidate;
|
||||||
|
|
||||||
closestDistance = NiPoint3::Distance(candidate->GetPosition(), reference);
|
closestDistance = NiPoint3::Distance(candidate->GetPosition(), reference);
|
||||||
@ -1954,9 +1950,7 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (closest == nullptr) {
|
if (!closest) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(closest);
|
Game::entityManager->SerializeEntity(closest);
|
||||||
|
|
||||||
@ -1982,20 +1976,18 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
|
|
||||||
if (args.size() >= 2) {
|
if (args.size() >= 2) {
|
||||||
if (args[1] == "-m" && args.size() >= 3) {
|
if (args[1] == "-m" && args.size() >= 3) {
|
||||||
auto* movingPlatformComponent = closest->GetComponent<MovingPlatformComponent>();
|
auto* const movingPlatformComponent = closest->GetComponent<MovingPlatformComponent>();
|
||||||
|
|
||||||
int32_t value = 0;
|
const auto mValue = GeneralUtils::TryParse<int32_t>(args[2]);
|
||||||
|
|
||||||
if (movingPlatformComponent == nullptr || !GeneralUtils::TryParse(args[2], value)) {
|
if (!movingPlatformComponent || !mValue) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
movingPlatformComponent->SetSerialized(true);
|
movingPlatformComponent->SetSerialized(true);
|
||||||
|
|
||||||
if (value == -1) {
|
if (mValue == -1) {
|
||||||
movingPlatformComponent->StopPathing();
|
movingPlatformComponent->StopPathing();
|
||||||
} else {
|
} else {
|
||||||
movingPlatformComponent->GotoWaypoint(value);
|
movingPlatformComponent->GotoWaypoint(mValue.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::entityManager->SerializeEntity(closest);
|
Game::entityManager->SerializeEntity(closest);
|
||||||
@ -2036,13 +2028,11 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() >= 3) {
|
if (args.size() >= 3) {
|
||||||
int32_t faction;
|
const auto faction = GeneralUtils::TryParse<int32_t>(args[2]);
|
||||||
if (!GeneralUtils::TryParse(args[2], faction)) {
|
if (!faction) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
destuctable->SetFaction(-1);
|
destuctable->SetFaction(-1);
|
||||||
destuctable->AddFaction(faction, true);
|
destuctable->AddFaction(faction.value(), true);
|
||||||
}
|
}
|
||||||
} else if (args[1] == "-cf") {
|
} else if (args[1] == "-cf") {
|
||||||
auto* destuctable = entity->GetComponent<DestroyableComponent>();
|
auto* destuctable = entity->GetComponent<DestroyableComponent>();
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
InstanceManager::InstanceManager(Logger* logger, const std::string& externalIP) {
|
InstanceManager::InstanceManager(Logger* logger, const std::string& externalIP) {
|
||||||
mLogger = logger;
|
mLogger = logger;
|
||||||
mExternalIP = externalIP;
|
mExternalIP = externalIP;
|
||||||
GeneralUtils::TryParse(Game::config->GetValue("world_port_start"), m_LastPort);
|
m_LastPort =
|
||||||
|
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("world_port_start")).value_or(m_LastPort);
|
||||||
m_LastInstanceID = LWOINSTANCEID_INVALID;
|
m_LastInstanceID = LWOINSTANCEID_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ private:
|
|||||||
Logger* mLogger;
|
Logger* mLogger;
|
||||||
std::string mExternalIP;
|
std::string mExternalIP;
|
||||||
std::vector<Instance*> m_Instances;
|
std::vector<Instance*> m_Instances;
|
||||||
unsigned short m_LastPort = 3000;
|
uint16_t m_LastPort = 3000;
|
||||||
LWOINSTANCEID m_LastInstanceID;
|
LWOINSTANCEID m_LastInstanceID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,9 +89,8 @@ int main(int argc, char** argv) {
|
|||||||
if (!dConfig::Exists("worldconfig.ini")) LOG("Could not find worldconfig.ini, using default settings");
|
if (!dConfig::Exists("worldconfig.ini")) LOG("Could not find worldconfig.ini, using default settings");
|
||||||
|
|
||||||
|
|
||||||
uint32_t clientNetVersion = 171022;
|
|
||||||
const auto clientNetVersionString = Game::config->GetValue("client_net_version");
|
const auto clientNetVersionString = Game::config->GetValue("client_net_version");
|
||||||
if (!clientNetVersionString.empty()) GeneralUtils::TryParse(clientNetVersionString, clientNetVersion);
|
const uint32_t clientNetVersion = GeneralUtils::TryParse<uint32_t>(clientNetVersionString).value_or(171022);
|
||||||
|
|
||||||
LOG("Using net version %i", clientNetVersion);
|
LOG("Using net version %i", clientNetVersion);
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "ZoneInstanceManager.h"
|
#include "ZoneInstanceManager.h"
|
||||||
#include "MD5.h"
|
#include "MD5.h"
|
||||||
#include "GeneralUtils.h"
|
#include "GeneralUtils.h"
|
||||||
|
#include "ClientVersion.h"
|
||||||
|
|
||||||
#include <bcrypt/BCrypt.hpp>
|
#include <bcrypt/BCrypt.hpp>
|
||||||
|
|
||||||
@ -38,10 +39,9 @@ void AuthPackets::LoadClaimCodes() {
|
|||||||
auto rcstring = Game::config->GetValue("rewardcodes");
|
auto rcstring = Game::config->GetValue("rewardcodes");
|
||||||
auto codestrings = GeneralUtils::SplitString(rcstring, ',');
|
auto codestrings = GeneralUtils::SplitString(rcstring, ',');
|
||||||
for(auto const &codestring: codestrings){
|
for(auto const &codestring: codestrings){
|
||||||
uint32_t code = -1;
|
const auto code = GeneralUtils::TryParse<uint32_t>(codestring);
|
||||||
if(GeneralUtils::TryParse(codestring, code) && code != -1){
|
|
||||||
claimCodes.push_back(code);
|
if (code && code.value() != -1) claimCodes.push_back(code.value());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,9 +73,8 @@ void AuthPackets::SendHandshake(dServer* server, const SystemAddress& sysAddr, c
|
|||||||
RakNet::BitStream bitStream;
|
RakNet::BitStream bitStream;
|
||||||
BitStreamUtils::WriteHeader(bitStream, eConnectionType::SERVER, eServerMessageType::VERSION_CONFIRM);
|
BitStreamUtils::WriteHeader(bitStream, eConnectionType::SERVER, eServerMessageType::VERSION_CONFIRM);
|
||||||
|
|
||||||
uint32_t clientNetVersion = 171022;
|
|
||||||
const auto clientNetVersionString = Game::config->GetValue("client_net_version");
|
const auto clientNetVersionString = Game::config->GetValue("client_net_version");
|
||||||
if (!clientNetVersionString.empty()) GeneralUtils::TryParse(clientNetVersionString, clientNetVersion);
|
const uint32_t clientNetVersion = GeneralUtils::TryParse<uint32_t>(clientNetVersionString).value_or(171022);
|
||||||
|
|
||||||
bitStream.Write<uint32_t>(clientNetVersion);
|
bitStream.Write<uint32_t>(clientNetVersion);
|
||||||
bitStream.Write<uint32_t>(861228100);
|
bitStream.Write<uint32_t>(861228100);
|
||||||
@ -242,12 +241,12 @@ void AuthPackets::SendLoginResponse(dServer* server, const SystemAddress& sysAdd
|
|||||||
loginResponse.Write(LUString(Game::config->GetValue("event_7")));
|
loginResponse.Write(LUString(Game::config->GetValue("event_7")));
|
||||||
loginResponse.Write(LUString(Game::config->GetValue("event_8")));
|
loginResponse.Write(LUString(Game::config->GetValue("event_8")));
|
||||||
|
|
||||||
uint16_t version_major = 1;
|
const uint16_t version_major =
|
||||||
uint16_t version_current = 10;
|
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_major")).value_or(ClientVersion::major);
|
||||||
uint16_t version_minor = 64;
|
const uint16_t version_current =
|
||||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_major"), version_major);
|
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_current")).value_or(ClientVersion::current);
|
||||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_current"), version_current);
|
const uint16_t version_minor =
|
||||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_minor"), version_minor);
|
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_minor")).value_or(ClientVersion::minor);
|
||||||
|
|
||||||
loginResponse.Write(version_major);
|
loginResponse.Write(version_major);
|
||||||
loginResponse.Write(version_current);
|
loginResponse.Write(version_current);
|
||||||
|
@ -26,9 +26,15 @@ namespace {
|
|||||||
|
|
||||||
void dpWorld::Initialize(unsigned int zoneID, bool generateNewNavMesh) {
|
void dpWorld::Initialize(unsigned int zoneID, bool generateNewNavMesh) {
|
||||||
const auto physSpTilecount = Game::config->GetValue("phys_sp_tilecount");
|
const auto physSpTilecount = Game::config->GetValue("phys_sp_tilecount");
|
||||||
if (!physSpTilecount.empty()) GeneralUtils::TryParse(physSpTilecount, phys_sp_tilecount);
|
if (!physSpTilecount.empty()) {
|
||||||
|
phys_sp_tilecount = GeneralUtils::TryParse<int32_t>(physSpTilecount).value_or(phys_sp_tilecount);
|
||||||
|
}
|
||||||
|
|
||||||
const auto physSpTilesize = Game::config->GetValue("phys_sp_tilesize");
|
const auto physSpTilesize = Game::config->GetValue("phys_sp_tilesize");
|
||||||
if (!physSpTilesize.empty()) GeneralUtils::TryParse(physSpTilesize, phys_sp_tilesize);
|
if (!physSpTilesize.empty()) {
|
||||||
|
phys_sp_tilesize = GeneralUtils::TryParse<int32_t>(physSpTilesize).value_or(phys_sp_tilesize);
|
||||||
|
}
|
||||||
|
|
||||||
const auto physSpatialPartitioning = Game::config->GetValue("phys_spatial_partitioning");
|
const auto physSpatialPartitioning = Game::config->GetValue("phys_spatial_partitioning");
|
||||||
if (!physSpatialPartitioning.empty()) phys_spatial_partitioning = physSpatialPartitioning == "1";
|
if (!physSpatialPartitioning.empty()) phys_spatial_partitioning = physSpatialPartitioning == "1";
|
||||||
|
|
||||||
|
@ -33,14 +33,12 @@ void AmDropshipComputer::OnUse(Entity* self, Entity* user) {
|
|||||||
void AmDropshipComputer::OnDie(Entity* self, Entity* killer) {
|
void AmDropshipComputer::OnDie(Entity* self, Entity* killer) {
|
||||||
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
|
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
|
||||||
|
|
||||||
int32_t pipeNum = 0;
|
const auto pipeNum = GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1));
|
||||||
if (!GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1), pipeNum)) {
|
if (!pipeNum) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto pipeGroup = myGroup.substr(0, 10);
|
const auto pipeGroup = myGroup.substr(0, 10);
|
||||||
|
|
||||||
const auto nextPipeNum = pipeNum + 1;
|
const auto nextPipeNum = pipeNum.value() + 1;
|
||||||
|
|
||||||
const auto samePipeSpawners = Game::zoneManager->GetSpawnersByName(myGroup);
|
const auto samePipeSpawners = Game::zoneManager->GetSpawnersByName(myGroup);
|
||||||
|
|
||||||
@ -70,11 +68,9 @@ void AmDropshipComputer::OnDie(Entity* self, Entity* killer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AmDropshipComputer::OnTimerDone(Entity* self, std::string timerName) {
|
void AmDropshipComputer::OnTimerDone(Entity* self, std::string timerName) {
|
||||||
auto* quickBuildComponent = self->GetComponent<QuickBuildComponent>();
|
const auto* const quickBuildComponent = self->GetComponent<QuickBuildComponent>();
|
||||||
|
|
||||||
if (quickBuildComponent == nullptr) {
|
if (!quickBuildComponent) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (timerName == "reset" && quickBuildComponent->GetState() == eQuickBuildState::OPEN) {
|
if (timerName == "reset" && quickBuildComponent->GetState() == eQuickBuildState::OPEN) {
|
||||||
self->Smash(self->GetObjectID(), eKillType::SILENT);
|
self->Smash(self->GetObjectID(), eKillType::SILENT);
|
||||||
|
@ -144,13 +144,10 @@ void AmSkullkinTower::OnChildRemoved(Entity* self, Entity* child) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
for (const auto& mission : missions) {
|
for (const auto& mission : missions) {
|
||||||
int32_t missionID = 0;
|
const auto missionID = GeneralUtils::TryParse<int32_t>(mission);
|
||||||
|
if (!missionID) continue;
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(mission, missionID)) {
|
missionIDs.push_back(missionID.value());
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
missionIDs.push_back(missionID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,12 +12,9 @@ void AmTemplateSkillVolume::OnSkillEventFired(Entity* self, Entity* caster, cons
|
|||||||
const auto missionIDs = GeneralUtils::SplitString(missionIDsVariable, '_');
|
const auto missionIDs = GeneralUtils::SplitString(missionIDsVariable, '_');
|
||||||
|
|
||||||
for (const auto& missionIDStr : missionIDs) {
|
for (const auto& missionIDStr : missionIDs) {
|
||||||
int32_t missionID = 0;
|
const auto missionID = GeneralUtils::TryParse<uint32_t>(missionIDStr);
|
||||||
|
if (!missionID) continue;
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(missionIDStr, missionID)) {
|
missionComponent->ForceProgressTaskType(missionID.value(), 1, 1, false);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
missionComponent->ForceProgressTaskType(missionID, 1, 1, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,9 @@ void ChooseYourDestinationNsToNt::SetDestination(Entity* self, Entity* player) {
|
|||||||
void ChooseYourDestinationNsToNt::BaseChoiceBoxRespond(Entity* self, Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier) {
|
void ChooseYourDestinationNsToNt::BaseChoiceBoxRespond(Entity* self, Entity* sender, int32_t button, const std::u16string& buttonIdentifier, const std::u16string& identifier) {
|
||||||
if (button != -1) {
|
if (button != -1) {
|
||||||
const auto newMapStr = GeneralUtils::UTF16ToWTF8(buttonIdentifier).substr(7, -1);
|
const auto newMapStr = GeneralUtils::UTF16ToWTF8(buttonIdentifier).substr(7, -1);
|
||||||
|
const auto newMap = GeneralUtils::TryParse<int32_t>(newMapStr);
|
||||||
|
|
||||||
int32_t newMap = 0;
|
if (!newMap) return;
|
||||||
if (!GeneralUtils::TryParse(newMapStr, newMap)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::u16string strText = u"";
|
std::u16string strText = u"";
|
||||||
|
|
||||||
@ -56,7 +54,7 @@ void ChooseYourDestinationNsToNt::BaseChoiceBoxRespond(Entity* self, Entity* sen
|
|||||||
}
|
}
|
||||||
|
|
||||||
self->SetVar(u"teleportString", strText);
|
self->SetVar(u"teleportString", strText);
|
||||||
self->SetVar(u"transferZoneID", GeneralUtils::to_u16string(newMap));
|
self->SetVar(u"transferZoneID", GeneralUtils::to_u16string(newMap.value()));
|
||||||
|
|
||||||
GameMessages::SendDisplayMessageBox(sender->GetObjectID(), true, self->GetObjectID(), u"TransferBox", 0, strText, u"", sender->GetSystemAddress());
|
GameMessages::SendDisplayMessageBox(sender->GetObjectID(), true, self->GetObjectID(), u"TransferBox", 0, strText, u"", sender->GetSystemAddress());
|
||||||
} else {
|
} else {
|
||||||
|
@ -7,10 +7,8 @@
|
|||||||
void FvBrickPuzzleServer::OnStartup(Entity* self) {
|
void FvBrickPuzzleServer::OnStartup(Entity* self) {
|
||||||
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
|
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
|
||||||
|
|
||||||
int32_t pipeNum = 0;
|
const auto pipeNum = GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1));
|
||||||
if (!GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1), pipeNum)) {
|
if (!pipeNum) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pipeNum != 1) {
|
if (pipeNum != 1) {
|
||||||
self->AddTimer("reset", 30);
|
self->AddTimer("reset", 30);
|
||||||
@ -20,14 +18,12 @@ void FvBrickPuzzleServer::OnStartup(Entity* self) {
|
|||||||
void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) {
|
void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) {
|
||||||
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
|
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
|
||||||
|
|
||||||
int32_t pipeNum = 0;
|
const auto pipeNum = GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1));
|
||||||
if (!GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1), pipeNum)) {
|
if (!pipeNum) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto pipeGroup = myGroup.substr(0, 10);
|
const auto pipeGroup = myGroup.substr(0, 10);
|
||||||
|
|
||||||
const auto nextPipeNum = pipeNum + 1;
|
const auto nextPipeNum = pipeNum.value() + 1;
|
||||||
|
|
||||||
const auto samePipeSpawners = Game::zoneManager->GetSpawnersByName(myGroup);
|
const auto samePipeSpawners = Game::zoneManager->GetSpawnersByName(myGroup);
|
||||||
|
|
||||||
@ -37,7 +33,7 @@ void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) {
|
|||||||
samePipeSpawners[0]->Deactivate();
|
samePipeSpawners[0]->Deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (killer != nullptr && killer->IsPlayer()) {
|
if (killer && killer->IsPlayer()) {
|
||||||
const auto nextPipe = pipeGroup + std::to_string(nextPipeNum);
|
const auto nextPipe = pipeGroup + std::to_string(nextPipeNum);
|
||||||
|
|
||||||
const auto nextPipeSpawners = Game::zoneManager->GetSpawnersByName(nextPipe);
|
const auto nextPipeSpawners = Game::zoneManager->GetSpawnersByName(nextPipe);
|
||||||
|
@ -208,8 +208,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
UserManager::Instance()->Initialize();
|
UserManager::Instance()->Initialize();
|
||||||
|
|
||||||
bool dontGenerateDCF = false;
|
const bool dontGenerateDCF = GeneralUtils::TryParse<bool>(Game::config->GetValue("dont_generate_dcf")).value_or(false);
|
||||||
GeneralUtils::TryParse(Game::config->GetValue("dont_generate_dcf"), dontGenerateDCF);
|
|
||||||
Game::chatFilter = new dChatFilter(Game::assetManager->GetResPath().string() + "/chatplus_en_us", dontGenerateDCF);
|
Game::chatFilter = new dChatFilter(Game::assetManager->GetResPath().string() + "/chatplus_en_us", dontGenerateDCF);
|
||||||
|
|
||||||
Game::server = new dServer(masterIP, ourPort, instanceID, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::World, Game::config, &Game::lastSignal, zoneID);
|
Game::server = new dServer(masterIP, ourPort, instanceID, maxClients, false, true, Game::logger, masterIP, masterPort, ServerType::World, Game::config, &Game::lastSignal, zoneID);
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "CDFeatureGatingTable.h"
|
#include "CDFeatureGatingTable.h"
|
||||||
#include "CDClientManager.h"
|
#include "CDClientManager.h"
|
||||||
#include "AssetManager.h"
|
#include "AssetManager.h"
|
||||||
|
#include "ClientVersion.h"
|
||||||
#include "dConfig.h"
|
#include "dConfig.h"
|
||||||
|
|
||||||
Level::Level(Zone* parentZone, const std::string& filepath) {
|
Level::Level(Zone* parentZone, const std::string& filepath) {
|
||||||
@ -211,12 +212,12 @@ void Level::ReadSceneObjectDataChunk(std::istream& file, Header& header) {
|
|||||||
CDFeatureGatingTable* featureGatingTable = CDClientManager::GetTable<CDFeatureGatingTable>();
|
CDFeatureGatingTable* featureGatingTable = CDClientManager::GetTable<CDFeatureGatingTable>();
|
||||||
|
|
||||||
CDFeatureGating gating;
|
CDFeatureGating gating;
|
||||||
gating.major = 1;
|
gating.major =
|
||||||
gating.current = 10;
|
GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_major")).value_or(ClientVersion::major);
|
||||||
gating.minor = 64;
|
gating.current =
|
||||||
GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_major"), gating.major);
|
GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_current")).value_or(ClientVersion::current);
|
||||||
GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_current"), gating.current);
|
gating.minor =
|
||||||
GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_minor"), gating.minor);
|
GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_minor")).value_or(ClientVersion::minor);
|
||||||
|
|
||||||
const auto zoneControlObject = Game::zoneManager->GetZoneControlObject();
|
const auto zoneControlObject = Game::zoneManager->GetZoneControlObject();
|
||||||
DluAssert(zoneControlObject != nullptr);
|
DluAssert(zoneControlObject != nullptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user