mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
First commit
This commit is contained in:
51
src/Olympus.sln
Normal file
51
src/Olympus.sln
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.3.32929.385
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Olympus", "Olympus\Olympus.vcxproj", "{5F3FC91E-1FBC-4223-8011-9708DE913474}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "core\core.vcxproj", "{8A48D855-0E01-42BA-BD8C-07B0877C68DF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "utils", "utils\utils.vcxproj", "{B85009CE-4A5C-4A5A-B85D-001B3A2651B2}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{5F3FC91E-1FBC-4223-8011-9708DE913474}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5F3FC91E-1FBC-4223-8011-9708DE913474}.Debug|x64.Build.0 = Debug|x64
|
||||
{5F3FC91E-1FBC-4223-8011-9708DE913474}.Debug|x86.ActiveCfg = Debug|x64
|
||||
{5F3FC91E-1FBC-4223-8011-9708DE913474}.Debug|x86.Build.0 = Debug|x64
|
||||
{5F3FC91E-1FBC-4223-8011-9708DE913474}.Release|x64.ActiveCfg = Release|x64
|
||||
{5F3FC91E-1FBC-4223-8011-9708DE913474}.Release|x64.Build.0 = Release|x64
|
||||
{5F3FC91E-1FBC-4223-8011-9708DE913474}.Release|x86.ActiveCfg = Release|x64
|
||||
{5F3FC91E-1FBC-4223-8011-9708DE913474}.Release|x86.Build.0 = Release|x64
|
||||
{8A48D855-0E01-42BA-BD8C-07B0877C68DF}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8A48D855-0E01-42BA-BD8C-07B0877C68DF}.Debug|x64.Build.0 = Debug|x64
|
||||
{8A48D855-0E01-42BA-BD8C-07B0877C68DF}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{8A48D855-0E01-42BA-BD8C-07B0877C68DF}.Debug|x86.Build.0 = Debug|Win32
|
||||
{8A48D855-0E01-42BA-BD8C-07B0877C68DF}.Release|x64.ActiveCfg = Release|x64
|
||||
{8A48D855-0E01-42BA-BD8C-07B0877C68DF}.Release|x64.Build.0 = Release|x64
|
||||
{8A48D855-0E01-42BA-BD8C-07B0877C68DF}.Release|x86.ActiveCfg = Release|Win32
|
||||
{8A48D855-0E01-42BA-BD8C-07B0877C68DF}.Release|x86.Build.0 = Release|Win32
|
||||
{B85009CE-4A5C-4A5A-B85D-001B3A2651B2}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B85009CE-4A5C-4A5A-B85D-001B3A2651B2}.Debug|x64.Build.0 = Debug|x64
|
||||
{B85009CE-4A5C-4A5A-B85D-001B3A2651B2}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{B85009CE-4A5C-4A5A-B85D-001B3A2651B2}.Debug|x86.Build.0 = Debug|Win32
|
||||
{B85009CE-4A5C-4A5A-B85D-001B3A2651B2}.Release|x64.ActiveCfg = Release|x64
|
||||
{B85009CE-4A5C-4A5A-B85D-001B3A2651B2}.Release|x64.Build.0 = Release|x64
|
||||
{B85009CE-4A5C-4A5A-B85D-001B3A2651B2}.Release|x86.ActiveCfg = Release|Win32
|
||||
{B85009CE-4A5C-4A5A-B85D-001B3A2651B2}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {FAB9F592-7511-4EB9-B365-078842ED9BDD}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
29
src/Olympus/Olympus.filters
Normal file
29
src/Olympus/Olympus.filters
Normal file
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="src">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="inc">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>inc</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>inc</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
114
src/Olympus/Olympus.vcxproj
Normal file
114
src/Olympus/Olympus.vcxproj
Normal file
@@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\utils\utils.vcxproj">
|
||||
<Project>{b85009ce-4a5c-4a5a-b85d-001b3a2651b2}</Project>
|
||||
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{5f3fc91e-1fbc-4223-8011-9708de913474}</ProjectGuid>
|
||||
<RootNamespace>Olympus</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>Olympus</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg">
|
||||
<VcpkgAutoLink>true</VcpkgAutoLink>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS; _DEBUG;OLYMPUS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>include; ..\..\third-party\lua\include; ..\utils\include; ..\shared\include</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AssemblerOutput>AssemblyCode</AssemblerOutput>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>lua.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\third-party\lua</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS; NDEBUG;OLYMPUS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>include; ..\..\third-party\lua\include; ..\utils\include; ..\shared\include</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AssemblerOutput>NoListing</AssemblerOutput>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>lua.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\third-party\lua</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
16
src/Olympus/Olympus.vcxproj.filters
Normal file
16
src/Olympus/Olympus.vcxproj.filters
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{c021f649-26ec-4040-abd4-13132def4a81}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{2809fbbc-77d2-465e-afef-230525a60c66}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
159
src/Olympus/src/main.cpp
Normal file
159
src/Olympus/src/main.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
#include "framework.h"
|
||||
|
||||
#include "DCSUtils.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#define DllExport __declspec( dllexport )
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Run-time linking to core dll allows for "hot swap"*/
|
||||
HINSTANCE hGetProcIDDLL = NULL;
|
||||
typedef int(__stdcall* f_coreInit)(lua_State* L);
|
||||
typedef int(__stdcall* f_coreDeinit)(lua_State* L);
|
||||
typedef int(__stdcall* f_coreFrame)(lua_State* L);
|
||||
typedef int(__stdcall* f_coreMissionData)(lua_State* L);
|
||||
f_coreInit coreInit = nullptr;
|
||||
f_coreDeinit coreDeinit = nullptr;
|
||||
f_coreFrame coreFrame = nullptr;
|
||||
f_coreMissionData coreMissionData = nullptr;
|
||||
|
||||
static int onSimulationStart(lua_State* L)
|
||||
{
|
||||
LOGGER->Log("onSimulationStart callback called successfully");
|
||||
#ifdef _DEBUG
|
||||
LOGGER->Log("Loading Debug core.dll");
|
||||
hGetProcIDDLL = LoadLibrary(L"C:\\Users\\dpass\\Documents\\Olympus\\bin\\x64\\Debug\\core.dll");
|
||||
#else
|
||||
LOGGER->Log("Loading Release core.dll");
|
||||
hGetProcIDDLL = LoadLibrary(L"C:\\Users\\dpass\\Documents\\Olympus\\bin\\x64\\Release\\core.dll");
|
||||
#endif
|
||||
|
||||
if (!hGetProcIDDLL) {
|
||||
DCSUtils::LogError(L, "Error loading core DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
LOGGER->Log("Core DLL loaded successfully");
|
||||
|
||||
coreInit = (f_coreInit)GetProcAddress(hGetProcIDDLL, "coreInit");
|
||||
if (!coreInit)
|
||||
{
|
||||
DCSUtils::LogError(L, "Error getting coreInit ProcAddress from DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreDeinit = (f_coreDeinit)GetProcAddress(hGetProcIDDLL, "coreDeinit");
|
||||
if (!coreInit)
|
||||
{
|
||||
DCSUtils::LogError(L, "Error getting coreDeinit ProcAddress from DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreFrame = (f_coreFrame)GetProcAddress(hGetProcIDDLL, "coreFrame");
|
||||
if (!coreFrame)
|
||||
{
|
||||
DCSUtils::LogError(L, "Error getting coreFrame ProcAddress from DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreMissionData = (f_coreFrame)GetProcAddress(hGetProcIDDLL, "coreMissionData");
|
||||
if (!coreFrame)
|
||||
{
|
||||
DCSUtils::LogError(L, "Error getting coreMissionData ProcAddress from DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreInit(L);
|
||||
|
||||
DCSUtils::LogInfo(L, "Module loaded and started successfully.");
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
DCSUtils::LogError(L, "Error while loading module, see Olympus.log in temporary folder for additional details.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int onSimulationFrame(lua_State* L)
|
||||
{
|
||||
if (coreFrame)
|
||||
{
|
||||
coreFrame(L);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int onSimulationStop(lua_State* L)
|
||||
{
|
||||
LOGGER->Log("onSimulationStop callback called successfully");
|
||||
if (hGetProcIDDLL)
|
||||
{
|
||||
LOGGER->Log("Trying to unload core DLL");
|
||||
if (coreDeinit)
|
||||
{
|
||||
coreDeinit(L);
|
||||
}
|
||||
|
||||
if (FreeLibrary(hGetProcIDDLL))
|
||||
{
|
||||
LOGGER->Log("Core DLL unloaded successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
DCSUtils::LogError(L, "Error unloading DLL");
|
||||
goto error;
|
||||
}
|
||||
|
||||
coreInit = nullptr;
|
||||
coreDeinit = nullptr;
|
||||
coreFrame = nullptr;
|
||||
coreMissionData = nullptr;
|
||||
}
|
||||
|
||||
hGetProcIDDLL = NULL;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
DCSUtils::LogError(L, "Error while unloading module, see Olympus.log in temporary folder for additional details.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int setMissionData(lua_State* L)
|
||||
{
|
||||
if (coreMissionData)
|
||||
{
|
||||
coreMissionData(L);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const luaL_Reg Map[] = {
|
||||
{"onSimulationStart", onSimulationStart},
|
||||
{"onSimulationFrame", onSimulationFrame},
|
||||
{"onSimulationStop", onSimulationStop},
|
||||
{"setMissionData", setMissionData },
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
extern "C" DllExport int luaopen_Olympus(lua_State * L)
|
||||
{
|
||||
luaL_register(L, "Olympus", Map);
|
||||
return 1;
|
||||
}
|
||||
2
src/Olympus/src/pch.cpp
Normal file
2
src/Olympus/src/pch.cpp
Normal file
@@ -0,0 +1,2 @@
|
||||
#include "pch.h"
|
||||
|
||||
90
src/core/core.filters
Normal file
90
src/core/core.filters
Normal file
@@ -0,0 +1,90 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\Commands.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\DCSUtils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\defines.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\logger.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\LUAUtils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\RESTServer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\Scheduler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\Unit.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\UnitsHandler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\Utils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Utils.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\UnitsHandler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Unit.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Scheduler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\LUAUtils.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\logger.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\DCSUtils.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\Commands.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\RESTServer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
182
src/core/core.vcxproj
Normal file
182
src/core/core.vcxproj
Normal file
@@ -0,0 +1,182 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\Commands.h" />
|
||||
<ClInclude Include="include\LUAFunctions.h" />
|
||||
<ClInclude Include="include\RESTServer.h" />
|
||||
<ClInclude Include="include\Scheduler.h" />
|
||||
<ClInclude Include="include\Unit.h" />
|
||||
<ClInclude Include="include\UnitsHandler.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Commands.cpp" />
|
||||
<ClCompile Include="src\LUAFunctions.cpp" />
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
<ClCompile Include="src\RESTServer.cpp" />
|
||||
<ClCompile Include="src\Scheduler.cpp" />
|
||||
<ClCompile Include="src\Unit.cpp" />
|
||||
<ClCompile Include="src\UnitsHandler.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\utils\utils.vcxproj">
|
||||
<Project>{b85009ce-4a5c-4a5a-b85d-001b3a2651b2}</Project>
|
||||
<LinkLibraryDependencies>true</LinkLibraryDependencies>
|
||||
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{8a48d855-0e01-42ba-bd8c-07b0877c68df}</ProjectGuid>
|
||||
<RootNamespace>core</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;OLYMPUSCORE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;OLYMPUSCORE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;CORE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>include; ..\..\third-party\lua\include; ..\utils\include; ..\shared\include</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>lua.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\third-party\lua</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;CORE_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>include; ..\..\third-party\lua\include; ..\utils\include; ..\shared\include</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>lua.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\third-party\lua</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
54
src/core/core.vcxproj.filters
Normal file
54
src/core/core.vcxproj.filters
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{cc40b2d0-5e40-4a2b-bfc7-df3aef133737}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{1be98bb1-2aa0-40b5-bac9-3d073e079771}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\Commands.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\RESTServer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Scheduler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Unit.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\UnitsHandler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\LUAFunctions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Commands.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RESTServer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Scheduler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Unit.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\UnitsHandler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\LUAFunctions.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
37
src/core/include/Commands.h
Normal file
37
src/core/include/Commands.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
#include "LUAUtils.h"
|
||||
#include "Utils.h"
|
||||
|
||||
namespace CommandPriority {
|
||||
enum CommandPriorities { LOW, MEDIUM, HIGH };
|
||||
};
|
||||
|
||||
namespace CommandType {
|
||||
enum CommandTypes { NO_TYPE, MOVE };
|
||||
};
|
||||
|
||||
/* Base command class */
|
||||
class Command
|
||||
{
|
||||
public:
|
||||
int getPriority() { return priority; }
|
||||
int getType() { return type; }
|
||||
virtual void execute(lua_State* L) {};
|
||||
|
||||
protected:
|
||||
int priority = CommandPriority::LOW;
|
||||
int type = CommandType::NO_TYPE;
|
||||
};
|
||||
|
||||
/* Simple low priority move command (from user click) */
|
||||
class MoveCommand : public Command
|
||||
{
|
||||
public:
|
||||
MoveCommand(int ID, wstring unitName, Coords destination) : ID(ID), unitName(unitName), destination(destination) { priority = CommandPriority::LOW; type = CommandType::MOVE; };
|
||||
virtual void execute(lua_State* L);
|
||||
|
||||
private:
|
||||
const int ID;
|
||||
const wstring unitName;
|
||||
const Coords destination;
|
||||
};
|
||||
7
src/core/include/LUAFunctions.h
Normal file
7
src/core/include/LUAFunctions.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
namespace LUAFunctions
|
||||
{
|
||||
void registerLuaFunctions(lua_State* L);
|
||||
}
|
||||
29
src/core/include/RESTServer.h
Normal file
29
src/core/include/RESTServer.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "LUAUtils.h"
|
||||
|
||||
using namespace web::http;
|
||||
using namespace web::http::experimental::listener;
|
||||
|
||||
class UnitsHandler;
|
||||
class Scheduler;
|
||||
|
||||
class RESTServer
|
||||
{
|
||||
public:
|
||||
RESTServer(lua_State* L);
|
||||
~RESTServer();
|
||||
|
||||
private:
|
||||
std::thread* serverThread;
|
||||
|
||||
void handle_options(http_request request);
|
||||
void handle_get(http_request request);
|
||||
void handle_request(http_request request, function<void(json::value const&, json::value&)> action);
|
||||
void handle_put(http_request request);
|
||||
|
||||
void task();
|
||||
|
||||
atomic<bool> runListener;
|
||||
};
|
||||
|
||||
20
src/core/include/Scheduler.h
Normal file
20
src/core/include/Scheduler.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
#include "LUAUtils.h"
|
||||
#include "framework.h"
|
||||
#include "Commands.h"
|
||||
|
||||
class Scheduler
|
||||
{
|
||||
public:
|
||||
Scheduler(lua_State* L);
|
||||
~Scheduler();
|
||||
|
||||
void appendCommand(Command* command);
|
||||
void execute(lua_State* L);
|
||||
void handleRequest(wstring key, json::value value);
|
||||
|
||||
private:
|
||||
list<Command*> commands;
|
||||
mutex lock;
|
||||
};
|
||||
|
||||
50
src/core/include/Unit.h
Normal file
50
src/core/include/Unit.h
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include "Utils.h"
|
||||
#include "DCSUtils.h"
|
||||
#include "LUAUtils.h"
|
||||
#include "framework.h"
|
||||
|
||||
class Unit
|
||||
{
|
||||
public:
|
||||
Unit(json::value json, int ID);
|
||||
~Unit();
|
||||
|
||||
void update(json::value json);
|
||||
|
||||
void setPath(list<Coords> path);
|
||||
|
||||
int getID() { return ID; }
|
||||
wstring getName() { return name; }
|
||||
wstring getUnitName() { return unitName; }
|
||||
wstring getGroupName() { return groupName; }
|
||||
int getType() { return type; }
|
||||
wstring getCountry() { return country; }
|
||||
int getCoalitionID() { return coalitionID; }
|
||||
double getLatitude() { return latitude; }
|
||||
double getLongitude() { return longitude; }
|
||||
double getAltitude() { return altitude; }
|
||||
double getHeading() { return heading; }
|
||||
|
||||
json::value json();
|
||||
|
||||
protected:
|
||||
int ID;
|
||||
wstring name = L"undefined";
|
||||
wstring unitName = L"undefined";
|
||||
wstring groupName = L"undefined";
|
||||
int type = 0;
|
||||
wstring country = L"undefined";
|
||||
int coalitionID = 0;
|
||||
double latitude = 0;
|
||||
double longitude = 0;
|
||||
double altitude = 0;
|
||||
double heading = 0;
|
||||
|
||||
list<Coords> activePath;
|
||||
Coords activeDestination;
|
||||
|
||||
private:
|
||||
virtual void AIloop();
|
||||
};
|
||||
|
||||
23
src/core/include/UnitsHandler.h
Normal file
23
src/core/include/UnitsHandler.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "DCSUtils.h"
|
||||
|
||||
class Unit;
|
||||
|
||||
class UnitsHandler
|
||||
{
|
||||
public:
|
||||
UnitsHandler(lua_State* L);
|
||||
~UnitsHandler();
|
||||
|
||||
Unit* getUnit(int ID);
|
||||
void getMissionDB(lua_State* L);
|
||||
void update(lua_State* L);
|
||||
void updateAnswer(json::value& answer);
|
||||
|
||||
private:
|
||||
map<int, Unit*> units;
|
||||
json::value missionDB;
|
||||
|
||||
};
|
||||
|
||||
23
src/core/src/Commands.cpp
Normal file
23
src/core/src/Commands.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "Commands.h"
|
||||
#include "framework.h"
|
||||
#include "Logger.h"
|
||||
|
||||
void MoveCommand::execute(lua_State* L)
|
||||
{
|
||||
std::ostringstream command;
|
||||
|
||||
command << "Olympus.move(\"" << Utils::to_string(unitName) << "\"," << destination.lat << "," << destination.lng << "," << 10 << ")";
|
||||
|
||||
lua_getglobal(L, "net");
|
||||
lua_getfield(L, -1, "dostring_in");
|
||||
lua_pushstring(L, "server");
|
||||
lua_pushstring(L, command.str().c_str());
|
||||
if (lua_pcall(L, 2, 0, 0) != 0)
|
||||
{
|
||||
LOGGER->Log("Error executing MoveCommand");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER->Log("MoveCommand executed successfully");
|
||||
}
|
||||
}
|
||||
28
src/core/src/LUAFunctions.cpp
Normal file
28
src/core/src/LUAFunctions.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include "LUAFunctions.h"
|
||||
#include "Logger.h"
|
||||
|
||||
void LUAFunctions::registerLuaFunctions(lua_State* L)
|
||||
{
|
||||
ifstream f("C:\\Users\\dpass\\Documents\\Olympus\\scripts\\OlympusCommand.lua");
|
||||
string str;
|
||||
if (f) {
|
||||
ostringstream ss;
|
||||
ss << f.rdbuf();
|
||||
str = ss.str();
|
||||
}
|
||||
|
||||
lua_getglobal(L, "net");
|
||||
lua_getfield(L, -1, "dostring_in");
|
||||
lua_pushstring(L, "server");
|
||||
lua_pushstring(L, str.c_str());
|
||||
|
||||
if (lua_pcall(L, 2, 0, 0) != 0)
|
||||
{
|
||||
LOGGER->Log("Error registering LUA functions");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER->Log("Lua functions registered successfully");
|
||||
}
|
||||
|
||||
}
|
||||
130
src/core/src/RESTServer.cpp
Normal file
130
src/core/src/RESTServer.cpp
Normal file
@@ -0,0 +1,130 @@
|
||||
#include "RESTServer.h"
|
||||
#include "Logger.h"
|
||||
#include "defines.h"
|
||||
#include "UnitsHandler.h"
|
||||
#include "Scheduler.h"
|
||||
#include "LUAUtils.h"
|
||||
|
||||
extern UnitsHandler* unitsHandler;
|
||||
extern Scheduler* scheduler;
|
||||
extern json::value missionData;
|
||||
|
||||
RESTServer::RESTServer(lua_State* L):
|
||||
runListener(true)
|
||||
{
|
||||
DCSUtils::LogInfo(L, "Starting RESTServer");
|
||||
serverThread = new thread(&RESTServer::task, this);
|
||||
}
|
||||
|
||||
RESTServer::~RESTServer()
|
||||
{
|
||||
runListener = false;
|
||||
}
|
||||
|
||||
void RESTServer::handle_options(http_request request)
|
||||
{
|
||||
http_response response(status_codes::OK);
|
||||
response.headers().add(U("Allow"), U("GET, POST, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Origin"), U("*"));
|
||||
response.headers().add(U("Access-Control-Allow-Methods"), U("GET, POST, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Headers"), U("Content-Type"));
|
||||
|
||||
request.reply(response);
|
||||
}
|
||||
|
||||
void RESTServer::handle_get(http_request request)
|
||||
{
|
||||
http_response response(status_codes::OK);
|
||||
response.headers().add(U("Allow"), U("GET, POST, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Origin"), U("*"));
|
||||
response.headers().add(U("Access-Control-Allow-Methods"), U("GET, POST, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Headers"), U("Content-Type"));
|
||||
|
||||
auto answer = json::value::object();
|
||||
try
|
||||
{
|
||||
unitsHandler->updateAnswer(answer);
|
||||
answer[L"missionData"] = missionData;
|
||||
}
|
||||
catch (http_exception const& e)
|
||||
{
|
||||
LOGGER->Log(e.what());
|
||||
}
|
||||
response.set_body(answer);
|
||||
|
||||
request.reply(response);
|
||||
}
|
||||
|
||||
void RESTServer::handle_request(http_request request, function<void(json::value const&, json::value&)> action)
|
||||
{
|
||||
auto answer = json::value::object();
|
||||
|
||||
request.extract_json().then([&answer, &action](pplx::task<json::value> task)
|
||||
{
|
||||
try
|
||||
{
|
||||
auto const& jvalue = task.get();
|
||||
|
||||
if (!jvalue.is_null())
|
||||
{
|
||||
action(jvalue, answer);
|
||||
}
|
||||
}
|
||||
catch (http_exception const& e)
|
||||
{
|
||||
LOGGER->Log(e.what());
|
||||
}
|
||||
}).wait();
|
||||
|
||||
http_response response(status_codes::OK);
|
||||
response.headers().add(U("Allow"), U("GET, POST, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Origin"), U("*"));
|
||||
response.headers().add(U("Access-Control-Allow-Methods"), U("GET, POST, PUT, OPTIONS"));
|
||||
response.headers().add(U("Access-Control-Allow-Headers"), U("Content-Type"));
|
||||
response.set_body(answer);
|
||||
request.reply(response);
|
||||
}
|
||||
|
||||
void RESTServer::handle_put(http_request request)
|
||||
{
|
||||
handle_request(
|
||||
request,
|
||||
[](json::value const& jvalue, json::value& answer)
|
||||
{
|
||||
for (auto const& e : jvalue.as_object())
|
||||
{
|
||||
auto key = e.first;
|
||||
auto value = e.second;
|
||||
scheduler->handleRequest(key, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void RESTServer::task()
|
||||
{
|
||||
http_listener listener(REST_ADDRESS);
|
||||
|
||||
std::function<void(http_request)> handle_options = std::bind(&RESTServer::handle_options, this, std::placeholders::_1);
|
||||
std::function<void(http_request)> handle_get = std::bind(&RESTServer::handle_get, this, std::placeholders::_1);
|
||||
std::function<void(http_request)> handle_put = std::bind(&RESTServer::handle_put, this, std::placeholders::_1);
|
||||
|
||||
listener.support(methods::OPTIONS, handle_options);
|
||||
listener.support(methods::GET, handle_get);
|
||||
listener.support(methods::PUT, handle_put);
|
||||
|
||||
try
|
||||
{
|
||||
listener.open()
|
||||
.then([&listener]() {LOGGER->Log("RESTServer starting to listen"); })
|
||||
.wait();
|
||||
|
||||
while (runListener);
|
||||
|
||||
listener.close();
|
||||
LOGGER->Log("RESTServer stopped listening");
|
||||
}
|
||||
catch (exception const& e)
|
||||
{
|
||||
LOGGER->Log(e.what());
|
||||
}
|
||||
}
|
||||
100
src/core/src/Scheduler.cpp
Normal file
100
src/core/src/Scheduler.cpp
Normal file
@@ -0,0 +1,100 @@
|
||||
#include "Scheduler.h"
|
||||
#include "Logger.h"
|
||||
#include "DCSUtils.h"
|
||||
#include "UnitsHandler.h"
|
||||
#include "Utils.h"
|
||||
#include "Unit.h"
|
||||
|
||||
extern UnitsHandler* unitsHandler;
|
||||
|
||||
Scheduler::Scheduler(lua_State* L)
|
||||
{
|
||||
DCSUtils::LogInfo(L, "Units Factory constructor called successfully");
|
||||
}
|
||||
|
||||
Scheduler::~Scheduler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Scheduler::appendCommand(Command* command)
|
||||
{
|
||||
commands.push_back(command);
|
||||
}
|
||||
|
||||
void Scheduler::execute(lua_State* L)
|
||||
{
|
||||
lock.lock();
|
||||
int priority = CommandPriority::HIGH;
|
||||
while (priority >= CommandPriority::LOW)
|
||||
{
|
||||
for (auto command : commands)
|
||||
{
|
||||
if (command->getPriority() == priority)
|
||||
{
|
||||
LOGGER->Log("Executing command");
|
||||
switch (command->getType())
|
||||
{
|
||||
case CommandType::MOVE:
|
||||
{
|
||||
MoveCommand* moveCommand = dynamic_cast<MoveCommand*>(command);
|
||||
moveCommand->execute(L);
|
||||
commands.remove(command);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
priority--;
|
||||
}
|
||||
|
||||
exit:
|
||||
lock.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void Scheduler::handleRequest(wstring key, json::value value)
|
||||
{
|
||||
lock.lock();
|
||||
Command* command = nullptr;
|
||||
|
||||
LOGGER->Log(L"Received request with ID: " + key);
|
||||
if (key.compare(L"setPath") == 0)
|
||||
{
|
||||
int ID = value[L"ID"].as_integer();
|
||||
wstring unitName = value[L"unitName"].as_string();
|
||||
LOGGER->Log(unitName);
|
||||
json::value path = value[L"path"];
|
||||
list<Coords> newPath;
|
||||
for (auto const& e : path.as_object())
|
||||
{
|
||||
wstring WP = e.first;
|
||||
double lat = path[WP][L"lat"].as_double();
|
||||
double lng = path[WP][L"lng"].as_double();
|
||||
LOGGER->Log(unitName + L" set path destination " + WP + L" (" + to_wstring(lat) + L", " + to_wstring(lng) + L")");
|
||||
Coords dest; dest.lat = lat; dest.lng = lng;
|
||||
newPath.push_back(dest);
|
||||
Unit* unit = unitsHandler->getUnit(ID);
|
||||
if (unit != nullptr)
|
||||
{
|
||||
unit->setPath(newPath);
|
||||
LOGGER->Log(unitName + L" new path set successfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER->Log(unitName + L" not found, request will be discarded");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (command != nullptr)
|
||||
{
|
||||
appendCommand(command);
|
||||
}
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
88
src/core/src/Unit.cpp
Normal file
88
src/core/src/Unit.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#include "Unit.h"
|
||||
#include "Utils.h"
|
||||
#include "Logger.h"
|
||||
#include "Commands.h"
|
||||
#include "Scheduler.h"
|
||||
|
||||
extern Scheduler* scheduler;
|
||||
|
||||
Unit::Unit(json::value json, int ID) :
|
||||
ID(ID)
|
||||
{
|
||||
LOGGER->Log("Creating unit with ID: " + to_string(ID));
|
||||
update(json);
|
||||
}
|
||||
|
||||
Unit::~Unit()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Unit::update(json::value json)
|
||||
{
|
||||
name = json[L"Name"].as_string();
|
||||
unitName = json[L"UnitName"].as_string();
|
||||
groupName = json[L"GroupName"].as_string();
|
||||
//type = json[L"Type"].as_number().to_int32();
|
||||
//country = json[L"Country"].as_string();
|
||||
//coalitionID = json[L"CoalitionID"].as_number().to_int32();
|
||||
latitude = json[L"LatLongAlt"][L"Lat"].as_number().to_double();
|
||||
longitude = json[L"LatLongAlt"][L"Long"].as_number().to_double();
|
||||
altitude = json[L"LatLongAlt"][L"Alt"].as_number().to_double();
|
||||
heading = json[L"Heading"].as_number().to_double();
|
||||
|
||||
AIloop();
|
||||
}
|
||||
|
||||
void Unit::setPath(list<Coords> path)
|
||||
{
|
||||
activePath = path;
|
||||
}
|
||||
|
||||
void Unit::AIloop()
|
||||
{
|
||||
if (activePath.size() > 0)
|
||||
{
|
||||
if (activeDestination != activePath.front())
|
||||
{
|
||||
activeDestination = activePath.front();
|
||||
Command* command = dynamic_cast<Command*>(new MoveCommand(ID, unitName, activeDestination));
|
||||
scheduler->appendCommand(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
json::value Unit::json()
|
||||
{
|
||||
auto json = json::value::object();
|
||||
|
||||
json[L"name"] = json::value::string(name);
|
||||
json[L"unitName"] = json::value::string(unitName);
|
||||
json[L"groupName"] = json::value::string(groupName);
|
||||
//json[L"type"] = type;
|
||||
//json[L"country"] = json::value::string(country);
|
||||
json[L"coalitionID"] = type;
|
||||
json[L"latitude"] = latitude;
|
||||
json[L"longitude"] = longitude;
|
||||
json[L"altitude"] = altitude;
|
||||
json[L"heading"] = heading;
|
||||
|
||||
/* Send the active path as a json object */
|
||||
if (activePath.size() > 0) {
|
||||
auto path = json::value::object();
|
||||
int count = 1;
|
||||
for (auto& destination : activePath)
|
||||
{
|
||||
auto json = json::value::object();
|
||||
json[L"lat"] = destination.lat;
|
||||
json[L"lng"] = destination.lng;
|
||||
json[L"alt"] = destination.alt;
|
||||
path[to_wstring(count++)] = json;
|
||||
}
|
||||
json[L"activePath"] = path;
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
59
src/core/src/UnitsHandler.cpp
Normal file
59
src/core/src/UnitsHandler.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include "UnitsHandler.h"
|
||||
#include "Logger.h"
|
||||
#include "Unit.h"
|
||||
#include "framework.h"
|
||||
#include "Utils.h"
|
||||
|
||||
UnitsHandler::UnitsHandler(lua_State* L)
|
||||
{
|
||||
DCSUtils::LogInfo(L, "Units Factory constructor called successfully");
|
||||
}
|
||||
|
||||
UnitsHandler::~UnitsHandler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Unit* UnitsHandler::getUnit(int ID)
|
||||
{
|
||||
if (units.find(ID) == units.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
return units[ID];
|
||||
}
|
||||
}
|
||||
|
||||
void UnitsHandler::update(lua_State* L)
|
||||
{
|
||||
//lua_getglobal(L, "net");
|
||||
//lua_getfield(L, -1, "dostring_in");
|
||||
//lua_pushstring(L, "server");
|
||||
//lua_pushstring(L, "dostring_in(\"export\", \"Olympus.OlympusDLL.test()\")");
|
||||
//lua_pcall(L, 2, 0, 0);
|
||||
|
||||
map<int, json::value> unitJSONs = DCSUtils::getAllUnits(L);
|
||||
|
||||
for (auto const& p : unitJSONs)
|
||||
{
|
||||
int ID = p.first;
|
||||
if (units.count(ID) == 0)
|
||||
{
|
||||
units[ID] = new Unit(p.second, ID);
|
||||
}
|
||||
units[ID]->update(p.second);
|
||||
}
|
||||
}
|
||||
|
||||
void UnitsHandler::updateAnswer(json::value& answer)
|
||||
{
|
||||
// TODO THREAT SAFEY!
|
||||
auto unitsJson = json::value::object();
|
||||
|
||||
for (auto const& p : units)
|
||||
{
|
||||
unitsJson[to_wstring(p.first)] = p.second->json();
|
||||
}
|
||||
|
||||
answer[L"units"] = unitsJson;
|
||||
}
|
||||
88
src/core/src/main.cpp
Normal file
88
src/core/src/main.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
#include "framework.h"
|
||||
#include "DCSUtils.h"
|
||||
#include "Logger.h"
|
||||
#include "defines.h"
|
||||
#include "UnitsHandler.h"
|
||||
#include "RESTServer.h"
|
||||
#include "Scheduler.h"
|
||||
#include "LUAFunctions.h"
|
||||
|
||||
|
||||
auto before = std::chrono::system_clock::now();
|
||||
UnitsHandler* unitsHandler = nullptr;
|
||||
RESTServer* restserver = nullptr;
|
||||
Scheduler* scheduler = nullptr;
|
||||
json::value missionData;
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#define DllExport __declspec( dllexport )
|
||||
|
||||
extern "C" DllExport int coreDeinit(lua_State* L)
|
||||
{
|
||||
LOGGER->Log("Olympus coreDeinit called successfully");
|
||||
|
||||
delete unitsHandler;
|
||||
delete restserver;
|
||||
delete scheduler;
|
||||
|
||||
LOGGER->Log("All singletons objects destroyed successfully");
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
extern "C" DllExport int coreInit(lua_State* L)
|
||||
{
|
||||
unitsHandler = new UnitsHandler(L);
|
||||
restserver = new RESTServer(L);
|
||||
scheduler = new Scheduler(L);
|
||||
|
||||
LUAFunctions::registerLuaFunctions(L);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
extern "C" DllExport int coreFrame(lua_State* L)
|
||||
{
|
||||
const std::chrono::duration<double> duration = std::chrono::system_clock::now() - before;
|
||||
|
||||
// TODO make intervals editable
|
||||
if (duration.count() > UPDATE_TIME_INTERVAL)
|
||||
{
|
||||
if (unitsHandler != nullptr)
|
||||
{
|
||||
unitsHandler->update(L);
|
||||
}
|
||||
|
||||
// TODO allow for different intervals
|
||||
if (scheduler != nullptr)
|
||||
{
|
||||
scheduler->execute(L);
|
||||
}
|
||||
before = std::chrono::system_clock::now();
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
extern "C" DllExport int coreMissionData(lua_State * L)
|
||||
{
|
||||
lua_getglobal(L, "Olympus");
|
||||
lua_getfield(L, -1, "missionData");
|
||||
missionData = LUAUtils::tableToJSON(L, -1);
|
||||
|
||||
return(0);
|
||||
}
|
||||
7
src/shared/include/defines.h
Normal file
7
src/shared/include/defines.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#define VERSION "v0.0.1"
|
||||
#define LOG_NAME "Olympus_log.txt"
|
||||
#define REST_ADDRESS L"http://localhost:30000/restdemo"
|
||||
|
||||
#define UPDATE_TIME_INTERVAL 0.25
|
||||
33
src/shared/include/framework.h
Normal file
33
src/shared/include/framework.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#define DllExport __declspec( dllexport )
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files
|
||||
#include <windows.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <time.h>
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <cstdarg>
|
||||
#include <filesystem>
|
||||
#include <codecvt>
|
||||
#include <cpprest/http_listener.h>
|
||||
#include <cpprest/json.h>
|
||||
#include <set>
|
||||
|
||||
using namespace std;
|
||||
using namespace web;
|
||||
|
||||
extern "C" {
|
||||
#include "lua.h"
|
||||
#include "lualib.h"
|
||||
#include "luaconf.h"
|
||||
#include "lauxlib.h"
|
||||
}
|
||||
13
src/utils/include/DCSUtils.h
Normal file
13
src/utils/include/DCSUtils.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
#include "LUAUtils.h"
|
||||
|
||||
namespace DCSUtils
|
||||
{
|
||||
void LogInfo(lua_State* L, string message);
|
||||
void LogWarning(lua_State* L, string message);
|
||||
void LogError(lua_State* L, string message);
|
||||
void Log(lua_State* L, string message, int level);
|
||||
|
||||
map<int, json::value> getAllUnits(lua_State* L);
|
||||
}
|
||||
15
src/utils/include/LUAUtils.h
Normal file
15
src/utils/include/LUAUtils.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
namespace LUAUtils
|
||||
{
|
||||
void stackUpdate(lua_State* L, int& stackDepth, int initialStack = 0);
|
||||
void stackPop(lua_State* L, int popDepth = 1);
|
||||
void stackClean(lua_State* L, int stackDepth);
|
||||
json::value tableToJSON(lua_State* L, int index);
|
||||
}
|
||||
|
||||
#define STACK_UPDATE LUAUtils::stackUpdate(L, stackDepth, initialStack);
|
||||
#define STACK_INIT int stackDepth = 0; int initialStack = 0; LUAUtils::stackUpdate(L, initialStack);
|
||||
#define STACK_POP(X) LUAUtils::stackPop(L, X); STACK_UPDATE;
|
||||
#define STACK_CLEAN STACK_UPDATE; LUAUtils::stackClean(L, stackDepth);
|
||||
26
src/utils/include/Logger.h
Normal file
26
src/utils/include/Logger.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
#define LOGGER Logger::GetLogger()
|
||||
class Logger
|
||||
{
|
||||
public:
|
||||
void Log(const std::string& sMessage);
|
||||
void Log(const std::wstring& sMessage);
|
||||
void Log(const char* format, ...);
|
||||
|
||||
Logger& operator<<(const string& sMessage);
|
||||
|
||||
static Logger* GetLogger();
|
||||
private:
|
||||
Logger();
|
||||
Logger(const Logger&) {}; // copy constructor is private
|
||||
Logger& operator=(const Logger&) { return *this; }; // assignment operator is private
|
||||
|
||||
static const std::string m_sFileName;
|
||||
static Logger* m_pThis;
|
||||
static ofstream m_Logfile;
|
||||
|
||||
void Open();
|
||||
void Close();
|
||||
};
|
||||
21
src/utils/include/Utils.h
Normal file
21
src/utils/include/Utils.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include "framework.h"
|
||||
|
||||
struct Coords {
|
||||
double lat = 0;
|
||||
double lng = 0;
|
||||
double alt = 0;
|
||||
};
|
||||
|
||||
bool operator== (const Coords& a, const Coords& b);
|
||||
bool operator!= (const Coords& a, const Coords& b);
|
||||
bool operator== (const Coords& a, const int& b);
|
||||
bool operator!= (const Coords& a, const int& b);
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
// Get current date/time, format is YYYY-MM-DD.HH:mm:ss
|
||||
const std::string CurrentDateTime();
|
||||
std::wstring to_wstring(const std::string& str);
|
||||
std::string to_string(const std::wstring& wstr);
|
||||
}
|
||||
96
src/utils/src/DCSUtils.cpp
Normal file
96
src/utils/src/DCSUtils.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
#include "DCSUtils.h"
|
||||
#include "Logger.h"
|
||||
|
||||
void DCSUtils::LogInfo(lua_State* L, string message)
|
||||
{
|
||||
STACK_INIT;
|
||||
|
||||
lua_getglobal(L, "log");
|
||||
lua_getfield(L, -1, "INFO");
|
||||
int infoLevel = (int) lua_tointeger(L, -1);
|
||||
STACK_POP(1);
|
||||
|
||||
STACK_CLEAN;
|
||||
|
||||
DCSUtils::Log(L, message, infoLevel);
|
||||
}
|
||||
|
||||
void DCSUtils::LogWarning(lua_State* L, string message)
|
||||
{
|
||||
STACK_INIT;
|
||||
|
||||
lua_getglobal(L, "log");
|
||||
lua_getfield(L, -1, "WARNING");
|
||||
int warningLevel = (int)lua_tointeger(L, -1);
|
||||
STACK_POP(1);
|
||||
|
||||
STACK_CLEAN;
|
||||
|
||||
DCSUtils::Log(L, message, warningLevel);
|
||||
}
|
||||
|
||||
void DCSUtils::LogError(lua_State* L, string message)
|
||||
{
|
||||
STACK_INIT;
|
||||
|
||||
lua_getglobal(L, "log");
|
||||
lua_getfield(L, -1, "ERROR");
|
||||
int errorLevel = (int)lua_tointeger(L, -1);
|
||||
STACK_POP(1);
|
||||
|
||||
STACK_CLEAN;
|
||||
|
||||
DCSUtils::Log(L, message, errorLevel);
|
||||
}
|
||||
|
||||
void DCSUtils::Log(lua_State* L, string message, int level)
|
||||
{
|
||||
STACK_INIT;
|
||||
|
||||
lua_getglobal(L, "log");
|
||||
lua_getfield(L, -1, "write");
|
||||
lua_pushstring(L, "Olympus.dll");
|
||||
lua_pushnumber(L, level);
|
||||
lua_pushstring(L, message.c_str());
|
||||
lua_pcall(L, 3, 0, 0);
|
||||
|
||||
STACK_CLEAN;
|
||||
}
|
||||
|
||||
map<int, json::value> DCSUtils::getAllUnits(lua_State* L)
|
||||
{
|
||||
int res = 0;
|
||||
map<int, json::value> units;
|
||||
|
||||
STACK_INIT;
|
||||
|
||||
lua_getglobal(L, "Export");
|
||||
lua_getfield(L, -1, "LoGetWorldObjects");
|
||||
res = lua_pcall(L, 0, 1, 0);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
DCSUtils::LogError(L, "Error retrieving World Objects");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!lua_istable(L, 2))
|
||||
{
|
||||
DCSUtils::LogError(L, "Error retrieving World Objects");
|
||||
goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, 2) != 0)
|
||||
{
|
||||
int ID = lua_tonumber(L, -2);
|
||||
units[ID] = LUAUtils::tableToJSON(L, -1);
|
||||
STACK_POP(1)
|
||||
}
|
||||
}
|
||||
|
||||
exit:
|
||||
STACK_CLEAN;
|
||||
return units;
|
||||
}
|
||||
57
src/utils/src/LUAUtils.cpp
Normal file
57
src/utils/src/LUAUtils.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "LUAUtils.h"
|
||||
#include "Logger.h"
|
||||
#include "Utils.h"
|
||||
|
||||
void LUAUtils::stackUpdate(lua_State* L, int& stackDepth, int initialStack)
|
||||
{
|
||||
stackDepth = lua_gettop(L) - initialStack;
|
||||
}
|
||||
|
||||
void LUAUtils::stackPop(lua_State* L, int popDepth)
|
||||
{
|
||||
lua_pop(L, popDepth);
|
||||
}
|
||||
|
||||
void LUAUtils::stackClean(lua_State* L, int stackDepth)
|
||||
{
|
||||
lua_pop(L, stackDepth);
|
||||
}
|
||||
|
||||
json::value LUAUtils::tableToJSON(lua_State* L, int index)
|
||||
{
|
||||
auto json = json::value::object();
|
||||
|
||||
if (lua_istable(L, index))
|
||||
{
|
||||
STACK_INIT;
|
||||
|
||||
lua_pushvalue(L, index);
|
||||
lua_pushnil(L);
|
||||
while (lua_next(L, -2))
|
||||
{
|
||||
lua_pushvalue(L, -2);
|
||||
const char* key = lua_tostring(L, -1);
|
||||
if (lua_istable(L, -2))
|
||||
{
|
||||
json[Utils::to_wstring(key)] = tableToJSON(L, -2);
|
||||
}
|
||||
else if (lua_isnumber(L, -2))
|
||||
{
|
||||
json[Utils::to_wstring(key)] = json::value::number(lua_tonumber(L, -2));
|
||||
}
|
||||
else if (lua_isboolean(L, -2))
|
||||
{
|
||||
json[Utils::to_wstring(key)] = json::value::boolean(lua_toboolean(L, -2));
|
||||
}
|
||||
else if (lua_isstring(L, -2)) // Keep last, only checks if it can be stringified
|
||||
{
|
||||
json[Utils::to_wstring(key)] = json::value::string(Utils::to_wstring(lua_tostring(L, -2)));
|
||||
}
|
||||
lua_pop(L, 2);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
STACK_CLEAN;
|
||||
}
|
||||
return json;
|
||||
}
|
||||
79
src/utils/src/Logger.cpp
Normal file
79
src/utils/src/Logger.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
#include "Logger.h"
|
||||
#include "Utils.h"
|
||||
#include "defines.h"
|
||||
|
||||
const string Logger::m_sFileName = LOG_NAME;
|
||||
Logger* Logger::m_pThis = NULL;
|
||||
ofstream Logger::m_Logfile;
|
||||
|
||||
Logger::Logger()
|
||||
{
|
||||
|
||||
}
|
||||
Logger* Logger::GetLogger()
|
||||
{
|
||||
if (m_pThis == NULL) {
|
||||
m_pThis = new Logger();
|
||||
std::filesystem::path dirPath = std::filesystem::temp_directory_path();
|
||||
m_Logfile.open((dirPath.string() + m_sFileName).c_str(), ios::out | ios::app);
|
||||
m_pThis->Log("**************************************************");
|
||||
}
|
||||
return m_pThis;
|
||||
}
|
||||
|
||||
void Logger::Open()
|
||||
{
|
||||
std::filesystem::path dirPath = std::filesystem::temp_directory_path();
|
||||
m_Logfile.open((dirPath.string() + m_sFileName).c_str(), ios::out | ios::app);
|
||||
}
|
||||
|
||||
void Logger::Close()
|
||||
{
|
||||
m_Logfile.close();
|
||||
}
|
||||
|
||||
void Logger::Log(const char* format, ...)
|
||||
{
|
||||
Open();
|
||||
char* sMessage = NULL;
|
||||
int nLength = 0;
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
// Return the number of characters in the string referenced the list of arguments.
|
||||
// _vscprintf doesn't count terminating '\0' (that's why +1)
|
||||
nLength = _vscprintf(format, args) + 1;
|
||||
sMessage = new char[nLength];
|
||||
vsprintf_s(sMessage, nLength, format, args);
|
||||
//vsprintf(sMessage, format, args);
|
||||
m_Logfile << Utils::CurrentDateTime() << ":\t";
|
||||
m_Logfile << sMessage << "\n";
|
||||
va_end(args);
|
||||
Close();
|
||||
|
||||
delete[] sMessage;
|
||||
}
|
||||
|
||||
void Logger::Log(const string& sMessage)
|
||||
{
|
||||
Open();
|
||||
m_Logfile << Utils::CurrentDateTime() << ":\t";
|
||||
m_Logfile << sMessage << "\n";
|
||||
Close();
|
||||
}
|
||||
|
||||
void Logger::Log(const wstring& sMessage)
|
||||
{
|
||||
Open();
|
||||
m_Logfile << Utils::CurrentDateTime() << ":\t";
|
||||
m_Logfile << Utils::to_string(sMessage) << "\n";
|
||||
Close();
|
||||
}
|
||||
|
||||
Logger& Logger::operator<<(const string& sMessage)
|
||||
{
|
||||
Open();
|
||||
m_Logfile << "\n" << Utils::CurrentDateTime() << ":\t";
|
||||
m_Logfile << sMessage << "\n";
|
||||
return *this;
|
||||
Close();
|
||||
}
|
||||
44
src/utils/src/Utils.cpp
Normal file
44
src/utils/src/Utils.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include "framework.h"
|
||||
#include "Utils.h"
|
||||
|
||||
// Get current date/time, format is YYYY-MM-DD.HH:mm:ss
|
||||
const std::string Utils::CurrentDateTime()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
struct tm tstruct;
|
||||
char buf[80];
|
||||
localtime_s(&tstruct, &now);
|
||||
strftime(buf, sizeof(buf), "%Y-%m-%d.%X", &tstruct);
|
||||
return buf;
|
||||
}
|
||||
|
||||
std::wstring Utils::to_wstring(const std::string& str)
|
||||
{
|
||||
int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
|
||||
std::wstring wstrTo(size_needed, 0);
|
||||
MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
|
||||
return wstrTo;
|
||||
}
|
||||
|
||||
std::string Utils::to_string(const std::wstring& wstr)
|
||||
{
|
||||
if (wstr.empty())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
const auto size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr.at(0), (int)wstr.size(), nullptr, 0, nullptr, nullptr);
|
||||
if (size_needed <= 0)
|
||||
{
|
||||
throw std::runtime_error("WideCharToMultiByte() failed: " + std::to_string(size_needed));
|
||||
}
|
||||
|
||||
std::string result(size_needed, 0);
|
||||
WideCharToMultiByte(CP_UTF8, 0, &wstr.at(0), (int)wstr.size(), &result.at(0), size_needed, nullptr, nullptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool operator== (const Coords& a, const Coords& b) { return a.lat == b.lat && a.lng == b.lng && a.alt == b.alt; }
|
||||
bool operator!= (const Coords& a, const Coords& b) { return !(a == b); }
|
||||
bool operator== (const Coords& a, const int& b) { return a.lat == b && a.lng == b && a.alt == b; }
|
||||
bool operator!= (const Coords& a, const int& b) { return !(a == b); }
|
||||
18
src/utils/src/main.cpp
Normal file
18
src/utils/src/main.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "framework.h"
|
||||
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
case DLL_THREAD_ATTACH:
|
||||
case DLL_THREAD_DETACH:
|
||||
case DLL_PROCESS_DETACH:
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
5
src/utils/src/pch.cpp
Normal file
5
src/utils/src/pch.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
// pch.cpp: source file corresponding to the pre-compiled header
|
||||
|
||||
#include "pch.h"
|
||||
|
||||
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
|
||||
171
src/utils/utils.vcxproj
Normal file
171
src/utils/utils.vcxproj
Normal file
@@ -0,0 +1,171 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\DCSUtils.h" />
|
||||
<ClInclude Include="include\Logger.h" />
|
||||
<ClInclude Include="include\LUAUtils.h" />
|
||||
<ClInclude Include="include\Utils.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\DCSUtils.cpp" />
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
<ClCompile Include="src\Logger.cpp" />
|
||||
<ClCompile Include="src\LUAUtils.cpp" />
|
||||
<ClCompile Include="src\Utils.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{b85009ce-4a5c-4a5a-b85d-001b3a2651b2}</ProjectGuid>
|
||||
<RootNamespace>utils</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;UTILS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;UTILS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>_DEBUG;UTILS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>include;..\..\third-party\lua\include;..\shared\include</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalLibraryDirectories>..\..\third-party\lua</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>lua.lib; $(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>NDEBUG;UTILS_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<AdditionalIncludeDirectories>include;..\..\third-party\lua\include;..\shared\include</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableUAC>false</EnableUAC>
|
||||
<AdditionalDependencies>lua.lib; $(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>..\..\third-party\lua</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
44
src/utils/utils.vcxproj.filters
Normal file
44
src/utils/utils.vcxproj.filters
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\DCSUtils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\LUAUtils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Utils.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\Logger.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\DCSUtils.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\main.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\LUAUtils.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Utils.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Logger.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user