Skip to content

Commit

Permalink
Moved all log-related stuff to stdafx.
Browse files Browse the repository at this point in the history
  • Loading branch information
intorr committed Jan 24, 2018
1 parent 5d4b21a commit cf1c617
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 113 deletions.
20 changes: 20 additions & 0 deletions src/utils/xrAI/StdAfx.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
#include "stdafx.h"
#include "xrCore/cdecl_cast.hpp"
#include "utils/xrLCUtil/LevelCompilerLoggerWindow.hpp"

ILevelCompilerLogger& Logger = LevelCompilerLoggerWindow::instance();

CThread::LogFunc ProxyMsg = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.clMsgV(format, args);
va_end(args);
});

CThreadManager::ReportStatusFunc ProxyStatus = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.StatusV(format, args);
va_end(args);
});

CThreadManager::ReportProgressFunc ProxyProgress = cdecl_cast([](float progress) { Logger.Progress(progress); });
4 changes: 2 additions & 2 deletions src/utils/xrAI/StdAfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#include <d3dx9.h>
#include "Common/_d3d_extensions.h"

#include "utils/xrLCUtil/LevelCompilerLoggerWindow.hpp"
#include "utils/xrLCUtil/ILevelCompilerLogger.hpp"
#include "utils/xrLCUtil/xrThread.hpp"

extern LevelCompilerLoggerWindow& Logger;
extern ILevelCompilerLogger& Logger;
extern CThread::LogFunc ProxyMsg;
extern CThreadManager::ReportStatusFunc ProxyStatus;
extern CThreadManager::ReportProgressFunc ProxyProgress;
Expand Down
21 changes: 1 addition & 20 deletions src/utils/xrAI/xrAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,13 @@

#pragma comment(lib, "winmm.LIB")

#include "xrCore/cdecl_cast.hpp"
#include "xrCore/ModuleLookup.hpp"

#include "factory_api.h"

Factory_Create* create_entity = 0;
Factory_Destroy* destroy_entity = 0;

LevelCompilerLoggerWindow& Logger = LevelCompilerLoggerWindow::instance();

CThread::LogFunc ProxyMsg = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.clMsgV(format, args);
va_end(args);
});

CThreadManager::ReportStatusFunc ProxyStatus = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.StatusV(format, args);
va_end(args);
});

CThreadManager::ReportProgressFunc ProxyProgress = cdecl_cast([](float progress) { Logger.Progress(progress); });

extern void xrCompiler(LPCSTR name, bool draft_mode, bool pure_covers, LPCSTR out_name);
extern void verify_level_graph(LPCSTR name, bool verbose);

Expand Down Expand Up @@ -184,7 +165,7 @@ void Startup(LPSTR lpCmdLine)
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
xrDebug::Initialize(false);
Core.Initialize("xrai", 0);
Core.Initialize("xrAI");

Startup(lpCmdLine);

Expand Down
20 changes: 20 additions & 0 deletions src/utils/xrDO_Light/StdAfx.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
#include "stdafx.h"
#include "xrCore/cdecl_cast.hpp"
#include "utils/xrLCUtil/LevelCompilerLoggerWindow.hpp"

ILevelCompilerLogger& Logger = LevelCompilerLoggerWindow::instance();

CThread::LogFunc ProxyMsg = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.clMsgV(format, args);
va_end(args);
});

CThreadManager::ReportStatusFunc ProxyStatus = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.StatusV(format, args);
va_end(args);
});

CThreadManager::ReportProgressFunc ProxyProgress = cdecl_cast([](float progress) { Logger.Progress(progress); });
29 changes: 0 additions & 29 deletions src/utils/xrDO_Light/StdAfx.h
Original file line number Diff line number Diff line change
@@ -1,40 +1,11 @@
#pragma once

#include "Common/Common.hpp"
#include "xrCore/xrCore.h"

#pragma warning(push)
#pragma warning(disable : 4995)
#include <d3dx9.h>
#include <commctrl.h>
#pragma warning(pop)

#define ENGINE_API
#define ECORE_API
#define XR_EPROPS_API
#include "xrCore/clsid.h"
#include "xrCDB/xrCDB.h"
#include "Common/_d3d_extensions.h"

#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <stdio.h>

#ifdef AI_COMPILER
#include "smart_cast.h"
#endif

#include "utils/xrLCUtil/ILevelCompilerLogger.hpp"
#include "utils/xrLCUtil/xrThread.hpp"
#include "xrCore/cdecl_cast.hpp"
#include "xrScriptEngine/DebugMacros.hpp" // XXX: move debug macros to xrCore

extern ILevelCompilerLogger& Logger;
extern CThread::LogFunc ProxyMsg;
extern CThreadManager::ReportStatusFunc ProxyStatus;
extern CThreadManager::ReportProgressFunc ProxyProgress;

#define READ_IF_EXISTS(ltx, method, section, name, default_value)\
(ltx->line_exist(section, name)) ? ltx->method(section, name) : default_value
31 changes: 1 addition & 30 deletions src/utils/xrDO_Light/xrDO_Light.cpp
Original file line number Diff line number Diff line change
@@ -1,46 +1,19 @@
#include "stdafx.h"
#include "process.h"

#include "utils/xrLC_Light/xrlc_light.h"
#include "utils/xrLCUtil/LevelCompilerLoggerWindow.hpp"
#include "xrCore/cdecl_cast.hpp"
#include "utils/xrLCUtil/xrLCUtil.hpp"
//#pragma comment(linker,"/STACK:0x800000,0x400000")

#pragma comment(lib, "comctl32.lib")
#pragma comment(lib, "winmm.LIB")

