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

@@ -42,7 +42,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
CBITSTREAM;
// Get the entity
Entity* entity = EntityManager::Instance()->GetEntity(objectID);
Entity* entity = Game::entityManager->GetEntity(objectID);
User* usr = UserManager::Instance()->GetUser(sysAddr);
@@ -122,9 +122,9 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
auto* destroyable = entity->GetComponent<DestroyableComponent>();
destroyable->SetImagination(destroyable->GetImagination());
EntityManager::Instance()->SerializeEntity(entity);
Game::entityManager->SerializeEntity(entity);
std::vector<Entity*> racingControllers = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL);
std::vector<Entity*> racingControllers = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RACING_CONTROL);
for (Entity* racingController : racingControllers) {
auto* racingComponent = racingController->GetComponent<RacingControlComponent>();
if (racingComponent != nullptr) {
@@ -132,12 +132,12 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
}
}
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
script->OnPlayerLoaded(zoneControl, player);
}
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPT);
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT);
for (Entity* scriptEntity : scriptedActs) {
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
@@ -248,7 +248,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
dest->SetHealth(4);
dest->SetArmor(0);
dest->SetImagination(6);
EntityManager::Instance()->SerializeEntity(entity);
Game::entityManager->SerializeEntity(entity);
}*/
break;
}
@@ -560,7 +560,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const System
break;
case eGameMessageType::ZONE_PROPERTY_MODEL_ROTATED:
EntityManager::Instance()->GetZoneControlEntity()->OnZonePropertyModelRotated(usr->GetLastUsedChar()->GetEntity());
Game::entityManager->GetZoneControlEntity()->OnZonePropertyModelRotated(usr->GetLastUsedChar()->GetEntity());
break;
case eGameMessageType::UPDATE_PROPERTY_OR_MODEL_FOR_FILTER_CHECK:

View File

