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