forked from citizenfx/fivem
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathXBRInit.cpp
More file actions
62 lines (48 loc) · 1.22 KB
/
XBRInit.cpp
File metadata and controls
62 lines (48 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "StdInc.h"
#ifndef IS_FXSERVER
#include "CrossBuildRuntime.h"
#include <HostSharedData.h>
#include <CfxState.h>
#include <shellapi.h>
namespace xbr
{
int GetRequestedGameBuildInit()
{
constexpr const std::pair<std::wstring_view, int> buildNumbers[] = {
#define EXPAND(_, __, x) \
{ BOOST_PP_WSTRINGIZE(BOOST_PP_CAT(-b, x)), x },
BOOST_PP_SEQ_FOR_EACH(EXPAND, , GAME_BUILDS)
#undef EXPAND
};
auto sharedData = CfxState::Get();
std::wstring_view cli = (sharedData->initCommandLine[0]) ? sharedData->initCommandLine : GetCommandLineW();
auto buildNumber = GetDefaultGameBuild();
int argc;
wchar_t** wargv = CommandLineToArgvW(cli.data(), &argc);
for (int i = 1; i < argc; i++)
{
std::wstring_view arg = wargv[i];
for (auto [build, number] : buildNumbers)
{
if (arg == build)
{
buildNumber = number;
break;
}
}
}
LocalFree(wargv);
return buildNumber;
}
bool GetReplaceExecutableInit()
{
bool replaceExecutable = true;
std::wstring fpath = MakeRelativeCitPath(L"CitizenFX.ini");
if (GetFileAttributes(fpath.c_str()) != INVALID_FILE_ATTRIBUTES)
{
replaceExecutable = (GetPrivateProfileInt(L"Game", L"ReplaceExecutable", 1, fpath.c_str()) != 0);
}
return replaceExecutable;
}
}
#endif