[Worker] Basic worker project
This commit is contained in:
parent
0ad65d04f3
commit
b0d863e28d
83
premake/boost.lua
Normal file
83
premake/boost.lua
Normal file
@ -0,0 +1,83 @@
|
||||
boost = {
|
||||
settings = nil,
|
||||
}
|
||||
|
||||
function boost.setup(settings)
|
||||
if not settings.source then error("Missing source.") end
|
||||
|
||||
boost.settings = settings
|
||||
end
|
||||
|
||||
function boost.import()
|
||||
if not boost.settings then error("Run boost.setup first") end
|
||||
|
||||
--links { "boost" }
|
||||
boost.includes()
|
||||
end
|
||||
|
||||
function boost.includes()
|
||||
if not boost.settings then error("Run boost.setup first") end
|
||||
|
||||
submodules = {
|
||||
"mpl",
|
||||
"core",
|
||||
"move",
|
||||
"tuple",
|
||||
"assert",
|
||||
"predef",
|
||||
"config",
|
||||
"detail",
|
||||
"winapi",
|
||||
"integer",
|
||||
"utility",
|
||||
"iterator",
|
||||
"container",
|
||||
"unordered",
|
||||
"date_time",
|
||||
"smart_ptr",
|
||||
"intrusive",
|
||||
"functional",
|
||||
"type_traits",
|
||||
"interprocess",
|
||||
"preprocessor",
|
||||
"static_assert",
|
||||
"throw_exception",
|
||||
}
|
||||
|
||||
for i, submodule in ipairs(submodules) do
|
||||
includedirs { path.join(boost.settings.source, string.format("%s/include", submodule)) }
|
||||
end
|
||||
|
||||
includedirs { boost.settings.source }
|
||||
end
|
||||
|
||||
function boost.project()
|
||||
if not boost.settings then error("Run boost.setup first") end
|
||||
|
||||
--[[
|
||||
project "boost"
|
||||
language "C++"
|
||||
|
||||
includedirs
|
||||
{
|
||||
boost.settings.source,
|
||||
}
|
||||
|
||||
files
|
||||
{
|
||||
path.join(boost.settings.source, "*.cpp"),
|
||||
path.join(boost.settings.source, "*.hpp"),
|
||||
}
|
||||
removefiles
|
||||
{
|
||||
path.join(boost.settings.source, "test*"),
|
||||
}
|
||||
|
||||
-- not our code, ignore POSIX usage warnings for now
|
||||
warnings "Off"
|
||||
|
||||
defines { "_LIB" }
|
||||
removedefines { "_USRDLL", "_DLL" }
|
||||
kind "StaticLib"
|
||||
]]
|
||||
end
|
127
premake5.lua
127
premake5.lua
@ -204,6 +204,7 @@ require "premake/pdcurses"
|
||||
require "premake/protobuf"
|
||||
require "premake/sqlite3"
|
||||
require "premake/zlib"
|
||||
require "premake/boost"
|
||||
|
||||
base128.setup
|
||||
{
|
||||
@ -260,6 +261,10 @@ zlib.setup
|
||||
},
|
||||
source = path.join(depsBasePath, "zlib"),
|
||||
}
|
||||
boost.setup
|
||||
{
|
||||
source = path.join(depsBasePath, "boost"),
|
||||
}
|
||||
|
||||
workspace "iw4x"
|
||||
location "./build"
|
||||
@ -302,34 +307,12 @@ workspace "iw4x"
|
||||
"./src/**.cpp",
|
||||
--"./src/**.proto",
|
||||
}
|
||||
removefiles {
|
||||
"./src/Worker/**.*",
|
||||
}
|
||||
includedirs {
|
||||
"%{prj.location}/src",
|
||||
"./src",
|
||||
|
||||
-- boost includes
|
||||
"./deps/boost/mpl/include",
|
||||
"./deps/boost/core/include",
|
||||
"./deps/boost/move/include",
|
||||
"./deps/boost/assert/include",
|
||||
"./deps/boost/predef/include",
|
||||
"./deps/boost/config/include",
|
||||
"./deps/boost/detail/include",
|
||||
"./deps/boost/winapi/include",
|
||||
"./deps/boost/integer/include",
|
||||
"./deps/boost/tuple/include",
|
||||
"./deps/boost/iterator/include",
|
||||
"./deps/boost/utility/include",
|
||||
"./deps/boost/container/include",
|
||||
"./deps/boost/unordered/include",
|
||||
"./deps/boost/date_time/include",
|
||||
"./deps/boost/type_traits/include",
|
||||
"./deps/boost/preprocessor/include",
|
||||
"./deps/boost/smart_ptr/include",
|
||||
"./deps/boost/throw_exception/include",
|
||||
"./deps/boost/functional/include",
|
||||
"./deps/boost/intrusive/include",
|
||||
"./deps/boost/interprocess/include",
|
||||
"./deps/boost/static_assert/include",
|
||||
}
|
||||
resincludedirs {
|
||||
"$(ProjectDir)src" -- fix for VS IDE
|
||||
@ -394,6 +377,7 @@ workspace "iw4x"
|
||||
pdcurses.import()
|
||||
protobuf.import()
|
||||
zlib.import()
|
||||
boost.import()
|
||||
|
||||
-- fix vpaths for protobuf sources
|
||||
vpaths
|
||||
@ -494,6 +478,98 @@ workspace "iw4x"
|
||||
}
|
||||
filter {}
|
||||
]]
|
||||
|
||||
project "iw4xworker"
|
||||
kind "WindowedApp"
|
||||
language "C++"
|
||||
flags { "C++14" }
|
||||
files {
|
||||
"./src/Worker/**.rc",
|
||||
"./src/Worker/**.hpp",
|
||||
"./src/Worker/**.cpp",
|
||||
--"./src/**.proto",
|
||||
}
|
||||
includedirs {
|
||||
"%{prj.location}/src",
|
||||
--"./src",
|
||||
"./src/Worker",
|
||||
}
|
||||
resincludedirs {
|
||||
"$(ProjectDir)src/Worker" -- fix for VS IDE
|
||||
}
|
||||
|
||||
-- Pre-compiled header
|
||||
pchheader "STDInclude.hpp" -- must be exactly same as used in #include directives
|
||||
pchsource "src/Worker/STDInclude.cpp" -- real path
|
||||
buildoptions { "/Zm200" }
|
||||
|
||||
protobuf.import()
|
||||
zlib.import()
|
||||
boost.import()
|
||||
|
||||
-- fix vpaths for protobuf sources
|
||||
vpaths
|
||||
{
|
||||
["*"] = { "./src/Worker/**" },
|
||||
--["Proto/Generated"] = { "**.pb.*" }, -- meh.
|
||||
}
|
||||
|
||||
-- Virtual paths
|
||||
if not _OPTIONS["no-new-structure"] then
|
||||
vpaths
|
||||
{
|
||||
["Headers/*"] = { "./src/Worker/**.hpp" },
|
||||
["Sources/*"] = { "./src/Worker/**.cpp" },
|
||||
["Resource/*"] = { "./src/Worker/**.rc" },
|
||||
}
|
||||
end
|
||||
|
||||
vpaths
|
||||
{
|
||||
["Docs/*"] = { "**.txt","**.md" },
|
||||
}
|
||||
|
||||
-- Pre-build
|
||||
prebuildcommands
|
||||
{
|
||||
"cd %{_MAIN_SCRIPT_DIR}",
|
||||
"tools\\premake5 generate-buildinfo",
|
||||
}
|
||||
|
||||
-- Post-build
|
||||
if _OPTIONS["copy-to"] then
|
||||
saneCopyToPath = string.gsub(_OPTIONS["copy-to"] .. "\\", "\\\\", "\\")
|
||||
postbuildcommands {
|
||||
"if not exist \"" .. saneCopyToPath .. "\" mkdir \"" .. saneCopyToPath .. "\"",
|
||||
}
|
||||
|
||||
if _OPTIONS["copy-pdb"] then
|
||||
postbuildcommands {
|
||||
"copy /y \"$(TargetDir)*.pdb\" \"" .. saneCopyToPath .. "\"",
|
||||
}
|
||||
end
|
||||
|
||||
-- This has to be the last one, as otherwise VisualStudio will succeed building even if copying fails
|
||||
postbuildcommands {
|
||||
"copy /y \"$(TargetDir)*.dll\" \"" .. saneCopyToPath .. "\"",
|
||||
}
|
||||
end
|
||||
|
||||
-- Specific configurations
|
||||
flags { "UndefinedIdentifiers", "ExtraWarnings" }
|
||||
|
||||
if symbols ~= nil then
|
||||
symbols "On"
|
||||
else
|
||||
flags { "Symbols" }
|
||||
end
|
||||
|
||||
configuration "Release*"
|
||||
flags {
|
||||
"FatalCompileWarnings",
|
||||
"FatalLinkWarnings",
|
||||
}
|
||||
configuration {}
|
||||
|
||||
group "External dependencies"
|
||||
if not _OPTIONS["disable-bitmessage"] then
|
||||
@ -511,6 +587,7 @@ workspace "iw4x"
|
||||
pdcurses.project()
|
||||
protobuf.project()
|
||||
zlib.project()
|
||||
boost.project()
|
||||
|
||||
rule "ProtobufCompiler"
|
||||
display "Protobuf compiler"
|
||||
|
15
src/Worker/Main.cpp
Normal file
15
src/Worker/Main.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include "STDInclude.hpp"
|
||||
#include <conio.h>
|
||||
|
||||
int main(int /*argc*/, char /*argv*/[])
|
||||
{
|
||||
AllocConsole();
|
||||
AttachConsole(GetCurrentProcessId());
|
||||
freopen("CONOUT$", "w", stdout);
|
||||
|
||||
printf("Hi");
|
||||
_getch();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
99
src/Worker/Resource.rc
Normal file
99
src/Worker/Resource.rc
Normal file
@ -0,0 +1,99 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#pragma code_page(65001)
|
||||
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "windows.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (United States) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""windows.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION VERSION_RC
|
||||
PRODUCTVERSION VERSION_RC
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x40004L
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "IW4x"
|
||||
#ifdef _DEBUG
|
||||
VALUE "FileDescription", "IW4 client modification (DEBUG)"
|
||||
#else
|
||||
VALUE "FileDescription", "IW4 client modification"
|
||||
#endif
|
||||
VALUE "FileVersion", SHORTVERSION
|
||||
VALUE "InternalName", "iw4x"
|
||||
VALUE "LegalCopyright", "No rights reserved."
|
||||
VALUE "OriginalFilename", "iw4x.dll"
|
||||
VALUE "ProductName", "IW4x"
|
||||
VALUE "ProductVersion", SHORTVERSION
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (United States) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
77
src/Worker/STDInclude.cpp
Normal file
77
src/Worker/STDInclude.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
#include "STDInclude.hpp"
|
||||
|
||||
// Rename sections
|
||||
#ifndef DEBUG
|
||||
#pragma comment(linker, "/merge:.text=.UPX0")
|
||||
#pragma comment(linker, "/merge:.data=.UPX1")
|
||||
#pragma comment(linker, "/merge:.rdata=.UPX2")
|
||||
#pragma comment(linker, "/merge:.tls=.UPX3")
|
||||
#pragma comment(linker, "/merge:.gfids=.UPX4")
|
||||
#endif
|
||||
|
||||
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
|
||||
// Do necessary assertions here
|
||||
// Some compilers treat them differently which causes a size mismatch
|
||||
|
||||
// WinAPI types
|
||||
AssertSize(DWORD, 4);
|
||||
AssertSize(WORD, 2);
|
||||
AssertSize(BYTE, 1);
|
||||
|
||||
// 128 bit integers (only x64)
|
||||
//AssertSize(__int128, 16);
|
||||
//AssertSize(unsigned __int128, 16);
|
||||
|
||||
// 64 bit integers
|
||||
AssertSize(__int64, 8);
|
||||
AssertSize(unsigned __int64, 8);
|
||||
AssertSize(long long, 8);
|
||||
AssertSize(unsigned long long, 8);
|
||||
AssertSize(int64_t, 8);
|
||||
AssertSize(uint64_t, 8);
|
||||
AssertSize(std::int64_t, 8);
|
||||
AssertSize(std::uint64_t, 8);
|
||||
|
||||
// 32 bit integers
|
||||
AssertSize(__int32, 4);
|
||||
AssertSize(unsigned __int32, 4);
|
||||
AssertSize(int, 4);
|
||||
AssertSize(unsigned int, 4);
|
||||
AssertSize(int32_t, 4);
|
||||
AssertSize(uint32_t, 4);
|
||||
AssertSize(std::int32_t, 4);
|
||||
AssertSize(std::uint32_t, 4);
|
||||
|
||||
// 16 bit integers
|
||||
AssertSize(__int16, 2);
|
||||
AssertSize(unsigned __int16, 2);
|
||||
AssertSize(short, 2);
|
||||
AssertSize(unsigned short, 2);
|
||||
AssertSize(int16_t, 2);
|
||||
AssertSize(uint16_t, 2);
|
||||
AssertSize(std::int16_t, 2);
|
||||
AssertSize(std::uint16_t, 2);
|
||||
|
||||
// 8 bit integers
|
||||
AssertSize(bool, 1);
|
||||
AssertSize(__int8, 1);
|
||||
AssertSize(unsigned __int8, 1);
|
||||
AssertSize(char, 1);
|
||||
AssertSize(unsigned char, 1);
|
||||
AssertSize(int8_t, 1);
|
||||
AssertSize(uint8_t, 1);
|
||||
AssertSize(std::int8_t, 1);
|
||||
AssertSize(std::uint8_t, 1);
|
||||
|
||||
// Ensure pointers are 4 bytes in size (32-bit)
|
||||
static_assert(sizeof(intptr_t) == 4 && sizeof(void*) == 4 && sizeof(size_t) == 4, "This doesn't seem to be a 32-bit environment!");
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// Disable telemetry data logging
|
||||
void __cdecl __vcrt_initialize_telemetry_provider() {}
|
||||
void __cdecl __telemetry_main_invoke_trigger() {}
|
||||
void __cdecl __telemetry_main_return_trigger() {}
|
||||
void __cdecl __vcrt_uninitialize_telemetry_provider() {}
|
||||
};
|
125
src/Worker/STDInclude.hpp
Normal file
125
src/Worker/STDInclude.hpp
Normal file
@ -0,0 +1,125 @@
|
||||
#pragma once
|
||||
|
||||
// Version number
|
||||
#include "version.h"
|
||||
|
||||
#ifndef RC_INVOKED
|
||||
|
||||
#define VC_EXTRALEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
// Requires Visual Leak Detector plugin: http://vld.codeplex.com/
|
||||
//#include <vld.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <timeapi.h>
|
||||
#include <shellapi.h>
|
||||
#include <Wininet.h>
|
||||
#include <d3d9.h>
|
||||
#include <Aclapi.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <cctype>
|
||||
#include <regex>
|
||||
#include <thread>
|
||||
#include <future>
|
||||
#include <queue>
|
||||
#include <unordered_map>
|
||||
|
||||
// Experimental C++17 features
|
||||
#include <filesystem>
|
||||
|
||||
// Usefull for debugging
|
||||
template <size_t S> class Sizer { };
|
||||
#define BindNum(x, y) Sizer<x> y;
|
||||
#define SizeOf(x, y) BindNum(sizeof(x), y)
|
||||
#define OffsetOf(x, y, z) BindNum(offsetof(x, y), z)
|
||||
|
||||
// Submodules
|
||||
// Ignore the warnings, it's no our code!
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4005)
|
||||
#pragma warning(disable: 4100)
|
||||
#pragma warning(disable: 4389)
|
||||
#pragma warning(disable: 4702)
|
||||
#pragma warning(disable: 4996) // _CRT_SECURE_NO_WARNINGS
|
||||
#pragma warning(disable: 6001)
|
||||
#pragma warning(disable: 6011)
|
||||
#pragma warning(disable: 6031)
|
||||
#pragma warning(disable: 6255)
|
||||
#pragma warning(disable: 6258)
|
||||
#pragma warning(disable: 6386)
|
||||
#pragma warning(disable: 6387)
|
||||
|
||||
#include <zlib.h>
|
||||
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
// Protobuf
|
||||
#include "proto/network.pb.h"
|
||||
#include "proto/party.pb.h"
|
||||
#include "proto/auth.pb.h"
|
||||
#include "proto/node.pb.h"
|
||||
#include "proto/rcon.pb.h"
|
||||
|
||||
#pragma warning(pop)
|
||||
/*
|
||||
#include "Utils/IO.hpp"
|
||||
#include "Utils/CSV.hpp"
|
||||
#include "Utils/Time.hpp"
|
||||
#include "Utils/Cache.hpp"
|
||||
#include "Utils/Chain.hpp"
|
||||
#include "Utils/Utils.hpp"
|
||||
#include "Utils/WebIO.hpp"
|
||||
#include "Utils/Memory.hpp"
|
||||
#include "Utils/String.hpp"
|
||||
#include "Utils/Hooking.hpp"
|
||||
#include "Utils/Library.hpp"
|
||||
#include "Utils/InfoString.hpp"
|
||||
#include "Utils/Compression.hpp"
|
||||
#include "Utils/Cryptography.hpp"
|
||||
*/
|
||||
// Libraries
|
||||
#pragma comment(lib, "Winmm.lib")
|
||||
#pragma comment(lib, "Crypt32.lib")
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
#pragma comment(lib, "d3d9.lib")
|
||||
#pragma comment(lib, "Wininet.lib")
|
||||
#pragma comment(lib, "shlwapi.lib")
|
||||
#pragma comment(lib, "Urlmon.lib")
|
||||
#pragma comment(lib, "Advapi32.lib")
|
||||
#pragma comment(lib, "rpcrt4.lib")
|
||||
|
||||
// Enable additional literals
|
||||
using namespace std::literals;
|
||||
|
||||
#endif
|
||||
|
||||
#define STRINGIZE_(x) #x
|
||||
#define STRINGIZE(x) STRINGIZE_(x)
|
||||
|
||||
#define AssertSize(x, size) static_assert(sizeof(x) == size, STRINGIZE(x) " structure has an invalid size.")
|
||||
#define AssertOffset(x, y, offset) static_assert(offsetof(x, y) == offset, STRINGIZE(x) "::" STRINGIZE(y) " is not at the right offset.")
|
||||
|
||||
// Resource stuff
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
// Defines below make accessing the resources from the code easier.
|
||||
#define _APS_NEXT_RESOURCE_VALUE 102
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Enables custom map code
|
||||
#ifdef DEBUG
|
||||
#define ENABLE_EXPERIMENTAL_MAP_CODE
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user