The logic for removing the world is working but when we send the map again the clients memory usage goes crazy.
This commit is contained in:
@@ -342,7 +342,8 @@ void Client::parseAmmoPickup(Packet & packet)
|
||||
void Client::parseRemoveWorld(Packet & packet)
|
||||
{
|
||||
removeWorld();
|
||||
|
||||
Events::Reset e;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
|
||||
|
||||
@@ -545,9 +545,12 @@ bool Server::OnPlayerDeath(const Events::PlayerDeath& e)
|
||||
|
||||
bool Server::OnWin(const Events::Win & e)
|
||||
{
|
||||
Events::Reset reset;
|
||||
m_EventBroker->Publish(reset);
|
||||
Packet removeMap(MessageType::RemoveWorld);
|
||||
reliableBroadcast(removeMap);
|
||||
removeWorld();
|
||||
// Hardcoded for now.
|
||||
auto entityFile = ResourceManager::Load<EntityFile>("Schema/Entities/CP_Rocky2.xml");
|
||||
entityFile->MergeInto(m_World);
|
||||
Packet newWorld(MessageType::Snapshot);
|
||||
|
||||
@@ -11,7 +11,25 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
||||
}
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EReset, &CapturePointSystem::OnReset);
|
||||
Init();
|
||||
}
|
||||
|
||||
void CapturePointSystem::Init()
|
||||
{
|
||||
m_WinnerWasFound = false;
|
||||
//need to track these variables for the captureSystem to work as per design!
|
||||
m_RedTeamNextPossibleCapturePoint = m_NotACapturePoint;
|
||||
m_BlueTeamNextPossibleCapturePoint = m_NotACapturePoint;
|
||||
m_RedTeamHomeCapturePoint = m_NotACapturePoint;
|
||||
m_BlueTeamHomeCapturePoint = m_NotACapturePoint;
|
||||
m_NumberOfCapturePoints = 0;
|
||||
m_ResetTimers = false;
|
||||
m_RecentlyCapturedNeedNextCapturePointNow = false;
|
||||
m_CapturePointNumberToEntityMap.clear();
|
||||
//vectors which will keep track of enter/leave changes
|
||||
m_ETriggerTouchVector.clear();
|
||||
m_ETriggerLeaveVector.clear();
|
||||
}
|
||||
|
||||
//here all capturepoints will update their component
|
||||
@@ -24,6 +42,9 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
||||
if (m_WinnerWasFound) {
|
||||
return;
|
||||
}
|
||||
if (!capturePointEntity.Valid()) {
|
||||
return;
|
||||
}
|
||||
const int capturePointNumber = cCapturePoint["CapturePointNumber"];
|
||||
const bool hasTeamComponent = capturePointEntity.HasComponent("Team");
|
||||
|
||||
@@ -60,7 +81,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
||||
}
|
||||
|
||||
//if we havent received all capturepoints yet, just return
|
||||
if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints != m_CapturePointNumberToEntityMap.size()) {
|
||||
if (m_NumberOfCapturePoints == 0 || m_NumberOfCapturePoints > m_CapturePointNumberToEntityMap.size()) {
|
||||
m_CapturePointNumberToEntityMap.insert(std::make_pair(capturePointNumber, capturePointEntity));
|
||||
return;
|
||||
}
|
||||
@@ -232,10 +253,10 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
||||
|
||||
}
|
||||
|
||||
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner) {
|
||||
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner)
|
||||
{
|
||||
(bool&)capturePointModels["Model"]["Visible"] = isOwner;
|
||||
for (auto& capModel : capturePointModels.ChildrenWithComponent("Transform"))
|
||||
{
|
||||
for (auto& capModel : capturePointModels.ChildrenWithComponent("Transform")) {
|
||||
if (capModel.HasComponent("Model")) {
|
||||
(bool&)capModel["Model"]["Visible"] = isOwner;
|
||||
}
|
||||
@@ -269,3 +290,9 @@ bool CapturePointSystem::OnCaptured(const Events::Captured& e)
|
||||
m_ResetTimers = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CapturePointSystem::OnReset(const Events::Reset& e)
|
||||
{
|
||||
Init();
|
||||
return true;
|
||||
}
|
||||
@@ -27,6 +27,14 @@ void SpectatorCameraSystem::Update(double dt)
|
||||
}
|
||||
}
|
||||
|
||||
void SpectatorCameraSystem::reset()
|
||||
{
|
||||
m_CamSetToTeamPick = false;
|
||||
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
|
||||
Events::UnlockMouse unlock;
|
||||
m_EventBroker->Publish(unlock);
|
||||
}
|
||||
|
||||
bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
||||
{
|
||||
// Only the client should do this, and only if player is not spawned.
|
||||
@@ -95,10 +103,13 @@ bool SpectatorCameraSystem::OnDisconnect(const Events::PlayerDisconnected& e)
|
||||
// If local player gets disconnected, they should be set to
|
||||
// the spectator camera next time a map loads that has one.
|
||||
if (e.Entity == LocalPlayer.ID) {
|
||||
m_CamSetToTeamPick = false;
|
||||
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
|
||||
Events::UnlockMouse unlock;
|
||||
m_EventBroker->Publish(unlock);
|
||||
reset();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SpectatorCameraSystem::OnReset(const Events::Reset & e)
|
||||
{
|
||||
reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user