Skip to content

Commit

Permalink
xrCore refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Aug 11, 2017
1 parent be5c51c commit 549d1bc
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/utils/ETools/ETools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ BOOL APIENTRY DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
{
case DLL_PROCESS_ATTACH:
xrDebug::Initialize(false);
Core._initialize("XRayEditorTools", 0, FALSE);
Core.Initialize("XRayEditorTools", 0, FALSE);
// FPU::m64r ();
break;
case DLL_THREAD_ATTACH: break;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mp_configs_verifyer/entry_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void run_configs_verifyer_server()

void initialize_core()
{
Core._initialize("mp_configs_info", LogCallback(xrcore_log_cb, nullptr), TRUE, "fsgame4mpu.ltx");
Core.Initialize("mp_configs_info", LogCallback(xrcore_log_cb, nullptr), TRUE, "fsgame4mpu.ltx");

string_path fname;
FS.update_path(fname, "$game_config$", "system.ltx");
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mp_screenshots_info/entry_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main(int argc, char** argv)
return EXIT_FAILURE;
}
printf("Initializing core...\n");
Core._initialize("mp_screenshots_info", LogCallback(xrcore_log_cb, nullptr), TRUE, "fsgame4mpu.ltx");
Core.Initialize("mp_screenshots_info", LogCallback(xrcore_log_cb, nullptr), TRUE, "fsgame4mpu.ltx");

#ifdef DEBUG
if (strstr(argv[1], "--gen_params"))
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xrAI/xrAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Factory_Destroy* destroy_entity = 0;
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
xrDebug::Initialize(false);
Core._initialize("xrai", 0);
Core.Initialize("xrai", 0);
HMODULE hFactory;
LPCSTR g_name = "xrSE_Factory";
Log("Loading DLL:", g_name);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xrCompress/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ extern int ProcessDifference();
int __cdecl main(int argc, char* argv[])
{
xrDebug::Initialize(false);
Core._initialize("xrCompress", 0, FALSE);
Core.Initialize("xrCompress", 0, FALSE);
printf("\n\n");

LPCSTR params = GetCommandLine();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xrDO_Light/xrDO_Light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
{
// Initialize debugging
xrDebug::Initialize(false);
Core._initialize("xrDO");
Core.Initialize("xrDO");
Startup(lpCmdLine);

return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xrLC/xrLC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
{
// Initialize debugging
xrDebug::Initialize(false);
Core._initialize("xrLC");
Core.Initialize("xrLC");

if (strstr(Core.Params, "-nosmg"))
g_using_smooth_groups = false;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xrLC_Light/xrLC_Light.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
{
xrDebug::Initialize(false);
bool init_log = (0 != xr_strcmp(Core.ApplicationName, "XRayEditorTools"));
Core._initialize("xrLC_Light", 0, FALSE);
Core.Initialize("xrLC_Light", 0, FALSE);
if (init_log)
CreateLog();

Expand Down
2 changes: 1 addition & 1 deletion src/utils/xrSE_Factory/xrSE_Factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ BOOL APIENTRY DllMain(HANDLE module_handle, DWORD call_reason, LPVOID reserved)
// g_temporary_stuff = &trivial_encryptor::decode;

Debug._initialize(false);
Core._initialize("xrSE_Factory", NULL, TRUE, "fsfactory.ltx");
Core.Initialize("xrSE_Factory", NULL, TRUE, "fsfactory.ltx");
string_path SYSTEM_LTX;
FS.update_path(SYSTEM_LTX, "$game_config$", "system.ltx");
pSettings = xr_new<CInifile>(SYSTEM_LTX);
Expand Down
18 changes: 9 additions & 9 deletions src/xrCore/xrCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static u32 init_counter = 0;

//. extern xr_vector<shared_str>* LogFile;

void xrCore::_initialize(LPCSTR _ApplicationName, LogCallback cb, BOOL init_fs, LPCSTR fs_fname, bool plugin)
void xrCore::Initialize(pcstr _ApplicationName, LogCallback cb, bool init_fs, pcstr fs_fname, bool plugin)
{
xr_strcpy(ApplicationName, _ApplicationName);
if (0 == init_counter)
Expand All @@ -36,13 +36,13 @@ void xrCore::_initialize(LPCSTR _ApplicationName, LogCallback cb, BOOL init_fs,
// HRESULT co_res =
Params = xr_strdup(GetCommandLine());
if (!strstr(Params, "-editor"))
CoInitializeEx(NULL, COINIT_MULTITHREADED);
CoInitializeEx(nullptr, COINIT_MULTITHREADED);

string_path fn, dr, di;

// application path
GetModuleFileName(GetModuleHandle("xrCore"), fn, sizeof(fn));
_splitpath(fn, dr, di, 0, 0);
_splitpath(fn, dr, di, nullptr, nullptr);
strconcat(sizeof(ApplicationPath), ApplicationPath, dr, di);

#ifdef _EDITOR
Expand Down Expand Up @@ -87,10 +87,10 @@ void xrCore::_initialize(LPCSTR _ApplicationName, LogCallback cb, BOOL init_fs,
}
if (init_fs)
{
u32 flags = 0;
if (0 != strstr(Params, "-build"))
u32 flags = 0u;
if (strstr(Params, "-build") != nullptr)
flags |= CLocatorAPI::flBuildCopy;
if (0 != strstr(Params, "-ebuild"))
if (strstr(Params, "-ebuild") != nullptr)
flags |= CLocatorAPI::flBuildCopy | CLocatorAPI::flEBuildCopy;
#ifdef DEBUG
if (strstr(Params, "-cache"))
Expand All @@ -105,11 +105,11 @@ void xrCore::_initialize(LPCSTR _ApplicationName, LogCallback cb, BOOL init_fs,

#ifndef _EDITOR
#ifndef ELocatorAPIH
if (0 != strstr(Params, "-file_activity"))
if (strstr(Params, "-file_activity") != nullptr)
flags |= CLocatorAPI::flDumpFileActivity;
#endif
#endif
FS._initialize(flags, 0, fs_fname);
FS._initialize(flags, nullptr, fs_fname);
CalculateBuildId();
Msg("'%s' build %d, %s\n", "xrCore", buildId, buildDate);
EFS._initialize();
Expand Down Expand Up @@ -201,7 +201,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD ul_reason_for_call, LPVOID lpvRese
break;
case DLL_THREAD_ATTACH:
if (!strstr(GetCommandLine(), "-editor"))
CoInitializeEx(NULL, COINIT_MULTITHREADED);
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
timeBeginPeriod(1);
break;
case DLL_THREAD_DETACH: break;
Expand Down
26 changes: 15 additions & 11 deletions src/xrCore/xrCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ struct XRCORE_API xr_rtoken
{
shared_str name;
int id;
xr_rtoken(LPCSTR _nm, int _id)

xr_rtoken(pcstr _nm, int _id)
{
name = _nm;
id = _id;
}

public:
void rename(LPCSTR _nm) { name = _nm; }
bool equal(LPCSTR _nm) { return (0 == xr_strcmp(*name, _nm)); }
void rename(pcstr _nm) { name = _nm; }
bool equal(pcstr _nm) const { return (0 == xr_strcmp(*name, _nm)); }
};

#pragma pack(push, 1)
Expand All @@ -157,6 +157,7 @@ struct XRCORE_API xr_shortcut
flCtrl = 0x40,
flAlt = 0x80,
};

union
{
struct
Expand All @@ -166,22 +167,25 @@ struct XRCORE_API xr_shortcut
};
u16 hotkey;
};
xr_shortcut(u8 k, BOOL a, BOOL c, BOOL s) : key(k)

xr_shortcut(u8 k, bool a, bool c, bool s) : key(k)
{
ext.assign(u8((a ? flAlt : 0) | (c ? flCtrl : 0) | (s ? flShift : 0)));
}

xr_shortcut()
{
ext.zero();
key = 0;
}

bool similar(const xr_shortcut& v) const { return ext.equal(v.ext) && (key == v.key); }
};
#pragma pack(pop)

DEFINE_VECTOR(shared_str, RStringVec, RStringVecIt);
DEFINE_SET(shared_str, RStringSet, RStringSetIt);
DEFINE_VECTOR(xr_rtoken, RTokenVec, RTokenVecIt);
using RStringVec = xr_vector<shared_str>;
using RStringSet = xr_set<shared_str>;
using RTokenVec = xr_vector<xr_rtoken>;

#define xr_pure_interface __interface

Expand Down Expand Up @@ -210,7 +214,7 @@ class destructor
public:
destructor(T* p) { ptr = p; }
~destructor() { xr_delete(ptr); }
IC T& operator()() { return *ptr; }
T& operator()() { return *ptr; }
};

// ********************************************** The Core definition
Expand All @@ -229,8 +233,8 @@ class XRCORE_API xrCore
DWORD dwFrame;
bool PluginMode;

void _initialize(
LPCSTR ApplicationName, LogCallback cb = 0, BOOL init_fs = TRUE, LPCSTR fs_fname = 0, bool plugin = false);
void Initialize(
pcstr ApplicationName, LogCallback cb = nullptr, bool init_fs = true, pcstr fs_fname = nullptr, bool plugin = false);
void _destroy();
const char* GetBuildDate() const { return buildDate; }
u32 GetBuildId() const { return buildId; }
Expand Down
2 changes: 2 additions & 0 deletions src/xrCore/xrMemory_subst_msvc.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

template <bool _is_pm, typename T>
struct xr_special_free
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrEngine/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ int RunApplication(pcstr commandLine)
u32 sz = xr_strlen(fsltx);
sscanf(strstr(commandLine, fsltx) + sz, "%[^ ] ", fsgame);
}
Core._initialize("xray", NULL, TRUE, *fsgame ? fsgame : nullptr);
Core.Initialize("xray", nullptr, true, *fsgame ? fsgame : nullptr);
InitSettings();
// Adjust player & computer name for Asian
if (pSettings->line_exist("string_table", "no_native_input"))
Expand Down

0 comments on commit 549d1bc

Please sign in to comment.