|
|
@ -42,6 +42,7 @@ using namespace std;
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Core.h"
|
|
|
|
#include "DataDefs.h"
|
|
|
|
#include "DataDefs.h"
|
|
|
|
#include "Console.h"
|
|
|
|
#include "Console.h"
|
|
|
|
|
|
|
|
#include "MiscUtils.h"
|
|
|
|
#include "Module.h"
|
|
|
|
#include "Module.h"
|
|
|
|
#include "VersionInfoFactory.h"
|
|
|
|
#include "VersionInfoFactory.h"
|
|
|
|
#include "VersionInfo.h"
|
|
|
|
#include "VersionInfo.h"
|
|
|
@ -1522,7 +1523,7 @@ Core::~Core()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Core::Core() :
|
|
|
|
Core::Core() :
|
|
|
|
d{new Private},
|
|
|
|
d(dts::make_unique<Private>()),
|
|
|
|
script_path_mutex{},
|
|
|
|
script_path_mutex{},
|
|
|
|
HotkeyMutex{},
|
|
|
|
HotkeyMutex{},
|
|
|
|
HotkeyCond{},
|
|
|
|
HotkeyCond{},
|
|
|
@ -1535,10 +1536,7 @@ Core::Core() :
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// init the console. This must be always the first step!
|
|
|
|
// init the console. This must be always the first step!
|
|
|
|
plug_mgr = 0;
|
|
|
|
plug_mgr = 0;
|
|
|
|
vif = 0;
|
|
|
|
|
|
|
|
p = 0;
|
|
|
|
|
|
|
|
errorstate = false;
|
|
|
|
errorstate = false;
|
|
|
|
vinfo = 0;
|
|
|
|
|
|
|
|
started = false;
|
|
|
|
started = false;
|
|
|
|
memset(&(s_mods), 0, sizeof(s_mods));
|
|
|
|
memset(&(s_mods), 0, sizeof(s_mods));
|
|
|
|
|
|
|
|
|
|
|
@ -1617,27 +1615,27 @@ bool Core::Init()
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
const char * path = "hack\\symbols.xml";
|
|
|
|
const char * path = "hack\\symbols.xml";
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
vif = new DFHack::VersionInfoFactory();
|
|
|
|
auto local_vif = dts::make_unique<DFHack::VersionInfoFactory>();
|
|
|
|
cerr << "Identifying DF version.\n";
|
|
|
|
cerr << "Identifying DF version.\n";
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vif->loadFile(path);
|
|
|
|
local_vif->loadFile(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Error::All & err)
|
|
|
|
catch(Error::All & err)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::stringstream out;
|
|
|
|
std::stringstream out;
|
|
|
|
out << "Error while reading symbols.xml:\n";
|
|
|
|
out << "Error while reading symbols.xml:\n";
|
|
|
|
out << err.what() << std::endl;
|
|
|
|
out << err.what() << std::endl;
|
|
|
|
delete vif;
|
|
|
|
|
|
|
|
vif = NULL;
|
|
|
|
|
|
|
|
errorstate = true;
|
|
|
|
errorstate = true;
|
|
|
|
fatal(out.str());
|
|
|
|
fatal(out.str());
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
p = new DFHack::Process(vif);
|
|
|
|
vif = std::move(local_vif);
|
|
|
|
vinfo = p->getDescriptor();
|
|
|
|
auto local_p = dts::make_unique<DFHack::Process>(*vif);
|
|
|
|
|
|
|
|
local_p->ValidateDescriptionOS();
|
|
|
|
|
|
|
|
vinfo = local_p->getDescriptor();
|
|
|
|
|
|
|
|
|
|
|
|
if(!vinfo || !p->isIdentified())
|
|
|
|
if(!vinfo || !local_p->isIdentified())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!Version::git_xml_match())
|
|
|
|
if (!Version::git_xml_match())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1668,23 +1666,10 @@ bool Core::Init()
|
|
|
|
fatal("Not a known DF version.\n");
|
|
|
|
fatal("Not a known DF version.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
errorstate = true;
|
|
|
|
errorstate = true;
|
|
|
|
delete p;
|
|
|
|
|
|
|
|
p = NULL;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cerr << "Version: " << vinfo->getVersion() << endl;
|
|
|
|
cerr << "Version: " << vinfo->getVersion() << endl;
|
|
|
|
|
|
|
|
p = std::move(local_p);
|
|
|
|
#if defined(_WIN32)
|
|
|
|
|
|
|
|
const OSType expected = OS_WINDOWS;
|
|
|
|
|
|
|
|
#elif defined(_DARWIN)
|
|
|
|
|
|
|
|
const OSType expected = OS_APPLE;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
const OSType expected = OS_LINUX;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (expected != vinfo->getOS()) {
|
|
|
|
|
|
|
|
cerr << "OS mismatch; resetting to " << int(expected) << endl;
|
|
|
|
|
|
|
|
vinfo->setOS(expected);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Init global object pointers
|
|
|
|
// Init global object pointers
|
|
|
|
df::global::InitGlobals();
|
|
|
|
df::global::InitGlobals();
|
|
|
@ -2319,14 +2304,9 @@ int Core::Shutdown ( void )
|
|
|
|
plug_mgr = 0;
|
|
|
|
plug_mgr = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// invalidate all modules
|
|
|
|
// invalidate all modules
|
|
|
|
for(size_t i = 0 ; i < allModules.size(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
delete allModules[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
allModules.clear();
|
|
|
|
allModules.clear();
|
|
|
|
memset(&(s_mods), 0, sizeof(s_mods));
|
|
|
|
memset(&(s_mods), 0, sizeof(s_mods));
|
|
|
|
delete d;
|
|
|
|
d.reset();
|
|
|
|
d = nullptr;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -2755,7 +2735,7 @@ void ClassNameCheck::getKnownClassNames(std::vector<std::string> &names)
|
|
|
|
MemoryPatcher::MemoryPatcher(Process *p_) : p(p_)
|
|
|
|
MemoryPatcher::MemoryPatcher(Process *p_) : p(p_)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!p)
|
|
|
|
if (!p)
|
|
|
|
p = Core::getInstance().p;
|
|
|
|
p = Core::getInstance().p.get();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MemoryPatcher::~MemoryPatcher()
|
|
|
|
MemoryPatcher::~MemoryPatcher()
|
|
|
@ -2846,9 +2826,9 @@ TYPE * Core::get##TYPE() \
|
|
|
|
if(errorstate) return NULL;\
|
|
|
|
if(errorstate) return NULL;\
|
|
|
|
if(!s_mods.p##TYPE)\
|
|
|
|
if(!s_mods.p##TYPE)\
|
|
|
|
{\
|
|
|
|
{\
|
|
|
|
Module * mod = create##TYPE();\
|
|
|
|
std::unique_ptr<Module> mod = create##TYPE();\
|
|
|
|
s_mods.p##TYPE = (TYPE *) mod;\
|
|
|
|
s_mods.p##TYPE = (TYPE *) mod.get();\
|
|
|
|
allModules.push_back(mod);\
|
|
|
|
allModules.push_back(std::move(mod));\
|
|
|
|
}\
|
|
|
|
}\
|
|
|
|
return s_mods.p##TYPE;\
|
|
|
|
return s_mods.p##TYPE;\
|
|
|
|
}
|
|
|
|
}
|
|
|
|