storage: only use relative paths if installed in a desired way
graph: drop support for cs-ebot ewp files
This commit is contained in:
parent
784ad5e303
commit
9b8c41edea
6 changed files with 32 additions and 13 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 89cfcf74cc870844d6e5029c296f6c4a6b2b6070
|
||||
Subproject commit b5f7ccc23dec2d018048b40085f78255cc232e52
|
||||
|
|
@ -67,7 +67,7 @@ public:
|
|||
CTS_BUILD_STR train { "train" };
|
||||
CTS_BUILD_STR graph { "graph" };
|
||||
CTS_BUILD_STR podbot { "pwf" };
|
||||
CTS_BUILD_STR ebot { "ewp" };
|
||||
CTS_BUILD_STR bin { "bin" };
|
||||
} folders {};
|
||||
|
||||
#undef CTS_BUILD_STR
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ CR_DECLARE_SCOPED_ENUM_TYPE (BotFile, uint32_t,
|
|||
Practice = 2,
|
||||
Graph = 3,
|
||||
Pathmatrix = 4,
|
||||
PodbotPWF = 5,
|
||||
EbotEWP = 6
|
||||
PodbotPWF = 5
|
||||
)
|
||||
|
||||
class BotStorage final : public Singleton <BotStorage> {
|
||||
|
|
@ -58,6 +57,7 @@ private:
|
|||
private:
|
||||
int m_retries {};
|
||||
ULZ *m_ulz {};
|
||||
bool m_useNonRelativePaths {};
|
||||
|
||||
public:
|
||||
BotStorage () = default;
|
||||
|
|
@ -91,6 +91,9 @@ public:
|
|||
// remove all bot related files from disk
|
||||
void unlinkFromDisk (bool onlyTrainingData, bool silenceMessages);
|
||||
|
||||
// is correctly installed and running from correct folder?
|
||||
void checkInstallLocation ();
|
||||
|
||||
public:
|
||||
// loading the graph may attempt to recurse loading, with converting or download, reset retry counter
|
||||
void resetRetries () {
|
||||
|
|
|
|||
|
|
@ -959,6 +959,7 @@ bool Game::loadCSBinary () {
|
|||
}
|
||||
|
||||
bool Game::postload () {
|
||||
bstor.checkInstallLocation (); // check if installed just as in manual
|
||||
|
||||
// register logger
|
||||
logger.initialize (bstor.buildPath (BotFile::LogFile), [] (const char *msg) {
|
||||
|
|
|
|||
|
|
@ -1702,9 +1702,7 @@ bool BotGraph::convertOldFormat () {
|
|||
MemFile fp (bstor.buildPath (BotFile::PodbotPWF, true));
|
||||
|
||||
if (!fp) {
|
||||
if (!fp.open (bstor.buildPath (BotFile::EbotEWP, true))) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
PODGraphHeader header {};
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
|
||||
#include <yapb.h>
|
||||
#include "storage.h"
|
||||
|
||||
#if defined(BOT_STORAGE_EXPLICIT_INSTANTIATIONS)
|
||||
|
||||
|
|
@ -347,8 +348,7 @@ String BotStorage::buildPath (int32_t file, bool isMemoryLoad, bool withoutMapNa
|
|||
{ BotFile::Pathmatrix, FilePath (folders.train, "pmx")},
|
||||
{ BotFile::LogFile, FilePath (folders.logs, "txt")},
|
||||
{ BotFile::Graph, FilePath (folders.graph, "graph")},
|
||||
{ BotFile::PodbotPWF, FilePath (folders.podbot, "pwf")},
|
||||
{ BotFile::EbotEWP, FilePath (folders.ebot, "ewp")},
|
||||
{ BotFile::PodbotPWF, FilePath (folders.podbot, "pwf")}
|
||||
};
|
||||
|
||||
static StringArray path {};
|
||||
|
|
@ -447,8 +447,8 @@ StringRef BotStorage::getRunningPath () {
|
|||
|
||||
static String path {};
|
||||
|
||||
// we're do not do relative (against bot's library) paths on android
|
||||
if (plat.android || plat.emscripten) {
|
||||
// we're do not do relative (against bot's library) paths on specific cases
|
||||
if (m_useNonRelativePaths) {
|
||||
if (path.empty ()) {
|
||||
path = strings.joinPath (game.getRunningModName (), folders.addons, folders.bot);
|
||||
}
|
||||
|
|
@ -459,7 +459,7 @@ StringRef BotStorage::getRunningPath () {
|
|||
if (path.empty ()) {
|
||||
path = SharedLibrary::path (&bstor);
|
||||
|
||||
if (path.startsWith ("<unk")) {
|
||||
if (path.empty ()) {
|
||||
logger.fatal ("Unable to detect library path. Giving up...");
|
||||
}
|
||||
|
||||
|
|
@ -481,7 +481,7 @@ StringRef BotStorage::getRunningPathVFS () {
|
|||
static String path {};
|
||||
|
||||
// we're do not do relative (against bot's library) paths on android
|
||||
if (plat.android) {
|
||||
if (m_useNonRelativePaths) {
|
||||
if (path.empty ()) {
|
||||
path = strings.joinPath (folders.addons, folders.bot);
|
||||
}
|
||||
|
|
@ -497,5 +497,22 @@ StringRef BotStorage::getRunningPathVFS () {
|
|||
return path;
|
||||
}
|
||||
|
||||
void BotStorage::checkInstallLocation () {
|
||||
if (plat.android || plat.emscripten) {
|
||||
m_useNonRelativePaths = true;
|
||||
return;
|
||||
}
|
||||
String path = SharedLibrary::path (&bstor);
|
||||
|
||||
if (path.empty ()) {
|
||||
m_useNonRelativePaths = true;
|
||||
return;
|
||||
}
|
||||
String dpath = strings.joinPath (folders.addons, folders.bot, folders.bin);
|
||||
path = path.substr (0, path.rfind (kPathSeparator));
|
||||
|
||||
m_useNonRelativePaths = !path.lowercase ().endsWith (dpath.lowercase ());
|
||||
}
|
||||
|
||||
#endif // BOT_STORAGE_EXPLICIT_INSTANTIATIONS
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue