mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-01-27 15:17:02 +00:00
move to std optional
This commit is contained in:
parent
dc526aeec1
commit
ff173dffce
@ -53,13 +53,8 @@ void CDZoneTableTable::LoadValuesFromDatabase() {
|
||||
}
|
||||
|
||||
//! Queries the table with a zoneID to find.
|
||||
const CDZoneTable* CDZoneTableTable::Query(unsigned int zoneID) {
|
||||
const std::optional<CDZoneTable> CDZoneTableTable::Query(unsigned int zoneID) {
|
||||
const auto& iter = m_Entries.find(zoneID);
|
||||
|
||||
if (iter != m_Entries.end()) {
|
||||
return &iter->second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return iter != m_Entries.end() ? std::make_optional(iter->second) : std::nullopt;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
// Custom Classes
|
||||
#include "CDTable.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
struct CDZoneTable {
|
||||
unsigned int zoneID; //!< The Zone ID of the object
|
||||
unsigned int locStatus; //!< The Locale Status(?)
|
||||
@ -41,5 +42,5 @@ public:
|
||||
void LoadValuesFromDatabase();
|
||||
|
||||
// Queries the table with a zoneID to find.
|
||||
const CDZoneTable* Query(unsigned int zoneID);
|
||||
const std::optional<CDZoneTable> Query(unsigned int zoneID);
|
||||
};
|
||||
|
@ -504,11 +504,11 @@ void Entity::Initialize() {
|
||||
|
||||
// ZoneControl script
|
||||
if (m_TemplateID == 2365) {
|
||||
CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
||||
auto* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
||||
const auto zoneID = Game::zoneManager->GetZoneID();
|
||||
const CDZoneTable* zoneData = zoneTable->Query(zoneID.GetMapID());
|
||||
auto zoneData = zoneTable->Query(zoneID.GetMapID());
|
||||
|
||||
if (zoneData != nullptr) {
|
||||
if (zoneData) {
|
||||
int zoneScriptID = zoneData->scriptID;
|
||||
CDScriptComponent zoneScriptData = scriptCompTable->GetByID(zoneScriptID);
|
||||
|
||||
|
@ -84,7 +84,6 @@
|
||||
#include "eMasterMessageType.h"
|
||||
|
||||
#include "CDObjectsTable.h"
|
||||
#include "CDZoneTableTable.h"
|
||||
|
||||
void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entity* entity, const SystemAddress& sysAddr) {
|
||||
auto commandCopy = command;
|
||||
|
@ -372,9 +372,9 @@ Instance* InstanceManager::FindPrivateInstance(const std::string& password) {
|
||||
int InstanceManager::GetSoftCap(LWOMAPID mapID) {
|
||||
CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
||||
if (zoneTable) {
|
||||
const CDZoneTable* zone = zoneTable->Query(mapID);
|
||||
auto zone = zoneTable->Query(mapID);
|
||||
|
||||
if (zone != nullptr) {
|
||||
if (zone) {
|
||||
return zone->population_soft_cap;
|
||||
}
|
||||
}
|
||||
@ -385,9 +385,9 @@ int InstanceManager::GetSoftCap(LWOMAPID mapID) {
|
||||
int InstanceManager::GetHardCap(LWOMAPID mapID) {
|
||||
CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
||||
if (zoneTable) {
|
||||
const CDZoneTable* zone = zoneTable->Query(mapID);
|
||||
auto zone = zoneTable->Query(mapID);
|
||||
|
||||
if (zone != nullptr) {
|
||||
if (zone) {
|
||||
return zone->population_hard_cap;
|
||||
}
|
||||
}
|
||||
|
@ -165,8 +165,8 @@ void Zone::LoadZoneIntoMemory() {
|
||||
std::string Zone::GetFilePathForZoneID() {
|
||||
//We're gonna go ahead and presume we've got the db loaded already:
|
||||
CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
||||
const CDZoneTable* zone = zoneTable->Query(this->GetZoneID().GetMapID());
|
||||
if (zone != nullptr) {
|
||||
auto zone = zoneTable->Query(this->GetZoneID().GetMapID());
|
||||
if (zone) {
|
||||
std::string toReturn = "maps/" + zone->zoneName;
|
||||
std::transform(toReturn.begin(), toReturn.end(), toReturn.begin(), ::tolower);
|
||||
return toReturn;
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "CDZoneTableTable.h"
|
||||
#include <chrono>
|
||||
#include "eObjectBits.h"
|
||||
#include "CDZoneTableTable.h"
|
||||
#include "AssetManager.h"
|
||||
|
||||
#include "../dWorldServer/ObjectIDManager.h"
|
||||
@ -31,9 +30,9 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
|
||||
|
||||
CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
||||
if (zoneTable != nullptr) {
|
||||
const CDZoneTable* zone = zoneTable->Query(zoneID.GetMapID());
|
||||
auto zone = zoneTable->Query(zoneID.GetMapID());
|
||||
|
||||
if (zone != nullptr) {
|
||||
if (zone) {
|
||||
zoneControlTemplate = zone->zoneControlTemplate != -1 ? zone->zoneControlTemplate : 2365;
|
||||
const auto min = zone->ghostdistance_min != -1.0f ? zone->ghostdistance_min : 100;
|
||||
const auto max = zone->ghostdistance != -1.0f ? zone->ghostdistance : 100;
|
||||
@ -235,8 +234,8 @@ uint32_t dZoneManager::GetUniqueMissionIdStartingValue() {
|
||||
bool dZoneManager::CheckIfAccessibleZone(LWOMAPID zoneID) {
|
||||
//We're gonna go ahead and presume we've got the db loaded already:
|
||||
CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
|
||||
const CDZoneTable* zone = zoneTable->Query(zoneID);
|
||||
if (zone != nullptr) {
|
||||
auto zone = zoneTable->Query(zoneID);
|
||||
if (zone) {
|
||||
return Game::assetManager->HasFile(("maps/" + zone->zoneName).c_str());
|
||||
} else {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user