Skip to content

Commit

Permalink
Global: use GEnv.isDedicatedServer instead of g_dedicated_server
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Nov 11, 2017
1 parent e00be34 commit 0328560
Show file tree
Hide file tree
Showing 64 changed files with 170 additions and 197 deletions.
3 changes: 2 additions & 1 deletion src/Include/xrAPI/xrAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class XRAPI_API EngineGlobalEnvironment
IRenderFactory* RenderFactory;
CScriptEngine* ScriptEngine;
AISpaceBase* AISpace;

bool isDedicatedServer;
};

extern XRAPI_API EngineGlobalEnvironment GEnv;
extern XRAPI_API bool g_dedicated_server; // XXX: move to EngineGlobalEnvironment
1 change: 0 additions & 1 deletion src/Layers/xrAPI/xrAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
#include "Include/xrAPI/xrAPI.h"

EngineGlobalEnvironment GEnv = {};
bool g_dedicated_server = false;
12 changes: 6 additions & 6 deletions src/Layers/xrRender/HW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void CHW::Reset(HWND hwnd)
// BOOL bWindowed = TRUE;
//#endif
BOOL bWindowed = TRUE;
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
bWindowed = !psDeviceFlags.is(rsFullscreen);

selectResolution(DevPP.BackBufferWidth, DevPP.BackBufferHeight, bWindowed);
Expand Down Expand Up @@ -98,7 +98,7 @@ void CHW::CreateD3D()
LPCSTR _name = "xrD3D9-Null";

#ifndef _EDITOR
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
#endif
_name = "d3d9.dll";

