mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
i hope this works
This commit is contained in:
parent
e83e03f714
commit
427c74fce3
2 changed files with 37 additions and 2 deletions
36
entry.cpp
36
entry.cpp
|
@ -17,3 +17,39 @@ namespace {
|
|||
// to make sure the instance is set into the sharedMod<> in load time
|
||||
static auto mod = geode::getMod();
|
||||
}
|
||||
|
||||
#if defined(_DEBUG) && defined(GEODE_IS_WINDOWS)
|
||||
|
||||
// This bypasses any of the heap validation measures that are injected when compiling in Debug.
|
||||
// Without these, the game will very likely crash when the mod tries to free memory allocated by the game (or another non-debug mod).
|
||||
|
||||
static inline void* relallocthrow(size_t size) {
|
||||
// void* p;
|
||||
// while ((p = HeapAlloc(GetProcessHeap(), 0, size)) == 0) {
|
||||
// if (_callnewh(size) == 0) {
|
||||
// static const std::bad_alloc exc;
|
||||
// throw exc;
|
||||
// }
|
||||
// }
|
||||
|
||||
return geode::stl::operatorNew(size);
|
||||
}
|
||||
|
||||
static inline void relfree(void* block) {
|
||||
// HeapFree(GetProcessHeap(), 0, block);
|
||||
geode::stl::operatorDelete(block);
|
||||
}
|
||||
|
||||
void* operator new(size_t size) {
|
||||
return relallocthrow(size);
|
||||
}
|
||||
|
||||
void* operator new[](size_t size) {
|
||||
return relallocthrow(size);
|
||||
}
|
||||
|
||||
void operator delete(void* block) noexcept {
|
||||
relfree(block);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -48,8 +48,7 @@ Result<> Mod::Impl::setup() {
|
|||
}
|
||||
if (!m_resourcesLoaded) {
|
||||
auto searchPathRoot = dirs::getModRuntimeDir() / m_metadata.getID() / "resources";
|
||||
// TODO: i think this crashes for some people
|
||||
// CCFileUtils::get()->addSearchPath(searchPathRoot.string().c_str());
|
||||
CCFileUtils::get()->addSearchPath(searchPathRoot.string().c_str());
|
||||
|
||||
const auto binariesDir = searchPathRoot / m_metadata.getID() / "binaries" / PlatformID::toShortString(GEODE_PLATFORM_TARGET);
|
||||
if (ghc::filesystem::exists(binariesDir))
|
||||
|
|
Loading…
Reference in a new issue