From b0bcf5fcdd920674685ace275e81ed20f7570ad2 Mon Sep 17 00:00:00 2001 From: Dmitry Date: Tue, 14 May 2019 11:38:45 +0300 Subject: [PATCH] Fixed crash when windows software renderer selected. --- include/engine.h | 3 +++ source/engine.cpp | 23 ++++++++++++++++++++++- source/manager.cpp | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/engine.h b/include/engine.h index f962d20..dbc1577 100644 --- a/include/engine.h +++ b/include/engine.h @@ -186,6 +186,9 @@ public: // do actual network message processing void processMessages (void *ptr); + // checks whether softwared rendering is enabled + bool isSoftwareRenderer (void); + // public inlines public: // get the current time on server diff --git a/source/engine.cpp b/source/engine.cpp index a4de9f0..31c8517 100644 --- a/source/engine.cpp +++ b/source/engine.cpp @@ -493,6 +493,27 @@ void Engine::execBotCmd (edict_t *ent, const char *fmt, ...) { m_argumentCount = 0; } +bool Engine::isSoftwareRenderer (void) { + + // xash always use "hw" structures + if (g_gameFlags & GAME_XASH_ENGINE) { + return false; + } + + // dedicated server (except xash) always use "sw" structures + if (isDedicated ()) { + return true; + } + + // and on only windows version you can use software-render engine. Linux, OSX always defaults to OpenGL +#if defined (PLATFORM_WIN32) + static bool isSoftware = GetModuleHandleA ("sw"); +#else + static bool isSoftware = false; +#endif + return isSoftware; +} + const char *Engine::getField (const char *string, size_t id) { // this function gets and returns a particular field in a string where several strings are concatenated @@ -1279,7 +1300,7 @@ float LightMeasure::getLightLevel (const Vector &point) { // it's depends if we're are on dedicated or on listenserver auto recursiveCheck = [&] (void) -> bool { - if (!engine.isDedicated () || (g_gameFlags & GAME_XASH_ENGINE)) { + if (!engine.isSoftwareRenderer ()) { return recursiveLightPoint (reinterpret_cast (m_worldModel->nodes), point, endPoint); } return recursiveLightPoint (m_worldModel->nodes, point, endPoint); diff --git a/source/manager.cpp b/source/manager.cpp index 03deef8..a645c8e 100644 --- a/source/manager.cpp +++ b/source/manager.cpp @@ -841,7 +841,7 @@ void BotManager::updateBotDifficulties (void) { auto bot = m_bots[i]; if (bot != nullptr) { - m_bots[i]->m_difficulty = difficulty; + bot->m_difficulty = difficulty; } } m_lastDifficulty = difficulty;