mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
First commit
This commit is contained in:
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;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user