[AssetHandler] Move asset related reallocations
This commit is contained in:
parent
12dc916f72
commit
c3dc8814eb
@ -407,8 +407,57 @@ namespace Components
|
||||
Utils::Hook::Call<void(int, const char*, const char*, const char*)>(0x4F8C70)(severity, format, type, name); // Print error
|
||||
}
|
||||
|
||||
void AssetHandler::reallocateEntryPool()
|
||||
{
|
||||
AssertSize(Game::XAssetEntry, 16);
|
||||
|
||||
size_t size = (ZoneBuilder::IsEnabled() ? 1183968 : 789312);
|
||||
Game::XAssetEntry* entryPool = Utils::Memory::GetAllocator()->allocateArray<Game::XAssetEntry>(size);
|
||||
|
||||
// Apply new size
|
||||
Utils::Hook::Set<DWORD>(0x5BAEB0, size);
|
||||
|
||||
// Apply new pool
|
||||
DWORD patches[] =
|
||||
{
|
||||
0x48E6F4,
|
||||
0x4C67E4,
|
||||
0x4C8584,
|
||||
0x5BAEA8,
|
||||
0x5BB0C4,
|
||||
0x5BB0F5,
|
||||
0x5BB1D4,
|
||||
0x5BB235,
|
||||
0x5BB278,
|
||||
0x5BB34C,
|
||||
0x5BB484,
|
||||
0x5BB570,
|
||||
0x5BB6B7,
|
||||
0x5BB844,
|
||||
0x5BB98D,
|
||||
0x5BBA66,
|
||||
0x5BBB8D,
|
||||
0x5BBCB1,
|
||||
0x5BBD9B,
|
||||
0x5BBE4C,
|
||||
0x5BBF14,
|
||||
0x5BBF54,
|
||||
0x5BBFB8
|
||||
};
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(patches); ++i)
|
||||
{
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(patches[i], entryPool);
|
||||
}
|
||||
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BAE91, entryPool + 1);
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BAEA2, entryPool + 1);
|
||||
}
|
||||
|
||||
AssetHandler::AssetHandler()
|
||||
{
|
||||
this->reallocateEntryPool();
|
||||
|
||||
Dvar::Register<bool>("r_noVoid", false, Game::DVAR_FLAG_SAVED, "Disable void model (red fx)");
|
||||
|
||||
AssetHandler::ClearTemporaryAssets();
|
||||
@ -450,9 +499,31 @@ namespace Components
|
||||
}
|
||||
});
|
||||
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_GAMEWORLD_SP, 1);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMAGE, ZoneBuilder::IsEnabled() ? 14336 : 7168);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_LOADED_SOUND, 2700);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_FX, 1200);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY, 14000);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_XANIMPARTS, 8192);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_XMODEL, 5125);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_PHYSPRESET, 128);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_PIXELSHADER, ZoneBuilder::IsEnabled() ? 0x4000 : 10000);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_VERTEXSHADER, ZoneBuilder::IsEnabled() ? 0x2000 : 3072);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_MATERIAL, 8192);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_VERTEXDECL, ZoneBuilder::IsEnabled() ? 0x400 : 196);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_WEAPON, WEAPON_LIMIT);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_STRINGTABLE, 800);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMPACT_FX, 8);
|
||||
|
||||
// Register asset interfaces
|
||||
if (ZoneBuilder::IsEnabled())
|
||||
{
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_MAP_ENTS, 10);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_XMODELSURFS, 8192);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET, 0x2000);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_FONT, 32);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_RAWFILE, 2048);
|
||||
|
||||
AssetHandler::RegisterInterface(new Assets::IFont_s());
|
||||
AssetHandler::RegisterInterface(new Assets::IXModel());
|
||||
AssetHandler::RegisterInterface(new Assets::IFxWorld());
|
||||
|
@ -70,6 +70,8 @@ namespace Components
|
||||
static void SetBypassState(bool value);
|
||||
|
||||
static void MissingAssetError(int severity, const char* format, const char* type, const char* name);
|
||||
|
||||
void reallocateEntryPool();
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ namespace Components
|
||||
|
||||
bool Maps::SPMap;
|
||||
std::vector<Maps::DLC> Maps::DlcPacks;
|
||||
std::vector<Game::XAssetEntry> Maps::EntryPool;
|
||||
|
||||
const char* Maps::UserMapFiles[4] =
|
||||
{
|
||||
@ -713,59 +712,7 @@ namespace Components
|
||||
|
||||
Game::XAssetEntry* Maps::GetAssetEntryPool()
|
||||
{
|
||||
if(Maps::EntryPool.empty())
|
||||
{
|
||||
return reinterpret_cast<Game::XAssetEntry*>(0x134CAD8);
|
||||
}
|
||||
|
||||
return Maps::EntryPool.data();
|
||||
}
|
||||
|
||||
void Maps::reallocateEntryPool()
|
||||
{
|
||||
AssertSize(Game::XAssetEntry, 16);
|
||||
|
||||
Maps::EntryPool.clear();
|
||||
|
||||
if (ZoneBuilder::IsEnabled())
|
||||
{
|
||||
Maps::EntryPool.resize(1183968);
|
||||
}
|
||||
else
|
||||
{
|
||||
Maps::EntryPool.resize(789312);
|
||||
}
|
||||
|
||||
// Apply new size
|
||||
Utils::Hook::Set<DWORD>(0x5BAEB0, Maps::EntryPool.size());
|
||||
|
||||
// Apply new pool
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x48E6F4, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x4C67E4, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x4C8584, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BAEA8, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BB0C4, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BB0F5, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BB1D4, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BB235, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BB278, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BB34C, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BB484, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BB570, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BB6B7, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BB844, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BB98D, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BBA66, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BBB8D, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BBCB1, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BBD9B, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BBE4C, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BBF14, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BBF54, Maps::EntryPool.data());
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BBFB8, Maps::EntryPool.data());
|
||||
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BAE91, Maps::EntryPool.data() + 1);
|
||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BAEA2, Maps::EntryPool.data() + 1);
|
||||
return *reinterpret_cast<Game::XAssetEntry**>(0x48E6F4);
|
||||
}
|
||||
|
||||
// dlcIsTrue serves as a check if the map is a custom map and if it's missing
|
||||
@ -1022,24 +969,6 @@ namespace Components
|
||||
// Load usermap arena file
|
||||
Utils::Hook(0x630A88, Maps::LoadArenaFileStub, HOOK_CALL).install()->quick();
|
||||
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_GAMEWORLD_SP, 1);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMAGE, 7168);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_LOADED_SOUND, 2700);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_FX, 1200);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_LOCALIZE_ENTRY, 14000);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_XANIMPARTS, 8192);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_XMODEL, 5125);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_PHYSPRESET, 128);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_PIXELSHADER, 10000);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_VERTEXSHADER, 3072);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_MATERIAL, 8192);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_VERTEXDECL, 196);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_WEAPON, WEAPON_LIMIT);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_STRINGTABLE, 800);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMPACT_FX, 8);
|
||||
|
||||
this->reallocateEntryPool();
|
||||
|
||||
// Dependencies
|
||||
//Maps::AddDependency("oilrig", "mp_subbase");
|
||||
//Maps::AddDependency("gulag", "mp_subbase");
|
||||
@ -1113,7 +1042,5 @@ namespace Components
|
||||
Maps::DependencyList.clear();
|
||||
Maps::CurrentMainZone.clear();
|
||||
Maps::CurrentDependencies.clear();
|
||||
|
||||
Maps::EntryPool.clear();
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,6 @@ namespace Components
|
||||
static bool SPMap;
|
||||
static UserMapContainer UserMap;
|
||||
static std::vector<DLC> DlcPacks;
|
||||
static std::vector<Game::XAssetEntry> EntryPool;
|
||||
|
||||
static std::vector<std::pair<std::string, std::string>> DependencyList;
|
||||
static std::vector<std::string> CurrentDependencies;
|
||||
@ -123,7 +122,5 @@ namespace Components
|
||||
static Game::dvar_t* GetSpecularDvar();
|
||||
static void SetSpecularStub1();
|
||||
static void SetSpecularStub2();
|
||||
|
||||
void reallocateEntryPool();
|
||||
};
|
||||
}
|
||||
|
@ -1034,17 +1034,6 @@ namespace Components
|
||||
// Don't read stats
|
||||
Utils::Hook(0x4875E1, 0x487717, HOOK_JUMP).install()->quick();
|
||||
|
||||
// Increase asset pools
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_MAP_ENTS, 10);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_XMODELSURFS, 8192);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_IMAGE, 14336);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_TECHNIQUE_SET, 0x2000);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_PIXELSHADER, 0x4000);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_VERTEXSHADER, 0x2000);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_VERTEXDECL, 0x400);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_FONT, 32);
|
||||
Game::ReallocateAssetPool(Game::XAssetType::ASSET_TYPE_RAWFILE, 2048);
|
||||
|
||||
// patch g_copyInfo because we're using so many more assets than originally intended
|
||||
int newLimit = 0x2000;
|
||||
int* g_copyInfo_new = Utils::Memory::GetAllocator()->allocateArray<int>(newLimit);
|
||||
|
Loading…
Reference in New Issue
Block a user