Start on SimConnect
This commit is contained in:
1 parent
997586b8aa
commit
23db85c2a5
22 files changed
+1209
-116
No files matched your search
@@ -16,7 +16,12 @@
|
||||
#include "constants.h"
|
||||
#include "simdata/gate.hpp"
|
||||
#include "simdata/runway.hpp"
|
||||
#ifdef XP
|
||||
#include "simdata/simdataXP.hpp"
|
||||
#endif
|
||||
#ifndef MSFS
|
||||
#include "simdata/simdataESP.hpp"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Header
|
||||
@@ -84,9 +89,11 @@ namespace file
|
||||
in.close();
|
||||
}
|
||||
|
||||
inline void fromFile()
|
||||
inline void fromFile(const char *file)
|
||||
{
|
||||
std::ifstream in(BASE_DIRECTORY SIMDATABASE, std::ifstream::binary);
|
||||
std::string path(BASE_DIRECTORY);
|
||||
path.append(file);
|
||||
std::ifstream in(path, std::ifstream::binary);
|
||||
|
||||
std::string ident = readString(in, 4);
|
||||
if (ident.compare(SIMDATABASE_HEADER) != 0) {
|
||||
@@ -100,37 +107,82 @@ namespace file
|
||||
}
|
||||
|
||||
public:
|
||||
inline SimDatabase(int xPlaneVersion,
|
||||
inline SimDatabase(int simVersion,
|
||||
const char *hash,
|
||||
std::unique_ptr<config::Config> &configuration,
|
||||
std::shared_ptr<config::Config> &configuration,
|
||||
std::function<void(const std::string)> toLog)
|
||||
{
|
||||
if (strcmp(configuration->getScenery().c_str(), hash) != 0 ||
|
||||
!util::fileExists(BASE_DIRECTORY SIMDATABASE)) {
|
||||
#ifdef XP
|
||||
scan(xPlaneVersion < 12000 ? XPLANE11_BASE_SCENERY
|
||||
: XPLANE12_BASE_SCENERY,
|
||||
scan(simVersion < 12000 ? XPLANE11_BASE_SCENERY
|
||||
: XPLANE12_BASE_SCENERY,
|
||||
XPLANE_CUSTOM_SCENERY,
|
||||
BASE_DIRECTORY "log.txt",
|
||||
airports);
|
||||
#else
|
||||
toLog("ESP SCAN WILL BE HERE");
|
||||
#endif
|
||||
|
||||
#ifndef MSFS
|
||||
scan(BASE_DIRECTORY MAKERWYS_R5,
|
||||
BASE_DIRECTORY MAKERWYS_G5,
|
||||
BASE_DIRECTORY "db_log.txt",
|
||||
airports);
|
||||
#endif
|
||||
configuration->updateScenery(hash);
|
||||
this->toFile();
|
||||
|
||||
#ifdef XP
|
||||
this->toFile(SIMDATABASE);
|
||||
#endif
|
||||
#ifndef MSFS
|
||||
switch (simVersion) {
|
||||
case FSX_VERSION:
|
||||
this->toFile(FSX_PREFIX SIMDATABASE);
|
||||
break;
|
||||
case FSXSE_VERSION:
|
||||
this->toFile(FSXSE_PREFIX SIMDATABASE);
|
||||
break;
|
||||
case P3D3_VERSION:
|
||||
this->toFile(P3D3_PREFIX SIMDATABASE);
|
||||
break;
|
||||
case P3D4_VERSION:
|
||||
this->toFile(P3D4_PREFIX SIMDATABASE);
|
||||
break;
|
||||
case P3D5_VERSION:
|
||||
this->toFile(P3D5_PREFIX SIMDATABASE);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
toLog("Sim Database updated");
|
||||
} else {
|
||||
this->fromFile();
|
||||
|
||||
#ifdef XP
|
||||
this->fromFile(SIMDATABASE);
|
||||
#endif
|
||||
#ifndef MSFS
|
||||
switch (simVersion) {
|
||||
case FSX_VERSION:
|
||||
this->fromFile(FSX_PREFIX SIMDATABASE);
|
||||
break;
|
||||
case FSXSE_VERSION:
|
||||
this->fromFile(FSXSE_PREFIX SIMDATABASE);
|
||||
break;
|
||||
case P3D3_VERSION:
|
||||
this->fromFile(P3D3_PREFIX SIMDATABASE);
|
||||
break;
|
||||
case P3D4_VERSION:
|
||||
this->fromFile(P3D4_PREFIX SIMDATABASE);
|
||||
break;
|
||||
case P3D5_VERSION:
|
||||
this->fromFile(P3D5_PREFIX SIMDATABASE);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
toLog("Sim Database loaded");
|
||||
}
|
||||
}
|
||||
|
||||
inline void toFile() const
|
||||
inline void toFile(const char *file) const
|
||||
{
|
||||
std::ofstream out(BASE_DIRECTORY SIMDATABASE, std::fstream::binary);
|
||||
std::string path(BASE_DIRECTORY);
|
||||
path.append(file);
|
||||
std::ofstream out(path, std::fstream::binary);
|
||||
|
||||
// File Header
|
||||
out.write(SIMDATABASE_HEADER, 4);
|
||||
|
||||
Reference in new issue
Block a user