Simulator database for X-Plane
This commit is contained in:
1 parent
eca1efdf83
commit
4b893ca726
16 files changed
+1054
-230
No files matched your search
+45
-5
@@ -9,6 +9,8 @@ std::queue<std::function<void()>> &messageQueue()
|
||||
std::thread serverThread;
|
||||
std::atomic<bool> wantsExit;
|
||||
|
||||
std::map<std::string, std::string> configuration;
|
||||
|
||||
websocket *connector;
|
||||
|
||||
/* Datarefs */
|
||||
@@ -54,9 +56,9 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
||||
/* First we must fill in the passed-in buffers to describe our
|
||||
* plugin to the plugin-system. */
|
||||
|
||||
strcpy(outName, "WebSocketTestXPlane");
|
||||
strcpy(outSig, "de.german-airlines.WebSocketTestXPlane");
|
||||
strcpy(outDesc, "WebSocketTestXPlane");
|
||||
strcpy(outName, "GAConnector");
|
||||
strcpy(outSig, "de.german-airlines.GAConnector");
|
||||
strcpy(outDesc, "GAConnector");
|
||||
|
||||
/* Flight Loop */
|
||||
XPLMRegisterFlightLoopCallback(flightLoop, -1, nullptr);
|
||||
@@ -111,11 +113,41 @@ PLUGIN_API int XPluginStart(char *outName, char *outSig, char *outDesc)
|
||||
toLog(e.what());
|
||||
return 0;
|
||||
}
|
||||
toLog("WebSocket started");
|
||||
|
||||
configuration =
|
||||
config::readConfig("Resources/plugins/GAConnector/config.cfg");
|
||||
toLog("Config loaded");
|
||||
|
||||
char hash[2 * MD5LEN + 1] = "";
|
||||
if (util::generateMD5("Custom Scenery/scenery_packs.ini", hash, toLog) ==
|
||||
0) {
|
||||
std::map<std::string, std::pair<std::vector<Gate>, std::vector<Runway>>>
|
||||
airports;
|
||||
|
||||
if (strcmp(configuration["scenery"].c_str(), hash) != 0) {
|
||||
scan("Resources/default scenery/default apt dat/Earth nav "
|
||||
"data/apt.dat",
|
||||
"Custom Scenery/scenery_packs.ini",
|
||||
"Resources/plugins/GAConnector/log.txt",
|
||||
airports);
|
||||
simulatorDatabase::toFile(airports,
|
||||
"Resources/plugins/GAConnector/sim.bin");
|
||||
|
||||
configuration["scenery"] = hash;
|
||||
config::writeConfig(configuration,
|
||||
"Resources/plugins/GAConnector/config.cfg");
|
||||
toLog("Sim Database updated");
|
||||
} else {
|
||||
airports = simulatorDatabase::fromFile(
|
||||
"Resources/plugins/GAConnector/sim.bin");
|
||||
toLog("Sim Database loaded");
|
||||
}
|
||||
}
|
||||
|
||||
// Thread for sending data to web socket
|
||||
serverThread = std::thread(&serverWorker);
|
||||
|
||||
toLog("WebSocketTestXPlane initialized and ready");
|
||||
toLog("Worker started");
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -134,11 +166,16 @@ PLUGIN_API void XPluginDisable(void) {}
|
||||
|
||||
PLUGIN_API int XPluginEnable(void) { return 1; }
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
PLUGIN_API void
|
||||
XPluginReceiveMessage(XPLMPluginID inFromWho, long inMessage, void *inParam)
|
||||
{
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
float flightLoop(float elapsedMe, float elapsedSim, int counter, void *refcon)
|
||||
{
|
||||
const std::lock_guard<std::mutex> lock(mutex);
|
||||
@@ -177,9 +214,12 @@ float flightLoop(float elapsedMe, float elapsedSim, int counter, void *refcon)
|
||||
|
||||
return -1;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
void serverWorker()
|
||||
{
|
||||
util::setThreadName("GAWorker");
|
||||
|
||||
while (!wantsExit) {
|
||||
data copy;
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user