mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-22 13:33:35 +00:00
Update in response to feedback
This commit is contained in:
parent
74d8a5b167
commit
27f69d6152
@ -176,7 +176,7 @@ namespace GeneralUtils {
|
||||
template <std::floating_point T>
|
||||
[[nodiscard]] std::optional<T> TryParse(const char* const str, const char* const strEnd = NULL) noexcept
|
||||
try {
|
||||
return std::make_optional<T>(std::stold(str));
|
||||
return std::stold(str);
|
||||
} catch (...) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@ -27,6 +27,13 @@ constexpr uint32_t highFrameDelta = FRAMES_TO_MS(highFramerate);
|
||||
constexpr uint32_t mediumFrameDelta = FRAMES_TO_MS(mediumFramerate);
|
||||
constexpr uint32_t lowFrameDelta = FRAMES_TO_MS(lowFramerate);
|
||||
|
||||
//========== CLIENT VERSION DEFAULTS ===========
|
||||
namespace ClientVersion {
|
||||
constexpr uint16_t major = 1;
|
||||
constexpr uint16_t current = 10;
|
||||
constexpr uint16_t minor = 64;
|
||||
}
|
||||
|
||||
//========== MACROS ===========
|
||||
|
||||
#define HEADER_SIZE 8
|
||||
|
@ -22,8 +22,8 @@ TriggerComponent::TriggerComponent(Entity* parent, const std::string triggerInfo
|
||||
|
||||
std::vector<std::string> tokens = GeneralUtils::SplitString(triggerInfo, ':');
|
||||
|
||||
const auto sceneID = GeneralUtils::TryParse<uint32_t>(tokens.at(0)).value();
|
||||
const auto triggerID = GeneralUtils::TryParse<uint32_t>(tokens.at(1)).value();
|
||||
const auto sceneID = GeneralUtils::TryParse<uint32_t>(tokens.at(0)).value_or(0);
|
||||
const auto triggerID = GeneralUtils::TryParse<uint32_t>(tokens.at(1)).value_or(0);
|
||||
|
||||
m_Trigger = Game::zoneManager->GetZone()->GetTrigger(sceneID, triggerID);
|
||||
|
||||
@ -189,7 +189,7 @@ void TriggerComponent::HandleFireEvent(Entity* targetEntity, std::string args) {
|
||||
}
|
||||
|
||||
void TriggerComponent::HandleDestroyObject(Entity* targetEntity, std::string args){
|
||||
const eKillType killType = GeneralUtils::TryParse<eKillType>(args).value_or(eKillType::SILENT);
|
||||
const eKillType killType = GeneralUtils::TryParse<eKillType>(args).value_or(eKillType::VIOLENT);
|
||||
targetEntity->Smash(m_Parent->GetObjectID(), killType);
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ void TriggerComponent::HandleRepelObject(Entity* targetEntity, std::string args)
|
||||
LOG_DEBUG("Phantom Physics component not found!");
|
||||
return;
|
||||
}
|
||||
const float forceMultiplier = GeneralUtils::TryParse<float>(args).value();
|
||||
const float forceMultiplier = GeneralUtils::TryParse<float>(args).value_or(1.0f);
|
||||
|
||||
phantomPhysicsComponent->SetPhysicsEffectActive(true);
|
||||
phantomPhysicsComponent->SetEffectType(ePhysicsEffectType::REPULSE);
|
||||
@ -356,7 +356,7 @@ void TriggerComponent::HandleCastSkill(Entity* targetEntity, std::string args){
|
||||
LOG_DEBUG("Skill component not found!");
|
||||
return;
|
||||
}
|
||||
const uint32_t skillId = GeneralUtils::TryParse<uint32_t>(args).value();
|
||||
const uint32_t skillId = GeneralUtils::TryParse<uint32_t>(args).value_or(0);
|
||||
skillComponent->CastSkill(skillId, targetEntity->GetObjectID());
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "dCommonVars.h"
|
||||
|
||||
BehaviorMessageBase::BehaviorMessageBase(AMFArrayValue* arguments) {
|
||||
this->behaviorId = GetBehaviorIdFromArgument(arguments);
|
||||
m_BehaviorId = GetBehaviorIdFromArgument(arguments);
|
||||
}
|
||||
|
||||
int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments) {
|
||||
@ -13,13 +13,13 @@ int32_t BehaviorMessageBase::GetBehaviorIdFromArgument(AMFArrayValue* arguments)
|
||||
auto* behaviorIDValue = arguments->Get<std::string>(key);
|
||||
|
||||
if (behaviorIDValue && behaviorIDValue->GetValueType() == eAmf::String) {
|
||||
this->behaviorId =
|
||||
GeneralUtils::TryParse<int32_t>(behaviorIDValue->GetValue()).value_or(this->behaviorId);
|
||||
m_BehaviorId =
|
||||
GeneralUtils::TryParse<int32_t>(behaviorIDValue->GetValue()).value_or(m_BehaviorId);
|
||||
} else if (arguments->Get(key) && arguments->Get(key)->GetValueType() != eAmf::Undefined) {
|
||||
throw std::invalid_argument("Unable to find behavior ID");
|
||||
}
|
||||
|
||||
return this->behaviorId;
|
||||
return m_BehaviorId;
|
||||
}
|
||||
|
||||
int32_t BehaviorMessageBase::GetActionIndexFromArgument(AMFArrayValue* arguments, const std::string& keyName) {
|
||||
|
@ -16,13 +16,13 @@ enum class BehaviorState : uint32_t;
|
||||
class BehaviorMessageBase {
|
||||
public:
|
||||
static inline int32_t DefaultBehaviorId = -1;
|
||||
const int32_t GetBehaviorId() const { return behaviorId; };
|
||||
bool IsDefaultBehaviorId() { return behaviorId == DefaultBehaviorId; };
|
||||
const int32_t GetBehaviorId() const { return m_BehaviorId; };
|
||||
bool IsDefaultBehaviorId() { return m_BehaviorId == DefaultBehaviorId; };
|
||||
BehaviorMessageBase(AMFArrayValue* arguments);
|
||||
protected:
|
||||
int32_t GetBehaviorIdFromArgument(AMFArrayValue* arguments);
|
||||
int32_t GetActionIndexFromArgument(AMFArrayValue* arguments, const std::string& keyName = "actionIndex");
|
||||
int32_t behaviorId = DefaultBehaviorId;
|
||||
int32_t m_BehaviorId = DefaultBehaviorId;
|
||||
};
|
||||
|
||||
#endif //!__BEHAVIORMESSAGEBASE__H__
|
||||
|
@ -1902,8 +1902,6 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
if (chatCommand == "inspect" && entity->GetGMLevel() >= eGameMasterLevel::DEVELOPER && args.size() >= 1) {
|
||||
Entity* closest = nullptr;
|
||||
|
||||
//eReplicaComponentType component;
|
||||
|
||||
std::u16string ldf;
|
||||
|
||||
bool isLDF = false;
|
||||
|
@ -18,7 +18,7 @@ InstanceManager::InstanceManager(Logger* logger, const std::string& externalIP)
|
||||
mLogger = logger;
|
||||
mExternalIP = externalIP;
|
||||
m_LastPort =
|
||||
GeneralUtils::TryParse<decltype(m_LastPort)>(Game::config->GetValue("world_port_start")).value_or(m_LastPort);
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("world_port_start")).value_or(m_LastPort);
|
||||
m_LastInstanceID = LWOINSTANCEID_INVALID;
|
||||
}
|
||||
|
||||
|
@ -241,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_8")));
|
||||
|
||||
uint16_t version_major = 1;
|
||||
uint16_t version_current = 10;
|
||||
uint16_t version_minor = 64;
|
||||
version_major = GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_major")).value_or(version_major);
|
||||
version_current = GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_current")).value_or(version_current);
|
||||
version_minor = GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_minor")).value_or(version_minor);
|
||||
const uint16_t version_major =
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_major")).value_or(ClientVersion::major);
|
||||
const uint16_t version_current =
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_current")).value_or(ClientVersion::current);
|
||||
const uint16_t version_minor =
|
||||
GeneralUtils::TryParse<uint16_t>(Game::config->GetValue("version_minor")).value_or(ClientVersion::minor);
|
||||
|
||||
loginResponse.Write(version_major);
|
||||
loginResponse.Write(version_current);
|
||||
|
@ -144,7 +144,7 @@ void AmSkullkinTower::OnChildRemoved(Entity* self, Entity* child) {
|
||||
);
|
||||
|
||||
for (const auto& mission : missions) {
|
||||
const auto missionID = GeneralUtils::TryParse<LOT>(mission);
|
||||
const auto missionID = GeneralUtils::TryParse<int32_t>(mission);
|
||||
if (!missionID) continue;
|
||||
|
||||
missionIDs.push_back(missionID.value());
|
||||
|
@ -211,12 +211,12 @@ void Level::ReadSceneObjectDataChunk(std::istream& file, Header& header) {
|
||||
CDFeatureGatingTable* featureGatingTable = CDClientManager::Instance().GetTable<CDFeatureGatingTable>();
|
||||
|
||||
CDFeatureGating gating;
|
||||
gating.major = 1;
|
||||
gating.current = 10;
|
||||
gating.minor = 64;
|
||||
gating.major = GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_major")).value_or(gating.major);
|
||||
gating.current = GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_current")).value_or(gating.current);
|
||||
gating.minor = GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_minor")).value_or(gating.minor);
|
||||
gating.major =
|
||||
GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_major")).value_or(ClientVersion::major);
|
||||
gating.current =
|
||||
GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_current")).value_or(ClientVersion::current);
|
||||
gating.minor =
|
||||
GeneralUtils::TryParse<int32_t>(Game::config->GetValue("version_minor")).value_or(ClientVersion::minor);
|
||||
|
||||
const auto zoneControlObject = Game::zoneManager->GetZoneControlObject();
|
||||
DluAssert(zoneControlObject != nullptr);
|
||||
|
Loading…
Reference in New Issue
Block a user