diff options
| -rw-r--r-- | src/engine/client/backend_sdl.cpp | 3 | ||||
| -rw-r--r-- | src/engine/client/graphics.cpp | 3 | ||||
| -rw-r--r-- | src/engine/client/graphics_threaded.cpp | 1 | ||||
| -rw-r--r-- | src/engine/client/graphics_threaded.h | 2 | ||||
| -rw-r--r-- | src/engine/graphics.h | 3 | ||||
| -rw-r--r-- | src/game/client/components/countryflags.cpp | 23 |
6 files changed, 26 insertions, 9 deletions
diff --git a/src/engine/client/backend_sdl.cpp b/src/engine/client/backend_sdl.cpp index 4d77ff3e..e7975aca 100644 --- a/src/engine/client/backend_sdl.cpp +++ b/src/engine/client/backend_sdl.cpp @@ -2,6 +2,8 @@ #include "SDL.h" #include "SDL_opengl.h" +#include <base/tl/threading.h> + #include "graphics_threaded.h" #include "backend_sdl.h" @@ -403,6 +405,7 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int Width, int Height, } const SDL_VideoInfo *pInfo = SDL_GetVideoInfo(); + SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); // prevent stuck mouse cursor sdl-bug when loosing fullscreen focus in windows // set flags int SdlFlags = SDL_OPENGL; diff --git a/src/engine/client/graphics.cpp b/src/engine/client/graphics.cpp index bb52e1b8..2111703e 100644 --- a/src/engine/client/graphics.cpp +++ b/src/engine/client/graphics.cpp @@ -3,6 +3,7 @@ #include <base/detect.h> #include <base/math.h> +#include <base/tl/threading.h> #include "SDL.h" #include "SDL_opengl.h" @@ -764,7 +765,7 @@ int CGraphics_SDL::TryInit() m_ScreenHeight = g_Config.m_GfxScreenHeight; const SDL_VideoInfo *pInfo = SDL_GetVideoInfo(); - SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); + SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); // prevent stuck mouse cursor sdl-bug when loosing fullscreen focus in windows // set flags int Flags = SDL_OPENGL; diff --git a/src/engine/client/graphics_threaded.cpp b/src/engine/client/graphics_threaded.cpp index 286428d7..b19e8a83 100644 --- a/src/engine/client/graphics_threaded.cpp +++ b/src/engine/client/graphics_threaded.cpp @@ -3,6 +3,7 @@ #include <base/detect.h> #include <base/math.h> +#include <base/tl/threading.h> #include <base/system.h> #include <engine/external/pnglite/pnglite.h> diff --git a/src/engine/client/graphics_threaded.h b/src/engine/client/graphics_threaded.h index 3f3bec89..f90f818d 100644 --- a/src/engine/client/graphics_threaded.h +++ b/src/engine/client/graphics_threaded.h @@ -1,7 +1,5 @@ #pragma once -#include <base/tl/threading.h> - #include <engine/graphics.h> class CCommandBuffer diff --git a/src/engine/graphics.h b/src/engine/graphics.h index 46750e03..7f272497 100644 --- a/src/engine/graphics.h +++ b/src/engine/graphics.h @@ -5,7 +5,6 @@ #include "kernel.h" -#include <base/tl/threading.h> class CImageInfo { @@ -139,7 +138,7 @@ public: virtual void Swap() = 0; // syncronization - virtual void InsertSignal(semaphore *pSemaphore) = 0; + virtual void InsertSignal(class semaphore *pSemaphore) = 0; virtual bool IsIdle() = 0; virtual void WaitForIdle() = 0; }; diff --git a/src/game/client/components/countryflags.cpp b/src/game/client/components/countryflags.cpp index e62f4e51..b63b126f 100644 --- a/src/game/client/components/countryflags.cpp +++ b/src/game/client/components/countryflags.cpp @@ -87,13 +87,28 @@ void CCountryFlags::LoadCountryflagsIndexfile() str_format(aBuf, sizeof(aBuf), "loaded country flag '%s'", aOrigin); Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aBuf); } - m_aCountryFlags.add(CountryFlag); + m_aCountryFlags.add_unsorted(CountryFlag); } io_close(File); + m_aCountryFlags.sort_range(); - mem_zero(m_CodeIndexLUT, sizeof(m_CodeIndexLUT)); + // find index of default item + int DefaultIndex = 0, Index = 0; + for(sorted_array<CCountryFlag>::range r = m_aCountryFlags.all(); !r.empty(); r.pop_front(), ++Index) + if(r.front().m_CountryCode == -1) + { + DefaultIndex = Index; + break; + } + + // init LUT + if(DefaultIndex != 0) + for(int i = 0; i < CODE_RANGE; ++i) + m_CodeIndexLUT[i] = DefaultIndex; + else + mem_zero(m_CodeIndexLUT, sizeof(m_CodeIndexLUT)); for(int i = 0; i < m_aCountryFlags.size(); ++i) - m_CodeIndexLUT[max(0, (m_aCountryFlags[i].m_CountryCode-CODE_LB)%CODE_RANGE)] = i+1; + m_CodeIndexLUT[max(0, (m_aCountryFlags[i].m_CountryCode-CODE_LB)%CODE_RANGE)] = i; } void CCountryFlags::OnInit() @@ -119,7 +134,7 @@ int CCountryFlags::Num() const const CCountryFlags::CCountryFlag *CCountryFlags::GetByCountryCode(int CountryCode) const { - return GetByIndex(m_CodeIndexLUT[max(0, (CountryCode-CODE_LB)%CODE_RANGE)]-1); + return GetByIndex(m_CodeIndexLUT[max(0, (CountryCode-CODE_LB)%CODE_RANGE)]); } const CCountryFlags::CCountryFlag *CCountryFlags::GetByIndex(int Index) const |