From c3599ed150bdc4d5e0df6070089a0801f095dc69 Mon Sep 17 00:00:00 2001 From: "Grayson Riffe (Laptop)" Date: Tue, 17 Aug 2021 14:26:01 -0500 Subject: [PATCH] Added check for default gamestate --- NothinFancy/src/Application.cpp | 10 ++++++++-- NothinFancy/src/include/Application.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NothinFancy/src/Application.cpp b/NothinFancy/src/Application.cpp index d753e5d..db14924 100644 --- a/NothinFancy/src/Application.cpp +++ b/NothinFancy/src/Application.cpp @@ -47,8 +47,14 @@ namespace nf { } void Application::addDefaultState(IGamestate* in) { - (*in).onEnter(); - m_activeStates.push_back(in); + if (!m_defaultStateAdded) { + (*in).onEnter(); + m_activeStates.push_back(in); + m_defaultStateAdded = true; + } + else { + Error("More than one default state defined"); //TODO: Test this + } } void Application::run() { diff --git a/NothinFancy/src/include/Application.h b/NothinFancy/src/include/Application.h index de9092d..5fdfc96 100644 --- a/NothinFancy/src/include/Application.h +++ b/NothinFancy/src/include/Application.h @@ -56,5 +56,6 @@ namespace nf { //The currently active and loaded states where the top-most is the current one std::vector m_activeStates; IntroGamestate* m_sIntro; + bool m_defaultStateAdded = false; }; } \ No newline at end of file