1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-01 00:45:26 +02:00

Simplified and fixed server restart procedure:

- Replaced several assertions with runtime_error's to detect them in
release builds
- Removed multiple dispatchMainThread calls in server shutdown code to
simplify debugging and code flow
- Moved handling of gameplay shutdown and score calculation from
PlayerInterface to ServerHandler (not perfect, but better than before)
This commit is contained in:
Ivan Savenko
2024-04-07 14:19:57 +03:00
parent 0a80c6c27b
commit 80acd7e77c
6 changed files with 119 additions and 102 deletions

View File

@ -22,7 +22,9 @@
void WindowHandler::popWindow(std::shared_ptr<IShowActivatable> top)
{
assert(windowsStack.back() == top);
if (windowsStack.back() != top)
throw std::runtime_error("Attempt to pop non-top window from stack!");
top->deactivate();
disposed.push_back(top);
windowsStack.pop_back();
@ -34,8 +36,11 @@ void WindowHandler::popWindow(std::shared_ptr<IShowActivatable> top)
void WindowHandler::pushWindow(std::shared_ptr<IShowActivatable> newInt)
{
assert(newInt);
assert(!vstd::contains(windowsStack, newInt)); // do not add same object twice
if (newInt == nullptr)
throw std::runtime_error("Attempt to push null window onto windows stack!");
if (vstd::contains(windowsStack, newInt))
throw std::runtime_error("Attempt to add already existing window to stack!");
//a new interface will be present, we'll need to use buffer surface (unless it's advmapint that will alter screenBuf on activate anyway)
screenBuf = screen2;