ILevelCompilerLogger& Logger = LevelCompilerLoggerWindow::instance();

CThread::LogFunc ProxyMsg = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.clMsgV(format, args);
va_end(args);
});

CThreadManager::ReportStatusFunc ProxyStatus = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.StatusV(format, args);
va_end(args);
});

CThreadManager::ReportProgressFunc ProxyProgress = cdecl_cast([](float progress) { Logger.Progress(progress); });

static const char* h_str =
"The following keys are supported / required:\n"
"-? or -h == this help\n"
"-f<NAME> == compile level in gamedata\\levels\\<NAME>\\\n"
"-o == modify build options\n"
"\n"
"NOTE: The last key is required for any functionality\n";

void Help() { MessageBox(0, h_str, "Command line options", MB_OK | MB_ICONINFORMATION); }
void Startup(LPSTR lpCmdLine)
{
char cmd[512];
// BOOL bModifyOptions = FALSE;
bool bNet = false;
xr_strcpy(cmd, lpCmdLine);
_strlwr(cmd);
Expand All @@ -54,7 +27,6 @@ void Startup(LPSTR lpCmdLine)
Help();
return;
}
// if (strstr(cmd,"-o")) bModifyOptions = TRUE;
if (strstr(cmd, "-net"))
bNet = true;
// Load project
Expand All @@ -65,7 +37,6 @@ void Startup(LPSTR lpCmdLine)
xr_sprintf(temp, "%s - Detail Compiler", name);
Logger.Initialize(temp);

// FS.update_path (name,"$game_levels$",name);
FS.get_path("$level$")->_set(name);

CTimer dwStartupTime;
Expand All @@ -84,9 +55,9 @@ void Startup(LPSTR lpCmdLine)

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// Initialize debugging
xrDebug::Initialize(false);
Core.Initialize("xrDO");

Startup(lpCmdLine);

return 0;
Expand Down
20 changes: 20 additions & 0 deletions src/utils/xrLC/StdAfx.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
#include "stdafx.h"
#include "xrCore/cdecl_cast.hpp"
#include "utils/xrLCUtil/LevelCompilerLoggerWindow.hpp"

ILevelCompilerLogger& Logger = LevelCompilerLoggerWindow::instance();

CThread::LogFunc ProxyMsg = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.clMsgV(format, args);
va_end(args);
});

CThreadManager::ReportStatusFunc ProxyStatus = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.StatusV(format, args);
va_end(args);
});

CThreadManager::ReportProgressFunc ProxyProgress = cdecl_cast([](float progress) { Logger.Progress(progress); });
12 changes: 3 additions & 9 deletions src/utils/xrLC/StdAfx.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
#pragma once
#include <memory>
#include "Common/Common.hpp"
#include "utils/xrLC_Light/xrLC_Light.h"

#define ENGINE_API // fake, to enable sharing with engine
// comment - ne figa oni ne sharyatsya
#define ENGINE_API

#define ECORE_API // fake, to enable sharing with editors
#define XR_EPROPS_API
#include "xrCore/clsid.h"
#include "Common/Common.hpp"
#include "utils/xrLC_Light/xrLC_Light.h"

#include "utils/xrLCUtil/ILevelCompilerLogger.hpp"
#include "utils/xrLCUtil/xrThread.hpp"
#include "xrCore/cdecl_cast.hpp"

extern ILevelCompilerLogger& Logger;
extern CThread::LogFunc ProxyMsg;
Expand Down
20 changes: 2 additions & 18 deletions src/utils/xrLC/xrLC.cpp
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@
// xrLC.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <memory>
#include "math.h"
#include "build.h"
#include "Common/FSMacros.hpp"
#include "utils/xrLC_Light/xrLC_GlobalData.h"
#include "utils/xrLCUtil/LevelCompilerLoggerWindow.hpp"
#include "xrCore/ModuleLookup.hpp"

#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "FreeImage.lib")

CBuild* pBuild = NULL;
u32 version = 0;
ILevelCompilerLogger& Logger = LevelCompilerLoggerWindow::instance();

CThread::LogFunc ProxyMsg = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.clMsgV(format, args);
va_end(args);
});

CThreadManager::ReportStatusFunc ProxyStatus = cdecl_cast([](const char* format, ...) {
va_list args;
va_start(args, format);
Logger.StatusV(format, args);
va_end(args);
});

CThreadManager::ReportProgressFunc ProxyProgress = cdecl_cast([](float progress) { Logger.Progress(progress); });

static const char* h_str =
"The following keys are supported / required:\n"
Expand Down Expand Up @@ -155,6 +138,7 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
g_using_smooth_groups = false;

Startup(lpCmdLine);

Core._destroy();

return 0;
Expand Down
5 changes: 1 addition & 4 deletions src/utils/xrLC_Light/stdafx.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// stdafx.cpp : source file that includes just the standard includes
// xrLC_Light.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information

#include "stdafx.h"
#include "xrCore/cdecl_cast.hpp"
#include "utils/xrLCUtil/LevelCompilerLoggerWindow.hpp"

ILevelCompilerLogger& Logger = LevelCompilerLoggerWindow::instance();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xrLC_Light/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

#pragma warning(disable : 4661)
#include "xrLC_Light.h"

#include "utils/xrLCUtil/ILevelCompilerLogger.hpp"
#include "utils/xrLCUtil/xrThread.hpp"
#include "xrCore/cdecl_cast.hpp"

extern ILevelCompilerLogger& Logger;
extern CThread::LogFunc ProxyMsg;
Expand Down

0 comments on commit cf1c617

Please sign in to comment.