Fixed crash when windows software renderer selected.

This commit is contained in:
Dmitry 2019-05-14 11:38:45 +03:00 committed by jeefo
commit b0bcf5fcdd
3 changed files with 26 additions and 2 deletions

View file

@ -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

View file

@ -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 <msurface_hw_t, mnode_hw_t> (reinterpret_cast <mnode_hw_t *> (m_worldModel->nodes), point, endPoint);
}
return recursiveLightPoint <msurface_t, mnode_t> (m_worldModel->nodes, point, endPoint);

View file

@ -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;