First commit

This commit is contained in:
Pax1601
2022-11-20 12:05:38 +01:00
commit 3aa1cfe104
162 changed files with 4318 additions and 0 deletions

View 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);
}

View 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);

View 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
View 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);
}