[ZoneBuilder] Fix one small thing in weapon writing, change how we search for assets in common_mp as using DB_EnumXAssets was missing some of them, and allow the weapon loading function see zonebuilder assets
This commit is contained in:
parent
5eb9996aea
commit
43456aedbd
@ -3,6 +3,7 @@
|
|||||||
namespace Components
|
namespace Components
|
||||||
{
|
{
|
||||||
thread_local int AssetHandler::BypassState = 0;
|
thread_local int AssetHandler::BypassState = 0;
|
||||||
|
bool AssetHandler::ShouldSearchTempAssets = false;
|
||||||
std::map<Game::XAssetType, AssetHandler::IAsset*> AssetHandler::AssetInterfaces;
|
std::map<Game::XAssetType, AssetHandler::IAsset*> AssetHandler::AssetInterfaces;
|
||||||
std::map<Game::XAssetType, Utils::Slot<AssetHandler::Callback>> AssetHandler::TypeCallbacks;
|
std::map<Game::XAssetType, Utils::Slot<AssetHandler::Callback>> AssetHandler::TypeCallbacks;
|
||||||
Utils::Signal<AssetHandler::RestrictCallback> AssetHandler::RestrictSignal;
|
Utils::Signal<AssetHandler::RestrictCallback> AssetHandler::RestrictSignal;
|
||||||
@ -69,6 +70,21 @@ namespace Components
|
|||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Game::XAssetHeader AssetHandler::FindTemporaryAsset(Game::XAssetType type, const char* filename)
|
||||||
|
{
|
||||||
|
Game::XAssetHeader header = { nullptr };
|
||||||
|
if (type >= Game::XAssetType::ASSET_TYPE_COUNT) return header;
|
||||||
|
|
||||||
|
auto tempPool = &AssetHandler::TemporaryAssets[type];
|
||||||
|
auto entry = tempPool->find(filename);
|
||||||
|
if (entry != tempPool->end())
|
||||||
|
{
|
||||||
|
header = { entry->second };
|
||||||
|
}
|
||||||
|
|
||||||
|
return header;
|
||||||
|
}
|
||||||
|
|
||||||
int AssetHandler::HasThreadBypass()
|
int AssetHandler::HasThreadBypass()
|
||||||
{
|
{
|
||||||
return AssetHandler::BypassState > 0;
|
return AssetHandler::BypassState > 0;
|
||||||
@ -116,7 +132,7 @@ namespace Components
|
|||||||
|
|
||||||
|
|
||||||
test al, al
|
test al, al
|
||||||
jnz finishOriginal
|
jnz checkTempAssets
|
||||||
|
|
||||||
mov ecx, [esp + 18h] // Asset type
|
mov ecx, [esp + 18h] // Asset type
|
||||||
mov ebx, [esp + 1Ch] // Filename
|
mov ebx, [esp + 1Ch] // Filename
|
||||||
@ -137,11 +153,30 @@ namespace Components
|
|||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
|
|
||||||
|
test eax, eax
|
||||||
|
jnz finishFound
|
||||||
|
|
||||||
|
checkTempAssets:
|
||||||
|
mov al, AssetHandler::ShouldSearchTempAssets // check to see if enabled
|
||||||
|
test eax, eax
|
||||||
|
jz finishOriginal
|
||||||
|
|
||||||
|
mov ecx, [esp + 18h] // Asset type
|
||||||
|
mov ebx, [esp + 1Ch] // Filename
|
||||||
|
|
||||||
|
push ebx
|
||||||
|
push ecx
|
||||||
|
|
||||||
|
call AssetHandler::FindTemporaryAsset
|
||||||
|
|
||||||
|
add esp, 8h
|
||||||
|
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz finishFound
|
jnz finishFound
|
||||||
|
|
||||||
finishOriginal:
|
finishOriginal:
|
||||||
// Asset not found using custom handlers, redirect to DB_FindXAssetHeader
|
// Asset not found using custom handlers or in temp assets or bypasses were enabled
|
||||||
|
// redirect to DB_FindXAssetHeader
|
||||||
mov ebx, ds:6D7190h // InterlockedDecrement
|
mov ebx, ds:6D7190h // InterlockedDecrement
|
||||||
mov eax, 40793Bh
|
mov eax, 40793Bh
|
||||||
jmp eax
|
jmp eax
|
||||||
@ -454,6 +489,11 @@ namespace Components
|
|||||||
Utils::Hook::Set<Game::XAssetEntry*>(0x5BAEA2, entryPool + 1);
|
Utils::Hook::Set<Game::XAssetEntry*>(0x5BAEA2, entryPool + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AssetHandler::ExposeTemporaryAssets(bool expose)
|
||||||
|
{
|
||||||
|
AssetHandler::ShouldSearchTempAssets = expose;
|
||||||
|
}
|
||||||
|
|
||||||
AssetHandler::AssetHandler()
|
AssetHandler::AssetHandler()
|
||||||
{
|
{
|
||||||
this->reallocateEntryPool();
|
this->reallocateEntryPool();
|
||||||
|
@ -39,8 +39,11 @@ namespace Components
|
|||||||
|
|
||||||
static void ResetBypassState();
|
static void ResetBypassState();
|
||||||
|
|
||||||
|
static void ExposeTemporaryAssets(bool expose);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static thread_local int BypassState;
|
static thread_local int BypassState;
|
||||||
|
static bool ShouldSearchTempAssets;
|
||||||
|
|
||||||
static std::map<std::string, Game::XAssetHeader> TemporaryAssets[Game::XAssetType::ASSET_TYPE_COUNT];
|
static std::map<std::string, Game::XAssetHeader> TemporaryAssets[Game::XAssetType::ASSET_TYPE_COUNT];
|
||||||
|
|
||||||
@ -55,6 +58,7 @@ namespace Components
|
|||||||
static void RegisterInterface(IAsset* iAsset);
|
static void RegisterInterface(IAsset* iAsset);
|
||||||
|
|
||||||
static Game::XAssetHeader FindAsset(Game::XAssetType type, const char* filename);
|
static Game::XAssetHeader FindAsset(Game::XAssetType type, const char* filename);
|
||||||
|
static Game::XAssetHeader FindTemporaryAsset(Game::XAssetType type, const char* filename);
|
||||||
static bool IsAssetEligible(Game::XAssetType type, Game::XAssetHeader* asset);
|
static bool IsAssetEligible(Game::XAssetType type, Game::XAssetHeader* asset);
|
||||||
static void FindAssetStub();
|
static void FindAssetStub();
|
||||||
static void AddAssetStub();
|
static void AddAssetStub();
|
||||||
|
@ -12,8 +12,12 @@ namespace Assets
|
|||||||
// let the function see temporary assets when calling DB_FindXAssetHeader during the loading function
|
// let the function see temporary assets when calling DB_FindXAssetHeader during the loading function
|
||||||
// otherwise it fails to link things properly
|
// otherwise it fails to link things properly
|
||||||
Components::AssetHandler::ExposeTemporaryAssets(true);
|
Components::AssetHandler::ExposeTemporaryAssets(true);
|
||||||
|
IWeapon::CurrentBuilder = builder;
|
||||||
|
|
||||||
header->data = Game::BG_LoadWeaponDef_LoadObj(name.data());
|
header->data = Game::BG_LoadWeaponDef_LoadObj(name.data());
|
||||||
|
|
||||||
Components::AssetHandler::ExposeTemporaryAssets(false);
|
Components::AssetHandler::ExposeTemporaryAssets(false);
|
||||||
|
IWeapon::CurrentBuilder = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +290,7 @@ namespace Assets
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer->saveMax();
|
buffer->saveMax(sizeof(Game::snd_alias_list_t*));
|
||||||
buffer->saveString(def->bounceSound[i]->aliasName);
|
buffer->saveString(def->bounceSound[i]->aliasName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -701,9 +701,9 @@ namespace Components
|
|||||||
|
|
||||||
if (zoneIndex > 0)
|
if (zoneIndex > 0)
|
||||||
{
|
{
|
||||||
Game::DB_EnumXAssetEntries(type, [&](Game::XAssetEntry* entry)
|
Game::XAssetEntry* entry = Game::DB_FindXAssetEntry(type, name.data());
|
||||||
{
|
|
||||||
if (!header.data && entry->zoneIndex == zoneIndex && Game::DB_GetXAssetName(&entry->asset) == name)
|
if (entry->zoneIndex == zoneIndex)
|
||||||
{
|
{
|
||||||
// Allocate an empty asset (filled with zeros)
|
// Allocate an empty asset (filled with zeros)
|
||||||
header.data = builder->getAllocator()->allocate(Game::DB_GetXAssetSizeHandlers[type]());
|
header.data = builder->getAllocator()->allocate(Game::DB_GetXAssetSizeHandlers[type]());
|
||||||
@ -715,7 +715,6 @@ namespace Components
|
|||||||
// Set the name to the empty name
|
// Set the name to the empty name
|
||||||
Game::DB_SetXAssetNameHandlers[type](&header, builder->getAllocator()->duplicateString("," + name));
|
Game::DB_SetXAssetNameHandlers[type](&header, builder->getAllocator()->duplicateString("," + name));
|
||||||
}
|
}
|
||||||
}, true, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user