Added support for loading Ubot Graph data

Fixes #123
This commit is contained in:
jeefo 2020-03-12 14:32:23 +03:00
commit 1f49026198
3 changed files with 5 additions and 3 deletions

View file

@ -66,8 +66,8 @@ private:
#if defined (CR_WINDOWS) #if defined (CR_WINDOWS)
DWORD oldProt; DWORD oldProt;
FlushInstructionCache (GetCurrentProcess (), orig, m_pageSize); FlushInstructionCache (GetCurrentProcess (), orig, CodeLength);
return VirtualProtect (orig, m_pageSize, PAGE_EXECUTE_READWRITE, &oldProt); return VirtualProtect (orig, CodeLength, PAGE_EXECUTE_READWRITE, &oldProt);
#else #else
auto aligned = align (orig); auto aligned = align (orig);
return !mprotect (aligned, m_pageSize, PROT_READ | PROT_WRITE | PROT_EXEC); return !mprotect (aligned, m_pageSize, PROT_READ | PROT_WRITE | PROT_EXEC);

View file

@ -406,7 +406,9 @@ namespace TaskPri {
// storage file magic // storage file magic
constexpr char kPodbotMagic[8] = "PODWAY!"; constexpr char kPodbotMagic[8] = "PODWAY!";
constexpr int32 kStorageMagic = 0x59415042; constexpr int32 kStorageMagic = 0x59415042;
constexpr int32 kStorageMagicUB = 0x544f4255; // storage magic for ubot-data files
constexpr float kInfiniteDistance = 9999999.0f; constexpr float kInfiniteDistance = 9999999.0f;
constexpr float kGrenadeCheckTime = 2.15f; constexpr float kGrenadeCheckTime = 2.15f;

View file

@ -1636,7 +1636,7 @@ template <typename U> bool BotGraph::loadStorage (const String &ext, const Strin
file.read (&hdr, sizeof (StorageHeader)); file.read (&hdr, sizeof (StorageHeader));
// check the magic // check the magic
if (hdr.magic != kStorageMagic) { if (hdr.magic != kStorageMagic && hdr.magic != kStorageMagicUB) {
if (tryReload ()) { if (tryReload ()) {
return true; return true;
} }