Expand Down Expand Up @@ -174,7 +174,7 @@ void CHW::selectResolution(u32& dwWidth, u32& dwHeight, BOOL bWindowed)
{
fill_vid_mode_list(this);
#ifndef _EDITOR
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
{
dwWidth = 640;
dwHeight = 480;
Expand Down Expand Up @@ -222,7 +222,7 @@ void CHW::CreateDevice(HWND m_hWnd, bool move_window)
BOOL bWindowed = TRUE;

#ifndef _EDITOR
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
bWindowed = !psDeviceFlags.is(rsFullscreen);
#else
bWindowed = 1;
Expand Down Expand Up @@ -534,7 +534,7 @@ void CHW::updateWindowProps(HWND m_hWnd)

BOOL bWindowed = TRUE;
#ifndef _EDITOR
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
bWindowed = !psDeviceFlags.is(rsFullscreen);
#endif

Expand Down Expand Up @@ -580,7 +580,7 @@ void CHW::updateWindowProps(HWND m_hWnd)
}

#ifndef _EDITOR
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
{
ShowCursor(FALSE);
SetForegroundWindow(m_hWnd);
Expand Down
4 changes: 2 additions & 2 deletions src/Layers/xrRender/R_Backend_Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void CBackend::OnFrameEnd()
{
//#ifndef DEDICATED_SERVER
#ifndef _EDITOR
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
#endif
{
#if defined(USE_DX10) || defined(USE_DX11)
Expand All @@ -41,7 +41,7 @@ void CBackend::OnFrameBegin()
{
//#ifndef DEDICATED_SERVER
#ifndef _EDITOR
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
#endif
{
PGO(Msg("PGO:*****frame[%d]*****", RDEVICE.dwFrame));
Expand Down
6 changes: 3 additions & 3 deletions src/Layers/xrRender/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ Shader* CResourceManager::_cpp_Create(LPCSTR s_shader, LPCSTR s_textures, LPCSTR
{
//#ifndef DEDICATED_SERVER
#ifndef _EDITOR
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
#endif
{
// TODO: DX10: When all shaders are ready switch to common path
Expand All @@ -297,7 +297,7 @@ Shader* CResourceManager::Create(IBlender* B, LPCSTR s_shader, LPCSTR s_textures
{
//#ifndef DEDICATED_SERVER
#ifndef _EDITOR
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
#endif
{
return _cpp_Create(B, s_shader, s_textures, s_constants, s_matrices);
Expand All @@ -316,7 +316,7 @@ Shader* CResourceManager::Create(LPCSTR s_shader, LPCSTR s_textures, LPCSTR s_co
{
//#ifndef DEDICATED_SERVER
#ifndef _EDITOR
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
#endif
{
// TODO: DX10: When all shaders are ready switch to common path
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/SH_Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void CTexture::Load()
Preload();
//#ifndef DEDICATED_SERVER
#ifndef _EDITOR
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
#endif
{
// Check for OGM
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/r__dsgraph_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ void D3DXRenderBase::OnDeviceCreate(const char* shName)
m_Gamma.Update();
Resources->OnDeviceCreate(shName);
create();
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
{
m_WireShader.create("editor\\wire");
m_SelectionShader.create("editor\\selection");
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/r__sector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void CSector::load(IReader& fs)
count--;
}

if (g_dedicated_server)
if (GEnv.isDedicatedServer)
m_root = nullptr;
else
{
Expand Down
24 changes: 10 additions & 14 deletions src/Layers/xrRender/stats_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
#include "stdafx.h"
#include "stats_manager.h"

#ifdef _EDITOR
const bool g_dedicated_server = false;
#endif

void stats_manager::increment_stats(u32 size, enum_stats_buffer_type type, _D3DPOOL location)
{
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;

R_ASSERT(type >= 0 && type < enum_stats_buffer_type_COUNT);
Expand All @@ -23,7 +19,7 @@ void stats_manager::increment_stats(u32 size, enum_stats_buffer_type type, _D3DP

void stats_manager::increment_stats(u32 size, enum_stats_buffer_type type, _D3DPOOL location, void* buff_ptr)
{
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;

R_ASSERT(buff_ptr != NULL);
Expand All @@ -44,7 +40,7 @@ void stats_manager::increment_stats(u32 size, enum_stats_buffer_type type, _D3DP

void stats_manager::increment_stats_rtarget(ID3DTexture2D* buff)
{
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;

_D3DPOOL pool = D3DPOOL_MANAGED;
Expand All @@ -63,7 +59,7 @@ void stats_manager::increment_stats_rtarget(ID3DTexture2D* buff)

void stats_manager::increment_stats_vb(ID3DVertexBuffer* buff)
{
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;

#if defined(USE_DX10) || defined(USE_DX11)
Expand All @@ -79,7 +75,7 @@ void stats_manager::increment_stats_vb(ID3DVertexBuffer* buff)

void stats_manager::increment_stats_ib(ID3DIndexBuffer* buff)
{
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;

#if defined(USE_DX10) || defined(USE_DX11)
Expand All @@ -95,7 +91,7 @@ void stats_manager::increment_stats_ib(ID3DIndexBuffer* buff)

void stats_manager::decrement_stats_rtarget(ID3DTexture2D* buff)
{
if (buff == nullptr || g_dedicated_server)
if (buff == nullptr || GEnv.isDedicatedServer)
return;

buff->AddRef();
Expand All @@ -119,7 +115,7 @@ void stats_manager::decrement_stats_rtarget(ID3DTexture2D* buff)

void stats_manager::decrement_stats_vb(ID3DVertexBuffer* buff)
{
if (buff == nullptr || g_dedicated_server)
if (buff == nullptr || GEnv.isDedicatedServer)
return;

buff->AddRef();
Expand All @@ -140,7 +136,7 @@ void stats_manager::decrement_stats_vb(ID3DVertexBuffer* buff)

void stats_manager::decrement_stats_ib(ID3DIndexBuffer* buff)
{
if (buff == nullptr || g_dedicated_server)
if (buff == nullptr || GEnv.isDedicatedServer)
return;

buff->AddRef();
Expand All @@ -161,7 +157,7 @@ void stats_manager::decrement_stats_ib(ID3DIndexBuffer* buff)

void stats_manager::decrement_stats(u32 size, enum_stats_buffer_type type, _D3DPOOL location)
{
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;

R_ASSERT(type >= 0 && type < enum_stats_buffer_type_COUNT);
Expand All @@ -171,7 +167,7 @@ void stats_manager::decrement_stats(u32 size, enum_stats_buffer_type type, _D3DP

void stats_manager::decrement_stats(u32 size, enum_stats_buffer_type type, _D3DPOOL location, void* buff_ptr)
{
if (buff_ptr == nullptr || g_dedicated_server)
if (buff_ptr == nullptr || GEnv.isDedicatedServer)
return;

#ifdef DEBUG
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRender/xrRender_console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ class CCC_Screenshot : public IConsole_Command
CCC_Screenshot(LPCSTR N) : IConsole_Command(N){};
virtual void Execute(LPCSTR args)
{
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;

string_path name;
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R1/FStaticRender_Loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void CRender::level_Load(IReader* fs)

marker = 0;

if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
{
// VB,IB,SWI
// g_pGamePersistent->LoadTitle("st_loading_geometry");
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R2/r2_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void CRender::level_Load(IReader* fs)
Wallmarks = new CWallmarksEngine();
Details = new CDetailManager();

if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
{
// VB,IB,SWI
// g_pGamePersistent->LoadTitle("st_loading_geometry");
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R3/r3_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void CRender::level_Load(IReader* fs)
Wallmarks = new CWallmarksEngine();
Details = new CDetailManager();

if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
{
// VB,IB,SWI
// g_pGamePersistent->LoadTitle("st_loading_geometry");
Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R4/r4_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void CRender::level_Load(IReader* fs)
Wallmarks = new CWallmarksEngine();
Details = new CDetailManager();

if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
{
// VB,IB,SWI
// g_pGamePersistent->LoadTitle("st_loading_geometry");
Expand Down
8 changes: 4 additions & 4 deletions src/xrAICore/AISpaceBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void AISpaceBase::Load(const char* levelName)

void AISpaceBase::Unload(bool reload)
{
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;
xr_delete(m_graph_engine);
xr_delete(m_level_graph);
Expand All @@ -45,7 +45,7 @@ void AISpaceBase::Unload(bool reload)

void AISpaceBase::Initialize()
{
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;
VERIFY(!m_graph_engine);
m_graph_engine = new CGraphEngine(1024);
Expand Down Expand Up @@ -87,7 +87,7 @@ void AISpaceBase::Validate(u32 levelId) const

void AISpaceBase::patrol_path_storage_raw(IReader& stream)
{
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;
xr_delete(m_patrol_path_storage);
m_patrol_path_storage = new CPatrolPathStorage();
Expand All @@ -96,7 +96,7 @@ void AISpaceBase::patrol_path_storage_raw(IReader& stream)

void AISpaceBase::patrol_path_storage(IReader& stream)
{
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;
xr_delete(m_patrol_path_storage);
m_patrol_path_storage = new CPatrolPathStorage();
Expand Down
4 changes: 2 additions & 2 deletions src/xrEngine/IGame_Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ bool IGame_Level::Load(u32 dwNum)
// Done
FS.r_close(LL_Stream);
bReady = true;
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
IR_Capture();
#ifndef DEDICATED_SERVER
Device.seqRender.Add(this);
Expand Down Expand Up @@ -154,7 +154,7 @@ void IGame_Level::OnRender()
#endif // _GPA_ENABLED

// Level render, only when no client output required
if (!g_dedicated_server)
if (!GEnv.isDedicatedServer)
{
GEnv.Render->Calculate();
GEnv.Render->Render();
Expand Down
2 changes: 1 addition & 1 deletion src/xrEngine/Stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void CStats::Show()
else
fMem_calls = 0.9f * fMem_calls + 0.1f * memCalls;
Memory.stat_calls = 0;
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
return;
auto& font = *statsFont;
auto engineTotal = Device.GetStats().EngineTotal.result;
Expand Down
11 changes: 3 additions & 8 deletions src/xrEngine/XR_IOConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void CConsole::OnRender()
{
bGame = true;
}
if (g_dedicated_server)
if (GEnv.isDedicatedServer)
{
bGame = false;
}
Expand Down Expand Up @@ -624,14 +624,9 @@ extern CInput* pInput;

void CConsole::Hide()
{
if (!bVisible)
{
if (!bVisible || g_pGamePersistent && GEnv.isDedicatedServer)
return;
}
if (g_pGamePersistent && g_dedicated_server)
{
return;
}

// if ( g_pGameLevel ||
// ( g_pGamePersistent && g_pGamePersistent->m_pMainMenu && g_pGamePersistent->m_pMainMenu->IsActive() ))

Expand Down
4 changes: 2 additions & 2 deletions src/xrEngine/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ class StickyKeyFilter
int RunApplication(pcstr commandLine)
{
#ifdef DEDICATED_SERVER
g_dedicated_server = true;
GEnv.isDedicatedServer = true;
#endif
xrDebug::Initialize(g_dedicated_server);
xrDebug::Initialize(GEnv.isDedicatedServer);
if (!IsDebuggerPresent())
{
u32 heapFragmentation = 2;
Expand Down
2 changes: 1 addition & 1 deletion src/xrEngine/x_ray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void CApplication::LoadDraw()
if (!Device.Begin())
return;

if (g_dedicated_server)
if (GEnv.isDedicatedServer)
Console->OnRender();
else
load_draw_internal();
Expand Down
Loading

0 comments on commit 0328560

Please sign in to comment.