@@ -1101,7 +1101,7 @@ void GameMessages::SendDropClientLoot(Entity* entity, const LWOOBJID& sourceID,
if (object.type != "Powerup") {
for (const auto memberId : team->members) {
auto* member = EntityManager::Instance()->GetEntity(memberId);
auto* member = Game::entityManager->GetEntity(memberId);
if (member == nullptr) continue;
@@ -1705,11 +1705,11 @@ void GameMessages::HandleActivityStateChangeRequest(RakNet::BitStream* inStream,
stringValue.push_back(character);
}
auto* assosiate = EntityManager::Instance()->GetEntity(objectID);
auto* assosiate = Game::entityManager->GetEntity(objectID);
Game::logger->Log("Activity State Change", "%s [%i, %i] from %i to %i", GeneralUtils::UTF16ToWTF8(stringValue).c_str(), value1, value2, entity->GetLOT(), assosiate != nullptr ? assosiate->GetLOT() : 0);
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SHOOTING_GALLERY);
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SHOOTING_GALLERY);
for (Entity* scriptEntity : scriptedActs) {
scriptEntity->OnActivityStateChangeRequest(objectID, value1, value2, stringValue);
}
@@ -2238,7 +2238,7 @@ void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity*
Game::logger->Log("HandleQueryPropertyData", "Entity (%i) requesting data", entity->GetLOT());
/*
auto entites = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::PROPERTY_VENDOR);
auto entites = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::PROPERTY_VENDOR);
entity = entites[0];
*/
@@ -2250,7 +2250,7 @@ void GameMessages::HandleQueryPropertyData(RakNet::BitStream* inStream, Entity*
}
/*
entites = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::PROPERTY_MANAGEMENT);
entites = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::PROPERTY_MANAGEMENT);
entity = entites[0];
*/
@@ -2285,7 +2285,7 @@ void GameMessages::HandleSetBuildMode(RakNet::BitStream* inStream, Entity* entit
if (inStream->ReadBit())
inStream->Read(startPosition);
auto* player = EntityManager::Instance()->GetEntity(playerId);
auto* player = Game::entityManager->GetEntity(playerId);
if (startPosition == NiPoint3::ZERO) {
startPosition = player->GetPosition();
@@ -2333,7 +2333,7 @@ void GameMessages::HandleStartBuildingWithItem(RakNet::BitStream* inStream, Enti
auto* user = UserManager::Instance()->GetUser(sysAddr);
auto* player = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
auto* player = Game::entityManager->GetEntity(user->GetLoggedInChar());
SendStartArrangingWithItem(
player,
@@ -2367,7 +2367,7 @@ void GameMessages::HandlePropertyEditorEnd(RakNet::BitStream* inStream, Entity*
void GameMessages::HandlePropertyContentsFromClient(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
User* user = UserManager::Instance()->GetUser(sysAddr);
Entity* player = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
Entity* player = Game::entityManager->GetEntity(user->GetLoggedInChar());
SendGetModelsOnProperty(player->GetObjectID(), PropertyManagementComponent::Instance()->GetModels(), UNASSIGNED_SYSTEM_ADDRESS);
}
@@ -2730,9 +2730,9 @@ void GameMessages::HandleBBBSaveRequest(RakNet::BitStream* inStream, Entity* ent
info.settings.push_back(propertyObjectID);
info.settings.push_back(userModelID);
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
Entity* newEntity = Game::entityManager->CreateEntity(info, nullptr);
if (newEntity) {
EntityManager::Instance()->ConstructEntity(newEntity);
Game::entityManager->ConstructEntity(newEntity);
//Make sure the propMgmt doesn't delete our model after the server dies
//Trying to do this after the entity is constructed. Shouldn't really change anything but
@@ -2928,7 +2928,7 @@ void GameMessages::HandleCinematicUpdate(RakNet::BitStream* inStream, Entity* en
inStream->Read<int32_t>(waypoint);
}
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPT);
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT);
for (Entity* scriptEntity : scriptedActs) {
scriptEntity->OnCinematicUpdate(scriptEntity, entity, event, pathName, pathTime, overallTime, waypoint);
}
@@ -3308,7 +3308,7 @@ void GameMessages::HandleClientTradeRequest(RakNet::BitStream* inStream, Entity*
inStream->Read(i64Invitee);
auto* invitee = EntityManager::Instance()->GetEntity(i64Invitee);
auto* invitee = Game::entityManager->GetEntity(i64Invitee);
if (invitee != nullptr && invitee->IsPlayer()) {
character = invitee->GetCharacter();
@@ -3895,7 +3895,7 @@ void GameMessages::HandleMessageBoxResponse(RakNet::BitStream* inStream, Entity*
racingControlComponent->HandleMessageBoxResponse(userEntity, iButton, GeneralUtils::UTF16ToWTF8(identifier));
}
for (auto* shootingGallery : EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SHOOTING_GALLERY)) {
for (auto* shootingGallery : Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SHOOTING_GALLERY)) {
shootingGallery->OnMessageBoxResponse(userEntity, iButton, identifier, userData);
}
}
@@ -4056,7 +4056,7 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e
// If we aren't possessing somethings, the don't do anything
if (objectId != LWOOBJID_EMPTY) {
auto* possessorComponent = entity->GetComponent<PossessorComponent>();
auto* mount = EntityManager::Instance()->GetEntity(objectId);
auto* mount = Game::entityManager->GetEntity(objectId);
// make sure we have the things we need and they aren't null
if (possessorComponent && mount) {
if (!possessorComponent->GetIsDismounting()) return;
@@ -4081,7 +4081,7 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e
if (possessableComponent) possessableComponent->Dismount();
// Update the entity that was possessing
EntityManager::Instance()->SerializeEntity(entity);
Game::entityManager->SerializeEntity(entity);
// We aren't mounted so remove the stun
GameMessages::SendSetStunned(entity->GetObjectID(), eStateChangeType::POP, UNASSIGNED_SYSTEM_ADDRESS, LWOOBJID_EMPTY, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true);
@@ -4091,11 +4091,11 @@ void GameMessages::HandleDismountComplete(RakNet::BitStream* inStream, Entity* e
void GameMessages::HandleAcknowledgePossession(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
EntityManager::Instance()->SerializeEntity(entity);
Game::entityManager->SerializeEntity(entity);
LWOOBJID objectId{};
inStream->Read(objectId);
auto* mount = EntityManager::Instance()->GetEntity(objectId);
if (mount) EntityManager::Instance()->SerializeEntity(mount);
auto* mount = Game::entityManager->GetEntity(objectId);
if (mount) Game::entityManager->SerializeEntity(mount);
}
//Racing
@@ -4131,7 +4131,7 @@ void GameMessages::HandleRacingClientReady(RakNet::BitStream* inStream, Entity*
inStream->Read(playerID);
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;
@@ -4195,7 +4195,7 @@ void GameMessages::HandleRequestDie(RakNet::BitStream* inStream, Entity* entity,
auto* possessableComponent = entity->GetComponent<PossessableComponent>();
if (possessableComponent != nullptr) {
entity = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
entity = Game::entityManager->GetEntity(possessableComponent->GetPossessor());
if (entity == nullptr) {
return;
@@ -4222,7 +4222,7 @@ void GameMessages::HandleRacingPlayerInfoResetFinished(RakNet::BitStream* inStre
inStream->Read(playerID);
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;
@@ -4286,7 +4286,7 @@ void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* in
if (inStream->ReadBit()) inStream->Read(pickupSpawnerIndex);
if (inStream->ReadBit()) inStream->Read(vehiclePosition);
auto* pickup = EntityManager::Instance()->GetEntity(pickupObjID);
auto* pickup = Game::entityManager->GetEntity(pickupObjID);
if (pickup == nullptr) {
return;
@@ -4295,7 +4295,7 @@ void GameMessages::HandleVehicleNotifyHitImaginationServer(RakNet::BitStream* in
auto* possessableComponent = entity->GetComponent<PossessableComponent>();
if (possessableComponent != nullptr) {
entity = EntityManager::Instance()->GetEntity(possessableComponent->GetPossessor());
entity = Game::entityManager->GetEntity(possessableComponent->GetPossessor());
if (entity == nullptr) {
return;
@@ -4686,7 +4686,7 @@ void GameMessages::HandleToggleGhostReferenceOverride(RakNet::BitStream* inStrea
if (player != nullptr) {
player->SetGhostOverride(bOverride);
EntityManager::Instance()->UpdateGhosting(player);
Game::entityManager->UpdateGhosting(player);
}
}
@@ -4701,7 +4701,7 @@ void GameMessages::HandleSetGhostReferencePosition(RakNet::BitStream* inStream,
if (player != nullptr) {
player->SetGhostOverridePoint(position);
EntityManager::Instance()->UpdateGhosting(player);
Game::entityManager->UpdateGhosting(player);
}
}
@@ -4719,7 +4719,7 @@ void GameMessages::HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* enti
User* user = UserManager::Instance()->GetUser(sysAddr);
if (!user) return;
Entity* player = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
Entity* player = Game::entityManager->GetEntity(user->GetLoggedInChar());
if (!player) return;
auto* propertyVendorComponent = static_cast<PropertyVendorComponent*>(entity->GetComponent(eReplicaComponentType::PROPERTY_VENDOR));
@@ -4822,7 +4822,7 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit
User* user = UserManager::Instance()->GetUser(sysAddr);
if (!user) return;
Entity* player = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
Entity* player = Game::entityManager->GetEntity(user->GetLoggedInChar());
if (!player) return;
Character* character = player->GetCharacter();
if (!character) return;
@@ -4853,7 +4853,7 @@ void GameMessages::HandleSellToVendor(RakNet::BitStream* inStream, Entity* entit
//inv->RemoveItem(count, -1, iObjID);
inv->MoveItemToInventory(item, eInventoryType::VENDOR_BUYBACK, count, true, false, true);
character->SetCoins(std::floor(character->GetCoins() + (static_cast<uint32_t>(itemComp.baseValue * sellScalar) * count)), eLootSourceType::VENDOR);
//EntityManager::Instance()->SerializeEntity(player); // so inventory updates
//Game::entityManager->SerializeEntity(player); // so inventory updates
GameMessages::SendVendorTransactionResult(entity, sysAddr);
}
@@ -4872,7 +4872,7 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity*
User* user = UserManager::Instance()->GetUser(sysAddr);
if (!user) return;
Entity* player = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
Entity* player = Game::entityManager->GetEntity(user->GetLoggedInChar());
if (!player) return;
Character* character = player->GetCharacter();
if (!character) return;
@@ -4912,7 +4912,7 @@ void GameMessages::HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity*
//inv->RemoveItem(count, -1, iObjID);
inv->MoveItemToInventory(item, Inventory::FindInventoryTypeForLot(item->GetLot()), count, true, false);
character->SetCoins(character->GetCoins() - cost, eLootSourceType::VENDOR);
//EntityManager::Instance()->SerializeEntity(player); // so inventory updates
//Game::entityManager->SerializeEntity(player); // so inventory updates
GameMessages::SendVendorTransactionResult(entity, sysAddr);
}
@@ -4959,7 +4959,7 @@ void GameMessages::HandleFireEventServerSide(RakNet::BitStream* inStream, Entity
if (param3IsDefault) inStream->Read(param3);
inStream->Read(senderID);
auto* sender = EntityManager::Instance()->GetEntity(senderID);
auto* sender = Game::entityManager->GetEntity(senderID);
auto* player = Player::GetPlayer(sysAddr);
if (!player) {
@@ -5033,7 +5033,7 @@ void GameMessages::HandleRebuildCancel(RakNet::BitStream* inStream, Entity* enti
RebuildComponent* rebComp = static_cast<RebuildComponent*>(entity->GetComponent(eReplicaComponentType::QUICK_BUILD));
if (!rebComp) return;
rebComp->CancelRebuild(EntityManager::Instance()->GetEntity(userID), eQuickBuildFailReason::CANCELED_EARLY);
rebComp->CancelRebuild(Game::entityManager->GetEntity(userID), eQuickBuildFailReason::CANCELED_EARLY);
}
void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
@@ -5049,7 +5049,7 @@ void GameMessages::HandleRequestUse(RakNet::BitStream* inStream, Entity* entity,
inStream->Read(objectID);
inStream->Read(secondary);
Entity* interactedObject = EntityManager::Instance()->GetEntity(objectID);
Entity* interactedObject = Game::entityManager->GetEntity(objectID);
if (interactedObject == nullptr) {
Game::logger->Log("GameMessages", "Object %llu tried to interact, but doesn't exist!", objectID);
@@ -5102,7 +5102,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity)
if (!missionComponent) return;
if (targetID != LWOOBJID_EMPTY) {
auto* targetEntity = EntityManager::Instance()->GetEntity(targetID);
auto* targetEntity = Game::entityManager->GetEntity(targetID);
Game::logger->LogDebug("GameMessages", "Emote target found (%d)", targetEntity != nullptr);
@@ -5112,7 +5112,7 @@ void GameMessages::HandlePlayEmote(RakNet::BitStream* inStream, Entity* entity)
}
} else {
Game::logger->LogDebug("GameMessages", "Target ID is empty, using backup");
const auto scriptedEntities = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPT);
const auto scriptedEntities = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPT);
const auto& referencePoint = entity->GetPosition();
@@ -5140,7 +5140,7 @@ void GameMessages::HandleModularBuildConvertModel(RakNet::BitStream* inStream, E
User* user = UserManager::Instance()->GetUser(sysAddr);
if (!user) return;
Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
Entity* character = Game::entityManager->GetEntity(user->GetLoggedInChar());
if (!character) return;
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY));
if (!inv) return;
@@ -5198,7 +5198,7 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream* inStream, Entity* e
Game::logger->Log("GameMessages", "Unable to get mission %i for entity %llu to update reward in RespondToMission", missionID, playerID);
}
Entity* offerer = EntityManager::Instance()->GetEntity(receiverID);
Entity* offerer = Game::entityManager->GetEntity(receiverID);
if (offerer == nullptr) {
Game::logger->Log("GameMessages", "Unable to get receiver entity %llu for RespondToMission", receiverID);
@@ -5206,7 +5206,7 @@ void GameMessages::HandleRespondToMission(RakNet::BitStream* inStream, Entity* e
}
for (CppScripts::Script* script : CppScripts::GetEntityScripts(offerer)) {
script->OnRespondToMission(offerer, missionID, EntityManager::Instance()->GetEntity(playerID), reward);
script->OnRespondToMission(offerer, missionID, Game::entityManager->GetEntity(playerID), reward);
}
}
@@ -5221,7 +5221,7 @@ void GameMessages::HandleMissionDialogOK(RakNet::BitStream* inStream, Entity* en
inStream->Read(iMissionState);
inStream->Read(missionID);
inStream->Read(responder);
player = EntityManager::Instance()->GetEntity(responder);
player = Game::entityManager->GetEntity(responder);
for (CppScripts::Script* script : CppScripts::GetEntityScripts(entity)) {
script->OnMissionDialogueOK(entity, player, missionID, iMissionState);
@@ -5250,7 +5250,7 @@ void GameMessages::HandleRequestLinkedMission(RakNet::BitStream* inStream, Entit
inStream->Read(missionId);
inStream->Read(bMissionOffered);
auto* player = EntityManager::Instance()->GetEntity(playerId);
auto* player = Game::entityManager->GetEntity(playerId);
auto* missionOfferComponent = static_cast<MissionOfferComponent*>(entity->GetComponent(eReplicaComponentType::MISSION_OFFER));
@@ -5263,7 +5263,7 @@ void GameMessages::HandleHasBeenCollected(RakNet::BitStream* inStream, Entity* e
LWOOBJID playerID;
inStream->Read(playerID);
Entity* player = EntityManager::Instance()->GetEntity(playerID);
Entity* player = Game::entityManager->GetEntity(playerID);
if (!player || !entity || entity->GetCollectibleID() == 0) return;
MissionComponent* missionComponent = static_cast<MissionComponent*>(player->GetComponent(eReplicaComponentType::MISSION));
@@ -5377,7 +5377,7 @@ void GameMessages::HandleEquipItem(RakNet::BitStream* inStream, Entity* entity)
item->Equip();
EntityManager::Instance()->SerializeEntity(entity);
Game::entityManager->SerializeEntity(entity);
}
void GameMessages::HandleUnequipItem(RakNet::BitStream* inStream, Entity* entity) {
@@ -5397,7 +5397,7 @@ void GameMessages::HandleUnequipItem(RakNet::BitStream* inStream, Entity* entity
item->UnEquip();
EntityManager::Instance()->SerializeEntity(entity);
Game::entityManager->SerializeEntity(entity);
}
void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
@@ -5482,7 +5482,7 @@ void GameMessages::HandleRemoveItemFromInventory(RakNet::BitStream* inStream, En
}
item->SetCount(item->GetCount() - iStackCount, true);
EntityManager::Instance()->SerializeEntity(entity);
Game::entityManager->SerializeEntity(entity);
auto* missionComponent = entity->GetComponent<MissionComponent>();
@@ -5516,7 +5516,7 @@ void GameMessages::HandleMoveItemInInventory(RakNet::BitStream* inStream, Entity
}
inv->MoveStack(item, static_cast<eInventoryType>(destInvType), slot);
EntityManager::Instance()->SerializeEntity(entity);
Game::entityManager->SerializeEntity(entity);
}
void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
@@ -5562,7 +5562,7 @@ void GameMessages::HandleMoveItemBetweenInventoryTypes(RakNet::BitStream* inStre
}
inv->MoveItemToInventory(item, inventoryTypeB, stackCount, showFlyingLoot);
EntityManager::Instance()->SerializeEntity(entity);
Game::entityManager->SerializeEntity(entity);
}
void GameMessages::HandleBuildModeSet(RakNet::BitStream* inStream, Entity* entity) {
@@ -5581,7 +5581,7 @@ void GameMessages::HandleBuildModeSet(RakNet::BitStream* inStream, Entity* entit
void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
User* user = UserManager::Instance()->GetUser(sysAddr);
if (!user) return;
Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
Entity* character = Game::entityManager->GetEntity(user->GetLoggedInChar());
if (!character) return;
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY));
if (!inv) return;
@@ -5592,7 +5592,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
GameMessages::SendModularBuildEnd(character); // i dont know if this does anything but DLUv2 did it
//inv->UnequipItem(inv->GetItemStackByLOT(6086, eInventoryType::ITEMS)); // take off the thinking cap
//EntityManager::Instance()->SerializeEntity(entity);
//Game::entityManager->SerializeEntity(entity);
uint8_t count; // 3 for rockets, 7 for cars
@@ -5669,7 +5669,7 @@ void GameMessages::HandleModularBuildFinish(RakNet::BitStream* inStream, Entity*
void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
User* user = UserManager::Instance()->GetUser(sysAddr);
if (!user) return;
Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
Entity* character = Game::entityManager->GetEntity(user->GetLoggedInChar());
if (!character) return;
InventoryComponent* inv = static_cast<InventoryComponent*>(character->GetComponent(eReplicaComponentType::INVENTORY));
if (!inv) return;
@@ -5722,9 +5722,9 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti
*/
if (PropertyManagementComponent::Instance() != nullptr) {
const auto& buildAreas = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::BUILD_BORDER);
const auto& buildAreas = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::BUILD_BORDER);
const auto& entities = EntityManager::Instance()->GetEntitiesInGroup("PropertyPlaque");
const auto& entities = Game::entityManager->GetEntitiesInGroup("PropertyPlaque");
Entity* buildArea;
@@ -5780,7 +5780,7 @@ void GameMessages::HandleDoneArrangingWithItem(RakNet::BitStream* inStream, Enti
void GameMessages::HandleModularBuildMoveAndEquip(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
User* user = UserManager::Instance()->GetUser(sysAddr);
if (!user) return;
Entity* character = EntityManager::Instance()->GetEntity(user->GetLoggedInChar());
Entity* character = Game::entityManager->GetEntity(user->GetLoggedInChar());
if (!character) return;
Game::logger->Log("GameMessages", "Build and move");
@@ -5813,7 +5813,7 @@ void GameMessages::HandlePickupItem(RakNet::BitStream* inStream, Entity* entity)
if (team != nullptr) {
for (const auto memberId : team->members) {
auto* member = EntityManager::Instance()->GetEntity(memberId);
auto* member = Game::entityManager->GetEntity(memberId);
if (member == nullptr || memberId == playerID) continue;
@@ -5825,12 +5825,12 @@ void GameMessages::HandlePickupItem(RakNet::BitStream* inStream, Entity* entity)
void GameMessages::HandleResurrect(RakNet::BitStream* inStream, Entity* entity) {
bool immediate = inStream->ReadBit();
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
Entity* zoneControl = Game::entityManager->GetZoneControlEntity();
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
script->OnPlayerResurrected(zoneControl, entity);
}
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
for (Entity* scriptEntity : scriptedActs) {
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
@@ -5850,7 +5850,7 @@ void GameMessages::HandlePopEquippedItemsState(RakNet::BitStream* inStream, Enti
InventoryComponent* inv = static_cast<InventoryComponent*>(entity->GetComponent(eReplicaComponentType::INVENTORY));
if (!inv) return;
inv->PopEquippedItems();
EntityManager::Instance()->SerializeEntity(entity); // so it updates on client side
Game::entityManager->SerializeEntity(entity); // so it updates on client side
}
@@ -5916,7 +5916,7 @@ void GameMessages::HandleMatchRequest(RakNet::BitStream* inStream, Entity* entit
inStream->Read(type);
inStream->Read(value);
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
std::vector<Entity*> scriptedActs = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::SCRIPTED_ACTIVITY);
if (type == 0) { // join
if (value != 0) {
for (Entity* scriptedAct : scriptedActs) {
@@ -6049,7 +6049,7 @@ void GameMessages::HandleReportBug(RakNet::BitStream* inStream, Entity* entity)
void
GameMessages::HandleClientRailMovementReady(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
const auto possibleRails = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
const auto possibleRails = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
for (const auto* possibleRail : possibleRails) {
const auto* rail = possibleRail->GetComponent<RailActivatorComponent>();
if (rail != nullptr) {
@@ -6061,7 +6061,7 @@ GameMessages::HandleClientRailMovementReady(RakNet::BitStream* inStream, Entity*
void GameMessages::HandleCancelRailMovement(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr) {
const auto immediate = inStream->ReadBit();
const auto possibleRails = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
const auto possibleRails = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
for (const auto* possibleRail : possibleRails) {
auto* rail = possibleRail->GetComponent<RailActivatorComponent>();
if (rail != nullptr) {
@@ -6085,7 +6085,7 @@ void GameMessages::HandlePlayerRailArrivedNotification(RakNet::BitStream* inStre
int32_t waypointNumber;
inStream->Read(waypointNumber);
const auto possibleRails = EntityManager::Instance()->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
const auto possibleRails = Game::entityManager->GetEntitiesByComponent(eReplicaComponentType::RAIL_ACTIVATOR);
for (auto* possibleRail : possibleRails) {
for (CppScripts::Script* script : CppScripts::GetEntityScripts(possibleRail)) {
script->OnPlayerRailArrived(possibleRail, entity, pathName, waypointNumber);
@@ -6178,7 +6178,7 @@ void GameMessages::SendDeactivateBubbleBuffFromServer(LWOOBJID objectId, const S
void GameMessages::HandleZoneSummaryDismissed(RakNet::BitStream* inStream, Entity* entity) {
LWOOBJID player_id;
inStream->Read<LWOOBJID>(player_id);
auto target = EntityManager::Instance()->GetEntity(player_id);
auto target = Game::entityManager->GetEntity(player_id);
entity->TriggerEvent(eTriggerEventType::ZONE_SUMMARY_DISMISSED, target);
};
@@ -6218,7 +6218,7 @@ void GameMessages::HandleRequestActivityExit(RakNet::BitStream* inStream, Entity
LWOOBJID player_id = LWOOBJID_EMPTY;
inStream->Read(player_id);
auto player = EntityManager::Instance()->GetEntity(player_id);
auto player = Game::entityManager->GetEntity(player_id);
if (!entity || !player) return;
entity->RequestActivityExit(entity, player_id, canceled);
}