From 1f49026198d499ec25b984b6f29ce4fe3eaa9f16 Mon Sep 17 00:00:00 2001 From: jeefo Date: Thu, 12 Mar 2020 14:32:23 +0300 Subject: [PATCH] Added support for loading Ubot Graph data Fixes #123 --- include/crlib/cr-hook.h | 4 ++-- include/yapb.h | 2 ++ source/graph.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/crlib/cr-hook.h b/include/crlib/cr-hook.h index b678247..2269422 100644 --- a/include/crlib/cr-hook.h +++ b/include/crlib/cr-hook.h @@ -66,8 +66,8 @@ private: #if defined (CR_WINDOWS) DWORD oldProt; - FlushInstructionCache (GetCurrentProcess (), orig, m_pageSize); - return VirtualProtect (orig, m_pageSize, PAGE_EXECUTE_READWRITE, &oldProt); + FlushInstructionCache (GetCurrentProcess (), orig, CodeLength); + return VirtualProtect (orig, CodeLength, PAGE_EXECUTE_READWRITE, &oldProt); #else auto aligned = align (orig); return !mprotect (aligned, m_pageSize, PROT_READ | PROT_WRITE | PROT_EXEC); diff --git a/include/yapb.h b/include/yapb.h index ed75ecf..e3854cf 100644 --- a/include/yapb.h +++ b/include/yapb.h @@ -406,7 +406,9 @@ namespace TaskPri { // storage file magic constexpr char kPodbotMagic[8] = "PODWAY!"; + constexpr int32 kStorageMagic = 0x59415042; +constexpr int32 kStorageMagicUB = 0x544f4255; // storage magic for ubot-data files constexpr float kInfiniteDistance = 9999999.0f; constexpr float kGrenadeCheckTime = 2.15f; diff --git a/source/graph.cpp b/source/graph.cpp index a5d1d66..72921e4 100644 --- a/source/graph.cpp +++ b/source/graph.cpp @@ -1636,7 +1636,7 @@ template bool BotGraph::loadStorage (const String &ext, const Strin file.read (&hdr, sizeof (StorageHeader)); // check the magic - if (hdr.magic != kStorageMagic) { + if (hdr.magic != kStorageMagic && hdr.magic != kStorageMagicUB) { if (tryReload ()) { return true; }