Merge branch 'main' into npc-pathing

This commit is contained in:
David Markowitz
2023-07-27 21:16:13 -07:00
321 changed files with 3729 additions and 3728 deletions

View File

@@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <cstdint>
class Command;
class Event;

View File

@@ -179,8 +179,8 @@ void Level::ReadSceneObjectDataChunk(std::istream& file, Header& header) {
//This is a little bit of a bodge, but because the alpha client (HF) doesn't store the
//spawn position / rotation like the later versions do, we need to check the LOT for the spawn pos & set it.
if (obj.lot == LOT_MARKER_PLAYER_START) {
dZoneManager::Instance()->GetZone()->SetSpawnPos(obj.position);
dZoneManager::Instance()->GetZone()->SetSpawnRot(obj.rotation);
Game::zoneManager->GetZone()->SetSpawnPos(obj.position);
Game::zoneManager->GetZone()->SetSpawnRot(obj.rotation);
}
std::u16string ldfString = u"";
@@ -297,7 +297,7 @@ void Level::ReadSceneObjectDataChunk(std::istream& file, Header& header) {
}
}
Spawner* spawner = new Spawner(spawnInfo);
dZoneManager::Instance()->AddSpawner(obj.id, spawner);
Game::zoneManager->AddSpawner(obj.id, spawner);
} else { //Regular object
EntityInfo info;
info.spawnerID = 0;
@@ -328,11 +328,11 @@ void Level::ReadSceneObjectDataChunk(std::istream& file, Header& header) {
if (!clientOnly) {
// We should never have more than 1 zone control object
const auto zoneControlObject = dZoneManager::Instance()->GetZoneControlObject();
const auto zoneControlObject = Game::zoneManager->GetZoneControlObject();
if (zoneControlObject != nullptr && info.lot == zoneControlObject->GetLOT())
goto deleteSettings;
EntityManager::Instance()->CreateEntity(info, nullptr);
Game::entityManager->CreateEntity(info, nullptr);
} else {
deleteSettings:

View File

@@ -30,12 +30,6 @@ public:
struct SceneObjectDataChunk {
std::map<LWOOBJID, SceneObject> objects;
SceneObject& GetObject(LWOOBJID id) {
for (std::map<LWOOBJID, SceneObject>::iterator it = objects.begin(); it != objects.end(); ++it) {
if (it->first == id) return it->second;
}
}
const void PrintAllObjects() {
for (std::map<LWOOBJID, SceneObject>::iterator it = objects.begin(); it != objects.end(); ++it) {
std::cout << "\t ID: " << it->first << " LOT: " << it->second.lot << std::endl;

View File

@@ -46,9 +46,9 @@ Spawner::Spawner(const SpawnerInfo info) {
}
if (m_Info.spawnOnSmashGroupName != "") {
std::vector<Entity*> spawnSmashEntities = EntityManager::Instance()->GetEntitiesInGroup(m_Info.spawnOnSmashGroupName);
std::vector<Spawner*> spawnSmashSpawners = dZoneManager::Instance()->GetSpawnersInGroup(m_Info.spawnOnSmashGroupName);
std::vector<Spawner*> spawnSmashSpawnersN = dZoneManager::Instance()->GetSpawnersByName(m_Info.spawnOnSmashGroupName);
std::vector<Entity*> spawnSmashEntities = Game::entityManager->GetEntitiesInGroup(m_Info.spawnOnSmashGroupName);
std::vector<Spawner*> spawnSmashSpawners = Game::zoneManager->GetSpawnersInGroup(m_Info.spawnOnSmashGroupName);
std::vector<Spawner*> spawnSmashSpawnersN = Game::zoneManager->GetSpawnersByName(m_Info.spawnOnSmashGroupName);
for (Entity* ssEntity : spawnSmashEntities) {
m_SpawnSmashFoundGroup = true;
ssEntity->AddDieCallback([=]() {
@@ -102,11 +102,11 @@ Entity* Spawner::Spawn(std::vector<SpawnerNode*> freeNodes, const bool force) {
m_EntityInfo.spawnerID = m_Info.spawnerID;
}
Entity* rezdE = EntityManager::Instance()->CreateEntity(m_EntityInfo, nullptr);
Entity* rezdE = Game::entityManager->CreateEntity(m_EntityInfo, nullptr);
rezdE->GetGroups() = m_Info.groups;
EntityManager::Instance()->ConstructEntity(rezdE);
Game::entityManager->ConstructEntity(rezdE);
m_Entities.insert({ rezdE->GetObjectID(), spawnNode });
spawnNode->entities.push_back(rezdE->GetObjectID());
@@ -143,7 +143,7 @@ void Spawner::Reset() {
void Spawner::DestroyAllEntities(){
for (auto* node : m_Info.nodes) {
for (const auto& element : node->entities) {
auto* entity = EntityManager::Instance()->GetEntity(element);
auto* entity = Game::entityManager->GetEntity(element);
if (entity == nullptr) continue;
entity->Kill();
}

View File

@@ -149,7 +149,7 @@ void Zone::LoadZoneIntoMemory() {
info.activeOnLoad = path.spawner.spawnerNetActive;
info.isNetwork = true;
Spawner* spawner = new Spawner(info);
dZoneManager::Instance()->AddSpawner(info.spawnerID, spawner);
Game::zoneManager->AddSpawner(info.spawnerID, spawner);
}
}

View File

@@ -12,11 +12,11 @@
#include "CDZoneTableTable.h"
#include <chrono>
#include "eObjectBits.h"
#include "CDZoneTableTable.h"
#include "AssetManager.h"
#include "../dWorldServer/ObjectIDManager.h"
dZoneManager* dZoneManager::m_Address = nullptr;
void dZoneManager::Initialize(const LWOZONEID& zoneID) {
Game::logger->Log("dZoneManager", "Preparing zone: %i/%i/%i", zoneID.GetMapID(), zoneID.GetInstanceID(), zoneID.GetCloneID());
@@ -37,8 +37,8 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
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;
EntityManager::Instance()->SetGhostDistanceMax(max + min);
EntityManager::Instance()->SetGhostDistanceMin(max);
Game::entityManager->SetGhostDistanceMax(max + min);
Game::entityManager->SetGhostDistanceMin(max);
m_PlayerLoseCoinsOnDeath = zone->PlayerLoseCoinsOnDeath;
}
}
@@ -46,10 +46,15 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
Game::logger->Log("dZoneManager", "Creating zone control object %i", zoneControlTemplate);
// Create ZoneControl object
if (!Game::entityManager) {
Game::logger->Log("dZoneManager", "ERROR: No entity manager loaded. Cannot proceed.");
throw std::invalid_argument("No entity manager loaded. Cannot proceed.");
}
Game::entityManager->Initialize();
EntityInfo info;
info.lot = zoneControlTemplate;
info.id = 70368744177662;
Entity* zoneControl = EntityManager::Instance()->CreateEntity(info, nullptr, nullptr, true);
Entity* zoneControl = Game::entityManager->CreateEntity(info, nullptr, nullptr, true);
m_ZoneControlObject = zoneControl;
m_pZone->Initalize();
@@ -146,9 +151,9 @@ LWOOBJID dZoneManager::MakeSpawner(SpawnerInfo info) {
entityInfo.id = objectId;
entityInfo.lot = 176;
auto* entity = EntityManager::Instance()->CreateEntity(entityInfo, nullptr, nullptr, false, objectId);
auto* entity = Game::entityManager->CreateEntity(entityInfo, nullptr, nullptr, false, objectId);
EntityManager::Instance()->ConstructEntity(entity);
Game::entityManager->ConstructEntity(entity);
AddSpawner(objectId, spawner);
@@ -173,7 +178,7 @@ void dZoneManager::RemoveSpawner(const LWOOBJID id) {
return;
}
auto* entity = EntityManager::Instance()->GetEntity(id);
auto* entity = Game::entityManager->GetEntity(id);
if (entity != nullptr) {
entity->Kill();
@@ -227,6 +232,17 @@ uint32_t dZoneManager::GetUniqueMissionIdStartingValue() {
return m_UniqueMissionIdStart;
}
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) {
return Game::assetManager->HasFile(("maps/" + zone->zoneName).c_str());
} else {
return false;
}
}
void dZoneManager::LoadWorldConfig() {
Game::logger->Log("dZoneManager", "Loading WorldConfig into memory");

View File

@@ -25,14 +25,6 @@ private:
void LoadWorldConfig();
public:
static dZoneManager* Instance() {
if (!m_Address) {
m_Address = new dZoneManager();
}
return m_Address;
}
void Initialize(const LWOZONEID& zoneID);
~dZoneManager();
@@ -50,6 +42,7 @@ public:
Entity* GetZoneControlObject() { return m_ZoneControlObject; }
bool GetPlayerLoseCoinOnDeath() { return m_PlayerLoseCoinsOnDeath; }
uint32_t GetUniqueMissionIdStartingValue();
bool CheckIfAccessibleZone(LWOMAPID zoneID);
// The world config should not be modified by a caller.
const WorldConfig* GetWorldConfig() {
@@ -63,7 +56,6 @@ private:
*/
uint32_t m_UniqueMissionIdStart = 0;
static dZoneManager* m_Address; //Singleton
Zone* m_pZone = nullptr;
LWOZONEID m_ZoneID;
bool m_PlayerLoseCoinsOnDeath; //Do players drop coins in this zone when smashed