Skip to content
This repository has been archived by the owner on Jun 26, 2019. It is now read-only.

Commit

Permalink
Fix crash on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ChillerDragon committed Dec 3, 2018
1 parent b21c058 commit 00868b0
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 143 deletions.
4 changes: 0 additions & 4 deletions bam.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
CheckVersion("0.5")

Import("configure.lua")
Import("other/freetype/freetype.lua")

--- Setup Config -------
config = NewConfig()
config:Add(OptCCompiler("compiler"))
config:Add(OptTestCompileC("stackprotector", "int main(){return 0;}", "-fstack-protector -fstack-protector-all"))
config:Add(OptTestCompileC("minmacosxsdk", "int main(){return 0;}", "-mmacosx-version-min=10.7 -isysroot /Developer/SDKs/MacOSX10.7.sdk"))
config:Add(OptLibrary("zlib", "zlib.h", false))
config:Add(FreeType.OptFind("freetype", true))
config:Finalize("config.lua")

generated_src_dir = "build/src"
Expand Down Expand Up @@ -325,8 +323,6 @@ end


function BuildClient(settings, family, platform)
config.freetype:Apply(settings)

local client = Compile(settings, Collect("src/engine/client/*.cpp"))

local game_client = Compile(settings, CollectRecursive("src/game/client/*.cpp"), SharedClientFiles())
Expand Down
3 changes: 0 additions & 3 deletions src/engine/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "kernel.h"

#include "message.h"
#include "graphics.h"

class IClient : public IInterface
{
Expand Down Expand Up @@ -149,8 +148,6 @@ class IClient : public IInterface
virtual bool ConnectionProblems() const = 0;

virtual bool SoundInitFailed() const = 0;

virtual IGraphics::CTextureHandle GetDebugFont() const = 0; // TODO: remove this function
};

class IGameClient : public IInterface
Expand Down
131 changes: 1 addition & 130 deletions src/engine/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@ CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta), m_DemoRecorder(&m_SnapshotD
{
m_pEditor = 0;
m_pInput = 0;
m_pGraphics = 0;
m_pGameClient = 0;
m_pMap = 0;
m_pConsole = 0;
Expand Down Expand Up @@ -511,7 +510,6 @@ void CClient::GetServerInfo(CServerInfo *pServerInfo) const

int CClient::LoadData()
{
m_DebugFont = Graphics()->LoadTexture("ui/debug_font.png", IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, IGraphics::TEXLOAD_NORESAMPLE);
return 1;
}

Expand Down Expand Up @@ -1698,7 +1696,6 @@ void CClient::Run()
// init the editor
m_pEditor->Init();


// load data
if(!LoadData())
return;
Expand Down Expand Up @@ -1738,62 +1735,6 @@ void CClient::Run()
m_aCmdConnect[0] = 0;
}

// release focus
if(!m_pGraphics->WindowActive())
{
if(m_WindowMustRefocus == 0)
Input()->MouseModeAbsolute();
m_WindowMustRefocus = 1;
}
else if (g_Config.m_DbgFocus && Input()->KeyPress(KEY_ESCAPE, true))
{
Input()->MouseModeAbsolute();
m_WindowMustRefocus = 1;
}

// refocus
if(m_WindowMustRefocus && m_pGraphics->WindowActive())
{
if(m_WindowMustRefocus < 3)
{
Input()->MouseModeAbsolute();
m_WindowMustRefocus++;
}

if(m_WindowMustRefocus >= 3 || Input()->KeyPress(KEY_MOUSE_1, true))
{
Input()->MouseModeRelative();
m_WindowMustRefocus = 0;

// update screen in case it got moved
int ActScreen = Graphics()->GetWindowScreen();
if(ActScreen >= 0 && ActScreen != g_Config.m_GfxScreen)
g_Config.m_GfxScreen = ActScreen;
}
}

// panic quit button
if(Input()->KeyIsPressed(KEY_LCTRL) && Input()->KeyIsPressed(KEY_LSHIFT) && Input()->KeyPress(KEY_Q, true))
{
Quit();
break;
}

if(Input()->KeyIsPressed(KEY_LCTRL) && Input()->KeyIsPressed(KEY_LSHIFT) && Input()->KeyPress(KEY_D, true))
g_Config.m_Debug ^= 1;

if(Input()->KeyIsPressed(KEY_LCTRL) && Input()->KeyIsPressed(KEY_LSHIFT) && Input()->KeyPress(KEY_G, true))
g_Config.m_DbgGraphs ^= 1;

if(Input()->KeyIsPressed(KEY_LCTRL) && Input()->KeyIsPressed(KEY_LSHIFT) && Input()->KeyPress(KEY_E, true))
{
g_Config.m_ClEditor = g_Config.m_ClEditor^1;
Input()->MouseModeRelative();
}


AutoScreenshot_Cleanup();

// check conditions
if(State() == IClient::STATE_QUITING)
break;
Expand All @@ -1809,7 +1750,7 @@ void CClient::Run()
// beNice
if(g_Config.m_ClCpuThrottle)
thread_sleep(g_Config.m_ClCpuThrottle);
else if(g_Config.m_DbgStress || !m_pGraphics->WindowActive())
else if(g_Config.m_DbgStress)
thread_sleep(5);

if(g_Config.m_DbgHitch)
Expand All @@ -1824,9 +1765,6 @@ void CClient::Run()

GameClient()->OnShutdown();
Disconnect();

m_pGraphics->Shutdown();

m_ServerBrowser.SaveServerlist();
}

Expand Down Expand Up @@ -1855,8 +1793,6 @@ void CClient::Con_Quit(IConsole::IResult *pResult, void *pUserData)

