mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Minor bug fixing, added patcher for Export.lua, added plugin options to enable/disable mod
This commit is contained in:
@@ -13,9 +13,7 @@ public:
|
||||
void execute(lua_State* L);
|
||||
void handleRequest(wstring key, json::value value);
|
||||
|
||||
|
||||
private:
|
||||
list<Command*> commands;
|
||||
mutex mutexLock;
|
||||
};
|
||||
|
||||
|
||||
@@ -105,9 +105,6 @@ protected:
|
||||
Coords oldPosition = Coords(0); // Used to approximate speed
|
||||
|
||||
virtual void AIloop() = 0;
|
||||
|
||||
private:
|
||||
mutex mutexLock;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@ void Scheduler::appendCommand(Command* command)
|
||||
|
||||
void Scheduler::execute(lua_State* L)
|
||||
{
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
int priority = CommandPriority::HIGH;
|
||||
while (priority >= CommandPriority::LOW)
|
||||
{
|
||||
@@ -51,8 +49,6 @@ void Scheduler::execute(lua_State* L)
|
||||
|
||||
void Scheduler::handleRequest(wstring key, json::value value)
|
||||
{
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
Command* command = nullptr;
|
||||
|
||||
log(L"Received request with ID: " + key);
|
||||
|
||||
@@ -25,9 +25,6 @@ Unit::~Unit()
|
||||
|
||||
void Unit::updateExportData(json::value json)
|
||||
{
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
/* Compute speed (loGetWorldObjects does not provide speed, we compute it for better performance instead of relying on many lua calls) */
|
||||
if (oldPosition != NULL)
|
||||
{
|
||||
@@ -77,11 +74,8 @@ void Unit::updateExportData(json::value json)
|
||||
|
||||
void Unit::updateMissionData(json::value json)
|
||||
{
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
if (json.has_number_field(L"fuel"))
|
||||
fuel = json[L"fuel"].as_number().to_int32();
|
||||
fuel = int(json[L"fuel"].as_number().to_double() * 100);
|
||||
if (json.has_object_field(L"ammo"))
|
||||
ammo = json[L"ammo"];
|
||||
if (json.has_object_field(L"targets"))
|
||||
@@ -92,9 +86,6 @@ void Unit::updateMissionData(json::value json)
|
||||
|
||||
json::value Unit::json()
|
||||
{
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
auto json = json::value::object();
|
||||
|
||||
json[L"alive"] = alive;
|
||||
|
||||
@@ -13,11 +13,15 @@ Server* server = nullptr;
|
||||
Scheduler* scheduler = nullptr;
|
||||
json::value airbasesData;
|
||||
json::value bullseyeData;
|
||||
|
||||
mutex mutexLock;
|
||||
bool initialized = false;
|
||||
|
||||
/* Called when DCS simulation stops. All singleton instances are deleted. */
|
||||
extern "C" DllExport int coreDeinit(lua_State* L)
|
||||
{
|
||||
if (!initialized)
|
||||
return (0);
|
||||
|
||||
log("Olympus coreDeinit called successfully");
|
||||
|
||||
delete unitsFactory;
|
||||
@@ -38,11 +42,18 @@ extern "C" DllExport int coreInit(lua_State* L)
|
||||
|
||||
registerLuaFunctions(L);
|
||||
|
||||
initialized = true;
|
||||
return(0);
|
||||
}
|
||||
|
||||
extern "C" DllExport int coreFrame(lua_State* L)
|
||||
{
|
||||
if (!initialized)
|
||||
return (0);
|
||||
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
const std::chrono::duration<double> duration = std::chrono::system_clock::now() - before;
|
||||
|
||||
// TODO make intervals editable
|
||||
@@ -65,6 +76,12 @@ extern "C" DllExport int coreFrame(lua_State* L)
|
||||
|
||||
extern "C" DllExport int coreMissionData(lua_State * L)
|
||||
{
|
||||
if (!initialized)
|
||||
return (0);
|
||||
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
lua_getglobal(L, "Olympus");
|
||||
lua_getfield(L, -1, "missionData");
|
||||
json::value missionData = luaTableToJSON(L, -1);
|
||||
|
||||
@@ -11,6 +11,7 @@ extern UnitsFactory* unitsFactory;
|
||||
extern Scheduler* scheduler;
|
||||
extern json::value airbasesData;
|
||||
extern json::value bullseyeData;
|
||||
extern mutex mutexLock;
|
||||
|
||||
void handle_eptr(std::exception_ptr eptr)
|
||||
{
|
||||
@@ -49,6 +50,9 @@ void Server::handle_options(http_request request)
|
||||
|
||||
void Server::handle_get(http_request request)
|
||||
{
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
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("*"));
|
||||
@@ -107,6 +111,9 @@ void Server::handle_put(http_request request)
|
||||
request,
|
||||
[](json::value const& jvalue, json::value& answer)
|
||||
{
|
||||
/* Lock for thread safety */
|
||||
lock_guard<mutex> guard(mutexLock);
|
||||
|
||||
for (auto const& e : jvalue.as_object())
|
||||
{
|
||||
auto key = e.first;
|
||||
|
||||
Reference in New Issue
Block a user