Fixed exit crash(es)
This commit is contained in:
@@ -7,10 +7,13 @@
|
||||
|
||||
class System
|
||||
{
|
||||
friend class SystemPipeline;
|
||||
|
||||
protected:
|
||||
System(EventBroker* eventBroker)
|
||||
: m_EventBroker(eventBroker)
|
||||
{ }
|
||||
virtual ~System() = default;
|
||||
|
||||
EventBroker* m_EventBroker;
|
||||
};
|
||||
@@ -24,6 +27,7 @@ protected:
|
||||
: System(eventBroker)
|
||||
, m_ComponentType(componentType)
|
||||
{ }
|
||||
virtual ~PureSystem() = default;
|
||||
|
||||
const std::string m_ComponentType;
|
||||
|
||||
@@ -38,6 +42,7 @@ protected:
|
||||
ImpureSystem(EventBroker* eventBroker)
|
||||
: System(eventBroker)
|
||||
{ }
|
||||
virtual ~ImpureSystem() = default;
|
||||
|
||||
virtual void Update(World* world, double dt) = 0;
|
||||
};
|
||||
|
||||
@@ -14,10 +14,8 @@ public:
|
||||
{ }
|
||||
~SystemPipeline()
|
||||
{
|
||||
for (auto& pair : m_PureSystems) {
|
||||
for (auto& system : pair.second) {
|
||||
delete system;
|
||||
}
|
||||
for (auto& pair : m_Systems) {
|
||||
delete pair.second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "../Core/World.h"
|
||||
#include "PickingPass.h"
|
||||
#include "DrawScenePass.h"
|
||||
#include "DebugCameraInputController.h"
|
||||
|
||||
|
||||
#define TILE_SIZE 16
|
||||
@@ -45,6 +46,8 @@ private:
|
||||
//----------------------Variables----------------------//
|
||||
EventBroker* m_EventBroker;
|
||||
|
||||
std::shared_ptr<DebugCameraInputController<Renderer>> m_DebugCameraInputController;
|
||||
|
||||
Texture* m_ErrorTexture;
|
||||
Texture* m_WhiteTexture;
|
||||
float m_CameraMoveSpeed;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "Rendering/Renderer.h"
|
||||
#include "Rendering/DebugCameraInputController.h"
|
||||
|
||||
void Renderer::Initialize()
|
||||
{
|
||||
@@ -10,6 +9,7 @@ void Renderer::Initialize()
|
||||
if (m_Camera == nullptr) {
|
||||
m_Camera = m_DefaultCamera;
|
||||
}
|
||||
m_DebugCameraInputController = std::make_shared<DebugCameraInputController<Renderer>>(m_EventBroker, -1);
|
||||
TEMPCreateLights();
|
||||
InitializeRenderPasses();
|
||||
|
||||
@@ -89,8 +89,6 @@ void Renderer::InitializeShaders()
|
||||
|
||||
void Renderer::InputUpdate(double dt)
|
||||
{
|
||||
static DebugCameraInputController<Renderer> firstPersonInputController(m_EventBroker, -1);
|
||||
|
||||
glm::vec3 m_Position = m_Camera->Position();
|
||||
if (glfwGetKey(m_Window, GLFW_KEY_O) == GLFW_PRESS)
|
||||
{
|
||||
@@ -120,9 +118,9 @@ void Renderer::InputUpdate(double dt)
|
||||
m_CameraMoveSpeed = 0.5f;
|
||||
}
|
||||
|
||||
firstPersonInputController.Update(dt);
|
||||
m_Camera->SetOrientation(firstPersonInputController.Orientation());
|
||||
m_Camera->SetPosition(firstPersonInputController.Position());
|
||||
m_DebugCameraInputController->Update(dt);
|
||||
m_Camera->SetOrientation(m_DebugCameraInputController->Orientation());
|
||||
m_Camera->SetPosition(m_DebugCameraInputController->Position());
|
||||
}
|
||||
|
||||
void Renderer::Update(double dt)
|
||||
|
||||
+7
-39
@@ -27,7 +27,7 @@ Game::Game(int argc, char* argv[])
|
||||
0,
|
||||
m_Config->Get<int>("Video.Width", 1280),
|
||||
m_Config->Get<int>("Video.Height", 720)
|
||||
));
|
||||
));
|
||||
m_Renderer->Initialize();
|
||||
m_Renderer->Camera()->SetFOV(glm::radians(m_Config->Get<float>("Video.FOV", 90.f)));
|
||||
|
||||
@@ -64,17 +64,17 @@ Game::Game(int argc, char* argv[])
|
||||
networkFunction();
|
||||
}
|
||||
m_LastTime = glfwGetTime();
|
||||
|
||||
debugInitialize();
|
||||
}
|
||||
|
||||
Game::~Game()
|
||||
{
|
||||
// Call before to ensure that thread closes correctly.
|
||||
//if (m_IsClientOrServer)
|
||||
// m_ClientOrServer.Close();
|
||||
|
||||
delete m_SystemPipeline;
|
||||
delete m_World;
|
||||
delete m_FrameStack;
|
||||
delete m_InputProxy;
|
||||
delete m_InputManager;
|
||||
delete m_Renderer;
|
||||
delete m_RenderQueueFactory;
|
||||
delete m_EventBroker;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,6 @@ void Game::Tick()
|
||||
|
||||
// Iterate through systems and update world!
|
||||
m_SystemPipeline->Update(m_World, dt);
|
||||
debugTick(dt);
|
||||
m_Renderer->Update(dt);
|
||||
m_EventBroker->Process<Client>();
|
||||
|
||||
@@ -115,37 +114,6 @@ void Game::Tick()
|
||||
m_EventBroker->Clear();
|
||||
}
|
||||
|
||||
|
||||
bool Game::debugOnInputCommand(const Events::InputCommand& e)
|
||||
{
|
||||
if (e.Command == "DebugReload" && e.Value == 1) {
|
||||
std::string mapToLoad = m_Config->Get<std::string>("Debug.LoadMap", "");
|
||||
if (!mapToLoad.empty()) {
|
||||
delete m_World;
|
||||
m_World = new World();
|
||||
ResourceManager::Release("EntityXMLFile", mapToLoad);
|
||||
ResourceManager::Load<EntityXMLFile>(mapToLoad)->PopulateWorld(m_World);
|
||||
}
|
||||
}
|
||||
if (e.Command == "SwitchToServer" && e.Value > 0) {
|
||||
m_ClientOrServer = new Server();
|
||||
LOG_INFO("Switching to server");
|
||||
m_ClientOrServer->Start(m_World, m_EventBroker);
|
||||
}
|
||||
if (e.Command == "SwitchToClient" && e.Value > 0) {
|
||||
m_ClientOrServer = new Client(m_Config);
|
||||
m_ClientOrServer->Start(m_World, m_EventBroker);
|
||||
LOG_INFO("Switching to client");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Game::debugInitialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Game::debugOnInputCommand);
|
||||
}
|
||||
|
||||
void Game::debugTick(double dt)
|
||||
{
|
||||
m_EventBroker->Process<Game>();
|
||||
|
||||
Reference in New Issue
Block a user