mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Added environment variable to set location of mod.
Multiple units selection and path drawing added.
This commit is contained in:
parent
ed193b6c78
commit
0c6142bf17
@ -14,10 +14,18 @@ Source: "..\scripts\OlympusExport.lua"; DestDir: "{app}\Scripts"; Flags: ignorev
|
||||
Source: "..\scripts\OlympusHook.lua"; DestDir: "{app}\Scripts\Hooks"; Flags: ignoreversion
|
||||
Source: "..\scripts\OlympusCommand.lua"; DestDir: "{app}\Mods\Services\Olympus\Scripts"; Flags: ignoreversion
|
||||
Source: "..\scripts\OlympusMission.lua"; DestDir: "{app}\Mods\Services\Olympus\Scripts"; Flags: ignoreversion
|
||||
Source: "..\bin\x64\Release\*.dll"; DestDir: "{app}\Mods\Services\Olympus\bin"; Flags: ignoreversion;
|
||||
Source: "..\scripts\mist_4_4_90.lua"; DestDir: "{app}\Mods\Services\Olympus\Scripts"; Flags: ignoreversion
|
||||
Source: "..\bin\*.dll"; DestDir: "{app}\Mods\Services\Olympus\bin"; Flags: ignoreversion;
|
||||
|
||||
[Code]
|
||||
procedure AppendExportString();
|
||||
begin
|
||||
SaveStringToFile(ExpandConstant('{app}\Scripts\Export.lua'), #13#10 + 'local Olympuslfs=require(''lfs'');dofile(Olympuslfs.writedir()..''Scripts/OlympusExport.lua'')' + #13#10, True);
|
||||
end;
|
||||
end;
|
||||
|
||||
[Registry]
|
||||
Root: HKCU; Subkey: "Environment"; ValueType:string; ValueName: "OLYMPUS"; ValueData: "{app}\Mods\Services\Olympus"; Flags: preservestringtype
|
||||
|
||||
[Setup]
|
||||
; Tell Windows Explorer to reload the environment
|
||||
ChangesEnvironment=yes
|
||||
@ -2,26 +2,16 @@ Olympus = {}
|
||||
Olympus.OlympusDLL = nil
|
||||
Olympus.cppRESTDLL = nil
|
||||
Olympus.DLLsloaded = false
|
||||
Olympus.debug = true
|
||||
if Olympus.debug then
|
||||
Olympus.OlympusModPath = "C:\\Users\\dpass\\Documents\\Olympus\\bin\\x64\\Debug\\"
|
||||
else
|
||||
Olympus.OlympusModPath = "C:\\Users\\dpass\\Doczuments\\Olympus\\bin\\x64\\Release\\"
|
||||
end
|
||||
Olympus.OlympusModPath = os.getenv('OLYMPUS')..'\\bin\\'
|
||||
|
||||
log.write('Olympus.EXPORT.LUA', log.INFO,'Executing OlympusExport.lua')
|
||||
log.write('Olympus.EXPORT.LUA', log.INFO, 'Executing OlympusExport.lua')
|
||||
|
||||
function Olympus.loadDLLs()
|
||||
-- Add the .dll paths
|
||||
package.cpath = package.cpath..';'..Olympus.OlympusModPath..'?.dll;'
|
||||
|
||||
if Olympus.debug then
|
||||
log.write('Olympus.EXPORT.LUA', log.INFO, 'Loading cpprest_2_10d.dll from ['..Olympus.OlympusModPath..']')
|
||||
pcall(require, 'cpprest_2_10d')
|
||||
else
|
||||
log.write('Olympus.EXPORT.LUA', log.INFO, 'Loading cpprest_2_10.dll from ['..Olympus.OlympusModPath..']')
|
||||
pcall(require, 'cpprest_2_10')
|
||||
end
|
||||
log.write('Olympus.EXPORT.LUA', log.INFO, 'Loading cpprest_2_10.dll from ['..Olympus.OlympusModPath..']')
|
||||
pcall(require, 'cpprest_2_10')
|
||||
|
||||
log.write('Olympus.EXPORT.LUA', log.INFO, 'Loading Olympus.dll from ['..Olympus.OlympusModPath..']')
|
||||
local status
|
||||
|
||||
@ -2,12 +2,7 @@ Olympus = {}
|
||||
Olympus.OlympusDLL = nil
|
||||
Olympus.cppRESTDLL = nil
|
||||
Olympus.DLLsloaded = false
|
||||
Olympus.debug = true
|
||||
if Olympus.debug then
|
||||
Olympus.OlympusModPath = "C:\\Users\\dpass\\Documents\\Olympus\\bin\\x64\\Debug\\"
|
||||
else
|
||||
Olympus.OlympusModPath = "C:\\Users\\dpass\\Doczuments\\Olympus\\bin\\x64\\Release\\"
|
||||
end
|
||||
Olympus.OlympusModPath = os.getenv('OLYMPUS')..'\\bin\\'
|
||||
|
||||
log.write('Olympus.HOOKS.LUA', log.INFO,'Executing OlympusHook.lua')
|
||||
|
||||
@ -15,13 +10,8 @@ function loadDLLs()
|
||||
-- Add the .dll paths
|
||||
package.cpath = package.cpath..';'..Olympus.OlympusModPath..'?.dll;'
|
||||
|
||||
if Olympus.debug then
|
||||
log.write('Olympus.HOOKS.LUA', log.INFO, 'Loading cpprest_2_10d.dll from ['..Olympus.OlympusModPath..']')
|
||||
pcall(require, 'cpprest_2_10d')
|
||||
else
|
||||
log.write('Olympus.HOOKS.LUA', log.INFO, 'Loading cpprest_2_10.dll from ['..Olympus.OlympusModPath..']')
|
||||
pcall(require, 'cpprest_2_10')
|
||||
end
|
||||
log.write('Olympus.HOOKS.LUA', log.INFO, 'Loading cpprest_2_10.dll from ['..Olympus.OlympusModPath..']')
|
||||
pcall(require, 'cpprest_2_10')
|
||||
|
||||
log.write('Olympus.HOOKS.LUA', log.INFO, 'Loading Olympus.dll from ['..Olympus.OlympusModPath..']')
|
||||
local status
|
||||
|
||||
7347
scripts/mist_4_4_90.lua
Normal file
7347
scripts/mist_4_4_90.lua
Normal file
File diff suppressed because it is too large
Load Diff
@ -59,7 +59,7 @@
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>.\..\..\bin\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Label="Vcpkg">
|
||||
<VcpkgAutoLink>true</VcpkgAutoLink>
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
#include "DCSUtils.h"
|
||||
#include "Logger.h"
|
||||
#include "Utils.h"
|
||||
|
||||
#define DllExport __declspec( dllexport )
|
||||
|
||||
@ -35,13 +36,25 @@ 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
|
||||
|
||||
string modLocation;
|
||||
string dllLocation;
|
||||
char* buf = nullptr;
|
||||
size_t sz = 0;
|
||||
if (_dupenv_s(&buf, &sz, "OLYMPUS") == 0 && buf != nullptr)
|
||||
{
|
||||
modLocation = buf;
|
||||
free(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER->Log("OLYMPUS environment variable is missing");
|
||||
goto error;
|
||||
}
|
||||
dllLocation = modLocation + "\\bin\\core.dll";
|
||||
|
||||
LOGGER->Log("Loading core.dll");
|
||||
hGetProcIDDLL = LoadLibrary(Utils::to_wstring(dllLocation).c_str());
|
||||
|
||||
if (!hGetProcIDDLL) {
|
||||
DCSUtils::LogError(L, "Error loading core DLL");
|
||||
|
||||
@ -98,7 +98,7 @@
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>.\..\..\bin\</OutDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
using namespace web::http;
|
||||
using namespace web::http::experimental::listener;
|
||||
|
||||
class UnitsHandler;
|
||||
class UnitsFactory;
|
||||
class Scheduler;
|
||||
|
||||
class RESTServer
|
||||
|
||||
@ -4,11 +4,11 @@
|
||||
|
||||
class Unit;
|
||||
|
||||
class UnitsHandler
|
||||
class UnitsFactory
|
||||
{
|
||||
public:
|
||||
UnitsHandler(lua_State* L);
|
||||
~UnitsHandler();
|
||||
UnitsFactory(lua_State* L);
|
||||
~UnitsFactory();
|
||||
|
||||
Unit* getUnit(int ID);
|
||||
void getMissionDB(lua_State* L);
|
||||
|
||||
@ -1,28 +1,84 @@
|
||||
#include "LUAFunctions.h"
|
||||
#include "Logger.h"
|
||||
|
||||
/* Executes the "OlympusCommand.lua" file to load in the "Server" Lua space all the Lua functions necessary to perform DCS commands (like moving units) */
|
||||
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();
|
||||
}
|
||||
string modLocation;
|
||||
|
||||
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)
|
||||
char* buf = nullptr;
|
||||
size_t sz = 0;
|
||||
if (_dupenv_s(&buf, &sz, "OLYMPUS") == 0 && buf != nullptr)
|
||||
{
|
||||
LOGGER->Log("Error registering LUA functions");
|
||||
modLocation = buf;
|
||||
free(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER->Log("Lua functions registered successfully");
|
||||
LOGGER->Log("OLYMPUS environment variable is missing");
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
ifstream f(modLocation + "\\Scripts\\mist_4_4_90.lua");
|
||||
string str;
|
||||
LOGGER->Log("Reading MIST from " + modLocation + "\\Scripts\\mist_4_4_90.lua");
|
||||
if (f) {
|
||||
ostringstream ss;
|
||||
ss << f.rdbuf();
|
||||
str = ss.str();
|
||||
LOGGER->Log("MIST read succesfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER->Log("Error reading MIST");
|
||||
return;
|
||||
}
|
||||
|
||||
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 MIST");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER->Log("MIST registered successfully");
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
ifstream f(modLocation + "\\Scripts\\OlympusCommand.lua");
|
||||
string str;
|
||||
LOGGER->Log("Reading OlympusCommand.lua from " + modLocation + "\\Scripts\\OlympusCommand.lua");
|
||||
if (f) {
|
||||
ostringstream ss;
|
||||
ss << f.rdbuf();
|
||||
str = ss.str();
|
||||
LOGGER->Log("OlympusCommand.lua read succesfully");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER->Log("Error reading OlympusCommand.lua");
|
||||
return;
|
||||
}
|
||||
|
||||
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 OlympusCommand.lua");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER->Log("OlympusCommand.lua registered successfully");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,7 +5,7 @@
|
||||
#include "Scheduler.h"
|
||||
#include "LUAUtils.h"
|
||||
|
||||
extern UnitsHandler* unitsHandler;
|
||||
extern UnitsFactory* unitsHandler;
|
||||
extern Scheduler* scheduler;
|
||||
extern json::value missionData;
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include "Utils.h"
|
||||
#include "Unit.h"
|
||||
|
||||
extern UnitsHandler* unitsHandler;
|
||||
extern UnitsFactory* unitsHandler;
|
||||
|
||||
Scheduler::Scheduler(lua_State* L)
|
||||
{
|
||||
|
||||
@ -4,17 +4,17 @@
|
||||
#include "framework.h"
|
||||
#include "Utils.h"
|
||||
|
||||
UnitsHandler::UnitsHandler(lua_State* L)
|
||||
UnitsFactory::UnitsFactory(lua_State* L)
|
||||
{
|
||||
DCSUtils::LogInfo(L, "Units Factory constructor called successfully");
|
||||
}
|
||||
|
||||
UnitsHandler::~UnitsHandler()
|
||||
UnitsFactory::~UnitsFactory()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Unit* UnitsHandler::getUnit(int ID)
|
||||
Unit* UnitsFactory::getUnit(int ID)
|
||||
{
|
||||
if (units.find(ID) == units.end()) {
|
||||
return nullptr;
|
||||
@ -24,7 +24,7 @@ Unit* UnitsHandler::getUnit(int ID)
|
||||
}
|
||||
}
|
||||
|
||||
void UnitsHandler::update(lua_State* L)
|
||||
void UnitsFactory::update(lua_State* L)
|
||||
{
|
||||
//lua_getglobal(L, "net");
|
||||
//lua_getfield(L, -1, "dostring_in");
|
||||
@ -45,7 +45,7 @@ void UnitsHandler::update(lua_State* L)
|
||||
}
|
||||
}
|
||||
|
||||
void UnitsHandler::updateAnswer(json::value& answer)
|
||||
void UnitsFactory::updateAnswer(json::value& answer)
|
||||
{
|
||||
// TODO THREAT SAFEY!
|
||||
auto unitsJson = json::value::object();
|
||||
|
||||
@ -7,13 +7,13 @@
|
||||
#include "Scheduler.h"
|
||||
#include "LUAFunctions.h"
|
||||
|
||||
|
||||
auto before = std::chrono::system_clock::now();
|
||||
UnitsHandler* unitsHandler = nullptr;
|
||||
UnitsFactory* unitsHandler = nullptr;
|
||||
RESTServer* restserver = nullptr;
|
||||
Scheduler* scheduler = nullptr;
|
||||
json::value missionData;
|
||||
|
||||
/* Standard DllMain entry point */
|
||||
BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
@ -32,6 +32,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,
|
||||
|
||||
#define DllExport __declspec( dllexport )
|
||||
|
||||
/* Called when DCS simulation stops. All singleton instances are deleted. */
|
||||
extern "C" DllExport int coreDeinit(lua_State* L)
|
||||
{
|
||||
LOGGER->Log("Olympus coreDeinit called successfully");
|
||||
@ -45,9 +46,10 @@ extern "C" DllExport int coreDeinit(lua_State* L)
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Called when DCS simulation starts. All singletons are instantiated, and the custom Lua functions are registered in the Lua state. */
|
||||
extern "C" DllExport int coreInit(lua_State* L)
|
||||
{
|
||||
unitsHandler = new UnitsHandler(L);
|
||||
unitsHandler = new UnitsFactory(L);
|
||||
restserver = new RESTServer(L);
|
||||
scheduler = new Scheduler(L);
|
||||
|
||||
|
||||
@ -84,7 +84,7 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<OutDir>.\..\..\bin\</OutDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>.\..\..\bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user