void CClient::Con_Minimize(IConsole::IResult *pResult, void *pUserData)
{
CClient *pSelf = (CClient *)pUserData;
pSelf->Graphics()->Minimize();
}

void CClient::Con_Ping(IConsole::IResult *pResult, void *pUserData)
Expand All @@ -1872,7 +1808,6 @@ void CClient::AutoScreenshot_Start()
{
if(g_Config.m_ClAutoScreenshot)
{
Graphics()->TakeScreenshot("auto/autoscreen");
m_AutoScreenshotRecycle = true;
}
}
Expand All @@ -1893,8 +1828,6 @@ void CClient::AutoScreenshot_Cleanup()

void CClient::Con_Screenshot(IConsole::IResult *pResult, void *pUserData)
{
CClient *pSelf = (CClient *)pUserData;
pSelf->Graphics()->TakeScreenshot(0);
}

void CClient::Con_Rcon(IConsole::IResult *pResult, void *pUserData)
Expand Down Expand Up @@ -2051,68 +1984,31 @@ void CClient::SwitchWindowScreen(int Index)

void CClient::ConchainWindowScreen(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{
CClient *pSelf = (CClient *)pUserData;
if(pSelf->Graphics() && pResult->NumArguments())
{
if(g_Config.m_GfxScreen != pResult->GetInteger(0))
pSelf->SwitchWindowScreen(pResult->GetInteger(0));
}
else
pfnCallback(pResult, pCallbackUserData);
}

void CClient::ToggleFullscreen()
{
if(Graphics()->Fullscreen(g_Config.m_GfxFullscreen^1))
g_Config.m_GfxFullscreen ^= 1;
}

void CClient::ConchainFullscreen(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{
CClient *pSelf = (CClient *)pUserData;
if(pSelf->Graphics() && pResult->NumArguments())
{
if(g_Config.m_GfxFullscreen != pResult->GetInteger(0))
pSelf->ToggleFullscreen();
}
else
pfnCallback(pResult, pCallbackUserData);
}

void CClient::ToggleWindowBordered()
{
g_Config.m_GfxBorderless ^= 1;
Graphics()->SetWindowBordered(!g_Config.m_GfxBorderless);
}

void CClient::ConchainWindowBordered(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{
CClient *pSelf = (CClient *)pUserData;
if(pSelf->Graphics() && pResult->NumArguments())
{
if(!g_Config.m_GfxFullscreen && (g_Config.m_GfxBorderless != pResult->GetInteger(0)))
pSelf->ToggleWindowBordered();
}
else
pfnCallback(pResult, pCallbackUserData);
}

void CClient::ToggleWindowVSync()
{
if(Graphics()->SetVSync(g_Config.m_GfxVsync^1))
g_Config.m_GfxVsync ^= 1;
}

void CClient::ConchainWindowVSync(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData)
{
CClient *pSelf = (CClient *)pUserData;
if(pSelf->Graphics() && pResult->NumArguments())
{
if(g_Config.m_GfxVsync != pResult->GetInteger(0))
pSelf->ToggleWindowVSync();
}
else
pfnCallback(pResult, pCallbackUserData);
}

void CClient::RegisterCommands()
Expand Down Expand Up @@ -2172,31 +2068,6 @@ extern "C" int SDL_main(int argc, char **argv_) // ignore_convention
#else
int main(int argc, const char **argv) // ignore_convention
{
#endif
#if defined(CONF_FAMILY_WINDOWS)
#ifdef CONF_RELEASE
bool HideConsole = true;
#else
bool HideConsole = false;
#endif
for(int i = 1; i < argc; i++) // ignore_convention
{
if(str_comp("-c", argv[i]) == 0 || str_comp("--console", argv[i]) == 0) // ignore_convention
{
HideConsole = false;
break;
}
if(str_comp("-s", argv[i]) == 0 || str_comp("--silent", argv[i]) == 0) // ignore_convention
{
HideConsole = true;
break;
}
}

if(HideConsole)
FreeConsole();
#endif

bool UseDefaultConfig = false;
for(int i = 1; i < argc; i++) // ignore_convention
{
Expand Down
6 changes: 0 additions & 6 deletions src/engine/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class CClient : public IClient, public CDemoPlayer::IListner
IEngine *m_pEngine;
IEditor *m_pEditor;
IEngineInput *m_pInput;
IEngineGraphics *m_pGraphics;
IGameClient *m_pGameClient;
IEngineMap *m_pMap;
IConsole *m_pConsole;
Expand All @@ -81,8 +80,6 @@ class CClient : public IClient, public CDemoPlayer::IListner
unsigned m_SnapshotParts;
int64 m_LocalStartTime;

IGraphics::CTextureHandle m_DebugFont;

int64 m_LastRenderTime;
int64 m_LastCpuTime;
float m_LastAvgCpuFrameTime;
Expand Down Expand Up @@ -183,7 +180,6 @@ class CClient : public IClient, public CDemoPlayer::IListner

public:
IEngine *Engine() { return m_pEngine; }
IEngineGraphics *Graphics() { return m_pGraphics; }
IEngineInput *Input() { return m_pInput; }
IGameClient *GameClient() { return m_pGameClient; }
IEngineMasterServer *MasterServer() { return m_pMasterServer; }
Expand All @@ -207,8 +203,6 @@ class CClient : public IClient, public CDemoPlayer::IListner

virtual bool SoundInitFailed() const { return m_SoundInitFailed; }

virtual IGraphics::CTextureHandle GetDebugFont() const { return m_DebugFont; }

void SendInput();

// TODO: OPT: do this alot smarter!
Expand Down

0 comments on commit 00868b0

Please sign in to comment.