Move EntityManager to Game namespace (#1140)

* Move EntityManager to Game namespace

* move initialization to later

Need to wait for dZoneManager to be initialized.

* Fix bugs

- Cannot delete from a RandomAccessIterator while in a range based for loop.

Touchup zone manager initialize

replace magic numbers with better named constants
replace magic zonecontrol id with a more readable hex alternative
condense stack variables
move initializers closer to their use
initialize entity manager with zone control

change initialize timings

If zone is not zero we expect to initialize the entity manager during zone manager initialization

Add constexpr for zone control LOT

* Add proper error handling

* revert vanity changes

* Update WorldServer.cpp

* Update dZoneManager.cpp
This commit is contained in:
David Markowitz
2023-07-15 13:56:33 -07:00
committed by GitHub
parent 9375c36c7b
commit 455f9470a5
200 changed files with 861 additions and 862 deletions

View File

@@ -195,7 +195,7 @@ void BaseWavesServer::OnActivityTimerDone(Entity* self, const std::string& name)
ActivityTimerStart(self, PlaySpawnSoundTimer, 3, 3);
} else if (name == PlaySpawnSoundTimer) {
for (const auto& playerID : state.players) {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player != nullptr) {
GameMessages::SendPlayNDAudioEmitter(player, player->GetSystemAddress(), spawnSoundGUID);
}
@@ -216,7 +216,7 @@ void BaseWavesServer::OnActivityTimerDone(Entity* self, const std::string& name)
} else if (name == GameOverWinTimer) {
GameOver(self, true);
} else if (name == CinematicDoneTimer) {
for (auto* boss : EntityManager::Instance()->GetEntitiesInGroup("boss")) {
for (auto* boss : Game::entityManager->GetEntitiesInGroup("boss")) {
boss->OnFireEventServerSide(self, "startAI");
}
}
@@ -224,7 +224,7 @@ void BaseWavesServer::OnActivityTimerDone(Entity* self, const std::string& name)
// Done
void BaseWavesServer::ResetStats(LWOOBJID playerID) {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player != nullptr) {
// Boost all the player stats when loading in
@@ -284,7 +284,7 @@ void BaseWavesServer::StartWaves(Entity* self) {
state.waitingPlayers.clear();
for (const auto& playerID : state.players) {
const auto player = EntityManager::Instance()->GetEntity(playerID);
const auto player = Game::entityManager->GetEntity(playerID);
if (player != nullptr) {
state.waitingPlayers.push_back(playerID);
@@ -309,7 +309,7 @@ bool BaseWavesServer::CheckAllPlayersDead() {
auto deadPlayers = 0;
for (const auto& playerID : state.players) {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr || player->GetIsDead()) {
deadPlayers++;
}
@@ -322,9 +322,9 @@ bool BaseWavesServer::CheckAllPlayersDead() {
void BaseWavesServer::SetPlayerSpawnPoints(const LWOOBJID& specificPlayerID) {
auto spawnerIndex = 1;
for (const auto& playerID : state.players) {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player != nullptr && (specificPlayerID == LWOOBJID_EMPTY || playerID == specificPlayerID)) {
auto possibleSpawners = EntityManager::Instance()->GetEntitiesInGroup("P" + std::to_string(spawnerIndex) + "_Spawn");
auto possibleSpawners = Game::entityManager->GetEntitiesInGroup("P" + std::to_string(spawnerIndex) + "_Spawn");
if (!possibleSpawners.empty()) {
auto* spawner = possibleSpawners.at(0);
GameMessages::SendTeleport(playerID, spawner->GetPosition(), spawner->GetRotation(), player->GetSystemAddress(), true);
@@ -353,7 +353,7 @@ void BaseWavesServer::GameOver(Entity* self, bool won) {
ClearSpawners();
for (const auto& playerID : state.players) {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr)
continue;
@@ -429,7 +429,7 @@ void BaseWavesServer::SpawnWave(Entity* self) {
}
for (const auto& playerID : state.players) {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player && player->GetIsDead()) {
player->Resurrect();
}
@@ -471,7 +471,7 @@ bool BaseWavesServer::UpdateSpawnedEnemies(Entity* self, LWOOBJID enemyID, uint3
state.currentSpawned--;
auto* enemy = EntityManager::Instance()->GetEntity(enemyID);
auto* enemy = Game::entityManager->GetEntity(enemyID);
if (enemy != nullptr && enemy->IsPlayer() && IsPlayerInActivity(self, enemyID)) {
SetActivityValue(self, enemyID, 0, GetActivityValue(self, enemyID, 0) + score);
}
@@ -499,7 +499,7 @@ bool BaseWavesServer::UpdateSpawnedEnemies(Entity* self, LWOOBJID enemyID, uint3
const auto soloWaveMissions = waves.at(completedWave).soloMissions;
for (const auto& playerID : state.players) {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player != nullptr && !player->GetIsDead()) {
SetActivityValue(self, playerID, 1, currentTime);
SetActivityValue(self, playerID, 2, state.waveNumber);
@@ -558,7 +558,7 @@ bool BaseWavesServer::UpdateSpawnedEnemies(Entity* self, LWOOBJID enemyID, uint3
// Done
void BaseWavesServer::UpdateMissionForAllPlayers(Entity* self, uint32_t missionID) {
for (const auto& playerID : state.players) {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player != nullptr) {
auto* missionComponent = player->GetComponent<MissionComponent>();
if (missionComponent == nullptr) return;