Convert ESP to Recorder

This commit is contained in:
2022-10-04 17:47:45 +02:00
parent 0a150391b8
commit 3a9db68e74
12 changed files with 271 additions and 316 deletions
+92 -15
View File
@@ -21,7 +21,13 @@ namespace file
{
private:
std::string user;
std::string scenery;
std::string XP11Scenery;
std::string XP12Scenery;
std::string FSXScenery;
std::string FSXSEScenery;
std::string P3D3Scenery;
std::string P3D4Scenery;
std::string P3D5Scenery;
std::string token;
std::string FSXPath;
std::string FSXSEPath;
@@ -33,7 +39,13 @@ namespace file
inline void writeFile() const
{
std::ofstream out(BASE_DIRECTORY CONFIG);
out << "scenery=" << this->scenery << "\n";
out << "xp11Scenery=" << this->XP11Scenery << "\n";
out << "xp12Scenery=" << this->XP12Scenery << "\n";
out << "fsxScenery=" << this->FSXScenery << "\n";
out << "fsxSEScenery=" << this->FSXSEScenery << "\n";
out << "p3d3Scenery=" << this->P3D3Scenery << "\n";
out << "p3d4Scenery=" << this->P3D4Scenery << "\n";
out << "p3d5Scenery=" << this->P3D5Scenery << "\n";
out << "user=" << this->user << "\n";
out << "token=" << this->token << "\n";
out << "fsxPath=" << this->FSXPath << "\n";
@@ -55,8 +67,20 @@ namespace file
if (fields.size() >= 2) {
utilities::trim(fields[0]);
utilities::trim(fields[1]);
if (fields[0] == "scenery") {
this->scenery = fields[1];
if (fields[0] == "xp11Scenery") {
this->XP11Scenery = fields[1];
} else if (fields[0] == "xp12Scenery") {
this->XP12Scenery = fields[1];
} else if (fields[0] == "fsxScenery") {
this->FSXScenery = fields[1];
} else if (fields[0] == "fsxSEScenery") {
this->FSXSEScenery = fields[1];
} else if (fields[0] == "p3d3Scenery") {
this->P3D3Scenery = fields[1];
} else if (fields[0] == "p3d4Scenery") {
this->P3D4Scenery = fields[1];
} else if (fields[0] == "p3d5Scenery") {
this->P3D5Scenery = fields[1];
} else if (fields[0] == "user") {
this->user = fields[1];
} else if (fields[0] == "token") {
@@ -79,25 +103,78 @@ namespace file
in.close();
}
inline void updateScenery(std::string scenery)
inline void updateScenery(int simVersion, std::string scenery)
{
this->scenery = scenery;
switch (simVersion) {
case FSX_VERSION:
this->FSXScenery = scenery;
break;
case FSXSE_VERSION:
this->FSXSEScenery = scenery;
break;
case P3D3_VERSION:
this->P3D3Scenery = scenery;
break;
case P3D4_VERSION:
this->P3D4Scenery = scenery;
break;
case P3D5_VERSION:
this->P3D5Scenery = scenery;
break;
default:
if (simVersion < 12000) {
this->XP11Scenery = scenery;
} else {
this->XP12Scenery = scenery;
}
break;
}
this->writeFile();
}
inline const std::string getUser() const { return this->user; }
inline const std::string getScenery() const { return this->scenery; }
inline const std::string getToken() const { return this->token; }
inline const std::string getFSXPath() const { return this->FSXPath; }
inline const std::string getFSXSEPath() const
inline const std::string getScenery(int simVersion) const
{
return this->FSXSEPath;
switch (simVersion) {
case FSX_VERSION:
return this->FSXScenery;
case FSXSE_VERSION:
return this->FSXSEScenery;
case P3D3_VERSION:
return this->P3D3Scenery;
case P3D4_VERSION:
return this->P3D4Scenery;
case P3D5_VERSION:
return this->P3D5Scenery;
default:
if (simVersion < 12000) {
return this->XP11Scenery;
} else {
return this->XP12Scenery;
}
}
}
inline const std::string getToken() const { return this->token; }
inline const std::string getPath(int simVersion) const
{
switch (simVersion) {
case FSX_VERSION:
return this->FSXPath;
case FSXSE_VERSION:
return this->FSXSEPath;
case P3D3_VERSION:
return this->P3D3Path;
case P3D4_VERSION:
return this->P3D4Path;
case P3D5_VERSION:
return this->P3D5Path;
case MSFS_VERSION:
return this->MSFSPath;
default:
return "/";
}
}
inline const std::string getP3D3Path() const { return this->P3D3Path; }
inline const std::string getP3D4Path() const { return this->P3D4Path; }
inline const std::string getP3D5Path() const { return this->P3D5Path; }
inline const std::string getMSFSPath() const { return this->MSFSPath; }
};
} // namespace config
} // namespace file
+28 -43
View File
@@ -108,14 +108,35 @@ namespace file
}
}
inline const char *resolveFilename(int simVersion) const
{
switch (simVersion) {
case FSX_VERSION:
return BASE_DIRECTORY FSX_PREFIX SIMDATABASE;
case FSXSE_VERSION:
return BASE_DIRECTORY FSXSE_PREFIX SIMDATABASE;
case P3D3_VERSION:
return BASE_DIRECTORY P3D3_PREFIX SIMDATABASE;
case P3D4_VERSION:
return BASE_DIRECTORY P3D4_PREFIX SIMDATABASE;
case P3D5_VERSION:
return BASE_DIRECTORY P3D5_PREFIX SIMDATABASE;
case MSFS_VERSION:
return "NONE";
default:
return BASE_DIRECTORY SIMDATABASE;
}
}
public:
inline SimDatabase(int simVersion,
const char *hash,
std::shared_ptr<config::Config> &configuration,
std::function<void(const std::string)> toLog)
{
if (strcmp(configuration->getScenery().c_str(), hash) != 0 ||
!utilities::fileExists(BASE_DIRECTORY SIMDATABASE)) {
if (strcmp(configuration->getScenery(simVersion).c_str(), hash) !=
0 ||
!utilities::fileExists(resolveFilename(simVersion))) {
#ifdef XP
scan(simVersion < 12000 ? XPLANE11_BASE_SCENERY
: XPLANE12_BASE_SCENERY,
@@ -129,52 +150,16 @@ namespace file
BASE_DIRECTORY "db_log.txt",
airports);
#endif
configuration->updateScenery(hash);
#ifdef XP
this->toFile(SIMDATABASE);
#endif
configuration->updateScenery(simVersion, hash);
#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;
}
this->toFile(resolveFilename(simVersion));
#endif
toLog("Sim Database updated");
} else {
#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;
}
this->fromFile(resolveFilename(simVersion));
#endif
toLog("Sim Database loaded");
}